Skip to content

Commit

Permalink
deploy to testnets
Browse files Browse the repository at this point in the history
  • Loading branch information
jarvisnn committed Jun 22, 2021
1 parent 63d6a0c commit aa12bf9
Show file tree
Hide file tree
Showing 7 changed files with 134 additions and 53 deletions.
20 changes: 17 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,26 @@ PRIVATE_KEY=0x****************************************************************
2. Run `yarn test -h` for instruction

```bash
yarn test [-h] [-c <eth,bsc>] [-n <mainnet>] -- to run test on specific chain and network
yarn <deploy,test> [-h] [-c <eth,bsc,polygon>] [-n <mainnet,testnet,ropsten>] -- to run test on specific chain and network

where:
-h show this help text
-c which chain to run, supported <eth,bsc>
-n which network to run, supported <mainnet>
-c which chain to run, supported <eth,bsc,polygon>
-n which network to run, supported <mainnet,testnet,ropsten,mumbai>
-f specific test to run if any
```
## Deploying
1. Run `yarn deploy -h` for instruction
```bash
yarn <deploy,test> [-h] [-c <eth,bsc,polygon>] [-n <mainnet,testnet,ropsten>] -- to run test on specific chain and network

where:
-h show this help text
-c which chain to run, supported <eth,bsc,polygon>
-n which network to run, supported <mainnet,testnet,ropsten,mumbai>
-f specific test to run if any
```
Expand Down
29 changes: 18 additions & 11 deletions tst.sh → cmd.sh
Original file line number Diff line number Diff line change
@@ -1,18 +1,19 @@
#!/bin/sh

usage="yarn test [-h] [-c <eth,bsc,polygon>] [-n <mainnet,testnet,ropsten>] -- to run test on specific chain and network
usage="yarn <deploy,test> [-h] [-c <eth,bsc,polygon>] [-n <mainnet,testnet,ropsten>] -- to run test on specific chain and network
where:
-h show this help text
-c which chain to run, supported <eth,bsc,polygon>
-n which network to run, supported <mainnet,ropsten>
-n which network to run, supported <mainnet,testnet,ropsten,mumbai>
-f specific test to run if any"

# Default chain and network
CHAIN="eth"
NETWORK="mainnet"
NETWORK="ropsten"
CMD="test"

while getopts ":hc:n:f:" option; do
while getopts ":hc:n:f:x:" option; do
case $option in
h)
echo "$usage"
Expand All @@ -22,18 +23,20 @@ while getopts ":hc:n:f:" option; do
if [[ ! "$OPTARG" =~ ^(eth|bsc|polygon)$ ]]; then
printf "invalid value for -%s\n" "$option" >&2
echo "$usage" >&2
exit 1P
exit 1
fi
CHAIN=$OPTARG;;
n)
if [[ ! "$OPTARG" =~ ^(mainnet|ropsten|testnet)$ ]]; then
if [[ ! "$OPTARG" =~ ^(mainnet|ropsten|testnet|mumbai)$ ]]; then
printf "invalid value for -%s\n" "$option" >&2
echo "$usage" >&2
exit 1
fi
NETWORK=$OPTARG;;
f)
FILE=$OPTARG;;
x)
CMD=$OPTARG;;
:)
printf "missing argument for -%s\n" "$OPTARG" >&2
echo "$usage" >&2
Expand All @@ -47,9 +50,13 @@ while getopts ":hc:n:f:" option; do
esac
done

if [ -n "$FILE" ]; then
CHAIN=$CHAIN NETWORK=$NETWORK yarn hardhat test --no-compile --network hardhat $FILE
else
echo "Running all tests..."
CHAIN=$CHAIN NETWORK=$NETWORK yarn hardhat test --no-compile --network hardhat
if [ $CMD == "test" ]; then
if [ -n "$FILE" ]; then
CHAIN=$CHAIN NETWORK=$NETWORK yarn hardhat test --no-compile --network hardhat $FILE
else
echo "Running all tests..."
CHAIN=$CHAIN NETWORK=$NETWORK yarn hardhat test --no-compile --network hardhat
fi
elif [ $CMD == "deploy" ]; then
CHAIN=$CHAIN NETWORK=$NETWORK yarn hardhat run scripts/deployer.ts --network "$CHAIN"_"$NETWORK"
fi
46 changes: 20 additions & 26 deletions contracts.json
Original file line number Diff line number Diff line change
@@ -1,42 +1,36 @@
{
"bsc_testnet_v1.0": {
"smartWalletImplementation": "0xE17E0D29De09214BBAcBcf31f2F57fbd72Fa1430",
"smartWalletProxy": "0xCc5197Dd8CdA6B1A48CD0082697Dba50753123D2",
"fetchTokenBalances": "0x2491ae103685BbfBbcfC668c2Ec3b18bBcE3e4bD",
"swapContracts": {
"uniSwap": "0x181Cf7df196612c6cb4eCA09c257156c4CB26F1C"
},
"lendingContracts": {
"compoundLending": "0x4C7A19b5191A308ca21f0aFC1Ad0828B55f7842C"
}
},
"bsc_mainnet_v1.0": {
"_v1.0_bsc_mainnet": {
"SmartWalletImplementation": "0xAE0505c0C30Dc0EA077cDB4Ed1B2BB894D9c6B65",
"SmartWalletProxy": "0x2FA1e7dF142665320cA916AFDA9DFD9A97C9b986",
"FetchTokenBalances": "0x465661625B3B96b102a49e07E2Eb31cC9F5cE58B"
},
"eth_ropsten": {
"smartWalletImplementation": "0x0B29C3CEd4DD3Cc34e559070cB2d4ed49a5f6b83",
"smartWalletProxy": "0xD9B1c826C8c290113ebB66F82A2F0f9EE4582964",
"fetchTokenBalances": "0xE60D933aE2Ded269FDF7A1d8EE5504bC50d8b364",
"_v1.0_bsc_testnet": {
"SmartWalletSwapImplementation": "0xfF0A25c7E0621358b8f84771D275810e47D35b6f",
"SmartWalletSwapProxy": "0xE7314051BCFD832398e232f2c274278c44121a3f",
"FetchTokenBalances": "0x813718C50df497BC136d5d6dfc0E0aDA8AB0C93e"
},
"bsc_testnet": {
"smartWalletImplementation": "0x25750A5FED63A79ddE8E516f8A0D3C4EbA656F79",
"smartWalletProxy": "0xA58573970cfFAd93309071cE9aff46b8A35eC62B",
"fetchTokenBalances": "0xEB029e27F86D4FA920e214Cbb933924C6df91e83",
"swapContracts": {
"uniSwap": "0xb7Bc27d8EcfAdBE52AA28DDa94e0e807bA6fDF1F",
"uniSwapV3": "0x6c9e1226F7a0940B195FD52BD8c73B3804Ec6bD1",
"kyberProxy": "0xD050274563048a0bde6180214bb97382093F1418"
"uniSwap": "0xf5a40993852e6C47B4981bEAC1659BF09B83C521"
},
"lendingContracts": {
"compoundLending": "0x0c607BaDcA1B2277DbA62b7c2d7B0F128DE1Ffc1"
"compoundLending": "0xb455810945407Ad3146B74Aa3773df1cDaD61b11"
}
},
"bsc_testnet": {
"smartWalletImplementation": "0x15315662e60848fb7329265EbE94967E2f97f333",
"smartWalletProxy": "0xEa21147D0001b0f362D05d737ce1314456070cC1",
"fetchTokenBalances": "0x497a5639527361349B64B8103ad18Be51639808A",
"eth_ropsten": {
"smartWalletImplementation": "0x379801fabAEDFB07e43e4Eb2E76199921f08858e",
"smartWalletProxy": "0xf351Dd5EC89e5ac6c9125262853c74E714C1d56a",
"fetchTokenBalances": "0xA526388721De4cB8206ff4D0b1A1948696b5d073",
"swapContracts": {
"uniSwap": "0xb716c894e14F5890bdD39A63e220ACa78CFB6a4A"
"uniSwap": "0x0C816D6C4C37294186CBCA0E514Fc56F0c34d059",
"uniSwapV3": "0x2FA1e7dF142665320cA916AFDA9DFD9A97C9b986",
"kyberProxy": "0x465661625B3B96b102a49e07E2Eb31cC9F5cE58B"
},
"lendingContracts": {
"compoundLending": "0x1a56c1688d68334809a80Bf173515C96ee0B2eAF"
"compoundLending": "0x60fc810EA972809d729FCE0043B82a58766596ee"
}
}
}
24 changes: 15 additions & 9 deletions hardhat.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,18 +100,9 @@ if (MAINNET_FORK) {
}

if (PRIVATE_KEY) {
config.networks!.polygon_mainnet = {
url: 'https://rpc-mainnet.matic.network',
chainId: 137,
gasPrice: 20000000000,
accounts: [PRIVATE_KEY],
timeout: 20000,
};

config.networks!.bsc_testnet = {
url: 'https://data-seed-prebsc-1-s1.binance.org:8545',
chainId: 97,
gasPrice: 20000000000,
accounts: [PRIVATE_KEY],
timeout: 20000,
};
Expand All @@ -125,6 +116,20 @@ if (PRIVATE_KEY) {
}

if (PRIVATE_KEY && INFURA_API_KEY) {
config.networks!.polygon_mainnet = {
url: `https://polygon-mainnet.infura.io/v3/${INFURA_API_KEY}`,
chainId: 137,
accounts: [PRIVATE_KEY],
timeout: 20000,
};

config.networks!.polygon_mumbai = {
url: `https://polygon-mumbai.infura.io/v3/${INFURA_API_KEY}`,
chainId: 80001,
accounts: [PRIVATE_KEY],
timeout: 20000,
};

config.networks!.eth_kovan = {
url: `https://kovan.infura.io/v3/${INFURA_API_KEY}`,
chainId: 42,
Expand All @@ -144,6 +149,7 @@ if (PRIVATE_KEY && INFURA_API_KEY) {
chainId: 3,
accounts: [PRIVATE_KEY],
timeout: 20000,
gasPrice: 20 * 1e9,
};

config.networks!.eth_mainnet = {
Expand Down
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@
"test": "test"
},
"scripts": {
"test": "./tst.sh",
"t": "./tst.sh",
"test": "./cmd.sh -x test",
"t": "yarn test",
"compile": "export NODE_OPTIONS=--max-old-space-size=4096 && yarn hardhat compile",
"c": "yarn compile",
"coverage": "yarn hardhat coverage",
"deploy": "yarn hardhat run scripts/deployer.ts",
"deploy": "./cmd.sh -x deploy",
"d": "yarn deploy",
"prettier": "./node_modules/.bin/prettier --write",
"size": "yarn run hardhat size-contracts",
Expand Down
50 changes: 50 additions & 0 deletions scripts/config_polygon.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,4 +51,54 @@ export const PolygonConfig: Record<string, IConfig> = {
supportedWallets: commonPlatformWallets,
fundedAmount: 10000, // swap some matic each for every token
},

polygon_mumbai: {
autoVerifyContract: true,

tokens: [
// {symbol: 'quick', address: '0x831753dd7087cac61ab5644b308642cc1c33dc13'},
// {symbol: 'uni', address: '0xb33eaad8d922b1083446dc23f610c2567fb5180f'},'
// {symbol: 'aave', address: '0xd6df932a45c0f255f85145f286ea0b292b21c90b'},
// {symbol: 'weth', address: '0x7ceB23fD6bC0adD59E62ac25578270cFf1b9f619'},
{symbol: 'dai', address: '0x8f3Cf7ad23Cd3CaDbD9735AFf958023239c6A063'},
{symbol: 'usdc', address: '0x2791bca1f2de4661ed88a30c99a7a9449aa84174'},
],

wNative: '0x0d500B1d8E8eF31E21C99d1Db9A6444d3ADf1270',

// Uniswap & clones
uniswap: {
routers: [
'0xFCB5348111665Cf95a777f0c4FCA768E05601760', // quickswap
],
},

// Compound
// compound: {
// compTroller: '0x3d9819210a31b4961b30ef54be2aed79b9c9cd3b',
// cNative: '0x4ddc2d193948926d02f9b1fe9e1daa0718270ed5',
// // empty array for the full market data
// 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
],
},

supportedWallets: commonPlatformWallets,
fundedAmount: 10000, // swap some matic each for every token
},
};
12 changes: 11 additions & 1 deletion scripts/deployer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,21 @@ try {
contracts = {};
}

const sortObject = (obj: Record<string, any>) => {
let res: Record<string, any> = {};
Object.keys(obj)
.sort((a, b) => (a > b ? 1 : -1))
.forEach((k: string) => {
res[k] = obj[k];
});
return res;
};

deploy(contracts[network.name])
.then((deployedContracts) => {
// Save contracts' addresses
contracts[network.name] = convertToAddressObject(deployedContracts);
const json = JSON.stringify(contracts, null, 2) + '\n';
const json = JSON.stringify(sortObject(contracts), null, 2) + '\n';
fs.writeFileSync(contractsFile, json, 'utf8');
process.exit(0);
})
Expand Down

0 comments on commit aa12bf9

Please sign in to comment.