Program

Accounts

Every account the kodama program owns or signs for, with its seeds, its size in bytes, each field in order, and how to derive its address.

The accounts at a glance

The program defines four data accounts and signs for three addresses that hold no data. All of them are program derived addresses of the kodama program, whose id is on Addresses.

AccountSeedsBytesOwnerOne per
Grovegrove229kodama programprogram
Treetree, mint442kodama programcoin
Kodamakodama, tree, wallet178kodama programtree and wallet
Dayday, tree, day index as u64 little-endian89kodama programtree and closed day that was watered
Burnerburner0System programprogram
Pursepurse, tree0System programtree
Event authority__event_authority0none, never createdprogram

Sizes include the 8-byte account discriminator. String seeds are their UTF-8 bytes, and a mint, tree or wallet seed is the 32 bytes of that address. Integers are little-endian and addresses are 32 bytes, as Borsh writes them. The program defines no enum.

The rent each account needs is a network parameter. Read it with getMinimumBalanceForRentExemption(bytes) from your RPC for the size in the table.

In TypeScript the decoded field names are camelCase (fruit_lamports is fruitLamports), u64, u128 and i128 fields are BN, and addresses are PublicKey.

Grove

The one account that holds every rate and external address the program reads. Every instruction a wallet sends reads it and none of them writes it.

  • Seeds: grove
  • Size: 229 bytes
  • Discriminator: [81, 31, 12, 33, 39, 76, 176, 78]
FieldTypeMeaningOffset
adminPubkeyThe Grove's administrator.8
global_configPubkeyThe LaunchLab GlobalConfig every coin's curve is created under.40
cpmm_configPubkeyThe CPMM fee tier every graduated pool uses.72
quote_mintPubkeyThe wrapped SOL mint.104
fee_ppmu64What every trade leaves for the tree, in parts per million of the trade. Written into each tree's PlatformConfig as its platform fee rate.136
fruit_ppmu64The part of fee_ppm that becomes fruit.144
planter_ppmu64The part of fee_ppm set aside for the planter.152
burner_ppmu64The part of fee_ppm that goes to the burner, less what echoes are owed.160
echo_ppmu64What a buy through an echo records for that echo's kodama, in parts per million of the SOL spent.168
sprout_threshold_ppmu64Curve progress, in parts per million of curve_quote_raise, at which a tree is a Sprout.176
sapling_threshold_ppmu64Curve progress at which a tree is a Sapling.184
day_secondsu64The length of a day in seconds. The day index is the Unix time divided by this, rounded down.192
curve_supplyu64The supply of every coin, in base units.200
curve_base_sellu64The coins sold on the curve before graduation, in base units.208
curve_quote_raiseu64The lamports the curve raises at graduation.216
base_decimalsu8The decimals of every coin.224
cpmm_indexu16The index of the CPMM fee tier.225
bumpu8The Grove's bump.227
burner_bumpu8The Burner's bump.228

Tree

One per coin. It records the planter, the coin's pools, the open day's accounting and every balance the tree owes. prepare_tree creates it, and the Tree itself is the owner of the vault that holds moved-in coins.

  • Seeds: tree, mint
  • Size: 442 bytes
  • Discriminator: [100, 9, 213, 154, 6, 136, 109, 55]
FieldTypeMeaningOffset
grovePubkeyThe Grove.8
mintPubkeyThe coin's mint.40
planterPubkeyThe wallet that signed prepare_tree. Only it can plant this tree and claim the planter's share.72
pursePubkeyThe tree's Purse.104
platform_configPubkeyThe tree's own LaunchLab PlatformConfig, whose administrator is the purse.136
launchlab_poolPubkeyThe coin's LaunchLab pool. All zeros until plant sets it.168
cpmm_poolPubkeyThe coin's graduated CPMM pool. All zeros until the first harvest after graduation sets it.200
fee_key_mintPubkeyThe mint of the Fee Key the purse holds for the pool's locked liquidity. Set together with cpmm_pool.232
coin_vaultPubkeyThe Tree's associated token account for mint. Holds every coin moved in.264
day_indexu64The tree's open day. close_day moves it to the current day.296
coins_in_treeu64All coins moved in, in base units.304
coins_countingu64The coins that count in the open day. Set to coins_in_tree at each close, and lowered when counting coins move out.312
watered_coinsu64The counting coins of the kodama who watered in the open day.320
watered_kodamau64How many kodama watered in the open day.328
fruit_lamportsu64The open day's fruit in lamports, including fruit carried from earlier days.336
carried_fruit_lamportsu64The part of fruit_lamports that was carried in when the open day began.344
planter_waitingu64The planter's share waiting to be claimed, in lamports.352
planter_claimedu64Lamports the planter has claimed, in total.360
fees_collectedu64Lamports harvest has collected, in total: trade fees and the locked liquidity's SOL fees.368
fruit_paidu64Lamports of fruit picked, in total.376
burner_sentu64Lamports sent to the Burner, in total.384
echo_pendingu64Echo shares recorded by buys and not yet assigned to a kodama's claimable balance.392
echo_reservedu64Harvested lamports held in the purse for echo_pending, not yet assigned to a Kodama.400
echo_payableu64Lamports assigned to Kodama accounts and not yet claimed.408
echo_paidu64Lamports of echo shares claimed, in total.416
rounding_dust_scaledi128The fractions of a lamport that day splits round away, scaled by 10^18. Each whole lamport it reaches joins the open day's fruit.424
bumpu8The Tree's bump.440
purse_bumpu8The Purse's bump.441

Kodama

One per tree and wallet. The first move_in creates it, paid for by the wallet moving in. It stays after the wallet moves every coin out, so fruit and echo shares earned before can still be picked and claimed.

  • Seeds: kodama, tree, wallet
  • Size: 178 bytes
  • Discriminator: [137, 110, 248, 171, 32, 243, 197, 143]
FieldTypeMeaningOffset
treePubkeyThe Tree.8
ownerPubkeyThe wallet.40
coins_in_treeu64The wallet's coins in the tree, in base units: coins_counting + pending_coins.72
coins_countingu64Coins that count today, as of this kodama's last instruction.80
pending_coinsu64Coins moved in that count from pending_day.88
pending_dayu64The day index from which pending_coins count. 0 when nothing is pending.96
last_watered_dayu64The day index of the latest watering. 18446744073709551615 until the first one.104
watered_coinsu64The coins the latest watering recorded, until that day is settled. 0 afterwards.112
water_settledboolTrue when the latest watering has been settled into fruit_ready, or there is none.120
fruit_readyu64Fruit ready to pick, in lamports.121
fruit_pickedu64Lamports of fruit picked, in total.129
echo_buysu64How many buys came through this kodama's echo.137
echo_volumeu64Lamports those buys spent.145
echo_pendingu64Echo share recorded and not yet claimable, in lamports.153
echo_payableu64Echo share that claim_echo pays, in lamports.161
echo_claimedu64Lamports of echo share claimed, in total.169
bumpu8The Kodama's bump.177

Pending coins join coins_counting inside the kodama's next instruction once pending_day has come. To read how many coins count today without sending anything, add pending_coins to coins_counting when pending_day is at most the current day index.

To list a wallet's Kodama accounts, filter the program's accounts on 178 bytes with the wallet at offset 40. To list a tree's kodama, filter on the tree at offset 8.

Day

One per tree and closed day in which at least one kodama watered. close_day creates it, paid for by whoever closes the day, and nothing changes it afterwards. A day nobody watered gets no Day account: its fruit stays on the Tree as carried fruit.

  • Seeds: day, tree, the day index as 8 bytes, little-endian
  • Size: 89 bytes
  • Discriminator: [132, 133, 176, 230, 205, 147, 21, 51]
FieldTypeMeaningOffset
treePubkeyThe Tree.8
day_indexu64The day this account closed.40
fruit_lamportsu64The day's fruit at its close, in lamports, with fruit carried into it.48
watered_coinsu64The counting coins of the kodama who watered that day.56
watered_kodamau64How many kodama watered that day.64
fruit_per_coinu128fruit_lamports × 10^18 / watered_coins, rounded down.72
bumpu8The Day's bump.88

A kodama's fruit from a day is fruit_per_coin × watered_coins / 10^18, rounded down, with the watered_coins of its own Kodama account. FRUIT_SCALE in backend/src/program/index.ts is the 10^18.

Burner

A System-owned address with no data that receives the burner's share of every harvest as SOL. It holds at least the rent of an empty account. No instruction moves SOL out of it.

  • Seeds: burner
  • Size: 0 bytes

Purse

A System-owned address with no data, one per tree. It holds all of that tree's SOL: the open day's fruit, fruit ready to pick, the planter's waiting share and the echo shares. It is also the address Raydium knows the tree by, and Overview lists the seats it holds. Only the program signs for it.

  • Seeds: purse, tree
  • Size: 0 bytes

prepare_tree funds it. Every payment out of a purse leaves the rent of an empty account behind.

Event authority

The address that signs the program's event instructions. It is never created and holds nothing. Every instruction takes it as its second-to-last account, and Events tells how it is used.

  • Seeds: __event_authority

Addresses derived from these

These accounts belong to other programs. Their addresses follow from a Tree or a Purse.

AccountDerived asProgram
Coin vaultThe associated token account of the Tree for the coin's mintToken
PlatformConfigSeeds platform_config, purseLaunchLab
Platform fee vaultSeeds PlatformConfig, wrapped SOL mintLaunchLab
LaunchLab poolSeeds pool, mint, wrapped SOL mintLaunchLab
Purse wrapped SOL accountThe associated token account of the Purse for wrapped SOL. Opened and closed inside each harvest.Token
Purse coin accountThe associated token account of the Purse for the coin's mint. Opened by the first harvest after graduation.Token
Fee Key accountThe associated token account of the Purse for fee_key_mintToken

Derive each address

programAddresses in backend/src/program/index.ts derives every address above the last table, and backend/src/engines/launchpad/launchlab/addresses.ts derives Raydium's. Neither reads the chain. The paths below are written from the repo's root.

derive.ts
import { PublicKey } from '@solana/web3.js'
import { NATIVE_MINT } from '@solana/spl-token'
import { PROGRAM_ID, programAddresses } from './backend/src/program/index.js'
import { ata, platformConfigAddress, platformFeeVault, poolAddress } from './backend/src/engines/launchpad/launchlab/addresses.js'

const pda = programAddresses(PROGRAM_ID)

export function treeAddresses(mint: PublicKey, wallet: PublicKey, dayIndex: bigint) {
  const tree = pda.tree(mint)
  const purse = pda.purse(tree)
  const platformConfig = platformConfigAddress(purse)
  return {
    grove: pda.grove(),
    burner: pda.burner(),
    eventAuthority: pda.eventAuthority(),
    tree,
    purse,
    kodama: pda.kodama(tree, wallet),
    day: pda.day(tree, dayIndex),
    coinVault: ata(tree, mint),
    platformConfig,
    platformFeeVault: platformFeeVault(platformConfig, NATIVE_MINT),
    launchlabPool: poolAddress(mint, NATIVE_MINT),
  }
}

programAddresses() with no argument uses the program id of the built IDL, and addresses is that result, exported ready to use.