Conversation
|
|
||
| //If the WETH balance is non-zero we'll initiate a swap. | ||
| if(wethCheck != 0){ | ||
| _sellRewards(); |
There was a problem hiding this comment.
don't initiate a swap here. Transfer weth to the new strat.
|
|
||
| //If there is no debt outstanding, deposit all looks back into contract and report back profit | ||
| emit debtOutstandingEvent(_debtOutstanding); | ||
| if(_debtOutstanding == 0){ |
There was a problem hiding this comment.
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){ |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
In this method I would do the following:
- sellRewards if there are any.
- calculate profit = estimatedAssets()-uint256 vaultDebt = vault.strategies(address(this)).totalDebt;
- call liquidatePosition(profit)
- 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(); |
No description provided.