Platform: Code4rena
Start Date: 21/11/2022
Pot Size: $90,500 USDC
Total HM: 18
Participants: 101
Period: 7 days
Judge: Picodes
Total Solo HM: 4
Id: 183
League: ETH
Rank: 81/101
Findings: 1
Award: $41.63
🌟 Selected for report: 0
🚀 Solo Findings: 0
🌟 Selected for report: xiaoming90
Also found by: 0xSmartContract, 8olidity, PaludoX0, Ruhum, adriro, bin2chen, cccz, koxuan, ladboy233, pashov, poirots, rvierdiiev, unforgiven
41.6303 USDC - $41.63
https://github.com/code-423n4/2022-11-redactedcartel/blob/03b71a8d395c02324cb9fdaf92401357da5b19d1/src/vaults/AutoPxGmx.sol#L323 https://github.com/code-423n4/2022-11-redactedcartel/blob/03b71a8d395c02324cb9fdaf92401357da5b19d1/src/vaults/AutoPxGlp.sol#L184
The comments on the affected lines state previewWithdraw
will round up. However, the implementation, an inner call to convertToShares is made, which actually calls mulDivDown.
From further inspection, this pair of functions withdraw
, previewWithdraw
as well as the "rounds up" comment exists in both the base PirexERC4626 as well as AutoPxGmx
, but the latter overrides it to slightly change the logic. The superclass implementation doesn't suffer from this problem, since the original previewWithdraw
directly calls mulDivUp
, and does not delegate to convertToShares
This has all the code smells of a copy&paste oversight.
Additionally, the second previewWithdraw
implementation does one additional mathematical division that implicitly rounds down a second time.
Also, it must be said that this fees like a fragile solution. Why implement hooks on the base ERC4626 contract if those hooks are then not enough to prevent overriding whole functions in your final contracts?
Provide direct links to all referenced code in GitHub. Add screenshots, logs, or any other relevant proof that illustrates the concept.
It is unclear wether this constitutes a serious issue, or just potential for dust amounts to be left on the contract. Best case scenario: the comment is actually what's wrong, and should just be ammended to reflect the current behaviour
#0 - c4-judge
2022-12-03T22:59:36Z
Picodes marked the issue as duplicate of #264
#1 - c4-judge
2022-12-03T22:59:40Z
Picodes marked the issue as partial-50
#2 - Picodes
2022-12-03T22:59:56Z
Partial credit as the warden didn't identified any potential impact
#3 - c4-judge
2022-12-03T23:00:25Z
Picodes marked the issue as partial-25
#4 - c4-judge
2023-01-01T11:34:28Z
Picodes changed the severity to 3 (High Risk)
#5 - C4-Staff
2023-01-10T21:57:30Z
JeeberC4 marked the issue as duplicate of #264
#6 - liveactionllama
2023-01-11T18:43:03Z
Duplicate of #178