-
Notifications
You must be signed in to change notification settings - Fork 1
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
add caviar staking strategy #28
Conversation
address[] memory rewardTokens_ = new address[](1); | ||
|
||
// caviarChef shows rewards in wUSDR but harvest returns USDR need to override | ||
rewardTokens_[0] = USDR_TOKEN; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@belbix Here is a caveat. According to the CAVIAR_CHEF there is an only one reward token - wURSD, but harvest sends USDR and CAVIAR tokens. I decided to use only USDR as reward token. Not sure if it is correct.
// ******************************************************* | ||
|
||
/// @dev Set new reward tokens | ||
function setRewardTokens(address[] memory rts) external restricted { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I decided to include this method since Tangible is famous for upgrading it's tokens USDR is v3. There is a high probability that reward tokens will be updated.
// so we need to store CAVIAR balance before harvest and send this value to the "_liquidateRewards" method. | ||
CAVIAR_CHEF.harvest(address(this)); | ||
} | ||
_liquidateRewards(silently, undBalanceBefore); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do we need liquidate if no tokens? better to move this into the if statement
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In case of withdrawAndClaimFromPool we are calling CAVIAR_CHEF.withdrawAndHarvest, we will have rewards which needs to be liquidated.
pendingReward = reward; | ||
} catch {} | ||
|
||
uint undBalanceBefore = IERC20(_underlying()).balanceOf(address(this)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why do you need this here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We need to store amount of underlying (CAVIAR) before harvest to liquidate only harvested CAVIAR tokens.
uint toCompound = amount * (_BUY_BACK_DENOMINATOR - bbRatio) / _BUY_BACK_DENOMINATOR; | ||
uint toGov = amount - toCompound; | ||
if (toCompound != 0) { | ||
_liquidate(rt, _underlying(), toCompound, silently); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
read slots in a loop not so good
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
} | ||
} | ||
|
||
uint undBalance = IERC20(_underlying()).balanceOf(address(this)) - undBalBeforeHarvest; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
reuse underlying
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
} | ||
|
||
//slither-disable-next-line unused-state | ||
uint256[45] private ______gap; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use 50 - count of variables (it's zero here)
e63c095
to
e0deb5d
Compare
4065b83
to
0184c5e
Compare
No description provided.