TWAP and Executable Capacity
Mature TWAP confirmation, immediate spot constraints, and lending inventory jointly determine maximum executable short-selling capacity.
Three Distinct Constraints
| Constraint | Question answered | Data source |
|---|---|---|
| Risk Curve | How much theoretical net selling is currently permitted? | Fixed-parameter model |
| TWAP + spot | Which price increases are confirmed, and does the current price contract capacity? | V2 cumulative prices and live reserves |
| Borrowable Token / exact output | Can inventory actually be sold for this much USDC? | Engine ledger, Token balance, live Pair |
The amount that can ultimately be opened depends on all three, not on a single market-cap table.
1. Cumulative Prices and TWAP
V2 records cumulative prices in external6 / token18 . Let A(t) be the cumulative value scaled by 2¹¹² , with Δt:
Converting to native18 market cap:
2. A Minimum Window Is Not a Fixed Rolling Window
The reference Engine family uses a minimum observation window of 300 seconds:
Δt < 300 seconds: Observation updates neither writes observation state nor raises the confirmed ceiling.Δt ≥ 300 seconds: the average covers the entire period.
3. The Confirmed Ceiling Can Only Rise
At initialization, the capacity ceiling starts from fixed M₀ and C(M₀) , rather than zero capacity. No elapsed-time TWAP sample exists yet.
For a mature sample, the candidate market cap is:
The historical ceiling rises only when the candidate exceeds it. Let H be the confirmed market-cap ceiling and the confirmed capacity ceiling:
Ordinary price declines do not reduce these two historically confirmed ceilings. Actual available capacity is still immediately limited by spot.
4. Immediate Spot Constraints
If total net sold across all existing positions is O = totalOpenShortNative:
- Spot falls: capacity for new positions contracts immediately, without waiting for a new TWAP.
- Spot recovers: capacity can recover immediately within the confirmed ceiling.
- Spot reaches a new high: the portion above the confirmed ceiling still requires mature TWAP confirmation.
- Spot falls below
M₀: the model still has anM₀floor; this does not mean that all market risk disappears.
Scenario Example
Assume a historically confirmed market-cap ceiling of 10,000,000 USDC and existing net sold of 8,000 USDC:
| Current spot market cap | Effective capacity (approx. USDC) | Remaining net-sale capacity for new positions (approx. USDC) |
|---|---|---|
| 25,000,000 | 55,056.240673 | 47,056.240673; the increase above the old ceiling has not been released |
| 1,000,000 | 10,518.095455 | 2,518.095455; immediate contraction |
| 10,000,000 | 55,056.240673 | 47,056.240673; recovery within the old ceiling |
This example calculates only the risk layer. Token lending constraints for the actual Pair may further reduce the final executable amount.
5. Token Inventory Constraints
The Engine's actual Token balance must also be at least its ledger balance available for lending. Additional Token transfers do not automatically increase L₀; if the balance is insufficient, the Quoter returns an error instead of continuing to show apparently available capacity.
Let T be the Pair's Token18 reserve,R its external6 USDC reserve, and L the Token18 available for lending. To ensure that V2's exact-output input calculation does not exceed L, the maximum external6 net sale amount permitted by inventory is:
L = 0 returns zero separately in that case.
Round this preview capacity down to external6, then take the smaller value:
If Qsold,max = 0, notional principal is also zero. Adding 1 and subtracting 1 here are raw native18 integer units, not 1 USDC.
6. A Quote Is Not an Execution Guarantee
- Preview and confirmed state are distinct fields and should be displayed separately.
- Swaps, other users' position openings, tax-Token conversions, or the passage of time may occur after a quote.
- Executable notional is still not a complete trade quote: the user must also meet collateral, maximum Token borrowing, and six-decimal exact net-output requirements.