Skip to content

Conversation

@mts1715
Copy link

@mts1715 mts1715 commented Jan 21, 2026

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.0
by
perSecondScaledValue = yearlyRate / 31_557_600.0 // 365.25 * 24.0 * 60.0 * 60.0

@mts1715 mts1715 requested a review from a team as a code owner January 21, 2026 13:13
@mts1715 mts1715 added the bug Something isn't working label Jan 21, 2026
@mts1715 mts1715 self-assigned this Jan 21, 2026
Copy link

@UlyanaAndrukhiv UlyanaAndrukhiv left a 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

Comment on lines 27 to 29
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

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.

Copy link
Author

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

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.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed ebe4ac4

Comment on lines 437 to 440
Test.assert(
growthDiff <= 0.01,
message: "Growth should be ~652.54706806. Actual: \(actualGrowth)"
)

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.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed
ebe4ac4

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Wrong calculation FlowCreditMarket->perSecondInterestRate

3 participants