tradeByTargetAmount()
The function parameters must include the list of orders (tradeActions) to interact with.
Using the SDK is highly recommended. See Performing Trades for details.
Function tradeByTargetAmount()
This function will trade to receive the exact amount of indicated target tokens for as few source tokens as possible.
Function Arguments
sourceToken
Token
The source token address
targetToken
Token
The target token address
tradeActions
list
This is a list of TradeAction objects, each of which contain the strategyId and amount of target tokens to receive from the strategy.
deadline
uint256
Unix timestamp after which the transaction will revert
maxInput
uint128
The maximum amount of source tokens you are willing to spend (use) for the transaction to result in the requested targetToken amount and not revert
tradeAction amount
need to follow the relevant token decimal.
tradeByTargetAmount, follows the targetToken decimals
Example
While all required data is available on chain, it is recommended to use the Carbon DeFi SDK.
To trade directly with the ETH token, use the contract address: 0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE
Last updated