> For the complete documentation index, see [llms.txt](https://document.sunprotocol.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://document.sunprotocol.io/zhi-neng-he-yue/jie-dai-he-yue.md).

# 借贷合约

借贷合约支持 USDT 出借报价、抵押 Bond/质押订单发起借款、撮合、还款与到期接管抵押品。

### 查询自己的记录

| 函数                                       | 返回                  |
| ---------------------------------------- | ------------------- |
| `getUserLendOffersByPage(user,page)`     | 用户发布的出借报价           |
| `getUserBorrowRequestsByPage(user,page)` | 用户发布的借款请求           |
| `getUserLenderLoansByPage(user,page)`    | 用户作为出借人的贷款          |
| `getUserBorrowerLoansByPage(user,page)`  | 用户作为借款人的贷款          |
| `getUserLoanIds(user)`                   | 用户作为出借人和借款人的全部贷款 ID |
| `getuserOrderByPage(user,page)`          | 当前可用于抵押的订单及其价值      |
| `getLoanDetail(loanId)`                  | 贷款详情和对应抵押订单         |

页码从 `1` 开始，每页 `20` 条。市场列表可使用 `getActiveLendOffersByPage`、`getActiveBorrowRequestsByPage` 和 `getActiveLoansByPage`。

### 状态值

* 出借报价：`1` 活跃、`2` 已撮合完、`3` 已取消。
* 借款请求：`1` 活跃、`2` 已撮合、`3` 已取消。
* 贷款：`1` 进行中、`2` 已还款、`3` 抵押品已被接管。

### 报价函数

| 函数                                                | 用途             |
| ------------------------------------------------- | -------------- |
| `quoteInterest(amount,dailyRateBps,durationDays)` | 计算总利息          |
| `quoteCollateralValue(collateralOrderId)`         | 查询抵押订单 USDT 价值 |
| `maxBorrowableByCollateral(collateralOrderId)`    | 查询该订单最多可借 USDT |

费率分母为 `1,000,000`。源码限制 `dailyRateBps` 为 0.1%–1.3%、`durationDays` 参数为 7–90、最高 LTV 为 70%。实际到期时间按 `durationDays × baseDuration()` 计算；当前源码把 `baseDuration` 初始化为 1 分钟，因此不要只根据参数名称把它理解为自然日，应读取 `baseDuration()`、贷款的 `dueTime` 和 `takeoverTime` 后再操作。

### 用户写入函数

* 出借人：`createLendOffer`、`cancelLendOffer`、`lendToRequest`。
* 借款人：`createBorrowRequest`、`cancelBorrowRequest`、`borrowFromOffer`、`repay`。
* 逾期处理：满足到期和宽限期条件后，出借人可调用 `takeOverCollateral`。


---

# 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 by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://document.sunprotocol.io/zhi-neng-he-yue/jie-dai-he-yue.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

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.
