intents machine
intents machine
value·price·light·updated

Program

Everything the machine does is emitted by one Solana program and one NEAR contract, and signed by a NEAR chain signatures key that only signs what those two emit.

Solana program
machine account
NEAR account
coin

State accounts

ACCOUNTHOLDSWRITTEN
machinelight, last fill, last vend, authorityevery fill and vend
coil 1 to 12asset, pitch, rotation, balance, state, notch, vendsevery curve trade and every fill
traydust, burned totalevery vend, dispense and burn
packettokens, age, status, recipienton vend, every later vend, dispense or burn
fill recordintent, legs, amounts, quoted, spreadevery fill
vend recordcoil, packet, tokens bought, trigger, recipientevery vend

Instructions

advance

Called by the curve trade listener with the trade's signature, side and size. Advances every coil. May vend. May clear a jam. May kick.

fill

Called by the NEAR contract through chain signatures with a settled intent. Moves balances between two coils and records the spread.

vend

Called by advance when a coil crosses 360. Emits the packet sale intent and the curve buy, creates the packet in the tray, dispenses the previous packet, burns stale ones.

relight

Called by fill when a dark coil's balance becomes positive.

Deploy notes

The program is deployed with a human readable name so explorers show it as near snack machine instead of an address. The IDL is uploaded on chain with anchor idl init against the deployed program id, the program name in Anchor.toml and the declare_id crate is near_snack_machine, the metadata is set with the Solana program metadata CLI so the name near snack machine and a one line description are attached to the program account, and the program is verified against its public source with the verifiable build tool so the explorer shows the verified mark. The program id above is the one these steps were run against.