> For the complete documentation index, see [llms.txt](https://docs.suilend.fi/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.suilend.fi/ecosystem/suilend-sdk-guide/suilend-sdk-types-reference.md).

# Suilend SDK Types Reference

This document provides a comprehensive reference for all types, interfaces, and enums used in the Suilend SDK.

## Table of Contents

* \[Core Enums]
* \[Client Types]
* \[Configuration Types]
* \[Event Types]
* \[Reward Types]
* \[Generated Types]
* \[Utility Types]

## Core Enums

### Side

Represents the side of a lending operation for rewards and positions.

```typescript
enum Side {
  DEPOSIT = "deposit",
  BORROW = "borrow",
}
```

**Usage:**

```typescript
import { Side } from "@suilend/sdk";

const reward = {
  reserveArrayIndex: 0n,
  rewardIndex: 0n,
  rewardCoinType: "0x2::sui::SUI",
  side: Side.DEPOSIT, // or Side.BORROW
};
```

### Action

Represents different types of lending actions.

```typescript
enum Action {
  DEPOSIT = "deposit",
  WITHDRAW = "withdraw",
  BORROW = "borrow",
  REPAY = "repay",
}
```

## Client Types

### UiLendingMarket

Represents a lending market configuration for UI purposes.

```typescript
interface UiLendingMarket {
  name: string; // Human-readable name
  slug: string; // URL-friendly identifier
  id: string; // On-chain object ID
  type: string; // Type signature for the market
  ownerCapId: string; // Owner capability object ID
  isHidden?: boolean; // Whether to hide in UI
}
```

**Example:**

```typescript
const mainMarket: UiLendingMarket = {
  name: "Main market",
  slug: "main",
  id: "0x84030d26d85eaa7035084a057f2f11f701b7e2e4eda87551becbc7c97505ece1",
  type: "0xf95b06141ed4a174f239417323bde3f209b972f5930d8521ea38a52aff3a6ddf::suilend::MAIN_POOL",
  ownerCapId: "0xf7a4defe0b6566b6a2674a02a0c61c9f99bd012eed21bc741a069eaa82d35927",
};
```

### ObligationWithUnclaimedRewards

Represents an obligation with associated unclaimed rewards.

```typescript
interface ObligationWithUnclaimedRewards {
  id: string;
  unclaimedRewards: {
    rewardReserveArrayIndex: bigint;
    rewardIndex: bigint;
    rewardCoinType: string;
    side: Side;
    depositReserveArrayIndex: bigint;
  }[];
}
```

## Configuration Types

### CreateReserveConfigArgs

Configuration parameters for creating a new reserve.

```typescript
interface CreateReserveConfigArgs {
  // Loan-to-Value ratios (percentages)
  openLtvPct: number; // LTV for opening positions
  closeLtvPct: number; // LTV for closing positions
  maxCloseLtvPct: number; // Maximum LTV before liquidation

  // Weight and limits
  borrowWeightBps: number; // Borrow weight in basis points
  depositLimitUsd: number; // Maximum deposit limit in USD
  borrowLimitUsd: number; // Maximum borrow limit in USD
  minBorrowLimitUsd: number; // Minimum borrow limit in USD

  // Liquidation parameters
  liquidationBonusBps: number; // Liquidation bonus in basis points
  maxLiquidationBonusBps: number; // Maximum liquidation bonus
  badDebtLiquidationBonusBps: number; // Bad debt liquidation bonus

  // Asset isolation
  isolatedAsset: boolean; // Whether asset is isolated

  // Attributed borrow limits
  openAttributedBorrowLimitUsd: number; // Open attributed borrow limit
  closeAttributedBorrowLimitUsd: number; // Close attributed borrow limit
}
```

**Example:**

```typescript
const reserveConfig: CreateReserveConfigArgs = {
  openLtvPct: 70,
  closeLtvPct: 75,
  maxCloseLtvPct: 80,
  borrowWeightBps: 11000,
  depositLimitUsd: 10000000,
  borrowLimitUsd: 5000000,
  liquidationBonusBps: 500,
  maxLiquidationBonusBps: 1000,
  badDebtLiquidationBonusBps: 2000,
  minBorrowLimitUsd: 100,
  isolatedAsset: false,
  openAttributedBorrowLimitUsd: 1000000,
  closeAttributedBorrowLimitUsd: 500000,
};
```

### CreateRateLimiterConfigArgs

Configuration for rate limiting functionality.

```typescript
interface CreateRateLimiterConfigArgs {
  windowDurationMs: bigint; // Time window in milliseconds
  maxOutflowPct: number; // Maximum outflow percentage
}
```

## Event Types

### ApiReserveAssetDataEvent

Event data for reserve asset updates.

```typescript
interface ApiReserveAssetDataEvent {
  id: number;
  lendingMarketId: string;
  coinType: string;
  reserveId: string;

  // Amounts
  availableAmount: string;
  supplyAmount: string;
  borrowedAmount: string;

  // USD estimates
  availableAmountUsdEstimate: string;
  supplyAmountUsdEstimate: string;
  borrowedAmountUsdEstimate: string;

  // Interest rates
  borrowApr: string;
  supplyApr: string;

  // Token data
  ctokenSupply: string;
  cumulativeBorrowRate: string;

  // Price data
  price: string;
  smoothedPrice: string;
  priceLastUpdateTimestampS: number;

  // Event metadata
  timestamp: number;
  digest: string;
  eventIndex: number;
  sender: string;
}
```

### ApiDepositEvent

Event data for deposit operations.

```typescript
interface ApiDepositEvent {
  id: number;
  lendingMarketId: string;
  coinType: string;
  reserveId: string;
  obligationId: string;
  ctokenAmount: string;
  timestamp: number;
  digest: string;
  eventIndex: number;
  sender: string;
}
```

### ApiWithdrawEvent

Event data for withdrawal operations.

```typescript
interface ApiWithdrawEvent {
  id: number;
  lendingMarketId: string;
  coinType: string;
  reserveId: string;
  obligationId: string;
  ctokenAmount: string;
  timestamp: number;
  digest: string;
  eventIndex: number;
  sender: string;
}
```

### ApiBorrowEvent

Event data for borrow operations.

```typescript
interface ApiBorrowEvent {
  id: number;
  lendingMarketId: string;
  coinType: string;
  reserveId: string;
  obligationId: string;
  liquidityAmount: string;
  originationFeeAmount: string;
  timestamp: number;
  digest: string;
  eventIndex: number;
  sender: string;
}
```

### ApiRepayEvent

Event data for repay operations.

```typescript
interface ApiRepayEvent {
  id: number;
  lendingMarketId: string;
  coinType: string;
  reserveId: string;
  obligationId: string;
  liquidityAmount: string;
  timestamp: number;
  digest: string;
  eventIndex: number;
  sender: string;
}
```

### ApiLiquidateEvent

Event data for liquidation operations.

```typescript
interface ApiLiquidateEvent {
  id: number;
  lendingMarketId: string;
  repayReserveId: string;
  withdrawReserveId: string;
  obligationId: string;
  repayAmount: string;
  withdrawAmount: string;
  protocolFeeAmount: string;
  liquidatorBonusAmount: string;
  timestamp: number;
  digest: string;
  eventIndex: number;
  sender: string;
}
```

### ApiInterestUpdateEvent

Event data for interest rate updates.

```typescript
interface ApiInterestUpdateEvent {
  id: number;
  lendingMarketId: string;
  coinType: string;
  reserveId: string;
  cumulativeBorrowRate: string;
  availableAmount: string;
  borrowedAmount: string;
  unclaimedSpreadFees: string;
  ctokenSupply: string;
  borrowInterestPaid: string;
  spreadFee: string;
  supplyInterestEarned: string;
  borrowInterestPaidUsdEstimate: string;
  protocolFeeUsdEstimate: string;
  supplyInterestEarnedUsdEstimate: string;
  timestamp: number;
  digest: string;
  eventIndex: number;
  sender: string;
}
```

### ApiObligationDataEvent

Event data for obligation state updates.

```typescript
interface ApiObligationDataEvent {
  id: number;
  lendingMarketId: string;
  obligationId: string;

  // Value calculations
  depositedValueUsd: string;
  allowedBorrowValueUsd: string;
  unhealthyBorrowValueUsd: string;
  superUnhealthyBorrowValueUsd: string;
  unweightedBorrowedValueUsd: string;
  weightedBorrowedValueUsd: string;
  weightedBorrowedValueUpperBoundUsd: string;

  // Status flags
  borrowingIsolatedAsset: boolean;
  badDebtUsd: string;
  closable: boolean;

  // JSON data (stringified objects)
  depositsJson: string; // Array of deposit data
  borrowsJson: string; // Array of borrow data

  // Event metadata
  timestamp: number;
  digest: string;
  eventIndex: number;
  sender: string;
}
```

## Reward Types

### ClaimRewardsReward

Specification for claiming a specific reward.

```typescript
interface ClaimRewardsReward {
  reserveArrayIndex: bigint; // Index of the reserve
  rewardIndex: bigint; // Index of the reward program
  rewardCoinType: string; // Type of reward token
  side: Side; // DEPOSIT or BORROW side
}
```

**Example:**

```typescript
const rewards: ClaimRewardsReward[] = [
  {
    reserveArrayIndex: 0n, // SUI reserve
    rewardIndex: 0n, // First reward program
    rewardCoinType: "0x2::sui::SUI",
    side: Side.DEPOSIT,
  },
  {
    reserveArrayIndex: 1n, // USDC reserve
    rewardIndex: 0n,
    rewardCoinType: "0x2::sui::SUI",
    side: Side.BORROW,
  },
];
```

### ApiClaimRewardEvent

Event data for reward claims.

```typescript
interface ApiClaimRewardEvent {
  id: number;
  lendingMarketId: string;
  reserveId: string;
  obligationId: string;
  isDepositReward: boolean;
  poolRewardId: string;
  coinType: string;
  liquidityAmount: string;
  timestamp: number;
  digest: string;
  eventIndex: number;
  sender: string;
}
```

### ApiMintEvent

Event data for cToken minting (when depositing to reserves).

```typescript
interface ApiMintEvent {
  id: number;
  lendingMarketId: string;
  coinType: string;
  reserveId: string;
  liquidityAmount: string;
  ctokenAmount: string;
  timestamp: number;
  digest: string;
  eventIndex: number;
  sender: string;
}
```

### ApiRedeemEvent

Event data for cToken redemption (when withdrawing from reserves).

```typescript
interface ApiRedeemEvent {
  id: number;
  lendingMarketId: string;
  coinType: string;
  reserveId: string;
  ctokenAmount: string;
  liquidityAmount: string;
  timestamp: number;
  digest: string;
  eventIndex: number;
  sender: string;
}
```

## Generated Types

The SDK includes many generated types from on-chain smart contracts. These are located in the `_generated` directory.

### Key Generated Interfaces

#### LendingMarket

```typescript
interface LendingMarket<T> {
  id: string;
  reserves: Reserve<T>[];
  // ... additional fields from on-chain struct
}
```

#### Obligation

```typescript
interface Obligation<T> {
  id: string;
  lendingMarketId: string;
  deposits: DepositInfo[];
  borrows: BorrowInfo[];
  // ... additional fields from on-chain struct
}
```

#### ObligationOwnerCap

```typescript
interface ObligationOwnerCap<T> {
  id: string;
  obligationId: string;
  // ... additional fields from on-chain struct
}
```

#### Reserve

```typescript
interface Reserve<T> {
  id: string;
  coinType: string;
  config: ReserveConfig;
  // ... additional fields from on-chain struct
}
```

#### FeeReceivers

```typescript
interface FeeReceivers<T> {
  receivers: string[];
  weights: bigint[];
  // ... additional fields from on-chain struct
}
```

## Utility Types

### DownsampledApiReserveAssetDataEvent

Extended reserve asset data with sampling information.

```typescript
type DownsampledApiReserveAssetDataEvent = ApiReserveAssetDataEvent & {
  sampletimestamp: number;
};
```

### Transaction Types

These are re-exported from `@mysten/sui`:

```typescript
// From @mysten/sui/transactions
type TransactionObjectInput =
  | string
  | { digest: string; objectId: string; version: string };

type TransactionObjectArgument =
  | { kind: "Input"; index: number }
  | { kind: "Result"; index: number };

type TransactionResult = { kind: "Result"; index: number };
```

## Constants

### Precision Constants

```typescript
// From lib/constants.ts
const WAD: BigNumber; // 10^18 for decimal precision
const msPerYear: number; // Milliseconds per year
```

### Market Constants

```typescript
// Available lending markets
const LENDING_MARKETS: UiLendingMarket[];

// Default market (main market)
const LENDING_MARKET_ID: string;
const LENDING_MARKET_TYPE: string;

// Registry and admin
const LENDING_MARKET_REGISTRY_ID: string;
const ADMIN_ADDRESS: string;

// Package information
const PACKAGE_ID: string;
const PUBLISHED_AT: string;
```

## Type Guards and Utilities

### Common Type Checks

```typescript
// Check if a coin type is SUI
function isSui(coinType: string): boolean {
  const NORMALIZED_SUI_COINTYPE = normalizeStructTag("0x2::sui::SUI");
  return normalizeStructTag(coinType) === NORMALIZED_SUI_COINTYPE;
}

// Normalize coin type for comparison
function normalizeStructTag(coinType: string): string {
  // Implementation from @mysten/sui
}
```

### Working with BigInt

Many amounts in the SDK are represented as `bigint` or string representations of large numbers:

```typescript
// Converting between string and bigint
const amount = "1000000000"; // 1 SUI in MIST
const amountBigInt = BigInt(amount);
const backToString = amountBigInt.toString();

// Using with reserves
const reserveIndex = 0n; // Note the 'n' suffix for bigint literals
```

### Example Type Usage

```typescript
import {
  SuilendClient,
  Side,
  ClaimRewardsReward,
  CreateReserveConfigArgs,
  LENDING_MARKET_ID,
} from "@suilend/sdk";
import { SuiClient } from "@mysten/sui/client";
import { Transaction } from "@mysten/sui/transactions";

async function exampleWithTypes() {
  const suiClient = new SuiClient({ url: "https://fullnode.mainnet.sui.io" });
  const suilendClient = await SuilendClient.initialize(
    LENDING_MARKET_ID,
    suiClient
  );

  // Using ClaimRewardsReward type
  const rewards: ClaimRewardsReward[] = [
    {
      reserveArrayIndex: 0n,
      rewardIndex: 0n,
      rewardCoinType: "0x2::sui::SUI",
      side: Side.DEPOSIT,
    },
  ];

  // Using Transaction type
  const transaction = new Transaction();

  // Call with properly typed parameters
  suilendClient.claimRewards(
    userAddress, // string
    obligationCapId, // string
    rewards, // ClaimRewardsReward[]
    transaction // Transaction
  );
}
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.suilend.fi/ecosystem/suilend-sdk-guide/suilend-sdk-types-reference.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
