BRIDGE function spotlight

This document explains the syntax and various usage patterns of Vektor's powerful  BRIDGE function. For a shorter summary with examples you could read our launch announcement here.

🧠
If you haven’t used VXL before, try our Quick Start Guide! You may also find it useful to first learn about VXL basics and Common Syntax Patterns, or book a call using the CALL function in the app to learn more.

Summary

Vektor's BRIDGE function allows you to seamlessly bridge assets from one blockchain to another.

Vektor's BRIDGE function aggregates a large number of different bridge protocols, so straight out of the gate users can enjoy the cheapest and/or fastest bridge routes available.  In addition to actually executing the bridge transaction, you can query different routes to simulate the transaction, watch quotes update in real-time, even  build alerts around cross-chain bridging conditions, all with the same powerful composability offered by VXL.

⚠️
Note: to work with Vektor functions, assets need to be listed in Vektor's asset registry. You can see this using the ASSETS.GET function. We plan to give users the ability to register their own assets, but for now you need to let us know if there is something missing that you need - we can add it quickly. 

Function Specification

You can use BRIDGE (without subfunctions) to execute a bridge transaction, or QUOTE / QUOTES subfunctions to get a read-only simulation of your intended bridge before you execute it.

Function Description
BRIDGE.QUOTES(...) Get a list of quotes for bridging an exact amount of an asset to another blockchain
BRIDGE.QUOTE(...) Get a quote for bridging an exact amount of an asset to another blockchain
BRIDGE(...) Bridge an exact amount of an asset to another blockchain

BRIDGE.QUOTES(...) Syntax and Examples

Use BRIDGE.QUOTES to output a table showing a list of quotes for the same bridging operation. Each row in the table represents a single route on a single venue, for the send and receive chains you specify. In aggregate, the BRIDGE.QUOTES table displays all the different options available for your specific bridge operation.

⚠️
Note: The Function Helper box pictured above should be useful in helping guide you through the syntax of Vektor functions. It appears automatically when you open the parentheses of a function.

BRIDGE.QUOTES(...) Examples

Get a table of quotes for bridging 10,000 USDC from Ethereum to Polygon (with sample output).

Description of data points:

  • SEND_AMOUNT : The amount of asset you specified to bridge
  • SEND_ASSET.SYMBOL : The symbol/ticker of the asset you specified to bridge
  • SEND_ASSET.BLOCKCHAIN.NAME : The blockchain that you are quoting to bridge from
  • RECEIVE_AMOUNT : The amount of asset that you can expect to receive
  • RECEIVE_ASSET.SYMBOL : The symbol/ticker of the asset you will receive
  • RECEIVE_ASSET.BLOCKCHAIN.NAME : The blockchain that you are quoting to bridge to
  • RECEIVE_TIME_EST : The estimated amount of time (in minutes) that the bridge will take
  • VENUE.SYMBOL : The venue/aggregator that is providing the quote
  • ROUTE : The specific route that will be used by the venue/aggregator
⚠️
Note: You can easily configure which data point columns are shown/hidden using the ⚙️ control at the top right of the pane.

Get a table of quotes for bridging 100 ETH from Optimism to Arbitrum (with sample output).

Lists are sorted by highest RECEIVE_AMOUNT first by default. Use the SORT function to sort by other columns (e.g. minimum RECEIVE_TIME first).

Get a table of quotes for bridging 100,000 USDT from Polygon to Ethereum and sort it by fastest first.

Isolate the 'fastest' bridge quote from the above, by picking the top quote from the list.

Set an alert to notify me when the best quote (by RECEIVE_AMOUNT) comes from the "Hop" route. (e.g. because it's incentivised and I'm happy to wait, but only if I get the best rate).

⚠️
Read more about Vektor's powerful ALERTs function here.

BRIDGE.QUOTE(...) Syntax and Examples

BRIDGE.QUOTE is very similar to BRIDGE.QUOTES except that it outputs a single 'best' quote found across all routes (judged by RECEIVE_AMOUNT), instead of a table of quotes for all the supported routes.

BRIDGE.QUOTE(...) Examples

Get the best quote for bridging 10,000 USDC from Ethereum to Polygon (with sample output).

Get the best quote for bridging 100 ETH from Optimism to Arbitrum (with sample output)

Get the receive amount from the above quote (e.g. for use in formulas)

⚠️
Read more about Vektor's data model here.

BRIDGE(...) Syntax and Example

If you use BRIDGE and omit the subfunction suffixes .QUOTES and .QUOTE you get the default behaviour of the BRIDGE function, which is to actually prepare and execute a bridge transaction.

The key differences between BRIDGE and BRIDGE.QUOTE[S] are:

  1. It is necessary to provide a SEND_LABEL (a labelled blockchain address that you've registered in Vektor) explicitly.
  2. Instead of just a read-only output in the workspace, the BRIDGE function will prepare an on-chain transaction that you will need to sign when presented with a Signing Request.

By default, the BRIDGE function will run a quote process in the background and pick the best venue+route automatically, but there is also an alternative usage of the BRIDGE function where you can pass in a specific QUOTE that you want to build the transaction on, which specifies a venue+route. This is VXL composability in action - you can see some examples below.

BRIDGE(...) Examples

Bridge 10,000 USDC from Arbitrum to Polygon, using the labelled address STABLES (with sample Signing Request).

⚠️
Note: You may be prompted to approve a token first before it can be used in a bridge transaction.

After signing, you can watch the transaction take effect using functions like BALANCES which will update the cross-chain move in real-time, or TRANSACTIONS which will show you the status of on-chain transactions.

Bridge 100 ETH from Optimism to Arbitrum, using the labelled address MY_WALLET2.

Bridge 1.5 WBTC from Arbitrum to Avalanche, using the labelled address MY_WALLET.

Bridge 1.5 WBTC from Arbitrum to Avalanche, using the labelled address MY_WALLET and overriding the destination address to MY_WALLET2.

Set an Alert for when bridged assets arrive on the destination blockchain.

Passing a QUOTE to BRIDGE

BRIDGE has an alternative usage where you can pass in a Bridge Quote to act on a specific quote, instead of leaving the BRIDGE function to automatically pick the quote with the highest receive amount.

One example is you may wish to priorize speed over receive amount. In this case you can use BRIDGE.QUOTES to compare the options, SORT and LIST.FIRST to pick a specific quote, and BRIDGE to build and sign the transaction:

Step 1: Compare the options with BRIDGE.QUOTES

Step 2: Sort the options with SORT

Step 3: Pick the first option with LIST.FIRST

Step 4: Pass this quote object to the BRIDGE function

Questions?

Email: [email protected]
Zoom: Use CALL function in Vektor