@bolt-liquidity-hq/sui-client 0.1.0-beta.18 → 0.1.0-beta.20
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 +102 -57
- 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 +100 -55
- 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
|
|
@@ -20,11 +20,11 @@ var MainnetChainConfig = {
|
|
|
20
20
|
rpcEndpoint: "https://fullnode.mainnet.sui.io:443"
|
|
21
21
|
};
|
|
22
22
|
var MainnetContracts = {
|
|
23
|
-
oracle: "
|
|
24
|
-
router: "
|
|
23
|
+
oracle: "0xfa3975b98f3d0e3df18ed88ae6e69db31836b3f4212df02fae144b1e5a89ca8e",
|
|
24
|
+
router: " "
|
|
25
25
|
};
|
|
26
|
-
var MainnetPackageId = "
|
|
27
|
-
var MainnetPoolGlobalConfigId = "
|
|
26
|
+
var MainnetPackageId = "0xc8724de692400a2a08585f6f7c8617acfb783abe2c66ae6a4680a21b36a504c5";
|
|
27
|
+
var MainnetPoolGlobalConfigId = "0x7bcd5035a991f42fa84c5a42216b5638cb3f1a8c4f065063093b0a3d5f165d63";
|
|
28
28
|
var MainnetNativeTokenDenom = SUI_TOKEN_DENOM;
|
|
29
29
|
var MainnetAssets = {
|
|
30
30
|
[SUI_TOKEN_DENOM]: {
|
|
@@ -44,9 +44,38 @@ var MainnetAssets = {
|
|
|
44
44
|
decimals: 6,
|
|
45
45
|
logo: "https://raw.githubusercontent.com/cosmos/chain-registry/refs/heads/master/_non-cosmos/ethereum/images/usdc.png",
|
|
46
46
|
coingeckoId: "usd-coin"
|
|
47
|
+
},
|
|
48
|
+
"0x356a26eb9e012a68958082340d4c4116e7f55615cf27affcff209cf0ae544f59::wal::WAL": {
|
|
49
|
+
symbol: "WAL",
|
|
50
|
+
name: "Walrus",
|
|
51
|
+
chainId: "101",
|
|
52
|
+
denom: "0x356a26eb9e012a68958082340d4c4116e7f55615cf27affcff209cf0ae544f59::wal::WAL",
|
|
53
|
+
decimals: 9,
|
|
54
|
+
logo: "https://app.lotusfinance.io/images/coins/wal-icon.svg",
|
|
55
|
+
coingeckoId: "walrus-2"
|
|
56
|
+
},
|
|
57
|
+
"0x375f70cf2ae4c00bf37117d0c85a2c71545e6ee05c4a5c7d282cd66a4504b068::usdt::USDT": {
|
|
58
|
+
symbol: "suiUSDT",
|
|
59
|
+
name: "Tether by Sui Bridge",
|
|
60
|
+
chainId: "101",
|
|
61
|
+
denom: "0x375f70cf2ae4c00bf37117d0c85a2c71545e6ee05c4a5c7d282cd66a4504b068::usdt::USDT",
|
|
62
|
+
decimals: 6,
|
|
63
|
+
logo: "https://raw.githubusercontent.com/cosmos/chain-registry/refs/heads/master/_non-cosmos/ethereum/images/usdt.svg",
|
|
64
|
+
coingeckoId: "tether"
|
|
47
65
|
}
|
|
48
66
|
};
|
|
49
|
-
var MainnetPools = [
|
|
67
|
+
var MainnetPools = [
|
|
68
|
+
{
|
|
69
|
+
poolAddress: "0x21167b2e981e2c0a693afcfe882a3a827d663118e19afcb92e45bfe43fe56278",
|
|
70
|
+
baseDenom: "0x0000000000000000000000000000000000000000000000000000000000000002::sui::SUI",
|
|
71
|
+
quoteDenoms: ["0xdba34672e30cb065b1f93e3ab55318768fd6fef66c15942c9f7cb846e2f900e7::usdc::USDC"]
|
|
72
|
+
},
|
|
73
|
+
{
|
|
74
|
+
poolAddress: "0x34fcaa553f1185e1c3a05de37b6a4d10c39535d19f9c8581eeae826434602b58",
|
|
75
|
+
baseDenom: "0xdba34672e30cb065b1f93e3ab55318768fd6fef66c15942c9f7cb846e2f900e7::usdc::USDC",
|
|
76
|
+
quoteDenoms: ["0x0000000000000000000000000000000000000000000000000000000000000002::sui::SUI"]
|
|
77
|
+
}
|
|
78
|
+
];
|
|
50
79
|
|
|
51
80
|
// src/config/testnet.ts
|
|
52
81
|
import { SUI_DECIMALS as SUI_DECIMALS2 } from "@mysten/sui/utils";
|
|
@@ -63,7 +92,6 @@ var TestnetContracts = {
|
|
|
63
92
|
var TestnetPackageId = "";
|
|
64
93
|
var TestnetPoolGlobalConfigId = "";
|
|
65
94
|
var TestnetNativeTokenDenom = SUI_TOKEN_DENOM;
|
|
66
|
-
var TestnetHelperAssets = ["::test_btc::TEST_BTC", "::test_usdt::TEST_USDT"];
|
|
67
95
|
var TestnetAssets = {
|
|
68
96
|
[SUI_TOKEN_DENOM]: {
|
|
69
97
|
symbol: "SUI",
|
|
@@ -100,6 +128,24 @@ var TestnetAssets = {
|
|
|
100
128
|
decimals: 6,
|
|
101
129
|
logo: "https://raw.githubusercontent.com/cosmos/chain-registry/refs/heads/master/_non-cosmos/ethereum/images/usdt.svg",
|
|
102
130
|
coingeckoId: "tether"
|
|
131
|
+
},
|
|
132
|
+
"::test_deep::TEST_DEEP": {
|
|
133
|
+
symbol: "TEST_DEEP",
|
|
134
|
+
name: "TEST_DEEP",
|
|
135
|
+
chainId: "103",
|
|
136
|
+
denom: "::test_deep::TEST_DEEP",
|
|
137
|
+
decimals: 6,
|
|
138
|
+
logo: "https://app.lotusfinance.io/images/coins/deepbook-icon.svg",
|
|
139
|
+
coingeckoId: "deep"
|
|
140
|
+
},
|
|
141
|
+
"::test_wal::TEST_WAL": {
|
|
142
|
+
symbol: "TEST_WAL",
|
|
143
|
+
name: "TEST_WAL",
|
|
144
|
+
chainId: "103",
|
|
145
|
+
denom: "::test_wal::TEST_WAL",
|
|
146
|
+
decimals: 9,
|
|
147
|
+
logo: "https://app.lotusfinance.io/images/coins/wal-icon.svg",
|
|
148
|
+
coingeckoId: "walrus-2"
|
|
103
149
|
}
|
|
104
150
|
};
|
|
105
151
|
|
|
@@ -712,6 +758,7 @@ var getSignerAddress = (signer) => {
|
|
|
712
758
|
// src/lib/oracle/parsers.ts
|
|
713
759
|
import { InvalidObjectError as InvalidObjectError2 } from "@bolt-liquidity-hq/core";
|
|
714
760
|
import { BigNumber as BigNumber2 } from "bignumber.js";
|
|
761
|
+
import { normalizeStructTag as normalizeStructTag3 } from "@mysten/sui/utils";
|
|
715
762
|
var parseOracleConfigStructOutput = (output) => {
|
|
716
763
|
return {
|
|
717
764
|
// TODO: try to query admin somewhere else? to fill empty value
|
|
@@ -723,24 +770,22 @@ var parseOracleConfigStructOutput = (output) => {
|
|
|
723
770
|
}
|
|
724
771
|
};
|
|
725
772
|
};
|
|
726
|
-
var parseAssetPairStructOutput = (output) => {
|
|
773
|
+
var parseAssetPairStructOutput = (output, assetsConfig) => {
|
|
727
774
|
return {
|
|
728
775
|
base: {
|
|
729
|
-
name: output.base_name,
|
|
730
|
-
|
|
731
|
-
symbol: output.base_name,
|
|
776
|
+
name: assetsConfig?.[output.base_name]?.name ?? output.base_name.match(/([^:]+)$/)?.[1] ?? output.base_name,
|
|
777
|
+
symbol: normalizeStructTag3(output.base_name),
|
|
732
778
|
precision: output.base_precision
|
|
733
779
|
},
|
|
734
780
|
quote: {
|
|
735
|
-
name: output.quote_name,
|
|
736
|
-
|
|
737
|
-
symbol: output.quote_name,
|
|
781
|
+
name: assetsConfig?.[output.quote_name]?.name ?? output.quote_name.match(/([^:]+)$/)?.[1] ?? output.quote_name,
|
|
782
|
+
symbol: normalizeStructTag3(output.quote_name),
|
|
738
783
|
precision: output.quote_precision
|
|
739
784
|
}
|
|
740
785
|
};
|
|
741
786
|
};
|
|
742
|
-
var parseAssetPairsResponseStructOutput = (output) => {
|
|
743
|
-
return output.map((item) => parseAssetPairStructOutput(item.info));
|
|
787
|
+
var parseAssetPairsResponseStructOutput = (output, assetsConfig) => {
|
|
788
|
+
return output.map((item) => parseAssetPairStructOutput(item.info, assetsConfig));
|
|
744
789
|
};
|
|
745
790
|
var parsePriceDataStructOutput = (output, baseDenom, quoteDenom, isInverted) => {
|
|
746
791
|
return {
|
|
@@ -857,12 +902,15 @@ var BaseLiquidityResponseStruct = bcs5.struct("BaseLiquidityResponse", {
|
|
|
857
902
|
...PaginationStruct
|
|
858
903
|
});
|
|
859
904
|
var SwapSimulationResultStruct = bcs5.struct("SwapSimulationResult", {
|
|
860
|
-
|
|
905
|
+
base_out: bcs5.u64(),
|
|
906
|
+
quote_out: bcs5.u64(),
|
|
907
|
+
swap_fee_pct: bcs5.u64(),
|
|
861
908
|
dynamic_fee_pct: bcs5.u64(),
|
|
862
909
|
ideal_quote_amt: bcs5.u128(),
|
|
863
910
|
swap_fee: bcs5.u64(),
|
|
864
911
|
lp_fee: bcs5.u64(),
|
|
865
|
-
protocol_fee: bcs5.u64()
|
|
912
|
+
protocol_fee: bcs5.u64(),
|
|
913
|
+
price_used: bcs5.u128()
|
|
866
914
|
});
|
|
867
915
|
|
|
868
916
|
// src/types/pool.ts
|
|
@@ -873,12 +921,13 @@ var PoolInfoStruct = bcs6.struct("PoolInfo", {
|
|
|
873
921
|
admin: BcsAddressType,
|
|
874
922
|
is_paused: bcs6.bool()
|
|
875
923
|
});
|
|
876
|
-
var
|
|
924
|
+
var PoolConfigStruct = bcs6.struct("PoolConfig", {
|
|
877
925
|
swap_fee_pct: bcs6.u64(),
|
|
878
926
|
lp_withdrawal_fee_pct: bcs6.u64(),
|
|
879
927
|
lp_fee_pct: bcs6.u64(),
|
|
880
928
|
max_dynamic_fee: bcs6.u64(),
|
|
881
|
-
limit_ratio: bcs6.u64()
|
|
929
|
+
limit_ratio: bcs6.u64(),
|
|
930
|
+
min_base_out: bcs6.u64()
|
|
882
931
|
});
|
|
883
932
|
var ProtocolFeesInfoStruct = bcs6.struct("ProtocolFeesInfo", {
|
|
884
933
|
swap_fee_pct: bcs6.u64(),
|
|
@@ -894,22 +943,22 @@ var getAssetPairs = async (client) => {
|
|
|
894
943
|
[client.contracts.oracle]
|
|
895
944
|
);
|
|
896
945
|
const output = parseDevInspectResult(response, AssetPairsResponseStruct);
|
|
897
|
-
return parseAssetPairsResponseStructOutput(output);
|
|
946
|
+
return parseAssetPairsResponseStructOutput(output, client.assetsConfig);
|
|
898
947
|
};
|
|
899
948
|
|
|
900
949
|
// src/lib/oracle/get-assets.ts
|
|
901
|
-
import { normalizeStructTag as
|
|
950
|
+
import { normalizeStructTag as normalizeStructTag4 } from "@mysten/sui/utils";
|
|
902
951
|
var getAssets = async (client) => {
|
|
903
952
|
const assetPairs = await client.getAllOracleAssetPairs();
|
|
904
953
|
const uniqueOracleAssets = {};
|
|
905
954
|
for (const item of assetPairs) {
|
|
906
|
-
uniqueOracleAssets[
|
|
955
|
+
uniqueOracleAssets[normalizeStructTag4(item.base.symbol)] = {
|
|
907
956
|
...item.base,
|
|
908
|
-
symbol:
|
|
957
|
+
symbol: normalizeStructTag4(item.base.symbol)
|
|
909
958
|
};
|
|
910
|
-
uniqueOracleAssets[
|
|
959
|
+
uniqueOracleAssets[normalizeStructTag4(item.quote.symbol)] = {
|
|
911
960
|
...item.quote,
|
|
912
|
-
symbol:
|
|
961
|
+
symbol: normalizeStructTag4(item.quote.symbol)
|
|
913
962
|
};
|
|
914
963
|
}
|
|
915
964
|
return Object.values(uniqueOracleAssets).map(
|
|
@@ -918,7 +967,7 @@ var getAssets = async (client) => {
|
|
|
918
967
|
symbol: item.name,
|
|
919
968
|
name: item.name,
|
|
920
969
|
chainId: client.chainConfig.id,
|
|
921
|
-
denom:
|
|
970
|
+
denom: normalizeStructTag4(item.symbol),
|
|
922
971
|
decimals: item.precision,
|
|
923
972
|
logo: void 0,
|
|
924
973
|
coingeckoId: void 0
|
|
@@ -953,7 +1002,7 @@ var getPrice = async (client, baseDenom, quoteDenom) => {
|
|
|
953
1002
|
|
|
954
1003
|
// src/lib/oracle/get-prices.ts
|
|
955
1004
|
import { NotFoundError as NotFoundError2 } from "@bolt-liquidity-hq/core";
|
|
956
|
-
import { normalizeStructTag as
|
|
1005
|
+
import { normalizeStructTag as normalizeStructTag5 } from "@mysten/sui/utils";
|
|
957
1006
|
var getPrices = async (client) => {
|
|
958
1007
|
const oracleObject = await client.suiClient.getObject({
|
|
959
1008
|
id: client.contracts.oracle,
|
|
@@ -988,8 +1037,8 @@ var getPrices = async (client) => {
|
|
|
988
1037
|
const pairKey = dynamicFields.data[index]?.name?.value;
|
|
989
1038
|
if (fields && pairKey) {
|
|
990
1039
|
prices.push({
|
|
991
|
-
baseDenom:
|
|
992
|
-
quoteDenom:
|
|
1040
|
+
baseDenom: normalizeStructTag5(pairKey.base.name),
|
|
1041
|
+
quoteDenom: normalizeStructTag5(pairKey.quote.name),
|
|
993
1042
|
price: fields.price,
|
|
994
1043
|
expiryTime: fields.expiry
|
|
995
1044
|
});
|
|
@@ -1058,7 +1107,7 @@ import { BigNumber as BigNumber3 } from "bignumber.js";
|
|
|
1058
1107
|
var parseSwapSimulationResultStructOutput = (output, poolAddress, assetOut) => {
|
|
1059
1108
|
return {
|
|
1060
1109
|
poolAddress,
|
|
1061
|
-
amountOut: output.
|
|
1110
|
+
amountOut: output.base_out,
|
|
1062
1111
|
assetOut,
|
|
1063
1112
|
protocolFee: output.protocol_fee,
|
|
1064
1113
|
lpFee: output.lp_fee,
|
|
@@ -1068,14 +1117,14 @@ var parseSwapSimulationResultStructOutput = (output, poolAddress, assetOut) => {
|
|
|
1068
1117
|
};
|
|
1069
1118
|
|
|
1070
1119
|
// src/lib/router/router-client/RouterClient.ts
|
|
1071
|
-
import { normalizeStructTag as
|
|
1120
|
+
import { normalizeStructTag as normalizeStructTag6 } from "@mysten/sui/utils";
|
|
1072
1121
|
var RouterClient = class {
|
|
1073
1122
|
constructor(pools) {
|
|
1074
1123
|
this.pools = pools;
|
|
1075
1124
|
}
|
|
1076
1125
|
getPool(denomIn, denomOut) {
|
|
1077
|
-
const normalizedDenomIn =
|
|
1078
|
-
const normalizedDenomOut =
|
|
1126
|
+
const normalizedDenomIn = normalizeStructTag6(denomIn);
|
|
1127
|
+
const normalizedDenomOut = normalizeStructTag6(denomOut);
|
|
1079
1128
|
const directPairPool = this.pools.find(
|
|
1080
1129
|
(item) => item.baseDenom === normalizedDenomOut && item.quoteDenoms.includes(normalizedDenomIn)
|
|
1081
1130
|
);
|
|
@@ -1148,39 +1197,35 @@ import { NotFoundError as NotFoundError6 } from "@bolt-liquidity-hq/core";
|
|
|
1148
1197
|
|
|
1149
1198
|
// src/lib/settlement/parsers.ts
|
|
1150
1199
|
import { BigNumber as BigNumber4 } from "bignumber.js";
|
|
1151
|
-
var
|
|
1200
|
+
var parsePoolConfigStructOutput = (routerClient, poolConfig, priceOracleContract) => {
|
|
1152
1201
|
return {
|
|
1153
1202
|
priceOracleContract,
|
|
1154
1203
|
protocolFeeRecipient: "0x",
|
|
1155
|
-
|
|
1156
|
-
|
|
1204
|
+
// TODO: get real fee recipient
|
|
1205
|
+
protocolFee: BigNumber4(poolConfig.swap_fee_pct).div(BASIS_POINTS).toFixed(),
|
|
1206
|
+
lpFee: BigNumber4(poolConfig.lp_fee_pct).div(BASIS_POINTS).toFixed(),
|
|
1157
1207
|
allowanceMode: "allow",
|
|
1158
1208
|
// Should come from pool config
|
|
1159
1209
|
lps: routerClient.getPools().map((item) => item.poolAddress),
|
|
1160
|
-
minBaseOut:
|
|
1161
|
-
// Should come from pool config
|
|
1210
|
+
minBaseOut: BigNumber4(poolConfig.min_base_out).toFixed()
|
|
1162
1211
|
};
|
|
1163
1212
|
};
|
|
1164
1213
|
|
|
1165
1214
|
// src/lib/settlement/get-pool-info.ts
|
|
1166
1215
|
var getPoolInfo = async (client, contractAddress) => {
|
|
1167
|
-
const
|
|
1216
|
+
const GET_POOL_CONFIG_FUNCTION = "get_pool_config";
|
|
1168
1217
|
const pool = client.routerClient.pools.find((item) => item.poolAddress === contractAddress);
|
|
1169
1218
|
if (!pool) {
|
|
1170
1219
|
throw new NotFoundError6(`Pool with the address ${contractAddress}`);
|
|
1171
1220
|
}
|
|
1172
|
-
const
|
|
1221
|
+
const poolConfig = await queryDevInspect(
|
|
1173
1222
|
client.suiClient,
|
|
1174
|
-
[client.packageId, POOL_MODULE,
|
|
1223
|
+
[client.packageId, POOL_MODULE, GET_POOL_CONFIG_FUNCTION],
|
|
1175
1224
|
[contractAddress],
|
|
1176
1225
|
[pool.baseDenom]
|
|
1177
1226
|
);
|
|
1178
|
-
const
|
|
1179
|
-
return
|
|
1180
|
-
client.routerClient,
|
|
1181
|
-
poolFeesInfoOutput,
|
|
1182
|
-
client.contracts.oracle
|
|
1183
|
-
);
|
|
1227
|
+
const output = parseDevInspectResult(poolConfig, PoolConfigStruct);
|
|
1228
|
+
return parsePoolConfigStructOutput(client.routerClient, output, client.contracts.oracle);
|
|
1184
1229
|
};
|
|
1185
1230
|
|
|
1186
1231
|
// src/lib/settlement/get-pool-info-by-denom.ts
|
|
@@ -1550,13 +1595,13 @@ var BoltSuiClient = class extends BaseClient {
|
|
|
1550
1595
|
this.poolGlobalConfigId = global_config_id;
|
|
1551
1596
|
}
|
|
1552
1597
|
for (const item of Object.values(assets)) {
|
|
1553
|
-
for (const
|
|
1554
|
-
if (item.
|
|
1598
|
+
for (const existingConfig of Object.values(this.assetsConfig)) {
|
|
1599
|
+
if (item.endsWith(existingConfig.denom)) {
|
|
1555
1600
|
this.assetsConfig[item] = {
|
|
1556
|
-
...
|
|
1601
|
+
...existingConfig,
|
|
1557
1602
|
denom: item
|
|
1558
1603
|
};
|
|
1559
|
-
delete this.assetsConfig[
|
|
1604
|
+
delete this.assetsConfig[existingConfig.denom];
|
|
1560
1605
|
break;
|
|
1561
1606
|
}
|
|
1562
1607
|
}
|
|
@@ -1565,8 +1610,8 @@ var BoltSuiClient = class extends BaseClient {
|
|
|
1565
1610
|
for (const item of pools) {
|
|
1566
1611
|
this.routerClient.pools.push({
|
|
1567
1612
|
poolAddress: item.pool_object_id,
|
|
1568
|
-
baseDenom:
|
|
1569
|
-
quoteDenoms: Object.values(assets).map((auxAsset) =>
|
|
1613
|
+
baseDenom: normalizeStructTag7(item.base),
|
|
1614
|
+
quoteDenoms: Object.values(assets).map((auxAsset) => normalizeStructTag7(auxAsset)).filter((auxAsset) => auxAsset !== normalizeStructTag7(item.base))
|
|
1570
1615
|
});
|
|
1571
1616
|
}
|
|
1572
1617
|
}
|
|
@@ -1587,7 +1632,7 @@ export {
|
|
|
1587
1632
|
MarketsResponseStruct,
|
|
1588
1633
|
OracleConfigStruct,
|
|
1589
1634
|
PaginationStruct,
|
|
1590
|
-
|
|
1635
|
+
PoolConfigStruct,
|
|
1591
1636
|
PoolInfoStruct,
|
|
1592
1637
|
PriceDataStruct,
|
|
1593
1638
|
PriceResponseStruct,
|