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

Calculate additional bounties #24

Merged
merged 1 commit into from
Feb 13, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions contracts/FeeOnlyBounty.sol
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,15 @@ contract FeeOnlyBounty is Owned, IRevoBounty {
}
}

function calculateAdditionalBountyFee(TokenAmount[] memory _interestAccrued)
external
view
override
returns (TokenAmount[] memory output)
{
return new TokenAmount[](0); // intentionally returns empty list
}

function calculateBountyFee(TokenAmount[] memory _interestAccrued)
external
view
Expand Down
5 changes: 5 additions & 0 deletions contracts/IRevoBounty.sol
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,11 @@ interface IRevoBounty {
view
returns (TokenAmount[] memory);

function calculateAdditionalBountyFee(TokenAmount[] calldata interestAccrued)
Copy link
Contributor

Choose a reason for hiding this comment

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

In my mind, a "bounty fee" is a fee the user pays that turns into a bounty for the person who calls claimRewards to collect. By that logic though, "additional bounty fee" doesn't make sense. The "additional bounty" is not funded by fees. It's a bounty that Revo pays for, presumably out of the community fund (which will have governance tokens, withdrawal fees, etc)

Copy link
Contributor

Choose a reason for hiding this comment

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

I think calculateAdditionalBounty would be easier to understand

external
view
returns (TokenAmount[] memory);

function calculateReserveFee(TokenAmount[] calldata interestAccrued)
external
view
Expand Down
17 changes: 14 additions & 3 deletions contracts/farm-bot.sol
Original file line number Diff line number Diff line change
Expand Up @@ -202,10 +202,11 @@ contract FarmBot is ERC20, AccessControl {
return tokenBalance;
}

// convenience method for anyone considering calling claimRewards (who may want to compare bounty to gas cost)
// Private method used to calculate what tokens would be available for reinvestment if claimRewards were called
// right now.
// Annoyingly, the MoolaStakingRewards.earnedExternal method is not declared as a view, so we cannot declare this
// method as a view itself.
function previewBounty() external returns (TokenAmount[] memory) {
function calculateRewards() private returns (TokenAmount[] memory) {
uint256[] memory _leftoverBalances = new uint256[](
rewardsTokens.length
);
Expand Down Expand Up @@ -238,8 +239,18 @@ contract FarmBot is ERC20, AccessControl {
_interestEarned[i] + _leftoverBalances[i]
);
}
return _rewardsTokenBalances;
}

return revoBounty.calculateBountyFee(_rewardsTokenBalances);
// convenience methods for anyone considering calling claimRewards (who may want to compare bounty to gas cost)
function previewAdditionalBounty() external returns (TokenAmount[] memory) {
TokenAmount[] memory _rewardsTokenBalances = calculateRewards();
return revoBounty.calculateAdditionalBountyFee(_rewardsTokenBalances);
}

function previewBounty() external returns (TokenAmount[] memory) {
TokenAmount[] memory _rewardsTokenBalances = calculateRewards();
return revoBounty.calculateBountyFee(_rewardsTokenBalances);
}

// Figure out best-case scenario amount of token we can get and swap
Expand Down
4 changes: 4 additions & 0 deletions contracts/mocks/MockRevoBounty.sol
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ contract MockRevoBounty is IRevoBounty {
return bounties;
}

function calculateAdditionalBountyFee(TokenAmount[] calldata interestAccrued) external override view returns (TokenAmount[] memory) {
return new TokenAmount[](0);
}

function calculateReserveFee(TokenAmount[] calldata interestAccrued) external override view returns (TokenAmount[] memory) {
return bounties;
}
Expand Down