Skip to content
Docs
Open app
Skip to Content

Deposit

Create a deposit request in a Volo vault and handle the SDK's pre-checks.

  • @naviprotocol/vault 0.1.0
  • @mysten/sui 2.39.1npm 3.0.1
  • TypeScript
  • Sui mainnet

A Volo deposit is a request. The coin moves into the vault when the user signs, and shares are issued at the share price when the operator settles the request.

deposit.ts
import { Transaction } from '@mysten/sui/transactions';
import { depositPTB, getVault, isVaultSdkError, type Vault } from '@naviprotocol/vault';

export async function buildDeposit(vaultId: string, owner: string, amount: string) {
  const vault: Vault = await getVault(vaultId);
  if (vault.source !== 'volo') throw new Error('Not a Volo vault');

  const tx = new Transaction();
  tx.setSender(owner);
  try {
    // amount is a decimal string in the deposit coin, for example '25.5'
    const { requestId } = await depositPTB(tx, vault, owner, amount);
    return { tx, requestId };
  } catch (error) {
    if (isVaultSdkError(error) && error.code === 'DEPOSIT_BELOW_MINIMUM') {
      throw new Error(`Deposit at least ${vault.minInvestment} ${vault.assets.baseCoin.symbol}`);
    }
    throw error;
  }
}

What depositPTB does

  1. Checks the vault is open (VAULT_NOT_OPEN), the amount is at least minInvestment (DEPOSIT_BELOW_MINIMUM) and within the remaining capacity (DEPOSIT_CAP_EXCEEDED). No transaction is built if a check fails.
  2. Selects and merges the owner’s coins of the deposit type.
  3. Adds the deposit request and transfers the receipt, and any change coin, back to the owner.
  4. Returns { receipt, requestId, charge } as transaction handles.

Compose a deposit

NeedOption
Deposit a coin produced earlier in the PTBPass the coin as amount together with { coin }; the amount is then raw base units.
Route the receipt yourselfPass { disableAutoTransfer: true } and transfer or use receipt and the change coin charge.
Pay from the gas coinPass { useGasCoin: true } for SUI deposits.

What the user should know

  • The deposit is pending until settlement and earns nothing until then. It can be cancelled after a short lock.
  • A deposit fee, if the vault charges one, is deducted at settlement. See fees.
  • A new deposit restarts the receipt’s withdrawal lock.

On this page