https://ethereum.org/en/developers/docs/standards/tokens/erc-4626/
- a = amount to deposit
- B = balance of vault before deposit
- s = shares to mint
- T = total shares before mint
eQ: a+B / B = s+T/T
to find s (shares) we can simplify it to:
-
Cross-multiply: [ (a + B)T = (s + T)B ]
-
Distribute both sides: [ aT + BT = sB + TB ]
-
Subtract ( BT ) from both sides: [ aT = sB ]
-
Solve for ( s ): [ s = aT/B ]
s = aT/B
- a = amount to withdraw
- B = balance of vault before withdraw
- s = shares to burn
- T = total shares before burn
eQ: B-a/B = T-s/T
-
Cross-multiply: [ (B + a)T = (T - s)B ]
-
Distribute both sides: [ BT + aT = TB + sB ]
-
Subtract ( BT ) from both sides: [ aT = sB ]
-
Solve for ( a ): [ a = sB/T ]
a = sB/T
-
Initial Shares and Deposits:
- User 1 deposited 125 and has 125 shares.
- User 2 deposited 200 and has 200 shares.
- Total shares: 125 + 200 = 325 shares.
- Total initial deposits: 125 + 200 = 325.
-
Vault Yields:
- The vault yields 100, so the new total value of the vault is: [ 325 + 100 = 425 ]
-
Share Value:
- The new share value is: [ \text{New share price} = \frac{\text{Total value of the vault}}{\text{Total shares}} = \frac{425}{325} \approx 1.3077 ]
-
Withdrawals:
- Each user will withdraw an amount proportional to the shares they hold.
- User 1 has 125 shares.
- The value of User 1's shares: [ \text{Value of User 1's shares} = 125 \times 1.3077 \approx 163.46 ]
- User 2 has 200 shares.
- The value of User 2's shares: [ \text{Value of User 2's shares} = 200 \times 1.3077 \approx 261.54 ]
- User 1 can withdraw approximately 163.46.
- User 2 can withdraw approximately 261.54.
These values add up to the total vault value of 425, ensuring that the withdrawals are proportional to the shares held by each user.