Skip to content

Commit 1797deb

Browse files
authored
feat: use gauge's weekly fees for pool fees calculation (#47)
* feat: use gauge's weekly fees for pool fees calculation * refactor: remove redundant pool supply check * docs: latest deployment address
1 parent 1f2638d commit 1797deb

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

contracts/LpSugar.vy

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -481,6 +481,7 @@ def _byData(_data: address[3], _token0: address, _token1: address, _account: add
481481

482482
earned: uint256 = 0
483483
acc_staked: uint256 = 0
484+
pool_total_supply: uint256 = pool.totalSupply()
484485
gauge_total_supply: uint256 = 0
485486
emissions: uint256 = 0
486487
emissions_token: address = empty(address)
@@ -489,6 +490,8 @@ def _byData(_data: address[3], _token0: address, _token1: address, _account: add
489490
pool_fees: address = pool.poolFees()
490491
token0: IERC20 = IERC20(_token0)
491492
token1: IERC20 = IERC20(_token1)
493+
token0_fees: uint256 = token0.balanceOf(pool_fees)
494+
token1_fees: uint256 = token1.balanceOf(pool_fees)
492495
gauge_alive: bool = self.voter.isAlive(gauge.address)
493496
decimals: uint8 = pool.decimals()
494497
claimable0: uint256 = 0
@@ -507,6 +510,9 @@ def _byData(_data: address[3], _token0: address, _token1: address, _account: add
507510

508511
if gauge_alive:
509512
emissions = gauge.rewardRate()
513+
if gauge_total_supply > 0:
514+
token0_fees = (pool.claimable0(_data[2]) * pool_total_supply) / gauge_total_supply
515+
token1_fees = (pool.claimable1(_data[2]) * pool_total_supply) / gauge_total_supply
510516

511517
if _account != empty(address):
512518
acc_balance = pool.balanceOf(_account)
@@ -542,7 +548,7 @@ def _byData(_data: address[3], _token0: address, _token1: address, _account: add
542548
lp: _data[1],
543549
symbol: pool.symbol(),
544550
decimals: decimals,
545-
total_supply: pool.totalSupply(),
551+
total_supply: pool_total_supply,
546552

547553
nft: empty(address),
548554
type: type,
@@ -568,8 +574,8 @@ def _byData(_data: address[3], _token0: address, _token1: address, _account: add
568574

569575
pool_fee: pool_fee,
570576
unstaked_fee: 0,
571-
token0_fees: token0.balanceOf(pool_fees),
572-
token1_fees: token1.balanceOf(pool_fees),
577+
token0_fees: token0_fees,
578+
token1_fees: token1_fees,
573579

574580
alm_vault: empty(address),
575581
alm_reserve0: 0,

readme.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ Below is the list of datasets we support.
3535

3636
### Liquidity Pools Data
3737

38-
`LpSugar.vy` is deployed at `0x3c971c178Bb0697F3D59CC043855e96f389dF61c`
38+
`LpSugar.vy` is deployed at `0x7Aa598dec373d63B16060cFDB6cC6ff7a2e86fAd`
3939

4040
It allows fetching on-chain pools data.
4141
The returned data/struct of type `Lp` values represent:

0 commit comments

Comments
 (0)