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.

  • @coverline-fi/sdk

    Typed calls for every user-facing write, simulate-before-sign helpers, contract errors in plain language, mirrors of the contract math (collateral, fees, payoffs) and a pricing model whose outputs are labelled “model”.

  • @coverline-fi/contracts-abi

    ABIs and deployment addresses per chain, exported from the contracts build. Never copy an ABI or an address by hand.

  • Indexer API

    JSON over HTTP, on the testnet at testnet-api.coverlinefi.xyz: offers, bids, positions, fills, settlements, claims and agent actions, each with the block it was read at.

Packages are on GitHub Packages and private for now.

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

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.