+
Claim Rewards
+
+ {status === 'no_rewards' && (
+
+ No rewards available to claim yet. Rewards accrue over time from vault participation.
+
+ )}
+
+ {error && (
+
+ {error}
+
+ )}
+
+ {status === 'success' && claimResult && (
+
+
+ Claimed {claimResult.rewards.map((r, i) => (
+
+ {i > 0 && ', '}
+ {formatTokenAmount(r.amount, 18, 4)} {r.token_symbol}
+
+ ))}
+
+
+ Status: {claimResult.status}
+
+
+ )}
+
+
+
+
+ Claim incentive rewards earned from vault participation
+
+
+ );
+}
diff --git a/examples/privy-next-yield-demo/src/components/TransactionHistory.tsx b/examples/privy-next-yield-demo/src/components/TransactionHistory.tsx
index 9149e10..a6d9a5f 100644
--- a/examples/privy-next-yield-demo/src/components/TransactionHistory.tsx
+++ b/examples/privy-next-yield-demo/src/components/TransactionHistory.tsx
@@ -2,15 +2,17 @@
import { useEffect, useState, useCallback } from "react";
import { usePrivy } from "@privy-io/react-auth";
-import { formatUSDC } from "@/lib/constants";
+import { formatUSDC, formatTokenAmount } from "@/lib/constants";
interface Transaction {
id: string;
wallet_id: string;
- vault_id: string;
+ vault_id?: string;
type: string;
status: string;
asset_amount: string;
+ token_symbol: string;
+ token_decimals: number;
share_amount?: string;
transaction_id?: string;
created_at: number;
@@ -137,7 +139,7 @@ export function TransactionHistory({
Transaction history
- No transactions yet. Make a deposit or withdrawal to get started.
+ No transactions yet. Make a deposit, withdrawal, or claim to get started.
);
@@ -151,7 +153,13 @@ export function TransactionHistory({
{transactions.map((tx, index) => {
- const isDeposit = tx.type === "deposit";
+ let label: string;
+ if (tx.type === "claim") {
+ label = `Claimed ${formatTokenAmount(tx.asset_amount, tx.token_decimals, 4)} ${tx.token_symbol}`;
+ } else {
+ const verb = tx.type === "deposit" ? "Deposited" : "Withdrew";
+ label = `${verb} $${formatUSDC(tx.asset_amount)} USDC`;
+ }
return (
-
- {isDeposit ? "Deposited" : "Withdrew"} $
- {formatUSDC(tx.asset_amount)} USDC
+
+ {label}
-
+
{formatTimestamp(tx.created_at)}
-
+
+
+
);
})}
diff --git a/examples/privy-next-yield-demo/src/lib/constants.ts b/examples/privy-next-yield-demo/src/lib/constants.ts
index b2bac02..4a82553 100644
--- a/examples/privy-next-yield-demo/src/lib/constants.ts
+++ b/examples/privy-next-yield-demo/src/lib/constants.ts
@@ -3,8 +3,9 @@ import { base } from 'viem/chains';
// Network Configuration
export const CHAIN = base;
// USDC on Base Mainnet
-export const USDC_ADDRESS = '0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913' as const;
+export const USDC_ADDRESS = '0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913';
export const USDC_DECIMALS = 6;
+export const USDC_TOKEN = { token_symbol: 'USDC', token_decimals: USDC_DECIMALS };
// Privy API — must match the URL used for authorization signature signing
export const PRIVY_API_URL = 'https://api.privy.io/v1';
@@ -15,11 +16,7 @@ export const getFeeRecipientWalletId = () => process.env.NEXT_PUBLIC_FEE_RECIPIE
// Format USDC amount for display (from smallest unit to human readable)
export function formatUSDC(amount: string | bigint): string {
- const value = typeof amount === 'string' ? BigInt(amount) : amount;
- const wholePart = value / BigInt(10 ** USDC_DECIMALS);
- const fractionalPart = value % BigInt(10 ** USDC_DECIMALS);
- const fractionalStr = fractionalPart.toString().padStart(USDC_DECIMALS, '0');
- return `${wholePart}.${fractionalStr.slice(0, 2)}`;
+ return formatTokenAmount(amount, USDC_DECIMALS);
}
// Parse human readable USDC to smallest unit (wei equivalent)
@@ -29,6 +26,24 @@ export function parseUSDC(amount: string): string {
return `${whole}${paddedDecimal}`;
}
+// MORPHO on Base Mainnet
+export const MORPHO_ADDRESS = '0xBAa5CC21fd487B8Fcc2F632f3F4E8D37262a0842';
+export const MORPHO_DECIMALS = 18;
+
+// Format any token amount for display (from smallest unit to human readable)
+export function formatTokenAmount(
+ amount: string | bigint,
+ decimals: number,
+ displayDecimals: number = 2
+): string {
+ const value = typeof amount === 'string' ? BigInt(amount) : amount;
+ const divisor = BigInt(10 ** decimals);
+ const wholePart = value / divisor;
+ const fractionalPart = value % divisor;
+ const fractionalStr = fractionalPart.toString().padStart(decimals, '0');
+ return `${wholePart}.${fractionalStr.slice(0, displayDecimals)}`;
+}
+
// Truncate address for display
export function truncateAddress(address: string): string {
if (!address) return '';
diff --git a/examples/privy-next-yield-demo/src/lib/transaction-store.ts b/examples/privy-next-yield-demo/src/lib/transaction-store.ts
index 0310b4a..25db693 100644
--- a/examples/privy-next-yield-demo/src/lib/transaction-store.ts
+++ b/examples/privy-next-yield-demo/src/lib/transaction-store.ts
@@ -8,10 +8,12 @@
export interface Transaction {
id: string;
wallet_id: string;
- vault_id: string;
- type: string; // "deposit" | "withdraw"
+ vault_id?: string;
+ type: string; // "deposit" | "withdraw" | "claim"
status: string; // "pending" | "confirmed" | "failed"
asset_amount: string;
+ token_symbol: string; // e.g. "USDC", "MORPHO"
+ token_decimals: number; // e.g. 6 for USDC, 18 for MORPHO
share_amount?: string;
transaction_id?: string;
approval_transaction_id?: string;