@scallop-io/sui-scallop-sdk 1.4.1 → 1.4.2-rc.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 +1 -1
- package/dist/constants/poolAddress.d.ts +16 -4
- package/dist/constants/queryKeys.d.ts +2 -2
- package/dist/constants/tokenBucket.d.ts +2 -2
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1270 -588
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1225 -544
- package/dist/index.mjs.map +1 -1
- package/dist/models/scallopBuilder.d.ts +2 -1
- package/dist/models/scallopCache.d.ts +2 -0
- package/dist/models/scallopQuery.d.ts +38 -20
- package/dist/models/scallopUtils.d.ts +4 -2
- package/dist/queries/borrowIncentiveQuery.d.ts +12 -0
- package/dist/queries/coreQuery.d.ts +18 -19
- package/dist/queries/index.d.ts +2 -0
- package/dist/queries/isolatedAssetQuery.d.ts +2 -2
- package/dist/queries/objectsQuery.d.ts +3 -0
- package/dist/queries/poolAddressesQuery.d.ts +18 -0
- package/dist/queries/spoolQuery.d.ts +6 -2
- package/dist/test.d.ts +1 -0
- package/dist/types/builder/borrowIncentive.d.ts +5 -5
- package/dist/types/builder/core.d.ts +20 -16
- package/dist/types/builder/loyaltyProgram.d.ts +1 -1
- package/dist/types/builder/referral.d.ts +4 -4
- package/dist/types/builder/sCoin.d.ts +2 -2
- package/dist/types/builder/spool.d.ts +4 -4
- package/dist/types/builder/vesca.d.ts +6 -6
- package/dist/types/query/core.d.ts +22 -5
- package/dist/types/query/spool.d.ts +20 -0
- package/dist/types/utils.d.ts +7 -2
- package/dist/utils/core.d.ts +2 -0
- package/dist/utils/index.d.ts +2 -0
- package/dist/utils/query.d.ts +1 -1
- package/dist/utils/util.d.ts +1 -0
- package/package.json +7 -7
- package/src/builders/borrowIncentiveBuilder.ts +28 -15
- package/src/builders/coreBuilder.ts +76 -49
- package/src/builders/loyaltyProgramBuilder.ts +4 -3
- package/src/builders/referralBuilder.ts +23 -10
- package/src/builders/sCoinBuilder.ts +8 -6
- package/src/builders/spoolBuilder.ts +21 -14
- package/src/builders/vescaBuilder.ts +23 -13
- package/src/constants/common.ts +1 -12
- package/src/constants/poolAddress.ts +336 -10
- package/src/constants/queryKeys.ts +9 -5
- package/src/constants/testAddress.ts +42 -0
- package/src/constants/tokenBucket.ts +2 -2
- package/src/index.ts +1 -0
- package/src/models/scallopBuilder.ts +59 -2
- package/src/models/scallopCache.ts +171 -19
- package/src/models/scallopClient.ts +16 -10
- package/src/models/scallopQuery.ts +36 -28
- package/src/models/scallopUtils.ts +11 -4
- package/src/queries/borrowIncentiveQuery.ts +6 -8
- package/src/queries/borrowLimitQuery.ts +1 -0
- package/src/queries/coreQuery.ts +408 -258
- package/src/queries/index.ts +2 -0
- package/src/queries/isolatedAssetQuery.ts +37 -31
- package/src/queries/objectsQuery.ts +20 -0
- package/src/queries/poolAddressesQuery.ts +146 -0
- package/src/queries/portfolioQuery.ts +31 -13
- package/src/queries/priceQuery.ts +3 -1
- package/src/queries/spoolQuery.ts +189 -122
- package/src/test.ts +17 -0
- package/src/types/builder/borrowIncentive.ts +8 -5
- package/src/types/builder/core.ts +23 -17
- package/src/types/builder/loyaltyProgram.ts +1 -1
- package/src/types/builder/referral.ts +6 -4
- package/src/types/builder/sCoin.ts +2 -2
- package/src/types/builder/spool.ts +4 -4
- package/src/types/builder/vesca.ts +9 -6
- package/src/types/query/core.ts +21 -5
- package/src/types/query/spool.ts +21 -0
- package/src/types/utils.ts +8 -3
- package/src/utils/core.ts +18 -0
- package/src/utils/index.ts +2 -0
- package/src/utils/query.ts +21 -5
- package/src/utils/tokenBucket.ts +9 -29
- package/src/utils/util.ts +8 -0
package/dist/index.mjs
CHANGED
|
@@ -114,18 +114,7 @@ var SUPPORT_WORMHOLE = [
|
|
|
114
114
|
"wsol"
|
|
115
115
|
];
|
|
116
116
|
var SUPPORT_SPOOLS_REWARDS = ["sui"];
|
|
117
|
-
var SUPPORT_BORROW_INCENTIVE_POOLS = [
|
|
118
|
-
"sui",
|
|
119
|
-
"wusdc",
|
|
120
|
-
"wusdt",
|
|
121
|
-
"afsui",
|
|
122
|
-
"hasui",
|
|
123
|
-
"vsui",
|
|
124
|
-
"weth",
|
|
125
|
-
"sbeth",
|
|
126
|
-
"sca",
|
|
127
|
-
"usdc"
|
|
128
|
-
];
|
|
117
|
+
var SUPPORT_BORROW_INCENTIVE_POOLS = [...SUPPORT_POOLS];
|
|
129
118
|
var SUPPORT_BORROW_INCENTIVE_REWARDS = [
|
|
130
119
|
...SUPPORT_POOLS,
|
|
131
120
|
...SUPPORT_SCOIN
|
|
@@ -341,65 +330,243 @@ var FlashLoanFeeObjectMap = {
|
|
|
341
330
|
var POOL_ADDRESSES = {
|
|
342
331
|
usdc: {
|
|
343
332
|
lendingPoolAddress: "0xd3be98bf540f7603eeb550c0c0a19dbfc78822f25158b5fa84ebd9609def415f",
|
|
344
|
-
collateralPoolAddress: "0x8f0d529ba179c5b3d508213003eab813aaae31f78226099639b9a69d1aec17af"
|
|
333
|
+
collateralPoolAddress: "0x8f0d529ba179c5b3d508213003eab813aaae31f78226099639b9a69d1aec17af",
|
|
334
|
+
borrowDynamic: "0x77837ecd4f26fac9a410fff594f2c0bd3288904a15492ca77cb8a52684dbb866",
|
|
335
|
+
interestModel: "0xaae3f179d63009380cbdcb9acb12907afc9c3cb79cc3460be296a9c6d28f3ff3",
|
|
336
|
+
riskModel: "0x198b24db213bfeb8b3c80ae63dde92e32fd24984d25da8233ff777b851edd574",
|
|
337
|
+
borrowFeeKey: "0xd37c5316cfe0a5967d14264fa6b423f880518b294a1ee6581ccbb49ccc401fb8",
|
|
338
|
+
supplyLimitKey: "0x4be9ae54ac4d320f4f9c14cae78cb85c8e0e67791dd9bdba6d2db20614a28a24",
|
|
339
|
+
borrowLimitKey: "0x6b01093cba95b835181f00e3a2c31ed8dfc8d64fe3db0fb80933a09f66e1ccf1",
|
|
340
|
+
isolatedAssetKey: void 0,
|
|
341
|
+
spool: "0x0b5f5f413bd3799e4052c37311966c77f3a4545eb125d2e93e67a68478021918",
|
|
342
|
+
spoolReward: "0x85ed6ed72ea97c35dbf0cdc7ed6fbc48d8ec15de9b17c74bf4512df8a6d7f166",
|
|
343
|
+
sCoinTreasury: "0xbe6b63021f3d82e0e7e977cdd718ed7c019cf2eba374b7b546220402452f938e",
|
|
344
|
+
coinDecimalId: "0x69b7a7c3c200439c1b5f3b19d7d495d5966d5f08de66c69276152f8db3992ec6"
|
|
345
345
|
},
|
|
346
346
|
sbeth: {
|
|
347
|
-
lendingPoolAddress: "
|
|
348
|
-
collateralPoolAddress: "0xce0549a1cbe952e734f56646988e6b02bbae14667889a60e24d0d03540a6119f"
|
|
347
|
+
lendingPoolAddress: "0xaa34c938e0394e5186c7dc626ad69be96af2194b23fdc6ac1c63090e399f5ba4",
|
|
348
|
+
collateralPoolAddress: "0xce0549a1cbe952e734f56646988e6b02bbae14667889a60e24d0d03540a6119f",
|
|
349
|
+
borrowDynamic: "0x7bbe75e8b924229f2f2110838ff612ea66e670fa3766759515dee78f617b1ea3",
|
|
350
|
+
interestModel: "0x9e6cae260d05155785a1904d24e6abc98368509c5752c8a9cec15a35aabc1512",
|
|
351
|
+
riskModel: "0xcf10334cfee675ecea2d2fee37b0f7cd2835c84b8b5692a853021debe6af80ab",
|
|
352
|
+
borrowFeeKey: "0x4298c8b6afe7a42a8e3ff93773fb9769529fe6d37e085ab411acf2ba2a44a931",
|
|
353
|
+
supplyLimitKey: "0x812fe508b78d3e0817149c0b39976221ddb267b5cc9514e81679f9b9a2f3624c",
|
|
354
|
+
borrowLimitKey: "0x165c274c67eda2b0d13563124741fffd0ce7d643f4c1c4b59d7e53a83796ae25",
|
|
355
|
+
isolatedAssetKey: void 0,
|
|
356
|
+
spool: void 0,
|
|
357
|
+
spoolReward: void 0,
|
|
358
|
+
sCoinTreasury: "0xfd0f02def6358a1f266acfa1493d4707ee8387460d434fb667d63d755ff907ed",
|
|
359
|
+
coinDecimalId: "0x89b04ba87f8832d4d76e17a1c9dce72eb3e64d372cf02012b8d2de5384faeef0"
|
|
349
360
|
},
|
|
350
361
|
weth: {
|
|
351
362
|
lendingPoolAddress: "0xc8fcdff48efc265740ae0b74aae3faccae9ec00034039a113f3339798035108c",
|
|
352
|
-
collateralPoolAddress: "0xad7ced91ed6e7f2b81805561eee27fa6f3e72fdae561077334c7248583db4dbf"
|
|
363
|
+
collateralPoolAddress: "0xad7ced91ed6e7f2b81805561eee27fa6f3e72fdae561077334c7248583db4dbf",
|
|
364
|
+
borrowDynamic: "0xd1578e1d1c9c82eb4c5bf14beece8142a67a683b2647d7276e92984119fc1445",
|
|
365
|
+
interestModel: "0xa1dc08541cd2cb7cfb4e56272292d5c6a4780e80fd210c58abffae98268b5ed9",
|
|
366
|
+
riskModel: "0x9f05a25fd33a9e8cf33962126b175d038e184f0ee1b87dc41d4cedbe6abebbe5",
|
|
367
|
+
borrowFeeKey: "0x29672ba8ab4625b8181d8ed739e5344de22a97d417748c4d1276c7379283d7a3",
|
|
368
|
+
supplyLimitKey: "0x2b957941bdc9432bbc83ab74dc194b6ebb7c927bc4c6926a5492b5503499e509",
|
|
369
|
+
borrowLimitKey: "0x51f256d87e51a7ca2b1c482923096f4b6dac6beac89d8ecf4c65b7d5764115d6",
|
|
370
|
+
isolatedAssetKey: void 0,
|
|
371
|
+
spool: "0xeec40beccb07c575bebd842eeaabb835f77cd3dab73add433477e57f583a6787",
|
|
372
|
+
spoolReward: "0x957de68a18d87817de8309b30c1ec269a4d87ae513abbeed86b5619cb9ce1077",
|
|
373
|
+
sCoinTreasury: "0x4b7f5da0e306c9d52490a0c1d4091e653d6b89778b9b4f23c877e534e4d9cd21",
|
|
374
|
+
coinDecimalId: "0x8900e4ceede3363bef086d6b50ca89d816d0e90bf6bc46efefe1f8455e08f50f"
|
|
353
375
|
},
|
|
354
376
|
wbtc: {
|
|
355
377
|
lendingPoolAddress: "0x65cc08a5aca0a0b8d72e1993ded8d145f06dd102fd0d8f285b92934faed564ab",
|
|
356
|
-
collateralPoolAddress: "0x1aa4e5cf743cd797b4eb8bf1e614f80ae2cf556ced426cddaaf190ffcd0e59c3"
|
|
378
|
+
collateralPoolAddress: "0x1aa4e5cf743cd797b4eb8bf1e614f80ae2cf556ced426cddaaf190ffcd0e59c3",
|
|
379
|
+
borrowDynamic: "0x6f97dcf54158a5d08f359a213a41e347bc1e6316414288dc1e1b674dc008742e",
|
|
380
|
+
interestModel: "0x582b915cca0ffca9576a7cedd505d0fd7cb146e9521ccf10e7453ed93705684d",
|
|
381
|
+
riskModel: "0x1d0a242bf1682e259112239720da19d3155dd99d70b1f4b3b973eecbab858911",
|
|
382
|
+
borrowFeeKey: "0x654ab7e8ff6d9ef04da697e1f12ca21eaf72ebb495daf877e0776e65187dcb92",
|
|
383
|
+
supplyLimitKey: "0xac3b0d17df9f98aa2798c54405cf1d8d5356ef22f76f02d150cbe5195e9f3a36",
|
|
384
|
+
borrowLimitKey: "0x231e13ba6b1eb26c562f4a125778d3152f9a77e31f124bd6012e234a73012169",
|
|
385
|
+
isolatedAssetKey: void 0,
|
|
386
|
+
spool: void 0,
|
|
387
|
+
spoolReward: void 0,
|
|
388
|
+
sCoinTreasury: "0xe2883934ea42c99bc998bbe0f01dd6d27aa0e27a56455707b1b34e6a41c20baa",
|
|
389
|
+
coinDecimalId: "0x5d3c6e60eeff8a05b693b481539e7847dfe33013e7070cdcb387f5c0cac05dfd"
|
|
357
390
|
},
|
|
358
391
|
wusdc: {
|
|
359
|
-
lendingPoolAddress: "
|
|
360
|
-
collateralPoolAddress: "
|
|
392
|
+
lendingPoolAddress: "0x2f4df5e1368fbbdaa5c712d28b837b3d41c2d3872979ccededcdfdac55ff8a93",
|
|
393
|
+
collateralPoolAddress: "0x94cf69158114c5b242d2ee5d0149a335bddf3b9c9a6ba919cca58097a4814980",
|
|
394
|
+
borrowDynamic: "0x0464d117908b52fc75f7f85322a47caa078ef56f48681bcfdcb630a66f2591e6",
|
|
395
|
+
interestModel: "0xd72e2b5ba486752939d6dfb86a67b86ce9a60c83cb8fb893caac54a0f112577f",
|
|
396
|
+
riskModel: "0xb74035de8f70c1531ceb8e2e8c152d6b8db24c8a9fe7bbf6f75dbf7c6700a0a3",
|
|
397
|
+
borrowFeeKey: "0x76dcf1acbd9951fe3d1a3fe28403fec089ffe53a7c7d6c77e3ea97033a63581a",
|
|
398
|
+
supplyLimitKey: "0x7b302196907e87c5d5872f2e6f40628d110170f994e0e08bc607bded001958c3",
|
|
399
|
+
borrowLimitKey: "0x97f1502ce994db0bcb15aac1760d174def9e88e97cd2262eed54521ee2c19f81",
|
|
400
|
+
isolatedAssetKey: void 0,
|
|
401
|
+
spool: "0x4ace6648ddc64e646ba47a957c562c32c9599b3bba8f5ac1aadb2ae23a2f8ca0",
|
|
402
|
+
spoolReward: "0xf4268cc9b9413b9bfe09e8966b8de650494c9e5784bf0930759cfef4904daff8",
|
|
403
|
+
sCoinTreasury: "0x50c5cfcbcca3aaacab0984e4d7ad9a6ad034265bebb440f0d1cd688ec20b2548",
|
|
404
|
+
coinDecimalId: "0x4fbf84f3029bd0c0b77164b587963be957f853eccf834a67bb9ecba6ec80f189"
|
|
361
405
|
},
|
|
362
406
|
wusdt: {
|
|
363
407
|
lendingPoolAddress: "0xfbc056f126dd35adc1f8fe985e2cedc8010e687e8e851e1c5b99fdf63cd1c879",
|
|
364
|
-
collateralPoolAddress: "0x2260cb5b24929dd20a1742f37a61ff3ce4fde5cdb023e2d3ce2e0ce2d90719e3"
|
|
408
|
+
collateralPoolAddress: "0x2260cb5b24929dd20a1742f37a61ff3ce4fde5cdb023e2d3ce2e0ce2d90719e3",
|
|
409
|
+
borrowDynamic: "0xb524030cc8f7cdbf13f1925a0a2b5e77cc52bab73b070f42c5e510f6083da1ba",
|
|
410
|
+
interestModel: "0x92f93c4431b4c51774d6d964da516af2def18b78f49dbbf519e58449a8ba4659",
|
|
411
|
+
riskModel: "0xdf89d66988cb506ddeff46f5dfd1d11aaece345e9a05a0c6a18a0788647de2a7",
|
|
412
|
+
borrowFeeKey: "0xda8f8b3522fc4086eae4ae7ce8844d60aa0dc3eab8ffc91fe93e922a72639b2d",
|
|
413
|
+
supplyLimitKey: "0xa9cb5ebb90ca6e808a2bd7728cca4a6fa8b565d4deeda96eb23c8322c477c24e",
|
|
414
|
+
borrowLimitKey: "0xa3278564fc613680a69c10972a0299965bf6e12e9ac171388842fc958de0f90e",
|
|
415
|
+
isolatedAssetKey: void 0,
|
|
416
|
+
spool: "0xcb328f7ffa7f9342ed85af3fdb2f22919e1a06dfb2f713c04c73543870d7548f",
|
|
417
|
+
spoolReward: "0x2c9f934d67a5baa586ceec2cc24163a2f049a6af3d5ba36b84d8ac40f25c4080",
|
|
418
|
+
sCoinTreasury: "0x1f02e2fed702b477732d4ad6044aaed04f2e8e586a169153694861a901379df0",
|
|
419
|
+
coinDecimalId: "0xfb0e3eb97dd158a5ae979dddfa24348063843c5b20eb8381dd5fa7c93699e45c"
|
|
365
420
|
},
|
|
366
421
|
sui: {
|
|
367
422
|
lendingPoolAddress: "0x9c9077abf7a29eebce41e33addbcd6f5246a5221dd733e56ea0f00ae1b25c9e8",
|
|
368
|
-
collateralPoolAddress: "0x75aacfb7dcbf92ee0111fc1bf975b12569e4ba632e81ed7ae5ac090d40cd3acb"
|
|
423
|
+
collateralPoolAddress: "0x75aacfb7dcbf92ee0111fc1bf975b12569e4ba632e81ed7ae5ac090d40cd3acb",
|
|
424
|
+
borrowDynamic: "0xbf68e6159c99dcaf87717385f1143d2891c2d19663bd51f0bc9b6909e4bb7c27",
|
|
425
|
+
interestModel: "0x0dad9baa89b863c15a0487575de7cc428b01f1aa3998ad7a9e9752d96e83ffa9",
|
|
426
|
+
riskModel: "0xcd6675864690b5648a6e309f2f02a66914b2b2bd9c31936f4e0f7fc0f792bc86",
|
|
427
|
+
borrowFeeKey: "0xda5ede87a05c0677b17511c859b22d0a2b0229ee374d5d7a1274cb836b9fe5f8",
|
|
428
|
+
supplyLimitKey: "0x0602418e66fb7a73fa997077bd66f248ad5b090d43344a14b9f1db598ecc1d47",
|
|
429
|
+
borrowLimitKey: "0x2b33a7efdcf6a6df24f4d8a356dd52f58d75bc023c3f171d99502d4d008b53f0",
|
|
430
|
+
isolatedAssetKey: void 0,
|
|
431
|
+
spool: "0x4f0ba970d3c11db05c8f40c64a15b6a33322db3702d634ced6536960ab6f3ee4",
|
|
432
|
+
spoolReward: "0x162250ef72393a4ad3d46294c4e1bdfcb03f04c869d390e7efbfc995353a7ee9",
|
|
433
|
+
sCoinTreasury: "0x5c1678c8261ac9eec024d4d630006a9f55c80dc0b1aa38a003fcb1d425818c6b",
|
|
434
|
+
coinDecimalId: "0x9258181f5ceac8dbffb7030890243caed69a9599d2886d957a9cb7656af3bdb3"
|
|
369
435
|
},
|
|
370
436
|
wapt: {
|
|
371
437
|
lendingPoolAddress: "0xca8c14a24e0c32b198eaf479a3317461e3cc339097ce88eaf296a15df8dcfdf5",
|
|
372
|
-
collateralPoolAddress: "0xde33f9ac5bb0ed34598da4e64b4983832716ced65f172fbf267bcfe859c4ad9c"
|
|
438
|
+
collateralPoolAddress: "0xde33f9ac5bb0ed34598da4e64b4983832716ced65f172fbf267bcfe859c4ad9c",
|
|
439
|
+
borrowDynamic: "0xadda873fb6bf68e1ba3f2dfaa51cf75d4a1bef73d9627bd36e77d2baecb1f2dc",
|
|
440
|
+
interestModel: "0xa4a29d07beecea5eb0c59745bb89d7a1380c6f206a7f1ca37046e05db6025c43",
|
|
441
|
+
riskModel: "0x7ada83b473af30aed50d187de82a0912878b53ade7ac30e11ce23953cf739d84",
|
|
442
|
+
borrowFeeKey: "0x768735df587c7e0f141dcd035fbbcbf9d2149a7b23888baed4e2baa160fa2eeb",
|
|
443
|
+
supplyLimitKey: void 0,
|
|
444
|
+
borrowLimitKey: void 0,
|
|
445
|
+
isolatedAssetKey: void 0,
|
|
446
|
+
spool: void 0,
|
|
447
|
+
spoolReward: void 0,
|
|
448
|
+
sCoinTreasury: void 0,
|
|
449
|
+
coinDecimalId: "0xc969c5251f372c0f34c32759f1d315cf1ea0ee5e4454b52aea08778eacfdd0a8"
|
|
373
450
|
},
|
|
374
451
|
wsol: {
|
|
375
452
|
lendingPoolAddress: "0x985682c42984cdfb03f9ff7d8923344c2fe096b1ae4b82ea17721af19d22a21f",
|
|
376
|
-
collateralPoolAddress: "0xdc1cc2c371a043ae8e3c3fe2d013c35f1346960b7dbb4c072982c5b794ed144f"
|
|
453
|
+
collateralPoolAddress: "0xdc1cc2c371a043ae8e3c3fe2d013c35f1346960b7dbb4c072982c5b794ed144f",
|
|
454
|
+
borrowDynamic: "0xe3f301e16d4f1273ea659dd82c5c3f124ca5a5883a5726c7ec0f77bf43b70895",
|
|
455
|
+
interestModel: "0xd95affaee077006b8dbb4b108c1b087e95fc6e5143ef0682da345d5b35bc6356",
|
|
456
|
+
riskModel: "0x8e0da6358073144ec3557400c87f04991ba3a13ca7e0d0a19daed45260b32f16",
|
|
457
|
+
borrowFeeKey: "0x604bffbc817e8e12db15f2373a9e15b2c7adbc510649cdf2cc62a594af90671c",
|
|
458
|
+
supplyLimitKey: "0xbd419b536b3f9c9d4adfc20372ca6feedc53cc31798ac860dbfc847bcf05f54b",
|
|
459
|
+
borrowLimitKey: "0x77d453c51948f32564c810bc73f9ba7abde880657b7f89e1c8a3bc28fa36ee87",
|
|
460
|
+
isolatedAssetKey: void 0,
|
|
461
|
+
spool: void 0,
|
|
462
|
+
spoolReward: void 0,
|
|
463
|
+
sCoinTreasury: "0x760fd66f5be869af4382fa32b812b3c67f0eca1bb1ed7a5578b21d56e1848819",
|
|
464
|
+
coinDecimalId: "0x4d2c39082b4477e3e79dc4562d939147ab90c42fc5f3e4acf03b94383cd69b6e"
|
|
377
465
|
},
|
|
378
466
|
cetus: {
|
|
379
467
|
lendingPoolAddress: "0xc09858f60e74a1b671635bec4e8a2c84a0ff313eb87f525fba3258e88c6b6282",
|
|
380
|
-
collateralPoolAddress: "0xe363967e29b7b9c1245d6d46d63e719de8f90b37e3358c545b55d945ea0b676a"
|
|
468
|
+
collateralPoolAddress: "0xe363967e29b7b9c1245d6d46d63e719de8f90b37e3358c545b55d945ea0b676a",
|
|
469
|
+
borrowDynamic: "0xcc725fd5d71990cdccc7e16c88a2abde6dbcd0bf6e805ccc1c0cb83a106bbf4e",
|
|
470
|
+
interestModel: "0x2f1258aab89d04d11834121599ab1317dfecb582b4246f106df399911125845a",
|
|
471
|
+
riskModel: "0x03fed312dbba624dff5edaf4736891a1c7d864445fd268e7572b42ec7381132e",
|
|
472
|
+
borrowFeeKey: "0xdf5fb0cc4ebbf5eebfae23dfa5b266f6a58c18a894a13054ae60c0eb6e79c382",
|
|
473
|
+
supplyLimitKey: "0xa5ea3d4bf663d7bc667e82b40a98923590ff3851b9ea8e7afbc26c588c7007d3",
|
|
474
|
+
borrowLimitKey: "0xf44218a5f0feb128e6fbe74b91d1e7e9ef859bd23a576ff0de151829e015a157",
|
|
475
|
+
isolatedAssetKey: void 0,
|
|
476
|
+
spool: "0xac1bb13bf4472a637c18c2415fb0e3c1227ea2bcf35242e50563c98215bd298e",
|
|
477
|
+
spoolReward: "0x6835c1224126a45086fc6406adc249e3f30df18d779ca4f4e570e38716a17f3f",
|
|
478
|
+
sCoinTreasury: "0xa283c63488773c916cb3d6c64109536160d5eb496caddc721eb39aad2977d735",
|
|
479
|
+
coinDecimalId: "0x4c0dce55eff2db5419bbd2d239d1aa22b4a400c01bbb648b058a9883989025da"
|
|
381
480
|
},
|
|
382
481
|
afsui: {
|
|
383
482
|
lendingPoolAddress: "0x9b942a24ce390b7f5016d34a0217057bf9487b92aa6d7cc9894271dbbe62471a",
|
|
384
|
-
collateralPoolAddress: "0xe5e56f5c0e3072760b21f9d49a5cc793f37d736c412a9065c16e1265c74e6341"
|
|
483
|
+
collateralPoolAddress: "0xe5e56f5c0e3072760b21f9d49a5cc793f37d736c412a9065c16e1265c74e6341",
|
|
484
|
+
borrowDynamic: "0x1c76d4df9506154a117bbac0f5e005d8a9c0d9ca60e3fe0c9d080006f6f54e81",
|
|
485
|
+
interestModel: "0xb155c536b37c9601baaa734ad1dd0ef335b2b597aceb8d3ecee41a43f94dcd70",
|
|
486
|
+
riskModel: "0x75371b1d04b5bebc0738af548ba64ea658e74f78228ec8014336d8eebb992312",
|
|
487
|
+
borrowFeeKey: "0xabc6422db2d4ee01635ddaeaa44ba68370eebd785d2c4632515f841ae9bc47d9",
|
|
488
|
+
supplyLimitKey: "0x61a2054eb37f543c0d774da57f2c9542aad8d79a197f748ac08ef5df6cc47028",
|
|
489
|
+
borrowLimitKey: "0x4459498a043872cd107ea917493fee0baf2d37a273c7538e1d6581cc61b92af8",
|
|
490
|
+
isolatedAssetKey: void 0,
|
|
491
|
+
spool: "0xeedf438abcaa6ce4d9625ffca110920592d5867e4c5637d84ad9f466c4feb800",
|
|
492
|
+
spoolReward: "0x89255a2f86ed7fbfef35ab8b7be48cc7667015975be2685dd9a55a9a64baf76e",
|
|
493
|
+
sCoinTreasury: "0x55f4dfe9e40bc4cc11c70fcb1f3daefa2bdc330567c58d4f0792fbd9f9175a62",
|
|
494
|
+
coinDecimalId: "0x2f9217f533e51334873a39b8026a4aa6919497b47f49d0986a4f1aec66f8a34d"
|
|
385
495
|
},
|
|
386
496
|
hasui: {
|
|
387
497
|
lendingPoolAddress: "0x7ebc607f6bdeb659fb6506cb91c5cc1d47bb365cfd5d2e637ea765346ec84ed4",
|
|
388
|
-
collateralPoolAddress: "0xad9ed40d6486e4c26cec7370dffce8dc4821eb79178250b5938a34ccafd61e6d"
|
|
498
|
+
collateralPoolAddress: "0xad9ed40d6486e4c26cec7370dffce8dc4821eb79178250b5938a34ccafd61e6d",
|
|
499
|
+
borrowDynamic: "0x13ec1220b41c6e0f11dd6113199a2aff8e4cf2223047b5bd06d7a3ed5d23e1d2",
|
|
500
|
+
interestModel: "0x987c58cbe48096618f4d9d83e0bde2ff638ce4753aba40dab7c302ac3e4b4519",
|
|
501
|
+
riskModel: "0xe42d8497d423eca0d8df89850c2d77d3644e7f54a2d28f59c315903ea5ec8dec",
|
|
502
|
+
borrowFeeKey: "0xef885c382d461c4fb14d1f3b3758c380c78a1a4b2a3d2fafe6e8649a60fdd7ab",
|
|
503
|
+
supplyLimitKey: "0xc7385b1703693cbbc9c97227fe3fd5c91d7afda00e0da69d942c3260d78e45e0",
|
|
504
|
+
borrowLimitKey: "0x65333e606eead786a999c8267bc9886b0fdbc298a8a8635a48a9c9b8838d9395",
|
|
505
|
+
isolatedAssetKey: void 0,
|
|
506
|
+
spool: "0xa6148bc1b623e936d39a952ceb5bea79e8b37228a8f595067bf1852efd3c34aa",
|
|
507
|
+
spoolReward: "0x6f3563644d3e2ef13176dbf9d865bd93479df60ccbe07b7e66db57f6309f5a66",
|
|
508
|
+
sCoinTreasury: "0x404ccc1404d74a90eb6f9c9d4b6cda6d417fb03189f80d9070a35e5dab1df0f5",
|
|
509
|
+
coinDecimalId: "0x2c5f33af93f6511df699aaaa5822d823aac6ed99d4a0de2a4a50b3afa0172e24"
|
|
389
510
|
},
|
|
390
511
|
vsui: {
|
|
391
512
|
lendingPoolAddress: "0xda9257c0731d8822e8a438ebced13415850d705b779c79958dcf2aeb21fcb43d",
|
|
392
|
-
collateralPoolAddress: "0x4435e8b8ec2a04094d863aa52deb6ab6f8f47ed8778f4d9f1b27afc4a6e85f1e"
|
|
513
|
+
collateralPoolAddress: "0x4435e8b8ec2a04094d863aa52deb6ab6f8f47ed8778f4d9f1b27afc4a6e85f1e",
|
|
514
|
+
borrowDynamic: "0x8eae703505246f975e83f5af24780e5f1b89ef403d5a80ea15534624d6f1a503",
|
|
515
|
+
interestModel: "0xaf6a52b5eaaa5af4d9e49d83de0d504c295ae21f3a37560c3f48e0e15a1d4625",
|
|
516
|
+
riskModel: "0x1e862f27a6bd47c3041159a5cf392f549485c6605ed9aa937f16ecc951e82e65",
|
|
517
|
+
borrowFeeKey: "0x5230de0f41a5e4c05b3d1187a90a9eeab491cec97b08b71512d9785e8af36aa6",
|
|
518
|
+
supplyLimitKey: "0x1d40e34d1f365ec431fff020bd75c16b14b340b3ed6c139803cc15c2384621b2",
|
|
519
|
+
borrowLimitKey: "0x4eb206b4417642cfc1b02f80bb5f5e366af2af2f9fb4ea4f4e898ae82367f8a0",
|
|
520
|
+
isolatedAssetKey: void 0,
|
|
521
|
+
spool: "0x69ce8e537e750a95381e6040794afa5ab1758353a1a2e1de7760391b01f91670",
|
|
522
|
+
spoolReward: "0xbca914adce058ad0902c7f3cfcd698392a475f00dcfdc3f76001d0370b98777a",
|
|
523
|
+
sCoinTreasury: "0xc06688ee1af25abc286ffb1d18ce273d1d5907cd1064c25f4e8ca61ea989c1d1",
|
|
524
|
+
coinDecimalId: "0xabd84a23467b33854ab25cf862006fd97479f8f6f53e50fe732c43a274d939bd"
|
|
393
525
|
},
|
|
394
526
|
sca: {
|
|
395
527
|
lendingPoolAddress: "0x6fc7d4211fc7018b6c75e7b908b88f2e0536443239804a3d32af547637bd28d7",
|
|
396
|
-
collateralPoolAddress: "0xff677a5d9e9dc8f08f0a8681ebfc7481d1c7d57bc441f2881974adcdd7b13c31"
|
|
528
|
+
collateralPoolAddress: "0xff677a5d9e9dc8f08f0a8681ebfc7481d1c7d57bc441f2881974adcdd7b13c31",
|
|
529
|
+
borrowDynamic: "0x4e24f52edd739dab59ca4c6353ca430b7ce57e7f333abd0957958570a7cd09ca",
|
|
530
|
+
interestModel: "0xbdcd48cf5b1a814911dc2d5c72d393a980c87820199fe5d799289ce94f4c47df",
|
|
531
|
+
riskModel: "0xc437c24b67b8e2676907700fa395af337ad6463d2c0b4f4fa2e9276414026089",
|
|
532
|
+
borrowFeeKey: "0xee55ba0f9800a62d9e7aef667f87e658258f41814d2c9fa02e25590671b4e5ad",
|
|
533
|
+
supplyLimitKey: "0x8dd938856b972a10ea27ecab2af7ed78e48fc5f6ccedaf2b2119959f747dc2e3",
|
|
534
|
+
borrowLimitKey: "0x04c7de61c5b42972f9bf6a8b1848e5fea2d037ee8deba81741ecd4a70aa80d30",
|
|
535
|
+
isolatedAssetKey: void 0,
|
|
536
|
+
spool: void 0,
|
|
537
|
+
spoolReward: void 0,
|
|
538
|
+
sCoinTreasury: "0xe04bfc95e00252bd654ee13c08edef9ac5e4b6ae4074e8390db39e9a0109c529",
|
|
539
|
+
coinDecimalId: "0x5d26a1e9a55c88147ac870bfa31b729d7f49f8804b8b3adfdf3582d301cca844"
|
|
397
540
|
},
|
|
398
541
|
fud: {
|
|
399
|
-
lendingPoolAddress: "
|
|
542
|
+
lendingPoolAddress: "0xefed2cbe76b344792ac724523c8b2236740d1cea2100d46a0ed0dc760c7f4231",
|
|
543
|
+
collateralPoolAddress: void 0,
|
|
544
|
+
borrowDynamic: "0x14367ddca30e2860cb89ed4eaca20c7ece260c5d59dd9990d2c85a8321326acb",
|
|
545
|
+
interestModel: "0x2600ac100ef154eb2329ffd3aad47aca308ff9f9348de3e8e94aaeb906ec2303",
|
|
546
|
+
riskModel: void 0,
|
|
547
|
+
borrowFeeKey: "0xa87e8b26e07ff35ac9fb57adcc779be2883080fc7d12de2d9e7e16d8d8d5e529",
|
|
548
|
+
supplyLimitKey: "0xf98419aecc37a3c5de716f8ec590f8991a5be34da72ce1a2da09531ff45adf7d",
|
|
549
|
+
borrowLimitKey: "0x3d928a001c453c50004baa54e14b0a0e1b0907d9c613dfd76064fd7ed4e8beb8",
|
|
550
|
+
isolatedAssetKey: "0xfcb533e9e4e31f9c9f32d6cbf7fbb3425f1d60474e229a363a2dc7f835d587e2",
|
|
551
|
+
spool: void 0,
|
|
552
|
+
spoolReward: void 0,
|
|
553
|
+
sCoinTreasury: "0xf25212f11d182decff7a86165699a73e3d5787aced203ca539f43cfbc10db867",
|
|
554
|
+
coinDecimalId: "0x01087411ef48aaac1eb6e24803213e3a60a03b147dac930e5e341f17a85e524e"
|
|
400
555
|
},
|
|
401
556
|
deep: {
|
|
402
|
-
lendingPoolAddress: "0xf4a67ffb43da1e1c61c049f188f19463ea8dbbf2d5ef4722d6df854ff1b1cc03"
|
|
557
|
+
lendingPoolAddress: "0xf4a67ffb43da1e1c61c049f188f19463ea8dbbf2d5ef4722d6df854ff1b1cc03",
|
|
558
|
+
collateralPoolAddress: void 0,
|
|
559
|
+
borrowDynamic: "0x95e00d7466f97a100e70f08bd37788dc49335796f6f49fab996d40dd0681c6d3",
|
|
560
|
+
interestModel: "0x4143c298506a332d92ea8a995e6f3991ee3215f58f6fc6441752835d275b9a69",
|
|
561
|
+
riskModel: void 0,
|
|
562
|
+
borrowFeeKey: "0xb14ee43f4ad2a2c40bac8c4406a401690e93c982e289cf3802fedf74a159cab2",
|
|
563
|
+
supplyLimitKey: "0x599528fdfdc253e90dfd0acf4f4a166b391e2aac1ca6528abbff63225b548fee",
|
|
564
|
+
borrowLimitKey: "0xf4217e8ef9d9c32e8992092e910a77535a8124c19b8a762a673f227f5f765a4e",
|
|
565
|
+
isolatedAssetKey: "0x208d3a24ba369dcfc8f0387333d1512b98199eb150d2f2a69359ff708cf761e3",
|
|
566
|
+
spool: void 0,
|
|
567
|
+
spoolReward: void 0,
|
|
568
|
+
sCoinTreasury: "0xc63838fabe37b25ad897392d89876d920f5e0c6a406bf3abcb84753d2829bc88",
|
|
569
|
+
coinDecimalId: "0x6e60b051a08fa836f5a7acd7c464c8d9825bc29c44657fe170fe9b8e1e4770c0"
|
|
403
570
|
}
|
|
404
571
|
};
|
|
405
572
|
|
|
@@ -450,7 +617,11 @@ var queryKeys = {
|
|
|
450
617
|
typeArgs: !typeArgs ? void 0 : JSON.stringify(typeArgs)
|
|
451
618
|
}
|
|
452
619
|
],
|
|
453
|
-
getObject: (objectId,
|
|
620
|
+
getObject: (objectId, options) => [
|
|
621
|
+
"rpc",
|
|
622
|
+
"getObject",
|
|
623
|
+
{ options, objectId }
|
|
624
|
+
],
|
|
454
625
|
getObjects: (objectIds, walletAddress, options) => [
|
|
455
626
|
"rpc",
|
|
456
627
|
"getObjects",
|
|
@@ -500,7 +671,10 @@ var queryKeys = {
|
|
|
500
671
|
"rpc",
|
|
501
672
|
"getAllCoinBalances",
|
|
502
673
|
{ owner }
|
|
503
|
-
]
|
|
674
|
+
],
|
|
675
|
+
getNormalizedMoveFunction: (target) => {
|
|
676
|
+
return ["rpc", "getNormalizedMoveCall", target];
|
|
677
|
+
}
|
|
504
678
|
},
|
|
505
679
|
oracle: {
|
|
506
680
|
getPythLatestPriceFeeds: () => ["oracle", "getPythPriceIds"]
|
|
@@ -724,6 +898,32 @@ var TEST_ADDRESSES = {
|
|
|
724
898
|
feedObject: "0x9193fd47f9a0ab99b6e365a464c8a9ae30e6150fc37ed2a89c1586631f6fc4ab"
|
|
725
899
|
}
|
|
726
900
|
}
|
|
901
|
+
},
|
|
902
|
+
deep: {
|
|
903
|
+
id: "0xdeeb7a4662eec9f2f3def03fb937a663dddaa2e215b8078a284d026b7946c270",
|
|
904
|
+
metaData: "0x6e60b051a08fa836f5a7acd7c464c8d9825bc29c44657fe170fe9b8e1e4770c0",
|
|
905
|
+
treasury: "",
|
|
906
|
+
oracle: {
|
|
907
|
+
supra: "",
|
|
908
|
+
switchboard: "",
|
|
909
|
+
pyth: {
|
|
910
|
+
feed: "29bdd5248234e33bd93d3b81100b5fa32eaa5997843847e2c2cb16d7c6d9f7ff",
|
|
911
|
+
feedObject: "0x8c7f3a322b94cc69db2a2ac575cbd94bf5766113324c3a3eceac91e3e88a51ed"
|
|
912
|
+
}
|
|
913
|
+
}
|
|
914
|
+
},
|
|
915
|
+
fud: {
|
|
916
|
+
id: "0x76cb819b01abed502bee8a702b4c2d547532c12f25001c9dea795a5e631c26f1",
|
|
917
|
+
metaData: "0x01087411ef48aaac1eb6e24803213e3a60a03b147dac930e5e341f17a85e524e",
|
|
918
|
+
treasury: "",
|
|
919
|
+
oracle: {
|
|
920
|
+
supra: "",
|
|
921
|
+
switchboard: "",
|
|
922
|
+
pyth: {
|
|
923
|
+
feed: "6a4090703da959247727f2b490eb21aea95c8684ecfac675f432008830890c75",
|
|
924
|
+
feedObject: "0x4531c3ed0d22f21f5fce882905372006c9aafa30f01db03b789e95a6c50de7b2"
|
|
925
|
+
}
|
|
926
|
+
}
|
|
727
927
|
}
|
|
728
928
|
},
|
|
729
929
|
oracles: {
|
|
@@ -943,14 +1143,22 @@ var TEST_ADDRESSES = {
|
|
|
943
1143
|
ssbeth: {
|
|
944
1144
|
coinType: "0xb14f82d8506d139eacef109688d1b71e7236bcce9b2c0ad526abcd6aa5be7de0::scallop_sb_eth::SCALLOP_SB_ETH",
|
|
945
1145
|
treasury: "0xfd0f02def6358a1f266acfa1493d4707ee8387460d434fb667d63d755ff907ed"
|
|
1146
|
+
},
|
|
1147
|
+
sdeep: {
|
|
1148
|
+
coinType: "0xeb7a05a3224837c5e5503575aed0be73c091d1ce5e43aa3c3e716e0ae614608f::scallop_deep::SCALLOP_DEEP",
|
|
1149
|
+
treasury: "0xc63838fabe37b25ad897392d89876d920f5e0c6a406bf3abcb84753d2829bc88"
|
|
1150
|
+
},
|
|
1151
|
+
sfud: {
|
|
1152
|
+
coinType: "0xe56d5167f427cbe597da9e8150ef5c337839aaf46891d62468dcf80bdd8e10d1::scallop_fud::SCALLOP_FUD",
|
|
1153
|
+
treasury: "0xf25212f11d182decff7a86165699a73e3d5787aced203ca539f43cfbc10db867"
|
|
946
1154
|
}
|
|
947
1155
|
}
|
|
948
1156
|
}
|
|
949
1157
|
};
|
|
950
1158
|
|
|
951
1159
|
// src/constants/tokenBucket.ts
|
|
952
|
-
var DEFAULT_TOKENS_PER_INTERVAL =
|
|
953
|
-
var DEFAULT_INTERVAL_IN_MS =
|
|
1160
|
+
var DEFAULT_TOKENS_PER_INTERVAL = 10;
|
|
1161
|
+
var DEFAULT_INTERVAL_IN_MS = 250;
|
|
954
1162
|
|
|
955
1163
|
// src/constants/vesca.ts
|
|
956
1164
|
var UNLOCK_ROUND_DURATION = 60 * 60 * 24;
|
|
@@ -966,7 +1174,8 @@ import { SuiKit } from "@scallop-io/sui-kit";
|
|
|
966
1174
|
import { QueryClient } from "@tanstack/query-core";
|
|
967
1175
|
import {
|
|
968
1176
|
SuiTxBlock,
|
|
969
|
-
normalizeStructTag as normalizeStructTag2
|
|
1177
|
+
normalizeStructTag as normalizeStructTag2,
|
|
1178
|
+
parseStructTag as parseStructTag2
|
|
970
1179
|
} from "@scallop-io/sui-kit";
|
|
971
1180
|
|
|
972
1181
|
// src/utils/builder.ts
|
|
@@ -1097,7 +1306,10 @@ var parseOriginMarketPoolData = (originMarketPoolData) => {
|
|
|
1097
1306
|
borrowRateOnMidKink: Number(originMarketPoolData.borrowRateOnMidKink.value) / 2 ** 32,
|
|
1098
1307
|
highKink: Number(originMarketPoolData.highKink.value) / 2 ** 32,
|
|
1099
1308
|
midKink: Number(originMarketPoolData.midKink.value) / 2 ** 32,
|
|
1100
|
-
minBorrowAmount: Number(originMarketPoolData.minBorrowAmount)
|
|
1309
|
+
minBorrowAmount: Number(originMarketPoolData.minBorrowAmount),
|
|
1310
|
+
isIsolated: originMarketPoolData.isIsolated,
|
|
1311
|
+
supplyLimit: Number(originMarketPoolData.supplyLimit),
|
|
1312
|
+
borrowLimit: Number(originMarketPoolData.borrowLimit)
|
|
1101
1313
|
};
|
|
1102
1314
|
};
|
|
1103
1315
|
var calculateMarketPoolData = (utils, parsedMarketPoolData) => {
|
|
@@ -1149,6 +1361,7 @@ var calculateMarketPoolData = (utils, parsedMarketPoolData) => {
|
|
|
1149
1361
|
borrowApyOnHighKink: utils.parseAprToApy(borrowAprOnHighKink),
|
|
1150
1362
|
borrowAprOnMidKink,
|
|
1151
1363
|
borrowApyOnMidKink: utils.parseAprToApy(borrowAprOnMidKink),
|
|
1364
|
+
coinDecimal,
|
|
1152
1365
|
maxBorrowApr,
|
|
1153
1366
|
maxBorrowApy: utils.parseAprToApy(maxBorrowApr),
|
|
1154
1367
|
borrowApr: Math.min(borrowApr, maxBorrowApr),
|
|
@@ -1167,17 +1380,21 @@ var calculateMarketPoolData = (utils, parsedMarketPoolData) => {
|
|
|
1167
1380
|
utilizationRate: utilizationRate.toNumber(),
|
|
1168
1381
|
supplyApr: supplyApr.toNumber(),
|
|
1169
1382
|
supplyApy: utils.parseAprToApy(supplyApr.toNumber()),
|
|
1170
|
-
conversionRate: conversionRate.toNumber()
|
|
1383
|
+
conversionRate: conversionRate.toNumber(),
|
|
1384
|
+
isIsolated: parsedMarketPoolData.isIsolated,
|
|
1385
|
+
maxSupplyCoin: BigNumber(parsedMarketPoolData.supplyLimit).shiftedBy(coinDecimal).toNumber(),
|
|
1386
|
+
maxBorrowCoin: BigNumber(parsedMarketPoolData.borrowLimit).shiftedBy(coinDecimal).toNumber()
|
|
1171
1387
|
};
|
|
1172
1388
|
};
|
|
1173
1389
|
var parseOriginMarketCollateralData = (originMarketCollateralData) => {
|
|
1174
1390
|
const divisor = 2 ** 32;
|
|
1175
1391
|
return {
|
|
1176
1392
|
coinType: normalizeStructTag(originMarketCollateralData.type.name),
|
|
1393
|
+
isIsolated: originMarketCollateralData.isIsolated,
|
|
1177
1394
|
collateralFactor: Number(originMarketCollateralData.collateralFactor.value) / divisor,
|
|
1178
1395
|
liquidationFactor: Number(originMarketCollateralData.liquidationFactor.value) / divisor,
|
|
1179
1396
|
liquidationDiscount: Number(originMarketCollateralData.liquidationDiscount.value) / divisor,
|
|
1180
|
-
|
|
1397
|
+
liquidationPenalty: Number(originMarketCollateralData.liquidationPenalty.value) / divisor,
|
|
1181
1398
|
liquidationReserveFactor: Number(originMarketCollateralData.liquidationReserveFactor.value) / divisor,
|
|
1182
1399
|
maxCollateralAmount: Number(originMarketCollateralData.maxCollateralAmount),
|
|
1183
1400
|
totalCollateralAmount: Number(
|
|
@@ -1197,6 +1414,8 @@ var calculateMarketCollateralData = (utils, parsedMarketCollateralData) => {
|
|
|
1197
1414
|
parsedMarketCollateralData.totalCollateralAmount
|
|
1198
1415
|
).shiftedBy(-1 * coinDecimal);
|
|
1199
1416
|
return {
|
|
1417
|
+
coinDecimal,
|
|
1418
|
+
isIsolated: parsedMarketCollateralData.isIsolated,
|
|
1200
1419
|
maxDepositAmount: parsedMarketCollateralData.maxCollateralAmount,
|
|
1201
1420
|
maxDepositCoin: maxCollateralCoin.toNumber(),
|
|
1202
1421
|
depositAmount: parsedMarketCollateralData.totalCollateralAmount,
|
|
@@ -1329,7 +1548,7 @@ var parseOriginBorrowIncentivesPoolPointData = (originBorrowIncentivePoolPointDa
|
|
|
1329
1548
|
createdAt: Number(originBorrowIncentivePoolPointData.created_at)
|
|
1330
1549
|
};
|
|
1331
1550
|
};
|
|
1332
|
-
var parseOriginBorrowIncentivePoolData = (originBorrowIncentivePoolData) => {
|
|
1551
|
+
var parseOriginBorrowIncentivePoolData = (utils, originBorrowIncentivePoolData) => {
|
|
1333
1552
|
return {
|
|
1334
1553
|
poolType: normalizeStructTag(originBorrowIncentivePoolData.pool_type.name),
|
|
1335
1554
|
minStakes: Number(originBorrowIncentivePoolData.min_stakes),
|
|
@@ -1338,9 +1557,9 @@ var parseOriginBorrowIncentivePoolData = (originBorrowIncentivePoolData) => {
|
|
|
1338
1557
|
poolPoints: originBorrowIncentivePoolData.points.reduce(
|
|
1339
1558
|
(acc, point) => {
|
|
1340
1559
|
const parsed = parseOriginBorrowIncentivesPoolPointData(point);
|
|
1341
|
-
const name =
|
|
1342
|
-
parsed.pointType
|
|
1343
|
-
)
|
|
1560
|
+
const name = utils.parseSCoinTypeNameToMarketCoinName(
|
|
1561
|
+
parseStructTag(parsed.pointType).name.toLowerCase()
|
|
1562
|
+
);
|
|
1344
1563
|
acc[name] = parsed;
|
|
1345
1564
|
return acc;
|
|
1346
1565
|
},
|
|
@@ -1527,6 +1746,13 @@ var findClosestUnlockRound = (unlockAtInSecondTimestamp) => {
|
|
|
1527
1746
|
}
|
|
1528
1747
|
return Math.floor(closestTwelveAM.getTime() / 1e3);
|
|
1529
1748
|
};
|
|
1749
|
+
var partitionArray = (array, chunkSize) => {
|
|
1750
|
+
const result = [];
|
|
1751
|
+
for (let i = 0; i < array.length; i += chunkSize) {
|
|
1752
|
+
result.push(array.slice(i, i + chunkSize));
|
|
1753
|
+
}
|
|
1754
|
+
return result;
|
|
1755
|
+
};
|
|
1530
1756
|
|
|
1531
1757
|
// src/utils/tokenBucket.ts
|
|
1532
1758
|
var TokenBucket = class {
|
|
@@ -1539,10 +1765,10 @@ var TokenBucket = class {
|
|
|
1539
1765
|
refill() {
|
|
1540
1766
|
const now = Date.now();
|
|
1541
1767
|
const elapsed = now - this.lastRefill;
|
|
1542
|
-
if (elapsed
|
|
1768
|
+
if (elapsed >= this.interval) {
|
|
1543
1769
|
const tokensToAdd = Math.floor(elapsed / this.interval) * this.tokensPerInterval;
|
|
1544
1770
|
this.tokens = Math.min(this.tokens + tokensToAdd, this.tokensPerInterval);
|
|
1545
|
-
this.lastRefill
|
|
1771
|
+
this.lastRefill += Math.floor(elapsed / this.interval) * this.interval;
|
|
1546
1772
|
}
|
|
1547
1773
|
}
|
|
1548
1774
|
removeTokens(count) {
|
|
@@ -1554,27 +1780,12 @@ var TokenBucket = class {
|
|
|
1554
1780
|
return false;
|
|
1555
1781
|
}
|
|
1556
1782
|
};
|
|
1557
|
-
var callWithRateLimit = async (tokenBucket, fn, retryDelayInMs = DEFAULT_INTERVAL_IN_MS, maxRetries = 15, backoffFactor =
|
|
1783
|
+
var callWithRateLimit = async (tokenBucket, fn, retryDelayInMs = DEFAULT_INTERVAL_IN_MS, maxRetries = 15, backoffFactor = 1.25) => {
|
|
1558
1784
|
let retries = 0;
|
|
1559
1785
|
const tryRequest = async () => {
|
|
1560
1786
|
if (tokenBucket.removeTokens(1)) {
|
|
1561
|
-
|
|
1562
|
-
|
|
1563
|
-
if (result && result.status === 429) {
|
|
1564
|
-
throw new Error("Unexpected status code: 429");
|
|
1565
|
-
}
|
|
1566
|
-
return result;
|
|
1567
|
-
} catch (error) {
|
|
1568
|
-
if (error.message === "Unexpected status code: 429" && retries < maxRetries) {
|
|
1569
|
-
retries++;
|
|
1570
|
-
const delay = retryDelayInMs * Math.pow(backoffFactor, retries);
|
|
1571
|
-
await new Promise((resolve) => setTimeout(resolve, delay));
|
|
1572
|
-
return tryRequest();
|
|
1573
|
-
} else {
|
|
1574
|
-
console.error("An error occurred:", error.message);
|
|
1575
|
-
return null;
|
|
1576
|
-
}
|
|
1577
|
-
}
|
|
1787
|
+
const result = await fn();
|
|
1788
|
+
return result;
|
|
1578
1789
|
} else if (retries < maxRetries) {
|
|
1579
1790
|
retries++;
|
|
1580
1791
|
const delay = retryDelayInMs * Math.pow(backoffFactor, retries);
|
|
@@ -1613,6 +1824,22 @@ function withIndexerFallback(method) {
|
|
|
1613
1824
|
};
|
|
1614
1825
|
}
|
|
1615
1826
|
|
|
1827
|
+
// src/utils/core.ts
|
|
1828
|
+
var parseObjectAs = (object) => {
|
|
1829
|
+
if (!(object && object.content && "fields" in object.content))
|
|
1830
|
+
throw new Error(`Failed to parse object`);
|
|
1831
|
+
const fields = object.content.fields;
|
|
1832
|
+
if (typeof fields === "object" && "value" in fields) {
|
|
1833
|
+
const value = fields.value;
|
|
1834
|
+
if (typeof value === "object" && "fields" in value)
|
|
1835
|
+
return value.fields;
|
|
1836
|
+
return value;
|
|
1837
|
+
} else if (typeof fields === "object") {
|
|
1838
|
+
return fields;
|
|
1839
|
+
}
|
|
1840
|
+
return fields;
|
|
1841
|
+
};
|
|
1842
|
+
|
|
1616
1843
|
// src/models/scallopCache.ts
|
|
1617
1844
|
var ScallopCache = class {
|
|
1618
1845
|
constructor(suiKit, walletAddress, cacheOptions, tokenBucket, queryClient) {
|
|
@@ -1647,6 +1874,13 @@ var ScallopCache = class {
|
|
|
1647
1874
|
})
|
|
1648
1875
|
);
|
|
1649
1876
|
}
|
|
1877
|
+
retryFn(errCount, e) {
|
|
1878
|
+
if (errCount === 5)
|
|
1879
|
+
return false;
|
|
1880
|
+
if (e.status === 429)
|
|
1881
|
+
return true;
|
|
1882
|
+
return false;
|
|
1883
|
+
}
|
|
1650
1884
|
/**
|
|
1651
1885
|
* @description Provides cache for inspectTxn of the SuiKit.
|
|
1652
1886
|
* @param QueryInspectTxnParams
|
|
@@ -1659,18 +1893,64 @@ var ScallopCache = class {
|
|
|
1659
1893
|
typeArgs
|
|
1660
1894
|
}) {
|
|
1661
1895
|
const txBlock = new SuiTxBlock();
|
|
1662
|
-
|
|
1896
|
+
const resolvedQueryTarget = await this.queryGetNormalizedMoveFunction(queryTarget);
|
|
1897
|
+
if (!resolvedQueryTarget)
|
|
1898
|
+
throw new Error("Invalid query target");
|
|
1899
|
+
const { parameters } = resolvedQueryTarget;
|
|
1900
|
+
const resolvedArgs = await Promise.all(
|
|
1901
|
+
(args ?? []).map(async (arg, idx) => {
|
|
1902
|
+
if (typeof arg !== "string")
|
|
1903
|
+
return arg;
|
|
1904
|
+
const cachedData = (await this.queryGetObject(arg))?.data;
|
|
1905
|
+
if (!cachedData)
|
|
1906
|
+
return arg;
|
|
1907
|
+
const owner = cachedData.owner;
|
|
1908
|
+
if (!owner || typeof owner !== "object" || !("Shared" in owner))
|
|
1909
|
+
return {
|
|
1910
|
+
objectId: cachedData.objectId,
|
|
1911
|
+
version: cachedData.version,
|
|
1912
|
+
digest: cachedData.digest
|
|
1913
|
+
};
|
|
1914
|
+
const parameter = parameters[idx];
|
|
1915
|
+
if (typeof parameter !== "object" || !("MutableReference" in parameter || "Reference" in parameter))
|
|
1916
|
+
return arg;
|
|
1917
|
+
return {
|
|
1918
|
+
objectId: cachedData.objectId,
|
|
1919
|
+
initialSharedVersion: owner.Shared.initial_shared_version,
|
|
1920
|
+
mutable: "MutableReference" in parameter
|
|
1921
|
+
};
|
|
1922
|
+
})
|
|
1923
|
+
);
|
|
1924
|
+
txBlock.moveCall(queryTarget, resolvedArgs, typeArgs);
|
|
1663
1925
|
const query = await this.queryClient.fetchQuery({
|
|
1926
|
+
retry: this.retryFn,
|
|
1927
|
+
retryDelay: 1e3,
|
|
1664
1928
|
queryKey: queryKeys.rpc.getInspectTxn(queryTarget, args, typeArgs),
|
|
1665
1929
|
queryFn: async () => {
|
|
1666
1930
|
return await callWithRateLimit(
|
|
1667
1931
|
this.tokenBucket,
|
|
1668
|
-
() => this.suiKit.inspectTxn(txBlock)
|
|
1932
|
+
async () => await this.suiKit.inspectTxn(txBlock)
|
|
1669
1933
|
);
|
|
1670
1934
|
}
|
|
1671
1935
|
});
|
|
1672
1936
|
return query;
|
|
1673
1937
|
}
|
|
1938
|
+
async queryGetNormalizedMoveFunction(target) {
|
|
1939
|
+
const { address, module, name } = parseStructTag2(target);
|
|
1940
|
+
return this.queryClient.fetchQuery({
|
|
1941
|
+
queryKey: queryKeys.rpc.getNormalizedMoveFunction(target),
|
|
1942
|
+
queryFn: async () => {
|
|
1943
|
+
return await callWithRateLimit(
|
|
1944
|
+
this.tokenBucket,
|
|
1945
|
+
async () => await this.suiKit.client().getNormalizedMoveFunction({
|
|
1946
|
+
package: address,
|
|
1947
|
+
module,
|
|
1948
|
+
function: name
|
|
1949
|
+
})
|
|
1950
|
+
);
|
|
1951
|
+
}
|
|
1952
|
+
});
|
|
1953
|
+
}
|
|
1674
1954
|
/**
|
|
1675
1955
|
* @description Provides cache for getObject of the SuiKit.
|
|
1676
1956
|
* @param objectId
|
|
@@ -1678,12 +1958,19 @@ var ScallopCache = class {
|
|
|
1678
1958
|
* @returns Promise<SuiObjectResponse>
|
|
1679
1959
|
*/
|
|
1680
1960
|
async queryGetObject(objectId, options) {
|
|
1961
|
+
options = {
|
|
1962
|
+
...options,
|
|
1963
|
+
showOwner: true,
|
|
1964
|
+
showContent: true
|
|
1965
|
+
};
|
|
1681
1966
|
return this.queryClient.fetchQuery({
|
|
1682
|
-
|
|
1967
|
+
retry: this.retryFn,
|
|
1968
|
+
retryDelay: 1e3,
|
|
1969
|
+
queryKey: queryKeys.rpc.getObject(objectId, options),
|
|
1683
1970
|
queryFn: async () => {
|
|
1684
1971
|
return await callWithRateLimit(
|
|
1685
1972
|
this.tokenBucket,
|
|
1686
|
-
() => this.client.getObject({
|
|
1973
|
+
async () => await this.client.getObject({
|
|
1687
1974
|
id: objectId,
|
|
1688
1975
|
options
|
|
1689
1976
|
})
|
|
@@ -1702,16 +1989,36 @@ var ScallopCache = class {
|
|
|
1702
1989
|
if (objectIds.length === 0)
|
|
1703
1990
|
return [];
|
|
1704
1991
|
return this.queryClient.fetchQuery({
|
|
1992
|
+
retry: this.retryFn,
|
|
1993
|
+
retryDelay: 1e3,
|
|
1705
1994
|
queryKey: queryKeys.rpc.getObjects(
|
|
1706
1995
|
objectIds,
|
|
1707
1996
|
this.walletAddress,
|
|
1708
1997
|
options
|
|
1709
1998
|
),
|
|
1710
1999
|
queryFn: async () => {
|
|
1711
|
-
|
|
2000
|
+
const results = await callWithRateLimit(
|
|
1712
2001
|
this.tokenBucket,
|
|
1713
|
-
() => this.suiKit.getObjects(objectIds, options)
|
|
2002
|
+
async () => await this.suiKit.getObjects(objectIds, options)
|
|
1714
2003
|
);
|
|
2004
|
+
if (results) {
|
|
2005
|
+
results.forEach((result) => {
|
|
2006
|
+
this.queryClient.setQueriesData(
|
|
2007
|
+
{
|
|
2008
|
+
exact: false,
|
|
2009
|
+
queryKey: queryKeys.rpc.getObject(result.objectId, options)
|
|
2010
|
+
},
|
|
2011
|
+
{
|
|
2012
|
+
data: result,
|
|
2013
|
+
error: null
|
|
2014
|
+
},
|
|
2015
|
+
{
|
|
2016
|
+
updatedAt: Date.now()
|
|
2017
|
+
}
|
|
2018
|
+
);
|
|
2019
|
+
});
|
|
2020
|
+
}
|
|
2021
|
+
return results;
|
|
1715
2022
|
}
|
|
1716
2023
|
});
|
|
1717
2024
|
}
|
|
@@ -1722,44 +2029,94 @@ var ScallopCache = class {
|
|
|
1722
2029
|
*/
|
|
1723
2030
|
async queryGetOwnedObjects(input) {
|
|
1724
2031
|
return this.queryClient.fetchQuery({
|
|
2032
|
+
retry: this.retryFn,
|
|
2033
|
+
retryDelay: 1e3,
|
|
1725
2034
|
queryKey: queryKeys.rpc.getOwnedObjects(input),
|
|
1726
2035
|
queryFn: async () => {
|
|
1727
|
-
|
|
2036
|
+
const results = await callWithRateLimit(
|
|
1728
2037
|
this.tokenBucket,
|
|
1729
|
-
() => this.client.getOwnedObjects(input)
|
|
2038
|
+
async () => await this.client.getOwnedObjects(input)
|
|
1730
2039
|
);
|
|
2040
|
+
if (results && results.data.length > 0) {
|
|
2041
|
+
results.data.filter(
|
|
2042
|
+
(result) => !!result.data
|
|
2043
|
+
).forEach((result) => {
|
|
2044
|
+
this.queryClient.setQueriesData(
|
|
2045
|
+
{
|
|
2046
|
+
exact: false,
|
|
2047
|
+
queryKey: queryKeys.rpc.getObject(
|
|
2048
|
+
result.data.objectId,
|
|
2049
|
+
input.options ?? {}
|
|
2050
|
+
)
|
|
2051
|
+
},
|
|
2052
|
+
{
|
|
2053
|
+
data: result.data,
|
|
2054
|
+
error: null
|
|
2055
|
+
},
|
|
2056
|
+
{
|
|
2057
|
+
updatedAt: Date.now()
|
|
2058
|
+
}
|
|
2059
|
+
);
|
|
2060
|
+
});
|
|
2061
|
+
}
|
|
2062
|
+
return results;
|
|
1731
2063
|
}
|
|
1732
2064
|
});
|
|
1733
2065
|
}
|
|
1734
2066
|
async queryGetDynamicFields(input) {
|
|
1735
2067
|
return this.queryClient.fetchQuery({
|
|
2068
|
+
retry: this.retryFn,
|
|
2069
|
+
retryDelay: 1e3,
|
|
1736
2070
|
queryKey: queryKeys.rpc.getDynamicFields(input),
|
|
1737
2071
|
queryFn: async () => {
|
|
1738
2072
|
return await callWithRateLimit(
|
|
1739
2073
|
this.tokenBucket,
|
|
1740
|
-
() => this.client.getDynamicFields(input)
|
|
2074
|
+
async () => await this.client.getDynamicFields(input)
|
|
1741
2075
|
);
|
|
1742
2076
|
}
|
|
1743
2077
|
});
|
|
1744
2078
|
}
|
|
1745
2079
|
async queryGetDynamicFieldObject(input) {
|
|
1746
2080
|
return this.queryClient.fetchQuery({
|
|
2081
|
+
retry: this.retryFn,
|
|
2082
|
+
retryDelay: (attemptIndex) => Math.min(1e3 * attemptIndex, 8e3),
|
|
1747
2083
|
queryKey: queryKeys.rpc.getDynamicFieldObject(input),
|
|
1748
2084
|
queryFn: async () => {
|
|
1749
|
-
|
|
2085
|
+
const result = await callWithRateLimit(
|
|
1750
2086
|
this.tokenBucket,
|
|
1751
2087
|
() => this.client.getDynamicFieldObject(input)
|
|
1752
2088
|
);
|
|
2089
|
+
if (result?.data) {
|
|
2090
|
+
this.queryClient.setQueriesData(
|
|
2091
|
+
{
|
|
2092
|
+
exact: false,
|
|
2093
|
+
queryKey: queryKeys.rpc.getObject(result?.data.objectId, {
|
|
2094
|
+
showContent: true,
|
|
2095
|
+
showOwner: true
|
|
2096
|
+
})
|
|
2097
|
+
},
|
|
2098
|
+
{
|
|
2099
|
+
data: result.data,
|
|
2100
|
+
error: null
|
|
2101
|
+
},
|
|
2102
|
+
{
|
|
2103
|
+
updatedAt: Date.now()
|
|
2104
|
+
}
|
|
2105
|
+
);
|
|
2106
|
+
}
|
|
2107
|
+
return result;
|
|
1753
2108
|
}
|
|
1754
2109
|
});
|
|
1755
2110
|
}
|
|
1756
2111
|
async queryGetAllCoinBalances(owner) {
|
|
1757
2112
|
return this.queryClient.fetchQuery({
|
|
2113
|
+
retry: this.retryFn,
|
|
2114
|
+
retryDelay: 1e3,
|
|
1758
2115
|
queryKey: queryKeys.rpc.getAllCoinBalances(owner),
|
|
1759
2116
|
queryFn: async () => {
|
|
1760
2117
|
const allBalances = await callWithRateLimit(
|
|
1761
2118
|
this.tokenBucket,
|
|
1762
|
-
() => this.client.getAllBalances({ owner })
|
|
2119
|
+
async () => await this.client.getAllBalances({ owner })
|
|
1763
2120
|
);
|
|
1764
2121
|
if (!allBalances)
|
|
1765
2122
|
return {};
|
|
@@ -2472,7 +2829,7 @@ var getBorrowIncentivePools = async (query, borrowIncentiveCoinNames = [
|
|
|
2472
2829
|
...SUPPORT_BORROW_INCENTIVE_POOLS
|
|
2473
2830
|
], indexer = false, marketPools, coinPrices) => {
|
|
2474
2831
|
const borrowIncentivePools = {};
|
|
2475
|
-
marketPools = marketPools ?? await query.getMarketPools(void 0, { coinPrices, indexer });
|
|
2832
|
+
marketPools = marketPools ?? (await query.getMarketPools(void 0, { coinPrices, indexer })).pools;
|
|
2476
2833
|
coinPrices = coinPrices ?? await query.getAllCoinPrices({ marketPools });
|
|
2477
2834
|
if (indexer) {
|
|
2478
2835
|
const borrowIncentivePoolsIndexer = await query.indexer.getBorrowIncentivePools();
|
|
@@ -2497,7 +2854,10 @@ var getBorrowIncentivePools = async (query, borrowIncentiveCoinNames = [
|
|
|
2497
2854
|
);
|
|
2498
2855
|
for (const pool of borrowIncentivePoolsQueryData?.incentive_pools ?? []) {
|
|
2499
2856
|
const borrowIncentivePoolPoints = {};
|
|
2500
|
-
const parsedBorrowIncentivePoolData = parseOriginBorrowIncentivePoolData(
|
|
2857
|
+
const parsedBorrowIncentivePoolData = parseOriginBorrowIncentivePoolData(
|
|
2858
|
+
query.utils,
|
|
2859
|
+
pool
|
|
2860
|
+
);
|
|
2501
2861
|
const poolCoinType = normalizeStructTag3(pool.pool_type.name);
|
|
2502
2862
|
const poolCoinName = query.utils.parseCoinNameFromType(
|
|
2503
2863
|
poolCoinType
|
|
@@ -2511,12 +2871,9 @@ var getBorrowIncentivePools = async (query, borrowIncentiveCoinNames = [
|
|
|
2511
2871
|
parsedBorrowIncentivePoolData.poolPoints
|
|
2512
2872
|
)) {
|
|
2513
2873
|
const rewardCoinType = poolPoint.pointType;
|
|
2514
|
-
|
|
2874
|
+
const rewardCoinName = query.utils.parseCoinNameFromType(
|
|
2515
2875
|
rewardCoinType
|
|
2516
2876
|
);
|
|
2517
|
-
if (sCoinRawNameToName[rewardCoinName]) {
|
|
2518
|
-
rewardCoinName = sCoinRawNameToName[rewardCoinName];
|
|
2519
|
-
}
|
|
2520
2877
|
const rewardCoinDecimal = query.utils.getCoinDecimal(rewardCoinName);
|
|
2521
2878
|
const rewardCoinPrice = coinPrices?.[rewardCoinName] ?? 0;
|
|
2522
2879
|
const symbol = query.utils.parseSymbol(rewardCoinName);
|
|
@@ -2705,9 +3062,14 @@ var isolatedAssetZod = zod2.object({
|
|
|
2705
3062
|
})
|
|
2706
3063
|
});
|
|
2707
3064
|
var isolatedAssetKeyType = `0xe7dbb371a9595631f7964b7ece42255ad0e738cc85fe6da26c7221b220f01af6::market_dynamic_keys::IsolatedAssetKey`;
|
|
2708
|
-
var getIsolatedAssets = async (
|
|
3065
|
+
var getIsolatedAssets = async (query) => {
|
|
3066
|
+
if (SUPPORT_POOLS.every((t) => !!POOL_ADDRESSES[t])) {
|
|
3067
|
+
return SUPPORT_POOLS.filter(
|
|
3068
|
+
(t) => !!POOL_ADDRESSES[t]?.isolatedAssetKey && !!POOL_ADDRESSES[t]?.coinType
|
|
3069
|
+
).map((t) => POOL_ADDRESSES[t]?.coinType);
|
|
3070
|
+
}
|
|
2709
3071
|
try {
|
|
2710
|
-
const marketObject = address.get("core.market");
|
|
3072
|
+
const marketObject = query.address.get("core.market");
|
|
2711
3073
|
const isolatedAssets = [];
|
|
2712
3074
|
if (!marketObject)
|
|
2713
3075
|
return isolatedAssets;
|
|
@@ -2717,7 +3079,7 @@ var getIsolatedAssets = async (address) => {
|
|
|
2717
3079
|
return dynamicField.name.type === isolatedAssetKeyType;
|
|
2718
3080
|
};
|
|
2719
3081
|
do {
|
|
2720
|
-
const response = await
|
|
3082
|
+
const response = await query.cache.queryGetDynamicFields({
|
|
2721
3083
|
parentId: marketObject,
|
|
2722
3084
|
cursor: nextCursor,
|
|
2723
3085
|
limit: 10
|
|
@@ -2740,32 +3102,30 @@ var getIsolatedAssets = async (address) => {
|
|
|
2740
3102
|
}
|
|
2741
3103
|
};
|
|
2742
3104
|
var isIsolatedAsset = async (utils, coinName) => {
|
|
2743
|
-
|
|
2744
|
-
|
|
2745
|
-
|
|
2746
|
-
|
|
2747
|
-
|
|
2748
|
-
|
|
2749
|
-
|
|
2750
|
-
|
|
2751
|
-
|
|
3105
|
+
if (POOL_ADDRESSES[coinName]) {
|
|
3106
|
+
return !!POOL_ADDRESSES[coinName].isolatedAssetKey;
|
|
3107
|
+
}
|
|
3108
|
+
const marketObject = utils.address.get("core.market");
|
|
3109
|
+
const cachedData = utils.address.cache.queryClient.getQueryData([
|
|
3110
|
+
"getDynamicFields",
|
|
3111
|
+
marketObject
|
|
3112
|
+
]);
|
|
3113
|
+
if (cachedData) {
|
|
3114
|
+
const coinType2 = utils.parseCoinType(coinName);
|
|
3115
|
+
return cachedData.includes(coinType2);
|
|
3116
|
+
}
|
|
3117
|
+
const coinType = utils.parseCoinType(coinName).slice(2);
|
|
3118
|
+
const object = await utils.cache.queryGetDynamicFieldObject({
|
|
3119
|
+
parentId: marketObject,
|
|
3120
|
+
name: {
|
|
3121
|
+
type: isolatedAssetKeyType,
|
|
3122
|
+
value: coinType
|
|
2752
3123
|
}
|
|
2753
|
-
|
|
2754
|
-
|
|
2755
|
-
|
|
2756
|
-
name: {
|
|
2757
|
-
type: isolatedAssetKeyType,
|
|
2758
|
-
value: coinType
|
|
2759
|
-
}
|
|
2760
|
-
});
|
|
2761
|
-
const parsedData = isolatedAssetZod.safeParse(object?.data?.content);
|
|
2762
|
-
if (!parsedData.success)
|
|
2763
|
-
return false;
|
|
2764
|
-
return parsedData.data.fields.value;
|
|
2765
|
-
} catch (e) {
|
|
2766
|
-
console.error(e);
|
|
3124
|
+
});
|
|
3125
|
+
const parsedData = isolatedAssetZod.safeParse(object?.data?.content);
|
|
3126
|
+
if (!parsedData.success)
|
|
2767
3127
|
return false;
|
|
2768
|
-
|
|
3128
|
+
return parsedData.data.fields.value;
|
|
2769
3129
|
};
|
|
2770
3130
|
|
|
2771
3131
|
// src/queries/borrowLimitQuery.ts
|
|
@@ -2808,6 +3168,17 @@ var getBorrowLimit = async (utils, poolName) => {
|
|
|
2808
3168
|
}
|
|
2809
3169
|
};
|
|
2810
3170
|
|
|
3171
|
+
// src/queries/objectsQuery.ts
|
|
3172
|
+
var queryMultipleObjects = async (cache, objectIds, options, partitionSize = 50) => {
|
|
3173
|
+
const objectIdsPartition = partitionArray(objectIds, partitionSize);
|
|
3174
|
+
const objects = [];
|
|
3175
|
+
for (const objectIds2 of objectIdsPartition) {
|
|
3176
|
+
const result = await cache.queryGetObjects(objectIds2, options);
|
|
3177
|
+
objects.push(...result);
|
|
3178
|
+
}
|
|
3179
|
+
return objects;
|
|
3180
|
+
};
|
|
3181
|
+
|
|
2811
3182
|
// src/queries/coreQuery.ts
|
|
2812
3183
|
var queryMarket = async (query, indexer = false, coinPrices) => {
|
|
2813
3184
|
coinPrices = coinPrices ?? await query.utils.getCoinPrices() ?? {};
|
|
@@ -2864,19 +3235,15 @@ var queryMarket = async (query, indexer = false, coinPrices) => {
|
|
|
2864
3235
|
borrowRateOnMidKink: pool.borrowRateOnMidKink,
|
|
2865
3236
|
highKink: pool.highKink,
|
|
2866
3237
|
midKink: pool.midKink,
|
|
2867
|
-
minBorrowAmount: pool.minBorrowAmount
|
|
3238
|
+
minBorrowAmount: pool.minBorrowAmount,
|
|
3239
|
+
isIsolated: await isIsolatedAsset(query.utils, poolCoinName),
|
|
3240
|
+
supplyLimit: await getSupplyLimit(query.utils, poolCoinName) ?? "0",
|
|
3241
|
+
borrowLimit: await getBorrowLimit(query.utils, poolCoinName) ?? "0"
|
|
2868
3242
|
});
|
|
2869
3243
|
const calculatedMarketPoolData = calculateMarketPoolData(
|
|
2870
3244
|
query.utils,
|
|
2871
3245
|
parsedMarketPoolData
|
|
2872
3246
|
);
|
|
2873
|
-
const coinDecimal = query.utils.getCoinDecimal(poolCoinName);
|
|
2874
|
-
const maxSupplyCoin = BigNumber3(
|
|
2875
|
-
await getSupplyLimit(query.utils, poolCoinName) ?? "0"
|
|
2876
|
-
).shiftedBy(-coinDecimal).toNumber();
|
|
2877
|
-
const maxBorrowCoin = BigNumber3(
|
|
2878
|
-
await getBorrowLimit(query.utils, poolCoinName) ?? "0"
|
|
2879
|
-
).shiftedBy(-coinDecimal).toNumber();
|
|
2880
3247
|
pools[poolCoinName] = {
|
|
2881
3248
|
coinName: poolCoinName,
|
|
2882
3249
|
symbol: query.utils.parseSymbol(poolCoinName),
|
|
@@ -2886,7 +3253,6 @@ var queryMarket = async (query, indexer = false, coinPrices) => {
|
|
|
2886
3253
|
query.utils.parseMarketCoinName(poolCoinName)
|
|
2887
3254
|
),
|
|
2888
3255
|
coinWrappedType: query.utils.getCoinWrappedType(poolCoinName),
|
|
2889
|
-
coinDecimal,
|
|
2890
3256
|
coinPrice,
|
|
2891
3257
|
highKink: parsedMarketPoolData.highKink,
|
|
2892
3258
|
midKink: parsedMarketPoolData.midKink,
|
|
@@ -2895,10 +3261,6 @@ var queryMarket = async (query, indexer = false, coinPrices) => {
|
|
|
2895
3261
|
borrowFee: parsedMarketPoolData.borrowFee,
|
|
2896
3262
|
marketCoinSupplyAmount: parsedMarketPoolData.marketCoinSupplyAmount,
|
|
2897
3263
|
minBorrowAmount: parsedMarketPoolData.minBorrowAmount,
|
|
2898
|
-
isIsolated: await isIsolatedAsset(query.utils, poolCoinName),
|
|
2899
|
-
// isIsolated: false,
|
|
2900
|
-
maxSupplyCoin,
|
|
2901
|
-
maxBorrowCoin,
|
|
2902
3264
|
...calculatedMarketPoolData
|
|
2903
3265
|
};
|
|
2904
3266
|
}
|
|
@@ -2914,10 +3276,11 @@ var queryMarket = async (query, indexer = false, coinPrices) => {
|
|
|
2914
3276
|
collateralFactor: collateral.collateralFactor,
|
|
2915
3277
|
liquidationFactor: collateral.liquidationFactor,
|
|
2916
3278
|
liquidationDiscount: collateral.liquidationDiscount,
|
|
2917
|
-
|
|
3279
|
+
liquidationPenalty: collateral.liquidationPanelty,
|
|
2918
3280
|
liquidationReserveFactor: collateral.liquidationReserveFactor,
|
|
2919
3281
|
maxCollateralAmount: collateral.maxCollateralAmount,
|
|
2920
|
-
totalCollateralAmount: collateral.totalCollateralAmount
|
|
3282
|
+
totalCollateralAmount: collateral.totalCollateralAmount,
|
|
3283
|
+
isIsolated: await isIsolatedAsset(query.utils, collateralCoinName)
|
|
2921
3284
|
});
|
|
2922
3285
|
const calculatedMarketCollateralData = calculateMarketCollateralData(
|
|
2923
3286
|
query.utils,
|
|
@@ -2929,14 +3292,12 @@ var queryMarket = async (query, indexer = false, coinPrices) => {
|
|
|
2929
3292
|
coinType,
|
|
2930
3293
|
marketCoinType: query.utils.parseMarketCoinType(collateralCoinName),
|
|
2931
3294
|
coinWrappedType: query.utils.getCoinWrappedType(collateralCoinName),
|
|
2932
|
-
coinDecimal: query.utils.getCoinDecimal(collateralCoinName),
|
|
2933
3295
|
coinPrice,
|
|
2934
3296
|
collateralFactor: parsedMarketCollateralData.collateralFactor,
|
|
2935
3297
|
liquidationFactor: parsedMarketCollateralData.liquidationFactor,
|
|
2936
3298
|
liquidationDiscount: parsedMarketCollateralData.liquidationDiscount,
|
|
2937
|
-
|
|
3299
|
+
liquidationPenalty: parsedMarketCollateralData.liquidationPenalty,
|
|
2938
3300
|
liquidationReserveFactor: parsedMarketCollateralData.liquidationReserveFactor,
|
|
2939
|
-
isIsolated: await isIsolatedAsset(query.utils, collateralCoinName),
|
|
2940
3301
|
...calculatedMarketCollateralData
|
|
2941
3302
|
};
|
|
2942
3303
|
}
|
|
@@ -2946,44 +3307,216 @@ var queryMarket = async (query, indexer = false, coinPrices) => {
|
|
|
2946
3307
|
// data: marketData,
|
|
2947
3308
|
};
|
|
2948
3309
|
};
|
|
2949
|
-
var
|
|
2950
|
-
const
|
|
2951
|
-
|
|
2952
|
-
|
|
2953
|
-
|
|
3310
|
+
var queryRequiredMarketObjects = async (query, poolCoinNames) => {
|
|
3311
|
+
const tasks = poolCoinNames.map((t) => ({
|
|
3312
|
+
poolCoinName: t,
|
|
3313
|
+
balanceSheet: POOL_ADDRESSES[t]?.lendingPoolAddress,
|
|
3314
|
+
collateralStat: POOL_ADDRESSES[t]?.collateralPoolAddress,
|
|
3315
|
+
borrowDynamic: POOL_ADDRESSES[t]?.borrowDynamic,
|
|
3316
|
+
interestModel: POOL_ADDRESSES[t]?.interestModel,
|
|
3317
|
+
riskModel: POOL_ADDRESSES[t]?.riskModel,
|
|
3318
|
+
borrowFeeKey: POOL_ADDRESSES[t]?.borrowFeeKey,
|
|
3319
|
+
supplyLimitKey: POOL_ADDRESSES[t]?.supplyLimitKey,
|
|
3320
|
+
borrowLimitKey: POOL_ADDRESSES[t]?.borrowLimitKey,
|
|
3321
|
+
isolatedAssetKey: POOL_ADDRESSES[t]?.isolatedAssetKey
|
|
3322
|
+
}));
|
|
3323
|
+
const [
|
|
3324
|
+
balanceSheetObjects,
|
|
3325
|
+
collateralStatObjects,
|
|
3326
|
+
borrowDynamicObjects,
|
|
3327
|
+
interestModelObjects,
|
|
3328
|
+
riskModelObjects,
|
|
3329
|
+
borrowFeeObjects,
|
|
3330
|
+
supplyLimitObjects,
|
|
3331
|
+
borrowLimitObjects,
|
|
3332
|
+
isolatedAssetObjects
|
|
3333
|
+
] = await Promise.all([
|
|
3334
|
+
queryMultipleObjects(
|
|
3335
|
+
query.cache,
|
|
3336
|
+
tasks.map((task) => task.balanceSheet).filter((t) => !!t)
|
|
3337
|
+
),
|
|
3338
|
+
queryMultipleObjects(
|
|
3339
|
+
query.cache,
|
|
3340
|
+
tasks.map((task) => task.collateralStat).filter((t) => !!t)
|
|
3341
|
+
),
|
|
3342
|
+
queryMultipleObjects(
|
|
3343
|
+
query.cache,
|
|
3344
|
+
tasks.map((task) => task.borrowDynamic).filter((t) => !!t)
|
|
3345
|
+
),
|
|
3346
|
+
queryMultipleObjects(
|
|
3347
|
+
query.cache,
|
|
3348
|
+
tasks.map((task) => task.interestModel).filter((t) => !!t)
|
|
3349
|
+
),
|
|
3350
|
+
queryMultipleObjects(
|
|
3351
|
+
query.cache,
|
|
3352
|
+
tasks.map((task) => task.riskModel).filter((t) => !!t)
|
|
3353
|
+
),
|
|
3354
|
+
queryMultipleObjects(
|
|
3355
|
+
query.cache,
|
|
3356
|
+
tasks.map((task) => task.borrowFeeKey).filter((t) => !!t)
|
|
3357
|
+
),
|
|
3358
|
+
queryMultipleObjects(
|
|
3359
|
+
query.cache,
|
|
3360
|
+
tasks.map((task) => task.supplyLimitKey).filter((t) => !!t)
|
|
3361
|
+
),
|
|
3362
|
+
queryMultipleObjects(
|
|
3363
|
+
query.cache,
|
|
3364
|
+
tasks.map((task) => task.borrowLimitKey).filter((t) => !!t)
|
|
3365
|
+
),
|
|
3366
|
+
queryMultipleObjects(
|
|
3367
|
+
query.cache,
|
|
3368
|
+
tasks.map((task) => task.isolatedAssetKey).filter((t) => !!t)
|
|
3369
|
+
)
|
|
3370
|
+
]);
|
|
3371
|
+
const mapObjects = (tasks2, fetchedObjects) => {
|
|
3372
|
+
const resultMap = {};
|
|
3373
|
+
let fetchedIndex = 0;
|
|
3374
|
+
for (const task of tasks2) {
|
|
3375
|
+
const key = task[Object.keys(task)[1]];
|
|
3376
|
+
if (key) {
|
|
3377
|
+
resultMap[task.poolCoinName] = fetchedObjects[fetchedIndex];
|
|
3378
|
+
fetchedIndex++;
|
|
3379
|
+
}
|
|
3380
|
+
}
|
|
3381
|
+
return resultMap;
|
|
3382
|
+
};
|
|
3383
|
+
const balanceSheetMap = mapObjects(tasks, balanceSheetObjects);
|
|
3384
|
+
const collateralStatMap = mapObjects(tasks, collateralStatObjects);
|
|
3385
|
+
const borrowDynamicMap = mapObjects(tasks, borrowDynamicObjects);
|
|
3386
|
+
const interestModelMap = mapObjects(tasks, interestModelObjects);
|
|
3387
|
+
const riskModelMap = mapObjects(tasks, riskModelObjects);
|
|
3388
|
+
const borrowFeeMap = mapObjects(tasks, borrowFeeObjects);
|
|
3389
|
+
const supplyLimitMap = mapObjects(tasks, supplyLimitObjects);
|
|
3390
|
+
const borrowLimitMap = mapObjects(tasks, borrowLimitObjects);
|
|
3391
|
+
const isolatedAssetMap = mapObjects(tasks, isolatedAssetObjects);
|
|
3392
|
+
return poolCoinNames.reduce(
|
|
3393
|
+
(acc, name) => {
|
|
3394
|
+
acc[name] = {
|
|
3395
|
+
balanceSheet: balanceSheetMap[name],
|
|
3396
|
+
collateralStat: collateralStatMap[name],
|
|
3397
|
+
borrowDynamic: borrowDynamicMap[name],
|
|
3398
|
+
interestModel: interestModelMap[name],
|
|
3399
|
+
riskModel: riskModelMap[name],
|
|
3400
|
+
borrowFeeKey: borrowFeeMap[name],
|
|
3401
|
+
supplyLimitKey: supplyLimitMap[name],
|
|
3402
|
+
borrowLimitKey: borrowLimitMap[name],
|
|
3403
|
+
isolatedAssetKey: isolatedAssetMap[name]
|
|
3404
|
+
};
|
|
3405
|
+
return acc;
|
|
3406
|
+
},
|
|
3407
|
+
{}
|
|
3408
|
+
);
|
|
3409
|
+
};
|
|
3410
|
+
var getMarketPools = async (query, poolCoinNames, indexer = false, coinPrices) => {
|
|
2954
3411
|
coinPrices = coinPrices ?? await query.utils.getCoinPrices();
|
|
2955
|
-
const
|
|
3412
|
+
const pools = {};
|
|
3413
|
+
const collaterals = {};
|
|
2956
3414
|
if (indexer) {
|
|
2957
|
-
const
|
|
2958
|
-
const
|
|
2959
|
-
|
|
2960
|
-
|
|
2961
|
-
|
|
2962
|
-
|
|
2963
|
-
|
|
2964
|
-
|
|
2965
|
-
|
|
3415
|
+
const marketIndexer = await query.indexer.getMarket();
|
|
3416
|
+
const updatePools = (item) => {
|
|
3417
|
+
item.coinPrice = coinPrices[item.coinName] ?? item.coinPrice;
|
|
3418
|
+
item.coinWrappedType = query.utils.getCoinWrappedType(item.coinName);
|
|
3419
|
+
pools[item.coinName] = item;
|
|
3420
|
+
};
|
|
3421
|
+
const updateCollaterals = (item) => {
|
|
3422
|
+
item.coinPrice = coinPrices[item.coinName] ?? item.coinPrice;
|
|
3423
|
+
item.coinWrappedType = query.utils.getCoinWrappedType(item.coinName);
|
|
3424
|
+
collaterals[item.coinName] = item;
|
|
3425
|
+
};
|
|
3426
|
+
Object.values(marketIndexer.pools).forEach(updatePools);
|
|
3427
|
+
Object.values(marketIndexer.collaterals).forEach(updateCollaterals);
|
|
3428
|
+
return {
|
|
3429
|
+
pools,
|
|
3430
|
+
collaterals
|
|
2966
3431
|
};
|
|
2967
|
-
Object.values(marketPoolsIndexer).forEach(updateMarketPool);
|
|
2968
|
-
return marketPools;
|
|
2969
3432
|
}
|
|
3433
|
+
const requiredObjects = await queryRequiredMarketObjects(
|
|
3434
|
+
query,
|
|
3435
|
+
poolCoinNames
|
|
3436
|
+
);
|
|
2970
3437
|
await Promise.allSettled(
|
|
2971
3438
|
poolCoinNames.map(async (poolCoinName) => {
|
|
2972
|
-
|
|
2973
|
-
|
|
2974
|
-
|
|
2975
|
-
|
|
2976
|
-
|
|
2977
|
-
|
|
2978
|
-
|
|
2979
|
-
|
|
2980
|
-
|
|
3439
|
+
try {
|
|
3440
|
+
const result = await getMarketPool(
|
|
3441
|
+
query,
|
|
3442
|
+
poolCoinName,
|
|
3443
|
+
indexer,
|
|
3444
|
+
coinPrices?.[poolCoinName] ?? 0,
|
|
3445
|
+
requiredObjects[poolCoinName]
|
|
3446
|
+
);
|
|
3447
|
+
if (result?.marketPool) {
|
|
3448
|
+
pools[poolCoinName] = result?.marketPool;
|
|
3449
|
+
}
|
|
3450
|
+
if (result?.collateral) {
|
|
3451
|
+
collaterals[poolCoinName] = result.collateral;
|
|
3452
|
+
}
|
|
3453
|
+
} catch (e) {
|
|
3454
|
+
console.error(e);
|
|
2981
3455
|
}
|
|
2982
3456
|
})
|
|
2983
3457
|
);
|
|
2984
|
-
return
|
|
3458
|
+
return {
|
|
3459
|
+
pools,
|
|
3460
|
+
collaterals
|
|
3461
|
+
};
|
|
2985
3462
|
};
|
|
2986
|
-
var
|
|
3463
|
+
var parseMarketPoolObjects = ({
|
|
3464
|
+
balanceSheet,
|
|
3465
|
+
borrowDynamic,
|
|
3466
|
+
collateralStat,
|
|
3467
|
+
interestModel,
|
|
3468
|
+
riskModel,
|
|
3469
|
+
borrowFeeKey,
|
|
3470
|
+
supplyLimitKey,
|
|
3471
|
+
borrowLimitKey,
|
|
3472
|
+
isolatedAssetKey
|
|
3473
|
+
}) => {
|
|
3474
|
+
const _balanceSheet = parseObjectAs(balanceSheet);
|
|
3475
|
+
const _interestModel = parseObjectAs(interestModel);
|
|
3476
|
+
const _borrowDynamic = parseObjectAs(borrowDynamic);
|
|
3477
|
+
const _borrowFee = parseObjectAs(borrowFeeKey);
|
|
3478
|
+
const _supplyLimit = supplyLimitKey ? parseObjectAs(supplyLimitKey) : "0";
|
|
3479
|
+
const _borrowLimit = borrowLimitKey ? parseObjectAs(borrowLimitKey) : "0";
|
|
3480
|
+
const _riskModel = riskModel ? parseObjectAs(riskModel) : void 0;
|
|
3481
|
+
const _collateralStat = collateralStat ? parseObjectAs(collateralStat) : void 0;
|
|
3482
|
+
const parsedOriginMarketCollateral = _riskModel && _collateralStat ? {
|
|
3483
|
+
type: _interestModel.type.fields,
|
|
3484
|
+
isIsolated: !!isolatedAssetKey,
|
|
3485
|
+
collateralFactor: _riskModel.collateral_factor.fields,
|
|
3486
|
+
liquidationFactor: _riskModel.liquidation_factor.fields,
|
|
3487
|
+
liquidationPenalty: _riskModel.liquidation_penalty.fields,
|
|
3488
|
+
liquidationDiscount: _riskModel.liquidation_discount.fields,
|
|
3489
|
+
liquidationReserveFactor: _riskModel.liquidation_revenue_factor.fields,
|
|
3490
|
+
maxCollateralAmount: _riskModel.max_collateral_amount,
|
|
3491
|
+
totalCollateralAmount: _collateralStat.amount
|
|
3492
|
+
} : void 0;
|
|
3493
|
+
return {
|
|
3494
|
+
type: _interestModel.type.fields,
|
|
3495
|
+
maxBorrowRate: _interestModel.max_borrow_rate.fields,
|
|
3496
|
+
interestRate: _borrowDynamic.interest_rate.fields,
|
|
3497
|
+
interestRateScale: _borrowDynamic.interest_rate_scale,
|
|
3498
|
+
borrowIndex: _borrowDynamic.borrow_index,
|
|
3499
|
+
lastUpdated: _borrowDynamic.last_updated,
|
|
3500
|
+
cash: _balanceSheet.cash,
|
|
3501
|
+
debt: _balanceSheet.debt,
|
|
3502
|
+
marketCoinSupply: _balanceSheet.market_coin_supply,
|
|
3503
|
+
reserve: _balanceSheet.revenue,
|
|
3504
|
+
reserveFactor: _interestModel.revenue_factor.fields,
|
|
3505
|
+
borrowWeight: _interestModel.borrow_weight.fields,
|
|
3506
|
+
borrowFeeRate: _borrowFee,
|
|
3507
|
+
baseBorrowRatePerSec: _interestModel.base_borrow_rate_per_sec.fields,
|
|
3508
|
+
borrowRateOnHighKink: _interestModel.borrow_rate_on_high_kink.fields,
|
|
3509
|
+
borrowRateOnMidKink: _interestModel.borrow_rate_on_mid_kink.fields,
|
|
3510
|
+
highKink: _interestModel.high_kink.fields,
|
|
3511
|
+
midKink: _interestModel.mid_kink.fields,
|
|
3512
|
+
minBorrowAmount: _interestModel.min_borrow_amount,
|
|
3513
|
+
isIsolated: !!isolatedAssetKey,
|
|
3514
|
+
supplyLimit: _supplyLimit,
|
|
3515
|
+
borrowLimit: _borrowLimit,
|
|
3516
|
+
parsedOriginMarketCollateral
|
|
3517
|
+
};
|
|
3518
|
+
};
|
|
3519
|
+
var getMarketPool = async (query, poolCoinName, indexer = false, coinPrice, requiredObjects) => {
|
|
2987
3520
|
coinPrice = coinPrice ?? (await query.utils.getCoinPrices())?.[poolCoinName];
|
|
2988
3521
|
if (indexer) {
|
|
2989
3522
|
const marketPoolIndexer = await query.indexer.getMarketPool(poolCoinName);
|
|
@@ -2994,135 +3527,70 @@ var getMarketPool = async (query, poolCoinName, indexer = false, marketObject, c
|
|
|
2994
3527
|
marketPoolIndexer.coinWrappedType = query.utils.getCoinWrappedType(
|
|
2995
3528
|
marketPoolIndexer.coinName
|
|
2996
3529
|
);
|
|
2997
|
-
|
|
2998
|
-
|
|
2999
|
-
|
|
3000
|
-
|
|
3001
|
-
|
|
3002
|
-
|
|
3003
|
-
|
|
3004
|
-
|
|
3005
|
-
|
|
3006
|
-
const coinType = query.utils.parseCoinType(poolCoinName);
|
|
3007
|
-
const balanceSheetParentId = fields.vault.fields.balance_sheets.fields.table.fields.id.id;
|
|
3008
|
-
const balanceSheetDynamicFieldObjectResponse = await query.cache.queryGetDynamicFieldObject({
|
|
3009
|
-
parentId: balanceSheetParentId,
|
|
3010
|
-
name: {
|
|
3011
|
-
type: "0x1::type_name::TypeName",
|
|
3012
|
-
value: {
|
|
3013
|
-
name: coinType.substring(2)
|
|
3014
|
-
}
|
|
3015
|
-
}
|
|
3016
|
-
});
|
|
3017
|
-
const balanceSheetDynamicFieldObject = balanceSheetDynamicFieldObjectResponse?.data;
|
|
3018
|
-
if (!(balanceSheetDynamicFieldObject && balanceSheetDynamicFieldObject.content && "fields" in balanceSheetDynamicFieldObject.content))
|
|
3019
|
-
throw new Error(
|
|
3020
|
-
`Failed to fetch balanceSheetDynamicFieldObject for ${poolCoinName}: ${balanceSheetDynamicFieldObjectResponse?.error?.code.toString()}`
|
|
3021
|
-
);
|
|
3022
|
-
const balanceSheet = balanceSheetDynamicFieldObject.content.fields.value.fields;
|
|
3023
|
-
const borrowIndexParentId = fields.borrow_dynamics.fields.table.fields.id.id;
|
|
3024
|
-
const borrowIndexDynamicFieldObjectResponse = await query.cache.queryGetDynamicFieldObject({
|
|
3025
|
-
parentId: borrowIndexParentId,
|
|
3026
|
-
name: {
|
|
3027
|
-
type: "0x1::type_name::TypeName",
|
|
3028
|
-
value: {
|
|
3029
|
-
name: coinType.substring(2)
|
|
3030
|
-
}
|
|
3031
|
-
}
|
|
3032
|
-
});
|
|
3033
|
-
const borrowIndexDynamicFieldObject = borrowIndexDynamicFieldObjectResponse?.data;
|
|
3034
|
-
if (!(borrowIndexDynamicFieldObject && borrowIndexDynamicFieldObject.content && "fields" in borrowIndexDynamicFieldObject.content))
|
|
3035
|
-
throw new Error(
|
|
3036
|
-
`Failed to fetch borrowIndexDynamicFieldObject for ${poolCoinName}`
|
|
3037
|
-
);
|
|
3038
|
-
const borrowIndex = borrowIndexDynamicFieldObject.content.fields.value.fields;
|
|
3039
|
-
const interestModelParentId = fields.interest_models.fields.table.fields.id.id;
|
|
3040
|
-
const interestModelDynamicFieldObjectResponse = await query.cache.queryGetDynamicFieldObject({
|
|
3041
|
-
parentId: interestModelParentId,
|
|
3042
|
-
name: {
|
|
3043
|
-
type: "0x1::type_name::TypeName",
|
|
3044
|
-
value: {
|
|
3045
|
-
name: coinType.substring(2)
|
|
3046
|
-
}
|
|
3530
|
+
let marketCollateralIndexer = void 0;
|
|
3531
|
+
if (SUPPORT_COLLATERALS.includes(poolCoinName)) {
|
|
3532
|
+
marketCollateralIndexer = await query.indexer.getMarketCollateral(
|
|
3533
|
+
poolCoinName
|
|
3534
|
+
);
|
|
3535
|
+
marketCollateralIndexer.coinPrice = coinPrice ?? marketCollateralIndexer.coinPrice;
|
|
3536
|
+
marketCollateralIndexer.coinWrappedType = query.utils.getCoinWrappedType(
|
|
3537
|
+
marketCollateralIndexer.coinName
|
|
3538
|
+
);
|
|
3047
3539
|
}
|
|
3048
|
-
|
|
3049
|
-
|
|
3050
|
-
|
|
3051
|
-
|
|
3052
|
-
|
|
3053
|
-
|
|
3054
|
-
const
|
|
3055
|
-
const
|
|
3056
|
-
|
|
3057
|
-
|
|
3058
|
-
name: {
|
|
3059
|
-
type: `${BORROW_FEE_PROTOCOL_ID}::market_dynamic_keys::BorrowFeeKey`,
|
|
3060
|
-
value: {
|
|
3061
|
-
type: {
|
|
3062
|
-
name: coinType.substring(2)
|
|
3063
|
-
}
|
|
3064
|
-
}
|
|
3065
|
-
}
|
|
3066
|
-
});
|
|
3067
|
-
const borrowFeeDynamicFieldObject = borrowFeeDynamicFieldObjectResponse?.data;
|
|
3068
|
-
if (!(borrowFeeDynamicFieldObject && borrowFeeDynamicFieldObject.content && "fields" in borrowFeeDynamicFieldObject.content))
|
|
3069
|
-
return { value: "0" };
|
|
3070
|
-
return borrowFeeDynamicFieldObject.content.fields.value.fields;
|
|
3071
|
-
};
|
|
3072
|
-
const parsedMarketPoolData = parseOriginMarketPoolData({
|
|
3073
|
-
type: interestModel.type.fields,
|
|
3074
|
-
maxBorrowRate: interestModel.max_borrow_rate.fields,
|
|
3075
|
-
interestRate: borrowIndex.interest_rate.fields,
|
|
3076
|
-
interestRateScale: borrowIndex.interest_rate_scale,
|
|
3077
|
-
borrowIndex: borrowIndex.borrow_index,
|
|
3078
|
-
lastUpdated: borrowIndex.last_updated,
|
|
3079
|
-
cash: balanceSheet.cash,
|
|
3080
|
-
debt: balanceSheet.debt,
|
|
3081
|
-
marketCoinSupply: balanceSheet.market_coin_supply,
|
|
3082
|
-
reserve: balanceSheet.revenue,
|
|
3083
|
-
reserveFactor: interestModel.revenue_factor.fields,
|
|
3084
|
-
borrowWeight: interestModel.borrow_weight.fields,
|
|
3085
|
-
borrowFeeRate: await getBorrowFee(),
|
|
3086
|
-
baseBorrowRatePerSec: interestModel.base_borrow_rate_per_sec.fields,
|
|
3087
|
-
borrowRateOnHighKink: interestModel.borrow_rate_on_high_kink.fields,
|
|
3088
|
-
borrowRateOnMidKink: interestModel.borrow_rate_on_mid_kink.fields,
|
|
3089
|
-
highKink: interestModel.high_kink.fields,
|
|
3090
|
-
midKink: interestModel.mid_kink.fields,
|
|
3091
|
-
minBorrowAmount: interestModel.min_borrow_amount
|
|
3092
|
-
});
|
|
3540
|
+
return {
|
|
3541
|
+
marketPool: marketPoolIndexer,
|
|
3542
|
+
collateral: marketCollateralIndexer
|
|
3543
|
+
};
|
|
3544
|
+
}
|
|
3545
|
+
requiredObjects ?? (requiredObjects = (await queryRequiredMarketObjects(query, [poolCoinName]))[poolCoinName]);
|
|
3546
|
+
const parsedMarketPoolObjects = parseMarketPoolObjects(requiredObjects);
|
|
3547
|
+
const parsedMarketPoolData = parseOriginMarketPoolData(
|
|
3548
|
+
parsedMarketPoolObjects
|
|
3549
|
+
);
|
|
3093
3550
|
const calculatedMarketPoolData = calculateMarketPoolData(
|
|
3094
3551
|
query.utils,
|
|
3095
3552
|
parsedMarketPoolData
|
|
3096
3553
|
);
|
|
3097
|
-
const
|
|
3098
|
-
|
|
3099
|
-
|
|
3100
|
-
|
|
3101
|
-
const maxBorrowCoin = BigNumber3(
|
|
3102
|
-
await getBorrowLimit(query.utils, poolCoinName) ?? "0"
|
|
3103
|
-
).shiftedBy(-coinDecimal).toNumber();
|
|
3104
|
-
return {
|
|
3554
|
+
const parsedMarketCollateralData = parsedMarketPoolObjects.parsedOriginMarketCollateral ? parseOriginMarketCollateralData(
|
|
3555
|
+
parsedMarketPoolObjects.parsedOriginMarketCollateral
|
|
3556
|
+
) : void 0;
|
|
3557
|
+
const basePoolData = () => ({
|
|
3105
3558
|
coinName: poolCoinName,
|
|
3106
3559
|
symbol: query.utils.parseSymbol(poolCoinName),
|
|
3107
|
-
coinType: query.utils.parseCoinType(poolCoinName),
|
|
3108
3560
|
marketCoinType: query.utils.parseMarketCoinType(poolCoinName),
|
|
3109
|
-
|
|
3110
|
-
|
|
3111
|
-
|
|
3112
|
-
|
|
3113
|
-
|
|
3114
|
-
|
|
3115
|
-
|
|
3116
|
-
|
|
3117
|
-
|
|
3118
|
-
|
|
3119
|
-
|
|
3120
|
-
|
|
3121
|
-
|
|
3122
|
-
|
|
3123
|
-
|
|
3124
|
-
|
|
3125
|
-
|
|
3561
|
+
coinType: query.utils.parseCoinType(poolCoinName)
|
|
3562
|
+
});
|
|
3563
|
+
return {
|
|
3564
|
+
marketPool: {
|
|
3565
|
+
...basePoolData(),
|
|
3566
|
+
sCoinType: query.utils.parseSCoinType(
|
|
3567
|
+
query.utils.parseMarketCoinName(poolCoinName)
|
|
3568
|
+
),
|
|
3569
|
+
coinWrappedType: query.utils.getCoinWrappedType(poolCoinName),
|
|
3570
|
+
coinPrice: coinPrice ?? 0,
|
|
3571
|
+
highKink: parsedMarketPoolData.highKink,
|
|
3572
|
+
midKink: parsedMarketPoolData.midKink,
|
|
3573
|
+
reserveFactor: parsedMarketPoolData.reserveFactor,
|
|
3574
|
+
borrowWeight: parsedMarketPoolData.borrowWeight,
|
|
3575
|
+
borrowFee: parsedMarketPoolData.borrowFee,
|
|
3576
|
+
marketCoinSupplyAmount: parsedMarketPoolData.marketCoinSupplyAmount,
|
|
3577
|
+
minBorrowAmount: parsedMarketPoolData.minBorrowAmount,
|
|
3578
|
+
...calculatedMarketPoolData
|
|
3579
|
+
},
|
|
3580
|
+
collateral: parsedMarketCollateralData ? {
|
|
3581
|
+
...basePoolData(),
|
|
3582
|
+
coinWrappedType: query.utils.getCoinWrappedType(poolCoinName),
|
|
3583
|
+
coinPrice,
|
|
3584
|
+
collateralFactor: parsedMarketCollateralData.collateralFactor,
|
|
3585
|
+
liquidationFactor: parsedMarketCollateralData.liquidationFactor,
|
|
3586
|
+
liquidationDiscount: parsedMarketCollateralData.liquidationDiscount,
|
|
3587
|
+
liquidationPenalty: parsedMarketCollateralData.liquidationPenalty,
|
|
3588
|
+
liquidationReserveFactor: parsedMarketCollateralData.liquidationReserveFactor,
|
|
3589
|
+
...calculateMarketCollateralData(
|
|
3590
|
+
query.utils,
|
|
3591
|
+
parsedMarketCollateralData
|
|
3592
|
+
)
|
|
3593
|
+
} : void 0
|
|
3126
3594
|
};
|
|
3127
3595
|
};
|
|
3128
3596
|
var getMarketCollaterals = async (query, collateralCoinNames = [...SUPPORT_COLLATERALS], indexer = false) => {
|
|
@@ -3217,10 +3685,11 @@ var getMarketCollateral = async (query, collateralCoinName, indexer = false, mar
|
|
|
3217
3685
|
collateralFactor: riskModel.collateral_factor.fields,
|
|
3218
3686
|
liquidationFactor: riskModel.liquidation_factor.fields,
|
|
3219
3687
|
liquidationDiscount: riskModel.liquidation_discount.fields,
|
|
3220
|
-
|
|
3688
|
+
liquidationPenalty: riskModel.liquidation_penalty.fields,
|
|
3221
3689
|
liquidationReserveFactor: riskModel.liquidation_revenue_factor.fields,
|
|
3222
3690
|
maxCollateralAmount: riskModel.max_collateral_amount,
|
|
3223
|
-
totalCollateralAmount: collateralStat.amount
|
|
3691
|
+
totalCollateralAmount: collateralStat.amount,
|
|
3692
|
+
isIsolated: await isIsolatedAsset(query.utils, collateralCoinName)
|
|
3224
3693
|
});
|
|
3225
3694
|
const calculatedMarketCollateralData = calculateMarketCollateralData(
|
|
3226
3695
|
query.utils,
|
|
@@ -3232,14 +3701,12 @@ var getMarketCollateral = async (query, collateralCoinName, indexer = false, mar
|
|
|
3232
3701
|
coinType: query.utils.parseCoinType(collateralCoinName),
|
|
3233
3702
|
marketCoinType: query.utils.parseMarketCoinType(collateralCoinName),
|
|
3234
3703
|
coinWrappedType: query.utils.getCoinWrappedType(collateralCoinName),
|
|
3235
|
-
coinDecimal: query.utils.getCoinDecimal(collateralCoinName),
|
|
3236
3704
|
coinPrice: coinPrice ?? 0,
|
|
3237
3705
|
collateralFactor: parsedMarketCollateralData.collateralFactor,
|
|
3238
3706
|
liquidationFactor: parsedMarketCollateralData.liquidationFactor,
|
|
3239
3707
|
liquidationDiscount: parsedMarketCollateralData.liquidationDiscount,
|
|
3240
|
-
|
|
3708
|
+
liquidationPenalty: parsedMarketCollateralData.liquidationPenalty,
|
|
3241
3709
|
liquidationReserveFactor: parsedMarketCollateralData.liquidationReserveFactor,
|
|
3242
|
-
isIsolated: await isIsolatedAsset(query.utils, collateralCoinName),
|
|
3243
3710
|
...calculatedMarketCollateralData
|
|
3244
3711
|
};
|
|
3245
3712
|
};
|
|
@@ -3275,14 +3742,26 @@ var getObligations = async ({
|
|
|
3275
3742
|
} while (hasNextPage);
|
|
3276
3743
|
const keyObjects = keyObjectsResponse.filter((ref) => !!ref.data);
|
|
3277
3744
|
const obligations = [];
|
|
3745
|
+
const obligationsObjects = await queryMultipleObjects(
|
|
3746
|
+
address.cache,
|
|
3747
|
+
keyObjects.map((ref) => ref.data?.content).filter(
|
|
3748
|
+
(content) => content?.dataType === "moveObject"
|
|
3749
|
+
).map((content) => content.fields.ownership.fields.of),
|
|
3750
|
+
{
|
|
3751
|
+
showContent: true
|
|
3752
|
+
}
|
|
3753
|
+
);
|
|
3278
3754
|
await Promise.allSettled(
|
|
3279
|
-
keyObjects.map(async ({ data }) => {
|
|
3755
|
+
keyObjects.map(async ({ data }, idx) => {
|
|
3280
3756
|
const keyId = data?.objectId;
|
|
3281
3757
|
const content = data?.content;
|
|
3282
3758
|
if (keyId && content && "fields" in content) {
|
|
3283
3759
|
const fields = content.fields;
|
|
3284
3760
|
const obligationId = String(fields.ownership.fields.of);
|
|
3285
|
-
const locked = await getObligationLocked(
|
|
3761
|
+
const locked = await getObligationLocked(
|
|
3762
|
+
address.cache,
|
|
3763
|
+
obligationsObjects[idx]
|
|
3764
|
+
);
|
|
3286
3765
|
obligations.push({ id: obligationId, keyId, locked });
|
|
3287
3766
|
}
|
|
3288
3767
|
})
|
|
@@ -3290,14 +3769,12 @@ var getObligations = async ({
|
|
|
3290
3769
|
return obligations;
|
|
3291
3770
|
};
|
|
3292
3771
|
var getObligationLocked = async (cache, obligation) => {
|
|
3293
|
-
const
|
|
3772
|
+
const obligationObjectData = typeof obligation === "string" ? (await cache.queryGetObject(obligation, {
|
|
3294
3773
|
showContent: true
|
|
3295
3774
|
}))?.data : obligation;
|
|
3296
3775
|
let obligationLocked = false;
|
|
3297
|
-
if (
|
|
3298
|
-
obligationLocked = Boolean(
|
|
3299
|
-
obligationObjectResponse.content.fields.lock_key
|
|
3300
|
-
);
|
|
3776
|
+
if (obligationObjectData && obligationObjectData?.content?.dataType === "moveObject" && "lock_key" in obligationObjectData.content.fields) {
|
|
3777
|
+
obligationLocked = Boolean(obligationObjectData.content.fields.lock_key);
|
|
3301
3778
|
}
|
|
3302
3779
|
return obligationLocked;
|
|
3303
3780
|
};
|
|
@@ -3480,10 +3957,10 @@ var getLendings = async (query, poolCoinNames = [...SUPPORT_POOLS], ownerAddress
|
|
|
3480
3957
|
(marketCoinName) => SUPPORT_SPOOLS.includes(marketCoinName)
|
|
3481
3958
|
);
|
|
3482
3959
|
const coinPrices = await query.utils.getCoinPrices();
|
|
3483
|
-
const marketPools = await query.getMarketPools(poolCoinNames, {
|
|
3960
|
+
const marketPools = (await query.getMarketPools(poolCoinNames, {
|
|
3484
3961
|
indexer,
|
|
3485
3962
|
coinPrices
|
|
3486
|
-
});
|
|
3963
|
+
})).pools;
|
|
3487
3964
|
const spools = await query.getSpools(stakeMarketCoinNames, {
|
|
3488
3965
|
indexer,
|
|
3489
3966
|
marketPools,
|
|
@@ -3651,8 +4128,10 @@ var getLending = async (query, poolCoinName, ownerAddress, indexer = false, mark
|
|
|
3651
4128
|
return lending;
|
|
3652
4129
|
};
|
|
3653
4130
|
var getObligationAccounts = async (query, ownerAddress, indexer = false) => {
|
|
3654
|
-
const
|
|
3655
|
-
const
|
|
4131
|
+
const market = await query.queryMarket({ indexer });
|
|
4132
|
+
const coinPrices = await query.getAllCoinPrices({
|
|
4133
|
+
marketPools: market.pools
|
|
4134
|
+
});
|
|
3656
4135
|
const [coinAmounts, obligations] = await Promise.all([
|
|
3657
4136
|
query.getCoinAmounts(void 0, ownerAddress),
|
|
3658
4137
|
query.getObligations(ownerAddress)
|
|
@@ -3674,17 +4153,21 @@ var getObligationAccounts = async (query, ownerAddress, indexer = false) => {
|
|
|
3674
4153
|
return obligationAccounts;
|
|
3675
4154
|
};
|
|
3676
4155
|
var getObligationAccount = async (query, obligationId, ownerAddress, indexer = false, market, coinPrices, coinAmounts) => {
|
|
4156
|
+
const coinNames = Array.from(
|
|
4157
|
+
/* @__PURE__ */ new Set([...SUPPORT_POOLS, ...SUPPORT_COLLATERALS])
|
|
4158
|
+
);
|
|
3677
4159
|
const collateralAssetCoinNames = [
|
|
3678
4160
|
...SUPPORT_COLLATERALS
|
|
3679
4161
|
];
|
|
3680
|
-
market = market ?? await query.
|
|
4162
|
+
market = market ?? await query.getMarketPools(void 0, { indexer });
|
|
3681
4163
|
coinPrices = coinPrices ?? await query.getAllCoinPrices({ marketPools: market.pools });
|
|
3682
|
-
coinAmounts = coinAmounts
|
|
4164
|
+
coinAmounts = coinAmounts ?? await query.getCoinAmounts(coinNames, ownerAddress);
|
|
3683
4165
|
const [obligationQuery, borrowIncentivePools, borrowIncentiveAccounts] = await Promise.all([
|
|
3684
4166
|
query.queryObligation(obligationId),
|
|
3685
4167
|
query.getBorrowIncentivePools(void 0, {
|
|
3686
4168
|
coinPrices,
|
|
3687
|
-
indexer
|
|
4169
|
+
indexer,
|
|
4170
|
+
marketPools: market.pools
|
|
3688
4171
|
}),
|
|
3689
4172
|
query.getBorrowIncentiveAccounts(obligationId)
|
|
3690
4173
|
]);
|
|
@@ -3822,7 +4305,7 @@ var getObligationAccount = async (query, obligationId, ownerAddress, indexer = f
|
|
|
3822
4305
|
const rewards = [];
|
|
3823
4306
|
Object.entries(borrowIncentiveAccount.pointList).forEach(
|
|
3824
4307
|
([key, accountPoint]) => {
|
|
3825
|
-
const poolPoint = borrowIncentivePool.points[key];
|
|
4308
|
+
const poolPoint = borrowIncentivePool.points[query.utils.parseSCoinTypeNameToMarketCoinName(key)];
|
|
3826
4309
|
if (accountPoint && poolPoint) {
|
|
3827
4310
|
let availableClaimAmount = BigNumber5(0);
|
|
3828
4311
|
let availableClaimCoin = BigNumber5(0);
|
|
@@ -3967,7 +4450,7 @@ var getObligationAccount = async (query, obligationId, ownerAddress, indexer = f
|
|
|
3967
4450
|
return obligationAccount;
|
|
3968
4451
|
};
|
|
3969
4452
|
var getTotalValueLocked = async (query, indexer = false) => {
|
|
3970
|
-
const market = await query.
|
|
4453
|
+
const market = await query.getMarketPools(void 0, { indexer });
|
|
3971
4454
|
let supplyValue = BigNumber5(0);
|
|
3972
4455
|
let borrowValue = BigNumber5(0);
|
|
3973
4456
|
if (indexer) {
|
|
@@ -4088,7 +4571,7 @@ var getPythPrices = async ({
|
|
|
4088
4571
|
};
|
|
4089
4572
|
var getAllCoinPrices = async (query, marketPools, coinPrices) => {
|
|
4090
4573
|
coinPrices = coinPrices ?? await query.utils.getCoinPrices();
|
|
4091
|
-
marketPools = marketPools ?? await query.getMarketPools(void 0, { coinPrices });
|
|
4574
|
+
marketPools = marketPools ?? (await query.getMarketPools(void 0, { coinPrices })).pools;
|
|
4092
4575
|
if (!marketPools) {
|
|
4093
4576
|
throw new Error(`Failed to fetch market pool for getAllCoinPrices`);
|
|
4094
4577
|
}
|
|
@@ -4214,12 +4697,80 @@ var getSCoinSwapRate = async (query, fromSCoin, toSCoin, underlyingCoinPrice) =>
|
|
|
4214
4697
|
|
|
4215
4698
|
// src/queries/spoolQuery.ts
|
|
4216
4699
|
import { normalizeStructTag as normalizeStructTag5 } from "@mysten/sui/utils";
|
|
4700
|
+
var queryRequiredSpoolObjects = async (query, stakePoolCoinNames) => {
|
|
4701
|
+
const tasks = stakePoolCoinNames.map((t, idx) => ({
|
|
4702
|
+
poolCoinName: stakePoolCoinNames[idx],
|
|
4703
|
+
spool: POOL_ADDRESSES[t]?.spool,
|
|
4704
|
+
spoolReward: POOL_ADDRESSES[t]?.spoolReward,
|
|
4705
|
+
sCoinTreasury: POOL_ADDRESSES[t]?.sCoinTreasury
|
|
4706
|
+
}));
|
|
4707
|
+
const [spoolObjects, spoolRewardObjects, sCoinTreasuryObjects] = await Promise.all([
|
|
4708
|
+
queryMultipleObjects(
|
|
4709
|
+
query.cache,
|
|
4710
|
+
tasks.map((task) => task.spool).filter((t) => !!t)
|
|
4711
|
+
),
|
|
4712
|
+
queryMultipleObjects(
|
|
4713
|
+
query.cache,
|
|
4714
|
+
tasks.map((task) => task.spoolReward).filter((t) => !!t)
|
|
4715
|
+
),
|
|
4716
|
+
queryMultipleObjects(
|
|
4717
|
+
query.cache,
|
|
4718
|
+
tasks.map((task) => task.sCoinTreasury).filter((t) => !!t)
|
|
4719
|
+
)
|
|
4720
|
+
]);
|
|
4721
|
+
const mapObjects = (tasks2, fetchedObjects) => {
|
|
4722
|
+
const resultMap = {};
|
|
4723
|
+
let fetchedIndex = 0;
|
|
4724
|
+
for (const task of tasks2) {
|
|
4725
|
+
const key = task[Object.keys(task)[1]];
|
|
4726
|
+
if (key) {
|
|
4727
|
+
resultMap[task.poolCoinName] = fetchedObjects[fetchedIndex];
|
|
4728
|
+
fetchedIndex++;
|
|
4729
|
+
}
|
|
4730
|
+
}
|
|
4731
|
+
return resultMap;
|
|
4732
|
+
};
|
|
4733
|
+
const spoolMap = mapObjects(tasks, spoolObjects);
|
|
4734
|
+
const spoolRewardMap = mapObjects(tasks, spoolRewardObjects);
|
|
4735
|
+
const sCoinTreasuryMap = mapObjects(tasks, sCoinTreasuryObjects);
|
|
4736
|
+
return stakePoolCoinNames.reduce(
|
|
4737
|
+
(acc, name) => {
|
|
4738
|
+
acc[name] = {
|
|
4739
|
+
spool: spoolMap[name],
|
|
4740
|
+
spoolReward: spoolRewardMap[name],
|
|
4741
|
+
sCoinTreasury: sCoinTreasuryMap[name]
|
|
4742
|
+
};
|
|
4743
|
+
return acc;
|
|
4744
|
+
},
|
|
4745
|
+
{}
|
|
4746
|
+
);
|
|
4747
|
+
};
|
|
4748
|
+
var parseSpoolObjects = ({
|
|
4749
|
+
spool,
|
|
4750
|
+
spoolReward
|
|
4751
|
+
}) => {
|
|
4752
|
+
const _spool = parseObjectAs(spool);
|
|
4753
|
+
const _spoolReward = parseObjectAs(spoolReward);
|
|
4754
|
+
return {
|
|
4755
|
+
stakeType: _spool.stake_type,
|
|
4756
|
+
maxDistributedPoint: _spool.max_distributed_point,
|
|
4757
|
+
distributedPoint: _spool.distributed_point,
|
|
4758
|
+
distributedPointPerPeriod: _spool.distributed_point_per_period,
|
|
4759
|
+
pointDistributionTime: _spool.point_distribution_time,
|
|
4760
|
+
maxStake: _spool.max_stakes,
|
|
4761
|
+
stakes: _spool.stakes,
|
|
4762
|
+
index: _spool.index,
|
|
4763
|
+
createdAt: _spool.created_at,
|
|
4764
|
+
lastUpdate: _spool.last_update,
|
|
4765
|
+
..._spoolReward
|
|
4766
|
+
};
|
|
4767
|
+
};
|
|
4217
4768
|
var getSpools = async (query, stakeMarketCoinNames = [...SUPPORT_SPOOLS], indexer = false, marketPools, coinPrices) => {
|
|
4218
4769
|
const stakeCoinNames = stakeMarketCoinNames.map(
|
|
4219
4770
|
(stakeMarketCoinName) => query.utils.parseCoinName(stakeMarketCoinName)
|
|
4220
4771
|
);
|
|
4221
|
-
|
|
4222
|
-
|
|
4772
|
+
marketPools = marketPools ?? (await query.getMarketPools(stakeCoinNames, { indexer })).pools;
|
|
4773
|
+
coinPrices = coinPrices ?? await query.getAllCoinPrices({ marketPools }) ?? {};
|
|
4223
4774
|
if (!marketPools)
|
|
4224
4775
|
throw new Error(`Fail to fetch marketPools for ${stakeCoinNames}`);
|
|
4225
4776
|
const spools = {};
|
|
@@ -4234,126 +4785,93 @@ var getSpools = async (query, stakeMarketCoinNames = [...SUPPORT_SPOOLS], indexe
|
|
|
4234
4785
|
const rewardCoinName = query.utils.getSpoolRewardCoinName(
|
|
4235
4786
|
spool.marketCoinName
|
|
4236
4787
|
);
|
|
4237
|
-
const marketPool = marketPools[coinName];
|
|
4238
4788
|
spool.coinPrice = coinPrices[coinName] ?? spool.coinPrice;
|
|
4239
|
-
spool.marketCoinPrice = coinPrices[
|
|
4789
|
+
spool.marketCoinPrice = coinPrices[spool.marketCoinName] ?? spool.marketCoinPrice;
|
|
4240
4790
|
spool.rewardCoinPrice = coinPrices[rewardCoinName] ?? spool.rewardCoinPrice;
|
|
4241
4791
|
spools[spool.marketCoinName] = spool;
|
|
4242
4792
|
};
|
|
4243
4793
|
Object.values(spoolsIndexer).forEach(updateSpools);
|
|
4244
4794
|
return spools;
|
|
4245
4795
|
}
|
|
4246
|
-
|
|
4247
|
-
|
|
4248
|
-
|
|
4249
|
-
|
|
4250
|
-
|
|
4251
|
-
|
|
4252
|
-
|
|
4253
|
-
|
|
4254
|
-
|
|
4255
|
-
|
|
4256
|
-
|
|
4257
|
-
|
|
4258
|
-
|
|
4796
|
+
const requiredObjects = await queryRequiredSpoolObjects(
|
|
4797
|
+
query,
|
|
4798
|
+
stakeCoinNames
|
|
4799
|
+
);
|
|
4800
|
+
await Promise.allSettled(
|
|
4801
|
+
stakeMarketCoinNames.map(async (stakeMarketCoinName, idx) => {
|
|
4802
|
+
try {
|
|
4803
|
+
const stakeCoinName = stakeCoinNames[idx];
|
|
4804
|
+
const spool = await getSpool(
|
|
4805
|
+
query,
|
|
4806
|
+
stakeMarketCoinName,
|
|
4807
|
+
indexer,
|
|
4808
|
+
coinPrices,
|
|
4809
|
+
requiredObjects[stakeCoinName]
|
|
4810
|
+
);
|
|
4811
|
+
if (spool) {
|
|
4812
|
+
spools[stakeMarketCoinName] = spool;
|
|
4813
|
+
}
|
|
4814
|
+
} catch (e) {
|
|
4815
|
+
console.error(e);
|
|
4816
|
+
}
|
|
4817
|
+
})
|
|
4818
|
+
);
|
|
4259
4819
|
return spools;
|
|
4260
4820
|
};
|
|
4261
|
-
var getSpool = async (query, marketCoinName, indexer = false,
|
|
4821
|
+
var getSpool = async (query, marketCoinName, indexer = false, coinPrices, requiredObjects) => {
|
|
4262
4822
|
const coinName = query.utils.parseCoinName(marketCoinName);
|
|
4263
|
-
|
|
4264
|
-
if (!marketPool) {
|
|
4265
|
-
throw new Error(`Failed to fetch marketPool for ${marketCoinName}`);
|
|
4266
|
-
}
|
|
4267
|
-
const poolId = query.address.get(`spool.pools.${marketCoinName}.id`);
|
|
4268
|
-
const rewardPoolId = query.address.get(
|
|
4269
|
-
`spool.pools.${marketCoinName}.rewardPoolId`
|
|
4270
|
-
);
|
|
4271
|
-
let spool = void 0;
|
|
4272
|
-
coinPrices = coinPrices || await query.utils.getCoinPrices();
|
|
4823
|
+
coinPrices = coinPrices || await query.getAllCoinPrices();
|
|
4273
4824
|
if (indexer) {
|
|
4274
4825
|
const spoolIndexer = await query.indexer.getSpool(marketCoinName);
|
|
4275
4826
|
const coinName2 = query.utils.parseCoinName(marketCoinName);
|
|
4276
4827
|
const rewardCoinName2 = query.utils.getSpoolRewardCoinName(marketCoinName);
|
|
4277
|
-
spoolIndexer.coinPrice = coinPrices?.[coinName2]
|
|
4278
|
-
spoolIndexer.marketCoinPrice =
|
|
4279
|
-
spoolIndexer.rewardCoinPrice = coinPrices?.[rewardCoinName2]
|
|
4828
|
+
spoolIndexer.coinPrice = coinPrices?.[coinName2] ?? spoolIndexer.coinPrice;
|
|
4829
|
+
spoolIndexer.marketCoinPrice = coinPrices?.[marketCoinName] ?? spoolIndexer.marketCoinPrice;
|
|
4830
|
+
spoolIndexer.rewardCoinPrice = coinPrices?.[rewardCoinName2] ?? spoolIndexer.rewardCoinPrice;
|
|
4280
4831
|
return spoolIndexer;
|
|
4281
4832
|
}
|
|
4282
|
-
|
|
4283
|
-
[poolId, rewardPoolId],
|
|
4284
|
-
{
|
|
4285
|
-
showContent: true
|
|
4286
|
-
}
|
|
4287
|
-
);
|
|
4288
|
-
if (!(spoolObjectResponse[0] && spoolObjectResponse[1])) {
|
|
4289
|
-
throw new Error("Fail to fetch spoolObjectResponse!");
|
|
4290
|
-
}
|
|
4833
|
+
requiredObjects ?? (requiredObjects = (await queryRequiredSpoolObjects(query, [coinName]))[coinName]);
|
|
4291
4834
|
const rewardCoinName = query.utils.getSpoolRewardCoinName(marketCoinName);
|
|
4292
4835
|
coinPrices = coinPrices || await query.utils.getCoinPrices();
|
|
4293
|
-
const
|
|
4294
|
-
const
|
|
4295
|
-
|
|
4296
|
-
|
|
4297
|
-
|
|
4298
|
-
|
|
4299
|
-
|
|
4300
|
-
|
|
4301
|
-
|
|
4302
|
-
|
|
4303
|
-
|
|
4304
|
-
|
|
4305
|
-
|
|
4306
|
-
|
|
4307
|
-
|
|
4308
|
-
|
|
4309
|
-
|
|
4310
|
-
|
|
4311
|
-
|
|
4312
|
-
|
|
4313
|
-
|
|
4314
|
-
|
|
4315
|
-
)
|
|
4316
|
-
|
|
4317
|
-
|
|
4318
|
-
|
|
4319
|
-
|
|
4320
|
-
|
|
4321
|
-
|
|
4322
|
-
|
|
4323
|
-
|
|
4324
|
-
|
|
4325
|
-
|
|
4326
|
-
|
|
4327
|
-
|
|
4328
|
-
|
|
4329
|
-
|
|
4330
|
-
|
|
4331
|
-
|
|
4332
|
-
rewardCoinDecimal
|
|
4333
|
-
);
|
|
4334
|
-
spool = {
|
|
4335
|
-
marketCoinName,
|
|
4336
|
-
symbol: query.utils.parseSymbol(marketCoinName),
|
|
4337
|
-
coinType: query.utils.parseCoinType(coinName),
|
|
4338
|
-
marketCoinType: query.utils.parseMarketCoinType(coinName),
|
|
4339
|
-
rewardCoinType: isMarketCoin(rewardCoinName) ? query.utils.parseMarketCoinType(rewardCoinName) : query.utils.parseCoinType(rewardCoinName),
|
|
4340
|
-
sCoinType: marketPool.sCoinType,
|
|
4341
|
-
coinDecimal: query.utils.getCoinDecimal(coinName),
|
|
4342
|
-
rewardCoinDecimal: query.utils.getCoinDecimal(rewardCoinName),
|
|
4343
|
-
coinPrice: coinPrices?.[coinName] ?? 0,
|
|
4344
|
-
marketCoinPrice,
|
|
4345
|
-
rewardCoinPrice,
|
|
4346
|
-
maxPoint: parsedSpoolData.maxPoint,
|
|
4347
|
-
distributedPoint: parsedSpoolData.distributedPoint,
|
|
4348
|
-
maxStake: parsedSpoolData.maxStake,
|
|
4349
|
-
...calculatedSpoolData,
|
|
4350
|
-
exchangeRateNumerator: parsedSpoolRewardPoolData.exchangeRateNumerator,
|
|
4351
|
-
exchangeRateDenominator: parsedSpoolRewardPoolData.exchangeRateDenominator,
|
|
4352
|
-
...calculatedRewardPoolData
|
|
4353
|
-
};
|
|
4354
|
-
}
|
|
4355
|
-
}
|
|
4356
|
-
return spool;
|
|
4836
|
+
const parsedSpoolObjects = parseSpoolObjects(requiredObjects);
|
|
4837
|
+
const parsedSpoolData = parseOriginSpoolData(parsedSpoolObjects);
|
|
4838
|
+
const marketCoinPrice = coinPrices?.[marketCoinName] ?? 0;
|
|
4839
|
+
const marketCoinDecimal = query.utils.getCoinDecimal(marketCoinName);
|
|
4840
|
+
const calculatedSpoolData = calculateSpoolData(
|
|
4841
|
+
parsedSpoolData,
|
|
4842
|
+
marketCoinPrice,
|
|
4843
|
+
marketCoinDecimal
|
|
4844
|
+
);
|
|
4845
|
+
const parsedSpoolRewardPoolData = parseOriginSpoolRewardPoolData(parsedSpoolObjects);
|
|
4846
|
+
const rewardCoinPrice = coinPrices?.[rewardCoinName] ?? 0;
|
|
4847
|
+
const rewardCoinDecimal = query.utils.getCoinDecimal(rewardCoinName);
|
|
4848
|
+
const calculatedRewardPoolData = calculateSpoolRewardPoolData(
|
|
4849
|
+
parsedSpoolData,
|
|
4850
|
+
parsedSpoolRewardPoolData,
|
|
4851
|
+
calculatedSpoolData,
|
|
4852
|
+
rewardCoinPrice,
|
|
4853
|
+
rewardCoinDecimal
|
|
4854
|
+
);
|
|
4855
|
+
return {
|
|
4856
|
+
marketCoinName,
|
|
4857
|
+
symbol: query.utils.parseSymbol(marketCoinName),
|
|
4858
|
+
coinType: query.utils.parseCoinType(coinName),
|
|
4859
|
+
marketCoinType: query.utils.parseMarketCoinType(coinName),
|
|
4860
|
+
rewardCoinType: isMarketCoin(rewardCoinName) ? query.utils.parseMarketCoinType(rewardCoinName) : query.utils.parseCoinType(rewardCoinName),
|
|
4861
|
+
sCoinType: query.utils.parseSCoinType(marketCoinName),
|
|
4862
|
+
coinDecimal: query.utils.getCoinDecimal(coinName),
|
|
4863
|
+
rewardCoinDecimal: query.utils.getCoinDecimal(rewardCoinName),
|
|
4864
|
+
coinPrice: coinPrices?.[coinName] ?? 0,
|
|
4865
|
+
marketCoinPrice,
|
|
4866
|
+
rewardCoinPrice,
|
|
4867
|
+
maxPoint: parsedSpoolData.maxPoint,
|
|
4868
|
+
distributedPoint: parsedSpoolData.distributedPoint,
|
|
4869
|
+
maxStake: parsedSpoolData.maxStake,
|
|
4870
|
+
...calculatedSpoolData,
|
|
4871
|
+
exchangeRateNumerator: parsedSpoolRewardPoolData.exchangeRateNumerator,
|
|
4872
|
+
exchangeRateDenominator: parsedSpoolRewardPoolData.exchangeRateDenominator,
|
|
4873
|
+
...calculatedRewardPoolData
|
|
4874
|
+
};
|
|
4357
4875
|
};
|
|
4358
4876
|
var getStakeAccounts = async ({
|
|
4359
4877
|
utils
|
|
@@ -4703,6 +5221,105 @@ var getVeScaTreasuryInfo = async (utils) => {
|
|
|
4703
5221
|
};
|
|
4704
5222
|
};
|
|
4705
5223
|
|
|
5224
|
+
// src/queries/poolAddressesQuery.ts
|
|
5225
|
+
var getAllAddresses = async (query) => {
|
|
5226
|
+
const results = {};
|
|
5227
|
+
const marketId = query.address.get("core.market");
|
|
5228
|
+
const marketObject = (await query.cache.queryGetObject(marketId, {
|
|
5229
|
+
showContent: true
|
|
5230
|
+
}))?.data;
|
|
5231
|
+
if (!(marketObject && marketObject.content?.dataType === "moveObject"))
|
|
5232
|
+
throw new Error(`Failed to fetch marketObject`);
|
|
5233
|
+
const fields = marketObject.content.fields;
|
|
5234
|
+
const coinTypesPairs = SUPPORT_POOLS.reduce(
|
|
5235
|
+
(acc, pool) => {
|
|
5236
|
+
acc.push([pool, query.utils.parseCoinType(pool).substring(2)]);
|
|
5237
|
+
return acc;
|
|
5238
|
+
},
|
|
5239
|
+
[]
|
|
5240
|
+
);
|
|
5241
|
+
const balanceSheetParentId = fields.vault.fields.balance_sheets.fields.table.fields.id.id;
|
|
5242
|
+
const collateralStatsParentId = fields.collateral_stats.fields.table.fields.id.id;
|
|
5243
|
+
const borrowDynamicsParentid = fields.borrow_dynamics.fields.table.fields.id.id;
|
|
5244
|
+
const interestModelParentId = fields.interest_models.fields.table.fields.id.id;
|
|
5245
|
+
const riskModelParentId = fields.risk_models.fields.table.fields.id.id;
|
|
5246
|
+
const ADDRESS_TYPE = `0x1::type_name::TypeName`;
|
|
5247
|
+
const BORROW_FEE_TYPE = `0xc38f849e81cfe46d4e4320f508ea7dda42934a329d5a6571bb4c3cb6ea63f5da::market_dynamic_keys::BorrowFeeKey`;
|
|
5248
|
+
const SUPPLY_LIMIT_TYPE = `0x6e641f0dca8aedab3101d047e96439178f16301bf0b57fe8745086ff1195eb3e::market_dynamic_keys::SupplyLimitKey`;
|
|
5249
|
+
const BORROW_LIMIT_TYPE = `0xe7dbb371a9595631f7964b7ece42255ad0e738cc85fe6da26c7221b220f01af6::market_dynamic_keys::BorrowLimitKey`;
|
|
5250
|
+
const ISOLATED_ASSET_KEY = `0xe7dbb371a9595631f7964b7ece42255ad0e738cc85fe6da26c7221b220f01af6::market_dynamic_keys::IsolatedAssetKey`;
|
|
5251
|
+
const fetchDynamicObject = async (parentId, type, value) => {
|
|
5252
|
+
try {
|
|
5253
|
+
return (await query.cache.queryGetDynamicFieldObject({
|
|
5254
|
+
parentId,
|
|
5255
|
+
name: {
|
|
5256
|
+
type,
|
|
5257
|
+
value
|
|
5258
|
+
}
|
|
5259
|
+
}))?.data?.objectId;
|
|
5260
|
+
} catch (_e) {
|
|
5261
|
+
return void 0;
|
|
5262
|
+
}
|
|
5263
|
+
};
|
|
5264
|
+
await Promise.all(
|
|
5265
|
+
coinTypesPairs.map(async ([coinName, coinType]) => {
|
|
5266
|
+
const addresses = await Promise.all([
|
|
5267
|
+
fetchDynamicObject(balanceSheetParentId, ADDRESS_TYPE, {
|
|
5268
|
+
name: coinType
|
|
5269
|
+
}),
|
|
5270
|
+
fetchDynamicObject(collateralStatsParentId, ADDRESS_TYPE, {
|
|
5271
|
+
name: coinType
|
|
5272
|
+
}),
|
|
5273
|
+
fetchDynamicObject(borrowDynamicsParentid, ADDRESS_TYPE, {
|
|
5274
|
+
name: coinType
|
|
5275
|
+
}),
|
|
5276
|
+
fetchDynamicObject(interestModelParentId, ADDRESS_TYPE, {
|
|
5277
|
+
name: coinType
|
|
5278
|
+
}),
|
|
5279
|
+
fetchDynamicObject(riskModelParentId, ADDRESS_TYPE, {
|
|
5280
|
+
name: coinType
|
|
5281
|
+
}),
|
|
5282
|
+
fetchDynamicObject(marketId, BORROW_FEE_TYPE, coinType),
|
|
5283
|
+
fetchDynamicObject(marketId, SUPPLY_LIMIT_TYPE, coinType),
|
|
5284
|
+
fetchDynamicObject(marketId, BORROW_LIMIT_TYPE, coinType),
|
|
5285
|
+
fetchDynamicObject(marketId, ISOLATED_ASSET_KEY, coinType)
|
|
5286
|
+
]);
|
|
5287
|
+
const spool = query.address.get(
|
|
5288
|
+
// @ts-ignore
|
|
5289
|
+
`spool.pools.s${coinName}.id`
|
|
5290
|
+
);
|
|
5291
|
+
const rewardPool = query.address.get(
|
|
5292
|
+
// @ts-ignore
|
|
5293
|
+
`spool.pools.s${coinName}.rewardPoolId`
|
|
5294
|
+
);
|
|
5295
|
+
const sCoinTreasury = query.address.get(
|
|
5296
|
+
// @ts-ignore
|
|
5297
|
+
`scoin.coins.s${coinName}.treasury`
|
|
5298
|
+
);
|
|
5299
|
+
const coinDecimalId = query.address.get(
|
|
5300
|
+
`core.coins.${coinName}.metaData`
|
|
5301
|
+
);
|
|
5302
|
+
results[coinName] = {
|
|
5303
|
+
lendingPoolAddress: addresses[0],
|
|
5304
|
+
collateralPoolAddress: addresses[1],
|
|
5305
|
+
borrowDynamic: addresses[2],
|
|
5306
|
+
interestModel: addresses[3],
|
|
5307
|
+
riskModel: addresses[4],
|
|
5308
|
+
borrowFeeKey: addresses[5],
|
|
5309
|
+
supplyLimitKey: addresses[6],
|
|
5310
|
+
borrowLimitKey: addresses[7],
|
|
5311
|
+
isolatedAssetKey: addresses[8],
|
|
5312
|
+
spool,
|
|
5313
|
+
spoolReward: rewardPool,
|
|
5314
|
+
sCoinTreasury,
|
|
5315
|
+
coinDecimalId
|
|
5316
|
+
};
|
|
5317
|
+
await new Promise((resolve) => setTimeout(resolve, 200));
|
|
5318
|
+
})
|
|
5319
|
+
);
|
|
5320
|
+
return results;
|
|
5321
|
+
};
|
|
5322
|
+
|
|
4706
5323
|
// src/models/suiKit.ts
|
|
4707
5324
|
import { SuiKit as SuiKit2 } from "@scallop-io/sui-kit";
|
|
4708
5325
|
var newSuiKit = (params) => {
|
|
@@ -4854,13 +5471,14 @@ var ScallopUtils = class {
|
|
|
4854
5471
|
}
|
|
4855
5472
|
}
|
|
4856
5473
|
/**
|
|
4857
|
-
* Convert sCoin name to coin name.
|
|
5474
|
+
* Convert sCoin name to market coin name.
|
|
4858
5475
|
* This function will parse new sCoin name `scallop_...` to its old market coin name which is shorter
|
|
4859
5476
|
* e.g: `scallop_sui -> ssui
|
|
5477
|
+
* if no `scallop_...` is encountered, return coinName
|
|
4860
5478
|
* @return sCoin name
|
|
4861
5479
|
*/
|
|
4862
|
-
|
|
4863
|
-
return sCoinRawNameToName[coinName];
|
|
5480
|
+
parseSCoinTypeNameToMarketCoinName(coinName) {
|
|
5481
|
+
return sCoinRawNameToName[coinName] ?? coinName;
|
|
4864
5482
|
}
|
|
4865
5483
|
/**
|
|
4866
5484
|
* Convert sCoin name into sCoin type
|
|
@@ -4909,6 +5527,9 @@ var ScallopUtils = class {
|
|
|
4909
5527
|
}
|
|
4910
5528
|
parseCoinNameFromType(coinType) {
|
|
4911
5529
|
coinType = normalizeStructTag6(coinType);
|
|
5530
|
+
if (sCoinTypeToName[coinType]) {
|
|
5531
|
+
return sCoinTypeToName[coinType];
|
|
5532
|
+
}
|
|
4912
5533
|
const coinTypeRegex = new RegExp(`((0x[^:]+::[^:]+::[^<>]+))(?![^<>]*<)`);
|
|
4913
5534
|
const coinTypeMatch = coinType.match(coinTypeRegex);
|
|
4914
5535
|
const isMarketCoinType = coinType.includes("reserve::MarketCoin");
|
|
@@ -5078,7 +5699,7 @@ var ScallopUtils = class {
|
|
|
5078
5699
|
);
|
|
5079
5700
|
const priceIds = priceIdPairs.map(([_2, priceId]) => priceId);
|
|
5080
5701
|
const pythConnection = new SuiPriceServiceConnection(endpoint, {
|
|
5081
|
-
timeout:
|
|
5702
|
+
timeout: 4e3
|
|
5082
5703
|
});
|
|
5083
5704
|
try {
|
|
5084
5705
|
const feeds = await this.cache.queryClient.fetchQuery({
|
|
@@ -5370,32 +5991,41 @@ var generateCoreNormalMethod = ({
|
|
|
5370
5991
|
const referralPkgId = builder.address.get("referral.id");
|
|
5371
5992
|
const referralWitnessType = `${referralPkgId}::scallop_referral_program::REFERRAL_WITNESS`;
|
|
5372
5993
|
return {
|
|
5373
|
-
openObligation: () => {
|
|
5374
|
-
const [obligation, obligationKey, obligationHotPotato] =
|
|
5994
|
+
openObligation: async () => {
|
|
5995
|
+
const [obligation, obligationKey, obligationHotPotato] = await builder.moveCall(
|
|
5996
|
+
txBlock,
|
|
5375
5997
|
`${coreIds.protocolPkg}::open_obligation::open_obligation`,
|
|
5376
5998
|
[coreIds.version]
|
|
5377
5999
|
);
|
|
5378
6000
|
return [obligation, obligationKey, obligationHotPotato];
|
|
5379
6001
|
},
|
|
5380
|
-
returnObligation: (obligation, obligationHotPotato) =>
|
|
5381
|
-
|
|
5382
|
-
|
|
5383
|
-
|
|
5384
|
-
|
|
5385
|
-
|
|
5386
|
-
|
|
5387
|
-
)
|
|
5388
|
-
|
|
6002
|
+
returnObligation: async (obligation, obligationHotPotato) => {
|
|
6003
|
+
await builder.moveCall(
|
|
6004
|
+
txBlock,
|
|
6005
|
+
`${coreIds.protocolPkg}::open_obligation::return_obligation`,
|
|
6006
|
+
[coreIds.version, obligation, obligationHotPotato]
|
|
6007
|
+
);
|
|
6008
|
+
},
|
|
6009
|
+
openObligationEntry: async () => {
|
|
6010
|
+
await builder.moveCall(
|
|
6011
|
+
txBlock,
|
|
6012
|
+
`${coreIds.protocolPkg}::open_obligation::open_obligation_entry`,
|
|
6013
|
+
[coreIds.version]
|
|
6014
|
+
);
|
|
6015
|
+
},
|
|
6016
|
+
addCollateral: async (obligation, coin, collateralCoinName) => {
|
|
5389
6017
|
const coinType = builder.utils.parseCoinType(collateralCoinName);
|
|
5390
|
-
|
|
6018
|
+
await builder.moveCall(
|
|
6019
|
+
txBlock,
|
|
5391
6020
|
`${coreIds.protocolPkg}::deposit_collateral::deposit_collateral`,
|
|
5392
6021
|
[coreIds.version, obligation, coreIds.market, coin],
|
|
5393
6022
|
[coinType]
|
|
5394
6023
|
);
|
|
5395
6024
|
},
|
|
5396
|
-
takeCollateral: (obligation, obligationKey, amount, collateralCoinName) => {
|
|
6025
|
+
takeCollateral: async (obligation, obligationKey, amount, collateralCoinName) => {
|
|
5397
6026
|
const coinType = builder.utils.parseCoinType(collateralCoinName);
|
|
5398
|
-
return
|
|
6027
|
+
return await builder.moveCall(
|
|
6028
|
+
txBlock,
|
|
5399
6029
|
`${coreIds.protocolPkg}::withdraw_collateral::withdraw_collateral`,
|
|
5400
6030
|
[
|
|
5401
6031
|
coreIds.version,
|
|
@@ -5410,41 +6040,46 @@ var generateCoreNormalMethod = ({
|
|
|
5410
6040
|
[coinType]
|
|
5411
6041
|
);
|
|
5412
6042
|
},
|
|
5413
|
-
deposit: (coin, poolCoinName) => {
|
|
6043
|
+
deposit: async (coin, poolCoinName) => {
|
|
5414
6044
|
const coinType = builder.utils.parseCoinType(poolCoinName);
|
|
5415
|
-
return
|
|
6045
|
+
return await builder.moveCall(
|
|
6046
|
+
txBlock,
|
|
5416
6047
|
`${coreIds.protocolPkg}::mint::mint`,
|
|
5417
6048
|
[coreIds.version, coreIds.market, coin, SUI_CLOCK_OBJECT_ID3],
|
|
5418
6049
|
[coinType]
|
|
5419
6050
|
);
|
|
5420
6051
|
},
|
|
5421
|
-
depositEntry: (coin, poolCoinName) => {
|
|
6052
|
+
depositEntry: async (coin, poolCoinName) => {
|
|
5422
6053
|
const coinType = builder.utils.parseCoinType(poolCoinName);
|
|
5423
|
-
return
|
|
6054
|
+
return await builder.moveCall(
|
|
6055
|
+
txBlock,
|
|
5424
6056
|
`${coreIds.protocolPkg}::mint::mint_entry`,
|
|
5425
6057
|
[coreIds.version, coreIds.market, coin, SUI_CLOCK_OBJECT_ID3],
|
|
5426
6058
|
[coinType]
|
|
5427
6059
|
);
|
|
5428
6060
|
},
|
|
5429
|
-
withdraw: (marketCoin, poolCoinName) => {
|
|
6061
|
+
withdraw: async (marketCoin, poolCoinName) => {
|
|
5430
6062
|
const coinType = builder.utils.parseCoinType(poolCoinName);
|
|
5431
|
-
return
|
|
6063
|
+
return await builder.moveCall(
|
|
6064
|
+
txBlock,
|
|
5432
6065
|
`${coreIds.protocolPkg}::redeem::redeem`,
|
|
5433
6066
|
[coreIds.version, coreIds.market, marketCoin, SUI_CLOCK_OBJECT_ID3],
|
|
5434
6067
|
[coinType]
|
|
5435
6068
|
);
|
|
5436
6069
|
},
|
|
5437
|
-
withdrawEntry: (marketCoin, poolCoinName) => {
|
|
6070
|
+
withdrawEntry: async (marketCoin, poolCoinName) => {
|
|
5438
6071
|
const coinType = builder.utils.parseCoinType(poolCoinName);
|
|
5439
|
-
return
|
|
6072
|
+
return await builder.moveCall(
|
|
6073
|
+
txBlock,
|
|
5440
6074
|
`${coreIds.protocolPkg}::redeem::redeem_entry`,
|
|
5441
6075
|
[coreIds.version, coreIds.market, marketCoin, SUI_CLOCK_OBJECT_ID3],
|
|
5442
6076
|
[coinType]
|
|
5443
6077
|
);
|
|
5444
6078
|
},
|
|
5445
|
-
borrow: (obligation, obligationKey, amount, poolCoinName) => {
|
|
6079
|
+
borrow: async (obligation, obligationKey, amount, poolCoinName) => {
|
|
5446
6080
|
const coinType = builder.utils.parseCoinType(poolCoinName);
|
|
5447
|
-
return
|
|
6081
|
+
return await builder.moveCall(
|
|
6082
|
+
txBlock,
|
|
5448
6083
|
`${coreIds.protocolPkg}::borrow::borrow`,
|
|
5449
6084
|
[
|
|
5450
6085
|
coreIds.version,
|
|
@@ -5459,9 +6094,10 @@ var generateCoreNormalMethod = ({
|
|
|
5459
6094
|
[coinType]
|
|
5460
6095
|
);
|
|
5461
6096
|
},
|
|
5462
|
-
borrowWithReferral: (obligation, obligationKey, borrowReferral, amount, poolCoinName) => {
|
|
6097
|
+
borrowWithReferral: async (obligation, obligationKey, borrowReferral, amount, poolCoinName) => {
|
|
5463
6098
|
const coinType = builder.utils.parseCoinType(poolCoinName);
|
|
5464
|
-
return
|
|
6099
|
+
return await builder.moveCall(
|
|
6100
|
+
txBlock,
|
|
5465
6101
|
`${coreIds.protocolPkg}::borrow::borrow_with_referral`,
|
|
5466
6102
|
[
|
|
5467
6103
|
coreIds.version,
|
|
@@ -5470,16 +6106,17 @@ var generateCoreNormalMethod = ({
|
|
|
5470
6106
|
coreIds.market,
|
|
5471
6107
|
coreIds.coinDecimalsRegistry,
|
|
5472
6108
|
borrowReferral,
|
|
5473
|
-
txBlock.pure.u64(amount),
|
|
6109
|
+
typeof amount === "number" ? txBlock.pure.u64(amount) : amount,
|
|
5474
6110
|
coreIds.xOracle,
|
|
5475
6111
|
SUI_CLOCK_OBJECT_ID3
|
|
5476
6112
|
],
|
|
5477
6113
|
[coinType, referralWitnessType]
|
|
5478
6114
|
);
|
|
5479
6115
|
},
|
|
5480
|
-
borrowEntry: (obligation, obligationKey, amount, poolCoinName) => {
|
|
6116
|
+
borrowEntry: async (obligation, obligationKey, amount, poolCoinName) => {
|
|
5481
6117
|
const coinType = builder.utils.parseCoinType(poolCoinName);
|
|
5482
|
-
return
|
|
6118
|
+
return await builder.moveCall(
|
|
6119
|
+
txBlock,
|
|
5483
6120
|
`${coreIds.protocolPkg}::borrow::borrow_entry`,
|
|
5484
6121
|
[
|
|
5485
6122
|
coreIds.version,
|
|
@@ -5494,9 +6131,10 @@ var generateCoreNormalMethod = ({
|
|
|
5494
6131
|
[coinType]
|
|
5495
6132
|
);
|
|
5496
6133
|
},
|
|
5497
|
-
repay: (obligation, coin, poolCoinName) => {
|
|
6134
|
+
repay: async (obligation, coin, poolCoinName) => {
|
|
5498
6135
|
const coinType = builder.utils.parseCoinType(poolCoinName);
|
|
5499
|
-
|
|
6136
|
+
await builder.moveCall(
|
|
6137
|
+
txBlock,
|
|
5500
6138
|
`${coreIds.protocolPkg}::repay::repay`,
|
|
5501
6139
|
[
|
|
5502
6140
|
coreIds.version,
|
|
@@ -5508,17 +6146,19 @@ var generateCoreNormalMethod = ({
|
|
|
5508
6146
|
[coinType]
|
|
5509
6147
|
);
|
|
5510
6148
|
},
|
|
5511
|
-
borrowFlashLoan: (amount, poolCoinName) => {
|
|
6149
|
+
borrowFlashLoan: async (amount, poolCoinName) => {
|
|
5512
6150
|
const coinType = builder.utils.parseCoinType(poolCoinName);
|
|
5513
|
-
return
|
|
6151
|
+
return await builder.moveCall(
|
|
6152
|
+
txBlock,
|
|
5514
6153
|
`${coreIds.protocolPkg}::flash_loan::borrow_flash_loan`,
|
|
5515
6154
|
[coreIds.version, coreIds.market, amount],
|
|
5516
6155
|
[coinType]
|
|
5517
6156
|
);
|
|
5518
6157
|
},
|
|
5519
|
-
repayFlashLoan: (coin, loan, poolCoinName) => {
|
|
6158
|
+
repayFlashLoan: async (coin, loan, poolCoinName) => {
|
|
5520
6159
|
const coinType = builder.utils.parseCoinType(poolCoinName);
|
|
5521
|
-
|
|
6160
|
+
await builder.moveCall(
|
|
6161
|
+
txBlock,
|
|
5522
6162
|
`${coreIds.protocolPkg}::flash_loan::repay_flash_loan`,
|
|
5523
6163
|
[coreIds.version, coreIds.market, coin, loan],
|
|
5524
6164
|
[coinType]
|
|
@@ -5540,7 +6180,7 @@ var generateCoreQuickMethod = ({
|
|
|
5540
6180
|
);
|
|
5541
6181
|
if (collateralCoinName === "sui") {
|
|
5542
6182
|
const [suiCoin] = txBlock.splitSUIFromGas([amount]);
|
|
5543
|
-
txBlock.addCollateral(obligationArg, suiCoin, collateralCoinName);
|
|
6183
|
+
await txBlock.addCollateral(obligationArg, suiCoin, collateralCoinName);
|
|
5544
6184
|
} else {
|
|
5545
6185
|
const { leftCoin, takeCoin } = await builder.selectCoin(
|
|
5546
6186
|
txBlock,
|
|
@@ -5548,7 +6188,11 @@ var generateCoreQuickMethod = ({
|
|
|
5548
6188
|
amount,
|
|
5549
6189
|
sender
|
|
5550
6190
|
);
|
|
5551
|
-
txBlock.addCollateral(
|
|
6191
|
+
await txBlock.addCollateral(
|
|
6192
|
+
obligationArg,
|
|
6193
|
+
takeCoin,
|
|
6194
|
+
collateralCoinName
|
|
6195
|
+
);
|
|
5552
6196
|
txBlock.transferObjects([leftCoin], sender);
|
|
5553
6197
|
}
|
|
5554
6198
|
},
|
|
@@ -5563,7 +6207,7 @@ var generateCoreQuickMethod = ({
|
|
|
5563
6207
|
obligationInfo.obligationId
|
|
5564
6208
|
);
|
|
5565
6209
|
await updateOracles(builder, txBlock, updateCoinNames);
|
|
5566
|
-
return txBlock.takeCollateral(
|
|
6210
|
+
return await txBlock.takeCollateral(
|
|
5567
6211
|
obligationInfo.obligationId,
|
|
5568
6212
|
obligationInfo.obligationKey,
|
|
5569
6213
|
amount,
|
|
@@ -5575,7 +6219,7 @@ var generateCoreQuickMethod = ({
|
|
|
5575
6219
|
let marketCoinDeposit;
|
|
5576
6220
|
if (poolCoinName === "sui") {
|
|
5577
6221
|
const [suiCoin] = txBlock.splitSUIFromGas([amount]);
|
|
5578
|
-
marketCoinDeposit = txBlock.deposit(suiCoin, poolCoinName);
|
|
6222
|
+
marketCoinDeposit = await txBlock.deposit(suiCoin, poolCoinName);
|
|
5579
6223
|
} else {
|
|
5580
6224
|
const { leftCoin, takeCoin } = await builder.selectCoin(
|
|
5581
6225
|
txBlock,
|
|
@@ -5584,9 +6228,9 @@ var generateCoreQuickMethod = ({
|
|
|
5584
6228
|
sender
|
|
5585
6229
|
);
|
|
5586
6230
|
txBlock.transferObjects([leftCoin], sender);
|
|
5587
|
-
marketCoinDeposit = txBlock.deposit(takeCoin, poolCoinName);
|
|
6231
|
+
marketCoinDeposit = await txBlock.deposit(takeCoin, poolCoinName);
|
|
5588
6232
|
}
|
|
5589
|
-
return returnSCoin ? txBlock.mintSCoin(
|
|
6233
|
+
return returnSCoin ? await txBlock.mintSCoin(
|
|
5590
6234
|
builder.utils.parseMarketCoinName(poolCoinName),
|
|
5591
6235
|
marketCoinDeposit
|
|
5592
6236
|
) : marketCoinDeposit;
|
|
@@ -5604,7 +6248,7 @@ var generateCoreQuickMethod = ({
|
|
|
5604
6248
|
totalAmount
|
|
5605
6249
|
} = await builder.selectSCoin(txBlock, sCoinName, amount, sender);
|
|
5606
6250
|
txBlock.transferObjects([leftCoin], sender);
|
|
5607
|
-
const marketCoins2 = txBlock.burnSCoin(sCoinName, sCoins2);
|
|
6251
|
+
const marketCoins2 = await txBlock.burnSCoin(sCoinName, sCoins2);
|
|
5608
6252
|
amount -= totalAmount;
|
|
5609
6253
|
try {
|
|
5610
6254
|
if (amount > 0) {
|
|
@@ -5628,7 +6272,7 @@ var generateCoreQuickMethod = ({
|
|
|
5628
6272
|
sender
|
|
5629
6273
|
);
|
|
5630
6274
|
txBlock.transferObjects([leftCoin], sender);
|
|
5631
|
-
return txBlock.withdraw(walletMarketCoins, poolCoinName);
|
|
6275
|
+
return await txBlock.withdraw(walletMarketCoins, poolCoinName);
|
|
5632
6276
|
}
|
|
5633
6277
|
},
|
|
5634
6278
|
borrowQuick: async (amount, poolCoinName, obligationId, obligationKey) => {
|
|
@@ -5643,7 +6287,7 @@ var generateCoreQuickMethod = ({
|
|
|
5643
6287
|
) ?? [];
|
|
5644
6288
|
const updateCoinNames = [...obligationCoinNames, poolCoinName];
|
|
5645
6289
|
await updateOracles(builder, txBlock, updateCoinNames);
|
|
5646
|
-
return txBlock.borrow(
|
|
6290
|
+
return await txBlock.borrow(
|
|
5647
6291
|
obligationInfo.obligationId,
|
|
5648
6292
|
obligationInfo.obligationKey,
|
|
5649
6293
|
amount,
|
|
@@ -5662,7 +6306,7 @@ var generateCoreQuickMethod = ({
|
|
|
5662
6306
|
) ?? [];
|
|
5663
6307
|
const updateCoinNames = [...obligationCoinNames, poolCoinName];
|
|
5664
6308
|
await updateOracles(builder, txBlock, updateCoinNames);
|
|
5665
|
-
return txBlock.borrowWithReferral(
|
|
6309
|
+
return await txBlock.borrowWithReferral(
|
|
5666
6310
|
obligationInfo.obligationId,
|
|
5667
6311
|
obligationInfo.obligationKey,
|
|
5668
6312
|
borrowReferral,
|
|
@@ -5679,7 +6323,7 @@ var generateCoreQuickMethod = ({
|
|
|
5679
6323
|
);
|
|
5680
6324
|
if (poolCoinName === "sui") {
|
|
5681
6325
|
const [suiCoin] = txBlock.splitSUIFromGas([amount]);
|
|
5682
|
-
return txBlock.repay(
|
|
6326
|
+
return await txBlock.repay(
|
|
5683
6327
|
obligationInfo.obligationId,
|
|
5684
6328
|
suiCoin,
|
|
5685
6329
|
poolCoinName
|
|
@@ -5692,7 +6336,7 @@ var generateCoreQuickMethod = ({
|
|
|
5692
6336
|
sender
|
|
5693
6337
|
);
|
|
5694
6338
|
txBlock.transferObjects([leftCoin], sender);
|
|
5695
|
-
return txBlock.repay(
|
|
6339
|
+
return await txBlock.repay(
|
|
5696
6340
|
obligationInfo.obligationId,
|
|
5697
6341
|
takeCoin,
|
|
5698
6342
|
poolCoinName
|
|
@@ -5700,7 +6344,7 @@ var generateCoreQuickMethod = ({
|
|
|
5700
6344
|
}
|
|
5701
6345
|
},
|
|
5702
6346
|
updateAssetPricesQuick: async (assetCoinNames) => {
|
|
5703
|
-
return updateOracles(builder, txBlock, assetCoinNames);
|
|
6347
|
+
return await updateOracles(builder, txBlock, assetCoinNames);
|
|
5704
6348
|
}
|
|
5705
6349
|
};
|
|
5706
6350
|
};
|
|
@@ -5763,10 +6407,10 @@ var stakeHelper = async (builder, txBlock, stakeAccount, coinName, amount, sende
|
|
|
5763
6407
|
try {
|
|
5764
6408
|
const { takeCoin, leftCoin, totalAmount } = isSCoin ? await builder.selectSCoin(txBlock, coinName, amount, sender) : await builder.selectMarketCoin(txBlock, coinName, amount, sender);
|
|
5765
6409
|
if (isSCoin) {
|
|
5766
|
-
const marketCoin = txBlock.burnSCoin(coinName, takeCoin);
|
|
5767
|
-
txBlock.stake(stakeAccount, marketCoin, coinName);
|
|
6410
|
+
const marketCoin = await txBlock.burnSCoin(coinName, takeCoin);
|
|
6411
|
+
await txBlock.stake(stakeAccount, marketCoin, coinName);
|
|
5768
6412
|
} else {
|
|
5769
|
-
txBlock.stake(stakeAccount, takeCoin, coinName);
|
|
6413
|
+
await txBlock.stake(stakeAccount, takeCoin, coinName);
|
|
5770
6414
|
}
|
|
5771
6415
|
txBlock.transferObjects([leftCoin], sender);
|
|
5772
6416
|
return totalAmount;
|
|
@@ -5782,40 +6426,43 @@ var generateSpoolNormalMethod = ({
|
|
|
5782
6426
|
spoolPkg: builder.address.get("spool.id")
|
|
5783
6427
|
};
|
|
5784
6428
|
return {
|
|
5785
|
-
createStakeAccount: (stakeMarketCoinName) => {
|
|
6429
|
+
createStakeAccount: async (stakeMarketCoinName) => {
|
|
5786
6430
|
const marketCoinType = builder.utils.parseMarketCoinType(stakeMarketCoinName);
|
|
5787
6431
|
const stakePoolId = builder.address.get(
|
|
5788
6432
|
`spool.pools.${stakeMarketCoinName}.id`
|
|
5789
6433
|
);
|
|
5790
|
-
return
|
|
6434
|
+
return await builder.moveCall(
|
|
6435
|
+
txBlock,
|
|
5791
6436
|
`${spoolIds.spoolPkg}::user::new_spool_account`,
|
|
5792
6437
|
[stakePoolId, SUI_CLOCK_OBJECT_ID4],
|
|
5793
6438
|
[marketCoinType]
|
|
5794
6439
|
);
|
|
5795
6440
|
},
|
|
5796
|
-
stake: (stakeAccount, coin, stakeMarketCoinName) => {
|
|
6441
|
+
stake: async (stakeAccount, coin, stakeMarketCoinName) => {
|
|
5797
6442
|
const marketCoinType = builder.utils.parseMarketCoinType(stakeMarketCoinName);
|
|
5798
6443
|
const stakePoolId = builder.address.get(
|
|
5799
6444
|
`spool.pools.${stakeMarketCoinName}.id`
|
|
5800
6445
|
);
|
|
5801
|
-
|
|
6446
|
+
await builder.moveCall(
|
|
6447
|
+
txBlock,
|
|
5802
6448
|
`${spoolIds.spoolPkg}::user::stake`,
|
|
5803
6449
|
[stakePoolId, stakeAccount, coin, SUI_CLOCK_OBJECT_ID4],
|
|
5804
6450
|
[marketCoinType]
|
|
5805
6451
|
);
|
|
5806
6452
|
},
|
|
5807
|
-
unstake: (stakeAccount, amount, stakeMarketCoinName) => {
|
|
6453
|
+
unstake: async (stakeAccount, amount, stakeMarketCoinName) => {
|
|
5808
6454
|
const marketCoinType = builder.utils.parseMarketCoinType(stakeMarketCoinName);
|
|
5809
6455
|
const stakePoolId = builder.address.get(
|
|
5810
6456
|
`spool.pools.${stakeMarketCoinName}.id`
|
|
5811
6457
|
);
|
|
5812
|
-
return
|
|
6458
|
+
return await builder.moveCall(
|
|
6459
|
+
txBlock,
|
|
5813
6460
|
`${spoolIds.spoolPkg}::user::unstake`,
|
|
5814
6461
|
[stakePoolId, stakeAccount, amount, SUI_CLOCK_OBJECT_ID4],
|
|
5815
6462
|
[marketCoinType]
|
|
5816
6463
|
);
|
|
5817
6464
|
},
|
|
5818
|
-
claim: (stakeAccount, stakeMarketCoinName) => {
|
|
6465
|
+
claim: async (stakeAccount, stakeMarketCoinName) => {
|
|
5819
6466
|
const stakePoolId = builder.address.get(
|
|
5820
6467
|
`spool.pools.${stakeMarketCoinName}.id`
|
|
5821
6468
|
);
|
|
@@ -5825,7 +6472,8 @@ var generateSpoolNormalMethod = ({
|
|
|
5825
6472
|
const marketCoinType = builder.utils.parseMarketCoinType(stakeMarketCoinName);
|
|
5826
6473
|
const rewardCoinName = spoolRewardCoins[stakeMarketCoinName];
|
|
5827
6474
|
const rewardCoinType = builder.utils.parseCoinType(rewardCoinName);
|
|
5828
|
-
return
|
|
6475
|
+
return await builder.moveCall(
|
|
6476
|
+
txBlock,
|
|
5829
6477
|
`${spoolIds.spoolPkg}::user::redeem_rewards`,
|
|
5830
6478
|
[stakePoolId, rewardPoolId, stakeAccount, SUI_CLOCK_OBJECT_ID4],
|
|
5831
6479
|
[marketCoinType, rewardCoinType]
|
|
@@ -5890,13 +6538,16 @@ var generateSpoolQuickMethod = ({
|
|
|
5890
6538
|
if (account.staked === 0)
|
|
5891
6539
|
continue;
|
|
5892
6540
|
const amountToUnstake = Math.min(amount, account.staked);
|
|
5893
|
-
const marketCoin = txBlock.unstake(
|
|
6541
|
+
const marketCoin = await txBlock.unstake(
|
|
5894
6542
|
account.id,
|
|
5895
6543
|
amountToUnstake,
|
|
5896
6544
|
stakeMarketCoinName
|
|
5897
6545
|
);
|
|
5898
6546
|
if (returnSCoin) {
|
|
5899
|
-
const sCoin = txBlock.mintSCoin(
|
|
6547
|
+
const sCoin = await txBlock.mintSCoin(
|
|
6548
|
+
stakeMarketCoinName,
|
|
6549
|
+
marketCoin
|
|
6550
|
+
);
|
|
5900
6551
|
toTransfer.push(sCoin);
|
|
5901
6552
|
} else {
|
|
5902
6553
|
toTransfer.push(marketCoin);
|
|
@@ -5922,7 +6573,7 @@ var generateSpoolQuickMethod = ({
|
|
|
5922
6573
|
);
|
|
5923
6574
|
const rewardCoins = [];
|
|
5924
6575
|
for (const accountId of stakeAccountIds) {
|
|
5925
|
-
const rewardCoin = txBlock.claim(accountId, stakeMarketCoinName);
|
|
6576
|
+
const rewardCoin = await txBlock.claim(accountId, stakeMarketCoinName);
|
|
5926
6577
|
rewardCoins.push(rewardCoin);
|
|
5927
6578
|
}
|
|
5928
6579
|
return rewardCoins;
|
|
@@ -6001,8 +6652,9 @@ var generateBorrowIncentiveNormalMethod = ({ builder, txBlock }) => {
|
|
|
6001
6652
|
config: builder.address.get("vesca.config")
|
|
6002
6653
|
};
|
|
6003
6654
|
return {
|
|
6004
|
-
stakeObligation: (obligationId, obligationKey) => {
|
|
6005
|
-
|
|
6655
|
+
stakeObligation: async (obligationId, obligationKey) => {
|
|
6656
|
+
await builder.moveCall(
|
|
6657
|
+
txBlock,
|
|
6006
6658
|
`${borrowIncentiveIds.borrowIncentivePkg}::user::stake`,
|
|
6007
6659
|
[
|
|
6008
6660
|
borrowIncentiveIds.config,
|
|
@@ -6015,8 +6667,9 @@ var generateBorrowIncentiveNormalMethod = ({ builder, txBlock }) => {
|
|
|
6015
6667
|
]
|
|
6016
6668
|
);
|
|
6017
6669
|
},
|
|
6018
|
-
stakeObligationWithVesca: (obligationId, obligationKey, veScaKey) => {
|
|
6019
|
-
|
|
6670
|
+
stakeObligationWithVesca: async (obligationId, obligationKey, veScaKey) => {
|
|
6671
|
+
await builder.moveCall(
|
|
6672
|
+
txBlock,
|
|
6020
6673
|
`${borrowIncentiveIds.borrowIncentivePkg}::user::stake_with_ve_sca`,
|
|
6021
6674
|
[
|
|
6022
6675
|
borrowIncentiveIds.config,
|
|
@@ -6034,8 +6687,9 @@ var generateBorrowIncentiveNormalMethod = ({ builder, txBlock }) => {
|
|
|
6034
6687
|
[]
|
|
6035
6688
|
);
|
|
6036
6689
|
},
|
|
6037
|
-
unstakeObligation: (obligationId, obligationKey) => {
|
|
6038
|
-
|
|
6690
|
+
unstakeObligation: async (obligationId, obligationKey) => {
|
|
6691
|
+
await builder.moveCall(
|
|
6692
|
+
txBlock,
|
|
6039
6693
|
`${borrowIncentiveIds.borrowIncentivePkg}::user::unstake`,
|
|
6040
6694
|
[
|
|
6041
6695
|
borrowIncentiveIds.config,
|
|
@@ -6047,9 +6701,10 @@ var generateBorrowIncentiveNormalMethod = ({ builder, txBlock }) => {
|
|
|
6047
6701
|
]
|
|
6048
6702
|
);
|
|
6049
6703
|
},
|
|
6050
|
-
claimBorrowIncentive: (obligationId, obligationKey, rewardCoinName) => {
|
|
6704
|
+
claimBorrowIncentive: async (obligationId, obligationKey, rewardCoinName) => {
|
|
6051
6705
|
const rewardType = builder.utils.parseCoinType(rewardCoinName);
|
|
6052
|
-
return
|
|
6706
|
+
return await builder.moveCall(
|
|
6707
|
+
txBlock,
|
|
6053
6708
|
`${borrowIncentiveIds.borrowIncentivePkg}::user::redeem_rewards`,
|
|
6054
6709
|
[
|
|
6055
6710
|
borrowIncentiveIds.config,
|
|
@@ -6062,8 +6717,9 @@ var generateBorrowIncentiveNormalMethod = ({ builder, txBlock }) => {
|
|
|
6062
6717
|
[rewardType]
|
|
6063
6718
|
);
|
|
6064
6719
|
},
|
|
6065
|
-
deactivateBoost: (obligation, veScaKey) => {
|
|
6066
|
-
|
|
6720
|
+
deactivateBoost: async (obligation, veScaKey) => {
|
|
6721
|
+
await builder.moveCall(
|
|
6722
|
+
txBlock,
|
|
6067
6723
|
`${borrowIncentiveIds.borrowIncentivePkg}::user::deactivate_boost`,
|
|
6068
6724
|
[
|
|
6069
6725
|
borrowIncentiveIds.config,
|
|
@@ -6094,7 +6750,7 @@ var generateBorrowIncentiveQuickMethod = ({ builder, txBlock }) => {
|
|
|
6094
6750
|
(txn) => txn.kind === "MoveCall" && (txn.target === `${OLD_BORROW_INCENTIVE_PROTOCOL_ID}::user::unstake` || txn.target === `${builder.address.get("borrowIncentive.id")}::user::unstake`)
|
|
6095
6751
|
);
|
|
6096
6752
|
if (!obligationLocked || unstakeObligationBeforeStake) {
|
|
6097
|
-
txBlock.stakeObligation(obligationArg, obligationKeyArg);
|
|
6753
|
+
await txBlock.stakeObligation(obligationArg, obligationKeyArg);
|
|
6098
6754
|
}
|
|
6099
6755
|
},
|
|
6100
6756
|
stakeObligationWithVeScaQuick: async (obligation, obligationKey, veScaKey) => {
|
|
@@ -6115,9 +6771,9 @@ var generateBorrowIncentiveQuickMethod = ({ builder, txBlock }) => {
|
|
|
6115
6771
|
const bindedVeScaKey = await builder.query.getBindedVeScaKey(obligationArg);
|
|
6116
6772
|
const _veScaKey = bindedVeScaKey ?? veScaKey;
|
|
6117
6773
|
if (!_veScaKey) {
|
|
6118
|
-
txBlock.stakeObligation(obligationArg, obligationKeyArg);
|
|
6774
|
+
await txBlock.stakeObligation(obligationArg, obligationKeyArg);
|
|
6119
6775
|
} else {
|
|
6120
|
-
txBlock.stakeObligationWithVesca(
|
|
6776
|
+
await txBlock.stakeObligationWithVesca(
|
|
6121
6777
|
obligationArg,
|
|
6122
6778
|
obligationKeyArg,
|
|
6123
6779
|
_veScaKey
|
|
@@ -6137,7 +6793,7 @@ var generateBorrowIncentiveQuickMethod = ({ builder, txBlock }) => {
|
|
|
6137
6793
|
obligationKey
|
|
6138
6794
|
);
|
|
6139
6795
|
if (obligationLocked) {
|
|
6140
|
-
txBlock.unstakeObligation(obligationArg, obligationKeyArg);
|
|
6796
|
+
await txBlock.unstakeObligation(obligationArg, obligationKeyArg);
|
|
6141
6797
|
}
|
|
6142
6798
|
},
|
|
6143
6799
|
claimBorrowIncentiveQuick: async (rewardCoinName, obligation, obligationKey) => {
|
|
@@ -6147,7 +6803,7 @@ var generateBorrowIncentiveQuickMethod = ({ builder, txBlock }) => {
|
|
|
6147
6803
|
obligation,
|
|
6148
6804
|
obligationKey
|
|
6149
6805
|
);
|
|
6150
|
-
return txBlock.claimBorrowIncentive(
|
|
6806
|
+
return await txBlock.claimBorrowIncentive(
|
|
6151
6807
|
obligationArg,
|
|
6152
6808
|
obligationKeyArg,
|
|
6153
6809
|
rewardCoinName
|
|
@@ -6216,8 +6872,9 @@ var generateNormalVeScaMethod = ({
|
|
|
6216
6872
|
config: builder.address.get("vesca.config")
|
|
6217
6873
|
};
|
|
6218
6874
|
return {
|
|
6219
|
-
lockSca: (scaCoin, unlockAtInSecondTimestamp) => {
|
|
6220
|
-
return
|
|
6875
|
+
lockSca: async (scaCoin, unlockAtInSecondTimestamp) => {
|
|
6876
|
+
return await builder.moveCall(
|
|
6877
|
+
txBlock,
|
|
6221
6878
|
`${veScaIds.pkgId}::ve_sca::mint_ve_sca_key`,
|
|
6222
6879
|
[
|
|
6223
6880
|
veScaIds.config,
|
|
@@ -6230,8 +6887,9 @@ var generateNormalVeScaMethod = ({
|
|
|
6230
6887
|
[]
|
|
6231
6888
|
);
|
|
6232
6889
|
},
|
|
6233
|
-
extendLockPeriod: (veScaKey, newUnlockAtInSecondTimestamp) => {
|
|
6234
|
-
|
|
6890
|
+
extendLockPeriod: async (veScaKey, newUnlockAtInSecondTimestamp) => {
|
|
6891
|
+
await builder.moveCall(
|
|
6892
|
+
txBlock,
|
|
6235
6893
|
`${veScaIds.pkgId}::ve_sca::extend_lock_period`,
|
|
6236
6894
|
[
|
|
6237
6895
|
veScaIds.config,
|
|
@@ -6244,8 +6902,9 @@ var generateNormalVeScaMethod = ({
|
|
|
6244
6902
|
[]
|
|
6245
6903
|
);
|
|
6246
6904
|
},
|
|
6247
|
-
extendLockAmount: (veScaKey, scaCoin) => {
|
|
6248
|
-
|
|
6905
|
+
extendLockAmount: async (veScaKey, scaCoin) => {
|
|
6906
|
+
await builder.moveCall(
|
|
6907
|
+
txBlock,
|
|
6249
6908
|
`${veScaIds.pkgId}::ve_sca::lock_more_sca`,
|
|
6250
6909
|
[
|
|
6251
6910
|
veScaIds.config,
|
|
@@ -6258,8 +6917,9 @@ var generateNormalVeScaMethod = ({
|
|
|
6258
6917
|
[]
|
|
6259
6918
|
);
|
|
6260
6919
|
},
|
|
6261
|
-
renewExpiredVeSca: (veScaKey, scaCoin, newUnlockAtInSecondTimestamp) => {
|
|
6262
|
-
|
|
6920
|
+
renewExpiredVeSca: async (veScaKey, scaCoin, newUnlockAtInSecondTimestamp) => {
|
|
6921
|
+
await builder.moveCall(
|
|
6922
|
+
txBlock,
|
|
6263
6923
|
`${veScaIds.pkgId}::ve_sca::renew_expired_ve_sca`,
|
|
6264
6924
|
[
|
|
6265
6925
|
veScaIds.config,
|
|
@@ -6273,8 +6933,9 @@ var generateNormalVeScaMethod = ({
|
|
|
6273
6933
|
[]
|
|
6274
6934
|
);
|
|
6275
6935
|
},
|
|
6276
|
-
redeemSca: (veScaKey) => {
|
|
6277
|
-
return
|
|
6936
|
+
redeemSca: async (veScaKey) => {
|
|
6937
|
+
return await builder.moveCall(
|
|
6938
|
+
txBlock,
|
|
6278
6939
|
`${veScaIds.pkgId}::ve_sca::redeem`,
|
|
6279
6940
|
[
|
|
6280
6941
|
veScaIds.config,
|
|
@@ -6286,8 +6947,9 @@ var generateNormalVeScaMethod = ({
|
|
|
6286
6947
|
[]
|
|
6287
6948
|
);
|
|
6288
6949
|
},
|
|
6289
|
-
mintEmptyVeSca: () => {
|
|
6290
|
-
return
|
|
6950
|
+
mintEmptyVeSca: async () => {
|
|
6951
|
+
return await builder.moveCall(
|
|
6952
|
+
txBlock,
|
|
6291
6953
|
`${veScaIds.pkgId}::ve_sca::mint_ve_sca_placeholder_key`,
|
|
6292
6954
|
[veScaIds.config, veScaIds.table],
|
|
6293
6955
|
[]
|
|
@@ -6425,7 +7087,7 @@ var generateQuickVeScaMethod = ({
|
|
|
6425
7087
|
const veSca = await requireVeSca(builder, txBlock, veScaKey);
|
|
6426
7088
|
checkVesca(veSca?.unlockAt);
|
|
6427
7089
|
if (veSca) {
|
|
6428
|
-
const sca = txBlock.redeemSca(veSca.keyId);
|
|
7090
|
+
const sca = await txBlock.redeemSca(veSca.keyId);
|
|
6429
7091
|
if (transferSca) {
|
|
6430
7092
|
txBlock.transferObjects([sca], sender);
|
|
6431
7093
|
return;
|
|
@@ -6485,8 +7147,9 @@ var generateReferralNormalMethod = ({
|
|
|
6485
7147
|
};
|
|
6486
7148
|
const veScaTable = builder.address.get("vesca.table");
|
|
6487
7149
|
return {
|
|
6488
|
-
bindToReferral: (veScaKeyId) => {
|
|
6489
|
-
|
|
7150
|
+
bindToReferral: async (veScaKeyId) => {
|
|
7151
|
+
await builder.moveCall(
|
|
7152
|
+
txBlock,
|
|
6490
7153
|
`${referralIds.referralPgkId}::referral_bindings::bind_ve_sca_referrer`,
|
|
6491
7154
|
[
|
|
6492
7155
|
referralIds.referralBindings,
|
|
@@ -6497,9 +7160,10 @@ var generateReferralNormalMethod = ({
|
|
|
6497
7160
|
[]
|
|
6498
7161
|
);
|
|
6499
7162
|
},
|
|
6500
|
-
claimReferralTicket: (poolCoinName) => {
|
|
7163
|
+
claimReferralTicket: async (poolCoinName) => {
|
|
6501
7164
|
const coinType = builder.utils.parseCoinType(poolCoinName);
|
|
6502
|
-
return
|
|
7165
|
+
return await builder.moveCall(
|
|
7166
|
+
txBlock,
|
|
6503
7167
|
`${referralIds.referralPgkId}::scallop_referral_program::claim_ve_sca_referral_ticket`,
|
|
6504
7168
|
[
|
|
6505
7169
|
referralIds.version,
|
|
@@ -6512,9 +7176,10 @@ var generateReferralNormalMethod = ({
|
|
|
6512
7176
|
[coinType]
|
|
6513
7177
|
);
|
|
6514
7178
|
},
|
|
6515
|
-
burnReferralTicket: (ticket, poolCoinName) => {
|
|
7179
|
+
burnReferralTicket: async (ticket, poolCoinName) => {
|
|
6516
7180
|
const coinType = builder.utils.parseCoinType(poolCoinName);
|
|
6517
|
-
|
|
7181
|
+
await builder.moveCall(
|
|
7182
|
+
txBlock,
|
|
6518
7183
|
`${referralIds.referralPgkId}::scallop_referral_program::burn_ve_sca_referral_ticket`,
|
|
6519
7184
|
[
|
|
6520
7185
|
referralIds.version,
|
|
@@ -6525,9 +7190,10 @@ var generateReferralNormalMethod = ({
|
|
|
6525
7190
|
[coinType]
|
|
6526
7191
|
);
|
|
6527
7192
|
},
|
|
6528
|
-
claimReferralRevenue: (veScaKey, poolCoinName) => {
|
|
7193
|
+
claimReferralRevenue: async (veScaKey, poolCoinName) => {
|
|
6529
7194
|
const coinType = builder.utils.parseCoinType(poolCoinName);
|
|
6530
|
-
return
|
|
7195
|
+
return await builder.moveCall(
|
|
7196
|
+
txBlock,
|
|
6531
7197
|
`${referralIds.referralPgkId}::referral_revenue_pool::claim_revenue_with_ve_sca_key`,
|
|
6532
7198
|
[
|
|
6533
7199
|
referralIds.version,
|
|
@@ -6550,10 +7216,16 @@ var generateReferralQuickMethod = ({
|
|
|
6550
7216
|
const objToTransfer = [];
|
|
6551
7217
|
for (const coinName of coinNames) {
|
|
6552
7218
|
if (coinName === "sui") {
|
|
6553
|
-
const rewardCoin = txBlock.claimReferralRevenue(
|
|
7219
|
+
const rewardCoin = await txBlock.claimReferralRevenue(
|
|
7220
|
+
veScaKey,
|
|
7221
|
+
coinName
|
|
7222
|
+
);
|
|
6554
7223
|
objToTransfer.push(rewardCoin);
|
|
6555
7224
|
} else {
|
|
6556
|
-
const rewardCoin = txBlock.claimReferralRevenue(
|
|
7225
|
+
const rewardCoin = await txBlock.claimReferralRevenue(
|
|
7226
|
+
veScaKey,
|
|
7227
|
+
coinName
|
|
7228
|
+
);
|
|
6557
7229
|
try {
|
|
6558
7230
|
const coins = await builder.suiKit.suiInteractor.selectCoins(
|
|
6559
7231
|
sender,
|
|
@@ -6613,8 +7285,9 @@ var generateLoyaltyProgramNormalMethod = ({ builder, txBlock }) => {
|
|
|
6613
7285
|
)
|
|
6614
7286
|
};
|
|
6615
7287
|
return {
|
|
6616
|
-
claimLoyaltyRevenue: (veScaKey) => {
|
|
6617
|
-
return
|
|
7288
|
+
claimLoyaltyRevenue: async (veScaKey) => {
|
|
7289
|
+
return await builder.moveCall(
|
|
7290
|
+
txBlock,
|
|
6618
7291
|
`${loyaltyProgramIds.loyaltyProgramPkgId}::reward_pool::redeem_reward`,
|
|
6619
7292
|
[loyaltyProgramIds.rewardPool, veScaKey]
|
|
6620
7293
|
);
|
|
@@ -6631,7 +7304,7 @@ var generateLoyaltyProgramQuickMethod = ({
|
|
|
6631
7304
|
const sender = requireSender(txBlock);
|
|
6632
7305
|
if (!veScaKey)
|
|
6633
7306
|
throw new Error(`No veScaKey found for user ${sender}`);
|
|
6634
|
-
const rewardCoin = txBlock.claimLoyaltyRevenue(veScaKey);
|
|
7307
|
+
const rewardCoin = await txBlock.claimLoyaltyRevenue(veScaKey);
|
|
6635
7308
|
await builder.utils.mergeSimilarCoins(
|
|
6636
7309
|
txBlock,
|
|
6637
7310
|
rewardCoin,
|
|
@@ -6680,8 +7353,9 @@ var generateSCoinNormalMethod = ({
|
|
|
6680
7353
|
pkgId: builder.address.get("scoin.id")
|
|
6681
7354
|
};
|
|
6682
7355
|
return {
|
|
6683
|
-
mintSCoin: (marketCoinName, marketCoin) => {
|
|
6684
|
-
return
|
|
7356
|
+
mintSCoin: async (marketCoinName, marketCoin) => {
|
|
7357
|
+
return await builder.moveCall(
|
|
7358
|
+
txBlock,
|
|
6685
7359
|
`${sCoinPkgIds.pkgId}::s_coin_converter::mint_s_coin`,
|
|
6686
7360
|
[builder.utils.getSCoinTreasury(marketCoinName), marketCoin],
|
|
6687
7361
|
[
|
|
@@ -6690,8 +7364,9 @@ var generateSCoinNormalMethod = ({
|
|
|
6690
7364
|
]
|
|
6691
7365
|
);
|
|
6692
7366
|
},
|
|
6693
|
-
burnSCoin: (sCoinName, sCoin) => {
|
|
6694
|
-
return
|
|
7367
|
+
burnSCoin: async (sCoinName, sCoin) => {
|
|
7368
|
+
return await builder.moveCall(
|
|
7369
|
+
txBlock,
|
|
6695
7370
|
`${sCoinPkgIds.pkgId}::s_coin_converter::burn_s_coin`,
|
|
6696
7371
|
[builder.utils.getSCoinTreasury(sCoinName), sCoin],
|
|
6697
7372
|
[
|
|
@@ -6716,7 +7391,7 @@ var generateSCoinQuickMethod = ({
|
|
|
6716
7391
|
sender
|
|
6717
7392
|
);
|
|
6718
7393
|
txBlock.transferObjects([leftCoin], sender);
|
|
6719
|
-
return txBlock.mintSCoin(marketCoinName, takeCoin);
|
|
7394
|
+
return await txBlock.mintSCoin(marketCoinName, takeCoin);
|
|
6720
7395
|
},
|
|
6721
7396
|
burnSCoinQuick: async (sCoinName, amount) => {
|
|
6722
7397
|
const sender = requireSender(txBlock);
|
|
@@ -6727,7 +7402,7 @@ var generateSCoinQuickMethod = ({
|
|
|
6727
7402
|
sender
|
|
6728
7403
|
);
|
|
6729
7404
|
txBlock.transferObjects([leftCoin], sender);
|
|
6730
|
-
return txBlock.burnSCoin(sCoinName, takeCoin);
|
|
7405
|
+
return await txBlock.burnSCoin(sCoinName, takeCoin);
|
|
6731
7406
|
}
|
|
6732
7407
|
};
|
|
6733
7408
|
};
|
|
@@ -7049,6 +7724,7 @@ var ScallopQuery = class {
|
|
|
7049
7724
|
}
|
|
7050
7725
|
/* ==================== Core Query Methods ==================== */
|
|
7051
7726
|
/**
|
|
7727
|
+
* @deprecated use getMarketPools
|
|
7052
7728
|
* Query market data.
|
|
7053
7729
|
* @param indexer - Whether to use indexer.
|
|
7054
7730
|
* @return Market data.
|
|
@@ -7067,7 +7743,7 @@ var ScallopQuery = class {
|
|
|
7067
7743
|
* @param indexer - Whether to use indexer.
|
|
7068
7744
|
* @return Market pools data.
|
|
7069
7745
|
*/
|
|
7070
|
-
async getMarketPools(poolCoinNames, args) {
|
|
7746
|
+
async getMarketPools(poolCoinNames = [...SUPPORT_POOLS], args) {
|
|
7071
7747
|
return await getMarketPools(
|
|
7072
7748
|
this,
|
|
7073
7749
|
poolCoinNames,
|
|
@@ -7083,13 +7759,8 @@ var ScallopQuery = class {
|
|
|
7083
7759
|
* @return Market pool data.
|
|
7084
7760
|
*/
|
|
7085
7761
|
async getMarketPool(poolCoinName, args) {
|
|
7086
|
-
|
|
7087
|
-
|
|
7088
|
-
poolCoinName,
|
|
7089
|
-
args?.indexer,
|
|
7090
|
-
args?.marketObject,
|
|
7091
|
-
args?.coinPrice
|
|
7092
|
-
);
|
|
7762
|
+
const marketPools = await this.getMarketPools(void 0, args);
|
|
7763
|
+
return marketPools.pools[poolCoinName];
|
|
7093
7764
|
}
|
|
7094
7765
|
/**
|
|
7095
7766
|
* Get market collaterals.
|
|
@@ -7216,13 +7887,8 @@ var ScallopQuery = class {
|
|
|
7216
7887
|
* @return Spool data.
|
|
7217
7888
|
*/
|
|
7218
7889
|
async getSpool(stakeMarketCoinName, args) {
|
|
7219
|
-
|
|
7220
|
-
|
|
7221
|
-
stakeMarketCoinName,
|
|
7222
|
-
args?.indexer,
|
|
7223
|
-
args?.marketPool,
|
|
7224
|
-
args?.coinPrices
|
|
7225
|
-
);
|
|
7890
|
+
const spools = await this.getSpools(void 0, args);
|
|
7891
|
+
return spools[stakeMarketCoinName];
|
|
7226
7892
|
}
|
|
7227
7893
|
/**
|
|
7228
7894
|
* Get stake accounts data for all stake pools (spools).
|
|
@@ -7388,11 +8054,9 @@ var ScallopQuery = class {
|
|
|
7388
8054
|
* @return Borrowing and collateral information.
|
|
7389
8055
|
*/
|
|
7390
8056
|
async getObligationAccount(obligationId, ownerAddress = this.walletAddress, args) {
|
|
7391
|
-
|
|
7392
|
-
|
|
7393
|
-
obligationId
|
|
7394
|
-
ownerAddress,
|
|
7395
|
-
args?.indexer
|
|
8057
|
+
const results = await this.getObligationAccounts(ownerAddress, args);
|
|
8058
|
+
return Object.values(results).find(
|
|
8059
|
+
(obligation) => obligation?.obligationId === obligationId
|
|
7396
8060
|
);
|
|
7397
8061
|
}
|
|
7398
8062
|
/**
|
|
@@ -7527,7 +8191,7 @@ var ScallopQuery = class {
|
|
|
7527
8191
|
* Get list of isolated assets
|
|
7528
8192
|
*/
|
|
7529
8193
|
async getIsolatedAssets() {
|
|
7530
|
-
return await getIsolatedAssets(this
|
|
8194
|
+
return await getIsolatedAssets(this);
|
|
7531
8195
|
}
|
|
7532
8196
|
/**
|
|
7533
8197
|
* Check if asset is an isolated asset
|
|
@@ -7550,6 +8214,13 @@ var ScallopQuery = class {
|
|
|
7550
8214
|
async getAllCoinPrices(args) {
|
|
7551
8215
|
return getAllCoinPrices(this, args?.marketPools, args?.coinPrices);
|
|
7552
8216
|
}
|
|
8217
|
+
/**
|
|
8218
|
+
* Query all address (lending pool, collateral pool, borrow dynamics, interest models) of all pool
|
|
8219
|
+
* @returns
|
|
8220
|
+
*/
|
|
8221
|
+
async getPoolAddresses() {
|
|
8222
|
+
return getAllAddresses(this);
|
|
8223
|
+
}
|
|
7553
8224
|
};
|
|
7554
8225
|
|
|
7555
8226
|
// src/models/scallopBuilder.ts
|
|
@@ -7608,7 +8279,6 @@ var ScallopBuilder = class {
|
|
|
7608
8279
|
await this.address.read();
|
|
7609
8280
|
}
|
|
7610
8281
|
await this.query.init(force, this.address);
|
|
7611
|
-
await this.utils.init(force, this.address);
|
|
7612
8282
|
}
|
|
7613
8283
|
/**
|
|
7614
8284
|
* Create a scallop txBlock instance that enhances transaction block.
|
|
@@ -7697,6 +8367,9 @@ var ScallopBuilder = class {
|
|
|
7697
8367
|
txBlock
|
|
7698
8368
|
);
|
|
7699
8369
|
}
|
|
8370
|
+
moveCall(txb, target, args, typeArgs) {
|
|
8371
|
+
return txb.moveCall(target, args, typeArgs);
|
|
8372
|
+
}
|
|
7700
8373
|
};
|
|
7701
8374
|
|
|
7702
8375
|
// src/models/scallopClient.ts
|
|
@@ -7843,7 +8516,7 @@ var ScallopClient = class {
|
|
|
7843
8516
|
}
|
|
7844
8517
|
async openObligation(sign = true) {
|
|
7845
8518
|
const txBlock = this.builder.createTxBlock();
|
|
7846
|
-
txBlock.openObligationEntry();
|
|
8519
|
+
await txBlock.openObligationEntry();
|
|
7847
8520
|
if (sign) {
|
|
7848
8521
|
return await this.suiKit.signAndSendTxn(
|
|
7849
8522
|
txBlock
|
|
@@ -7865,9 +8538,9 @@ var ScallopClient = class {
|
|
|
7865
8538
|
specificObligationId
|
|
7866
8539
|
);
|
|
7867
8540
|
} else {
|
|
7868
|
-
const [obligation, obligationKey, hotPotato] = txBlock.openObligation();
|
|
8541
|
+
const [obligation, obligationKey, hotPotato] = await txBlock.openObligation();
|
|
7869
8542
|
await txBlock.addCollateralQuick(amount, collateralCoinName, obligation);
|
|
7870
|
-
txBlock.returnObligation(obligation, hotPotato);
|
|
8543
|
+
await txBlock.returnObligation(obligation, hotPotato);
|
|
7871
8544
|
txBlock.transferObjects([obligationKey], sender);
|
|
7872
8545
|
}
|
|
7873
8546
|
if (sign) {
|
|
@@ -7937,7 +8610,7 @@ var ScallopClient = class {
|
|
|
7937
8610
|
targetStakeAccount
|
|
7938
8611
|
);
|
|
7939
8612
|
} else {
|
|
7940
|
-
const account = txBlock.createStakeAccount(stakeMarketCoinName);
|
|
8613
|
+
const account = await txBlock.createStakeAccount(stakeMarketCoinName);
|
|
7941
8614
|
await txBlock.stakeQuick(marketCoin, stakeMarketCoinName, account);
|
|
7942
8615
|
txBlock.transferObjects([account], sender);
|
|
7943
8616
|
}
|
|
@@ -8034,8 +8707,12 @@ var ScallopClient = class {
|
|
|
8034
8707
|
const txBlock = this.builder.createTxBlock();
|
|
8035
8708
|
const sender = walletAddress ?? this.walletAddress;
|
|
8036
8709
|
txBlock.setSender(sender);
|
|
8037
|
-
const [coin, loan] = txBlock.borrowFlashLoan(amount, poolCoinName);
|
|
8038
|
-
txBlock.repayFlashLoan(
|
|
8710
|
+
const [coin, loan] = await txBlock.borrowFlashLoan(amount, poolCoinName);
|
|
8711
|
+
await txBlock.repayFlashLoan(
|
|
8712
|
+
await callback(txBlock, coin),
|
|
8713
|
+
loan,
|
|
8714
|
+
poolCoinName
|
|
8715
|
+
);
|
|
8039
8716
|
if (sign) {
|
|
8040
8717
|
return await this.suiKit.signAndSendTxn(
|
|
8041
8718
|
txBlock
|
|
@@ -8048,7 +8725,7 @@ var ScallopClient = class {
|
|
|
8048
8725
|
const txBlock = this.builder.createTxBlock();
|
|
8049
8726
|
const sender = walletAddress ?? this.walletAddress;
|
|
8050
8727
|
txBlock.setSender(sender);
|
|
8051
|
-
const stakeAccount = txBlock.createStakeAccount(marketCoinName);
|
|
8728
|
+
const stakeAccount = await txBlock.createStakeAccount(marketCoinName);
|
|
8052
8729
|
txBlock.transferObjects([stakeAccount], sender);
|
|
8053
8730
|
if (sign) {
|
|
8054
8731
|
return await this.suiKit.signAndSendTxn(
|
|
@@ -8067,7 +8744,7 @@ var ScallopClient = class {
|
|
|
8067
8744
|
if (targetStakeAccount) {
|
|
8068
8745
|
await txBlock.stakeQuick(amount, stakeMarketCoinName, targetStakeAccount);
|
|
8069
8746
|
} else {
|
|
8070
|
-
const account = txBlock.createStakeAccount(stakeMarketCoinName);
|
|
8747
|
+
const account = await txBlock.createStakeAccount(stakeMarketCoinName);
|
|
8071
8748
|
await txBlock.stakeQuick(amount, stakeMarketCoinName, account);
|
|
8072
8749
|
txBlock.transferObjects([account], sender);
|
|
8073
8750
|
}
|
|
@@ -8117,7 +8794,7 @@ var ScallopClient = class {
|
|
|
8117
8794
|
);
|
|
8118
8795
|
const stakeCoinName = this.utils.parseCoinName(stakeMarketCoinName);
|
|
8119
8796
|
if (stakeMarketCoin) {
|
|
8120
|
-
const coin = txBlock.withdraw(stakeMarketCoin, stakeCoinName);
|
|
8797
|
+
const coin = await txBlock.withdraw(stakeMarketCoin, stakeCoinName);
|
|
8121
8798
|
await this.utils.mergeSimilarCoins(
|
|
8122
8799
|
txBlock,
|
|
8123
8800
|
coin,
|
|
@@ -8214,6 +8891,8 @@ var ScallopClient = class {
|
|
|
8214
8891
|
txBlock.setSender(sender);
|
|
8215
8892
|
const rewardCoinsCollection = {};
|
|
8216
8893
|
const obligationAccount = await this.query.getObligationAccount(obligationId);
|
|
8894
|
+
if (!obligationAccount)
|
|
8895
|
+
throw new Error("Obligation not found");
|
|
8217
8896
|
const rewardCoinNames = Object.values(obligationAccount.borrowIncentives).flatMap(
|
|
8218
8897
|
({ rewards }) => rewards.filter(({ availableClaimAmount }) => availableClaimAmount > 0)
|
|
8219
8898
|
).flatMap(({ coinName }) => coinName);
|
|
@@ -8276,7 +8955,7 @@ var ScallopClient = class {
|
|
|
8276
8955
|
throw e;
|
|
8277
8956
|
}
|
|
8278
8957
|
if (toDestroyMarketCoin) {
|
|
8279
|
-
const sCoin = txBlock.mintSCoin(
|
|
8958
|
+
const sCoin = await txBlock.mintSCoin(
|
|
8280
8959
|
sCoinName,
|
|
8281
8960
|
toDestroyMarketCoin
|
|
8282
8961
|
);
|
|
@@ -8544,9 +9223,11 @@ export {
|
|
|
8544
9223
|
ScallopQuery,
|
|
8545
9224
|
ScallopUtils,
|
|
8546
9225
|
TEST_ADDRESSES,
|
|
9226
|
+
TokenBucket,
|
|
8547
9227
|
UNLOCK_ROUND_DURATION,
|
|
8548
9228
|
USE_TEST_ADDRESS,
|
|
8549
9229
|
assetCoins,
|
|
9230
|
+
callWithRateLimit,
|
|
8550
9231
|
coinDecimals,
|
|
8551
9232
|
coinIds,
|
|
8552
9233
|
marketCoins,
|