@suilend/sdk 7.0.1 → 8.0.0

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/client.js CHANGED
@@ -1,24 +1,33 @@
1
1
  import { SUI_CLOCK_OBJECT_ID, SUI_SYSTEM_STATE_OBJECT_ID, normalizeStructTag, normalizeSuiObjectId, toHex, } from "@mysten/sui/utils";
2
2
  import { SuiPriceServiceConnection, SuiPythClient, } from "@pythnetwork/pyth-sui-js";
3
3
  import { extractCTokenCoinType, getAllCoins, getSpendableCoin, } from "@suilend/sui-core";
4
- import { PriceInfoObject } from "./_generated/_dependencies/source/0x8d97f1cd6ac663735be08d1d2b6d02a159e711586461306ce60a2b7a6a565a9e/price-info/structs.js";
5
4
  import { phantom } from "./_generated/_framework/reified.js";
6
5
  import { PKG_V10, setPublishedAt } from "./_generated/suilend/index.js";
7
6
  import { PACKAGE_ID, PUBLISHED_AT } from "./_generated/suilend/index.js";
8
- import { addPoolReward, addReserve, addReserveV2, borrowRequest, cancelPoolReward, changeReservePriceFeed, claimFees, claimRewards, claimRewardsAndDeposit, closePoolReward, depositCtokensIntoObligation, depositLiquidityAndMintCtokens, fulfillLiquidityRequest, liquidate, migrate, newObligationOwnerCap, rebalanceStaker, redeemCtokensAndWithdrawLiquidityRequest, refreshReservePrice, repay, setFeeReceivers, unstakeSuiFromStaker, updateRateLimiterConfig, updateReserveConfig, withdrawCtokens, } from "./_generated/suilend/lending-market/functions.js";
7
+ import { addPoolReward, borrowRequest, cancelPoolReward, claimFees, claimRewards, claimRewardsAndDeposit, closePoolReward, depositCtokensIntoObligation, depositLiquidityAndMintCtokens, fulfillLiquidityRequest, liquidate, migrate, newObligationOwnerCap, rebalanceStaker, redeemCtokensAndWithdrawLiquidityRequest, repay, setFeeReceivers, unstakeSuiFromStaker, updateRateLimiterConfig, updateReserveConfig, withdrawCtokens, } from "./_generated/suilend/lending-market/functions.js";
9
8
  import { LendingMarket, ObligationOwnerCap, } from "./_generated/suilend/lending-market/structs.js";
10
9
  import { createLendingMarket } from "./_generated/suilend/lending-market-registry/functions.js";
11
10
  import { Obligation } from "./_generated/suilend/obligation/structs.js";
12
11
  import { newConfig as createRateLimiterConfig, } from "./_generated/suilend/rate-limiter/functions.js";
13
12
  import { createReserveConfig, } from "./_generated/suilend/reserve-config/functions.js";
13
+ import { addReserveProCompatible, addReserveV2ProCompatible, changeReservePriceFeedProCompatible, priceInfoPublishTime, refreshReservePriceProCompatible, } from "./lib/proCompatible.js";
14
14
  import { PRIMARY_PYTH_ENDPOINT } from "./lib/pyth.js";
15
15
  import { Side } from "./lib/types.js";
16
16
  import { chunkedMultiGet } from "./utils/obligation.js";
17
17
  const SUI_COINTYPE = "0x2::sui::SUI";
18
18
  const NORMALIZED_SUI_COINTYPE = normalizeStructTag(SUI_COINTYPE);
19
19
  const isSui = (coinType) => normalizeStructTag(coinType) === NORMALIZED_SUI_COINTYPE;
20
- const WORMHOLE_STATE_ID = "0xaeab97f96cf9877fee2883315d459552b2b921edc16d7ceac6eab944dd88919c";
21
- const PYTH_STATE_ID = "0x1f9310238ee9298fb703c3419030b35b22bb1cc37113e3bb5007c99aec79e5b8";
20
+ // Pyth Core's 2026-08-18 upgrade. These are the UPGRADED state objects, which
21
+ // pair with the pro-compatible Pyth package the Move contracts now link against
22
+ // (see move/contracts/suilend/Move.toml). The pre-upgrade values were
23
+ // Wormhole 0xaeab97f9… and Pyth 0x1f931023….
24
+ //
25
+ // MUST ship in the same release as the suilend package upgrade. Pointing the
26
+ // SDK at the upgraded state while the published package still links the legacy
27
+ // Pyth package breaks every on-chain price update -- the object passed to
28
+ // refresh would come from a package the contract does not accept.
29
+ const WORMHOLE_STATE_ID = "0xdbca52b9fb4f712e25f61f974586d93ac541bcf8389564f0323bb07215168b5c";
30
+ const PYTH_STATE_ID = "0x03719fae774ddab3cfcaa53bbc046f0cbe21410019b6280811bf3f9f4b05839d";
22
31
  export const ADMIN_ADDRESS = process.env.NEXT_PUBLIC_SUILEND_USE_BETA_MARKET === "true"
23
32
  ? "0xa902504c338e17f44dfee1bd1c3cad1ff03326579b9cdcfe2762fc12c46fc033" // beta owner
24
33
  : "0xb1ffbc2e1915f44b8f271a703becc1bf8aa79bc22431a58900a102892b783c25";
@@ -292,7 +301,9 @@ export class SuilendClient {
292
301
  throw new Error("Error: CoinMetadata not found");
293
302
  if (!coinMetadata.id)
294
303
  throw new Error("Error: CoinMetadata.id not found");
295
- const addReserveFn = useV2 ? addReserveV2 : addReserve;
304
+ const addReserveFn = useV2
305
+ ? addReserveV2ProCompatible
306
+ : addReserveProCompatible;
296
307
  return addReserveFn(transaction, [this.lendingMarket.$typeArgs[0], coinType], {
297
308
  lendingMarketOwnerCap: transaction.object(lendingMarketOwnerCapId),
298
309
  lendingMarket: transaction.object(this.lendingMarket.id),
@@ -422,7 +433,7 @@ export class SuilendClient {
422
433
  pythPriceId,
423
434
  ]);
424
435
  const priceInfoObjectIds = await this.pythClient.updatePriceFeeds(transaction, priceUpdateData, [pythPriceId]);
425
- return changeReservePriceFeed(transaction, [this.lendingMarket.$typeArgs[0], coinType], {
436
+ return changeReservePriceFeedProCompatible(transaction, [this.lendingMarket.$typeArgs[0], coinType], {
426
437
  lendingMarketOwnerCap: transaction.object(lendingMarketOwnerCapId),
427
438
  lendingMarket: transaction.object(this.lendingMarket.id),
428
439
  reserveArrayIndex: transaction.pure.u64(this.findReserveArrayIndex(coinType)),
@@ -469,8 +480,13 @@ export class SuilendClient {
469
480
  })()));
470
481
  const stalePriceIdentifiers = [];
471
482
  await Promise.all(Object.entries(priceInfoObjectIds).map(([i, priceInfoObjectId]) => (async () => {
472
- const priceInfoObject = await PriceInfoObject.fetch(this.suiGrpcClient, priceInfoObjectId);
473
- const publishTime = priceInfoObject.priceInfo.priceFeed.price.timestamp;
483
+ // Read the field directly: the generated parser's type check is
484
+ // bound to one Pyth package address and would throw post-cutover.
485
+ const { object } = await this.suiGrpcClient.getObject({
486
+ objectId: priceInfoObjectId,
487
+ include: { json: true },
488
+ });
489
+ const publishTime = priceInfoPublishTime(object.json, priceInfoObjectId);
474
490
  const stalenessSeconds = Date.now() / 1000 - Number(publishTime);
475
491
  if (stalenessSeconds > 20) {
476
492
  const reserve = this.lendingMarket.reserves[Number(reserveArrayIndexes[+i])];
@@ -489,7 +505,7 @@ export class SuilendClient {
489
505
  if (priceInfoObjectId == null) {
490
506
  return;
491
507
  }
492
- refreshReservePrice(transaction, this.lendingMarket.$typeArgs[0], {
508
+ refreshReservePriceProCompatible(transaction, this.lendingMarket.$typeArgs[0], {
493
509
  lendingMarket: transaction.object(this.lendingMarket.id),
494
510
  reserveArrayIndex: transaction.pure.u64(reserveArrayIndex),
495
511
  clock: transaction.object(SUI_CLOCK_OBJECT_ID),
@@ -0,0 +1,63 @@
1
+ /**
2
+ * Bindings for the Pyth Core 2026-08-18 cutover entry points.
3
+ *
4
+ * Still hand-written, but no longer for the original reason: suilend v22 is
5
+ * published, so `sui-client-gen` could now see these functions. What blocks
6
+ * regeneration is that `_generated/gen.toml` points at
7
+ * `ts/suilend/contracts/suilend`, a pre-monorepo path that no longer exists,
8
+ * and regenerating rewrites 166 files. Fixing the generator config is worth
9
+ * doing on its own, without a cutover attached.
10
+ */
11
+ import { Transaction, TransactionArgument, TransactionObjectInput } from "@mysten/sui/transactions";
12
+ export interface RefreshReservePriceProCompatibleArgs {
13
+ lendingMarket: TransactionObjectInput;
14
+ reserveArrayIndex: bigint | TransactionArgument;
15
+ clock: TransactionObjectInput;
16
+ priceInfo: TransactionObjectInput;
17
+ }
18
+ /** `priceInfo` must come from the upgraded Pyth package; a legacy one aborts. */
19
+ export declare function refreshReservePriceProCompatible(tx: Transaction, typeArg: string, args: RefreshReservePriceProCompatibleArgs): import("@mysten/sui/transactions").TransactionResult;
20
+ /**
21
+ * Publish time out of a `PriceInfoObject`'s json projection.
22
+ *
23
+ * Read by field path rather than through the generated `PriceInfoObject.fetch`,
24
+ * whose type check is bound to ONE Pyth package address and therefore throws
25
+ * for every caller once the contracts link the upgraded package.
26
+ *
27
+ * The nesting is identical across both packages — verified 2026-08-18 against
28
+ * live mainnet objects from each:
29
+ *
30
+ * upgraded 0x55300367…::price_info::PriceInfoObject -> timestamp present
31
+ * legacy 0x8d97f1cd…::price_info::PriceInfoObject -> timestamp present
32
+ *
33
+ * Validated rather than dereferenced blindly: this runs inside every deposit,
34
+ * borrow and withdraw, so a wrong or stale `priceInfoObjectId` — a bad cache in
35
+ * `getPriceFeedObjectId`, or a network mismatch — should name itself instead of
36
+ * surfacing as `Cannot read properties of undefined`.
37
+ */
38
+ export declare function priceInfoPublishTime(json: unknown, priceInfoObjectId: string): string | number;
39
+ export interface AddReserveProCompatibleArgs {
40
+ lendingMarketOwnerCap: TransactionObjectInput;
41
+ lendingMarket: TransactionObjectInput;
42
+ priceInfo: TransactionObjectInput;
43
+ config: TransactionObjectInput;
44
+ /** `CoinMetadata<T>` for add_reserve, `Currency<T>` for the v2 form. */
45
+ coinMetadata: TransactionObjectInput;
46
+ clock: TransactionObjectInput;
47
+ }
48
+ /**
49
+ * Creating a reserve needs the upgraded Pyth package too. Post-cutover the
50
+ * legacy `add_reserve` cannot be given a `PriceInfoObject` the contract will
51
+ * accept, so adding a reserve fails outright without this.
52
+ */
53
+ export declare function addReserveProCompatible(tx: Transaction, typeArgs: [string, string], args: AddReserveProCompatibleArgs): import("@mysten/sui/transactions").TransactionResult;
54
+ /** The `Currency`-based form; same shape, different metadata argument. */
55
+ export declare function addReserveV2ProCompatible(tx: Transaction, typeArgs: [string, string], args: AddReserveProCompatibleArgs): import("@mysten/sui/transactions").TransactionResult;
56
+ export interface ChangeReservePriceFeedProCompatibleArgs {
57
+ lendingMarketOwnerCap: TransactionObjectInput;
58
+ lendingMarket: TransactionObjectInput;
59
+ reserveArrayIndex: bigint | TransactionArgument;
60
+ priceInfoObj: TransactionObjectInput;
61
+ clock: TransactionObjectInput;
62
+ }
63
+ export declare function changeReservePriceFeedProCompatible(tx: Transaction, typeArgs: [string, string], args: ChangeReservePriceFeedProCompatibleArgs): import("@mysten/sui/transactions").TransactionResult;
@@ -0,0 +1,89 @@
1
+ import { PUBLISHED_AT } from "../_generated/suilend/index.js";
2
+ import { obj, pure } from "../_generated/_framework/util.js";
3
+ /** `priceInfo` must come from the upgraded Pyth package; a legacy one aborts. */
4
+ export function refreshReservePriceProCompatible(tx, typeArg, args) {
5
+ return tx.moveCall({
6
+ target: `${PUBLISHED_AT}::lending_market::refresh_reserve_price_pro_compatible`,
7
+ typeArguments: [typeArg],
8
+ arguments: [
9
+ obj(tx, args.lendingMarket),
10
+ pure(tx, args.reserveArrayIndex, `u64`),
11
+ obj(tx, args.clock),
12
+ obj(tx, args.priceInfo),
13
+ ],
14
+ });
15
+ }
16
+ /**
17
+ * Publish time out of a `PriceInfoObject`'s json projection.
18
+ *
19
+ * Read by field path rather than through the generated `PriceInfoObject.fetch`,
20
+ * whose type check is bound to ONE Pyth package address and therefore throws
21
+ * for every caller once the contracts link the upgraded package.
22
+ *
23
+ * The nesting is identical across both packages — verified 2026-08-18 against
24
+ * live mainnet objects from each:
25
+ *
26
+ * upgraded 0x55300367…::price_info::PriceInfoObject -> timestamp present
27
+ * legacy 0x8d97f1cd…::price_info::PriceInfoObject -> timestamp present
28
+ *
29
+ * Validated rather than dereferenced blindly: this runs inside every deposit,
30
+ * borrow and withdraw, so a wrong or stale `priceInfoObjectId` — a bad cache in
31
+ * `getPriceFeedObjectId`, or a network mismatch — should name itself instead of
32
+ * surfacing as `Cannot read properties of undefined`.
33
+ */
34
+ export function priceInfoPublishTime(json, priceInfoObjectId) {
35
+ const timestamp = json?.price_info?.price_feed?.price?.timestamp;
36
+ if (timestamp === undefined) {
37
+ throw new Error(`${priceInfoObjectId} is not a PriceInfoObject, or its layout changed: ` +
38
+ `expected json.price_info.price_feed.price.timestamp, got keys ` +
39
+ `[${Object.keys(json ?? {}).join(", ")}]`);
40
+ }
41
+ return timestamp;
42
+ }
43
+ /**
44
+ * Creating a reserve needs the upgraded Pyth package too. Post-cutover the
45
+ * legacy `add_reserve` cannot be given a `PriceInfoObject` the contract will
46
+ * accept, so adding a reserve fails outright without this.
47
+ */
48
+ export function addReserveProCompatible(tx, typeArgs, args) {
49
+ return tx.moveCall({
50
+ target: `${PUBLISHED_AT}::lending_market::add_reserve_pro_compatible`,
51
+ typeArguments: typeArgs,
52
+ arguments: [
53
+ obj(tx, args.lendingMarketOwnerCap),
54
+ obj(tx, args.lendingMarket),
55
+ obj(tx, args.priceInfo),
56
+ obj(tx, args.config),
57
+ obj(tx, args.coinMetadata),
58
+ obj(tx, args.clock),
59
+ ],
60
+ });
61
+ }
62
+ /** The `Currency`-based form; same shape, different metadata argument. */
63
+ export function addReserveV2ProCompatible(tx, typeArgs, args) {
64
+ return tx.moveCall({
65
+ target: `${PUBLISHED_AT}::lending_market::add_reserve_v2_pro_compatible`,
66
+ typeArguments: typeArgs,
67
+ arguments: [
68
+ obj(tx, args.lendingMarketOwnerCap),
69
+ obj(tx, args.lendingMarket),
70
+ obj(tx, args.priceInfo),
71
+ obj(tx, args.config),
72
+ obj(tx, args.coinMetadata),
73
+ obj(tx, args.clock),
74
+ ],
75
+ });
76
+ }
77
+ export function changeReservePriceFeedProCompatible(tx, typeArgs, args) {
78
+ return tx.moveCall({
79
+ target: `${PUBLISHED_AT}::lending_market::change_reserve_price_feed_pro_compatible`,
80
+ typeArguments: typeArgs,
81
+ arguments: [
82
+ obj(tx, args.lendingMarketOwnerCap),
83
+ obj(tx, args.lendingMarket),
84
+ pure(tx, args.reserveArrayIndex, `u64`),
85
+ obj(tx, args.priceInfoObj),
86
+ obj(tx, args.clock),
87
+ ],
88
+ });
89
+ }
package/package.json CHANGED
@@ -1 +1 @@
1
- {"name":"@suilend/sdk","version":"7.0.1","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/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/_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/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","./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","./_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.d.ts","scripts":{"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.5.0","@cetusprotocol/aggregator-sdk":"^1.5.7","@flowx-finance/sdk":"^2.1.0","@pythnetwork/hermes-client":"3.1.0","@pythnetwork/pyth-sui-js":"4.0.0","@suilend/springsui-sdk":"^4.0.0","bignumber.js":"^11.1.5","bn.js":"^5.2.2","crypto-js":"^4.2.0","lodash":"^4.17.21","p-limit":"7.3.1","uuid":"^14.0.1"},"devDependencies":{"@mysten/bcs":"^2.0.5","@mysten/sui":"2.23.1","@suilend/sui-core":"^1.0.0","@tsconfig/recommended":"^1.0.8","@types/bn.js":"^5.2.0","@types/lodash":"^4.17.20","@types/node":"^26.1.2","fast-check":"^4.9.0","prettier":"^3.3.3","ts-node":"^10.9.2","typescript":"^6.0.3","vitest":"4.1.10"},"peerDependencies":{"@mysten/bcs":"^2.0.5","@mysten/sui":">=2.22.1 <3","@suilend/sui-core":"^1.0.0"},"type":"module"}
1
+ {"name":"@suilend/sdk","version":"8.0.0","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/_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/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","./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","./_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/price-identifier/structs":"./_generated/_dependencies/source/0x8d97f1cd6ac663735be08d1d2b6d02a159e711586461306ce60a2b7a6a565a9e/price-identifier/structs.js"},"types":"./index.d.ts","scripts":{"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.5.0","@cetusprotocol/aggregator-sdk":"^1.5.7","@flowx-finance/sdk":"^2.1.0","@pythnetwork/hermes-client":"3.1.0","@pythnetwork/pyth-sui-js":"4.0.0","@suilend/springsui-sdk":"^4.0.0","bignumber.js":"^11.1.5","bn.js":"^5.2.2","crypto-js":"^4.2.0","lodash":"^4.17.21","p-limit":"7.3.1","uuid":"^14.0.1"},"devDependencies":{"@mysten/bcs":"^2.0.5","@mysten/sui":"2.23.1","@suilend/sui-core":"^1.0.0","@tsconfig/recommended":"^1.0.8","@types/bn.js":"^5.2.0","@types/lodash":"^4.17.20","@types/node":"^26.1.2","fast-check":"^4.9.0","prettier":"^3.3.3","ts-node":"^10.9.2","typescript":"^6.0.3","vitest":"4.1.10"},"peerDependencies":{"@mysten/bcs":"^2.0.5","@mysten/sui":">=2.22.1 <3","@suilend/sui-core":"^1.0.0"},"type":"module"}
@@ -1,47 +0,0 @@
1
- import { PhantomReified, Reified, StructClass, ToField, ToTypeStr } from "../../../../_framework/reified";
2
- import { FieldsWithTypes } from "../../../../_framework/util";
3
- import { PKG_V1 } from "../index";
4
- import { SuiGrpcClient } from "@mysten/sui/grpc";
5
- export declare function isI64(type: string): boolean;
6
- export interface I64Fields {
7
- negative: ToField<"bool">;
8
- magnitude: ToField<"u64">;
9
- }
10
- export type I64Reified = Reified<I64, I64Fields>;
11
- export declare class I64 implements StructClass {
12
- __StructClass: true;
13
- static readonly $typeName = "0x8d97f1cd6ac663735be08d1d2b6d02a159e711586461306ce60a2b7a6a565a9e::i64::I64";
14
- static readonly $numTypeParams = 0;
15
- static readonly $isPhantom: readonly [];
16
- readonly $typeName = "0x8d97f1cd6ac663735be08d1d2b6d02a159e711586461306ce60a2b7a6a565a9e::i64::I64";
17
- readonly $fullTypeName: `${typeof PKG_V1}::i64::I64`;
18
- readonly $typeArgs: [];
19
- readonly $isPhantom: readonly [];
20
- readonly negative: ToField<"bool">;
21
- readonly magnitude: ToField<"u64">;
22
- private constructor();
23
- static reified(): I64Reified;
24
- static get r(): import("../../../../_framework/reified").StructClassReified<I64, I64Fields>;
25
- static phantom(): PhantomReified<ToTypeStr<I64>>;
26
- static get p(): PhantomReified<"0x8d97f1cd6ac663735be08d1d2b6d02a159e711586461306ce60a2b7a6a565a9e::i64::I64">;
27
- static get bcs(): import("@mysten/bcs").BcsStruct<{
28
- negative: import("@mysten/bcs").BcsType<boolean, boolean, "bool">;
29
- magnitude: import("@mysten/bcs").BcsType<string, string | number | bigint, "u64">;
30
- }, string>;
31
- static fromFields(fields: Record<string, any>): I64;
32
- static fromFieldsWithTypes(item: FieldsWithTypes): I64;
33
- static fromBcs(data: Uint8Array): I64;
34
- toJSONField(): {
35
- negative: boolean;
36
- magnitude: string;
37
- };
38
- toJSON(): {
39
- negative: boolean;
40
- magnitude: string;
41
- $typeName: string;
42
- $typeArgs: [];
43
- };
44
- static fromJSONField(field: any): I64;
45
- static fromJSON(json: Record<string, any>): I64;
46
- static fetch(client: SuiGrpcClient, id: string): Promise<I64>;
47
- }
@@ -1,112 +0,0 @@
1
- import { decodeFromFields, decodeFromFieldsWithTypes, decodeFromJSONField, phantom, } from "../../../../_framework/reified.js";
2
- import { composeSuiType, compressSuiType, } from "../../../../_framework/util.js";
3
- import { PKG_V1 } from "../index.js";
4
- import { bcs } from "@mysten/sui/bcs";
5
- /* ============================== I64 =============================== */
6
- export function isI64(type) {
7
- type = compressSuiType(type);
8
- return type === `${PKG_V1}::i64::I64`;
9
- }
10
- export class I64 {
11
- __StructClass = true;
12
- static $typeName = `${PKG_V1}::i64::I64`;
13
- static $numTypeParams = 0;
14
- static $isPhantom = [];
15
- $typeName = I64.$typeName;
16
- $fullTypeName;
17
- $typeArgs;
18
- $isPhantom = I64.$isPhantom;
19
- negative;
20
- magnitude;
21
- constructor(typeArgs, fields) {
22
- this.$fullTypeName = composeSuiType(I64.$typeName, ...typeArgs);
23
- this.$typeArgs = typeArgs;
24
- this.negative = fields.negative;
25
- this.magnitude = fields.magnitude;
26
- }
27
- static reified() {
28
- return {
29
- typeName: I64.$typeName,
30
- fullTypeName: composeSuiType(I64.$typeName, ...[]),
31
- typeArgs: [],
32
- isPhantom: I64.$isPhantom,
33
- reifiedTypeArgs: [],
34
- fromFields: (fields) => I64.fromFields(fields),
35
- fromFieldsWithTypes: (item) => I64.fromFieldsWithTypes(item),
36
- fromBcs: (data) => I64.fromBcs(data),
37
- bcs: I64.bcs,
38
- fromJSONField: (field) => I64.fromJSONField(field),
39
- fromJSON: (json) => I64.fromJSON(json),
40
- fetch: async (client, id) => I64.fetch(client, id),
41
- new: (fields) => {
42
- return new I64([], fields);
43
- },
44
- kind: "StructClassReified",
45
- };
46
- }
47
- static get r() {
48
- return I64.reified();
49
- }
50
- static phantom() {
51
- return phantom(I64.reified());
52
- }
53
- static get p() {
54
- return I64.phantom();
55
- }
56
- static get bcs() {
57
- return bcs.struct("I64", {
58
- negative: bcs.bool(),
59
- magnitude: bcs.u64(),
60
- });
61
- }
62
- static fromFields(fields) {
63
- return I64.reified().new({
64
- negative: decodeFromFields("bool", fields.negative),
65
- magnitude: decodeFromFields("u64", fields.magnitude),
66
- });
67
- }
68
- static fromFieldsWithTypes(item) {
69
- if (!isI64(item.type)) {
70
- throw new Error("not a I64 type");
71
- }
72
- return I64.reified().new({
73
- negative: decodeFromFieldsWithTypes("bool", item.fields.negative),
74
- magnitude: decodeFromFieldsWithTypes("u64", item.fields.magnitude),
75
- });
76
- }
77
- static fromBcs(data) {
78
- return I64.fromFields(I64.bcs.parse(data));
79
- }
80
- toJSONField() {
81
- return {
82
- negative: this.negative,
83
- magnitude: this.magnitude.toString(),
84
- };
85
- }
86
- toJSON() {
87
- return {
88
- $typeName: this.$typeName,
89
- $typeArgs: this.$typeArgs,
90
- ...this.toJSONField(),
91
- };
92
- }
93
- static fromJSONField(field) {
94
- return I64.reified().new({
95
- negative: decodeFromJSONField("bool", field.negative),
96
- magnitude: decodeFromJSONField("u64", field.magnitude),
97
- });
98
- }
99
- static fromJSON(json) {
100
- if (json.$typeName !== I64.$typeName) {
101
- throw new Error("not a WithTwoGenerics json object");
102
- }
103
- return I64.fromJSONField(json);
104
- }
105
- static async fetch(client, id) {
106
- const { object } = await client.getObject({ objectId: id, include: { content: true } });
107
- if (!isI64(object.type)) {
108
- throw new Error(`object at id ${id} is not a I64 object`);
109
- }
110
- return I64.fromBcs(object.content);
111
- }
112
- }
@@ -1,76 +0,0 @@
1
- import { PhantomReified, Reified, StructClass, ToField, ToTypeStr } from "../../../../_framework/reified";
2
- import { FieldsWithTypes } from "../../../../_framework/util";
3
- import { I64 } from "../i64/structs";
4
- import { PKG_V1 } from "../index";
5
- import { SuiGrpcClient } from "@mysten/sui/grpc";
6
- export declare function isPrice(type: string): boolean;
7
- export interface PriceFields {
8
- price: ToField<I64>;
9
- conf: ToField<"u64">;
10
- expo: ToField<I64>;
11
- timestamp: ToField<"u64">;
12
- }
13
- export type PriceReified = Reified<Price, PriceFields>;
14
- export declare class Price implements StructClass {
15
- __StructClass: true;
16
- static readonly $typeName = "0x8d97f1cd6ac663735be08d1d2b6d02a159e711586461306ce60a2b7a6a565a9e::price::Price";
17
- static readonly $numTypeParams = 0;
18
- static readonly $isPhantom: readonly [];
19
- readonly $typeName = "0x8d97f1cd6ac663735be08d1d2b6d02a159e711586461306ce60a2b7a6a565a9e::price::Price";
20
- readonly $fullTypeName: `${typeof PKG_V1}::price::Price`;
21
- readonly $typeArgs: [];
22
- readonly $isPhantom: readonly [];
23
- readonly price: ToField<I64>;
24
- readonly conf: ToField<"u64">;
25
- readonly expo: ToField<I64>;
26
- readonly timestamp: ToField<"u64">;
27
- private constructor();
28
- static reified(): PriceReified;
29
- static get r(): import("../../../../_framework/reified").StructClassReified<Price, PriceFields>;
30
- static phantom(): PhantomReified<ToTypeStr<Price>>;
31
- static get p(): PhantomReified<"0x8d97f1cd6ac663735be08d1d2b6d02a159e711586461306ce60a2b7a6a565a9e::price::Price">;
32
- static get bcs(): import("@mysten/bcs").BcsStruct<{
33
- price: import("@mysten/bcs").BcsStruct<{
34
- negative: import("@mysten/bcs").BcsType<boolean, boolean, "bool">;
35
- magnitude: import("@mysten/bcs").BcsType<string, string | number | bigint, "u64">;
36
- }, string>;
37
- conf: import("@mysten/bcs").BcsType<string, string | number | bigint, "u64">;
38
- expo: import("@mysten/bcs").BcsStruct<{
39
- negative: import("@mysten/bcs").BcsType<boolean, boolean, "bool">;
40
- magnitude: import("@mysten/bcs").BcsType<string, string | number | bigint, "u64">;
41
- }, string>;
42
- timestamp: import("@mysten/bcs").BcsType<string, string | number | bigint, "u64">;
43
- }, string>;
44
- static fromFields(fields: Record<string, any>): Price;
45
- static fromFieldsWithTypes(item: FieldsWithTypes): Price;
46
- static fromBcs(data: Uint8Array): Price;
47
- toJSONField(): {
48
- price: {
49
- negative: boolean;
50
- magnitude: string;
51
- };
52
- conf: string;
53
- expo: {
54
- negative: boolean;
55
- magnitude: string;
56
- };
57
- timestamp: string;
58
- };
59
- toJSON(): {
60
- price: {
61
- negative: boolean;
62
- magnitude: string;
63
- };
64
- conf: string;
65
- expo: {
66
- negative: boolean;
67
- magnitude: string;
68
- };
69
- timestamp: string;
70
- $typeName: string;
71
- $typeArgs: [];
72
- };
73
- static fromJSONField(field: any): Price;
74
- static fromJSON(json: Record<string, any>): Price;
75
- static fetch(client: SuiGrpcClient, id: string): Promise<Price>;
76
- }
@@ -1,127 +0,0 @@
1
- import { decodeFromFields, decodeFromFieldsWithTypes, decodeFromJSONField, phantom, } from "../../../../_framework/reified.js";
2
- import { composeSuiType, compressSuiType, } from "../../../../_framework/util.js";
3
- import { I64 } from "../i64/structs.js";
4
- import { PKG_V1 } from "../index.js";
5
- import { bcs } from "@mysten/sui/bcs";
6
- /* ============================== Price =============================== */
7
- export function isPrice(type) {
8
- type = compressSuiType(type);
9
- return type === `${PKG_V1}::price::Price`;
10
- }
11
- export class Price {
12
- __StructClass = true;
13
- static $typeName = `${PKG_V1}::price::Price`;
14
- static $numTypeParams = 0;
15
- static $isPhantom = [];
16
- $typeName = Price.$typeName;
17
- $fullTypeName;
18
- $typeArgs;
19
- $isPhantom = Price.$isPhantom;
20
- price;
21
- conf;
22
- expo;
23
- timestamp;
24
- constructor(typeArgs, fields) {
25
- this.$fullTypeName = composeSuiType(Price.$typeName, ...typeArgs);
26
- this.$typeArgs = typeArgs;
27
- this.price = fields.price;
28
- this.conf = fields.conf;
29
- this.expo = fields.expo;
30
- this.timestamp = fields.timestamp;
31
- }
32
- static reified() {
33
- return {
34
- typeName: Price.$typeName,
35
- fullTypeName: composeSuiType(Price.$typeName, ...[]),
36
- typeArgs: [],
37
- isPhantom: Price.$isPhantom,
38
- reifiedTypeArgs: [],
39
- fromFields: (fields) => Price.fromFields(fields),
40
- fromFieldsWithTypes: (item) => Price.fromFieldsWithTypes(item),
41
- fromBcs: (data) => Price.fromBcs(data),
42
- bcs: Price.bcs,
43
- fromJSONField: (field) => Price.fromJSONField(field),
44
- fromJSON: (json) => Price.fromJSON(json),
45
- fetch: async (client, id) => Price.fetch(client, id),
46
- new: (fields) => {
47
- return new Price([], fields);
48
- },
49
- kind: "StructClassReified",
50
- };
51
- }
52
- static get r() {
53
- return Price.reified();
54
- }
55
- static phantom() {
56
- return phantom(Price.reified());
57
- }
58
- static get p() {
59
- return Price.phantom();
60
- }
61
- static get bcs() {
62
- return bcs.struct("Price", {
63
- price: I64.bcs,
64
- conf: bcs.u64(),
65
- expo: I64.bcs,
66
- timestamp: bcs.u64(),
67
- });
68
- }
69
- static fromFields(fields) {
70
- return Price.reified().new({
71
- price: decodeFromFields(I64.reified(), fields.price),
72
- conf: decodeFromFields("u64", fields.conf),
73
- expo: decodeFromFields(I64.reified(), fields.expo),
74
- timestamp: decodeFromFields("u64", fields.timestamp),
75
- });
76
- }
77
- static fromFieldsWithTypes(item) {
78
- if (!isPrice(item.type)) {
79
- throw new Error("not a Price type");
80
- }
81
- return Price.reified().new({
82
- price: decodeFromFieldsWithTypes(I64.reified(), item.fields.price),
83
- conf: decodeFromFieldsWithTypes("u64", item.fields.conf),
84
- expo: decodeFromFieldsWithTypes(I64.reified(), item.fields.expo),
85
- timestamp: decodeFromFieldsWithTypes("u64", item.fields.timestamp),
86
- });
87
- }
88
- static fromBcs(data) {
89
- return Price.fromFields(Price.bcs.parse(data));
90
- }
91
- toJSONField() {
92
- return {
93
- price: this.price.toJSONField(),
94
- conf: this.conf.toString(),
95
- expo: this.expo.toJSONField(),
96
- timestamp: this.timestamp.toString(),
97
- };
98
- }
99
- toJSON() {
100
- return {
101
- $typeName: this.$typeName,
102
- $typeArgs: this.$typeArgs,
103
- ...this.toJSONField(),
104
- };
105
- }
106
- static fromJSONField(field) {
107
- return Price.reified().new({
108
- price: decodeFromJSONField(I64.reified(), field.price),
109
- conf: decodeFromJSONField("u64", field.conf),
110
- expo: decodeFromJSONField(I64.reified(), field.expo),
111
- timestamp: decodeFromJSONField("u64", field.timestamp),
112
- });
113
- }
114
- static fromJSON(json) {
115
- if (json.$typeName !== Price.$typeName) {
116
- throw new Error("not a WithTwoGenerics json object");
117
- }
118
- return Price.fromJSONField(json);
119
- }
120
- static async fetch(client, id) {
121
- const { object } = await client.getObject({ objectId: id, include: { content: true } });
122
- if (!isPrice(object.type)) {
123
- throw new Error(`object at id ${id} is not a Price object`);
124
- }
125
- return Price.fromBcs(object.content);
126
- }
127
- }