@bolt-liquidity-hq/cosmwasm-client 0.1.0-beta.2 → 0.1.0-beta.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.cts CHANGED
@@ -17,7 +17,7 @@ import { OfflineSigner } from '@cosmjs/proto-signing';
17
17
  * import { BoltSdkErrorCode, BoltSdkError } from '@bolt-liquidity-hq/cosmwasm-client';
18
18
  *
19
19
  * try {
20
- * await client.swapExactIn(signer, params);
20
+ * await client.swap(signer, params);
21
21
  * } catch (error) {
22
22
  * if (error instanceof BoltSdkError) {
23
23
  * switch (error.code) {
@@ -270,76 +270,94 @@ declare enum Environment {
270
270
  type Address = string;
271
271
  type AssetPairString = string;
272
272
  type Timestamp = string;
273
- interface Duration {
274
- secs: string;
273
+ type Duration = {
274
+ secs: number;
275
275
  nanos: number;
276
- }
277
- interface Coin {
276
+ };
277
+ type Coin = {
278
278
  denom: string;
279
279
  amount: string;
280
- }
280
+ };
281
281
 
282
- interface ClientConfig {
282
+ type ClientConfig = {
283
283
  environment?: Environment;
284
- override?: {
284
+ customOverride?: {
285
285
  rpcEndpoint?: string;
286
286
  contracts?: Partial<Contracts>;
287
287
  };
288
- }
289
- interface Contracts {
288
+ };
289
+ type Contracts = {
290
290
  oracle: Address;
291
291
  router: Address;
292
- }
292
+ };
293
293
 
294
- interface OracleConfig {
294
+ type OracleConfig = {
295
295
  admin: Address;
296
296
  priceThresholdRatio: string;
297
297
  priceExpireTime: Duration | null;
298
- }
299
- interface Price {
298
+ };
299
+ type Price = {
300
300
  assetPair: AssetPairString;
301
301
  price: string;
302
302
  expiryTime: Timestamp;
303
- }
304
- interface InvertiblePrice extends Price {
303
+ };
304
+ type InvertiblePrice = Price & {
305
305
  isInverse: boolean;
306
- }
307
- interface OracleAsset {
306
+ };
307
+ type OracleAsset = {
308
308
  name: string;
309
309
  symbol: string;
310
310
  precision: number;
311
- }
312
- interface OracleAssetPair {
311
+ };
312
+ type OracleAssetPair = {
313
313
  base: OracleAsset;
314
314
  quote: OracleAsset;
315
- }
315
+ };
316
+
317
+ declare enum AllowanceMode {
318
+ Allow = "allow",
319
+ Disallow = "disallow"
320
+ }
321
+ type PoolConfig = {
322
+ priceOracleContract: Address;
323
+ protocolFeeRecipient: Address;
324
+ protocolFee: string;
325
+ lpFee: string;
326
+ allowanceMode: AllowanceMode;
327
+ lps: Address[];
328
+ minBaseOut: string;
329
+ };
330
+ type BaseLiquidityDetails = {
331
+ baseLiquidity: Coin;
332
+ totalShares: string;
333
+ };
316
334
 
317
- interface RouterConfig {
335
+ type RouterConfig = {
318
336
  admin: Address;
319
337
  defaultPriceOracleContract: Address;
320
338
  defaultProtocolFeeRecipient: Address;
321
339
  defaultProtocolFee: string;
322
340
  defaultLpFee: string;
323
341
  settlementCodeId: number;
324
- }
325
- interface Pool {
342
+ };
343
+ type Pool = {
326
344
  poolAddress: Address;
327
345
  baseAssetSymbol: string;
328
346
  quoteAssetsSymbols: string[];
329
- }
330
- interface SwapParams {
347
+ };
348
+ type SwapParams = {
331
349
  assetIn: string;
332
350
  amountIn: string;
333
351
  assetOut: string;
334
352
  minimumAmountOut?: string;
335
353
  receiver?: Address;
336
- }
337
- interface SwapResult<TTxOutput = unknown> {
354
+ };
355
+ type SwapResult<TTxOutput = unknown> = {
338
356
  txOutput: TTxOutput;
339
357
  amountOut: string;
340
358
  assetOut: string;
341
359
  txHash: string;
342
- }
360
+ };
343
361
 
344
362
  /**
345
363
  * Abstract base client for all implementations of the Bolt SDK for different chains/networks.
@@ -368,12 +386,12 @@ declare abstract class BaseClient<TSigner = unknown> {
368
386
  /**
369
387
  * Creates a new instance of the BaseClient.
370
388
  *
371
- * @param config - Optional configuration object for the client
372
- * @param config.override - Override configuration for RPC endpoint and contract addresses
373
- * @param config.override.rpcEndpoint - The RPC endpoint URL for the blockchain network
374
- * @param config.override.contracts - Contract addresses for oracle and router
375
- * @param config.override.contracts.oracle - Address of the price oracle contract
376
- * @param config.override.contracts.router - Address of the swap router contract
389
+ * @param config - (Optional) Configuration object for the client
390
+ * @param config.customOverride - (Optional) Override configuration for RPC endpoint and contract addresses
391
+ * @param config.customOverride.rpcEndpoint - (Optional) Custom RPC endpoint URL for the blockchain network
392
+ * @param config.customOverride.contracts - (Optional) Custom contract addresses
393
+ * @param config.customOverride.contracts.oracle - (Optional) Custom oracle contract address
394
+ * @param config.customOverride.contracts.router - (Optional) Custom router contract address
377
395
  *
378
396
  * @throws {InvalidObjectError} Thrown when required configuration fields are missing
379
397
  *
@@ -472,17 +490,20 @@ declare abstract class BaseClient<TSigner = unknown> {
472
490
  * Fetches the total liquidity for all base assets across all pools.
473
491
  *
474
492
  * @returns A promise that resolves to a record mapping pool addresses
475
- * to their respective base asset liquidity amounts
493
+ * to their respective base asset liquidity details, including
494
+ * the base liquidity amount and total shares
476
495
  *
477
496
  * @example
478
497
  * ```typescript
479
498
  * const liquidity = await client.getAllBaseAssetsLiquidity();
480
- * Object.entries(liquidity).forEach(([poolAddress, coin]) => {
481
- * console.log(`Pool ${poolAddress}: ${coin.amount} ${coin.denom}`);
499
+ * Object.entries(liquidity).forEach(([poolAddress, details]) => {
500
+ * console.log(`Pool ${poolAddress}:`);
501
+ * console.log(` Base: ${details.baseLiquidity.amount} ${details.baseLiquidity.denom}`);
502
+ * console.log(` Total Shares: ${details.totalShares}`);
482
503
  * });
483
504
  * ```
484
505
  */
485
- abstract getAllBaseAssetsLiquidity(): Promise<Record<Address, Coin>>;
506
+ abstract getAllBaseAssetsLiquidity(): Promise<Record<Address, BaseLiquidityDetails>>;
486
507
  /**
487
508
  * Fetches all withdrawable quote assets for a specific user or liquidity provider.
488
509
  *
@@ -527,6 +548,8 @@ declare abstract class BaseClient<TSigner = unknown> {
527
548
  *
528
549
  * @returns A promise that resolves to an array containing all pool information
529
550
  *
551
+ * @throws Will throw an error if no pool exists for the specified base asset
552
+ *
530
553
  * @example
531
554
  * ```typescript
532
555
  * const pools = await client.getAllPools();
@@ -539,9 +562,58 @@ declare abstract class BaseClient<TSigner = unknown> {
539
562
  */
540
563
  abstract getAllPools(): Promise<Pool[]>;
541
564
  /**
542
- * Executes a "swap exact in" operation on the blockchain from one asset to another.
565
+ * Fetches the configuration settings for a specific liquidity pool.
566
+ *
567
+ * This method retrieves detailed configuration parameters for a pool, including
568
+ * fee structures, oracle settings, liquidity provider information, and trading limits.
569
+ *
570
+ * @param poolContractAddress - The blockchain address of the pool contract
571
+ *
572
+ * @returns A promise that resolves to a pool configuration object
573
+ * containing settings such as fees, oracle address, LP addresses, and minimum trade amounts
574
+ *
575
+ * @example
576
+ * ```typescript
577
+ * const poolConfig = await client.getPoolConfig("archway1pool...");
578
+ * console.log(`Oracle: ${poolConfig.priceOracleContract}`);
579
+ * console.log(`Protocol fee: ${poolConfig.protocolFee * 100}%`);
580
+ * console.log(`LP fee: ${poolConfig.lpFee * 100}%`);
581
+ * console.log(`Allowance mode: ${poolConfig.allowanceMode}`);
582
+ * console.log(`LPs: ${poolConfig.lps.join(', ')}`);
583
+ * console.log(`Min base output: ${poolConfig.minBaseOut}`);
584
+ * ```
585
+ */
586
+ abstract getPoolConfig(poolContractAddress: string): Promise<PoolConfig>;
587
+ /**
588
+ * Fetches the configuration settings for a pool identified by its base asset symbol.
589
+ *
590
+ * This method retrieves the pool configuration by first looking up the pool
591
+ * associated with the given base asset, then fetching its configuration parameters.
592
+ *
593
+ * @param baseAssetSymbol - The symbol of the base asset (e.g., "aarch", "ibc/...")
594
+ *
595
+ * @returns A promise that resolves to a pool configuration object containing
596
+ * settings such as fees, oracle address, LP addresses, and minimum trade amounts
597
+ *
598
+ * @throws Will throw an error if no pool exists for the specified base asset
599
+ *
600
+ * @example
601
+ * ```typescript
602
+ * // Get pool configuration for ARCH base asset
603
+ * const poolConfig = await client.getPoolConfigByBaseAsset("aarch");
604
+ * console.log(`Oracle: ${poolConfig.priceOracleContract}`);
605
+ * console.log(`Protocol fee: ${poolConfig.protocolFee * 100}%`);
606
+ * console.log(`LP fee: ${poolConfig.lpFee * 100}%`);
607
+ * console.log(`Allowance mode: ${poolConfig.allowanceMode}`);
608
+ * console.log(`Number of LPs: ${poolConfig.lps.length}`);
609
+ * console.log(`Min base output: ${poolConfig.minBaseOut}`);
610
+ * ```
611
+ */
612
+ abstract getPoolConfigByBaseAsset(baseAssetSymbol: string): Promise<PoolConfig>;
613
+ /**
614
+ * Executes a swap operation on the blockchain from one asset to another.
543
615
  *
544
- * This method performs a swap where the exact input amount is specified, and the output
616
+ * This method performs a "swap exact in" where the exact input amount is specified, and the output
545
617
  * amount varies based on current pool conditions and fees. The transaction includes
546
618
  * slippage protection through the optional minimumAmountOut parameter.
547
619
  *
@@ -565,7 +637,7 @@ declare abstract class BaseClient<TSigner = unknown> {
565
637
  * @example
566
638
  * ```typescript
567
639
  * // Swap exactly 1 ARCH for USDC (output amount varies)
568
- * const result = await client.swapExactIn(signer, {
640
+ * const result = await client.swap(signer, {
569
641
  * assetIn: "aarch",
570
642
  * amountIn: "1000000000000000000", // Exactly 1 ARCH (18 decimals)
571
643
  * assetOut: "ibc/43897B9739BD63E3A08A88191999C632E052724AB96BD4C74AE31375C991F48D", // USDC IBC denom
@@ -585,61 +657,77 @@ declare abstract class BaseClient<TSigner = unknown> {
585
657
  * - Fees are deducted from the output
586
658
  * - Use minimumAmountOut to protect against excessive slippage
587
659
  */
588
- abstract swapExactIn(signer: TSigner, params: SwapParams): Promise<SwapResult>;
660
+ abstract swap(signer: TSigner, params: SwapParams): Promise<SwapResult>;
589
661
  }
590
662
 
591
- interface CosmWasmClientConfig extends ClientConfig {
663
+ type CosmWasmClientConfig = ClientConfig & {
592
664
  chain?: CosmWasmChain;
593
- }
665
+ cosmWasmClient?: CosmWasmClient | ArchwayClient;
666
+ signingCosmWasmClient?: SigningCosmWasmClient | SigningArchwayClient;
667
+ };
594
668
  declare enum CosmWasmChain {
595
669
  Archway = "archway"
596
670
  }
597
671
 
598
- interface QueryOracleConfigResponse {
672
+ type QueryOracleConfigResponse = {
599
673
  admin: Address;
600
674
  price_threshold_ratio: string;
601
675
  price_expire_time: Duration | null;
602
- }
603
- interface PriceRepresentation {
676
+ };
677
+ type PriceRepresentation = {
604
678
  asset_pair: AssetPairString;
605
679
  price: string;
606
680
  expiry_time: Timestamp;
607
- }
608
- interface InvertiblePriceRepresentation extends PriceRepresentation {
681
+ };
682
+ type InvertiblePriceRepresentation = PriceRepresentation & {
609
683
  is_inverse: boolean;
610
- }
611
- interface QueryPriceResponse {
684
+ };
685
+ type QueryPriceResponse = {
612
686
  pair_data: InvertiblePriceRepresentation;
613
- }
614
- interface QueryPricesResponse {
687
+ };
688
+ type QueryPricesResponse = {
615
689
  prices: PriceRepresentation[];
616
- }
617
- interface QueryAssetPairsResponse {
690
+ };
691
+ type QueryAssetPairsResponse = {
618
692
  list: OracleAssetPair[];
619
- }
693
+ };
694
+
695
+ type QuerySettlementConfigResponse = {
696
+ price_oracle_contract: Address;
697
+ protocol_fee_recipient: Address;
698
+ protocol_fee: string;
699
+ lp_fee: string;
700
+ allowance_mode: AllowanceMode;
701
+ lps: Address[];
702
+ min_base_out: string;
703
+ };
704
+ type QueryBaseLiquidityResponse = {
705
+ base_liquidity: Coin;
706
+ total_shares: string;
707
+ };
620
708
 
621
- interface QueryRouterConfigResponse {
709
+ type QueryRouterConfigResponse = {
622
710
  admin: Address;
623
711
  default_price_oracle_contract: Address;
624
712
  default_protocol_fee_recipient: Address;
625
713
  default_protocol_fee: string;
626
714
  default_lp_fee: string;
627
715
  settlement_code_id: number;
628
- }
629
- interface MarketRepresentation {
716
+ };
717
+ type MarketRepresentation = {
630
718
  market_address: Address;
631
719
  base_asset_symbol: string;
632
720
  quote_assets_symbols: string[];
633
- }
634
- interface QueryMarketsResponse {
721
+ };
722
+ type QueryMarketsResponse = {
635
723
  markets: MarketRepresentation[];
636
- }
637
- interface QueryBaseLiquidityAllResponse {
638
- liquidity: Record<Address, Coin>;
639
- }
640
- interface QueryQuotesForUserAllResponse {
724
+ };
725
+ type QueryBaseLiquidityAllResponse = {
726
+ liquidity: Record<Address, QueryBaseLiquidityResponse>;
727
+ };
728
+ type QueryQuotesForUserAllResponse = {
641
729
  quotes: Record<Address, Coin[]>;
642
- }
730
+ };
643
731
 
644
732
  /**
645
733
  * Client implementation for interacting with the Bolt Liquidity Outpost on CosmWasm-based blockchains.
@@ -697,11 +785,13 @@ declare class BoltCosmWasmClient extends BaseClient<OfflineSigner> {
697
785
  * @param config - (Optional) Configuration for the client
698
786
  * @param config.environment - (Optional) The deployment environment (Mainnet or Testnet). Defaults to Mainnet
699
787
  * @param config.chain - (Optional) The specific CosmWasm chain to connect to. Defaults to Archway
700
- * @param config.override - (Optional) Overrides for RPC endpoint and contract addresses
701
- * @param config.override.rpcEndpoint - (Optional) Custom RPC endpoint URL
702
- * @param config.override.contracts - (Optional) Custom contract addresses
703
- * @param config.override.contracts.oracle - (Optional) Custom oracle contract address
704
- * @param config.override.contracts.router - (Optional) Custom router contract address
788
+ * @param config.customOverride - (Optional) Overrides for RPC endpoint and contract addresses
789
+ * @param config.customOverride.rpcEndpoint - (Optional) Custom RPC endpoint URL
790
+ * @param config.customOverride.contracts - (Optional) Custom contract addresses
791
+ * @param config.customOverride.contracts.oracle - (Optional) Custom oracle contract address
792
+ * @param config.customOverride.contracts.router - (Optional) Custom router contract address
793
+ * @param config.customOverride.cosmWasmClient - (Optional) Custom CosmWasmClient to use for blockchain queries
794
+ * @param config.customOverride.signingCosmWasmClient - (Optional) Custom SigningCosmWasmClient to use for blockchain transactions
705
795
  *
706
796
  * @throws {InvalidTypeError} Thrown when an unsupported chain is specified
707
797
  *
@@ -779,13 +869,17 @@ declare class BoltCosmWasmClient extends BaseClient<OfflineSigner> {
779
869
  /** @inheritdoc */
780
870
  getRouterConfig(): Promise<RouterConfig>;
781
871
  /** @inheritdoc */
782
- getAllBaseAssetsLiquidity(): Promise<Record<Address, Coin>>;
872
+ getAllBaseAssetsLiquidity(): Promise<Record<Address, BaseLiquidityDetails>>;
783
873
  /** @inheritdoc */
784
874
  getAllQuotesByUser(address: Address): Promise<Record<Address, Coin[]>>;
785
875
  /** @inheritdoc */
786
876
  getPoolByBaseAsset(baseAssetSymbol: string): Promise<Pool>;
787
877
  /** @inheritdoc */
788
878
  getAllPools(): Promise<Pool[]>;
879
+ /** @inheritdoc */
880
+ getPoolConfig(poolContractAddress: Address): Promise<PoolConfig>;
881
+ /** @inheritdoc */
882
+ getPoolConfigByBaseAsset(baseAssetSymbol: string): Promise<PoolConfig>;
789
883
  /**
790
884
  * @inheritdoc
791
885
  *
@@ -809,7 +903,7 @@ declare class BoltCosmWasmClient extends BaseClient<OfflineSigner> {
809
903
  * console.log(`Gas used: ${result.gasUsed}`);
810
904
  * ```
811
905
  */
812
- swapExactIn(signer: OfflineSigner, params: SwapParams): Promise<SwapResult<ExecuteResult>>;
906
+ swap(signer: OfflineSigner, params: SwapParams): Promise<SwapResult<ExecuteResult>>;
813
907
  }
814
908
 
815
- export { type Address, type AssetPairString, 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 };
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 };