Skip to content

Commit

Permalink
Voting power refactor : 1 cycle delay (#51)
Browse files Browse the repository at this point in the history
* update: updating submodule to include fixes to voting power

* fix: updating refactor to match with upstream natspec pr, version is compiling

* fix: refactoring tests and making one work

* fix: updating tests (all working) and some initilization functionality

* fix: issue with 0 voters in a cycle addressed

* fix: amending deploy script

* fix: addressing typo"

* fix: fixing another typo

* chore: adding two view functions for #53 , #52

* fix: fixing spacing mistake

* chore: adding min voting power for current bread holders

* fix: amending hardcoded value to be equivalent to maxpoints, assures no division errors

* fix: if the first mint is after the end period, return 0

* fix: fixing prevKey > _end

* fix: further minimizing and documenting the code

* fix: fixing some more issues with the voting func

* fix: amending to conform to natspect

* fix: reverting named variable

* fix: deprecated nastspec comment block

* fix: removing extra space

* fix: changing ownable call location

* fix: adding linebreak after check

* fix: removing line break before function

* fix: spacing and unbulking comments

* fix: removing maxpoints and fixing spacing

* fix: removing setter for block time

* fix: removing voting power from last block, simplyfing checkpoint filtering, accounting for no checkpoints in the interval, renaming variables for clarity

* fix: reordering variables and adding line breaks after checks for consistency

* fix: deprecating the usage of timestamps

* fix: removing extraneous variables, initalizing with preconfigured values

* fix: amending initalizer ordering

* fix: ordering initalizers constants > public variable

* fix: adding division loss protection

* fix: documentation update

* fix: trimming trailing whitespace

* fix: incorrect reverse traversal of list

* fix: fixing setup of tests to properly init cycling

* fix: amending tests to work with changes

* fix: voting with above required voting power

* Refactor 'getVotingPowerForPeriod' function

* fix: changing grace voting power to to constant, view function to test wrapper

* fix: timestamp ref deprecated

* A few small additional changes to 'getVotingPowerForPeriod'

* Fix bug with decrementing index in 'getVotingPowerForPeriod'

* Changes to variables names to fix broken build

* Remove grace period vote logic and slight refactor of

* General style cleanup, removed unused settings, remove return values from errors

* Refactor 'distributeYield' function and other small changes

* Refactor add/remove projects and errors, events, and globals

* Add missing 'votingPower' param

* Change contract name to YieldDistributor

* Fix minimum voting power test

* Update src/YieldDisburser.sol

Co-authored-by: RonTuretzky <[email protected]>

* Update src/YieldDisburser.sol

* fix: removing extra linebreak

* Non-breaking changes cleanup (#58)

* Refactor 'getVotingPowerForPeriod' function

* A few small additional changes to 'getVotingPowerForPeriod'

* Fix bug with decrementing index in 'getVotingPowerForPeriod'

* Changes to variables names to fix broken build

* Remove grace period vote logic and slight refactor of

* General style cleanup, removed unused settings, remove return values from errors

* Refactor 'distributeYield' function and other small changes

* Refactor add/remove projects and errors, events, and globals

* Add missing 'votingPower' param

* Fix minimum voting power test

* Update src/YieldDisburser.sol

Co-authored-by: RonTuretzky <[email protected]>

* Update src/YieldDisburser.sol

* fix: removing extra linebreak

---------

Co-authored-by: RonTuretzky <[email protected]>
Co-authored-by: Ron Turetzky <[email protected]>

---------

Co-authored-by: bagelface.eth <[email protected]>
Co-authored-by: bagelface <[email protected]>
  • Loading branch information
3 people authored Jun 28, 2024
1 parent a3a7413 commit 92001af
Show file tree
Hide file tree
Showing 11 changed files with 751 additions and 851 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ $ forge test --fork-url "https://rpc.gnosis.gateway.fm" -vvvv
### Deploy

```shell
forge script script/deploy/DeployYieldDisburser.s.sol:DeployYieldDisburser --rpc-url "https://rpc.gnosis.gateway.fm" --broadcast --private-key <pk>
forge script script/deploy/DeployYieldDistributor.s.sol:DeployYieldDistributor --rpc-url "https://rpc.gnosis.gateway.fm" --broadcast --private-key <pk>
```

### Cast
Expand Down
2 changes: 1 addition & 1 deletion lib/bread-token-v2
51 changes: 0 additions & 51 deletions script/deploy/DeployYieldDisburser.s.sol

This file was deleted.

43 changes: 43 additions & 0 deletions script/deploy/DeployYieldDistributor.s.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
pragma solidity ^0.8.20;

import "forge-std/Script.sol";
import "forge-std/StdJson.sol";
import "forge-std/console.sol";
import "openzeppelin-contracts/contracts/proxy/transparent/TransparentUpgradeableProxy.sol";
import "openzeppelin-contracts/contracts/proxy/transparent/ProxyAdmin.sol";
import "forge-std/StdJson.sol";

import {YieldDistributor} from "../../src/YieldDistributor.sol";

contract DeployYieldDistributor is Script {
string public deployConfigPath = string(bytes("./script/deploy/config/deploy.json"));
string config_data = vm.readFile(deployConfigPath);
address _bread = stdJson.readAddress(config_data, "._bread");
uint256 _minRequiredVotingPower = stdJson.readUint(config_data, "._minRequiredVotingPower");
uint256 _cycleLength = stdJson.readUint(config_data, "._cycleLength");
uint256 _maxPoints = stdJson.readUint(config_data, "._maxPoints");
uint256 _precision = stdJson.readUint(config_data, "._precision");
uint256 _lastClaimedBlockNumber = stdJson.readUint(config_data, "._lastClaimedBlockNumber");
bytes projectsRaw = stdJson.parseRaw(config_data, "._projects");
address[] projects = abi.decode(projectsRaw, (address[]));
bytes initData = abi.encodeWithSelector(
YieldDistributor.initialize.selector,
_bread,
_precision,
_minRequiredVotingPower,
_maxPoints,
_cycleLength,
_lastClaimedBlockNumber,
projects
);

function run() external {
vm.startBroadcast();
YieldDistributor yieldDistributorImplementation = new YieldDistributor();
YieldDistributor yieldDistributor = YieldDistributor(
address(new TransparentUpgradeableProxy(address(yieldDistributorImplementation), address(this), initData))
);
console2.log("Deployed YieldDistributor at address: {}", address(yieldDistributor));
vm.stopBroadcast();
}
}
11 changes: 4 additions & 7 deletions script/deploy/config/deploy.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"breadAddress": "0xa555d5344f6FB6c65da19e403Cb4c1eC4a1a5Ee3",
"_bread": "0xa555d5344f6FB6c65da19e403Cb4c1eC4a1a5Ee3",
"_projectNames": [
"laborDao",
"Dandelion",
Expand All @@ -15,12 +15,9 @@
"0x918dEf5d593F46735f74F9E2B280Fe51AF3A99ad"
],
"_blocktime": 5,
"_minVotingAmount": 10,
"_minHoldingDuration": 10,
"_maxVotes": 2500,
"_maxPoints": 10000,
"_minTimeBetweenClaims": 30,
"_lastClaimedTimestamp": 0,
"_lastClaimedBlocknumber": 0,
"_cycleLength": 518400,
"_minRequiredVotingPower":1728000000000000000000000,
"_lastClaimedBlockNumber": 0,
"_precision": 1000000000000000000
}
Loading

0 comments on commit 92001af

Please sign in to comment.