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
  • Function Arguments
  • Example
  1. Contracts & Functions
  2. CarbonVortexBridge Functions
  3. Write Functions

Bridge()

PreviousWrite FunctionsNextCarbon DeFi Public REST API

Last updated 2 months ago

    function bridge(uint256 amount) external payable override nonReentrant returns (uint256) {

This function allows anyone to trigger a bridge transaction where the consolidated fees (typically in the finalTargetToken format) will be sent to the Ethereum blockchain.

Function Arguments

Name
Type
Description

amount

uint256

This value represents the amount of tokens to bridge over from the contract on the selected chain to Ethereum

bridge

uint256

This value represents the bridge fee in native gas token units

This function requires 2 values to successfully work:

  1. Amount

    This value represents the amount of finalTargetToken you would like to bridge over. When passing the value 0, it will try to bridge the entire available amount. How to identify the available amount?

    1. Visit the CarbonVortex contract ()

    2. Read finalTargetToken to find the address of the token to bridge over (if the address is null, check targetToken address instead)

    3. Check the contract balance for the token address

  2. Bridge

    This value represents the bridge fee required in order for the transaction to completely deliver the tokens on the Ethereum blockchain. How to identify the required bridge fee?

    1. Visit

    2. Connect wallet

    3. Attempt to bridge any amount of tokens (you want to see the transaction details on your wallet signed page DO NOT SIGN THE TRANSACTION)

    4. In the wallet confirmation popup, find the value under "Param #2" as outlined in the image (you can "Cancel" the wallet popup after coping the required value)

    5. Copy the indicated value and paste it into the bridge field of the transaction. Make sure you normalize the decimal correctly to the gas token of the chain. For example, on Base, the input value should be in "ETH" units i.e. 0.000666588492010473 and not as indicated in WEI.

Example

bridge(
0, //zero will try to bridge the full available amount
0.000666588492010473 //bridge fee (some bridge require this value in WEI)
follow the address in the relevant chain
StarGate interface