Skip to content

Commit

Permalink
Deploy and proposal for native USDC market on Arbitrum Goerli (#793)
Browse files Browse the repository at this point in the history
* Deploy Arbitrum goerli for usdc native (#778)

* 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

* rename bridged version to .e to match with mainnet

* ported changes to testnet

* update on workflow

* hmm the error is gone

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

* move migration steps out of this branch

* add readme.md to corner cases when deploy new market on the chain with an existing market already

* add line

* removed USDC in relations

* update version to unblock deploy workerflow for now

* use dummy requested_network id

* try arbitrum goerli network id right away

* change a bit on how it locates the hardhat config base

* remove hardcoded network chain-id

* no more manual wallet project id input

* use env.GOV_NETWORK

* GOV_NETWORK got some errors :[

* try this seacrest with fixes

* try new seacrest :D

* Modified deployment roots from GitHub Actions

* Migrate Arbitrum Goerli Native usdc (#779)

* migration scripts commits

* set supply and borrow speeds to be non zero

* add diff check

* add diff checker

* added comments on checks

* now scenario run is passing, but with the cost of removing linea's contract addresses from goerli/roots.json

* add linea back, but scenario run will fail. But it's not related to arbitrum-goerli

* Upgrade git action to use new seacrest (#782)

* upgrade git action to use new seacrest

* Fix unverified Linea Goerli contract issue (#787)

* addressed comments

* first initial working version of CCTP attestation script to help check with circle attestation status to mint native USDC to destination

* attestation script with sending txn on user behalf

* fix lint

* fix lint

* Modified migration from GitHub Actions

---------

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

* removed asdf config file that should've been ignored

* add native usdc whale for arbitrum goerli

---------

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

* revert some mixed up changes when extracted from #769

* fix name

* update reference path

* fix lint

* Update hardhat.config.ts

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

* Update hardhat.config.ts

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

* fix error

---------

Co-authored-by: Kevin Cheng <[email protected]>
  • Loading branch information
cwang25 and kevincheng96 authored Jul 21, 2023
1 parent 761028a commit 9a962f0
Show file tree
Hide file tree
Showing 17 changed files with 569 additions and 66 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, base-goerli, base-goerli-weth, linea-goerli ]
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]
name: Run scenarios
env:
ETHERSCAN_KEY: ${{ secrets.ETHERSCAN_KEY }}
Expand Down
15 changes: 10 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -232,11 +232,16 @@ These simulations are extremely useful for testing deployments before actually c

#### Deploy Workflow

0. Create the deployment script and configuration file, and test locally
1. Open a PR containing the new deployment directory files
2. Trigger the `deploy-market` workflow action through the GitHub UI
3. Inspect the new `roots.json` which the workflow automatically commited to your PR
4. Start using the new protocol deployment and/or create further migrations to modify it
1. Create the deployment script and configuration file, and test locally
2. Open a PR containing the new deployment directory files
3. Trigger the `deploy-market` workflow action through the GitHub UI
4. Inspect the new `roots.json` which the workflow automatically commited to your PR
5. Start using the new protocol deployment and/or create further migrations to modify it

##### Deploy Script Gotchas and Tips

- If the deploy script is for a new market on a chain with an existing market, make sure to call 'setFactory(address,address)' in the initialization migration script.
(TODO: Scenarios will fail prior to running the migration script because the factory will not be set during deployment, will need to figure out a better way)

##### Verifying Deployments

Expand Down
56 changes: 56 additions & 0 deletions deployments/arbitrum-goerli/usdc.e/configuration.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
{
"name": "Compound USDC",
"symbol": "cUSDCv3",
"baseToken": "USDC.e",
"baseTokenAddress": "0x8FB1E3fC51F3b789dED7557E680551d93Ea9d892",
"baseTokenPriceFeed": "0x1692Bdd32F31b831caAc1b0c9fAF68613682813b",
"borrowMin": "100e6",
"pauseGuardian": "0x6C2fD6738e43ce0cc4A6f23a37e3a733516794A0",
"storeFrontPriceFactor": 0.5,
"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": "0e15",
"baseBorrowSpeed": "0e15",
"baseMinForRewards": "10000e6"
},
"assets": {
"LINK": {
"address": "0xbb7303602be1b9149b097aafb094ffce1860e532",
"priceFeed": "0xd28Ba6CA3bB72bF371b80a2a0a33cBcf9073C954",
"decimals": "18",
"borrowCF": 0.775,
"liquidateCF": 0.825,
"liquidationFactor": 0.95,
"supplyCap": "5000000e18"
},
"WETH": {
"address": "0xe39ab88f8a4777030a534146a9ca3b52bd5d43a3",
"priceFeed": "0x62CAe0FA2da220f43a51F86Db2EDb36DcA9A5A08",
"decimals": "18",
"borrowCF": 0.775,
"liquidateCF": 0.825,
"liquidationFactor": 0.95,
"supplyCap": "5000e18"
},
"WBTC": {
"address": "0x22d5e2dE578677791f6c90e0110Ec629be9d5Fb5",
"priceFeed": "0x6550bc2301936011c1334555e62A87705A81C12C",
"decimals": "8",
"borrowCF": 0.7,
"liquidateCF": 0.75,
"liquidationFactor": 0.93,
"supplyCap": "300e8"
}
}
}
70 changes: 70 additions & 0 deletions deployments/arbitrum-goerli/usdc.e/deploy.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
import { Deployed, DeploymentManager } from '../../../plugins/deployment_manager';
import { DeploySpec, deployComet } from '../../../src/deploy';

const SECONDS_PER_DAY = 24 * 60 * 60;

const GOERLI_TIMELOCK = '0x8Fa336EB4bF58Cfc508dEA1B0aeC7336f55B1399';

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', '0x8FB1E3fC51F3b789dED7557E680551d93Ea9d892', 'arbitrum-goerli');
const LINK = await deploymentManager.existing('LINK', '0xbb7303602be1b9149b097aafb094ffce1860e532', 'arbitrum-goerli');
const WETH = await deploymentManager.existing('WETH', '0xe39ab88f8a4777030a534146a9ca3b52bd5d43a3', 'arbitrum-goerli');
const WBTC = await deploymentManager.existing('WBTC', '0x22d5e2dE578677791f6c90e0110Ec629be9d5Fb5', 'arbitrum-goerli');

// 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
10 * 60, // delay
14 * SECONDS_PER_DAY, // grace period
10 * 60, // minimum delay
30 * SECONDS_PER_DAY // maximum delay
]
);

// Initialize ArbitrumBridgeReceiver
await deploymentManager.idempotent(
async () => !(await bridgeReceiver.initialized()),
async () => {
trace(`Initializing BridgeReceiver`);
await bridgeReceiver.initialize(
GOERLI_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
};
}
29 changes: 29 additions & 0 deletions deployments/arbitrum-goerli/usdc.e/relations.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import baseRelationConfig from '../../relations';

export default {
...baseRelationConfig,
governor: {
artifact: 'contracts/bridges/arbitrum/ArbitrumBridgeReceiver.sol:ArbitrumBridgeReceiver'
},
ClonableBeaconProxy: {
artifact: 'contracts/ERC20.sol:ERC20'
},
// USDC
'0x8FB1E3fC51F3b789dED7557E680551d93Ea9d892': {
artifact: 'contracts/ERC20.sol:ERC20',
delegates: {
field: {
slot: '0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc'
}
}
},
// WETH
'0xe39ab88f8a4777030a534146a9ca3b52bd5d43a3': {
artifact: 'contracts/ERC20.sol:ERC20',
delegates: {
field: {
slot: '0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc'
}
}
}
};
7 changes: 7 additions & 0 deletions deployments/arbitrum-goerli/usdc.e/roots.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"comet": "0x1d573274E19174260c5aCE3f2251598959d24456",
"configurator": "0x1Ead344570F0f0a0cD86d95d8adDC7855C8723Fb",
"rewards": "0x8DA65F8E3Aa22A498211fc4204C498ae9050DAE4",
"bridgeReceiver": "0xAC9fC1a9532BC92a9f33eD4c6Ce4A7a54930F376",
"bulker": "0x987350Af5a17b6DdafeB95E6e329c178f44841d7"
}
8 changes: 4 additions & 4 deletions deployments/arbitrum-goerli/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": "0x8FB1E3fC51F3b789dED7557E680551d93Ea9d892",
"baseTokenAddress": "0xfd064A18f3BF249cf1f87FC203E90D8f650f2d63",
"baseTokenPriceFeed": "0x1692Bdd32F31b831caAc1b0c9fAF68613682813b",
"borrowMin": "100e6",
"borrowMin": "1e6",
"pauseGuardian": "0x6C2fD6738e43ce0cc4A6f23a37e3a733516794A0",
"storeFrontPriceFactor": 0.5,
"targetReserves": "5000000e6",
Expand All @@ -20,8 +20,8 @@
},
"tracking": {
"indexScale": "1e15",
"baseSupplySpeed": "0e15",
"baseBorrowSpeed": "0e15",
"baseSupplySpeed": "0.000402083333333e15",
"baseBorrowSpeed": "0.000402083333333e15",
"baseMinForRewards": "10000e6"
},
"assets": {
Expand Down
57 changes: 12 additions & 45 deletions deployments/arbitrum-goerli/usdc/deploy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,61 +10,28 @@ export default async function deploy(deploymentManager: DeploymentManager, deplo
const ethers = deploymentManager.hre.ethers;

// pull in existing assets
const USDC = await deploymentManager.existing('USDC', '0x8FB1E3fC51F3b789dED7557E680551d93Ea9d892', 'arbitrum-goerli');
const USDC = await deploymentManager.existing('USDC', '0xfd064A18f3BF249cf1f87FC203E90D8f650f2d63', 'arbitrum-goerli');
const LINK = await deploymentManager.existing('LINK', '0xbb7303602be1b9149b097aafb094ffce1860e532', 'arbitrum-goerli');
const WETH = await deploymentManager.existing('WETH', '0xe39ab88f8a4777030a534146a9ca3b52bd5d43a3', 'arbitrum-goerli');
const WBTC = await deploymentManager.existing('WBTC', '0x22d5e2dE578677791f6c90e0110Ec629be9d5Fb5', 'arbitrum-goerli');

// 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
10 * 60, // delay
14 * SECONDS_PER_DAY, // grace period
10 * 60, // minimum delay
30 * SECONDS_PER_DAY // maximum delay
]
);

// Initialize ArbitrumBridgeReceiver
await deploymentManager.idempotent(
async () => !(await bridgeReceiver.initialized()),
async () => {
trace(`Initializing BridgeReceiver`);
await bridgeReceiver.initialize(
GOERLI_TIMELOCK, // govTimelock
localTimelock.address // localTimelock
);
trace(`BridgeReceiver initialized`);
}
);
// Import shared contracts from cUSDCv3
const cometAdmin = await deploymentManager.fromDep('cometAdmin', 'arbitrum-goerli', 'usdc.e');
const cometFactory = await deploymentManager.fromDep('cometFactory', 'arbitrum-goerli', 'usdc.e');
const $configuratorImpl = await deploymentManager.fromDep('configurator:implementation', 'arbitrum-goerli', 'usdc.e');
const configurator = await deploymentManager.fromDep('configurator', 'arbitrum-goerli', 'usdc.e');
const rewards = await deploymentManager.fromDep('rewards', 'arbitrum-goerli', 'usdc.e');
const bulker = await deploymentManager.fromDep('bulker', 'arbitrum-goerli', 'usdc.e');
const localTimelock = await deploymentManager.fromDep('timelock', 'arbitrum-goerli', 'usdc.e');
const bridgeReceiver = await deploymentManager.fromDep('bridgeReceiver', 'arbitrum-goerli', '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
bulker,
rewards,
};
}
Loading

0 comments on commit 9a962f0

Please sign in to comment.