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

setCvpVestingPool #151

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
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
4 changes: 4 additions & 0 deletions contracts/powerindex-mining/VestedLPMining.sol
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,10 @@ contract VestedLPMining is
emit SetCvpPerBlock(_cvpPerBlock);
}

function setCvpVestingPool(uint256 _cvpVestingPool) public onlyOwner {
cvpVestingPool = SafeMath96.fromUint(_cvpVestingPool, "VLPMining: too big _cvpVestingPool");
}

/// @inheritdoc IVestedLPMining
function setCvpVestingPeriodInBlocks(uint256 _cvpVestingPeriodInBlocks) public override onlyOwner {
cvpVestingPeriodInBlocks = SafeMath32.fromUint(
Expand Down
26 changes: 26 additions & 0 deletions test/VestedLPMining.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -560,6 +560,32 @@ describe('VestedLPMining', () => {
assert.equal(await this.allCvpOf(bob), '2900');
});

it('cvpVestingPool can be changed by owner', async () => {
await time.advanceBlockTo(this.shiftBlock('959'));
// 100 per block farming rate starting at block 900
this.lpMining = await VestedLPMining.new({ from: minter });
await this.lpMining.initialize(this.cvp.address, this.reservoir.address, '100', this.shiftBlock('900'), '100', {
from: minter,
});
await this.prepareReservoir();

await this.lp.approve(this.lpMining.address, '1000', { from: bob });
await time.advanceBlockTo(this.shiftBlock('969'));
await this.lpMining.add('100', this.lp.address, '1', true, '0', '0', '0', '0', { from: minter });
await this.lpMining.deposit(0, '100', 0, { from: bob });
await time.advanceBlockTo(this.shiftBlock('979'));
await this.lpMining.deposit(0, '0', 0, { from: bob }); // block 920
assert.equal(await this.lpMining.cvpVestingPool(), '826');

await expectRevert(this.lpMining.setCvpVestingPool('100', { from: alice }), 'Ownable: caller is not the owner');
await this.lpMining.setCvpVestingPool('100', { from: minter });

await time.advanceBlockTo(this.shiftBlock('983'));
assert.equal(await this.lpMining.cvpVestingPool(), '100');
await this.lpMining.deposit(0, '0', 0, { from: bob }); // block 930
assert.equal(await this.lpMining.cvpVestingPool(), '452');
});

it('cvpVestingPeriodInBlocks can be changed by owner', async () => {
this.lpMining = await VestedLPMining.new({ from: minter });
await this.lpMining.initialize(this.cvp.address, this.reservoir.address, '100', this.shiftBlock('900'), '100', {
Expand Down