Skip to content

Commit

Permalink
Deploy and initialize native USDC market on Arbitrum (#769)
Browse files Browse the repository at this point in the history
* initial gen

* remove files

* rename directory

* add scenario

* upadte deploy script

* renamde to usdc.n

* added relations for scenario test

* add scenario test to CI

* add migration scrtips, but just changed the USDC reference address

* update migration script

* since it's native, we shouldn't need usdc bridge things in migration

* try to fix the liquidator scenario errors

* intent

* change those to be 0 initially

* FINALLY scneario passed :D

* don't re-deploy bulker

* set a number in configuration to make bulker tests pass

* set configuration to 0 supply cap for initialization, although it will fail the bulker test

* update liquidity pool to use the one with better liquidity

* after new pool use better liquidity, now able to bump up the volume

* remove v2 rewards config step, crank down borrowMin

* update migration description

* remove trailing newline

* ok need to referencing existing rewards in deploy script to share the rewards'

* naming changes

* added cctp contracts address to roots and update relayArbitrummessage

* add l2 cctp

* depositForBurn() to use CCTP to send native USDC to arbitrum comet

* finally relayArbitrum works with CCTP

* format

* update to turn off bridge market's reward speed

* fix scenarios and slightly reduced volume in liquidator scenarios (somehow during testing the pool the bot uses to flashloan have been withdrew and don't have full liquidity to cover tests

* now it has just enough liquidity to pass the test, reverted the liquidation scenario back to usual amount

* address comments: remove network prefixes, move contract import from deploy to migration scripts, move relay specific contracts to relay script

* remove network prefixes, and rename bridgeComet to usdceComet

* rename/refactor usdc -> usdc.e, and usdc.n -> usdc. Also rename deplyoment name for  to  and  to

* luckily by the time of testing now Jul 6th 1:40PM PST, we have enough liquidity in the uniswap USDC.e:USDC pool to cover the unchanged volume liquidation scenarios test

* rename usdc.n to usdc

* make yarn lint happy

* change default supply reward speed on new comet to be 0

* hardat confit resolve conflicts

* removed migration script, and set supply cap to 0 on configuration

* set reward speed to zero

* set borrow min to 1 wer

* Update deployments/arbitrum/usdc/deploy.ts

Co-authored-by: Kevin Cheng <[email protected]>

* Modified deployment roots from GitHub Actions

* Migrate and initialize Arbitrum Native USDC market (#789)

* Revert "move migration files to separate PR, and keep this original one to be 'deploy' PR"

This reverts commit f1f9808.

* update configurate to meet with the feedback from testnet

* fix scenario test error and udpate migration to meet the latest official market list and prepare for the official launch

* update speed to 10COMP/day and update migration description

* uncommented state change verify, since comet has been deployed

* 10/86400 is irrationale number so it is 0.000115740740740 to be the closest value that falls within e15 limit

* fix migrations

* fix typo

* update description

* Modified migration from GitHub Actions

* Update deployments/arbitrum/usdc/migrations/1686953660_configurate_and_ens.ts

Co-authored-by: Kevin Cheng <[email protected]>

* removed comments

---------

Co-authored-by: GitHub Actions Bot <>
Co-authored-by: Kevin Cheng <[email protected]>

* add arb mainnet messagetransmitter

---------

Co-authored-by: Kevin Cheng <[email protected]>
Co-authored-by: GitHub Actions Bot <>
  • Loading branch information
cwang25 and kevincheng96 authored Sep 12, 2023
1 parent 658f451 commit 22cf923
Show file tree
Hide file tree
Showing 19 changed files with 669 additions and 67 deletions.
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-usdbc, base-weth, 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-usdbc, base-weth, 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'
}
}
}
};
7 changes: 7 additions & 0 deletions deployments/arbitrum/usdc.e/roots.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"comet": "0xA5EDBDD9646f8dFF606d7448e414884C7d905dCA",
"configurator": "0xb21b06D71c75973babdE35b49fFDAc3F82Ad3775",
"rewards": "0x88730d254A2f7e6AC8388c3198aFd694bA9f7fae",
"bridgeReceiver": "0x42480C37B249e33aABaf4c22B20235656bd38068",
"bulker": "0xbdE8F31D2DdDA895264e27DD990faB3DC87b372d"
}
6 changes: 3 additions & 3 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": "1e0",
"pauseGuardian": "0x78E6317DD6D43DdbDa00Dce32C2CbaFc99361a9d",
"storeFrontPriceFactor": 0.8,
"targetReserves": "5000000e6",
Expand All @@ -20,7 +20,7 @@
},
"tracking": {
"indexScale": "1e15",
"baseSupplySpeed": "0.000402083333333e15",
"baseSupplySpeed": "0.000115740740740e15",
"baseBorrowSpeed": "0e15",
"baseMinForRewards": "10000e6"
},
Expand Down
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 the USDC.e market
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,
};
}
Loading

0 comments on commit 22cf923

Please sign in to comment.