Add accounting tests and expose total credit/debit balance queries#276
Closed
jordanschalm wants to merge 1 commit intomainfrom
Closed
Add accounting tests and expose total credit/debit balance queries#276jordanschalm wants to merge 1 commit intomainfrom
jordanschalm wants to merge 1 commit intomainfrom
Conversation
totalCreditBalance/totalDebitBalance are updated with raw "true" amounts at deposit/withdrawal time but never compounded with interest indices. As interest accrues, individual position balances grow via scaledBalance × interestIndex, but the totals remain stale sums of point-in-time values. Test 1 proves: after 1 year at 10% rate, a 100 FLOW position grows to ~110 but totalCreditBalance stays at 100. After withdrawing 100, the position retains ~10 FLOW of accrued interest while totalCreditBalance shows 0. Test 2 proves: with multiple positions depositing at different times, the gap compounds - sum of true balances (~210) exceeds totalCreditBalance (200) by the untracked interest. Also adds getTotalCreditBalance/getTotalDebitBalance public getters on Pool, a query script, and a test helper to enable observability. https://claude.ai/code/session_01Uad8KoZo93XPhndt8Aj14B
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.
Test demonstrating behaviour of total balance fields, result is documentation updates here: #277