Router
Functions#
constructor#
receive#
factory#
returns factory address
WETH#
returns WETH address
flash#
Accepts payment from msg.sender in the requested token
and calls the corresponding smart contract that implements
the ISfpyCallback interface.
If the callee is successful, it mints liquidity to the owner
of the flash app contract
Parameters:#
| Name | Type | Description |
|---|---|---|
token | address | the contract address of the token being used |
tokenAmount | uint256 | the amount of tokenAmount sent |
to | address | the recipient of the minted liquidity. Usually the same address that controls the Flash App |
callback | address | the address of the smart contract that implements the ISfpyCallback interface |
deadline | uint256 | Unix timestamp after which the transaction will revert. |
data | bytes | any aribitrary data needed to execute the Flash App |
pay#
Sends tokens to a pool designated for a particular address
adds liquidity to an ERC-20 pool. To cover all possible
scenarios msg.sender should have already given the router
an allowance of at least tokenAmount on token
Parameters:#
| Name | Type | Description |
|---|---|---|
token | address | the contract address of the token being used in the payment |
tokenAmount | uint256 | the amount of tokenAmount being paid |
rate | uint256 | a belief of the value of the token in a fiat currency - the exchange rate |
request | bytes32 | an external ID of a payment request |
to | address | recipient of the payment. |
deadline | uint256 | Unix timestamp after which the transaction will revert. |
refund#
Removes liquidity from an ERC-20 pool and sends the underlying
tokens to the recipient. To cover all possible
scenarios msg.sender should have already given the router
an allowance of at least the required liquidity to burn
Parameters:#
| Name | Type | Description |
|---|---|---|
token | address | the contract address of the token being used in the payment |
tokenAmount | uint256 | the amount of tokenAmount being paid |
payment | bytes32 | an external ID of a payment |
to | address | recipient of the payment. |
deadline | uint256 | Unix timestamp after which the transaction will revert. |
payETH#
Sends tokens to a pool designated for a particular address
when a payment needs to be made using ETH.
Adds liquidity to a WETH pool.
msg.value is treated as the amount of ETH being paid.
Parameters:#
| Name | Type | Description |
|---|---|---|
request | bytes32 | an external ID of a payment request |
to | address | recipient of the payment. |
rate | uint256 | a belief of the value of ETH in a fiat currency - the exchange rate |
deadline | uint256 | Unix timestamp after which the transaction will revert. |
refundETH#
Removes liquidity from a WETH pool and sends the underlying
ETH to the recipient.
To cover all possible scenarios msg.sender should have already given the router
an allowance of at least the required liquidity to burn
Parameters:#
| Name | Type | Description |
|---|---|---|
payment | bytes32 | an external ID of a payment |
tokenAmount | uint256 | the amount of tokenAmount being paid |
to | address | recipient of the payment. |
deadline | uint256 | Unix timestamp after which the transaction will revert. |
withdraw#
Removes liquidity from an ERC-20 pool and converts liquidity into the underlying token which is sent to the recipient
Parameters:#
| Name | Type | Description |
|---|---|---|
token | address | the contract address of the desired token. |
liquidity | uint256 | the amount of liquidity tokens to remove. |
amountMin | uint256 | the minimum amount of token that must be received for the transaction not to revert. |
to | address | recipient of the underlying assets. |
deadline | uint256 | Unix timestamp after which the transaction will revert. |
withdrawETH#
Removes liquidity from a WETH pool and converts liquidity into ETH which is sent to the recipient
Parameters:#
| Name | Type | Description |
|---|---|---|
liquidity | uint256 | the amount of liquidity tokens to remove. |
amountMin | uint256 | the minimum amount of token that must be received for the transaction not to revert. |
to | address | recipient of the underlying assets. |
deadline | uint256 | Unix timestamp after which the transaction will revert. |
refundWithPermit#
Removes liquidity from an ERC-20 pool and sends the underlying
tokens to the recipient, without pre-approval using EIP 712 signatures
Parameters:#
| Name | Type | Description |
|---|---|---|
token | address | the contract address of the token being used in the payment |
tokenAmount | uint256 | the amount of tokenAmount being refunded |
payment | bytes32 | an external ID of a payment |
to | address | recipient of the payment. |
deadline | uint256 | Unix timestamp after which the transaction will revert. |
approveMax | bool | Whether or not the approval amount in the signature is for liquidity or 2**256 |
v | uint8 | The v component of the permit signature. |
r | bytes32 | The r component of the permit signature. |
s | bytes32 | The s component of the permit signature. |
withdrawWithPermit#
Removes liquidity from an ERC-20 pool and converts liquidity into the underlying token, without pre-approval using EIP 712 signatures
Parameters:#
| Name | Type | Description |
|---|---|---|
token | address | the contract address of the desired token. |
liquidity | uint256 | the amount of liquidity tokens to remove. |
amountMin | uint256 | the minimum amount of token that must be received for the transaction not to revert. |
to | address | recipient of the underlying assets. |
deadline | uint256 | Unix timestamp after which the transaction will revert. |
approveMax | bool | Whether or not the approval amount in the signature is for liquidity or 2**256 |
v | uint8 | The v component of the permit signature. |
r | bytes32 | The r component of the permit signature. |
s | bytes32 | The s component of the permit signature. |
withdrawETHWithPermit#
Removes liquidity from a WETH pool and converts liquidity into ETH, without pre-approval using EIP 712 signatures
Parameters:#
| Name | Type | Description |
|---|---|---|
liquidity | uint256 | the amount of liquidity tokens to remove. |
amountMin | uint256 | the minimum amount of token that must be received for the transaction not to revert. |
to | address | recipient of the underlying assets. |
deadline | uint256 | Unix timestamp after which the transaction will revert. |
approveMax | bool | Whether or not the approval amount in the signature is for liquidity or 2**256 |
v | uint8 | The v component of the permit signature. |
r | bytes32 | The r component of the permit signature. |
s | bytes32 | The s component of the permit signature. |
refundETHWithPermit#
Removes liquidity from a WETH pool and sends the underlying
ETH to the recipient, without pre-approval using EIP 712 signatures
Parameters:#
| Name | Type | Description |
|---|---|---|
tokenAmount | bytes32 | the amount of tokenAmount being refunded |
payment | uint256 | an external ID of a payment |
to | address | recipient of the payment. |
deadline | uint256 | Unix timestamp after which the transaction will revert. |
approveMax | bool | Whether or not the approval amount in the signature is for liquidity or 2**256 |
v | uint8 | The v component of the permit signature. |
r | bytes32 | The r component of the permit signature. |
s | bytes32 | The s component of the permit signature. |