PDA Derivation
The SDK provides functions to derive all Program Derived Addresses (PDAs) used by the CCA V2 and Launchpad programs. All functions return [PublicKey, number] tuples (address and bump seed) using PublicKey.findProgramAddressSync.
CCA V2 PDAs
These PDAs are derived against CCA_V2_PROGRAM_ID (F5DdorN9nawhpQJZkfLYx2SpcWxSTZnwh3ZRyNtXP5do).
findAuctionConfigPda
Derives the auction configuration account.
function findAuctionConfigPda(
authority: PublicKey,
auctionId: bigint
): [PublicKey, number]
Seeds: ["cca_auction", authority, auctionId (u64 LE)]
import { findAuctionConfigPda } from "@runner-protocol/sdk";
const [auctionConfig, bump] = findAuctionConfigPda(
authorityPubkey,
BigInt(0) // first auction for this authority
);
findAuctionStatePda
Derives the mutable auction state account.
function findAuctionStatePda(
auctionConfig: PublicKey
): [PublicKey, number]
Seeds: ["cca_state", auctionConfig]
findSupplySchedulePda
Derives the supply schedule account that defines token release rates.
function findSupplySchedulePda(
auctionConfig: PublicKey
): [PublicKey, number]
Seeds: ["cca_supply", auctionConfig]
findBidPda
Derives a bid account. Each bid has a sequential ID within the auction.
function findBidPda(
auctionConfig: PublicKey,
bidId: bigint
): [PublicKey, number]
Seeds: ["cca_bid", auctionConfig, bidId (u64 LE)]
findTickPda
Derives a tick account for a specific price level.
function findTickPda(
auctionConfig: PublicKey,
price: bigint
): [PublicKey, number]
Seeds: ["cca_tick", auctionConfig, price (u128 LE)]
The price parameter is a Q96-encoded u128 value, not a human-readable decimal.
findCheckpointPda
Derives a checkpoint account for a specific auction block.
function findCheckpointPda(
auctionConfig: PublicKey,
auctionBlock: bigint
): [PublicKey, number]
Seeds: ["cca_checkpoint", auctionConfig, auctionBlock (u64 LE)]
findQuoteVaultPda
Derives the quote token vault (holds bid deposits).
function findQuoteVaultPda(
auctionConfig: PublicKey
): [PublicKey, number]
Seeds: ["cca_quote_vault", auctionConfig]
findBaseVaultPda
Derives the base token vault (holds auction tokens for claiming).
function findBaseVaultPda(
auctionConfig: PublicKey
): [PublicKey, number]
Seeds: ["cca_base_vault", auctionConfig]
findVaultAuthorityPda
Derives the vault authority PDA that signs token transfers from vaults.
function findVaultAuthorityPda(
auctionConfig: PublicKey
): [PublicKey, number]
Seeds: ["cca_vault_auth", auctionConfig]
Launchpad PDAs
These PDAs are derived against LAUNCHPAD_PROGRAM_ID (8zfW4iLA7JagfotwCn8FT3SpdzUyGQ7CRSzjMwmJyK6F).
findProtocolConfigPda
Derives the singleton protocol configuration account.
function findProtocolConfigPda(): [PublicKey, number]
Seeds: ["cca_protocol"]
findLaunchConfigPda
Derives a launch configuration account.
function findLaunchConfigPda(
creator: PublicKey,
launchId: bigint
): [PublicKey, number]
Seeds: ["cca_launch", creator, launchId (u64 LE)]
The launch config seeds use the creator key, not the protocol config key. This is a common source of bugs when deriving addresses manually.
findTokenMintPda
Derives the Token-2022 mint for a launch.
function findTokenMintPda(
launchConfig: PublicKey
): [PublicKey, number]
Seeds: ["cca_token_mint", launchConfig]
findMintAuthorityPda
Derives the mint authority PDA.
function findMintAuthorityPda(
launchConfig: PublicKey
): [PublicKey, number]
Seeds: ["cca_mint_auth", launchConfig]
findEscrowAuthorityPda
Derives the escrow authority PDA that controls all escrow accounts for a launch.
function findEscrowAuthorityPda(
launchConfig: PublicKey
): [PublicKey, number]
Seeds: ["cca_launch_auth", launchConfig]
findEscrowPda
Derives a specific escrow account by type.
function findEscrowPda(
launchConfig: PublicKey,
escrowType: Buffer // e.g., Buffer.from("auction")
): [PublicKey, number]
Seeds: ["escrow", launchConfig, escrowType]
Valid escrow types: "auction", "lp", "team", "proceeds", "fee"
findFeeEscrowPda
Convenience function that derives the fee escrow specifically.
function findFeeEscrowPda(
launchConfig: PublicKey
): [PublicKey, number]
Seeds: ["escrow", launchConfig, "fee"]
Convenience Functions
deriveCcaPdas
Derive all CCA V2 PDAs for a given authority, auction ID, and floor price in a single call.
function deriveCcaPdas(
authority: PublicKey,
auctionId: bigint,
floorPrice: bigint
): {
auctionConfig: PublicKey;
auctionState: PublicKey;
supplySchedule: PublicKey;
baseVault: PublicKey;
quoteVault: PublicKey;
vaultAuthority: PublicKey;
floorTick: PublicKey;
}
import { deriveCcaPdas, encodeQ96 } from "@runner-protocol/sdk";
const pdas = deriveCcaPdas(
authorityPubkey,
BigInt(0),
encodeQ96("0.001") // floor price
);
console.log("Auction config:", pdas.auctionConfig.toBase58());
console.log("Quote vault:", pdas.quoteVault.toBase58());
deriveLaunchPdas
Derive all Launchpad PDAs for a given creator and launch ID in a single call.
function deriveLaunchPdas(
creator: PublicKey,
launchId: bigint
): {
launchConfig: PublicKey;
tokenMint: PublicKey;
mintAuthority: PublicKey;
escrowAuthority: PublicKey;
auctionEscrow: PublicKey;
lpEscrow: PublicKey;
teamEscrow: PublicKey;
proceedsEscrow: PublicKey;
feeEscrow: PublicKey;
}
import { deriveLaunchPdas } from "@runner-protocol/sdk";
const pdas = deriveLaunchPdas(creatorPubkey, BigInt(0));
console.log("Launch config:", pdas.launchConfig.toBase58());
console.log("Token mint:", pdas.tokenMint.toBase58());
console.log("Auction escrow:", pdas.auctionEscrow.toBase58());