getDailyApyHistory
Get daily APY history with weighted average for a wallet over a specified period.
Signature
getDailyApyHistory(walletAddress: string, days?: '7D' | '14D' | '30D'): Promise<DailyApyHistoryResponse>
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
walletAddress | string | ✅ | Smart wallet address |
days | `'7D' | '14D' | '30D'` |
Returns
Daily APY history with weighted averages
Return Type
// TokenApy is a record of token symbols to APY values
type TokenApy = Record<string, number>; // e.g., { "USDC": 5.05, "WETH": 1.58 }
interface ApyPosition {
apy: number;
balance: number;
chainId: number;
protocol: string;
pool: string;
strategy: string;
tokenSymbol?: string;
}
interface DailyApyEntry {
positions: ApyPosition[];
weighted_apy: TokenApy;
fee: TokenApy;
weighted_apy_after_fee: TokenApy;
rzfi_merkl_apr: TokenApy;
final_weighted_apy: TokenApy;
}
interface DailyApyHistoryResponse {
success: boolean;
walletAddress: string;
history: Record<string, DailyApyEntry>;
totalDays: number;
requestedDays?: string;
}
Example
const apyHistory = await sdk.getDailyApyHistory("0x...", "30D");
// Access history by date
Object.entries(apyHistory.history).forEach(([date, entry]) => {
console.log(`Date: ${date}`);
console.log(` USDC APY: ${entry.final_weighted_apy["USDC"] || 0}%`);
console.log(` WETH APY: ${entry.final_weighted_apy["WETH"] || 0}%`);
// Show positions
entry.positions.forEach(pos => {
console.log(` Position: ${pos.protocol} - ${pos.pool} (${pos.tokenSymbol}): ${pos.apy}%`);
});
});