@@ -217,6 +217,7 @@ interface ICLGauge:
217
217
interface INFPositionManager :
218
218
def positions (_position_id: uint256 ) -> PositionData: view
219
219
def tokenOfOwnerByIndex (_account: address , _index: uint256 ) -> uint256 : view
220
+ def balanceOf (_account: address ) -> uint256 : view
220
221
221
222
interface IReward :
222
223
def getPriorSupplyIndex (_ts: uint256 ) -> uint256 : view
@@ -626,7 +627,14 @@ def _byDataCL(_data: address[4], _token0: address, _token1: address, \
626
627
emissions_token: address = empty (address )
627
628
token0: IERC20 = IERC20 (_token0)
628
629
token1: IERC20 = IERC20 (_token1)
629
- tick_spacing: int24 = pool.tickSpacing ()
630
+ positions_count: uint256 = 0
631
+
632
+ slot: Slot = pool.slot0 ()
633
+ positions: DynArray[Position, MAX_POSITIONS] = \
634
+ empty (DynArray[Position, MAX_POSITIONS])
635
+
636
+ if _account != empty (address ):
637
+ positions_count = self .nfpm.balanceOf (_account)
630
638
631
639
if gauge.address != empty (address ):
632
640
fee_voting_reward = gauge.feesVotingReward ()
@@ -635,18 +643,11 @@ def _byDataCL(_data: address[4], _token0: address, _token1: address, \
635
643
if gauge_alive:
636
644
emissions = gauge.rewardRate ()
637
645
638
- slot: Slot = pool.slot0 ()
639
- price: uint160 = slot.sqrtPriceX96
640
-
641
- positions: DynArray[Position, MAX_POSITIONS] = \
642
- empty (DynArray[Position, MAX_POSITIONS])
643
-
644
646
for index in range (0 , MAX_POSITIONS):
645
- position_id: uint256 = self .nfpm.tokenOfOwnerByIndex (_account, index)
646
-
647
- if position_id == 0 :
647
+ if index >= positions_count:
648
648
break
649
649
650
+ position_id: uint256 = self .nfpm.tokenOfOwnerByIndex (_account, index)
650
651
position_data: PositionData = self .nfpm.positions (position_id)
651
652
652
653
emissions_earned: uint256 = 0
@@ -676,9 +677,9 @@ def _byDataCL(_data: address[4], _token0: address, _token1: address, \
676
677
decimals: 0 ,
677
678
total_supply: 0 ,
678
679
679
- type: tick_spacing ,
680
+ type: pool. tickSpacing () ,
680
681
tick: slot.tick,
681
- price: price ,
682
+ price: slot.sqrtPriceX96 ,
682
683
683
684
token0: token0.address ,
684
685
reserve0: token0.balanceOf (pool.address ),
0 commit comments