A transfer pays amount_in on one venue and receives at least min_out on another, from maker pools. First run the quickstart: sign in, then link and set up an account on both venues. More than LaMarge’s pools hold, or a pair they don’t serve: a move fills what LaMarge can and bridges the rest, with the SDK’s moveFunds().

With the SDK

  1. npm install @lamarge/sdk viem
  2. Copy the taker script.
  3. Run it with API_URL, APP_ORIGIN and PRIVATE_KEY set.
It signs in, links and sets up both accounts, then calls transfer(): create the transfer, withdraw any shortfall from venue margin, take, check and sign the payment, submit it. Rerun it after an interruption: it resumes the same transfer and never signs a payment twice.

Over HTTP

With the master session as $TOKEN. Amounts are base units: 250 USDC is 250000000.

1. Create the transfer

Persist client_transfer_id first: the same request returns the same transfer.
Read funding_plan:
  • payment_setup required: do the permit setup step first.
  • withdrawal_amount above "0": withdraw it from venue margin first (paying from venue margin).
  • Otherwise the wallet and the available balance cover the payment: take now.

2. Take

Send the transfer’s terms, its client_take_id and its id as transfer_intent_id. Add max_fee_bps to accept the pair’s fee.
The answer holds the take, its fills in PREPARED, and one pay_take item to sign. Abridged:
Each item carries attestation when LaMarge attests it: LaMarge’s signature that it asks this signer to sign this exact request, with the terms it commits to for the take (where it delivers, the token, the total and payBy). A signer that holds your key apart from the app calling LaMarge calls verifyAttestation from @lamarge/sdk/attestation with the request it is about to sign, the item’s attestation, its own address and ATTESTERS.production. It throws unless LaMarge attests that request, and from payBy on; it returns the terms for the signer’s own policy, such as refusing a recipient that isn’t one of its addresses. A wallet delivery’s terms are WalletTakeTerms: destination: "wallet", recipient the address it transfers to, token the wallet token, amountOut the least received. The SDK passes each attestation to your Signer with the request (signTypedData(request, { attestation }), signMessage(request, { attestation })).

3. Sign and submit the payment

  1. Check the pay_take item against your request (signing): payer, deposit, and one LockPayment per fill with its amount, recipient and deadlines.
  2. Sign its typed_data as EIP-712 with the payer.
  3. Before pay_by, submit it with the take ID as fill_id:
The answer lists the fills. After a lost answer, submit the same signature again; never sign a second payment for the take.

4. Follow the fills

Read GET /v1/takes/{id}, or stream fill.changed, until every fill is final:
  1. RESERVED: the operator reserved the maker’s liquidity and sends your payment.
  2. PAID: the payment is locked; the delivery is on its way.
  3. CLAIMING: delivered: amount_out is in your account on to_venue.
  4. SETTLED: the maker claimed your payment.
A fill that cannot settle ends EXPIRED (unpaid) or REFUNDED (payment returned to your available balance). Outcomes. A fill delivered on Lighter or Aster first waits up to 15 seconds for its maker’s acceptance; without it, the take expires unpaid.