Learn · Updated November 18, 2026

Reading a DEX swap from its instruction

A Solana swap instruction has the same shape on almost every DEX: the pool account and its two vaults, the user's two token accounts and signing wallet, and two numbers, the amount on the side the user fixes and a limit on the other side. Which side is fixed varies. The amount actually received is never in the instruction.

The common shape#

Strip the names away and a swap needs the same pieces everywhere. The program has to know which pool to trade against, so the pool account comes first or near it, along with the pool's two token vaults. It has to know where the user's tokens come from and go to, so the user's source and destination token accounts follow, with the wallet that signs for them. And it has to know how much to trade and how bad a price to accept, so the data carries one amount and one limit.

Everything else varies by design: concentrated-liquidity pools add price limits and tick arrays, order-book-era pools add market accounts, and programs that support Token-2022 add a token program per side.

Seven real swap instructions side by side#

Each row is a swap instruction we decoded from a real mainnet transaction on 18 November 2026, with the names its own IDL or source uses:

Venue and instructionFixed amountLimitWhich side is fixedPool and user accounts
Raydium AMM v4, tag 9 or 16amount_inminimum_amount_outalways the inputpool at position 1, user accounts at the end
Raydium CPMM, swap_base_inputamount_inminimum_amount_outthe input (swap_base_output fixes the output)pool_state, input_token_account, output_token_account
Raydium CLMM, swap_v2amountother_amount_thresholdflag is_base_inputpool_state, input_token_account, output_token_account
Orca Whirlpool, swap_v2amountother_amount_thresholdflag amount_specified_is_input, direction a_to_bwhirlpool, token_owner_account_a, token_owner_account_b
Meteora DAMM v2, swap2amount_0amount_1field swap_modepool, input_token_account, output_token_account
PumpSwap, sellbase_amount_inmin_quote_amount_outthe input (buy fixes the output)pool, user_base_token_account, user_quote_token_account
Jupiter v6, routein_amountquoted_out_amount with slippage_bpsthe input (exact_out_route fixes the output)user source and destination accounts; venues are accounts too

Three encodings of the same idea are in that table: separate instructions for each direction, a boolean flag, and a mode field. Your decoder has to know which one each program uses before it can say what the user fixed.

Exact in and exact out#

With an exact-in swap the user says "take exactly this much and give me at least that much": the fixed amount is the input and the limit is a minimum output. With exact out it flips: "give me exactly this much and take at most that much", a fixed output and a maximum input.

Reading the limit as a price is a trap. A minimum output is the worst case the user would accept, often set well below the expected fill, so it tells you the user's tolerance more than the market price. Jupiter is the one venue here that also states the quote it expected; the slippage figure then says how far below that quote the user will go.

Routed swaps through aggregators#

When a user swaps through an aggregator such as Jupiter, the user's instruction goes to the aggregator, not to the pools. The aggregator then calls each pool by itself during execution. Those pool calls are inner instructions, recorded only in execution metadata. So in the raw transaction a routed swap looks like one instruction to Jupiter whose route plan names the venues, while the swaps on each pool are invisible until the transaction has run. Inner instructions and CPIs shows one route from both sides.

What you cannot know before execution#

The instruction tells you what the user asked for and the worst price they would accept. It cannot tell you what they received, the exact price the pool gave, the fees taken along the way or whether the swap succeeded. Those are all results of running the instruction against the pool's state at that moment, and they arrive with execution data. For an exact-in Jupiter route the output was at least the quote less the slippage in all seven routes we could check, and in two of them it was exactly the quote, but only execution data could show which.

Swaps as a shred decoder meets them#

From shreds you see a direct swap instruction as the user signed it, so you know very early which pool someone is trading against, in which direction, how much and with what tolerance. That is enough to watch pools, spot new trading or follow a wallet. It is not enough to compute volume or prices, because the fill is not there yet. DEX volume before confirmation goes into what that means for analytics.

Questions about swap instructions#

Why does my decoder never see the pool swaps inside a Jupiter route?#

Because Jupiter makes them at run time through CPI, and raw transactions only contain the instruction the user signed. You see the route instruction and its plan.

Is the minimum output the price?#

No. It is the user's floor, usually below the expected output by their slippage tolerance.

How do I tell which token is being sold?#

From the account roles: the user's source token account and the instruction's direction flag or mode. Look up the account's mint if the instruction does not list it.

Where reading the instruction stops#

Reading swaps from instructions gives you intent at the earliest possible moment and nothing about outcomes. It misses routed pool swaps entirely, cannot price anything, and counts failed swaps exactly like successful ones until you reconcile. Who made this swap covers attributing swaps to wallets with these limits in mind.

Recipes for each venue#

Decode each venue with its own recipe: Raydium AMM v4, Raydium CPMM and CLMM, Orca Whirlpool, Meteora, PumpSwap and Jupiter routes. Concentrated liquidity explains the extra accounts those pools need, and to see swaps arrive on your own feed, try a first decode.

Sources#

Raw shreds on your own server

Ultra Low Latency Shreds is $200 and Standard Shreds is $100. You pay in crypto, tell us which IPv4 address and UDP port should receive the stream, and we wire it up by hand.