});
```
## Read Progress And Fees
```typescript theme={"system"}
const quoteProgress = await client.state.getPoolQuoteTokenCurveProgress(pool);
const baseProgress = await client.state.getPoolBaseTokenCurveProgress(pool);
const feeMetrics = await client.state.getPoolFeeMetrics(pool);
const feeBreakdown = await client.state.getPoolFeeBreakdown(pool);
console.log({
quoteProgress,
baseProgress,
currentPartnerQuoteFee: feeMetrics.current.partnerQuoteFee.toString(),
totalTradingQuoteFee: feeMetrics.total.totalTradingQuoteFee.toString(),
partnerUnclaimedQuoteFee: feeBreakdown.partner.unclaimedQuoteFee.toString(),
});
```
## Claim Fees
```typescript theme={"system"}
const partnerClaimTx = await client.partner.claimPartnerTradingFeeToReceiver({
feeClaimer: partner.publicKey,
payer: partner.publicKey,
pool,
maxBaseAmount: new BN("18446744073709551615"),
maxQuoteAmount: new BN("18446744073709551615"),
receiver: partner.publicKey,
});
const creatorClaimTx = await client.creator.claimCreatorTradingFeeToReceiver({
creator: creator.publicKey,
payer: creator.publicKey,
pool,
maxBaseAmount: new BN("18446744073709551615"),
maxQuoteAmount: new BN("18446744073709551615"),
receiver: creator.publicKey,
});
```
## Migration Flow
| Destination | SDK sequence |
| - | - |
| DAMM v1 | `createDammV1MigrationMetadata`, optional `createLocker`, `migrateToDammV1`, optional `lockDammV1LpToken`, optional `claimDammV1LpToken`. |
| DAMM v2 | Optional `createLocker`, then `migrateToDammV2`. |
```typescript theme={"system"}
const { transaction: migrateToDammV2Tx } = await client.migration.migrateToDammV2({
payer: new PublicKey("MIGRATOR"),
pool,
dammConfig: new PublicKey("DAMM_V2_CONFIG"),
});
```
<Note>
Meteora runs mainnet migration keepers for eligible pools, including matching quote-mint thresholds, Stock Token quote pairs, and Jupiter Verified quote tokens with Organic Score greater than 50 and notional value greater than 750 USD. The SDK migration builders are still useful for manual migration, devnet validation, and custom keeper infrastructure. See [DBC Migration and Liquidity](/core-products/dbc/migration-and-liquidity) for the full keeper criteria.
</Note>
# DBC TS SDK Getting Started
Source: https://docs.meteora.ag/developer-guides/dbc/typescript-sdk/getting-started
Learn how to install @meteora-ag/dynamic-bonding-curve-sdk, initialize the DBC client, read standard and transfer-hook pool state, quote swaps, and test the SDK.
This guide shows how to install and initialize the official DBC TypeScript SDK, `@meteora-ag/dynamic-bonding-curve-sdk`.
Before you begin, here are the main resources:
<CardGroup>
<Card title="TypeScript SDK" icon="node-js" href="https://github.com/MeteoraAg/dynamic-bonding-curve-sdk/tree/main/packages/dynamic-bonding-curve">
SDK source, tests, IDLs, services, math helpers, and package metadata.
</Card>
<Card title="NPM Package" icon="npm" href="https://www.npmjs.com/package/@meteora-ag/dynamic-bonding-curve-sdk">
Published package for DBC TypeScript integrations.
</Card>
</CardGroup>
## Installation
Install the SDK and its Solana dependencies:
<Tabs>
<Tab title="npm">
```bash theme={"system"}
npm install @meteora-ag/dynamic-bonding-curve-sdk @solana/web3.js @solana/spl-token bn.js
```
</Tab>
<Tab title="pnpm">
```bash theme={"system"}
pnpm install @meteora-ag/dynamic-bonding-curve-sdk @solana/web3.js @solana/spl-token bn.js
```
</Tab>
<Tab title="yarn">
```bash theme={"system"}
yarn add @meteora-ag/dynamic-bonding-curve-sdk @solana/web3.js @solana/spl-token bn.js
```
</Tab>
<Tab title="bun">
```bash theme={"system"}
bun add @meteora-ag/dynamic-bonding-curve-sdk @solana/web3.js @solana/spl-token bn.js
```
</Tab>
</Tabs>
## Initialization
Create a client from a Solana connection and commitment:
```typescript theme={"system"}
import { Connection } from "@solana/web3.js";
import { DynamicBondingCurveClient } from "@meteora-ag/dynamic-bonding-curve-sdk";
const connection = new Connection(process.env.RPC_URL!, "confirmed");
const client = DynamicBondingCurveClient.create(connection, "confirmed");
```
The constructor is also public:
```typescript theme={"system"}
const client = new DynamicBondingCurveClient(connection, "confirmed");
```
## Program ID
The SDK defaults to the public DBC program ID on both mainnet and devnet:
```text theme={"system"}
dbcij3LWUppWqq96dh6gJWwBifmcGfLSB5D4DuSMaqN
```
## Reference
<CardGroup>
<Card title="SDK Examples" icon="bolt" href="/developer-guides/dbc/typescript-sdk/examples">
Explore full transaction flows, including pool initialization, swaps, liquidity, and more.
</Card>
<Card title="SDK Reference" icon="code" href="/developer-guides/dbc/typescript-sdk/reference">
Access the full method map, PDA helpers, and fee helpers for DBC.
</Card>
<Card title="Transfer Hooks" icon="code-branch" href="/developer-guides/dbc/typescript-sdk/transfer-hooks">
Build Token 2022 transfer-hook configs, pools, swaps, claims, and state reads.
</Card>
</CardGroup>
## Testing The SDK
The local package scripts use `pnpm` in the repository root and package scripts in `packages/dynamic-bonding-curve`.
```bash theme={"system"}
cd packages/dynamic-bonding-curve
pnpm install
pnpm run build
pnpm run check-types
pnpm test
```
Some tests depend on local validator fixtures and deployed program artifacts. For application integrations, simulate transactions and test on devnet before mainnet.
## Faucets
<CardGroup>
<Card title="Devnet Faucet" icon="faucet" href="https://faucet.solana.com/">
Request test SOL for devnet integration testing.
</Card>
</CardGroup>
# DBC TS SDK Reference
Source: https://docs.meteora.ag/developer-guides/dbc/typescript-sdk/reference
Understand @meteora-ag/dynamic-bonding-curve-sdk exports, services, config builders, transaction builders, state readers, quote helpers, constants, enums, and validation helpers.
This page is based on the public declaration surface of `@meteora-ag/dynamic-bonding-curve-sdk`. Use it as the high-level map for the SDK, then open the package types when you need exact parameter shapes.
```typescript theme={"system"}
import {
DynamicBondingCurveClient,
ActivationType,
BaseFeeMode,
CollectFeeMode,
MigrationOption,
SwapMode,
buildCurveWithMarketCap,
deriveDbcPoolAddress,
getDynamicFeeParams,
getFeeSchedulerParams,
getRateLimiterParams,
} from "@meteora-ag/dynamic-bonding-curve-sdk";
```
## Dependencies
| Package | Version |
| - | - |
| `@coral-xyz/anchor` | `^0.31.0` |
| `@solana/web3.js` | `^1.98.0` |
| `@solana/spl-token` | `^0.4.13` |
| `bn.js` | `^5.2.1` |
| `decimal.js` | `^10.5.0` |
## Program IDs
| Program | ID |
| - | - |
| DBC | `dbcij3LWUppWqq96dh6gJWwBifmcGfLSB5D4DuSMaqN` |
| DAMM v1 | `Eo7WjKq67rjJQSZxS6z3YkapzY3eMj6Xy8X5EQVn5UaB` |
| DAMM v2 | `cpamdpZCGKUy5JxQXB4dcpGPiikHawvSWAd6mEn1sGG` |
| Locker | `LocpQgucEQHbqNABEYvBvwoxCPsSbG91A1QaQhQQqjn` |
| Dynamic Vault | `24Uqj9JCLxUeoC3hGfh5W3s9FM9uCHDS2SG3LYwBpyTi` |
| Metaplex metadata | `metaqbxxUerdq28cj1RbAWkYQm3ybzjb6a8bt518x1s` |
## Core Exports
| Export | Use |
| - | - |
| `DynamicBondingCurveClient` | Main SDK client. Exposes `pool`, `partner`, `creator`, `migration`, and `state` services. |
| `DynamicBondingCurveIdl` | Bundled Anchor IDL JSON for `dynamic_bonding_curve`. |
| `DynamicBondingCurveTypes` | IDL TypeScript type export. |
| `DynamicBondingCurveProgram` | Base service class with the connection-backed Anchor program. |
| `types` exports | IDL account types, SDK parameter types, enums, and quote result types. |
| `constants` exports | Program IDs, fee constants, curve limits, migration fee config keys, and default parameter structs. |
| `helpers` exports | Curve builders, PDA helpers, validation helpers, token helpers, instruction helpers, and config math helpers. |
| `services` exports | Service classes for partner, pool, creator, migration, program, and state flows. |
| `math` exports | Curve math, swap quote math, fee math, safe math, and pool fee handlers. |
## Enums
| Enum | Values |
| - | - |
| `ActivationType` | `Slot = 0`, `Timestamp = 1`. |
| `TokenType` | `SPLToken = 0`, `Token2022 = 1`. |
| `CollectFeeMode` | `QuoteToken = 0`, `OutputToken = 1`. |
| `MigratedCollectFeeMode` | `QuoteToken = 0`, `OutputToken = 1`, `Compounding = 2`. |
| `DammV2DynamicFeeMode` | `Disabled = 0`, `Enabled = 1`. |
| `DammV2BaseFeeMode` | `FeeTimeSchedulerLinear = 0`, `FeeTimeSchedulerExponential = 1`, `RateLimiter = 2`, `FeeMarketCapSchedulerLinear = 3`, `FeeMarketCapSchedulerExponential = 4`. |
| `MigrationOption` | `MET_DAMM = 0` (deprecated for new configs and new pools), `MET_DAMM_V2 = 1`. |
| `BaseFeeMode` | `FeeSchedulerLinear = 0`, `FeeSchedulerExponential = 1`, `RateLimiter = 2` (deprecated for new configs and new pools). |
| `MigrationFeeOption` | `FixedBps25 = 0`, `FixedBps30 = 1`, `FixedBps100 = 2`, `FixedBps200 = 3`, `FixedBps400 = 4`, `FixedBps600 = 5`, `Customizable = 6`. |
| `TokenDecimal` | `SIX = 6`, `SEVEN = 7`, `EIGHT = 8`, `NINE = 9`. |
| `TradeDirection` | `BaseToQuote = 0`, `QuoteToBase = 1`. |
| `SwapMode` | `ExactIn = 0`, `PartialFill = 1`, `ExactOut = 2`. |
| `TokenAuthorityOption` | `CreatorUpdateAuthority = 0`, `Immutable = 1`, `PartnerUpdateAuthority = 2`, `CreatorUpdateAndMintAuthority = 3`, `PartnerUpdateAndMintAuthority = 4`. |
## Important Constants
| Constant | Value |
| - | - |
| `MAX_CURVE_POINT` | `16` |
| `FEE_DENOMINATOR` | `1_000_000_000` |
| `MAX_BASIS_POINT` | `10_000` |
| `U16_MAX`, `U24_MAX`, `U64_MAX`, `U128_MAX` | Integer bounds used by validation and math helpers. |
| `MIN_SQRT_PRICE` / `MAX_SQRT_PRICE` | `4295048016` / `79226673521066979257578248091` |
| `MIN_FEE_BPS` / `MAX_FEE_BPS` | `25` / `9900` |
| `MIN_FEE_NUMERATOR` / `MAX_FEE_NUMERATOR` | `2_500_000` / `990_000_000` |
| `MAX_RATE_LIMITER_DURATION_IN_SECONDS` | `43_200` |
| `MAX_RATE_LIMITER_DURATION_IN_SLOTS` | `108_000` |
| `DYNAMIC_FEE_FILTER_PERIOD_DEFAULT`, `DYNAMIC_FEE_DECAY_PERIOD_DEFAULT`, `DYNAMIC_FEE_REDUCTION_FACTOR_DEFAULT` | Default dynamic-fee timing and reduction settings. |
| `BIN_STEP_BPS_DEFAULT`, `BIN_STEP_BPS_U128_DEFAULT`, `MAX_PRICE_CHANGE_BPS_DEFAULT` | Default dynamic-fee bin and price-change settings. |
| `PROTOCOL_FEE_PERCENT` / `HOST_FEE_PERCENT` | `20` / `20` |
| `SWAP_BUFFER_PERCENTAGE` | `25` |
| `MAX_MIGRATION_FEE_PERCENTAGE` / `MAX_CREATOR_MIGRATION_FEE_PERCENTAGE` | `99` / `100` |
| `MIN_LOCKED_LIQUIDITY_BPS` | `1000` |
| `SECONDS_PER_DAY` | `86400` |
| `MAX_LOCK_DURATION_IN_SECONDS` | `63_072_000` |
| `PROTOCOL_POOL_CREATION_FEE_PERCENT` | `10` |
| `MIN_POOL_CREATION_FEE` / `MAX_POOL_CREATION_FEE` | `1_000_000` / `100_000_000_000` lamports |
| `MIN_MIGRATED_POOL_FEE_BPS` / `MAX_MIGRATED_POOL_FEE_BPS` | `10` / `1000` |
| `DAMM_V1_MIGRATION_FEE_ADDRESS`, `DAMM_V2_MIGRATION_FEE_ADDRESS` | Published migration fee config addresses used by migrated-pool flows. |
| `DEFAULT_MIGRATED_POOL_FEE_PARAMS`, `DEFAULT_LIQUIDITY_VESTING_INFO_PARAMS`, `DEFAULT_MIGRATED_POOL_MARKET_CAP_FEE_SCHEDULER_PARAMS` | Default config helper structs. |
## Creating A Client
```typescript theme={"system"}
import { Connection } from "@solana/web3.js";
import { DynamicBondingCurveClient } from "@meteora-ag/dynamic-bonding-curve-sdk";
const connection = new Connection(process.env.RPC_URL!, "confirmed");
const client = DynamicBondingCurveClient.create(connection, "confirmed");
```
The client creates service instances for transactions, quotes, and account reads. The returned transactions are unsigned; callers still set blockhashes when needed, sign, simulate, and submit.
## Complete Function Index
### Client And Program Helpers
| Function or method | Returns | Use |
| - | - | - |
| `new DynamicBondingCurveClient(connection, commitment)` | `DynamicBondingCurveClient` | Construct a client and its service instances manually. |
| `DynamicBondingCurveClient.create(connection, commitment?)` | `DynamicBondingCurveClient` | Preferred client factory. Defaults commitment to `confirmed`. |
| `new DynamicBondingCurveProgram(connection, commitment)` | `DynamicBondingCurveProgram` | Construct the base program service used by concrete services. |
| `DynamicBondingCurveProgram.getProgram()` | `Program<DynamicBondingCurve>` | Return the underlying Anchor program instance. |
| `createDbcProgram(connection, commitment?)` | DBC program wrapper | Create an Anchor program for the DBC IDL and program ID. |
| `createDynamicVaultProgram(connection, commitment?)` | Dynamic Vault program wrapper | Create an Anchor program for Dynamic Vault migration helpers. |
| `createDammV1Program(connection, commitment?)` | DAMM v1 program wrapper | Create an Anchor program for DAMM v1 migration helpers. |
| `createDammV2Program(connection, commitment?)` | DAMM v2 program wrapper | Create an Anchor program for DAMM v2 migration helpers. |
### `PartnerService`
| Method | Returns | Use |
| - | - | - |
| `createConfig(params)` | `Promise<Transaction>` | Create a `PoolConfig` from `CreateConfigParams`. |
| `createConfigWithTransferHook(params)` | `Promise<Transaction>` | Create a `ConfigWithTransferHook` from `CreateConfigWithTransferHookParams`. |
| `createConfigAndPool(params)` | `Promise<Transaction>` | Build one transaction that creates a config and initializes a standard pool. |
| `createConfigAndPoolWithTransferHook(params)` | `Promise<Transaction>` | Build one transaction that creates a transfer-hook config and initializes a transfer-hook pool. |
| `createConfigAndPoolWithFirstBuy(params)` | `Promise<{ createConfigTx; createPoolWithFirstBuyTx }>` | Build separate config and pool-with-first-buy transactions for a standard pool. |
| `createConfigAndPoolWithFirstBuyWithTransferHook(params)` | `Promise<{ createConfigTx; createPoolWithFirstBuyTx }>` | Build separate config and pool-with-first-buy transactions for a transfer-hook pool. |
| `createPartnerMetadata(params)` | `Promise<Transaction>` | Create partner metadata for a fee claimer. |
| `claimPartnerTradingFee(params)` | `Promise<Transaction>` | Claim partner trading fees with optional SOL wrapping behavior. |
| `claimPartnerTradingFeeToReceiver(params)` | `Promise<Transaction>` | Claim standard-pool partner trading fees to an explicit receiver. |
| `claimPartnerTradingFee2(params)` | `Promise<Transaction>` | Claim transfer-hook pool partner trading fees. |
| `partnerWithdrawSurplus(params)` | `Promise<Transaction>` | Withdraw partner surplus after migration. |
| `partnerWithdrawMigrationFee(params)` | `Promise<Transaction>` | Withdraw the partner share of migration fees. |
| `claimPartnerPoolCreationFee(params)` | `Promise<Transaction>` | Claim the partner share of pool creation fees. |
### `PoolService`
| Method | Returns | Use |
| - | - | - |
| `swap(params)` | `Promise<Transaction>` | Build the legacy exact-in swap transaction. |
| `swap2(params)` | `Promise<Transaction>` | Build the preferred swap transaction for exact-in, partial-fill, and exact-out modes. |
| `swap2WithTransferHook(params)` | `Promise<Transaction>` | Build the transfer-hook swap transaction for exact-in, partial-fill, and exact-out modes. |
| `swapQuote(params)` | `SwapQuoteResult` | Quote the legacy exact-in swap path. |
| `swapQuote2(params)` | `SwapQuote2Result` | Quote `SwapMode.ExactIn`, `PartialFill`, or `ExactOut`. |
### `CreatorService`
| Method | Returns | Use |
| - | - | - |
| `createPool(params)` | `Promise<Transaction>` | Create a standard virtual pool from an existing config and base mint. Pass optional `tokenBadge` on `CreatePoolParams` when the quote mint is not permissionless-supported. |
| `createPoolWithTransferHook(params)` | `Promise<Transaction>` | Create a transfer-hook pool from an existing transfer-hook config. |
| `createPoolWithFirstBuy(params)` | `Promise<Transaction>` | Create a standard pool and include an initial buy. |
| `createPoolWithFirstBuyWithTransferHook(params)` | `Promise<Transaction>` | Create a transfer-hook pool and include an initial buy. |
| `createPoolWithPartnerAndCreatorFirstBuy(params)` | `Promise<Transaction>` | Create a standard pool with partner and creator first-buy handling. |
| `createPoolWithPartnerAndCreatorFirstBuyWithTransferHook(params)` | `Promise<Transaction>` | Create a transfer-hook pool with partner and creator first-buy handling. |
| `createPoolMetadata(params)` | `Promise<Transaction>` | Create optional metadata for a virtual pool. |
| `claimCreatorTradingFee(params)` | `Promise<Transaction>` | Claim creator trading fees with optional SOL wrapping behavior. |
| `claimCreatorTradingFeeToReceiver(params)` | `Promise<Transaction>` | Claim standard-pool creator trading fees to an explicit receiver. |
| `claimCreatorTradingFee2(params)` | `Promise<Transaction>` | Claim transfer-hook pool creator trading fees. |
| `creatorWithdrawSurplus(params)` | `Promise<Transaction>` | Withdraw creator surplus after migration. |
| `transferPoolCreator(params)` | `Promise<Transaction>` | Transfer creator rights to a new creator. |
| `creatorWithdrawMigrationFee(params)` | `Promise<Transaction>` | Withdraw the creator share of migration fees. |
### `MigrationService`
| Method | Returns | Use |
| - | - | - |
| `createLocker(params)` | `Promise<Transaction>` | Create a locker escrow when locked vesting is configured. |
| `withdrawLeftover(params)` | `Promise<Transaction>` | Withdraw leftover base tokens after migration. |
| `createDammV1MigrationMetadata(params)` | `Promise<Transaction>` | Create DAMM v1 migration metadata. |
| `migrateToDammV1(params)` | `Promise<Transaction>` | Migrate a completed DBC pool to DAMM v1. |
| `lockDammV1LpToken(params)` | `Promise<Transaction>` | Lock DAMM v1 LP allocation. |
| `claimDammV1LpToken(params)` | `Promise<Transaction>` | Claim locked DAMM v1 LP allocation. |
| `migrateToDammV2(params)` | `Promise<MigrateToDammV2Response>` | Migrate a completed DBC pool to DAMM v2 and return position NFT keypairs with the transaction. |
### `StateService`
| Method | Returns | Use |
| - | - | - |
| `getPoolConfig(configAddress)` | `Promise<PoolConfig or null>` | Fetch one standard or transfer-hook config. Transfer-hook configs return the embedded `PoolConfig`. |
| `getPoolConfigs()` | `Promise<ProgramAccount<PoolConfig>[]>` | Fetch all standard and transfer-hook configs. |
| `getPoolConfigsByOwner(owner)` | `Promise<ProgramAccount<PoolConfig>[]>` | Fetch standard and transfer-hook configs by partner owner or fee claimer. |
| `getPool(poolAddress)` | `Promise<VirtualPool or null>` | Fetch one standard or transfer-hook pool account. |
| `getPools()` | `Promise<ProgramAccount<VirtualPool>[]>` | Fetch all standard and transfer-hook pool accounts. |
| `getPoolsByConfig(configAddress)` | `Promise<ProgramAccount<VirtualPool>[]>` | Fetch standard and transfer-hook pools created from one config. |
| `getPoolsByCreator(creatorAddress)` | `Promise<ProgramAccount<VirtualPool>[]>` | Fetch standard and transfer-hook pools by creator. |
| `getPoolByBaseMint(baseMint)` | `Promise<ProgramAccount<VirtualPool> or null>` | Resolve a standard or transfer-hook pool by base mint. |
| `getPoolMigrationQuoteThreshold(poolAddress)` | `Promise<BN>` | Read the migration quote threshold for a pool. |
| `getPoolQuoteTokenCurveProgress(poolAddress)` | `Promise<number>` | Calculate quote-side curve progress. |
| `getPoolBaseTokenCurveProgress(poolAddress)` | `Promise<number>` | Calculate base-side curve progress. |
| `getPoolMetadata(pool)` | `Promise<VirtualPoolMetadata[]>` | Fetch optional pool metadata accounts. |
| `getPartnerMetadata(feeClaimer)` | `Promise<PartnerMetadata[]>` | Fetch optional partner metadata accounts. |
| `getPoolFeeMetrics(poolAddress)` | Fee metrics object | Read lifetime fee metrics for one pool. |
| `getPoolFeeBreakdown(poolAddress)` | Fee breakdown object | Read current claimable fee breakdown for partner and creator. |
| `getPoolsFeesByConfig(configAddress)` | Aggregated fee metrics | Aggregate fee metrics across pools fo프로젝트로 돌아가기