diff --git a/src/utils/apr.test.ts b/src/utils/apr.test.ts index 097e854..4371233 100644 --- a/src/utils/apr.test.ts +++ b/src/utils/apr.test.ts @@ -88,9 +88,10 @@ describe('Apr', () => { }, ]; - const apr = calculateLastApr(aprState, 86400 * 1000, new Date('2024-06-18T07:26:11.773Z')); + const res = calculateLastApr(aprState, 86400 * 1000, new Date('2024-06-18T07:26:11.773Z')); - expect(apr.apr.toNumber()).toBeCloseTo(0.45586, 3); + expect(res.apr.toNumber()).toBeCloseTo(0.45586, 3); + expect(res.apy.toNumber()).toBeCloseTo(0.57709, 3); }); test('should compute apr in the simplest case', () => { diff --git a/src/utils/apr.ts b/src/utils/apr.ts index 3bbc692..7682756 100644 --- a/src/utils/apr.ts +++ b/src/utils/apr.ts @@ -82,7 +82,7 @@ export function calculateLastApr( const rewardRate = sliceCollected.div(sliceTvl).div(sliceDuration); const apr = rewardRate.times(ONE_YEAR); - const apy = aprToApy(apr, 1); + const apy = aprToApy(apr, ONE_YEAR / periodMs); return { apr, apy }; }