# Meteora DAMM V2

This document describes the output structure for the Meteora DAMM V2 (Dynamic Automated Market Maker Version 2) decoder functions. The decoder handles four main event types: INITIALIZE\_POOL, SWAP, ADD\_LIQUIDITY, and REMOVE\_ALL\_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 V2 program ID                                                     |
| `eventType`       | `string`         | `string`         | Type of event (INITIALIZE\_POOL, SWAP, ADD\_LIQUIDITY, REMOVE\_ALL\_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\_POOL Event

Pool initialization event for Meteora DAMM V2.

| Property             | Type             | JSON Type | Description                    |
| -------------------- | ---------------- | --------- | ------------------------------ |
| `pool`               | `string`         | `string`  | Pool account address           |
| `position`           | `string`         | `string`  | Position account address       |
| `positionNftAccount` | `string`         | `string`  | Position NFT account address   |
| `tokenAMint`         | `string`         | `string`  | Token A mint address           |
| `tokenBMint`         | `string`         | `string`  | Token B mint address           |
| `tokenAVault`        | `string`         | `string`  | Token A vault address          |
| `tokenBVault`        | `string`         | `string`  | Token B vault address          |
| `payerTokenA`        | `string`         | `string`  | Payer's token A account        |
| `payerTokenB`        | `string`         | `string`  | Payer's token B account        |
| `liquidity`          | `bigint`         | `string`  | Initial liquidity amount       |
| `liquidityUiAmount`  | `PreciseDecimal` | `string`  | UI-formatted initial liquidity |
| `sqrtPrice`          | `bigint`         | `string`  | Square root price              |
| `sqrtPriceUiAmount`  | `PreciseDecimal` | `string`  | UI-formatted square root price |

### SWAP Event

Token swap event on Meteora DAMM V2 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        |
| `inputTokenPostBalance`          | `bigint`         | `string`  | Input token balance after swap          |
| `inputTokenPostBalanceUiAmount`  | `PreciseDecimal` | `string`  | UI-formatted input token post-balance   |
| `outputTokenPostBalance`         | `bigint`         | `string`  | Output token balance after swap         |
| `outputTokenPostBalanceUiAmount` | `PreciseDecimal` | `string`  | UI-formatted output token 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 |
| `inputTokenPreBalance`           | `bigint`         | `string`  | Input token balance before swap         |
| `inputTokenPreBalanceUiAmount`   | `PreciseDecimal` | `string`  | UI-formatted input token pre-balance    |
| `outputTokenPreBalance`          | `bigint`         | `string`  | Output token balance before swap        |
| `outputTokenPreBalanceUiAmount`  | `PreciseDecimal` | `string`  | UI-formatted output token 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           |
| `lpFee`                          | `bigint`         | `string`  | Liquidity provider fee amount           |
| `lpFeeUiAmount`                  | `PreciseDecimal` | `string`  | UI-formatted LP fee                     |
| `protocolFee`                    | `bigint`         | `string`  | Protocol fee amount                     |
| `protocolFeeUiAmount`            | `PreciseDecimal` | `string`  | UI-formatted protocol fee               |
| `partnerFee`                     | `bigint`         | `string`  | Partner fee amount                      |
| `partnerFeeUiAmount`             | `PreciseDecimal` | `string`  | UI-formatted partner fee                |
| `referralFee`                    | `bigint`         | `string`  | Referral fee amount                     |
| `referralFeeUiAmount`            | `PreciseDecimal` | `string`  | UI-formatted referral fee               |
| `isInputTokenA`                  | `boolean`        | `boolean` | Whether the input token is token A      |

### ADD\_LIQUIDITY Event

Liquidity addition event for Meteora DAMM V2 pool.

| Property                           | Type             | JSON Type | Description                               |
| ---------------------------------- | ---------------- | --------- | ----------------------------------------- |
| `pool`                             | `string`         | `string`  | Pool account address                      |
| `position`                         | `string`         | `string`  | Position account address                  |
| `tokenAAccount`                    | `string`         | `string`  | Token A account address                   |
| `tokenBAccount`                    | `string`         | `string`  | Token B account address                   |
| `tokenAMint`                       | `string`         | `string`  | Token A mint address                      |
| `tokenBMint`                       | `string`         | `string`  | Token B mint address                      |
| `liquidityDelta`                   | `bigint`         | `string`  | Change in liquidity amount                |
| `liquidityDeltaUiAmount`           | `PreciseDecimal` | `string`  | UI-formatted liquidity delta              |
| `tokenAAmountThreshold`            | `bigint`         | `string`  | Token A amount threshold                  |
| `tokenAAmountThresholdUiAmount`    | `PreciseDecimal` | `string`  | UI-formatted token A threshold            |
| `tokenBAmountThreshold`            | `bigint`         | `string`  | Token B amount threshold                  |
| `tokenBAmountThresholdUiAmount`    | `PreciseDecimal` | `string`  | UI-formatted token B threshold            |
| `tokenAAccountPostBalance`         | `bigint`         | `string`  | Token A account balance after addition    |
| `tokenAAccountPostBalanceUiAmount` | `PreciseDecimal` | `string`  | UI-formatted token A account post-balance |
| `tokenBAccountPostBalance`         | `bigint`         | `string`  | Token B account balance after addition    |
| `tokenBAccountPostBalanceUiAmount` | `PreciseDecimal` | `string`  | UI-formatted token B account post-balance |
| `tokenAVaultPostBalance`           | `bigint`         | `string`  | Token A vault balance after addition      |
| `tokenAVaultPostBalanceUiAmount`   | `PreciseDecimal` | `string`  | UI-formatted token A vault post-balance   |
| `tokenBVaultPostBalance`           | `bigint`         | `string`  | Token B vault balance after addition      |
| `tokenBVaultPostBalanceUiAmount`   | `PreciseDecimal` | `string`  | UI-formatted token B vault post-balance   |
| `tokenAAccountPreBalance`          | `bigint`         | `string`  | Token A account balance before addition   |
| `tokenAAccountPreBalanceUiAmount`  | `PreciseDecimal` | `string`  | UI-formatted token A account pre-balance  |
| `tokenBAccountPreBalance`          | `bigint`         | `string`  | Token B account balance before addition   |
| `tokenBAccountPreBalanceUiAmount`  | `PreciseDecimal` | `string`  | UI-formatted token B account pre-balance  |
| `tokenAVaultPreBalance`            | `bigint`         | `string`  | Token A vault balance before addition     |
| `tokenAVaultPreBalanceUiAmount`    | `PreciseDecimal` | `string`  | UI-formatted token A vault pre-balance    |
| `tokenBVaultPreBalance`            | `bigint`         | `string`  | Token B vault balance before addition     |
| `tokenBVaultPreBalanceUiAmount`    | `PreciseDecimal` | `string`  | UI-formatted token B vault pre-balance    |
| `owner`                            | `string`         | `string`  | Position owner 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       |

### REMOVE\_ALL\_LIQUIDITY Event

Complete liquidity removal event for Meteora DAMM V2 pool.

| Property                           | Type             | JSON Type | Description                               |
| ---------------------------------- | ---------------- | --------- | ----------------------------------------- |
| `pool`                             | `string`         | `string`  | Pool account address                      |
| `position`                         | `string`         | `string`  | Position account address                  |
| `tokenAAccount`                    | `string`         | `string`  | Token A account address                   |
| `tokenBAccount`                    | `string`         | `string`  | Token B account address                   |
| `tokenAVault`                      | `string`         | `string`  | Token A vault address                     |
| `tokenBVault`                      | `string`         | `string`  | Token B vault address                     |
| `tokenAAmountThreshold`            | `bigint`         | `string`  | Token A amount threshold                  |
| `tokenAAmountThresholdUiAmount`    | `PreciseDecimal` | `string`  | UI-formatted token A threshold            |
| `tokenBAmountThreshold`            | `bigint`         | `string`  | Token B amount threshold                  |
| `tokenBAmountThresholdUiAmount`    | `PreciseDecimal` | `string`  | UI-formatted token B threshold            |
| `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    |
| `tokenAAccountPostBalance`         | `bigint`         | `string`  | Token A account balance after removal     |
| `tokenAAccountPostBalanceUiAmount` | `PreciseDecimal` | `string`  | UI-formatted token A account post-balance |
| `tokenBAccountPostBalance`         | `bigint`         | `string`  | Token B account balance after removal     |
| `tokenBAccountPostBalanceUiAmount` | `PreciseDecimal` | `string`  | UI-formatted token B account post-balance |
| `tokenAVaultPostBalance`           | `bigint`         | `string`  | Token A vault balance after removal       |
| `tokenAVaultPostBalanceUiAmount`   | `PreciseDecimal` | `string`  | UI-formatted token A vault post-balance   |
| `tokenBVaultPostBalance`           | `bigint`         | `string`  | Token B vault balance after removal       |
| `tokenBVaultPostBalanceUiAmount`   | `PreciseDecimal` | `string`  | UI-formatted token B vault post-balance   |
| `tokenAAccountPreBalance`          | `bigint`         | `string`  | Token A account balance before removal    |
| `tokenAAccountPreBalanceUiAmount`  | `PreciseDecimal` | `string`  | UI-formatted token A account pre-balance  |
| `tokenBAccountPreBalance`          | `bigint`         | `string`  | Token B account balance before removal    |
| `tokenBAccountPreBalanceUiAmount`  | `PreciseDecimal` | `string`  | UI-formatted token B account pre-balance  |
| `tokenAVaultPreBalance`            | `bigint`         | `string`  | Token A vault balance before removal      |
| `tokenAVaultPreBalanceUiAmount`    | `PreciseDecimal` | `string`  | UI-formatted token A vault pre-balance    |
| `tokenBVaultPreBalance`            | `bigint`         | `string`  | Token B vault balance before removal      |
| `tokenBVaultPreBalanceUiAmount`    | `PreciseDecimal` | `string`  | UI-formatted token B vault pre-balance    |
| `owner`                            | `string`         | `string`  | Position owner address                    |

### Data Types

* `bigint`: Large integer values for token amounts, prices, and liquidity
* `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\_V2)

### 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 V2 decoder handles concentrated liquidity mechanics with position management, multiple fee tiers, and advanced slippage protection.
