-
Notifications
You must be signed in to change notification settings - Fork 440
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
change add liq accounting #126
Conversation
220efb8
to
9edb230
Compare
contracts/libraries/Position.sol
Outdated
function updateTokensOwed( | ||
IBaseLiquidityManagement.Position storage position, | ||
uint128 tokensOwed0, | ||
uint128 tokensOwed1 | ||
) internal { | ||
position.tokensOwed0 = tokensOwed0; | ||
position.tokensOwed1 = tokensOwed1; | ||
} |
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.
Ive been thinking about moving tokensOwed0/tokensOwed1
to a BalanceDelta
type. iirc we almost always handle the two as a pair
maybe we're over-using the type, but i like it a lot haha
(token0Owed) = FeeMath.getFeeOwed(feeGrowthInside0X128, position.feeGrowthInside0LastX128, position.liquidity); | ||
(token1Owed) = FeeMath.getFeeOwed(feeGrowthInside1X128, position.feeGrowthInside1LastX128, position.liquidity); |
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.
any reason why to call this twice vs the getFeesOwed
which returns both?
BalanceDelta totalFeesAccrued, | ||
BalanceDelta callerFeesAccrued, | ||
PoolKey memory poolKey | ||
) internal returns (int128 callerDelta0, int128 callerDelta1) { |
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.
another candidate to move the return type to BalanceDelta ?
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.
directionally i think its getting there. makes a lot of sense to separately handle callerDeltas vs externalDeltas and remove PM currency transfers within the operation functions (_increaseLiq, _decreaseLiq, _collect). feels like we can reduce the round trips to PM
have picked up on some edge cases we might need to think thru:
int128 delta0 = int128(manager.currencyDelta(address(this), currency0)); | ||
int128 delta1 = int128(manager.currencyDelta(address(this), currency1)); |
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.
you can use CurrencyDeltas, which uses sparse extload to load both deltas in a single external call 😎
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.
nice!
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.
can we move that function to TransientStateLibrary.sol ?
* additional increase liquidity tests * edge case of using cached fees for autocompound * wip
* fix some assertions * use BalanceDeltas for arithmetic * cleanest code in the game??? * additional cleaning * typo lol * autocompound gas benchmarks * autocompound excess credit gas benchmark * save 600 gas, cleaner code when moving caller delta to tokensOwed
Related Issue
Which issue does this pull request resolve?
Description of changes