Skip to content

Commit

Permalink
patched a bug with omni staking
Browse files Browse the repository at this point in the history
  • Loading branch information
deadshotryker committed Dec 13, 2024
1 parent 42e7480 commit 10d22e7
Show file tree
Hide file tree
Showing 10 changed files with 60 additions and 157 deletions.
2 changes: 0 additions & 2 deletions contracts/interfaces/IOmnichainStaking.sol
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,6 @@ interface IOmnichainStaking is IVotes {
function getTokenPower(uint256 amount) external view returns (uint256 power);

error InvalidUnstaker(address, address);
error VeTokenTransferDisabled();

event LpOracleSet(address indexed oldLpOracle, address indexed newLpOracle);
event ZeroAggregatorSet(address indexed oldZeroAggregator, address indexed newZeroAggregator);
event RewardPaid(address indexed user, uint256 reward);
Expand Down
20 changes: 5 additions & 15 deletions contracts/locker/staking/OmnichainStakingBase.sol
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ abstract contract OmnichainStakingBase is
OwnableUpgradeable
{
ILocker public locker;
// ILocker public __; // unwanted variable to keep storage layout
ILocker public __; // unwanted variable to keep storage layout
IVotingPowerCombined public votingPowerCombined;

// staking reward variables
Expand All @@ -61,12 +61,6 @@ abstract contract OmnichainStakingBase is
/// @notice Account that distributes staking rewards
address public distributor;

mapping(address => bool) public blacklisted;

constructor() {
_disableInitializers();
}

/**
* @dev Initializes the contract with the provided token lockers.
* @param _locker The address of the token locker contract.
Expand Down Expand Up @@ -232,11 +226,11 @@ abstract contract OmnichainStakingBase is
}

function transfer(address to, uint256 value) public virtual override returns (bool) {
revert VeTokenTransferDisabled();
require(false, 'revert');
}

function transferFrom(address from, address to, uint256 value) public virtual override returns (bool) {
revert VeTokenTransferDisabled();
require(false, 'revert');
}

/**
Expand Down Expand Up @@ -456,17 +450,13 @@ abstract contract OmnichainStakingBase is

function _getTokenPower(uint256 amount) internal view virtual returns (uint256 power);

function blacklist(address _user) external onlyOwner {
blacklisted[_user] = true;
}

function recall(address from, address to) external onlyOwner {
super._update(from, to, balanceOf(from));
}

function _update(address from, address to, uint256 value) internal virtual override {
require(from != address(0) && to != address(0), "no transfer between holders");
require(!blacklisted[from] && !blacklisted[to], "blacklisted");
super._update(from, to, value);
require(from == address(0) || to == address(0), "no transfer between holders");
super._update(from, to, value);
}
}
2 changes: 1 addition & 1 deletion contracts/locker/staking/OmnichainStakingLP.sol
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ contract OmnichainStakingLP is OmnichainStakingBase {
address _zeroPythAggregator,
address _owner,
address _distributor
) external reinitializer(7) {
) external reinitializer(10) {
super.__OmnichainStakingBase_init(
"ZERO LP Voting Power", "ZEROvp-LP", _locker, _zeroToken, _poolVoter, _rewardsDuration, _distributor
);
Expand Down
2 changes: 1 addition & 1 deletion contracts/locker/staking/OmnichainStakingToken.sol
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ contract OmnichainStakingToken is OmnichainStakingBase {
uint256 _rewardsDuration,
address _owner,
address _distributor
) external reinitializer(7) {
) external reinitializer(10) {
super.__OmnichainStakingBase_init(
"ZERO Voting Power", "ZEROvp", _locker, _zeroToken, _poolVoter, _rewardsDuration, _distributor
);
Expand Down
8 changes: 4 additions & 4 deletions hardhat.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,27 +89,27 @@ const config: HardhatUserConfig = {
{
version: "0.8.10",
settings: {
optimizer: { enabled: true, runs: 100_000 },
optimizer: { enabled: true, runs: 200_000 },
},
},
{
version: "0.8.12",
settings: {
optimizer: { enabled: true, runs: 100_000 },
optimizer: { enabled: true, runs: 200_000 },
},
},
{
version: "0.8.20",
settings: {
optimizer: { enabled: true, runs: 100_000 },
optimizer: { enabled: true, runs: 200_000 },
},
},
],
},
networks: {
hardhat: {
// live: false,
loggingEnabled: true,
// loggingEnabled: true,
allowBlocksWithSameTimestamp: true,
allowUnlimitedContractSize: true,
},
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
"dotenv": "^16.0.3",
"ethereum-waffle": "^4.0.10",
"ethers": "^6.11.1",
"hardhat": "^2.22.10",
"hardhat": "2.19.4",
"hardhat-deploy": "^0.12.2",
"hardhat-tracer": "^3.0.3",
"mocha": "^10.2.0",
Expand Down
11 changes: 6 additions & 5 deletions scripts/deploy-contract.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import hre, { ethers } from "hardhat";

const main = async function () {
const factory = await ethers.getContractFactory("UpdateZeroNFTScript");
const contract = await factory.deploy(
"0x9fa72ea96591e486ff065e7c8a89282dedfa6c12"
);
const factory = await ethers.getContractFactory("OmnichainStakingToken");
const contract = await factory
.deploy
// "0x9fa72ea96591e486ff065e7c8a89282dedfa6c12"
();

console.log("deployed to", contract.target);

Expand All @@ -13,7 +14,7 @@ const main = async function () {
// Verify contract programmatically
await hre.run("verify:verify", {
address: contract.target,
constructorArguments: [contract.target],
// constructorArguments: [contract.target],
});
};

Expand Down
50 changes: 25 additions & 25 deletions scripts/upgrade-tests/upgrade-omnichain-lp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ const main = async function () {
// const impl = await factory.deploy();
const impl = await hre.ethers.getContractAt(
"OmnichainStakingLP",
"0xB5327E0961eef65803b29114bAfc3B90cFe9035E"
"0xe98f5d40f5F07376675542F9a449c59f18275A19"
);

// proxies
Expand All @@ -36,29 +36,29 @@ const main = async function () {
"0xb21da3000ffcc2156da080940da8506311da037e"
);

// console.log(
// "impl",
// await getSlot(
// proxy,
// "0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc"
// )
// );

// console.log(
// "admin",
// await getSlot(
// proxy,
// "0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103"
// )
// );

// console.log("rewardRate", await implP.rewardRate());
// console.log("balanceOf", await implP.balanceOf(d));
// console.log("userRewardPerTokenPaid", await implP.userRewardPerTokenPaid(d));
// console.log("earned", await implP.earned(d));
// console.log("owner", await implP.owner());
// console.log("lockedByToken", await implP.lockedByToken(1));
// console.log("lockedTokenIdNfts", await implP.lockedTokenIdNfts(d, 0));
console.log(
"impl",
await getSlot(
proxy,
"0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc"
)
);

console.log(
"admin",
await getSlot(
proxy,
"0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103"
)
);

console.log("rewardRate", await implP.rewardRate());
console.log("balanceOf", await implP.balanceOf(d));
console.log("userRewardPerTokenPaid", await implP.userRewardPerTokenPaid(d));
console.log("earned", await implP.earned(d));
console.log("owner", await implP.owner());
console.log("lockedByToken", await implP.lockedByToken(1));
console.log("lockedTokenIdNfts", await implP.lockedTokenIdNfts(d, 0));

const call = await impl.init.populateTransaction(
"0x8bB8B092f3f872a887F377f73719c665Dd20Ab06", // address _locker,
Expand All @@ -79,7 +79,7 @@ const main = async function () {

const tx = await admin
.connect(safeSigner)
.upgradeAndCall.populateTransaction(proxy.target, impl.target, call.data);
.upgradeAndCall(proxy.target, impl.target, call.data);

console.log(tx);

Expand Down
4 changes: 2 additions & 2 deletions scripts/upgrade-tests/upgrade-omnichain-token.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ const main = async function () {

const impl = await hre.ethers.getContractAt(
"OmnichainStakingToken",
"0x9067cE4F32242a78938e4AF7E2A4A3801D98Dd1B"
"0xb320Fa6C84d67145759f2e6B06e2Fc14B0BADb5d"
);

// proxies
Expand Down Expand Up @@ -76,7 +76,7 @@ const main = async function () {
const tx = await admin
.connect(safeSigner)
.upgradeAndCall(proxy.target, impl.target, call.data);
console.log(tx.data);
console.log(tx);

console.log("rewardRate", await implP.rewardRate());
console.log("balanceOf", await implP.balanceOf(d));
Expand Down
Loading

0 comments on commit 10d22e7

Please sign in to comment.