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.
| Account | Seeds | Bytes | Owner | One per |
|---|---|---|---|---|
| Grove | grove | 229 | kodama program | program |
| Tree | tree, mint | 442 | kodama program | coin |
| Kodama | kodama, tree, wallet | 178 | kodama program | tree and wallet |
| Day | day, tree, day index as u64 little-endian | 89 | kodama program | tree and closed day that was watered |
| Burner | burner | 0 | System program | program |
| Purse | purse, tree | 0 | System program | tree |
| Event authority | __event_authority | 0 | none, never created | program |
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]
| Field | Type | Meaning | Offset |
|---|---|---|---|
admin | Pubkey | The Grove's administrator. | 8 |
global_config | Pubkey | The LaunchLab GlobalConfig every coin's curve is created under. | 40 |
cpmm_config | Pubkey | The CPMM fee tier every graduated pool uses. | 72 |
quote_mint | Pubkey | The wrapped SOL mint. | 104 |
fee_ppm | u64 | What 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_ppm | u64 | The part of fee_ppm that becomes fruit. | 144 |
planter_ppm | u64 | The part of fee_ppm set aside for the planter. | 152 |
burner_ppm | u64 | The part of fee_ppm that goes to the burner, less what echoes are owed. | 160 |
echo_ppm | u64 | What a buy through an echo records for that echo's kodama, in parts per million of the SOL spent. | 168 |
sprout_threshold_ppm | u64 | Curve progress, in parts per million of curve_quote_raise, at which a tree is a Sprout. | 176 |
sapling_threshold_ppm | u64 | Curve progress at which a tree is a Sapling. | 184 |
day_seconds | u64 | The length of a day in seconds. The day index is the Unix time divided by this, rounded down. | 192 |
curve_supply | u64 | The supply of every coin, in base units. | 200 |
curve_base_sell | u64 | The coins sold on the curve before graduation, in base units. | 208 |
curve_quote_raise | u64 | The lamports the curve raises at graduation. | 216 |
base_decimals | u8 | The decimals of every coin. | 224 |
cpmm_index | u16 | The index of the CPMM fee tier. | 225 |
bump | u8 | The Grove's bump. | 227 |
burner_bump | u8 | The 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]
| Field | Type | Meaning | Offset |
|---|---|---|---|
grove | Pubkey | The Grove. | 8 |
mint | Pubkey | The coin's mint. | 40 |
planter | Pubkey | The wallet that signed prepare_tree. Only it can plant this tree and claim the planter's share. | 72 |
purse | Pubkey | The tree's Purse. | 104 |
platform_config | Pubkey | The tree's own LaunchLab PlatformConfig, whose administrator is the purse. | 136 |
launchlab_pool | Pubkey | The coin's LaunchLab pool. All zeros until plant sets it. | 168 |
cpmm_pool | Pubkey | The coin's graduated CPMM pool. All zeros until the first harvest after graduation sets it. | 200 |
fee_key_mint | Pubkey | The mint of the Fee Key the purse holds for the pool's locked liquidity. Set together with cpmm_pool. | 232 |
coin_vault | Pubkey | The Tree's associated token account for mint. Holds every coin moved in. | 264 |
day_index | u64 | The tree's open day. close_day moves it to the current day. | 296 |
coins_in_tree | u64 | All coins moved in, in base units. | 304 |
coins_counting | u64 | The coins that count in the open day. Set to coins_in_tree at each close, and lowered when counting coins move out. | 312 |
watered_coins | u64 | The counting coins of the kodama who watered in the open day. | 320 |
watered_kodama | u64 | How many kodama watered in the open day. | 328 |
fruit_lamports | u64 | The open day's fruit in lamports, including fruit carried from earlier days. | 336 |
carried_fruit_lamports | u64 | The part of fruit_lamports that was carried in when the open day began. | 344 |
planter_waiting | u64 | The planter's share waiting to be claimed, in lamports. | 352 |
planter_claimed | u64 | Lamports the planter has claimed, in total. | 360 |
fees_collected | u64 | Lamports harvest has collected, in total: trade fees and the locked liquidity's SOL fees. | 368 |
fruit_paid | u64 | Lamports of fruit picked, in total. | 376 |
burner_sent | u64 | Lamports sent to the Burner, in total. | 384 |
echo_pending | u64 | Echo shares recorded by buys and not yet assigned to a kodama's claimable balance. | 392 |
echo_reserved | u64 | Harvested lamports held in the purse for echo_pending, not yet assigned to a Kodama. | 400 |
echo_payable | u64 | Lamports assigned to Kodama accounts and not yet claimed. | 408 |
echo_paid | u64 | Lamports of echo shares claimed, in total. | 416 |
rounding_dust_scaled | i128 | The 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 |
bump | u8 | The Tree's bump. | 440 |
purse_bump | u8 | The 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]
| Field | Type | Meaning | Offset |
|---|---|---|---|
tree | Pubkey | The Tree. | 8 |
owner | Pubkey | The wallet. | 40 |
coins_in_tree | u64 | The wallet's coins in the tree, in base units: coins_counting + pending_coins. | 72 |
coins_counting | u64 | Coins that count today, as of this kodama's last instruction. | 80 |
pending_coins | u64 | Coins moved in that count from pending_day. | 88 |
pending_day | u64 | The day index from which pending_coins count. 0 when nothing is pending. | 96 |
last_watered_day | u64 | The day index of the latest watering. 18446744073709551615 until the first one. | 104 |
watered_coins | u64 | The coins the latest watering recorded, until that day is settled. 0 afterwards. | 112 |
water_settled | bool | True when the latest watering has been settled into fruit_ready, or there is none. | 120 |
fruit_ready | u64 | Fruit ready to pick, in lamports. | 121 |
fruit_picked | u64 | Lamports of fruit picked, in total. | 129 |
echo_buys | u64 | How many buys came through this kodama's echo. | 137 |
echo_volume | u64 | Lamports those buys spent. | 145 |
echo_pending | u64 | Echo share recorded and not yet claimable, in lamports. | 153 |
echo_payable | u64 | Echo share that claim_echo pays, in lamports. | 161 |
echo_claimed | u64 | Lamports of echo share claimed, in total. | 169 |
bump | u8 | The 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]
| Field | Type | Meaning | Offset |
|---|---|---|---|
tree | Pubkey | The Tree. | 8 |
day_index | u64 | The day this account closed. | 40 |
fruit_lamports | u64 | The day's fruit at its close, in lamports, with fruit carried into it. | 48 |
watered_coins | u64 | The counting coins of the kodama who watered that day. | 56 |
watered_kodama | u64 | How many kodama watered that day. | 64 |
fruit_per_coin | u128 | fruit_lamports × 10^18 / watered_coins, rounded down. | 72 |
bump | u8 | The 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.
| Account | Derived as | Program |
|---|---|---|
| Coin vault | The associated token account of the Tree for the coin's mint | Token |
| PlatformConfig | Seeds platform_config, purse | LaunchLab |
| Platform fee vault | Seeds PlatformConfig, wrapped SOL mint | LaunchLab |
| LaunchLab pool | Seeds pool, mint, wrapped SOL mint | LaunchLab |
| Purse wrapped SOL account | The associated token account of the Purse for wrapped SOL. Opened and closed inside each harvest. | Token |
| Purse coin account | The associated token account of the Purse for the coin's mint. Opened by the first harvest after graduation. | Token |
| Fee Key account | The associated token account of the Purse for fee_key_mint | Token |
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.
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.