@scallop-io/sui-scallop-sdk 1.3.4 → 1.3.5-alpha.1
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 +3 -3
- package/dist/constants/enum.d.ts +2 -1
- package/dist/constants/tokenBucket.d.ts +1 -1
- package/dist/index.js +161 -84
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +160 -84
- package/dist/index.mjs.map +1 -1
- package/dist/models/scallopQuery.d.ts +41 -7
- package/dist/models/scallopUtils.d.ts +10 -3
- package/dist/queries/borrowIncentiveQuery.d.ts +2 -2
- package/dist/queries/coreQuery.d.ts +0 -2
- package/dist/queries/portfolioQuery.d.ts +0 -2
- package/dist/queries/priceQuery.d.ts +32 -2
- package/dist/queries/sCoinQuery.d.ts +1 -1
- package/dist/types/constant/common.d.ts +1 -1
- package/dist/types/utils.d.ts +2 -6
- package/package.json +1 -1
- package/src/constants/coinGecko.ts +3 -2
- package/src/constants/common.ts +10 -5
- package/src/constants/enum.ts +54 -31
- package/src/constants/poolAddress.ts +10 -7
- package/src/constants/pyth.ts +3 -2
- package/src/constants/tokenBucket.ts +1 -1
- package/src/models/scallopQuery.ts +14 -1
- package/src/models/scallopUtils.ts +14 -2
- package/src/queries/borrowIncentiveQuery.ts +30 -12
- package/src/queries/borrowLimitQuery.ts +3 -2
- package/src/queries/coreQuery.ts +4 -9
- package/src/queries/isolatedAssetQuery.ts +3 -2
- package/src/queries/portfolioQuery.ts +3 -6
- package/src/queries/priceQuery.ts +36 -2
- package/src/queries/sCoinQuery.ts +1 -1
- package/src/queries/spoolQuery.ts +2 -4
- package/src/queries/supplyLimitQuery.ts +3 -2
- package/src/types/constant/common.ts +1 -2
- package/src/types/utils.ts +2 -10
- package/src/utils/query.ts +0 -87
package/dist/index.mjs
CHANGED
|
@@ -23,9 +23,10 @@ var COIN_GECKGO_IDS = {
|
|
|
23
23
|
afsui: "sui",
|
|
24
24
|
hasui: "sui",
|
|
25
25
|
vsui: "sui",
|
|
26
|
-
sca: "scallop-2"
|
|
27
|
-
|
|
28
|
-
|
|
26
|
+
sca: "scallop-2"
|
|
27
|
+
// TODO: enable for production
|
|
28
|
+
// deep: 'deepbook',
|
|
29
|
+
// fud: 'fud-the-pug',
|
|
29
30
|
};
|
|
30
31
|
|
|
31
32
|
// src/constants/common.ts
|
|
@@ -54,9 +55,10 @@ var SUPPORT_POOLS = [
|
|
|
54
55
|
"afsui",
|
|
55
56
|
"hasui",
|
|
56
57
|
"vsui",
|
|
57
|
-
"sca"
|
|
58
|
-
|
|
59
|
-
|
|
58
|
+
"sca"
|
|
59
|
+
// TODO: enable for production
|
|
60
|
+
// 'fud',
|
|
61
|
+
// 'deep',
|
|
60
62
|
];
|
|
61
63
|
var SUPPORT_COLLATERALS = [
|
|
62
64
|
"usdc",
|
|
@@ -100,9 +102,10 @@ var SUPPORT_SCOIN = [
|
|
|
100
102
|
"ssca",
|
|
101
103
|
"scetus",
|
|
102
104
|
"swsol",
|
|
103
|
-
"swbtc"
|
|
104
|
-
|
|
105
|
-
|
|
105
|
+
"swbtc"
|
|
106
|
+
// TODO: enable for production
|
|
107
|
+
// 'sdeep',
|
|
108
|
+
// 'sfud',
|
|
106
109
|
];
|
|
107
110
|
var SUPPORT_SUI_BRIDGE = ["sbeth"];
|
|
108
111
|
var SUPPORT_WORMHOLE = [
|
|
@@ -126,7 +129,10 @@ var SUPPORT_BORROW_INCENTIVE_POOLS = [
|
|
|
126
129
|
"sca",
|
|
127
130
|
"usdc"
|
|
128
131
|
];
|
|
129
|
-
var SUPPORT_BORROW_INCENTIVE_REWARDS = [
|
|
132
|
+
var SUPPORT_BORROW_INCENTIVE_REWARDS = [
|
|
133
|
+
...SUPPORT_POOLS,
|
|
134
|
+
...SUPPORT_SCOIN
|
|
135
|
+
];
|
|
130
136
|
var SUPPORT_ORACLES = ["supra", "switchboard", "pyth"];
|
|
131
137
|
var SUPPORT_PACKAGES = [
|
|
132
138
|
"coinDecimalsRegistry",
|
|
@@ -159,8 +165,9 @@ var coinDecimals = {
|
|
|
159
165
|
hasui: 9,
|
|
160
166
|
vsui: 9,
|
|
161
167
|
sca: 9,
|
|
162
|
-
|
|
163
|
-
|
|
168
|
+
// TODO: enable for production
|
|
169
|
+
// deep: 6,
|
|
170
|
+
// fud: 5,
|
|
164
171
|
susdc: 6,
|
|
165
172
|
sweth: 8,
|
|
166
173
|
ssbeth: 8,
|
|
@@ -174,9 +181,10 @@ var coinDecimals = {
|
|
|
174
181
|
safsui: 9,
|
|
175
182
|
shasui: 9,
|
|
176
183
|
svsui: 9,
|
|
177
|
-
ssca: 9
|
|
178
|
-
|
|
179
|
-
|
|
184
|
+
ssca: 9
|
|
185
|
+
// TODO: enable for production
|
|
186
|
+
// sdeep: 6,
|
|
187
|
+
// sfud: 5,
|
|
180
188
|
};
|
|
181
189
|
var assetCoins = {
|
|
182
190
|
usdc: "usdc",
|
|
@@ -192,9 +200,10 @@ var assetCoins = {
|
|
|
192
200
|
afsui: "afsui",
|
|
193
201
|
hasui: "hasui",
|
|
194
202
|
vsui: "vsui",
|
|
195
|
-
sca: "sca"
|
|
196
|
-
|
|
197
|
-
|
|
203
|
+
sca: "sca"
|
|
204
|
+
// TODO: enable for production
|
|
205
|
+
// deep: 'deep',
|
|
206
|
+
// fud: 'fud',
|
|
198
207
|
};
|
|
199
208
|
var marketCoins = {
|
|
200
209
|
susdc: "susdc",
|
|
@@ -210,9 +219,10 @@ var marketCoins = {
|
|
|
210
219
|
safsui: "safsui",
|
|
211
220
|
shasui: "shasui",
|
|
212
221
|
svsui: "svsui",
|
|
213
|
-
ssca: "ssca"
|
|
214
|
-
|
|
215
|
-
|
|
222
|
+
ssca: "ssca"
|
|
223
|
+
// TODO: enable for production
|
|
224
|
+
// sdeep: 'sdeep',
|
|
225
|
+
// sfud: 'sfud',
|
|
216
226
|
};
|
|
217
227
|
var sCoins = {
|
|
218
228
|
susdc: "susdc",
|
|
@@ -227,9 +237,10 @@ var sCoins = {
|
|
|
227
237
|
svsui: "svsui",
|
|
228
238
|
ssca: "ssca",
|
|
229
239
|
swsol: "swsol",
|
|
230
|
-
swbtc: "swbtc"
|
|
231
|
-
|
|
232
|
-
|
|
240
|
+
swbtc: "swbtc"
|
|
241
|
+
// TODO: enable for production
|
|
242
|
+
// sfud: 'sfud',
|
|
243
|
+
// sdeep: 'sdeep',
|
|
233
244
|
};
|
|
234
245
|
var stakeMarketCoins = {
|
|
235
246
|
susdc: "susdc",
|
|
@@ -257,16 +268,16 @@ var suiBridgeCoins = {
|
|
|
257
268
|
sbeth: "sbeth"
|
|
258
269
|
};
|
|
259
270
|
var borrowIncentiveRewardCoins = {
|
|
260
|
-
usdc: ["
|
|
261
|
-
sui: ["
|
|
262
|
-
wusdc: ["
|
|
263
|
-
wusdt: ["
|
|
264
|
-
sca: ["
|
|
265
|
-
afsui: ["
|
|
266
|
-
hasui: ["
|
|
267
|
-
vsui: ["
|
|
268
|
-
weth: ["
|
|
269
|
-
sbeth: ["
|
|
271
|
+
usdc: ["ssui", "ssca"],
|
|
272
|
+
sui: ["ssui", "ssca"],
|
|
273
|
+
wusdc: ["ssui", "ssca"],
|
|
274
|
+
wusdt: ["ssui", "ssca"],
|
|
275
|
+
sca: ["ssui", "ssca"],
|
|
276
|
+
afsui: ["ssui"],
|
|
277
|
+
hasui: ["ssui"],
|
|
278
|
+
vsui: ["ssui"],
|
|
279
|
+
weth: ["ssui"],
|
|
280
|
+
sbeth: ["ssui"]
|
|
270
281
|
};
|
|
271
282
|
var coinIds = {
|
|
272
283
|
usdc: "0xdba34672e30cb065b1f93e3ab55318768fd6fef66c15942c9f7cb846e2f900e7",
|
|
@@ -282,10 +293,10 @@ var coinIds = {
|
|
|
282
293
|
afsui: "0xf325ce1300e8dac124071d3152c5c5ee6174914f8bc2161e88329cf579246efc",
|
|
283
294
|
hasui: "0xbde4ba4c2e274a60ce15c1cfff9e5c42e41654ac8b6d906a57efa4bd3c29f47d",
|
|
284
295
|
vsui: "0x549e8b69270defbfafd4f94e17ec44cdbdd99820b33bda2278dea3b9a32d3f55",
|
|
285
|
-
sca: IS_VE_SCA_TEST ? "0x6cd813061a3adf3602b76545f076205f0c8e7ec1d3b1eab9a1da7992c18c0524" : "0x7016aae72cfc67f2fadf55769c0a7dd54291a583b63051a5ed71081cce836ac6"
|
|
296
|
+
sca: IS_VE_SCA_TEST ? "0x6cd813061a3adf3602b76545f076205f0c8e7ec1d3b1eab9a1da7992c18c0524" : "0x7016aae72cfc67f2fadf55769c0a7dd54291a583b63051a5ed71081cce836ac6"
|
|
286
297
|
// isolated assets
|
|
287
|
-
deep:
|
|
288
|
-
fud:
|
|
298
|
+
// deep: '0xdeeb7a4662eec9f2f3def03fb937a663dddaa2e215b8078a284d026b7946c270',
|
|
299
|
+
// fud: '0x76cb819b01abed502bee8a702b4c2d547532c12f25001c9dea795a5e631c26f1',
|
|
289
300
|
};
|
|
290
301
|
var wormholeCoinIds = {
|
|
291
302
|
weth: "0xaf8cd5edc19c4512f4259f0bee101a40d41ebed738ade5874359610ef8eeced5",
|
|
@@ -301,19 +312,28 @@ var voloCoinIds = {
|
|
|
301
312
|
var sCoinIds = {
|
|
302
313
|
susdc: "0x854950aa624b1df59fe64e630b2ba7c550642e9342267a33061d59fb31582da5::scallop_usdc::SCALLOP_USDC",
|
|
303
314
|
ssbeth: "0xb14f82d8506d139eacef109688d1b71e7236bcce9b2c0ad526abcd6aa5be7de0::scallop_sb_eth::SCALLOP_SB_ETH",
|
|
304
|
-
|
|
315
|
+
// prod values
|
|
316
|
+
// ssui: '0xaafc4f740de0dd0dde642a31148fb94517087052f19afb0f7bed1dc41a50c77b::scallop_sui::SCALLOP_SUI',
|
|
317
|
+
// swusdc:
|
|
318
|
+
// '0xad4d71551d31092230db1fd482008ea42867dbf27b286e9c70a79d2a6191d58d::scallop_wormhole_usdc::SCALLOP_WORMHOLE_USDC',
|
|
319
|
+
// swusdt:
|
|
320
|
+
// '0xe6e5a012ec20a49a3d1d57bd2b67140b96cd4d3400b9d79e541f7bdbab661f95::scallop_wormhole_usdt::SCALLOP_WORMHOLE_USDT',
|
|
321
|
+
// ssca: '0x5ca17430c1d046fae9edeaa8fd76c7b4193a00d764a0ecfa9418d733ad27bc1e::scallop_sca::SCALLOP_SCA',
|
|
322
|
+
// test values
|
|
323
|
+
ssui: "0xf569919046f19a0c40b519ecfbb6ca0319698cd5908716c29b62ef56541f298b::scallop_sui::SCALLOP_SUI",
|
|
324
|
+
swusdt: "0xac781d9f73058ff5e69f9bf8dde32f2e8c71c66d7fe8497fc83b2d9182254b22::scallop_wormhole_usdt::SCALLOP_WORMHOLE_USDT",
|
|
325
|
+
swusdc: "0xf5447c4305a486d8c8557559887c2c39449ddb5e748f15d33946d02a1663c158::scallop_wormhole_usdc::SCALLOP_WORMHOLE_USDC",
|
|
326
|
+
ssca: "0x958428555e778e55918a59eb1c92c77f32b5c554fa3a5e56cd0815086b5072e7::scallop_sca::SCALLOP_SCA",
|
|
305
327
|
scetus: "0xea346ce428f91ab007210443efcea5f5cdbbb3aae7e9affc0ca93f9203c31f0c::scallop_cetus::SCALLOP_CETUS",
|
|
306
|
-
ssca: "0x5ca17430c1d046fae9edeaa8fd76c7b4193a00d764a0ecfa9418d733ad27bc1e::scallop_sca::SCALLOP_SCA",
|
|
307
|
-
swusdc: "0xad4d71551d31092230db1fd482008ea42867dbf27b286e9c70a79d2a6191d58d::scallop_wormhole_usdc::SCALLOP_WORMHOLE_USDC",
|
|
308
|
-
swusdt: "0xe6e5a012ec20a49a3d1d57bd2b67140b96cd4d3400b9d79e541f7bdbab661f95::scallop_wormhole_usdt::SCALLOP_WORMHOLE_USDT",
|
|
309
328
|
sweth: "0x67540ceb850d418679e69f1fb6b2093d6df78a2a699ffc733f7646096d552e9b::scallop_wormhole_eth::SCALLOP_WORMHOLE_ETH",
|
|
310
329
|
safsui: "0x00671b1fa2a124f5be8bdae8b91ee711462c5d9e31bda232e70fd9607b523c88::scallop_af_sui::SCALLOP_AF_SUI",
|
|
311
330
|
shasui: "0x9a2376943f7d22f88087c259c5889925f332ca4347e669dc37d54c2bf651af3c::scallop_ha_sui::SCALLOP_HA_SUI",
|
|
312
331
|
svsui: "0xe1a1cc6bcf0001a015eab84bcc6713393ce20535f55b8b6f35c142e057a25fbe::scallop_v_sui::SCALLOP_V_SUI",
|
|
313
332
|
swsol: "0x1392650f2eca9e3f6ffae3ff89e42a3590d7102b80e2b430f674730bc30d3259::scallop_wormhole_sol::SCALLOP_WORMHOLE_SOL",
|
|
314
|
-
swbtc: "0x2cf76a9cf5d3337961d1154283234f94da2dcff18544dfe5cbdef65f319591b5::scallop_wormhole_btc::SCALLOP_WORMHOLE_BTC"
|
|
315
|
-
sdeep:
|
|
316
|
-
|
|
333
|
+
swbtc: "0x2cf76a9cf5d3337961d1154283234f94da2dcff18544dfe5cbdef65f319591b5::scallop_wormhole_btc::SCALLOP_WORMHOLE_BTC"
|
|
334
|
+
// sdeep:
|
|
335
|
+
// '0xeb7a05a3224837c5e5503575aed0be73c091d1ce5e43aa3c3e716e0ae614608f::scallop_deep::SCALLOP_DEEP',
|
|
336
|
+
// sfud: '0xe56d5167f427cbe597da9e8150ef5c337839aaf46891d62468dcf80bdd8e10d1::scallop_fud::SCALLOP_FUD',
|
|
317
337
|
};
|
|
318
338
|
var sCoinTypeToName = Object.entries(sCoinIds).reduce(
|
|
319
339
|
(acc, [coinName, coinType]) => {
|
|
@@ -322,6 +342,13 @@ var sCoinTypeToName = Object.entries(sCoinIds).reduce(
|
|
|
322
342
|
},
|
|
323
343
|
{}
|
|
324
344
|
);
|
|
345
|
+
var sCoinRawNameToName = Object.entries(sCoinIds).reduce(
|
|
346
|
+
(acc, [coinName, coinType]) => {
|
|
347
|
+
acc[coinType.split("::")[2].toLowerCase()] = coinName;
|
|
348
|
+
return acc;
|
|
349
|
+
},
|
|
350
|
+
{}
|
|
351
|
+
);
|
|
325
352
|
|
|
326
353
|
// src/constants/flashloan.ts
|
|
327
354
|
var FlashLoanFeeObjectMap = {
|
|
@@ -396,13 +423,16 @@ var POOL_ADDRESSES = {
|
|
|
396
423
|
sca: {
|
|
397
424
|
lendingPoolAddress: "0x6fc7d4211fc7018b6c75e7b908b88f2e0536443239804a3d32af547637bd28d7",
|
|
398
425
|
collateralPoolAddress: "0xff677a5d9e9dc8f08f0a8681ebfc7481d1c7d57bc441f2881974adcdd7b13c31"
|
|
399
|
-
},
|
|
400
|
-
fud: {
|
|
401
|
-
lendingPoolAddress: ""
|
|
402
|
-
},
|
|
403
|
-
deep: {
|
|
404
|
-
lendingPoolAddress: ""
|
|
405
426
|
}
|
|
427
|
+
// TODO: enable for production
|
|
428
|
+
// fud: {
|
|
429
|
+
// lendingPoolAddress:
|
|
430
|
+
// '0x14367ddca30e2860cb89ed4eaca20c7ece260c5d59dd9990d2c85a8321326acb',
|
|
431
|
+
// },
|
|
432
|
+
// deep: {
|
|
433
|
+
// lendingPoolAddress:
|
|
434
|
+
// '0xf4a67ffb43da1e1c61c049f188f19463ea8dbbf2d5ef4722d6df854ff1b1cc03',
|
|
435
|
+
// },
|
|
406
436
|
};
|
|
407
437
|
|
|
408
438
|
// src/constants/pyth.ts
|
|
@@ -424,9 +454,10 @@ var PYTH_FEED_IDS = {
|
|
|
424
454
|
afsui: "23d7315113f5b1d3ba7a83604c44b94d79f4fd69af77f804fc7f920a6dc65744",
|
|
425
455
|
hasui: "23d7315113f5b1d3ba7a83604c44b94d79f4fd69af77f804fc7f920a6dc65744",
|
|
426
456
|
vsui: "23d7315113f5b1d3ba7a83604c44b94d79f4fd69af77f804fc7f920a6dc65744",
|
|
427
|
-
sca: "7e17f0ac105abe9214deb9944c30264f5986bf292869c6bd8e8da3ccd92d79bc"
|
|
428
|
-
|
|
429
|
-
|
|
457
|
+
sca: "7e17f0ac105abe9214deb9944c30264f5986bf292869c6bd8e8da3ccd92d79bc"
|
|
458
|
+
// TODO: enable for production
|
|
459
|
+
// deep: '29bdd5248234e33bd93d3b81100b5fa32eaa5997843847e2c2cb16d7c6d9f7ff',
|
|
460
|
+
// fud: '6a4090703da959247727f2b490eb21aea95c8684ecfac675f432008830890c75',
|
|
430
461
|
};
|
|
431
462
|
|
|
432
463
|
// src/constants/queryKeys.ts
|
|
@@ -951,7 +982,7 @@ var TEST_ADDRESSES = {
|
|
|
951
982
|
};
|
|
952
983
|
|
|
953
984
|
// src/constants/tokenBucket.ts
|
|
954
|
-
var DEFAULT_TOKENS_PER_INTERVAL =
|
|
985
|
+
var DEFAULT_TOKENS_PER_INTERVAL = 50;
|
|
955
986
|
var DEFAULT_INTERVAL_IN_MS = 300;
|
|
956
987
|
|
|
957
988
|
// src/constants/vesca.ts
|
|
@@ -2466,15 +2497,22 @@ var queryBorrowIncentivePools = async (address) => {
|
|
|
2466
2497
|
};
|
|
2467
2498
|
var getBorrowIncentivePools = async (query, borrowIncentiveCoinNames = [
|
|
2468
2499
|
...SUPPORT_BORROW_INCENTIVE_POOLS
|
|
2469
|
-
], indexer = false, coinPrices) => {
|
|
2500
|
+
], indexer = false, marketPools, coinPrices) => {
|
|
2470
2501
|
const borrowIncentivePools = {};
|
|
2471
|
-
|
|
2502
|
+
marketPools = marketPools ?? await query.getMarketPools(void 0, false, { coinPrices });
|
|
2503
|
+
coinPrices = coinPrices ?? await query.getAllCoinPrices({ marketPools });
|
|
2504
|
+
console.log({ coinPrices });
|
|
2472
2505
|
if (indexer) {
|
|
2473
2506
|
const borrowIncentivePoolsIndexer = await query.indexer.getBorrowIncentivePools();
|
|
2474
2507
|
const updateBorrowIncentivePool = (pool) => {
|
|
2475
2508
|
if (!borrowIncentiveCoinNames.includes(pool.coinName))
|
|
2476
2509
|
return;
|
|
2477
|
-
pool.coinPrice = coinPrices[pool.coinName]
|
|
2510
|
+
pool.coinPrice = coinPrices[pool.coinName] || pool.coinPrice;
|
|
2511
|
+
for (const sCoinName of SUPPORT_BORROW_INCENTIVE_REWARDS) {
|
|
2512
|
+
if (pool.points[sCoinName]) {
|
|
2513
|
+
pool.points[sCoinName].coinPrice = coinPrices[sCoinName] ?? pool.points[sCoinName].coinPrice;
|
|
2514
|
+
}
|
|
2515
|
+
}
|
|
2478
2516
|
borrowIncentivePools[pool.coinName] = pool;
|
|
2479
2517
|
};
|
|
2480
2518
|
Object.values(borrowIncentivePoolsIndexer).forEach(
|
|
@@ -2500,12 +2538,15 @@ var getBorrowIncentivePools = async (query, borrowIncentiveCoinNames = [
|
|
|
2500
2538
|
for (const [coinName, poolPoint] of Object.entries(
|
|
2501
2539
|
parsedBorrowIncentivePoolData.poolPoints
|
|
2502
2540
|
)) {
|
|
2503
|
-
const rewardCoinType =
|
|
2504
|
-
|
|
2541
|
+
const rewardCoinType = poolPoint.pointType;
|
|
2542
|
+
let rewardCoinName = query.utils.parseCoinNameFromType(
|
|
2505
2543
|
rewardCoinType
|
|
2506
2544
|
);
|
|
2507
|
-
|
|
2545
|
+
if (sCoinRawNameToName[rewardCoinName]) {
|
|
2546
|
+
rewardCoinName = sCoinRawNameToName[rewardCoinName];
|
|
2547
|
+
}
|
|
2508
2548
|
const rewardCoinDecimal = query.utils.getCoinDecimal(rewardCoinName);
|
|
2549
|
+
const rewardCoinPrice = coinPrices?.[rewardCoinName] ?? 0;
|
|
2509
2550
|
const symbol = query.utils.parseSymbol(rewardCoinName);
|
|
2510
2551
|
const coinDecimal = query.utils.getCoinDecimal(rewardCoinName);
|
|
2511
2552
|
const calculatedPoolPoint = calculateBorrowIncentivePoolPointData(
|
|
@@ -2651,7 +2692,7 @@ var supplyLimitZod = zod.object({
|
|
|
2651
2692
|
value: zod.string()
|
|
2652
2693
|
})
|
|
2653
2694
|
});
|
|
2654
|
-
var supplyLimitKeyType = `
|
|
2695
|
+
var supplyLimitKeyType = `0x6c23585e940a989588432509107e98bae06dbca4e333f26d0635d401b3c7c76d::market_dynamic_keys::SupplyLimitKey`;
|
|
2655
2696
|
var getSupplyLimit = async (utils, poolName) => {
|
|
2656
2697
|
try {
|
|
2657
2698
|
const poolCoinType = utils.parseCoinType(poolName).slice(2);
|
|
@@ -2691,7 +2732,7 @@ var isolatedAssetZod = zod2.object({
|
|
|
2691
2732
|
value: zod2.boolean()
|
|
2692
2733
|
})
|
|
2693
2734
|
});
|
|
2694
|
-
var isolatedAssetKeyType = `
|
|
2735
|
+
var isolatedAssetKeyType = `0x6c23585e940a989588432509107e98bae06dbca4e333f26d0635d401b3c7c76d::market_dynamic_keys::IsolatedAssetKey`;
|
|
2695
2736
|
var getIsolatedAssets = async (address) => {
|
|
2696
2737
|
try {
|
|
2697
2738
|
const marketObject = address.get("core.market");
|
|
@@ -2771,7 +2812,7 @@ var borrowLimitZod = zod3.object({
|
|
|
2771
2812
|
value: zod3.string()
|
|
2772
2813
|
})
|
|
2773
2814
|
});
|
|
2774
|
-
var borrowLimitKeyType = `
|
|
2815
|
+
var borrowLimitKeyType = `0xb784ea287d944e478a3ceaa071f8885072cce6b7224cf245914dc2f9963f460e::market_dynamic_keys::BorrowLimitKey`;
|
|
2775
2816
|
var getBorrowLimit = async (utils, poolName) => {
|
|
2776
2817
|
try {
|
|
2777
2818
|
const poolCoinType = utils.parseCoinType(poolName).slice(2);
|
|
@@ -2938,7 +2979,7 @@ var getMarketPools = async (query, poolCoinNames = [...SUPPORT_POOLS], indexer =
|
|
|
2938
2979
|
const marketObjectResponse = await query.cache.queryGetObject(marketId, {
|
|
2939
2980
|
showContent: true
|
|
2940
2981
|
});
|
|
2941
|
-
coinPrices = await query.utils.getCoinPrices(
|
|
2982
|
+
coinPrices = coinPrices ?? await query.utils.getCoinPrices();
|
|
2942
2983
|
const marketPools = {};
|
|
2943
2984
|
if (indexer) {
|
|
2944
2985
|
const marketPoolsIndexer = await query.indexer.getMarketPools();
|
|
@@ -2972,7 +3013,7 @@ var getMarketPools = async (query, poolCoinNames = [...SUPPORT_POOLS], indexer =
|
|
|
2972
3013
|
};
|
|
2973
3014
|
var getMarketPool = async (query, poolCoinName, indexer = false, marketObject, coinPrice) => {
|
|
2974
3015
|
try {
|
|
2975
|
-
coinPrice = coinPrice
|
|
3016
|
+
coinPrice = coinPrice ?? (await query.utils.getCoinPrices())?.[poolCoinName];
|
|
2976
3017
|
if (indexer) {
|
|
2977
3018
|
const marketPoolIndexer = await query.indexer.getMarketPool(poolCoinName);
|
|
2978
3019
|
if (!marketPoolIndexer) {
|
|
@@ -3118,7 +3159,7 @@ var getMarketPool = async (query, poolCoinName, indexer = false, marketObject, c
|
|
|
3118
3159
|
};
|
|
3119
3160
|
var getMarketCollaterals = async (query, collateralCoinNames = [...SUPPORT_COLLATERALS], indexer = false) => {
|
|
3120
3161
|
const marketId = query.address.get("core.market");
|
|
3121
|
-
const coinPrices = await query.utils.getCoinPrices(
|
|
3162
|
+
const coinPrices = await query.utils.getCoinPrices() ?? {};
|
|
3122
3163
|
const marketCollaterals = {};
|
|
3123
3164
|
if (indexer) {
|
|
3124
3165
|
const marketCollateralsIndexer = await query.indexer.getMarketCollaterals();
|
|
@@ -3154,7 +3195,7 @@ var getMarketCollaterals = async (query, collateralCoinNames = [...SUPPORT_COLLA
|
|
|
3154
3195
|
return marketCollaterals;
|
|
3155
3196
|
};
|
|
3156
3197
|
var getMarketCollateral = async (query, collateralCoinName, indexer = false, marketObject, coinPrice) => {
|
|
3157
|
-
coinPrice = coinPrice
|
|
3198
|
+
coinPrice = coinPrice ?? (await query.utils.getCoinPrices())?.[collateralCoinName];
|
|
3158
3199
|
if (indexer) {
|
|
3159
3200
|
const marketCollateralIndexer = await query.indexer.getMarketCollateral(collateralCoinName);
|
|
3160
3201
|
marketCollateralIndexer.coinPrice = coinPrice ?? marketCollateralIndexer.coinPrice;
|
|
@@ -3470,7 +3511,7 @@ var getLendings = async (query, poolCoinNames = [...SUPPORT_POOLS], ownerAddress
|
|
|
3470
3511
|
const stakeMarketCoinNames = marketCoinNames.filter(
|
|
3471
3512
|
(marketCoinName) => SUPPORT_SPOOLS.includes(marketCoinName)
|
|
3472
3513
|
);
|
|
3473
|
-
const coinPrices = await query.utils.getCoinPrices(
|
|
3514
|
+
const coinPrices = await query.utils.getCoinPrices();
|
|
3474
3515
|
const marketPools = await query.getMarketPools(poolCoinNames, indexer, {
|
|
3475
3516
|
coinPrices
|
|
3476
3517
|
});
|
|
@@ -3508,7 +3549,7 @@ var getLendings = async (query, poolCoinNames = [...SUPPORT_POOLS], ownerAddress
|
|
|
3508
3549
|
};
|
|
3509
3550
|
var getLending = async (query, poolCoinName, ownerAddress, indexer = false, marketPool, spool, stakeAccounts, coinAmount, marketCoinAmount, coinPrice, sCoinAmount) => {
|
|
3510
3551
|
const marketCoinName = query.utils.parseMarketCoinName(poolCoinName);
|
|
3511
|
-
coinPrice = coinPrice ?? (await query.utils.getCoinPrices(
|
|
3552
|
+
coinPrice = coinPrice ?? (await query.utils.getCoinPrices())?.[poolCoinName] ?? 0;
|
|
3512
3553
|
marketPool = marketPool ?? await query.getMarketPool(poolCoinName, indexer, {
|
|
3513
3554
|
coinPrice
|
|
3514
3555
|
});
|
|
@@ -3668,7 +3709,7 @@ var getObligationAccount = async (query, obligationId, ownerAddress, indexer = f
|
|
|
3668
3709
|
const collateralAssetCoinNames = [
|
|
3669
3710
|
...SUPPORT_COLLATERALS
|
|
3670
3711
|
];
|
|
3671
|
-
coinPrices = coinPrices ?? await query.utils.getCoinPrices(
|
|
3712
|
+
coinPrices = coinPrices ?? await query.utils.getCoinPrices();
|
|
3672
3713
|
market = market ?? await query.queryMarket(indexer, { coinPrices });
|
|
3673
3714
|
coinAmounts = coinAmounts || await query.getCoinAmounts(collateralAssetCoinNames, ownerAddress);
|
|
3674
3715
|
const [obligationQuery, borrowIncentivePools, borrowIncentiveAccounts] = await Promise.all([
|
|
@@ -3991,6 +4032,7 @@ var getTotalValueLocked = async (query, indexer = false) => {
|
|
|
3991
4032
|
};
|
|
3992
4033
|
|
|
3993
4034
|
// src/queries/priceQuery.ts
|
|
4035
|
+
import BigNumber6 from "bignumber.js";
|
|
3994
4036
|
var getPythPrice = async ({
|
|
3995
4037
|
address
|
|
3996
4038
|
}, assetCoinName, priceFeedObject) => {
|
|
@@ -4072,6 +4114,22 @@ var getPythPrices = async ({
|
|
|
4072
4114
|
{}
|
|
4073
4115
|
);
|
|
4074
4116
|
};
|
|
4117
|
+
var getAllCoinPrices = async (query, marketPools, coinPrices) => {
|
|
4118
|
+
coinPrices = coinPrices ?? await query.utils.getCoinPrices();
|
|
4119
|
+
marketPools = marketPools ?? await query.getMarketPools(void 0, void 0, { coinPrices });
|
|
4120
|
+
if (!marketPools) {
|
|
4121
|
+
throw new Error(`Failed to fetch market pool for getAllCoinPrices`);
|
|
4122
|
+
}
|
|
4123
|
+
const sCoinPrices = {};
|
|
4124
|
+
SUPPORT_SCOIN.forEach((sCoinName) => {
|
|
4125
|
+
const coinName = query.utils.parseCoinName(sCoinName);
|
|
4126
|
+
sCoinPrices[sCoinName] = BigNumber6(coinPrices[coinName] ?? 0).multipliedBy(marketPools[coinName]?.conversionRate ?? 1).toNumber();
|
|
4127
|
+
});
|
|
4128
|
+
return {
|
|
4129
|
+
...coinPrices,
|
|
4130
|
+
...sCoinPrices
|
|
4131
|
+
};
|
|
4132
|
+
};
|
|
4075
4133
|
|
|
4076
4134
|
// src/queries/referralQuery.ts
|
|
4077
4135
|
var queryVeScaKeyIdFromReferralBindings = async (address, refereeAddress) => {
|
|
@@ -4092,7 +4150,7 @@ var queryVeScaKeyIdFromReferralBindings = async (address, refereeAddress) => {
|
|
|
4092
4150
|
// src/queries/sCoinQuery.ts
|
|
4093
4151
|
import { bcs } from "@mysten/sui/bcs";
|
|
4094
4152
|
import assert from "assert";
|
|
4095
|
-
import
|
|
4153
|
+
import BigNumber7 from "bignumber.js";
|
|
4096
4154
|
var getSCoinTotalSupply = async ({
|
|
4097
4155
|
utils
|
|
4098
4156
|
}, sCoinName) => {
|
|
@@ -4113,7 +4171,7 @@ var getSCoinTotalSupply = async ({
|
|
|
4113
4171
|
const value = Uint8Array.from(results[0].returnValues[0][0]);
|
|
4114
4172
|
const type = results[0].returnValues[0][1];
|
|
4115
4173
|
assert(type === "u64", "Result type is not u64");
|
|
4116
|
-
return
|
|
4174
|
+
return BigNumber7(bcs.u64().parse(value)).shiftedBy(utils.getCoinDecimal(utils.parseCoinName(sCoinName))).toNumber();
|
|
4117
4175
|
}
|
|
4118
4176
|
return 0;
|
|
4119
4177
|
};
|
|
@@ -4139,7 +4197,7 @@ var getSCoinAmount = async ({
|
|
|
4139
4197
|
owner,
|
|
4140
4198
|
coinType: sCoinType
|
|
4141
4199
|
});
|
|
4142
|
-
return
|
|
4200
|
+
return BigNumber7(amount).toNumber();
|
|
4143
4201
|
};
|
|
4144
4202
|
var isSupportStakeCoins = (value) => {
|
|
4145
4203
|
return SUPPORT_SCOIN.includes(value);
|
|
@@ -4169,7 +4227,7 @@ var getSCoinSwapRate = async (query, fromSCoin, toSCoin, underlyingCoinPrice) =>
|
|
|
4169
4227
|
const ScoinAToARate = marketPools[0].conversionRate;
|
|
4170
4228
|
const BtoSCoinBRate = 1 / marketPools[1].conversionRate;
|
|
4171
4229
|
const calcAtoBRate = async () => {
|
|
4172
|
-
const prices = await query.utils.getCoinPrices(
|
|
4230
|
+
const prices = await query.utils.getCoinPrices();
|
|
4173
4231
|
if (!prices[fromCoinName] || !prices[toCoinName]) {
|
|
4174
4232
|
throw new Error("Failed to fetch the coin prices");
|
|
4175
4233
|
}
|
|
@@ -4179,7 +4237,7 @@ var getSCoinSwapRate = async (query, fromSCoin, toSCoin, underlyingCoinPrice) =>
|
|
|
4179
4237
|
return prices[fromCoinName] / prices[toCoinName];
|
|
4180
4238
|
};
|
|
4181
4239
|
const AtoBRate = underlyingCoinPrice ?? await calcAtoBRate();
|
|
4182
|
-
return
|
|
4240
|
+
return BigNumber7(ScoinAToARate).multipliedBy(AtoBRate).multipliedBy(BtoSCoinBRate).toNumber();
|
|
4183
4241
|
};
|
|
4184
4242
|
|
|
4185
4243
|
// src/queries/spoolQuery.ts
|
|
@@ -4239,7 +4297,7 @@ var getSpool = async (query, marketCoinName, indexer = false, marketPool, coinPr
|
|
|
4239
4297
|
`spool.pools.${marketCoinName}.rewardPoolId`
|
|
4240
4298
|
);
|
|
4241
4299
|
let spool = void 0;
|
|
4242
|
-
coinPrices = coinPrices || await query.utils.getCoinPrices(
|
|
4300
|
+
coinPrices = coinPrices || await query.utils.getCoinPrices();
|
|
4243
4301
|
if (indexer) {
|
|
4244
4302
|
const spoolIndexer = await query.indexer.getSpool(marketCoinName);
|
|
4245
4303
|
const coinName2 = query.utils.parseCoinName(marketCoinName);
|
|
@@ -4259,7 +4317,7 @@ var getSpool = async (query, marketCoinName, indexer = false, marketPool, coinPr
|
|
|
4259
4317
|
throw new Error("Fail to fetch spoolObjectResponse!");
|
|
4260
4318
|
}
|
|
4261
4319
|
const rewardCoinName = query.utils.getSpoolRewardCoinName(marketCoinName);
|
|
4262
|
-
coinPrices = coinPrices || await query.utils.getCoinPrices(
|
|
4320
|
+
coinPrices = coinPrices || await query.utils.getCoinPrices();
|
|
4263
4321
|
const spoolObject = spoolObjectResponse[0];
|
|
4264
4322
|
const rewardPoolObject = spoolObjectResponse[1];
|
|
4265
4323
|
if (spoolObject.content && "fields" in spoolObject.content) {
|
|
@@ -4503,7 +4561,7 @@ var getStakeRewardPool = async ({
|
|
|
4503
4561
|
};
|
|
4504
4562
|
|
|
4505
4563
|
// src/queries/vescaQuery.ts
|
|
4506
|
-
import
|
|
4564
|
+
import BigNumber8 from "bignumber.js";
|
|
4507
4565
|
import { SUI_CLOCK_OBJECT_ID, SuiTxBlock as SuiTxBlock2 } from "@scallop-io/sui-kit";
|
|
4508
4566
|
import { bcs as bcs2 } from "@mysten/sui/bcs";
|
|
4509
4567
|
import { z as zod5 } from "zod";
|
|
@@ -4585,7 +4643,7 @@ var getVeSca = async (utils, veScaKey) => {
|
|
|
4585
4643
|
0
|
|
4586
4644
|
);
|
|
4587
4645
|
const lockedScaAmount = String(dynamicFields.locked_sca_amount);
|
|
4588
|
-
const lockedScaCoin =
|
|
4646
|
+
const lockedScaCoin = BigNumber8(dynamicFields.locked_sca_amount).shiftedBy(-9).toNumber();
|
|
4589
4647
|
const currentVeScaBalance = lockedScaCoin * (Math.floor(remainingLockPeriodInMilliseconds / 1e3) / MAX_LOCK_DURATION);
|
|
4590
4648
|
vesca = {
|
|
4591
4649
|
id: veScaDynamicFieldObject.objectId,
|
|
@@ -4595,7 +4653,7 @@ var getVeSca = async (utils, veScaKey) => {
|
|
|
4595
4653
|
lockedScaAmount,
|
|
4596
4654
|
lockedScaCoin,
|
|
4597
4655
|
currentVeScaBalance,
|
|
4598
|
-
unlockAt:
|
|
4656
|
+
unlockAt: BigNumber8(dynamicFields.unlock_at * 1e3).toNumber()
|
|
4599
4657
|
};
|
|
4600
4658
|
}
|
|
4601
4659
|
return vesca;
|
|
@@ -4657,10 +4715,10 @@ var getVeScaTreasuryInfo = async (utils) => {
|
|
|
4657
4715
|
if (!veScaTreasury || veScaTreasury.data?.content?.dataType !== "moveObject")
|
|
4658
4716
|
return null;
|
|
4659
4717
|
const treasuryFields = veScaTreasury.data.content.fields;
|
|
4660
|
-
const totalLockedSca =
|
|
4718
|
+
const totalLockedSca = BigNumber8(
|
|
4661
4719
|
treasuryFields.unlock_schedule.fields.locked_sca_amount
|
|
4662
4720
|
).shiftedBy(-9).toNumber();
|
|
4663
|
-
const totalVeSca =
|
|
4721
|
+
const totalVeSca = BigNumber8(
|
|
4664
4722
|
await getTotalVeScaTreasuryAmount(utils, veScaTreasury.data) ?? 0
|
|
4665
4723
|
).shiftedBy(-9).toNumber();
|
|
4666
4724
|
const averageLockingPeriod = totalLockedSca > 0 ? totalVeSca / totalLockedSca * 4 : 0;
|
|
@@ -4829,6 +4887,15 @@ var ScallopUtils = class {
|
|
|
4829
4887
|
return void 0;
|
|
4830
4888
|
}
|
|
4831
4889
|
}
|
|
4890
|
+
/**
|
|
4891
|
+
* Convert sCoin name to coin name.
|
|
4892
|
+
* This function will parse new sCoin name `scallop_...` to its old market coin name which is shorter
|
|
4893
|
+
* e.g: `scallop_sui -> ssui
|
|
4894
|
+
* @return sCoin name
|
|
4895
|
+
*/
|
|
4896
|
+
parseCoinNameFromSCoinName(coinName) {
|
|
4897
|
+
return sCoinRawNameToName[coinName];
|
|
4898
|
+
}
|
|
4832
4899
|
/**
|
|
4833
4900
|
* Convert sCoin name into sCoin type
|
|
4834
4901
|
* @param sCoinName
|
|
@@ -4880,7 +4947,7 @@ var ScallopUtils = class {
|
|
|
4880
4947
|
const coinTypeMatch = coinType.match(coinTypeRegex);
|
|
4881
4948
|
const isMarketCoinType = coinType.includes("reserve::MarketCoin");
|
|
4882
4949
|
coinType = coinTypeMatch?.[1] ?? coinType;
|
|
4883
|
-
const
|
|
4950
|
+
const wormholeCoinTypeMap = {
|
|
4884
4951
|
[`${this.address.get("core.coins.wusdc.id") ?? wormholeCoinIds.wusdc}::coin::COIN`]: "wusdc",
|
|
4885
4952
|
[`${this.address.get("core.coins.wusdt.id") ?? wormholeCoinIds.wusdt}::coin::COIN`]: "wusdt",
|
|
4886
4953
|
[`${this.address.get("core.coins.weth.id") ?? wormholeCoinIds.weth}::coin::COIN`]: "weth",
|
|
@@ -4900,7 +4967,7 @@ var ScallopUtils = class {
|
|
|
4900
4967
|
},
|
|
4901
4968
|
{}
|
|
4902
4969
|
);
|
|
4903
|
-
const assetCoinName =
|
|
4970
|
+
const assetCoinName = wormholeCoinTypeMap[coinType] || voloCoinTypeMap[coinType] || suiBridgeTypeMap[coinType] || coinType.split("::")[2].toLowerCase();
|
|
4904
4971
|
return isMarketCoinType ? this.parseMarketCoinName(assetCoinName) : assetCoinName;
|
|
4905
4972
|
}
|
|
4906
4973
|
/**
|
|
@@ -7294,6 +7361,7 @@ var ScallopQuery = class {
|
|
|
7294
7361
|
this,
|
|
7295
7362
|
coinNames,
|
|
7296
7363
|
indexer,
|
|
7364
|
+
args?.marketPools,
|
|
7297
7365
|
args?.coinPrices
|
|
7298
7366
|
);
|
|
7299
7367
|
}
|
|
@@ -7509,6 +7577,13 @@ var ScallopQuery = class {
|
|
|
7509
7577
|
async getCoinPriceByIndexer(poolName) {
|
|
7510
7578
|
return this.indexer.getCoinPrice(poolName);
|
|
7511
7579
|
}
|
|
7580
|
+
/**
|
|
7581
|
+
* Get all coin prices, including sCoin
|
|
7582
|
+
* @returns prices data
|
|
7583
|
+
*/
|
|
7584
|
+
async getAllCoinPrices(args) {
|
|
7585
|
+
return getAllCoinPrices(this, args?.marketPools, args?.coinPrices);
|
|
7586
|
+
}
|
|
7512
7587
|
};
|
|
7513
7588
|
|
|
7514
7589
|
// src/models/scallopBuilder.ts
|
|
@@ -8496,6 +8571,7 @@ export {
|
|
|
8496
8571
|
marketCoins,
|
|
8497
8572
|
queryKeys,
|
|
8498
8573
|
sCoinIds,
|
|
8574
|
+
sCoinRawNameToName,
|
|
8499
8575
|
sCoinTypeToName,
|
|
8500
8576
|
sCoins,
|
|
8501
8577
|
spoolRewardCoins,
|