Formats
Last updated
Last updated
AirSwap orders are mutually signed instructions to perform an atomic swap. Prior to execution, both the signer (party that creates and signs the order) and sender (party that sends the order to the EVM) must have approved the swap contract to transfer the specified tokens on their behalf.
An OrderERC20
has the following properties:
Property | Type | Description |
---|---|---|
Orders are passed to the SwapERC20 contract for execution, which emits a SwapERC20
event on success. The swapLight
function is more efficient, whereas the swap
function provides protocol fee rebates to staked AST holders. Either function can execute a properly signed order.
AirSwap signatures are EIP712, which includes a domain separator to avoid replays across chains.
TypeScript. Swap signatures in TypeScript can be created using the @airswap/utils
package.
Python. Swap signatures in Python can be created using the py_eth_sig_utils
package.
Optional. One account may authorize another account to sign orders on its behalf. For example, a server might sign using an account that has been authorized by a contract wallet. To manage signer authorizations, use the following functions on the SwapERC20 contract.
The following values are used for the EIP712Domain.
Param | Type | Value |
---|---|---|
nonce
uint256
Unique per signer and usually sequential.
expiry
uint256
Expiry in seconds since 1 January 1970.
signerWallet
address
Wallet that sets and signs terms.
signerToken
address
Token that the signer transfers.
signerAmount
uint256
Amount that the signer transfers.
senderToken
address
Token that the sender transfers.
senderAmount
uint256
Amount that the sender transfers.
v
uint8
v
value of the ECDSA signature.
r
bytes32
r
value of the ECDSA signature.
s
bytes32
s
value of the ECDSA signature.
name
bytes32
SWAP_ERC20
version
bytes32
4
chainId
uint256
Ethereum Mainnet: 1
, Goerli: 5
verifyingContract
address
SwapERC20 address