@paraswap/dex-lib 2.41.3 → 2.41.5-polygon-migrator

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 (57) hide show
  1. package/build/abi/polygon-migration/PolygonMigration.abi.json +364 -0
  2. package/build/config.js +2 -2
  3. package/build/dex/dexalot/constants.js.map +1 -1
  4. package/build/dex/dexalot/dexalot.js +18 -10
  5. package/build/dex/dexalot/dexalot.js.map +1 -1
  6. package/build/dex/dexalot/rate-fetcher.js +1 -1
  7. package/build/dex/dexalot/rate-fetcher.js.map +1 -1
  8. package/build/dex/index.js +4 -0
  9. package/build/dex/index.js.map +1 -1
  10. package/build/dex/polygon-migrator/config.d.ts +11 -0
  11. package/build/dex/polygon-migrator/config.js +21 -0
  12. package/build/dex/polygon-migrator/config.js.map +1 -0
  13. package/build/dex/polygon-migrator/constants.d.ts +1 -0
  14. package/build/dex/polygon-migrator/constants.js +5 -0
  15. package/build/dex/polygon-migrator/constants.js.map +1 -0
  16. package/build/dex/polygon-migrator/polygon-migrator.d.ts +48 -0
  17. package/build/dex/polygon-migrator/polygon-migrator.js +109 -0
  18. package/build/dex/polygon-migrator/polygon-migrator.js.map +1 -0
  19. package/build/dex/polygon-migrator/types.d.ts +11 -0
  20. package/build/dex/polygon-migrator/types.js +9 -0
  21. package/build/dex/polygon-migrator/types.js.map +1 -0
  22. package/build/dex/solidly/config.js +11 -1
  23. package/build/dex/solidly/config.js.map +1 -1
  24. package/build/dex/solidly/forks-override/chronos.js +10 -3
  25. package/build/dex/solidly/forks-override/chronos.js.map +1 -1
  26. package/build/dex/solidly/forks-override/usdfi.d.ts +8 -0
  27. package/build/dex/solidly/forks-override/usdfi.js +15 -0
  28. package/build/dex/solidly/forks-override/usdfi.js.map +1 -0
  29. package/build/dex/solidly/forks-override/velocimeter.js +6 -2
  30. package/build/dex/solidly/forks-override/velocimeter.js.map +1 -1
  31. package/build/dex/solidly/solidly.js +1 -0
  32. package/build/dex/solidly/solidly.js.map +1 -1
  33. package/build/dex/swaap-v2/swaap-v2.js.map +1 -1
  34. package/package.json +1 -1
  35. package/src/abi/polygon-migration/PolygonMigration.abi.json +364 -0
  36. package/src/config.ts +2 -2
  37. package/src/dex/algebra/algebra-e2e.test.ts +1 -1
  38. package/src/dex/dexalot/constants.ts +2 -1
  39. package/src/dex/dexalot/dexalot-e2e.test.ts +9 -9
  40. package/src/dex/dexalot/dexalot.ts +59 -34
  41. package/src/dex/dexalot/rate-fetcher.ts +1 -1
  42. package/src/dex/index.ts +4 -0
  43. package/src/dex/polygon-migrator/config.ts +25 -0
  44. package/src/dex/polygon-migrator/constants.ts +2 -0
  45. package/src/dex/polygon-migrator/polygon-migrator-e2e.test.ts +102 -0
  46. package/src/dex/polygon-migrator/polygon-migrator-integration.test.ts +140 -0
  47. package/src/dex/polygon-migrator/polygon-migrator.ts +151 -0
  48. package/src/dex/polygon-migrator/types.ts +14 -0
  49. package/src/dex/solidly/config.ts +13 -1
  50. package/src/dex/solidly/forks-override/chronos.ts +93 -68
  51. package/src/dex/solidly/forks-override/usdfi.ts +10 -0
  52. package/src/dex/solidly/forks-override/velocimeter.ts +6 -2
  53. package/src/dex/solidly/solidly-e2e.test.ts +20 -0
  54. package/src/dex/solidly/solidly-integration.test.ts +189 -1
  55. package/src/dex/solidly/solidly.ts +1 -0
  56. package/src/dex/swaap-v2/swaap-v2.ts +5 -2
  57. package/tests/constants-e2e.ts +25 -0
@@ -18,6 +18,7 @@ import * as util from 'util';
18
18
  import { VelodromeV2 } from './forks-override/velodromeV2';
19
19
  import { Equalizer } from './forks-override/equalizer';
20
20
  import { Velocimeter } from './forks-override/velocimeter';
21
+ import { Usdfi } from './forks-override/usdfi';
21
22
 
22
23
  const amounts18 = [0n, BI_POWS[18], 2000000000000000000n];
23
24
  const amounts6 = [0n, BI_POWS[6], 2000000n];
@@ -976,6 +977,194 @@ describe('Solidly integration tests', () => {
976
977
  });
977
978
  });
978
979
  });
980
+
981
+ describe('Usdfi', function () {
982
+ const dexKey = 'Usdfi';
983
+ const usdfi = new Usdfi(network, dexKey, dexHelper);
984
+
985
+ describe('UniswapV2 like pool', function () {
986
+ const TokenASymbol = 'USDFI';
987
+ const tokenA = Tokens[network][TokenASymbol];
988
+ const TokenBSymbol = 'USDT';
989
+ const tokenB = Tokens[network][TokenBSymbol];
990
+
991
+ const amounts = amounts18;
992
+
993
+ it('getPoolIdentifiers and getPricesVolume', async function () {
994
+ const blocknumber = await dexHelper.web3Provider.eth.getBlockNumber();
995
+ const pools = await usdfi.getPoolIdentifiers(
996
+ tokenA,
997
+ tokenB,
998
+ SwapSide.SELL,
999
+ blocknumber,
1000
+ );
1001
+ console.log(
1002
+ `${TokenASymbol} <> ${TokenBSymbol} Pool Identifiers: `,
1003
+ pools,
1004
+ );
1005
+
1006
+ expect(pools.length).toBeGreaterThan(0);
1007
+
1008
+ const poolPrices = await usdfi.getPricesVolume(
1009
+ tokenA,
1010
+ tokenB,
1011
+ amounts,
1012
+ SwapSide.SELL,
1013
+ blocknumber,
1014
+ pools,
1015
+ );
1016
+ console.log(
1017
+ `${TokenASymbol} <> ${TokenBSymbol} Pool Prices: `,
1018
+ poolPrices,
1019
+ );
1020
+
1021
+ expect(poolPrices).not.toBeNull();
1022
+ checkPoolPrices(poolPrices!, amounts, SwapSide.SELL, dexKey);
1023
+
1024
+ // Check if onchain pricing equals to calculated ones
1025
+
1026
+ for (const poolPrice of poolPrices || []) {
1027
+ await checkOnChainPricing(
1028
+ usdfi,
1029
+ 'getAmountOut',
1030
+ blocknumber,
1031
+ poolPrice.prices,
1032
+ poolPrice.poolAddresses![0],
1033
+ tokenA.address,
1034
+ amounts,
1035
+ );
1036
+ }
1037
+ });
1038
+
1039
+ it('getTopPoolsForToken', async function () {
1040
+ const poolLiquidity = await usdfi.getTopPoolsForToken(
1041
+ tokenA.address,
1042
+ 10,
1043
+ );
1044
+ console.log(`${TokenASymbol} Top Pools:`, poolLiquidity);
1045
+
1046
+ checkPoolsLiquidity(poolLiquidity, tokenA.address, dexKey);
1047
+ });
1048
+ });
1049
+
1050
+ describe('Curve like stable pool', function () {
1051
+ const TokenASymbol = 'USDT';
1052
+ const tokenA = Tokens[network][TokenASymbol];
1053
+ const TokenBSymbol = 'BUSD';
1054
+ const tokenB = Tokens[network][TokenBSymbol];
1055
+
1056
+ const amounts = amounts6;
1057
+
1058
+ it('getPoolIdentifiers and getPricesVolume', async function () {
1059
+ const blocknumber = await dexHelper.web3Provider.eth.getBlockNumber();
1060
+ const pools = await usdfi.getPoolIdentifiers(
1061
+ tokenA,
1062
+ tokenB,
1063
+ SwapSide.SELL,
1064
+ blocknumber,
1065
+ );
1066
+ console.log(
1067
+ `${TokenASymbol} <> ${TokenBSymbol} Pool Identifiers: `,
1068
+ pools,
1069
+ );
1070
+
1071
+ expect(pools.length).toBeGreaterThan(0);
1072
+
1073
+ const poolPrices = await usdfi.getPricesVolume(
1074
+ tokenA,
1075
+ tokenB,
1076
+ amounts,
1077
+ SwapSide.SELL,
1078
+ blocknumber,
1079
+ pools,
1080
+ );
1081
+ console.log(
1082
+ `${TokenASymbol} <> ${TokenBSymbol} Pool Prices: `,
1083
+ poolPrices,
1084
+ );
1085
+
1086
+ expect(poolPrices).not.toBeNull();
1087
+ checkPoolPrices(poolPrices!, amounts, SwapSide.SELL, dexKey);
1088
+
1089
+ // Check if onchain pricing equals to calculated ones
1090
+ for (const poolPrice of poolPrices || []) {
1091
+ await checkOnChainPricing(
1092
+ usdfi,
1093
+ 'getAmountOut',
1094
+ blocknumber,
1095
+ poolPrice.prices,
1096
+ poolPrice.poolAddresses![0],
1097
+ tokenA.address,
1098
+ amounts,
1099
+ );
1100
+ }
1101
+ });
1102
+
1103
+ it('getTopPoolsForToken', async function () {
1104
+ const poolLiquidity = await usdfi.getTopPoolsForToken(
1105
+ tokenA.address,
1106
+ 10,
1107
+ );
1108
+ console.log(`${TokenASymbol} Top Pools:`, poolLiquidity);
1109
+
1110
+ checkPoolsLiquidity(poolLiquidity, tokenA.address, dexKey);
1111
+ });
1112
+ });
1113
+
1114
+ describe('FRAX -> frxETH', () => {
1115
+ const TokenASymbol = 'FRAX';
1116
+ const tokenA = Tokens[network][TokenASymbol];
1117
+ const TokenBSymbol = 'frxETH';
1118
+ const tokenB = Tokens[network][TokenBSymbol];
1119
+
1120
+ const amounts = amounts18;
1121
+
1122
+ it('getPoolIdentifiers and getPricesVolume', async function () {
1123
+ const blocknumber = await dexHelper.web3Provider.eth.getBlockNumber();
1124
+ const pools = await usdfi.getPoolIdentifiers(
1125
+ tokenA,
1126
+ tokenB,
1127
+ SwapSide.SELL,
1128
+ blocknumber,
1129
+ );
1130
+ console.log(
1131
+ `${TokenASymbol} <> ${TokenBSymbol} Pool Identifiers: `,
1132
+ pools,
1133
+ );
1134
+
1135
+ expect(pools.length).toBeGreaterThan(0);
1136
+
1137
+ const poolPrices = await usdfi.getPricesVolume(
1138
+ tokenA,
1139
+ tokenB,
1140
+ amounts,
1141
+ SwapSide.SELL,
1142
+ blocknumber,
1143
+ pools,
1144
+ );
1145
+ console.log(
1146
+ `${TokenASymbol} <> ${TokenBSymbol} Pool Prices: `,
1147
+ poolPrices,
1148
+ );
1149
+
1150
+ expect(poolPrices).not.toBeNull();
1151
+ checkPoolPrices(poolPrices!, amounts, SwapSide.SELL, dexKey);
1152
+
1153
+ // Check if onchain pricing equals to calculated ones
1154
+ for (const poolPrice of poolPrices || []) {
1155
+ await checkOnChainPricing(
1156
+ usdfi,
1157
+ 'getAmountOut',
1158
+ blocknumber,
1159
+ poolPrice.prices,
1160
+ poolPrice.poolAddresses![0],
1161
+ tokenA.address,
1162
+ amounts,
1163
+ );
1164
+ }
1165
+ });
1166
+ });
1167
+ });
979
1168
  });
980
1169
 
981
1170
  describe('Arbitrum', () => {
@@ -1551,7 +1740,6 @@ describe('Solidly integration tests', () => {
1551
1740
  }
1552
1741
  });
1553
1742
  });
1554
-
1555
1743
  });
1556
1744
  });
1557
1745
  });
@@ -76,6 +76,7 @@ export class Solidly extends UniswapV2 {
76
76
  'Ramses',
77
77
  'Equalizer',
78
78
  'Velocimeter',
79
+ 'Usdfi',
79
80
  ]),
80
81
  );
81
82
 
@@ -55,7 +55,10 @@ import {
55
55
  } from './constants';
56
56
  import { getPoolIdentifier, normalizeTokenAddress, getPairName } from './utils';
57
57
  import { Method } from '../../dex-helper/irequest-wrapper';
58
- import { SlippageCheckError, TooStrictSlippageCheckError } from '../generic-rfq/types';
58
+ import {
59
+ SlippageCheckError,
60
+ TooStrictSlippageCheckError,
61
+ } from '../generic-rfq/types';
59
62
  import { BI_MAX_UINT256 } from '../../bigint-constants';
60
63
 
61
64
  const BLACKLISTED = 'blacklisted';
@@ -567,7 +570,7 @@ export class SwaapV2 extends SimpleExchange implements IDex<SwaapV2Data> {
567
570
  `${this.dexKey}-${this.network}: Encountered restricted user=${options.txOrigin}. Adding to local blacklist cache`,
568
571
  );
569
572
  } else {
570
- if(e instanceof TooStrictSlippageCheckError) {
573
+ if (e instanceof TooStrictSlippageCheckError) {
571
574
  this.logger.warn(
572
575
  `${this.dexKey}-${this.network}: failed to build transaction on side ${side} with too strict slippage. Skipping restriction`,
573
576
  );
@@ -311,6 +311,14 @@ export const Tokens: {
311
311
  address: '0x8751d4196027d4e6da63716fa7786b5174f04c15',
312
312
  decimals: 18,
313
313
  },
314
+ MATIC: {
315
+ address: '0x7d1afa7b718fb893db30a3abc0cfc608aacfebb0',
316
+ decimals: 18,
317
+ },
318
+ POL: {
319
+ address: '0x455e53CBB86018Ac2B8092FdCd39d8444aFFC3F6',
320
+ decimals: 19,
321
+ }
314
322
  },
315
323
  [Network.ROPSTEN]: {
316
324
  DAI: {
@@ -583,6 +591,18 @@ export const Tokens: {
583
591
  address: '0x4268B8F0B87b6Eae5d897996E6b845ddbD99Adf3',
584
592
  decimals: 6,
585
593
  },
594
+ FRAX: {
595
+ address: '0x90C97F71E18723b0Cf0dfa30ee176Ab653E89F40',
596
+ decimals: 18,
597
+ },
598
+ frxETH: {
599
+ address: '0x64048A7eEcF3a2F1BA9e144aAc3D7dB6e58F555e',
600
+ decimals: 18,
601
+ },
602
+ USDFI: {
603
+ address: '0x11A38e06699b238D6D9A0C7A01f3AC63a07ad318',
604
+ decimals: 18,
605
+ },
586
606
  },
587
607
  [Network.AVALANCHE]: {
588
608
  USDCe: {
@@ -996,6 +1016,8 @@ export const Holders: {
996
1016
  crvUSD: '0xA920De414eA4Ab66b97dA1bFE9e6EcA7d4219635',
997
1017
  GHO: '0x844Dc85EdD8492A56228D293cfEbb823EF3E10EC',
998
1018
  wibBTC: '0xFbdCA68601f835b27790D98bbb8eC7f05FDEaA9B',
1019
+ MATIC: '0x7073783eee7e9b3e6e4ddac4d7f49dc46044dd9a',
1020
+ POL: '0xCc56a33BdfCfdec4E35aD1259C1f1A06efa0AAcd',
999
1021
  },
1000
1022
  [Network.ROPSTEN]: {
1001
1023
  ETH: '0x43262A12d8610AA70C15DbaeAC321d51613c9071',
@@ -1071,6 +1093,9 @@ export const Holders: {
1071
1093
  anyBTC: '0x4ffef8e8a75c20ab0ddf96c50d2457277d27923c',
1072
1094
  nUSD: '0x28ec0b36f0819ecb5005cab836f4ed5a2eca4d13',
1073
1095
  axlUSD: '0xc03fbeda9069b22a120ae6a09349a0b5eea5570a',
1096
+ FRAX: '0xEB4576fE753DAB07635c0Bb6c8f0A355e1Db5d31',
1097
+ frxETH: '0xf324adC872005197A6f7DAE214d3b63aa0C3625F',
1098
+ USDFI: '0x2E00D722e091836B39Db3e4dcE6eE51c90c5B221',
1074
1099
  },
1075
1100
  [Network.AVALANCHE]: {
1076
1101
  AVAX: '0xD6216fC19DB775Df9774a6E33526131dA7D19a2c',