Skip to content

Commit

Permalink
Merge pull request #60 from Into-the-Fathom/dev
Browse files Browse the repository at this point in the history
1.3.0 "MOLLOY DEEP V3"
  • Loading branch information
TonioMacaronio authored May 1, 2023
2 parents 6761064 + 340a4bf commit 30aa0be
Show file tree
Hide file tree
Showing 9 changed files with 469 additions and 13 deletions.
2 changes: 2 additions & 0 deletions contracts/dao/staking/interfaces/IStakingGetter.sol
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,6 @@ interface IStakingGetter {
function getStream(
uint256 streamId
) external view returns (uint256 rewardDepositAmount, uint256 rewardClaimedAmount, uint256 rps, StreamStatus status);

function isProhibitedLockPosition(uint256 lockId, address account) external view returns (bool);
}
6 changes: 6 additions & 0 deletions contracts/dao/staking/packages/RewardsInternals.sol
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ contract RewardsInternals is StakingStorage, IStakingEvents {
error InsufficientRewardsError();
error NoLockError();
error NoSharesError();
error ClaimingOfRewardsUnfeasibleForLockWithoutEarlyWithdraw();

function _updateStreamsRewardsSchedules(uint256 streamId, uint256 rewardTokenAmount) internal {
uint256 streamScheduleRewardLength = streams[streamId].schedule.reward.length;
Expand All @@ -28,6 +29,11 @@ contract RewardsInternals is StakingStorage, IStakingEvents {
revert InactiveStreamError();
}
LockedBalance storage lock = locks[account][lockId - 1];

if (prohibitedEarlyWithdraw[account][lockId] && lock.end > block.timestamp) {
return;
}

if (lock.amountOfToken == 0) {
revert NoStakeError();
}
Expand Down
7 changes: 7 additions & 0 deletions contracts/dao/staking/packages/StakingGetters.sol
Original file line number Diff line number Diff line change
Expand Up @@ -45,4 +45,11 @@ contract StakingGetters is StakingStorage, IStakingGetter, StakingInternals {
Stream storage stream = streams[streamId];
return (stream.rewardDepositAmount, stream.rewardClaimedAmount, stream.rps, stream.status);
}

/**
@notice this will be used by frontend to get the actual amount that can be claimed
*/
function isProhibitedLockPosition(uint256 lockId, address account) external view override returns (bool) {
return prohibitedEarlyWithdraw[account][lockId];
}
}
8 changes: 8 additions & 0 deletions coralX-scenarios.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,14 @@ module.exports = {
['execute', '--path', 'scripts/migrations/save-address/3_save_address_prod.js', '--network', 'xdc']
],

deployUpgradedStakingContractApothem: [
['execute', '--path', 'scripts/migrations/deploy-new-staking-package', '--network', 'apothem'],
],

deployUpgradedStakingContractXDC: [
['execute', '--path', 'scripts/migrations/deploy-new-staking-package', '--network', 'xdc'],
],

transferTokenFromMultisigApothem: [
['execute', '--path', 'scripts/units/transfer-tokens.js', '--network', 'apothem'],
],
Expand Down
7 changes: 6 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,13 @@
"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-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",
"migrate-reset-staking-upgrade-xdc": "export NODE_ENV=prod && rm -rf build/contracts && rm -rf build/job-logs && coralX compile && coralX scenario --run deployUpgradedStakingContractXDC"
},

"author": "fathom.fi",
"license": "AGPL 3.0",
"dependencies": {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
const PackageStakingImplementation = artifacts.require('./dao/staking/packages/StakingPackage.sol');
const fs = require("fs");

module.exports = async function(deployer) {
let promises = [
deployer.deploy(PackageStakingImplementation, {gas: 8000000}),
]
await Promise.all(promises);

let addresses = {
newStakingPackageImplementation: PackageStakingImplementation.address
}

let env = process.env.NODE_ENV || 'demo';
let filePath = `./addresses.new-staking-package.${env}.json`;

let data = JSON.stringify(addresses, null, " ");
fs.writeFileSync(filePath, data, function (err) {
if (err) {
console.log(err);
}
});
}
51 changes: 51 additions & 0 deletions scripts/migrations/deploy-new-staking-package/2_staking_upgrade.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
const constants = require("../../tests/helpers/testConstants");
const eventsHelper = require("../../tests/helpers/eventsHelper");

const PackageStakingImplementation = artifacts.require('./dao/staking/packages/StakingPackage.sol');
const fs = require("fs");
const { EMPTY_BYTES } = require("../../tests/helpers/testConstants");
let env = process.env.NODE_ENV;
let addressesFilePath = `../../../addresses.${env}.json`;
const rawdata = fs.readFileSync(addressesFilePath);
const addresses = JSON.parse(rawdata);
const IMultiSigWallet = artifacts.require("./dao/treasury/interfaces/IMultiSigWallet.sol");

const MultisigWalletAddress = addresses.multiSigWallet;
const StakingProxyAddress = addresses.staking;
const StakingProxyAdminAddress = addresses.stakingProxyAdmin;
const SUBMIT_TRANSACTION_EVENT = constants.SUBMIT_TRANSACTION_EVENT

const _encodeUpgradeFunction = (_proxy, _impl) => {
let toRet = web3.eth.abi.encodeFunctionCall({
name: 'upgrade',
type: 'function',
inputs: [{
type: 'address',
name: 'proxy'
},{
type: 'address',
name: 'implementation'
}]
}, [_proxy, _impl]);

return toRet;
}

module.exports = async function(deployer) {
const multiSigWallet = await IMultiSigWallet.at(MultisigWalletAddress)

let resultUpgrade = await multiSigWallet.submitTransaction(
StakingProxyAdminAddress,
EMPTY_BYTES,
_encodeUpgradeFunction(
StakingProxyAddress,
PackageStakingImplementation.address
),
0,
{gas: 8000000}
)

let txnIndexUpgrade = eventsHelper.getIndexedEventArgs(resultUpgrade, SUBMIT_TRANSACTION_EVENT)[0];
await multiSigWallet.confirmTransaction(txnIndexUpgrade, {gas: 8000000});
await multiSigWallet.executeTransaction(txnIndexUpgrade, {gas: 8000000});
}
8 changes: 1 addition & 7 deletions scripts/migrations/test/6_init_main_stream.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,17 +62,11 @@ module.exports = async function(deployer) {
const oneYear = 31556926;
const scheduleTimes = [
startTime,
startTime + oneYear,
startTime + 2 * oneYear,
startTime + 3 * oneYear,
startTime + 4 * oneYear,
];

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

Expand Down
Loading

0 comments on commit 30aa0be

Please sign in to comment.