Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add L2 deploy function and L2 audit reports #19

Merged
merged 2 commits into from
Oct 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file not shown.
Binary file not shown.
14 changes: 13 additions & 1 deletion deploy/UsdsDeploy.sol
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import { Usds } from "src/Usds.sol";
import { UsdsJoin } from "src/UsdsJoin.sol";
import { DaiUsds } from "src/DaiUsds.sol";

import { UsdsInstance } from "./UsdsInstance.sol";
import { UsdsInstance, UsdsL2Instance } from "./UsdsInstance.sol";

interface DaiJoinLike {
function vat() external view returns (address);
Expand All @@ -47,4 +47,16 @@ library UsdsDeploy {
instance.usdsJoin = _usdsJoin;
instance.daiUsds = _daiUsds;
}

function deployL2(
address deployer,
address owner
) internal returns (UsdsL2Instance memory instance) {
address _usdsImp = address(new Usds());
address _usds = address((new ERC1967Proxy(_usdsImp, abi.encodeCall(Usds.initialize, ()))));
ScriptTools.switchOwner(_usds, deployer, owner);

instance.usds = _usds;
instance.usdsImp = _usdsImp;
}
}
5 changes: 5 additions & 0 deletions deploy/UsdsInstance.sol
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,8 @@ struct UsdsInstance {
address usdsJoin;
address daiUsds;
}

struct UsdsL2Instance {
address usds;
address usdsImp;
}
43 changes: 43 additions & 0 deletions test/L2Deployment.t.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
// SPDX-FileCopyrightText: © 2024 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.21;

import "dss-test/DssTest.sol";

import { Upgrades } from "openzeppelin-foundry-upgrades/Upgrades.sol";

import { UsdsL2Instance } from "deploy/UsdsInstance.sol";
import { UsdsDeploy } from "deploy/UsdsDeploy.sol";

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

contract L2DeploymentTest is DssTest {

address l2GovRelay = address(222);
UsdsL2Instance inst;

function setUp() public {
inst = UsdsDeploy.deployL2(address(this), l2GovRelay);
}

function testSetUp() public view {
assertEq(Usds(inst.usds).wards(l2GovRelay), 1);
assertEq(Usds(inst.usds).wards(address(this)), 0);
assertEq(Upgrades.getImplementationAddress(inst.usds), inst.usdsImp);
assertEq(Usds(inst.usds).version(), "1");
}
}
Loading