Review feedback from @gregtatcam: seconds per year

- Define a constexpr secondsInYear in LedgerHelpers.h
This commit is contained in:
Ed Hennis
2025-11-23 00:03:52 -05:00
parent a3b2ce91de
commit 63724e4405
3 changed files with 5 additions and 3 deletions

View File

@@ -2388,7 +2388,7 @@ protected:
// the below BEAST_EXPECTs may not hold across assets.
Number const interval = state.paymentInterval;
auto const periodicRate =
interval * Number(12, -2) / (365 * 24 * 60 * 60);
interval * Number(12, -2) / secondsInYear;
BEAST_EXPECT(
periodicRate ==
Number(2283105022831050, -21, Number::unchecked{}));
@@ -2620,7 +2620,7 @@ protected:
// the below BEAST_EXPECTs may not hold across assets.
Number const interval = state.paymentInterval;
auto const periodicRate =
interval * Number(12, -2) / (365 * 24 * 60 * 60);
interval * Number(12, -2) / secondsInYear;
BEAST_EXPECT(
periodicRate ==
Number(2283105022831050, -21, Number::unchecked{}));

View File

@@ -12,6 +12,8 @@ struct PreflightContext;
bool
checkLendingProtocolDependencies(PreflightContext const& ctx);
static constexpr std::uint32_t secondsInYear = 365 * 24 * 60 * 60;
Number
loanPeriodicRate(TenthBips32 interestRate, std::uint32_t paymentInterval);

View File

@@ -54,7 +54,7 @@ loanPeriodicRate(TenthBips32 interestRate, std::uint32_t paymentInterval)
* other places.
*/
return tenthBipsOfValue(Number(paymentInterval), interestRate) /
(365 * 24 * 60 * 60);
secondsInYear;
}
bool