Skip to content

Commit 203e1ec

Browse files
authored
fix: add warn where trigger_value is below 0.1 grt (#340)
1 parent ad8d4fb commit 203e1ec

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

config/src/config.rs

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,27 @@ impl Config {
9494
),
9595
_ => {}
9696
}
97+
let grt_wei = self.tap.max_amount_willing_to_lose_grt.get_value();
98+
let decimal = BigDecimal::from_u128(grt_wei).unwrap();
99+
let divisor = &self.tap.rav_request.trigger_value_divisor;
100+
let trigger_value = (decimal / divisor)
101+
.to_u128()
102+
.expect("Could not represent the trigger value in u128");
103+
let minimum_recommended_for_max_willing_to_lose_grt = 0.1;
104+
if trigger_value
105+
< minimum_recommended_for_max_willing_to_lose_grt
106+
.to_u128()
107+
.unwrap()
108+
{
109+
warn!(
110+
"Trigger value is too low, currently below 0.1 GRT. \
111+
Please modify `max_amount_willing_to_lose_grt` or `trigger_value_divisor`. \
112+
It is best to have a higher trigger value, ideally above 1 GRT. \
113+
Anything lower and the system may constantly deny the sender. \
114+
`Trigger value` is defined by: \
115+
(max_amount_willing_to_lose_grt / trigger_value_divisor) "
116+
)
117+
}
97118

98119
let ten: BigDecimal = 10.into();
99120
let usual_grt_price = BigDecimal::from_str("0.0001").unwrap() * ten;

0 commit comments

Comments
 (0)