The deposit
function takes tokens and returns ownership claims for a certain fraction of the assets held in the strategy.
The flow is next:
Pull in tokens (ETH, USDC, and oSQTH) from the sender in a proportion same as the current strategy holdings
Poke positions so the vault's current holdings are up to date
shares=sharePricedepositorValueβ where share price calculated as:
sharePrice=totalSupplytotalValueβ and Value calculated in ETH terms as:
value=ethAmount+EthUsdcPriceusdcAmountβ+osqthAmountβ
OsqthEthPrice β4. Check deposit cap
5. Mint shares to user
Example
Suppose that Alice would like to deposit 10 ETH and match it with the necesasary amount of USDC and oSQTH.
The current strategy holdings are 53.4 ETH, 45681 USDC, and 216.3 oSQTH.
After the Alice's deposit there will be 63.4 ETH, that need to be matched with:
ratio=EthBalanceEthToDepositβ=53.410β=0.1872 UsdcToDeposit=UsdcBalanceβratio=45681β0.1872=8551.5 OsqthToDeposit=OsqthBalanceβratio=216.3β0.1872=40.49 βAt the current prices of ETH/USDC 1500 and oSQTH/ETH 0.085, with the total supply of shares = 100, there will be minted:β
depositorValue=10+8551.5/1500+40.49β
0.085=19.14totalValue=63.4+45681/1500+216.3β
0.085=112.24Β shares=totalSupplyβ
TotalValuedepositorValueβ=100β
112.2419.14β=17.053 βTo simplify the deposit we introduce a deposit helper, that takes the user's wETH and automatically swaps it to a set of wETH, USDC, and oSQTH targeting the required strategy proportion.