Saving
π What is Saving?
The Saving service allows users to earn time-based interest on their deposited assets. These assets are efficiently managed within the protocol to provide sustainable and stable returns.
Key Features:
Stable Yield: Powered by a time-based ESD Savings Rate (ESR).
Compound Growth: Accumulated interest is added to the principal continuously.
User-Friendly Interface: Simple deposit and withdrawal functionality.
π Key Concepts
1. ESR (Esd Savings Rate)
Definition: The continuous annual interest rate applied per second.
Management:
Governed by the protocol's governance mechanism.
Provides stable returns by accumulating interest over time.
Unit:
ray(fixed-point, (10^{27})).
DSR Calculation Formula
( r ): Per-second interest rate.
( Ξt ): Time elapsed since the last update.
2. CHI (Rate Accumulator)
Definition: Tracks the cumulative interest rate over time.
Role:
Used to calculate the total value of deposited assets, including interest.
Updated whenever the
dripfunction is called.
CHI Calculation Flow
( chi_next = chi_current \times r^{Ξt} )
( total_value = pie \times chi )
π οΈ How to Use
1. Deposit (Join)
Users can start earning savings by depositing their assets into the protocol.
Steps:
Call the
joinfunction on the smart contract.The deposited amount is stored in
pie, and interest is accumulated based onchi.
2. Withdraw (Exit)
Users can withdraw their deposits at any time.
Steps:
Call the
exitfunction.The total amount (principal + interest) is calculated using
chiand transferred to the user.
π‘ Key Benefits
Stable Returns:
Sustainable interest rate powered by protocol revenue.
Flexible Withdrawals:
Users can withdraw their savings anytime.
Governance-Controlled Rate:
ESR can be adjusted by governance to maintain protocol liquidity and stability.
π§βπ» Smart Contract Specification
Key Functions
join(uint256 wad):Deposits assets into the protocol.
wad: The amount to deposit.The normalized deposit is stored in
pie[msg.sender].
exit(uint256 wad):Withdraws assets from the protocol.
wad: The amount to withdraw.
drip():Updates the interest rate (
chi) and last update timestamp (rho).
file(bytes32 what, uint256 data):Sets the ESR value.
π Example: Earning with Saving
Initial Conditions:
DSR:
1000000002293273137447730714(approximately 7.5% annual interest rate).Deposit Amount: 1,000 ESD.
Over Time:
( Ξt = 1 year (31,536,000 seconds) ).
CHI Update: [ chi_next = chi_current * r^{31,536,000} ]
Final Asset Value:
1,000 ESD β approximately 1,075 ESD (7.5% growth).
Last updated