
ATLIS
Laddered, time-decaying automated trading strategies that are intended to grow "HODL" stacks
Demo
About
This project is a rebalancing trading bot leveraging 1inch Aqua. It purchases WETH with USDC and then attempts to sell it for a higher price. The strategy begins by defining a price ladder, where each price is roughly 2.5% higher than the one below it on the ladder. The protocol will create "buy"and "sell" orders as concentrated liquidity positions on 1inch Aqua. For example, the strategy will create a sell order ranging from roughly 5% above the average purchase price to 20% above the average purchase price. Similarly, a standing "buy" order will exist below the average buy price. The concentrated liquidity setup is used because it allows us to scale into positions proportional to price movements. When WETH dips heavily, we buy more, and when it goes up quickly, we sell proportionally more. The strategy will leave some USDC initially un-deployed, and then over time it will deploy more capital. Every "period", the strategy rebalances, deploying more capital into the "buy" side based on user configuration. during each rebalance, the "time decaying" nature of the system may occur. If the current spot price of WETH is higher than the average buy price, the system will sell some pre-defined portion of the held WETH on Uniswap. This will be repeated every time a rebalance occurs while the system is in profit. This way, we capture profits every time we are able, while not completely exiting the trade immediately. Finally, during a rebalance, we may also purchase some WETH (on Uniswap) if the spot price is lower than the average entry price of the strategy. The amount of "dry powder" USDC that is used for a direct buy during a rebalance is based on user defined parameters. Every rebalance, buying or selling may occur if the spot price differs from the entry price. Then, the average entry price is recomputed, buy and sell liquidity ranges are recomputed, and a new set of Aqua strategies are shipped. The system redirects proceeds from sales into a "tax" and "profit" wallet, such that the profit wallet will passively grow in USDC value over time.
How it's made
This project uses 1inch Aqua, Uniswap v3, and Chainlink oracles on Base Mainnet. The general structure of the project is centered around a "Manager" contract, which is the owner of two "ladder proxies". These ladder proxies hold the funds and are the addresses associated with the "buy" and "sell" Aqua strategies. The Manager contract computes the values of the ladder rungs, as well as tracking average entry price for all WETH purchased. Average entry price is the universally used value for profit accounting, and by doing this we can ensure that purchasing new WETH at a low price helps to bring the average purchase price down. The Manager holds the "amount spent on WETH" and uses the WETH balance held by itself and strategies to compute the average entry price. On every rebalance, which must be triggered manually by the Manager's owner, the manager will call into the proxies, having them dock their aqua strategies and transfer all funds into the Manager contract. The Manager will first tabulate profit from any WETH sold, then proceed to sell more WETH if the spot price is high enough. This does not change the average entry price. Profit and "taxes" will be redirected to two separate wallets, and the principle USDC will be re-invested in the strategy. After tabulating profit, the manager will tabulate the new average entry price based on any new WETH purchased from the buy side. Then, the manager will compute the new amount of USDC to make "active", and potentially purchase some WETH if the spot price is low enough. Finally, new buy-band and sell-band price limits will be computed based on the spot price and average entry price (the bands must not include either). These price limits will be passed into the buy and sell proxies, along with USDC for the buy side and WETH for the sell side, and then the proxies will use these amounts and price boundaries to construct an Aqua concentrated liquidity position, and then call `ship` in Aqua to make the strategy live. At any point, partial fills can be "harvested" to prevent selling WETH at a low price or buying it at a high price. A harvest simply transfers purchased WETH out of the buy-side, or transfers USDC out of the sell-side, and into the Manager. The manager will include these in its rebalance computations. If harvest is not called in a timely manner, the ATLIS system still benefits in the form of trading fees. The ATLIS system also has a simple emergency withdraw functionality, which allows the Manager to pull funds into its own address from the proxies. This is great in the case that a strategy cannot easily be docked via the proxy functions. Aqua allows the proxies to retain custody of their funds. If there is ever an emergency, funds are transferred directly back to the manager, which does not possess an Aqua strategy, at which point those funds are safe. Various libraries were created for this project, in order to construct Aqua strategies, convert prices to "square root price" form (needed for Aqua), read chainlink prices and convert them to a standardized form, and simulate trades on uniswap. The Aqua strategy builder I have implemented was based on the bytecode used for generating real Aqua strategies on-chain (I tested them using my own wallet and dissected the bytecode), so we can be sure that they both work and are designed in an Aqua-friendly way.