Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #1170 +/- ##
==========================================
- Coverage 92.26% 89.41% -2.86%
==========================================
Files 59 81 +22
Lines 1811 3496 +1685
==========================================
+ Hits 1671 3126 +1455
- Misses 140 370 +230
... and 78 files with indirect coverage changes Continue to review full report in Codecov by Sentry.
|
ericnordelo
left a comment
There was a problem hiding this comment.
Great work @andrew-fleming! Left some non-blocking suggestions.
| asset_address: ContractAddress, shares: u256, recipient: ContractAddress, | ||
| ) -> ERC4626ABIDispatcher { | ||
| let fee_basis_points = 500_u256; // 5% | ||
| let _value_without_fees = 10_000_u256; |
There was a problem hiding this comment.
No good reason. Fixed!
| let fee_basis_points = 500_u256; // 5% | ||
| let _value_without_fees = 10_000_u256; | ||
| let _fees = (_value_without_fees * fee_basis_points) / 10_000_u256; | ||
| let _value_with_fees = _value_without_fees - _fees; |
There was a problem hiding this comment.
Nope, fixed!
Co-authored-by: Eric Nordelo <eric.nordelo39@gmail.com>
|
@ericnordelo when we have |
immrsd
left a comment
There was a problem hiding this comment.
Good job, left a few minor suggestions
Co-authored-by: immrsd <103599616+immrsd@users.noreply.github.com>
ericnordelo
left a comment
There was a problem hiding this comment.
Left two extra small suggestions, but besides looks ready to be merged.
Co-authored-by: Eric Nordelo <eric.nordelo39@gmail.com>
immrsd
left a comment
There was a problem hiding this comment.
Great job on making the last improvements! Left a single tiny suggestion
Co-authored-by: immrsd <103599616+immrsd@users.noreply.github.com>
Fixes #277
PR Checklist
[ ] DocumentationAdd erc4626 docs #1244...still a WIP. The tests need to be refactored and improved. The idea was to make sure the logic works as expected so there's a standard (from the openzeppelin solidity tests) for any and all changes moving forward.Some things to note and discuss:
Decimals
EIP4626 states at the end of the doc:
The OpenZeppelin solidity implementation checks for the underlying asset's tokens upon construction with a try/catch which defaults to
18decimals if query fails. Given Starknet's current status with try/catch (✌️ dual dispatchers), this doesn't seem like a viable approach. If the vault is for an undeployed token, the deployment will fail. This PR proposes that the decimals (both underlying decimals and offset decimals) are explicitly defined by the contract through the ImmutableConfig.Math
u512 Precision math for multiply and divide (
u256_mul_div)This PR leverages the corelib's
wide_mulandu512_safe_div_rem_by_u256for mathematical precision. This is set as a tmp solution and should be scrutinized further. More tests should be provided and we should look for ways to optimize.Exponentiation
This PR requires exponentiation for converting to shares and assets. The current implementation is the brute force formula. We can definitely improve this.This was added to the corelib (starkware-libs/cairo#6694).
Will update when releasedUpdated.FeeConfigTrait
This PR proposes to utilize
FeeConfigTrait(which is really like a hook) for contracts to integrate entry and exit fees forpreview_fns. The state-changing methods of ERC4626 rely onpreview_to determine the number of assets or shares to exchange.Another approach that can reduce the verbosity of the traits/hooks is to have a single
adjust_assets_or_sharesfunction that accepts anExchangeType.The downside though is I think it's easy to misuse i.e.
IMO having a dedicated function for each exchange type is more difficult to mess up...but it's at the cost of some verbosity.
LimitsConfigTrait
This mirrors the
FeeConfigTraitexcept that these target the limits on themax_methods and return anOptionsoOption::Nonecan point to the default. Same arguments apply for not having a single trait/hook with anExchangeTypeparameter.before_withdrawandafter_deposithooksThe
before_withdrawandafter_deposithooks take inspiration from solmate's solidity implementation of erc4626. These hooks are where contracts can transfer fees calculated from theFeeConfigTraitin the implementing contract. See the Fees mock to see how this works in the proposed PR.