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

Adds patch-package to apply fix for Arbitrum Nitro #701

Merged
merged 1 commit into from
Sep 7, 2022
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
70 changes: 70 additions & 0 deletions deploy/arbitrum/999_impersonate_owners.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
import {
asyncForEach,
impersonateAccount,
setEtherBalance,
} from "../../test/testUtils"

import { DeployFunction } from "hardhat-deploy/types"
import { GenericERC20 } from "../../build/typechain/"
import { HardhatRuntimeEnvironment } from "hardhat/types"
import dotenv from "dotenv"
import { ethers } from "hardhat"
import { isMainnet } from "../../utils/network"
import path from "path"
import { getHardhatTestSigners } from "../../scripts/utils"

dotenv.config()

const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {
const { deployments, getNamedAccounts, getChainId } = hre
const { execute, log, read, all, get } = deployments
const { deployer } = await getNamedAccounts()

// These addresses are for large holders of the given token (used in forked mainnet testing)
// You can find whales' addresses on etherscan's holders page.
// Example: https://etherscan.io/token/0x6b175474e89094c44da98b954eedeac495271d0f#balances
// Note that some addresses may be blacklisted so if the top address didnt work, try another instead.
// key = token deployment name, value = array of addresses
const tokenToAccountsMap: Record<string, string[]> = {
// USD
USDC: ["0x489ee077994B6658eAfA855C308275EAd8097C4A"],
FRAX: ["0x489ee077994b6658eafa855c308275ead8097c4a"],
USDT: ["0x489ee077994b6658eafa855c308275ead8097c4a"],
}

if (
isMainnet(await getChainId()) &&
process.env.HARDHAT_DEPLOY_FORK &&
process.env.FUND_FORK_NETWORK
) {
// Give the deployer tokens from each token holder for testing
for (const [tokenName, holders] of Object.entries(tokenToAccountsMap)) {
const contract = (await ethers.getContract(tokenName)) as GenericERC20

await asyncForEach(holders, async (holder) => {
const balance = await contract.balanceOf(holder)
await setEtherBalance(holder, ethers.constants.WeiPerEther.mul(1000))
await contract
.connect(await impersonateAccount(holder))
.transfer(deployer, await contract.balanceOf(holder))
log(
`Sent ${ethers.utils.formatUnits(
balance,
await contract.decimals(),
)} ${tokenName} from ${holder} to ${deployer}`,
)
})
}
// Give the deployer some ether to use for testing
await setEtherBalance(deployer, ethers.constants.WeiPerEther.mul(1000))
// Give hardhat test account some ether
await setEtherBalance(
await getHardhatTestSigners()[0].getAddress(),
ethers.constants.WeiPerEther.mul(1000),
)
} else {
log(`skipping ${path.basename(__filename)}`)
}
}

export default func
2 changes: 1 addition & 1 deletion deploy/hardhat/999_impersonate_owners.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {

if (
isMainnet(await getChainId()) &&
process.env.FORK_NETWORK &&
process.env.HARDHAT_DEPLOY_FORK &&
process.env.FUND_FORK_NETWORK
) {
// Give the deployer tokens from each token holder for testing
Expand Down
2 changes: 1 addition & 1 deletion deploy/mainnet/599_multisig_actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {
const { deploy, get, getOrNull, execute, read, log } = deployments

// If we are not on forked mainnet, skip this file
if (process.env.FORK_NETWORK !== "mainnet") {
if (process.env.HARDHAT_DEPLOY_FORK !== "mainnet") {
log(`Not running on forked mainnet, skipping...`)
return
}
Expand Down
2 changes: 1 addition & 1 deletion deploy/mainnet/999_impersonate_owners.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {

if (
isMainnet(await getChainId()) &&
process.env.FORK_NETWORK &&
process.env.HARDHAT_DEPLOY_FORK &&
process.env.FUND_FORK_NETWORK
) {
// Give the deployer tokens from each token holder for testing
Expand Down
Loading