@scallop-io/sui-scallop-sdk 1.4.7 → 1.4.8
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 +51 -32
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +51 -32
- package/dist/index.mjs.map +1 -1
- package/dist/models/scallopQuery.d.ts +44 -36
- package/dist/queries/portfolioQuery.d.ts +44 -38
- package/package.json +1 -1
- package/src/models/scallopQuery.ts +8 -1
- package/src/queries/poolAddressesQuery.ts +1 -1
- package/src/queries/portfolioQuery.ts +54 -29
package/dist/index.js
CHANGED
|
@@ -4133,14 +4133,14 @@ var getLoyaltyProgramInformations = async (query, veScaKey) => {
|
|
|
4133
4133
|
// src/queries/portfolioQuery.ts
|
|
4134
4134
|
var import_bignumber5 = __toESM(require("bignumber.js"));
|
|
4135
4135
|
var import_sui_kit3 = require("@scallop-io/sui-kit");
|
|
4136
|
-
var getLendings = async (query, poolCoinNames = [...SUPPORT_POOLS], ownerAddress, marketPools, indexer = false) => {
|
|
4136
|
+
var getLendings = async (query, poolCoinNames = [...SUPPORT_POOLS], ownerAddress, marketPools, coinPrices, indexer = false) => {
|
|
4137
4137
|
const marketCoinNames = poolCoinNames.map(
|
|
4138
4138
|
(poolCoinName) => query.utils.parseMarketCoinName(poolCoinName)
|
|
4139
4139
|
);
|
|
4140
4140
|
const stakeMarketCoinNames = marketCoinNames.filter(
|
|
4141
4141
|
(marketCoinName) => SUPPORT_SPOOLS.includes(marketCoinName)
|
|
4142
4142
|
);
|
|
4143
|
-
|
|
4143
|
+
coinPrices = coinPrices ?? await query.utils.getCoinPrices();
|
|
4144
4144
|
marketPools = marketPools ?? (await query.getMarketPools(poolCoinNames, {
|
|
4145
4145
|
indexer,
|
|
4146
4146
|
coinPrices
|
|
@@ -4311,9 +4311,9 @@ var getLending = async (query, poolCoinName, ownerAddress, indexer = false, mark
|
|
|
4311
4311
|
};
|
|
4312
4312
|
return lending;
|
|
4313
4313
|
};
|
|
4314
|
-
var getObligationAccounts = async (query, ownerAddress, market, indexer = false) => {
|
|
4314
|
+
var getObligationAccounts = async (query, ownerAddress, market, coinPrices, indexer = false) => {
|
|
4315
4315
|
market = market ?? await query.getMarketPools(void 0, { indexer });
|
|
4316
|
-
|
|
4316
|
+
coinPrices = coinPrices ?? await query.getAllCoinPrices({
|
|
4317
4317
|
marketPools: market.pools
|
|
4318
4318
|
});
|
|
4319
4319
|
const [coinAmounts, obligations] = await Promise.all([
|
|
@@ -4673,19 +4673,24 @@ var getTotalValueLocked = async (query, indexer = false) => {
|
|
|
4673
4673
|
return tvl;
|
|
4674
4674
|
};
|
|
4675
4675
|
var getUserPortfolio = async (query, walletAddress, indexer = false) => {
|
|
4676
|
-
const
|
|
4677
|
-
const
|
|
4676
|
+
const coinPrices = await query.utils.getCoinPrices();
|
|
4677
|
+
const market = await query.getMarketPools(void 0, { indexer, coinPrices });
|
|
4678
|
+
const [lendings, obligationAccounts, borrowIncentivePools, veScas] = await Promise.all([
|
|
4678
4679
|
query.getLendings(void 0, walletAddress, {
|
|
4679
4680
|
indexer,
|
|
4680
|
-
marketPools: market.pools
|
|
4681
|
+
marketPools: market.pools,
|
|
4682
|
+
coinPrices
|
|
4681
4683
|
}),
|
|
4682
4684
|
query.getObligationAccounts(walletAddress, {
|
|
4683
4685
|
indexer,
|
|
4684
|
-
market
|
|
4686
|
+
market,
|
|
4687
|
+
coinPrices
|
|
4685
4688
|
}),
|
|
4686
4689
|
query.getBorrowIncentivePools(void 0, {
|
|
4687
|
-
marketPools: market.pools
|
|
4688
|
-
|
|
4690
|
+
marketPools: market.pools,
|
|
4691
|
+
coinPrices
|
|
4692
|
+
}),
|
|
4693
|
+
query.getVeScas({ walletAddress, excludeEmpty: true })
|
|
4689
4694
|
]);
|
|
4690
4695
|
const parsedLendings = Object.values(lendings).filter((t) => t.availableWithdrawCoin > 0).map((lending) => ({
|
|
4691
4696
|
suppliedCoin: lending.availableWithdrawCoin,
|
|
@@ -4772,28 +4777,39 @@ var getUserPortfolio = async (query, walletAddress, indexer = false) => {
|
|
|
4772
4777
|
},
|
|
4773
4778
|
{}
|
|
4774
4779
|
);
|
|
4780
|
+
const parsedVeScas = veScas.map(
|
|
4781
|
+
({ keyId, lockedScaCoin, currentVeScaBalance, unlockAt }) => ({
|
|
4782
|
+
veScaKey: keyId,
|
|
4783
|
+
coinPrice: coinPrices.sca ?? 0,
|
|
4784
|
+
lockedScaInCoin: lockedScaCoin,
|
|
4785
|
+
lockedScaInUsd: lockedScaCoin * (coinPrices.sca ?? 0),
|
|
4786
|
+
currentVeScaBalance,
|
|
4787
|
+
remainingLockPeriodInDays: unlockAt - Date.now() > 0 ? (unlockAt - Date.now()) / 864e5 : 0,
|
|
4788
|
+
unlockAt
|
|
4789
|
+
})
|
|
4790
|
+
);
|
|
4775
4791
|
return {
|
|
4776
|
-
|
|
4777
|
-
|
|
4778
|
-
|
|
4792
|
+
totalSupplyValue: parsedLendings.reduce((acc, curr) => {
|
|
4793
|
+
acc += curr.suppliedValue;
|
|
4794
|
+
return acc;
|
|
4795
|
+
}, 0),
|
|
4796
|
+
...parsedObligationAccounts.reduce(
|
|
4797
|
+
(acc, curr) => {
|
|
4798
|
+
acc.totalDebtValue += curr.totalDebtsInUsd;
|
|
4799
|
+
acc.totalCollateralValue += curr.totalCollateralInUsd;
|
|
4779
4800
|
return acc;
|
|
4780
|
-
},
|
|
4781
|
-
|
|
4782
|
-
|
|
4783
|
-
|
|
4784
|
-
|
|
4785
|
-
|
|
4786
|
-
|
|
4787
|
-
|
|
4788
|
-
|
|
4789
|
-
|
|
4790
|
-
|
|
4791
|
-
|
|
4792
|
-
totalCollateralValue: 0
|
|
4793
|
-
}
|
|
4794
|
-
),
|
|
4795
|
-
obligations: parsedObligationAccounts
|
|
4796
|
-
},
|
|
4801
|
+
},
|
|
4802
|
+
{
|
|
4803
|
+
totalDebtValue: 0,
|
|
4804
|
+
totalCollateralValue: 0
|
|
4805
|
+
}
|
|
4806
|
+
),
|
|
4807
|
+
totalLockedScaValue: parsedVeScas.reduce((acc, curr) => {
|
|
4808
|
+
acc += curr.lockedScaInUsd;
|
|
4809
|
+
return acc;
|
|
4810
|
+
}, 0),
|
|
4811
|
+
lendings: parsedLendings,
|
|
4812
|
+
borrowings: parsedObligationAccounts,
|
|
4797
4813
|
pendingRewards: {
|
|
4798
4814
|
lendings: Object.entries(pendingLendingRewards).reduce(
|
|
4799
4815
|
(acc, [key, value]) => {
|
|
@@ -4817,7 +4833,8 @@ var getUserPortfolio = async (query, walletAddress, indexer = false) => {
|
|
|
4817
4833
|
},
|
|
4818
4834
|
[]
|
|
4819
4835
|
)
|
|
4820
|
-
}
|
|
4836
|
+
},
|
|
4837
|
+
veScas: parsedVeScas
|
|
4821
4838
|
};
|
|
4822
4839
|
};
|
|
4823
4840
|
|
|
@@ -5658,7 +5675,7 @@ var getAllAddresses = async (query) => {
|
|
|
5658
5675
|
sCoinTreasury,
|
|
5659
5676
|
sCoinType,
|
|
5660
5677
|
coinDecimalId,
|
|
5661
|
-
coinType
|
|
5678
|
+
coinType: `0x${coinType}`
|
|
5662
5679
|
};
|
|
5663
5680
|
await new Promise((resolve) => setTimeout(resolve, 200));
|
|
5664
5681
|
})
|
|
@@ -8339,6 +8356,7 @@ var ScallopQuery = class {
|
|
|
8339
8356
|
poolCoinNames,
|
|
8340
8357
|
ownerAddress,
|
|
8341
8358
|
args?.marketPools,
|
|
8359
|
+
args?.coinPrices,
|
|
8342
8360
|
args?.indexer
|
|
8343
8361
|
);
|
|
8344
8362
|
}
|
|
@@ -8368,6 +8386,7 @@ var ScallopQuery = class {
|
|
|
8368
8386
|
this,
|
|
8369
8387
|
ownerAddress,
|
|
8370
8388
|
args?.market,
|
|
8389
|
+
args?.coinPrices,
|
|
8371
8390
|
args?.indexer
|
|
8372
8391
|
);
|
|
8373
8392
|
}
|