@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 CHANGED
@@ -16,7 +16,7 @@
16
16
 
17
17
  ## Description
18
18
 
19
- This SDK is used to interact with [sui-lending-protocal](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:
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 client = query.suiKit.client();
2663
- const incentivePoolsResponse = await client.getObject({
2664
- id: incentivePoolsId,
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 client.getDynamicFieldObject({
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 client = query.suiKit.client();
2694
- const incentiveAccountsObject = await client.getObject({
2695
- id: incentiveAccountsId,
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 client.getDynamicFieldObject({
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(
@@ -5651,16 +5650,17 @@ var generateReferralQuickMethod = ({
5651
5650
  const rewardCoin = txBlock.claimReferralRevenue(veScaKey, coinName);
5652
5651
  objToTransfer.push(rewardCoin);
5653
5652
  } else {
5654
- const coins = await builder.suiKit.suiInteractor.selectCoins(
5655
- sender,
5656
- Infinity,
5657
- builder.utils.parseCoinType(coinName)
5658
- );
5659
5653
  const rewardCoin = txBlock.claimReferralRevenue(veScaKey, coinName);
5660
- if (coins.length > 0) {
5654
+ try {
5655
+ const coins = await builder.suiKit.suiInteractor.selectCoins(
5656
+ sender,
5657
+ Infinity,
5658
+ builder.utils.parseCoinType(coinName)
5659
+ );
5661
5660
  txBlock.mergeCoins(rewardCoin, coins);
5661
+ } finally {
5662
+ objToTransfer.push(rewardCoin);
5662
5663
  }
5663
- objToTransfer.push(rewardCoin);
5664
5664
  }
5665
5665
  }
5666
5666
  if (objToTransfer.length > 0) {