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

IAction.rolloverPosition and IAction.closePosition are not always called together as part round lifecycle #11

Open
andreiashu opened this issue Jul 30, 2021 · 0 comments

Comments

@andreiashu
Copy link
Member

andreiashu commented Jul 30, 2021

Description

When a round is started, the Vault owner will call rollOver function, which in turn calls _distribute. The IAction.rolloverPosition is called only if the percentage allocation amount is non-zero:

https://github.com/monoceros-alpha/review-opyn-perp-vault-templates-2021-07/blob/d94fcb2e2173008272604705a9fc618710349462/code/contracts/core/OpynPerpVault.sol#L447-L450

When a round is closed, the IAction.closePosition function is always called:

https://github.com/monoceros-alpha/review-opyn-perp-vault-templates-2021-07/blob/d94fcb2e2173008272604705a9fc618710349462/code/contracts/core/OpynPerpVault.sol#L419-L422

Upon rollover round, the state in the action is updated:

https://github.com/monoceros-alpha/review-opyn-perp-vault-templates-2021-07/blob/d94fcb2e2173008272604705a9fc618710349462/code/contracts/utils/RollOverBase.sol#L64-L70

And the close position step is dependent on this state in order to correctly function:

https://github.com/monoceros-alpha/review-opyn-perp-vault-templates-2021-07/blob/d94fcb2e2173008272604705a9fc618710349462/code/contracts/example-actions/ShortOToken.sol#L234-L238

Recommendation

While we have yet to find a specific issue with the code under review, we believe that as a design decision, the system should always call IAction.rolloverPosition and IAction.closePosition in tandem.

In the case above, either always call IAction.rolloverPosition regardless of the allocation percentage for the action or add code in _closeAndWithdraw function to only call IAction.closePosition if the action's balance is non-zero.

@andreiashu andreiashu changed the title IAction.rolloverPosition and IAction.closePosition are not always called together as part of a round IAction.rolloverPosition and IAction.closePosition are not always called together as part round lifecycle Jul 30, 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