|
1 | | -# Restaking V2 |
| 1 | +# Staking |
2 | 2 |
|
3 | | -This program was built to make it easier to keep track of deposits to the restaking vaults and make use of fungible receipt tokens as opposed to using NFTs in previous version which had a few drawbacks for it to be used as an yield for the rollup. |
| 3 | +This program was built to allow stake MANTIS tokens for anyone. |
4 | 4 |
|
5 | | -The drawbacks of the previous restaking program |
6 | | -- The depositors were given an NFT as a receipt token which meant that there were no partial withdrawals. |
7 | | -- Since the users could choose the validator to which they deposit to, the token deposited to one validator is different from the token deposited to another validator. Which means if the token is restaked and bridged to the rollup, then there would be a token for each validator even if they are same token. |
| 5 | +# Rewards for staking: |
| 6 | +Admin able to call submit_epoch_rewards_by_admin transaction to deposit funds as rewards for next epoch. Epoch is the timeslot that admin specified during initiation of staking contract. |
8 | 7 |
|
9 | | -For example: JitoSOL deposited to validator A and B would be different on rollup even though it is the same token on Solana. |
| 8 | +# Modes: |
| 9 | +- Mode 1. User stake their token into the contract and staking's PDA hold users stake untill user withdraw it. |
| 10 | +- Mode 2. (liquid staking version) User stake MANTIS and recieves back lsMANTIS based on exchange rate lsMANTIS/MANTIS |
10 | 11 |
|
11 | | -So the new restaking program was built specifically to support restaking of tokens before bridging to rollup and use fungible receipt tokens. |
12 | | -These are changes which were introduced in the new version. |
13 | | -- Users cannot choose which validator they delegate their stake to since their stake is equally divided among the validators specified in the program. |
14 | | -- If one of the validator gets slashed, the amount is slashed equally among the validators. |
15 | | -- A fungible receipt token is issued instead of a non fungible one. |
16 | | -- There is no unbonding period since all the validators get slashed equally. |
17 | | -- Allow deposits of tokens other than LSTs with the use of oracles. |
| 12 | +Admin can turn of/on any of this modes anytime. |
| 13 | + |
| 14 | +Vesting/Staking connection: |
| 15 | +Only staking mode1 (non liquid staking version) communicates with vesting contract to notify via CPI user's stake/unstake amounts. |
| 16 | + |
| 17 | +# EpochsAccount |
| 18 | + |
| 19 | +EpochsAccount is the PDA that correspond to specific epoch, so epochs changed each X time depends on admin settings. When admin submits rewards for each next epoch then admin also create EpochsAccount to store: |
| 20 | +- how many rewards should be distributed to stakers of that epoch |
| 21 | +- amount of tokens that will join as an active stakes in next epoch |
| 22 | + |
| 23 | + |
| 24 | +# Claim rewards: |
| 25 | + |
| 26 | +- Mode 1 (non liquid staking version) user should manually call claim_reward_mode_1 instruction to claim reward for all epochs in past that they participates as an active stakers. |
| 27 | + |
| 28 | +- Mode 2 (liquid staking version) where 2 tokens participate in the process lsMantis and Mantis. initial lsMantis:Mantis ration is 1:1. Once Admin submit rewards for epoch the price of lsMantis going up compared to Mantis because lsMantis contains accomulative rewards for all prev epochs. |
| 29 | + |
| 30 | +# Unstaking |
| 31 | + |
| 32 | +- Unstaking in mode 1 (non liquid staking). User call unbond to usntake and then wait unstaking period(specified by admin during initialization process). After unstaking period user can call withdraw unbonding to recieve Mantis back. |
| 33 | + |
| 34 | +- Mode 2 (liquid staking). User executes unbond_staking_mode_2 to burn lsMantis and only after usntaking period will be able to executues withdraw_staking_mode_2 to recieve back Mantis back. |
| 35 | + |
| 36 | + |
| 37 | +# CPI call to vesting contract |
| 38 | + |
| 39 | +Only mode 1 (non liquid staking) stake and unstake instractuction call update_stake CPI on vesting contract to update stake/unstake position of user. |
| 40 | + |
| 41 | +Stake/unstake has 2 versions: |
| 42 | + |
| 43 | +- the version that executes CPI update_stake to notify vesting contract |
| 44 | + |
| 45 | +- the version that NOT executes CPI update_stake |
| 46 | + |
| 47 | +Because some users does not participate in vesting schedules they do not need to notify vesting contact and UI are not forced to pass list of accounts of vesting contract for that user and able to call stake/unstake version that not related to vesting contract at all. |
18 | 48 |
|
19 | | -This program can only be called by the bridge contract. If people just want to restake directly and dont want to bridge, they can do it via restaking-v1 program. |
20 | 49 |
|
21 | | -## Oracles |
22 | 50 |
|
23 | | -For tokens others than LSTs which have a different value than SOL, we need to use oracle to get their current price and then update the stake. But since the stake is recorded in lamports in the guest chain, everytime the price changes we would need to update the stake. To do this, we store the delegations of the particular token locally and get the price on every interval set during initialization. Every time the price is updated, we calculate the difference and update the price on the guest chain. This would make sure that the stake on guest chain is always up to date. Whenever new deposits are made, it would use the stored price rather than from the oracle. But if the price is stale then the deposit would be rejected. This is a better way of updating the stake using oracle where we need to update it once for all the deposits for a particular token during an interval. |
|
0 commit comments