@scallop-io/sui-scallop-sdk 0.44.1 → 0.44.2
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/constants/common.d.ts +2 -2
- package/dist/constants/enum.d.ts +2 -1
- package/dist/index.js +90 -17
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +89 -17
- package/dist/index.mjs.map +1 -1
- package/dist/models/scallopQuery.d.ts +5 -0
- package/dist/models/scallopUtils.d.ts +1 -0
- package/dist/queries/coreQuery.d.ts +4 -0
- package/dist/queries/portfolioQuery.d.ts +1 -0
- package/dist/types/address.d.ts +2 -2
- package/dist/types/constant/enum.d.ts +3 -0
- package/dist/utils/util.d.ts +2 -1
- package/package.json +12 -12
- package/src/constants/common.ts +2 -0
- package/src/constants/enum.ts +10 -0
- package/src/models/scallopAddress.ts +39 -0
- package/src/models/scallopUtils.ts +32 -10
- package/src/types/address.ts +2 -2
- package/src/types/constant/enum.ts +4 -0
- package/src/utils/util.ts +24 -8
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
export declare const API_BASE_URL = "https://sui.api.scallop.io";
|
|
2
2
|
export declare const ADDRESSES_ID = "6462a088a7ace142bb6d7e9b";
|
|
3
3
|
export declare const PROTOCOL_OBJECT_ID = "0xefe8b36d5b2e43728cc323298626b83177803521d195cfb11e15b910e892fddf";
|
|
4
|
-
export declare const SUPPORT_POOLS: readonly ["eth", "btc", "usdc", "usdt", "sui", "apt", "sol", "cetus", "afsui", "hasui"];
|
|
5
|
-
export declare const SUPPORT_COLLATERALS: readonly ["eth", "btc", "usdc", "usdt", "sui", "apt", "sol", "cetus", "afsui", "hasui"];
|
|
4
|
+
export declare const SUPPORT_POOLS: readonly ["eth", "btc", "usdc", "usdt", "sui", "apt", "sol", "cetus", "afsui", "hasui", "vsui"];
|
|
5
|
+
export declare const SUPPORT_COLLATERALS: readonly ["eth", "btc", "usdc", "usdt", "sui", "apt", "sol", "cetus", "afsui", "hasui", "vsui"];
|
|
6
6
|
export declare const SUPPORT_SPOOLS: readonly ["ssui", "susdc", "susdt"];
|
|
7
7
|
export declare const SUPPORT_REWARD_POOLS: readonly ["sui"];
|
|
8
8
|
export declare const SUPPORT_ORACLES: readonly ["supra", "switchboard", "pyth"];
|
package/dist/constants/enum.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { SupportCoinDecimals, AssetCoins, MarketCoins, StakeMarketCoins, RewardCoins, AssetCoinIds, WormholeCoinIds } from '../types';
|
|
1
|
+
import type { SupportCoinDecimals, AssetCoins, MarketCoins, StakeMarketCoins, RewardCoins, AssetCoinIds, WormholeCoinIds, VoloCoinIds } from '../types';
|
|
2
2
|
export declare const coinDecimals: SupportCoinDecimals;
|
|
3
3
|
export declare const assetCoins: AssetCoins;
|
|
4
4
|
export declare const marketCoins: MarketCoins;
|
|
@@ -6,3 +6,4 @@ export declare const stakeMarketCoins: StakeMarketCoins;
|
|
|
6
6
|
export declare const rewardCoins: RewardCoins;
|
|
7
7
|
export declare const coinIds: AssetCoinIds;
|
|
8
8
|
export declare const wormholeCoinIds: WormholeCoinIds;
|
|
9
|
+
export declare const voloCoinIds: VoloCoinIds;
|
package/dist/index.js
CHANGED
|
@@ -51,6 +51,7 @@ __export(src_exports, {
|
|
|
51
51
|
marketCoins: () => marketCoins,
|
|
52
52
|
rewardCoins: () => rewardCoins,
|
|
53
53
|
stakeMarketCoins: () => stakeMarketCoins,
|
|
54
|
+
voloCoinIds: () => voloCoinIds,
|
|
54
55
|
wormholeCoinIds: () => wormholeCoinIds
|
|
55
56
|
});
|
|
56
57
|
module.exports = __toCommonJS(src_exports);
|
|
@@ -69,7 +70,8 @@ var SUPPORT_POOLS = [
|
|
|
69
70
|
"sol",
|
|
70
71
|
"cetus",
|
|
71
72
|
"afsui",
|
|
72
|
-
"hasui"
|
|
73
|
+
"hasui",
|
|
74
|
+
"vsui"
|
|
73
75
|
];
|
|
74
76
|
var SUPPORT_COLLATERALS = [
|
|
75
77
|
"eth",
|
|
@@ -81,7 +83,8 @@ var SUPPORT_COLLATERALS = [
|
|
|
81
83
|
"sol",
|
|
82
84
|
"cetus",
|
|
83
85
|
"afsui",
|
|
84
|
-
"hasui"
|
|
86
|
+
"hasui",
|
|
87
|
+
"vsui"
|
|
85
88
|
];
|
|
86
89
|
var SUPPORT_SPOOLS = ["ssui", "susdc", "susdt"];
|
|
87
90
|
var SUPPORT_REWARD_POOLS = ["sui"];
|
|
@@ -113,6 +116,7 @@ var coinDecimals = {
|
|
|
113
116
|
cetus: 9,
|
|
114
117
|
afsui: 9,
|
|
115
118
|
hasui: 9,
|
|
119
|
+
vsui: 9,
|
|
116
120
|
seth: 8,
|
|
117
121
|
sbtc: 8,
|
|
118
122
|
susdc: 6,
|
|
@@ -122,7 +126,8 @@ var coinDecimals = {
|
|
|
122
126
|
ssol: 8,
|
|
123
127
|
scetus: 9,
|
|
124
128
|
safsui: 9,
|
|
125
|
-
shasui: 9
|
|
129
|
+
shasui: 9,
|
|
130
|
+
svsui: 9
|
|
126
131
|
};
|
|
127
132
|
var assetCoins = {
|
|
128
133
|
eth: "eth",
|
|
@@ -134,7 +139,8 @@ var assetCoins = {
|
|
|
134
139
|
sol: "sol",
|
|
135
140
|
cetus: "cetus",
|
|
136
141
|
afsui: "afsui",
|
|
137
|
-
hasui: "hasui"
|
|
142
|
+
hasui: "hasui",
|
|
143
|
+
vsui: "vsui"
|
|
138
144
|
};
|
|
139
145
|
var marketCoins = {
|
|
140
146
|
seth: "seth",
|
|
@@ -146,7 +152,8 @@ var marketCoins = {
|
|
|
146
152
|
ssol: "ssol",
|
|
147
153
|
scetus: "scetus",
|
|
148
154
|
safsui: "safsui",
|
|
149
|
-
shasui: "shasui"
|
|
155
|
+
shasui: "shasui",
|
|
156
|
+
svsui: "svsui"
|
|
150
157
|
};
|
|
151
158
|
var stakeMarketCoins = {
|
|
152
159
|
ssui: "ssui",
|
|
@@ -168,7 +175,8 @@ var coinIds = {
|
|
|
168
175
|
sol: "0xb7844e289a8410e50fb3ca48d69eb9cf29e27d223ef90353fe1bd8e27ff8f3f8",
|
|
169
176
|
cetus: "0x06864a6f921804860930db6ddbe2e16acdf8504495ea7481637a1c8b9a8fe54b",
|
|
170
177
|
afsui: "0xf325ce1300e8dac124071d3152c5c5ee6174914f8bc2161e88329cf579246efc",
|
|
171
|
-
hasui: "0xbde4ba4c2e274a60ce15c1cfff9e5c42e41654ac8b6d906a57efa4bd3c29f47d"
|
|
178
|
+
hasui: "0xbde4ba4c2e274a60ce15c1cfff9e5c42e41654ac8b6d906a57efa4bd3c29f47d",
|
|
179
|
+
vsui: "0x549e8b69270defbfafd4f94e17ec44cdbdd99820b33bda2278dea3b9a32d3f55"
|
|
172
180
|
};
|
|
173
181
|
var wormholeCoinIds = {
|
|
174
182
|
eth: "0xaf8cd5edc19c4512f4259f0bee101a40d41ebed738ade5874359610ef8eeced5",
|
|
@@ -178,6 +186,9 @@ var wormholeCoinIds = {
|
|
|
178
186
|
apt: "0x3a5143bb1196e3bcdfab6203d1683ae29edd26294fc8bfeafe4aaa9d2704df37",
|
|
179
187
|
sol: "0xb7844e289a8410e50fb3ca48d69eb9cf29e27d223ef90353fe1bd8e27ff8f3f8"
|
|
180
188
|
};
|
|
189
|
+
var voloCoinIds = {
|
|
190
|
+
vsui: "0x549e8b69270defbfafd4f94e17ec44cdbdd99820b33bda2278dea3b9a32d3f55"
|
|
191
|
+
};
|
|
181
192
|
|
|
182
193
|
// src/models/scallop.ts
|
|
183
194
|
var import_sui_kit8 = require("@scallop-io/sui-kit");
|
|
@@ -256,6 +267,45 @@ var EMPTY_ADDRESSES = {
|
|
|
256
267
|
feedObject: ""
|
|
257
268
|
}
|
|
258
269
|
}
|
|
270
|
+
},
|
|
271
|
+
afsui: {
|
|
272
|
+
id: "",
|
|
273
|
+
metaData: "",
|
|
274
|
+
treasury: "",
|
|
275
|
+
oracle: {
|
|
276
|
+
supra: "",
|
|
277
|
+
switchboard: "",
|
|
278
|
+
pyth: {
|
|
279
|
+
feed: "",
|
|
280
|
+
feedObject: ""
|
|
281
|
+
}
|
|
282
|
+
}
|
|
283
|
+
},
|
|
284
|
+
hasui: {
|
|
285
|
+
id: "",
|
|
286
|
+
metaData: "",
|
|
287
|
+
treasury: "",
|
|
288
|
+
oracle: {
|
|
289
|
+
supra: "",
|
|
290
|
+
switchboard: "",
|
|
291
|
+
pyth: {
|
|
292
|
+
feed: "",
|
|
293
|
+
feedObject: ""
|
|
294
|
+
}
|
|
295
|
+
}
|
|
296
|
+
},
|
|
297
|
+
vsui: {
|
|
298
|
+
id: "",
|
|
299
|
+
metaData: "",
|
|
300
|
+
treasury: "",
|
|
301
|
+
oracle: {
|
|
302
|
+
supra: "",
|
|
303
|
+
switchboard: "",
|
|
304
|
+
pyth: {
|
|
305
|
+
feed: "",
|
|
306
|
+
feedObject: ""
|
|
307
|
+
}
|
|
308
|
+
}
|
|
259
309
|
}
|
|
260
310
|
},
|
|
261
311
|
oracles: {
|
|
@@ -912,8 +962,8 @@ var minBigNumber = (...args) => {
|
|
|
912
962
|
|
|
913
963
|
// src/utils/util.ts
|
|
914
964
|
var isMarketCoin = (coinName) => {
|
|
915
|
-
const assetCoinName = coinName.slice(1);
|
|
916
|
-
return [
|
|
965
|
+
const assetCoinName = coinName.slice(1).toLowerCase();
|
|
966
|
+
return coinName.charAt(0).toLowerCase() === "s" && [
|
|
917
967
|
.../* @__PURE__ */ new Set([
|
|
918
968
|
...SUPPORT_POOLS,
|
|
919
969
|
...SUPPORT_COLLATERALS,
|
|
@@ -921,6 +971,18 @@ var isMarketCoin = (coinName) => {
|
|
|
921
971
|
])
|
|
922
972
|
].includes(assetCoinName);
|
|
923
973
|
};
|
|
974
|
+
var parseAssetSymbol = (coinName) => {
|
|
975
|
+
switch (coinName) {
|
|
976
|
+
case "afsui":
|
|
977
|
+
return "afSUI";
|
|
978
|
+
case "hasui":
|
|
979
|
+
return "haSUI";
|
|
980
|
+
case "vsui":
|
|
981
|
+
return "vSUI";
|
|
982
|
+
default:
|
|
983
|
+
return coinName.toUpperCase();
|
|
984
|
+
}
|
|
985
|
+
};
|
|
924
986
|
|
|
925
987
|
// src/queries/coreQuery.ts
|
|
926
988
|
var queryMarket = async (query) => {
|
|
@@ -2494,9 +2556,10 @@ var ScallopUtils = class {
|
|
|
2494
2556
|
*/
|
|
2495
2557
|
parseSymbol(coinName) {
|
|
2496
2558
|
if (isMarketCoin(coinName)) {
|
|
2497
|
-
|
|
2559
|
+
const assetCoinName = coinName.slice(1).toLowerCase();
|
|
2560
|
+
return coinName.slice(0, 1).toLowerCase() + parseAssetSymbol(assetCoinName);
|
|
2498
2561
|
} else {
|
|
2499
|
-
return coinName
|
|
2562
|
+
return parseAssetSymbol(coinName);
|
|
2500
2563
|
}
|
|
2501
2564
|
}
|
|
2502
2565
|
/**
|
|
@@ -2512,13 +2575,13 @@ var ScallopUtils = class {
|
|
|
2512
2575
|
*/
|
|
2513
2576
|
parseCoinType(coinName) {
|
|
2514
2577
|
coinName = isMarketCoin(coinName) ? this.parseCoinName(coinName) : coinName;
|
|
2515
|
-
const coinPackageId = this._address.get(`core.coins.${coinName}.id`)
|
|
2578
|
+
const coinPackageId = this._address.get(`core.coins.${coinName}.id`) || coinIds[coinName] || void 0;
|
|
2516
2579
|
if (!coinPackageId) {
|
|
2517
2580
|
throw Error(`Coin ${coinName} is not supported`);
|
|
2518
2581
|
}
|
|
2519
2582
|
if (coinName === "sui")
|
|
2520
2583
|
return (0, import_utils5.normalizeStructTag)(`${coinPackageId}::sui::SUI`);
|
|
2521
|
-
const
|
|
2584
|
+
const wormHolePckageIds = [
|
|
2522
2585
|
this._address.get("core.coins.usdc.id") ?? wormholeCoinIds.usdc,
|
|
2523
2586
|
this._address.get("core.coins.usdt.id") ?? wormholeCoinIds.usdt,
|
|
2524
2587
|
this._address.get("core.coins.eth.id") ?? wormholeCoinIds.eth,
|
|
@@ -2526,8 +2589,13 @@ var ScallopUtils = class {
|
|
|
2526
2589
|
this._address.get("core.coins.sol.id") ?? wormholeCoinIds.sol,
|
|
2527
2590
|
this._address.get("core.coins.apt.id") ?? wormholeCoinIds.apt
|
|
2528
2591
|
];
|
|
2529
|
-
|
|
2592
|
+
const voloPckageIds = [
|
|
2593
|
+
this._address.get("core.coins.vsui.id") ?? voloCoinIds.vsui
|
|
2594
|
+
];
|
|
2595
|
+
if (wormHolePckageIds.includes(coinPackageId)) {
|
|
2530
2596
|
return `${coinPackageId}::coin::COIN`;
|
|
2597
|
+
} else if (voloPckageIds.includes(coinPackageId)) {
|
|
2598
|
+
return `${coinPackageId}::cert::CERT`;
|
|
2531
2599
|
} else {
|
|
2532
2600
|
return `${coinPackageId}::${coinName}::${coinName.toUpperCase()}`;
|
|
2533
2601
|
}
|
|
@@ -2557,7 +2625,10 @@ var ScallopUtils = class {
|
|
|
2557
2625
|
[`${this._address.get("core.coins.sol.id") ?? wormholeCoinIds.sol}::coin::COIN`]: "sol",
|
|
2558
2626
|
[`${this._address.get("core.coins.apt.id") ?? wormholeCoinIds.apt}::coin::COIN`]: "apt"
|
|
2559
2627
|
};
|
|
2560
|
-
const
|
|
2628
|
+
const voloCoinTypeMap = {
|
|
2629
|
+
[`${this._address.get("core.coins.vsui.id") ?? voloCoinIds.vsui}::cert::CERT`]: "vsui"
|
|
2630
|
+
};
|
|
2631
|
+
const assetCoinName = wormHoleCoinTypeMap[coinType] || voloCoinTypeMap[coinType] || coinType.split("::")[2].toLowerCase();
|
|
2561
2632
|
return isMarketCoinType ? this.parseMarketCoinName(assetCoinName) : assetCoinName;
|
|
2562
2633
|
}
|
|
2563
2634
|
/**
|
|
@@ -2680,13 +2751,14 @@ var ScallopUtils = class {
|
|
|
2680
2751
|
);
|
|
2681
2752
|
try {
|
|
2682
2753
|
const priceFeeds = await pythConnection.getLatestPriceFeeds(priceIds) || [];
|
|
2683
|
-
for (const feed of priceFeeds) {
|
|
2754
|
+
for (const [index, feed] of priceFeeds.entries()) {
|
|
2684
2755
|
const data = parseDataFromPythPriceFeed(feed, this._address);
|
|
2685
|
-
|
|
2756
|
+
const coinName = lackPricesCoinNames[index];
|
|
2757
|
+
this._priceMap.set(coinName, {
|
|
2686
2758
|
price: data.price,
|
|
2687
2759
|
publishTime: data.publishTime
|
|
2688
2760
|
});
|
|
2689
|
-
coinPrices[
|
|
2761
|
+
coinPrices[coinName] = data.price;
|
|
2690
2762
|
}
|
|
2691
2763
|
} catch (_e) {
|
|
2692
2764
|
for (const coinName of lackPricesCoinNames) {
|
|
@@ -4022,6 +4094,7 @@ var Scallop = class {
|
|
|
4022
4094
|
marketCoins,
|
|
4023
4095
|
rewardCoins,
|
|
4024
4096
|
stakeMarketCoins,
|
|
4097
|
+
voloCoinIds,
|
|
4025
4098
|
wormholeCoinIds
|
|
4026
4099
|
});
|
|
4027
4100
|
//# sourceMappingURL=index.js.map
|