def addresses_to_decoders( self) -> Dict[ChecksumEthAddress, Tuple[Any, ...]]: return { string_to_ethereum_address('0x11111254369792b2Ca5d084aB5eEA397cA8fa48B'): (self.decode_action, ), # noqa: E501 }
from rotkehlchen.chain.ethereum.types import string_to_ethereum_address from rotkehlchen.constants.misc import ZERO from rotkehlchen.fval import FVal from rotkehlchen.tests.utils.api import ( ASYNC_TASK_WAIT_TIMEOUT, api_url_for, assert_error_response, assert_ok_async_response, assert_proper_response_with_result, assert_simple_ok_response, wait_for_async_task, ) from rotkehlchen.tests.utils.rotkehlchen import setup_balances from rotkehlchen.types import AssetAmount, Location, Price, Timestamp, TradeType SWAP_ADDRESS = string_to_ethereum_address('0x63BC843b9640c4D79d6aE0105bc39F773172d121') @pytest.mark.parametrize('ethereum_accounts', [[SWAP_ADDRESS]]) @pytest.mark.parametrize('start_with_valid_premium', [True]) @pytest.mark.parametrize('ethereum_modules', [['compound']]) def test_get_balances_module_not_activated( rotkehlchen_api_server, ethereum_accounts, # pylint: disable=unused-argument ): response = requests.get( api_url_for(rotkehlchen_api_server, 'sushiswapbalancesresource'), ) assert_error_response( response=response, contained_in_msg='sushiswap module is not activated',
from rotkehlchen.accounting.structures.balance import Balance from rotkehlchen.chain.ethereum.modules.adex.types import Bond, ChannelWithdraw, Unbond from rotkehlchen.chain.ethereum.types import string_to_ethereum_address from rotkehlchen.constants.assets import A_ADX from rotkehlchen.fval import FVal from rotkehlchen.tests.utils.api import ( api_url_for, assert_error_response, assert_ok_async_response, assert_proper_response_with_result, assert_simple_ok_response, wait_for_async_task, ) from rotkehlchen.tests.utils.rotkehlchen import setup_balances ADEX_TEST_ADDR = string_to_ethereum_address( '0x8Fe178db26ebA2eEdb22575265bf10A63c395a3d') @pytest.mark.parametrize('ethereum_accounts', [[ADEX_TEST_ADDR]]) @pytest.mark.parametrize('ethereum_modules', [['uniswap']]) def test_get_balances_module_not_activated( rotkehlchen_api_server, ethereum_accounts, # pylint: disable=unused-argument ): response = requests.get( api_url_for(rotkehlchen_api_server, 'adexbalancesresource'), ) assert_error_response( response=response, contained_in_msg='adex module is not activated', status_code=HTTPStatus.CONFLICT, )
def test_get_asset_with_symbol(globaldb): # both categories of assets asset_data = globaldb.get_assets_with_symbol('KEY') bihukey_address = string_to_ethereum_address( '0x4Cd988AfBad37289BAAf53C13e98E2BD46aAEa8c') aave_address = string_to_ethereum_address( '0x7Fc66500c84A76Ad7e9c93437bFc5Ac33E2DDaE9') renbtc_address = string_to_ethereum_address( '0xEB4C2781e4ebA804CE9a9803C67d0893436bB27D') assert asset_data == [ selfkey_asset_data, AssetData( identifier=ethaddress_to_identifier(bihukey_address), name='Bihu KEY', symbol='KEY', asset_type=AssetType.ETHEREUM_TOKEN, started=1507822985, forked=None, swapped_for=None, ethereum_address=bihukey_address, decimals=18, cryptocompare='BIHU', coingecko='key', protocol=None, ), AssetData( identifier='KEY-3', name='KeyCoin', symbol='KEY', asset_type=AssetType.OWN_CHAIN, started=1405382400, forked=None, swapped_for=None, ethereum_address=None, decimals=None, cryptocompare='KEYC', coingecko='', protocol=None, ) ] # only non-ethereum token assert globaldb.get_assets_with_symbol('BIDR') == [bidr_asset_data] # only ethereum token assert globaldb.get_assets_with_symbol('AAVE') == [ AssetData( identifier=ethaddress_to_identifier(aave_address), name='Aave Token', symbol='AAVE', asset_type=AssetType.ETHEREUM_TOKEN, started=1600970788, forked=None, swapped_for=None, ethereum_address=aave_address, decimals=18, cryptocompare=None, coingecko='aave', protocol=None, ) ] # finally non existing asset assert globaldb.get_assets_with_symbol('DASDSADSDSDSAD') == [] # also check that symbol comparison is case insensitive for many arg combinations expected_renbtc = [ AssetData( identifier=ethaddress_to_identifier(renbtc_address), name='renBTC', symbol='renBTC', asset_type=AssetType.ETHEREUM_TOKEN, started=1585090944, forked=None, swapped_for=None, ethereum_address=renbtc_address, decimals=8, cryptocompare=None, coingecko='renbtc', protocol=None, ) ] for x in itertools.product(('ReNbTc', 'renbtc', 'RENBTC', 'rEnBTc'), (None, AssetType.ETHEREUM_TOKEN)): # noqa: E501 assert globaldb.get_assets_with_symbol(*x) == expected_renbtc
if TYPE_CHECKING: from rotkehlchen.chain.ethereum.decoding.base import BaseDecoderTools from rotkehlchen.chain.ethereum.manager import EthereumManager from rotkehlchen.user_messages import MessagesAggregator ADD_LIQUIDITY = b'B?d\x95\xa0\x8f\xc6RB\\\xf4\xed\r\x1f\x9e7\xe5q\xd9\xb9R\x9b\x1c\x1c#\xcc\xe7\x80\xb2\xe7\xdf\r' # noqa: E501 ADD_LIQUIDITY_2_ASSETS = b'&\xf5Z\x85\x08\x1d$\x97N\x85\xc6\xc0\x00E\xd0\xf0E9\x91\xe9Xs\xf5+\xff\r!\xaf@y\xa7h' # noqa: E501 ADD_LIQUIDITY_4_ASSETS = b'?\x19\x15w^\x0c\x9a8\xa5z{\xb7\xf1\xf9\x00_Ho\xb9\x04\xe1\xf8J\xa2\x156MVs\x19\xa5\x8d' # noqa: E501 REMOVE_LIQUIDITY = b"Z\xd0V\xf2\xe2\x8a\x8c\xec# \x15@k\x846h\xc1\xe3l\xdaY\x81'\xec;\x8cY\xb8\xc7's\xa0" # noqa: E501 REMOVE_ONE = b'\x9e\x96\xdd;\x99z*%~\xecM\xf9\xbbn\xafbn m\xf5\xf5C\xbd\x966\x82\xd1C0\x0b\xe3\x10' # noqa: E501 REMOVE_LIQUIDITY_3_ASSETS = b'\xa4\x9dL\xf0&V\xae\xbf\x8cw\x1fZ\x85\x85c\x8a*\x15\xeel\x97\xcfr\x05\xd4 \x8e\xd7\xc1\xdf%-' # noqa: E501 REMOVE_LIQUIDITY_4_ASSETS = b'\x98x\xca7^\x10o*C\xc3\xb5\x99\xfcbEh\x13\x1cL\x9aK\xa6j\x14V7\x15v;\xe9\xd5\x9d' # noqa: E501 REMOVE_LIQUIDITY_IMBALANCE = b'\xb9d\xb7/s\xf5\xef[\xf0\xfd\xc5Y\xb2\xfa\xb9\xa7\xb1*9\xe4x\x17\xa5G\xf1\xf0\xae\xe4\x7f\xeb\xd6\x02' # noqa: E501 CURVE_Y_DEPOSIT = string_to_ethereum_address('0xbBC81d23Ea2c3ec7e56D39296F0cbB648873a5d3') class CurveDecoder(DecoderInterface): # lgtm[py/missing-call-to-init] def __init__( self, ethereum_manager: 'EthereumManager', # pylint: disable=unused-argument base_tools: 'BaseDecoderTools', # pylint: disable=unused-argument msg_aggregator: 'MessagesAggregator', # pylint: disable=unused-argument ) -> None: super().__init__( ethereum_manager=ethereum_manager, base_tools=base_tools, msg_aggregator=msg_aggregator, )
import pytest import requests from rotkehlchen.chain.ethereum.types import string_to_ethereum_address from rotkehlchen.constants.assets import A_ETH, A_EUR from rotkehlchen.constants.misc import ZERO from rotkehlchen.exchanges.data_structures import Trade from rotkehlchen.fval import FVal from rotkehlchen.tests.utils.api import api_url_for, assert_proper_response_with_result from rotkehlchen.tests.utils.exchanges import mock_exchange_data_in_db from rotkehlchen.types import AssetAmount, Fee, Location, Price, Timestamp, TradeType UNISWAP_ADDR = string_to_ethereum_address( '0xcaf012cB72f2c7152b255E091837E3a628F739e7') @pytest.mark.parametrize('added_exchanges', [(Location.BINANCE, Location.POLONIEX)]) @pytest.mark.parametrize('ethereum_accounts', [[UNISWAP_ADDR]]) @pytest.mark.parametrize('ethereum_modules', [['uniswap']]) @pytest.mark.parametrize('start_with_valid_premium', [True]) def test_get_associated_locations( rotkehlchen_api_server_with_exchanges, added_exchanges, ethereum_accounts, # pylint: disable=unused-argument start_with_valid_premium, # pylint: disable=unused-argument ): rotki = rotkehlchen_api_server_with_exchanges.rest_api.rotkehlchen mock_exchange_data_in_db(added_exchanges, rotki) db = rotki.data.db
return DefiBalance( token_address=string_to_ethereum_address( '0xBD87447F48ad729C5c4b8bcb503e1395F62e8B98'), token_name='Pool Together USDC token', token_symbol='plUSDC', balance=Balance( amount=normalized_balance, usd_value=normalized_balance * usdc_price, ), ) # else return None # supported zerion adapter address ZERION_ADAPTER_ADDRESS = string_to_ethereum_address( '0x06FE76B2f432fdfEcAEf1a7d4f6C3d41B5861672') class ZerionSDK(): """Adapter for the Zerion DeFi SDK https://github.com/zeriontech/defi-sdk""" def __init__( self, ethereum_manager: 'EthereumManager', msg_aggregator: MessagesAggregator, ) -> None: self.ethereum = ethereum_manager self.msg_aggregator = msg_aggregator self.contract = EthereumContract( address=ZERION_ADAPTER_ADDRESS, abi=ZERION_ABI, deployed_block=1586199170,
def test_liquity_trove_adjust(database, ethereum_manager, eth_transactions): """Data for deposit taken from https://etherscan.io/tx/0xdb9a541a4af7d5d46d7ea5fe4a2a752dcb731d64d052f86f630e97362063602c Deposit 2.1 ether and borrow 4752 LUSD """ msg_aggregator = MessagesAggregator() tx_hex = '0xdb9a541a4af7d5d46d7ea5fe4a2a752dcb731d64d052f86f630e97362063602c' user_address = '0x9ba961989Dd6609Ed091f512bE947118c40F2291' evmhash = deserialize_evm_tx_hash(tx_hex) transaction = EthereumTransaction( tx_hash=evmhash, timestamp=1646375440, block_number=14318825, from_address=user_address, to_address='0x24179cd81c9e782a4096035f7ec97fb8b783e007', value=FVal('2.1') * EXP18, gas=171249, gas_price=22990000000, gas_used=171249, input_data=hexstring_to_bytes('0xc6a6cf2000000000000000000000000000000000000000000000000000238e8a8455758900000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001018f9e3f8eea75e0100000000000000000000000000000000000000000000000000000000000000001000000000000000000000000e24328e7df3d87c1cbcc9043326f9b20c425a9e6000000000000000000000000de64f98baece7282973ce8d67cd73455d4748673'), # noqa: E501 nonce=507, ) receipt = EthereumTxReceipt( tx_hash=evmhash, contract_address=None, status=True, type=0, logs=[ EthereumTxReceiptLog( log_index=91, data=hexstring_to_bytes('0x0000000000000000000000000000000000000000000000014a3a4295480654a6'), # noqa: E501 address=string_to_ethereum_address('0x5f98805A4E8be255a32880FDeC7F6728C6568bA0'), removed=False, topics=[ hexstring_to_bytes('0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef'), # noqa: E501 hexstring_to_bytes('0x0000000000000000000000000000000000000000000000000000000000000000'), # noqa: E501 hexstring_to_bytes('0x0000000000000000000000004f9fbb3f1e99b56e0fe2892e623ed36a76fc605d'), # noqa: E501 ], ), EthereumTxReceiptLog( log_index=95, data=hexstring_to_bytes('0x00000000000000000000000000000000000000000000021e19de846fc75de296000000000000000000000000000000000000000000000000429d069189e00000000000000000000000000000000000000000000000000000429d069189e000000000000000000000000000000000000000000000000000000000000000000002'), # noqa: E501 address=string_to_ethereum_address('0x24179CD81c9e782A4096035f7eC97fB8B783e007'), removed=False, topics=[ hexstring_to_bytes('0xc3770d654ed33aeea6bf11ac8ef05d02a6a04ed4686dd2f624d853bbec43cc8b'), # noqa: E501 hexstring_to_bytes('0x0000000000000000000000009ba961989dd6609ed091f512be947118c40f2291'), # noqa: E501 ], ), EthereumTxReceiptLog( log_index=98, data=hexstring_to_bytes('0x0000000000000000000000000000000000000000000001018f9e3f8eea75e010'), # noqa: E501 address=string_to_ethereum_address('0x5f98805A4E8be255a32880FDeC7F6728C6568bA0'), removed=False, topics=[ hexstring_to_bytes('0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef'), # noqa: E501 hexstring_to_bytes('0x0000000000000000000000000000000000000000000000000000000000000000'), # noqa: E501 hexstring_to_bytes('0x0000000000000000000000009ba961989dd6609ed091f512be947118c40f2291'), # noqa: E501 ], ), EthereumTxReceiptLog( log_index=99, data=hexstring_to_bytes('0x000000000000000000000000000000000000000000004e97821fe7ced4f8b2fb'), # noqa: E501 address=string_to_ethereum_address('0xDf9Eb223bAFBE5c5271415C75aeCD68C21fE3D7F'), removed=False, topics=[ hexstring_to_bytes('0xca232b5abb988c540b959ff6c3bfae3e97fff964fd098c508f9613c0a6bf1a80'), # noqa: E501 ], ), ], ) dbethtx = DBEthTx(database) dbethtx.add_ethereum_transactions([transaction], relevant_address=None) decoder = EVMTransactionDecoder( database=database, ethereum_manager=ethereum_manager, eth_transactions=eth_transactions, msg_aggregator=msg_aggregator, ) events = decoder.decode_transaction(transaction=transaction, tx_receipt=receipt) assert len(events) == 3 expected_events = [ HistoryBaseEntry( event_identifier=tx_hex, sequence_index=0, timestamp=1646375440000, location=Location.BLOCKCHAIN, event_type=HistoryEventType.SPEND, event_subtype=HistoryEventSubType.FEE, asset=A_ETH, balance=Balance( amount=FVal(0.00393701451), usd_value=ZERO, ), location_label=user_address, notes=f'Burned 0.00393701451 ETH in gas from {user_address}', counterparty=CPT_GAS, ), HistoryBaseEntry( event_identifier=tx_hex, sequence_index=1, timestamp=1646375440000, location=Location.BLOCKCHAIN, event_type=HistoryEventType.DEPOSIT, event_subtype=HistoryEventSubType.DEPOSIT_ASSET, asset=A_ETH, balance=Balance(amount=FVal('2.1'), usd_value=ZERO), location_label=user_address, notes='Deposit 2.1 ETH as collateral for liquity', counterparty='liquity', ), HistoryBaseEntry( event_identifier=tx_hex, sequence_index=100, timestamp=1646375440000, location=Location.BLOCKCHAIN, event_type=HistoryEventType.WITHDRAWAL, event_subtype=HistoryEventSubType.GENERATE_DEBT, asset=A_LUSD, balance=Balance(amount=FVal('4751.162005820150243344'), usd_value=ZERO), location_label=user_address, notes='Generate 4751.162005820150243344 LUSD from liquity', counterparty='liquity', )] assert events == expected_events
def test_gnosis_chain_bridge(database, ethereum_manager, eth_transactions): """Data for bridge taken from https://etherscan.io/tx/0x52f853d559d83b5303faf044e00e9109bd5c6a05b6633f9df34939f8e7c6de02 """ msg_aggregator = MessagesAggregator() tx_hex = '0x52f853d559d83b5303faf044e00e9109bd5c6a05b6633f9df34939f8e7c6de02' evmhash = deserialize_evm_tx_hash(tx_hex) transaction = EthereumTransaction( tx_hash=evmhash, timestamp=1646375440, block_number=14351442, from_address='0x5EDCf547eCE0EA1765D6C02e9E5bae53b52E09D4', to_address='0x88ad09518695c6c3712AC10a214bE5109a655671', value=0, gas=171249, gas_price=22990000000, gas_used=171249, input_data=hexstring_to_bytes('0x09c5eabe000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000002e43f7658fd000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000001a0000000000000000000000000000000000000000000000000000000000000013500050000a7823d6f1e31569f51861e345b30c6bebf70ebe70000000000009cf6f6a78083ca3e2a662d6dd1703c939c8ace2e268d88ad09518695c6c3712ac10a214be5109a655671000927c00101006401867f7a4d000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc20000000000000000000000003f615ba21bc6cc5d4a6d798c5950cc5c42937fbd00000000000000000000000000000000000000000000000007392088b40d14000000000000000000000000000000000000000000000000000000000000000080000000000000000000000000000000000000000000000000000000000000004000000000000000000000000006c187e1b71ffbee4429003bb846c1b3eb1610000000000000000000000000000000000000000000000000000048c52ee05b140000000000000000000000000000000000000000000000000000000000000000000000000000000000000105041b1c1c1c73a08c7605fa9c69f068338cb7cd1c8dd21189cbe56f4cc66cff8dc7f0b0c8cc8c64433ea24643b893c9062beae6a05656b1df5643a242533d63925144c3e5c7dfd0509fb3c4232cfdb4c500e942a95b23439b3e18bab4a40057e1bdfae2d9967025b3f8fdca13354b25250c0d7fa9e4b472dc97df1f0cd0f595dc266d09e711628b3a63c1a6e4c83a11d3655891e31901eacf73b927e10bfbe6b0d5ed808cc228d606779a19a7dfb7393956b4fada14eaef8f6de6ee3824e67d6df18cc2d55f00cf869cc920135a94fb4abc213dc43e97812879d9efab046e4fffb931dcb55e5aa2b86f6a848408fea42cd221df99f1720b2ce22830498d78d04e1d083ba12800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000'), # noqa: E501 nonce=12, ) receipt = EthereumTxReceipt( tx_hash=evmhash, contract_address=None, status=True, type=0, logs=[ EthereumTxReceiptLog( log_index=473, data=hexstring_to_bytes('0x000000000000000000000000000000000000000000000000000000250d51ce33'), # noqa: E501 address=string_to_ethereum_address('0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48'), removed=False, topics=[ hexstring_to_bytes('0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef'), # noqa: E501 hexstring_to_bytes('0x00000000000000000000000088ad09518695c6c3712ac10a214be5109a655671'), # noqa: E501 hexstring_to_bytes('0x0000000000000000000000005edcf547ece0ea1765d6c02e9e5bae53b52e09d4'), # noqa: E501 ], ), EthereumTxReceiptLog( log_index=474, data=hexstring_to_bytes('0x000000000000000000000000000000000000000000000000000000250d51ce33'), # noqa: E501 address=string_to_ethereum_address('0x88ad09518695c6c3712AC10a214bE5109a655671'), removed=False, topics=[ hexstring_to_bytes('0x9afd47907e25028cdaca89d193518c302bbb128617d5a992c5abd45815526593'), # noqa: E501 hexstring_to_bytes('0x000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48'), # noqa: E501 hexstring_to_bytes('0x0000000000000000000000005edcf547ece0ea1765d6c02e9e5bae53b52e09d4'), # noqa: E501 hexstring_to_bytes('0x00050000a7823d6f1e31569f51861e345b30c6bebf70ebe70000000000009cf9'), # noqa: E501 ], ), EthereumTxReceiptLog( log_index=6, data=hexstring_to_bytes('0x0000000000000000000000000000000000000000000000000000000000000001'), # noqa: E501 address=string_to_ethereum_address('0x4c36d2919e407f0cc2ee3c993ccf8ac26d9ce64e'), removed=False, topics=[ hexstring_to_bytes('0x27333edb8bdcd40a0ae944fb121b5e2d62ea782683946654a0f5e607a908d578'), # noqa: E501 hexstring_to_bytes('0x000000000000000000000000f6a78083ca3e2a662d6dd1703c939c8ace2e268d'), # noqa: E501 hexstring_to_bytes('0x00000000000000000000000088ad09518695c6c3712ac10a214be5109a655671'), # noqa: E501 hexstring_to_bytes('0x00050000a7823d6f1e31569f51861e345b30c6bebf70ebe70000000000009cf9'), # noqa: E501 ], ), ], ) dbethtx = DBEthTx(database) dbethtx.add_ethereum_transactions([transaction], relevant_address=None) decoder = EVMTransactionDecoder( database=database, ethereum_manager=ethereum_manager, eth_transactions=eth_transactions, msg_aggregator=msg_aggregator, ) events = decoder.decode_transaction(transaction=transaction, tx_receipt=receipt) assert len(events) == 2 expected_events = [ HistoryBaseEntry( event_identifier='0x52f853d559d83b5303faf044e00e9109bd5c6a05b6633f9df34939f8e7c6de02', sequence_index=0, timestamp=1646375440000, location=Location.BLOCKCHAIN, event_type=HistoryEventType.SPEND, event_subtype=HistoryEventSubType.FEE, asset=A_ETH, balance=Balance( amount=FVal(0.00393701451), usd_value=ZERO, ), location_label='0x5EDCf547eCE0EA1765D6C02e9E5bae53b52E09D4', notes='Burned 0.00393701451 ETH in gas from 0x5EDCf547eCE0EA1765D6C02e9E5bae53b52E09D4', # noqa: E501 counterparty=CPT_GAS, ), HistoryBaseEntry( event_identifier='0x52f853d559d83b5303faf044e00e9109bd5c6a05b6633f9df34939f8e7c6de02', sequence_index=474, timestamp=1646375440000, location=Location.BLOCKCHAIN, event_type=HistoryEventType.TRANSFER, event_subtype=HistoryEventSubType.BRIDGE, asset=EthereumToken('0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48'), balance=Balance(amount=FVal('159137.254963'), usd_value=ZERO), location_label='0x5EDCf547eCE0EA1765D6C02e9E5bae53b52E09D4', notes='Bridge 159137.254963 USDC from gnosis chain', counterparty=CPT_GNOSIS_CHAIN, ), ] assert events == expected_events
def test_liquity_trove_deposit_lusd(database, ethereum_manager, eth_transactions): """Data for deposit taken from https://etherscan.io/tx/0x40bb08427a3b99fb9896cf14858d82d361a6e7a8fb7dd6d2000511ac3dca5707 Deposit 2.1 ether and borrow 4752 LUSD """ msg_aggregator = MessagesAggregator() tx_hex = '0x40bb08427a3b99fb9896cf14858d82d361a6e7a8fb7dd6d2000511ac3dca5707' user_address = '0x648E180e246741363639B1496762763dd25649db' evmhash = deserialize_evm_tx_hash(tx_hex) transaction = EthereumTransaction( tx_hash=evmhash, timestamp=1646375440, block_number=14318825, from_address=user_address, to_address='0x24179cd81c9e782a4096035f7ec97fb8b783e007', value=0, gas=171249, gas_price=22990000000, gas_used=171249, input_data=hexstring_to_bytes('0xc6a6cf200000000000000000000000000000000000000000000000000023c5d78add1ce10000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001906c5721af5fbe700000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000de9ac8262766e73a1d5f75cc3c37ae495e88d225000000000000000000000000cb926f497763ea5cf993912a442431e6a91d5a64'), # noqa: E501 nonce=507, ) receipt = EthereumTxReceipt( tx_hash=evmhash, contract_address=None, status=True, type=0, logs=[ EthereumTxReceiptLog( log_index=204, data=hexstring_to_bytes('0x000000000000000000000000000000000000000000038f9ba4f4e8bb875c546b0000000000000000000000000000000000000000000000aed129e69968ff40000000000000000000000000000000000000000000000000aed129e69968ff40000000000000000000000000000000000000000000000000000000000000000002'), # noqa: E501 address=string_to_ethereum_address('0x24179CD81c9e782A4096035f7eC97fB8B783e007'), removed=False, topics=[ hexstring_to_bytes('0xc3770d654ed33aeea6bf11ac8ef05d02a6a04ed4686dd2f624d853bbec43cc8b'), # noqa: E501 hexstring_to_bytes('0x000000000000000000000000648e180e246741363639b1496762763dd25649db'), # noqa: E501 ], ), EthereumTxReceiptLog( log_index=207, data=hexstring_to_bytes('0x000000000000000000000000000000000000000000001906c5721af5fbe70000'), # noqa: E501 address=string_to_ethereum_address('0x5f98805A4E8be255a32880FDeC7F6728C6568bA0'), removed=False, topics=[ hexstring_to_bytes('0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef'), # noqa: E501 hexstring_to_bytes('0x000000000000000000000000648e180e246741363639b1496762763dd25649db'), # noqa: E501 hexstring_to_bytes('0x0000000000000000000000000000000000000000000000000000000000000000'), # noqa: E501 ], ), EthereumTxReceiptLog( log_index=208, data=hexstring_to_bytes('0x000000000000000000000000000000000000000000004e900a6a97e3873abb07'), # noqa: E501 address=string_to_ethereum_address('0xDf9Eb223bAFBE5c5271415C75aeCD68C21fE3D7F'), removed=False, topics=[ hexstring_to_bytes('0xca232b5abb988c540b959ff6c3bfae3e97fff964fd098c508f9613c0a6bf1a80'), # noqa: E501 ], ), ], ) dbethtx = DBEthTx(database) dbethtx.add_ethereum_transactions([transaction], relevant_address=None) decoder = EVMTransactionDecoder( database=database, ethereum_manager=ethereum_manager, eth_transactions=eth_transactions, msg_aggregator=msg_aggregator, ) events = decoder.decode_transaction(transaction=transaction, tx_receipt=receipt) assert len(events) == 2 expected_events = [ HistoryBaseEntry( event_identifier=tx_hex, sequence_index=0, timestamp=1646375440000, location=Location.BLOCKCHAIN, event_type=HistoryEventType.SPEND, event_subtype=HistoryEventSubType.FEE, asset=A_ETH, balance=Balance( amount=FVal(0.00393701451), usd_value=ZERO, ), location_label=user_address, notes=f'Burned 0.00393701451 ETH in gas from {user_address}', counterparty=CPT_GAS, ), HistoryBaseEntry( event_identifier=tx_hex, sequence_index=208, timestamp=1646375440000, location=Location.BLOCKCHAIN, event_type=HistoryEventType.SPEND, event_subtype=HistoryEventSubType.PAYBACK_DEBT, asset=A_LUSD, balance=Balance(amount=FVal('118184.07'), usd_value=ZERO), location_label=user_address, notes='Return 118184.07 LUSD to liquity', counterparty='liquity', )] assert events == expected_events
def test_liquity_trove_remove_eth(database, ethereum_manager, eth_transactions): """Data for deposit taken from https://etherscan.io/tx/0x6be5312c21855c3cc324b5b6ce9f9f65dbd488e270e84ac5e6fb96c74d83fe4e Deposit 2.1 ether and borrow 4752 LUSD """ msg_aggregator = MessagesAggregator() tx_hex = '0x6be5312c21855c3cc324b5b6ce9f9f65dbd488e270e84ac5e6fb96c74d83fe4e' user_address = '0x648E180e246741363639B1496762763dd25649db' evmhash = deserialize_evm_tx_hash(tx_hex) transaction = EthereumTransaction( tx_hash=evmhash, timestamp=1646375440, block_number=14318825, from_address=user_address, to_address='0x24179cd81c9e782a4096035f7ec97fb8b783e007', value=0, gas=171249, gas_price=22990000000, gas_used=171249, input_data=hexstring_to_bytes('0xc6a6cf2000000000000000000000000000000000000000000000000000238811c2e89e1b000000000000000000000000000000000000000000000001bc16d674ec80000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000cb926f497763ea5cf993912a442431e6a91d5a64000000000000000000000000c68d61757a9894f34871c0ae733ac034d9abf807'), # noqa: E501 nonce=507, ) receipt = EthereumTxReceipt( tx_hash=evmhash, contract_address=None, status=True, type=0, logs=[ EthereumTxReceiptLog( log_index=204, data=hexstring_to_bytes('0x000000000000000000000000000000000000000000038f9ba4f4e8bb875c546b0000000000000000000000000000000000000000000000aed129e69968ff40000000000000000000000000000000000000000000000000aed129e69968ff40000000000000000000000000000000000000000000000000000000000000000002'), # noqa: E501 address=string_to_ethereum_address('0x24179CD81c9e782A4096035f7eC97fB8B783e007'), removed=False, topics=[ hexstring_to_bytes('0xc3770d654ed33aeea6bf11ac8ef05d02a6a04ed4686dd2f624d853bbec43cc8b'), # noqa: E501 hexstring_to_bytes('0x000000000000000000000000648e180e246741363639b1496762763dd25649db'), # noqa: E501 ], ), EthereumTxReceiptLog( log_index=293, data=hexstring_to_bytes('0x0000000000000000000000000000000000000000000000000000000000000000'), # noqa: E501 address=string_to_ethereum_address('0x5f98805A4E8be255a32880FDeC7F6728C6568bA0'), removed=False, topics=[ hexstring_to_bytes('0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef'), # noqa: E501 hexstring_to_bytes('0x000000000000000000000000648e180e246741363639b1496762763dd25649db'), # noqa: E501 hexstring_to_bytes('0x0000000000000000000000000000000000000000000000000000000000000000'), # noqa: E501 ], ), EthereumTxReceiptLog( log_index=208, data=hexstring_to_bytes('0x000000000000000000000000000000000000000000004e927b246c443a2daac9'), # noqa: E501 address=string_to_ethereum_address('0xDf9Eb223bAFBE5c5271415C75aeCD68C21fE3D7F'), removed=False, topics=[ hexstring_to_bytes('0xca232b5abb988c540b959ff6c3bfae3e97fff964fd098c508f9613c0a6bf1a80'), # noqa: E501 ], ), ], ) internal_tx = EthereumInternalTransaction( parent_tx_hash=evmhash, trace_id=19, timestamp=Timestamp(1646375440), block_number=10182160, from_address='0xDf9Eb223bAFBE5c5271415C75aeCD68C21fE3D7F', to_address=user_address, value=FVal(32) * EXP18, ) dbethtx = DBEthTx(database) dbethtx.add_ethereum_transactions([transaction], relevant_address=None) dbethtx.add_ethereum_internal_transactions([internal_tx], relevant_address=user_address) # noqa: E501 decoder = EVMTransactionDecoder( database=database, ethereum_manager=ethereum_manager, eth_transactions=eth_transactions, msg_aggregator=msg_aggregator, ) events = decoder.decode_transaction(transaction=transaction, tx_receipt=receipt) assert len(events) == 3 expected_events = [ HistoryBaseEntry( event_identifier=tx_hex, sequence_index=0, timestamp=1646375440000, location=Location.BLOCKCHAIN, event_type=HistoryEventType.SPEND, event_subtype=HistoryEventSubType.FEE, asset=A_ETH, balance=Balance( amount=FVal(0.00393701451), usd_value=ZERO, ), location_label=user_address, notes=f'Burned 0.00393701451 ETH in gas from {user_address}', counterparty=CPT_GAS, ), HistoryBaseEntry( event_identifier=tx_hex, sequence_index=1, timestamp=1646375440000, location=Location.BLOCKCHAIN, event_type=HistoryEventType.WITHDRAWAL, event_subtype=HistoryEventSubType.REMOVE_ASSET, asset=A_ETH, balance=Balance(amount=FVal('32'), usd_value=ZERO), location_label=user_address, notes='Withdraw 32 ETH collateral from liquity', counterparty='liquity', ), HistoryBaseEntry( event_identifier=tx_hex, sequence_index=295, timestamp=1646375440000, location=Location.BLOCKCHAIN, event_type=HistoryEventType.SPEND, event_subtype=HistoryEventSubType.PAYBACK_DEBT, asset=A_LUSD, balance=Balance(amount=FVal('0'), usd_value=ZERO), location_label=user_address, notes='Return 0 LUSD to liquity', counterparty='liquity', )] assert events == expected_events
def test_avax_query_token_with_info(rotkehlchen_api_server): """Query DAI token to retrieve basic information""" response = requests.get( api_url_for( rotkehlchen_api_server, 'erc20tokeninfoavax', ), json={ 'address': string_to_ethereum_address( '0xba7deebbfc5fa1100fb055a87773e1e99cd3507a'), }, ) result = assert_proper_response_with_result(response) assert result['decimals'] == 18 assert result['symbol'] == 'DAI' assert result['name'] == 'Dai Stablecoin' # Test a contract without decimals/name/symbol methods response_2 = requests.get( api_url_for( rotkehlchen_api_server, 'erc20tokeninfoavax', ), json={ 'address': string_to_ethereum_address( '0x7d655c57f71464B6f83811C55D84009Cd9f5221C'), }, ) result_2 = assert_proper_response_with_result(response_2) assert len(result_2.keys()) == 3 assert all((value is None for value in result_2.values())) # Test an address that is not a contract response_3 = requests.get( api_url_for( rotkehlchen_api_server, 'erc20tokeninfoavax', ), json={ 'address': string_to_ethereum_address( '0x00f195C9ed671173d618e7c03e4A987ef906C739'), }, ) result_3 = assert_proper_response_with_result(response_3) assert len(result_3.keys()) == 3 assert all((value is None for value in result_3.values())) # Test an address that is not valid (this one has extra chars) response_4 = requests.get( api_url_for( rotkehlchen_api_server, 'erc20tokeninfoavax', ), json={ 'address': string_to_ethereum_address( '0x4652D63f4750bCd9d5f5dAds96087485d31554b10F'), }, ) assert_error_response( response=response_4, contained_in_msg='is not an ethereum address', status_code=HTTPStatus.BAD_REQUEST, )
def setup_ethereum_transactions_test( database: DBHandler, transaction_already_queried: bool, one_receipt_in_db: bool = False, ) -> Tuple[List[EthereumTransaction], List[EthereumTxReceipt]]: dbethtx = DBEthTx(database) tx_hash1 = deserialize_evm_tx_hash( '0x692f9a6083e905bdeca4f0293f3473d7a287260547f8cbccc38c5cb01591fcda' ) # noqa: E501 addr1 = string_to_ethereum_address( '0x443E1f9b1c866E54e914822B7d3d7165EdB6e9Ea') addr2 = string_to_ethereum_address( '0x442068F934BE670aDAb81242C87144a851d56d16') database.add_blockchain_accounts( blockchain=SupportedBlockchain.ETHEREUM, account_data=[ BlockchainAccountData(address=addr1), BlockchainAccountData(address=addr2), ], ) transaction1 = EthereumTransaction( tx_hash=tx_hash1, timestamp=Timestamp(1630532276), block_number=13142218, from_address=addr1, to_address=string_to_ethereum_address( '0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D'), value=int(10 * 10**18), gas=194928, gas_price=int(0.000000204 * 10**18), gas_used=136675, input_data=hexstring_to_bytes( '0x7ff36ab5000000000000000000000000000000000000000000000367469995d0723279510000000000000000000000000000000000000000000000000000000000000080000000000000000000000000443e1f9b1c866e54e914822b7d3d7165edb6e9ea00000000000000000000000000000000000000000000000000000000612ff9b50000000000000000000000000000000000000000000000000000000000000002000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc20000000000000000000000002a3bff78b79a009976eea096a51a948a3dc00e34' ), # noqa: E501 nonce=13, ) tx_hash2 = deserialize_evm_tx_hash( '0x6beab9409a8f3bd11f82081e99e856466a7daf5f04cca173192f79e78ed53a77' ) # noqa: E501 transaction2 = EthereumTransaction( tx_hash=tx_hash2, timestamp=Timestamp(1631013757), block_number=13178342, from_address=addr2, to_address=string_to_ethereum_address( '0xEaDD9B69F96140283F9fF75DA5FD33bcF54E6296'), value=0, gas=77373, gas_price=int(0.000000100314697497 * 10**18), gas_used=46782, input_data=hexstring_to_bytes( '0xa9059cbb00000000000000000000000020c8032d4f7d4a380385f87aeadf05bed84504cb000000000000000000000000000000000000000000000000000000003b9deec6' ), # noqa: E501 nonce=3, ) transactions = [transaction1, transaction2] if transaction_already_queried is True: dbethtx.add_ethereum_transactions(ethereum_transactions=[transaction1], relevant_address=addr1) # noqa: E501 dbethtx.add_ethereum_transactions(ethereum_transactions=[transaction2], relevant_address=addr2) # noqa: E501 result = dbethtx.get_ethereum_transactions( ETHTransactionsFilterQuery.make(), True) assert result == transactions expected_receipt1 = EthereumTxReceipt( tx_hash=tx_hash1, contract_address=None, status=True, type=0, logs=[ EthereumTxReceiptLog( log_index=295, data=hexstring_to_bytes( '0x0000000000000000000000000000000000000000000000008ac7230489e80000' ), # noqa: E501 address=string_to_ethereum_address( '0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2'), removed=False, topics=[ hexstring_to_bytes( '0xe1fffcc4923d04b559f4d29a8bfc6cda04eb5b0d3c460751c2402c5c5cc9109c' ), # noqa: E501 hexstring_to_bytes( '0x0000000000000000000000007a250d5630b4cf539739df2c5dacb4c659f2488d' ), # noqa: E501 ], ), EthereumTxReceiptLog( log_index=296, data=hexstring_to_bytes( '0x0000000000000000000000000000000000000000000000008ac7230489e80000' ), # noqa: E501 address=string_to_ethereum_address( '0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2'), removed=False, topics=[ hexstring_to_bytes( '0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef' ), # noqa: E501 hexstring_to_bytes( '0x0000000000000000000000007a250d5630b4cf539739df2c5dacb4c659f2488d' ), # noqa: E501 hexstring_to_bytes( '0x000000000000000000000000caa004418eb42cdf00cb057b7c9e28f0ffd840a5' ), # noqa: E501 ], ), EthereumTxReceiptLog( log_index=297, data=hexstring_to_bytes( '0x00000000000000000000000000000000000000000000036ba1d53baeeda5ed20' ), # noqa: E501 address=string_to_ethereum_address( '0x2a3bFF78B79A009976EeA096a51A948a3dC00e34'), removed=False, topics=[ hexstring_to_bytes( '0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef' ), # noqa: E501 hexstring_to_bytes( '0x000000000000000000000000caa004418eb42cdf00cb057b7c9e28f0ffd840a5' ), # noqa: E501 hexstring_to_bytes( '0x000000000000000000000000443e1f9b1c866e54e914822b7d3d7165edb6e9ea' ), # noqa: E501 ], ), EthereumTxReceiptLog( log_index=298, data=hexstring_to_bytes( '0x000000000000000000000000000000000000000000007b6ea033189ba7d047e30000000000000000000000000000000000000000000000140bc8194dd0f5e4be' ), # noqa: E501 address=string_to_ethereum_address( '0xcaA004418eB42cdf00cB057b7C9E28f0FfD840a5'), removed=False, topics=[ hexstring_to_bytes( '0x1c411e9a96e071241c2f21f7726b17ae89e3cab4c78be50e062b03a9fffbbad1' ) ], # noqa: E501 ), EthereumTxReceiptLog( log_index=299, data=hexstring_to_bytes( '0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008ac7230489e8000000000000000000000000000000000000000000000000036ba1d53baeeda5ed200000000000000000000000000000000000000000000000000000000000000000' ), # noqa: E501 address=string_to_ethereum_address( '0xcaA004418eB42cdf00cB057b7C9E28f0FfD840a5'), removed=False, topics=[ hexstring_to_bytes( '0xd78ad95fa46c994b6551d0da85fc275fe613ce37657fb8d5e3d130840159d822' ), # noqa: E501 hexstring_to_bytes( '0x0000000000000000000000007a250d5630b4cf539739df2c5dacb4c659f2488d' ), # noqa: E501 hexstring_to_bytes( '0x000000000000000000000000443e1f9b1c866e54e914822b7d3d7165edb6e9ea' ), # noqa: E501 ], ), ], ) expected_receipt2 = EthereumTxReceipt( tx_hash=tx_hash2, contract_address=None, status=True, type=2, logs=[ EthereumTxReceiptLog( log_index=438, data=hexstring_to_bytes( '0x000000000000000000000000000000000000000000000000000000003b9deec6' ), # noqa: E501 address=string_to_ethereum_address( '0xEaDD9B69F96140283F9fF75DA5FD33bcF54E6296'), removed=False, topics=[ hexstring_to_bytes( '0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef' ), # noqa: E501 hexstring_to_bytes( '0x000000000000000000000000442068f934be670adab81242c87144a851d56d16' ), # noqa: E501 hexstring_to_bytes( '0x00000000000000000000000020c8032d4f7d4a380385f87aeadf05bed84504cb' ), # noqa: E501 ], ), ], ) if one_receipt_in_db: dbethtx.add_receipt_data(txreceipt_to_data(expected_receipt1)) return transactions, [expected_receipt1, expected_receipt2]
from rotkehlchen.chain.ethereum.types import string_to_ethereum_address RANGE_PREFIX_ETHTX = 'ethtxs' RANGE_PREFIX_ETHINTERNALTX = 'ethinternaltxs' RANGE_PREFIX_ETHTOKENTX = 'ethtokentxs' MODULES_PACKAGE = 'rotkehlchen.chain.ethereum.modules' MODULES_PREFIX = MODULES_PACKAGE + '.' MODULES_PREFIX_LENGTH = len(MODULES_PREFIX) ZERO_ADDRESS = string_to_ethereum_address( '0x0000000000000000000000000000000000000000') CPT_KRAKEN = 'kraken'
def test_associated_locations(database): """Test that locations imported in different places are correctly stored in database""" # Add trades from different locations trades = [Trade( timestamp=Timestamp(1595833195), location=Location.CRYPTOCOM, base_asset=A_ETH, quote_asset=A_EUR, trade_type=TradeType.BUY, amount=AssetAmount(FVal('1.0')), rate=Price(FVal('281.14')), fee=Fee(ZERO), fee_currency=A_USD, link='', notes='', ), Trade( timestamp=Timestamp(1587825824), location=Location.CRYPTOCOM, base_asset=A_ETH, quote_asset=A_EUR, trade_type=TradeType.BUY, amount=AssetAmount(FVal('50.0')), rate=Price(FVal('3.521')), fee=Fee(ZERO), fee_currency=A_USD, link='', notes='', ), Trade( timestamp=Timestamp(1596014214), location=Location.BLOCKFI, base_asset=A_ETH, quote_asset=A_EUR, trade_type=TradeType.BUY, amount=AssetAmount(FVal('50.0')), rate=Price(FVal('3.521')), fee=Fee(ZERO), fee_currency=A_USD, link='', notes='', ), Trade( timestamp=Timestamp(1565888464), location=Location.NEXO, base_asset=A_ETH, quote_asset=A_EUR, trade_type=TradeType.BUY, amount=AssetAmount(FVal('50.0')), rate=Price(FVal('3.521')), fee=Fee(ZERO), fee_currency=A_USD, link='', notes='', ), Trade( timestamp=Timestamp(1596014214), location=Location.NEXO, base_asset=A_ETH, quote_asset=A_EUR, trade_type=TradeType.BUY, amount=AssetAmount(FVal('50.0')), rate=Price(FVal('3.521')), fee=Fee(ZERO), fee_currency=A_USD, link='', notes='', ), Trade( timestamp=Timestamp(1612051199), location=Location.BLOCKFI, base_asset=symbol_to_asset_or_token('USDC'), quote_asset=symbol_to_asset_or_token('LTC'), trade_type=TradeType.BUY, amount=AssetAmount(FVal('6404.6')), rate=Price(FVal('151.6283999982779809352223797')), fee=None, fee_currency=None, link='', notes='One Time', ), Trade( timestamp=Timestamp(1595833195), location=Location.POLONIEX, base_asset=A_ETH, quote_asset=A_EUR, trade_type=TradeType.BUY, amount=AssetAmount(FVal('1.0')), rate=Price(FVal('281.14')), fee=Fee(ZERO), fee_currency=A_USD, link='', notes='', ), Trade( timestamp=Timestamp(1596429934), location=Location.COINBASE, base_asset=A_ETH, quote_asset=A_EUR, trade_type=TradeType.BUY, amount=AssetAmount(FVal('0.00061475')), rate=Price(FVal('309.0687271248474989833265555')), fee=Fee(ZERO), fee_currency=A_USD, link='', notes='', ), Trade( timestamp=Timestamp(1596429934), location=Location.EXTERNAL, base_asset=A_ETH, quote_asset=A_EUR, trade_type=TradeType.BUY, amount=AssetAmount(FVal('1')), rate=Price(FVal('320')), fee=Fee(ZERO), fee_currency=A_USD, link='', notes='', )] # Add multiple entries for same exchange + connected exchange database.add_trades(trades) kraken_api_key1 = ApiKey('kraken_api_key') kraken_api_secret1 = ApiSecret(b'kraken_api_secret') kraken_api_key2 = ApiKey('kraken_api_key2') kraken_api_secret2 = ApiSecret(b'kraken_api_secret2') binance_api_key = ApiKey('binance_api_key') binance_api_secret = ApiSecret(b'binance_api_secret') # add mock kraken and binance database.add_exchange('kraken1', Location.KRAKEN, kraken_api_key1, kraken_api_secret1) database.add_exchange('kraken2', Location.KRAKEN, kraken_api_key2, kraken_api_secret2) database.add_exchange('binance', Location.BINANCE, binance_api_key, binance_api_secret) # Add uniswap and sushiswap events database.add_amm_events([ LiquidityPoolEvent( tx_hash='0x47ea26957ce09e84a51b51dfdab6a4ac1c3672a372eef77b15ef7677174ac847', log_index=23, address=ChecksumEthAddress('0x3163Bb273E8D9960Ce003fD542bF26b4C529f515'), timestamp=Timestamp(1590011534), event_type=EventType.MINT_SUSHISWAP, pool_address=ChecksumEthAddress('0xa2107FA5B38d9bbd2C461D6EDf11B11A50F6b974'), token0=EthereumToken('0x514910771AF9Ca656af840dff83E8264EcF986CA'), token1=EthereumToken('0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2'), amount0=FVal('3.313676003468974932'), amount1=FVal('0.064189269269768657'), usd_price=FVal('26.94433946158740371839009166230438'), lp_amount=FVal('0.460858304063739927'), ), ]) database.add_amm_swaps([ AMMSwap( tx_hash='0xa54bf4c68d435e3c8f432fd7e62b7f8aca497a831a3d3fca305a954484ddd7b2', log_index=208, address=ChecksumEthAddress('0xa2107FA5B38d9bbd2C461D6EDf11B11A50F6b974'), from_address=string_to_ethereum_address('0xd9e1cE17f2641f24aE83637ab66a2cca9C378B9F'), to_address=string_to_ethereum_address('0xC9cB53B48A2f3A9e75982685644c1870F1405CCb'), timestamp=Timestamp(1609301469), location=Location.UNISWAP, token0=EthereumToken('0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2'), token1=EthereumToken('0xdAC17F958D2ee523a2206206994597C13D831ec7'), amount0_in=AssetAmount(FVal('2.6455727132446468')), amount1_in=AssetAmount(ZERO), amount0_out=AssetAmount(ZERO), amount1_out=AssetAmount(FVal('1936.810111')), ), ]) database.add_balancer_events([ BalancerEvent( tx_hash='0xa54bf4c68d435e3c8f432fd7e62b7f8aca497a831a3d3fca305a954484ddd7b3', log_index=23, address=ChecksumEthAddress('0xa2107FA5B38d9bbd2C461D6EDf11B11A50F6b974'), timestamp=Timestamp(1609301469), event_type=BalancerBPTEventType.MINT, pool_address_token=EthereumToken('0x514910771AF9Ca656af840dff83E8264EcF986CA'), lp_balance=Balance(amount=FVal(2), usd_value=FVal(3)), amounts=[ AssetAmount(FVal(1)), AssetAmount(FVal(2)), ], ), ]) expected_locations = { Location.KRAKEN, Location.BINANCE, Location.BLOCKFI, Location.NEXO, Location.CRYPTOCOM, Location.POLONIEX, Location.COINBASE, Location.EXTERNAL, Location.SUSHISWAP, Location.UNISWAP, Location.BALANCER, } assert set(database.get_associated_locations()) == expected_locations
def test_gitcoin_claim(database, ethereum_manager, eth_transactions): """Data for claim taken from https://etherscan.io/tx/0x0e22cbdbac56c785f186bec44d715ab0834ceeadd96573c030f2fae1550b64fa """ msg_aggregator = MessagesAggregator() tx_hex = '0x0e22cbdbac56c785f186bec44d715ab0834ceeadd96573c030f2fae1550b64fa' evmhash = deserialize_evm_tx_hash(tx_hex) transaction = EthereumTransaction( tx_hash=evmhash, timestamp=1646375440, block_number=14351442, from_address='0xdF5CEF8Dc0CEA8DC200F09280915d1CD7a016BDe', to_address='0xDE3e5a990bCE7fC60a6f017e7c4a95fc4939299E', value=0, gas=171249, gas_price=22990000000, gas_used=171249, input_data=hexstring_to_bytes('0x09c5eabe000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000002e43f7658fd000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000001a0000000000000000000000000000000000000000000000000000000000000013500050000a7823d6f1e31569f51861e345b30c6bebf70ebe70000000000009cf6f6a78083ca3e2a662d6dd1703c939c8ace2e268d88ad09518695c6c3712ac10a214be5109a655671000927c00101006401867f7a4d000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc20000000000000000000000003f615ba21bc6cc5d4a6d798c5950cc5c42937fbd00000000000000000000000000000000000000000000000007392088b40d14000000000000000000000000000000000000000000000000000000000000000080000000000000000000000000000000000000000000000000000000000000004000000000000000000000000006c187e1b71ffbee4429003bb846c1b3eb1610000000000000000000000000000000000000000000000000000048c52ee05b140000000000000000000000000000000000000000000000000000000000000000000000000000000000000105041b1c1c1c73a08c7605fa9c69f068338cb7cd1c8dd21189cbe56f4cc66cff8dc7f0b0c8cc8c64433ea24643b893c9062beae6a05656b1df5643a242533d63925144c3e5c7dfd0509fb3c4232cfdb4c500e942a95b23439b3e18bab4a40057e1bdfae2d9967025b3f8fdca13354b25250c0d7fa9e4b472dc97df1f0cd0f595dc266d09e711628b3a63c1a6e4c83a11d3655891e31901eacf73b927e10bfbe6b0d5ed808cc228d606779a19a7dfb7393956b4fada14eaef8f6de6ee3824e67d6df18cc2d55f00cf869cc920135a94fb4abc213dc43e97812879d9efab046e4fffb931dcb55e5aa2b86f6a848408fea42cd221df99f1720b2ce22830498d78d04e1d083ba12800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000'), # noqa: E501 nonce=12, ) receipt = EthereumTxReceipt( tx_hash=evmhash, contract_address=None, status=True, type=0, logs=[ EthereumTxReceiptLog( log_index=473, data=hexstring_to_bytes('0x00000000000000000000000000000000000000000000000eb9078f7826f80000'), # noqa: E501 address=string_to_ethereum_address('0xDe30da39c46104798bB5aA3fe8B9e0e1F348163F'), removed=False, topics=[ hexstring_to_bytes('0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef'), # noqa: E501 hexstring_to_bytes('0x000000000000000000000000de3e5a990bce7fc60a6f017e7c4a95fc4939299e'), # noqa: E501 hexstring_to_bytes('0x000000000000000000000000df5cef8dc0cea8dc200f09280915d1cd7a016bde'), # noqa: E501 ], ), EthereumTxReceiptLog( log_index=6, data=hexstring_to_bytes('0x0000000000000000000000000000000000000000000000000000000000018580000000000000000000000000df5cef8dc0cea8dc200f09280915d1cd7a016bde00000000000000000000000000000000000000000000000eb9078f7826f80000bcfadbb867130fed43327b6c801903ab2afb5134ba5f3d47d2647ab858d5e49e'), # noqa: E501 address=string_to_ethereum_address('0xDE3e5a990bCE7fC60a6f017e7c4a95fc4939299E'), removed=False, topics=[ hexstring_to_bytes('0x04672052dcb6b5b19a9cc2ec1b8f447f1f5e47b5e24cfa5e4ffb640d63ca2be7'), # noqa: E501 ], ), ], ) dbethtx = DBEthTx(database) dbethtx.add_ethereum_transactions([transaction], relevant_address=None) decoder = EVMTransactionDecoder( database=database, ethereum_manager=ethereum_manager, eth_transactions=eth_transactions, msg_aggregator=msg_aggregator, ) events = decoder.decode_transaction(transaction=transaction, tx_receipt=receipt) assert len(events) == 2 expected_events = [ HistoryBaseEntry( event_identifier='0x0e22cbdbac56c785f186bec44d715ab0834ceeadd96573c030f2fae1550b64fa', sequence_index=0, timestamp=1646375440000, location=Location.BLOCKCHAIN, event_type=HistoryEventType.SPEND, event_subtype=HistoryEventSubType.FEE, asset=A_ETH, balance=Balance( amount=FVal(0.00393701451), usd_value=ZERO, ), location_label='0xdF5CEF8Dc0CEA8DC200F09280915d1CD7a016BDe', notes='Burned 0.00393701451 ETH in gas from 0xdF5CEF8Dc0CEA8DC200F09280915d1CD7a016BDe', # noqa: E501 counterparty=CPT_GAS, ), HistoryBaseEntry( event_identifier='0x0e22cbdbac56c785f186bec44d715ab0834ceeadd96573c030f2fae1550b64fa', sequence_index=474, timestamp=1646375440000, location=Location.BLOCKCHAIN, event_type=HistoryEventType.RECEIVE, event_subtype=HistoryEventSubType.AIRDROP, asset=EthereumToken('0xDe30da39c46104798bB5aA3fe8B9e0e1F348163F'), balance=Balance(amount=FVal('271.5872'), usd_value=ZERO), location_label='0xdF5CEF8Dc0CEA8DC200F09280915d1CD7a016BDe', notes='Claim 271.5872 GTC from the GTC airdrop', counterparty='0xDE3e5a990bCE7fC60a6f017e7c4a95fc4939299E', ), ] assert events == expected_events
from rotkehlchen.chain.ethereum.structures import EthereumTxReceiptLog from rotkehlchen.chain.ethereum.types import string_to_ethereum_address from rotkehlchen.chain.ethereum.utils import asset_normalized_value, ethaddress_to_asset from rotkehlchen.fval import FVal from rotkehlchen.types import ChecksumEthAddress, EthereumTransaction from rotkehlchen.user_messages import MessagesAggregator from rotkehlchen.utils.misc import hex_or_bytes_to_address, hex_or_bytes_to_int from .constants import CPT_KYBER if TYPE_CHECKING: from rotkehlchen.chain.ethereum.decoding.base import BaseDecoderTools from rotkehlchen.chain.ethereum.manager import EthereumManager KYBER_TRADE_LEGACY = b'\xf7$\xb4\xdff\x17G6\x12\xb5=\x7f\x88\xec\xc6\xea\x980t\xb3\t`\xa0I\xfc\xd0e\x7f\xfe\x80\x80\x83' # noqa: E501 KYBER_LEGACY_CONTRACT = string_to_ethereum_address('0x9ae49C0d7F8F9EF4B864e004FE86Ac8294E20950') KYBER_LEGACY_CONTRACT_MIGRATED = string_to_ethereum_address('0x65bF64Ff5f51272f729BDcD7AcFB00677ced86Cd') # noqa: E501 KYBER_LEGACY_CONTRACT_UPGRADED = string_to_ethereum_address('0x9AAb3f75489902f3a48495025729a0AF77d4b11e') # noqa: E501 def _legacy_contracts_basic_info(tx_log: EthereumTxReceiptLog) -> Tuple[ChecksumEthAddress, Optional[Asset], Optional[Asset]]: # noqa: E501 """ Returns: - address of the sender - source token (can be none) - destination token (can be none) May raise: - DeserializationError when using hex_or_bytes_to_address """ sender = hex_or_bytes_to_address(tx_log.topics[1]) source_token_address = hex_or_bytes_to_address(tx_log.data[:32])
def test_1inch_claim(database, ethereum_manager, eth_transactions): """Data for claim taken from https://etherscan.io/tx/0x0582a0db79de3fa21d3b92a8658e0b1034c51ea54a8e06ea84fbb91d41b8fe17 """ msg_aggregator = MessagesAggregator() tx_hex = '0x0582a0db79de3fa21d3b92a8658e0b1034c51ea54a8e06ea84fbb91d41b8fe17' evmhash = deserialize_evm_tx_hash(tx_hex) transaction = EthereumTransaction( tx_hash=evmhash, timestamp=1646375440, block_number=14351442, from_address='0xc931De6d845846E332a52D045072E3feF540Bd5d', to_address='0xE295aD71242373C37C5FdA7B57F26f9eA1088AFe', value=0, gas=171249, gas_price=22990000000, gas_used=171249, input_data=hexstring_to_bytes('0x2e7ba6ef000000000000000000000000000000000000000000000000000000000000c0e5000000000000000000000000c931de6d845846e332a52d045072e3fef540bd5d00000000000000000000000000000000000000000000002109156970b0a5f32f00000000000000000000000000000000000000000000000000000000000000800000000000000000000000000000000000000000000000000000000000000010dbe83b35ea054d18e5fdd804d60b6a528f4b66a227079ecb82febf8eb40919495d102f8922e57278b2b6bb3369ae34c37c378dbd4819126c5e5d371ed4777c4580a9985219f50d16cefc798c2aeb6a4d7fa786f4f38ab27b420e6f3f8e25bd0f45709afe1f9fdec3cbea17d1ec63c6f62ce396524b04c9460bb05ef548239ae050b5330a4228c26b8b25ff021c6cc89ed4f0411ecce80256d090d860f9e6ff5e604076af74bd91959259ff59f8d54455a0edcad41ef1fe230504826f025769c250d89c63241d1dfec9dc4dc75f0a0ec47bcc10594ca7db74335507a5f6e4344b52b129d8e0aaeffe22b7595fa9f11c8e2381feafaf25042407913b9ec34cdf879a05d18a68b7a2506a29ba42fb004c7f32390f986f943a2557e304dc777f73869a046dc08506268e16603452a33ea179b4932eeae59338dd3fee75685cc490f1acba6c0ed0c90792bb6f9f696ad1417efe0032bb0e86b6927234ce419628e24c0d577b40b8956166e4d21cba88b58b32dec0a00b2864e8ed4ac5d7be6683f5f297aaf35d6ca208a954554f4ab14a1ca973daf13e7c1dad49db82611f4dadf2a3c32355753f5e11ba88adc0d27f10ad32ad4904bfd782c15693c6795b047124fccd0f927a7dda89206be7ad613644d02a622c3f30f5de40d052b4c3e10ef02a18107e7a23a7abca2aacc0bf854e247569f822013a86927b10f772b7b13fbc8732'), # noqa: E501 nonce=19, ) receipt = EthereumTxReceipt( tx_hash=evmhash, contract_address=None, status=True, type=0, logs=[ EthereumTxReceiptLog( log_index=297, data=hexstring_to_bytes('0x00000000000000000000000000000000000000000000002109156970b0a5f32f'), # noqa: E501 address=string_to_ethereum_address('0x111111111117dC0aa78b770fA6A738034120C302'), removed=False, topics=[ hexstring_to_bytes('0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef'), # noqa: E501 hexstring_to_bytes('0x000000000000000000000000e295ad71242373c37c5fda7b57f26f9ea1088afe'), # noqa: E501 hexstring_to_bytes('0x000000000000000000000000c931de6d845846e332a52d045072e3fef540bd5d'), # noqa: E501 ], ), EthereumTxReceiptLog( log_index=298, data=hexstring_to_bytes('0x000000000000000000000000000000000000000000000000000000000000c0e5000000000000000000000000c931de6d845846e332a52d045072e3fef540bd5d00000000000000000000000000000000000000000000002109156970b0a5f32f'), # noqa: E501 address=string_to_ethereum_address('0xE295aD71242373C37C5FdA7B57F26f9eA1088AFe'), removed=False, topics=[ hexstring_to_bytes('0x4ec90e965519d92681267467f775ada5bd214aa92c0dc93d90a5e880ce9ed026'), # noqa: E501 ], ), ], ) dbethtx = DBEthTx(database) dbethtx.add_ethereum_transactions([transaction], relevant_address=None) decoder = EVMTransactionDecoder( database=database, ethereum_manager=ethereum_manager, eth_transactions=eth_transactions, msg_aggregator=msg_aggregator, ) events = decoder.decode_transaction(transaction=transaction, tx_receipt=receipt) assert len(events) == 2 expected_events = [ HistoryBaseEntry( event_identifier='0x0582a0db79de3fa21d3b92a8658e0b1034c51ea54a8e06ea84fbb91d41b8fe17', sequence_index=0, timestamp=1646375440000, location=Location.BLOCKCHAIN, event_type=HistoryEventType.SPEND, event_subtype=HistoryEventSubType.FEE, asset=A_ETH, balance=Balance( amount=FVal(0.00393701451), usd_value=ZERO, ), location_label='0xc931De6d845846E332a52D045072E3feF540Bd5d', notes='Burned 0.00393701451 ETH in gas from 0xc931De6d845846E332a52D045072E3feF540Bd5d', # noqa: E501 counterparty=CPT_GAS, ), HistoryBaseEntry( event_identifier='0x0582a0db79de3fa21d3b92a8658e0b1034c51ea54a8e06ea84fbb91d41b8fe17', sequence_index=298, timestamp=1646375440000, location=Location.BLOCKCHAIN, event_type=HistoryEventType.RECEIVE, event_subtype=HistoryEventSubType.AIRDROP, asset=EthereumToken('0x111111111117dC0aa78b770fA6A738034120C302'), balance=Balance(amount=FVal('609.397099685988397871'), usd_value=ZERO), location_label='0xc931De6d845846E332a52D045072E3feF540Bd5d', notes='Claim 609.397099685988397871 1INCH from the 1INCH airdrop', counterparty=CPT_ONEINCH, ), ] assert events == expected_events
def addresses_to_decoders( self) -> Dict[ChecksumEthAddress, Tuple[Any, ...]]: return { MAKERDAO_BAT_A_JOIN.address: (self.decode_makerdao_vault_action, A_BAT, 'BAT-A'), MAKERDAO_ETH_A_JOIN.address: (self.decode_makerdao_vault_action, A_ETH, 'ETH-A'), MAKERDAO_ETH_B_JOIN.address: (self.decode_makerdao_vault_action, A_ETH, 'ETH-B'), MAKERDAO_ETH_C_JOIN.address: (self.decode_makerdao_vault_action, A_ETH, 'ETH-C'), MAKERDAO_KNC_A_JOIN.address: (self.decode_makerdao_vault_action, A_KNC, 'KNC-A'), MAKERDAO_TUSD_A_JOIN.address: (self.decode_makerdao_vault_action, A_TUSD, 'TUSD-A'), MAKERDAO_USDC_A_JOIN.address: (self.decode_makerdao_vault_action, A_USDC, 'USDC-A'), MAKERDAO_USDC_B_JOIN.address: (self.decode_makerdao_vault_action, A_USDC, 'USDC-B'), MAKERDAO_USDT_A_JOIN.address: (self.decode_makerdao_vault_action, A_USDT, 'USDT-A'), MAKERDAO_WBTC_A_JOIN.address: (self.decode_makerdao_vault_action, A_WBTC, 'WBTC-A'), MAKERDAO_WBTC_B_JOIN.address: (self.decode_makerdao_vault_action, A_WBTC, 'WBTC-B'), MAKERDAO_WBTC_C_JOIN.address: (self.decode_makerdao_vault_action, A_WBTC, 'WBTC-C'), MAKERDAO_ZRX_A_JOIN.address: (self.decode_makerdao_vault_action, A_ZRX, 'ZRX-A'), MAKERDAO_MANA_A_JOIN.address: (self.decode_makerdao_vault_action, A_MANA, 'MANA-A'), MAKERDAO_PAXUSD_A_JOIN.address: (self.decode_makerdao_vault_action, A_PAX, 'PAXUSD-A'), MAKERDAO_COMP_A_JOIN.address: (self.decode_makerdao_vault_action, A_COMP, 'COMP-A'), MAKERDAO_LRC_A_JOIN.address: (self.decode_makerdao_vault_action, A_LRC, 'LRC-A'), MAKERDAO_LINK_A_JOIN.address: (self.decode_makerdao_vault_action, A_LINK, 'LINK-A'), MAKERDAO_BAL_A_JOIN.address: (self.decode_makerdao_vault_action, A_BAL, 'BAL-A'), MAKERDAO_YFI_A_JOIN.address: (self.decode_makerdao_vault_action, A_YFI, 'YFI-A'), MAKERDAO_GUSD_A_JOIN.address: (self.decode_makerdao_vault_action, A_GUSD, 'GUSD-A'), MAKERDAO_UNI_A_JOIN.address: (self.decode_makerdao_vault_action, A_UNI, 'UNI-A'), MAKERDAO_RENBTC_A_JOIN.address: (self.decode_makerdao_vault_action, A_RENBTC, 'RENBTC-A'), # noqa: E501 MAKERDAO_AAVE_A_JOIN.address: (self.decode_makerdao_vault_action, A_AAVE, 'AAVE-A'), MAKERDAO_MATIC_A_JOIN.address: (self.decode_makerdao_vault_action, A_MATIC, 'MATIC-A'), MAKERDAO_POT.address: (self.decode_pot_for_dsr, ), MAKERDAO_DAI_JOIN.address: (self.decode_makerdao_debt_payback, ), string_to_ethereum_address('0xA26e15C895EFc0616177B7c1e7270A4C7D51C997'): (self.decode_proxy_creation, ), # noqa: E501 string_to_ethereum_address('0x89d24A6b4CcB1B6fAA2625fE562bDD9a23260359'): (self.decode_saidai_migration, ), # noqa: E501 MAKERDAO_CDP_MANAGER.address: (self.decode_cdp_manager_events, ), }
event_subtype=HistoryEventSubType.NONE, asset=asset, balance=Balance(amount=ONE, usd_value=ONE), counterparty=counterparty, ) def generate_tx_entries_response( data: List[Tuple[EthereumTransaction, List[HistoryBaseEntry]]], ) -> List: result = [] for tx, events in data: decoded_events = [] for event in events: decoded_events.append({ 'entry': event.serialize(), 'customized': False, }) result.append({ 'entry': tx.serialize(), 'decoded_events': decoded_events, 'ignored_in_accounting': False, }) return result UNIT_BTC_ADDRESS1 = '1BvBMSEYstWetqTFn5Au4m4GFg7xJaNVN2' UNIT_BTC_ADDRESS2 = '1CounterpartyXXXXXXXXXXXXXXXUWLpVr' UNIT_BTC_ADDRESS3 = '18ddjB7HWTVxzvTbLp1nWvaBxU3U2oTZF2' ZERO_ETH_ADDRESS = string_to_ethereum_address('0x' + '0' * 40)
from rotkehlchen.assets.utils import symbol_to_asset_or_token from rotkehlchen.chain.ethereum.types import string_to_ethereum_address from rotkehlchen.constants.assets import A_BAT, A_CRV, A_DAI, A_PICKLE from rotkehlchen.constants.misc import NFT_DIRECTIVE from rotkehlchen.constants.resolver import ethaddress_to_identifier from rotkehlchen.errors.misc import InputError from rotkehlchen.exchanges.data_structures import Trade from rotkehlchen.globaldb.handler import GLOBAL_DB_VERSION, GlobalDBHandler from rotkehlchen.history.types import HistoricalPriceOracle from rotkehlchen.serialization.deserialize import deserialize_asset_amount from rotkehlchen.tests.fixtures.globaldb import create_globaldb from rotkehlchen.tests.utils.factories import make_ethereum_address from rotkehlchen.tests.utils.globaldb import INITIAL_TOKENS from rotkehlchen.types import Location, Price, Timestamp, TradeType selfkey_address = string_to_ethereum_address( '0x4CC19356f2D37338b9802aa8E8fc58B0373296E7') selfkey_id = ethaddress_to_identifier(selfkey_address) selfkey_asset_data = AssetData( identifier=selfkey_id, name='Selfkey', symbol='KEY', asset_type=AssetType.ETHEREUM_TOKEN, started=Timestamp(1508803200), forked=None, swapped_for=None, ethereum_address=selfkey_address, decimals=18, cryptocompare=None, coingecko='selfkey', protocol=None, )
from rotkehlchen.chain.ethereum.types import string_to_ethereum_address # keccak of Transfer(address,address,uint256) ERC20_OR_ERC721_TRANSFER = b'\xdd\xf2R\xad\x1b\xe2\xc8\x9bi\xc2\xb0h\xfc7\x8d\xaa\x95+\xa7\xf1c\xc4\xa1\x16(\xf5ZM\xf5#\xb3\xef' # noqa: E501 # keccak of approve(address,uint256) ERC20_APPROVE = b'\x8c[\xe1\xe5\xeb\xec}[\xd1OqB}\x1e\x84\xf3\xdd\x03\x14\xc0\xf7\xb2)\x1e[ \n\xc8\xc7\xc3\xb9%' # noqa: E501 GTC_CLAIM = b'\x04g R\xdc\xb6\xb5\xb1\x9a\x9c\xc2\xec\x1b\x8fD\x7f\x1f^G\xb5\xe2L\xfa^O\xfbd\rc\xca+\xe7' # noqa: E501 ONEINCH_CLAIM = b'N\xc9\x0e\x96U\x19\xd9&\x81&tg\xf7u\xad\xa5\xbd!J\xa9,\r\xc9=\x90\xa5\xe8\x80\xce\x9e\xd0&' # noqa: E501 GNOSIS_CHAIN_BRIDGE_RECEIVE = b'\x9a\xfdG\x90~%\x02\x8c\xda\xca\x89\xd1\x93Q\x8c0+\xbb\x12\x86\x17\xd5\xa9\x92\xc5\xab\xd4X\x15Re\x93' # noqa: E501 GOVERNORALPHA_PROPOSE = b"}\x84\xa6&:\xe0\xd9\x8d3)\xbd{F\xbbN\x8do\x98\xcd5\xa7\xad\xb4\\'L\x8b\x7f\xd5\xeb\xd5\xe0" # noqa: E501 GOVERNORALPHA_PROPOSE_ABI = '{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"id","type":"uint256"},{"indexed":false,"internalType":"address","name":"proposer","type":"address"},{"indexed":false,"internalType":"address[]","name":"targets","type":"address[]"},{"indexed":false,"internalType":"uint256[]","name":"values","type":"uint256[]"},{"indexed":false,"internalType":"string[]","name":"signatures","type":"string[]"},{"indexed":false,"internalType":"bytes[]","name":"calldatas","type":"bytes[]"},{"indexed":false,"internalType":"uint256","name":"startBlock","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"endBlock","type":"uint256"},{"indexed":false,"internalType":"string","name":"description","type":"string"}],"name":"ProposalCreated","type":"event"}' # noqa: E501 NAUGHTY_ERC721 = ( # list of ERC721 NFT tokens, not really following the standard # Cryptovoxels string_to_ethereum_address('0x4243a8413A77Eb559c6f8eAFfA63F46019056d08'), ) # TODO: Probably this mapping needs to go somewhere else as part of # https://github.com/rotki/rotki/issues/1420 # Map of known addresses to some names. Names sourced by various sources # including but not limited to etherscan's labels ETHADDRESS_TO_KNOWN_NAME = { string_to_ethereum_address('0x2910543Af39abA0Cd09dBb2D50200b3E800A63D2'): 'Kraken', string_to_ethereum_address('0xAe2D4617c862309A3d75A0fFB358c7a5009c673F'): 'Kraken 10', string_to_ethereum_address('0x43984D578803891dfa9706bDEee6078D80cFC79E'): 'Kraken 11', string_to_ethereum_address('0x66c57bF505A85A74609D2C83E94Aabb26d691E1F'): 'Kraken 12', string_to_ethereum_address('0xDA9dfA130Df4dE4673b89022EE50ff26f6EA73Cf'): 'Kraken 13', string_to_ethereum_address('0x0A869d79a7052C7f1b55a8EbAbbEa3420F0D1E13'): 'Kraken 2', string_to_ethereum_address('0xE853c56864A2ebe4576a807D26Fdc4A0adA51919'): 'Kraken 3',
AIRDROPS_LIST, CPT_BADGER, CPT_CONVEX, CPT_ELEMENT_FINANCE, CPT_FRAX, CPT_ONEINCH, CPT_SHAPESHIFT, CPT_UNISWAP, ) if TYPE_CHECKING: from rotkehlchen.chain.ethereum.decoding.base import BaseDecoderTools from rotkehlchen.chain.ethereum.manager import EthereumManager from rotkehlchen.user_messages import MessagesAggregator UNISWAP_DISTRIBUTOR = string_to_ethereum_address( '0x090D4613473dEE047c3f2706764f49E0821D256e') UNISWAP_TOKEN_CLAIMED = b'N\xc9\x0e\x96U\x19\xd9&\x81&tg\xf7u\xad\xa5\xbd!J\xa9,\r\xc9=\x90\xa5\xe8\x80\xce\x9e\xd0&' # noqa: E501 BADGERHUNT = string_to_ethereum_address( '0x394DCfbCf25C5400fcC147EbD9970eD34A474543') BADGER_HUNT_EVENT = b'\x8e\xaf\x15aI\x08\xa4\xe9\x02!A\xfeJYk\x1a\xb0\xcbr\xab2\xb2P#\xe3\xda*E\x9c\x9a3\\' # noqa: E501 ONEINCH = string_to_ethereum_address( '0xE295aD71242373C37C5FdA7B57F26f9eA1088AFe') ONEINCH_CLAIMED = b'N\xc9\x0e\x96U\x19\xd9&\x81&tg\xf7u\xad\xa5\xbd!J\xa9,\r\xc9=\x90\xa5\xe8\x80\xce\x9e\xd0&' # noqa: E501 FPIS = string_to_ethereum_address('0x61A1f84F12Ba9a56C22c31dDB10EC2e2CA0ceBCf') CONVEX = string_to_ethereum_address( '0x2E088A0A19dda628B4304301d1EA70b114e4AcCd') FPIS_CONVEX_CLAIM = b'G\xce\xe9|\xb7\xac\xd7\x17\xb3\xc0\xaa\x145\xd0\x04\xcd[<\x8cW\xd7\r\xbc\xebNDX\xbb\xd6\x0e9\xd4' # noqa: E501
from rotkehlchen.serialization.deserialize import ( deserialize_asset_amount, deserialize_ethereum_address, deserialize_timestamp, ) from .types import AdexEventDBTuple, AdexEventType, Bond, ChannelWithdraw, Unbond, UnbondRequest # Constants from the AdExNetwork repo IDENTITY_FACTORY_ADDR = '0x9fe0d438E3c29C7CFF949aD8e8dA9403A531cC1A' IDENTITY_PROXY_INIT_CODE = ( '0x608060405234801561001057600080fd5b5060026000803073ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff021916908360ff160217905550600260008073' # noqa: E501 '{signer_address}' '73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff021916908360ff1602179055506000734470bb87d77b963a013db939be332f927f2b992e9050600073ade00c28244d5ce17d72e40330b1c318cd12b7c3905060008273ffffffffffffffffffffffffffffffffffffffff166370a08231306040518263ffffffff1660e01b81526004016101429190610501565b60206040518083038186803b15801561015a57600080fd5b505afa15801561016e573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610192919061045a565b90506000811115610276578273ffffffffffffffffffffffffffffffffffffffff1663095ea7b383836040518363ffffffff1660e01b81526004016101d892919061051c565b600060405180830381600087803b1580156101f257600080fd5b505af1158015610206573d6000803e3d6000fd5b505050508173ffffffffffffffffffffffffffffffffffffffff166394b918de826040518263ffffffff1660e01b81526004016102439190610560565b600060405180830381600087803b15801561025d57600080fd5b505af1158015610271573d6000803e3d6000fd5b505050505b60008273ffffffffffffffffffffffffffffffffffffffff166370a08231306040518263ffffffff1660e01b81526004016102b19190610501565b60206040518083038186803b1580156102c957600080fd5b505afa1580156102dd573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610301919061045a565b9050600081111561043c576000734846c6837ec670bbd1f5b485471c8f64ecb9c53490508373ffffffffffffffffffffffffffffffffffffffff1663095ea7b382846040518363ffffffff1660e01b815260040161036092919061051c565b600060405180830381600087803b15801561037a57600080fd5b505af115801561038e573d6000803e3d6000fd5b505050508073ffffffffffffffffffffffffffffffffffffffff1663b4dca72460405180606001604052808581526020017f2ce0c96383fb229d9776f33846e983a956a7d95844fac57b180ed0071d93bb2860001b8152602001428152506040518263ffffffff1660e01b81526004016104089190610545565b600060405180830381600087803b15801561042257600080fd5b505af1158015610436573d6000803e3d6000fd5b50505050505b505050506105d8565b600081519050610454816105c1565b92915050565b60006020828403121561046c57600080fd5b600061047a84828501610445565b91505092915050565b61048c8161057b565b82525050565b61049b8161058d565b82525050565b6060820160008201516104b760008501826104e3565b5060208201516104ca6020850182610492565b5060408201516104dd60408501826104e3565b50505050565b6104ec816105b7565b82525050565b6104fb816105b7565b82525050565b60006020820190506105166000830184610483565b92915050565b60006040820190506105316000830185610483565b61053e60208301846104f2565b9392505050565b600060608201905061055a60008301846104a1565b92915050565b600060208201905061057560008301846104f2565b92915050565b600061058682610597565b9050919050565b6000819050919050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000819050919050565b6105ca816105b7565b81146105d557600080fd5b50565b6101b7806105e76000396000f3fe608060405234801561001057600080fd5b506004361061002f5760003560e01c8063c066a5b11461007357610030565b5b60007396e3cb4b4632ed45363ff2c9f0fbec9b583d9d3a90503660008037600080366000846127105a03f43d6000803e806000811461006e573d6000f35b3d6000fd5b61008d600480360381019061008891906100d8565b6100a3565b60405161009a9190610110565b60405180910390f35b60006020528060005260406000206000915054906101000a900460ff1681565b6000813590506100d28161016a565b92915050565b6000602082840312156100ea57600080fd5b60006100f8848285016100c3565b91505092915050565b61010a8161015d565b82525050565b60006020820190506101256000830184610101565b92915050565b60006101368261013d565b9050919050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b600060ff82169050919050565b6101738161012b565b811461017e57600080fd5b5056fea26469706673582212200e40aa3025d54e828fb973089b64ce06688fedcd71b98ae68521a0217652c59564736f6c634300060c0033' # noqa: E501 ) STAKING_ADDR = string_to_ethereum_address( '0x4846C6837ec670Bbd1f5b485471c8f64ECB9c534') CREATE2_SALT = f'0x{bytearray(32).hex()}' ADX_AMOUNT_MANTISSA = FVal(10**18) ADEX_EVENTS_PREFIX = 'adex_events' # Defines the expected order of the events given the same timestamp and sorting # in ascending mode EVENT_TYPE_ORDER_IN_ASC = { Bond: 3, ChannelWithdraw: 1, Unbond: 2, UnbondRequest: 4, }
import random import pytest import requests from rotkehlchen.chain.ethereum.types import string_to_ethereum_address from rotkehlchen.constants.assets import A_ETH, A_LQTY, A_LUSD from rotkehlchen.fval import FVal from rotkehlchen.tests.utils.api import ( api_url_for, assert_ok_async_response, assert_proper_response_with_result, wait_for_async_task_with_result, ) LQTY_ADDR = string_to_ethereum_address( '0x063c26fF1592688B73d8e2A18BA4C23654e2792E') LQTY_STAKING = string_to_ethereum_address( '0x018565899A88f75E6edfEA0639183adF8c205641') LQTY_PROXY = string_to_ethereum_address( '0x9476832d4687c14b2c1a04E2ee4693162a7340B6') ADDR_WITHOUT_TROVE = string_to_ethereum_address( '0xA0446D8804611944F1B527eCD37d7dcbE442caba') liquity_mocked_historical_prices = { A_ETH: { 'USD': { 1627818194: FVal('3000'), 1627818617: FVal('3000'), 1627827057: FVal('3500'), 1641529258: FVal('3395'), },
HistoryBaseEntry, HistoryEventSubType, HistoryEventType, ) from rotkehlchen.chain.ethereum.decoding.interfaces import DecoderInterface from rotkehlchen.chain.ethereum.decoding.structures import ActionItem from rotkehlchen.chain.ethereum.structures import EthereumTxReceiptLog from rotkehlchen.chain.ethereum.types import string_to_ethereum_address from rotkehlchen.chain.ethereum.utils import asset_normalized_value, ethaddress_to_asset from rotkehlchen.types import ChecksumEthAddress, EthereumTransaction from rotkehlchen.utils.misc import hex_or_bytes_to_address, hex_or_bytes_to_int from .constants import CPT_VOTIUM VOTIUM_CLAIM = b'Gf\x92\x1f\\Ydm"\xd7\xd2f\xa2\x91d\xc8\xe9b6\x84\xd8\xdf\xdb\xd91s\x1d\xfd\xca\x02R8' # noqa: E501 VOTIUM_CONTRACT = string_to_ethereum_address( '0x378Ba9B73309bE80BF4C2c027aAD799766a7ED5A') class VotiumDecoder(DecoderInterface): # lgtm[py/missing-call-to-init] def _decode_claim( # pylint: disable=no-self-use self, tx_log: EthereumTxReceiptLog, transaction: EthereumTransaction, # pylint: disable=unused-argument decoded_events: List[HistoryBaseEntry], all_logs: List[EthereumTxReceiptLog], # pylint: disable=unused-argument action_items: Optional[List[ActionItem]], # pylint: disable=unused-argument ) -> Tuple[Optional[HistoryBaseEntry], Optional[ActionItem]]: if tx_log.topics[0] != VOTIUM_CLAIM: return None, None claimed_token_address = hex_or_bytes_to_address(tx_log.topics[1])
def get_expected_trades(): """Function so no price (unknown) assets can be resolved only when existing in the DB""" address = string_to_ethereum_address('0x63BC843b9640c4D79d6aE0105bc39F773172d121') return [AMMTrade( trade_type=TradeType.BUY, base_asset=EthereumToken('0xdAC17F958D2ee523a2206206994597C13D831ec7'), quote_asset=EthereumToken('0x4b4D2e899658FB59b1D518b68fe836B100ee8958'), amount=AssetAmount(FVal('796.857811')), rate=Price(FVal('0.0008323741932057006980885326353')), trade_index=0, swaps=[AMMSwap( tx_hash='0x962d904d75c751fbff316f7a2ed280bd93241d5088d747a4f26fe7437813512f', log_index=141, address=address, from_address=string_to_ethereum_address('0xd9e1cE17f2641f24aE83637ab66a2cca9C378B9F'), to_address=string_to_ethereum_address('0x63BC843b9640c4D79d6aE0105bc39F773172d121'), timestamp=Timestamp(1609308616), location=Location.SUSHISWAP, token0=EthereumToken('0x4b4D2e899658FB59b1D518b68fe836B100ee8958'), token1=EthereumToken('0xdAC17F958D2ee523a2206206994597C13D831ec7'), amount0_in=AssetAmount(FVal('0.663283877530785731')), amount1_in=AssetAmount(ZERO), amount0_out=AssetAmount(ZERO), amount1_out=AssetAmount(FVal('796.857811')), )], ), AMMTrade( trade_type=TradeType.BUY, base_asset=EthereumToken('0x368B3a58B5f49392e5C9E4C998cb0bB966752E51'), quote_asset=EthereumToken('0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48'), amount=AssetAmount(FVal('2.223721994593087248')), rate=Price(FVal('1124.241252314216598775470692')), trade_index=0, swaps=[AMMSwap( tx_hash='0x90f68af0ebbbb8d4938a4fbd07a70862e806124abd907d1225f25a10afda0180', log_index=26, address=address, from_address=string_to_ethereum_address('0xd9e1cE17f2641f24aE83637ab66a2cca9C378B9F'), to_address=string_to_ethereum_address('0x06da0fd433C1A5d7a4faa01111c044910A184553'), timestamp=Timestamp(1609303966), location=Location.SUSHISWAP, token0=EthereumToken('0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48'), token1=EthereumToken('0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2'), amount0_in=AssetAmount(FVal('2500')), amount1_in=AssetAmount(ZERO), amount0_out=AssetAmount(ZERO), amount1_out=AssetAmount(FVal('3.410623314913014194')), ), AMMSwap( tx_hash='0x90f68af0ebbbb8d4938a4fbd07a70862e806124abd907d1225f25a10afda0180', log_index=29, address=address, from_address=string_to_ethereum_address('0xd9e1cE17f2641f24aE83637ab66a2cca9C378B9F'), to_address=string_to_ethereum_address('0xC9cB53B48A2f3A9e75982685644c1870F1405CCb'), timestamp=Timestamp(1609303966), location=Location.SUSHISWAP, token0=EthereumToken('0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2'), token1=EthereumToken('0xdAC17F958D2ee523a2206206994597C13D831ec7'), amount0_in=AssetAmount(FVal('3.410623314913014194')), amount1_in=AssetAmount(ZERO), amount0_out=AssetAmount(ZERO), amount1_out=AssetAmount(FVal('2474.601464')), ), AMMSwap( tx_hash='0x90f68af0ebbbb8d4938a4fbd07a70862e806124abd907d1225f25a10afda0180', log_index=32, address=address, from_address=string_to_ethereum_address('0xd9e1cE17f2641f24aE83637ab66a2cca9C378B9F'), to_address=string_to_ethereum_address('0x63BC843b9640c4D79d6aE0105bc39F773172d121'), timestamp=Timestamp(1609303966), location=Location.SUSHISWAP, token0=EthereumToken('0x368B3a58B5f49392e5C9E4C998cb0bB966752E51'), token1=EthereumToken('0xdAC17F958D2ee523a2206206994597C13D831ec7'), amount0_in=AssetAmount(ZERO), amount1_in=AssetAmount(FVal('2474.601464')), amount0_out=AssetAmount(FVal('2.223721994593087248')), amount1_out=AssetAmount(ZERO), )], ), AMMTrade( trade_type=TradeType.BUY, base_asset=EthereumToken('0x368B3a58B5f49392e5C9E4C998cb0bB966752E51'), quote_asset=EthereumToken('0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48'), amount=AssetAmount(FVal('1.925851508322134245')), rate=Price(FVal('1012.539124420295894184748806')), trade_index=0, swaps=[AMMSwap( tx_hash='0xa54bf4c68d435e3c8f432fd7e62b7f8aca497a831a3d3fca305a954484ddd7b2', log_index=205, address=address, from_address=string_to_ethereum_address('0xd9e1cE17f2641f24aE83637ab66a2cca9C378B9F'), to_address=string_to_ethereum_address('0x06da0fd433C1A5d7a4faa01111c044910A184553'), timestamp=Timestamp(1609301469), location=Location.SUSHISWAP, token0=EthereumToken('0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48'), token1=EthereumToken('0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2'), amount0_in=AssetAmount(FVal('1950')), amount1_in=AssetAmount(ZERO), amount0_out=AssetAmount(ZERO), amount1_out=AssetAmount(FVal('2.6455727132446468')), ), AMMSwap( tx_hash='0xa54bf4c68d435e3c8f432fd7e62b7f8aca497a831a3d3fca305a954484ddd7b2', log_index=208, address=address, from_address=string_to_ethereum_address('0xd9e1cE17f2641f24aE83637ab66a2cca9C378B9F'), to_address=string_to_ethereum_address('0xC9cB53B48A2f3A9e75982685644c1870F1405CCb'), timestamp=Timestamp(1609301469), location=Location.SUSHISWAP, token0=EthereumToken('0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2'), token1=EthereumToken('0xdAC17F958D2ee523a2206206994597C13D831ec7'), amount0_in=AssetAmount(FVal('2.6455727132446468')), amount1_in=AssetAmount(ZERO), amount0_out=AssetAmount(ZERO), amount1_out=AssetAmount(FVal('1936.810111')), ), AMMSwap( tx_hash='0xa54bf4c68d435e3c8f432fd7e62b7f8aca497a831a3d3fca305a954484ddd7b2', log_index=211, address=address, from_address=string_to_ethereum_address('0xd9e1cE17f2641f24aE83637ab66a2cca9C378B9F'), to_address=string_to_ethereum_address('0x63BC843b9640c4D79d6aE0105bc39F773172d121'), timestamp=Timestamp(1609301469), location=Location.SUSHISWAP, token0=EthereumToken('0x368B3a58B5f49392e5C9E4C998cb0bB966752E51'), token1=EthereumToken('0xdAC17F958D2ee523a2206206994597C13D831ec7'), amount0_in=AssetAmount(ZERO), amount1_in=AssetAmount(FVal('1936.810111')), amount0_out=AssetAmount(FVal('1.925851508322134245')), amount1_out=AssetAmount(ZERO), )], ), AMMTrade( trade_type=TradeType.BUY, base_asset=EthereumToken('0xdAC17F958D2ee523a2206206994597C13D831ec7'), quote_asset=EthereumToken('0x368B3a58B5f49392e5C9E4C998cb0bB966752E51'), amount=AssetAmount(FVal('951.611472')), rate=Price(FVal('0.001050849038104071952592013309')), trade_index=0, swaps=[AMMSwap( tx_hash='0xb3cea8179e8bc349661f265937187403ae4914c108d118889d026bac1fbec4e9', log_index=9, address=address, from_address=string_to_ethereum_address('0xd9e1cE17f2641f24aE83637ab66a2cca9C378B9F'), to_address=string_to_ethereum_address('0x63BC843b9640c4D79d6aE0105bc39F773172d121'), timestamp=Timestamp(1609296759), location=Location.SUSHISWAP, token0=EthereumToken('0x368B3a58B5f49392e5C9E4C998cb0bB966752E51'), token1=EthereumToken('0xdAC17F958D2ee523a2206206994597C13D831ec7'), amount0_in=AssetAmount(FVal('1')), amount1_in=AssetAmount(ZERO), amount0_out=AssetAmount(ZERO), amount1_out=AssetAmount(FVal('951.611472')), )], ), AMMTrade( trade_type=TradeType.BUY, base_asset=EthereumToken('0x368B3a58B5f49392e5C9E4C998cb0bB966752E51'), quote_asset=EthereumToken('0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48'), amount=AssetAmount(FVal('1')), rate=Price(FVal('511.20342')), trade_index=0, swaps=[AMMSwap( tx_hash='0x0ccec8fd15c8d3ab923ee4a2406778f22769e74da20b19a35e614bfead6bab8d', log_index=242, address=address, from_address=string_to_ethereum_address('0xd9e1cE17f2641f24aE83637ab66a2cca9C378B9F'), to_address=string_to_ethereum_address('0x06da0fd433C1A5d7a4faa01111c044910A184553'), timestamp=Timestamp(1609294923), location=Location.SUSHISWAP, token0=EthereumToken('0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48'), token1=EthereumToken('0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2'), amount0_in=AssetAmount(FVal('511.20342')), amount1_in=AssetAmount(ZERO), amount0_out=AssetAmount(ZERO), amount1_out=AssetAmount(FVal('0.690577933591789501')), ), AMMSwap( tx_hash='0x0ccec8fd15c8d3ab923ee4a2406778f22769e74da20b19a35e614bfead6bab8d', log_index=245, address=address, from_address=string_to_ethereum_address('0xd9e1cE17f2641f24aE83637ab66a2cca9C378B9F'), to_address=string_to_ethereum_address('0xC9cB53B48A2f3A9e75982685644c1870F1405CCb'), timestamp=Timestamp(1609294923), location=Location.SUSHISWAP, token0=EthereumToken('0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2'), token1=EthereumToken('0xdAC17F958D2ee523a2206206994597C13D831ec7'), amount0_in=AssetAmount(FVal('0.690577933591789501')), amount1_in=AssetAmount(ZERO), amount0_out=AssetAmount(ZERO), amount1_out=AssetAmount(FVal('506.399839')), ), AMMSwap( tx_hash='0x0ccec8fd15c8d3ab923ee4a2406778f22769e74da20b19a35e614bfead6bab8d', log_index=248, address=address, from_address=string_to_ethereum_address('0xd9e1cE17f2641f24aE83637ab66a2cca9C378B9F'), to_address=string_to_ethereum_address('0x63BC843b9640c4D79d6aE0105bc39F773172d121'), timestamp=Timestamp(1609294923), location=Location.SUSHISWAP, token0=EthereumToken('0x368B3a58B5f49392e5C9E4C998cb0bB966752E51'), token1=EthereumToken('0xdAC17F958D2ee523a2206206994597C13D831ec7'), amount0_in=AssetAmount(ZERO), amount1_in=AssetAmount(FVal('506.399839')), amount0_out=AssetAmount(FVal('1')), amount1_out=AssetAmount(ZERO), )], )]
TEST_ACCOUNTS = [ # For mint/redeem '0x2B888954421b424C5D3D9Ce9bB67c9bD47537d12', # For borrowing/liquidations '0xC440f3C87DC4B6843CABc413916220D4f4FeD117', # For mint/redeem + comp '0xF59D4937BF1305856C3a267bB07791507a3377Ee', # For repay '0x65304d6aff5096472519ca86a6a1fea31cb47Ced', ] EXPECTED_EVENTS = [ CompoundEvent( event_type='mint', address=string_to_ethereum_address( '0x2B888954421b424C5D3D9Ce9bB67c9bD47537d12'), block_number=9443573, timestamp=Timestamp(1581184577), asset=A_DAI, value=Balance(amount=FVal('2988.4343'), usd_value=FVal('3012.3417744')), to_asset=A_CDAI, to_value=Balance(amount=FVal('148015.6966153'), usd_value=FVal('3012.3417744')), realized_pnl=None, tx_hash= '0xacc2e21f911a4e438966694e9ad16747878a15dae52de62a09f1ebabc8b26c8d', log_index=130, ), CompoundEvent( event_type='redeem',
def addresses_to_decoders( self) -> Dict[ChecksumEthAddress, Tuple[Any, ...]]: return { string_to_ethereum_address('0x111111125434b319222CdBf8C261674aDB56F3ae'): (self.decode_action, ), # noqa: E501 }
from rotkehlchen.chain.ethereum.modules.adex.adex import Adex from rotkehlchen.chain.ethereum.modules.adex.types import TOM_POOL_ID from rotkehlchen.chain.ethereum.types import string_to_ethereum_address TEST_ADDR = string_to_ethereum_address('0x494B9728BECA6C03269c38Ed86179757F77Cc0dd') TEST_ADDR_USER_IDENTITY = string_to_ethereum_address('0xaC29E71ACA2ff1C121673f0FC9d47e7616F692Ae') # noqa: E501 def test_get_user_identity(): """Test our Python port of AdEX `getUserIdentity()` works as expected. AdEX `getUserIdentity()`: https://github.com/AdExNetwork/adex-staking/blob/master/src/helpers/identity.js#L12 """ contract_address = Adex._get_user_identity(address=TEST_ADDR) assert contract_address == TEST_ADDR_USER_IDENTITY def test_get_bond_id(): """Test our Python port of AdEX `getBondId()` calculates the expected bond id using the LogBond event data. Bond tx (origin of `owner`, `amount`, `pool_id` and `nonce`): 0x7944c10032e2a079d3f03ad57a90a93bde468b0baba84121be79790162215855 Unbond tx (claiming and re-staking), its log index 283 contains the expected bond id: 0xc59d65bc6c18e11a3650e8d7ec41a11f58016bbf843376c7f4cb0833402399f1 AdEX `getBondId()`: https://github.com/AdExNetwork/adex-staking/blob/master/src/helpers/bonds.js#L5