Skip to content
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
4 changes: 1 addition & 3 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,8 @@ ARBITRUM_SEPOLIA_RPC_URL="https://arb-sepolia.g.alchemy.com/v2/your_arbitrum_sep
# Mnemonic, first address will be used for deployments
MNEMONIC='copy here your mnemonic words'

# Etherscan API - for contract verification
# Etherscan API - for contract verification (multichain)
ETHERSCAN_API_KEY=ABC123ABC123ABC123ABC123ABC123ABC1
BASESCAN_API_KEY=ABC123ABC123ABC123ABC123ABC123ABC1
ARBISCAN_API_KEY=ABC123ABC123ABC123ABC123ABC123ABC1

# WARNING: all of the following will make SLOW a truthy value:
# SLOW=0
Expand Down
45 changes: 3 additions & 42 deletions hardhat.config.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import 'tsconfig-paths/register'
import '@nomicfoundation/hardhat-toolbox'
import '@nomicfoundation/hardhat-chai-matchers'
import '@nomicfoundation/hardhat-verify'
import '@nomiclabs/hardhat-ethers'
import '@nomiclabs/hardhat-etherscan'
import '@openzeppelin/hardhat-upgrades'
import '@typechain/hardhat'
import 'hardhat-contract-sizer'
Expand Down Expand Up @@ -170,46 +169,8 @@ const config: HardhatUserConfig = {
enabled: !!useEnv('REPORT_GAS'),
},
etherscan: {
apiKey: {
mainnet: useEnv('ETHERSCAN_API_KEY'),
base: useEnv('BASESCAN_API_KEY'),
arbitrum: useEnv('ARBISCAN_API_KEY'),
'arbitrum-sepolia': useEnv('ARBISCAN_API_KEY'),
},
customChains: [
{
network: 'base',
chainId: 8453,
urls: {
apiURL: 'https://api.basescan.org/api',
browserURL: 'https://basescan.org',
},
},
{
network: 'base-goerli',
chainId: 84531,
urls: {
apiURL: 'https://api-goerli.basescan.org/api',
browserURL: 'https://goerli.basescan.org',
},
},
{
network: 'arbitrum',
chainId: 42161,
urls: {
apiURL: 'https://api.arbiscan.io/api',
browserURL: 'https://arbiscan.io',
},
},
{
network: 'arbitrum-sepolia',
chainId: 421614,
urls: {
apiURL: 'https://api-sepolia.arbiscan.io/api',
browserURL: 'https://sepolia.arbiscan.io',
},
},
],
enabled: true,
apiKey: useEnv('ETHERSCAN_API_KEY'),
},
// tenderly: {
// // see https://github.com/Tenderly/hardhat-tenderly/tree/master/packages/tenderly-hardhat for details
Expand Down
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,10 @@
"@chainlink/contracts": "^0.5.1",
"@ethersproject/providers": "^5.7.2",
"@nomicfoundation/hardhat-chai-matchers": "^1.0.6",
"@nomicfoundation/hardhat-ethers": "^3.1.0",
"@nomicfoundation/hardhat-network-helpers": "^1.0.8",
"@nomicfoundation/hardhat-toolbox": "^2.0.1",
"@nomiclabs/hardhat-ethers": "^2.2.3",
"@nomiclabs/hardhat-etherscan": "^3.1.0",
"@nomicfoundation/hardhat-verify": "^2.1.1",
"@openzeppelin/contracts": "4.9.6",
"@openzeppelin/contracts-upgradeable": "4.9.6",
"@openzeppelin/hardhat-upgrades": "^1.23.0",
Expand Down Expand Up @@ -92,7 +92,7 @@
"fast-check": "^2.24.0",
"graphql": "^16.6.0",
"graphql-request": "^5.2.0",
"hardhat": "^2.22.19",
"hardhat": "^2.26.0",
"hardhat-contract-sizer": "^2.4.0",
"hardhat-gas-reporter": "^1.0.8",
"husky": "^7.0.0",
Expand Down
4 changes: 2 additions & 2 deletions scripts/addresses/1-tmp-assets-collateral.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
"cvxPayPool": "0x5315Fbe0CEB299F53aE375f65fd9376767C8224c",
"cvxeUSDFRAXBP": "0x994455cE66Fd984e2A0A0aca453e637810a8f032",
"cvxMIM3Pool": "0x3d21f841C0Fb125176C1DBDF0DE196b071323A75",
"cvxETHPlusETH": "0x05F164E71C46a8f8FB2ba71550a00eeC9FCd85cd",
"cvxETHPlusETH": "0xcB275C9D871f21Be67a4E4a25dc2781BfFD627c4",
"crveUSDFRAXBP": "0xCDC5f5E041b49Cad373E94930E2b3bE30be70535",
"crvMIM3Pool": "0x692cf8CE08d03eF1f8C3dCa82F67935fa9417B62",
"crv3Pool": "0xf59a7987EDd5380cbAb30c37D1c808686f9b67B9",
Expand Down Expand Up @@ -100,7 +100,7 @@
"cvxPayPool": "0x511daB8150966aFfE15F0a5bFfBa7F4d2b62DEd4",
"cvxeUSDFRAXBP": "0x81697e25DFf8564d9E0bC6D27edb40006b34ea2A",
"cvxMIM3Pool": "0x3e8f7EDc03E0133b95EcB4dD2f72B5027E695413",
"cvxETHPlusETH": "0xDbC0cE2321B76D3956412B36e9c0FA9B0fD176E7",
"cvxETHPlusETH": "0x767F8655cb8e81064954C65e126028C4a733dCd8",
"crv3Pool": "0x8A6029C6D921dCa4fAbf6F5b2F6D14606F8Fd0aB",
"crveUSDFRAXBP": "0x3D07B9b2Aa60843470e6dAb09a0c3a31DE42E7Ea",
"crvMIM3Pool": "0xB1d0076d156D83B117De3bc63E7CE8031AB117fD",
Expand Down
6 changes: 4 additions & 2 deletions scripts/addresses/mainnet-4.0.0/1-tmp-assets-collateral.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,15 @@
"cUSDTv3": "0x1B2256a88Bb9F2E54cC8D355D3161a2F069a320B",
"sUSDS": "0xaFf578165bEA370D16d8AC61A4C8c6D435785d58",
"saEthUSDT": "0x18A8D9088433aE749cE6c33070b2Fe95e8a263d9",
"wOETH": "0xD9Ee6fEb2a277E5948B6Fd6B93d125B3225339aA"
"wOETH": "0xD9Ee6fEb2a277E5948B6Fd6B93d125B3225339aA",
"cvxETHPlusETH": "0xcB275C9D871f21Be67a4E4a25dc2781BfFD627c4"
},
"erc20s": {
"ETHx": "0xA35b1B31Ce002FBF2058D22F30f95D405200A15b",
"cUSDTv3": "0xEB74EC1d4C1DAB412D5d6674F6833FD19d3118Ce",
"sUSDS": "0xa3931d71877C0E7a3148CB7Eb4463524FEc27fbD",
"saEthUSDT": "0x7133EbCb1a23e3d8Be7Ff09362b02b2A2e4c3dA4",
"wOETH": "0xDcEe70654261AF21C44c093C300eD3Bb97b78192"
"wOETH": "0xDcEe70654261AF21C44c093C300eD3Bb97b78192",
"cvxETHPlusETH": "0x767F8655cb8e81064954C65e126028C4a733dCd8"
}
}
55 changes: 34 additions & 21 deletions scripts/deployment/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -109,27 +109,13 @@ export async function verifyContract(
// Sleep 0.5s to not overwhelm API
await new Promise((r) => setTimeout(r, 500))

// Etherscan v2 Multichain API KEY
const ETHERSCAN_API_KEY = useEnv('ETHERSCAN_API_KEY')

let url: string
if (baseL2Chains.includes(hre.network.name)) {
const BASESCAN_API_KEY = useEnv('BASESCAN_API_KEY')
// Base L2
url = `${getVerificationURL(
chainId
)}?module=contract&action=getsourcecode&address=${address}&apikey=${BASESCAN_API_KEY}`
} else if (arbitrumL2Chains.includes(hre.network.name)) {
const ARBISCAN_API_KEY = useEnv('ARBISCAN_API_KEY')
// Arbitrum L2
url = `${getVerificationURL(
chainId
)}?module=contract&action=getsourcecode&address=${address}&apikey=${ARBISCAN_API_KEY}`
} else {
// Ethereum
url = `${getVerificationURL(
chainId
)}/api?module=contract&action=getsourcecode&address=${address}&apikey=${ETHERSCAN_API_KEY}`
}
url = `${getVerificationURL(
chainId
)}/api?chainid=${chainId}&module=contract&action=getsourcecode&address=${address}&apikey=${ETHERSCAN_API_KEY}`

// Check to see if already verified
const { data, status } = await axios.get(url, { headers: { Accept: 'application/json' } })
Expand All @@ -153,7 +139,7 @@ export async function verifyContract(
} catch (e) {
console.log(
`IMPORTANT: failed to verify ${contract}.
${getVerificationURL(chainId)}/address/${address}#code`,
${getExplorerURL(chainId)}/address/${address}#code`,
e
)
}
Expand All @@ -163,16 +149,43 @@ export async function verifyContract(
}

export const getVerificationURL = (chainId: number) => {
if (chainId == 1) return 'https://api.etherscan.io'
const supportedChains = [1, 56, 8453, 84531, 42161, 421614]

// Use Etherscan V2 for all supported chains
if (supportedChains.includes(Number(chainId))) {
return 'https://api.etherscan.io/v2'
}

// For Base, get URL from HH config
// For other chains, get URL from HH config (if defined)
const chainConfig = hre.config.etherscan.customChains.find((chain) => chain.chainId == chainId)
if (!chainConfig || !chainConfig.urls) {
throw new Error(`Missing custom chain configuration for ${hre.network.name}`)
}
return `${chainConfig.urls.apiURL}`
}

export const getExplorerURL = (chainId: number) => {
const explorers: Record<number, string> = {
1: 'https://etherscan.io/', // Ethereum Mainnet
56: 'https://bscscan.com/', // BNB Smart Chain Mainnet
8453: 'https://basescan.org/', // Base Mainnet
84531: 'https://sepolia.basescan.org/', // Base Sepolia Testnet
42161: 'https://arbiscan.io/', // Arbitrum One Mainnet
421614: 'https://sepolia.arbiscan.io/', // Arbitrum Sepolia Testnet
}

// Return explorer URL if defined
const explorer = explorers[chainId]
if (explorer) return explorer

// For other chains, get URL from HH config (if defined)
const chainConfig = hre.config.etherscan.customChains.find((chain) => chain.chainId == chainId)
if (!chainConfig || !chainConfig.urls) {
throw new Error(`Missing custom chain configuration for ${hre.network.name}`)
}
return `${chainConfig.urls.browserURL}`
}

export const getEmptyDeployment = (): IDeployments => {
return {
prerequisites: {
Expand Down
1 change: 0 additions & 1 deletion scripts/refresh-whales.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import { useEnv } from '#/utils/env'

// set to true to force a refresh of all whales
const FORCE_REFRESH = useEnv('FORCE_WHALE_REFRESH')
const BASESCAN_API_KEY = useEnv('BASESCAN_API_KEY')
const FORK_NETWORK = useEnv('FORK_NETWORK')

const SCANNER_URLS: { [key: string]: string } = {
Expand Down
9 changes: 4 additions & 5 deletions tasks/deployment/get-addresses.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,15 +34,14 @@ task('get-addys', 'Compile the deployed addresses of an RToken deployment')
const chainId = await getChainId(hre)
const network: Network = hre.network.name as Network
let scannerUrl: string
let scannerApiUrl: string
let scannerApiUrl = `https://api.etherscan.io/v2/api?chainid=${chainId}`

switch (network) {
case 'mainnet':
scannerUrl = 'https://etherscan.io/address/'
scannerApiUrl = `https://api.etherscan.io/api`
break
case 'base':
scannerUrl = 'https://basescan.org/address/'
scannerApiUrl = `https://api.basescan.org/api`
break
default:
throw new Error(`Unsupported network: ${network}`)
Expand All @@ -57,7 +56,7 @@ task('get-addys', 'Compile the deployed addresses of an RToken deployment')
}

const createRTokenTableRow = async (name: string, address: string) => {
const url = `${scannerApiUrl}?module=contract&action=getsourcecode&address=${address}&apikey=${process.env.ETHERSCAN_API_KEY}`
const url = `${scannerApiUrl}&module=contract&action=getsourcecode&address=${address}&apikey=${process.env.ETHERSCAN_API_KEY}`
await delay(200)
const response = await fetch(url)
const data = await response.json()
Expand All @@ -73,7 +72,7 @@ task('get-addys', 'Compile the deployed addresses of an RToken deployment')
}

const createComponentTableRow = async (name: string, address: string) => {
const url = `${scannerApiUrl}?module=contract&action=getsourcecode&address=${address}&apikey=${process.env.ETHERSCAN_API_KEY}`
const url = `${scannerApiUrl}&module=contract&action=getsourcecode&address=${address}&apikey=${process.env.ETHERSCAN_API_KEY}`
await delay(200)
const response = await fetch(url)
const data = await response.json()
Expand Down
2 changes: 0 additions & 2 deletions utils/env.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@ type IEnvVars =
| 'PROTO'
| 'PROTO_IMPL'
| 'ETHERSCAN_API_KEY'
| 'BASESCAN_API_KEY'
| 'ARBISCAN_API_KEY'
| 'NO_OPT'
| 'ONLY_FAST'
| 'JOBS'
Expand Down
Loading
Loading