Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Review] Balance calculation when operators will be removed #284

Merged
merged 10 commits into from
Dec 11, 2023
3 changes: 3 additions & 0 deletions contracts/SSVNetworkViews.sol
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,9 @@ contract SSVNetworkViews is UUPSUpgradeable, Ownable2StepUpgradeable, ISSVViews
/*******************************/
/* DAO External View Functions */
/*******************************/
function getNetworkFeeIndex() external view returns (uint256) {
Mohsen-T marked this conversation as resolved.
Show resolved Hide resolved
return ssvNetwork.getNetworkFeeIndex();
}

function getNetworkFee() external view override returns (uint256) {
return ssvNetwork.getNetworkFee();
Expand Down
2 changes: 2 additions & 0 deletions contracts/interfaces/ISSVViews.sol
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,8 @@ interface ISSVViews is ISSVNetworkCore {
Cluster memory cluster
) external view returns (uint256 balance);

function getNetworkFeeIndex() external view returns (uint256);

/// @notice Gets the network fee
/// @return networkFee The fee associated with the network (SSV)
function getNetworkFee() external view returns (uint256 networkFee);
Expand Down
1 change: 1 addition & 0 deletions contracts/modules/SSVOperators.sol
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ contract SSVOperators is ISSVOperators {
operator.snapshot.balance = 0;
operator.validatorCount = 0;
operator.fee = 0;
operator.whitelisted = false;
Mohsen-T marked this conversation as resolved.
Show resolved Hide resolved

s.operators[operatorId] = operator;

Expand Down
5 changes: 5 additions & 0 deletions contracts/modules/SSVViews.sol
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import "../libraries/CoreLib.sol";
import "../libraries/ProtocolLib.sol";
import "../libraries/SSVStorage.sol";
import "../libraries/SSVStorageProtocol.sol";
import "hardhat/console.sol";
Mohsen-T marked this conversation as resolved.
Show resolved Hide resolved

contract SSVViews is ISSVViews {
using Types64 for uint64;
Expand Down Expand Up @@ -163,6 +164,10 @@ contract SSVViews is ISSVViews {
/* DAO External View Functions */
/*******************************/

function getNetworkFeeIndex() external view override returns (uint256) {
return SSVStorageProtocol.load().currentNetworkFeeIndex();
}

function getNetworkFee() external view override returns (uint256) {
return SSVStorageProtocol.load().networkFee.expand();
}
Expand Down
3 changes: 3 additions & 0 deletions contracts/test/SSVViewsT.sol
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,9 @@ contract SSVViewsT is ISSVViews {
/*******************************/
/* DAO External View Functions */
/*******************************/
function getNetworkFeeIndex() external view override returns (uint256) {
return SSVStorageProtocol.load().currentNetworkFeeIndex();
}

function getNetworkFee() external view override returns (uint256) {
return SSVStorageProtocol.load().networkFee.expand();
Expand Down
61 changes: 30 additions & 31 deletions hardhat.config.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import 'dotenv/config';

import { HardhatUserConfig } from 'hardhat/config';
import { NetworkUserConfig } from "hardhat/types";
import { NetworkUserConfig } from 'hardhat/types';
import '@nomicfoundation/hardhat-toolbox';
import '@openzeppelin/hardhat-upgrades';
import 'hardhat-tracer';
Expand All @@ -14,60 +14,59 @@ import './tasks/upgrade';

type SSVNetworkConfig = NetworkUserConfig & {
ssvToken: string;
}

};

const config: HardhatUserConfig = {
// Your type-safe config goes here
mocha: {
timeout: 40000000000000000
timeout: 40000000000000000,
},
solidity: {
compilers: [
{
version: "0.8.4",
version: '0.8.4',
},
{
version: '0.8.18',
settings: {
optimizer: {
enabled: true,
runs: 10000
}
}
}
runs: 10000,
},
},
},
],
},
networks: {
ganache: {
chainId: 1337,
url: "http://127.0.0.1:8585",
ssvToken: process.env.SSVTOKEN_ADDRESS // if empty, deploy SSV mock token
url: 'http://127.0.0.1:8585',
ssvToken: process.env.SSVTOKEN_ADDRESS, // if empty, deploy SSV mock token
} as SSVNetworkConfig,
hardhat: {
allowUnlimitedContractSize: true
}
allowUnlimitedContractSize: true,
},
},
etherscan: {
// Your API key for Etherscan
// Obtain one at https://etherscan.io/
apiKey: process.env.ETHERSCAN_KEY,
customChains: [
{
network: "holesky",
network: 'holesky',
chainId: 17000,
urls: {
apiURL: "https://api-holesky.etherscan.io/api",
browserURL: "https://holesky.etherscan.io"
}
}
]
apiURL: 'https://api-holesky.etherscan.io/api',
browserURL: 'https://holesky.etherscan.io',
},
},
],
},
gasReporter: {
enabled: true,
enabled: false,
currency: 'USD',
gasPrice: 0.3
}
gasPrice: 0.3,
},
};

if (process.env.GOERLI_ETH_NODE_URL) {
Expand All @@ -82,13 +81,13 @@ if (process.env.GOERLI_ETH_NODE_URL) {
...config.networks,
goerli_development: {
...sharedConfig,
ssvToken: '0x6471F70b932390f527c6403773D082A0Db8e8A9F'
ssvToken: '0x6471F70b932390f527c6403773D082A0Db8e8A9F',
} as SSVNetworkConfig,
goerli_testnet: {
...sharedConfig,
ssvToken: '0x3a9f01091C446bdE031E39ea8354647AFef091E7'
ssvToken: '0x3a9f01091C446bdE031E39ea8354647AFef091E7',
} as SSVNetworkConfig,
}
};
}

if (process.env.HOLESKY_ETH_NODE_URL) {
Expand All @@ -103,13 +102,13 @@ if (process.env.HOLESKY_ETH_NODE_URL) {
...config.networks,
holesky_development: {
...sharedConfig,
ssvToken: '0x68A8DDD7a59A900E0657e9f8bbE02B70c947f25F'
ssvToken: '0x68A8DDD7a59A900E0657e9f8bbE02B70c947f25F',
} as SSVNetworkConfig,
holesky_testnet: {
...sharedConfig,
ssvToken: '0xad45A78180961079BFaeEe349704F411dfF947C6'
ssvToken: '0xad45A78180961079BFaeEe349704F411dfF947C6',
} as SSVNetworkConfig,
}
};
}

if (process.env.MAINNET_ETH_NODE_URL) {
Expand All @@ -121,9 +120,9 @@ if (process.env.MAINNET_ETH_NODE_URL) {
accounts: [`0x${process.env.MAINNET_OWNER_PRIVATE_KEY}`],
gasPrice: +(process.env.GAS_PRICE || ''),
gas: +(process.env.GAS || ''),
ssvToken: '0x9D65fF81a3c488d585bBfb0Bfe3c7707c7917f54'
} as SSVNetworkConfig
}
ssvToken: '0x9D65fF81a3c488d585bBfb0Bfe3c7707c7917f54',
} as SSVNetworkConfig,
};
}

export default config;
Loading
Loading