// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.8.0) (utils/Address.sol)
pragma solidity ^0.8.1;
/**
* @dev Collection of functions related to the address type
*/
library Address {
/**
* @dev Returns true if `account` is a contract.
*
* [IMPORTANT]
* ====
* It is unsafe to assume that an address for which this function returns
* false is an externally-owned account (EOA) and not a contract.
*
* Among others, `isContract` will return false for the following
* types of addresses:
*
* - an externally-owned account
* - a contract in construction
* - an address where a contract will be created
* - an address where a contract lived, but was destroyed
* ====
*
* [IMPORTANT]
* ====
* You shouldn't rely on `isContract` to protect against flash loan attacks!
*
* Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets
* like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract
* constructor.
* ====
*/
function isContract(address account) internal view returns (bool) {
// This method relies on extcodesize/address.code.length, which returns 0
// for contracts in construction, since the code is only stored at the end
// of the constructor execution.
return account.code.length > 0;
}
/**
* @dev Replacement for Solidity's `transfer`: sends `amount` wei to
* `recipient`, forwarding all available gas and reverting on errors.
*
* https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost
* of certain opcodes, possibly making contracts go over the 2300 gas limit
* imposed by `transfer`, making them unable to receive funds via
* `transfer`. {sendValue} removes this limitation.
*
* https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].
*
* IMPORTANT: because control is transferred to `recipient`, care must be
* taken to not create reentrancy vulnerabilities. Consider using
* {ReentrancyGuard} or the
* https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].
*/
function sendValue(address payable recipient, uint256 amount) internal {
require(address(this).balance >= amount, "Address: insufficient balance");
(bool success, ) = recipient.call{value: amount}("");
require(success, "Address: unable to send value, recipient may have reverted");
}
/**
* @dev Performs a Solidity function call using a low level `call`. A
* plain `call` is an unsafe replacement for a function call: use this
* function instead.
*
* If `target` reverts with a revert reason, it is bubbled up by this
* function (like regular Solidity function calls).
*
* Returns the raw returned data. To convert to the expected return value,
* use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].
*
* Requirements:
*
* - `target` must be a contract.
* - calling `target` with `data` must not revert.
*
* _Available since v3.1._
*/
function functionCall(address target, bytes memory data) internal returns (bytes memory) {
return functionCallWithValue(target, data, 0, "Address: low-level call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with
* `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCall(
address target,
bytes memory data,
string memory errorMessage
) internal returns (bytes memory) {
return functionCallWithValue(target, data, 0, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but also transferring `value` wei to `target`.
*
* Requirements:
*
* - the calling contract must have an ETH balance of at least `value`.
* - the called Solidity function must be `payable`.
*
* _Available since v3.1._
*/
function functionCallWithValue(
address target,
bytes memory data,
uint256 value
) internal returns (bytes memory) {
return functionCallWithValue(target, data, value, "Address: low-level call with value failed");
}
/**
* @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but
* with `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCallWithValue(
address target,
bytes memory data,
uint256 value,
string memory errorMessage
) internal returns (bytes memory) {
require(address(this).balance >= value, "Address: insufficient balance for call");
(bool success, bytes memory returndata) = target.call{value: value}(data);
return verifyCallResultFromTarget(target, success, returndata, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but performing a static call.
*
* _Available since v3.3._
*/
function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {
return functionStaticCall(target, data, "Address: low-level static call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
* but performing a static call.
*
* _Available since v3.3._
*/
function functionStaticCall(
address target,
bytes memory data,
string memory errorMessage
) internal view returns (bytes memory) {
(bool success, bytes memory returndata) = target.staticcall(data);
return verifyCallResultFromTarget(target, success, returndata, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but performing a delegate call.
*
* _Available since v3.4._
*/
function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {
return functionDelegateCall(target, data, "Address: low-level delegate call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
* but performing a delegate call.
*
* _Available since v3.4._
*/
function functionDelegateCall(
address target,
bytes memory data,
string memory errorMessage
) internal returns (bytes memory) {
(bool success, bytes memory returndata) = target.delegatecall(data);
return verifyCallResultFromTarget(target, success, returndata, errorMessage);
}
/**
* @dev Tool to verify that a low level call to smart-contract was successful, and revert (either by bubbling
* the revert reason or using the provided one) in case of unsuccessful call or if target was not a contract.
*
* _Available since v4.8._
*/
function verifyCallResultFromTarget(
address target,
bool success,
bytes memory returndata,
string memory errorMessage
) internal view returns (bytes memory) {
if (success) {
if (returndata.length == 0) {
// only check isContract if the call was successful and the return data is empty
// otherwise we already know that it was a contract
require(isContract(target), "Address: call to non-contract");
}
return returndata;
} else {
_revert(returndata, errorMessage);
}
}
/**
* @dev Tool to verify that a low level call was successful, and revert if it wasn't, either by bubbling the
* revert reason or using the provided one.
*
* _Available since v4.3._
*/
function verifyCallResult(
bool success,
bytes memory returndata,
string memory errorMessage
) internal pure returns (bytes memory) {
if (success) {
return returndata;
} else {
_revert(returndata, errorMessage);
}
}
function _revert(bytes memory returndata, string memory errorMessage) private pure {
// Look for revert reason and bubble it up if present
if (returndata.length > 0) {
// The easiest way to bubble the revert reason is using memory via assembly
/// @solidity memory-safe-assembly
assembly {
let returndata_size := mload(returndata)
revert(add(32, returndata), returndata_size)
}
} else {
revert(errorMessage);
}
}
}
// SPDX-License-Identifier: MIT
pragma solidity =0.8.18;
import {IRegistry} from "./interfaces/IRegistry.sol";
import {IEdge} from "./interfaces/IEdge.sol";
import {TransferReason} from "./libraries/TransferReason.sol";
import {
SafeERC20,
IERC20
} from "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
import {
ReentrancyGuard
} from "@openzeppelin/contracts/security/ReentrancyGuard.sol";
import {SafeCast} from "@openzeppelin/contracts/utils/math/SafeCast.sol";
contract AethirEdge is IEdge, ReentrancyGuard {
using SafeERC20 for IERC20;
struct UserData {
uint64 nonce;
uint64 lastUpdateBlock;
}
IRegistry private immutable _registry;
mapping(address account => UserData data) private _users;
modifier usualCheck(VerifiableData calldata vdata) {
_beforeCheck(vdata);
_;
_afterCheck(vdata);
}
constructor(IRegistry registry) {
_registry = registry;
}
function version() external view override returns (uint64) {
return _registry.getVersion();
}
function currentEpoch()
external
view
override
returns (uint64 epoch, uint64 startTs, uint64 endTs)
{
uint256 start = _registry.getConfigurator().getDeployTs();
uint256 dur = _registry.getConfigurator().getEpochDuration();
epoch = SafeCast.toUint64((block.timestamp - start) / dur);
startTs = SafeCast.toUint64((dur * epoch) + start);
endTs = SafeCast.toUint64(dur + startTs);
}
function getUserData(
address owner
) external view returns (UserData memory) {
return _users[owner];
}
function nonces(address owner) external view returns (uint64) {
return _users[owner].nonce;
}
function switchContainers(
ContainerList calldata container,
VerifiableData calldata vdata
) external override nonReentrant usualCheck(vdata) returns (bool) {
_registry.getContainerHandler().handleSwitch(
msg.sender,
container,
vdata
);
emit Switch(msg.sender, vdata.nonce, container);
return true;
}
function stakeContainers(
ContainerList calldata containers,
VerifiableData calldata vdata
) external override nonReentrant usualCheck(vdata) returns (bool) {
uint256 amount = _registry.getContainerHandler().handleStake(
msg.sender,
containers,
vdata
);
_registry.getAethirToken().safeTransferFrom(
msg.sender,
address(this),
amount
);
emit Stake(msg.sender, vdata.nonce, containers);
return true;
}
function unstakeContainers(
ContainerList calldata containers,
VerifiableData calldata vdata
) external override nonReentrant usualCheck(vdata) returns (bool) {
(uint256 amount, bool skipVesting) = _registry
.getContainerHandler()
.handleUnstake(msg.sender, containers, vdata);
if (skipVesting) {
_sendToken(msg.sender, amount, TransferReason.UNSTAKE);
} else {
uint256[] memory pendings = new uint256[](1);
pendings[0] = amount;
_registry.getAethirToken().safeIncreaseAllowance(
address(_registry.getVestingController()),
amount
);
_registry.getVestingController().newVesting(
msg.sender,
_registry.getConfigurator().getRewardLockedTime(),
pendings
);
}
emit Unstake(msg.sender, vdata.nonce, containers);
return true;
}
function claimReward(
ContainerList calldata containers,
VerifiableData calldata vdata
) external override nonReentrant usualCheck(vdata) returns (bool) {
uint256 amount = _registry.getRewardHandler().handleClaim(
msg.sender,
containers,
vdata
);
_sendToken(msg.sender, amount, TransferReason.CLAIM_REWARD);
emit ClaimReward(msg.sender, vdata.nonce, containers);
return true;
}
function claimServiceFee(
ContainerList calldata containers,
VerifiableData calldata vdata
) external override nonReentrant usualCheck(vdata) returns (bool) {
uint256 earned = _registry.getServiceFeeHandler().handleClaim(
msg.sender,
containers,
vdata
);
_sendToken(msg.sender, earned, TransferReason.CLAIM_FEE);
emit ClaimServiceFee(msg.sender, vdata.nonce, containers);
return true;
}
function depositServiceFee(
uint256 amount,
VerifiableData calldata vdata
) external override nonReentrant usualCheck(vdata) returns (bool) {
uint256 depositable = _registry.getServiceFeeHandler().handleDeposit(
msg.sender,
amount,
vdata
);
require(depositable >= amount, "Deposit more than available");
_registry.getAethirToken().safeTransferFrom(
msg.sender,
address(this),
amount
);
emit DepositServiceFee(msg.sender, vdata.nonce, amount);
return true;
}
function withdrawServiceFee(
uint256 amount,
VerifiableData calldata vdata
) external override nonReentrant usualCheck(vdata) returns (bool) {
uint256 withdrawable = _registry.getServiceFeeHandler().handleWithdraw(
msg.sender,
amount,
vdata
);
require(withdrawable >= amount, "Withdraw more than available");
_sendToken(msg.sender, amount, TransferReason.WITHDRAW_FEE);
emit WithdrawServiceFee(msg.sender, vdata.nonce, amount);
return true;
}
function forceUnstake(
address[] calldata providers,
uint32[] calldata indexes,
VerifiableData calldata vdata
) external override nonReentrant usualCheck(vdata) returns (bool) {
_registry.getContainerHandler().handleForceUnstake(
msg.sender,
providers,
indexes,
vdata
);
emit ForceUnstake(msg.sender, vdata.nonce, providers, indexes);
return true;
}
function adminWithdraw(
address to,
uint256 amount,
string calldata message
) external returns (bool) {
_registry.getACLManager().requireDefaultAdmin(msg.sender);
_sendToken(to, amount, TransferReason.ADMIN_WITHDRAW);
emit AdminWithdraw(to, amount, message);
return true;
}
function _sendToken(address to, uint256 amount, uint8 reason) internal {
if (amount <= 0) return;
_registry.getRiskManager().tryTransfer(to, amount, reason);
_registry.getAethirToken().safeTransfer(to, amount);
}
function _beforeCheck(VerifiableData calldata vdata) internal view {
require(vdata.version == _registry.getVersion(), "InvalidVersion");
// slither-disable-next-line timestamp
require(vdata.deadline >= block.timestamp, "DataExpired");
require(vdata.nonce > _users[msg.sender].nonce, "NonceTooLow");
require(
vdata.lastUpdateBlock >= _users[msg.sender].lastUpdateBlock,
"DataTooOld"
);
}
function _afterCheck(VerifiableData calldata vdata) internal {
_users[msg.sender].nonce = vdata.nonce;
_users[msg.sender].lastUpdateBlock = uint64(block.number);
}
}
// SPDX-License-Identifier: MIT
pragma solidity =0.8.18;
/**
* @title IACLManager
* @notice Defines the basic interface for the ACL Manager
*/
interface IACLManager {
/// @notice thrown when tx has not been completed because it lacks valid authentication credentials
error Unauthorized(string message);
/// @notice revert if the address is not DefaultAdmin
/// @param account: the address to check
function requireDefaultAdmin(address account) external view;
/// @notice true if the address is Core Module, false otherwise
/// @param account: the address to check
/// @return true if the given address is Core Module, false otherwise
function isCore(address account) external view returns (bool);
/// @notice revert if the address is not Core Module
/// @param account: the address to check
function requireCore(address account) external view;
/// @notice true if the address is Originator, false otherwise
/// @param account: the address to check
/// @return true if the given address is Originator, false otherwise
function isOriginator(address account) external view returns (bool);
/// @notice revert if the address is not Originator
/// @param account: the address to check
function requireOriginator(address account) external view;
/// @notice true if the address is Operator, false otherwise
/// @param account: the address to check
/// @return true if the given address is Operator, false otherwise
function isOperator(address account) external view returns (bool);
/// @notice revert if the address is not Operator
/// @param account: the address to check
function requireOperator(address account) external view;
/// @notice true if the address is Migrator, false otherwise
/// @param account: the address to check
/// @return true if the given address is Migrator, false otherwise
function isMigrator(address account) external view returns (bool);
/// @notice revert if the address is not Migrator
/// @param account: the address to check
function requireMigrator(address account) external view;
/// @notice true if the address is Validator, false otherwise
/// @param account: the address to check
/// @return true if the given address is Validator, false otherwise
function isValidator(address account) external view returns (bool);
/// @notice revert if the address is not Validator
/// @param account: the address to check
function requireValidator(address account) external view;
/// @notice true if the address is Approver, false otherwise
/// @param account: the address to check
/// @return true if the given address is Approver, false otherwise
function isApprover(address account) external view returns (bool);
/// @notice revert if the address is not Approver
/// @param account: the address to check
function requireApprover(address account) external view;
/// @notice true if the address is EmergencyAdmin, false otherwise
/// @param account: the address to check
/// @return true if the given address is EmergencyAdmin, false otherwise
function isEmergencyAdmin(address account) external view returns (bool);
/// @notice revert if the address is not EmergencyAdmin
/// @param account: the address to check
function requireEmergencyAdmin(address account) external view;
/// @notice true if the address is RiskAdmin, false otherwise
/// @param account: the address to check
/// @return true if the given address is RiskAdmin, false otherwise
function isRiskAdmin(address account) external view returns (bool);
/// @notice revert if the address is not RiskAdmin
/// @param account: the address to check
function requireRiskAdmin(address account) external view;
/// @notice get number of required validator signatures for verifiable data
function getRequiredValidatorSignatures() external view returns (uint8);
/// @notice set number of required validator signatures for verifiable data
function setRequiredValidatorSignatures(uint8 value) external;
/// @notice get number of required approver signatures for verifiable data
function getRequiredApproverSignatures() external view returns (uint8);
/// @notice set number of required approver signatures for verifiable data
function setRequiredApproverSignatures(uint8 value) external;
function checkValidatorSignatures(
bytes32 dataHash,
bytes calldata signatures
) external view;
function checkApproverSignatures(
bytes32 dataHash,
bytes calldata signatures
) external view;
}
// SPDX-License-Identifier: MIT
pragma solidity =0.8.18;
interface IConfigurator {
/// @notice service fee data
/// @param retailUpside: retail service fee upside
/// @param retailDownside: retail service fee downside
/// @param wholesaleUpside: wholesale service fee upside
/// @param wholesaleDownside: wholesale service fee downside
struct ServiceFee {
uint256 retailUpside;
uint256 retailDownside;
uint256 wholesaleUpside;
uint256 wholesaleDownside;
}
/// @notice thrown when value is not valid
error InvalidValue(string message);
/// @notice returns first epoch start time (in UNIX timestamp)
function getDeployTs() external view returns (uint256);
/// @notice returns epoch duration (in seconds)
function getEpochDuration() external view returns (uint256);
/// @notice returns current system epoch
function getEpoch() external view returns (uint256);
/// @notice returns token amount released current year
function getYearlyEmission() external view returns (uint256);
/// @notice returns token amount released yearly
function getYearlyEmissionTable()
external
view
returns (uint256[] memory values);
/// @notice configures yearly emission rate
/// @param values: yearly emission rate
function initYearlyEmissionTable(uint256[] calldata values) external;
/// @notice returns yearly emission rate at wstakenum
/// @param wstakenum: wstakenum
function getYearlyEmissionRate(
uint256 wstakenum
) external view returns (uint256 value, uint8 index);
/// @notice returns yearly emission rate at index
/// @param index: index
function getYearlyEmissionRateAtIndex(
uint8 index
) external view returns (uint256 value);
/// @notice returns token amount released yearly
function getYearlyEmissionRateTable()
external
view
returns (uint256[] memory values);
/// @notice configures token amount released rate yearly
/// @param values: yearly emission amount
function initYearlyEmissionRateTable(uint256[] calldata values) external;
/// @notice returns weighted number of containers staked table
function getWStakeNumTable()
external
view
returns (uint256[] memory values);
/// @notice configures weighted number of containers staked table
/// @param values: WStakeNum list
function initWStakeNumTable(uint256[] calldata values) external;
/// @notice returns stake base at wstakenum
/// @param wstakenum: wstakenum
function getStakeBase(
uint256 wstakenum
) external view returns (uint256 value, uint8 index);
/// @notice returns stake base at index
/// @param index: index
function getStakeBaseAtIndex(
uint8 index
) external view returns (uint256 value);
/// @notice returns stake base table
function getStakeBaseTable()
external
view
returns (uint256[] memory values);
/// @notice configures stake base table
/// @param values: stake base list
function initStakeBaseTable(uint256[] calldata values) external;
/// @notice returns k-value for container ith configuration
function getContainerKValue(
uint16 index
) external view returns (uint256 value);
/// @notice configures k-values for each container configuration
/// @param indexes: the k-indexes
/// @param values: the new k-values
function setContainerKValue(
uint16[] calldata indexes,
uint256[] calldata values
) external;
/// @notice returns the number of decimals used to get its user representation.
/// For example, if `decimals` equals `2`, a kValue of `505` should
/// be displayed to a user as `5.05` (`505 / 10 ** 2`)
function getKValueDecimals() external view returns (uint8);
/// @notice returns reward locked time before vesting
function getRewardLockedTime() external view returns (uint64);
/// @notice configures reward locked time before vesting
/// @param value: new locked time (in days)
function setRewardLockedTime(uint64 value) external;
/// @notice returns vesting period
function getVestingPeriod() external view returns (uint64);
/// @notice configures vesting period
/// @param value: new vesting period (in days)
function setVestingPeriod(uint64 value) external;
/// @notice returns service fee for container ith configuration
function getServiceFees(
uint16 index
) external view returns (ServiceFee memory);
/// @notice configures wholesale service fee for each container configuration
/// @param indexes: the k-indexes
/// @param values: the new service fee
function setServiceFees(
uint16[] calldata indexes,
ServiceFee[] calldata values
) external;
/// @notice returns wholesale maintenance time
function getWholesaleMaintenanceTime() external view returns (uint256);
/// @notice configures wholesale maintenance time
/// @param value: new wholesale maintenance time
function setWholesaleMaintenanceTime(uint256 value) external;
/// @notice returns slash grace period
function getGracePeriod() external view returns (uint256);
/// @notice configures slash grace period
/// @param value: new slash grace period
function setGracePeriod(uint256 value) external;
}
// SPDX-License-Identifier: MIT
pragma solidity =0.8.18;
import {IEdge} from "../interfaces/IEdge.sol";
interface IContainerHandler {
function handleSwitch(
address provider,
IEdge.ContainerList calldata containers,
IEdge.VerifiableData calldata vdata
) external;
function handleStake(
address provider,
IEdge.ContainerList calldata containers,
IEdge.VerifiableData calldata vdata
) external returns (uint256 amount);
function handleUnstake(
address provider,
IEdge.ContainerList calldata containers,
IEdge.VerifiableData calldata vdata
) external returns (uint256 amount, bool skipVesting);
function handleForceUnstake(
address operator,
address[] calldata providers,
uint32[] calldata indexes,
IEdge.VerifiableData calldata vdata
) external;
}
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.6.0) (token/ERC20/IERC20.sol)
pragma solidity ^0.8.0;
/**
* @dev Interface of the ERC20 standard as defined in the EIP.
*/
interface IERC20 {
/**
* @dev Emitted when `value` tokens are moved from one account (`from`) to
* another (`to`).
*
* Note that `value` may be zero.
*/
event Transfer(address indexed from, address indexed to, uint256 value);
/**
* @dev Emitted when the allowance of a `spender` for an `owner` is set by
* a call to {approve}. `value` is the new allowance.
*/
event Approval(address indexed owner, address indexed spender, uint256 value);
/**
* @dev Returns the amount of tokens in existence.
*/
function totalSupply() external view returns (uint256);
/**
* @dev Returns the amount of tokens owned by `account`.
*/
function balanceOf(address account) external view returns (uint256);
/**
* @dev Moves `amount` tokens from the caller's account to `to`.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transfer(address to, uint256 amount) external returns (bool);
/**
* @dev Returns the remaining number of tokens that `spender` will be
* allowed to spend on behalf of `owner` through {transferFrom}. This is
* zero by default.
*
* This value changes when {approve} or {transferFrom} are called.
*/
function allowance(address owner, address spender) external view returns (uint256);
/**
* @dev Sets `amount` as the allowance of `spender` over the caller's tokens.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* IMPORTANT: Beware that changing an allowance with this method brings the risk
* that someone may use both the old and the new allowance by unfortunate
* transaction ordering. One possible solution to mitigate this race
* condition is to first reduce the spender's allowance to 0 and set the
* desired value afterwards:
* https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
*
* Emits an {Approval} event.
*/
function approve(address spender, uint256 amount) external returns (bool);
/**
* @dev Moves `amount` tokens from `from` to `to` using the
* allowance mechanism. `amount` is then deducted from the caller's
* allowance.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transferFrom(
address from,
address to,
uint256 amount
) external returns (bool);
}
// SPDX-License-Identifier: MIT
pragma solidity =0.8.18;
/**
* @dev Interface of Aethir Edge Contract
*/
interface IEdge {
/// @notice verifiable off-chain data
/// @param nonce: off-chain request id
/// @param deadline: deadline timestamp as seconds since Unix epoch
/// @param lastUpdateBlock: last indexed event blocknumber
/// @param version: system version
/// @param payloads: data package (format according to system version)
/// @param proof: data proof (Validator Signature or Merkle Proof)
struct VerifiableData {
uint64 nonce;
uint64 deadline;
uint64 lastUpdateBlock;
uint64 version;
bytes[] payloads;
bytes[] proof;
}
/// @notice list of containers
/// @param offset: index of the first container in the bitset, must be multiples of 256
/// @param bitset: bit[n] = 1 mean enable container at index `offset`+`n`
struct ContainerList {
uint16 count;
uint32 offset;
bytes bitset;
}
/// @notice emitted after a successful switch containers request
event Switch(
address indexed provider,
uint64 nonce,
ContainerList containers
);
/// @notice emitted after a successful stake containers request
event Stake(
address indexed provider,
uint64 nonce,
ContainerList containers
);
/// @notice emitted after a successful unstake containers request
event Unstake(
address indexed provider,
uint64 nonce,
ContainerList containers
);
/// @notice emitted after a successful claim reward request
event ClaimReward(
address indexed provider,
uint64 nonce,
ContainerList containers
);
/// @notice emitted after a successful claim service fee request
event ClaimServiceFee(
address indexed provider,
uint64 nonce,
ContainerList containers
);
/// @notice emitted after a successful deposit service fee request
event DepositServiceFee(
address indexed developer,
uint64 nonce,
uint256 amount
);
/// @notice emitted after a successful withdraw service fee request
event WithdrawServiceFee(
address indexed developer,
uint64 nonce,
uint256 amount
);
/// @notice emitted after a successful admin withdraw request
event AdminWithdraw(address indexed to, uint256 amount, string message);
/// @notice emitted after system update version
event VersionUpdate(uint64 indexed oldVersion, uint64 indexed newVersion);
/// @notice emitted after a successful force unstake containers request
event ForceUnstake(
address indexed operator,
uint64 nonce,
address[] providers,
uint32[] indexes
);
/// @notice thrown when data version does not match with system version
error InvalidVersion();
/// @notice thrown when data deadline exceeded block timestamp
error DataExpired();
/// @notice thrown when data nonce is lower than the last id
error NonceTooLow();
/// @notice thrown when data payload is invalid
error InvalidPayload();
/// @notice thrown when parameter is invalid
error InvalidParameter(string message);
/// @notice thrown when data merkle proof or signature is invalid
error InvalidProof();
/// @notice thrown when on-chain and off-chain data are out-of-sync
error DataTooOld();
/// @notice thrown when there is abnormal data
error DataConflict(string message);
/// @notice Returns the current system version
function version() external view returns (uint64);
/// @notice Returns the current system epoch
function currentEpoch()
external
view
returns (uint64 epoch, uint64 startTs, uint64 endTs);
/// @notice Returns the current nonce for `owner`
/// A higher nonce must be included whenever generate a signature
/// Every successful call update `owner`'s nonce to the new one
/// This prevents a signature from being used multiple times.
function nonces(address owner) external view returns (uint64);
/// @notice Container Provider switch multiple containers
/// @param containers: list of containers to switch
/// @param vdata: additional data for switching containers
function switchContainers(
ContainerList calldata containers,
VerifiableData calldata vdata
) external returns (bool);
/// @notice Container Provider stake multiple containers
/// @dev Caller must have allowance for this contract of at least stake amount
/// @param containers: list of containers to stake
/// @param vdata: additional data for calculating stake amount
function stakeContainers(
ContainerList calldata containers,
VerifiableData calldata vdata
) external returns (bool);
/// @notice Container Provider unstake and claim reward for multiple containers
/// @param containers: list of containers to unstake
/// @param vdata: additional data for calculating unstake amount, reward and service fee
function unstakeContainers(
ContainerList calldata containers,
VerifiableData calldata vdata
) external returns (bool);
/// @notice Container Provider claim reward for multiple containers
/// @dev Reward will be sent to Vesting Controller and released following schedule
/// @param containers: list of container to claim reward
/// @param vdata: additional data for calculating reward amount
function claimReward(
ContainerList calldata containers,
VerifiableData calldata vdata
) external returns (bool);
/// @notice Container Provider claim service fee for multiple containers
/// @param containers: list of container to claim service fee
/// @param vdata: additional data for calculating service fee amount
function claimServiceFee(
ContainerList calldata containers,
VerifiableData calldata vdata
) external returns (bool);
/// @notice Game Developer deposit service fee
/// @dev Caller must have allowance for this contract of at least deposit amount
/// @param amount: amount of token game developer want to deposit
/// @param vdata: additional data for calculating depositable service fee
function depositServiceFee(
uint256 amount,
VerifiableData calldata vdata
) external returns (bool);
/// @notice Game Developer withdraw service fee
/// @param amount: amount of token game developer want to withdraw
/// @param vdata: additional data for calculating withdrawable service fee
function withdrawServiceFee(
uint256 amount,
VerifiableData calldata vdata
) external returns (bool);
/// @notice Operator force unstake multiple containers
/// @param providers: address of providers
/// @param indexes: unstaked container index
/// @param vdata: additional data for calculating remain stake number
function forceUnstake(
address[] calldata providers,
uint32[] calldata indexes,
VerifiableData calldata vdata
) external returns (bool);
/// @notice Admin withdraw fund
/// @param to: recipient address
/// @param amount: amount of token want to withdraw
/// @param message: withdraw message
function adminWithdraw(
address to,
uint256 amount,
string calldata message
) external returns (bool);
}
// SPDX-License-Identifier: MIT
pragma solidity =0.8.18;
import {IACLManager} from "./IACLManager.sol";
import {IRewardHandler} from "./IRewardHandler.sol";
import {IServiceFeeHandler} from "./IServiceFeeHandler.sol";
import {IContainerHandler} from "./IContainerHandler.sol";
import {IVestingController} from "./IVestingController.sol";
import {IRiskManager} from "./IRiskManager.sol";
import {IConfigurator} from "./IConfigurator.sol";
import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol";
interface IRegistry {
/// @notice thrown when value is not valid
error CannotBeZero();
/// @notice returns the current system version
function getVersion() external view returns (uint64);
/// @notice registers new system version
/// @param value: new version
function setVersion(uint64 value) external;
/// @notice returns the contract address of the Aethir Token
/// @return The address of the Aethir Token
function getAethirToken() external view returns (IERC20);
/// @notice returns the contract address of the ACL Manager
/// @return The address of the ACL Manager
function getACLManager() external view returns (IACLManager);
/// @notice returns the contract address of the Reward Handler
/// @return The address of the Reward Handler
function getRewardHandler() external view returns (IRewardHandler);
/// @notice registers the contract address of the Reward Handler
/// @param value: address of new Reward Handler
function setRewardHandler(IRewardHandler value) external;
/// @notice returns the contract address of the Service Fee Handler
/// @return The address of the Service Fee Handler
function getServiceFeeHandler() external view returns (IServiceFeeHandler);
/// @notice registers the contract address of the Service Fee Handler
/// @param value: address of new Service Fee Handler
function setServiceFeeHandler(IServiceFeeHandler value) external;
/// @notice returns the contract address of the Stake Handler
/// @return The address of the Stake Handler
function getContainerHandler() external view returns (IContainerHandler);
/// @notice registers the contract address of the Stake Handler
/// @param value: address of new Stake Handler
function setContainerHandler(IContainerHandler value) external;
/// @notice returns the contract address of the Vesting Controller
/// @return The address of the Vesting Controller
function getVestingController() external view returns (IVestingController);
/// @notice registers the contract address of the Vesting Controller
/// @param value: address of new Vesting Controller
function setVestingController(IVestingController value) external;
/// @notice returns the contract address of the Risk Manager
/// @return The address of the Risk Manager
function getRiskManager() external view returns (IRiskManager);
/// @notice registers the contract address of the Risk Manager
/// @param value: address of new Risk Manager
function setRiskManager(IRiskManager value) external;
/// @notice returns the contract address of the Configurator
/// @return The address of the Configurator
function getConfigurator() external view returns (IConfigurator);
/// @notice registers the contract address of the Configurator
/// @param value: address of new Configurator
function setConfigurator(IConfigurator value) external;
}
// SPDX-License-Identifier: MIT
pragma solidity =0.8.18;
import {IEdge} from "../interfaces/IEdge.sol";
interface IRewardHandler {
function handleClaim(
address provider,
IEdge.ContainerList calldata containers,
IEdge.VerifiableData calldata data
) external returns (uint256 reward);
}
// SPDX-License-Identifier: MIT
pragma solidity =0.8.18;
/**
* @dev Interface of Risk Manager
*/
interface IRiskManager {
/// @notice thrown when transfer more than risk limit
error InvalidTransfer();
/// @notice Throws if the transfering is on suspicion of illegal activity
/// @param to: address of receiver
/// @param amount: amount of token want to transfer
/// @param reason: tranfering reason
function tryTransfer(address to, uint256 amount, uint8 reason) external;
}
// SPDX-License-Identifier: MIT
pragma solidity =0.8.18;
import {IEdge} from "../interfaces/IEdge.sol";
interface IServiceFeeHandler {
function handleClaim(
address provider,
IEdge.ContainerList calldata containers,
IEdge.VerifiableData calldata data
) external returns (uint256 earned);
function handleDeposit(
address developer,
uint256 amount,
IEdge.VerifiableData calldata data
) external returns (uint256 depositable);
function handleWithdraw(
address developer,
uint256 amount,
IEdge.VerifiableData calldata data
) external returns (uint256 withdrawable);
}
// SPDX-License-Identifier: MIT
pragma solidity =0.8.18;
/**
* @dev Interface of Vesting Controller
*/
interface IVestingController {
/// @notice emitted after a successful release request
event TokenReleased(address indexed beneficiary, uint256 amount);
/// @notice emitted after a successful new vesting request
event NewVestingSchedule(
address indexed beneficiary,
uint64 lockedDays,
uint256[] amounts
);
/// @notice Amount of token already released
function released(address beneficiary) external view returns (uint256);
/// @notice Getter for the amount of releasable tokens
function releasable(address beneficiary) external view returns (uint256);
/// @notice Release the tokens that have already vested
function release(address beneficiary) external;
/// @notice Calculates the amount of tokens that has already vested
function vestedAmount(
address beneficiary,
uint64 timestamp
) external view returns (uint256);
/// @notice Start new vesting for the beneficiary
function newVesting(
address beneficiary,
uint64 lockedDays,
uint256[] memory amounts
) external;
}
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.8.0) (security/ReentrancyGuard.sol)
pragma solidity ^0.8.0;
/**
* @dev Contract module that helps prevent reentrant calls to a function.
*
* Inheriting from `ReentrancyGuard` will make the {nonReentrant} modifier
* available, which can be applied to functions to make sure there are no nested
* (reentrant) calls to them.
*
* Note that because there is a single `nonReentrant` guard, functions marked as
* `nonReentrant` may not call one another. This can be worked around by making
* those functions `private`, and then adding `external` `nonReentrant` entry
* points to them.
*
* TIP: If you would like to learn more about reentrancy and alternative ways
* to protect against it, check out our blog post
* https://blog.openzeppelin.com/reentrancy-after-istanbul/[Reentrancy After Istanbul].
*/
abstract contract ReentrancyGuard {
// Booleans are more expensive than uint256 or any type that takes up a full
// word because each write operation emits an extra SLOAD to first read the
// slot's contents, replace the bits taken up by the boolean, and then write
// back. This is the compiler's defense against contract upgrades and
// pointer aliasing, and it cannot be disabled.
// The values being non-zero value makes deployment a bit more expensive,
// but in exchange the refund on every call to nonReentrant will be lower in
// amount. Since refunds are capped to a percentage of the total
// transaction's gas, it is best to keep them low in cases like this one, to
// increase the likelihood of the full refund coming into effect.
uint256 private constant _NOT_ENTERED = 1;
uint256 private constant _ENTERED = 2;
uint256 private _status;
constructor() {
_status = _NOT_ENTERED;
}
/**
* @dev Prevents a contract from calling itself, directly or indirectly.
* Calling a `nonReentrant` function from another `nonReentrant`
* function is not supported. It is possible to prevent this from happening
* by making the `nonReentrant` function external, and making it call a
* `private` function that does the actual work.
*/
modifier nonReentrant() {
_nonReentrantBefore();
_;
_nonReentrantAfter();
}
function _nonReentrantBefore() private {
// On the first call to nonReentrant, _status will be _NOT_ENTERED
require(_status != _ENTERED, "ReentrancyGuard: reentrant call");
// Any calls to nonReentrant after this point will fail
_status = _ENTERED;
}
function _nonReentrantAfter() private {
// By storing the original value once again, a refund is triggered (see
// https://eips.ethereum.org/EIPS/eip-2200)
_status = _NOT_ENTERED;
}
}
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.8.0) (utils/math/SafeCast.sol)
// This file was procedurally generated from scripts/generate/templates/SafeCast.js.
pragma solidity ^0.8.0;
/**
* @dev Wrappers over Solidity's uintXX/intXX casting operators with added overflow
* checks.
*
* Downcasting from uint256/int256 in Solidity does not revert on overflow. This can
* easily result in undesired exploitation or bugs, since developers usually
* assume that overflows raise errors. `SafeCast` restores this intuition by
* reverting the transaction when such an operation overflows.
*
* Using this library instead of the unchecked operations eliminates an entire
* class of bugs, so it's recommended to use it always.
*
* Can be combined with {SafeMath} and {SignedSafeMath} to extend it to smaller types, by performing
* all math on `uint256` and `int256` and then downcasting.
*/
library SafeCast {
/**
* @dev Returns the downcasted uint248 from uint256, reverting on
* overflow (when the input is greater than largest uint248).
*
* Counterpart to Solidity's `uint248` operator.
*
* Requirements:
*
* - input must fit into 248 bits
*
* _Available since v4.7._
*/
function toUint248(uint256 value) internal pure returns (uint248) {
require(value <= type(uint248).max, "SafeCast: value doesn't fit in 248 bits");
return uint248(value);
}
/**
* @dev Returns the downcasted uint240 from uint256, reverting on
* overflow (when the input is greater than largest uint240).
*
* Counterpart to Solidity's `uint240` operator.
*
* Requirements:
*
* - input must fit into 240 bits
*
* _Available since v4.7._
*/
function toUint240(uint256 value) internal pure returns (uint240) {
require(value <= type(uint240).max, "SafeCast: value doesn't fit in 240 bits");
return uint240(value);
}
/**
* @dev Returns the downcasted uint232 from uint256, reverting on
* overflow (when the input is greater than largest uint232).
*
* Counterpart to Solidity's `uint232` operator.
*
* Requirements:
*
* - input must fit into 232 bits
*
* _Available since v4.7._
*/
function toUint232(uint256 value) internal pure returns (uint232) {
require(value <= type(uint232).max, "SafeCast: value doesn't fit in 232 bits");
return uint232(value);
}
/**
* @dev Returns the downcasted uint224 from uint256, reverting on
* overflow (when the input is greater than largest uint224).
*
* Counterpart to Solidity's `uint224` operator.
*
* Requirements:
*
* - input must fit into 224 bits
*
* _Available since v4.2._
*/
function toUint224(uint256 value) internal pure returns (uint224) {
require(value <= type(uint224).max, "SafeCast: value doesn't fit in 224 bits");
return uint224(value);
}
/**
* @dev Returns the downcasted uint216 from uint256, reverting on
* overflow (when the input is greater than largest uint216).
*
* Counterpart to Solidity's `uint216` operator.
*
* Requirements:
*
* - input must fit into 216 bits
*
* _Available since v4.7._
*/
function toUint216(uint256 value) internal pure returns (uint216) {
require(value <= type(uint216).max, "SafeCast: value doesn't fit in 216 bits");
return uint216(value);
}
/**
* @dev Returns the downcasted uint208 from uint256, reverting on
* overflow (when the input is greater than largest uint208).
*
* Counterpart to Solidity's `uint208` operator.
*
* Requirements:
*
* - input must fit into 208 bits
*
* _Available since v4.7._
*/
function toUint208(uint256 value) internal pure returns (uint208) {
require(value <= type(uint208).max, "SafeCast: value doesn't fit in 208 bits");
return uint208(value);
}
/**
* @dev Returns the downcasted uint200 from uint256, reverting on
* overflow (when the input is greater than largest uint200).
*
* Counterpart to Solidity's `uint200` operator.
*
* Requirements:
*
* - input must fit into 200 bits
*
* _Available since v4.7._
*/
function toUint200(uint256 value) internal pure returns (uint200) {
require(value <= type(uint200).max, "SafeCast: value doesn't fit in 200 bits");
return uint200(value);
}
/**
* @dev Returns the downcasted uint192 from uint256, reverting on
* overflow (when the input is greater than largest uint192).
*
* Counterpart to Solidity's `uint192` operator.
*
* Requirements:
*
* - input must fit into 192 bits
*
* _Available since v4.7._
*/
function toUint192(uint256 value) internal pure returns (uint192) {
require(value <= type(uint192).max, "SafeCast: value doesn't fit in 192 bits");
return uint192(value);
}
/**
* @dev Returns the downcasted uint184 from uint256, reverting on
* overflow (when the input is greater than largest uint184).
*
* Counterpart to Solidity's `uint184` operator.
*
* Requirements:
*
* - input must fit into 184 bits
*
* _Available since v4.7._
*/
function toUint184(uint256 value) internal pure returns (uint184) {
require(value <= type(uint184).max, "SafeCast: value doesn't fit in 184 bits");
return uint184(value);
}
/**
* @dev Returns the downcasted uint176 from uint256, reverting on
* overflow (when the input is greater than largest uint176).
*
* Counterpart to Solidity's `uint176` operator.
*
* Requirements:
*
* - input must fit into 176 bits
*
* _Available since v4.7._
*/
function toUint176(uint256 value) internal pure returns (uint176) {
require(value <= type(uint176).max, "SafeCast: value doesn't fit in 176 bits");
return uint176(value);
}
/**
* @dev Returns the downcasted uint168 from uint256, reverting on
* overflow (when the input is greater than largest uint168).
*
* Counterpart to Solidity's `uint168` operator.
*
* Requirements:
*
* - input must fit into 168 bits
*
* _Available since v4.7._
*/
function toUint168(uint256 value) internal pure returns (uint168) {
require(value <= type(uint168).max, "SafeCast: value doesn't fit in 168 bits");
return uint168(value);
}
/**
* @dev Returns the downcasted uint160 from uint256, reverting on
* overflow (when the input is greater than largest uint160).
*
* Counterpart to Solidity's `uint160` operator.
*
* Requirements:
*
* - input must fit into 160 bits
*
* _Available since v4.7._
*/
function toUint160(uint256 value) internal pure returns (uint160) {
require(value <= type(uint160).max, "SafeCast: value doesn't fit in 160 bits");
return uint160(value);
}
/**
* @dev Returns the downcasted uint152 from uint256, reverting on
* overflow (when the input is greater than largest uint152).
*
* Counterpart to Solidity's `uint152` operator.
*
* Requirements:
*
* - input must fit into 152 bits
*
* _Available since v4.7._
*/
function toUint152(uint256 value) internal pure returns (uint152) {
require(value <= type(uint152).max, "SafeCast: value doesn't fit in 152 bits");
return uint152(value);
}
/**
* @dev Returns the downcasted uint144 from uint256, reverting on
* overflow (when the input is greater than largest uint144).
*
* Counterpart to Solidity's `uint144` operator.
*
* Requirements:
*
* - input must fit into 144 bits
*
* _Available since v4.7._
*/
function toUint144(uint256 value) internal pure returns (uint144) {
require(value <= type(uint144).max, "SafeCast: value doesn't fit in 144 bits");
return uint144(value);
}
/**
* @dev Returns the downcasted uint136 from uint256, reverting on
* overflow (when the input is greater than largest uint136).
*
* Counterpart to Solidity's `uint136` operator.
*
* Requirements:
*
* - input must fit into 136 bits
*
* _Available since v4.7._
*/
function toUint136(uint256 value) internal pure returns (uint136) {
require(value <= type(uint136).max, "SafeCast: value doesn't fit in 136 bits");
return uint136(value);
}
/**
* @dev Returns the downcasted uint128 from uint256, reverting on
* overflow (when the input is greater than largest uint128).
*
* Counterpart to Solidity's `uint128` operator.
*
* Requirements:
*
* - input must fit into 128 bits
*
* _Available since v2.5._
*/
function toUint128(uint256 value) internal pure returns (uint128) {
require(value <= type(uint128).max, "SafeCast: value doesn't fit in 128 bits");
return uint128(value);
}
/**
* @dev Returns the downcasted uint120 from uint256, reverting on
* overflow (when the input is greater than largest uint120).
*
* Counterpart to Solidity's `uint120` operator.
*
* Requirements:
*
* - input must fit into 120 bits
*
* _Available since v4.7._
*/
function toUint120(uint256 value) internal pure returns (uint120) {
require(value <= type(uint120).max, "SafeCast: value doesn't fit in 120 bits");
return uint120(value);
}
/**
* @dev Returns the downcasted uint112 from uint256, reverting on
* overflow (when the input is greater than largest uint112).
*
* Counterpart to Solidity's `uint112` operator.
*
* Requirements:
*
* - input must fit into 112 bits
*
* _Available since v4.7._
*/
function toUint112(uint256 value) internal pure returns (uint112) {
require(value <= type(uint112).max, "SafeCast: value doesn't fit in 112 bits");
return uint112(value);
}
/**
* @dev Returns the downcasted uint104 from uint256, reverting on
* overflow (when the input is greater than largest uint104).
*
* Counterpart to Solidity's `uint104` operator.
*
* Requirements:
*
* - input must fit into 104 bits
*
* _Available since v4.7._
*/
function toUint104(uint256 value) internal pure returns (uint104) {
require(value <= type(uint104).max, "SafeCast: value doesn't fit in 104 bits");
return uint104(value);
}
/**
* @dev Returns the downcasted uint96 from uint256, reverting on
* overflow (when the input is greater than largest uint96).
*
* Counterpart to Solidity's `uint96` operator.
*
* Requirements:
*
* - input must fit into 96 bits
*
* _Available since v4.2._
*/
function toUint96(uint256 value) internal pure returns (uint96) {
require(value <= type(uint96).max, "SafeCast: value doesn't fit in 96 bits");
return uint96(value);
}
/**
* @dev Returns the downcasted uint88 from uint256, reverting on
* overflow (when the input is greater than largest uint88).
*
* Counterpart to Solidity's `uint88` operator.
*
* Requirements:
*
* - input must fit into 88 bits
*
* _Available since v4.7._
*/
function toUint88(uint256 value) internal pure returns (uint88) {
require(value <= type(uint88).max, "SafeCast: value doesn't fit in 88 bits");
return uint88(value);
}
/**
* @dev Returns the downcasted uint80 from uint256, reverting on
* overflow (when the input is greater than largest uint80).
*
* Counterpart to Solidity's `uint80` operator.
*
* Requirements:
*
* - input must fit into 80 bits
*
* _Available since v4.7._
*/
function toUint80(uint256 value) internal pure returns (uint80) {
require(value <= type(uint80).max, "SafeCast: value doesn't fit in 80 bits");
return uint80(value);
}
/**
* @dev Returns the downcasted uint72 from uint256, reverting on
* overflow (when the input is greater than largest uint72).
*
* Counterpart to Solidity's `uint72` operator.
*
* Requirements:
*
* - input must fit into 72 bits
*
* _Available since v4.7._
*/
function toUint72(uint256 value) internal pure returns (uint72) {
require(value <= type(uint72).max, "SafeCast: value doesn't fit in 72 bits");
return uint72(value);
}
/**
* @dev Returns the downcasted uint64 from uint256, reverting on
* overflow (when the input is greater than largest uint64).
*
* Counterpart to Solidity's `uint64` operator.
*
* Requirements:
*
* - input must fit into 64 bits
*
* _Available since v2.5._
*/
function toUint64(uint256 value) internal pure returns (uint64) {
require(value <= type(uint64).max, "SafeCast: value doesn't fit in 64 bits");
return uint64(value);
}
/**
* @dev Returns the downcasted uint56 from uint256, reverting on
* overflow (when the input is greater than largest uint56).
*
* Counterpart to Solidity's `uint56` operator.
*
* Requirements:
*
* - input must fit into 56 bits
*
* _Available since v4.7._
*/
function toUint56(uint256 value) internal pure returns (uint56) {
require(value <= type(uint56).max, "SafeCast: value doesn't fit in 56 bits");
return uint56(value);
}
/**
* @dev Returns the downcasted uint48 from uint256, reverting on
* overflow (when the input is greater than largest uint48).
*
* Counterpart to Solidity's `uint48` operator.
*
* Requirements:
*
* - input must fit into 48 bits
*
* _Available since v4.7._
*/
function toUint48(uint256 value) internal pure returns (uint48) {
require(value <= type(uint48).max, "SafeCast: value doesn't fit in 48 bits");
return uint48(value);
}
/**
* @dev Returns the downcasted uint40 from uint256, reverting on
* overflow (when the input is greater than largest uint40).
*
* Counterpart to Solidity's `uint40` operator.
*
* Requirements:
*
* - input must fit into 40 bits
*
* _Available since v4.7._
*/
function toUint40(uint256 value) internal pure returns (uint40) {
require(value <= type(uint40).max, "SafeCast: value doesn't fit in 40 bits");
return uint40(value);
}
/**
* @dev Returns the downcasted uint32 from uint256, reverting on
* overflow (when the input is greater than largest uint32).
*
* Counterpart to Solidity's `uint32` operator.
*
* Requirements:
*
* - input must fit into 32 bits
*
* _Available since v2.5._
*/
function toUint32(uint256 value) internal pure returns (uint32) {
require(value <= type(uint32).max, "SafeCast: value doesn't fit in 32 bits");
return uint32(value);
}
/**
* @dev Returns the downcasted uint24 from uint256, reverting on
* overflow (when the input is greater than largest uint24).
*
* Counterpart to Solidity's `uint24` operator.
*
* Requirements:
*
* - input must fit into 24 bits
*
* _Available since v4.7._
*/
function toUint24(uint256 value) internal pure returns (uint24) {
require(value <= type(uint24).max, "SafeCast: value doesn't fit in 24 bits");
return uint24(value);
}
/**
* @dev Returns the downcasted uint16 from uint256, reverting on
* overflow (when the input is greater than largest uint16).
*
* Counterpart to Solidity's `uint16` operator.
*
* Requirements:
*
* - input must fit into 16 bits
*
* _Available since v2.5._
*/
function toUint16(uint256 value) internal pure returns (uint16) {
require(value <= type(uint16).max, "SafeCast: value doesn't fit in 16 bits");
return uint16(value);
}
/**
* @dev Returns the downcasted uint8 from uint256, reverting on
* overflow (when the input is greater than largest uint8).
*
* Counterpart to Solidity's `uint8` operator.
*
* Requirements:
*
* - input must fit into 8 bits
*
* _Available since v2.5._
*/
function toUint8(uint256 value) internal pure returns (uint8) {
require(value <= type(uint8).max, "SafeCast: value doesn't fit in 8 bits");
return uint8(value);
}
/**
* @dev Converts a signed int256 into an unsigned uint256.
*
* Requirements:
*
* - input must be greater than or equal to 0.
*
* _Available since v3.0._
*/
function toUint256(int256 value) internal pure returns (uint256) {
require(value >= 0, "SafeCast: value must be positive");
return uint256(value);
}
/**
* @dev Returns the downcasted int248 from int256, reverting on
* overflow (when the input is less than smallest int248 or
* greater than largest int248).
*
* Counterpart to Solidity's `int248` operator.
*
* Requirements:
*
* - input must fit into 248 bits
*
* _Available since v4.7._
*/
function toInt248(int256 value) internal pure returns (int248 downcasted) {
downcasted = int248(value);
require(downcasted == value, "SafeCast: value doesn't fit in 248 bits");
}
/**
* @dev Returns the downcasted int240 from int256, reverting on
* overflow (when the input is less than smallest int240 or
* greater than largest int240).
*
* Counterpart to Solidity's `int240` operator.
*
* Requirements:
*
* - input must fit into 240 bits
*
* _Available since v4.7._
*/
function toInt240(int256 value) internal pure returns (int240 downcasted) {
downcasted = int240(value);
require(downcasted == value, "SafeCast: value doesn't fit in 240 bits");
}
/**
* @dev Returns the downcasted int232 from int256, reverting on
* overflow (when the input is less than smallest int232 or
* greater than largest int232).
*
* Counterpart to Solidity's `int232` operator.
*
* Requirements:
*
* - input must fit into 232 bits
*
* _Available since v4.7._
*/
function toInt232(int256 value) internal pure returns (int232 downcasted) {
downcasted = int232(value);
require(downcasted == value, "SafeCast: value doesn't fit in 232 bits");
}
/**
* @dev Returns the downcasted int224 from int256, reverting on
* overflow (when the input is less than smallest int224 or
* greater than largest int224).
*
* Counterpart to Solidity's `int224` operator.
*
* Requirements:
*
* - input must fit into 224 bits
*
* _Available since v4.7._
*/
function toInt224(int256 value) internal pure returns (int224 downcasted) {
downcasted = int224(value);
require(downcasted == value, "SafeCast: value doesn't fit in 224 bits");
}
/**
* @dev Returns the downcasted int216 from int256, reverting on
* overflow (when the input is less than smallest int216 or
* greater than largest int216).
*
* Counterpart to Solidity's `int216` operator.
*
* Requirements:
*
* - input must fit into 216 bits
*
* _Available since v4.7._
*/
function toInt216(int256 value) internal pure returns (int216 downcasted) {
downcasted = int216(value);
require(downcasted == value, "SafeCast: value doesn't fit in 216 bits");
}
/**
* @dev Returns the downcasted int208 from int256, reverting on
* overflow (when the input is less than smallest int208 or
* greater than largest int208).
*
* Counterpart to Solidity's `int208` operator.
*
* Requirements:
*
* - input must fit into 208 bits
*
* _Available since v4.7._
*/
function toInt208(int256 value) internal pure returns (int208 downcasted) {
downcasted = int208(value);
require(downcasted == value, "SafeCast: value doesn't fit in 208 bits");
}
/**
* @dev Returns the downcasted int200 from int256, reverting on
* overflow (when the input is less than smallest int200 or
* greater than largest int200).
*
* Counterpart to Solidity's `int200` operator.
*
* Requirements:
*
* - input must fit into 200 bits
*
* _Available since v4.7._
*/
function toInt200(int256 value) internal pure returns (int200 downcasted) {
downcasted = int200(value);
require(downcasted == value, "SafeCast: value doesn't fit in 200 bits");
}
/**
* @dev Returns the downcasted int192 from int256, reverting on
* overflow (when the input is less than smallest int192 or
* greater than largest int192).
*
* Counterpart to Solidity's `int192` operator.
*
* Requirements:
*
* - input must fit into 192 bits
*
* _Available since v4.7._
*/
function toInt192(int256 value) internal pure returns (int192 downcasted) {
downcasted = int192(value);
require(downcasted == value, "SafeCast: value doesn't fit in 192 bits");
}
/**
* @dev Returns the downcasted int184 from int256, reverting on
* overflow (when the input is less than smallest int184 or
* greater than largest int184).
*
* Counterpart to Solidity's `int184` operator.
*
* Requirements:
*
* - input must fit into 184 bits
*
* _Available since v4.7._
*/
function toInt184(int256 value) internal pure returns (int184 downcasted) {
downcasted = int184(value);
require(downcasted == value, "SafeCast: value doesn't fit in 184 bits");
}
/**
* @dev Returns the downcasted int176 from int256, reverting on
* overflow (when the input is less than smallest int176 or
* greater than largest int176).
*
* Counterpart to Solidity's `int176` operator.
*
* Requirements:
*
* - input must fit into 176 bits
*
* _Available since v4.7._
*/
function toInt176(int256 value) internal pure returns (int176 downcasted) {
downcasted = int176(value);
require(downcasted == value, "SafeCast: value doesn't fit in 176 bits");
}
/**
* @dev Returns the downcasted int168 from int256, reverting on
* overflow (when the input is less than smallest int168 or
* greater than largest int168).
*
* Counterpart to Solidity's `int168` operator.
*
* Requirements:
*
* - input must fit into 168 bits
*
* _Available since v4.7._
*/
function toInt168(int256 value) internal pure returns (int168 downcasted) {
downcasted = int168(value);
require(downcasted == value, "SafeCast: value doesn't fit in 168 bits");
}
/**
* @dev Returns the downcasted int160 from int256, reverting on
* overflow (when the input is less than smallest int160 or
* greater than largest int160).
*
* Counterpart to Solidity's `int160` operator.
*
* Requirements:
*
* - input must fit into 160 bits
*
* _Available since v4.7._
*/
function toInt160(int256 value) internal pure returns (int160 downcasted) {
downcasted = int160(value);
require(downcasted == value, "SafeCast: value doesn't fit in 160 bits");
}
/**
* @dev Returns the downcasted int152 from int256, reverting on
* overflow (when the input is less than smallest int152 or
* greater than largest int152).
*
* Counterpart to Solidity's `int152` operator.
*
* Requirements:
*
* - input must fit into 152 bits
*
* _Available since v4.7._
*/
function toInt152(int256 value) internal pure returns (int152 downcasted) {
downcasted = int152(value);
require(downcasted == value, "SafeCast: value doesn't fit in 152 bits");
}
/**
* @dev Returns the downcasted int144 from int256, reverting on
* overflow (when the input is less than smallest int144 or
* greater than largest int144).
*
* Counterpart to Solidity's `int144` operator.
*
* Requirements:
*
* - input must fit into 144 bits
*
* _Available since v4.7._
*/
function toInt144(int256 value) internal pure returns (int144 downcasted) {
downcasted = int144(value);
require(downcasted == value, "SafeCast: value doesn't fit in 144 bits");
}
/**
* @dev Returns the downcasted int136 from int256, reverting on
* overflow (when the input is less than smallest int136 or
* greater than largest int136).
*
* Counterpart to Solidity's `int136` operator.
*
* Requirements:
*
* - input must fit into 136 bits
*
* _Available since v4.7._
*/
function toInt136(int256 value) internal pure returns (int136 downcasted) {
downcasted = int136(value);
require(downcasted == value, "SafeCast: value doesn't fit in 136 bits");
}
/**
* @dev Returns the downcasted int128 from int256, reverting on
* overflow (when the input is less than smallest int128 or
* greater than largest int128).
*
* Counterpart to Solidity's `int128` operator.
*
* Requirements:
*
* - input must fit into 128 bits
*
* _Available since v3.1._
*/
function toInt128(int256 value) internal pure returns (int128 downcasted) {
downcasted = int128(value);
require(downcasted == value, "SafeCast: value doesn't fit in 128 bits");
}
/**
* @dev Returns the downcasted int120 from int256, reverting on
* overflow (when the input is less than smallest int120 or
* greater than largest int120).
*
* Counterpart to Solidity's `int120` operator.
*
* Requirements:
*
* - input must fit into 120 bits
*
* _Available since v4.7._
*/
function toInt120(int256 value) internal pure returns (int120 downcasted) {
downcasted = int120(value);
require(downcasted == value, "SafeCast: value doesn't fit in 120 bits");
}
/**
* @dev Returns the downcasted int112 from int256, reverting on
* overflow (when the input is less than smallest int112 or
* greater than largest int112).
*
* Counterpart to Solidity's `int112` operator.
*
* Requirements:
*
* - input must fit into 112 bits
*
* _Available since v4.7._
*/
function toInt112(int256 value) internal pure returns (int112 downcasted) {
downcasted = int112(value);
require(downcasted == value, "SafeCast: value doesn't fit in 112 bits");
}
/**
* @dev Returns the downcasted int104 from int256, reverting on
* overflow (when the input is less than smallest int104 or
* greater than largest int104).
*
* Counterpart to Solidity's `int104` operator.
*
* Requirements:
*
* - input must fit into 104 bits
*
* _Available since v4.7._
*/
function toInt104(int256 value) internal pure returns (int104 downcasted) {
downcasted = int104(value);
require(downcasted == value, "SafeCast: value doesn't fit in 104 bits");
}
/**
* @dev Returns the downcasted int96 from int256, reverting on
* overflow (when the input is less than smallest int96 or
* greater than largest int96).
*
* Counterpart to Solidity's `int96` operator.
*
* Requirements:
*
* - input must fit into 96 bits
*
* _Available since v4.7._
*/
function toInt96(int256 value) internal pure returns (int96 downcasted) {
downcasted = int96(value);
require(downcasted == value, "SafeCast: value doesn't fit in 96 bits");
}
/**
* @dev Returns the downcasted int88 from int256, reverting on
* overflow (when the input is less than smallest int88 or
* greater than largest int88).
*
* Counterpart to Solidity's `int88` operator.
*
* Requirements:
*
* - input must fit into 88 bits
*
* _Available since v4.7._
*/
function toInt88(int256 value) internal pure returns (int88 downcasted) {
downcasted = int88(value);
require(downcasted == value, "SafeCast: value doesn't fit in 88 bits");
}
/**
* @dev Returns the downcasted int80 from int256, reverting on
* overflow (when the input is less than smallest int80 or
* greater than largest int80).
*
* Counterpart to Solidity's `int80` operator.
*
* Requirements:
*
* - input must fit into 80 bits
*
* _Available since v4.7._
*/
function toInt80(int256 value) internal pure returns (int80 downcasted) {
downcasted = int80(value);
require(downcasted == value, "SafeCast: value doesn't fit in 80 bits");
}
/**
* @dev Returns the downcasted int72 from int256, reverting on
* overflow (when the input is less than smallest int72 or
* greater than largest int72).
*
* Counterpart to Solidity's `int72` operator.
*
* Requirements:
*
* - input must fit into 72 bits
*
* _Available since v4.7._
*/
function toInt72(int256 value) internal pure returns (int72 downcasted) {
downcasted = int72(value);
require(downcasted == value, "SafeCast: value doesn't fit in 72 bits");
}
/**
* @dev Returns the downcasted int64 from int256, reverting on
* overflow (when the input is less than smallest int64 or
* greater than largest int64).
*
* Counterpart to Solidity's `int64` operator.
*
* Requirements:
*
* - input must fit into 64 bits
*
* _Available since v3.1._
*/
function toInt64(int256 value) internal pure returns (int64 downcasted) {
downcasted = int64(value);
require(downcasted == value, "SafeCast: value doesn't fit in 64 bits");
}
/**
* @dev Returns the downcasted int56 from int256, reverting on
* overflow (when the input is less than smallest int56 or
* greater than largest int56).
*
* Counterpart to Solidity's `int56` operator.
*
* Requirements:
*
* - input must fit into 56 bits
*
* _Available since v4.7._
*/
function toInt56(int256 value) internal pure returns (int56 downcasted) {
downcasted = int56(value);
require(downcasted == value, "SafeCast: value doesn't fit in 56 bits");
}
/**
* @dev Returns the downcasted int48 from int256, reverting on
* overflow (when the input is less than smallest int48 or
* greater than largest int48).
*
* Counterpart to Solidity's `int48` operator.
*
* Requirements:
*
* - input must fit into 48 bits
*
* _Available since v4.7._
*/
function toInt48(int256 value) internal pure returns (int48 downcasted) {
downcasted = int48(value);
require(downcasted == value, "SafeCast: value doesn't fit in 48 bits");
}
/**
* @dev Returns the downcasted int40 from int256, reverting on
* overflow (when the input is less than smallest int40 or
* greater than largest int40).
*
* Counterpart to Solidity's `int40` operator.
*
* Requirements:
*
* - input must fit into 40 bits
*
* _Available since v4.7._
*/
function toInt40(int256 value) internal pure returns (int40 downcasted) {
downcasted = int40(value);
require(downcasted == value, "SafeCast: value doesn't fit in 40 bits");
}
/**
* @dev Returns the downcasted int32 from int256, reverting on
* overflow (when the input is less than smallest int32 or
* greater than largest int32).
*
* Counterpart to Solidity's `int32` operator.
*
* Requirements:
*
* - input must fit into 32 bits
*
* _Available since v3.1._
*/
function toInt32(int256 value) internal pure returns (int32 downcasted) {
downcasted = int32(value);
require(downcasted == value, "SafeCast: value doesn't fit in 32 bits");
}
/**
* @dev Returns the downcasted int24 from int256, reverting on
* overflow (when the input is less than smallest int24 or
* greater than largest int24).
*
* Counterpart to Solidity's `int24` operator.
*
* Requirements:
*
* - input must fit into 24 bits
*
* _Available since v4.7._
*/
function toInt24(int256 value) internal pure returns (int24 downcasted) {
downcasted = int24(value);
require(downcasted == value, "SafeCast: value doesn't fit in 24 bits");
}
/**
* @dev Returns the downcasted int16 from int256, reverting on
* overflow (when the input is less than smallest int16 or
* greater than largest int16).
*
* Counterpart to Solidity's `int16` operator.
*
* Requirements:
*
* - input must fit into 16 bits
*
* _Available since v3.1._
*/
function toInt16(int256 value) internal pure returns (int16 downcasted) {
downcasted = int16(value);
require(downcasted == value, "SafeCast: value doesn't fit in 16 bits");
}
/**
* @dev Returns the downcasted int8 from int256, reverting on
* overflow (when the input is less than smallest int8 or
* greater than largest int8).
*
* Counterpart to Solidity's `int8` operator.
*
* Requirements:
*
* - input must fit into 8 bits
*
* _Available since v3.1._
*/
function toInt8(int256 value) internal pure returns (int8 downcasted) {
downcasted = int8(value);
require(downcasted == value, "SafeCast: value doesn't fit in 8 bits");
}
/**
* @dev Converts an unsigned uint256 into a signed int256.
*
* Requirements:
*
* - input must be less than or equal to maxInt256.
*
* _Available since v3.0._
*/
function toInt256(uint256 value) internal pure returns (int256) {
// Note: Unsafe cast below is okay because `type(int256).max` is guaranteed to be positive
require(value <= uint256(type(int256).max), "SafeCast: value doesn't fit in an int256");
return int256(value);
}
}
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.8.0) (token/ERC20/utils/SafeERC20.sol)
pragma solidity ^0.8.0;
import "../IERC20.sol";
import "../extensions/draft-IERC20Permit.sol";
import "../../../utils/Address.sol";
/**
* @title SafeERC20
* @dev Wrappers around ERC20 operations that throw on failure (when the token
* contract returns false). Tokens that return no value (and instead revert or
* throw on failure) are also supported, non-reverting calls are assumed to be
* successful.
* To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract,
* which allows you to call the safe operations as `token.safeTransfer(...)`, etc.
*/
library SafeERC20 {
using Address for address;
function safeTransfer(
IERC20 token,
address to,
uint256 value
) internal {
_callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value));
}
function safeTransferFrom(
IERC20 token,
address from,
address to,
uint256 value
) internal {
_callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value));
}
/**
* @dev Deprecated. This function has issues similar to the ones found in
* {IERC20-approve}, and its usage is discouraged.
*
* Whenever possible, use {safeIncreaseAllowance} and
* {safeDecreaseAllowance} instead.
*/
function safeApprove(
IERC20 token,
address spender,
uint256 value
) internal {
// safeApprove should only be called when setting an initial allowance,
// or when resetting it to zero. To increase and decrease it, use
// 'safeIncreaseAllowance' and 'safeDecreaseAllowance'
require(
(value == 0) || (token.allowance(address(this), spender) == 0),
"SafeERC20: approve from non-zero to non-zero allowance"
);
_callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value));
}
function safeIncreaseAllowance(
IERC20 token,
address spender,
uint256 value
) internal {
uint256 newAllowance = token.allowance(address(this), spender) + value;
_callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));
}
function safeDecreaseAllowance(
IERC20 token,
address spender,
uint256 value
) internal {
unchecked {
uint256 oldAllowance = token.allowance(address(this), spender);
require(oldAllowance >= value, "SafeERC20: decreased allowance below zero");
uint256 newAllowance = oldAllowance - value;
_callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));
}
}
function safePermit(
IERC20Permit token,
address owner,
address spender,
uint256 value,
uint256 deadline,
uint8 v,
bytes32 r,
bytes32 s
) internal {
uint256 nonceBefore = token.nonces(owner);
token.permit(owner, spender, value, deadline, v, r, s);
uint256 nonceAfter = token.nonces(owner);
require(nonceAfter == nonceBefore + 1, "SafeERC20: permit did not succeed");
}
/**
* @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement
* on the return value: the return value is optional (but if data is returned, it must not be false).
* @param token The token targeted by the call.
* @param data The call data (encoded using abi.encode or one of its variants).
*/
function _callOptionalReturn(IERC20 token, bytes memory data) private {
// We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since
// we're implementing it ourselves. We use {Address-functionCall} to perform this call, which verifies that
// the target address contains contract code and also asserts for success in the low-level call.
bytes memory returndata = address(token).functionCall(data, "SafeERC20: low-level call failed");
if (returndata.length > 0) {
// Return data is optional
require(abi.decode(returndata, (bool)), "SafeERC20: ERC20 operation did not succeed");
}
}
}
// SPDX-License-Identifier: MIT
pragma solidity =0.8.18;
library TransferReason {
uint8 public constant UNSTAKE = 0x01;
uint8 public constant CLAIM_REWARD = 0x02;
uint8 public constant CLAIM_FEE = 0x03;
uint8 public constant WITHDRAW_FEE = 0x04;
uint8 public constant ADMIN_WITHDRAW = 0x05;
}
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/draft-IERC20Permit.sol)
pragma solidity ^0.8.0;
/**
* @dev Interface of the ERC20 Permit extension allowing approvals to be made via signatures, as defined in
* https://eips.ethereum.org/EIPS/eip-2612[EIP-2612].
*
* Adds the {permit} method, which can be used to change an account's ERC20 allowance (see {IERC20-allowance}) by
* presenting a message signed by the account. By not relying on {IERC20-approve}, the token holder account doesn't
* need to send a transaction, and thus is not required to hold Ether at all.
*/
interface IERC20Permit {
/**
* @dev Sets `value` as the allowance of `spender` over ``owner``'s tokens,
* given ``owner``'s signed approval.
*
* IMPORTANT: The same issues {IERC20-approve} has related to transaction
* ordering also apply here.
*
* Emits an {Approval} event.
*
* Requirements:
*
* - `spender` cannot be the zero address.
* - `deadline` must be a timestamp in the future.
* - `v`, `r` and `s` must be a valid `secp256k1` signature from `owner`
* over the EIP712-formatted function arguments.
* - the signature must use ``owner``'s current nonce (see {nonces}).
*
* For more information on the signature format, see the
* https://eips.ethereum.org/EIPS/eip-2612#specification[relevant EIP
* section].
*/
function permit(
address owner,
address spender,
uint256 value,
uint256 deadline,
uint8 v,
bytes32 r,
bytes32 s
) external;
/**
* @dev Returns the current nonce for `owner`. This value must be
* included whenever a signature is generated for {permit}.
*
* Every successful call to {permit} increases ``owner``'s nonce by one. This
* prevents a signature from being used multiple times.
*/
function nonces(address owner) external view returns (uint256);
/**
* @dev Returns the domain separator used in the encoding of the signature for {permit}, as defined by {EIP712}.
*/
// solhint-disable-next-line func-name-mixedcase
function DOMAIN_SEPARATOR() external view returns (bytes32);
}
{
"compilationTarget": {
"contracts/AethirEdge.sol": "AethirEdge"
},
"evmVersion": "paris",
"libraries": {},
"metadata": {
"bytecodeHash": "none",
"useLiteralContent": true
},
"optimizer": {
"enabled": true,
"runs": 200
},
"remappings": []
}
[{"inputs":[{"internalType":"contract IRegistry","name":"registry","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[{"internalType":"string","name":"message","type":"string"}],"name":"DataConflict","type":"error"},{"inputs":[],"name":"DataExpired","type":"error"},{"inputs":[],"name":"DataTooOld","type":"error"},{"inputs":[{"internalType":"string","name":"message","type":"string"}],"name":"InvalidParameter","type":"error"},{"inputs":[],"name":"InvalidPayload","type":"error"},{"inputs":[],"name":"InvalidProof","type":"error"},{"inputs":[],"name":"InvalidVersion","type":"error"},{"inputs":[],"name":"NonceTooLow","type":"error"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"},{"indexed":false,"internalType":"string","name":"message","type":"string"}],"name":"AdminWithdraw","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"provider","type":"address"},{"indexed":false,"internalType":"uint64","name":"nonce","type":"uint64"},{"components":[{"internalType":"uint16","name":"count","type":"uint16"},{"internalType":"uint32","name":"offset","type":"uint32"},{"internalType":"bytes","name":"bitset","type":"bytes"}],"indexed":false,"internalType":"struct IEdge.ContainerList","name":"containers","type":"tuple"}],"name":"ClaimReward","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"provider","type":"address"},{"indexed":false,"internalType":"uint64","name":"nonce","type":"uint64"},{"components":[{"internalType":"uint16","name":"count","type":"uint16"},{"internalType":"uint32","name":"offset","type":"uint32"},{"internalType":"bytes","name":"bitset","type":"bytes"}],"indexed":false,"internalType":"struct IEdge.ContainerList","name":"containers","type":"tuple"}],"name":"ClaimServiceFee","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"developer","type":"address"},{"indexed":false,"internalType":"uint64","name":"nonce","type":"uint64"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"DepositServiceFee","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"operator","type":"address"},{"indexed":false,"internalType":"uint64","name":"nonce","type":"uint64"},{"indexed":false,"internalType":"address[]","name":"providers","type":"address[]"},{"indexed":false,"internalType":"uint32[]","name":"indexes","type":"uint32[]"}],"name":"ForceUnstake","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"provider","type":"address"},{"indexed":false,"internalType":"uint64","name":"nonce","type":"uint64"},{"components":[{"internalType":"uint16","name":"count","type":"uint16"},{"internalType":"uint32","name":"offset","type":"uint32"},{"internalType":"bytes","name":"bitset","type":"bytes"}],"indexed":false,"internalType":"struct IEdge.ContainerList","name":"containers","type":"tuple"}],"name":"Stake","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"provider","type":"address"},{"indexed":false,"internalType":"uint64","name":"nonce","type":"uint64"},{"components":[{"internalType":"uint16","name":"count","type":"uint16"},{"internalType":"uint32","name":"offset","type":"uint32"},{"internalType":"bytes","name":"bitset","type":"bytes"}],"indexed":false,"internalType":"struct IEdge.ContainerList","name":"containers","type":"tuple"}],"name":"Switch","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"provider","type":"address"},{"indexed":false,"internalType":"uint64","name":"nonce","type":"uint64"},{"components":[{"internalType":"uint16","name":"count","type":"uint16"},{"internalType":"uint32","name":"offset","type":"uint32"},{"internalType":"bytes","name":"bitset","type":"bytes"}],"indexed":false,"internalType":"struct IEdge.ContainerList","name":"containers","type":"tuple"}],"name":"Unstake","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint64","name":"oldVersion","type":"uint64"},{"indexed":true,"internalType":"uint64","name":"newVersion","type":"uint64"}],"name":"VersionUpdate","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"developer","type":"address"},{"indexed":false,"internalType":"uint64","name":"nonce","type":"uint64"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"WithdrawServiceFee","type":"event"},{"inputs":[{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"string","name":"message","type":"string"}],"name":"adminWithdraw","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"components":[{"internalType":"uint16","name":"count","type":"uint16"},{"internalType":"uint32","name":"offset","type":"uint32"},{"internalType":"bytes","name":"bitset","type":"bytes"}],"internalType":"struct IEdge.ContainerList","name":"containers","type":"tuple"},{"components":[{"internalType":"uint64","name":"nonce","type":"uint64"},{"internalType":"uint64","name":"deadline","type":"uint64"},{"internalType":"uint64","name":"lastUpdateBlock","type":"uint64"},{"internalType":"uint64","name":"version","type":"uint64"},{"internalType":"bytes[]","name":"payloads","type":"bytes[]"},{"internalType":"bytes[]","name":"proof","type":"bytes[]"}],"internalType":"struct IEdge.VerifiableData","name":"vdata","type":"tuple"}],"name":"claimReward","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"components":[{"internalType":"uint16","name":"count","type":"uint16"},{"internalType":"uint32","name":"offset","type":"uint32"},{"internalType":"bytes","name":"bitset","type":"bytes"}],"internalType":"struct IEdge.ContainerList","name":"containers","type":"tuple"},{"components":[{"internalType":"uint64","name":"nonce","type":"uint64"},{"internalType":"uint64","name":"deadline","type":"uint64"},{"internalType":"uint64","name":"lastUpdateBlock","type":"uint64"},{"internalType":"uint64","name":"version","type":"uint64"},{"internalType":"bytes[]","name":"payloads","type":"bytes[]"},{"internalType":"bytes[]","name":"proof","type":"bytes[]"}],"internalType":"struct IEdge.VerifiableData","name":"vdata","type":"tuple"}],"name":"claimServiceFee","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"currentEpoch","outputs":[{"internalType":"uint64","name":"epoch","type":"uint64"},{"internalType":"uint64","name":"startTs","type":"uint64"},{"internalType":"uint64","name":"endTs","type":"uint64"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"amount","type":"uint256"},{"components":[{"internalType":"uint64","name":"nonce","type":"uint64"},{"internalType":"uint64","name":"deadline","type":"uint64"},{"internalType":"uint64","name":"lastUpdateBlock","type":"uint64"},{"internalType":"uint64","name":"version","type":"uint64"},{"internalType":"bytes[]","name":"payloads","type":"bytes[]"},{"internalType":"bytes[]","name":"proof","type":"bytes[]"}],"internalType":"struct IEdge.VerifiableData","name":"vdata","type":"tuple"}],"name":"depositServiceFee","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address[]","name":"providers","type":"address[]"},{"internalType":"uint32[]","name":"indexes","type":"uint32[]"},{"components":[{"internalType":"uint64","name":"nonce","type":"uint64"},{"internalType":"uint64","name":"deadline","type":"uint64"},{"internalType":"uint64","name":"lastUpdateBlock","type":"uint64"},{"internalType":"uint64","name":"version","type":"uint64"},{"internalType":"bytes[]","name":"payloads","type":"bytes[]"},{"internalType":"bytes[]","name":"proof","type":"bytes[]"}],"internalType":"struct IEdge.VerifiableData","name":"vdata","type":"tuple"}],"name":"forceUnstake","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"}],"name":"getUserData","outputs":[{"components":[{"internalType":"uint64","name":"nonce","type":"uint64"},{"internalType":"uint64","name":"lastUpdateBlock","type":"uint64"}],"internalType":"struct AethirEdge.UserData","name":"","type":"tuple"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"}],"name":"nonces","outputs":[{"internalType":"uint64","name":"","type":"uint64"}],"stateMutability":"view","type":"function"},{"inputs":[{"components":[{"internalType":"uint16","name":"count","type":"uint16"},{"internalType":"uint32","name":"offset","type":"uint32"},{"internalType":"bytes","name":"bitset","type":"bytes"}],"internalType":"struct IEdge.ContainerList","name":"containers","type":"tuple"},{"components":[{"internalType":"uint64","name":"nonce","type":"uint64"},{"internalType":"uint64","name":"deadline","type":"uint64"},{"internalType":"uint64","name":"lastUpdateBlock","type":"uint64"},{"internalType":"uint64","name":"version","type":"uint64"},{"internalType":"bytes[]","name":"payloads","type":"bytes[]"},{"internalType":"bytes[]","name":"proof","type":"bytes[]"}],"internalType":"struct IEdge.VerifiableData","name":"vdata","type":"tuple"}],"name":"stakeContainers","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"components":[{"internalType":"uint16","name":"count","type":"uint16"},{"internalType":"uint32","name":"offset","type":"uint32"},{"internalType":"bytes","name":"bitset","type":"bytes"}],"internalType":"struct IEdge.ContainerList","name":"container","type":"tuple"},{"components":[{"internalType":"uint64","name":"nonce","type":"uint64"},{"internalType":"uint64","name":"deadline","type":"uint64"},{"internalType":"uint64","name":"lastUpdateBlock","type":"uint64"},{"internalType":"uint64","name":"version","type":"uint64"},{"internalType":"bytes[]","name":"payloads","type":"bytes[]"},{"internalType":"bytes[]","name":"proof","type":"bytes[]"}],"internalType":"struct IEdge.VerifiableData","name":"vdata","type":"tuple"}],"name":"switchContainers","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"components":[{"internalType":"uint16","name":"count","type":"uint16"},{"internalType":"uint32","name":"offset","type":"uint32"},{"internalType":"bytes","name":"bitset","type":"bytes"}],"internalType":"struct IEdge.ContainerList","name":"containers","type":"tuple"},{"components":[{"internalType":"uint64","name":"nonce","type":"uint64"},{"internalType":"uint64","name":"deadline","type":"uint64"},{"internalType":"uint64","name":"lastUpdateBlock","type":"uint64"},{"internalType":"uint64","name":"version","type":"uint64"},{"internalType":"bytes[]","name":"payloads","type":"bytes[]"},{"internalType":"bytes[]","name":"proof","type":"bytes[]"}],"internalType":"struct IEdge.VerifiableData","name":"vdata","type":"tuple"}],"name":"unstakeContainers","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"version","outputs":[{"internalType":"uint64","name":"","type":"uint64"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"amount","type":"uint256"},{"components":[{"internalType":"uint64","name":"nonce","type":"uint64"},{"internalType":"uint64","name":"deadline","type":"uint64"},{"internalType":"uint64","name":"lastUpdateBlock","type":"uint64"},{"internalType":"uint64","name":"version","type":"uint64"},{"internalType":"bytes[]","name":"payloads","type":"bytes[]"},{"internalType":"bytes[]","name":"proof","type":"bytes[]"}],"internalType":"struct IEdge.VerifiableData","name":"vdata","type":"tuple"}],"name":"withdrawServiceFee","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"}]