calculateTradeSourceAmount()

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

This function is used to get the number of target tokens that would be received by trading the indicated number of source tokens.

Function Arguments

Returns

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

Example

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

// Return
// 7300000000000000000

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

Last updated