DIM · Dagon Inference Marketplace

Instructions

Instruction data is Anchor's 8-byte discriminator followed by the Borsh-encoded arguments. Account order follows the IDL, as in the tables below.

  • Optional accounts (mandate, parent) are always present in the account list. To omit one, pass the program id in its place.
  • Ancestor Mandates go in the remaining accounts after the listed ones: the immediate parent first, the root last, at most MAX_ANCESTORS, all writable even when the instruction changes nothing in them. The program checks that the chain is exactly the Mandate's ancestry and that every ancestor is writable (InvalidAncestry).
  • Periods. Every instruction that touches a Mandate first rolls its period forward (A9).
  • Versions. Every instruction rejects an account whose version is not ACCOUNT_VERSION (InvalidVersion), and every vault check also requires the pinned mint (InvalidMint).
  • Arithmetic is checked everywhere; an overflow or underflow fails with Arithmetic.
  • Tokens. The program decodes every token account itself: it must be owned by the classic SPL Token program (Token-2022 is rejected), hold the pinned mint and be initialized (InvalidTokenAccount). Transfers use TransferChecked with 6 decimals.

Anchor's own errors (for example ConstraintHasOne 2001, ConstraintSeeds 2006, AccountNotInitialized 3012) can also occur when an account does not match its constraints. Program error codes are listed on Error codes.

Instruction Discriminator Arguments Signer accounts
begin_close 2a 02 cc cf 5b 59 7c fc — authority
close_mandate 75 57 bd 05 fe 7d f8 b4 — none (permissionless)
close_on_revoked dc 0d 66 5e cf bf f0 ee — none (permissionless)
create_mandate e6 aa 9e 44 21 a9 10 9e args: CreateMandateArgs authority
deposit f2 23 c6 89 52 e1 f2 b6 amount: u64 owner
finalize ab 3d da 38 7f 73 0c d9 — none (permissionless)
init_vault 4d 4f 55 96 21 d9 34 6a — owner
open_channel 5b 2d fd 47 8c a6 6b 6d args: OpenChannelArgs authority
redeem b8 0c 56 95 46 c4 61 e1 voucher_bytes: [u8; 168] none (permissionless)
revoke_mandate fc 61 8c 77 43 2b b1 6c — authority
top_up ec e1 60 09 3c 6a 4d d0 amount: u64 authority
withdraw_free c2 96 76 32 34 65 b8 5a amount: u64 owner

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

Vault

init_vault

  • Signer: owner, who pays rent for the vault and, if missing, its associated token account.
  • Checks: mint is the pinned mint with 6 decimals; the vault token account belongs to the vault and covers its liabilities.
  • Effects: creates the Vault at ["vault", owner, mint] with free = reserved = last_channel_epoch = 0.
  • Errors: InvalidMint, InvalidTokenAccount, InsolventVault.

Discriminator 4d 4f 55 96 21 d9 34 6a (sha256("global:init_vault")[..8]). Instruction data: 8 bytes.

Offset Size Data Type Meaning
0 8 discriminator [u8; 8]
# Account Writable Signer Optional Address and constraints
0 owner yes yes
1 mint pinned MINT (2LYaM1PTo4WwkoUx87E4pV39vWPDsohWVLyjUyA4MLUu in the default devnet build); 6 decimals
2 vault yes PDA ["vault", owner, mint]; created (payer owner)
3 vault_token yes PDA [vault, token_program, mint] of the Associated Token Account program; created if missing (payer owner)
4 token_program SPL Token program (classic) (TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA)
5 associated_token_program Associated Token Account program (ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL)
6 system_program System program (11111111111111111111111111111111)

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

deposit

  • Signer: owner, who must also own source.
  • Checks: the vault's version and mint; source and the vault token account are classic SPL Token accounts of the pinned mint.
  • Effects: transfers amount from source to the vault token account and adds it to free.
  • Errors: InvalidVersion, InvalidMint, InvalidTokenAccount, InsolventVault, Arithmetic.

Discriminator f2 23 c6 89 52 e1 f2 b6 (sha256("global:deposit")[..8]). Instruction data: 16 bytes.

Offset Size Data Type Meaning
0 8 discriminator [u8; 8]
8 8 amount u64 micro-USDC
# Account Writable Signer Optional Address and constraints
0 owner yes = vault.owner
1 vault yes PDA ["vault", vault.owner, vault.mint]
2 vault_token yes = vault.token_account
3 source yes
4 token_program SPL Token program (classic) (TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA)
5 mint pinned MINT (2LYaM1PTo4WwkoUx87E4pV39vWPDsohWVLyjUyA4MLUu in the default devnet build); 6 decimals

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

withdraw_free

  • Signer: owner.
  • Checks: amount ≤ free; destination is a token account of the pinned mint and is not the vault's own token account.
  • Effects: subtracts amount from free and transfers it to destination.
  • Errors: InvalidVersion, InvalidMint, InsufficientFree, InvalidPayout, InvalidTokenAccount, InsolventVault, Arithmetic.

Discriminator c2 96 76 32 34 65 b8 5a (sha256("global:withdraw_free")[..8]). Instruction data: 16 bytes.

Offset Size Data Type Meaning
0 8 discriminator [u8; 8]
8 8 amount u64 micro-USDC
# Account Writable Signer Optional Address and constraints
0 owner yes = vault.owner
1 vault yes PDA ["vault", vault.owner, vault.mint]
2 vault_token yes = vault.token_account
3 destination yes destination ≠ vault.token_account
4 token_program SPL Token program (classic) (TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA)
5 mint pinned MINT (2LYaM1PTo4WwkoUx87E4pV39vWPDsohWVLyjUyA4MLUu in the default devnet build); 6 decimals

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

Mandates

create_mandate

  • Signer: authority: the vault owner for a root Mandate, or the owner or the parent's agent for a child. The signer pays rent and is recorded as rent_payer.
  • Checks: expiry is in the future; period_secs is nonzero and fits in an i64; any_seller is false (SellerNotAllowed); at most MAX_SELLERS sellers; 1 ≤ max_grace_secs ≤ MAX_GRACE_SECS. For a child: the parent and its ancestors (at most MAX_ANCESTORS in all, passed writable) belong to the same vault and owner and are live, and the child narrows the parent: budget_per_period fits in the parent's remaining period budget, per_request_cap, max_grace_secs and expiry are no larger than the parent's, and unless the parent allows any seller, the child lists only sellers the parent allows. A root takes no ancestors.
  • Effects: creates the Mandate at ["mandate", vault, agent_key, nonce] with period_start = now, all counters 0 and revoked_slot = 0; increments the parent's children.
  • Errors: InvalidVersion, InvalidMint, MandateExpired, MandateRevoked, InvalidTime, SellerNotAllowed, TooManySellers, InvalidAncestry, Unauthorized, NotNarrowed, Arithmetic.

Discriminator e6 aa 9e 44 21 a9 10 9e (sha256("global:create_mandate")[..8]). Instruction data: 93 + 64n bytes.

Offset Size Data Type Meaning
0 8 discriminator [u8; 8]
8 32 args.agent_key pubkey Agent to authorize; a PDA seed.
40 8 args.nonce u64 PDA seed.
48 8 args.budget_per_period u64 Per-period budget.
56 8 args.period_secs u64 Period length; nonzero and at most i64::MAX.
64 8 args.per_request_cap u64 Per-request limit.
72 8 args.max_grace_secs u64 1 to MAX_GRACE_SECS.
80 4 + 64n args.sellers Vec<SellerPair> At most MAX_SELLERS pairs.
84 + 64n 1 args.any_seller bool Must be false; true fails with SellerNotAllowed.
85 + 64n 8 args.expiry i64 Unix seconds; must be in the future.

Offsets after a variable-length field move: 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.

# Account Writable Signer Optional Address and constraints
0 authority yes yes
1 vault PDA ["vault", vault.owner, vault.mint]
2 parent yes optional
3 mandate yes PDA ["mandate", vault, args.agent_key, args.nonce (u64 LE)]; created (payer authority)
4 system_program System program (11111111111111111111111111111111)

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

revoke_mandate

  • Signer: authority: the vault owner, or the agent of any ancestor of this Mandate (passed as remaining accounts). A Mandate's own agent cannot revoke it.
  • Effects: sets revoked_slot to the current slot (at least 1) if it is still 0. Revoking again is a no-op success. Channels opened under it can then be closed by anyone with close_on_revoked.
  • Errors: InvalidVersion, InvalidAncestry, Unauthorized, Arithmetic.

Discriminator fc 61 8c 77 43 2b b1 6c (sha256("global:revoke_mandate")[..8]). Instruction data: 8 bytes.

Offset Size Data Type Meaning
0 8 discriminator [u8; 8]
# Account Writable Signer Optional Address and constraints
0 authority yes
1 mandate yes

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

close_mandate

  • Signer: none; anyone may relay it.
  • Checks: the Mandate is revoked or expired; it has no live channels, no reservation and no children; parent is passed exactly when the Mandate has one.
  • Effects: decrements the parent's children and closes the Mandate, refunding its rent to rent_payer. Close a chain from the leaves up.
  • Errors: InvalidVersion, InvalidAncestry, MandateNotRevoked, MandateInUse, Arithmetic.

Discriminator 75 57 bd 05 fe 7d f8 b4 (sha256("global:close_mandate")[..8]). Instruction data: 8 bytes.

Offset Size Data Type Meaning
0 8 discriminator [u8; 8]
# Account Writable Signer Optional Address and constraints
0 mandate yes closed to rent_payer
1 parent yes optional
2 rent_payer yes = mandate.rent_payer

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

Channels

open_channel

  • Signer: authority: the vault owner, or with a Mandate the owner or the Mandate's agent. The signer pays rent and is recorded as rent_payer.
  • Checks: service_end_unix > now; 1 ≤ grace_secs ≤ MAX_GRACE_SECS; budget ≤ free; channel_epoch == last_channel_epoch + 1; seller_payout_token is a token account of the pinned mint and not the vault's own. With a Mandate, on the Mandate and every ancestor: live, service_end_unix ≤ expiry, not any_seller and the (seller_settler, seller_payout_token) pair is allowlisted (A20), grace_secs ≤ max_grace_secs and service_end_unix + grace_secs ≤ expiry + max_grace_secs (A21), and committed_in_period + budget ≤ budget_per_period. Without a Mandate: the owner signs and no ancestors are passed.
  • Effects: moves budget from vault free to reserved and sets last_channel_epoch; with a Mandate, adds budget to committed_in_period and reserved and increments live_channels on the Mandate and every ancestor; creates the Channel Open with redeemed = 0 and close_deadline_unix = 0.
  • Errors: InvalidVersion, InvalidMint, InvalidTime, InsufficientFree, EpochNotIncreasing, InvalidPayout, InvalidTokenAccount, InvalidAncestry, Unauthorized, MandateRevoked, MandateExpired, SellerNotAllowed, MandateBudget, Arithmetic.

Discriminator 5b 2d fd 47 8c a6 6b 6d (sha256("global:open_channel")[..8]). Instruction data: 136 bytes.

Offset Size Data Type Meaning
0 8 discriminator [u8; 8]
8 8 args.budget u64 Moved from vault free to reserved.
16 8 args.service_end_unix i64 T; must be in the future.
24 8 args.grace_secs u64 G; 1 to MAX_GRACE_SECS.
32 32 args.seller_settler pubkey PDA seed.
64 32 args.seller_payout_token pubkey Must be the seller_payout_token account passed.
96 32 args.session_key pubkey Ed25519 key for Holds and vouchers.
128 8 args.channel_epoch u64 Exactly vault.last_channel_epoch + 1 (A31).
# Account Writable Signer Optional Address and constraints
0 authority yes yes
1 vault yes PDA ["vault", vault.owner, vault.mint]
2 mandate yes optional
3 seller_payout_token = args.seller_payout_token; seller_payout_token ≠ vault.token_account
4 channel yes PDA ["channel", vault, args.seller_settler, args.channel_epoch (u64 LE)]; created (payer authority)
5 system_program System program (11111111111111111111111111111111)

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

top_up

  • Signer: authority, under the same rules as open_channel.
  • Checks: the channel is Open and before its service end; amount ≤ free; with a Mandate, the same Mandate and ancestor checks as open_channel for amount.
  • Effects: moves amount from vault free to reserved and adds it to the channel budget; with a Mandate, adds it to committed_in_period and reserved along the chain (the channel is already counted in live_channels).
  • Errors: InvalidVersion, InvalidMint, InvalidAncestry, NotOpen, InsufficientFree, InvalidTime, Unauthorized, MandateRevoked, MandateExpired, SellerNotAllowed, MandateBudget, Arithmetic.

Discriminator ec e1 60 09 3c 6a 4d d0 (sha256("global:top_up")[..8]). Instruction data: 16 bytes.

Offset Size Data Type Meaning
0 8 discriminator [u8; 8]
8 8 amount u64 micro-USDC
# Account Writable Signer Optional Address and constraints
0 authority yes
1 vault yes PDA ["vault", vault.owner, vault.mint]; = channel.vault
2 channel yes PDA ["channel", vault, channel.seller_settler, channel.channel_epoch (u64 LE)]
3 mandate yes optional

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

redeem

  • Signer: none; any relay may submit it. Authorization is the Ed25519 proof in the immediately preceding instruction.
  • Checks: close_deadline_unix is 0 or still in the future; the channel's Mandate matches the one passed; the voucher has the right tag, length, domain, channel and epoch; settled_total ≤ budget; the preceding instruction proves the session key signed these exact 168 bytes.
  • Effects: pays delta = max(settled_total, redeemed) − redeemed from the vault token account to seller_payout_token, lowers vault reserved by delta and sets redeemed = settled_total; with a Mandate, moves delta from reserved to spent_total on the Mandate and every ancestor. A voucher at or below redeemed changes nothing and succeeds.
  • Errors: InvalidVersion, InvalidMint, DeadlinePassed, InvalidAncestry, InvalidVoucher, ChannelBudget, MissingSignature, InvalidPayout, InvalidTokenAccount, InsolventVault, Arithmetic.

Discriminator b8 0c 56 95 46 c4 61 e1 (sha256("global:redeem")[..8]). Instruction data: 176 bytes.

Offset Size Data Type Meaning
0 8 discriminator [u8; 8]
8 168 voucher_bytes [u8; 168] The 168-byte IM/VOUCHER/1 message, with no Borsh length prefix.
# Account Writable Signer Optional Address and constraints
0 vault yes PDA ["vault", vault.owner, vault.mint]; = channel.vault
1 channel yes PDA ["channel", vault, channel.seller_settler, channel.channel_epoch (u64 LE)]
2 mandate yes optional
3 vault_token yes = vault.token_account
4 seller_payout_token yes = channel.seller_payout_token; seller_payout_token ≠ vault.token_account
5 instructions Instructions sysvar (Sysvar1nstructions1111111111111111111111111)
6 token_program SPL Token program (classic) (TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA)
7 mint pinned MINT (2LYaM1PTo4WwkoUx87E4pV39vWPDsohWVLyjUyA4MLUu in the default devnet build); 6 decimals

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

begin_close

  • Signer: authority: the vault owner, the Mandate's agent, or the channel's seller_settler.
  • Effects: if the channel is Open, sets close_deadline_unix = D = min(service_end_unix, now) + grace_secs and the status to Closing. On a channel that is already closing it changes nothing.
  • Errors: InvalidVersion, InvalidMint, InvalidAncestry, Unauthorized, InvalidTime, Arithmetic.

Discriminator 2a 02 cc cf 5b 59 7c fc (sha256("global:begin_close")[..8]). Instruction data: 8 bytes.

Offset Size Data Type Meaning
0 8 discriminator [u8; 8]
# Account Writable Signer Optional Address and constraints
0 authority yes
1 vault PDA ["vault", vault.owner, vault.mint]; = channel.vault
2 channel yes PDA ["channel", vault, channel.seller_settler, channel.channel_epoch (u64 LE)]
3 mandate yes optional

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

close_on_revoked

  • Signer: none; anyone may relay it.
  • Checks: the channel was opened under this Mandate, and the Mandate or one of its ancestors is revoked or expired.
  • Effects: the same as begin_close.
  • Errors: InvalidVersion, InvalidAncestry, MandateNotRevoked, InvalidTime, Arithmetic.

Discriminator dc 0d 66 5e cf bf f0 ee (sha256("global:close_on_revoked")[..8]). Instruction data: 8 bytes.

Offset Size Data Type Meaning
0 8 discriminator [u8; 8]
# Account Writable Signer Optional Address and constraints
0 channel yes PDA ["channel", channel.vault, channel.seller_settler, channel.channel_epoch (u64 LE)]
1 mandate yes

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

finalize

  • Signer: none; anyone may relay it.
  • Checks: the channel is Closing and now ≥ close_deadline_unix; the Mandate and rent_payer match the channel.
  • Effects: returns budget − redeemed from vault reserved to free; with a Mandate, releases that amount from reserved and decrements live_channels on the Mandate and every ancestor; closes the Channel and refunds its rent to rent_payer.
  • Errors: InvalidVersion, InvalidMint, NotClosing, DeadlineNotReached, InvalidAncestry, Arithmetic.

Discriminator ab 3d da 38 7f 73 0c d9 (sha256("global:finalize")[..8]). Instruction data: 8 bytes.

Offset Size Data Type Meaning
0 8 discriminator [u8; 8]
# Account Writable Signer Optional Address and constraints
0 vault yes PDA ["vault", vault.owner, vault.mint]; = channel.vault
1 channel yes PDA ["channel", vault, channel.seller_settler, channel.channel_epoch (u64 LE)]; closed to rent_payer
2 mandate yes optional
3 rent_payer yes = channel.rent_payer

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