Skip to content

Commit

Permalink
Merge pull request #1 from vfat-io/automation
Browse files Browse the repository at this point in the history
Automation docs
  • Loading branch information
vfat0 committed Jul 5, 2024
2 parents 66a06f2 + 695eb24 commit ab5710b
Show file tree
Hide file tree
Showing 7 changed files with 116 additions and 0 deletions.
27 changes: 27 additions & 0 deletions automation/compound.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Automatic Compound

Auto-Compound automatically compounds your positions at the optimal frequency.

This is calculated using a formula that takes in the position size, the APR and the current gas cost.

There is a 1.8% auto-compound fee on rewards, part of which is used to pay for gas costs (no further user input needed).

The setting can be enabled in two places:

Firstly in the general settings (gear icon on the top right).

![Settings](../img/automation/settings.png)

Secondly in the Compound tab of any active position.

![Compound](../img/automation/compound.png)

It is enabled once per chain and applies to all positions on that chain.

The general setting of Automation needs to be enabled as well, so this requires two transactions:
a) Enable Automation
b) Enable Auto-Compound

These can then be disabled in the general settings.

Auto-Compound and Auto-Harvest are mutually exclusive, only one per chain can be enabled.
25 changes: 25 additions & 0 deletions automation/harvest.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Automatic Harvest

Auto-Harvest automatically harvests your positions up to once per day, with the minimum earnings currently set to the equivalent of $50.

There is a 1.2% auto-harvest fee on rewards, part of which is used to pay for gas costs (no further user input needed).

The setting can be enabled in two places:

Firstly in the general settings (gear icon on the top right).

![Settings](../img/automation/settings.png)

Secondly in the Harvest tab of any active position.

![Harvest](../img/automation/harvest.png)

It is enabled once per chain and applies to all positions on that chain.

The general setting of Automation needs to be enabled as well, so this requires two transactions:
a) Enable Automation
b) Enable Auto-Harvest

These can then be disabled in the general settings.

Auto-Harvest and Auto-Compound are mutually exclusive, only one per chain can be enabled.
11 changes: 11 additions & 0 deletions automation/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Automation

Sickle enables three different forms of automation:

[Auto-Harvest](harvest.md) automatically harvests earnings and optionally converts them to a different token.

[Auto-Compound](compound.md) automatically compounds earnings into each position.

[Auto-Rebalance](rebalance.md) automatically rebalances a concentrated liquidity position once it is out of range.

In order to use one of these, Automation first needs to be enabled on that chain (allowing our Automation contract to call these functions on behalf of your Sickle). For more information on how to enable each one please see their dedicated documents.
53 changes: 53 additions & 0 deletions automation/rebalance.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
# Automatic Rebalance

When a concentrated liquidity (CL) position is out of range, it needs rebalancing. This is done by withdrawing the single token in the position (since out of range positions are only comprised of one token), swapping an appropriate amount of it for the other token, and then creating a new CL position in-range.

Auto-Rebalance does this by monitoring all out of range positions in a loop. When one is found, we retrieve quotes for swaps from all supported aggregators, then simulate the transaction using the best one. If it results in less dust (leftover tokens) and price impact than the user has specified, the rebalance takes place, otherwise the attempt is repeated in the next loop.

The new position will use the same width as the previous one, but centered under the new price. For example a -1% +2% width position (-100 ticks, +200 ticks from active tick space), will remain -1% +2% after rebalancing.

Auto-Rebalance will automatically be activated for the new position as well, using the same settings as the last position.

Enabling Auto-Rebalance is done in the Rebalance tab in an active CL position (whether in range or not).

## Required Configuration

### Rewards

There are two ways to handle the rewards that a position has accumulated before it went out of range, they can be either compounded back into the position or harvested out to the user's wallet. Optionally when harvesting it can be converted to a different token. The fee charged is 1.8% of rewards.

### Slippage

The user has to select an appropriate slippage. This is used both for the dust calculation and for price impact. For instance in a pool with large liquidity rebalancing may work with as low as 0.1%, but for smaller pools or larger positions a higher value would be required.

Further to slippage there are two advanced configuration options. These are optional, and they are used to create a custom range in which Auto-Rebalance should take place. The default setting, when not using advanced configuration, is to always attempt to rebalance when the position is out of range.

## Advanced Configuration

### Buffer

This adds a buffer on either side of the position range, in which rebalancing should not take place. For example if a user's position is in the 3000-3300 range, a buffer of -1% on the lower side will mean that rebalance will not take place when the price is between 2970 and 3000. While the price is in that buffer the position will remain as is.

Similarly in that example a buffer of +1% on the upper side will mean that rebalance will not take place between 3300 and 3333.

Buffer settings are relative, so a buffer of -1% +1% will remain so when a position is rebalanced (-1% from the new lower end, +1% from the new upper end).

### Stop Loss

Lastly stop loss values can be set on either side. Continuing the previous example, a stop loss value of 2700 on the lower side will mean that automatic rebalancing will stop completely if the price drops below 2700.

The same mechanism on the upper side if setting a stop loss of 3600 would disable all automatic rebalancing once hte price goes above 3600.

Stop loss settings are absolute, so a stop loss setting of 2700, 3600 will remain the same when a position is rebalanced.

### Advanced Settings Example

Putting all advanced settings together, for the example position of 3000-3300, creates two ranges on either side of the user's position where automatic rebalance will take place:

2700-2970 and 3333-3600

As well as four ranges where automatic rebalance will not take place:

0-2700, 2970-3000, 3300-3333, 3600-infinite

The advanced settings are entirely optional, the default behaviour when not setting a buffer and stop loss would be to rebalance whenever the position is out of range.
Binary file added img/automation/compound.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added img/automation/harvest.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added img/automation/settings.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit ab5710b

Please sign in to comment.