walt/program/accounts

accounts

the accounts the program owns and what each one holds.

definition

meter     = pda(["meter", coin_mint])
ticket    = pda(["ticket", coin_mint, sha256(trade_signature)])
channel   = pda(["channel", coin_mint, provider])
root      = pda(["root", coin_mint])
row       = pda(["row", coin_mint, table_id, row_id])

what it is

every account is found from the coin's mint and a few fixed words. nothing is stored in a list that has to be searched. if you know the coin and the trade, you know where the ticket is.

the meter is the only account that touches money. the fee arrives there, is converted, and leaves through a ticket, a sale or a channel before the instruction ends.

the row account is a counter. it exists only for rows that have been sold at least once and holds how many times. the price follows from that count alone.

accounts

accountone perholds
metercoinfee vault, usdc vault, running totals, root sequence
tickettradetrade hash, payer, class, budget, status, two hashes
channelproviderdeposit, watermark, nonce, call count
rootcoinsequence, top root, nine table roots
rowsold rowsale count, last price

notes

the drawing shows the ticket, the account that exists once per trade. each cell is one byte.

figure

the ticket account, 178 bytes. fields alternate shade in the order listed.

ticket fields

fieldbytessize
discriminator0 to 88
trade_sig_hash8 to 4032
payer40 to 7232
size_usd_micros72 to 808
class80 to 811
budget_usdc81 to 898
status89 to 901
receipt_hash90 to 12232
thought_hash122 to 15432
read_cost154 to 1628
opened_slot162 to 1708
settled_slot170 to 1788
walt/program/accounts: five kinds of account, all derived from the coin.