Repository navigation
feat(token-2022) PR 1: settle Token-2022 mints under their own token program - #5002
Conversation
…token program before its buy account
|
Claude finished @squadgazzz's task in 7m 44s —— View job Review complete ✅I reviewed the diff against
One minor point (posted inline):
Nothing blocking. Nice work on the test coverage and the inline documentation. --- · |
`resolve_accounts` turns the chain results into a `TokenPrograms` map first and hands it to the setup account derivation, the missing account check and the instruction builder. One lookup and one `UnresolvedMint` error for a mint outside `Settlement::mints`, shared by `ResolveError` and `Error`. The infra `MintPrograms` newtype goes away: its `get` read a mint that was never looked up as not found, which conflated a code bug with a chain fact. The results arrive in a `HashMap`, so with several invalid mints the reported one varies. The test accepts either mint of the order.
The fetched addresses are the orders' buy token accounts, the program is only compared against them afterwards, so the two lookups do not depend on each other.
|
Claude finished @squadgazzz's task in 4m 22s —— View job Re-review complete ✅I re-reviewed the full diff against What I verified this pass:
One standing note (already posted inline on CI: no failures so far ( Nice work on the test coverage and the inline documentation. |
Description
Solana has two token programs: the classic SPL Token program and Token-2022. Every mint belongs to one of them. The settlement program handles both, even mixed in one settlement (cowprotocol/solana-programs#128). But the driver assumes SPL Token for every mint.
So any settlement that moves a Token-2022 mint fails simulation.
BeginSettlepulls the user's sell tokens into the payer's ATA. The payer is the solver account that signs the settlement. An ATA address derives from the wallet, the mint and the token program, so the driver derives the wrong address and asks SPL Token to create it. On the buy side,CreateBuffersinitializes the buffers (token accounts that hold the bought tokens until payout) under one token program, and the driver always passes SPL Token.This PR looks up the program that owns each mint account. That lookup has to run first, since the addresses of the accounts the driver checks and creates depend on it. The
Solanaadapter caches the answer, so only the first lookup of a mint costs an extra RPC round trip. The entries never expire. A mint changes owner only if it is closed and re-created, and its settlements would then fail simulation until the driver restarts.The buy token account check from #4982 derives an order's ATA the same way, so at
/solvethe driver reads the buy mints before the buy token accounts. An order whose buy mint is missing or not a mint is dropped from the auction, since no settlement can pay it out.Mints with transfer fees or transfer hooks still fail simulation, because the program moves tokens with a plain
Transferand Token-2022 rejects that for them. #5003 keeps them out of the auction.Changes
Solanaadapter reads and caches each mint's token programBeginSettlepull destinations derive under their mint's token programCreateBuffersinstruction per token program with missing buffers/solvedrops an order whose buy mint is missing on chain or not a mint of either token programInvalidMintwhen one of its mints is missing on chain or not a mint of either token program. The error names which.How to test
New unit tests. Updated unit and API tests.
Related issues
BE-337