Skip to content

Commit

Permalink
refactor: remove VestInit.init
Browse files Browse the repository at this point in the history
The ownership of `DssVest` no longer lies with this module, instead it assumes that DssVest is already properly initialized and can be used to create vesting streams.
  • Loading branch information
amusingaxl committed Sep 5, 2024
1 parent 5fe6d25 commit badd7b1
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 22 deletions.
11 changes: 1 addition & 10 deletions script/dependencies/VestInit.sol
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,6 @@

pragma solidity ^0.8.16;

struct VestInitParams {
uint256 cap;
}

struct VestCreateParams {
address usr;
uint256 tot;
Expand All @@ -27,11 +23,8 @@ struct VestCreateParams {
uint256 eta;
}

/// @dev Handles vesting stream creation. Assumes `DssVest` parameters are initialized somewhere else.
library VestInit {
function init(address vest, VestInitParams memory p) internal {
DssVestLike(vest).file("cap", p.cap);
}

function create(address vest, VestCreateParams memory p) internal returns (uint256 vestId) {
vestId = DssVestLike(vest).create(
p.usr,
Expand All @@ -47,8 +40,6 @@ library VestInit {
}

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

function create(
address _usr,
uint256 _tot,
Expand Down
21 changes: 9 additions & 12 deletions script/phase-1b/02-UsdsSkyFarmingInit.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ import {Script} from "forge-std/Script.sol";
import {ScriptTools} from "dss-test/ScriptTools.sol";

import {Reader} from "../helpers/Reader.sol";
import {VestInit, VestInitParams} from "../dependencies/VestInit.sol";
import {
UsdsSkyFarmingInit,
UsdsSkyFarmingInitParams,
Expand Down Expand Up @@ -60,17 +59,12 @@ contract Phase1b_UsdsSkyFarmingInitScript is Script {
vestTau: vestTau
});

VestInitParams memory vestInitCfg = VestInitParams({cap: type(uint256).max});

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

vm.startBroadcast();

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

vm.stopBroadcast();

Expand All @@ -85,11 +79,10 @@ contract Phase1b_UsdsSkyFarmingInitScript is Script {
}

contract UsdsSkyFarmingInitSpell {
function cast(
UsdsSkyFarmingInitParams memory farmingCfg,
VestInitParams calldata vestInitCfg
) public returns (UsdsSkyFarmingInitResult memory) {
VestInit.init(farmingCfg.vest, vestInitCfg);
uint256 internal constant CAP = type(uint256).max;

function cast(UsdsSkyFarmingInitParams memory farmingCfg) public returns (UsdsSkyFarmingInitResult memory) {
DssVestLike(farmingCfg.vest).file("cap", CAP);
return UsdsSkyFarmingInit.init(farmingCfg);
}
}
Expand All @@ -101,3 +94,7 @@ interface ProxyLike {
interface ChainlogLike {
function getAddress(bytes32 _key) external view returns (address addr);
}

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

0 comments on commit badd7b1

Please sign in to comment.