@scallop-io/sui-scallop-sdk 0.46.33 → 0.46.34
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/README.md +1 -1
- package/dist/index.js +17 -18
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +17 -18
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
- package/src/models/scallopCache.ts +4 -3
- package/src/queries/borrowIncentiveQuery.ts +12 -15
- package/src/queries/portfolioQuery.ts +4 -4
package/README.md
CHANGED
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
|
|
17
17
|
## Description
|
|
18
18
|
|
|
19
|
-
This SDK is used to interact with [sui-lending-
|
|
19
|
+
This SDK is used to interact with [sui-lending-protocol](https://github.com/scallop-io/sui-lending-protocol) and is written based on another sui-integrated tool, [sui-kit](https://github.com/scallop-io/sui-kit). It consists of seven main functional models, here's a brief introduction to each of them:
|
|
20
20
|
|
|
21
21
|
- **Scallop**: Provide an entry to quickly create an instance (client, address, query, builder, utils) and complete initialization at the same time.
|
|
22
22
|
|
package/dist/index.js
CHANGED
|
@@ -395,6 +395,9 @@ var ScallopCache = class {
|
|
|
395
395
|
JSON.stringify(objectIds),
|
|
396
396
|
this.suiKit.currentAddress()
|
|
397
397
|
];
|
|
398
|
+
if (options) {
|
|
399
|
+
queryKey.push(JSON.stringify(options));
|
|
400
|
+
}
|
|
398
401
|
return this.queryClient.fetchQuery({
|
|
399
402
|
queryKey,
|
|
400
403
|
queryFn: async () => {
|
|
@@ -433,9 +436,6 @@ var ScallopCache = class {
|
|
|
433
436
|
if (input.cursor) {
|
|
434
437
|
queryKey.push(JSON.stringify(input.cursor));
|
|
435
438
|
}
|
|
436
|
-
if (input.cursor) {
|
|
437
|
-
queryKey.push(JSON.stringify(input.cursor));
|
|
438
|
-
}
|
|
439
439
|
if (input.limit) {
|
|
440
440
|
queryKey.push(JSON.stringify(input.limit));
|
|
441
441
|
}
|
|
@@ -450,6 +450,7 @@ var ScallopCache = class {
|
|
|
450
450
|
const queryKey = [
|
|
451
451
|
"getDynamicFieldObject",
|
|
452
452
|
input.parentId,
|
|
453
|
+
input.name.type,
|
|
453
454
|
input.name.value
|
|
454
455
|
];
|
|
455
456
|
return this.queryClient.fetchQuery({
|
|
@@ -2659,19 +2660,18 @@ var getBindedObligationId = async (query, veScaKeyId) => {
|
|
|
2659
2660
|
const borrowIncentiveObjectId = query.address.get("borrowIncentive.object");
|
|
2660
2661
|
const incentivePoolsId = query.address.get("borrowIncentive.incentivePools");
|
|
2661
2662
|
const veScaObjId = query.address.get("vesca.object");
|
|
2662
|
-
const
|
|
2663
|
-
|
|
2664
|
-
|
|
2665
|
-
options: {
|
|
2663
|
+
const incentivePoolsResponse = await query.cache.queryGetObject(
|
|
2664
|
+
incentivePoolsId,
|
|
2665
|
+
{
|
|
2666
2666
|
showContent: true
|
|
2667
2667
|
}
|
|
2668
|
-
|
|
2668
|
+
);
|
|
2669
2669
|
if (incentivePoolsResponse.data?.content?.dataType !== "moveObject")
|
|
2670
2670
|
return null;
|
|
2671
2671
|
const incentivePoolFields = incentivePoolsResponse.data.content.fields;
|
|
2672
2672
|
const veScaBindTableId = incentivePoolFields.ve_sca_bind.fields.id.id;
|
|
2673
2673
|
const keyType = `${borrowIncentiveObjectId}::typed_id::TypedID<${veScaObjId}::ve_sca::VeScaKey>`;
|
|
2674
|
-
const veScaBindTableResponse = await
|
|
2674
|
+
const veScaBindTableResponse = await query.cache.queryGetDynamicFieldObject({
|
|
2675
2675
|
parentId: veScaBindTableId,
|
|
2676
2676
|
name: {
|
|
2677
2677
|
type: keyType,
|
|
@@ -2690,17 +2690,16 @@ var getBindedVeScaKey = async (query, obliationId) => {
|
|
|
2690
2690
|
"borrowIncentive.incentiveAccounts"
|
|
2691
2691
|
);
|
|
2692
2692
|
const corePkg = query.address.get("core.object");
|
|
2693
|
-
const
|
|
2694
|
-
|
|
2695
|
-
|
|
2696
|
-
options: {
|
|
2693
|
+
const incentiveAccountsObject = await query.cache.queryGetObject(
|
|
2694
|
+
incentiveAccountsId,
|
|
2695
|
+
{
|
|
2697
2696
|
showContent: true
|
|
2698
2697
|
}
|
|
2699
|
-
|
|
2698
|
+
);
|
|
2700
2699
|
if (incentiveAccountsObject.data?.content?.dataType !== "moveObject")
|
|
2701
2700
|
return null;
|
|
2702
2701
|
const incentiveAccountsTableId = incentiveAccountsObject.data.content.fields.accounts.fields.id.id;
|
|
2703
|
-
const bindedIncentiveAcc = await
|
|
2702
|
+
const bindedIncentiveAcc = await query.cache.queryGetDynamicFieldObject({
|
|
2704
2703
|
parentId: incentiveAccountsTableId,
|
|
2705
2704
|
name: {
|
|
2706
2705
|
type: `${borrowIncentiveObjectId}::typed_id::TypedID<${corePkg}::obligation::Obligation>`,
|
|
@@ -3051,11 +3050,11 @@ var getObligationAccount = async (query, obligationId, ownerAddress, indexer = f
|
|
|
3051
3050
|
const coinAmount = coinAmounts?.[assetCoinName] ?? 0;
|
|
3052
3051
|
if (marketPool && coinPrice) {
|
|
3053
3052
|
const increasedRate = debt?.borrowIndex ? marketPool.borrowIndex / Number(debt.borrowIndex) - 1 : 0;
|
|
3054
|
-
const borrowedAmount = (0, import_bignumber4.default)(debt?.amount ?? 0)
|
|
3055
|
-
const borrowedCoin = borrowedAmount.shiftedBy(-1 * coinDecimal);
|
|
3056
|
-
const requiredRepayAmount = borrowedAmount.multipliedBy(
|
|
3053
|
+
const borrowedAmount = (0, import_bignumber4.default)(debt?.amount ?? 0).multipliedBy(
|
|
3057
3054
|
increasedRate + 1
|
|
3058
3055
|
);
|
|
3056
|
+
const borrowedCoin = borrowedAmount.shiftedBy(-1 * coinDecimal);
|
|
3057
|
+
const requiredRepayAmount = borrowedAmount;
|
|
3059
3058
|
const requiredRepayCoin = requiredRepayAmount.shiftedBy(-1 * coinDecimal);
|
|
3060
3059
|
const availableRepayAmount = (0, import_bignumber4.default)(coinAmount);
|
|
3061
3060
|
const availableRepayCoin = availableRepayAmount.shiftedBy(
|