# Meteora DBC

This document describes the output structure for the Meteora DBC (Dynamic Bond Curve) decoder functions. The decoder handles four main event types: INITIALIZE\_VIRTUAL\_POOL\_WITH\_SPL\_TOKEN, SWAP, MIGRATE\_METEORA\_DAMM, and MIGRATE\_METEORA\_DAMM\_V2.

### 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 DBC program ID                                                                                                |
| `eventType`       | `string`         | `string`         | Type of event (INITIALIZE\_VIRTUAL\_POOL\_WITH\_SPL\_TOKEN, SWAP, MIGRATE\_METEORA\_DAMM, MIGRATE\_METEORA\_DAMM\_V2) |
| `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\_VIRTUAL\_POOL\_WITH\_SPL\_TOKEN Event

Virtual pool initialization event with SPL token.

| Property     | Type     | JSON Type | Description               |
| ------------ | -------- | --------- | ------------------------- |
| `name`       | `string` | `string`  | Token name                |
| `symbol`     | `string` | `string`  | Token symbol              |
| `uri`        | `string` | `string`  | Token metadata URI        |
| `creator`    | `string` | `string`  | Pool creator address      |
| `mint`       | `string` | `string`  | Token mint address        |
| `pool`       | `string` | `string`  | Virtual pool address      |
| `quoteMint`  | `string` | `string`  | Quote token mint address  |
| `baseVault`  | `string` | `string`  | Base token vault address  |
| `quoteVault` | `string` | `string`  | Quote token vault address |

### SWAP Event

Token swap event on Meteora DBC virtual pool.

| Property                                 | Type             | JSON Type | Description                                |
| ---------------------------------------- | ---------------- | --------- | ------------------------------------------ |
| `isBuy`                                  | `boolean`        | `boolean` | True for buy orders, false for sell orders |
| `pool`                                   | `string`         | `string`  | Virtual pool address                       |
| `config`                                 | `string`         | `string`  | Pool configuration address                 |
| `hasReferral`                            | `boolean`        | `boolean` | Whether the swap has a referral            |
| `inputTokenAccount`                      | `string`         | `string`  | Input token account address                |
| `outputTokenAccount`                     | `string`         | `string`  | Output token account address               |
| `baseVault`                              | `string`         | `string`  | Base token vault address                   |
| `quoteVault`                             | `string`         | `string`  | Quote token vault address                  |
| `baseMint`                               | `string`         | `string`  | Base token mint address                    |
| `quoteMint`                              | `string`         | `string`  | Quote token mint address                   |
| `price`                                  | `bigint`         | `string`  | Current swap price                         |
| `priceUiAmount`                          | `PreciseDecimal` | `string`  | UI-formatted current price                 |
| `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              |
| `minimumAmountOut`                       | `bigint`         | `string`  | Minimum acceptable output amount           |
| `minimumAmountOutUiAmount`               | `PreciseDecimal` | `string`  | UI-formatted minimum output amount         |
| `nextSqrtPrice`                          | `bigint`         | `string`  | Next square root price                     |
| `nextSqrtPriceUiAmount`                  | `PreciseDecimal` | `string`  | UI-formatted next square root price        |
| `tradingFee`                             | `bigint`         | `string`  | Trading fee amount                         |
| `tradingFeeUiAmount`                     | `PreciseDecimal` | `string`  | UI-formatted trading fee                   |
| `protocolFee`                            | `bigint`         | `string`  | Protocol fee amount                        |
| `protocolFeeUiAmount`                    | `PreciseDecimal` | `string`  | UI-formatted protocol fee                  |
| `referralFee`                            | `bigint`         | `string`  | Referral fee amount                        |
| `referralFeeUiAmount`                    | `PreciseDecimal` | `string`  | UI-formatted referral fee                  |
| `currentTimestamp`                       | `number`         | `number`  | Current timestamp                          |
| `baseVaultPreBalance`                    | `bigint`         | `string`  | Base vault balance before swap             |
| `baseVaultPreBalanceUiAmount`            | `PreciseDecimal` | `string`  | UI-formatted base vault pre-balance        |
| `quoteVaultPreBalance`                   | `bigint`         | `string`  | Quote vault balance before swap            |
| `quoteVaultPreBalanceUiAmount`           | `PreciseDecimal` | `string`  | UI-formatted quote vault pre-balance       |
| `inputAccountAmountPreBalance`           | `bigint`         | `string`  | Input account balance before swap          |
| `inputAccountAmountPreBalanceUiAmount`   | `PreciseDecimal` | `string`  | UI-formatted input account pre-balance     |
| `outputAccountAmountPreBalance`          | `bigint`         | `string`  | Output account balance before swap         |
| `outputAccountAmountPreBalanceUiAmount`  | `PreciseDecimal` | `string`  | UI-formatted output account pre-balance    |
| `baseVaultPostBalance`                   | `bigint`         | `string`  | Base vault balance after swap              |
| `baseVaultPostBalanceUiAmount`           | `PreciseDecimal` | `string`  | UI-formatted base vault post-balance       |
| `quoteVaultPostBalance`                  | `bigint`         | `string`  | Quote vault balance after swap             |
| `quoteVaultPostBalanceUiAmount`          | `PreciseDecimal` | `string`  | UI-formatted quote vault post-balance      |
| `inputAccountAmountPostBalance`          | `bigint`         | `string`  | Input account balance after swap           |
| `inputAccountAmountPostBalanceUiAmount`  | `PreciseDecimal` | `string`  | UI-formatted input account post-balance    |
| `outputAccountAmountPostBalance`         | `bigint`         | `string`  | Output account balance after swap          |
| `outputAccountAmountPostBalanceUiAmount` | `PreciseDecimal` | `string`  | UI-formatted output account post-balance   |
| `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                 |
| `sqrtStartPrice`                         | `bigint`         | `string`  | Starting square root price                 |
| `sqrtPricePre`                           | `bigint`         | `string`  | Square root price before swap              |
| `sqrtPricePreUiAmount`                   | `PreciseDecimal` | `string`  | UI-formatted sqrt price before swap        |
| `sqrtPricePost`                          | `bigint`         | `string`  | Square root price after swap               |
| `sqrtPricePostUiAmount`                  | `PreciseDecimal` | `string`  | UI-formatted sqrt price after swap         |
| `virtualLiquidity`                       | `bigint`         | `string`  | Virtual liquidity amount                   |
| `virtualLiquidityUiAmount`               | `PreciseDecimal` | `string`  | UI-formatted virtual liquidity             |

### MIGRATE\_METEORA\_DAMM Event

Migration event from DBC to Meteora DAMM.

| Property            | Type     | JSON Type | Description                 |
| ------------------- | -------- | --------- | --------------------------- |
| `virtualPool`       | `string` | `string`  | Source virtual pool address |
| `migrationMetadata` | `string` | `string`  | Migration metadata account  |
| `pool`              | `string` | `string`  | Destination pool address    |
| `lpMint`            | `string` | `string`  | LP token mint address       |
| `tokenAMint`        | `string` | `string`  | Token A mint address        |
| `tokenBMint`        | `string` | `string`  | Token B mint address        |
| `AVault`            | `string` | `string`  | Token A vault address       |
| `BVault`            | `string` | `string`  | Token B vault address       |
| `ATokenVault`       | `string` | `string`  | Token A token vault address |
| `BTokenVault`       | `string` | `string`  | Token B token vault address |
| `AlpVault`          | `string` | `string`  | Token A LP vault address    |
| `BlPVault`          | `string` | `string`  | Token B LP vault address    |

### MIGRATE\_METEORA\_DAMM\_V2 Event

Migration event from DBC to Meteora DAMM V2.

| Property                   | Type     | JSON Type | Description                         |
| -------------------------- | -------- | --------- | ----------------------------------- |
| `virtualPool`              | `string` | `string`  | Source virtual pool address         |
| `migrationMetadata`        | `string` | `string`  | Migration metadata account          |
| `pool`                     | `string` | `string`  | Destination pool address            |
| `firstPositionNftMint`     | `string` | `string`  | First position NFT mint address     |
| `firstPositionNftAccount`  | `string` | `string`  | First position NFT account address  |
| `firstPosition`            | `string` | `string`  | First position account address      |
| `secondPositionNftMint`    | `string` | `string`  | Second position NFT mint address    |
| `secondPositionNftAccount` | `string` | `string`  | Second position NFT account address |
| `secondPosition`           | `string` | `string`  | Second position account address     |
| `baseMint`                 | `string` | `string`  | Base token mint address             |
| `quoteMint`                | `string` | `string`  | Quote token mint address            |

### Data Types

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

### 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 DBC decoder handles dynamic bonding curve mechanics with comprehensive price tracking, fee calculation, and migration capabilities to other Meteora protocols.
