Skip to content

Commit 67f60c2

Browse files
committed
Add note regarding ERC4626 fees mechanics
1 parent ea646cd commit 67f60c2

3 files changed

Lines changed: 4 additions & 5 deletions

File tree

content/contracts-cairo/3.x/api/erc20.mdx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1139,6 +1139,8 @@ Allows contracts to hook logic into deposit and withdraw transactions. This is w
11391139

11401140
ERC4626 preview methods must be inclusive of any entry or exit fees. Fees are calculated using [FeeConfigTrait](#ERC4626Component-FeeConfigTrait) methods and automatically adjust the final asset and share amounts. Fee transfers are handled in `ERC4626HooksTrait` methods.
11411141

1142+
When a vault implements fees on deposits or withdrawals (either in shares or assets), fee transfers must be handled in these hooks by library clients. This creates a non-atomic operation flow consisting of multiple state-changing steps: transferring assets, minting or burning shares, and transferring (or minting) fees. Between these steps, the vault's state is temporarily inconsistent: the asset-to-share conversion rate does not accurately reflect the vault's final state until all steps have completed. Therefore, it is critical to avoid making any external calls (including to the vault contract itself) or querying conversion rates during hook execution.
1143+
11421144
Special care must be taken when calling external contracts in these hooks. In that case, consider implementing reentrancy protections. For example, in the `withdraw` flow, the `withdraw_limit` is checked **before** the `before_withdraw` hook is invoked. If this hook performs a reentrant call that invokes `withdraw` again, the subsequent check on `withdraw_limit` will be done before the first withdrawal's core logic (e.g., burning shares and transferring assets) is executed. This could lead to bypassing withdrawal constraints or draining funds.
11431145

11441146
See the [ERC4626AssetsFeesMock](https://github.com/OpenZeppelin/cairo-contracts/tree/main/packages/test_common/src/mocks/erc4626.cairo#L253) and [ERC4626SharesFeesMock](https://github.com/OpenZeppelin/cairo-contracts/tree/main/packages/test_common/src/mocks/erc4626.cairo#L426) examples.

content/contracts-cairo/3.x/api/governance.mdx

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -186,9 +186,7 @@ Delay between when a proposal is created and when the vote starts. The unit this
186186

187187
This can be increased to leave time for users to buy voting power, or delegate it, before the voting of a proposal starts.
188188

189-
NOTE: While this function returns a u64 value, timepoints must fit into u48 according to
190-
the EIP-6372 specification. Consequently this value must fit in a u48 (when added to the
191-
current clock).
189+
While this function returns a u64 value, timepoints must fit into u48 according to the EIP-6372 specification. Consequently this value must fit in a u48 (when added to the current clock).
192190
</APIItem>
193191

194192
<APIItem

content/contracts-cairo/3.x/api/utilities.mdx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -276,8 +276,7 @@ Requirements:
276276

277277
- This function MUST always be non-decreasing.
278278

279-
NOTE: While this function returns a u64 value, timepoints must fit into u48 according to
280-
the EIP-6372 specification.
279+
While this function returns a u64 value, timepoints must fit into u48 according to the EIP-6372 specification.
281280
</APIItem>
282281

283282
<APIItem

0 commit comments

Comments
 (0)