Skip to content

Fix/issues 709 726 729 731 - #737

Merged
gboigwe merged 2 commits into
ThinkLikeAFounder:mainfrom
OlaGreat:fix/issues-709-726-729-731
Jul 27, 2026
Merged

Fix/issues 709 726 729 731#737
gboigwe merged 2 commits into
ThinkLikeAFounder:mainfrom
OlaGreat:fix/issues-709-726-729-731

Conversation

@OlaGreat

Copy link
Copy Markdown
Contributor

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

OlaGreat added 2 commits July 27, 2026 19:34
- 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
@drips-wave

drips-wave Bot commented Jul 27, 2026

Copy link
Copy Markdown

@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! 🚀

Learn more about application limits

@gboigwe
gboigwe merged commit a54bc3d into ThinkLikeAFounder:main Jul 27, 2026
2 of 4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment