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.
This guide shows how to install and initialize the official Dynamic Fee Sharing TypeScript SDK, @meteora-ag/dynamic-fee-sharing-sdk.
Before you begin, here are the main resources:
TypeScript SDK Dynamic Fee Sharing TypeScript SDK repository.
Dynamic Fee Sharing NPM Package Published package for transaction builders, state reads, PDA helpers, and examples.
Install
To use the SDK in your project, install it with your preferred package manager:
npm install @meteora-ag/dynamic-fee-sharing-sdk @solana/web3.js @solana/spl-token bn.js
pnpm install @meteora-ag/dynamic-fee-sharing-sdk @solana/web3.js @solana/spl-token bn.js
yarn add @meteora-ag/dynamic-fee-sharing-sdk @solana/web3.js @solana/spl-token bn.js
Dependencies
Package Version @coral-xyz/anchor^0.31.0@meteora-ag/cp-amm-sdk^1.2.0@meteora-ag/dynamic-bonding-curve-sdk^1.4.5@solana/spl-token^0.4.13@solana/web3.js^1.98.0bn.js^5.2.1decimal.js^10.5.0
Create A Client
import { Connection } from "@solana/web3.js" ;
import { DynamicFeeSharingClient } from "@meteora-ag/dynamic-fee-sharing-sdk" ;
const connection = new Connection ( process . env . RPC_URL ! , "confirmed" );
const client = new DynamicFeeSharingClient ( connection , "confirmed" );
The client builds unsigned transactions. Your application is responsible for signing, simulating, sending, and confirming them.
Program IDs
Constant Value DYNAMIC_FEE_SHARING_PROGRAM_IDdfsdo2UqvwfN8DuUVrMRNfQe11VaiNoKcMqLHVvDPzh
Derive Addresses
import {
deriveFeeVaultAuthorityAddress ,
deriveFeeVaultPdaAddress ,
deriveTokenVaultAddress ,
} from "@meteora-ag/dynamic-fee-sharing-sdk" ;
const feeVault = deriveFeeVaultPdaAddress ( base . publicKey , tokenMint );
const tokenVault = deriveTokenVaultAddress ( feeVault );
const feeVaultAuthority = deriveFeeVaultAuthorityAddress ();
Create A Fee Vault
Use createFeeVault for a keypair-based fee vault:
import { Keypair } from "@solana/web3.js" ;
import { TOKEN_PROGRAM_ID } from "@solana/spl-token" ;
const feeVault = Keypair . generate ();
const tx = await client . createFeeVault ({
feeVault: feeVault . publicKey ,
tokenMint ,
tokenProgram: TOKEN_PROGRAM_ID ,
owner: owner . publicKey ,
payer: payer . publicKey ,
userShare: [
{ address: userA . publicKey , share: 600 },
{ address: userB . publicKey , share: 400 },
],
});
// Sign with payer and feeVault.
Use createFeeVaultPda when the vault must be deterministic or must sign whitelisted source-program fee claims:
const tx = await client . createFeeVaultPda ({
base: base . publicKey ,
tokenMint ,
tokenProgram: TOKEN_PROGRAM_ID ,
owner: owner . publicKey ,
payer: payer . publicKey ,
userShare: [
{ address: userA . publicKey , share: 600 },
{ address: userB . publicKey , share: 400 },
],
});
// Sign with payer and base.
Fund And Claim
import BN from "bn.js" ;
const fundTx = await client . fundFeeVault ({
feeVault ,
funder: funder . publicKey ,
fundAmount: new BN ( "1000000" ),
});
// Sign with funder.
const claimTx = await client . claimUserFee ({
feeVault ,
user: userA . publicKey ,
payer: payer . publicKey ,
});
// Sign with payer and userA.
Use claimUserFee2 when the user signs but the claimed fee should be delivered to a separate receiver token account owner.
SDK Examples
Dynamic Fee Sharing Examples Example scripts for creating fee vaults, funding vaults, claiming user fees, reading state, and source-program funding.
Testing The SDK
If you have cloned the SDK repository, start with package-level checks and tests:
pnpm install
pnpm run build
bun test