-
Notifications
You must be signed in to change notification settings - Fork 5
Storage
type delegator = address
type delegatorRecord = {
lpTokenBalance: nat,
accumulatedRewardPerShareStart: nat,
};
type claimedRewards = {
unpaid: nat,
paid: nat,
};
type plannedRewards = {
totalBlocks: nat,
rewardPerBlock: nat,
};
type farm = {
lastBlockUpdate: nat,
accumulatedRewardPerShare: nat,
claimedRewards: claimedRewards,
plannedRewards: plannedRewards
};
type addresses = {
admin: address,
lpTokenContract: address,
rewardTokenContract: address,
rewardReserve: address
};
type storage = {
farm: farm,
delegators: big_map(delegator, delegatorRecord),
farmLpTokenBalance: nat,
addresses: addresses
};
-
Keeps track of pool rewards that have been paid or are pending to be paid out
unpaid
paid
-
Configuration object set at origination, specifying how much of the reward token should be paid out every block. And how many blocks of lifetime the farm has.
The overall amount of the reward token distributed is calculated as
totalBlocks * rewardPerBlock
.totalBlocks
rewardPerBlock
-
(big) Map of delegator addresses and their staking balances & reward debts.
-
balance
Represents the total staked balance (of the staking token) of the current delegator.
-
stakingStart
Represents the accumulatedRewardPerShare at the time the delegator started staking (joined the staking pool), or has claimed the reward payout the last time.
-
-
Keeps track of the last time the pool state was updated. This is used to prevent duplicate pool state updates in the same block. Invariant of the system achieved thanks to the
lastBlockUpdate
is that the delegation rewards start accumulating only in then+1
block after depositing.E.g. if you deposit in
block 0
, you're only eligible for rewards fromblock 1
-
Keeps track of how many reward token each liquidity pool share (staked LP token) is worth. This number is recalculated at every pool update.
-
Address of the administrator who has permission to update
plannedRewards
(total blocks & reward per block) and set another address as admin. -
Address of the token being staked, originally an LP token from a DEX.
-
Balance of the
lpTokenContract
tokens for the current farm contract. This standalone "ledger" entry exists to avoid exploits with operations that may introduce issues & overhead due to Tezos' message passing architecture (BFS), specifically when callingtokenContract%getBalance
. -
Address of the reward token contract.
-
Address of the account that holds the reward tokens to be paid out. This account gives an allowance to the farm contract through the
approve
method of theFA1.2 contract
.