@suilend/sdk 1.1.52 → 1.1.54
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/lib/initialize.d.ts +5 -7
- package/lib/initialize.js +12 -4
- package/package.json +1 -1
package/lib/initialize.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { SuiClient } from "@mysten/sui/client";
|
|
1
|
+
import { CoinMetadata, SuiClient } from "@mysten/sui/client";
|
|
2
2
|
import BigNumber from "bignumber.js";
|
|
3
3
|
import { Reserve } from "../_generated/suilend/reserve/structs";
|
|
4
4
|
import { SuilendClient } from "../client";
|
|
@@ -7,7 +7,7 @@ export declare const RESERVES_CUSTOM_ORDER: string[];
|
|
|
7
7
|
export declare const NORMALIZED_MAYA_COINTYPE: string;
|
|
8
8
|
export declare const NORMALIZED_mPOINTS_COINTYPE: string;
|
|
9
9
|
export declare const NORMALIZED_TREATS_COINTYPE: string;
|
|
10
|
-
export declare const initializeSuilend: (suiClient: SuiClient, suilendClient: SuilendClient) => Promise<{
|
|
10
|
+
export declare const initializeSuilend: (suiClient: SuiClient, suilendClient: SuilendClient, existingCoinMetadataMap?: Record<string, CoinMetadata>) => Promise<{
|
|
11
11
|
lendingMarket: {
|
|
12
12
|
id: string;
|
|
13
13
|
type: string;
|
|
@@ -144,9 +144,7 @@ export declare const initializeSuilend: (suiClient: SuiClient, suilendClient: Su
|
|
|
144
144
|
totalSupplyUsd: BigNumber;
|
|
145
145
|
totalBorrowUsd: BigNumber;
|
|
146
146
|
};
|
|
147
|
-
coinMetadataMap:
|
|
148
|
-
[x: string]: import("@mysten/sui/client").CoinMetadata;
|
|
149
|
-
};
|
|
147
|
+
coinMetadataMap: Record<string, CoinMetadata>;
|
|
150
148
|
refreshedRawReserves: Reserve<string>[];
|
|
151
149
|
reserveMap: Record<string, {
|
|
152
150
|
config: {
|
|
@@ -257,10 +255,10 @@ export declare const initializeSuilend: (suiClient: SuiClient, suilendClient: Su
|
|
|
257
255
|
totalDeposits: BigNumber;
|
|
258
256
|
}>;
|
|
259
257
|
reserveCoinTypes: string[];
|
|
260
|
-
reserveCoinMetadataMap: Record<string,
|
|
258
|
+
reserveCoinMetadataMap: Record<string, CoinMetadata>;
|
|
261
259
|
rewardCoinTypes: string[];
|
|
262
260
|
activeRewardCoinTypes: string[];
|
|
263
|
-
rewardCoinMetadataMap: Record<string,
|
|
261
|
+
rewardCoinMetadataMap: Record<string, CoinMetadata>;
|
|
264
262
|
}>;
|
|
265
263
|
export declare const initializeSuilendRewards: (reserveMap: Record<string, ParsedReserve>, activeRewardCoinTypes: string[]) => Promise<{
|
|
266
264
|
rewardPriceMap: Record<string, BigNumber | undefined>;
|
package/lib/initialize.js
CHANGED
|
@@ -95,7 +95,7 @@ const TREATS_COINTYPE = "0x0dadb7fa2771c2952f96161fc1f0c105d1f22d53926b9ff2498a8
|
|
|
95
95
|
exports.NORMALIZED_MAYA_COINTYPE = (0, utils_1.normalizeStructTag)(MAYA_COINTYPE);
|
|
96
96
|
exports.NORMALIZED_mPOINTS_COINTYPE = (0, utils_1.normalizeStructTag)(mPOINTS_COINTYPE);
|
|
97
97
|
exports.NORMALIZED_TREATS_COINTYPE = (0, utils_1.normalizeStructTag)(TREATS_COINTYPE);
|
|
98
|
-
const initializeSuilend = (suiClient, suilendClient) => __awaiter(void 0, void 0, void 0, function* () {
|
|
98
|
+
const initializeSuilend = (suiClient, suilendClient, existingCoinMetadataMap) => __awaiter(void 0, void 0, void 0, function* () {
|
|
99
99
|
const nowMs = Date.now();
|
|
100
100
|
const nowS = Math.floor(nowMs / 1000);
|
|
101
101
|
const refreshedRawReserves = yield simulate.refreshReservePrice(suilendClient.lendingMarket.reserves.map((r) => simulate.compoundReserveInterest(r, nowS)), new pyth_sui_js_1.SuiPriceServiceConnection("https://hermes.pyth.network"));
|
|
@@ -119,10 +119,18 @@ const initializeSuilend = (suiClient, suilendClient) => __awaiter(void 0, void 0
|
|
|
119
119
|
const uniqueReserveCoinTypes = Array.from(new Set(reserveCoinTypes));
|
|
120
120
|
const uniqueRewardCoinTypes = Array.from(new Set(rewardCoinTypes));
|
|
121
121
|
const uniqueActiveRewardsCoinTypes = Array.from(new Set(activeRewardCoinTypes));
|
|
122
|
-
const [
|
|
123
|
-
(0, frontend_sui_1.getCoinMetadataMap)(
|
|
124
|
-
(0, frontend_sui_1.getCoinMetadataMap)(
|
|
122
|
+
const [_reserveCoinMetadataMap, _rewardCoinMetadataMap] = yield Promise.all([
|
|
123
|
+
(0, frontend_sui_1.getCoinMetadataMap)(uniqueReserveCoinTypes.filter((coinType) => !(existingCoinMetadataMap !== null && existingCoinMetadataMap !== void 0 ? existingCoinMetadataMap : {})[coinType])),
|
|
124
|
+
(0, frontend_sui_1.getCoinMetadataMap)(uniqueRewardCoinTypes.filter((coinType) => !(existingCoinMetadataMap !== null && existingCoinMetadataMap !== void 0 ? existingCoinMetadataMap : {})[coinType])),
|
|
125
125
|
]);
|
|
126
|
+
const reserveCoinMetadataMap = uniqueReserveCoinTypes.reduce((acc, coinType) => {
|
|
127
|
+
var _a;
|
|
128
|
+
return (Object.assign(Object.assign({}, acc), { [coinType]: (_a = existingCoinMetadataMap === null || existingCoinMetadataMap === void 0 ? void 0 : existingCoinMetadataMap[coinType]) !== null && _a !== void 0 ? _a : _reserveCoinMetadataMap[coinType] }));
|
|
129
|
+
}, {});
|
|
130
|
+
const rewardCoinMetadataMap = uniqueRewardCoinTypes.reduce((acc, coinType) => {
|
|
131
|
+
var _a;
|
|
132
|
+
return (Object.assign(Object.assign({}, acc), { [coinType]: (_a = existingCoinMetadataMap === null || existingCoinMetadataMap === void 0 ? void 0 : existingCoinMetadataMap[coinType]) !== null && _a !== void 0 ? _a : _rewardCoinMetadataMap[coinType] }));
|
|
133
|
+
}, {});
|
|
126
134
|
const coinMetadataMap = Object.assign(Object.assign({}, reserveCoinMetadataMap), rewardCoinMetadataMap);
|
|
127
135
|
const reservesWithTemporaryPythPriceFeeds = refreshedRawReserves.filter((r) => frontend_sui_1.TEMPORARY_PYTH_PRICE_FEED_COINTYPES.includes((0, utils_1.normalizeStructTag)(r.coinType.name)));
|
|
128
136
|
for (const reserve of reservesWithTemporaryPythPriceFeeds) {
|
package/package.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"name":"@suilend/sdk","version":"1.1.
|
|
1
|
+
{"name":"@suilend/sdk","version":"1.1.54","private":false,"description":"A TypeScript SDK for interacting with the Suilend program","author":"Suilend","license":"MIT","main":"./index.js","exports":{".":"./index.js","./client":"./client.js","./api/events":"./api/events.js","./api":"./api/index.js","./lib/constants":"./lib/constants.js","./lib":"./lib/index.js","./lib/initialize":"./lib/initialize.js","./lib/liquidityMining":"./lib/liquidityMining.js","./lib/transactions":"./lib/transactions.js","./lib/types":"./lib/types.js","./parsers/apiReserveAssetDataEvent":"./parsers/apiReserveAssetDataEvent.js","./parsers":"./parsers/index.js","./parsers/lendingMarket":"./parsers/lendingMarket.js","./parsers/obligation":"./parsers/obligation.js","./parsers/rateLimiter":"./parsers/rateLimiter.js","./parsers/reserve":"./parsers/reserve.js","./utils/events":"./utils/events.js","./utils":"./utils/index.js","./utils/obligation":"./utils/obligation.js","./utils/simulate":"./utils/simulate.js","./_generated/_framework/reified":"./_generated/_framework/reified.js","./_generated/_framework/util":"./_generated/_framework/util.js","./_generated/_framework/vector":"./_generated/_framework/vector.js","./_generated/suilend":"./_generated/suilend/index.js","./_generated/suilend/cell/structs":"./_generated/suilend/cell/structs.js","./_generated/suilend/decimal/structs":"./_generated/suilend/decimal/structs.js","./_generated/suilend/lending-market/functions":"./_generated/suilend/lending-market/functions.js","./_generated/suilend/lending-market/structs":"./_generated/suilend/lending-market/structs.js","./_generated/suilend/lending-market-registry/functions":"./_generated/suilend/lending-market-registry/functions.js","./_generated/suilend/liquidity-mining/structs":"./_generated/suilend/liquidity-mining/structs.js","./_generated/suilend/obligation/structs":"./_generated/suilend/obligation/structs.js","./_generated/suilend/rate-limiter/functions":"./_generated/suilend/rate-limiter/functions.js","./_generated/suilend/rate-limiter/structs":"./_generated/suilend/rate-limiter/structs.js","./_generated/suilend/reserve/structs":"./_generated/suilend/reserve/structs.js","./_generated/suilend/reserve-config/functions":"./_generated/suilend/reserve-config/functions.js","./_generated/suilend/reserve-config/structs":"./_generated/suilend/reserve-config/structs.js","./_generated/_dependencies/source/0x1":"./_generated/_dependencies/source/0x1/index.js","./_generated/_dependencies/source/0x2":"./_generated/_dependencies/source/0x2/index.js","./_generated/_dependencies/source/0x8d97f1cd6ac663735be08d1d2b6d02a159e711586461306ce60a2b7a6a565a9e":"./_generated/_dependencies/source/0x8d97f1cd6ac663735be08d1d2b6d02a159e711586461306ce60a2b7a6a565a9e/index.js","./_generated/_dependencies/source/0x1/ascii/structs":"./_generated/_dependencies/source/0x1/ascii/structs.js","./_generated/_dependencies/source/0x1/option/structs":"./_generated/_dependencies/source/0x1/option/structs.js","./_generated/_dependencies/source/0x1/type-name/structs":"./_generated/_dependencies/source/0x1/type-name/structs.js","./_generated/_dependencies/source/0x2/bag/structs":"./_generated/_dependencies/source/0x2/bag/structs.js","./_generated/_dependencies/source/0x2/balance/structs":"./_generated/_dependencies/source/0x2/balance/structs.js","./_generated/_dependencies/source/0x2/object/structs":"./_generated/_dependencies/source/0x2/object/structs.js","./_generated/_dependencies/source/0x2/object-table/structs":"./_generated/_dependencies/source/0x2/object-table/structs.js","./_generated/_dependencies/source/0x8d97f1cd6ac663735be08d1d2b6d02a159e711586461306ce60a2b7a6a565a9e/i64/structs":"./_generated/_dependencies/source/0x8d97f1cd6ac663735be08d1d2b6d02a159e711586461306ce60a2b7a6a565a9e/i64/structs.js","./_generated/_dependencies/source/0x8d97f1cd6ac663735be08d1d2b6d02a159e711586461306ce60a2b7a6a565a9e/price/structs":"./_generated/_dependencies/source/0x8d97f1cd6ac663735be08d1d2b6d02a159e711586461306ce60a2b7a6a565a9e/price/structs.js","./_generated/_dependencies/source/0x8d97f1cd6ac663735be08d1d2b6d02a159e711586461306ce60a2b7a6a565a9e/price-feed/structs":"./_generated/_dependencies/source/0x8d97f1cd6ac663735be08d1d2b6d02a159e711586461306ce60a2b7a6a565a9e/price-feed/structs.js","./_generated/_dependencies/source/0x8d97f1cd6ac663735be08d1d2b6d02a159e711586461306ce60a2b7a6a565a9e/price-identifier/structs":"./_generated/_dependencies/source/0x8d97f1cd6ac663735be08d1d2b6d02a159e711586461306ce60a2b7a6a565a9e/price-identifier/structs.js","./_generated/_dependencies/source/0x8d97f1cd6ac663735be08d1d2b6d02a159e711586461306ce60a2b7a6a565a9e/price-info/structs":"./_generated/_dependencies/source/0x8d97f1cd6ac663735be08d1d2b6d02a159e711586461306ce60a2b7a6a565a9e/price-info/structs.js"},"types":"./index.js","scripts":{"build":"rm -rf ./dist && bun tsc","eslint":"eslint --fix \"./src/**/*.ts\"","prettier":"prettier --write \"./src/**/*\"","lint":"bun eslint && bun prettier && bun tsc --noEmit","release":"bun run build && bun ts-node ./release.ts && cd ./dist && npm publish --access public"},"repository":{"type":"git","url":"git+https://github.com/solendprotocol/suilend-public.git"},"bugs":{"url":"https://github.com/solendprotocol/suilend-public/issues"},"dependencies":{"@pythnetwork/pyth-sui-js":"^2.1.0","bignumber.js":"^9.1.2","p-limit":"3.1.0","uuid":"^11.0.3"},"devDependencies":{"ts-node":"^10.9.2"},"peerDependencies":{"@mysten/bcs":"1.6.0","@mysten/sui":"1.28.2","@suilend/frontend-sui":"^0.2.60"}}
|