calculateTradeTargetAmount()

CarbonController.sol
    function calculateTradeTargetAmount(
        Token sourceToken,
        Token targetToken,
        TradeAction[] calldata tradeActions
    ) external view returns (uint128);

This function is used to get the number of source tokens that would be required to trade to receive the indicated number of target tokens.

Function Arguments

Returns

This returns the number of source tokens expected to be returned by the specified trade.

Example

tradeTargetAmount(
0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE, //token0
0x514910771AF9Ca656af840dff83E8264EcF986CA, //token1
[{712,1500000000000000000}, {615, 2300000000000000000}] // TradeAction {id, amount}
)

// Return
// 7300000000000000000 source tokens

For the ETH token, use the contract address: 0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE

Last updated