Skip to main content

Documentation Index

Fetch the complete documentation index at: https://docs.meteora.ag/llms.txt

Use this file to discover all available pages before exploring further.

Use CPI when your Solana program must call DBC directly, for example to swap, add or remove liquidity, claim fees or rewards, or manage a DBC position as part of a larger protocol instruction.

Program ID

NetworkProgram ID
Mainnet Betadbcij3LWUppWqq96dh6gJWwBifmcGfLSB5D4DuSMaqN
Devnetdbcij3LWUppWqq96dh6gJWwBifmcGfLSB5D4DuSMaqN

Generated Bindings

For a Rust program in the same workspace, enable the DBC program crate with the cpi feature:
[dependencies]
dynamic-bonding-curve = { git = "https://github.com/MeteoraAg/dynamic-bonding-curve", package = "dynamic-bonding-curve", features = ["cpi"] }
If you are outside the repository, generate bindings from the published IDL and pin the IDL version you tested against.

CPI Instruction Scope

FlowCPI suitabilityNotes
Fee claimsGoodAccount lists are smaller and signer roles are clear.
SwapsPossiblePlan slippage, token accounts, token program variants, optional referral account, event authority, and optional instructions sysvar.
Pool creationPossible, but heavierRequires mint signer, metadata accounts, vault PDAs, token program variant, event authority, and payer accounts.
DAMM v1/v2 migrationAdvancedDBC migration instructions perform downstream CPIs into DAMM, locker, and token programs. Prefer SDK-built top-level transactions unless your program owns the keeper flow.
Protocol operator flowsUsually internalRequire admin-created operator accounts and protocol permissions.

Event CPI Accounts

Most public DBC instructions use #[event_cpi]. Include these accounts when constructing CPI contexts:
AccountPurpose
event_authorityDBC event authority PDA derived from __event_authority.
programDBC program account.
Destination event authoritiesMigration flows may also require DAMM, DAMM v2, or locker event authority accounts.

Remaining Accounts

Swaps may require the instructions sysvar as the first remaining account.
CaseRemaining account
Rate limiter base fee is activeSYSVAR_INSTRUCTIONS_PUBKEY
enable_first_swap_with_min_fee is enabledSYSVAR_INSTRUCTIONS_PUBKEY
No rate limiter and no first-swap minimum feeNo swap-specific remaining account is required by this rule.
The program validates single-swap behavior for active rate limiter pools. The first-swap minimum-fee path also validates that pool initialization appears earlier in the top-level transaction; do not assume a CPI-only path is eligible for that minimum fee.

Swap CPI Shape

Use swap2 for new integrations because it supports exact-in, partial-fill, and exact-out modes.
ModeRequired user limit
Exact inMinimum output amount.
Partial fillMinimum output amount and clear handling of amount_left.
Exact outMaximum input amount.
Before calling DBC from your program:
  1. Decode and validate VirtualPool and PoolConfig.
  2. Verify account ownership and data length before deserializing.
  3. Use the Rust quote library or TypeScript SDK math to calculate expected amounts.
  4. Pass user-controlled slippage limits into your own instruction args.
  5. Recheck token mints, vaults, token program IDs, and signer authorities in your account constraints.

Token Programs

DBC supports SPL Token and Token-2022 base mints. Migration and pool creation account lists differ by token type.
Token sideGuidance
Base mintRead PoolConfig.token_type and VirtualPool.pool_type; use the matching token program.
Quote mintNative SOL uses wrapped SOL account handling in SDK-built transactions. CPI integrations must prepare token accounts explicitly.
Token-2022Include Token-2022 program accounts where required and validate associated token accounts carefully.

Common CPI Failures

Some DBC handlers wrap downstream CPIs with account invariant checks. If the downstream CPI unexpectedly changes account owner, data length, or reduces lamports, DBC can return AccountInvariantViolation.
ErrorCommon CPI cause
InvalidAccountPDA, vault, mint, owner, or token program mismatch.
IncorrectATAAssociated token account owner or mint mismatch.
FailToValidateSingleSwapInstructionMissing instructions sysvar or invalid single-swap transaction context.
FirstSwapValidationFailedFirst-swap minimum-fee transaction context does not match program requirements.
AccountInvariantViolationDownstream CPI changed protected account invariants.
CpiDisabledDownstream protocol zap CPI disabled.

Best Practices

PracticeWhy it matters
Prefer SDK-built transactions for frontends and botsThe SDK keeps account order, wrapped SOL, event authorities, and remaining accounts aligned with the IDL.
Keep CPI account lists explicitDBC migration and swap flows have many optional and downstream accounts.
Pin IDL and program versionsThe local IDL is 0.1.10; regenerate bindings when the IDL changes.
Simulate on devnet or localnetMigration and swap CPI failures are easier to diagnose before mainnet.
Store raw event and account data in indexersEvtSwap2 and VirtualPool state are both needed for reliable charting and progress tracking.