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

add caviar staking strategy #28

Merged
merged 4 commits into from
Sep 5, 2023
Merged

add caviar staking strategy #28

merged 4 commits into from
Sep 5, 2023

Conversation

AlehNat
Copy link
Contributor

@AlehNat AlehNat commented Aug 29, 2023

No description provided.

address[] memory rewardTokens_ = new address[](1);

// caviarChef shows rewards in wUSDR but harvest returns USDR need to override
rewardTokens_[0] = USDR_TOKEN;
Copy link
Contributor Author

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 {
Copy link
Contributor Author

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);
Copy link
Member

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

Copy link
Contributor Author

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));
Copy link
Member

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?

Copy link
Contributor Author

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);
Copy link
Member

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

Copy link
Contributor Author

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;
Copy link
Member

Choose a reason for hiding this comment

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

reuse underlying

Copy link
Contributor Author

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;
Copy link
Member

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)

@belbix belbix merged commit da742e5 into dev Sep 5, 2023
1 check failed
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