> ## Documentation Index
> Fetch the complete documentation index at: https://docs.defindex.io/llms.txt
> Use this file to discover all available pages before exploring further.

# Vault Methods

The three user-facing methods on a vault. For the API equivalents, see [Vault Operations](/integration-guide/vault-operations/index).

## Deposit

```rust theme={null}
fn deposit(
    e: Env,
    amounts_desired: Vec<i128>,
    amounts_min: Vec<i128>,
    from: Address,
    invest: bool,
) -> Result<(Vec<i128>, i128, Option<Vec<Option<AssetInvestmentAllocation>>>), ContractError>
```

* **`amounts_desired`**: the quantity of each asset to deposit.
* **`amounts_min`**: the minimum quantity of each asset to transfer, your slippage protection.
* **`from`**: the Soroban address making the deposit.
* **`invest`**: `true` to invest into the vault's strategies immediately, `false` to leave the funds idle.

```rust theme={null}
let deposit_args = vec![
            e,
            &amounts_desired,
            &amounts_min,
            &user_address,
            &auto_invest,
        ]
let result = e.try_invoke_contract::(
            &vault_address,
            &Symbol::new(&e, "deposit"),
            deposit_args.into_val(e),
    ).unwrap_or_else(|_| {
        panic_with_error!(e, SomeError::SomeError);
    }).unwrap();
```

Returns the amounts actually deposited, the shares minted, and, when `invest` is `true`, how the funds were allocated across strategies.

## Withdraw

* **`withdraw_shares`**: the amount of vault shares to burn.
* **`min_amounts_out`**: the minimum amounts to receive before the transaction fails, in underlying assets.
* **`from`**: the address performing the withdrawal, which receives the funds.

```json theme={null}
{
  "method": "withdraw",
  "params": {
    "withdraw_shares": 500,
    "min_amounts_out": [450],
    "from": "GCINP..."
  }
}
```

```rust theme={null}
let withdraw_args = vec![
            e,
            &withdraw_shares,
            &min_amounts_out,
            &from
        ]
let result = e.try_invoke_contract::(
            &vault_address,
            &Symbol::new(&e, "withdraw"),
            withdraw_args.into_val(e),
    ).unwrap_or_else(|_| {
        panic_with_error!(e, SomeError::SomeError);
    }).unwrap();
```

To withdraw a given amount of the underlying asset rather than a number of shares, convert first: call `total_supply` for the vault's total shares and `fetch_total_managed_funds` for the `total_amount` of the asset, then

`shares_to_withdraw = total_supply * amount_to_withdraw / total_amount`

A vault can hold several assets, so on a single-asset vault take the first element to get its `total_amount`.

## Balance

* **`from`**: the Soroban address whose balance you are querying.

```json theme={null}
{
  "method": "balance",
  "params": {
    "from": "GCINP..."
  }
}
```
