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
Decode Liquidity additions & removal for Uniswap(V2 & V3) & Sushiswap #5337
Decode Liquidity additions & removal for Uniswap(V2 & V3) & Sushiswap #5337
Conversation
25be8e7
to
378d030
Compare
Codecov Report
@@ Coverage Diff @@
## develop #5337 +/- ##
===========================================
- Coverage 71.45% 71.07% -0.39%
===========================================
Files 988 1005 +17
Lines 74172 74916 +744
Branches 9156 9238 +82
===========================================
+ Hits 53001 53247 +246
- Misses 19566 20027 +461
- Partials 1605 1642 +37
Flags with carried forward coverage won't be shown. Click here to find out more.
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. |
to_notes=notes.format(amount, asset.symbol, counterparty, pool_address), | ||
to_counterparty=counterparty, | ||
) | ||
action_items.append(action_item) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This approach might be frowned upon because I'm directly mutating action_items
.
However, this is quite unavoidable because the other decoding method that supports returning a list of ActionItem
requires key-value pair of addresses to a decoder function.
The above won't work as we don't keep a store of all UNISWAP lp tokens. We store the ones users encounter, but this would mean that users have to manually re-decode transactions. Terrible UX.
Another option would be to create a new method in DecoderInterface
for this use case.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have been checking and I believe it would be better to allow returning events from here. The problem with mutating the action_items
list here is that you introduce unexpected behavior in some of the decoders and this will surely be an issue in the future.
This decoding methods are executed here if I'm correct
event = self.try_all_rules( |
if you read that function the rules by address returns both events and new action items and then the list of action items is extended in that place. Is for that why I say that mutating here introduces unexpected behavior.
My idea would be that, return both event and new action items and extend in the same way. It shouldn't be a difficult change since we have few of these decoders. What do you think?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks Isaac. Left you some comments and things to improve
to_notes=notes.format(amount, asset.symbol, counterparty, pool_address), | ||
to_counterparty=counterparty, | ||
) | ||
action_items.append(action_item) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have been checking and I believe it would be better to allow returning events from here. The problem with mutating the action_items
list here is that you introduce unexpected behavior in some of the decoders and this will surely be an issue in the future.
This decoding methods are executed here if I'm correct
event = self.try_all_rules( |
if you read that function the rules by address returns both events and new action items and then the list of action items is extended in that place. Is for that why I say that mutating here introduces unexpected behavior.
My idea would be that, return both event and new action items and extend in the same way. It shouldn't be a difficult change since we have few of these decoders. What do you think?
12e4596
to
c3d1b03
Compare
c3d1b03
to
6cc167f
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just two small comments but can be addressed later
ADDY = '0xb63e0C506dDBa7b0dd106d1937d6D13BE2C62aE2' | ||
ADDY_2 = '0xeB312F4921aEbbE99faCaCFE92f22b942Cbd7599' | ||
ADDY_3 = '0xdD84Ce1aDcb3A4908Db61A1dFA3353C3974c5a2B' | ||
ADDY_4 = '0x354304234329A8d2425965C647e701A72d3438e5' | ||
ADDY_5 = '0xa931b486F661540c6D709aE6DfC8BcEF347ea437' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Those should have string_to_evm_address
calls but since we are not checking types is fine
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Still do it please @prettyirrelevant
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Left some comments
get_tx_event_type_identifier(HistoryEventType.RECEIVE, HistoryEventSubType.RECEIVE_WRAPPED, CPT_UNISWAP_V2): TxEventSettings( # noqa: E501 | ||
taxable=False, | ||
count_entire_amount_spend=False, | ||
count_cost_basis_pnl=False, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
here and in all the others why do you count cost basis pnl as False? Doesn't this determine asset spends and counts how much of something you have at any point? Are you not making this for all uniswa/sushiswap pools deposit/withdrawals? Taxable or not the spends should be counted.
Please understand what these are and what they do. Same thing for the reviewer @yabirgb.
Don't just blindly copy paste shit around.
Sidenote: We need tests for these as stated here: #5260
ALL of these accountants should have tests, otherwise you guys are throwing shit at the wall and hope it sticks.
Sidenote2: Need to abstract all those better. We copy too much stuff around to create these accounting rules. Probably there is a better way ... but need to think about it.
Won't leave the same comment in the other accountants. Please understand it applies there too though
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Quite frankly, in as much as the argument names are pretty descriptive, it's still quite difficult to get the hang of how to combine the arguments to suit different types of transactions.
This comment helped though, thanks.
for token, amount in zip(liquidity_pool_position_info[2:4], (amount0_raw, amount1_raw)): | ||
token_with_data: 'CryptoAsset' = get_or_create_evm_token( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I also think this needs refactoring here. I get that it looks and reads nice, but we should not sacrifice speed for readability to such an extent. I was gonna try and come up with a nice alternative but it's more tricky than what I can do at 01:30 at night.
So please think on this a bit and try to find a way to have this read as nicely as this does but also not iterate the events twice.
ADDY = '0xb63e0C506dDBa7b0dd106d1937d6D13BE2C62aE2' | ||
ADDY_2 = '0xeB312F4921aEbbE99faCaCFE92f22b942Cbd7599' | ||
ADDY_3 = '0xdD84Ce1aDcb3A4908Db61A1dFA3353C3974c5a2B' | ||
ADDY_4 = '0x354304234329A8d2425965C647e701A72d3438e5' | ||
ADDY_5 = '0xa931b486F661540c6D709aE6DfC8BcEF347ea437' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Still do it please @prettyirrelevant
6cc167f
to
045e821
Compare
045e821
to
f9065a8
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. Will merge though I left 2 smaller comments.
IT's too big to leave it out.
@pytest.mark.parametrize('ethereum_accounts', [[ADDY_2]]) | ||
def test_sushiswap_v2_remove_liquidity(database, ethereum_inquirer, eth_transactions): | ||
""" | ||
This checks that removing liquidity to Sushiswap V2 pool is decoded properly. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This checks that removing liquidity to Sushiswap V2 pool is decoded properly. | |
This checks that removing liquidity from a Sushiswap V2 pool is decoded properly. |
Congrats, your important contribution to this open-source project has earned you a GitPOAP! GitPOAP: 2023 rotki Contributor: Head to gitpoap.io & connect your GitHub account to mint! Learn more about GitPOAPs here. |
Checklist