# Loan Endpoints

## **Contract Name**

* ApproveTrade

## **Mainnet Addresses**

<table data-header-hidden><thead><tr><th width="142"></th><th></th></tr></thead><tbody><tr><td><strong>Network</strong></td><td><strong>Contract Address</strong></td></tr><tr><td>Arbitrum</td><td><code>0x4d5797F05992c9E81c64a39CEe5A8BA56df8D38e</code></td></tr><tr><td>Base</td><td><code>0x54A70516e9c0223F4a92bE3a4832a06f546e783B</code></td></tr><tr><td>Ethereum</td><td><code>0x54A70516e9c0223F4a92bE3a4832a06f546e783B</code></td></tr><tr><td>Polygon</td><td><code>0x4d5797F05992c9E81c64a39CEe5A8BA56df8D38e</code></td></tr><tr><td>Bitlayer</td><td><code>0x54A70516e9c0223F4a92bE3a4832a06f546e783B</code></td></tr><tr><td>BSC</td><td><code>0x83541A6B4A5c5512624CcbF35E9c77290f4068C0</code></td></tr><tr><td>Apechain</td><td>0x9688B0965885ca8Db34f3C7187A3D0eD4E633852</td></tr></tbody></table>

***

## **Smart Contract Interface**

### **1. Get the Nonce of the User's Order**

Fetch the nonce of the order created by the user.

* **Function**: `nonces(address maker) returns (uint256)`

#### Request Parameter

| **Parameter Name** | **Required** | **Type**  | **Description** |
| ------------------ | ------------ | --------- | --------------- |
| `maker`            | Yes          | `address` | Creator Address |

#### Response Parameter

| **Parameter Name** | **Type**  | **Description**  |
| ------------------ | --------- | ---------------- |
| `nonce`            | `uint256` | User order nonce |

***

### **2. Calculate the Hash of the Order**

Calculate the hash of an order, required when creating the order.

* **Function**: `hashOrder(Order memory order) returns (bytes32)`

#### Request Parameter

| **Parameter Name** | **Required** | **Type** | **Description** |
| ------------------ | ------------ | -------- | --------------- |
| `order`            | Yes          | `Order`  | Order details   |

#### Response Parameter

| **Parameter Name** | **Type**  | **Description** |
| ------------------ | --------- | --------------- |
| `orderHash`        | `bytes32` | User order hash |

***

### **3. Lend Funds Using the Signed Order Information**

Use the borrower's signed order to lend funds.

* **Function**: `loan(Order memory loanOrder)`

#### Request Parameter

| **Parameter Name** | **Required** | **Type** | **Description**                              |
| ------------------ | ------------ | -------- | -------------------------------------------- |
| `loanOrder`        | Yes          | `Order`  | Order information from centralized interface |

#### Order Structure

| **Parameter Name**  | **Required** | **Type**  | **Description**                               |
| ------------------- | ------------ | --------- | --------------------------------------------- |
| `maker`             | Yes          | `address` | Borrower Address                              |
| `taker`             | Yes          | `address` | Lender address (use 0 address)                |
| `asset`             | Yes          | `Asset[]` | List of collateral assets                     |
| `currency`          | Yes          | `address` | Funding token address                         |
| `price`             | Yes          | `uint256` | Loan amount                                   |
| `deadline`          | Yes          | `uint256` | Fundraising deadline                          |
| `duration`          | Yes          | `uint256` | Loan duration                                 |
| `interestPerSecond` | Yes          | `uint256` | Interest accrued per second after loan        |
| `endTime`           | Yes          | `uint256` | Redemption deadline (use 0 if not applicable) |
| `themselves`        | Yes          | `bytes`   | Signed transaction data                       |

***

### **4. Repay Principal and Interest to Redeem Asset**

Allows the borrower to repay the principal and interest to reclaim the collateral.

* **Function**: `redeem(bytes32 orderHash)`

#### Request Parameter

| **Parameter Name** | **Required** | **Type**  | **Description**             |
| ------------------ | ------------ | --------- | --------------------------- |
| `orderHash`        | Yes          | `bytes32` | Order hash (from interface) |

***

### **5. Liquidate Overdue Orders**

Allows the lender to liquidate an overdue order and claim the collateral.

* **Function**: `liquidate(bytes32 orderHash)`

#### Request Parameter

| **Parameter Name** | **Required** | **Type**  | **Description**             |
| ------------------ | ------------ | --------- | --------------------------- |
| `orderHash`        | Yes          | `bytes32` | Order hash (from interface) |

***

### **6. Cancel Order**

Allows the creator to cancel an order.

* **Function**: `cancelOrder(Order memory order)`

#### Request Parameter

| **Parameter Name** | **Required** | **Type** | **Description**                              |
| ------------------ | ------------ | -------- | -------------------------------------------- |
| `order`            | Yes          | `Order`  | Order information from centralized interface |

***

### **7. Cancel Multiple Orders**

Allows the creator to cancel multiple orders in one call.

* **Function**: `cancelMultipleOrders(Order[] memory orders)`

#### Request Parameter

| **Parameter Name** | **Required** | **Type**  | **Description**                            |
| ------------------ | ------------ | --------- | ------------------------------------------ |
| `orders`           | Yes          | `Order[]` | List of order information (from interface) |

***

### **8. Cancel All Orders**

Allows the creator to cancel all orders they have created.

* **Function**: `cancelAllOrders()`

#### Request Parameters

This function does not take any parameters.

***

### **9. Buy Assets Using Signed Order**

Allows a buyer to purchase assets using the seller's signed order.

* **Function**: `buy(Order memory sellOrder)`

#### Request Parameter

| **Parameter Name** | **Required** | **Type** | **Description**                              |
| ------------------ | ------------ | -------- | -------------------------------------------- |
| `sellOrder`        | Yes          | `Order`  | Order information from centralized interface |

***

### **10. Sell Assets Using Buyer's Signed Order**

Allows a seller to sell assets using the buyer's signed order.

* **Function**: `sell(Order memory buyOrder)`

#### Request Parameter

| **Parameter Name** | **Required** | **Type** | **Description**                              |
| ------------------ | ------------ | -------- | -------------------------------------------- |
| `buyOrder`         | Yes          | `Order`  | Order information from centralized interface |

***

### **11. Get Platform Loan Fee Rate**

Returns the platform commission ratio for loans.

* **Function**: `feeRate() returns (uint256)`

#### Response Parameter

| **Parameter Name** | **Type**  | **Description**                              |
| ------------------ | --------- | -------------------------------------------- |
| `feeRate`          | `uint256` | Platform commission ratio (divide by 10,000) |

***

### **12. Get Platform Repayment Interest Fee Rate**

Returns the platform commission rate for repayment interest.

* **Function**: `interestFeeRate() returns (uint256)`

#### Response Parameter

| **Parameter Name** | **Type**  | **Description**                              |
| ------------------ | --------- | -------------------------------------------- |
| `interestFeeRate`  | `uint256` | Interest commission ratio (divide by 10,000) |

***

### **13. Get Minimum Repayment Interest Ratio**

Returns the minimum interest rate for repayment.

* **Function**: `interestFeeRate() returns (uint256)`

#### Response Parameter

| **Parameter Name** | **Type**  | **Description**                          |
| ------------------ | --------- | ---------------------------------------- |
| `interestFeeRate`  | `uint256` | Minimum interest rate (divide by 10,000) |


---

# Agent Instructions: 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:

```
GET https://docs.paddlefi.com/api-documentation/loan-endpoints.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
