135 subscribers
join
Rating
Login
Logout

How to bridge tokens to Aptos on Liquidswap with LayerZero

Tutorials

Table of Contents

Thanks to LayerZero, you can bridge USDC, USDT, ETH, and WETH from 6 different blockchains to Aptos. Here’s what you need to know about this omnichain communication protocol, using the LayerZero bridge, bridging fees.

LayerZero (LZ) is an interoperability protocol that can pass messages trustlessly and securely between any of the 30+ supported blockchains. In fancy words, it’s an omnichain blockchain primitive that enables direct native cross-chain transactions.

LayerZero isn’t an L1, or an L2, or even a bridge. Rather, it’s a blockchain primitive – a building block that can be integrated into products like cross-chain DEXs and yield protocols. Other examples of primitives include smart contracts, governance, staking, oracles, and NFTs.

“Trustless” is the key word: many bridges enable cross-chain transactions, but  you have to trust a network of bridge validators or a sidechain that places assets in custody on the departure chain as their wrapped versions are minted on the destination chain. This creates security risks and extra costs. LayerZero has a very different architecture, because it doesn’t require any middlemen, wrapped tokens, or asset custody.

“Omnichain” is also a key part of the definition. With LayerZero, you can send transactions between any two supported chains, no matter how different their consensus models or smart contract standards. For example, you can connect Aptos and Ethereum, or Avalanche and BNB.

How LayerZero works

For two chains to be connected using LayerZero, each of them needs to have an LZ Endpoint – an interface that includes several smart contracts. When a user initiates a cross-chain transaction through a dApp on chain A, the dApp sends information about the transaction to the LZ Endpoint – or rather, to its Communicator module.

The transaction gets a unique identifier, and the Communicator prepares a data packet and forwards it to another Endpoint module, Validator. The latter sends it to the third module, the Network, and gets in touch with the Oracle – an independent protocol that reads block headers on Chain A and sends them to the destination chain (Chain B). LayerZero uses Chainlink as its Oracle.

Now Chain B knows that the transaction was confirmed and added to a block on Chain A. This can take a bit of time, as different blockchains require different number of block confirmations. Meanwhile, another third party enters the process: the Relayer. Its job is to fetch the proof of the transaction on Chain A and store it off-chain.

Finally, the LayerZero Endpoint on Chain B receives the block header and transaction proof from the Oracle and the Relayer. Once the transaction info is verified, the Endpoint gets in touch with the  dApp on Chain B, telling it that it’s ok to do whatever the user wants it to do – issue tokens, for example.

Credit: LayerZero White Paper

However, if the Endpoint Validator on Chain B finds that the transaction proof doesn’t match the block header, the transaction won’t be executed.

You’ll find more info in the LayerZero White Paper.

LayerZero advantages

Trustless

The key element of this communication protocol is valid and trustless message delivery, guaranteed by the Oracle and the Relayer. The only condition is that these two entities are independent of each other, so that they can’t collude to make an invalid transaction look valid.

Omnichain

When LayerZero adds support for a new blockchain, a new Library smart contract is deployed. Every Endpoint has a full set of Libraries, so that it can handle transactions between any two supported networks.

Scalable

The messages transmitted via the Oracle and the Relayer are very lightweight, and the Endpoints themselves don’t have to store a lot of information or execute any gas-intensive transactions. As a result, the protocol can handle huge numbers of transactions without incurring high costs, even on chains with expensive gas like Ethereum.

Secure

LayerZero doesn’t store any assets the way bridges do, so you can’t orchestrate an attack like those that happened on Wormhole ($325M stolen) or Poly Network ($610M). The only way to send an invalid transaction would be if the Oracle and the Relayer were both malicious and colluded, but the architecture of LayerZero strictly requires for them to be independent.

Important: beware scammers

LayerZero does not have a token and has not announced any specific plans to release one. If you see any Telegram groups or Twitter accounts promoting an LZ token, they are scams.

Such groups use the same logo and style as the real LayerZero, and their admins pretend to be real LZ team members. The point is to fool users into connecting their wallet to a fraudulent site to steal their crypto assets, or trick them into buying a worthless fake token.

Our advice is that you join LayerZero's official Discord, Telegram group and Twitter and follow the announcements. Don’t trust any “LZ admin” who sends you a DM out of the blue!

Now that we’ve seen how this groundbreaking communication protocol works, it’s time to get hands-on and bridge some APT or USDT.

Tutorial: how to bridge with LayerZero

Four important points

1) Bridging from Aptos to other chains takes a minimum of 500,000 blocks to confirm

The number of block confirmations is a security measure introduced by LayerZero because Aptos is a new blockchain, and this restriction may be lifted in the future. Bridging can be completed in three days, but there’s no way to speed it up manually.

Even though the bridge displays a warning before a user confirms a transaction, we keep getting questions along the lines of “Why is it taking so long?” Now you know why – and if your transfer from Aptos doesn’t confirm after 500,000 blocks (normally around 2 days) , you can open a ticket in the LayerZero Discord.

2) The bridge on Liquidswap and on the LayerZero website are the same

Inaccurate article  about the non-existent  LayerZero airdrop keep repeating that you have to first bridge assets over the Aptos Bridge on the LayerZero website and then over the one on Liquidswap. These are the same thing! In reality, Liquidswap’s widget is the LayerZero bridge  -- the colors are different, but it’s the same bridge.

3) The bridge is run by LayerZero, not by Pontem Network

Once again: we’ve implemented a bridge widget by LayerZero on Liquidswap, but we don’t control the technology. For all issues with the bridge, please refer to the official LZ Telegram or Discord.

4) You can airdrop yourself APT for gas, but it’s not free

When you bridge USDT or other tokens from Ethereum or another chain to Aptos for the first time, you’ll need a little APT to register them in the wallet and claim them. Having to register a token before transacting with it is a standard requirement on Aptos, and it requires some gas. You’ll also need APT for your first swap on Liquidswap (e.g. USDT to APT).  So where do you get APT for gas if your wallet is completely empty?

LayerZero has a solution: it allows you to airdrop yourself a little bit of APT if you don’t have any yet. You’ll need to pay for this airdrop on the origin chain, and that constitutes a considerable chunk of the bridge fee. You can adjust the APT airdrop amount by clicking on Gas on Destination in the bridging window (read on).

Now for the instrcutions:

Step 1: Install Pontem Wallet and connect to the mainnet

Pontem’s Liquidswap Bridge works with four different wallets for Aptos: our own Pontem Wallet, Petra, Martian, and Fewcha. We will use Pontem Wallet throughout this tutorial: you can use it with almost all Aptos dApps and even connect it to Ledger.

You can download Pontem Wallet as a Chrome extension here. The wallet creation process is the same as for any other popular non-custodial wallet. Make sure to save the seed phrase in a safe location, as there is no way to recover it in the wallet later (though we plan to add this feature).

Step 2: Connect to Liquidswap Bridge

Go to the Liquidswap Bridge page and accept the Terms and Conditions, then click on Connect.

Choose MetaMask as source and Pontem as destination. As usual with dApps, each wallet will ask you to confirm the connection. This transaction doesn’t require any gas.

Step 4: Pick the chain to bridge from Liquidswap Bridge supports 7 assets (USDT, USDC, ETH, WETH, USDD, BTC.b, CAKE) on 7 different blockchains:

  • USDT: Aptos, Ethereum, BNB Chain, Avalanche, Polygon;
  • USDC: Aptos, Ethereum, Avalanche, Polygon, Arbitrum, Optimism;
  • ETH: Ethereum, Arbitrum, Optimism;
  • WETH: Aptos, Ethereum, Arbitrum, Optimism;
  • USDD: Aptos, Ethereum, BNB Chain;
  • BTC.b: Aptos, Ethereum, BNB Chain, Avalanche, Polygon, Arbitrum, Optimism;
  • CAKE: Aptos, BNB Chain.

Here, we won’t focus on how to install MetaMask, how to withdraw ETH and stablecoins from exchanges, or how to swap ETH and WETH for USDC or USDT on Uniswap or PancakeSwap, etc. You can easily find this information online. We will, however, give you a couple of tips.

Bridge fee check: How to estimate fees

For the same token, bridging fees can vary greatly from chain to chain. So start by picking the chain and currency, then look for an APT value next to Gas on Destination at the bottom.

Click on it, then check the values for None, Medium, and High. They correspond to different amounts of APT you can airdrop to yourself for gas.  In this example, you’ll find that the Medium fee is 0.00328 BNB, which will give you 0.007 APT at destination, while the maximum is 0.0463 BNB, which will give you 1 APT. In general, you’ll need around 0.003 APT to claim the bridged tokens, plus around 0.01 APT to swap them for APT, so the Gas on Destination value should be at least 0.02 to be on the safe side.

You can also enter a custom amount of APT you want to receive. Don’t try to toggle the Custom Amount switch.  Just enter an amount, and the switch will be toggled automatically.

‘Not enough native for gas’ error

Once you’ve checked how much you’ll need to pay in fees at the source, make sure that you have enough native coins (be it ETH, BNB, MATIC, AVAX etc.) to pay for gas. If you don’t, you’ll see this warning:

Liquidity and Liquidswap price check

Before bridging an asset, check the liquidity in the Liquidswap pools that feature that asset.

For example, if you have USDD on BNB Chain and you wish to buy APT, first check the APT price and if there are enough reserves in the USDD/APT and USDT/USDD pools on Liquidswap. If the reserves are low or the exchange rate is unfavorable compared to other pools, consider bridging another token, such as USDT.

Doesn’t make sense to bridge a token that has less than $5 in liquidity

Level up to complex schemes

For example, if you have BUSD tokens on BNB Chain, you can swap them for USDC on PancakeSwap first, then bridge them to Aptos.

If you are relatively new to DeFi, this can seem complicated. But with just a little practice, you’ll become a proficient bridger - or, as they say in crypto, ‘bridgooor’.

Step 5: Bridge!

In this example, we’ll bridge USDT from BNB Chain, so we’ll make sure that MetaMask is connected to this network and choose USDT BNB Chain in the top (Source) part of the widget. In the bottom (Target) part, USDT Aptos will be chosen automatically.

Next, enter the amount you want to transfer. If your MetaMask balance isn’t displayed correctly, refresh the page.

Click on Transfer. You’ll see a popup with a prompt to confirm the transaction, and MetaMask will open, asking you to set a spending cap for the token, if you haven’t done it at an earlier point. You can set it to Max, if the amount in the wallet isn’t too high and you’re willing to send it all.

Review the transaction, approve, and confirm the final gas fee estimate. In this example, the actual gas fee is just 0.001 BNB, while the fee for dropping yourself APT for gas is 0.009 BNB, for a total of 0.01 BNB (around $3), which is still good.

If everything goes well, you’ll see a reminder to claim the tokens. Users often ask us, “Where are the tokens that I bridged?” Well, the answer is usually that they simply forgot to claim them!

Step 6: Claim

As BNB Chain is relatively fast, you’ll soon see the Claim button above the bridging window. On Ethereum it will take longer.

If you check your Pontem Wallet at this point, you should see the APT gas airdrop, but no USDT yet.

Click on the Claim button and confirm in Pontem Wallet. The gas fee should be around 0.003 APT, or less than $0.1.

Bingo! USDT is now in your wallet.

What if it says ‘Failed’?

Occasionally the widget can display a transaction as ‘Failed’, especially when execution takes more than 10 minutes. Don’t panic: your tokens aren’t lost. Click on the small square icon on the left to go to LayerZero Scan: most probably it will say ‘Delivered’. Save the transaction hash and refresh the page - or just wait a little longer.

Congratulations! You’ve successfully bridged USDT and can now start swapping on Liquidswap. Of course, you can also test the bridge with some other token, blockchain, or wallet if you like.

Step 7: Connect to Liquidswap and swap

Go to https://liquidswap.com/#/  and connect Pontem Wallet to the DEX.

Next, in the Swap tab, pick LayerZero USDT in the top field and APT in the bottom field (if you are swapping USDT for APT). Note that LayerZero USDT, Wormhole USDT, and Celer USDT are three completely different contracts on Aptos.

Make sure that Unstable is selected, as the prices of these two assets are not correlated.

Enter the amount of USDT you want to swap to see how much you’ll get in APT. Before completing the swap, check that there’s enough liquidity in the pool to keep the price impact low (0.39% in this case, which is acceptable). We also recommend that you turn frontrunning protection on (the little red lock icon next to the settings gear).

You can also adjust the slippage in Settings (the gear icon). For the first time, it’s better to leave it at 0.50% to make sure that the transaction succeeds, as you may not have enough APT to pay for gas.

Double-check the values, hit the Swap button, then confirm the transaction in the swap popup, click on Send Transaction, and finally confirm it in Pontem Wallet. The $APT airdropped by LayerZero should be enough to cover the swap gas fee.

If you get a ‘Simulation failed: out of gas’ warning, try clicking on Gas Fee and click on Set Optimal Gas. If you don’t have enough APT to pay that amount, you risk that the swap will fail. You can also wait for a bit: the optimal amount of gas for a swap varies according to network load.

That’s it: you’ve just purchased APT, the official coin of the Aptos blockchain! You should see it in the wallet balance.

Note: if you decide to buy some other token, like USDC, Liquidswap will first ask you to register it in the wallet. This transaction is subject to a small gas fee.

Bridging back from Aptos to EVM blockchains

The LayerZero bridge works both ways, so you can also send USDC, USDT, etc. from Aptos to Ethereum, BNB Chain, and so on. However, be very attentive to gas fees, as they can be surprisingly high when the network load is high. Click the Gas at Destination value at the bottom right of the widget and play with the settings (None - Medium - High) to get an idea of how much you’ll have to pay.

To send USDT back from Aptos to BNB Chain, set the origin and destination chains. If you have enough BNB in MetaMask, you can set Gas on Destination to None to minimize the bridging fee.

Note the gas fee (0.017 APT). Also, keep in mind that the standard transfer time is 3-4 days, so if you see an estimated processing time of 4000+ minutes, don’t be surprised. After this time elapses, you’ll be able to claim your funds. There is no way to speed up the process, because the 4-day transfer window was added for security reasons.

Once you confirm, a countdown timer will appear at the top of the widget. Click on Aptos -> BNB Chain to view transaction status on LayerZero Scan, though information may not be available immediately.

Important! Always copy and save the bridge transaction hash (the one after Message Details) so that you can look it up on LayerZero Scan later if something goes wrong.

For all questions and troubleshooting that have to do with the bridge, please message in LayerZero’s official Discord or Telegram group. We also recommend that you review the official Aptos Bridge FAQ. If you encounter issues with Pontem Wallet or Liquidswap, get in touch with us in the Tech Support chat.

Pontem has many new features in the pipeline for Liquidswap and Pontem Wallet, so follow us on Telegram, Twitter, and Discord for the latest updates!

About Pontem

Pontem Network is a product studio building foundational dApps for Aptos. Our products  include Pontem Wallet; Liquidswap, the first DEX (AMM) for Aptos; browser code editor Move Playground; the Move IntelliJ IDE plugin for developers; and the Solidity to Move translator ByteBabel -- the first implementation of the Ethereum Virtual Machine for Aptos.

Install our wallet and try DEX

Related posts

how-to-bridge-tokens-to-aptos-buy-apt-on-liquidswap
63569fa5139df1a79b547e0c
amb-how-to-bridge-tokens-to-aptos-buy-apt-on-liquidswap