@paraswap/dex-lib 2.28.7 → 2.28.9-ramses-v2

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 (149) hide show
  1. package/.idea/aws.xml +17 -0
  2. package/.idea/codeStyles/Project.xml +19 -0
  3. package/.idea/codeStyles/codeStyleConfig.xml +5 -0
  4. package/.idea/misc.xml +6 -0
  5. package/.idea/modules.xml +8 -0
  6. package/.idea/paraswap-dex-lib.iml +9 -0
  7. package/.idea/vcs.xml +6 -0
  8. package/build/abi/RamsesV2StateMulticall.abi.json +891 -0
  9. package/build/abi/algebra/AlgebraPool.abi.json +727 -0
  10. package/build/abi/curve-v1/StableSwapFRXETH.json +889 -0
  11. package/build/abi/curve-v1/StableSwapWBETH.json +1223 -0
  12. package/build/abi/wBETH.json +1527 -0
  13. package/build/dex/algebra/algebra-pool.d.ts +46 -0
  14. package/build/dex/algebra/algebra-pool.js +336 -0
  15. package/build/dex/algebra/algebra-pool.js.map +1 -0
  16. package/build/dex/balancer-v2/balancer-v2.js +2 -0
  17. package/build/dex/balancer-v2/balancer-v2.js.map +1 -1
  18. package/build/dex/balancer-v2/optimizer.js +51 -38
  19. package/build/dex/balancer-v2/optimizer.js.map +1 -1
  20. package/build/dex/balancer-v2/types.d.ts +4 -0
  21. package/build/dex/balancer-v2/types.js.map +1 -1
  22. package/build/dex/curve-v1/pools/frxETHpool.d.ts +7 -0
  23. package/build/dex/curve-v1/pools/frxETHpool.js +27 -0
  24. package/build/dex/curve-v1/pools/frxETHpool.js.map +1 -0
  25. package/build/dex/curve-v1/pools/wbETHpool.d.ts +29 -0
  26. package/build/dex/curve-v1/pools/wbETHpool.js +408 -0
  27. package/build/dex/curve-v1/pools/wbETHpool.js.map +1 -0
  28. package/build/dex/curve-v1-factory/price-handlers/functions/calc_token_amount.js +26 -1
  29. package/build/dex/curve-v1-factory/price-handlers/functions/calc_token_amount.js.map +1 -1
  30. package/build/dex/index.js +2 -0
  31. package/build/dex/index.js.map +1 -1
  32. package/build/dex/pancakeswap-v3/types.d.ts +14 -0
  33. package/build/dex/{test-dex → pancakeswap-v3}/types.js.map +1 -1
  34. package/build/dex/{test-dex → ramses-v2}/config.d.ts +1 -1
  35. package/build/dex/ramses-v2/config.js +28 -0
  36. package/build/dex/ramses-v2/config.js.map +1 -0
  37. package/build/dex/ramses-v2/constants.d.ts +28 -0
  38. package/build/dex/ramses-v2/constants.js +35 -0
  39. package/build/dex/ramses-v2/constants.js.map +1 -0
  40. package/build/dex/ramses-v2/contract-math/BitMath.d.ts +4 -0
  41. package/build/dex/ramses-v2/contract-math/BitMath.js +93 -0
  42. package/build/dex/ramses-v2/contract-math/BitMath.js.map +1 -0
  43. package/build/dex/ramses-v2/contract-math/FixedPoint128.d.ts +3 -0
  44. package/build/dex/ramses-v2/contract-math/FixedPoint128.js +8 -0
  45. package/build/dex/ramses-v2/contract-math/FixedPoint128.js.map +1 -0
  46. package/build/dex/ramses-v2/contract-math/FixedPoint96.d.ts +4 -0
  47. package/build/dex/ramses-v2/contract-math/FixedPoint96.js +9 -0
  48. package/build/dex/ramses-v2/contract-math/FixedPoint96.js.map +1 -0
  49. package/build/dex/ramses-v2/contract-math/FullMath.d.ts +4 -0
  50. package/build/dex/ramses-v2/contract-math/FullMath.js +19 -0
  51. package/build/dex/ramses-v2/contract-math/FullMath.js.map +1 -0
  52. package/build/dex/ramses-v2/contract-math/LiquidityMath.d.ts +3 -0
  53. package/build/dex/ramses-v2/contract-math/LiquidityMath.js +22 -0
  54. package/build/dex/ramses-v2/contract-math/LiquidityMath.js.map +1 -0
  55. package/build/dex/ramses-v2/contract-math/Oracle.d.ts +10 -0
  56. package/build/dex/ramses-v2/contract-math/Oracle.js +133 -0
  57. package/build/dex/ramses-v2/contract-math/Oracle.js.map +1 -0
  58. package/build/dex/ramses-v2/contract-math/SqrtPriceMath.d.ts +10 -0
  59. package/build/dex/ramses-v2/contract-math/SqrtPriceMath.js +91 -0
  60. package/build/dex/ramses-v2/contract-math/SqrtPriceMath.js.map +1 -0
  61. package/build/dex/ramses-v2/contract-math/SwapMath.d.ts +8 -0
  62. package/build/dex/ramses-v2/contract-math/SwapMath.js +70 -0
  63. package/build/dex/ramses-v2/contract-math/SwapMath.js.map +1 -0
  64. package/build/dex/ramses-v2/contract-math/Tick.d.ts +7 -0
  65. package/build/dex/ramses-v2/contract-math/Tick.js +45 -0
  66. package/build/dex/ramses-v2/contract-math/Tick.js.map +1 -0
  67. package/build/dex/ramses-v2/contract-math/TickBitMap.d.ts +8 -0
  68. package/build/dex/ramses-v2/contract-math/TickBitMap.js +87 -0
  69. package/build/dex/ramses-v2/contract-math/TickBitMap.js.map +1 -0
  70. package/build/dex/ramses-v2/contract-math/TickMath.d.ts +8 -0
  71. package/build/dex/ramses-v2/contract-math/TickMath.js +162 -0
  72. package/build/dex/ramses-v2/contract-math/TickMath.js.map +1 -0
  73. package/build/dex/ramses-v2/contract-math/UnsafeMath.d.ts +3 -0
  74. package/build/dex/ramses-v2/contract-math/UnsafeMath.js +10 -0
  75. package/build/dex/ramses-v2/contract-math/UnsafeMath.js.map +1 -0
  76. package/build/dex/ramses-v2/contract-math/uniswap-v3-math.d.ts +18 -0
  77. package/build/dex/ramses-v2/contract-math/uniswap-v3-math.js +392 -0
  78. package/build/dex/ramses-v2/contract-math/uniswap-v3-math.js.map +1 -0
  79. package/build/dex/ramses-v2/contract-math/utils.d.ts +3 -0
  80. package/build/dex/ramses-v2/contract-math/utils.js +16 -0
  81. package/build/dex/ramses-v2/contract-math/utils.js.map +1 -0
  82. package/build/dex/ramses-v2/ramses-v2-pool.d.ts +44 -0
  83. package/build/dex/ramses-v2/ramses-v2-pool.js +327 -0
  84. package/build/dex/ramses-v2/ramses-v2-pool.js.map +1 -0
  85. package/build/dex/ramses-v2/ramses-v2.d.ts +61 -0
  86. package/build/dex/ramses-v2/ramses-v2.js +690 -0
  87. package/build/dex/ramses-v2/ramses-v2.js.map +1 -0
  88. package/build/dex/ramses-v2/types.d.ts +154 -0
  89. package/build/dex/ramses-v2/types.js +9 -0
  90. package/build/dex/ramses-v2/types.js.map +1 -0
  91. package/build/dex/ramses-v2/utils.d.ts +6 -0
  92. package/build/dex/ramses-v2/utils.js +71 -0
  93. package/build/dex/ramses-v2/utils.js.map +1 -0
  94. package/build/dex/solidly/forks-override/ramses.d.ts +8 -0
  95. package/build/dex/solidly/forks-override/ramses.js +15 -0
  96. package/build/dex/solidly/forks-override/ramses.js.map +1 -0
  97. package/build/dex/uniswap-v3/uniswap-v3.js +1 -1
  98. package/build/dex/uniswap-v3/uniswap-v3.js.map +1 -1
  99. package/build/lib/multi-wrapper.js +5 -3
  100. package/build/lib/multi-wrapper.js.map +1 -1
  101. package/package.json +1 -1
  102. package/src/abi/RamsesV2Pool.abi.json +1554 -0
  103. package/src/abi/RamsesV2StateMulticall.abi.json +891 -0
  104. package/src/dex/balancer-v2/balancer-v2.ts +2 -0
  105. package/src/dex/balancer-v2/optimizer.ts +62 -49
  106. package/src/dex/balancer-v2/types.ts +4 -0
  107. package/src/dex/curve-v1-factory/price-handlers/functions/calc_token_amount.ts +33 -1
  108. package/src/dex/index.ts +2 -0
  109. package/src/dex/ramses-v2/config.ts +31 -0
  110. package/src/dex/ramses-v2/constants.ts +41 -0
  111. package/src/dex/ramses-v2/contract-math/BitMath.ts +90 -0
  112. package/src/dex/ramses-v2/contract-math/FixedPoint128.ts +3 -0
  113. package/src/dex/ramses-v2/contract-math/FixedPoint96.ts +4 -0
  114. package/src/dex/ramses-v2/contract-math/FullMath.ts +30 -0
  115. package/src/dex/ramses-v2/contract-math/LiquidityMath.ts +17 -0
  116. package/src/dex/ramses-v2/contract-math/Oracle.ts +226 -0
  117. package/src/dex/ramses-v2/contract-math/SqrtPriceMath.ts +226 -0
  118. package/src/dex/ramses-v2/contract-math/SwapMath.ts +139 -0
  119. package/src/dex/ramses-v2/contract-math/Tick.ts +82 -0
  120. package/src/dex/ramses-v2/contract-math/TickBitMap.ts +128 -0
  121. package/src/dex/ramses-v2/contract-math/TickMath.ts +211 -0
  122. package/src/dex/ramses-v2/contract-math/UnsafeMath.ts +5 -0
  123. package/src/dex/ramses-v2/contract-math/uniswap-v3-math.ts +666 -0
  124. package/src/dex/ramses-v2/contract-math/utils.ts +11 -0
  125. package/src/dex/ramses-v2/ramses-v2-e2e.test.ts +100 -0
  126. package/src/dex/ramses-v2/ramses-v2-events.test.ts +182 -0
  127. package/src/dex/ramses-v2/ramses-v2-integration.test.ts +462 -0
  128. package/src/dex/ramses-v2/ramses-v2-pool.ts +546 -0
  129. package/src/dex/ramses-v2/ramses-v2.ts +1136 -0
  130. package/src/dex/ramses-v2/types.ts +177 -0
  131. package/src/dex/ramses-v2/utils.ts +90 -0
  132. package/src/dex/uniswap-v3/uniswap-v3-integration.test.ts +26 -3
  133. package/src/dex/uniswap-v3/uniswap-v3.ts +1 -1
  134. package/src/lib/multi-wrapper.ts +4 -4
  135. package/tests/constants-e2e.ts +1 -5
  136. package/tests/utils-e2e.ts +1 -0
  137. package/build/dex/test-dex/config.js +0 -15
  138. package/build/dex/test-dex/config.js.map +0 -1
  139. package/build/dex/test-dex/test-dex-pool.d.ts +0 -39
  140. package/build/dex/test-dex/test-dex-pool.js +0 -63
  141. package/build/dex/test-dex/test-dex-pool.js.map +0 -1
  142. package/build/dex/test-dex/test-dex.d.ts +0 -37
  143. package/build/dex/test-dex/test-dex.js +0 -126
  144. package/build/dex/test-dex/test-dex.js.map +0 -1
  145. package/build/dex/test-dex/types.d.ts +0 -6
  146. package/build/dex/woo-fi-v2/woo-fi-math.d.ts +0 -16
  147. package/build/dex/woo-fi-v2/woo-fi-math.js +0 -137
  148. package/build/dex/woo-fi-v2/woo-fi-math.js.map +0 -1
  149. /package/build/dex/{test-dex → pancakeswap-v3}/types.js +0 -0
@@ -0,0 +1,177 @@
1
+ import { BigNumber } from 'ethers';
2
+ import { NumberAsString } from '../../types';
3
+ import { Address } from '../../types';
4
+
5
+ export type OracleObservation = {
6
+ blockTimestamp: bigint;
7
+ tickCumulative: bigint;
8
+ secondsPerLiquidityCumulativeX128: bigint;
9
+ initialized: boolean;
10
+ };
11
+
12
+ export type OracleObservationCandidates = {
13
+ beforeOrAt: OracleObservation;
14
+ atOrAfter: OracleObservation;
15
+ };
16
+
17
+ export type TickInfo = {
18
+ liquidityGross: bigint;
19
+ liquidityNet: bigint;
20
+ tickCumulativeOutside: bigint;
21
+ secondsPerLiquidityOutsideX128: bigint;
22
+ secondsOutside: bigint;
23
+ initialized: boolean;
24
+ };
25
+
26
+ export type Slot0 = {
27
+ sqrtPriceX96: bigint;
28
+ tick: bigint;
29
+ observationIndex: number;
30
+ observationCardinality: number;
31
+ observationCardinalityNext: number;
32
+ feeProtocol: bigint;
33
+ };
34
+
35
+ export type PoolState = {
36
+ pool: string;
37
+ blockTimestamp: bigint;
38
+ tickSpacing: bigint;
39
+ fee: bigint;
40
+ slot0: Slot0;
41
+ liquidity: bigint;
42
+ maxLiquidityPerTick: bigint;
43
+ tickBitmap: Record<NumberAsString, bigint>;
44
+ ticks: Record<NumberAsString, TickInfo>;
45
+ observations: Record<number, OracleObservation>;
46
+ isValid: boolean;
47
+ startTickBitmap: bigint;
48
+ lowestKnownTick: bigint;
49
+ highestKnownTick: bigint;
50
+ balance0: bigint;
51
+ balance1: bigint;
52
+ };
53
+
54
+ export type RamsesV2Data = {
55
+ path: {
56
+ tokenIn: Address;
57
+ tokenOut: Address;
58
+ fee: NumberAsString;
59
+ }[];
60
+ isApproved?: boolean;
61
+ };
62
+
63
+ export type DexParams = {
64
+ router: Address;
65
+ quoter: Address;
66
+ factory: Address;
67
+ stateMulticall: Address;
68
+ uniswapMulticall: Address;
69
+ supportedFees: bigint[];
70
+ chunksCount: number;
71
+ deployer?: Address;
72
+ subgraphURL: string;
73
+ initHash: string;
74
+ };
75
+
76
+ export type RamsesV2SimpleSwapSellParam = {
77
+ path: string;
78
+ recipient: Address;
79
+ deadline: string;
80
+ amountIn: NumberAsString;
81
+ amountOutMinimum: NumberAsString;
82
+ };
83
+
84
+ export type RamsesV2SimpleSwapBuyParam = {
85
+ path: string;
86
+ recipient: Address;
87
+ deadline: string;
88
+ amountOut: NumberAsString;
89
+ amountInMaximum: NumberAsString;
90
+ };
91
+
92
+ export type RamsesV2SimpleSwapParams =
93
+ | RamsesV2SimpleSwapSellParam
94
+ | RamsesV2SimpleSwapBuyParam;
95
+
96
+ export type RamsesV2Param = [
97
+ fromToken: Address,
98
+ toToken: Address,
99
+ exchange: Address,
100
+ fromAmount: NumberAsString,
101
+ toAmount: NumberAsString,
102
+ expectedAmount: NumberAsString,
103
+ feePercent: NumberAsString,
104
+ deadline: NumberAsString,
105
+ partner: Address,
106
+ isApproved: boolean,
107
+ beneficiary: Address,
108
+ path: string,
109
+ permit: string,
110
+ uuid: string,
111
+ ];
112
+
113
+ export enum RamsesV2Functions {
114
+ exactInput = 'exactInput',
115
+ exactOutput = 'exactOutput',
116
+ }
117
+
118
+ export type TickInfoMappings = {
119
+ index: number;
120
+ value: TickInfo;
121
+ };
122
+
123
+ export type TickBitMapMappings = {
124
+ index: number;
125
+ value: bigint;
126
+ };
127
+
128
+ export type OutputResult = {
129
+ outputs: bigint[];
130
+ tickCounts: number[];
131
+ };
132
+
133
+ // Just rewrote every type with BigNumber basically
134
+
135
+ export type TickBitMapMappingsWithBigNumber = {
136
+ index: number;
137
+ value: BigNumber;
138
+ };
139
+
140
+ export type TickInfoWithBigNumber = {
141
+ initialized: boolean;
142
+ liquidityGross: BigNumber;
143
+ liquidityNet: BigNumber;
144
+ secondsOutside: number;
145
+ secondsPerLiquidityOutsideX128: BigNumber;
146
+ tickCumulativeOutside: BigNumber;
147
+ };
148
+
149
+ export type TickInfoMappingsWithBigNumber = {
150
+ index: number;
151
+ value: TickInfoWithBigNumber;
152
+ };
153
+
154
+ export type DecodedStateMultiCallResultWithRelativeBitmaps = {
155
+ pool: Address;
156
+ blockTimestamp: BigNumber;
157
+ slot0: {
158
+ feeProtocol: number;
159
+ observationCardinality: number;
160
+ observationCardinalityNext: number;
161
+ observationIndex: number;
162
+ sqrtPriceX96: BigNumber;
163
+ tick: number;
164
+ unlocked: boolean;
165
+ };
166
+ liquidity: BigNumber;
167
+ tickSpacing: number;
168
+ maxLiquidityPerTick: BigNumber;
169
+ observation: {
170
+ blockTimestamp: number;
171
+ initialized: boolean;
172
+ secondsPerLiquidityCumulativeX128: BigNumber;
173
+ tickCumulative: BigNumber;
174
+ };
175
+ tickBitmap: TickBitMapMappingsWithBigNumber[];
176
+ ticks: TickInfoMappingsWithBigNumber[];
177
+ };
@@ -0,0 +1,90 @@
1
+ import { BytesLike, ethers } from 'ethers';
2
+ import { assert } from 'ts-essentials';
3
+ import { extractSuccessAndValue } from '../../lib/decoders';
4
+ import { MultiResult } from '../../lib/multi-wrapper';
5
+ import { DexConfigMap } from '../../types';
6
+ import {
7
+ DexParams,
8
+ DecodedStateMultiCallResultWithRelativeBitmaps,
9
+ } from './types';
10
+
11
+ export function getUniswapV3DexKey(UniswapV3Config: DexConfigMap<DexParams>) {
12
+ const UniswapV3Keys = Object.keys(UniswapV3Config);
13
+ if (UniswapV3Keys.length !== 1) {
14
+ throw new Error(
15
+ `UniswapV3 key in UniswapV3Config is not unique. Update relevant places (optimizer) or fix config issue. Received: ${JSON.stringify(
16
+ UniswapV3Config,
17
+ (_0, value) => (typeof value === 'bigint' ? value.toString() : value),
18
+ )}`,
19
+ );
20
+ }
21
+
22
+ return UniswapV3Keys[0].toLowerCase();
23
+ }
24
+
25
+ export function decodeStateMultiCallResultWithRelativeBitmaps(
26
+ result: MultiResult<BytesLike> | BytesLike,
27
+ ): DecodedStateMultiCallResultWithRelativeBitmaps {
28
+ const [isSuccess, toDecode] = extractSuccessAndValue(result);
29
+
30
+ assert(
31
+ isSuccess && toDecode !== '0x',
32
+ `decodeStateMultiCallResultWithRelativeBitmaps failed to get decodable result: ${result}`,
33
+ );
34
+
35
+ const decoded = ethers.utils.defaultAbiCoder.decode(
36
+ [
37
+ // I don't want to pass here any interface, so I just use it in ethers format
38
+ `
39
+ tuple(
40
+ address pool,
41
+ uint256 blockTimestamp,
42
+ tuple(
43
+ uint160 sqrtPriceX96,
44
+ int24 tick,
45
+ uint16 observationIndex,
46
+ uint16 observationCardinality,
47
+ uint16 observationCardinalityNext,
48
+ uint8 feeProtocol,
49
+ bool unlocked,
50
+ ) slot0,
51
+ uint128 liquidity,
52
+ int24 tickSpacing,
53
+ uint128 maxLiquidityPerTick,
54
+ tuple(
55
+ uint32 blockTimestamp,
56
+ int56 tickCumulative,
57
+ uint160 secondsPerLiquidityCumulativeX128,
58
+ bool initialized,
59
+ uint160 secondsPerBoostedLiquidityPeriodX128,
60
+ uint32 boostedInRange,
61
+ ) observation,
62
+ tuple(
63
+ int16 index,
64
+ uint256 value
65
+ )[] tickBitmap,
66
+ tuple(
67
+ int24 index,
68
+ tuple(
69
+ uint128 liquidityGross,
70
+ int128 liquidityNet,
71
+ uint128 cleanUnusedSlot,
72
+ uint128 cleanUnusedSlot2,
73
+ uint256 feeGrowthOutside0X128,
74
+ uint256 feeGrowthOutside1X128,
75
+ int56 tickCumulativeOutside,
76
+ uint160 secondsPerLiquidityOutsideX128,
77
+ uint32 secondsOutside,
78
+ bool initialized,
79
+ ) value,
80
+ )[] ticks
81
+ )
82
+ `,
83
+ ],
84
+ toDecode,
85
+ )[0];
86
+
87
+ // This conversion is not precise, because when we decode, we have more values
88
+ // But I typed only the ones that are used later
89
+ return decoded as DecodedStateMultiCallResultWithRelativeBitmaps;
90
+ }
@@ -88,8 +88,18 @@ async function checkOnChainPricing(
88
88
  return false;
89
89
  }
90
90
 
91
+ // const readerCallData = getReaderCalldata(
92
+ // exchangeAddress,
93
+ // readerIface,
94
+ // _amounts.slice(1),
95
+ // funcName,
96
+ // tokenIn,
97
+ // tokenOut,
98
+ // fee,
99
+ // );
100
+
91
101
  const readerCallData = getReaderCalldata(
92
- exchangeAddress,
102
+ '0x61fFE014bA17989E743c5F6cB21bF9697530B21e',
93
103
  readerIface,
94
104
  _amounts.slice(1),
95
105
  funcName,
@@ -138,9 +148,22 @@ describe('UniswapV3', function () {
138
148
  blockNumber = await dexHelper.web3Provider.eth.getBlockNumber();
139
149
  uniswapV3 = new UniswapV3(network, dexKey, dexHelper);
140
150
  uniswapV3Mainnet = new UniswapV3(
141
- Network.MAINNET,
151
+ Network.ARBITRUM,
142
152
  dexKey,
143
- new DummyDexHelper(Network.MAINNET),
153
+ new DummyDexHelper(Network.ARBITRUM),
154
+ );
155
+ });
156
+
157
+
158
+ it('fgggg', async () => {
159
+ const readerCallData = getReaderCalldata(
160
+ '',
161
+ readerIface,
162
+ _amounts.slice(1),
163
+ funcName,
164
+ tokenIn,
165
+ tokenOut,
166
+ fee,
144
167
  );
145
168
  });
146
169
 
@@ -276,7 +276,7 @@ export class UniswapV3
276
276
  e,
277
277
  );
278
278
  } else {
279
- // on unkown error mark as failed and increase retryCount for retry init strategy
279
+ // on unknown error mark as failed and increase retryCount for retry init strategy
280
280
  // note: state would be null by default which allows to fallback
281
281
  this.logger.warn(
282
282
  `${this.dexKey}: Can not generate pool state for srcAddress=${srcAddress}, destAddress=${destAddress}, fee=${fee} pool fallback to rpc and retry every ${this.config.initRetryFrequency} times, initRetryAttemptCount=${pool.initRetryAttemptCount}`,
@@ -65,11 +65,11 @@ export class MultiWrapper {
65
65
  }
66
66
 
67
67
  const aggregatedResult = await Promise.all(
68
- allCalls.map(batch =>
69
- this.multi.methods
68
+ allCalls.map(batch => {
69
+ return this.multi.methods
70
70
  .tryAggregate(mandatory, batch)
71
- .call(undefined, blockNumber),
72
- ),
71
+ .call(undefined, blockNumber);
72
+ })
73
73
  );
74
74
 
75
75
  let globalInd = 0;
@@ -785,10 +785,6 @@ export const Tokens: {
785
785
  address: '0x2f2a2543b76a4166549f7aab2e75bef0aefc5b0f',
786
786
  decimals: 8,
787
787
  },
788
- USDCe: {
789
- address: '0xff970a61a04b1ca14834a43f5de4533ebddb5cc8',
790
- decimals: 6,
791
- },
792
788
  LEX: {
793
789
  address: '0x6bB7A17AcC227fd1F6781D1EEDEAE01B42047eE0',
794
790
  decimals: 18,
@@ -1020,7 +1016,7 @@ export const Holders: {
1020
1016
  USDCe: '0x62383739d68dd0f844103db8dfb05a7eded5bbe6',
1021
1017
  USDC: '0xa843392198862f98d17e3aa1421b08f2c2020cff',
1022
1018
  OHM: '0xebce5f29ff5ca9aa330ebdf7ec6b5f474bff271e',
1023
- USDT: '0x62383739d68dd0f844103db8dfb05a7eded5bbe6',
1019
+ USDT: '0x5ff47d4ab75bcaff6807c81f1367abb53439883c',
1024
1020
  POPS: '0x4b78b52e7de4d8b7d367297cb8a87c1875a9d591',
1025
1021
  FRAX: '0x59bf0545fca0e5ad48e13da269facd2e8c886ba4',
1026
1022
  nUSD: '0x9dd329f5411466d9e0c488ff72519ca9fef0cb40',
@@ -340,6 +340,7 @@ export async function testE2E(
340
340
  }
341
341
  }
342
342
 
343
+ console.log('DEX KEY: ', dexKey);
343
344
  const useAPI = testingEndpoint && !poolIdentifiers;
344
345
  // The API currently doesn't allow for specifying poolIdentifiers
345
346
  const paraswap: IParaSwapSDK = useAPI
@@ -1,15 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Adapters = exports.TestDexConfig = void 0;
4
- const constants_1 = require("../../constants");
5
- exports.TestDexConfig = {
6
- TestDex: {
7
- // TODO: complete me!
8
- },
9
- };
10
- exports.Adapters = {
11
- // TODO: add adapters for each chain
12
- // This is an example to copy
13
- [constants_1.Network.MAINNET]: { [constants_1.SwapSide.SELL]: [{ name: '', index: 0 }] },
14
- };
15
- //# sourceMappingURL=config.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"config.js","sourceRoot":"","sources":["../../../src/dex/test-dex/config.ts"],"names":[],"mappings":";;;AAEA,+CAAoD;AAEvC,QAAA,aAAa,GAA4B;IACpD,OAAO,EAAE;IACP,qBAAqB;KACtB;CACF,CAAC;AAEW,QAAA,QAAQ,GAAoC;IACvD,oCAAoC;IACpC,6BAA6B;IAC7B,CAAC,mBAAO,CAAC,OAAO,CAAC,EAAE,EAAE,CAAC,oBAAQ,CAAC,IAAI,CAAC,EAAE,CAAC,EAAE,IAAI,EAAE,EAAE,EAAE,KAAK,EAAE,CAAC,EAAE,CAAC,EAAE;CACjE,CAAC"}
@@ -1,39 +0,0 @@
1
- import { Interface } from '@ethersproject/abi';
2
- import { DeepReadonly } from 'ts-essentials';
3
- import { Log, Logger } from '../../types';
4
- import { StatefulEventSubscriber } from '../../stateful-event-subscriber';
5
- import { IDexHelper } from '../../dex-helper/idex-helper';
6
- import { PoolState } from './types';
7
- export declare class TestDexEventPool extends StatefulEventSubscriber<PoolState> {
8
- protected parentName: string;
9
- protected network: number;
10
- protected dexHelper: IDexHelper;
11
- protected testDexIface: Interface;
12
- handlers: {
13
- [event: string]: (event: any, state: DeepReadonly<PoolState>, log: Readonly<Log>) => DeepReadonly<PoolState> | null;
14
- };
15
- logDecoder: (log: Log) => any;
16
- addressesSubscribed: string[];
17
- constructor(parentName: string, network: number, dexHelper: IDexHelper, logger: Logger, testDexIface?: Interface);
18
- /**
19
- * The function is called every time any of the subscribed
20
- * addresses release log. The function accepts the current
21
- * state, updates the state according to the log, and returns
22
- * the updated state.
23
- * @param state - Current state of event subscriber
24
- * @param log - Log released by one of the subscribed addresses
25
- * @returns Updates state of the event subscriber after the log
26
- */
27
- protected processLog(state: DeepReadonly<PoolState>, log: Readonly<Log>): DeepReadonly<PoolState> | null;
28
- /**
29
- * The function generates state using on-chain calls. This
30
- * function is called to regenerate state if the event based
31
- * system fails to fetch events and the local state is no
32
- * more correct.
33
- * @param blockNumber - Blocknumber for which the state should
34
- * should be generated
35
- * @returns state of the event subscriber at blocknumber
36
- */
37
- generateState(blockNumber: number): Promise<DeepReadonly<PoolState>>;
38
- handleMyEvent(event: any, state: DeepReadonly<PoolState>, log: Readonly<Log>): DeepReadonly<PoolState> | null;
39
- }
@@ -1,63 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.TestDexEventPool = void 0;
4
- const abi_1 = require("@ethersproject/abi");
5
- const utils_1 = require("../../utils");
6
- const stateful_event_subscriber_1 = require("../../stateful-event-subscriber");
7
- class TestDexEventPool extends stateful_event_subscriber_1.StatefulEventSubscriber {
8
- constructor(parentName, network, dexHelper, logger, testDexIface = new abi_1.Interface('' /* TODO: Import and put here TestDex ABI */)) {
9
- super(parentName, logger);
10
- this.parentName = parentName;
11
- this.network = network;
12
- this.dexHelper = dexHelper;
13
- this.testDexIface = testDexIface;
14
- this.handlers = {};
15
- // TODO: make logDecoder decode logs that
16
- this.logDecoder = (log) => this.testDexIface.parseLog(log);
17
- this.addressesSubscribed = [
18
- /* subscribed addresses */
19
- ];
20
- // Add handlers
21
- this.handlers['myEvent'] = this.handleMyEvent.bind(this);
22
- }
23
- /**
24
- * The function is called every time any of the subscribed
25
- * addresses release log. The function accepts the current
26
- * state, updates the state according to the log, and returns
27
- * the updated state.
28
- * @param state - Current state of event subscriber
29
- * @param log - Log released by one of the subscribed addresses
30
- * @returns Updates state of the event subscriber after the log
31
- */
32
- processLog(state, log) {
33
- try {
34
- const event = this.logDecoder(log);
35
- if (event.name in this.handlers) {
36
- return this.handlers[event.name](event, state, log);
37
- }
38
- }
39
- catch (e) {
40
- (0, utils_1.catchParseLogError)(e, this.logger);
41
- }
42
- return null;
43
- }
44
- /**
45
- * The function generates state using on-chain calls. This
46
- * function is called to regenerate state if the event based
47
- * system fails to fetch events and the local state is no
48
- * more correct.
49
- * @param blockNumber - Blocknumber for which the state should
50
- * should be generated
51
- * @returns state of the event subscriber at blocknumber
52
- */
53
- async generateState(blockNumber) {
54
- // TODO: complete me!
55
- return {};
56
- }
57
- // Its just a dummy example
58
- handleMyEvent(event, state, log) {
59
- return null;
60
- }
61
- }
62
- exports.TestDexEventPool = TestDexEventPool;
63
- //# sourceMappingURL=test-dex-pool.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"test-dex-pool.js","sourceRo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;;;;;;OAQG;IACH,KAAK,CAAC,aAAa,CAAC,WAAmB;QACrC,qBAAqB;QACrB,OAAO,EAAE,CAAC;IACZ,CAAC;IAED,2BAA2B;IAC3B,aAAa,CACX,KAAU,EACV,KAA8B,EAC9B,GAAkB;QAElB,OAAO,IAAI,CAAC;IACd,CAAC;CACF;AA/ED,4CA+EC"}
@@ -1,37 +0,0 @@
1
- import { AsyncOrSync } from 'ts-essentials';
2
- import { Token, Address, ExchangePrices, PoolPrices, AdapterExchangeParam, SimpleExchangeParam, PoolLiquidity, Logger } from '../../types';
3
- import { SwapSide, Network } from '../../constants';
4
- import { IDex } from '../../dex/idex';
5
- import { IDexHelper } from '../../dex-helper/idex-helper';
6
- import { TestDexData } from './types';
7
- import { SimpleExchange } from '../simple-exchange';
8
- import { TestDexEventPool } from './test-dex-pool';
9
- export declare class TestDex extends SimpleExchange implements IDex<TestDexData> {
10
- readonly network: Network;
11
- readonly dexKey: string;
12
- readonly dexHelper: IDexHelper;
13
- protected adapters: import("../../types").AdapterMappings;
14
- protected eventPools: TestDexEventPool;
15
- readonly hasConstantPriceLargeAmounts = false;
16
- readonly needWrapNative = true;
17
- readonly isFeeOnTransferSupported = false;
18
- static dexKeysWithNetwork: {
19
- key: string;
20
- networks: Network[];
21
- }[];
22
- logger: Logger;
23
- constructor(network: Network, dexKey: string, dexHelper: IDexHelper, adapters?: import("../../types").AdapterMappings);
24
- initializePricing(blockNumber: number): Promise<void>;
25
- getAdapters(side: SwapSide): {
26
- name: string;
27
- index: number;
28
- }[] | null;
29
- getPoolIdentifiers(srcToken: Token, destToken: Token, side: SwapSide, blockNumber: number): Promise<string[]>;
30
- getPricesVolume(srcToken: Token, destToken: Token, amounts: bigint[], side: SwapSide, blockNumber: number, limitPools?: string[]): Promise<null | ExchangePrices<TestDexData>>;
31
- getCalldataGasCost(poolPrices: PoolPrices<TestDexData>): number | number[];
32
- getAdapterParam(srcToken: string, destToken: string, srcAmount: string, destAmount: string, data: TestDexData, side: SwapSide): AdapterExchangeParam;
33
- getSimpleParam(srcToken: string, destToken: string, srcAmount: string, destAmount: string, data: TestDexData, side: SwapSide): Promise<SimpleExchangeParam>;
34
- updatePoolState(): Promise<void>;
35
- getTopPoolsForToken(tokenAddress: Address, limit: number): Promise<PoolLiquidity[]>;
36
- releaseResources(): AsyncOrSync<void>;
37
- }
@@ -1,126 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || function (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
24
- };
25
- Object.defineProperty(exports, "__esModule", { value: true });
26
- exports.TestDex = void 0;
27
- const CALLDATA_GAS_COST = __importStar(require("../../calldata-gas-cost"));
28
- const utils_1 = require("../../utils");
29
- const simple_exchange_1 = require("../simple-exchange");
30
- const config_1 = require("./config");
31
- const test_dex_pool_1 = require("./test-dex-pool");
32
- class TestDex extends simple_exchange_1.SimpleExchange {
33
- constructor(network, dexKey, dexHelper, adapters = config_1.Adapters[network] || {}) {
34
- super(dexHelper, dexKey);
35
- this.network = network;
36
- this.dexKey = dexKey;
37
- this.dexHelper = dexHelper;
38
- this.adapters = adapters;
39
- this.hasConstantPriceLargeAmounts = false;
40
- // TODO: set true here if protocols works only with wrapped asset
41
- this.needWrapNative = true;
42
- this.isFeeOnTransferSupported = false;
43
- this.logger = dexHelper.getLogger(dexKey);
44
- this.eventPools = new test_dex_pool_1.TestDexEventPool(dexKey, network, dexHelper, this.logger);
45
- }
46
- // Initialize pricing is called once in the start of
47
- // pricing service. It is intended to setup the integration
48
- // for pricing requests. It is optional for a DEX to
49
- // implement this function
50
- async initializePricing(blockNumber) {
51
- // TODO: complete me!
52
- }
53
- // Returns the list of contract adapters (name and index)
54
- // for a buy/sell. Return null if there are no adapters.
55
- getAdapters(side) {
56
- return this.adapters[side] ? this.adapters[side] : null;
57
- }
58
- // Returns list of pool identifiers that can be used
59
- // for a given swap. poolIdentifiers must be unique
60
- // across DEXes. It is recommended to use
61
- // ${dexKey}_${poolAddress} as a poolIdentifier
62
- async getPoolIdentifiers(srcToken, destToken, side, blockNumber) {
63
- // TODO: complete me!
64
- return [];
65
- }
66
- // Returns pool prices for amounts.
67
- // If limitPools is defined only pools in limitPools
68
- // should be used. If limitPools is undefined then
69
- // any pools can be used.
70
- async getPricesVolume(srcToken, destToken, amounts, side, blockNumber, limitPools) {
71
- // TODO: complete me!
72
- return null;
73
- }
74
- // Returns estimated gas cost of calldata for this DEX in multiSwap
75
- getCalldataGasCost(poolPrices) {
76
- // TODO: update if there is any payload in getAdapterParam
77
- return CALLDATA_GAS_COST.DEX_NO_PAYLOAD;
78
- }
79
- // Encode params required by the exchange adapter
80
- // Used for multiSwap, buy & megaSwap
81
- // Hint: abiCoder.encodeParameter() could be useful
82
- getAdapterParam(srcToken, destToken, srcAmount, destAmount, data, side) {
83
- // TODO: complete me!
84
- const { exchange } = data;
85
- // Encode here the payload for adapter
86
- const payload = '';
87
- return {
88
- targetExchange: exchange,
89
- payload,
90
- networkFee: '0',
91
- };
92
- }
93
- // Encode call data used by simpleSwap like routers
94
- // Used for simpleSwap & simpleBuy
95
- // Hint: this.buildSimpleParamWithoutWETHConversion
96
- // could be useful
97
- async getSimpleParam(srcToken, destToken, srcAmount, destAmount, data, side) {
98
- // TODO: complete me!
99
- const { exchange } = data;
100
- // Encode here the transaction arguments
101
- const swapData = '';
102
- return this.buildSimpleParamWithoutWETHConversion(srcToken, srcAmount, destToken, destAmount, swapData, exchange);
103
- }
104
- // This is called once before getTopPoolsForToken is
105
- // called for multiple tokens. This can be helpful to
106
- // update common state required for calculating
107
- // getTopPoolsForToken. It is optional for a DEX
108
- // to implement this
109
- async updatePoolState() {
110
- // TODO: complete me!
111
- }
112
- // Returns list of top pools based on liquidity. Max
113
- // limit number pools should be returned.
114
- async getTopPoolsForToken(tokenAddress, limit) {
115
- //TODO: complete me!
116
- return [];
117
- }
118
- // This is optional function in case if your implementation has acquired any resources
119
- // you need to release for graceful shutdown. For example, it may be any interval timer
120
- releaseResources() {
121
- // TODO: complete me!
122
- }
123
- }
124
- exports.TestDex = TestDex;
125
- TestDex.dexKeysWithNetwork = (0, utils_1.getDexKeysWithNetwork)(config_1.TestDexConfig);
126
- //# sourceMappingURL=test-dex.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"test-dex.js","sourceRoot":"","sources":["../../../src/dex/test-dex/test-dex.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAYA,2EAA6D;AAC7D,uCAAoD;AAIpD,wDAAoD;AACpD,qCAAmD;AACnD,mDAAmD;AAEnD,MAAa,OACX,SAAQ,gCAAc;IAgBtB,YACW,OAAgB,EAChB,MAAc,EACd,SAAqB,EACpB,WAAW,iBAAQ,CAAC,OAAO,CAAC,IAAI,EAAE;QAE5C,KAAK,CAAC,SAAS,EAAE,MAAM,CAAC,CAAC;QALhB,YAAO,GAAP,OAAO,CAAS;QAChB,WAAM,GAAN,MAAM,CAAQ;QACd,cAAS,GAAT,SAAS,CAAY;QACpB,aAAQ,GAAR,QAAQ,CAA0B;QAfrC,iCAA4B,GAAG,KAAK,CAAC;QAC9C,iEAAiE;QACxD,mBAAc,GA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AE,QAAQ,EAAE,GAAG,IAAI,CAAC;QAE1B,sCAAsC;QACtC,MAAM,OAAO,GAAG,EAAE,CAAC;QAEnB,OAAO;YACL,cAAc,EAAE,QAAQ;YACxB,OAAO;YACP,UAAU,EAAE,GAAG;SAChB,CAAC;IACJ,CAAC;IAED,mDAAmD;IACnD,kCAAkC;IAClC,mDAAmD;IACnD,kBAAkB;IAClB,KAAK,CAAC,cAAc,CAClB,QAAgB,EAChB,SAAiB,EACjB,SAAiB,EACjB,UAAkB,EAClB,IAAiB,EACjB,IAAc;QAEd,qBAAqB;QACrB,MAAM,EAAE,QAAQ,EAAE,GAAG,IAAI,CAAC;QAE1B,wCAAwC;QACxC,MAAM,QAAQ,GAAG,EAAE,CAAC;QAEpB,OAAO,IAAI,CAAC,qCAAqC,CAC/C,QAAQ,EACR,SAAS,EACT,SAAS,EACT,UAAU,EACV,QAAQ,EACR,QAAQ,CACT,CAAC;IACJ,CAAC;IAED,oDAAoD;IACpD,qDAAqD;IACrD,+CAA+C;IAC/C,gDAAgD;IAChD,oBAAoB;IACpB,KAAK,CAAC,eAAe;QACnB,qBAAqB;IACvB,CAAC;IAED,oDAAoD;IACpD,yCAAyC;IACzC,KAAK,CAAC,mBAAmB,CACvB,YAAqB,EACrB,KAAa;QAEb,oBAAoB;QACpB,OAAO,EAAE,CAAC;IACZ,CAAC;IAED,sFAAsF;IACtF,uFAAuF;IACvF,gBAAgB;QACd,qBAAqB;IACvB,CAAC;;AAhKH,0BAiKC;AArJe,0BAAkB,GAC9B,IAAA,6BAAqB,EAAC,sBAAa,CAAC,CAAC"}
@@ -1,6 +0,0 @@
1
- import { Address } from '../../types';
2
- export declare type PoolState = {};
3
- export declare type TestDexData = {
4
- exchange: Address;
5
- };
6
- export declare type DexParams = {};