@scallop-io/sui-scallop-sdk 2.0.2 → 2.0.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.d.mts +11 -2
- package/dist/index.d.ts +11 -2
- package/dist/index.js +8 -8
- package/dist/index.mjs +2 -2
- package/package.json +1 -1
- package/src/models/scallopConstants.ts +3 -1
- package/src/models/suiKit.ts +19 -4
- package/src/queries/portfolioQuery.ts +15 -1
- package/src/types/model.ts +2 -2
package/package.json
CHANGED
|
@@ -326,7 +326,9 @@ export class ScallopConstants {
|
|
|
326
326
|
const resp = await this.queryClient.fetchQuery({
|
|
327
327
|
queryKey,
|
|
328
328
|
queryFn: async () => {
|
|
329
|
-
return await this._requestClient.get(url
|
|
329
|
+
return await this._requestClient.get(url, {
|
|
330
|
+
timeout: 4000,
|
|
331
|
+
});
|
|
330
332
|
},
|
|
331
333
|
});
|
|
332
334
|
|
package/src/models/suiKit.ts
CHANGED
|
@@ -1,11 +1,26 @@
|
|
|
1
1
|
import { SuiKit, SuiKitParams } from '@scallop-io/sui-kit';
|
|
2
2
|
import { RPC_PROVIDERS } from 'src/constants/rpc';
|
|
3
3
|
|
|
4
|
-
export const newSuiKit = (params: SuiKitParams) => {
|
|
4
|
+
export const newSuiKit = (params: Partial<SuiKitParams>) => {
|
|
5
|
+
let initParams;
|
|
6
|
+
if (
|
|
7
|
+
'suiClients' in params &&
|
|
8
|
+
params.suiClients &&
|
|
9
|
+
params.suiClients?.length > 0
|
|
10
|
+
) {
|
|
11
|
+
initParams = {
|
|
12
|
+
suiClients: params.suiClients,
|
|
13
|
+
};
|
|
14
|
+
} else {
|
|
15
|
+
initParams = {
|
|
16
|
+
fullnodeUrls:
|
|
17
|
+
'fullnodeUrls' in params
|
|
18
|
+
? (params?.fullnodeUrls ?? RPC_PROVIDERS)
|
|
19
|
+
: RPC_PROVIDERS,
|
|
20
|
+
};
|
|
21
|
+
}
|
|
5
22
|
return new SuiKit({
|
|
6
23
|
...params,
|
|
7
|
-
|
|
8
|
-
new Set([...(params.fullnodeUrls ?? []), ...RPC_PROVIDERS])
|
|
9
|
-
),
|
|
24
|
+
...initParams,
|
|
10
25
|
});
|
|
11
26
|
};
|
|
@@ -896,7 +896,7 @@ export const getUserPortfolio = async (
|
|
|
896
896
|
const parsedObligationAccounts = Object.values(obligationAccounts)
|
|
897
897
|
.filter(
|
|
898
898
|
(t): t is NonNullable<typeof t> =>
|
|
899
|
-
!!t && t.totalBorrowedValueWithWeight > 0
|
|
899
|
+
!!t && (t.totalBorrowedValueWithWeight > 0 || t.totalDepositedValue > 0)
|
|
900
900
|
)
|
|
901
901
|
.map((obligationAccount) => {
|
|
902
902
|
return {
|
|
@@ -908,6 +908,20 @@ export const getUserPortfolio = async (
|
|
|
908
908
|
obligationAccount.totalAvailableCollateralValue,
|
|
909
909
|
totalUnhealthyCollateralInUsd:
|
|
910
910
|
obligationAccount.totalUnhealthyCollateralValue,
|
|
911
|
+
collaterals: Object.values(obligationAccount.collaterals)
|
|
912
|
+
.filter(
|
|
913
|
+
(collateral): collateral is NonNullable<typeof collateral> =>
|
|
914
|
+
!!collateral && collateral.depositedCoin > 0
|
|
915
|
+
)
|
|
916
|
+
.map((collateral) => ({
|
|
917
|
+
coinName: collateral.coinName,
|
|
918
|
+
symbol: collateral.symbol,
|
|
919
|
+
coinDecimals: collateral.coinDecimal,
|
|
920
|
+
coinType: collateral.coinType,
|
|
921
|
+
coinPrice: collateral.coinPrice,
|
|
922
|
+
depositedCoin: collateral.depositedCoin,
|
|
923
|
+
depositedValueInUsd: collateral.depositedValue,
|
|
924
|
+
})),
|
|
911
925
|
borrowedPools: Object.values(obligationAccount.debts)
|
|
912
926
|
.filter(
|
|
913
927
|
(debt): debt is NonNullable<typeof debt> =>
|
package/src/types/model.ts
CHANGED
|
@@ -74,7 +74,7 @@ export type ScallopCacheParams = {
|
|
|
74
74
|
walletAddress?: string;
|
|
75
75
|
cacheOptions?: QueryClientConfig;
|
|
76
76
|
config?: ScallopCacheConfig;
|
|
77
|
-
} & SuiKitParams
|
|
77
|
+
} & Partial<SuiKitParams>;
|
|
78
78
|
|
|
79
79
|
export type ScallopIndexerParams = ScallopCacheParams & {
|
|
80
80
|
indexerApiUrl?: string;
|
|
@@ -109,7 +109,7 @@ export type ScallopBuilderParams = ScallopQueryParams & {
|
|
|
109
109
|
};
|
|
110
110
|
|
|
111
111
|
export type ScallopClientParams = ScallopBuilderParams;
|
|
112
|
-
export type ScallopParams = SuiKitParams &
|
|
112
|
+
export type ScallopParams = Partial<SuiKitParams> &
|
|
113
113
|
ScallopAddressParams &
|
|
114
114
|
ScallopConstantsParams & {
|
|
115
115
|
walletAddress?: string;
|