import { SuiClientTypes } from "@mysten/sui/client"; import { SuiGrpcClient } from "@mysten/sui/grpc"; import { Transaction, TransactionArgument, TransactionObjectArgument, TransactionObjectInput } from "@mysten/sui/transactions"; import { SuiPythClient } from "@pythnetwork/pyth-sui-js"; import BigNumber from "bignumber.js"; import { Decimal } from "./_generated/suilend/decimal/structs"; import { type ConfidenceShare } from "./utils/simulate"; import { LendingMarket, ObligationOwnerCap } from "./_generated/suilend/lending-market/structs"; import { Obligation } from "./_generated/suilend/obligation/structs"; import { NewConfigArgs as CreateRateLimiterConfigArgs } from "./_generated/suilend/rate-limiter/functions"; import { CreateReserveConfigArgs } from "./_generated/suilend/reserve-config/functions"; import { type PriceUpdateDataSource } from "./lib/pyth"; import { Side } from "./lib/types"; /** * Signed Pyth update data the caller already fetched for `priceIds`, posted * unconditionally instead of the on-chain staleness check deciding. */ export interface PriceUpdate { priceIds: string[]; updateData: Buffer[]; } export declare function needsPriceRefresh(stalenessSeconds: number): boolean; export declare const ADMIN_ADDRESS = "0xb1ffbc2e1915f44b8f271a703becc1bf8aa79bc22431a58900a102892b783c25"; export declare function getStrategyWrapperPackageId(): string; export declare function setStrategyWrapperPackageId(packageId: string): void; export declare const LENDING_MARKET_REGISTRY_ID = "0x64faff8d91a56c4f55debbb44767b009ee744a70bc2cc8e3bbd2718c92f85931"; export declare const LENDING_MARKET_ID: string, LENDING_MARKET_TYPE: string; export declare const STEAMM_LM_LENDING_MARKET_ID: string, STEAMM_LM_LENDING_MARKET_TYPE: string; export declare function getLatestPackageId(suiGrpcClient: SuiGrpcClient, upgradeCapId: string): Promise; /** * Lists every owned object of `type`, following pagination. * * `object_type` matches all instantiations when the type params are omitted * (`0x2::coin::Coin` returns every `Coin`), so passing a bare struct type * lets one request serve callers that each only want their own type args. * Filter the result on `obj.type` — comparing via normalizeStructTag, since * the node returns fully-normalized addresses. */ export declare function listAllOwnedObjects(suiGrpcClient: SuiGrpcClient, owner: string, type: string, include?: Include): Promise[]>; export type ObligationWithUnclaimedRewards = { id: string; lendingMarketId?: string; unclaimedRewards: { rewardReserveArrayIndex: bigint; rewardIndex: bigint; rewardCoinType: string; side: Side; depositReserveArrayIndex: bigint; }[]; }; export type ClaimRewardsReward = { reserveArrayIndex: bigint; rewardIndex: bigint; rewardCoinType: string; side: Side; }; export type PatchReserveConfigArgs = Partial & { confidenceMultiplierBps?: bigint | TransactionArgument; minConfidenceRatio?: bigint | TransactionArgument; maxStalenessSeconds?: bigint | TransactionArgument; }; export type LendingMarketObject = { objectId: string; type: string; content: Uint8Array; }; export declare class SuilendClient { lendingMarket: LendingMarket; suiGrpcClient: SuiGrpcClient; pythClient: SuiPythClient; /** * The source of the signed update this client puts ON-CHAIN. * * Typed as the one-method `PriceUpdateDataSource` rather than the concrete * `SuiPriceServiceConnection` it used to be: a real connection still satisfies * it structurally, and the narrower type is what lets a caller inject an * authenticated or proxied source without reimplementing a pyth client. It * stays a public, reassignable field because consumers already assign it * directly — the indexer to reach its failover connection, the admin dialogs * to read update data for a reserve change. */ pythConnection: PriceUpdateDataSource; constructor(lendingMarket: LendingMarket, suiGrpcClient: SuiGrpcClient); static initialize(lendingMarketId: string, lendingMarketType: string, suiGrpcClient: SuiGrpcClient, logPackageId?: boolean): Promise; /** * Same as `initialize`, but fetches every LendingMarket object in one * request rather than one per market. */ static initializeAll(lendingMarkets: { id: string; type: string; }[], suiGrpcClient: SuiGrpcClient, logPackageId?: boolean): Promise; /** * Sets only the suilend package, to `publishedAt`, and leaves the * strategy_wrapper package as it was. Callers that build strategy * transactions must also call `setStrategyWrapperPackageId` with the * strategy_wrapper package for MAIN's lending market version. */ static initializeAllFromObjects(lendingMarkets: { id: string; type: string; }[], objects: readonly (LendingMarketObject | Error)[], publishedAt: string, suiGrpcClient: SuiGrpcClient, logPackageId?: boolean): SuilendClient[]; static getFeeReceivers(suiGrpcClient: SuiGrpcClient, lendingMarketId: string): Promise<{ receivers: string[]; weights: string[]; }>; /** A reserve's confidence multiplier `k`, in bps; pass `parsedReserve.config.additionalFields.id`. 0 when unset. */ static getReserveConfidenceMultiplierBps(suiGrpcClient: SuiGrpcClient, additionalFieldsBagId: string): Promise; /** A reserve's stored Pyth confidence as a share of the spot it was read with, `conf / spot` (the `ConfidenceKey` dynamic field on `reserve.id` directly, not inside `config.additionalFields`). Reads as 0 until the reserve's first price update writes it. */ static getReserveConfidenceShare(suiGrpcClient: SuiGrpcClient, reserveId: string): Promise; /** The raw spot and EMA of the reserve's last refresh under a price guard (the `RawPriceKey` dynamic field on `reserve.id`). Undefined until its first refresh under a guard. Attach them with `withUnclampedPrices` only to a reserve as stored on chain, never to one a feed refresh has repriced. */ static getReserveRawPrices(suiGrpcClient: SuiGrpcClient, reserveId: string): Promise<{ price: Decimal; smoothedPrice: Decimal; } | undefined>; static createNewLendingMarket(registryId: string, lendingMarketType: string, transaction: Transaction): { NestedResult: [number, number]; $kind: "NestedResult"; }; static getObligationOwnerCaps(ownerId: string, lendingMarketTypeArgs: string[], suiGrpcClient: SuiGrpcClient): Promise[]>; static getObligation(obligationId: string, lendingMarketTypeArgs: string[], suiGrpcClient: SuiGrpcClient): Promise>; static getObligations(obligationIds: string[], lendingMarketTypeArgs: string[], suiGrpcClient: SuiGrpcClient): Promise[]>; getObligation(obligationId: string): Promise>; static getLendingMarketOwnerCapId(ownerId: string, lendingMarketTypeArgs: string[], suiGrpcClient: SuiGrpcClient): Promise; getLendingMarketOwnerCapId(ownerId: string): Promise; createReserve(lendingMarketOwnerCapId: string, transaction: Transaction, pythPriceId: string, coinType: string, createReserveConfigArgs: CreateReserveConfigArgs, useV2?: boolean): Promise; addReward(ownerId: string, lendingMarketOwnerCapId: string, reserveArrayIndex: bigint, isDepositReward: boolean, rewardCoinType: string, rewardValue: string, startTimeMs: bigint, endTimeMs: bigint, transaction: Transaction, mergeCoins?: boolean): Promise; cancelReward(lendingMarketOwnerCapId: string, reserveArrayIndex: bigint, isDepositReward: boolean, rewardIndex: bigint, rewardCoinType: string, transaction: Transaction): import("@mysten/sui/transactions").TransactionResult; closeReward(lendingMarketOwnerCapId: string, reserveArrayIndex: bigint, isDepositReward: boolean, rewardIndex: bigint, rewardCoinType: string, transaction: Transaction): import("@mysten/sui/transactions").TransactionResult; claimReward(obligationOwnerCap: TransactionObjectInput, reserveArrayIndex: bigint, rewardIndex: bigint, rewardType: string, side: Side, transaction: Transaction): import("@mysten/sui/transactions").TransactionResult; claimRewardAndDeposit(obligationId: string, rewardReserveArrayIndex: bigint, rewardIndex: bigint, rewardCoinType: string, side: Side, depositReserveArrayIndex: bigint, transaction: Transaction): import("@mysten/sui/transactions").TransactionResult; claimRewards(ownerId: string, obligationOwnerCap: TransactionObjectInput, rewards: ClaimRewardsReward[], transaction: Transaction): { transaction: Transaction; mergedCoinsMap: Record; }; claimRewardsAndSendToUser(ownerId: string, obligationOwnerCap: TransactionObjectInput, rewards: ClaimRewardsReward[], transaction: Transaction): Transaction; claimRewardsAndDeposit(ownerId: string, obligationOwnerCap: TransactionObjectInput, rewards: ClaimRewardsReward[], transaction: Transaction): Transaction; findReserveArrayIndex(coinType: string): bigint; private submitReserveConfigUpdate; /** * From market version 8, sets every `CreateReserveConfigArgs` field on a * builder seeded from the reserve's live config, so `additionalFields` * entries (confidence multiplier, oracle thresholds, stable pause) keep * their current values: version 8 installs only `build` output. At version * 7 it replaces the whole config, which resets those entries. */ updateReserveConfig(lendingMarketOwnerCapId: string, transaction: Transaction, coinType: string, createReserveConfigArgs: CreateReserveConfigArgs): import("@mysten/sui/transactions").TransactionResult; /** * Updates a subset of a reserve's config fields, leaving every unspecified * field -- including `additionalFields` entries like the confidence * multiplier -- unchanged from the reserve's current on-chain value. */ patchReserveConfig(lendingMarketOwnerCapId: string, transaction: Transaction, coinType: string, overrides: PatchReserveConfigArgs): import("@mysten/sui/transactions").TransactionResult; newObligationOwnerCap(transaction: Transaction, lendingMarketOwnerCapId: string, destinationAddress: string, obligationId: string): void; updateRateLimiterConfig(lendingMarketOwnerCapId: string, transaction: Transaction, newRateLimiterConfigArgs: CreateRateLimiterConfigArgs): import("@mysten/sui/transactions").TransactionResult; changeReservePriceFeed(lendingMarketOwnerCapId: string, coinType: string, pythPriceId: string, transaction: Transaction): Promise; createObligation(transaction: Transaction): import("@mysten/sui/transactions").TransactionResult; refreshAll(transaction: Transaction, obligation?: Obligation, coinTypes?: string[], priceUpdate?: PriceUpdate): Promise; refreshReservePrices(transaction: Transaction, priceInfoObjectId: string, reserveArrayIndex: bigint): Promise; deposit(sendCoin: TransactionObjectInput, coinType: string, obligationOwnerCap: TransactionObjectInput, transaction: Transaction): void; depositIntoObligation(ownerId: string, coinType: string, value: string, transaction: Transaction, obligationOwnerCap: TransactionObjectInput): Promise; depositLiquidityAndGetCTokens(ownerId: string, coinType: string, value: string, transaction: Transaction): Promise; withdraw(obligationOwnerCap: TransactionObjectInput, obligationId: string, coinType: string, value: string, transaction: Transaction, addRefreshCalls?: boolean): Promise; redeem(ctokens: TransactionObjectInput, coinType: string, exemption: TransactionObjectInput, transaction: Transaction): import("@mysten/sui/transactions").TransactionResult; withdrawAndSendToUser(ownerId: string, obligationOwnerCap: TransactionObjectInput, obligationId: string, coinType: string, value: string, transaction: Transaction): Promise; borrow(obligationOwnerCap: TransactionObjectInput, obligationId: string, coinType: string, value: string, transaction: Transaction, addRefreshCalls?: boolean): Promise; borrowAndSendToUser(ownerId: string, obligationOwnerCap: TransactionObjectInput, obligationId: string, coinType: string, value: string, transaction: Transaction): Promise; repay(obligationId: string, coinType: string, coin: TransactionObjectInput, transaction: Transaction): import("@mysten/sui/transactions").TransactionResult; repayIntoObligation(ownerId: string, obligationId: string, coinType: string, value: string, transaction: Transaction): Promise; liquidateAndRedeem(transaction: Transaction, obligation: Obligation, repayCoinType: string, withdrawCoinType: string, repayCoinId: TransactionObjectInput, priceUpdate?: PriceUpdate): Promise; liquidate(transaction: Transaction, obligation: Obligation, repayCoinType: string, withdrawCoinType: string, repayCoinId: TransactionObjectInput, priceUpdate?: PriceUpdate): Promise; migrate(transaction: Transaction, lendingMarketOwnerCapId: string): import("@mysten/sui/transactions").TransactionResult; claimFees(transaction: Transaction, coinType: string): import("@mysten/sui/transactions").TransactionResult; setFeeReceiversAndWeights(transaction: Transaction, lendingMarketOwnerCapId: string, receivers: string[], weights: bigint[]): import("@mysten/sui/transactions").TransactionResult; redeemCtokensAndWithdrawLiquidity(ownerId: string, ctokenCoinTypes: string[], transaction: Transaction): Promise; }