@bolt-liquidity-hq/cosmwasm-client 0.1.0-beta.10 → 0.1.0-beta.11
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.cjs +159 -42
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +64 -20
- package/dist/index.d.ts +64 -20
- package/dist/index.js +151 -34
- package/dist/index.js.map +1 -1
- package/package.json +17 -13
package/dist/index.d.cts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ArchwayClient, SigningArchwayClient } from '@archwayhq/arch3.js';
|
|
2
|
-
import { ChainConfig, ClientConfig, Address, Duration,
|
|
2
|
+
import { ChainConfig, ClientConfig, Address, Duration, Timestamp, OracleAssetPair, Coin, AllowanceMode, RouterConfig, BaseClient, OracleConfig, InvertiblePrice, Price, BaseLiquidityDetails, Pool, PoolConfig, Asset, SwapParams, SwapResult } from '@bolt-liquidity-hq/core';
|
|
3
3
|
import { CosmWasmClient, SigningCosmWasmClient, ExecuteResult } from '@cosmjs/cosmwasm-stargate';
|
|
4
4
|
import { OfflineSigner } from '@cosmjs/proto-signing';
|
|
5
5
|
|
|
@@ -10,10 +10,16 @@ type CosmWasmChainConfig = ChainConfig & {
|
|
|
10
10
|
type CosmWasmClientConfig = ClientConfig<CosmWasmChainConfig> & {
|
|
11
11
|
chain?: CosmWasmChain;
|
|
12
12
|
cosmWasmClient?: CosmWasmClient | ArchwayClient;
|
|
13
|
+
signer?: OfflineSigner;
|
|
13
14
|
signingCosmWasmClient?: SigningCosmWasmClient | SigningArchwayClient;
|
|
14
15
|
};
|
|
15
16
|
type CosmWasmChain = 'archway';
|
|
17
|
+
type SignerWithSigningClient = {
|
|
18
|
+
signer: OfflineSigner;
|
|
19
|
+
signingCosmWasmClient: SigningCosmWasmClient | SigningArchwayClient;
|
|
20
|
+
};
|
|
16
21
|
|
|
22
|
+
type AssetPairString = string;
|
|
17
23
|
type QueryOracleConfigResponse = {
|
|
18
24
|
admin: Address;
|
|
19
25
|
price_threshold_ratio: string;
|
|
@@ -94,17 +100,17 @@ type QueryQuotesForUserAllResponse = {
|
|
|
94
100
|
* const client = new BoltCosmWasmClient();
|
|
95
101
|
*
|
|
96
102
|
* // Query oracle prices
|
|
97
|
-
* const price = await client.getPrice("
|
|
103
|
+
* const price = await client.getPrice("aarch", "ibc/...");
|
|
98
104
|
*
|
|
99
105
|
* // Execute a swap (requires signer)
|
|
100
106
|
* const signer = await DirectSecp256k1HdWallet.fromMnemonic("my mnemonic goes here", {
|
|
101
107
|
* prefix: 'archway',
|
|
102
108
|
* });
|
|
103
|
-
* const result = await client.swap(
|
|
109
|
+
* const result = await client.swap({
|
|
104
110
|
* assetIn: "aarch",
|
|
105
111
|
* amountIn: "1000000",
|
|
106
112
|
* assetOut: "ibc/43897B9739BD63E3A08A88191999C632E052724AB96BD4C74AE31375C991F48D"
|
|
107
|
-
* });
|
|
113
|
+
* }, signer);
|
|
108
114
|
* ```
|
|
109
115
|
*/
|
|
110
116
|
declare class BoltCosmWasmClient extends BaseClient<OfflineSigner, ExecuteResult> {
|
|
@@ -117,6 +123,11 @@ declare class BoltCosmWasmClient extends BaseClient<OfflineSigner, ExecuteResult
|
|
|
117
123
|
* @private
|
|
118
124
|
*/
|
|
119
125
|
private _cosmWasmClient?;
|
|
126
|
+
/**
|
|
127
|
+
* Cached instance of the Signer for transaction execution
|
|
128
|
+
* @private
|
|
129
|
+
*/
|
|
130
|
+
private _signer?;
|
|
120
131
|
/**
|
|
121
132
|
* Cached instance of the signing CosmWasm client for transaction execution
|
|
122
133
|
* @private
|
|
@@ -130,12 +141,13 @@ declare class BoltCosmWasmClient extends BaseClient<OfflineSigner, ExecuteResult
|
|
|
130
141
|
* Creates a new instance of the BoltCosmWasmClient.
|
|
131
142
|
*
|
|
132
143
|
* The client automatically configures itself based on the specified chain and environment,
|
|
133
|
-
* loading the appropriate contract addresses, chain configuration,
|
|
144
|
+
* loading the appropriate contract addresses, chain configuration, native token denomination,
|
|
145
|
+
* and assets from configuration files.
|
|
134
146
|
*
|
|
135
147
|
* @param config - (Optional) Configuration for the client
|
|
136
148
|
* @param config.environment - (Optional) The deployment environment ('mainnet' or 'testnet'). Defaults to 'mainnet'
|
|
137
149
|
* @param config.chain - (Optional) The specific CosmWasm chain to connect to. Defaults to 'archway'
|
|
138
|
-
* @param config.customOverride - (Optional) Custom overrides for chain configuration, contracts, and assets
|
|
150
|
+
* @param config.customOverride - (Optional) Custom overrides for chain configuration, contracts, native token, and assets
|
|
139
151
|
* @param config.customOverride.chainConfig - (Optional) Override chain configuration
|
|
140
152
|
* @param config.customOverride.chainConfig.id - (Optional) Custom chain ID
|
|
141
153
|
* @param config.customOverride.chainConfig.name - (Optional) Custom chain name
|
|
@@ -144,8 +156,10 @@ declare class BoltCosmWasmClient extends BaseClient<OfflineSigner, ExecuteResult
|
|
|
144
156
|
* @param config.customOverride.contracts - (Optional) Override contract addresses
|
|
145
157
|
* @param config.customOverride.contracts.oracle - (Optional) Custom oracle contract address
|
|
146
158
|
* @param config.customOverride.contracts.router - (Optional) Custom router contract address
|
|
159
|
+
* @param config.customOverride.nativeTokenDenom - (Optional) Custom native token denomination (e.g., "aarch")
|
|
147
160
|
* @param config.customOverride.assetsConfig - (Optional) Custom asset configurations indexed by denom
|
|
148
161
|
* @param config.cosmWasmClient - (Optional) Pre-existing CosmWasmClient to use for blockchain queries
|
|
162
|
+
* @param config.signer - (Optional) Pre-existing OfflineSigner for transaction signing
|
|
149
163
|
* @param config.signingCosmWasmClient - (Optional) Pre-existing SigningCosmWasmClient to use for blockchain transactions
|
|
150
164
|
*
|
|
151
165
|
* @throws {InvalidTypeError} Thrown when an unsupported chain is specified
|
|
@@ -173,6 +187,7 @@ declare class BoltCosmWasmClient extends BaseClient<OfflineSigner, ExecuteResult
|
|
|
173
187
|
* oracle: 'archway1custom_oracle...',
|
|
174
188
|
* router: 'archway1custom_router...'
|
|
175
189
|
* },
|
|
190
|
+
* nativeTokenDenom: 'aarch',
|
|
176
191
|
* assetsConfig: {
|
|
177
192
|
* 'aarch': {
|
|
178
193
|
* symbol: 'ARCH',
|
|
@@ -190,6 +205,7 @@ declare class BoltCosmWasmClient extends BaseClient<OfflineSigner, ExecuteResult
|
|
|
190
205
|
* // Use pre-existing CosmWasm clients
|
|
191
206
|
* const clientWithCustomClients = new BoltCosmWasmClient({
|
|
192
207
|
* cosmWasmClient: myCosmWasmClient,
|
|
208
|
+
* signer: mySigner,
|
|
193
209
|
* signingCosmWasmClient: mySigningClient
|
|
194
210
|
* });
|
|
195
211
|
* ```
|
|
@@ -213,18 +229,18 @@ declare class BoltCosmWasmClient extends BaseClient<OfflineSigner, ExecuteResult
|
|
|
213
229
|
*/
|
|
214
230
|
getCosmWasmClient(): Promise<CosmWasmClient | ArchwayClient>;
|
|
215
231
|
/**
|
|
216
|
-
* Gets or creates a signing CosmWasm client instance for transaction execution.
|
|
232
|
+
* Gets or creates a signing CosmWasm client instance along with the signer for transaction execution.
|
|
217
233
|
*
|
|
218
|
-
* This method implements lazy initialization and caching of the signing client.
|
|
234
|
+
* This method implements lazy initialization and caching of both the signing client and signer.
|
|
219
235
|
* A signer must be provided either on first call or to replace the cached instance.
|
|
220
236
|
* The appropriate client type is selected based on the configured chain.
|
|
221
237
|
*
|
|
222
|
-
* @param
|
|
223
|
-
*
|
|
238
|
+
* @param newSigner - Optional offline signer for transaction signing. Required on first call
|
|
239
|
+
* or to replace the existing signer
|
|
224
240
|
*
|
|
225
|
-
* @returns A promise that resolves to the signing
|
|
241
|
+
* @returns A promise that resolves to an object containing both the signer and signing client
|
|
226
242
|
*
|
|
227
|
-
* @throws {MissingParameterError} Thrown when no signer is provided and no cached
|
|
243
|
+
* @throws {MissingParameterError} Thrown when no signer is provided and no cached signer exists
|
|
228
244
|
*
|
|
229
245
|
* @example
|
|
230
246
|
* ```typescript
|
|
@@ -232,13 +248,13 @@ declare class BoltCosmWasmClient extends BaseClient<OfflineSigner, ExecuteResult
|
|
|
232
248
|
* const signer = await DirectSecp256k1HdWallet.fromMnemonic("my mnemonic goes here", {
|
|
233
249
|
* prefix: 'archway',
|
|
234
250
|
* });
|
|
235
|
-
* const
|
|
251
|
+
* const { signer: cachedSigner, signingCosmWasmClient } = await boltClient.getSignerWithSigningClient(signer);
|
|
236
252
|
*
|
|
237
|
-
* // Subsequent calls can reuse the cached client
|
|
238
|
-
* const
|
|
253
|
+
* // Subsequent calls can reuse the cached signer and client
|
|
254
|
+
* const { signer, signingCosmWasmClient: client } = await boltClient.getSignerWithSigningClient();
|
|
239
255
|
* ```
|
|
240
256
|
*/
|
|
241
|
-
|
|
257
|
+
getSignerWithSigningClient(newSigner?: OfflineSigner): Promise<SignerWithSigningClient>;
|
|
242
258
|
/** @inheritdoc */
|
|
243
259
|
getOracleConfig(): Promise<OracleConfig>;
|
|
244
260
|
/** @inheritdoc */
|
|
@@ -272,13 +288,13 @@ declare class BoltCosmWasmClient extends BaseClient<OfflineSigner, ExecuteResult
|
|
|
272
288
|
* const signer = await window.keplr.getOfflineSignerAuto(chainId);
|
|
273
289
|
*
|
|
274
290
|
* // Execute swap: 1 ARCH for USDC
|
|
275
|
-
* const result = await client.swap(
|
|
291
|
+
* const result = await client.swap({
|
|
276
292
|
* assetIn: "aarch",
|
|
277
293
|
* amountIn: "1000000000000000000", // 1 ARCH (18 decimals)
|
|
278
294
|
* assetOut: "ibc/43897B9739BD63E3A08A88191999C632E052724AB96BD4C74AE31375C991F48D", // USDC IBC denom
|
|
279
295
|
* minimumAmountOut: "1950000000", // Minimum 1950 USDC expected
|
|
280
296
|
* receiver: "archway1..." // Optional custom receiver
|
|
281
|
-
* });
|
|
297
|
+
* }, signer);
|
|
282
298
|
*
|
|
283
299
|
* console.log(`Swap successful!`);
|
|
284
300
|
* console.log(`Transaction hash: ${result.txHash}`);
|
|
@@ -291,7 +307,35 @@ declare class BoltCosmWasmClient extends BaseClient<OfflineSigner, ExecuteResult
|
|
|
291
307
|
* This implementation returns a CosmWasm ExecuteResult as the transaction output,
|
|
292
308
|
* which includes details like gas used, block height, transaction hash, and events.
|
|
293
309
|
*/
|
|
294
|
-
swap(
|
|
310
|
+
swap(params: SwapParams, signer?: OfflineSigner): Promise<SwapResult<ExecuteResult>>;
|
|
311
|
+
/**
|
|
312
|
+
* @inheritdoc
|
|
313
|
+
*
|
|
314
|
+
* @example
|
|
315
|
+
* ```typescript
|
|
316
|
+
* // Get signer (e.g., from Keplr wallet)
|
|
317
|
+
* const signer = await window.keplr.getOfflineSignerAuto(chainId);
|
|
318
|
+
*
|
|
319
|
+
* // Estimate gas for swapping 1 ARCH to USDC
|
|
320
|
+
* const gasEstimate = await client.estimateSwapGasFees({
|
|
321
|
+
* assetIn: "aarch",
|
|
322
|
+
* amountIn: "1000000000000000000", // 1 ARCH
|
|
323
|
+
* assetOut: "ibc/43897B9739BD63E3A08A88191999C632E052724AB96BD4C74AE31375C991F48D", // USDC
|
|
324
|
+
* minimumAmountOut: "1950000000" // Min 1950 USDC
|
|
325
|
+
* }, signer, 1.3); // 30% safety margin
|
|
326
|
+
*
|
|
327
|
+
* if (gasEstimate) {
|
|
328
|
+
* console.log(`Estimated gas: ${gasEstimate.amount} ${gasEstimate.denom}`);
|
|
329
|
+
* }
|
|
330
|
+
* ```
|
|
331
|
+
*
|
|
332
|
+
* @remarks
|
|
333
|
+
* - For CosmWasm chains, gas is always paid in the native token (e.g., "aarch" for Archway)
|
|
334
|
+
* - The returned amount is in the smallest denomination (6 decimals for most Cosmos chains)
|
|
335
|
+
* - Gas estimation uses CosmWasm's simulation capabilities
|
|
336
|
+
* - The gasAdjustment parameter helps account for variations in actual execution
|
|
337
|
+
*/
|
|
338
|
+
estimateSwapGasFees(params: SwapParams, signer: OfflineSigner, gasAdjustment?: number): Promise<Coin | undefined>;
|
|
295
339
|
}
|
|
296
340
|
|
|
297
|
-
export { BoltCosmWasmClient, type CosmWasmChain, type CosmWasmChainConfig, type CosmWasmClientConfig, type CosmWasmRouterConfig, type InvertiblePriceRepresentation, type MarketRepresentation, type PriceRepresentation, type QueryAssetPairsResponse, type QueryBaseLiquidityAllResponse, type QueryBaseLiquidityResponse, type QueryMarketsResponse, type QueryOracleConfigResponse, type QueryPriceResponse, type QueryPricesResponse, type QueryQuotesForUserAllResponse, type QueryRouterConfigResponse, type QuerySettlementConfigResponse };
|
|
341
|
+
export { type AssetPairString, BoltCosmWasmClient, type CosmWasmChain, type CosmWasmChainConfig, type CosmWasmClientConfig, type CosmWasmRouterConfig, type InvertiblePriceRepresentation, type MarketRepresentation, type PriceRepresentation, type QueryAssetPairsResponse, type QueryBaseLiquidityAllResponse, type QueryBaseLiquidityResponse, type QueryMarketsResponse, type QueryOracleConfigResponse, type QueryPriceResponse, type QueryPricesResponse, type QueryQuotesForUserAllResponse, type QueryRouterConfigResponse, type QuerySettlementConfigResponse, type SignerWithSigningClient };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ArchwayClient, SigningArchwayClient } from '@archwayhq/arch3.js';
|
|
2
|
-
import { ChainConfig, ClientConfig, Address, Duration,
|
|
2
|
+
import { ChainConfig, ClientConfig, Address, Duration, Timestamp, OracleAssetPair, Coin, AllowanceMode, RouterConfig, BaseClient, OracleConfig, InvertiblePrice, Price, BaseLiquidityDetails, Pool, PoolConfig, Asset, SwapParams, SwapResult } from '@bolt-liquidity-hq/core';
|
|
3
3
|
import { CosmWasmClient, SigningCosmWasmClient, ExecuteResult } from '@cosmjs/cosmwasm-stargate';
|
|
4
4
|
import { OfflineSigner } from '@cosmjs/proto-signing';
|
|
5
5
|
|
|
@@ -10,10 +10,16 @@ type CosmWasmChainConfig = ChainConfig & {
|
|
|
10
10
|
type CosmWasmClientConfig = ClientConfig<CosmWasmChainConfig> & {
|
|
11
11
|
chain?: CosmWasmChain;
|
|
12
12
|
cosmWasmClient?: CosmWasmClient | ArchwayClient;
|
|
13
|
+
signer?: OfflineSigner;
|
|
13
14
|
signingCosmWasmClient?: SigningCosmWasmClient | SigningArchwayClient;
|
|
14
15
|
};
|
|
15
16
|
type CosmWasmChain = 'archway';
|
|
17
|
+
type SignerWithSigningClient = {
|
|
18
|
+
signer: OfflineSigner;
|
|
19
|
+
signingCosmWasmClient: SigningCosmWasmClient | SigningArchwayClient;
|
|
20
|
+
};
|
|
16
21
|
|
|
22
|
+
type AssetPairString = string;
|
|
17
23
|
type QueryOracleConfigResponse = {
|
|
18
24
|
admin: Address;
|
|
19
25
|
price_threshold_ratio: string;
|
|
@@ -94,17 +100,17 @@ type QueryQuotesForUserAllResponse = {
|
|
|
94
100
|
* const client = new BoltCosmWasmClient();
|
|
95
101
|
*
|
|
96
102
|
* // Query oracle prices
|
|
97
|
-
* const price = await client.getPrice("
|
|
103
|
+
* const price = await client.getPrice("aarch", "ibc/...");
|
|
98
104
|
*
|
|
99
105
|
* // Execute a swap (requires signer)
|
|
100
106
|
* const signer = await DirectSecp256k1HdWallet.fromMnemonic("my mnemonic goes here", {
|
|
101
107
|
* prefix: 'archway',
|
|
102
108
|
* });
|
|
103
|
-
* const result = await client.swap(
|
|
109
|
+
* const result = await client.swap({
|
|
104
110
|
* assetIn: "aarch",
|
|
105
111
|
* amountIn: "1000000",
|
|
106
112
|
* assetOut: "ibc/43897B9739BD63E3A08A88191999C632E052724AB96BD4C74AE31375C991F48D"
|
|
107
|
-
* });
|
|
113
|
+
* }, signer);
|
|
108
114
|
* ```
|
|
109
115
|
*/
|
|
110
116
|
declare class BoltCosmWasmClient extends BaseClient<OfflineSigner, ExecuteResult> {
|
|
@@ -117,6 +123,11 @@ declare class BoltCosmWasmClient extends BaseClient<OfflineSigner, ExecuteResult
|
|
|
117
123
|
* @private
|
|
118
124
|
*/
|
|
119
125
|
private _cosmWasmClient?;
|
|
126
|
+
/**
|
|
127
|
+
* Cached instance of the Signer for transaction execution
|
|
128
|
+
* @private
|
|
129
|
+
*/
|
|
130
|
+
private _signer?;
|
|
120
131
|
/**
|
|
121
132
|
* Cached instance of the signing CosmWasm client for transaction execution
|
|
122
133
|
* @private
|
|
@@ -130,12 +141,13 @@ declare class BoltCosmWasmClient extends BaseClient<OfflineSigner, ExecuteResult
|
|
|
130
141
|
* Creates a new instance of the BoltCosmWasmClient.
|
|
131
142
|
*
|
|
132
143
|
* The client automatically configures itself based on the specified chain and environment,
|
|
133
|
-
* loading the appropriate contract addresses, chain configuration,
|
|
144
|
+
* loading the appropriate contract addresses, chain configuration, native token denomination,
|
|
145
|
+
* and assets from configuration files.
|
|
134
146
|
*
|
|
135
147
|
* @param config - (Optional) Configuration for the client
|
|
136
148
|
* @param config.environment - (Optional) The deployment environment ('mainnet' or 'testnet'). Defaults to 'mainnet'
|
|
137
149
|
* @param config.chain - (Optional) The specific CosmWasm chain to connect to. Defaults to 'archway'
|
|
138
|
-
* @param config.customOverride - (Optional) Custom overrides for chain configuration, contracts, and assets
|
|
150
|
+
* @param config.customOverride - (Optional) Custom overrides for chain configuration, contracts, native token, and assets
|
|
139
151
|
* @param config.customOverride.chainConfig - (Optional) Override chain configuration
|
|
140
152
|
* @param config.customOverride.chainConfig.id - (Optional) Custom chain ID
|
|
141
153
|
* @param config.customOverride.chainConfig.name - (Optional) Custom chain name
|
|
@@ -144,8 +156,10 @@ declare class BoltCosmWasmClient extends BaseClient<OfflineSigner, ExecuteResult
|
|
|
144
156
|
* @param config.customOverride.contracts - (Optional) Override contract addresses
|
|
145
157
|
* @param config.customOverride.contracts.oracle - (Optional) Custom oracle contract address
|
|
146
158
|
* @param config.customOverride.contracts.router - (Optional) Custom router contract address
|
|
159
|
+
* @param config.customOverride.nativeTokenDenom - (Optional) Custom native token denomination (e.g., "aarch")
|
|
147
160
|
* @param config.customOverride.assetsConfig - (Optional) Custom asset configurations indexed by denom
|
|
148
161
|
* @param config.cosmWasmClient - (Optional) Pre-existing CosmWasmClient to use for blockchain queries
|
|
162
|
+
* @param config.signer - (Optional) Pre-existing OfflineSigner for transaction signing
|
|
149
163
|
* @param config.signingCosmWasmClient - (Optional) Pre-existing SigningCosmWasmClient to use for blockchain transactions
|
|
150
164
|
*
|
|
151
165
|
* @throws {InvalidTypeError} Thrown when an unsupported chain is specified
|
|
@@ -173,6 +187,7 @@ declare class BoltCosmWasmClient extends BaseClient<OfflineSigner, ExecuteResult
|
|
|
173
187
|
* oracle: 'archway1custom_oracle...',
|
|
174
188
|
* router: 'archway1custom_router...'
|
|
175
189
|
* },
|
|
190
|
+
* nativeTokenDenom: 'aarch',
|
|
176
191
|
* assetsConfig: {
|
|
177
192
|
* 'aarch': {
|
|
178
193
|
* symbol: 'ARCH',
|
|
@@ -190,6 +205,7 @@ declare class BoltCosmWasmClient extends BaseClient<OfflineSigner, ExecuteResult
|
|
|
190
205
|
* // Use pre-existing CosmWasm clients
|
|
191
206
|
* const clientWithCustomClients = new BoltCosmWasmClient({
|
|
192
207
|
* cosmWasmClient: myCosmWasmClient,
|
|
208
|
+
* signer: mySigner,
|
|
193
209
|
* signingCosmWasmClient: mySigningClient
|
|
194
210
|
* });
|
|
195
211
|
* ```
|
|
@@ -213,18 +229,18 @@ declare class BoltCosmWasmClient extends BaseClient<OfflineSigner, ExecuteResult
|
|
|
213
229
|
*/
|
|
214
230
|
getCosmWasmClient(): Promise<CosmWasmClient | ArchwayClient>;
|
|
215
231
|
/**
|
|
216
|
-
* Gets or creates a signing CosmWasm client instance for transaction execution.
|
|
232
|
+
* Gets or creates a signing CosmWasm client instance along with the signer for transaction execution.
|
|
217
233
|
*
|
|
218
|
-
* This method implements lazy initialization and caching of the signing client.
|
|
234
|
+
* This method implements lazy initialization and caching of both the signing client and signer.
|
|
219
235
|
* A signer must be provided either on first call or to replace the cached instance.
|
|
220
236
|
* The appropriate client type is selected based on the configured chain.
|
|
221
237
|
*
|
|
222
|
-
* @param
|
|
223
|
-
*
|
|
238
|
+
* @param newSigner - Optional offline signer for transaction signing. Required on first call
|
|
239
|
+
* or to replace the existing signer
|
|
224
240
|
*
|
|
225
|
-
* @returns A promise that resolves to the signing
|
|
241
|
+
* @returns A promise that resolves to an object containing both the signer and signing client
|
|
226
242
|
*
|
|
227
|
-
* @throws {MissingParameterError} Thrown when no signer is provided and no cached
|
|
243
|
+
* @throws {MissingParameterError} Thrown when no signer is provided and no cached signer exists
|
|
228
244
|
*
|
|
229
245
|
* @example
|
|
230
246
|
* ```typescript
|
|
@@ -232,13 +248,13 @@ declare class BoltCosmWasmClient extends BaseClient<OfflineSigner, ExecuteResult
|
|
|
232
248
|
* const signer = await DirectSecp256k1HdWallet.fromMnemonic("my mnemonic goes here", {
|
|
233
249
|
* prefix: 'archway',
|
|
234
250
|
* });
|
|
235
|
-
* const
|
|
251
|
+
* const { signer: cachedSigner, signingCosmWasmClient } = await boltClient.getSignerWithSigningClient(signer);
|
|
236
252
|
*
|
|
237
|
-
* // Subsequent calls can reuse the cached client
|
|
238
|
-
* const
|
|
253
|
+
* // Subsequent calls can reuse the cached signer and client
|
|
254
|
+
* const { signer, signingCosmWasmClient: client } = await boltClient.getSignerWithSigningClient();
|
|
239
255
|
* ```
|
|
240
256
|
*/
|
|
241
|
-
|
|
257
|
+
getSignerWithSigningClient(newSigner?: OfflineSigner): Promise<SignerWithSigningClient>;
|
|
242
258
|
/** @inheritdoc */
|
|
243
259
|
getOracleConfig(): Promise<OracleConfig>;
|
|
244
260
|
/** @inheritdoc */
|
|
@@ -272,13 +288,13 @@ declare class BoltCosmWasmClient extends BaseClient<OfflineSigner, ExecuteResult
|
|
|
272
288
|
* const signer = await window.keplr.getOfflineSignerAuto(chainId);
|
|
273
289
|
*
|
|
274
290
|
* // Execute swap: 1 ARCH for USDC
|
|
275
|
-
* const result = await client.swap(
|
|
291
|
+
* const result = await client.swap({
|
|
276
292
|
* assetIn: "aarch",
|
|
277
293
|
* amountIn: "1000000000000000000", // 1 ARCH (18 decimals)
|
|
278
294
|
* assetOut: "ibc/43897B9739BD63E3A08A88191999C632E052724AB96BD4C74AE31375C991F48D", // USDC IBC denom
|
|
279
295
|
* minimumAmountOut: "1950000000", // Minimum 1950 USDC expected
|
|
280
296
|
* receiver: "archway1..." // Optional custom receiver
|
|
281
|
-
* });
|
|
297
|
+
* }, signer);
|
|
282
298
|
*
|
|
283
299
|
* console.log(`Swap successful!`);
|
|
284
300
|
* console.log(`Transaction hash: ${result.txHash}`);
|
|
@@ -291,7 +307,35 @@ declare class BoltCosmWasmClient extends BaseClient<OfflineSigner, ExecuteResult
|
|
|
291
307
|
* This implementation returns a CosmWasm ExecuteResult as the transaction output,
|
|
292
308
|
* which includes details like gas used, block height, transaction hash, and events.
|
|
293
309
|
*/
|
|
294
|
-
swap(
|
|
310
|
+
swap(params: SwapParams, signer?: OfflineSigner): Promise<SwapResult<ExecuteResult>>;
|
|
311
|
+
/**
|
|
312
|
+
* @inheritdoc
|
|
313
|
+
*
|
|
314
|
+
* @example
|
|
315
|
+
* ```typescript
|
|
316
|
+
* // Get signer (e.g., from Keplr wallet)
|
|
317
|
+
* const signer = await window.keplr.getOfflineSignerAuto(chainId);
|
|
318
|
+
*
|
|
319
|
+
* // Estimate gas for swapping 1 ARCH to USDC
|
|
320
|
+
* const gasEstimate = await client.estimateSwapGasFees({
|
|
321
|
+
* assetIn: "aarch",
|
|
322
|
+
* amountIn: "1000000000000000000", // 1 ARCH
|
|
323
|
+
* assetOut: "ibc/43897B9739BD63E3A08A88191999C632E052724AB96BD4C74AE31375C991F48D", // USDC
|
|
324
|
+
* minimumAmountOut: "1950000000" // Min 1950 USDC
|
|
325
|
+
* }, signer, 1.3); // 30% safety margin
|
|
326
|
+
*
|
|
327
|
+
* if (gasEstimate) {
|
|
328
|
+
* console.log(`Estimated gas: ${gasEstimate.amount} ${gasEstimate.denom}`);
|
|
329
|
+
* }
|
|
330
|
+
* ```
|
|
331
|
+
*
|
|
332
|
+
* @remarks
|
|
333
|
+
* - For CosmWasm chains, gas is always paid in the native token (e.g., "aarch" for Archway)
|
|
334
|
+
* - The returned amount is in the smallest denomination (6 decimals for most Cosmos chains)
|
|
335
|
+
* - Gas estimation uses CosmWasm's simulation capabilities
|
|
336
|
+
* - The gasAdjustment parameter helps account for variations in actual execution
|
|
337
|
+
*/
|
|
338
|
+
estimateSwapGasFees(params: SwapParams, signer: OfflineSigner, gasAdjustment?: number): Promise<Coin | undefined>;
|
|
295
339
|
}
|
|
296
340
|
|
|
297
|
-
export { BoltCosmWasmClient, type CosmWasmChain, type CosmWasmChainConfig, type CosmWasmClientConfig, type CosmWasmRouterConfig, type InvertiblePriceRepresentation, type MarketRepresentation, type PriceRepresentation, type QueryAssetPairsResponse, type QueryBaseLiquidityAllResponse, type QueryBaseLiquidityResponse, type QueryMarketsResponse, type QueryOracleConfigResponse, type QueryPriceResponse, type QueryPricesResponse, type QueryQuotesForUserAllResponse, type QueryRouterConfigResponse, type QuerySettlementConfigResponse };
|
|
341
|
+
export { type AssetPairString, BoltCosmWasmClient, type CosmWasmChain, type CosmWasmChainConfig, type CosmWasmClientConfig, type CosmWasmRouterConfig, type InvertiblePriceRepresentation, type MarketRepresentation, type PriceRepresentation, type QueryAssetPairsResponse, type QueryBaseLiquidityAllResponse, type QueryBaseLiquidityResponse, type QueryMarketsResponse, type QueryOracleConfigResponse, type QueryPriceResponse, type QueryPricesResponse, type QueryQuotesForUserAllResponse, type QueryRouterConfigResponse, type QuerySettlementConfigResponse, type SignerWithSigningClient };
|