Most programs don’t need this page.
POST /v1/orders already buys with cash held on the other
venue, in one call. See Paying from the other venue. Use
the flow below only if your program signs each payment with the account’s wallet itself.funding_venue), Lean buys on the other venue, and you sign the payment before anything moves.
It takes two calls:
POST /v1/routed-ordersquotes the route, books the order aspendingand returns the payment to sign.POST /v1/routed-orders/{id}/executesends your signature. Lean then moves the cash and buys.
trade and route scopes. See
Authentication.
1
Create the routed order
The response is the order,
pending, with route and payment:Only the response that created the order carries
payment. A replay with the same
client_order_id returns the order with payment: null.2
Sign the payment
Sign
payment.typed_data as EIP-712 typed data with the wallet at payment.signer_address.
If payment.agent_approval is set, sign it as well. Sign and execute before the quote expires.3
Execute it
agent_approval_signature when the payment had no agent_approval. The response
is the order with payment: null. A test order is filled. A live order stays pending
while Lean moves the cash, then fills on the other venue. Sending the same authorization again
returns the order as it stands.4
Reconcile
Read the order back with
GET /v1/orders/{id} until it is final, as for any order. See
Orders and idempotency.Letting Lean sign
Send{ "authorization": "delegated" } to the execute call instead of a signature, and Lean signs
the payment with the account’s delegated signer, as POST /v1/orders does. A live key needs the
account to have trading enabled in the Lean app; otherwise the call returns 403 FORBIDDEN with
details.reason: "ACCOUNT_NOT_DELEGATED".
A routed order is authorized once. Sending a signature after a delegated authorization, or the
other way round, returns 409 CONFLICT with details.reason: "PAYMENT_ALREADY_AUTHORIZED".
Errors
See Errors for the envelope and the other codes.