Gate before submitting
Run source and destination Pre-Trade checks. DANGER and BLOCK stop the workflow before your transaction function is called.
10 — Guard
Insight Guard SDK · The execution workflow for DeFi agents
One server-side TypeScript workflow for two-sided pre-trade gates, Oracle Watch halts, and signed execution receipts. It orchestrates Insight’s API; the risk engine, attestation keys, and credit meter remain on Insight.
01 — One guarded workflow
Use individual REST or MCP calls when you need them. Use Guard when an agent should check, decide, execute, and retain proof as one explicit workflow.
Run source and destination Pre-Trade checks. DANGER and BLOCK stop the workflow before your transaction function is called.
Poll Oracle Watch at a bounded cadence and bind its halt signal to the strategy pause operation.
Pair the two signed pre-trade proofs with the transaction hash to issue a VERIFIED execution receipt.
02 — Quickstart
Install the package in a trusted agent runtime. Never expose an Insight API key in a browser bundle.
npm install oracle-insight-guardimport { InsightGuard } from 'oracle-insight-guard';
const guard = new InsightGuard({ apiKey: process.env.INSIGHT_API_KEY! });
const result = await guard.executeSwap({
source: {
asset: 'ETH', destinationAsset: 'USDC', chainId: 1,
action: 'swap', tradeAmountUsd: 100_000,
},
destination: {
asset: 'USDC', destinationAsset: 'ETH', chainId: 1,
action: 'swap', tradeAmountUsd: 100_000,
},
watchTarget: { symbol: 'ETH', chain: 'ethereum' },
receipt: { settlementChainId: 1, maxSlippageBps: 50 },
submitTransaction: async () => ({ txHash: await submitSwap() }),
});
if (result.status === 'blocked') return; // no transaction was submitted
console.log(result.receipt.executionStatus);03 — Between trades
Guard defaults to a 15-minute Watch cadence. A halt is remembered for that target; pass the same target to executeSwap to prevent a new submission while the halt is active.
const watch = guard.watch(
{ symbol: 'ETH', chain: 'ethereum' },
{
onHalt: async (signal) => strategy.pause(signal.reason),
onError: (error) => logger.error(error),
}
);Guard uses the same API key and the existing C3/C4 credit meter: pre-trade and Watch calls are C3; execution receipt issuance is C4. A successful two-sided guarded swap uses 20 credits at current prices (two C3 gates plus one C4 receipt), excluding Watch polling. There is no second billing model.