Skip to content

Commit eedcc53

Browse files
authored
fix spot sdot overflow (paritytech#616)
1 parent d1a9f93 commit eedcc53

File tree

3 files changed

+9
-5
lines changed

3 files changed

+9
-5
lines changed

rpc/src/chainx/impl_rpc.rs

+8-4
Original file line numberDiff line numberDiff line change
@@ -560,9 +560,12 @@ where
560560
if !handicap.lowest_offer.is_zero() {
561561
info.maximum_bid = handicap.lowest_offer + pair.fluctuation();
562562
}
563-
if !handicap.highest_bid.is_zero() {
563+
if handicap.highest_bid > pair.fluctuation() {
564564
info.minimum_offer = handicap.highest_bid - pair.fluctuation();
565+
}else {
566+
info.minimum_offer = 10_u64.pow(pair.tick_precision);//tick
565567
}
568+
566569
}
567570

568571
pairs.push(info);
@@ -642,10 +645,11 @@ where
642645
lowest_offer + pair.fluctuation()
643646
};
644647

645-
let minimum_offer = if highest_bid.is_zero() {
646-
0
647-
} else {
648+
let minimum_offer = if highest_bid > pair.fluctuation() {
648649
highest_bid - pair.fluctuation()
650+
} else {
651+
10_u64.pow(pair.tick_precision)
652+
649653
};
650654

651655
for price in (lowest_offer..=maximum_bid).step_by(tick as usize) {
Binary file not shown.

xrml/xdex/spot/src/manager/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ impl<T: Trait> Module<T> {
4949
fluctuation
5050
);
5151

52-
if lowest_offer.is_zero() {
52+
if highest_bid.is_zero() {
5353
return Ok(());
5454
}
5555

0 commit comments

Comments
 (0)