@paraswap/dex-lib 2.20.1 → 2.20.2-curve-new-implementations.1

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 (90) hide show
  1. package/build/dex/aave-v3/tokens/arbitrum.json +50 -0
  2. package/build/dex/aave-v3/tokens/avalanche.json +74 -0
  3. package/build/dex/aave-v3/tokens/fantom.json +62 -0
  4. package/build/dex/aave-v3/tokens/optimism.json +50 -0
  5. package/build/dex/aave-v3/tokens/polygon.json +116 -0
  6. package/build/dex/curve-v1-factory/config.js +88 -8
  7. package/build/dex/curve-v1-factory/config.js.map +1 -1
  8. package/build/dex/curve-v1-factory/curve-v1-factory.js +2 -2
  9. package/build/dex/curve-v1-factory/curve-v1-factory.js.map +1 -1
  10. package/build/dex/curve-v1-factory/price-handlers/functions/_calc_withdraw_one_coin.js +27 -3
  11. package/build/dex/curve-v1-factory/price-handlers/functions/_calc_withdraw_one_coin.js.map +1 -1
  12. package/build/dex/curve-v1-factory/price-handlers/functions/_dynamic_fee.js +6 -0
  13. package/build/dex/curve-v1-factory/price-handlers/functions/_dynamic_fee.js.map +1 -1
  14. package/build/dex/curve-v1-factory/price-handlers/functions/_rates.js +6 -0
  15. package/build/dex/curve-v1-factory/price-handlers/functions/_rates.js.map +1 -1
  16. package/build/dex/curve-v1-factory/price-handlers/functions/_xp.js +6 -0
  17. package/build/dex/curve-v1-factory/price-handlers/functions/_xp.js.map +1 -1
  18. package/build/dex/curve-v1-factory/price-handlers/functions/_xp_mem.js +6 -0
  19. package/build/dex/curve-v1-factory/price-handlers/functions/_xp_mem.js.map +1 -1
  20. package/build/dex/curve-v1-factory/price-handlers/functions/calc_token_amount.js +6 -0
  21. package/build/dex/curve-v1-factory/price-handlers/functions/calc_token_amount.js.map +1 -1
  22. package/build/dex/curve-v1-factory/price-handlers/functions/calc_withdraw_one_coin.js +6 -0
  23. package/build/dex/curve-v1-factory/price-handlers/functions/calc_withdraw_one_coin.js.map +1 -1
  24. package/build/dex/curve-v1-factory/price-handlers/functions/constants.js +66 -0
  25. package/build/dex/curve-v1-factory/price-handlers/functions/constants.js.map +1 -1
  26. package/build/dex/curve-v1-factory/price-handlers/functions/get_D.js +6 -0
  27. package/build/dex/curve-v1-factory/price-handlers/functions/get_D.js.map +1 -1
  28. package/build/dex/curve-v1-factory/price-handlers/functions/get_D_mem.js +20 -0
  29. package/build/dex/curve-v1-factory/price-handlers/functions/get_D_mem.js.map +1 -1
  30. package/build/dex/curve-v1-factory/price-handlers/functions/get_D_precisions.js +6 -0
  31. package/build/dex/curve-v1-factory/price-handlers/functions/get_D_precisions.js.map +1 -1
  32. package/build/dex/curve-v1-factory/price-handlers/functions/get_dy.js +26 -3
  33. package/build/dex/curve-v1-factory/price-handlers/functions/get_dy.js.map +1 -1
  34. package/build/dex/curve-v1-factory/price-handlers/functions/get_dy_underlying.js +6 -0
  35. package/build/dex/curve-v1-factory/price-handlers/functions/get_dy_underlying.js.map +1 -1
  36. package/build/dex/curve-v1-factory/price-handlers/functions/get_y.js +6 -0
  37. package/build/dex/curve-v1-factory/price-handlers/functions/get_y.js.map +1 -1
  38. package/build/dex/curve-v1-factory/price-handlers/functions/get_y_D.js +6 -0
  39. package/build/dex/curve-v1-factory/price-handlers/functions/get_y_D.js.map +1 -1
  40. package/build/dex/curve-v1-factory/state-polling-pools/custom-pool-polling.d.ts +1 -1
  41. package/build/dex/curve-v1-factory/state-polling-pools/custom-pool-polling.js +2 -2
  42. package/build/dex/curve-v1-factory/state-polling-pools/custom-pool-polling.js.map +1 -1
  43. package/build/dex/curve-v1-factory/state-polling-pools/factory-pool-polling.d.ts +3 -1
  44. package/build/dex/curve-v1-factory/state-polling-pools/factory-pool-polling.js +22 -3
  45. package/build/dex/curve-v1-factory/state-polling-pools/factory-pool-polling.js.map +1 -1
  46. package/build/dex/curve-v1-factory/state-polling-pools/pool-polling-base.d.ts +2 -1
  47. package/build/dex/curve-v1-factory/state-polling-pools/pool-polling-base.js +2 -1
  48. package/build/dex/curve-v1-factory/state-polling-pools/pool-polling-base.js.map +1 -1
  49. package/build/dex/curve-v1-factory/types.d.ts +16 -0
  50. package/build/dex/curve-v1-factory/types.js +6 -0
  51. package/build/dex/curve-v1-factory/types.js.map +1 -1
  52. package/build/dex/test-dex/config.d.ts +4 -0
  53. package/build/dex/test-dex/config.js +15 -0
  54. package/build/dex/test-dex/config.js.map +1 -0
  55. package/build/dex/test-dex/test-dex-pool.d.ts +39 -0
  56. package/build/dex/test-dex/test-dex-pool.js +63 -0
  57. package/build/dex/test-dex/test-dex-pool.js.map +1 -0
  58. package/build/dex/test-dex/test-dex.d.ts +37 -0
  59. package/build/dex/test-dex/test-dex.js +126 -0
  60. package/build/dex/test-dex/test-dex.js.map +1 -0
  61. package/build/dex/test-dex/types.d.ts +6 -0
  62. package/build/dex/test-dex/types.js +3 -0
  63. package/build/dex/test-dex/types.js.map +1 -0
  64. package/build/dex/woo-fi-v2/woo-fi-math.d.ts +16 -0
  65. package/build/dex/woo-fi-v2/woo-fi-math.js +137 -0
  66. package/build/dex/woo-fi-v2/woo-fi-math.js.map +1 -0
  67. package/package.json +1 -1
  68. package/src/dex/curve-v1-factory/config.ts +88 -8
  69. package/src/dex/curve-v1-factory/curve-v1-factory-e2e.test.ts +36 -0
  70. package/src/dex/curve-v1-factory/curve-v1-factory.ts +3 -0
  71. package/src/dex/curve-v1-factory/price-handlers/functions/_calc_withdraw_one_coin.ts +53 -6
  72. package/src/dex/curve-v1-factory/price-handlers/functions/_dynamic_fee.ts +7 -0
  73. package/src/dex/curve-v1-factory/price-handlers/functions/_rates.ts +7 -0
  74. package/src/dex/curve-v1-factory/price-handlers/functions/_xp.ts +7 -0
  75. package/src/dex/curve-v1-factory/price-handlers/functions/_xp_mem.ts +7 -0
  76. package/src/dex/curve-v1-factory/price-handlers/functions/calc_token_amount.ts +7 -0
  77. package/src/dex/curve-v1-factory/price-handlers/functions/calc_withdraw_one_coin.ts +7 -0
  78. package/src/dex/curve-v1-factory/price-handlers/functions/constants.ts +78 -0
  79. package/src/dex/curve-v1-factory/price-handlers/functions/get_D.ts +13 -0
  80. package/src/dex/curve-v1-factory/price-handlers/functions/get_D_mem.ts +40 -3
  81. package/src/dex/curve-v1-factory/price-handlers/functions/get_D_precisions.ts +7 -0
  82. package/src/dex/curve-v1-factory/price-handlers/functions/get_dy.ts +53 -4
  83. package/src/dex/curve-v1-factory/price-handlers/functions/get_dy_underlying.ts +7 -0
  84. package/src/dex/curve-v1-factory/price-handlers/functions/get_y.ts +7 -0
  85. package/src/dex/curve-v1-factory/price-handlers/functions/get_y_D.ts +7 -0
  86. package/src/dex/curve-v1-factory/state-polling-pools/custom-pool-polling.ts +2 -0
  87. package/src/dex/curve-v1-factory/state-polling-pools/factory-pool-polling.ts +42 -1
  88. package/src/dex/curve-v1-factory/state-polling-pools/pool-polling-base.ts +1 -0
  89. package/src/dex/curve-v1-factory/types.ts +14 -0
  90. package/tests/constants-e2e.ts +6 -10
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@paraswap/dex-lib",
3
- "version": "2.20.1",
3
+ "version": "2.20.2-curve-new-implementations.1",
4
4
  "main": "build/index.js",
5
5
  "types": "build/index.d.ts",
6
6
  "repository": "https://github.com/paraswap/paraswap-dex-lib",
@@ -68,6 +68,38 @@ const CurveV1FactoryConfig: DexConfigMap<DexParams> = {
68
68
  address: '0x2eb24483ef551da247ab87cf18e1cc980073032d',
69
69
  basePoolAddress: '0xDcEF968d416a41Cdac0ED8702fAC8128A64241A2',
70
70
  },
71
+ '0x008cfa89df5b0c780ca3462fc2602d7f8c7ac315': {
72
+ name: ImplementationNames.FACTORY_META_BTC_SBTC2,
73
+ address: '0x008cfa89df5b0c780ca3462fc2602d7f8c7ac315',
74
+ basePoolAddress: '0xf253f83AcA21aAbD2A20553AE0BF7F65C755A07F',
75
+ },
76
+ '0xabc533ebcdded41215c46ee078c5818b5b0a252f': {
77
+ name: ImplementationNames.FACTORY_META_BTC_BALANCES_SBTC2,
78
+ address: '0xabc533ebcdded41215c46ee078c5818b5b0a252f',
79
+ basePoolAddress: '0xf253f83AcA21aAbD2A20553AE0BF7F65C755A07F',
80
+ },
81
+ '0xc629a01ec23ab04e1050500a3717a2a5c0701497': {
82
+ name: ImplementationNames.FACTORY_PLAIN_2_BASIC_EMA,
83
+ address: '0xc629a01ec23ab04e1050500a3717a2a5c0701497',
84
+ customGasCost: 130_000,
85
+ },
86
+ '0x94b4dfd9ba5865cc931195c99a2db42f3fc5d45b': {
87
+ name: ImplementationNames.FACTORY_PLAIN_2_ETH_EMA,
88
+ address: '0x94b4dfd9ba5865cc931195c99a2db42f3fc5d45b',
89
+ customGasCost: 130_000,
90
+ },
91
+ '0x847ee1227a9900b73aeeb3a47fac92c52fd54ed9': {
92
+ name: ImplementationNames.FACTORY_PLAIN_2_ETH_EMA2,
93
+ address: '0x847ee1227a9900b73aeeb3a47fac92c52fd54ed9',
94
+ customGasCost: 130_000,
95
+ isStoreRateSupported: true,
96
+ },
97
+ '0x1713141278648a4edd5b027fdbd448bb4a13ac0f': {
98
+ name: ImplementationNames.FACTORY_PLAIN_2_ETH_EMA2,
99
+ address: '0x1713141278648a4edd5b027fdbd448bb4a13ac0f',
100
+ customGasCost: 130_000,
101
+ isStoreRateSupported: true,
102
+ },
71
103
  '0x24d937143d3f5cf04c72ba112735151a8cae2262': {
72
104
  name: ImplementationNames.FACTORY_PLAIN_2_BALANCES,
73
105
  address: '0x24d937143d3f5cf04c72ba112735151a8cae2262',
@@ -125,6 +157,7 @@ const CurveV1FactoryConfig: DexConfigMap<DexParams> = {
125
157
  liquidityApiSlug: '/main',
126
158
  coinsInputType: 'uint256',
127
159
  balancesInputType: 'uint256',
160
+ useForPricing: false,
128
161
  },
129
162
  '0x7fC77b5c7614E1533320Ea6DDc2Eb61fa00A9714': {
130
163
  name: CustomImplementationNames.CUSTOM_PLAIN_3COIN_SBTC,
@@ -133,6 +166,7 @@ const CurveV1FactoryConfig: DexConfigMap<DexParams> = {
133
166
  liquidityApiSlug: '/main',
134
167
  coinsInputType: 'int128',
135
168
  balancesInputType: 'int128',
169
+ useForPricing: false,
136
170
  },
137
171
  '0xbebc44782c7db0a1a60cb6fe97d0b483032ff1c7': {
138
172
  name: CustomImplementationNames.CUSTOM_PLAIN_3COIN_THREE,
@@ -141,6 +175,7 @@ const CurveV1FactoryConfig: DexConfigMap<DexParams> = {
141
175
  liquidityApiSlug: '/main',
142
176
  coinsInputType: 'uint256',
143
177
  balancesInputType: 'uint256',
178
+ useForPricing: false,
144
179
  },
145
180
  '0x93054188d876f558f4a66B2EF1d97d16eDf0895B': {
146
181
  name: CustomImplementationNames.CUSTOM_PLAIN_2COIN_RENBTC,
@@ -149,6 +184,16 @@ const CurveV1FactoryConfig: DexConfigMap<DexParams> = {
149
184
  liquidityApiSlug: '/main',
150
185
  coinsInputType: 'int128',
151
186
  balancesInputType: 'int128',
187
+ useForPricing: false,
188
+ },
189
+ '0xf253f83aca21aabd2a20553ae0bf7f65c755a07f': {
190
+ name: CustomImplementationNames.CUSTOM_PLAIN_2COIN_WBTC,
191
+ address: '0xf253f83aca21aabd2a20553ae0bf7f65c755a07f',
192
+ lpTokenAddress: '0x051d7e5609917Bd9b73f04BAc0DED8Dd46a74301',
193
+ liquidityApiSlug: '/main',
194
+ coinsInputType: 'uint256',
195
+ balancesInputType: 'uint256',
196
+ useForPricing: true,
152
197
  },
153
198
  },
154
199
  },
@@ -245,6 +290,7 @@ const CurveV1FactoryConfig: DexConfigMap<DexParams> = {
245
290
  liquidityApiSlug: '/main',
246
291
  coinsInputType: 'uint256',
247
292
  balancesInputType: 'uint256',
293
+ useForPricing: false,
248
294
  },
249
295
  '0xC2d95EEF97Ec6C17551d45e77B590dc1F9117C67': {
250
296
  name: CustomImplementationNames.CUSTOM_POLYGON_2COIN_LENDING,
@@ -253,6 +299,7 @@ const CurveV1FactoryConfig: DexConfigMap<DexParams> = {
253
299
  liquidityApiSlug: '/main',
254
300
  coinsInputType: 'uint256',
255
301
  balancesInputType: 'uint256',
302
+ useForPricing: false,
256
303
  },
257
304
  },
258
305
  },
@@ -349,6 +396,7 @@ const CurveV1FactoryConfig: DexConfigMap<DexParams> = {
349
396
  liquidityApiSlug: '/main',
350
397
  coinsInputType: 'uint256',
351
398
  balancesInputType: 'uint256',
399
+ useForPricing: false,
352
400
  },
353
401
  '0x3eF6A01A0f81D6046290f3e2A8c5b843e738E604': {
354
402
  name: CustomImplementationNames.CUSTOM_FANTOM_2COIN_BTC,
@@ -357,15 +405,17 @@ const CurveV1FactoryConfig: DexConfigMap<DexParams> = {
357
405
  liquidityApiSlug: '/main',
358
406
  coinsInputType: 'uint256',
359
407
  balancesInputType: 'uint256',
408
+ useForPricing: false,
409
+ },
410
+ '0x0fa949783947Bf6c1b171DB13AEACBB488845B3f': {
411
+ name: CustomImplementationNames.CUSTOM_FANTOM_3COIN_LENDING,
412
+ address: '0x0fa949783947Bf6c1b171DB13AEACBB488845B3f',
413
+ lpTokenAddress: '0xD02a30d33153877BC20e5721ee53DeDEE0422B2F',
414
+ liquidityApiSlug: '/main',
415
+ coinsInputType: 'uint256',
416
+ balancesInputType: 'uint256',
417
+ useForPricing: false,
360
418
  },
361
- // '0x0fa949783947Bf6c1b171DB13AEACBB488845B3f': {
362
- // name: CustomImplementationNames.CUSTOM_FANTOM_3COIN_LENDING,
363
- // address: '0x0fa949783947Bf6c1b171DB13AEACBB488845B3f',
364
- // lpTokenAddress: '0xD02a30d33153877BC20e5721ee53DeDEE0422B2F',
365
- // liquidityApiSlug: '/main',
366
- // coinsInputType: 'uint256',
367
- // balancesInputType: 'uint256',
368
- // },
369
419
  },
370
420
  },
371
421
  [Network.AVALANCHE]: {
@@ -454,6 +504,7 @@ const CurveV1FactoryConfig: DexConfigMap<DexParams> = {
454
504
  liquidityApiSlug: '/main',
455
505
  coinsInputType: 'uint256',
456
506
  balancesInputType: 'uint256',
507
+ useForPricing: false,
457
508
  },
458
509
  // This contract is not verified. I think it is just abandoned. I am commenting both related
459
510
  // btc meta pools
@@ -549,6 +600,17 @@ const CurveV1FactoryConfig: DexConfigMap<DexParams> = {
549
600
  address: '0xF1f85a74AD6c64315F85af52d3d46bF715236ADc',
550
601
  basePoolAddress: '0x3E01dD8a5E1fb3481F0F589056b428Fc308AF0Fb',
551
602
  },
603
+ '0x73ec37618683c274d0bbf5f5726aa856b2bdab81': {
604
+ name: ImplementationNames.FACTORY_PLAIN_2_BASIC_EMA,
605
+ address: '0x73ec37618683c274d0bbf5f5726aa856b2bdab81',
606
+ customGasCost: 130_000,
607
+ },
608
+ '0x6f9fb833501f46cbe6f6a4b6cf32c834e5a5e8c5': {
609
+ name: ImplementationNames.FACTORY_PLAIN_2_ETH_EMA2,
610
+ address: '0x6f9fb833501f46cbe6f6a4b6cf32c834e5a5e8c5',
611
+ customGasCost: 130_000,
612
+ isStoreRateSupported: true,
613
+ },
552
614
  },
553
615
  customPools: {
554
616
  '0x7f90122BF0700F9E7e1F688fe926940E8839F353': {
@@ -558,6 +620,7 @@ const CurveV1FactoryConfig: DexConfigMap<DexParams> = {
558
620
  liquidityApiSlug: '/main',
559
621
  coinsInputType: 'uint256',
560
622
  balancesInputType: 'uint256',
623
+ useForPricing: false,
561
624
  },
562
625
  '0xC9B8a3FDECB9D5b218d02555a8Baf332E5B740d5': {
563
626
  name: FactoryImplementationNames.FACTORY_PLAIN_2_BASIC,
@@ -566,6 +629,7 @@ const CurveV1FactoryConfig: DexConfigMap<DexParams> = {
566
629
  liquidityApiSlug: '/factory',
567
630
  coinsInputType: 'uint256',
568
631
  balancesInputType: 'uint256',
632
+ useForPricing: false,
569
633
  },
570
634
  '0x3E01dD8a5E1fb3481F0F589056b428Fc308AF0Fb': {
571
635
  name: CustomImplementationNames.CUSTOM_ARBITRUM_2COIN_BTC,
@@ -574,6 +638,7 @@ const CurveV1FactoryConfig: DexConfigMap<DexParams> = {
574
638
  liquidityApiSlug: '/main',
575
639
  coinsInputType: 'uint256',
576
640
  balancesInputType: 'uint256',
641
+ useForPricing: false,
577
642
  },
578
643
  },
579
644
  },
@@ -651,6 +716,17 @@ const CurveV1FactoryConfig: DexConfigMap<DexParams> = {
651
716
  address: '0x114C4042B11a2b16F58Fe1BFe847589a122F678a',
652
717
  basePoolAddress: '0x29A3d66B30Bc4AD674A4FDAF27578B64f6afbFe7',
653
718
  },
719
+ '0x73ec37618683c274d0bbf5f5726aa856b2bdab81': {
720
+ name: ImplementationNames.FACTORY_PLAIN_2_BASIC_EMA,
721
+ address: '0x73ec37618683c274d0bbf5f5726aa856b2bdab81',
722
+ customGasCost: 130_000,
723
+ },
724
+ '0x6f9fb833501f46cbe6f6a4b6cf32c834e5a5e8c5': {
725
+ name: ImplementationNames.FACTORY_PLAIN_2_ETH_EMA2,
726
+ address: '0x6f9fb833501f46cbe6f6a4b6cf32c834e5a5e8c5',
727
+ customGasCost: 130_000,
728
+ isStoreRateSupported: true,
729
+ },
654
730
  },
655
731
  customPools: {
656
732
  '0x1337BedC9D22ecbe766dF105c9623922A27963EC': {
@@ -660,6 +736,7 @@ const CurveV1FactoryConfig: DexConfigMap<DexParams> = {
660
736
  liquidityApiSlug: '/main',
661
737
  coinsInputType: 'uint256',
662
738
  balancesInputType: 'uint256',
739
+ useForPricing: false,
663
740
  },
664
741
  '0x29A3d66B30Bc4AD674A4FDAF27578B64f6afbFe7': {
665
742
  name: FactoryImplementationNames.FACTORY_PLAIN_2_BASIC,
@@ -668,6 +745,7 @@ const CurveV1FactoryConfig: DexConfigMap<DexParams> = {
668
745
  liquidityApiSlug: '/factory',
669
746
  coinsInputType: 'uint256',
670
747
  balancesInputType: 'uint256',
748
+ useForPricing: false,
671
749
  },
672
750
  },
673
751
  },
@@ -761,6 +839,7 @@ const configAddressesNormalizer = (
761
839
  balancesInputType: customPoolConfig.balancesInputType,
762
840
  address: normalizeAddress(customPoolConfig.address),
763
841
  lpTokenAddress: normalizeAddress(customPoolConfig.lpTokenAddress),
842
+ useForPricing: customPoolConfig.useForPricing,
764
843
  };
765
844
  acc[normalizeAddress(customPoolAddress)] = normalizedImplementation;
766
845
  return acc;
@@ -777,6 +856,7 @@ const configAddressesNormalizer = (
777
856
  basePoolAddress: implementationConfig.basePoolAddress
778
857
  ? normalizeAddress(implementationConfig.basePoolAddress)
779
858
  : undefined,
859
+ isStoreRateSupported: implementationConfig.isStoreRateSupported,
780
860
  };
781
861
  acc[normalizeAddress(implementationAddress)] =
782
862
  normalizedImplementation;
@@ -111,6 +111,42 @@ describe('CurveV1Factory E2E', () => {
111
111
  tokenBAmount,
112
112
  );
113
113
  });
114
+ describe('Mainnet ng pool', () => {
115
+ const network = Network.MAINNET;
116
+
117
+ const tokenASymbol: string = 'ETH';
118
+ const tokenBSymbol: string = 'STETH';
119
+
120
+ const tokenAAmount: string = '1000000000000000000';
121
+ const tokenBAmount: string = '1000000000000000000';
122
+
123
+ testForNetwork(
124
+ network,
125
+ dexKey,
126
+ tokenASymbol,
127
+ tokenBSymbol,
128
+ tokenAAmount,
129
+ tokenBAmount,
130
+ );
131
+ });
132
+ describe('Mainnet SBTC2 pool', () => {
133
+ const network = Network.MAINNET;
134
+
135
+ const tokenASymbol: string = 'WBTC';
136
+ const tokenBSymbol: string = 'sBTC';
137
+
138
+ const tokenAAmount: string = '1000000000';
139
+ const tokenBAmount: string = '1000000000';
140
+
141
+ testForNetwork(
142
+ network,
143
+ dexKey,
144
+ tokenASymbol,
145
+ tokenBSymbol,
146
+ tokenAAmount,
147
+ tokenBAmount,
148
+ );
149
+ });
114
150
  describe('Polygon', () => {
115
151
  const network = Network.POLYGON;
116
152
 
@@ -274,6 +274,7 @@ export class CurveV1Factory
274
274
  isLending,
275
275
  customPool.balancesInputType,
276
276
  useLending,
277
+ customPool.useForPricing,
277
278
  );
278
279
  } else {
279
280
  // Use for pricing pools from factory
@@ -580,6 +581,8 @@ export class CurveV1Factory
580
581
  factoryImplementationConstants,
581
582
  factoryImplementationConstants.isFeeOnTransferSupported,
582
583
  basePoolStateFetcher,
584
+ factoryImplementationFromConfig.customGasCost,
585
+ factoryImplementationFromConfig.isStoreRateSupported,
583
586
  );
584
587
 
585
588
  this.poolManager.initializeNewPool(poolIdentifier, newPool);
@@ -52,22 +52,21 @@ const customPlain3CoinThree: _calc_withdraw_one_coin = (
52
52
  return [dy, dy_0 - dy, undefined];
53
53
  };
54
54
 
55
- const customArbitrum2CoinBtc: _calc_withdraw_one_coin = (
55
+ const _genericCustomArbitrum2CoinBtc = (
56
56
  self: IPoolContext,
57
57
  state: PoolState,
58
58
  _token_amount: bigint,
59
59
  i: number,
60
- ) => {
60
+ rates: bigint[],
61
+ ): [bigint, bigint, undefined] => {
61
62
  const { N_COINS, BI_N_COINS, FEE_DENOMINATOR, PRECISION } = self.constants;
63
+
62
64
  if (state.totalSupply === undefined) {
63
65
  throw new Error(
64
- `${self.IMPLEMENTATION_NAME} customArbitrum2CoinBtc: totalSupply is not provided`,
66
+ `${self.IMPLEMENTATION_NAME} _genericCustomArbitrum2CoinBtc: totalSupply is not provided`,
65
67
  );
66
68
  }
67
-
68
69
  const amp = state.A;
69
- const rates = [...state.constants.rate_multipliers];
70
-
71
70
  const xp = self._xp_mem(self, rates, state.balances);
72
71
  const D0 = self.get_D(self, xp, amp);
73
72
 
@@ -96,6 +95,46 @@ const customArbitrum2CoinBtc: _calc_withdraw_one_coin = (
96
95
  return [dy, dy_0 - dy, undefined];
97
96
  };
98
97
 
98
+ const customArbitrum2CoinBtc: _calc_withdraw_one_coin = (
99
+ self: IPoolContext,
100
+ state: PoolState,
101
+ _token_amount: bigint,
102
+ i: number,
103
+ ) => {
104
+ const rates = [...state.constants.rate_multipliers];
105
+ return _genericCustomArbitrum2CoinBtc(self, state, _token_amount, i, rates);
106
+ };
107
+
108
+ const factoryPlain2EthEma2: _calc_withdraw_one_coin = (
109
+ self: IPoolContext,
110
+ state: PoolState,
111
+ _token_amount: bigint,
112
+ i: number,
113
+ ) => {
114
+ if (state.storedRates === undefined) {
115
+ throw new Error(
116
+ `${self.IMPLEMENTATION_NAME} factoryPlain2EthEma2: storedRates is not provided`,
117
+ );
118
+ }
119
+ const rates = [...state.storedRates];
120
+ return _genericCustomArbitrum2CoinBtc(self, state, _token_amount, i, rates);
121
+ };
122
+
123
+ const factoryMetaBtcSbtc2: _calc_withdraw_one_coin = (
124
+ self: IPoolContext,
125
+ state: PoolState,
126
+ _token_amount: bigint,
127
+ i: number,
128
+ ) => {
129
+ if (state.virtualPrice === undefined) {
130
+ throw new Error(
131
+ `${self.IMPLEMENTATION_NAME} factoryMetaBtcSbtc2: virtualPrice is not provided`,
132
+ );
133
+ }
134
+ const rates = [state.constants.rate_multipliers[0], state.virtualPrice];
135
+ return _genericCustomArbitrum2CoinBtc(self, state, _token_amount, i, rates);
136
+ };
137
+
99
138
  const customAvalanche3CoinLending: _calc_withdraw_one_coin = (
100
139
  self: IPoolContext,
101
140
  state: PoolState,
@@ -187,6 +226,7 @@ const notImplemented: _calc_withdraw_one_coin = (
187
226
  const implementations: Record<ImplementationNames, _calc_withdraw_one_coin> = {
188
227
  [ImplementationNames.CUSTOM_PLAIN_2COIN_FRAX]: customPlain3CoinThree,
189
228
  [ImplementationNames.CUSTOM_PLAIN_2COIN_RENBTC]: customPlain3CoinThree,
229
+ [ImplementationNames.CUSTOM_PLAIN_2COIN_WBTC]: customFantom2CoinBtc,
190
230
  [ImplementationNames.CUSTOM_PLAIN_3COIN_SBTC]: customPlain3CoinThree,
191
231
  [ImplementationNames.CUSTOM_PLAIN_3COIN_THREE]: customPlain3CoinThree,
192
232
 
@@ -237,6 +277,13 @@ const implementations: Record<ImplementationNames, _calc_withdraw_one_coin> = {
237
277
  [ImplementationNames.FACTORY_PLAIN_4_BASIC]: notImplemented,
238
278
  [ImplementationNames.FACTORY_PLAIN_4_ETH]: notImplemented,
239
279
  [ImplementationNames.FACTORY_PLAIN_4_OPTIMIZED]: notImplemented,
280
+
281
+ [ImplementationNames.FACTORY_META_BTC_SBTC2]: factoryMetaBtcSbtc2,
282
+ [ImplementationNames.FACTORY_META_BTC_BALANCES_SBTC2]: factoryMetaBtcSbtc2,
283
+ // Keep in mind: these 2 are not 100% correct, because I don't calculate last "last_p" entry, because it doesn't affect pricing
284
+ [ImplementationNames.FACTORY_PLAIN_2_BASIC_EMA]: customArbitrum2CoinBtc,
285
+ [ImplementationNames.FACTORY_PLAIN_2_ETH_EMA]: customArbitrum2CoinBtc,
286
+ [ImplementationNames.FACTORY_PLAIN_2_ETH_EMA2]: factoryPlain2EthEma2,
240
287
  };
241
288
 
242
289
  export default implementations;
@@ -36,6 +36,7 @@ const notExist: _dynamic_fee = (
36
36
  const implementations: Record<ImplementationNames, _dynamic_fee> = {
37
37
  [ImplementationNames.CUSTOM_PLAIN_2COIN_FRAX]: notExist,
38
38
  [ImplementationNames.CUSTOM_PLAIN_2COIN_RENBTC]: notExist,
39
+ [ImplementationNames.CUSTOM_PLAIN_2COIN_WBTC]: notExist,
39
40
  [ImplementationNames.CUSTOM_PLAIN_3COIN_SBTC]: notExist,
40
41
  [ImplementationNames.CUSTOM_PLAIN_3COIN_THREE]: notExist,
41
42
 
@@ -86,6 +87,12 @@ const implementations: Record<ImplementationNames, _dynamic_fee> = {
86
87
  [ImplementationNames.FACTORY_PLAIN_4_BASIC]: notExist,
87
88
  [ImplementationNames.FACTORY_PLAIN_4_ETH]: notExist,
88
89
  [ImplementationNames.FACTORY_PLAIN_4_OPTIMIZED]: notExist,
90
+
91
+ [ImplementationNames.FACTORY_META_BTC_SBTC2]: notExist,
92
+ [ImplementationNames.FACTORY_META_BTC_BALANCES_SBTC2]: notExist,
93
+ [ImplementationNames.FACTORY_PLAIN_2_BASIC_EMA]: notExist,
94
+ [ImplementationNames.FACTORY_PLAIN_2_ETH_EMA]: notExist,
95
+ [ImplementationNames.FACTORY_PLAIN_2_ETH_EMA2]: notExist,
89
96
  };
90
97
 
91
98
  export default implementations;
@@ -55,6 +55,7 @@ const notExist: _rates = (self: IPoolContext, state: PoolState) => {
55
55
  const implementations: Record<ImplementationNames, _rates> = {
56
56
  [ImplementationNames.CUSTOM_PLAIN_2COIN_FRAX]: notExist,
57
57
  [ImplementationNames.CUSTOM_PLAIN_2COIN_RENBTC]: customPlain3CoinSbtc,
58
+ [ImplementationNames.CUSTOM_PLAIN_2COIN_WBTC]: notExist,
58
59
  [ImplementationNames.CUSTOM_PLAIN_3COIN_SBTC]: customPlain3CoinSbtc,
59
60
  [ImplementationNames.CUSTOM_PLAIN_3COIN_THREE]: notExist,
60
61
 
@@ -101,6 +102,12 @@ const implementations: Record<ImplementationNames, _rates> = {
101
102
  [ImplementationNames.FACTORY_PLAIN_4_BASIC]: notExist,
102
103
  [ImplementationNames.FACTORY_PLAIN_4_ETH]: notExist,
103
104
  [ImplementationNames.FACTORY_PLAIN_4_OPTIMIZED]: notExist,
105
+
106
+ [ImplementationNames.FACTORY_META_BTC_SBTC2]: notExist,
107
+ [ImplementationNames.FACTORY_META_BTC_BALANCES_SBTC2]: notExist,
108
+ [ImplementationNames.FACTORY_PLAIN_2_BASIC_EMA]: notExist,
109
+ [ImplementationNames.FACTORY_PLAIN_2_ETH_EMA]: notExist,
110
+ [ImplementationNames.FACTORY_PLAIN_2_ETH_EMA2]: notExist,
104
111
  };
105
112
 
106
113
  export default implementations;
@@ -53,6 +53,7 @@ const notExist: _xp = (self: IPoolContext, state: PoolState) => {
53
53
  const implementations: Record<ImplementationNames, _xp> = {
54
54
  [ImplementationNames.CUSTOM_PLAIN_2COIN_FRAX]: customPlain2CoinFrax,
55
55
  [ImplementationNames.CUSTOM_PLAIN_2COIN_RENBTC]: customPlain3CoinSbtc,
56
+ [ImplementationNames.CUSTOM_PLAIN_2COIN_WBTC]: customPlain2CoinFrax,
56
57
  [ImplementationNames.CUSTOM_PLAIN_3COIN_SBTC]: customPlain3CoinSbtc,
57
58
  [ImplementationNames.CUSTOM_PLAIN_3COIN_THREE]: customPlain3CoinThree,
58
59
 
@@ -99,6 +100,12 @@ const implementations: Record<ImplementationNames, _xp> = {
99
100
  [ImplementationNames.FACTORY_PLAIN_4_BASIC]: notExist,
100
101
  [ImplementationNames.FACTORY_PLAIN_4_ETH]: notExist,
101
102
  [ImplementationNames.FACTORY_PLAIN_4_OPTIMIZED]: notExist,
103
+
104
+ [ImplementationNames.FACTORY_META_BTC_SBTC2]: notExist,
105
+ [ImplementationNames.FACTORY_META_BTC_BALANCES_SBTC2]: notExist,
106
+ [ImplementationNames.FACTORY_PLAIN_2_BASIC_EMA]: notExist,
107
+ [ImplementationNames.FACTORY_PLAIN_2_ETH_EMA]: notExist,
108
+ [ImplementationNames.FACTORY_PLAIN_2_ETH_EMA2]: notExist,
102
109
  };
103
110
 
104
111
  export default implementations;
@@ -42,6 +42,7 @@ const notExist: _xp_mem = (
42
42
  const implementations: Record<ImplementationNames, _xp_mem> = {
43
43
  [ImplementationNames.CUSTOM_PLAIN_2COIN_FRAX]: customPlain3CoinThree,
44
44
  [ImplementationNames.CUSTOM_PLAIN_2COIN_RENBTC]: factoryPlain2Basic,
45
+ [ImplementationNames.CUSTOM_PLAIN_2COIN_WBTC]: customPlain3CoinThree,
45
46
  [ImplementationNames.CUSTOM_PLAIN_3COIN_SBTC]: factoryPlain2Basic,
46
47
  [ImplementationNames.CUSTOM_PLAIN_3COIN_THREE]: customPlain3CoinThree,
47
48
 
@@ -88,6 +89,12 @@ const implementations: Record<ImplementationNames, _xp_mem> = {
88
89
  [ImplementationNames.FACTORY_PLAIN_4_OPTIMIZED]: factoryPlain2Basic,
89
90
  [ImplementationNames.FACTORY_PLAIN_4_BALANCES]: factoryPlain2Basic,
90
91
  [ImplementationNames.FACTORY_PLAIN_4_ETH]: factoryPlain2Basic,
92
+
93
+ [ImplementationNames.FACTORY_META_BTC_SBTC2]: factoryPlain2Basic,
94
+ [ImplementationNames.FACTORY_META_BTC_BALANCES_SBTC2]: factoryPlain2Basic,
95
+ [ImplementationNames.FACTORY_PLAIN_2_BASIC_EMA]: factoryPlain2Basic,
96
+ [ImplementationNames.FACTORY_PLAIN_2_ETH_EMA]: factoryPlain2Basic,
97
+ [ImplementationNames.FACTORY_PLAIN_2_ETH_EMA2]: factoryPlain2Basic,
91
98
  };
92
99
 
93
100
  export default implementations;
@@ -76,6 +76,7 @@ const notImplemented: calc_token_amount = (
76
76
  const implementations: Record<ImplementationNames, calc_token_amount> = {
77
77
  [ImplementationNames.CUSTOM_PLAIN_2COIN_FRAX]: customPlain3CoinThree,
78
78
  [ImplementationNames.CUSTOM_PLAIN_2COIN_RENBTC]: customPlain3CoinThree,
79
+ [ImplementationNames.CUSTOM_PLAIN_2COIN_WBTC]: customPlain3CoinThree,
79
80
  [ImplementationNames.CUSTOM_PLAIN_3COIN_SBTC]: customPlain3CoinThree,
80
81
  [ImplementationNames.CUSTOM_PLAIN_3COIN_THREE]: customPlain3CoinThree,
81
82
 
@@ -126,6 +127,12 @@ const implementations: Record<ImplementationNames, calc_token_amount> = {
126
127
  [ImplementationNames.FACTORY_PLAIN_4_BASIC]: notImplemented,
127
128
  [ImplementationNames.FACTORY_PLAIN_4_ETH]: notImplemented,
128
129
  [ImplementationNames.FACTORY_PLAIN_4_OPTIMIZED]: notImplemented,
130
+
131
+ [ImplementationNames.FACTORY_META_BTC_SBTC2]: customPlain3CoinThree,
132
+ [ImplementationNames.FACTORY_META_BTC_BALANCES_SBTC2]: customPlain3CoinThree,
133
+ [ImplementationNames.FACTORY_PLAIN_2_BASIC_EMA]: customPlain3CoinThree,
134
+ [ImplementationNames.FACTORY_PLAIN_2_ETH_EMA]: customPlain3CoinThree,
135
+ [ImplementationNames.FACTORY_PLAIN_2_ETH_EMA2]: customPlain3CoinThree,
129
136
  };
130
137
 
131
138
  export default implementations;
@@ -29,6 +29,7 @@ export const implementations: Record<
29
29
  > = {
30
30
  [ImplementationNames.CUSTOM_PLAIN_2COIN_FRAX]: customPlain3CoinThree,
31
31
  [ImplementationNames.CUSTOM_PLAIN_2COIN_RENBTC]: customPlain3CoinThree,
32
+ [ImplementationNames.CUSTOM_PLAIN_2COIN_WBTC]: customPlain3CoinThree,
32
33
  [ImplementationNames.CUSTOM_PLAIN_3COIN_SBTC]: customPlain3CoinThree,
33
34
  [ImplementationNames.CUSTOM_PLAIN_3COIN_THREE]: customPlain3CoinThree,
34
35
 
@@ -75,6 +76,12 @@ export const implementations: Record<
75
76
  [ImplementationNames.FACTORY_PLAIN_4_BASIC]: notImplemented,
76
77
  [ImplementationNames.FACTORY_PLAIN_4_ETH]: notImplemented,
77
78
  [ImplementationNames.FACTORY_PLAIN_4_OPTIMIZED]: notImplemented,
79
+
80
+ [ImplementationNames.FACTORY_META_BTC_SBTC2]: customPlain3CoinThree,
81
+ [ImplementationNames.FACTORY_META_BTC_BALANCES_SBTC2]: customPlain3CoinThree,
82
+ [ImplementationNames.FACTORY_PLAIN_2_BASIC_EMA]: customPlain3CoinThree,
83
+ [ImplementationNames.FACTORY_PLAIN_2_ETH_EMA]: customPlain3CoinThree,
84
+ [ImplementationNames.FACTORY_PLAIN_2_ETH_EMA2]: customPlain3CoinThree,
78
85
  };
79
86
 
80
87
  export default implementations;
@@ -1,5 +1,6 @@
1
1
  import {} from 'ts-essentials';
2
2
  import { BI_POWS } from '../../../../bigint-constants';
3
+ import { PRECISION } from '../../../kyberdmm/fee-formula';
3
4
  import { ImplementationNames, PoolContextConstants } from '../../types';
4
5
 
5
6
  const implementationConstants: Record<
@@ -35,6 +36,21 @@ const implementationConstants: Record<
35
36
  LENDING_PRECISION: BI_POWS[18],
36
37
  USE_LENDING: [true, false],
37
38
  },
39
+ [ImplementationNames.CUSTOM_PLAIN_2COIN_WBTC]: {
40
+ isWrapNative: false,
41
+ isFeeOnTransferSupported: false,
42
+ isLending: false,
43
+
44
+ N_COINS: 2,
45
+ BI_N_COINS: 2n,
46
+
47
+ FEE_DENOMINATOR: BI_POWS[10],
48
+ PRECISION: BI_POWS[18],
49
+
50
+ PRECISION_MUL: [10000000000n, 1n],
51
+ RATES: [10000000000000000000000000000n, 1000000000000000000n],
52
+ A_PRECISION: 100n,
53
+ },
38
54
  [ImplementationNames.CUSTOM_PLAIN_3COIN_SBTC]: {
39
55
  isWrapNative: false,
40
56
  isFeeOnTransferSupported: false,
@@ -501,6 +517,68 @@ const implementationConstants: Record<
501
517
 
502
518
  A_PRECISION: 100n,
503
519
  },
520
+
521
+ [ImplementationNames.FACTORY_META_BTC_SBTC2]: {
522
+ isWrapNative: false,
523
+ isFeeOnTransferSupported: false,
524
+ isLending: false,
525
+
526
+ N_COINS: 2,
527
+ BI_N_COINS: 2n,
528
+ MAX_COIN: 2 - 1,
529
+
530
+ BASE_N_COINS: 2,
531
+ PRECISION: BI_POWS[18],
532
+ FEE_DENOMINATOR: BI_POWS[10],
533
+ A_PRECISION: 100n,
534
+ },
535
+ [ImplementationNames.FACTORY_META_BTC_BALANCES_SBTC2]: {
536
+ isWrapNative: false,
537
+ isFeeOnTransferSupported: true,
538
+ isLending: false,
539
+
540
+ N_COINS: 2,
541
+ BI_N_COINS: 2n,
542
+ MAX_COIN: 2 - 1,
543
+
544
+ BASE_N_COINS: 2,
545
+ PRECISION: BI_POWS[18],
546
+ FEE_DENOMINATOR: BI_POWS[10],
547
+ A_PRECISION: 100n,
548
+ },
549
+ [ImplementationNames.FACTORY_PLAIN_2_BASIC_EMA]: {
550
+ isWrapNative: false,
551
+ isFeeOnTransferSupported: false,
552
+ isLending: false,
553
+
554
+ N_COINS: 2,
555
+ BI_N_COINS: 2n,
556
+ PRECISION: BI_POWS[18],
557
+ FEE_DENOMINATOR: BI_POWS[10],
558
+ A_PRECISION: 100n,
559
+ },
560
+ [ImplementationNames.FACTORY_PLAIN_2_ETH_EMA]: {
561
+ isWrapNative: false,
562
+ isFeeOnTransferSupported: false,
563
+ isLending: false,
564
+
565
+ N_COINS: 2,
566
+ BI_N_COINS: 2n,
567
+ PRECISION: BI_POWS[18],
568
+ FEE_DENOMINATOR: BI_POWS[10],
569
+ A_PRECISION: 100n,
570
+ },
571
+ [ImplementationNames.FACTORY_PLAIN_2_ETH_EMA2]: {
572
+ isWrapNative: false,
573
+ isFeeOnTransferSupported: false,
574
+ isLending: false,
575
+
576
+ N_COINS: 2,
577
+ BI_N_COINS: 2n,
578
+ PRECISION: BI_POWS[18],
579
+ FEE_DENOMINATOR: BI_POWS[10],
580
+ A_PRECISION: 100n,
581
+ },
504
582
  };
505
583
 
506
584
  export default implementationConstants;
@@ -225,6 +225,8 @@ const implementations: Record<ImplementationNames, get_D> = {
225
225
  [ImplementationNames.CUSTOM_PLAIN_2COIN_RENBTC]: makeFuncCacheable(
226
226
  customPlain3CoinThree,
227
227
  ),
228
+ [ImplementationNames.CUSTOM_PLAIN_2COIN_WBTC]:
229
+ makeFuncCacheable(customPlain2CoinFrax),
228
230
  [ImplementationNames.CUSTOM_PLAIN_3COIN_SBTC]: makeFuncCacheable(
229
231
  customPlain3CoinThree,
230
232
  ),
@@ -308,6 +310,17 @@ const implementations: Record<ImplementationNames, get_D> = {
308
310
  makeFuncCacheable(customPlain2CoinFrax),
309
311
  [ImplementationNames.FACTORY_PLAIN_4_OPTIMIZED]:
310
312
  makeFuncCacheable(customPlain2CoinFrax),
313
+
314
+ [ImplementationNames.FACTORY_META_BTC_SBTC2]:
315
+ makeFuncCacheable(customPlain2CoinFrax),
316
+ [ImplementationNames.FACTORY_META_BTC_BALANCES_SBTC2]:
317
+ makeFuncCacheable(customPlain2CoinFrax),
318
+ [ImplementationNames.FACTORY_PLAIN_2_BASIC_EMA]:
319
+ makeFuncCacheable(factoryPlain2Basic),
320
+ [ImplementationNames.FACTORY_PLAIN_2_ETH_EMA]:
321
+ makeFuncCacheable(factoryPlain2Basic),
322
+ [ImplementationNames.FACTORY_PLAIN_2_ETH_EMA2]:
323
+ makeFuncCacheable(factoryPlain2Basic),
311
324
  };
312
325
 
313
326
  export default implementations;