> For the complete documentation index, see [llms.txt](https://docs.carbondefi.xyz/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.carbondefi.xyz/contracts-and-functions/carboncontroller-functions/write-functions/strategy-management/createstrategy.md).

# createStrategy()

{% hint style="danger" %}
Only standard ERC20 tokens are supported \
(rebase, fee-on-transfer etc are not supported)
{% endhint %}

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

```solidity
    function createStrategy(
        Token token0,
        Token token1,
        Order[2] calldata orders
    ) external payable nonReentrant whenNotPaused onlyProxyDelegate returns (uint256)
```

{% endcode %}

This function is used to create a strategy on Carbon DeFi. Each strategy must include two linked orders.&#x20;

### **Function Arguments**

<table><thead><tr><th width="171">Name</th><th width="159.66666666666663">Type</th><th>Description</th></tr></thead><tbody><tr><td>token0</td><td>Token</td><td>The first token in the strategy. Order0 will be referring to selling this token for token1. <br>(The Carbon DeFi UI will use this as "<a href="https://www.investopedia.com/terms/b/basecurrency.asp">Base</a>" token)</td></tr><tr><td>token1</td><td>Token</td><td>The second token in the strategy. <br>Order1 will be referring to selling this token for token0. <br>(The Carbon DeFi UI will use this as "<a href="https://www.investopedia.com/terms/q/quotecurrency.asp">Quote</a>" token)</td></tr><tr><td>orders</td><td>array</td><td>This is an array of two Order objects. Each order contains the following:<br><strong>y: uint128</strong> The amount of tokens deposited into the order.<br><strong>z: uint128</strong>  The y intercept of the order, which is used to calculate the marginal price.<br><strong>A: uint64</strong> Price range (width) parameter, encoded. <br><strong>B: uint64</strong> Price range (edge) parameter, encoded.  </td></tr></tbody></table>

### Example

{% code overflow="wrap" %}

```solidity
createStrategy(
0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE, //token0 ETH
0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48, //token1 USDC
[{y, z, A, B}, // order0, selling token0 (ETH) for token1 (USDC)
{y, z, A, B}], // order1, selling token1 (USDC) for token0 (ETH)
)

// In the Carbon DeFi UI, this will appear with rates in units of ETH per USDC. 
```

{% endcode %}

### Returns

This function returns the assigned id of the strategy.

### Important notes

{% hint style="success" %}

* While all required data is available on chain, it is recommended to use the [Carbon DeFi SDK](/developer-guides/carbon-defi-sdk.md).
* *Due to input value normalization and memory restrictions, the order parameters stored on chain might be slightly different than those \`input\` via the UI and/or the SDK.*&#x20;
  {% endhint %}

### Example

```
//user inputs

{
    'liquidity'    : 759250124,
    'lowestRate'   : 309485009821345068724781056.000000000000000000000,
    'highestRate'  : 309485009821345068724781056.000000000014551915228,
    'marginalRate' : 309485009821345068724781056.000000000000000000019
}

//encoded order

{
    'y': 759250124, 
    'z': 759250124, 
    'A': 0, 
    'B': 12807111440334848
}

//decoded order

{
    'liquidity'    : 759250124,
    'lowestRate'   : 309485009821345068724781056,
    'highestRate'  : 309485009821345068724781056,
    'marginalRate' : 309485009821345068724781056
}

```

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


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## 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/write-functions/strategy-management/createstrategy.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.
