Impermanent Lossless AMM Model Using PostTrade Price

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.

price(amount_in)
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
return price;

amount_out = amount_in/ price
token_in_balance=+ amount_in
token_out_balance = - amount out

I think the problem with your solution is that the impermanent loss is mostly the result of the price drifting over time. So there will be a lot of small changes instead of one big jump. For big trades the user could split the trade into smaller pieces to get a better price at the cost of higher gas fees. I don’t think this is an improvement over the original.

Btw, the latest improvement of the AMM design is from Mooniswap.
They are updating the price slowly after a big trade, such that the liquidity providers are getting a cut in the arbitrage income of getting the pool back to normal prices levels.