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
npm install @lamarge/sdk viem- Copy the taker script.
- Run it with
API_URL,APP_ORIGINandPRIVATE_KEYset.
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
Persistclient_transfer_id first: the same request returns the same transfer.
funding_plan:
payment_setuprequired: do thepermitsetup step first.withdrawal_amountabove"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, itsclient_take_id and its id as transfer_intent_id. Add max_fee_bps to accept the pair’s fee.
PREPARED, and one pay_take item to sign. Abridged:
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
- Check the
pay_takeitem against your request (signing): payer, deposit, and oneLockPaymentper fill with its amount, recipient and deadlines. - Sign its
typed_dataas EIP-712 with the payer. - Before
pay_by, submit it with the take ID asfill_id:
4. Follow the fills
ReadGET /v1/takes/{id}, or stream fill.changed, until every fill is final:
RESERVED: the operator reserved the maker’s liquidity and sends your payment.PAID: the payment is locked; the delivery is on its way.CLAIMING: delivered:amount_outis in your account onto_venue.SETTLED: the maker claimed your payment.
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.