-
Notifications
You must be signed in to change notification settings - Fork 11
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
Pack BucketState struct into a single slot #645
Conversation
* Add Position struct to keep lps and deposit time of memorialized position. remove positionLPs and positionDepositTime mappings, keep only one positions mapping to Position struct Emit events at the end of functions Small gas improvements by reusing pool address / reading only once from storage Rename RemoveLiquidityFailed error to RemovePositionFailed * Approve and reset partial LPs Consistent naming LPs, replaced all LP tokens occurences * Change transferLps to allow partial transfer of deposit, transfer the min(approvedAmount, availableAmount), account bucket bankruptcy on new owner Add tests * changes after review - create IPool only once
…at memorialized indexes
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.
lgtm. I don't see any downsides to limiting LPB to 127 bits.
since we're packing this with bucket rate we could increase the uint128 for LPs and reduce the one for rate? (I suspect uint128 for rate is huge but we'd like to be safer for lps?) |
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 description's comment about token supply doesn't seem relevant, because neither field stores a token balance. If exchange rates get too low, LPs will go to infinity. That said, we have bigger problems if the exchange rate goes to 0. Since this is isolated to the rewards contract, I'm fine with it.
Description of change
High level
Gas usage
Pre Change
Post Change