-
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
Integrate $BB in YieldDistributor #94
Merged
Merged
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
df10e0c
chore: adding voting power pulling
51af8dc
fix: adding buttered bread init to tests
92930d4
fix: adding buttered bread init to tests
3886001
chore: adding buttered bread to initalizer in yd
fa9b3b6
Merge branch 'dev' into integrate_bb_in_yd
bf4f97e
fix: reordering variable for upgrade safety
f909a84
fix: adding validation of init variables
63228eb
fix: amending variable name to conform with style guide
0558896
fix: line break after conditional"
5fe2c80
fix: fixing implication of token symbol
1d5be1e
fix: amend init values to align with init validations
f7c8b7f
chore: adding integration test
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,11 @@ | ||
{ | ||
"_owner": "0x918dEf5d593F46735f74F9E2B280Fe51AF3A99ad", | ||
"_liquidityPools": ["0xa555d5344f6FB6c65da19e403Cb4c1eC4a1a5Ee3"], | ||
"_scalingFactors": ["100"], | ||
"_liquidityPools": [ | ||
"0xf3d8f3de71657d342db60dd714c8a2ae37eac6b4" | ||
], | ||
"_scalingFactors": [ | ||
"100" | ||
], | ||
"_name": "ButteredBread", | ||
"_symbol": "BB" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,6 +12,11 @@ import {IERC20} from "openzeppelin-contracts/contracts/token/ERC20/IERC20.sol"; | |
import {ButteredBread, IButteredBread} from "src/ButteredBread.sol"; | ||
import {ICurveStableSwap} from "src/interfaces/ICurveStableSwap.sol"; | ||
import {IERC20Votes} from "src/interfaces/IERC20Votes.sol"; | ||
import {YieldDistributorTestWrapper} from "src/test/YieldDistributorTestWrapper.sol"; | ||
import {YieldDistributor, IYieldDistributor} from "src/YieldDistributor.sol"; | ||
import {IBread} from "bread-token/src/interfaces/IBread.sol"; | ||
import {OwnableUpgradeable} from "openzeppelin-contracts-upgradeable/contracts/access/OwnableUpgradeable.sol"; | ||
import {ERC20Mock} from "openzeppelin-contracts/contracts/mocks/token/ERC20Mock.sol"; | ||
|
||
uint256 constant XDAI_FACTOR = 700; // 700% scaling factor; 7X | ||
uint256 constant TOKEN_AMOUNT = 1000 ether; | ||
|
@@ -23,6 +28,21 @@ contract ButteredBreadTest is Test { | |
|
||
uint256 public fixedPointPercent; | ||
address[] public userList; | ||
YieldDistributorTestWrapper public yieldDistributor; | ||
string public deployConfigPath = string(bytes("./test/test_deploy.json")); | ||
string config_data = vm.readFile(deployConfigPath); | ||
bytes projectsRaw = stdJson.parseRaw(config_data, "._projects"); | ||
address[] projects = abi.decode(projectsRaw, (address[])); | ||
uint256 _blocktime = stdJson.readUint(config_data, "._blocktime"); | ||
uint256 _maxPoints = stdJson.readUint(config_data, "._maxPoints"); | ||
uint256 _precision = stdJson.readUint(config_data, "._precision"); | ||
uint256 _minVotingAmount = stdJson.readUint(config_data, "._minVotingAmount"); | ||
uint256 _cycleLength = stdJson.readUint(config_data, "._cycleLength"); | ||
uint256 _minHoldingDuration = stdJson.readUint(config_data, "._minHoldingDuration"); | ||
uint256 _lastClaimedBlockNumber = stdJson.readUint(config_data, "._lastClaimedBlockNumber"); | ||
uint256 _yieldFixedSplitDivisor = stdJson.readUint(config_data, "._yieldFixedSplitDivisor"); | ||
// See test/YieldDistributor.t.sol for explanation of these values | ||
uint256 _minRequiredVotingPower = stdJson.readUint(config_data, "._minRequiredVotingPower"); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. i recommend in the future, inheriting the deployment script from the Scripts folder into the test setup, which will also inherit the stdJson datas. but for now, this works |
||
|
||
function setUp() public virtual { | ||
vm.createSelectFork(vm.rpcUrl("gnosis")); | ||
|
@@ -54,6 +74,25 @@ contract ButteredBreadTest is Test { | |
vm.label(GNOSIS_CURVE_POOL_XDAI_BREAD, "CurveLP_XDAI_BREAD"); | ||
|
||
userList.push(ALICE); | ||
|
||
YieldDistributorTestWrapper yieldDistributorImplementation = new YieldDistributorTestWrapper(); | ||
address[] memory projects1 = new address[](1); | ||
projects1[0] = address(this); | ||
bytes memory ydinitData = abi.encodeWithSelector( | ||
YieldDistributor.initialize.selector, | ||
address(GNOSIS_BREAD), | ||
address(bb), | ||
_precision, | ||
_minRequiredVotingPower, | ||
_maxPoints, | ||
_cycleLength, | ||
_yieldFixedSplitDivisor, | ||
_lastClaimedBlockNumber, | ||
projects1 | ||
); | ||
yieldDistributor = YieldDistributorTestWrapper( | ||
address(new TransparentUpgradeableProxy(address(yieldDistributorImplementation), address(this), ydinitData)) | ||
); | ||
} | ||
|
||
function _helperAddLiquidity(address _account, uint256 _amountT0, uint256 _amountT1) internal { | ||
|
@@ -490,3 +529,41 @@ contract ButteredBreadTest_Delegation is ButteredBreadTest { | |
assertEq(bb.delegates(ALICE), DELEGATEE); | ||
} | ||
} | ||
|
||
interface Mintable { | ||
function mint(address account) external payable; | ||
} | ||
|
||
contract ButteredBreadTest_Integration is ButteredBreadTest { | ||
uint256 public start = 32_323_232_323; | ||
|
||
function setUp() public virtual override { | ||
super.setUp(); | ||
_helperAddLiquidity(ALICE, TOKEN_AMOUNT, TOKEN_AMOUNT); | ||
} | ||
|
||
function setUpForCycle(YieldDistributorTestWrapper _yieldDistributor) public { | ||
vm.roll(start - (_cycleLength)); | ||
address yieldDistributorOwner = OwnableUpgradeable(_yieldDistributor).owner(); | ||
vm.prank(yieldDistributorOwner); | ||
_yieldDistributor.setLastClaimedBlockNumber(vm.getBlockNumber()); | ||
address breadOwner = OwnableUpgradeable(GNOSIS_BREAD).owner(); | ||
vm.prank(breadOwner); | ||
IBread(GNOSIS_BREAD).setYieldClaimer(address(_yieldDistributor)); | ||
vm.roll(start - (_cycleLength + 1)); | ||
vm.deal(ALICE, _minVotingAmount); | ||
vm.startPrank(ALICE); | ||
bb.deposit(GNOSIS_CURVE_POOL_XDAI_BREAD, TOKEN_AMOUNT); | ||
Mintable(GNOSIS_BREAD).mint{value: _minVotingAmount}(ALICE); | ||
vm.roll(start); | ||
} | ||
|
||
function testIntegration() public { | ||
setUpForCycle(yieldDistributor); | ||
assertEq(bb.balanceOf(ALICE), TOKEN_AMOUNT * XDAI_FACTOR / fixedPointPercent); | ||
assertEq(bb.accountToLPBalance(ALICE, GNOSIS_CURVE_POOL_XDAI_BREAD), TOKEN_AMOUNT); | ||
uint256 bbBalance = bb.balanceOf(ALICE); | ||
uint256 bBalance = IERC20(GNOSIS_BREAD).balanceOf(ALICE); | ||
assertEq(yieldDistributor.getCurrentVotingPower(ALICE), bbBalance + bBalance); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 think this is more readable personally
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.
formatter overrides this.. do you know if there's a comment I can add for it to ignore 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.
Aside from changing
line_length
, which i wouldn't recommend, not really. all good