Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
55 commits
Select commit Hold shift + click to select a range
52272ec
WIP: gauge-proxy-v2
UrAvgDeveloper Mar 23, 2022
2047c4c
feat: add periodization to voting
UrAvgDeveloper Mar 30, 2022
42e3521
fix: periodized totalWeight
UrAvgDeveloper Mar 31, 2022
7394d85
added periodization to weights
UrAvgDeveloper Mar 31, 2022
1668db6
fix: updated currentId increment
UrAvgDeveloper Mar 31, 2022
b373608
chore: refactoring and logic improvements
UrAvgDeveloper Apr 1, 2022
2120853
chore: more refactoring of ballot id updation
UrAvgDeveloper Apr 4, 2022
3a465a8
feat: censoring Gauges
UrAvgDeveloper Apr 4, 2022
05fe629
feat: added more features for censorship
UrAvgDeveloper Apr 5, 2022
f9a7be3
feat: deligation of votes
UrAvgDeveloper Apr 6, 2022
9f99894
fix: fixed deligation
UrAvgDeveloper Apr 6, 2022
7f87274
feat: updates to delegation
UrAvgDeveloper Apr 7, 2022
5bfb06e
feat: add indefinite delegation
UrAvgDeveloper Apr 7, 2022
d8eab06
feat: new delegate address can only vote after currentId
UrAvgDeveloper Apr 7, 2022
0bad1a2
feat: upgraded to v 0.8.1
UrAvgDeveloper Apr 13, 2022
717caa2
WIP: gaugeProxyV2 tests
UrAvgDeveloper Apr 21, 2022
e1cbec3
WIP: periodisation test
UrAvgDeveloper Apr 26, 2022
1fe8a99
feat: refactored logic to remove arrays
UrAvgDeveloper Apr 27, 2022
bd95e9f
WIP: more test coverage
UrAvgDeveloper Apr 27, 2022
9c7569e
feat: added fix for distribute to work without voting periods
UrAvgDeveloper Apr 28, 2022
8a2a59d
fix: minor updates
UrAvgDeveloper Apr 28, 2022
aa8e4fc
feat: chunk distribution test
UrAvgDeveloper Apr 28, 2022
be8dd3b
fix: currentId
UrAvgDeveloper Apr 28, 2022
e979be4
fix brackets
larrythecucumber321 Apr 29, 2022
176e0ef
WIP: expect statements
UrAvgDeveloper Apr 29, 2022
cd6b278
feat: GaugeProxyV2 tests
UrAvgDeveloper May 13, 2022
3d8c9a1
fix: minor fix
UrAvgDeveloper May 25, 2022
dba8915
feat: added support for time locking in Gauge V2
UrAvgDeveloper Jun 7, 2022
0c94278
fix: added Gauge V2 to Gauge proxy v2
UrAvgDeveloper Jun 7, 2022
e12911d
feat: add setters and minor improvements
UrAvgDeveloper Jun 7, 2022
d07c2e8
feat: add more admin functions
UrAvgDeveloper Jun 8, 2022
aab7a80
feat: add decaying reward multiplier logic
UrAvgDeveloper Jun 9, 2022
51913c2
fix: chnage decay per period to decay per second
UrAvgDeveloper Jun 9, 2022
2b1366a
feat: liquidity locking
UrAvgDeveloper Jun 14, 2022
7ea40eb
feat: permanat stake lock
UrAvgDeveloper Jun 15, 2022
25e4e5e
feat: add setDelegate method
UrAvgDeveloper Jun 16, 2022
b49bcff
feat:add support for multiple reward tokens
UrAvgDeveloper Jun 20, 2022
1196a91
fix: notifyReward for multiple tokens
UrAvgDeveloper Jun 21, 2022
fcc128d
fix: minor fixes
UrAvgDeveloper Jun 23, 2022
817ee69
fix: minor fixes
UrAvgDeveloper Jun 29, 2022
e31da24
feat: situational test
UrAvgDeveloper Jun 30, 2022
45f1f37
feat: virtual gauge proxy
UrAvgDeveloper Jun 28, 2022
086d1e5
fix: remove mapping entry from is_virtual_gauge
UrAvgDeveloper Jun 28, 2022
7c14e12
feat: gauge proxy with gauge middleware to support updating of versio…
UrAvgDeveloper Jun 30, 2022
52e3746
feat: add virtual gauge
UrAvgDeveloper Jul 1, 2022
1b3b671
feat: update Interface gauge middleware
UrAvgDeveloper Jul 1, 2022
a9abe2c
fix:minor fixes
UrAvgDeveloper Jul 4, 2022
81c672b
fix: change reward claim time
UrAvgDeveloper Jul 1, 2022
af5d04b
feat: partial withdrawal
UrAvgDeveloper Jul 7, 2022
3c22a4c
fix: seprate gaugeMiddlewares for both normal and virtual gauge
UrAvgDeveloper Jul 7, 2022
1ee6fe1
fix: minor fix
UrAvgDeveloper Jul 8, 2022
c077a52
fix: distribution address for gauge contracts
UrAvgDeveloper Jul 12, 2022
95139b7
feat: add gauge interface
UrAvgDeveloper Jul 12, 2022
7951809
fix: fixed gaguge-proxy tests
UrAvgDeveloper Jul 15, 2022
f093cd6
fix: updates and fix for better coverage
UrAvgDeveloper Aug 1, 2022
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
134 changes: 134 additions & 0 deletions hardhat-scripts/dill-test/5.vote-and-distribute-v2.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,134 @@
// We require the Hardhat Runtime Environment explicitly here. This is optional
// but useful for running the script in a standalone fashion through `node <script>`.
//
// When running the script with `hardhat run <script>` you'll find the Hardhat
// Runtime Environment's members available in the global scope.
const hre = require("hardhat");
const {ethers, upgrades} = require("hardhat");

async function main() {
const governanceAddr = "0x9d074E37d408542FD38be78848e8814AFB38db17";
const masterChefAddr = "0xbD17B1ce622d73bD438b9E658acA5996dc394b0d";
const userAddr = "0xaCfE4511CE883C14c4eA40563F176C3C09b4c47C";

const pickleLP = "0xdc98556Ce24f007A5eF6dC1CE96322d65832A819";
const pickleAddr = "0x429881672B9AE42b8EbA0E26cD9C73711b891Ca5";

const pyveCRVETH = "0x5eff6d166d66bacbc1bf52e2c54dd391ae6b1f48";

await hre.network.provider.request({
method: "evm_unlockUnknownAccount",
params: [governanceAddr],
});

const governanceSigner = ethers.provider.getSigner(governanceAddr);
const userSigner = ethers.provider.getSigner(userAddr);
const masterChef = await ethers.getContractAt(
"src/yield-farming/masterchef.sol:MasterChef",
masterChefAddr,
governanceSigner
);
masterChef.connect(governanceSigner);

/** *************************************setting up gauge proxy****************************************** */

// const blockNumBefore = await ethers.provider.getBlockNumber();
// const blockBefore = await ethers.provider.getBlock(blockNumBefore);
// const timestampBefore = blockBefore.timestamp;

// console.log(Math.round(new Date().getTime()/1000));
// console.log(timestampBefore);

console.log("-- Deploying GaugeProxy v2 contract --");
const gaugeProxyV2 = await ethers.getContractFactory("/src/dill/gauge-proxy-v2.sol:GaugeProxyV2", governanceSigner);
console.log("Deploying GaugeProxyV2...");
const GaugeProxyV2 = await upgrades.deployProxy(gaugeProxyV2, [Math.round(new Date().getTime() / 1000)], {
initializer: "initialize",
});
await GaugeProxyV2.deployed();
console.log("GaugeProxyV2 deployed to:", GaugeProxyV2.address);
const mDILLAddr = await GaugeProxyV2.TOKEN();

console.log("-- Adding mDILL to MasterChef --");
let populatedTx;
populatedTx = await masterChef.populateTransaction.add(
5000000,
mDILLAddr,
false
// { gasLimit: 9000000 }
);
await governanceSigner.sendTransaction(populatedTx);

/** *************************************add gauges****************************************** */

console.log("-- Adding PICKLE LP Gauge --");
await GaugeProxyV2.addGauge(pickleLP);

console.log("-- Adding pyveCRVETH Gauge --");
await GaugeProxyV2.addGauge(pyveCRVETH);

await hre.network.provider.request({
method: "evm_unlockUnknownAccount",
params: [userAddr],
});
// await GaugeProxyV2.updateCurrentId();
console.log("currentId ", (await GaugeProxyV2.currentId()).toString());

// console.log("first period time stamp ", (await GaugeProxyV2.firstDistribution()).toString());

/** ************************************* VOTING ****************************************** */

console.log("-- Voting on LP Gauge with 100% weight --");
const gaugeProxyFromUser = GaugeProxyV2.connect(userAddr);
populatedTx = await gaugeProxyFromUser.populateTransaction.vote([pickleLP, pyveCRVETH], [6000000, 4000000], {
gasLimit: 9000000,
});
await userSigner.sendTransaction(populatedTx);
console.log("voted");
const pidDill = (await masterChef.poolLength()) - 1;
await GaugeProxyV2.setPID(pidDill);
await GaugeProxyV2.deposit();

/** ************************************* increase time by 7 days ****************************************** */
console.log("-- Wait 7 days to accumulate");
await hre.network.provider.request({
method: "evm_increaseTime",
params: [3600 * 24 * 7],
});

/** ************************************* mine block ****************************************** */
console.log("-- Wait for 1 block to be mined --");
await hre.network.provider.request({
method: "evm_mine",
});

/** ************************************* DISTRIBUTE ****************************************** */
await GaugeProxyV2.updateCurrentId();
console.log("currentId", (await GaugeProxyV2.currentId()).toString());
console.log("-- Distribute PICKLE to gauges --");
await GaugeProxyV2.distribute(0, 2);

/** ************************************* get gauge address ****************************************** */

const pickleGaugeAddr = await GaugeProxyV2.getGauge(pickleLP);
const yvecrvGaugeAddr = await GaugeProxyV2.getGauge(pyveCRVETH);

/** *************************************get PICKLE contract ****************************************** */
const pickle = await ethers.getContractAt("src/yield-farming/pickle-token.sol:PickleToken", pickleAddr);

/** *************************************check rewards ****************************************** */
let pickleRewards = await pickle.balanceOf(pickleGaugeAddr);
console.log("rewards to Pickle gauge", pickleRewards.toString());

let yvecrvRewards = await pickle.balanceOf(yvecrvGaugeAddr);
console.log("rewards to pyveCRV gauge", yvecrvRewards.toString());
}

// We recommend this pattern to be able to use async/await everywhere
// and properly handle errors.
main()
.then(() => process.exit(0))
.catch((error) => {
console.error(error);
process.exit(1);
});
98 changes: 98 additions & 0 deletions src/dill/gauge-middleware.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
// SPDX-License-Identifier: MIT
pragma solidity >=0.8.0;

import {GaugeV2, Initializable, ProtocolGovernance, VirtualGaugeV2} from "./gauge-proxy-v2.sol";

contract GaugeMiddleware is ProtocolGovernance, Initializable {
address public gaugeProxy;

function initialize(address _gaugeProxy, address _governance)
public
initializer
{
require(
_gaugeProxy != address(0),
"_gaugeProxy address cannot be set to zero"
);
require(
_governance != _gaugeProxy,
"_governance address and _gaugeProxy cannot be same"
);
gaugeProxy = _gaugeProxy;
governance = _governance;
}

function changeGaugeProxy(address _newgaugeProxy) external {
require(msg.sender == governance, "can only be called by governance");
gaugeProxy = _newgaugeProxy;
}

function addGauge(
address _token,
address _governance,
string[] memory _rewardSymbols,
address[] memory _rewardTokens
) external returns (address) {
require(msg.sender == gaugeProxy, "can only be called by gaugeProxy");
require(_token != address(0), "address of token cannot be zero");
return
address(
new GaugeV2(
_token,
_governance,
msg.sender,
_rewardSymbols,
_rewardTokens
)
);
}
}

contract VirtualGaugeMiddleware is ProtocolGovernance, Initializable {
address public gaugeProxy;

function initialize(address _gaugeProxy, address _governance)
public
initializer
{
require(
_gaugeProxy != address(0),
"_gaugeProxy address cannot be set to zero"
);
require(
_governance != _gaugeProxy,
"_governance address and _gaugeProxy cannot be same"
);
gaugeProxy = _gaugeProxy;
governance = _governance;
}

function changeGaugeProxy(address _newgaugeProxy) external {
require(msg.sender == governance, "can only be called by governance");
gaugeProxy = _newgaugeProxy;
}

function addVirtualGauge(
address _jar,
address _governance,
string[] memory _rewardSymbols,
address[] memory _rewardTokens
) external returns (address) {
require(msg.sender == gaugeProxy, "can only be called by gaugeProxy");
require(_jar != address(0), "address of jar cannot be zero");
require(
_governance != address(0),
"address of governance cannot be zero"
);
return
address(
new VirtualGaugeV2(
_jar,
_governance,
msg.sender,
_rewardSymbols,
_rewardTokens
)
);
}
}
Loading