@suilend/sdk 12.3.0-next.g22670e4 → 12.3.0-next.gcbeb44e
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.d.ts +3 -11
- package/client.js +12 -20
- package/package.json +1 -1
package/client.d.ts
CHANGED
|
@@ -8,14 +8,6 @@ import { NewConfigArgs as CreateRateLimiterConfigArgs } from "./_generated/suile
|
|
|
8
8
|
import { CreateReserveConfigArgs } from "./_generated/suilend/reserve-config/functions";
|
|
9
9
|
import { type PriceUpdateDataSource } from "./lib/pyth";
|
|
10
10
|
import { Side } from "./lib/types";
|
|
11
|
-
/**
|
|
12
|
-
* Signed Pyth update data the caller already fetched for `priceIds`, posted
|
|
13
|
-
* unconditionally instead of the on-chain staleness check deciding.
|
|
14
|
-
*/
|
|
15
|
-
export interface PriceUpdate {
|
|
16
|
-
priceIds: string[];
|
|
17
|
-
updateData: Buffer[];
|
|
18
|
-
}
|
|
19
11
|
export declare function needsPriceRefresh(stalenessSeconds: number): boolean;
|
|
20
12
|
export declare const ADMIN_ADDRESS: string;
|
|
21
13
|
export declare const LENDING_MARKET_REGISTRY_ID: string;
|
|
@@ -107,7 +99,7 @@ export declare class SuilendClient {
|
|
|
107
99
|
updateRateLimiterConfig(lendingMarketOwnerCapId: string, transaction: Transaction, newRateLimiterConfigArgs: CreateRateLimiterConfigArgs): import("@mysten/sui/transactions").TransactionResult;
|
|
108
100
|
changeReservePriceFeed(lendingMarketOwnerCapId: string, coinType: string, pythPriceId: string, transaction: Transaction): Promise<import("@mysten/sui/transactions").TransactionResult>;
|
|
109
101
|
createObligation(transaction: Transaction): import("@mysten/sui/transactions").TransactionResult;
|
|
110
|
-
refreshAll(transaction: Transaction, obligation?: Obligation<string>, coinTypes?: string[]
|
|
102
|
+
refreshAll(transaction: Transaction, obligation?: Obligation<string>, coinTypes?: string[]): Promise<void>;
|
|
111
103
|
refreshReservePrices(transaction: Transaction, priceInfoObjectId: string, reserveArrayIndex: bigint): Promise<void>;
|
|
112
104
|
deposit(sendCoin: TransactionObjectInput, coinType: string, obligationOwnerCap: TransactionObjectInput, transaction: Transaction): void;
|
|
113
105
|
depositIntoObligation(ownerId: string, coinType: string, value: string, transaction: Transaction, obligationOwnerCap: TransactionObjectInput): Promise<void>;
|
|
@@ -119,8 +111,8 @@ export declare class SuilendClient {
|
|
|
119
111
|
borrowAndSendToUser(ownerId: string, obligationOwnerCap: TransactionObjectInput, obligationId: string, coinType: string, value: string, transaction: Transaction): Promise<void>;
|
|
120
112
|
repay(obligationId: string, coinType: string, coin: TransactionObjectInput, transaction: Transaction): import("@mysten/sui/transactions").TransactionResult;
|
|
121
113
|
repayIntoObligation(ownerId: string, obligationId: string, coinType: string, value: string, transaction: Transaction): Promise<import("@mysten/sui/transactions").TransactionResult>;
|
|
122
|
-
liquidateAndRedeem(transaction: Transaction, obligation: Obligation<string>, repayCoinType: string, withdrawCoinType: string, repayCoinId: TransactionObjectInput
|
|
123
|
-
liquidate(transaction: Transaction, obligation: Obligation<string>, repayCoinType: string, withdrawCoinType: string, repayCoinId: TransactionObjectInput
|
|
114
|
+
liquidateAndRedeem(transaction: Transaction, obligation: Obligation<string>, repayCoinType: string, withdrawCoinType: string, repayCoinId: TransactionObjectInput): Promise<import("@mysten/sui/transactions").TransactionResult>;
|
|
115
|
+
liquidate(transaction: Transaction, obligation: Obligation<string>, repayCoinType: string, withdrawCoinType: string, repayCoinId: TransactionObjectInput): Promise<import("@mysten/sui/transactions").TransactionResult>;
|
|
124
116
|
migrate(transaction: Transaction, lendingMarketOwnerCapId: string): import("@mysten/sui/transactions").TransactionResult;
|
|
125
117
|
claimFees(transaction: Transaction, coinType: string): import("@mysten/sui/transactions").TransactionResult;
|
|
126
118
|
setFeeReceiversAndWeights(transaction: Transaction, lendingMarketOwnerCapId: string, receivers: string[], weights: bigint[]): import("@mysten/sui/transactions").TransactionResult;
|
package/client.js
CHANGED
|
@@ -28,7 +28,6 @@ const isSui = (coinType) => normalizeStructTag(coinType) === NORMALIZED_SUI_COIN
|
|
|
28
28
|
// refresh would come from a package the contract does not accept.
|
|
29
29
|
const WORMHOLE_STATE_ID = "0xdbca52b9fb4f712e25f61f974586d93ac541bcf8389564f0323bb07215168b5c";
|
|
30
30
|
const PYTH_STATE_ID = "0x03719fae774ddab3cfcaa53bbc046f0cbe21410019b6280811bf3f9f4b05839d";
|
|
31
|
-
const normalizePriceIdentifier = (id) => id.toLowerCase().replace(/^0x/, "");
|
|
32
31
|
// Mirrors suilend::oracles's MAX_FORWARD_SECONDS (move/contracts/suilend/sources/oracles.move);
|
|
33
32
|
// `refresh_reserve_price` now rejects a forward-dated price the same as a stale one.
|
|
34
33
|
const MAX_FORWARD_SECONDS = 60;
|
|
@@ -476,7 +475,7 @@ export class SuilendClient {
|
|
|
476
475
|
typeArguments: this.lendingMarket.$typeArgs,
|
|
477
476
|
});
|
|
478
477
|
}
|
|
479
|
-
async refreshAll(transaction, obligation, coinTypes
|
|
478
|
+
async refreshAll(transaction, obligation, coinTypes) {
|
|
480
479
|
const reserveArrayIndexToPriceId = new Map();
|
|
481
480
|
if (obligation) {
|
|
482
481
|
obligation.deposits.forEach((deposit) => {
|
|
@@ -506,14 +505,8 @@ export class SuilendClient {
|
|
|
506
505
|
const priceInfoObjectId = await this.pythClient.getPriceFeedObjectId(priceIdentifiers[i]);
|
|
507
506
|
priceInfoObjectIds[i] = priceInfoObjectId;
|
|
508
507
|
})()));
|
|
509
|
-
const
|
|
510
|
-
|
|
511
|
-
await this.pythClient.updatePriceFeeds(transaction, priceUpdate.updateData, priceUpdate.priceIds);
|
|
512
|
-
}
|
|
513
|
-
const stalePriceIdentifiers = new Set();
|
|
514
|
-
await Promise.all(Object.entries(priceInfoObjectIds)
|
|
515
|
-
.filter(([i]) => !suppliedPriceIdentifiers.has(normalizePriceIdentifier(priceIdentifiers[+i])))
|
|
516
|
-
.map(([i, priceInfoObjectId]) => (async () => {
|
|
508
|
+
const stalePriceIdentifiers = [];
|
|
509
|
+
await Promise.all(Object.entries(priceInfoObjectIds).map(([i, priceInfoObjectId]) => (async () => {
|
|
517
510
|
// Read the field directly: the generated parser's type check is
|
|
518
511
|
// bound to one Pyth package address and would throw post-cutover.
|
|
519
512
|
const { object } = await this.suiGrpcClient.getObject({
|
|
@@ -523,16 +516,15 @@ export class SuilendClient {
|
|
|
523
516
|
const publishTime = priceInfoPublishTime(object.json, priceInfoObjectId);
|
|
524
517
|
const stalenessSeconds = Date.now() / 1000 - Number(publishTime);
|
|
525
518
|
if (needsPriceRefresh(stalenessSeconds)) {
|
|
526
|
-
stalePriceIdentifiers.
|
|
519
|
+
stalePriceIdentifiers.push(priceIdentifiers[+i]);
|
|
527
520
|
}
|
|
528
521
|
})()));
|
|
529
|
-
if (stalePriceIdentifiers.
|
|
530
|
-
const
|
|
531
|
-
|
|
532
|
-
await this.pythClient.updatePriceFeeds(transaction, stalePriceUpdateData, staleIds);
|
|
522
|
+
if (stalePriceIdentifiers.length > 0) {
|
|
523
|
+
const stalePriceUpdateData = await this.pythConnection.getPriceFeedsUpdateData(stalePriceIdentifiers);
|
|
524
|
+
await this.pythClient.updatePriceFeeds(transaction, stalePriceUpdateData, stalePriceIdentifiers);
|
|
533
525
|
}
|
|
534
526
|
for (let i = 0; i < reserveArrayIndexes.length; i++) {
|
|
535
|
-
|
|
527
|
+
this.refreshReservePrices(transaction, priceInfoObjectIds[i], reserveArrayIndexes[i]);
|
|
536
528
|
}
|
|
537
529
|
}
|
|
538
530
|
async refreshReservePrices(transaction, priceInfoObjectId, reserveArrayIndex) {
|
|
@@ -678,8 +670,8 @@ export class SuilendClient {
|
|
|
678
670
|
transaction.transferObjects([sendCoin], transaction.pure.address(ownerId));
|
|
679
671
|
return result;
|
|
680
672
|
}
|
|
681
|
-
async liquidateAndRedeem(transaction, obligation, repayCoinType, withdrawCoinType, repayCoinId
|
|
682
|
-
const [ctokens, exemption] = await this.liquidate(transaction, obligation, repayCoinType, withdrawCoinType, repayCoinId
|
|
673
|
+
async liquidateAndRedeem(transaction, obligation, repayCoinType, withdrawCoinType, repayCoinId) {
|
|
674
|
+
const [ctokens, exemption] = await this.liquidate(transaction, obligation, repayCoinType, withdrawCoinType, repayCoinId);
|
|
683
675
|
const [optionalExemption] = transaction.moveCall({
|
|
684
676
|
target: `0x1::option::some`,
|
|
685
677
|
typeArguments: [
|
|
@@ -689,8 +681,8 @@ export class SuilendClient {
|
|
|
689
681
|
});
|
|
690
682
|
return this.redeem(ctokens, withdrawCoinType, optionalExemption, transaction);
|
|
691
683
|
}
|
|
692
|
-
async liquidate(transaction, obligation, repayCoinType, withdrawCoinType, repayCoinId
|
|
693
|
-
await this.refreshAll(transaction, obligation
|
|
684
|
+
async liquidate(transaction, obligation, repayCoinType, withdrawCoinType, repayCoinId) {
|
|
685
|
+
await this.refreshAll(transaction, obligation);
|
|
694
686
|
return liquidate(transaction, [this.lendingMarket.$typeArgs[0], repayCoinType, withdrawCoinType], {
|
|
695
687
|
lendingMarket: transaction.object(this.lendingMarket.id),
|
|
696
688
|
obligationId: obligation.id,
|
package/package.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"name":"@suilend/sdk","version":"12.3.0-next.
|
|
1
|
+
{"name":"@suilend/sdk","version":"12.3.0-next.gcbeb44e","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.6.3","@cetusprotocol/aggregator-sdk":"1.7.2","@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.2","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.0","prettier":"3.9.6","ts-node":"10.9.2","typescript":"6.0.3","vite":"8.3.0","vitest":"5.0.0"},"peerDependencies":{"@mysten/bcs":"^2.1.1","@mysten/sui":">=2.22.1 <3","@suilend/sui-core":"^2.0.1"},"type":"module"}
|