Open Action | Rewards Swap
Introduction
Rewards Swap lets you create incentivized swaps for your token. To start you need a UniswapV3 poool for the token that you want to shill. Then you can create a Shill2Earn pool by transferring in tokens to be disbursed as rewards and setting some parameters
Now a user can initialize the action on their post by passing in the index of the rewards pool to point to. They can also opt to share some of the rewards with the swapper. When the action is processed the user will pass in the Uniswap path to swap in through and the swap is called on the Uniswap Router. Rewards are doled out to the publication owner, the acter (if the owner has opted to share rewards), and the first profile in the mirror referrals array, if there is one.
You can also select a token when initializing your post that doest not have a pool. In this case the post creator will get .25% of incoming swaps as a reward.
Users can still act on the publication even after the rewards pool is used up and they will be able to swap but no rewards will be given out.
The post creator can opt to share some of their reward with the client also. This is done by setting the sharedRewardPercent
in the initializePublicationAction
call. When acting on the publication the client can inject their recipient address into the action module data and the specified percent of the reward will be sent to them.
Handler
The @madfi/lens-oa-client
npm package exports a class called RewardsSwapAction
that can be used to simplify interactions with the Rewards Swap Lens Open Action.
Instantiate class
The class needs to be instantiated with a environment config (testnet or production), the profile id and publication id of the publication to act on and then the authenticated profile id of the actor.
Helper Methods
There are several helper methods that can be used to access relevant data.
Get active reward pools: returns rewards pools that a new publication can be pointed to to begin earning swap rewards
Get user balances: returns the balances of some common quote tokens on Polygon (WMATIC, USDC, USDT, DAI, WETH) for a given wallet address
Get the params for the post being acted on: returns the params for the specified post given profile and pub ids
Get splits from the token out: returns the token amounts that go to each party based on the
amountOut
value of a swap. The args can be determined from the params of the post and the params of the rewards pool (if there is one, otherwise from the direct promotion params specified in the post). Reward pool params can be passed in as zero for direct promotions and they will be ignored.
Get splits from the token in: there is only one split that happens on the token in, and that is the protocol fee. Call this function to get the exact value
Create a new rewards pool. Requires token allowance to be approved on the Rewards Swap contract first in order to be transferred into the pool
Common tokens on Lens and their info (name/logo/ticker) can be found at this token list: https://www.storj-ipfs.com/ipfs/bafkreifgpzc4wotzfs73iytn7exnfm7bx454gndeypzg5xi6vjqxgiv2lq
Encode Module Data
Encode module init data:
Encode act data. If you don't know the path for a given input and output token then you can use the Uniswap alpha router to find one - https://docs.uniswap.org/sdk/v3/guides/swaps/routing
If you want to encode the init or act data directly here is what you'll need:
Deployments
Testnet
https://mumbai.polygonscan.com/address/0x8a3fFD86C4409Eb3c3b94DCC5219024CCf6C6179
Mainnet
https://polygonscan.com/address/0x3394E78a3389b1f0216F30fA0613f4975D0573C3
Last updated