Read-only: vault state (start here)
read vault state + live market
Mirrors runner/src/plugins/01-exampleReadState
What this teaches
- The minimum shape of a plugin: name, vaultId, triggers, decide()
- decide() returns Action[]; `noop` is a valid action (do nothing, on purpose)
- ctx.logger comes pre-bound with your plugin name + vault id The entry point: it only observes (logs vault) and noops. Later examples add signals, sizing, and real mints.
import type { StrategyPlugin } from "@automark/runtime-core";
export default function createExampleReadState(): StrategyPlugin {
const vaultId = process.env.VAULT_ID;
if (!vaultId) throw new Error("exampleReadState: VAULT_ID not set");
return {
name: "exampleReadState",
vaultId,
triggers: [{ kind: "cron", everySeconds: 10 }],
async decide(ctx) {
const { isFrozen, quoteBalance } = ctx.vault;
if (isFrozen) return [{ kind: "noop", reason: "vault frozen" }];
ctx.logger.info("free capital to trade?", {
free: quoteBalance.toString(),
});
if (quoteBalance === 0n) return [{ kind: "noop", reason: "no funds" }];
return [{ kind: "noop", reason: "just checking 👀" }];
},
};
}
// insights we can take from this example:
// checking isFrozen lets us avoid submitting orders that would be reverted because the vault is closed on-chain
// ctx.logger.info lets us debug
// checking quoteBalance lets us verify there are funds to open positions, thus avoiding an on-chain error
Environment variables
- VAULT_ID