Pool policies
A pool policy is a contract that a Curve Cryptoswap pool calls on each operation. It can set two values for the pool: the swap fee and the price_scale target. price_scale is the pool's internal price, around which the pool concentrates liquidity. The target is the price that price_scale moves toward. Only pools on Twocrypto code v3.0.0 can take a policy.
YieldBasis has two pool policies. The oracle-report policy, YBOraclizedPolicy, prices each swap against a signed USD price report of the pool asset. It uses the same reports to steer price_scale. YBTwocryptoPolicy uses only the pool's own prices and sets only the price_scale target, so a pool that runs it keeps its own fee curve. To see which policy a pool runs, call POLICY() on the pool or read the table in Contract addresses. A return of the zero address means that the pool has no policy.
A policy does not change where fees go. The pool admin_fee sets the Curve DAO share of the pool profit that the reserved profit fraction protects. The reserved profit fraction is the share of the pool's fee profit that the pool cannot spend to recenter price_scale. Other swap fees stay in the pool for its liquidity provider (LP) holders. The main holder is LEVAMM, the market's leveraged automated market maker. For how those fees reach yb-LP holders and veYB, read Fees and veYB revenue.
What the policy changes for you
These subsections describe a pool that runs the oracle-report policy.
Swap fee
A price report is a signed USD price of the pool asset from Pyth Pro (Pyth Lazer), Pyth's low-latency price service. Anyone can deliver one to the policy. Arbitrageurs deliver one with their swap, because a fresh report can lower their fee.
The policy sets each swap fee between two settings. The fallback fee is the fee when no discount applies, and the highest fee of the policy. The base fee is the lowest fee that a swap can pay.
A swap gets a discount from the fallback fee only when all of these conditions are true:
- The stored report is younger than the relax time, a policy setting.
- The swap is corrective: it moves the pool price toward the report price without passing it.
- The swap has a positive edge. The edge is the swap's gain at the report price before fees.
The discounted fee is the base fee plus the capture share of the part of the edge above the base fee. The capture share is a policy setting. The discounted fee is at most the fallback fee. The discount fades with the square root of the report age and is gone at the relax time. Every other swap pays the fallback fee. While the pool parameter A changes gradually over a set time, swaps usually pay the fallback fee.
The following example uses the deployment settings. The base fee is 0.50%, the capture share is 67.5%, the fallback fee is 1.75%, and the relax time is 300 s. A corrective swap with an edge of 1.00% pays these fees:
- With a report of age 0: 0.50% + 0.675 × (1.00% − 0.50%) = 0.50% + 0.675 × 0.50% = 0.8375%.
- With a report of age 75 s, one quarter of the relax time: 0.8375% + (1.75% − 0.8375%) × √(75 / 300) = 0.8375% + (1.75% − 0.8375%) × 0.5 ≈ 1.29%.
On a $10,000 swap, these fees are about $84 and $129, against $175 at the fallback fee. The YieldBasis DAO (YB DAO) can change the settings. To read the current settings, call config() on the policy.
price_scale target
The LP oracle is the YieldBasis contract that returns the USD value of one Curve LP token. It computes that value from price_scale, and LEVAMM uses the value. So the price_scale target sets how fast your yb-LP position value follows the market price. For how the oracle turns price_scale into a position value, read Oracle design.
The policy keeps two exponential moving averages (EMAs) of an observed price: a fast EMA and a slow EMA. An EMA gives more weight to recent observations. The observed price comes from one of two sources:
- While the stored report is younger than the report lifetime, the EMAs observe the report price. The report lifetime is the report age at which a report stops steering the EMAs: 90 minutes in the deployment settings.
- Otherwise, the EMAs observe the pool's spot price after the previous pool operation, not the price of the trade in progress.
The trend gate is the relative gap between the two EMAs at which the target reaches the observed price: 0.70% in the deployment settings. In a flat market, the target stays near the fast EMA. As the gap between the EMAs grows to the trend gate, the target moves to the observed price. So the pool spends less profit recentering on short price swings, and the target still follows a trend.
Each rebalance moves price_scale at most half the gap to the target. The step cap, a policy setting, limits each move: 0.50% of price_scale in the deployment settings. The pool's own limits also apply:
- The pool rebalances at most once a block.
- The pool rebalances only if its rebalance budget and refueling donations together pay for the move, so per-LP value stays above the profit floor. The profit floor is the protected part of the pool's lifetime profit, per LP token.
- The pool keeps the target within 20% of
price_oracle, its own EMA of trade prices. - The pool caps each step at its maximum step, the second value of
adjustment_step().
The policy admits a price report only if Pyth's verifier accepts its signature and the report passes the feed, channel, time, and price-bound checks. The report must also be newer than the stored report. For each check, read Price report admission in Dev: Pool policy.
Deposits and withdrawals
A yb-LP deposit or withdrawal adds or removes pool liquidity. The pool charges half its fee rate on the imbalanced part. While the policy is active, that rate is the fallback fee, so the deployment settings give 1.75% / 2 = 0.875% on the imbalanced part. A balanced removal pays no imbalance fee. During the donation protection period, a deposit can also pay a penalty of up to half the fee rate on the whole deposit. preview_deposit and preview_withdraw include these fees.
LT deviation check
A yb-LP deposit into LT, the market's vault contract, adds LP collateral and crvUSD debt to LEVAMM. The policy requires the added debt to match the LEVAMM debt-to-collateral ratio within ratio_tolerance, a policy setting: 1 basis point (0.01%) in the deployment settings. If it does not match, the deposit reverts with LT deviation.
The check applies to every LT.deposit call while the policy is not killed and LEVAMM holds collateral. This includes Hybrid Vault deposits and LTMigrator migrations. Swaps, donations, withdrawals, and liquidity added directly to the pool skip it.
If your deposit reverts with LT deviation, get a fresh preview and deposit again.
Who controls the policy
After a pool's one-time initialization, only a Curve DAO vote can attach, replace, or remove its policy. At deployment, the deployer could attach a policy in initialize() before the first deposit without a vote. The YB DAO owns each YBOraclizedPolicy and changes its settings within limits in the code, which the Pool policy developer page lists. For the powers of each DAO, read Roles and permissions.
What can go wrong
On a pool that runs the oracle-report policy, these failures and effects can occur:
- No fresh price report. Every swap pays the fallback fee. With the deployment settings, the corrective swap in the swap-fee example pays 1.75% instead of 0.8375%. After the report lifetime, the EMAs observe the pool's own spot price.
- crvUSD away from $1. The policy counts 1 crvUSD as exactly $1. A price report is a USD price, but
price_scaleis a crvUSD price. If crvUSD trades away from $1, the policy prices swaps wrongly, and a price report steersprice_scaletoward the USD price, not the crvUSD price. Both errors are about the size of the depeg. - Kill switch. The YB DAO or the Curve Emergency DAO can kill the policy. The pool then uses its own fee curve and
price_scaletarget, the policy refuses price reports, and the LT deviation check is off. Killing also drops the stored price report, so after a revive a swap needs a new report to get a discount. Swap fees change at once when the policy is killed or revived. - A failing policy. If the policy contract reverts, swaps, deposits, and normal withdrawals on the pool also revert. If at least 500,000 gas remains before the policy call, a balanced removal of liquidity ignores the failed call, so
emergency_withdrawstays available. If less than 500,000 gas remains, the balanced removal also reverts. - Price trust. The verifier, the Pyth contract that checks price report signatures, decides which prices are authentic. The YB DAO can replace it with any contract, so you trust the YB DAO for prices.
- A wrong signed price. If Pyth signs a wrong price, or a Pyth signing key is compromised, a trader can deliver that price. A wrong price report can lower the fee on swaps against the pool and steer
price_scaleby at most one step per block. - Fee income changes. The policy changes how much the pool earns per swap, so pool fee income and yb-LP returns differ from those under the pool's own fee curve. To read the fees, call
config()on the policy.
Why a pool runs the oracle-report policy
A pool loses value when it undercharges arbitrageurs for the edge they take, or spends too much profit recentering price_scale toward the wrong price. It also loses value when price_scale lags far behind the market, because the pool then stays unbalanced while the price moves.
A pool without the oracle-report policy uses its own fee curve, and its price_scale target follows only the pool's own prices. Two effects of that design can cost yb-LP holders value:
- High fees on corrective swaps. The pool's own fee depends only on how far its balances sit from an even split, not on the market price. So the fee cannot tell a corrective swap, a swap that moves the pool back toward the market price, from any other swap. Arbitrageurs wait until the gap to the market is larger than that fee. Until then, the pool price lags the market, and other traders also pay the high fee.
- A target that follows only the pool's own trades. The
price_scaletarget moves only with the prices of the pool's own trades. So it lags the market, and the pool's own trades can push it away from the market price.
The oracle-report policy changes both. It prices each swap against a signed price report. With a fresh report, a swap that closes a small gap pays close to the base fee, so smaller gaps become worth closing. It also steers the price_scale target from the same reports during the report lifetime, and the pool's own trades cannot move a report price. For how each part works, read Swap fee and price_scale target.
The design has two limits:
- The donation rate and the reserved profit fraction must be set as a pair. They must be set again when the pool parameter
Achanges. - After a large, fast price move,
price_scalecan stay away from the market price. The gap closes as new fees and donations pay for more steps, or when the price comes back.
Related
- Fees and veYB revenue: where swap fees go after the pool collects them.
- Oracle design: how
price_scalebecomes the value of your position. - Dev: Pool policy: the configuration table, setter limits, and getters.
- Oracle report arbitrage: how an arbitrageur delivers a price report with a swap.
- How oracle-report swaps are priced: how a price report sets the swap fee, with profit and age tables.