cairo-contracts icon indicating copy to clipboard operation
cairo-contracts copied to clipboard

ERC-4626 Pass fee to hooks

Open immrsd opened this issue 7 months ago • 2 comments

This PR shows the draft implementation of the improvement that enables passing the calculated deposit/withdraw fee in ERC-4626 component to avoid recalculation in the implementing contract.

The following changes were required to support it:

  • Change the hooks by adding the fee param (Breaking)
  • Change the internal _deposit and _withdraw fns by adding the fee param (Breaking)
  • Introduce a helper Preview struct to aggregate the calculated preview values: net_assets, fee, and shares
  • Introduce 4 internal helper fns: _preview_deposit, _preview_mint, _preview_withdraw, and preview_redeem

immrsd avatar Jun 10 '25 08:06 immrsd

Codecov Report

:x: Patch coverage is 78.00000% with 11 lines in your changes missing coverage. Please review. :white_check_mark: Project coverage is 92.40%. Comparing base (13855ce) to head (f53e1bb). :warning: Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
...s/token/src/erc20/extensions/erc4626/erc4626.cairo 78.00% 11 Missing :warning:
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1452      +/-   ##
==========================================
- Coverage   92.66%   92.40%   -0.27%     
==========================================
  Files          82       82              
  Lines        2237     2265      +28     
==========================================
+ Hits         2073     2093      +20     
- Misses        164      172       +8     
Files with missing lines Coverage Δ
...s/token/src/erc20/extensions/erc4626/erc4626.cairo 83.21% <78.00%> (-2.88%) :arrow_down:

Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update 13855ce...f53e1bb. Read the comment docs.

:rocket: New features to boost your workflow:
  • :snowflake: Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

codecov[bot] avatar Jun 10 '25 09:06 codecov[bot]

The recent changes support charging fees in shares and include a mock with an example implementation for this use case

immrsd avatar Jun 27 '25 08:06 immrsd