tradeByTargetAmount()

Trade target tokens for the least amount of source tokens possible

Function tradeByTargetAmount()

    function tradeByTargetAmount(
        Token sourceToken,
        Token targetToken,
        uint256 targetAmount,
        uint256 maxSourceAmount,
        uint256 deadline,
        address beneficiary
    ) external payable 

Trades to receive the exact amount of target tokens for as few source tokens as possible.

Function Arguments

NameTypeDescription

sourceToken

Token

The source token address

targetToken

Token

The target token address

targetAmount

uint256

The exact amount of tokens to receive

maxSourceAmount

uint256

The maximum amount of source tokens that can be used for the transaction to not revert

deadline

uint256

Unix timestamp after which the transaction will revert

beneficiary

address

The address receiving the target tokens

See Errors and Troubleshooting for a list of common errors and how to resolve them.

To trade directly with the Ether token, use the contract address: 0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE

Last updated