Skip to content

Commit

Permalink
chore: updating the audit contract setup script
Browse files Browse the repository at this point in the history
  • Loading branch information
kupermind committed Aug 18, 2023
1 parent 3bee97f commit 144ac1e
Show file tree
Hide file tree
Showing 4 changed files with 126 additions and 27 deletions.
8 changes: 7 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,13 @@ The finalized contract ABIs for deployment and their number of optimization pass
For testing purposes, the hardhat node deployment script is located [here](https://github.com/valory-xyz/autonolas-tokenomics/blob/main/deploy).

## Deployed Protocol
The list of addresses can be found [here](https://github.com/valory-xyz/autonolas-tokenomics/blob/main/docs/mainnet_addresses.json).
The list of contract addresses for different chains and their full contract configuration can be found [here](https://github.com/valory-xyz/autonolas-tokenomics/blob/main/docs/configuration.json).

In order to test the protocol setup on all the deployed chains, the audit script is implemented. Make sure to export
required API keys for corresponding chains (see the script for more information). The audit script can be run as follows:
```
node scripts/audit_chains/audit_contracts_setup.js
```

## LP Token Guide
It is advised to check the following [list of instructions](https://github.com/valory-xyz/autonolas-tokenomics/blob/main/docs/LP_token_guide.md) before enabling OLAS-based LP tokens.
Expand Down
2 changes: 1 addition & 1 deletion docs/configuration.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
{
"name": "Depository",
"artifact": "abis/0.8.20/Depository.json",
"address": "0xff8697d8d2998d6aa2e09b405795c6f4beeb0c81"
"address": "0xfF8697d8d2998d6AA2e09B405795C6F4BEeB0C81"
}
]
},
Expand Down
141 changes: 117 additions & 24 deletions scripts/audit_chains/audit_contracts_setup.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,6 @@ async function checkBytecode(provider, configContracts, contractName, log) {
const contractFromJSON = fs.readFileSync(configContracts[i]["artifact"], "utf8");
const parsedFile = JSON.parse(contractFromJSON);
const bytecode = parsedFile["deployedBytecode"];
console.log("\nContract name", configContracts[i]["name"]);
console.log("Contract address", configContracts[i]["address"]);
const onChainCreationCode = await provider.getCode(configContracts[i]["address"]);

// Compare last 8-th part of deployed bytecode bytes (wveOLAS can't manage more)
Expand Down Expand Up @@ -91,6 +89,9 @@ async function checkDonatorBlacklist(chainId, provider, globalsInstance, configC
const donatorBlacklist = await findContractInstance(provider, configContracts, contractName);

log += ", address: " + donatorBlacklist.address;
// Check the contract owner
const owner = await donatorBlacklist.owner();
customExpect(owner, globalsInstance["timelockAddress"], log + ", function: owner()");
}

// Check Tokenomics Proxy: chain Id, provider, parsed globals, configuration contracts, contract name
Expand All @@ -102,6 +103,25 @@ async function checkTokenomicsProxy(chainId, provider, globalsInstance, configCo
const tokenomics = await findContractInstance(provider, configContracts, contractName);

log += ", address: " + tokenomics.address;
// Check contract owner
const owner = await tokenomics.owner();
customExpect(owner, globalsInstance["timelockAddress"], log + ", function: owner()");

// Check OLAS token
const olas = await tokenomics.olas();
customExpect(olas, globalsInstance["olasAddress"], log + ", function: olas()");

// Check treasury
const treasury = await tokenomics.treasury();
customExpect(treasury, globalsInstance["treasuryAddress"], log + ", function: treasury()");

// Check depository
const depository = await tokenomics.depository();
customExpect(depository, globalsInstance["depositoryTwoAddress"], log + ", function: depository()");

// Check dispenser
const dispenser = await tokenomics.dispenser();
customExpect(dispenser, globalsInstance["dispenserAddress"], log + ", function: dispenser()");
}

// Check Treasury: chain Id, provider, parsed globals, configuration contracts, contract name
Expand All @@ -113,6 +133,33 @@ async function checkTreasury(chainId, provider, globalsInstance, configContracts
const treasury = await findContractInstance(provider, configContracts, contractName);

log += ", address: " + treasury.address;
// Check contract owner
const owner = await treasury.owner();
customExpect(owner, globalsInstance["timelockAddress"], log + ", function: owner()");

// Check OLAS token
const olas = await treasury.olas();
customExpect(olas, globalsInstance["olasAddress"], log + ", function: olas()");

// Check tokenomics
const tokenomics = await treasury.tokenomics();
customExpect(tokenomics, globalsInstance["tokenomicsProxyAddress"], log + ", function: tokenomics()");

// Check depository
const depository = await treasury.depository();
customExpect(depository, globalsInstance["depositoryTwoAddress"], log + ", function: depository()");

// Check dispenser
const dispenser = await treasury.dispenser();
customExpect(dispenser, globalsInstance["dispenserAddress"], log + ", function: dispenser()");

// Check minAcceptedETH (0.065 ETH)
const minAcceptedETH = await treasury.minAcceptedETH();
customExpect(minAcceptedETH.toString(), "65" + "0".repeat(15), log + ", function: minAcceptedETH()");

// Check paused
const paused = await treasury.paused();
customExpect(paused, false, log + ", function: paused()");
}

// Check Generic Bond Calculator: chain Id, provider, parsed globals, configuration contracts, contract name
Expand All @@ -124,6 +171,13 @@ async function checkGenericBondCalculator(chainId, provider, globalsInstance, co
const genericBondCalculator = await findContractInstance(provider, configContracts, contractName);

log += ", address: " + genericBondCalculator.address;
// Check OLAS token
const olas = await genericBondCalculator.olas();
customExpect(olas, globalsInstance["olasAddress"], log + ", function: olas()");

// Check tokenomics
const tokenomics = await genericBondCalculator.tokenomics();
customExpect(tokenomics, globalsInstance["tokenomicsProxyAddress"], log + ", function: tokenomics()");
}

// Check Dispenser: chain Id, provider, parsed globals, configuration contracts, contract name
Expand All @@ -135,6 +189,17 @@ async function checkDispenser(chainId, provider, globalsInstance, configContract
const dispenser = await findContractInstance(provider, configContracts, contractName);

log += ", address: " + dispenser.address;
// Check contract owner
const owner = await dispenser.owner();
customExpect(owner, globalsInstance["timelockAddress"], log + ", function: owner()");

// Check tokenomics
const tokenomics = await dispenser.tokenomics();
customExpect(tokenomics, globalsInstance["tokenomicsProxyAddress"], log + ", function: tokenomics()");

// Check treasury
const treasury = await dispenser.treasury();
customExpect(treasury, globalsInstance["treasuryAddress"], log + ", function: treasury()");
}

// Check Depository: chain Id, provider, parsed globals, configuration contracts, contract name
Expand All @@ -146,6 +211,33 @@ async function checkDepository(chainId, provider, globalsInstance, configContrac
const depository = await findContractInstance(provider, configContracts, contractName);

log += ", address: " + depository.address;
// Check contract owner
const owner = await depository.owner();
customExpect(owner, globalsInstance["timelockAddress"], log + ", function: owner()");

// Check OLAS token
const olas = await depository.olas();
customExpect(olas, globalsInstance["olasAddress"], log + ", function: olas()");

// Check tokenomics
const tokenomics = await depository.tokenomics();
customExpect(tokenomics, globalsInstance["tokenomicsProxyAddress"], log + ", function: tokenomics()");

// Check treasury
const treasury = await depository.treasury();
customExpect(treasury, globalsInstance["treasuryAddress"], log + ", function: treasury()");

// Check bond calculator
const bondCalculator = await depository.bondCalculator();
customExpect(bondCalculator, globalsInstance["genericBondCalculatorAddress"], log + ", function: bondCalculator()");

// Check version
const version = await depository.VERSION();
customExpect(version, "1.0.1", log + ", function: VERSION()");

// Check min vesting
const minVesting = Number(await depository.MIN_VESTING());
customExpect(minVesting, 3600 * 24, log + ", function: VERSION()");
}

async function main() {
Expand All @@ -171,28 +263,29 @@ async function main() {

console.log("\nVerifying deployed contracts vs the repo... If no error is output, then the contracts are correct.");

// // Traverse all chains
// for (let i = 0; i < numChains; i++) {
// // Skip gnosis chains
// if (!networks[configs[i]["name"]]) {
// continue;
// }
//
// console.log("\n\nNetwork:", configs[i]["name"]);
// const network = networks[configs[i]["name"]];
// const contracts = configs[i]["contracts"];
//
// // Verify contracts
// for (let j = 0; j < contracts.length; j++) {
// console.log("Checking " + contracts[j]["name"]);
// const execSync = require("child_process").execSync;
// try {
// execSync("scripts/audit_chains/audit_repo_contract.sh " + network + " " + contracts[j]["name"] + " " + contracts[j]["address"]);
// } catch (error) {
// }
// }
// }
// // ################################# /VERIFY CONTRACTS WITH REPO #################################
// Traverse all chains
for (let i = 0; i < numChains; i++) {
// Skip gnosis chains
if (!networks[configs[i]["name"]]) {
continue;
}

console.log("\n\nNetwork:", configs[i]["name"]);
const network = networks[configs[i]["name"]];
const contracts = configs[i]["contracts"];

// Verify contracts
for (let j = 0; j < contracts.length; j++) {
console.log("Checking " + contracts[j]["name"]);
const execSync = require("child_process").execSync;
try {
execSync("scripts/audit_chains/audit_repo_contract.sh " + network + " " + contracts[j]["name"] + " " + contracts[j]["address"]);
} catch (error) {
continue;
}
}
}
// ################################# /VERIFY CONTRACTS WITH REPO #################################

// ################################# VERIFY CONTRACTS SETUP #################################
const globalNames = {
Expand Down
2 changes: 1 addition & 1 deletion scripts/deployment/globals_mainnet.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"contractVerification":true,"useLedger":true,"derivationPath":"m/44'/60'/2'/0/0","providerName":"mainnet","olasAddress":"0x0001A500A6B18995B03f44bb040A5fFc28E45CB0","timelockAddress":"0x3C1fF68f5aa342D296d4DEe4Bb1cACCA912D95fE","veOLASAddress":"0x7e01A500805f8A52Fad229b3015AD130A332B7b3","governorAddress":"0x34C895f302D0b5cf52ec0Edd3945321EB0f83dd5","governorTwoAddress":"0x4E3e48bA826b15214FDe72a50BFd17aB286B584E","componentRegistryAddress":"0x15bd56669F57192a97dF41A2aa8f4403e9491776","agentRegistryAddress":"0x2F1f7D38e4772884b88f3eCd8B6b9faCdC319112","serviceRegistryAddress":"0x48b6af7B12C71f09e2fC8aF4855De4Ff54e775cA","epochLen":"2592000","donatorBlacklistAddress":"0xE85791B18F5df42163092Acc5C9da1c479AFEa9d","tokenomicsAddress":"0x87f89F94033305791B6269AE2F9cF4e09983E56e","tokenomicsProxyAddress":"0xc096362fa6f4A4B1a9ea68b1043416f3381ce300","treasuryAddress":"0xa0DA53447C0f6C4987964d8463da7e6628B30f82","genericBondCalculatorAddress":"0x1521918961bDBC9Ed4C67a7103D5999e4130E6CB","depositoryAddress":"0x52A043bcebdB2f939BaEF2E8b6F01652290eAB3f","dispenserAddress":"0xeED0000fE94d7cfeF4Dc0CA86a223f0F603A61B8","tokenomicsTwoAddress":"0xD599ED4a5c45Fa66AA3C474b00701Fd452a2C30e","OLAS_ETH_PairAddress":"0x09D1d767eDF8Fa23A64C51fa559E0688E526812F","depositoryTwoAddress":"0xff8697d8d2998d6aa2e09b405795c6f4beeb0c81"}
{"contractVerification":true,"useLedger":true,"derivationPath":"m/44'/60'/2'/0/0","providerName":"mainnet","olasAddress":"0x0001A500A6B18995B03f44bb040A5fFc28E45CB0","timelockAddress":"0x3C1fF68f5aa342D296d4DEe4Bb1cACCA912D95fE","veOLASAddress":"0x7e01A500805f8A52Fad229b3015AD130A332B7b3","governorAddress":"0x34C895f302D0b5cf52ec0Edd3945321EB0f83dd5","governorTwoAddress":"0x4E3e48bA826b15214FDe72a50BFd17aB286B584E","componentRegistryAddress":"0x15bd56669F57192a97dF41A2aa8f4403e9491776","agentRegistryAddress":"0x2F1f7D38e4772884b88f3eCd8B6b9faCdC319112","serviceRegistryAddress":"0x48b6af7B12C71f09e2fC8aF4855De4Ff54e775cA","epochLen":"2592000","donatorBlacklistAddress":"0xE85791B18F5df42163092Acc5C9da1c479AFEa9d","tokenomicsAddress":"0x87f89F94033305791B6269AE2F9cF4e09983E56e","tokenomicsProxyAddress":"0xc096362fa6f4A4B1a9ea68b1043416f3381ce300","treasuryAddress":"0xa0DA53447C0f6C4987964d8463da7e6628B30f82","genericBondCalculatorAddress":"0x1521918961bDBC9Ed4C67a7103D5999e4130E6CB","depositoryAddress":"0x52A043bcebdB2f939BaEF2E8b6F01652290eAB3f","dispenserAddress":"0xeED0000fE94d7cfeF4Dc0CA86a223f0F603A61B8","tokenomicsTwoAddress":"0xD599ED4a5c45Fa66AA3C474b00701Fd452a2C30e","OLAS_ETH_PairAddress":"0x09D1d767eDF8Fa23A64C51fa559E0688E526812F","depositoryTwoAddress":"0xfF8697d8d2998d6AA2e09B405795C6F4BEeB0C81"}

0 comments on commit 144ac1e

Please sign in to comment.