Skip to content

Commit

Permalink
Deploy to all chain with new impl contract (#18)
Browse files Browse the repository at this point in the history
* deploy to all chain except ethereum mainnet

* new impl contracts on bsc, missin gpolygon and eth

* deploy polygon

* polygon mumbai

* verify contract after deploying

* update
  • Loading branch information
Jarvis authored Aug 2, 2021
1 parent 0209b9e commit 1ce1329
Show file tree
Hide file tree
Showing 6 changed files with 116 additions and 91 deletions.
31 changes: 21 additions & 10 deletions contracts.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"FetchTokenBalances": "0x813718C50df497BC136d5d6dfc0E0aDA8AB0C93e"
},
"bsc_mainnet": {
"smartWalletImplementation": "0x52643C0C0CCABd8C70baF5f1b6842886f0f8b953",
"smartWalletImplementation": "0x95ceC39Aa053C62d1A49D88B60620a489C241F53",
"smartWalletProxy": "0x051DC16b2ECB366984d1074dCC07c342a9463999",
"fetchTokenBalances": "0xB8C6Ed80688a2674623D89A0AaBD3a87507B1868",
"fetchAaveDataWrapper": "0xE7314051BCFD832398e232f2c274278c44121a3f",
Expand All @@ -22,9 +22,10 @@
}
},
"bsc_testnet": {
"smartWalletImplementation": "0x25750A5FED63A79ddE8E516f8A0D3C4EbA656F79",
"smartWalletImplementation": "0xe66cc698a26a943A6152040662e88b254f9afcAa",
"smartWalletProxy": "0xA58573970cfFAd93309071cE9aff46b8A35eC62B",
"fetchTokenBalances": "0xEB029e27F86D4FA920e214Cbb933924C6df91e83",
"fetchAaveDataWrapper": "0x9e81428F5672EDCea83F5bf58b6B2cD968df8EE6",
"swapContracts": {
"uniSwap": "0xf5a40993852e6C47B4981bEAC1659BF09B83C521"
},
Expand All @@ -33,7 +34,7 @@
}
},
"eth_mainnet": {
"smartWalletImplementation": "0x379801fabAEDFB07e43e4Eb2E76199921f08858e",
"smartWalletImplementation": "0x051DC16b2ECB366984d1074dCC07c342a9463999",
"smartWalletProxy": "0x70270C228c5B4279d1578799926873aa72446CcD",
"fetchTokenBalances": "0xA526388721De4cB8206ff4D0b1A1948696b5d073",
"fetchAaveDataWrapper": "0x0C816D6C4C37294186CBCA0E514Fc56F0c34d059",
Expand All @@ -45,22 +46,22 @@
},
"lendingContracts": {
"compoundLending": "0x8C27aBf05DE1d4847c3924566C3cBAFec6eFb42A",
"aaveV1Lending": "0x66f54006B47d1b381b5B933F2De9bf05a6B4Eb40",
"aaveV2Lending": "0xAE0505c0C30Dc0EA077cDB4Ed1B2BB894D9c6B65",
"aaveAMMLending": "0x2bcfCaA40395F4f38Ad1aFa8915BF11d9df8Cf56"
"aaveV1": "0x66f54006B47d1b381b5B933F2De9bf05a6B4Eb40",
"aaveV2": "0xAE0505c0C30Dc0EA077cDB4Ed1B2BB894D9c6B65"
}
},
"eth_rinkeby": {
"smartWalletImplementation": "0xf351Dd5EC89e5ac6c9125262853c74E714C1d56a",
"smartWalletImplementation": "0xD7eA9048908F5E19DCcdD9623dc820feDbb54D45",
"smartWalletProxy": "0xAE0505c0C30Dc0EA077cDB4Ed1B2BB894D9c6B65",
"fetchTokenBalances": "0x8C27aBf05DE1d4847c3924566C3cBAFec6eFb42A",
"fetchAaveDataWrapper": "0x9295A8F78540418f5Ab58Bba5879D87665C3A16C",
"swapContracts": {
"uniSwap": "0x66f54006B47d1b381b5B933F2De9bf05a6B4Eb40"
},
"lendingContracts": {}
},
"eth_ropsten": {
"smartWalletImplementation": "0x813718C50df497BC136d5d6dfc0E0aDA8AB0C93e",
"smartWalletImplementation": "0x2ce6E029f52da66c95682541F3c230c28E72dF14",
"smartWalletProxy": "0xf351Dd5EC89e5ac6c9125262853c74E714C1d56a",
"fetchTokenBalances": "0xA526388721De4cB8206ff4D0b1A1948696b5d073",
"fetchAaveDataWrapper": "0xD7eA9048908F5E19DCcdD9623dc820feDbb54D45",
Expand All @@ -75,7 +76,7 @@
}
},
"polygon_mainnet": {
"smartWalletImplementation": "0xa303f067D511673832e57ACEF3d4FE6F333557e4",
"smartWalletImplementation": "0xedE7cc39C5160d7DD82Eb5Ec71c63AEEe442cf32",
"smartWalletProxy": "0x70270c228c5b4279d1578799926873aa72446ccd",
"fetchTokenBalances": "0xf351Dd5EC89e5ac6c9125262853c74E714C1d56a",
"fetchAaveDataWrapper": "0x8C27aBf05DE1d4847c3924566C3cBAFec6eFb42A",
Expand All @@ -84,7 +85,17 @@
"kyberDmm": "0x52643C0C0CCABd8C70baF5f1b6842886f0f8b953"
},
"lendingContracts": {
"aaveV2": "0xB8C6Ed80688a2674623D89A0AaBD3a87507B1868"
"aaveV2": "0x95ceC39Aa053C62d1A49D88B60620a489C241F53"
}
},
"polygon_mumbai": {
"smartWalletImplementation": "0x52643C0C0CCABd8C70baF5f1b6842886f0f8b953",
"smartWalletProxy": "0x6deaAe9d76991db2943064Bca84e00f63c46C0A3",
"fetchTokenBalances": "0xB8C6Ed80688a2674623D89A0AaBD3a87507B1868",
"fetchAaveDataWrapper": "0xE7314051BCFD832398e232f2c274278c44121a3f",
"swapContracts": {
"uniSwap": "0x813718C50df497BC136d5d6dfc0E0aDA8AB0C93e"
},
"lendingContracts": {}
}
}
4 changes: 2 additions & 2 deletions hardhat.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ if (PRIVATE_KEY && INFURA_API_KEY) {
chainId: 137,
accounts: [PRIVATE_KEY],
timeout: 20000,
gasPrice: 2 * 1e9,
gasPrice: 5 * 1e9,
};

config.networks!.polygon_mumbai = {
Expand Down Expand Up @@ -163,7 +163,7 @@ if (PRIVATE_KEY && INFURA_API_KEY) {
chainId: 1,
accounts: [PRIVATE_KEY],
timeout: 20000,
gasPrice: 15 * 1e9,
gasPrice: 25 * 1e9,
};
}

Expand Down
2 changes: 1 addition & 1 deletion scripts/config_bsc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export const BscConfig: Record<string, IConfig> = {
compTroller: '0xfd36e2c2a6789db23113685031d7f16329158384',
// cBNB or cETH
cNative: '0xA07c5b74C9B40447a954e1466938b865b6BBea36',
// https://api.compound.io/api/cToken
// https://api.venus.io/api/vToken
// empty array for the full market data
cTokens: [],
},
Expand Down
59 changes: 30 additions & 29 deletions scripts/config_eth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ export const EthConfig: Record<string, IConfig> = {
'0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2', // weth
'0x0bc529c00C6401aEF6D220BE8C6Ea1667F6Ad93e', // yfi
'0xE41d2489571d322189246DaFA5ebDe1F4699F498', // zrx
'0x80fB784B7eD66730e8b1DBd9820aFD29931aab03', // lend
],
},

Expand Down Expand Up @@ -118,35 +119,35 @@ export const EthConfig: Record<string, IConfig> = {
],
},

aaveAMM: {
poolV2: '0x7937d4799803fbbe595ed57278bc4ca21f3bffcb',
provider: '0xc443AD9DDE3cecfB9dfC5736578f447aFE3590ba',
weth: '0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
referralCode: 157,
tokens: [
'0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2', // weth
'0x6B175474E89094C44Da98b954EedeAC495271d0F', // dai
'0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48', // usdc
'0xdAC17F958D2ee523a2206206994597C13D831ec7', // usdt
'0x2260FAC5E5542a773Aa44fBCfeDf7C193bc2C599', // wbtc
'0xA478c2975Ab1Ea89e8196811F51A7B7Ade33eB11', // uniDaiEth
'0xBb2b8038a1640196FbE3e38816F3e67Cba72D940', // uniWbtcWeth
'0xDFC14d2Af169B0D36C4EFF567Ada9b2E0CAE044f', // uniAaveWeth
'0xB6909B960DbbE7392D405429eB2b3649752b4838', // uniBatWeth
'0xAE461cA67B15dc8dc81CE7615e0320dA1A9aB8D5', // uniDaiUsdc
'0x3dA1313aE46132A397D90d95B1424A9A7e3e0fCE', // uniCrvWeth
'0xa2107FA5B38d9bbd2C461D6EDf11B11A50F6b974', // uniLinkWeth
'0xC2aDdA861F89bBB333c90c492cB837741916A225', // uniMkrWeth
'0x8Bd1661Da98EBDd3BD080F0bE4e6d9bE8cE9858c', // uniRenWeth
'0x43AE24960e5534731Fc831386c07755A2dc33D47', // uniSnxWeth
'0xd3d2E2692501A5c9Ca623199D38826e513033a17', // uniUniWeth
'0xB4e16d0168e52d35CaCD2c6185b44281Ec28C9Dc', // uniUsdcWeth
'0x004375Dff511095CC5A197A54140a24eFEF3A416', // uniWbtcUsdc
'0x2fDbAdf3C4D5A8666Bc06645B8358ab803996E28', // uniYfiWeth
'0x1efF8aF5D577060BA4ac8A29A13525bb0Ee2A3D5', // bptWbtcWeth
'0x59A19D8c652FA0284f44113D0ff9aBa70bd46fB4', // bptBalWeth
],
},
// aaveAMM: {
// poolV2: '0x7937d4799803fbbe595ed57278bc4ca21f3bffcb',
// provider: '0xc443AD9DDE3cecfB9dfC5736578f447aFE3590ba',
// weth: '0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
// referralCode: 157,
// tokens: [
// '0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2', // weth
// '0x6B175474E89094C44Da98b954EedeAC495271d0F', // dai
// '0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48', // usdc
// '0xdAC17F958D2ee523a2206206994597C13D831ec7', // usdt
// '0x2260FAC5E5542a773Aa44fBCfeDf7C193bc2C599', // wbtc
// '0xA478c2975Ab1Ea89e8196811F51A7B7Ade33eB11', // uniDaiEth
// '0xBb2b8038a1640196FbE3e38816F3e67Cba72D940', // uniWbtcWeth
// '0xDFC14d2Af169B0D36C4EFF567Ada9b2E0CAE044f', // uniAaveWeth
// '0xB6909B960DbbE7392D405429eB2b3649752b4838', // uniBatWeth
// '0xAE461cA67B15dc8dc81CE7615e0320dA1A9aB8D5', // uniDaiUsdc
// '0x3dA1313aE46132A397D90d95B1424A9A7e3e0fCE', // uniCrvWeth
// '0xa2107FA5B38d9bbd2C461D6EDf11B11A50F6b974', // uniLinkWeth
// '0xC2aDdA861F89bBB333c90c492cB837741916A225', // uniMkrWeth
// '0x8Bd1661Da98EBDd3BD080F0bE4e6d9bE8cE9858c', // uniRenWeth
// '0x43AE24960e5534731Fc831386c07755A2dc33D47', // uniSnxWeth
// '0xd3d2E2692501A5c9Ca623199D38826e513033a17', // uniUniWeth
// '0xB4e16d0168e52d35CaCD2c6185b44281Ec28C9Dc', // uniUsdcWeth
// '0x004375Dff511095CC5A197A54140a24eFEF3A416', // uniWbtcUsdc
// '0x2fDbAdf3C4D5A8666Bc06645B8358ab803996E28', // uniYfiWeth
// '0x1efF8aF5D577060BA4ac8A29A13525bb0Ee2A3D5', // bptWbtcWeth
// '0x59A19D8c652FA0284f44113D0ff9aBa70bd46fB4', // bptBalWeth
// ],
// },

supportedWallets: commonPlatformWallets,
fundedAmount: 5, // swap 5 eth each for every token
Expand Down
32 changes: 16 additions & 16 deletions scripts/config_polygon.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,22 +85,22 @@ export const PolygonConfig: Record<string, IConfig> = {
// cTokens: [],
// },

aaveV2: {
poolV2: '0x8dff5e27ea6b7ac08ebfdf9eb090f32ee9a30fcf',
provider: '0x7551b5D2763519d4e37e8B81929D336De671d46d',
weth: '0x0d500b1d8e8ef31e21c99d1db9a6444d3adf1270', // wmatic
referralCode: 157,
// empty array for the full market data
tokens: [
'0xD6DF932A45C0f255f85145f286eA0b292B21C90B', // aave
'0x8f3Cf7ad23Cd3CaDbD9735AFf958023239c6A063', // dai
'0x2791Bca1f2de4661ED88A30C99A7a9449Aa84174', // usdc
'0xc2132D05D31c914a87C6611C10748AEb04B58e8F', // usdt
'0x1BFD67037B42Cf73acF2047067bd4F2C47D9BfD6', // wbtc
'0x7ceB23fD6bC0adD59E62ac25578270cFf1b9f619', // weth
'0x0d500B1d8E8eF31E21C99d1Db9A6444d3ADf1270', // wmatic
],
},
// aaveV2: {
// poolV2: '0x8dff5e27ea6b7ac08ebfdf9eb090f32ee9a30fcf',
// provider: '0x7551b5D2763519d4e37e8B81929D336De671d46d',
// weth: '0x0d500b1d8e8ef31e21c99d1db9a6444d3adf1270', // wmatic
// referralCode: 157,
// // empty array for the full market data
// tokens: [
// '0xD6DF932A45C0f255f85145f286eA0b292B21C90B', // aave
// '0x8f3Cf7ad23Cd3CaDbD9735AFf958023239c6A063', // dai
// '0x2791Bca1f2de4661ED88A30C99A7a9449Aa84174', // usdc
// '0xc2132D05D31c914a87C6611C10748AEb04B58e8F', // usdt
// '0x1BFD67037B42Cf73acF2047067bd4F2C47D9BfD6', // wbtc
// '0x7ceB23fD6bC0adD59E62ac25578270cFf1b9f619', // weth
// '0x0d500B1d8E8eF31E21C99d1Db9A6444d3ADf1270', // wmatic
// ],
// },

supportedWallets: commonPlatformWallets,
fundedAmount: 10000, // swap some matic each for every token
Expand Down
79 changes: 46 additions & 33 deletions scripts/deployLogic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ async function deployContracts(
++step,
networkConfig.autoVerifyContract,
'AaveV1Lending',
existingContract?.['lendingContracts']?.['aaveV1Lending'],
existingContract?.['lendingContracts']?.['aaveV1'],
contractAdmin
)) as AaveV1Lending,

Expand All @@ -212,7 +212,7 @@ async function deployContracts(
++step,
networkConfig.autoVerifyContract,
'AaveV2Lending',
existingContract?.['lendingContracts']?.['aaveV2Lending'],
existingContract?.['lendingContracts']?.['aaveV2'],
contractAdmin
)) as AaveV2Lending,

Expand All @@ -222,7 +222,7 @@ async function deployContracts(
++step,
networkConfig.autoVerifyContract,
'AaveV2Lending',
existingContract?.['lendingContracts']?.['aaveAMMLending'],
existingContract?.['lendingContracts']?.['aaveAMM'],
contractAdmin
)) as AaveV2Lending,
};
Expand Down Expand Up @@ -264,23 +264,24 @@ async function deployContract(
log(1, '------------------------------------');

const factory = await ethers.getContractFactory(contractName);
let contract;

if (contractAddress) {
log(2, `> contract already exists`);
log(2, `> address:\t${contractAddress}`);
// TODO: Transfer admin if needed
return factory.attach(contractAddress);
contract = factory.attach(contractAddress);
} else {
contract = await factory.deploy(...args);
const tx = await contract.deployed();
await printInfo(tx.deployTransaction);
log(2, `> address:\t${contract.address}`);
}

const contract = await factory.deploy(...args);
const tx = await contract.deployed();
await printInfo(tx.deployTransaction);
log(2, `> address:\t${contract.address}`);

if (autoVerify) {
try {
log(3, '>> sleep first, wait for contract data to be propagated');
await sleep(10000);
await sleep(5000);
log(3, '>> start verifying');
await run('verify:verify', {
address: contract.address,
Expand Down Expand Up @@ -443,8 +444,7 @@ async function updateCompoundLending(compoundLending: CompoundLending | undefine
log(1, 'update compound data');
let compoundData = await compoundLending.compoundData();
// comptroller is at the first 20 bytes
let currentComptroller = '0x' + compoundData.slice(2, 40);
if (currentComptroller === networkConfig.compound.compTroller) {
if (compoundData.toLowerCase() === networkConfig.compound.compTroller.toLowerCase()) {
log(2, `comptroller already up-to-date at ${networkConfig.compound.compTroller}`);
} else {
const tx = await executeTxn(
Expand All @@ -466,16 +466,21 @@ async function updateAaveV1Lending(aaveV1Lending: AaveV1Lending | undefined, ext
}

log(1, 'update aave v1 data');
const tx = await executeTxn(
await aaveV1Lending.populateTransaction.updateAaveData(
networkConfig.aaveV1.poolV1,
networkConfig.aaveV1.poolCoreV1,
networkConfig.aaveV1.referralCode,
networkConfig.aaveV1.tokens
)
);
log(2, '> updated aave v1', JSON.stringify(networkConfig.aaveV1, null, 2));
await printInfo(tx);
let aaveData = await aaveV1Lending.aaveData();
if (networkConfig.aaveV1.poolV1.toLowerCase() === aaveData.lendingPoolV1.toLowerCase()) {
log(2, `aave pool already up-to-date at ${networkConfig.aaveV1.poolV1}`);
} else {
const tx = await executeTxn(
await aaveV1Lending.populateTransaction.updateAaveData(
networkConfig.aaveV1.poolV1,
networkConfig.aaveV1.poolCoreV1,
networkConfig.aaveV1.referralCode,
networkConfig.aaveV1.tokens
)
);
log(2, '> updated aave v1', JSON.stringify(networkConfig.aaveV1, null, 2));
await printInfo(tx);
}
}

async function updateAaveV2Lending(
Expand All @@ -489,17 +494,25 @@ async function updateAaveV2Lending(
}

log(1, 'update aave v2 data');
const tx = await executeTxn(
await aaveV2Lending.populateTransaction.updateAaveData(
aaveV2Config.provider,
aaveV2Config.poolV2,
aaveV2Config.referralCode,
aaveV2Config.weth,
aaveV2Config.tokens
)
);
log(2, '> updated aave v2', JSON.stringify(networkConfig.aaveV2, null, 2));
await printInfo(tx);
let aaveData = await aaveV2Lending.aaveData();
if (
aaveV2Config.poolV2.toLowerCase() === aaveData.lendingPoolV2.toLowerCase() &&
aaveV2Config.provider.toLowerCase() === aaveData.provider.toLowerCase()
) {
log(2, `aave pool and provider already up-to-date`);
} else {
const tx = await executeTxn(
await aaveV2Lending.populateTransaction.updateAaveData(
aaveV2Config.provider,
aaveV2Config.poolV2,
aaveV2Config.referralCode,
aaveV2Config.weth,
aaveV2Config.tokens
)
);
log(2, '> updated aave v2', JSON.stringify(networkConfig.aaveV2, null, 2));
await printInfo(tx);
}
}

async function updateAddressSet(
Expand Down

0 comments on commit 1ce1329

Please sign in to comment.