Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(WETH): Add decoder for all supported EVM chains #7708

Merged
merged 3 commits into from Apr 12, 2024

Conversation

iRhonin
Copy link
Contributor

@iRhonin iRhonin commented Apr 5, 2024

This PR adds builtin WETH decoder for all supported EVM chains except Gnosis and Polygon PoS.

SqlDiff:

INSERT INTO assets(rowid,identifier,name,type) VALUES(6841,'eip155:534352/erc20:0x5300000000000000000000000000000000000004','Wrapped Ether','C');
INSERT INTO common_asset_details(rowid,identifier,symbol,coingecko,cryptocompare,forked,started,swapped_for) VALUES(6841,'eip155:534352/erc20:0x5300000000000000000000000000000000000004','WETH','weth','weth',NULL,1696960800,NULL);
INSERT INTO evm_tokens(rowid,identifier,token_kind,chain,address,decimals,protocol) VALUES(5909,'eip155:534352/erc20:0x5300000000000000000000000000000000000004','A',534352,'0x5300000000000000000000000000000000000004',18,NULL);
INSERT INTO multiasset_mappings(rowid,collection_id,asset) VALUES(677,38,'eip155:534352/erc20:0x5300000000000000000000000000000000000004');

@CLAassistant
Copy link

CLAassistant commented Apr 5, 2024

CLA assistant check
All committers have signed the CLA.

Copy link
Member

@yabirgb yabirgb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You forgot to add the changelog entry in docs/changelog.rst

rotkehlchen/chain/evm/decoding/weth/constants.py Outdated Show resolved Hide resolved
rotkehlchen/tests/unit/decoders/test_weth.py Outdated Show resolved Hide resolved
rotkehlchen/chain/evm/decoding/decoder.py Outdated Show resolved Hide resolved
rotkehlchen/chain/evm/decoding/weth/constants.py Outdated Show resolved Hide resolved
rotkehlchen/chain/evm/decoding/weth/constants.py Outdated Show resolved Hide resolved
rotkehlchen/chain/evm/decoding/weth/constants.py Outdated Show resolved Hide resolved
rotkehlchen/chain/evm/decoding/weth/constants.py Outdated Show resolved Hide resolved
rotkehlchen/chain/evm/decoding/weth/decoder.py Outdated Show resolved Hide resolved
rotkehlchen/chain/evm/decoding/weth/decoder.py Outdated Show resolved Hide resolved
rotkehlchen/chain/evm/decoding/weth/decoder.py Outdated Show resolved Hide resolved
@iRhonin iRhonin added the PR review work work on PR review comments label Apr 5, 2024
@iRhonin iRhonin force-pushed the feat/weth-evm-decoder branch 5 times, most recently from b7337a8 to 90af540 Compare April 8, 2024 08:19
Copy link

codecov bot commented Apr 8, 2024

Codecov Report

Attention: Patch coverage is 91.83673% with 8 lines in your changes are missing coverage. Please review.

Project coverage is 77.32%. Comparing base (511ee93) to head (c5d3444).
Report is 3 commits behind head on develop.

Files Patch % Lines
rotkehlchen/chain/scroll/modules/weth/decoder.py 90.56% 3 Missing and 2 partials ⚠️
...ehlchen/chain/arbitrum_one/modules/weth/decoder.py 85.71% 1 Missing and 1 partial ⚠️
...hlchen/chain/polygon_pos/modules/wmatic/decoder.py 80.00% 1 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #7708      +/-   ##
===========================================
- Coverage    77.74%   77.32%   -0.42%     
===========================================
  Files          949      952       +3     
  Lines        63400    63437      +37     
  Branches     11183    11187       +4     
===========================================
- Hits         49288    49054     -234     
- Misses       11919    12174     +255     
- Partials      2193     2209      +16     
Flag Coverage Δ
backend 80.51% <91.83%> (-0.54%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

rotkehlchen/tests/unit/decoders/test_weth.py Outdated Show resolved Hide resolved
rotkehlchen/tests/unit/decoders/test_weth.py Outdated Show resolved Hide resolved
rotkehlchen/tests/unit/decoders/test_weth.py Outdated Show resolved Hide resolved
rotkehlchen/chain/evm/decoding/weth/decoder.py Outdated Show resolved Hide resolved
Comment on lines 635 to 637
balance=Balance(amount=FVal('0.000001897927938075')),
location_label='0x81aa5101D4c376cd6DC031EA62D7b64A9BAE10a0',
notes='Burned 0.000001897927938075 ETH for gas',
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To avoid repeating the values in balance and notes check what we do here

deposit_amount, gas_fees = '99503', '0.007154122119159412'
. Do a similar thing in the tests on this file

rotkehlchen/chain/evm/decoding/weth/decoder.py Outdated Show resolved Hide resolved
@iRhonin iRhonin force-pushed the feat/weth-evm-decoder branch 2 times, most recently from b45ffc6 to 232d90b Compare April 8, 2024 14:07
@yabirgb yabirgb force-pushed the feat/weth-evm-decoder branch 3 times, most recently from a1ec89c to dc55616 Compare April 11, 2024 12:34
@@ -3,6 +3,7 @@ Changelog
=========

* :feature:`-` rotki will now properly decode the transactions for bridging to and from Scroll.
* :feature:`7708` rotki now properly decode WETH transactions on all supported EVM chains with native ETH
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems this does not do it for non-native, but I would just add the changelog when it is all done. And not 1 changelog per entry.

Suggested change
* :feature:`7708` rotki now properly decode WETH transactions on all supported EVM chains with native ETH
* :feature:`7708` rotki now properly decodes all native to/from wrapped token transactions (e.g. ETH<->WETH, Matic<->WMatic) on all supported EVM chains

rotkehlchen/chain/evm/decoding/weth/constants.py Outdated Show resolved Hide resolved
rotkehlchen/chain/evm/decoding/weth/constants.py Outdated Show resolved Hide resolved
rotkehlchen/chain/evm/decoding/weth/decoder.py Outdated Show resolved Hide resolved
rotkehlchen/chain/evm/decoding/weth/decoder.py Outdated Show resolved Hide resolved
rotkehlchen/chain/evm/decoding/weth/decoder.py Outdated Show resolved Hide resolved
rotkehlchen/tests/unit/decoders/test_aave_v2.py Outdated Show resolved Hide resolved
rotkehlchen/tests/unit/decoders/test_aave_v2.py Outdated Show resolved Hide resolved
rotkehlchen/tests/unit/decoders/test_aave_v2.py Outdated Show resolved Hide resolved
rotkehlchen/tests/unit/decoders/test_aave_v2.py Outdated Show resolved Hide resolved
Copy link
Member

@LefterisJP LefterisJP left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Left some comments.

Also test_balancer_v1_join that failed was a remote error. We can VCR in another PR. Do not mix here

rotkehlchen/chain/arbitrum_one/modules/weth/decoder.py Outdated Show resolved Hide resolved
rotkehlchen/chain/evm/decoding/weth/decoder.py Outdated Show resolved Hide resolved
rotkehlchen/chain/polygon_pos/modules/wmatic/decoder.py Outdated Show resolved Hide resolved
rotkehlchen/chain/polygon_pos/modules/wmatic/decoder.py Outdated Show resolved Hide resolved
rotkehlchen/tests/unit/decoders/test_weth.py Outdated Show resolved Hide resolved

@pytest.mark.vcr()
@pytest.mark.parametrize('base_accounts', [['0xf396e7dbb20489D47F2daBfDA013163223B892a0']])
def test_weth_deposit_base(database, base_inquirer):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you already did them but there is no need to tests every case for every chain if they are just repeating the logic across other evm chains.

Just 1 test per chain if other cases are repeating.

rotkehlchen/tests/unit/decoders/test_weth.py Outdated Show resolved Hide resolved
rotkehlchen/tests/unit/decoders/test_weth.py Outdated Show resolved Hide resolved
rotkehlchen/tests/unit/decoders/test_weth.py Outdated Show resolved Hide resolved
@yabirgb yabirgb force-pushed the feat/weth-evm-decoder branch 3 times, most recently from 3cabc20 to 0bab26c Compare April 12, 2024 10:39
rotkehlchen/chain/scroll/modules/weth/decoder.py Outdated Show resolved Hide resolved
rotkehlchen/chain/scroll/modules/weth/decoder.py Outdated Show resolved Hide resolved
rotkehlchen/chain/scroll/modules/weth/decoder.py Outdated Show resolved Hide resolved
rotkehlchen/chain/scroll/modules/weth/decoder.py Outdated Show resolved Hide resolved
rotkehlchen/chain/scroll/modules/weth/decoder.py Outdated Show resolved Hide resolved
rotkehlchen/chain/scroll/modules/weth/decoder.py Outdated Show resolved Hide resolved
event.balance.amount == deposited_amount and
event.asset == self.base_asset
):
if event.address == depositor:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not done yet

rotkehlchen/tests/unit/decoders/test_weth.py Outdated Show resolved Hide resolved
Copy link
Member

@LefterisJP LefterisJP left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@LefterisJP LefterisJP merged commit 53e64a3 into rotki:develop Apr 12, 2024
13 checks passed
Copy link

gitpoap-bot bot commented Apr 12, 2024

Congrats, your important contribution to this open-source project has earned you a GitPOAP!

GitPOAP: 2024 rotki Contributor:

GitPOAP: 2024 rotki Contributor GitPOAP Badge

Head to gitpoap.io & connect your GitHub account to mint!

Learn more about GitPOAPs here.

@rotkibot
Copy link

rotki/test-caching/tree/feat/weth-evm-decoder was successfully merged

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
PR review work work on PR review comments
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants