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
  • 1) User requests a deposit
  • 2) User claim his shares
  • Ux tip - Claim shares and request redeem in one tx
  1. Developer hub
  2. Integration

Async deposit flow

1) User requests a deposit

 function requestDeposit(
        uint256 assets,
        address controller,
        address owner
    ) external payable returns (uint256 requestId);Copy

Args:

  • assets: the quantity of underlying to deposit.

  • controller: the address that will control the request. The user address.

  • owner: the address from which the asset will be transfered from. The user address.

An asset.approve() transaction from the user to the vault should happen before the request deposit.

After the transaction, users can check their pending requests by calling:

function pendingDepositRequest(
        uint256 requestId, 
        address controller
    ) external view returns (uint256 assets);Copy

Args:

  • requestId, the id of the deposit request. Put 0 as a wildcard.

  • controller. User address.

Return:

  • Amount of assets pending

2) User claim his shares

After a settleDeposits, the shares are claimable and waiting in the vault.

Claiming the shares is not mandatory to start earning.

A user can know the amount of claimable shares by calling:

function maxMint(address) public view virtual returns (uint256 shares)Copy

He can claim them by calling:

function mint(uint256 shares, address receiver) public virtual returns (uint256)Copy

Args:

  • shares: the amount of shares to claim. Between 0 and the return of maxMint(userAddress).

  • receiver: user address.

Ux tip - Claim shares and request redeem in one tx

A user with claimable shares can directly request a redemption by calling:

function claimSharesAndRequestRedeem(
   uint256 sharesToRedeem
    ) public onlyOpen whenNotPaused returns (uint40 requestId)Copy

Note: Already claimed shares can be requested to be redeemed via this method. It also means that you could only use this function to do redemption requests.

Example:
userClaimableShares: 10
userSharesBalance: 5
claimSharesAndRequestRedeem(15) --> valid call

userClaimableShares: 0
userSharesBalance: 5
claimSharesAndRequestRedeem(5) --> valid call

This will improve the UX and remove one transaction in the process.

PreviousGet a user positionNextSynchronous deposit flow

Last updated 1 month ago