# Obtaining RWA Underlying

> Markdown export of the Gearbox Protocol documentation page for agents and retrieval systems.

Canonical page: https://docs.gearbox.finance/developers/obtain-rwa-underlying
Source file: content/developers/obtain-rwa-underlying.mdx
Section router: https://docs.gearbox.finance/developers/llms.txt
Section full export: https://docs.gearbox.finance/developers/llms-full.txt

Some Gearbox RWA pools use
[`DefaultRWAUnderlying`](https://docs.gearbox.finance/developers/rwa-underlying) as their
underlying. Obtain it by depositing the wrapper's configured ERC-20 asset.
This does not require KYC or an allowlist step.

After obtaining the token, use the standard
[Pool Integration](https://docs.gearbox.finance/developers/pool-integration) flow without changing the
pool logic.

Before continuing, [install and attach the Gearbox SDK](https://docs.gearbox.finance/developers/sdk-setup).
The examples use these inputs:

| Variable | Type | Meaning |
|---|---|---|
| `sdk` | `OnchainSDK` | Attached Gearbox SDK instance |
| `poolAddress` | `Address` | RWA pool whose underlying must be obtained |
| `lender` | `Address` | Wallet supplying the configured asset and receiving the RWA underlying |
| `assetAmount` | `bigint` | ERC-20 asset amount to deposit, in native token units |
| `rwaUnderlyingAmount` | `bigint` | RWA underlying amount to redeem, in native token units |

## Resolve the wrapper

Resolve the RWA underlying and its ERC-20 asset from the pool:

```typescript
import {
  BaseContract,
  RWA_UNDERLYING_DEFAULT,
} from "@gearbox-protocol/sdk";
import { iRWAUnderlyingAbi } from "@gearbox-protocol/sdk/abi/rwa/iRWAUnderlying";

const market = sdk.marketRegister.findByPool(poolAddress);
const meta = sdk.tokensMeta.mustGet(market.underlying);

if (
  !sdk.tokensMeta.isRWAUnderlying(meta) ||
  meta.contractType !== RWA_UNDERLYING_DEFAULT
) {
  throw new Error("Pool does not use DefaultRWAUnderlying");
}

const underlyingAsset = meta.asset;
const rwaUnderlying = new BaseContract(sdk, {
  addr: market.underlying,
  abi: iRWAUnderlyingAbi,
  name: "DefaultRWAUnderlying",
});
```

`underlyingAsset` is the token supplied to and returned by the wrapper.
`rwaUnderlying.address` is the token used by the Gearbox pool.

## Obtain RWA underlying

### Preview deposit

```typescript
const expectedRwaUnderlying =
  await rwaUnderlying.contract.read.previewDeposit([assetAmount]);
```

The wrapper converts its configured asset 1:1, but use the preview rather than
hardcoding that result.

### Generate deposit transaction

```typescript
const depositTransaction = rwaUnderlying.createRawTx({
  functionName: "deposit",
  args: [assetAmount, lender],
});
```

Approve `underlyingAsset` for `rwaUnderlying.address` with an allowance of at
least `assetAmount`. `depositTransaction` is the unsigned wrapper deposit call.

After execution, approve the received RWA underlying to the Gearbox pool and
continue with [Pool Integration](https://docs.gearbox.finance/developers/pool-integration#deposit).

## Check how much can be redeemed

```typescript
const [withdrawableAsset, redeemableRwaUnderlying] = await Promise.all([
  rwaUnderlying.contract.read.maxWithdraw([lender]),
  rwaUnderlying.contract.read.maxRedeem([lender]),
]);
```

`withdrawableAsset` is the asset-denominated limit.
`redeemableRwaUnderlying` is the share-denominated limit.

## Redeem to the underlying asset

### Preview redemption

```typescript
const expectedAsset = await rwaUnderlying.contract.read.previewRedeem([
  rwaUnderlyingAmount,
]);
```

### Generate redemption transaction

```typescript
const redeemTransaction = rwaUnderlying.createRawTx({
  functionName: "redeem",
  args: [rwaUnderlyingAmount, lender, lender],
});
```

No approval is required when `lender` submits the redemption. If another
address submits it, `lender` must approve that address to spend the RWA
underlying. `redeemTransaction` is the unsigned wrapper redemption call.

## Pricing

```typescript
const [rwaUnderlyingOut, assetOut] = await Promise.all([
  rwaUnderlying.contract.read.convertToShares([assetAmount]),
  rwaUnderlying.contract.read.convertToAssets([rwaUnderlyingAmount]),
]);
```

`DefaultRWAUnderlying` currently defines a 1:1 conversion in both directions.
Use `previewDeposit` and `previewRedeem` when preparing an actual transaction.

## Integration boundary

This page provides Gearbox address resolution, limits, previews, approval
targets, and unsigned calldata. The lender's existing infrastructure owns
allowance state, simulation, signing, submission, and monitoring.

For why this token exists, how freeze authority works, and why it does not add
direct freeze risk to LP wallets, see
[Default RWA Underlying](https://docs.gearbox.finance/developers/rwa-underlying).

## Sources

- [`DefaultRWAUnderlying`](https://github.com/Gearbox-protocol/periphery-v3/blob/main/contracts/rwa/DefaultRWAUnderlying.sol)
- [Gearbox SDK RWA underlying ABI](https://github.com/Gearbox-protocol/sdk/blob/next/src/abi/rwa/iRWAUnderlying.ts)
