Deposit Management
The Backstop contract allows users to deposit backstop tokens and allocate them towards different pools.
Storing User Backstop Deposits
Users backstop deposits are allocated to individual pools. Their deposits are stored by the Backstop contract in a hashmap where the key is a PoolUserKey
struct
and the value is a UserBalance
struct
Deposits
Users deposit backstop tokens into the backstop contract using the deposit()
function which accepts a deposit amount and a pool address. The specified amount will be sent to the backstop contract, and recorded as a user's deposit in the specified pool. The deposit amount is accounted for as a number of shares, calculated as:
The number of backstop tokens each share is worth fluctuates based on the behavior of the pool the deposit is allocated to
Share value increases when the associated pool pays interest to the backstop as this increases the pool's
total_tokens
Share value decreases when deposits are used to cover bad debt as this decreases the pool's
total_tokens
Once the deposit is finalized the pool's total_tokens
will be increased by the deposit amount and the pool's total_shares
will be increased by the number of shares issued.
deposit()
calls will fail if the user attempts to deposit into a pool not listed as a deployed_pool
by the designated Pool Factory contract
Withdrawals
Backstop withdrawals are handled in two steps.
The user calls
queue_withdrawal
with the amount they wish to withdraw and the pool they wish to withdraw from. This will queue a withdrawal for the specified amount of tokens from the specified pool.
While deposits are queued for withdrawal the user will no longer receive emissions from the backstop. They will still receive their share of interest from the pool.
User waits for the 21-day withdrawal queue to expire
At any point, the user can cancel a queued withdrawal using the cancel_withdrawal()
function.
A withdrawal queue is required to prevent backstop depositors from leaving a pool before their backstop deposits can be used to cover bad debt.
User calls
withdraw()
to withdraw the shares. This will transfer the tokens to the user and reduce the pooltotal_tokens
andtotal_shares
accordingly.Tokens received are calculated as:
Last updated