Skip to content

Latest commit

 

History

History
227 lines (166 loc) · 6.18 KB

File metadata and controls

227 lines (166 loc) · 6.18 KB

Fee Sharing Guide

Set up and manage creator fee distribution among multiple shareholders.

Fee sharing flow — trades to creator vault to shareholders

Overview

Fee sharing allows token creators to split their accumulated trading fees among up to 10 shareholders. This is managed through the PumpFees program and works for both bonding curve tokens and graduated AMM tokens.

Prerequisites

import { Connection, PublicKey, Transaction, Keypair } from "@solana/web3.js";
import {
  PUMP_SDK,
  OnlinePumpSdk,
  isCreatorUsingSharingConfig,
  feeSharingConfigPda,
} from "@nirholas/pump-sdk";

const connection = new Connection("https://api.devnet.solana.com", "confirmed");
const onlineSdk = new OnlinePumpSdk(connection);

Step 1: Create a Fee Sharing Config

After creating a token, set up fee sharing:

const mint = new PublicKey("your-token-mint");
const creator = wallet.publicKey;

// For non-graduated tokens (still on bonding curve):
const ix = await PUMP_SDK.createFeeSharingConfig({
  creator,
  mint,
  pool: null,
});

// For graduated tokens (on AMM), you must provide the pool:
import { canonicalPumpPoolPda } from "@nirholas/pump-sdk";
const pool = canonicalPumpPoolPda(mint);

const ix = await PUMP_SDK.createFeeSharingConfig({
  creator,
  mint,
  pool,
});

Note: For graduated tokens (bondingCurve.complete === true), you must provide the pool address. For ungraduated tokens, pass pool: null.

Step 2: Set Up Shareholders

Define how fees are split. Shares are in basis points (bps), where 10,000 bps = 100%.

const shareholders = [
  { address: new PublicKey("wallet-A"), shareBps: 5000 }, // 50%
  { address: new PublicKey("wallet-B"), shareBps: 3000 }, // 30%
  { address: new PublicKey("wallet-C"), shareBps: 2000 }, // 20%
];

const ix = await PUMP_SDK.updateFeeShares({
  authority: creator,          // The config admin
  mint,
  currentShareholders: [],     // Empty on first setup
  newShareholders: shareholders,
});

Validation Rules

The SDK validates shareholders before building the instruction:

Rule Error
At least 1 shareholder NoShareholdersError
Maximum 10 shareholders TooManyShareholdersError
No zero shares ZeroShareError
Shares sum to 10,000 bps InvalidShareTotalError
No duplicate addresses DuplicateShareholderError

Step 3: Check Distributable Fees

Before distributing, check if there are enough accumulated fees:

const result = await onlineSdk.getMinimumDistributableFee(mint);

console.log("Minimum required:", result.minimumRequired.toString());
console.log("Available:", result.distributableFees.toString());
console.log("Can distribute:", result.canDistribute);
console.log("Token graduated:", result.isGraduated);

Step 4: Distribute Fees

When fees are ready, build and send the distribution transaction:

const { instructions, isGraduated } =
  await onlineSdk.buildDistributeCreatorFeesInstructions(mint);

const tx = new Transaction().add(...instructions);
const sig = await sendAndConfirmTransaction(connection, tx, [wallet]);

For graduated tokens, the method automatically includes a transferCreatorFeesToPump instruction to consolidate AMM vault fees before distributing.

Checking Fee Sharing Status

Verify whether a creator has already set up fee sharing:

const isSharing = isCreatorUsingSharingConfig({ mint, creator });

if (isSharing) {
  // Fee sharing is active
  const configAddress = feeSharingConfigPda(mint);
  // ... decode and inspect the config
}

Updating Shareholders

To change the distribution, pass both current and new shareholders:

const currentShareholders = [
  new PublicKey("wallet-A"),
  new PublicKey("wallet-B"),
  new PublicKey("wallet-C"),
];

const newShareholders = [
  { address: new PublicKey("wallet-A"), shareBps: 6000 },
  { address: new PublicKey("wallet-D"), shareBps: 4000 },
];

const ix = await PUMP_SDK.updateFeeShares({
  authority: creator,
  mint,
  currentShareholders,  // PublicKey[] of current shareholders
  newShareholders,
});

Collecting Creator Fees (Without Sharing)

If fee sharing is not set up, creators can collect fees directly:

// Collect from both Pump and AMM programs
const instructions = await onlineSdk.collectCoinCreatorFeeInstructions(creator);

// Check balance before collecting
const balance = await onlineSdk.getCreatorVaultBalanceBothPrograms(creator);
console.log("Uncollected fees:", balance.toString(), "lamports");

Social Fee PDAs

For platform-based fee routing (e.g., tipping by username rather than wallet address), the SDK supports social fee PDAs.

// Create a social fee PDA for a platform user
const ix = await PUMP_SDK.createSocialFeePdaInstruction({
  payer: wallet.publicKey,
  userId: "user123",
  platform: 1,   // platform identifier
});

// Claim fees routed to a social fee PDA
const ix2 = await PUMP_SDK.claimSocialFeePdaInstruction({
  recipient: wallet.publicKey,
  socialClaimAuthority: authorityKeypair.publicKey,
  userId: "user123",
  platform: 1,
});

Authority Management

The fee sharing config has an admin who can update shareholders. The SDK provides methods to transfer, reset, or permanently revoke this authority.

Transfer Authority

Transfer admin control to a new address:

const ix = await PUMP_SDK.transferFeeSharingAuthorityInstruction({
  authority: wallet.publicKey,  // current admin
  mint,
  newAdmin: newAdminPublicKey,
});

Reset Config

Reset the fee sharing configuration and assign a new admin:

const ix = await PUMP_SDK.resetFeeSharingConfigInstruction({
  authority: wallet.publicKey,
  mint,
  newAdmin: newAdminPublicKey,
});

Revoke Authority (Irreversible)

Permanently lock the fee sharing configuration. After this, no one can modify shareholders.

const ix = await PUMP_SDK.revokeFeeSharingAuthorityInstruction({
  authority: wallet.publicKey,
  mint,
});

Warning: Revoking is permanent. The adminRevoked flag in SharingConfig will be set to true and no further changes are possible.