Skip to content

V4 revised#5

Open
OpenOrg-gg wants to merge 2 commits intomasterfrom
v4-revised
Open

V4 revised#5
OpenOrg-gg wants to merge 2 commits intomasterfrom
v4-revised

Conversation

@OpenOrg-gg
Copy link
Copy Markdown
Owner

No description provided.


//If the WETH balance is non-zero we'll initiate a swap.
if(wethCheck != 0){
_sellRewards();
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

don't initiate a swap here. Transfer weth to the new strat.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Did you change this?


//If there is no debt outstanding, deposit all looks back into contract and report back profit
emit debtOutstandingEvent(_debtOutstanding);
if(_debtOutstanding == 0){
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

uint256 finalProfit = LOOKSprofit.sub(vaultDebt); -> this line can result in a negative value. Should consider possibility loss. I've read your comment and makes sense but should handle that case also.

emit debtOutstandingEvent(_debtOutstanding);
if(_debtOutstanding == 0){
return(finalProfit,0,0);
if(finalProfit < _debtOutstanding){
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

there is a scenario where finalProfit != balanceOfWant() right? Basically this function withdrawProfitOrFloor(finalProfit); doesn't necessarily guarantee that finalProfit == balanceOfWant(). So, checking finalProfit vs debtOutstanding might not be correct, given that you could have more finalProfit than BalanceOfWant, and if finalProfit >= _debtOutstanding and finalProfit < base, you will end up telling the vault that there is want that can be withdraw, and it's not the case.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

In this method I would do the following:

  1. sellRewards if there are any.
  2. calculate profit = estimatedAssets()-uint256 vaultDebt = vault.strategies(address(this)).totalDebt;
  3. call liquidatePosition(profit)
  4. liquidatePosition will return a liquidatedAmount and a loss. Then you can see if you have a profit, a loss and how much to return.

Let me know if this makes sense


//If the WETH balance is non-zero we'll initiate a swap.
if(wethCheck != 0){
_sellRewards();
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Did you change this?

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