# revert-finance/v4lend architecture

> Architecture diagram of the GitHub repository revert-finance/v4lend, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-15). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/revert-finance/v4lend
- Repository: https://github.com/revert-finance/v4lend

## Overview

Revert v4lend finances Uniswap v4 LP positions and manages them through swap-triggered or operator-driven automation. The main user flow is lending assets into the vault, borrowing against LP collateral, and using hook automation or a transformer to manage positions; the oracle supplies position valuations. The README documents auction and lease fee mechanisms as alternatives. No source excerpts were provided, so edges below are limited to relationships explicitly described in the README; unsampled internals are represented at their documented module paths.

Main entry points: [`src/vault/V4Vault.sol`](https://github.com/revert-finance/v4lend/blob/main/src/vault/V4Vault.sol) (Lending vault), [`src/RevertHook.sol`](https://github.com/revert-finance/v4lend/blob/main/src/RevertHook.sol) (Hook entrypoint), [`src/hook/RevertHookCallbacks.sol`](https://github.com/revert-finance/v4lend/blob/main/src/hook/RevertHookCallbacks.sol) (Swap callbacks), [`src/hook/RevertHookExecution.sol`](https://github.com/revert-finance/v4lend/blob/main/src/hook/RevertHookExecution.sol) (Hook execution)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_lending["Lending and valuation"]
  node_vault[("Lending vault<br/>[V4Vault.sol]")]
  node_oracle["Position oracle<br/>[V4Oracle.sol]"]
  node_liquidation["Liquidation helpers"]
  node_transformers["Vault transformers"]
end

subgraph group_hook["Hook automation"]
  node_hookentry["Hook entrypoint<br/>[RevertHook.sol]"]
  node_callbacks["Swap callbacks"]
  node_execution["Hook execution"]
  node_triggers["Automation triggers"]
end

subgraph group_fees["Fee mechanisms"]
  node_auction["Epoch auction"]
  node_lease["Harberger lease"]
  node_registry["Executor registry"]
end

subgraph group_automation["Position automation"]
  node_autoexit["Auto exit<br/>[AutoExit.sol]"]
  node_autorange["Auto range<br/>[AutoRange.sol]"]
  node_autolend["Auto lend<br/>[AutoLend.sol]"]
  node_autoleverage["Auto leverage<br/>[AutoLeverage.sol]"]
  node_autocollect["Auto collect<br/>[AutoCollect.sol]"]
end

subgraph group_shared["Position tools"]
  node_planning["Planning utilities"]
  node_swapper["Swap utilities<br/>[Swapper.sol]"]
end

node_lenders(("Lenders"))
node_borrowers(("Borrowers"))
node_operators(("Operators"))
node_pool["Uniswap v4 pool"]

node_lenders -->|"deposit assets"| node_vault
node_borrowers -->|"borrow against collateral"| node_vault
node_vault -.->|"values LP positions"| node_oracle
node_vault -->|"liquidation support"| node_liquidation
node_vault -->|"manages collateral"| node_transformers
node_pool -->|"swap callbacks"| node_hookentry
node_hookentry -->|"handles callbacks"| node_callbacks
node_callbacks -.->|"checks triggers"| node_triggers
node_callbacks -.->|"executes automation"| node_execution
node_hookentry -->|"calls controller"| node_auction
node_hookentry -->|"alternative controller"| node_lease
node_operators -->|"runs strategy"| node_autoexit
node_operators -->|"runs strategy"| node_autorange
node_operators -->|"runs strategy"| node_autolend
node_operators -->|"runs strategy"| node_autoleverage
node_operators -->|"runs strategy"| node_autocollect
node_execution -.->|"uses planning"| node_planning
node_execution -.->|"uses swaps"| node_swapper

click node_vault "https://github.com/revert-finance/v4lend/blob/main/src/vault/V4Vault.sol"
click node_oracle "https://github.com/revert-finance/v4lend/blob/main/src/oracle/V4Oracle.sol"
click node_liquidation "https://github.com/revert-finance/v4lend/tree/main/src/vault/liquidation"
click node_transformers "https://github.com/revert-finance/v4lend/tree/main/src/vault/transformers"
click node_hookentry "https://github.com/revert-finance/v4lend/blob/main/src/RevertHook.sol"
click node_callbacks "https://github.com/revert-finance/v4lend/blob/main/src/hook/RevertHookCallbacks.sol"
click node_execution "https://github.com/revert-finance/v4lend/blob/main/src/hook/RevertHookExecution.sol"
click node_triggers "https://github.com/revert-finance/v4lend/blob/main/src/hook/RevertHookTriggers.sol"
click node_auction "https://github.com/revert-finance/v4lend/blob/main/src/hook/HookAuctionController.sol"
click node_lease "https://github.com/revert-finance/v4lend/blob/main/src/hook/HookLeaseController.sol"
click node_registry "https://github.com/revert-finance/v4lend/blob/main/src/hook/HookExecutorRegistry.sol"
click node_autoexit "https://github.com/revert-finance/v4lend/blob/main/src/automators/AutoExit.sol"
click node_autorange "https://github.com/revert-finance/v4lend/blob/main/src/automators/AutoRange.sol"
click node_autolend "https://github.com/revert-finance/v4lend/blob/main/src/automators/AutoLend.sol"
click node_autoleverage "https://github.com/revert-finance/v4lend/blob/main/src/automators/AutoLeverage.sol"
click node_autocollect "https://github.com/revert-finance/v4lend/blob/main/src/automators/AutoCollect.sol"
click node_planning "https://github.com/revert-finance/v4lend/tree/main/src/shared/planning"
click node_swapper "https://github.com/revert-finance/v4lend/blob/main/src/shared/swap/Swapper.sol"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_vault,node_oracle,node_liquidation,node_transformers toneBlue
class node_hookentry,node_callbacks,node_execution,node_triggers toneAmber
class node_auction,node_lease,node_registry toneMint
class node_autoexit,node_autorange,node_autolend,node_autoleverage,node_autocollect toneRose
class node_planning,node_swapper,node_lenders,node_borrowers,node_operators,node_pool toneIndigo
```

## Components

### Lending and valuation

- [Lending vault](https://github.com/revert-finance/v4lend/blob/main/src/vault/V4Vault.sol): `src/vault/V4Vault.sol`
- [Position oracle](https://github.com/revert-finance/v4lend/blob/main/src/oracle/V4Oracle.sol): `src/oracle/V4Oracle.sol`
- [Liquidation helpers](https://github.com/revert-finance/v4lend/tree/main/src/vault/liquidation): `src/vault/liquidation`
- [Vault transformers](https://github.com/revert-finance/v4lend/tree/main/src/vault/transformers): `src/vault/transformers`

### Hook automation

- [Hook entrypoint](https://github.com/revert-finance/v4lend/blob/main/src/RevertHook.sol): `src/RevertHook.sol`
- [Swap callbacks](https://github.com/revert-finance/v4lend/blob/main/src/hook/RevertHookCallbacks.sol): `src/hook/RevertHookCallbacks.sol`
- [Hook execution](https://github.com/revert-finance/v4lend/blob/main/src/hook/RevertHookExecution.sol): `src/hook/RevertHookExecution.sol`
- [Automation triggers](https://github.com/revert-finance/v4lend/blob/main/src/hook/RevertHookTriggers.sol): `src/hook/RevertHookTriggers.sol`

### Fee mechanisms

- [Epoch auction](https://github.com/revert-finance/v4lend/blob/main/src/hook/HookAuctionController.sol): `src/hook/HookAuctionController.sol`
- [Harberger lease](https://github.com/revert-finance/v4lend/blob/main/src/hook/HookLeaseController.sol): `src/hook/HookLeaseController.sol`
- [Executor registry](https://github.com/revert-finance/v4lend/blob/main/src/hook/HookExecutorRegistry.sol): `src/hook/HookExecutorRegistry.sol`

### Position automation

- [Auto exit](https://github.com/revert-finance/v4lend/blob/main/src/automators/AutoExit.sol): `src/automators/AutoExit.sol`
- [Auto range](https://github.com/revert-finance/v4lend/blob/main/src/automators/AutoRange.sol): `src/automators/AutoRange.sol`
- [Auto lend](https://github.com/revert-finance/v4lend/blob/main/src/automators/AutoLend.sol): `src/automators/AutoLend.sol`
- [Auto leverage](https://github.com/revert-finance/v4lend/blob/main/src/automators/AutoLeverage.sol): `src/automators/AutoLeverage.sol`
- [Auto collect](https://github.com/revert-finance/v4lend/blob/main/src/automators/AutoCollect.sol): `src/automators/AutoCollect.sol`

### Position tools

- [Planning utilities](https://github.com/revert-finance/v4lend/tree/main/src/shared/planning): `src/shared/planning`
- [Swap utilities](https://github.com/revert-finance/v4lend/blob/main/src/shared/swap/Swapper.sol): `src/shared/swap/Swapper.sol`

### Other components

- **Lenders**
- **Borrowers**
- **Operators**
- **Uniswap v4 pool**

## Connections

- Lenders → Lending vault: deposit assets (evidence: `README.md`)
- Borrowers → Lending vault: borrow against collateral (evidence: `README.md`)
- Lending vault → Position oracle: values LP positions
- Lending vault → Liquidation helpers: liquidation support (evidence: `README.md`)
- Lending vault → Vault transformers: manages collateral (evidence: `README.md`)
- Uniswap v4 pool → Hook entrypoint: swap callbacks (evidence: `README.md`)
- Hook entrypoint → Swap callbacks: handles callbacks (evidence: `README.md`)
- Swap callbacks → Automation triggers: checks triggers
- Swap callbacks → Hook execution: executes automation
- Hook entrypoint → Epoch auction: calls controller (evidence: `README.md`)
- Hook entrypoint → Harberger lease: alternative controller (evidence: `README.md`)
- Operators → Auto exit: runs strategy (evidence: `README.md`)
- Operators → Auto range: runs strategy (evidence: `README.md`)
- Operators → Auto lend: runs strategy (evidence: `README.md`)
- Operators → Auto leverage: runs strategy (evidence: `README.md`)
- Operators → Auto collect: runs strategy (evidence: `README.md`)
- Hook execution → Planning utilities: uses planning
- Hook execution → Swap utilities: uses swaps
