@bolt-liquidity-hq/cosmwasm-client 0.1.0-beta.3 → 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 +17 -4
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +86 -75
- package/dist/index.d.ts +86 -75
- package/dist/index.js +17 -4
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
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.
|
|
20
|
+
* await client.swap(signer, params);
|
|
21
21
|
* } catch (error) {
|
|
22
22
|
* if (error instanceof BoltSdkError) {
|
|
23
23
|
* switch (error.code) {
|
|
@@ -270,55 +270,55 @@ declare enum Environment {
|
|
|
270
270
|
type Address = string;
|
|
271
271
|
type AssetPairString = string;
|
|
272
272
|
type Timestamp = string;
|
|
273
|
-
|
|
273
|
+
type Duration = {
|
|
274
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
316
|
|
|
317
317
|
declare enum AllowanceMode {
|
|
318
318
|
Allow = "allow",
|
|
319
319
|
Disallow = "disallow"
|
|
320
320
|
}
|
|
321
|
-
|
|
321
|
+
type PoolConfig = {
|
|
322
322
|
priceOracleContract: Address;
|
|
323
323
|
protocolFeeRecipient: Address;
|
|
324
324
|
protocolFee: string;
|
|
@@ -326,34 +326,38 @@ interface PoolConfig {
|
|
|
326
326
|
allowanceMode: AllowanceMode;
|
|
327
327
|
lps: Address[];
|
|
328
328
|
minBaseOut: string;
|
|
329
|
-
}
|
|
329
|
+
};
|
|
330
|
+
type BaseLiquidityDetails = {
|
|
331
|
+
baseLiquidity: Coin;
|
|
332
|
+
totalShares: string;
|
|
333
|
+
};
|
|
330
334
|
|
|
331
|
-
|
|
335
|
+
type RouterConfig = {
|
|
332
336
|
admin: Address;
|
|
333
337
|
defaultPriceOracleContract: Address;
|
|
334
338
|
defaultProtocolFeeRecipient: Address;
|
|
335
339
|
defaultProtocolFee: string;
|
|
336
340
|
defaultLpFee: string;
|
|
337
341
|
settlementCodeId: number;
|
|
338
|
-
}
|
|
339
|
-
|
|
342
|
+
};
|
|
343
|
+
type Pool = {
|
|
340
344
|
poolAddress: Address;
|
|
341
345
|
baseAssetSymbol: string;
|
|
342
346
|
quoteAssetsSymbols: string[];
|
|
343
|
-
}
|
|
344
|
-
|
|
347
|
+
};
|
|
348
|
+
type SwapParams = {
|
|
345
349
|
assetIn: string;
|
|
346
350
|
amountIn: string;
|
|
347
351
|
assetOut: string;
|
|
348
352
|
minimumAmountOut?: string;
|
|
349
353
|
receiver?: Address;
|
|
350
|
-
}
|
|
351
|
-
|
|
354
|
+
};
|
|
355
|
+
type SwapResult<TTxOutput = unknown> = {
|
|
352
356
|
txOutput: TTxOutput;
|
|
353
357
|
amountOut: string;
|
|
354
358
|
assetOut: string;
|
|
355
359
|
txHash: string;
|
|
356
|
-
}
|
|
360
|
+
};
|
|
357
361
|
|
|
358
362
|
/**
|
|
359
363
|
* Abstract base client for all implementations of the Bolt SDK for different chains/networks.
|
|
@@ -486,17 +490,20 @@ declare abstract class BaseClient<TSigner = unknown> {
|
|
|
486
490
|
* Fetches the total liquidity for all base assets across all pools.
|
|
487
491
|
*
|
|
488
492
|
* @returns A promise that resolves to a record mapping pool addresses
|
|
489
|
-
* to their respective base asset liquidity
|
|
493
|
+
* to their respective base asset liquidity details, including
|
|
494
|
+
* the base liquidity amount and total shares
|
|
490
495
|
*
|
|
491
496
|
* @example
|
|
492
497
|
* ```typescript
|
|
493
498
|
* const liquidity = await client.getAllBaseAssetsLiquidity();
|
|
494
|
-
* Object.entries(liquidity).forEach(([poolAddress,
|
|
495
|
-
* 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}`);
|
|
496
503
|
* });
|
|
497
504
|
* ```
|
|
498
505
|
*/
|
|
499
|
-
abstract getAllBaseAssetsLiquidity(): Promise<Record<Address,
|
|
506
|
+
abstract getAllBaseAssetsLiquidity(): Promise<Record<Address, BaseLiquidityDetails>>;
|
|
500
507
|
/**
|
|
501
508
|
* Fetches all withdrawable quote assets for a specific user or liquidity provider.
|
|
502
509
|
*
|
|
@@ -604,9 +611,9 @@ declare abstract class BaseClient<TSigner = unknown> {
|
|
|
604
611
|
*/
|
|
605
612
|
abstract getPoolConfigByBaseAsset(baseAssetSymbol: string): Promise<PoolConfig>;
|
|
606
613
|
/**
|
|
607
|
-
* Executes a
|
|
614
|
+
* Executes a swap operation on the blockchain from one asset to another.
|
|
608
615
|
*
|
|
609
|
-
* 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
|
|
610
617
|
* amount varies based on current pool conditions and fees. The transaction includes
|
|
611
618
|
* slippage protection through the optional minimumAmountOut parameter.
|
|
612
619
|
*
|
|
@@ -630,7 +637,7 @@ declare abstract class BaseClient<TSigner = unknown> {
|
|
|
630
637
|
* @example
|
|
631
638
|
* ```typescript
|
|
632
639
|
* // Swap exactly 1 ARCH for USDC (output amount varies)
|
|
633
|
-
* const result = await client.
|
|
640
|
+
* const result = await client.swap(signer, {
|
|
634
641
|
* assetIn: "aarch",
|
|
635
642
|
* amountIn: "1000000000000000000", // Exactly 1 ARCH (18 decimals)
|
|
636
643
|
* assetOut: "ibc/43897B9739BD63E3A08A88191999C632E052724AB96BD4C74AE31375C991F48D", // USDC IBC denom
|
|
@@ -650,73 +657,77 @@ declare abstract class BaseClient<TSigner = unknown> {
|
|
|
650
657
|
* - Fees are deducted from the output
|
|
651
658
|
* - Use minimumAmountOut to protect against excessive slippage
|
|
652
659
|
*/
|
|
653
|
-
abstract
|
|
660
|
+
abstract swap(signer: TSigner, params: SwapParams): Promise<SwapResult>;
|
|
654
661
|
}
|
|
655
662
|
|
|
656
|
-
|
|
663
|
+
type CosmWasmClientConfig = ClientConfig & {
|
|
657
664
|
chain?: CosmWasmChain;
|
|
658
665
|
cosmWasmClient?: CosmWasmClient | ArchwayClient;
|
|
659
666
|
signingCosmWasmClient?: SigningCosmWasmClient | SigningArchwayClient;
|
|
660
|
-
}
|
|
667
|
+
};
|
|
661
668
|
declare enum CosmWasmChain {
|
|
662
669
|
Archway = "archway"
|
|
663
670
|
}
|
|
664
671
|
|
|
665
|
-
|
|
672
|
+
type QueryOracleConfigResponse = {
|
|
666
673
|
admin: Address;
|
|
667
674
|
price_threshold_ratio: string;
|
|
668
675
|
price_expire_time: Duration | null;
|
|
669
|
-
}
|
|
670
|
-
|
|
676
|
+
};
|
|
677
|
+
type PriceRepresentation = {
|
|
671
678
|
asset_pair: AssetPairString;
|
|
672
679
|
price: string;
|
|
673
680
|
expiry_time: Timestamp;
|
|
674
|
-
}
|
|
675
|
-
|
|
681
|
+
};
|
|
682
|
+
type InvertiblePriceRepresentation = PriceRepresentation & {
|
|
676
683
|
is_inverse: boolean;
|
|
677
|
-
}
|
|
678
|
-
|
|
684
|
+
};
|
|
685
|
+
type QueryPriceResponse = {
|
|
679
686
|
pair_data: InvertiblePriceRepresentation;
|
|
680
|
-
}
|
|
681
|
-
|
|
687
|
+
};
|
|
688
|
+
type QueryPricesResponse = {
|
|
682
689
|
prices: PriceRepresentation[];
|
|
683
|
-
}
|
|
684
|
-
|
|
690
|
+
};
|
|
691
|
+
type QueryAssetPairsResponse = {
|
|
685
692
|
list: OracleAssetPair[];
|
|
686
|
-
}
|
|
693
|
+
};
|
|
687
694
|
|
|
688
|
-
|
|
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
|
+
};
|
|
708
|
+
|
|
709
|
+
type QueryRouterConfigResponse = {
|
|
689
710
|
admin: Address;
|
|
690
711
|
default_price_oracle_contract: Address;
|
|
691
712
|
default_protocol_fee_recipient: Address;
|
|
692
713
|
default_protocol_fee: string;
|
|
693
714
|
default_lp_fee: string;
|
|
694
715
|
settlement_code_id: number;
|
|
695
|
-
}
|
|
696
|
-
|
|
716
|
+
};
|
|
717
|
+
type MarketRepresentation = {
|
|
697
718
|
market_address: Address;
|
|
698
719
|
base_asset_symbol: string;
|
|
699
720
|
quote_assets_symbols: string[];
|
|
700
|
-
}
|
|
701
|
-
|
|
721
|
+
};
|
|
722
|
+
type QueryMarketsResponse = {
|
|
702
723
|
markets: MarketRepresentation[];
|
|
703
|
-
}
|
|
704
|
-
|
|
705
|
-
liquidity: Record<Address,
|
|
706
|
-
}
|
|
707
|
-
|
|
724
|
+
};
|
|
725
|
+
type QueryBaseLiquidityAllResponse = {
|
|
726
|
+
liquidity: Record<Address, QueryBaseLiquidityResponse>;
|
|
727
|
+
};
|
|
728
|
+
type QueryQuotesForUserAllResponse = {
|
|
708
729
|
quotes: Record<Address, Coin[]>;
|
|
709
|
-
}
|
|
710
|
-
|
|
711
|
-
interface QuerySettlementConfigResponse {
|
|
712
|
-
price_oracle_contract: Address;
|
|
713
|
-
protocol_fee_recipient: Address;
|
|
714
|
-
protocol_fee: string;
|
|
715
|
-
lp_fee: string;
|
|
716
|
-
allowance_mode: AllowanceMode;
|
|
717
|
-
lps: Address[];
|
|
718
|
-
min_base_out: string;
|
|
719
|
-
}
|
|
730
|
+
};
|
|
720
731
|
|
|
721
732
|
/**
|
|
722
733
|
* Client implementation for interacting with the Bolt Liquidity Outpost on CosmWasm-based blockchains.
|
|
@@ -858,7 +869,7 @@ declare class BoltCosmWasmClient extends BaseClient<OfflineSigner> {
|
|
|
858
869
|
/** @inheritdoc */
|
|
859
870
|
getRouterConfig(): Promise<RouterConfig>;
|
|
860
871
|
/** @inheritdoc */
|
|
861
|
-
getAllBaseAssetsLiquidity(): Promise<Record<Address,
|
|
872
|
+
getAllBaseAssetsLiquidity(): Promise<Record<Address, BaseLiquidityDetails>>;
|
|
862
873
|
/** @inheritdoc */
|
|
863
874
|
getAllQuotesByUser(address: Address): Promise<Record<Address, Coin[]>>;
|
|
864
875
|
/** @inheritdoc */
|
|
@@ -892,7 +903,7 @@ declare class BoltCosmWasmClient extends BaseClient<OfflineSigner> {
|
|
|
892
903
|
* console.log(`Gas used: ${result.gasUsed}`);
|
|
893
904
|
* ```
|
|
894
905
|
*/
|
|
895
|
-
|
|
906
|
+
swap(signer: OfflineSigner, params: SwapParams): Promise<SwapResult<ExecuteResult>>;
|
|
896
907
|
}
|
|
897
908
|
|
|
898
|
-
export { type Address, AllowanceMode, type AssetPairString, BaseClient, BoltCosmWasmClient, type BoltSdkError, BoltSdkErrorBase, BoltSdkErrorCode, type ClientConfig, type Coin, type Contracts, CosmWasmChain, type CosmWasmClientConfig, type Duration, Environment, InsufficientFundsError, InvalidAddressError, InvalidObjectError, InvalidParameterError, InvalidTypeError, type InvertiblePrice, type InvertiblePriceRepresentation, type MarketRepresentation, MissingParameterError, NetworkError, NotFoundError, type OracleAsset, type OracleAssetPair, type OracleConfig, ParameterOutOfRangeError, type Pool, type PoolConfig, type Price, type PriceRepresentation, type QueryAssetPairsResponse, type QueryBaseLiquidityAllResponse, type QueryMarketsResponse, type QueryOracleConfigResponse, type QueryPriceResponse, type QueryPricesResponse, type QueryQuotesForUserAllResponse, type QueryRouterConfigResponse, type QuerySettlementConfigResponse, 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.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,55 +270,55 @@ declare enum Environment {
|
|
|
270
270
|
type Address = string;
|
|
271
271
|
type AssetPairString = string;
|
|
272
272
|
type Timestamp = string;
|
|
273
|
-
|
|
273
|
+
type Duration = {
|
|
274
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
316
|
|
|
317
317
|
declare enum AllowanceMode {
|
|
318
318
|
Allow = "allow",
|
|
319
319
|
Disallow = "disallow"
|
|
320
320
|
}
|
|
321
|
-
|
|
321
|
+
type PoolConfig = {
|
|
322
322
|
priceOracleContract: Address;
|
|
323
323
|
protocolFeeRecipient: Address;
|
|
324
324
|
protocolFee: string;
|
|
@@ -326,34 +326,38 @@ interface PoolConfig {
|
|
|
326
326
|
allowanceMode: AllowanceMode;
|
|
327
327
|
lps: Address[];
|
|
328
328
|
minBaseOut: string;
|
|
329
|
-
}
|
|
329
|
+
};
|
|
330
|
+
type BaseLiquidityDetails = {
|
|
331
|
+
baseLiquidity: Coin;
|
|
332
|
+
totalShares: string;
|
|
333
|
+
};
|
|
330
334
|
|
|
331
|
-
|
|
335
|
+
type RouterConfig = {
|
|
332
336
|
admin: Address;
|
|
333
337
|
defaultPriceOracleContract: Address;
|
|
334
338
|
defaultProtocolFeeRecipient: Address;
|
|
335
339
|
defaultProtocolFee: string;
|
|
336
340
|
defaultLpFee: string;
|
|
337
341
|
settlementCodeId: number;
|
|
338
|
-
}
|
|
339
|
-
|
|
342
|
+
};
|
|
343
|
+
type Pool = {
|
|
340
344
|
poolAddress: Address;
|
|
341
345
|
baseAssetSymbol: string;
|
|
342
346
|
quoteAssetsSymbols: string[];
|
|
343
|
-
}
|
|
344
|
-
|
|
347
|
+
};
|
|
348
|
+
type SwapParams = {
|
|
345
349
|
assetIn: string;
|
|
346
350
|
amountIn: string;
|
|
347
351
|
assetOut: string;
|
|
348
352
|
minimumAmountOut?: string;
|
|
349
353
|
receiver?: Address;
|
|
350
|
-
}
|
|
351
|
-
|
|
354
|
+
};
|
|
355
|
+
type SwapResult<TTxOutput = unknown> = {
|
|
352
356
|
txOutput: TTxOutput;
|
|
353
357
|
amountOut: string;
|
|
354
358
|
assetOut: string;
|
|
355
359
|
txHash: string;
|
|
356
|
-
}
|
|
360
|
+
};
|
|
357
361
|
|
|
358
362
|
/**
|
|
359
363
|
* Abstract base client for all implementations of the Bolt SDK for different chains/networks.
|
|
@@ -486,17 +490,20 @@ declare abstract class BaseClient<TSigner = unknown> {
|
|
|
486
490
|
* Fetches the total liquidity for all base assets across all pools.
|
|
487
491
|
*
|
|
488
492
|
* @returns A promise that resolves to a record mapping pool addresses
|
|
489
|
-
* to their respective base asset liquidity
|
|
493
|
+
* to their respective base asset liquidity details, including
|
|
494
|
+
* the base liquidity amount and total shares
|
|
490
495
|
*
|
|
491
496
|
* @example
|
|
492
497
|
* ```typescript
|
|
493
498
|
* const liquidity = await client.getAllBaseAssetsLiquidity();
|
|
494
|
-
* Object.entries(liquidity).forEach(([poolAddress,
|
|
495
|
-
* 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}`);
|
|
496
503
|
* });
|
|
497
504
|
* ```
|
|
498
505
|
*/
|
|
499
|
-
abstract getAllBaseAssetsLiquidity(): Promise<Record<Address,
|
|
506
|
+
abstract getAllBaseAssetsLiquidity(): Promise<Record<Address, BaseLiquidityDetails>>;
|
|
500
507
|
/**
|
|
501
508
|
* Fetches all withdrawable quote assets for a specific user or liquidity provider.
|
|
502
509
|
*
|
|
@@ -604,9 +611,9 @@ declare abstract class BaseClient<TSigner = unknown> {
|
|
|
604
611
|
*/
|
|
605
612
|
abstract getPoolConfigByBaseAsset(baseAssetSymbol: string): Promise<PoolConfig>;
|
|
606
613
|
/**
|
|
607
|
-
* Executes a
|
|
614
|
+
* Executes a swap operation on the blockchain from one asset to another.
|
|
608
615
|
*
|
|
609
|
-
* 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
|
|
610
617
|
* amount varies based on current pool conditions and fees. The transaction includes
|
|
611
618
|
* slippage protection through the optional minimumAmountOut parameter.
|
|
612
619
|
*
|
|
@@ -630,7 +637,7 @@ declare abstract class BaseClient<TSigner = unknown> {
|
|
|
630
637
|
* @example
|
|
631
638
|
* ```typescript
|
|
632
639
|
* // Swap exactly 1 ARCH for USDC (output amount varies)
|
|
633
|
-
* const result = await client.
|
|
640
|
+
* const result = await client.swap(signer, {
|
|
634
641
|
* assetIn: "aarch",
|
|
635
642
|
* amountIn: "1000000000000000000", // Exactly 1 ARCH (18 decimals)
|
|
636
643
|
* assetOut: "ibc/43897B9739BD63E3A08A88191999C632E052724AB96BD4C74AE31375C991F48D", // USDC IBC denom
|
|
@@ -650,73 +657,77 @@ declare abstract class BaseClient<TSigner = unknown> {
|
|
|
650
657
|
* - Fees are deducted from the output
|
|
651
658
|
* - Use minimumAmountOut to protect against excessive slippage
|
|
652
659
|
*/
|
|
653
|
-
abstract
|
|
660
|
+
abstract swap(signer: TSigner, params: SwapParams): Promise<SwapResult>;
|
|
654
661
|
}
|
|
655
662
|
|
|
656
|
-
|
|
663
|
+
type CosmWasmClientConfig = ClientConfig & {
|
|
657
664
|
chain?: CosmWasmChain;
|
|
658
665
|
cosmWasmClient?: CosmWasmClient | ArchwayClient;
|
|
659
666
|
signingCosmWasmClient?: SigningCosmWasmClient | SigningArchwayClient;
|
|
660
|
-
}
|
|
667
|
+
};
|
|
661
668
|
declare enum CosmWasmChain {
|
|
662
669
|
Archway = "archway"
|
|
663
670
|
}
|
|
664
671
|
|
|
665
|
-
|
|
672
|
+
type QueryOracleConfigResponse = {
|
|
666
673
|
admin: Address;
|
|
667
674
|
price_threshold_ratio: string;
|
|
668
675
|
price_expire_time: Duration | null;
|
|
669
|
-
}
|
|
670
|
-
|
|
676
|
+
};
|
|
677
|
+
type PriceRepresentation = {
|
|
671
678
|
asset_pair: AssetPairString;
|
|
672
679
|
price: string;
|
|
673
680
|
expiry_time: Timestamp;
|
|
674
|
-
}
|
|
675
|
-
|
|
681
|
+
};
|
|
682
|
+
type InvertiblePriceRepresentation = PriceRepresentation & {
|
|
676
683
|
is_inverse: boolean;
|
|
677
|
-
}
|
|
678
|
-
|
|
684
|
+
};
|
|
685
|
+
type QueryPriceResponse = {
|
|
679
686
|
pair_data: InvertiblePriceRepresentation;
|
|
680
|
-
}
|
|
681
|
-
|
|
687
|
+
};
|
|
688
|
+
type QueryPricesResponse = {
|
|
682
689
|
prices: PriceRepresentation[];
|
|
683
|
-
}
|
|
684
|
-
|
|
690
|
+
};
|
|
691
|
+
type QueryAssetPairsResponse = {
|
|
685
692
|
list: OracleAssetPair[];
|
|
686
|
-
}
|
|
693
|
+
};
|
|
687
694
|
|
|
688
|
-
|
|
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
|
+
};
|
|
708
|
+
|
|
709
|
+
type QueryRouterConfigResponse = {
|
|
689
710
|
admin: Address;
|
|
690
711
|
default_price_oracle_contract: Address;
|
|
691
712
|
default_protocol_fee_recipient: Address;
|
|
692
713
|
default_protocol_fee: string;
|
|
693
714
|
default_lp_fee: string;
|
|
694
715
|
settlement_code_id: number;
|
|
695
|
-
}
|
|
696
|
-
|
|
716
|
+
};
|
|
717
|
+
type MarketRepresentation = {
|
|
697
718
|
market_address: Address;
|
|
698
719
|
base_asset_symbol: string;
|
|
699
720
|
quote_assets_symbols: string[];
|
|
700
|
-
}
|
|
701
|
-
|
|
721
|
+
};
|
|
722
|
+
type QueryMarketsResponse = {
|
|
702
723
|
markets: MarketRepresentation[];
|
|
703
|
-
}
|
|
704
|
-
|
|
705
|
-
liquidity: Record<Address,
|
|
706
|
-
}
|
|
707
|
-
|
|
724
|
+
};
|
|
725
|
+
type QueryBaseLiquidityAllResponse = {
|
|
726
|
+
liquidity: Record<Address, QueryBaseLiquidityResponse>;
|
|
727
|
+
};
|
|
728
|
+
type QueryQuotesForUserAllResponse = {
|
|
708
729
|
quotes: Record<Address, Coin[]>;
|
|
709
|
-
}
|
|
710
|
-
|
|
711
|
-
interface QuerySettlementConfigResponse {
|
|
712
|
-
price_oracle_contract: Address;
|
|
713
|
-
protocol_fee_recipient: Address;
|
|
714
|
-
protocol_fee: string;
|
|
715
|
-
lp_fee: string;
|
|
716
|
-
allowance_mode: AllowanceMode;
|
|
717
|
-
lps: Address[];
|
|
718
|
-
min_base_out: string;
|
|
719
|
-
}
|
|
730
|
+
};
|
|
720
731
|
|
|
721
732
|
/**
|
|
722
733
|
* Client implementation for interacting with the Bolt Liquidity Outpost on CosmWasm-based blockchains.
|
|
@@ -858,7 +869,7 @@ declare class BoltCosmWasmClient extends BaseClient<OfflineSigner> {
|
|
|
858
869
|
/** @inheritdoc */
|
|
859
870
|
getRouterConfig(): Promise<RouterConfig>;
|
|
860
871
|
/** @inheritdoc */
|
|
861
|
-
getAllBaseAssetsLiquidity(): Promise<Record<Address,
|
|
872
|
+
getAllBaseAssetsLiquidity(): Promise<Record<Address, BaseLiquidityDetails>>;
|
|
862
873
|
/** @inheritdoc */
|
|
863
874
|
getAllQuotesByUser(address: Address): Promise<Record<Address, Coin[]>>;
|
|
864
875
|
/** @inheritdoc */
|
|
@@ -892,7 +903,7 @@ declare class BoltCosmWasmClient extends BaseClient<OfflineSigner> {
|
|
|
892
903
|
* console.log(`Gas used: ${result.gasUsed}`);
|
|
893
904
|
* ```
|
|
894
905
|
*/
|
|
895
|
-
|
|
906
|
+
swap(signer: OfflineSigner, params: SwapParams): Promise<SwapResult<ExecuteResult>>;
|
|
896
907
|
}
|
|
897
908
|
|
|
898
|
-
export { type Address, AllowanceMode, type AssetPairString, BaseClient, BoltCosmWasmClient, type BoltSdkError, BoltSdkErrorBase, BoltSdkErrorCode, type ClientConfig, type Coin, type Contracts, CosmWasmChain, type CosmWasmClientConfig, type Duration, Environment, InsufficientFundsError, InvalidAddressError, InvalidObjectError, InvalidParameterError, InvalidTypeError, type InvertiblePrice, type InvertiblePriceRepresentation, type MarketRepresentation, MissingParameterError, NetworkError, NotFoundError, type OracleAsset, type OracleAssetPair, type OracleConfig, ParameterOutOfRangeError, type Pool, type PoolConfig, type Price, type PriceRepresentation, type QueryAssetPairsResponse, type QueryBaseLiquidityAllResponse, type QueryMarketsResponse, type QueryOracleConfigResponse, type QueryPriceResponse, type QueryPricesResponse, type QueryQuotesForUserAllResponse, type QueryRouterConfigResponse, type QuerySettlementConfigResponse, 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
|
@@ -297,7 +297,7 @@ var archway_testnet_default = {
|
|
|
297
297
|
restEndpoint: "https://api.constantine.archway.io"
|
|
298
298
|
},
|
|
299
299
|
contracts: {
|
|
300
|
-
oracle: "
|
|
300
|
+
oracle: "archway1ehpghtr0v95kfx648dck7pvs08d6ah97l99xkx87t2zx8tcyen0s9n90x4",
|
|
301
301
|
router: "archway1h5x6upghew9xkfek85q48let2twdxq33sgsnzze5weshla46xd8sttps44"
|
|
302
302
|
}
|
|
303
303
|
};
|
|
@@ -369,6 +369,19 @@ var parseQuerySettlementConfigResponse = (response) => {
|
|
|
369
369
|
minBaseOut: response.min_base_out
|
|
370
370
|
};
|
|
371
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
|
+
};
|
|
372
385
|
|
|
373
386
|
// src/lib/helpers/transactions.ts
|
|
374
387
|
var getSignerAddress = async (signer) => {
|
|
@@ -412,7 +425,7 @@ var getAllBaseLiquidity = async (client) => {
|
|
|
412
425
|
const response = await cosmWasmClient.queryContractSmart(client.contracts.router, {
|
|
413
426
|
base_liquidity_all: {}
|
|
414
427
|
});
|
|
415
|
-
return response
|
|
428
|
+
return parseQueryBaseLiquidityAllResponse(response);
|
|
416
429
|
};
|
|
417
430
|
|
|
418
431
|
// src/lib/router/get-all-quotes-for-user.ts
|
|
@@ -456,7 +469,7 @@ var BOLT_SWAP_EVENT_TYPE = "wasm-bolt_swap";
|
|
|
456
469
|
var BOLT_COIN_RECEIVED_EVENT_TYPE = "coin_received";
|
|
457
470
|
var BOLT_COIN_RECEIVED_EVENT_AMOUNT_KEY = "amount";
|
|
458
471
|
|
|
459
|
-
// src/lib/router/swap.ts
|
|
472
|
+
// src/lib/router/swap-exact-in.ts
|
|
460
473
|
var swapExactIn = async (client, signer, { assetIn, amountIn, assetOut, minimumAmountOut, receiver }) => {
|
|
461
474
|
const signingCosmWasmClient = await client.getSigningCosmWasmClient(signer);
|
|
462
475
|
const address = await getSignerAddress(signer);
|
|
@@ -740,7 +753,7 @@ var BoltCosmWasmClient = class extends BaseClient {
|
|
|
740
753
|
* console.log(`Gas used: ${result.gasUsed}`);
|
|
741
754
|
* ```
|
|
742
755
|
*/
|
|
743
|
-
async
|
|
756
|
+
async swap(signer, params) {
|
|
744
757
|
return await swapExactIn(this, signer, params);
|
|
745
758
|
}
|
|
746
759
|
};
|