> For the complete documentation index, see [llms.txt](https://docs.lagoon.finance/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.lagoon.finance/developer-hub/integration/async-deposit-flow.md).

# Async deposit flow

### 1) User requests a deposit

```solidity
 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.

{% hint style="info" %}
An asset.approve() transaction from the user to the vault should happen before the request deposit.
{% endhint %}

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

```solidity
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.

{% hint style="warning" %}
*Claiming the shares is not mandatory to start earning.*
{% endhint %}

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

```solidity
function maxMint(address) public view virtual returns (uint256 shares)
```

He can claim them by calling:

```solidity
function mint(uint256 shares, address receiver) public virtual returns (uint256 assets)
```

or

```solidity
function deposit(uint256 assets, address receiver) public virtual returns (uint256 shares)
```

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:

```solidity
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
```

{% hint style="success" %}
This will improve the UX and remove one transaction in the process.
{% endhint %}


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.lagoon.finance/developer-hub/integration/async-deposit-flow.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
