@scallop-io/sui-scallop-sdk 0.46.32 → 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/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 client = query.suiKit.client();
2590
- const incentivePoolsResponse = await client.getObject({
2591
- id: incentivePoolsId,
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 client.getDynamicFieldObject({
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 client = query.suiKit.client();
2621
- const incentiveAccountsObject = await client.getObject({
2622
- id: incentiveAccountsId,
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 client.getDynamicFieldObject({
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(
@@ -3034,9 +3033,10 @@ var getObligationAccount = async (query, obligationId, ownerAddress, indexer = f
3034
3033
  let availableClaimCoin = BigNumber4(0);
3035
3034
  const accountBorrowedAmount = BigNumber4(accountPoint.weightedAmount);
3036
3035
  const baseIndexRate = 1e9;
3037
- const increasedPointRate = poolPoint.currentPointIndex ? BigNumber4(
3038
- poolPoint.currentPointIndex - accountPoint.index
3039
- ).dividedBy(baseIndexRate) : 1;
3036
+ const increasedPointRate = poolPoint.currentPointIndex ? Math.max(
3037
+ BigNumber4(poolPoint.currentPointIndex - accountPoint.index).dividedBy(baseIndexRate).toNumber(),
3038
+ 0
3039
+ ) : 1;
3040
3040
  availableClaimAmount = availableClaimAmount.plus(
3041
3041
  accountBorrowedAmount.multipliedBy(increasedPointRate).plus(accountPoint.points)
3042
3042
  );
@@ -3049,7 +3049,7 @@ var getObligationAccount = async (query, obligationId, ownerAddress, indexer = f
3049
3049
  ).isFinite() ? BigNumber4(accountPoint.weightedAmount).div(
3050
3050
  BigNumber4(borrowIncentiveAccount.debtAmount).multipliedBy(poolPoint.baseWeight).dividedBy(weightScale)
3051
3051
  ).toNumber() : 1;
3052
- if (availableClaimAmount.isGreaterThan(0)) {
3052
+ if (availableClaimAmount.isGreaterThanOrEqualTo(0)) {
3053
3053
  rewards.push({
3054
3054
  coinName: poolPoint.coinName,
3055
3055
  coinType: poolPoint.coinType,