> ## Documentation Index
> Fetch the complete documentation index at: https://docs.pulend.art/llms.txt
> Use this file to discover all available pages before exploring further.

# Smart Contracts

> Core protocol contracts and interfaces

## Overview

Pulend uses upgradeable proxy contracts built with OpenZeppelin and Foundry.

```mermaid theme={null}
flowchart TD
    R[Router] --> LP[LendingPool]
    LP --> IRM[InterestRateModel]
    LP --> PF[Pricefeed]
    LP --> IH[IsHealthy]
```

***

## LendingPool

The main contract managing collateral, borrowing, and liquidations.

**Address:** `0x01316834f5B709D5B5f5cc5691FD6AA71b232AD8` — [View on Arbiscan](https://sepolia.arbiscan.io/address/0x01316834f5B709D5B5f5cc5691FD6AA71b232AD8)

### User Functions

```solidity theme={null}
// Deposit NFT as collateral
function supplyCollateral(uint256 tokenId) external;

// Withdraw NFT (requires healthy position)
function withdrawCollateral(uint256 tokenId) external;

// Borrow tokens against collateral
function borrow(uint256 amount) external;

// Repay borrowed amount
function repay(uint256 amount) external;

// Supply liquidity to earn interest
function supplyLiquidity(uint256 amount) external;

// Withdraw supplied liquidity
function withdrawLiquidity(uint256 shares) external;
```

### View Functions

```solidity theme={null}
// Get user's collateral token IDs
function userCollateralTokenIds(address user) external view returns (uint256[]);

// Get user's borrow balance
function userBorrowAssets(address user) external view returns (uint256);

// Get user's supply shares
function userSupplyShares(address user) external view returns (uint256);

// Get total supply/borrow
function totalSupplyAssets() external view returns (uint256);
function totalBorrowAssets() external view returns (uint256);
```

### Events

| Event                | Description                 |
| -------------------- | --------------------------- |
| `SupplyCollateral`   | NFT deposited as collateral |
| `WithdrawCollateral` | NFT withdrawn               |
| `Borrow`             | Tokens borrowed             |
| `Repay`              | Loan repaid                 |
| `SupplyLiquidity`    | Liquidity supplied          |
| `WithdrawLiquidity`  | Liquidity withdrawn         |
| `Liquidation`        | Position liquidated         |

***

## InterestRateModel

Calculates dynamic interest rates based on utilization.

**Address:** `0x6C6311DF4aAd49262eDbC41ABFa828935BF9DbbB` — [View on Arbiscan](https://sepolia.arbiscan.io/address/0x6C6311DF4aAd49262eDbC41ABFa828935BF9DbbB)

```solidity theme={null}
function calculateBorrowRate(
    address lendingPool
) external view returns (uint256);

function calculateSupplyRate(
    address lendingPool
) external view returns (uint256);
```

***

## IsHealthy

Helper contract to check position health.

**Address:** `0x93890c2abA1434d3105652baaE9A37630e81b065` — [View on Arbiscan](https://sepolia.arbiscan.io/address/0x93890c2abA1434d3105652baaE9A37630e81b065)

```solidity theme={null}
function isHealthy(
    address user,
    address lendingPool
) external view returns (bool);
```

***

## Router

Entry point for batched operations.

**Address:** `0xe03ceC7a0cf54685a991FE0b000df7814D8aF8A6` — [View on Arbiscan](https://sepolia.arbiscan.io/address/0xe03ceC7a0cf54685a991FE0b000df7814D8aF8A6)

***

## ABIs

Contract ABIs are available in:

* **Frontend:** `frontend/lib/abis/`
* **Indexer:** `indexer/abis/`
