Verified contractPartialMIT
GenesisSplitUpkeep
Address0x565554e00f35f2c774e6ce99bfff10a51a16349f
- Balance
0 ETH
- Transactions
1
- Compiler
solc 0.8.20
- Same code
Only this contract
Details
- Compiler
- solc 0.8.20+commit.a1b79de6
- Language
- solidity
- Optimization
- Yes, 800 runs
- EVM version
- paris
- License
- MIT
- Match
- Partialcreation code: yes, runtime code: yes
- Verified on Sourcify
- Created in block
- 26,336,702
- Creation transaction
- 0x8fbf49b94b…ad88d140cd
contracts/GenesisSplitUpkeep.sol
// SPDX-License-Identifier: MIT
pragma solidity =0.8.20;
import {IAccessControl} from '@openzeppelin/contracts/access/IAccessControl.sol';
import {IAlgebraVault} from './interfaces/IAlgebraVault.sol';
import {IGenesisSplitUpkeep} from './interfaces/IGenesisSplitUpkeep.sol';
/// @title Genesis Split Upkeep
/// @notice Calls splitAndHold on a list of Algebra vaults
/// @dev The vaults check their caller, so this contract must hold GENESIS_SPLITTER_ROLE on the vault factory too
contract GenesisSplitUpkeep is IGenesisSplitUpkeep {
/// @inheritdoc IGenesisSplitUpkeep
bytes32 public constant GENESIS_SPLITTER_ROLE = keccak256('GENESIS_SPLITTER_ROLE');
/// @inheritdoc IGenesisSplitUpkeep
address public immutable factory;
/// @param _factory The vault factory that holds the roles
constructor(address _factory) {
if (_factory == address(0)) revert ZeroAddress();
factory = _factory;
}
/// @inheritdoc IGenesisSplitUpkeep
function splitAndHoldUpkeep(address[] calldata vaults) external {
if (!IAccessControl(factory).hasRole(GENESIS_SPLITTER_ROLE, msg.sender)) revert NotGenesisSplitter();
uint256 len = vaults.length;
for (uint256 i; i < len; i++) IAlgebraVault(vaults[i]).splitAndHold();
}
}
@openzeppelin/contracts/access/IAccessControl.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (access/IAccessControl.sol)
pragma solidity ^0.8.0;
/**
* @dev External interface of AccessControl declared to support ERC165 detection.
*/
interface IAccessControl {
/**
* @dev Emitted when `newAdminRole` is set as ``role``'s admin role, replacing `previousAdminRole`
*
* `DEFAULT_ADMIN_ROLE` is the starting admin for all roles, despite
* {RoleAdminChanged} not being emitted signaling this.
*
* _Available since v3.1._
*/
event RoleAdminChanged(bytes32 indexed role, bytes32 indexed previousAdminRole, bytes32 indexed newAdminRole);
/**
* @dev Emitted when `account` is granted `role`.
*
* `sender` is the account that originated the contract call, an admin role
* bearer except when using {AccessControl-_setupRole}.
*/
event RoleGranted(bytes32 indexed role, address indexed account, address indexed sender);
/**
* @dev Emitted when `account` is revoked `role`.
*
* `sender` is the account that originated the contract call:
* - if using `revokeRole`, it is the admin role bearer
* - if using `renounceRole`, it is the role bearer (i.e. `account`)
*/
event RoleRevoked(bytes32 indexed role, address indexed account, address indexed sender);
/**
* @dev Returns `true` if `account` has been granted `role`.
*/
function hasRole(bytes32 role, address account) external view returns (bool);
/**
* @dev Returns the admin role that controls `role`. See {grantRole} and
* {revokeRole}.
*
* To change a role's admin, use {AccessControl-_setRoleAdmin}.
*/
function getRoleAdmin(bytes32 role) external view returns (bytes32);
/**
* @dev Grants `role` to `account`.
*
* If `account` had not been already granted `role`, emits a {RoleGranted}
* event.
*
* Requirements:
*
* - the caller must have ``role``'s admin role.
*/
function grantRole(bytes32 role, address account) external;
/**
* @dev Revokes `role` from `account`.
*
* If `account` had been granted `role`, emits a {RoleRevoked} event.
*
* Requirements:
*
* - the caller must have ``role``'s admin role.
*/
function revokeRole(bytes32 role, address account) external;
/**
* @dev Revokes `role` from the calling account.
*
* Roles are often managed via {grantRole} and {revokeRole}: this function's
* purpose is to provide a mechanism for accounts to lose their privileges
* if they are compromised (such as when a trusted device is misplaced).
*
* If the calling account had been granted `role`, emits a {RoleRevoked}
* event.
*
* Requirements:
*
* - the caller must be `account`.
*/
function renounceRole(bytes32 role, address account) external;
}
contracts/interfaces/IAlgebraVault.sol
// SPDX-License-Identifier: MIT
pragma solidity >=0.8.0;
/// @title Interface for Algebra Vault
/// @notice Interface for managing fee collection and distribution for Algebra pools
interface IAlgebraVault {
/// @notice The address of the vault factory contract
function factory() external view returns (address);
/// @notice The address of the associated Algebra pool
function pool() external view returns (address);
/// @notice The address of the voter contract, read from the vault factory
/// @dev Zero when the chain has no voter, in which case only the non-farming claimers can claim
function voter() external view returns (address);
/// @notice Initializes the vault with pool and factory addresses
/// @param _pool The address of the associated Algebra pool
/// @param _factory The address of the vault factory contract
function initialize(address _pool, address _factory) external;
/// @notice Withdraws tokens from the vault
/// @param to The address to receive the withdrawn tokens
/// @param token Array of token addresses to withdraw
/// @param amount Array of amounts to withdraw for each token
/// @dev Only callable by accounts with FACTORY_VAULT_MANAGER_ROLE on factory
function withdraw(address to, address[] calldata token, uint256[] calldata amount) external;
/// @notice Until this time a gauge claim moves nothing and the gauge share is held in the vault
/// @return The timestamp the hold ends at, zero for no hold
/// @dev Immutable in the implementation, a new date needs a new implementation behind the beacon
function holdUntil() external view returns (uint256);
/// @notice Amount of token0 held for the gauge, released by the first gauge claim from holdUntil on
/// @return The held amount of token0
function heldForGauge0() external view returns (uint256);
/// @notice Amount of token1 held for the gauge, released by the first gauge claim from holdUntil on
/// @return The held amount of token1
function heldForGauge1() external view returns (uint256);
/// @notice Pays the farming receivers their share of the balance above the held part and holds the rest for the gauge
/// @return held0_ Amount of token0 held for the gauge after the call
/// @return held1_ Amount of token1 held for the gauge after the call
/// @dev Only callable by accounts with GENESIS_SPLITTER_ROLE on factory before holdUntil. Does nothing outside farming mode
function splitAndHold() external returns (uint256 held0_, uint256 held1_);
/// @notice Distributes the accumulated fees to the gauge and the fee receivers
/// @return _claimed0 Amount of token0 distributed
/// @return _claimed1 Amount of token1 distributed
/// @dev Only callable by the gauge contract. Before holdUntil the gauge gets nothing, its first claim after takes the held part too
function claimFees() external returns (uint256 _claimed0, uint256 _claimed1);
/// @notice Error thrown when withdrawal amount exceeds available balance
error WithdrawAmountTooBig();
/// @notice Error thrown when a zero address is provided where a non-zero address is required
error ZeroAddress();
/// @notice Error thrown when caller is not the gauge
error MsgSenderNotGauge();
/// @notice Error thrown when fee basis is zero (misconfiguration)
error InvalidFeeBasis();
/// @notice Error thrown when caller does not have factory manager role
error NotFactoryManager();
/// @notice Error thrown when caller does not have non-farming vault claimer role
error NotNonFarmingVaultClaimer();
/// @notice Error thrown when caller does not have genesis splitter role
error NotGenesisSplitter();
/// @notice Error thrown when splitAndHold is called from holdUntil on
error HoldEnded();
/// @notice Emitted when fees are claimed and distributed
/// @param gauge The address of the gauge receiving fees
/// @param token0Amount Amount of token0 distributed
/// @param token1Amount Amount of token1 distributed
event FeesDistributed(address indexed gauge, uint256 token0Amount, uint256 token1Amount);
/// @notice Emitted when the farming receivers are paid and the gauge share is held
/// @param splitter The account that called splitAndHold
/// @param held0 Total token0 held for the gauge
/// @param held1 Total token1 held for the gauge
event FeesHeld(address indexed splitter, uint256 held0, uint256 held1);
}
contracts/interfaces/IGenesisSplitUpkeep.sol
// SPDX-License-Identifier: MIT
pragma solidity >=0.8.0;
/// @title Interface for the Genesis Split Upkeep
/// @notice Calls splitAndHold on a list of Algebra
/// @dev The implementation must hold GENESIS_SPLITTER_ROLE on the vault factory, the vaults check their caller
interface IGenesisSplitUpkeep {
/// @notice Role identifier for the genesis fee splitters, same id as in AlgebraVault
/// @return The role id
function GENESIS_SPLITTER_ROLE() external view returns (bytes32);
/// @notice The vault factory that holds the roles
/// @return The vault factory address
function factory() external view returns (address);
/// @notice Pays the farming receivers and holds the gauge share on every given vault
/// @param vaults The Algebra vaults to process
/// @dev Only callable by accounts with GENESIS_SPLITTER_ROLE on factory. One reverting vault reverts the whole call
function splitAndHoldUpkeep(address[] calldata vaults) external;
/// @notice Error thrown when a zero address is provided where a non-zero address is required
error ZeroAddress();
/// @notice Error thrown when caller does not have genesis splitter role
error NotGenesisSplitter();
}
Compiler settingsShow
{
"metadata": {
"bytecodeHash": "none"
},
"optimizer": {
"runs": 800,
"enabled": true
},
"evmVersion": "paris"
}Source code and metadata: Sourcify.
The source code belongs to the authors of the contract.