# calculateTradeTargetAmount()

{% code title="CarbonController.sol" overflow="wrap" lineNumbers="true" %}

```solidity
    function calculateTradeTargetAmount(
        Token sourceToken,
        Token targetToken,
        TradeAction[] calldata tradeActions
    ) external view returns (uint128);
```

{% endcode %}

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**

<table><thead><tr><th>Name</th><th width="116.66666666666663">Type</th><th>Description</th></tr></thead><tbody><tr><td>sourceToken</td><td>Token</td><td>The address of the token being swapped into the trade</td></tr><tr><td>targetToken</td><td>Token</td><td>The address of the token received from the trade</td></tr><tr><td>tradeActions</td><td>array</td><td>The list of TradeAction objects that specify the route of the trade <br><br>The TradeAction object contains the strategy ID of the strategy that is being swapped into, and the number of tokens being swapped in.<br><br>For example:<br>{712,<br>1500000000000000000}</td></tr></tbody></table>

### Returns

This returns the number of **source** tokens expected to be returned by the specified trade.&#x20;

### Example

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

// Return
// 7300000000000000000 source tokens
```

{% hint style="info" %}
For the ETH token, use the contract address: *0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE*&#x20;
{% endhint %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.carbondefi.xyz/contracts-and-functions/carboncontroller-functions/read-functions/calculatetradetargetamount.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
