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

# Deposit and redeem onchain

> Integrate the synchronous and request/claim contract flows exposed by Ground gVaults.

Use the `interface` returned by `GET /v2/gvaults/yield-sources` to select the
correct deployed interface. Do not assume every gVault implements the same
operation lifecycle.

## Before any deposit

1. Resolve `contractAddress` from the current environment's catalogue.
2. Confirm the receiving address is allowlisted.
3. Call `asset()` and verify the returned token and chain.
4. Convert human-readable amounts to the asset's native units.
5. Estimate the result and set application-level slippage or minimum-output policy.

## USTB-style synchronous deposit

USTB-style gVaults accept an ERC-20 approval followed by a deposit:

```solidity theme={"theme":{"light":"github-light","dark":"github-dark"}}
address token = gVault.asset();
uint256 limit = gVault.maxDeposit(receiver);
uint256 expectedShares = gVault.convertToShares(assets);

IERC20(token).approve(address(gVault), assets);
uint256 shares = gVault.deposit(assets, receiver);
```

The `receiver` receives gVault shares and must be authorized for deposits.
Record the actual returned share amount; previews are estimates, not receipts.

## Immediate withdrawal

Check the owner's current synchronous capacity before submitting:

```solidity theme={"theme":{"light":"github-light","dark":"github-dark"}}
uint256 maxAssets = gVault.maxWithdraw(owner);
uint256 maxShares = gVault.maxRedeem(owner);
```

Within those limits, the owner can call:

```solidity theme={"theme":{"light":"github-light","dark":"github-dark"}}
uint256 sharesBurned = gVault.withdraw(assets, receiver, owner);
uint256 assetsOut = gVault.redeem(shares, receiver, owner);
```

If a caller other than `owner` is used, confirm the deployed contract's
authorization rules before building that transaction.

## Queued redemption

For an exit above current synchronous liquidity, submit:

```solidity theme={"theme":{"light":"github-light","dark":"github-dark"}}
uint256 requestId = gVault.requestRedeem(owner, shares);
```

Persist the chain, contract, transaction hash, `owner`, share amount, and
returned `requestId`. Once the request is processed, the same owner claims:

```solidity theme={"theme":{"light":"github-light","dark":"github-dark"}}
uint256 assetsOut = gVault.claimRedeem(owner, requestId);
```

Do not infer claimability from elapsed time. Read onchain request state or
simulate the claim against the current block before prompting the user.

## Centrifuge-style operations

Centrifuge-style gVaults expose explicit request and claim methods:

```solidity theme={"theme":{"light":"github-light","dark":"github-dark"}}
requestDeposit(address owner, uint256 assets, uint256 minSharesOut)
claimDeposit(address owner, uint256 requestId)
requestRedeem(address owner, uint256 shares, uint256 minBasinAssetsOut)
claimRedeem(address owner, uint256 requestId)
```

Centrifuge-style deposit methods are restricted to the configured Ground
router. A user address cannot call them directly. For a fully direct customer
deposit, select a synchronous gVault; otherwise coordinate the router flow with
Ground.

See [gVault contract interfaces](/docs/gvaults/contract-interfaces) and
[Handle asynchronous gVault operations](/docs/gvaults/async-operations).
