Skip to content

Commit

Permalink
Fix/spot price (paritytech#243)
Browse files Browse the repository at this point in the history
fix spot price
  • Loading branch information
toxotguo authored Jan 24, 2019
1 parent 19b5938 commit 8994288
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions rpc/src/chainx/impl_rpc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -550,9 +550,9 @@ where
}

let max_price: Balance =
handicap.sell * ((100_u64 + price_volatility as Balance) / 100_u64);
(handicap.sell * (100_u64 + price_volatility as Balance)) / 100_u64;
let min_price: Balance =
handicap.sell * ((100_u64 - price_volatility as Balance) / 100_u64);
(handicap.sell * (100_u64 - price_volatility as Balance)) / 100_u64;
let mut n = 0;

loop {
Expand Down
Binary file not shown.
6 changes: 3 additions & 3 deletions xrml/xdex/spot/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -404,16 +404,16 @@ impl<T: Trait> Module<T> {
OrderDirection::Buy => {
if handicap.sell > Zero::zero()
&& price
> (handicap.sell
* As::sa((100_u32 + <PriceVolatility<T>>::get()) / 100_u32))
> ((handicap.sell
* As::sa(100_u32 + <PriceVolatility<T>>::get())) / As::sa(100_u32))
{
return Err("price cann't > PriceVolatility");
}
}
OrderDirection::Sell => {
if handicap.buy > Zero::zero()
&& price
< (handicap.buy * As::sa((100_u32 - <PriceVolatility<T>>::get()) / 100_u32))
< (handicap.buy * As::sa(100_u32 - <PriceVolatility<T>>::get()) / As::sa(100_u32))
{
return Err("price cann't > PriceVolatility");
}
Expand Down

0 comments on commit 8994288

Please sign in to comment.