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

Deploy pyusd #1190

Merged
merged 8 commits into from
Sep 10, 2024
Merged
Show file tree
Hide file tree
Changes from 2 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
6 changes: 3 additions & 3 deletions hardhat.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ const BASE_RPC_URL = useEnv('BASE_RPC_URL')
const ARBITRUM_SEPOLIA_RPC_URL = useEnv('ARBITRUM_SEPOLIA_RPC_URL')
const ARBITRUM_RPC_URL = useEnv('ARBITRUM_RPC_URL')
const MNEMONIC = useEnv('MNEMONIC') || 'test test test test test test test test test test test junk'
const DEPLOYER_PK = useEnv('DEPLOYER_PK')
const TIMEOUT = useEnv('SLOW') ? 6_000_000 : 600_000

const src_dir = `./contracts/${useEnv('PROTO')}`
Expand All @@ -47,6 +48,7 @@ const config: HardhatUserConfig = {
gas: 0x1ffffffff,
blockGasLimit: 0x1fffffffffffff,
allowUnlimitedContractSize: true,
accounts: [{privateKey: DEPLOYER_PK, balance: '100000000000000000'}],
},
localhost: {
// network for long-lived mainnet forks
Expand Down Expand Up @@ -81,9 +83,7 @@ const config: HardhatUserConfig = {
mainnet: {
chainId: 1,
url: MAINNET_RPC_URL,
accounts: {
mnemonic: MNEMONIC,
},
accounts: [DEPLOYER_PK],
pmckelvy1 marked this conversation as resolved.
Show resolved Hide resolved
pmckelvy1 marked this conversation as resolved.
Show resolved Hide resolved
// gasPrice: 30_000_000_000,
gasMultiplier: 2, // 100% buffer; seen failures on RToken deployment and asset refreshes otherwise
},
Expand Down
8 changes: 5 additions & 3 deletions scripts/addresses/1-tmp-assets-collateral.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
"stkAAVE": "0xF4493581D52671a9E04d693a68ccc61853bceEaE",
"COMP": "0x63eDdF26Bc65eDa1D1c0147ce8E23c09BE963596",
"CRV": "0xc18bF46F178F7e90b9CD8b7A8b00Af026D5ce3D3",
"CVX": "0x7ef93b20C10E6662931b32Dd9D4b85861eB2E4b8"
"CVX": "0x7ef93b20C10E6662931b32Dd9D4b85861eB2E4b8",
"pyUSD": "0x7622D205b88e5fB7030E5D717ade7202592B31ab"
},
"collateral": {
"DAI": "0xEc375F2984D21D5ddb0D82767FD8a9C4CE8Eec2F",
Expand Down Expand Up @@ -121,6 +122,7 @@
"CRV": "0xD533a949740bb3306d119CC777fa900bA034cd52",
"CVX": "0x4e3FBD56CD56c3e72c1403e103b45Db9da5B9D2B",
"apxETH": "0x9Ba021B0a9b958B5E75cE9f6dff97C7eE52cb3E6",
"sUSDe": "0x9D39A5DE30e57443BfF2A8307A4256c8797A3497"
"sUSDe": "0x9D39A5DE30e57443BfF2A8307A4256c8797A3497",
"pyUSD": "0x6c3ea9036406852006290770bedfcaba0e23a0e8"
}
}
}
3 changes: 2 additions & 1 deletion scripts/deploy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,8 @@ async function main() {
'phase2-assets/collaterals/deploy_apxeth.ts',
'phase2-assets/collaterals/deploy_USDe.ts',
'phase2-assets/assets/deploy_crv.ts',
'phase2-assets/assets/deploy_cvx.ts'
'phase2-assets/assets/deploy_cvx.ts',
'phase2-assets/assets/deploy_pyUSD.ts'
pmckelvy1 marked this conversation as resolved.
Show resolved Hide resolved
)
} else if (chainId == '8453' || chainId == '84531') {
// Base L2 chains
Expand Down
71 changes: 71 additions & 0 deletions scripts/deployment/phase2-assets/assets/deploy_pyusd.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
import fs from 'fs'
import hre, { ethers } from 'hardhat'
import { getChainId } from '../../../../common/blockchain-utils'
import { arbitrumL2Chains, baseL2Chains, networkConfig } from '../../../../common/configuration'
import { fp } from '../../../../common/numbers'
import {
getDeploymentFile,
getDeploymentFilename,
getAssetCollDeploymentFilename,
IAssetCollDeployments,
fileExists,
} from '../../../deployment/common'
import { priceTimeout } from '../../../deployment/utils'
import { Asset } from '../../../../typechain'

async function main() {
// ==== Read Configuration ====
const [burner] = await hre.ethers.getSigners()
const chainId = await getChainId(hre)

console.log(`Deploying pyUSD asset to network ${hre.network.name} (${chainId})
with burner account: ${burner.address}`)

if (!networkConfig[chainId]) {
throw new Error(`Missing network configuration for ${hre.network.name}`)
}

// Only exists on Mainnet
if (baseL2Chains.includes(hre.network.name) || arbitrumL2Chains.includes(hre.network.name)) {
throw new Error(`Invalid network ${hre.network.name} - only available on Mainnet`)
}

// Get phase1 deployment
const phase1File = getDeploymentFilename(chainId)
if (!fileExists(phase1File)) {
throw new Error(`${phase1File} doesn't exist yet. Run phase 1`)
}
// Check previous step completed
const assetCollDeploymentFilename = getAssetCollDeploymentFilename(chainId)
const assetCollDeployments = <IAssetCollDeployments>getDeploymentFile(assetCollDeploymentFilename)

const deployedAssets: string[] = []

/******** Deploy pyUSD asset **************************/
const { asset: pyUSDAsset } = await hre.run('deploy-asset', {
priceTimeout: priceTimeout.toString(),
priceFeed: networkConfig[chainId].chainlinkFeeds.pyUSD,
oracleError: fp('0.003').toString(), // 0.3%
tokenAddress: networkConfig[chainId].tokens.pyUSD,
maxTradeVolume: fp('1e6').toString(), // $1m,
oracleTimeout: '86400', // 24 hr
})
await (<Asset>await ethers.getContractAt('Asset', pyUSDAsset)).refresh()

assetCollDeployments.assets.pyUSD = pyUSDAsset
assetCollDeployments.erc20s.pyUSD = networkConfig[chainId].tokens.pyUSD
deployedAssets.push(pyUSDAsset.toString())

/**************************************************************/

fs.writeFileSync(assetCollDeploymentFilename, JSON.stringify(assetCollDeployments, null, 2))

console.log(`Deployed pyUSD asset to ${hre.network.name} (${chainId}):
New deployments: ${deployedAssets}
Deployment file: ${assetCollDeploymentFilename}`)
}

main().catch((error) => {
console.error(error)
process.exitCode = 1
})
45 changes: 45 additions & 0 deletions scripts/verification/assets/verify_pyusd.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
import hre from 'hardhat'

import { getChainId } from '../../../common/blockchain-utils'
import { developmentChains, networkConfig } from '../../../common/configuration'
import { getAssetCollDeploymentFilename, getDeploymentFile, getDeploymentFilename, IAssetCollDeployments, IDeployments } from '../../deployment/common'
import { verifyContract } from '../../deployment/utils'
import { fp } from '../../../common/numbers'

let deployments: IAssetCollDeployments

async function main() {
// ********** Read config **********
const chainId = await getChainId(hre)
if (!networkConfig[chainId]) {
throw new Error(`Missing network configuration for ${hre.network.name}`)
}

if (developmentChains.includes(hre.network.name)) {
throw new Error(`Cannot verify contracts for development chain ${hre.network.name}`)
}

deployments = <IAssetCollDeployments>getDeploymentFile(getAssetCollDeploymentFilename(chainId))

const asset = await hre.ethers.getContractAt('Asset', deployments.assets.pyUSD!)

/** ******************** Verify RSR Asset ****************************************/
pmckelvy1 marked this conversation as resolved.
Show resolved Hide resolved
await verifyContract(
chainId,
deployments.assets.pyUSD,
[
(await asset.priceTimeout()).toString(),
await asset.chainlinkFeed(),
fp('0.003').toString(),
await asset.erc20(),
(await asset.maxTradeVolume()).toString(),
(await asset.oracleTimeout()).toString(),
],
'contracts/plugins/assets/Asset.sol:Asset'
)
}

main().catch((error) => {
console.error(error)
process.exitCode = 1
})
1 change: 1 addition & 0 deletions utils/env.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ type IEnvVars =
| 'FORK_NETWORK'
| 'FORK_BLOCK'
| 'FORCE_WHALE_REFRESH'
| 'DEPLOYER_PK'

export function useEnv(key: IEnvVars | IEnvVars[], _default = ''): string {
if (typeof key === 'string') {
Expand Down
Loading