DIM · Dagon Inference Marketplace

On-chain accounts

The settlement program im-channels holds buyer funds in a Vault, lets an owner delegate bounded spending to an agent with a Mandate, and pays one seller through a Channel. A FeeConfig and optional SellerFeeOverride accounts set the protocol fee that each new Channel snapshots. Every account is a program-derived address, starts with Anchor's 8-byte discriminator and then version: u8, and is Borsh-encoded little-endian. Clients read the tracked IDL at programs/idl/im_channels.json, never a build output (A23).

Not yet deployed. These pages document the tracked IDL. The program deployed at 2grG8aUKE1HRjE8FqG4h5C2tmfAUG7PLsS8yL4nKrjdW on devnet (source commit f58d497) predates it, and its interface is programs/idl/deployed/im_channels.json.

  • Not in the deployed program: instruction clear_seller_fee, instruction set_fee_config, instruction set_seller_fee, account FeeConfig, account SellerFeeOverride, error InvalidFeeBps (6027) and error InvalidFeeRecipient (6028).
  • Different in the deployed program: open_channel (8 accounts; deployed 6), redeem (9 accounts; deployed 8) and the Channel layout.

<sub>Generated from programs/idl/im_channels.json, programs/idl/deployed/im_channels.json, programs/idl/deployed/RELEASE.</sub>

Constant Value
Program id 2grG8aUKE1HRjE8FqG4h5C2tmfAUG7PLsS8yL4nKrjdW
IDL im_channels 0.1.0 (spec 0.1.0)
MAX_SELLERS 8
MAX_ANCESTORS 3
ACCOUNT_VERSION 2
MAX_GRACE_SECS 2,592,000
MAX_FEE_BPS 1,000
Voucher length accepted by redeem 168

<sub>Generated from programs/idl/im_channels.json, programs/programs/im-channels/src/state.rs, programs/programs/im-channels/src/lib.rs, programs/programs/im-channels/src/domain.rs.</sub>

Addresses

Account Address Created by
Vault PDA ["vault", owner, mint] init_vault
Mandate PDA ["mandate", vault, args.agent_key, args.nonce (u64 LE)] create_mandate
Channel PDA ["channel", vault, args.seller_settler, args.channel_epoch (u64 LE)] open_channel
FeeConfig PDA ["fee_config"] set_fee_config
SellerFeeOverride PDA ["seller_fee", seller_settler] set_seller_fee
Vault token account PDA [vault, token_program, mint] of the Associated Token Account program init_vault

<sub>Generated from programs/idl/im_channels.json.</sub>

u64 seeds are their 8 little-endian bytes. String seeds are their ASCII bytes.

Account Discriminator (sha256("account:<Name>")[..8])
Channel 31 9f 63 6a dc 57 db 58
FeeConfig 8f 34 92 bb db 7b 4c 9b
Mandate 71 d8 62 9f b9 3f 37 12
SellerFeeOverride f7 0c bd d1 88 44 b0 5d
Vault d3 08 e8 2b 02 98 75 77

<sub>Generated from programs/idl/im_channels.json.</sub>

Vault

One per owner and mint. It holds the owner's USDC in its associated token account and tracks two balances: free, which the owner can withdraw or commit, and reserved, the unspent budgets of open and closing channels. After every token movement, and on a no-op redeem, the program checks that the token account holds at least free + reserved (InsolventVault). Tokens sent straight to the token account are surplus: they are never credited to free and cannot be withdrawn.

Allocated: 130 bytes (8-byte discriminator + 122), rent-exempt minimum 1,795,680 lamports. Encoded length: 130 bytes; the unused tail is zero.

Offset Size Field Type Meaning
0 8 discriminator [u8; 8] sha256("account:Vault")[..8] = d3 08 e8 2b 02 98 75 77
8 1 version u8 Account layout version; every instruction requires ACCOUNT_VERSION.
9 32 owner pubkey Signs deposits, withdrawals and root Mandates.
41 32 mint pubkey Must equal the compiled MINT.
73 32 token_account pubkey The vault's associated token account; custody paths check it by address.
105 8 free u64 Unreserved balance, in micro-USDC.
113 8 reserved u64 Sum of budget − redeemed over open and closing channels.
121 8 last_channel_epoch u64 Epoch of the most recent channel opened in this vault (0 before the first). A31: a new channel must use exactly last_channel_epoch + 1, so a closed Channel PDA can never be re-created, old vouchers (bound to the channel address and epoch) never replay, and no opener can exhaust the epoch space.
129 1 bump u8 PDA bump.

<sub>Generated from programs/idl/im_channels.json, programs/programs/im-channels/src/state.rs.</sub>

A vault cannot be closed. Recreating it would reset last_channel_epoch to 0 and make old channel addresses, and their vouchers, reusable.

Mandate

A Mandate lets agent_key open channels from the vault within a per-period budget, a per-request cap, an allowlist of sellers and an expiry. A child Mandate (with parent) may only narrow its parent: its period budget fits in the parent's remaining period budget, its cap, grace and expiry are no larger than the parent's, and its sellers are ones the parent allows. A Mandate has at most MAX_ANCESTORS ancestors.

Allocated: 792 bytes (8-byte discriminator + 784), rent-exempt minimum 6,403,200 lamports. Encoded length: 248 + 32p + 64n bytes; the unused tail is zero.

Offset Size Field Type Meaning
0 8 discriminator [u8; 8] sha256("account:Mandate")[..8] = 71 d8 62 9f b9 3f 37 12
8 1 version u8 Account layout version.
9 32 owner pubkey Copied from the vault.
41 32 vault pubkey The vault this Mandate spends from.
73 32 agent_key pubkey The agent this Mandate authorizes.
105 8 nonce u64 PDA seed; lets one agent hold several Mandates (A8).
113 32 rent_payer pubkey Paid the account rent; the only possible recipient when it is closed.
145 1 + 32p parent Option<pubkey> Parent Mandate for a delegated (narrowed) Mandate; None for a root.
146 + 32p 8 budget_per_period u64 Most that channels opened in one period may commit, in micro-USDC.
154 + 32p 8 period_secs u64 Period length in seconds; nonzero.
162 + 32p 8 period_start i64 Unix seconds; rolled forward by whole periods before any use (A9).
170 + 32p 8 committed_in_period u64 Gross budgets of channels opened in the current period (A9). finalize never lowers it.
178 + 32p 8 reserved u64 Outstanding budget of channels opened under this Mandate or a descendant.
186 + 32p 8 spent_total u64 Lifetime redeemed amount; informational, and saturates at u64::MAX instead of failing.
194 + 32p 8 per_request_cap u64 Per-request limit the gateway applies to Holds on these channels.
202 + 32p 8 max_grace_secs u64 Largest grace G a channel may use (A21); 1 to MAX_GRACE_SECS.
210 + 32p 8 live_channels u64 Channels opened under this Mandate or a descendant and not yet finalized.
218 + 32p 8 children u64 Child Mandates that still exist (created and not yet closed).
226 + 32p 4 + 64n sellers Vec<SellerPair> Allowlisted (seller_settler, seller_payout_token) pairs (A20), at most MAX_SELLERS.
230 + 32p + 64n 1 any_seller bool Always false: create_mandate rejects true (SellerNotAllowed), and such a Mandate could not open channels.
231 + 32p + 64n 8 expiry i64 Unix seconds; the Mandate is inactive from this time.
239 + 32p + 64n 8 revoked_slot u64 Slot of revocation; 0 means live.
247 + 32p + 64n 1 bump u8 PDA bump.

Offsets after a variable-length field move: p = 1 when parent is Some, else 0; n = sellers.len(). An Option is a one-byte tag (0 None, 1 Some) followed by the value only when present; a Vec is a u32 length followed by its elements.

<sub>Generated from programs/idl/im_channels.json, programs/programs/im-channels/src/state.rs.</sub>

Because offsets after parent move, filter Mandates with getProgramAccounts only on the fixed prefix (discriminator through rent_payer).

Periods (A9). Before any instruction uses a Mandate, it rolls period_start forward by whole periods once now ≥ period_start + period_secs and resets committed_in_period to 0. Opening a channel adds its full budget to committed_in_period of the Mandate and every ancestor; finalizing never gives period capacity back.

Liveness (A10). A Mandate is live only while it and every ancestor are unrevoked (revoked_slot == 0) and unexpired (now < expiry).

SellerPair

64 bytes, embedded without a discriminator.

Offset Size Field Type Meaning
0 32 seller_settler pubkey Seller settlement key.
32 32 seller_payout_token pubkey Seller payout token account.

<sub>Generated from programs/idl/im_channels.json.</sub>

Channel

One payment relationship between a vault and one seller, at one epoch. session_key signs the buyer's Holds and vouchers; redeem pays the seller's seller_payout_token, less the protocol fee at the fee_bps rate fixed when the channel opened, which goes to fee_recipient.

Allocated: 286 bytes (8-byte discriminator + 278), rent-exempt minimum 2,881,440 lamports. Encoded length: 254 + 32m bytes; the unused tail is zero.

Offset Size Field Type Meaning
0 8 discriminator [u8; 8] sha256("account:Channel")[..8] = 31 9f 63 6a dc 57 db 58
8 1 version u8 Account layout version.
9 32 vault pubkey The funding vault.
41 32 rent_payer pubkey Paid the account rent; finalize closes the channel to this account only.
73 1 + 32m mandate Option<pubkey> Mandate the channel was opened under, if any.
74 + 32m 32 seller_payout_token pubkey Token account that receives redemptions.
106 + 32m 32 seller_settler pubkey Seller settlement key; a PDA seed, and may begin closing.
138 + 32m 32 session_key pubkey Ed25519 key that signs Holds and vouchers.
170 + 32m 8 channel_epoch u64 Vault-wide epoch; a PDA seed and part of every voucher.
178 + 32m 8 budget u64 Most this channel can pay out, in micro-USDC.
186 + 32m 8 redeemed u64 Highest settled_total paid so far.
194 + 32m 8 service_end_unix i64 T: service end, Unix seconds.
202 + 32m 8 grace_secs u64 G: redemption grace after closing begins.
210 + 32m 8 close_deadline_unix i64 D = min(T, now) + G; 0 until closing begins.
218 + 32m 1 status ChannelStatus (u8 variant index) Open or Closing. A finalized channel no longer exists.
219 + 32m 1 bump u8 PDA bump.
220 + 32m 2 fee_bps u16 Protocol fee basis points snapshotted at open_channel (0..=MAX_FEE_BPS).
222 + 32m 32 fee_recipient pubkey Protocol fee SPL token account snapshotted at open_channel (zero pubkey when fee_bps == 0).

Offsets after a variable-length field move: m = 1 when mandate is Some, else 0. An Option is a one-byte tag (0 None, 1 Some) followed by the value only when present; a Vec is a u32 length followed by its elements.

<sub>Generated from programs/idl/im_channels.json, programs/programs/im-channels/src/state.rs.</sub>

ChannelStatus

One byte: the Borsh variant index. A finalized channel has no status: finalize closes the account.

Value Variant
0 Open
1 Closing

<sub>Generated from programs/idl/im_channels.json, programs/programs/im-channels/src/state.rs.</sub>

Epochs (A31). channel_epoch is counted per vault across all sellers, starting at 1. open_channel accepts only vault.last_channel_epoch + 1, so a finalized channel's address is never recreated and its vouchers can never be replayed. Two opens built from the same vault snapshot race; the loser fails with EpochNotIncreasing and retries with the next epoch.

FeeConfig

Protocol-wide redemption fee configuration PDA (["fee_config"]). open_channel snapshots the active default_fee_bps and fee_recipient onto each Channel so later fee updates never alter already-open channels. The account does not exist until the first set_fee_config; until then every new channel has fee_bps = 0.

Allocated: 76 bytes (8-byte discriminator + 68), rent-exempt minimum 1,419,840 lamports. Encoded length: 76 bytes; the unused tail is zero.

Offset Size Field Type Meaning
0 8 discriminator [u8; 8] sha256("account:FeeConfig")[..8] = 8f 34 92 bb db 7b 4c 9b
8 1 version u8 Account layout version.
9 32 authority pubkey Fee administrator key allowed to update FeeConfig and SellerFeeOverride accounts.
41 32 fee_recipient pubkey Default classic SPL token account receiving protocol redemption fees.
73 2 default_fee_bps u16 Default protocol fee in basis points (0 to MAX_FEE_BPS).
75 1 bump u8 PDA bump.

<sub>Generated from programs/idl/im_channels.json, programs/programs/im-channels/src/state.rs.</sub>

SellerFeeOverride

Optional per-seller fee override PDA (["seller_fee", seller_settler]) allowing volume discounts or partner fee rates (0 to MAX_FEE_BPS) for a specific seller. It replaces default_fee_bps for channels opened with that seller_settler after it is set; the fee still goes to FeeConfig.fee_recipient.

Allocated: 44 bytes (8-byte discriminator + 36), rent-exempt minimum 1,197,120 lamports. Encoded length: 44 bytes; the unused tail is zero.

Offset Size Field Type Meaning
0 8 discriminator [u8; 8] sha256("account:SellerFeeOverride")[..8] = f7 0c bd d1 88 44 b0 5d
8 1 version u8 Account layout version.
9 32 seller_settler pubkey Seller settlement key this override applies to; a PDA seed.
41 2 fee_bps u16 Per-seller protocol fee override in basis points (0 to MAX_FEE_BPS).
43 1 bump u8 PDA bump.

<sub>Generated from programs/idl/im_channels.json, programs/programs/im-channels/src/state.rs.</sub>

Rent

Rent is a deposit. A Channel is closed by finalize and a Mandate by close_mandate; both send all the account's lamports to the rent_payer stored when it was created, never to the caller. Naming any other refund account fails with Anchor's ConstraintHasOne (2001). Both closes are permissionless. clear_seller_fee closes a SellerFeeOverride and returns its rent to the fee authority that signs it; no instruction closes FeeConfig.