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

fix: buy debt and role addition #177

Merged
merged 8 commits into from
Oct 2, 2023
Merged

Conversation

Schlagonia
Copy link
Collaborator

@Schlagonia Schlagonia commented Aug 24, 2023

Description

  • buy debt based on the current_debt not relying on strategy conversion rates
  • Add an add_role and remove_role option for setting roles.

Fixes # (issue)

Checklist

  • I have run vyper and solidity linting
  • I have run the tests on my machine
  • I have followed commitlint guidelines
  • I have rebased my changes to the latest version of the main branch

@@ -580,7 +580,7 @@ def _deposit(sender: address, recipient: address, assets: uint256) -> uint256:
# Issue the corresponding shares for assets.
shares: uint256 = self._issue_shares_for_amount(assets, recipient)

assert shares > 0, "cannot mint zero"
assert shares > 0, "ZERO_SHARES"
Copy link
Contributor

Choose a reason for hiding this comment

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

why? this seems to be less useful error msg

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

It was to try and make the error messages conform to more normal ones used across other vaults/ Erc 20 contracts.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

perhaps we want it to be different though

Copy link
Collaborator

@fp-crypto fp-crypto Oct 2, 2023

Choose a reason for hiding this comment

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

i will say i would prefer we stuck with either cannot or can't 😉

@@ -597,8 +597,8 @@ def _mint(sender: address, recipient: address, shares: uint256) -> uint256:

assets: uint256 = self._convert_to_assets(shares, Rounding.ROUND_UP)

assert assets > 0, "cannot mint zero"
assert self._total_assets() + assets <= self.deposit_limit, "exceed deposit limit"
assert assets > 0, "ZERO_ASSETS"
Copy link
Contributor

Choose a reason for hiding this comment

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

same, less useful error message

contracts/VaultV3.vy Outdated Show resolved Hide resolved
"""
assert msg.sender == self.role_manager
self.roles[account] = role

log RoleSet(account, role)

@external
def add_role(account: address, role: Roles):
Copy link
Contributor

Choose a reason for hiding this comment

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

should this and remove_role to be the only way to set roles? seems less error prone

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I think given the number of Roles the vault has, we want to keep the set_role function.

For something like yChad you want to give all the roles to. I dont want to have to loop through each one calling add_role

contracts/VaultV3.vy Outdated Show resolved Hide resolved
# We get the proportion of the debt that is being bought and
# transfer the equivalant shares. We assume this is being used
# due to strategy issues so won't rely on its conversion rates.
shares: uint256 = IStrategy(strategy).balanceOf(self) * _amount / current_debt
Copy link
Contributor

Choose a reason for hiding this comment

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

why would you allow partial debt buy? if the only situation is when there's an issue with the strat, it should be 100% sold, no?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

If governance either doesnt have enough funds, or desire to buy the whole position.

For example debt is 10m but governance is only gonna but 2m cause it doesnt have more.

Copy link
Collaborator

Choose a reason for hiding this comment

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

i agree a partial buy could be useful

@fp-crypto
Copy link
Collaborator

Given the immunefi report received, i've been wondering if there is a reason to overpay for debt. For example, a strategy has a loss that is reported to the vault, governance decides it wants to buy the debt and cover the loss. Would it make sense to over pay for the debt or to donate to the strategy and run through a reporting cycle first?

@Schlagonia
Copy link
Collaborator Author

Schlagonia commented Sep 22, 2023

Given the immunefi report received, i've been wondering if there is a reason to overpay for debt. For example, a strategy has a loss that is reported to the vault, governance decides it wants to buy the debt and cover the loss. Would it make sense to over pay for the debt or to donate to the strategy and run through a reporting cycle first?

I think the better way to do it this is either through the accountant with refunds or buy the debt then add a strategy that has funds donated to it and report the donation profit that way.

If debt is being purchased i would imagine we dont want to do any more reporting for that strategy.

@fp-crypto
Copy link
Collaborator

@Schlagonia rename PR plz

@Schlagonia Schlagonia changed the title build: updates fix: buy debt and role addition Oct 2, 2023
@fp-crypto
Copy link
Collaborator

Generally LGTM, although i think combining the buy debt changes and error messages makes this somewhat harder to merge cleanly. Not to create extra busywork, but maybe break out the revert message changes so we can discuss elsewhere?

@Schlagonia
Copy link
Collaborator Author

Schlagonia commented Oct 2, 2023

Generally LGTM, although i think combining the buy debt changes and error messages makes this somewhat harder to merge cleanly. Not to create extra busywork, but maybe break out the revert message changes so we can discuss elsewhere?

Okay changed the error messages back to the original ones
f68ed1f
e582f0f

I will consider adding the deposit limit ones to the withdraw limits module PR since that is where they are relevant.

Copy link
Collaborator

@fp-crypto fp-crypto left a comment

Choose a reason for hiding this comment

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

LGTM

@Schlagonia Schlagonia merged commit 5632f70 into yearn:master Oct 2, 2023
7 checks passed
@Schlagonia Schlagonia deleted the misc-updates branch October 2, 2023 21:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants