project-serum / swap

Swap on the Serum Order Book
Apache License 2.0
78 stars 90 forks source link

Use `min_amount_out` rather than `min_exchange_rate ` #32

Open gitmalong opened 2 years ago

gitmalong commented 2 years ago

Scenario: Token A decimals: 6 Token B decimals: 0 Exchange Rate: 1 -> 6 A 1 = 6 B Program internally expects a min_amount_out of 6 A 1 + (6*0.04) = 6.24 Therefore I have to adjust the exchange rate to 6 B / 1,04 = 5,77 As the exchange rate must have B decimals I would need to round it down to 5! That makes the minimum amount out my exchange rate guarantees thrift far away from the original expected min_amount_out.

So instead of setting the threshold via an Exchange rate I suggest to set a min_amount_out threshold.