@bolt-liquidity-hq/cosmwasm-client 0.1.0-beta.3 → 0.1.0-beta.5

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
@@ -6,7 +6,14 @@ import { OfflineSigner } from '@cosmjs/proto-signing';
6
6
  * Error codes used throughout the Bolt SDK to categorize different types of errors.
7
7
  *
8
8
  * These codes help in programmatic error handling and provide a consistent way
9
- * to identify error types across the SDK.
9
+ * to identify error types across the SDK. Error codes are organized into ranges
10
+ * by category for easier identification and handling.
11
+ *
12
+ * Error Code Ranges:
13
+ * - 1000-1999: Resource & Data Errors
14
+ * - 2000-2999: Blockchain Transaction Errors
15
+ * - 3000-3999: Infrastructure & Network Errors
16
+ * - 4000-4999: Validation & Input Errors
10
17
  *
11
18
  * @enum {number}
12
19
  * @group Errors
@@ -17,7 +24,7 @@ import { OfflineSigner } from '@cosmjs/proto-signing';
17
24
  * import { BoltSdkErrorCode, BoltSdkError } from '@bolt-liquidity-hq/cosmwasm-client';
18
25
  *
19
26
  * try {
20
- * await client.swapExactIn(signer, params);
27
+ * await client.swap(signer, params);
21
28
  * } catch (error) {
22
29
  * if (error instanceof BoltSdkError) {
23
30
  * switch (error.code) {
@@ -36,27 +43,27 @@ import { OfflineSigner } from '@cosmjs/proto-signing';
36
43
  */
37
44
  declare enum BoltSdkErrorCode {
38
45
  /** Resource not found (pools, assets, configurations) */
39
- NOT_FOUND = 0,
46
+ NOT_FOUND = 1000,
40
47
  /** Invalid object structure or missing required fields */
41
- INVALID_OBJECT = 1,
48
+ INVALID_OBJECT = 1001,
42
49
  /** Type mismatch or invalid type provided */
43
- INVALID_TYPE = 2,
50
+ INVALID_TYPE = 1002,
44
51
  /** Insufficient balance to perform the operation */
45
- INSUFFICIENT_FUNDS = 3,
52
+ INSUFFICIENT_FUNDS = 2000,
46
53
  /** Invalid blockchain address format */
47
- INVALID_ADDRESS = 4,
54
+ INVALID_ADDRESS = 2001,
48
55
  /** Transaction reverted or failed on-chain */
49
- TRANSACTION_FAILED = 5,
56
+ TRANSACTION_FAILED = 2002,
50
57
  /** Expected transaction event not found in logs */
51
- TRANSACTION_EVENT_NOT_FOUND = 6,
58
+ TRANSACTION_EVENT_NOT_FOUND = 2003,
52
59
  /** Network connectivity or RPC communication failure */
53
- NETWORK_ERROR = 7,
60
+ NETWORK_ERROR = 3000,
54
61
  /** Invalid parameter provided to a method */
55
- INVALID_PARAMETER = 8,
62
+ INVALID_PARAMETER = 4000,
56
63
  /** Required parameter is missing */
57
- MISSING_PARAMETER = 9,
64
+ MISSING_PARAMETER = 4001,
58
65
  /** Numeric value outside acceptable range */
59
- PARAMETER_OUT_OF_RANGE = 10
66
+ PARAMETER_OUT_OF_RANGE = 4002
60
67
  }
61
68
  /**
62
69
  * Base interface for all Bolt SDK errors.
@@ -262,63 +269,73 @@ declare class ParameterOutOfRangeError extends BoltSdkErrorBase {
262
269
  constructor(parameterName: string, value: number | bigint, min?: number | bigint, max?: number | bigint, details?: string);
263
270
  }
264
271
 
265
- declare enum Environment {
266
- Mainnet = "mainnet",
267
- Testnet = "testnet"
268
- }
269
-
270
272
  type Address = string;
271
273
  type AssetPairString = string;
272
274
  type Timestamp = string;
273
- interface Duration {
275
+ type Duration = {
274
276
  secs: number;
275
277
  nanos: number;
276
- }
277
- interface Coin {
278
+ };
279
+ type Coin = {
278
280
  denom: string;
279
281
  amount: string;
280
- }
282
+ };
281
283
 
282
- interface ClientConfig {
284
+ type Environment = 'mainnet' | 'testnet';
285
+ type Asset = {
286
+ symbol: string;
287
+ name: string;
288
+ chainId: string;
289
+ denom: string;
290
+ decimals: number;
291
+ logo?: string;
292
+ coingeckoId?: string;
293
+ };
294
+ type ChainConfig = {
295
+ name: string;
296
+ id: string;
297
+ rpcEndpoint: string;
298
+ };
299
+ type Contracts = {
300
+ oracle: Address;
301
+ router: Address;
302
+ };
303
+ type AssetsConfig = Record<string, Asset>;
304
+
305
+ type ClientConfig<TChainConfig = ChainConfig> = {
283
306
  environment?: Environment;
284
307
  customOverride?: {
285
- rpcEndpoint?: string;
308
+ chainConfig?: Partial<TChainConfig>;
286
309
  contracts?: Partial<Contracts>;
310
+ assetsConfig?: AssetsConfig;
287
311
  };
288
- }
289
- interface Contracts {
290
- oracle: Address;
291
- router: Address;
292
- }
312
+ };
293
313
 
294
- interface OracleConfig {
314
+ type OracleConfig = {
295
315
  admin: Address;
296
316
  priceThresholdRatio: string;
297
317
  priceExpireTime: Duration | null;
298
- }
299
- interface Price {
318
+ };
319
+ type Price = {
300
320
  assetPair: AssetPairString;
301
321
  price: string;
302
322
  expiryTime: Timestamp;
303
- }
304
- interface InvertiblePrice extends Price {
323
+ };
324
+ type InvertiblePrice = Price & {
305
325
  isInverse: boolean;
306
- }
307
- interface OracleAsset {
326
+ };
327
+ type OracleAsset = {
308
328
  name: string;
309
329
  symbol: string;
310
330
  precision: number;
311
- }
312
- interface OracleAssetPair {
331
+ };
332
+ type OracleAssetPair = {
313
333
  base: OracleAsset;
314
334
  quote: OracleAsset;
315
- }
335
+ };
316
336
 
317
- declare enum AllowanceMode {
318
- Allow = "allow",
319
- Disallow = "disallow"
320
- }
321
- interface PoolConfig {
337
+ type AllowanceMode = 'allow' | 'disallow';
338
+ type PoolConfig = {
322
339
  priceOracleContract: Address;
323
340
  protocolFeeRecipient: Address;
324
341
  protocolFee: string;
@@ -326,34 +343,38 @@ interface PoolConfig {
326
343
  allowanceMode: AllowanceMode;
327
344
  lps: Address[];
328
345
  minBaseOut: string;
329
- }
346
+ };
347
+ type BaseLiquidityDetails = {
348
+ baseLiquidity: Coin;
349
+ totalShares: string;
350
+ };
330
351
 
331
- interface RouterConfig {
352
+ type RouterConfig = {
332
353
  admin: Address;
333
354
  defaultPriceOracleContract: Address;
334
355
  defaultProtocolFeeRecipient: Address;
335
356
  defaultProtocolFee: string;
336
357
  defaultLpFee: string;
337
358
  settlementCodeId: number;
338
- }
339
- interface Pool {
359
+ };
360
+ type Pool = {
340
361
  poolAddress: Address;
341
362
  baseAssetSymbol: string;
342
363
  quoteAssetsSymbols: string[];
343
- }
344
- interface SwapParams {
364
+ };
365
+ type SwapParams = {
345
366
  assetIn: string;
346
367
  amountIn: string;
347
368
  assetOut: string;
348
369
  minimumAmountOut?: string;
349
370
  receiver?: Address;
350
- }
351
- interface SwapResult<TTxOutput = unknown> {
371
+ };
372
+ type SwapResult<TTxOutput = unknown> = {
352
373
  txOutput: TTxOutput;
353
374
  amountOut: string;
354
375
  assetOut: string;
355
376
  txHash: string;
356
- }
377
+ };
357
378
 
358
379
  /**
359
380
  * Abstract base client for all implementations of the Bolt SDK for different chains/networks.
@@ -362,43 +383,67 @@ interface SwapResult<TTxOutput = unknown> {
362
383
  * defining the core interface for interacting with oracle and router contracts.
363
384
  *
364
385
  * @template TSigner - The type of the transaction signer specific to the blockchain implementation
386
+ * @template TTxOutput - The type of the transaction output specific to the blockchain implementation
365
387
  *
366
388
  * @example
367
389
  * ```typescript
368
- * class BoltCosmWasmClient extends BaseClient<OfflineSigner> {
390
+ * class BoltCosmWasmClient extends BaseClient<OfflineSigner, ExecuteResult> {
369
391
  * // Implementation specific to CosmWasm
370
392
  * }
371
393
  * ```
372
394
  */
373
- declare abstract class BaseClient<TSigner = unknown> {
395
+ declare abstract class BaseClient<TSigner = unknown, TTxOutput = unknown> {
374
396
  /**
375
- * The RPC endpoint URL for connecting to the blockchain network
397
+ * The blockchain network configuration containing chain ID, name, and RPC endpoint
376
398
  */
377
- rpcEndpoint: Address;
399
+ chainConfig: ChainConfig;
378
400
  /**
379
401
  * Smart contract addresses for making Bolt queries and transactions in the blockchain
380
402
  */
381
403
  contracts: Contracts;
404
+ /**
405
+ * Configuration mapping of supported assets indexed by their symbol
406
+ */
407
+ assetsConfig: AssetsConfig;
382
408
  /**
383
409
  * Creates a new instance of the BaseClient.
384
410
  *
385
411
  * @param config - (Optional) Configuration object for the client
386
- * @param config.customOverride - (Optional) Override configuration for RPC endpoint and contract addresses
387
- * @param config.customOverride.rpcEndpoint - (Optional) Custom RPC endpoint URL for the blockchain network
388
- * @param config.customOverride.contracts - (Optional) Custom contract addresses
389
- * @param config.customOverride.contracts.oracle - (Optional) Custom oracle contract address
390
- * @param config.customOverride.contracts.router - (Optional) Custom router contract address
412
+ * @param config.customOverride - (Optional) Override configuration containing chain settings, contracts, and assets
413
+ * @param config.customOverride.chainConfig - (Optional) Chain configuration object
414
+ * @param config.customOverride.chainConfig.id - (Optional) The chain ID of the blockchain network (e.g., "archway-1")
415
+ * @param config.customOverride.chainConfig.name - (Optional) The human-readable name of the chain (e.g., "Archway")
416
+ * @param config.customOverride.chainConfig.rpcEndpoint - (Optional) RPC endpoint URL for the blockchain network
417
+ * @param config.customOverride.contracts - (Optional) Contract addresses for oracle and router
418
+ * @param config.customOverride.contracts.oracle - (Optional) Oracle contract address
419
+ * @param config.customOverride.contracts.router - (Optional) Router contract address
420
+ * @param config.customOverride.assetsConfig - (Optional) Configuration for supported assets indexed by symbol
391
421
  *
392
422
  * @throws {InvalidObjectError} Thrown when required configuration fields are missing
393
423
  *
394
424
  * @example
395
425
  * ```typescript
396
426
  * const client = new ConcreteClient({
397
- * override: {
398
- * rpcEndpoint: 'https://rpc.example.com',
427
+ * customOverride: {
428
+ * chainConfig: {
429
+ * id: 'archway-1',
430
+ * name: 'Archway',
431
+ * rpcEndpoint: 'https://rpc.example.com'
432
+ * },
399
433
  * contracts: {
400
- * oracle: 'archway1...',
401
- * router: 'archway1...'
434
+ * oracle: 'archway1oracle...',
435
+ * router: 'archway1router...'
436
+ * },
437
+ * assetsConfig: {
438
+ * 'ARCH': {
439
+ * symbol: 'ARCH',
440
+ * name: 'Archway',
441
+ * chainId: 'archway-1',
442
+ * denom: 'aarch',
443
+ * decimals: 18,
444
+ * logo: 'https://...',
445
+ * coingeckoId: 'archway'
446
+ * }
402
447
  * }
403
448
  * }
404
449
  * });
@@ -415,6 +460,8 @@ declare abstract class BaseClient<TSigner = unknown> {
415
460
  * ```typescript
416
461
  * const oracleConfig = await client.getOracleConfig();
417
462
  * console.log(`Price expiration: ${oracleConfig.priceExpireTime} seconds`);
463
+ * console.log(`Admin: ${oracleConfig.admin}`);
464
+ * console.log(`Price threshold ratio: ${oracleConfig.priceThresholdRatio}`);
418
465
  * ```
419
466
  */
420
467
  abstract getOracleConfig(): Promise<OracleConfig>;
@@ -429,26 +476,27 @@ declare abstract class BaseClient<TSigner = unknown> {
429
476
  * const pairs = await client.getAllOracleAssetPairs();
430
477
  * pairs.forEach(pair => {
431
478
  * console.log(`${pair.base.symbol}/${pair.quote.symbol}`);
432
- * console.log(` Base: ${pair.base.name}`);
433
- * console.log(` Quote: ${pair.quote.name}`);
479
+ * console.log(` Base: ${pair.base.name} (${pair.base.precision} decimals)`);
480
+ * console.log(` Quote: ${pair.quote.name} (${pair.quote.precision} decimals)`);
434
481
  * });
435
482
  * ```
436
483
  */
437
484
  abstract getAllOracleAssetPairs(): Promise<OracleAssetPair[]>;
438
485
  /**
439
- * Fetches the current price for a specific base/quote asset pair.
486
+ * Fetches the current price for a specific base/quote asset pair from the oracle.
440
487
  *
441
- * @param baseAssetSymbol - The chain symbol of the base asset (e.g., "aarch", "ibc/...")
442
- * @param quoteAssetSymbol - The chain symbol of the quote asset (e.g., "aarch", "ibc/...")
488
+ * @param baseAssetSymbol - The symbol of the base asset (e.g., "ARCH", "USDC")
489
+ * @param quoteAssetSymbol - The symbol of the quote asset (e.g., "ARCH", "USDC")
443
490
  *
444
491
  * @returns A promise that resolves to an invertible price object containing
445
- * the current price from the oracle
492
+ * the current price from the oracle and whether it's inverted
446
493
  *
447
494
  * @example
448
495
  * ```typescript
449
496
  * // Get price of ARCH in terms of USDC
450
- * const priceResult = await client.getPrice("aarch", "ibc/43897B9739BD63E3A08A88191999C632E052724AB96BD4C74AE31375C991F48D");
497
+ * const priceResult = await client.getPrice("ARCH", "USDC");
451
498
  * console.log(`1 ARCH = ${priceResult.price} USDC`);
499
+ * console.log(`Is inverted: ${priceResult.isInverse}`);
452
500
  * ```
453
501
  */
454
502
  abstract getPrice(baseAssetSymbol: string, quoteAssetSymbol: string): Promise<InvertiblePrice>;
@@ -456,14 +504,14 @@ declare abstract class BaseClient<TSigner = unknown> {
456
504
  * Fetches all available prices from the oracle.
457
505
  *
458
506
  * @returns A promise that resolves to an array of all current prices
459
- * available in the oracle with their respective asset pairs
507
+ * available in the oracle with their respective asset pairs and expiry times
460
508
  *
461
509
  * @example
462
510
  * ```typescript
463
511
  * const prices = await client.getAllPrices();
464
512
  * prices.forEach(priceData => {
465
513
  * console.log(`${priceData.assetPair}: ${priceData.price}`);
466
- * console.log(` Expires on: ${priceData.expiryTime}`);
514
+ * console.log(` Expires at: ${new Date(priceData.expiryTime * 1000).toISOString()}`);
467
515
  * });
468
516
  * ```
469
517
  */
@@ -479,6 +527,7 @@ declare abstract class BaseClient<TSigner = unknown> {
479
527
  * const routerConfig = await client.getRouterConfig();
480
528
  * console.log(`Default protocol fee: ${routerConfig.defaultProtocolFee * 100}%`);
481
529
  * console.log(`Default LP fee: ${routerConfig.defaultLpFee * 100}%`);
530
+ * console.log(`Oracle address: ${routerConfig.priceOracleContract}`);
482
531
  * ```
483
532
  */
484
533
  abstract getRouterConfig(): Promise<RouterConfig>;
@@ -486,17 +535,20 @@ declare abstract class BaseClient<TSigner = unknown> {
486
535
  * Fetches the total liquidity for all base assets across all pools.
487
536
  *
488
537
  * @returns A promise that resolves to a record mapping pool addresses
489
- * to their respective base asset liquidity amounts
538
+ * to their respective base asset liquidity details, including
539
+ * the base liquidity amount and total shares
490
540
  *
491
541
  * @example
492
542
  * ```typescript
493
543
  * const liquidity = await client.getAllBaseAssetsLiquidity();
494
- * Object.entries(liquidity).forEach(([poolAddress, coin]) => {
495
- * console.log(`Pool ${poolAddress}: ${coin.amount} ${coin.denom}`);
544
+ * Object.entries(liquidity).forEach(([poolAddress, details]) => {
545
+ * console.log(`Pool ${poolAddress}:`);
546
+ * console.log(` Base: ${details.baseLiquidity.amount} ${details.baseLiquidity.denom}`);
547
+ * console.log(` Total Shares: ${details.totalShares}`);
496
548
  * });
497
549
  * ```
498
550
  */
499
- abstract getAllBaseAssetsLiquidity(): Promise<Record<Address, Coin>>;
551
+ abstract getAllBaseAssetsLiquidity(): Promise<Record<Address, BaseLiquidityDetails>>;
500
552
  /**
501
553
  * Fetches all withdrawable quote assets for a specific user or liquidity provider.
502
554
  *
@@ -511,7 +563,7 @@ declare abstract class BaseClient<TSigner = unknown> {
511
563
  * Object.entries(quotes).forEach(([poolAddress, coins]) => {
512
564
  * console.log(`Pool ${poolAddress}:`);
513
565
  * coins.forEach(coin => {
514
- * console.log(` ${coin.amount} ${coin.symbol}`);
566
+ * console.log(` ${coin.amount} ${coin.denom}`);
515
567
  * });
516
568
  * });
517
569
  * ```
@@ -520,13 +572,15 @@ declare abstract class BaseClient<TSigner = unknown> {
520
572
  /**
521
573
  * Fetches pool information for a specific base asset.
522
574
  *
523
- * @param baseAssetSymbol - The symbol of the base asset (e.g., "aarch", "ibc/...")
575
+ * @param baseAssetSymbol - The symbol of the base asset (e.g., "ARCH", "ATOM")
524
576
  *
525
577
  * @returns A promise that resolves to the pool information for the specified asset
526
578
  *
579
+ * @throws Will throw an error if no pool exists for the specified base asset
580
+ *
527
581
  * @example
528
582
  * ```typescript
529
- * const pool = await client.getPoolByBaseAsset("aarch");
583
+ * const pool = await client.getPoolByBaseAsset("ARCH");
530
584
  * console.log(`Pool address: ${pool.poolAddress}`);
531
585
  * console.log(`Base asset: ${pool.baseAssetSymbol}`);
532
586
  * console.log('Available quote assets:');
@@ -541,8 +595,6 @@ declare abstract class BaseClient<TSigner = unknown> {
541
595
  *
542
596
  * @returns A promise that resolves to an array containing all pool information
543
597
  *
544
- * @throws Will throw an error if no pool exists for the specified base asset
545
- *
546
598
  * @example
547
599
  * ```typescript
548
600
  * const pools = await client.getAllPools();
@@ -578,35 +630,49 @@ declare abstract class BaseClient<TSigner = unknown> {
578
630
  */
579
631
  abstract getPoolConfig(poolContractAddress: string): Promise<PoolConfig>;
580
632
  /**
581
- * Fetches the configuration settings for a pool identified by its base asset symbol.
633
+ * Fetches all supported assets across all pools in the Bolt protocol.
582
634
  *
583
- * This method retrieves the pool configuration by first looking up the pool
584
- * associated with the given base asset, then fetching its configuration parameters.
635
+ * This method retrieves comprehensive information about all assets that can be traded,
636
+ * including their metadata, chain-specific details, and external identifiers.
585
637
  *
586
- * @param baseAssetSymbol - The symbol of the base asset (e.g., "aarch", "ibc/...")
587
- *
588
- * @returns A promise that resolves to a pool configuration object containing
589
- * settings such as fees, oracle address, LP addresses, and minimum trade amounts
590
- *
591
- * @throws Will throw an error if no pool exists for the specified base asset
638
+ * @returns A promise that resolves to an array of Asset objects, each containing:
639
+ * - symbol: The asset's trading symbol (e.g., "ARCH", "USDC")
640
+ * - name: The full name of the asset (e.g., "Archway", "USD Coin")
641
+ * - chainId: The blockchain network identifier where this asset exists
642
+ * - denom: The chain-specific denomination (e.g., "aarch", "ibc/...")
643
+ * - decimals: The number of decimal places for the asset
644
+ * - logo: Optional URL to the asset's logo image
645
+ * - coingeckoId: Optional CoinGecko identifier for price data
592
646
  *
593
647
  * @example
594
648
  * ```typescript
595
- * // Get pool configuration for ARCH base asset
596
- * const poolConfig = await client.getPoolConfigByBaseAsset("aarch");
597
- * console.log(`Oracle: ${poolConfig.priceOracleContract}`);
598
- * console.log(`Protocol fee: ${poolConfig.protocolFee * 100}%`);
599
- * console.log(`LP fee: ${poolConfig.lpFee * 100}%`);
600
- * console.log(`Allowance mode: ${poolConfig.allowanceMode}`);
601
- * console.log(`Number of LPs: ${poolConfig.lps.length}`);
602
- * console.log(`Min base output: ${poolConfig.minBaseOut}`);
649
+ * const assets = await client.getAllAssets();
650
+ *
651
+ * // Display all available assets
652
+ * assets.forEach(asset => {
653
+ * console.log(`${asset.symbol} (${asset.name})`);
654
+ * console.log(` Chain: ${asset.chainId}`);
655
+ * console.log(` Denom: ${asset.denom}`);
656
+ * console.log(` Decimals: ${asset.decimals}`);
657
+ * if (asset.coingeckoId) {
658
+ * console.log(` CoinGecko: ${asset.coingeckoId}`);
659
+ * }
660
+ * });
661
+ *
662
+ * // Find a specific asset
663
+ * const archAsset = assets.find(a => a.symbol === 'ARCH');
664
+ * console.log(`ARCH denom: ${archAsset?.denom}`);
603
665
  * ```
666
+ *
667
+ * @remarks
668
+ * Assets returned by this method represent all tokens available for trading
669
+ * in the Bolt protocol. The list may vary between mainnet and testnet environments.
604
670
  */
605
- abstract getPoolConfigByBaseAsset(baseAssetSymbol: string): Promise<PoolConfig>;
671
+ abstract getAllAssets(): Promise<Asset[]>;
606
672
  /**
607
- * Executes a "swap exact in" operation on the blockchain from one asset to another.
673
+ * Executes a swap operation on the blockchain from one asset to another.
608
674
  *
609
- * This method performs a swap where the exact input amount is specified, and the output
675
+ * This method performs a "swap exact in" where the exact input amount is specified, and the output
610
676
  * amount varies based on current pool conditions and fees. The transaction includes
611
677
  * slippage protection through the optional minimumAmountOut parameter.
612
678
  *
@@ -621,8 +687,11 @@ declare abstract class BaseClient<TSigner = unknown> {
621
687
  * @param params.receiver - Optional recipient address for the swapped assets.
622
688
  * If not provided, defaults to the signer's address.
623
689
  *
624
- * @returns A promise that resolves to the swap result containing transaction
625
- * details and the actual amount of output asset received
690
+ * @returns A promise that resolves to a SwapResult containing:
691
+ * - txOutput: Transaction execution details (type varies by implementation)
692
+ * - amountOut: The actual amount of output asset received (as a string)
693
+ * - assetOut: The denom of the asset received
694
+ * - txHash: The transaction hash
626
695
  *
627
696
  * @throws Will throw an error if the swap fails due to insufficient balance,
628
697
  * slippage exceeding tolerance, or other transaction errors
@@ -630,7 +699,7 @@ declare abstract class BaseClient<TSigner = unknown> {
630
699
  * @example
631
700
  * ```typescript
632
701
  * // Swap exactly 1 ARCH for USDC (output amount varies)
633
- * const result = await client.swapExactIn(signer, {
702
+ * const result = await client.swap(signer, {
634
703
  * assetIn: "aarch",
635
704
  * amountIn: "1000000000000000000", // Exactly 1 ARCH (18 decimals)
636
705
  * assetOut: "ibc/43897B9739BD63E3A08A88191999C632E052724AB96BD4C74AE31375C991F48D", // USDC IBC denom
@@ -639,7 +708,7 @@ declare abstract class BaseClient<TSigner = unknown> {
639
708
  * });
640
709
  *
641
710
  * console.log(`Swapped exactly 1 ARCH`);
642
- * console.log(`Received: ${result.amountOut} USDC`);
711
+ * console.log(`Received: ${result.amountOut} ${result.assetOut}`);
643
712
  * console.log(`Transaction: ${result.txHash}`);
644
713
  * ```
645
714
  *
@@ -649,95 +718,102 @@ declare abstract class BaseClient<TSigner = unknown> {
649
718
  * - The output amount depends on pool conditions
650
719
  * - Fees are deducted from the output
651
720
  * - Use minimumAmountOut to protect against excessive slippage
721
+ *
722
+ * The TTxOutput type parameter represents the transaction execution result type,
723
+ * which varies by blockchain implementation (e.g., ExecuteResult for CosmWasm).
652
724
  */
653
- abstract swapExactIn(signer: TSigner, params: SwapParams): Promise<SwapResult>;
725
+ abstract swap(signer: TSigner, params: SwapParams): Promise<SwapResult<TTxOutput>>;
654
726
  }
655
727
 
656
- interface CosmWasmClientConfig extends ClientConfig {
728
+ type CosmWasmChainConfig = ChainConfig & {
729
+ restEndpoint: string;
730
+ };
731
+
732
+ type CosmWasmClientConfig = ClientConfig<CosmWasmChainConfig> & {
657
733
  chain?: CosmWasmChain;
658
734
  cosmWasmClient?: CosmWasmClient | ArchwayClient;
659
735
  signingCosmWasmClient?: SigningCosmWasmClient | SigningArchwayClient;
660
- }
661
- declare enum CosmWasmChain {
662
- Archway = "archway"
663
- }
736
+ };
737
+ type CosmWasmChain = 'archway';
664
738
 
665
- interface QueryOracleConfigResponse {
739
+ type QueryOracleConfigResponse = {
666
740
  admin: Address;
667
741
  price_threshold_ratio: string;
668
742
  price_expire_time: Duration | null;
669
- }
670
- interface PriceRepresentation {
743
+ };
744
+ type PriceRepresentation = {
671
745
  asset_pair: AssetPairString;
672
746
  price: string;
673
747
  expiry_time: Timestamp;
674
- }
675
- interface InvertiblePriceRepresentation extends PriceRepresentation {
748
+ };
749
+ type InvertiblePriceRepresentation = PriceRepresentation & {
676
750
  is_inverse: boolean;
677
- }
678
- interface QueryPriceResponse {
751
+ };
752
+ type QueryPriceResponse = {
679
753
  pair_data: InvertiblePriceRepresentation;
680
- }
681
- interface QueryPricesResponse {
754
+ };
755
+ type QueryPricesResponse = {
682
756
  prices: PriceRepresentation[];
683
- }
684
- interface QueryAssetPairsResponse {
757
+ };
758
+ type QueryAssetPairsResponse = {
685
759
  list: OracleAssetPair[];
686
- }
760
+ };
687
761
 
688
- interface QueryRouterConfigResponse {
762
+ type QuerySettlementConfigResponse = {
763
+ price_oracle_contract: Address;
764
+ protocol_fee_recipient: Address;
765
+ protocol_fee: string;
766
+ lp_fee: string;
767
+ allowance_mode: AllowanceMode;
768
+ lps: Address[];
769
+ min_base_out: string;
770
+ };
771
+ type QueryBaseLiquidityResponse = {
772
+ base_liquidity: Coin;
773
+ total_shares: string;
774
+ };
775
+
776
+ type QueryRouterConfigResponse = {
689
777
  admin: Address;
690
778
  default_price_oracle_contract: Address;
691
779
  default_protocol_fee_recipient: Address;
692
780
  default_protocol_fee: string;
693
781
  default_lp_fee: string;
694
782
  settlement_code_id: number;
695
- }
696
- interface MarketRepresentation {
783
+ };
784
+ type MarketRepresentation = {
697
785
  market_address: Address;
698
786
  base_asset_symbol: string;
699
787
  quote_assets_symbols: string[];
700
- }
701
- interface QueryMarketsResponse {
788
+ };
789
+ type QueryMarketsResponse = {
702
790
  markets: MarketRepresentation[];
703
- }
704
- interface QueryBaseLiquidityAllResponse {
705
- liquidity: Record<Address, Coin>;
706
- }
707
- interface QueryQuotesForUserAllResponse {
791
+ };
792
+ type QueryBaseLiquidityAllResponse = {
793
+ liquidity: Record<Address, QueryBaseLiquidityResponse>;
794
+ };
795
+ type QueryQuotesForUserAllResponse = {
708
796
  quotes: Record<Address, Coin[]>;
709
- }
710
-
711
- interface QuerySettlementConfigResponse {
712
- price_oracle_contract: Address;
713
- protocol_fee_recipient: Address;
714
- protocol_fee: string;
715
- lp_fee: string;
716
- allowance_mode: AllowanceMode;
717
- lps: Address[];
718
- min_base_out: string;
719
- }
797
+ };
720
798
 
721
799
  /**
722
800
  * Client implementation for interacting with the Bolt Liquidity Outpost on CosmWasm-based blockchains.
723
801
  *
724
802
  * This class extends the abstract {@link BaseClient} to provide CosmWasm-specific functionality
725
803
  * for querying and executing transactions on Bolt Protocol's oracle and router smart contracts.
804
+ * It uses ExecuteResult as the transaction output type, providing detailed transaction execution information.
726
805
  *
727
- * @extends {BaseClient<OfflineSigner>}
806
+ * @extends {BaseClient<OfflineSigner, ExecuteResult>}
728
807
  *
729
808
  * @group Bolt API Clients
730
809
  *
731
810
  * @example
732
811
  * ```typescript
733
812
  * // Create a client for Archway mainnet
734
- * const client = new BoltCosmWasmClient({
735
- * environment: Environment.Mainnet,
736
- * chain: CosmWasmChain.Archway
737
- * });
813
+ * const client = new BoltCosmWasmClient();
738
814
  *
739
815
  * // Query oracle prices
740
- * const price = await client.getPrice("aarch", "ibc/43897B9739BD63E3A08A88191999C632E052724AB96BD4C74AE31375C991F48D");
816
+ * const price = await client.getPrice("ARCH", "USDC");
741
817
  *
742
818
  * // Execute a swap (requires signer)
743
819
  * const signer = await DirectSecp256k1HdWallet.fromMnemonic("my mnemonic goes here", {
@@ -750,7 +826,11 @@ interface QuerySettlementConfigResponse {
750
826
  * });
751
827
  * ```
752
828
  */
753
- declare class BoltCosmWasmClient extends BaseClient<OfflineSigner> {
829
+ declare class BoltCosmWasmClient extends BaseClient<OfflineSigner, ExecuteResult> {
830
+ /**
831
+ * The CosmWasm-specific chain configuration including REST endpoint
832
+ */
833
+ chainConfig: CosmWasmChainConfig;
754
834
  /**
755
835
  * Cached instance of the CosmWasm client for read-only operations
756
836
  * @private
@@ -769,18 +849,23 @@ declare class BoltCosmWasmClient extends BaseClient<OfflineSigner> {
769
849
  * Creates a new instance of the BoltCosmWasmClient.
770
850
  *
771
851
  * The client automatically configures itself based on the specified chain and environment,
772
- * loading the appropriate contract addresses and RPC endpoints from configuration files.
852
+ * loading the appropriate contract addresses, chain configuration, and assets from configuration files.
773
853
  *
774
854
  * @param config - (Optional) Configuration for the client
775
- * @param config.environment - (Optional) The deployment environment (Mainnet or Testnet). Defaults to Mainnet
776
- * @param config.chain - (Optional) The specific CosmWasm chain to connect to. Defaults to Archway
777
- * @param config.customOverride - (Optional) Overrides for RPC endpoint and contract addresses
778
- * @param config.customOverride.rpcEndpoint - (Optional) Custom RPC endpoint URL
779
- * @param config.customOverride.contracts - (Optional) Custom contract addresses
855
+ * @param config.environment - (Optional) The deployment environment ('mainnet' or 'testnet'). Defaults to 'mainnet'
856
+ * @param config.chain - (Optional) The specific CosmWasm chain to connect to. Defaults to 'archway'
857
+ * @param config.customOverride - (Optional) Custom overrides for chain configuration, contracts, and assets
858
+ * @param config.customOverride.chainConfig - (Optional) Override chain configuration
859
+ * @param config.customOverride.chainConfig.id - (Optional) Custom chain ID
860
+ * @param config.customOverride.chainConfig.name - (Optional) Custom chain name
861
+ * @param config.customOverride.chainConfig.rpcEndpoint - (Optional) Custom RPC endpoint URL
862
+ * @param config.customOverride.chainConfig.restEndpoint - (Optional) Custom REST endpoint URL
863
+ * @param config.customOverride.contracts - (Optional) Override contract addresses
780
864
  * @param config.customOverride.contracts.oracle - (Optional) Custom oracle contract address
781
865
  * @param config.customOverride.contracts.router - (Optional) Custom router contract address
782
- * @param config.customOverride.cosmWasmClient - (Optional) Custom CosmWasmClient to use for blockchain queries
783
- * @param config.customOverride.signingCosmWasmClient - (Optional) Custom SigningCosmWasmClient to use for blockchain transactions
866
+ * @param config.customOverride.assetsConfig - (Optional) Custom asset configurations indexed by denom
867
+ * @param config.cosmWasmClient - (Optional) Pre-existing CosmWasmClient to use for blockchain queries
868
+ * @param config.signingCosmWasmClient - (Optional) Pre-existing SigningCosmWasmClient to use for blockchain transactions
784
869
  *
785
870
  * @throws {InvalidTypeError} Thrown when an unsupported chain is specified
786
871
  *
@@ -791,15 +876,41 @@ declare class BoltCosmWasmClient extends BaseClient<OfflineSigner> {
791
876
  *
792
877
  * // Use testnet configuration
793
878
  * const testnetClient = new BoltCosmWasmClient({
794
- * environment: Environment.Testnet
879
+ * environment: 'testnet'
795
880
  * });
796
881
  *
797
- * // Use custom RPC endpoint
882
+ * // Use custom chain configuration
798
883
  * const customClient = new BoltCosmWasmClient({
799
- * override: {
800
- * rpcEndpoint: 'https://custom-rpc.example.com'
884
+ * customOverride: {
885
+ * chainConfig: {
886
+ * id: 'archway-custom-1',
887
+ * name: 'Archway Custom',
888
+ * rpcEndpoint: 'https://custom-rpc.example.com',
889
+ * restEndpoint: 'https://custom-rest.example.com'
890
+ * },
891
+ * contracts: {
892
+ * oracle: 'archway1custom_oracle...',
893
+ * router: 'archway1custom_router...'
894
+ * },
895
+ * assetsConfig: {
896
+ * 'aarch': {
897
+ * symbol: 'ARCH',
898
+ * name: 'Archway',
899
+ * chainId: 'archway-custom-1',
900
+ * denom: 'aarch',
901
+ * decimals: 18,
902
+ * logo: 'https://example.com/arch.png',
903
+ * coingeckoId: 'archway'
904
+ * }
905
+ * }
801
906
  * }
802
907
  * });
908
+ *
909
+ * // Use pre-existing CosmWasm clients
910
+ * const clientWithCustomClients = new BoltCosmWasmClient({
911
+ * cosmWasmClient: myCosmWasmClient,
912
+ * signingCosmWasmClient: mySigningClient
913
+ * });
803
914
  * ```
804
915
  */
805
916
  constructor(config?: CosmWasmClientConfig);
@@ -858,7 +969,7 @@ declare class BoltCosmWasmClient extends BaseClient<OfflineSigner> {
858
969
  /** @inheritdoc */
859
970
  getRouterConfig(): Promise<RouterConfig>;
860
971
  /** @inheritdoc */
861
- getAllBaseAssetsLiquidity(): Promise<Record<Address, Coin>>;
972
+ getAllBaseAssetsLiquidity(): Promise<Record<Address, BaseLiquidityDetails>>;
862
973
  /** @inheritdoc */
863
974
  getAllQuotesByUser(address: Address): Promise<Record<Address, Coin[]>>;
864
975
  /** @inheritdoc */
@@ -868,6 +979,33 @@ declare class BoltCosmWasmClient extends BaseClient<OfflineSigner> {
868
979
  /** @inheritdoc */
869
980
  getPoolConfig(poolContractAddress: Address): Promise<PoolConfig>;
870
981
  /** @inheritdoc */
982
+ getAllAssets(): Promise<Asset[]>;
983
+ /**
984
+ * Fetches the configuration settings for a pool identified by its base asset symbol.
985
+ *
986
+ * This is a convenience method that combines pool lookup and configuration retrieval.
987
+ * It first finds the pool associated with the given base asset, then fetches that
988
+ * pool's configuration parameters from its settlement contract.
989
+ *
990
+ * @param baseAssetSymbol - The symbol of the base asset (e.g., "ARCH", "ATOM")
991
+ *
992
+ * @returns A promise that resolves to a pool configuration object containing
993
+ * settings such as fees, oracle address, LP addresses, and minimum trade amounts
994
+ *
995
+ * @throws Will throw an error if no pool exists for the specified base asset
996
+ *
997
+ * @example
998
+ * ```typescript
999
+ * // Get pool configuration for ARCH base asset
1000
+ * const poolConfig = await client.getPoolConfigByBaseAsset("ARCH");
1001
+ * console.log(`Oracle: ${poolConfig.priceOracleContract}`);
1002
+ * console.log(`Protocol fee: ${parseFloat(poolConfig.protocolFee) * 100}%`);
1003
+ * console.log(`LP fee: ${parseFloat(poolConfig.lpFee) * 100}%`);
1004
+ * console.log(`Allowance mode: ${poolConfig.allowanceMode}`);
1005
+ * console.log(`Number of LPs: ${poolConfig.lps.length}`);
1006
+ * console.log(`Min base output: ${poolConfig.minBaseOut}`);
1007
+ * ```
1008
+ */
871
1009
  getPoolConfigByBaseAsset(baseAssetSymbol: string): Promise<PoolConfig>;
872
1010
  /**
873
1011
  * @inheritdoc
@@ -889,10 +1027,15 @@ declare class BoltCosmWasmClient extends BaseClient<OfflineSigner> {
889
1027
  * console.log(`Swap successful!`);
890
1028
  * console.log(`Transaction hash: ${result.txHash}`);
891
1029
  * console.log(`Received: ${result.amountOut} ${result.assetOut}`);
892
- * console.log(`Gas used: ${result.gasUsed}`);
1030
+ * console.log(`Gas used: ${result.txOutput.gasUsed}`);
1031
+ * console.log(`Block height: ${result.txOutput.height}`);
893
1032
  * ```
1033
+ *
1034
+ * @remarks
1035
+ * This implementation returns a CosmWasm ExecuteResult as the transaction output,
1036
+ * which includes details like gas used, block height, transaction hash, and events.
894
1037
  */
895
- swapExactIn(signer: OfflineSigner, params: SwapParams): Promise<SwapResult<ExecuteResult>>;
1038
+ swap(signer: OfflineSigner, params: SwapParams): Promise<SwapResult<ExecuteResult>>;
896
1039
  }
897
1040
 
898
- export { type Address, AllowanceMode, type AssetPairString, BaseClient, BoltCosmWasmClient, type BoltSdkError, BoltSdkErrorBase, BoltSdkErrorCode, type ClientConfig, type Coin, type Contracts, CosmWasmChain, type CosmWasmClientConfig, type Duration, Environment, InsufficientFundsError, InvalidAddressError, InvalidObjectError, InvalidParameterError, InvalidTypeError, type InvertiblePrice, type InvertiblePriceRepresentation, type MarketRepresentation, MissingParameterError, NetworkError, NotFoundError, type OracleAsset, type OracleAssetPair, type OracleConfig, ParameterOutOfRangeError, type Pool, type PoolConfig, type Price, type PriceRepresentation, type QueryAssetPairsResponse, type QueryBaseLiquidityAllResponse, type QueryMarketsResponse, type QueryOracleConfigResponse, type QueryPriceResponse, type QueryPricesResponse, type QueryQuotesForUserAllResponse, type QueryRouterConfigResponse, type QuerySettlementConfigResponse, type RouterConfig, type SwapParams, type SwapResult, type Timestamp, TransactionEventNotFoundError, TransactionFailedError };
1041
+ export { type Address, type AllowanceMode, type Asset, type AssetPairString, type AssetsConfig, BaseClient, type BaseLiquidityDetails, BoltCosmWasmClient, type BoltSdkError, BoltSdkErrorBase, BoltSdkErrorCode, type ChainConfig, type ClientConfig, type Coin, type Contracts, type CosmWasmChain, type CosmWasmChainConfig, type CosmWasmClientConfig, type Duration, type Environment, InsufficientFundsError, InvalidAddressError, InvalidObjectError, InvalidParameterError, InvalidTypeError, type InvertiblePrice, type InvertiblePriceRepresentation, type MarketRepresentation, MissingParameterError, NetworkError, NotFoundError, type OracleAsset, type OracleAssetPair, type OracleConfig, ParameterOutOfRangeError, type Pool, type PoolConfig, type Price, type PriceRepresentation, type QueryAssetPairsResponse, type QueryBaseLiquidityAllResponse, type QueryBaseLiquidityResponse, type QueryMarketsResponse, type QueryOracleConfigResponse, type QueryPriceResponse, type QueryPricesResponse, type QueryQuotesForUserAllResponse, type QueryRouterConfigResponse, type QuerySettlementConfigResponse, type RouterConfig, type SwapParams, type SwapResult, type Timestamp, TransactionEventNotFoundError, TransactionFailedError };