@paraswap/dex-lib 4.1.2 → 4.1.3-wusdl.0

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 (43) hide show
  1. package/build/dex/aave-v3-stata-v2/config.js +0 -13
  2. package/build/dex/aave-v3-stata-v2/config.js.map +1 -1
  3. package/build/dex/algebra/config.js +1 -1
  4. package/build/dex/algebra/config.js.map +1 -1
  5. package/build/dex/balancer-v2/pools/gyro/GyroEPool.js.map +1 -1
  6. package/build/dex/balancer-v3/balancer-v3-pool.d.ts +0 -2
  7. package/build/dex/balancer-v3/balancer-v3-pool.js +4 -14
  8. package/build/dex/balancer-v3/balancer-v3-pool.js.map +1 -1
  9. package/build/dex/balancer-v3/balancer-v3.js +1 -1
  10. package/build/dex/balancer-v3/balancer-v3.js.map +1 -1
  11. package/build/dex/balancer-v3/config.js +0 -12
  12. package/build/dex/balancer-v3/config.js.map +1 -1
  13. package/build/dex/cables/cables.d.ts +1 -1
  14. package/build/dex/cables/cables.js +7 -26
  15. package/build/dex/cables/cables.js.map +1 -1
  16. package/build/dex/wusdm/config.js +6 -0
  17. package/build/dex/wusdm/config.js.map +1 -1
  18. package/build/generic-swap-transaction-builder.d.ts +1 -1
  19. package/build/generic-swap-transaction-builder.js +1 -6
  20. package/build/generic-swap-transaction-builder.js.map +1 -1
  21. package/build/implementations/local-paraswap-sdk.js +1 -1
  22. package/build/implementations/local-paraswap-sdk.js.map +1 -1
  23. package/package.json +3 -3
  24. package/src/dex/aave-v3-stata-v2/aave-v3-stata-v2-e2e.test.ts +32 -11
  25. package/src/dex/aave-v3-stata-v2/config.ts +0 -16
  26. package/src/dex/algebra/config.ts +1 -1
  27. package/src/dex/balancer-v2/balancer-v2-integration.test.ts +12 -11
  28. package/src/dex/balancer-v2/pools/gyro/GyroEPool.ts +1 -0
  29. package/src/dex/balancer-v3/balancer-v3-e2e.test.ts +0 -110
  30. package/src/dex/balancer-v3/balancer-v3-events.test.ts +84 -157
  31. package/src/dex/balancer-v3/balancer-v3-integration.test.ts +5 -101
  32. package/src/dex/balancer-v3/balancer-v3-pool.ts +13 -33
  33. package/src/dex/balancer-v3/balancer-v3.ts +1 -1
  34. package/src/dex/balancer-v3/config.ts +0 -12
  35. package/src/dex/cables/cables-e2e.test.ts +40 -40
  36. package/src/dex/cables/cables.ts +10 -37
  37. package/src/dex/wusdm/config.ts +7 -0
  38. package/src/dex/wusdm/wusdm-e2e.test.ts +20 -0
  39. package/src/generic-swap-transaction-builder.ts +2 -10
  40. package/src/implementations/local-paraswap-sdk.ts +1 -1
  41. package/tests/constants-e2e.ts +8 -46
  42. package/tests/tenderly-simulation.ts +0 -2
  43. package/tests/utils-e2e.ts +7 -4
@@ -399,15 +399,11 @@ export class Cables extends SimpleExchange implements IDex<any> {
399
399
  let decimals = baseToken.decimals;
400
400
  let out_decimals = quoteToken.decimals;
401
401
 
402
- let price = 0;
403
-
404
- try {
405
- price = this.calculatePriceSwap(
406
- orderbook,
407
- Number(amt) / 10 ** decimals,
408
- isInputQuote,
409
- );
410
- } catch {}
402
+ let price = this.calculatePriceSwap(
403
+ orderbook,
404
+ Number(amt) / 10 ** decimals,
405
+ isInputQuote,
406
+ );
411
407
  result.push(BigInt(Math.round(price * 10 ** out_decimals)));
412
408
  }
413
409
  return result;
@@ -420,17 +416,11 @@ export class Cables extends SimpleExchange implements IDex<any> {
420
416
  ) {
421
417
  let sumBaseQty = 0;
422
418
  let sumQuoteQty = 0;
423
-
424
419
  const selectedRows: string[][] = [];
425
420
 
426
421
  const isBase = qtyMode;
427
422
  const isQuote = !qtyMode;
428
423
 
429
- const totalVolume: number = prices.reduce(
430
- (sum, [, volume]) => sum + Number(volume),
431
- 0,
432
- );
433
-
434
424
  for (const [price, volume] of prices) {
435
425
  if (isBase) {
436
426
  if (sumBaseQty >= requiredQty) {
@@ -470,10 +460,6 @@ export class Cables extends SimpleExchange implements IDex<any> {
470
460
  selectedRows.push([price, currentBaseQty.toString()]);
471
461
  }
472
462
 
473
- if (sumBaseQty == 0) {
474
- return 0;
475
- }
476
-
477
463
  const vSumBase = selectedRows.reduce((sum: number, [price, volume]) => {
478
464
  return sum + Number(price) * Number(volume);
479
465
  }, 0);
@@ -482,24 +468,11 @@ export class Cables extends SimpleExchange implements IDex<any> {
482
468
  .dividedBy(new BigNumber(sumBaseQty))
483
469
  .toNumber();
484
470
 
485
- let result: any;
486
471
  if (isBase) {
487
- result = requiredQty / price;
472
+ return requiredQty / price;
488
473
  } else {
489
- result = requiredQty * price;
474
+ return requiredQty * price;
490
475
  }
491
-
492
- if (isQuote) {
493
- if (requiredQty > totalVolume) {
494
- result = 0;
495
- }
496
- } else {
497
- if (result > totalVolume) {
498
- result = 0;
499
- }
500
- }
501
-
502
- return result;
503
476
  }
504
477
 
505
478
  async getPricesVolume(
@@ -565,10 +538,10 @@ export class Cables extends SimpleExchange implements IDex<any> {
565
538
  const priceData = priceMap[pairKey];
566
539
 
567
540
  let orderbook: any[] = [];
568
- orderbook = priceData.bids;
569
- // reverse orderbook if isInputQuote
570
- if (isInputQuote) {
541
+ if (side === SwapSide.BUY) {
571
542
  orderbook = priceData.asks;
543
+ } else {
544
+ orderbook = priceData.bids;
572
545
  }
573
546
  if (orderbook?.length === 0) {
574
547
  throw new Error(`Empty orderbook for ${pairKey}`);
@@ -33,4 +33,11 @@ export const WUSDMConfig: DexConfigMap<WusdmParams> = {
33
33
  USDMAddress: '0xe91D153E0b41518A2Ce8Dd3D7944Fa863463a97d', // WXDAI
34
34
  },
35
35
  },
36
+
37
+ wUSDL: {
38
+ [Network.MAINNET]: {
39
+ wUSDMAddress: '0x7751E2F4b8ae93EF6B79d86419d42FE3295A4559', // wUSDL
40
+ USDMAddress: '0xbdC7c08592Ee4aa51D06C27Ee23D5087D65aDbcD', // USDL
41
+ },
42
+ },
36
43
  };
@@ -201,4 +201,24 @@ describe('MountainProtocol E2E', () => {
201
201
  tokenBAmount,
202
202
  );
203
203
  });
204
+
205
+ describe('wUSDL', () => {
206
+ const network = Network.MAINNET;
207
+ const dexKey = 'wUSDL';
208
+
209
+ const tokenASymbol: string = 'wUSDL';
210
+ const tokenBSymbol: string = 'USDL';
211
+
212
+ const tokenAAmount: string = '1000000000000000000';
213
+ const tokenBAmount: string = '1000000000000000000';
214
+
215
+ testForNetwork(
216
+ network,
217
+ dexKey,
218
+ tokenASymbol,
219
+ tokenBSymbol,
220
+ tokenAAmount,
221
+ tokenBAmount,
222
+ );
223
+ });
204
224
  });
@@ -447,7 +447,7 @@ export class GenericSwapTransactionBuilder {
447
447
  uuid: string;
448
448
  beneficiary?: Address;
449
449
  onlyParams?: boolean;
450
- }): Promise<TxObject | (string | string[])[]> {
450
+ }): Promise<TxObject> {
451
451
  // if beneficiary is not defined, then in smart contract it will be replaced to msg.sender
452
452
  const _beneficiary =
453
453
  beneficiary !== NULL_ADDRESS &&
@@ -494,8 +494,6 @@ export class GenericSwapTransactionBuilder {
494
494
  ));
495
495
  }
496
496
 
497
- if (onlyParams) return params;
498
-
499
497
  const value = (
500
498
  priceRoute.srcToken.toLowerCase() === ETHER_ADDRESS.toLowerCase()
501
499
  ? BigInt(
@@ -527,14 +525,8 @@ export class GenericSwapTransactionBuilder {
527
525
  isReferral,
528
526
  isSkipBlacklist,
529
527
  }: FeeParams): string {
530
- const partnerAddress =
531
- feePercent === '0' && !isTakeSurplus && !isReferral
532
- ? NULL_ADDRESS
533
- : partner;
534
-
535
528
  // Partner address shifted left to make room for flags and fee percent
536
- const partialFeeCodeWithPartnerAddress =
537
- BigNumber.from(partnerAddress).shl(96);
529
+ const partialFeeCodeWithPartnerAddress = BigNumber.from(partner).shl(96);
538
530
  let partialFeeCodeWithBitFlags = BigNumber.from(0); // default 0 is safe if none the conditions pass
539
531
 
540
532
  const isFixedFees = !BigNumber.from(feePercent).isZero();
@@ -117,7 +117,7 @@ export class LocalParaswapSDK implements IParaSwapSDK {
117
117
  transferFees?: TransferFeeParams,
118
118
  forceRoute?: AddressOrSymbol[],
119
119
  ): Promise<OptimalRate> {
120
- const blockNumber = await this.dexHelper.provider.getBlockNumber();
120
+ const blockNumber = await this.dexHelper.web3Provider.eth.getBlockNumber();
121
121
  const poolIdentifiers =
122
122
  _poolIdentifiers ||
123
123
  (await this.pricingHelper.getPoolIdentifiers(
@@ -571,6 +571,11 @@ export const Tokens: {
571
571
  decimals: 18,
572
572
  symbol: 'wUSDL',
573
573
  },
574
+ USDL: {
575
+ address: '0xbdC7c08592Ee4aa51D06C27Ee23D5087D65aDbcD',
576
+ decimals: 18,
577
+ symbol: 'USDL',
578
+ },
574
579
  WrappedM: {
575
580
  address: '0x437cc33344a0B27A429f795ff6B469C72698B291',
576
581
  decimals: 6,
@@ -1204,10 +1209,6 @@ export const Tokens: {
1204
1209
  addBalance: _balancesFn,
1205
1210
  addAllowance: _allowancesFn,
1206
1211
  },
1207
- waArbWETH: {
1208
- address: '0x4ce13a79f45c1be00bdabd38b764ac28c082704e',
1209
- decimals: 18,
1210
- },
1211
1212
  ETH: { address: ETHER_ADDRESS, decimals: 18 },
1212
1213
  USDCe: {
1213
1214
  address: '0xFF970A61A04b1cA14834A43f5dE4533eBDDB5CC8',
@@ -1242,10 +1243,6 @@ export const Tokens: {
1242
1243
  addBalance: _balancesFn,
1243
1244
  addAllowance: _allowancesFn,
1244
1245
  },
1245
- waArbUSDT: {
1246
- address: '0xa6D12574eFB239FC1D2099732bd8b5dC6306897F',
1247
- decimals: 6,
1248
- },
1249
1246
  FRAX: {
1250
1247
  address: '0x17FC002b466eEc40DaE837Fc4bE5c67993ddBd6F',
1251
1248
  decimals: 18,
@@ -1364,10 +1361,6 @@ export const Tokens: {
1364
1361
  address: '0x7dff72693f6a4149b17e7c6314655f6a9f7c8b33',
1365
1362
  decimals: 18,
1366
1363
  },
1367
- waArbwstETH: {
1368
- address: '0xe98fc055c99decd8da0c111b090885d5d15c774e',
1369
- decimals: 18,
1370
- },
1371
1364
  },
1372
1365
  [Network.OPTIMISM]: {
1373
1366
  DAI: {
@@ -1685,34 +1678,10 @@ export const Tokens: {
1685
1678
  address: '0x4ea71a20e655794051d1ee8b6e4a3269b13ccacc',
1686
1679
  decimals: 6,
1687
1680
  },
1688
- waBasUSDC: {
1689
- address: '0xC768c589647798a6EE01A91FdE98EF2ed046DBD6',
1690
- decimals: 6,
1691
- },
1692
1681
  aaveUSDC: {
1693
1682
  address: '0x4e65fe4dba92790696d040ac24aa414708f5c0ab',
1694
1683
  decimals: 6,
1695
1684
  },
1696
- aBasUSDC: {
1697
- address: '0x4e65fe4dba92790696d040ac24aa414708f5c0ab',
1698
- decimals: 6,
1699
- },
1700
- waBasWETH: {
1701
- address: '0xe298b938631f750dd409fb18227c4a23dcdaab9b',
1702
- decimals: 18,
1703
- },
1704
- waBaswstETH: {
1705
- address: '0x0830820d1a9aa1554364752d6d8f55c836871b74',
1706
- decimals: 18,
1707
- },
1708
- sUSDS: {
1709
- address: '0x5875eee11cf8398102fdad704c9e96607675467a',
1710
- decimals: 18,
1711
- },
1712
- smUSDC: {
1713
- address: '0x616a4e1db48e22028f6bbf20444cd3b8e3273738',
1714
- decimals: 18,
1715
- },
1716
1685
  },
1717
1686
  [Network.SEPOLIA]: {
1718
1687
  ETH: { address: ETHER_ADDRESS, decimals: 18 },
@@ -1870,6 +1839,8 @@ export const Holders: {
1870
1839
  'USD0++': '0x2227b6806339906707b43F36a1f07B52FF7Fa776',
1871
1840
  USDM: '0x57F5E098CaD7A3D1Eed53991D4d66C45C9AF7812',
1872
1841
  wUSDM: '0x3B95bC951EE0f553ba487327278cAc44f29715E5',
1842
+ USDL: '0xAb96AA0ee764924f49fbB372f3B4db9c2cB24Ea2',
1843
+ wUSDL: '0xBBBBBbbBBb9cC5e90e3b3Af64bdAF62C37EEFFCb',
1873
1844
  UsualM: '0xE3f7A0c4a44b740328157A5152A85c3bCB54DA09',
1874
1845
  },
1875
1846
  [Network.POLYGON]: {
@@ -2036,7 +2007,6 @@ export const Holders: {
2036
2007
  MIM: '0xf46bb6dda9709c49efb918201d97f6474eac5aea',
2037
2008
  VST: '0x59bf0545fca0e5ad48e13da269facd2e8c886ba4',
2038
2009
  aArbUSDC: '0x048BF2F5908e95976CeAD0E47D805b3803E286e2',
2039
- waArbUSDT: '0xa6D12574eFB239FC1D2099732bd8b5dC6306897F',
2040
2010
  ZYB: '0x3ec0eddcd1e25025077327886a78133589082fb2',
2041
2011
  WBTC: '0xd9d611c6943585bc0e18e51034af8fa28778f7da',
2042
2012
  RDNT: '0x62383739d68dd0f844103db8dfb05a7eded5bbe6',
@@ -2055,7 +2025,6 @@ export const Holders: {
2055
2025
  GHO: '0xda39E48523770197EF3CbB70C1bf1cCCF9B4b1E7',
2056
2026
  USDM: '0x57F5E098CaD7A3D1Eed53991D4d66C45C9AF7812',
2057
2027
  wUSDM: '0x12c9cE6b155c8aaC74004732A621B64bC669bb79',
2058
- waArbWETH: '0x854B004700885A61107B458f11eCC169A019b764',
2059
2028
  },
2060
2029
  [Network.OPTIMISM]: {
2061
2030
  ETH: '0xF6D4E5a7c5215F91f59a95065190CCa24bf64554',
@@ -2118,7 +2087,7 @@ export const Holders: {
2118
2087
  waGnoGNO: '0x9Ec6472Fc33D9a5D17613484aDF0295A001fDF32',
2119
2088
  },
2120
2089
  [Network.BASE]: {
2121
- WETH: '0x24D61e5411C143135068557AfD06546d81A751b8',
2090
+ WETH: '0x4bb6b2efe7036020ba6f02a05602546c9f25bf28',
2122
2091
  PRIME: '0xe3879b7359695f802d6FD56Bb76fD82C362Dafd6',
2123
2092
  ETH: '0xd34ea7278e6bd48defe656bbe263aef11101469c',
2124
2093
  MAV: '0xf977814e90da44bfa03b6295a0616a897441acec',
@@ -2138,17 +2107,10 @@ export const Holders: {
2138
2107
  DOG: '0xbe3ab8a87730684ef1e476064c2e43c3e982f8e8',
2139
2108
  stataUSDC: '0x88Cac91ADDE2208039A227B373C2A692C0700547',
2140
2109
  aaveUSDC: '0x5DE3c5BE52D7aDbdC3aEFe2eA061A2ECE0C7d766',
2141
- waBasUSDC: '0xC768c589647798a6EE01A91FdE98EF2ed046DBD6',
2142
2110
  USDM: '0x426c4966fC76Bf782A663203c023578B744e4C5E',
2143
2111
  crvUSD: '0xBbAbDB1385deA5285113581A7024d6DC04131101',
2144
2112
  cbETH: '0x50e011dD1e2b4906F1534623cD134B30422bb11E',
2145
2113
  wUSDM: '0xe30965Acd0Ee1CE2e0Cd0AcBFB3596bD6fC78A51',
2146
- aBasUSDC: '0xC006544B93e86E8999623C1D12d2E352c61C8123',
2147
- waBasWETH: '0xbA1333333333a1BA1108E8412f11850A5C319bA9',
2148
- wstETH: '0x96892b8FBd24e0aC40BD98A304095a6c485A6A68',
2149
- waBaswstETH: '0x854B004700885A61107B458f11eCC169A019b764',
2150
- sUSDS: '0xC9716E991396AA933Fa7A481003a5953bcBabC17',
2151
- smUSDC: '0x88457F47c9BEC8379eB90d8dC3592F79084e555d',
2152
2114
  },
2153
2115
  [Network.SEPOLIA]: {
2154
2116
  bal: '0xDb4ff41B4C1222c2b1869A67Be115070688989a2',
@@ -21,7 +21,6 @@ export type SimulationResult = {
21
21
 
22
22
  export interface TransactionSimulator {
23
23
  vnetId: string;
24
- rpcURL: string;
25
24
  setup(): Promise<void>;
26
25
 
27
26
  getChainNameByChainId(network: number): string;
@@ -34,7 +33,6 @@ export interface TransactionSimulator {
34
33
 
35
34
  export class EstimateGasSimulation implements TransactionSimulator {
36
35
  vnetId: string = '0';
37
- rpcURL: string = '';
38
36
 
39
37
  constructor(private provider: Provider) {}
40
38
 
@@ -214,7 +214,7 @@ class APIParaswapSDK implements IParaSwapSDK {
214
214
  const minMaxAmount = _minMaxAmount.toString();
215
215
  let deadline = Number((Math.floor(Date.now() / 1000) + 10 * 60).toFixed());
216
216
 
217
- return (await this.transactionBuilder.build({
217
+ return await this.transactionBuilder.build({
218
218
  priceRoute,
219
219
  minMaxAmount: minMaxAmount.toString(),
220
220
  userAddress,
@@ -222,7 +222,7 @@ class APIParaswapSDK implements IParaSwapSDK {
222
222
  partnerFeePercent: '0',
223
223
  deadline: deadline.toString(),
224
224
  uuid: uuid(),
225
- })) as TxObject;
225
+ });
226
226
  }
227
227
  }
228
228
 
@@ -485,8 +485,11 @@ export async function testE2E(
485
485
  }
486
486
 
487
487
  if (paraswap.dexHelper?.replaceProviderWithRPC) {
488
- console.log('ts.rpcURL: ', ts.rpcURL);
489
- paraswap.dexHelper?.replaceProviderWithRPC(ts.rpcURL);
488
+ paraswap.dexHelper?.replaceProviderWithRPC(
489
+ `https://virtual.${ts.getChainNameByChainId(network)}.rpc.tenderly.co/${
490
+ ts.vnetId
491
+ }`,
492
+ );
490
493
  }
491
494
 
492
495
  try {