@scallop-io/sui-scallop-sdk 2.1.1-merge-split-ve-sca-alpha.1 → 2.1.2-merge-split-ve-sca-alpha.1
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 +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +5 -5
- package/dist/index.mjs +2 -2
- package/package.json +1 -1
- package/src/models/scallopConstants.ts +18 -3
- package/src/queries/portfolioQuery.ts +0 -1
package/package.json
CHANGED
|
@@ -28,7 +28,7 @@ export type ScallopConstantsParams = {
|
|
|
28
28
|
poolAddressesApiUrl?: string;
|
|
29
29
|
whitelistApiUrl?: string;
|
|
30
30
|
forcePoolAddressInterface?: Record<string, PoolAddress>;
|
|
31
|
-
forceWhitelistInterface?: Whitelist
|
|
31
|
+
forceWhitelistInterface?: Whitelist | Record<string, any>;
|
|
32
32
|
} & ScallopAddressParams;
|
|
33
33
|
|
|
34
34
|
const DEFAULT_WHITELIST = {
|
|
@@ -48,6 +48,18 @@ const DEFAULT_WHITELIST = {
|
|
|
48
48
|
emerging: new Set(),
|
|
49
49
|
} as Whitelist;
|
|
50
50
|
|
|
51
|
+
const parseWhitelistParams = (params: Record<string, any> | Whitelist) => {
|
|
52
|
+
return Object.entries(params)
|
|
53
|
+
.filter(
|
|
54
|
+
([_, value]) => !!value && (Array.isArray(value) || value instanceof Set)
|
|
55
|
+
)
|
|
56
|
+
.reduce((acc, [key, value]) => {
|
|
57
|
+
acc[key as keyof typeof DEFAULT_WHITELIST] =
|
|
58
|
+
value instanceof Set ? value : new Set(value);
|
|
59
|
+
return acc;
|
|
60
|
+
}, {} as Whitelist);
|
|
61
|
+
};
|
|
62
|
+
|
|
51
63
|
class ScallopConstants extends ScallopAddress {
|
|
52
64
|
private _poolAddresses: Record<string, PoolAddress | undefined> = {};
|
|
53
65
|
private _whitelist: Whitelist = DEFAULT_WHITELIST;
|
|
@@ -144,7 +156,7 @@ class ScallopConstants extends ScallopAddress {
|
|
|
144
156
|
networkType?: NetworkType;
|
|
145
157
|
} = {}) {
|
|
146
158
|
const addresses = this.getAddresses(networkType);
|
|
147
|
-
return
|
|
159
|
+
return !!addresses && !isEmptyObject(addresses);
|
|
148
160
|
}
|
|
149
161
|
|
|
150
162
|
parseToOldMarketCoin(coinType: string) {
|
|
@@ -174,10 +186,13 @@ class ScallopConstants extends ScallopAddress {
|
|
|
174
186
|
}
|
|
175
187
|
|
|
176
188
|
if (constantsParams.forceWhitelistInterface) {
|
|
177
|
-
this._whitelist =
|
|
189
|
+
this._whitelist = parseWhitelistParams(
|
|
190
|
+
constantsParams.forceWhitelistInterface
|
|
191
|
+
);
|
|
178
192
|
}
|
|
179
193
|
|
|
180
194
|
if (this.isInitialized && !force) {
|
|
195
|
+
this.initConstants();
|
|
181
196
|
return;
|
|
182
197
|
}
|
|
183
198
|
|
|
@@ -821,7 +821,6 @@ export const getTotalValueLocked = async (
|
|
|
821
821
|
);
|
|
822
822
|
}
|
|
823
823
|
|
|
824
|
-
// console.dir(market.collaterals, { depth: null });
|
|
825
824
|
for (const collateral of Object.values(market.collaterals)) {
|
|
826
825
|
if (!collateral) continue;
|
|
827
826
|
supplyCollateralValue = supplyCollateralValue.plus(
|