@paraswap/dex-lib 3.8.1 → 3.8.3

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 (213) hide show
  1. package/.vscode/launch.json +9 -49
  2. package/.vscode/settings.json +2 -1
  3. package/build/abi/Uncompressor.json +250 -0
  4. package/build/abi/integral/factory.json +333 -0
  5. package/build/abi/integral/oracle.json +501 -0
  6. package/build/abi/integral/pool.json +1041 -0
  7. package/build/abi/{wombat/pool.json → integral/relayer.json} +720 -473
  8. package/build/abi/oswap/oswap.abi.json +452 -0
  9. package/build/dex/aave-v1/aave-v1.d.ts +1 -2
  10. package/build/dex/aave-v1/aave-v1.js +0 -23
  11. package/build/dex/aave-v1/aave-v1.js.map +1 -1
  12. package/build/dex/aave-v3/aave-v3.js +2 -1
  13. package/build/dex/aave-v3/aave-v3.js.map +1 -1
  14. package/build/dex/aave-v3-stata/aave-v3-stata.js +1 -0
  15. package/build/dex/aave-v3-stata/aave-v3-stata.js.map +1 -1
  16. package/build/dex/angle-staked-stable/angle-staked-stable.js +4 -1
  17. package/build/dex/angle-staked-stable/angle-staked-stable.js.map +1 -1
  18. package/build/dex/compound/compound.js +2 -1
  19. package/build/dex/compound/compound.js.map +1 -1
  20. package/build/dex/compound.js +1 -1
  21. package/build/dex/compound.js.map +1 -1
  22. package/build/dex/etherfi/etherfi.d.ts +26 -0
  23. package/build/dex/etherfi/etherfi.js +96 -0
  24. package/build/dex/etherfi/etherfi.js.map +1 -0
  25. package/build/dex/etherfi.js +4 -1
  26. package/build/dex/etherfi.js.map +1 -1
  27. package/build/dex/idle-dao/idle-dao.js +1 -0
  28. package/build/dex/idle-dao/idle-dao.js.map +1 -1
  29. package/build/dex/integral/config.d.ts +4 -0
  30. package/build/dex/integral/config.js +20 -0
  31. package/build/dex/integral/config.js.map +1 -0
  32. package/build/dex/integral/context.d.ts +33 -0
  33. package/build/dex/integral/context.js +98 -0
  34. package/build/dex/integral/context.js.map +1 -0
  35. package/build/dex/integral/helpers.d.ts +17 -0
  36. package/build/dex/integral/helpers.js +157 -0
  37. package/build/dex/integral/helpers.js.map +1 -0
  38. package/build/dex/integral/integral-factory.d.ts +21 -0
  39. package/build/dex/integral/integral-factory.js +92 -0
  40. package/build/dex/integral/integral-factory.js.map +1 -0
  41. package/build/dex/integral/integral-pool.d.ts +46 -0
  42. package/build/dex/integral/integral-pool.js +143 -0
  43. package/build/dex/integral/integral-pool.js.map +1 -0
  44. package/build/dex/integral/integral-pricing.d.ts +18 -0
  45. package/build/dex/integral/integral-pricing.js +114 -0
  46. package/build/dex/integral/integral-pricing.js.map +1 -0
  47. package/build/dex/integral/integral-relayer.d.ts +39 -0
  48. package/build/dex/integral/integral-relayer.js +189 -0
  49. package/build/dex/integral/integral-relayer.js.map +1 -0
  50. package/build/dex/integral/integral-token.d.ts +22 -0
  51. package/build/dex/integral/integral-token.js +55 -0
  52. package/build/dex/integral/integral-token.js.map +1 -0
  53. package/build/dex/integral/integral.d.ts +41 -0
  54. package/build/dex/integral/integral.js +382 -0
  55. package/build/dex/integral/integral.js.map +1 -0
  56. package/build/dex/integral/types.d.ts +84 -0
  57. package/build/dex/integral/types.js +9 -0
  58. package/build/dex/integral/types.js.map +1 -0
  59. package/build/dex/integral/utils.d.ts +6 -0
  60. package/build/dex/integral/utils.js +23 -0
  61. package/build/dex/integral/utils.js.map +1 -0
  62. package/build/dex/mStable.js +1 -1
  63. package/build/dex/mStable.js.map +1 -1
  64. package/build/dex/oswap/config.d.ts +5 -0
  65. package/build/dex/oswap/config.js +31 -0
  66. package/build/dex/oswap/config.js.map +1 -0
  67. package/build/dex/oswap/oswap-pool.d.ts +51 -0
  68. package/build/dex/oswap/oswap-pool.js +150 -0
  69. package/build/dex/oswap/oswap-pool.js.map +1 -0
  70. package/build/dex/oswap/oswap.d.ts +46 -0
  71. package/build/dex/oswap/oswap.js +266 -0
  72. package/build/dex/oswap/oswap.js.map +1 -0
  73. package/build/dex/oswap/types.d.ts +20 -0
  74. package/build/dex/oswap/types.js +3 -0
  75. package/build/dex/oswap/types.js.map +1 -0
  76. package/build/dex/paraswap-limit-orders/paraswap-limit-orders.js +3 -0
  77. package/build/dex/paraswap-limit-orders/paraswap-limit-orders.js.map +1 -1
  78. package/build/dex/platypus/platypus.d.ts +1 -2
  79. package/build/dex/platypus/platypus.js +0 -45
  80. package/build/dex/platypus/platypus.js.map +1 -1
  81. package/build/dex/sdai/config.d.ts +11 -0
  82. package/build/dex/sdai/config.js +21 -0
  83. package/build/dex/sdai/config.js.map +1 -0
  84. package/build/dex/sdai/constants.d.ts +2 -0
  85. package/build/dex/sdai/constants.js +6 -0
  86. package/build/dex/sdai/constants.js.map +1 -0
  87. package/build/dex/sdai/scripts/validate-state.js +102 -0
  88. package/build/dex/sdai/scripts/validate-state.js.map +1 -0
  89. package/build/dex/sdai/sdai-pool.d.ts +16 -0
  90. package/build/dex/sdai/sdai-pool.js +85 -0
  91. package/build/dex/sdai/sdai-pool.js.map +1 -0
  92. package/build/dex/sdai/sdai.d.ts +51 -0
  93. package/build/dex/sdai/sdai.js +172 -0
  94. package/build/dex/sdai/sdai.js.map +1 -0
  95. package/build/dex/sdai/types.d.ts +21 -0
  96. package/build/dex/sdai/types.js +11 -0
  97. package/build/dex/sdai/types.js.map +1 -0
  98. package/build/dex/sdai/utils.d.ts +4 -0
  99. package/build/dex/sdai/utils.js +39 -0
  100. package/build/dex/sdai/utils.js.map +1 -0
  101. package/build/dex/simple-exchange.d.ts +1 -1
  102. package/build/dex/simple-exchange.js +4 -2
  103. package/build/dex/simple-exchange.js.map +1 -1
  104. package/build/dex/spark/spark.js +2 -1
  105. package/build/dex/spark/spark.js.map +1 -1
  106. package/build/dex/stable-pool.js +8 -1
  107. package/build/dex/stable-pool.js.map +1 -1
  108. package/build/dex/swaap-v1/swaap-v1.d.ts +1 -2
  109. package/build/dex/swaap-v1/swaap-v1.js +0 -14
  110. package/build/dex/swaap-v1/swaap-v1.js.map +1 -1
  111. package/build/executor/Executor01BytecodeBuilder.js +3 -1
  112. package/build/executor/Executor01BytecodeBuilder.js.map +1 -1
  113. package/build/executor/Executor02BytecodeBuilder.js +3 -1
  114. package/build/executor/Executor02BytecodeBuilder.js.map +1 -1
  115. package/build/executor/Executor03BytecodeBuilder.js +2 -0
  116. package/build/executor/Executor03BytecodeBuilder.js.map +1 -1
  117. package/build/executor/ExecutorBytecodeBuilder.js +2 -0
  118. package/build/executor/ExecutorBytecodeBuilder.js.map +1 -1
  119. package/build/executor/compressor/Compressor.d.ts +23 -0
  120. package/build/executor/compressor/Compressor.js +144 -0
  121. package/build/executor/compressor/Compressor.js.map +1 -0
  122. package/build/executor/compressor/compress.d.ts +17 -0
  123. package/build/executor/compressor/compress.js +187 -0
  124. package/build/executor/compressor/compress.js.map +1 -0
  125. package/build/executor/compressor/compress_functions/addressSubstitution.d.ts +6 -0
  126. package/build/executor/compressor/compress_functions/addressSubstitution.js +29 -0
  127. package/build/executor/compressor/compress_functions/addressSubstitution.js.map +1 -0
  128. package/build/executor/compressor/compress_functions/addressSubstitutionFromObject.d.ts +10 -0
  129. package/build/executor/compressor/compress_functions/addressSubstitutionFromObject.js +40 -0
  130. package/build/executor/compressor/compress_functions/addressSubstitutionFromObject.js.map +1 -0
  131. package/build/executor/compressor/compress_functions/byteSubstitution.d.ts +11 -0
  132. package/build/executor/compressor/compress_functions/byteSubstitution.js +64 -0
  133. package/build/executor/compressor/compress_functions/byteSubstitution.js.map +1 -0
  134. package/build/executor/compressor/compress_functions/ffSubstitution.d.ts +7 -0
  135. package/build/executor/compressor/compress_functions/ffSubstitution.js +54 -0
  136. package/build/executor/compressor/compress_functions/ffSubstitution.js.map +1 -0
  137. package/build/executor/compressor/compress_functions/findLongestAndSubstitute.d.ts +8 -0
  138. package/build/executor/compressor/compress_functions/findLongestAndSubstitute.js +67 -0
  139. package/build/executor/compressor/compress_functions/findLongestAndSubstitute.js.map +1 -0
  140. package/build/executor/compressor/compress_functions/findLongestAndSubstitute_old.d.ts +8 -0
  141. package/build/executor/compressor/compress_functions/findLongestAndSubstitute_old.js +61 -0
  142. package/build/executor/compressor/compress_functions/findLongestAndSubstitute_old.js.map +1 -0
  143. package/build/executor/compressor/compress_functions/reverseAddressSubstitution.d.ts +6 -0
  144. package/build/executor/compressor/compress_functions/reverseAddressSubstitution.js +37 -0
  145. package/build/executor/compressor/compress_functions/reverseAddressSubstitution.js.map +1 -0
  146. package/build/executor/compressor/compress_functions/searchUnusedBytes.d.ts +9 -0
  147. package/build/executor/compressor/compress_functions/searchUnusedBytes.js +33 -0
  148. package/build/executor/compressor/compress_functions/searchUnusedBytes.js.map +1 -0
  149. package/build/executor/compressor/fetchSaved.js +17 -0
  150. package/build/executor/compressor/fetchSaved.js.map +1 -0
  151. package/build/executor/compressor/utils/computeCostL2.d.ts +2 -0
  152. package/build/executor/compressor/utils/computeCostL2.js +14 -0
  153. package/build/executor/compressor/utils/computeCostL2.js.map +1 -0
  154. package/build/executor/compressor/utils/findLongestDuplicatedString.d.ts +2 -0
  155. package/build/executor/compressor/utils/findLongestDuplicatedString.js +30 -0
  156. package/build/executor/compressor/utils/findLongestDuplicatedString.js.map +1 -0
  157. package/build/executor/compressor/utils/getAllIndexes.d.ts +2 -0
  158. package/build/executor/compressor/utils/getAllIndexes.js +12 -0
  159. package/build/executor/compressor/utils/getAllIndexes.js.map +1 -0
  160. package/build/executor/compressor/utils/getByteForAddress.d.ts +2 -0
  161. package/build/executor/compressor/utils/getByteForAddress.js +14 -0
  162. package/build/executor/compressor/utils/getByteForAddress.js.map +1 -0
  163. package/build/executor/compressor/utils/intTo2Bytes.d.ts +2 -0
  164. package/build/executor/compressor/utils/intTo2Bytes.js +14 -0
  165. package/build/executor/compressor/utils/intTo2Bytes.js.map +1 -0
  166. package/build/executor/compressor/utils/intTo3Bytes.d.ts +2 -0
  167. package/build/executor/compressor/utils/intTo3Bytes.js +18 -0
  168. package/build/executor/compressor/utils/intTo3Bytes.js.map +1 -0
  169. package/build/executor/compressor/utils/intToByte.d.ts +2 -0
  170. package/build/executor/compressor/utils/intToByte.js +10 -0
  171. package/build/executor/compressor/utils/intToByte.js.map +1 -0
  172. package/build/types.d.ts +1 -0
  173. package/package.json +1 -1
  174. package/src/dex/aave-v3/aave-v3-e2e.test.ts +4 -9
  175. package/src/dex/aave-v3/aave-v3.ts +5 -0
  176. package/src/dex/aave-v3-stata/aave-v3-stata.ts +1 -0
  177. package/src/dex/angle-staked-stable/angle-staked-stable.ts +8 -0
  178. package/src/dex/compound/compound.ts +5 -0
  179. package/src/dex/etherfi.ts +5 -0
  180. package/src/dex/idle-dao/idle-dao.ts +1 -0
  181. package/src/dex/paraswap-limit-orders/paraswap-limit-orders-e2e.test.ts +152 -68
  182. package/src/dex/paraswap-limit-orders/paraswap-limit-orders.ts +3 -0
  183. package/src/dex/simple-exchange.ts +5 -5
  184. package/src/dex/spark/spark-e2e.test.ts +9 -1
  185. package/src/dex/spark/spark.ts +5 -0
  186. package/src/executor/Executor01BytecodeBuilder.ts +3 -1
  187. package/src/executor/Executor02BytecodeBuilder.ts +3 -1
  188. package/src/executor/Executor03BytecodeBuilder.ts +2 -0
  189. package/src/executor/ExecutorBytecodeBuilder.ts +2 -0
  190. package/src/executor/executor01-bytecode-builder-e2e.test.ts +25 -0
  191. package/src/executor/executor02-bytecode-builder-e2e.test.ts +29 -0
  192. package/src/types.ts +1 -0
  193. package/tests/constants-e2e.ts +14 -14
  194. package/tests/utils-e2e.ts +1 -1
  195. package/.vscode/tasks.json +0 -15
  196. package/build/abi/uniswap-v3/AlienBaseV3Router.abi.json +0 -52
  197. package/build/dex/aave-v2/tokens-avalanche.json +0 -44
  198. package/build/dex/aave-v2/tokens-mainnet.json +0 -188
  199. package/build/dex/aave-v2/tokens-polygon.json +0 -44
  200. package/build/dex/maker-psm/scripts/gem.abi.json +0 -136
  201. package/build/dex/maker-psm/scripts/validate-state.js +0 -185
  202. package/build/dex/maker-psm/scripts/validate-state.js.map +0 -1
  203. package/build/dex/maker-psm/scripts/vat.abi.json +0 -243
  204. package/build/dex/solidly-v3/scripts/check-event-pool-event.js +0 -53
  205. package/build/dex/solidly-v3/scripts/check-event-pool-event.js.map +0 -1
  206. package/build/dex/uniswap-v3/forks/alien-base-v3/alien-base-v3.d.ts +0 -17
  207. package/build/dex/uniswap-v3/forks/alien-base-v3/alien-base-v3.js +0 -64
  208. package/build/dex/uniswap-v3/forks/alien-base-v3/alien-base-v3.js.map +0 -1
  209. package/build/dex/uniswap-v3/forks/alien-v3/alien-v3.d.ts +0 -17
  210. package/build/dex/uniswap-v3/forks/alien-v3/alien-v3.js +0 -79
  211. package/build/dex/uniswap-v3/forks/alien-v3/alien-v3.js.map +0 -1
  212. /package/build/dex/{solidly-v3/scripts/check-event-pool-event.d.ts → sdai/scripts/validate-state.d.ts} +0 -0
  213. /package/build/{dex/maker-psm/scripts/validate-state.d.ts → executor/compressor/fetchSaved.d.ts} +0 -0
@@ -21,7 +21,7 @@ describe('AaveV3 E2E', () => {
21
21
 
22
22
  beforeAll(async () => {
23
23
  let results: Promise<void>[] = [];
24
- for (const networkEntry in Network) {
24
+ for (const networkEntry of Object.values(Network)) {
25
25
  if (isNaN(Number(networkEntry))) {
26
26
  break;
27
27
  }
@@ -446,15 +446,10 @@ describe('AaveV3 E2E', () => {
446
446
  );
447
447
 
448
448
  const pairs = [
449
- {
450
- tokenSymbol: 'USDC',
451
- aTokenSymbol: 'aEthUSDC',
452
- amount: '10000',
453
- },
454
449
  {
455
450
  tokenSymbol: 'ETH',
456
451
  aTokenSymbol: 'aEthWETH',
457
- amount: '100000000',
452
+ amount: '1000000000000000000',
458
453
  },
459
454
  {
460
455
  tokenSymbol: 'WETH',
@@ -481,7 +476,7 @@ describe('AaveV3 E2E', () => {
481
476
  describe(`${contractMethod}`, () => {
482
477
  it(pair.aTokenSymbol + ' -> ' + pair.tokenSymbol, async () => {
483
478
  await testE2E(
484
- getTokenFromASymbol(network, pair.aTokenSymbol)!,
479
+ tokens[pair.aTokenSymbol],
485
480
  tokens[pair.tokenSymbol],
486
481
  holders[pair.aTokenSymbol],
487
482
  pair.amount,
@@ -496,7 +491,7 @@ describe('AaveV3 E2E', () => {
496
491
  it(pair.tokenSymbol + ' -> ' + pair.aTokenSymbol, async () => {
497
492
  await testE2E(
498
493
  tokens[pair.tokenSymbol],
499
- getTokenFromASymbol(network, pair.aTokenSymbol)!,
494
+ tokens[pair.aTokenSymbol],
500
495
  holders[pair.tokenSymbol],
501
496
  pair.amount,
502
497
  side,
@@ -246,6 +246,7 @@ export class AaveV3 extends SimpleExchange implements IDex<Data, Param> {
246
246
  exchangeData,
247
247
  targetExchange: swapCallee,
248
248
  returnAmountPos: undefined,
249
+ skipApproval: data.fromAToken,
249
250
  };
250
251
  }
251
252
 
@@ -308,6 +309,10 @@ export class AaveV3 extends SimpleExchange implements IDex<Data, Param> {
308
309
  destAmount,
309
310
  swapData,
310
311
  swapCallee,
312
+ undefined,
313
+ undefined,
314
+ undefined,
315
+ data.fromAToken,
311
316
  );
312
317
  }
313
318
 
@@ -427,6 +427,7 @@ export class AaveV3Stata
427
427
  exchangeData: swapData,
428
428
  targetExchange: exchange,
429
429
  returnAmountPos,
430
+ skipApproval: srcType === TokenType.STATA_TOKEN,
430
431
  };
431
432
  }
432
433
 
@@ -215,6 +215,7 @@ export class AngleStakedStable
215
215
  this.augustusAddress,
216
216
  ],
217
217
  );
218
+ const skipApproval = srcToken.toLowerCase() !== this.config.agToken;
218
219
 
219
220
  return this.buildSimpleParamWithoutWETHConversion(
220
221
  srcToken,
@@ -223,6 +224,10 @@ export class AngleStakedStable
223
224
  destAmount,
224
225
  swapData,
225
226
  exchange,
227
+ undefined,
228
+ undefined,
229
+ undefined,
230
+ skipApproval,
226
231
  );
227
232
  }
228
233
 
@@ -254,12 +259,15 @@ export class AngleStakedStable
254
259
  ],
255
260
  );
256
261
 
262
+ const skipApproval = srcToken.toLowerCase() !== this.config.agToken;
263
+
257
264
  return {
258
265
  needWrapNative: this.needWrapNative,
259
266
  dexFuncHasRecipient: true,
260
267
  exchangeData: swapData,
261
268
  targetExchange: exchange,
262
269
  returnAmountPos: undefined,
270
+ skipApproval,
263
271
  };
264
272
  }
265
273
 
@@ -76,6 +76,10 @@ export class Compound
76
76
  destAmount,
77
77
  swapData,
78
78
  cToken,
79
+ undefined,
80
+ undefined,
81
+ undefined,
82
+ data.fromCToken,
79
83
  );
80
84
  }
81
85
 
@@ -102,6 +106,7 @@ export class Compound
102
106
  exchangeData: swapData,
103
107
  targetExchange: cToken,
104
108
  returnAmountPos: undefined,
109
+ skipApproval: data.fromCToken,
105
110
  };
106
111
  }
107
112
  }
@@ -127,6 +127,7 @@ export class EtherFi
127
127
 
128
128
  // if src token is WETH, we need to withdraw from weth and pass eth value on call. For other cases, we need to approve and perform call
129
129
  const isSrcTokenWeth = this.isWETH(srcToken);
130
+ const skipApproval = this.is_weETH(srcToken) && this.is_eETH(destToken);
130
131
 
131
132
  return this.buildSimpleParamWithoutWETHConversion(
132
133
  isSrcTokenWeth ? ETHER_ADDRESS : srcToken,
@@ -148,6 +149,7 @@ export class EtherFi
148
149
  values: ['0'],
149
150
  }
150
151
  : undefined,
152
+ skipApproval,
151
153
  );
152
154
  }
153
155
 
@@ -206,6 +208,8 @@ export class EtherFi
206
208
  swapFunctionParams,
207
209
  );
208
210
 
211
+ const skipApproval = this.is_weETH(srcToken) && this.is_eETH(destToken);
212
+
209
213
  return {
210
214
  needWrapNative: this.needWrapNative,
211
215
  dexFuncHasRecipient: false,
@@ -219,6 +223,7 @@ export class EtherFi
219
223
  ])
220
224
  : undefined,
221
225
  returnAmountPos: extractReturnAmountPosition(Interface, swapFunction),
226
+ skipApproval,
222
227
  };
223
228
  }
224
229
 
@@ -350,6 +350,7 @@ export class IdleDao extends SimpleExchange implements IDex<IdleDaoData> {
350
350
  exchangeData,
351
351
  targetExchange: swapCallee,
352
352
  returnAmountPos: side === SwapSide.SELL ? returnAmountPos : undefined,
353
+ skipApproval: data.fromIdleToken,
353
354
  };
354
355
  }
355
356
 
@@ -2,7 +2,7 @@ import dotenv from 'dotenv';
2
2
  dotenv.config();
3
3
 
4
4
  import { testE2E } from '../../../tests/utils-e2e';
5
- import { Tokens } from '../../../tests/constants-e2e';
5
+ import { Holders, Tokens } from '../../../tests/constants-e2e';
6
6
  import { Network, ContractMethod, SwapSide } from '../../constants';
7
7
  import { StaticJsonRpcProvider } from '@ethersproject/providers';
8
8
  import { ParaSwapOrderResponse, ParaSwapOrderBookResponse } from './types';
@@ -12,87 +12,168 @@ import { generateConfig } from '../../config';
12
12
  describe('ParaSwapLimitOrders E2E', () => {
13
13
  const dexKey = 'ParaSwapLimitOrders';
14
14
 
15
- describe('ParaSwapLimitOrders MAINNET', () => {
16
- const network = Network.MAINNET;
15
+ // describe('ParaSwapLimitOrders MAINNET', () => {
16
+ // const network = Network.MAINNET;
17
+ // const tokens = Tokens[network];
18
+ // const provider = new StaticJsonRpcProvider(
19
+ // generateConfig(network).privateHttpProvider,
20
+ // network,
21
+ // );
22
+ //
23
+ // const tokenASymbol: string = 'DAI';
24
+ // const tokenBSymbol: string = 'WETH';
25
+ //
26
+ // // Do not change arbitrarily. Need to adjust the orders amounts too
27
+ // const tokenAAmount: string = '50000000000000000000';
28
+ // const tokenBAmount: string = '110000000000000000';
29
+ //
30
+ // const sideToContractMethods = new Map([
31
+ // [
32
+ // SwapSide.SELL,
33
+ // [
34
+ // ContractMethod.simpleSwap,
35
+ // ContractMethod.multiSwap,
36
+ // ContractMethod.megaSwap,
37
+ // ],
38
+ // ],
39
+ // [SwapSide.BUY, [ContractMethod.simpleBuy, ContractMethod.buy]],
40
+ // ]);
41
+ // const maker = '0xc3643bC869DC0dcd2Df8729fC3cb768d4F86F57a';
42
+ // const taker = '0xCf8C4a46816b146Ed613d23f6D22e1711915d653';
43
+ //
44
+ // const ordersToUse: ParaSwapOrderResponse[] = [
45
+ // {
46
+ // order: {
47
+ // nonceAndMeta:
48
+ // '6845735429342786815130681271919807714789080615235334578045452288',
49
+ // expiry: '0',
50
+ // makerAsset: tokens[tokenASymbol].address,
51
+ // takerAsset: tokens[tokenBSymbol].address,
52
+ // maker,
53
+ // taker: '0x0000000000000000000000000000000000000000',
54
+ // makerAmount: '10000000000000000000',
55
+ // takerAmount: '20000000000000000',
56
+ // },
57
+ // signature:
58
+ // '0xa75880885e92ed7d46c842d3d20138c60c33c411642ec33a82b73216c508b5503bc57a3ec4fcc2f8ece2477c9eb9716850ae8b97f64d86afac56d3dace8f9f701b',
59
+ // takerTokenFillAmount: '20000000000000000',
60
+ // permitTakerAsset: '0x',
61
+ // permitMakerAsset: '0x',
62
+ // },
63
+ // {
64
+ // order: {
65
+ // nonceAndMeta:
66
+ // '11585127861177800418865894644506682666974354234368387567816015872',
67
+ // expiry: '0',
68
+ // makerAsset: tokens[tokenASymbol].address,
69
+ // takerAsset: tokens[tokenBSymbol].address,
70
+ // maker,
71
+ // taker: '0x0000000000000000000000000000000000000000',
72
+ // makerAmount: '50000000000000000000',
73
+ // takerAmount: '110000000000000000',
74
+ // },
75
+ // signature:
76
+ // '0x33ce6d9a609190d3d936c0cac2609ab13ad9aaa64d79917d32064003903105302cb80dcf0133e102d513a45c61d9b813a9c85b2f627aec7fed53d858dad90df61c',
77
+ // takerTokenFillAmount: '110000000000000000',
78
+ // permitTakerAsset: '0x',
79
+ // permitMakerAsset: '0x',
80
+ // },
81
+ // {
82
+ // order: {
83
+ // nonceAndMeta:
84
+ // '11375705433687422051822427911677732183148366573414372269099057152',
85
+ // expiry: '0',
86
+ // makerAsset: tokens[tokenASymbol].address,
87
+ // takerAsset: tokens[tokenBSymbol].address,
88
+ // maker,
89
+ // taker: '0x0000000000000000000000000000000000000000',
90
+ // makerAmount: '70000000000000000000',
91
+ // takerAmount: '170000000000000000',
92
+ // },
93
+ // signature:
94
+ // '0x989eec978c60b1104c7133beae1da691353d138f1fe32862e75a9fc36d294e92655e327fcaa83b6506c6712268ea03423249714308418955dfcc067583fd823a1b',
95
+ // takerTokenFillAmount: '170000000000000000',
96
+ // permitTakerAsset: '0x',
97
+ // permitMakerAsset: '0x',
98
+ // },
99
+ // ];
100
+ //
101
+ // const orderBookToUse: ParaSwapOrderBookResponse[] = ordersToUse.map(o => ({
102
+ // swappableMakerBalance: o.order.makerAmount,
103
+ // swappableTakerBalance: o.order.takerAmount,
104
+ // }));
105
+ //
106
+ // const dummyLimitOrderProvider = new DummyLimitOrderProvider();
107
+ // dummyLimitOrderProvider.setOrdersToExecute(network, ordersToUse);
108
+ // dummyLimitOrderProvider.setOrderBook(
109
+ // network,
110
+ // tokens[tokenBSymbol].address,
111
+ // tokens[tokenASymbol].address,
112
+ // orderBookToUse,
113
+ // );
114
+ //
115
+ // sideToContractMethods.forEach((contractMethods, side) =>
116
+ // contractMethods.forEach((contractMethod: ContractMethod) => {
117
+ // describe(`${contractMethod}`, () => {
118
+ // it(`${network} ${side} ${contractMethod} ${tokenASymbol} -> ${tokenBSymbol}`, async () => {
119
+ // await testE2E(
120
+ // tokens[tokenBSymbol],
121
+ // tokens[tokenASymbol],
122
+ // taker,
123
+ // side === SwapSide.SELL ? tokenBAmount : tokenAAmount,
124
+ // side,
125
+ // dexKey,
126
+ // contractMethod,
127
+ // network,
128
+ // provider,
129
+ // undefined,
130
+ // dummyLimitOrderProvider,
131
+ // );
132
+ // });
133
+ // });
134
+ // }),
135
+ // );
136
+ // });
137
+
138
+ describe('USDC -> DAI.e', () => {
139
+ const network = Network.AVALANCHE;
17
140
  const tokens = Tokens[network];
141
+ const holders = Holders[network];
142
+
18
143
  const provider = new StaticJsonRpcProvider(
19
144
  generateConfig(network).privateHttpProvider,
20
145
  network,
21
146
  );
22
147
 
23
- const tokenASymbol: string = 'DAI';
24
- const tokenBSymbol: string = 'WETH';
25
-
26
- // Do not change arbitrarily. Need to adjust the orders amounts too
27
- const tokenAAmount: string = '50000000000000000000';
28
- const tokenBAmount: string = '110000000000000000';
29
-
30
148
  const sideToContractMethods = new Map([
31
- [
32
- SwapSide.SELL,
33
- [
34
- ContractMethod.simpleSwap,
35
- ContractMethod.multiSwap,
36
- ContractMethod.megaSwap,
37
- ],
38
- ],
39
- [SwapSide.BUY, [ContractMethod.simpleBuy, ContractMethod.buy]],
149
+ [SwapSide.SELL, [ContractMethod.swapExactAmountIn]],
150
+ [SwapSide.BUY, [ContractMethod.swapExactAmountOut]],
40
151
  ]);
41
- const maker = '0xc3643bC869DC0dcd2Df8729fC3cb768d4F86F57a';
42
- const taker = '0xCf8C4a46816b146Ed613d23f6D22e1711915d653';
152
+
153
+ const tokenASymbol: string = 'USDC';
154
+ const tokenBSymbol: string = 'DAIE';
155
+
156
+ const tokenAAmount: string = '2200000';
157
+ const tokenBAmount: string = '2000000000000000000';
158
+
159
+ const maker = '0x450C01300B83bE379113256038b4Dd3b45d23B5e';
160
+ const taker = '0x187b6Ab771482CCFEE7cD2C35176080631082368';
43
161
 
44
162
  const ordersToUse: ParaSwapOrderResponse[] = [
45
163
  {
46
164
  order: {
47
165
  nonceAndMeta:
48
- '6845735429342786815130681271919807714789080615235334578045452288',
166
+ '1970736690787950733482238420044572595585384097365282143164432384',
49
167
  expiry: '0',
50
- makerAsset: tokens[tokenASymbol].address,
51
- takerAsset: tokens[tokenBSymbol].address,
168
+ makerAsset: '0xd586e7f844cea2f87f50152665bcbc2c279d8d70',
169
+ takerAsset: '0xb97ef9ef8734c71904d8002f8b6bc66dd9c48a6e',
52
170
  maker,
53
171
  taker: '0x0000000000000000000000000000000000000000',
54
- makerAmount: '10000000000000000000',
55
- takerAmount: '20000000000000000',
172
+ makerAmount: '2000000000000000000',
173
+ takerAmount: '2200000',
56
174
  },
57
- signature:
58
- '0xa75880885e92ed7d46c842d3d20138c60c33c411642ec33a82b73216c508b5503bc57a3ec4fcc2f8ece2477c9eb9716850ae8b97f64d86afac56d3dace8f9f701b',
59
- takerTokenFillAmount: '20000000000000000',
60
- permitTakerAsset: '0x',
61
- permitMakerAsset: '0x',
62
- },
63
- {
64
- order: {
65
- nonceAndMeta:
66
- '11585127861177800418865894644506682666974354234368387567816015872',
67
- expiry: '0',
68
- makerAsset: tokens[tokenASymbol].address,
69
- takerAsset: tokens[tokenBSymbol].address,
70
- maker,
71
- taker: '0x0000000000000000000000000000000000000000',
72
- makerAmount: '50000000000000000000',
73
- takerAmount: '110000000000000000',
74
- },
75
- signature:
76
- '0x33ce6d9a609190d3d936c0cac2609ab13ad9aaa64d79917d32064003903105302cb80dcf0133e102d513a45c61d9b813a9c85b2f627aec7fed53d858dad90df61c',
77
- takerTokenFillAmount: '110000000000000000',
78
- permitTakerAsset: '0x',
79
- permitMakerAsset: '0x',
80
- },
81
- {
82
- order: {
83
- nonceAndMeta:
84
- '11375705433687422051822427911677732183148366573414372269099057152',
85
- expiry: '0',
86
- makerAsset: tokens[tokenASymbol].address,
87
- takerAsset: tokens[tokenBSymbol].address,
88
- maker,
89
- taker: '0x0000000000000000000000000000000000000000',
90
- makerAmount: '70000000000000000000',
91
- takerAmount: '170000000000000000',
92
- },
93
- signature:
94
- '0x989eec978c60b1104c7133beae1da691353d138f1fe32862e75a9fc36d294e92655e327fcaa83b6506c6712268ea03423249714308418955dfcc067583fd823a1b',
95
- takerTokenFillAmount: '170000000000000000',
175
+ signature: '0x',
176
+ takerTokenFillAmount: '2200000',
96
177
  permitTakerAsset: '0x',
97
178
  permitMakerAsset: '0x',
98
179
  },
@@ -101,6 +182,9 @@ describe('ParaSwapLimitOrders E2E', () => {
101
182
  const orderBookToUse: ParaSwapOrderBookResponse[] = ordersToUse.map(o => ({
102
183
  swappableMakerBalance: o.order.makerAmount,
103
184
  swappableTakerBalance: o.order.takerAmount,
185
+ makerAmount: o.order.makerAmount,
186
+ takerAmount: o.order.takerAmount,
187
+ isFillOrKill: true,
104
188
  }));
105
189
 
106
190
  const dummyLimitOrderProvider = new DummyLimitOrderProvider();
@@ -117,10 +201,10 @@ describe('ParaSwapLimitOrders E2E', () => {
117
201
  describe(`${contractMethod}`, () => {
118
202
  it(`${network} ${side} ${contractMethod} ${tokenASymbol} -> ${tokenBSymbol}`, async () => {
119
203
  await testE2E(
120
- tokens[tokenBSymbol],
121
204
  tokens[tokenASymbol],
122
- taker,
123
- side === SwapSide.SELL ? tokenBAmount : tokenAAmount,
205
+ tokens[tokenBSymbol],
206
+ holders[tokenASymbol],
207
+ side === SwapSide.SELL ? tokenAAmount : tokenBAmount,
124
208
  side,
125
209
  dexKey,
126
210
  contractMethod,
@@ -38,6 +38,7 @@ import {
38
38
  ONE_ORDER_GASCOST,
39
39
  } from './constant';
40
40
  import BigNumber from 'bignumber.js';
41
+ import { SpecialDex } from '../../executor/types';
41
42
 
42
43
  const BLACKLIST_CACHE_PREFIX = `lo_blacklist`;
43
44
 
@@ -397,7 +398,9 @@ export class ParaSwapLimitOrders
397
398
  needWrapNative: this.needWrapNative,
398
399
  dexFuncHasRecipient: true,
399
400
  exchangeData: swapData,
401
+ specialDexFlag: SpecialDex.SWAP_ON_AUGUSTUS_RFQ,
400
402
  targetExchange: this.augustusRFQAddress,
403
+ specialDexSupportsInsertFromAmount: true,
401
404
  returnAmountPos: undefined,
402
405
  };
403
406
  }
@@ -110,12 +110,12 @@ export class SimpleExchange {
110
110
  spender?: Address,
111
111
  networkFee: NumberAsString = '0',
112
112
  preCalls?: Omit<SimpleExchangeParam, 'networkFee'>,
113
+ skipApproval?: boolean,
113
114
  ): Promise<SimpleExchangeParam> {
114
- const approveParam = await this.getApproveSimpleParam(
115
- src,
116
- spender || swapCallee,
117
- srcAmount,
118
- );
115
+ const approveParam = skipApproval
116
+ ? { callees: [], calldata: [], values: [], networkFee: '0' }
117
+ : await this.getApproveSimpleParam(src, spender || swapCallee, srcAmount);
118
+
119
119
  const swapValue = (
120
120
  BigInt(networkFee) + (isETHAddress(src) ? BigInt(srcAmount) : 0n)
121
121
  ).toString();
@@ -29,9 +29,17 @@ function testForNetwork(
29
29
  ContractMethod.simpleSwap,
30
30
  ContractMethod.multiSwap,
31
31
  ContractMethod.megaSwap,
32
+ ContractMethod.swapExactAmountIn,
33
+ ],
34
+ ],
35
+ [
36
+ SwapSide.BUY,
37
+ [
38
+ ContractMethod.simpleBuy,
39
+ ContractMethod.buy,
40
+ ContractMethod.swapExactAmountOut,
32
41
  ],
33
42
  ],
34
- [SwapSide.BUY, [ContractMethod.simpleBuy, ContractMethod.buy]],
35
43
  ]);
36
44
 
37
45
  describe(`${network}`, () => {
@@ -207,6 +207,10 @@ export class Spark
207
207
  destAmount,
208
208
  swapData,
209
209
  exchange,
210
+ undefined,
211
+ undefined,
212
+ undefined,
213
+ isSell && this.isDai(destToken),
210
214
  );
211
215
  }
212
216
 
@@ -251,6 +255,7 @@ export class Spark
251
255
  this.isDai(srcToken) ? 'shares' : 'assets',
252
256
  )
253
257
  : undefined,
258
+ skipApproval: isSell && this.isDai(destToken),
254
259
  };
255
260
  }
256
261
 
@@ -268,6 +268,7 @@ export class Executor01BytecodeBuilder extends ExecutorBytecodeBuilder<
268
268
  (!isETHAddress(swap.srcToken) ||
269
269
  (isETHAddress(swap.srcToken) && index !== 0)) &&
270
270
  !curExchangeParam.transferSrcTokenBeforeSwap &&
271
+ !curExchangeParam.skipApproval &&
271
272
  curExchangeParam.approveData
272
273
  ) {
273
274
  const approveCallData = this.buildApproveCallData(
@@ -290,7 +291,8 @@ export class Executor01BytecodeBuilder extends ExecutorBytecodeBuilder<
290
291
  let approveWethCalldata = '0x';
291
292
  if (
292
293
  curExchangeParam.approveData &&
293
- !curExchangeParam.transferSrcTokenBeforeSwap
294
+ !curExchangeParam.transferSrcTokenBeforeSwap &&
295
+ !curExchangeParam.skipApproval
294
296
  ) {
295
297
  approveWethCalldata = this.buildApproveCallData(
296
298
  curExchangeParam.approveData.target,
@@ -606,6 +606,7 @@ export class Executor02BytecodeBuilder extends ExecutorBytecodeBuilder<
606
606
  if (
607
607
  !isETHAddress(swap.srcToken) &&
608
608
  !curExchangeParam.transferSrcTokenBeforeSwap &&
609
+ !curExchangeParam.skipApproval &&
609
610
  curExchangeParam.approveData
610
611
  ) {
611
612
  const approveCallData = this.buildApproveCallData(
@@ -622,7 +623,8 @@ export class Executor02BytecodeBuilder extends ExecutorBytecodeBuilder<
622
623
  let approveWethCalldata = '0x';
623
624
  if (
624
625
  curExchangeParam.approveData &&
625
- !curExchangeParam.transferSrcTokenBeforeSwap
626
+ !curExchangeParam.transferSrcTokenBeforeSwap &&
627
+ !curExchangeParam.skipApproval
626
628
  ) {
627
629
  approveWethCalldata = this.buildApproveCallData(
628
630
  curExchangeParam.approveData.target,
@@ -147,6 +147,7 @@ export class Executor03BytecodeBuilder extends ExecutorBytecodeBuilder<
147
147
  if (
148
148
  flags.dexes[index] % 4 !== 1 && // not sendEth
149
149
  !isETHAddress(swap.srcToken) &&
150
+ !curExchangeParam.skipApproval &&
150
151
  curExchangeParam.approveData
151
152
  ) {
152
153
  // TODO: as we give approve for MAX_UINT and approve for current targetExchange was given
@@ -163,6 +164,7 @@ export class Executor03BytecodeBuilder extends ExecutorBytecodeBuilder<
163
164
  if (
164
165
  maybeWethCallData?.deposit &&
165
166
  isETHAddress(swap.srcToken) &&
167
+ !curExchangeParam.skipApproval &&
166
168
  curExchangeParam.needWrapNative
167
169
  // do deposit only for the first path with wrapping
168
170
  // exchangeParams.findIndex(p => p.needWrapNative) === index
@@ -358,6 +358,8 @@ export abstract class ExecutorBytecodeBuilder<S = {}, D = {}> {
358
358
  swap: OptimalSwap,
359
359
  exchangeParam: DexExchangeParam,
360
360
  ): { target: string; token: Address } | null {
361
+ if (exchangeParam.skipApproval) return null;
362
+
361
363
  const target = exchangeParam.spender || exchangeParam.targetExchange;
362
364
 
363
365
  if (
@@ -102,6 +102,31 @@ describe('Executor01ByteCodeBuilder e2e tests', () => {
102
102
  const network = Network.MAINNET;
103
103
 
104
104
  describe('SimpleSwap', () => {
105
+ describe('AngleStakedStableUSD', () => {
106
+ const dexKey = 'AngleStakedStableUSD';
107
+
108
+ const tokens = Tokens[network];
109
+ const holders = Holders[network];
110
+ const provider = new StaticJsonRpcProvider(
111
+ generateConfig(network).privateHttpProvider,
112
+ network,
113
+ );
114
+
115
+ it('SimpleSwap stUSD -> USDA', async () => {
116
+ await testE2E(
117
+ tokens['stUSD'],
118
+ tokens['USDA'],
119
+ holders['stUSD'],
120
+ '1000000000000',
121
+ SwapSide.SELL,
122
+ dexKey,
123
+ ContractMethod.simpleSwap,
124
+ network,
125
+ provider,
126
+ );
127
+ });
128
+ });
129
+
105
130
  describe('UniswapV3', () => {
106
131
  const dexKey = 'UniswapV3';
107
132
 
@@ -23,6 +23,35 @@ describe('Executor02ByteCodeBuilder e2e tests', () => {
23
23
  describe('SimpleSwap', () => {
24
24
  const contractMethod = ContractMethod.simpleSwap;
25
25
 
26
+ describe('stUSD -> USDA via Angle Staked Stable USD', () => {
27
+ const dexKeys = ['AngleStakedStableUSD'];
28
+
29
+ const tokenASymbol: string = 'stUSD';
30
+ const tokenBSymbol: string = 'USDA';
31
+ const tokenAAmount: string = '60000000000000000000';
32
+
33
+ const side = SwapSide.SELL;
34
+
35
+ it(`${tokenASymbol} -> ${tokenBSymbol}`, async () => {
36
+ await testE2E(
37
+ tokens[tokenASymbol],
38
+ tokens[tokenBSymbol],
39
+ holders[tokenASymbol],
40
+ tokenAAmount,
41
+ side,
42
+ dexKeys,
43
+ contractMethod,
44
+ network,
45
+ provider,
46
+ undefined,
47
+ undefined,
48
+ undefined,
49
+ 200,
50
+ 2000,
51
+ );
52
+ });
53
+ });
54
+
26
55
  describe('ETH -> SUSHI via SushiSwapV3 and UniswapV3', () => {
27
56
  const dexKeys = ['SushiSwapV3', 'UniswapV3'];
28
57
 
package/src/types.ts CHANGED
@@ -159,6 +159,7 @@ export type AdapterExchangeParam = {
159
159
 
160
160
  export type DexExchangeParam = {
161
161
  needWrapNative: boolean;
162
+ skipApproval?: boolean;
162
163
  wethAddress?: string;
163
164
  exchangeData: string;
164
165
  targetExchange: string;