@scallop-io/sui-scallop-sdk 0.46.33 → 0.46.35
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 +25 -25
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +25 -25
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
- package/src/builders/referralBuilder.ts +9 -9
- package/src/models/scallopCache.ts +4 -3
- package/src/queries/borrowIncentiveQuery.ts +12 -15
- package/src/queries/portfolioQuery.ts +4 -4
package/dist/index.mjs
CHANGED
|
@@ -322,6 +322,9 @@ var ScallopCache = class {
|
|
|
322
322
|
JSON.stringify(objectIds),
|
|
323
323
|
this.suiKit.currentAddress()
|
|
324
324
|
];
|
|
325
|
+
if (options) {
|
|
326
|
+
queryKey.push(JSON.stringify(options));
|
|
327
|
+
}
|
|
325
328
|
return this.queryClient.fetchQuery({
|
|
326
329
|
queryKey,
|
|
327
330
|
queryFn: async () => {
|
|
@@ -360,9 +363,6 @@ var ScallopCache = class {
|
|
|
360
363
|
if (input.cursor) {
|
|
361
364
|
queryKey.push(JSON.stringify(input.cursor));
|
|
362
365
|
}
|
|
363
|
-
if (input.cursor) {
|
|
364
|
-
queryKey.push(JSON.stringify(input.cursor));
|
|
365
|
-
}
|
|
366
366
|
if (input.limit) {
|
|
367
367
|
queryKey.push(JSON.stringify(input.limit));
|
|
368
368
|
}
|
|
@@ -377,6 +377,7 @@ var ScallopCache = class {
|
|
|
377
377
|
const queryKey = [
|
|
378
378
|
"getDynamicFieldObject",
|
|
379
379
|
input.parentId,
|
|
380
|
+
input.name.type,
|
|
380
381
|
input.name.value
|
|
381
382
|
];
|
|
382
383
|
return this.queryClient.fetchQuery({
|
|
@@ -2586,19 +2587,18 @@ var getBindedObligationId = async (query, veScaKeyId) => {
|
|
|
2586
2587
|
const borrowIncentiveObjectId = query.address.get("borrowIncentive.object");
|
|
2587
2588
|
const incentivePoolsId = query.address.get("borrowIncentive.incentivePools");
|
|
2588
2589
|
const veScaObjId = query.address.get("vesca.object");
|
|
2589
|
-
const
|
|
2590
|
-
|
|
2591
|
-
|
|
2592
|
-
options: {
|
|
2590
|
+
const incentivePoolsResponse = await query.cache.queryGetObject(
|
|
2591
|
+
incentivePoolsId,
|
|
2592
|
+
{
|
|
2593
2593
|
showContent: true
|
|
2594
2594
|
}
|
|
2595
|
-
|
|
2595
|
+
);
|
|
2596
2596
|
if (incentivePoolsResponse.data?.content?.dataType !== "moveObject")
|
|
2597
2597
|
return null;
|
|
2598
2598
|
const incentivePoolFields = incentivePoolsResponse.data.content.fields;
|
|
2599
2599
|
const veScaBindTableId = incentivePoolFields.ve_sca_bind.fields.id.id;
|
|
2600
2600
|
const keyType = `${borrowIncentiveObjectId}::typed_id::TypedID<${veScaObjId}::ve_sca::VeScaKey>`;
|
|
2601
|
-
const veScaBindTableResponse = await
|
|
2601
|
+
const veScaBindTableResponse = await query.cache.queryGetDynamicFieldObject({
|
|
2602
2602
|
parentId: veScaBindTableId,
|
|
2603
2603
|
name: {
|
|
2604
2604
|
type: keyType,
|
|
@@ -2617,17 +2617,16 @@ var getBindedVeScaKey = async (query, obliationId) => {
|
|
|
2617
2617
|
"borrowIncentive.incentiveAccounts"
|
|
2618
2618
|
);
|
|
2619
2619
|
const corePkg = query.address.get("core.object");
|
|
2620
|
-
const
|
|
2621
|
-
|
|
2622
|
-
|
|
2623
|
-
options: {
|
|
2620
|
+
const incentiveAccountsObject = await query.cache.queryGetObject(
|
|
2621
|
+
incentiveAccountsId,
|
|
2622
|
+
{
|
|
2624
2623
|
showContent: true
|
|
2625
2624
|
}
|
|
2626
|
-
|
|
2625
|
+
);
|
|
2627
2626
|
if (incentiveAccountsObject.data?.content?.dataType !== "moveObject")
|
|
2628
2627
|
return null;
|
|
2629
2628
|
const incentiveAccountsTableId = incentiveAccountsObject.data.content.fields.accounts.fields.id.id;
|
|
2630
|
-
const bindedIncentiveAcc = await
|
|
2629
|
+
const bindedIncentiveAcc = await query.cache.queryGetDynamicFieldObject({
|
|
2631
2630
|
parentId: incentiveAccountsTableId,
|
|
2632
2631
|
name: {
|
|
2633
2632
|
type: `${borrowIncentiveObjectId}::typed_id::TypedID<${corePkg}::obligation::Obligation>`,
|
|
@@ -2978,11 +2977,11 @@ var getObligationAccount = async (query, obligationId, ownerAddress, indexer = f
|
|
|
2978
2977
|
const coinAmount = coinAmounts?.[assetCoinName] ?? 0;
|
|
2979
2978
|
if (marketPool && coinPrice) {
|
|
2980
2979
|
const increasedRate = debt?.borrowIndex ? marketPool.borrowIndex / Number(debt.borrowIndex) - 1 : 0;
|
|
2981
|
-
const borrowedAmount = BigNumber4(debt?.amount ?? 0)
|
|
2982
|
-
const borrowedCoin = borrowedAmount.shiftedBy(-1 * coinDecimal);
|
|
2983
|
-
const requiredRepayAmount = borrowedAmount.multipliedBy(
|
|
2980
|
+
const borrowedAmount = BigNumber4(debt?.amount ?? 0).multipliedBy(
|
|
2984
2981
|
increasedRate + 1
|
|
2985
2982
|
);
|
|
2983
|
+
const borrowedCoin = borrowedAmount.shiftedBy(-1 * coinDecimal);
|
|
2984
|
+
const requiredRepayAmount = borrowedAmount;
|
|
2986
2985
|
const requiredRepayCoin = requiredRepayAmount.shiftedBy(-1 * coinDecimal);
|
|
2987
2986
|
const availableRepayAmount = BigNumber4(coinAmount);
|
|
2988
2987
|
const availableRepayCoin = availableRepayAmount.shiftedBy(
|
|
@@ -5589,16 +5588,17 @@ var generateReferralQuickMethod = ({
|
|
|
5589
5588
|
const rewardCoin = txBlock.claimReferralRevenue(veScaKey, coinName);
|
|
5590
5589
|
objToTransfer.push(rewardCoin);
|
|
5591
5590
|
} else {
|
|
5592
|
-
const coins = await builder.suiKit.suiInteractor.selectCoins(
|
|
5593
|
-
sender,
|
|
5594
|
-
Infinity,
|
|
5595
|
-
builder.utils.parseCoinType(coinName)
|
|
5596
|
-
);
|
|
5597
5591
|
const rewardCoin = txBlock.claimReferralRevenue(veScaKey, coinName);
|
|
5598
|
-
|
|
5592
|
+
try {
|
|
5593
|
+
const coins = await builder.suiKit.suiInteractor.selectCoins(
|
|
5594
|
+
sender,
|
|
5595
|
+
Infinity,
|
|
5596
|
+
builder.utils.parseCoinType(coinName)
|
|
5597
|
+
);
|
|
5599
5598
|
txBlock.mergeCoins(rewardCoin, coins);
|
|
5599
|
+
} finally {
|
|
5600
|
+
objToTransfer.push(rewardCoin);
|
|
5600
5601
|
}
|
|
5601
|
-
objToTransfer.push(rewardCoin);
|
|
5602
5602
|
}
|
|
5603
5603
|
}
|
|
5604
5604
|
if (objToTransfer.length > 0) {
|