Skip to content

Conversation

@matchv
Copy link
Collaborator

@matchv matchv commented Oct 14, 2025

withdraw: ray_mul => ray_mul_down to round down user's asset balance.

Apply directional rounding for conservative withdrawal balance calculation.

Changes:
- Calculate user_balance using ray_mul_down instead of ray_mul in withdraw function
- Modified: supply_logic.move line 199-206

Rationale:
- User withdrawal balance should never be overestimated for protocol safety
- Conservative calculation prevents users from withdrawing more than actual balance
- Consistent with a_token_factory::balance_of behavior
- Aligns with Solidity Aave V3 implementation pattern

Impact:
- Withdrawal balance calculations become more conservative
- User may need to query real-time balance for complete withdrawal
- Better protection against over-withdrawal scenarios
- Consistent with balance_of external API behavior
@codecov
Copy link

codecov bot commented Oct 14, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 97.70%. Comparing base (32aa70b) to head (894edeb).

Additional details and impacted files
@@                     Coverage Diff                     @@
##           mike/improve/generic-logic      #70   +/-   ##
===========================================================
  Coverage                       97.70%   97.70%           
===========================================================
  Files                              38       38           
  Lines                             785      785           
===========================================================
  Hits                              767      767           
  Misses                             18       18           
Flag Coverage Δ
move 97.70% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@matchv matchv closed this Oct 21, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants