Saving ESD
📘 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
drip
function 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
join
function 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
exit
function.The total amount (principal + interest) is calculated using
chi
and 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