Skip to content

Commit

Permalink
Merge pull request #64 from Into-the-Fathom/dev-multisig-scripts
Browse files Browse the repository at this point in the history
Multisig Scripts - Maximum Coverage
  • Loading branch information
TonioMacaronio authored Aug 1, 2023
2 parents af55036 + 2deaa25 commit f0a511a
Show file tree
Hide file tree
Showing 56 changed files with 1,182 additions and 57 deletions.
3 changes: 3 additions & 0 deletions contracts/dao/test/dex/IUniswapV2Factory.sol
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// SPDX-License-Identifier: MIT
// Original Copyright Uniswap
// Copyright Fathom 2022
pragma solidity >=0.6.2;

interface IUniswapV2Factory {
Expand Down
3 changes: 3 additions & 0 deletions contracts/dao/test/dex/IUniswapV2Pair.sol
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// SPDX-License-Identifier: MIT
// Original Copyright Uniswap
// Copyright Fathom 2022
pragma solidity >=0.5.0;

interface IUniswapV2Pair {
Expand Down
3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,19 @@
"test-with-timeout": "coralX test --params TIMEOUT=100000",
"test-skip-compile": "coralX test skip_compile true",
"test-use-snapshot": "coralX test skip_compile true use_snapshot true",

"compile": "npm run prettier && npm run lint && coralX compile",
"prettier": "prettier --write 'contracts/**/*.sol'",
"lint": "solhint 'contracts/**/*.sol'",
"pre-release": "npm run prettier && npm run lint && npm run test-with-timeout",

"migrate-reset": "coralX scenario --run migrateAndConfigureForTests",
"migrate-reset-sepolia": "rm -rf build/contracts && rm -rf build/job-logs && coralX compile && coralX scenario --run deploySepolia",
"migrate-reset-apothem-dev": "export NODE_ENV=dev && rm -rf build/contracts && rm -rf build/job-logs && coralX compile && coralX scenario --run deployApothem",
"migrate-reset-apothem-demo": "export NODE_ENV=demo && rm -rf build/contracts && rm -rf build/job-logs && coralX compile && coralX scenario --run deployApothem",
"migrate-reset-apothem-qa": "export NODE_ENV=qa && rm -rf build/contracts && rm -rf build/job-logs && coralX compile && coralX scenario --run deployApothem",
"migrate-reset-xdc": "export NODE_ENV=prod && rm -rf build/contracts && rm -rf build/job-logs && coralX compile && coralX scenario --run deployXDC",

"migrate-reset-staking-upgrade-apothem-dev": "export NODE_ENV=dev && rm -rf build/contracts && rm -rf build/job-logs && coralX compile && coralX scenario --run deployUpgradedStakingContractApothem",
"migrate-reset-staking-upgrade-apothem-demo": "export NODE_ENV=demo && rm -rf build/contracts && rm -rf build/job-logs && coralX compile && coralX scenario --run deployUpgradedStakingContractApothem",
"migrate-reset-staking-upgrade-apothem-qa": "export NODE_ENV=qa && rm -rf build/contracts && rm -rf build/job-logs && coralX compile && coralX scenario --run deployUpgradedStakingContractApothem",
Expand Down
4 changes: 2 additions & 2 deletions scripts/migrations/test/1_deploy_test_contracts.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ module.exports = async function(deployer) {
let promises = [
deployer.deploy(Box, { gas: 12000000 }),
deployer.deploy(ERC20Factory, { gas: 12000000 }),
deployer.deploy(ERC20TokenReward1, "Reward2 Tokens", "R2T", web3.utils.toWei("1000000","ether"), accounts[0], { gas: 3600000 }),
deployer.deploy(ERC20TokenReward2, "Reward2 Tokens", "R3T", web3.utils.toWei("1000000","ether"), accounts[0], { gas: 3600000 }),deployer.deploy(
deployer.deploy(ERC20TokenReward1, "Reward2 Tokens", "R2T", web3.utils.toWei("100000000","ether"), accounts[0], { gas: 3600000 }),
deployer.deploy(ERC20TokenReward2, "Reward2 Tokens", "R3T", web3.utils.toWei("100000000","ether"), accounts[0], { gas: 3600000 }),deployer.deploy(
TokenTimelock,
MainToken.address,
accounts[0], // beneficiary
Expand Down
7 changes: 3 additions & 4 deletions scripts/migrations/test/6_init_main_stream.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,17 +57,16 @@ const _encodeInitMainStreamFunction = (_owner, _scheduleTimes, _scheduleRewards,
const tau = 2;

module.exports = async function(deployer) {

const startTime = await _getTimeStamp() + 3 * 24 * 60 * 60;
const oneYear = 31556926;
const oneMonth = 2628288;
const scheduleTimes = [
startTime,
startTime + 4 * oneYear,
startTime + 48 * oneMonth
];

const scheduleRewards = [
web3.utils.toWei('200000000', 'ether'),
web3.utils.toWei("0", 'ether')
web3.utils.toWei('0', 'ether')
];


Expand Down
4 changes: 2 additions & 2 deletions scripts/units/create_pool_dex.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ const env = process.env.NODE_ENV || 'dev';
const addressesConfig = require(`../../config/config.${env}`)


const Token_A_Address = "0xf31146956Cb3be9EFD6Cfd665Cb4Cb5Aeeb5cA3e" //FTHM
const Token_B_Address = "0x0Cc79883b6FF52B857bDA7D5Df9214eE0bb28839" //WXDC
const Token_A_Address = "0xDf29cB40Cb92a1b8E8337F542E3846E185DefF96" //FTHM
const Token_B_Address = "0x916D9BFa4480418bE7b653f4808106709a38b4fc" //FXD
// SET AS Necessary
const Amount_A_Desired = web3.utils.toWei('100000', 'ether')
const Amount_B_Desired = web3.utils.toWei('100000', 'ether')
Expand Down
8 changes: 4 additions & 4 deletions scripts/units/create_pool_dex_xdc.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ const env = process.env.NODE_ENV || 'dev';
const addressesConfig = require(`../../config/config.${env}`)

const TOKEN_ADDRESS = addresses.fthmToken //FTHM address
const AMOUNT_TOKEN_DESIRED = web3.utils.toWei('2', 'ether')
const AMOUNT_TOKEN_MIN = web3.utils.toWei('0', 'ether')
const AMOUNT_TOKEN_ETH = web3.utils.toWei('3', 'ether')
const AMOUNT_ETH_MIN = web3.utils.toWei('1', 'ether')
const AMOUNT_TOKEN_DESIRED = web3.utils.toWei('2.144', 'ether')
const AMOUNT_TOKEN_MIN = web3.utils.toWei('2.144', 'ether')
const AMOUNT_TOKEN_ETH = web3.utils.toWei('50', 'ether')
const AMOUNT_ETH_MIN = web3.utils.toWei('50', 'ether')

//const DEX_ROUTER_ADDRESS = "0x05b0e01DD9737a3c0993de6F57B93253a6C3Ba95"//old router
const DEX_ROUTER_ADDRESS = addressesConfig.DEX_ROUTER_ADDRESS
Expand Down
7 changes: 5 additions & 2 deletions scripts/units/helpers/constants.js
Original file line number Diff line number Diff line change
@@ -1,18 +1,21 @@
const SUBMIT_TRANSACTION_EVENT = "SubmitTransaction(uint256,address,address,uint256,bytes)";
const EMPTY_BYTES = '0x0000000000000000000000000000000000000000000000000000000000000000';

const NULL_ADDRESS = '0x0000000000000000000000000000000000000000'
// Update the PATH_TO_ADDRESSES based on the NODE_ENV environment variable
const env = process.env.NODE_ENV || 'dev';
const PATH_TO_ADDRESSES = `../../addresses.${env}.json`;
const PATH_TO_ADDRESSES_FOR_DEX_FOLDER = `../../../config/config.${env}`
const PATH_TO_ADDRESSES_FOR_STABLECOIN_FOLDER = `../../../../config/config.${env}`
const PATH_TO_NEWLY_GENERATED_TRANSACTION_INDEX = `./config/newly-generated-transaction-index.${env}.json`;
const PATH_TO_ADDRESSES_FOR_STAKING_POSITION_FOLDER = `../../../addresses.staking-position.${env}.json`;

module.exports = {
SUBMIT_TRANSACTION_EVENT,
EMPTY_BYTES,
PATH_TO_ADDRESSES,
PATH_TO_NEWLY_GENERATED_TRANSACTION_INDEX,
PATH_TO_ADDRESSES_FOR_DEX_FOLDER,
PATH_TO_ADDRESSES_FOR_STABLECOIN_FOLDER
PATH_TO_ADDRESSES_FOR_STABLECOIN_FOLDER,
PATH_TO_ADDRESSES_FOR_STAKING_POSITION_FOLDER,
NULL_ADDRESS
}
3 changes: 3 additions & 0 deletions scripts/units/helpers/create-config-QA.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@ else
COLLATERAL_POOL_CONFIG_ADDRESS: "",
DEX_FACTORY_ADDRESS: "",
WETH_ADDRESS: "",
STABLE_SWAP_WRAPPER_ADDRESS:"",
STAKING_ADDRESS:"",
VAULT_ADDRESS:"",
COUNCIL_1:"",
COUNCIL_2:"",
COUNCIL_3:""
Expand Down
3 changes: 3 additions & 0 deletions scripts/units/helpers/create-config-demo.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@ else
COLLATERAL_POOL_CONFIG_ADDRESS: "",
DEX_FACTORY_ADDRESS: "",
WETH_ADDRESS: "",
STABLE_SWAP_WRAPPER_ADDRESS:"",
STAKING_ADDRESS:"",
VAULT_ADDRESS:"",
COUNCIL_1:"",
COUNCIL_2:"",
COUNCIL_3:""
Expand Down
3 changes: 3 additions & 0 deletions scripts/units/helpers/create-config-dev.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@ else
COLLATERAL_POOL_CONFIG_ADDRESS: "",
DEX_FACTORY_ADDRESS: "",
WETH_ADDRESS: "",
STABLE_SWAP_WRAPPER_ADDRESS:"",
STAKING_ADDRESS:"",
VAULT_ADDRESS:"",
COUNCIL_1:"",
COUNCIL_2:"",
COUNCIL_3:""
Expand Down
3 changes: 3 additions & 0 deletions scripts/units/helpers/create-config-prod.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@ else
COLLATERAL_POOL_CONFIG_ADDRESS: "",
DEX_FACTORY_ADDRESS: "",
WETH_ADDRESS: "",
STABLE_SWAP_WRAPPER_ADDRESS:"",
STAKING_ADDRESS:"",
VAULT_ADDRESS:"",
COUNCIL_1:"",
COUNCIL_2:"",
COUNCIL_3:""
Expand Down
5 changes: 4 additions & 1 deletion scripts/units/helpers/submitAndExecuteTransaction.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ const createTransactionObject = (TransactionName, tx, resultSubmitTransaction, r
};
return transactionObject;
}

//@note: We can use this to generate encoded function as required
//@note: To do it comment out this line: await _submitExecuteAndSaveTransaction();
async function submitAndExecute(encodedFunction, targetAddress, TransactionName, ETH_AMOUNT=0, shouldExecute = true) {

const MULTISIG_WALLET_ADDRESS = addresses.multiSigWallet;
Expand Down Expand Up @@ -79,7 +80,9 @@ async function submitAndExecute(encodedFunction, targetAddress, TransactionName,
transactionObject.confirmationTransactionHash,
transactionObject.executeTransactionHash)
}
console.log(`encoded function for the transaction --${TransactionName} is: ${encodedFunction}`)

//@note: comment out this line: await _submitExecuteAndSaveTransaction(); to only have console of the encodings
await _submitExecuteAndSaveTransaction();

}
Expand Down
23 changes: 11 additions & 12 deletions scripts/units/remove-liqudiity-dex.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ const env = process.env.NODE_ENV || 'dev';
const addressesConfig = require(`../../config/config.${env}`);
const { default: BigNumber } = require('bignumber.js');

const Token_A_Address = "0xD033b52657F3580092914e1976715e0cbC622855" //USD
const Token_B_Address = "0x603B972D894bF754B63103ECB4b70b024096451D" //WXDC
const Token_A_Address = addressesConfig.FXD_ADDRESS //USD
const Token_B_Address = addresses.fthmToken //WXDC

// SET AS Necessary
const LIQUIDITY = web3.utils.toWei('99999.999999999999999', 'ether')
Expand Down Expand Up @@ -106,7 +106,6 @@ module.exports = async function(deployer) {
const uniswapFactory = await IUniswapFactory.at(addressesConfig.DEX_FACTORY_ADDRESS)
const pairAddress = await uniswapFactory.getPair(Token_A_Address, Token_B_Address)
const pairToken = await IUniswapV2Pair.at(pairAddress)

const balance = (await pairToken.balanceOf(multiSigWallet.address)).toString()
const reserves = await pairToken.getReserves();
const token0 = await pairToken.token0();
Expand All @@ -120,15 +119,15 @@ module.exports = async function(deployer) {
const minAmountA = new BigNumber(amountADesired - amountADesired * SLIPPAGE)
const minAmountB = new BigNumber(amountBDesired - amountBDesired * SLIPPAGE)

// await txnHelper.submitAndExecute(
// _encodeApproveFunction(
// addressesConfig.DEX_ROUTER_ADDRESS,
// balance
// )
// ,pairAddress,
// "ApproveTxn",
// 0
// )
await txnHelper.submitAndExecute(
_encodeApproveFunction(
addressesConfig.DEX_ROUTER_ADDRESS,
balance
)
,pairAddress,
"ApproveTxn",
0
)

await txnHelper.submitAndExecute(
_encodeRemoveLiquidity(
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
const fs = require('fs');
const txnHelper = require('../../helpers/submitAndExecuteTransaction')

const constants = require('../../helpers/constants')
const addressesConfig = require(constants.PATH_TO_ADDRESSES_FOR_STABLECOIN_FOLDER)
const COLLATERAL_TOKEN_ADAPTER_ADDRESS =addressesConfig.COLLATERAL_TOKEN_ADAPTER_ADDRESS
const toBeWhitelisted = ""
const _encodeAddToWhitelist = (toBeWhitelisted) => {
let toRet = web3.eth.abi.encodeFunctionCall({
name: 'whitelist',
type: 'function',
inputs: [{
type: 'address',
name: 'toBeWhitelisted'
}]
}, [toBeWhitelisted]);

return toRet;
}


module.exports = async function(deployer) {

await txnHelper.submitAndExecute(
_encodeAddToWhitelist(toBeWhitelisted),
COLLATERAL_TOKEN_ADAPTER_ADDRESS,
"WhitelistCollateralTokenAdapter"
)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
const fs = require('fs');
const txnHelper = require('../../helpers/submitAndExecuteTransaction')

const constants = require('../../helpers/constants')
const addressesConfig = require(constants.PATH_TO_ADDRESSES_FOR_STABLECOIN_FOLDER)
const COLLATERAL_TOKEN_ADAPTER_ADDRESS =addressesConfig.COLLATERAL_TOKEN_ADAPTER_ADDRESS
const _amount = web3.utils.toWei("100000","wei")
const _usr = ""
const _encodeWithdraw = (_usr, _amount) => {
let toRet = web3.eth.abi.encodeFunctionCall({
name: 'withdraw',
type: 'function',
inputs: [{
type: 'address',
name: '_usr'
}, {
type: 'uint256',
name: '_amount'
},{
type: 'bytes'
}]
}, [_usr,_amount]);

return toRet;
}


module.exports = async function(deployer) {

await txnHelper.submitAndExecute(
_encodeWithdraw(_usr,_amount),
COLLATERAL_TOKEN_ADAPTER_ADDRESS,
"WithdrawCollateralTokenAdapter"
)
}
36 changes: 36 additions & 0 deletions scripts/units/stablecoin/adapter/withdraw-stablecoin-adapter.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
const fs = require('fs');
const txnHelper = require('../../helpers/submitAndExecuteTransaction')

const constants = require('../../helpers/constants')
const addressesConfig = require(constants.PATH_TO_ADDRESSES_FOR_STABLECOIN_FOLDER)
const BOOK_KEEPER_ADDRESS =addressesConfig.BOOK_KEEPER_ADDRESS
const STABLE_COIN_ADAPTER_ADDRESS =addressesConfig.STABLE_COIN_ADAPTER_ADDRESS
const wad = web3.utils.toWei("100000","wei")
const usr = ""
const _encodeWithdraw = (usr, wad) => {
let toRet = web3.eth.abi.encodeFunctionCall({
name: 'withdraw',
type: 'function',
inputs: [{
type: 'address',
name: 'usr'
}, {
type: 'uint256',
name: 'wad'
},{
type: 'bytes'
}]
}, [usr,wad]);

return toRet;
}


module.exports = async function(deployer) {

await txnHelper.submitAndExecute(
_encodeWithdraw(usr,wad),
STABLE_COIN_ADAPTER_ADDRESS,
"WithdrawStablecoinAdapter"
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,4 @@ module.exports = async function(deployer) {
BOOK_KEEPER_ADDRESS,
"setAllowlistedAddressBookkeeper"
)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
const fs = require('fs');
const txnHelper = require('../../helpers/submitAndExecuteTransaction')

const constants = require('../../helpers/constants')
const addressesConfig = require(constants.PATH_TO_ADDRESSES_FOR_STABLECOIN_FOLDER)

const BOOK_KEEPER_ADDRESS =addressesConfig.BOOK_KEEPER_ADDRESS
const AccessControlConfig = ""
const _encodeSetAccessControlConfig = (_accessControlConfig) => {
let toRet = web3.eth.abi.encodeFunctionCall({
name: 'setAccessControlConfig',
type: 'function',
inputs: [{
type: 'address',
name: '_accessControlConfig'
}]
}, [_accessControlConfig]);

return toRet;
}


module.exports = async function(deployer) {

await txnHelper.submitAndExecute(
_encodeSetAccessControlConfig(AccessControlConfig),
BOOK_KEEPER_ADDRESS,
"setAccessControlConfig"
)
}
30 changes: 30 additions & 0 deletions scripts/units/stablecoin/book-keeper/set-collateral-pool-config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
const fs = require('fs');
const txnHelper = require('../../helpers/submitAndExecuteTransaction')

const constants = require('../../helpers/constants')
const addressesConfig = require(constants.PATH_TO_ADDRESSES_FOR_STABLECOIN_FOLDER)

const BOOK_KEEPER_ADDRESS =addressesConfig.BOOK_KEEPER_ADDRESS
const CollateralPoolConfig = ""
const _encodeSetCollateralPoolConfig = (_collateralPoolConfig) => {
let toRet = web3.eth.abi.encodeFunctionCall({
name: 'setCollateralPoolConfig',
type: 'function',
inputs: [{
type: 'address',
name: '_collateralPoolConfig'
}]
}, [_collateralPoolConfig]);

return toRet;
}


module.exports = async function(deployer) {

await txnHelper.submitAndExecute(
_encodeSetCollateralPoolConfig(CollateralPoolConfig),
BOOK_KEEPER_ADDRESS,
"setCollateralPoolConfig"
)
}
Loading

0 comments on commit f0a511a

Please sign in to comment.