Overview
Liquidity providers interact with the CLP vault, which mints an ERC-20 share token representing proportional ownership of the vault’s pooled base token/quote token inventory.
Core user entrypoints from CLP.sol:
depositDual(baseAmountDesired, quoteAmountDesired, baseMin, quoteMin) -> shareswithdrawDual(shares, baseMin, quoteMin) -> (baseOut, quoteOut)
Depositing
depositDual
LPs deposit both assets and receive CLP shares:
baseAmountDesired: desired base tokens to depositquoteAmountDesired: desired quote tokens to depositbaseMin/quoteMin: slippage guards (enforced after the initial deposit)
Behavior notes from CLP.sol:
- If this is the initial deposit (
totalSupply() == 0), onlyDEFAULT_ADMIN_ROLEorOPERATOR_ROLEcan deposit (CLP__InitialDepositRestrictedotherwise). - After initialization, the vault computes an “optimal” ratio vs. realtime balances and may deposit less than your desired amounts to match the pool ratio.
- CLP uses balance-difference accounting on transfer to support fee-on-transfer tokens more safely, but tokens with adversarial behavior can still pose risk.
Withdrawing
withdrawDual
LPs burn shares and receive both assets:
shares: shares to burnbaseMin/quoteMin: slippage guards
Additional mechanics:
- Withdrawal fee:
withdrawalFeeBps(burned shares) may reduce the effective shares redeemed, capped byMAX_WITHDRAWAL_FEE_BPS. - Cooldown: if
withdrawalCooldown != 0, repeated withdrawals can revert withCLP__WithdrawalCooldown.
Liquidity availability
CLP assets may be:
- held directly by the vault
- withdrawable from MAOB (after maker claims/cancels + MAOB withdraw)
- locked in active MAOB orders (unfilled input)
If a withdrawal requires liquidity that is currently locked, CLP will attempt to:
- claim active orders
- withdraw MAOB withdrawables
- cancel “outermost” active orders until enough liquidity exists
Inspecting vault state
Use getRealtimeBalances() to understand the vault’s current composition:
freeBase/freeQuote: base token and quote token balances held by CLPwithdrawableBase/withdrawableQuote: base token and quote token balances withdrawable from MAOBunfilledBase/unfilledQuote: base token and quote token input still resting in active ordersunclaimedBase/unclaimedQuote: base token and quote token output claimable from fillstotalBase/totalQuote: sum of all base token and quote token components