@paraswap/dex-lib 2.48.4-etherfi.3 → 2.49.0-pharaoh-v1

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.
Files changed (145) hide show
  1. package/build/abi/Redstone.json +739 -0
  2. package/build/abi/angle/stagToken.json +963 -0
  3. package/build/abi/angle-transmuter/MorphoOracle.json +193 -0
  4. package/build/abi/angle-transmuter/MorphoVault.json +2506 -0
  5. package/build/abi/angle-transmuter/Pyth.json +1534 -0
  6. package/build/abi/angle-transmuter/Transmuter.json +1711 -0
  7. package/build/abi/pharaoh/PharaohPool.abi.json +1582 -0
  8. package/build/abi/smardex/smardex-factory.json +185 -0
  9. package/build/abi/smardex/smardex-pool.json +578 -0
  10. package/build/abi/smardex/smardex-router.json +648 -0
  11. package/build/abi/trader-joe-v2_1/FactoryABI.json +1208 -0
  12. package/build/abi/trader-joe-v2_1/PairABI.json +1493 -0
  13. package/build/abi/trader-joe-v2_1/RouterABI.json +1489 -0
  14. package/build/abi/trader-joe-v2_1/StateMulticall.json +193 -0
  15. package/build/dex/angle-staked-stable/angle-staked-stable-pool.d.ts +55 -0
  16. package/build/dex/angle-staked-stable/angle-staked-stable-pool.js +183 -0
  17. package/build/dex/angle-staked-stable/angle-staked-stable-pool.js.map +1 -0
  18. package/build/dex/angle-staked-stable/angle-staked-stable.d.ts +50 -0
  19. package/build/dex/angle-staked-stable/angle-staked-stable.js +280 -0
  20. package/build/dex/angle-staked-stable/angle-staked-stable.js.map +1 -0
  21. package/build/dex/angle-staked-stable/config.d.ts +4 -0
  22. package/build/dex/angle-staked-stable/config.js +46 -0
  23. package/build/dex/angle-staked-stable/config.js.map +1 -0
  24. package/build/dex/angle-staked-stable/types.d.ts +17 -0
  25. package/build/dex/angle-staked-stable/types.js +3 -0
  26. package/build/dex/angle-staked-stable/types.js.map +1 -0
  27. package/build/dex/angle-transmuter/angle-transmuter-pool.d.ts +61 -0
  28. package/build/dex/angle-transmuter/angle-transmuter-pool.js +415 -0
  29. package/build/dex/angle-transmuter/angle-transmuter-pool.js.map +1 -0
  30. package/build/dex/angle-transmuter/angle-transmuter.d.ts +59 -0
  31. package/build/dex/angle-transmuter/angle-transmuter.js +262 -0
  32. package/build/dex/angle-transmuter/angle-transmuter.js.map +1 -0
  33. package/build/dex/angle-transmuter/backedOracle.d.ts +19 -0
  34. package/build/dex/angle-transmuter/backedOracle.js +56 -0
  35. package/build/dex/angle-transmuter/backedOracle.js.map +1 -0
  36. package/build/dex/angle-transmuter/config.d.ts +4 -0
  37. package/build/dex/angle-transmuter/config.js +30 -0
  38. package/build/dex/angle-transmuter/config.js.map +1 -0
  39. package/build/dex/angle-transmuter/constants.d.ts +77 -0
  40. package/build/dex/angle-transmuter/constants.js +94 -0
  41. package/build/dex/angle-transmuter/constants.js.map +1 -0
  42. package/build/dex/angle-transmuter/morphoOracle.d.ts +42 -0
  43. package/build/dex/angle-transmuter/morphoOracle.js +179 -0
  44. package/build/dex/angle-transmuter/morphoOracle.js.map +1 -0
  45. package/build/dex/angle-transmuter/morphoVault.d.ts +19 -0
  46. package/build/dex/angle-transmuter/morphoVault.js +78 -0
  47. package/build/dex/angle-transmuter/morphoVault.js.map +1 -0
  48. package/build/dex/angle-transmuter/pyth.d.ts +19 -0
  49. package/build/dex/angle-transmuter/pyth.js +70 -0
  50. package/build/dex/angle-transmuter/pyth.js.map +1 -0
  51. package/build/dex/angle-transmuter/redstone.d.ts +20 -0
  52. package/build/dex/angle-transmuter/redstone.js +73 -0
  53. package/build/dex/angle-transmuter/redstone.js.map +1 -0
  54. package/build/dex/angle-transmuter/transmuter.d.ts +52 -0
  55. package/build/dex/angle-transmuter/transmuter.js +374 -0
  56. package/build/dex/angle-transmuter/transmuter.js.map +1 -0
  57. package/build/dex/angle-transmuter/types.d.ts +188 -0
  58. package/build/dex/angle-transmuter/types.js +33 -0
  59. package/build/dex/angle-transmuter/types.js.map +1 -0
  60. package/build/dex/angle-transmuter/utils.d.ts +9 -0
  61. package/build/dex/angle-transmuter/utils.js +252 -0
  62. package/build/dex/angle-transmuter/utils.js.map +1 -0
  63. package/build/dex/etherfi.js +13 -19
  64. package/build/dex/etherfi.js.map +1 -1
  65. package/build/dex/index.js +2 -0
  66. package/build/dex/index.js.map +1 -1
  67. package/build/dex/smardex/subgraph-queries.d.ts +1 -0
  68. package/build/dex/smardex/subgraph-queries.js +17 -0
  69. package/build/dex/smardex/subgraph-queries.js.map +1 -0
  70. package/build/dex/smardex/usd-reserves.d.ts +23 -0
  71. package/build/dex/smardex/usd-reserves.js +86 -0
  72. package/build/dex/smardex/usd-reserves.js.map +1 -0
  73. package/build/dex/solidly/config.js +10 -0
  74. package/build/dex/solidly/config.js.map +1 -1
  75. package/build/dex/solidly/forks-override/pharaohV1.d.ts +44 -0
  76. package/build/dex/solidly/forks-override/pharaohV1.js +144 -0
  77. package/build/dex/solidly/forks-override/pharaohV1.js.map +1 -0
  78. package/build/dex/solidly/solidly.js +1 -0
  79. package/build/dex/solidly/solidly.js.map +1 -1
  80. package/build/dex/trader-joe-v2-1-2/config.d.ts +4 -0
  81. package/build/dex/trader-joe-v2-1-2/config.js +47 -0
  82. package/build/dex/trader-joe-v2-1-2/config.js.map +1 -0
  83. package/build/dex/trader-joe-v2-1-2/constants.d.ts +20 -0
  84. package/build/dex/trader-joe-v2-1-2/constants.js +22 -0
  85. package/build/dex/trader-joe-v2-1-2/constants.js.map +1 -0
  86. package/build/dex/trader-joe-v2-1-2/math/index.d.ts +37 -0
  87. package/build/dex/trader-joe-v2-1-2/math/index.js +291 -0
  88. package/build/dex/trader-joe-v2-1-2/math/index.js.map +1 -0
  89. package/build/dex/trader-joe-v2-1-2/trader-joe-v2-1-2-pool.d.ts +60 -0
  90. package/build/dex/trader-joe-v2-1-2/trader-joe-v2-1-2-pool.js +248 -0
  91. package/build/dex/trader-joe-v2-1-2/trader-joe-v2-1-2-pool.js.map +1 -0
  92. package/build/dex/trader-joe-v2-1-2/trader-joe-v2-1-2.d.ts +53 -0
  93. package/build/dex/trader-joe-v2-1-2/trader-joe-v2-1-2.js +307 -0
  94. package/build/dex/trader-joe-v2-1-2/trader-joe-v2-1-2.js.map +1 -0
  95. package/build/dex/trader-joe-v2-1-2/types.d.ts +82 -0
  96. package/build/dex/trader-joe-v2-1-2/types.js +9 -0
  97. package/build/dex/trader-joe-v2-1-2/types.js.map +1 -0
  98. package/build/dex/trader-joe-v2_1/config.d.ts +4 -0
  99. package/build/dex/trader-joe-v2_1/config.js +47 -0
  100. package/build/dex/trader-joe-v2_1/config.js.map +1 -0
  101. package/build/dex/trader-joe-v2_1/constants.d.ts +20 -0
  102. package/build/dex/trader-joe-v2_1/constants.js +22 -0
  103. package/build/dex/trader-joe-v2_1/constants.js.map +1 -0
  104. package/build/dex/trader-joe-v2_1/math/index.d.ts +37 -0
  105. package/build/dex/trader-joe-v2_1/math/index.js +291 -0
  106. package/build/dex/trader-joe-v2_1/math/index.js.map +1 -0
  107. package/build/dex/trader-joe-v2_1/trader-joe-v2.1.d.ts +0 -0
  108. package/build/dex/trader-joe-v2_1/trader-joe-v2.1.js +384 -0
  109. package/build/dex/trader-joe-v2_1/trader-joe-v2.1.js.map +1 -0
  110. package/build/dex/trader-joe-v2_1/trader-joe-v2_1-pool.d.ts +60 -0
  111. package/build/dex/trader-joe-v2_1/trader-joe-v2_1-pool.js +247 -0
  112. package/build/dex/trader-joe-v2_1/trader-joe-v2_1-pool.js.map +1 -0
  113. package/build/dex/trader-joe-v2_1/trader-joe-v2_1.d.ts +53 -0
  114. package/build/dex/trader-joe-v2_1/trader-joe-v2_1.js +307 -0
  115. package/build/dex/trader-joe-v2_1/trader-joe-v2_1.js.map +1 -0
  116. package/build/dex/trader-joe-v2_1/types.d.ts +82 -0
  117. package/build/dex/trader-joe-v2_1/types.js +9 -0
  118. package/build/dex/trader-joe-v2_1/types.js.map +1 -0
  119. package/build/dex/wombat/wombat-pool-poller.d.ts +22 -0
  120. package/build/dex/wombat/wombat-pool-poller.js +164 -0
  121. package/build/dex/wombat/wombat-pool-poller.js.map +1 -0
  122. package/build/dex-helper/RedisBatcher.d.ts +20 -0
  123. package/build/dex-helper/RedisBatcher.js +75 -0
  124. package/build/dex-helper/RedisBatcher.js.map +1 -0
  125. package/package.json +1 -1
  126. package/src/dex/etherfi.ts +25 -26
  127. package/src/dex/index.ts +2 -0
  128. package/src/dex/solidly/config.ts +12 -0
  129. package/src/dex/solidly/forks-override/pharaohV1.ts +253 -0
  130. package/src/dex/solidly/solidly-e2e.test.ts +21 -0
  131. package/src/dex/solidly/solidly-integration.test.ts +143 -0
  132. package/src/dex/solidly/solidly.ts +1 -0
  133. package/tests/constants-e2e.ts +5 -0
  134. package/build/abi/algebra/AlgebraPool.abi.json +0 -727
  135. package/build/abi/uniswap-v3/UniswapV3Quoter.abi.json +0 -193
  136. package/build/dex/algebra/algebra-pool.d.ts +0 -46
  137. package/build/dex/algebra/algebra-pool.js +0 -336
  138. package/build/dex/algebra/algebra-pool.js.map +0 -1
  139. package/build/dex/quickswap/camelot-v3.d.ts +0 -6
  140. package/build/dex/quickswap/camelot-v3.js +0 -19
  141. package/build/dex/quickswap/camelot-v3.js.map +0 -1
  142. package/build/dex/quickswap/zyberswap-v3.d.ts +0 -6
  143. package/build/dex/quickswap/zyberswap-v3.js +0 -19
  144. package/build/dex/quickswap/zyberswap-v3.js.map +0 -1
  145. package/build/dex/uniswap-v2/rebase-tokens.json +0 -7
@@ -0,0 +1,253 @@
1
+ import { Network, SUBGRAPH_TIMEOUT } from '../../../constants';
2
+ import { getDexKeysWithNetwork } from '../../../utils';
3
+ import { SolidlyConfig } from '../config';
4
+ import _ from 'lodash';
5
+ import { Address, PoolLiquidity } from '../../../types';
6
+ import BigNumber from 'bignumber.js';
7
+ import { Solidly } from '../solidly';
8
+ import { IDexHelper } from '../../../dex-helper';
9
+ import { SolidlyPair } from '../types';
10
+ import { Interface } from '@ethersproject/abi';
11
+
12
+ const PharaohV1FactoryABI = [
13
+ {
14
+ inputs: [{ internalType: 'address', name: '', type: 'address' }],
15
+ name: 'pairFee',
16
+ outputs: [{ internalType: 'uint256', name: '', type: 'uint256' }],
17
+ stateMutability: 'view',
18
+ type: 'function',
19
+ },
20
+ ];
21
+
22
+ const pharaohV1FactoryIface = new Interface(PharaohV1FactoryABI);
23
+
24
+ export type PharaohV1SubgraphPool = {
25
+ id: string;
26
+ isStable: boolean;
27
+ token0: string;
28
+ reserve0: string;
29
+ reserve1: string;
30
+ token1: string;
31
+ };
32
+
33
+ export type PharaohV1SubgraphToken = {
34
+ id: string;
35
+ decimals: string;
36
+ };
37
+
38
+ export class PharaohV1 extends Solidly {
39
+ public static dexKeysWithNetwork: { key: string; networks: Network[] }[] =
40
+ getDexKeysWithNetwork(_.pick(SolidlyConfig, ['PharaohV1']));
41
+
42
+ constructor(
43
+ protected network: Network,
44
+ dexKey: string,
45
+ protected dexHelper: IDexHelper,
46
+ ) {
47
+ super(
48
+ network,
49
+ dexKey,
50
+ dexHelper,
51
+ true, // dynamic fees
52
+ );
53
+ }
54
+
55
+ protected getFeesMultiCallData(pair: SolidlyPair) {
56
+ const callEntry = {
57
+ target: this.factoryAddress,
58
+ callData: pharaohV1FactoryIface.encodeFunctionData('pairFee', [
59
+ pair.exchange,
60
+ ]),
61
+ };
62
+ const callDecoder = (values: any[]) =>
63
+ parseInt(
64
+ pharaohV1FactoryIface
65
+ .decodeFunctionResult('pairFee', values)[0]
66
+ .toString(),
67
+ );
68
+
69
+ return {
70
+ callEntry,
71
+ callDecoder,
72
+ };
73
+ }
74
+
75
+ async getTopPoolsForToken(
76
+ tokenAddress: Address,
77
+ count: number,
78
+ ): Promise<PoolLiquidity[]> {
79
+ if (!this.subgraphURL) return [];
80
+
81
+ const query = `query ($token: Bytes!, $count: Int) {
82
+ pools0: pairs(first: $count, orderBy: reserve0, orderDirection: desc, where: {token0: $token, reserve0_gt: 1, reserve1_gt: 1}) {
83
+ id
84
+ isStable
85
+ token0
86
+ token1
87
+ reserve0,
88
+ reserve1,
89
+ }
90
+ pools1: pairs(first: $count, orderBy: reserve1, orderDirection: desc, where: {token1: $token, reserve0_gt: 1, reserve1_gt: 1}) {
91
+ id
92
+ isStable
93
+ token0
94
+ token1
95
+ reserve0,
96
+ reserve1,
97
+ }
98
+ }`;
99
+
100
+ const { data } = await this.dexHelper.httpRequest.post(
101
+ this.subgraphURL,
102
+ {
103
+ query,
104
+ variables: { token: tokenAddress.toLowerCase(), count },
105
+ },
106
+ SUBGRAPH_TIMEOUT,
107
+ );
108
+
109
+ if (!(data && data.pools0 && data.pools1))
110
+ throw new Error("Couldn't fetch the pools from the subgraph");
111
+
112
+ const tokenIds = _.uniq(
113
+ []
114
+ .concat(data.pools0, data.pools1)
115
+ .map((pool: PharaohV1SubgraphPool) => [pool.token0, pool.token1])
116
+ .flat(),
117
+ );
118
+
119
+ const tokensQuery = `
120
+ query ($tokenIds: [String!]) {
121
+ tokens(where: {id_in: $tokenIds}) {
122
+ id
123
+ decimals
124
+ }
125
+ }`;
126
+
127
+ const { data: tokensData } = await this.dexHelper.httpRequest.post(
128
+ this.subgraphURL,
129
+ {
130
+ query: tokensQuery,
131
+ variables: { tokenIds },
132
+ },
133
+ SUBGRAPH_TIMEOUT,
134
+ );
135
+
136
+ const pools0 = await this.prepareSubgraphPools(
137
+ tokensData.tokens,
138
+ data.pools0,
139
+ (
140
+ pool,
141
+ { address1, decimals1, liquidityUSDToken0, liquidityUSDToken1 },
142
+ ) => ({
143
+ exchange: this.dexKey,
144
+ stable: pool.isStable,
145
+ address: pool.id.toLowerCase(),
146
+ connectorTokens: [
147
+ {
148
+ address: address1,
149
+ decimals: decimals1,
150
+ },
151
+ ],
152
+ liquidityUSD: liquidityUSDToken0 + liquidityUSDToken1,
153
+ }),
154
+ );
155
+
156
+ const pools1 = await this.prepareSubgraphPools(
157
+ tokensData.tokens,
158
+ data.pools1,
159
+ (
160
+ pool,
161
+ { address0, decimals0, liquidityUSDToken0, liquidityUSDToken1 },
162
+ ) => ({
163
+ exchange: this.dexKey,
164
+ stable: pool.isStable,
165
+ address: pool.id.toLowerCase(),
166
+ connectorTokens: [
167
+ {
168
+ address: address0,
169
+ decimals: decimals0,
170
+ },
171
+ ],
172
+ liquidityUSD: liquidityUSDToken0 + liquidityUSDToken1,
173
+ }),
174
+ );
175
+
176
+ return _.slice(
177
+ _.sortBy(_.concat(pools0, pools1), [pool => -1 * pool.liquidityUSD]),
178
+ 0,
179
+ count,
180
+ );
181
+ }
182
+
183
+ protected async prepareSubgraphPools(
184
+ tokens: PharaohV1SubgraphToken[],
185
+ pools: PharaohV1SubgraphPool[],
186
+ iterator: (
187
+ pool: PharaohV1SubgraphPool,
188
+ {
189
+ address0,
190
+ address1,
191
+ decimals0,
192
+ decimals1,
193
+ reserve0,
194
+ reserve1,
195
+ liquidityUSDToken0,
196
+ liquidityUSDToken1,
197
+ }: {
198
+ address0: string;
199
+ address1: string;
200
+ decimals0: number;
201
+ decimals1: number;
202
+ reserve0: bigint;
203
+ reserve1: bigint;
204
+ liquidityUSDToken0: number;
205
+ liquidityUSDToken1: number;
206
+ },
207
+ ) => PoolLiquidity,
208
+ ): Promise<PoolLiquidity[]> {
209
+ return Promise.all(
210
+ pools.map(async (pool: PharaohV1SubgraphPool) => {
211
+ const address0 = pool.token0.toLowerCase();
212
+ const address1 = pool.token1.toLowerCase();
213
+
214
+ const decimals0 = parseInt(
215
+ tokens.find(t => t.id === address0)!.decimals,
216
+ );
217
+ const decimals1 = parseInt(
218
+ tokens.find(t => t.id === address1)!.decimals,
219
+ );
220
+
221
+ const reserve0 = BigInt(new BigNumber(pool.reserve0).toFixed());
222
+ const reserve1 = BigInt(new BigNumber(pool.reserve1).toFixed());
223
+
224
+ const liquidityUSDToken0 = await this.dexHelper.getTokenUSDPrice(
225
+ {
226
+ address: address0,
227
+ decimals: decimals0,
228
+ },
229
+ reserve0,
230
+ );
231
+
232
+ const liquidityUSDToken1 = await this.dexHelper.getTokenUSDPrice(
233
+ {
234
+ address: address1,
235
+ decimals: decimals1,
236
+ },
237
+ reserve1,
238
+ );
239
+
240
+ return iterator(pool, {
241
+ address0,
242
+ address1,
243
+ decimals0,
244
+ decimals1,
245
+ reserve0,
246
+ reserve1,
247
+ liquidityUSDToken0,
248
+ liquidityUSDToken1,
249
+ });
250
+ }),
251
+ );
252
+ }
253
+ }
@@ -1245,6 +1245,27 @@ describe('Solidly E2E', () => {
1245
1245
  });
1246
1246
  });
1247
1247
  });
1248
+
1249
+ describe('PharaohV1', () => {
1250
+ const dexKey = 'PharaohV1';
1251
+
1252
+ const tokenASymbol: string = 'USDC';
1253
+ const tokenBSymbol: string = 'WAVAX';
1254
+
1255
+ const tokenAAmount: string = '100000';
1256
+ const tokenBAmount: string = '100000000000000000';
1257
+ const nativeTokenAmount = '100000000000000000';
1258
+
1259
+ testForNetwork(
1260
+ network,
1261
+ dexKey,
1262
+ tokenASymbol,
1263
+ tokenBSymbol,
1264
+ tokenAAmount,
1265
+ tokenBAmount,
1266
+ nativeTokenAmount,
1267
+ );
1268
+ });
1248
1269
  });
1249
1270
 
1250
1271
  describe('Arbitrum', () => {
@@ -19,6 +19,7 @@ import { VelodromeV2 } from './forks-override/velodromeV2';
19
19
  import { Equalizer } from './forks-override/equalizer';
20
20
  import { Velocimeter } from './forks-override/velocimeter';
21
21
  import { Usdfi } from './forks-override/usdfi';
22
+ import { PharaohV1 } from './forks-override/pharaohV1';
22
23
 
23
24
  const amounts18 = [0n, BI_POWS[18], 2000000000000000000n];
24
25
  const amounts6 = [0n, BI_POWS[6], 2000000n];
@@ -1443,6 +1444,148 @@ describe('Solidly integration tests', () => {
1443
1444
  });
1444
1445
  });
1445
1446
 
1447
+ describe('Avalanche', () => {
1448
+ const network = Network.AVALANCHE;
1449
+ const dexHelper = new DummyDexHelper(network);
1450
+ const checkOnChainPricing = constructCheckOnChainPricing(dexHelper);
1451
+
1452
+ describe('PharaohV1', function () {
1453
+ const dexKey = 'PharaohV1';
1454
+ const pharaohV1 = new PharaohV1(network, dexKey, dexHelper);
1455
+
1456
+ describe('UniswapV2 like pool', function () {
1457
+ const TokenASymbol = 'USDC';
1458
+ const tokenA = Tokens[network][TokenASymbol];
1459
+ const TokenBSymbol = 'WAVAX';
1460
+ const tokenB = Tokens[network][TokenBSymbol];
1461
+
1462
+ const amounts = amounts18;
1463
+
1464
+ it('getPoolIdentifiers and getPricesVolume', async function () {
1465
+ const blocknumber = await dexHelper.web3Provider.eth.getBlockNumber();
1466
+ const pools = await pharaohV1.getPoolIdentifiers(
1467
+ tokenA,
1468
+ tokenB,
1469
+ SwapSide.SELL,
1470
+ blocknumber,
1471
+ );
1472
+ console.log(
1473
+ `${TokenASymbol} <> ${TokenBSymbol} Pool Identifiers: `,
1474
+ pools,
1475
+ );
1476
+
1477
+ expect(pools.length).toBeGreaterThan(0);
1478
+
1479
+ console.log('AMOUNTS: ', amounts);
1480
+
1481
+ const poolPrices = await pharaohV1.getPricesVolume(
1482
+ tokenA,
1483
+ tokenB,
1484
+ amounts,
1485
+ SwapSide.SELL,
1486
+ blocknumber,
1487
+ pools,
1488
+ );
1489
+ console.log(
1490
+ `${TokenASymbol} <> ${TokenBSymbol} Pool Prices: `,
1491
+ util.inspect(poolPrices, false, null, true),
1492
+ );
1493
+
1494
+ expect(poolPrices).not.toBeNull();
1495
+ checkPoolPrices(poolPrices!, amounts, SwapSide.SELL, dexKey);
1496
+
1497
+ // Check if onchain pricing equals to calculated ones
1498
+
1499
+ for (const poolPrice of poolPrices || []) {
1500
+ await checkOnChainPricing(
1501
+ pharaohV1,
1502
+ 'getAmountOut',
1503
+ blocknumber,
1504
+ poolPrice.prices,
1505
+ poolPrice.poolAddresses![0],
1506
+ tokenA.address,
1507
+ amounts,
1508
+ );
1509
+ }
1510
+ });
1511
+
1512
+ it('getTopPoolsForToken', async function () {
1513
+ const poolLiquidity = await pharaohV1.getTopPoolsForToken(
1514
+ tokenA.address,
1515
+ 10,
1516
+ );
1517
+ console.log(`${TokenASymbol} Top Pools:`, poolLiquidity);
1518
+
1519
+ checkPoolsLiquidity(poolLiquidity, tokenA.address, dexKey);
1520
+ });
1521
+ });
1522
+
1523
+ describe('Curve like stable pool', function () {
1524
+ const TokenASymbol = 'USDT';
1525
+ const tokenA = Tokens[network][TokenASymbol];
1526
+ const TokenBSymbol = 'USDC';
1527
+ const tokenB = Tokens[network][TokenBSymbol];
1528
+
1529
+ const amounts = amounts6;
1530
+
1531
+ it('getPoolIdentifiers and getPricesVolume', async function () {
1532
+ const blocknumber = await dexHelper.web3Provider.eth.getBlockNumber();
1533
+ const pools = await pharaohV1.getPoolIdentifiers(
1534
+ tokenA,
1535
+ tokenB,
1536
+ SwapSide.SELL,
1537
+ blocknumber,
1538
+ );
1539
+ console.log(
1540
+ `${TokenASymbol} <> ${TokenBSymbol} Pool Identifiers: `,
1541
+ pools,
1542
+ );
1543
+
1544
+ expect(pools.length).toBeGreaterThan(0);
1545
+
1546
+ const poolPrices = await pharaohV1.getPricesVolume(
1547
+ tokenA,
1548
+ tokenB,
1549
+ amounts,
1550
+ SwapSide.SELL,
1551
+ blocknumber,
1552
+ pools,
1553
+ );
1554
+ console.log(
1555
+ `${TokenASymbol} <> ${TokenBSymbol} Pool Prices: `,
1556
+ poolPrices,
1557
+ );
1558
+
1559
+ expect(poolPrices).not.toBeNull();
1560
+ checkPoolPrices(poolPrices!, amounts, SwapSide.SELL, dexKey);
1561
+
1562
+ // Check if onchain pricing equals to calculated ones
1563
+ for (const poolPrice of poolPrices || []) {
1564
+ await checkOnChainPricing(
1565
+ pharaohV1,
1566
+ 'getAmountOut',
1567
+ blocknumber,
1568
+ poolPrice.prices,
1569
+ poolPrice.poolAddresses![0],
1570
+ tokenA.address,
1571
+ amounts,
1572
+ );
1573
+ }
1574
+ });
1575
+
1576
+ it('getTopPoolsForToken', async function () {
1577
+ const poolLiquidity = await pharaohV1.getTopPoolsForToken(
1578
+ tokenA.address,
1579
+ 10,
1580
+ );
1581
+ console.log(`${TokenASymbol} Top Pools:`, poolLiquidity);
1582
+
1583
+ checkPoolsLiquidity(poolLiquidity, tokenA.address, dexKey);
1584
+ });
1585
+ });
1586
+ });
1587
+ });
1588
+
1446
1589
  describe('Optimism', () => {
1447
1590
  const network = Network.OPTIMISM;
1448
1591
  const dexHelper = new DummyDexHelper(network);
@@ -78,6 +78,7 @@ export class Solidly extends UniswapV2 {
78
78
  'Equalizer',
79
79
  'Velocimeter',
80
80
  'Usdfi',
81
+ 'PharaohV1',
81
82
  ]),
82
83
  );
83
84
 
@@ -669,6 +669,10 @@ export const Tokens: {
669
669
  },
670
670
  },
671
671
  [Network.AVALANCHE]: {
672
+ PHAR: {
673
+ address: '0xAAAB9D12A30504559b0C5a9A5977fEE4A6081c6b',
674
+ decimals: 18,
675
+ },
672
676
  USDCe: {
673
677
  address: '0xA7D7079b0FEaD91F3e65f86E8915Cb59c1a4C664',
674
678
  decimals: 6,
@@ -1232,6 +1236,7 @@ export const Holders: {
1232
1236
  YUSD: '0x6c1a5ef2acde1fd2fc68def440d2c1eb35bae24a',
1233
1237
  BTCb: '0x84c06d3c27821d0136f66306f5028d43ceac268d',
1234
1238
  AMPL: '0xfcaA5ea7F8eb0631BcA72C345025C0A5a6D93f0E',
1239
+ PHAR: '0x654296D56532f62B7d91d335791d3c364a9385b5',
1235
1240
  },
1236
1241
  [Network.ARBITRUM]: {
1237
1242
  SEN: '0xcb19b6b4971bd4206bab176c75b1efe3e28ee5a8',