Skip to content

Commit

Permalink
feat: Deploy to prod (SC-787) (#46)
Browse files Browse the repository at this point in the history
* feat: add initital script

* forge install: spark-address-registry

* feat: initial setup working

* feat: update sub and use usdc
lucas-manuel authored Oct 23, 2024
1 parent 6a5a579 commit 3c5a8aa
Showing 6 changed files with 44 additions and 6 deletions.
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -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
2 changes: 2 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
.PHONY: deploy
deploy :; forge script script/Deploy.s.sol:DeployPSM3 --sender ${ETH_FROM} --broadcast --slow --verify
4 changes: 2 additions & 2 deletions deploy/PSM3Deploy.sol
Original file line number Diff line number Diff line change
@@ -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);
}

}
1 change: 1 addition & 0 deletions lib/spark-address-registry
Submodule spark-address-registry added at 655597
32 changes: 32 additions & 0 deletions script/Deploy.s.sol
Original file line number Diff line number Diff line change
@@ -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);
}

}
8 changes: 4 additions & 4 deletions test/unit/Deployment.t.sol
Original file line number Diff line number Diff line change
@@ -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);

0 comments on commit 3c5a8aa

Please sign in to comment.