createStrategy()

Only standard ERC20 tokens are supported (rebase, fee-on-transfer etc are not supported)

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

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

Function Arguments

Example

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. 

Returns

This function returns the assigned id of the strategy.

Important notes

  • While all required data is available on chain, it is recommended to use the Carbon DeFi SDK.

  • 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.

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
}

To create a strategy with the ETH token, use the contract address: 0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE

Last updated