Skip to content

Commit

Permalink
refactor: replace NGT with SKY
Browse files Browse the repository at this point in the history
  • Loading branch information
amusingaxl committed Aug 27, 2024
1 parent 5afaca9 commit 877f5e8
Show file tree
Hide file tree
Showing 6 changed files with 48 additions and 48 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ import {StakingRewardsInit, StakingRewardsInitParams} from "../StakingRewardsIni
import {VestedRewardsDistributionInit, VestedRewardsDistributionInitParams} from "../VestedRewardsDistributionInit.sol";
import {VestInit, VestCreateParams} from "../VestInit.sol";

struct UsdsNgtFarmingInitParams {
struct UsdsSkyFarmingInitParams {
address usds;
address ngt;
address sky;
address rewards;
bytes32 rewardsKey; // Chainlog key
address dist;
Expand All @@ -32,38 +32,38 @@ struct UsdsNgtFarmingInitParams {
uint256 vestTau;
}

struct UsdsNgtFarmingInitResult {
struct UsdsSkyFarmingInitResult {
uint256 vestId;
}

library UsdsNgtFarmingInit {
library UsdsSkyFarmingInit {
ChainlogLike internal constant chainlog = ChainlogLike(0xdA0Ab1e0017DEbCd72Be8599041a2aa3bA7e740F);

function init(UsdsNgtFarmingInitParams memory p) internal returns (UsdsNgtFarmingInitResult memory r) {
function init(UsdsSkyFarmingInitParams memory p) internal returns (UsdsSkyFarmingInitResult memory r) {
address stakingToken = StakingRewardsLike(p.rewards).stakingToken();
address rewardsToken = StakingRewardsLike(p.rewards).rewardsToken();

require(stakingToken != rewardsToken, "UsdsNgtFarmingInit/rewards-token-same-as-staking-token");
require(stakingToken != rewardsToken, "UsdsSkyFarmingInit/rewards-token-same-as-staking-token");

require(DssVestWithGemLike(p.vest).gem() == p.ngt, "UsdsNgtFarmingInit/vest-gem-mismatch");
require(DssVestWithGemLike(p.vest).gem() == p.sky, "UsdsSkyFarmingInit/vest-gem-mismatch");

require(stakingToken == p.usds, "UsdsNgtFarmingInit/rewards-staking-token-mismatch");
require(rewardsToken == p.ngt, "UsdsNgtFarmingInit/rewards-rewards-token-mismatch");
require(stakingToken == p.usds, "UsdsSkyFarmingInit/rewards-staking-token-mismatch");
require(rewardsToken == p.sky, "UsdsSkyFarmingInit/rewards-rewards-token-mismatch");
require(
StakingRewardsLike(p.rewards).lastUpdateTime() == 0,
"UsdsNgtFarmingInit/rewards-last-update-time-invalid"
"UsdsSkyFarmingInit/rewards-last-update-time-invalid"
);

require(VestedRewardsDistributionLike(p.dist).gem() == p.ngt, "UsdsNgtFarmingInit/dist-gem-mismatch");
require(VestedRewardsDistributionLike(p.dist).dssVest() == p.vest, "UsdsNgtFarmingInit/dist-dss-vest-mismatch");
require(VestedRewardsDistributionLike(p.dist).gem() == p.sky, "UsdsSkyFarmingInit/dist-gem-mismatch");
require(VestedRewardsDistributionLike(p.dist).dssVest() == p.vest, "UsdsSkyFarmingInit/dist-dss-vest-mismatch");
require(
VestedRewardsDistributionLike(p.dist).stakingRewards() == p.rewards,
"UsdsNgtFarmingInit/dist-staking-rewards-mismatch"
"UsdsSkyFarmingInit/dist-staking-rewards-mismatch"
);

// `vest` is expected to be an instance of `DssVestMintable`.
// Check if minting rights on `ngt` were granted to `vest`.
require(WardsLike(p.ngt).wards(p.vest) == 1, "UsdsNgtFarmingInit/missing-ngt-rely-vest");
// Check if minting rights on `sky` were granted to `vest`.
require(WardsLike(p.sky).wards(p.vest) == 1, "UsdsSkyFarmingInit/missing-sky-rely-vest");

// Set `dist` with `rewardsDistribution` role in `rewards`.
StakingRewardsInit.init(p.rewards, StakingRewardsInitParams({dist: p.dist}));
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"ngt": "address: the address of NGT",
"sky": "address: the address of SKY",
"usds": "address: the address of USDS",
"vest": "address: the address of a DssVestMintable contract for NGT",
"vest": "address: the address of a DssVestMintable contract for SKY",
"rewards": "[OPTIONAL] address: the address of the StakingRewards contract",
"dist": "[OPTIONAL ]address: the address of the VestedRewardsDistrubution contract"
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"ngt": "address: the address of NGT",
"sky": "address: the address of SKY",
"usds": "address: the address of USDS",
"vest": "address: the address of a DssVestMintable contract for NGT",
"vest": "address: the address of a DssVestMintable contract for SKY",
"rewards": "[OPTIONAL] address: the address of the StakingRewards contract",
"dist": "[OPTIONAL ]address: the address of the VestedRewardsDistrubution contract"
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,17 +25,17 @@ import {
VestedRewardsDistributionDeployParams
} from "../dependencies/VestedRewardsDistributionDeploy.sol";

contract Phase1b_UsdsNgtFarmingDeployScript is Script {
contract Phase1b_UsdsSkyFarmingDeployScript is Script {
ChainlogLike internal constant chainlog = ChainlogLike(0xdA0Ab1e0017DEbCd72Be8599041a2aa3bA7e740F);

string internal constant NAME = "phase-1b/usds-ngt-farming-deploy";
string internal constant NAME = "phase-1b/usds-sky-farming-deploy";

function run() external {
Reader reader = new Reader(ScriptTools.loadConfig());

address admin = chainlog.getAddress("MCD_PAUSE_PROXY");

address ngt = reader.envOrReadAddress("FOUNDRY_NGT", ".ngt");
address sky = reader.envOrReadAddress("FOUNDRY_SKY", ".sky");
address usds = reader.envOrReadAddress("FOUNDRY_USDS", ".usds");
address vest = reader.envOrReadAddress("FOUNDRY_VEST", ".vest");
address dist = reader.readAddressOptional(".dist");
Expand All @@ -45,7 +45,7 @@ contract Phase1b_UsdsNgtFarmingDeployScript is Script {

if (rewards == address(0)) {
rewards = StakingRewardsDeploy.deploy(
StakingRewardsDeployParams({owner: admin, stakingToken: usds, rewardsToken: ngt})
StakingRewardsDeployParams({owner: admin, stakingToken: usds, rewardsToken: sky})
);
}

Expand All @@ -63,7 +63,7 @@ contract Phase1b_UsdsNgtFarmingDeployScript is Script {
vm.stopBroadcast();

ScriptTools.exportContract(NAME, "admin", admin);
ScriptTools.exportContract(NAME, "ngt", ngt);
ScriptTools.exportContract(NAME, "sky", sky);
ScriptTools.exportContract(NAME, "usds", usds);
ScriptTools.exportContract(NAME, "dist", dist);
ScriptTools.exportContract(NAME, "rewards", rewards);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,17 +21,17 @@ import {ScriptTools} from "dss-test/ScriptTools.sol";
import {Reader} from "../helpers/Reader.sol";
import {VestInit, VestInitParams} from "../dependencies/VestInit.sol";
import {
UsdsNgtFarmingInit,
UsdsNgtFarmingInitParams,
UsdsNgtFarmingInitResult
} from "../dependencies/phase-1b/UsdsNgtFarmingInit.sol";
UsdsSkyFarmingInit,
UsdsSkyFarmingInitParams,
UsdsSkyFarmingInitResult
} from "../dependencies/phase-1b/UsdsSkyFarmingInit.sol";

contract Phase1b_UsdsNgtFarmingInitScript is Script {
contract Phase1b_UsdsSkyFarmingInitScript is Script {
using ScriptTools for string;

ChainlogLike internal constant chainlog = ChainlogLike(0xdA0Ab1e0017DEbCd72Be8599041a2aa3bA7e740F);

string internal constant NAME = "phase-1b/usds-ngt-farming-init";
string internal constant NAME = "phase-1b/usds-sky-farming-init";

function run() external {
Reader config = new Reader(ScriptTools.loadConfig());
Expand All @@ -41,19 +41,19 @@ contract Phase1b_UsdsNgtFarmingInitScript is Script {
uint256 vestBgn = config.envOrReadUint("FOUNDRY_VEST_BGN", ".vestBgn");
uint256 vestTau = config.envOrReadUint("FOUNDRY_VEST_TAU", ".vestTau");

address ngt = deps.envOrReadAddress("FOUNDRY_NGT", ".ngt");
address sky = deps.envOrReadAddress("FOUNDRY_SKY", ".sky");
address usds = deps.envOrReadAddress("FOUNDRY_USDS", ".usds");
address dist = deps.envOrReadAddress("FOUNDRY_DIST", ".dist");
address rewards = deps.envOrReadAddress("FOUNDRY_FARM", ".rewards");
address vest = deps.envOrReadAddress("FOUNDRY_VEST", ".vest");

UsdsNgtFarmingInitParams memory farmingCfg = UsdsNgtFarmingInitParams({
ngt: ngt,
UsdsSkyFarmingInitParams memory farmingCfg = UsdsSkyFarmingInitParams({
sky: sky,
usds: usds,
dist: dist,
distKey: "REWARDS_DISTRIBUTION_USDS_NGT",
distKey: "REWARDS_DISTRIBUTION_USDS_SKY",
rewards: rewards,
rewardsKey: "FARM_USDS_NGT",
rewardsKey: "FARM_USDS_SKY",
vest: vest,
vestTot: vestTot,
vestBgn: vestBgn,
Expand All @@ -66,31 +66,31 @@ contract Phase1b_UsdsNgtFarmingInitScript is Script {

vm.startBroadcast();

UsdsNgtFarmingInitSpell spell = new UsdsNgtFarmingInitSpell();
UsdsSkyFarmingInitSpell spell = new UsdsSkyFarmingInitSpell();
bytes memory out = ProxyLike(pauseProxy).exec(
address(spell),
abi.encodeCall(spell.cast, (farmingCfg, vestInitCfg))
);

vm.stopBroadcast();

UsdsNgtFarmingInitResult memory res = abi.decode(out, (UsdsNgtFarmingInitResult));
UsdsSkyFarmingInitResult memory res = abi.decode(out, (UsdsSkyFarmingInitResult));

ScriptTools.exportContract(NAME, "ngt", ngt);
ScriptTools.exportContract(NAME, "sky", sky);
ScriptTools.exportContract(NAME, "dist", dist);
ScriptTools.exportContract(NAME, "rewards", rewards);
ScriptTools.exportContract(NAME, "vest", vest);
ScriptTools.exportValue(NAME, "vestId", res.vestId);
}
}

contract UsdsNgtFarmingInitSpell {
contract UsdsSkyFarmingInitSpell {
function cast(
UsdsNgtFarmingInitParams memory farmingCfg,
UsdsSkyFarmingInitParams memory farmingCfg,
VestInitParams calldata vestInitCfg
) public returns (UsdsNgtFarmingInitResult memory) {
) public returns (UsdsSkyFarmingInitResult memory) {
VestInit.init(farmingCfg.vest, vestInitCfg);
return UsdsNgtFarmingInit.init(farmingCfg);
return UsdsSkyFarmingInit.init(farmingCfg);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,13 @@ pragma solidity ^0.8.16;
import {Script} from "forge-std/Script.sol";
import {Reader} from "../helpers/Reader.sol";

contract Phase1b_UsdsNgtFarmingCheckScript is Script {
contract Phase1b_UsdsSkyFarmingCheckScript is Script {
function run() external returns (bool) {
Reader deps = new Reader("");
deps.loadDependenciesOrConfig();

address admin = deps.envOrReadAddress("FOUNDRY_ADMIN", ".admin");
address ngt = deps.envOrReadAddress("FOUNDRY_NGT", ".ngt");
address sky = deps.envOrReadAddress("FOUNDRY_SKY", ".sky");
address usds = deps.envOrReadAddress("FOUNDRY_USDS", ".usds");
address dist = deps.readAddress(".dist");
address rewards = deps.readAddress(".rewards");
Expand All @@ -33,23 +33,23 @@ contract Phase1b_UsdsNgtFarmingCheckScript is Script {

require(VestedRewardsDistributionLike(dist).dssVest() == vest, "VestedRewardsDistribution/invalid-vest");
require(VestedRewardsDistributionLike(dist).vestId() == vestId, "VestedRewardsDistribution/invalid-vest-id");
require(VestedRewardsDistributionLike(dist).gem() == ngt, "VestedRewardsDistribution/invalid-gem");
require(VestedRewardsDistributionLike(dist).gem() == sky, "VestedRewardsDistribution/invalid-gem");
require(
VestedRewardsDistributionLike(dist).stakingRewards() == rewards,
"VestedRewardsDistribution/invalid-staking-rewards"
);

require(StakingRewardsLike(rewards).owner() == admin, "StakingRewards/admin-not-owner");
require(StakingRewardsLike(rewards).rewardsToken() == ngt, "StakingRewards/invalid-rewards-token");
require(StakingRewardsLike(rewards).rewardsToken() == sky, "StakingRewards/invalid-rewards-token");
require(StakingRewardsLike(rewards).stakingToken() == usds, "StakingRewards/invalid-rewards-token");
require(
StakingRewardsLike(rewards).rewardsDistribution() == dist,
"StakingRewards/invalid-rewards-distribution"
);

require(WardsLike(ngt).wards(vest) == 1, "Ngt/dss-vest-not-ward");
require(WardsLike(sky).wards(vest) == 1, "Sky/dss-vest-not-ward");

require(DssVestWithGemLike(vest).gem() == ngt, "DssVest/invalid-gem");
require(DssVestWithGemLike(vest).gem() == sky, "DssVest/invalid-gem");
require(DssVestWithGemLike(vest).valid(vestId), "DssVest/invalid-vest-id");
require(DssVestWithGemLike(vest).res(vestId) == 1, "DssVest/invalid-vest-res");
require(DssVestWithGemLike(vest).usr(vestId) == dist, "DssVest/wrong-dist");
Expand Down

0 comments on commit 877f5e8

Please sign in to comment.