fix: correct rate scaling, liquidity accounting, and code clarity issues#2
Draft
FabianSanchezD with Copilot wants to merge 4 commits into
Draft
fix: correct rate scaling, liquidity accounting, and code clarity issues#2FabianSanchezD with Copilot wants to merge 4 commits into
FabianSanchezD with Copilot wants to merge 4 commits into
Conversation
…larity Co-authored-by: FabianSanchezD <85092684+FabianSanchezD@users.noreply.github.com>
Co-authored-by: FabianSanchezD <85092684+FabianSanchezD@users.noreply.github.com>
Co-authored-by: FabianSanchezD <85092684+FabianSanchezD@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Refactor contract logic for protocol update
fix: correct rate scaling, liquidity accounting, and code clarity issues
Jan 4, 2026
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.
Addressed unresolved review feedback regarding scaling inconsistencies, state management bugs, and code clarity issues in the lending protocol contracts.
Rate Scaling Fix
Problem: Interest calculation divided by
YEAR_MSonly, ignoring the 1e9 rate scaling factor. Withbase_rate = 10_000_000_000(10% scaled), this calculated 10 billion percent interest instead of 10%.Solution: Created
INTEREST_DENOMINATOR = YEAR_MS × RATE_SCALEconstant for proper scaling:Liquidity Accounting Fix
Problem:
disburse()decreasedtotal_liquidityandreceive_repayment()increased it, double-counting interest already added byaccrue_interest().Solution:
total_liquiditynow represents total pool value (available + borrowed). Onlyaccrue_interest()modifies it:disburse(): increasestotal_borrowed,total_liquidityunchangedreceive_repayment(): decreasestotal_borrowed,total_liquidityunchanged (interest already accrued)Other Fixes
DEFAULT_BOOST: Changed from2_000_000_000to2(raw star count, not scaled value)purposeparameter with clarifying commentmutwarning in disburse function💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.