Lately, I've seen a video on youtube on the EatTheBlocks channel concerning the arbitrage options on Aurora. I had already heard about that one, but never actually try to use that blockchain, and was not really sure to understand what it was in the first place. Time to change that in this session and check if I could successful run my Arb monitoring system there, let's rock it baby 😎!
"aurora": { "chain_id": 1313161554, "provider_url": "https://mainnet.aurora.dev", "short_name": "aurora", "explorer_url": "https://aurorascan.dev/", "abi_provider_url": "https://api.aurorascan.dev/api?module=contract&action=getabi&address=", "default_account": "evm_default", "max_gas_price": 50, "chain_db_name": "aurora_chain", "default_gas_price": 27, "gas_price_weights": { "default": [20.0, 0.8, 0.2, 0.0], "fast": [15.0, 0.4, 0.6, 0.0], "high": [10.0, 0.0, 1.5, 0.0], "ultra": [8.0, 0.0, 0.9, 0.1] }, "native_symbol": "AURORA" }
from nvp.nvp_context import NVPContext import numpy as np from hexbytes import HexBytes import matplotlib.pyplot as plt if NVPContext.instance is None: NVPContext() ctx = NVPContext.get() chain = ctx.get_component('aurora_chain') bck = chain.get_block('latest', full_tx=True) bck
$ nvp collect_aurora_blocks (...) File "D:\Projects\NervHome\nvh\crypto\blockchain\evm_sig_map.py", line 20, in __init__ self.native_address = chain.get_wrapped_native_token().address() File "D:\Projects\NervHome\nvh\crypto\blockchain\evm_blockchain.py", line 807, in get_wrapped_native_token self.native_token = self.get_token(self.native_symbol) File "D:\Projects\NervHome\nvh\crypto\blockchain\evm_blockchain.py", line 828, in get_token self.check(desc is not None, "No token found with symbol %s", addr) File "D:\Projects\NervProj\nvp\nvp_object.py", line 73, in check raise NVPCheckError(fmt % args) nvp.nvp_object.NVPCheckError: No token found with symbol AURORA
if cmd == "add-token": chain_name = self.get_param("chain") chain: EVMBlockchain = self.get_component(f"{chain_name}_chain") addr = self.get_param("address") # We check if we have a token for that address: token = chain.get_token(addr) if token is not None: logger.info("Found token '%s'", token.symbol()) else: logger.info("Token not found.") return True
$ nvp bchain add-token -c aurora 0xC9BdeEd33CD01541e1eeD10f90519d2C06Fe3feB
$ nvp collect_aurora_blocks 2022/07/06 21:06:29 [collect_evm_blocks] INFO: Collect 11 blocks and 19 transactions
$ nvp bchain collect-gas-price -c aurora 2022/07/06 21:09:49 [nvh.crypto.blockchain.evm_blockchain] INFO: Ignoring block 69270259: not enough transactions.
$ nvp bchain collect-gas-price -c aurora 2022/07/06 21:19:28 [nvh.crypto.blockchain.evm_blockchain] INFO: Block 69270699: num_tx=2, mode=0.070, mean=0.070, dev=0.000
chain.handle("find_uniswap_routers")
File D:\Projects\NervHome\nvh\crypto\blockchain\handlers\find_uniswap_routers.py:68, in handle(chain) 65 cdb: ChainDB = chain.get_db() 67 sql = "SELECT to_id from transactions WHERE sig = ANY(%s);" ---> 68 cur = cdb.execute(sql, (sigs_i32,)) 69 rows = cur.fetchall() 70 ids = [row[0] for row in rows] File D:\Projects\NervHome\nvh\crypto\blockchain\chain_db.py:191, in ChainDB.execute(self, *args, * *kaargs) 189 def execute(self, *args, * *kaargs): 190 """Forward execute code to the SQL DB""" --> 191 return self.sql_db.execute(*args, * *kaargs) File D:\Projects\NervHome\nvh\core\postgresql_db.py:62, in PostgreSQLDB.execute(self, code, data, many, commit) 60 c.executemany(code, data) 61 else: ---> 62 c.execute(code, data) 63 if commit: 64 self.conn.commit() UndefinedTable: relation "transactions" does not exist LINE 1: SELECT to_id from transactions WHERE sig = ANY(ARRAY[2146658...
{ "inputs": [], "name": "factory", "outputs": [ { "internalType": "address", "name": "", "type": "address" } ], "stateMutability": "view", "type": "function" },
def add_function(self, fname): """Add a function to the abi""" # fname will be a full function declaration, so we parse it as such: full_sig = fname idx = fname.find("(") idx2 = fname.find(")") self.check(idx > 0 and idx2 > 0, "Invalid function declaration: %s", full_sig) args = fname[idx + 1 : idx2] fname = fname[:idx] mods = fname[:idx2] state = "nonpayable" for sname in ["view", "pure", "payable"]: if sname in mods: state = sname # in the function name part we may still have the return value type first and # then the actual function name, so we check if we have a space in the name: outputs = [] if " " in fname: parts = fname.split(" ") self.check(len(parts), "Unexpected function signature: '%s'", full_sig) # Update the function name: fname = parts[1] # We may still split the return types on commas here: rets = parts[0].split(",") for idx, rname in enumerate(rets): desc = {"internalType": rname, "name": f"out{idx}", "type": rname} outputs.append(desc) logger.debug("Adding function '%s' with args '%s'", fname, args) inputs = [] args = [] if args == "" else args.split(",") for idx, aname in enumerate(args): inputs.append({"internalType": aname, "name": f"arg{idx}", "type": aname}) desc = {"inputs": inputs, "name": fname, "outputs": outputs, "stateMutability": state, "type": "function"} self.abi.append(desc)
logger.info("Retrieving factory addresses...") funcs = ["address factory()"] for desc in descs: addr = desc["router_address"] # logger.info("Current router: %s", addr) contract = chain.get_contract(addr, funcs=funcs) try: factory_addr = contract.call_function("factory") logger.info("Factory for router %d: %s", desc["router_id"], factory_addr) desc["factory_address"] = factory_addr except NVPCheckError: logger.error("Cannot retrieve factory for router %s", addr) desc["factory_address"] = None
2022/07/07 07:26:02 [find_uniswap_routers] INFO: Searching for routers in 2068 transactions... 2022/07/07 07:26:02 [find_uniswap_routers] INFO: Found 7 routers: 2022/07/07 07:26:02 [find_uniswap_routers] INFO: - 0x2CB45Edb4517d5947aFdE3BEAbF95A582506858B: 1784 2022/07/07 07:26:02 [find_uniswap_routers] INFO: - 0xa3a1eF5Ae6561572023363862e238aFA84C72ef5: 242 2022/07/07 07:26:02 [find_uniswap_routers] INFO: - 0xcCC7B6CD8764E84Be19BD13b25850C4ac24aa2C0: 20 2022/07/07 07:26:02 [find_uniswap_routers] INFO: - 0xBaE0d7DFcd03C90EBCe003C58332c1346A72836A: 15 2022/07/07 07:26:02 [find_uniswap_routers] INFO: - 0xE52854C86fb64B04dd1D77AD542876dDC040c4f4: 3 2022/07/07 07:26:02 [find_uniswap_routers] INFO: - 0xA1B1742e9c32C7cAa9726d8204bD5715e3419861: 2 2022/07/07 07:26:02 [find_uniswap_routers] INFO: - 0x3d99B2F578d94f61adcD899DE55F2991522cefE1: 2 2022/07/07 07:26:02 [find_uniswap_routers] INFO: Retrieving factory addresses... 2022/07/07 07:26:03 [find_uniswap_routers] INFO: Factory for router 2: 0xc66F594268041dB60507F00703b152492fb176E7 2022/07/07 07:26:03 [find_uniswap_routers] INFO: Factory for router 187: 0x7928D4FeA7b2c90C732c10aFF59cf403f0C38246 2022/07/07 07:26:04 [find_uniswap_routers] INFO: Factory for router 648: 0x78f406B41C81eb4144C321ADa5902BBF5de28538 2022/07/07 07:26:04 [find_uniswap_routers] INFO: Factory for router 548: 0x34484b4E416f5d4B45D4Add0B6eF6Ca08FcED8f1 2022/07/07 07:26:05 [find_uniswap_routers] INFO: Factory for router 1042: 0x70dcc803784bd540d9f2A29b99C4df0130E348BB 2022/07/07 07:26:05 [find_uniswap_routers] INFO: Factory for router 738: 0xC5E1DaeC2ad401eBEBdd3E32516d90Ab251A3aA3 2022/07/07 07:26:06 [find_uniswap_routers] INFO: Factory for router 789: 0x34696b6cE48051048f07f4cAfa39e3381242c3eD
"TriSolaris": { "chain": "aurora", "id": 14, "name": "TriSolaris", "router": "0x2CB45Edb4517d5947aFdE3BEAbF95A582506858B", "factory": "0xc66F594268041dB60507F00703b152492fb176E7", "flash_loan_supported": true, "swap_fee_points": 30, "default_slippage": 0.1, "swap_max_gas": 550000 }
$ nvp bchain update-pairs trisolaris Traceback (most recent call last): File "D:\Projects\NervHome\nvh\crypto\blockchain\uniswap_base.py", line 49, in __init__ self.factory = self.chain.get_contract(self.config["factory"]) File "D:\Projects\NervHome\nvh\crypto\blockchain\evm_blockchain.py", line 507, in get_contract contract = EVMSmartContract(self, address, abi_file, abi_fallback=abi_fallback, abi=abi) File "D:\Projects\NervHome\nvh\crypto\blockchain\evm_smart_contract.py", line 35, in __init__ abi_file = self.download_abi(abi_fallback) File "D:\Projects\NervHome\nvh\crypto\blockchain\evm_smart_contract.py", line 75, in download_abi self.check(msg[0:2] == "OK", "Cannot retrieve contract ABI: %s (url=%s)", data, url) File "D:\Projects\NervProj\nvp\nvp_object.py", line 73, in check raise NVPCheckError(fmt % args) nvp.nvp_object.NVPCheckError: Cannot retrieve contract ABI: {'status': '0', 'message': 'NOTOK', 'result': 'Contract source code not verified'} (url=https://api.aurorascan.dev/api?module=contract&action=getabi&address=0xc66F594268041dB60507F00703b152492fb176E7)
uint256 getPairFees(address) view
(⇒ that one may not be available ?)uint256 allPairsLength() view
address allPairs(uint256) view
uint256[] swapExactTokensForETH(uint256,uint256,address[],address,uint256)
swapExactTokensForTokensSupportingFeeOnTransferTokens(uint256,uint256,address[],address,uint256)
self.use_abi_builds = self.config.get("use_abi_builds", False) factory_funcs = None router_funcs = None if self.use_abi_builds: factory_funcs = [ "uint256 getPairFees(address) view", "uint256 allPairsLength() view", "address allPairs(uint256) view", ] router_funcs = [ "uint256[] swapExactTokensForETH(uint256,uint256,address[],address,uint256)", "swapExactTokensForTokensSupportingFeeOnTransferTokens(uint256,uint256,address[],address,uint256)", ] self.factory = self.chain.get_contract(self.config["factory"], funcs=factory_funcs) # Load the pancake router: self.router = self.chain.get_contract(self.config["router"], funcs=router_funcs)
"TriSolarisSwap": { "chain": "aurora", "id": 14, "name": "TriSolarisSwap", "router": "0x2CB45Edb4517d5947aFdE3BEAbF95A582506858B", "factory": "0xc66F594268041dB60507F00703b152492fb176E7", "flash_loan_supported": true, "use_abi_builder": true, "swap_fee_points": 30, "default_slippage": 0.1, "swap_max_gas": 550000 }, "WannaSwap": { "chain": "aurora", "id": 15, "name": "WannaSwap", "router": "0xa3a1eF5Ae6561572023363862e238aFA84C72ef5", "factory": "0x7928D4FeA7b2c90C732c10aFF59cf403f0C38246", "flash_loan_supported": true, "use_abi_builder": true, "swap_fee_points": 30, "default_slippage": 0.1, "swap_max_gas": 550000 }, "AuroraAnonSwap1": { "chain": "aurora", "id": 16, "name": "AuroraAnonSwap1", "router": "0xcCC7B6CD8764E84Be19BD13b25850C4ac24aa2C0", "factory": "0x78f406B41C81eb4144C321ADa5902BBF5de28538", "flash_loan_supported": true, "use_abi_builder": true, "swap_fee_points": 30, "default_slippage": 0.1, "swap_max_gas": 550000 }, "AuroraAnonSwap2": { "chain": "aurora", "id": 17, "name": "AuroraAnonSwap2", "router": "0xBaE0d7DFcd03C90EBCe003C58332c1346A72836A", "factory": "0x34484b4E416f5d4B45D4Add0B6eF6Ca08FcED8f1", "flash_loan_supported": true, "use_abi_builder": true, "swap_fee_points": 30, "default_slippage": 0.1, "swap_max_gas": 550000 }, "AuroraAnonSwap3": { "chain": "aurora", "id": 18, "name": "AuroraAnonSwap3", "router": "0xE52854C86fb64B04dd1D77AD542876dDC040c4f4", "factory": "0x70dcc803784bd540d9f2A29b99C4df0130E348BB", "flash_loan_supported": true, "use_abi_builder": true, "swap_fee_points": 30, "default_slippage": 0.1, "swap_max_gas": 550000 }, "AuroraSwap": { "chain": "aurora", "id": 19, "name": "AuroraSwap", "router": "0xA1B1742e9c32C7cAa9726d8204bD5715e3419861", "factory": "0xC5E1DaeC2ad401eBEBdd3E32516d90Ab251A3aA3", "flash_loan_supported": true, "use_abi_builder": true, "swap_fee_points": 30, "default_slippage": 0.1, "swap_max_gas": 550000 }, "AmaterasuSwap": { "chain": "aurora", "id": 20, "name": "AmaterasuSwap", "router": "0x3d99B2F578d94f61adcD899DE55F2991522cefE1", "factory": "0x34696b6cE48051048f07f4cAfa39e3381242c3eD", "flash_loan_supported": true, "use_abi_builder": true, "swap_fee_points": 25, "default_slippage": 0.1, "swap_max_gas": 550000 }
lastest outputs: File "/mnt/data1/dev/projects/NervProj/.pyenvs/bsc_env/lib/python3.10/site-packages/web3/middleware/buffered_gas_estimate.py", line 40, in middleware return make_request(method, params) File "cytoolz/functoolz.pyx", line 250, in cytoolz.functoolz.curry.__call__ File "/mnt/data1/dev/projects/NervProj/.pyenvs/bsc_env/lib/python3.10/site-packages/web3/middleware/formatting.py", line 76, in apply_formatters response = make_request(method, params) File "/mnt/data1/dev/projects/NervProj/.pyenvs/bsc_env/lib/python3.10/site-packages/web3/middleware/exception_retry_request.py", line 104, in middleware return make_request(method, params) File "/mnt/data1/dev/projects/NervProj/.pyenvs/bsc_env/lib/python3.10/site-packages/web3/providers/rpc.py", line 88, in make_request raw_response = make_post_request( File "/mnt/data1/dev/projects/NervProj/.pyenvs/bsc_env/lib/python3.10/site-packages/web3/_utils/request.py", line 48, in make_post_request response = session.post(endpoint_uri, data=data, *args, **kwargs) # type: ignore File "/mnt/data1/dev/projects/NervProj/.pyenvs/bsc_env/lib/python3.10/site-packages/requests/sessions.py", line 577, in post return self.request('POST', url, data=data, json=json, **kwargs) File "/mnt/data1/dev/projects/NervProj/.pyenvs/bsc_env/lib/python3.10/site-packages/requests/sessions.py", line 529, in request resp = self.send(prep, **send_kwargs) File "/mnt/data1/dev/projects/NervProj/.pyenvs/bsc_env/lib/python3.10/site-packages/requests/sessions.py", line 645, in send r = adapter.send(request, **kwargs) File "/mnt/data1/dev/projects/NervProj/.pyenvs/bsc_env/lib/python3.10/site-packages/requests/adapters.py", line 532, in send raise ReadTimeout(e, request=request) requests.exceptions.ReadTimeout: HTTPSConnectionPool(host='mainnet.aurora.dev', port=443): Read timed out. (read timeout=10) 2022/07/07 10:29:17 [nvh.crypto.blockchain.evm_blockchain] INFO: Block 69303942: num_tx=1, mode=0.070, mean=0.070, dev=0.000
def get_block(self, block_num=None, full_tx=False): """Retrieve the current block""" if block_num is None: block_num = "latest" return self.safe_call( lambda: self.web3.eth.get_block(block_num, full_transactions=full_tx), [requests.exceptions.ReadTimeout, urllib3.exceptions.ReadTimeoutError, ValueError], )
$ nvp bchain balance -a evm_arb -c aurora 2022/07/08 15:58:29 [__main__] INFO: Current balance: 0.020000 ETH
$ nvp solc compile 2022/07/08 15:59:36 [__main__] INFO: Auto selecting solidity compiler '0.6.6' 2022/07/08 15:59:36 [__main__] INFO: Auto installing solidity compiler version '0.6.6' 2022/07/08 15:59:36 [nvp.core.tools] INFO: Downloading file from https://solc-bin.ethereum.org/windows-amd64/solc-windows-amd64-v0.6.6+commit.6c089d02.zip... [==================================================] 7196296/7196296 100.000% 2022/07/08 15:59:45 [__main__] INFO: Compiling D:\Projects\NervHome\contracts\sources\FlashArbV4.sol... 2022/07/08 15:59:45 [__main__] INFO: Auto selecting solidity compiler '0.6.6' 2022/07/08 15:59:45 [__main__] INFO: Compiling D:\Projects\NervHome\contracts\sources\FlashArbV5.sol... 2022/07/08 15:59:45 [__main__] INFO: Auto selecting solidity compiler '0.6.6' 2022/07/08 15:59:45 [__main__] INFO: Compiling D:\Projects\NervHome\contracts\sources\GetReservesV2.sol... 2022/07/08 15:59:45 [__main__] INFO: Auto selecting solidity compiler '0.6.6' 2022/07/08 15:59:45 [__main__] INFO: Compiling D:\Projects\NervHome\contracts\sources\PairCheckerV5.sol... 2022/07/08 15:59:45 [__main__] INFO: Auto selecting solidity compiler '0.6.6' 2022/07/08 15:59:45 [__main__] INFO: Compiling D:\Projects\NervHome\contracts\sources\PairCheckerV6.sol... 2022/07/08 15:59:45 [__main__] INFO: Auto selecting solidity compiler '0.6.6' 2022/07/08 15:59:45 [__main__] INFO: Compiling D:\Projects\NervHome\contracts\sources\TestPair.sol... 2022/07/08 15:59:45 [__main__] INFO: Auto selecting solidity compiler '0.6.6' 2022/07/08 15:59:45 [__main__] INFO: Compiling D:\Projects\NervHome\contracts\sources\TestToken.sol...
$ nvp bchain deploy -c aurora -a evm_arb GetReservesV2
$ nvp bchain deploy -c aurora -a evm_arb PairCheckerV6
$ nvp bchain deploy -c aurora -a evm_arb FlashArbV5
$ nvp arbman monitor-arbs -c aurora 2022/07/08 17:22:11 [nvh.crypto.blockchain.evm_blockchain] INFO: Keeping 733/1076 quotable pairs. 2022/07/08 17:22:11 [nvh.crypto.blockchain.evm_blockchain] INFO: Found 0 arb compatible pairs 2022/07/08 17:22:11 [__main__] INFO: Collected 0 arb pairs 2022/07/08 17:22:11 [__main__] INFO: Min profit value: 0.000100 2022/07/08 17:22:11 [__main__] INFO: Wrapping some WETH for PairChecker setup... 2022/07/08 17:22:12 [nvh.crypto.blockchain.evm_blockchain] INFO: Trial 1: Gas estimate for transaction: 6721975 2022/07/08 17:22:12 [nvh.crypto.blockchain.evm_blockchain] INFO: Error while trying to perform operation: cannot convert float NaN to integer Traceback (most recent call last): File "D:\Projects\NervHome\nvh\crypto\blockchain\arbitrage_manager.py", line 929, in <module> comp.run() File "D:\Projects\NervProj\nvp\nvp_component.py", line 93, in run res = self.process_command(cmd) File "D:\Projects\NervHome\nvh\crypto\blockchain\arbitrage_manager.py", line 884, in process_command self.monitor_arbitrages(chain) File "D:\Projects\NervHome\nvh\crypto\blockchain\arbitrage_manager.py", line 130, in monitor_arbitrages self.update_quote_token_values() File "D:\Projects\NervHome\nvh\crypto\blockchain\arbitrage_manager.py", line 151, in update_quote_token_values ntoken.deposit(200000 * 20) File "D:\Projects\NervHome\nvh\crypto\blockchain\erc20_token.py", line 186, in deposit self.check(receipt is not None, "Cannot deposit %d units of %s ", amount, self.symbol()) File "D:\Projects\NervProj\nvp\nvp_object.py", line 73, in check raise NVPCheckError(fmt % args) nvp.nvp_object.NVPCheckError: Cannot deposit 4000000 units of WETH
chain.compute_gas_price_estimate('default')
--------------------------------------------------------------------------- ValueError Traceback (most recent call last) Input In [2], in <cell line: 1>() ----> 1 chain.compute_gas_price_estimate('default') File D:\Projects\NervHome\nvh\crypto\blockchain\evm_blockchain.py:736, in EVMBlockchain.compute_gas_price_estimate(self, mode) 731 self.check(totw > 0.0, "Invalid total weights.") 733 price = ( 734 emas["mode"] * weights[0] + emas["mean"] * weights[1] + (emas["mean"] + emas["std_dev"]) * weights[2] 735 ) / totw --> 736 price = math.floor(price * 1000) / 1000 738 # Clamp if bigger than max gas price: 739 maxp = self.max_gas_price ValueError: cannot convert float NaN to integer
$ nvp bchain update-pairs -c aurora
$ nvp arbman monitor-arbs -c aurora 2022/07/08 21:22:05 [nvh.crypto.blockchain.evm_blockchain] INFO: Keeping 906/1470 quotable pairs. 2022/07/08 21:22:05 [nvh.crypto.blockchain.evm_blockchain] INFO: Found 62 arb compatible pairs 2022/07/08 21:22:05 [__main__] INFO: Collected 62 arb pairs 2022/07/08 21:22:05 [__main__] INFO: Min profit value: 0.000100 2022/07/08 21:22:05 [__main__] INFO: Quote token WETH value: 1 WETH 2022/07/08 21:22:06 [__main__] INFO: PairChecker balance: 200000 WETH 2022/07/08 21:22:06 [__main__] INFO: Quote token NEAR value: 0.00292044 WETH 2022/07/08 21:22:06 [__main__] INFO: PairChecker balance: 200000 NEAR 2022/07/08 21:23:03 [__main__] INFO: 4 pair reserves collected in 0.1087 secs
if cmd == "list-quote-tokens": chain_name = self.get_param("chain") chain: EVMBlockchain = self.get_component(f"{chain_name}_chain") account = self.get_param("account") chain.set_account(account) num = self.get_param("count") _, qtokens = chain.collect_arb_compatible_pairs(num) for idx, addr in enumerate(qtokens): token = chain.get_token(addr) logger.info("Quote token %d: %s (%s)", idx + 1, token.symbol(), addr) return True
$ nvp arbman list-quote-tokens -c aurora -n 10 2022/07/08 21:42:53 [nvh.crypto.blockchain.evm_blockchain] INFO: Keeping 1295/1470 quotable pairs. 2022/07/08 21:42:53 [nvh.crypto.blockchain.evm_blockchain] INFO: Found 103 arb compatible pairs 2022/07/08 21:42:53 [__main__] INFO: Quote token 1: WETH (0xC9BdeEd33CD01541e1eeD10f90519d2C06Fe3feB) 2022/07/08 21:42:53 [__main__] INFO: Quote token 2: NEAR (0xC42C30aC6Cc15faC9bD938618BcaA1a1FaE8501d) 2022/07/08 21:42:53 [__main__] INFO: Quote token 3: AURORA (0x8BEc47865aDe3B172A928df8f990Bc7f2A3b9f79) 2022/07/08 21:42:53 [__main__] INFO: Quote token 4: USDC (0xB12BFcA5A55806AaF64E99521918A4bf0fC40802) 2022/07/08 21:42:53 [__main__] INFO: Quote token 5: USDT (0x4988a896b1227218e4A686fdE5EabdcAbd91571f) 2022/07/08 21:42:53 [__main__] INFO: Quote token 6: TRI#2 (0xFa94348467f64D5A457F75F8bc40495D33c65aBB) 2022/07/08 21:42:53 [__main__] INFO: Quote token 7: DAI (0xe3520349F477A5F6EB06107066048508498A291b) 2022/07/08 21:42:53 [__main__] INFO: Quote token 8: WBTC (0xF4eB217Ba2454613b15dBdea6e5f22276410e89e) 2022/07/08 21:42:53 [__main__] INFO: Quote token 9: atUST (0x5ce9F0B6AFb36135b5ddBF11705cEB65E634A9dC) 2022/07/08 21:42:53 [__main__] INFO: Quote token 10: WANNA (0x7faA64Faf54750a2E3eE621166635fEAF406Ab22)
def parse_1inch_swap_op(self, regdata, _sig=None, txh=None): """Parse a 1inch swapoperation input data""" # regdata should contain the data for: # (uint256,uint256,address[],address,uint256) regs = self.parse_register_data(regdata, txh) if len(regs) < 7: logger.warning("Invalid num regs: %d (hash=%s)", len(regs), txh) return None # Extract the data: token_in = self.chain.to_checksum_address(regs[1][-40:]) token_out = self.chain.to_checksum_address(regs[2][-40:]) to_id = self.chain.to_checksum_address(regs[4][-40:]) am_in = float(int(regs[5], 16)) am_out = float(int(regs[6], 16)) if am_in < 0.0 or am_out < 0.0 or am_in > 1e74 or am_out > 1e74: logger.warning("Invalid amounts %f or %f in tx (hash=%s)", am_in, am_out, txh) # utl.send_rocketchat_message(f"Invalid amounts in tx {txh}") return None return { "amount_in": am_in, "amount_out": am_out, "token_in": self.chain.get_address_id(token_in), "token_out": self.chain.get_address_id(token_out), "to_id": self.chain.get_address_id(to_id), }