Fulfilling Request for Quotes (RFQs)
Aori builds products and tooling for supporting high-frequency gas-efficient DeFi execution.
One of the more common flows is the RFQ flow. This flow is quick and useful for communication efficiency amongst takers and makers.
Maker Flow for Fulfilling RFQs
A market maker / solver is able to easily subscribe to the RFQ feed to receive requests from takers. A taker may interact with the RFQ service in 2 ways: with a partial request or a full request (see RFQ: Getting Started).
A partial request and a full request will be shown the same to the market maker / solver as to ensure that a market maker / solver is not able to discern between the two and give fair prices in case they have the chance to be matched with the taker and win the order.
Tutorial
Approving the Contract
You will need to approve the Aori contract first to spend each token in your wallet.
We will soon add in signature-based approvals in the future via Permit2 (opens in a new tab).
Formatting a Limit Order
See the Limit Order section for more information on how to format a limit order.
Sending the Quote Response
POST https://api.aori.io/
{
"id": 1,
"jsonrpc": "2.0",
"method": "aori_respond",
"params": {
"rfqId": "aori-1234567890",
"order": <Limit Order>,
"signature": "0x1234567890123456789012345678901234567890123456789012345678901234..."
}
}
API Response
{
"id": 1,
"jsonrpc": "2.0",
"result": "Ok"
}
Connecting to the Websocket Feed
To connect to the websocket feed, you first connect via websocket at wss://rfq.aori.io
.
Upon connection, you can use the aori_subscribe
JSON-RPC method to subscribe to all events by passing in "ALL"
as the parameter.
{
"id": "1",
"jsonrpc": "2.0",
"method": "aori_subscribe",
"params": [{
"rfqId": "ALL"
}]
}
A number of events will be emitted from the websocket feed related to any RFQs.
QuoteRequested Event
The QuoteRequested
event is emitted when a quote is requested (an RFQ), either from you or another user. An example of the format can be found below:
{
"event": "QuoteRequested",
"data": {
"rfqId": "aori-1234567890",
"address": "0x1234567890123456789012345678901234567890",
"inputToken": "0x1234567890123456789012345678901234567890",
"outputToken": "0x1234567890123456789012345678901234567890",
"inputAmount": "1000000000000000000",
"deadline": "1714204800",
"endTime": "1714204800",
}
}
QuoteReceived Event
The QuoteReceived
event is emitted when a market maker or solver has provided a quote for your RFQ. An example of the format can be found below:
{
"event": "QuoteReceived",
"data": {
"rfqId": "aori-1234567890",
"address": "0x1234567890123456789012345678901234567890",
"inputToken": "0x1234567890123456789012345678901234567890",
"outputToken": "0x1234567890123456789012345678901234567890",
"inputAmount": "1000000000000000000",
"zone": "0x1234567890123456789012345678901234567890",
"chainId": 1,
"deadline": 1714204800
}
}
CalldataToExecute Event
The CalldataToExecute
event is emitted when a match has occurred between a taker and a maker. You can find the market maker's address that has won the RFQ within the event data.
{
"event": "CalldataToExecute",
"data": {
"rfqId": "aori-1234567890",
"matchingHash": "0x1234567890123456789012345678901234567890123456789012345678901234",
"matching": {
"makerOrder": <Limit Order>,
"takerOrder": <Limit Order>,
"makerSignature": "0x1234567890123456789012345678901234567890123456789012345678901234",
"takerSignature": "0x1234567890123456789012345678901234567890123456789012345678901234",
"blockDeadline": 1714204800,
"seatNumber": 0,
"seatHolder": "0x1234567890123456789012345678901234567890",
"seatPercentOfFees": 40
},
"matchingSignature": "0x1234567890123456789012345678901234567890123456789012345678901234",
"makerOrderHash": "0x1234567890123456789012345678901234567890123456789012345678901234",
"takerOrderHash": "0x1234567890123456789012345678901234567890123456789012345678901234",
"chainId": 1,
"zone": "0x1234567890123456789012345678901234567890",
"to": "0x1234567890123456789012345678901234567890",
"value": 0,
"data": "0x1234567890123456789012345678901234567890123456789012345678901234",
"maker": "0x1234567890123456789012345678901234567890",
"taker": "0x1234567890123456789012345678901234567890",
"inputToken": "0x1234567890123456789012345678901234567890",
"inputAmount": "1000000000000000000",
"outputToken": "0x1234567890123456789012345678901234567890",
"outputAmount": "1000000000000000000",
}
}
TradeSettled Event
The TradeSettled
event is emitted when a trade / RFQ has been settled for a full request. An example of the format can be found below:
{
"event": "TradeSettled",
"data": {
"rfqId": "aori-1234567890",
"transactionHash": "0x1234567890123456789012345678901234567890123456789012345678901234",
}
}
TradeExpired Event
The TradeExpired
event is emitted when a trade / RFQ has expired past its deadline
or endTime
. An example of the format can be found below:
{
"event": "TradeExpired",
"data": {
"rfqId": "aori-1234567890",
}
}
TradeFailed Event
Similarly, a market maker or solver can choose to voluntarily fail a quote by calling the cancelQuote
function. This will emit a TradeFailed
event. An example of the format can be found below:
{
"event": "TradeFailed",
"data": {
"rfqId": "aori-1234567890",
}
}