Skip to content

Commit

Permalink
Fix apy for 1 event collected in last 24h
Browse files Browse the repository at this point in the history
  • Loading branch information
prevostc committed Jun 18, 2024
1 parent 5310337 commit f0d041d
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
5 changes: 3 additions & 2 deletions src/utils/apr.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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', () => {
Expand Down
2 changes: 1 addition & 1 deletion src/utils/apr.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 };
}

Expand Down

0 comments on commit f0d041d

Please sign in to comment.