Skip to content
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

Merged
merged 4 commits into from
Nov 15, 2023
Merged

Conversation

ethzoomer
Copy link
Contributor

Perform same calculation that pool._updateFor does to fetch updated claimable unstaked fees for user

@ethzoomer ethzoomer requested a review from stas November 15, 2023 05:13
Copy link
Collaborator

@stas stas left a 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.

claimable_delta1: uint256 = pool.index1() - pool.supplyIndex1(_account)

if claimable_delta0 > 0:
claimable0 += (acc_balance * claimable_delta0) / 10**18
Copy link
Collaborator

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

@@ -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)
Copy link
Collaborator

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 ?

@ethzoomer ethzoomer requested a review from stas November 15, 2023 17:58
Copy link
Collaborator

@stas stas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great!

@ethzoomer ethzoomer merged commit c30be94 into v2 Nov 15, 2023
0 of 2 checks passed
@stas stas deleted the SOL-218 branch January 16, 2024 00:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants