@@ -86,12 +86,9 @@ math_implementation: public(address)
86
86
# mapping of coins -> pools for trading
87
87
# a mapping key is generated for each pair of addresses via
88
88
# `bitwise_xor(convert(a, uint256), convert(b, uint256))`
89
- markets: HashMap[uint256 , address [4294967296 ]]
90
- market_counts: HashMap[uint256 , uint256 ]
91
-
92
- pool_count: public (uint256 ) # actual length of pool_list
89
+ markets: HashMap[uint256 , DynArray[address , 4294967296 ]]
93
90
pool_data: HashMap[address , PoolArray]
94
- pool_list: public (address [ 4294967296 ]) # master list of pools
91
+ pool_list: public (DynArray[ address , 4294967296 ]) # master list of pools
95
92
96
93
97
94
@external
@@ -203,9 +200,8 @@ def deploy_pool(
203
200
)
204
201
205
202
# populate pool data
206
- length: uint256 = self .pool_count
207
- self .pool_list[length] = pool
208
- self .pool_count = length + 1
203
+ self .pool_list.append (pool)
204
+
209
205
self .pool_data[pool].decimals = decimals
210
206
self .pool_data[pool].coins = _coins
211
207
self .pool_data[pool].implementation = pool_implementation
@@ -237,10 +233,7 @@ def _add_coins_to_market(coin_a: address, coin_b: address, pool: address):
237
233
key: uint256 = (
238
234
convert (coin_a, uint256 ) ^ convert (coin_b, uint256 )
239
235
)
240
-
241
- length: uint256 = self .market_counts[key]
242
- self .markets[key][length] = pool
243
- self .market_counts[key] = length + 1
236
+ self .markets[key].append (pool)
244
237
245
238
246
239
@external
@@ -378,6 +371,16 @@ def find_pool_for_coins(_from: address, _to: address, i: uint256 = 0) -> address
378
371
# <--- Pool Getters --->
379
372
380
373
374
+ @view
375
+ @external
376
+ def pool_count () -> uint256 :
377
+ """
378
+ @notice Get number of pools deployed from the factory
379
+ @return Number of pools deployed from factory
380
+ """
381
+ return len (self .pool_list)
382
+
383
+
381
384
@view
382
385
@external
383
386
def get_coins (_pool: address ) -> address [N_COINS]:
@@ -460,4 +463,4 @@ def get_market_counts(coin_a: address, coin_b: address) -> uint256:
460
463
convert (coin_a, uint256 ) ^ convert (coin_b, uint256 )
461
464
)
462
465
463
- return self .market_counts [key]
466
+ return len ( self .markets [key])
0 commit comments