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

# getYieldPosition

# getYieldPosition

Gets a wallet account's share balance and asset value in an [Earn](/docs/overview/yield) vault. Reads on-chain, so the result always reflects the vault's current state.

<Note>
  `shares` and `assets` are raw, undecimalized on-chain units — divide by the
  vault's `assetDecimals` (from
  [`getYieldDetails`](/docs/javascript/reference/client/get-yield-details)) before
  displaying them.
</Note>

## Usage

```javascript theme={"system"}
import { getYieldPosition } from '@dynamic-labs-sdk/client';

const position = await getYieldPosition({
  vaultId: 'fb-eth-galaxy-usdc-fw-01',
  walletAccount,
});

console.log(position.shares, position.assets);
```

## Parameters

| Parameter       | Type                       | Description                                                                                        |
| --------------- | -------------------------- | -------------------------------------------------------------------------------------------------- |
| `vaultId`       | `string`                   | Opaque vault identifier, from [`listYieldVaults`](/docs/javascript/reference/client/list-yield-vaults). |
| `walletAccount` | `WalletAccount`            | The wallet account whose position in the vault is being read.                                      |
| `client`        | `DynamicClient` (optional) | The Dynamic client instance. Only required when using multiple Dynamic clients.                    |

## Returns

`Promise<YieldVaultPosition>` - The wallet's share balance and asset value in the vault.

| Field          | Type     | Description                                                           |
| -------------- | -------- | --------------------------------------------------------------------- |
| `vaultId`      | `string` | Opaque vault identifier.                                              |
| `ownerAddress` | `string` | The wallet address the position was read for.                         |
| `shares`       | `string` | Vault share balance, in raw share units.                              |
| `assets`       | `string` | Underlying assets the shares are currently worth, in raw token units. |

## Examples

### Format a position for display

```javascript theme={"system"}
import { getYieldDetails, getYieldPosition } from '@dynamic-labs-sdk/client';
import { formatUnits } from 'viem';

async function loadPosition(vaultId, walletAccount) {
  const [details, position] = await Promise.all([
    getYieldDetails({ vaultId }),
    getYieldPosition({ vaultId, walletAccount }),
  ]);

  return {
    assetSymbol: details.assetSymbol,
    assets: formatUnits(BigInt(position.assets), details.assetDecimals),
  };
}
```

## React

`useGetYieldPosition` is a query hook that stays disabled until `walletAccount` is defined — safe to render before a wallet is connected.

```tsx theme={"system"}
import { useGetYieldPosition } from '@dynamic-labs-sdk/react-hooks';
import type { WalletAccount } from '@dynamic-labs-sdk/client';

function Position({
  vaultId,
  walletAccount,
}: {
  vaultId: string;
  walletAccount: WalletAccount | undefined;
}) {
  const { data: position, isLoading } = useGetYieldPosition({
    vaultId,
    walletAccount,
  });

  if (isLoading) {
    return <p>Loading position...</p>;
  }

  return <p>Shares: {position?.shares ?? '0'}</p>;
}
```

## Related

* [`getYieldDetails`](/docs/javascript/reference/client/get-yield-details) - Vault details, including `assetDecimals`
* [`getYieldRewards`](/docs/javascript/reference/client/get-yield-rewards) - The wallet's accrued rewards in this vault
* [`withdrawFromYieldVault`](/docs/javascript/reference/client/withdraw-from-yield-vault) - Withdraw from this vault
