Skip to content

Commit

Permalink
Refactor: seggregate scripts by launch phase (#13)
Browse files Browse the repository at this point in the history
* fix: add sanity checks for staking token and dss-vest

* fix: add check for `StakingRewards` being updated before

* refactor: seggregate scripts for different phases

* refactor: fully segregate scripts for different phases

* refactor: rename scripts and template inputs

* fix: bad sanity check on phase-0/FarmingInit library

* refactor: change internal name for `StakingRewards` instances

* refactor(phase-0-alpha): remove creation of vesting stream

`vestId` is expected as an input parameter instead. This makes it easier, since another team deployed the `DssVest` contract for NGT tokens.

* chore: update `lib/dss-test`

* fix(phase-0-alpha): adjust init and check script after deloy refactor

* refactor(ConfigReader): swap envOrRead* parameters

Since env vars take priority, `envKey` should be the 1st parameter.

* docs(phase-0): add comment for assumption on `vest`

* refactor(phase-0): update deploy script input template

* chore(deps): update `dss-test`

* refactor(solc-version): use `0.8.16`

Use `solc`@`0.8.16` to match the remaining endgame related contracts

* refactor(VestInit): remove unused dependency
  • Loading branch information
amusingaxl authored Nov 27, 2023
1 parent cc223aa commit 2c20e25
Show file tree
Hide file tree
Showing 43 changed files with 592 additions and 369 deletions.
6 changes: 3 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ out/
/broadcast

# Ignores script config
/script/input/*/*.json
!/script/input/*/template-*.json
/script/output/*/*.json
/script/input/**/*.json
!/script/input/**/template-*.json
/script/output/**/*.json

# Docs
docs/
Expand Down
2 changes: 1 addition & 1 deletion foundry.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ src = 'src'
out = 'out'
script = 'script'
libs = ['lib']
solc_version = '0.8.19'
solc_version = '0.8.16'
optimizer = true
fs_permissions = [
{ access = "read", path = "./out/" },
Expand Down
2 changes: 1 addition & 1 deletion lib/dss-test
98 changes: 0 additions & 98 deletions script/02-StakingRewardsInit.s.sol

This file was deleted.

2 changes: 1 addition & 1 deletion script/dependencies/SDAODeploy.sol
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.

pragma solidity ^0.8.0;
pragma solidity ^0.8.16;

import {ScriptTools} from "dss-test/ScriptTools.sol";
import {SDAO} from "../../src/SDAO.sol";
Expand Down
6 changes: 3 additions & 3 deletions script/dependencies/StakingRewardsDeploy.sol
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.

pragma solidity ^0.8.0;
pragma solidity ^0.8.16;

import {StakingRewards} from "../../src/synthetix/StakingRewards.sol";

Expand All @@ -24,7 +24,7 @@ struct StakingRewardsDeployParams {
}

library StakingRewardsDeploy {
function deploy(StakingRewardsDeployParams memory p) internal returns (address farm) {
farm = address(new StakingRewards(p.owner, address(0), p.rewardsToken, p.stakingToken));
function deploy(StakingRewardsDeployParams memory p) internal returns (address rewards) {
rewards = address(new StakingRewards(p.owner, address(0), p.rewardsToken, p.stakingToken));
}
}
30 changes: 15 additions & 15 deletions script/dependencies/StakingRewardsInit.sol
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,7 @@
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.

pragma solidity ^0.8.0;

interface StakingRewardsLike {
function setRewardsDistribution(address _rewardsDistribution) external;

function acceptOwnership() external;

function nominateNewOwner(address _owner) external;
}
pragma solidity ^0.8.16;

struct StakingRewardsInitParams {
address dist;
Expand All @@ -32,17 +24,25 @@ struct StakingRewardsNominateNewOwnerParams {
}

library StakingRewardsInit {
function init(address farm, StakingRewardsInitParams memory p) internal {
StakingRewardsLike(farm).setRewardsDistribution(p.dist);
function init(address rewards, StakingRewardsInitParams memory p) internal {
StakingRewardsLike(rewards).setRewardsDistribution(p.dist);
}

/// @dev `StakingRewards` ownership transfer is a 2-step process: nominate + acceptance.
function nominateNewOwner(address farm, StakingRewardsNominateNewOwnerParams memory p) internal {
StakingRewardsLike(farm).nominateNewOwner(p.newOwner);
function nominateNewOwner(address rewards, StakingRewardsNominateNewOwnerParams memory p) internal {
StakingRewardsLike(rewards).nominateNewOwner(p.newOwner);
}

/// @dev `StakingRewards` ownership transfer requires the new owner to explicitly accept it.
function acceptOwnership(address farm) internal {
StakingRewardsLike(farm).acceptOwnership();
function acceptOwnership(address rewards) internal {
StakingRewardsLike(rewards).acceptOwnership();
}
}

interface StakingRewardsLike {
function setRewardsDistribution(address _rewardsDistribution) external;

function acceptOwnership() external;

function nominateNewOwner(address _owner) external;
}
2 changes: 1 addition & 1 deletion script/dependencies/SubProxyDeploy.sol
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.

pragma solidity ^0.8.0;
pragma solidity ^0.8.16;

import {ScriptTools} from "dss-test/ScriptTools.sol";
import {SubProxy} from "../../src/SubProxy.sol";
Expand Down
10 changes: 5 additions & 5 deletions script/dependencies/SubProxyInit.sol
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,11 @@
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.

pragma solidity ^0.8.0;
pragma solidity ^0.8.16;

import {ScriptTools} from "dss-test/ScriptTools.sol";
import {DssInstance, MCD} from "dss-test/MCD.sol";

interface SubProxyLike {
function rely(address who) external;
}

struct SubProxyInitParams {
address chainlog;
string name;
Expand All @@ -42,3 +38,7 @@ library SubProxyInit {
mcd.chainlog.setAddress(string.concat("SUBPROXY_", name).stringToBytes32(), subProxy);
}
}

interface SubProxyLike {
function rely(address who) external;
}
36 changes: 16 additions & 20 deletions script/dependencies/VestInit.sol
Original file line number Diff line number Diff line change
Expand Up @@ -13,24 +13,7 @@
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.

pragma solidity ^0.8.0;

import {ScriptTools} from "dss-test/ScriptTools.sol";

interface DssVestLike {
function file(bytes32 _what, uint256 _data) external;

function create(
address _usr,
uint256 _tot,
uint256 _bgn,
uint256 _tau,
uint256 _eta,
address _mgr
) external returns (uint256 id);

function restrict(uint256 _id) external;
}
pragma solidity ^0.8.16;

struct VestInitParams {
uint256 cap;
Expand All @@ -45,8 +28,6 @@ struct VestCreateParams {
}

library VestInit {
using ScriptTools for string;

function init(address vest, VestInitParams memory p) internal {
DssVestLike(vest).file("cap", p.cap);
}
Expand All @@ -64,3 +45,18 @@ library VestInit {
DssVestLike(vest).restrict(vestId);
}
}

interface DssVestLike {
function file(bytes32 _what, uint256 _data) external;

function create(
address _usr,
uint256 _tot,
uint256 _bgn,
uint256 _tau,
uint256 _eta,
address _mgr
) external returns (uint256 id);

function restrict(uint256 _id) external;
}
6 changes: 3 additions & 3 deletions script/dependencies/VestedRewardsDistributionDeploy.sol
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.

pragma solidity ^0.8.0;
pragma solidity ^0.8.16;

import {ScriptTools} from "dss-test/ScriptTools.sol";
import {VestedRewardsDistribution} from "../../src/VestedRewardsDistribution.sol";
Expand All @@ -22,12 +22,12 @@ struct VestedRewardsDistributionDeployParams {
address deployer;
address owner;
address vest;
address farm;
address rewards;
}

library VestedRewardsDistributionDeploy {
function deploy(VestedRewardsDistributionDeployParams memory p) internal returns (address dist) {
dist = address(new VestedRewardsDistribution(p.vest, p.farm));
dist = address(new VestedRewardsDistribution(p.vest, p.rewards));

ScriptTools.switchOwner(dist, p.deployer, p.owner);
}
Expand Down
10 changes: 5 additions & 5 deletions script/dependencies/VestedRewardsDistributionInit.sol
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,7 @@
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.

pragma solidity ^0.8.0;

interface VestedRewardsDistributionLike {
function file(bytes32 what, uint256 data) external;
}
pragma solidity ^0.8.16;

struct VestedRewardsDistributionInitParams {
uint256 vestId;
Expand All @@ -28,3 +24,7 @@ library VestedRewardsDistributionInit {
VestedRewardsDistributionLike(dist).file("vestId", p.vestId);
}
}

interface VestedRewardsDistributionLike {
function file(bytes32 what, uint256 data) external;
}
Loading

0 comments on commit 2c20e25

Please sign in to comment.