solana-orderbook: accept sponsored orders on Token-2022 tokens - #5004
Draft
squadgazzz wants to merge 3 commits into
Conversation
|
Reminder: Please consider backward compatibility when modifying the API specification.
Caused by: |
…he mint rule from solana-token
squadgazzz
changed the base branch from
main
to
solana-autopilot/be-338-let-token-2022-orders-into-the-auction
September 30, 2026 20:42
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
A sponsored order is placed through
POST /api/v1/ordersas a creation transaction that CoW's funder account pays for. So the orderbook only accepts the instructions a fixed template allows beforeCreateOrder: wrap SOL, delegate the sell account to the settlement program, create the buy token account. The template hardcodes the SPL Token program. For Token-2022 tokens the frontend builds the delegation and the buy account creation under Token-2022, so those orders fail withInvalidTransaction.Just allowing both programs would let two kinds of broken orders through. A step naming a program that doesn't own its mint passes placement, but its creation transaction fails at settlement, so the user sees an accepted order that never fills. And some Token-2022 mints can't settle at all. The settlement program pays out with a plain
Transfer, which Token-2022 refuses for mints with a transfer fee, transfer hook or pausable extension (even while unpaused) and for non-transferable mints. #5003 keeps those orders out of auctions, so placement should refuse them too.This PR allows Token-2022 in those two steps and rejects both kinds of broken orders. After the template check, placement reads the sell and buy mints in one
getMultipleAccountscall. The wallet check of a native SOL buy from #4990 joins that call. A native SOL buy has no buy mint to read, since its buy token is the System Program ID.POST /api/v1/quoteruns the same mint check where sponsoring is configured, so the frontend finds out before the user signs. The mint rule is thesolana-tokencrate from #5003. This PR is stacked on #5003 and merges after #5002 and #5003 are deployed.Changes
InvalidTransactionUnsupportedToken(the EVM error type) for a token that isn't a mint of either token program, and for mints with a transfer fee, transfer hook, pausable or non-transferable extension, or a frozen default account state. A native SOL buy only has its sell mint checked.How to test
New unit and API tests, one against the DB. Before merge, a barn run: place a sponsored order on a plain Token-2022 token from the frontend, and check that a PYUSD quote answers
UnsupportedToken.Related issues
BE-339