Pools
A commitment pool is a SwapPool. It holds vouchers and swaps one for another at the price its quoter gives, minus fees. It issues no shares.
What makes up a pool
A pool points at four contracts that do the work, plus a shared protocol fee controller.
| Contract | Pool setting | What it does |
|---|---|---|
TokenUniqueSymbolIndex | tokenRegistry | Lists the vouchers the pool accepts, one per symbol. Deposits and swaps of other tokens revert. |
Limiter | tokenLimiter | Caps the pool's balance of each voucher. A deposit or swap that would go over the cap reverts. |
FeePolicy | feePolicy | Default fee and per-pair fees, in parts per million (PPM). |
| Quoter | quoter | Prices one voucher against another. See Quoters. |
ProtocolFeeController | protocolFeeController | Protocol fee rate and recipient. Shared by every CLC pool, and set only at initialization. |
The pool also has a feeAddress, which receives collected fees, and feesDecoupled, which reserves accrued fees so swaps and liquidity withdrawals cannot spend them.
Create a pool
CLC deploys a new pool as ERC-1967 proxies, all owned by the pool owner, in this order:
TokenUniqueSymbolIndexLimiterFeePolicy, with the default feeRelativeQuoterorOracleQuoter. A pool with equal-value pricing uses the sharedDecimalQuoterinstead.SwapPool, initialized with the addresses above
The CLC app asks for a name, symbol, pricing type, default fee, and fee address. It uses 6 decimals.
Add a voucher
The owner sends one batch:
registry.add(voucher)limiter.setLimitFor(voucher, pool, cap). The cap is the most of that voucher the pool will hold. The CLC app calls it the credit limit.- Set the price on the quoter:
setPriceIndexValue(voucher, index)on a RelativeQuoter, orsetOracle(voucher, feed)on an OracleQuoter. A DecimalQuoter needs nothing.
A voucher with no cap cannot be deposited. registry.remove(voucher) takes the voucher out and leaves its cap and price.
Liquidity and fees
- Anyone can approve the pool and call
deposit(voucher, amount). The deposit counts toward the cap. - Anyone can swap with
withdraw. See Quote and settle swaps. - The owner can take any voucher out with
withdrawLiquidity(token, to, amount). - The owner sends accrued fees to
feeAddresswithwithdraw(token)orwithdraw(token, amount).
Seal settings
seal(bits) permanently locks the address a setting points to:
| Bit | Setting |
|---|---|
1 | feePolicy |
2 | feeAddress |
4 | quoter |
8 | tokenRegistry |
16 | tokenLimiter |
31 locks all five. Sealing does not lock the contents of those contracts: their owner can still change fees, caps, prices and the voucher list. Check who owns each one, and who can upgrade the pool proxy.