Architecture
Multiswap runs as a router with installed modules. The Router maps function
selectors to module contracts. Calls execute by delegatecall, so installed
modules share the Router storage context.
Core Modules
- Pool: initializes pool state, target token, treasury, surplus accounts, anchors, and deposit phase prep/start.
- PoolState: exposes read models for pool state, epoch state, reserves, scale, stake, anchors, and deposit phase flags.
- Deposit: owns user deposits, refund, seal, settle, claim, and claimable amount reads.
- QuoteParams: stores quote parameters and exposes reserve-asset quote inputs.
- QuoteMultiswap: computes multiswap quotes from current reserve state.
- Multiswap: executes user swaps by quoting internally, moving ledger balances, and wrapping or unwrapping external assets when needed.
Ledger State
The pool is ledger-native. Important ledger groups include:
Reserve AssetsReservesSurplusProtocolStakeRewardsRecoveredUser DepositsUnclaimed
Reserve assets are debit-side tokens. Claim tokens are credit-side tokens. The target token can be either a reserve asset, such as CAV, or a claim token, such as an LP token in a claim-token pool.
Scale
Scale is the pool's internal unit of value. Reserve assets have token reserves and scale balances. A token's pool price is its scale divided by its reserve amount.
The pool also exposes priceOfUSD(), which connects oracle USD prices to the
pool's scale numeraire. The current genesis phase intentionally has no anchors,
so priceOfUSD() is one for epoch 1.
Stake And Target Scale
Stake lives under:
<Target Token> / Stake / <Reserve Asset> / <account>
Target scale is derived from stake:
targetScale(target token) = totalStaketargetScale(reserve asset) = stake(target token, reserve asset)- reserve targets use
totalTargetScale = 2 * totalStake - claim targets use
totalTargetScale = totalStake
For reserve targets, the target token has a fixed 50% target weight. For claim targets, the claim token owns the backing basket, so reserve assets share the full target-scale denominator.
Deposit Phases
A deposit phase is an epoch. The first token in the epoch token list is the distribution token. The remaining tokens are deposit assets.
The protocol creates receipt-token accounting for each deposit asset and epoch. Those receipts represent a user's position during the phase. Refunds and claims consume the same receipt balances.