Apostro algorithms
Or how it works behind the scenes
Market impact
Market impact cost calculation algorithms are designed to estimate the minimum capital required to change the price on a target exchange through market orders. Target prices for manipulation are calculated based on protocols' risk parameters.
Uniswap V3
Our methodology involves the use of Time-Weighted Average Prices (TWAPs) within oracle settings to ensure precise price estimations. The impact cost algorithm calculates the cost of short-term (5-10 minute timeframe) TWAP manipulation on Uniswap V3 using a single market order. We assume that there is sufficient liquidity available on other decentralized markets, allowing the token to be sold at a price close to the current market rate.
If the token has low liquidity, long-term attacks may be more profitable, while the actual impact costs could be lower than estimated (described in the next section).
Actual short-term TWAP manipulation costs may be higher or lower than reported depending on the manipulation mechanics used.
Upper Bound
In cases where Chainlink-like oracles are used, or short-term (1-5 minutes) manipulation estimated by the Uniswap model isn't feasible, we have developed an upper-bound formula for manipulation costs. The predicted market impact is proportional to the order size and inversely proportional to the token's market capitalization.
This model has been tested extensively and is expected to provide a confident upper bound for manipulation costs; however, real costs may be many times lower than those produced using this approach.
Here are several examples that illustrate use cases for both methods.
Example 1
- Suppose we have a pool consisting of $WETH, $USDC and $SHI, the latter one being a low-cap ($2M) token; - WETH and USDC price manipulation is basically impossible due to the huge liquidity, therefore, manipulation costs only make sense for $SHI. Let's also assume that the target price increase for a manipulation is 40% for $SHI. - Uniswap V3 TWAP is used as the price feed for $SHI; - The liquidity for $SHI is placed in such a way that a short-term TWAP manipulation requires $10B+; - Meanwhile, according to even general economic knowledge, buying 10% of the market capitalization increases the price by at least 10% with a longer-lasting impact. Therefore, pumping up $SHI by the aforementioned 40% requires no more than 40% * $2M = $800K; our Upper Bound algorithm will show ~200K; - This number will be displayed in the dashboard as Impact Cost for $SHI instead of $10B.
Example 2
- Assume the same setup, but now $SHI liquidity on Uniswap is placed on a narrow range, making short-term TWAP manipulation relatively cheap (~$50K); - This number will be displayed in the dashboard, and the Upper Bound result will be neglected.
Example 3
- Assume the same setup, but now $SHI is mostly traded on small centralized exchanges and Chainlink price is used, with no TWAP constructed on top. - Market conditions are such that most of $SHI supply is locked in reward farming or inactive in other ways, and the liquidity available on exchanges is only a fraction of the value expected for a token with such capitalization. - In this case, pushing the price up for several minutes by 40% can in fact cost $20K, while the cost predicted by the Upper Bound algorithm is ~$200K. For now, while we are developing a universally accurate market impact model, Upper Bound results will be displayed in the dashboard.
Last updated