/** * APR Service Module * * Production-validated APR calculations using Lagoon SDK. * Patterns from frontend-dapp-v2/src/lib/manage/apr-data-service.ts * * @module sdk/apr-service */ import type { VaultData } from '../graphql/fragments/index.js'; /** * Period summary structure from GraphQL */ export interface PeriodSummary { timestamp: string; totalAssetsAtStart: string; totalSupplyAtStart: string; } /** * APR historical data point */ export interface APRDataPoint { timestamp: number; pricePerShare: bigint; } /** * APR historical data structure */ export interface APRHistoricalData { thirtyDay?: APRDataPoint; inception?: APRDataPoint; } /** * Transform period summaries to APR historical data * * Production pattern from frontend-dapp-v2/src/lib/manage/apr-data-service.ts * * Extracts 30-day and inception data points using SDK's getLastPeriodSummaryInDuration. * Gracefully handles new vaults with no history (returns empty object). * * @param periodSummaries - Historical period summaries from GraphQL * @param vault - Vault data for decimal calculations * @returns APR historical data with optional 30-day and inception points * * @example * ```typescript * const aprData = transformPeriodSummariesToAPRData(periodSummaries, vault); * * if (aprData.thirtyDay) { * console.log('30-day price:', aprData.thirtyDay.pricePerShare); * console.log('Timestamp:', aprData.thirtyDay.timestamp); * } * ``` */ export declare function transformPeriodSummariesToAPRData(periodSummaries: PeriodSummary[], vault: VaultData): APRHistoricalData; /** * Calculate APR from price per share change * * Computes annualized percentage return based on price per share change over time. * Uses precise BigInt math to avoid floating-point errors. * * @param oldPrice - Historical price per share * @param newPrice - Current price per share * @param daysElapsed - Number of days between prices * @returns APR as percentage (e.g., 15.5 for 15.5%) * * @example * ```typescript * const apr = calculateAPRFromPriceChange( * 1000000n, // 1.0 USDC (6 decimals) * 1025000n, // 1.025 USDC * 30 // 30 days * ); * // => ~30.42% APR (2.5% in 30 days, annualized) * ``` */ export declare function calculateAPRFromPriceChange(oldPrice: bigint, newPrice: bigint, daysElapsed: number): number; /** * Calculate current APR from historical data * * Convenience function that combines APR historical data with current price * to compute 30-day and inception APR values. * * @param aprData - APR historical data with 30-day and/or inception points * @param currentPricePerShare - Current price per share * @returns Object with 30-day and inception APR values (undefined if no data) * * @example * ```typescript * const aprs = calculateCurrentAPR(aprData, currentPrice); * * if (aprs.thirtyDay !== undefined) { * console.log(`30-day APR: ${aprs.thirtyDay.toFixed(2)}%`); * } * ``` */ export declare function calculateCurrentAPR(aprData: APRHistoricalData, currentPricePerShare: bigint): { thirtyDay?: number; inception?: number; }; //# sourceMappingURL=apr-service.d.ts.map