# 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.
