Skip to content

refactor(positions): extract scale_by_bps helper for readability#236

Open
Mmesolove wants to merge 1 commit into
Vatix-Protocol:devfrom
Mmesolove:refactor/fee-calculation-readability
Open

refactor(positions): extract scale_by_bps helper for readability#236
Mmesolove wants to merge 1 commit into
Vatix-Protocol:devfrom
Mmesolove:refactor/fee-calculation-readability

Conversation

@Mmesolove
Copy link
Copy Markdown

@Mmesolove Mmesolove commented Jun 1, 2026

closes #166

Summary

Extracts the repeated checked_mul / checked_div(BASIS_POINTS) chain in calculate_locked_collateral into a private scale_by_bps(amount, price_bps) helper.

Changes

  • positions.rs: new private scale_by_bps helper; both branches of calculate_locked_collateral reduced to a single expression each

No behavior change

Arithmetic is identical — same overflow semantics, same results for all inputs. All existing tests cover the refactored paths unchanged.

Checklist

  • No behavior change
  • Clippy clean (CI enforces -D warnings)

No behavior change. The repeated checked_mul/checked_div chain in
calculate_locked_collateral is extracted into a private scale_by_bps
helper, making both branches a single readable expression.
@Mmesolove
Copy link
Copy Markdown
Author

please review

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.

[topup] [contracts] Refactor fee calculation for readability

1 participant