Skip to content

Commit 0f6e5e5

Browse files
committed
Guard against bad on-chain data producing absurd APYs
1 parent 570a19b commit 0f6e5e5

1 file changed

Lines changed: 10 additions & 1 deletion

File tree

src/templates/origin-arm/arm-apy.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,5 +16,14 @@ export const calculateArmDailyApy = ({
1616
const startOfDay = dayjs(date).startOf('day').toDate()
1717
const endOfDay = dayjs(date).endOf('day').toDate()
1818

19-
return calculateAPY(startOfDay, endOfDay, previousDailyStat?.assetsPerShare ?? 10n ** 18n, state.assetsPerShare)
19+
const result = calculateAPY(
20+
startOfDay,
21+
endOfDay,
22+
previousDailyStat?.assetsPerShare ?? 10n ** 18n,
23+
state.assetsPerShare,
24+
)
25+
// Guard against bad on-chain data producing absurd APYs. Anything above
26+
// 1000% is treated as noise and zeroed out.
27+
if (result.apy > 10) return { apr: 0, apy: 0 }
28+
return result
2029
}

0 commit comments

Comments
 (0)