Skip to content
Docs
Sending RFQs

Sending 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.

Taker Flows for Sending RFQs

A taker may interact with the RFQ service in 2 ways: with a partial request or a full request.

Partial Request Flow

The partial request flow is used when a taker wants to merely request a price quote from market makers and solvers without any execution. This is helpful for them in knowing the price that they could get.

Full Request Flow

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 Request

A RFQ request is formatted in a certain way to allow for split functionalities: to request a quote only, or to request a quote and execute a trade.

In all cases, you need to know the token's address (inputToken), the destination token address (outputToken), and the amount that you want to sell (inputAmount).

There are two types of RFQs that you can send: a partial request or a full request.

Partial Request

{
    "address": <address>,
    "inputToken": <address>,
    "outputToken": <address>,
    "inputAmount": <uint256>,
    "zone": <address (optional)>,
    "chainId": <uint256>,
    "deadline": <uint256 (optional)> // Deadline in seconds
}

Full Request

{
    "order": "<Limit Order>", // See Limit Order section
    "signature": "<string>"
}

Sending the Request

To send a request, you can use the aori_rfq JSON-RPC method.

You would then send the following payload body as a POST request to https://rfq.aori.io.

Typical Request Format

{
    "id": "1",
    "jsonrpc": "2.0",
    "method": "aori_rfq",
    "params": [
        <Partial Request> | <Full Request>
    ]
}

Example: Sending a Partial Request

POST https://rfq.aori.io
{
    "id": "1",
    "jsonrpc": "2.0",
    "method": "aori_rfq",
    "params": [
        {
            "address": "0x1234567890123456789012345678901234567890",
            "inputToken": "0x0987654321098765432109876543210987654321",
            "outputToken": "0x0987654321098765432109876543210987654321",
            "inputAmount": "1000000000000000000",
            "chainId": 1,
        }
    ]
}

Example: Sending a Full Request

POST https://rfq.aori.io
{
    "id": "1",
    "jsonrpc": "2.0",
    "method": "aori_rfq",
    "params": [
        {
            "order": "<Limit Order>",
            "signature": "0x12345678901234567890123456789..."
        }
    ]
}

API Response

Both partial and full requests will return a response after the given deadline that follows the format below:

{
    "id": "1",
    "jsonrpc": "2.0",
    "result": {
        "rfqId": "aori-<string>",
        "address": <address>,
        "inputToken": <address>,
        "outputToken": <address>,
        "inputAmount": <uint256>,
        "outputAmount": <uint256>, // Notice that out is now included
        "zone": "0x0AD86842EadEe5b484E31db60716EB6867B46e21",
        "chainId": <uint256>,
    }
}

For a full request, if the outputAmount is met by a market maker or solver, they'll then go on to execute the trade, as given by the CalldataToExecute event that they'll be responsible for handling.

Listening to Events

To connect to the websocket feed that broadcasts these events related to your RFQ, 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 the returned rfqId. You can pass in "ALL" as the value for rfqId if you would like to subscribe to all events globally.

{
    "id": "1",
    "jsonrpc": "2.0",
    "method": "aori_subscribe",
    "params": [
        "ALL"
    ]
}

A number of events will be emitted from the websocket feed related to your RFQ.

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",
        "zone": "0x1234567890123456789012345678901234567890",
        "chainId": 1,
        "deadline": 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
    }
}

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",
    }
}