Skip to content

Commit

Permalink
add usdc market on scroll mainnet
Browse files Browse the repository at this point in the history
  • Loading branch information
isabellewei committed Jan 25, 2024
1 parent 23de1e8 commit 3bde642
Show file tree
Hide file tree
Showing 14 changed files with 223 additions and 12 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/deploy-market.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ on:
- base-goerli
- linea-goerli
- scroll-goerli
- scroll
deployment:
description: Deployment Name (e.g. "usdc")
required: true
Expand Down Expand Up @@ -44,7 +45,7 @@ jobs:
with:
wallet_connect_project_id: ${{ secrets.WALLET_CONNECT_PROJECT_ID }}
requested_network: "${{ inputs.network }}"
ethereum_url: "${{ fromJSON('{\"fuji\":\"https://api.avax-test.network/ext/bc/C/rpc\",\"mainnet\":\"https://mainnet.infura.io/v3/$INFURA_KEY\",\"goerli\":\"https://goerli.infura.io/v3/$INFURA_KEY\",\"mumbai\":\"https://polygon-mumbai.infura.io/v3/$INFURA_KEY\",\"polygon\":\"https://polygon-mainnet.infura.io/v3/$INFURA_KEY\",\"arbitrum-goerli\":\"https://arbitrum-goerli.infura.io/v3/$INFURA_KEY\",\"arbitrum\":\"https://arbitrum-mainnet.infura.io/v3/$INFURA_KEY\",\"base\":\"https://clean-spring-wind.base-mainnet.discover.quiknode.pro/$QUICKNODE_KEY\",\"base-goerli\":\"https://base-goerli.infura.io/v3/$INFURA_KEY\",\"linea-goerli\":\"https://linea-goerli.infura.io/v3/$INFURA_KEY\",\"scroll-goerli\":\"https://alpha-rpc.scroll.io/l2\"}')[inputs.network] }}"
ethereum_url: "${{ fromJSON('{\"fuji\":\"https://api.avax-test.network/ext/bc/C/rpc\",\"mainnet\":\"https://mainnet.infura.io/v3/$INFURA_KEY\",\"goerli\":\"https://goerli.infura.io/v3/$INFURA_KEY\",\"mumbai\":\"https://polygon-mumbai.infura.io/v3/$INFURA_KEY\",\"polygon\":\"https://polygon-mainnet.infura.io/v3/$INFURA_KEY\",\"arbitrum-goerli\":\"https://arbitrum-goerli.infura.io/v3/$INFURA_KEY\",\"arbitrum\":\"https://arbitrum-mainnet.infura.io/v3/$INFURA_KEY\",\"base\":\"https://clean-spring-wind.base-mainnet.discover.quiknode.pro/$QUICKNODE_KEY\",\"base-goerli\":\"https://base-goerli.infura.io/v3/$INFURA_KEY\",\"linea-goerli\":\"https://linea-goerli.infura.io/v3/$INFURA_KEY\",\"scroll-goerli\":\"https://alpha-rpc.scroll.io/l2\",\"scroll\":\"https://rpc.scroll.io\"}')[inputs.network] }}"
port: 8585
if: github.event.inputs.eth_pk == ''

Expand Down
5 changes: 3 additions & 2 deletions .github/workflows/enact-migration.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ on:
- base-goerli
- linea-goerli
- scroll-goerli
- scroll
deployment:
description: Deployment Name (e.g. "usdc")
required: true
Expand Down Expand Up @@ -52,7 +53,7 @@ jobs:
case ${{ github.event.inputs.network }} in
polygon | arbitrum | base)
echo "GOV_NETWORK=mainnet" >> $GITHUB_ENV ;;
mumbai | arbitrum-goerli | base-goerli | linea-goerli | scroll-goerli)
mumbai | arbitrum-goerli | base-goerli | linea-goerli | scroll-goerli | scroll)
echo "GOV_NETWORK=goerli" >> $GITHUB_ENV ;;
*)
echo "No governance network for selected network" ;;
Expand All @@ -63,7 +64,7 @@ jobs:
with:
wallet_connect_project_id: ${{ secrets.WALLET_CONNECT_PROJECT_ID }}
requested_network: "${{ inputs.network }}"
ethereum_url: "${{ fromJSON('{\"fuji\":\"https://api.avax-test.network/ext/bc/C/rpc\",\"mainnet\":\"https://mainnet.infura.io/v3/$INFURA_KEY\",\"goerli\":\"https://goerli.infura.io/v3/$INFURA_KEY\",\"mumbai\":\"https://polygon-mumbai.infura.io/v3/$INFURA_KEY\",\"polygon\":\"https://polygon-mainnet.infura.io/v3/$INFURA_KEY\",\"arbitrum-goerli\":\"https://arbitrum-goerli.infura.io/v3/$INFURA_KEY\",\"arbitrum\":\"https://arbitrum-mainnet.infura.io/v3/$INFURA_KEY\",\"base\":\"https://clean-spring-wind.base-mainnet.discover.quiknode.pro/$QUICKNODE_KEY\",\"base-goerli\":\"https://base-goerli.infura.io/v3/$INFURA_KEY\",\"linea-goerli\":\"https://linea-goerli.infura.io/v3/$INFURA_KEY\",\"scroll-goerli\":\"https://alpha-rpc.scroll.io/l2\"}')[inputs.network] }}"
ethereum_url: "${{ fromJSON('{\"fuji\":\"https://api.avax-test.network/ext/bc/C/rpc\",\"mainnet\":\"https://mainnet.infura.io/v3/$INFURA_KEY\",\"goerli\":\"https://goerli.infura.io/v3/$INFURA_KEY\",\"mumbai\":\"https://polygon-mumbai.infura.io/v3/$INFURA_KEY\",\"polygon\":\"https://polygon-mainnet.infura.io/v3/$INFURA_KEY\",\"arbitrum-goerli\":\"https://arbitrum-goerli.infura.io/v3/$INFURA_KEY\",\"arbitrum\":\"https://arbitrum-mainnet.infura.io/v3/$INFURA_KEY\",\"base\":\"https://clean-spring-wind.base-mainnet.discover.quiknode.pro/$QUICKNODE_KEY\",\"base-goerli\":\"https://base-goerli.infura.io/v3/$INFURA_KEY\",\"linea-goerli\":\"https://linea-goerli.infura.io/v3/$INFURA_KEY\",\"scroll-goerli\":\"https://alpha-rpc.scroll.io/l2\",\"scroll\":\"https://rpc.scroll.io\"}')[inputs.network] }}"
port: 8585
if: github.event.inputs.eth_pk == ''

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/prepare-migration.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ jobs:
with:
wallet_connect_project_id: ${{ secrets.WALLET_CONNECT_PROJECT_ID }}
requested_network: "${{ inputs.network }}"
ethereum_url: "${{ fromJSON('{\"fuji\":\"https://api.avax-test.network/ext/bc/C/rpc\",\"mainnet\":\"https://mainnet.infura.io/v3/$INFURA_KEY\",\"goerli\":\"https://goerli.infura.io/v3/$INFURA_KEY\",\"mumbai\":\"https://polygon-mumbai.infura.io/v3/$INFURA_KEY\",\"polygon\":\"https://polygon-mainnet.infura.io/v3/$INFURA_KEY\",\"arbitrum-goerli\":\"https://arbitrum-goerli.infura.io/v3/$INFURA_KEY\",\"arbitrum\":\"https://arbitrum-mainnet.infura.io/v3/$INFURA_KEY\",\"base\":\"https://clean-spring-wind.base-mainnet.discover.quiknode.pro/$QUICKNODE_KEY\",\"base-goerli\":\"https://base-goerli.infura.io/v3/$INFURA_KEY\",\"linea-goerli\":\"https://linea-goerli.infura.io/v3/$INFURA_KEY\",\"scroll-goerli\":\"https://alpha-rpc.scroll.io/l2\"}')[inputs.network] }}"
ethereum_url: "${{ fromJSON('{\"fuji\":\"https://api.avax-test.network/ext/bc/C/rpc\",\"mainnet\":\"https://mainnet.infura.io/v3/$INFURA_KEY\",\"goerli\":\"https://goerli.infura.io/v3/$INFURA_KEY\",\"mumbai\":\"https://polygon-mumbai.infura.io/v3/$INFURA_KEY\",\"polygon\":\"https://polygon-mainnet.infura.io/v3/$INFURA_KEY\",\"arbitrum-goerli\":\"https://arbitrum-goerli.infura.io/v3/$INFURA_KEY\",\"arbitrum\":\"https://arbitrum-mainnet.infura.io/v3/$INFURA_KEY\",\"base\":\"https://clean-spring-wind.base-mainnet.discover.quiknode.pro/$QUICKNODE_KEY\",\"base-goerli\":\"https://base-goerli.infura.io/v3/$INFURA_KEY\",\"linea-goerli\":\"https://linea-goerli.infura.io/v3/$INFURA_KEY\",\"scroll-goerli\":\"https://alpha-rpc.scroll.io/l2\",\"scroll\":\"https://rpc.scroll.io\"}')[inputs.network] }}"
port: 8585
if: github.event.inputs.eth_pk == ''

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/run-scenarios.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ jobs:
strategy:
fail-fast: false
matrix:
bases: [ development, mainnet, mainnet-weth, goerli, goerli-weth, fuji, mumbai, polygon, arbitrum-usdc.e, arbitrum-usdc, arbitrum-goerli-usdc, arbitrum-goerli-usdc.e, base-usdbc, base-weth, base-goerli, base-goerli-weth, linea-goerli, scroll-goerli]
bases: [ development, mainnet, mainnet-weth, goerli, goerli-weth, fuji, mumbai, polygon, arbitrum-usdc.e, arbitrum-usdc, arbitrum-goerli-usdc, arbitrum-goerli-usdc.e, base-usdbc, base-weth, base-goerli, base-goerli-weth, linea-goerli, scroll-goerli, scroll]
name: Run scenarios
env:
ETHERSCAN_KEY: ${{ secrets.ETHERSCAN_KEY }}
Expand Down
45 changes: 45 additions & 0 deletions deployments/scroll/usdc/configuration.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
{
"name": "Compound USDC",
"symbol": "cUSDCv3",
"baseToken": "USDC",
"baseTokenAddress": "0x06eFdBFf2a14a7c8E15944D1F4A48F9F95F663A4",
"baseTokenPriceFeed": "0x43d12Fb3AfCAd5347fA764EeAB105478337b7200",
"borrowMin": "0.001e6",
"storeFrontPriceFactor": 0.5,
"targetReserves": "1000000e6",
"rates": {
"supplyKink": 0.8,
"supplySlopeLow": 0.0325,
"supplySlopeHigh": 0.4,
"supplyBase": 0,
"borrowKink": 0.8,
"borrowSlopeLow": 0.035,
"borrowSlopeHigh": 0.25,
"borrowBase": 0.015
},
"tracking": {
"indexScale": "1e15",
"baseSupplySpeed": "0.000402083333333e15",
"baseBorrowSpeed": "0.000402083333333e15",
"baseMinForRewards": "1000e6"
},
"assets": {
"WETH": {
"address": "0x5300000000000000000000000000000000000004",
"priceFeed": "0x6bF14CB0A831078629D993FDeBcB182b21A8774C",
"decimals": "18",
"borrowCF": 0.775,
"liquidateCF": 0.825,
"liquidationFactor": 0.95,
"supplyCap": "10000000e18"
},
"wstETH": {
"address": "0xf610A9dfB7C89644979b4A0f27063E9e7d7Cda32",
"decimals": "18",
"borrowCF": 0.90,
"liquidateCF": 0.93,
"liquidationFactor": 0.95,
"supplyCap": "80_000e18"
}
}
}
89 changes: 89 additions & 0 deletions deployments/scroll/usdc/deploy.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
import { Deployed, DeploymentManager } from '../../../plugins/deployment_manager';
import { DeploySpec, deployComet, exp, wait } from '../../../src/deploy';

const secondsPerDay = 24 * 60 * 60;

const MAINNET_TIMELOCK = '0x6d903f6003cca6255d85cca4d3b5e5146dc33925'; // L1 contract

export default async function deploy(
deploymentManager: DeploymentManager,
deploySpec: DeploySpec
): Promise<Deployed> {
const trace = deploymentManager.tracer();
const ethers = deploymentManager.hre.ethers;

// Pull in existing assets
const WETH = await deploymentManager.existing('WETH','0x5300000000000000000000000000000000000004','scroll');
const wstETH = await deploymentManager.existing('wstETH', '0xf610A9dfB7C89644979b4A0f27063E9e7d7Cda32', 'scroll');

const l2Messenger = await deploymentManager.existing('l2Messenger','0x781e90f1c8Fc4611c9b7497C3B47F99Ef6969CbC','scroll');
const l2ERC20Gateway = await deploymentManager.existing('l2ERC20Gateway','0xE2b4795039517653c5Ae8C2A9BFdd783b48f447A','scroll');
const l2ETHGateway = await deploymentManager.existing('l2ETHGateway', '0x6EA73e05AdC79974B931123675ea8F78FfdacDF0', 'scroll');
const l2WETHGateway = await deploymentManager.existing('l2WETHGateway','0x7003E7B7186f0E6601203b99F7B8DECBfA391cf9','scroll');

// Deploy ScrollBridgeReceiver
const bridgeReceiver = await deploymentManager.deploy(
'bridgeReceiver',
'bridges/scroll/ScrollBridgeReceiver.sol',
[l2Messenger.address]
);

// Deploy Local Timelock
const localTimelock = await deploymentManager.deploy('timelock', 'vendor/Timelock.sol', [
bridgeReceiver.address, // admin
10 * 60, // delay
14 * secondsPerDay, // grace period
10 * 60, // minimum delay
30 * secondsPerDay // maximum delay
]);

// Deploy multiplicative price feed for wstETH / USD
const wstETHMultiplicativePriceFeed = await deploymentManager.deploy(
'wstETH:priceFeed',
'pricefeeds/MultiplicativePriceFeed.sol',
[
'0xe428fbdbd61CC1be6C273dC0E27a1F43124a86F3', // wstETH / ETH price feed
'0x6bF14CB0A831078629D993FDeBcB182b21A8774C', // ETH / USD price feed
8, // decimals
'wstETH / USD price feed' // description
]
);

// Initialize BridgeReceiver
await deploymentManager.idempotent(
async () => !(await bridgeReceiver.initialized()),
async () => {
trace(`Initializing BridgeReceiver`);
await bridgeReceiver.initialize(
MAINNET_TIMELOCK, // govTimelock
localTimelock.address // localTimelock
);
trace(`BridgeReceiver initialized`);
}
);

// Deploy Comet
const deployed = await deployComet(deploymentManager, deploySpec);
const { comet } = deployed;

// Deploy Bulker
const bulker = await deploymentManager.deploy(
'bulker',
'bulkers/MainnetBulker.sol',
[
await comet.governor(), // admin_
WETH.address, // weth_
wstETH.address // wsteth_
]
);

return {
...deployed,
bridgeReceiver,
l2Messenger,
l2ERC20Gateway,
l2ETHGateway,
l2WETHGateway,
bulker,
};
}
36 changes: 36 additions & 0 deletions deployments/scroll/usdc/relations.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import baseRelationConfig from '../../relations';

export default {
...baseRelationConfig,
governor: {
artifact: 'contracts/bridges/scroll/ScrollBridgeReceiver.sol:ScrollBridgeReceiver'
},
l2Messenger: {
delegates: {
field: {
slot: '0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc'
}
}
},
l2ERC20Gateway: {
delegates: {
field: {
slot: '0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc'
}
}
},
l2ETHGateway: {
delegates: {
field: {
slot: '0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc'
}
}
},
l2WETHGateway: {
delegates: {
field: {
slot: '0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc'
}
}
}
};
27 changes: 26 additions & 1 deletion hardhat.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ import baseGoerliRelationConfigMap from './deployments/base-goerli/usdc/relation
import baseGoerliWethRelationConfigMap from './deployments/base-goerli/weth/relations';
import lineaGoerliRelationConfigMap from './deployments/linea-goerli/usdc/relations';
import scrollGoerliRelationConfigMap from './deployments/scroll-goerli/usdc/relations';
import scrollRelationConfigMap from './deployments/scroll/usdc/relations';


task('accounts', 'Prints the list of accounts', async (taskArgs, hre) => {
Expand Down Expand Up @@ -146,6 +147,11 @@ const networkConfigs: NetworkConfig[] = [
network: 'scroll-goerli',
chainId: 534353,
url: 'https://alpha-rpc.scroll.io/l2',
},
{
network: 'scroll',
chainId: 534352,
url: 'https://rpc.scroll.io',
}
];

Expand Down Expand Up @@ -236,8 +242,10 @@ const config: HardhatUserConfig = {
'base-goerli': BASESCAN_KEY,
// Linea
'linea-goerli': LINEASCAN_KEY,
// Scroll Testnet
'scroll-goerli': ETHERSCAN_KEY,
// Scroll
'scroll-goerli': ETHERSCAN_KEY
'scroll': ETHERSCAN_KEY,
},
customChains: [
{
Expand Down Expand Up @@ -291,6 +299,14 @@ const config: HardhatUserConfig = {
apiURL: 'https://alpha-blockscout.scroll.io/api',
browserURL: 'https://alpha-blockscout.scroll.io/'
}
},
{
network: 'scroll',
chainId: 534352,
urls: {
apiURL: 'https://api.scrollscan.com/api',
browserURL: 'https://scrollscan.com/'
}
}
]
},
Expand Down Expand Up @@ -338,6 +354,9 @@ const config: HardhatUserConfig = {
},
'scroll-goerli': {
usdc: scrollGoerliRelationConfigMap
},
'scroll': {
usdc: scrollRelationConfigMap
}
},
},
Expand Down Expand Up @@ -446,6 +465,12 @@ const config: HardhatUserConfig = {
network: 'scroll-goerli',
deployment: 'usdc',
auxiliaryBase: 'goerli'
},
{
name: 'scroll',
network: 'scroll',
deployment: 'usdc',
auxiliaryBase: 'mainnet'
}
],
},
Expand Down
3 changes: 3 additions & 0 deletions plugins/import/etherscan.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ export function getEtherscanApiUrl(network: string): string {
'base-goerli': 'api-goerli.basescan.org',
'linea-goerli': 'api-goerli.lineascan.build',
'scroll-goerli': 'alpha-blockscout.scroll.io',
scroll: 'api.scrollscan.com'
}[network];

if (!host) {
Expand All @@ -47,6 +48,7 @@ export function getEtherscanUrl(network: string): string {
'base-goerli': 'goerli.basescan.org',
'linea-goerli': 'goerli.lineascan.build',
'scroll-goerli': 'alpha-blockscout.scroll.io',
scroll: 'scrollscan.com'
}[network];

if (!host) {
Expand All @@ -72,6 +74,7 @@ export function getEtherscanApiKey(network: string): string {
'base-goerli': process.env.BASESCAN_KEY,
'linea-goerli': process.env.LINEASCAN_KEY,
'scroll-goerli': process.env.ETHERSCAN_KEY,
scroll: process.env.ETHERSCAN_KEY
}[network];

if (!apiKey) {
Expand Down
2 changes: 1 addition & 1 deletion scenario/CrossChainGovernanceScenario.ts
Original file line number Diff line number Diff line change
Expand Up @@ -386,7 +386,7 @@ scenario(
scenario(
'upgrade Scroll governance contracts and ensure they work properly',
{
filter: async ctx => matchesDeployment(ctx, [{ network: 'scroll-goerli' }])
filter: async ctx => matchesDeployment(ctx, [{ network: 'scroll-goerli' }, {network: 'scroll'}])
},
async (
{
Expand Down
1 change: 1 addition & 0 deletions scenario/utils/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -504,6 +504,7 @@ export async function createCrossChainProposal(context: CometContext, l2Proposal
calldata.push(sendMessageCalldata);
break;
}
case 'scroll':
case 'scroll-goerli': {
const sendMessageCalldata = utils.defaultAbiCoder.encode(
['address', 'uint256', 'bytes', 'uint256'],
Expand Down
1 change: 1 addition & 0 deletions scenario/utils/isBridgeProposal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ export async function isBridgeProposal(
const { targets } = await governor.getActions(openProposal.id);
return targets.includes(lineaMessageService.address);
}
case 'scroll':
case 'scroll-goerli': {
const governor = await governanceDeploymentManager.getContractOrThrow('governor');
const scrollMessenger = await governanceDeploymentManager.getContractOrThrow(
Expand Down
1 change: 1 addition & 0 deletions scenario/utils/relayMessage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ export default async function relayMessage(
startingBlockNumber
);
break;
case 'scroll':
case 'scroll-goerli':
await relayScrollMessage(
governanceDeploymentManager,
Expand Down
18 changes: 13 additions & 5 deletions scenario/utils/relayScrollMessage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,18 @@ export default async function relayScrollMessage(

await setNextBaseFeeToZero(bridgeDeploymentManager);

const aliasAccount = await impersonateAddress(
bridgeDeploymentManager,
"0xD69c917c7F1C0a724A51c189B4A8F4F8C8E8cA0a"
);
let aliasAccount
if (bridgeDeploymentManager.network == 'scroll-goerli'){
aliasAccount = await impersonateAddress(
bridgeDeploymentManager,
"0xD69c917c7F1C0a724A51c189B4A8F4F8C8E8cA0a"
);
} else {
aliasAccount = await impersonateAddress(
bridgeDeploymentManager,
applyL1ToL2Alias(scrollMessenger.address)
);
}

const relayMessageTxn = await (
await l2Messenger.connect(aliasAccount).relayMessage(
Expand Down Expand Up @@ -99,7 +107,7 @@ export default async function relayScrollMessage(
`[${governanceDeploymentManager.network} -> ${bridgeDeploymentManager.network}] Bridged over ${amount} of ETH to user ${to}`
);
}else if (target === l2WETHGateway.address){
// Bridging WETH
// 1c. Bridging WETH
const { _l1Token, _l2Token, _from, to, amount, _data } = ethers.utils.defaultAbiCoder.decode(
['address _l1Token', 'address _l2Token','address _from', 'address _to','uint256 _amount', 'bytes _data'],
messageWithoutSigHash
Expand Down

0 comments on commit 3bde642

Please sign in to comment.