Fix/issues 709 726 729 731 - #737
Merged
gboigwe merged 2 commits intoJul 27, 2026
Merged
Conversation
- liquidity-pool: add checked_add overflow guard on due_at and cap duration_secs to MAX_DURATION_SECS (1 year) to prevent permanently locked loans Closes ThinkLikeAFounder#731 - rewards-distributor: apply 10_000 bps scaling factor in claim_rewards vested_total calculation to prevent integer division truncating small rewards to 0 for long vesting schedules Closes ThinkLikeAFounder#729 - governance-token: implement take_snapshot and get_voting_snapshot functions that store voter balance + delegated power at a given ledger sequence, eliminating the dead VotingSnapshot DataKey and closing the flash-loan attack vector Closes ThinkLikeAFounder#709 - milestone-tracker: add permissionless mark_missed function allowing anyone to finalize an expired milestone as Missed when the oracle is offline or throttled, unblocking downstream gated logic Closes ThinkLikeAFounder#726
and ThinkLikeAFounder#726 - governance-token: implement take_snapshot and get_voting_snapshot functions that write/read the VotingSnapshot(Address, u32) DataKey, storing voter balance + delegated power at a given ledger sequence. Eliminates the dead DataKey variant and closes the flash-loan attack vector in governance voting Closes ThinkLikeAFounder#709 - milestone-tracker: add permissionless mark_missed(milestone_id) function that anyone can call once a milestone deadline has passed and the milestone is not already finalized (Achieved or Missed). Unblocks downstream logic when oracle is offline or throttled Closes ThinkLikeAFounder#726
|
@OlaGreat Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits. You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀 |
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.
This PR addresses four bugs spanning the liquidity-pool, rewards-distributor, governance-token, and milestone-tracker contracts.
liquidity-pool — borrow due_at overflow guard
borrow computed the loan due date with a raw u64 addition. A duration_secs value near u64::MAX would silently wrap to a small past timestamp, making the loan appear immediately overdue on creation. Added a checked_add with a panic on overflow, and capped duration_secs to MAX_DURATION_SECS (1 year / 31,557,600 seconds) to prevent permanently locked loans.
Closes #731
rewards-distributor — vested_total integer division truncation
claim_rewards computed vested_total with a bare u128 division. For users with small total_earned and long vesting_duration, the numerator stayed below the denominator for weeks or months, truncating to 0 and making tokens unclaimable. Applied a 10_000 bps scaling factor before the division and divided back after, preserving sub-unit precision.
Closes #729
governance-token — VotingSnapshot dead code, feature unimplemented
DataKey::VotingSnapshot(Address, u32) existed in the enum but was never read or written by any function, leaving the entire voting snapshot feature missing. Implemented take_snapshot(env, voter, ledger_sequence) which stores the voter's balance + delegated_power (or 0 if they have delegated away) at the specified ledger sequence, and get_voting_snapshot(env, voter, ledger_sequence) -> Option to retrieve it. Governance-dao can now use snapshot balances during vote casting to close the flash-loan attack vector.
Closes #709
milestone-tracker — no mark_missed function
The only path to Missed status was through the oracle calling update_progress after the deadline. If the oracle went offline or was throttled, expired milestones stayed in Pending or InProgress indefinitely with no recourse. Added a permissionless mark_missed(env, milestone_id) function — anyone can call it once the deadline has passed; it panics if the milestone is already finalized (Achieved or Missed) or if the deadline has not yet elapsed.
Closes #726