Skip to content

Commit

Permalink
fix spot sdot overflow (paritytech#616)
Browse files Browse the repository at this point in the history
  • Loading branch information
toxotguo committed May 16, 2019
1 parent d1a9f93 commit eedcc53
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 5 deletions.
12 changes: 8 additions & 4 deletions rpc/src/chainx/impl_rpc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -560,9 +560,12 @@ where
if !handicap.lowest_offer.is_zero() {
info.maximum_bid = handicap.lowest_offer + pair.fluctuation();
}
if !handicap.highest_bid.is_zero() {
if handicap.highest_bid > pair.fluctuation() {
info.minimum_offer = handicap.highest_bid - pair.fluctuation();
}else {
info.minimum_offer = 10_u64.pow(pair.tick_precision);//tick
}

}

pairs.push(info);
Expand Down Expand Up @@ -642,10 +645,11 @@ where
lowest_offer + pair.fluctuation()
};

let minimum_offer = if highest_bid.is_zero() {
0
} else {
let minimum_offer = if highest_bid > pair.fluctuation() {
highest_bid - pair.fluctuation()
} else {
10_u64.pow(pair.tick_precision)

};

for price in (lowest_offer..=maximum_bid).step_by(tick as usize) {
Expand Down
Binary file not shown.
2 changes: 1 addition & 1 deletion xrml/xdex/spot/src/manager/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ impl<T: Trait> Module<T> {
fluctuation
);

if lowest_offer.is_zero() {
if highest_bid.is_zero() {
return Ok(());
}

Expand Down

0 comments on commit eedcc53

Please sign in to comment.