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.

The TypeScript SDK package is @meteora-ag/dynamic-fee-sharing-sdk. It exports the DynamicFeeSharingClient class, PDA helpers, token helpers, constants, IDL-backed account types, and parameter types.
import {
  DynamicFeeSharingClient,
  DYNAMIC_FEE_SHARING_PROGRAM_ID,
  deriveFeeVaultPdaAddress,
  deriveTokenVaultAddress,
} from "@meteora-ag/dynamic-fee-sharing-sdk";

Client Construction

APISignatureUse
new DynamicFeeSharingClient(connection: Connection, commitment: Commitment)Creates an Anchor program client and caches the fee vault authority PDA.
createDfsProgram(connection: Connection, commitment?: Commitment) => DynamicFeeSharingProgramCreates the raw Anchor program client from the SDK IDL.

State Methods

APISignatureUse
getFeeVault(feeVault: PublicKey) => Promise<FeeVault>Fetches and decodes one fee vault account.
getFeeBreakdown(feeVault: PublicKey) => Promise<{ totalFundedFee; totalClaimedFee; totalUnclaimedFee; userFees }>Calculates total funded, claimed, unclaimed, and per-user fee totals from fee vault state.
getFeeBreakdown filters out empty user slots where share is zero.

Vault Creation Methods

APIParametersSignersUse
createFeeVaultfeeVault, tokenMint, tokenProgram, owner, payer, userSharepayer, feeVaultBuilds a transaction for a keypair-based fee vault.
createFeeVaultPdabase, tokenMint, tokenProgram, owner, payer, userSharepayer, baseBuilds a transaction for a deterministic PDA fee vault.
userShare maps to the on-chain UserShare[] type:
FieldTypeRule
addressPublicKeyMust not be the default public key.
sharenumberMust be greater than zero and fit u32.
The program requires 2 to 5 users.

Funding Methods

APIParametersSignerUse
fundFeeVaultfundAmount, funder, feeVault, optional feeVaultStatefunderDirectly funds a fee vault from the funder’s associated token account.
fundByClaimDammV2Feesigner, owner, feeVault, dammV2Pool, dammV2Position, dammV2PositionNftAccount, optional dammV2PoolStatesignerClaims DAMM v2 position fees into a PDA fee vault.
fundByClaimDammV2Rewardsigner, rewardIndex, feeVault, dammV2Pool, dammV2Position, dammV2PositionNftAccount, optional dammV2PoolStatesignerClaims one DAMM v2 reward into a PDA fee vault.
fundByClaimDbcCreatorTradingFeesigner, creator, feeVault, poolConfig, virtualPool, optional cached statessignerClaims DBC creator trading fees into a PDA fee vault.
fundByClaimDbcPartnerTradingFeesigner, feeClaimer, feeVault, poolConfig, virtualPool, optional cached statessignerClaims DBC partner trading fees into a PDA fee vault.
fundByWithdrawDbcCreatorSurplussigner, feeVault, poolConfig, virtualPool, optional cached statessignerWithdraws DBC creator surplus into a PDA fee vault.
fundByWithdrawDbcPartnerSurplussigner, feeVault, poolConfig, virtualPool, optional cached statessignerWithdraws DBC partner surplus into a PDA fee vault.
fundByWithdrawDbcMigrationFeesigner, isPartner, feeVault, poolConfig, virtualPool, optional cached statessignerWithdraws DBC migration fees into a PDA fee vault.
The source-program wrappers call the on-chain fund_by_claiming_fee instruction. That instruction requires a PDA fee vault and a signer that is one of the configured shareholders.

Claim Methods

APIParametersSignersUse
claimUserFeefeeVault, user, payerpayer, userClaims the user’s available amount into the user’s associated token account.
claimUserFee2feeVault, user, payer, receiverpayer, userClaims the user’s available amount into a receiver-associated token account. The receiver does not sign.
Both methods fetch the fee vault, find the user’s share index, create the destination associated token account if needed, and build claim_fee.

PDA Helpers

HelperSeedsReturns
deriveFeeVaultAuthorityAddress()fee_vault_authorityPublicKey
deriveTokenVaultAddress(feeVault)token_vault, fee vaultPublicKey
deriveFeeVaultPdaAddress(base, tokenMint)fee_vault, base, token mintPublicKey
deriveDammV2EventAuthorityAddress()__event_authority under DAMM v2PublicKey

Token And Transaction Helpers

HelperUse
getTokenProgram(tokenFlag)Maps SDK TokenType.SPL or TokenType.Token2022 to the SPL Token or Token 2022 program ID.
getOrCreateATAInstruction(connection, tokenMint, owner, payer, allowOwnerOffCurve, tokenProgram)Returns an associated token account and optional idempotent create instruction.
wrapSOLInstruction(from, to, amount)Builds native SOL wrap instructions for a WSOL token account.
unwrapSOLInstruction(owner, receiver, allowOwnerOffCurve?)Builds a WSOL close-account instruction when claiming native SOL.
setTokenAccountOwnerTx(tokenAccount, from, to, tokenProgramId)Builds a token-account authority transfer transaction, used for DAMM v2 position NFT account ownership handoff.
convertToLamportsBN(amount, tokenDecimal)Converts a UI amount string or number to a raw BN token amount.
checkPositionOwnership(connection, commitment, positionNftAccount, feeVault, tokenProgram?)Verifies that a DAMM v2 position NFT account is owned by the fee vault.
checkFeeVaultTokenMint(feeVaultTokenMint, tokenAMint, tokenBMint)Validates that the fee vault mint matches one of a pool’s token mints.

Constants

ExportValue or use
DYNAMIC_FEE_SHARING_PROGRAM_IDdfsdo2UqvwfN8DuUVrMRNfQe11VaiNoKcMqLHVvDPzh
FEE_VAULT_PREFIXfee_vault
FEE_VAULT_AUTHORITY_PREFIXfee_vault_authority
TOKEN_VAULT_PREFIXtoken_vault

Enums And Types

ExportValues or fields
TokenTypeSPL = 0, Token2022 = 1.
FeeVaultGenerated IDL account type for feeVault.
InitializeFeeVaultParameterspadding, users.
UserShareaddress, share.
CreateFeeVaultParamsKeypair fee vault creation params.
CreateFeeVaultPdaParamsPDA fee vault creation params.
FundFeeVaultParamsDirect funding params, with optional cached feeVaultState.
ClaimUserFeeParamsfeeVault, user, payer.
ClaimUserFee2ParamsfeeVault, user, payer, receiver.
Source funding paramsDAMM v2 and DBC wrapper parameter types listed in the funding API table.