Skip to main content

Overview

Starkzap supports lending and borrowing through Vesu. Users can supply assets (deposit), borrow against collateral, repay debt, and withdraw supplied assets. What users can do with lending:
  • 💰 Supply assets - Deposit tokens into lending pools and earn interest (supply APY)
  • 💳 Borrow - Use supplied collateral to borrow other assets
  • 💵 Repay - Pay down debt; optionally withdraw collateral in the same flow
  • 📤 Withdraw - Withdraw supplied tokens (or max withdraw in one call)
  • 📊 Monitor positions - Query position size, debt, and collateralization health
The default lending provider is Vesu. It is registered automatically when the wallet is created. You can register additional providers or set a different default via wallet.lending().registerProvider() and setDefaultProvider().

Configuration

No extra configuration is required for Vesu on mainnet or Sepolia. The wallet’s lending() client uses the connected chain:
Optional: register another provider or set default:

Discovering markets

Fetch available lending markets for the wallet’s chain:

LendingMarket shape

Use these markets (and their poolAddress / asset / vTokenAddress) when calling deposit, withdraw, borrow, and repay with the same token/pool.

Depositing

Supply tokens into a lending pool. The provider includes the approval call when building the transaction.
With execution options (e.g. sponsored fees):

Withdrawing

Withdraw a specific amount of supplied tokens:
Withdraw the maximum allowed (e.g. full supplied balance) in one call:
Max withdraw may not be supported by all providers. Vesu supports withdrawMax. Check provider.prepareWithdrawMax or catch the error if you need to support multiple providers.

Borrowing

Borrow against collateral. You specify the collateral pair (collateral token + debt token) and the amount to borrow (or collateral amount, depending on denomination).
Optional: pass poolAddress if you have a specific pool, or provider: "vesu" to force the provider. user defaults to the wallet address.

Repaying

Repay borrowed debt. You can optionally withdraw collateral in the same action (provider-dependent).

Position and health

Get position

Retrieve the user’s lending position for a collateral/debt pair:

LendingPosition shape

Get health

Check if the position is collateralized (above liquidation threshold):

Quote projected health

Simulate an action (e.g. borrow or repay) and get the projected health after the action, plus the prepared calls and fee simulation:
Use this to show users how a borrow or repay would affect their collateralization before they confirm.

Using the transaction builder

Batch lending actions with transfers, staking, or other operations using the tx builder. Methods are prefixed with lend:
  • .lendDeposit(request) — add a deposit
  • .lendWithdraw(request) — add a withdraw
  • .lendWithdrawMax(request) — add a max withdraw
  • .lendBorrow(request) — add a borrow
  • .lendRepay(request) — add a repay
Example: deposit and then transfer in one tx
Example: repay and withdraw collateral
See Tx Builder for the full list of builder methods.

Best practices

  1. Check health before and after borrow/repay so users understand liquidation risk.
  2. Use quoteHealth() to show projected health after an action before the user confirms.
  3. Discover markets once (e.g. on load) and cache getMarkets() if you list markets in the UI.
  4. Use token presets for token, collateralToken, and debtToken so addresses match the chain.

Troubleshooting

”Lending provider returned no calls”

The provider could not build calls for the given request (e.g. wrong pool, unsupported pair, or invalid amount). Verify the market exists for the current chain and that you are passing the correct tokens and pool.

Provider does not support chain

Vesu supports SN_MAIN and SN_SEPOLIA. Ensure the wallet is on one of these chains. If you use a custom provider, ensure it supports the wallet’s chain.

”No default lending provider configured”

The default is set when the wallet is created (Vesu). If you replaced it, call setDefaultProvider("vesu") or pass provider: "vesu" in each request.

Next steps