Release: develop -> main - #130
Merged
Merged
Conversation
…efresh (#129) * Read isClosed and principal live from chain in positions refresh The positions refresh already overwrites collateralBalance, virtualPrice and interest with the live contract state but copied closed and principal verbatim from the indexer. The indexer only updates those two fields in its MintingUpdate handler, so a position whose last MintingUpdate never reached the index stayed open with a stale principal in /positions/list and /positions/open although the contract reported it as closed with zero debt. Read isClosed() and principal() per position in the same batched refresh and fall back to the indexed values only when the RPC call fails. * Keep closed monotonic when merging indexed and live flag closed is only ever set to true on-chain, so OR the indexed flag with the live isClosed() result instead of replacing it. A stale read from an eventually consistent RPC node can then never reopen a position that the index already knows as closed. * Clarify comment on live principal and closed reads State the motivation once and spell out that principal replaces the indexed value while closed is OR-ed with it. * Keep an observed closed flag across refresh cycles The indexed closed flag is fetched fresh on every refresh, so a failed live read in a later cycle would have dropped a closure that an earlier cycle had already observed. OR the previously cached flag into the merge so that a position seen as closed stays closed. --------- Co-authored-by: TaprootFreakAI <315477232+TaprootFreakAI@users.noreply.github.com>
TaprootFreak
approved these changes
Aug 31, 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.
Automatic Release PR
This PR was automatically created after changes were pushed to develop.
Commits: 1 new commit(s)
Checklist