Run a strategy & dispatch
Write the tick
import type { Agent, AgentContext, Dispatch } from "@sail.money/sailor/sdk";
const agent: Agent = {
name: "dca-usdc-weth",
description: "Buys WETH with USDC, capped per trade, once per tick.",
async tick(ctx: AgentContext): Promise<Dispatch[]> {
const usdc = await ctx.read.balance("0xUSDC");
if (usdc < 100_000_000n) return []; // 100 USDC (6 decimals); skip if low
const result = await ctx.client.strategy.swap(
ctx.account,
{ from: "0xUSDC", to: "0xWETH", amount: 100_000_000n, swapPermission: "0xSwapPermission" },
ctx.manager,
);
ctx.log(`bought WETH, swap tx ${result.swap.txHash}`);
return [result.swap];
},
};
export default agent;Run it
What a denied dispatch looks like
You'll see
Meaning
Pause and resume
Last updated

