Skip to content

Conversation

@matchv
Copy link
Collaborator

@matchv matchv commented Oct 28, 2025

add up/down param to the function and its call chain:
token_base::transfer
a_token_factory::transfer
pool_token_logic::transfer

finally
liquidation_logic, rounding up a_token transfer in "liquidation -> receive a_token" path, so the amount of a_token transferred match exactly the v_token burned, so the party being liquidated will not have 1 octa or any unit of a_token left in the account.

Note:
Without this PR, when the liquidating party choose to receive a_token, the party being liquidated may have 1 octa left in the collateral asset after a full liquidation, this is an un-exploitable dust, but still it is better to align the math of "receive a_token" path with the "burn debt token" path.

…ation

- Add rounding_up: bool parameter to control rounding direction
- Use ray_div_up when rounding_up=true, ray_div when rounding_up=false
- Update liquidation collateral transfer to use rounding_up=true (favor protocol)
- Update liquidation protocol fee transfer to use rounding_up=false (favor user)
- Update function documentation and inline comments
- Fix all affected unit tests to pass new parameter
- Align with directional rounding principles and existing API patterns
- Add rounding_up: bool parameter to token_base::transfer
- Update a_token_factory::transfer_on_liquidation to use rounding parameter
- Update pool_token_logic::transfer to pass rounding_up=false for user transfers
- Update liquidation calls to use appropriate rounding:
  - Collateral transfer: rounding_up=true (favor protocol, consistent with burn)
  - Protocol fee transfer: rounding_up=false (conservative charging)
- Align with existing mint_scaled/burn_scaled API patterns
- Ensure complete liquidation without dust accumulation
@codecov
Copy link

codecov bot commented Oct 28, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 97.58%. Comparing base (ef67100) to head (cf5d102).
⚠️ Report is 5 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main      #77   +/-   ##
=======================================
  Coverage   97.58%   97.58%           
=======================================
  Files          38       38           
  Lines         786      786           
=======================================
  Hits          767      767           
  Misses         19       19           
Flag Coverage Δ
move 97.58% <ø> (ø)

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 merged commit 9291992 into main Oct 30, 2025
20 checks passed
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