Hey so Imperm Loss is probably the biggest risk LPs face and is the largest barrier to entry for them to provide funds, reducing the size and liquidity of DeFi Markets. So I made an algo to fix this by using post trade price as the rate of exchange rather than pretrade price. This makes it so that if price moves to any value n then if a single trade is made that will set the previous value to n then the trader will get a fair rate on the assets, itll make it so that LPs suffer no imperm loss and itll allow for the protocol to grow as risk is reduced. Do note that this model only removes IL in cases where there is a market maker that is able to trade with the AMM such that it always keeps the price tracking realtime price. This could be incentivised by a small part of the fees going to the MM which would be a smart contract and so as the liquidity grows for the AMM the MM will become better funded in order to be able to deploy the capital required to do the new price in 1 single trade. If a trade is not enough to set the new price using the inbal/outbal = price then there will be IL. This will in reality probably be a IL reducing algo not a ILless algo. But if designed well a system would be able to use fees and automate the MM to be able to make IL in almost all cases 0.
bar = 1 - (token_in_balance / (token_in_balance + amount_in));
amount_out = token_out_balance * bar;
inbal = token_in_balance + amount_in;
outbal = token_out_balance - amount out;
price = inbal/outbal
amount_out = amount_in/ price
token_out_balance = - amount out