@scallop-io/sui-scallop-sdk 1.4.3-rc.1 → 1.4.4

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
@@ -4128,7 +4128,7 @@ var getLending = async (query, poolCoinName, ownerAddress, indexer = false, mark
4128
4128
  return lending;
4129
4129
  };
4130
4130
  var getObligationAccounts = async (query, ownerAddress, indexer = false) => {
4131
- const market = await query.queryMarket({ indexer });
4131
+ const market = await query.getMarketPools(void 0, { indexer });
4132
4132
  const coinPrices = await query.getAllCoinPrices({
4133
4133
  marketPools: market.pools
4134
4134
  });
@@ -4136,12 +4136,16 @@ var getObligationAccounts = async (query, ownerAddress, indexer = false) => {
4136
4136
  query.getCoinAmounts(void 0, ownerAddress),
4137
4137
  query.getObligations(ownerAddress)
4138
4138
  ]);
4139
+ const obligationObjects = await queryMultipleObjects(
4140
+ query.cache,
4141
+ obligations.map((obligation) => obligation.id)
4142
+ );
4139
4143
  const obligationAccounts = {};
4140
4144
  await Promise.allSettled(
4141
- obligations.map(async (obligation) => {
4145
+ obligations.map(async (obligation, idx) => {
4142
4146
  obligationAccounts[obligation.keyId] = await getObligationAccount(
4143
4147
  query,
4144
- obligation.id,
4148
+ obligationObjects[idx] ?? obligation.id,
4145
4149
  ownerAddress,
4146
4150
  indexer,
4147
4151
  market,
@@ -4152,7 +4156,7 @@ var getObligationAccounts = async (query, ownerAddress, indexer = false) => {
4152
4156
  );
4153
4157
  return obligationAccounts;
4154
4158
  };
4155
- var getObligationAccount = async (query, obligationId, ownerAddress, indexer = false, market, coinPrices, coinAmounts) => {
4159
+ var getObligationAccount = async (query, obligation, ownerAddress, indexer = false, market, coinPrices, coinAmounts) => {
4156
4160
  const coinNames = Array.from(
4157
4161
  /* @__PURE__ */ new Set([...SUPPORT_POOLS, ...SUPPORT_COLLATERALS])
4158
4162
  );
@@ -4163,13 +4167,13 @@ var getObligationAccount = async (query, obligationId, ownerAddress, indexer = f
4163
4167
  coinPrices = coinPrices ?? await query.getAllCoinPrices({ marketPools: market.pools });
4164
4168
  coinAmounts = coinAmounts ?? await query.getCoinAmounts(coinNames, ownerAddress);
4165
4169
  const [obligationQuery, borrowIncentivePools, borrowIncentiveAccounts] = await Promise.all([
4166
- query.queryObligation(obligationId),
4170
+ query.queryObligation(obligation),
4167
4171
  query.getBorrowIncentivePools(void 0, {
4168
4172
  coinPrices,
4169
4173
  indexer,
4170
4174
  marketPools: market.pools
4171
4175
  }),
4172
- query.getBorrowIncentiveAccounts(obligationId)
4176
+ query.getBorrowIncentiveAccounts(obligation)
4173
4177
  ]);
4174
4178
  const collaterals = {};
4175
4179
  const debts = {};
@@ -4367,7 +4371,7 @@ var getObligationAccount = async (query, obligationId, ownerAddress, indexer = f
4367
4371
  const requiredCollateralValue = totalBorrowedValueWithWeight.isGreaterThan(0) ? totalRequiredCollateralValue : BigNumber5(0);
4368
4372
  const unhealthyCollateralValue = totalBorrowedValueWithWeight.minus(requiredCollateralValue).isGreaterThan(0) ? totalBorrowedValueWithWeight.minus(requiredCollateralValue) : BigNumber5(0);
4369
4373
  const obligationAccount = {
4370
- obligationId,
4374
+ obligationId: typeof obligation === "string" ? obligation : obligation.objectId,
4371
4375
  // Deposited collateral value (collateral balance)
4372
4376
  totalDepositedValue: totalDepositedValue.toNumber(),
4373
4377
  // Borrowed debt value (liabilities balance)