@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/README.md +1 -1
- package/dist/index.cjs +87 -25
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +170 -76
- package/dist/index.d.ts +170 -76
- package/dist/index.js +87 -25
- package/dist/index.js.map +1 -1
- package/package.json +7 -3
package/dist/index.d.ts
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.
|
|
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
|
-
|
|
274
|
-
secs:
|
|
273
|
+
type Duration = {
|
|
274
|
+
secs: number;
|
|
275
275
|
nanos: number;
|
|
276
|
-
}
|
|
277
|
-
|
|
276
|
+
};
|
|
277
|
+
type Coin = {
|
|
278
278
|
denom: string;
|
|
279
279
|
amount: string;
|
|
280
|
-
}
|
|
280
|
+
};
|
|
281
281
|
|
|
282
|
-
|
|
282
|
+
type ClientConfig = {
|
|
283
283
|
environment?: Environment;
|
|
284
|
-
|
|
284
|
+
customOverride?: {
|
|
285
285
|
rpcEndpoint?: string;
|
|
286
286
|
contracts?: Partial<Contracts>;
|
|
287
287
|
};
|
|
288
|
-
}
|
|
289
|
-
|
|
288
|
+
};
|
|
289
|
+
type Contracts = {
|
|
290
290
|
oracle: Address;
|
|
291
291
|
router: Address;
|
|
292
|
-
}
|
|
292
|
+
};
|
|
293
293
|
|
|
294
|
-
|
|
294
|
+
type OracleConfig = {
|
|
295
295
|
admin: Address;
|
|
296
296
|
priceThresholdRatio: string;
|
|
297
297
|
priceExpireTime: Duration | null;
|
|
298
|
-
}
|
|
299
|
-
|
|
298
|
+
};
|
|
299
|
+
type Price = {
|
|
300
300
|
assetPair: AssetPairString;
|
|
301
301
|
price: string;
|
|
302
302
|
expiryTime: Timestamp;
|
|
303
|
-
}
|
|
304
|
-
|
|
303
|
+
};
|
|
304
|
+
type InvertiblePrice = Price & {
|
|
305
305
|
isInverse: boolean;
|
|
306
|
-
}
|
|
307
|
-
|
|
306
|
+
};
|
|
307
|
+
type OracleAsset = {
|
|
308
308
|
name: string;
|
|
309
309
|
symbol: string;
|
|
310
310
|
precision: number;
|
|
311
|
-
}
|
|
312
|
-
|
|
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
|
-
|
|
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
|
-
|
|
342
|
+
};
|
|
343
|
+
type Pool = {
|
|
326
344
|
poolAddress: Address;
|
|
327
345
|
baseAssetSymbol: string;
|
|
328
346
|
quoteAssetsSymbols: string[];
|
|
329
|
-
}
|
|
330
|
-
|
|
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
|
-
|
|
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
|
|
372
|
-
* @param config.
|
|
373
|
-
* @param config.
|
|
374
|
-
* @param config.
|
|
375
|
-
* @param config.
|
|
376
|
-
* @param config.
|
|
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
|
|
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,
|
|
481
|
-
* console.log(`Pool ${poolAddress}
|
|
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,
|
|
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
|
-
*
|
|
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.
|
|
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
|
|
660
|
+
abstract swap(signer: TSigner, params: SwapParams): Promise<SwapResult>;
|
|
589
661
|
}
|
|
590
662
|
|
|
591
|
-
|
|
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
|
-
|
|
672
|
+
type QueryOracleConfigResponse = {
|
|
599
673
|
admin: Address;
|
|
600
674
|
price_threshold_ratio: string;
|
|
601
675
|
price_expire_time: Duration | null;
|
|
602
|
-
}
|
|
603
|
-
|
|
676
|
+
};
|
|
677
|
+
type PriceRepresentation = {
|
|
604
678
|
asset_pair: AssetPairString;
|
|
605
679
|
price: string;
|
|
606
680
|
expiry_time: Timestamp;
|
|
607
|
-
}
|
|
608
|
-
|
|
681
|
+
};
|
|
682
|
+
type InvertiblePriceRepresentation = PriceRepresentation & {
|
|
609
683
|
is_inverse: boolean;
|
|
610
|
-
}
|
|
611
|
-
|
|
684
|
+
};
|
|
685
|
+
type QueryPriceResponse = {
|
|
612
686
|
pair_data: InvertiblePriceRepresentation;
|
|
613
|
-
}
|
|
614
|
-
|
|
687
|
+
};
|
|
688
|
+
type QueryPricesResponse = {
|
|
615
689
|
prices: PriceRepresentation[];
|
|
616
|
-
}
|
|
617
|
-
|
|
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
|
-
|
|
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
|
-
|
|
716
|
+
};
|
|
717
|
+
type MarketRepresentation = {
|
|
630
718
|
market_address: Address;
|
|
631
719
|
base_asset_symbol: string;
|
|
632
720
|
quote_assets_symbols: string[];
|
|
633
|
-
}
|
|
634
|
-
|
|
721
|
+
};
|
|
722
|
+
type QueryMarketsResponse = {
|
|
635
723
|
markets: MarketRepresentation[];
|
|
636
|
-
}
|
|
637
|
-
|
|
638
|
-
liquidity: Record<Address,
|
|
639
|
-
}
|
|
640
|
-
|
|
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.
|
|
701
|
-
* @param config.
|
|
702
|
-
* @param config.
|
|
703
|
-
* @param config.
|
|
704
|
-
* @param config.
|
|
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,
|
|
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
|
-
|
|
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 };
|
package/dist/index.js
CHANGED
|
@@ -219,12 +219,12 @@ var BaseClient = class {
|
|
|
219
219
|
/**
|
|
220
220
|
* Creates a new instance of the BaseClient.
|
|
221
221
|
*
|
|
222
|
-
* @param config - Optional
|
|
223
|
-
* @param config.
|
|
224
|
-
* @param config.
|
|
225
|
-
* @param config.
|
|
226
|
-
* @param config.
|
|
227
|
-
* @param config.
|
|
222
|
+
* @param config - (Optional) Configuration object for the client
|
|
223
|
+
* @param config.customOverride - (Optional) Override configuration for RPC endpoint and contract addresses
|
|
224
|
+
* @param config.customOverride.rpcEndpoint - (Optional) Custom RPC endpoint URL for the blockchain network
|
|
225
|
+
* @param config.customOverride.contracts - (Optional) Custom contract addresses
|
|
226
|
+
* @param config.customOverride.contracts.oracle - (Optional) Custom oracle contract address
|
|
227
|
+
* @param config.customOverride.contracts.router - (Optional) Custom router contract address
|
|
228
228
|
*
|
|
229
229
|
* @throws {InvalidObjectError} Thrown when required configuration fields are missing
|
|
230
230
|
*
|
|
@@ -250,7 +250,7 @@ var BaseClient = class {
|
|
|
250
250
|
* Smart contract addresses for making Bolt queries and transactions in the blockchain
|
|
251
251
|
*/
|
|
252
252
|
__publicField(this, "contracts");
|
|
253
|
-
const {
|
|
253
|
+
const { customOverride: { rpcEndpoint, contracts } = {} } = config ?? {};
|
|
254
254
|
if (!rpcEndpoint || !contracts?.oracle || !contracts.router) {
|
|
255
255
|
throw new InvalidObjectError("ClientConfig is missing fields");
|
|
256
256
|
}
|
|
@@ -269,6 +269,13 @@ var Environment = /* @__PURE__ */ ((Environment2) => {
|
|
|
269
269
|
return Environment2;
|
|
270
270
|
})(Environment || {});
|
|
271
271
|
|
|
272
|
+
// src/common/types/pool.ts
|
|
273
|
+
var AllowanceMode = /* @__PURE__ */ ((AllowanceMode2) => {
|
|
274
|
+
AllowanceMode2["Allow"] = "allow";
|
|
275
|
+
AllowanceMode2["Disallow"] = "disallow";
|
|
276
|
+
return AllowanceMode2;
|
|
277
|
+
})(AllowanceMode || {});
|
|
278
|
+
|
|
272
279
|
// src/config/archway-mainnet.json
|
|
273
280
|
var archway_mainnet_default = {
|
|
274
281
|
chain: {
|
|
@@ -277,8 +284,8 @@ var archway_mainnet_default = {
|
|
|
277
284
|
restEndpoint: "https://api.mainnet.archway.io"
|
|
278
285
|
},
|
|
279
286
|
contracts: {
|
|
280
|
-
oracle: "
|
|
281
|
-
router: "
|
|
287
|
+
oracle: "archway1cr5l0tvhqsdjfzun4jkwqfzv7fadu598hultcra4jrljgwl639wsksmd28",
|
|
288
|
+
router: "archway199r5vm4yzww5hct2z58tz9v3chfcvkpln34sqcav3ldqs7nkwktqc7aeju"
|
|
282
289
|
}
|
|
283
290
|
};
|
|
284
291
|
|
|
@@ -290,8 +297,8 @@ var archway_testnet_default = {
|
|
|
290
297
|
restEndpoint: "https://api.constantine.archway.io"
|
|
291
298
|
},
|
|
292
299
|
contracts: {
|
|
293
|
-
oracle: "
|
|
294
|
-
router: "
|
|
300
|
+
oracle: "archway1ehpghtr0v95kfx648dck7pvs08d6ah97l99xkx87t2zx8tcyen0s9n90x4",
|
|
301
|
+
router: "archway1h5x6upghew9xkfek85q48let2twdxq33sgsnzze5weshla46xd8sttps44"
|
|
295
302
|
}
|
|
296
303
|
};
|
|
297
304
|
|
|
@@ -351,6 +358,30 @@ var parseQueryRouterConfigResponse = (response) => {
|
|
|
351
358
|
settlementCodeId: response.settlement_code_id
|
|
352
359
|
};
|
|
353
360
|
};
|
|
361
|
+
var parseQuerySettlementConfigResponse = (response) => {
|
|
362
|
+
return {
|
|
363
|
+
priceOracleContract: response.price_oracle_contract,
|
|
364
|
+
protocolFeeRecipient: response.protocol_fee_recipient,
|
|
365
|
+
protocolFee: response.protocol_fee,
|
|
366
|
+
lpFee: response.lp_fee,
|
|
367
|
+
allowanceMode: response.allowance_mode,
|
|
368
|
+
lps: response.lps,
|
|
369
|
+
minBaseOut: response.min_base_out
|
|
370
|
+
};
|
|
371
|
+
};
|
|
372
|
+
var parseQueryBaseLiquidityResponse = (response) => {
|
|
373
|
+
return {
|
|
374
|
+
baseLiquidity: response.base_liquidity,
|
|
375
|
+
totalShares: response.total_shares
|
|
376
|
+
};
|
|
377
|
+
};
|
|
378
|
+
var parseQueryBaseLiquidityAllResponse = (response) => {
|
|
379
|
+
const newMapping = {};
|
|
380
|
+
for (const [key, value] of Object.entries(response.liquidity)) {
|
|
381
|
+
newMapping[key] = parseQueryBaseLiquidityResponse(value);
|
|
382
|
+
}
|
|
383
|
+
return newMapping;
|
|
384
|
+
};
|
|
354
385
|
|
|
355
386
|
// src/lib/helpers/transactions.ts
|
|
356
387
|
var getSignerAddress = async (signer) => {
|
|
@@ -394,7 +425,7 @@ var getAllBaseLiquidity = async (client) => {
|
|
|
394
425
|
const response = await cosmWasmClient.queryContractSmart(client.contracts.router, {
|
|
395
426
|
base_liquidity_all: {}
|
|
396
427
|
});
|
|
397
|
-
return response
|
|
428
|
+
return parseQueryBaseLiquidityAllResponse(response);
|
|
398
429
|
};
|
|
399
430
|
|
|
400
431
|
// src/lib/router/get-all-quotes-for-user.ts
|
|
@@ -438,7 +469,7 @@ var BOLT_SWAP_EVENT_TYPE = "wasm-bolt_swap";
|
|
|
438
469
|
var BOLT_COIN_RECEIVED_EVENT_TYPE = "coin_received";
|
|
439
470
|
var BOLT_COIN_RECEIVED_EVENT_AMOUNT_KEY = "amount";
|
|
440
471
|
|
|
441
|
-
// src/lib/router/swap.ts
|
|
472
|
+
// src/lib/router/swap-exact-in.ts
|
|
442
473
|
var swapExactIn = async (client, signer, { assetIn, amountIn, assetOut, minimumAmountOut, receiver }) => {
|
|
443
474
|
const signingCosmWasmClient = await client.getSigningCosmWasmClient(signer);
|
|
444
475
|
const address = await getSignerAddress(signer);
|
|
@@ -499,6 +530,21 @@ var CosmWasmChain = /* @__PURE__ */ ((CosmWasmChain2) => {
|
|
|
499
530
|
return CosmWasmChain2;
|
|
500
531
|
})(CosmWasmChain || {});
|
|
501
532
|
|
|
533
|
+
// src/lib/settlement/get-settlement-config.ts
|
|
534
|
+
var getSettlementConfig = async (client, contractAddress) => {
|
|
535
|
+
const cosmWasmClient = await client.getCosmWasmClient();
|
|
536
|
+
const response = await cosmWasmClient.queryContractSmart(contractAddress, {
|
|
537
|
+
config: {}
|
|
538
|
+
});
|
|
539
|
+
return parseQuerySettlementConfigResponse(response);
|
|
540
|
+
};
|
|
541
|
+
|
|
542
|
+
// src/lib/settlement/get-settlement-config-for-base.ts
|
|
543
|
+
var getSettlementConfigForBase = async (client, baseAssetSymbol) => {
|
|
544
|
+
const pool = await getPoolForBase(client, baseAssetSymbol);
|
|
545
|
+
return await getSettlementConfig(client, pool.poolAddress);
|
|
546
|
+
};
|
|
547
|
+
|
|
502
548
|
// src/lib/client.ts
|
|
503
549
|
var BoltCosmWasmClient = class extends BaseClient {
|
|
504
550
|
/**
|
|
@@ -510,11 +556,13 @@ var BoltCosmWasmClient = class extends BaseClient {
|
|
|
510
556
|
* @param config - (Optional) Configuration for the client
|
|
511
557
|
* @param config.environment - (Optional) The deployment environment (Mainnet or Testnet). Defaults to Mainnet
|
|
512
558
|
* @param config.chain - (Optional) The specific CosmWasm chain to connect to. Defaults to Archway
|
|
513
|
-
* @param config.
|
|
514
|
-
* @param config.
|
|
515
|
-
* @param config.
|
|
516
|
-
* @param config.
|
|
517
|
-
* @param config.
|
|
559
|
+
* @param config.customOverride - (Optional) Overrides for RPC endpoint and contract addresses
|
|
560
|
+
* @param config.customOverride.rpcEndpoint - (Optional) Custom RPC endpoint URL
|
|
561
|
+
* @param config.customOverride.contracts - (Optional) Custom contract addresses
|
|
562
|
+
* @param config.customOverride.contracts.oracle - (Optional) Custom oracle contract address
|
|
563
|
+
* @param config.customOverride.contracts.router - (Optional) Custom router contract address
|
|
564
|
+
* @param config.customOverride.cosmWasmClient - (Optional) Custom CosmWasmClient to use for blockchain queries
|
|
565
|
+
* @param config.customOverride.signingCosmWasmClient - (Optional) Custom SigningCosmWasmClient to use for blockchain transactions
|
|
518
566
|
*
|
|
519
567
|
* @throws {InvalidTypeError} Thrown when an unsupported chain is specified
|
|
520
568
|
*
|
|
@@ -540,7 +588,9 @@ var BoltCosmWasmClient = class extends BaseClient {
|
|
|
540
588
|
const {
|
|
541
589
|
environment = "mainnet" /* Mainnet */,
|
|
542
590
|
chain = "archway" /* Archway */,
|
|
543
|
-
|
|
591
|
+
customOverride,
|
|
592
|
+
cosmWasmClient,
|
|
593
|
+
signingCosmWasmClient
|
|
544
594
|
} = config ?? {};
|
|
545
595
|
let configJson;
|
|
546
596
|
switch (chain) {
|
|
@@ -551,11 +601,11 @@ var BoltCosmWasmClient = class extends BaseClient {
|
|
|
551
601
|
throw new InvalidTypeError("A valid value of CosmWasmChain", chain);
|
|
552
602
|
}
|
|
553
603
|
super({
|
|
554
|
-
|
|
555
|
-
rpcEndpoint:
|
|
604
|
+
customOverride: {
|
|
605
|
+
rpcEndpoint: customOverride?.rpcEndpoint ?? configJson.chain.rpcEndpoint,
|
|
556
606
|
contracts: {
|
|
557
|
-
oracle:
|
|
558
|
-
router:
|
|
607
|
+
oracle: customOverride?.contracts?.oracle ?? configJson.contracts.oracle,
|
|
608
|
+
router: customOverride?.contracts?.router ?? configJson.contracts.router
|
|
559
609
|
}
|
|
560
610
|
}
|
|
561
611
|
});
|
|
@@ -574,6 +624,8 @@ var BoltCosmWasmClient = class extends BaseClient {
|
|
|
574
624
|
*/
|
|
575
625
|
__publicField(this, "chain");
|
|
576
626
|
this.chain = chain;
|
|
627
|
+
this._cosmWasmClient = cosmWasmClient;
|
|
628
|
+
this._signingCosmWasmClient = signingCosmWasmClient;
|
|
577
629
|
}
|
|
578
630
|
/**
|
|
579
631
|
* Gets or creates a CosmWasm client instance for read-only blockchain operations.
|
|
@@ -664,12 +716,20 @@ var BoltCosmWasmClient = class extends BaseClient {
|
|
|
664
716
|
}
|
|
665
717
|
/** @inheritdoc */
|
|
666
718
|
async getPoolByBaseAsset(baseAssetSymbol) {
|
|
667
|
-
return getPoolForBase(this, baseAssetSymbol);
|
|
719
|
+
return await getPoolForBase(this, baseAssetSymbol);
|
|
668
720
|
}
|
|
669
721
|
/** @inheritdoc */
|
|
670
722
|
async getAllPools() {
|
|
671
723
|
return await getPools(this);
|
|
672
724
|
}
|
|
725
|
+
/** @inheritdoc */
|
|
726
|
+
async getPoolConfig(poolContractAddress) {
|
|
727
|
+
return await getSettlementConfig(this, poolContractAddress);
|
|
728
|
+
}
|
|
729
|
+
/** @inheritdoc */
|
|
730
|
+
async getPoolConfigByBaseAsset(baseAssetSymbol) {
|
|
731
|
+
return await getSettlementConfigForBase(this, baseAssetSymbol);
|
|
732
|
+
}
|
|
673
733
|
/**
|
|
674
734
|
* @inheritdoc
|
|
675
735
|
*
|
|
@@ -693,11 +753,13 @@ var BoltCosmWasmClient = class extends BaseClient {
|
|
|
693
753
|
* console.log(`Gas used: ${result.gasUsed}`);
|
|
694
754
|
* ```
|
|
695
755
|
*/
|
|
696
|
-
async
|
|
756
|
+
async swap(signer, params) {
|
|
697
757
|
return await swapExactIn(this, signer, params);
|
|
698
758
|
}
|
|
699
759
|
};
|
|
700
760
|
export {
|
|
761
|
+
AllowanceMode,
|
|
762
|
+
BaseClient,
|
|
701
763
|
BoltCosmWasmClient,
|
|
702
764
|
BoltSdkErrorBase,
|
|
703
765
|
BoltSdkErrorCode,
|