How it works
- A user asks LI.FI for a quote.
- The order server sends
rfq:requestto the solvers it selects for the route. - You answer with
rfq:quoteorrfq:no-quotebefore the request’sresponseDeadlinepasses. - For each solver, the order server takes its valid RFQ quote, or its published quote when it sent none. It ranks these across solvers, and the best one goes back to the user.
- If the user goes ahead, the order is opened with your amounts. You get it through the order stream and fill it like any other order.
- If you send a valid
rfq:quote, it ranks that quote, even when your published quote is better. - If you send
rfq:no-quote, an invalid answer or nothing, it ranks your published quote.
Getting access
Only approved solvers receive RFQs. To get approved, contact the LI.FI team. By default you get RFQs on every chain. To limit them, set your chain list withPUT /api/v1/solver/rfq/chains. You get a request only when both its source and destination chain are on the list. Send the complete list each time, or an empty list to get every chain again.
Connecting
- Use the same API key as for the Solver API. A missing or invalid key gets a
401on connect. - You can open up to 4 sockets. Each request goes to all of them and the first accepted answer counts.
- The heartbeat works like on the order stream. The server sends
{"event": "ping"}every 5 seconds, so reply with{"event": "pong"}or a WebSocket pong within 10 seconds or the socket is closed. - Messages you send are capped at 16 KiB.
- A revoked or expired key closes its sockets within about 30 seconds.
Messages
Every RFQ message is a JSON object with anevent name and a data payload. The payload always includes "version": 1.
rfq:request
The same route and amount can come again, for example while a user keeps a quote open. Treat eachrequestId as a new RFQ.
Unix milliseconds. Your answer has to reach us before this. We check it on our side, so leave some margin for the network. You usually get a few hundred milliseconds.
Asset on
fromChain, in the native format of that chain, for example T... on Tron and base58 on Solana.rfq:quote
Final input amount as a positive integer string in base units, up to 78 digits. On an
exact-input request it must equal the requested amount.Final output amount as a positive integer string in base units, up to 78 digits, with your gas costs and fees included. On an
exact-output request it must equal the requested amount.Unix seconds. When your quote expires. At least
minValidUntil, and after responseDeadline.Your registered account that gets exclusivity on the order, in the format of
fromChain. Required when the request lists accounts. Otherwise you can name any of your registered accounts, or none.Cross-chain only, so leave it out on a same-chain swap. Leave it out to use the default pair of the route, which then has to be in
acceptedOraclePairs when the request lists them. A pair you name must belong to the route.rfq:quote or rfq:no-quote. Sending the same answer again is ignored. A different second answer gets ALREADY_ANSWERED.
rfq:no-quote
rfq:rejected
You get no reply when your answer is accepted. When it is not, you get:
An answer without a usable
requestId closes the socket with 1008, since there is nothing to reject.
