Skip to content

Commit

Permalink
feat: add deploy scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
amusingaxl committed Nov 24, 2024
1 parent f930860 commit 3d39ec9
Show file tree
Hide file tree
Showing 13 changed files with 297 additions and 4 deletions.
11 changes: 7 additions & 4 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,13 @@
cache/
out/

# Ignores development broadcast logs
!/broadcast
/broadcast/*/31337/
/broadcast/**/dry-run/
# Ignores broadcast logs
broadcast/

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

# Docs
docs/
Expand Down
49 changes: 49 additions & 0 deletions script/SingleClipBreakerDeploy.s.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
// SPDX-FileCopyrightText: © 2023 Dai Foundation <www.daifoundation.org>
// SPDX-License-Identifier: AGPL-3.0-or-later
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// 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.16;

import {Script} from "forge-std/Script.sol";
import {stdJson} from "forge-std/StdJson.sol";
import {MCD, DssInstance} from "dss-test/MCD.sol";
import {ScriptTools} from "dss-test/ScriptTools.sol";
import {SingleClipBreakerFactory} from "src/clip-breaker/SingleClipBreakerSpell.sol";

contract SingleClipBreakerDeployScript is Script {
using stdJson for string;
using ScriptTools for string;

string constant NAME = "single-clip-breaker-deploy";
string config;

SingleClipBreakerFactory fab;
string[] ilkStrs;

function run() external {
config = ScriptTools.loadConfig();

fab = SingleClipBreakerFactory(config.readAddress(".factory", "FOUNDRY_FACTORY"));
ilkStrs = config.readStringArray(".ilks", "FOUNDRY_ILKS");

vm.startBroadcast();

for (uint256 i = 0; i < ilkStrs.length; i++) {
bytes32 ilk = ilkStrs[i].stringToBytes32();
address spell = fab.deploy(ilk);
ScriptTools.exportContract(NAME, ilkStrs[i], spell);
}
vm.stopBroadcast();
}
}
49 changes: 49 additions & 0 deletions script/SingleDdmDisableDeploy.s.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
// SPDX-FileCopyrightText: © 2023 Dai Foundation <www.daifoundation.org>
// SPDX-License-Identifier: AGPL-3.0-or-later
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// 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.16;

import {Script} from "forge-std/Script.sol";
import {stdJson} from "forge-std/StdJson.sol";
import {MCD, DssInstance} from "dss-test/MCD.sol";
import {ScriptTools} from "dss-test/ScriptTools.sol";
import {SingleDdmDisableFactory} from "src/ddm-disable/SingleDdmDisableSpell.sol";

contract SingleDdmDisableDeployScript is Script {
using stdJson for string;
using ScriptTools for string;

string constant NAME = "single-ddm-disable-deploy";
string config;

SingleDdmDisableFactory fab;
string[] ilkStrs;

function run() external {
config = ScriptTools.loadConfig();

fab = SingleDdmDisableFactory(config.readAddress(".factory", "FOUNDRY_FACTORY"));
ilkStrs = config.readStringArray(".ilks", "FOUNDRY_ILKS");

vm.startBroadcast();

for (uint256 i = 0; i < ilkStrs.length; i++) {
bytes32 ilk = ilkStrs[i].stringToBytes32();
address spell = fab.deploy(ilk);
ScriptTools.exportContract(NAME, ilkStrs[i], spell);
}
vm.stopBroadcast();
}
}
49 changes: 49 additions & 0 deletions script/SingleLineWipeDeploy.s.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
// SPDX-FileCopyrightText: © 2023 Dai Foundation <www.daifoundation.org>
// SPDX-License-Identifier: AGPL-3.0-or-later
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// 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.16;

import {Script} from "forge-std/Script.sol";
import {stdJson} from "forge-std/StdJson.sol";
import {MCD, DssInstance} from "dss-test/MCD.sol";
import {ScriptTools} from "dss-test/ScriptTools.sol";
import {SingleLineWipeFactory} from "src/line-wipe/SingleLineWipeSpell.sol";

contract SingleLineWipeDeployScript is Script {
using stdJson for string;
using ScriptTools for string;

string constant NAME = "single-line-wipe-deploy";
string config;

SingleLineWipeFactory fab;
string[] ilkStrs;

function run() external {
config = ScriptTools.loadConfig();

fab = SingleLineWipeFactory(config.readAddress(".factory", "FOUNDRY_FACTORY"));
ilkStrs = config.readStringArray(".ilks", "FOUNDRY_ILKS");

vm.startBroadcast();

for (uint256 i = 0; i < ilkStrs.length; i++) {
bytes32 ilk = ilkStrs[i].stringToBytes32();
address spell = fab.deploy(ilk);
ScriptTools.exportContract(NAME, ilkStrs[i], spell);
}
vm.stopBroadcast();
}
}
72 changes: 72 additions & 0 deletions script/SingleLitePsmHaltDeploy.s.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
// SPDX-FileCopyrightText: © 2023 Dai Foundation <www.daifoundation.org>
// SPDX-License-Identifier: AGPL-3.0-or-later
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// 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.16;

import {Script} from "forge-std/Script.sol";
import {stdJson} from "forge-std/StdJson.sol";
import {MCD, DssInstance} from "dss-test/MCD.sol";
import {ScriptTools} from "dss-test/ScriptTools.sol";
import {SingleLitePsmHaltSpellFactory, Flow} from "src/lite-psm-halt/SingleLitePsmHaltSpell.sol";

interface LitePsmLike {
function ilk() external view returns (bytes32);
}

contract SingleLitePsmHaltDeployScript is Script {
using stdJson for string;
using ScriptTools for string;

string constant NAME = "single-lite-psm-halt-deploy";
string config;

SingleLitePsmHaltSpellFactory fab;
address[] litePsms;

function run() external {
config = ScriptTools.loadConfig();

fab = SingleLitePsmHaltSpellFactory(config.readAddress(".factory", "FOUNDRY_FACTORY"));
litePsms = config.readAddressArray(".litePsms", "FOUNDRY_LITE_PSMS");

vm.startBroadcast();

for (uint256 i = 0; i < litePsms.length; i++) {
address litePsm = litePsms[i];
string memory ilkStr = _bytes32ToString(LitePsmLike(litePsm).ilk());
ScriptTools.exportContract(NAME, string.concat(ilkStr, "_SELL"), fab.deploy(litePsm, Flow.SELL));
ScriptTools.exportContract(NAME, string.concat(ilkStr, "_BUY"), fab.deploy(litePsm, Flow.BUY));
ScriptTools.exportContract(NAME, string.concat(ilkStr, "_BOTH"), fab.deploy(litePsm, Flow.BOTH));
}
vm.stopBroadcast();
}

/// @notice Converts a bytes32 value into a string.
function _bytes32ToString(bytes32 src) internal pure returns (string memory res) {
uint256 len = 0;
while (src[len] != 0 && len < 32) {
len++;
}
assembly {
res := mload(0x40)
// new "memory end" including padding (the string isn't larger than 32 bytes)
mstore(0x40, add(res, 0x40))
// store len in memory
mstore(res, len)
// write actual data
mstore(add(res, 0x20), src)
}
}
}
49 changes: 49 additions & 0 deletions script/SingleOsmStopDeploy.s.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
// SPDX-FileCopyrightText: © 2023 Dai Foundation <www.daifoundation.org>
// SPDX-License-Identifier: AGPL-3.0-or-later
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// 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.16;

import {Script} from "forge-std/Script.sol";
import {stdJson} from "forge-std/StdJson.sol";
import {MCD, DssInstance} from "dss-test/MCD.sol";
import {ScriptTools} from "dss-test/ScriptTools.sol";
import {SingleOsmStopFactory} from "src/osm-stop/SingleOsmStopSpell.sol";

contract SingleOsmStopDeployScript is Script {
using stdJson for string;
using ScriptTools for string;

string constant NAME = "single-osm-stop-deploy";
string config;

SingleOsmStopFactory fab;
string[] ilkStrs;

function run() external {
config = ScriptTools.loadConfig();

fab = SingleOsmStopFactory(config.readAddress(".factory", "FOUNDRY_FACTORY"));
ilkStrs = config.readStringArray(".ilks", "FOUNDRY_ILKS");

vm.startBroadcast();

for (uint256 i = 0; i < ilkStrs.length; i++) {
bytes32 ilk = ilkStrs[i].stringToBytes32();
address spell = fab.deploy(ilk);
ScriptTools.exportContract(NAME, ilkStrs[i], spell);
}
vm.stopBroadcast();
}
}
1 change: 1 addition & 0 deletions script/input/1/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Script inputs for Mainnet.
4 changes: 4 additions & 0 deletions script/input/1/template-ddm-disable-deploy.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"factory": "address: the address of the on-chain spell factory",
"ilks": ["ILK-A", "ILK-B"]
}
4 changes: 4 additions & 0 deletions script/input/1/template-single-clip-breaker-deploy.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"factory": "address: the address of the on-chain spell factory",
"ilks": ["ILK-A", "ILK-B"]
}
4 changes: 4 additions & 0 deletions script/input/1/template-single-line-wipe-deploy.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"factory": "address: the address of the on-chain spell factory",
"ilks": ["ILK-A", "ILK-B"]
}
4 changes: 4 additions & 0 deletions script/input/1/template-single-lite-psm-halt-deploy.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"factory": "address: the address of the on-chain spell factory",
"litePsms": ["address: litePsm address"]
}
4 changes: 4 additions & 0 deletions script/input/1/template-single-osm-stop-deploy.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"factory": "address: the address of the on-chain spell factory",
"ilks": ["ILK-A", "ILK-B"]
}
1 change: 1 addition & 0 deletions script/output/1/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Script outputs for Mainnet.

0 comments on commit 3d39ec9

Please sign in to comment.