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 deploy script & testing for Investor.sol #319

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
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
45 changes: 36 additions & 9 deletions contracts/vesting/Investor.sol
Original file line number Diff line number Diff line change
Expand Up @@ -43,21 +43,24 @@ contract InvestorClaimV2 is Ownable {
}

/* ========== STATE VARIABLES ========== */

/*
the below defaults are the accurate internal variables for mainnet.
we changed the variables so that they could be added in the constructor for test nets.
*/
// claim token
IERC20 internal immutable ohm = IERC20(0x64aa3364F17a4D01c6f1751Fd97C2BD3D7e7f1D5);
IERC20 internal ohm = IERC20(0x64aa3364F17a4D01c6f1751Fd97C2BD3D7e7f1D5);
// payment token
IERC20 internal immutable dai = IERC20(0x6B175474E89094C44Da98b954EedeAC495271d0F);
IERC20 internal dai = IERC20(0x6B175474E89094C44Da98b954EedeAC495271d0F);
// mints claim token
ITreasury internal immutable treasury = ITreasury(0x9A315BdF513367C0377FB36545857d12e85813Ef);
ITreasury internal treasury = ITreasury(0x9A315BdF513367C0377FB36545857d12e85813Ef);
// stake OHM for sOHM
IStaking internal immutable staking = IStaking(0xB63cac384247597756545b500253ff8E607a8020);
IStaking internal staking = IStaking(0xB63cac384247597756545b500253ff8E607a8020);
// holds non-circulating supply
address internal immutable dao = 0x245cc372C84B3645Bf0Ffe6538620B04a217988B;
address internal dao = 0x245cc372C84B3645Bf0Ffe6538620B04a217988B;
// tracks rebase-agnostic balance
IgOHM internal immutable gOHM = IgOHM(0x0ab87046fBb341D058F17CBC4c1133F25a20a52f);
IgOHM internal gOHM = IgOHM(0x0ab87046fBb341D058F17CBC4c1133F25a20a52f);
// previous deployment of contract (to migrate terms)
IClaim internal immutable previous = IClaim(0xcD4B3c7B746161f0E54bc9a23307CE222a2bF081);
IClaim internal previous = IClaim(0xcD4B3c7B746161f0E54bc9a23307CE222a2bF081);

// tracks address info
mapping(address => Term) public terms;
Expand All @@ -68,7 +71,31 @@ contract InvestorClaimV2 is Ownable {
// maximum portion of supply can allocate. == 4%
uint256 public maximumAllocated = 40000;

constructor() {}
/// @dev adjust constructor to declare OHM, DAI, TREASURY, STAKING, DAO, gOHM, ICLAIM
constructor(
address ohmAd,
address daiAd,
address treasuryAd,
address stakingAd,
address daoAd,
address gohmAd,
address claimAd
) {
// claim token
ohm = IERC20(ohmAd);
// payment token
dai = IERC20(daiAd);
// mints claim token
treasury = ITreasury(treasuryAd);
// stake OHM for sOHM
staking = IStaking(stakingAd);
// holds non-circulating supply
dao = daoAd;
// tracks rebase-agnostic balance
gOHM = IgOHM(gohmAd);
// previous deployment of contract (to migrate terms)
previous = IClaim(claimAd);
}

/* ========== MUTABLE FUNCTIONS ========== */

Expand Down
98 changes: 98 additions & 0 deletions scripts/deploy/testnet/002_investor_pohm.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
import { ethers } from "hardhat";

/**
* This deploy script will deploy a simple, isolated Investor contract.
* It would be less code if the additional deployments required for Investor used
* the hre, but... I think it's simpler on the dev to use this isolated deployment
* where previous hre deployments are immaterial.
*/
async function main () {
const [owner] = await ethers.getSigners();

// deploy Authority
const Authority = await ethers.getContractFactory('OlympusAuthority');
console.log('Deploying Authority...');
const authority = await Authority.deploy(owner.address, owner.address, owner.address, owner.address);
await authority.deployed();
console.log('authority deployed to:', authority.address);

// deploy OHM
const OHM = await ethers.getContractFactory('OlympusERC20Token');
console.log('Deploying OHM...');
const ohm = await OHM.deploy(authority.address);
await ohm.deployed();
console.log('ohm deployed to:', ohm.address);

// sohm
const SOHM = await ethers.getContractFactory("sOlympus");
const sOHM = await SOHM.deploy();
console.log('sOHM deployed to:', sOHM.address);

// gohm
const GOHM = await ethers.getContractFactory("gOHM");
const gOHM = await GOHM.deploy(owner.address, sOHM.address);
console.log('gOHM deployed to:', gOHM.address);

// // deploy Staking
const firstEpochNumber = "550";
const firstBlockNumber = "9505000";
const Staking = await ethers.getContractFactory('OlympusStaking');
console.log('Deploying Staking...');
const staking = await Staking.deploy(
ohm.address,
sOHM.address,
gOHM.address,
"2200",
firstEpochNumber,
firstBlockNumber,
authority.address
);
await staking.deployed();
console.log('staking deployed to:', staking.address);

// migrate gOHM
await gOHM.migrate(staking.address, sOHM.address);

// deploy DAI
const DAI = await ethers.getContractFactory('DAI');
console.log('Deploying DAI...');
const dai = await DAI.deploy(1337);
await dai.deployed();
console.log('dai deployed to:', dai.address);

// deploy Treasury
const Treasury = await ethers.getContractFactory('OlympusTreasury');
console.log('Deploying Treasury...');
const treasury = await Treasury.deploy(ohm.address, 0, authority.address);
await treasury.deployed();
console.log('treasury deployed to:', treasury.address);

await authority.pushVault(treasury.address, true);
// // dao
const daoAddress = owner.address;

// // claim
const claimAddress = owner.address;

// // deploy Investor
const Investor = await ethers.getContractFactory('InvestorClaimV2');
console.log('Deploying OHM...');
const investor = await Investor.deploy(
ohm.address,
dai.address,
treasury.address,
staking.address,
daoAddress,
gOHM.address,
claimAddress
);
await investor.deployed();
console.log('investor deployed to:', investor.address);
};

main()
.then(() => process.exit(0))
.catch(error => {
console.error(error);
process.exit(1);
});
Loading