# Meteora DAMM

This document describes the output structure for the Meteora DAMM (Dynamic Automated Market Maker) decoder functions. The decoder handles four main event types: INITIALIZE\_PERMISSIONLESS\_CONSTANT\_PRODUCT\_POOL\_WITH\_CONFIG2, SWAP, ADD\_BALANCE\_LIQUIDITY, and REMOVE\_BALANCE\_LIQUIDITY.

### 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`         | Meteora DAMM program ID                                                                                                                       |
| `eventType`       | `string`         | `string`         | Type of event (INITIALIZE\_PERMISSIONLESS\_CONSTANT\_PRODUCT\_POOL\_WITH\_CONFIG2, SWAP, ADD\_BALANCE\_LIQUIDITY, REMOVE\_BALANCE\_LIQUIDITY) |
| `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                                                                                                                  |

### INITIALIZE\_PERMISSIONLESS\_CONSTANT\_PRODUCT\_POOL\_WITH\_CONFIG2 Event

Constant product pool initialization event.

| Property               | Type             | JSON Type | Description                         |
| ---------------------- | ---------------- | --------- | ----------------------------------- |
| `lpMint`               | `string`         | `string`  | LP token mint address               |
| `mint`                 | `string`         | `string`  | Pool mint address                   |
| `tokenBMint`           | `string`         | `string`  | Token B mint address                |
| `tokenAVault`          | `string`         | `string`  | Token A vault address               |
| `tokenBVault`          | `string`         | `string`  | Token B vault address               |
| `tokenAAmount`         | `bigint`         | `string`  | Initial token A amount              |
| `tokenAAmountUiAmount` | `PreciseDecimal` | `string`  | UI-formatted initial token A amount |
| `tokenBAmount`         | `bigint`         | `string`  | Initial token B amount              |
| `tokenBAmountUiAmount` | `PreciseDecimal` | `string`  | UI-formatted initial token B amount |

### SWAP Event

Token swap event on Meteora DAMM pool.

| Property                             | Type             | JSON Type | Description                                |
| ------------------------------------ | ---------------- | --------- | ------------------------------------------ |
| `tokenAMint`                         | `string`         | `string`  | Token A mint address                       |
| `tokenBMint`                         | `string`         | `string`  | Token B mint address                       |
| `tokenADecimals`                     | `number`         | `number`  | Token A decimal places                     |
| `tokenBDecimals`                     | `number`         | `number`  | Token B decimal places                     |
| `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         |
| `slippageAmount`                     | `bigint`         | `string`  | Slippage amount                            |
| `slippageAmountUiAmount`             | `PreciseDecimal` | `string`  | UI-formatted slippage amount               |
| `expectedAmountOut`                  | `bigint`         | `string`  | Expected output amount                     |
| `expectedAmountOutUiAmount`          | `PreciseDecimal` | `string`  | UI-formatted expected output amount        |
| `slippageTolerance`                  | `bigint`         | `string`  | Slippage tolerance                         |
| `slippageToleranceUiAmount`          | `PreciseDecimal` | `string`  | UI-formatted slippage tolerance            |
| `actualPrice`                        | `bigint`         | `string`  | Actual swap price                          |
| `actualPriceUiAmount`                | `PreciseDecimal` | `string`  | UI-formatted actual price                  |
| `slippagePercentage`                 | `bigint`         | `string`  | Slippage percentage                        |
| `slippagePercentageUiAmount`         | `PreciseDecimal` | `string`  | UI-formatted slippage percentage           |
| `userSourcePostBalance`              | `bigint`         | `string`  | User source balance after swap             |
| `userSourcePostBalanceUiAmount`      | `PreciseDecimal` | `string`  | UI-formatted user source post-balance      |
| `userDestinationPostBalance`         | `bigint`         | `string`  | User destination balance after swap        |
| `userDestinationPostBalanceUiAmount` | `PreciseDecimal` | `string`  | UI-formatted user destination post-balance |
| `tokenAVaultPostBalance`             | `bigint`         | `string`  | Token A vault balance after swap           |
| `tokenAVaultPostBalanceUiAmount`     | `PreciseDecimal` | `string`  | UI-formatted token A vault post-balance    |
| `tokenBVaultPostBalance`             | `bigint`         | `string`  | Token B vault balance after swap           |
| `tokenBVaultPostBalanceUiAmount`     | `PreciseDecimal` | `string`  | UI-formatted token B vault post-balance    |
| `userSourcePreBalance`               | `bigint`         | `string`  | User source balance before swap            |
| `userSourcePreBalanceUiAmount`       | `PreciseDecimal` | `string`  | UI-formatted user source pre-balance       |
| `userDestinationPreBalance`          | `bigint`         | `string`  | User destination balance before swap       |
| `userDestinationPreBalanceUiAmount`  | `PreciseDecimal` | `string`  | UI-formatted user destination pre-balance  |
| `tokenAVaultPreBalance`              | `bigint`         | `string`  | Token A vault balance before swap          |
| `tokenAVaultPreBalanceUiAmount`      | `PreciseDecimal` | `string`  | UI-formatted token A vault pre-balance     |
| `tokenBVaultPreBalance`              | `bigint`         | `string`  | Token B vault balance before swap          |
| `tokenBVaultPreBalanceUiAmount`      | `PreciseDecimal` | `string`  | UI-formatted token B vault pre-balance     |
| `pricePre`                           | `bigint`         | `string`  | Price before swap                          |
| `pricePreUiAmount`                   | `PreciseDecimal` | `string`  | UI-formatted price before swap             |
| `pricePost`                          | `bigint`         | `string`  | Price after swap                           |
| `pricePostUiAmount`                  | `PreciseDecimal` | `string`  | UI-formatted price after swap              |
| `protocolTokenFeeAmount`             | `bigint`         | `string`  | Protocol token fee amount                  |
| `protocolTokenFeeAmountUiAmount`     | `PreciseDecimal` | `string`  | UI-formatted protocol token fee            |
| `isInputTokenA`                      | `boolean`        | `boolean` | Whether the input token is token A         |

### ADD\_BALANCE\_LIQUIDITY Event

Liquidity addition event for Meteora DAMM pool.

| Property                         | Type             | JSON Type | Description                             |
| -------------------------------- | ---------------- | --------- | --------------------------------------- |
| `lpMintAddress`                  | `string`         | `string`  | LP token mint address                   |
| `userPoolLp`                     | `string`         | `string`  | User's LP pool account                  |
| `tokenAVault`                    | `string`         | `string`  | Token A vault address                   |
| `tokenBVault`                    | `string`         | `string`  | Token B vault address                   |
| `userAToken`                     | `string`         | `string`  | User's token A account                  |
| `userBToken`                     | `string`         | `string`  | User's token B account                  |
| `lpAVault`                       | `string`         | `string`  | LP token A vault address                |
| `lpBVault`                       | `string`         | `string`  | LP token B vault address                |
| `lpAMintVault`                   | `string`         | `string`  | LP A mint vault address                 |
| `lpBMintVault`                   | `string`         | `string`  | LP B mint vault address                 |
| `tokenAAmountIn`                 | `bigint`         | `string`  | Token A amount deposited                |
| `tokenAAmountInUiAmount`         | `PreciseDecimal` | `string`  | UI-formatted token A deposit amount     |
| `tokenBAmountIn`                 | `bigint`         | `string`  | Token B amount deposited                |
| `tokenBAmountInUiAmount`         | `PreciseDecimal` | `string`  | UI-formatted token B deposit amount     |
| `lpTokenAmountOut`               | `bigint`         | `string`  | LP tokens minted                        |
| `lpTokenAmountOutUiAmount`       | `PreciseDecimal` | `string`  | UI-formatted LP tokens minted           |
| `maximumTokenAAmount`            | `bigint`         | `string`  | Maximum token A amount to deposit       |
| `maximumTokenAAmountUiAmount`    | `PreciseDecimal` | `string`  | UI-formatted maximum token A amount     |
| `maximumTokenBAmount`            | `bigint`         | `string`  | Maximum token B amount to deposit       |
| `maximumTokenBAmountUiAmount`    | `PreciseDecimal` | `string`  | UI-formatted maximum token B amount     |
| `userATokenPostBalance`          | `bigint`         | `string`  | User token A balance after deposit      |
| `userATokenPostBalanceUiAmount`  | `PreciseDecimal` | `string`  | UI-formatted user token A post-balance  |
| `userBTokenPostBalance`          | `bigint`         | `string`  | User token B balance after deposit      |
| `userBTokenPostBalanceUiAmount`  | `PreciseDecimal` | `string`  | UI-formatted user token B post-balance  |
| `lpTokenPostBalance`             | `bigint`         | `string`  | LP token balance after deposit          |
| `lpTokenPostBalanceUiAmount`     | `PreciseDecimal` | `string`  | UI-formatted LP token post-balance      |
| `tokenAVaultPostBalance`         | `bigint`         | `string`  | Token A vault balance after deposit     |
| `tokenAVaultPostBalanceUiAmount` | `PreciseDecimal` | `string`  | UI-formatted token A vault post-balance |
| `tokenBVaultPostBalance`         | `bigint`         | `string`  | Token B vault balance after deposit     |
| `tokenBVaultPostBalanceUiAmount` | `PreciseDecimal` | `string`  | UI-formatted token B vault post-balance |
| `userATokenPreBalance`           | `bigint`         | `string`  | User token A balance before deposit     |
| `userATokenPreBalanceUiAmount`   | `PreciseDecimal` | `string`  | UI-formatted user token A pre-balance   |
| `userBTokenPreBalance`           | `bigint`         | `string`  | User token B balance before deposit     |
| `userBTokenPreBalanceUiAmount`   | `PreciseDecimal` | `string`  | UI-formatted user token B pre-balance   |
| `lpTokenPreBalance`              | `bigint`         | `string`  | LP token balance before deposit         |
| `lpTokenPreBalanceUiAmount`      | `PreciseDecimal` | `string`  | UI-formatted LP token pre-balance       |
| `tokenAVaultPreBalance`          | `bigint`         | `string`  | Token A vault balance before deposit    |
| `tokenAVaultPreBalanceUiAmount`  | `PreciseDecimal` | `string`  | UI-formatted token A vault pre-balance  |
| `tokenBVaultPreBalance`          | `bigint`         | `string`  | Token B vault balance before deposit    |
| `tokenBVaultPreBalanceUiAmount`  | `PreciseDecimal` | `string`  | UI-formatted token B vault pre-balance  |

### REMOVE\_BALANCE\_LIQUIDITY Event

Liquidity removal event for Meteora DAMM pool.

| Property                         | Type             | JSON Type | Description                             |
| -------------------------------- | ---------------- | --------- | --------------------------------------- |
| `lpMintAddress`                  | `string`         | `string`  | LP token mint address                   |
| `userPoolLp`                     | `string`         | `string`  | User's LP pool account                  |
| `tokenAVault`                    | `string`         | `string`  | Token A vault address                   |
| `tokenBVault`                    | `string`         | `string`  | Token B vault address                   |
| `userAToken`                     | `string`         | `string`  | User's token A account                  |
| `userBToken`                     | `string`         | `string`  | User's token B account                  |
| `lpAVault`                       | `string`         | `string`  | LP token A vault address                |
| `lpBVault`                       | `string`         | `string`  | LP token B vault address                |
| `lpAMintVault`                   | `string`         | `string`  | LP A mint vault address                 |
| `lpBMintVault`                   | `string`         | `string`  | LP B mint vault address                 |
| `tokenAAmountOut`                | `bigint`         | `string`  | Token A amount withdrawn                |
| `tokenAAmountOutUiAmount`        | `PreciseDecimal` | `string`  | UI-formatted token A withdrawal amount  |
| `tokenBAmountOut`                | `bigint`         | `string`  | Token B amount withdrawn                |
| `tokenBAmountOutUiAmount`        | `PreciseDecimal` | `string`  | UI-formatted token B withdrawal amount  |
| `lpTokenAmountIn`                | `bigint`         | `string`  | LP tokens burned                        |
| `lpTokenAmountInUiAmount`        | `PreciseDecimal` | `string`  | UI-formatted LP tokens burned           |
| `minimumTokenAAmount`            | `bigint`         | `string`  | Minimum token A amount to receive       |
| `minimumTokenAAmountUiAmount`    | `PreciseDecimal` | `string`  | UI-formatted minimum token A amount     |
| `minimumTokenBAmount`            | `bigint`         | `string`  | Minimum token B amount to receive       |
| `minimumTokenBAmountUiAmount`    | `PreciseDecimal` | `string`  | UI-formatted minimum token B amount     |
| `userATokenPostBalance`          | `bigint`         | `string`  | User token A balance after withdrawal   |
| `userATokenPostBalanceUiAmount`  | `PreciseDecimal` | `string`  | UI-formatted user token A post-balance  |
| `userBTokenPostBalance`          | `bigint`         | `string`  | User token B balance after withdrawal   |
| `userBTokenPostBalanceUiAmount`  | `PreciseDecimal` | `string`  | UI-formatted user token B post-balance  |
| `lpTokenPostBalance`             | `bigint`         | `string`  | LP token balance after withdrawal       |
| `lpTokenPostBalanceUiAmount`     | `PreciseDecimal` | `string`  | UI-formatted LP token post-balance      |
| `tokenAVaultPostBalance`         | `bigint`         | `string`  | Token A vault balance after withdrawal  |
| `tokenAVaultPostBalanceUiAmount` | `PreciseDecimal` | `string`  | UI-formatted token A vault post-balance |
| `tokenBVaultPostBalance`         | `bigint`         | `string`  | Token B vault balance after withdrawal  |
| `tokenBVaultPostBalanceUiAmount` | `PreciseDecimal` | `string`  | UI-formatted token B vault post-balance |
| `userATokenPreBalance`           | `bigint`         | `string`  | User token A balance before withdrawal  |
| `userATokenPreBalanceUiAmount`   | `PreciseDecimal` | `string`  | UI-formatted user token A pre-balance   |
| `userBTokenPreBalance`           | `bigint`         | `string`  | User token B balance before withdrawal  |
| `userBTokenPreBalanceUiAmount`   | `PreciseDecimal` | `string`  | UI-formatted user token B pre-balance   |
| `lpTokenPreBalance`              | `bigint`         | `string`  | LP token balance before withdrawal      |
| `lpTokenPreBalanceUiAmount`      | `PreciseDecimal` | `string`  | UI-formatted LP token pre-balance       |
| `tokenAVaultPreBalance`          | `bigint`         | `string`  | Token A vault balance before withdrawal |
| `tokenAVaultPreBalanceUiAmount`  | `PreciseDecimal` | `string`  | UI-formatted token A vault pre-balance  |
| `tokenBVaultPreBalance`          | `bigint`         | `string`  | Token B vault balance before withdrawal |
| `tokenBVaultPreBalanceUiAmount`  | `PreciseDecimal` | `string`  | UI-formatted token B vault pre-balance  |

### Data Types

* `bigint`: Large integer values for token amounts and prices
* `string`: Text values for addresses and identifiers
* `number`: Numeric values for decimals and other integer values
* `boolean`: True/false values for token input indicators
* `PreciseDecimal`: High-precision decimal representation for UI display
* `DecoderType`: Enum indicating the decoder type (METEORA\_DAMM)

### 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 DAMM decoder handles constant product automated market maker mechanics with comprehensive balance tracking, slippage calculation, and liquidity management.
