# Tech Stack

The **Reputation Hook Contract Project** is built using a robust and carefully selected technology stack. It leverages low-level libraries, efficient contract design patterns, gas optimizations, and thorough testing to ensure both security and scalability. This section provides a comprehensive overview of the technical underpinnings, including contract sizes, bitmap usage, gas optimizations, and the separation of concerns enabled by **Reputation Logic**. Here's a closer look at the core components:

### **Low-Level Libraries**

The project incorporates a range of low-level libraries, which are designed to optimize contract performance and ensure efficient execution, particularly in gas-heavy environments like Ethereum.

<figure><img src="/files/ml9IQLRAAExt0wdEg6I2" alt=""><figcaption></figcaption></figure>

* **Contract Sizes**:
  * The main contracts, **MetaPool** and **ReputationLogic**, are highly optimized, with their size kept under limits to prevent exceeding block gas limits and keep deployment costs low.
  * These optimized sizes ensure that contract deployment is efficient, even with large systems of interconnected pools and hooks.

<figure><img src="/files/BrbjjvDMb7vHn5KdJsmR" alt=""><figcaption></figcaption></figure>

* **Bitmap Optimization**:
  * **Bitmap storage** is employed to track the state of pools, user activity, and overall reputation within the system, reducing the cost of accessing multiple mappings and instead allowing batch operations on a single storage word.
  * Example: Tracking up to 256 pools in a single word reduces storage costs significantly compared to using a separate mapping for each pool.

<figure><img src="/files/31DxnBFygFs1dMRAogZH" alt=""><figcaption></figcaption></figure>

* **Gas-Optimized Hook Execution**:
  * By utilizing **beforeSwap** and **afterSwap** hooks, gas usage is minimized by bundling multiple pool updates and reputation checks into a single call.
  * **Gas Savings**: Replacing multiple read and write operations with batched updates using the **MetaPool Library** reduces gas per transaction, making the system scalable even for complex liquidity strategies.
* **Unblocking Flow Through Reputation Logic**:
  * The **Reputation Logic** contract introduces a separation of concerns, ensuring that user reputation calculations are offloaded to separate contracts, minimizing the impact on the core liquidity pool.
  * **Unblocking Flow**: By using off-chain computations (via Brevis), reputation updates do not block or delay on-chain liquidity operations. This ensures that users can interact with liquidity pools in real-time, even when complex reputation calculations are being processed in the background.

```
  ├─ [445236] 0xaD1A161142DC747f47De724F748444D35eE62650::performUpkeep(0x)
    │   ├─ [445061] ReputationLogic::performUpkeep(0x) [delegatecall]
    │   │   ├─ emit ReputationUpdateBatchEmitted(batchId: 86884260856199153866334879381415440615693346100533887595885188063103080643154 
[8.688e76], nonce: 2, users: [0x343E2e8DA3339EE4946CDCaf8b797192bCe50bA9], updatesToProcess: 1, swapInfoHashes: [0x2b429e4eab6541b4beccc7b602371aa993f406b84ccf73c8867b6d83cb135f94], 
tickInfoHashes: [0x308444febab250095893c1e1841e20e09069dfd103bd7c8538ffde11443240af], tokenInfoHashes: [0x030c6288b28bc8aaf9e399b58b81710050cf1c2457caac36f3f7ecec520a64b7], 
metricsInfoHashes: [0xeccae8a648a17579c67a3de5d1d92478a49c40cd34b5f72077db7799220e3f47], hookAddress: ReputationHook: [0x5c9A009485C55894d2d3430cCE5783B8d031FdCc])
    │   │   ├─ [2942] ReputationOracle::getRequiredFee() [staticcall]
    │   │   │   └─ ← 10000000000000000 [1e16]
    │   │   ├─ [122448] ReputationOracle::initiateReputationUpdateBatch{value: 10000000000000000}(86884260856199153866334879381415440615693346100533887595885188063103080643154 
[8.688e76], 2, 31337 [3.133e4])
    │   │   │   ├─ emit ProofRequestInitiated(requestId: 0x517f65e58a58f4e0294f17597317388e5bef5f15b4f4d98980eb5ecc58c0ec93, chainId: 31337 [3.133e4], reputationLogic: 0xaD1A161142DC747f47De724F748444D35eE62650)
    │   │   │   └─ ← 0x517f65e58a58f4e0294f17597317388e5bef5f15b4f4d98980eb5ecc58c0ec93
    │   │   └─ ← ()
    │   └─ ← ()
    ├─ [1107] 0xaD1A161142DC747f47De724F748444D35eE62650::getUpdateQueueLength() [staticcall]
    │   ├─ [941] ReputationLogic::getUpdateQueueLength() [delegatecall]
    │   │   └─ ← 0
    │   └─ ← 0
```


---

# 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://metapool.bloklab.fi/basics/tech-stack.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.
