ERC-4626 Pass fee to hooks
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
feeparam (Breaking) - Change the internal
_depositand_withdrawfns by adding thefeeparam (Breaking) - Introduce a helper
Previewstruct to aggregate the calculated preview values:net_assets,fee, andshares - Introduce 4 internal helper fns:
_preview_deposit,_preview_mint,_preview_withdraw, andpreview_redeem
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 dataPowered 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.
The recent changes support charging fees in shares and include a mock with an example implementation for this use case