ExchangeHelper

Git Source

Inherits: IExchangeHelper, ReentrancyGuard

deployed standalone and referenced by ExchangeProxy

do NOT set additional approval to this contract!

Functions

swapWithToken

perform arbitrary swap transaction

function swapWithToken(
    address sourceToken,
    address targetToken,
    uint256 sourceTokenAmount,
    address callee,
    address allowanceTarget,
    bytes calldata data,
    address refundAddress
) external nonReentrant returns (uint256 amountOut, uint256 sourceLeft);

Parameters

NameTypeDescription
sourceTokenaddresssource token to pull into this address
targetTokenaddresstarget token to buy
sourceTokenAmountuint256amount of source token to start the trade
calleeaddressexchange address to call to execute the trade.
allowanceTargetaddressaddress for which to set allowance for the trade
databytescalldata to execute the trade
refundAddressaddressaddress that un-used source token goes to

Returns

NameTypeDescription
amountOutuint256quantity of targetToken yielded by swap
sourceLeftuint256quantity of sourceToken left and refunded to refundAddress