Rewards
The protocol allows for vaults to be connected to reward distributors by the pool’s owner using the rewards manager. This allows rewards (typically tokens) to be provided across liquidity positions participating in a pool’s vault (instantaneously or over time) pro-rata based on their amount of shares in the corresponding vault.
Rewards Distributor
Reward distributors must conform to the IRewardDistributor
interface. This consists of:
function payout(uint128 accountId, uint128 poolId, address collateralType, address sender, uint amount) external returns (bool);
- A function which should transferamount
of rewards to thesender
address.
For security reasons, the payout function should revert unless msg.sender
is equal to Synthetix’s Core System address.
Rewards Manager
A pool owner can then connect a rewards distributor to a vault with the registerRewardsDistributor
function. 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 removeRewardsDistributor
function.
A registered rewards distributor can call the distributeRewards
function. The poolId
and collateralType
parameters identify the relevant vault. amount
indicates the total amount of tokens to be distributed starting at the start
timestamp over duration
seconds. Note that duration
may 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 distributeRewards
function multiple times, adding to the rewards already distributed to those participating in the vault.
Anyone can call the getAvailableRewards
function 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 claimRewards
function. This, in turn, calls the payout()
function on the rewards distributor with the appropriate amount.