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 and initialize native USDC market on Arbitrum #769

Merged
merged 51 commits into from
Sep 12, 2023
Merged
Show file tree
Hide file tree
Changes from 43 commits
Commits
Show all changes
51 commits
Select commit Hold shift + click to select a range
1025d24
initial gen
Jun 15, 2023
0b4b0bf
remove files
Jun 15, 2023
6c8d767
rename directory
Jun 15, 2023
3890dc1
add scenario
Jun 16, 2023
280b091
upadte deploy script
Jun 16, 2023
55ef5c1
renamde to usdc.n
Jun 16, 2023
fdd3e27
added relations for scenario test
Jun 16, 2023
9bb5ec5
add scenario test to CI
Jun 16, 2023
944f551
add migration scrtips, but just changed the USDC reference address
Jun 16, 2023
b666eda
update migration script
Jun 16, 2023
1a158a5
since it's native, we shouldn't need usdc bridge things in migration
Jun 20, 2023
c8058e6
try to fix the liquidator scenario errors
Jun 21, 2023
7a697bb
intent
Jun 21, 2023
48d4c0e
change those to be 0 initially
Jun 21, 2023
922121d
FINALLY scneario passed :D
Jun 21, 2023
7e894ea
don't re-deploy bulker
Jun 21, 2023
4d68113
set a number in configuration to make bulker tests pass
Jun 22, 2023
24bb4fe
set configuration to 0 supply cap for initialization, although it wil…
Jun 22, 2023
a0b5f90
update liquidity pool to use the one with better liquidity
Jun 23, 2023
a9d0d4a
after new pool use better liquidity, now able to bump up the volume
Jun 23, 2023
1d31ac2
remove v2 rewards config step, crank down borrowMin
Jun 23, 2023
81e837c
update migration description
Jun 23, 2023
d5886ef
remove trailing newline
Jun 23, 2023
e4c1a34
ok need to referencing existing rewards in deploy script to share the…
Jun 23, 2023
c1f606e
naming changes
Jun 23, 2023
d6e272e
added cctp contracts address to roots and update relayArbitrummessage
Jun 28, 2023
74cc7bf
add l2 cctp
Jun 28, 2023
82b0cb7
depositForBurn() to use CCTP to send native USDC to arbitrum comet
Jun 28, 2023
748259f
finally relayArbitrum works with CCTP
Jun 29, 2023
e008f58
format
Jun 29, 2023
07da85b
update to turn off bridge market's reward speed
Jun 30, 2023
e739bf2
fix scenarios and slightly reduced volume in liquidator scenarios (so…
Jul 3, 2023
b77225c
now it has just enough liquidity to pass the test, reverted the liqui…
Jul 5, 2023
8c29661
address comments: remove network prefixes, move contract import from …
Jul 6, 2023
a1afade
remove network prefixes, and rename bridgeComet to usdceComet
Jul 6, 2023
9d3cf20
rename/refactor usdc -> usdc.e, and usdc.n -> usdc. Also rename deply…
Jul 6, 2023
e3d8597
luckily by the time of testing now Jul 6th 1:40PM PST, we have enough…
Jul 6, 2023
4b95ada
rename usdc.n to usdc
Jul 6, 2023
a73265b
make yarn lint happy
Jul 6, 2023
b0bab3f
change default supply reward speed on new comet to be 0
Jul 12, 2023
cbc56da
Merge remote-tracking branch 'refs/remotes/origin/main' into hans/arb…
Aug 16, 2023
14f1c5f
hardat confit resolve conflicts
Aug 16, 2023
cb89aa5
removed migration script, and set supply cap to 0 on configuration
Aug 16, 2023
6b846ed
set reward speed to zero
Aug 16, 2023
ca12b57
set borrow min to 1 wer
Aug 16, 2023
0c53036
Merge remote-tracking branch 'refs/remotes/origin/main' into hans/arb…
Aug 16, 2023
2590b83
Update deployments/arbitrum/usdc/deploy.ts
cwang25 Aug 16, 2023
427bbf2
Modified deployment roots from GitHub Actions
Aug 16, 2023
d006f46
Migrate and initialize Arbitrum Native USDC market (#789)
cwang25 Aug 29, 2023
cc15ed8
Merge remote-tracking branch 'origin/main' into hans/arbitrum-usdc-na…
Aug 31, 2023
cca8968
add arb mainnet messagetransmitter
Aug 31, 2023
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
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, arbitrum-goerli-usdc, arbitrum-goerli-usdc.e, base-goerli, base-goerli-weth, linea-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-goerli, base-goerli-weth, linea-goerli]
name: Run scenarios
env:
ETHERSCAN_KEY: ${{ secrets.ETHERSCAN_KEY }}
Expand Down
65 changes: 65 additions & 0 deletions deployments/arbitrum/usdc.e/configuration.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
{
"name": "Compound USDC",
"symbol": "cUSDCv3",
"baseToken": "USDC.e",
"baseTokenAddress": "0xff970a61a04b1ca14834a43f5de4533ebddb5cc8",
"baseTokenPriceFeed": "0x50834F3163758fcC1Df9973b6e91f0F0F0434aD3",
"borrowMin": "100e6",
"pauseGuardian": "0x78E6317DD6D43DdbDa00Dce32C2CbaFc99361a9d",
"storeFrontPriceFactor": 0.8,
"targetReserves": "5000000e6",
"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": "0e15",
"baseMinForRewards": "10000e6"
},
"assets": {
"ARB": {
"address": "0x912ce59144191c1204e64559fe8253a0e49e6548",
"priceFeed": "0xb2A824043730FE05F3DA2efaFa1CBbe83fa548D6",
"decimals": "18",
"borrowCF": 0.55,
"liquidateCF": 0.60,
"liquidationFactor": 0.93,
"supplyCap": "4000000e18"
},
"GMX": {
"address": "0xfc5a1a6eb076a2c7ad06ed22c90d7e710e35ad0a",
"priceFeed": "0xDB98056FecFff59D032aB628337A4887110df3dB",
"decimals": "18",
"borrowCF": 0.40,
"liquidateCF": 0.45,
"liquidationFactor": 0.93,
"supplyCap": "50000e18"
},
"WETH": {
"address": "0x82af49447d8a07e3bd95bd0d56f35241523fbab1",
"priceFeed": "0x639Fe6ab55C921f74e7fac1ee960C0B6293ba612",
"decimals": "18",
"borrowCF": 0.78,
"liquidateCF": 0.85,
"liquidationFactor": 0.95,
"supplyCap": "5000e18"
},
"WBTC": {
"address": "0x2f2a2543b76a4166549f7aab2e75bef0aefc5b0f",
"priceFeed": "0xd0C7101eACbB49F3deCcCc166d238410D6D46d57",
"decimals": "8",
"borrowCF": 0.70,
"liquidateCF": 0.77,
"liquidationFactor": 0.95,
"supplyCap": "300e8"
}
}
}
72 changes: 72 additions & 0 deletions deployments/arbitrum/usdc.e/deploy.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
import { Deployed, DeploymentManager } from '../../../plugins/deployment_manager';
import { DeploySpec, deployComet } from '../../../src/deploy';

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

const MAINNET_TIMELOCK = '0x6d903f6003cca6255d85cca4d3b5e5146dc33925';

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 USDC = await deploymentManager.existing('USDC', '0xff970a61a04b1ca14834a43f5de4533ebddb5cc8', 'arbitrum');
const ARB = await deploymentManager.existing('ARB', '0x912ce59144191c1204e64559fe8253a0e49e6548', 'arbitrum');
const GMX = await deploymentManager.existing('GMX', '0xfc5a1a6eb076a2c7ad06ed22c90d7e710e35ad0a', 'arbitrum');
const WETH = await deploymentManager.existing('WETH', '0x82af49447d8a07e3bd95bd0d56f35241523fbab1', 'arbitrum');
const WBTC = await deploymentManager.existing('WBTC', '0x2f2a2543b76a4166549f7aab2e75bef0aefc5b0f', 'arbitrum');

// Deploy ArbitrumBridgeReceiver
const bridgeReceiver = await deploymentManager.deploy(
'bridgeReceiver',
'bridges/arbitrum/ArbitrumBridgeReceiver.sol',
[]
);

// 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
]
);

// Initialize ArbitrumBridgeReceiver
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,
bulker
};
}
38 changes: 38 additions & 0 deletions deployments/arbitrum/usdc.e/relations.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import baseRelationConfig from '../../relations';

export default {
...baseRelationConfig,
governor: {
artifact: 'contracts/bridges/arbitrum/ArbitrumBridgeReceiver.sol:ArbitrumBridgeReceiver'
},
ClonableBeaconProxy: {
artifact: 'contracts/ERC20.sol:ERC20'
},
// USDC
'0xff970a61a04b1ca14834a43f5de4533ebddb5cc8': {
artifact: 'contracts/ERC20.sol:ERC20',
delegates: {
field: {
slot: '0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc'
}
}
},
// ARB
'0x912ce59144191c1204e64559fe8253a0e49e6548': {
artifact: 'contracts/ERC20.sol:ERC20',
delegates: {
field: {
slot: '0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc'
}
}
},
// WETH
'0x82af49447d8a07e3bd95bd0d56f35241523fbab1': {
artifact: 'contracts/ERC20.sol:ERC20',
delegates: {
field: {
slot: '0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc'
}
}
}
};
12 changes: 6 additions & 6 deletions deployments/arbitrum/usdc/configuration.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
"name": "Compound USDC",
"symbol": "cUSDCv3",
"baseToken": "USDC",
"baseTokenAddress": "0xff970a61a04b1ca14834a43f5de4533ebddb5cc8",
"baseTokenAddress": "0xaf88d065e77c8cC2239327C5EDb3A432268e5831",
"baseTokenPriceFeed": "0x50834F3163758fcC1Df9973b6e91f0F0F0434aD3",
"borrowMin": "100e6",
"borrowMin": "1e6",
"pauseGuardian": "0x78E6317DD6D43DdbDa00Dce32C2CbaFc99361a9d",
"storeFrontPriceFactor": 0.8,
"targetReserves": "5000000e6",
Expand Down Expand Up @@ -32,7 +32,7 @@
"borrowCF": 0.55,
"liquidateCF": 0.60,
"liquidationFactor": 0.93,
"supplyCap": "4000000e18"
"supplyCap": "0e18"
},
"GMX": {
"address": "0xfc5a1a6eb076a2c7ad06ed22c90d7e710e35ad0a",
Expand All @@ -41,7 +41,7 @@
"borrowCF": 0.40,
"liquidateCF": 0.45,
"liquidationFactor": 0.93,
"supplyCap": "50000e18"
"supplyCap": "0e18"
},
"WETH": {
"address": "0x82af49447d8a07e3bd95bd0d56f35241523fbab1",
Expand All @@ -50,7 +50,7 @@
"borrowCF": 0.78,
"liquidateCF": 0.85,
"liquidationFactor": 0.95,
"supplyCap": "5000e18"
"supplyCap": "0e18"
},
"WBTC": {
"address": "0x2f2a2543b76a4166549f7aab2e75bef0aefc5b0f",
Expand All @@ -59,7 +59,7 @@
"borrowCF": 0.70,
"liquidateCF": 0.77,
"liquidationFactor": 0.95,
"supplyCap": "300e8"
"supplyCap": "0e8"
}
}
}
60 changes: 14 additions & 46 deletions deployments/arbitrum/usdc/deploy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,62 +11,30 @@ export default async function deploy(deploymentManager: DeploymentManager, deplo
const ethers = deploymentManager.hre.ethers;

// pull in existing assets
const USDC = await deploymentManager.existing('USDC', '0xff970a61a04b1ca14834a43f5de4533ebddb5cc8', 'arbitrum');
// USDC native
const USDC = await deploymentManager.existing('USDC', '0xaf88d065e77c8cC2239327C5EDb3A432268e5831', 'arbitrum');
const ARB = await deploymentManager.existing('ARB', '0x912ce59144191c1204e64559fe8253a0e49e6548', 'arbitrum');
const GMX = await deploymentManager.existing('GMX', '0xfc5a1a6eb076a2c7ad06ed22c90d7e710e35ad0a', 'arbitrum');
const WETH = await deploymentManager.existing('WETH', '0x82af49447d8a07e3bd95bd0d56f35241523fbab1', 'arbitrum');
const WBTC = await deploymentManager.existing('WBTC', '0x2f2a2543b76a4166549f7aab2e75bef0aefc5b0f', 'arbitrum');

// Deploy ArbitrumBridgeReceiver
const bridgeReceiver = await deploymentManager.deploy(
'bridgeReceiver',
'bridges/arbitrum/ArbitrumBridgeReceiver.sol',
[]
);

// 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
]
);

// Initialize ArbitrumBridgeReceiver
await deploymentManager.idempotent(
async () => !(await bridgeReceiver.initialized()),
async () => {
trace(`Initializing BridgeReceiver`);
await bridgeReceiver.initialize(
MAINNET_TIMELOCK, // govTimelock
localTimelock.address // localTimelock
);
trace(`BridgeReceiver initialized`);
}
);
// Import shared contracts from cUSDCv3
cwang25 marked this conversation as resolved.
Show resolved Hide resolved
const cometAdmin = await deploymentManager.fromDep('cometAdmin', 'arbitrum', 'usdc.e');
const cometFactory = await deploymentManager.fromDep('cometFactory', 'arbitrum', 'usdc.e');
const $configuratorImpl = await deploymentManager.fromDep('configurator:implementation', 'arbitrum', 'usdc.e');
const configurator = await deploymentManager.fromDep('configurator', 'arbitrum', 'usdc.e');
const rewards = await deploymentManager.fromDep('rewards', 'arbitrum', 'usdc.e');
const bulker = await deploymentManager.fromDep('bulker', 'arbitrum', 'usdc.e');
const localTimelock = await deploymentManager.fromDep('timelock', 'arbitrum', 'usdc.e');
const bridgeReceiver = await deploymentManager.fromDep('bridgeReceiver', 'arbitrum', 'usdc.e');

// 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,
bulker
bridgeReceiver,
bulker,
rewards,
};
}
15 changes: 12 additions & 3 deletions deployments/arbitrum/usdc/relations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,16 @@ export default {
ClonableBeaconProxy: {
artifact: 'contracts/ERC20.sol:ERC20'
},
// USDC
// Native USDC
'0xaf88d065e77c8cC2239327C5EDb3A432268e5831': {
artifact: 'contracts/ERC20.sol:ERC20',
delegates: {
field: {
slot: '0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc'
}
}
},
// Bridged USDC
'0xff970a61a04b1ca14834a43f5de4533ebddb5cc8': {
artifact: 'contracts/ERC20.sol:ERC20',
delegates: {
Expand All @@ -34,5 +43,5 @@ export default {
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 @@ -6,5 +6,7 @@
"bulker": "0xa397a8C2086C554B531c02E29f3291c9704B00c7",
"fxRoot": "0xfe5e5D361b2ad62c541bAb87C45a0B9B018389a2",
"arbitrumInbox": "0x4Dbd4fc535Ac27206064B68FfCf827b0A60BAB3f",
"arbitrumL1GatewayRouter": "0x72Ce9c846789fdB6fC1f34aC4AD25Dd9ef7031ef"
"arbitrumL1GatewayRouter": "0x72Ce9c846789fdB6fC1f34aC4AD25Dd9ef7031ef",
"CCTPTokenMessenger": "0xbd3fa81b58ba92a82136038b25adec7066af3155",
"CCTPMessageTransmitter": "0x0a992d191deec32afe36203ad87d7d289a738f81"
}
14 changes: 11 additions & 3 deletions hardhat.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ import mumbaiRelationConfigMap from './deployments/mumbai/usdc/relations';
import mainnetRelationConfigMap from './deployments/mainnet/usdc/relations';
import mainnetWethRelationConfigMap from './deployments/mainnet/weth/relations';
import polygonRelationConfigMap from './deployments/polygon/usdc/relations';
import arbitrumRelationConfigMap from './deployments/arbitrum/usdc/relations';
import arbitrumBridgedUsdcRelationConfigMap from './deployments/arbitrum/usdc.e/relations';
import arbitrumNativeUsdcRelationConfigMap from './deployments/arbitrum/usdc/relations';
import arbitrumBridgedUsdcGoerliRelationConfigMap from './deployments/arbitrum-goerli/usdc.e/relations';
import arbitrumGoerliNativeUsdcRelationConfigMap from './deployments/arbitrum-goerli/usdc/relations';
import baseGoerliRelationConfigMap from './deployments/base-goerli/usdc/relations';
Expand Down Expand Up @@ -282,7 +283,8 @@ const config: HardhatUserConfig = {
usdc: polygonRelationConfigMap
},
arbitrum: {
usdc: arbitrumRelationConfigMap
'usdc.e': arbitrumBridgedUsdcRelationConfigMap,
usdc: arbitrumNativeUsdcRelationConfigMap
},
'arbitrum-goerli': {
'usdc.e': arbitrumBridgedUsdcGoerliRelationConfigMap,
Expand Down Expand Up @@ -344,7 +346,13 @@ const config: HardhatUserConfig = {
auxiliaryBase: 'mainnet'
},
{
name: 'arbitrum',
name: 'arbitrum-usdc.e',
network: 'arbitrum',
deployment: 'usdc.e',
auxiliaryBase: 'mainnet'
},
{
name: 'arbitrum-usdc',
network: 'arbitrum',
deployment: 'usdc',
auxiliaryBase: 'mainnet'
Expand Down
Loading
Loading