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

# getYieldRewards

# getYieldRewards

Gets a wallet's accrued bonus [rewards](https://docs.dynamic.xyz/docs/earn/overview.md#key-concepts) in an [Earn](https://docs.dynamic.xyz/docs/earn/overview.md) vault. Rewards are separate from base yield. Base yield accrues automatically and never needs claiming, but rewards sit here until you call [`claimYieldRewards`](https://docs.dynamic.xyz/docs/javascript/reference/client/claim-yield-rewards).

This function currently supports vaults from these providers: Morpho, whose rewards come from reward campaigns, and Kamino, whose rewards come from the vault's reward farms. For a vault from any other provider, such as an Aave vault, the call rejects because the API responds with an HTTP 400 error, so check the vault's `provider` from [`getYieldDetails`](https://docs.dynamic.xyz/docs/javascript/reference/client/get-yield-details) first. For a supported vault, it returns an empty array when the wallet has no accrued rewards in this vault. A vault can run more than one reward campaign at once, each paying out in a different token, so each entry carries its own token identity (address, symbol, decimals) alongside the amount.

## Usage

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

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

console.log(rewards[0]?.accrued, rewards[0]?.tokenSymbol);
```

## Parameters

| Parameter | Type | Description |
| - | - | - |
| `vaultId` | `string` | Opaque vault identifier, from [`listYieldVaults`](https://docs.dynamic.xyz/docs/javascript/reference/client/list-yield-vaults). |
| `walletAccount` | `WalletAccount` | The wallet account whose accrued rewards are being read. Must be an EVM wallet account for an EVM vault, or a Solana wallet account for a Solana vault. |
| `client` | `DynamicClient` (optional) | The Dynamic client instance. Only required when using multiple Dynamic clients. |

## Returns

`Promise<YieldVaultReward[]>` - The wallet's accrued rewards in the vault, one entry per reward token/campaign.

| Field | Type | Description |
| - | - | - |
| `accrued` | `string \| null` | Amount claimable right now, as a raw string (e.g. `"5000000"`). Divide by `tokenDecimals` before displaying. |
| `tokenAddress` | `string \| null` | Contract address of the reward token. |
| `tokenSymbol` | `string \| null` | Ticker symbol of the reward token. |
| `tokenDecimals` | `number` | Number of decimals for the reward token. Use this to format `accrued`, the same way you'd use `assetDecimals` for a vault position. |

## Examples

### Sum rewards by token

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

const rewards = await getYieldRewards({ vaultId, walletAccount });

for (const reward of rewards) {
  if (reward.accrued && reward.accrued !== '0') {
    console.log(`${reward.tokenSymbol}: ${reward.accrued}`);
  }
}
```

## React

`useGetYieldRewards` is a query hook that stays disabled until `walletAccount` is defined.

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

function Rewards({
  vaultId,
  walletAccount,
}: {
  vaultId: string;
  walletAccount: WalletAccount | undefined;
}) {
  const { data: rewards = [], isLoading } = useGetYieldRewards({
    vaultId,
    walletAccount,
  });

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

  return (
    <ul>
      {rewards.map((reward) => (
        <li key={reward.tokenAddress}>
          {reward.tokenSymbol}: {reward.accrued}
        </li>
      ))}
    </ul>
  );
}
```

## Related

* [`claimYieldRewards`](https://docs.dynamic.xyz/docs/javascript/reference/client/claim-yield-rewards) - Claim these rewards
* [`getYieldPosition`](https://docs.dynamic.xyz/docs/javascript/reference/client/get-yield-position) - The wallet's share balance and asset value


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