DIM · Dagon Inference Marketplace

Vaults

A vault is your USDC account inside the DIM Solana program (im-channels). You deposit into it, channels draw their budgets from it, and only you, the owner, can withdraw its free balance. It is the one place your money sits between purchases, and nothing leaves it except by your signature, a channel you or your Mandate opened, or a voucher signed for that channel.

What a vault holds

A vault is a program-derived account at ["vault", owner, mint]. Its tokens sit in an associated token account owned by the vault itself. It tracks two balances:

Balance Meaning
free Money not committed anywhere. You can withdraw it or open channels with it.
reserved The sum of budget − redeemed over your open and closing channels: money promised to channels and not yet paid out.

After every token movement the program checks that the token account holds at least free + reserved. If it does not, the instruction fails (InsolventVault).

What can move money

Instruction Who signs Effect
init_vault owner Creates the vault and its token account.
deposit(amount) owner Moves USDC from the owner's token account into free.
withdraw_free(amount) owner Moves USDC from free back out to a token account the owner chooses.
top_up(amount) owner, or a Mandate's agent Adds free balance to an open channel's budget.
open_channel owner, or a Mandate's agent Moves a channel budget from free to reserved.
redeem anyone, carrying a voucher Pays a seller from reserved, only up to the voucher's signed total.
finalize anyone, after the close deadline Returns a closed channel's unspent budget to free.

Nobody else can withdraw from your vault. A seller can only receive what a voucher for its own channel says, and only into the payout account the channel was opened with.

[!WARNING] Deposit with the deposit instruction. Tokens sent straight to the vault's token account are never credited to free and cannot be withdrawn.

One mint, one cluster

Each program build pins one token mint and one cluster at compile time. The default devnet build uses a project test mint with 6 decimals; the mainnet build pins USDC but is not deployed or audited for mainnet. Amounts are always integers in micro-USDC: 1 USDC is 1,000,000.

Vaults are never closed

A vault cannot be closed. Closing it would let the same address be recreated with its channel counter back at zero, which would make old channel addresses, and the vouchers signed for them, reusable. Keeping it costs a one-time rent deposit of about 1,795,680 lamports for the vault plus about 2.04 million for its token account, per owner and mint.

In the SDK

The SDK's SolanaChannelBackend takes your vault's address and builds the channel and Mandate instructions. It does not build init_vault, deposit or withdraw_free; build those from the tracked IDL at programs/idl/im_channels.json, as the devnet demo scripts in the repository do. Funding shows how to derive the vault address.