Skip to content

Properly handle beefy CLM vaults #10374

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

Merged
merged 1 commit into from
Aug 6, 2025
Merged

Conversation

nicholasyoder
Copy link
Contributor

Closes https://github.com/orgs/rotki/projects/11/views/3?pane=issue&itemId=122546245

Unfortunately the beefy docs on this don't get very technical, so the approach here is based on what was said in a discussion in the beefy discord.

@nicholasyoder nicholasyoder marked this pull request as ready for review August 5, 2025 12:02
get_or_create_evm_token(
userdb=database,
evm_address=deserialize_evm_address(vault['earnedTokenAddress']),
evm_address=deserialize_evm_address(vault['earnContractAddress']),
Copy link
Contributor

Choose a reason for hiding this comment

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

they're not always the same address?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think they are always the same address when both are present, but for some types of vaults the earnedTokenAddress key is missing. earnContractAddress however seems to be present for all vaults.

Copy link
Contributor

Choose a reason for hiding this comment

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

i think you should add this as a comment also.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

added a comment mentioning that earnContractAddress is present for all vaults. I don't think it would really make sense to mention earnedTokenAddress in the comment though - future readers of the code will not be aware that that is even a key that may be present since we aren't using it anywhere.

return ZERO_PRICE

usd_price = ZERO
for underlying_token, amount in zip(vault_token.underlying_tokens, response, strict=False):
Copy link
Contributor

Choose a reason for hiding this comment

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

is the order guaranteed to be the same?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

hmm... I expect it would be (the underlying tokens are added in the order used in the API which should be the same) - but this does seem a bit risky - the underlying token order could get changed in the db I suppose or the order in the api could be off in some cases.

Changed this to instead pull the token addresses directly from the clm contract where they are guaranteed to be in the correct order. This also avoids needing to set underlying tokens for the clm cow tokens.

chain_id=evm_inquirer.chain_id,
)) is None:
log.error(
f'Unexpected underlying token {underlying_token} for '
Copy link
Contributor

Choose a reason for hiding this comment

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

i think this log message is wrong.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

hmm... so actually I guess I should probably use get_or_create_evm_token here - changed this and the log message.

get_or_create_evm_token(
userdb=database,
evm_address=deserialize_evm_address(vault['earnedTokenAddress']),
evm_address=deserialize_evm_address(vault['earnContractAddress']),
Copy link
Contributor

Choose a reason for hiding this comment

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

i think you should add this as a comment also.

@prettyirrelevant prettyirrelevant added the ready for final review Backend PR ready to be reviewed by great Lefteris label Aug 5, 2025
method_name='previewWithdraw',
arguments=[single_share_raw_amount],
)
else:
Copy link
Member

Choose a reason for hiding this comment

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

is this else an error? If yes please log it as such.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yes, its an error - but since it sets the addresses and amounts to empty tuples this triggers the if below where it logs an error about an unexpected number of tokens & amounts. This way in both the case of this else, and the case where len(call_output) == 2 but the number of items in the call_output entries are off are both handled without needing separate log.errors.

Added a comment mentioning that it triggers the if below with an error logged there.

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 e8bfac2 into rotki:develop Aug 6, 2025
28 of 31 checks passed
@rotkibot
Copy link

rotkibot commented Aug 6, 2025

rotki/test-caching#217 was successfully merged

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ready for final review Backend PR ready to be reviewed by great Lefteris
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants