Lagoon
  • Back to App
  • Overview
    • What is Lagoon?
    • Lagoon Vault Architecture
    • FAQ
    • Terminology
  • VAULT
    • Overview
    • Deposit and Withdraw flows
    • Vault valuation
    • Fees
    • Roles and capacities
      • Vault admin
      • Valuation Oracle
      • Curator
      • Whitelist Manager
    • Create your vault
      • Vault post-deployment operations
      • Access your vault on Lagoon
    • How to?
      • Update the vault valuation & settle requests
      • Activate and manage a synchronous vault
      • Migrate an existing vault into a new Lagoon vault ?
      • How to pause a vault
  • Curation solutions
    • Safe & Zodiac Roles Modifier
    • MPC (Multi-Party Computation) wallet
    • How to?
      • Renounce Safe & Zodiac role modifier ownership
  • Developer hub
    • Key Data Structures and Epoch mechanism
    • Integration
      • Get a user position
      • Async deposit flow
      • Synchronous deposit flow
      • Vaults Frontend Integration
  • RESOURCES
    • Addresses
    • Audits
    • Brand Kit
    • Github
    • X
    • Blog
    • LinkedIn
Powered by GitBook
On this page
  • How to do a synchronous deposit ?
  • How to know if synchronous deposits are currently possible?
  • Typescript example with viem
  1. Developer hub
  2. Integration

Synchronous deposit flow

This page will guide you through activating synchronous deposits.

PreviousAsync deposit flowNextVaults Frontend Integration

Last updated 1 month ago

How to do a synchronous deposit ?

Synchronous deposits can be done by calling:

function syncDeposit(uint256 assets, address receiver, address referral) payable returns (uint256 shares);
Variable
Definition

assets

Amount of assets to deposit.

receiver

Recipient of the shares.

referral

Address that referred the depositor. Put the address 0 if not applicable.

How to know if synchronous deposits are currently possible?

if the function isTotalAssetsValid returns true, users can do synchronous deposits. If it returns false, users must do .

function isTotalAssetsValid() returns (bool);

Typescript example with viem

Here is an example of how to decide weither a user should do a synchronous or an asynchronous deposit.

const isSyncDepositAllowed = await client.readContract({
  abi: vaultAbi,
  address: vault.address,
  functionName: "isTotalAssetsValid",
});

if (isSyncDepositAllowed) {
  await client.writeContract({
    abi: vaultAbi,
    address: vault.address,
    functionName: "syncDeposit", // synchronous deposit
    args: [1000n, user.address, user.address],
  });
} else {
  await client.writeContract({
    abi: vaultAbi,
    address: vault.address,
    functionName: "requestDeposit", // asynchronous deposit
    args: [1000n, user.address, user.address],
  });
}

async deposits