Skip to main content

ClipperRouter

Clipper router that allows to use ClipperExchangeInterface for swaps

Derives

Functions

constructor

function constructor(contract IWETH weth)

Parameters:

NameTypeDescription
wethcontract IWETH

clipperSwapToWithPermit

function clipperSwapToWithPermit(
contract IClipperExchangeInterface clipperExchange,
address payable recipient,
contract IERC20 srcToken,
contract IERC20 dstToken,
uint256 inputAmount,
uint256 outputAmount,
uint256 expiryWithFlags,
bytes32 r,
bytes32 vs,
bytes calldata permit
) external returns(uint256 returnAmount)

Same as clipperSwapTo but calls permit first, allowing to approve token spending and make a swap in one transaction.

Parameters:

NameTypeDescription
clipperExchangecontract IClipperExchangeInterfaceClipper pool address
recipientaddress payableAddress that will receive swap funds
srcTokencontract IERC20Source token
dstTokencontract IERC20Destination token
inputAmountuint256Amount of source tokens to swap
outputAmountuint256Amount of destination tokens to receive
expiryWithFlagsuint256Timestamp until the swap will be valid with permit2 flag
rbytes32Clipper order signature (r part)
vsbytes32Clipper order signature (vs part)
permitbytesShould contain valid permit that can be used in IERC20Permit.permit calls. See tests for examples

Return values

NameTypeDescription
returnAmountuint256Amount of destination tokens received

clipperSwap

function clipperSwap(
contract IClipperExchangeInterface clipperExchange,
contract IERC20 srcToken,
contract IERC20 dstToken,
uint256 inputAmount,
uint256 outputAmount,
uint256 expiryWithFlags,
bytes32 r,
bytes32 vs
) external payable returns(uint256 returnAmount)

Same as clipperSwapTo but uses msg.sender as recipient

Parameters:

NameTypeDescription
clipperExchangecontract IClipperExchangeInterfaceClipper pool address
srcTokencontract IERC20Source token
dstTokencontract IERC20Destination token
inputAmountuint256Amount of source tokens to swap
outputAmountuint256Amount of destination tokens to receive
expiryWithFlagsuint256Timestamp until the swap will be valid with permit2 flag
rbytes32Clipper order signature (r part)
vsbytes32Clipper order signature (vs part)

Return values

NameTypeDescription
returnAmountuint256Amount of destination tokens received

clipperSwapTo

function clipperSwapTo(
contract IClipperExchangeInterface clipperExchange,
address payable recipient,
contract IERC20 srcToken,
contract IERC20 dstToken,
uint256 inputAmount,
uint256 outputAmount,
uint256 expiryWithFlags,
bytes32 r,
bytes32 vs
) public payable returns(uint256 returnAmount)

Performs swap using Clipper exchange. Wraps and unwraps ETH if required. Sending non-zero msg.value for anything but ETH swaps is prohibited

Parameters:

NameTypeDescription
clipperExchangecontract IClipperExchangeInterfaceClipper pool address
recipientaddress payableAddress that will receive swap funds
srcTokencontract IERC20Source token
dstTokencontract IERC20Destination token
inputAmountuint256Amount of source tokens to swap
outputAmountuint256Amount of destination tokens to receive
expiryWithFlagsuint256Timestamp until the swap will be valid with permit2 flag
rbytes32Clipper order signature (r part)
vsbytes32Clipper order signature (vs part)

Return values

NameTypeDescription
returnAmountuint256Amount of destination tokens received