Single Sided Reinsurance Pool
Its called SSRP in short form
Last updated
Its called SSRP in short form
Last updated
The Single Sided Reinsurance Pool (or SSRP in short) contract is based on the MasterChef v2 accumulated system to give out block rewards as an incentive for stakers who stake their funds and take on insurance coverage risks. For the block rewards, a constant number of UNO is dispersed. To calculate the per user rewards i.e. the accumulated rewards per user the concept of accumulated UNO per share has been implemented. This share fluctuates according to mint or burn i.e. stake or unstake functionality done by the users.
Whenever users deposit or withdraw their funds in the pool instead of storing all staking and unstaking data in a mapping, the reward debt concept is brought into use to calculate Block rewards fairly for each user based on their contribution to the pool.
Reward debt is a representation of the reward which a user shall get if he had joined the pool from the first block. This rewardDebt will changes according to whenever deposit or withdraw happens. For example:
If the UNO pool started at block F and user A staked at block G => Then the rewardDebt of the user is the reward the user would have accumulated from block F to G.
When submitting a withdrawl request at block H, the pending reward for user A will be calculated by subtracting the rewardDebt from the total reward amount determined by accumulated UNOs per share till block H.
accUnoPerShare - LP tokens are minted or burned whenever a user stakes or withdraws their funds from the UNO risk pool and so it will represent the user's share in the risk pool. accUnoPerShare is the accumulated UNOs per share, times 1e12(ACC_UNO_PRECISION).
unoMultiplierPerBlock - is the factor which will calculate the accumulated UNOs per LP share from the last reward block to the current block. It is defined by admin in the setUnoMultiplierPerBlock function of SSRP at the beginning of the pool.
lastRewardBlock - It is referred to as the current block when the user is committing the withdraw action.
rewardDebt - It keeps track of how much the user is owed or has been credited already.
lpPriceUno - It is the factor that represents Uno value per LP token, which is upgraded whenever policy claim occurs.
lpPriceUno = 1e18 * [UNO balance of the pool / LP token totalSupply]
From this formula, the UNO value(UNOx) of the LP token x(LPx):
UNOx = LPx * lpPriceUno / 1e18
LPx = UNOx * 1e18 / UNOx
We set the initial lpPriceUno to 1 now.
ACC_UNO_PRECISION = 1e18
To distribute the block rewards the admin will call the createRewarder
function, this function will deploy a rewarder contract which will house the funds for distribution as rewards. This function can only be called by the admin
_operator : refers to the address which will have admin access to the rewarder contract
_factory : refers to the address of the factory from
_currency : refers to the address of reward token which will be deposited in the rewarder contract
We will produce synthetic pools, which the users can stake their SSRP or SSIP Lp tokens and get additional reward in stable coin(USDC).
The function will create SyntheticSSRP pool through SyntheticSSRPFactory contract.
This function can only be called by the admin.
_owner: refers to the owner's address to control SyntheticSSRP contract
_factory: refers to the SyntheticSSRPFactory contract address to create SyntheticSSRP.
When a user invest i.e. stakes into the pool they are issued with LP tokens specific to that pool. LP tokens being a representation of the user's investment and is burned when user unstakes his funds. To create the ERC 20 standard LP token for the pool the createRiskPoolFunction
is called. This function can only be called by the admin
_name : refers to the name of the ERC 20 LP token
_symbol : refers to the symbol of the ERC 20 LP token
_factory : refers to factory address
_currency : currency of the pool
_rewardMultiplier : It is the factor, which will be used to calculate accumulated UNOs per LP share from the last reward block to the current block.
Instead of storing all staking and unstaking data per user the concept of reward debt is implemented. The rewardDebt concept is fuelled from accUnoPerShare, lastRewardBlock from MasterChef V2 contracts. When a user withdraws or deposits funds the updatePool
function is called which updates the accUnoPerShare, lastRewardBlock.
block diff = current block number - lastRewardBlock(n)
unoReward = block diff * unoMultiplierPerBlock
accUnoPerShare(n+1) = accUnoPerShare(n) + unoReward * ACC_UNO_PRECISION / LP tokenSupply
lastRewardBlock = current block
To participate in the Synthetic SSIP/SSRP pool and be eligible for rewards in USDC the user will call the enterInPool
function.
_amount : the amount of funds being deposited
rewardDebt(n+1) = rewardDebt(n) + (staking amount * accUnoPerShare(n+1) / ACC_UNO_PRECISION
To unstake the funds from the SSRP pool the users are required to call the leaveFromPoolInPending
function. After this function is called the user is put in a 10 day waiting list after which he can call the leaveFromPending
function upon which his funds will be transferred back to his wallet.
_amount : the amount of LP tokens being unstaked
accumulatedUNO = LP balance of the user * accUnoPerShare / ACC_UNO_PRECISION
pending UNO reward = accumulatedUNO - rewardDebt of the user
rewardDebt(n+1) = accumulatedUNO - (withdraw amount * accUnoPerShare) / ACC_UNO_PRECISION
To transfer back the funds from to the user's ownership the user's are required to call the leaveFromPending
function
To harvest rewards the user shall call the harvest
function. Upon calling this function the rewards accumulated by the user shall be transferred back to the user
_to : the address of the user where the funds shall be transferred
To settle a claim and take out funds from the pool the policyClaim
function is constructed. The ClaimAssessor address is set when deploying a contract and is upgradable by the contract owner. While settling a claim 2 situations can arise
The claim amount is less than the UNO balance of the pool, in that case the claim amount will be transferred to the claim requester.
The claim amount is larger than the UNO balance of the pool, in that case the amount with a substraction of 100 $UNO from the pool will be transferred to the claim requester.
This function can only be called by UNO claim assessors
_to : refers to the address of the claimee
_amount : refers to the amount of funds being dispersed to the claim requester
If the user changes his mind and want to keep continue staking in the SSRP pool, the user shall call the cancelWithdrawRequest
function
The user can migrate his staked capital to another risk pool LP token in the future.
The migrate contract address should be set by admin in advance. When the user run migrate function, his block reward will be calculated and transferred to his wallet.
The user’s withdrawal request is not empty and its lock time is ended, in that case, the withdrawal request amount also will be transferred to the user.
The user’s withdrawal request is not empty and its lock time is not ended, in that case, the user’s WR will be canceled.
After implementing withdraw request, other UNO balance will be moved to migrate contract and the user’s origin LP balance will be burnt.
The migrate function is a back up solution put in case of an unforeseen situation occurs.
The user can transfer his LP token which the user received at staking UNO into SSRP.
When transferring LP token, the user's pending reward till the time will be transferred to his wallet and then rewardDebt of the sender and recipient will be adjusted with the transferring amount.
When this function is called the users withdrawal request is calculated and the lpTransfer is only allowed when the tokens being transferred is not involved in the withdrawal request
_from: refers to the address transferring the LP tokens
_to: refers to the recipient address of the LP tokens.
_amount: refers to the amount of LP tokens being transferred.
The future goal of SSRP is to allow investments in any rather popular currencies like ETH, DAI, USDC, UST, mUSD, etc and allow them to take on insurance coverage risk and get rewarded in $UNO block rewards.