@bolt-liquidity-hq/sui-client 0.1.0-beta.13 → 0.1.0-beta.14

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,6 +1,7 @@
1
1
  import { ChainConfig, ClientConfig, Pool, BaseClient, OracleConfig, OracleAssetPair, InvertiblePrice, Price, RouterConfig, Address, BaseLiquidityDetails, Coin, PoolConfig, Asset, SwapParams, SwapResult } from '@bolt-liquidity-hq/core';
2
2
  import { SuiClient, SuiTransactionBlockResponse } from '@mysten/sui/client';
3
3
  import { Signer } from '@mysten/sui/cryptography';
4
+ import { WalletContextState } from '@suiet/wallet-kit';
4
5
  import * as _mysten_bcs from '@mysten/bcs';
5
6
  import { BcsType } from '@mysten/bcs';
6
7
 
@@ -17,8 +18,10 @@ type BcsParsedMultiple<T extends readonly BcsType<any>[]> = {
17
18
 
18
19
  type SuiChainConfig = ChainConfig;
19
20
 
21
+ type WalletSigner = WalletContextState;
22
+
20
23
  type SuiClientConfig = ClientConfig<SuiChainConfig> & {
21
- signer?: Signer;
24
+ signer?: Signer | WalletSigner;
22
25
  suiClient?: SuiClient;
23
26
  customOverride?: ClientConfig<SuiChainConfig>['customOverride'] & {
24
27
  packageId?: string;
@@ -132,31 +135,9 @@ declare const PriceResponseStruct: _mysten_bcs.BcsStruct<{
132
135
  last_updated_ms: string | number | bigint;
133
136
  updater: string;
134
137
  } | null | undefined, `Option<${string}>`>;
138
+ is_inverted: _mysten_bcs.BcsType<boolean, boolean, "bool">;
135
139
  }, string>;
136
140
  type PriceResponseStructOutput = BcsParsed<typeof PriceResponseStruct>;
137
- declare const PricesResponsePaginatedStruct: _mysten_bcs.BcsStruct<{
138
- total_count: _mysten_bcs.BcsType<string, string | number | bigint, "u64">;
139
- has_next_page: _mysten_bcs.BcsType<boolean, boolean, "bool">;
140
- next_cursor: _mysten_bcs.BcsType<string | null, string | null | undefined, "Option<string>">;
141
- prices: _mysten_bcs.BcsType<{
142
- price: {
143
- price: string;
144
- expiry: string;
145
- };
146
- last_updated_ms: string;
147
- updater: string;
148
- }[], Iterable<{
149
- price: {
150
- price: string | number | bigint;
151
- expiry: string | number | bigint;
152
- };
153
- last_updated_ms: string | number | bigint;
154
- updater: string;
155
- }> & {
156
- length: number;
157
- }, string>;
158
- }, string>;
159
- type PricesResponsePaginatedStructOutput = BcsParsed<typeof PricesResponsePaginatedStruct>;
160
141
 
161
142
  declare const RouterConfigStruct: _mysten_bcs.BcsStruct<{
162
143
  admin: _mysten_bcs.BcsType<string, string, "address">;
@@ -329,7 +310,7 @@ declare class BoltSuiClient extends BaseClient<Signer, SuiTransactionBlockRespon
329
310
  /**
330
311
  * Cached instance of the Signer for transaction execution
331
312
  */
332
- signer?: Signer;
313
+ signer?: Signer | WalletSigner;
333
314
  /**
334
315
  * Instance of the Sui client to interact with the blockchain
335
316
  */
@@ -442,7 +423,7 @@ declare class BoltSuiClient extends BaseClient<Signer, SuiTransactionBlockRespon
442
423
  * const signer = client.getSigner(newSigner);
443
424
  * ```
444
425
  */
445
- getSigner(newSigner?: Signer): Signer;
426
+ getSigner(newSigner?: Signer | WalletSigner): Signer | WalletSigner;
446
427
  /** @inheritdoc */
447
428
  getOracleConfig(): Promise<OracleConfig>;
448
429
  /** @inheritdoc */
@@ -513,7 +494,7 @@ declare class BoltSuiClient extends BaseClient<Signer, SuiTransactionBlockRespon
513
494
  * This implementation returns a SuiTransactionBlockResponse as the transaction output,
514
495
  * which includes details like gas costs, transaction effects, object changes, and events.
515
496
  */
516
- swap(params: SwapParams, signer?: Signer): Promise<SwapResult<SuiTransactionBlockResponse>>;
497
+ swap(params: SwapParams, signer?: Signer | WalletSigner): Promise<SwapResult<SuiTransactionBlockResponse>>;
517
498
  /**
518
499
  * @inheritdoc
519
500
  *
@@ -542,7 +523,7 @@ declare class BoltSuiClient extends BaseClient<Signer, SuiTransactionBlockRespon
542
523
  * - The gasAdjustment parameter helps account for variations in actual execution
543
524
  * - Sui's gas model includes computation, storage, and storage rebates
544
525
  */
545
- estimateSwapGasFees(params: SwapParams, signer?: Signer, gasAdjustment?: number): Promise<Coin | undefined>;
526
+ estimateSwapGasFees(params: SwapParams, signer?: Signer | WalletSigner, gasAdjustment?: number): Promise<Coin | undefined>;
546
527
  /**
547
528
  * Loads configuration from a remote URL for testnet environments.
548
529
  *
@@ -566,4 +547,4 @@ declare class BoltSuiClient extends BaseClient<Signer, SuiTransactionBlockRespon
566
547
  private loadConfigFromUrl;
567
548
  }
568
549
 
569
- export { AssetPairResponseStruct, type AssetPairResponseStructOutput, AssetPairStruct, type AssetPairStructOutput, AssetPairsResponseStruct, type AssetPairsResponseStructOutput, BaseLiquidityInfoStruct, type BaseLiquidityInfoStructOutput, BaseLiquidityResponseStruct, type BaseLiquidityResponseStructOutput, BcsAddressType, type BcsParsed, type BcsParsedMultiple, BoltSuiClient, MarketResponseStruct, type MarketResponseStructOutput, MarketStruct, type MarketStructOutput, MarketsResponsePaginatedStruct, type MarketsResponsePaginatedStructOutput, MarketsResponseStruct, type MarketsResponseStructOutput, OracleConfigStruct, type OracleConfigStructOutput, PaginationStruct, PoolFeesInfoStruct, type PoolFeesInfoStructOutput, PoolInfoStruct, type PoolInfoStructOutput, PriceDataStruct, type PriceDataStructOutput, PriceResponseStruct, type PriceResponseStructOutput, PricesResponsePaginatedStruct, type PricesResponsePaginatedStructOutput, ProtocolFeesInfoStruct, type ProtocolFeesInfoStructOutput, RawPairStruct, type RawPairStructOutput, RawPriceStruct, type RawPriceStructOutput, RouterConfigStruct, type RouterConfigStructOutput, type SuiChainConfig, type SuiClientConfig, TypeNameStruct, type TypeNameStructOutput };
550
+ export { AssetPairResponseStruct, type AssetPairResponseStructOutput, AssetPairStruct, type AssetPairStructOutput, AssetPairsResponseStruct, type AssetPairsResponseStructOutput, BaseLiquidityInfoStruct, type BaseLiquidityInfoStructOutput, BaseLiquidityResponseStruct, type BaseLiquidityResponseStructOutput, BcsAddressType, type BcsParsed, type BcsParsedMultiple, BoltSuiClient, MarketResponseStruct, type MarketResponseStructOutput, MarketStruct, type MarketStructOutput, MarketsResponsePaginatedStruct, type MarketsResponsePaginatedStructOutput, MarketsResponseStruct, type MarketsResponseStructOutput, OracleConfigStruct, type OracleConfigStructOutput, PaginationStruct, PoolFeesInfoStruct, type PoolFeesInfoStructOutput, PoolInfoStruct, type PoolInfoStructOutput, PriceDataStruct, type PriceDataStructOutput, PriceResponseStruct, type PriceResponseStructOutput, ProtocolFeesInfoStruct, type ProtocolFeesInfoStructOutput, RawPairStruct, type RawPairStructOutput, RawPriceStruct, type RawPriceStructOutput, RouterConfigStruct, type RouterConfigStructOutput, type SuiChainConfig, type SuiClientConfig, TypeNameStruct, type TypeNameStructOutput, type WalletSigner };
package/dist/index.d.ts CHANGED
@@ -1,6 +1,7 @@
1
1
  import { ChainConfig, ClientConfig, Pool, BaseClient, OracleConfig, OracleAssetPair, InvertiblePrice, Price, RouterConfig, Address, BaseLiquidityDetails, Coin, PoolConfig, Asset, SwapParams, SwapResult } from '@bolt-liquidity-hq/core';
2
2
  import { SuiClient, SuiTransactionBlockResponse } from '@mysten/sui/client';
3
3
  import { Signer } from '@mysten/sui/cryptography';
4
+ import { WalletContextState } from '@suiet/wallet-kit';
4
5
  import * as _mysten_bcs from '@mysten/bcs';
5
6
  import { BcsType } from '@mysten/bcs';
6
7
 
@@ -17,8 +18,10 @@ type BcsParsedMultiple<T extends readonly BcsType<any>[]> = {
17
18
 
18
19
  type SuiChainConfig = ChainConfig;
19
20
 
21
+ type WalletSigner = WalletContextState;
22
+
20
23
  type SuiClientConfig = ClientConfig<SuiChainConfig> & {
21
- signer?: Signer;
24
+ signer?: Signer | WalletSigner;
22
25
  suiClient?: SuiClient;
23
26
  customOverride?: ClientConfig<SuiChainConfig>['customOverride'] & {
24
27
  packageId?: string;
@@ -132,31 +135,9 @@ declare const PriceResponseStruct: _mysten_bcs.BcsStruct<{
132
135
  last_updated_ms: string | number | bigint;
133
136
  updater: string;
134
137
  } | null | undefined, `Option<${string}>`>;
138
+ is_inverted: _mysten_bcs.BcsType<boolean, boolean, "bool">;
135
139
  }, string>;
136
140
  type PriceResponseStructOutput = BcsParsed<typeof PriceResponseStruct>;
137
- declare const PricesResponsePaginatedStruct: _mysten_bcs.BcsStruct<{
138
- total_count: _mysten_bcs.BcsType<string, string | number | bigint, "u64">;
139
- has_next_page: _mysten_bcs.BcsType<boolean, boolean, "bool">;
140
- next_cursor: _mysten_bcs.BcsType<string | null, string | null | undefined, "Option<string>">;
141
- prices: _mysten_bcs.BcsType<{
142
- price: {
143
- price: string;
144
- expiry: string;
145
- };
146
- last_updated_ms: string;
147
- updater: string;
148
- }[], Iterable<{
149
- price: {
150
- price: string | number | bigint;
151
- expiry: string | number | bigint;
152
- };
153
- last_updated_ms: string | number | bigint;
154
- updater: string;
155
- }> & {
156
- length: number;
157
- }, string>;
158
- }, string>;
159
- type PricesResponsePaginatedStructOutput = BcsParsed<typeof PricesResponsePaginatedStruct>;
160
141
 
161
142
  declare const RouterConfigStruct: _mysten_bcs.BcsStruct<{
162
143
  admin: _mysten_bcs.BcsType<string, string, "address">;
@@ -329,7 +310,7 @@ declare class BoltSuiClient extends BaseClient<Signer, SuiTransactionBlockRespon
329
310
  /**
330
311
  * Cached instance of the Signer for transaction execution
331
312
  */
332
- signer?: Signer;
313
+ signer?: Signer | WalletSigner;
333
314
  /**
334
315
  * Instance of the Sui client to interact with the blockchain
335
316
  */
@@ -442,7 +423,7 @@ declare class BoltSuiClient extends BaseClient<Signer, SuiTransactionBlockRespon
442
423
  * const signer = client.getSigner(newSigner);
443
424
  * ```
444
425
  */
445
- getSigner(newSigner?: Signer): Signer;
426
+ getSigner(newSigner?: Signer | WalletSigner): Signer | WalletSigner;
446
427
  /** @inheritdoc */
447
428
  getOracleConfig(): Promise<OracleConfig>;
448
429
  /** @inheritdoc */
@@ -513,7 +494,7 @@ declare class BoltSuiClient extends BaseClient<Signer, SuiTransactionBlockRespon
513
494
  * This implementation returns a SuiTransactionBlockResponse as the transaction output,
514
495
  * which includes details like gas costs, transaction effects, object changes, and events.
515
496
  */
516
- swap(params: SwapParams, signer?: Signer): Promise<SwapResult<SuiTransactionBlockResponse>>;
497
+ swap(params: SwapParams, signer?: Signer | WalletSigner): Promise<SwapResult<SuiTransactionBlockResponse>>;
517
498
  /**
518
499
  * @inheritdoc
519
500
  *
@@ -542,7 +523,7 @@ declare class BoltSuiClient extends BaseClient<Signer, SuiTransactionBlockRespon
542
523
  * - The gasAdjustment parameter helps account for variations in actual execution
543
524
  * - Sui's gas model includes computation, storage, and storage rebates
544
525
  */
545
- estimateSwapGasFees(params: SwapParams, signer?: Signer, gasAdjustment?: number): Promise<Coin | undefined>;
526
+ estimateSwapGasFees(params: SwapParams, signer?: Signer | WalletSigner, gasAdjustment?: number): Promise<Coin | undefined>;
546
527
  /**
547
528
  * Loads configuration from a remote URL for testnet environments.
548
529
  *
@@ -566,4 +547,4 @@ declare class BoltSuiClient extends BaseClient<Signer, SuiTransactionBlockRespon
566
547
  private loadConfigFromUrl;
567
548
  }
568
549
 
569
- export { AssetPairResponseStruct, type AssetPairResponseStructOutput, AssetPairStruct, type AssetPairStructOutput, AssetPairsResponseStruct, type AssetPairsResponseStructOutput, BaseLiquidityInfoStruct, type BaseLiquidityInfoStructOutput, BaseLiquidityResponseStruct, type BaseLiquidityResponseStructOutput, BcsAddressType, type BcsParsed, type BcsParsedMultiple, BoltSuiClient, MarketResponseStruct, type MarketResponseStructOutput, MarketStruct, type MarketStructOutput, MarketsResponsePaginatedStruct, type MarketsResponsePaginatedStructOutput, MarketsResponseStruct, type MarketsResponseStructOutput, OracleConfigStruct, type OracleConfigStructOutput, PaginationStruct, PoolFeesInfoStruct, type PoolFeesInfoStructOutput, PoolInfoStruct, type PoolInfoStructOutput, PriceDataStruct, type PriceDataStructOutput, PriceResponseStruct, type PriceResponseStructOutput, PricesResponsePaginatedStruct, type PricesResponsePaginatedStructOutput, ProtocolFeesInfoStruct, type ProtocolFeesInfoStructOutput, RawPairStruct, type RawPairStructOutput, RawPriceStruct, type RawPriceStructOutput, RouterConfigStruct, type RouterConfigStructOutput, type SuiChainConfig, type SuiClientConfig, TypeNameStruct, type TypeNameStructOutput };
550
+ export { AssetPairResponseStruct, type AssetPairResponseStructOutput, AssetPairStruct, type AssetPairStructOutput, AssetPairsResponseStruct, type AssetPairsResponseStructOutput, BaseLiquidityInfoStruct, type BaseLiquidityInfoStructOutput, BaseLiquidityResponseStruct, type BaseLiquidityResponseStructOutput, BcsAddressType, type BcsParsed, type BcsParsedMultiple, BoltSuiClient, MarketResponseStruct, type MarketResponseStructOutput, MarketStruct, type MarketStructOutput, MarketsResponsePaginatedStruct, type MarketsResponsePaginatedStructOutput, MarketsResponseStruct, type MarketsResponseStructOutput, OracleConfigStruct, type OracleConfigStructOutput, PaginationStruct, PoolFeesInfoStruct, type PoolFeesInfoStructOutput, PoolInfoStruct, type PoolInfoStructOutput, PriceDataStruct, type PriceDataStructOutput, PriceResponseStruct, type PriceResponseStructOutput, ProtocolFeesInfoStruct, type ProtocolFeesInfoStructOutput, RawPairStruct, type RawPairStructOutput, RawPriceStruct, type RawPriceStructOutput, RouterConfigStruct, type RouterConfigStructOutput, type SuiChainConfig, type SuiClientConfig, TypeNameStruct, type TypeNameStructOutput, type WalletSigner };
package/dist/index.js CHANGED
@@ -5,11 +5,15 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
5
5
  // src/lib/client.ts
6
6
  import { BaseClient, MissingParameterError as MissingParameterError2 } from "@bolt-liquidity-hq/core";
7
7
  import { SuiClient } from "@mysten/sui/client";
8
- import { normalizeStructTag as normalizeStructTag5 } from "@mysten/sui/utils";
8
+ import { normalizeStructTag as normalizeStructTag7 } from "@mysten/sui/utils";
9
9
  import axios from "axios";
10
10
 
11
+ // src/config/common.ts
12
+ import { normalizeStructTag, SUI_TYPE_ARG } from "@mysten/sui/utils";
13
+ var SUI_TOKEN_DENOM = normalizeStructTag(SUI_TYPE_ARG);
14
+
11
15
  // src/config/mainnet.ts
12
- import { SUI_DECIMALS, SUI_TYPE_ARG } from "@mysten/sui/utils";
16
+ import { SUI_DECIMALS } from "@mysten/sui/utils";
13
17
  var MainnetChainConfig = {
14
18
  name: "Sui",
15
19
  id: "101",
@@ -21,13 +25,13 @@ var MainnetContracts = {
21
25
  };
22
26
  var MainnetPackageId = "0x...";
23
27
  var MainnetPoolGlobalConfigId = "0x...";
24
- var MainnetNativeTokenDenom = SUI_TYPE_ARG;
28
+ var MainnetNativeTokenDenom = SUI_TOKEN_DENOM;
25
29
  var MainnetAssets = {
26
- [SUI_TYPE_ARG]: {
30
+ [SUI_TOKEN_DENOM]: {
27
31
  symbol: "SUI",
28
32
  name: "Sui",
29
33
  chainId: "101",
30
- denom: SUI_TYPE_ARG,
34
+ denom: SUI_TOKEN_DENOM,
31
35
  decimals: SUI_DECIMALS,
32
36
  logo: "https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/sui/info/logo.png",
33
37
  coingeckoId: "sui"
@@ -45,7 +49,7 @@ var MainnetAssets = {
45
49
  var MainnetPools = [];
46
50
 
47
51
  // src/config/testnet.ts
48
- import { SUI_DECIMALS as SUI_DECIMALS2, SUI_TYPE_ARG as SUI_TYPE_ARG2 } from "@mysten/sui/utils";
52
+ import { SUI_DECIMALS as SUI_DECIMALS2 } from "@mysten/sui/utils";
49
53
  var TestnetConfigUrl = "https://phi-labs-ltd.github.io/sui-outpost/testnet.json";
50
54
  var TestnetChainConfig = {
51
55
  name: "Sui Testnet",
@@ -58,14 +62,14 @@ var TestnetContracts = {
58
62
  };
59
63
  var TestnetPackageId = "";
60
64
  var TestnetPoolGlobalConfigId = "";
61
- var TestnetNativeTokenDenom = SUI_TYPE_ARG2;
65
+ var TestnetNativeTokenDenom = SUI_TOKEN_DENOM;
62
66
  var TestnetHelperAssets = ["::test_btc::TEST_BTC", "::test_usdt::TEST_USDT"];
63
67
  var TestnetAssets = {
64
- [SUI_TYPE_ARG2]: {
68
+ [SUI_TOKEN_DENOM]: {
65
69
  symbol: "SUI",
66
70
  name: "Sui",
67
71
  chainId: "103",
68
- denom: SUI_TYPE_ARG2,
72
+ denom: SUI_TOKEN_DENOM,
69
73
  decimals: SUI_DECIMALS2,
70
74
  logo: "https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/sui/info/logo.png",
71
75
  coingeckoId: "sui"
@@ -85,7 +89,7 @@ var TestnetAssets = {
85
89
  chainId: "103",
86
90
  denom: "::test_btc::TEST_BTC",
87
91
  decimals: 8,
88
- logo: "https://github.com/cosmos/chain-registry/blob/master/_non-cosmos/bitcoin/images/btc.png",
92
+ logo: "https://raw.githubusercontent.com/cosmos/chain-registry/refs/heads/master/_non-cosmos/bitcoin/images/btc.svg",
89
93
  coingeckoId: "bitcoin"
90
94
  },
91
95
  "::test_usdt::TEST_USDT": {
@@ -94,7 +98,7 @@ var TestnetAssets = {
94
98
  chainId: "103",
95
99
  denom: "::test_usdt::TEST_USDT",
96
100
  decimals: 6,
97
- logo: "https://github.com/cosmos/chain-registry/blob/master/_non-cosmos/ethereum/images/usdt.png",
101
+ logo: "https://raw.githubusercontent.com/cosmos/chain-registry/refs/heads/master/_non-cosmos/ethereum/images/usdt.svg",
98
102
  coingeckoId: "tether"
99
103
  }
100
104
  };
@@ -140,7 +144,7 @@ var parseDevInspectResult = (result, bcsType, resultIndex = 0, returnValueIndex
140
144
 
141
145
  // src/lib/helpers/coin-manager.ts
142
146
  import { InsufficientFundsError, MissingParameterError } from "@bolt-liquidity-hq/core";
143
- import { SUI_TYPE_ARG as SUI_TYPE_ARG3 } from "@mysten/sui/utils";
147
+ import { normalizeStructTag as normalizeStructTag2 } from "@mysten/sui/utils";
144
148
  var CoinManager = class {
145
149
  /**
146
150
  * Creates a new CoinManager instance.
@@ -507,7 +511,7 @@ var CoinManager = class {
507
511
  */
508
512
  async prepareCoinInput(tx, coinType, amount, options = {}, owner) {
509
513
  const ownerAddress = this.getOwnerAddress(owner);
510
- if (coinType === SUI_TYPE_ARG3) {
514
+ if (normalizeStructTag2(coinType) === SUI_TOKEN_DENOM) {
511
515
  const [coin] = tx.splitCoins(tx.gas, [amount]);
512
516
  return coin;
513
517
  }
@@ -579,7 +583,7 @@ import {
579
583
  } from "@bolt-liquidity-hq/core";
580
584
  import { bcs as bcs2 } from "@mysten/bcs";
581
585
  import { Transaction as Transaction2 } from "@mysten/sui/transactions";
582
- import { normalizeStructTag, SUI_CLOCK_OBJECT_ID, SUI_TYPE_ARG as SUI_TYPE_ARG4 } from "@mysten/sui/utils";
586
+ import { normalizeStructTag as normalizeStructTag3, SUI_CLOCK_OBJECT_ID } from "@mysten/sui/utils";
583
587
  import { BigNumber } from "bignumber.js";
584
588
  var buildSwapTxArgs = async (client, swapParams, signer) => {
585
589
  const { assetIn, amountIn, assetOut, minimumAmountOut, receiver } = swapParams;
@@ -587,14 +591,16 @@ var buildSwapTxArgs = async (client, swapParams, signer) => {
587
591
  if (!pool) {
588
592
  throw new NotFoundError(`Pool for the pair ${assetIn}/${assetOut}`);
589
593
  }
590
- const isSell = normalizeStructTag(assetIn) === pool.baseDenom;
594
+ const isSell = normalizeStructTag3(assetIn) === pool.baseDenom;
591
595
  const FUNCTION_NAME = isSell ? "swap_sell" : "swap_buy";
592
596
  const finalSigner = client.getSigner(signer);
593
597
  const tx = new Transaction2();
594
- const coinManager = new CoinManager(client.suiClient, finalSigner.toSuiAddress());
598
+ const signerAddress = getSignerAddress(finalSigner);
599
+ const coinManager = new CoinManager(client.suiClient, signerAddress);
595
600
  const coinInput = await coinManager.prepareCoinInput(tx, assetIn, amountIn);
596
601
  return {
597
602
  signer: finalSigner,
603
+ signerAddress,
598
604
  target: [client.packageId, ROUTER_MODULE, FUNCTION_NAME],
599
605
  args: [
600
606
  pool.poolAddress,
@@ -602,7 +608,7 @@ var buildSwapTxArgs = async (client, swapParams, signer) => {
602
608
  SUI_CLOCK_OBJECT_ID,
603
609
  coinInput,
604
610
  bcs2.u64().serialize(amountIn),
605
- bcs2.option(bcs2.string()).serialize(minimumAmountOut),
611
+ bcs2.option(bcs2.u64()).serialize(minimumAmountOut),
606
612
  bcs2.option(bcs2.string()).serialize(receiver)
607
613
  ],
608
614
  typeArguments: [isSell ? assetIn : assetOut, isSell ? assetOut : assetIn],
@@ -621,15 +627,29 @@ var signAndExecuteTx = async (suiClient, signer, target, args, typeArguments, tr
621
627
  typeArguments
622
628
  });
623
629
  try {
624
- const result = await suiClient.signAndExecuteTransaction({
625
- signer,
626
- transaction: tx,
627
- options
628
- });
629
- if (result.effects?.status.status === "success") {
630
- return result;
630
+ if ("toSuiAddress" in signer) {
631
+ const result = await suiClient.signAndExecuteTransaction({
632
+ signer,
633
+ transaction: tx,
634
+ options
635
+ });
636
+ if (result.effects?.status.status === "success") {
637
+ return result;
638
+ } else {
639
+ throw new TransactionFailedError2(result.digest, result.effects?.status.error, { result });
640
+ }
631
641
  } else {
632
- throw new TransactionFailedError2(result.digest, result.effects?.status.error, { result });
642
+ const result = await signer.signAndExecuteTransaction({
643
+ transaction: tx
644
+ });
645
+ if (!result.digest) {
646
+ throw new TransactionFailedError2("not found");
647
+ }
648
+ const fullTx = await suiClient.waitForTransaction({
649
+ digest: result.digest,
650
+ options
651
+ });
652
+ return fullTx;
633
653
  }
634
654
  } catch (error) {
635
655
  throw UnexpectedError2.from(error, "Failed to execute transaction", {
@@ -672,13 +692,20 @@ var estimateTxGasPrice = async (suiClient, senderAddress, target, args, typeArgu
672
692
  const totalGasCost = BigNumber(gasUsed.computationCost).plus(gasUsed.storageCost).minus(gasUsed.storageRebate);
673
693
  const adjustedGasCost = totalGasCost.times(gasAdjustment);
674
694
  return {
675
- denom: SUI_TYPE_ARG4,
695
+ denom: SUI_TOKEN_DENOM,
676
696
  amount: adjustedGasCost.toFixed(0, BigNumber.ROUND_CEIL)
677
697
  };
678
698
  } catch {
679
699
  return;
680
700
  }
681
701
  };
702
+ var getSignerAddress = (signer) => {
703
+ const address = "address" in signer ? signer.address : signer.toSuiAddress?.();
704
+ if (!address) {
705
+ throw new NotFoundError("Signer account's address");
706
+ }
707
+ return address;
708
+ };
682
709
 
683
710
  // src/lib/oracle/parsers.ts
684
711
  import { InvalidObjectError as InvalidObjectError2 } from "@bolt-liquidity-hq/core";
@@ -713,20 +740,20 @@ var parseAssetPairStructOutput = (output) => {
713
740
  var parseAssetPairsResponseStructOutput = (output) => {
714
741
  return output.map((item) => parseAssetPairStructOutput(item.info));
715
742
  };
716
- var parsePriceDataStructOutput = (output, baseDenom, quoteDenom) => {
743
+ var parsePriceDataStructOutput = (output, baseDenom, quoteDenom, isInverted) => {
717
744
  return {
718
745
  baseDenom,
719
746
  quoteDenom,
720
747
  price: output.price.price,
721
748
  expiryTime: BigNumber2(output.price.expiry).times(1e6).toFixed(),
722
- isInverse: false
749
+ isInverse: isInverted ?? false
723
750
  };
724
751
  };
725
752
  var parsePriceResponseStructOutput = (output, baseDenom, quoteDenom) => {
726
753
  if (!output.pair_data) {
727
754
  throw new InvalidObjectError2("Can't find pair data price");
728
755
  }
729
- return parsePriceDataStructOutput(output.pair_data, baseDenom, quoteDenom);
756
+ return parsePriceDataStructOutput(output.pair_data, baseDenom, quoteDenom, output.is_inverted);
730
757
  };
731
758
 
732
759
  // src/types/bcs.ts
@@ -789,11 +816,8 @@ var PriceDataStruct = bcs4.struct("PriceData", {
789
816
  updater: BcsAddressType
790
817
  });
791
818
  var PriceResponseStruct = bcs4.struct("PriceResponse", {
792
- pair_data: bcs4.option(PriceDataStruct)
793
- });
794
- var PricesResponsePaginatedStruct = bcs4.struct("PricesResponsePaginated", {
795
- prices: bcs4.vector(PriceDataStruct),
796
- ...PaginationStruct
819
+ pair_data: bcs4.option(PriceDataStruct),
820
+ is_inverted: bcs4.bool()
797
821
  });
798
822
 
799
823
  // src/types/router.ts
@@ -863,13 +887,19 @@ var getAssetPairs = async (client) => {
863
887
  };
864
888
 
865
889
  // src/lib/oracle/get-assets.ts
866
- import { normalizeStructTag as normalizeStructTag2 } from "@mysten/sui/utils";
890
+ import { normalizeStructTag as normalizeStructTag4 } from "@mysten/sui/utils";
867
891
  var getAssets = async (client) => {
868
892
  const assetPairs = await client.getAllOracleAssetPairs();
869
893
  const uniqueOracleAssets = {};
870
894
  for (const item of assetPairs) {
871
- uniqueOracleAssets[item.base.symbol] = item.base;
872
- uniqueOracleAssets[item.quote.symbol] = item.quote;
895
+ uniqueOracleAssets[normalizeStructTag4(item.base.symbol)] = {
896
+ ...item.base,
897
+ symbol: normalizeStructTag4(item.base.symbol)
898
+ };
899
+ uniqueOracleAssets[normalizeStructTag4(item.quote.symbol)] = {
900
+ ...item.quote,
901
+ symbol: normalizeStructTag4(item.quote.symbol)
902
+ };
873
903
  }
874
904
  return Object.values(uniqueOracleAssets).map(
875
905
  (item) => client.assetsConfig[item.symbol] ?? // Fallback to minimal asset data from oracle
@@ -877,7 +907,7 @@ var getAssets = async (client) => {
877
907
  symbol: item.name,
878
908
  name: item.name,
879
909
  chainId: client.chainConfig.id,
880
- denom: normalizeStructTag2(item.symbol),
910
+ denom: normalizeStructTag4(item.symbol),
881
911
  decimals: item.precision,
882
912
  logo: void 0,
883
913
  coingeckoId: void 0
@@ -912,7 +942,7 @@ var getPrice = async (client, baseDenom, quoteDenom) => {
912
942
 
913
943
  // src/lib/oracle/get-prices.ts
914
944
  import { NotFoundError as NotFoundError2 } from "@bolt-liquidity-hq/core";
915
- import { normalizeStructTag as normalizeStructTag3 } from "@mysten/sui/utils";
945
+ import { normalizeStructTag as normalizeStructTag5 } from "@mysten/sui/utils";
916
946
  var getPrices = async (client) => {
917
947
  const oracleObject = await client.suiClient.getObject({
918
948
  id: client.contracts.oracle,
@@ -947,8 +977,8 @@ var getPrices = async (client) => {
947
977
  const pairKey = dynamicFields.data[index]?.name?.value;
948
978
  if (fields && pairKey) {
949
979
  prices.push({
950
- baseDenom: normalizeStructTag3(pairKey.base.name),
951
- quoteDenom: normalizeStructTag3(pairKey.quote.name),
980
+ baseDenom: normalizeStructTag5(pairKey.base.name),
981
+ quoteDenom: normalizeStructTag5(pairKey.quote.name),
952
982
  price: fields.price,
953
983
  expiryTime: fields.expiry
954
984
  });
@@ -967,7 +997,7 @@ var estimateSwapExactInGasFees = async (client, swapParams, signer, gasAdjustmen
967
997
  const swapArgs = await buildSwapTxArgs(client, swapParams, signer);
968
998
  return await estimateTxGasPrice(
969
999
  client.suiClient,
970
- swapArgs.signer.toSuiAddress(),
1000
+ swapArgs.signerAddress,
971
1001
  swapArgs.target,
972
1002
  swapArgs.args,
973
1003
  swapArgs.typeArguments,
@@ -993,9 +1023,9 @@ var getAllQuotesForUser = async (_client, _lpAddress) => {
993
1023
  // src/lib/router/get-pool-by-denom.ts
994
1024
  import { NotFoundError as NotFoundError3 } from "@bolt-liquidity-hq/core";
995
1025
  var getPoolByDenom = async (client, baseDenom, quoteDenom) => {
996
- const result = await client.routerClient.getPool(baseDenom, quoteDenom);
1026
+ const result = await client.routerClient.getPool(quoteDenom, baseDenom);
997
1027
  if (!result) {
998
- throw new NotFoundError3("Pool", `Didn't find a pool to swap ${baseDenom} for ${quoteDenom}`);
1028
+ throw new NotFoundError3("Pool", `Didn't find a pool to swap ${quoteDenom} for ${baseDenom}`);
999
1029
  }
1000
1030
  return result;
1001
1031
  };
@@ -1012,22 +1042,22 @@ var getRouterConfig = async (_client) => {
1012
1042
  };
1013
1043
 
1014
1044
  // src/lib/router/router-client/RouterClient.ts
1015
- import { normalizeStructTag as normalizeStructTag4 } from "@mysten/sui/utils";
1045
+ import { normalizeStructTag as normalizeStructTag6 } from "@mysten/sui/utils";
1016
1046
  var RouterClient = class {
1017
1047
  constructor(pools) {
1018
1048
  this.pools = pools;
1019
1049
  }
1020
1050
  getPool(denomIn, denomOut) {
1021
- const normalizedDenomIn = normalizeStructTag4(denomIn);
1022
- const normalizedDenomOut = normalizeStructTag4(denomOut);
1051
+ const normalizedDenomIn = normalizeStructTag6(denomIn);
1052
+ const normalizedDenomOut = normalizeStructTag6(denomOut);
1023
1053
  const directPairPool = this.pools.find(
1024
- (item) => item.baseDenom === normalizedDenomIn && item.quoteDenoms.includes(normalizedDenomOut)
1054
+ (item) => item.baseDenom === normalizedDenomOut && item.quoteDenoms.includes(normalizedDenomIn)
1025
1055
  );
1026
1056
  if (directPairPool) {
1027
1057
  return directPairPool;
1028
1058
  }
1029
1059
  const inversePairPool = this.pools.find(
1030
- (item) => item.baseDenom === normalizedDenomOut && item.quoteDenoms.includes(normalizedDenomIn)
1060
+ (item) => item.baseDenom === normalizedDenomIn && item.quoteDenoms.includes(normalizedDenomOut)
1031
1061
  );
1032
1062
  if (inversePairPool) {
1033
1063
  return inversePairPool;
@@ -1060,15 +1090,16 @@ var swapExactIn = async (client, swapParams, signer) => {
1060
1090
  };
1061
1091
 
1062
1092
  // src/lib/settlement/get-pool-info.ts
1063
- import { SUI_TYPE_ARG as SUI_TYPE_ARG5 } from "@mysten/sui/utils";
1093
+ import { NotFoundError as NotFoundError4 } from "@bolt-liquidity-hq/core";
1064
1094
 
1065
1095
  // src/lib/settlement/parsers.ts
1096
+ import { BigNumber as BigNumber3 } from "bignumber.js";
1066
1097
  var parseSettlementConfigStructOutput = (routerClient, poolFeesInfo, protocolFeesInfo, priceOracleContract) => {
1067
1098
  return {
1068
1099
  priceOracleContract,
1069
1100
  protocolFeeRecipient: protocolFeesInfo.bolt_fee_addr,
1070
- protocolFee: poolFeesInfo.swap_fee_pct,
1071
- lpFee: poolFeesInfo.lp_fee_pct,
1101
+ protocolFee: BigNumber3(poolFeesInfo.swap_fee_pct).div(100).toFixed(),
1102
+ lpFee: BigNumber3(poolFeesInfo.lp_fee_pct).div(100).toFixed(),
1072
1103
  allowanceMode: "allow",
1073
1104
  // Should come from pool config
1074
1105
  lps: routerClient.getPools().map((item) => item.poolAddress),
@@ -1081,22 +1112,24 @@ var parseSettlementConfigStructOutput = (routerClient, poolFeesInfo, protocolFee
1081
1112
  var getPoolInfo = async (client, contractAddress) => {
1082
1113
  const GET_POOL_FEES_INFO_FUNCTION = "get_pool_fees_info";
1083
1114
  const GET_PROTOCOL_FEES_INFO_FUNCTION = "get_protocol_fees_info";
1115
+ const pool = client.routerClient.pools.find((item) => item.poolAddress === contractAddress);
1116
+ if (!pool) {
1117
+ throw new NotFoundError4(`Pool with the address ${contractAddress}`);
1118
+ }
1084
1119
  const [poolFeesInfo, protocolFeesInfo] = await Promise.all([
1085
1120
  // Query pool fee information
1086
1121
  queryDevInspect(
1087
1122
  client.suiClient,
1088
1123
  [client.packageId, POOL_MODULE, GET_POOL_FEES_INFO_FUNCTION],
1089
1124
  [contractAddress],
1090
- // TODO: get the base token of the pool to pass it here instead of hardcoded SUI token
1091
- [SUI_TYPE_ARG5]
1125
+ [pool.baseDenom]
1092
1126
  ),
1093
1127
  // Query protocol fee information
1094
1128
  queryDevInspect(
1095
1129
  client.suiClient,
1096
1130
  [client.packageId, POOL_MODULE, GET_PROTOCOL_FEES_INFO_FUNCTION],
1097
1131
  [contractAddress],
1098
- // TODO: get the base token of the pool to pass it here instead of hardcoded SUI token
1099
- [SUI_TYPE_ARG5]
1132
+ [pool.baseDenom]
1100
1133
  )
1101
1134
  ]);
1102
1135
  const poolFeesInfoOutput = parseDevInspectResult(poolFeesInfo, PoolFeesInfoStruct);
@@ -1487,8 +1520,8 @@ var BoltSuiClient = class extends BaseClient {
1487
1520
  for (const item of pools) {
1488
1521
  this.routerClient.pools.push({
1489
1522
  poolAddress: item.pool_object_id,
1490
- baseDenom: normalizeStructTag5(item.base),
1491
- quoteDenoms: Object.values(assets).map((auxAsset) => normalizeStructTag5(auxAsset)).filter((auxAsset) => auxAsset !== normalizeStructTag5(item.base))
1523
+ baseDenom: normalizeStructTag7(item.base),
1524
+ quoteDenoms: Object.values(assets).map((auxAsset) => normalizeStructTag7(auxAsset)).filter((auxAsset) => auxAsset !== normalizeStructTag7(item.base))
1492
1525
  });
1493
1526
  }
1494
1527
  }
@@ -1513,7 +1546,6 @@ export {
1513
1546
  PoolInfoStruct,
1514
1547
  PriceDataStruct,
1515
1548
  PriceResponseStruct,
1516
- PricesResponsePaginatedStruct,
1517
1549
  ProtocolFeesInfoStruct,
1518
1550
  RawPairStruct,
1519
1551
  RawPriceStruct,