ReferenceCurve_v1 increase the reference price: rebalance (rebalanceSegments) and elevation (elevate).
The reference price is the lowest price on the curve. A rebalance uses collateral that the market already holds for supply bought above the reference price. An elevation adds collateral from outside the curve, such as fees that reach the market’s ElevationTreasury_v1.
Rebalance
How it works
The caller submits a complete new list of segments. The contract replaces the curve if every check below passes, in this order. The check names (B1 to B6, I3) are the ones in the contract’s comments.- State. The block timestamp is at or below the call’s deadline, the hash of the current segments equals the expected hash, and the virtual collateral supply equals the expected value. Otherwise the call reverts before any other check and moves no collateral.
- Reference price (B1). The new reference price is at or above the current one.
- Capacity (B5). The new curve’s capacity is at or above the current supply and at or below the issuance token’s cap.
- Supplied collateral (B2). The contract pulls the supplied collateral from the caller and adds the amount received to the virtual collateral supply. That amount must equal the amount the call names. This comparison runs after the segment rules (6).
- Reserve held (B3). The reserve for the current supply under the new segments is at or below the virtual collateral supply.
- Segment rules. The rules in Markets and curves apply.
- Reserve for supply (B6). The reserve for the current supply under the new segments is at or above the reserve under the old segments.
- Spot does not fall (I3). Spot at the current supply is at or above the old spot.
- Spot tolerance (B4). Spot rises by at most the spot tolerance (Curve shape).
reconfigureSegments does not.
where:
- is the issuance supply
- and are the reserve for under the old and new segments
- is the virtual collateral supply before the call
- is the collateral supplied in the call (
suppliedCollateral_) - and are the reference prices
- and are spot at
- is the spot tolerance in basis points
- a reference segment of 1,000 tokens at 1.00
- a band of 5 steps of 100 tokens, from 1.20 rising 0.20 per step to 2.00
- a tail of 20 steps of 100 tokens, from 2.04 rising 0.04 per step to 2.80
- a reference segment of 1,500 tokens at 1.28
- 5 steps of 100 tokens, from 1.56 rising 0.16 per step to 2.20
- 15 steps of 100 tokens, from 2.24 rising 0.04 per step to 2.80
After the call:
- the reference price is 1.28, and the reference segment holds 1,920.00 of the 2,860.00 reserve
- the premium supply below spot holds 940.00, down from 1,860.00
- an address that sells 100 tokens at supply 2,000 receives 220.00 before fees, the same as before the call
Re-form after the reference segment shrinks
A sell that takes supply below the reference segment’s capacity shrinks the reference segment to the supply (Markets and curves). The band and tail then start at the lower supply with their old widths. A re-form is a rebalance that keeps the reference price and rebuilds the band and tail from the curve policy at the new reference-segment capacity. Example. The curve above, before the rebalance, has supply 1,000. Sells take 200 tokens out of supply at a sell fee of 0.
Before the re-form, the next buyer pays 1.20 for tokens 801 to 900. After it, the next buyer pays 1.20 for tokens 801 to 880. The band is 50% of the reference segment again, so price discovery restarts from the new end of the reference segment.
Keeper policy
The rebalance keeper decides when to callrebalanceSegments and which segments to submit. That decision is keeper policy, off chain. In the configuration code this policy is named the LRE step.
The interval and the shrink share are deployment settings.
Elevation
How it works
The caller offers a collateral budget. The contract walks the premium steps upward from the reference price:- The reference supply is the smaller of the reference segment’s capacity and the supply.
- The cost of the next step is its price minus the reference price, times , rounded up. The tokens in that step were bought at the step’s price, so only the reference supply needs raising to it.
- If the remaining budget covers the cost, the step joins the reference segment. The reference price becomes the step’s price, grows by the step’s width up to the supply, and the cost leaves the budget.
- Otherwise, the rest of the budget is spread over the reference supply, and the walk stops.
- The contract computes the reserve for the supply under the new segments. It pulls the difference between that reserve and the virtual collateral supply from the caller. The rest of the budget stays with the caller.
- and are the price and width of the -th premium step
- and are the reference price and reference supply before step
- is the cost of absorbing step
- is the first step the budget does not cover
- is the budget left at step
- is the new reference price
- is the issuance supply
- is the virtual collateral supply before the call
- is the collateral the contract pulls from the caller
After the call:
- the reference segment is 1,100 tokens at 1.290909…
- the premium segment has 9 steps, from 1.40
- spot at 1,300 is 1.60 and the next buy pays 1.80, both unchanged
- an address that sells 300 tokens at supply 1,300 receives 160.00 + 140.00 + 100 × 1.290909… = 429.09 before fees, against 420.00 before the call
ElevationSurplusAbsorbed.
Elevation from the elevation treasury
At launch, the curve’selevate is granted only to the market’s ElevationTreasury_v1. The treasury holds collateral: fees routed to it by the splitter (Fees and routing) and any collateral sent to it. An elevation from the treasury takes two calls.
- The authorizer admin calls
authorizeElevationwith a supply cap and a deadline. The authorization covers one elevation and replaces any pending one. A deadline of 0 or in the past reverts. - An
ELEVATION_KEEPERcallsElevationTreasury_v1.elevatewith its own supply cap and deadline. The lower of the two caps applies.
elevate then runs in this order:
- It reverts if either deadline has passed, if no authorization exists, if the supply is above the cap, or if its collateral balance is below the threshold.
- It deletes the authorization.
- It asks the curve for the largest budget at or below its balance that
elevateaccepts (maxElevatable). The quote walks at most 1,000 premium steps. - If the quote is 0, the call ends without calling the curve and emits
ElevationExecutedwith 0 attempted and 0 consumed. - Otherwise, it approves the budget and calls the curve’s
elevate. If the curve call reverts, the treasury catches the revert. The reference price does not change and the collateral stays in the treasury. - It resets the approval to 0 and returns the budget offered, the collateral the curve used and the balance left.
Parameters
At launch:
- the
REBALANCERrole has one member, the rebalance keeper (the keeper address in the market configuration), and holdsrebalanceSegmentsonly - the curve’s
elevateis granted only toELEVATION_MODULE, whose member is the market’sElevationTreasury_v1 - the treasury’s
elevateis granted toELEVATION_KEEPER, whose members are the elevation keeper addresses in the market configuration reconfigureSegmentsandsetThresholdare granted to no role; the authorizer admin can call them
Scenarios
Flat curve
On a flat curve every step has the reference price (Curve shape), so the reserve for supply is .- A rebalance with no supplied collateral raises the reference price only as far as any surplus of the virtual collateral supply over covers. Beyond that, B3 reverts.
- A rebalance that supplies collateral can raise it, up to the reserve that the new collateral covers.
elevatereverts. No step is priced above the reference price, so there is no premium step to absorb.
Elevation reaching the supply
When the walk absorbs the step that holds the current supply, the reference segment ends at the supply. The part of that step above the supply is dropped from the curve, and the next premium step starts at the supply. Spot is then the new reference price, and the next buy pays the next step’s price.Edge cases
- Stale rebalance. A call after its deadline, or one whose expected segments hash or virtual collateral supply differs from the curve’s, reverts before any collateral moves.
- Freeze.
rebalanceSegments,elevate,ElevationTreasury_v1.elevate,authorizeElevationandsetSpotToleranceBpsrevert while the market is frozen. - Supplied collateral in a rebalance. If the collateral the curve receives differs from the amount the call names, B2 reverts.
- Endowed markets. With an endowment controller registered, every new curve must keep the reference price times the smaller of supply and the new reference segment’s capacity at or above the outstanding draws. While reference sells are closed, a new reference segment longer than the supply reverts. See Endowed reference segment.
- Last premium step. A budget large enough to reach the last step of the last premium segment reverts with
InsufficientPremiumSteps. - Small budgets. A budget of 0 reverts. A budget too small to raise the reference price by 1 wei reverts with
CollateralTooSmall. In wei, the smallest accepted budget is the reference supply in wei divided by 1018, plus 1. - No supply.
elevatewith no issuance supply reverts withNoIssuanceSupply. - No rise. If the new reserve is at or below the virtual collateral supply,
elevatereverts withNoElevation. - Packed limits. If a new price or reference-segment capacity does not fit its packed field,
elevatereverts withInitialPriceTooLargeorSupplyPerStepTooLarge. - Rounding. The remainder rise is rounded down. The contract pulls the exact reserve difference, and the rest of the budget stays with the caller.
- Direct budget range.
maxElevatablelimits its quote to 1,000 premium steps. A direct call toelevatehas no step limit.
Code
Keeper policy (configuration code):
Source:
house-markets/contracts at 0ebbc89a (branch integration/v12-post-qa); house-markets/middleware at 35ebfefc (main).