@bolt-liquidity-hq/cosmwasm-client 0.1.0-beta.10 → 0.1.0-beta.12
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 +6 -3
package/dist/index.cjs
CHANGED
|
@@ -28,7 +28,7 @@ module.exports = __toCommonJS(index_exports);
|
|
|
28
28
|
|
|
29
29
|
// src/lib/client.ts
|
|
30
30
|
var import_arch3 = require("@archwayhq/arch3.js");
|
|
31
|
-
var
|
|
31
|
+
var import_core4 = require("@bolt-liquidity-hq/core");
|
|
32
32
|
var import_cosmwasm_stargate = require("@cosmjs/cosmwasm-stargate");
|
|
33
33
|
|
|
34
34
|
// src/config/archway-mainnet.ts
|
|
@@ -42,6 +42,7 @@ var ArchwayMainnetContracts = {
|
|
|
42
42
|
oracle: "archway1cr5l0tvhqsdjfzun4jkwqfzv7fadu598hultcra4jrljgwl639wsksmd28",
|
|
43
43
|
router: "archway1vu2ctevyav3wlka9yn7hmcm0xnlltklnnceqaanpuh0eete80xgsymc3ln"
|
|
44
44
|
};
|
|
45
|
+
var ArchwayMainnetNativeTokenDenom = "aarch";
|
|
45
46
|
var ArchwayMainnetAssets = {
|
|
46
47
|
aarch: {
|
|
47
48
|
symbol: "ARCH",
|
|
@@ -5240,6 +5241,7 @@ var ArchwayTestnetContracts = {
|
|
|
5240
5241
|
oracle: "archway1ehpghtr0v95kfx648dck7pvs08d6ah97l99xkx87t2zx8tcyen0s9n90x4",
|
|
5241
5242
|
router: "archway1rtdlmwgedg2vnsdyp3l23yr8eh7gspndt0x5cv5n9vxnerm374cs8lxk25"
|
|
5242
5243
|
};
|
|
5244
|
+
var ArchwayTestnetNativeTokenDenom = "aconst";
|
|
5243
5245
|
var ArchwayTestnetAssets = {
|
|
5244
5246
|
aconst: {
|
|
5245
5247
|
symbol: "CONST",
|
|
@@ -5448,8 +5450,10 @@ var parseQueryOracleConfigResponse = (response) => {
|
|
|
5448
5450
|
};
|
|
5449
5451
|
};
|
|
5450
5452
|
var parsePriceRepresentation = (priceRepresentation) => {
|
|
5453
|
+
const [baseDenom, quoteDenom] = priceRepresentation.asset_pair.split(":");
|
|
5451
5454
|
return {
|
|
5452
|
-
|
|
5455
|
+
baseDenom: baseDenom ?? "",
|
|
5456
|
+
quoteDenom: quoteDenom ?? "",
|
|
5453
5457
|
price: priceRepresentation.price,
|
|
5454
5458
|
expiryTime: priceRepresentation.expiry_time
|
|
5455
5459
|
};
|
|
@@ -5494,6 +5498,76 @@ var getPrices = async (client) => {
|
|
|
5494
5498
|
return parseQueryPricesResponse(response);
|
|
5495
5499
|
};
|
|
5496
5500
|
|
|
5501
|
+
// src/lib/router/estimate-swap-exact-in-gas-fees.ts
|
|
5502
|
+
var import_core2 = require("@bolt-liquidity-hq/core");
|
|
5503
|
+
var import_encoding = require("@cosmjs/encoding");
|
|
5504
|
+
var import_bignumber = require("bignumber.js");
|
|
5505
|
+
var import_tx = require("cosmjs-types/cosmwasm/wasm/v1/tx");
|
|
5506
|
+
|
|
5507
|
+
// src/lib/helpers/transactions.ts
|
|
5508
|
+
var import_core = require("@bolt-liquidity-hq/core");
|
|
5509
|
+
var getSignerAddress = async (signer) => {
|
|
5510
|
+
const accounts = await signer.getAccounts();
|
|
5511
|
+
if (!accounts?.[0]) {
|
|
5512
|
+
throw new import_core.NotFoundError("Signer account's address");
|
|
5513
|
+
}
|
|
5514
|
+
return accounts[0].address;
|
|
5515
|
+
};
|
|
5516
|
+
|
|
5517
|
+
// src/lib/router/estimate-swap-exact-in-gas-fees.ts
|
|
5518
|
+
var estimateSwapExactInGasFees = async (client, { assetIn, amountIn, assetOut, minimumAmountOut, receiver }, signer, gasAdjustment = import_core2.DEFAULT_GAS_ADJUSTMENT) => {
|
|
5519
|
+
const { signer: finalSigner, signingCosmWasmClient } = await client.getSignerWithSigningClient(signer);
|
|
5520
|
+
const address = await getSignerAddress(finalSigner);
|
|
5521
|
+
const message = [
|
|
5522
|
+
{
|
|
5523
|
+
typeUrl: "/cosmwasm.wasm.v1.MsgExecuteContract",
|
|
5524
|
+
value: import_tx.MsgExecuteContract.fromPartial({
|
|
5525
|
+
contract: client.contracts.router,
|
|
5526
|
+
funds: [
|
|
5527
|
+
{
|
|
5528
|
+
amount: amountIn,
|
|
5529
|
+
denom: assetIn
|
|
5530
|
+
}
|
|
5531
|
+
],
|
|
5532
|
+
msg: (0, import_encoding.toUtf8)(
|
|
5533
|
+
JSON.stringify({
|
|
5534
|
+
swap_exact_in: {
|
|
5535
|
+
want_out: assetOut,
|
|
5536
|
+
minimum_base_out: minimumAmountOut,
|
|
5537
|
+
receiver
|
|
5538
|
+
}
|
|
5539
|
+
})
|
|
5540
|
+
),
|
|
5541
|
+
sender: address
|
|
5542
|
+
})
|
|
5543
|
+
}
|
|
5544
|
+
];
|
|
5545
|
+
const SIMULATION_MEMO = "Swap simulation from Bolt SDK";
|
|
5546
|
+
if ("calculateFee" in signingCosmWasmClient) {
|
|
5547
|
+
try {
|
|
5548
|
+
const result = await signingCosmWasmClient.calculateFee(
|
|
5549
|
+
address,
|
|
5550
|
+
message,
|
|
5551
|
+
SIMULATION_MEMO,
|
|
5552
|
+
gasAdjustment
|
|
5553
|
+
);
|
|
5554
|
+
return result.amount[0];
|
|
5555
|
+
} catch {
|
|
5556
|
+
return;
|
|
5557
|
+
}
|
|
5558
|
+
} else {
|
|
5559
|
+
try {
|
|
5560
|
+
const result = await signingCosmWasmClient.simulate(address, message, SIMULATION_MEMO);
|
|
5561
|
+
return {
|
|
5562
|
+
amount: (0, import_bignumber.BigNumber)(result).times(gasAdjustment).toFixed(0),
|
|
5563
|
+
denom: client.nativeTokenDenom
|
|
5564
|
+
};
|
|
5565
|
+
} catch {
|
|
5566
|
+
return;
|
|
5567
|
+
}
|
|
5568
|
+
}
|
|
5569
|
+
};
|
|
5570
|
+
|
|
5497
5571
|
// src/lib/router/parsers.ts
|
|
5498
5572
|
var parseMarketRepresentation = (marketRepresentation) => {
|
|
5499
5573
|
return {
|
|
@@ -5575,27 +5649,17 @@ var getRouterConfig = async (client) => {
|
|
|
5575
5649
|
};
|
|
5576
5650
|
|
|
5577
5651
|
// src/lib/router/swap-exact-in.ts
|
|
5578
|
-
var
|
|
5652
|
+
var import_core3 = require("@bolt-liquidity-hq/core");
|
|
5579
5653
|
|
|
5580
5654
|
// src/lib/constants/events.ts
|
|
5581
5655
|
var BOLT_SWAP_EVENT_TYPE = "wasm-bolt_swap";
|
|
5582
5656
|
var BOLT_COIN_RECEIVED_EVENT_TYPE = "coin_received";
|
|
5583
5657
|
var BOLT_COIN_RECEIVED_EVENT_AMOUNT_KEY = "amount";
|
|
5584
5658
|
|
|
5585
|
-
// src/lib/helpers/transactions.ts
|
|
5586
|
-
var import_core = require("@bolt-liquidity-hq/core");
|
|
5587
|
-
var getSignerAddress = async (signer) => {
|
|
5588
|
-
const accounts = await signer.getAccounts();
|
|
5589
|
-
if (!accounts?.[0]) {
|
|
5590
|
-
throw new import_core.NotFoundError("Signer account's address");
|
|
5591
|
-
}
|
|
5592
|
-
return accounts[0].address;
|
|
5593
|
-
};
|
|
5594
|
-
|
|
5595
5659
|
// src/lib/router/swap-exact-in.ts
|
|
5596
|
-
var swapExactIn = async (client,
|
|
5597
|
-
const signingCosmWasmClient = await client.
|
|
5598
|
-
const address = await getSignerAddress(
|
|
5660
|
+
var swapExactIn = async (client, { assetIn, amountIn, assetOut, minimumAmountOut, receiver }, signer) => {
|
|
5661
|
+
const { signer: finalSigner, signingCosmWasmClient } = await client.getSignerWithSigningClient(signer);
|
|
5662
|
+
const address = await getSignerAddress(finalSigner);
|
|
5599
5663
|
const txOutput = await signingCosmWasmClient.execute(
|
|
5600
5664
|
address,
|
|
5601
5665
|
client.contracts.router,
|
|
@@ -5614,7 +5678,7 @@ var swapExactIn = async (client, signer, { assetIn, amountIn, assetOut, minimumA
|
|
|
5614
5678
|
(item) => item.type === BOLT_SWAP_EVENT_TYPE
|
|
5615
5679
|
);
|
|
5616
5680
|
if (boltSwapEventIndex === -1) {
|
|
5617
|
-
throw new
|
|
5681
|
+
throw new import_core3.TransactionEventNotFoundError(
|
|
5618
5682
|
BOLT_SWAP_EVENT_TYPE,
|
|
5619
5683
|
"After the transaction was executed, no successful swap event was emitted, the transaction may have failed"
|
|
5620
5684
|
);
|
|
@@ -5627,14 +5691,14 @@ var swapExactIn = async (client, signer, { assetIn, amountIn, assetOut, minimumA
|
|
|
5627
5691
|
)?.value;
|
|
5628
5692
|
if (amountWithDenomOut) {
|
|
5629
5693
|
try {
|
|
5630
|
-
amountOut = (0,
|
|
5694
|
+
amountOut = (0, import_core3.getCoinFromAmountWithDenomString)(amountWithDenomOut).amount;
|
|
5631
5695
|
break;
|
|
5632
5696
|
} catch {
|
|
5633
5697
|
}
|
|
5634
5698
|
}
|
|
5635
5699
|
}
|
|
5636
5700
|
if (!amountOut) {
|
|
5637
|
-
throw new
|
|
5701
|
+
throw new import_core3.TransactionEventNotFoundError(
|
|
5638
5702
|
BOLT_COIN_RECEIVED_EVENT_TYPE,
|
|
5639
5703
|
"After the transaction was executed, no coin received event was emitted, the transaction may have failed"
|
|
5640
5704
|
);
|
|
@@ -5676,17 +5740,18 @@ var getSettlementConfigForBase = async (client, baseDenom) => {
|
|
|
5676
5740
|
};
|
|
5677
5741
|
|
|
5678
5742
|
// src/lib/client.ts
|
|
5679
|
-
var BoltCosmWasmClient = class extends
|
|
5743
|
+
var BoltCosmWasmClient = class extends import_core4.BaseClient {
|
|
5680
5744
|
/**
|
|
5681
5745
|
* Creates a new instance of the BoltCosmWasmClient.
|
|
5682
5746
|
*
|
|
5683
5747
|
* The client automatically configures itself based on the specified chain and environment,
|
|
5684
|
-
* loading the appropriate contract addresses, chain configuration,
|
|
5748
|
+
* loading the appropriate contract addresses, chain configuration, native token denomination,
|
|
5749
|
+
* and assets from configuration files.
|
|
5685
5750
|
*
|
|
5686
5751
|
* @param config - (Optional) Configuration for the client
|
|
5687
5752
|
* @param config.environment - (Optional) The deployment environment ('mainnet' or 'testnet'). Defaults to 'mainnet'
|
|
5688
5753
|
* @param config.chain - (Optional) The specific CosmWasm chain to connect to. Defaults to 'archway'
|
|
5689
|
-
* @param config.customOverride - (Optional) Custom overrides for chain configuration, contracts, and assets
|
|
5754
|
+
* @param config.customOverride - (Optional) Custom overrides for chain configuration, contracts, native token, and assets
|
|
5690
5755
|
* @param config.customOverride.chainConfig - (Optional) Override chain configuration
|
|
5691
5756
|
* @param config.customOverride.chainConfig.id - (Optional) Custom chain ID
|
|
5692
5757
|
* @param config.customOverride.chainConfig.name - (Optional) Custom chain name
|
|
@@ -5695,8 +5760,10 @@ var BoltCosmWasmClient = class extends import_core3.BaseClient {
|
|
|
5695
5760
|
* @param config.customOverride.contracts - (Optional) Override contract addresses
|
|
5696
5761
|
* @param config.customOverride.contracts.oracle - (Optional) Custom oracle contract address
|
|
5697
5762
|
* @param config.customOverride.contracts.router - (Optional) Custom router contract address
|
|
5763
|
+
* @param config.customOverride.nativeTokenDenom - (Optional) Custom native token denomination (e.g., "aarch")
|
|
5698
5764
|
* @param config.customOverride.assetsConfig - (Optional) Custom asset configurations indexed by denom
|
|
5699
5765
|
* @param config.cosmWasmClient - (Optional) Pre-existing CosmWasmClient to use for blockchain queries
|
|
5766
|
+
* @param config.signer - (Optional) Pre-existing OfflineSigner for transaction signing
|
|
5700
5767
|
* @param config.signingCosmWasmClient - (Optional) Pre-existing SigningCosmWasmClient to use for blockchain transactions
|
|
5701
5768
|
*
|
|
5702
5769
|
* @throws {InvalidTypeError} Thrown when an unsupported chain is specified
|
|
@@ -5724,6 +5791,7 @@ var BoltCosmWasmClient = class extends import_core3.BaseClient {
|
|
|
5724
5791
|
* oracle: 'archway1custom_oracle...',
|
|
5725
5792
|
* router: 'archway1custom_router...'
|
|
5726
5793
|
* },
|
|
5794
|
+
* nativeTokenDenom: 'aarch',
|
|
5727
5795
|
* assetsConfig: {
|
|
5728
5796
|
* 'aarch': {
|
|
5729
5797
|
* symbol: 'ARCH',
|
|
@@ -5741,6 +5809,7 @@ var BoltCosmWasmClient = class extends import_core3.BaseClient {
|
|
|
5741
5809
|
* // Use pre-existing CosmWasm clients
|
|
5742
5810
|
* const clientWithCustomClients = new BoltCosmWasmClient({
|
|
5743
5811
|
* cosmWasmClient: myCosmWasmClient,
|
|
5812
|
+
* signer: mySigner,
|
|
5744
5813
|
* signingCosmWasmClient: mySigningClient
|
|
5745
5814
|
* });
|
|
5746
5815
|
* ```
|
|
@@ -5751,19 +5820,22 @@ var BoltCosmWasmClient = class extends import_core3.BaseClient {
|
|
|
5751
5820
|
chain = "archway",
|
|
5752
5821
|
customOverride,
|
|
5753
5822
|
cosmWasmClient,
|
|
5823
|
+
signer,
|
|
5754
5824
|
signingCosmWasmClient
|
|
5755
5825
|
} = config ?? {};
|
|
5756
5826
|
let defaultChainConfig;
|
|
5757
5827
|
let defaultContracts;
|
|
5828
|
+
let defaultNativeTokenDenom;
|
|
5758
5829
|
let assetsConfig;
|
|
5759
5830
|
switch (chain) {
|
|
5760
5831
|
case "archway":
|
|
5761
5832
|
defaultChainConfig = environment === "mainnet" ? ArchwayMainnetChainConfig : ArchwayTestnetChainConfig;
|
|
5762
5833
|
defaultContracts = environment === "mainnet" ? ArchwayMainnetContracts : ArchwayTestnetContracts;
|
|
5834
|
+
defaultNativeTokenDenom = environment === "mainnet" ? ArchwayMainnetNativeTokenDenom : ArchwayTestnetNativeTokenDenom;
|
|
5763
5835
|
assetsConfig = environment === "mainnet" ? ArchwayMainnetAssets : ArchwayTestnetAssets;
|
|
5764
5836
|
break;
|
|
5765
5837
|
default:
|
|
5766
|
-
throw new
|
|
5838
|
+
throw new import_core4.InvalidTypeError("A valid value of CosmWasmChain", chain);
|
|
5767
5839
|
}
|
|
5768
5840
|
const chainConfig = {
|
|
5769
5841
|
id: customOverride?.chainConfig?.id ?? defaultChainConfig.id,
|
|
@@ -5775,6 +5847,7 @@ var BoltCosmWasmClient = class extends import_core3.BaseClient {
|
|
|
5775
5847
|
oracle: customOverride?.contracts?.oracle ?? defaultContracts.oracle,
|
|
5776
5848
|
router: customOverride?.contracts?.router ?? defaultContracts.router
|
|
5777
5849
|
};
|
|
5850
|
+
const nativeTokenDenom = customOverride?.nativeTokenDenom ?? defaultNativeTokenDenom;
|
|
5778
5851
|
for (const item of Object.values(customOverride?.assetsConfig ?? {})) {
|
|
5779
5852
|
assetsConfig[item.denom] = item;
|
|
5780
5853
|
}
|
|
@@ -5782,6 +5855,7 @@ var BoltCosmWasmClient = class extends import_core3.BaseClient {
|
|
|
5782
5855
|
customOverride: {
|
|
5783
5856
|
chainConfig,
|
|
5784
5857
|
contracts,
|
|
5858
|
+
nativeTokenDenom,
|
|
5785
5859
|
assetsConfig
|
|
5786
5860
|
}
|
|
5787
5861
|
});
|
|
@@ -5794,6 +5868,11 @@ var BoltCosmWasmClient = class extends import_core3.BaseClient {
|
|
|
5794
5868
|
* @private
|
|
5795
5869
|
*/
|
|
5796
5870
|
__publicField(this, "_cosmWasmClient");
|
|
5871
|
+
/**
|
|
5872
|
+
* Cached instance of the Signer for transaction execution
|
|
5873
|
+
* @private
|
|
5874
|
+
*/
|
|
5875
|
+
__publicField(this, "_signer");
|
|
5797
5876
|
/**
|
|
5798
5877
|
* Cached instance of the signing CosmWasm client for transaction execution
|
|
5799
5878
|
* @private
|
|
@@ -5806,6 +5885,7 @@ var BoltCosmWasmClient = class extends import_core3.BaseClient {
|
|
|
5806
5885
|
this.chainConfig = chainConfig;
|
|
5807
5886
|
this.chain = chain;
|
|
5808
5887
|
this._cosmWasmClient = cosmWasmClient;
|
|
5888
|
+
this._signer = signer;
|
|
5809
5889
|
this._signingCosmWasmClient = signingCosmWasmClient;
|
|
5810
5890
|
}
|
|
5811
5891
|
/**
|
|
@@ -5831,18 +5911,18 @@ var BoltCosmWasmClient = class extends import_core3.BaseClient {
|
|
|
5831
5911
|
return this._cosmWasmClient;
|
|
5832
5912
|
}
|
|
5833
5913
|
/**
|
|
5834
|
-
* Gets or creates a signing CosmWasm client instance for transaction execution.
|
|
5914
|
+
* Gets or creates a signing CosmWasm client instance along with the signer for transaction execution.
|
|
5835
5915
|
*
|
|
5836
|
-
* This method implements lazy initialization and caching of the signing client.
|
|
5916
|
+
* This method implements lazy initialization and caching of both the signing client and signer.
|
|
5837
5917
|
* A signer must be provided either on first call or to replace the cached instance.
|
|
5838
5918
|
* The appropriate client type is selected based on the configured chain.
|
|
5839
5919
|
*
|
|
5840
|
-
* @param
|
|
5841
|
-
*
|
|
5920
|
+
* @param newSigner - Optional offline signer for transaction signing. Required on first call
|
|
5921
|
+
* or to replace the existing signer
|
|
5842
5922
|
*
|
|
5843
|
-
* @returns A promise that resolves to the signing
|
|
5923
|
+
* @returns A promise that resolves to an object containing both the signer and signing client
|
|
5844
5924
|
*
|
|
5845
|
-
* @throws {MissingParameterError} Thrown when no signer is provided and no cached
|
|
5925
|
+
* @throws {MissingParameterError} Thrown when no signer is provided and no cached signer exists
|
|
5846
5926
|
*
|
|
5847
5927
|
* @example
|
|
5848
5928
|
* ```typescript
|
|
@@ -5850,20 +5930,27 @@ var BoltCosmWasmClient = class extends import_core3.BaseClient {
|
|
|
5850
5930
|
* const signer = await DirectSecp256k1HdWallet.fromMnemonic("my mnemonic goes here", {
|
|
5851
5931
|
* prefix: 'archway',
|
|
5852
5932
|
* });
|
|
5853
|
-
* const
|
|
5933
|
+
* const { signer: cachedSigner, signingCosmWasmClient } = await boltClient.getSignerWithSigningClient(signer);
|
|
5854
5934
|
*
|
|
5855
|
-
* // Subsequent calls can reuse the cached client
|
|
5856
|
-
* const
|
|
5935
|
+
* // Subsequent calls can reuse the cached signer and client
|
|
5936
|
+
* const { signer, signingCosmWasmClient: client } = await boltClient.getSignerWithSigningClient();
|
|
5857
5937
|
* ```
|
|
5858
5938
|
*/
|
|
5859
|
-
async
|
|
5860
|
-
if (!this._signingCosmWasmClient ||
|
|
5861
|
-
|
|
5862
|
-
|
|
5939
|
+
async getSignerWithSigningClient(newSigner) {
|
|
5940
|
+
if (!this._signingCosmWasmClient || !this._signer || newSigner) {
|
|
5941
|
+
this._signer = newSigner ?? this._signer;
|
|
5942
|
+
if (!this._signer) {
|
|
5943
|
+
throw new import_core4.MissingParameterError("signer");
|
|
5863
5944
|
}
|
|
5864
|
-
this._signingCosmWasmClient = await (this.chain === "archway" ? import_arch3.SigningArchwayClient : import_cosmwasm_stargate.SigningCosmWasmClient).connectWithSigner(this.chainConfig.rpcEndpoint,
|
|
5945
|
+
this._signingCosmWasmClient = await (this.chain === "archway" ? import_arch3.SigningArchwayClient : import_cosmwasm_stargate.SigningCosmWasmClient).connectWithSigner(this.chainConfig.rpcEndpoint, this._signer);
|
|
5946
|
+
}
|
|
5947
|
+
if (!this._signer) {
|
|
5948
|
+
throw new import_core4.MissingParameterError("signer");
|
|
5865
5949
|
}
|
|
5866
|
-
return
|
|
5950
|
+
return {
|
|
5951
|
+
signer: this._signer,
|
|
5952
|
+
signingCosmWasmClient: this._signingCosmWasmClient
|
|
5953
|
+
};
|
|
5867
5954
|
}
|
|
5868
5955
|
// The following methods inherit their documentation from BaseClient
|
|
5869
5956
|
// Only add documentation here if you need to override or add implementation-specific details
|
|
@@ -5924,13 +6011,13 @@ var BoltCosmWasmClient = class extends import_core3.BaseClient {
|
|
|
5924
6011
|
* const signer = await window.keplr.getOfflineSignerAuto(chainId);
|
|
5925
6012
|
*
|
|
5926
6013
|
* // Execute swap: 1 ARCH for USDC
|
|
5927
|
-
* const result = await client.swap(
|
|
6014
|
+
* const result = await client.swap({
|
|
5928
6015
|
* assetIn: "aarch",
|
|
5929
6016
|
* amountIn: "1000000000000000000", // 1 ARCH (18 decimals)
|
|
5930
6017
|
* assetOut: "ibc/43897B9739BD63E3A08A88191999C632E052724AB96BD4C74AE31375C991F48D", // USDC IBC denom
|
|
5931
6018
|
* minimumAmountOut: "1950000000", // Minimum 1950 USDC expected
|
|
5932
6019
|
* receiver: "archway1..." // Optional custom receiver
|
|
5933
|
-
* });
|
|
6020
|
+
* }, signer);
|
|
5934
6021
|
*
|
|
5935
6022
|
* console.log(`Swap successful!`);
|
|
5936
6023
|
* console.log(`Transaction hash: ${result.txHash}`);
|
|
@@ -5943,8 +6030,38 @@ var BoltCosmWasmClient = class extends import_core3.BaseClient {
|
|
|
5943
6030
|
* This implementation returns a CosmWasm ExecuteResult as the transaction output,
|
|
5944
6031
|
* which includes details like gas used, block height, transaction hash, and events.
|
|
5945
6032
|
*/
|
|
5946
|
-
async swap(
|
|
5947
|
-
return await swapExactIn(this,
|
|
6033
|
+
async swap(params, signer) {
|
|
6034
|
+
return await swapExactIn(this, params, signer);
|
|
6035
|
+
}
|
|
6036
|
+
/**
|
|
6037
|
+
* @inheritdoc
|
|
6038
|
+
*
|
|
6039
|
+
* @example
|
|
6040
|
+
* ```typescript
|
|
6041
|
+
* // Get signer (e.g., from Keplr wallet)
|
|
6042
|
+
* const signer = await window.keplr.getOfflineSignerAuto(chainId);
|
|
6043
|
+
*
|
|
6044
|
+
* // Estimate gas for swapping 1 ARCH to USDC
|
|
6045
|
+
* const gasEstimate = await client.estimateSwapGasFees({
|
|
6046
|
+
* assetIn: "aarch",
|
|
6047
|
+
* amountIn: "1000000000000000000", // 1 ARCH
|
|
6048
|
+
* assetOut: "ibc/43897B9739BD63E3A08A88191999C632E052724AB96BD4C74AE31375C991F48D", // USDC
|
|
6049
|
+
* minimumAmountOut: "1950000000" // Min 1950 USDC
|
|
6050
|
+
* }, signer, 1.3); // 30% safety margin
|
|
6051
|
+
*
|
|
6052
|
+
* if (gasEstimate) {
|
|
6053
|
+
* console.log(`Estimated gas: ${gasEstimate.amount} ${gasEstimate.denom}`);
|
|
6054
|
+
* }
|
|
6055
|
+
* ```
|
|
6056
|
+
*
|
|
6057
|
+
* @remarks
|
|
6058
|
+
* - For CosmWasm chains, gas is always paid in the native token (e.g., "aarch" for Archway)
|
|
6059
|
+
* - The returned amount is in the smallest denomination (6 decimals for most Cosmos chains)
|
|
6060
|
+
* - Gas estimation uses CosmWasm's simulation capabilities
|
|
6061
|
+
* - The gasAdjustment parameter helps account for variations in actual execution
|
|
6062
|
+
*/
|
|
6063
|
+
async estimateSwapGasFees(params, signer, gasAdjustment) {
|
|
6064
|
+
return await estimateSwapExactInGasFees(this, params, signer, gasAdjustment);
|
|
5948
6065
|
}
|
|
5949
6066
|
};
|
|
5950
6067
|
//# sourceMappingURL=index.cjs.map
|