Skip to content

Shares and the exchange rate

The vault keeps two running totals:

  • C = total_coin_in, the tracked value of the whole pool (idle + deployed), in base units.
  • S = the total supply of share tokens (samSUI / samUSDC).

The price of one share is C / S. Everything below is just careful rounding around that ratio.

When you deposit a net amount a (after the deposit fee), the shares you receive are:

shares={aif S=0 or C=0(first deposit, 1:1)aSCotherwise\text{shares} = \begin{cases} a & \text{if } S = 0 \text{ or } C = 0 \quad(\text{first deposit, } 1{:}1)\\[4pt] \left\lfloor \dfrac{a \cdot S}{C} \right\rfloor & \text{otherwise} \end{cases}

Then the pool grows by your deposit and the supply by your shares:

C+=a,S+=sharesC \mathrel{+}= a, \qquad S \mathrel{+}= \text{shares}

The share count is rounded down. Any sub-share remainder stays in the pool (it benefits all holders), never minted to you.

When you redeem s shares, the underlying you receive (before the withdraw fee) is:

underlying=sCS\text{underlying} = \left\lfloor \dfrac{s \cdot C}{S} \right\rfloor

Then:

C=underlying,S=sC \mathrel{-}= \text{underlying}, \qquad S \mathrel{-}= s

Again rounded down, so the tiny remainder stays with the vault rather than being over-paid to you.

When the vault earns, protocol interest, harvested rewards, or a vesting incentive, the earned amount e is added to the pool without minting any shares:

C+=e,S unchangedC \mathrel{+}= e, \qquad S \text{ unchanged}

Since the price is C / S and only C grew, every share is now worth more. This is how your balance accrues yield: not by your share count going up, but by each share redeeming for more underlying over time.

Because minting rounds down and burning rounds down, a deposit immediately followed by a withdrawal always returns slightly less than you put in (the dust stays in the pool). There is no rounding direction that pays a depositor more than their fair share, so the share price can only move up from yield, never be gamed by deposit/withdraw cycles.

Suppose the pool is C = 1_000 USDC-units and S = 1_000 shares (price 1.0).

  1. The vault earns 200 from interest: C = 1_200, S = 1_000. Price is now 1.2.
  2. You deposit 600: shares = ⌊600 · 1000 / 1200⌋ = 500. Now C = 1_800, S = 1_500.
  3. You hold 500 shares worth 500 · 1800 / 1500 = 600, exactly what you put in, at the higher price. Later, as C keeps growing, those same 500 shares redeem for more.