@bolt-liquidity-hq/cosmwasm-client 0.1.0-beta.4 → 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.
- package/README.md +15 -4
- package/dist/index.cjs +5562 -106
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +233 -101
- package/dist/index.d.ts +233 -101
- package/dist/index.js +5562 -106
- package/dist/index.js.map +1 -1
- package/package.json +28 -55
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
|
|
@@ -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 =
|
|
46
|
+
NOT_FOUND = 1000,
|
|
40
47
|
/** Invalid object structure or missing required fields */
|
|
41
|
-
INVALID_OBJECT =
|
|
48
|
+
INVALID_OBJECT = 1001,
|
|
42
49
|
/** Type mismatch or invalid type provided */
|
|
43
|
-
INVALID_TYPE =
|
|
50
|
+
INVALID_TYPE = 1002,
|
|
44
51
|
/** Insufficient balance to perform the operation */
|
|
45
|
-
INSUFFICIENT_FUNDS =
|
|
52
|
+
INSUFFICIENT_FUNDS = 2000,
|
|
46
53
|
/** Invalid blockchain address format */
|
|
47
|
-
INVALID_ADDRESS =
|
|
54
|
+
INVALID_ADDRESS = 2001,
|
|
48
55
|
/** Transaction reverted or failed on-chain */
|
|
49
|
-
TRANSACTION_FAILED =
|
|
56
|
+
TRANSACTION_FAILED = 2002,
|
|
50
57
|
/** Expected transaction event not found in logs */
|
|
51
|
-
TRANSACTION_EVENT_NOT_FOUND =
|
|
58
|
+
TRANSACTION_EVENT_NOT_FOUND = 2003,
|
|
52
59
|
/** Network connectivity or RPC communication failure */
|
|
53
|
-
NETWORK_ERROR =
|
|
60
|
+
NETWORK_ERROR = 3000,
|
|
54
61
|
/** Invalid parameter provided to a method */
|
|
55
|
-
INVALID_PARAMETER =
|
|
62
|
+
INVALID_PARAMETER = 4000,
|
|
56
63
|
/** Required parameter is missing */
|
|
57
|
-
MISSING_PARAMETER =
|
|
64
|
+
MISSING_PARAMETER = 4001,
|
|
58
65
|
/** Numeric value outside acceptable range */
|
|
59
|
-
PARAMETER_OUT_OF_RANGE =
|
|
66
|
+
PARAMETER_OUT_OF_RANGE = 4002
|
|
60
67
|
}
|
|
61
68
|
/**
|
|
62
69
|
* Base interface for all Bolt SDK errors.
|
|
@@ -262,11 +269,6 @@ 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;
|
|
@@ -279,17 +281,35 @@ type Coin = {
|
|
|
279
281
|
amount: string;
|
|
280
282
|
};
|
|
281
283
|
|
|
282
|
-
type
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
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;
|
|
288
298
|
};
|
|
289
299
|
type Contracts = {
|
|
290
300
|
oracle: Address;
|
|
291
301
|
router: Address;
|
|
292
302
|
};
|
|
303
|
+
type AssetsConfig = Record<string, Asset>;
|
|
304
|
+
|
|
305
|
+
type ClientConfig<TChainConfig = ChainConfig> = {
|
|
306
|
+
environment?: Environment;
|
|
307
|
+
customOverride?: {
|
|
308
|
+
chainConfig?: Partial<TChainConfig>;
|
|
309
|
+
contracts?: Partial<Contracts>;
|
|
310
|
+
assetsConfig?: AssetsConfig;
|
|
311
|
+
};
|
|
312
|
+
};
|
|
293
313
|
|
|
294
314
|
type OracleConfig = {
|
|
295
315
|
admin: Address;
|
|
@@ -314,10 +334,7 @@ type OracleAssetPair = {
|
|
|
314
334
|
quote: OracleAsset;
|
|
315
335
|
};
|
|
316
336
|
|
|
317
|
-
|
|
318
|
-
Allow = "allow",
|
|
319
|
-
Disallow = "disallow"
|
|
320
|
-
}
|
|
337
|
+
type AllowanceMode = 'allow' | 'disallow';
|
|
321
338
|
type PoolConfig = {
|
|
322
339
|
priceOracleContract: Address;
|
|
323
340
|
protocolFeeRecipient: Address;
|
|
@@ -366,43 +383,67 @@ type SwapResult<TTxOutput = unknown> = {
|
|
|
366
383
|
* defining the core interface for interacting with oracle and router contracts.
|
|
367
384
|
*
|
|
368
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
|
|
369
387
|
*
|
|
370
388
|
* @example
|
|
371
389
|
* ```typescript
|
|
372
|
-
* class BoltCosmWasmClient extends BaseClient<OfflineSigner> {
|
|
390
|
+
* class BoltCosmWasmClient extends BaseClient<OfflineSigner, ExecuteResult> {
|
|
373
391
|
* // Implementation specific to CosmWasm
|
|
374
392
|
* }
|
|
375
393
|
* ```
|
|
376
394
|
*/
|
|
377
|
-
declare abstract class BaseClient<TSigner = unknown> {
|
|
395
|
+
declare abstract class BaseClient<TSigner = unknown, TTxOutput = unknown> {
|
|
378
396
|
/**
|
|
379
|
-
* The
|
|
397
|
+
* The blockchain network configuration containing chain ID, name, and RPC endpoint
|
|
380
398
|
*/
|
|
381
|
-
|
|
399
|
+
chainConfig: ChainConfig;
|
|
382
400
|
/**
|
|
383
401
|
* Smart contract addresses for making Bolt queries and transactions in the blockchain
|
|
384
402
|
*/
|
|
385
403
|
contracts: Contracts;
|
|
404
|
+
/**
|
|
405
|
+
* Configuration mapping of supported assets indexed by their symbol
|
|
406
|
+
*/
|
|
407
|
+
assetsConfig: AssetsConfig;
|
|
386
408
|
/**
|
|
387
409
|
* Creates a new instance of the BaseClient.
|
|
388
410
|
*
|
|
389
411
|
* @param config - (Optional) Configuration object for the client
|
|
390
|
-
* @param config.customOverride - (Optional) Override configuration
|
|
391
|
-
* @param config.customOverride.
|
|
392
|
-
* @param config.customOverride.
|
|
393
|
-
* @param config.customOverride.
|
|
394
|
-
* @param config.customOverride.
|
|
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
|
|
395
421
|
*
|
|
396
422
|
* @throws {InvalidObjectError} Thrown when required configuration fields are missing
|
|
397
423
|
*
|
|
398
424
|
* @example
|
|
399
425
|
* ```typescript
|
|
400
426
|
* const client = new ConcreteClient({
|
|
401
|
-
*
|
|
402
|
-
*
|
|
427
|
+
* customOverride: {
|
|
428
|
+
* chainConfig: {
|
|
429
|
+
* id: 'archway-1',
|
|
430
|
+
* name: 'Archway',
|
|
431
|
+
* rpcEndpoint: 'https://rpc.example.com'
|
|
432
|
+
* },
|
|
403
433
|
* contracts: {
|
|
404
|
-
* oracle: '
|
|
405
|
-
* router: '
|
|
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
|
+
* }
|
|
406
447
|
* }
|
|
407
448
|
* }
|
|
408
449
|
* });
|
|
@@ -419,6 +460,8 @@ declare abstract class BaseClient<TSigner = unknown> {
|
|
|
419
460
|
* ```typescript
|
|
420
461
|
* const oracleConfig = await client.getOracleConfig();
|
|
421
462
|
* console.log(`Price expiration: ${oracleConfig.priceExpireTime} seconds`);
|
|
463
|
+
* console.log(`Admin: ${oracleConfig.admin}`);
|
|
464
|
+
* console.log(`Price threshold ratio: ${oracleConfig.priceThresholdRatio}`);
|
|
422
465
|
* ```
|
|
423
466
|
*/
|
|
424
467
|
abstract getOracleConfig(): Promise<OracleConfig>;
|
|
@@ -433,26 +476,27 @@ declare abstract class BaseClient<TSigner = unknown> {
|
|
|
433
476
|
* const pairs = await client.getAllOracleAssetPairs();
|
|
434
477
|
* pairs.forEach(pair => {
|
|
435
478
|
* console.log(`${pair.base.symbol}/${pair.quote.symbol}`);
|
|
436
|
-
* console.log(` Base: ${pair.base.name}`);
|
|
437
|
-
* 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)`);
|
|
438
481
|
* });
|
|
439
482
|
* ```
|
|
440
483
|
*/
|
|
441
484
|
abstract getAllOracleAssetPairs(): Promise<OracleAssetPair[]>;
|
|
442
485
|
/**
|
|
443
|
-
* 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.
|
|
444
487
|
*
|
|
445
|
-
* @param baseAssetSymbol - The
|
|
446
|
-
* @param quoteAssetSymbol - The
|
|
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")
|
|
447
490
|
*
|
|
448
491
|
* @returns A promise that resolves to an invertible price object containing
|
|
449
|
-
* the current price from the oracle
|
|
492
|
+
* the current price from the oracle and whether it's inverted
|
|
450
493
|
*
|
|
451
494
|
* @example
|
|
452
495
|
* ```typescript
|
|
453
496
|
* // Get price of ARCH in terms of USDC
|
|
454
|
-
* const priceResult = await client.getPrice("
|
|
497
|
+
* const priceResult = await client.getPrice("ARCH", "USDC");
|
|
455
498
|
* console.log(`1 ARCH = ${priceResult.price} USDC`);
|
|
499
|
+
* console.log(`Is inverted: ${priceResult.isInverse}`);
|
|
456
500
|
* ```
|
|
457
501
|
*/
|
|
458
502
|
abstract getPrice(baseAssetSymbol: string, quoteAssetSymbol: string): Promise<InvertiblePrice>;
|
|
@@ -460,14 +504,14 @@ declare abstract class BaseClient<TSigner = unknown> {
|
|
|
460
504
|
* Fetches all available prices from the oracle.
|
|
461
505
|
*
|
|
462
506
|
* @returns A promise that resolves to an array of all current prices
|
|
463
|
-
* available in the oracle with their respective asset pairs
|
|
507
|
+
* available in the oracle with their respective asset pairs and expiry times
|
|
464
508
|
*
|
|
465
509
|
* @example
|
|
466
510
|
* ```typescript
|
|
467
511
|
* const prices = await client.getAllPrices();
|
|
468
512
|
* prices.forEach(priceData => {
|
|
469
513
|
* console.log(`${priceData.assetPair}: ${priceData.price}`);
|
|
470
|
-
* console.log(` Expires
|
|
514
|
+
* console.log(` Expires at: ${new Date(priceData.expiryTime * 1000).toISOString()}`);
|
|
471
515
|
* });
|
|
472
516
|
* ```
|
|
473
517
|
*/
|
|
@@ -483,6 +527,7 @@ declare abstract class BaseClient<TSigner = unknown> {
|
|
|
483
527
|
* const routerConfig = await client.getRouterConfig();
|
|
484
528
|
* console.log(`Default protocol fee: ${routerConfig.defaultProtocolFee * 100}%`);
|
|
485
529
|
* console.log(`Default LP fee: ${routerConfig.defaultLpFee * 100}%`);
|
|
530
|
+
* console.log(`Oracle address: ${routerConfig.priceOracleContract}`);
|
|
486
531
|
* ```
|
|
487
532
|
*/
|
|
488
533
|
abstract getRouterConfig(): Promise<RouterConfig>;
|
|
@@ -518,7 +563,7 @@ declare abstract class BaseClient<TSigner = unknown> {
|
|
|
518
563
|
* Object.entries(quotes).forEach(([poolAddress, coins]) => {
|
|
519
564
|
* console.log(`Pool ${poolAddress}:`);
|
|
520
565
|
* coins.forEach(coin => {
|
|
521
|
-
* console.log(` ${coin.amount} ${coin.
|
|
566
|
+
* console.log(` ${coin.amount} ${coin.denom}`);
|
|
522
567
|
* });
|
|
523
568
|
* });
|
|
524
569
|
* ```
|
|
@@ -527,13 +572,15 @@ declare abstract class BaseClient<TSigner = unknown> {
|
|
|
527
572
|
/**
|
|
528
573
|
* Fetches pool information for a specific base asset.
|
|
529
574
|
*
|
|
530
|
-
* @param baseAssetSymbol - The symbol of the base asset (e.g., "
|
|
575
|
+
* @param baseAssetSymbol - The symbol of the base asset (e.g., "ARCH", "ATOM")
|
|
531
576
|
*
|
|
532
577
|
* @returns A promise that resolves to the pool information for the specified asset
|
|
533
578
|
*
|
|
579
|
+
* @throws Will throw an error if no pool exists for the specified base asset
|
|
580
|
+
*
|
|
534
581
|
* @example
|
|
535
582
|
* ```typescript
|
|
536
|
-
* const pool = await client.getPoolByBaseAsset("
|
|
583
|
+
* const pool = await client.getPoolByBaseAsset("ARCH");
|
|
537
584
|
* console.log(`Pool address: ${pool.poolAddress}`);
|
|
538
585
|
* console.log(`Base asset: ${pool.baseAssetSymbol}`);
|
|
539
586
|
* console.log('Available quote assets:');
|
|
@@ -548,8 +595,6 @@ declare abstract class BaseClient<TSigner = unknown> {
|
|
|
548
595
|
*
|
|
549
596
|
* @returns A promise that resolves to an array containing all pool information
|
|
550
597
|
*
|
|
551
|
-
* @throws Will throw an error if no pool exists for the specified base asset
|
|
552
|
-
*
|
|
553
598
|
* @example
|
|
554
599
|
* ```typescript
|
|
555
600
|
* const pools = await client.getAllPools();
|
|
@@ -585,31 +630,45 @@ declare abstract class BaseClient<TSigner = unknown> {
|
|
|
585
630
|
*/
|
|
586
631
|
abstract getPoolConfig(poolContractAddress: string): Promise<PoolConfig>;
|
|
587
632
|
/**
|
|
588
|
-
* Fetches
|
|
633
|
+
* Fetches all supported assets across all pools in the Bolt protocol.
|
|
589
634
|
*
|
|
590
|
-
* This method retrieves
|
|
591
|
-
*
|
|
635
|
+
* This method retrieves comprehensive information about all assets that can be traded,
|
|
636
|
+
* including their metadata, chain-specific details, and external identifiers.
|
|
592
637
|
*
|
|
593
|
-
* @
|
|
594
|
-
*
|
|
595
|
-
*
|
|
596
|
-
*
|
|
597
|
-
*
|
|
598
|
-
*
|
|
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
|
|
599
646
|
*
|
|
600
647
|
* @example
|
|
601
648
|
* ```typescript
|
|
602
|
-
*
|
|
603
|
-
*
|
|
604
|
-
*
|
|
605
|
-
*
|
|
606
|
-
*
|
|
607
|
-
*
|
|
608
|
-
*
|
|
609
|
-
*
|
|
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}`);
|
|
610
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.
|
|
611
670
|
*/
|
|
612
|
-
abstract
|
|
671
|
+
abstract getAllAssets(): Promise<Asset[]>;
|
|
613
672
|
/**
|
|
614
673
|
* Executes a swap operation on the blockchain from one asset to another.
|
|
615
674
|
*
|
|
@@ -628,8 +687,11 @@ declare abstract class BaseClient<TSigner = unknown> {
|
|
|
628
687
|
* @param params.receiver - Optional recipient address for the swapped assets.
|
|
629
688
|
* If not provided, defaults to the signer's address.
|
|
630
689
|
*
|
|
631
|
-
* @returns A promise that resolves to
|
|
632
|
-
*
|
|
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
|
|
633
695
|
*
|
|
634
696
|
* @throws Will throw an error if the swap fails due to insufficient balance,
|
|
635
697
|
* slippage exceeding tolerance, or other transaction errors
|
|
@@ -646,7 +708,7 @@ declare abstract class BaseClient<TSigner = unknown> {
|
|
|
646
708
|
* });
|
|
647
709
|
*
|
|
648
710
|
* console.log(`Swapped exactly 1 ARCH`);
|
|
649
|
-
* console.log(`Received: ${result.amountOut}
|
|
711
|
+
* console.log(`Received: ${result.amountOut} ${result.assetOut}`);
|
|
650
712
|
* console.log(`Transaction: ${result.txHash}`);
|
|
651
713
|
* ```
|
|
652
714
|
*
|
|
@@ -656,18 +718,23 @@ declare abstract class BaseClient<TSigner = unknown> {
|
|
|
656
718
|
* - The output amount depends on pool conditions
|
|
657
719
|
* - Fees are deducted from the output
|
|
658
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).
|
|
659
724
|
*/
|
|
660
|
-
abstract swap(signer: TSigner, params: SwapParams): Promise<SwapResult
|
|
725
|
+
abstract swap(signer: TSigner, params: SwapParams): Promise<SwapResult<TTxOutput>>;
|
|
661
726
|
}
|
|
662
727
|
|
|
663
|
-
type
|
|
728
|
+
type CosmWasmChainConfig = ChainConfig & {
|
|
729
|
+
restEndpoint: string;
|
|
730
|
+
};
|
|
731
|
+
|
|
732
|
+
type CosmWasmClientConfig = ClientConfig<CosmWasmChainConfig> & {
|
|
664
733
|
chain?: CosmWasmChain;
|
|
665
734
|
cosmWasmClient?: CosmWasmClient | ArchwayClient;
|
|
666
735
|
signingCosmWasmClient?: SigningCosmWasmClient | SigningArchwayClient;
|
|
667
736
|
};
|
|
668
|
-
|
|
669
|
-
Archway = "archway"
|
|
670
|
-
}
|
|
737
|
+
type CosmWasmChain = 'archway';
|
|
671
738
|
|
|
672
739
|
type QueryOracleConfigResponse = {
|
|
673
740
|
admin: Address;
|
|
@@ -734,21 +801,19 @@ type QueryQuotesForUserAllResponse = {
|
|
|
734
801
|
*
|
|
735
802
|
* This class extends the abstract {@link BaseClient} to provide CosmWasm-specific functionality
|
|
736
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.
|
|
737
805
|
*
|
|
738
|
-
* @extends {BaseClient<OfflineSigner>}
|
|
806
|
+
* @extends {BaseClient<OfflineSigner, ExecuteResult>}
|
|
739
807
|
*
|
|
740
808
|
* @group Bolt API Clients
|
|
741
809
|
*
|
|
742
810
|
* @example
|
|
743
811
|
* ```typescript
|
|
744
812
|
* // Create a client for Archway mainnet
|
|
745
|
-
* const client = new BoltCosmWasmClient(
|
|
746
|
-
* environment: Environment.Mainnet,
|
|
747
|
-
* chain: CosmWasmChain.Archway
|
|
748
|
-
* });
|
|
813
|
+
* const client = new BoltCosmWasmClient();
|
|
749
814
|
*
|
|
750
815
|
* // Query oracle prices
|
|
751
|
-
* const price = await client.getPrice("
|
|
816
|
+
* const price = await client.getPrice("ARCH", "USDC");
|
|
752
817
|
*
|
|
753
818
|
* // Execute a swap (requires signer)
|
|
754
819
|
* const signer = await DirectSecp256k1HdWallet.fromMnemonic("my mnemonic goes here", {
|
|
@@ -761,7 +826,11 @@ type QueryQuotesForUserAllResponse = {
|
|
|
761
826
|
* });
|
|
762
827
|
* ```
|
|
763
828
|
*/
|
|
764
|
-
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;
|
|
765
834
|
/**
|
|
766
835
|
* Cached instance of the CosmWasm client for read-only operations
|
|
767
836
|
* @private
|
|
@@ -780,18 +849,23 @@ declare class BoltCosmWasmClient extends BaseClient<OfflineSigner> {
|
|
|
780
849
|
* Creates a new instance of the BoltCosmWasmClient.
|
|
781
850
|
*
|
|
782
851
|
* The client automatically configures itself based on the specified chain and environment,
|
|
783
|
-
* loading the appropriate contract addresses and
|
|
852
|
+
* loading the appropriate contract addresses, chain configuration, and assets from configuration files.
|
|
784
853
|
*
|
|
785
854
|
* @param config - (Optional) Configuration for the client
|
|
786
|
-
* @param config.environment - (Optional) The deployment environment (
|
|
787
|
-
* @param config.chain - (Optional) The specific CosmWasm chain to connect to. Defaults to
|
|
788
|
-
* @param config.customOverride - (Optional)
|
|
789
|
-
* @param config.customOverride.
|
|
790
|
-
* @param config.customOverride.
|
|
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
|
|
791
864
|
* @param config.customOverride.contracts.oracle - (Optional) Custom oracle contract address
|
|
792
865
|
* @param config.customOverride.contracts.router - (Optional) Custom router contract address
|
|
793
|
-
* @param config.customOverride.
|
|
794
|
-
* @param config.
|
|
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
|
|
795
869
|
*
|
|
796
870
|
* @throws {InvalidTypeError} Thrown when an unsupported chain is specified
|
|
797
871
|
*
|
|
@@ -802,15 +876,41 @@ declare class BoltCosmWasmClient extends BaseClient<OfflineSigner> {
|
|
|
802
876
|
*
|
|
803
877
|
* // Use testnet configuration
|
|
804
878
|
* const testnetClient = new BoltCosmWasmClient({
|
|
805
|
-
* environment:
|
|
879
|
+
* environment: 'testnet'
|
|
806
880
|
* });
|
|
807
881
|
*
|
|
808
|
-
* // Use custom
|
|
882
|
+
* // Use custom chain configuration
|
|
809
883
|
* const customClient = new BoltCosmWasmClient({
|
|
810
|
-
*
|
|
811
|
-
*
|
|
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
|
+
* }
|
|
812
906
|
* }
|
|
813
907
|
* });
|
|
908
|
+
*
|
|
909
|
+
* // Use pre-existing CosmWasm clients
|
|
910
|
+
* const clientWithCustomClients = new BoltCosmWasmClient({
|
|
911
|
+
* cosmWasmClient: myCosmWasmClient,
|
|
912
|
+
* signingCosmWasmClient: mySigningClient
|
|
913
|
+
* });
|
|
814
914
|
* ```
|
|
815
915
|
*/
|
|
816
916
|
constructor(config?: CosmWasmClientConfig);
|
|
@@ -879,6 +979,33 @@ declare class BoltCosmWasmClient extends BaseClient<OfflineSigner> {
|
|
|
879
979
|
/** @inheritdoc */
|
|
880
980
|
getPoolConfig(poolContractAddress: Address): Promise<PoolConfig>;
|
|
881
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
|
+
*/
|
|
882
1009
|
getPoolConfigByBaseAsset(baseAssetSymbol: string): Promise<PoolConfig>;
|
|
883
1010
|
/**
|
|
884
1011
|
* @inheritdoc
|
|
@@ -900,10 +1027,15 @@ declare class BoltCosmWasmClient extends BaseClient<OfflineSigner> {
|
|
|
900
1027
|
* console.log(`Swap successful!`);
|
|
901
1028
|
* console.log(`Transaction hash: ${result.txHash}`);
|
|
902
1029
|
* console.log(`Received: ${result.amountOut} ${result.assetOut}`);
|
|
903
|
-
* console.log(`Gas used: ${result.gasUsed}`);
|
|
1030
|
+
* console.log(`Gas used: ${result.txOutput.gasUsed}`);
|
|
1031
|
+
* console.log(`Block height: ${result.txOutput.height}`);
|
|
904
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.
|
|
905
1037
|
*/
|
|
906
1038
|
swap(signer: OfflineSigner, params: SwapParams): Promise<SwapResult<ExecuteResult>>;
|
|
907
1039
|
}
|
|
908
1040
|
|
|
909
|
-
export { type Address, AllowanceMode, type AssetPairString, BaseClient, type BaseLiquidityDetails, 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 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 };
|
|
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 };
|