@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.cjs +94 -62
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +10 -29
- package/dist/index.d.ts +10 -29
- package/dist/index.js +91 -59
- package/dist/index.js.map +1 -1
- package/package.json +5 -3
package/dist/index.cjs
CHANGED
|
@@ -49,7 +49,6 @@ __export(index_exports, {
|
|
|
49
49
|
PoolInfoStruct: () => PoolInfoStruct,
|
|
50
50
|
PriceDataStruct: () => PriceDataStruct,
|
|
51
51
|
PriceResponseStruct: () => PriceResponseStruct,
|
|
52
|
-
PricesResponsePaginatedStruct: () => PricesResponsePaginatedStruct,
|
|
53
52
|
ProtocolFeesInfoStruct: () => ProtocolFeesInfoStruct,
|
|
54
53
|
RawPairStruct: () => RawPairStruct,
|
|
55
54
|
RawPriceStruct: () => RawPriceStruct,
|
|
@@ -59,13 +58,17 @@ __export(index_exports, {
|
|
|
59
58
|
module.exports = __toCommonJS(index_exports);
|
|
60
59
|
|
|
61
60
|
// src/lib/client.ts
|
|
62
|
-
var
|
|
61
|
+
var import_core13 = require("@bolt-liquidity-hq/core");
|
|
63
62
|
var import_client = require("@mysten/sui/client");
|
|
64
63
|
var import_utils9 = require("@mysten/sui/utils");
|
|
65
64
|
var import_axios = __toESM(require("axios"), 1);
|
|
66
65
|
|
|
67
|
-
// src/config/
|
|
66
|
+
// src/config/common.ts
|
|
68
67
|
var import_utils = require("@mysten/sui/utils");
|
|
68
|
+
var SUI_TOKEN_DENOM = (0, import_utils.normalizeStructTag)(import_utils.SUI_TYPE_ARG);
|
|
69
|
+
|
|
70
|
+
// src/config/mainnet.ts
|
|
71
|
+
var import_utils2 = require("@mysten/sui/utils");
|
|
69
72
|
var MainnetChainConfig = {
|
|
70
73
|
name: "Sui",
|
|
71
74
|
id: "101",
|
|
@@ -77,14 +80,14 @@ var MainnetContracts = {
|
|
|
77
80
|
};
|
|
78
81
|
var MainnetPackageId = "0x...";
|
|
79
82
|
var MainnetPoolGlobalConfigId = "0x...";
|
|
80
|
-
var MainnetNativeTokenDenom =
|
|
83
|
+
var MainnetNativeTokenDenom = SUI_TOKEN_DENOM;
|
|
81
84
|
var MainnetAssets = {
|
|
82
|
-
[
|
|
85
|
+
[SUI_TOKEN_DENOM]: {
|
|
83
86
|
symbol: "SUI",
|
|
84
87
|
name: "Sui",
|
|
85
88
|
chainId: "101",
|
|
86
|
-
denom:
|
|
87
|
-
decimals:
|
|
89
|
+
denom: SUI_TOKEN_DENOM,
|
|
90
|
+
decimals: import_utils2.SUI_DECIMALS,
|
|
88
91
|
logo: "https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/sui/info/logo.png",
|
|
89
92
|
coingeckoId: "sui"
|
|
90
93
|
},
|
|
@@ -101,7 +104,7 @@ var MainnetAssets = {
|
|
|
101
104
|
var MainnetPools = [];
|
|
102
105
|
|
|
103
106
|
// src/config/testnet.ts
|
|
104
|
-
var
|
|
107
|
+
var import_utils3 = require("@mysten/sui/utils");
|
|
105
108
|
var TestnetConfigUrl = "https://phi-labs-ltd.github.io/sui-outpost/testnet.json";
|
|
106
109
|
var TestnetChainConfig = {
|
|
107
110
|
name: "Sui Testnet",
|
|
@@ -114,15 +117,15 @@ var TestnetContracts = {
|
|
|
114
117
|
};
|
|
115
118
|
var TestnetPackageId = "";
|
|
116
119
|
var TestnetPoolGlobalConfigId = "";
|
|
117
|
-
var TestnetNativeTokenDenom =
|
|
120
|
+
var TestnetNativeTokenDenom = SUI_TOKEN_DENOM;
|
|
118
121
|
var TestnetHelperAssets = ["::test_btc::TEST_BTC", "::test_usdt::TEST_USDT"];
|
|
119
122
|
var TestnetAssets = {
|
|
120
|
-
[
|
|
123
|
+
[SUI_TOKEN_DENOM]: {
|
|
121
124
|
symbol: "SUI",
|
|
122
125
|
name: "Sui",
|
|
123
126
|
chainId: "103",
|
|
124
|
-
denom:
|
|
125
|
-
decimals:
|
|
127
|
+
denom: SUI_TOKEN_DENOM,
|
|
128
|
+
decimals: import_utils3.SUI_DECIMALS,
|
|
126
129
|
logo: "https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/sui/info/logo.png",
|
|
127
130
|
coingeckoId: "sui"
|
|
128
131
|
},
|
|
@@ -141,7 +144,7 @@ var TestnetAssets = {
|
|
|
141
144
|
chainId: "103",
|
|
142
145
|
denom: "::test_btc::TEST_BTC",
|
|
143
146
|
decimals: 8,
|
|
144
|
-
logo: "https://
|
|
147
|
+
logo: "https://raw.githubusercontent.com/cosmos/chain-registry/refs/heads/master/_non-cosmos/bitcoin/images/btc.svg",
|
|
145
148
|
coingeckoId: "bitcoin"
|
|
146
149
|
},
|
|
147
150
|
"::test_usdt::TEST_USDT": {
|
|
@@ -150,7 +153,7 @@ var TestnetAssets = {
|
|
|
150
153
|
chainId: "103",
|
|
151
154
|
denom: "::test_usdt::TEST_USDT",
|
|
152
155
|
decimals: 6,
|
|
153
|
-
logo: "https://
|
|
156
|
+
logo: "https://raw.githubusercontent.com/cosmos/chain-registry/refs/heads/master/_non-cosmos/ethereum/images/usdt.svg",
|
|
154
157
|
coingeckoId: "tether"
|
|
155
158
|
}
|
|
156
159
|
};
|
|
@@ -196,7 +199,7 @@ var parseDevInspectResult = (result, bcsType, resultIndex = 0, returnValueIndex
|
|
|
196
199
|
|
|
197
200
|
// src/lib/helpers/coin-manager.ts
|
|
198
201
|
var import_core2 = require("@bolt-liquidity-hq/core");
|
|
199
|
-
var
|
|
202
|
+
var import_utils4 = require("@mysten/sui/utils");
|
|
200
203
|
var CoinManager = class {
|
|
201
204
|
/**
|
|
202
205
|
* Creates a new CoinManager instance.
|
|
@@ -563,7 +566,7 @@ var CoinManager = class {
|
|
|
563
566
|
*/
|
|
564
567
|
async prepareCoinInput(tx, coinType, amount, options = {}, owner) {
|
|
565
568
|
const ownerAddress = this.getOwnerAddress(owner);
|
|
566
|
-
if (coinType ===
|
|
569
|
+
if ((0, import_utils4.normalizeStructTag)(coinType) === SUI_TOKEN_DENOM) {
|
|
567
570
|
const [coin] = tx.splitCoins(tx.gas, [amount]);
|
|
568
571
|
return coin;
|
|
569
572
|
}
|
|
@@ -630,7 +633,7 @@ var queryDevInspect = async (suiClient, target, args, typeArguments, senderAddre
|
|
|
630
633
|
var import_core4 = require("@bolt-liquidity-hq/core");
|
|
631
634
|
var import_bcs2 = require("@mysten/bcs");
|
|
632
635
|
var import_transactions2 = require("@mysten/sui/transactions");
|
|
633
|
-
var
|
|
636
|
+
var import_utils5 = require("@mysten/sui/utils");
|
|
634
637
|
var import_bignumber = require("bignumber.js");
|
|
635
638
|
var buildSwapTxArgs = async (client, swapParams, signer) => {
|
|
636
639
|
const { assetIn, amountIn, assetOut, minimumAmountOut, receiver } = swapParams;
|
|
@@ -638,22 +641,24 @@ var buildSwapTxArgs = async (client, swapParams, signer) => {
|
|
|
638
641
|
if (!pool) {
|
|
639
642
|
throw new import_core4.NotFoundError(`Pool for the pair ${assetIn}/${assetOut}`);
|
|
640
643
|
}
|
|
641
|
-
const isSell = (0,
|
|
644
|
+
const isSell = (0, import_utils5.normalizeStructTag)(assetIn) === pool.baseDenom;
|
|
642
645
|
const FUNCTION_NAME = isSell ? "swap_sell" : "swap_buy";
|
|
643
646
|
const finalSigner = client.getSigner(signer);
|
|
644
647
|
const tx = new import_transactions2.Transaction();
|
|
645
|
-
const
|
|
648
|
+
const signerAddress = getSignerAddress(finalSigner);
|
|
649
|
+
const coinManager = new CoinManager(client.suiClient, signerAddress);
|
|
646
650
|
const coinInput = await coinManager.prepareCoinInput(tx, assetIn, amountIn);
|
|
647
651
|
return {
|
|
648
652
|
signer: finalSigner,
|
|
653
|
+
signerAddress,
|
|
649
654
|
target: [client.packageId, ROUTER_MODULE, FUNCTION_NAME],
|
|
650
655
|
args: [
|
|
651
656
|
pool.poolAddress,
|
|
652
657
|
client.contracts.oracle,
|
|
653
|
-
|
|
658
|
+
import_utils5.SUI_CLOCK_OBJECT_ID,
|
|
654
659
|
coinInput,
|
|
655
660
|
import_bcs2.bcs.u64().serialize(amountIn),
|
|
656
|
-
import_bcs2.bcs.option(import_bcs2.bcs.
|
|
661
|
+
import_bcs2.bcs.option(import_bcs2.bcs.u64()).serialize(minimumAmountOut),
|
|
657
662
|
import_bcs2.bcs.option(import_bcs2.bcs.string()).serialize(receiver)
|
|
658
663
|
],
|
|
659
664
|
typeArguments: [isSell ? assetIn : assetOut, isSell ? assetOut : assetIn],
|
|
@@ -672,15 +677,29 @@ var signAndExecuteTx = async (suiClient, signer, target, args, typeArguments, tr
|
|
|
672
677
|
typeArguments
|
|
673
678
|
});
|
|
674
679
|
try {
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
680
|
+
if ("toSuiAddress" in signer) {
|
|
681
|
+
const result = await suiClient.signAndExecuteTransaction({
|
|
682
|
+
signer,
|
|
683
|
+
transaction: tx,
|
|
684
|
+
options
|
|
685
|
+
});
|
|
686
|
+
if (result.effects?.status.status === "success") {
|
|
687
|
+
return result;
|
|
688
|
+
} else {
|
|
689
|
+
throw new import_core4.TransactionFailedError(result.digest, result.effects?.status.error, { result });
|
|
690
|
+
}
|
|
682
691
|
} else {
|
|
683
|
-
|
|
692
|
+
const result = await signer.signAndExecuteTransaction({
|
|
693
|
+
transaction: tx
|
|
694
|
+
});
|
|
695
|
+
if (!result.digest) {
|
|
696
|
+
throw new import_core4.TransactionFailedError("not found");
|
|
697
|
+
}
|
|
698
|
+
const fullTx = await suiClient.waitForTransaction({
|
|
699
|
+
digest: result.digest,
|
|
700
|
+
options
|
|
701
|
+
});
|
|
702
|
+
return fullTx;
|
|
684
703
|
}
|
|
685
704
|
} catch (error) {
|
|
686
705
|
throw import_core4.UnexpectedError.from(error, "Failed to execute transaction", {
|
|
@@ -723,13 +742,20 @@ var estimateTxGasPrice = async (suiClient, senderAddress, target, args, typeArgu
|
|
|
723
742
|
const totalGasCost = (0, import_bignumber.BigNumber)(gasUsed.computationCost).plus(gasUsed.storageCost).minus(gasUsed.storageRebate);
|
|
724
743
|
const adjustedGasCost = totalGasCost.times(gasAdjustment);
|
|
725
744
|
return {
|
|
726
|
-
denom:
|
|
745
|
+
denom: SUI_TOKEN_DENOM,
|
|
727
746
|
amount: adjustedGasCost.toFixed(0, import_bignumber.BigNumber.ROUND_CEIL)
|
|
728
747
|
};
|
|
729
748
|
} catch {
|
|
730
749
|
return;
|
|
731
750
|
}
|
|
732
751
|
};
|
|
752
|
+
var getSignerAddress = (signer) => {
|
|
753
|
+
const address = "address" in signer ? signer.address : signer.toSuiAddress?.();
|
|
754
|
+
if (!address) {
|
|
755
|
+
throw new import_core4.NotFoundError("Signer account's address");
|
|
756
|
+
}
|
|
757
|
+
return address;
|
|
758
|
+
};
|
|
733
759
|
|
|
734
760
|
// src/lib/oracle/parsers.ts
|
|
735
761
|
var import_core5 = require("@bolt-liquidity-hq/core");
|
|
@@ -764,20 +790,20 @@ var parseAssetPairStructOutput = (output) => {
|
|
|
764
790
|
var parseAssetPairsResponseStructOutput = (output) => {
|
|
765
791
|
return output.map((item) => parseAssetPairStructOutput(item.info));
|
|
766
792
|
};
|
|
767
|
-
var parsePriceDataStructOutput = (output, baseDenom, quoteDenom) => {
|
|
793
|
+
var parsePriceDataStructOutput = (output, baseDenom, quoteDenom, isInverted) => {
|
|
768
794
|
return {
|
|
769
795
|
baseDenom,
|
|
770
796
|
quoteDenom,
|
|
771
797
|
price: output.price.price,
|
|
772
798
|
expiryTime: (0, import_bignumber2.BigNumber)(output.price.expiry).times(1e6).toFixed(),
|
|
773
|
-
isInverse: false
|
|
799
|
+
isInverse: isInverted ?? false
|
|
774
800
|
};
|
|
775
801
|
};
|
|
776
802
|
var parsePriceResponseStructOutput = (output, baseDenom, quoteDenom) => {
|
|
777
803
|
if (!output.pair_data) {
|
|
778
804
|
throw new import_core5.InvalidObjectError("Can't find pair data price");
|
|
779
805
|
}
|
|
780
|
-
return parsePriceDataStructOutput(output.pair_data, baseDenom, quoteDenom);
|
|
806
|
+
return parsePriceDataStructOutput(output.pair_data, baseDenom, quoteDenom, output.is_inverted);
|
|
781
807
|
};
|
|
782
808
|
|
|
783
809
|
// src/types/bcs.ts
|
|
@@ -840,11 +866,8 @@ var PriceDataStruct = import_bcs4.bcs.struct("PriceData", {
|
|
|
840
866
|
updater: BcsAddressType
|
|
841
867
|
});
|
|
842
868
|
var PriceResponseStruct = import_bcs4.bcs.struct("PriceResponse", {
|
|
843
|
-
pair_data: import_bcs4.bcs.option(PriceDataStruct)
|
|
844
|
-
|
|
845
|
-
var PricesResponsePaginatedStruct = import_bcs4.bcs.struct("PricesResponsePaginated", {
|
|
846
|
-
prices: import_bcs4.bcs.vector(PriceDataStruct),
|
|
847
|
-
...PaginationStruct
|
|
869
|
+
pair_data: import_bcs4.bcs.option(PriceDataStruct),
|
|
870
|
+
is_inverted: import_bcs4.bcs.bool()
|
|
848
871
|
});
|
|
849
872
|
|
|
850
873
|
// src/types/router.ts
|
|
@@ -914,13 +937,19 @@ var getAssetPairs = async (client) => {
|
|
|
914
937
|
};
|
|
915
938
|
|
|
916
939
|
// src/lib/oracle/get-assets.ts
|
|
917
|
-
var
|
|
940
|
+
var import_utils6 = require("@mysten/sui/utils");
|
|
918
941
|
var getAssets = async (client) => {
|
|
919
942
|
const assetPairs = await client.getAllOracleAssetPairs();
|
|
920
943
|
const uniqueOracleAssets = {};
|
|
921
944
|
for (const item of assetPairs) {
|
|
922
|
-
uniqueOracleAssets[item.base.symbol] =
|
|
923
|
-
|
|
945
|
+
uniqueOracleAssets[(0, import_utils6.normalizeStructTag)(item.base.symbol)] = {
|
|
946
|
+
...item.base,
|
|
947
|
+
symbol: (0, import_utils6.normalizeStructTag)(item.base.symbol)
|
|
948
|
+
};
|
|
949
|
+
uniqueOracleAssets[(0, import_utils6.normalizeStructTag)(item.quote.symbol)] = {
|
|
950
|
+
...item.quote,
|
|
951
|
+
symbol: (0, import_utils6.normalizeStructTag)(item.quote.symbol)
|
|
952
|
+
};
|
|
924
953
|
}
|
|
925
954
|
return Object.values(uniqueOracleAssets).map(
|
|
926
955
|
(item) => client.assetsConfig[item.symbol] ?? // Fallback to minimal asset data from oracle
|
|
@@ -928,7 +957,7 @@ var getAssets = async (client) => {
|
|
|
928
957
|
symbol: item.name,
|
|
929
958
|
name: item.name,
|
|
930
959
|
chainId: client.chainConfig.id,
|
|
931
|
-
denom: (0,
|
|
960
|
+
denom: (0, import_utils6.normalizeStructTag)(item.symbol),
|
|
932
961
|
decimals: item.precision,
|
|
933
962
|
logo: void 0,
|
|
934
963
|
coingeckoId: void 0
|
|
@@ -963,7 +992,7 @@ var getPrice = async (client, baseDenom, quoteDenom) => {
|
|
|
963
992
|
|
|
964
993
|
// src/lib/oracle/get-prices.ts
|
|
965
994
|
var import_core6 = require("@bolt-liquidity-hq/core");
|
|
966
|
-
var
|
|
995
|
+
var import_utils7 = require("@mysten/sui/utils");
|
|
967
996
|
var getPrices = async (client) => {
|
|
968
997
|
const oracleObject = await client.suiClient.getObject({
|
|
969
998
|
id: client.contracts.oracle,
|
|
@@ -998,8 +1027,8 @@ var getPrices = async (client) => {
|
|
|
998
1027
|
const pairKey = dynamicFields.data[index]?.name?.value;
|
|
999
1028
|
if (fields && pairKey) {
|
|
1000
1029
|
prices.push({
|
|
1001
|
-
baseDenom: (0,
|
|
1002
|
-
quoteDenom: (0,
|
|
1030
|
+
baseDenom: (0, import_utils7.normalizeStructTag)(pairKey.base.name),
|
|
1031
|
+
quoteDenom: (0, import_utils7.normalizeStructTag)(pairKey.quote.name),
|
|
1003
1032
|
price: fields.price,
|
|
1004
1033
|
expiryTime: fields.expiry
|
|
1005
1034
|
});
|
|
@@ -1018,7 +1047,7 @@ var estimateSwapExactInGasFees = async (client, swapParams, signer, gasAdjustmen
|
|
|
1018
1047
|
const swapArgs = await buildSwapTxArgs(client, swapParams, signer);
|
|
1019
1048
|
return await estimateTxGasPrice(
|
|
1020
1049
|
client.suiClient,
|
|
1021
|
-
swapArgs.
|
|
1050
|
+
swapArgs.signerAddress,
|
|
1022
1051
|
swapArgs.target,
|
|
1023
1052
|
swapArgs.args,
|
|
1024
1053
|
swapArgs.typeArguments,
|
|
@@ -1042,9 +1071,9 @@ var getAllQuotesForUser = async (_client, _lpAddress) => {
|
|
|
1042
1071
|
// src/lib/router/get-pool-by-denom.ts
|
|
1043
1072
|
var import_core10 = require("@bolt-liquidity-hq/core");
|
|
1044
1073
|
var getPoolByDenom = async (client, baseDenom, quoteDenom) => {
|
|
1045
|
-
const result = await client.routerClient.getPool(
|
|
1074
|
+
const result = await client.routerClient.getPool(quoteDenom, baseDenom);
|
|
1046
1075
|
if (!result) {
|
|
1047
|
-
throw new import_core10.NotFoundError("Pool", `Didn't find a pool to swap ${
|
|
1076
|
+
throw new import_core10.NotFoundError("Pool", `Didn't find a pool to swap ${quoteDenom} for ${baseDenom}`);
|
|
1048
1077
|
}
|
|
1049
1078
|
return result;
|
|
1050
1079
|
};
|
|
@@ -1061,22 +1090,22 @@ var getRouterConfig = async (_client) => {
|
|
|
1061
1090
|
};
|
|
1062
1091
|
|
|
1063
1092
|
// src/lib/router/router-client/RouterClient.ts
|
|
1064
|
-
var
|
|
1093
|
+
var import_utils8 = require("@mysten/sui/utils");
|
|
1065
1094
|
var RouterClient = class {
|
|
1066
1095
|
constructor(pools) {
|
|
1067
1096
|
this.pools = pools;
|
|
1068
1097
|
}
|
|
1069
1098
|
getPool(denomIn, denomOut) {
|
|
1070
|
-
const normalizedDenomIn = (0,
|
|
1071
|
-
const normalizedDenomOut = (0,
|
|
1099
|
+
const normalizedDenomIn = (0, import_utils8.normalizeStructTag)(denomIn);
|
|
1100
|
+
const normalizedDenomOut = (0, import_utils8.normalizeStructTag)(denomOut);
|
|
1072
1101
|
const directPairPool = this.pools.find(
|
|
1073
|
-
(item) => item.baseDenom ===
|
|
1102
|
+
(item) => item.baseDenom === normalizedDenomOut && item.quoteDenoms.includes(normalizedDenomIn)
|
|
1074
1103
|
);
|
|
1075
1104
|
if (directPairPool) {
|
|
1076
1105
|
return directPairPool;
|
|
1077
1106
|
}
|
|
1078
1107
|
const inversePairPool = this.pools.find(
|
|
1079
|
-
(item) => item.baseDenom ===
|
|
1108
|
+
(item) => item.baseDenom === normalizedDenomIn && item.quoteDenoms.includes(normalizedDenomOut)
|
|
1080
1109
|
);
|
|
1081
1110
|
if (inversePairPool) {
|
|
1082
1111
|
return inversePairPool;
|
|
@@ -1109,15 +1138,16 @@ var swapExactIn = async (client, swapParams, signer) => {
|
|
|
1109
1138
|
};
|
|
1110
1139
|
|
|
1111
1140
|
// src/lib/settlement/get-pool-info.ts
|
|
1112
|
-
var
|
|
1141
|
+
var import_core12 = require("@bolt-liquidity-hq/core");
|
|
1113
1142
|
|
|
1114
1143
|
// src/lib/settlement/parsers.ts
|
|
1144
|
+
var import_bignumber3 = require("bignumber.js");
|
|
1115
1145
|
var parseSettlementConfigStructOutput = (routerClient, poolFeesInfo, protocolFeesInfo, priceOracleContract) => {
|
|
1116
1146
|
return {
|
|
1117
1147
|
priceOracleContract,
|
|
1118
1148
|
protocolFeeRecipient: protocolFeesInfo.bolt_fee_addr,
|
|
1119
|
-
protocolFee: poolFeesInfo.swap_fee_pct,
|
|
1120
|
-
lpFee: poolFeesInfo.lp_fee_pct,
|
|
1149
|
+
protocolFee: (0, import_bignumber3.BigNumber)(poolFeesInfo.swap_fee_pct).div(100).toFixed(),
|
|
1150
|
+
lpFee: (0, import_bignumber3.BigNumber)(poolFeesInfo.lp_fee_pct).div(100).toFixed(),
|
|
1121
1151
|
allowanceMode: "allow",
|
|
1122
1152
|
// Should come from pool config
|
|
1123
1153
|
lps: routerClient.getPools().map((item) => item.poolAddress),
|
|
@@ -1130,22 +1160,24 @@ var parseSettlementConfigStructOutput = (routerClient, poolFeesInfo, protocolFee
|
|
|
1130
1160
|
var getPoolInfo = async (client, contractAddress) => {
|
|
1131
1161
|
const GET_POOL_FEES_INFO_FUNCTION = "get_pool_fees_info";
|
|
1132
1162
|
const GET_PROTOCOL_FEES_INFO_FUNCTION = "get_protocol_fees_info";
|
|
1163
|
+
const pool = client.routerClient.pools.find((item) => item.poolAddress === contractAddress);
|
|
1164
|
+
if (!pool) {
|
|
1165
|
+
throw new import_core12.NotFoundError(`Pool with the address ${contractAddress}`);
|
|
1166
|
+
}
|
|
1133
1167
|
const [poolFeesInfo, protocolFeesInfo] = await Promise.all([
|
|
1134
1168
|
// Query pool fee information
|
|
1135
1169
|
queryDevInspect(
|
|
1136
1170
|
client.suiClient,
|
|
1137
1171
|
[client.packageId, POOL_MODULE, GET_POOL_FEES_INFO_FUNCTION],
|
|
1138
1172
|
[contractAddress],
|
|
1139
|
-
|
|
1140
|
-
[import_utils8.SUI_TYPE_ARG]
|
|
1173
|
+
[pool.baseDenom]
|
|
1141
1174
|
),
|
|
1142
1175
|
// Query protocol fee information
|
|
1143
1176
|
queryDevInspect(
|
|
1144
1177
|
client.suiClient,
|
|
1145
1178
|
[client.packageId, POOL_MODULE, GET_PROTOCOL_FEES_INFO_FUNCTION],
|
|
1146
1179
|
[contractAddress],
|
|
1147
|
-
|
|
1148
|
-
[import_utils8.SUI_TYPE_ARG]
|
|
1180
|
+
[pool.baseDenom]
|
|
1149
1181
|
)
|
|
1150
1182
|
]);
|
|
1151
1183
|
const poolFeesInfoOutput = parseDevInspectResult(poolFeesInfo, PoolFeesInfoStruct);
|
|
@@ -1165,7 +1197,7 @@ var getPoolInfoByDenom = async (client, baseDenom, quoteDenom) => {
|
|
|
1165
1197
|
};
|
|
1166
1198
|
|
|
1167
1199
|
// src/lib/client.ts
|
|
1168
|
-
var BoltSuiClient = class extends
|
|
1200
|
+
var BoltSuiClient = class extends import_core13.BaseClient {
|
|
1169
1201
|
/**
|
|
1170
1202
|
* Creates a new instance of the BoltSuiClient.
|
|
1171
1203
|
*
|
|
@@ -1337,7 +1369,7 @@ var BoltSuiClient = class extends import_core12.BaseClient {
|
|
|
1337
1369
|
getSigner(newSigner) {
|
|
1338
1370
|
this.signer = newSigner ?? this.signer;
|
|
1339
1371
|
if (!this.signer) {
|
|
1340
|
-
throw new
|
|
1372
|
+
throw new import_core13.MissingParameterError("signer");
|
|
1341
1373
|
}
|
|
1342
1374
|
return this.signer;
|
|
1343
1375
|
}
|