Withdrawal Amount Calculations
How to calculate the withdrawal amount?

### Definitions:

• Interest (I): the interest earned by the user from the protocol and has not been withdrawn yet
• Total Withdrawal Amount (TWA): the amount deducted from the deposit balance
• Interest Reserve (IR): the amount of interest reserved for the protocol and only be deducted when the user withdraws the interest
• Withdrawal Amount (WA): the final amount transferred to the user's wallet after the deduction of interest reserve from the total withdrawal amount
• Interest Reserve Factor (IRF): the ratio between interest reserve and the total withdrawal amount.
When users withdraw funds from the savings contract, the interest will always be deducted first from the users' deposit balance. And there is a portion of the interest that will be reserved from users' deposit balance for the protocol upon the withdrawal of any interest. If the user didn't withdraw any interest, the reserved interest would be kept in the user's account and continue to generate interest. The interest reserve is only a portion of interest earned through the platform.
Calculations:
$Total Withdrawal Amount =Withdrawal Amount +Interest Reserve$
If
$Total Withdrawal Amount <= Interest$
, then
$Interest Reserve=Total Withdrawal Amount*Interest Reserve Factor$
If
$Total Withdrawal Amount > Interest,$
then
$Interest Reserve=Interest*Interest Reserve Factor$
$0<=IFR<=1$