# akshadgujarkar/rangefit architecture

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

- Interactive diagram: https://gitdiagram.com/akshadgujarkar/rangefit
- Repository: https://github.com/akshadgujarkar/rangefit

## Overview

This repository contains a Uniswap v4 hook project, with a range-fitting hook and fixed-point range arithmetic indicated by the source tree and Python reference oracle. The user-facing workflow documented in the README is to deploy a hook, create a pool, add liquidity, and swap tokens using scripts against a local or production network. The hook and Solidity implementation details were not excerpted, so their internal calls and connections are not asserted; the oracle explicitly says it mirrors the Solidity range math.

Main entry points: [`script/00_DeployHook.s.sol`](https://github.com/akshadgujarkar/rangefit/blob/main/script/00_DeployHook.s.sol) (Deploy hook), [`script/01_CreatePoolAndAddLiquidity.s.sol`](https://github.com/akshadgujarkar/rangefit/blob/main/script/01_CreatePoolAndAddLiquidity.s.sol) (Create pool), [`script/02_AddLiquidity.s.sol`](https://github.com/akshadgujarkar/rangefit/blob/main/script/02_AddLiquidity.s.sol) (Add liquidity), [`script/03_Swap.s.sol`](https://github.com/akshadgujarkar/rangefit/blob/main/script/03_Swap.s.sol) (Swap tokens)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_contracts["Hook contracts"]
  node_hook["RangeFit hook<br/>[RangeFitHook.sol]"]
  node_hook_interface["Hook interface<br/>[IRangeFit.sol]"]
end

subgraph group_operations["Pool operations"]
  node_deploy["Deploy hook"]
  node_create_pool["Create pool"]
  node_add_liquidity["Add liquidity"]
  node_swap["Swap tokens<br/>[03_Swap.s.sol]"]
end

subgraph group_arithmetic["Range arithmetic"]
  node_range_math["Range math<br/>[RangeMath.sol]"]
  node_math_oracle["Python oracle<br/>[range_math.py]"]
end

node_operator(("Operator"))
node_network{{"v4 network"}}

node_operator -->|"runs deployment"| node_deploy
node_deploy -.->|"deploys"| node_hook
node_operator -->|"runs pool setup"| node_create_pool
node_create_pool -->|"creates pool"| node_network
node_operator -->|"runs liquidity script"| node_add_liquidity
node_add_liquidity -->|"provides liquidity"| node_network
node_operator -->|"runs swap script"| node_swap
node_swap -->|"swaps tokens"| node_network
node_math_oracle -->|"mirrors arithmetic"| node_range_math

click node_hook "https://github.com/akshadgujarkar/rangefit/blob/main/src/RangeFitHook.sol"
click node_hook_interface "https://github.com/akshadgujarkar/rangefit/blob/main/src/interfaces/IRangeFit.sol"
click node_range_math "https://github.com/akshadgujarkar/rangefit/blob/main/src/libraries/RangeMath.sol"
click node_math_oracle "https://github.com/akshadgujarkar/rangefit/blob/main/sim/range_math.py"
click node_deploy "https://github.com/akshadgujarkar/rangefit/blob/main/script/00_DeployHook.s.sol"
click node_create_pool "https://github.com/akshadgujarkar/rangefit/blob/main/script/01_CreatePoolAndAddLiquidity.s.sol"
click node_add_liquidity "https://github.com/akshadgujarkar/rangefit/blob/main/script/02_AddLiquidity.s.sol"
click node_swap "https://github.com/akshadgujarkar/rangefit/blob/main/script/03_Swap.s.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_hook,node_hook_interface toneBlue
class node_deploy,node_create_pool,node_add_liquidity,node_swap toneAmber
class node_range_math,node_math_oracle toneMint
class node_operator,node_network toneIndigo
```

## Components

### Hook contracts

- [RangeFit hook](https://github.com/akshadgujarkar/rangefit/blob/main/src/RangeFitHook.sol): `src/RangeFitHook.sol`
- [Hook interface](https://github.com/akshadgujarkar/rangefit/blob/main/src/interfaces/IRangeFit.sol): `src/interfaces/IRangeFit.sol`

### Pool operations

- [Deploy hook](https://github.com/akshadgujarkar/rangefit/blob/main/script/00_DeployHook.s.sol): `script/00_DeployHook.s.sol`
- [Create pool](https://github.com/akshadgujarkar/rangefit/blob/main/script/01_CreatePoolAndAddLiquidity.s.sol): `script/01_CreatePoolAndAddLiquidity.s.sol`
- [Add liquidity](https://github.com/akshadgujarkar/rangefit/blob/main/script/02_AddLiquidity.s.sol): `script/02_AddLiquidity.s.sol`
- [Swap tokens](https://github.com/akshadgujarkar/rangefit/blob/main/script/03_Swap.s.sol): `script/03_Swap.s.sol`

### Range arithmetic

- [Range math](https://github.com/akshadgujarkar/rangefit/blob/main/src/libraries/RangeMath.sol): `src/libraries/RangeMath.sol`
- [Python oracle](https://github.com/akshadgujarkar/rangefit/blob/main/sim/range_math.py): `sim/range_math.py`

### Other components

- **Operator**
- **v4 network**

## Connections

- Operator → Deploy hook: runs deployment (evidence: `README.md`)
- Deploy hook → RangeFit hook: deploys
- Operator → Create pool: runs pool setup (evidence: `README.md`)
- Create pool → v4 network: creates pool (evidence: `README.md`)
- Operator → Add liquidity: runs liquidity script (evidence: `README.md`)
- Add liquidity → v4 network: provides liquidity (evidence: `README.md`)
- Operator → Swap tokens: runs swap script (evidence: `README.md`)
- Swap tokens → v4 network: swaps tokens (evidence: `README.md`)
- Python oracle → Range math: mirrors arithmetic (evidence: `sim/range_math.py`)
