Carbon DeFi Dev
  • Carbon DeFi
    • Introducing Carbon DeFi
      • What Makes Carbon DeFi Unique?
      • Fees & Payments
      • Resources
    • Security & Audits
  • Contracts & Functions
    • Contracts
      • CarbonController
      • CarbonVortex
      • CarbonVortexBridge
      • Deployments
        • Mainnet Contracts
        • Testnet Contracts
    • CarbonController Functions
      • Write Functions
        • Transaction Prerequisites
          • approve() / allowance()
        • Trade
          • tradeBySourceAmount()
          • tradeByTargetAmount()
        • Strategy Management
          • createStrategy()
          • updateStrategy
          • deleteStrategy()
      • Read Functions
        • controllerType()
        • tradingFeePPM()
        • pairTradingFeePPM()
        • pair()
        • pairs()
        • strategy()
        • strategiesByPair()
        • strategiesByPairCount()
        • calculateTradeSourceAmount()
        • calculateTradeTargetAmount()
      • Data & Events
        • TradingFeePPMUpdated()
        • PairCreated()
        • StrategyCreated()
        • StrategyDeleted()
        • StrategyUpdated()
        • TokensTraded()
        • FeesWithdrawn()
    • CarbonVortex Functions
      • Write Functions
        • trade()
        • execute()
      • Read Functions
        • amountAvailableForTrading()
        • availableTokens()
        • expectedTradeInput()
        • expectedTradeReturn()
        • finalTargetToken()
        • minTargetTokenSaleAmount()
        • minTokenSaleAmount()
        • pairDisabled()
        • priceDecayHalfLife()
        • rewardsPPM()
        • targetToken()
        • targetTokenPriceDecayHalfLife()
        • targetTokenSaleAmount()
        • tokenPrice()
        • totalCollected()
        • tradingEnabled()
    • CarbonVortexBridge Functions
      • Write Functions
        • Bridge()
  • Rest API
    • Carbon DeFi Public REST API
  • Developer Guides
    • Carbon DeFi SDK
      • Getting started
      • Interacting with the SDK
        • Managing Strategies
        • Performing Trades
        • Getting User and Pair Data
        • Collecting Liquidity Data
      • SDK Functions
        • constructor
        • startDataSync
        • getCachedPairs
        • hasLiquidityByPair
        • getLiquidityByPair
        • getUserStrategies
        • getTradeData
        • composeTradeByTargetTransaction
        • composeTradeBySourceTransaction
        • createBuySellStrategy
        • updateStrategy
        • deleteStrategy
        • getMinRateByPair
        • getMaxRateByPair
        • getRateLiquidityDepthByPair
    • The Carbon DeFi versus Uniswap V3 Invariant Functions
    • Carbon DeFi Subgraph
      • Accessing the Subgraph
      • Creating Subgraph Queries
      • Subgraph Query in Python
      • Sample Subgraph Queries
    • Using CarbonVortex
      • CarbonVortex Dynamics
Powered by GitBook
On this page
  1. Developer Guides
  2. Carbon DeFi SDK
  3. SDK Functions

createBuySellStrategy

This function creates an unsigned transaction to create a strategy, using a buy/sell format.

public createBuySellStrategy(
    baseToken: { address: string; decimals: number },
    quoteToken: { address: string; decimals: number },
    buyPriceLow: string,
    buyPriceHigh: string,
    buyBudget: string,
    sellPriceLow: string,
    sellPriceHigh: string,
    sellBudget: string,
    overrides?: PayableOverrides
  )
Name
Type
Description

baseToken

object {token address, number}

An object containing a token address and a string with the number of decimal places used for the given token.

quoteToken

object {token address, number}

An object containing a token address and a string with the number of decimal places used for the given token.

buyPriceLow

string (number)

The lowest price at which to buy the quote token, in the form of quoteTokens per 1 baseToken.

buyPriceHigh

string (number)

The highest price at which to buy the quote token, in the form quoteTokens per 1 baseToken.

buyBudget

string (number)

The number of base tokens to start the strategy with.

sellPriceLow

string (number)

The lowest price at which to buy the base token, in the form of baseTokens per 1 quote token.

sellPriceHigh

string (number)

The highest price at which to buy the base token, in the form of baseTokens per 1 quote token.

sellBudget

string (number)

The number of quote tokens to start the strategy with.

overrides

object (optional)

Returns

This function returns an unsigned transaction that is ready to sign and submit to the blockchain.

Example:

createBuySellStrategy(
    {"0x514910771AF9Ca656af840dff83E8264EcF986CA", 18}, // LINK token, 18 decimal places
    {"0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE", 18}, // ETH token, 18 decimal places
    "0.05", // Lowest number of ETH per LINK
    "0.07", // Highest number of ETH per LINK
    "1877.3", // number of LINK to start the strategy with
    "25", // Lowest number of LINK per ETH
    "30", // Highest number of LINK per ETH
    "5.2", // number of ETH to start the strategy with
    null // optional overrides - skipped
  )
PreviouscomposeTradeBySourceTransactionNextupdateStrategy

Last updated 5 months ago

This optional object contains transaction parameters, such as gas price, Eth value, etc. See overrides in the for details.

Ethers documentation