Skip to main content

Developers

Build on the market contract

The app uses the same three pieces you can: a TypeScript SDK, the contract ABIs with deployment addresses, and a read-only indexer API. The contracts are the source of truth; the packages are generated from them.

Packages are on GitHub Packages and private for now: [PACKAGE ACCESS].

Using an AI client? Connect it with MCP: a local server that reads the market and prepares orders, holds no keys and sends nothing.

Simulate, then sign

import { createPublicClient, http } from 'viem';
import { getDeployment, marketCalls, simulateMarketCall, sendSimulated,
         explainMarketError, fillBreakdown, getOffer, marketConfig } from '@coverline-fi/sdk';

const d = getDeployment(chainId);
const ctx = { client: createPublicClient({ transport: http(rpcUrl) }), market: d.market };

// What the buyer pays and the writer receives: the contract's own integer math.
const offer = await getOffer(ctx, offerId);
const { feeBps } = await marketConfig(ctx);
const cost = fillBreakdown(offer.premiumPerLot, 2, feeBps);

// Simulate first; sign only what simulated.
try {
  const sim = await simulateMarketCall(ctx, account, marketCalls.fillOffer(offerId, 2));
  await sendSimulated(walletClient, sim);
} catch (e) {
  console.error(explainMarketError(e).message); // plain language
}

Indexer API

Every list route uses keyset pagination: the first page carries an X-Next-Cursor header, later pages are requested with after. Amounts are integer strings in token units, addresses are checksummed, and nothing the indexer returns is estimated: model values come from the SDK and are labelled.

Indexer routes
RouteFiltersReturns
/health—Indexed block, chain head and lag
/market—Market parameters: fees, settlement policy, paused and frozen tokens
/offersunderlying, writer, statusOffers, with the block they were read at
/bidsunderlying, bidder, openResting bids and their escrow
/positionsholder, offerIdNon-zero position balances
/portfolioaddressPositions, open offers, open bids and unclaimed amounts of one account
/fillsofferId, buyerFills (OfferFilled events)
/settlementsofferId, or underlying + expirySettlement prices and settled offers
/claimsofferId, holderHolder and writer claims
/agent-actionsowner, agentEvery action an agent took for an owner
/agent-grantsowner, agentGrants and revocations
/eventsnameRaw events of one type

Contract reference

Functions, events, errors, fees and settlement rules of the market contract: [CONTRACT DOCS]. Agent grants are described on Agents.

Local test network

For development, the contracts deploy to a local Anvil chain (chain id 31337) with test tokens that anyone can mint. Those tokens and the Anvil test accounts exist only on local chains. Never use them, or any private key, on a public network.