@bolt-liquidity-hq/cosmwasm-client 0.1.0-beta.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,872 @@
1
+ import { ArchwayClient, SigningArchwayClient } from '@archwayhq/arch3.js';
2
+ import { CosmWasmClient, SigningCosmWasmClient, ExecuteResult } from '@cosmjs/cosmwasm-stargate';
3
+ import { OfflineSigner } from '@cosmjs/proto-signing';
4
+
5
+ /**
6
+ * Error codes used throughout the Bolt SDK to categorize different types of errors.
7
+ *
8
+ * These codes help in programmatic error handling and provide a consistent way
9
+ * to identify error types across the SDK.
10
+ *
11
+ * @enum {number}
12
+ * @group Errors
13
+ * @category Error Types
14
+ *
15
+ * @example
16
+ * ```typescript
17
+ * import { BoltSdkErrorCode, BoltSdkError } from '@bolt-liquidity-hq/cosmwasm-client';
18
+ *
19
+ * try {
20
+ * await client.swapExactIn(signer, params);
21
+ * } catch (error) {
22
+ * if (error instanceof BoltSdkError) {
23
+ * switch (error.code) {
24
+ * case BoltSdkErrorCode.INVALID_ADDRESS:
25
+ * console.error("Invalid address format");
26
+ * break;
27
+ * case BoltSdkErrorCode.TRANSACTION_EVENT_NOT_FOUND:
28
+ * console.error("Transaction event not found");
29
+ * break;
30
+ * default:
31
+ * console.error("Operation failed:", error.message);
32
+ * }
33
+ * }
34
+ * }
35
+ * ```
36
+ */
37
+ declare enum BoltSdkErrorCode {
38
+ /** Resource not found (pools, assets, configurations) */
39
+ NOT_FOUND = 0,
40
+ /** Invalid object structure or missing required fields */
41
+ INVALID_OBJECT = 1,
42
+ /** Type mismatch or invalid type provided */
43
+ INVALID_TYPE = 2,
44
+ /** Insufficient balance to perform the operation */
45
+ INSUFFICIENT_FUNDS = 3,
46
+ /** Invalid blockchain address format */
47
+ INVALID_ADDRESS = 4,
48
+ /** Transaction reverted or failed on-chain */
49
+ TRANSACTION_FAILED = 5,
50
+ /** Expected transaction event not found in logs */
51
+ TRANSACTION_EVENT_NOT_FOUND = 6,
52
+ /** Network connectivity or RPC communication failure */
53
+ NETWORK_ERROR = 7,
54
+ /** Invalid parameter provided to a method */
55
+ INVALID_PARAMETER = 8,
56
+ /** Required parameter is missing */
57
+ MISSING_PARAMETER = 9,
58
+ /** Numeric value outside acceptable range */
59
+ PARAMETER_OUT_OF_RANGE = 10
60
+ }
61
+ /**
62
+ * Base interface for all Bolt SDK errors.
63
+ *
64
+ * All custom errors in the SDK implement this interface, providing
65
+ * a consistent error structure with error codes for easy handling.
66
+ *
67
+ * @interface
68
+ * @group Errors
69
+ * @category Error Types
70
+ */
71
+ interface BoltSdkError extends Error {
72
+ /** The error code categorizing this error */
73
+ code: BoltSdkErrorCode;
74
+ }
75
+ /**
76
+ * Base class for all custom errors in the Bolt SDK.
77
+ *
78
+ * This abstract base class provides common functionality for all SDK errors,
79
+ * including error code assignment and proper error name setting.
80
+ *
81
+ * @abstract
82
+ * @group Errors
83
+ * @category Error Classes
84
+ */
85
+ declare class BoltSdkErrorBase extends Error implements BoltSdkError {
86
+ code: BoltSdkErrorCode;
87
+ /**
88
+ * Creates a new BoltSdkErrorBase instance.
89
+ *
90
+ * @param code - The error code categorizing this error
91
+ * @param message - Human-readable error message
92
+ */
93
+ constructor(code: BoltSdkErrorCode, message: string);
94
+ }
95
+ /**
96
+ * Error thrown when a requested resource cannot be found.
97
+ *
98
+ * @group Errors
99
+ * @category Error Classes
100
+ */
101
+ declare class NotFoundError extends BoltSdkErrorBase {
102
+ /**
103
+ * Creates a new NotFoundError instance.
104
+ *
105
+ * @param resource - The type of resource that was not found
106
+ * @param details - Optional additional details about what was searched for
107
+ */
108
+ constructor(resource: string, details?: string);
109
+ }
110
+ /**
111
+ * Error thrown when an object doesn't have the expected structure.
112
+ *
113
+ * @group Errors
114
+ * @category Error Classes
115
+ */
116
+ declare class InvalidObjectError extends BoltSdkErrorBase {
117
+ /**
118
+ * Creates a new InvalidObjectError instance.
119
+ *
120
+ * @param details - Optional description of what is invalid about the object
121
+ */
122
+ constructor(details?: string);
123
+ }
124
+ /**
125
+ * Error thrown when an unexpected type is encountered.
126
+ *
127
+ * @group Errors
128
+ * @category Error Classes
129
+ */
130
+ declare class InvalidTypeError extends BoltSdkErrorBase {
131
+ /**
132
+ * Creates a new InvalidTypeError instance.
133
+ *
134
+ * @param expectedType - The type that was expected
135
+ * @param receivedType - The actual type that was received
136
+ */
137
+ constructor(expectedType: string, receivedType: string);
138
+ }
139
+ /**
140
+ * Error thrown when an account has insufficient funds for an operation.
141
+ *
142
+ * @group Errors
143
+ * @category Error Classes
144
+ */
145
+ declare class InsufficientFundsError extends BoltSdkErrorBase {
146
+ /**
147
+ * Creates a new InsufficientFundsError instance.
148
+ *
149
+ * @param required - The amount required for the operation
150
+ * @param available - The amount available in the account
151
+ */
152
+ constructor(required: number, available: number);
153
+ }
154
+ /**
155
+ * Error thrown when an invalid blockchain address is provided.
156
+ *
157
+ * @group Errors
158
+ * @category Error Classes
159
+ */
160
+ declare class InvalidAddressError extends BoltSdkErrorBase {
161
+ /**
162
+ * Creates a new InvalidAddressError instance.
163
+ *
164
+ * @param address - The invalid address that was provided
165
+ */
166
+ constructor(address: string);
167
+ }
168
+ /**
169
+ * Error thrown when a blockchain transaction fails or is reverted.
170
+ *
171
+ * @group Errors
172
+ * @category Error Classes
173
+ */
174
+ declare class TransactionFailedError extends BoltSdkErrorBase {
175
+ /**
176
+ * Creates a new TransactionFailedError instance.
177
+ *
178
+ * @param transactionId - The transaction hash or identifier
179
+ * @param details - Optional details about why the transaction failed
180
+ */
181
+ constructor(transactionId: string, details?: string);
182
+ }
183
+ /**
184
+ * Error thrown when an expected transaction event is not found in the logs.
185
+ *
186
+ * @group Errors
187
+ * @category Error Classes
188
+ */
189
+ declare class TransactionEventNotFoundError extends BoltSdkErrorBase {
190
+ /**
191
+ * Creates a new TransactionEventNotFoundError instance.
192
+ *
193
+ * @param eventName - The name of the event that was expected
194
+ * @param details - Optional details about the context
195
+ */
196
+ constructor(eventName: string, details?: string);
197
+ }
198
+ /**
199
+ * Error thrown when network communication fails.
200
+ *
201
+ * @group Errors
202
+ * @category Error Classes
203
+ */
204
+ declare class NetworkError extends BoltSdkErrorBase {
205
+ /**
206
+ * Creates a new NetworkError instance.
207
+ *
208
+ * @param details - Optional details about the network failure
209
+ */
210
+ constructor(details?: string);
211
+ }
212
+ /**
213
+ * Error thrown when an invalid parameter is provided to a method.
214
+ *
215
+ * @group Errors
216
+ * @category Error Classes
217
+ */
218
+ declare class InvalidParameterError<T = unknown> extends BoltSdkErrorBase {
219
+ /**
220
+ * Creates a new InvalidParameterError instance.
221
+ *
222
+ * @param parameterName - The name of the invalid parameter
223
+ * @param expected - Description of what was expected
224
+ * @param receivedValue - The actual value that was provided
225
+ * @param details - Optional additional details or constraints
226
+ *
227
+ * @template T - The type of the received value
228
+ */
229
+ constructor(parameterName: string, expected: string, receivedValue: T, details?: string);
230
+ }
231
+ /**
232
+ * Error thrown when a required parameter is missing.
233
+ *
234
+ * @group Errors
235
+ * @category Error Classes
236
+ */
237
+ declare class MissingParameterError extends BoltSdkErrorBase {
238
+ /**
239
+ * Creates a new MissingParameterError instance.
240
+ *
241
+ * @param parameterName - The name of the missing parameter
242
+ * @param context - Optional context about where the parameter was expected
243
+ */
244
+ constructor(parameterName: string, context?: string);
245
+ }
246
+ /**
247
+ * Error thrown when a numeric parameter is outside the acceptable range.
248
+ *
249
+ * @group Errors
250
+ * @category Error Classes
251
+ */
252
+ declare class ParameterOutOfRangeError extends BoltSdkErrorBase {
253
+ /**
254
+ * Creates a new ParameterOutOfRangeError instance.
255
+ *
256
+ * @param parameterName - The name of the parameter that's out of range
257
+ * @param value - The actual value that was provided
258
+ * @param min - Optional minimum acceptable value (inclusive)
259
+ * @param max - Optional maximum acceptable value (inclusive)
260
+ * @param details - Optional additional details about the constraint
261
+ */
262
+ constructor(parameterName: string, value: number | bigint, min?: number | bigint, max?: number | bigint, details?: string);
263
+ }
264
+
265
+ declare enum Environment {
266
+ Mainnet = "mainnet",
267
+ Testnet = "testnet"
268
+ }
269
+
270
+ type Address = string;
271
+ type AssetPairString = string;
272
+ type Timestamp = string;
273
+ interface Duration {
274
+ secs: string;
275
+ nanos: number;
276
+ }
277
+ interface Coin {
278
+ denom: string;
279
+ amount: string;
280
+ }
281
+
282
+ interface ClientConfig {
283
+ environment?: Environment;
284
+ override?: {
285
+ rpcEndpoint?: string;
286
+ contracts?: Partial<Contracts>;
287
+ };
288
+ }
289
+ interface Contracts {
290
+ oracle: Address;
291
+ router: Address;
292
+ }
293
+
294
+ interface OracleConfig {
295
+ admin: Address;
296
+ priceThresholdRatio: string;
297
+ priceExpireTime: Duration | null;
298
+ }
299
+ interface Price {
300
+ assetPair: AssetPairString;
301
+ price: string;
302
+ expiryTime: Timestamp;
303
+ }
304
+ interface InvertiblePrice extends Price {
305
+ isInverse: boolean;
306
+ }
307
+ interface OracleAsset {
308
+ name: string;
309
+ symbol: string;
310
+ precision: number;
311
+ }
312
+ interface OracleAssetPair {
313
+ base: OracleAsset;
314
+ quote: OracleAsset;
315
+ }
316
+
317
+ interface RouterConfig {
318
+ admin: Address;
319
+ defaultPriceOracleContract: Address;
320
+ defaultProtocolFeeRecipient: Address;
321
+ defaultProtocolFee: string;
322
+ defaultLpFee: string;
323
+ settlementCodeId: number;
324
+ }
325
+ interface Pool {
326
+ poolAddress: Address;
327
+ baseAssetSymbol: string;
328
+ quoteAssetsSymbols: string[];
329
+ }
330
+ interface SwapParams {
331
+ assetIn: string;
332
+ amountIn: string;
333
+ assetOut: string;
334
+ minimumAmountOut?: string;
335
+ receiver?: Address;
336
+ }
337
+ interface SwapResult<TTxOutput = unknown> {
338
+ txOutput: TTxOutput;
339
+ amountOut: string;
340
+ assetOut: string;
341
+ txHash: string;
342
+ }
343
+
344
+ /**
345
+ * Parses a coin string containing both amount and denomination into a structured Coin object.
346
+ *
347
+ * This utility function extracts the numeric amount and denomination from a concatenated string
348
+ * where amounts are represented as a single string
349
+ * (e.g., "1000000uatom", "500000000aconst").
350
+ *
351
+ * @param amountWithDenom - A string containing the amount immediately followed by the denomination,
352
+ * with no spaces or separators. The amount must be a positive integer
353
+ * (no decimals or scientific notation).
354
+ *
355
+ * @returns A Coin object containing:
356
+ * - amount: The numeric portion as a string
357
+ * - denom: The denomination portion as a string
358
+ *
359
+ * @throws {InvalidParameterError} Thrown when the input string doesn't match the expected format
360
+ * or when the amount or denomination cannot be extracted
361
+ *
362
+ * @example
363
+ * ```typescript
364
+ * // Parse a standard Cosmos coin string
365
+ * const coin = getCoinFromAmountWithDenomString("1000000uatom");
366
+ * console.log(coin); // { amount: "1000000", denom: "uatom" }
367
+ *
368
+ * // Parse an IBC token
369
+ * const ibcCoin = getCoinFromAmountWithDenomString("500000000ibc/34F8D3402273FFA5278AE5757D81CE151ACFD4B19C494C0EE372A7229714824F");
370
+ * console.log(ibcCoin); // { amount: "500000000", denom: "ibc/34F8D3402273FFA5278AE5757D81CE151ACFD4B19C494C0EE372A7229714824F" }
371
+ *
372
+ * // Parse a custom token
373
+ * const customCoin = getCoinFromAmountWithDenomString("123456789aconst");
374
+ * console.log(customCoin); // { amount: "123456789", denom: "aconst" }
375
+ * ```
376
+ *
377
+ * @example
378
+ * ```typescript
379
+ * // Invalid formats that will throw errors
380
+ * try {
381
+ * getCoinFromAmountWithDenomString("1000000"); // Missing denom
382
+ * } catch (error) {
383
+ * console.error("No denomination found");
384
+ * }
385
+ *
386
+ * try {
387
+ * getCoinFromAmountWithDenomString("uatom"); // Missing amount
388
+ * } catch (error) {
389
+ * console.error("No amount found");
390
+ * }
391
+ *
392
+ * try {
393
+ * getCoinFromAmountWithDenomString("1000000 uatom"); // Contains space
394
+ * } catch (error) {
395
+ * console.error("Invalid format");
396
+ * }
397
+ * ```
398
+ */
399
+ declare const getCoinFromAmountWithDenomString: (amountWithDenom: string) => Coin;
400
+
401
+ /**
402
+ * Abstract base client for all implementations of the Bolt SDK for different chains/networks.
403
+ *
404
+ * This class provides the foundation for blockchain-specific implementations,
405
+ * defining the core interface for interacting with oracle and router contracts.
406
+ *
407
+ * @template TSigner - The type of the transaction signer specific to the blockchain implementation
408
+ *
409
+ * @example
410
+ * ```typescript
411
+ * class BoltCosmWasmClient extends BaseClient<OfflineSigner> {
412
+ * // Implementation specific to CosmWasm
413
+ * }
414
+ * ```
415
+ */
416
+ declare abstract class BaseClient<TSigner = unknown> {
417
+ /**
418
+ * The RPC endpoint URL for connecting to the blockchain network
419
+ */
420
+ rpcEndpoint: Address;
421
+ /**
422
+ * Smart contract addresses for making Bolt queries and transactions in the blockchain
423
+ */
424
+ contracts: Contracts;
425
+ /**
426
+ * Creates a new instance of the BaseClient.
427
+ *
428
+ * @param config - Optional configuration object for the client
429
+ * @param config.override - Override configuration for RPC endpoint and contract addresses
430
+ * @param config.override.rpcEndpoint - The RPC endpoint URL for the blockchain network
431
+ * @param config.override.contracts - Contract addresses for oracle and router
432
+ * @param config.override.contracts.oracle - Address of the price oracle contract
433
+ * @param config.override.contracts.router - Address of the swap router contract
434
+ *
435
+ * @throws {InvalidObjectError} Thrown when required configuration fields are missing
436
+ *
437
+ * @example
438
+ * ```typescript
439
+ * const client = new ConcreteClient({
440
+ * override: {
441
+ * rpcEndpoint: 'https://rpc.example.com',
442
+ * contracts: {
443
+ * oracle: 'archway1...',
444
+ * router: 'archway1...'
445
+ * }
446
+ * }
447
+ * });
448
+ * ```
449
+ */
450
+ constructor(config?: ClientConfig);
451
+ /**
452
+ * Fetches the oracle configuration from the blockchain.
453
+ *
454
+ * @returns A promise that resolves to the oracle configuration containing
455
+ * settings such as price expiration time and threshold ratio
456
+ *
457
+ * @example
458
+ * ```typescript
459
+ * const oracleConfig = await client.getOracleConfig();
460
+ * console.log(`Price expiration: ${oracleConfig.priceExpireTime} seconds`);
461
+ * ```
462
+ */
463
+ abstract getOracleConfig(): Promise<OracleConfig>;
464
+ /**
465
+ * Fetches all asset pairs supported by the oracle.
466
+ *
467
+ * @returns A promise that resolves to an array of oracle asset pairs,
468
+ * each containing base and quote asset information with name, symbol and precision
469
+ *
470
+ * @example
471
+ * ```typescript
472
+ * const pairs = await client.getAllOracleAssetPairs();
473
+ * pairs.forEach(pair => {
474
+ * console.log(`${pair.base.symbol}/${pair.quote.symbol}`);
475
+ * console.log(` Base: ${pair.base.name}`);
476
+ * console.log(` Quote: ${pair.quote.name}`);
477
+ * });
478
+ * ```
479
+ */
480
+ abstract getAllOracleAssetPairs(): Promise<OracleAssetPair[]>;
481
+ /**
482
+ * Fetches the current price for a specific base/quote asset pair.
483
+ *
484
+ * @param baseAssetSymbol - The chain symbol of the base asset (e.g., "aconst", "ibc/...")
485
+ * @param quoteAssetSymbol - The chain symbol of the quote asset (e.g., "aconst", "ibc/...")
486
+ *
487
+ * @returns A promise that resolves to an invertible price object containing
488
+ * the current price from the oracle
489
+ *
490
+ * @example
491
+ * ```typescript
492
+ * // Get price of CONST in terms of USDC
493
+ * const priceResult = await client.getPrice("aconst", "ibc/34F8D3402273FFA5278AE5757D81CE151ACFD4B19C494C0EE372A7229714824F");
494
+ * console.log(`1 CONST = ${priceResult.price} USDC`);
495
+ * ```
496
+ */
497
+ abstract getPrice(baseAssetSymbol: string, quoteAssetSymbol: string): Promise<InvertiblePrice>;
498
+ /**
499
+ * Fetches all available prices from the oracle.
500
+ *
501
+ * @returns A promise that resolves to an array of all current prices
502
+ * available in the oracle with their respective asset pairs
503
+ *
504
+ * @example
505
+ * ```typescript
506
+ * const prices = await client.getAllPrices();
507
+ * prices.forEach(priceData => {
508
+ * console.log(`${priceData.assetPair}: ${priceData.price}`);
509
+ * console.log(` Expires on: ${priceData.expiryTime}`);
510
+ * });
511
+ * ```
512
+ */
513
+ abstract getAllPrices(): Promise<Price[]>;
514
+ /**
515
+ * Fetches the router configuration from the blockchain.
516
+ *
517
+ * @returns A promise that resolves to the router configuration containing
518
+ * settings such as default protocol fees, LP fees, and oracle configuration
519
+ *
520
+ * @example
521
+ * ```typescript
522
+ * const routerConfig = await client.getRouterConfig();
523
+ * console.log(`Default protocol fee: ${routerConfig.defaultProtocolFee * 100}%`);
524
+ * console.log(`Default LP fee: ${routerConfig.defaultLpFee * 100}%`);
525
+ * ```
526
+ */
527
+ abstract getRouterConfig(): Promise<RouterConfig>;
528
+ /**
529
+ * Fetches the total liquidity for all base assets across all pools.
530
+ *
531
+ * @returns A promise that resolves to a record mapping pool addresses
532
+ * to their respective base asset liquidity amounts
533
+ *
534
+ * @example
535
+ * ```typescript
536
+ * const liquidity = await client.getAllBaseAssetsLiquidity();
537
+ * Object.entries(liquidity).forEach(([poolAddress, coin]) => {
538
+ * console.log(`Pool ${poolAddress}: ${coin.amount} ${coin.denom}`);
539
+ * });
540
+ * ```
541
+ */
542
+ abstract getAllBaseAssetsLiquidity(): Promise<Record<Address, Coin>>;
543
+ /**
544
+ * Fetches all withdrawable quote assets for a specific user or liquidity provider.
545
+ *
546
+ * @param address - The blockchain address of the user or liquidity provider
547
+ *
548
+ * @returns A promise that resolves to a record mapping pool addresses
549
+ * to arrays of withdrawable quote asset coins
550
+ *
551
+ * @example
552
+ * ```typescript
553
+ * const quotes = await client.getAllQuotesByUser("archway1...");
554
+ * Object.entries(quotes).forEach(([poolAddress, coins]) => {
555
+ * console.log(`Pool ${poolAddress}:`);
556
+ * coins.forEach(coin => {
557
+ * console.log(` ${coin.amount} ${coin.symbol}`);
558
+ * });
559
+ * });
560
+ * ```
561
+ */
562
+ abstract getAllQuotesByUser(address: Address): Promise<Record<Address, Coin[]>>;
563
+ /**
564
+ * Fetches pool information for a specific base asset.
565
+ *
566
+ * @param baseAssetSymbol - The symbol of the base asset (e.g., "aconst", "ibc/...")
567
+ *
568
+ * @returns A promise that resolves to the pool information for the specified asset
569
+ *
570
+ * @example
571
+ * ```typescript
572
+ * const pool = await client.getPoolByBaseAsset("aconst");
573
+ * console.log(`Pool address: ${pool.poolAddress}`);
574
+ * console.log(`Base asset: ${pool.baseAssetSymbol}`);
575
+ * console.log('Available quote assets:');
576
+ * pool.quoteAssetsSymbols.forEach(symbol => {
577
+ * console.log(` - ${symbol}`);
578
+ * });
579
+ * ```
580
+ */
581
+ abstract getPoolByBaseAsset(baseAssetSymbol: string): Promise<Pool>;
582
+ /**
583
+ * Fetches information for all available pools.
584
+ *
585
+ * @returns A promise that resolves to an array containing all pool information
586
+ *
587
+ * @example
588
+ * ```typescript
589
+ * const pools = await client.getAllPools();
590
+ * pools.forEach(pool => {
591
+ * console.log(`Pool ${pool.poolAddress}:`);
592
+ * console.log(` Base: ${pool.baseAssetSymbol}`);
593
+ * console.log(` Quotes: ${pool.quoteAssetsSymbols.join(', ')}`);
594
+ * });
595
+ * ```
596
+ */
597
+ abstract getAllPools(): Promise<Pool[]>;
598
+ /**
599
+ * Executes a "swap exact in" operation on the blockchain from one asset to another.
600
+ *
601
+ * This method performs a swap where the exact input amount is specified, and the output
602
+ * amount varies based on current pool conditions and fees. The transaction includes
603
+ * slippage protection through the optional minimumAmountOut parameter.
604
+ *
605
+ * @param signer - The transaction signer that will authorize the swap operation.
606
+ * Must have sufficient balance of the input asset.
607
+ * @param params - The swap configuration parameters
608
+ * @param params.assetIn - The denom of the asset being sold (e.g., "aconst", "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., "aconst", "ibc/...")
611
+ * @param params.minimumAmountOut - Optional minimum acceptable amount of output asset.
612
+ * Transaction will fail if actual output would be less.
613
+ * @param params.receiver - Optional recipient address for the swapped assets.
614
+ * If not provided, defaults to the signer's address.
615
+ *
616
+ * @returns A promise that resolves to the swap result containing transaction
617
+ * details and the actual amount of output asset received
618
+ *
619
+ * @throws Will throw an error if the swap fails due to insufficient balance,
620
+ * slippage exceeding tolerance, or other transaction errors
621
+ *
622
+ * @example
623
+ * ```typescript
624
+ * // Swap exactly 1 CONST for USDC (output amount varies)
625
+ * const result = await client.swapExactIn(signer, {
626
+ * assetIn: "aconst",
627
+ * amountIn: "1000000000000000000", // Exactly 1 CONST (18 decimals)
628
+ * assetOut: "ibc/34F8D3402273FFA5278AE5757D81CE151ACFD4B19C494C0EE372A7229714824F", // USDC IBC denom
629
+ * minimumAmountOut: "1950000000", // Accept no less than 1950 USDC
630
+ * receiver: "archway1..." // Optional custom receiver
631
+ * });
632
+ *
633
+ * console.log(`Swapped exactly 1 CONST`);
634
+ * console.log(`Received: ${result.amountOut} USDC`);
635
+ * console.log(`Transaction: ${result.txHash}`);
636
+ * ```
637
+ *
638
+ * @remarks
639
+ * This is a "swap exact in" operation where:
640
+ * - The input amount is exactly what you specify
641
+ * - The output amount depends on pool conditions
642
+ * - Fees are deducted from the output
643
+ * - Use minimumAmountOut to protect against excessive slippage
644
+ */
645
+ abstract swapExactIn(signer: TSigner, params: SwapParams): Promise<SwapResult>;
646
+ }
647
+
648
+ interface CosmWasmClientConfig extends ClientConfig {
649
+ chain?: CosmWasmChain;
650
+ }
651
+ declare enum CosmWasmChain {
652
+ Archway = "archway"
653
+ }
654
+
655
+ interface QueryOracleConfigResponse {
656
+ admin: Address;
657
+ price_threshold_ratio: string;
658
+ price_expire_time: Duration | null;
659
+ }
660
+ interface PriceRepresentation {
661
+ asset_pair: AssetPairString;
662
+ price: string;
663
+ expiry_time: Timestamp;
664
+ }
665
+ interface InvertiblePriceRepresentation extends PriceRepresentation {
666
+ is_inverse: boolean;
667
+ }
668
+ interface QueryPriceResponse {
669
+ pair_data: InvertiblePriceRepresentation;
670
+ }
671
+ interface QueryPricesResponse {
672
+ prices: PriceRepresentation[];
673
+ }
674
+ interface QueryAssetPairsResponse {
675
+ list: OracleAssetPair[];
676
+ }
677
+
678
+ interface QueryRouterConfigResponse {
679
+ admin: Address;
680
+ default_price_oracle_contract: Address;
681
+ default_protocol_fee_recipient: Address;
682
+ default_protocol_fee: string;
683
+ default_lp_fee: string;
684
+ settlement_code_id: number;
685
+ }
686
+ interface MarketRepresentation {
687
+ market_address: Address;
688
+ base_asset_symbol: string;
689
+ quote_assets_symbols: string[];
690
+ }
691
+ interface QueryMarketsResponse {
692
+ markets: MarketRepresentation[];
693
+ }
694
+ interface QueryBaseLiquidityAllResponse {
695
+ liquidity: Record<Address, Coin>;
696
+ }
697
+ interface QueryQuotesForUserAllResponse {
698
+ quotes: Record<Address, Coin[]>;
699
+ }
700
+
701
+ /**
702
+ * Client implementation for interacting with the Bolt Liquidity Outpost on CosmWasm-based blockchains.
703
+ *
704
+ * This class extends the abstract {@link BaseClient} to provide CosmWasm-specific functionality
705
+ * for querying and executing transactions on Bolt Protocol's oracle and router smart contracts.
706
+ *
707
+ * @extends {BaseClient<OfflineSigner>}
708
+ *
709
+ * @group Bolt API Clients
710
+ *
711
+ * @example
712
+ * ```typescript
713
+ * // Create a client for Archway mainnet
714
+ * const client = new BoltCosmWasmClient({
715
+ * environment: Environment.Mainnet,
716
+ * chain: CosmWasmChain.Archway
717
+ * });
718
+ *
719
+ * // Query oracle prices
720
+ * const price = await client.getPrice("aconst", "ibc/34F8D3402273FFA5278AE5757D81CE151ACFD4B19C494C0EE372A7229714824F");
721
+ *
722
+ * // Execute a swap (requires signer)
723
+ * const signer = await DirectSecp256k1HdWallet.fromMnemonic("my mnemonic goes here", {
724
+ * prefix: 'archway',
725
+ * });
726
+ * const result = await client.swap(signer, {
727
+ * assetIn: "aconst",
728
+ * amountIn: "1000000",
729
+ * assetOut: "ibc/34F8D3402273FFA5278AE5757D81CE151ACFD4B19C494C0EE372A7229714824F"
730
+ * });
731
+ * ```
732
+ */
733
+ declare class BoltCosmWasmClient extends BaseClient<OfflineSigner> {
734
+ /**
735
+ * Cached instance of the CosmWasm client for read-only operations
736
+ * @private
737
+ */
738
+ private _cosmWasmClient?;
739
+ /**
740
+ * Cached instance of the signing CosmWasm client for transaction execution
741
+ * @private
742
+ */
743
+ private _signingCosmWasmClient?;
744
+ /**
745
+ * The specific CosmWasm chain this client is connected to
746
+ */
747
+ chain: CosmWasmChain;
748
+ /**
749
+ * Creates a new instance of the BoltCosmWasmClient.
750
+ *
751
+ * The client automatically configures itself based on the specified chain and environment,
752
+ * loading the appropriate contract addresses and RPC endpoints from configuration files.
753
+ *
754
+ * @param config - (Optional) Configuration for the client
755
+ * @param config.environment - (Optional) The deployment environment (Mainnet or Testnet). Defaults to Mainnet
756
+ * @param config.chain - (Optional) The specific CosmWasm chain to connect to. Defaults to Archway
757
+ * @param config.override - (Optional) Overrides for RPC endpoint and contract addresses
758
+ * @param config.override.rpcEndpoint - (Optional) Custom RPC endpoint URL
759
+ * @param config.override.contracts - (Optional) Custom contract addresses
760
+ * @param config.override.contracts.oracle - (Optional) Custom oracle contract address
761
+ * @param config.override.contracts.router - (Optional) Custom router contract address
762
+ *
763
+ * @throws {InvalidTypeError} Thrown when an unsupported chain is specified
764
+ *
765
+ * @example
766
+ * ```typescript
767
+ * // Use default configuration (Archway mainnet)
768
+ * const client = new BoltCosmWasmClient();
769
+ *
770
+ * // Use testnet configuration
771
+ * const testnetClient = new BoltCosmWasmClient({
772
+ * environment: Environment.Testnet
773
+ * });
774
+ *
775
+ * // Use custom RPC endpoint
776
+ * const customClient = new BoltCosmWasmClient({
777
+ * override: {
778
+ * rpcEndpoint: 'https://custom-rpc.example.com'
779
+ * }
780
+ * });
781
+ * ```
782
+ */
783
+ constructor(config?: CosmWasmClientConfig);
784
+ /**
785
+ * Gets or creates a CosmWasm client instance for read-only blockchain operations.
786
+ *
787
+ * This method implements lazy initialization and caching of the client instance.
788
+ * The appropriate client type (ArchwayClient or generic CosmWasmClient) is selected
789
+ * based on the configured chain.
790
+ *
791
+ * @returns A promise that resolves to the CosmWasm client instance
792
+ *
793
+ * @example
794
+ * ```typescript
795
+ * const client = await boltClient.getCosmWasmClient();
796
+ * const chainId = await client.getChainId();
797
+ * const height = await client.getHeight();
798
+ * ```
799
+ */
800
+ getCosmWasmClient(): Promise<CosmWasmClient | ArchwayClient>;
801
+ /**
802
+ * Gets or creates a signing CosmWasm client instance for transaction execution.
803
+ *
804
+ * This method implements lazy initialization and caching of the signing client.
805
+ * A signer must be provided either on first call or to replace the cached instance.
806
+ * The appropriate client type is selected based on the configured chain.
807
+ *
808
+ * @param signer - Optional offline signer for transaction signing. Required on first call
809
+ * or to replace the existing signer
810
+ *
811
+ * @returns A promise that resolves to the signing CosmWasm client instance
812
+ *
813
+ * @throws {MissingParameterError} Thrown when no signer is provided and no cached client exists
814
+ *
815
+ * @example
816
+ * ```typescript
817
+ * // First call requires a signer
818
+ * const signer = await DirectSecp256k1HdWallet.fromMnemonic("my mnemonic goes here", {
819
+ * prefix: 'archway',
820
+ * });
821
+ * const signingClient = await boltClient.getSigningCosmWasmClient(signer);
822
+ *
823
+ * // Subsequent calls can reuse the cached client
824
+ * const cachedClient = await boltClient.getSigningCosmWasmClient();
825
+ * ```
826
+ */
827
+ getSigningCosmWasmClient(signer?: OfflineSigner): Promise<SigningCosmWasmClient | SigningArchwayClient>;
828
+ /** @inheritdoc */
829
+ getOracleConfig(): Promise<OracleConfig>;
830
+ /** @inheritdoc */
831
+ getAllOracleAssetPairs(): Promise<OracleAssetPair[]>;
832
+ /** @inheritdoc */
833
+ getPrice(baseAssetSymbol: string, quoteAssetSymbol: string): Promise<InvertiblePrice>;
834
+ /** @inheritdoc */
835
+ getAllPrices(): Promise<Price[]>;
836
+ /** @inheritdoc */
837
+ getRouterConfig(): Promise<RouterConfig>;
838
+ /** @inheritdoc */
839
+ getAllBaseAssetsLiquidity(): Promise<Record<Address, Coin>>;
840
+ /** @inheritdoc */
841
+ getAllQuotesByUser(address: Address): Promise<Record<Address, Coin[]>>;
842
+ /** @inheritdoc */
843
+ getPoolByBaseAsset(baseAssetSymbol: string): Promise<Pool>;
844
+ /** @inheritdoc */
845
+ getAllPools(): Promise<Pool[]>;
846
+ /**
847
+ * @inheritdoc
848
+ *
849
+ * @example
850
+ * ```typescript
851
+ * // Get signer (e.g., from Keplr wallet)
852
+ * const signer = await window.keplr.getOfflineSignerAuto(chainId);
853
+ *
854
+ * // Execute swap: 1 CONST for USDC
855
+ * const result = await client.swap(signer, {
856
+ * assetIn: "aconst",
857
+ * amountIn: "1000000000000000000", // 1 CONST (18 decimals)
858
+ * assetOut: "ibc/34F8D3402273FFA5278AE5757D81CE151ACFD4B19C494C0EE372A7229714824F", // USDC IBC denom
859
+ * minimumAmountOut: "1950000000", // Minimum 1950 USDC expected
860
+ * receiver: "archway1..." // Optional custom receiver
861
+ * });
862
+ *
863
+ * console.log(`Swap successful!`);
864
+ * console.log(`Transaction hash: ${result.txHash}`);
865
+ * console.log(`Received: ${result.amountOut} ${result.assetOut}`);
866
+ * console.log(`Gas used: ${result.gasUsed}`);
867
+ * ```
868
+ */
869
+ swapExactIn(signer: OfflineSigner, params: SwapParams): Promise<SwapResult<ExecuteResult>>;
870
+ }
871
+
872
+ export { type Address, 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 Price, type PriceRepresentation, type QueryAssetPairsResponse, type QueryBaseLiquidityAllResponse, type QueryMarketsResponse, type QueryOracleConfigResponse, type QueryPriceResponse, type QueryPricesResponse, type QueryQuotesForUserAllResponse, type QueryRouterConfigResponse, type RouterConfig, type SwapParams, type SwapResult, type Timestamp, TransactionEventNotFoundError, TransactionFailedError, getCoinFromAmountWithDenomString };