@guru-fund/sdk 0.2.8 → 0.2.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -24,7 +24,10 @@ const V3_FACTORY_ABI = [
|
|
|
24
24
|
const AERO_V3_FACTORY_ABI = [
|
|
25
25
|
'function getPool(address tokenA, address tokenB, int24 tickSpacing) view returns (address pool)',
|
|
26
26
|
];
|
|
27
|
-
const V3_POOL_ABI = [
|
|
27
|
+
const V3_POOL_ABI = [
|
|
28
|
+
'function fee() view returns (uint24)',
|
|
29
|
+
'function liquidity() view returns (uint128)',
|
|
30
|
+
];
|
|
28
31
|
const AERO_FACTORY_ABI = [
|
|
29
32
|
'function getPool(address tokenA, address tokenB, bool stable) view returns (address)',
|
|
30
33
|
];
|
|
@@ -114,6 +117,17 @@ function buildDexTable(addresses) {
|
|
|
114
117
|
}
|
|
115
118
|
return table;
|
|
116
119
|
}
|
|
120
|
+
export function rankUsablePools(pools) {
|
|
121
|
+
return pools
|
|
122
|
+
.filter((pool) => pool.feeTier === 0 || (pool.activeLiquidity ?? 0n) > 0n)
|
|
123
|
+
.sort((a, b) => {
|
|
124
|
+
if (a.wethBalance > b.wethBalance)
|
|
125
|
+
return -1;
|
|
126
|
+
if (a.wethBalance < b.wethBalance)
|
|
127
|
+
return 1;
|
|
128
|
+
return 0;
|
|
129
|
+
});
|
|
130
|
+
}
|
|
117
131
|
const PERCENT_DENOMINATOR = 100000n;
|
|
118
132
|
const CACHE_DURATION = 60 * 60 * 1000;
|
|
119
133
|
function withSlippageTolerance(amount, slippage) {
|
|
@@ -274,11 +288,14 @@ export default class PoolHelper {
|
|
|
274
288
|
const wethBalance = await wethToken.balanceOf(poolAddress);
|
|
275
289
|
if (wethBalance === 0n)
|
|
276
290
|
return;
|
|
291
|
+
const pool = connect(poolAddress, V3_POOL_ABI, this.provider);
|
|
292
|
+
const activeLiquidity = await pool.liquidity();
|
|
277
293
|
pools.push({
|
|
278
294
|
address: poolAddress,
|
|
279
295
|
feeTier: feeTier,
|
|
280
296
|
exchangeFactory: factoryAddress,
|
|
281
297
|
wethBalance,
|
|
298
|
+
activeLiquidity,
|
|
282
299
|
});
|
|
283
300
|
}
|
|
284
301
|
catch {
|
|
@@ -286,14 +303,7 @@ export default class PoolHelper {
|
|
|
286
303
|
}));
|
|
287
304
|
}
|
|
288
305
|
}));
|
|
289
|
-
pools
|
|
290
|
-
if (a.wethBalance > b.wethBalance)
|
|
291
|
-
return -1;
|
|
292
|
-
if (a.wethBalance < b.wethBalance)
|
|
293
|
-
return 1;
|
|
294
|
-
return 0;
|
|
295
|
-
});
|
|
296
|
-
return pools;
|
|
306
|
+
return rankUsablePools(pools);
|
|
297
307
|
}
|
|
298
308
|
async getUniswapCompatibleTokenPools(token, options) {
|
|
299
309
|
const swappableOnly = options?.swappableOnly ?? true;
|