Functions

    /**
     * @dev  Performs a swap using the provided route and swap parameters.
     * @param   route  The route parameters for the swap.
     * @param   swap_parameters  The parameters for the swaps to perform.
     * @return  The amount of the output token received.
     */
    function swap(RouteParam calldata route, SwapParams[] calldata swap_parameters)
        external
        payable
        returns (uint256)

Paramaters

RouteParam

@notice RouteParam is a struct that contains the parameters needed to execute a swap

struct RouteParam {
    address token_in;
    address token_out;
    uint256 amount_in;
    uint256 min_received;
    address destination;
    SwapType swap_type;
}
nametypedescription
token_inaddresscontract address of token to sell
token_outaddresscontract address of token to buy
amount_inuint256amount of token to sell
min_receiveduint256minimum received amount of user get
destinationaddressThe receiver address for the output token
swap_typeenum(SwapType)Swap type

#SwapType(Enum)

@notice SwapType is an enum that represents the type of swap

enum SwapType {
    ethToToken,
    tokenToEth,
    tokenToToken
}
namevaluedescription
ethToToken0eth to token
tokenToEth1token to eth
tokenToToken2token to token

SwapParams

@notice SwapParams is a struct that contains the parameters needed to execute a swap

struct SwapParams {
    address token_in;
    address token_out;
    uint32 rate;
    uint256 protocol_id;
    address pool_address;
    SwapType swap_type;
    uint256[] extra_data;
}
nametypedescription
token_inContractAddresscontract address of token to sell
token_outContractAddresscontract address of token to buy
rateuint32rate * 10**4 gives 4 precision points
protocol_iduint256procotol id
pool_addressaddresspool contract address
swap_typeenum(SwapType)Swap type
extra_dataArray(uint256)extra data from route

Events

Swap

event Swap(
    address sender,
    uint256 amount_in,
    uint256 amount_out,
    address token_in,
    address token_out,
    address destination
  )
nametypedescription
senderaddressaddress that execute the swap
token_inaddresscontract address of token to sold
token_outaddresscontract address of token to bought
amount_inuint256amount of token to sold
amount_outuint256amount of token to bought
destinationaddressThe receiver address for the output token