> Agents can also search and read this documentation through its [MCP server](https://docs.revert.finance/revert/~gitbook/mcp).

# Introduction

![](https://1849061604-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FwVXi8b0BXAXDUzfJDx1d%2Fuploads%2Fgit-blob-db571057faf699659da8c132f2639061b1640882%2Funknown.png?alt=media)

Revert builds analytics and financial tools for liquidity providers in AMM protocols. A liquidity position is an investment, and we treat it like one: it deserves accounting-grade performance data, automation that executes while you sleep, and the ability to work as collateral without ceasing to earn.

AMMs are becoming a fundamental part of financial markets. That only works if the people providing the liquidity have open, transparent tools that let them see exactly what their capital is doing, which is what we build.

## What you can do with Revert

* **Know your real performance.** PnL, APR, ROI, and divergence loss for Uniswap v2, v3, and v4 positions and Aerodrome positions on Base, across Ethereum, Polygon, Arbitrum, Optimism, Base, and Unichain. Every number is computed from your position's full cash-flow history and defined precisely enough to recompute: see [How Revert measures performance](https://docs.revert.finance/revert/position-analytics/how-revert-measures-performance).
* **Manage everything in one place.** Add or withdraw liquidity, claim fees, and change ranges directly from the position page.
* **Automate the busywork.** [Auto-compound](https://docs.revert.finance/revert/auto-compounder) reinvests fees when it is profitable to do so, [Auto-Range](https://docs.revert.finance/revert/auto-range) keeps ranges tracking the price, and [Auto-Exit](https://docs.revert.finance/revert/auto-exit) gives a position a pre-committed way out.
* **Earn on Aerodrome.** Positions on Base are staked for you to earn AERO emissions, with [auto-compounding of rewards](https://docs.revert.finance/revert/aerodrome/aero-auto-compounding) back into the position.
* **Borrow without unwinding.** [Revert Lend](https://docs.revert.finance/revert/revert-lend) takes your Uniswap v3 or Aerodrome position as collateral for a USDC loan while it keeps earning.
* **Combine the tools deliberately.** The [Playbooks](https://docs.revert.finance/revert/playbooks) walk the decisions: when to compound versus collect, how to pick a range with evidence, and how to run a carry on staked collateral.

New to Aerodrome on Revert? Start with [Aerodrome on Base](https://docs.revert.finance/revert/aerodrome).


# Position Analytics

Check and easily track the performance of your positions on the following AMM protocols and chains or L2s.

* Uniswap v4 on Ethereum
* Uniswap v4 on Unichain
* Uniswap v2 on Ethereum
* Sushiswap on Ethereum
* Uniswap v3 on Ethereum
* Sushiswap on Arbitrum
* Uniswap v3 on Arbitrum
* Uniswap v3 on Polygon
* Uniswap v3 on Optimism
* Uniswap v3 on BNB Chain
* Uniswap v3 on Base
* Aerodrome on Base

Read about our [approach to detecting staked LP tokens](https://docs.revert.finance/revert/position-analytics/detecting-staked-lp-tokens) and also breakdowns for our analytics dashboards for [Uniswap V2](https://docs.revert.finance/revert/position-analytics/uniswap-v2-positions), [Uniswap V3](https://docs.revert.finance/revert/position-analytics/uniswap-v3-positions), and [Uniswap V4](https://docs.revert.finance/revert/position-analytics/uniswap-v4-positions). For Aerodrome positions on Base, which earn AERO rewards through gauge staking, see [Aerodrome on Base](https://docs.revert.finance/revert/aerodrome).


# How Revert measures performance

Every number on a position page is computed from the position's full cash-flow history: deposits, withdrawals, fee collections, reward claims, gas costs, and the current state of the position. Each flow is recorded with its token amounts and the prices at the time it happened. Nothing is sampled or approximated from charts. This page defines each metric precisely, so you can recompute any of them and know exactly what you are looking at.

## The benchmark

PnL is always measured against a benchmark, selectable from the reference dropdown on the position page:

* **HOLD** (default): what you would have if you had kept the deposited tokens in your wallet. All flows are valued at current prices, so pure price movement cancels out and what remains is the pool's actual contribution: fees, rewards, and divergence.
* **USD**: what you would have if you had kept the dollars instead of buying the tokens. Flows are valued at their historical prices.
* **ETH**: the same comparison, denominated in ETH.
* **token0 / token1**: everything denominated in one of the pair's tokens.

Changing the benchmark changes PnL, APR, and ROI together. The question each answers is different: HOLD isolates what providing liquidity earned you versus holding; USD measures it against having stayed in cash.

## The metrics

**Pooled assets.** The position's current token amounts valued at current prices. Principal only: uncollected fees and unclaimed rewards are tracked separately.

**Total PnL** (header). Everything the position has earned or lost against the benchmark:

```
total PnL = divergence + fees (collected + uncollected)
          + rewards (claimed + unclaimed) - gas costs
```

**Pool PnL** (Performance panel, "excluding gas"). The pool's own contribution, with gas and incentive rewards stripped out:

```
pool PnL = divergence + fees (collected + uncollected)
```

The two differ exactly by rewards minus gas. On a staked Aerodrome position, where income arrives as AERO rather than fees, total PnL carries the rewards and pool PnL does not. Compare them and you can read where your return actually comes from.

**Divergence loss.** Pool PnL minus fees. This is the cost of the pool's price action: what rebalancing your inventory against the market cost you relative to the benchmark. It is reported as its own line rather than hidden inside PnL, because a position with strong fee income and worse divergence is a different trade than one with modest fees and none.

**Total APR** (header). Total PnL annualized over the position's life:

```
APR = total PnL / time-weighted average balance / years elapsed * 100
```

The denominator is the time-weighted average of capital actually in the position, so adding or removing liquidity mid-life does not distort the rate. Years elapsed runs from the first mint. Income counts fees and rewards; gas is subtracted.

**Fee APR.** The same annualization with only fees in the numerator. On a staked Aerodrome position this trends toward zero by design; the income shows up in rewards instead. See [Staking & AERO rewards](https://docs.revert.finance/revert/aerodrome/staking-and-rewards).

**ROI.** Total PnL divided by what you put in (net deposits plus gas), not annualized. APR tells you the rate; ROI tells you the cumulative result.

**Avg daily fees.** Total fees (collected plus uncollected, at current prices) divided by position age in days.

**Age.** Time since the position's first mint.

**Rewards APR** (pool-level, Aerodrome). Annualized gauge emissions, valued at the reward-token price, divided by pool TVL:

```
rewards APR = (rewards per second * AERO price * seconds per year / pool TVL) * 100
```

This is a pool-wide reference rate, not a floor: it assumes liquidity is evenly distributed, and your realized rate depends on where your liquidity sits. A staked position concentrated tighter than the rest of the pool's staked liquidity earns more than this while in range; a wider one earns less; one parked out of range earns nothing. Emissions are re-voted weekly, so this number moves with each epoch.

## Reading them together

The metrics are designed to be cross-examined:

* **Fee APR high, total APR low**: divergence is eating the fee income. Check the divergence loss line and the price chart.
* **Total PnL positive, pool PnL negative**: the pool itself lost against the benchmark and rewards carried the position. Your return depends on the reward token's price holding up.
* **APR strong, ROI small**: the rate is good but it has not compounded long enough, or the position is young. Age tells you which.

If a number on the position page does not reconcile with these definitions, that is a bug, and we want to hear about it.


# Uniswap v4 Positions

![Uniswap v4 position example](https://1849061604-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FwVXi8b0BXAXDUzfJDx1d%2Fuploads%2Fgit-blob-8fe449c972f371f4bf63f8a5e51481560e2a2afd%2Fv3position.png?alt=media)

{% hint style="info" %}
Uniswap V4 is currently in early stages. Analytics and Position Management features are available on Ethereum mainnet and Unichain.
{% endhint %}

## Supported Networks

* Ethereum mainnet
* Unichain

### Uniswap v4 position definitions

#### pooled assets:

Value in USD of the position.

#### APR:

Annual percentage rate of returns given the current value of the underlying position assets including deposits, withdrawals, gas costs, and staking rewards at current prices.

#### fee APR:

Annual percentage rate of returns considering the accrued fees only. Does not account for divergence loss.

#### APR excluding gas:

Annual percentage rate of returns considering the value of the underlying position and the accrued fees, and divergence loss. Does not account for gas costs.

#### pool PnL:

Profit and loss for the position from only fees accrued and price divergence.

`Pool PnL = value of current LP underlying tokens`\
`- value of tokens deposited (at current price)`\
`+ value of tokens withdrawn (at current price)`

#### total PnL (vs HOLD):

`Total PnL = USD value of underlying tokens (at current price)`\
`- USD value of tokens deposited (at current price)`\
`+ USD value of tokens withdrawn (at current price)`\
`+ USD value of pending rewards (at current price)`\
`+ USD value of claimed rewards (at current price)`\
`- USD value of gas costs at current ETH price.`

#### total PnL (vs ETH):

`Total PnL = ETH value of underlying tokens (at current price)`\
`- ETH value of tokens deposited (at deposit price)`\
`+ ETH value of tokens withdrawn (at withdrawal price)`\
`+ ETH value of pending rewards (at current prices)`\
`+ ETH value of claimed rewards at (at claim price)`\
`- ETH value of gas costs.`

#### total PnL (vs USD):

`Total PnL = USD value of current underlying tokens`\
`- USD value of tokens deposited (at deposit price)`\
`+ USD value of tokens withdrawn (at withdrawal price)`\
`+ USD value of pending rewards (at current price)`\
`+ USD value of claimed rewards (at claim price)`\
`- USD value of gas costs (at tx price).`

#### current assets:

The amount of underlying tokens corresponding to this LP position.

#### invested assets:

The sum of all assets invested in the position.

#### withdrawn:

The sum of all assets withdrawn out of the position.

#### diffs:

The difference between the assets invested, subtracting the assets withdrawn, and the current assets in the LP position.\
\
\&#xNAN;*`diffs = current assets - invested assets + withdrawn assets`*

#### **unclaimed rewards:**

The sum of all detected unclaimed staking reward assets for the account and pool.

#### claimed rewards:

The sum of all detected claimed staking reward assets for the account and pool.

### Pool definitions

#### reserves:

USD value of the underlying token reserves for the pool.

#### volume:

USD value of the traded volume for the pool.

#### price divergence:

The running difference between the changes in prices (as percentages) for the underlying assets against the prices 30 days ago. Price divergences between a pair of assets can result in losses for liquidity providers.\
\
`Price Divergence = abs(token0_price_change_pct - token1_price_change_pt)`

#### **position age:**

The amount of time (in days) that have passed since the position was first created.


# Uniswap v3 Positions

![Uniswap v3 position example](https://1849061604-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FwVXi8b0BXAXDUzfJDx1d%2Fuploads%2Fgit-blob-8fe449c972f371f4bf63f8a5e51481560e2a2afd%2Fv3position.png?alt=media)

### Uniswap v3 position definitions

#### pooled assets:

Value in USD of the position.

#### APR:

Annual percentage rate of returns given the current value of the underlying position assets including deposits, withdrawals, gas costs, and staking rewards at current prices.

#### fee APR:

Annual percentage rate of returns considering the accrued fees only. Does not account for divergence loss.

#### APR excluding gas:

Annual percentage rate of returns considering the value of the underlying position and the accrued fees, and divergence loss. Does not account for gas costs.

#### pool PnL:

Profit and loss for the position from only fees accrued and price divergence.

`Pool PnL = value of current LP underlying tokens`\
`- value of tokens deposited (at current price)`\
`+ value of tokens withdrawn (at current price)`

#### total PnL (vs HOLD):

`Total PnL = USD value of underlying tokens (at current price)`\
`- USD value of tokens deposited (at current price)`\
`+ USD value of tokens withdrawn (at current price)`\
`+ USD value of pending rewards (at current price)`\
`+ USD value of claimed rewards (at current price)`\
`- USD value of gas costs at current ETH price.`

#### total PnL (vs ETH):

`Total PnL = ETH value of underlying tokens (at current price)`\
`- ETH value of tokens deposited (at deposit price)`\
`+ ETH value of tokens withdrawn (at withdrawal price)`\
`+ ETH value of pending rewards (at current prices)`\
`+ ETH value of claimed rewards at (at claim price)`\
`- ETH value of gas costs.`

#### total PnL (vs USD):

`Total PnL = USD value of current underlying tokens`\
`- USD value of tokens deposited (at deposit price)`\
`+ USD value of tokens withdrawn (at withdrawal price)`\
`+ USD value of pending rewards (at current price)`\
`+ USD value of claimed rewards (at claim price)`\
`- USD value of gas costs (at tx price).`

#### current assets:

The amount of underlying tokens corresponding to this LP position.

#### invested assets:

The sum of all assets invested in the position.

#### withdrawn:

The sum of all assets withdrawn out of the position.

#### diffs:

The difference between the assets invested, subtracting the assets withdrawn, and the current assets in the LP position.\
\
\&#xNAN;*`diffs = current assets - invested assets + withdrawn assets`*

#### **unclaimed rewards:**

The sum of all detected unclaimed staking reward assets for the account and pool.

#### claimed rewards:

The sum of all detected claimed staking reward assets for the account and pool.

### Pool definitions

#### reserves:

USD value of the underlying token reserves for the pool.

#### volume:

USD value of the traded volume for the pool.

#### price divergence:

The running difference between the changes in prices (as percentages) for the underlying assets against the prices 30 days ago. Price divergences between a pair of assets can result in losses for liquidity providers.\
\
`Price Divergence = abs(token0_price_change_pct - token1_price_change_pt)`

#### **position age:**

The amount of time (in days) that have passed since the position was first created.


# Uniswap v2 Positions

![Example](https://1849061604-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FwVXi8b0BXAXDUzfJDx1d%2Fuploads%2Fgit-blob-0dd6efb0c5faa8878630cef57e012cb30adec8dd%2Fimage.png?alt=media)

### LP definitions

The following are definitions for the user to fully understand the concepts displayed on our analytics dashboards.

#### assets\_value:

Value in USD of the LP tokens detected as owned by the account, computed using the amount of underlying assets and current coingecko prices.

#### pool\_pnl:

Profit and loss for the LP position from only fees accrued and price divergence.\
\
\&#xNAN;*`Pool PnL = value of current LP underlying tokens`*\
*`- value of tokens deposited (at current price)`*\
*`+ value of tokens withdrawn (at current price)`*

#### total\_pnl:

Profit and loss for the LP position from fees accrued, price divergence, gas costs, and reward incentives

```
Total PnL =   value of current LP underlying tokens
              - value of tokens deposited (at current price)
              + value of tokens withdrawn (at current price)
              + pending rewards at current prices
              + claimed rewards at current price
              - gas costs for all deposit and withdrawal transactions at current ETH price.
```

#### apr:

Annual percentage rate of returns given the current value of the underlying LP assets and deposits, withdrawals, gas costs, and staking rewards at current prices.

#### current\_assets:

The amount of underlying tokens corresponding to this LP position. Computed by taking all the pool LP tokens minted by the account, and subtracting any LP tokens that were burned for a withdrawal, as well as total current LP tokens for the pool, and the total amount of underlying assets.

#### invested\_assets:

The sum of all assets invested in the LP position, obtained from the respective mint transactions for the account and pool.

#### withdrawn\_assets:

The sum of all assets withdrawn out of the LP position, obtained from the respective burn transactions for the account and pool.

#### diffs:

The difference between the assets invested, subtracting the assets withdrawn, and the current assets in the LP position.\
\
\&#xNAN;*`diffs = current assets - invested assets + withdrawn asset`*

#### staking\_rewards:

The sum of all detected staking rewards (claimed and unclaimed) at current prices for the reward assets.

#### unclaimed\_rewards:

The sum of all detected unclaimed staking reward assets for the account and pool.

#### claimed\_rewards:

The sum of all detected claimed staking reward assets for the account and pool.

#### lp\_tokens:

LP tokens owned by the account. Computed by taking the LP tokens minted and subtracting any LP tokens that were burned for a withdrawal.

### Pool definitions

#### reserves:

USD value of the underlying token reserves for the pool.

#### volume:

USD value of the traded volume for the pool.

#### price\_divergence:

The running difference between the changes in prices (as percentages) for the underlying assets against the prices 30 days ago. Price divergences between a pair of assets can result in losses for liquidity providers.\
\
`Price Divergence = abs(token0_price_change_pct - token1_price_change_pt)`


# Detecting staked LP tokens

An initial naive approach to take when counting LP tokens an account owns would be to simply check the balance the account currently holds. The Uniswap subgraph makes this particularly easy. The problem with this approach is that many times LP tokens are staked in various contracts that provide reward incentives, at which point the tokens are not held by the account.

A different approach that addresses this issue is to compute the LP tokens that have been “minted” and “burned” by the account, when depositing and withdrawing assets from the pool. This addresses the problem of LP tokens being staked in any unknown contract, however, it comes with some important caveats:

1. If an account transfers LP tokens to a different account, or contract, in a way that would imply relinquishment of ownership, they would still appear as being owned by the original minter account.
2. If an account receives LP tokens from a different minter account, they are (currently) not counted as being owned by the receiving account.

The first issue is easy to address in a manual fashion by providing an option to “ignore” the LP position in question. The second issue can be addressed by accounting for received LP transfers, and differentiating these from transfers that might be the result of unstakings, which we are currently working on.

It’s almost certain that our approach will evolve over time as changing practices with regard to staking contracts, feedback from users, and our own experience will improve our solution to the problem described.


# Open Positions

​The Open Positions section lists the open active positions based on their overall performance on supported networks and exchanges.

![](https://1849061604-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FwVXi8b0BXAXDUzfJDx1d%2Fuploads%2Fgit-blob-5d54d1be3f1e6a770eeb86e574a249d809d2dbdc%2Ftop-positions.png?alt=media)

The first thing to note here is that we are counting PnL and APR versus holding the invested asset(s) outside of the pool (HODL), as explained [here](https://revert.finance/#/about), but ignoring associated gas costs. So the PnL and APR used to compare positions correspond to the “***pool PnL***” and “***APR excluding gas***” on the individual position views. The reason to compare them in that way is that gas costs will have a very different impact on the APR depending on the size of each position.

\
The overall top position view is an interesting list of outliers, perfectly exemplified by a once [top position](https://revert.finance/#/uniswap-position/156349), which accrued a disproportionate fee for its size, range, and age. That seems very likely due to LPing in a low liquidity pool, when a large swap pushes the rest of the liquidity out of range.

![](https://1849061604-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FwVXi8b0BXAXDUzfJDx1d%2Fuploads%2Fgit-blob-f28b11ebd6ad02b189821d839ba83a8d57bb5f8c%2Fimage.png?alt=media)

But perhaps more useful are the views into the top positions for each pool, from which we can get an overview of how the current active positions are performing relative to each selected price range.

![](https://1849061604-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FwVXi8b0BXAXDUzfJDx1d%2Fuploads%2Fgit-blob-b768b5d365617f648a5c8b508f734ca6f1af930e%2Fimage.png?alt=media)


# Create Position

[Create Position](https://revert.finance/#/discover) helps you discover liquidity pools and create positions across multiple protocols including Uniswap V3, V4, and Aerodrome.

Browse pools by filtering on metrics like TVL, volume, fees APR, and rewards. Compare opportunities across networks and protocols, then create positions with visual price range selection and backtesting tools.

## Key Features

* **Discover Pools** - Browse available liquidity pools across Ethereum, Polygon, Arbitrum, Optimism, Base, and Unichain
* **Filter & Sort** - Find pools by rewards, trending pools, new pools, or pools with lending support
* **Pool Analytics** - View detailed charts for price, TVL, volume, and fees
* **Top Positions** - See how other LPs have positioned their liquidity
* **Visual Range Selection** - Set price ranges using preset buttons or manual inputs
* **Backtesting** - Simulate how your position would have performed historically
* **Multi-Protocol** - Create positions on Uniswap V3, V4, and Aerodrome from one interface


# How to Create a Position

Creating a position with Revert is a discovery-first process that lets you find the best pools before opening positions.

## Browse Pools

Start by browsing available liquidity pools across multiple protocols and networks.

### Network & Token Filters

* **Any network** - Select specific networks (Ethereum, Polygon, Arbitrum, Optimism, Base, Unichain)
* **Any tokens** - Filter by token pairs
* **+ filters** - Opens advanced filtering panel

Click the **"+ filters"** button to access additional filtering options:

* **Exchanges** - Filter by specific exchanges/protocols (Uniswap V3, V4, Aerodrome)
* **Pool address** - Search for a specific pool by contract address
* **TVL** - Set minimum and maximum Total Value Locked range (in USD)
* **Fees APR** - Filter by fee APR percentage range
* **Fees/TVL** - Filter by fee efficiency ratio
* **Pool age** - Filter by pool age in days

Click **"Apply"** to activate filters or **"Clear"** to reset them.

### Quick Filters

* **Rewards** - Pools with active reward programs
* **Trending** - Popular pools by volume or new positions
* **New pools** - Recently created pools
* **Loan** - Pools with lending/borrowing support

### Pool Metrics

Each pool row displays:

* **Pool/Fee Tier** - Token pair and fee percentage (e.g., WETH/USDC 0.05%)
* **TVL** - Total Value Locked in the pool
* **Volume** - Trading volume for the selected time period
* **Fees** - Total fees generated
* **Fees/TVL** - Fee efficiency ratio
* **Age** - How long the pool has existed
* **Fees APR** - Annual percentage rate from trading fees
* **Rewards APR** - Annual percentage rate from external rewards (if available)

## Select a Pool

Click the expand button (▼) on any pool row to view details and create a position.

The expanded view shows:

### Pool Overview

* **Price Chart** - Historical price movement for the token pair
* **TVL/Volume/Fees Graphs** - Performance metrics over time
* **Current Prices** - Real-time prices for both tokens
* **Top Positions** - Existing positions in this pool showing their ranges, sizes, and performance

### Create Position Panel

On the right side, you'll see the position creation interface.

## Configure Your Position

### Amounts to Deposit

1. Select **"Same Tokens"** to deposit both tokens at current ratio, or choose a single token to swap
2. Toggle **"Use prices ratio"** - When enabled, forces deposits to use the exact current pool ratio without performing any swap
3. Enter amounts for each token (use **MAX** button to deposit full balance)
4. Adjust **deposit slippage** if needed (default 1.0%)

{% hint style="info" %}
If "Use prices ratio" is disabled and you enter custom amounts, Revert may swap tokens to achieve the required ratio. The applicable swap fee is shown before confirmation and is capped at 0.65%.
{% endhint %}

### Price Range Selection

Choose the price range where your liquidity will be active:

#### Preset Buttons

* **MIN** - Full range from minimum to current price
* **1%** - ±1% from current price (very concentrated)
* **5%** - ±5% from current price
* **10%** - ±10% from current price
* **20%** - ±20% from current price
* **FULL** - Full range (all prices)

#### Manual Entry

Enter specific prices for your minimum and maximum range. The visual graph shows:

* Current pool price
* Your selected **NEW MIN** and **NEW MAX** prices
* Where your liquidity will be active (green area)

### Swap Preview

If swapping tokens, you'll see:

* Swap amounts and direction
* Applicable swap fee (dynamic, up to 0.65%)
* Slippage tolerance (adjustable, default 0.50%)

## Run Backtester (Optional)

Click **"Run backtester"** to simulate how your position would have performed historically with the selected parameters.

The backtester shows:

* Projected fees earned
* Impermanent loss/gain
* Comparison vs. holding tokens

{% hint style="info" %}
**Fee dilution** refers to the dilution effect of adding more capital to a pool (assuming volume had remained constant). e.g., adding 10M to a 5M pool might reduce APR considerably more than adding 50k.
{% endhint %}

## Create Position

Review the **Transaction summary** showing:

* Expected amounts to add
* Minimum amounts after slippage
* Estimated gas costs

Click **"Create \[TOKEN/TOKEN] position"** to confirm and create your position.

After approving token permissions (if needed), the transaction will create your position NFT directly with the protocol's contracts.


# Auto-compounder

## The basics

LP positions in Uniswap V3 earn fees while swaps happen within their selected price ranges. However, these fees do not accumulate inside the pool, but in a separate balance for each position. One consequence of this is that fees are not compounded automatically as liquidity back into the position.

If a liquidity provider wants to compound accrued fees back into their position, they need to collect these fees, possibly swap them to the correct ratio given the position range and current pool tick, and add these possibly swapped amounts back into the position.

The Revert auto-compounder allows LPs to automate the compounding of the accrued fees in exchange for a fixed percentage of the compounded fees. This serves to incentivize a maximum number of compounds at optimal times with regards to gas costs.

Depending on the fee APR and size of your position this can significantly improve your returns.

![](https://1849061604-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FwVXi8b0BXAXDUzfJDx1d%2Fuploads%2Fgit-blob-e3dc846d93a0a26e23a765a852cb613552a00c1b%2FGroup%20260.png?alt=media)

Auto-compounding functionality is provided by the Revert Compoundor protocol.\
\
Positions managed by the Compoundor contract can be auto-compounded at any time by the operator account. The ***autoCompound*** function takes any uncollected fees for a position, optionally swaps them to a determined ratio given the position range and the current pool price, and adds it as liquidity to the position.

A small fraction of the *collected-and-compounded* fees are paid to the protocol and to compensate the accounts call the auto-compound function for their gas costs incurred. This performance fee is set to 2%.

**Aerodrome AERO rewards**

On Aerodrome positions on Base, auto-compounding reinvests the position's emitted **AERO rewards** rather than swap fees. The mechanics and fees differ slightly, see [AERO auto-compounding](https://docs.revert.finance/revert/aerodrome/aero-auto-compounding).

**Rebasing tokens support**

The protocol is not intended to work with any kind of deflationary, rebasing, fee-on-transfer, or any non-standard erc20 behavior tokens.


# User Guide

### Check your position

For any tracked Uniswap v3 position, click on the **'Compound fees'** button to see estimations of auto-compounding profits and decide if you want to auto-compound a position, depending on the possible improvement over different periods, up to a year, and your expected time preference.

![](https://1849061604-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FwVXi8b0BXAXDUzfJDx1d%2Fuploads%2Fgit-blob-e3dc846d93a0a26e23a765a852cb613552a00c1b%2FGroup%20260.png?alt=media)

### Activate Auto-Compounding

When an LP clicks on "**Activate Autocompound"** their wallet permissions will be prompted, asking for authorization to set the [auto-compounder contract](https://docs.revert.finance/revert/resources/contract-addresses) as operator for the position.\
\
Once the transaction has finished successfully, the Revert auto-compounder will compound uncollected fees when it's profitable to do so given their expected rewards and gas costs as constraints.

![](https://1849061604-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FwVXi8b0BXAXDUzfJDx1d%2Fuploads%2Fgit-blob-eef7408884d2d8fc13bc5ed6b5132507775751d9%2FGroup%20262.png?alt=media)

### Manage position

While your position is auto-compounded, you can manage your position as you would normally, add/remove liquidity, collect fees, or manually auto-compound (self-compound).

![](https://1849061604-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FwVXi8b0BXAXDUzfJDx1d%2Fuploads%2Fgit-blob-9c574f2f341ca0fed8d7cb6367e460c5f47a7077%2FGroup%20263.png?alt=media)

### Deactivate Auto-Compounding

To deactivate the auto-compounding, LPs click on the 'Compound fees' button to expand the compounding options.\
\
Clicking the **'Stop Autocompound'** button will prompt the wallet authorization screen, and clear the auto-compounder contract as operator for the position.

![](https://1849061604-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FwVXi8b0BXAXDUzfJDx1d%2Fuploads%2Fgit-blob-3b79b73e7451486d1611253c881482fceb88f65a%2FFrame%20255.png?alt=media)


# Performance improvement

The increase in performance due to compounding fees will be widely different across positions, and in some cases, the gas costs of compounding the fees may not be offset by the increased fees collected due to the compounding effect for more than a year.

**Costs of Compounding**

We can estimate the costs of compounding fees without using the auto-compounder on Mainnet (25 Gwei), Polygon (50 Gwei), Optimism (0.25 Gwei), and Arbitrum (0.2 Gwei) as per the following table\[^2]. Assuming separate transactions and ETH price of $1000 and MATIC price of $0.5. For Optimism and Arbitrum estimated Gwei amounts were used to avoid doing L2 gas price calculation.

| Function      | Gas cost | Mainnet | Optimism | Arbitrum | Polygon |
| ------------- | -------- | ------- | -------- | -------- | ------- |
| Collect       | 124,000  | $3.10   | $0.03    | $0.02    | $0.003  |
| Swap          | 184,523  | $4.61   | $0.05    | $0.04    | $0.004  |
| Add liquidity | 216,912  | $5.42   | $0.05    | $0.04    | $0.005  |
| Total         | 525,435  | $13.13  | $0.13    | $0.10    | $0.012  |

Likewise we can estimate the gas costs for compounding a position using the Compoundor contract on the same chains as shown below.

| Function      | Gas cost | Mainnet | Optimism | Arbitrum | Polygon |
| ------------- | -------- | ------- | -------- | -------- | ------- |
| Auto-Compound | 479,521  | $11.99  | $0.12    | $0.10    | $0.01   |

**Estimating Benefits of Auto-compounding**

We define the relevant parameters for our estimations as follows:

***P =*** Principal amount (current value of LP position) ***APR =*** annual percentage rate from fees only (fee APR) ***GASCOST =*** current gas costs of compounding fees ***PREWARD =*** fraction of compounded fees paid to the protocol ***CREWARD =*** fraction of the compounded fees paid to the account that calls the contract function and pays for the gas. This value is always equal or less than ***PREWARD***, as it defines the fraction of the protocol rewards assigned to the caller.

**Number of Yearly Compoundings**

To estimate the number of compoundings the protocol would execute for a given position we assume that auto-compounding happens when the compounder reward, which is a fraction of the uncollected fees, reaches the gas cost for executing the operation. In practice, the number of compoundings will be slightly lower because ***compoundors*** will execute the function when it is profitable.

The number of compoundings that will be executed is a function of the estimated APY, this makes calculating these values self-referential. One way to approximate the number of compoundings is to compute the APY assuming continuous compounding which gives us an upper bound, to get a lower bound we can calculate the number of compoundings possible given the non-compounded APR. In reality the real value will fall between these bounds, for the purposes of our calculations we use $n\_{min}$ which is precise enough for realistic P and APR values.

![](https://1849061604-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FwVXi8b0BXAXDUzfJDx1d%2Fuploads%2Fgit-blob-bd5f739c90ef9a8249b74e558f1c20916dec277d%2FScreenshot%20from%202022-07-17%2013-22-27.png?alt=media)

**Estimated APY**

To calculate the projected APY for an auto-compounded position we use the formula for compound interest with the estimated number of compoundings per year, and we subtract the protocol reward from the APR.

![](https://1849061604-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FwVXi8b0BXAXDUzfJDx1d%2Fuploads%2Fgit-blob-ed8f816de12008ffbd47d600cb5d3b54ed94f5fb%2FScreenshot%20from%202022-07-17%2013-22-34.png?alt=media)

**Compounding Improvement**

The expected improvement in performance for a position during a 1 year period is the difference between the APY and the APR.

![](https://1849061604-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FwVXi8b0BXAXDUzfJDx1d%2Fuploads%2Fgit-blob-6d8a78938b969efee01c3de8e1203bcc8ac6566d%2FScreenshot%20from%202022-07-17%2013-22-40.png?alt=media)

The below chart uses the estimated gas cost values from the table above and values of ***PREWARD=0.02***, ***CREWARD=0.01*** to estimate APY improvements, over a 1 year period, from compounding for positions of sizes 1k USD, 10k USD, 100k USD, and 1m USD.

![](https://1849061604-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FwVXi8b0BXAXDUzfJDx1d%2Fuploads%2Fgit-blob-865a92e41bc0a7463019d66b1fe7e93ad3a3ae33%2FyoltWV7.png?alt=media)

**A worked example**

Take a $10,000 position earning a 20% fee APR, so $2,000 per year in fees, with PREWARD = 0.02 and CREWARD = 0.01. A compound fires when the executor's share of pending fees (1%) covers the gas:

* On a chain where a compound costs $0.05 of gas, the trigger is $5 of pending fees: hundreds of compounds a year, effectively continuous compounding. Projected APY is roughly 21.7% against the 20% simple rate.
* At $12 of gas, the trigger is $1,200 of pending fees: fewer than two compounds a year, for an APY around 20.4%.
* The same parameters on a $1,000 position at $12 gas earn about $200 a year against a $1,200 trigger, so the compounder would fire only once every six years or so. Activating it is a one-time authorization transaction, so on any horizon you would realistically hold the position you are paying that gas for nothing: no ongoing fees, but nothing gained.

**When not to compound**

If your position is small, your fee APR modest, and your chain's gas expensive, the improvement rounds to zero, and the table above lets you compute exactly that before activating anything. Compounding also grows your exposure to the pair: every compounded dollar is new capital subject to divergence loss. If you would not add fresh capital to the pool today, collecting the fees is the consistent choice. See the [Compound or collect](https://docs.revert.finance/revert/playbooks/compound-or-collect) playbook for the full decision.


# Position Management

Liquidity providers not only can initiate their positions from Revert, but they can also manage them. The position management interface is available from the account and position pages, where LPs can Add or Withdraw Liquidity and Claim Fees.

Revert now saves you the hassle of swapping your assets, if you only have one of them, or even none, to create the perfect ratio when adding more liquidity and also when withdrawing or claiming.

{% hint style="success" %}
Position-management transactions that do not include a swap have no Revert fee. Swaps use dynamic pricing: eligible stablecoin pairs can pay as little as 0.01%, with the fee generally following the pool's fee tier. Revert's swap fee is shown before confirmation and is capped at 0.65%.
{% endhint %}

### Add liquidity

Using the connected wallet’s balances with a nifty slider to increase liquidity in the required proportions to any position.

If you don’t have the right proportions, toggle on the “enter custom amounts” option and we will swap them into the actual pool ratio.

<figure><img src="https://1849061604-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FwVXi8b0BXAXDUzfJDx1d%2Fuploads%2Fgit-blob-272fcf2a86daad41307cced81057cfd6a5c365da%2Fimage.png?alt=media" alt=""><figcaption></figcaption></figure>

Don’t worry if you have none or only one of the pool assets, click on the “add liquidity using” dropdown and select the token you want to use to add liquidity. Then, we will swap it into the pair and the actual pool ratio to increase the liquidity of your position.

<figure><img src="https://1849061604-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FwVXi8b0BXAXDUzfJDx1d%2Fuploads%2Fgit-blob-5bc8d6e104029cb7517b8d92ea2872c6d8c04f07%2Fimage.png?alt=media" alt=""><figcaption></figcaption></figure>

### Withdraw liquidity

After connecting your wallet, you are able to withdraw any amount of liquidity from a position you own.

If you need the withdrawn tokens in a particular currency, we can swap them for you in the same transaction, just need to select the currency from the “withdraw liquidity in” dropdown. Check the slippage settings and change it if you want to.

<figure><img src="https://1849061604-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FwVXi8b0BXAXDUzfJDx1d%2Fuploads%2Fgit-blob-1689ff03ff7f5b8e653f05d9a54d28837a2af180%2Fimage.png?alt=media" alt=""><figcaption></figcaption></figure>

### Claim fees

Collect fees from positions: You can likewise use the nifty slides to collect any amount of uncollected fees from a position you own. We can also save you the inconvenience of claiming and then swapping, only by selecting the new currency under the "Claim fees in" dropdown we will do it for you in only one transaction.

<figure><img src="https://1849061604-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FwVXi8b0BXAXDUzfJDx1d%2Fuploads%2Fgit-blob-c3691fa750574c46301a56902c753a451a8e5546%2Fimage.png?alt=media" alt=""><figcaption></figcaption></figure>

### Slippage

Slippage is the difference between the expected price of a trade and the executed price. It exists because sometimes the price updates so fast that it changes between starting and finishing the transaction.

In Revert, the slippage tolerance can be customized under the "settings button" for each transaction while using the position management features. If the price moves beyond this percentage, the transaction will revert.

<figure><img src="https://1849061604-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FwVXi8b0BXAXDUzfJDx1d%2Fuploads%2Fgit-blob-89e6b2b7cf0e6cbb2ffb2c9f54d2ae6e5c9c1b96%2Fimage.png?alt=media" alt=""><figcaption></figcaption></figure>

* Add liquidity slippage: Refers to the accepted price difference when adding assets to a position.
* Withdraw slippage: Is the tolerated difference between the amount shown in the site and the assets reaching your wallet when withdrawing.
* Swap slippage: Is the possible difference between the assets prices when using our swap transactions.

{% hint style="success" %}
Revert's swap fee varies by pool and transaction. Eligible stablecoin pairs can pay as little as 0.01%, with the fee generally following the pool's fee tier. The applicable fee is shown before confirmation and is capped at 0.65%.
{% endhint %}

## Supported Protocols

Position management is currently available for:

* **Uniswap V3:** Ethereum, Polygon, Optimism, Arbitrum
* **Uniswap V4:** Ethereum mainnet, Unichain
* **Aerodrome:** Base


# Auto-Exit

Auto-Exit lets you pre-configure a position so that the liquidity is automatically withdrawn when the pool price reaches a predetermined value. Moreover, you can optionally configure the system to swap from one token to the other on withdrawal, providing a safety net for your investments akin to a stop-loss order.

<figure><img src="https://1849061604-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FwVXi8b0BXAXDUzfJDx1d%2Fuploads%2Fgit-blob-6ab92b9481269e659472c3ad397dd5fc5f066661%2Fimage.png?alt=media" alt=""><figcaption></figcaption></figure>

## Maximum Price Impact

During auto-exit swaps, the contract cross-verifies with the pool's TWAP oracle to prevent potential price manipulation. While setting up an auto-exit position, you choose a maximum price impact for swaps. This determines the permissible deviation between the pool price at the time of execution and the actual swap price, accounting for the pool fee, swap price impact and possible slippage.

Revert bots perform swaps sourcing liquidity from the 0x protocol, considering the max price impact as the swap execution threshold. All swaps can be confirmed on-chain, with 0x ensuring optimal pricing and providing slippage protection when available.

When swaps are executed on auto-exit operations, the contract runs a check against the pool TWAP oracle to avoid price manipulations of the pool.

## Selecting a fee source

To set up auto-exit on a position, you need to decide the source for paying protocol fees and gas costs. You have two options: a portion of the total position assets or a portion of the uncollected fees.

1. **Position Assets**: The protocol fee is 0.15%. Any percentage chosen above this will contribute to the gas budget. Note that if the gas budget is too low due to high gas prices at the time of auto-exit, the action won't trigger. Therefore, it's crucial to anticipate gas price fluctuations and allocate a sufficiently high percentage to ensure coverage. Surplus funds from the gas budget are returned to your wallet upon triggering the auto-exit.
2. **Uncollected Fees**: The protocol fee here is 2% of the uncollected fees at execution. The selected percentage should exceed this fee and sufficiently cover potential gas cost increases. Any excess in this scenario is also returned to your wallet upon triggering the auto-exit.

## Left-over tokens

When auto-exit is configured to be executed when a position is still in-range there may be slippage when removing the liquidity. This may lead to a few left-over tokens after swapping, because not all available tokens may be swapped. These will be sent to the position owner in the same transaction.

However, the operator (bots) are incentivized to maximize the capital used, because when swapping is configured, their fee is derived from the tokens which are successfully swapped to the target token.


# Auto-Range

Auto-Range automates the process of rebalancing your liquidity positions. When the token price moves and your position goes out-of-range by your selected percentage, Auto-Range springs into action. The system then automatically rebalances your position, by withdrawing the liquidity and recreating it with the same range width but centered around the current price, ensuring your liquidity stays in-range and collecting fees always.

<figure><img src="https://1849061604-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FwVXi8b0BXAXDUzfJDx1d%2Fuploads%2Fgit-blob-f22954ad0f5563c9377c3691aa63e53bb60659bd%2Fimage.png?alt=media" alt=""><figcaption></figcaption></figure>

## Maximum Price Impact

During auto-range swaps, the contract cross-verifies with the pool's TWAP oracle to prevent potential price manipulation. While setting up an auto-exit position, you choose a maximum price impact for swaps. This determines the permissible deviation between the pool price at the time of execution and the actual swap price, accounting for the pool fee, swap price impact and possible slippage.

Revert bots perform swaps sourcing liquidity from the 0x protocol, considering the max price impact as the swap execution threshold. All swaps can be confirmed on-chain, with 0x ensuring optimal pricing and providing slippage protection when available.

When swaps are executed on auto-exit operations, the contract runs a check against the pool TWAP oracle to avoid price manipulations of the pool.

## Selecting a fee source

To set up auto-range on a position, you need to decide the source for paying protocol fees and gas costs. You have two options: a portion of the total position assets or a portion of the uncollected fees.

1. **Position Assets**: The protocol fee is 0.15%. Any percentage chosen above this will contribute to the gas budget. Note that if the gas budget is too low due to high gas prices at the time of auto-exit, the action won't trigger. Therefore, it's crucial to anticipate gas price fluctuations and allocate a sufficiently high percentage to ensure coverage. Surplus funds from the gas budget will not be spent and will be used as capital for the next position.
2. **Uncollected Fees**: The protocol fee here is 2% of the uncollected fees at execution. The selected percentage should exceed this fee and sufficiently cover potential gas cost increases. Any surplus funds from the gas budget will not be spent and will be used as capital for the next position.

## Left-over tokens

Given the fact, that swaps are executed via 0x as a swap aggregator and many other swaps may happen at the same time, it is impossible to calculate a swap which results in the exact proportion of tokens to be added to the new position. This may lead to a few left-over tokens after minting the new position. These will be sent to the position owner in the same transaction.

The operator (bots) are incentivized to maximize the capital added, because their gets their fees are calculated from the tokens added to the new position.


# Revert Lend

Revert Lend is lending built for liquidity providers. Your LP position becomes collateral without stopping being an LP position: it keeps earning, you keep managing it, and the automation tools keep working on it while it backs your loan.

Use Uniswap v3 positions, or [Aerodrome positions on Base](https://docs.revert.finance/revert/aerodrome), as collateral to borrow USDC. Aerodrome collateral stays staked in its gauge, keeps earning AERO, and can auto-compound while the loan is open. Lend is integrated directly into the normal position management UI: there is no separate app to learn.

### What you can do

* Borrow USDC against your LP position: [Borrowing](https://docs.revert.finance/revert/revert-lend/borrowing)
* Lend USDC and earn the interest borrowers pay: [Lending](https://docs.revert.finance/revert/revert-lend/lending)
* Repay any time, in full or in part, with outside funds or from the collateral itself: [Repaying](https://docs.revert.finance/revert/revert-lend/repaying)
* Withdraw your lent USDC: [Withdrawing](https://docs.revert.finance/revert/revert-lend/withdrawing)
* Lever a position in a single transaction: [Leverage](https://docs.revert.finance/revert/revert-lend/leverage)
* Understand how unhealthy loans are closed: [Liquidations](https://docs.revert.finance/revert/revert-lend/liquidations)

### Automation keeps working

Auto-Range and Auto-Compound work on collateralized positions the same way they do on any other position. For Aerodrome collateral this includes [AERO auto-compounding](https://docs.revert.finance/revert/aerodrome/aero-auto-compounding).


# Borrowing

Your position does not stop working when you borrow against it. Deposit the LP NFT into the vault and borrow USDC in the same transaction. The position stays yours to manage from the normal position page, and it keeps earning while it backs the loan. It remains locked in the vault until the loan is repaid.

<figure><img src="https://1849061604-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FwVXi8b0BXAXDUzfJDx1d%2Fuploads%2Fgit-blob-e2a1b05a4d9c2b7577008b9553c9a2f3bde9ca49%2Fborrow%201.png?alt=media" alt=""><figcaption></figcaption></figure>

### How much you can borrow

Your borrowing power is the position's value scaled by the pair's collateral factor, using the lower of the two tokens' factors, then held to a 95% safety buffer so a fresh loan does not start right at the liquidation line. The position page shows your actual available-to-borrow figure; size against that rather than the raw collateral-factor value. Borrowed funds are issued in the vault's lending asset, USDC, and are yours to deploy immediately.

### Interest

The borrow rate floats with utilization of the lending pool and accrues continuously into your debt balance. There is no fixed term and no repayment schedule. The only standing requirement is that the loan stays healthy.

### Loan health

Loan health is one comparison: collateral value, after collateral factors, against outstanding debt.

<figure><img src="https://1849061604-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FwVXi8b0BXAXDUzfJDx1d%2Fuploads%2Fgit-blob-a02f32b47e005cd27f053b683a77370a6aef69d3%2Fborrow2.png?alt=media" alt="" width="375"><figcaption></figcaption></figure>

Three things move it:

* **Interest** grows the debt side continuously.
* **Pool prices and divergence loss** move the collateral side, in both directions.
* **Your own actions**: adding liquidity or repaying widens the gap; withdrawing or borrowing more narrows it.

While the collateral value exceeds the debt, the loan is in good standing. If the debt crosses above the collateral value, the loan becomes liquidatable: see [Liquidations](https://docs.revert.finance/revert/revert-lend/liquidations) for exactly what happens then and what it costs. Watching the gap, and knowing which of the three inputs is moving it, is the whole job of managing a loan.


# Lending

The other side of every loan is a lender earning the interest. Deposit USDC into the lending pool and you receive rlUSDC, a vault share following the ERC-4626 standard. Your yield is the interest borrowers pay, denominated in USDC: no lockups, no reward emissions to sell.

<figure><img src="https://1849061604-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FwVXi8b0BXAXDUzfJDx1d%2Fuploads%2Fgit-blob-3ac76861d357bd94edaa0ba861e61a08a98b77f1%2FCaptura%20de%20pantalla%202024-08-30%20a%20la(s)%2012.10.14%E2%80%AFp.m..png?alt=media" alt=""><figcaption></figcaption></figure>

### How the yield accrues

rlUSDC appreciates against USDC. The exchange rate starts at 1 and rises as borrowers pay interest into the pool; redeeming your shares later returns more USDC than you deposited. For illustration: deposit 10,000 USDC at an exchange rate of 1.00 and you hold 10,000 rlUSDC. If accrued interest has moved the rate to 1.06 when you redeem, your shares return 10,600 USDC.

Your realized rate depends on utilization: interest is only paid on the portion of the pool that is actually borrowed. High utilization means more interest per deposited dollar, but also less idle liquidity, which matters when you want out: see [Withdrawing](https://docs.revert.finance/revert/revert-lend/withdrawing).


# Repaying

Repay in full whenever you want: there is no schedule and no penalty for early repayment, and your debt is simply the borrowed amount plus accrued interest, tracked by the debt exchange rate. Partial repayments work too, with one constraint: a partial repayment must leave your remaining debt at or above the vault's minimum loan size. To clear a balance below that, repay in full. Every repayment reduces your debt directly.

<figure><img src="https://1849061604-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FwVXi8b0BXAXDUzfJDx1d%2Fuploads%2Fgit-blob-ee4743105476702a0cec9ba8957dc42c07ed93e9%2Frepay1.png?alt=media" alt=""><figcaption></figcaption></figure>

### Repaying from the collateral

You do not need outside funds to deleverage. Part of the position itself can be swapped into the borrowed token and used to repay, atomically in a single transaction. This is the lever that lets you cut debt in response to market moves without touching your wallet.

<figure><img src="https://1849061604-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FwVXi8b0BXAXDUzfJDx1d%2Fuploads%2Fgit-blob-012f3146eb5c8b1a4e0310536b07a604a075f2bf%2Frepay2.png?alt=media" alt="" width="563"><figcaption></figcaption></figure>

<figure><img src="https://1849061604-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FwVXi8b0BXAXDUzfJDx1d%2Fuploads%2Fgit-blob-e93defea6c2ce70f68cfe1334e50789ac0eb66d1%2Frepay3.png?alt=media" alt="" width="563"><figcaption></figcaption></figure>

### Closing out

Once the debt is fully repaid, including accrued interest, the position is released from the vault back to your full control: manage it, move it, or withdraw it as you see fit.


# Withdrawing

Redeem your rlUSDC and you receive USDC at the current exchange rate: your principal plus your share of the interest accrued since you deposited.

<figure><img src="https://1849061604-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FwVXi8b0BXAXDUzfJDx1d%2Fuploads%2Fgit-blob-348a31d00a6628f47e05178d62b3cc1997d55d89%2FCaptura%20de%20pantalla%202024-08-30%20a%20la(s)%2012.14.05%E2%80%AFp.m..png?alt=media" alt=""><figcaption></figcaption></figure>

### When the pool is heavily utilized

Your USDC is not sitting idle: it is lent out, which is where the yield comes from. If most of the pool is currently borrowed, there may not be enough idle liquidity to fill your full withdrawal immediately. The protocol does not pretend otherwise, and it does not guarantee instant exit at high utilization.

What restores liquidity is the interest rate model. A drained pool pushes the borrow rate up, which makes carrying debt more expensive and repayment more attractive, and makes lending more attractive at the same time. Repayments and new deposits refill the idle buffer, and your withdrawal can complete. If you anticipate needing fast access to your funds, watch the pool's utilization: it is the single number that determines how quickly you can exit.


# Leverage

Leverage turns borrowing power into position size: borrow USDC against your position, swap it into the pool's tokens, and add them back to the same position, all in a single transaction. The result is a larger position earning on borrowed capital, with debt interest accruing until the loop is unwound.

### The loop

1. **Borrow** against the position's collateral value, up to the pair's collateral factor.
2. **Swap** the borrowed USDC into the position's tokens at the ratio the range requires.
3. **Reinvest** the proceeds into the same position, increasing its liquidity.

Each pass increases both the position and the debt, so the available headroom shrinks with every iteration: the collateral factor caps how far the loop can go. Unwinding works the same way in reverse, removing liquidity, swapping, and repaying in one transaction. See [Repaying](https://docs.revert.finance/revert/revert-lend/repaying).

<figure><img src="https://1849061604-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FwVXi8b0BXAXDUzfJDx1d%2Fuploads%2Fgit-blob-ba0c272718163c2f95cac9f823d2c33c934d54c2%2Fleverage1.png?alt=media" alt=""><figcaption></figcaption></figure>

### What leverage actually does

Leverage scales both sides of your trade. Fee income grows with the larger position; so do divergence loss and the debt's interest cost. The carry works while the position's income rate exceeds the borrow rate, and the borrow rate floats. A levered position also sits closer to liquidation than an unlevered one by construction: the same price move that dents an unlevered position can end a levered one. And where a direct borrow is held back to a 95% safety buffer, a leverage loop can be built right up to the collateral-factor limit, so a freshly maxed loop can sit at the edge of liquidation from the start. Size the loop so that the moves you consider normal for the pair leave your loan health intact. See [Liquidations](https://docs.revert.finance/revert/revert-lend/liquidations).


# Liquidations

Liquidation is not an event that strikes from nowhere. It is a distance you can read and manage: the gap between your collateral value, after collateral factors, and your debt.

### Position health

A loan is healthy while the collateral value exceeds the debt. The gap closes from two directions: interest accrues into the debt continuously, and the collateral side moves with pool prices and divergence loss. When the debt crosses above the collateral value, the loan becomes liquidatable.

<figure><img src="https://1849061604-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FwVXi8b0BXAXDUzfJDx1d%2Fuploads%2Fgit-blob-01df7e73d7b4891f521aeae30f25a3dc079bc00c%2Fliquidation1.png?alt=media" alt="" width="373"><figcaption></figcaption></figure>

### What a liquidation costs you

Any account can liquidate an unhealthy loan: the liquidator repays your outstanding debt and receives collateral worth the debt plus a liquidation penalty. The penalty ranges from 2% to 10% of the debt value, scaling with how far the debt has run past the collateral value, so a loan caught just past the line costs far less than one deep underwater.

If the position is still worth more than your debt plus the penalty, the liquidator takes that much and the remainder is returned to you: you lose the penalty and keep the rest. That is the good case, and it depends on being liquidated in time. If a fast move pushes your debt plus penalty above the position's entire value, there is no remainder: the liquidator takes the whole position and you get nothing back, and the shortfall becomes bad debt that the pool's reserves, and ultimately lenders, absorb. Liquidation defends the pool's solvency, not your residual value. The only reliable protection is managing the distance before you reach the line.

### Liquidator bots

Liquidation is open and permissionless by design. Revert publishes an open-source reference bot at the [liquidator-js repository](https://github.com/revert-finance/liquidator-js) and runs it as a backstop, but anyone can operate one, and we encourage it: more independent liquidators means unhealthy debt is cleared faster and the lending pool stays solvent for everyone.


# Aerodrome on Base

Revert supports [Aerodrome Slipstream](https://aerodrome.finance/) concentrated-liquidity positions on Base, with the same tooling you already use for Uniswap, plus the parts that are specific to Aerodrome.

![AERO position on Revert](https://1849061604-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FwVXi8b0BXAXDUzfJDx1d%2Fuploads%2Fgit-blob-0cec95d5bbaa186982a52cfab627a88caee62f74%2FAERO-position.png?alt=media)

## What you can do

* **Track performance** of your Aerodrome Slipstream positions with Revert's full analytics: PnL, fee APR, rewards APR, impermanent loss, and historical charts.
* **Manage positions** directly from the Revert interface: add or remove liquidity, change ranges, and swap through the best available route.
* **Earn and track AERO rewards.** Aerodrome positions earn AERO emissions when staked in a pool's gauge. Revert stakes your position for you and shows your unclaimed and claimed rewards alongside your fees. See [Staking & AERO rewards](https://docs.revert.finance/revert/aerodrome/staking-and-rewards).
* **Auto-compound your AERO.** Reinvest emitted AERO back into your position automatically, growing your liquidity over time without manual steps. See [AERO auto-compounding](https://docs.revert.finance/revert/aerodrome/aero-auto-compounding).
* **Automate ranges and exits.** Auto-Range and Auto-Exit work on Aerodrome positions the same way they do on Uniswap.
* **Borrow against your position.** Use an Aerodrome position as collateral in [Revert Lend](https://docs.revert.finance/revert/revert-lend) on Base, and keep earning AERO while you borrow. See [Using staked positions as collateral](https://docs.revert.finance/revert/aerodrome/staked-lp-as-collateral).

## What's different about Aerodrome

On Uniswap, a position earns swap fees only. On Aerodrome, a staked position earns **AERO emissions** through the pool's gauge instead of swap fees: staked liquidity's trading fees go to veAERO voters, so a position earns either fees (unstaked) or AERO (staked), never both. To make those rewards work for you without extra clicks, Revert takes custody of the staked position through its GaugeManager contract so it can claim rewards, compound them, and keep the position staked, all while you retain full control to manage, withdraw, or borrow against it at any time.

The Aerodrome-specific topics are covered here:

* [Staking & AERO rewards](https://docs.revert.finance/revert/aerodrome/staking-and-rewards)
* [AERO auto-compounding](https://docs.revert.finance/revert/aerodrome/aero-auto-compounding)
* [Using staked positions as collateral](https://docs.revert.finance/revert/aerodrome/staked-lp-as-collateral)

All Aerodrome contracts and their audit are listed in [Contract Addresses](https://docs.revert.finance/revert/resources/contract-addresses) and [Security](https://docs.revert.finance/revert/resources/security).


# Staking & AERO rewards

Aerodrome rewards liquidity providers with AERO emissions instead of swap fees. A position earns one or the other, never both: while staked in the pool's gauge it earns AERO emissions and its share of trading fees goes to veAERO voters; while unstaked it earns swap fees and no emissions.

Emissions are only paid to staked positions, so Revert handles staking for you: your position earns rewards from the moment it is created, and those rewards are shown on the position page.

![AERO Rewards](https://1849061604-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FwVXi8b0BXAXDUzfJDx1d%2Fuploads%2Fgit-blob-b42b52ff5832f8d3457f68acd7de0a723dc89a1f%2FAERO-rewards.png?alt=media)

## How staking works on Revert

When you create or deposit an Aerodrome position through Revert, the position is staked in the corresponding Aerodrome gauge. To do this on your behalf while keeping your funds safe, the staked position is held by Revert's **GaugeManager** contract, which is the custody layer for Aerodrome on Revert.

This is what lets Revert:

* Claim AERO emissions for your position.
* Auto-compound those emissions back into the position (see [AERO auto-compounding](https://docs.revert.finance/revert/aerodrome/aero-auto-compounding)).
* Keep the position staked and earning while you manage it, change its range, or use it as collateral in Revert Lend.

You keep full control of the position at all times. You can withdraw, remove liquidity, or stop using Revert's tooling whenever you choose.

## Tracking your rewards

On the position page you will see, alongside your fees:

![Uncollected AERO Rewards](https://1849061604-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FwVXi8b0BXAXDUzfJDx1d%2Fuploads%2Fgit-blob-8524d8cfdbdd601e15a9ddad26aff895ccb17c17%2FAERO-rewards-uncollected.png?alt=media)

* **Unclaimed rewards** - AERO that has accrued to your position and is not yet claimed.
* **Claimed rewards** - AERO that has already been claimed for the position, including amounts that were claimed and reinvested by auto-compounding.

Reward values are shown in AERO and in your reference currency, and are included in the position's rewards APR so you can compare opportunities on a like-for-like basis.

## Claiming

Rewards are claimed for you as part of normal operations such as auto-compounding, range changes, or withdrawals. The claimed amounts are recorded in the position's history so your reward earnings are always reflected in your performance figures.


# AERO auto-compounding

Auto-compounding on Aerodrome reinvests the AERO emissions your position earns back into the position, automatically and at optimal times. Your liquidity grows over time without you having to claim, swap, and re-deposit by hand.

This is the Aerodrome counterpart to the [Auto-compounder](https://docs.revert.finance/revert/auto-compounder) you may already use for Uniswap fees. The difference is what gets compounded: on Uniswap it is the accrued swap fees, while on Aerodrome it is the **AERO rewards** emitted by the gauge.

![AERO Auto-Compounding](https://1849061604-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FwVXi8b0BXAXDUzfJDx1d%2Fuploads%2Fgit-blob-bf690f330f08994f632dd5c70ed7dc748eeb832d%2FAERO-auto-comp-cursor2.png?alt=media)

## How it works

Once enabled, the auto-compounder periodically:

1. **Claims** the AERO emissions accrued to your position.
2. **Swaps** the AERO into the position's tokens at the right ratio for its current range.
3. **Reinvests** the result as additional liquidity in the position.
4. **Restakes** the position so it keeps earning emissions.

All of this happens automatically in a single transaction, performed by the Revert protocol's audited contracts, so you never need to act yourself. Auto-compounding only reinvests your rewards back into your own position; it cannot move your funds anywhere else.

## When it compounds

A compound only happens when it is worthwhile. Compounding occurs once the accrued rewards are large enough to cover a **1% gas fee** and a **1% protocol fee**. This makes sure small amounts are not compounded at a loss to gas, and that compounding happens at efficient times relative to your rewards.

## Tracking compounds

On the position page, the auto-compound panel shows:

![AERO Auto-Compounding](https://1849061604-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FwVXi8b0BXAXDUzfJDx1d%2Fuploads%2Fgit-blob-0d8c1b14bdfda7f9253e6e00a526a52f8307bfed%2FAERO-auto-comp.png?alt=media)

* **Rewards APY with auto-compounding** and the improvement over not compounding.
* **Amounts reinvested** - the token amounts that have been compounded back into the position.
* **Auto-comps executed** - how many times your position has been compounded.

These figures update as compounds happen, so you can see the effect on your position over time.

## Managing auto-compounding

You can enable or disable auto-compounding from the position page at any time. While a position is auto-compounding you can still manage it normally: add or remove liquidity, change its range, or use it as collateral in [Revert Lend](https://docs.revert.finance/revert/revert-lend).


# Using staked positions as collateral

Aerodrome positions staked through Revert can be used as collateral in [Revert Lend](https://docs.revert.finance/revert/revert-lend) on Base. The position stays staked in its gauge for the entire life of the loan, so it keeps earning AERO emissions while it backs your debt.

![Aerodrome position with an active USDC loan on Revert Lend](https://1849061604-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FwVXi8b0BXAXDUzfJDx1d%2Fuploads%2Fgit-blob-d2e1a77d6e1920d56a7597f80bed37b5ec1ed214%2FAERO-lend-collateral.jpg?alt=media)

## How it works

1. Deposit the position into the Revert Lend vault and borrow against it, in a single step. Borrowed tokens are issued in the vault's lending asset, USDC. See [Borrowing](https://docs.revert.finance/revert/revert-lend/borrowing).
2. The vault keeps the position staked through Revert's [GaugeManager](https://docs.revert.finance/revert/aerodrome/staking-and-rewards). AERO emissions continue to accrue to you while the position is locked as collateral.
3. Your borrowing power is determined by the position's value and the lower of the two assets' collateral factors, the same as any other Lend collateral.
4. You can claim AERO or [auto-compound](https://docs.revert.finance/revert/aerodrome/aero-auto-compounding) it while the loan is open. Compounded rewards grow the position, which grows your collateral value.

## What your collateral earns

While staked in an Aerodrome gauge, a position earns AERO emissions instead of swap fees: trading fees generated by staked liquidity go to veAERO voters. The yield on your collateral is therefore the position's rewards APR, not a fee APR. If you unstake, the position earns swap fees again and stops receiving emissions. A position never earns both at once.

## The carry

Borrowing against a productive position is a spread trade. Your collateral earns the rewards APR while your debt accrues the borrow rate, and the loop only works while the first exceeds the second.

For illustration: a $10,000 staked position at a 40% rewards APR accrues about $11 per day in AERO. Borrowing $5,000 against it at a 15% borrow rate accrues about $2 per day in interest. That carry is not fixed:

* Emissions are re-voted every weekly epoch, and their dollar value moves with the AERO price.
* The borrow rate floats with utilization of the lending pool.

A position that is positive carry today can turn negative without any price movement in your pool. Check both legs, not just the rewards side.

## Levering the position

The carry can be levered: borrow USDC against the staked position, swap it to the pool's tokens, add them back to the same position, and restake. Revert executes the whole loop, including the unstake and restake around it, in a single transaction. The result is a larger staked position earning emissions on borrowed capital, with debt interest accruing until the loop is unwound. See [Leverage](https://docs.revert.finance/revert/revert-lend/leverage) for the general mechanics.

![Leverage loop for staked Aerodrome positions](https://1849061604-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FwVXi8b0BXAXDUzfJDx1d%2Fuploads%2Fgit-blob-8af0d519dbd62ca740d449993214dbe3f138c424%2FAERO-lend-leverage-loop.png?alt=media)

Leverage scales both legs of the carry and shrinks the distance to liquidation. The risks below apply with more force, not less.

## Liquidation

Staked collateral follows the same health rules as any Lend position: if the debt exceeds the collateral value, the loan becomes liquidatable. See [Liquidations](https://docs.revert.finance/revert/revert-lend/liquidations).

Two details are specific to staked positions:

* The vault unstakes the position as part of the liquidation.
* AERO accrued and unclaimed up to that point is claimed and sent to you, the borrower. It is not part of what the liquidator receives.

The liquidation penalty of 2% to 10% of the debt applies as usual.

## Risks

* **Liquidation risk.** Your collateral is an LP position: its value moves with the pool's prices and with divergence loss. Leverage on top of LP exposure concentrates outcomes in both directions.
* **Floating borrow rate.** Interest accrues continuously and the rate is not fixed. Rising utilization raises your cost of carry.
* **Reward-token risk.** The earning leg is denominated in AERO. A falling AERO price reduces your rewards APR in dollar terms even if emissions are unchanged.
* **Epoch variability.** Gauge emissions depend on weekly veAERO votes. The rewards APR you see today is not a commitment.


# Stable Hooks

Stable Hooks are stableswap pools on Uniswap v4, built by Revert. Each pool holds 2 to 4 assets that trade at a steady ratio to each other (stablecoins, liquid-staking tokens, wrapped assets) and prices them with a StableSwap curve instead of v4's default constant-product math.

The result is a pool where you deposit once and every unit of your capital stays active. There are no price ranges to choose, no ticks to manage, and no positions drifting out of range. Liquidity is represented by plain ERC-20 LP tokens, and swap fees compound into the pool automatically, so your share grows without a claim step.

## Why it exists

Concentrated liquidity is a powerful tool for volatile pairs, but for assets that hold a steady ratio it turns LPing into ongoing work: small moves push the price outside tight ranges, and every adjustment costs time and gas. A StableSwap curve concentrates depth where correlated assets actually trade without any range management, which makes it the right instrument for this asset class.

For the assets themselves, the curve shape matters too: depth thins out gradually as the price moves instead of cliffing at a range boundary, so large trades keep getting filled and the same sell pressure moves the price less.

## What you can do with it

* **Provide liquidity.** Deposit 2 to 4 correlated assets, hold an ERC-20 LP token, earn fees on every swap. Withdraw any time; positions are fully non-custodial.
* **Create a pool.** Pool deployment is permissionless through the Stable Hooks factory, with configurable amplification and rate oracles for yield-bearing assets like wstETH.
* **Trade and route.** Pools live inside Uniswap v4, so they are reachable through the Universal Router and the standard v4 quoting stack from day one.
* **Run incentives.** Rewards on ERC-20 LP shares split pro-rata across all holders. There is no tick to camp, so a reward budget buys depth instead of games.

## Status

Stable Hooks is launching soon. Join the waitlist at [revert.finance/stablehooks](https://revert.finance/stablehooks) to get notified when deposits go live.

## Technical documentation

* [Architecture overview](https://docs.revert.finance/revert/technical-docs/stable-hooks): how the hook works, fees, amplification, rate oracles, pool deployment.
* [Integrating swaps](https://docs.revert.finance/revert/technical-docs/stable-hooks/integrating-swaps): for aggregators and routers sourcing liquidity from Stable Hooks pools, including gas benchmarks and stability guarantees.

## Security

The contracts were independently audited by PeckShield and went through a public audit competition on Cantina. Source: [github.com/revert-finance/stableswap-hooks](https://github.com/revert-finance/stableswap-hooks).


# Playbooks

The feature pages tell you what each tool does. Playbooks tell you when to reach for which, and how the tools combine into something none of them does alone. Each one walks a decision: the setup, the numbers that drive it, and the conditions under which you should do the opposite.

* [Compound or collect](https://docs.revert.finance/revert/playbooks/compound-or-collect): when reinvesting fees beats taking the income, by chain and position size.
* [Backtest before funding](https://docs.revert.finance/revert/playbooks/backtest-before-funding): choosing a range with evidence instead of instinct.
* [The staked-collateral carry](https://docs.revert.finance/revert/playbooks/carry-on-staked-aerodrome): running a borrow against a staked Aerodrome position, and the triggers for unwinding it.

The examples use round illustrative numbers. Live rates, gas costs, and emissions move; the decision structure is the part that holds.


# Compound or collect

Every fee your position earns sits in a separate balance until you do something with it. You have two options: collect it as income, or compound it back into the position as liquidity. The right answer depends on three numbers: your fee APR, your position size, and your chain's gas cost.

## What compounding buys you

Compounded fees become principal, and principal earns fees. The improvement is the difference between simple and compound growth, and it only materializes if compounding happens often, which is what the [Auto-compounder](https://docs.revert.finance/revert/auto-compounder) automates: compounds fire when the pending fees justify the gas.

## The numbers

For illustration, take a $10,000 position earning a 20% fee APR ($2,000 per year in fees), with the auto-compounder's 2% performance fee, of which half goes to the executor who pays the gas. A compound fires when the executor's share of pending fees covers the gas cost:

* **On Base** (gas well under $1), compounds fire at a few dollars of pending fees: hundreds of compounds per year, effectively continuous. Projected APY is about 21.7% versus the 20% simple rate. Compounding is close to free money here.
* **On mainnet** (call it $12 of gas), a compound fires only once pending fees reach about $1,200. That is fewer than two compounds per year: APY around 20.4%. Still positive, but thin.
* **The same setup at $1,000 position size on mainnet** effectively never compounds: the position earns about $200 a year in fees against a $1,200 trigger, so it would take roughly six years to fire once. Activating the auto-compounder is a one-time authorization transaction, so on any horizon you would realistically hold this position you are paying that gas for nothing: no ongoing fees, but nothing gained. Collect manually instead.

The pattern: compounding improvement scales with fee APR, position size, and cheap gas. On L2s and Base it is nearly always worth it. On mainnet, do the arithmetic above with your own numbers first; the [performance improvement](https://docs.revert.finance/revert/auto-compounder/performance-improvement) page has the full formulas.

## When to collect instead

* **You want the income.** Compounding grows your LP exposure; collecting realizes it. If the position is your yield source rather than your growth vehicle, collect.
* **You want to cap exposure to the pair.** Compounded fees are capital newly exposed to divergence loss. If you would not add fresh money to this pool today, reconsider compounding into it either.
* **The position is about to change.** If a range move or exit is coming, there is little point compounding fees you are about to reposition anyway.

On Aerodrome the same logic applies to AERO emissions instead of swap fees, with one extra variable: compounding converts AERO into pool tokens at the current price, which also closes your exposure to AERO price moves. See [AERO auto-compounding](https://docs.revert.finance/revert/aerodrome/aero-auto-compounding).


# Backtest before funding

Range width is the biggest decision you make when opening a concentrated-liquidity position, and most LPs make it by instinct. You do not have to: the position creation flow includes a backtester that replays your exact range against the pool's history before you commit capital.

## The trade-off you are pricing

A tighter range concentrates your liquidity, which raises your share of fees while the price is inside it, and raises everything else too: time spent out of range earning nothing, divergence loss when the price crosses your bounds, and rebalancing frequency. A wider range earns a lower rate more reliably. Neither is better in general. Which is better for a specific pool depends on how that pool's price actually moves, which is an empirical question, and empirical questions deserve data.

## Using the backtester

In [Create Position](https://docs.revert.finance/revert/initiator), set your candidate range and run the backtester. It replays the position against the pool's historical data and reports projected fees earned, impermanent loss or gain, and the result compared against simply holding the tokens. Run it for the tight version and the wide version of the range you are considering, and compare the net outcomes, not the fee numbers alone: a range that earned triple the fees and lost more than the difference to divergence is the worse trade dressed as the better one.

Two caveats to keep in front of you:

* **Accuracy correlates with time in range.** The technique is built on periodic pool snapshots, and it is most reliable for ranges that would have stayed in range most of the period. Results for very tight ranges carry more uncertainty, which is exactly when you should be most skeptical of a flattering number.
* **Fee dilution.** The backtest assumes historical volume against historical liquidity. Adding large capital to a small pool dilutes the fee rate for everyone, including you: adding $10M to a $5M pool will not earn what the history suggests. The creation flow flags this.

## The discipline

A backtest is history, not a forecast. What it actually gives you is a falsifiable baseline: how this range would have behaved in regimes the pool has already seen. If a range only works in the backtest's calmest stretch, you have learned what conditions you are betting on, and that knowledge is the real product. Fund the position when you can say which regime you expect, not just which number you liked. Once funded, the position page tells you whether reality is tracking the test: see [How Revert measures performance](https://docs.revert.finance/revert/position-analytics/how-revert-measures-performance).


# The staked-collateral carry

A staked Aerodrome position earns AERO emissions. Used as Lend collateral, it keeps earning them while backing a USDC loan. The spread between the rewards APR and the borrow rate is a carry you can run deliberately, and this page is the operational checklist for running it: what to check before entering, what to watch while it is on, and the three triggers for taking it off. The mechanics live on [Using staked positions as collateral](https://docs.revert.finance/revert/aerodrome/staked-lp-as-collateral); this is the decision layer.

## Before entering

1. **Confirm the income leg.** The pool's rewards APR is your collateral's yield; while staked it earns no swap fees, so this one number is the entire earning side. Remember it is a pool-wide estimate that assumes even liquidity distribution: your realized rate depends on your concentration relative to the rest of the pool's staked liquidity, and on staying in range.
2. **Confirm the cost leg.** The USDC borrow rate floats with utilization. Check it at current utilization and ask what it becomes if utilization rises.
3. **Size the borrow for the move you consider normal.** Your loan health absorbs pool price moves and divergence loss before liquidation becomes possible. Borrow so that an ordinary week in this pair leaves comfortable distance. The collateral factor caps what you can take; it is not a target.

## While the carry is on

Watch three things, roughly in order of how fast they change:

* **Range.** A staked position that drifts out of range earns nothing while the debt keeps accruing interest. The carry flips negative automatically, with no price crash and no rate spike required. This is the most common way the trade quietly dies.
* **The weekly epoch.** Emissions are re-voted every week, and the rewards APR moves with the vote and with the AERO price. The income leg you entered with is not the income leg you hold.
* **Loan health.** Interest compounds into the debt continuously; the collateral side moves with the pool. The [liquidation](https://docs.revert.finance/revert/revert-lend/liquidations) penalty runs 2% to 10% of the debt, which prices exactly what inattention costs here.

Auto-compounding the AERO back into the position grows your collateral, which widens your liquidation distance over time: the carry partially defends itself if you let it.

## Unwind triggers

Decide these before entering, not during the event:

* **Carry compression.** Borrow rate up, rewards APR down, or AERO weakness: when the spread no longer pays for the liquidation risk you are warehousing, the trade is over even if nothing has gone wrong yet.
* **Range break you do not expect to mean-revert.** Out of range, the position is a non-earning asset securing an interest-bearing debt. Either move the range or close the loop.
* **Loan health approaching your floor.** Repay partially from the position itself if needed: see [Repaying](https://docs.revert.finance/revert/revert-lend/repaying). Your floor should be a number you wrote down on day one.

The honest summary: this trade pays you a floating spread for warehousing liquidation risk and AERO price risk. Run it when both legs are visible to you and the exit rules are pre-committed; skip it when you would be checking the position page once a week and hoping.


# Auto-compounder

Auto-compounder functionality for Uniswap v3 is provided by the **Revert Compoundor protocol** which allows for the automation through awarding executors (compoundors) a small fee to compensate for their gas costs, and a simple mechanism that incentivizes the compounding of positions as close to optimal as possible.\
\
Unlike its predecessor, in Uniswap v3, swap fees taken by the protocol for LPs do not accumulate inside the pool, but in a separate balance for each position. One consequence of this is that fees are not compounded automatically back into the position.\
\
Manual compounding of fees is possible, but it is a cumbersome process composed of the following steps:

1. Collecting fees via the NFT Manager contract.
2. Checking the amount**s** of token0/token1 required to swap so as to maximize the amount of liquidity added to the position.
3. Perform the swap without getting sandwiched.
4. Add the swapped amounts as liquidity to the position.

\
**Costs associated with compounding fees**\
\
Given the above described contract interactions, compounding fees can result in high gas costs. The decision of when to compound fees falls on a protocol mechanism that incentivizes frequency of compounding fees without the costs being a significant portion of the collected fees.\
\
The protocol allows a designated operator account, at any point, to call the autoCompound function. The operator will have to pay for the gas costs of making this transaction, and in exchange the protocol gets 2% of the uncollected fees compounded into the position.

### Protocol Roles

#### **Position owners**

Any account that adds his Uniswap v3 position to the Compounder contract and benefits from auto-compounding.

#### **Compoundors**

Any account that participates in auto-compounding positions deposited in the Compounder contract. Compoundors monitor collected fees, token prices and gas price to decide when to execute auto-compound operations, and win a part of the compounded fees as a reward (and to account for the gas cost of calling the auto-compounding function).

#### **Contract deployer**


# Backtester

We’ve published the [backtester code](https://github.com/revert-finance/revert-backtester) as a [ClojureScript](https://clojurescript.org/) library under the MIT license.

{% embed url="<https://github.com/revert-finance/revert-backtester>" %}

The backtesting technique for Uniswap v3 LP positions that we use, relies on periodic pool snapshot data, such as that provided by the Uniswap v3's subgraph *poolHourData* entities.

This technique is fairly accurate, though the accuracy will be correlated with the proportion of time that a position would have been in range given its selected price ranges. It also has the advantage of being pretty fast.

When the Initiator backtester was launched we ran an accuracy test to check its performance, the results can be found in [this post](https://medium.com/@revert_finance/presenting-the-initiator-3450f63d6b7e).


# Self-compounder

The SelfCompoundor contract allows users to manually compound their Uniswap V3 NFT positions. When positions are sent to this contract, they are swapped into correct ratio, compounded and returned in the same transaction. Any remaining tokens after swapping and compounding are always returned to the position owner.

A 1% protocol fee (performance fee) is taken from the compounded amounts.

### Deployed contracts

#### SelfCompoundor Contract

* Polygon: <https://polygonscan.com/address/0xad58D1DF63AFcf090Cc930475db3dD3cD8f739eA>
* Ethereum Mainnet: <https://etherscan.io/address/0xB50a397543fB2c7D08c53D5f5331AD8990D3B48f>
* Arbitrum: <https://arbiscan.io/address/0xb43a613f0dd19af1cb1f5d03d8e8e5af04d9f0a1>
* Optimistic Ethereum: <https://optimistic.etherscan.io/address/0x3C0Fd0B42aa46F03f6cF5e305Ed9B2Ce402847eF>
* BNB Chain: <https://bscscan.com/address/0x69437b43805C9fFF78eC63394474a48C69DD8DA6>
* EVMOS: <https://escan.live/address/0xc35539ff16b60ebc6bdcb376316f638288ccdd24>
* Robinhood Chain: <https://robinhoodchain.blockscout.com/address/0x7220E133D9889EB893efCF8663a82569bb629076>


# Auto-Exit

### How to activate a position

To setup a position it needs to be approved for the Auto-Exit contract (`approve` or `setApprovalForAll`) and the method `configToken()` must be called.

### How to remove a position

Call the `configToken()` function with all values set to default.

##


# Auto-Range

### How to activate a position

To setup a position it needs to be approved for the Auto-Exit contract with `setApprovalForAll` and the method `configToken()` must be called.

`setApprovalForAll` is mandatory here because it is the only way that the newly created positions are approved automatically.

### How to remove a position

Call the `configToken()` function with all values set to default.

##


# Revert Lend

Revert Lend is a decentralized peer-to-pool lending protocol designed for Automated Market Maker Liquidity Providers. It allows users to collateralize their Uniswap v3 liquidity provider positions, in the form of the Uniswap NFTManager NFTs, and obtain loans in a protocol-determined ERC-20 token. The protocol is specifically designed to allow Liquidity Providers to maintain control over the capital in their positions while they are collateralized. This feature facilitates uninterrupted management and optimization of LP positions, catering to the dynamic needs of liquidity providers.

### Main Contracts

#### V3Vault

The `V3Vault` contract allows users to deposit a specific ERC20 token (e.g., USDC) to earn interest or borrow against their LP positions. The contract manages collateral LP positions, calculates interest rates, and handles liquidations to ensure the safety and liquidity of the lending pool.

#### V3Oracle

The `V3Oracle` contract is designed to calculate the value of Uniswap V3 LP positions for use in the `V3Vault`. It integrates both Chainlink price feeds and Uniswap V3 Time-Weighted Average Price (TWAP) oracles, providing a fallback mechanism in case one fails. The contract ensures accurate and reliable pricing by cross-verifying between the oracles and can operate in various modes depending on the situation. This setup enhances the security and reliability of the `V3Vault` by preventing manipulation and ensuring that collateral values are accurate and up-to-date.

#### InterestRateModel

The `InterestRateModel` contract is used in a vault to calculate both borrow and supply interest rates based on the utilization of available liquidity. It dynamically adjusts the rates using a base rate, a multiplier for utilization below a specified "kink" level, and a jump multiplier for utilization above the kink. This allows the vault to effectively manage interest rates, ensuring stability and incentivizing appropriate borrowing and lending behavior. The model is customizable, allowing the owner to update parameters to adapt to changing market conditions.

### V3Vault functions

These external functions are

* **`deposit(uint256 assets, address receiver)` & `mint(uint256 shares, address receiver)`**
  * Allows users to deposit assets into the vault or mint new shares, with the possibility of using permit2 for signature-based approval.
* **`withdraw(uint256 assets, address receiver, address owner)` & `redeem(uint256 shares, address receiver, address owner)`**
  * Allows users to withdraw assets or redeem shares from the vault.
* **`create(uint256 tokenId, address recipient)` & `createWithPermit(uint256 tokenId, address recipient, uint256 deadline, uint8 v, bytes32 r, bytes32 s)`**
  * Enables users to create new collateralized positions by transferring a Uniswap V3 NFT to the vault, with or without permit-based approval.
* **`onERC721Received(address, address from, uint256 tokenId, bytes calldata data)`**
  * Handles the receipt of Uniswap V3 NFTs, creating or modifying a loan.
* **`approveTransform(uint256 tokenId, address target, bool isActive)`**
  * Allows an address to transform a loan on behalf of the owner (this is used when using Auto-Range or Auto-Compound funcionality)
* **`transform(uint256 tokenId, address transformer, bytes calldata data)`**
  * Allows a whitelisted transformer contract to modify a loan.
* **`borrow(uint256 tokenId, uint256 assets)`**
  * Allows users to borrow assets against their collateralized Uniswap V3 position.
* **`decreaseLiquidityAndCollect(DecreaseLiquidityAndCollectParams calldata params)`**
  * Decreases the liquidity of a Uniswap V3 position and collects the resultant assets, while ensuring the loan remains healthy.
* **`repay(uint256 tokenId, uint256 amount, bool isShare)` & `repay(uint256 tokenId, uint256 amount, bool isShare, bytes calldata permitData)`**
  * Allows users to repay their loans, either by specifying assets or debt shares, with an option for permit-based approval.
* **`liquidate(LiquidateParams calldata params)`**
  * Liquidates a loan that has become under-collateralized, transferring the collateral to the liquidator and handling any shortfall with reserves.
* **`remove(uint256 tokenId, address recipient, bytes calldata data)`**
  * Removes a fully repaid collateral position from the vault.

### Additional contracts

#### LeverageTransformer

The `LeverageTransformer` contract is designed to provide leverage and deleverage functionalities for positions held in the `V3Vault`. It allows users to borrow additional funds, swap them for the underlying assets of a Uniswap V3 position, and add liquidity in a single transaction, effectively leveraging their position. Conversely, it also enables users to reduce leverage by removing liquidity, swapping the underlying assets back to the borrowed asset, and repaying the loan. This contract integrates tightly with the `V3Vault`, making it easier for users to manage leveraged positions efficiently and securely in a single transaction.

#### FlashloanLiquidator

The `FlashloanLiquidator` contract facilitates the atomic liquidation of under-collateralized loans within the `V3Vault` using a Uniswap V3 flash loan. It allows a liquidator to borrow the necessary funds instantly, liquidate a position, and then repay the flash loan within a single transaction. The contract also supports swapping collateral tokens back to the asset used for liquidation, ensuring the liquidator receives a reward. This process ensures that liquidations are efficient, secure, and require minimal upfront capital from the liquidator.


# Configuration parameters

The initial configuration of Revert Lend supported tokens and parameters was defined by using the risk framework from [Anthias](https://www.anthias.xyz/) described in detail in this document (TODO link).

### Supported Chains and Tokens

Currently Revert Lend is available on `Arbitrum`.

The lend token is `USDC`

The supported collateral tokens are: `USDC, USDC.e, USDT, DAI, WETH, WBTC, ARB, wstETH`.

### Collateral factors

To decide the collateral factor of a LP position, the lower collateral factor of the two tokens is applied.

<table><thead><tr><th width="191">Token</th><th>Collateral factor</th></tr></thead><tbody><tr><td><code>USDC</code></td><td>85.0%</td></tr><tr><td><code>USDC.e</code></td><td>85.0%</td></tr><tr><td><code>USDT</code></td><td>85.0%</td></tr><tr><td><code>DAI</code></td><td>85.0%</td></tr><tr><td><code>WETH</code></td><td>77.5%</td></tr><tr><td><code>WBTC</code></td><td>77.5%</td></tr><tr><td><code>ARB</code></td><td>60%</td></tr><tr><td><code>wstETH</code></td><td>72.5%</td></tr></tbody></table>


# Stable Hooks

{% hint style="info" %}
Stable Hooks is **live on Base**. See [Contract Addresses](https://docs.revert.finance/revert/resources/contract-addresses) for the deployed contracts, [Deploying a pool](https://docs.revert.finance/revert/technical-docs/stable-hooks/deploying-a-pool) to launch your own, and [Integrating swaps](https://docs.revert.finance/revert/technical-docs/stable-hooks/integrating-swaps) if you route or aggregate.
{% endhint %}

Stable Hooks is Revert's StableSwap AMM for Uniswap v4. Each deployment is a single hook contract that replaces v4's constant-product pricing with a Curve-style StableSwap invariant for a fixed set of 2 to 4 correlated assets (stablecoins, liquid-staking tokens, wrapped assets).

Source: [github.com/revert-finance/stableswap-hooks](https://github.com/revert-finance/stableswap-hooks) (BUSL-1.1).

## Architecture

One `StableSwapHooks` contract is, at the same time:

* **The AMM.** It overrides `beforeSwap` with `beforeSwapReturnDelta`, computes swap amounts with StableSwap math, and settles against its own reserves. The v4 core pool never executes any swap math.
* **The liquidity token.** The hook itself is an ERC-20. Deposits and withdrawals are proportional across all pool assets; there are no ranges, ticks, or position NFTs.
* **The fee accountant.** The LP fee is fixed at deployment and encoded in `PoolKey.fee`. Hook and protocol fees are carved out of the gross LP fee and accrue inside the contract until withdrawn to fixed collector addresses.

At deployment the hook initializes **every pairwise v4 pool** for its currency set: a 4-asset hook registers 6 pairwise pools, all drawing on one shared set of reserves. Reserves are held as ERC-6909 claims on the `PoolManager`.

Key parameters:

| Parameter           | Where                                            | Notes                                                                                                                                                                     |
| ------------------- | ------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Currencies          | `currencies(i)`, `currenciesLength()`            | 2 to 4, sorted ascending by address. Native ETH supported as `address(0)`.                                                                                                |
| LP fee              | `lpFeePercentage()`, also `PoolKey.fee`          | Scaled by `FEE_PRECISION = 1e6` (e.g. `500` = 0.05%). Immutable per hook.                                                                                                 |
| Hook / protocol fee | `hookFeePercentage()`, `protocolFeePercentage()` | Percentages of the gross LP fee, set by the factory owner.                                                                                                                |
| Amplification       | `getCurrentAmp()`                                | Higher A prices tighter around the reference ratio. Changed only by gradual ramping (`AmpRampStarted` / `AmpRampStopped` events).                                         |
| Rate oracles        | `rateOracles(i)`                                 | Optional per-asset on-chain redemption-rate reads (e.g. wstETH `stEthPerToken`) so yield-bearing assets are priced at their true ratio. Zero config for plain 1:1 assets. |
| Tick spacing        | `TICK_SPACING()`                                 | Always `1`. Required in the `PoolKey`, otherwise unused.                                                                                                                  |

## Pool deployment

Pools are deployed permissionlessly through `StableSwapHooksFactory.deploy(...)`: it is `whenNotPaused` with no owner gate, so any address can deploy while the factory is unpaused. The factory validates the creation bytecode against a stored hash and deploys via CREATE2; a valid hook address requires off-chain salt mining. Every deployment emits `StableSwapHooksDeployed(sender, hook)`.

See [Deploying a pool](https://docs.revert.finance/revert/technical-docs/stable-hooks/deploying-a-pool) for the full step-by-step (parameters, salt mining, seeding liquidity, and common reverts).

## Liquidity

* `quoteAddLiquidity(amounts)` returns expected shares and the actual amounts a proportional deposit will consume; pass minimums into `addLiquidity(amounts, minAmounts, minShares)`.
* `quoteRemoveLiquidity(shares)` previews proportional withdrawal amounts for `removeLiquidity(shares, minAmounts)`.
* The first deposit permanently locks `MINIMUM_LIQUIDITY` to a dead address.
* Net LP fees stay in reserves, so fees compound into the value of every LP share automatically. There is no claim step.

## Security

The contracts were independently audited by PeckShield and went through a public audit competition on Cantina.

## For integrators

If you route or aggregate swaps, see [Integrating swaps](https://docs.revert.finance/revert/technical-docs/stable-hooks/integrating-swaps). The short version: pools are quoted and executed through the standard v4 stack (Quoter, Universal Router), but all pricing state lives in the hook, not in the core pool's slot0 or tick data.


# Deploying a pool

Stable Hooks pools are permissionless. Anyone can deploy one by calling the factory on-chain: there is no allowlist and no approval step. `StableSwapHooksFactory.deploy(...)` is `whenNotPaused` with no owner gate, so any address can call it while the factory is unpaused.

There is no UI for this today, so deploying a pool is a contract-level operation aimed at developers and issuers. This page documents the full path. The factory address is on the [Contract Addresses](https://docs.revert.finance/revert/resources/contract-addresses) page.

{% hint style="info" %}
The reference implementation of everything below is `script/DeployStableSwapPool.s.sol` (a Foundry script) and `script/hookMiner.demo.js` (a standalone salt miner) in [github.com/revert-finance/stableswap-hooks](https://github.com/revert-finance/stableswap-hooks).
{% endhint %}

## Chains

The factory is deployed on **Base** only (address on the [Contract Addresses](https://docs.revert.finance/revert/resources/contract-addresses) page). Deploying a pool requires the factory, so pools can currently be created on Base only. To bring Stable Hooks to another chain, reach out on [Discord](https://discord.gg/HXfxKHrRmf); we deploy and configure the factory per chain.

## What you control, and what you don't

You set these at deploy time, and they are **immutable** for the life of the pool:

* the **currency set** (2 to 4 correlated assets),
* the **LP fee** charged to traders,
* the **amplification** coefficient (A),
* the per-currency **rate oracles**.

Two things are administered by the factory owner, not the deployer:

* **The hook/protocol fee split** (`setProtocolFeePercentage`, `setHookFeePercentage`) is `onlyFactoryOwner`. On a self-deployed pool these default to `0`, so the entire net LP fee accrues to LPs. The trader-facing LP fee you set at deploy is immutable and is never changed by this split. This mirrors the behavior described under [Integrating swaps → Stability guarantees](https://docs.revert.finance/revert/technical-docs/stable-hooks/integrating-swaps).
* **Amplification ramping** (`startAmpRamp`, `stopAmpRamp`) is `onlyFactoryOwner`. Your initial `baseAmp` is fixed at deploy; only the factory owner can later ramp it, and only gradually (see limits below).

## Parameters

| Parameter         | Type                 | Rules                                                                                                                                                                                                                               |
| ----------------- | -------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `currencies`      | `Currency[]`         | 2 to 4 entries (`MIN_CURRENCIES`..`MAX_CURRENCIES`), sorted strictly ascending by address. Native ETH is `address(0)`.                                                                                                              |
| `rateOracles`     | `RateOracleConfig[]` | One per currency (length must match). `{oracle: address(0), selector: 0x00000000}` for a static 1:1 asset. For a yield-bearing asset, point at its rate function (e.g. wstETH `stEthPerToken()`) so it is priced at its true ratio. |
| `lpFeePercentage` | `uint256`            | Trader-facing LP fee, scaled by `FEE_PRECISION = 1e6`. Must be `0 < fee < 1e6`. Example: `500` = 0.05%. Stored in `PoolKey.fee`.                                                                                                    |
| `baseAmp`         | `uint256`            | Initial amplification, unscaled. Must be `< MAX_AMP` (1,000,000); use a non-zero value. Higher A prices tighter around the reference ratio.                                                                                         |

## Deploy flow

### 1. Verify the creation bytecode

The factory validates that the creation code you pass hashes to a stored value, so you must use the exact `StableSwapHooks` creation bytecode:

```solidity
bytes memory creationCode = type(StableSwapHooks).creationCode;
require(keccak256(creationCode) == factory.creationCodeHash(), "hash mismatch");
```

### 2. Build the constructor args

The factory appends `abi.encode(poolManager, currencies, rateOracles, lpFeePercentage, baseAmp)` to the creation code. Use the factory's own `poolManager()`:

```solidity
bytes memory constructorArgs = abi.encode(
    factory.poolManager(), currencies, rateOracles, lpFeePercentage, baseAmp
);
```

### 3. Mine a CREATE2 salt

A Uniswap v4 hook address must encode its permission flags in its low 14 bits. Stable Hooks uses `factory.HOOK_FLAGS()` (`0x2AA8` = 10920: `BEFORE_INITIALIZE`, `BEFORE_ADD_LIQUIDITY`, `BEFORE_REMOVE_LIQUIDITY`, `BEFORE_SWAP`, `BEFORE_SWAP_RETURNS_DELTA`, `BEFORE_DONATE`). Mine a salt whose predicted CREATE2 address matches. This is pure off-chain computation and costs no gas.

```solidity
// Foundry: @uniswap/v4-periphery/src/utils/HookMiner.sol
(address predicted, bytes32 salt) =
    HookMiner.find(address(factory), factory.HOOK_FLAGS(), creationCode, constructorArgs);
```

`script/hookMiner.demo.js` does the same in standalone JavaScript (mask `0x3fff`, deployer = the factory address) if you are not using Foundry.

### 4. Deploy

```solidity
address hook = factory.deploy(
    currencies, rateOracles, lpFeePercentage, baseAmp, salt, creationCode
);
```

This deploys the hook via CREATE2 and initializes **every pairwise pool** for the currency set (`n * (n - 1) / 2` pools), all sharing one set of reserves. It emits `StableSwapHooksDeployed(msg.sender, hook)`, which integrators watch for discovery (see [Integrating swaps → Pool discovery](https://docs.revert.finance/revert/technical-docs/stable-hooks/integrating-swaps)).

### 5. Seed initial liquidity

The pool is live but empty. Add the first liquidity so swaps can execute. Approve the tokens to the hook, preview with `quoteAddLiquidity`, then deposit:

```solidity
// amounts are proportional across all pool currencies
(uint256 shares, uint256[] memory used) = hook.quoteAddLiquidity(amounts);
hook.addLiquidity(amounts, minAmounts, minShares);
```

The first deposit permanently locks `MINIMUM_LIQUIDITY` (1000) shares to a dead address to prevent share-price manipulation. Net LP fees stay in reserves, so fees compound into every LP share automatically; there is no claim step. Withdraw with `removeLiquidity(shares, minAmounts)`.

## Foundry one-liner

The reference script mines the salt, deploys, and (as factory owner) configures the fee split:

```bash
forge script script/DeployStableSwapPool.s.sol:DeployStableSwapPool \
  --rpc-url base --broadcast --verify -vvvv \
  --sig "run(address)" <FACTORY_ADDRESS>
```

Edit the currency addresses, `LP_FEE_PERCENTAGE`, and `BASE_AMP` constants in the script for your pool. The `setProtocolFeePercentage`/`setHookFeePercentage` calls at the end only succeed if the sender is the factory owner; drop them if you are deploying a third-party pool (the split then stays at 0).

## Common reverts

| Revert                     | Cause                                                                                    |
| -------------------------- | ---------------------------------------------------------------------------------------- |
| `CurrenciesNotSorted`      | `currencies` not strictly ascending by address                                           |
| `InvalidCurrenciesLength`  | fewer than 2 or more than 4 currencies                                                   |
| `InvalidFeePercentage`     | `lpFeePercentage` is 0 or `>= 1e6`                                                       |
| `InvalidRateOraclesLength` | `rateOracles.length != currencies.length`                                                |
| `InvalidCreationCode`      | `keccak256(creationCode) != factory.creationCodeHash()`                                  |
| `InvalidAmp`               | `baseAmp >= MAX_AMP` (1,000,000)                                                         |
| `EnforcedPause`            | the factory is paused                                                                    |
| hook address mismatch      | the mined salt does not encode `HOOK_FLAGS`; re-mine against the exact `constructorArgs` |

## Amplification ramping (factory owner)

`baseAmp` is fixed at deploy. Changing it later is a factory-owner action and is rate-limited for pool safety: at most a 10x change (`MAX_AMP_MULTIPLIER`) per ramp, at least `MIN_AMP_RAMP_TIME` (1 day) between ramps, and the ramp end must be at least 1 day out. `getCurrentAmp()` returns the interpolated value during a ramp.


# Integrating swaps

{% hint style="info" %}
Stable Hooks is **live on Base**. Contract addresses are in the [Deployments](#deployments) section below and on the [Contract Addresses](https://docs.revert.finance/revert/resources/contract-addresses) page. This guide is stable and can be built against directly.
{% endhint %}

This page is for aggregators, solvers, and routers that want to source liquidity from Stable Hooks pools. It covers pool discovery, quoting, execution, indexing, and the ways these pools differ from vanilla v4 pools.

**TL;DR:** integration is standard Uniswap v4. Build the `PoolKey`, quote with the v4 `Quoter`, execute through the Universal Router with empty `hookData`. The one thing you must not do is price these pools from core pool state: `slot0` and tick data are meaningless here (see [What not to do](#what-not-to-do)).

## Pool discovery

1. Watch the factory for deployments:

```solidity
event StableSwapHooksDeployed(address indexed _sender, address indexed _hook);
```

2. For each hook, enumerate its assets and parameters:

```solidity
uint256 n = hook.currenciesLength();          // 2 to 4
Currency c = hook.currencies(i);              // sorted ascending; address(0) = native ETH
uint256 lpFee = hook.lpFeePercentage();       // scaled by 1e6; also the PoolKey.fee value
int24 spacing = hook.TICK_SPACING();          // always 1
```

3. A hook with `n` assets registers all `n * (n - 1) / 2` pairwise pools at deployment. Every pair is a routable pool; all pairs of one hook draw on the same shared reserves. You can verify a candidate pool id with `hook.isValidPoolId(poolId)`.

The `PoolKey` for any pair (with `currency0 < currency1`):

```solidity
PoolKey memory poolKey = PoolKey({
    currency0: currency0,
    currency1: currency1,
    fee: uint24(hook.lpFeePercentage()),
    tickSpacing: hook.TICK_SPACING(),
    hooks: IHooks(address(hook))
});
```

## Quoting

### Via the v4 Quoter (RPC simulation)

The standard v4 `Quoter` simulates the full swap including the hook and returns correct amounts with no special handling. It is revert-based and not gas-efficient, so call it off-chain over `eth_call`, not from a contract:

```solidity
(uint256 amountOut,) = quoter.quoteExactInputSingle(
    IV4Quoter.QuoteExactSingleParams({
        poolKey: poolKey,
        zeroForOne: true,
        exactAmount: uint128(amountIn),
        hookData: bytes("")
    })
);
// quoteExactOutputSingle works the same way for exact-output amounts.
```

### Without RPC: replicating the math

For indicative pricing without RPC simulation, replicate the hook's math from four reads:

1. **Reserves:** `hook.reserves(i)` for each currency index.
2. **Amplification:** `hook.getCurrentAmp()` (interpolates during ramps).
3. **Rates:** each reserve is scaled by a per-currency rate before the invariant math. The static rate is `10^(36 - decimals)` (native ETH counts as 18 decimals). If `hook.rateOracles(i)` has a non-zero oracle, the effective rate is `staticRate * fetchedRate / 1e18`, where `fetchedRate` is a `staticcall` to the configured selector (e.g. wstETH's `stEthPerToken()`). See `Base._getRate` and `StableSwapMath.scaleTo` in the repo.
4. **Fees:** for exact input, compute the raw StableSwap output first, then deduct the gross LP fee from the output: `fee = ceil(rawAmountOut * lpFeePercentage / 1e6)`, `amountOut = rawAmountOut - fee`. For exact output, compute the raw input, then add the same gross fee on top: `amountIn = rawAmountIn + ceil(rawAmountIn * lpFeePercentage / 1e6)`. The fee is charged on the raw amount, not grossed up by `1 / (1 - fee)`. The hook/protocol split within the LP fee does not affect trader amounts.

The invariant and target-reserve computation are in `src/libraries/StableSwapMath.sol` (`getInvariant`, `getTargetReserves`); the swap flow that composes them is `src/Swap.sol`. Cache invalidation: reserves change on every swap and liquidity event (see [Indexing](#indexing)); amp changes only during announced ramps; oracle rates drift slowly (staking yield).

## Execution

Swaps route through the Universal Router with the ordinary v4 action encoding. No listing, registration, or approval is involved: the router executes against any initialized v4 pool the caller's `PoolKey` points at, so these pools are callable by anyone from the moment they are deployed.

```solidity
bytes memory actions = abi.encodePacked(
    uint8(Actions.SWAP_EXACT_IN_SINGLE), uint8(Actions.SETTLE_ALL), uint8(Actions.TAKE_ALL));

bytes[] memory params = new bytes[](3);
params[0] = abi.encode(IV4Router.ExactInputSingleParams({
    poolKey: poolKey,
    zeroForOne: true,
    amountIn: uint128(amountIn),
    amountOutMinimum: amountOutMin,   // slippage protection
    minHopPriceX36: 0,                // per-hop price bound; 0 disables it (see note)
    hookData: bytes("")
}));
params[1] = abi.encode(poolKey.currency0, amountIn);  // SETTLE_ALL
params[2] = abi.encode(poolKey.currency1, 0);         // TAKE_ALL

bytes memory commands = abi.encodePacked(uint8(Commands.V4_SWAP));
bytes[] memory inputs = new bytes[](1);
inputs[0] = abi.encode(actions, params);
universalRouter.execute(commands, inputs, deadline);
```

Notes:

* Exact output uses `SWAP_EXACT_OUT_SINGLE`, whose params swap `amountIn`/`amountOutMinimum` for `amountOut`/`amountInMaximum` (same `minHopPriceX36` and `hookData` fields).
* **Match the params struct to your v4-periphery version.** `minHopPriceX36` (a per-hop price bound, `0` to disable) is present in current `IV4Router.ExactInputSingleParams`/`ExactOutputSingleParams` but was added after some earlier periphery releases. If your pinned periphery predates it, drop that field; if you are on a newer one, keep it. Always check the `IV4Router` struct in the version you build against.
* Native ETH: pass value with the call; for exact-output swaps send `amountInMaximum` and append a `Commands.SWEEP` to recover the unused remainder.
* `hookData` is always empty. The hook takes no per-swap parameters.
* Slippage is enforced by the router's `amountOutMinimum` / `amountInMaximum`, exactly as for any v4 pool.
* **Multi-hop composes normally.** These pools participate in standard v4 path swaps (`SWAP_EXACT_IN` / `SWAP_EXACT_OUT`) and can be batched with any other v4 pools in a single Universal Router call. Each hop through a Stable Hooks pool runs its own `beforeSwap`.
* **Universal Router pulls input tokens via Permit2**, as for any v4 swap; callers need the usual token-to-Permit2 approval plus a Permit2 allowance for the router.
* **Custom settlement contracts work too.** The Universal Router is the common path, not a requirement. A settlement contract that unlocks the `PoolManager` and calls `swap()` with the `PoolKey` directly (the pattern aggregator executors typically use) integrates the same way; the hook does not care who the caller is.
* **Dust swaps return zero, they do not revert.** The gross LP fee rounds up against the trader, so a tiny exact-input swap (for example 1 wei) executes successfully with `amountOut = 0`. Route-splitting logic should floor leg sizes rather than rely on reverts to catch dust legs. Rounding always favors the pool; round-tripping tiny amounts cannot extract value.

## Gas costs

Measured end-to-end through the Universal Router against the repo's test suite (execution gas only; add \~21k intrinsic plus calldata):

| Swap                     | First pool touch in tx | Pool state already warm |
| ------------------------ | ---------------------- | ----------------------- |
| Exact input, single hop  | \~176k                 | \~77k                   |
| Exact output, single hop | \~244k                 | \~88k                   |

The cold column is the representative cost for a standalone swap transaction. The warm column applies when the same pool is touched again within one transaction (multi-hop batches, split routes). These benchmarks are for a plain pool with no oracles. Pools with rate oracles read each asset's rate when building the swap context and again for the swap's input and output assets, so an oracle-configured asset can be read up to twice per swap: a 2-asset pool with both assets oracle-configured does 4 rate `staticcall`s, a 4-asset pool up to 6. Each costs whatever the token's rate function costs (typically a few thousand gas).

## Stability guarantees

Answers to the usual "can this pool change under me" questions:

* **The trader-facing fee cannot change.** `lpFeePercentage` is immutable per hook, set at deployment. The hook/protocol split within it is admin-adjustable but never changes trader amounts.
* **Live pools cannot be paused.** The factory's `pause()` only blocks new pool deployments. There is no admin switch that halts swaps or withdrawals on an existing hook.
* **Amplification changes only gradually and observably.** Only the factory owner can ramp A, a ramp takes at least 1 day (`MIN_AMP_RAMP_TIME`) and changes A by at most 10x (`MAX_AMP_MULTIPLIER`), and both ramp start and stop emit events (`AmpRampStarted` / `AmpRampStopped`), so quote engines can track A precisely.
* **The asset set is fixed.** Currencies and rate-oracle configs are set in the constructor and cannot be added, removed, or repointed.

## Revert conditions

Swaps revert when:

* **Exact output exceeds available reserves.** There is no partial fill; size exact-output swaps below `hook.reserves(i)` of the output asset (the effective bound is lower once price impact and fees are counted).
* **A configured rate oracle fails.** `_getRate` performs a `staticcall` for each oracle-configured asset on every swap. If the oracle call itself reverts, that revert bubbles up through OpenZeppelin's `Address.functionStaticCall` (the oracle's own error data, or a failed-call error). The dedicated `RateOracleCallFailed` error is raised only when the call succeeds but returns a non-32-byte value. Either way the swap reverts, so do not key retry logic on a single error selector. Plain pools (no oracles) have no such dependency.
* **The pool id is not registered to the hook** (`InvalidPoolId`). Only the pairwise pools initialized at deployment are valid.
* **Router-level checks fail:** `amountOutMinimum` / `amountInMaximum` violated, expired deadline. Standard v4 behavior.

## What not to do

These pools are custom-curve pools. The v4 core pool exists only as a settlement shell:

* **Do not price from `slot0`.** Every pairwise pool is initialized at `sqrtPriceX96 = 1 << 96` (a 1:1 price) and never moves, because the hook consumes 100% of `amountSpecified` in `beforeSwap` (via `beforeSwapReturnDelta`) and core swap math runs on zero.
* **Do not read tick data or core liquidity.** Native liquidity positions are blocked (`beforeAddLiquidity` / `beforeRemoveLiquidity` revert), so in-range liquidity is always zero. Depth lives in `hook.reserves(i)`.
* **Do not apply core LP-fee math.** The fee in `PoolKey.fee` is charged by the hook's own math as described above, not by the core fee mechanism.
* **Do not assume pairwise independence for large flows.** All pairs of one hook share reserves, so a large swap on one pair shifts quotes on every other pair of the same hook.

## Indexing

Emitted by the hook:

```solidity
event StableSwap(
    address indexed _sender,
    Currency indexed _currencyIn,
    Currency indexed _currencyOut,
    uint256 _amountIn,
    uint256 _amountOut,
    uint256 _lpFees,
    uint256 _hookFees,
    uint256 _protocolFees
);

event LiquidityAdded(address indexed _sender, uint256[] _amounts, uint256 _shares);
event LiquidityRemoved(address indexed _sender, uint256[] _amounts, uint256 _shares);
event AmpRampStarted(
    address indexed _sender, uint256 _currentAmp, uint256 _nextAmp, uint256 _currentTime, uint256 _nextAmpTime
);
event AmpRampStopped(address indexed _sender, uint256 _currentAmp, uint256 _currentTime);
```

`StableSwap` fires on every swap with the full fee breakdown, so volume and fee analytics need no core-pool event parsing. Reserve state can always be re-read from `hook.reserves(i)`.

## Interfaces and ABI

The contract interface is stable, so integrations can be built now against the public source. The pieces an integrator needs:

* **Hook** (swap, liquidity, fees, amplification, getters): [`src/StableSwapHooks.sol`](https://github.com/revert-finance/stableswap-hooks/blob/main/src/StableSwapHooks.sol) and its mixins [`Swap.sol`](https://github.com/revert-finance/stableswap-hooks/blob/main/src/Swap.sol), [`Liquidity.sol`](https://github.com/revert-finance/stableswap-hooks/blob/main/src/Liquidity.sol), [`Fees.sol`](https://github.com/revert-finance/stableswap-hooks/blob/main/src/Fees.sol), [`Amp.sol`](https://github.com/revert-finance/stableswap-hooks/blob/main/src/Amp.sol), [`Base.sol`](https://github.com/revert-finance/stableswap-hooks/blob/main/src/Base.sol).
* **Factory** (deployment, `StableSwapHooksDeployed` event): [`src/factories/StableSwapHooksFactory.sol`](https://github.com/revert-finance/stableswap-hooks/blob/main/src/factories/StableSwapHooksFactory.sol).
* **Interfaces:** [`src/interfaces/`](https://github.com/revert-finance/stableswap-hooks/tree/main/src/interfaces).

To generate the JSON ABI, clone the repo and run `forge build`; artifacts land in `out/StableSwapHooks.sol/StableSwapHooks.json`. At launch the deployed contracts are verified on the block explorer, which becomes the canonical ABI source alongside the addresses below.

## Deployments

Stable Hooks is **live on Base**. New pools are deployed permissionlessly through the factory (see [Pool discovery](#pool-discovery)); the factory is the source of truth for the current pool set. The canonical registry for all Revert contracts is the [Contract Addresses](https://docs.revert.finance/revert/resources/contract-addresses) page.

### Base (chain ID 8453)

| Contract                                          | Address                                                                                  |
| ------------------------------------------------- | ---------------------------------------------------------------------------------------- |
| StableSwapHooksFactory                            | [`0x3805…f564`](https://basescan.org/address/0x38059503CD538e375D485357B5DE893080a4f564) |
| StableSwapZapIn                                   | [`0x7d5c…0e73`](https://basescan.org/address/0x7d5cc6095d0FD8534D1e055c17dA794385470e73) |
| cbETH / WETH pool (hook + `SSLP` LP token)        | [`0x90A4…AAA8`](https://basescan.org/address/0x90A40A2A62044e7AF9163E2F36d3AC65eA08AAA8) |
| ↳ rate oracle: ChainlinkOracleAdapter (cbETH/ETH) | [`0xb9Cf…4614`](https://basescan.org/address/0xb9CfC2A6746896cadb34D6CDe407432f8B604614) |
| USDC / USDT pool (hook + `SSLP` LP token)         | [`0x37cA…2aa8`](https://basescan.org/address/0x37cA10C307fA8caA772f3583B3fd1e923DeE2aa8) |

Each pool address is a `StableSwapHooks` contract: at once the hook, the AMM, and the ERC-20 LP token (`StableSwap LP Token`, `SSLP`). Price these pools through the hook (Quoter / Universal Router), never from core pool `slot0` or tick data. For access questions, reach out on [Discord](https://discord.gg/HXfxKHrRmf).

## Security

The contracts were independently audited by PeckShield and went through a public audit competition on Cantina. Source and tests: [github.com/revert-finance/stableswap-hooks](https://github.com/revert-finance/stableswap-hooks).


# Contract Addresses

### Contract Addresses

### **Revert V4utils**

V4Utils on Ethereum Mainnet <https://etherscan.io/address/0x528a72897C64547fb84e7FD8ac17102Bdd564eb5>

V4Utils on Unichain <https://uniscan.xyz/address/0xae8999DA4D81cB81b42288b12176fE20D7EAD578>

V4Utils on Arbitrum <https://arbiscan.io/address/0x47e2fb3a7d3FFE8390D975d7566627A7514D733c>

V4Utils on Base <https://basescan.org/address/0x209E399ac7FC8747c3821F9376E4eb6Ce105DbA8>

V4Utils on Robinhood <https://robinhoodchain.blockscout.com/address/0xd322Dc8F96004d2A92a2ae821b99D25eBB2a3EA4>

#### Stable Hooks on Base

The StableSwap AMM for Uniswap v4, live on Base. Each pool address is a `StableSwapHooks` contract that is simultaneously the hook, the AMM, and the ERC-20 LP token (`StableSwap LP Token`, symbol `SSLP`). New pools are deployed permissionlessly through the factory. See [Stable Hooks](https://docs.revert.finance/revert/technical-docs/stable-hooks) and [Integrating swaps](https://docs.revert.finance/revert/technical-docs/stable-hooks/integrating-swaps).

StableSwapHooksFactory <https://basescan.org/address/0x38059503CD538e375D485357B5DE893080a4f564>

StableSwapZapIn <https://basescan.org/address/0x7d5cc6095d0FD8534D1e055c17dA794385470e73>

cbETH/WETH pool (hook + SSLP LP token) <https://basescan.org/address/0x90A40A2A62044e7AF9163E2F36d3AC65eA08AAA8>

ChainlinkOracleAdapter, cbETH/ETH (rate oracle for the cbETH/WETH pool) <https://basescan.org/address/0xb9CfC2A6746896cadb34D6CDe407432f8B604614>

USDC/USDT pool (hook + SSLP LP token) <https://basescan.org/address/0x37cA10C307fA8caA772f3583B3fd1e923DeE2aa8>

#### Revert Lend Contracts for Arbitrum

V3Vault <https://arbiscan.io/address/0x74e6afef5705beb126c6d3bf46f8fad8f3e07825>

V3Oracle <https://arbiscan.io/address/0x9F703BFccd04389725FbaD7Bc50F2E345583d506>

InterestRateModel <https://arbiscan.io/address/0x18616C0a8389A2cabF596f91D3e6CCC626E58997>

LeverageTransformer <https://arbiscan.io/address/0xe5047b321071b939d48ae8aa34770c9838bb25e8>

FlashloanLiquidator <https://arbiscan.io/address/0x5b94d444dfba48780524a1f0cd116f8a57bfefc2>

#### Revert Lend Contracts for Base

V3Vault <https://basescan.org/address/0x36AEAe0E411a1E28372e0d66f02E57744EbE7599>

V3Oracle <https://basescan.org/address/0x31c8Ae1E4d7a1788536aC19C92Ce3eBae3F4731F>

InterestRateModel <https://basescan.org/address/0xD0524a77C8E2bD22b1F57268fD6beA1973aC7927>

LeverageTransformer <https://basescan.org/address/0x5e97A478184993D3E376eec00B603F80463D9B23>

FlashloanLiquidator <https://basescan.org/address/0x6BCB1Ae7b3aec6086066dC4348dc679C93eeAC5b>

#### Revert Lend Contracts for Ethereum mainnet

V3Vault\
[https://etherscan.io/address/0xa2754543f69dC036764bBfad16d2A74F5cD15667](https://etherscan.io/address/0xa2754543f69dC036764bBfad16d2A74F5cD15667#code)

V3Oracle\
[https://etherscan.io/address/0xe0151d335A6C4AB0600Ae4000a9CAAf7b236072f](https://etherscan.io/address/0xe0151d335A6C4AB0600Ae4000a9CAAf7b236072f#code)

InterestRateModel\
[https://etherscan.io/address/0xb50daFe03fEe68595Ab2bAaD3c16F899421F063B](https://etherscan.io/address/0xb50daFe03fEe68595Ab2bAaD3c16F899421F063B#code)

LeverageTransformer\
[https://etherscan.io/address/0xbAEA7f73569456096fCf38AE34242c52CA227b1e](https://etherscan.io/address/0xbAEA7f73569456096fCf38AE34242c52CA227b1e#code)

FlashLoanLiquidator\
[https://etherscan.io/address/0xa44080F20464de260e25F35A69d6BDa50f2cc79D](https://etherscan.io/address/0xa44080F20464de260e25F35A69d6BDa50f2cc79D#code)

#### Aerodrome on Base

These are the contracts for the Aerodrome Slipstream deployment on Base, covering lending, gauge custody, automation, and AERO auto-compounding. See [Aerodrome on Base](https://docs.revert.finance/revert/aerodrome) for what they do.

V3Vault <https://basescan.org/address/0x1EF7C181188687e20A9750714f1b9DE6F70f17C0>

V3Oracle <https://basescan.org/address/0x82722327E45E86a0F2107746F423f612139b0952>

InterestRateModel <https://basescan.org/address/0x9E29b74336A0D698AD600b3e52729bFda85e0564>

LeverageTransformer <https://basescan.org/address/0xF4fCBaB7D092A0b46438DBBaa21333f7F07137EC>

GaugeManager (gauge custody for staked positions) <https://basescan.org/address/0xc171F8c6ED8253151DE50ab839E3A468028113F2>

V3Utils <https://basescan.org/address/0x2309A5aE06e86986a6f27b81a53cC31Fc1B55b0a>

Auto-Range / Auto-Compound <https://basescan.org/address/0xEB6127DcFB1E4107Dc1F3111151f779920c213Dd>

Auto-Exit <https://basescan.org/address/0xc35e20379C3267B5f63E569c25959031aC588203>

#### Auto-Range v3

<https://arbiscan.io/address/0x5ff2195ba28d2544aed91e30e5f74b87d4f158de>

<https://optimistic.etherscan.io/address/0x87f44220d8895d6b9fc3f80f104a1a6cb87fdca5>

<https://polygonscan.com/address/0x5e54224a75d459f57ac4c76ce7c560a353374a5b>

<https://basescan.org/address/0xa8549424b20a514eb9e7a829ec013065bef9dc1d>

<https://bscscan.com/address/0xa8b9fc43974cc78fe8a137d8c6c48856ab96a493>

<https://bscscan.com/address/0xa8b9Fc43974CC78FE8A137d8c6C48856aB96a493>

<https://bscscan.com/address/0xa0dc48783d6a5cc58d0ed6016eaa929e14c10ad5> (pancakeswap)

<https://etherscan.io/address/0x88481e2fbc98d4a251655b0f1a4422555ea72d9e>

#### Auto-Exit v3

<https://arbiscan.io/address/0xd0186335f7b7c390b6d6c0c021212243ed297dda>

<https://optimistic.etherscan.io/address/0x32d03c762995e1e90c6f809e13675ac84db223c7>

<https://polygonscan.com/address/0x1d0d743466b0e65482bc7effd81232354c5ebcad>

<https://basescan.org/address/0x16e0b91ce6f1c426df6e2a5a295d113e8f596a93>

<https://bscscan.com/address/0xc2c77dd78f6f73aa0553bf3a2108566a40f696b3>

<https://bscscan.com/address/0xa16cf1e8adb706c762a04449cbbf8fa99cb66a58> (pancakeswap)

<https://etherscan.io/address/0xef4868d67a6dc9f0eb9dbaadfae6f4e78829edf7>

#### Auto-Compound v3

<https://arbiscan.io/address/0x9d97c76102e72883cd25fa60e0f4143516d5b6db>

<https://optimistic.etherscan.io/address/0xbe931744bf0b4c4c580d375de04ee7fc2f52c568>

<https://polygonscan.com/address/0xf887e57ad9114bb31c7506890efc181f355e9783>

<https://basescan.org/address/0x0bf485bd7ebb82e282f72e7d14822c680e3f7bec>

<https://bscscan.com/address/0x843fe45972f638a2e7065b8d8b54efcfed09b72b>

<https://bscscan.com/address/0x3b1767957d08ddc60493d35d812c66e2d52bd875> (pancakeswap)

<https://etherscan.io/address/0x7c81247ae0a35b03e3f4a704dcd6b101dca53abd>

V3Utils v1.1

<https://arbiscan.io/address/0xcfd55ac7647454ea0f7c4c9ec231e0a282b30980>

<https://optimistic.etherscan.io/address/0xd5c6057a3fa473431975e6d28e4e858544ecf4d8>

<https://polygonscan.com/address/0x4ec6f2c562b811ec363e20df143745737452108f>

<https://basescan.org/address/0x5b2f7cc65f8eb6222289c714547b9ab22db86be5>

<https://bscscan.com/address/0x81835416ba59810cf0716ae2b1334f2ed6c53392>

<https://bscscan.com/address/>[0x2b19718f8f28c17e3fec92e937d58c477584d773](https://bscscan.com/address/0x2b19718f8f28c17e3fec92e937d58c477584d773)

<https://etherscan.io/address/0x371a339d21a45d874f1399a4e060b6931f423e8c>

#### Selfcompoundor

<https://etherscan.io/address/0xB50a397543fB2c7D08c53D5f5331AD8990D3B48f>

<https://polygonscan.com/address/0xad58D1DF63AFcf090Cc930475db3dD3cD8f739eA>

<https://arbiscan.io/address/0xb43a613f0dd19af1cb1f5d03d8e8e5af04d9f0a1>

<https://optimistic.etherscan.io/address/0x3C0Fd0B42aa46F03f6cF5e305Ed9B2Ce402847eF>

<https://bscscan.com/address/0x69437b43805C9fFF78eC63394474a48C69DD8DA6>

<https://escan.live/address/0xc35539ff16b60ebc6bdcb376316f638288ccdd24>

<https://bscscan.com/address/0x48331aEc6a59A44FE1648AAa38545CEDDbdd747c>

<https://basescan.org/address/0xc5d8fa6439a5a8caa4ab24025751255296f1551a>

<https://blastscan.io/address/0x4A8c2bDf0D8D2473b985f869815D9CaA36a57ee4>

<https://robinhoodchain.blockscout.com/address/0x7220E133D9889EB893efCF8663a82569bb629076>

#### Auto-Range v2 (deprecated)

<https://polygonscan.com/address/0x54ebb4815326d922a93339f37dcbbf0d2fe2864e>

<https://arbiscan.io/address/0xa44b95e50932e2792625886d4ed3099b6932645a>

<https://optimistic.etherscan.io/address/0x9377ff26ea172bb61596d730ec4eeee78232ccab>

<https://bscscan.com/address/0x9a515ff53f38185b1f2aed81685c22953092fb3b>

<https://bscscan.com/address/>[0xd8dcdbd48ba059c288a9d654c468ebd94c27d7e4](https://bscscan.com/address/0xd8dcdbd48ba059c288a9d654c468ebd94c27d7e4)

<https://basescan.org/address/0x043e2ff28db24061d46629b999a358a24c784c69>

<https://etherscan.io/address/0x9576fc12363cbbd8aa010242f0939a4d55ce0b1a>

#### Auto-Exit v2 (deprecated)

<https://polygonscan.com/address/0x08ad36649da1271124533d36dccacb1e00e37533>

<https://arbiscan.io/address/0xee1e94addc3aec46d16ab9735e262c92824165c0>

<https://optimistic.etherscan.io/address/0x3322ac2d080dafb4a312929d97d51d66764742b9>

<https://bscscan.com/address/0x3cac4a92c8bac93ea2986cb819a4aaf529974d93>

<https://bscscan.com/address/0x68bb8dbcb554b95ce0fffef6846a0ac8a7fe3cb9>

<https://basescan.org/address/0x5b3b61342c09c9455bd1913cf0be4c13c053d046>

<https://etherscan.io/address/0x37c25b604d7f9615c375cc392be853a272ee4e90>

#### AutoRange (deprecated)

<https://polygonscan.com/address/0x55d5889211e33296eb1d9087b8a8d7dd89edfbf4>

<https://optimistic.etherscan.io/address/0x6ee80279c057f17a3c7d5a9aa3e52ac304861e71>

<https://bscscan.com/address/0x1af7cf68f100a564325df83ae111cb61c29c54b1>

<https://arbiscan.io/address/0xab6998459d767eeab2c58aa0a08b7bb5990e7f1b>

<https://etherscan.io/address/0x9b74e52ae52ef26ebd4b77aa1929dd06f187cca9>

<https://bscscan.com/address/0x52c200da4c57e3575788306ad8aafd15e8ac3e68>

<https://basescan.org/address/0xca7134443f4bd65c4f7ab30983858c239d88b906>

#### AutoExit (deprecated)

<https://polygonscan.com/address/0x9210a14b2b62607246d453df6ff0860e98aea00e>

<https://optimistic.etherscan.io/address/0x6d55aa15e84bd5847b13bab3245c06b05917d3da>

<https://bscscan.com/address/0xae19eb52cca56c178d695b4d823d81b5f3829bb1>

<https://arbiscan.io/address/0xd82e0be376196690aae31372b25cc9025600ab06>

<https://etherscan.io/address/0xfcc46d2fde6b6eb9ab9f2c8e39802020c8ca4299>

<https://bscscan.com/address/0x4bb7c9f44262af978f84a65bb5b13a8f946003ba>

<https://basescan.org/address/0xde3dee3fbd8fd798e69f13de3745867b2b345d6a>

#### V3Utils (deprecated)

<https://polygonscan.com/address/0xae8999da4d81cb81b42288b12176fe20d7ead578>

<https://optimistic.etherscan.io/address/0xae8999da4d81cb81b42288b12176fe20d7ead578>

<https://arbiscan.io/address/0xae8999da4d81cb81b42288b12176fe20d7ead578>

<https://bscscan.com/address/0xae8999da4d81cb81b42288b12176fe20d7ead578>

<https://etherscan.io/address/0xae8999da4d81cb81b42288b12176fe20d7ead578>

<https://bscscan.com/address/0xd81a68fca163b772f0346881fd98aa1d41aad97d>

<https://basescan.org/address/0x3EB0FFfa1470cDD3725B9EB29ADEd2736144B078>

#### Compoundor (v1, deprecated)

<https://polygonscan.com/address/0x5411894842e610C4D0F6Ed4C232DA689400f94A1>

<https://etherscan.io/address/0x5411894842e610C4D0F6Ed4C232DA689400f94A1>

<https://arbiscan.io/address/0x5411894842e610C4D0F6Ed4C232DA689400f94A1>

<https://optimistic.etherscan.io/address/0x5411894842e610c4d0f6ed4c232da689400f94a1>

<https://bscscan.com/address/0x98eC492942090364AC0736Ef1A741AE6C92ec790>

<https://escan.live/address/0x013573fa9fAF879DB49855aDdF10653F46903419>

<https://basescan.org/address/0x4a8c2bdf0d8d2473b985f869815d9caa36a57ee4>

<https://bscscan.com/address/0x317202b11add82232d06bc13892cd22e38d505d3>

<https://blastscan.io/address/0x6a5023628E1a9a811548a99291f8d5d5cae1dfB3>

####


# Security

All contracts used have gone through the security and auditing processes described below.

Please reach us via email at [`hi@revert.finance`](mailto:hi@revert.finance) for security inquiries, disclosures, or findings.

## Compoundor v1 <a href="#focus-v1" id="focus-v1"></a>

The protocol has had a successful audit process by Peckshield on August 2022. The audit revealed to 2 low-severity and 1 informal recommendation that have been addressed. The results are available [here](https://github.com/peckshield/publications/blob/master/audit_reports/PeckShield-Audit-Report-Revert-Compoundor-v1.0.pdf).

## V3Utils

The V3Utils contract has undergone a comprehensive audit by Peckshield, resulting in its redeployment with enhanced security measures. The audit successfully identified and addressed two low-severity issues and one informational issue. For those who are interested, the full audit report is available [here](https://github.com/peckshield/publications/blob/master/audit_reports/PeckShield-Audit-Report-Revert-V3utils-v1.0.pdf).

## Vesting V3Staker

The forked v3 staker contract has gone through an [audit process](https://github.com/peckshield/publications/blob/master/audit_reports/PeckShield-Audit-Report-Revert-v1.0.pdf) with PeckShield, which was generously sponsored by Polygon, and covered under the grant program for building on top of Uniswap v3, of which this project is the first recipient.

## Self-Compoundor

The Self-Compoundor contract has gone through an audit process with PeckShield. The full report is [available here](https://github.com/peckshield/publications/blob/master/audit_reports/PeckShield-Audit-Report-RevertFinance-SelfCompoundor-v1.0.pdf).

## Auto-Exit and Auto-Range

The Auto-Exit and Auto-Range have undergone an audit process with [Hydn Security](https://hydnsec.com/), the full report is [available here](https://github.com/hydnsec/audits/blob/main/Revert%20Finance%20-%20Exit%20Auto%20%20%26%20Move%20Range/Revert_Finance_Audit_Report_%20Auto-Exit_Auto-Move_Range.pdf).

## Auto-Exit and Auto-Range v2

Version 2 of the automator contracts were also audited by [Hydn Security](https://hydnsec.com/) and the full report is [available here](https://github.com/hydnsec/audits/blob/main/Revert%20Finance%20-%20Exit%20Auto%20%26%20Range%20Auto/HYDN%20-%20Revert%20Finance%20autoExit_autoRange%20Audit%20Report.pdf).

## Revert Lend, V3Utils v1.1, Auto-Compound, Auto-Exit and Auto-Range v3

Version 3 of the automator contracts were audited alongside the Revert Lend protocol contracts, with the reports linked below:

Hydn Security: [Report available here](https://github.com/hydnsec/audits/blob/main/Revert%20Finance%20-%20Lend/HYDN%20-%20Revert%20Finance%20Lend%20Audit%20Report.pdf)\
\
Code4rena: [Report available here](https://code4rena.com/audits/2024-03-revert-lend)

PeckShield: [Report available here](https://github.com/peckshield/publications/blob/master/audit_reports/PeckShield-Audit-Report-Revert-Lend-v1.0.pdf)

## Revert V4Utils v1.0

PeckShield: [Report available here](https://github.com/peckshield/publications/blob/master/audit_reports/PeckShield-Audit-Report-Revert-v4Utils-v1.0.pdf)<br>

## Revert Lend on Aerodrome Slipstream (Base)

The Aerodrome Slipstream deployment of Revert Lend, including the GaugeManager custody layer and the AERO auto-compounding, was reviewed through a competitive audit on [Cantina](https://cantina.xyz/). The full report is [available here](https://github.com/revert-finance/lend/blob/aerodrome-slipstream/report_cli_cantina_efb6f308_f13b_4110_aff8_0d67181608dd_revert_finance.pdf).


# Auto-compounder v1 FAQ

This applies to the now deprecated v1 auto-compounder

### Why should I use auto-compounding if I can do it manually?

The process of collecting fees, swapping them into the required ratio, and adding liquidity to a position requires separate contract interactions and is cumbersome to do manually. From a gas cost perspective, it is best to have some form of automation that bundles all the required actions into one transaction. For high fee APR positions, the optimal number of compounds can be several times a day.

Gas price fluctuates and the Compoundor protocol will incentivize auto-compounding of positions when gas prices are low.

Uncollected fees do not grow at a constant rate, so compounding manually at the optimal moments would require constant monitoring of the fee growths.

Peace of mind.

### What are the costs?

Two percent of the compounded fees. This amount is modifiable by the contract deployer (Revert), but can only be decreased and never increased.

### What modifiable parameters does the Compoundor protocol have?

* **totalRewardX64: T**otal reward paid to the protocol, including the compounder reward. This value starts at 2% (of the compounded fees) and can only be reduced, never increased.
* **compounderRewardX64:** Reward paid to compounder. Must always be less than **totalRewardX64.**
* **maxTWAPTickDifference:** max amount of ticks the current tick may differ from the 60s Oracle TWAP tick to allow swaps. A sanity check to provide price manipulation protection.
* ***TWAPSeconds***: How many seconds should be used to calculate TWAP.

### What are the risks?

When you activate auto-compounding for a position you transfer it to the Compoundor contract. You are able to withdraw your position at any time, but you are subject to the following risks while your position is owned by the contract.

* There is smart-contract risk in the Compoundor protocol.
* Compounding fees will often require swapping some amount of the uncollected fees so that they are at ratio that maximizes the amount of new liquidity added for each position. The PNL for these swaps will depend on what happens with the asset pair prices, they can be negative, and the extra fees accrued from auto-compounding might not make up for that loss.

### Will my position be constantly auto-compounding

The way the Compoundor contract is implemented, there is an incentive for auto-compounding positions which have accumulated enough fees to pay for the gas cost. Anyone can trigger the auto-compounding function.

Additionally Revert is maintaining its own auto-compounding bot to ensure that positions are auto-compounding as frequently as possible.

### Wen token?

There are no plans for any token.

### How to manually withdraw my position from the Auto-compounder?

A position in the auto-compounder contract is withdrawable by the owner at any time and can do so by interacting directly with the smart contract.\
Please follow the next steps to manually withdraw your position from the auto-compounder contract, in case our front-end is unavailable.

1. Visit the contract page for the chain block scanner where the position is located.
   1. Block scanners: [Optimism](https://optimistic.etherscan.io/address/0x5411894842e610c4d0f6ed4c232da689400f94a1#writeContract), [Arbitrum](https://arbiscan.io/address/0x5411894842e610C4D0F6Ed4C232DA689400f94A1#writeContract), [Polygon](https://polygonscan.com/address/0x5411894842e610C4D0F6Ed4C232DA689400f94A1#writeContract), [BNB Chain](https://bscscan.com/address/0x98eC492942090364AC0736Ef1A741AE6C92ec790), [Base](https://basescan.org/address/0x4a8c2bdf0d8d2473b985f869815d9caa36a57ee4#writeContract), or [Mainnet](https://etherscan.io/address/0x5411894842e610C4D0F6Ed4C232DA689400f94A1#writeContract).
2. Connect your wallet.<br>

   <figure><img src="https://1849061604-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FwVXi8b0BXAXDUzfJDx1d%2Fuploads%2Fgit-blob-d971f7f26ef83007bfd769d7fdd05aa70cff2e42%2Fimage.png?alt=media" alt=""><figcaption></figcaption></figure>
3. Select the "WithdrawToken" function and fill out the form.

<figure><img src="https://1849061604-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FwVXi8b0BXAXDUzfJDx1d%2Fuploads%2Fgit-blob-d41a7f04994a9400acb16eae0c3da50cc7b36e99%2Fimage.png?alt=media" alt=""><figcaption></figcaption></figure>

* **tokenId:** Is the NFT id of the position.
  * You can find it in Revert's UI.

    <figure><img src="https://1849061604-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FwVXi8b0BXAXDUzfJDx1d%2Fuploads%2Fgit-blob-f97fe3e4ff5ef6a95359b345c7e21b4419d809e9%2Fimage%20(73).png?alt=media" alt=""><figcaption></figcaption></figure>
  * Alternatively, use the "accountTokens" function from the "Read Contract" tab, in the block scanner (step 1).
    * Insert the position owner address in the first input field and start looking for your positions by entering the number 0 in the second field and clicking on "Query".
      * (In case of having more than one position keep increasing the number until finding all the required IDs.)

        <figure><img src="https://1849061604-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FwVXi8b0BXAXDUzfJDx1d%2Fuploads%2Fgit-blob-fa85dcbe992cd9c1743782e260a3f32b8ab870b1%2Fimage%20(46).png?alt=media" alt=""><figcaption></figcaption></figure>
* **to(address):** Is the destination address where your position is going to be transferred.

{% hint style="warning" %}
Be extra careful when filling out the "address" field. Once the position leaves the Auto-compounder contract is not on Revert's control anymore.
{% endhint %}

* **withdrawBalances:** Enter the word "true".
* **data:** Complete the field with "0x".

4\. Click on "Write" and sign the transaction on your wallet.

By the end of this process, the position will be transferred outside the contract.

### Why has my position not been compounded yet?

Compounding occurs when the unclaimed fees are more than 100x the gas cost of compounding, which varies by network and gas price. The compoundor [whitepaper](https://hackmd.io/@revert/BJcGIJQ35) explains the way it works:

We can estimate the costs of compounding fees using the auto-compounder on Mainnet (25 Gwei), Polygon (50 Gwei), Optimism (0.25 Gwei), BNB Chain (5 Gwei), and Arbitrum (0.2 Gwei). Therefore, assuming an ETH price of $1000, a MATIC price of $0.5 and a BNB price of $300, we can estimate the gas costs for compounding a position using the Compoundor contract on the same chains as shown below.

<table data-header-hidden><thead><tr><th width="136"></th><th width="100"></th><th width="95"></th><th width="106"></th><th width="103"></th><th></th><th></th></tr></thead><tbody><tr><td>Function</td><td>Gas cost</td><td>Mainnet</td><td>Optimism</td><td>Arbitrum</td><td>Polygon</td><td>BNB Chain</td></tr><tr><td>Auto-Compound</td><td>479,521</td><td>$11.99</td><td>$0.12</td><td>$0.10</td><td>$0.01</td><td>$0.72</td></tr></tbody></table>

For Optimism and Arbitrum, we used estimated Gwei amounts to avoid doing the L2 gas price calculation.\
\
For instance, given the above estimations, an Optimism position should have accrued at least a total of $12 worth of fees ($0.12\*100) to compound automatically.


