* Integration test catastrophic mode * Update test for withdrawals in catastrophic mode * Test withdrawing delegator rewards work in catastrophic mode * Test top stakers can withdraw * Test more delegators rewards withdrawals * Add claiming rewards for a pool owner * Fix for forge coverage
93 lines
3.3 KiB
Solidity
93 lines
3.3 KiB
Solidity
// SPDX-License-Identifier: Apache-2.0
|
|
/*
|
|
|
|
Copyright 2021 ZeroEx Intl.
|
|
|
|
Licensed under the Apache License, Version 2.0 (the "License");
|
|
you may not use this file except in compliance with the License.
|
|
You may obtain a copy of the License at
|
|
|
|
http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
Unless required by applicable law or agreed to in writing, software
|
|
distributed under the License is distributed on an "AS IS" BASIS,
|
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
See the License for the specific language governing permissions and
|
|
limitations under the License.
|
|
|
|
*/
|
|
|
|
pragma solidity ^0.8.19;
|
|
|
|
interface IStructs {
|
|
/// @dev Stats for a pool that earned rewards.
|
|
/// @param feesCollected Fees collected in ETH by this pool.
|
|
/// @param weightedStake Amount of weighted stake in the pool.
|
|
/// @param membersStake Amount of non-operator stake in the pool.
|
|
struct PoolStats {
|
|
uint256 feesCollected;
|
|
uint256 weightedStake;
|
|
uint256 membersStake;
|
|
}
|
|
|
|
/// @dev Holds stats aggregated across a set of pools.
|
|
/// @param rewardsAvailable Rewards (ETH) available to the epoch
|
|
/// being finalized (the previous epoch). This is simply the balance
|
|
/// of the contract at the end of the epoch.
|
|
/// @param numPoolsToFinalize The number of pools that have yet to be finalized through `finalizePools()`.
|
|
/// @param totalFeesCollected The total fees collected for the epoch being finalized.
|
|
/// @param totalWeightedStake The total fees collected for the epoch being finalized.
|
|
/// @param totalRewardsFinalized Amount of rewards that have been paid during finalization.
|
|
struct AggregatedStats {
|
|
uint256 rewardsAvailable;
|
|
uint256 numPoolsToFinalize;
|
|
uint256 totalFeesCollected;
|
|
uint256 totalWeightedStake;
|
|
uint256 totalRewardsFinalized;
|
|
}
|
|
|
|
/// @dev Encapsulates a balance for the current and next epochs.
|
|
/// Note that these balances may be stale if the current epoch
|
|
/// is greater than `currentEpoch`.
|
|
/// @param currentEpoch the current epoch
|
|
/// @param currentEpochBalance balance in the current epoch.
|
|
/// @param nextEpochBalance balance in `currentEpoch+1`.
|
|
struct StoredBalance {
|
|
uint64 currentEpoch;
|
|
uint96 currentEpochBalance;
|
|
uint96 nextEpochBalance;
|
|
}
|
|
|
|
/// @dev Statuses that stake can exist in.
|
|
/// Any stake can be (re)delegated effective at the next epoch
|
|
/// Undelegated stake can be withdrawn if it is available in both the current and next epoch
|
|
enum StakeStatus {
|
|
UNDELEGATED,
|
|
DELEGATED
|
|
}
|
|
|
|
/// @dev Info used to describe a status.
|
|
/// @param status of the stake.
|
|
/// @param poolId Unique Id of pool. This is set when status=DELEGATED.
|
|
struct StakeInfo {
|
|
StakeStatus status;
|
|
bytes32 poolId;
|
|
}
|
|
|
|
/// @dev Struct to represent a fraction.
|
|
/// @param numerator of fraction.
|
|
/// @param denominator of fraction.
|
|
struct Fraction {
|
|
uint256 numerator;
|
|
uint256 denominator;
|
|
}
|
|
|
|
/// @dev Holds the metadata for a staking pool.
|
|
/// @param operator of the pool.
|
|
/// @param operatorShare Fraction of the total balance owned by the operator, in ppm.
|
|
struct Pool {
|
|
address operator;
|
|
uint32 operatorShare;
|
|
}
|
|
}
|