You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* Refactor ERC-4626 component to pass calculated fee value to hooks
* Support ERC-4626 changes in mocks
* Rename Fee to FeeConfig, run linter
* Support fees in shares
* Update ERC-4626 mocks, add a mock for fees in shares
* Support ERC-4626 fees changes in tests
* Support changes in mocks and tests
* Fix ERC4626 impl names
* Some improvements to ERC4626 mocks
* Update ERC4626 doc about fees
* Update ERC4626 API reference
* Update ERC4626 fees section doc
* Update ERC4626 FeeConfigTrait functions in-code doc
* Update ERC4626Hooks trait doc, incorporating additional function parameters added
* Switch functions order in ERC4626Hooks trait
* Minor improvements to ERC4626 mocks
* Lint files
* Fix doc inconsistencies
* Support ERC4626 changes in macros
* Lint files
* Remove unused imports in ERC4626 mock
* Improve doc for FeeConfigTrait functions
* Update FeeConfigTrait functions doc in API reference
* Document internal preview functions, solve TODOs
* Improve ERC4626Hooks and FeeConfigTrait docs
* Add changelog entry
* Lint files
In ERC4626 vaults, fees can be captured during deposit/mint and/or withdraw/redeem operations. It is essential to remain
204
+
compliant with the ERC4626 requirements regarding the preview functions. Fees are calculated through the {fee_config_trait}
205
+
implementation. By default, the ERC4626 component charges no fees. If this is the desired behavior, you can use the default
206
+
{no_fees_impl} implementation.
207
+
208
+
NOTE: Starting from v3.0.0, fees can be charged in either assets or shares. Prior versions only supported fees taken in assets.
209
+
See the updated {fee_config_trait} and implementation examples in {erc4626_mocks}.
201
210
202
211
For example, if calling `deposit(100, receiver)`, the caller should deposit exactly 100 underlying tokens, including fees, and the receiver should receive a number of shares that matches the value returned by `preview_deposit(100)`.
203
212
Similarly, `preview_mint` should account for the fees that the user will have to pay on top of share's cost.
@@ -213,29 +222,29 @@ The `Withdraw` event should include the number of shares the user burns (includi
213
222
The consequence of this design is that both the `Deposit` and `Withdraw` events will describe two exchange rates.
214
223
The spread between the "Buy-in" and the "Exit" prices correspond to the fees taken by the vault.
215
224
216
-
The following example describes how fees proportional to the deposited/withdrawn amount can be implemented:
225
+
The following example describes how fees taken in assets on deposits/withdrawals and in shares on mints/redemptions
226
+
proportional to the deposited/withdrawn amount can be implemented:
217
227
218
228
```cairo
219
-
/// The mock contract charges fees in terms of assets, not shares.
220
-
/// This means that the fees are calculated based on the amount of assets that are being deposited
221
-
/// or withdrawn, and not based on the amount of shares that are being minted or redeemed.
229
+
/// The mock contract charges fees in assets on deposits and withdrawals and in shares on mints and
230
+
/// redemptions.
222
231
/// This is an opinionated design decision for the purpose of testing.
223
232
/// DO NOT USE IN PRODUCTION
224
233
#[starknet::contract]
234
+
#[with_components(ERC20, ERC4626)]
225
235
pub mod ERC4626Fees {
226
-
use openzeppelin_token::erc20::extensions::erc4626::ERC4626Component;
227
-
use openzeppelin_token::erc20::extensions::erc4626::ERC4626Component::FeeConfigTrait;
228
-
use openzeppelin_token::erc20::extensions::erc4626::ERC4626Component::InternalTrait as ERC4626InternalTrait;
229
-
use openzeppelin_token::erc20::extensions::erc4626::{DefaultConfig, ERC4626DefaultLimits};
230
236
use openzeppelin_interfaces::erc20::{IERC20Dispatcher, IERC20DispatcherTrait};
231
-
use openzeppelin_token::erc20::{ERC20Component, ERC20HooksEmptyImpl};
237
+
use openzeppelin_token::erc20::extensions::erc4626::ERC4626Component::{Fee, FeeConfigTrait};
238
+
use openzeppelin_token::erc20::extensions::erc4626::{
0 commit comments