@bolt-liquidity-hq/core 0.1.0-beta.6

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,781 @@
1
+ type Address = string;
2
+ type AssetPairString = string;
3
+ type Timestamp = string;
4
+ type Duration = {
5
+ secs: number;
6
+ nanos: number;
7
+ };
8
+ type Coin = {
9
+ denom: string;
10
+ amount: string;
11
+ };
12
+
13
+ type Environment = 'mainnet' | 'testnet';
14
+ type Asset = {
15
+ symbol: string;
16
+ name: string;
17
+ chainId: string;
18
+ denom: string;
19
+ decimals: number;
20
+ logo?: string;
21
+ coingeckoId?: string;
22
+ };
23
+ type ChainConfig = {
24
+ name: string;
25
+ id: string;
26
+ rpcEndpoint: string;
27
+ };
28
+ type Contracts = {
29
+ oracle: Address;
30
+ router: Address;
31
+ };
32
+ type AssetsConfig = Record<string, Asset>;
33
+
34
+ type ClientConfig<TChainConfig = ChainConfig> = {
35
+ environment?: Environment;
36
+ customOverride?: {
37
+ chainConfig?: Partial<TChainConfig>;
38
+ contracts?: Partial<Contracts>;
39
+ assetsConfig?: AssetsConfig;
40
+ };
41
+ };
42
+
43
+ type OracleConfig = {
44
+ admin: Address;
45
+ priceThresholdRatio: string;
46
+ priceExpireTime: Duration | null;
47
+ };
48
+ type Price = {
49
+ assetPair: AssetPairString;
50
+ price: string;
51
+ expiryTime: Timestamp;
52
+ };
53
+ type InvertiblePrice = Price & {
54
+ isInverse: boolean;
55
+ };
56
+ type OracleAsset = {
57
+ name: string;
58
+ symbol: string;
59
+ precision: number;
60
+ };
61
+ type OracleAssetPair = {
62
+ base: OracleAsset;
63
+ quote: OracleAsset;
64
+ };
65
+
66
+ type AllowanceMode = 'allow' | 'disallow';
67
+ type PoolConfig = {
68
+ priceOracleContract: Address;
69
+ protocolFeeRecipient: Address;
70
+ protocolFee: string;
71
+ lpFee: string;
72
+ allowanceMode: AllowanceMode;
73
+ lps: Address[];
74
+ minBaseOut: string;
75
+ };
76
+ type BaseLiquidityDetails = {
77
+ baseLiquidity: Coin;
78
+ totalShares: string;
79
+ };
80
+
81
+ type RouterConfig = {
82
+ admin: Address;
83
+ defaultPriceOracleContract: Address;
84
+ defaultProtocolFeeRecipient: Address;
85
+ defaultProtocolFee: string;
86
+ defaultLpFee: string;
87
+ settlementCodeId: number;
88
+ };
89
+ type Pool = {
90
+ poolAddress: Address;
91
+ baseAssetSymbol: string;
92
+ quoteAssetsSymbols: string[];
93
+ };
94
+ type SwapParams = {
95
+ assetIn: string;
96
+ amountIn: string;
97
+ assetOut: string;
98
+ minimumAmountOut?: string;
99
+ receiver?: Address;
100
+ };
101
+ type SwapResult<TTxOutput = unknown> = {
102
+ txOutput: TTxOutput;
103
+ amountOut: string;
104
+ assetOut: string;
105
+ txHash: string;
106
+ };
107
+
108
+ /**
109
+ * Parses a coin string containing both amount and denomination into a structured Coin object.
110
+ *
111
+ * This utility function extracts the numeric amount and denomination from a concatenated string
112
+ * where amounts are represented as a single string
113
+ * (e.g., "1000000uatom", "500000000aarch").
114
+ *
115
+ * @param amountWithDenom - A string containing the amount immediately followed by the denomination,
116
+ * with no spaces or separators. The amount must be a positive integer
117
+ * (no decimals or scientific notation).
118
+ *
119
+ * @returns A Coin object containing:
120
+ * - amount: The numeric portion as a string
121
+ * - denom: The denomination portion as a string
122
+ *
123
+ * @throws {InvalidParameterError} Thrown when the input string doesn't match the expected format
124
+ * or when the amount or denomination cannot be extracted
125
+ *
126
+ * @example
127
+ * ```typescript
128
+ * // Parse a standard Cosmos coin string
129
+ * const coin = getCoinFromAmountWithDenomString("1000000uatom");
130
+ * console.log(coin); // { amount: "1000000", denom: "uatom" }
131
+ *
132
+ * // Parse an IBC token
133
+ * const ibcCoin = getCoinFromAmountWithDenomString("500000000ibc/43897B9739BD63E3A08A88191999C632E052724AB96BD4C74AE31375C991F48D");
134
+ * console.log(ibcCoin); // { amount: "500000000", denom: "ibc/43897B9739BD63E3A08A88191999C632E052724AB96BD4C74AE31375C991F48D" }
135
+ *
136
+ * // Parse a custom token
137
+ * const customCoin = getCoinFromAmountWithDenomString("123456789aarch");
138
+ * console.log(customCoin); // { amount: "123456789", denom: "aarch" }
139
+ * ```
140
+ *
141
+ * @example
142
+ * ```typescript
143
+ * // Invalid formats that will throw errors
144
+ * try {
145
+ * getCoinFromAmountWithDenomString("1000000"); // Missing denom
146
+ * } catch (error) {
147
+ * console.error("No denomination found");
148
+ * }
149
+ *
150
+ * try {
151
+ * getCoinFromAmountWithDenomString("uatom"); // Missing amount
152
+ * } catch (error) {
153
+ * console.error("No amount found");
154
+ * }
155
+ *
156
+ * try {
157
+ * getCoinFromAmountWithDenomString("1000000 uatom"); // Contains space
158
+ * } catch (error) {
159
+ * console.error("Invalid format");
160
+ * }
161
+ * ```
162
+ */
163
+ declare const getCoinFromAmountWithDenomString: (amountWithDenom: string) => Coin;
164
+
165
+ /**
166
+ * Abstract base client for all implementations of the Bolt SDK for different chains/networks.
167
+ *
168
+ * This class provides the foundation for blockchain-specific implementations,
169
+ * defining the core interface for interacting with oracle and router contracts.
170
+ *
171
+ * @template TSigner - The type of the transaction signer specific to the blockchain implementation
172
+ * @template TTxOutput - The type of the transaction output specific to the blockchain implementation
173
+ *
174
+ * @example
175
+ * ```typescript
176
+ * class BoltCosmWasmClient extends BaseClient<OfflineSigner, ExecuteResult> {
177
+ * // Implementation specific to CosmWasm
178
+ * }
179
+ * ```
180
+ */
181
+ declare abstract class BaseClient<TSigner = unknown, TTxOutput = unknown> {
182
+ /**
183
+ * The blockchain network configuration containing chain ID, name, and RPC endpoint
184
+ */
185
+ chainConfig: ChainConfig;
186
+ /**
187
+ * Smart contract addresses for making Bolt queries and transactions in the blockchain
188
+ */
189
+ contracts: Contracts;
190
+ /**
191
+ * Configuration mapping of supported assets indexed by their symbol
192
+ */
193
+ assetsConfig: AssetsConfig;
194
+ /**
195
+ * Creates a new instance of the BaseClient.
196
+ *
197
+ * @param config - (Optional) Configuration object for the client
198
+ * @param config.customOverride - (Optional) Override configuration containing chain settings, contracts, and assets
199
+ * @param config.customOverride.chainConfig - (Optional) Chain configuration object
200
+ * @param config.customOverride.chainConfig.id - (Optional) The chain ID of the blockchain network (e.g., "archway-1")
201
+ * @param config.customOverride.chainConfig.name - (Optional) The human-readable name of the chain (e.g., "Archway")
202
+ * @param config.customOverride.chainConfig.rpcEndpoint - (Optional) RPC endpoint URL for the blockchain network
203
+ * @param config.customOverride.contracts - (Optional) Contract addresses for oracle and router
204
+ * @param config.customOverride.contracts.oracle - (Optional) Oracle contract address
205
+ * @param config.customOverride.contracts.router - (Optional) Router contract address
206
+ * @param config.customOverride.assetsConfig - (Optional) Configuration for supported assets indexed by symbol
207
+ *
208
+ * @throws {InvalidObjectError} Thrown when required configuration fields are missing
209
+ *
210
+ * @example
211
+ * ```typescript
212
+ * const client = new ConcreteClient({
213
+ * customOverride: {
214
+ * chainConfig: {
215
+ * id: 'archway-1',
216
+ * name: 'Archway',
217
+ * rpcEndpoint: 'https://rpc.example.com'
218
+ * },
219
+ * contracts: {
220
+ * oracle: 'archway1oracle...',
221
+ * router: 'archway1router...'
222
+ * },
223
+ * assetsConfig: {
224
+ * 'ARCH': {
225
+ * symbol: 'ARCH',
226
+ * name: 'Archway',
227
+ * chainId: 'archway-1',
228
+ * denom: 'aarch',
229
+ * decimals: 18,
230
+ * logo: 'https://...',
231
+ * coingeckoId: 'archway'
232
+ * }
233
+ * }
234
+ * }
235
+ * });
236
+ * ```
237
+ */
238
+ constructor(config?: ClientConfig);
239
+ /**
240
+ * Fetches the oracle configuration from the blockchain.
241
+ *
242
+ * @returns A promise that resolves to the oracle configuration containing
243
+ * settings such as price expiration time and threshold ratio
244
+ *
245
+ * @example
246
+ * ```typescript
247
+ * const oracleConfig = await client.getOracleConfig();
248
+ * console.log(`Price expiration: ${oracleConfig.priceExpireTime} seconds`);
249
+ * console.log(`Admin: ${oracleConfig.admin}`);
250
+ * console.log(`Price threshold ratio: ${oracleConfig.priceThresholdRatio}`);
251
+ * ```
252
+ */
253
+ abstract getOracleConfig(): Promise<OracleConfig>;
254
+ /**
255
+ * Fetches all asset pairs supported by the oracle.
256
+ *
257
+ * @returns A promise that resolves to an array of oracle asset pairs,
258
+ * each containing base and quote asset information with name, symbol and precision
259
+ *
260
+ * @example
261
+ * ```typescript
262
+ * const pairs = await client.getAllOracleAssetPairs();
263
+ * pairs.forEach(pair => {
264
+ * console.log(`${pair.base.symbol}/${pair.quote.symbol}`);
265
+ * console.log(` Base: ${pair.base.name} (${pair.base.precision} decimals)`);
266
+ * console.log(` Quote: ${pair.quote.name} (${pair.quote.precision} decimals)`);
267
+ * });
268
+ * ```
269
+ */
270
+ abstract getAllOracleAssetPairs(): Promise<OracleAssetPair[]>;
271
+ /**
272
+ * Fetches the current price for a specific base/quote asset pair from the oracle.
273
+ *
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")
276
+ *
277
+ * @returns A promise that resolves to an invertible price object containing
278
+ * the current price from the oracle and whether it's inverted
279
+ *
280
+ * @example
281
+ * ```typescript
282
+ * // Get price of ARCH in terms of USDC
283
+ * const priceResult = await client.getPrice("ARCH", "USDC");
284
+ * console.log(`1 ARCH = ${priceResult.price} USDC`);
285
+ * console.log(`Is inverted: ${priceResult.isInverse}`);
286
+ * ```
287
+ */
288
+ abstract getPrice(baseAssetSymbol: string, quoteAssetSymbol: string): Promise<InvertiblePrice>;
289
+ /**
290
+ * Fetches all available prices from the oracle.
291
+ *
292
+ * @returns A promise that resolves to an array of all current prices
293
+ * available in the oracle with their respective asset pairs and expiry times
294
+ *
295
+ * @example
296
+ * ```typescript
297
+ * const prices = await client.getAllPrices();
298
+ * prices.forEach(priceData => {
299
+ * console.log(`${priceData.assetPair}: ${priceData.price}`);
300
+ * console.log(` Expires at: ${new Date(priceData.expiryTime * 1000).toISOString()}`);
301
+ * });
302
+ * ```
303
+ */
304
+ abstract getAllPrices(): Promise<Price[]>;
305
+ /**
306
+ * Fetches the router configuration from the blockchain.
307
+ *
308
+ * @returns A promise that resolves to the router configuration containing
309
+ * settings such as default protocol fees, LP fees, and oracle configuration
310
+ *
311
+ * @example
312
+ * ```typescript
313
+ * const routerConfig = await client.getRouterConfig();
314
+ * console.log(`Default protocol fee: ${routerConfig.defaultProtocolFee * 100}%`);
315
+ * console.log(`Default LP fee: ${routerConfig.defaultLpFee * 100}%`);
316
+ * console.log(`Oracle address: ${routerConfig.priceOracleContract}`);
317
+ * ```
318
+ */
319
+ abstract getRouterConfig(): Promise<RouterConfig>;
320
+ /**
321
+ * Fetches the total liquidity for all base assets across all pools.
322
+ *
323
+ * @returns A promise that resolves to a record mapping pool addresses
324
+ * to their respective base asset liquidity details, including
325
+ * the base liquidity amount and total shares
326
+ *
327
+ * @example
328
+ * ```typescript
329
+ * const liquidity = await client.getAllBaseAssetsLiquidity();
330
+ * Object.entries(liquidity).forEach(([poolAddress, details]) => {
331
+ * console.log(`Pool ${poolAddress}:`);
332
+ * console.log(` Base: ${details.baseLiquidity.amount} ${details.baseLiquidity.denom}`);
333
+ * console.log(` Total Shares: ${details.totalShares}`);
334
+ * });
335
+ * ```
336
+ */
337
+ abstract getAllBaseAssetsLiquidity(): Promise<Record<Address, BaseLiquidityDetails>>;
338
+ /**
339
+ * Fetches all withdrawable quote assets for a specific user or liquidity provider.
340
+ *
341
+ * @param address - The blockchain address of the user or liquidity provider
342
+ *
343
+ * @returns A promise that resolves to a record mapping pool addresses
344
+ * to arrays of withdrawable quote asset coins
345
+ *
346
+ * @example
347
+ * ```typescript
348
+ * const quotes = await client.getAllQuotesByUser("archway1...");
349
+ * Object.entries(quotes).forEach(([poolAddress, coins]) => {
350
+ * console.log(`Pool ${poolAddress}:`);
351
+ * coins.forEach(coin => {
352
+ * console.log(` ${coin.amount} ${coin.denom}`);
353
+ * });
354
+ * });
355
+ * ```
356
+ */
357
+ abstract getAllQuotesByUser(address: Address): Promise<Record<Address, Coin[]>>;
358
+ /**
359
+ * Fetches pool information for a specific base asset.
360
+ *
361
+ * @param baseAssetSymbol - The symbol of the base asset (e.g., "ARCH", "ATOM")
362
+ *
363
+ * @returns A promise that resolves to the pool information for the specified asset
364
+ *
365
+ * @throws Will throw an error if no pool exists for the specified base asset
366
+ *
367
+ * @example
368
+ * ```typescript
369
+ * const pool = await client.getPoolByBaseAsset("ARCH");
370
+ * console.log(`Pool address: ${pool.poolAddress}`);
371
+ * console.log(`Base asset: ${pool.baseAssetSymbol}`);
372
+ * console.log('Available quote assets:');
373
+ * pool.quoteAssetsSymbols.forEach(symbol => {
374
+ * console.log(` - ${symbol}`);
375
+ * });
376
+ * ```
377
+ */
378
+ abstract getPoolByBaseAsset(baseAssetSymbol: string): Promise<Pool>;
379
+ /**
380
+ * Fetches information for all available pools.
381
+ *
382
+ * @returns A promise that resolves to an array containing all pool information
383
+ *
384
+ * @example
385
+ * ```typescript
386
+ * const pools = await client.getAllPools();
387
+ * pools.forEach(pool => {
388
+ * console.log(`Pool ${pool.poolAddress}:`);
389
+ * console.log(` Base: ${pool.baseAssetSymbol}`);
390
+ * console.log(` Quotes: ${pool.quoteAssetsSymbols.join(', ')}`);
391
+ * });
392
+ * ```
393
+ */
394
+ abstract getAllPools(): Promise<Pool[]>;
395
+ /**
396
+ * Fetches the configuration settings for a specific liquidity pool.
397
+ *
398
+ * This method retrieves detailed configuration parameters for a pool, including
399
+ * fee structures, oracle settings, liquidity provider information, and trading limits.
400
+ *
401
+ * @param poolContractAddress - The blockchain address of the pool contract
402
+ *
403
+ * @returns A promise that resolves to a pool configuration object
404
+ * containing settings such as fees, oracle address, LP addresses, and minimum trade amounts
405
+ *
406
+ * @example
407
+ * ```typescript
408
+ * const poolConfig = await client.getPoolConfig("archway1pool...");
409
+ * console.log(`Oracle: ${poolConfig.priceOracleContract}`);
410
+ * console.log(`Protocol fee: ${poolConfig.protocolFee * 100}%`);
411
+ * console.log(`LP fee: ${poolConfig.lpFee * 100}%`);
412
+ * console.log(`Allowance mode: ${poolConfig.allowanceMode}`);
413
+ * console.log(`LPs: ${poolConfig.lps.join(', ')}`);
414
+ * console.log(`Min base output: ${poolConfig.minBaseOut}`);
415
+ * ```
416
+ */
417
+ abstract getPoolConfig(poolContractAddress: string): Promise<PoolConfig>;
418
+ /**
419
+ * Fetches all supported assets across all pools in the Bolt protocol.
420
+ *
421
+ * This method retrieves comprehensive information about all assets that can be traded,
422
+ * including their metadata, chain-specific details, and external identifiers.
423
+ *
424
+ * @returns A promise that resolves to an array of Asset objects, each containing:
425
+ * - symbol: The asset's trading symbol (e.g., "ARCH", "USDC")
426
+ * - name: The full name of the asset (e.g., "Archway", "USD Coin")
427
+ * - chainId: The blockchain network identifier where this asset exists
428
+ * - denom: The chain-specific denomination (e.g., "aarch", "ibc/...")
429
+ * - decimals: The number of decimal places for the asset
430
+ * - logo: Optional URL to the asset's logo image
431
+ * - coingeckoId: Optional CoinGecko identifier for price data
432
+ *
433
+ * @example
434
+ * ```typescript
435
+ * const assets = await client.getAllAssets();
436
+ *
437
+ * // Display all available assets
438
+ * assets.forEach(asset => {
439
+ * console.log(`${asset.symbol} (${asset.name})`);
440
+ * console.log(` Chain: ${asset.chainId}`);
441
+ * console.log(` Denom: ${asset.denom}`);
442
+ * console.log(` Decimals: ${asset.decimals}`);
443
+ * if (asset.coingeckoId) {
444
+ * console.log(` CoinGecko: ${asset.coingeckoId}`);
445
+ * }
446
+ * });
447
+ *
448
+ * // Find a specific asset
449
+ * const archAsset = assets.find(a => a.symbol === 'ARCH');
450
+ * console.log(`ARCH denom: ${archAsset?.denom}`);
451
+ * ```
452
+ *
453
+ * @remarks
454
+ * Assets returned by this method represent all tokens available for trading
455
+ * in the Bolt protocol. The list may vary between mainnet and testnet environments.
456
+ */
457
+ abstract getAllAssets(): Promise<Asset[]>;
458
+ /**
459
+ * Executes a swap operation on the blockchain from one asset to another.
460
+ *
461
+ * This method performs a "swap exact in" where the exact input amount is specified, and the output
462
+ * amount varies based on current pool conditions and fees. The transaction includes
463
+ * slippage protection through the optional minimumAmountOut parameter.
464
+ *
465
+ * @param signer - The transaction signer that will authorize the swap operation.
466
+ * Must have sufficient balance of the input asset.
467
+ * @param params - The swap configuration parameters
468
+ * @param params.assetIn - The denom of the asset being sold (e.g., "aarch", "ibc/...")
469
+ * @param params.amountIn - The exact amount of input asset to swap (in minimal denomination)
470
+ * @param params.assetOut - The denom of the asset being bought (e.g., "aarch", "ibc/...")
471
+ * @param params.minimumAmountOut - Optional minimum acceptable amount of output asset.
472
+ * Transaction will fail if actual output would be less.
473
+ * @param params.receiver - Optional recipient address for the swapped assets.
474
+ * If not provided, defaults to the signer's address.
475
+ *
476
+ * @returns A promise that resolves to a SwapResult containing:
477
+ * - txOutput: Transaction execution details (type varies by implementation)
478
+ * - amountOut: The actual amount of output asset received (as a string)
479
+ * - assetOut: The denom of the asset received
480
+ * - txHash: The transaction hash
481
+ *
482
+ * @throws Will throw an error if the swap fails due to insufficient balance,
483
+ * slippage exceeding tolerance, or other transaction errors
484
+ *
485
+ * @example
486
+ * ```typescript
487
+ * // Swap exactly 1 ARCH for USDC (output amount varies)
488
+ * const result = await client.swap(signer, {
489
+ * assetIn: "aarch",
490
+ * amountIn: "1000000000000000000", // Exactly 1 ARCH (18 decimals)
491
+ * assetOut: "ibc/43897B9739BD63E3A08A88191999C632E052724AB96BD4C74AE31375C991F48D", // USDC IBC denom
492
+ * minimumAmountOut: "1950000000", // Accept no less than 1950 USDC
493
+ * receiver: "archway1..." // Optional custom receiver
494
+ * });
495
+ *
496
+ * console.log(`Swapped exactly 1 ARCH`);
497
+ * console.log(`Received: ${result.amountOut} ${result.assetOut}`);
498
+ * console.log(`Transaction: ${result.txHash}`);
499
+ * ```
500
+ *
501
+ * @remarks
502
+ * This is a "swap exact in" operation where:
503
+ * - The input amount is exactly what you specify
504
+ * - The output amount depends on pool conditions
505
+ * - Fees are deducted from the output
506
+ * - Use minimumAmountOut to protect against excessive slippage
507
+ *
508
+ * The TTxOutput type parameter represents the transaction execution result type,
509
+ * which varies by blockchain implementation (e.g., ExecuteResult for CosmWasm).
510
+ */
511
+ abstract swap(signer: TSigner, params: SwapParams): Promise<SwapResult<TTxOutput>>;
512
+ }
513
+
514
+ /**
515
+ * Error codes used throughout the Bolt SDK to categorize different types of errors.
516
+ *
517
+ * These codes help in programmatic error handling and provide a consistent way
518
+ * to identify error types across the SDK. Error codes are organized into ranges
519
+ * by category for easier identification and handling.
520
+ *
521
+ * Error Code Ranges:
522
+ * - 1000-1999: Resource & Data Errors
523
+ * - 2000-2999: Blockchain Transaction Errors
524
+ * - 3000-3999: Infrastructure & Network Errors
525
+ * - 4000-4999: Validation & Input Errors
526
+ *
527
+ * @enum {number}
528
+ * @group Errors
529
+ * @category Error Types
530
+ *
531
+ * @example
532
+ * ```typescript
533
+ * import { BoltSdkErrorCode, BoltSdkError } from '@bolt-liquidity-hq/cosmwasm-client';
534
+ *
535
+ * try {
536
+ * await client.swap(signer, params);
537
+ * } catch (error) {
538
+ * if (error instanceof BoltSdkError) {
539
+ * switch (error.code) {
540
+ * case BoltSdkErrorCode.INVALID_ADDRESS:
541
+ * console.error("Invalid address format");
542
+ * break;
543
+ * case BoltSdkErrorCode.TRANSACTION_EVENT_NOT_FOUND:
544
+ * console.error("Transaction event not found");
545
+ * break;
546
+ * default:
547
+ * console.error("Operation failed:", error.message);
548
+ * }
549
+ * }
550
+ * }
551
+ * ```
552
+ */
553
+ declare enum BoltSdkErrorCode {
554
+ /** Resource not found (pools, assets, configurations) */
555
+ NOT_FOUND = 1000,
556
+ /** Invalid object structure or missing required fields */
557
+ INVALID_OBJECT = 1001,
558
+ /** Type mismatch or invalid type provided */
559
+ INVALID_TYPE = 1002,
560
+ /** Insufficient balance to perform the operation */
561
+ INSUFFICIENT_FUNDS = 2000,
562
+ /** Invalid blockchain address format */
563
+ INVALID_ADDRESS = 2001,
564
+ /** Transaction reverted or failed on-chain */
565
+ TRANSACTION_FAILED = 2002,
566
+ /** Expected transaction event not found in logs */
567
+ TRANSACTION_EVENT_NOT_FOUND = 2003,
568
+ /** Network connectivity or RPC communication failure */
569
+ NETWORK_ERROR = 3000,
570
+ /** Invalid parameter provided to a method */
571
+ INVALID_PARAMETER = 4000,
572
+ /** Required parameter is missing */
573
+ MISSING_PARAMETER = 4001,
574
+ /** Numeric value outside acceptable range */
575
+ PARAMETER_OUT_OF_RANGE = 4002
576
+ }
577
+ /**
578
+ * Base interface for all Bolt SDK errors.
579
+ *
580
+ * All custom errors in the SDK implement this interface, providing
581
+ * a consistent error structure with error codes for easy handling.
582
+ *
583
+ * @interface
584
+ * @group Errors
585
+ * @category Error Types
586
+ */
587
+ interface BoltSdkError extends Error {
588
+ /** The error code categorizing this error */
589
+ code: BoltSdkErrorCode;
590
+ }
591
+ /**
592
+ * Base class for all custom errors in the Bolt SDK.
593
+ *
594
+ * This abstract base class provides common functionality for all SDK errors,
595
+ * including error code assignment and proper error name setting.
596
+ *
597
+ * @abstract
598
+ * @group Errors
599
+ * @category Error Classes
600
+ */
601
+ declare class BoltSdkErrorBase extends Error implements BoltSdkError {
602
+ code: BoltSdkErrorCode;
603
+ /**
604
+ * Creates a new BoltSdkErrorBase instance.
605
+ *
606
+ * @param code - The error code categorizing this error
607
+ * @param message - Human-readable error message
608
+ */
609
+ constructor(code: BoltSdkErrorCode, message: string);
610
+ }
611
+ /**
612
+ * Error thrown when a requested resource cannot be found.
613
+ *
614
+ * @group Errors
615
+ * @category Error Classes
616
+ */
617
+ declare class NotFoundError extends BoltSdkErrorBase {
618
+ /**
619
+ * Creates a new NotFoundError instance.
620
+ *
621
+ * @param resource - The type of resource that was not found
622
+ * @param details - Optional additional details about what was searched for
623
+ */
624
+ constructor(resource: string, details?: string);
625
+ }
626
+ /**
627
+ * Error thrown when an object doesn't have the expected structure.
628
+ *
629
+ * @group Errors
630
+ * @category Error Classes
631
+ */
632
+ declare class InvalidObjectError extends BoltSdkErrorBase {
633
+ /**
634
+ * Creates a new InvalidObjectError instance.
635
+ *
636
+ * @param details - Optional description of what is invalid about the object
637
+ */
638
+ constructor(details?: string);
639
+ }
640
+ /**
641
+ * Error thrown when an unexpected type is encountered.
642
+ *
643
+ * @group Errors
644
+ * @category Error Classes
645
+ */
646
+ declare class InvalidTypeError extends BoltSdkErrorBase {
647
+ /**
648
+ * Creates a new InvalidTypeError instance.
649
+ *
650
+ * @param expectedType - The type that was expected
651
+ * @param receivedType - The actual type that was received
652
+ */
653
+ constructor(expectedType: string, receivedType: string);
654
+ }
655
+ /**
656
+ * Error thrown when an account has insufficient funds for an operation.
657
+ *
658
+ * @group Errors
659
+ * @category Error Classes
660
+ */
661
+ declare class InsufficientFundsError extends BoltSdkErrorBase {
662
+ /**
663
+ * Creates a new InsufficientFundsError instance.
664
+ *
665
+ * @param required - The amount required for the operation
666
+ * @param available - The amount available in the account
667
+ */
668
+ constructor(required: number, available: number);
669
+ }
670
+ /**
671
+ * Error thrown when an invalid blockchain address is provided.
672
+ *
673
+ * @group Errors
674
+ * @category Error Classes
675
+ */
676
+ declare class InvalidAddressError extends BoltSdkErrorBase {
677
+ /**
678
+ * Creates a new InvalidAddressError instance.
679
+ *
680
+ * @param address - The invalid address that was provided
681
+ */
682
+ constructor(address: string);
683
+ }
684
+ /**
685
+ * Error thrown when a blockchain transaction fails or is reverted.
686
+ *
687
+ * @group Errors
688
+ * @category Error Classes
689
+ */
690
+ declare class TransactionFailedError extends BoltSdkErrorBase {
691
+ /**
692
+ * Creates a new TransactionFailedError instance.
693
+ *
694
+ * @param transactionId - The transaction hash or identifier
695
+ * @param details - Optional details about why the transaction failed
696
+ */
697
+ constructor(transactionId: string, details?: string);
698
+ }
699
+ /**
700
+ * Error thrown when an expected transaction event is not found in the logs.
701
+ *
702
+ * @group Errors
703
+ * @category Error Classes
704
+ */
705
+ declare class TransactionEventNotFoundError extends BoltSdkErrorBase {
706
+ /**
707
+ * Creates a new TransactionEventNotFoundError instance.
708
+ *
709
+ * @param eventName - The name of the event that was expected
710
+ * @param details - Optional details about the context
711
+ */
712
+ constructor(eventName: string, details?: string);
713
+ }
714
+ /**
715
+ * Error thrown when network communication fails.
716
+ *
717
+ * @group Errors
718
+ * @category Error Classes
719
+ */
720
+ declare class NetworkError extends BoltSdkErrorBase {
721
+ /**
722
+ * Creates a new NetworkError instance.
723
+ *
724
+ * @param details - Optional details about the network failure
725
+ */
726
+ constructor(details?: string);
727
+ }
728
+ /**
729
+ * Error thrown when an invalid parameter is provided to a method.
730
+ *
731
+ * @group Errors
732
+ * @category Error Classes
733
+ */
734
+ declare class InvalidParameterError<T = unknown> extends BoltSdkErrorBase {
735
+ /**
736
+ * Creates a new InvalidParameterError instance.
737
+ *
738
+ * @param parameterName - The name of the invalid parameter
739
+ * @param expected - Description of what was expected
740
+ * @param receivedValue - The actual value that was provided
741
+ * @param details - Optional additional details or constraints
742
+ *
743
+ * @template T - The type of the received value
744
+ */
745
+ constructor(parameterName: string, expected: string, receivedValue: T, details?: string);
746
+ }
747
+ /**
748
+ * Error thrown when a required parameter is missing.
749
+ *
750
+ * @group Errors
751
+ * @category Error Classes
752
+ */
753
+ declare class MissingParameterError extends BoltSdkErrorBase {
754
+ /**
755
+ * Creates a new MissingParameterError instance.
756
+ *
757
+ * @param parameterName - The name of the missing parameter
758
+ * @param context - Optional context about where the parameter was expected
759
+ */
760
+ constructor(parameterName: string, context?: string);
761
+ }
762
+ /**
763
+ * Error thrown when a numeric parameter is outside the acceptable range.
764
+ *
765
+ * @group Errors
766
+ * @category Error Classes
767
+ */
768
+ declare class ParameterOutOfRangeError extends BoltSdkErrorBase {
769
+ /**
770
+ * Creates a new ParameterOutOfRangeError instance.
771
+ *
772
+ * @param parameterName - The name of the parameter that's out of range
773
+ * @param value - The actual value that was provided
774
+ * @param min - Optional minimum acceptable value (inclusive)
775
+ * @param max - Optional maximum acceptable value (inclusive)
776
+ * @param details - Optional additional details about the constraint
777
+ */
778
+ constructor(parameterName: string, value: number | bigint, min?: number | bigint, max?: number | bigint, details?: string);
779
+ }
780
+
781
+ 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 };