Repository navigation
feat(opencode): build CoinbaseStableSwapper SwapV2 for stablecoin swaps - #1817
Merged
Merged
Conversation
…d stablecoin swaps Add the SwapV2 instruction (no whitelist account, 15 accounts) and send swap_version = 2 on the stateful and stateless stablecoin initiate requests. The request and the locally built instruction both read CoinbaseStableSwapperProgram.SERVER_SWAP_VERSION so they cannot drift. The client-built deposit paths keep the legacy Swap.
This was referenced Oct 22, 2026
0.9.0 carries swap_version on both CoinbaseStableSwapper initiate params.
bmc08gt
marked this pull request as ready for review
October 22, 2026 17:24
The USDF deposit and the USDC to USDF fund swap both moved from Swap to SwapV2, which drops the whitelist account. The deposit transaction fixture is regenerated from the builder; the v1 bytes it replaces were mainnet-simulated, and the v2 bytes are not yet.
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.
Server-mediated stablecoin swaps now build CoinbaseStableSwapper
SwapV2and sendswap_version = 2. This matches code-payments/ocp-server#278, where the server builds whichever instruction the request names and the client rebuilds and signs the same transaction.The
ocp-client-protocolpin is at 0.9.0 (3fef1e0), which carriesswap_version.What changed
CoinbaseStableSwapperProgram_SwapV2is new. It uses discriminator[43, 4, 237, 11, 26, 201, 30, 98]and the v1swapargs. Its 15 accounts are v1's 16 with the whitelist (index 12) removed.CoinbaseStableSwapperProgram_Swap,_SwapForVersion, the builders'swapVersionparameter, and the whitelist PDA derivation. Every swap the app builds isSwapV2;SERVER_SWAP_VERSIONstays as the value sent inswap_version.SERVER_SWAP_VERSION = 2feeds both the request field and the local builder, so the two cannot disagree.StatefulSwapRequest.stablecoinParams()andbuildStablecoinSwapperInstructions.IntentStatelessSwap.stablecoinParams()andbuildStatelessSwapInstructions.UsdfDepositInstructions,UsdcToUsdfSwapInstructions, both reached fromPhantomWalletController) buildSwapV2too, without a version switch. The server never sees these transactions, so there is noswap_versionto match.Tests
CoinbaseStableSwapperProgramTestasserts the exact bytes and account list from the server'sinstructions_swap_v2_test.go. iOS asserts the same vector.CoinbaseStablecoinSwapperInstructionsTestandStatelessSwapInstructionsTestcheck that both builders emit the 15-accountSwapV2.StablecoinSwapVersionRequestTestchecks that both requests carryswap_version = 2.ClientBuiltDepositSwapV2Testchecks that both deposit builders emit the 15-accountSwapV2.CoinbaseStablecoinDepositTransactionTestpins the full encoded deposit transaction. ItsSwapV2bytes passsimulateTransactionon mainnet (Swapped 5000000 tokens, 59730 compute units), so mainnet CoinbaseStableSwapper acceptsswap_v2on the deposit path.Before merging
swap_versionand buildsSwap, so the signedSwapV2transaction wouldn't match.swap_versionis also inside the signed proof'sclient_parameters, viaverifiedMetadata(). That needs a confirmation from the server side that this is accepted.Linked: iOS code-payments/code-ios-app#1104