LEND and BORROW function spotlight

This document explains the syntax and usage of two of Vektor’s core execution functions: LEND() and BORROW(). 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 LEND and BORROW functions facilitate lending and/or borrowing of assets on multiple chains and venues supported by Vektor.

  • Use the LEND function to supply assets to a lending venue.
  • Use the BORROW function to borrow assets from a lending venue.

The LEND and BORROW functions also have various powerful sub-functions that can be used to access current market information or monitor existing positions. This is covered in more detail below.

⚠️
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 Specifications

You can use the .MARKET and .MARKETS sub-functions to see current lend and borrow rates available in the market, or use LEND and BORROW (without sub-functions) to execute actual lend and borrow transactions on-chain. Then retrieve and monitor information about your different lend and borrow positions using the .POSITION and/or .POSITIONS sub-functions, or check aggregated account-level information like health factors using .ACCOUNT and/or .ACCOUNTS subfunctions.

Function Description
LEND.MARKETS(...) Get the current market rates for lending an asset
LEND.MARKET(...) Get the current market rate for lending an asset on a venue on a blockchain
LEND(...) Supply an asset to a lending venue
LEND.WITHDRAW(...) Withdraw an asset from a lending venue
LEND.POSITIONS(...) Get info on supplied lending positions
LEND.POSITION(...) Get info on a specific supplied lending position
BORROW.MARKETS(...) Get the current market rates for borrowing an asset
BORROW.MARKET(...) Get the current market rate for borrowing an asset on a venue on a blockchain
BORROW(...) Borrow an asset from a lending venue
BORROW.REPAY(...) Repay an asset to a lending venue
BORROW.POSITIONS(...) Get info on borrowed positions
BORROW.POSITION(...) Get info on a specific borrowed position
BORROW.ACCOUNTS(...) Get account-level borrow info on multiple labels
BORROW.ACCOUNT(...) Get account-level borrow info on a specific label

LEND.MARKETS(...) Syntax and Examples

LEND.MARKETS is a powerful way to get an overview of the different lending conditions on multiple different assets, venues, and blockchains all in one view, with live updates.

CleanShot 2022-08-29 at 15.43.11.png
⚠️
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.

LEND.MARKETS(...) Examples

Get the current lending rates of all assets, venues, and chains supported by Vektor (with sample output).

Get a table of lending rates for a single asset (ETH) across all venues and chains supported by Vektor (with sample output).

Get a table of lending rates for a selection of stable coins (USDC, USDT, DAI) across all venues and chains supported by Vektor.

Get a table of lending rates for all assets and venues on a specific chain.

Get a table of lending rates for a selection of assets, on all venues and chains except Polygon.

Get a table of lending rates for a selection of assets, on all chains, on a specific venue (Aave v2).

⚠️
Note: The INCLUDE_ASSETS , EXCLUDE_ASSETS , INCLUDE_BLOCKCHAINS , EXCLUDE_BLOCKCHAINS , INCLUDE_VENUES and EXCLUDE_VENUES are optional arguments, so they must be represent by key=value (Python style). In these instances the value can be a list of assets, so use array notation [venue1,venue2,venue3].

Get three separate tables at the same time, one each for three specific assets, across all venues and chains.

⚠️
Note: Press Shift+Enter to start a new line in the same command statement, or use the semicolon ;separator. Everything will be executed like a script, probably resulting in several view panes showing the output of each part.

LEND.MARKET(...) Syntax and Examples

LEND.MARKET is very similar to LEND.MARKETS except that it outputs information about a particular lending market, as specified by an asset, venue, and blockchain that you provide. Unlike LEND.MARKETS, LEND.MARKET has required arguments instead of options.

LEND.MARKET(...) Examples

Get the current market rate for lending WETH on the Aave v3 venue on the Polygon blockchain (with sample output).

Get two current market rates, one for lending WETH on Aave v3 on Polygon, and another for lending DAI on Aave v2 on Ethereum (with sample output).

⚠️
Note: If the market that you specify with an asset, venue, and blockchain combination does not exist, Vektor will return an error.

LEND(...) Syntax and Examples

If you omit any sub-function suffix, you can use LEND to actually prepare and execute an on-chain lend transaction. A lend transaction supplies your assets to a lending venue, typically in order to generate a return.

The key differences between LEND and LEND.MARKET[S] above are:

  1. Instead of providing INCLUDE_BLOCKCHAINS or EXCLUDE_BLOCKCHAINS as optional parameters, it is necessary to provide a LABEL (a human-readable label for a blockchain address that you've registered in Vektor) and a BLOCKCHAIN explicitly. Since LABELS are natively 'multi-chain' or 'chain-agnostic', this additional information is needed by Vektor to build the transaction.
  2. Instead of just a read-only output in the workspace, the LEND function will prepare an on-chain transaction that you will need to sign when presented with a Signing Request.

LEND(…) Examples

Lend exactly 1000 MATIC to the Aave v3 venue on Polygon, using funds available at MY_ADDRESS(with sample Signing Request).

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

Lend exactly 1 WBTC to the Aave v2 venue on Ethereum, using funds available at MY_ADDRESS.

Lend half of the total balance of WETH held in the label MY_ADDRESS on Avalanche, to the Aave v3 venue on Avalanche.


LEND.WITHDRAW(…) Syntax and Examples

The LEND.WITHDRAW function performs the reverse of LEND; removing some or all of your assets from lending venues. The requirement is that you already have some supplied assets associated with your address.

⚠️
When you supply a native asset like ETH (on Ethereum) or MATIC (on Polygon) to a lending venue, it will automatically get converted to a wrapped version of the asset (in this case WETH and WMATIC respectively) which is the form needed to interact with the lending venue smart contracts. Wrapped assets are worth the same as their unwrapped equivalents. When you withdraw, depending on whether you use the unwrapped or wrapped asset symbol, you can automatically unwrap the asset again or leave it in its wrapped form. Or you can manually wrap/unwrap native assets later using the dedicated WRAP and WRAP.UNWRAP functions.

LEND.WITHDRAW(…) Examples

Withdraw 1000 MATIC on the Aave v2 venue on Polygon, from the position associated with the labelled address MY_ADDRESS.

Withdraw 20 ETH on the Aave v3 venue on Avalanche, from the position associated with the labelled address MY_ADDRESS.


LEND.POSITIONS(…) Syntax and Examples

After you have supplied assets to one or more lending venues, you can use LEND.POSITIONS to keep track of all these lending positions, including supplied amounts, APYs, venues, blockchains, and associated labelled addresses.

The difference between LEND.POSITIONS and LEND.POSITION (featured next) is that LEND.POSTIONS returns a list of all the existing positions in a tabulated format, while LEND.POSITION returns a summary of a single position. LEND.POSITIONS is more powerful in that it can read multiple blockchains in one operation. Both are read-only functions.

LEND.POSITIONS(…) Examples

Get the current supplied lending positions of all assets, venues, and chains supported by Vektor, searching all labelled addresses (with sample output).

Get the current supplied lending positions, filtering on just the labelled address TEST_ADDRESS_1 and on just the Polygon blockchain.

Get the current supplied lending positions, filtering on just stable coins (USDC, USDT, DAI) and on just the Aave v2 venue.

Get the current supplied lending positions of all assets excluding stable coins (DAI, USDC, USDT), and for all blockchains excluding Arbitrum.

Get three separate tables at the same time, one each for three specific blockchains, showing for each blockchain the supplied lending positions across all assets and venues and labelled addresses.


LEND.POSITION(…) Syntax and Examples

LEND.POSITION is very similar to LEND.POSITIONS except that it outputs information about a particular lending position, as specified by an asset, venue, blockchain, and labelled address that you provide. Unlike LEND.POSITIONS, LEND.POSITION has required arguments instead of options.

LEND.POSITION(…) Examples

Get information on the current lending position for WBTC on the Aave v3 venue on the Arbitrum blockchain, on the labelled address ADDRESS_2 (with sample output).

⚠️
Note: If the position that you specify with an asset, venue, blockchain, and label combination does not exist, Vektor will return an error.

Get the current supply APY for the above position is greater than 1% (with sample output)

BORROW.MARKETS(…) Syntax and Examples

BORROW.MARKETS is a powerful way to get an overview of the different borrowing conditions on multiple different assets, venues, and blockchains all in one view, with live updates.

⚠️
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.

BORROW.MARKETS(...) Examples

Get the current borrowing rates of all assets, venues, and chains supported by Vektor (with sample output).

Get a table of borrowing rates for a single asset (ETH) across all venues and chains supported by Vektor (with sample output).

Get a table of borrowing rates for a selection of stable coins (USDC, USDT, DAI) across all venues and chains supported by Vektor.

Get a table of borrowing rates for all assets and venues on a specific chain.

Get a table of borrowing rates for a selection of assets, on all venues and chains except Polygon.

⚠️
Note: The INCLUDE_ASSETS , EXCLUDE_ASSETS , INCLUDE_BLOCKCHAINS , EXCLUDE_BLOCKCHAINS , INCLUDE_VENUES and EXCLUDE_VENUES are optional arguments, so they must be represent by key=value (Python style). In these instances the value can be a list of assets, so use array notation [venue1,venue2,venue3].

Get a table of borrowing rates for all assets and chains, on a specific venue (Aave v2)


BORROW.MARKET(…) Syntax and Examples

BORROW.MARKET is very similar to BORROW.MARKETS except that it outputs information about a particular borrowing market, as specified by an asset, venue, and blockchain that you provide. Unlike BORROW.MARKETS, BORROW.MARKET has required arguments instead of options.

BORROW.MARKET(...) Examples

Get the current market rate for borrowing ETH from the Aave v3 venue on the Polygon blockchain (with sample output).

Get two current market rates, one for borrowing ETH from Aave v3 on Polygon, and another for borrowing DAI from Aave v2 on Ethereum (with sample output).

⚠️
Note: If the market that you specify with an asset, venue, and blockchain combination does not exist, Vektor will return an error.

BORROW(…) Syntax and Examples

If you omit any subfunction suffix, you can use BORROW to actually prepare and execute an on-chain borrow transaction. A borrow transaction acquires assets from a borrowing/lending venue, typically in order to use those borrowed assets for other things. Depending on the venue, restrictions apply around collateral amounts you need to pledge in order to borrow.

The key differences between BORROW and BORROW.MARKET[S] above are:

  1. Instead of providing INCLUDE_BLOCKCHAINS or EXCLUDE_BLOCKCHAINS as optional parameters, it is necessary to provide a LABEL (a human-readable label for a blockchain address that you've registered in Vektor) and a BLOCKCHAIN explicitly. Since LABELS are natively 'multi-chain' or 'chain-agnostic', this additional information is needed by Vektor to build the transaction.
  2. Instead of just a read-only output in the workspace, the BORROW function will prepare an on-chain transaction that you will need to sign when presented with a Signing Request.

BORROW(...) Examples

Borrow exactly 1000 USDC from the Aave v2 venue on Polygon, using MY_ADDRESS (with sample Signing Request).

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

Borrow exactly 1 WBTC from the Aave v3 venue on Optimism, using MY_ADDRESS.


BORROW.REPAY(…) Syntax and Examples

The BORROW.REPAY function performs the reverse of BORROW; repaying some or all of your assets to borrowing/lending venues.

BORROW.REPAY(...) Examples

Repay 0.5 WBTC on the Aave v2 venue on Polygon, to the position associated with the labelled address MY_ADDRESS.

Repay 20 ETH on the Radiant venue on Arbitrum, to the position associated with the labelled address MY_ADDRESS.


BORROW.POSITIONS(…) Syntax and Examples

After you have borrowed assets from one or more borrowing/lending venues, you can use BORROW.POSITIONS to keep track of all these borrowed positions, including borrowed amounts, APYs, venues, blockchains, and associated labelled addresses.

The difference between BORROW.POSITIONS and BORROW.POSITION (featured next) is that BORROW.POSITIONS returns a list of all the existing positions in a tabulated format, while BORROW.POSITION returns a summary of a single positions. BORROW.POSITIONS is more powerful in that it can read multiple blockchains in one operation. Both are read-only functions.

BORROW.POSITIONS(...) Examples

Get the current borrowed positions of all assets, venues, and chains supported by Vektor, searching all labelled addresses (with sample output).

⚠️
Note: Some important metrics related to borrowing (e.g. total collateral, health factor) are excluded from BORROW.POSITIONS because these are aggregated metrics that are non-meaningful on a specific position-by-position basis; instead these are evaluated using the BORROW.ACCOUNT[S] functions covered further below.

Get the current borrowed positions, filtering on just the labelled address MY_ADDRESS and on just the Ethereum blockchain.

Get the current borrowed positions, filtering on just stable coins (USDC, USDT, DAI) and on just the Aave v2 and Aave v3 venues.

Get three separate tables at the same time, one each for three specific blockchains, showing for each blockchain the current borrowed positions across all assets and venues and labelled addresses.


BORROW.POSITION(…) Syntax and Examples

BORROW.POSITION is very similar to BORROW.POSITIONS except that it outputs information about a particular borrow position, as specified by an asset, venue, blockchain, and labelled address that you provide. Unlike BORROW.POSITIONS, BORROW.POSITION has required arguments instead of options.

BORROW.POSITION(...) Examples

Get information on the current borrowed position for USDT on the Aave v3 venue on the Avalanche blockchain, on the labelled ADDRESS_2 (with sample output).

⚠️
Note: if the position that you specific with an asset, venue, blockchain, and venue combination does not exist, Vektor will return an error.

Tell me if the current borrow APY for the above position is greater than 4%.


BORROW.ACCOUNTS(...) Syntax and Examples

Many venues supported by Vektor for lending and borrowing work on the principle of an over-collateralization requirement. That is, total assets deposited/lent to the venue must exceed total assets borrowed by some safety factor. Most venues will consider the aggregated notional value of supplied and borrowed assets for imposing these safety checks and restrictions, which may exist across several positions for the same account/labelled address. Therefore, position-level functions like BORROW.POSITIONS and BORROW.POSITION are unable to support these particular aggregated data points such as Total Collateral, Total Debt, or Health Factor, because they only have meaning at the account-level.

BORROW.ACCOUNTS and BORROW.ACCOUNT can be used to retrieve these data points.

BORROW.ACCOUNTS(...) Examples

Get the account-level borrow info across all venues and chains supported by Vektor, searching all labelled addresses (with sample output).

COLUMN DESCRIPTION
VENUE The on-chain lend/borrow venue name
BLOCKCHAIN The blockchain where the one or more borrow positions exist
LABEL The labelled address being considered as the single 'account' for aggregating the data
HEALTH_FACTOR The ratio between the total amount borrowed, and the discounted value of the collateral associated with that label
TOTAL_COLLATERAL The total value of all collateral assets supplied by that label
TOTAL_DEBT The total value of all assets borrowed by that label
AVAILABLE_BORROW The value that can be currently borrowed by that label according to collateral requirements
QUOTE_ASSET The display unit for Total Collateral, Total Debt, and Available Borrow (default USDC)

Same as above, but override the default quote asset by setting it to ETH.

⚠️
Note: the data points / columns affected by QUOTE include TOTAL_COLLATERAL, TOTAL_DEBT, and AVAILABLE_BORROW . It does not affect HEALTH_FACTOR.

Get the account-level borrow info filtering on just the Ethereum blockchain and just the labelled address MY_ADDRESS.

Get the account-level borrow info filtering on just Aave v3, and excluding the Polygon blockchain.


BORROW.ACCOUNT(...) Syntax and Examples

BORROW.ACCOUNT is very similar to BORROW.ACCOUNTS except that it outputs information about a particular account, as specified by a venue, blockchain, and labelled address that you provide. Unlike BORROW.ACCOUNTS, BORROW.ACCOUNT has required arguments instead of options.

Get specific account-level borrow information associated with the Aave v3 venue, on the Arbitrum blockchain, and the labelled address ADDRESS_2 (with sample output).

Same as above, but showing overriding the default quote asset by setting it to EUROC. (a Euro-denominated stablecoin) - with sample output.

⚠️
Note: the data points / columns affected by QUOTE include TOTAL_COLLATERAL, TOTAL_DEBT, and AVAILABLE_BORROW . It does not affect HEALTH_FACTOR.

Tell me if my health factor for this position falls below 2 with an on-screen warning (with sample output)

The above in text for better readability:
IF(GET(BORROW.ACCOUNT(AAVE_V3, ARBITRUM, DEMO), "HEALTH_FACTOR") < 2, "WARNING LOW HEALTH FACTOR!", "HEALTH FACTOR OK.. 👍")

⚠️
Reminder: Any indicators like the one shown above will also update every few seconds, as denoted by the LIVE button in the top left.

Questions?

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