@bolt-liquidity-hq/core 0.1.0-beta.8 → 0.1.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.cts CHANGED
@@ -1,5 +1,6 @@
1
+ declare const DEFAULT_GAS_ADJUSTMENT = 1.5;
2
+
1
3
  type Address = string;
2
- type AssetPairString = string;
3
4
  type Timestamp = string;
4
5
  type Duration = {
5
6
  secs: number;
@@ -36,6 +37,7 @@ type ClientConfig<TChainConfig = ChainConfig> = {
36
37
  customOverride?: {
37
38
  chainConfig?: Partial<TChainConfig>;
38
39
  contracts?: Partial<Contracts>;
40
+ nativeTokenDenom?: string;
39
41
  assetsConfig?: AssetsConfig;
40
42
  };
41
43
  };
@@ -46,7 +48,8 @@ type OracleConfig = {
46
48
  priceExpireTime: Duration | null;
47
49
  };
48
50
  type Price = {
49
- assetPair: AssetPairString;
51
+ baseDenom: string;
52
+ quoteDenom: string;
50
53
  price: string;
51
54
  expiryTime: Timestamp;
52
55
  };
@@ -84,17 +87,18 @@ type RouterConfig = {
84
87
  defaultProtocolFeeRecipient: Address;
85
88
  defaultProtocolFee: string;
86
89
  defaultLpFee: string;
87
- settlementCodeId: number;
88
90
  };
89
91
  type Pool = {
90
92
  poolAddress: Address;
91
- baseAssetSymbol: string;
92
- quoteAssetsSymbols: string[];
93
+ baseDenom: string;
94
+ quoteDenoms: string[];
93
95
  };
94
- type SwapParams = {
96
+ type SwapRequiredParams = {
95
97
  assetIn: string;
96
98
  amountIn: string;
97
99
  assetOut: string;
100
+ };
101
+ type SwapParams = SwapRequiredParams & {
98
102
  minimumAmountOut?: string;
99
103
  receiver?: Address;
100
104
  };
@@ -104,6 +108,15 @@ type SwapResult<TTxOutput = unknown> = {
104
108
  assetOut: string;
105
109
  txHash: string;
106
110
  };
111
+ type SimulateSwapResult = {
112
+ poolAddress: Address;
113
+ amountOut: string;
114
+ assetOut: string;
115
+ protocolFee: string;
116
+ lpFee: string;
117
+ dynamicFeePercentage?: string;
118
+ totalFees: string;
119
+ };
107
120
 
108
121
  /**
109
122
  * Parses a coin string containing both amount and denomination into a structured Coin object.
@@ -187,6 +200,11 @@ declare abstract class BaseClient<TSigner = unknown, TTxOutput = unknown> {
187
200
  * Smart contract addresses for making Bolt queries and transactions in the blockchain
188
201
  */
189
202
  contracts: Contracts;
203
+ /**
204
+ * The denomination of the native token for the chain.
205
+ * This is used for gas fee calculations and native token operations.
206
+ */
207
+ nativeTokenDenom: string;
190
208
  /**
191
209
  * Configuration mapping of supported assets indexed by their symbol
192
210
  */
@@ -195,7 +213,7 @@ declare abstract class BaseClient<TSigner = unknown, TTxOutput = unknown> {
195
213
  * Creates a new instance of the BaseClient.
196
214
  *
197
215
  * @param config - (Optional) Configuration object for the client
198
- * @param config.customOverride - (Optional) Override configuration containing chain settings, contracts, and assets
216
+ * @param config.customOverride - (Optional) Override configuration containing chain settings, contracts, native token, and assets
199
217
  * @param config.customOverride.chainConfig - (Optional) Chain configuration object
200
218
  * @param config.customOverride.chainConfig.id - (Optional) The chain ID of the blockchain network (e.g., "archway-1")
201
219
  * @param config.customOverride.chainConfig.name - (Optional) The human-readable name of the chain (e.g., "Archway")
@@ -203,6 +221,7 @@ declare abstract class BaseClient<TSigner = unknown, TTxOutput = unknown> {
203
221
  * @param config.customOverride.contracts - (Optional) Contract addresses for oracle and router
204
222
  * @param config.customOverride.contracts.oracle - (Optional) Oracle contract address
205
223
  * @param config.customOverride.contracts.router - (Optional) Router contract address
224
+ * @param config.customOverride.nativeTokenDenom - (Optional) The denomination of the native token (e.g., "aarch", "0x2::sui::SUI")
206
225
  * @param config.customOverride.assetsConfig - (Optional) Configuration for supported assets indexed by symbol
207
226
  *
208
227
  * @throws {InvalidObjectError} Thrown when required configuration fields are missing
@@ -220,6 +239,7 @@ declare abstract class BaseClient<TSigner = unknown, TTxOutput = unknown> {
220
239
  * oracle: 'archway1oracle...',
221
240
  * router: 'archway1router...'
222
241
  * },
242
+ * nativeTokenDenom: 'uarch',
223
243
  * assetsConfig: {
224
244
  * 'ARCH': {
225
245
  * symbol: 'ARCH',
@@ -271,8 +291,8 @@ declare abstract class BaseClient<TSigner = unknown, TTxOutput = unknown> {
271
291
  /**
272
292
  * Fetches the current price for a specific base/quote asset pair from the oracle.
273
293
  *
274
- * @param baseAssetSymbol - The symbol of the base asset (e.g., "ARCH", "USDC")
275
- * @param quoteAssetSymbol - The symbol of the quote asset (e.g., "ARCH", "USDC")
294
+ * @param baseDenom - The denom of the base asset (e.g., "aarch", "ibc/...")
295
+ * @param quoteDenom - The denom of the quote asset (e.g., "aarch", "ibc/...")
276
296
  *
277
297
  * @returns A promise that resolves to an invertible price object containing
278
298
  * the current price from the oracle and whether it's inverted
@@ -280,12 +300,12 @@ declare abstract class BaseClient<TSigner = unknown, TTxOutput = unknown> {
280
300
  * @example
281
301
  * ```typescript
282
302
  * // Get price of ARCH in terms of USDC
283
- * const priceResult = await client.getPrice("ARCH", "USDC");
303
+ * const priceResult = await client.getPrice("aarch", "ibc/...");
284
304
  * console.log(`1 ARCH = ${priceResult.price} USDC`);
285
305
  * console.log(`Is inverted: ${priceResult.isInverse}`);
286
306
  * ```
287
307
  */
288
- abstract getPrice(baseAssetSymbol: string, quoteAssetSymbol: string): Promise<InvertiblePrice>;
308
+ abstract getPrice(baseDenom: string, quoteDenom: string): Promise<InvertiblePrice>;
289
309
  /**
290
310
  * Fetches all available prices from the oracle.
291
311
  *
@@ -296,8 +316,9 @@ declare abstract class BaseClient<TSigner = unknown, TTxOutput = unknown> {
296
316
  * ```typescript
297
317
  * const prices = await client.getAllPrices();
298
318
  * prices.forEach(priceData => {
299
- * console.log(`${priceData.assetPair}: ${priceData.price}`);
300
- * console.log(` Expires at: ${new Date(priceData.expiryTime * 1000).toISOString()}`);
319
+ * console.log(`${priceData.baseDenom}/${priceData.quoteDenom}: ${priceData.price}`);
320
+ * // expiryTime is a Unix timestamp in nanoseconds
321
+ * console.log(` Expires at: ${new Date(Number(priceData.expiryTime) / 1_000_000).toISOString()}`);
301
322
  * });
302
323
  * ```
303
324
  */
@@ -356,26 +377,40 @@ declare abstract class BaseClient<TSigner = unknown, TTxOutput = unknown> {
356
377
  */
357
378
  abstract getAllQuotesByUser(address: Address): Promise<Record<Address, Coin[]>>;
358
379
  /**
359
- * Fetches pool information for a specific base asset.
380
+ * Fetches pool information for a specific asset pair.
360
381
  *
361
- * @param baseAssetSymbol - The symbol of the base asset (e.g., "aarch", "ibc/...")
382
+ * This method retrieves pool information based on a base asset denomination,
383
+ * with an optional quote asset denomination to find a specific pool when
384
+ * multiple pools exist for the same base asset (this depends on the chain-specific
385
+ * implementation)
362
386
  *
363
- * @returns A promise that resolves to the pool information for the specified asset
387
+ * @param baseDenom - The denom of the base asset (e.g., "aarch", "ibc/...")
388
+ * @param quoteDenom - (Optional) The denom of the quote asset to find a specific pool
364
389
  *
365
- * @throws Will throw an error if no pool exists for the specified base asset
390
+ * @returns A promise that resolves to the pool information for the specified asset(s)
391
+ *
392
+ * @throws Will throw an error if no pool exists for the specified base asset,
393
+ * or if quoteDenom is provided but no matching pool is found
366
394
  *
367
395
  * @example
368
396
  * ```typescript
369
- * const pool = await client.getPoolByBaseAsset("aarch");
397
+ * // Get any pool for the base asset
398
+ * const pool = await client.getPoolByDenom("aarch");
370
399
  * console.log(`Pool address: ${pool.poolAddress}`);
371
- * console.log(`Base asset: ${pool.baseAssetSymbol}`);
400
+ * console.log(`Base asset: ${pool.baseDenom}`);
372
401
  * console.log('Available quote assets:');
373
- * pool.quoteAssetsSymbols.forEach(symbol => {
374
- * console.log(` - ${symbol}`);
402
+ * pool.quoteDenoms.forEach(denom => {
403
+ * console.log(` - ${denom}`);
375
404
  * });
405
+ *
406
+ * // Get pool for ARCH as base asset
407
+ * const specificPool = await client.getPoolByDenom(
408
+ * "aarch"
409
+ * );
410
+ * console.log(`Found pool: ${specificPool.poolAddress}`);
376
411
  * ```
377
412
  */
378
- abstract getPoolByBaseAsset(baseAssetSymbol: string): Promise<Pool>;
413
+ abstract getPoolByDenom(baseDenom: string, quoteDenom?: string): Promise<Pool>;
379
414
  /**
380
415
  * Fetches information for all available pools.
381
416
  *
@@ -386,8 +421,8 @@ declare abstract class BaseClient<TSigner = unknown, TTxOutput = unknown> {
386
421
  * const pools = await client.getAllPools();
387
422
  * pools.forEach(pool => {
388
423
  * console.log(`Pool ${pool.poolAddress}:`);
389
- * console.log(` Base: ${pool.baseAssetSymbol}`);
390
- * console.log(` Quotes: ${pool.quoteAssetsSymbols.join(', ')}`);
424
+ * console.log(` Base: ${pool.baseDenom}`);
425
+ * console.log(` Quotes: ${pool.quoteDenoms.join(', ')}`);
391
426
  * });
392
427
  * ```
393
428
  */
@@ -416,32 +451,58 @@ declare abstract class BaseClient<TSigner = unknown, TTxOutput = unknown> {
416
451
  */
417
452
  abstract getPoolConfig(poolContractAddress: string): Promise<PoolConfig>;
418
453
  /**
419
- * Fetches the configuration settings for a pool identified by its base asset symbol.
454
+ * Fetches the configuration settings for a pool identified by asset denominations.
420
455
  *
421
456
  * This is a convenience method that combines pool lookup and configuration retrieval.
422
- * It first finds the pool associated with the given base asset, then fetches that
423
- * pool's configuration parameters from its settlement contract.
457
+ * It first finds the pool associated with the given asset pair, then fetches that
458
+ * pool's configuration parameters.
424
459
  *
425
- * @param baseAssetSymbol - The symbol of the base asset (e.g., "aarch", "ibc/...")
460
+ * @param baseDenom - The denom of the base asset (e.g., "aarch", "ibc/...")
461
+ * @param quoteDenom - (Optional) The denom of the quote asset to find a specific pool
426
462
  *
427
463
  * @returns A promise that resolves to a pool configuration object containing
428
464
  * settings such as fees, oracle address, LP addresses, and minimum trade amounts
429
465
  *
430
- * @throws Will throw an error if no pool exists for the specified base asset
466
+ * @throws Will throw an error if no pool exists for the specified asset(s)
431
467
  *
432
468
  * @example
433
469
  * ```typescript
434
- * // Get pool configuration for ARCH base asset
435
- * const poolConfig = await client.getPoolConfigByBaseAsset("aarch");
470
+ * // Get pool configuration for any ARCH pool
471
+ * const poolConfig = await client.getPoolConfigByDenom("aarch");
436
472
  * console.log(`Oracle: ${poolConfig.priceOracleContract}`);
437
473
  * console.log(`Protocol fee: ${parseFloat(poolConfig.protocolFee) * 100}%`);
438
474
  * console.log(`LP fee: ${parseFloat(poolConfig.lpFee) * 100}%`);
439
475
  * console.log(`Allowance mode: ${poolConfig.allowanceMode}`);
440
476
  * console.log(`Number of LPs: ${poolConfig.lps.length}`);
441
477
  * console.log(`Min base output: ${poolConfig.minBaseOut}`);
478
+ *
479
+ * // Get configuration for specific ARCH/USDC pool
480
+ * const specificConfig = await client.getPoolConfigByDenom(
481
+ * "aarch",
482
+ * "ibc/43897B9739BD63E3A08A88191999C632E052724AB96BD4C74AE31375C991F48D"
483
+ * );
484
+ * console.log(`Specific pool fees: ${specificConfig.protocolFee}`);
442
485
  * ```
443
486
  */
444
- abstract getPoolConfigByBaseAsset(baseAssetSymbol: string): Promise<PoolConfig>;
487
+ abstract getPoolConfigByDenom(baseDenom: string, quoteDenom?: string): Promise<PoolConfig>;
488
+ /**
489
+ * Fetches the base liquidity details for a specific pool.
490
+ *
491
+ * @param poolContractAddress - The blockchain address of the pool contract
492
+ *
493
+ * @returns A promise that resolves to the base liquidity details for the pool
494
+ *
495
+ * @throws Will throw an error if no pool exists for the specified asset(s)
496
+ *
497
+ * @example
498
+ * ```typescript
499
+ * // Get base liquidity details for a specific pool
500
+ * const baseLiquidity = await client.getPoolBaseLiquidity("archway1pool...");
501
+ * console.log(`Base liquidity: ${baseLiquidity.baseLiquidity.amount} ${baseLiquidity.baseLiquidity.denom}`);
502
+ * console.log(`Total shares: ${baseLiquidity.totalShares}`);
503
+ * ```
504
+ */
505
+ abstract getPoolBaseLiquidity(poolContractAddress: string): Promise<BaseLiquidityDetails>;
445
506
  /**
446
507
  * Fetches all supported assets across all pools in the Bolt protocol.
447
508
  *
@@ -459,7 +520,7 @@ declare abstract class BaseClient<TSigner = unknown, TTxOutput = unknown> {
459
520
  *
460
521
  * @example
461
522
  * ```typescript
462
- * const assets = await client.getAllAssets();
523
+ * const assets = await client.getAssets();
463
524
  *
464
525
  * // Display all available assets
465
526
  * assets.forEach(asset => {
@@ -481,7 +542,7 @@ declare abstract class BaseClient<TSigner = unknown, TTxOutput = unknown> {
481
542
  * Assets returned by this method represent all tokens available for trading
482
543
  * in the Bolt protocol. The list may vary between mainnet and testnet environments.
483
544
  */
484
- abstract getAllAssets(): Promise<Asset[]>;
545
+ abstract getAssets(): Promise<Asset[]>;
485
546
  /**
486
547
  * Executes a swap operation on the blockchain from one asset to another.
487
548
  *
@@ -489,8 +550,6 @@ declare abstract class BaseClient<TSigner = unknown, TTxOutput = unknown> {
489
550
  * amount varies based on current pool conditions and fees. The transaction includes
490
551
  * slippage protection through the optional minimumAmountOut parameter.
491
552
  *
492
- * @param signer - The transaction signer that will authorize the swap operation.
493
- * Must have sufficient balance of the input asset.
494
553
  * @param params - The swap configuration parameters
495
554
  * @param params.assetIn - The denom of the asset being sold (e.g., "aarch", "ibc/...")
496
555
  * @param params.amountIn - The exact amount of input asset to swap (in minimal denomination)
@@ -499,6 +558,8 @@ declare abstract class BaseClient<TSigner = unknown, TTxOutput = unknown> {
499
558
  * Transaction will fail if actual output would be less.
500
559
  * @param params.receiver - Optional recipient address for the swapped assets.
501
560
  * If not provided, defaults to the signer's address.
561
+ * @param signer - The transaction signer that will authorize the swap operation.
562
+ * Must have sufficient balance of the input asset.
502
563
  *
503
564
  * @returns A promise that resolves to a SwapResult containing:
504
565
  * - txOutput: Transaction execution details (type varies by implementation)
@@ -512,13 +573,13 @@ declare abstract class BaseClient<TSigner = unknown, TTxOutput = unknown> {
512
573
  * @example
513
574
  * ```typescript
514
575
  * // Swap exactly 1 ARCH for USDC (output amount varies)
515
- * const result = await client.swap(signer, {
576
+ * const result = await client.swap({
516
577
  * assetIn: "aarch",
517
578
  * amountIn: "1000000000000000000", // Exactly 1 ARCH (18 decimals)
518
579
  * assetOut: "ibc/43897B9739BD63E3A08A88191999C632E052724AB96BD4C74AE31375C991F48D", // USDC IBC denom
519
580
  * minimumAmountOut: "1950000000", // Accept no less than 1950 USDC
520
581
  * receiver: "archway1..." // Optional custom receiver
521
- * });
582
+ * }, signer);
522
583
  *
523
584
  * console.log(`Swapped exactly 1 ARCH`);
524
585
  * console.log(`Received: ${result.amountOut} ${result.assetOut}`);
@@ -535,7 +596,104 @@ declare abstract class BaseClient<TSigner = unknown, TTxOutput = unknown> {
535
596
  * The TTxOutput type parameter represents the transaction execution result type,
536
597
  * which varies by blockchain implementation (e.g., ExecuteResult for CosmWasm).
537
598
  */
538
- abstract swap(signer: TSigner, params: SwapParams): Promise<SwapResult<TTxOutput>>;
599
+ abstract swap(params: SwapParams, signer?: TSigner): Promise<SwapResult<TTxOutput>>;
600
+ /**
601
+ * Estimates the gas fees for a swap operation without executing the transaction.
602
+ *
603
+ * This method performs a dry run of the swap transaction to calculate the required gas fees
604
+ * in the chain's native token denomination. It's useful for displaying estimated costs
605
+ * to users before they confirm a swap, or for ensuring sufficient gas balance.
606
+ *
607
+ * @param params - The swap configuration parameters (same as for the swap method)
608
+ * @param params.assetIn - The denom of the asset being sold (e.g., "aarch", "ibc/...")
609
+ * @param params.amountIn - The exact amount of input asset to swap (in minimal denomination)
610
+ * @param params.assetOut - The denom of the asset being bought (e.g., "aarch", "ibc/...")
611
+ * @param params.minimumAmountOut - Optional minimum acceptable amount of output asset
612
+ * @param params.receiver - Optional recipient address for the swapped assets
613
+ * @param signer - The transaction signer that would authorize the swap operation
614
+ * @param gasAdjustment - Optional multiplier for gas estimation (default: 1.5).
615
+ * Use higher values for safety margin. For example, 1.5 means 50% buffer.
616
+ *
617
+ * @returns A promise that resolves to a Coin object containing:
618
+ * - denom: The gas token denomination (e.g., "uarch" for Archway, "SUI" for Sui)
619
+ * - amount: The estimated gas amount as a string (in minimal denomination)
620
+ * Returns undefined if gas estimation fails or is not supported
621
+ *
622
+ * @example
623
+ * ```typescript
624
+ * // Estimate gas for swapping 1 ARCH to USDC
625
+ * const gasEstimate = await client.estimateSwapGasFees({
626
+ * assetIn: "aarch",
627
+ * amountIn: "1000000000000000000", // 1 ARCH
628
+ * assetOut: "ibc/43897B9739BD63E3A08A88191999C632E052724AB96BD4C74AE31375C991F48D", // USDC
629
+ * minimumAmountOut: "1950000000" // Min 1950 USDC
630
+ * }, signer, 1.3); // 30% safety margin
631
+ *
632
+ * if (gasEstimate) {
633
+ * console.log(`Estimated gas: ${gasEstimate.amount} ${gasEstimate.denom}`);
634
+ * }
635
+ * ```
636
+ *
637
+ * @remarks
638
+ * - Gas estimation is performed via simulation/dry run without state changes
639
+ * - The returned amount is in the smallest denomination of the native token
640
+ * - Different chains have different decimal places (e.g., 6 for Cosmos chains, 9 for Sui)
641
+ * - The gasAdjustment parameter helps account for potential variations in actual execution
642
+ * - Some implementations may return undefined if gas estimation is not available
643
+ * - Always ensure the signer has sufficient native token balance for gas fees
644
+ */
645
+ abstract estimateSwapGasFees(params: SwapParams, signer?: TSigner, gasAdjustment?: number): Promise<Coin | undefined>;
646
+ /**
647
+ * Simulates a swap operation to calculate the expected output amount without executing the transaction.
648
+ *
649
+ * This method performs a dry run of the swap to determine how much of the output asset
650
+ * would be received for a given input amount, taking into account current pool conditions,
651
+ * oracle prices, and fees. It's useful for getting accurate estimates before executing a swap.
652
+ *
653
+ * @param params - The required swap parameters for simulation
654
+ * @param params.assetIn - The denom of the asset being sold (e.g., "aarch", "ibc/...")
655
+ * @param params.amountIn - The exact amount of input asset to simulate swapping (in minimal denomination)
656
+ * @param params.assetOut - The denom of the asset being bought (e.g., "aarch", "ibc/...")
657
+ *
658
+ * @returns A promise that resolves to a SimulateSwapResult containing:
659
+ * - poolAddress: The address of the pool that would handle this swap
660
+ * - amountOut: The expected amount of output asset to be received (as a string)
661
+ * - assetOut: The denom of the output asset (same as params.assetOut)
662
+ * - protocolFee: The protocol fee amount that would be charged (as a string)
663
+ * - lpFee: The liquidity provider fee amount that would be charged (as a string)
664
+ * - dynamicFeePercentage: Optional dynamic fee percentage if applicable to the pool (as a string)
665
+ * - totalFees: The sum of all fees (protocol + LP + dynamic) (as a string)
666
+ *
667
+ * @example
668
+ * ```typescript
669
+ * // Simulate swapping 1 ARCH for USDC
670
+ * const simulation = await client.simulateSwap({
671
+ * assetIn: "aarch",
672
+ * amountIn: "1000000000000000000", // 1 ARCH (18 decimals)
673
+ * assetOut: "ibc/43897B9739BD63E3A08A88191999C632E052724AB96BD4C74AE31375C991F48D" // USDC
674
+ * });
675
+ *
676
+ * console.log(`Pool: ${simulation.poolAddress}`);
677
+ * console.log(`Expected output: ${simulation.amountOut} ${simulation.assetOut}`);
678
+ * console.log(`Protocol fee: ${simulation.protocolFee}`);
679
+ * console.log(`LP fee: ${simulation.lpFee}`);
680
+ * if (simulation.dynamicFeePercentage) {
681
+ * console.log(`Dynamic fee percentage: ${simulation.dynamicFee}%`);
682
+ * }
683
+ * console.log(`Total fees: ${simulation.totalFees}`);
684
+ * ```
685
+ *
686
+ * @remarks
687
+ * - This simulation reflects the current state of the pool and oracle prices
688
+ * - The actual swap may differ slightly due to state changes between simulation and execution
689
+ * - Use the amountOut to set appropriate minimumAmountOut in the actual swap
690
+ * - All fee amounts are returned in the output asset's denomination
691
+ * - Dynamic fees may not be present in all chains and pools (check if defined)
692
+ * - The totalFees includes all applicable fees for full transparency
693
+ * - No gas is consumed for simulations as they don't modify blockchain state
694
+ */
695
+ abstract simulateSwap(params: SwapRequiredParams): Promise<SimulateSwapResult>;
696
+ abstract simulateSwap(params: SwapRequiredParams): Promise<SimulateSwapResult>;
539
697
  }
540
698
 
541
699
  /**
@@ -550,6 +708,7 @@ declare abstract class BaseClient<TSigner = unknown, TTxOutput = unknown> {
550
708
  * - 2000-2999: Blockchain Transaction Errors
551
709
  * - 3000-3999: Infrastructure & Network Errors
552
710
  * - 4000-4999: Validation & Input Errors
711
+ * - 9000-9999: Unknown & Unexpected Errors
553
712
  *
554
713
  * @enum {number}
555
714
  * @group Errors
@@ -560,7 +719,7 @@ declare abstract class BaseClient<TSigner = unknown, TTxOutput = unknown> {
560
719
  * import { BoltSdkErrorCode, BoltSdkError } from '@bolt-liquidity-hq/cosmwasm-client';
561
720
  *
562
721
  * try {
563
- * await client.swap(signer, params);
722
+ * await client.swap(params, signer);
564
723
  * } catch (error) {
565
724
  * if (error instanceof BoltSdkError) {
566
725
  * switch (error.code) {
@@ -570,6 +729,9 @@ declare abstract class BaseClient<TSigner = unknown, TTxOutput = unknown> {
570
729
  * case BoltSdkErrorCode.TRANSACTION_EVENT_NOT_FOUND:
571
730
  * console.error("Transaction event not found");
572
731
  * break;
732
+ * case BoltSdkErrorCode.UNEXPECTED_ERROR:
733
+ * console.error("Unexpected error occurred:", error.message);
734
+ * break;
573
735
  * default:
574
736
  * console.error("Operation failed:", error.message);
575
737
  * }
@@ -577,7 +739,7 @@ declare abstract class BaseClient<TSigner = unknown, TTxOutput = unknown> {
577
739
  * }
578
740
  * ```
579
741
  */
580
- declare enum BoltSdkErrorCode {
742
+ declare const enum BoltSdkErrorCode {
581
743
  /** Resource not found (pools, assets, configurations) */
582
744
  NOT_FOUND = 1000,
583
745
  /** Invalid object structure or missing required fields */
@@ -599,7 +761,11 @@ declare enum BoltSdkErrorCode {
599
761
  /** Required parameter is missing */
600
762
  MISSING_PARAMETER = 4001,
601
763
  /** Numeric value outside acceptable range */
602
- PARAMETER_OUT_OF_RANGE = 4002
764
+ PARAMETER_OUT_OF_RANGE = 4002,
765
+ /** Feature or method not yet implemented */
766
+ NOT_IMPLEMENTED = 4003,
767
+ /** Unexpected or unknown error occurred */
768
+ UNEXPECTED_ERROR = 9000
603
769
  }
604
770
  /**
605
771
  * Base interface for all Bolt SDK errors.
@@ -614,12 +780,14 @@ declare enum BoltSdkErrorCode {
614
780
  interface BoltSdkError extends Error {
615
781
  /** The error code categorizing this error */
616
782
  code: BoltSdkErrorCode;
783
+ /** Optional additional context data that might help debugging */
784
+ context?: Record<string, unknown>;
617
785
  }
618
786
  /**
619
787
  * Base class for all custom errors in the Bolt SDK.
620
788
  *
621
789
  * This abstract base class provides common functionality for all SDK errors,
622
- * including error code assignment and proper error name setting.
790
+ * including error code assignment, proper error name setting, and optional context data.
623
791
  *
624
792
  * @abstract
625
793
  * @group Errors
@@ -627,13 +795,16 @@ interface BoltSdkError extends Error {
627
795
  */
628
796
  declare class BoltSdkErrorBase extends Error implements BoltSdkError {
629
797
  code: BoltSdkErrorCode;
798
+ /** Optional additional context data that might help debugging */
799
+ context?: Record<string, unknown>;
630
800
  /**
631
801
  * Creates a new BoltSdkErrorBase instance.
632
802
  *
633
803
  * @param code - The error code categorizing this error
634
804
  * @param message - Human-readable error message
805
+ * @param context - Optional additional context or state information
635
806
  */
636
- constructor(code: BoltSdkErrorCode, message: string);
807
+ constructor(code: BoltSdkErrorCode, message: string, context?: Record<string, unknown>);
637
808
  }
638
809
  /**
639
810
  * Error thrown when a requested resource cannot be found.
@@ -647,8 +818,9 @@ declare class NotFoundError extends BoltSdkErrorBase {
647
818
  *
648
819
  * @param resource - The type of resource that was not found
649
820
  * @param details - Optional additional details about what was searched for
821
+ * @param context - Optional additional context or state information
650
822
  */
651
- constructor(resource: string, details?: string);
823
+ constructor(resource: string, details?: string, context?: Record<string, unknown>);
652
824
  }
653
825
  /**
654
826
  * Error thrown when an object doesn't have the expected structure.
@@ -661,8 +833,9 @@ declare class InvalidObjectError extends BoltSdkErrorBase {
661
833
  * Creates a new InvalidObjectError instance.
662
834
  *
663
835
  * @param details - Optional description of what is invalid about the object
836
+ * @param context - Optional additional context or state information
664
837
  */
665
- constructor(details?: string);
838
+ constructor(details?: string, context?: Record<string, unknown>);
666
839
  }
667
840
  /**
668
841
  * Error thrown when an unexpected type is encountered.
@@ -676,8 +849,29 @@ declare class InvalidTypeError extends BoltSdkErrorBase {
676
849
  *
677
850
  * @param expectedType - The type that was expected
678
851
  * @param receivedType - The actual type that was received
852
+ * @param context - Optional additional context or state information
679
853
  */
680
- constructor(expectedType: string, receivedType: string);
854
+ constructor(expectedType: string, receivedType: string, context?: Record<string, unknown>);
855
+ }
856
+ /**
857
+ * Error thrown when a response cannot be parsed into the expected TypeScript type.
858
+ *
859
+ * This error is used when API responses, JSON data, or other external data
860
+ * cannot be successfully parsed or validated against the expected TypeScript
861
+ * interface or type definition.
862
+ *
863
+ * @group Errors
864
+ * @category Error Classes
865
+ */
866
+ declare class ParseError extends BoltSdkErrorBase {
867
+ /**
868
+ * Creates a new ParseError instance.
869
+ *
870
+ * @param targetType - The TypeScript type or interface name that parsing failed for
871
+ * @param details - Specific details about what failed during parsing
872
+ * @param context - Optional additional context including the raw data that failed to parse
873
+ */
874
+ constructor(targetType: string, details: string, context?: Record<string, unknown>);
681
875
  }
682
876
  /**
683
877
  * Error thrown when an account has insufficient funds for an operation.
@@ -691,8 +885,9 @@ declare class InsufficientFundsError extends BoltSdkErrorBase {
691
885
  *
692
886
  * @param required - The amount required for the operation
693
887
  * @param available - The amount available in the account
888
+ * @param context - Optional additional context or state information
694
889
  */
695
- constructor(required: number, available: number);
890
+ constructor(required: string | number, available: string | number, context?: Record<string, unknown>);
696
891
  }
697
892
  /**
698
893
  * Error thrown when an invalid blockchain address is provided.
@@ -705,8 +900,9 @@ declare class InvalidAddressError extends BoltSdkErrorBase {
705
900
  * Creates a new InvalidAddressError instance.
706
901
  *
707
902
  * @param address - The invalid address that was provided
903
+ * @param context - Optional additional context or state information
708
904
  */
709
- constructor(address: string);
905
+ constructor(address: string, context?: Record<string, unknown>);
710
906
  }
711
907
  /**
712
908
  * Error thrown when a blockchain transaction fails or is reverted.
@@ -720,8 +916,9 @@ declare class TransactionFailedError extends BoltSdkErrorBase {
720
916
  *
721
917
  * @param transactionId - The transaction hash or identifier
722
918
  * @param details - Optional details about why the transaction failed
919
+ * @param context - Optional additional context or state information
723
920
  */
724
- constructor(transactionId: string, details?: string);
921
+ constructor(transactionId: string, details?: string, context?: Record<string, unknown>);
725
922
  }
726
923
  /**
727
924
  * Error thrown when an expected transaction event is not found in the logs.
@@ -735,8 +932,9 @@ declare class TransactionEventNotFoundError extends BoltSdkErrorBase {
735
932
  *
736
933
  * @param eventName - The name of the event that was expected
737
934
  * @param details - Optional details about the context
935
+ * @param context - Optional additional context or state information
738
936
  */
739
- constructor(eventName: string, details?: string);
937
+ constructor(eventName: string, details?: string, context?: Record<string, unknown>);
740
938
  }
741
939
  /**
742
940
  * Error thrown when network communication fails.
@@ -749,8 +947,9 @@ declare class NetworkError extends BoltSdkErrorBase {
749
947
  * Creates a new NetworkError instance.
750
948
  *
751
949
  * @param details - Optional details about the network failure
950
+ * @param context - Optional additional context or state information
752
951
  */
753
- constructor(details?: string);
952
+ constructor(details?: string, context?: Record<string, unknown>);
754
953
  }
755
954
  /**
756
955
  * Error thrown when an invalid parameter is provided to a method.
@@ -766,10 +965,11 @@ declare class InvalidParameterError<T = unknown> extends BoltSdkErrorBase {
766
965
  * @param expected - Description of what was expected
767
966
  * @param receivedValue - The actual value that was provided
768
967
  * @param details - Optional additional details or constraints
968
+ * @param context - Optional additional context or state information
769
969
  *
770
970
  * @template T - The type of the received value
771
971
  */
772
- constructor(parameterName: string, expected: string, receivedValue: T, details?: string);
972
+ constructor(parameterName: string, expected: string, receivedValue: T, details?: string, context?: Record<string, unknown>);
773
973
  }
774
974
  /**
775
975
  * Error thrown when a required parameter is missing.
@@ -782,9 +982,10 @@ declare class MissingParameterError extends BoltSdkErrorBase {
782
982
  * Creates a new MissingParameterError instance.
783
983
  *
784
984
  * @param parameterName - The name of the missing parameter
785
- * @param context - Optional context about where the parameter was expected
985
+ * @param expectedLocation - Optional context about where the parameter was expected to be found
986
+ * @param context - Optional additional context or state information
786
987
  */
787
- constructor(parameterName: string, context?: string);
988
+ constructor(parameterName: string, expectedLocation?: string, context?: Record<string, unknown>);
788
989
  }
789
990
  /**
790
991
  * Error thrown when a numeric parameter is outside the acceptable range.
@@ -801,8 +1002,118 @@ declare class ParameterOutOfRangeError extends BoltSdkErrorBase {
801
1002
  * @param min - Optional minimum acceptable value (inclusive)
802
1003
  * @param max - Optional maximum acceptable value (inclusive)
803
1004
  * @param details - Optional additional details about the constraint
1005
+ * @param context - Optional additional context or state information
1006
+ */
1007
+ constructor(parameterName: string, value: number | bigint, min?: number | bigint, max?: number | bigint, details?: string, context?: Record<string, unknown>);
1008
+ }
1009
+ /**
1010
+ * Error thrown when a feature or method is not yet implemented.
1011
+ *
1012
+ * This error is useful during development to mark planned functionality
1013
+ * that hasn't been completed yet. It helps distinguish between bugs
1014
+ * and intentionally unimplemented features.
1015
+ *
1016
+ * @group Errors
1017
+ * @category Error Classes
1018
+ *
1019
+ * @example
1020
+ * ```typescript
1021
+ * class BoltClient {
1022
+ * async advancedSwap(params: AdvancedSwapParams): Promise<SwapResult> {
1023
+ * throw new NotImplementedError('advancedSwap', 'v2.0.0');
1024
+ * }
1025
+ * }
1026
+ * ```
1027
+ *
1028
+ * @example
1029
+ * ```typescript
1030
+ * throw new NotImplementedError(
1031
+ * 'multi-hop routing',
1032
+ * undefined,
1033
+ * { requestedHops: 3, maxSupportedHops: 1 }
1034
+ * );
1035
+ * ```
1036
+ */
1037
+ declare class NotImplementedError extends BoltSdkErrorBase {
1038
+ /**
1039
+ * Creates a new NotImplementedError instance.
1040
+ *
1041
+ * @param feature - The name of the feature or method that is not implemented
1042
+ * @param plannedVersion - Optional version when the feature is planned to be implemented
1043
+ * @param context - Optional additional context or state information
1044
+ */
1045
+ constructor(feature: string, plannedVersion?: string, context?: Record<string, unknown>);
1046
+ }
1047
+ /**
1048
+ * Error thrown when an unexpected or unhandled error occurs.
1049
+ *
1050
+ * This error is used as a catch-all for errors that don't fit into any
1051
+ * of the specific error categories. It can wrap unknown errors from
1052
+ * external libraries or unexpected runtime conditions.
1053
+ *
1054
+ * @group Errors
1055
+ * @category Error Classes
1056
+ *
1057
+ * @example
1058
+ * ```typescript
1059
+ * try {
1060
+ * // Some operation that might throw unknown errors
1061
+ * await someExternalLibraryCall();
1062
+ * } catch (error) {
1063
+ * if (error instanceof Error) {
1064
+ * throw new UnexpectedError(error.message, error);
1065
+ * } else {
1066
+ * throw new UnexpectedError(String(error));
1067
+ * }
1068
+ * }
1069
+ * ```
1070
+ *
1071
+ * @example
1072
+ * ```typescript
1073
+ * // Handle unexpected conditions
1074
+ * if (someUnexpectedCondition) {
1075
+ * throw new UnexpectedError(
1076
+ * "Unexpected state encountered during swap operation",
1077
+ * undefined,
1078
+ * { poolState, userBalance, timestamp }
1079
+ * );
1080
+ * }
1081
+ * ```
1082
+ */
1083
+ declare class UnexpectedError extends BoltSdkErrorBase {
1084
+ /** The original error that was caught, if any */
1085
+ originalError?: Error | unknown;
1086
+ /**
1087
+ * Creates a new UnexpectedError instance.
1088
+ *
1089
+ * @param message - A description of the unexpected error
1090
+ * @param originalError - Optional original error that was caught
1091
+ * @param context - Optional additional context or state information
1092
+ */
1093
+ constructor(message: string, originalError?: Error | unknown, context?: Record<string, unknown>);
1094
+ /**
1095
+ * Creates an UnexpectedError from an unknown caught value.
1096
+ * This is a convenience method for error handling blocks.
1097
+ *
1098
+ * @param caught - The value that was caught in a try-catch block
1099
+ * @param message - Optional custom message to prepend
1100
+ * @param context - Optional additional context
1101
+ * @returns A new UnexpectedError instance
1102
+ *
1103
+ * @example
1104
+ * ```typescript
1105
+ * try {
1106
+ * await riskyOperation();
1107
+ * } catch (caught) {
1108
+ * throw UnexpectedError.from(
1109
+ * caught,
1110
+ * "Failed to execute risky operation",
1111
+ * { operation: 'riskyOperation', timestamp: Date.now() }
1112
+ * );
1113
+ * }
1114
+ * ```
804
1115
  */
805
- constructor(parameterName: string, value: number | bigint, min?: number | bigint, max?: number | bigint, details?: string);
1116
+ static from(caught: unknown, message?: string, context?: Record<string, unknown>): UnexpectedError;
806
1117
  }
807
1118
 
808
- export { type Address, type AllowanceMode, type Asset, type AssetPairString, type AssetsConfig, BaseClient, type BaseLiquidityDetails, type BoltSdkError, BoltSdkErrorBase, BoltSdkErrorCode, type ChainConfig, type ClientConfig, type Coin, type Contracts, type Duration, type Environment, InsufficientFundsError, InvalidAddressError, InvalidObjectError, InvalidParameterError, InvalidTypeError, type InvertiblePrice, MissingParameterError, NetworkError, NotFoundError, type OracleAsset, type OracleAssetPair, type OracleConfig, ParameterOutOfRangeError, type Pool, type PoolConfig, type Price, type RouterConfig, type SwapParams, type SwapResult, type Timestamp, TransactionEventNotFoundError, TransactionFailedError, getCoinFromAmountWithDenomString };
1119
+ export { type Address, type AllowanceMode, type Asset, type AssetsConfig, BaseClient, type BaseLiquidityDetails, type BoltSdkError, BoltSdkErrorBase, type ChainConfig, type ClientConfig, type Coin, type Contracts, DEFAULT_GAS_ADJUSTMENT, type Duration, type Environment, InsufficientFundsError, InvalidAddressError, InvalidObjectError, InvalidParameterError, InvalidTypeError, type InvertiblePrice, MissingParameterError, NetworkError, NotFoundError, NotImplementedError, type OracleAsset, type OracleAssetPair, type OracleConfig, ParameterOutOfRangeError, ParseError, type Pool, type PoolConfig, type Price, type RouterConfig, type SimulateSwapResult, type SwapParams, type SwapRequiredParams, type SwapResult, type Timestamp, TransactionEventNotFoundError, TransactionFailedError, UnexpectedError, getCoinFromAmountWithDenomString };