Skip to content

Commit fd6c9a1

Browse files
committed
feat: calculate updated claimable unstaked fees in LpSugar
1 parent c3f2a8d commit fd6c9a1

File tree

1 file changed

+18
-3
lines changed

1 file changed

+18
-3
lines changed

contracts/LpSugar.vy

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,10 @@ interface IPool:
107107
def reserve1() -> uint256: view
108108
def claimable0(_account: address) -> uint256: view
109109
def claimable1(_account: address) -> uint256: view
110+
def supplyIndex0(_account: address) -> uint256: view
111+
def supplyIndex1(_account: address) -> uint256: view
112+
def index0() -> uint256: view
113+
def index1() -> uint256: view
110114
def totalSupply() -> uint256: view
111115
def symbol() -> String[100]: view
112116
def decimals() -> uint8: view
@@ -353,6 +357,17 @@ def _byData(_data: address[3], _account: address) -> Lp:
353357
token0: IERC20 = IERC20(pool.token0())
354358
token1: IERC20 = IERC20(pool.token1())
355359
gauge_alive: bool = self.voter.isAlive(gauge.address)
360+
acc_balance: uint256 = pool.balanceOf(_account)
361+
362+
claimable0: uint256 = pool.claimable0(_account)
363+
claimable1: uint256 = pool.claimable1(_account)
364+
claimable_delta0: uint256 = pool.index0() - pool.supplyIndex0(_account)
365+
claimable_delta1: uint256 = pool.index1() - pool.supplyIndex1(_account)
366+
367+
if claimable_delta0 > 0:
368+
claimable0 += (acc_balance * claimable_delta0) / 10**18
369+
if claimable_delta1 > 0:
370+
claimable1 += (acc_balance * claimable_delta1) / 10**18
356371

357372
if gauge.address != empty(address):
358373
acc_staked = gauge.balanceOf(_account)
@@ -372,11 +387,11 @@ def _byData(_data: address[3], _account: address) -> Lp:
372387

373388
token0: token0.address,
374389
reserve0: pool.reserve0(),
375-
claimable0: pool.claimable0(_account),
390+
claimable0: claimable0,
376391

377392
token1: token1.address,
378393
reserve1: pool.reserve1(),
379-
claimable1: pool.claimable1(_account),
394+
claimable1: claimable1,
380395

381396
gauge: gauge.address,
382397
gauge_total_supply: gauge_total_supply,
@@ -389,7 +404,7 @@ def _byData(_data: address[3], _account: address) -> Lp:
389404
emissions: emissions,
390405
emissions_token: emissions_token,
391406

392-
account_balance: pool.balanceOf(_account),
407+
account_balance: acc_balance,
393408
account_earned: earned,
394409
account_staked: acc_staked,
395410

0 commit comments

Comments
 (0)