From 3c5a8aa28e0ef424b31c7dd62561648a88bc402d Mon Sep 17 00:00:00 2001 From: Lucas Manuel Date: Wed, 23 Oct 2024 10:36:58 -0400 Subject: [PATCH] feat: Deploy to prod (SC-787) (#46) * feat: add initital script * forge install: spark-address-registry * feat: initial setup working * feat: update sub and use usdc --- .gitmodules | 3 +++ Makefile | 2 ++ deploy/PSM3Deploy.sol | 4 ++-- lib/spark-address-registry | 1 + script/Deploy.s.sol | 32 ++++++++++++++++++++++++++++++++ test/unit/Deployment.t.sol | 8 ++++---- 6 files changed, 44 insertions(+), 6 deletions(-) create mode 100644 Makefile create mode 160000 lib/spark-address-registry create mode 100644 script/Deploy.s.sol diff --git a/.gitmodules b/.gitmodules index fc05ab8..0421da2 100644 --- a/.gitmodules +++ b/.gitmodules @@ -10,3 +10,6 @@ [submodule "lib/xchain-ssr-oracle"] path = lib/xchain-ssr-oracle url = https://github.com/marsfoundation/xchain-ssr-oracle +[submodule "lib/spark-address-registry"] + path = lib/spark-address-registry + url = https://github.com/marsfoundation/spark-address-registry diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..bbce73e --- /dev/null +++ b/Makefile @@ -0,0 +1,2 @@ +.PHONY: deploy +deploy :; forge script script/Deploy.s.sol:DeployPSM3 --sender ${ETH_FROM} --broadcast --slow --verify diff --git a/deploy/PSM3Deploy.sol b/deploy/PSM3Deploy.sol index 0399960..23a6801 100644 --- a/deploy/PSM3Deploy.sol +++ b/deploy/PSM3Deploy.sol @@ -18,8 +18,8 @@ library PSM3Deploy { { psm = address(new PSM3(owner, usdc, usds, susds, rateProvider)); - IERC20(usds).approve(psm, 1e18); - PSM3(psm).deposit(usds, address(0), 1e18); + IERC20(usdc).approve(psm, 1e6); + PSM3(psm).deposit(usdc, address(0), 1e6); } } diff --git a/lib/spark-address-registry b/lib/spark-address-registry new file mode 160000 index 0000000..655597a --- /dev/null +++ b/lib/spark-address-registry @@ -0,0 +1 @@ +Subproject commit 655597a8bd8d6c1d1b18d3f5da7ecbabfe920c5d diff --git a/script/Deploy.s.sol b/script/Deploy.s.sol new file mode 100644 index 0000000..d86c3f5 --- /dev/null +++ b/script/Deploy.s.sol @@ -0,0 +1,32 @@ +// SPDX-License-Identifier: AGPL-3.0 +pragma solidity ^0.8.0; + +import "forge-std/Script.sol"; + +import { Base } from "lib/spark-address-registry/src/Base.sol"; + +import { PSM3Deploy } from "deploy/PSM3Deploy.sol"; + +contract DeployPSM3 is Script { + + function run() external { + vm.createSelectFork(getChain("base").rpcUrl); + + console.log("Deploying PSM..."); + + vm.startBroadcast(); + + address psm = PSM3Deploy.deploy({ + owner : Base.SPARK_EXECUTOR, + usdc : Base.USDC, + usds : Base.USDS, + susds : Base.SUSDS, + rateProvider : Base.SSR_AUTH_ORACLE + }); + + vm.stopBroadcast(); + + console.log("PSM3 deployed at:", psm); + } + +} diff --git a/test/unit/Deployment.t.sol b/test/unit/Deployment.t.sol index 54516fb..9eae29b 100644 --- a/test/unit/Deployment.t.sol +++ b/test/unit/Deployment.t.sol @@ -12,7 +12,7 @@ import { PSMTestBase } from "test/PSMTestBase.sol"; contract PSMDeployTests is PSMTestBase { function test_deploy() public { - deal(address(usds), address(this), 1e18); + deal(address(usdc), address(this), 1e6); PSM3 newPsm = PSM3(PSM3Deploy.deploy( address(owner), @@ -28,10 +28,10 @@ contract PSMDeployTests is PSMTestBase { assertEq(address(newPsm.susds()), address(susds)); assertEq(address(newPsm.rateProvider()), address(rateProvider)); - assertEq(usds.allowance(address(this), address(newPsm)), 0); + assertEq(usdc.allowance(address(this), address(newPsm)), 0); - assertEq(usds.balanceOf(address(this)), 0); - assertEq(usds.balanceOf(address(newPsm)), 1e18); + assertEq(usdc.balanceOf(address(this)), 0); + assertEq(usdc.balanceOf(address(newPsm)), 1e6); assertEq(newPsm.totalAssets(), 1e18); assertEq(newPsm.totalShares(), 1e18);