Running a Server

Servers implement the Quote and Order APIs using JSON-RPC over HTTP. To be reachable for RFQs, servers run at public endpoints with CORS enabled. To become discoverable, server URLs are added to the Indexer smart contract, which is queried by prospective counterparties.

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. Within the AirSwap RFQ system, a Server is always the signer and a taker 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.

  • Locators take the form of hostname[:port][/path] with a max length is 32 characters. If no scheme is provided, https:// is implied.

  • Indexers are used to signal that a server is available to trade specific tokens, including contact information (locator), without pricing.

Getting Started

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

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

You should provide descriptive errors where possible. In the case of a server side error, return a JSON-RPC error response.

{
"jsonrpc": "2.0",
"id": 123,
"error": { "code": -33605, "message": "Rate limit exceeded" }
}

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)