> ## 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

> Deposit assets, withdraw funds and redeem earned fee shares from customer wallets.

Deposit assets and redeem shares directly from customer wallets through your organization's gToken contract.

Before depositing, [set up your gVault](https://docs.groundtech.co/v3/docs/gtokens/discover-yield-sources.md) and [allowlist the customer wallet](https://docs.groundtech.co/v3/docs/gtokens/manage-gtoken-access.md).

Call the methods below on the discovered `contractAddress`. Use `assetId` to choose the withdrawal method.

## Deposit

Both USTB and PRIME accept the same deposit method:

```solidity theme={"theme":{"light":"github-light","dark":"github-dark"}}
function deposit(uint256 assets, address receiver, uint256 minWrapperShares)
  external returns (uint256 shares);
```

1. From the customer's wallet, approve the exact funding amount to `contractAddress` and wait for the approval transaction to confirm.
2. Choose a positive `minWrapperShares` from current contract reads or a simulated deposit and your slippage tolerance.
3. Call `deposit` from the admitted wallet, using that same address as `receiver`.
4. Wait for a successful receipt and verify the customer's share balance increased.

Express `assets` in the funding token's smallest units and `minWrapperShares` in the contract's share units. For example, 1 USDC is `1000000` units when the funding token has 6 decimals. The [quickstart](https://docs.groundtech.co/v3/docs/gtokens/quickstart.md#4-make-a-deposit) includes a runnable deposit example.

## USTB withdrawals

For USTB, withdrawals can settle immediately when the underlying vault has enough liquidity. The customer who owns the shares sends the transaction, passing their address as `owner` and the destination for the assets as `receiver`:

```solidity theme={"theme":{"light":"github-light","dark":"github-dark"}}
function redeem(uint256 wrapperShares, address receiver, address owner)
  external returns (uint256 assets);
function withdraw(uint256 assets, address receiver, address owner)
  external returns (uint256 wrapperShares);
```

Use `redeem` to withdraw a number of shares, or `withdraw` to receive a specified amount of the funding asset.

When withdrawal requires asynchronous settlement, the owner requests redemption and claims the assets after settlement:

```solidity theme={"theme":{"light":"github-light","dark":"github-dark"}}
function requestRedeem(address owner, uint256 wrapperShares)
  external returns (uint256 requestId);
function claimRedeem(address owner, uint256 requestId)
  external returns (uint256 assetsOut);
```

1. Call `requestRedeem` from the owner's wallet. Save the chain, contract address, owner, request ID and successful request receipt.
2. Wait for the underlying redemption to settle. Confirm readiness through contract reads or a simulated claim before submitting `claimRedeem`.
3. Call `claimRedeem` from the owner's wallet with the saved request ID. Wait for a successful receipt and verify the owner's funding-asset balance increased.

Claim proceeds go to the owner. Shares committed to a request cannot be spent again; track pending claims separately from available shares. See [asynchronous operations](https://docs.groundtech.co/v3/docs/gtokens/async-operations) for request tracking and recovery.

## PRIME withdrawals

For PRIME, use the four-argument redemption method:

```solidity theme={"theme":{"light":"github-light","dark":"github-dark"}}
function redeem(uint256 shares, address receiver, address owner, uint256 minAssets)
  external returns (uint256 assets);
```

The customer who owns the shares sends the transaction, passing their address as `owner` and the destination for the assets as `receiver`. Set a positive `minAssets` in the funding token's smallest units, based on current contract reads or a simulated redemption and your slippage tolerance.

Wait for a successful receipt and verify the receiver's funding-asset balance increased.

## Redeem earned fees

Management and performance fees accrue as shares minted to the configured recipients. Each recipient reads `balanceOf(recipient)` on `contractAddress` and redeems through the USTB or PRIME withdrawal methods above, using their address as `owner`.

A balance read does not trigger fee accrual. Deposits, redemptions and fee configuration changes accrue fees according to the contract.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.