This repository contains a script for testing a client implementation of Rubicon's RFQ system for an arbitrary chain and token pair. It allows you to fetch price levels and submit orders through an RFQ contract. Please see rfq-test.ts for a detailed code example you can use to aid your implementation.
To learn more about Rubicon RFQ, please see our official documentation.
- Node.js
- Yarn package manager
- An environment file (
.env) with the requisite variables
-
Clone the repository:
git clone https://github.com/RubiconDeFi/rfq-client-example.git cd rfq-client-example -
Install dependencies:
yarn install
-
Create a
.envfile in the root directory of the project and add the following environment variables:API_KEY=your_api_key (for the RFQ system) TAG=your_api_tag (for the RFQ system) PRIVATE_KEY=your_private_key (in case you want to execute trades, not required) <CHAIN_ID>_JSON_RPC=https://your-json-rpc-urlReplace
<CHAIN_ID>with the appropriate chain ID, e.g.,42161_JSON_RPCfor Arbitrum,8453_JSON_RPCfor Base, etc.
Run the script with the following command:
yarn start <chainId> <buyToken> <sellToken> [price] [amount]<chainId>: The ID of the blockchain network (e.g., 42161 for Arbitrum).<buyToken>: The address of the token you want to buy.<sellToken>: The address of the token you want to sell.[price](optional): The price of the token.[amount](optional): The amount of the token you want to buy/sell.
-
To fetch price levels for a trading pair:
yarn start 42161 0x82aF49447D8a07e3bd95BD0d56f35241523fBab1 0xaf88d065e77c8cC2239327C5EDb3A432268e5831
-
To fetch price levels and submit an order (must uncomment the order submission block):
yarn start 42161 0x82aF49447D8a07e3bd95BD0d56f35241523fBab1 0xaf88d065e77c8cC2239327C5EDb3A432268e5831 3400 0.1
-
Inverse:
yarn start 42161 0xaf88d065e77c8cC2239327C5EDb3A432268e5831 0x82aF49447D8a07e3bd95BD0d56f35241523fBab1 0.0003125 500