Liquid Staking Basics
The exchange rate is used for deposits and reward distribution. The exchange rate of eSOL to SOL is determined by the ratio of staked SOL in the stake pool to the total eSOL supply. Every eSOL represents a share of ownership of the SOL pool.
Deposits do not change the exchange rate since we add new eSOL 1:1 to the amount deposited in SOL, so it keeps the rate constant. Yet, adding SOL rewards changes the exchange rate. It happens every epoch. A smart contract updates the exchange rate for each epoch based on changes in SOL deposits, distributed SOL rewards, and minted eSOL.
We use the process_update_stake_pool_balance() function to run once per epoch; this method calculates the current ROE number based on the updated epoch data. The calculations include the rewards earned in the previous epoch while the ROE is being calculated for the current epoch.
Other manipulations, like obtaining rewards, etc., are processed according to the standard SPL contract.