> For the complete documentation index, see [llms.txt](https://hypotheca.gitbook.io/hypotheca-docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://hypotheca.gitbook.io/hypotheca-docs/hypotheca/technology/uniswap-v4-hook.md).

# Uniswap v4 Hook

How Hypotheca's Uniswap v4 Hook enforces verification, asset, oracle, and LTV controls at the execution layer.

Verification only matters if it can be enforced.

Hypotheca uses a custom Uniswap v4 Hook to intercept borrow-related execution and apply verification and risk controls before liquidity is accessed. The Hook connects the verification architecture to actual pool execution.

### Role of the Hook

A borrower initiates a borrow-related pool interaction. The Hook intercepts the relevant execution path and evaluates whether the required conditions are satisfied.

It can allow the transaction to proceed or revert it when a required condition fails. The Hook enforces conditions defined by the broader Hypotheca architecture. It does not independently create every verification source.

```
Borrow Intent
        →
Hook Interception
        →
Verification Gate
        →
Asset Allowlist
        →
Oracle Status
        →
LTV Check
        →
Allow or Revert
        →
Borrow Execution
        →
Transaction Record
```

### Verification gate

The Hook sits after the borrower request and before successful borrow execution. It applies the complete borrowing decision:

```
Can_Borrow =
Valid_Identity
AND Current_Security_Report
AND Payment_Receipts_Exist
AND Asset_in_Allowlist
AND Oracle_Not_Paused
AND LTV_Within_Limits
```

When this condition evaluates to true, the borrow can proceed. When any required condition fails, the transaction is rejected.

The Hook applies borrowing conditions. The Hypotheca Credit Score is one part of the broader credit system and remains distinct from this execution decision.

### Hook lifecycle points

The whitepaper defines four Hook lifecycle points:

| Lifecycle point         | Role                                                                                                                                                                |
| ----------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `beforeSwap`            | Intercepts borrow-minted swaps and runs the verification gate before execution. Checks include verification layers, asset allowlist, oracle status, and LTV limits. |
| `afterSwap`             | Records successful borrow execution and its transaction hash.                                                                                                       |
| `beforeRemoveLiquidity` | Prevents liquidity removal that would breach applicable LTV conditions.                                                                                             |
| `afterRemoveLiquidity`  | Updates tracking after liquidation-related liquidity changes.                                                                                                       |

No other Hook permissions or callbacks are defined here.

### Borrow execution flow

The Hook provides an enforcement point within the borrow path:

```
Borrower
        →
pool.swap with borrow intent
        →
beforeSwap
        →
Identity Verification
        →
Security Verification
        →
Payment Verification
        →
Asset Allowlist
        →
Oracle Check
        →
LTV Check
        →
Allow or Revert
        →
afterSwap
        →
Record txHash
```

`beforeSwap` intercepts the borrow-minted swap and applies the gate. If the conditions pass, execution can continue. `afterSwap` records the successful execution and its transaction hash.

This makes verification enforceable at execution time. It does not rely only on off-chain screening or informational checks.

### Transaction tracking

Successful protocol actions are recorded with transaction hashes. Each major credit event can therefore be tied to an on-chain transaction, keeping credit history queryable and auditable.

**Borrow** records `agentId`, amount, asset, `txHash`, timestamp, and LTV.

**Repay** records `agentId`, amount, `txHash`, timestamp, and interest paid.

**Liquidation** records `agentId`, amount seized, `txHash`, timestamp, and trigger reason.

**Reputation Update** records `agentId`, score delta, `txHash`, and reason.

### Asset allowlist

The Hook does not allow arbitrary borrowing assets. Asset eligibility is a separate control from borrower verification.

| Asset                 | Contract                                     | Maximum LTV              | Oracle    |
| --------------------- | -------------------------------------------- | ------------------------ | --------- |
| USDG                  | `0x5fc5360D0400a0Fd4f2af552ADD042D716F1d168` | 75%                      | Chainlink |
| WETH                  | `0x0Bd7D308f8E1639FAb988df18A8011f41EAcAD73` | 70%                      | Chainlink |
| Official Stock Tokens | Governance-approved                          | 50%; parameters may vary | Custom    |

A borrower can pass identity, security, and payment checks while still failing because the requested asset is not allowlisted.

### Oracle controls

Oracle safeguards act as execution safety controls. Real-time feeds use Chainlink or an equivalent oracle source.

| Condition                           | Response           |
| ----------------------------------- | ------------------ |
| 5% deviation between oracle sources | Pause              |
| 15% price movement within one hour  | Global borrow halt |
| Feed stale for more than 60 minutes | Pause              |

These controls are distinct from credit scoring. They determine whether market conditions permit borrowing at the time of execution.

### LTV enforcement

The Hook checks that the requested borrowing position remains within the permitted LTV boundary.

* Minimum collateralization: **125%**
* Liquidation threshold: **110%**
* Liquidation bonus: **8%**
* Maximum borrow per agent: **5% of the pool**

Effective LTV also varies by credit tier:

| Tier     | Maximum effective LTV |
| -------- | --------------------- |
| Platinum | 82.5%                 |
| Gold     | 75%                   |
| Silver   | 63.75%                |
| Bronze   | 45%                   |
| Rejected | 0%                    |

Effective LTV must never exceed **90%**. Borrowers do not all receive the same effective LTV.

### Credit determines eligibility. The Hook enforces it.

{% hint style="info" %}
The credit system determines eligibility. The Uniswap v4 Hook allows or rejects the borrow at execution.
{% endhint %}

The credit system evaluates required identity, security, payment, asset, oracle, and LTV conditions. The Hook provides the execution-level mechanism that enforces their outcome.

### Failure path

Failure is an explicit part of the execution architecture:

```
Invalid identity                    → Reject
Expired security report             → Reject
Insufficient verified payment history → Reject
Asset not allowlisted               → Reject
Oracle paused                       → Reject
LTV exceeds limit                   → Reject
```

The Hook rejects the borrowing action when a required condition is not satisfied.

### Technical reference

* **Network:** Robinhood Chain
* **Chain ID:** `4663`
* **Gas token:** ETH
* **Hypotheca v4 Hook:** TBD, Phase 4
* **Hypotheca Credit Gate:** TBD, Phase 4

Deployment addresses for the Hook and Credit Gate are not defined.


---

# 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://hypotheca.gitbook.io/hypotheca-docs/hypotheca/technology/uniswap-v4-hook.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.
