@suilend/sdk 12.7.0 → 13.0.0-next.g122801a
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/_generated/_dependencies/pyth-2/price-identifier/structs.d.ts +46 -0
- package/_generated/_dependencies/{source/0x8d97f1cd6ac663735be08d1d2b6d02a159e711586461306ce60a2b7a6a565a9e → pyth-2}/price-identifier/structs.js +45 -25
- package/_generated/_dependencies/std/ascii/structs.d.ts +100 -0
- package/_generated/_dependencies/{source/0x1 → std}/ascii/structs.js +153 -103
- package/_generated/_dependencies/{source/0x1 → std}/option/structs.d.ts +29 -21
- package/_generated/_dependencies/std/option/structs.js +155 -0
- package/_generated/_dependencies/std/type-name/structs.d.ts +65 -0
- package/_generated/_dependencies/{source/0x1 → std}/type-name/structs.js +49 -22
- package/_generated/_dependencies/sui/bag/structs.d.ts +75 -0
- package/_generated/_dependencies/sui/bag/structs.js +154 -0
- package/_generated/_dependencies/{source/0x2 → sui}/balance/structs.d.ts +80 -60
- package/_generated/_dependencies/sui/balance/structs.js +306 -0
- package/_generated/_dependencies/sui/object/structs.d.ts +104 -0
- package/_generated/_dependencies/{source/0x2 → sui}/object/structs.js +98 -46
- package/_generated/_dependencies/{source/0x2 → sui}/object-table/structs.d.ts +37 -30
- package/_generated/_dependencies/sui/object-table/structs.js +164 -0
- package/_generated/_envs/index.d.ts +3 -0
- package/_generated/_envs/index.js +18 -0
- package/_generated/_envs/mainnet.d.ts +2 -0
- package/_generated/_envs/mainnet.js +490 -0
- package/_generated/_framework/env.d.ts +137 -0
- package/_generated/_framework/env.js +261 -0
- package/_generated/_framework/reified.d.ts +68 -36
- package/_generated/_framework/reified.js +110 -98
- package/_generated/_framework/util.d.ts +4 -4
- package/_generated/_framework/util.js +82 -79
- package/_generated/_framework/vector.d.ts +11 -9
- package/_generated/_framework/vector.js +10 -10
- package/_generated/suilend/cell/structs.d.ts +24 -22
- package/_generated/suilend/cell/structs.js +68 -24
- package/_generated/suilend/decimal/structs.d.ts +28 -24
- package/_generated/suilend/decimal/structs.js +45 -24
- package/_generated/suilend/index.d.ts +5 -6
- package/_generated/suilend/index.js +10 -19
- package/_generated/suilend/lending-market/functions.d.ts +1123 -149
- package/_generated/suilend/lending-market/functions.js +1121 -207
- package/_generated/suilend/lending-market/structs.d.ts +985 -1290
- package/_generated/suilend/lending-market/structs.js +2482 -1282
- package/_generated/suilend/lending-market-registry/functions.d.ts +32 -3
- package/_generated/suilend/lending-market-registry/functions.js +30 -6
- package/_generated/suilend/liquidity-mining/structs.d.ts +200 -333
- package/_generated/suilend/liquidity-mining/structs.js +449 -319
- package/_generated/suilend/obligation/structs.d.ts +406 -918
- package/_generated/suilend/obligation/structs.js +786 -596
- package/_generated/suilend/rate-limiter/functions.d.ts +134 -15
- package/_generated/suilend/rate-limiter/functions.js +139 -21
- package/_generated/suilend/rate-limiter/structs.d.ts +72 -80
- package/_generated/suilend/rate-limiter/structs.js +98 -48
- package/_generated/suilend/reserve/structs.d.ts +611 -904
- package/_generated/suilend/reserve/structs.js +1528 -736
- package/_generated/suilend/reserve-config/functions.d.ts +718 -96
- package/_generated/suilend/reserve-config/functions.js +751 -157
- package/_generated/suilend/reserve-config/structs.d.ts +148 -163
- package/_generated/suilend/reserve-config/structs.js +260 -94
- package/client.d.ts +2 -2
- package/client.js +22 -39
- package/lib/initialize.d.ts +617 -83
- package/lib/initialize.js +151 -48
- package/lib/proCompatible.js +5 -5
- package/package.json +1 -1
- package/parsers/lendingMarket.d.ts +9 -9
- package/parsers/obligation.d.ts +14 -14
- package/parsers/obligation.js +4 -4
- package/parsers/rateLimiter.d.ts +1 -1
- package/parsers/reserve.d.ts +12 -12
- package/parsers/reserve.js +2 -2
- package/strategies.d.ts +14 -14
- package/utils/obligation.d.ts +3 -0
- package/utils/obligation.js +10 -0
- package/utils/simulate.d.ts +1 -1
- package/utils/simulate.js +5 -5
- package/_generated/_dependencies/source/0x1/ascii/structs.d.ts +0 -84
- package/_generated/_dependencies/source/0x1/index.d.ts +0 -3
- package/_generated/_dependencies/source/0x1/index.js +0 -3
- package/_generated/_dependencies/source/0x1/option/structs.js +0 -110
- package/_generated/_dependencies/source/0x1/type-name/structs.d.ts +0 -47
- package/_generated/_dependencies/source/0x2/bag/structs.d.ts +0 -52
- package/_generated/_dependencies/source/0x2/bag/structs.js +0 -113
- package/_generated/_dependencies/source/0x2/balance/structs.js +0 -210
- package/_generated/_dependencies/source/0x2/index.d.ts +0 -3
- package/_generated/_dependencies/source/0x2/index.js +0 -3
- package/_generated/_dependencies/source/0x2/object/structs.d.ts +0 -82
- package/_generated/_dependencies/source/0x2/object-table/structs.js +0 -115
- package/_generated/_dependencies/source/0x8d97f1cd6ac663735be08d1d2b6d02a159e711586461306ce60a2b7a6a565a9e/index.d.ts +0 -4
- package/_generated/_dependencies/source/0x8d97f1cd6ac663735be08d1d2b6d02a159e711586461306ce60a2b7a6a565a9e/index.js +0 -4
- package/_generated/_dependencies/source/0x8d97f1cd6ac663735be08d1d2b6d02a159e711586461306ce60a2b7a6a565a9e/price-identifier/structs.d.ts +0 -46
package/lib/initialize.js
CHANGED
|
@@ -1,8 +1,13 @@
|
|
|
1
|
-
import { normalizeStructTag } from "@mysten/sui/utils";
|
|
1
|
+
import { normalizeStructTag, parseStructTag } from "@mysten/sui/utils";
|
|
2
2
|
import BigNumber from "bignumber.js";
|
|
3
3
|
import { NORMALIZED_ALKIMI_COINTYPE, NORMALIZED_AUSD_COINTYPE, NORMALIZED_BLUE_COINTYPE, NORMALIZED_BUCK_COINTYPE, NORMALIZED_DEEP_COINTYPE, NORMALIZED_DMC_COINTYPE, NORMALIZED_FUD_COINTYPE, NORMALIZED_HAEDAL_COINTYPE, NORMALIZED_HIPPO_COINTYPE, NORMALIZED_IKA_COINTYPE, NORMALIZED_KOBAN_COINTYPE, NORMALIZED_LBTC_COINTYPE, NORMALIZED_NS_COINTYPE, NORMALIZED_SEND_COINTYPE, NORMALIZED_SEND_POINTS_S1_COINTYPE, NORMALIZED_SEND_POINTS_S2_COINTYPE, NORMALIZED_SOL_COINTYPE, NORMALIZED_SUI_COINTYPE, NORMALIZED_UP_COINTYPE, NORMALIZED_USDB_COINTYPE, NORMALIZED_USDC_COINTYPE, NORMALIZED_USDsui_COINTYPE, NORMALIZED_WAL_COINTYPE, NORMALIZED_WBTC_COINTYPE, NORMALIZED_WETH_COINTYPE, NORMALIZED_XAUm_COINTYPE, NORMALIZED_eEARN_COINTYPE, NORMALIZED_eTHIRD_COINTYPE, NORMALIZED_flSUI_COINTYPE, NORMALIZED_fpSUI_COINTYPE, NORMALIZED_fudSUI_COINTYPE, NORMALIZED_iSUI_COINTYPE, NORMALIZED_jugSUI_COINTYPE, NORMALIZED_kSUI_COINTYPE, NORMALIZED_mSUI_COINTYPE, NORMALIZED_mUSD_COINTYPE, NORMALIZED_oshiSUI_COINTYPE, NORMALIZED_sSUI_COINTYPE, NORMALIZED_sdeUSD_COINTYPE, NORMALIZED_stratSUI_COINTYPE, NORMALIZED_suiETH_COINTYPE, NORMALIZED_suiUSDT_COINTYPE, NORMALIZED_suiUSDe_COINTYPE, NORMALIZED_suiWBTC_COINTYPE, NORMALIZED_trevinSUI_COINTYPE, NORMALIZED_upSUI_COINTYPE, NORMALIZED_wUSDC_COINTYPE, NORMALIZED_wUSDT_COINTYPE, NORMALIZED_xBTC_COINTYPE, NORMALIZED_yapSUI_COINTYPE, TEMPORARY_PYTH_PRICE_FEED_COINTYPES, getCoinMetadataMapPartial, getPrices, isSendPoints, isSteammPoints, } from "@suilend/sui-core";
|
|
4
|
+
import { phantom } from "../_generated/_framework/reified.js";
|
|
5
|
+
import { PACKAGE_ID } from "../_generated/suilend/index.js";
|
|
6
|
+
import { ObligationOwnerCap } from "../_generated/suilend/lending-market/structs.js";
|
|
7
|
+
import { Obligation } from "../_generated/suilend/obligation/structs.js";
|
|
4
8
|
import { LENDING_MARKET_ID, SuilendClient, listAllOwnedObjects, } from "../client.js";
|
|
5
9
|
import { parseLendingMarket, parseObligation } from "../parsers/index.js";
|
|
10
|
+
import { chunkedMultiGetSettled } from "../utils/obligation.js";
|
|
6
11
|
import * as simulate from "../utils/simulate.js";
|
|
7
12
|
import { WAD } from "./constants.js";
|
|
8
13
|
import { resolvePythConnection } from "./pyth.js";
|
|
@@ -216,7 +221,7 @@ export const refreshReservesForInitialize = async (reserves, pythConnection, tol
|
|
|
216
221
|
*/
|
|
217
222
|
export const priceTemporaryPythFeedReserves = async (reserves, fetchPrices = getPrices) => {
|
|
218
223
|
const fabricatedPriceCoinTypes = [];
|
|
219
|
-
const coinTypes = reserves.map((reserve) => normalizeStructTag(reserve.coinType
|
|
224
|
+
const coinTypes = reserves.map((reserve) => normalizeStructTag(reserve.coinType));
|
|
220
225
|
let cachedUsdPrices = {};
|
|
221
226
|
try {
|
|
222
227
|
cachedUsdPrices = await fetchPrices(Array.from(new Set(coinTypes)));
|
|
@@ -241,7 +246,7 @@ export const priceTemporaryPythFeedReserves = async (reserves, fetchPrices = get
|
|
|
241
246
|
};
|
|
242
247
|
export const priceTemporaryPythFeedReservesAll = async (reservesByMarket, fetchPrices = getPrices) => {
|
|
243
248
|
const fabricatedPriceCoinTypes = new Set(await priceTemporaryPythFeedReserves(reservesByMarket.flat(), fetchPrices));
|
|
244
|
-
return reservesByMarket.map((reserves) => Array.from(new Set(reserves.map((reserve) => normalizeStructTag(reserve.coinType
|
|
249
|
+
return reservesByMarket.map((reserves) => Array.from(new Set(reserves.map((reserve) => normalizeStructTag(reserve.coinType)))).filter((coinType) => fabricatedPriceCoinTypes.has(coinType)));
|
|
245
250
|
};
|
|
246
251
|
const marketCoinTypes = (reserves, nowMs) => {
|
|
247
252
|
const miscCoinTypes = [
|
|
@@ -253,7 +258,7 @@ const marketCoinTypes = (reserves, nowMs) => {
|
|
|
253
258
|
const rewardCoinTypes = [];
|
|
254
259
|
const activeRewardCoinTypes = [];
|
|
255
260
|
reserves.forEach((r) => {
|
|
256
|
-
reserveCoinTypes.push(normalizeStructTag(r.coinType
|
|
261
|
+
reserveCoinTypes.push(normalizeStructTag(r.coinType));
|
|
257
262
|
[
|
|
258
263
|
...r.depositsPoolRewardManager.poolRewards,
|
|
259
264
|
...r.borrowsPoolRewardManager.poolRewards,
|
|
@@ -261,9 +266,9 @@ const marketCoinTypes = (reserves, nowMs) => {
|
|
|
261
266
|
if (!pr)
|
|
262
267
|
return;
|
|
263
268
|
const isActive = nowMs >= Number(pr.startTimeMs) && nowMs < Number(pr.endTimeMs);
|
|
264
|
-
rewardCoinTypes.push(normalizeStructTag(pr.coinType
|
|
269
|
+
rewardCoinTypes.push(normalizeStructTag(pr.coinType));
|
|
265
270
|
if (isActive)
|
|
266
|
-
activeRewardCoinTypes.push(normalizeStructTag(pr.coinType
|
|
271
|
+
activeRewardCoinTypes.push(normalizeStructTag(pr.coinType));
|
|
267
272
|
});
|
|
268
273
|
});
|
|
269
274
|
return {
|
|
@@ -277,7 +282,7 @@ const isUnpricedRewardCoinType = (coinType) => isSendPoints(coinType) ||
|
|
|
277
282
|
isSteammPoints(coinType) ||
|
|
278
283
|
coinType === NORMALIZED_MAYA_COINTYPE ||
|
|
279
284
|
coinType === NORMALIZED_mPOINTS_COINTYPE;
|
|
280
|
-
const isTemporaryPythFeedReserve = (reserve) => TEMPORARY_PYTH_PRICE_FEED_COINTYPES.includes(normalizeStructTag(reserve.coinType
|
|
285
|
+
const isTemporaryPythFeedReserve = (reserve) => TEMPORARY_PYTH_PRICE_FEED_COINTYPES.includes(normalizeStructTag(reserve.coinType));
|
|
281
286
|
const reservelessActiveRewardCoinTypes = ({ uniqueReserveCoinTypes, uniqueActiveRewardsCoinTypes, }) => uniqueActiveRewardsCoinTypes.filter((coinType) => !isUnpricedRewardCoinType(coinType) &&
|
|
282
287
|
coinType !== NORMALIZED_TREATS_COINTYPE &&
|
|
283
288
|
!uniqueReserveCoinTypes.includes(coinType));
|
|
@@ -287,7 +292,7 @@ export const getInitializePriceInputs = (lendingMarkets, nowMs) => {
|
|
|
287
292
|
priceFeedIds: simulate.reservePriceFeedIds(reserves.filter((reserve) => !isTemporaryPythFeedReserve(reserve))),
|
|
288
293
|
temporaryPythFeedCoinTypes: Array.from(new Set(reserves
|
|
289
294
|
.filter(isTemporaryPythFeedReserve)
|
|
290
|
-
.map((reserve) => normalizeStructTag(reserve.coinType
|
|
295
|
+
.map((reserve) => normalizeStructTag(reserve.coinType)))),
|
|
291
296
|
rewardCoinTypes: Array.from(new Set(lendingMarkets.flatMap((lendingMarket) => reservelessActiveRewardCoinTypes(marketCoinTypes(lendingMarket.reserves, nowMs))))),
|
|
292
297
|
};
|
|
293
298
|
};
|
|
@@ -354,13 +359,13 @@ const initializeSuilendMarkets = async (markets, fallbackPythEndpoint, options,
|
|
|
354
359
|
// the caller knows whether a given reserve can safely hold such a price.
|
|
355
360
|
//
|
|
356
361
|
// Normalized, matching `reserveMap` / `reserveCoinTypes` keys. Entries in
|
|
357
|
-
// `refreshedRawReserves` carry the RAW on-chain `coinType
|
|
362
|
+
// `refreshedRawReserves` carry the RAW on-chain `coinType`, which never
|
|
358
363
|
// compares equal to these (no `0x` prefix), so filtering that array means
|
|
359
364
|
// normalizing first:
|
|
360
365
|
//
|
|
361
366
|
// const unpriced = new Set(unpricedCoinTypes);
|
|
362
367
|
// refreshedRawReserves.filter(
|
|
363
|
-
// (r) => !unpriced.has(normalizeStructTag(r.coinType
|
|
368
|
+
// (r) => !unpriced.has(normalizeStructTag(r.coinType)),
|
|
364
369
|
// );
|
|
365
370
|
const unpricedCoinTypes = [
|
|
366
371
|
...refreshedWithoutTemporaryByMarket[index].unpricedCoinTypes,
|
|
@@ -377,7 +382,7 @@ const initializeSuilendMarkets = async (markets, fallbackPythEndpoint, options,
|
|
|
377
382
|
const initialized = prepared.map(({ suilendClient, lendingMarketMetadata, refreshedRawReserves, unpricedCoinTypes, uniqueReserveCoinTypes, uniqueRewardCoinTypes, uniqueActiveRewardsCoinTypes, }, index) => {
|
|
378
383
|
const { coinMetadataMap, reserveCoinMetadataMap, rewardCoinMetadataMap } = coinMetadataByMarket[index];
|
|
379
384
|
// const walReserve = refreshedRawReserves.find(
|
|
380
|
-
// (r) => normalizeStructTag(r.coinType
|
|
385
|
+
// (r) => normalizeStructTag(r.coinType) === NORMALIZED_WAL_COINTYPE,
|
|
381
386
|
// );
|
|
382
387
|
// if (walReserve) {
|
|
383
388
|
// const walPrice = BigInt(
|
|
@@ -440,47 +445,84 @@ export const initializeSuilendRewards = async (reserveMap, activeRewardCoinTypes
|
|
|
440
445
|
const [rewards] = await initializeSuilendRewardsAll([{ reserveMap, activeRewardCoinTypes }], fetchPrices);
|
|
441
446
|
return rewards;
|
|
442
447
|
};
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
})
|
|
474
|
-
SuilendClient.getObligationOwnerCaps(address, suilendClient.lendingMarket.$typeArgs, suiGrpcClient),
|
|
448
|
+
const toStrategyOwnerCap = (json) => {
|
|
449
|
+
const cap = json;
|
|
450
|
+
return {
|
|
451
|
+
id: cap.id,
|
|
452
|
+
strategyType: `${cap.strategy_type}`,
|
|
453
|
+
obligationOwnerCapId: cap.inner_cap.id,
|
|
454
|
+
obligationId: cap.inner_cap.obligation_id,
|
|
455
|
+
};
|
|
456
|
+
};
|
|
457
|
+
const OBLIGATION_OWNER_CAP_TYPE = `${PACKAGE_ID}::lending_market::ObligationOwnerCap`;
|
|
458
|
+
const STRATEGY_OWNER_CAP_TYPE = `${STRATEGY_WRAPPER_PACKAGE_ID_V1}::strategy_wrapper::StrategyOwnerCap`;
|
|
459
|
+
const capType = (capStructType, lendingMarketType) => normalizeStructTag(`${capStructType}<${lendingMarketType}>`);
|
|
460
|
+
const lendingMarketTypeOf = (type) => {
|
|
461
|
+
const [lendingMarketType] = parseStructTag(type).typeParams;
|
|
462
|
+
if (lendingMarketType === undefined)
|
|
463
|
+
return undefined;
|
|
464
|
+
return typeof lendingMarketType === "string"
|
|
465
|
+
? lendingMarketType
|
|
466
|
+
: normalizeStructTag(lendingMarketType);
|
|
467
|
+
};
|
|
468
|
+
const hasStrategies = (suilendClient) => Object.values(STRATEGY_TYPE_INFO_MAP).some((info) => info.lendingMarketId === suilendClient.lendingMarket.id);
|
|
469
|
+
const listOwnedCaps = async (suiGrpcClient, address, includeStrategyOwnerCaps) => {
|
|
470
|
+
const [strategyObjects, ownerCapObjects] = await Promise.all([
|
|
471
|
+
includeStrategyOwnerCaps
|
|
472
|
+
? listAllOwnedObjects(suiGrpcClient, address, STRATEGY_OWNER_CAP_TYPE, {
|
|
473
|
+
json: true,
|
|
474
|
+
})
|
|
475
|
+
: [],
|
|
476
|
+
listAllOwnedObjects(suiGrpcClient, address, OBLIGATION_OWNER_CAP_TYPE, {
|
|
477
|
+
content: true,
|
|
478
|
+
}),
|
|
475
479
|
]);
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
+
return {
|
|
481
|
+
strategyOwnerCaps: strategyObjects.flatMap((obj) => {
|
|
482
|
+
const lendingMarketType = lendingMarketTypeOf(obj.type);
|
|
483
|
+
return lendingMarketType === undefined
|
|
484
|
+
? []
|
|
485
|
+
: [{ ...toStrategyOwnerCap(obj.json), lendingMarketType }];
|
|
486
|
+
}),
|
|
487
|
+
obligationOwnerCaps: ownerCapObjects.flatMap((obj) => {
|
|
488
|
+
const lendingMarketType = lendingMarketTypeOf(obj.type);
|
|
489
|
+
return lendingMarketType === undefined
|
|
490
|
+
? []
|
|
491
|
+
: [
|
|
492
|
+
ObligationOwnerCap.fromBcs(phantom(lendingMarketType), obj.content),
|
|
493
|
+
];
|
|
494
|
+
}),
|
|
495
|
+
};
|
|
496
|
+
};
|
|
497
|
+
const selectMarketCaps = (owned, suilendClient) => {
|
|
498
|
+
const lendingMarketType = suilendClient.lendingMarket.$typeArgs[0];
|
|
499
|
+
const strategyOwnerCapType = capType(STRATEGY_OWNER_CAP_TYPE, lendingMarketType);
|
|
500
|
+
const obligationOwnerCapType = capType(OBLIGATION_OWNER_CAP_TYPE, lendingMarketType);
|
|
501
|
+
return {
|
|
502
|
+
strategyOwnerCaps: hasStrategies(suilendClient)
|
|
503
|
+
? owned.strategyOwnerCaps
|
|
504
|
+
.filter((soc) => capType(STRATEGY_OWNER_CAP_TYPE, soc.lendingMarketType) ===
|
|
505
|
+
strategyOwnerCapType)
|
|
506
|
+
.map(({ id, strategyType, obligationOwnerCapId, obligationId }) => ({
|
|
507
|
+
id,
|
|
508
|
+
strategyType,
|
|
509
|
+
obligationOwnerCapId,
|
|
510
|
+
obligationId,
|
|
511
|
+
}))
|
|
512
|
+
: [],
|
|
513
|
+
obligationOwnerCaps: owned.obligationOwnerCaps.filter((ownerCap) => capType(OBLIGATION_OWNER_CAP_TYPE, ownerCap.$typeArgs[0]) ===
|
|
514
|
+
obligationOwnerCapType),
|
|
515
|
+
};
|
|
516
|
+
};
|
|
517
|
+
const obligationIdsOf = ({ strategyOwnerCaps, obligationOwnerCaps, }) => [
|
|
518
|
+
...strategyOwnerCaps.map((soc) => soc.obligationId),
|
|
519
|
+
...obligationOwnerCaps.map((ownerCap) => ownerCap.obligationId),
|
|
520
|
+
];
|
|
521
|
+
const parseMarketObligations = (rawObligations, { strategyOwnerCaps, obligationOwnerCaps }, refreshedRawReserves, reserveMap) => {
|
|
522
|
+
const obligations = rawObligations
|
|
480
523
|
.map((rawObligation) => simulate.refreshObligation(rawObligation, refreshedRawReserves))
|
|
481
524
|
.map((refreshedObligation) => parseObligation(refreshedObligation, reserveMap, strategyOwnerCaps.some((soc) => soc.obligationId === refreshedObligation.id)))
|
|
482
525
|
.sort((a, b) => +b.netValueUsd.minus(a.netValueUsd));
|
|
483
|
-
// Divide into strategy and non-strategy
|
|
484
526
|
const strategyObligations = obligations.filter((o) => strategyOwnerCaps.some((soc) => soc.obligationId === o.id));
|
|
485
527
|
const nonStrategyObligations = obligations.filter((o) => !strategyObligations.some((so) => so.id === o.id));
|
|
486
528
|
return {
|
|
@@ -490,3 +532,64 @@ export const initializeObligations = async (suiGrpcClient, suilendClient, refres
|
|
|
490
532
|
obligations: nonStrategyObligations,
|
|
491
533
|
};
|
|
492
534
|
};
|
|
535
|
+
export const fetchOwnedObligations = async (suiGrpcClient, address) => {
|
|
536
|
+
const { strategyOwnerCaps, obligationOwnerCaps } = await listOwnedCaps(suiGrpcClient, address, true);
|
|
537
|
+
const lendingMarketTypeByObligationId = new Map();
|
|
538
|
+
for (const { obligationId, lendingMarketType } of [
|
|
539
|
+
...strategyOwnerCaps,
|
|
540
|
+
...obligationOwnerCaps.map((ownerCap) => ({
|
|
541
|
+
obligationId: ownerCap.obligationId,
|
|
542
|
+
lendingMarketType: ownerCap.$typeArgs[0],
|
|
543
|
+
})),
|
|
544
|
+
]) {
|
|
545
|
+
lendingMarketTypeByObligationId.set(obligationId, lendingMarketType);
|
|
546
|
+
}
|
|
547
|
+
const obligationLendingMarketTypes = Array.from(lendingMarketTypeByObligationId);
|
|
548
|
+
const objects = await chunkedMultiGetSettled(suiGrpcClient, obligationLendingMarketTypes.map(([obligationId]) => obligationId));
|
|
549
|
+
const obligations = [];
|
|
550
|
+
const obligationErrors = {};
|
|
551
|
+
for (const [index, object] of objects.entries()) {
|
|
552
|
+
const [obligationId, lendingMarketType] = obligationLendingMarketTypes[index];
|
|
553
|
+
if (object instanceof Error) {
|
|
554
|
+
obligationErrors[obligationId] = object;
|
|
555
|
+
continue;
|
|
556
|
+
}
|
|
557
|
+
try {
|
|
558
|
+
obligations.push(Obligation.fromBcs(phantom(lendingMarketType), object.content));
|
|
559
|
+
}
|
|
560
|
+
catch (error) {
|
|
561
|
+
obligationErrors[obligationId] = error;
|
|
562
|
+
}
|
|
563
|
+
}
|
|
564
|
+
return {
|
|
565
|
+
strategyOwnerCaps,
|
|
566
|
+
obligationOwnerCaps,
|
|
567
|
+
obligations,
|
|
568
|
+
obligationErrors,
|
|
569
|
+
};
|
|
570
|
+
};
|
|
571
|
+
export const parseOwnedObligations = (owned, suilendClient, refreshedRawReserves, reserveMap) => {
|
|
572
|
+
const marketCaps = selectMarketCaps(owned, suilendClient);
|
|
573
|
+
const obligationsById = new Map(owned.obligations.map((obligation) => [obligation.id, obligation]));
|
|
574
|
+
const rawObligations = obligationIdsOf(marketCaps).map((obligationId) => {
|
|
575
|
+
const obligation = obligationsById.get(obligationId);
|
|
576
|
+
if (obligation)
|
|
577
|
+
return obligation;
|
|
578
|
+
if (obligationId in owned.obligationErrors)
|
|
579
|
+
throw owned.obligationErrors[obligationId];
|
|
580
|
+
throw new Error(`Obligation ${obligationId} is not in the owned obligations`);
|
|
581
|
+
});
|
|
582
|
+
return parseMarketObligations(rawObligations, marketCaps, refreshedRawReserves, reserveMap);
|
|
583
|
+
};
|
|
584
|
+
export const initializeObligations = async (suiGrpcClient, suilendClient, refreshedRawReserves, reserveMap, address) => {
|
|
585
|
+
if (!address)
|
|
586
|
+
return {
|
|
587
|
+
strategyOwnerCaps: [],
|
|
588
|
+
strategyObligations: [],
|
|
589
|
+
obligationOwnerCaps: [],
|
|
590
|
+
obligations: [],
|
|
591
|
+
};
|
|
592
|
+
const marketCaps = selectMarketCaps(await listOwnedCaps(suiGrpcClient, address, hasStrategies(suilendClient)), suilendClient);
|
|
593
|
+
const rawObligations = await SuilendClient.getObligations(obligationIdsOf(marketCaps), suilendClient.lendingMarket.$typeArgs, suiGrpcClient);
|
|
594
|
+
return parseMarketObligations(rawObligations, marketCaps, refreshedRawReserves, reserveMap);
|
|
595
|
+
};
|
package/lib/proCompatible.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { getPublishedAt } from "../_generated/_envs/index.js";
|
|
2
2
|
import { obj, pure } from "../_generated/_framework/util.js";
|
|
3
3
|
/** `priceInfo` must come from the upgraded Pyth package; a legacy one aborts. */
|
|
4
4
|
export function refreshReservePriceProCompatible(tx, typeArg, args) {
|
|
5
5
|
return tx.moveCall({
|
|
6
|
-
target: `${
|
|
6
|
+
target: `${getPublishedAt("suilend")}::lending_market::refresh_reserve_price_pro_compatible`,
|
|
7
7
|
typeArguments: [typeArg],
|
|
8
8
|
arguments: [
|
|
9
9
|
obj(tx, args.lendingMarket),
|
|
@@ -47,7 +47,7 @@ export function priceInfoPublishTime(json, priceInfoObjectId) {
|
|
|
47
47
|
*/
|
|
48
48
|
export function addReserveProCompatible(tx, typeArgs, args) {
|
|
49
49
|
return tx.moveCall({
|
|
50
|
-
target: `${
|
|
50
|
+
target: `${getPublishedAt("suilend")}::lending_market::add_reserve_pro_compatible`,
|
|
51
51
|
typeArguments: typeArgs,
|
|
52
52
|
arguments: [
|
|
53
53
|
obj(tx, args.lendingMarketOwnerCap),
|
|
@@ -62,7 +62,7 @@ export function addReserveProCompatible(tx, typeArgs, args) {
|
|
|
62
62
|
/** The `Currency`-based form; same shape, different metadata argument. */
|
|
63
63
|
export function addReserveV2ProCompatible(tx, typeArgs, args) {
|
|
64
64
|
return tx.moveCall({
|
|
65
|
-
target: `${
|
|
65
|
+
target: `${getPublishedAt("suilend")}::lending_market::add_reserve_v2_pro_compatible`,
|
|
66
66
|
typeArguments: typeArgs,
|
|
67
67
|
arguments: [
|
|
68
68
|
obj(tx, args.lendingMarketOwnerCap),
|
|
@@ -76,7 +76,7 @@ export function addReserveV2ProCompatible(tx, typeArgs, args) {
|
|
|
76
76
|
}
|
|
77
77
|
export function changeReservePriceFeedProCompatible(tx, typeArgs, args) {
|
|
78
78
|
return tx.moveCall({
|
|
79
|
-
target: `${
|
|
79
|
+
target: `${getPublishedAt("suilend")}::lending_market::change_reserve_price_feed_pro_compatible`,
|
|
80
80
|
typeArguments: typeArgs,
|
|
81
81
|
arguments: [
|
|
82
82
|
obj(tx, args.lendingMarketOwnerCap),
|
package/package.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"name":"@suilend/sdk","version":"
|
|
1
|
+
{"name":"@suilend/sdk","version":"13.0.0-next.g122801a","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","./mmt":"./mmt.js","./strategies":"./strategies.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/proCompatible":"./lib/proCompatible.js","./lib/pyth":"./lib/pyth.js","./lib/strategyOwnerCap":"./lib/strategyOwnerCap.js","./lib/transactions":"./lib/transactions.js","./lib/types":"./lib/types.js","./margin":"./margin/index.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","./swap":"./swap/index.js","./swap/quote":"./swap/quote.js","./swap/transaction":"./swap/transaction.js","./utils/events":"./utils/events.js","./utils/feedId":"./utils/feedId.js","./utils":"./utils/index.js","./utils/obligation":"./utils/obligation.js","./utils/simulate":"./utils/simulate.js","./_generated/_envs":"./_generated/_envs/index.js","./_generated/_envs/mainnet":"./_generated/_envs/mainnet.js","./_generated/_framework/env":"./_generated/_framework/env.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","./margin/margin/admin_cap":"./margin/margin/admin_cap.js","./margin/margin/market":"./margin/margin/market.js","./margin/margin/permissions":"./margin/margin/permissions.js","./margin/margin/position":"./margin/margin/position.js","./margin/margin/router":"./margin/margin/router.js","./margin/margin/version":"./margin/margin/version.js","./margin/utils":"./margin/utils/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/pyth-2/price-identifier/structs":"./_generated/_dependencies/pyth-2/price-identifier/structs.js","./_generated/_dependencies/std/ascii/structs":"./_generated/_dependencies/std/ascii/structs.js","./_generated/_dependencies/std/option/structs":"./_generated/_dependencies/std/option/structs.js","./_generated/_dependencies/std/type-name/structs":"./_generated/_dependencies/std/type-name/structs.js","./_generated/_dependencies/sui/bag/structs":"./_generated/_dependencies/sui/bag/structs.js","./_generated/_dependencies/sui/balance/structs":"./_generated/_dependencies/sui/balance/structs.js","./_generated/_dependencies/sui/object/structs":"./_generated/_dependencies/sui/object/structs.js","./_generated/_dependencies/sui/object-table/structs":"./_generated/_dependencies/sui/object-table/structs.js","./margin/margin/deps/std/type_name":"./margin/margin/deps/std/type_name.js","./margin/margin/deps/sui/vec_set":"./margin/margin/deps/sui/vec_set.js","./margin/margin/deps/suilend/lending_market":"./margin/margin/deps/suilend/lending_market.js"},"types":"./index.d.ts","scripts":{"codegen":"node ./codegen.js","codegen:install":"node ./install-codegen.js","build":"rm -rf ./dist && tsc && node ./fix-esm-imports.js","typecheck":"tsc --noEmit && tsc --noEmit -p tsconfig.test.json","test":"vitest run","lint:ci":"yarn run typecheck","prettier":"prettier --write src/ tests/","release":"yarn run build && node ./release.js && cd ./dist && npm publish --access public"},"repository":{"type":"git","url":"git+https://github.com/fireflyprotocol/lending-mono.git","directory":"ts/sdks/sdk"},"dependencies":{"@bluefin-exchange/bluefin7k-aggregator-sdk":"7.6.3","@cetusprotocol/aggregator-sdk":"1.7.3","@flowx-finance/sdk":"2.1.0","@pythnetwork/hermes-client":"3.1.0","@pythnetwork/pyth-sui-js":"4.0.0","@suilend/springsui-sdk":"4.1.0","bignumber.js":"11.1.5","bn.js":"5.2.5","crypto-js":"4.2.0","lodash":"4.18.1","p-limit":"7.3.3","uuid":"14.0.2"},"devDependencies":{"@mysten/bcs":"2.1.1","@mysten/sui":"2.29.0","@suilend/sui-core":"2.1.0","@tsconfig/recommended":"1.0.13","@types/bn.js":"5.2.0","@types/lodash":"4.17.25","@types/node":"26.5.1","fast-check":"4.10.2","prettier":"3.9.9","ts-node":"10.9.2","typescript":"6.0.3","vite":"8.3.0","vitest":"5.0.1"},"peerDependencies":{"@mysten/bcs":"^2.1.1","@mysten/sui":">=2.22.1 <3","@suilend/sui-core":"^2.0.1"},"type":"module"}
|
|
@@ -8,7 +8,7 @@ export declare const parseLendingMarket: (lendingMarket: LendingMarket<string>,
|
|
|
8
8
|
version: bigint;
|
|
9
9
|
reserves: {
|
|
10
10
|
config: {
|
|
11
|
-
$typeName: string
|
|
11
|
+
$typeName: `${string}::reserve_config::ReserveConfig`;
|
|
12
12
|
openLtvPct: number;
|
|
13
13
|
closeLtvPct: number;
|
|
14
14
|
maxCloseLtvPct: number;
|
|
@@ -25,14 +25,14 @@ export declare const parseLendingMarket: (lendingMarket: LendingMarket<string>,
|
|
|
25
25
|
isolated: boolean;
|
|
26
26
|
openAttributedBorrowLimitUsd: number;
|
|
27
27
|
closeAttributedBorrowLimitUsd: number;
|
|
28
|
-
additionalFields: import("../_generated/_dependencies/
|
|
28
|
+
additionalFields: import("../_generated/_dependencies/sui/bag/structs").Bag;
|
|
29
29
|
interestRate: {
|
|
30
30
|
id: string;
|
|
31
31
|
utilPercent: BigNumber;
|
|
32
32
|
aprPercent: BigNumber;
|
|
33
33
|
}[];
|
|
34
34
|
};
|
|
35
|
-
$typeName: string
|
|
35
|
+
$typeName: `${string}::reserve::Reserve`;
|
|
36
36
|
id: string;
|
|
37
37
|
arrayIndex: bigint;
|
|
38
38
|
coinType: string;
|
|
@@ -51,11 +51,11 @@ export declare const parseLendingMarket: (lendingMarket: LendingMarket<string>,
|
|
|
51
51
|
unclaimedSpreadFees: BigNumber;
|
|
52
52
|
attributedBorrowValue: BigNumber;
|
|
53
53
|
depositsPoolRewardManager: {
|
|
54
|
-
$typeName: string
|
|
54
|
+
$typeName: `${string}::liquidity_mining::PoolRewardManager`;
|
|
55
55
|
id: string;
|
|
56
56
|
totalShares: bigint;
|
|
57
57
|
poolRewards: {
|
|
58
|
-
$typeName: string
|
|
58
|
+
$typeName: `${string}::liquidity_mining::PoolReward`;
|
|
59
59
|
id: string;
|
|
60
60
|
poolRewardManagerId: string;
|
|
61
61
|
coinType: string;
|
|
@@ -72,11 +72,11 @@ export declare const parseLendingMarket: (lendingMarket: LendingMarket<string>,
|
|
|
72
72
|
lastUpdateTimeMs: bigint;
|
|
73
73
|
};
|
|
74
74
|
borrowsPoolRewardManager: {
|
|
75
|
-
$typeName: string
|
|
75
|
+
$typeName: `${string}::liquidity_mining::PoolRewardManager`;
|
|
76
76
|
id: string;
|
|
77
77
|
totalShares: bigint;
|
|
78
78
|
poolRewards: {
|
|
79
|
-
$typeName: string
|
|
79
|
+
$typeName: `${string}::liquidity_mining::PoolReward`;
|
|
80
80
|
id: string;
|
|
81
81
|
poolRewardManagerId: string;
|
|
82
82
|
coinType: string;
|
|
@@ -115,13 +115,13 @@ export declare const parseLendingMarket: (lendingMarket: LendingMarket<string>,
|
|
|
115
115
|
description: string;
|
|
116
116
|
totalDeposits: BigNumber;
|
|
117
117
|
}[];
|
|
118
|
-
obligations: import("../_generated/_dependencies/
|
|
118
|
+
obligations: import("../_generated/_dependencies/sui/object-table/structs").ObjectTable<"0x2::object::ID", `${string}::obligation::Obligation<${string}>`>;
|
|
119
119
|
rateLimiter: {
|
|
120
120
|
config: {
|
|
121
121
|
windowDuration: bigint;
|
|
122
122
|
maxOutflow: bigint;
|
|
123
123
|
};
|
|
124
|
-
$typeName: string
|
|
124
|
+
$typeName: `${string}::rate_limiter::RateLimiter`;
|
|
125
125
|
prevQty: bigint;
|
|
126
126
|
windowStart: bigint;
|
|
127
127
|
curQty: bigint;
|
package/parsers/obligation.d.ts
CHANGED
|
@@ -28,7 +28,7 @@ export declare const parseObligation: (obligation: Obligation<string>, parsedRes
|
|
|
28
28
|
depositedCtokenAmount: BigNumber;
|
|
29
29
|
reserve: {
|
|
30
30
|
config: {
|
|
31
|
-
$typeName: string
|
|
31
|
+
$typeName: `${string}::reserve_config::ReserveConfig`;
|
|
32
32
|
openLtvPct: number;
|
|
33
33
|
closeLtvPct: number;
|
|
34
34
|
maxCloseLtvPct: number;
|
|
@@ -45,14 +45,14 @@ export declare const parseObligation: (obligation: Obligation<string>, parsedRes
|
|
|
45
45
|
isolated: boolean;
|
|
46
46
|
openAttributedBorrowLimitUsd: number;
|
|
47
47
|
closeAttributedBorrowLimitUsd: number;
|
|
48
|
-
additionalFields: import("../_generated/_dependencies/
|
|
48
|
+
additionalFields: import("../_generated/_dependencies/sui/bag/structs").Bag;
|
|
49
49
|
interestRate: {
|
|
50
50
|
id: string;
|
|
51
51
|
utilPercent: BigNumber;
|
|
52
52
|
aprPercent: BigNumber;
|
|
53
53
|
}[];
|
|
54
54
|
};
|
|
55
|
-
$typeName: string
|
|
55
|
+
$typeName: `${string}::reserve::Reserve`;
|
|
56
56
|
id: string;
|
|
57
57
|
arrayIndex: bigint;
|
|
58
58
|
coinType: string;
|
|
@@ -71,11 +71,11 @@ export declare const parseObligation: (obligation: Obligation<string>, parsedRes
|
|
|
71
71
|
unclaimedSpreadFees: BigNumber;
|
|
72
72
|
attributedBorrowValue: BigNumber;
|
|
73
73
|
depositsPoolRewardManager: {
|
|
74
|
-
$typeName: string
|
|
74
|
+
$typeName: `${string}::liquidity_mining::PoolRewardManager`;
|
|
75
75
|
id: string;
|
|
76
76
|
totalShares: bigint;
|
|
77
77
|
poolRewards: {
|
|
78
|
-
$typeName: string
|
|
78
|
+
$typeName: `${string}::liquidity_mining::PoolReward`;
|
|
79
79
|
id: string;
|
|
80
80
|
poolRewardManagerId: string;
|
|
81
81
|
coinType: string;
|
|
@@ -92,11 +92,11 @@ export declare const parseObligation: (obligation: Obligation<string>, parsedRes
|
|
|
92
92
|
lastUpdateTimeMs: bigint;
|
|
93
93
|
};
|
|
94
94
|
borrowsPoolRewardManager: {
|
|
95
|
-
$typeName: string
|
|
95
|
+
$typeName: `${string}::liquidity_mining::PoolRewardManager`;
|
|
96
96
|
id: string;
|
|
97
97
|
totalShares: bigint;
|
|
98
98
|
poolRewards: {
|
|
99
|
-
$typeName: string
|
|
99
|
+
$typeName: `${string}::liquidity_mining::PoolReward`;
|
|
100
100
|
id: string;
|
|
101
101
|
poolRewardManagerId: string;
|
|
102
102
|
coinType: string;
|
|
@@ -146,7 +146,7 @@ export declare const parseObligation: (obligation: Obligation<string>, parsedRes
|
|
|
146
146
|
borrowedAmountUsd: BigNumber;
|
|
147
147
|
reserve: {
|
|
148
148
|
config: {
|
|
149
|
-
$typeName: string
|
|
149
|
+
$typeName: `${string}::reserve_config::ReserveConfig`;
|
|
150
150
|
openLtvPct: number;
|
|
151
151
|
closeLtvPct: number;
|
|
152
152
|
maxCloseLtvPct: number;
|
|
@@ -163,14 +163,14 @@ export declare const parseObligation: (obligation: Obligation<string>, parsedRes
|
|
|
163
163
|
isolated: boolean;
|
|
164
164
|
openAttributedBorrowLimitUsd: number;
|
|
165
165
|
closeAttributedBorrowLimitUsd: number;
|
|
166
|
-
additionalFields: import("../_generated/_dependencies/
|
|
166
|
+
additionalFields: import("../_generated/_dependencies/sui/bag/structs").Bag;
|
|
167
167
|
interestRate: {
|
|
168
168
|
id: string;
|
|
169
169
|
utilPercent: BigNumber;
|
|
170
170
|
aprPercent: BigNumber;
|
|
171
171
|
}[];
|
|
172
172
|
};
|
|
173
|
-
$typeName: string
|
|
173
|
+
$typeName: `${string}::reserve::Reserve`;
|
|
174
174
|
id: string;
|
|
175
175
|
arrayIndex: bigint;
|
|
176
176
|
coinType: string;
|
|
@@ -189,11 +189,11 @@ export declare const parseObligation: (obligation: Obligation<string>, parsedRes
|
|
|
189
189
|
unclaimedSpreadFees: BigNumber;
|
|
190
190
|
attributedBorrowValue: BigNumber;
|
|
191
191
|
depositsPoolRewardManager: {
|
|
192
|
-
$typeName: string
|
|
192
|
+
$typeName: `${string}::liquidity_mining::PoolRewardManager`;
|
|
193
193
|
id: string;
|
|
194
194
|
totalShares: bigint;
|
|
195
195
|
poolRewards: {
|
|
196
|
-
$typeName: string
|
|
196
|
+
$typeName: `${string}::liquidity_mining::PoolReward`;
|
|
197
197
|
id: string;
|
|
198
198
|
poolRewardManagerId: string;
|
|
199
199
|
coinType: string;
|
|
@@ -210,11 +210,11 @@ export declare const parseObligation: (obligation: Obligation<string>, parsedRes
|
|
|
210
210
|
lastUpdateTimeMs: bigint;
|
|
211
211
|
};
|
|
212
212
|
borrowsPoolRewardManager: {
|
|
213
|
-
$typeName: string
|
|
213
|
+
$typeName: `${string}::liquidity_mining::PoolRewardManager`;
|
|
214
214
|
id: string;
|
|
215
215
|
totalShares: bigint;
|
|
216
216
|
poolRewards: {
|
|
217
|
-
$typeName: string
|
|
217
|
+
$typeName: `${string}::liquidity_mining::PoolReward`;
|
|
218
218
|
id: string;
|
|
219
219
|
poolRewardManagerId: string;
|
|
220
220
|
coinType: string;
|
package/parsers/obligation.js
CHANGED
|
@@ -12,10 +12,10 @@ export const parseObligation = (obligation, parsedReserveMap, isStrategy) => {
|
|
|
12
12
|
let depositPositionCount = 0;
|
|
13
13
|
let borrowPositionCount = 0;
|
|
14
14
|
const deposits = obligation.deposits.map((deposit) => {
|
|
15
|
-
const coinType = normalizeStructTag(deposit.coinType
|
|
15
|
+
const coinType = normalizeStructTag(deposit.coinType);
|
|
16
16
|
const reserve = parsedReserveMap[coinType];
|
|
17
17
|
if (!reserve)
|
|
18
|
-
throw new Error(`Reserve with coinType ${deposit.coinType
|
|
18
|
+
throw new Error(`Reserve with coinType ${deposit.coinType} not found`);
|
|
19
19
|
depositPositionCount++;
|
|
20
20
|
const depositedCtokenAmount = new BigNumber(deposit.depositedCtokenAmount.toString());
|
|
21
21
|
const depositedAmount = depositedCtokenAmount
|
|
@@ -44,10 +44,10 @@ export const parseObligation = (obligation, parsedReserveMap, isStrategy) => {
|
|
|
44
44
|
};
|
|
45
45
|
});
|
|
46
46
|
const borrows = obligation.borrows.map((borrow) => {
|
|
47
|
-
const coinType = normalizeStructTag(borrow.coinType
|
|
47
|
+
const coinType = normalizeStructTag(borrow.coinType);
|
|
48
48
|
const reserve = parsedReserveMap[coinType];
|
|
49
49
|
if (!reserve)
|
|
50
|
-
throw new Error(`Reserve with coinType ${borrow.coinType
|
|
50
|
+
throw new Error(`Reserve with coinType ${borrow.coinType} not found`);
|
|
51
51
|
borrowPositionCount++;
|
|
52
52
|
const cumulativeBorrowRate = new BigNumber(borrow.cumulativeBorrowRate.value.toString()).div(WAD);
|
|
53
53
|
const borrowedAmountInitial = new BigNumber(borrow.borrowedAmount.value.toString())
|
package/parsers/rateLimiter.d.ts
CHANGED
|
@@ -7,7 +7,7 @@ export declare const parseRateLimiter: (rateLimiter: RateLimiter, nowS: number)
|
|
|
7
7
|
windowDuration: bigint;
|
|
8
8
|
maxOutflow: bigint;
|
|
9
9
|
};
|
|
10
|
-
$typeName: string
|
|
10
|
+
$typeName: `${string}::rate_limiter::RateLimiter`;
|
|
11
11
|
prevQty: bigint;
|
|
12
12
|
windowStart: bigint;
|
|
13
13
|
curQty: bigint;
|