Skip to main content

Router

Functions#

constructor#

function constructor(
) public

receive#

function receive(
) external

factory#

function factory(
) external returns (address)

returns factory address

WETH#

function WETH(
) external returns (address)

returns WETH address

flash#

function flash(
address token,
uint256 tokenAmount,
address to,
address callback,
uint256 deadline,
bytes data
) external returns (uint256 amount, uint256 liquidity)

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:#

NameTypeDescription
tokenaddressthe contract address of the token being used
tokenAmountuint256the amount of tokenAmount sent
toaddressthe recipient of the minted liquidity. Usually the same address that controls the Flash App
callbackaddressthe address of the smart contract that implements the ISfpyCallback interface
deadlineuint256Unix timestamp after which the transaction will revert.
databytesany aribitrary data needed to execute the Flash App

pay#

function pay(
address token,
uint256 tokenAmount,
uint256 rate,
bytes32 request,
address to,
uint256 deadline
) external returns (uint256 amount, uint256 liquidity)

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:#

NameTypeDescription
tokenaddressthe contract address of the token being used in the payment
tokenAmountuint256the amount of tokenAmount being paid
rateuint256a belief of the value of the token in a fiat currency - the exchange rate
requestbytes32an external ID of a payment request
toaddressrecipient of the payment.
deadlineuint256Unix timestamp after which the transaction will revert.

refund#

function refund(
address token,
uint256 tokenAmount,
bytes32 payment,
address to,
uint256 deadline
) external returns (uint256 amount, uint256 liquidity)

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:#

NameTypeDescription
tokenaddressthe contract address of the token being used in the payment
tokenAmountuint256the amount of tokenAmount being paid
paymentbytes32an external ID of a payment
toaddressrecipient of the payment.
deadlineuint256Unix timestamp after which the transaction will revert.

payETH#

function payETH(
bytes32 request,
address to,
uint256 rate,
uint256 deadline
) external returns (uint256 amount, uint256 liquidity)

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:#

NameTypeDescription
requestbytes32an external ID of a payment request
toaddressrecipient of the payment.
rateuint256a belief of the value of ETH in a fiat currency - the exchange rate
deadlineuint256Unix timestamp after which the transaction will revert.

refundETH#

function refundETH(
bytes32 payment,
uint256 tokenAmount,
address to,
uint256 deadline
) external returns (uint256 amount, uint256 liquidity)

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:#

NameTypeDescription
paymentbytes32an external ID of a payment
tokenAmountuint256the amount of tokenAmount being paid
toaddressrecipient of the payment.
deadlineuint256Unix timestamp after which the transaction will revert.

withdraw#

function withdraw(
address token,
uint256 liquidity,
uint256 amountMin,
address to,
uint256 deadline
) public returns (uint256 amount)

Removes liquidity from an ERC-20 pool and converts liquidity into the underlying token which is sent to the recipient

Parameters:#

NameTypeDescription
tokenaddressthe contract address of the desired token.
liquidityuint256the amount of liquidity tokens to remove.
amountMinuint256the minimum amount of token that must be received for the transaction not to revert.
toaddressrecipient of the underlying assets.
deadlineuint256Unix timestamp after which the transaction will revert.

withdrawETH#

function withdrawETH(
uint256 liquidity,
uint256 amountMin,
address to,
uint256 deadline
) public returns (uint256 amount)

Removes liquidity from a WETH pool and converts liquidity into ETH which is sent to the recipient

Parameters:#

NameTypeDescription
liquidityuint256the amount of liquidity tokens to remove.
amountMinuint256the minimum amount of token that must be received for the transaction not to revert.
toaddressrecipient of the underlying assets.
deadlineuint256Unix timestamp after which the transaction will revert.

refundWithPermit#

function refundWithPermit(
address token,
uint256 tokenAmount,
bytes32 payment,
address to,
uint256 deadline,
bool approveMax,
uint8 v,
bytes32 r,
bytes32 s
) external returns (uint256 amount)

Removes liquidity from an ERC-20 pool and sends the underlying
tokens to the recipient, without pre-approval using EIP 712 signatures

Parameters:#

NameTypeDescription
tokenaddressthe contract address of the token being used in the payment
tokenAmountuint256the amount of tokenAmount being refunded
paymentbytes32an external ID of a payment
toaddressrecipient of the payment.
deadlineuint256Unix timestamp after which the transaction will revert.
approveMaxboolWhether or not the approval amount in the signature is for liquidity or 2**256
vuint8The v component of the permit signature.
rbytes32The r component of the permit signature.
sbytes32The s component of the permit signature.

withdrawWithPermit#

function withdrawWithPermit(
address token,
uint256 liquidity,
uint256 amountMin,
address to,
uint256 deadline,
bool approveMax,
uint8 v,
bytes32 r,
bytes32 s
) external returns (uint256 amount)

Removes liquidity from an ERC-20 pool and converts liquidity into the underlying token, without pre-approval using EIP 712 signatures

Parameters:#

NameTypeDescription
tokenaddressthe contract address of the desired token.
liquidityuint256the amount of liquidity tokens to remove.
amountMinuint256the minimum amount of token that must be received for the transaction not to revert.
toaddressrecipient of the underlying assets.
deadlineuint256Unix timestamp after which the transaction will revert.
approveMaxboolWhether or not the approval amount in the signature is for liquidity or 2**256
vuint8The v component of the permit signature.
rbytes32The r component of the permit signature.
sbytes32The s component of the permit signature.

withdrawETHWithPermit#

function withdrawETHWithPermit(
uint256 liquidity,
uint256 amountMin,
address to,
uint256 deadline,
bool approveMax,
uint8 v,
bytes32 r,
bytes32 s
) external returns (uint256 amount)

Removes liquidity from a WETH pool and converts liquidity into ETH, without pre-approval using EIP 712 signatures

Parameters:#

NameTypeDescription
liquidityuint256the amount of liquidity tokens to remove.
amountMinuint256the minimum amount of token that must be received for the transaction not to revert.
toaddressrecipient of the underlying assets.
deadlineuint256Unix timestamp after which the transaction will revert.
approveMaxboolWhether or not the approval amount in the signature is for liquidity or 2**256
vuint8The v component of the permit signature.
rbytes32The r component of the permit signature.
sbytes32The s component of the permit signature.

refundETHWithPermit#

function refundETHWithPermit(
bytes32 tokenAmount,
uint256 payment,
address to,
uint256 deadline,
bool approveMax,
uint8 v,
bytes32 r,
bytes32 s
) external returns (uint256 amount)

Removes liquidity from a WETH pool and sends the underlying
ETH to the recipient, without pre-approval using EIP 712 signatures

Parameters:#

NameTypeDescription
tokenAmountbytes32the amount of tokenAmount being refunded
paymentuint256an external ID of a payment
toaddressrecipient of the payment.
deadlineuint256Unix timestamp after which the transaction will revert.
approveMaxboolWhether or not the approval amount in the signature is for liquidity or 2**256
vuint8The v component of the permit signature.
rbytes32The r component of the permit signature.
sbytes32The s component of the permit signature.

Interface#

interface ISfpyRouter {
event Pay(
address indexed from,
address indexed to,
address indexed token,
bytes32 request,
uint256 amount,
uint256 rate
);
event Refund(
address indexed from,
address indexed to,
address indexed token,
bytes32 payment,
uint256 amount
);
event Flash(
address indexed from,
address indexed to,
address indexed token,
address callback,
uint256 amount
);
function factory() external view returns (address);
function WETH() external view returns (address);
function flash(
address token,
uint256 tokenAmount,
address to,
address callback,
uint256 deadline,
bytes calldata data
) external returns (uint256 amount, uint256 liquidity);
function pay(
address token,
uint256 tokenAmount,
uint256 rate,
bytes32 request,
address to,
uint256 deadline
) external returns (uint256 amount, uint256 liquidity);
function refund(
address token,
uint256 tokenAmount,
bytes32 payment,
address to,
uint256 deadline
) external returns (uint256 amount, uint256 liquidity);
function payETH(
bytes32 request,
address to,
uint256 rate,
uint256 deadline
) external payable returns (uint256 amount, uint256 liquidity);
function refundETH(
bytes32 payment,
uint256 tokenAmount,
address to,
uint256 deadline
) external returns (uint256 amount, uint256 liquidity);
function withdraw(
address token,
uint256 liquidity,
uint256 amountMin,
address to,
uint256 deadline
) external returns (uint256 amount);
function withdrawWithPermit(
address token,
uint256 liquidity,
uint256 amountMin,
address to,
uint256 deadline,
bool approveMax,
uint8 v,
bytes32 r,
bytes32 s
) external returns (uint256 amount);
function refundWithPermit(
address token,
uint256 tokenAmount,
bytes32 payment,
address to,
uint256 deadline,
bool approveMax,
uint8 v,
bytes32 r,
bytes32 s
) external returns (uint256 amount);
function withdrawETH(
uint256 liquidity,
uint256 amountMin,
address to,
uint256 deadline
) external returns (uint256 amount);
function withdrawETHWithPermit(
uint256 liquidity,
uint256 amountMin,
address to,
uint256 deadline,
bool approveMax,
uint8 v,
bytes32 r,
bytes32 s
) external returns (uint256 amount);
function refundETHWithPermit(
bytes32 payment,
uint256 tokenAmount,
address to,
uint256 deadline,
bool approveMax,
uint8 v,
bytes32 r,
bytes32 s
) external returns (uint256 amount);
}