From 5ee7a892ae9aacedd3fef3ff32524852092b0f29 Mon Sep 17 00:00:00 2001 From: 0xrusowsky <90208954+0xRusowsky@users.noreply.github.com> Date: Tue, 26 Sep 2023 08:50:45 +0200 Subject: [PATCH] style: adapt imports so that etherscan can verify the contracts (#65) --- .gitignore | 3 ++- lib/forge-std | 2 +- src/Cooler.sol | 16 +++++++++++----- src/scripts/Deploy.sol | 21 +++++++++++++++++++++ src/scripts/deploy.sh | 9 +++++++++ 5 files changed, 44 insertions(+), 7 deletions(-) create mode 100644 src/scripts/Deploy.sol create mode 100755 src/scripts/deploy.sh diff --git a/.gitignore b/.gitignore index c7272e3..e94b40e 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ /out /cache -.env \ No newline at end of file +.env +/broadcast \ No newline at end of file diff --git a/lib/forge-std b/lib/forge-std index 74cfb77..705263c 160000 --- a/lib/forge-std +++ b/lib/forge-std @@ -1 +1 @@ -Subproject commit 74cfb77e308dd188d2f58864aaf44963ae6b88b1 +Subproject commit 705263c95892a906d7af65f0f73ce8a4a0c80b80 diff --git a/src/Cooler.sol b/src/Cooler.sol index 3cd34fb..356e341 100644 --- a/src/Cooler.sol +++ b/src/Cooler.sol @@ -5,9 +5,12 @@ import {SafeTransferLib} from "solmate/utils/SafeTransferLib.sol"; import {ERC20} from "solmate/tokens/ERC20.sol"; import {Clone} from "clones/Clone.sol"; -import {IDelegate} from "src/interfaces/IDelegate.sol"; -import {CoolerFactory} from "src/CoolerFactory.sol"; -import {CoolerCallback} from "src/CoolerCallback.sol"; +import {CoolerFactory} from "./CoolerFactory.sol"; +import {CoolerCallback} from "./CoolerCallback.sol"; + +// Function sig taken from gOHM contract +interface IDelegate { function delegate(address to_) external; } + /// @title Cooler Loans. /// @notice A Cooler is a smart contract escrow that facilitates fixed-duration, peer-to-peer @@ -189,7 +192,9 @@ contract Cooler is Clone { factory().logRepayLoan(loanID_, repayment_); // If necessary, trigger lender callback. - if (loan.callback) CoolerCallback(loan.lender).onRepay(loanID_, remainder, interestPaid); + if (loan.callback) { + CoolerCallback(loan.lender).onRepay(loanID_, remainder, interestPaid); + } return decollateralized; } @@ -297,8 +302,9 @@ contract Cooler is Clone { factory().logDefaultLoan(loanID_, loan.collateral); // If necessary, trigger lender callback. - if (loan.callback) + if (loan.callback) { CoolerCallback(loan.lender).onDefault(loanID_, loan.principal, loan.interestDue, loan.collateral); + } return (loan.principal, loan.interestDue, loan.collateral, block.timestamp - loan.expiry); } diff --git a/src/scripts/Deploy.sol b/src/scripts/Deploy.sol new file mode 100644 index 0000000..245cf80 --- /dev/null +++ b/src/scripts/Deploy.sol @@ -0,0 +1,21 @@ +// SPDX-License-Identifier: AGPL-3.0-or-later +pragma solidity ^0.8.15; + +import {Script, console2} from "forge-std/Script.sol"; + +// Cooler Loans +import {CoolerFactory, Cooler} from "src/CoolerFactory.sol"; + +/// @notice Script to deploy and initialize the Olympus system +/// @dev The address that this script is broadcast from must have write access to the contracts being configured +contract Deploy is Script { + // Cooler Loan contracts + CoolerFactory public coolerFactory; + + function deploy() external { + // Deploy a new Cooler Factory implementation + vm.broadcast(); + coolerFactory = new CoolerFactory(); + console2.log("Cooler Factory deployed at:", address(coolerFactory)); + } +} diff --git a/src/scripts/deploy.sh b/src/scripts/deploy.sh new file mode 100755 index 0000000..72571d4 --- /dev/null +++ b/src/scripts/deploy.sh @@ -0,0 +1,9 @@ +#!/bin/bash + +# Load environment variables +source .env + +# Deploy using script +forge script ./src/scripts/Deploy.sol:Deploy --sig "deploy()()" $CHAIN \ +--rpc-url $RPC_URL --private-key $PRIVATE_KEY --froms $DEPLOYER --slow -vvv \ +--broadcast --verify --etherscan-api-key $ETHERSCAN_KEY # uncomment to broadcast to the network \ No newline at end of file