Pool owners may register and remove rewards distributors from the vaults in their pools. Rewards distributors are smart contracts which can distribute rewards among all of the liquidity positions in a specified vault (instantaneously or over time) and allow these rewards to be collected.
Reward distributors must conform to the
IRewardDistributorinterface. This includes a
payoutfunction which should transfer
amountof rewards to the
function payout(uint128 accountId, uint128 poolId, address collateralType, address sender, uint amount) external returns (bool);
For security reasons, the payout function should always revert unless
msg.senderis equal to Synthetix Core address.
A pool owner can then connect a rewards distributor to a vault with the
registerRewardsDistributorfunction. (Note that due to gas considerations, no more than 10 rewards distributors may be connected to a given vault at time.) To remove a rewards distributor, the pool owner can call the
Below is an example Rewards Distributor contract that can be used to develop your own.
Below is an example transaction that:
- 1.Registers a Rewards Distributor contract
- 2.to poolId 69
- 3.with SNX (on Optimism Goerli)
A registered rewards distributor can call the
collateralTypeparameters identify the relevant vault.
amountindicates the total amount of tokens to be distributed starting at the
durationseconds. Note that
durationmay be set to 0, such that the rewards are distributed instantaneously based on the pro-rata distribution at
start. A rewards distributor can call the
distributeRewardsfunction multiple times, adding to the rewards already distributed to those participating in the vault.
Anyone can static call the
claimRewardsfunction to see what an account ID can claim from a distributor registered to a specified vault, accounting for amounts previously claimed. Then, an address that owns (or has relevant permissions on) that account can call the
claimRewardsfunction. This, in turn, calls the
payoutfunction on the rewards distributor with the appropriate amount.