sora2-network icon indicating copy to clipboard operation
sora2-network copied to clipboard

ALT: quote rounding

Open wer1st opened this issue 8 months ago • 0 comments

Situation

There is a situation (most likely with Order Book) when liquidity sources cannot provide the exact desired input/output amount.

Example

Order Book has the ask order with price 3600 XOR for 1 VAL. step_lot_size = 0.00001

quote XOR -> VAL with desired input 5000 cannot obtain exact 5000, because the result is

input: 5000
output: 1.388888888888885 - it must be alingned by 0.00001

We can get:

input: 4999.96800000001399991
output: 1.38888

or

input: 5000.004000000014000011
output: 1.38889

It's better to select the 1st variant, because we shouldn't take more than user is ready to spend.

Solution

Introduce internal slippage tollerance (default value is 0.1% as on https://polkaswap.io/).

wer1st avatar May 28 '24 14:05 wer1st