Swap is a trustless peer-to-peer trade settlement contract. View the code on GitHub.
Authorizations are for peers that trade on behalf of others. These peers are authorized by an individual to send or sign orders for them. Peers can be wallets (people or programs) or smart contracts.
Affiliates are third-parties compensated for their part in bringing together the two parties of a trade, and can be other traders or software applications that connect traders on the network.
Create a new Swap
contract.
constructor() public
An atomic token swap between a signer and a sender.
function swap(Types.Order calldata order) external
Param | Type | Required | Description |
|
| required | Order struct as specified in Types. |
Preconditions |
✓ signerWallet must approve the Swap contract to transfer its signerToken. |
✓ senderWallet must approve the Swap contract to transfer its senderToken. |
A successful swap
emits a Swap
event.
event Swap(uint256 indexed nonce,uint256 timestamp,address indexed signerWallet,uint256 signerParam,address signerToken,address indexed senderWallet,uint256 senderParam,address senderToken,address affiliateWallet,uint256 affiliateParam,address affiliateToken);
Revert Reason | Scenario |
| Order has been signed by an account that has not been authorized to sign it. |
| Signature provided does not match the Order provided. |
| Order has already been taken or cancelled by its |
| Order has an |
| Nonce provided is below the minimum value set. |
| Order has been sent by an account that has not been authorized to send it. |
| Order has the same signer and sender for the swap. |
| One of the token transfers in the swap failed. |
Provide an array of nonces
, unique by signer address, to mark one or more orders as cancelled.
Out of gas may occur in arrays of length > 400
function cancel(uint256[] memory nonces) external
Param | Type | Required | Description |
|
| required | Array of order nonces to cancel. |
A successful cancel
emits one Cancel
event per nonce.
event Cancel(uint256 indexed nonce,address indexed signerWallet);
Provide a minimum value to cancel all nonces below the value. This is not inclusive - the minimumNonce
value is still considered valid.
function cancelUpTo(uint256 minimumNonce) external
Param | Type | Required | Description |
|
| required | Lowest acceptable nonce value for a signer. |
A successful cancelUpTo
emits an CancelUpTo
event.
event CancelUpTo(uint256 indexed nonce,address indexed signerWallet);
Authorize another account or contract send orders on behalf of the caller.
function authorizeSender(address authorizedSender) external
Param | Type | Required | Description |
|
| required | Address to authorize for sending. |
A successful authorizeSender
emits an AuthorizeSender
event.
event AuthorizeSender(address indexed authorizerAddress,address indexed authorizedSender);
Revert Reason | Scenario |
| The |
Authorize another account or contract to:
Sign an order OR
Submit an order without a signature
on behalf of the function caller. This means the function caller is no longer required to sign such orders.
function authorizeSigner(address authorizedSigner) external
Param | Type | Required | Description |
|
| required | Address to authorize for signing. |
A successful authorizeSigner
emits an AuthorizeSigner
event.
event AuthorizeSigner(address indexed authorizerAddress,address indexed authorizedSigner);
Revert Reason | Scenario |
| The |
Revoke the sending authorization of a delegate account or contract.
function revokeSender(address authorizedSender) external
Param | Type | Required | Description |
|
| required | Address from which to revoke sending authorization. |
A successful revokeSender
emits a RevokeSender
event.
event RevokeSender(address indexed authorizerAddress,address indexed revokedSender,);
Revoke the signing authorization of a delegate account or contract.
function revokeSigner(address authorizedSigner) external
Param | Type | Required | Description |
|
| required | Address from which to revoke signing authorization. |
A successful revokeSigner
emits a RevokeSigner
event.
event RevokeSigner(address indexed authorizerAddress,address indexed revokedSigner,);