-
Notifications
You must be signed in to change notification settings - Fork 2
Fix calculation per second interest rate #116
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
UlyanaAndrukhiv
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, left some minor comments
| access(all) let TEN_DAYS: Fix64 = 864_000.0 | ||
| access(all) let THIRTY_DAYS: Fix64 = 2_592_000.0 // 30 * 86400 | ||
| access(all) let ONE_YEAR: Fix64 = 31_557_600.0 // 365.25 * 86400 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe let’s move these time constants to a common file (cadence/tests/test_helpers.cdc) so we can reuse them across other tests and avoid duplication.
If you apply this proposal, please check the test files for duplicated constant declarations and remove them.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed ebe4ac4
| // - 9% APY → (1 + 0.09 / 31_557_600) ^ 31_557_600 - 1 ≈ 9.42% effective rate | ||
| // - Spread should be approximately 1% | ||
| let ONE_YEAR: Fix64 = 31536000.0 | ||
| let ONE_YEAR: Fix64 = 31_557_600.0 // 365.25 days |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Once we move ONE_YEAR to the common file (cadence/tests/test_helpers.cdc), we won’t need to declare it in every test file individually.
So we can safely remove this line.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed ebe4ac4
| Test.assert( | ||
| growthDiff <= 0.01, | ||
| message: "Growth should be ~652.54706806. Actual: \(actualGrowth)" | ||
| ) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess we should keep this assert with growth, or just updated it like you did for growthRate.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
ebe4ac4
Closes: #110
Description
Fixed the wrong seconds in year used in the method FlowCreditMarket->perSecondInterestRate:
perSecondScaledValue = yearlyRate / 31536000.0 // 365.0 * 24.0 * 60.0 * 60.0by
perSecondScaledValue = yearlyRate / 31_557_600.0 // 365.25 * 24.0 * 60.0 * 60.0