-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix Doppler Fee Disbursement #331
Fix Doppler Fee Disbursement #331
Conversation
src/Doppler.sol
Outdated
uint256 extraBalance0 = poolKey.currency0.balanceOfSelf(); | ||
uint256 extraBalance1 = poolKey.currency1.balanceOfSelf(); | ||
poolKey.currency0.transfer(recipient, extraBalance0); | ||
poolKey.currency1.transfer(recipient, extraBalance1); | ||
|
||
(sqrtPriceX96,,,) = poolManager.getSlot0(poolKey.toId()); | ||
token0 = Currency.unwrap(poolKey.currency0); | ||
token1 = Currency.unwrap(poolKey.currency1); | ||
|
||
// No need to safe cast since these amounts will always be positive | ||
fees0 = uint128(totalFeesAccrued.amount0()); | ||
balance0 = uint128(totalCallerDelta.amount0()); | ||
balance0 = uint128(slugCallerDelta.amount0()) + extraBalance0.toUint128(); | ||
fees1 = uint128(totalFeesAccrued.amount1()); | ||
balance1 = uint128(totalCallerDelta.amount1()); | ||
balance1 = uint128(slugCallerDelta.amount1()) + extraBalance1.toUint128(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Im a slightly worried about the extraBalance.toUint128()
-- if it reverts on overflow, were gonna brick migrations and have stuck capital
the question is -- is there a scenario where the unaccounted for balances (i.e. rebalanced slug dust, accrued fees, excess tokens, etc would exceed uint128.max 🤔
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the safety precaution might be to set balance0 = uint128.max
if its gonna overflow, so that migrations can still happen?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems to be an edge case but I think it's best to cover it just in case.
@clemlak ready for review again, i think tests are failing since im not apart of the repo |
Yes, these tests are failing due to a missing RPC in your fork, everything looks good on my end 👌 |
Doppler was collecting fees during rebalancing and NOT using them towards new slugs. Additionally, only the last set of slugs were transferred in migration
This lead to unaccounted for fees during migrations, leaving tokens in Airlock that were unrecoverable
Closes #321, #325, #314