XY Finance
  • Getting Started
  • XY Token
  • Supported Blockchains/Bridges/DEXs
  • Fee Structure
    • 🌉yBridge Fee Information
    • 🌉(Legacy) XY Bridge Fee Information
  • products
    • Bridge Aggregator : XY Finance
      • Gasless Transaction
    • Bridge : yBridge
      • Yield Farming
      • Omnichain Settlement
      • Consensus
    • Refuel
    • Proxy Bridge
    • Cross Chain Infrastructure
  • Bridge Aggregator Integration
    • XY Finance API (Multiple Bridges Aggregator)
      • 1️⃣Get Quote
      • 2️⃣Get Allowance
      • 3️⃣Build Approval Transaction
      • 4️⃣Build Swap Transaction
      • 5️⃣Get Cross-Chain Status
      • 6️⃣Get MinimumSwapAmount
      • ✔️Recommended Tokens
      • ✅Supported Blockchains/Bridges/DEXs
      • 📩Error Message
      • 💰Monetization / Take Fees
      • 📄Change Log
    • XY Finance Widget (iframe)
      • (Legacy) XY Finance Widget (iframe)
    • XY Finance Widget (NPM)
      • 1️⃣Install the Widget
      • 2️⃣Configure the Widget
      • 3️⃣Customize the Theme
      • 📘Widget API Reference
      • 📄Change Log
    • Custom-Built Link
    • Token Listing
  • Single Bridge Integration
    • yBridge API
      • 1️⃣Get Quote
      • 2️⃣Get Allowance
      • 3️⃣Build Approval Transaction
      • 4️⃣Build Swap Transaction
      • 5️⃣Get Cross-Chain Status
      • 🚰Get Pool Liquidity
      • 💲Get Fee Structure
      • ✔️Recommended Tokens
      • ✅Supported Blockchains
      • 📩Error Message
      • 📄Change Log
    • yBridge Contract Integration
      • Integrate YBridge Contract
        • Bridge Example
        • Latest Upgrade ( 2024/07/17 )
        • Migrate from V2 to V3
      • Integrate YBridgeVault Contract
        • Maximum Available Liquidity
        • Migrate from V2 to V3
      • (Legacy) Integrate X Swap Contract
        • (Legacy) Bridge Example
      • (Legacy) Integrate Y Pool Contract
        • (Legacy) Maximum Available Liquidity
    • xAsset Bridge
      • How to Develop Under XY Standards
        • Function Interface for Token Contract
      • How to Deposit / Withdraw Liquidity
        • Direct Contract Interaction
        • Through the Explorer
      • Set up Your Own Validator
  • SMART CONTRACT
    • Addresses
      • Ethereum (chain id : 1)
      • BNB Chain (chain id : 56)
      • Polygon (chain id : 137)
      • Cronos (chain id : 25)
      • Avalanche (chain id : 43144)
      • Kucoin Community Chain (chain id : 321)
      • Arbitrum (chain id : 42161)
      • Optimism (chain id : 10)
      • Astar (chain id : 592)
      • Kaia (chain id : 8217)
      • zkSync Era (chain id : 324)
      • Polygon zkEVM ( chainid : 1101)
      • Linea (chain id : 59144)
      • Base (chain id : 8453)
      • Mantle ( chain id : 5000)
      • Scroll (chain id : 534352 )
      • Blast (chain id : 81457)
      • X Layer (chain id : 196)
      • Taiko (chain id : 167000)
      • Cronos zkEVM (chain id : 388)
      • Abstract (chain id : 2741)
      • Berachain (chain id : 80094)
      • Numbers (chain id : 10507)
      • Treasury
      • (Suspended)Fantom
      • (Suspended)ThunderCore
      • (Suspended)Moonriver
    • Audit Reports
    • Privileged Roles Management
  • Document
    • Terms of Use
    • AML and CFT Compliance Statement
    • Integration Terms and Brand Guidelines
    • Product Update
  • FAQ
    • How to Speed up Pending Transactions
    • How to add a custom RPC to my wallet
  • Contact Us
    • Telegram
    • Medium
    • Twitter
    • Discord
Powered by GitBook
On this page
  • Overview of Changes
  • Parameter Naming Convention Changes
  • Bridge Fee Settings
  • Event Changes
  • Migration Steps
  • Update Parameter Names to Follow New Conventions
  • Monitor Swap Completion
  • Update Bridge Fee Retrieval Method

Was this helpful?

  1. Single Bridge Integration
  2. yBridge Contract Integration
  3. Integrate YBridge Contract

Migrate from V2 to V3

This document provides a detailed outline of the key changes between XSwapper (V2) and YBridge (V3) and guides you through the necessary steps to migrate your system

Overview of Changes

The update from v2 to v3 introduces a couple of significant changes that will affect the way you interact with the system. Most notably, there have been changes in the naming convention of certain prefixes, a shift in how bridge fee settings are retrieved, and alterations to the semantics of certain event parameters.

Parameter Naming Convention Changes

In YBridgeV3, the prefix convention has changed as follows:

  • From from- to src-: All instances where the prefix from- was used are now replaced with src-. This change affects all contract codes.

  • From to- to dst-: Similarly, to- has been replaced with dst-. As with src-, this applies to all contract codes.

Bridge Fee Settings

The method for obtaining bridge fee settings in the contract has been moved:

  • From Blockchain to API: In the previous version, the bridge fee settings could be retrieved directly from the blockchain. In YBridgeV3, however, these settings are no longer available on the blockchain and must be accessed via the API ( Get Fee Structure)since the fee setting is now managed by validators off-chain.

Event Changes

  • event SwapRequested

event SwapRequested(uint256 _swapId, address indexed _aggregatorAdaptor, DstChainDescription _dstChainDesc, IERC20 _srcToken, IERC20 indexed _vaultToken, uint256 _vaultTokenAmount, address _receiver, uint256 _srcTokenAmount, uint256 _expressFeeAmount, address indexed _referrer);

Previously there were _xyFee and _gasFee in the place of _srcTokenAmount and _expressFeeAmount. The removal is because the fee calculation is now handled by validators off-chain.

As for the new added _srcTokenAmount is to log the original amount of the source token (not the bridge token).

The _expressFeeAmount logs the amount of express fee paid by user.


Migration Steps

For developers who are interacting directly with the system's interfaces and events, the following updates are important to note:

Update Parameter Names to Follow New Conventions

While the interface for initiating a swap request remains unchanged, you're suggested to update the parameter names to reflect the new prefix conventions:

  • Search for any instances where -from- and -to- are used in the parameters of functions and events.

  • Replace from with src and to with dst to align with the new naming convention.

    Here is an example of how to update your swap request parameters:

    struct SwapDescription {
    -   IERC20 fromToken;
    -   IERC20 toToken;
        address receiver;
        uint256 amount;
        uint256 minReturnAmount;
    }
    
    struct SwapDescription {
    +   IERC20 srcToken;
    +   IERC20 dstToken;
        address receiver;
        uint256 amount;
        uint256 minReturnAmount;
    }
    
    
    function swapWithReferrer(
        address aggregatorAdaptor,
        IDexAggregatorAdaptor.SwapDescription memory swapDesc,
        bytes memory aggregatorData,
    -   ToChainDescription calldata toChainDesc,
        address referrer
    )
    
    function swapWithReferrer(
        address aggregatorAdaptor,
        IDexAggregatorAdaptor.SwapDescription memory swapDesc,
        bytes memory aggregatorData,
    +   DstChainDescription calldata dstChainDesc,
        address referrer
    )

Monitor Swap Completion

On the Source Chain

If you are currently monitoring a swap is successfully requested by listening to event SwapRequested, you should be careful that the bridge fee amount paid could no longer be retrieved in the event.

On the Destination Chain

If you are currently monitoring the completion of a swap request on the destination chain by polling function getEverClosed, no action is required. The method for checking whether a swap is closed remain the same in YBridgeV3:

If you are currently monitoring the completion of a swap request on the destination chain by listening to event CloseSwapCompleted or event SwappedForUser, you might need to update the parameter names as mentioned above.

Update Bridge Fee Retrieval Method

  • Identify any instances where bridge fee settings are being retrieved from the blockchain.

  • Replace these instances with the appropriate API calls to fetch the bridge fee settings.

    Example:

    - // Old method: Retrieve bridge fees from blockchain
    - const bridgeFees = getBridgeFeesFromBlockchain();
    + // New method: Retrieve bridge fees from API
    + const bridgeFees = getBridgeFeesFromAPI();
    
    // The detail of bridge fee API can be found here:
    // *****URL GOES HERE*****

PreviousLatest Upgrade ( 2024/07/17 )NextIntegrate YBridgeVault Contract

Last updated 11 months ago

Was this helpful?