Skip to content

Commit

Permalink
add future proof function to redirect rewards directly to stashes
Browse files Browse the repository at this point in the history
  • Loading branch information
C2tP-C2tP committed May 17, 2021
1 parent 446a69c commit 0ec6514
Show file tree
Hide file tree
Showing 4 changed files with 72 additions and 0 deletions.
9 changes: 9 additions & 0 deletions contracts/contracts/Booster.sol
Original file line number Diff line number Diff line change
Expand Up @@ -372,6 +372,15 @@ contract Booster{
return true;
}

function setGaugeRedirect(uint256 _pid) external returns(bool){
address stash = poolInfo[_pid].stash;
require(msg.sender == stash,"!auth");
address gauge = poolInfo[_pid].gauge;
bytes memory data = abi.encodeWithSelector(bytes4(keccak256("set_rewards_receiver(address)")), stash);
IStaker(staker).execute(gauge,uint256(0),data);
return true;
}

//claim crv and extra rewards and disperse to reward contracts
function _earmarkRewards(uint256 _pid) internal {
PoolInfo storage pool = poolInfo[_pid];
Expand Down
1 change: 1 addition & 0 deletions contracts/contracts/Interfaces.sol
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ interface IStaker{
function voteGaugeWeight(address,uint256) external;
function balanceOfPool(address) external view returns (uint256);
function operator() external view returns (address);
function execute(address _to, uint256 _value, bytes calldata _data) external returns (bool, bytes memory);
}

interface IRewards{
Expand Down
42 changes: 42 additions & 0 deletions contracts/contracts/RedirectableGaugeTest.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
// SPDX-License-Identifier: MIT
pragma solidity 0.6.12;

import '@openzeppelin/contracts/token/ERC20/IERC20.sol';
import '@openzeppelin/contracts/utils/Address.sol';
import '@openzeppelin/contracts/token/ERC20/SafeERC20.sol';

contract RedirectableGauge{
using SafeERC20 for IERC20;
using Address for address;


mapping(address => address) public redirectMap;

constructor() public {
}

function deposit(uint256 _amount) external{

}

function balanceOf(address _account) external view returns (uint256){
return 0;
}

function withdraw(uint256 _amount) external{

}

function claim_rewards() external{

}

function reward_tokens(uint256 _token) external view returns(address){
return address(0);
}

function set_rewards_receiver(address _receiver) external returns(bool){
redirectMap[msg.sender] = _receiver;
return true;
}
}
20 changes: 20 additions & 0 deletions contracts/test/12_Vesting.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ const MerkleTree = require('./helpers/merkleTree');
var jsonfile = require('jsonfile');
var droplist = jsonfile.readFileSync('../airdrop/drop_proofs.json');
var contractList = jsonfile.readFileSync('./contracts.json');
var distroList = jsonfile.readFileSync('./migrations/distro.json');

const VestedEscrow = artifacts.require("VestedEscrow");
const cvxRewardPool = artifacts.require("cvxRewardPool");
Expand All @@ -18,6 +19,25 @@ contract("VestedEscrow Test", async accounts => {
let cvxRewards = await cvxRewardPool.at(contractList.system.cvxRewards)
let cvx = await ConvexToken.at(contractList.system.cvx)

var team = distroList.vested.team.addresses;
var investor = distroList.vested.investor.addresses;
var treasury = distroList.vested.treasury.addresses;
for(var i = 0; i < team.length; i++){
await vested.lockedOf(team[i]).then(a=>console.log(team[i] + " locked: " +a))
await vested.balanceOf(team[i]).then(a=>console.log(team[i] + " balance: " +a))
await vested.vestedOf(team[i]).then(a=>console.log(team[i] + " vested: " +a))
}
for(var i = 0; i < investor.length; i++){
await vested.lockedOf(investor[i]).then(a=>console.log(investor[i] + " locked: " +a))
await vested.balanceOf(investor[i]).then(a=>console.log(investor[i] + " balance: " +a))
await vested.vestedOf(investor[i]).then(a=>console.log(investor[i] + " vested: " +a))
}
for(var i = 0; i < treasury.length; i++){
await vested.lockedOf(treasury[i]).then(a=>console.log(treasury[i] + " locked: " +a))
await vested.balanceOf(treasury[i]).then(a=>console.log(treasury[i] + " balance: " +a))
await vested.vestedOf(treasury[i]).then(a=>console.log(treasury[i] + " vested: " +a))
}

let accountA = "0xAAc0aa431c237C2C0B5f041c8e59B3f1a43aC78F";
let accountB = "0xb3DF5271b92e9fD2fed137253BB4611285923f16";
for(var i = 0; i < 13; i++){
Expand Down

0 comments on commit 0ec6514

Please sign in to comment.