@wardenswap/bestrate-sdk-beta 2.10.0 → 2.12.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.
package/dist/index.d.ts CHANGED
@@ -8,7 +8,8 @@ declare enum BESTRATE_NETWORK {
8
8
  polygon = "polygon",
9
9
  ethereum = "ethereum",
10
10
  avalanche = "avalanche",
11
- optimism = "optimism"
11
+ optimism = "optimism",
12
+ base = "base"
12
13
  }
13
14
  type TokenInfo = {
14
15
  address: string;
@@ -292,46 +293,71 @@ interface Multicall2 extends BaseContract {
292
293
  };
293
294
  }
294
295
 
296
+ type Params = {
297
+ alpha: bigint;
298
+ beta: bigint;
299
+ c: bigint;
300
+ s: bigint;
301
+ lambda: bigint;
302
+ };
303
+ type DerivedParams = {
304
+ tauAlpha: Vector2;
305
+ tauBeta: Vector2;
306
+ u: bigint;
307
+ v: bigint;
308
+ w: bigint;
309
+ z: bigint;
310
+ dSq: bigint;
311
+ };
312
+ type Vector2 = {
313
+ x: bigint;
314
+ y: bigint;
315
+ };
316
+
295
317
  declare enum DexModel {
296
318
  UniswapV2 = 0,
297
319
  UniswapV3 = 1,
298
320
  PancakeV3 = 2,
299
321
  VelodromeSS = 3,
300
322
  AlgebraV1CL = 4,
301
- DMM = 5,
302
- CurvePlain = 6,
303
- CurveMeta = 7,
304
- CurvePlainSol = 8,
305
- Iron = 9,
306
- Synapse = 10,
307
- CurveMetaSol = 11,
308
- CurveCrypto = 12,
309
- CurveTriCryptoNG = 13,
310
- CurveStableNG = 14,
311
- CurveLendingA = 15,
312
- CurveLendingCryptoZap = 16,
313
- CurveLendingCryptoTwoZap = 17,
314
- CurveLido = 18,
315
- PolyDex = 19,
316
- FireBirdWeighted = 20,
317
- BalancerWeighted = 21,
318
- BalancerStable = 22,
319
- BalancerMetaStable = 23,
320
- BalancerBoostedStable = 24,
321
- BalancerLinear = 25,
322
- BalancerLiquidityBootstrapping = 26,
323
- Biswap = 27,
324
- DodoV1 = 28,
325
- DodoV2 = 29,
326
- Mdex = 30,
327
- Mars = 31,
328
- Smoothy = 32,
329
- Shibaswap = 33,
330
- GmxDex = 34,
331
- Solidly = 35,
332
- VelodromeV2 = 36,
333
- Synthetix = 37,
334
- Unknown = 38
323
+ SolidlyV3 = 5,
324
+ DMM = 6,
325
+ CurvePlain = 7,
326
+ CurveMeta = 8,
327
+ CurvePlainSol = 9,
328
+ Iron = 10,
329
+ Synapse = 11,
330
+ CurveMetaSol = 12,
331
+ CurveCrypto = 13,
332
+ CurveTriCryptoNG = 14,
333
+ CurveStableNG = 15,
334
+ CurveLendingA = 16,
335
+ CurveLendingCryptoZap = 17,
336
+ CurveLendingCryptoTwoZap = 18,
337
+ CurveLido = 19,
338
+ PolyDex = 20,
339
+ FireBirdWeighted = 21,
340
+ BalancerWeighted = 22,
341
+ BalancerStable = 23,
342
+ BalancerComposableStableV6 = 24,
343
+ BalancerWeightedV4 = 25,
344
+ BalancerGyroECLP = 26,
345
+ BalancerMetaStable = 27,
346
+ BalancerBoostedStable = 28,
347
+ BalancerLinear = 29,
348
+ BalancerLiquidityBootstrapping = 30,
349
+ Biswap = 31,
350
+ DodoV1 = 32,
351
+ DodoV2 = 33,
352
+ Mdex = 34,
353
+ Mars = 35,
354
+ Smoothy = 36,
355
+ Shibaswap = 37,
356
+ GmxDex = 38,
357
+ Solidly = 39,
358
+ VelodromeV2 = 40,
359
+ Synthetix = 41,
360
+ Unknown = 42
335
361
  }
336
362
  interface UniswapV2BasedModelInfo {
337
363
  model: DexModel.UniswapV2 | DexModel.Mdex | DexModel.Biswap | DexModel.Mars | DexModel.Shibaswap;
@@ -348,6 +374,10 @@ interface UniswapV3ModelInfo extends Omit<UniswapV2BasedModelInfo, 'model' | 'fe
348
374
  gasPerInitializedTick: bigint;
349
375
  gasPerTick: bigint;
350
376
  }
377
+ interface SolidlyV3ModelInfo extends Omit<UniswapV3ModelInfo, 'model' | 'fee'> {
378
+ model: DexModel.SolidlyV3;
379
+ tickSpacing: bigint;
380
+ }
351
381
  interface AlgebraV1CLModelInfo extends Omit<UniswapV3ModelInfo, 'model' | 'fee' | 'feePrecision' | 'factory'> {
352
382
  model: DexModel.AlgebraV1CL;
353
383
  poolDeployer: string;
@@ -456,8 +486,14 @@ interface BalancerWeightedModelInfo extends Omit<BalancerStableModelInfo, 'model
456
486
  interface BalancerStableModelInfo {
457
487
  model: DexModel.BalancerStable;
458
488
  tokens: string[];
489
+ /**
490
+ * Calculated from 1e18 * 10^(18-decimals)
491
+ */
459
492
  scalingFactors: bigint[];
460
493
  vaultContract: string;
494
+ /**
495
+ * Get from getPoolId() of pool contract
496
+ */
461
497
  poolId: string;
462
498
  aPrecision: bigint;
463
499
  depositAddress: string;
@@ -484,6 +520,43 @@ interface BalancerMetaStableModelInfo extends Omit<BalancerStableModelInfo, 'mod
484
520
  rateProviders: string[];
485
521
  multicall: string;
486
522
  }
523
+ interface BalancerComposableStableModelInfo extends Omit<BalancerStableModelInfo, 'model' | 'aPrecision'> {
524
+ model: DexModel.BalancerComposableStableV6;
525
+ /**
526
+ * BPT token index
527
+ * Get from getBptIndex() at pool contract
528
+ */
529
+ bptIndex: number;
530
+ /**
531
+ * Rate providers, zero means no providers
532
+ * Get from getRateProviders() at pool contract
533
+ */
534
+ rateProviders: string[];
535
+ multicall: string;
536
+ /**
537
+ * A flag whether exempt from yield protocol fee
538
+ * Get from isExemptFromYieldProtocolFee() at pool contract
539
+ */
540
+ isExemptFromYieldProtocolFee: boolean;
541
+ /**
542
+ * A flag whether protocol swap fee delegation
543
+ * Get from getProtocolSwapFeeDelegation() at pool contract
544
+ */
545
+ isProtocolSwapFeeDelegation: boolean;
546
+ /**
547
+ * Maximum protocol's swap fee percentage
548
+ * Get from _MAX_PROTOCOL_SWAP_FEE_PERCENTAGE at ComposableStablePoolFactory.getProtocolFeePercenragesProvider
549
+ */
550
+ maxProtocolSwapFeePercentage: bigint;
551
+ }
552
+ interface BalancerWeightedV4ModelInfo extends Omit<BalancerWeightedModelInfo, 'model'> {
553
+ model: DexModel.BalancerWeightedV4;
554
+ }
555
+ interface BalancerGyroECLPModelInfo extends Omit<BalancerWeightedModelInfo, 'model'> {
556
+ model: DexModel.BalancerGyroECLP;
557
+ params: Params;
558
+ derivedParams: DerivedParams;
559
+ }
487
560
  interface DodoV2ModelInfo {
488
561
  model: DexModel.DodoV2 | DexModel.DodoV1;
489
562
  factoryContract: string;
@@ -536,7 +609,7 @@ interface RouteInfo {
536
609
  type RouteInfoModel = RouteInfo & {
537
610
  gas: bigint;
538
611
  isTradingAllowed: boolean;
539
- } & (UniswapV2BasedModelInfo | UniswapV3ModelInfo | PancakeV3ModelInfo | VelodromeSSModelInfo | AlgebraV1CLModelInfo | CurvePlainModelInfo | CurvePlainNGModelInfo | CurveMetaModelInfo | CurveCryptoModelInfo | CurveCryptoNGModelInfo | CurveCryptoZapModelInfo | CurveCryptoTwoZapModelInfo | CurveLendingModelInfo | CurveLidoModelInfo | DodoV2ModelInfo | SmoothyModelInfo | DMMModelInfo | BalancerWeightedModelInfo | BalancerStableModelInfo | BalancerMetaStableModelInfo | BalancerBoostedStableModelInfo | BalancerLinearModelInfo | PolyDexModelInfo | GmxDexModelInfo | SolidlyModelInfo | VelodromeV2ModelInfo | SynthetixModelInfo | {
612
+ } & (UniswapV2BasedModelInfo | UniswapV3ModelInfo | PancakeV3ModelInfo | VelodromeSSModelInfo | AlgebraV1CLModelInfo | SolidlyV3ModelInfo | CurvePlainModelInfo | CurvePlainNGModelInfo | CurveMetaModelInfo | CurveCryptoModelInfo | CurveCryptoNGModelInfo | CurveCryptoZapModelInfo | CurveCryptoTwoZapModelInfo | CurveLendingModelInfo | CurveLidoModelInfo | DodoV2ModelInfo | SmoothyModelInfo | DMMModelInfo | BalancerWeightedModelInfo | BalancerStableModelInfo | BalancerMetaStableModelInfo | BalancerBoostedStableModelInfo | BalancerLinearModelInfo | BalancerComposableStableModelInfo | BalancerWeightedV4ModelInfo | BalancerGyroECLPModelInfo | PolyDexModelInfo | GmxDexModelInfo | SolidlyModelInfo | VelodromeV2ModelInfo | SynthetixModelInfo | {
540
613
  model: DexModel.Unknown;
541
614
  });
542
615
 
@@ -765,7 +838,7 @@ declare class WardenBestRate {
765
838
  * @param amountIn Amount of src asset to be traded
766
839
  * @param gasPrice Amount of gas price per unit in native currency (18 decimals)
767
840
  * e.g. BSC = BNB, Polygon = MATIC, Ethereum = ETH. For L2 chains,
768
- * this is Ethereum (L1) gas price.
841
+ * this is price per byte of data.
769
842
  * @param opts Options for getting quote
770
843
  * @returns Trading routes which provide the best rate
771
844
  */
@@ -8,7 +8,8 @@ declare enum BESTRATE_NETWORK {
8
8
  polygon = "polygon",
9
9
  ethereum = "ethereum",
10
10
  avalanche = "avalanche",
11
- optimism = "optimism"
11
+ optimism = "optimism",
12
+ base = "base"
12
13
  }
13
14
  type TokenInfo = {
14
15
  address: string;
@@ -292,46 +293,71 @@ interface Multicall2 extends BaseContract {
292
293
  };
293
294
  }
294
295
 
296
+ type Params = {
297
+ alpha: bigint;
298
+ beta: bigint;
299
+ c: bigint;
300
+ s: bigint;
301
+ lambda: bigint;
302
+ };
303
+ type DerivedParams = {
304
+ tauAlpha: Vector2;
305
+ tauBeta: Vector2;
306
+ u: bigint;
307
+ v: bigint;
308
+ w: bigint;
309
+ z: bigint;
310
+ dSq: bigint;
311
+ };
312
+ type Vector2 = {
313
+ x: bigint;
314
+ y: bigint;
315
+ };
316
+
295
317
  declare enum DexModel {
296
318
  UniswapV2 = 0,
297
319
  UniswapV3 = 1,
298
320
  PancakeV3 = 2,
299
321
  VelodromeSS = 3,
300
322
  AlgebraV1CL = 4,
301
- DMM = 5,
302
- CurvePlain = 6,
303
- CurveMeta = 7,
304
- CurvePlainSol = 8,
305
- Iron = 9,
306
- Synapse = 10,
307
- CurveMetaSol = 11,
308
- CurveCrypto = 12,
309
- CurveTriCryptoNG = 13,
310
- CurveStableNG = 14,
311
- CurveLendingA = 15,
312
- CurveLendingCryptoZap = 16,
313
- CurveLendingCryptoTwoZap = 17,
314
- CurveLido = 18,
315
- PolyDex = 19,
316
- FireBirdWeighted = 20,
317
- BalancerWeighted = 21,
318
- BalancerStable = 22,
319
- BalancerMetaStable = 23,
320
- BalancerBoostedStable = 24,
321
- BalancerLinear = 25,
322
- BalancerLiquidityBootstrapping = 26,
323
- Biswap = 27,
324
- DodoV1 = 28,
325
- DodoV2 = 29,
326
- Mdex = 30,
327
- Mars = 31,
328
- Smoothy = 32,
329
- Shibaswap = 33,
330
- GmxDex = 34,
331
- Solidly = 35,
332
- VelodromeV2 = 36,
333
- Synthetix = 37,
334
- Unknown = 38
323
+ SolidlyV3 = 5,
324
+ DMM = 6,
325
+ CurvePlain = 7,
326
+ CurveMeta = 8,
327
+ CurvePlainSol = 9,
328
+ Iron = 10,
329
+ Synapse = 11,
330
+ CurveMetaSol = 12,
331
+ CurveCrypto = 13,
332
+ CurveTriCryptoNG = 14,
333
+ CurveStableNG = 15,
334
+ CurveLendingA = 16,
335
+ CurveLendingCryptoZap = 17,
336
+ CurveLendingCryptoTwoZap = 18,
337
+ CurveLido = 19,
338
+ PolyDex = 20,
339
+ FireBirdWeighted = 21,
340
+ BalancerWeighted = 22,
341
+ BalancerStable = 23,
342
+ BalancerComposableStableV6 = 24,
343
+ BalancerWeightedV4 = 25,
344
+ BalancerGyroECLP = 26,
345
+ BalancerMetaStable = 27,
346
+ BalancerBoostedStable = 28,
347
+ BalancerLinear = 29,
348
+ BalancerLiquidityBootstrapping = 30,
349
+ Biswap = 31,
350
+ DodoV1 = 32,
351
+ DodoV2 = 33,
352
+ Mdex = 34,
353
+ Mars = 35,
354
+ Smoothy = 36,
355
+ Shibaswap = 37,
356
+ GmxDex = 38,
357
+ Solidly = 39,
358
+ VelodromeV2 = 40,
359
+ Synthetix = 41,
360
+ Unknown = 42
335
361
  }
336
362
  interface UniswapV2BasedModelInfo {
337
363
  model: DexModel.UniswapV2 | DexModel.Mdex | DexModel.Biswap | DexModel.Mars | DexModel.Shibaswap;
@@ -348,6 +374,10 @@ interface UniswapV3ModelInfo extends Omit<UniswapV2BasedModelInfo, 'model' | 'fe
348
374
  gasPerInitializedTick: bigint;
349
375
  gasPerTick: bigint;
350
376
  }
377
+ interface SolidlyV3ModelInfo extends Omit<UniswapV3ModelInfo, 'model' | 'fee'> {
378
+ model: DexModel.SolidlyV3;
379
+ tickSpacing: bigint;
380
+ }
351
381
  interface AlgebraV1CLModelInfo extends Omit<UniswapV3ModelInfo, 'model' | 'fee' | 'feePrecision' | 'factory'> {
352
382
  model: DexModel.AlgebraV1CL;
353
383
  poolDeployer: string;
@@ -456,8 +486,14 @@ interface BalancerWeightedModelInfo extends Omit<BalancerStableModelInfo, 'model
456
486
  interface BalancerStableModelInfo {
457
487
  model: DexModel.BalancerStable;
458
488
  tokens: string[];
489
+ /**
490
+ * Calculated from 1e18 * 10^(18-decimals)
491
+ */
459
492
  scalingFactors: bigint[];
460
493
  vaultContract: string;
494
+ /**
495
+ * Get from getPoolId() of pool contract
496
+ */
461
497
  poolId: string;
462
498
  aPrecision: bigint;
463
499
  depositAddress: string;
@@ -484,6 +520,43 @@ interface BalancerMetaStableModelInfo extends Omit<BalancerStableModelInfo, 'mod
484
520
  rateProviders: string[];
485
521
  multicall: string;
486
522
  }
523
+ interface BalancerComposableStableModelInfo extends Omit<BalancerStableModelInfo, 'model' | 'aPrecision'> {
524
+ model: DexModel.BalancerComposableStableV6;
525
+ /**
526
+ * BPT token index
527
+ * Get from getBptIndex() at pool contract
528
+ */
529
+ bptIndex: number;
530
+ /**
531
+ * Rate providers, zero means no providers
532
+ * Get from getRateProviders() at pool contract
533
+ */
534
+ rateProviders: string[];
535
+ multicall: string;
536
+ /**
537
+ * A flag whether exempt from yield protocol fee
538
+ * Get from isExemptFromYieldProtocolFee() at pool contract
539
+ */
540
+ isExemptFromYieldProtocolFee: boolean;
541
+ /**
542
+ * A flag whether protocol swap fee delegation
543
+ * Get from getProtocolSwapFeeDelegation() at pool contract
544
+ */
545
+ isProtocolSwapFeeDelegation: boolean;
546
+ /**
547
+ * Maximum protocol's swap fee percentage
548
+ * Get from _MAX_PROTOCOL_SWAP_FEE_PERCENTAGE at ComposableStablePoolFactory.getProtocolFeePercenragesProvider
549
+ */
550
+ maxProtocolSwapFeePercentage: bigint;
551
+ }
552
+ interface BalancerWeightedV4ModelInfo extends Omit<BalancerWeightedModelInfo, 'model'> {
553
+ model: DexModel.BalancerWeightedV4;
554
+ }
555
+ interface BalancerGyroECLPModelInfo extends Omit<BalancerWeightedModelInfo, 'model'> {
556
+ model: DexModel.BalancerGyroECLP;
557
+ params: Params;
558
+ derivedParams: DerivedParams;
559
+ }
487
560
  interface DodoV2ModelInfo {
488
561
  model: DexModel.DodoV2 | DexModel.DodoV1;
489
562
  factoryContract: string;
@@ -536,7 +609,7 @@ interface RouteInfo {
536
609
  type RouteInfoModel = RouteInfo & {
537
610
  gas: bigint;
538
611
  isTradingAllowed: boolean;
539
- } & (UniswapV2BasedModelInfo | UniswapV3ModelInfo | PancakeV3ModelInfo | VelodromeSSModelInfo | AlgebraV1CLModelInfo | CurvePlainModelInfo | CurvePlainNGModelInfo | CurveMetaModelInfo | CurveCryptoModelInfo | CurveCryptoNGModelInfo | CurveCryptoZapModelInfo | CurveCryptoTwoZapModelInfo | CurveLendingModelInfo | CurveLidoModelInfo | DodoV2ModelInfo | SmoothyModelInfo | DMMModelInfo | BalancerWeightedModelInfo | BalancerStableModelInfo | BalancerMetaStableModelInfo | BalancerBoostedStableModelInfo | BalancerLinearModelInfo | PolyDexModelInfo | GmxDexModelInfo | SolidlyModelInfo | VelodromeV2ModelInfo | SynthetixModelInfo | {
612
+ } & (UniswapV2BasedModelInfo | UniswapV3ModelInfo | PancakeV3ModelInfo | VelodromeSSModelInfo | AlgebraV1CLModelInfo | SolidlyV3ModelInfo | CurvePlainModelInfo | CurvePlainNGModelInfo | CurveMetaModelInfo | CurveCryptoModelInfo | CurveCryptoNGModelInfo | CurveCryptoZapModelInfo | CurveCryptoTwoZapModelInfo | CurveLendingModelInfo | CurveLidoModelInfo | DodoV2ModelInfo | SmoothyModelInfo | DMMModelInfo | BalancerWeightedModelInfo | BalancerStableModelInfo | BalancerMetaStableModelInfo | BalancerBoostedStableModelInfo | BalancerLinearModelInfo | BalancerComposableStableModelInfo | BalancerWeightedV4ModelInfo | BalancerGyroECLPModelInfo | PolyDexModelInfo | GmxDexModelInfo | SolidlyModelInfo | VelodromeV2ModelInfo | SynthetixModelInfo | {
540
613
  model: DexModel.Unknown;
541
614
  });
542
615
 
@@ -765,7 +838,7 @@ declare class WardenBestRate {
765
838
  * @param amountIn Amount of src asset to be traded
766
839
  * @param gasPrice Amount of gas price per unit in native currency (18 decimals)
767
840
  * e.g. BSC = BNB, Polygon = MATIC, Ethereum = ETH. For L2 chains,
768
- * this is Ethereum (L1) gas price.
841
+ * this is price per byte of data.
769
842
  * @param opts Options for getting quote
770
843
  * @returns Trading routes which provide the best rate
771
844
  */