How to use clipper RFQ API?

Clipper's Formula Market Maker (FMM) is implemented similar to a typical Request For Quotes (RFQ) system. In an RFQ architecture, you first ask our offchain server to quote a transaction price, specifying the buy and sell tokens and either a target input or output amount. You then have a short amount of time to accept that quote, and receive back a signed certificate from our offchain server. Then, you must pass that transaction and signed certificate to our onchain smart contracts to execute the swap.

Clipper supports a “send, then swap" modality and is designed to be as simple as possible to chain within a larger set of transactions, or to automate trading with bots.

circle-exclamation
circle-info

You can see the supported networks here

  1. Get exchange address and asset information.

const fetch = require('node-fetch');

const chainId = 137;  // You can use a different network. Look for our supported networks
const fieldset = 'offchain-data';
const authorizationHeader = 'YXBpLXVzZXI6dXNlci1wYXNz';  // This is a placeholder 

const requestOptions = {
  method: 'GET',
  headers: {
    'x-api-key': authorizationHeader,
    'Content-Type': 'application/json'
  }
};

const response = await fetch(`https://blade-api.sushi.com/rfq/v2/pool/${chainId}?fieldset=${fieldset}`, requestOptions);
const data = await response.json();
console.log(data);

The API response will look like the following (some fields omitted):

💡 You can include the query param time_in_seconds to the GET call if you intend to get quotes for values other than the default_time_in_seconds for a chain. As you lower the time you will see lower fees (and therefore better prices).

💡 You can include the pool_address query parameter; if it’s not provided, multiple pools can be returned per chain.

💡 To obtain more details about the endpoint, its parameters, and the response, please refer to the API Reference in the pool section.

circle-exclamation
  1. Request a quote

circle-exclamation

The API response will look like the following (some fields omitted):

circle-exclamation

💡 To obtain more details about the endpoint, its parameters, and the response, please refer to the API Reference in the quote section.

  1. Sign the quote

circle-exclamation
circle-exclamation

The API response will look like the following:

circle-info

If you want to get the bytes representation of the swap to be sent directly to the pool contract you can review our calldata swap feature

💡 To obtain more details about the endpoint, its parameters, and the response, please refer to the API Reference in the sign section

  1. Send the transaction

Using ether.js

file-download
19KB

💡 You can review the guide Interacting with the Clipper Exchange to know more ways of interact with Clipper. You can also review code examples in the section Integration Examples

circle-info

You can find a complete swap flow example here

Last updated

Was this helpful?