Skip to content

Commit

Permalink
Add USDC market on Scroll mainnet (#824)
Browse files Browse the repository at this point in the history
* debug

* update price feed

* update config

* temp workaround

* add scroll to scenarios

* uncomment spider debug messages

* add scroll relations

* catch failed spider crawls

* Fix spider for scroll

* update bridge receiver to be compatible with scroll bridge

* update relations

* Modified deployment roots from GitHub Actions

* remove console.log

* rename scroll messenger

* add scroll to governance scenarios

* adapt scroll relay message fn

* fix unit tests

* rename contracts and update message relaying

* update scroll testnet block explorer URL

* remove base fee

* fix scroll l2 sender address

* remove old roots

* fix type errors

* Modified deployment roots from GitHub Actions

* proposal for intializing usdc market on scroll goerli

* add configurator to scroll relations

* PR comments

* add docstrings

* emit event when intializing ScrollBridgeReceiver

* PR comments

* update comment

* add usdc market on scroll mainnet

* fix wseth

* create migration

* use gauntlet recommended parameters

* lint and fix timelock params

* set  rewards speed to 0

* add pause guardian

* fix scientific notation

* add scroll mainnet roots

* update scroll relations for wsteth

* PR comments

* update wsteth/USD price feed to exchange rate based

* Modified deployment roots from GitHub Actions

* update proposal description

* update scroll governance proposal to bridge USDC instead of COMP

* final PR comments

* set message value on propsal actions

---------

Co-authored-by: Isabelle Wei <isabellewei@Isabelles-MacBook-Pro.local>
Co-authored-by: isabelle <isabelle@scroll.io>
Co-authored-by: kevincheng96 <kevincheng96@hotmail.com>
Co-authored-by: GitHub Actions Bot <>
  • Loading branch information
4 people committed Mar 28, 2024
1 parent b924358 commit bbee087
Show file tree
Hide file tree
Showing 18 changed files with 506 additions and 13 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/deploy-market.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ on:
- base-goerli
- linea-goerli
- scroll-goerli
- scroll
deployment:
description: Deployment Name (e.g. "usdc")
required: true
Expand Down Expand Up @@ -45,7 +46,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\",\"sepolia\":\"https://sepolia.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 @@ -18,6 +18,7 @@ on:
- base-goerli
- linea-goerli
- scroll-goerli
- scroll
deployment:
description: Deployment Name (e.g. "usdc")
required: true
Expand Down Expand Up @@ -53,7 +54,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 @@ -64,7 +65,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 @@ -46,7 +46,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-usdc]
name: Run scenarios
env:
ETHERSCAN_KEY: ${{ secrets.ETHERSCAN_KEY }}
Expand Down
14 changes: 14 additions & 0 deletions deployments/mainnet/usdc/relations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,5 +41,19 @@ export default {
slot: '0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc'
}
}
},
scrollMessenger: {
delegates: {
field: {
slot: '0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc'
}
}
},
scrollL1USDCGateway: {
delegates: {
field: {
slot: '0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc'
}
}
}
};
4 changes: 3 additions & 1 deletion deployments/mainnet/usdc/roots.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,7 @@
"CCTPTokenMessenger": "0xbd3fa81b58ba92a82136038b25adec7066af3155",
"CCTPMessageTransmitter": "0x0a992d191deec32afe36203ad87d7d289a738f81",
"baseL1CrossDomainMessenger": "0x866E82a600A1414e583f7F13623F1aC5d58b0Afa",
"baseL1StandardBridge": "0x3154Cf16ccdb4C6d922629664174b904d80F2C35"
"baseL1StandardBridge": "0x3154Cf16ccdb4C6d922629664174b904d80F2C35",
"scrollMessenger": "0x6774Bcbd5ceCeF1336b5300fb5186a12DDD8b367",
"scrollL1USDCGateway": "0xf1AF3b23DE0A5Ca3CAb7261cb0061C0D779A5c7B"
}
46 changes: 46 additions & 0 deletions deployments/scroll/usdc/configuration.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
{
"name": "Compound USDC",
"symbol": "cUSDCv3",
"baseToken": "USDC",
"baseTokenAddress": "0x06eFdBFf2a14a7c8E15944D1F4A48F9F95F663A4",
"baseTokenPriceFeed": "0x43d12Fb3AfCAd5347fA764EeAB105478337b7200",
"borrowMin": "0.001e6",
"pauseGuardian": "0x0747a435b8a60070A7a111D015046d765098e4cc",
"storeFrontPriceFactor": 0.6,
"targetReserves": "1000000e6",
"rates": {
"supplyKink": 0.85,
"supplySlopeLow": 0.048,
"supplySlopeHigh": 1.6,
"supplyBase": 0,
"borrowKink": 0.85,
"borrowSlopeLow": 0.053,
"borrowSlopeHigh": 1.8,
"borrowBase": 0.015
},
"tracking": {
"indexScale": "1e15",
"baseSupplySpeed": "0e15",
"baseBorrowSpeed": "0e15",
"baseMinForRewards": "1000e6"
},
"assets": {
"WETH": {
"address": "0x5300000000000000000000000000000000000004",
"priceFeed": "0x6bF14CB0A831078629D993FDeBcB182b21A8774C",
"decimals": "18",
"borrowCF": 0.8,
"liquidateCF": 0.85,
"liquidationFactor": 0.9,
"supplyCap": "300e18"
},
"wstETH": {
"address": "0xf610A9dfB7C89644979b4A0f27063E9e7d7Cda32",
"decimals": "18",
"borrowCF": 0.75,
"liquidateCF": 0.8,
"liquidationFactor": 0.85,
"supplyCap": "50e18"
}
}
}
87 changes: 87 additions & 0 deletions deployments/scroll/usdc/deploy.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
import { Deployed, DeploymentManager } from '../../../plugins/deployment_manager';
import { DeploySpec, deployComet, exp, wait } from '../../../src/deploy';

const HOUR = 60 * 60;
const DAY = 24 * HOUR;

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');
const l2WstETHGateway = await deploymentManager.existing('l2WstETHGateway', '0x8aE8f22226B9d789A36AC81474e633f8bE2856c9', '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
1 * DAY, // delay
14 * DAY, // grace period
12 * HOUR, // minimum delay
30 * DAY // maxiumum delay
]);

// Deploy multiplicative price feed for wstETH / USD
const wstETHMultiplicativePriceFeed = await deploymentManager.deploy(
'wstETH:priceFeed',
'pricefeeds/MultiplicativePriceFeed.sol',
[
'0xE61Da4C909F7d86797a0D06Db63c34f76c9bCBDC', // wstETH-stETH 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/BaseBulker.sol', [
await comet.governor(), // admin_
WETH.address, // weth_
]);

return {
...deployed,
bridgeReceiver,
l2Messenger,
l2ERC20Gateway,
l2ETHGateway,
l2WETHGateway,
l2WstETHGateway,
bulker,
};
}
Loading

0 comments on commit bbee087

Please sign in to comment.