Skip to content

Commit

Permalink
Merge pull request #65 from Into-the-Fathom/dev
Browse files Browse the repository at this point in the history
1.2.2
  • Loading branch information
BaldyAsh authored Aug 1, 2023
2 parents 30aa0be + f0a511a commit 1d0dcb3
Show file tree
Hide file tree
Showing 59 changed files with 1,336 additions and 85 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
14 changes: 8 additions & 6 deletions scripts/units/create-fixed-lock-on-behalf-of-user.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,12 @@ const addressesConfig = require(`../../config/config.${env}`)
const LOCK_PERIOD = 365 * 24 * 60 * 60;
//SET AS NEEDED
// NOT MAX UINT for security as its not good to approve max for Multisig

// this is how much to stake for one council . Right now 10KK
const T_TO_STAKE = web3.utils.toWei('10000000', 'ether');
const T_TO_APPROVE = web3.utils.toWei('10000000', 'ether');

const ACCOUNT_TO_STAKE_FOR = addressesConfig.COUNCIL_1;
const ACCOUNT_TO_STAKE_FOR = "0x9a337088801B30a3eB715937BCDE27A34BC62841";

const rawdata = fs.readFileSync(constants.PATH_TO_ADDRESSES);
const addresses = JSON.parse(rawdata);
Expand Down Expand Up @@ -67,16 +69,16 @@ module.exports = async function(deployer) {
const stakingService = await IStaking.at(addresses.staking);

await txnHelper.submitAndExecute(
_encodeApproveFunction(stakingService.address,T_TO_STAKE),
_encodeApproveFunction(stakingService.address,T_TO_APPROVE),
addresses.fthmToken,
"ApproveFathomTxn"
)

const LockPositionForStaker = [_createLockParamObject(T_TO_STAKE,LOCK_PERIOD,ACCOUNT_TO_STAKE_FOR)]
const lockPositionForUser = _createLockParamObject(T_TO_STAKE,LOCK_PERIOD,ACCOUNT_TO_STAKE_FOR)
const allLockPositions = [lockPositionForUser]

await txnHelper.submitAndExecute(
_encodeCreateLocksForCouncils(LockPositionForStaker),
_encodeCreateLocksForCouncils(allLockPositions),
stakingService.address,
"createLocksForCouncilTxn"
"createLocksForUserTxn"
)
}
131 changes: 131 additions & 0 deletions scripts/units/create-fixed-locks-on-behalf-of-multiple-users.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,131 @@
//NOTE: This script can be run only once for each deployment as making COUNCIL_STAKES is only possible once
const fs = require('fs');

const constants = require('./helpers/constants')
const txnHelper = require('./helpers/submitAndExecuteTransaction')
const IStaking = artifacts.require('./dao/staking/interfaces/IStaking.sol');

const env = process.env.NODE_ENV || 'dev';
const addressesConfig = require(`../../config/config.${env}`)

const LOCK_PERIOD = 365 * 24 * 60 * 60;
//SET AS NEEDED
// this needs to be sum of all the stakes. Right now 10KK * 3.
// NOT MAX UINT for security as its not good to approve max for Multisig
// This needs to be sum of all the staking position
const T_TOTAL_TO_APPROVE = web3.utils.toWei('10000000', 'ether');
// this is how much to stake for each council
const T_TO_STAKE_USER_1 = web3.utils.toWei('1000000', 'ether'); //set as needed
const T_TO_STAKE_USER_2 = web3.utils.toWei('1000000', 'ether'); //set as needed
const T_TO_STAKE_USER_3 = web3.utils.toWei('1000000', 'ether'); //set as needed
const T_TO_STAKE_USER_4 = web3.utils.toWei('1000000', 'ether'); //set as needed
const T_TO_STAKE_USER_5 = web3.utils.toWei('1000000', 'ether'); //set as needed
const T_TO_STAKE_USER_6 = web3.utils.toWei('1000000', 'ether'); //set as needed
const T_TO_STAKE_USER_7 = web3.utils.toWei('1000000', 'ether'); //set as needed
const T_TO_STAKE_USER_8 = web3.utils.toWei('1000000', 'ether'); //set as needed
const T_TO_STAKE_USER_9 = web3.utils.toWei('1000000', 'ether'); //set as needed
const T_TO_STAKE_USER_10 = web3.utils.toWei('1000000', 'ether'); //set as needed


// const USER_1 = addressesConfig.COUNCIL_1; //better to hardcode this
// const USER_2 = addressesConfig.COUNCIL_2; //better to hardcode this
// const USER_3 = addressesConfig.COUNCIL_3; //better to hardcode this

const USER_1 = "0x9a337088801B30a3eB715937BCDE27A34BC62841"
const USER_2 = "0xAD2c9625Fe6c88fcAf3E0D488543d51528d4a30D"
const USER_3 = "0x078D6d3e5b547D766e90078902ecC4C5AEf7a960"
const USER_4 = "0xa639856772F31f530AC0727Ec0f478a294aCfB21"
const USER_5 = "0x6f45f117f58A65AeE2F7F1aC53a22bAcC3d22ca0"
const USER_6 = "0x4db5B862AcD756D243dFD8168a14918681D6EDB4"
const USER_7 = "0xe8C7A3BCF6932E958dE77111CCfe853B1D7Cc7c5"
const USER_8 = "0xDd0A499401f710496f7663e97778AF364242cB3d"
const USER_9 = "0x5b5fC32Eb3e243A542684bCC09713Fb5f6f5E914"
const USER_10 = "0x35b176582819F2b5e70640624876927968904822"

const rawdata = fs.readFileSync(constants.PATH_TO_ADDRESSES);
const addresses = JSON.parse(rawdata);

const _createLockParamObject = (
_amount,
_lockPeriod,
_account) => {
return {
amount: _amount,
lockPeriod: _lockPeriod,
account: _account
}
}
const _encodeApproveFunction = (_account, _amount) => {
let toRet = web3.eth.abi.encodeFunctionCall({
name: 'approve',
type: 'function',
inputs: [{
type: 'address',
name: 'spender'
},{
type: 'uint256',
name: 'amount'
}]
}, [_account, _amount]);

return toRet;
}

const _encodeCreateLocksForCouncils = (_createLockParam) => {
let toRet = web3.eth.abi.encodeFunctionCall({
name:'createFixedLocksOnBehalfOfUserByAdmin',
type:'function',
inputs: [{
type: 'tuple[]',
name: 'lockPositions',
components: [
{"type":"uint256", "name":"amount"},
{"type":"uint256", "name":"lockPeriod"},
{"type":"address", "name":"account"}
]
}
]
},[_createLockParam])
return toRet
}

module.exports = async function(deployer) {
const stakingService = await IStaking.at(addresses.staking);


await txnHelper.submitAndExecute(
_encodeApproveFunction(stakingService.address,T_TOTAL_TO_APPROVE),
addresses.fthmToken,
"ApproveFathomTxn"
)

const LockPositionForUser1 = _createLockParamObject(T_TO_STAKE_USER_1,LOCK_PERIOD,USER_1)
const LockPositionForUser2 = _createLockParamObject(T_TO_STAKE_USER_2,LOCK_PERIOD,USER_2)
const LockPositionForUser3 = _createLockParamObject(T_TO_STAKE_USER_3,LOCK_PERIOD,USER_3)
const LockPositionForUser4 = _createLockParamObject(T_TO_STAKE_USER_4,LOCK_PERIOD,USER_4)
const LockPositionForUser5 = _createLockParamObject(T_TO_STAKE_USER_5,LOCK_PERIOD,USER_5)
const LockPositionForUser6 = _createLockParamObject(T_TO_STAKE_USER_6,LOCK_PERIOD,USER_6)
const LockPositionForUser7 = _createLockParamObject(T_TO_STAKE_USER_7,LOCK_PERIOD,USER_7)
const LockPositionForUser8 = _createLockParamObject(T_TO_STAKE_USER_8,LOCK_PERIOD,USER_8)
const LockPositionForUser9 = _createLockParamObject(T_TO_STAKE_USER_9,LOCK_PERIOD,USER_9)
const LockPositionForUser10 = _createLockParamObject(T_TO_STAKE_USER_10,LOCK_PERIOD,USER_10)

const allLockPositions = [
LockPositionForUser1,
LockPositionForUser2,
LockPositionForUser3,
LockPositionForUser4,
LockPositionForUser5,
LockPositionForUser6,
LockPositionForUser7,
LockPositionForUser8,
LockPositionForUser9,
LockPositionForUser10
]

await txnHelper.submitAndExecute(
_encodeCreateLocksForCouncils(allLockPositions),
stakingService.address,
"createMultipleLocksForUsers"
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,18 @@ const IStaking = artifacts.require('./dao/staking/interfaces/IStaking.sol');
const env = process.env.NODE_ENV || 'dev';
const addressesConfig = require(`../../config/config.${env}`)


const LOCK_PERIOD = 365 * 24 * 60 * 60;
//SET AS NEEDED
// this needs to be sum of all the stakes. Right now 10KK * 3.
// NOT MAX UINT for security as its not good to approve max for Multisig
const T_TOTAL_TO_APPROVE = web3.utils.toWei('30000000', 'ether');

// this is how much to stake for one council . Right now 10KK
const T_TO_STAKE = web3.utils.toWei('10000000', 'ether');
const T_TO_STAKE_USER_1 = web3.utils.toWei('1000000', 'ether'); //set as needed
const T_TO_STAKE_USER_2 = web3.utils.toWei('1000000', 'ether'); //set as needed

const COUNCIL_1 = addressesConfig.COUNCIL_1;
const COUNCIL_2 = addressesConfig.COUNCIL_2;
const COUNCIL_3 = addressesConfig.COUNCIL_3;
const T_TO_APPROVE = web3.utils.toWei('20000000', 'ether');

const USER_1 = "0x9a337088801B30a3eB715937BCDE27A34BC62841";
const USER_2 = "0xAD2c9625Fe6c88fcAf3E0D488543d51528d4a30D";

const rawdata = fs.readFileSync(constants.PATH_TO_ADDRESSES);
const addresses = JSON.parse(rawdata);
Expand Down Expand Up @@ -71,26 +71,19 @@ const _encodeCreateLocksForCouncils = (_createLockParam) => {
module.exports = async function(deployer) {
const stakingService = await IStaking.at(addresses.staking);


await txnHelper.submitAndExecute(
_encodeApproveFunction(stakingService.address,T_TOTAL_TO_APPROVE),
_encodeApproveFunction(stakingService.address,T_TO_APPROVE),
addresses.fthmToken,
"ApproveFathomTxn"
)

const LockPositionForCouncil_1 = _createLockParamObject(T_TO_STAKE,LOCK_PERIOD,COUNCIL_1)
const LockPositionForCouncil_2 = _createLockParamObject(T_TO_STAKE,LOCK_PERIOD,COUNCIL_2)
const LockPositionForCouncil_3 = _createLockParamObject(T_TO_STAKE,LOCK_PERIOD,COUNCIL_3)
const LockPositionForUser1 = _createLockParamObject(T_TO_STAKE_USER_1,LOCK_PERIOD,USER_1)
const LockPositionForUser2 = _createLockParamObject(T_TO_STAKE_USER_2,LOCK_PERIOD,USER_2)

const allLockPositions = [LockPositionForUser1,LockPositionForUser2]

const LockParamObjectForAllCouncils = [
LockPositionForCouncil_1,
LockPositionForCouncil_2,
LockPositionForCouncil_3
]

await txnHelper.submitAndExecute(
_encodeCreateLocksForCouncils(LockParamObjectForAllCouncils),
_encodeCreateLocksForCouncils(allLockPositions),
stakingService.address,
"createLocksForCouncilTxn"
"createLocksForUserTxn"
)
}
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
Loading

0 comments on commit 1d0dcb3

Please sign in to comment.