Documentation
Plugins

LiFi

BuildBear LiFi is a bridge & DEX aggregation protocol that provides the best cross-chain swap across all liquidity pools and bridges.

Overview

LI.FI is a bridge & DEX aggregation protocol that simplifies cross-chain swaps and bridging by aggregating liquidity from multiple sources. The LI.FI plugin on BuildBear provides developers with a controlled environment to test multi-chain transactions without interacting with the mainnet.

By integrating this plugin, developers can validate LI.FI’s functionalities, debug transactions, and simulate real-world scenarios before deploying. The plugin grants access to all DEXs, DEX aggregators, and relevant bridges across supported networks, allowing seamless swaps, bridging, or a combination of both in a single transaction.

Features

  • Cross-Chain Testing: Enables developers to test multi-chain interactions without using real assets.
  • Seamless Integration: Works effortlessly within BuildBear’s sandbox environment.
  • Support for LI.FI SDK: Facilitates simulation & testing of bridging and swapping transactions.
  • Comprehensive Testing Logs: Provides detailed transaction logs, debug information, and validation reports.
  • Sandboxed Liquidity Access: Allows controlled liquidity aggregation testing without real asset exposure.

Supported API Routes

BuildBear supports a variety of API routes powered by LI.FI. Explore the full list here

How to Use

Step 1: Install the Plugin

  1. Log in to your BuildBear account and navigate to the Plugin Marketplace.
  2. Search for the "LiFi" Plugin and click "Install".

Plugin Installation

Step 2: Verify Installation

Ensure the plugin appears as installed in the marketplace or under the 'Installed' tab.

Step 3: Get Sandbox ID & RPC URL

Go to your BuildBear sandbox dashboard and locate the RPC URL:

https://rpc.buildbear.io/{sandbox-id}

The sandbox ID also acts as the API endpoint for the LI.FI plugin:

https://api.buildbear.io/{from-sandbox-id}/plugin/lifi/{to-sandbox-id}

You will need two sandboxes, one for the source chain and one for the destination chain.

Step 4: Get Bridge Quotes from LI.FI

To retrieve bridging/swapping quotes, use the following API URLs:

const API_URL = "https://api.buildbear.io/{from-sandbox-id}/plugin/lifi/{to-sandbox-id}"
const RPC_URL = "https://rpc.buildbear.io/{from-sandbox-id}";

Query the /quote endpoint to get quotes for desired token swaps or bridges:

const getQuote = async (
  fromChain,
  toChain,
  fromToken,
  toToken,
  fromAmount,
  fromAddress
) => {
  const result = await axios.get(`${API_URL}/quote`, {
    params: {
      fromChain,
      toChain,
      fromToken,
      toToken,
      fromAmount,
      fromAddress,
    },
  });
  console.log("============= LiFi Quote =============");
  console.log(result.data);
  console.log("====================================");
  return result.data;
};

Step 5: Execute the Transaction

Use the transaction request object from getQuote response to send a bridging transaction:

const sendTransaction = async (transactionRequest, isApproval = false) => {
  const payload = {
    from: transactionRequest.from,
    to: transactionRequest.to,
    input: transactionRequest.data,
  };
  const response = await axios.post(RPC_URL, payload);
  return response.data;
};

Example Transaction Payload

{
  "from": "0x37305B1cD40574E4C5Ce33f8e8306Be057fD7341",
  "to": "0x1231DEB6f5749EF6cE6943a275A1D3E7486F4EaE",
  "input": "0xae3285900000000000000000000000000000000000000000000000000000000000000040"
}

Conclusion

Integrating the LI.FI plugin into BuildBear’s sandbox provides developers with a structured environment to test multi-chain transactions, including bridging and swapping, without real asset exposure. With enhanced debugging capabilities and seamless integration, developers can efficiently validate their implementations before mainnet deployment.