@paraswap/dex-lib 2.35.3-quick-perps-proxy.3 → 2.35.4

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 (108) hide show
  1. package/build/abi/algebra/AlgebraPool.abi.json +727 -0
  2. package/build/abi/api3-proxy.json +0 -7
  3. package/build/config.js +26 -0
  4. package/build/config.js.map +1 -1
  5. package/build/constants.d.ts +2 -1
  6. package/build/constants.js +1 -0
  7. package/build/constants.js.map +1 -1
  8. package/build/dex/algebra/algebra-factory.d.ts +23 -0
  9. package/build/dex/algebra/algebra-factory.js +40 -0
  10. package/build/dex/algebra/algebra-factory.js.map +1 -0
  11. package/build/dex/algebra/algebra-pool.d.ts +46 -0
  12. package/build/dex/algebra/algebra-pool.js +336 -0
  13. package/build/dex/algebra/algebra-pool.js.map +1 -0
  14. package/build/dex/generic-rfq/generic-rfq.js +2 -4
  15. package/build/dex/generic-rfq/generic-rfq.js.map +1 -1
  16. package/build/dex/quick-perps/pool.js +6 -21
  17. package/build/dex/quick-perps/pool.js.map +1 -1
  18. package/build/dex/quick-perps/quick-perps.js +28 -34
  19. package/build/dex/quick-perps/quick-perps.js.map +1 -1
  20. package/build/dex/uniswap-v3/config.js +16 -0
  21. package/build/dex/uniswap-v3/config.js.map +1 -1
  22. package/build/dex/weth/config.js +3 -0
  23. package/build/dex/weth/config.js.map +1 -1
  24. package/build/lib/api3-feed.d.ts +0 -4
  25. package/build/lib/api3-feed.js +0 -18
  26. package/build/lib/api3-feed.js.map +1 -1
  27. package/package.json +1 -1
  28. package/src/abi/api3-proxy.json +0 -7
  29. package/src/config.ts +27 -1
  30. package/src/constants.ts +1 -0
  31. package/src/dex/generic-rfq/generic-rfq.ts +2 -4
  32. package/src/dex/quick-perps/pool.ts +7 -42
  33. package/src/dex/quick-perps/quick-perps-events.test.ts +1 -0
  34. package/src/dex/quick-perps/quick-perps.ts +35 -45
  35. package/src/dex/uniswap-v3/config.ts +17 -0
  36. package/src/dex/uniswap-v3/uniswap-v3-e2e.test.ts +95 -0
  37. package/src/dex/weth/config.ts +3 -0
  38. package/src/lib/api3-feed.ts +0 -35
  39. package/tests/constants-e2e.ts +17 -0
  40. package/build/abi/quickPerps/fast-price-events.json +0 -70
  41. package/build/abi/quickPerps/fast-price-feed.json +0 -748
  42. package/build/abi/quickPerps/reader.json +0 -313
  43. package/build/abi/quickPerps/vault-price-feed.json +0 -477
  44. package/build/abi/quickPerps/vault.json +0 -1953
  45. package/build/abi/uniswap-v3/pancakeswap-v3/PancakeswapV3QuoterV2.abi.json +0 -285
  46. package/build/abi/uniswap-v3/pancakeswap-v3/PancakeswapV3Router.abi.json +0 -583
  47. package/build/abi/woo-fi/WooFeeManager.abi.json +0 -318
  48. package/build/abi/woo-fi/WooPP.abi.json +0 -548
  49. package/build/abi/woo-fi/Wooracle.abi.json +0 -260
  50. package/build/dex/aave-v3/tokens/arbitrum.json +0 -50
  51. package/build/dex/aave-v3/tokens/avalanche.json +0 -74
  52. package/build/dex/aave-v3/tokens/fantom.json +0 -62
  53. package/build/dex/aave-v3/tokens/optimism.json +0 -50
  54. package/build/dex/aave-v3/tokens/polygon.json +0 -116
  55. package/build/dex/balancer-v2/LinearMath.d.ts +0 -19
  56. package/build/dex/balancer-v2/LinearMath.js +0 -179
  57. package/build/dex/balancer-v2/LinearMath.js.map +0 -1
  58. package/build/dex/balancer-v2/LinearPool.d.ts +0 -47
  59. package/build/dex/balancer-v2/LinearPool.js +0 -324
  60. package/build/dex/balancer-v2/LinearPool.js.map +0 -1
  61. package/build/dex/balancer-v2/PhantomStablePool.d.ts +0 -47
  62. package/build/dex/balancer-v2/PhantomStablePool.js +0 -294
  63. package/build/dex/balancer-v2/PhantomStablePool.js.map +0 -1
  64. package/build/dex/balancer-v2/StableMath.d.ts +0 -9
  65. package/build/dex/balancer-v2/StableMath.js +0 -272
  66. package/build/dex/balancer-v2/StableMath.js.map +0 -1
  67. package/build/dex/balancer-v2/balancer-v2-pool.d.ts +0 -75
  68. package/build/dex/balancer-v2/balancer-v2-pool.js +0 -417
  69. package/build/dex/balancer-v2/balancer-v2-pool.js.map +0 -1
  70. package/build/dex/quickswap-v3.d.ts +0 -21
  71. package/build/dex/quickswap-v3.js +0 -40
  72. package/build/dex/quickswap-v3.js.map +0 -1
  73. package/build/dex/test-dex/config.d.ts +0 -4
  74. package/build/dex/test-dex/config.js +0 -15
  75. package/build/dex/test-dex/config.js.map +0 -1
  76. package/build/dex/test-dex/test-dex-pool.d.ts +0 -39
  77. package/build/dex/test-dex/test-dex-pool.js +0 -63
  78. package/build/dex/test-dex/test-dex-pool.js.map +0 -1
  79. package/build/dex/test-dex/test-dex.d.ts +0 -37
  80. package/build/dex/test-dex/test-dex.js +0 -126
  81. package/build/dex/test-dex/test-dex.js.map +0 -1
  82. package/build/dex/test-dex/types.d.ts +0 -6
  83. package/build/dex/test-dex/types.js +0 -3
  84. package/build/dex/test-dex/types.js.map +0 -1
  85. package/build/dex/uniswap-v3/forks/pancakeswap-v3/pancakeswap-v3.d.ts +0 -12
  86. package/build/dex/uniswap-v3/forks/pancakeswap-v3/pancakeswap-v3.js +0 -23
  87. package/build/dex/uniswap-v3/forks/pancakeswap-v3/pancakeswap-v3.js.map +0 -1
  88. package/build/dex/woo-fi/config.d.ts +0 -4
  89. package/build/dex/woo-fi/config.js +0 -141
  90. package/build/dex/woo-fi/config.js.map +0 -1
  91. package/build/dex/woo-fi/constants.d.ts +0 -5
  92. package/build/dex/woo-fi/constants.js +0 -20
  93. package/build/dex/woo-fi/constants.js.map +0 -1
  94. package/build/dex/woo-fi/types.d.ts +0 -48
  95. package/build/dex/woo-fi/types.js +0 -3
  96. package/build/dex/woo-fi/types.js.map +0 -1
  97. package/build/dex/woo-fi/woo-fi-decimal-math.d.ts +0 -14
  98. package/build/dex/woo-fi/woo-fi-decimal-math.js +0 -42
  99. package/build/dex/woo-fi/woo-fi-decimal-math.js.map +0 -1
  100. package/build/dex/woo-fi/woo-fi-math.d.ts +0 -31
  101. package/build/dex/woo-fi/woo-fi-math.js +0 -300
  102. package/build/dex/woo-fi/woo-fi-math.js.map +0 -1
  103. package/build/dex/woo-fi/woo-fi.d.ts +0 -65
  104. package/build/dex/woo-fi/woo-fi.js +0 -480
  105. package/build/dex/woo-fi/woo-fi.js.map +0 -1
  106. package/build/dex/woo-fi-v2/woo-fi-math.d.ts +0 -16
  107. package/build/dex/woo-fi-v2/woo-fi-math.js +0 -137
  108. package/build/dex/woo-fi-v2/woo-fi-math.js.map +0 -1
@@ -117,55 +117,45 @@ export class QuickPerps extends SimpleExchange implements IDex<QuickPerpsData> {
117
117
  limitPools?: string[],
118
118
  ): Promise<null | ExchangePrices<QuickPerpsData>> {
119
119
  if (side === SwapSide.BUY || !this.pool) return null;
120
- try {
121
- const srcAddress = this.dexHelper.config
122
- .wrapETH(srcToken)
123
- .address.toLowerCase();
124
- const destAddress = this.dexHelper.config
125
- .wrapETH(destToken)
126
- .address.toLowerCase();
127
- if (
128
- srcAddress === destAddress ||
129
- !(
130
- this.supportedTokensMap[srcAddress] &&
131
- this.supportedTokensMap[destAddress]
132
- )
120
+ const srcAddress = this.dexHelper.config
121
+ .wrapETH(srcToken)
122
+ .address.toLowerCase();
123
+ const destAddress = this.dexHelper.config
124
+ .wrapETH(destToken)
125
+ .address.toLowerCase();
126
+ if (
127
+ srcAddress === destAddress ||
128
+ !(
129
+ this.supportedTokensMap[srcAddress] &&
130
+ this.supportedTokensMap[destAddress]
133
131
  )
134
- return null;
135
- const srcPoolIdentifier = `${this.dexKey}_${srcAddress}`;
136
- const destPoolIdentifier = `${this.dexKey}_${destAddress}`;
137
- const pools = [srcPoolIdentifier, destPoolIdentifier];
138
- if (limitPools && pools.some(p => !limitPools.includes(p))) return null;
132
+ )
133
+ return null;
134
+ const srcPoolIdentifier = `${this.dexKey}_${srcAddress}`;
135
+ const destPoolIdentifier = `${this.dexKey}_${destAddress}`;
136
+ const pools = [srcPoolIdentifier, destPoolIdentifier];
137
+ if (limitPools && pools.some(p => !limitPools.includes(p))) return null;
139
138
 
140
- const unitVolume = getBigIntPow(srcToken.decimals);
141
- const prices = await this.pool.getAmountOut(
142
- srcAddress,
143
- destAddress,
144
- [unitVolume, ...amounts],
145
- blockNumber,
146
- );
139
+ const unitVolume = getBigIntPow(srcToken.decimals);
140
+ const prices = await this.pool.getAmountOut(
141
+ srcAddress,
142
+ destAddress,
143
+ [unitVolume, ...amounts],
144
+ blockNumber,
145
+ );
147
146
 
148
- if (!prices) return null;
147
+ if (!prices) return null;
149
148
 
150
- return [
151
- {
152
- prices: prices.slice(1),
153
- unit: prices[0],
154
- gasCost: QuickPerpsGasCost,
155
- exchange: this.dexKey,
156
- data: {},
157
- poolAddresses: [this.params.vault],
158
- },
159
- ];
160
- } catch (e) {
161
- this.logger.error(
162
- `Error_getPrices ${srcToken.symbol || srcToken.address}, ${
163
- destToken.symbol || destToken.address
164
- }, ${side}: `,
165
- e,
166
- );
167
- return null;
168
- }
149
+ return [
150
+ {
151
+ prices: prices.slice(1),
152
+ unit: prices[0],
153
+ gasCost: QuickPerpsGasCost,
154
+ exchange: this.dexKey,
155
+ data: {},
156
+ poolAddresses: [this.params.vault],
157
+ },
158
+ ];
169
159
  }
170
160
 
171
161
  // Returns estimated gas cost of calldata for this DEX in multiSwap
@@ -106,6 +106,19 @@ export const UniswapV3Config: DexConfigMap<DexParams> = {
106
106
  subgraphURL:
107
107
  'https://api.thegraph.com/subgraphs/name/lynnshaoyu/uniswap-v3-avax',
108
108
  },
109
+ [Network.BASE]: {
110
+ factory: '0x33128a8fC17869897dcE68Ed026d694621f6FDfD',
111
+ quoter: '0x3d4e44Eb1374240CE5F1B871ab261CD16335B76a',
112
+ router: '0xaeE2b8d4A154e36f479dAeCe3FB3e6c3c03d396E',
113
+ supportedFees: SUPPORTED_FEES,
114
+ stateMulticall: '0x7160f736c52e1e78e92FD4eE4D73e21A7Cf4F950',
115
+ uniswapMulticall: '0x091e99cb1C49331a94dD62755D168E941AbD0693',
116
+ chunksCount: 10,
117
+ initRetryFrequency: 10,
118
+ initHash: `0xe34f199b19b2b4f47f68442619d555527d244f78a3297ea89325f843f87b8b54`,
119
+ subgraphURL:
120
+ 'https://api.studio.thegraph.com/query/48211/uniswap-v3-base/version/latest',
121
+ },
109
122
  },
110
123
  SushiSwapV3: {
111
124
  [Network.MAINNET]: {
@@ -283,4 +296,8 @@ export const Adapters: Record<number, AdapterMappings> = {
283
296
  [SwapSide.SELL]: [{ name: 'AvalancheAdapter02', index: 5 }],
284
297
  [SwapSide.BUY]: [{ name: 'AvalancheBuyAdapter', index: 6 }],
285
298
  },
299
+ [Network.BASE]: {
300
+ [SwapSide.SELL]: [{ name: 'BaseAdapter01', index: 1 }],
301
+ [SwapSide.BUY]: [{ name: 'BaseBuyAdapter', index: 1 }],
302
+ },
286
303
  };
@@ -403,6 +403,101 @@ describe('UniswapV3 E2E', () => {
403
403
  );
404
404
  });
405
405
 
406
+ describe('UniswapV3 Base', () => {
407
+ const network = Network.BASE;
408
+ const tokens = Tokens[network];
409
+ const holders = Holders[network];
410
+ const provider = new StaticJsonRpcProvider(
411
+ generateConfig(network).privateHttpProvider,
412
+ network,
413
+ );
414
+
415
+ const tokenASymbol: string = 'PRIME';
416
+ const tokenBSymbol: string = 'WETH';
417
+ const nativeTokenSymbol = NativeTokenSymbols[network];
418
+
419
+ const tokenAAmount: string = '1000000000000000000';
420
+ const tokenBAmount: string = '1000000000000000000';
421
+ const nativeTokenAmount = '1000000000000000000';
422
+
423
+ const sideToContractMethods = new Map([
424
+ [
425
+ SwapSide.SELL,
426
+ [
427
+ // ContractMethod.simpleSwap,
428
+ ContractMethod.multiSwap,
429
+ // ContractMethod.megaSwap,
430
+ ],
431
+ ],
432
+ [
433
+ SwapSide.BUY,
434
+ [
435
+ // ContractMethod.simpleBuy,
436
+ // ContractMethod.buy
437
+ ],
438
+ ],
439
+ ]);
440
+
441
+ sideToContractMethods.forEach((contractMethods, side) =>
442
+ contractMethods.forEach((contractMethod: ContractMethod) => {
443
+ describe(`${contractMethod}`, () => {
444
+ it(`${network} ${side} ${contractMethod} ${nativeTokenSymbol} -> ${tokenASymbol}`, async () => {
445
+ await testE2E(
446
+ tokens[nativeTokenSymbol],
447
+ tokens[tokenASymbol],
448
+ holders[nativeTokenSymbol],
449
+ side === SwapSide.SELL ? nativeTokenAmount : tokenAAmount,
450
+ side,
451
+ dexKey,
452
+ contractMethod,
453
+ network,
454
+ provider,
455
+ );
456
+ });
457
+ it(`${network} ${side} ${contractMethod} ${tokenASymbol} -> ${nativeTokenSymbol}`, async () => {
458
+ await testE2E(
459
+ tokens[tokenASymbol],
460
+ tokens[nativeTokenSymbol],
461
+ holders[tokenASymbol],
462
+ side === SwapSide.SELL ? tokenAAmount : nativeTokenAmount,
463
+ side,
464
+ dexKey,
465
+ contractMethod,
466
+ network,
467
+ provider,
468
+ );
469
+ });
470
+ it(`${network} ${side} ${contractMethod} ${tokenBSymbol} -> ${tokenASymbol}`, async () => {
471
+ await testE2E(
472
+ tokens[tokenBSymbol],
473
+ tokens[tokenASymbol],
474
+ holders[tokenASymbol],
475
+ side === SwapSide.SELL ? tokenBAmount : tokenAAmount,
476
+ side,
477
+ dexKey,
478
+ contractMethod,
479
+ network,
480
+ provider,
481
+ );
482
+ });
483
+ it(`${network} ${side} ${contractMethod} ${tokenASymbol} -> ${tokenBSymbol}`, async () => {
484
+ await testE2E(
485
+ tokens[tokenASymbol],
486
+ tokens[tokenBSymbol],
487
+ holders[tokenASymbol],
488
+ side === SwapSide.SELL ? tokenAAmount : tokenBAmount,
489
+ side,
490
+ dexKey,
491
+ contractMethod,
492
+ network,
493
+ provider,
494
+ );
495
+ });
496
+ });
497
+ }),
498
+ );
499
+ });
500
+
406
501
  describe('UniswapV3 Avalanche', () => {
407
502
  const network = Network.AVALANCHE;
408
503
  const tokens = Tokens[network];
@@ -25,6 +25,9 @@ export const WethConfig: DexConfigMap<DexParams> = {
25
25
  [Network.ZKEVM]: {
26
26
  poolGasCost: WethGasCost,
27
27
  },
28
+ [Network.BASE]: {
29
+ poolGasCost: WethGasCost,
30
+ },
28
31
  },
29
32
  Wbnb: {
30
33
  [Network.BSC]: {
@@ -51,14 +51,6 @@ export class Api3FeedSubscriber<State> extends PartialEventSubscriber<
51
51
  };
52
52
  }
53
53
 
54
- static getDapiNameHashMultiCallInput(proxy: Address): MultiCallInput {
55
- return {
56
- target: proxy,
57
- callData:
58
- Api3FeedSubscriber.proxyInterface.encodeFunctionData('dapiNameHash'),
59
- };
60
- }
61
-
62
54
  static getDataFeedId(proxy: Address): MultiCallInput {
63
55
  return {
64
56
  target: proxy,
@@ -67,33 +59,6 @@ export class Api3FeedSubscriber<State> extends PartialEventSubscriber<
67
59
  };
68
60
  }
69
61
 
70
- static getFeedIdFromDapiNameHash(
71
- api3Server: Address,
72
- dapiNameHash: string,
73
- ): MultiCallInput {
74
- return {
75
- target: api3Server,
76
- callData: Api3FeedSubscriber.api3ServerV1Iface.encodeFunctionData(
77
- 'dapiNameHashToDataFeedId',
78
- [dapiNameHash],
79
- ),
80
- };
81
- }
82
-
83
- static decodeFeedIdFromDapiNameHash(multicallOutput: MultiCallOutput) {
84
- return Api3FeedSubscriber.api3ServerV1Iface.decodeFunctionResult(
85
- 'dapiNameHashToDataFeedId',
86
- multicallOutput,
87
- )[0];
88
- }
89
-
90
- static decodeDapiNameHash(multicallOutput: MultiCallOutput) {
91
- return Api3FeedSubscriber.proxyInterface.decodeFunctionResult(
92
- 'dapiNameHash',
93
- multicallOutput,
94
- )[0];
95
- }
96
-
97
62
  static decodeDataFeedId(multicallOutput: MultiCallOutput) {
98
63
  return Api3FeedSubscriber.proxyInterface.decodeFunctionResult(
99
64
  'dataFeedId',
@@ -883,6 +883,17 @@ export const Tokens: {
883
883
  decimals: 6,
884
884
  },
885
885
  },
886
+ [Network.BASE]: {
887
+ PRIME: {
888
+ address: '0xfA980cEd6895AC314E7dE34Ef1bFAE90a5AdD21b',
889
+ decimals: 18,
890
+ },
891
+ WETH: {
892
+ address: '0x4200000000000000000000000000000000000006',
893
+ decimals: 18,
894
+ },
895
+ ETH: { address: ETHER_ADDRESS, decimals: 18 },
896
+ },
886
897
  };
887
898
 
888
899
  export const Holders: {
@@ -1102,6 +1113,11 @@ export const Holders: {
1102
1113
  WBTC: '0x99b31498b0a1dae01fc3433e3cb60f095340935c',
1103
1114
  USDC: '0x99b31498b0a1dae01fc3433e3cb60f095340935c',
1104
1115
  },
1116
+ [Network.BASE]: {
1117
+ WETH: '0x4bb6b2efe7036020ba6f02a05602546c9f25bf28',
1118
+ PRIME: '0x956bcc6b56c99db382d9d97a30ba5f1402144b3e',
1119
+ ETH: '0xdd9176ea3e7559d6b68b537ef555d3e89403f742',
1120
+ },
1105
1121
  };
1106
1122
 
1107
1123
  export const SmartTokens = Object.keys(Tokens).reduce((acc, _network) => {
@@ -1126,4 +1142,5 @@ export const NativeTokenSymbols: { [network: number]: string } = {
1126
1142
  [Network.FANTOM]: 'FTM',
1127
1143
  [Network.ARBITRUM]: 'ETH',
1128
1144
  [Network.OPTIMISM]: 'ETH',
1145
+ [Network.BASE]: 'ETH',
1129
1146
  };
@@ -1,70 +0,0 @@
1
- [
2
- {
3
- "anonymous": false,
4
- "inputs": [
5
- {
6
- "indexed": false,
7
- "internalType": "address",
8
- "name": "token",
9
- "type": "address"
10
- },
11
- {
12
- "indexed": false,
13
- "internalType": "uint256",
14
- "name": "price",
15
- "type": "uint256"
16
- },
17
- {
18
- "indexed": false,
19
- "internalType": "address",
20
- "name": "priceFeed",
21
- "type": "address"
22
- }
23
- ],
24
- "name": "PriceUpdate",
25
- "type": "event"
26
- },
27
- {
28
- "inputs": [
29
- { "internalType": "address", "name": "_token", "type": "address" },
30
- { "internalType": "uint256", "name": "_price", "type": "uint256" }
31
- ],
32
- "name": "emitPriceEvent",
33
- "outputs": [],
34
- "stateMutability": "nonpayable",
35
- "type": "function"
36
- },
37
- {
38
- "inputs": [],
39
- "name": "gov",
40
- "outputs": [{ "internalType": "address", "name": "", "type": "address" }],
41
- "stateMutability": "view",
42
- "type": "function"
43
- },
44
- {
45
- "inputs": [{ "internalType": "address", "name": "", "type": "address" }],
46
- "name": "isPriceFeed",
47
- "outputs": [{ "internalType": "bool", "name": "", "type": "bool" }],
48
- "stateMutability": "view",
49
- "type": "function"
50
- },
51
- {
52
- "inputs": [
53
- { "internalType": "address", "name": "_gov", "type": "address" }
54
- ],
55
- "name": "setGov",
56
- "outputs": [],
57
- "stateMutability": "nonpayable",
58
- "type": "function"
59
- },
60
- {
61
- "inputs": [
62
- { "internalType": "address", "name": "_priceFeed", "type": "address" },
63
- { "internalType": "bool", "name": "_isPriceFeed", "type": "bool" }
64
- ],
65
- "name": "setIsPriceFeed",
66
- "outputs": [],
67
- "stateMutability": "nonpayable",
68
- "type": "function"
69
- }
70
- ]