feat: implement interest accrual and last_update_timestamp#92
Open
Mrwicks00 wants to merge 1 commit intoCreditra:mainfrom
Open
feat: implement interest accrual and last_update_timestamp#92Mrwicks00 wants to merge 1 commit intoCreditra:mainfrom
Mrwicks00 wants to merge 1 commit intoCreditra:mainfrom
Conversation
Author
|
@greatest0fallt1me please check |
Contributor
|
resolve the conflict |
Contributor
Contributor
|
@Mrwicks00 please resolve the conflicts |
Contributor
|
@Mrwicks00 Can you resolve the conflicts? |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Pull Request: Implement interest accrual logic and last_update_timestamp
Title: feat: implement interest accrual and last_update_timestamp
Branch: feature/interest-accrual
Base: main
Description
This PR implements the interest accrual logic for Soroban credit lines as specified in issue #8. Utilized debt now grows over time based on the
interest_rate_bpsand the time elapsed since thelast_update_timestamp.Closes #8
Changes Made
last_update_timestamptoCreditLineData.compute_accrued_interesthelper to calculate interest using overflow-safe arithmetic (i128) and a simple interest model (linear in time).update_accrued_interestto dynamically add interest toutilized_amountand update thelast_update_timestamp.update_accrued_interesthelper before relevant storage accesses in:draw_creditrepay_creditupdate_risk_parameterscompute_accrued_interestintoget_credit_lineso queries reflect real-time effective debt.test_interest_accrualtest_interest_accrual_zero_ratetest_interest_accrual_large_time(tests 10-year span of simple interest calculation).Verification
Tests have been run locally using
cargo test -p creditra-credit. All tests passed successfully.