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

feat: use allocator #30

Merged
merged 35 commits into from
Jan 9, 2024
Merged

feat: use allocator #30

merged 35 commits into from
Jan 9, 2024

Conversation

Schlagonia
Copy link
Collaborator

No description provided.

@Schlagonia Schlagonia changed the base branch from yield-manager to master December 19, 2023 04:39
@fp-crypto
Copy link
Collaborator

Any reason the tests are failing?

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.

Initial review

event AddedNewVault(
address indexed vault,
address indexed debtAllocator,
uint256 rating
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is rating there for the future or is it used?

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 would be used once this is deployed, both for naming conventions as well as on chain tracking.

Also for future use by a strategy manager contract to potentially compare rating before adding certain strategies.

/// @notice The minimum amount denominated in asset that will
// need to be moved to trigger a debt update.
uint256 public minimumChange;

/// @notice Time to wait between debt updates.
uint256 public minimumWait;
Copy link
Collaborator

Choose a reason for hiding this comment

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

was this removed so that a timelock could be used instead?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

No it was just moved up above 'minimumChange` for formatting looks.

@@ -82,13 +82,13 @@ contract GenericDebtAllocator is Governance {
// Can't be more than 10_000.
uint256 public debtRatio;

/// @notice Time to wait between debt updates.
uint256 public minimumWait;

/// @notice The minimum amount denominated in asset that will
// need to be moved to trigger a debt update.
uint256 public minimumChange;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Probably worth noting which units this uses (e.g. nominal, bps, percent)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

* @param _strategy The address of the strategy.
*/
function addNewStrategy(address _strategy) external virtual onlyGovernance {
address currentManager = IStrategy(_strategy).management();
Copy link
Collaborator

Choose a reason for hiding this comment

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

currentManager could be moved down in this function to save gas on reverts

Copy link
Collaborator Author

Choose a reason for hiding this comment

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


/// @notice Contract that holds the logic and oracles for each strategy.
AprOracle internal constant aprOracle =
AprOracle(0xF012fBb9283e03994A7829fCE994a105cC066c14);
Copy link
Collaborator

Choose a reason for hiding this comment

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

Any reason this is a hardcoded address?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Its one of the few contracts i am confident in that wont need to change.

* and debt increases at the end.
*
* It is expected that the proposer does all needed checks for values such
* as max_debt, maxWithdraw, min total Idle etc. that are enforced on debt
Copy link
Collaborator

Choose a reason for hiding this comment

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

"max_debt, maxWithdraw, min total Idle etc." this is like 3 different inconsistent formats

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

updated it to make a little more clear fc3b236

Still snake case for the vault stuff though

_accountedFor += _currentDebt;

// Get the current weighted APR the strategy is earning
uint256 _strategyApr = (aprOracle.getStrategyApr(_strategy, 0) *
Copy link
Collaborator

Choose a reason for hiding this comment

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

not really apr, but i'll give you a pass

Copy link
Collaborator

Choose a reason for hiding this comment

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

question, what units is getStrategyApr in? I guess we don't care about the units here, but if we wanted it to be in token terms, we would need to divide by the apr units.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

its denominated in 1e18 for every vault

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Updated all the comments and variables to use "rate" instead of APR or yield fc3b236

if (_currentDebt > _newDebt) {
// If we are pulling all debt from a strategy.
if (_newDebt == 0) {
// We need to report profits and have them immediately unlock to not lose out on locked profit.
Copy link
Collaborator

Choose a reason for hiding this comment

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

🤢

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Updated it be a bit more accurate for not immediately unlocking fc3b236

_afterYield += (aprOracle.getStrategyApr(
_strategy,
int256(_newDebt) - int256(_currentDebt)
) * _newDebt);
Copy link
Collaborator

Choose a reason for hiding this comment

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

same as on L144-145

}

// Make sure the ending amounts are the same otherwise rates could be wrong.
require(_totalAssets == _accountedFor, "cheater");
Copy link
Collaborator

Choose a reason for hiding this comment

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

Might be worth adding some dev messages // dev: wtf

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 "cheater" is unique enogh to find out where its reverting

@Schlagonia
Copy link
Collaborator Author

also added max withdraw, max deposit and min idle checks into the allocations fc3b236

@Schlagonia Schlagonia merged commit bd7c8c4 into master Jan 9, 2024
4 checks passed
@Schlagonia Schlagonia deleted the use_allocator branch January 9, 2024 01:38
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.

2 participants