-
Notifications
You must be signed in to change notification settings - Fork 33
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
feat: calculate updated claimable unstaked fees in LpSugar #34
Conversation
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.
Looks great! Left some questions before we can merge it all.
contracts/LpSugar.vy
Outdated
claimable_delta1: uint256 = pool.index1() - pool.supplyIndex1(_account) | ||
|
||
if claimable_delta0 > 0: | ||
claimable0 += (acc_balance * claimable_delta0) / 10**18 |
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.
We should probably use pool.decimals()
here instead of the hardcoded 10**18
contracts/LpSugar.vy
Outdated
@@ -353,6 +357,17 @@ def _byData(_data: address[3], _account: address) -> Lp: | |||
token0: IERC20 = IERC20(pool.token0()) | |||
token1: IERC20 = IERC20(pool.token1()) | |||
gauge_alive: bool = self.voter.isAlive(gauge.address) | |||
acc_balance: uint256 = pool.balanceOf(_account) |
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.
I'm a bit concerned of the gas usage now that we're introducing these extra calls, should we skip fully the balance and claimable calculations if the _account
is 0x0...00
?
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.
Looks great!
Perform same calculation that pool._updateFor does to fetch updated claimable unstaked fees for user