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

claimShares should send tokens only if there something to transfer #5

Open
cleanunicorn opened this issue Jul 27, 2021 · 0 comments
Open

Comments

@cleanunicorn
Copy link
Member

cleanunicorn commented Jul 27, 2021

Description

A user can call registerDeposit when the vault is locked to add their own funds for the next investment round.

After enough time passes and the round is closed, by calling closePositions, the user can come back to the contract to retrieve their locked funds, along with the realized yields.

In order to do this, they need to call claimShares.

The method calculates how many tokens they should have received, in case they were to join when the vault was unlocked and transfers those tokens to the depositor.

The calculated value can be zero, either in case the depositor never added tokens, or the depositor already claimed their tokens. However, the transfer happens either way, for 0 tokens or for a positive value of tokens.

https://github.com/monoceros-alpha/review-opyn-perp-vault-templates-2021-07/blob/518e4f6d174cae6ee75e316ad56789aaeb695069/code/contracts/core/OpynPerpVault.sol#L268-L271

Recommendation

It might help users (from a UX point of view) and the contract to only send tokens when there are tokens to send. Consider transferring only if there is a positive amount to be sent.

This will reduce the number of events the contract emits, and the user knows before committing the transaction if they will receive tokens or not.

@cleanunicorn cleanunicorn changed the title claimShares should send tokens only if there something to transfer claimShares should send tokens only if there something to transfer Jul 27, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant