Single Sided Insurance Pool

Introduction

Built on a synonymous structure to Uno's SSRP pool. The Single Sided Insurance Pool (SSIP in short) will be a direct insurance providing pool. The stakers of these pools will be directly responsible for the policies being sold on the basis of the SSIP, the TVL of the pool with the leverage ratio will determine the capacity of the pool to insure and sell policies.

Contract Architecture

Contract Functions

The SSRP and SSIP pool are architecturally alike interms on staking and unstaking functions since they both are based on Master Chef V2 contracts, but the SSIP pools have an additional Capital Agent contract brought into implementation. This is because funds in the SSIP pool are leveraged and use concepts like MCR (Minimum Calculation Ratio)and MLR (Maximum Leverage Ratio) for which additional calculation is required.

Create Rewarder

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

    function createRewarder(
        address _operator,
        address _factory,
        address _currency)

Input variables :

  • _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

Create Risk Pool

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

    function createRiskPool(
        string calldata _name,
        string calldata _symbol,
        address _factory,
        address _currency,
        uint256 _rewardMultiplier
    )

Input variables :

  • _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.

Update Pool

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.

function updatePool()

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

Enter in Pool

To participate in the Synthetic SSIP/SSRP pool and be eligible for rewards in $UNO the user will call the enterInPool function. When the enterInPool function is called the SSIPStaking function in the Capital Agent is also called to update the total capital amount(TVL of the pools), which will be used to check if the pool has enough capacity to provide coverage for the particular to be bought policy.

function enterInPool(uint256 _amount)

Input variables :

  • _amount : the amount of funds being deposited

rewardDebt(n+1) = rewardDebt(n) + (staking amount * accUnoPerShare(n+1) / ACC_UNO_PRECISION

Leave From Pool In Pending

To unstake the funds from the SSIP 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.

At the moment, the total capital and withdraw request amount are checked by MCR(Minimum Capital Ratio) in the CapitalAgent.

totalCapital - withdrawAmount >= totalCapital * MCR

function leaveFromPoolInPending(uint256 _amount)

Input variables :

  • _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

Leave From Pending

To transfer back the funds from to the user's ownership the user's are required to call the leaveFromPending function. When this function is called the SSIPWithdraw function in the Capital Agent is also called to check if the pool would have enough capital to insure present active policies, only after a safe check from the Capital Agent the request is approved.

Then, total capital amount also will be updated in the CaptialAgent because capital in the pool is decreased.

function leaveFromPending()

Harvest

The user can harvest his rewards at any time.

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

function harvest(address _to)

Input variables :

  • _to : the address of the user where the funds shall be transferred

Policy Claim

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.

While handling this policyClaim, total capital amount in CapitalAgent is decreased.

This function can only be called by UNO claim assessors

function policyClaim(address _to, 
        uint256 _amount)

Input variables :

  • _to : refers to the address of the claimee

  • _amount : refers to the amount of funds being dispersed to the claim requester

Cancel Withdraw Request

If the user changes his mind and want to keep continue staking in the SSRP pool, the user shall call the cancelWithdrawRequest function

function cancelWithdrawRequest()

Migrate

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 has the pending withdraw request and its lock time is over(10 days), in that case, the user's WR(withdraw request) will be transferred to his wallet.

  • The user's withdrawal request is not empty and its lock time is not ended , in that case, the user’s WR will be cancelled.

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.

function migrate()

LP Transfer

The user can transfer his LP token which the user received at staking UNO into SSIP.

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 user's withdrawal request is calculated and the lpTransfer is only allowed when the tokens being transferred is not involved in the withdrawal request

function lpTransfer(
        address _from,
        address _to,
        uint256 _amount)

Input variables:

  • _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.

Last updated