Formula
The arbitration logic of NostraSwap is to maximize the product invariant by bringing the market price of the third party DEX as close to our market price as possible, eliminating any potential arbitrage opportunity. 10% of the arbitraging profit goes to the trader, while the rest goes to the liquidity pool.
NostraSwap begins with determining the amount of bonus token the trader should receive by calculating the profit from the arbitrage from the newReserves
NostraSwap expects to have if it arbitrages between itself and a third party DEX with the assumption that no bonus token will be returned to the trader.
Where
is the expected new reserve of the token is the post-swap, pre-arbitrage reserve of the token is the post-swap, pre-arbitrage reserve of the token in the third party DEX.
The percent increase of the pool value can be calculated by:
NostraSwap then uses this ratio to calculate the arbitration profit. 10% of the expected arbitration profit is sent to the trader. This calculation is done on all third-party DEXes to find the one that would yield the best profit.
Then, NostraSwap initiates the actual arbitrage between itself and the third party DEX repeating the calculation of , with its new reserves since the bonus token is already returned to the trader, to find the optimal amount of token to swap with third-party DEX.
Last updated
Was this helpful?