Agents and developers
SDK quick start
Every payout is already in the contract, so an integration never needs custody. The SDK reads the market, previews each order and simulates it; only the user’s wallet signs.
The package is @coverline-fi/sdk, on GitHub Packages and private for now.
Four rules
- Preview before signing. Use the SDK’s flow previews and show what the user pays, receives, when, and the worst case. Do not build calldata by hand.
- Amounts are integers in base units. Format them only for display, and never guess a token’s decimals.
- Standard expiries come from the SDK’s calendar. Do not trust a server’s “standard” label for a year your SDK does not cover.
- Issuer controls exist: The token's issuer can pause it, block the Coverline market or burn tokens the market holds. Cancels, settlement and claims could then stop, and you could get back less than shown, or nothing. Say so wherever you show a worst case.
1. Read the open series
Read only: no key and no transaction. First check that the indexer serves the market the SDK lists for the chain; the indexer is a convenience, and the chain is the truth.
const indexer = createIndexerClient(o.indexerUrl, { fetch: o.fetch });
const d = getDeployment(o.chainId);
// 1. is this indexer serving the market this SDK lists for the chain?
const health = await indexer.health();
const st = indexerDeploymentStatus(health, o.chainId);
// 2. the open series: best ask and bid per lot in USDG
const series = await indexer.series({ limit: o.limit ?? 20 });2. Preview a buy, then sign
The preview says what you pay now, what you receive, what can come later and the worst case, from a simulation from your address. Send only a passing simulation, and sign in your own wallet: never put a real key in a script.
const d = getDeployment(chainId);
const ctx: MarketContext = { client: o.client, market: d.market, lens: d.lens ?? undefined };
const p = await previewFillOffer(ctx, o.account, o.offerId, o.lots);
if (!p.simulation.ok) throw new Error(`not sent: ${p.simulation.error.message}`);
const hash = await sendSimulated(wallet, p.simulation as never);To show the preview in words, the example passes it to the SDK’s formatPreview(p, { tokens }). Its tokens are keyed by token address, each with its symbol and decimals, while getDeployment lists the tokens by symbol, so the example maps one to the other. Without the mapping, every amount prints in base units with the token’s address.
export function describePreview(p: FlowPreview, chainId: number): string[] {
const d = getDeployment(chainId);
const tokens = Object.fromEntries(Object.entries(d.tokens).map(([symbol, t]) => [t.address, { symbol, decimals: t.decimals }]));
return [...formatPreview(p, { tokens }), p.simulation.ok ? "Simulation: ok" : "Simulation: fails (above)"];
}Excerpts of the SDK’s own examples, examples/read-series.ts and examples/preview-buy.ts (at 04c9655), which run in the SDK’s tests.
For an AI client, see MCP. To let an agent act inside limits, see Agent limits.