Curvefinance

Curvefinance CryptoSwap pools limit liquidity rebalancing through accumulated trading profits

Curvefinance CryptoSwap pools use accumulated trading profits to limit the cost of liquidity rebalancing. These pools concentrate liquidity around an adjustable internal price scale for assets whose relative prices change. A smoothed price oracle guides the direction of a proposed adjustment. The pool accepts that adjustment only when its price-distance and profit conditions allow it. Liquidity providers therefore receive automated concentration with a constraint: thin fee income can leave the liquidity center behind a moving market.

Updated ·

On this page
A persistent gap between CryptoSwap’s oracle and price scale can reflect insufficient profit to pay for re-centering.

Trading volume and the available profit margin

Trading volume contributes to the profit margin that CryptoSwap can use for re-centering liquidity. A pool that earns little from swaps has less scope for a costly price-scale adjustment.

Trading fees accrue within the pool and contribute to the value represented by its LP tokens. The pool does not send every holder a separate payment after each swap. The amount charged varies with the balances used by the fee calculation. Consequently, equal turnover need not generate equal fee income across different pools or trading periods.

Rebalancing can reduce the pool’s internal measure of retained value. The algorithm compares that reduction with the profit already accumulated through pool activity. Greater earnings can provide room for an adjustment that would fail with a smaller margin, provided the price-distance condition and the remaining contract checks also pass.

Available profit and the proposed adjustment cost must therefore be considered together. High trading volume alone does not establish that a particular shift of the liquidity center is affordable.

The liquidity center and the shape of the curve

The price scale defines the center around which CryptoSwap concentrates liquidity, while the curve parameters determine how that liquidity extends outward. The amplification parameter, A, affects depth near balanced liquidity. A separate parameter, gamma, shapes how the curve behaves away from its center. Together they govern the relationship between pool balances and exchange prices. Re-centering changes where that concentration sits; changing the curve parameters changes its shape.

LPs share the pool’s curve instead of selecting individual price intervals for their deposits. This design removes an individual range-setting task. Exposure still follows the assets and the pricing behavior of the selected pool, including conditions far from its liquidity center.

The oracle target and the accepted price scale

The internal price oracle supplies a smoothed direction for re-centering, while the price scale records the center that the pool actually uses. An exponential moving average, or EMA, combines recent pool prices with its previous value. In Twocrypto-NG, ma_time controls that smoothing, and the oracle calculation caps its incoming price observation relative to the existing scale. This reduces sensitivity to abrupt observations. The EMA can lag a fast price move, and an oracle-scale gap can persist when an adjustment lacks sufficient profit.

Pool accounting and an LP’s economic return

CryptoSwap’s profit accounting measures changes within the pool’s mathematical framework, so its profit readings need their own interpretation.

The xcp profit measure

The Xcp measure derives from the pool invariant, price scales and asset count. It supplies a way to compare pool value before and after changing the pricing coordinates. The xcp_profit counter tracks accumulated proportional gains in this framework. Its normalized starting value is one. A reading above that baseline represents an accounting gain, not a token amount available for a separate withdrawal.

The retained virtual-price measure

The virtual price expresses the pool’s Xcp-based value relative to its LP-token supply. An accepted re-centering can lower that measure compared with its value immediately before the adjustment. The profit checks constrain that reduction. Market prices also determine the monetary value of the underlying assets, so internal accounting gains can coexist with a falling portfolio value or underperformance against holding the deposited assets.

What allows a CryptoSwap pool to change its price scale?

A price-scale change requires a sufficiently large oracle-scale gap and enough retained profit to support the proposed adjustment.

In Twocrypto-NG and Tricrypto-NG, allowed_extra_profit adds a buffer to the initial profit test. The algorithm also compares the normalized price distance with an effective adjustment step. If these conditions permit a proposal, it recalculates the invariant and virtual price using the candidate scale. Twocrypto-NG’s CurveTwocryptoOptimized implementation accepts a price-scale adjustment only if its proposed virtual-price gain exceeds half the gain recorded by xcp_profit. That comparison measures both gains above their normalized baseline. Twocrypto v2.1.0 instead requires the candidate’s squared normalized virtual price to exceed the normalized xcp_profit counter. A candidate that fails the final profit test leaves the previous price scale in place.

These NG implementations choose the effective step as the larger of the configured adjustment step and one-fifth of the normalized oracle-scale distance. The candidate moves the scale toward the oracle by that step. Acceptance can therefore leave a remaining gap; the contract does not necessarily recenter all the way to the oracle in one update.

Balance-sensitive swap fees

The dynamic fee responds to the pool’s scaled balances, connecting the charge on a swap with its liquidity state.

Fees near balanced liquidity

The mid_fee parameter sets the fee at balanced liquidity. Balance here concerns the values used by the invariant after precision and price scaling. Raw token quantities alone cannot show whether a volatile-asset pool is balanced. Assets with different units or relative prices can have very different token counts at equilibrium.

Fees as balances diverge

The fee moves toward out_fee as imbalance increases. The fee_gamma parameter controls that transition; it has a different role from the gamma parameter that shapes the curve. A higher charge can increase revenue on an executed trade, while also affecting its competitiveness. The amount earned ultimately requires actual trades at the fees that apply to them.

Administrative fees and retained LP value

Administrative fees allocate part of pool earnings away from LPs, so gross swap fees differ from the earnings retained for liquidity providers. Twocrypto-NG hardcodes its administrative-fee parameter at 50%. Its collection calculation applies that setting through the pool’s accounting; it does not simply transfer half of each swap fee to a recipient. Collection timing and settlement methods differ across CryptoSwap implementations.

Tricrypto-NG calculates its administrative claim from the change in its profit counter since the previous claim. Its calculation accounts for the rebalancing allowance. CurveTricryptoOptimizedWETH settles the claim by minting LP tokens, while CurveTricryptoOptimized transfers underlying pool assets to the fee recipient. The claim also updates profit accounting and, depending on the implementation, LP-token supply or pool asset balances. An administrative allocation therefore affects the value retained by existing LP shares.

Hypothetical acceptance of a price-scale adjustment

A CryptoSwap adjustment can pass while reducing virtual price relative to its pre-adjustment value. Consider a hypothetical CurveTwocryptoOptimized pool state with an oracle above the current scale, a gap beyond the effective adjustment step and all other contract checks passing. The profit readings and extra-profit buffer in this case are symbolic inputs.

Let P be the pre-adjustment virtual price, Q the candidate virtual price, X the accumulated profit counter and E the extra-profit buffer. Express the virtual prices and profit counter relative to a unit baseline, with the buffer in matching normalized units. Suppose 2P - 1 > X + 2E, Q > 1 and 2Q - 1 > X. The proposal passes the profit tests, so the contract adopts the candidate price scale. The re-centering step itself changes pricing coordinates without transferring the pool’s token balances.

The relationship permits Q to be lower than P while retaining sufficient accumulated gain. If the candidate fails the retained-profit inequality, the existing center remains. The acceptance conclusion applies only while the assumed price gap, accounting values and other contract conditions hold.

LP ownership, deposits and withdrawal costs

LP tokens represent a share of changing pool assets, and liquidity operations determine the cost of entering or redeeming that share.

Changing asset balances

Swaps change the quantities of underlying assets that back each LP token. A position can therefore accumulate trading income while its asset mix moves away from the mix originally deposited. The LP-token balance does not identify a fixed inventory of each token. Valuing the position requires its share of the pool assets and their prices, alongside any separately earned rewards.

Costs at entry and exit

CryptoSwap contracts apply liquidity-operation calculations as well as swap calculations. An imbalanced deposit can incur a fee, and a withdrawal into one asset can incur fees and price impact. In Tricrypto-NG, proportional removal returns the pool assets in their existing proportions without a pool withdrawal fee. That method does not preserve the original deposit mix or remove blockchain gas costs. The net amounts from the selected operation determine the assets received.

Visual summary: Curvefinance - Costs at entry and exit

View full-size image

Gauge incentives alongside trading income

Gauge rewards add a separate income stream when a pool has an eligible, funded reward arrangement. Holding LP tokens provides exposure to pool trading income. Staking them in a liquidity gauge can add CRV emissions or other token rewards where those incentives exist. The reward token price and distribution conditions affect their monetary contribution.

veCRV voting helps direct CRV emissions among eligible gauges. Those emissions belong to the incentive system, rather than the pool’s swap-profit counter. A displayed total yield can therefore combine components with different economic roles. A strong incentive rate does not itself demonstrate that the CryptoSwap contract has enough trading profit to re-center.

Contract-specific limits and stale liquidity

Stale liquidity can develop when the market moves away faster than the pool earns enough profit to adjust. Less depth near the trading price can reduce attractive trading opportunities and fee generation. Lower earnings then leave less room for re-centering. Concentration settings affect this feedback loop because they shape both available depth away from the center and the cost of moving it.

Twocrypto-NG handles two pool assets, while Tricrypto-NG handles three. Earlier CryptoSwap implementations also exist. Profit tests, fee settlement, collection timing, oracle settings and adjustable parameters can vary across NG revisions and earlier CryptoSwap contracts. An implementation’s profit guard also does not cover losses from an asset failure or a smart-contract exploit.

A persistent oracle-scale gap therefore reflects a conditional re-centering constraint, not an automatic promise of eventual convergence. A pool can regain room to adjust after it earns sufficient additional profit or its oracle moves closer to the existing scale.

Details worth knowing about Curvefinance

Does Curvefinance rebalance CryptoSwap pools on a fixed schedule?

CryptoSwap does not rebalance at a guaranteed interval. In Twocrypto-NG, price-adjustment logic runs within swaps, deposits and single-asset withdrawals. Those operations can leave the price scale unchanged when the distance or profit conditions fail. Elapsed time affects the moving average, but time passing alone does not force the contract to store a new liquidity center.

What units does Twocrypto-NG use for its oracle price?

Twocrypto-NG reports the price of coin 1 in units of coin 0, scaled by 10^18. Divide the returned integer by 10^18 to obtain the relative price. The pool’s coin ordering fixes the quote direction. A dollar valuation also needs the base token’s dollar price, which this relative-price reading does not supply.

How does get_virtual_price differ from the stored virtual_price value?

In Twocrypto-NG, get_virtual_price calculates the LP-token virtual price, while virtual_price returns the cached accounting value. The calculated getter uses the pool invariant, current price scale and LP-token supply. Neither reading states the exact output of a single-asset withdrawal. That output follows its own withdrawal calculation, including the fees and liquidity conditions that apply to it.

Can CryptoSwap fee earnings move with a transferred LP token?

A transferable CryptoSwap LP token carries its proportional claim on the pool, including the effect of fees already retained there. Those earnings form part of the underlying position rather than a separate payment owed to its previous holder. Gauge rewards use separate staking and reward accounting, so a transfer of an unstaked LP token does not transfer a previous holder’s gauge reward claim.

Will unstaking CryptoSwap LP tokens return the underlying pool assets?

Unstaking returns LP tokens from the gauge; removing liquidity redeems LP tokens for pool assets. These actions affect different contracts and balances. An unstaked position still represents a share of the pool until its holder removes liquidity or transfers the tokens. The withdrawal method then determines the asset mix received and the applicable withdrawal costs.

Are gas fees refunded when a CryptoSwap deposit reverts on Ethereum?

An Ethereum transaction that executes and reverts still incurs gas costs for the work performed. The revert undoes the deposit’s state changes, including token movements and LP-token minting within that transaction. Gas already consumed remains chargeable, while unused gas is not consumed. A pre-execution simulation does not itself charge a blockchain transaction fee.

Is a direct token transfer enough to mint CryptoSwap LP tokens?

A direct token transfer to a Twocrypto-NG pool does not mint LP tokens. The add_liquidity function performs deposit accounting and issues the pool share. Sending tokens through an ordinary transfer does not execute that function or establish a fee-earning LP position. Its exchange_received method supports a transfer-based swap flow, which performs a different operation.