@@ -139,6 +139,7 @@ interface IPoolFactory:
139
139
def allPoolsLength () -> uint256 : view
140
140
def allPools (_index: uint256 ) -> address : view
141
141
def getFee (_pool_addr: address , _stable: bool ) -> uint256 : view
142
+ def getPool (_token0: address , _token1: address , _fee: uint24 ) -> address : view
142
143
143
144
interface IPool :
144
145
def token0 () -> address : view
@@ -153,17 +154,13 @@ interface IPool:
153
154
def stable () -> bool : view
154
155
def balanceOf (_account: address ) -> uint256 : view
155
156
def poolFees () -> address : view
156
-
157
- interface IV3Pool :
158
- def token0 () -> address : view
159
- def token1 () -> address : view
160
- def gauge () -> address : view
161
- def nft () -> address : view
162
- def tickSpacing () -> int24 : view
163
- def slot0 () -> Slot: view
164
- def gaugeFees () -> GaugeFees: view
165
- def fee () -> uint24 : view
166
- def unstakedFee () -> uint24 : view
157
+ def gauge () -> address : view # fetches gauge from v3 pool
158
+ def nft () -> address : view # fetches nft address from v3 pool
159
+ def tickSpacing () -> int24 : view # v3 tick spacing
160
+ def slot0 () -> Slot: view # v3 slot data
161
+ def gaugeFees () -> GaugeFees: view # v3 gauge fees amounts
162
+ def fee () -> uint24 : view # v3 fee level
163
+ def unstakedFee () -> uint24 : view # v3 unstaked fee level
167
164
168
165
interface IVoter :
169
166
def gauges (_pool_addr: address ) -> address : view
@@ -297,27 +294,25 @@ def forSwaps(_limit: uint256, _offset: uint256) -> DynArray[SwapLp, MAX_POOLS]:
297
294
break
298
295
299
296
pool_addr: address = factory.allPools (pindex)
297
+ pool: IPool = IPool (pool_addr)
300
298
type: int24 = - 1
301
- token0: address = empty ( address )
302
- token1: address = empty ( address )
299
+ token0: address = pool. token0 ( )
300
+ token1: address = pool. token1 ( )
303
301
reserve0: uint256 = 0
304
302
305
- # to-do: create preferred way of differentiating between v2 and v3 pools
306
303
is_cl_pool: bool = False
304
+ is_stable: bool = factory.getPool (token0, token1, 0 ) == pool_addr
305
+
306
+ if not is_stable and factory.getPool (token0, token1, 1 ) != pool_addr:
307
+ is_cl_pool = True
307
308
308
309
if is_cl_pool:
309
- pool: IV3Pool = IV3Pool (pool_addr)
310
310
type = pool.tickSpacing ()
311
- token0 = pool.token0 ()
312
- token1 = pool.token1 ()
313
311
reserve0 = IERC20 (token0).balanceOf (pool_addr)
314
312
315
313
else :
316
- pool: IPool = IPool (pool_addr)
317
- if pool.stable ():
314
+ if is_stable:
318
315
type = 0
319
- token0 = pool.token0 ()
320
- token1 = pool.token1 ()
321
316
reserve0 = pool.reserve0 ()
322
317
323
318
if reserve0 > 0 :
@@ -403,8 +398,16 @@ def all(_limit: uint256, _offset: uint256, _account: address) \
403
398
if len (col) == _limit or index >= pools_count:
404
399
break
405
400
406
- # to-do: create preferred way of differentiating between v2 and v3 pools
401
+ pool: IPool = IPool (pools[index][1 ])
402
+ factory: IPoolFactory = IPoolFactory (pools[index][0 ])
403
+ token0: address = pool.token0 ()
404
+ token1: address = pool.token1 ()
405
+
407
406
is_cl_pool: bool = False
407
+ is_stable: bool = factory.getPool (token0, token1, 0 ) == pools[index][1 ]
408
+
409
+ if not is_stable and factory.getPool (token0, token1, 1 ) != pools[index][1 ]:
410
+ is_cl_pool = True
408
411
409
412
if is_cl_pool:
410
413
col.append (self ._byDataCL (pools[index], _account))
@@ -424,8 +427,16 @@ def byIndex(_index: uint256, _account: address) -> Lp:
424
427
"""
425
428
pools: DynArray[address [3 ], MAX_POOLS] = self ._pools ()
426
429
427
- # to-do: create preferred way of differentiating between v2 and v3 pools
430
+ pool: IPool = IPool (pools[_index][1 ])
431
+ factory: IPoolFactory = IPoolFactory (pools[_index][0 ])
432
+ token0: address = pool.token0 ()
433
+ token1: address = pool.token1 ()
434
+
428
435
is_cl_pool: bool = False
436
+ is_stable: bool = factory.getPool (token0, token1, 0 ) == pools[_index][1 ]
437
+
438
+ if not is_stable and factory.getPool (token0, token1, 1 ) != pools[_index][1 ]:
439
+ is_cl_pool = True
429
440
430
441
if is_cl_pool:
431
442
return self ._byDataCL (pools[_index], _account)
@@ -529,7 +540,7 @@ def _byDataCL(_data: address[3], _account: address) -> Lp:
529
540
@param _account The user account
530
541
@return Lp struct
531
542
"""
532
- pool: IV3Pool = IV3Pool (_data[1 ])
543
+ pool: IPool = IPool (_data[1 ])
533
544
gauge: ICLGauge = ICLGauge (_data[2 ])
534
545
nft: INFTPositionManager = INFTPositionManager (pool.nft ())
535
546
0 commit comments