@bolt-liquidity-hq/sui-client 0.1.0-beta.18 → 0.1.0-beta.19
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 +64 -47
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +8 -4
- package/dist/index.d.ts +8 -4
- package/dist/index.js +62 -45
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.d.cts
CHANGED
|
@@ -239,12 +239,15 @@ declare const BaseLiquidityResponseStruct: _mysten_bcs.BcsStruct<{
|
|
|
239
239
|
}, string>;
|
|
240
240
|
type BaseLiquidityResponseStructOutput = BcsParsed<typeof BaseLiquidityResponseStruct>;
|
|
241
241
|
declare const SwapSimulationResultStruct: _mysten_bcs.BcsStruct<{
|
|
242
|
-
|
|
242
|
+
base_out: _mysten_bcs.BcsType<string, string | number | bigint, "u64">;
|
|
243
|
+
quote_out: _mysten_bcs.BcsType<string, string | number | bigint, "u64">;
|
|
244
|
+
swap_fee_pct: _mysten_bcs.BcsType<string, string | number | bigint, "u64">;
|
|
243
245
|
dynamic_fee_pct: _mysten_bcs.BcsType<string, string | number | bigint, "u64">;
|
|
244
246
|
ideal_quote_amt: _mysten_bcs.BcsType<string, string | number | bigint, "u128">;
|
|
245
247
|
swap_fee: _mysten_bcs.BcsType<string, string | number | bigint, "u64">;
|
|
246
248
|
lp_fee: _mysten_bcs.BcsType<string, string | number | bigint, "u64">;
|
|
247
249
|
protocol_fee: _mysten_bcs.BcsType<string, string | number | bigint, "u64">;
|
|
250
|
+
price_used: _mysten_bcs.BcsType<string, string | number | bigint, "u128">;
|
|
248
251
|
}, string>;
|
|
249
252
|
type SwapSimulationResultStructOutput = BcsParsed<typeof SwapSimulationResultStruct>;
|
|
250
253
|
type RouterPool = Pool & {
|
|
@@ -258,14 +261,15 @@ declare const PoolInfoStruct: _mysten_bcs.BcsStruct<{
|
|
|
258
261
|
is_paused: _mysten_bcs.BcsType<boolean, boolean, "bool">;
|
|
259
262
|
}, string>;
|
|
260
263
|
type PoolInfoStructOutput = BcsParsed<typeof PoolInfoStruct>;
|
|
261
|
-
declare const
|
|
264
|
+
declare const PoolConfigStruct: _mysten_bcs.BcsStruct<{
|
|
262
265
|
swap_fee_pct: _mysten_bcs.BcsType<string, string | number | bigint, "u64">;
|
|
263
266
|
lp_withdrawal_fee_pct: _mysten_bcs.BcsType<string, string | number | bigint, "u64">;
|
|
264
267
|
lp_fee_pct: _mysten_bcs.BcsType<string, string | number | bigint, "u64">;
|
|
265
268
|
max_dynamic_fee: _mysten_bcs.BcsType<string, string | number | bigint, "u64">;
|
|
266
269
|
limit_ratio: _mysten_bcs.BcsType<string, string | number | bigint, "u64">;
|
|
270
|
+
min_base_out: _mysten_bcs.BcsType<string, string | number | bigint, "u64">;
|
|
267
271
|
}, string>;
|
|
268
|
-
type
|
|
272
|
+
type PoolConfigStructOutput = BcsParsed<typeof PoolConfigStruct>;
|
|
269
273
|
declare const ProtocolFeesInfoStruct: _mysten_bcs.BcsStruct<{
|
|
270
274
|
swap_fee_pct: _mysten_bcs.BcsType<string, string | number | bigint, "u64">;
|
|
271
275
|
lp_withdrawal_fee_pct: _mysten_bcs.BcsType<string, string | number | bigint, "u64">;
|
|
@@ -562,4 +566,4 @@ declare class BoltSuiClient extends BaseClient<Signer, SuiTransactionBlockRespon
|
|
|
562
566
|
private loadConfigFromUrl;
|
|
563
567
|
}
|
|
564
568
|
|
|
565
|
-
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,
|
|
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, PoolConfigStruct, type PoolConfigStructOutput, PoolInfoStruct, type PoolInfoStructOutput, PriceDataStruct, type PriceDataStructOutput, PriceResponseStruct, type PriceResponseStructOutput, ProtocolFeesInfoStruct, type ProtocolFeesInfoStructOutput, RawPairStruct, type RawPairStructOutput, RawPriceStruct, type RawPriceStructOutput, RouterConfigStruct, type RouterConfigStructOutput, type RouterPool, type SuiChainConfig, type SuiClientConfig, SwapSimulationResultStruct, type SwapSimulationResultStructOutput, TypeNameStruct, type TypeNameStructOutput, type WalletSigner };
|
package/dist/index.d.ts
CHANGED
|
@@ -239,12 +239,15 @@ declare const BaseLiquidityResponseStruct: _mysten_bcs.BcsStruct<{
|
|
|
239
239
|
}, string>;
|
|
240
240
|
type BaseLiquidityResponseStructOutput = BcsParsed<typeof BaseLiquidityResponseStruct>;
|
|
241
241
|
declare const SwapSimulationResultStruct: _mysten_bcs.BcsStruct<{
|
|
242
|
-
|
|
242
|
+
base_out: _mysten_bcs.BcsType<string, string | number | bigint, "u64">;
|
|
243
|
+
quote_out: _mysten_bcs.BcsType<string, string | number | bigint, "u64">;
|
|
244
|
+
swap_fee_pct: _mysten_bcs.BcsType<string, string | number | bigint, "u64">;
|
|
243
245
|
dynamic_fee_pct: _mysten_bcs.BcsType<string, string | number | bigint, "u64">;
|
|
244
246
|
ideal_quote_amt: _mysten_bcs.BcsType<string, string | number | bigint, "u128">;
|
|
245
247
|
swap_fee: _mysten_bcs.BcsType<string, string | number | bigint, "u64">;
|
|
246
248
|
lp_fee: _mysten_bcs.BcsType<string, string | number | bigint, "u64">;
|
|
247
249
|
protocol_fee: _mysten_bcs.BcsType<string, string | number | bigint, "u64">;
|
|
250
|
+
price_used: _mysten_bcs.BcsType<string, string | number | bigint, "u128">;
|
|
248
251
|
}, string>;
|
|
249
252
|
type SwapSimulationResultStructOutput = BcsParsed<typeof SwapSimulationResultStruct>;
|
|
250
253
|
type RouterPool = Pool & {
|
|
@@ -258,14 +261,15 @@ declare const PoolInfoStruct: _mysten_bcs.BcsStruct<{
|
|
|
258
261
|
is_paused: _mysten_bcs.BcsType<boolean, boolean, "bool">;
|
|
259
262
|
}, string>;
|
|
260
263
|
type PoolInfoStructOutput = BcsParsed<typeof PoolInfoStruct>;
|
|
261
|
-
declare const
|
|
264
|
+
declare const PoolConfigStruct: _mysten_bcs.BcsStruct<{
|
|
262
265
|
swap_fee_pct: _mysten_bcs.BcsType<string, string | number | bigint, "u64">;
|
|
263
266
|
lp_withdrawal_fee_pct: _mysten_bcs.BcsType<string, string | number | bigint, "u64">;
|
|
264
267
|
lp_fee_pct: _mysten_bcs.BcsType<string, string | number | bigint, "u64">;
|
|
265
268
|
max_dynamic_fee: _mysten_bcs.BcsType<string, string | number | bigint, "u64">;
|
|
266
269
|
limit_ratio: _mysten_bcs.BcsType<string, string | number | bigint, "u64">;
|
|
270
|
+
min_base_out: _mysten_bcs.BcsType<string, string | number | bigint, "u64">;
|
|
267
271
|
}, string>;
|
|
268
|
-
type
|
|
272
|
+
type PoolConfigStructOutput = BcsParsed<typeof PoolConfigStruct>;
|
|
269
273
|
declare const ProtocolFeesInfoStruct: _mysten_bcs.BcsStruct<{
|
|
270
274
|
swap_fee_pct: _mysten_bcs.BcsType<string, string | number | bigint, "u64">;
|
|
271
275
|
lp_withdrawal_fee_pct: _mysten_bcs.BcsType<string, string | number | bigint, "u64">;
|
|
@@ -562,4 +566,4 @@ declare class BoltSuiClient extends BaseClient<Signer, SuiTransactionBlockRespon
|
|
|
562
566
|
private loadConfigFromUrl;
|
|
563
567
|
}
|
|
564
568
|
|
|
565
|
-
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,
|
|
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, PoolConfigStruct, type PoolConfigStructOutput, PoolInfoStruct, type PoolInfoStructOutput, PriceDataStruct, type PriceDataStructOutput, PriceResponseStruct, type PriceResponseStructOutput, ProtocolFeesInfoStruct, type ProtocolFeesInfoStructOutput, RawPairStruct, type RawPairStructOutput, RawPriceStruct, type RawPriceStructOutput, RouterConfigStruct, type RouterConfigStructOutput, type RouterPool, type SuiChainConfig, type SuiClientConfig, SwapSimulationResultStruct, type SwapSimulationResultStructOutput, TypeNameStruct, type TypeNameStructOutput, type WalletSigner };
|
package/dist/index.js
CHANGED
|
@@ -5,7 +5,7 @@ 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
|
|
8
|
+
import { normalizeStructTag as normalizeStructTag7 } from "@mysten/sui/utils";
|
|
9
9
|
import axios from "axios";
|
|
10
10
|
|
|
11
11
|
// src/config/common.ts
|
|
@@ -100,6 +100,24 @@ var TestnetAssets = {
|
|
|
100
100
|
decimals: 6,
|
|
101
101
|
logo: "https://raw.githubusercontent.com/cosmos/chain-registry/refs/heads/master/_non-cosmos/ethereum/images/usdt.svg",
|
|
102
102
|
coingeckoId: "tether"
|
|
103
|
+
},
|
|
104
|
+
"::test_deep::TEST_DEEP": {
|
|
105
|
+
symbol: "TEST_DEEP",
|
|
106
|
+
name: "TEST_DEEP",
|
|
107
|
+
chainId: "103",
|
|
108
|
+
denom: "0xb3aa3abfda8979c403edcb2fdc5cd433d3ccc0e6332844bdfdfddc870bf116b0::test_deep::TEST_DEEP",
|
|
109
|
+
decimals: 6,
|
|
110
|
+
logo: "https://app.lotusfinance.io/images/coins/deepbook-icon.svg",
|
|
111
|
+
coingeckoId: "deep"
|
|
112
|
+
},
|
|
113
|
+
"::test_wal::TEST_WAL": {
|
|
114
|
+
symbol: "TEST_WAL",
|
|
115
|
+
name: "TEST_WAL",
|
|
116
|
+
chainId: "103",
|
|
117
|
+
denom: "0xb3aa3abfda8979c403edcb2fdc5cd433d3ccc0e6332844bdfdfddc870bf116b0::test_wal::TEST_WAL",
|
|
118
|
+
decimals: 9,
|
|
119
|
+
logo: "https://app.lotusfinance.io/images/coins/wal-icon.svg",
|
|
120
|
+
coingeckoId: "walrus-2"
|
|
103
121
|
}
|
|
104
122
|
};
|
|
105
123
|
|
|
@@ -712,6 +730,7 @@ var getSignerAddress = (signer) => {
|
|
|
712
730
|
// src/lib/oracle/parsers.ts
|
|
713
731
|
import { InvalidObjectError as InvalidObjectError2 } from "@bolt-liquidity-hq/core";
|
|
714
732
|
import { BigNumber as BigNumber2 } from "bignumber.js";
|
|
733
|
+
import { normalizeStructTag as normalizeStructTag3 } from "@mysten/sui/utils";
|
|
715
734
|
var parseOracleConfigStructOutput = (output) => {
|
|
716
735
|
return {
|
|
717
736
|
// TODO: try to query admin somewhere else? to fill empty value
|
|
@@ -723,24 +742,22 @@ var parseOracleConfigStructOutput = (output) => {
|
|
|
723
742
|
}
|
|
724
743
|
};
|
|
725
744
|
};
|
|
726
|
-
var parseAssetPairStructOutput = (output) => {
|
|
745
|
+
var parseAssetPairStructOutput = (output, assetsConfig) => {
|
|
727
746
|
return {
|
|
728
747
|
base: {
|
|
729
|
-
name: output.base_name,
|
|
730
|
-
|
|
731
|
-
symbol: output.base_name,
|
|
748
|
+
name: assetsConfig?.[output.base_name]?.name ?? output.base_name.match(/([^:]+)$/)?.[1] ?? output.base_name,
|
|
749
|
+
symbol: normalizeStructTag3(output.base_name),
|
|
732
750
|
precision: output.base_precision
|
|
733
751
|
},
|
|
734
752
|
quote: {
|
|
735
|
-
name: output.quote_name,
|
|
736
|
-
|
|
737
|
-
symbol: output.quote_name,
|
|
753
|
+
name: assetsConfig?.[output.quote_name]?.name ?? output.quote_name.match(/([^:]+)$/)?.[1] ?? output.quote_name,
|
|
754
|
+
symbol: normalizeStructTag3(output.quote_name),
|
|
738
755
|
precision: output.quote_precision
|
|
739
756
|
}
|
|
740
757
|
};
|
|
741
758
|
};
|
|
742
|
-
var parseAssetPairsResponseStructOutput = (output) => {
|
|
743
|
-
return output.map((item) => parseAssetPairStructOutput(item.info));
|
|
759
|
+
var parseAssetPairsResponseStructOutput = (output, assetsConfig) => {
|
|
760
|
+
return output.map((item) => parseAssetPairStructOutput(item.info, assetsConfig));
|
|
744
761
|
};
|
|
745
762
|
var parsePriceDataStructOutput = (output, baseDenom, quoteDenom, isInverted) => {
|
|
746
763
|
return {
|
|
@@ -857,12 +874,15 @@ var BaseLiquidityResponseStruct = bcs5.struct("BaseLiquidityResponse", {
|
|
|
857
874
|
...PaginationStruct
|
|
858
875
|
});
|
|
859
876
|
var SwapSimulationResultStruct = bcs5.struct("SwapSimulationResult", {
|
|
860
|
-
|
|
877
|
+
base_out: bcs5.u64(),
|
|
878
|
+
quote_out: bcs5.u64(),
|
|
879
|
+
swap_fee_pct: bcs5.u64(),
|
|
861
880
|
dynamic_fee_pct: bcs5.u64(),
|
|
862
881
|
ideal_quote_amt: bcs5.u128(),
|
|
863
882
|
swap_fee: bcs5.u64(),
|
|
864
883
|
lp_fee: bcs5.u64(),
|
|
865
|
-
protocol_fee: bcs5.u64()
|
|
884
|
+
protocol_fee: bcs5.u64(),
|
|
885
|
+
price_used: bcs5.u128()
|
|
866
886
|
});
|
|
867
887
|
|
|
868
888
|
// src/types/pool.ts
|
|
@@ -873,12 +893,13 @@ var PoolInfoStruct = bcs6.struct("PoolInfo", {
|
|
|
873
893
|
admin: BcsAddressType,
|
|
874
894
|
is_paused: bcs6.bool()
|
|
875
895
|
});
|
|
876
|
-
var
|
|
896
|
+
var PoolConfigStruct = bcs6.struct("PoolConfig", {
|
|
877
897
|
swap_fee_pct: bcs6.u64(),
|
|
878
898
|
lp_withdrawal_fee_pct: bcs6.u64(),
|
|
879
899
|
lp_fee_pct: bcs6.u64(),
|
|
880
900
|
max_dynamic_fee: bcs6.u64(),
|
|
881
|
-
limit_ratio: bcs6.u64()
|
|
901
|
+
limit_ratio: bcs6.u64(),
|
|
902
|
+
min_base_out: bcs6.u64()
|
|
882
903
|
});
|
|
883
904
|
var ProtocolFeesInfoStruct = bcs6.struct("ProtocolFeesInfo", {
|
|
884
905
|
swap_fee_pct: bcs6.u64(),
|
|
@@ -894,22 +915,22 @@ var getAssetPairs = async (client) => {
|
|
|
894
915
|
[client.contracts.oracle]
|
|
895
916
|
);
|
|
896
917
|
const output = parseDevInspectResult(response, AssetPairsResponseStruct);
|
|
897
|
-
return parseAssetPairsResponseStructOutput(output);
|
|
918
|
+
return parseAssetPairsResponseStructOutput(output, client.assetsConfig);
|
|
898
919
|
};
|
|
899
920
|
|
|
900
921
|
// src/lib/oracle/get-assets.ts
|
|
901
|
-
import { normalizeStructTag as
|
|
922
|
+
import { normalizeStructTag as normalizeStructTag4 } from "@mysten/sui/utils";
|
|
902
923
|
var getAssets = async (client) => {
|
|
903
924
|
const assetPairs = await client.getAllOracleAssetPairs();
|
|
904
925
|
const uniqueOracleAssets = {};
|
|
905
926
|
for (const item of assetPairs) {
|
|
906
|
-
uniqueOracleAssets[
|
|
927
|
+
uniqueOracleAssets[normalizeStructTag4(item.base.symbol)] = {
|
|
907
928
|
...item.base,
|
|
908
|
-
symbol:
|
|
929
|
+
symbol: normalizeStructTag4(item.base.symbol)
|
|
909
930
|
};
|
|
910
|
-
uniqueOracleAssets[
|
|
931
|
+
uniqueOracleAssets[normalizeStructTag4(item.quote.symbol)] = {
|
|
911
932
|
...item.quote,
|
|
912
|
-
symbol:
|
|
933
|
+
symbol: normalizeStructTag4(item.quote.symbol)
|
|
913
934
|
};
|
|
914
935
|
}
|
|
915
936
|
return Object.values(uniqueOracleAssets).map(
|
|
@@ -918,7 +939,7 @@ var getAssets = async (client) => {
|
|
|
918
939
|
symbol: item.name,
|
|
919
940
|
name: item.name,
|
|
920
941
|
chainId: client.chainConfig.id,
|
|
921
|
-
denom:
|
|
942
|
+
denom: normalizeStructTag4(item.symbol),
|
|
922
943
|
decimals: item.precision,
|
|
923
944
|
logo: void 0,
|
|
924
945
|
coingeckoId: void 0
|
|
@@ -953,7 +974,7 @@ var getPrice = async (client, baseDenom, quoteDenom) => {
|
|
|
953
974
|
|
|
954
975
|
// src/lib/oracle/get-prices.ts
|
|
955
976
|
import { NotFoundError as NotFoundError2 } from "@bolt-liquidity-hq/core";
|
|
956
|
-
import { normalizeStructTag as
|
|
977
|
+
import { normalizeStructTag as normalizeStructTag5 } from "@mysten/sui/utils";
|
|
957
978
|
var getPrices = async (client) => {
|
|
958
979
|
const oracleObject = await client.suiClient.getObject({
|
|
959
980
|
id: client.contracts.oracle,
|
|
@@ -988,8 +1009,8 @@ var getPrices = async (client) => {
|
|
|
988
1009
|
const pairKey = dynamicFields.data[index]?.name?.value;
|
|
989
1010
|
if (fields && pairKey) {
|
|
990
1011
|
prices.push({
|
|
991
|
-
baseDenom:
|
|
992
|
-
quoteDenom:
|
|
1012
|
+
baseDenom: normalizeStructTag5(pairKey.base.name),
|
|
1013
|
+
quoteDenom: normalizeStructTag5(pairKey.quote.name),
|
|
993
1014
|
price: fields.price,
|
|
994
1015
|
expiryTime: fields.expiry
|
|
995
1016
|
});
|
|
@@ -1058,7 +1079,7 @@ import { BigNumber as BigNumber3 } from "bignumber.js";
|
|
|
1058
1079
|
var parseSwapSimulationResultStructOutput = (output, poolAddress, assetOut) => {
|
|
1059
1080
|
return {
|
|
1060
1081
|
poolAddress,
|
|
1061
|
-
amountOut: output.
|
|
1082
|
+
amountOut: output.base_out,
|
|
1062
1083
|
assetOut,
|
|
1063
1084
|
protocolFee: output.protocol_fee,
|
|
1064
1085
|
lpFee: output.lp_fee,
|
|
@@ -1068,14 +1089,14 @@ var parseSwapSimulationResultStructOutput = (output, poolAddress, assetOut) => {
|
|
|
1068
1089
|
};
|
|
1069
1090
|
|
|
1070
1091
|
// src/lib/router/router-client/RouterClient.ts
|
|
1071
|
-
import { normalizeStructTag as
|
|
1092
|
+
import { normalizeStructTag as normalizeStructTag6 } from "@mysten/sui/utils";
|
|
1072
1093
|
var RouterClient = class {
|
|
1073
1094
|
constructor(pools) {
|
|
1074
1095
|
this.pools = pools;
|
|
1075
1096
|
}
|
|
1076
1097
|
getPool(denomIn, denomOut) {
|
|
1077
|
-
const normalizedDenomIn =
|
|
1078
|
-
const normalizedDenomOut =
|
|
1098
|
+
const normalizedDenomIn = normalizeStructTag6(denomIn);
|
|
1099
|
+
const normalizedDenomOut = normalizeStructTag6(denomOut);
|
|
1079
1100
|
const directPairPool = this.pools.find(
|
|
1080
1101
|
(item) => item.baseDenom === normalizedDenomOut && item.quoteDenoms.includes(normalizedDenomIn)
|
|
1081
1102
|
);
|
|
@@ -1148,39 +1169,35 @@ import { NotFoundError as NotFoundError6 } from "@bolt-liquidity-hq/core";
|
|
|
1148
1169
|
|
|
1149
1170
|
// src/lib/settlement/parsers.ts
|
|
1150
1171
|
import { BigNumber as BigNumber4 } from "bignumber.js";
|
|
1151
|
-
var
|
|
1172
|
+
var parsePoolConfigStructOutput = (routerClient, poolConfig, priceOracleContract) => {
|
|
1152
1173
|
return {
|
|
1153
1174
|
priceOracleContract,
|
|
1154
1175
|
protocolFeeRecipient: "0x",
|
|
1155
|
-
|
|
1156
|
-
|
|
1176
|
+
// TODO: get real fee recipient
|
|
1177
|
+
protocolFee: BigNumber4(poolConfig.swap_fee_pct).div(BASIS_POINTS).toFixed(),
|
|
1178
|
+
lpFee: BigNumber4(poolConfig.lp_fee_pct).div(BASIS_POINTS).toFixed(),
|
|
1157
1179
|
allowanceMode: "allow",
|
|
1158
1180
|
// Should come from pool config
|
|
1159
1181
|
lps: routerClient.getPools().map((item) => item.poolAddress),
|
|
1160
|
-
minBaseOut:
|
|
1161
|
-
// Should come from pool config
|
|
1182
|
+
minBaseOut: BigNumber4(poolConfig.min_base_out).toFixed()
|
|
1162
1183
|
};
|
|
1163
1184
|
};
|
|
1164
1185
|
|
|
1165
1186
|
// src/lib/settlement/get-pool-info.ts
|
|
1166
1187
|
var getPoolInfo = async (client, contractAddress) => {
|
|
1167
|
-
const
|
|
1188
|
+
const GET_POOL_CONFIG_FUNCTION = "get_pool_config";
|
|
1168
1189
|
const pool = client.routerClient.pools.find((item) => item.poolAddress === contractAddress);
|
|
1169
1190
|
if (!pool) {
|
|
1170
1191
|
throw new NotFoundError6(`Pool with the address ${contractAddress}`);
|
|
1171
1192
|
}
|
|
1172
|
-
const
|
|
1193
|
+
const poolConfig = await queryDevInspect(
|
|
1173
1194
|
client.suiClient,
|
|
1174
|
-
[client.packageId, POOL_MODULE,
|
|
1195
|
+
[client.packageId, POOL_MODULE, GET_POOL_CONFIG_FUNCTION],
|
|
1175
1196
|
[contractAddress],
|
|
1176
1197
|
[pool.baseDenom]
|
|
1177
1198
|
);
|
|
1178
|
-
const
|
|
1179
|
-
return
|
|
1180
|
-
client.routerClient,
|
|
1181
|
-
poolFeesInfoOutput,
|
|
1182
|
-
client.contracts.oracle
|
|
1183
|
-
);
|
|
1199
|
+
const output = parseDevInspectResult(poolConfig, PoolConfigStruct);
|
|
1200
|
+
return parsePoolConfigStructOutput(client.routerClient, output, client.contracts.oracle);
|
|
1184
1201
|
};
|
|
1185
1202
|
|
|
1186
1203
|
// src/lib/settlement/get-pool-info-by-denom.ts
|
|
@@ -1565,8 +1582,8 @@ var BoltSuiClient = class extends BaseClient {
|
|
|
1565
1582
|
for (const item of pools) {
|
|
1566
1583
|
this.routerClient.pools.push({
|
|
1567
1584
|
poolAddress: item.pool_object_id,
|
|
1568
|
-
baseDenom:
|
|
1569
|
-
quoteDenoms: Object.values(assets).map((auxAsset) =>
|
|
1585
|
+
baseDenom: normalizeStructTag7(item.base),
|
|
1586
|
+
quoteDenoms: Object.values(assets).map((auxAsset) => normalizeStructTag7(auxAsset)).filter((auxAsset) => auxAsset !== normalizeStructTag7(item.base))
|
|
1570
1587
|
});
|
|
1571
1588
|
}
|
|
1572
1589
|
}
|
|
@@ -1587,7 +1604,7 @@ export {
|
|
|
1587
1604
|
MarketsResponseStruct,
|
|
1588
1605
|
OracleConfigStruct,
|
|
1589
1606
|
PaginationStruct,
|
|
1590
|
-
|
|
1607
|
+
PoolConfigStruct,
|
|
1591
1608
|
PoolInfoStruct,
|
|
1592
1609
|
PriceDataStruct,
|
|
1593
1610
|
PriceResponseStruct,
|