Quotes And Swaps
Multiswap quotes and swaps use current pool state. Users submit trade intent; the protocol derives reserve, scale, target scale, fee, and stableness from the installed modules.
Quote Inputs
For each reserve asset, the quote model reads:
- reserve amount
- scale
- target scale
- fee
- stableness
The quote model also reads:
- total pool scale
- total target scale
priceOfUSD()
Dynamic Weight Model
A reserve asset has a current weight and a target weight.
When a trade moves an asset toward its target weight, the trade can execute linearly. When a trade moves an asset away from its target weight, price impact increases according to the asset's stableness parameter.
In code terms, quote math computes a target-relative reserve change and applies a nonlinear curve only when the trade moves beyond the target direction.
Multiswap Execution
The public multiswap(...) function accepts:
- pay reserve assets with amounts
- receive reserve assets with allocations and minimum amounts
The module quotes internally before settlement. It then:
- validates native value for native pay legs
- wraps external pay assets into ledger balances when needed
- settles pay legs into reserves, rewards, or treasury
- settles receive legs from reserves or surplus
- applies scale value changes
- unwraps external receive assets back to the user when needed
The settlement code enforces value-flow invariants before moving balances.