# Open Source Code

### [`uniswap-v3-automan`](https://github.com/Aperture-Finance/uniswap-v3-automan)

The UniV3Automan contract allows Aperture's automation service to perform three actions: rebalancing, reinvesting, and swapping tokens. It leverages the OptimalSwap library to calculate the optimal token swap amount, considering the desired token ratio and its impact on the liquidity position.

### [`uni-v3-lib`](https://github.com/Aperture-Finance/uni-v3-lib)

This repository offers close to **30%** gas saving and focuses on essential Uniswap libraries for external integrators. It includes modified versions of `SqrtPriceMath` and `TickMath`, optimized for modern Solidity compilers (v0.8.0+). Inline assembly reduces gas usage in most functions. Additional libraries, like `PoolCaller` and `NPMCaller`, improve efficiency by bypassing `extcodesize` checks and directly manipulating stack and memory. Helpers, including nextInitializedTick, aid in searching for initialized ticks. Extensive code annotations document optimization techniques used.


---

# 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://docs.aperture.finance/docs/technical-docs/open-source-code.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.
