TIP-1001: Place-only Mode for Next Quote Token
Status: Draft
Authors: Dan Robinson
Authors: Dan Robinson
Abstract
This TIP adds acreateNextPair function to the Stablecoin DEX that creates a trading pair between a base token and its nextQuoteToken(), along with place and placeFlip overloads that accept a book key to target specific pairs. This enables market makers to place orders on the new pair before a quote token update is finalized, providing a smooth liquidity transition.
Motivation
When a token issuer decides to change their quote token (viasetNextQuoteToken and completeQuoteTokenUpdate), there is currently no way to establish liquidity on the new pair before the transition completes. This means that market makers will need to wait until the quote token has been updated before they can place orders, which could cause a period where there is no liquidity, or limited liquidity, for the token, which will interrupt swaps involving that token.
By allowing pair creation against nextQuoteToken(), this change allows users and market makers to add liquidity to the DEX before it is used on swaps. Since swaps route through quoteToken() (not nextQuoteToken()), the new pair operates in “place-only” mode: orders can be placed and cancelled, but no swaps route through it until completeQuoteTokenUpdate() is called.
Specification
New Functions
Add the following functions to the Stablecoin DEX interface:Behavior
Pair Creation
createNextPair(base) creates a pair between base and base.nextQuoteToken(). The function:
- Calls
nextQuoteToken()on the base token - Reverts with
NO_NEXT_QUOTE_TOKENif the result isaddress(0) - Validates both tokens are USD-denominated (same as
createPair) - Creates the pair using the same mechanism as
createPair - Emits
PairCreated(key, base, nextQuoteToken)
Place-only Mode
Once the pair exists, it supports the full order lifecycle:place(bookKey, ...)andplaceFlip(bookKey, ...)allow placing orders on the paircancelandcancelStaleOrderwork normally (they use order ID, not pair lookup)booksreturns accurate data (it takes the book key directly)
place and placeFlip overloads are required because the existing functions derive the pair from token.quoteToken(), which would look up the wrong pair. The overloads accept a bookKey parameter to target the correct pair.
Swap functions (swapExactAmountIn, swapExactAmountOut) and quote functions (quoteSwapExactAmountIn, quoteSwapExactAmountOut) do not route through this pair because routing uses quoteToken() to find paths between tokens.
After Quote Token Update
When the token issuer callscompleteQuoteTokenUpdate():
- The token’s
quoteToken()changes to what wasnextQuoteToken() - The token’s
nextQuoteToken()becomesaddress(0) - The existing pair (created via
createNextPair) is now the active pair - Swaps begin routing through the pair
New Error
Events
No new events. The existingPairCreated event is emitted by createNextPair, and the existing OrderPlaced event is emitted by the place and placeFlip overloads.
Invariants
- A pair created via
createNextPairmust be identical to one created viacreatePaironcecompleteQuoteTokenUpdateis called createNextPairmust revert ifnextQuoteToken()returnsaddress(0)createNextPairmust revert if the pair already exists (same ascreatePair)- Orders placed on a next-quote-token pair must be executable via swaps after the quote token update completes
- Swap routing must not change until
completeQuoteTokenUpdateis called on the base token