Blockchain/Level IX · Speed and spectacle/9.2 The fair market/Lesson 6
Perpetual curves and self-pricing markets
Removing the migration event and the external price feed
MaterialsA block explorer interface for Solana or EthereumDocumentation on constant-product AMM mathematicsA spreadsheet to track reserve ratios
Wonder
- Why does moving liquidity from a curve to a pool create a window for exploitation?
- How can a contract determine its own price without trusting an external oracle?
- What is the trade-off between fixed internal liquidity depth and variable market provision?
Explore
- Many launchpad bonding curves price tokens with a constant-product formula whose virtual reserves set the starting price. When a token reaches a specific market cap threshold, it typically ‘graduates,’ migrating its accumulated reserves to an automated market maker pool. This migration involves a pause in trading and the execution of complex state changes that transfer ownership of assets between contracts.
- This graduation moment is structurally fragile. It creates a brief window where liquidity is in transit, open to sniping by sophisticated actors who monitor pending transactions. In poorly designed systems, bugs during this transition can lead to permanent lockouts or theft. A perpetual curve eliminates this event entirely; the contract never migrates, so the migration-specific window disappears, though ordinary sandwiching of curve trades remains.
- A perpetual curve derives its price solely from its own internal reserves: the ratio of the native asset reserve (such as SOL) to the token reserve. Because the contract holds both sides of the trade, it quotes buy and sell prices directly from these balances. This self-pricing mechanism removes the dependency on external price feeds (oracles), which are a common vector for manipulation in decentralized finance.
- Oracle manipulation has drained significant capital from DeFi protocols. In October 2022 an attacker pushed up the price of the MNGO token on the thin markets that Mango Markets’ oracle read, inflating the value of his collateral, and borrowed about $110 million against it. A curve that prices only from its own reserves has no outside feed to skew; its price can still be moved by trading, but only by paying the curve’s own price for every token.
- The primary trade-off is liquidity depth. In a perpetual curve, the available liquidity is fixed by the initial parameters and subsequent trades within that single contract. It does not benefit from aggregated liquidity provided by outside market makers or other pools. Large trades move its price more than they would in a deep pool fed by many providers, and its depth grows only as its own reserves grow.
- To verify this mechanism, examine a bonding curve implementation on a block explorer. Observe the ‘virtual reserves’ variables that initialize the constant-product constant (k). On each trade the virtual and real reserve fields change by the same amounts; the constant offset between them, the initial virtual amount, fixes the curve’s shape, and the price comes only from the contract’s own state.
Key facts
- Graduation involves migrating reserves from a bonding curve to an AMM pool, creating a transient state vulnerable to sniping.
- Perpetual curves eliminate migration by keeping all liquidity within a single, non-upgradeable contract.
- Self-pricing uses the ratio of native asset reserves to token reserves (constant-product) rather than external oracles.
- The Mango Markets exploit in October 2022 highlighted the risks of relying on manipulable oracle price feeds to value collateral that can be borrowed against.
- Internal pricing removes the attack surface associated with external data manipulation but limits liquidity depth to the contract’s own reserves.
- Virtual reserves in bonding curves inflate initial liquidity, and their static nature ensures the curve’s mathematical shape remains consistent.
Exercise nine, six, three, one
9CollectIdentify 9 token launch mechanisms. For each, note whether it uses a migration event (graduation) or a perpetual structure, and how price is derived.
6ClusterGroup these 9 into 6 by how they manage liquidity and derive price.
3DistillReduce the 6 groups to 3 fundamental trade-offs between security from simplicity and efficiency from aggregation.
1CrystallizeWrite one sentence on which attack, if any, disappears when the migration event is removed.
Fact check
Dates, figures and claims checked against the published sources listed below.
- E. Hertzog, G. Benartzi & G. Benartzi, 'Bancor Protocol' white paper (2017)
- H. Adams, N. Zinsmeister & D. Robinson, 'Uniswap v2 Core' (2020)
- Contemporary reporting on the Mango Markets exploit (October 2022)