Closed kilrau closed 6 years ago
Thanks for catching and describing this, it's indeed a bug and it's possible for the amounts to get switched. I opened a PR to fix this and also a similar bug in the logic for deriving the SwapResult
from a completed swap.
@moshababo discovered:
I was looking at the swaps code for something, and there’s something in the currency/amount calculations that I don’t understand. Considering i’m on pair
LTC/BTC
and the price is0.01
. we have 2 scenarios:1)
maker order: buy quantity 5 taker order: sell quantity 5
swap amounts: maker: 5 LTC taker: 0.05 BTC
buy
, then he wants to buy LTC. so why he’s the one sending LTC?2)
maker order: sell quantity 5 taker order: buy quantity 5
swap amounts maker: 5 BTC taker: 0.05 LTC
--
My calculations are based on: https://github.com/ExchangeUnion/xud/blob/master/lib/swaps/Swaps.ts#L91 https://github.com/ExchangeUnion/xud/blob/master/lib/swaps/Swaps.ts#L241