Skip to content
This repository has been archived by the owner on May 21, 2024. It is now read-only.

Custom HandleCredit implementation for block author rewards using on-chain DEX #100

Open
stiiifff opened this issue Dec 22, 2022 · 0 comments
Labels
enhancement New feature or request

Comments

@stiiifff
Copy link
Contributor

The Trappist runtime uses the FRAME pallet-asset-tx-payment pallet to support paying for transaction fees in either the chain's native token or an arbitrary asset. This pallet is configured with a FungiblesAdapter that provides an implementation of the OnChargeAssetTransaction trait, and is relying on the AssetsToBlockAuthor (from Cumulus) implementation of the HandleCredit trait. This implementation is rather simplistic as it attempts to transfer the transaction fees to the block author, and if it fails, the fees are burned.

This issue proposes to create an example credit handler implementation with a more refined logic, that leverages Trappist's on-chain DEX:

  • This implementation will attempt to directly transfer 20% of the fees to the block author. This is a short-term incentive to reward collators.
  • The other 80% is swapped for native tokens using the on-chain DEX, if there exists a liquidity pool between the asset and the native token, and based on the current rate between the two. The credit handler will then call the add_liquidity function of the DEX to add liquidity to the pool on behalf of the block author's account. This is a longer-term incentive to reward collators, with a self-reinforcing positive (feedback) loop as LP providers are rewarded in LP tokens and receive a portion of fees for every swap operations (based on their LP tokens share).
  • If any of these above fail, the fees are burnt (as previously).

This behavior mimics the block author rewards of Polkadot where 20% of the transaction fees go to the block author and 80% go to the on-chain treasury (the Trappist runtime does not have a Treasury).

Note: the pallet-dex should be be modified to define a trait for basic DEX operations (inquire whether a liquidity pool exists, add liquidity to a pool, perform a swap operation) so as to allow for a loosely-coupled integration with the credit handler (and a call to the add_liquidity & swap operations without the origin checks performed in the dispatchable calls).

Note: this is inspired by Alex Popiak's presentation at sub0 2021, where he mentioned (at the end of the presentation) some possible future improvements of the current AssetsToBlockAuthor implementation: see Statemint - Adding Support for Paying Transactions in Assets

@stiiifff stiiifff added the enhancement New feature or request label Dec 22, 2022
@stiiifff stiiifff added this to the Trappist M2 / XCM v3 milestone Feb 17, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant