Required Amount of Currency (RAC)
When dealing with a single pool governed by some AMM curve, it is possible to deduce the feasible token amounts by accounting for the impact of MEV/Arbitrage on the pool. However, DEX aggregators use various liquidity sources to facilitate swaps. It is almost impossible (or a significant undertaking) to assume what will happen to the aggregated liquidity sources as a result of price disparity and MEV/Arbitrage. What we can do however, is give an approximation or worse case scenario.
The Murabaha Aggregator/Order Book queries the DEX aggregator in the following way :
What amount (A) of Murabaha token (i.e. UNI) do we need to sell to obtain B amount of Currency token (i.e. USDT)
What amount (C) of the Currency Token (USDT) do we need to swap in order receive the amount (A) of the Murabaha token specified in the first query.
This amount (C) is then appended to account for the slippage in order to derive the base debt that will be owed to the AZKA pool as follows:
The DEX Aggregator Quote (Q) value is essentially the amount of currency token (USDT) and represents the base debt (ex additional protocol fees) in the currency token that the user would would owe the pool. The DEX aggregator quote/base debt is what will be taken from the pool to facilitate the takers request.
If price impact is greater than 1% the calculation starts to lose accuracy and may not be feasible to use as a good approximation. This is because we are receiving both quotes before any transaction is executed. We can assume that aggregated on-chain liquidity will return to its original state but if price impact is large it could cause a more broad market price movement that will make on-chain liquidity and price less predictable. It is also not a bad idea to set a small buffer on the RAC value just in case.
The Murabaha Aggregator/Order Book then adds on any additional Fees to the DEX Aggregator Quote/Base Debt as follows:
The Murabaha and protocol fees are a compensation for the providing this financing up front for the specified duration. It is possible; that due to the pool already having a high utilisation and/or the impact of the DEX Quote/Base debt on the pools utilisation; the Murabaha fee and Protocol fee is quite high. This coupled with price impact and gas fees might make the Murabaha transaction unfeasible for the taker.
Last updated