hashgraph / hedera-exchange-rate-tool

Hedera Exchange Rate Tool to send median of HBAR/USD exchange rate from various Exchanges to Hedera Network
Apache License 2.0
3 stars 4 forks source link

ERT should also clip current Rate if out of bound #145

Closed anighanta closed 3 years ago

anighanta commented 3 years ago

Summary of the defect Example on how an ERT would push a rate that would give back EXCHANGE_CHANGE_LIMIT_EXCEEDED from the nodes:

Say: midnightRate on nodes and ERT is : currentRate : 207129/30000 and nextRate : 216305/30000

bounds on them would be with 25% : currentRate : 258911/30000 and nextRate : 270381/30000

last successful file update: currentRate : 253398/30000 and nextRate : 261120/30000

next file update failed with following rates: currentRate : 261120/30000 and nextRate : 270381/30000

As Nodes enforce the bound on both currentRate and nextRate where as ERT just enforces it on nextRate, there will be cases when ERT thinks that the rate is good enough but Nodes reject it.

So enforce the bound on currentRate too on the ERT side.