Subscriber Rewards
Creators have the option to offer rewards to their subscribers when deploying a subscription contract. The reward model is designed to incentivize early adoption of a subscription, but is completely optional. There are a few key pieces here:
- Reward Allocation
- Reward Share Issuance
- Reward Redemption
- Reward Share Slashing
When configured, reward shares are issued to subscribers when they mint or renew a subscription. The amount of shares issued depends on the reward multiplier and the number of tokens transferred to the reward pool. Rewards can be redeemed by share holders in proportion to their share of the pool.
Reward Allocation
Each tier in a subscription contract can have a rev share percentage. This percentage is applied to purchases for the tier. Tokens are allocated to the reward pool for reward share holders to redeem.
Reward Share Issuance
Reward issuance is determined by a reward curve, the time of mint, and the amount of tokens allocated to the reward pool upon mint. Eg: tokensAllocatedToRewardPool * curveMultiplier
.
Reward curves are used to calculate a reward multiplier, which is used to determine how many shares are issued to the minter. The curve is a decaying exponential function with an optional floor. Here is a playground to see how multipliers decay from period to period. See tiers for settings curves.
Reward Redemption
Rewards are redeemable for tokens. Subscribers can redeem their reward tokens by invoking the transferRewards
on a subscription contract.
The amount of redeemable tokens depends on the total amount of rewards issued, the number of tokens in the reward pool, and previous claims for the user.
The denominated reward token is the same as the subscription token. For example, if a user mints a subscription with DAI, the reward token is also DAI. Tokens are allocated to the reward pool on every mint (if configured).
import {
prepareTransferRewards
} from '@withfabric/protocol-sdks/stpv2';
const transfer = await prepareTransferRewards({
contractAddress: '0x...',
account: '0x...', // reward share holder account
})
const receipt = await transfer();
Reward Slashing
The creator has the option to enable or disable reward slashing in addition to configuring a slash grace period.
When slashing is enabled, reward share holders which fail to to renew are subject to share slashing. When slash is called, their entire reward share is burned and active reward holders receive a proportional increase in their rewards.
This is designed to incentivize loyalty and dissensenitivize farming.
Creating a Reward Curve
Each tier can be configured to use a specific reward curve. When creating a tier, the sender must specify rewardCurveId
and it must exist.
Only the owner and manager can create reward curves. A contract can have no more than 256 reward curves. id 0 - 255.
import {
prepareCreateRewardCurve
} from '@withfabric/protocol-sdks/stpv2';
const create = await prepareCreateRewardCurve({
contractAddress: '0x...',
curve: {
numPeriods: 6, // number of periods of decay
formulaBase: 2, // base of the formula 2 ^ N periods
periodSeconds: 36000, // number of seconds in a period
startTimestamp: 0, // start timestamp for the curve (will be set to block.timestamp if 0)
minMultiplier: 0, // minimum multiplier for the curve (0 means no new distribution after the curve ends)
},
})
const receipt = await create();
Yielding Rewards
The reward pool balance can be increased by calling yieldRewards
. This function allows callers to add tokens to the reward pool without minting a subscription.
Creator Issued Shares
It's possible for the creator to issue reward shares to accounts. This can be done by calling issueRewardShares
. This is useful for migrating reward shares from a previous contract, or for rewarding users for actions other than minting.