Makers
Makers run web servers that implement the RFQ and Last Look APIs using JSON-RPC over HTTP. To be reachable by clients, servers run at public endpoints with CORS enabled. To become discoverable, server URLs are added to the Registry smart contract, which is queried by clients.

Introduction

AirSwap liquidity providers are makers, generally online and quoting, with takers on the other side of each trade. At the lower protocol level, where the software used by makers and takers interacts with Ethereum, there are signers, who set and cryptographically sign terms (an order), and senders who submit those terms for settlement on the Swap contract.
For the RFQ protocol, a server is always the signer and the client is always the sender. For Last Look, the client is always the signer and a server is always the sender.
    Nonces are unique identifiers for swaps and used for cancels. They should be generated incrementally but might execute out of order.
    URLs may be to either HTTP or WebSocket servers using https or wss respectively.
    Registry is used to signal that a server is available to trade specific tokens, including contact information (URL), without pricing.

HTTP vs WebSocket

If a URL is HTTPS, it is implied that the server supports the latest RFQ protocol at that endpoint. If a URL is WebSocket (wss) then the server communicates its supported protocols upon connnection. See the initialize method of the Request for Quote and Last Look protocols for details. WebSocket servers can support both RFQ and Last Look protocols.

Getting Started

Getting started is as easy as standing up a JSON-RPC web server and adding its URL to the Registry.

Protocol Fees

When signing orders in RFQ, a protocol fee (in basis points) is hashed into the signature and verified during settlement. The value of this parameter must match its current value of signerFee on the Light contract. The amount is transferred from the signerWallet address upon settlement.
100% of protocol fees go toward AirSwap governance and development contributors.

Helpful for Testing

The following resources are helpful for testing on Rinkeby.
    ETH to pay for transactions - Faucet
    WETH for trading - 0xc778417e063141139fce010982780140aa0cd5ab Etherscan
    DAI for trading - 0x5592ec0cfb4dbc12d3ab100b257153436a1f0fea Etherscan
    AST for staking - 0xcc1cbd4f67cceb7c001bd4adf98451237a193ff8 Etherscan / Faucet

Handling Errors

Provide descriptive errors where possible. In the case of a server side error, return a JSON-RPC error response.
1
{
2
"jsonrpc": "2.0",
3
"id": 123,
4
"error": { "code": -33605, "message": "Rate limit exceeded" }
5
}
Copied!
The following are error codes in the JSON-RPC specification:
    -32700 Parse error
    -32600 Invalid Request
    -32601 Method not found
    -32602 Invalid params
    -32603 Internal error
    -32000 to -32099 (Reserved for implementation-defined server-errors)
The following are AirSwap specific errors:
    -33600 Cannot provide the requested quote or order
    -33601 Not trading the requested signerToken senderToken pair
    -33602 The specified senderAmount or signerAmount is too low
    -33603 The specified senderAmount or signerAmount is too high
    -33604 Invalid request parameters
    -33605 Rate limit exceeded
    -33700 to -33799 (Reserved for implementation specific trading errors)

Debugging with the CLI

Ensure the AirSwap CLI is installed.
1
$ yarn global add airswap
Copied!
In development, set the chain to 4 with the airswap chain command. The following examples assume a local development server is running at http://localhost:3000.
Several useful commands can help you debug your server:
    airswap order:get to request an order directly from your server. (RFQ)
    airswap order:best to request an order from servers supporting a specific token pair. Once your server is on the registry it will be queried with this command. (RFQ)
    airswap quote:stream to subscribe to a pricing stream and make orders for your server. (Last Look)

Adding to the Registry

You can debug all methods using the quote and order AirSwap CLI commands.
Ensure the AirSwap CLI is installed.
1
$ yarn global add airswap
Copied!
Once your server is up and running at a public URL, you're ready to add it to the Registry. First, ensure an account is set with the airswap account:import command. You can but are not required to use the same Ethereum account that your Server is using.
Let's take a look at the available Registry commands.
1
$ airswap registry
2
AirSwap CLI 1.6.1 — https://airswap.io/
3
add and remove supported tokens
4
5
USAGE
6
$ airswap registry:COMMAND
7
8
COMMANDS
9
registry:add add supported tokens to the registry
10
registry:enable enable staking on the registry
11
registry:get get urls from the registry
12
registry:list list supported tokens from registry
13
registry:remove remove supported tokens from the registry
14
registry:url set server url on the registry
Copied!
First run the following command to enable staking for your account.
1
$ airswap registry:enable
Copied!
Now run the following command to set your server url on the registry.
1
$ airswap registry:url
Copied!
Now run the following command to add tokens you support.
1
$ airswap registry:add
Copied!
To ensure your configuration is correct, you can query tokens that you support on the registry.
1
$ airswap registry:get
2
AirSwap CLI 1.6.1 — https://airswap.io/
3
4
get urls from the registry RINKEBY
5
6
Registry 0xa77fbeD39D5128e1cA9795d68D73010851393BCc
7
8
Token pair (e.g. WETH/USDT): DAI/WETH
9
10
Server
11
----------------------------------------
12
https://maker.example.com/
Copied!
Now that your server is running and has been added to the Registry, your quotes will be returned among results of the airswap order:best command and aggregators like MetaMask Swaps.
1
$ airswap order:best
2
AirSwap CLI 1.6.1 — https://airswap.io/
3
4
get the best available order MAINNET
5
6
full or light: light
7
buy or sell: buy
8
amount: 0.1
9
of: weth
10
for: dai
11
12
Quote from https://maker.example.com/
13
14
✨ Buy 0.1 WETH for 250 DAI
15
Price 0.0004 WETH/DAI (2500 DAI/WETH)
Copied!
Last modified 24d ago