Ricochet-Exchange / ricochet-keeper

Keeper for Ricochet Protocol, implemented with Apache Airflow
5 stars 10 forks source link

Test Transaction Status before Sending #11

Closed mikeghen closed 2 years ago

mikeghen commented 2 years ago

Many distribute calls fail for BAD_EXCHANGE_RATE which just means the exchange price on sushi/quickswap is no good compared to the "global" price reported by tellor. Right now we just send these txns and let them fail, wasting gas.

This issue is to add a pre-send check in the ContractInteractionOperator to check that a transaction won't fail, something like:

txn = self.function(...).buildTransaction(..)
if not confirm_success(txn):
   return False
...

where confirm_success will use web4py to verify the txn will be successful (without executing it).

mikeghen commented 2 years ago

https://web3py.readthedocs.io/en/stable/contracts.html?highlight=transact#web3.contract.ContractFunction.estimateGas I do think this is what can be used to check failure I think if .estimateGas() throws a ValueError then its telling you the txn will fail not 100% sure, Ive not tried it