@bolt-liquidity-hq/cosmwasm-client 0.1.0-beta.14 → 0.1.0-beta.16

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.cts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { ArchwayClient, SigningArchwayClient } from '@archwayhq/arch3.js';
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';
2
+ import { ChainConfig, ClientConfig, Address, Duration, Timestamp, OracleAssetPair, Coin, AllowanceMode, RouterConfig, BaseClient, OracleConfig, InvertiblePrice, Price, BaseLiquidityDetails, Pool, PoolConfig, Asset, SwapParams, SwapResult, SwapRequiredParams, SimulateSwapResult } 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
 
@@ -82,6 +82,13 @@ type QueryBaseLiquidityAllResponse = {
82
82
  type QueryQuotesForUserAllResponse = {
83
83
  quotes: Record<Address, Coin[]>;
84
84
  };
85
+ type QuerySimulateSwapExactInResponse = {
86
+ from_pool: Address;
87
+ quote_in: Coin;
88
+ base_out: Coin;
89
+ protocol_fee: string;
90
+ lp_fee: string;
91
+ };
85
92
 
86
93
  /**
87
94
  * Client implementation for interacting with the Bolt Liquidity Outpost on CosmWasm-based blockchains.
@@ -350,6 +357,8 @@ declare class BoltCosmWasmClient extends BaseClient<OfflineSigner, ExecuteResult
350
357
  * - The gasAdjustment parameter helps account for variations in actual execution
351
358
  */
352
359
  estimateSwapGasFees(params: SwapParams, signer: OfflineSigner, gasAdjustment?: number): Promise<Coin | undefined>;
360
+ /** @inheritdoc */
361
+ simulateSwap(params: SwapRequiredParams): Promise<SimulateSwapResult>;
353
362
  }
354
363
 
355
- 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 };
364
+ 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 QuerySimulateSwapExactInResponse, 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, Timestamp, OracleAssetPair, Coin, AllowanceMode, RouterConfig, BaseClient, OracleConfig, InvertiblePrice, Price, BaseLiquidityDetails, Pool, PoolConfig, Asset, SwapParams, SwapResult } from '@bolt-liquidity-hq/core';
2
+ import { ChainConfig, ClientConfig, Address, Duration, Timestamp, OracleAssetPair, Coin, AllowanceMode, RouterConfig, BaseClient, OracleConfig, InvertiblePrice, Price, BaseLiquidityDetails, Pool, PoolConfig, Asset, SwapParams, SwapResult, SwapRequiredParams, SimulateSwapResult } 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
 
@@ -82,6 +82,13 @@ type QueryBaseLiquidityAllResponse = {
82
82
  type QueryQuotesForUserAllResponse = {
83
83
  quotes: Record<Address, Coin[]>;
84
84
  };
85
+ type QuerySimulateSwapExactInResponse = {
86
+ from_pool: Address;
87
+ quote_in: Coin;
88
+ base_out: Coin;
89
+ protocol_fee: string;
90
+ lp_fee: string;
91
+ };
85
92
 
86
93
  /**
87
94
  * Client implementation for interacting with the Bolt Liquidity Outpost on CosmWasm-based blockchains.
@@ -350,6 +357,8 @@ declare class BoltCosmWasmClient extends BaseClient<OfflineSigner, ExecuteResult
350
357
  * - The gasAdjustment parameter helps account for variations in actual execution
351
358
  */
352
359
  estimateSwapGasFees(params: SwapParams, signer: OfflineSigner, gasAdjustment?: number): Promise<Coin | undefined>;
360
+ /** @inheritdoc */
361
+ simulateSwap(params: SwapRequiredParams): Promise<SimulateSwapResult>;
353
362
  }
354
363
 
355
- 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 };
364
+ 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 QuerySimulateSwapExactInResponse, type SignerWithSigningClient };
package/dist/index.js CHANGED
@@ -5548,6 +5548,7 @@ var estimateSwapExactInGasFees = async (client, { assetIn, amountIn, assetOut, m
5548
5548
  };
5549
5549
 
5550
5550
  // src/lib/router/parsers.ts
5551
+ import { BigNumber as BigNumber2 } from "bignumber.js";
5551
5552
  var parseMarketRepresentation = (marketRepresentation) => {
5552
5553
  return {
5553
5554
  poolAddress: marketRepresentation.market_address,
@@ -5581,6 +5582,17 @@ var parseQueryBaseLiquidityAllResponse = (response) => {
5581
5582
  }
5582
5583
  return newMapping;
5583
5584
  };
5585
+ var parseQuerySimulateSwapExactInResponse = (response) => {
5586
+ const protocolFeeAmount = BigNumber2(response.protocol_fee).times(BigNumber2(response.base_out.amount).plus(response.lp_fee)).div(BigNumber2(response.quote_in.amount).minus(response.protocol_fee));
5587
+ return {
5588
+ poolAddress: response.from_pool,
5589
+ amountOut: response.base_out.amount,
5590
+ assetOut: response.base_out.denom,
5591
+ protocolFee: protocolFeeAmount.toFixed(),
5592
+ lpFee: response.lp_fee,
5593
+ totalFees: protocolFeeAmount.plus(response.lp_fee).toFixed()
5594
+ };
5595
+ };
5584
5596
 
5585
5597
  // src/lib/router/get-all-base-liquidity.ts
5586
5598
  var getAllBaseLiquidity = async (client) => {
@@ -5627,6 +5639,21 @@ var getRouterConfig = async (client) => {
5627
5639
  return parseQueryRouterConfigResponse(response);
5628
5640
  };
5629
5641
 
5642
+ // src/lib/router/simulate-swap-exact-in.ts
5643
+ var simulateSwapExactIn = async (client, { assetIn, amountIn, assetOut }) => {
5644
+ const cosmWasmClient = await client.getCosmWasmClient();
5645
+ const response = await cosmWasmClient.queryContractSmart(client.contracts.router, {
5646
+ simulate_swap_exact_in: {
5647
+ amount_in: {
5648
+ denom: assetIn,
5649
+ amount: amountIn
5650
+ },
5651
+ want_out: assetOut
5652
+ }
5653
+ });
5654
+ return parseQuerySimulateSwapExactInResponse(response);
5655
+ };
5656
+
5630
5657
  // src/lib/router/swap-exact-in.ts
5631
5658
  import {
5632
5659
  TransactionEventNotFoundError,
@@ -6060,6 +6087,10 @@ var BoltCosmWasmClient = class extends BaseClient {
6060
6087
  async estimateSwapGasFees(params, signer, gasAdjustment) {
6061
6088
  return await estimateSwapExactInGasFees(this, params, signer, gasAdjustment);
6062
6089
  }
6090
+ /** @inheritdoc */
6091
+ async simulateSwap(params) {
6092
+ return await simulateSwapExactIn(this, params);
6093
+ }
6063
6094
  };
6064
6095
  export {
6065
6096
  BoltCosmWasmClient