You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
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.
The text was updated successfully, but these errors were encountered:
cleanunicorn
changed the title
claimShares should send tokens only if there something to transferclaimShares should send tokens only if there something to transfer
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.
The text was updated successfully, but these errors were encountered: