Protocols

Discovery

getProtocols

Peers may call getProtocols to determine protocols supported by a peer. Protocols are identified by interfaceId and configuration params include the chainId, swapContractAddress, and walletAddress that the peer intends to use.

getProtocols(
): [SupportedProtocolInfo](#supportedprotocolinfo)[]

Returns

[SupportedProtocolInfo](#supportedprotocolinfo)[] — Array of supported protocol configurations

setProtocols

When connected via WebSocket, the server may send a setProtocols notification to the client to indicate the protocols it supports.

setProtocols(
  protocols: [SupportedProtocolInfo](#supportedprotocolinfo)[], // Array of supported protocol configurations
): boolean

Parameters

Name
Type
Required
Description

protocols

Yes

Array of supported protocol configurations

Returns

boolean

getTokens

Peers may call getTokens to determine tokens supported by another peer, whether connected via HTTPS or WebSocket. The return value is an array of tokens identified by the token contract address.

Returns

[Address](#address)[] — Array of token contract addresses

setTokens

When connected via WebSocket, the server may send a setTokens notification to indicate the tokens it supports.

Parameters

Name
Type
Required
Description

tokens

Yes

Array of token contract addresses

Returns

boolean

RequestForQuoteERC20

getSignerSideOrderERC20

Given a senderAmount the server returns a signed OrderERC20 including the signerAmount. The client is selling to the server. Client may optionally request a minimum expiry in seconds.

Parameters

Name
Type
Required
Description

chainId

Yes

The blockchain network chain ID

swapContract

Yes

Address of the AirSwap SwapERC20 contract

senderAmount

Yes

Amount of tokens the sender will provide (in wei)

signerToken

Yes

Address of the token the signer will provide

senderToken

Yes

Address of the token the sender will provide

senderWallet

Yes

Address of the sender's wallet

minExpiry

No

Minimum expiry in seconds (optional)

proxyingFor

No

Address being proxied for (optional)

Returns

[OrderERC20](#ordererc20) — Signed ERC20 order

getSenderSideOrderERC20

Given a signerAmount the server returns a signed OrderERC20 with a senderAmount. The client is buying from the server. Client may optionally request a minimum expiry in seconds.

Parameters

Name
Type
Required
Description

chainId

Yes

The blockchain network chain ID

swapContract

Yes

Address of the AirSwap SwapERC20 contract

signerAmount

Yes

Amount of tokens the signer will provide (in wei)

signerToken

Yes

Address of the token the signer will provide

senderToken

Yes

Address of the token the sender will provide

senderWallet

Yes

Address of the sender's wallet

minExpiry

No

Minimum expiry in seconds (optional)

proxyingFor

No

Address being proxied for (optional)

Returns

[OrderERC20](#ordererc20) — Signed ERC20 order

getPricingERC20

Client may request soft pricing for a list of token pairs. Client may optionally request a minimum expiry in seconds to be factored into pricing. Returns current formula or levels for each pair.

Parameters

Name
Type
Required
Description

pairs

Yes

Array of token pairs to get pricing for

minExpiry

No

Minimum expiry in seconds (optional)

Returns

[Pricing](#pricing)[] — Pricing information for each pair

getAllPricingERC20

Client may request pricing for all available pairs.

Returns

[Pricing](#pricing)[] — Pricing information for all available pairs

LastLookERC20

subscribePricingERC20

Client subscribes to pricing updates for a list of token pairs. Returns current formula or levels for each pair.

Parameters

Name
Type
Required
Description

pairs

Yes

Array of token pairs to subscribe to

minExpiry

No

Minimum expiry in seconds (optional)

Returns

[Pricing](#pricing)[] — Current pricing for subscribed pairs

subscribeAllPricingERC20

Client subscribes to pricing updates for all available pairs. Returns current formula or levels for each pair.

Returns

[Pricing](#pricing)[] — Current pricing for all available pairs

unsubscribePricingERC20

Client unsubscribes from pricing updates for a list of token pairs.

Parameters

Name
Type
Required
Description

pairs

Yes

Array of token pairs to unsubscribe from

Returns

boolean

unsubscribeAllPricingERC20

Client unsubscribes from all pricing subscriptions.

Returns

boolean

setPricingERC20

Server updates pricing for one or more token pairs.

Parameters

Name
Type
Required
Description

pricing

Yes

Array of pricing updates

Returns

boolean

considerOrderERC20

Client provides a priced OrderERC20 to the server. Returns boolean true if accepted by the server. In last-look, the client is the signer and the server is the sender.

Parameters

Name
Type
Required
Description

nonce

Yes

Unique order nonce

expiry

Yes

Order expiry timestamp

signerWallet

Yes

Address of the signer's wallet

signerToken

Yes

Address of the token the signer will provide

signerAmount

Yes

Amount of tokens the signer will provide

senderToken

Yes

Address of the token the sender will provide

senderAmount

Yes

Amount of tokens the sender will provide

v

Yes

ECDSA signature recovery parameter

r

Yes

ECDSA signature r parameter

s

Yes

ECDSA signature s parameter

Returns

boolean — Whether the order was accepted

Indexing

addOrder

Peers may call addOrder to add an order to another peer.

Parameters

Name
Type
Required
Description

order

Yes

The full order to add

tags

string[]

No

Tags to associate with the order

Returns

boolean

getOrders

Peers may call getOrders to query for orders indexed by another peer.

Parameters

Name
Type
Required
Description

filter

Yes

Filter criteria for orders

offset

integer

No

Pagination offset

limit

integer

No

Maximum number of orders to return

by

No

Index to sort by

direction

No

Sort direction

Returns

[OrderResponse](#orderresponse)

getTags

Peers may call getTags to get all available tags for a token.

Parameters

Name
Type
Required
Description

token

Yes

Token contract address

Returns

string[]

IndexingERC20

addOrderERC20

Peers may call addOrderERC20 to add an ERC20 order to another peer.

Parameters

Name
Type
Required
Description

order

Yes

The full ERC20 order to add

tags

string[]

No

Tags to associate with the order

Returns

boolean

getOrdersERC20

Peers may call getOrdersERC20 to query for ERC20 orders indexed by another peer.

Parameters

Name
Type
Required
Description

filter

Yes

Filter criteria for orders

offset

integer

No

Pagination offset

limit

integer

No

Maximum number of orders to return

by

No

Index to sort by

direction

No

Sort direction

Returns

[OrderResponseERC20](#orderresponseerc20)

getTags

Peers may call getTags to get all available tags for a token.

Parameters

Name
Type
Required
Description

token

Yes

Token contract address

Returns

string[]

Types

Address

Ethereum address (20 bytes)

Bytes32

32-byte hex string

Amount

Numeric string representing an amount

ChainId

Blockchain network chain ID

SupportedProtocolInfo

Information about a supported trading protocol

Property
Type
Description

interfaceId

string

Protocol interface identifier (e.g., 0x02ad05d3 for RequestForQuoteERC20)

params

{ chainId: ChainId, swapContractAddress: Address, walletAddress: Address, senderServer: string, senderWallet: Address }

TokenPair

A pair of tokens for trading

Property
Type
Description

baseToken

Base token address

quoteToken

Quote token address

OrderERC20

Signed ERC20 order in AirSwap format

Property
Type
Description

nonce

Unique order nonce

expiry

Order expiry timestamp (Unix timestamp)

signerWallet

Address of the signer's wallet

signerToken

Address of the token the signer will provide

signerAmount

Amount of tokens the signer will provide (in wei)

protocolFee

Protocol fee in basis points

senderToken

Address of the token the sender will provide

senderAmount

Amount of tokens the sender will provide (in wei)

v

ECDSA signature recovery parameter

r

ECDSA signature r parameter

s

ECDSA signature s parameter

FullOrderERC20

Full ERC20 order including settlement information

FullOrder

Full order for NFT/ERC721 swaps

Property
Type
Description

nonce

expiry

signerWallet

signerToken

signerAmount

signerId

senderWallet

senderToken

senderAmount

senderId

affiliateWallet

affiliateAmount

chainId

swapContract

Pricing

Pricing information for a token pair

Property
Type
Description

baseToken

quoteToken

minimum

Minimum order size

bid

any

Bid pricing (levels array or formula string)

ask

any

Ask pricing (levels array or formula string)

Levels

Array of price levels as [baseAmount, quoteAmount] tuples in wei

Formula

Pricing formula where x is the input amount (e.g., 'x*0.00053')

OrderFilter

Filter criteria for querying orders

Property
Type
Description

chainId

signerWallet

signerToken

signerId

senderWallet

senderToken

minSignerAmount

maxSignerAmount

minSenderAmount

maxSenderAmount

tags

string[]

Indexes

Index to sort orders by

Direction

Sort direction

OrderResponse

Response containing orders and pagination info

Property
Type
Description

orders

offset

integer

total

integer

OrderResponseERC20

Response containing ERC20 orders and pagination info

Property
Type
Description

offset

integer

total

integer

Last updated