Skip to content

Commit

Permalink
rounding errors
Browse files Browse the repository at this point in the history
  • Loading branch information
mj850 committed Jan 30, 2024
1 parent 77c6261 commit 258cbb8
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions packages/core/src/lib/utils/apr.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ export function getUpcomingMintTokens(startDate: Moment, days: number, releaseSc

// The case where this release ends after our search window.
else if (release.endDate.isAfter(endDate)) {
let daysLeft: number = endDate.diff(release.startDate, 'days');
let daysLeft: number = Math.round(endDate.diff(release.startDate, 'days', true));
let totalPeriod: number = calculateDaysInclusive(release.startDate, release.endDate);
tokens += (daysLeft / totalPeriod) * release.tokenReleaseAmount;
}
Expand Down Expand Up @@ -114,7 +114,7 @@ function getSortedReleaseSchedule(releaseSchedule: ScheduledTokenReleaseSDKType[

// Returns the number of days in the window inclusive of the start and end date.
function calculateDaysInclusive(startDate: Moment, endDate: Moment) {
return endDate.diff(startDate, 'days') + 1;
return Math.round(endDate.diff(startDate, 'days', true)) + 1;
}

interface ReleaseSchedule {
Expand Down

0 comments on commit 258cbb8

Please sign in to comment.