@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.js +11 -7
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +11 -7
- package/dist/index.mjs.map +1 -1
- package/dist/models/scallopQuery.d.ts +4 -3
- package/dist/queries/borrowIncentiveQuery.d.ts +2 -1
- package/dist/queries/portfolioQuery.d.ts +3 -2
- package/package.json +1 -1
- package/src/models/scallopQuery.ts +4 -3
- package/src/queries/borrowIncentiveQuery.ts +2 -1
- package/src/queries/portfolioQuery.ts +15 -10
package/dist/index.js
CHANGED
|
@@ -4218,7 +4218,7 @@ var getLending = async (query, poolCoinName, ownerAddress, indexer = false, mark
|
|
|
4218
4218
|
return lending;
|
|
4219
4219
|
};
|
|
4220
4220
|
var getObligationAccounts = async (query, ownerAddress, indexer = false) => {
|
|
4221
|
-
const market = await query.
|
|
4221
|
+
const market = await query.getMarketPools(void 0, { indexer });
|
|
4222
4222
|
const coinPrices = await query.getAllCoinPrices({
|
|
4223
4223
|
marketPools: market.pools
|
|
4224
4224
|
});
|
|
@@ -4226,12 +4226,16 @@ var getObligationAccounts = async (query, ownerAddress, indexer = false) => {
|
|
|
4226
4226
|
query.getCoinAmounts(void 0, ownerAddress),
|
|
4227
4227
|
query.getObligations(ownerAddress)
|
|
4228
4228
|
]);
|
|
4229
|
+
const obligationObjects = await queryMultipleObjects(
|
|
4230
|
+
query.cache,
|
|
4231
|
+
obligations.map((obligation) => obligation.id)
|
|
4232
|
+
);
|
|
4229
4233
|
const obligationAccounts = {};
|
|
4230
4234
|
await Promise.allSettled(
|
|
4231
|
-
obligations.map(async (obligation) => {
|
|
4235
|
+
obligations.map(async (obligation, idx) => {
|
|
4232
4236
|
obligationAccounts[obligation.keyId] = await getObligationAccount(
|
|
4233
4237
|
query,
|
|
4234
|
-
obligation.id,
|
|
4238
|
+
obligationObjects[idx] ?? obligation.id,
|
|
4235
4239
|
ownerAddress,
|
|
4236
4240
|
indexer,
|
|
4237
4241
|
market,
|
|
@@ -4242,7 +4246,7 @@ var getObligationAccounts = async (query, ownerAddress, indexer = false) => {
|
|
|
4242
4246
|
);
|
|
4243
4247
|
return obligationAccounts;
|
|
4244
4248
|
};
|
|
4245
|
-
var getObligationAccount = async (query,
|
|
4249
|
+
var getObligationAccount = async (query, obligation, ownerAddress, indexer = false, market, coinPrices, coinAmounts) => {
|
|
4246
4250
|
const coinNames = Array.from(
|
|
4247
4251
|
/* @__PURE__ */ new Set([...SUPPORT_POOLS, ...SUPPORT_COLLATERALS])
|
|
4248
4252
|
);
|
|
@@ -4253,13 +4257,13 @@ var getObligationAccount = async (query, obligationId, ownerAddress, indexer = f
|
|
|
4253
4257
|
coinPrices = coinPrices ?? await query.getAllCoinPrices({ marketPools: market.pools });
|
|
4254
4258
|
coinAmounts = coinAmounts ?? await query.getCoinAmounts(coinNames, ownerAddress);
|
|
4255
4259
|
const [obligationQuery, borrowIncentivePools, borrowIncentiveAccounts] = await Promise.all([
|
|
4256
|
-
query.queryObligation(
|
|
4260
|
+
query.queryObligation(obligation),
|
|
4257
4261
|
query.getBorrowIncentivePools(void 0, {
|
|
4258
4262
|
coinPrices,
|
|
4259
4263
|
indexer,
|
|
4260
4264
|
marketPools: market.pools
|
|
4261
4265
|
}),
|
|
4262
|
-
query.getBorrowIncentiveAccounts(
|
|
4266
|
+
query.getBorrowIncentiveAccounts(obligation)
|
|
4263
4267
|
]);
|
|
4264
4268
|
const collaterals = {};
|
|
4265
4269
|
const debts = {};
|
|
@@ -4457,7 +4461,7 @@ var getObligationAccount = async (query, obligationId, ownerAddress, indexer = f
|
|
|
4457
4461
|
const requiredCollateralValue = totalBorrowedValueWithWeight.isGreaterThan(0) ? totalRequiredCollateralValue : (0, import_bignumber5.default)(0);
|
|
4458
4462
|
const unhealthyCollateralValue = totalBorrowedValueWithWeight.minus(requiredCollateralValue).isGreaterThan(0) ? totalBorrowedValueWithWeight.minus(requiredCollateralValue) : (0, import_bignumber5.default)(0);
|
|
4459
4463
|
const obligationAccount = {
|
|
4460
|
-
obligationId,
|
|
4464
|
+
obligationId: typeof obligation === "string" ? obligation : obligation.objectId,
|
|
4461
4465
|
// Deposited collateral value (collateral balance)
|
|
4462
4466
|
totalDepositedValue: totalDepositedValue.toNumber(),
|
|
4463
4467
|
// Borrowed debt value (liabilities balance)
|