Raydium AMM

This document describes the output structure for the Raydium AMM decoder functions. The decoder handles four main event types: INITIALIZE2, SWAP, ADD_LIQUIDITY, and WITHDRAW_PNL.

Common Properties

All decoded events include the following base properties from BaseTransactionRecord:

Property
Type
JSON Type
Description

uuid

bigint

string

Unique identifier for the transaction record

instructionPath

string

string

Path to the instruction within the transaction

parentProgramId

string | null

string | null

ID of the parent program if applicable

txSignature

string

string

Transaction signature

blockTime

number

number

Block timestamp

programId

string

string

Raydium AMM program ID

eventType

string

string

Type of event (INITIALIZE2, SWAP, ADD_LIQUIDITY, WITHDRAW_PNL)

decoderType

DecoderType

string

Decoder type identifier

blockHeight

number

number

Block height

slot

number

number

Blockchain slot number

txFee

number

number

Transaction fee in lamports

txFeeUiAmount

PreciseDecimal

string

UI-formatted transaction fee

INITIALIZE2 Event

AMM pool initialization event.

Property
Type
JSON Type
Description

lpMint

string

string

LP token mint address

mint

string

string

Pool mint address

pcMint

string

string

PC (quote) token mint address

userWallet

string

string

User wallet address

amm

string

string

AMM pool account address

poolCoinTokenAccount

string

string

Pool coin token account

poolPcTokenAccount

string

string

Pool PC token account

poolWithdrawQueue

string

string

Pool withdraw queue account

ammTargetOrders

string

string

AMM target orders account

poolTempLp

string

string

Pool temporary LP account

nonce

number

number

Pool nonce value

openTime

string

string

Pool opening timestamp

initPcAmount

bigint

string

Initial PC token amount

initPcAmountUiAmount

PreciseDecimal

string

UI-formatted initial PC amount

initCoinAmount

bigint

string

Initial coin token amount

initCoinAmountUiAmount

PreciseDecimal

string

UI-formatted initial coin amount

SWAP Event

Token swap event on Raydium AMM.

Property
Type
JSON Type
Description

amountIn

bigint

string

Input token amount

amountInUiAmount

PreciseDecimal

string

UI-formatted input amount

amountOut

bigint

string

Output token amount

amountOutUiAmount

PreciseDecimal

string

UI-formatted output amount

minimumAmountOut

bigint

string

Minimum acceptable output amount

minimumAmountOutUiAmount

PreciseDecimal

string

UI-formatted minimum output amount

inputMint

string

string

Input token mint address

outputMint

string

string

Output token mint address

userSourceTokenAccount

string

string

User's source token account

userDestinationTokenAccount

string

string

User's destination token account

poolCoinTokenAccount

string

string

Pool coin token account

poolPcTokenAccount

string

string

Pool PC token account

pricePre

PreciseDecimal

string

Price before swap

pricePost

PreciseDecimal

string

Price after swap

expectedAmountIn

bigint

string

Expected input amount

expectedAmountInUiAmount

PreciseDecimal

string

UI-formatted expected input amount

expectedAmountOut

bigint

string

Expected output amount

expectedAmountOutUiAmount

PreciseDecimal

string

UI-formatted expected output amount

slippageTolerance

number

number

Slippage tolerance percentage

slippagePercentage

number

number

Actual slippage percentage

slippageAmount

bigint

string

Slippage amount

slippageAmountUiAmount

PreciseDecimal

string

UI-formatted slippage amount

actualPrice

PreciseDecimal

string

Actual swap price

userSourcePreBalance

bigint

string

User source balance before swap

userSourcePreBalanceUiAmount

PreciseDecimal

string

UI-formatted user source pre-balance

userSourcePostBalance

bigint

string

User source balance after swap

userSourcePostBalanceUiAmount

PreciseDecimal

string

UI-formatted user source post-balance

userDestinationPreBalance

bigint

string

User destination balance before swap

userDestinationPreBalanceUiAmount

PreciseDecimal

string

UI-formatted user destination pre-balance

userDestinationPostBalance

bigint

string

User destination balance after swap

userDestinationPostBalanceUiAmount

PreciseDecimal

string

UI-formatted user destination post-balance

poolCoinPreBalance

bigint

string

Pool coin balance before swap

poolCoinPreBalanceUiAmount

PreciseDecimal

string

UI-formatted pool coin pre-balance

poolCoinPostBalance

bigint

string

Pool coin balance after swap

poolCoinPostBalanceUiAmount

PreciseDecimal

string

UI-formatted pool coin post-balance

poolPcPreBalance

bigint

string

Pool PC balance before swap

poolPcPreBalanceUiAmount

PreciseDecimal

string

UI-formatted pool PC pre-balance

poolPcPostBalance

bigint

string

Pool PC balance after swap

poolPcPostBalanceUiAmount

PreciseDecimal

string

UI-formatted pool PC post-balance

ADD_LIQUIDITY Event

Liquidity provision event for Raydium AMM.

Property
Type
JSON Type
Description

mint

string

string

Pool mint address

maxCoinAmount

bigint

string

Maximum coin amount to deposit

maxCoinAmountUiAmount

PreciseDecimal

string

UI-formatted max coin amount

maxPcAmount

bigint

string

Maximum PC amount to deposit

maxPcAmountUiAmount

PreciseDecimal

string

UI-formatted max PC amount

coinAmountIn

bigint

string

Actual coin amount deposited

coinAmountInUiAmount

PreciseDecimal

string

UI-formatted coin deposit amount

pcAmountIn

bigint

string

Actual PC amount deposited

pcAmountInUiAmount

PreciseDecimal

string

UI-formatted PC deposit amount

lpTokenAmountOut

bigint

string

LP tokens minted

lpTokenAmountOutUiAmount

PreciseDecimal

string

UI-formatted LP tokens minted

baseSide

string

string

Base side specification

lpMintAddress

string

string

LP token mint address

poolCoinToken

string

string

Pool coin token account

poolPcToken

string

string

Pool PC token account

userCoinTokenAccount

string

string

User's coin token account

userPcTokenAccount

string

string

User's PC token account

lpTokenAccount

string

string

User's LP token account

userCoinPreBalance

bigint

string

User coin balance before deposit

userCoinPreBalanceUiAmount

PreciseDecimal

string

UI-formatted user coin pre-balance

userCoinPostBalance

bigint

string

User coin balance after deposit

userCoinPostBalanceUiAmount

PreciseDecimal

string

UI-formatted user coin post-balance

userPcPreBalance

bigint

string

User PC balance before deposit

userPcPreBalanceUiAmount

PreciseDecimal

string

UI-formatted user PC pre-balance

userPcPostBalance

bigint

string

User PC balance after deposit

userPcPostBalanceUiAmount

PreciseDecimal

string

UI-formatted user PC post-balance

userLpPreBalance

bigint

string

User LP balance before deposit

userLpPreBalanceUiAmount

PreciseDecimal

string

UI-formatted user LP pre-balance

userLpPostBalance

bigint

string

User LP balance after deposit

userLpPostBalanceUiAmount

PreciseDecimal

string

UI-formatted user LP post-balance

poolCoinPreBalance

bigint

string

Pool coin balance before deposit

poolCoinPreBalanceUiAmount

PreciseDecimal

string

UI-formatted pool coin pre-balance

poolCoinPostBalance

bigint

string

Pool coin balance after deposit

poolCoinPostBalanceUiAmount

PreciseDecimal

string

UI-formatted pool coin post-balance

poolPcPreBalance

bigint

string

Pool PC balance before deposit

poolPcPreBalanceUiAmount

PreciseDecimal

string

UI-formatted pool PC pre-balance

poolPcPostBalance

bigint

string

Pool PC balance after deposit

poolPcPostBalanceUiAmount

PreciseDecimal

string

UI-formatted pool PC post-balance

WITHDRAW_PNL Event

Profit and loss withdrawal event from Serum to AMM pool.

Property
Type
JSON Type
Description

mint

string

string

Pool mint address

coinAmountOut

bigint

string

Coin amount withdrawn

coinAmountOutUiAmount

PreciseDecimal

string

UI-formatted coin withdrawal amount

pcAmountOut

bigint

string

PC amount withdrawn

pcAmountOutUiAmount

PreciseDecimal

string

UI-formatted PC withdrawal amount

poolCoinToken

string

string

Pool coin token account

poolPcToken

string

string

Pool PC token account

coinPnlToken

string

string

Coin PnL token account

pcPnlToken

string

string

PC PnL token account

serumCoinVault

string

string

Serum coin vault account

serumPcVault

string

string

Serum PC vault account

poolCoinPreBalance

bigint

string

Pool coin balance before withdrawal

poolCoinPreBalanceUiAmount

PreciseDecimal

string

UI-formatted pool coin pre-balance

poolCoinPostBalance

bigint

string

Pool coin balance after withdrawal

poolCoinPostBalanceUiAmount

PreciseDecimal

string

UI-formatted pool coin post-balance

poolPcPreBalance

bigint

string

Pool PC balance before withdrawal

poolPcPreBalanceUiAmount

PreciseDecimal

string

UI-formatted pool PC pre-balance

poolPcPostBalance

bigint

string

Pool PC balance after withdrawal

poolPcPostBalanceUiAmount

PreciseDecimal

string

UI-formatted pool PC post-balance

coinPnlPreBalance

bigint

string

Coin PnL balance before withdrawal

coinPnlPreBalanceUiAmount

PreciseDecimal

string

UI-formatted coin PnL pre-balance

coinPnlPostBalance

bigint

string

Coin PnL balance after withdrawal

coinPnlPostBalanceUiAmount

PreciseDecimal

string

UI-formatted coin PnL post-balance

pcPnlPreBalance

bigint

string

PC PnL balance before withdrawal

pcPnlPreBalanceUiAmount

PreciseDecimal

string

UI-formatted PC PnL pre-balance

pcPnlPostBalance

bigint

string

PC PnL balance after withdrawal

pcPnlPostBalanceUiAmount

PreciseDecimal

string

UI-formatted PC PnL post-balance

serumCoinVaultPreBalance

bigint

string

Serum coin vault balance before withdrawal

serumCoinVaultPreBalanceUiAmount

PreciseDecimal

string

UI-formatted serum coin vault pre-balance

serumCoinVaultPostBalance

bigint

string

Serum coin vault balance after withdrawal

serumCoinVaultPostBalanceUiAmount

PreciseDecimal

string

UI-formatted serum coin vault post-balance

serumPcVaultPreBalance

bigint

string

Serum PC vault balance before withdrawal

serumPcVaultPreBalanceUiAmount

PreciseDecimal

string

UI-formatted serum PC vault pre-balance

serumPcVaultPostBalance

bigint

string

Serum PC vault balance after withdrawal

serumPcVaultPostBalanceUiAmount

PreciseDecimal

string

UI-formatted serum PC vault post-balance

Data Types

  • bigint: Large integer values for token amounts

  • string: Text values for addresses and identifiers

  • number: Numeric values for percentages, nonces, and timestamps

  • PreciseDecimal: High-precision decimal representation for UI display

  • DecoderType: Enum indicating the decoder type (RAYDIUM_AMM)

Usage

The decoder automatically determines the event type and returns the appropriate structure. All monetary values are provided in both raw (bigint) and UI-formatted (PreciseDecimal) versions for flexibility in different use cases. The AMM decoder handles both coin and PC (quote) tokens with comprehensive balance tracking.

Last updated