feat: implement automated portfolio rebalancing engine#79
Merged
memplethee-lab merged 1 commit intoJun 22, 2026
Conversation
7 tasks
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.
Summary
This PR introduces a new convenience method,
get_score_age(wallet: Address, asset_pair: Symbol) -> u64, to simplify retrieval of the age of a submitted score.The function calculates the elapsed time since the last score submission using the current ledger timestamp and the stored submission timestamp. If no submission has been recorded, the function returns
u64::MAXas a sentinel value to indicate that the score has never been submitted.Changes Made
get_score_age(wallet: Address, asset_pair: Symbol) -> u64tolib.rs.u64::MAXwhenget_last_submit_time()returns0.env.ledger().timestamp().saturating_sub(last_submit_time)to safely calculate score age and avoid underflow.Testing
Added unit tests covering the following scenarios:
u64::MAXbefore any score submission exists.This addition provides a straightforward way for callers to obtain the raw age of a score without performing multiple reads or manually calculating the elapsed time. It complements the existing
is_score_stalefunctionality by exposing the underlying age value directly, improving usability for logging, monitoring, and UI display scenarios.closes #71