Skip to content
Permalink
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
90 lines (65 sloc) 4.41 KB

Servers implement the Quote and Order APIs using JSON-RPC 2.0 over HTTPS. To be accessible by other applications and websites, these servers run at public endpoints with CORS enabled. Each endpoint (locator) is staked on an indexer contract that takers query based on the tokens they wish to trade.

Introduction

On AirSwap there are makers, generally available to trade, and takers, everyday people looking to buy or sell tokens. 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 execution and settlement on the Swap contract. Within the AirSwap system, a Server is always the signer and a taker is always the sender.

  • Orders are signed and executable trades and Quotes are indicative prices. Servers should provide both.
  • Intent is a signal to takers that a server is trading specific tokens, including contact information (locator), without pricing.
  • Locators take the form of hostname[:port][/path] with a max length is 32 characters. If no scheme is provided, https:// is implied.

Getting Started

Quote and Order APIs

Servers implement the Quote and Order APIs. The following responses would be based on your internal pricing.

Quote API

  • getMaxQuote requests a Quote including maximum signer and sender amounts.
  • getSignerSideQuote requests a Quote including the signer amount.
  • getSenderSideQuote requests a Quote including the sender amount.

Order API

  • getSignerSideOrder is a request for an Order including the signer amount.
  • getSenderSideOrder is a request for an Order including the sender amount.

Error Handling

A JSON-RPC request may result in an error, matched by its request id:

Example

Request

{
  "jsonrpc": "2.0",
  "id": 123,
  "method": "getMaxQuote",
  "params": {
    "senderToken": "0xc778417e063141139fce010982780140aa0cd5ab",
    "signerToken": "0x27054b13b1b798b345b591a4d22e6562d47ea75a"
  }
}

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)

We have allocated the following range for Swap Protocol 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)

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
You can’t perform that action at this time.