Source Code
Overview
ETH Balance
ETH Value
$0.00| Transaction Hash |
|
Block
|
From
|
To
|
|||||
|---|---|---|---|---|---|---|---|---|---|
Latest 25 internal transactions (View All)
Advanced mode:
| Parent Transaction Hash | Block | From | To | |||
|---|---|---|---|---|---|---|
| 21912859 | 172 days ago | 0 ETH | ||||
| 21912831 | 172 days ago | 0 ETH | ||||
| 21912803 | 172 days ago | 0 ETH | ||||
| 21912773 | 172 days ago | 0 ETH | ||||
| 21912714 | 172 days ago | 0 ETH | ||||
| 21912656 | 172 days ago | 0 ETH | ||||
| 21912625 | 172 days ago | 0 ETH | ||||
| 21912418 | 172 days ago | 0 ETH | ||||
| 21912393 | 172 days ago | 0 ETH | ||||
| 21912366 | 172 days ago | 0 ETH | ||||
| 21912335 | 172 days ago | 0 ETH | ||||
| 21912218 | 172 days ago | 0 ETH | ||||
| 21912185 | 172 days ago | 0 ETH | ||||
| 21912156 | 172 days ago | 0 ETH | ||||
| 21912013 | 172 days ago | 0 ETH | ||||
| 21911983 | 172 days ago | 0 ETH | ||||
| 21911896 | 172 days ago | 0 ETH | ||||
| 21911866 | 172 days ago | 0 ETH | ||||
| 21911837 | 172 days ago | 0 ETH | ||||
| 21911687 | 172 days ago | 0 ETH | ||||
| 21911657 | 172 days ago | 0 ETH | ||||
| 21911567 | 172 days ago | 0 ETH | ||||
| 21911537 | 172 days ago | 0 ETH | ||||
| 21911507 | 172 days ago | 0 ETH | ||||
| 21911417 | 172 days ago | 0 ETH |
Cross-Chain Transactions
Loading...
Loading
Contract Name:
AccessHub
Compiler Version
v0.8.28+commit.7893614a
Optimization Enabled:
Yes with 200 runs
Other Settings:
paris EvmVersion
Contract Source Code (Solidity Standard Json-Input format)
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.26;
import {IAccessHub} from "./interfaces/IAccessHub.sol";
import {AccessControlEnumerableUpgradeable} from
"@openzeppelin/contracts-upgradeable/access/extensions/AccessControlEnumerableUpgradeable.sol";
import {Initializable} from "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol";
import {IVoter} from "./interfaces/IVoter.sol";
import {IMinter} from "./interfaces/IMinter.sol";
import {IXRex} from "./interfaces/IXRex.sol";
import {IREX33} from "./interfaces/IREX33.sol";
import {IRamsesV3Factory} from "./CL/core/interfaces/IRamsesV3Factory.sol";
import {IPairFactory} from "./interfaces/IPairFactory.sol";
import {IFeeRecipientFactory} from "./interfaces/IFeeRecipientFactory.sol";
import {IRamsesV3Pool} from "./CL/core/interfaces/IRamsesV3Pool.sol";
import {IFeeCollector} from "./CL/gauge/interfaces/IFeeCollector.sol";
import {IVoteModule} from "./interfaces/IVoteModule.sol";
import {GaugeV3} from "./CL/gauge/GaugeV3.sol";
import {ClGaugeFactory} from "./CL/gauge/ClGaugeFactory.sol";
import {Errors} from "./libraries/Errors.sol";
import {ITransparentUpgradeableProxy} from "@openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.sol";
contract AccessHub is IAccessHub, Initializable, AccessControlEnumerableUpgradeable {
/**
* Start of Storage Slots
*/
/// @notice role that can call changing fee splits and swap fees
bytes32 public constant SWAP_FEE_SETTER = keccak256("SWAP_FEE_SETTER");
/// @notice operator role
bytes32 public constant PROTOCOL_OPERATOR = keccak256("PROTOCOL_OPERATOR");
/// @inheritdoc IAccessHub
address public timelock;
/// @inheritdoc IAccessHub
address public treasury;
/**
* "nice-to-have" addresses for quickly finding contracts within the system
*/
/// @inheritdoc IAccessHub
address public clGaugeFactory;
/// @inheritdoc IAccessHub
address public gaugeFactory;
/// @inheritdoc IAccessHub
address public feeDistributorFactory;
/**
* core contracts
*/
/// @notice central voter contract
IVoter public voter;
/// @notice weekly emissions minter
IMinter public minter;
/// @notice xRam contract
IXRex public xRam;
/// @notice R33 contract
IREX33 public r33;
/// @notice CL V3 factory
IRamsesV3Factory public ramsesV3PoolFactory;
/// @notice legacy pair factory
IPairFactory public poolFactory;
/// @notice legacy fees holder contract
IFeeRecipientFactory public feeRecipientFactory;
/// @notice fee collector contract
IFeeCollector public feeCollector;
/// @notice voteModule contract
IVoteModule public voteModule;
/**
* End of Storage Slots
*/
modifier timelocked() {
require(msg.sender == timelock, NOT_TIMELOCK(msg.sender));
_;
}
modifier onlyMultisig() {
require(msg.sender == treasury, Errors.NOT_AUTHORIZED(msg.sender));
_;
}
constructor() {
_disableInitializers();
}
/// @inheritdoc IAccessHub
function initialize(InitParams calldata params) external initializer {
/// @dev initialize all external interfaces
timelock = params.timelock;
treasury = params.treasury;
voter = IVoter(params.voter);
minter = IMinter(params.minter);
xRam = IXRex(params.xRam);
r33 = IREX33(params.r33);
ramsesV3PoolFactory = IRamsesV3Factory(params.ramsesV3PoolFactory);
poolFactory = IPairFactory(params.poolFactory);
feeRecipientFactory = IFeeRecipientFactory(params.feeRecipientFactory);
feeCollector = IFeeCollector(params.feeCollector);
voteModule = IVoteModule(params.voteModule);
/// @dev reference addresses
clGaugeFactory = params.clGaugeFactory;
gaugeFactory = params.gaugeFactory;
feeDistributorFactory = params.feeDistributorFactory;
/// @dev fee setter role given to treasury
_grantRole(SWAP_FEE_SETTER, params.treasury);
/// @dev operator role given to treasury
_grantRole(PROTOCOL_OPERATOR, params.treasury);
/// @dev initially give admin role to treasury
_grantRole(DEFAULT_ADMIN_ROLE, params.treasury);
/// @dev give timelock the admin role
_grantRole(DEFAULT_ADMIN_ROLE, params.timelock);
}
function reinit(InitParams calldata params) external onlyMultisig {
voter = IVoter(params.voter);
minter = IMinter(params.minter);
xRam = IXRex(params.xRam);
r33 = IREX33(params.r33);
ramsesV3PoolFactory = IRamsesV3Factory(params.ramsesV3PoolFactory);
poolFactory = IPairFactory(params.poolFactory);
feeRecipientFactory = IFeeRecipientFactory(params.feeRecipientFactory);
feeCollector = IFeeCollector(params.feeCollector);
voteModule = IVoteModule(params.voteModule);
/// @dev reference addresses
clGaugeFactory = params.clGaugeFactory;
gaugeFactory = params.gaugeFactory;
feeDistributorFactory = params.feeDistributorFactory;
}
/// @inheritdoc IAccessHub
function initializeVoter(
IVoter.InitializationParams memory inputs
) external onlyMultisig {
voter.initialize(
inputs
);
}
/**
* Fee Setting Logic
*/
/// @inheritdoc IAccessHub
function setSwapFees(address[] calldata _pools, uint24[] calldata _swapFees) external onlyRole(SWAP_FEE_SETTER) {
/// @dev ensure continuity of length
require(_pools.length == _swapFees.length, Errors.LENGTH_MISMATCH());
for (uint256 i; i < _pools.length; ++i) {
/// @dev we check if the pool is v3 or legacy and set their fees accordingly
if (ramsesV3PoolFactory.isPairV3(_pools[i])) {
ramsesV3PoolFactory.setFee(_pools[i], _swapFees[i]);
} else if (poolFactory.isPair(_pools[i])) {
poolFactory.setPairFee(_pools[i], _swapFees[i]);
}
}
}
/// @inheritdoc IAccessHub
function setFeeSplitCL(address[] calldata _pools, uint24[] calldata _feeProtocol)
external
{
/// @dev allow either SWAP_FEE_SETTER role holders OR the voter contract
require(
hasRole(SWAP_FEE_SETTER, msg.sender) || msg.sender == address(voter),
Errors.NOT_AUTHORIZED(msg.sender)
);
/// @dev ensure continuity of length
require(_pools.length == _feeProtocol.length, Errors.LENGTH_MISMATCH());
for (uint256 i; i < _pools.length; ++i) {
ramsesV3PoolFactory.setPoolFeeProtocol(_pools[i], _feeProtocol[i]);
}
}
/// @inheritdoc IAccessHub
function setFeeSplitLegacy(address[] calldata _pools, uint256[] calldata _feeSplits)
external
{
/// @dev allow either SWAP_FEE_SETTER role holders OR the voter contract
require(
hasRole(SWAP_FEE_SETTER, msg.sender) || msg.sender == address(voter),
Errors.NOT_AUTHORIZED(msg.sender)
);
/// @dev ensure continuity of length
require(_pools.length == _feeSplits.length, Errors.LENGTH_MISMATCH());
for (uint256 i; i < _pools.length; ++i) {
poolFactory.setPairFeeSplit(_pools[i], _feeSplits[i]);
}
}
/// @notice sets the fee recipient for legacy pairs
function setFeeRecipientLegacyBatched(address[] calldata _pairs, address[] calldata _feeRecipients) external onlyMultisig {
require(_pairs.length == _feeRecipients.length, Errors.LENGTH_MISMATCH());
for (uint256 i; i < _pairs.length; ++i) {
poolFactory.setFeeRecipient(_pairs[i], _feeRecipients[i]);
}
}
/**
* Voter governance
*/
/// @inheritdoc IAccessHub
function setNewGovernorInVoter(address _newGovernor) external onlyRole(PROTOCOL_OPERATOR) {
/// @dev no checks are needed as the voter handles this already
voter.setGovernor(_newGovernor);
}
/// @inheritdoc IAccessHub
function governanceWhitelist(address[] calldata _token, bool[] calldata _whitelisted)
external
onlyRole(PROTOCOL_OPERATOR)
{
/// @dev ensure continuity of length
require(_token.length == _whitelisted.length, Errors.LENGTH_MISMATCH());
for (uint256 i; i < _token.length; ++i) {
/// @dev if adding to the whitelist
if (_whitelisted[i]) {
/// @dev call the voter's whitelist function
voter.whitelist(_token[i]);
}
/// @dev remove the token's whitelist
else {
voter.revokeWhitelist(_token[i]);
}
}
}
/// @inheritdoc IAccessHub
function killGauge(address[] calldata _pairs) external onlyRole(PROTOCOL_OPERATOR) {
for (uint256 i; i < _pairs.length; ++i) {
/// @dev store pair
address pair = _pairs[i];
/// @dev collect fees from the pair
feeCollector.collectProtocolFees(pair);
/// @dev kill the gauge
voter.killGauge(voter.gaugeForPool(pair));
/// @dev set the new fees in the pair to 95/5
ramsesV3PoolFactory.setPoolFeeProtocol(pair, 5);
}
}
/// @inheritdoc IAccessHub
function reviveGauge(address[] calldata _pairs) external onlyRole(PROTOCOL_OPERATOR) {
for (uint256 i; i < _pairs.length; ++i) {
address pair = _pairs[i];
/// @dev collect fees from the pair
feeCollector.collectProtocolFees(pair);
/// @dev revive the pair
voter.reviveGauge(voter.gaugeForPool(pair));
/// @dev set fee to the factory default
ramsesV3PoolFactory.setPoolFeeProtocol(pair, ramsesV3PoolFactory.feeProtocol());
}
}
/// @inheritdoc IAccessHub
function setEmissionsRatioInVoter(uint256 _pct) external onlyRole(PROTOCOL_OPERATOR) {
voter.setGlobalRatio(_pct);
}
/// @inheritdoc IAccessHub
function retrieveStuckEmissionsToGovernance(address _gauge, uint256 _period) external onlyRole(PROTOCOL_OPERATOR) {
voter.stuckEmissionsRecovery(_gauge, _period);
}
/// @notice Set the minimum time threshold for rewarder (in seconds)
/// @param _timeThreshold New time threshold in seconds (0 = no threshold)
function setTimeThresholdForRewarder(uint256 _timeThreshold) external onlyRole(PROTOCOL_OPERATOR) {
voter.setTimeThresholdForRewarder(_timeThreshold);
}
/// @inheritdoc IAccessHub
function createLegacyGauge(address _pool) external onlyRole(PROTOCOL_OPERATOR) returns (address) {
return voter.createGauge(_pool);
}
/// @inheritdoc IAccessHub
function createCLGauge(address tokenA, address tokenB, int24 tickSpacing)
external
onlyRole(PROTOCOL_OPERATOR)
returns (address)
{
return voter.createCLGauge(tokenA, tokenB, tickSpacing);
}
/**
* xRam Functions
*/
function setFeeCollectorAccessHub(address _feeCollector) external onlyMultisig {
feeCollector = IFeeCollector(_feeCollector);
}
function setFeeCollectorInClGaugeFactory(address _feeCollector) external onlyMultisig {
ClGaugeFactory(clGaugeFactory).setFeeCollector(_feeCollector);
}
/// @inheritdoc IAccessHub
function transferWhitelistInXRam(address[] calldata _who, bool[] calldata _whitelisted)
external
onlyRole(PROTOCOL_OPERATOR)
{
/// @dev ensure continuity of length
require(_who.length == _whitelisted.length, Errors.LENGTH_MISMATCH());
xRam.setExemption(_who, _whitelisted);
}
/// @inheritdoc IAccessHub
function toggleXRamGovernance(bool enable) external onlyRole(PROTOCOL_OPERATOR) {
/// @dev if enabled we call unpause otherwise we pause to disable
enable ? xRam.unpause() : xRam.pause();
}
/// @inheritdoc IAccessHub
function operatorRedeemXRam(uint256 _amount) external onlyRole(PROTOCOL_OPERATOR) {
xRam.operatorRedeem(_amount);
}
/// @inheritdoc IAccessHub
function migrateOperator(address _operator) external onlyRole(PROTOCOL_OPERATOR) {
xRam.migrateOperator(_operator);
}
/// @inheritdoc IAccessHub
function rescueTrappedTokens(address[] calldata _tokens, uint256[] calldata _amounts)
external
onlyRole(PROTOCOL_OPERATOR)
{
xRam.rescueTrappedTokens(_tokens, _amounts);
}
/**
* X33 Functions
*/
/// @inheritdoc IAccessHub
function transferOperatorInR33(address _newOperator) external onlyRole(PROTOCOL_OPERATOR) {
r33.transferOperator(_newOperator);
}
/**
* Minter Functions
*/
/// @inheritdoc IAccessHub
function setEmissionsMultiplierInMinter(uint256 _multiplier) external onlyRole(PROTOCOL_OPERATOR) {
minter.updateEmissionsMultiplier(_multiplier);
}
/**
* Reward List Functions
*/
/// @inheritdoc IAccessHub
function augmentGaugeRewardsForPair(
address[] calldata _pools,
address[] calldata _rewards,
bool[] calldata _addReward
) external onlyRole(PROTOCOL_OPERATOR) {
/// @dev length continuity check
require(_pools.length == _rewards.length && _rewards.length == _addReward.length, Errors.LENGTH_MISMATCH());
/// @dev loop through all entries
for (uint256 i; i < _pools.length; ++i) {
/// @dev fetch the gauge address
address gauge = voter.gaugeForPool(_pools[i]);
/// @dev if true (add rewards)
if (_addReward[i]) {
// voter.whitelistGaugeRewards(gauge, _rewards[i]); //TODO do we remove this?
}
/// @dev if false remove the rewards
else {
// voter.removeGaugeRewardWhitelist(gauge, _rewards[i]); //TODO do we remove this?
}
}
}
/// @inheritdoc IAccessHub
function removeFeeDistributorRewards(address[] calldata _pools, address[] calldata _rewards)
external
onlyRole(PROTOCOL_OPERATOR)
{
require(_pools.length == _rewards.length, Errors.LENGTH_MISMATCH());
for (uint256 i; i < _pools.length; ++i) {
voter.removeFeeDistributorReward(voter.feeDistributorForGauge(voter.gaugeForPool(_pools[i])), _rewards[i]);
}
}
/**
* FeeCollector functions
*/
/// @inheritdoc IAccessHub
function setTreasuryInFeeCollector(address newTreasury) external onlyRole(PROTOCOL_OPERATOR) {
feeCollector.setTreasury(newTreasury);
}
/// @inheritdoc IAccessHub
function setTreasuryFeesInFeeCollector(uint256 _treasuryFees) external onlyRole(PROTOCOL_OPERATOR) {
feeCollector.setTreasuryFees(_treasuryFees);
}
/**
* FeeRecipientFactory functions
*/
/// @inheritdoc IAccessHub
function setFeeToTreasuryInFeeRecipientFactory(uint256 _feeToTreasury) external onlyRole(PROTOCOL_OPERATOR) {
feeRecipientFactory.setFeeToTreasury(_feeToTreasury);
}
/// @inheritdoc IAccessHub
function setTreasuryInFeeRecipientFactory(address _treasury) external onlyRole(PROTOCOL_OPERATOR) {
feeRecipientFactory.setTreasury(_treasury);
}
/**
* CL Pool Factory functions
*/
/// @inheritdoc IAccessHub
function enableTickSpacing(int24 tickSpacing, uint24 initialFee) external onlyRole(PROTOCOL_OPERATOR) {
ramsesV3PoolFactory.enableTickSpacing(tickSpacing, initialFee);
}
/// @inheritdoc IAccessHub
function setGlobalClFeeProtocol(uint24 _feeProtocolGlobal) external onlyRole(PROTOCOL_OPERATOR) {
ramsesV3PoolFactory.setFeeProtocol(_feeProtocolGlobal);
}
/// @inheritdoc IAccessHub
/// @notice sets the address of the voter in the v3 factory for gauge fee setting
function setVoterAddressInFactoryV3(address _voter) external onlyMultisig {
ramsesV3PoolFactory.setVoter(_voter);
}
/// @inheritdoc IAccessHub
/// @notice sets the address of the voter in the fee recipient factory for fee recipient creation
function setVoterInFeeRecipientFactory(address _voter) external onlyMultisig {
feeRecipientFactory.setVoter(_voter);
}
/// @inheritdoc IAccessHub
function setFeeCollectorInFactoryV3(address _newFeeCollector) external onlyMultisig {
ramsesV3PoolFactory.setFeeCollector(_newFeeCollector);
}
/// @notice Update FeeDistributor for a gauge (emergency governance function)
function updateFeeDistributorForGauge(address _gauge, address _newFeeDistributor) external onlyMultisig {
voter.updateFeeDistributorForGauge(_gauge, _newFeeDistributor);
}
/// @notice Create a new FeeDistributor with specified feeRecipient (emergency governance function)
function createFeeDistributorWithRecipient(address _feeRecipient) external onlyMultisig returns (address) {
return voter.createFeeDistributorWithRecipient(_feeRecipient);
}
/**
* Legacy Pool Factory functions
*/
/// @inheritdoc IAccessHub
function setTreasuryInLegacyFactory(address _treasury) external onlyMultisig {
poolFactory.setTreasury(_treasury);
}
/// @inheritdoc IAccessHub
function setVoterInLegacyFactory(address _voter) external onlyMultisig {
IPairFactory(poolFactory).setVoter(_voter);
}
/// @inheritdoc IAccessHub
function setFeeSplitWhenNoGauge(bool status) external onlyRole(PROTOCOL_OPERATOR) {
poolFactory.setFeeSplitWhenNoGauge(status);
}
/// @inheritdoc IAccessHub
function setLegacyFeeSplitGlobal(uint256 _feeSplit) external onlyRole(PROTOCOL_OPERATOR) {
poolFactory.setFeeSplit(_feeSplit);
}
/// @inheritdoc IAccessHub
function setLegacyFeeGlobal(uint256 _fee) external onlyRole(PROTOCOL_OPERATOR) {
poolFactory.setFee(_fee);
}
/// @inheritdoc IAccessHub
function setSkimEnabledLegacy(address _pair, bool _status) external onlyRole(PROTOCOL_OPERATOR) {
poolFactory.setSkimEnabled(_pair, _status);
}
/**
* VoteModule Functions
*/
/// @inheritdoc IAccessHub
function setCooldownExemption(address[] calldata _candidates, bool[] calldata _exempt) external timelocked {
for (uint256 i; i < _candidates.length; ++i) {
voteModule.setCooldownExemption(_candidates[i], _exempt[i]);
}
}
/// @inheritdoc IAccessHub
function setNewRebaseStreamingDuration(uint256 _newDuration) external timelocked {
// voteModule.setNewDuration(_newDuration); //TODO do we remove this?
}
/// @inheritdoc IAccessHub
function setNewVoteModuleCooldown(uint256 _newCooldown) external timelocked {
voteModule.setNewCooldown(_newCooldown);
}
/**
* Timelock specific functions
*/
/// @inheritdoc IAccessHub
function execute(address _target, bytes calldata _payload) external timelocked {
(bool success,) = _target.call(_payload);
require(success, MANUAL_EXECUTION_FAILURE(_payload));
}
/// @inheritdoc IAccessHub
function setNewTimelock(address _timelock) external timelocked {
require(timelock != _timelock, SAME_ADDRESS());
timelock = _timelock;
}
function reinitializeV3Gauge(
address _gauge,
address _voter,
address _nfpManager,
address _feeCollector,
address _pool
) public onlyMultisig {
GaugeV3(_gauge).initializeV2(_voter, _nfpManager, _feeCollector, _pool);
}
function setV3FactoryImplementation(address _newImplementation) public onlyMultisig {
ClGaugeFactory(clGaugeFactory).setImplementation(_newImplementation);
}
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.26;
import {IVoteModule} from "contracts/interfaces/IVoteModule.sol";
import {IVoter} from "contracts/interfaces/IVoter.sol";
import {IFeeRecipientFactory} from "contracts/interfaces/IFeeRecipientFactory.sol";
import {IMinter} from "contracts/interfaces/IMinter.sol";
import {IXRex} from "contracts/interfaces/IXRex.sol";
import {IREX33} from "contracts/interfaces/IREX33.sol";
import {IRamsesV3Factory} from "contracts/CL/core/interfaces/IRamsesV3Factory.sol";
import {IPairFactory} from "contracts/interfaces/IPairFactory.sol";
import {IFeeCollector} from "contracts/CL/gauge/interfaces/IFeeCollector.sol";
interface IAccessHub {
error SAME_ADDRESS();
error NOT_TIMELOCK(address);
error MANUAL_EXECUTION_FAILURE(bytes);
error KICK_FORBIDDEN(address);
/// @dev Struct to hold initialization parameters
struct InitParams {
address timelock;
address treasury;
address voter;
address minter;
address xRam;
address r33;
address ramsesV3PoolFactory;
address poolFactory;
address clGaugeFactory;
address gaugeFactory;
address feeRecipientFactory;
address feeDistributorFactory;
address feeCollector;
address voteModule;
}
/// @notice protocol timelock address
function timelock() external view returns (address timelock);
/// @notice protocol treasury address
function treasury() external view returns (address treasury);
/// @notice vote module
function voteModule() external view returns (IVoteModule voteModule);
/// @notice voter
function voter() external view returns (IVoter voter);
/// @notice weekly emissions minter
function minter() external view returns (IMinter minter);
/// @notice xRam contract
function xRam() external view returns (IXRex xRam);
/// @notice R33 contract
function r33() external view returns (IREX33 r33);
/// @notice CL V3 factory
function ramsesV3PoolFactory() external view returns (IRamsesV3Factory ramsesV3PoolFactory);
/// @notice legacy pair factory
function poolFactory() external view returns (IPairFactory poolFactory);
/// @notice fee collector contract
function feeCollector() external view returns (IFeeCollector feeCollector);
/// @notice concentrated (v3) gauge factory
function clGaugeFactory() external view returns (address _clGaugeFactory);
/// @notice legacy gauge factory address
function gaugeFactory() external view returns (address _gaugeFactory);
/// @notice the feeDistributor factory address
function feeDistributorFactory() external view returns (address _feeDistributorFactory);
/// @notice fee recipient factory
function feeRecipientFactory() external view returns (IFeeRecipientFactory _feeRecipientFactory);
/// @notice initializing function for setting values in the AccessHub
function initialize(InitParams calldata params) external;
/// @notice re-initializing function for updating values in the AccessHub
function reinit(InitParams calldata params) external;
/// @notice sets the swap fees for multiple pairs
function setSwapFees(address[] calldata _pools, uint24[] calldata _swapFees)
external;
/// @notice sets the split of fees between LPs and voters
function setFeeSplitCL(address[] calldata _pools, uint24[] calldata _feeProtocol) external;
/// @notice sets the split of fees between LPs and voters for legacy pools
function setFeeSplitLegacy(address[] calldata _pools, uint256[] calldata _feeSplits) external;
/**
* Voter governance
*/
/// @notice sets a new governor address in the voter.sol contract
function setNewGovernorInVoter(address _newGovernor) external;
/// @notice whitelists a token for governance, or removes if boolean is set to false
function governanceWhitelist(address[] calldata _token, bool[] calldata _whitelisted) external;
/// @notice kills active gauges, removing them from earning further emissions, and claims their fees prior
function killGauge(address[] calldata _pairs) external;
/// @notice revives inactive/killed gauges
function reviveGauge(address[] calldata _pairs) external;
/// @notice sets the ratio of xRam/Ramses awarded globally to LPs
function setEmissionsRatioInVoter(uint256 _pct) external;
/// @notice allows governance to retrieve emissions in the voter contract that will not be distributed due to the gauge being inactive
/// @dev allows per-period retrieval for granularity
function retrieveStuckEmissionsToGovernance(address _gauge, uint256 _period) external;
/// @notice sets the minimum time threshold for rewarder (in seconds)
function setTimeThresholdForRewarder(uint256 _timeThreshold) external;
/// @notice creates a new gauge for a legacy pool
function createLegacyGauge(address _pool) external returns (address);
/// @notice creates a new concentrated liquidity gauge for a CL pool
function createCLGauge(address tokenA, address tokenB, int24 tickSpacing) external returns (address);
/**
* xRam Functions
*/
/// @notice enables or disables the transfer whitelist in xRam
function transferWhitelistInXRam(address[] calldata _who, bool[] calldata _whitelisted) external;
/// @notice enables or disables the governance in xRam
function toggleXRamGovernance(bool enable) external;
/// @notice allows redemption from the operator
function operatorRedeemXRam(uint256 _amount) external;
/// @notice migrates the xRam operator
function migrateOperator(address _operator) external;
/// @notice rescues any trapped tokens in xRam
function rescueTrappedTokens(address[] calldata _tokens, uint256[] calldata _amounts) external;
/**
* X33 Functions
*/
/// @notice transfers the r33 operator address
function transferOperatorInR33(address _newOperator) external;
/**
* Minter Functions
*/
/// @notice sets the inflation multiplier
/// @param _multiplier the multiplier
function setEmissionsMultiplierInMinter(uint256 _multiplier) external;
/**
* Reward List Functions
*/
/// @notice function for adding or removing rewards for pools
function augmentGaugeRewardsForPair(
address[] calldata _pools,
address[] calldata _rewards,
bool[] calldata _addReward
) external;
/// @notice function for removing rewards for feeDistributors
function removeFeeDistributorRewards(address[] calldata _pools, address[] calldata _rewards) external;
/**
* FeeCollector functions
*/
/// @notice Sets the treasury address to a new value.
/// @param newTreasury The new address to set as the treasury.
function setTreasuryInFeeCollector(address newTreasury) external;
/// @notice Sets the value of treasury fees to a new amount.
/// @param _treasuryFees The new amount of treasury fees to be set.
function setTreasuryFeesInFeeCollector(uint256 _treasuryFees) external;
/**
* FeeRecipientFactory functions
*/
/// @notice set the fee % to be sent to the treasury
/// @param _feeToTreasury the fee % to be sent to the treasury
function setFeeToTreasuryInFeeRecipientFactory(uint256 _feeToTreasury) external;
/// @notice set a new treasury address
/// @param _treasury the new address
function setTreasuryInFeeRecipientFactory(address _treasury) external;
/**
* CL Pool Factory functions
*/
/// @notice enables a tickSpacing with the given initialFee amount
/// @dev unlike UniswapV3, we map via the tickSpacing rather than the fee tier
/// @dev tickSpacings may never be removed once enabled
/// @param tickSpacing The spacing between ticks to be enforced for all pools created
/// @param initialFee The initial fee amount, denominated in hundredths of a bip (i.e. 1e-6)
function enableTickSpacing(int24 tickSpacing, uint24 initialFee) external;
/// @notice sets the feeProtocol (feeSplit) for new CL pools and stored in the factory
function setGlobalClFeeProtocol(uint24 _feeProtocolGlobal) external;
/// @notice sets the address of the voter in the v3 factory for gauge fee setting
function setVoterAddressInFactoryV3(address _voter) external;
/// @notice sets the address of the feeCollector in the v3 factory for fee routing
function setFeeCollectorInFactoryV3(address _newFeeCollector) external;
/**
* Legacy Pool Factory functions
*/
/// @notice sets the treasury address in the legacy factory
function setTreasuryInLegacyFactory(address _treasury) external;
/// @notice sets the voter address in the legacy factory
function setVoterInLegacyFactory(address _voter) external;
/// @notice enables or disables if there is a feeSplit when no gauge for legacy pairs
function setFeeSplitWhenNoGauge(bool status) external;
/// @notice set the default feeSplit in the legacy factory
function setLegacyFeeSplitGlobal(uint256 _feeSplit) external;
/// @notice set the default swap fee for legacy pools
function setLegacyFeeGlobal(uint256 _fee) external;
/// @notice sets whether a pair can have skim() called or not for rebasing purposes
function setSkimEnabledLegacy(address _pair, bool _status) external;
/**
* VoteModule Functions
*/
/// @notice sets addresses as exempt or removes their exemption
function setCooldownExemption(address[] calldata _candidates, bool[] calldata _exempt) external;
/// @notice function to alter the duration that rebases are streamed in the voteModule
function setNewRebaseStreamingDuration(uint256 _newDuration) external;
/// @notice function to change the cooldown in the voteModule
function setNewVoteModuleCooldown(uint256 _newCooldown) external;
/// @notice sets the address of the voter in the fee recipient factory for fee recipient creation
function setVoterInFeeRecipientFactory(address _voter) external;
/**
* Timelock gated functions
*/
/// @notice timelock gated payload execution in case tokens get stuck or other unexpected behaviors
function execute(address _target, bytes calldata _payload) external;
/// @notice timelock gated function to change the timelock
function setNewTimelock(address _timelock) external;
/// @notice function for initializing the voter contract with its dependencies
function initializeVoter(
IVoter.InitializationParams memory inputs
) external;
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.1.0) (access/extensions/AccessControlEnumerable.sol)
pragma solidity ^0.8.20;
import {IAccessControlEnumerable} from "@openzeppelin/contracts/access/extensions/IAccessControlEnumerable.sol";
import {AccessControlUpgradeable} from "../AccessControlUpgradeable.sol";
import {EnumerableSet} from "@openzeppelin/contracts/utils/structs/EnumerableSet.sol";
import {Initializable} from "../../proxy/utils/Initializable.sol";
/**
* @dev Extension of {AccessControl} that allows enumerating the members of each role.
*/
abstract contract AccessControlEnumerableUpgradeable is Initializable, IAccessControlEnumerable, AccessControlUpgradeable {
using EnumerableSet for EnumerableSet.AddressSet;
/// @custom:storage-location erc7201:openzeppelin.storage.AccessControlEnumerable
struct AccessControlEnumerableStorage {
mapping(bytes32 role => EnumerableSet.AddressSet) _roleMembers;
}
// keccak256(abi.encode(uint256(keccak256("openzeppelin.storage.AccessControlEnumerable")) - 1)) & ~bytes32(uint256(0xff))
bytes32 private constant AccessControlEnumerableStorageLocation = 0xc1f6fe24621ce81ec5827caf0253cadb74709b061630e6b55e82371705932000;
function _getAccessControlEnumerableStorage() private pure returns (AccessControlEnumerableStorage storage $) {
assembly {
$.slot := AccessControlEnumerableStorageLocation
}
}
function __AccessControlEnumerable_init() internal onlyInitializing {
}
function __AccessControlEnumerable_init_unchained() internal onlyInitializing {
}
/**
* @dev See {IERC165-supportsInterface}.
*/
function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
return interfaceId == type(IAccessControlEnumerable).interfaceId || super.supportsInterface(interfaceId);
}
/**
* @dev Returns one of the accounts that have `role`. `index` must be a
* value between 0 and {getRoleMemberCount}, non-inclusive.
*
* Role bearers are not sorted in any particular way, and their ordering may
* change at any point.
*
* WARNING: When using {getRoleMember} and {getRoleMemberCount}, make sure
* you perform all queries on the same block. See the following
* https://forum.openzeppelin.com/t/iterating-over-elements-on-enumerableset-in-openzeppelin-contracts/2296[forum post]
* for more information.
*/
function getRoleMember(bytes32 role, uint256 index) public view virtual returns (address) {
AccessControlEnumerableStorage storage $ = _getAccessControlEnumerableStorage();
return $._roleMembers[role].at(index);
}
/**
* @dev Returns the number of accounts that have `role`. Can be used
* together with {getRoleMember} to enumerate all bearers of a role.
*/
function getRoleMemberCount(bytes32 role) public view virtual returns (uint256) {
AccessControlEnumerableStorage storage $ = _getAccessControlEnumerableStorage();
return $._roleMembers[role].length();
}
/**
* @dev Return all accounts that have `role`
*
* WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed
* to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that
* this function has an unbounded cost, and using it as part of a state-changing function may render the function
* uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.
*/
function getRoleMembers(bytes32 role) public view virtual returns (address[] memory) {
AccessControlEnumerableStorage storage $ = _getAccessControlEnumerableStorage();
return $._roleMembers[role].values();
}
/**
* @dev Overload {AccessControl-_grantRole} to track enumerable memberships
*/
function _grantRole(bytes32 role, address account) internal virtual override returns (bool) {
AccessControlEnumerableStorage storage $ = _getAccessControlEnumerableStorage();
bool granted = super._grantRole(role, account);
if (granted) {
$._roleMembers[role].add(account);
}
return granted;
}
/**
* @dev Overload {AccessControl-_revokeRole} to track enumerable memberships
*/
function _revokeRole(bytes32 role, address account) internal virtual override returns (bool) {
AccessControlEnumerableStorage storage $ = _getAccessControlEnumerableStorage();
bool revoked = super._revokeRole(role, account);
if (revoked) {
$._roleMembers[role].remove(account);
}
return revoked;
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (proxy/utils/Initializable.sol)
pragma solidity ^0.8.20;
/**
* @dev This is a base contract to aid in writing upgradeable contracts, or any kind of contract that will be deployed
* behind a proxy. Since proxied contracts do not make use of a constructor, it's common to move constructor logic to an
* external initializer function, usually called `initialize`. It then becomes necessary to protect this initializer
* function so it can only be called once. The {initializer} modifier provided by this contract will have this effect.
*
* The initialization functions use a version number. Once a version number is used, it is consumed and cannot be
* reused. This mechanism prevents re-execution of each "step" but allows the creation of new initialization steps in
* case an upgrade adds a module that needs to be initialized.
*
* For example:
*
* [.hljs-theme-light.nopadding]
* ```solidity
* contract MyToken is ERC20Upgradeable {
* function initialize() initializer public {
* __ERC20_init("MyToken", "MTK");
* }
* }
*
* contract MyTokenV2 is MyToken, ERC20PermitUpgradeable {
* function initializeV2() reinitializer(2) public {
* __ERC20Permit_init("MyToken");
* }
* }
* ```
*
* TIP: To avoid leaving the proxy in an uninitialized state, the initializer function should be called as early as
* possible by providing the encoded function call as the `_data` argument to {ERC1967Proxy-constructor}.
*
* CAUTION: When used with inheritance, manual care must be taken to not invoke a parent initializer twice, or to ensure
* that all initializers are idempotent. This is not verified automatically as constructors are by Solidity.
*
* [CAUTION]
* ====
* Avoid leaving a contract uninitialized.
*
* An uninitialized contract can be taken over by an attacker. This applies to both a proxy and its implementation
* contract, which may impact the proxy. To prevent the implementation contract from being used, you should invoke
* the {_disableInitializers} function in the constructor to automatically lock it when it is deployed:
*
* [.hljs-theme-light.nopadding]
* ```
* /// @custom:oz-upgrades-unsafe-allow constructor
* constructor() {
* _disableInitializers();
* }
* ```
* ====
*/
abstract contract Initializable {
/**
* @dev Storage of the initializable contract.
*
* It's implemented on a custom ERC-7201 namespace to reduce the risk of storage collisions
* when using with upgradeable contracts.
*
* @custom:storage-location erc7201:openzeppelin.storage.Initializable
*/
struct InitializableStorage {
/**
* @dev Indicates that the contract has been initialized.
*/
uint64 _initialized;
/**
* @dev Indicates that the contract is in the process of being initialized.
*/
bool _initializing;
}
// keccak256(abi.encode(uint256(keccak256("openzeppelin.storage.Initializable")) - 1)) & ~bytes32(uint256(0xff))
bytes32 private constant INITIALIZABLE_STORAGE = 0xf0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a00;
/**
* @dev The contract is already initialized.
*/
error InvalidInitialization();
/**
* @dev The contract is not initializing.
*/
error NotInitializing();
/**
* @dev Triggered when the contract has been initialized or reinitialized.
*/
event Initialized(uint64 version);
/**
* @dev A modifier that defines a protected initializer function that can be invoked at most once. In its scope,
* `onlyInitializing` functions can be used to initialize parent contracts.
*
* Similar to `reinitializer(1)`, except that in the context of a constructor an `initializer` may be invoked any
* number of times. This behavior in the constructor can be useful during testing and is not expected to be used in
* production.
*
* Emits an {Initialized} event.
*/
modifier initializer() {
// solhint-disable-next-line var-name-mixedcase
InitializableStorage storage $ = _getInitializableStorage();
// Cache values to avoid duplicated sloads
bool isTopLevelCall = !$._initializing;
uint64 initialized = $._initialized;
// Allowed calls:
// - initialSetup: the contract is not in the initializing state and no previous version was
// initialized
// - construction: the contract is initialized at version 1 (no reininitialization) and the
// current contract is just being deployed
bool initialSetup = initialized == 0 && isTopLevelCall;
bool construction = initialized == 1 && address(this).code.length == 0;
if (!initialSetup && !construction) {
revert InvalidInitialization();
}
$._initialized = 1;
if (isTopLevelCall) {
$._initializing = true;
}
_;
if (isTopLevelCall) {
$._initializing = false;
emit Initialized(1);
}
}
/**
* @dev A modifier that defines a protected reinitializer function that can be invoked at most once, and only if the
* contract hasn't been initialized to a greater version before. In its scope, `onlyInitializing` functions can be
* used to initialize parent contracts.
*
* A reinitializer may be used after the original initialization step. This is essential to configure modules that
* are added through upgrades and that require initialization.
*
* When `version` is 1, this modifier is similar to `initializer`, except that functions marked with `reinitializer`
* cannot be nested. If one is invoked in the context of another, execution will revert.
*
* Note that versions can jump in increments greater than 1; this implies that if multiple reinitializers coexist in
* a contract, executing them in the right order is up to the developer or operator.
*
* WARNING: Setting the version to 2**64 - 1 will prevent any future reinitialization.
*
* Emits an {Initialized} event.
*/
modifier reinitializer(uint64 version) {
// solhint-disable-next-line var-name-mixedcase
InitializableStorage storage $ = _getInitializableStorage();
if ($._initializing || $._initialized >= version) {
revert InvalidInitialization();
}
$._initialized = version;
$._initializing = true;
_;
$._initializing = false;
emit Initialized(version);
}
/**
* @dev Modifier to protect an initialization function so that it can only be invoked by functions with the
* {initializer} and {reinitializer} modifiers, directly or indirectly.
*/
modifier onlyInitializing() {
_checkInitializing();
_;
}
/**
* @dev Reverts if the contract is not in an initializing state. See {onlyInitializing}.
*/
function _checkInitializing() internal view virtual {
if (!_isInitializing()) {
revert NotInitializing();
}
}
/**
* @dev Locks the contract, preventing any future reinitialization. This cannot be part of an initializer call.
* Calling this in the constructor of a contract will prevent that contract from being initialized or reinitialized
* to any version. It is recommended to use this to lock implementation contracts that are designed to be called
* through proxies.
*
* Emits an {Initialized} event the first time it is successfully executed.
*/
function _disableInitializers() internal virtual {
// solhint-disable-next-line var-name-mixedcase
InitializableStorage storage $ = _getInitializableStorage();
if ($._initializing) {
revert InvalidInitialization();
}
if ($._initialized != type(uint64).max) {
$._initialized = type(uint64).max;
emit Initialized(type(uint64).max);
}
}
/**
* @dev Returns the highest version that has been initialized. See {reinitializer}.
*/
function _getInitializedVersion() internal view returns (uint64) {
return _getInitializableStorage()._initialized;
}
/**
* @dev Returns `true` if the contract is currently initializing. See {onlyInitializing}.
*/
function _isInitializing() internal view returns (bool) {
return _getInitializableStorage()._initializing;
}
/**
* @dev Returns a pointer to the storage namespace.
*/
// solhint-disable-next-line var-name-mixedcase
function _getInitializableStorage() private pure returns (InitializableStorage storage $) {
assembly {
$.slot := INITIALIZABLE_STORAGE
}
}
}// SPDX-License-Identifier: BUSL-1.1
pragma solidity ^0.8.0;
pragma abicoder v2;
interface IVoter {
event GaugeCreated(address indexed gauge, address creator, address feeDistributor, address indexed pool);
event GaugeKilled(address indexed gauge);
event GaugeRevived(address indexed gauge);
event Voted(address indexed owner, uint256 weight, address indexed pool);
event Abstained(address indexed owner, uint256 weight);
event Deposit(address indexed lp, address indexed gauge, address indexed owner, uint256 amount);
event Withdraw(address indexed lp, address indexed gauge, address indexed owner, uint256 amount);
event NotifyReward(address indexed sender, address indexed reward, uint256 amount);
event DistributeReward(address indexed sender, address indexed gauge, uint256 amount);
event EmissionsRatio(address indexed caller, uint256 oldRatio, uint256 newRatio);
event NewGovernor(address indexed sender, address indexed governor);
event Whitelisted(address indexed whitelister, address indexed token);
event WhitelistRevoked(address indexed forbidder, address indexed token, bool status);
event Poke(address indexed user);
event EmissionsRedirected(address indexed sourceGauge, address indexed destinationGauge);
struct InitializationParams {
address ram;
address legacyFactory;
address gauges;
address feeDistributorFactory;
address minter;
address msig;
address xRam;
address clFactory;
address clGaugeFactory;
address nfpManager;
address feeRecipientFactory;
address voteModule;
}
function initialize(InitializationParams memory inputs) external;
/// @notice denominator basis
function BASIS() external view returns (uint256);
/// @notice ratio of xRam emissions globally
function xRatio() external view returns (uint256);
/// @notice minimum time threshold for rewarder (in seconds)
function timeThresholdForRewarder() external view returns (uint256);
/// @notice xRam contract address
function xRam() external view returns (address);
/// @notice legacy factory address (uni-v2/stableswap)
function legacyFactory() external view returns (address);
/// @notice concentrated liquidity factory
function clFactory() external view returns (address);
/// @notice gauge factory for CL
function clGaugeFactory() external view returns (address);
/// @notice legacy fee recipient factory
function feeRecipientFactory() external view returns (address);
/// @notice peripheral NFPManager contract
function nfpManager() external view returns (address);
/// @notice returns the address of the current governor
/// @return _governor address of the governor
function governor() external view returns (address _governor);
/// @notice the address of the vote module
/// @return _voteModule the vote module contract address
function voteModule() external view returns (address _voteModule);
/// @notice address of the central access Hub
function accessHub() external view returns (address);
/// @notice distributes emissions from the minter to the voter
/// @param amount the amount of tokens to notify
function notifyRewardAmount(uint256 amount) external;
/// @notice distributes the emissions for a specific gauge
/// @param _gauge the gauge address
function distribute(address _gauge) external;
/// @notice returns the address of the gauge factory
/// @param _gaugeFactory gauge factory address
function gaugeFactory() external view returns (address _gaugeFactory);
/// @notice returns the address of the feeDistributor factory
/// @return _feeDistributorFactory feeDist factory address
function feeDistributorFactory() external view returns (address _feeDistributorFactory);
/// @notice returns the address of the minter contract
/// @return _minter address of the minter
function minter() external view returns (address _minter);
/// @notice check if the gauge is active for governance use
/// @param _gauge address of the gauge
/// @return _trueOrFalse if the gauge is alive
function isAlive(address _gauge) external view returns (bool _trueOrFalse);
/// @notice allows the token to be paired with other whitelisted assets to participate in governance
/// @param _token the address of the token
function whitelist(address _token) external;
/// @notice effectively disqualifies a token from governance
/// @param _token the address of the token
function revokeWhitelist(address _token) external;
/// @notice returns if the address is a gauge
/// @param gauge address of the gauge
/// @return _trueOrFalse boolean if the address is a gauge
function isGauge(address gauge) external view returns (bool _trueOrFalse);
/// @notice disable a gauge from governance
/// @param _gauge address of the gauge
function killGauge(address _gauge) external;
/// @notice re-activate a dead gauge
/// @param _gauge address of the gauge
function reviveGauge(address _gauge) external;
/// @notice re-cast a tokenID's votes
/// @param owner address of the owner
function poke(address owner) external;
/// @notice sets the main destinationGauge of a token pairing
/// @param tokenA address of tokenA
/// @param tokenB address of tokenB
/// @param destinationGauge the main gauge to set to
function redirectEmissions(address tokenA, address tokenB, address destinationGauge) external;
/// @notice returns if the address is a fee distributor
/// @param _feeDistributor address of the feeDist
/// @return _trueOrFalse if the address is a fee distributor
function isFeeDistributor(address _feeDistributor) external view returns (bool _trueOrFalse);
/// @notice returns the address of the emission's token
/// @return _ram emissions token contract address
function ram() external view returns (address _ram);
/// @notice returns the address of the pool's gauge, if any
/// @param _pool pool address
/// @return _gauge gauge address
function gaugeForPool(address _pool) external view returns (address _gauge);
/// @notice returns the address of the pool's feeDistributor, if any
/// @param _gauge address of the gauge
/// @return _feeDistributor address of the pool's feedist
function feeDistributorForGauge(address _gauge) external view returns (address _feeDistributor);
/// @notice returns the gauge address of a CL pool
/// @param tokenA address of token A in the pair
/// @param tokenB address of token B in the pair
/// @param tickSpacing tickspacing of the pool
/// @return gauge address of the gauge
function gaugeForClPool(address tokenA, address tokenB, int24 tickSpacing) external view returns (address gauge);
/// @notice returns the array of all tickspacings for the tokenA/tokenB combination
/// @param tokenA address of token A in the pair
/// @param tokenB address of token B in the pair
/// @return _ts array of all the tickspacings
function tickSpacingsForPair(address tokenA, address tokenB) external view returns (int24[] memory _ts);
/// @notice returns the destination of a gauge redirect
/// @param gauge address of gauge
function gaugeRedirect(address gauge) external view returns (address);
/// @notice returns the block.timestamp divided by 1 week in seconds
/// @return period the period used for gauges
function getPeriod() external view returns (uint256 period);
/// @notice cast a vote to direct emissions to gauges and earn incentives
/// @param owner address of the owner
/// @param _pools the list of pools to vote on
/// @param _weights an arbitrary weight per pool which will be normalized to 100% regardless of numerical inputs
function vote(address owner, address[] calldata _pools, uint256[] calldata _weights) external;
/// @notice reset the vote of an address
/// @param owner address of the owner
function reset(address owner) external;
/// @notice set the governor address
/// @param _governor the new governor address
function setGovernor(address _governor) external;
/// @notice recover stuck emissions
/// @param _gauge the gauge address
/// @param _period the period
function stuckEmissionsRecovery(address _gauge, uint256 _period) external;
/// @notice creates a legacy gauge for the pool
/// @param _pool pool's address
/// @return _gauge address of the new gauge
function createGauge(address _pool) external returns (address _gauge);
/// @notice create a concentrated liquidity gauge
/// @param tokenA the address of tokenA
/// @param tokenB the address of tokenB
/// @param tickSpacing the tickspacing of the pool
/// @return _clGauge address of the new gauge
function createCLGauge(address tokenA, address tokenB, int24 tickSpacing) external returns (address _clGauge);
/// @notice claim concentrated liquidity gauge rewards for specific NFP token ids
/// @param _gauges array of gauges
/// @param _tokens two dimensional array for the tokens to claim
/// @param _nfpTokenIds two dimensional array for the NFPs
function claimClGaugeRewards(
address[] calldata _gauges,
address[][] calldata _tokens,
uint256[][] calldata _nfpTokenIds
) external;
/// @notice claim arbitrary rewards from specific feeDists
/// @param owner address of the owner
/// @param _feeDistributors address of the feeDists
/// @param _tokens two dimensional array for the tokens to claim
function claimIncentives(address owner, address[] calldata _feeDistributors, address[][] calldata _tokens)
external;
/// @notice claim arbitrary rewards from specific feeDists and break up legacy pairs
/// @param owner address of the owner
/// @param _feeDistributors address of the feeDists
/// @param _tokens two dimensional array for the tokens to claim
function claimLegacyIncentives(address owner, address[] calldata _feeDistributors, address[][] calldata _tokens)
external;
/// @notice claim arbitrary rewards from specific gauges
/// @param _gauges address of the gauges
/// @param _tokens two dimensional array for the tokens to claim
function claimRewards(address[] calldata _gauges, address[][] calldata _tokens) external;
/// @notice distribute emissions to a gauge for a specific period
/// @param _gauge address of the gauge
/// @param _period value of the period
function distributeForPeriod(address _gauge, uint256 _period) external;
/// @notice attempt distribution of emissions to all gauges
function distributeAll() external;
/// @notice distribute emissions to gauges by index
/// @param startIndex start of the loop
/// @param endIndex end of the loop
function batchDistributeByIndex(uint256 startIndex, uint256 endIndex) external;
/// @notice lets governance update lastDistro period for a gauge
/// @dev should only be used if distribute() is running out of gas
/// @dev gaugePeriodDistributed will stop double claiming
/// @param _gauge gauge to update
/// @param _period period to update to
function updateLastDistro(address _gauge, uint256 _period) external;
/// @notice returns the votes cast for a tokenID
/// @param owner address of the owner
/// @return votes an array of votes casted
/// @return weights an array of the weights casted per pool
function getVotes(address owner, uint256 period)
external
view
returns (address[] memory votes, uint256[] memory weights);
/// @notice returns an array of all the pools
/// @return _pools the array of pools
function getAllPools() external view returns (address[] memory _pools);
/// @notice returns the length of pools
function getPoolsLength() external view returns (uint256);
/// @notice returns the pool at index
function getPool(uint256 index) external view returns (address);
/// @notice returns an array of all the gauges
/// @return _gauges the array of gauges
function getAllGauges() external view returns (address[] memory _gauges);
/// @notice returns the length of gauges
function getGaugesLength() external view returns (uint256);
/// @notice returns the gauge at index
function getGauge(uint256 index) external view returns (address);
/// @notice returns an array of all the feeDists
/// @return _feeDistributors the array of feeDists
function getAllFeeDistributors() external view returns (address[] memory _feeDistributors);
/// @notice sets the xRamRatio default
function setGlobalRatio(uint256 _xRatio) external;
/// @notice whether the token is whitelisted in governance
function isWhitelisted(address _token) external view returns (bool _tf);
/// @notice function for removing malicious or stuffed tokens
function removeFeeDistributorReward(address _feeDist, address _token) external;
/// @notice returns the total votes for a pool in a specific period
/// @param pool the pool address to check
/// @param period the period to check
/// @return votes the total votes for the pool in that period
function poolTotalVotesPerPeriod(address pool, uint256 period) external view returns (uint256 votes);
/// @notice returns the pool address for a given gauge
/// @param gauge address of the gauge
/// @return pool address of the pool
function poolForGauge(address gauge) external view returns (address pool);
/// @notice returns the pool address for a given feeDistributor
/// @param feeDistributor address of the feeDistributor
/// @return pool address of the pool
function poolForFeeDistributor(address feeDistributor) external view returns (address pool);
/// @notice returns the voting power used by a voter for a period
/// @param user address of the user
/// @param period the period to check
function userVotingPowerPerPeriod(address user, uint256 period) external view returns (uint256 votingPower);
/// @notice returns the total votes for a specific period
/// @param period the period to check
/// @return weight the total votes for that period
function totalVotesPerPeriod(uint256 period) external view returns (uint256 weight);
/// @notice returns the total rewards allocated for a specific period
/// @param period the period to check
/// @return amount the total rewards for that period
function totalRewardPerPeriod(uint256 period) external view returns (uint256 amount);
/// @notice returns the last distribution period for a gauge
/// @param _gauge address of the gauge
/// @return period the last period distributions occurred
function lastDistro(address _gauge) external view returns (uint256 period);
/// @notice returns if the gauge is a Cl gauge
/// @param gauge the gauge to check
function isClGauge(address gauge) external view returns (bool);
/// @notice returns if the gauge is a legacy gauge
/// @param gauge the gauge to check
function isLegacyGauge(address gauge) external view returns (bool);
/// @notice sets a new NFP manager
function setNfpManager(address _nfpManager) external;
/// @notice sets the minimum time threshold for rewarder (in seconds)
function setTimeThresholdForRewarder(uint256 _timeThreshold) external;
/// @notice returns all voters for a period
function getAllVotersPerPeriod(uint256 period) external view returns (address[] memory);
/// @notice returns the length of all voters for a period
function getAllVotersPerPeriodLength(uint256 period) external view returns (uint256);
/// @notice returns voter at index for a period
function getAllVotersPerPeriodAt(uint256 period, uint256 index) external view returns (address);
/// @notice Update FeeDistributor for a gauge (emergency governance function)
function updateFeeDistributorForGauge(address _gauge, address _newFeeDistributor) external;
/// @notice Create a new FeeDistributor with specified feeRecipient (emergency governance function)
function createFeeDistributorWithRecipient(address _feeRecipient) external returns (address);
}// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity ^0.8.0;
interface IMinter {
event SetVeDist(address _value);
event SetVoter(address _value);
event Mint(address indexed sender, uint256 weekly);
event RebaseUnsuccessful(uint256 _current, uint256 _currentPeriod);
event EmissionsMultiplierUpdated(uint256 _emissionsMultiplier);
/// @notice decay or inflation scaled to 10_000 = 100%
/// @return _multiplier the emissions multiplier
function emissionsMultiplier() external view returns (uint256 _multiplier);
/// @notice unix timestamp of current epoch's start
/// @return _activePeriod the active period
function activePeriod() external view returns (uint256 _activePeriod);
/// @notice update the epoch (period) -- callable once a week at >= Thursday 0 UTC
/// @return period the new period
function updatePeriod() external returns (uint256 period);
/// @notice intialize epoch0 + emissions (immediately active for this week)
function initEpoch0() external;
/// @notice updates the decay or inflation scaled to 10_000 = 100%
/// @param _emissionsMultiplier multiplier for emissions each week
function updateEmissionsMultiplier(uint256 _emissionsMultiplier) external;
/// @notice calculates the emissions to be sent to the voter
/// @return _weeklyEmissions the amount of emissions for the week
function calculateWeeklyEmissions() external view returns (uint256 _weeklyEmissions);
/// @notice kicks off the initial minting and variable declarations
function kickoff(
address _rex,
address _voter,
uint256 _initialWeeklyEmissions,
uint256 _initialMultiplier,
address _xRex
) external;
/// @notice returns (block.timestamp / 1 week) for gauge use
/// @return period period number
function getPeriod() external view returns (uint256 period);
/// @notice returns the numerical value of the current epoch
/// @return _epoch epoch number
function getEpoch() external view returns (uint256 _epoch);
}// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity ^0.8.0;
import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import {IVoter} from "./IVoter.sol";
import {Pausable} from "@openzeppelin/contracts/utils/Pausable.sol";
interface IXRex is IERC20 {
event InstantExit(address indexed user, uint256);
event NewSlashingPenalty(uint256 penalty);
event Converted(address indexed user, uint256);
event Exemption(address indexed candidate, bool status, bool success);
event XRamRedeemed(address indexed user, uint256);
event NewOperator(address indexed o, address indexed n);
event Rebase(address indexed caller, uint256 amount);
event NewRebaseThreshold(uint256 threshold);
/// @notice address of the rex token
function REX() external view returns (IERC20);
/// @notice address of the voter
function VOTER() external view returns (IVoter);
function MINTER() external view returns (address);
function ACCESS_HUB() external view returns (address);
/// @notice address of the operator
function operator() external view returns (address);
/// @notice address of the VoteModule
function VOTE_MODULE() external view returns (address);
/// @notice max slashing amount
function SLASHING_PENALTY() external view returns (uint256);
/// @notice denominator
function BASIS() external view returns (uint256);
function rex() external view returns (address);
/// @notice the last period rebases were distributed
function lastDistributedPeriod() external view returns (uint256);
/// @notice amount of pvp rebase penalties accumulated pending to be distributed
function pendingRebase() external view returns (uint256);
/// @notice dust threshold before a rebase can happen
function rebaseThreshold() external view returns (uint256);
/// @notice pauses the contract
function pause() external;
/// @notice unpauses the contract
function unpause() external;
/**
*
*/
// General use functions
/**
*
*/
/// @dev mints xREX for each rex.
function convertEmissionsToken(uint256 _amount) external;
/// @notice function called by the minter to send the rebases once a week
function rebase() external;
/**
* @dev exit instantly with a penalty
* @param _amount amount of xREX to exit
*/
function exit(uint256 _amount) external returns (uint256 _exitedAmount);
/**
*
*/
// Permissioned functions, timelock/operator gated
/**
*
*/
/// @dev allows the operator to redeem collected xREX
function operatorRedeem(uint256 _amount) external;
/// @dev allows rescue of any non-stake token
function rescueTrappedTokens(address[] calldata _tokens, uint256[] calldata _amounts) external;
/// @notice migrates the operator to another contract
function migrateOperator(address _operator) external;
/// @notice set exemption status for an address
function setExemption(address[] calldata _exemptee, bool[] calldata _exempt) external;
function setExemptionTo(address[] calldata _exemptee, bool[] calldata _exempt) external;
/// @notice set dust threshold before a rebase can happen
function setRebaseThreshold(uint256 _newThreshold) external;
/**
*
*/
// Getter functions
/**
*
*/
/// @notice returns the amount of REX within the contract
function getBalanceResiding() external view returns (uint256);
/// @notice whether the address is exempt
/// @param _who who to check
/// @return _exempt whether it's exempt
function isExempt(address _who) external view returns (bool _exempt);
/// @notice whether the address is exempt to
/// @param _who who to check
/// @return _exempt whether it's exempt
function isExemptTo(address _who) external view returns (bool _exempt);
}// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity ^0.8.0;
import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import {IXRex} from "contracts/interfaces/IXRex.sol";
interface IREX33 is IERC20 {
/// @dev parameters passed to the aggregator swap
struct AggregatorParams {
address aggregator; // address of the whitelisted aggregator
address tokenIn; // token to swap from
uint256 amountIn; // amount of tokenIn to swap
uint256 minAmountOut; // minimum amount of tokenOut to receive
bytes callData; // encoded swap calldata
}
event Entered(address indexed user, uint256 amount, uint256 ratioAtDeposit);
event Exited(address indexed user, uint256 _outAmount, uint256 ratioAtWithdrawal);
event NewOperator(address _oldOperator, address _newOperator);
event Compounded(uint256 oldRatio, uint256 newRatio, uint256 amount);
event SwappedBribe(address indexed operator, address indexed tokenIn, uint256 amountIn, uint256 amountOut);
event Rebased(uint256 oldRatio, uint256 newRatio, uint256 amount);
/// @notice Event emitted when an aggregator's whitelist status changes
event AggregatorWhitelistUpdated(address aggregator, bool status);
event Unlocked(uint256 _ts);
event UpdatedIndex(uint256 _index);
event ClaimedIncentives(address[] feeDistributors, address[][] tokens);
function whitelistedAggregators(address aggregator) external returns (bool);
/// @notice submits the optimized votes for the epoch
function submitVotes(address[] calldata _pools, uint256[] calldata _weights) external;
/// @notice swap function using aggregators to process rewards into RAM
function swapIncentiveViaAggregator(AggregatorParams calldata _params) external;
/// @notice claims the rebase accrued to x33
function claimRebase() external;
/// @notice compounds any existing RAM within the contract
function compound() external;
/// @notice direct claim
function claimIncentives(address[] calldata _feeDistributors, address[][] calldata _tokens) external;
/// @notice rescue stuck tokens
function rescue(address _token, uint256 _amount) external;
/// @notice allows the operator to unlock the contract for the current period
function unlock() external;
/// @notice add or remove an aggregator from the whitelist (timelocked)
/// @param _aggregator address of the aggregator to update
/// @param _status new whitelist status
function whitelistAggregator(address _aggregator, bool _status) external;
/// @notice transfers the operator via accesshub
function transferOperator(address _newOperator) external;
/// @notice simple getPeriod call
function getPeriod() external view returns (uint256 period);
/// @notice if the contract is unlocked for deposits
function isUnlocked() external view returns (bool);
/// @notice determines whether the cooldown is active
function isCooldownActive() external view returns (bool);
/// @notice address of the current operator
function operator() external view returns (address);
/// @notice accessHub address
function accessHub() external view returns (address);
/// @notice returns the ratio of xRam per X33 token
function ratio() external view returns (uint256 _ratio);
/// @notice the most recent active period the contract has interacted in
function activePeriod() external view returns (uint256);
/// @notice whether the periods are unlocked
function periodUnlockStatus(uint256 _period) external view returns (bool unlocked);
/// @notice the rex token
function rex() external view returns (IERC20);
/// @notice the xREX token
function xRex() external view returns (IXRex);
}// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity >=0.5.0;
/// @title The interface for the Ramses V3 Factory
/// @notice The Ramses V3 Factory facilitates creation of Ramses V3 pools and control over the protocol fees
interface IRamsesV3Factory {
/// @notice Emitted when a pool is created
/// @param token0 The first token of the pool by address sort order
/// @param token1 The second token of the pool by address sort order
/// @param fee The fee collected upon every swap in the pool, denominated in hundredths of a bip
/// @param tickSpacing The minimum number of ticks between initialized ticks
/// @param pool The address of the created pool
event PoolCreated(
address indexed token0, address indexed token1, uint24 indexed fee, int24 tickSpacing, address pool
);
/// @notice Emitted when a new tickspacing amount is enabled for pool creation via the factory
/// @dev unlike UniswapV3, we map via the tickSpacing rather than the fee tier
/// @param tickSpacing The minimum number of ticks between initialized ticks
/// @param fee The fee, denominated in hundredths of a bip
event TickSpacingEnabled(int24 indexed tickSpacing, uint24 indexed fee);
/// @notice Emitted when the protocol fee is changed
/// @param feeProtocolOld The previous value of the protocol fee
/// @param feeProtocolNew The updated value of the protocol fee
event SetFeeProtocol(uint24 feeProtocolOld, uint24 feeProtocolNew);
/// @notice Emitted when the protocol fee is changed
/// @param pool The pool address
/// @param feeProtocolOld The previous value of the protocol fee
/// @param feeProtocolNew The updated value of the protocol fee
event SetPoolFeeProtocol(address pool, uint24 feeProtocolOld, uint24 feeProtocolNew);
/// @notice Emitted when a pool's fee is changed
/// @param pool The pool address
/// @param newFee The updated value of the protocol fee
event FeeAdjustment(address pool, uint24 newFee);
/// @notice Emitted when the fee collector is changed
/// @param oldFeeCollector The previous implementation
/// @param newFeeCollector The new implementation
event FeeCollectorChanged(address indexed oldFeeCollector, address indexed newFeeCollector);
/// @notice Returns the PoolDeployer address
/// @return The address of the PoolDeployer contract
function ramsesV3PoolDeployer() external returns (address);
/// @notice Returns the fee amount for a given tickSpacing, if enabled, or 0 if not enabled
/// @dev A tickSpacing can never be removed, so this value should be hard coded or cached in the calling context
/// @dev unlike UniswapV3, we map via the tickSpacing rather than the fee tier
/// @param tickSpacing The enabled tickSpacing. Returns 0 in case of unenabled tickSpacing
/// @return initialFee The initial fee
function tickSpacingInitialFee(int24 tickSpacing) external view returns (uint24 initialFee);
/// @notice Returns the pool address for a given pair of tokens and a tickSpacing, or address 0 if it does not exist
/// @dev tokenA and tokenB may be passed in either token0/token1 or token1/token0 order
/// @dev unlike UniswapV3, we map via the tickSpacing rather than the fee tier
/// @param tokenA The contract address of either token0 or token1
/// @param tokenB The contract address of the other token
/// @param tickSpacing The tickSpacing of the pool
/// @return pool The pool address
function getPool(address tokenA, address tokenB, int24 tickSpacing) external view returns (address pool);
/// @notice Creates a pool for the given two tokens and fee
/// @dev unlike UniswapV3, we map via the tickSpacing rather than the fee tier
/// @param tokenA One of the two tokens in the desired pool
/// @param tokenB The other of the two tokens in the desired pool
/// @param tickSpacing The desired tickSpacing for the pool
/// @param sqrtPriceX96 initial sqrtPriceX96 of the pool
/// @dev tokenA and tokenB may be passed in either order: token0/token1 or token1/token0.
/// @dev The call will revert if the pool already exists, the tickSpacing is invalid, or the token arguments are invalid.
/// @return pool The address of the newly created pool
function createPool(address tokenA, address tokenB, int24 tickSpacing, uint160 sqrtPriceX96)
external
returns (address pool);
/// @notice Enables a tickSpacing with the given initialFee amount
/// @dev unlike UniswapV3, we map via the tickSpacing rather than the fee tier
/// @dev tickSpacings may never be removed once enabled
/// @param tickSpacing The spacing between ticks to be enforced for all pools created
/// @param initialFee The initial fee amount, denominated in hundredths of a bip (i.e. 1e-6)
function enableTickSpacing(int24 tickSpacing, uint24 initialFee) external;
/// @notice Returns the default protocol fee value
/// @return _feeProtocol The default protocol fee percentage
function feeProtocol() external view returns (uint24 _feeProtocol);
/// @notice Returns the protocol fee percentage for a specific pool
/// @dev If the fee is 0 or the pool is uninitialized, returns the Factory's default feeProtocol
/// @param pool The address of the pool
/// @return _feeProtocol The protocol fee percentage for the specified pool
function poolFeeProtocol(address pool) external view returns (uint24 _feeProtocol);
/// @notice Sets the default protocol fee percentage
/// @param _feeProtocol New default protocol fee percentage for token0 and token1
function setFeeProtocol(uint24 _feeProtocol) external;
/// @notice Retrieves the parameters used in constructing a pool
/// @dev Called by the pool constructor to fetch the pool's parameters
/// @return factory The factory address
/// @return token0 The first token of the pool by address sort order
/// @return token1 The second token of the pool by address sort order
/// @return fee The initialized fee tier of the pool, denominated in hundredths of a bip
/// @return tickSpacing The minimum number of ticks between initialized ticks
function parameters()
external
view
returns (address factory, address token0, address token1, uint24 fee, int24 tickSpacing);
/// @notice Updates the fee collector address
/// @param _feeCollector The new fee collector address
function setFeeCollector(address _feeCollector) external;
/// @notice Updates the swap fee for a specific pool
/// @param _pool The address of the pool to modify
/// @param _fee The new fee value, scaled where 1_000_000 = 100%
function setFee(address _pool, uint24 _fee) external;
/// @notice Returns the current fee collector address
/// @dev The fee collector contract determines the distribution of protocol fees
/// @return The address of the fee collector contract
function feeCollector() external view returns (address);
/// @notice Flag for getting a pool to use the default feeProcotol
/// @dev type(uint24).max denotes using default feeProcotol
function DEFAULT_FEE_FLAG() external view returns (uint24);
/// @notice Updates the protocol fee percentage for a specific pool
/// @dev type(uint24).max denotes using default feeProcotol
/// @param pool The address of the pool to modify
/// @param _feeProtocol The new protocol fee percentage to assign
function setPoolFeeProtocol(address pool, uint24 _feeProtocol) external;
/// @notice Enables fee protocol splitting upon gauge creation
/// @param pool The address of the pool to enable fee splitting for
function gaugeFeeSplitEnable(address pool) external;
/// @notice Updates the voter contract address
/// @param _voter The new voter contract address
function setVoter(address _voter) external;
/// @notice Checks if a given address is a V3 pool
/// @param _pool The address to check
/// @return isV3 True if the address is a V3 pool, false otherwise
function isPairV3(address _pool) external view returns (bool isV3);
/// @notice Initializes the factory with a pool deployer
/// @param poolDeployer The address of the pool deployer contract
function initialize(address poolDeployer) external;
/// @notice returns the voter
function voter() external returns (address);
}// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity ^0.8.0;
interface IPairFactory {
event PairCreated(address indexed token0, address indexed token1, address pair, uint256);
event SetFee(uint256 indexed fee);
event SetVoter(address indexed voter);
event SetPairFee(address indexed pair, uint256 indexed fee);
event SetFeeSplit(uint256 indexed _feeSplit);
event SetPairFeeSplit(address indexed pair, uint256 indexed _feeSplit);
event SkimStatus(address indexed _pair, bool indexed _status);
event NewTreasury(address indexed _caller, address indexed _newTreasury);
event FeeSplitWhenNoGauge(address indexed _caller, bool indexed _status);
event SetFeeRecipient(address indexed pair, address indexed feeRecipient);
/// @notice returns the total length of legacy pairs
/// @return _length the length
function allPairsLength() external view returns (uint256 _length);
/// @notice calculates if the address is a legacy pair
/// @param pair the address to check
/// @return _boolean the bool return
function isPair(address pair) external view returns (bool _boolean);
/// @notice calculates the pairCodeHash
/// @return _hash the pair code hash
function pairCodeHash() external view returns (bytes32 _hash);
/// @param tokenA address of tokenA
/// @param tokenB address of tokenB
/// @param stable whether it uses the stable curve
/// @return _pair the address of the pair
function getPair(address tokenA, address tokenB, bool stable) external view returns (address _pair);
/// @notice creates a new legacy pair
/// @param tokenA address of tokenA
/// @param tokenB address of tokenB
/// @param stable whether it uses the stable curve
/// @return pair the address of the created pair
function createPair(address tokenA, address tokenB, bool stable) external returns (address pair);
/// @notice the address of the voter
/// @return _voter the address of the voter
function voter() external view returns (address _voter);
/// @notice returns the address of a pair based on the index
/// @param _index the index to check for a pair
/// @return _pair the address of the pair at the index
function allPairs(uint256 _index) external view returns (address _pair);
/// @notice the swap fee of a pair
/// @param _pair the address of the pair
/// @return _fee the fee
function pairFee(address _pair) external view returns (uint256 _fee);
/// @notice the split of fees
/// @return _split the feeSplit
function feeSplit() external view returns (uint256 _split);
/// @notice sets the swap fee for a pair
/// @param _pair the address of the pair
/// @param _fee the fee for the pair
function setPairFee(address _pair, uint256 _fee) external;
/// @notice set the swap fees of the pair
/// @param _fee the fee, scaled to MAX 500_000 = 50%
function setFee(uint256 _fee) external;
/// @notice the address for the treasury
/// @return _treasury address of the treasury
function treasury() external view returns (address _treasury);
/// @notice sets the pairFees contract
/// @param _pair the address of the pair
/// @param _pairFees the address of the new Pair Fees
function setFeeRecipient(address _pair, address _pairFees) external;
/// @notice sets the feeSplit for a pair
/// @param _pair the address of the pair
/// @param _feeSplit the feeSplit
function setPairFeeSplit(address _pair, uint256 _feeSplit) external;
/// @notice whether there is feeSplit when there's no gauge
/// @return _boolean whether there is a feesplit when no gauge
function feeSplitWhenNoGauge() external view returns (bool _boolean);
/// @notice whether a pair can be skimmed
/// @param _pair the pair address
/// @return _boolean whether skim is enabled
function skimEnabled(address _pair) external view returns (bool _boolean);
/// @notice set whether skim is enabled for a specific pair
function setSkimEnabled(address _pair, bool _status) external;
/// @notice sets a new treasury address
/// @param _treasury the new treasury address
function setTreasury(address _treasury) external;
/// @notice set whether there should be a feesplit without gauges
/// @param status whether enabled or not
function setFeeSplitWhenNoGauge(bool status) external;
/// @notice sets the feesSplit globally
/// @param _feeSplit the fee split
function setFeeSplit(uint256 _feeSplit) external;
/// @notice sets the voter
/// @param _voter the voter address
function setVoter(address _voter) external;
}// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity ^0.8.0;
import {IVoter} from "contracts/interfaces/IVoter.sol";
interface IFeeRecipientFactory {
/// @notice the pair fees for a specific pair
/// @param pair the pair to check
/// @return feeRecipient the feeRecipient contract address for the pair
function feeRecipientForPair(address pair) external view returns (address feeRecipient);
/// @notice the last feeRecipient address created
/// @return _feeRecipient the address of the last pair fees contract
function lastFeeRecipient() external view returns (address _feeRecipient);
/// @notice create the pair fees for a pair
/// @param pair the address of the pair
/// @return _feeRecipient the address of the newly created feeRecipient
function createFeeRecipient(address pair) external returns (address _feeRecipient);
/// @notice the fee % going to the treasury
/// @return _feeToTreasury the fee %
function feeToTreasury() external view returns (uint256 _feeToTreasury);
/// @notice get the treasury address
/// @return _treasury address of the treasury
function treasury() external view returns (address _treasury);
/// @notice get the voter address
/// @return _voter address of the voter
function voter() external view returns (address _voter);
/// @notice set the fee % to be sent to the treasury
/// @param _feeToTreasury the fee % to be sent to the treasury
function setFeeToTreasury(uint256 _feeToTreasury) external;
/// @notice set the treasury address
/// @param _treasury the address of the treasury
function setTreasury(address _treasury) external;
/// @notice set the voter address
/// @param _voter the address of the voter
function setVoter(address _voter) external;
}// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity >=0.5.0;
import {IRamsesV3PoolImmutables} from "./pool/IRamsesV3PoolImmutables.sol";
import {IRamsesV3PoolState} from "./pool/IRamsesV3PoolState.sol";
import {IRamsesV3PoolDerivedState} from "./pool/IRamsesV3PoolDerivedState.sol";
import {IRamsesV3PoolActions} from "./pool/IRamsesV3PoolActions.sol";
import {IRamsesV3PoolOwnerActions} from "./pool/IRamsesV3PoolOwnerActions.sol";
import {IRamsesV3PoolErrors} from "./pool/IRamsesV3PoolErrors.sol";
import {IRamsesV3PoolEvents} from "./pool/IRamsesV3PoolEvents.sol";
/// @title The interface for a Ramses V3 Pool
/// @notice A Ramses pool facilitates swapping and automated market making between any two assets that strictly conform
/// to the ERC20 specification
/// @dev The pool interface is broken up into many smaller pieces
interface IRamsesV3Pool is
IRamsesV3PoolImmutables,
IRamsesV3PoolState,
IRamsesV3PoolDerivedState,
IRamsesV3PoolActions,
IRamsesV3PoolOwnerActions,
IRamsesV3PoolErrors,
IRamsesV3PoolEvents
{
/// @notice if a new period, advance on interaction
function _advancePeriod() external;
/// @notice Get the index of the last period in the pool
/// @return The index of the last period
function lastPeriod() external view returns (uint256);
/// @notice allows reading arbitrary storage slots
function readStorage(bytes32[] calldata slots) external view returns (bytes32[] memory returnData);
}// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity ^0.8.0;
import {IRamsesV3Pool} from "../../core/interfaces/IRamsesV3Pool.sol";
interface IFeeCollector {
/// @notice Emitted when the treasury address is changed.
/// @param oldTreasury The previous treasury address.
/// @param newTreasury The new treasury address.
event TreasuryChanged(address oldTreasury, address newTreasury);
/// @notice Emitted when the treasury fees value is changed.
/// @param oldTreasuryFees The previous value of the treasury fees.
/// @param newTreasuryFees The new value of the treasury fees.
event TreasuryFeesChanged(uint256 oldTreasuryFees, uint256 newTreasuryFees);
/// @notice Emitted when protocol fees are collected from a pool and distributed to the fee distributor and treasury.
/// @param pool The address of the pool from which the fees were collected.
/// @param feeDistAmount0 The amount of fee tokens (token 0) distributed to the fee distributor.
/// @param feeDistAmount1 The amount of fee tokens (token 1) distributed to the fee distributor.
/// @param treasuryAmount0 The amount of fee tokens (token 0) allocated to the treasury.
/// @param treasuryAmount1 The amount of fee tokens (token 1) allocated to the treasury.
event FeesCollected(
address pool, uint256 feeDistAmount0, uint256 feeDistAmount1, uint256 treasuryAmount0, uint256 treasuryAmount1
);
/// @notice Returns the treasury address.
function treasury() external returns (address);
/// @notice Returns the treasury fees ratio.
function treasuryFees() external returns (uint256);
/// @notice Sets the treasury address to a new value.
/// @param newTreasury The new address to set as the treasury.
function setTreasury(address newTreasury) external;
/// @notice Sets the value of treasury fees to a new amount.
/// @param _treasuryFees The new amount of treasury fees to be set.
function setTreasuryFees(uint256 _treasuryFees) external;
/// @notice Collects protocol fees from a specified pool and distributes them to the fee distributor and treasury.
/// @param pool The pool from which to collect the protocol fees.
function collectProtocolFees(address pool) external;
}// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity ^0.8.0;
interface IVoteModule {
/**
* Events
*/
event Deposit(address indexed from, uint256 amount);
event Withdraw(address indexed from, uint256 amount);
event NotifyReward(address indexed from, uint256 amount);
event ClaimRewards(address indexed from, uint256 amount);
event ExemptedFromCooldown(address indexed candidate, bool status);
event NewDuration(uint256 oldDuration, uint256 newDuration);
event NewCooldown(uint256 oldCooldown, uint256 newCooldown);
event Delegate(address indexed delegator, address indexed delegatee, bool indexed isAdded);
event SetAdmin(address indexed owner, address indexed operator, bool indexed isAdded);
/**
* Functions
*/
function delegates(address) external view returns (address);
/// @notice mapping for admins for a specific address
/// @param owner the owner to check against
/// @return operator the address that is designated as an admin/operator
function admins(address owner) external view returns (address operator);
function accessHub() external view returns (address);
/// @notice reward supply for a period
function rewardSupply(uint256 period) external view returns (uint256);
/// @notice user claimed reward amount for a period
/// @dev same mapping order as FeeDistributor so the name is a bit odd
function userClaimed(uint256 period, address owner) external view returns (uint256);
/// @notice last claimed period for a user
function userLastClaimPeriod(address owner) external view returns (uint256);
/// @notice returns the current period
function getPeriod() external view returns (uint256);
/// @notice returns the amount of unclaimed rebase earned by the user
function earned(address account) external view returns (uint256 _reward);
/// @notice returns the amount of unclaimed rebase earned by the user for a period
function periodEarned(uint256 period, address user) external view returns (uint256 amount);
/// @notice the time which users can deposit and withdraw
function unlockTime() external view returns (uint256 _timestamp);
/// @notice claims pending rebase rewards
function getReward() external;
/// @notice claims pending rebase rewards for a period
function getPeriodReward(uint256 period) external;
/// @notice allows users to set their own last claimed period in case they haven't claimed in a while
/// @param period the new period to start loops from
function setUserLastClaimPeriod(uint256 period) external;
/// @notice deposits all xREX in the caller's wallet
function depositAll() external;
/// @notice deposit a specified amount of xRam
function deposit(uint256 amount) external;
/// @notice withdraw all xREX
function withdrawAll() external;
/// @notice withdraw a specified amount of xREX
function withdraw(uint256 amount) external;
/// @notice check for admin perms
/// @param operator the address to check
/// @param owner the owner to check against for permissions
function isAdminFor(address operator, address owner) external view returns (bool approved);
/// @notice check for delegations
/// @param delegate the address to check
/// @param owner the owner to check against for permissions
function isDelegateFor(address delegate, address owner) external view returns (bool approved);
/// @notice used by the xREX contract to notify pending rebases
/// @param amount the amount of REX to be notified from exit penalties
function notifyRewardAmount(uint256 amount) external;
/// @notice the address of the xREX token (staking/voting token)
/// @return _xRex the address
function xRex() external view returns (address _xRex);
/// @notice address of the voter contract
/// @return _voter the voter contract address
function voter() external view returns (address _voter);
/// @notice returns the total voting power (equal to total supply in the VoteModule)
/// @return _totalSupply the total voting power
function totalSupply() external view returns (uint256 _totalSupply);
/// @notice voting power
/// @param user the address to check
/// @return amount the staked balance
function balanceOf(address user) external view returns (uint256 amount);
/// @notice delegate voting perms to another address
/// @param delegatee who you delegate to
/// @dev set address(0) to revoke
function delegate(address delegatee) external;
/// @notice give admin permissions to a another address
/// @param operator the address to give administrative perms to
/// @dev set address(0) to revoke
function setAdmin(address operator) external;
function cooldownExempt(address) external view returns (bool);
function setCooldownExemption(address, bool) external;
/// @notice lock period after rebase starts accruing
function cooldown() external returns (uint256);
function setNewCooldown(uint256) external;
}// SPDX-License-Identifier: kBUSL-1.1
pragma solidity ^0.8.26;
import {IGaugeV3} from "./interfaces/IGaugeV3.sol";
import {INonfungiblePositionManager} from "../periphery/interfaces/INonfungiblePositionManager.sol";
import {IFeeCollector} from "./interfaces/IFeeCollector.sol";
import {FullMath} from "../core/libraries/FullMath.sol";
import {IRamsesV3Pool} from "../core/interfaces/IRamsesV3Pool.sol";
import {IRamsesV3PoolState} from "../core/interfaces/pool/IRamsesV3PoolState.sol";
import {SafeERC20, IERC20} from "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
import {Math} from "@openzeppelin/contracts/utils/math/Math.sol";
import {Initializable} from "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol";
import {IVoter} from "../../interfaces/IVoter.sol";
import {Errors} from "../../libraries/Errors.sol";
contract GaugeV3 is IGaugeV3, Initializable {
using SafeERC20 for IERC20;
uint256 internal constant WEEK = 1 weeks;
uint256 internal constant PRECISION = 10 ** 18;
bool internal _unlocked;
IRamsesV3Pool public pool;
address public voter;
IFeeCollector public feeCollector;
INonfungiblePositionManager public nfpManager;
/// @inheritdoc IGaugeV3
uint256 public firstPeriod;
/// @inheritdoc IGaugeV3
/// @dev period => token => total supply
mapping(uint256 => mapping(address => uint256)) public tokenTotalSupplyByPeriod;
/// @dev period => position hash => bool
mapping(uint256 => mapping(bytes32 => bool)) internal periodAmountsWritten;
/// @dev period => position hash => seconds in range
mapping(uint256 => mapping(bytes32 => uint256)) internal periodNfpSecondsX96;
/// @inheritdoc IGaugeV3
/// @dev period => position hash => reward token => amount
mapping(uint256 => mapping(bytes32 => mapping(address => uint256))) public periodClaimedAmount;
/// @dev token => position hash => period
/// @inheritdoc IGaugeV3
mapping(address => mapping(bytes32 => uint256)) public lastClaimByToken;
/// @inheritdoc IGaugeV3
address[] public rewards;
/// @inheritdoc IGaugeV3
mapping(address => bool) public isReward;
/// @dev Mutually exclusive reentrancy protection into the pool to/from a method. This method also prevents entrance
/// @dev to a function before the Gauge is initialized.
modifier lock() {
require(_unlocked, Errors.LOCKED());
_unlocked = false;
_;
_unlocked = true;
}
/// @dev pushes fees from the pool to fee distributor on notify rewards
modifier pushFees() {
feeCollector.collectProtocolFees(address(pool));
_;
}
function initialize(
address _voter,
address _nfpManager,
address _feeCollector,
address _pool
) public initializer {
_unlocked = true;
voter = _voter;
feeCollector = IFeeCollector(_feeCollector);
nfpManager = INonfungiblePositionManager(_nfpManager);
pool = IRamsesV3Pool(_pool);
firstPeriod = _blockTimestamp() / WEEK;
(address rex, address xrex) = (
IVoter(_voter).ram(),
IVoter(_voter).xRam()
);
(address token0, address token1) = (
IRamsesV3Pool(_pool).token0(),
IRamsesV3Pool(_pool).token1()
);
rewards.push(token0);
rewards.push(token1);
(isReward[token0], isReward[token1], isReward[xrex]) = (
true,
true,
true
);
/// @dev if token0 and token1 aren't shadow add shadow in the records
if (token0 != rex && token1 != rex) {
rewards.push(rex);
isReward[rex] = true;
}
for (uint256 i; i < rewards.length; i++) {
emit RewardAdded(rewards[i]);
}
}
function initializeV2(
address _voter,
address _nfpManager,
address _feeCollector,
address _pool
) public {
// gated to accesshub
require(msg.sender == 0x683035188E3670fda1deF2a7Aa5742DEa28Ed5f3, Errors.NOT_AUTHORIZED(msg.sender));
_unlocked = true;
voter = _voter;
feeCollector = IFeeCollector(_feeCollector);
nfpManager = INonfungiblePositionManager(_nfpManager);
pool = IRamsesV3Pool(_pool);
firstPeriod = _blockTimestamp() / WEEK;
(address rex, address xrex) = (
IVoter(_voter).ram(),
IVoter(_voter).xRam()
);
(address token0, address token1) = (
IRamsesV3Pool(_pool).token0(),
IRamsesV3Pool(_pool).token1()
);
rewards.push(token0);
rewards.push(token1);
(isReward[token0], isReward[token1], isReward[xrex]) = (
true,
true,
true
);
/// @dev if token0 and token1 aren't rex add rex in the records
if (token0 != rex && token1 != rex) {
rewards.push(rex);
isReward[rex] = true;
}
for (uint256 i; i < rewards.length; i++) {
emit RewardAdded(rewards[i]);
}
}
constructor() {
_disableInitializers();
}
function _blockTimestamp() internal view virtual returns (uint256) {
return block.timestamp;
}
/// @inheritdoc IGaugeV3
function left(address token) external view override returns (uint256) {
uint256 period = _blockTimestamp() / WEEK;
uint256 remainingTime = ((period + 1) * WEEK) - _blockTimestamp();
return (tokenTotalSupplyByPeriod[period][token] * remainingTime) / WEEK;
}
/// @inheritdoc IGaugeV3
function rewardRate(address token) external view returns (uint256) {
uint256 period = _blockTimestamp() / WEEK;
return (tokenTotalSupplyByPeriod[period][token] / WEEK);
}
/// @inheritdoc IGaugeV3
function getRewardTokens() external view override returns (address[] memory) {
return rewards;
}
/// @inheritdoc IGaugeV3
function positionHash(address owner, uint256 index, int24 tickLower, int24 tickUpper)
public
pure
returns (bytes32)
{
return keccak256(abi.encodePacked(owner, index, tickLower, tickUpper));
}
/// @inheritdoc IGaugeV3
function notifyRewardAmount(
address token,
uint256 amount
) external override pushFees lock {
require(amount > 0, Errors.NOT_GT_ZERO(amount));
require(isReward[token], Errors.NOT_WHITELISTED(token));
IRamsesV3Pool(pool)._advancePeriod();
uint256 period = _blockTimestamp() / WEEK;
uint256 balanceBefore = IERC20(token).balanceOf(address(this));
IERC20(token).safeTransferFrom(msg.sender, address(this), amount);
uint256 balanceAfter = IERC20(token).balanceOf(address(this));
amount = balanceAfter - balanceBefore;
tokenTotalSupplyByPeriod[period][token] += amount;
emit NotifyReward(msg.sender, token, amount, period);
}
/// @inheritdoc IGaugeV3
function notifyRewardAmountNextPeriod(address token, uint256 amount) external lock {
require(amount > 0, Errors.NOT_GT_ZERO(amount));
require(isReward[token], Errors.NOT_WHITELISTED(token));
uint256 period = (_blockTimestamp() / WEEK) + 1;
uint256 balanceBefore = IERC20(token).balanceOf(address(this));
IERC20(token).safeTransferFrom(msg.sender, address(this), amount);
uint256 balanceAfter = IERC20(token).balanceOf(address(this));
amount = balanceAfter - balanceBefore;
tokenTotalSupplyByPeriod[period][token] += amount;
emit NotifyReward(msg.sender, token, amount, period);
}
/// @inheritdoc IGaugeV3
function notifyRewardAmountForPeriod(address token, uint256 amount, uint256 period) external lock {
require(amount > 0, Errors.NOT_GT_ZERO(amount));
require(isReward[token], Errors.NOT_WHITELISTED(token));
require(period > _blockTimestamp() / WEEK, Errors.CANT_CLAIM_FUTURE());
uint256 balanceBefore = IERC20(token).balanceOf(address(this));
IERC20(token).safeTransferFrom(msg.sender, address(this), amount);
uint256 balanceAfter = IERC20(token).balanceOf(address(this));
amount = balanceAfter - balanceBefore;
tokenTotalSupplyByPeriod[period][token] += amount;
emit NotifyReward(msg.sender, token, amount, period);
}
/// @inheritdoc IGaugeV3
function earned(address token, uint256 tokenId) external view returns (uint256 reward) {
INonfungiblePositionManager _nfpManager = nfpManager;
(,,, int24 tickLower, int24 tickUpper,,,,,) = _nfpManager.positions(tokenId);
bytes32 _positionHash = positionHash(address(_nfpManager), tokenId, tickLower, tickUpper);
uint256 lastClaim = Math.max(lastClaimByToken[token][_positionHash], firstPeriod);
uint256 currentPeriod = _blockTimestamp() / WEEK;
for (uint256 period = lastClaim; period <= currentPeriod; ++period) {
reward += periodEarned(period, token, address(_nfpManager), tokenId, tickLower, tickUpper);
}
}
/// @inheritdoc IGaugeV3
function periodEarned(uint256 period, address token, uint256 tokenId) public view override returns (uint256) {
INonfungiblePositionManager _nfpManager = nfpManager;
(,,, int24 tickLower, int24 tickUpper,,,,,) = _nfpManager.positions(tokenId);
return periodEarned(period, token, address(_nfpManager), tokenId, tickLower, tickUpper);
}
/// @inheritdoc IGaugeV3
function periodEarned(uint256 period, address token, address owner, uint256 index, int24 tickLower, int24 tickUpper)
public
view
returns (uint256 amount)
{
(bool success, bytes memory data) = address(this).staticcall(
abi.encodeCall(this.cachePeriodEarned, (period, token, owner, index, tickLower, tickUpper, false))
);
if (!success) {
return 0;
}
return abi.decode(data, (uint256));
}
/// @inheritdoc IGaugeV3
/// @dev used by getReward() and saves gas by saving states
function cachePeriodEarned(
uint256 period,
address token,
address owner,
uint256 index,
int24 tickLower,
int24 tickUpper,
bool caching
) public override returns (uint256 amount) {
uint256 periodSecondsInsideX96;
bytes32 _positionHash = positionHash(owner, index, tickLower, tickUpper);
/// @dev get seconds from pool if not already written into storage
if (!periodAmountsWritten[period][_positionHash]) {
(bool success, bytes memory data) = address(pool).staticcall(
abi.encodeCall(
IRamsesV3PoolState.positionPeriodSecondsInRange, (period, owner, index, tickLower, tickUpper)
)
);
if (!success) {
return 0;
}
(periodSecondsInsideX96) = abi.decode(data, (uint256));
if (period < _blockTimestamp() / WEEK && caching) {
periodAmountsWritten[period][_positionHash] = true;
periodNfpSecondsX96[period][_positionHash] = periodSecondsInsideX96;
}
} else {
periodSecondsInsideX96 = periodNfpSecondsX96[period][_positionHash];
}
amount = FullMath.mulDiv(tokenTotalSupplyByPeriod[period][token], periodSecondsInsideX96, WEEK << 96);
uint256 claimed = periodClaimedAmount[period][_positionHash][token];
if (amount >= claimed) {
amount -= claimed;
} else {
amount = 0;
}
return amount;
}
/// @inheritdoc IGaugeV3
function getPeriodReward(uint256 period, address[] calldata tokens, uint256 tokenId, address receiver)
external
override
lock
{
require(period <= _blockTimestamp() / WEEK, Errors.CANT_CLAIM_FUTURE());
INonfungiblePositionManager _nfpManager = nfpManager;
address owner = _nfpManager.ownerOf(tokenId);
address operator = _nfpManager.getApproved(tokenId);
/// @dev check if owner, operator, or approved for all
require(
msg.sender == owner || msg.sender == operator || _nfpManager.isApprovedForAll(owner, msg.sender),
Errors.NOT_AUTHORIZED(msg.sender)
);
(,,, int24 tickLower, int24 tickUpper,,,,,) = _nfpManager.positions(tokenId);
bytes32 _positionHash = positionHash(address(_nfpManager), tokenId, tickLower, tickUpper);
for (uint256 i = 0; i < tokens.length; ++i) {
if (period < _blockTimestamp() / WEEK) {
lastClaimByToken[tokens[i]][_positionHash] = period;
}
_getReward(period, tokens[i], address(_nfpManager), tokenId, tickLower, tickUpper, _positionHash, receiver);
}
}
/// @inheritdoc IGaugeV3
function getPeriodReward(
uint256 period,
address[] calldata tokens,
address owner,
uint256 index,
int24 tickLower,
int24 tickUpper,
address receiver
) external override lock {
require(msg.sender == owner, Errors.NOT_AUTHORIZED(msg.sender));
bytes32 _positionHash = positionHash(owner, index, tickLower, tickUpper);
for (uint256 i = 0; i < tokens.length; ++i) {
if (period < _blockTimestamp() / WEEK) {
lastClaimByToken[tokens[i]][_positionHash] = period;
}
_getReward(period, tokens[i], owner, index, tickLower, tickUpper, _positionHash, receiver);
}
}
/// @inheritdoc IGaugeV3
function getReward(uint256[] calldata tokenIds, address[] memory tokens) external {
uint256 length = tokenIds.length;
for (uint256 i = 0; i < length; ++i) {
getReward(tokenIds[i], tokens);
}
}
/// @inheritdoc IGaugeV3
function getReward(uint256 tokenId, address[] memory tokens) public lock {
INonfungiblePositionManager _nfpManager = nfpManager;
address owner = _nfpManager.ownerOf(tokenId);
address operator = _nfpManager.getApproved(tokenId);
/// @dev check if owner, operator, or approved for all
require(
msg.sender == owner || msg.sender == operator || _nfpManager.isApprovedForAll(owner, msg.sender),
Errors.NOT_AUTHORIZED(msg.sender)
);
(,,, int24 tickLower, int24 tickUpper,,,,,) = _nfpManager.positions(tokenId);
_getAllRewards(address(_nfpManager), tokenId, tickLower, tickUpper, tokens, msg.sender);
}
/// @inheritdoc IGaugeV3
function getRewardForOwner(uint256 tokenId, address[] memory tokens) external lock {
require(msg.sender == voter || msg.sender == address(nfpManager), Errors.NOT_AUTHORIZED(msg.sender));
INonfungiblePositionManager _nfpManager = nfpManager;
address owner = _nfpManager.ownerOf(tokenId);
(,,, int24 tickLower, int24 tickUpper,,,,,) = _nfpManager.positions(tokenId);
_getAllRewards(address(_nfpManager), tokenId, tickLower, tickUpper, tokens, owner);
}
function getReward(
address owner,
uint256 index,
int24 tickLower,
int24 tickUpper,
address[] memory tokens,
address receiver
) external lock {
require(msg.sender == owner, Errors.NOT_AUTHORIZED(msg.sender));
_getAllRewards(owner, index, tickLower, tickUpper, tokens, receiver);
}
function _getAllRewards(
address owner,
uint256 index,
int24 tickLower,
int24 tickUpper,
address[] memory tokens,
address receiver
) internal {
bytes32 _positionHash = positionHash(owner, index, tickLower, tickUpper);
uint256 currentPeriod = _blockTimestamp() / WEEK;
uint256 lastClaim;
for (uint256 i = 0; i < tokens.length; ++i) {
lastClaim = Math.max(lastClaimByToken[tokens[i]][_positionHash], firstPeriod);
for (uint256 period = lastClaim; period <= currentPeriod; ++period) {
_getReward(period, tokens[i], owner, index, tickLower, tickUpper, _positionHash, receiver);
}
lastClaimByToken[tokens[i]][_positionHash] = currentPeriod - 1;
}
}
function _getReward(
uint256 period,
address token,
address owner,
uint256 index,
int24 tickLower,
int24 tickUpper,
bytes32 _positionHash,
address receiver
) internal {
uint256 _reward = cachePeriodEarned(period, token, owner, index, tickLower, tickUpper, true);
if (_reward > 0) {
periodClaimedAmount[period][_positionHash][token] += _reward;
IERC20(token).safeTransfer(receiver, _reward);
emit ClaimRewards(period, _positionHash, receiver, token, _reward);
}
}
function addRewards(address reward) external {
require(msg.sender == voter, Errors.NOT_VOTER(msg.sender));
if (!isReward[reward]) {
rewards.push(reward);
isReward[reward] = true;
emit RewardAdded(reward);
}
}
function removeRewards(address reward) external {
require(msg.sender == voter, Errors.NOT_VOTER(msg.sender));
if (isReward[reward]) {
uint256 idx;
for (uint256 i; i < rewards.length; ++i) {
if (rewards[i] == reward) {
idx = i;
break;
}
}
for (uint256 i = idx; i < rewards.length - 1; ++i) {
rewards[i] = rewards[i + 1];
}
rewards.pop();
isReward[reward] = false;
emit RewardRemoved(reward);
}
}
}// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity ^0.8.0;
import {BeaconProxy} from "@openzeppelin/contracts/proxy/beacon/BeaconProxy.sol";
import {Errors} from "contracts/libraries/Errors.sol";
import {IVoter} from "contracts/interfaces/IVoter.sol";
import {IClGaugeFactory} from "contracts/CL/gauge/interfaces/IClGaugeFactory.sol";
import {GaugeV3} from "contracts/CL/gauge/GaugeV3.sol";
/// @title Canonical CL gauge factory
/// @notice Deploys CL gauges
contract ClGaugeFactory is IClGaugeFactory {
/// @inheritdoc IClGaugeFactory
address public voter;
/// @inheritdoc IClGaugeFactory
address public feeCollector;
/// @inheritdoc IClGaugeFactory
address public nfpManager;
address public implementation;
/// @inheritdoc IClGaugeFactory
mapping(address => address) public override getGauge;
constructor(address _nfpManager, address _voter, address _feeCollector) {
nfpManager = _nfpManager;
voter = _voter;
feeCollector = _feeCollector;
}
/// @inheritdoc IClGaugeFactory
function createGauge(address pool) external override returns (address gauge) {
require(msg.sender == voter, Errors.NOT_AUTHORIZED(msg.sender));
require(getGauge[pool] == address(0), Errors.GAUGE_EXISTS(pool));
if (implementation == address(0)) {
require(IVoter(voter).ram() != address(0), Errors.NOT_INIT());
implementation = address(new GaugeV3());
emit Upgraded(implementation);
}
gauge = address(
new BeaconProxy(address(this), abi.encodeWithSelector(GaugeV3.initialize.selector, voter, nfpManager, feeCollector, pool))
);
getGauge[pool] = gauge;
emit GaugeCreated(pool, gauge);
}
function setNfpManager(address _nfpManager) external {
/// @dev authorize voter instead of accessHub since this is handled as part of voter.setNfpManager
require(msg.sender == voter, Errors.NOT_AUTHORIZED(msg.sender));
emit NfpManagerChanged(_nfpManager, nfpManager);
nfpManager = _nfpManager;
}
function setVoter(address _voter) external {
require(msg.sender == IVoter(voter).accessHub(), Errors.NOT_AUTHORIZED(msg.sender));
emit VoterChanged(_voter, voter);
voter = _voter;
}
function setFeeCollector(address _feeCollector) external {
require(msg.sender == IVoter(voter).accessHub(), Errors.NOT_AUTHORIZED(msg.sender));
emit FeeCollectorChanged(_feeCollector, feeCollector);
feeCollector = _feeCollector;
}
function setImplementation(address _newImplementation) external {
require(msg.sender == IVoter(voter).accessHub(), Errors.NOT_AUTHORIZED(msg.sender));
if (_newImplementation != implementation) {
implementation = _newImplementation;
emit Upgraded(_newImplementation);
}
}
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
/// @title Central Errors Library
/// @notice Contains all custom errors used across the protocol
/// @dev Centralized error definitions to prevent redundancy
library Errors {
/*//////////////////////////////////////////////////////////////
VOTER ERRORS
//////////////////////////////////////////////////////////////*/
/// @notice Thrown when attempting to interact with an already active gauge
/// @param gauge The address of the gauge
error ACTIVE_GAUGE(address gauge);
/// @notice Thrown when attempting to interact with an inactive gauge
/// @param gauge The address of the gauge
error GAUGE_INACTIVE(address gauge);
/// @notice Thrown when attempting to whitelist an already whitelisted token
/// @param token The address of the token
error ALREADY_WHITELISTED(address token);
/// @notice Thrown when caller is not authorized to perform an action
/// @param caller The address of the unauthorized caller
error NOT_AUTHORIZED(address caller);
/// @notice Thrown when token is not whitelisted
/// @param token The address of the non-whitelisted token
error NOT_WHITELISTED(address token);
/// @notice Thrown when both tokens in a pair are not whitelisted
error BOTH_NOT_WHITELISTED();
/// @notice Thrown when address is not a valid pool
/// @param pool The invalid pool address
error NOT_POOL(address pool);
/// @notice Thrown when contract is not initialized
error NOT_INIT();
/// @notice Thrown when array lengths don't match
error LENGTH_MISMATCH();
/// @notice Thrown when pool doesn't have an associated gauge
/// @param pool The address of the pool
error NO_GAUGE(address pool);
/// @notice Thrown when rewards are already distributed for a period
/// @param gauge The gauge address
/// @param period The distribution period
error ALREADY_DISTRIBUTED(address gauge, uint256 period);
/// @notice Thrown when attempting to vote with zero amount
/// @param pool The pool address
error ZERO_VOTE(address pool);
/// @notice Thrown when ratio exceeds maximum allowed
/// @param _xRatio The excessive ratio value
error RATIO_TOO_HIGH(uint256 _xRatio);
/// @notice Thrown when vote operation fails
error VOTE_UNSUCCESSFUL();
/*//////////////////////////////////////////////////////////////
GAUGE V3 ERRORS
//////////////////////////////////////////////////////////////*/
/// @notice Thrown when the pool already has a gauge
/// @param pool The address of the pool
error GAUGE_EXISTS(address pool);
/// @notice Thrown when caller is not the voter
/// @param caller The address of the invalid caller
error NOT_VOTER(address caller);
/// @notice Thrown when amount is not greater than zero
/// @param amt The invalid amount
error NOT_GT_ZERO(uint256 amt);
/// @notice Thrown when attempting to claim future rewards
error CANT_CLAIM_FUTURE();
/// @notice Throw when gauge can't determine if using secondsInRange from the pool is safe
error NEED_TEAM_TO_UPDATE();
/*//////////////////////////////////////////////////////////////
GAUGE ERRORS
//////////////////////////////////////////////////////////////*/
/// @notice Thrown when amount is zero
error ZERO_AMOUNT();
/// @notice Thrown when stake notification fails
error CANT_NOTIFY_STAKE();
/// @notice Thrown when reward amount is too high
error REWARD_TOO_HIGH();
/// @notice Thrown when amount exceeds remaining balance
/// @param amount The requested amount
/// @param remaining The remaining balance
error NOT_GREATER_THAN_REMAINING(uint256 amount, uint256 remaining);
/// @notice Thrown when token operation fails
/// @param token The address of the problematic token
error TOKEN_ERROR(address token);
/// @notice Thrown when an address is not an NfpManager
error NOT_NFP_MANAGER(address nfpManager);
/*//////////////////////////////////////////////////////////////
FEE DISTRIBUTOR ERRORS
//////////////////////////////////////////////////////////////*/
/// @notice Thrown when period is not finalized
/// @param period The unfinalized period
error NOT_FINALIZED(uint256 period);
/// @notice Thrown when the destination of a redirect is not a feeDistributor
/// @param destination Destination of the redirect
error NOT_FEE_DISTRIBUTOR(address destination);
/// @notice Thrown when the destination of a redirect's pool/pair has completely different tokens
error DIFFERENT_DESTINATION_TOKENS();
/*//////////////////////////////////////////////////////////////
PAIR ERRORS
//////////////////////////////////////////////////////////////*/
/// @notice Thrown when ratio is unstable
error UNSTABLE_RATIO();
/// @notice Thrown when safe transfer fails
error SAFE_TRANSFER_FAILED();
/// @notice Thrown on arithmetic overflow
error OVERFLOW();
/// @notice Thrown when skim operation is disabled
error SKIM_DISABLED();
/// @notice Thrown when insufficient liquidity is minted
error INSUFFICIENT_LIQUIDITY_MINTED();
/// @notice Thrown when insufficient liquidity is burned
error INSUFFICIENT_LIQUIDITY_BURNED();
/// @notice Thrown when output amount is insufficient
error INSUFFICIENT_OUTPUT_AMOUNT();
/// @notice Thrown when input amount is insufficient
error INSUFFICIENT_INPUT_AMOUNT();
/// @notice Generic insufficient liquidity error
error INSUFFICIENT_LIQUIDITY();
/// @notice Invalid transfer error
error INVALID_TRANSFER();
/// @notice K value error in AMM
error K();
/*//////////////////////////////////////////////////////////////
PAIR FACTORY ERRORS
//////////////////////////////////////////////////////////////*/
/// @notice Thrown when fee is too high
error FEE_TOO_HIGH();
/// @notice Thrown when fee is zero
error ZERO_FEE();
/// @notice Thrown when token assortment is invalid
error INVALID_ASSORTMENT();
/// @notice Thrown when address is zero
error ZERO_ADDRESS();
/// @notice Thrown when pair already exists
error PAIR_EXISTS();
/// @notice Thrown when fee split is invalid
error INVALID_FEE_SPLIT();
/*//////////////////////////////////////////////////////////////
FEE RECIPIENT FACTORY ERRORS
//////////////////////////////////////////////////////////////*/
/// @notice Thrown when treasury fee is invalid
error INVALID_TREASURY_FEE();
/*//////////////////////////////////////////////////////////////
ROUTER ERRORS
//////////////////////////////////////////////////////////////*/
/// @notice Thrown when deadline has expired
error EXPIRED();
/// @notice Thrown when tokens are identical
error IDENTICAL();
/// @notice Thrown when amount is insufficient
error INSUFFICIENT_AMOUNT();
/// @notice Thrown when path is invalid
error INVALID_PATH();
/// @notice Thrown when token B amount is insufficient
error INSUFFICIENT_B_AMOUNT();
/// @notice Thrown when token A amount is insufficient
error INSUFFICIENT_A_AMOUNT();
/// @notice Thrown when input amount is excessive
error EXCESSIVE_INPUT_AMOUNT();
/// @notice Thrown when ETH transfer fails
error ETH_TRANSFER_FAILED();
/// @notice Thrown when reserves are invalid
error INVALID_RESERVES();
/*//////////////////////////////////////////////////////////////
MINTER ERRORS
//////////////////////////////////////////////////////////////*/
/// @notice Thrown when epoch 0 has already started
error STARTED();
/// @notice Thrown when emissions haven't started
error EMISSIONS_NOT_STARTED();
/// @notice Thrown when deviation is too high
error TOO_HIGH();
/// @notice Thrown when no value change detected
error NO_CHANGE();
/// @notice Thrown when updating emissions in same period
error SAME_PERIOD();
/// @notice Thrown when contract setup is invalid
error INVALID_CONTRACT();
/// @notice Thrown when legacy factory doesn't have feeSplitWhenNoGauge on
error FEE_SPLIT_WHEN_NO_GAUGE_IS_OFF();
/*//////////////////////////////////////////////////////////////
ACCESS HUB ERRORS
//////////////////////////////////////////////////////////////*/
/// @notice Thrown when addresses are identical
error SAME_ADDRESS();
/// @notice Thrown when caller is not timelock
/// @param caller The invalid caller address
error NOT_TIMELOCK(address caller);
/// @notice Thrown when manual execution fails
/// @param reason The failure reason
error MANUAL_EXECUTION_FAILURE(bytes reason);
/// @notice Thrown when kick operation is forbidden
/// @param target The target address
error KICK_FORBIDDEN(address target);
/// @notice Thrown when the function called on AccessHub is not found
error FUNCTION_NOT_FOUND();
/// @notice Thrown when the expansion pack can't be added
error FAILED_TO_ADD();
/// @notice Thrown when the expansion pack can't be removed
error FAILED_TO_REMOVE();
/// @notice Throw when someone other than x33Adapter calls rebaseX33Callback
error NOT_X33_ADAPTER();
/*//////////////////////////////////////////////////////////////
VOTE MODULE ERRORS
//////////////////////////////////////////////////////////////*/
/// @notice Thrown when caller is not xRam
error NOT_XRAM();
/// @notice Thrown when cooldown period is still active
error COOLDOWN_ACTIVE();
/// @notice Thrown when caller is not vote module
error NOT_VOTEMODULE();
/// @notice Thrown when caller is unauthorized
error UNAUTHORIZED();
/// @notice Thrown when caller is not access hub
error NOT_ACCESSHUB();
/// @notice Thrown when address is invalid
error INVALID_ADDRESS();
/*//////////////////////////////////////////////////////////////
X33 ERRORS
//////////////////////////////////////////////////////////////*/
/// @notice Thrown when value is zero
error ZERO();
/// @notice Thrown when amount is insufficient
error NOT_ENOUGH();
/// @notice Thrown when value doesn't conform to scale
/// @param value The non-conforming value
error NOT_CONFORMED_TO_SCALE(uint256 value);
/// @notice Thrown when contract is locked
error LOCKED();
/// @notice Thrown when rebase is in progress
error REBASE_IN_PROGRESS();
/// @notice Thrown when aggregator reverts
/// @param reason The revert reason
error AGGREGATOR_REVERTED(bytes reason);
/// @notice Thrown when output amount is too low
/// @param amount The insufficient amount
error AMOUNT_OUT_TOO_LOW(uint256 amount);
/// @notice Thrown when aggregator is not whitelisted
/// @param aggregator The non-whitelisted aggregator address
error AGGREGATOR_NOT_WHITELISTED(address aggregator);
/// @notice Thrown when token is forbidden
/// @param token The forbidden token address
error FORBIDDEN_TOKEN(address token);
/*//////////////////////////////////////////////////////////////
XRAM ERRORS
//////////////////////////////////////////////////////////////*/
/// @notice Thrown when caller is not minter
error NOT_MINTER();
/// @notice Thrown when no vest exists
error NO_VEST();
/// @notice Thrown when already exempt
error ALREADY_EXEMPT();
/// @notice Thrown when not exempt
error NOT_EXEMPT();
/// @notice Thrown when rescue operation is not allowed
error CANT_RESCUE();
/// @notice Thrown when array lengths mismatch
error ARRAY_LENGTHS();
/// @notice Thrown when vesting periods overlap
error VEST_OVERLAP();
/*//////////////////////////////////////////////////////////////
V3 FACTORY ERRORS
//////////////////////////////////////////////////////////////*/
/// @notice Thrown when tokens are identical
error IDENTICAL_TOKENS();
/// @notice Thrown when fee is too large
error FEE_TOO_LARGE();
/// @notice Address zero error
error ADDRESS_ZERO();
/// @notice Fee zero error
error F0();
/// @notice Thrown when value is out of bounds
/// @param value The out of bounds value
error OOB(uint8 value);
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.1.0) (proxy/transparent/TransparentUpgradeableProxy.sol)
pragma solidity ^0.8.20;
import {ERC1967Utils} from "../ERC1967/ERC1967Utils.sol";
import {ERC1967Proxy} from "../ERC1967/ERC1967Proxy.sol";
import {IERC1967} from "../../interfaces/IERC1967.sol";
import {ProxyAdmin} from "./ProxyAdmin.sol";
/**
* @dev Interface for {TransparentUpgradeableProxy}. In order to implement transparency, {TransparentUpgradeableProxy}
* does not implement this interface directly, and its upgradeability mechanism is implemented by an internal dispatch
* mechanism. The compiler is unaware that these functions are implemented by {TransparentUpgradeableProxy} and will not
* include them in the ABI so this interface must be used to interact with it.
*/
interface ITransparentUpgradeableProxy is IERC1967 {
/// @dev See {UUPSUpgradeable-upgradeToAndCall}
function upgradeToAndCall(address newImplementation, bytes calldata data) external payable;
}
/**
* @dev This contract implements a proxy that is upgradeable through an associated {ProxyAdmin} instance.
*
* To avoid https://medium.com/nomic-labs-blog/malicious-backdoors-in-ethereum-proxies-62629adf3357[proxy selector
* clashing], which can potentially be used in an attack, this contract uses the
* https://blog.openzeppelin.com/the-transparent-proxy-pattern/[transparent proxy pattern]. This pattern implies two
* things that go hand in hand:
*
* 1. If any account other than the admin calls the proxy, the call will be forwarded to the implementation, even if
* that call matches the {ITransparentUpgradeableProxy-upgradeToAndCall} function exposed by the proxy itself.
* 2. If the admin calls the proxy, it can call the `upgradeToAndCall` function but any other call won't be forwarded to
* the implementation. If the admin tries to call a function on the implementation it will fail with an error indicating
* the proxy admin cannot fallback to the target implementation.
*
* These properties mean that the admin account can only be used for upgrading the proxy, so it's best if it's a
* dedicated account that is not used for anything else. This will avoid headaches due to sudden errors when trying to
* call a function from the proxy implementation. For this reason, the proxy deploys an instance of {ProxyAdmin} and
* allows upgrades only if they come through it. You should think of the `ProxyAdmin` instance as the administrative
* interface of the proxy, including the ability to change who can trigger upgrades by transferring ownership.
*
* NOTE: The real interface of this proxy is that defined in `ITransparentUpgradeableProxy`. This contract does not
* inherit from that interface, and instead `upgradeToAndCall` is implicitly implemented using a custom dispatch
* mechanism in `_fallback`. Consequently, the compiler will not produce an ABI for this contract. This is necessary to
* fully implement transparency without decoding reverts caused by selector clashes between the proxy and the
* implementation.
*
* NOTE: This proxy does not inherit from {Context} deliberately. The {ProxyAdmin} of this contract won't send a
* meta-transaction in any way, and any other meta-transaction setup should be made in the implementation contract.
*
* IMPORTANT: This contract avoids unnecessary storage reads by setting the admin only during construction as an
* immutable variable, preventing any changes thereafter. However, the admin slot defined in ERC-1967 can still be
* overwritten by the implementation logic pointed to by this proxy. In such cases, the contract may end up in an
* undesirable state where the admin slot is different from the actual admin. Relying on the value of the admin slot
* is generally fine if the implementation is trusted.
*
* WARNING: It is not recommended to extend this contract to add additional external functions. If you do so, the
* compiler will not check that there are no selector conflicts, due to the note above. A selector clash between any new
* function and the functions declared in {ITransparentUpgradeableProxy} will be resolved in favor of the new one. This
* could render the `upgradeToAndCall` function inaccessible, preventing upgradeability and compromising transparency.
*/
contract TransparentUpgradeableProxy is ERC1967Proxy {
// An immutable address for the admin to avoid unnecessary SLOADs before each call
// at the expense of removing the ability to change the admin once it's set.
// This is acceptable if the admin is always a ProxyAdmin instance or similar contract
// with its own ability to transfer the permissions to another account.
address private immutable _admin;
/**
* @dev The proxy caller is the current admin, and can't fallback to the proxy target.
*/
error ProxyDeniedAdminAccess();
/**
* @dev Initializes an upgradeable proxy managed by an instance of a {ProxyAdmin} with an `initialOwner`,
* backed by the implementation at `_logic`, and optionally initialized with `_data` as explained in
* {ERC1967Proxy-constructor}.
*/
constructor(address _logic, address initialOwner, bytes memory _data) payable ERC1967Proxy(_logic, _data) {
_admin = address(new ProxyAdmin(initialOwner));
// Set the storage value and emit an event for ERC-1967 compatibility
ERC1967Utils.changeAdmin(_proxyAdmin());
}
/**
* @dev Returns the admin of this proxy.
*/
function _proxyAdmin() internal view virtual returns (address) {
return _admin;
}
/**
* @dev If caller is the admin process the call internally, otherwise transparently fallback to the proxy behavior.
*/
function _fallback() internal virtual override {
if (msg.sender == _proxyAdmin()) {
if (msg.sig != ITransparentUpgradeableProxy.upgradeToAndCall.selector) {
revert ProxyDeniedAdminAccess();
} else {
_dispatchUpgradeToAndCall();
}
} else {
super._fallback();
}
}
/**
* @dev Upgrade the implementation of the proxy. See {ERC1967Utils-upgradeToAndCall}.
*
* Requirements:
*
* - If `data` is empty, `msg.value` must be zero.
*/
function _dispatchUpgradeToAndCall() private {
(address newImplementation, bytes memory data) = abi.decode(msg.data[4:], (address, bytes));
ERC1967Utils.upgradeToAndCall(newImplementation, data);
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.1.0) (access/extensions/IAccessControlEnumerable.sol)
pragma solidity ^0.8.20;
import {IAccessControl} from "../IAccessControl.sol";
/**
* @dev External interface of AccessControlEnumerable declared to support ERC-165 detection.
*/
interface IAccessControlEnumerable is IAccessControl {
/**
* @dev Returns one of the accounts that have `role`. `index` must be a
* value between 0 and {getRoleMemberCount}, non-inclusive.
*
* Role bearers are not sorted in any particular way, and their ordering may
* change at any point.
*
* WARNING: When using {getRoleMember} and {getRoleMemberCount}, make sure
* you perform all queries on the same block. See the following
* https://forum.openzeppelin.com/t/iterating-over-elements-on-enumerableset-in-openzeppelin-contracts/2296[forum post]
* for more information.
*/
function getRoleMember(bytes32 role, uint256 index) external view returns (address);
/**
* @dev Returns the number of accounts that have `role`. Can be used
* together with {getRoleMember} to enumerate all bearers of a role.
*/
function getRoleMemberCount(bytes32 role) external view returns (uint256);
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (access/AccessControl.sol)
pragma solidity ^0.8.20;
import {IAccessControl} from "@openzeppelin/contracts/access/IAccessControl.sol";
import {ContextUpgradeable} from "../utils/ContextUpgradeable.sol";
import {ERC165Upgradeable} from "../utils/introspection/ERC165Upgradeable.sol";
import {Initializable} from "../proxy/utils/Initializable.sol";
/**
* @dev Contract module that allows children to implement role-based access
* control mechanisms. This is a lightweight version that doesn't allow enumerating role
* members except through off-chain means by accessing the contract event logs. Some
* applications may benefit from on-chain enumerability, for those cases see
* {AccessControlEnumerable}.
*
* Roles are referred to by their `bytes32` identifier. These should be exposed
* in the external API and be unique. The best way to achieve this is by
* using `public constant` hash digests:
*
* ```solidity
* bytes32 public constant MY_ROLE = keccak256("MY_ROLE");
* ```
*
* Roles can be used to represent a set of permissions. To restrict access to a
* function call, use {hasRole}:
*
* ```solidity
* function foo() public {
* require(hasRole(MY_ROLE, msg.sender));
* ...
* }
* ```
*
* Roles can be granted and revoked dynamically via the {grantRole} and
* {revokeRole} functions. Each role has an associated admin role, and only
* accounts that have a role's admin role can call {grantRole} and {revokeRole}.
*
* By default, the admin role for all roles is `DEFAULT_ADMIN_ROLE`, which means
* that only accounts with this role will be able to grant or revoke other
* roles. More complex role relationships can be created by using
* {_setRoleAdmin}.
*
* WARNING: The `DEFAULT_ADMIN_ROLE` is also its own admin: it has permission to
* grant and revoke this role. Extra precautions should be taken to secure
* accounts that have been granted it. We recommend using {AccessControlDefaultAdminRules}
* to enforce additional security measures for this role.
*/
abstract contract AccessControlUpgradeable is Initializable, ContextUpgradeable, IAccessControl, ERC165Upgradeable {
struct RoleData {
mapping(address account => bool) hasRole;
bytes32 adminRole;
}
bytes32 public constant DEFAULT_ADMIN_ROLE = 0x00;
/// @custom:storage-location erc7201:openzeppelin.storage.AccessControl
struct AccessControlStorage {
mapping(bytes32 role => RoleData) _roles;
}
// keccak256(abi.encode(uint256(keccak256("openzeppelin.storage.AccessControl")) - 1)) & ~bytes32(uint256(0xff))
bytes32 private constant AccessControlStorageLocation = 0x02dd7bc7dec4dceedda775e58dd541e08a116c6c53815c0bd028192f7b626800;
function _getAccessControlStorage() private pure returns (AccessControlStorage storage $) {
assembly {
$.slot := AccessControlStorageLocation
}
}
/**
* @dev Modifier that checks that an account has a specific role. Reverts
* with an {AccessControlUnauthorizedAccount} error including the required role.
*/
modifier onlyRole(bytes32 role) {
_checkRole(role);
_;
}
function __AccessControl_init() internal onlyInitializing {
}
function __AccessControl_init_unchained() internal onlyInitializing {
}
/**
* @dev See {IERC165-supportsInterface}.
*/
function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
return interfaceId == type(IAccessControl).interfaceId || super.supportsInterface(interfaceId);
}
/**
* @dev Returns `true` if `account` has been granted `role`.
*/
function hasRole(bytes32 role, address account) public view virtual returns (bool) {
AccessControlStorage storage $ = _getAccessControlStorage();
return $._roles[role].hasRole[account];
}
/**
* @dev Reverts with an {AccessControlUnauthorizedAccount} error if `_msgSender()`
* is missing `role`. Overriding this function changes the behavior of the {onlyRole} modifier.
*/
function _checkRole(bytes32 role) internal view virtual {
_checkRole(role, _msgSender());
}
/**
* @dev Reverts with an {AccessControlUnauthorizedAccount} error if `account`
* is missing `role`.
*/
function _checkRole(bytes32 role, address account) internal view virtual {
if (!hasRole(role, account)) {
revert AccessControlUnauthorizedAccount(account, role);
}
}
/**
* @dev Returns the admin role that controls `role`. See {grantRole} and
* {revokeRole}.
*
* To change a role's admin, use {_setRoleAdmin}.
*/
function getRoleAdmin(bytes32 role) public view virtual returns (bytes32) {
AccessControlStorage storage $ = _getAccessControlStorage();
return $._roles[role].adminRole;
}
/**
* @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.
*
* May emit a {RoleGranted} event.
*/
function grantRole(bytes32 role, address account) public virtual onlyRole(getRoleAdmin(role)) {
_grantRole(role, account);
}
/**
* @dev Revokes `role` from `account`.
*
* If `account` had been granted `role`, emits a {RoleRevoked} event.
*
* Requirements:
*
* - the caller must have ``role``'s admin role.
*
* May emit a {RoleRevoked} event.
*/
function revokeRole(bytes32 role, address account) public virtual onlyRole(getRoleAdmin(role)) {
_revokeRole(role, account);
}
/**
* @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 revoked `role`, emits a {RoleRevoked}
* event.
*
* Requirements:
*
* - the caller must be `callerConfirmation`.
*
* May emit a {RoleRevoked} event.
*/
function renounceRole(bytes32 role, address callerConfirmation) public virtual {
if (callerConfirmation != _msgSender()) {
revert AccessControlBadConfirmation();
}
_revokeRole(role, callerConfirmation);
}
/**
* @dev Sets `adminRole` as ``role``'s admin role.
*
* Emits a {RoleAdminChanged} event.
*/
function _setRoleAdmin(bytes32 role, bytes32 adminRole) internal virtual {
AccessControlStorage storage $ = _getAccessControlStorage();
bytes32 previousAdminRole = getRoleAdmin(role);
$._roles[role].adminRole = adminRole;
emit RoleAdminChanged(role, previousAdminRole, adminRole);
}
/**
* @dev Attempts to grant `role` to `account` and returns a boolean indicating if `role` was granted.
*
* Internal function without access restriction.
*
* May emit a {RoleGranted} event.
*/
function _grantRole(bytes32 role, address account) internal virtual returns (bool) {
AccessControlStorage storage $ = _getAccessControlStorage();
if (!hasRole(role, account)) {
$._roles[role].hasRole[account] = true;
emit RoleGranted(role, account, _msgSender());
return true;
} else {
return false;
}
}
/**
* @dev Attempts to revoke `role` to `account` and returns a boolean indicating if `role` was revoked.
*
* Internal function without access restriction.
*
* May emit a {RoleRevoked} event.
*/
function _revokeRole(bytes32 role, address account) internal virtual returns (bool) {
AccessControlStorage storage $ = _getAccessControlStorage();
if (hasRole(role, account)) {
$._roles[role].hasRole[account] = false;
emit RoleRevoked(role, account, _msgSender());
return true;
} else {
return false;
}
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.1.0) (utils/structs/EnumerableSet.sol)
// This file was procedurally generated from scripts/generate/templates/EnumerableSet.js.
pragma solidity ^0.8.20;
/**
* @dev Library for managing
* https://en.wikipedia.org/wiki/Set_(abstract_data_type)[sets] of primitive
* types.
*
* Sets have the following properties:
*
* - Elements are added, removed, and checked for existence in constant time
* (O(1)).
* - Elements are enumerated in O(n). No guarantees are made on the ordering.
*
* ```solidity
* contract Example {
* // Add the library methods
* using EnumerableSet for EnumerableSet.AddressSet;
*
* // Declare a set state variable
* EnumerableSet.AddressSet private mySet;
* }
* ```
*
* As of v3.3.0, sets of type `bytes32` (`Bytes32Set`), `address` (`AddressSet`)
* and `uint256` (`UintSet`) are supported.
*
* [WARNING]
* ====
* Trying to delete such a structure from storage will likely result in data corruption, rendering the structure
* unusable.
* See https://github.com/ethereum/solidity/pull/11843[ethereum/solidity#11843] for more info.
*
* In order to clean an EnumerableSet, you can either remove all elements one by one or create a fresh instance using an
* array of EnumerableSet.
* ====
*/
library EnumerableSet {
// To implement this library for multiple types with as little code
// repetition as possible, we write it in terms of a generic Set type with
// bytes32 values.
// The Set implementation uses private functions, and user-facing
// implementations (such as AddressSet) are just wrappers around the
// underlying Set.
// This means that we can only create new EnumerableSets for types that fit
// in bytes32.
struct Set {
// Storage of set values
bytes32[] _values;
// Position is the index of the value in the `values` array plus 1.
// Position 0 is used to mean a value is not in the set.
mapping(bytes32 value => uint256) _positions;
}
/**
* @dev Add a value to a set. O(1).
*
* Returns true if the value was added to the set, that is if it was not
* already present.
*/
function _add(Set storage set, bytes32 value) private returns (bool) {
if (!_contains(set, value)) {
set._values.push(value);
// The value is stored at length-1, but we add 1 to all indexes
// and use 0 as a sentinel value
set._positions[value] = set._values.length;
return true;
} else {
return false;
}
}
/**
* @dev Removes a value from a set. O(1).
*
* Returns true if the value was removed from the set, that is if it was
* present.
*/
function _remove(Set storage set, bytes32 value) private returns (bool) {
// We cache the value's position to prevent multiple reads from the same storage slot
uint256 position = set._positions[value];
if (position != 0) {
// Equivalent to contains(set, value)
// To delete an element from the _values array in O(1), we swap the element to delete with the last one in
// the array, and then remove the last element (sometimes called as 'swap and pop').
// This modifies the order of the array, as noted in {at}.
uint256 valueIndex = position - 1;
uint256 lastIndex = set._values.length - 1;
if (valueIndex != lastIndex) {
bytes32 lastValue = set._values[lastIndex];
// Move the lastValue to the index where the value to delete is
set._values[valueIndex] = lastValue;
// Update the tracked position of the lastValue (that was just moved)
set._positions[lastValue] = position;
}
// Delete the slot where the moved value was stored
set._values.pop();
// Delete the tracked position for the deleted slot
delete set._positions[value];
return true;
} else {
return false;
}
}
/**
* @dev Returns true if the value is in the set. O(1).
*/
function _contains(Set storage set, bytes32 value) private view returns (bool) {
return set._positions[value] != 0;
}
/**
* @dev Returns the number of values on the set. O(1).
*/
function _length(Set storage set) private view returns (uint256) {
return set._values.length;
}
/**
* @dev Returns the value stored at position `index` in the set. O(1).
*
* Note that there are no guarantees on the ordering of values inside the
* array, and it may change when more values are added or removed.
*
* Requirements:
*
* - `index` must be strictly less than {length}.
*/
function _at(Set storage set, uint256 index) private view returns (bytes32) {
return set._values[index];
}
/**
* @dev Return the entire set in an array
*
* WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed
* to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that
* this function has an unbounded cost, and using it as part of a state-changing function may render the function
* uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.
*/
function _values(Set storage set) private view returns (bytes32[] memory) {
return set._values;
}
// Bytes32Set
struct Bytes32Set {
Set _inner;
}
/**
* @dev Add a value to a set. O(1).
*
* Returns true if the value was added to the set, that is if it was not
* already present.
*/
function add(Bytes32Set storage set, bytes32 value) internal returns (bool) {
return _add(set._inner, value);
}
/**
* @dev Removes a value from a set. O(1).
*
* Returns true if the value was removed from the set, that is if it was
* present.
*/
function remove(Bytes32Set storage set, bytes32 value) internal returns (bool) {
return _remove(set._inner, value);
}
/**
* @dev Returns true if the value is in the set. O(1).
*/
function contains(Bytes32Set storage set, bytes32 value) internal view returns (bool) {
return _contains(set._inner, value);
}
/**
* @dev Returns the number of values in the set. O(1).
*/
function length(Bytes32Set storage set) internal view returns (uint256) {
return _length(set._inner);
}
/**
* @dev Returns the value stored at position `index` in the set. O(1).
*
* Note that there are no guarantees on the ordering of values inside the
* array, and it may change when more values are added or removed.
*
* Requirements:
*
* - `index` must be strictly less than {length}.
*/
function at(Bytes32Set storage set, uint256 index) internal view returns (bytes32) {
return _at(set._inner, index);
}
/**
* @dev Return the entire set in an array
*
* WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed
* to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that
* this function has an unbounded cost, and using it as part of a state-changing function may render the function
* uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.
*/
function values(Bytes32Set storage set) internal view returns (bytes32[] memory) {
bytes32[] memory store = _values(set._inner);
bytes32[] memory result;
assembly ("memory-safe") {
result := store
}
return result;
}
// AddressSet
struct AddressSet {
Set _inner;
}
/**
* @dev Add a value to a set. O(1).
*
* Returns true if the value was added to the set, that is if it was not
* already present.
*/
function add(AddressSet storage set, address value) internal returns (bool) {
return _add(set._inner, bytes32(uint256(uint160(value))));
}
/**
* @dev Removes a value from a set. O(1).
*
* Returns true if the value was removed from the set, that is if it was
* present.
*/
function remove(AddressSet storage set, address value) internal returns (bool) {
return _remove(set._inner, bytes32(uint256(uint160(value))));
}
/**
* @dev Returns true if the value is in the set. O(1).
*/
function contains(AddressSet storage set, address value) internal view returns (bool) {
return _contains(set._inner, bytes32(uint256(uint160(value))));
}
/**
* @dev Returns the number of values in the set. O(1).
*/
function length(AddressSet storage set) internal view returns (uint256) {
return _length(set._inner);
}
/**
* @dev Returns the value stored at position `index` in the set. O(1).
*
* Note that there are no guarantees on the ordering of values inside the
* array, and it may change when more values are added or removed.
*
* Requirements:
*
* - `index` must be strictly less than {length}.
*/
function at(AddressSet storage set, uint256 index) internal view returns (address) {
return address(uint160(uint256(_at(set._inner, index))));
}
/**
* @dev Return the entire set in an array
*
* WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed
* to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that
* this function has an unbounded cost, and using it as part of a state-changing function may render the function
* uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.
*/
function values(AddressSet storage set) internal view returns (address[] memory) {
bytes32[] memory store = _values(set._inner);
address[] memory result;
assembly ("memory-safe") {
result := store
}
return result;
}
// UintSet
struct UintSet {
Set _inner;
}
/**
* @dev Add a value to a set. O(1).
*
* Returns true if the value was added to the set, that is if it was not
* already present.
*/
function add(UintSet storage set, uint256 value) internal returns (bool) {
return _add(set._inner, bytes32(value));
}
/**
* @dev Removes a value from a set. O(1).
*
* Returns true if the value was removed from the set, that is if it was
* present.
*/
function remove(UintSet storage set, uint256 value) internal returns (bool) {
return _remove(set._inner, bytes32(value));
}
/**
* @dev Returns true if the value is in the set. O(1).
*/
function contains(UintSet storage set, uint256 value) internal view returns (bool) {
return _contains(set._inner, bytes32(value));
}
/**
* @dev Returns the number of values in the set. O(1).
*/
function length(UintSet storage set) internal view returns (uint256) {
return _length(set._inner);
}
/**
* @dev Returns the value stored at position `index` in the set. O(1).
*
* Note that there are no guarantees on the ordering of values inside the
* array, and it may change when more values are added or removed.
*
* Requirements:
*
* - `index` must be strictly less than {length}.
*/
function at(UintSet storage set, uint256 index) internal view returns (uint256) {
return uint256(_at(set._inner, index));
}
/**
* @dev Return the entire set in an array
*
* WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed
* to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that
* this function has an unbounded cost, and using it as part of a state-changing function may render the function
* uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.
*/
function values(UintSet storage set) internal view returns (uint256[] memory) {
bytes32[] memory store = _values(set._inner);
uint256[] memory result;
assembly ("memory-safe") {
result := store
}
return result;
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.1.0) (token/ERC20/IERC20.sol)
pragma solidity ^0.8.20;
/**
* @dev Interface of the ERC-20 standard as defined in the ERC.
*/
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 value of tokens in existence.
*/
function totalSupply() external view returns (uint256);
/**
* @dev Returns the value of tokens owned by `account`.
*/
function balanceOf(address account) external view returns (uint256);
/**
* @dev Moves a `value` amount of 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 value) 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 a `value` amount of tokens 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 value) external returns (bool);
/**
* @dev Moves a `value` amount of tokens from `from` to `to` using the
* allowance mechanism. `value` 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 value) external returns (bool);
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (utils/Pausable.sol)
pragma solidity ^0.8.20;
import {Context} from "../utils/Context.sol";
/**
* @dev Contract module which allows children to implement an emergency stop
* mechanism that can be triggered by an authorized account.
*
* This module is used through inheritance. It will make available the
* modifiers `whenNotPaused` and `whenPaused`, which can be applied to
* the functions of your contract. Note that they will not be pausable by
* simply including this module, only once the modifiers are put in place.
*/
abstract contract Pausable is Context {
bool private _paused;
/**
* @dev Emitted when the pause is triggered by `account`.
*/
event Paused(address account);
/**
* @dev Emitted when the pause is lifted by `account`.
*/
event Unpaused(address account);
/**
* @dev The operation failed because the contract is paused.
*/
error EnforcedPause();
/**
* @dev The operation failed because the contract is not paused.
*/
error ExpectedPause();
/**
* @dev Initializes the contract in unpaused state.
*/
constructor() {
_paused = false;
}
/**
* @dev Modifier to make a function callable only when the contract is not paused.
*
* Requirements:
*
* - The contract must not be paused.
*/
modifier whenNotPaused() {
_requireNotPaused();
_;
}
/**
* @dev Modifier to make a function callable only when the contract is paused.
*
* Requirements:
*
* - The contract must be paused.
*/
modifier whenPaused() {
_requirePaused();
_;
}
/**
* @dev Returns true if the contract is paused, and false otherwise.
*/
function paused() public view virtual returns (bool) {
return _paused;
}
/**
* @dev Throws if the contract is paused.
*/
function _requireNotPaused() internal view virtual {
if (paused()) {
revert EnforcedPause();
}
}
/**
* @dev Throws if the contract is not paused.
*/
function _requirePaused() internal view virtual {
if (!paused()) {
revert ExpectedPause();
}
}
/**
* @dev Triggers stopped state.
*
* Requirements:
*
* - The contract must not be paused.
*/
function _pause() internal virtual whenNotPaused {
_paused = true;
emit Paused(_msgSender());
}
/**
* @dev Returns to normal state.
*
* Requirements:
*
* - The contract must be paused.
*/
function _unpause() internal virtual whenPaused {
_paused = false;
emit Unpaused(_msgSender());
}
}// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity >=0.5.0;
/// @title Pool state that never changes
/// @notice These parameters are fixed for a pool forever, i.e., the methods will always return the same values
interface IRamsesV3PoolImmutables {
/// @notice The contract that deployed the pool, which must adhere to the IRamsesV3Factory interface
/// @return The contract address
function factory() external view returns (address);
/// @notice The first of the two tokens of the pool, sorted by address
/// @return The token contract address
function token0() external view returns (address);
/// @notice The second of the two tokens of the pool, sorted by address
/// @return The token contract address
function token1() external view returns (address);
/// @notice The pool's fee in hundredths of a bip, i.e. 1e-6
/// @return The fee
function fee() external view returns (uint24);
/// @notice The pool tick spacing
/// @dev Ticks can only be used at multiples of this value, minimum of 1 and always positive
/// e.g.: a tickSpacing of 3 means ticks can be initialized every 3rd tick, i.e., ..., -6, -3, 0, 3, 6, ...
/// This value is an int24 to avoid casting even though it is always positive.
/// @return The tick spacing
function tickSpacing() external view returns (int24);
/// @notice The maximum amount of position liquidity that can use any tick in the range
/// @dev This parameter is enforced per tick to prevent liquidity from overflowing a uint128 at any point, and
/// also prevents out-of-range liquidity from being used to prevent adding in-range liquidity to a pool
/// @return The max amount of liquidity per tick
function maxLiquidityPerTick() external view returns (uint128);
}// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity >=0.5.0;
/// @title Pool state that can change
/// @notice These methods compose the pool's state, and can change with any frequency including multiple times
/// per transaction
interface IRamsesV3PoolState {
/// @notice The 0th storage slot in the pool stores many values, and is exposed as a single method to save gas
/// when accessed externally.
/// @return sqrtPriceX96 The current price of the pool as a sqrt(token1/token0) Q64.96 value
/// @return tick The current tick of the pool, i.e. according to the last tick transition that was run.
/// This value may not always be equal to SqrtTickMath.getTickAtSqrtRatio(sqrtPriceX96) if the price is on a tick
/// boundary.
/// @return observationIndex The index of the last oracle observation that was written,
/// @return observationCardinality The current maximum number of observations stored in the pool,
/// @return observationCardinalityNext The next maximum number of observations, to be updated when the observation.
/// @return feeProtocol The protocol fee for both tokens of the pool.
/// Encoded as two 4 bit values, where the protocol fee of token1 is shifted 4 bits and the protocol fee of token0
/// is the lower 4 bits. Used as the denominator of a fraction of the swap fee, e.g. 4 means 1/4th of the swap fee.
/// unlocked Whether the pool is currently locked to reentrancy
function slot0()
external
view
returns (
uint160 sqrtPriceX96,
int24 tick,
uint16 observationIndex,
uint16 observationCardinality,
uint16 observationCardinalityNext,
uint24 feeProtocol,
bool unlocked
);
/// @notice The fee growth as a Q128.128 fees of token0 collected per unit of liquidity for the entire life of the pool
/// @dev This value can overflow the uint256
function feeGrowthGlobal0X128() external view returns (uint256);
/// @notice The fee growth as a Q128.128 fees of token1 collected per unit of liquidity for the entire life of the pool
/// @dev This value can overflow the uint256
function feeGrowthGlobal1X128() external view returns (uint256);
/// @notice Get the accumulated fee growth for the first token in the pool before protocol fees
/// @dev This value can overflow the uint256
function grossFeeGrowthGlobal0X128() external view returns (uint256);
/// @notice Get the accumulated fee growth for the second token in the pool before protocol fees
/// @dev This value can overflow the uint256
function grossFeeGrowthGlobal1X128() external view returns (uint256);
/// @notice The amounts of token0 and token1 that are owed to the protocol
/// @dev Protocol fees will never exceed uint128 max in either token
function protocolFees() external view returns (uint128 token0, uint128 token1);
/// @notice The currently in range liquidity available to the pool
/// @dev This value has no relationship to the total liquidity across all ticks
/// @return The liquidity at the current price of the pool
function liquidity() external view returns (uint128);
/// @notice Look up information about a specific tick in the pool
/// @param tick The tick to look up
/// @return liquidityGross the total amount of position liquidity that uses the pool either as tick lower or
/// tick upper
/// @return liquidityNet how much liquidity changes when the pool price crosses the tick,
/// @return feeGrowthOutside0X128 the fee growth on the other side of the tick from the current tick in token0,
/// @return feeGrowthOutside1X128 the fee growth on the other side of the tick from the current tick in token1,
/// @return tickCumulativeOutside the cumulative tick value on the other side of the tick from the current tick
/// @return secondsPerLiquidityOutsideX128 the seconds spent per liquidity on the other side of the tick from the current tick,
/// @return secondsOutside the seconds spent on the other side of the tick from the current tick,
/// @return initialized Set to true if the tick is initialized, i.e. liquidityGross is greater than 0, otherwise equal to false.
/// Outside values can only be used if the tick is initialized, i.e. if liquidityGross is greater than 0.
/// In addition, these values are only relative and must be used only in comparison to previous snapshots for
/// a specific position.
function ticks(
int24 tick
)
external
view
returns (
uint128 liquidityGross,
int128 liquidityNet,
uint256 feeGrowthOutside0X128,
uint256 feeGrowthOutside1X128,
int56 tickCumulativeOutside,
uint160 secondsPerLiquidityOutsideX128,
uint32 secondsOutside,
bool initialized
);
/// @notice Returns 256 packed tick initialized boolean values. See TickBitmap for more information
function tickBitmap(int16 wordPosition) external view returns (uint256);
/// @notice Returns the information about a position by the position's key
/// @param key The position's key is a hash of a preimage composed by the owner, tickLower and tickUpper
/// @return liquidity The amount of liquidity in the position,
/// @return feeGrowthInside0LastX128 fee growth of token0 inside the tick range as of the last mint/burn/poke,
/// @return feeGrowthInside1LastX128 fee growth of token1 inside the tick range as of the last mint/burn/poke,
/// @return tokensOwed0 the computed amount of token0 owed to the position as of the last mint/burn/poke,
/// @return tokensOwed1 the computed amount of token1 owed to the position as of the last mint/burn/poke
function positions(
bytes32 key
)
external
view
returns (
uint128 liquidity,
uint256 feeGrowthInside0LastX128,
uint256 feeGrowthInside1LastX128,
uint128 tokensOwed0,
uint128 tokensOwed1
);
/// @notice Returns data about a specific observation index
/// @param index The element of the observations array to fetch
/// @dev You most likely want to use #observe() instead of this method to get an observation as of some amount of time
/// ago, rather than at a specific index in the array.
/// @return blockTimestamp The timestamp of the observation,
/// @return tickCumulative the tick multiplied by seconds elapsed for the life of the pool as of the observation timestamp,
/// @return secondsPerLiquidityCumulativeX128 the seconds per in range liquidity for the life of the pool as of the observation timestamp,
/// @return initialized whether the observation has been initialized and the values are safe to use
function observations(
uint256 index
)
external
view
returns (
uint32 blockTimestamp,
int56 tickCumulative,
uint160 secondsPerLiquidityCumulativeX128,
bool initialized
);
/// @notice get the period seconds in range of a specific position
/// @param period the period number
/// @param owner owner address
/// @param index position index
/// @param tickLower lower bound of range
/// @param tickUpper upper bound of range
/// @return periodSecondsInsideX96 seconds the position was not in range for the period
function positionPeriodSecondsInRange(
uint256 period,
address owner,
uint256 index,
int24 tickLower,
int24 tickUpper
) external view returns (uint256 periodSecondsInsideX96);
}// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity >=0.5.0;
/// @title Pool state that is not stored
/// @notice Contains view functions to provide information about the pool that is computed rather than stored on the
/// blockchain. The functions here may have variable gas costs.
interface IRamsesV3PoolDerivedState {
/// @notice Returns the cumulative tick and liquidity as of each timestamp `secondsAgo` from the current block timestamp
/// @dev To get a time weighted average tick or liquidity-in-range, you must call this with two values, one representing
/// the beginning of the period and another for the end of the period. E.g., to get the last hour time-weighted average tick,
/// you must call it with secondsAgos = [3600, 0].
/// @dev The time weighted average tick represents the geometric time weighted average price of the pool, in
/// log base sqrt(1.0001) of token1 / token0. The TickMath library can be used to go from a tick value to a ratio.
/// @param secondsAgos From how long ago each cumulative tick and liquidity value should be returned
/// @return tickCumulatives Cumulative tick values as of each `secondsAgos` from the current block timestamp
/// @return secondsPerLiquidityCumulativeX128s Cumulative seconds per liquidity-in-range value as of each `secondsAgos` from the current block
/// timestamp
function observe(
uint32[] calldata secondsAgos
) external view returns (int56[] memory tickCumulatives, uint160[] memory secondsPerLiquidityCumulativeX128s);
/// @notice Returns a snapshot of the tick cumulative, seconds per liquidity and seconds inside a tick range
/// @dev Snapshots must only be compared to other snapshots, taken over a period for which a position existed.
/// I.e., snapshots cannot be compared if a position is not held for the entire period between when the first
/// snapshot is taken and the second snapshot is taken.
/// @param tickLower The lower tick of the range
/// @param tickUpper The upper tick of the range
/// @return tickCumulativeInside The snapshot of the tick accumulator for the range
/// @return secondsPerLiquidityInsideX128 The snapshot of seconds per liquidity for the range
/// @return secondsInside The snapshot of seconds per liquidity for the range
function snapshotCumulativesInside(
int24 tickLower,
int24 tickUpper
) external view returns (int56 tickCumulativeInside, uint160 secondsPerLiquidityInsideX128, uint32 secondsInside);
}// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity >=0.5.0;
/// @title Permissionless pool actions
/// @notice Contains pool methods that can be called by anyone
interface IRamsesV3PoolActions {
/// @notice Sets the initial price for the pool
/// @dev Price is represented as a sqrt(amountToken1/amountToken0) Q64.96 value
/// @param sqrtPriceX96 the initial sqrt price of the pool as a Q64.96
function initialize(uint160 sqrtPriceX96) external;
/// @notice Adds liquidity for the given recipient/tickLower/tickUpper position
/// @dev The caller of this method receives a callback in the form of IUniswapV3MintCallback#uniswapV3MintCallback
/// in which they must pay any token0 or token1 owed for the liquidity. The amount of token0/token1 due depends
/// on tickLower, tickUpper, the amount of liquidity, and the current price.
/// @param recipient The address for which the liquidity will be created
/// @param index The index for which the liquidity will be created
/// @param tickLower The lower tick of the position in which to add liquidity
/// @param tickUpper The upper tick of the position in which to add liquidity
/// @param amount The amount of liquidity to mint
/// @param data Any data that should be passed through to the callback
/// @return amount0 The amount of token0 that was paid to mint the given amount of liquidity. Matches the value in the callback
/// @return amount1 The amount of token1 that was paid to mint the given amount of liquidity. Matches the value in the callback
function mint(
address recipient,
uint256 index,
int24 tickLower,
int24 tickUpper,
uint128 amount,
bytes calldata data
) external returns (uint256 amount0, uint256 amount1);
/// @notice Collects tokens owed to a position
/// @dev Does not recompute fees earned, which must be done either via mint or burn of any amount of liquidity.
/// Collect must be called by the position owner. To withdraw only token0 or only token1, amount0Requested or
/// amount1Requested may be set to zero. To withdraw all tokens owed, caller may pass any value greater than the
/// actual tokens owed, e.g. type(uint128).max. Tokens owed may be from accumulated swap fees or burned liquidity.
/// @param recipient The address which should receive the fees collected
/// @param index The index of the position to be collected
/// @param tickLower The lower tick of the position for which to collect fees
/// @param tickUpper The upper tick of the position for which to collect fees
/// @param amount0Requested How much token0 should be withdrawn from the fees owed
/// @param amount1Requested How much token1 should be withdrawn from the fees owed
/// @return amount0 The amount of fees collected in token0
/// @return amount1 The amount of fees collected in token1
function collect(
address recipient,
uint256 index,
int24 tickLower,
int24 tickUpper,
uint128 amount0Requested,
uint128 amount1Requested
) external returns (uint128 amount0, uint128 amount1);
/// @notice Burn liquidity from the sender and account tokens owed for the liquidity to the position
/// @dev Can be used to trigger a recalculation of fees owed to a position by calling with an amount of 0
/// @dev Fees must be collected separately via a call to #collect
/// @param index The index for which the liquidity will be burned
/// @param tickLower The lower tick of the position for which to burn liquidity
/// @param tickUpper The upper tick of the position for which to burn liquidity
/// @param amount How much liquidity to burn
/// @return amount0 The amount of token0 sent to the recipient
/// @return amount1 The amount of token1 sent to the recipient
function burn(
uint256 index,
int24 tickLower,
int24 tickUpper,
uint128 amount
) external returns (uint256 amount0, uint256 amount1);
/// @notice Swap token0 for token1, or token1 for token0
/// @dev The caller of this method receives a callback in the form of IUniswapV3SwapCallback#uniswapV3SwapCallback
/// @param recipient The address to receive the output of the swap
/// @param zeroForOne The direction of the swap, true for token0 to token1, false for token1 to token0
/// @param amountSpecified The amount of the swap, which implicitly configures the swap as exact input (positive), or exact output (negative)
/// @param sqrtPriceLimitX96 The Q64.96 sqrt price limit. If zero for one, the price cannot be less than this
/// value after the swap. If one for zero, the price cannot be greater than this value after the swap
/// @param data Any data to be passed through to the callback
/// @return amount0 The delta of the balance of token0 of the pool, exact when negative, minimum when positive
/// @return amount1 The delta of the balance of token1 of the pool, exact when negative, minimum when positive
function swap(
address recipient,
bool zeroForOne,
int256 amountSpecified,
uint160 sqrtPriceLimitX96,
bytes calldata data
) external returns (int256 amount0, int256 amount1);
/// @notice Receive token0 and/or token1 and pay it back, plus a fee, in the callback
/// @dev The caller of this method receives a callback in the form of IUniswapV3FlashCallback#uniswapV3FlashCallback
/// @dev Can be used to donate underlying tokens pro-rata to currently in-range liquidity providers by calling
/// with 0 amount{0,1} and sending the donation amount(s) from the callback
/// @param recipient The address which will receive the token0 and token1 amounts
/// @param amount0 The amount of token0 to send
/// @param amount1 The amount of token1 to send
/// @param data Any data to be passed through to the callback
function flash(
address recipient,
uint256 amount0,
uint256 amount1,
bytes calldata data
) external;
/// @notice Increase the maximum number of price and liquidity observations that this pool will store
/// @dev This method is no-op if the pool already has an observationCardinalityNext greater than or equal to
/// the input observationCardinalityNext.
/// @param observationCardinalityNext The desired minimum number of observations for the pool to store
function increaseObservationCardinalityNext(uint16 observationCardinalityNext) external;
}// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity >=0.5.0;
/// @title Permissioned pool actions
/// @notice Contains pool methods that may only be called by the factory owner
interface IRamsesV3PoolOwnerActions {
/// @notice Set the denominator of the protocol's % share of the fees
function setFeeProtocol() external;
/// @notice Collect the protocol fee accrued to the pool
/// @param recipient The address to which collected protocol fees should be sent
/// @param amount0Requested The maximum amount of token0 to send, can be 0 to collect fees in only token1
/// @param amount1Requested The maximum amount of token1 to send, can be 0 to collect fees in only token0
/// @return amount0 The protocol fee collected in token0
/// @return amount1 The protocol fee collected in token1
function collectProtocol(
address recipient,
uint128 amount0Requested,
uint128 amount1Requested
) external returns (uint128 amount0, uint128 amount1);
function setFee(uint24 _fee) external;
}// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity >=0.5.0;
/// @title Errors emitted by a pool
/// @notice Contains all custom errors that can be emitted by the pool
interface IRamsesV3PoolErrors {
/*//////////////////////////////////////////////////////////////
POOL ERRORS
//////////////////////////////////////////////////////////////*/
/// @notice Thrown when the pool is locked during a swap or mint/burn operation
error LOK(); // Locked
/// @notice Thrown when tick lower is greater than upper in position management
error TLU(); // Tick Lower > Upper
/// @notice Thrown when tick lower is less than minimum allowed
error TLM(); // Tick Lower < Min
/// @notice Thrown when tick upper is greater than maximum allowed
error TUM(); // Tick Upper > Max
/// @notice Thrown when the pool is already initialized
error AI(); // Already Initialized
/// @notice Thrown when the first margin value is zero
error M0(); // Mint token 0 error
/// @notice Thrown when the second margin value is zero
error M1(); // Mint token1 error
/// @notice Thrown when amount specified is invalid
error AS(); // Amount Specified Invalid
/// @notice Thrown when input amount is insufficient
error IIA(); // Insufficient Input Amount
/// @notice Thrown when pool lacks sufficient liquidity for operation
error L(); // Insufficient Liquidity
/// @notice Thrown when the first fee value is zero
error F0(); // Fee0 issue or Fee = 0
/// @notice Thrown when the second fee value is zero
error F1(); // Fee1 issue
/// @notice Thrown when square price limit is invalid
error SPL(); // Square Price Limit Invalid
}// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity >=0.5.0;
/// @title Events emitted by a pool
/// @notice Contains all events emitted by the pool
interface IRamsesV3PoolEvents {
/// @notice Emitted exactly once by a pool when #initialize is first called on the pool
/// @dev Mint/Burn/Swap cannot be emitted by the pool before Initialize
/// @param sqrtPriceX96 The initial sqrt price of the pool, as a Q64.96
/// @param tick The initial tick of the pool, i.e. log base 1.0001 of the starting price of the pool
event Initialize(uint160 sqrtPriceX96, int24 tick);
/// @notice Emitted when liquidity is minted for a given position
/// @param sender The address that minted the liquidity
/// @param owner The owner of the position and recipient of any minted liquidity
/// @param tickLower The lower tick of the position
/// @param tickUpper The upper tick of the position
/// @param amount The amount of liquidity minted to the position range
/// @param amount0 How much token0 was required for the minted liquidity
/// @param amount1 How much token1 was required for the minted liquidity
event Mint(
address sender,
address indexed owner,
int24 indexed tickLower,
int24 indexed tickUpper,
uint128 amount,
uint256 amount0,
uint256 amount1
);
/// @notice Emitted when fees are collected by the owner of a position
/// @dev Collect events may be emitted with zero amount0 and amount1 when the caller chooses not to collect fees
/// @param owner The owner of the position for which fees are collected
/// @param tickLower The lower tick of the position
/// @param tickUpper The upper tick of the position
/// @param amount0 The amount of token0 fees collected
/// @param amount1 The amount of token1 fees collected
event Collect(
address indexed owner,
address recipient,
int24 indexed tickLower,
int24 indexed tickUpper,
uint128 amount0,
uint128 amount1
);
/// @notice Emitted when a position's liquidity is removed
/// @dev Does not withdraw any fees earned by the liquidity position, which must be withdrawn via #collect
/// @param owner The owner of the position for which liquidity is removed
/// @param tickLower The lower tick of the position
/// @param tickUpper The upper tick of the position
/// @param amount The amount of liquidity to remove
/// @param amount0 The amount of token0 withdrawn
/// @param amount1 The amount of token1 withdrawn
event Burn(
address indexed owner,
int24 indexed tickLower,
int24 indexed tickUpper,
uint128 amount,
uint256 amount0,
uint256 amount1
);
/// @notice Emitted by the pool for any swaps between token0 and token1
/// @param sender The address that initiated the swap call, and that received the callback
/// @param recipient The address that received the output of the swap
/// @param amount0 The delta of the token0 balance of the pool
/// @param amount1 The delta of the token1 balance of the pool
/// @param sqrtPriceX96 The sqrt(price) of the pool after the swap, as a Q64.96
/// @param liquidity The liquidity of the pool after the swap
/// @param tick The log base 1.0001 of price of the pool after the swap
event Swap(
address indexed sender,
address indexed recipient,
int256 amount0,
int256 amount1,
uint160 sqrtPriceX96,
uint128 liquidity,
int24 tick
);
/// @notice Emitted by the pool for any flashes of token0/token1
/// @param sender The address that initiated the swap call, and that received the callback
/// @param recipient The address that received the tokens from flash
/// @param amount0 The amount of token0 that was flashed
/// @param amount1 The amount of token1 that was flashed
/// @param paid0 The amount of token0 paid for the flash, which can exceed the amount0 plus the fee
/// @param paid1 The amount of token1 paid for the flash, which can exceed the amount1 plus the fee
event Flash(
address indexed sender,
address indexed recipient,
uint256 amount0,
uint256 amount1,
uint256 paid0,
uint256 paid1
);
/// @notice Emitted by the pool for increases to the number of observations that can be stored
/// @dev observationCardinalityNext is not the observation cardinality until an observation is written at the index
/// just before a mint/swap/burn.
/// @param observationCardinalityNextOld The previous value of the next observation cardinality
/// @param observationCardinalityNextNew The updated value of the next observation cardinality
event IncreaseObservationCardinalityNext(
uint16 observationCardinalityNextOld, uint16 observationCardinalityNextNew
);
/// @notice Emitted when the protocol fee is changed by the pool
/// @param feeProtocol0Old The previous value of the token0 protocol fee
/// @param feeProtocol1Old The previous value of the token1 protocol fee
/// @param feeProtocol0New The updated value of the token0 protocol fee
/// @param feeProtocol1New The updated value of the token1 protocol fee
event SetFeeProtocol(uint8 feeProtocol0Old, uint8 feeProtocol1Old, uint8 feeProtocol0New, uint8 feeProtocol1New);
/// @notice Emitted when the collected protocol fees are withdrawn by the factory owner
/// @param sender The address that collects the protocol fees
/// @param recipient The address that receives the collected protocol fees
/// @param amount0 The amount of token0 protocol fees that is withdrawn
/// @param amount0 The amount of token1 protocol fees that is withdrawn
event CollectProtocol(address indexed sender, address indexed recipient, uint128 amount0, uint128 amount1);
}// SPDX-License-Identifier: BUSL-1.1
pragma solidity ^0.8.26;
interface IGaugeV3 {
/// @notice Emitted when a reward notification is made.
/// @param from The address from which the reward is notified.
/// @param reward The address of the reward token.
/// @param amount The amount of rewards notified.
/// @param period The period for which the rewards are notified.
event NotifyReward(
address indexed from,
address indexed reward,
uint256 amount,
uint256 period
);
/// @notice Emitted when a bribe is made.
/// @param from The address from which the bribe is made.
/// @param reward The address of the reward token.
/// @param amount The amount of tokens bribed.
/// @param period The period for which the bribe is made.
event Bribe(
address indexed from,
address indexed reward,
uint256 amount,
uint256 period
);
/// @notice Emitted when rewards are claimed.
/// @param period The period for which the rewards are claimed.
/// @param _positionHash The identifier of the NFP for which rewards are claimed.
/// @param receiver The address of the receiver of the claimed rewards.
/// @param reward The address of the reward token.
/// @param amount The amount of rewards claimed.
event ClaimRewards(
uint256 period,
bytes32 _positionHash,
address receiver,
address reward,
uint256 amount
);
/// @notice Emitted when a new reward token was pushed to the rewards array
event RewardAdded(address reward);
/// @notice Emitted when a reward token was removed from the rewards array
event RewardRemoved(address reward);
/// @notice Retrieves the value of the firstPeriod variable.
/// @return The value of the firstPeriod variable.
function firstPeriod() external returns (uint256);
/// @notice Retrieves the total supply of a specific token for a given period.
/// @param period The period for which to retrieve the total supply.
/// @param token The address of the token for which to retrieve the total supply.
/// @return The total supply of the specified token for the given period.
function tokenTotalSupplyByPeriod(
uint256 period,
address token
) external view returns (uint256);
/// @notice Retrieves the getTokenTotalSupplyByPeriod of the current period.
/// @dev included to support voter's left() check during distribute().
/// @param token The address of the token for which to retrieve the remaining amount.
/// @return The amount of tokens left to distribute in this period.
function left(address token) external view returns (uint256);
/// @notice Retrieves the reward rate for a specific reward address.
/// @dev this method returns the base rate without boost
/// @param token The address of the reward for which to retrieve the reward rate.
/// @return The reward rate for the specified reward address.
function rewardRate(address token) external view returns (uint256);
/// @notice Retrieves the claimed amount for a specific period, position hash, and user address.
/// @param period The period for which to retrieve the claimed amount.
/// @param _positionHash The identifier of the NFP for which to retrieve the claimed amount.
/// @param reward The address of the token for the claimed amount.
/// @return The claimed amount for the specified period, token ID, and user address.
function periodClaimedAmount(
uint256 period,
bytes32 _positionHash,
address reward
) external view returns (uint256);
/// @notice Retrieves the last claimed period for a specific token, token ID combination.
/// @param token The address of the reward token for which to retrieve the last claimed period.
/// @param _positionHash The identifier of the NFP for which to retrieve the last claimed period.
/// @return The last claimed period for the specified token and token ID.
function lastClaimByToken(
address token,
bytes32 _positionHash
) external view returns (uint256);
/// @notice Retrieves the reward address at the specified index in the rewards array.
/// @param index The index of the reward address to retrieve.
/// @return The reward address at the specified index.
function rewards(uint256 index) external view returns (address);
/// @notice Checks if a given address is a valid reward.
/// @param reward The address to check.
/// @return A boolean indicating whether the address is a valid reward.
function isReward(address reward) external view returns (bool);
/// @notice Returns an array of reward token addresses.
/// @return An array of reward token addresses.
function getRewardTokens() external view returns (address[] memory);
/// @notice Returns the hash used to store positions in a mapping
/// @param owner The address of the position owner
/// @param index The index of the position
/// @param tickLower The lower tick boundary of the position
/// @param tickUpper The upper tick boundary of the position
/// @return _hash The hash used to store positions in a mapping
function positionHash(
address owner,
uint256 index,
int24 tickLower,
int24 tickUpper
) external pure returns (bytes32);
/*
/// @notice Retrieves the liquidity and boosted liquidity for a specific NFP.
/// @param tokenId The identifier of the NFP.
/// @return liquidity The liquidity of the position token.
function positionInfo(
uint256 tokenId
) external view returns (uint128 liquidity);
*/
/// @notice Returns the amount of rewards earned for an NFP.
/// @param token The address of the token for which to retrieve the earned rewards.
/// @param tokenId The identifier of the specific NFP for which to retrieve the earned rewards.
/// @return reward The amount of rewards earned for the specified NFP and tokens.
function earned(
address token,
uint256 tokenId
) external view returns (uint256 reward);
/// @notice Returns the amount of rewards earned during a period for an NFP.
/// @param period The period for which to retrieve the earned rewards.
/// @param token The address of the token for which to retrieve the earned rewards.
/// @param tokenId The identifier of the specific NFP for which to retrieve the earned rewards.
/// @return reward The amount of rewards earned for the specified NFP and tokens.
function periodEarned(
uint256 period,
address token,
uint256 tokenId
) external view returns (uint256);
/// @notice Retrieves the earned rewards for a specific period, token, owner, index, tickLower, and tickUpper.
/// @param period The period for which to retrieve the earned rewards.
/// @param token The address of the token for which to retrieve the earned rewards.
/// @param owner The address of the owner for which to retrieve the earned rewards.
/// @param index The index for which to retrieve the earned rewards.
/// @param tickLower The tick lower bound for which to retrieve the earned rewards.
/// @param tickUpper The tick upper bound for which to retrieve the earned rewards.
/// @return The earned rewards for the specified period, token, owner, index, tickLower, and tickUpper.
function periodEarned(
uint256 period,
address token,
address owner,
uint256 index,
int24 tickLower,
int24 tickUpper
) external view returns (uint256);
/// @notice Retrieves the earned rewards for a specific period, token, owner, index, tickLower, and tickUpper.
/// @dev used by getReward() and saves gas by saving states
/// @param period The period for which to retrieve the earned rewards.
/// @param token The address of the token for which to retrieve the earned rewards.
/// @param owner The address of the owner for which to retrieve the earned rewards.
/// @param index The index for which to retrieve the earned rewards.
/// @param tickLower The tick lower bound for which to retrieve the earned rewards.
/// @param tickUpper The tick upper bound for which to retrieve the earned rewards.
/// @param caching Whether to cache the results or not.
/// @return The earned rewards for the specified period, token, owner, index, tickLower, and tickUpper.
function cachePeriodEarned(
uint256 period,
address token,
address owner,
uint256 index,
int24 tickLower,
int24 tickUpper,
bool caching
) external returns (uint256);
/// @notice Notifies the contract about the amount of rewards to be distributed for a specific token.
/// @param token The address of the token for which to notify the reward amount.
/// @param amount The amount of rewards to be distributed.
function notifyRewardAmount(address token, uint256 amount) external;
/// @notice Retrieves the reward amount for a specific period, NFP, and token addresses.
/// @param period The period for which to retrieve the reward amount.
/// @param tokens The addresses of the tokens for which to retrieve the reward amount.
/// @param tokenId The identifier of the specific NFP for which to retrieve the reward amount.
/// @param receiver The address of the receiver of the reward amount.
function getPeriodReward(
uint256 period,
address[] calldata tokens,
uint256 tokenId,
address receiver
) external;
/// @notice Retrieves the rewards for a specific period, set of tokens, owner, index, tickLower, tickUpper, and receiver.
/// @param period The period for which to retrieve the rewards.
/// @param tokens An array of token addresses for which to retrieve the rewards.
/// @param owner The address of the owner for which to retrieve the rewards.
/// @param index The index for which to retrieve the rewards.
/// @param tickLower The tick lower bound for which to retrieve the rewards.
/// @param tickUpper The tick upper bound for which to retrieve the rewards.
/// @param receiver The address of the receiver of the rewards.
function getPeriodReward(
uint256 period,
address[] calldata tokens,
address owner,
uint256 index,
int24 tickLower,
int24 tickUpper,
address receiver
) external;
/// @notice retrieves rewards based on an NFP id and an array of tokens
function getReward(uint256 tokenId, address[] memory tokens) external;
/// @notice retrieves rewards based on an array of NFP ids and an array of tokens
function getReward(
uint256[] calldata tokenIds,
address[] memory tokens
) external;
/// @notice get reward for an owner of an NFP
function getRewardForOwner(
uint256 tokenId,
address[] memory tokens
) external;
function addRewards(address reward) external;
function removeRewards(address reward) external;
/// @notice Notifies rewards for periods greater than current period
/// @dev does not push fees
/// @dev requires reward token to be whitelisted
function notifyRewardAmountForPeriod(
address token,
uint256 amount,
uint256 period
) external;
/// @notice Notifies rewards for the next period
/// @dev does not push fees
/// @dev requires reward token to be whitelisted
function notifyRewardAmountNextPeriod(
address token,
uint256 amount
) external;
}// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity >=0.7.5;
pragma abicoder v2;
import {IPoolInitializer} from './IPoolInitializer.sol';
import {IPeripheryPayments} from './IPeripheryPayments.sol';
import {IPeripheryImmutableState} from './IPeripheryImmutableState.sol';
import {PoolAddress} from '../libraries/PoolAddress.sol';
import {IERC721} from '@openzeppelin/contracts/token/ERC721/IERC721.sol';
import {IERC721Metadata} from '@openzeppelin/contracts/token/ERC721/extensions/IERC721Metadata.sol';
import {IERC721Enumerable} from '@openzeppelin/contracts/token/ERC721/extensions/IERC721Enumerable.sol';
import {IPeripheryErrors} from './IPeripheryErrors.sol';
/// @title Non-fungible token for positions
/// @notice Wraps Ramses V3 positions in a non-fungible token interface which allows for them to be transferred
/// and authorized.
interface INonfungiblePositionManager is
IPeripheryErrors,
IPoolInitializer,
IPeripheryPayments,
IPeripheryImmutableState,
IERC721,
IERC721Metadata,
IERC721Enumerable
{
/// @notice Emitted when liquidity is increased for a position NFT
/// @dev Also emitted when a token is minted
/// @param tokenId The ID of the token for which liquidity was increased
/// @param liquidity The amount by which liquidity for the NFT position was increased
/// @param amount0 The amount of token0 that was paid for the increase in liquidity
/// @param amount1 The amount of token1 that was paid for the increase in liquidity
event IncreaseLiquidity(uint256 indexed tokenId, uint128 liquidity, uint256 amount0, uint256 amount1);
/// @notice Emitted when liquidity is decreased for a position NFT
/// @param tokenId The ID of the token for which liquidity was decreased
/// @param liquidity The amount by which liquidity for the NFT position was decreased
/// @param amount0 The amount of token0 that was accounted for the decrease in liquidity
/// @param amount1 The amount of token1 that was accounted for the decrease in liquidity
event DecreaseLiquidity(uint256 indexed tokenId, uint128 liquidity, uint256 amount0, uint256 amount1);
/// @notice Emitted when tokens are collected for a position NFT
/// @dev The amounts reported may not be exactly equivalent to the amounts transferred, due to rounding behavior
/// @param tokenId The ID of the token for which underlying tokens were collected
/// @param recipient The address of the account that received the collected tokens
/// @param amount0 The amount of token0 owed to the position that was collected
/// @param amount1 The amount of token1 owed to the position that was collected
event Collect(uint256 indexed tokenId, address recipient, uint256 amount0, uint256 amount1);
/// @notice Returns the position information associated with a given token ID.
/// @dev Throws if the token ID is not valid.
/// @param tokenId The ID of the token that represents the position
/// @return token0 The address of the token0 for a specific pool
/// @return token1 The address of the token1 for a specific pool
/// @return tickSpacing The tickSpacing the pool
/// @return tickLower The lower end of the tick range for the position
/// @return tickUpper The higher end of the tick range for the position
/// @return liquidity The liquidity of the position
/// @return feeGrowthInside0LastX128 The fee growth of token0 as of the last action on the individual position
/// @return feeGrowthInside1LastX128 The fee growth of token1 as of the last action on the individual position
/// @return tokensOwed0 The uncollected amount of token0 owed to the position as of the last computation
/// @return tokensOwed1 The uncollected amount of token1 owed to the position as of the last computation
function positions(
uint256 tokenId
)
external
view
returns (
address token0,
address token1,
int24 tickSpacing,
int24 tickLower,
int24 tickUpper,
uint128 liquidity,
uint256 feeGrowthInside0LastX128,
uint256 feeGrowthInside1LastX128,
uint128 tokensOwed0,
uint128 tokensOwed1
);
struct MintParams {
address token0;
address token1;
int24 tickSpacing;
int24 tickLower;
int24 tickUpper;
uint256 amount0Desired;
uint256 amount1Desired;
uint256 amount0Min;
uint256 amount1Min;
address recipient;
uint256 deadline;
}
/// @notice Creates a new position wrapped in a NFT
/// @dev Call this when the pool does exist and is initialized. Note that if the pool is created but not initialized
/// a method does not exist, i.e. the pool is assumed to be initialized.
/// @param params The params necessary to mint a position, encoded as `MintParams` in calldata
/// @return tokenId The ID of the token that represents the minted position
/// @return liquidity The amount of liquidity for this position
/// @return amount0 The amount of token0
/// @return amount1 The amount of token1
function mint(
MintParams calldata params
) external payable returns (uint256 tokenId, uint128 liquidity, uint256 amount0, uint256 amount1);
struct IncreaseLiquidityParams {
uint256 tokenId;
uint256 amount0Desired;
uint256 amount1Desired;
uint256 amount0Min;
uint256 amount1Min;
uint256 deadline;
}
/// @notice Increases the amount of liquidity in a position, with tokens paid by the `msg.sender`
/// @param params tokenId The ID of the token for which liquidity is being increased,
/// amount0Desired The desired amount of token0 to be spent,
/// amount1Desired The desired amount of token1 to be spent,
/// amount0Min The minimum amount of token0 to spend, which serves as a slippage check,
/// amount1Min The minimum amount of token1 to spend, which serves as a slippage check,
/// deadline The time by which the transaction must be included to effect the change
/// @return liquidity The new liquidity amount as a result of the increase
/// @return amount0 The amount of token0 to acheive resulting liquidity
/// @return amount1 The amount of token1 to acheive resulting liquidity
function increaseLiquidity(
IncreaseLiquidityParams calldata params
) external payable returns (uint128 liquidity, uint256 amount0, uint256 amount1);
struct DecreaseLiquidityParams {
uint256 tokenId;
uint128 liquidity;
uint256 amount0Min;
uint256 amount1Min;
uint256 deadline;
}
/// @notice Decreases the amount of liquidity in a position and accounts it to the position
/// @param params tokenId The ID of the token for which liquidity is being decreased,
/// amount The amount by which liquidity will be decreased,
/// amount0Min The minimum amount of token0 that should be accounted for the burned liquidity,
/// amount1Min The minimum amount of token1 that should be accounted for the burned liquidity,
/// deadline The time by which the transaction must be included to effect the change
/// @return amount0 The amount of token0 accounted to the position's tokens owed
/// @return amount1 The amount of token1 accounted to the position's tokens owed
function decreaseLiquidity(
DecreaseLiquidityParams calldata params
) external payable returns (uint256 amount0, uint256 amount1);
struct CollectParams {
uint256 tokenId;
address recipient;
uint128 amount0Max;
uint128 amount1Max;
}
/// @notice Collects up to a maximum amount of fees owed to a specific position to the recipient
/// @param params tokenId The ID of the NFT for which tokens are being collected,
/// recipient The account that should receive the tokens,
/// amount0Max The maximum amount of token0 to collect,
/// amount1Max The maximum amount of token1 to collect
/// @return amount0 The amount of fees collected in token0
/// @return amount1 The amount of fees collected in token1
function collect(CollectParams calldata params) external payable returns (uint256 amount0, uint256 amount1);
/// @notice Burns a token ID, which deletes it from the NFT contract. The token must have 0 liquidity and all tokens
/// must be collected first.
/// @param tokenId The ID of the token that is being burned
function burn(uint256 tokenId) external payable;
/// @notice Claims gauge rewards from liquidity incentives for a specific tokenId
/// @param tokenId The ID of the token to claim rewards from
/// @param tokens an array of reward tokens to claim
function getReward(uint256 tokenId, address[] calldata tokens) external;
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
/// @title Contains 512-bit math functions
/// @notice Facilitates multiplication and division that can have overflow of an intermediate value without any loss of precision
/// @dev Handles "phantom overflow" i.e., allows multiplication and division where an intermediate value overflows 256 bits
library FullMath {
/// @notice Calculates floor(a×b÷denominator) with full precision. Throws if result overflows a uint256 or denominator == 0
/// @param a The multiplicand
/// @param b The multiplier
/// @param denominator The divisor
/// @return result The 256-bit result
/// @dev Credit to Remco Bloemen under MIT license https://xn--2-umb.com/21/muldiv
function mulDiv(uint256 a, uint256 b, uint256 denominator) internal pure returns (uint256 result) {
unchecked {
// 512-bit multiply [prod1 prod0] = a * b
// Compute the product mod 2**256 and mod 2**256 - 1
// then use the Chinese Remainder Theorem to reconstruct
// the 512 bit result. The result is stored in two 256
// variables such that product = prod1 * 2**256 + prod0
uint256 prod0; // Least significant 256 bits of the product
uint256 prod1; // Most significant 256 bits of the product
assembly {
let mm := mulmod(a, b, not(0))
prod0 := mul(a, b)
prod1 := sub(sub(mm, prod0), lt(mm, prod0))
}
// Handle non-overflow cases, 256 by 256 division
if (prod1 == 0) {
require(denominator > 0);
assembly {
result := div(prod0, denominator)
}
return result;
}
// Make sure the result is less than 2**256.
// Also prevents denominator == 0
require(denominator > prod1);
///////////////////////////////////////////////
// 512 by 256 division.
///////////////////////////////////////////////
// Make division exact by subtracting the remainder from [prod1 prod0]
// Compute remainder using mulmod
uint256 remainder;
assembly {
remainder := mulmod(a, b, denominator)
}
// Subtract 256 bit number from 512 bit number
assembly {
prod1 := sub(prod1, gt(remainder, prod0))
prod0 := sub(prod0, remainder)
}
// Factor powers of two out of denominator
// Compute largest power of two divisor of denominator.
// Always >= 1.
uint256 twos = (0 - denominator) & denominator;
// Divide denominator by power of two
assembly {
denominator := div(denominator, twos)
}
// Divide [prod1 prod0] by the factors of two
assembly {
prod0 := div(prod0, twos)
}
// Shift in bits from prod1 into prod0. For this we need
// to flip `twos` such that it is 2**256 / twos.
// If twos is zero, then it becomes one
assembly {
twos := add(div(sub(0, twos), twos), 1)
}
prod0 |= prod1 * twos;
// Invert denominator mod 2**256
// Now that denominator is an odd number, it has an inverse
// modulo 2**256 such that denominator * inv = 1 mod 2**256.
// Compute the inverse by starting with a seed that is correct
// correct for four bits. That is, denominator * inv = 1 mod 2**4
uint256 inv = (3 * denominator) ^ 2;
// Now use Newton-Raphson iteration to improve the precision.
// Thanks to Hensel's lifting lemma, this also works in modular
// arithmetic, doubling the correct bits in each step.
inv *= 2 - denominator * inv; // inverse mod 2**8
inv *= 2 - denominator * inv; // inverse mod 2**16
inv *= 2 - denominator * inv; // inverse mod 2**32
inv *= 2 - denominator * inv; // inverse mod 2**64
inv *= 2 - denominator * inv; // inverse mod 2**128
inv *= 2 - denominator * inv; // inverse mod 2**256
// Because the division is now exact we can divide by multiplying
// with the modular inverse of denominator. This will give us the
// correct result modulo 2**256. Since the precoditions guarantee
// that the outcome is less than 2**256, this is the final result.
// We don't need to compute the high bits of the result and prod1
// is no longer required.
result = prod0 * inv;
return result;
}
}
/// @notice Calculates ceil(a×b÷denominator) with full precision. Throws if result overflows a uint256 or denominator == 0
/// @param a The multiplicand
/// @param b The multiplier
/// @param denominator The divisor
/// @return result The 256-bit result
function mulDivRoundingUp(uint256 a, uint256 b, uint256 denominator) internal pure returns (uint256 result) {
unchecked {
result = mulDiv(a, b, denominator);
if (mulmod(a, b, denominator) > 0) {
require(result < type(uint256).max);
result++;
}
}
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.1.0) (token/ERC20/utils/SafeERC20.sol)
pragma solidity ^0.8.20;
import {IERC20} from "../IERC20.sol";
import {IERC1363} from "../../../interfaces/IERC1363.sol";
import {Address} from "../../../utils/Address.sol";
/**
* @title SafeERC20
* @dev Wrappers around ERC-20 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 {
/**
* @dev An operation with an ERC-20 token failed.
*/
error SafeERC20FailedOperation(address token);
/**
* @dev Indicates a failed `decreaseAllowance` request.
*/
error SafeERC20FailedDecreaseAllowance(address spender, uint256 currentAllowance, uint256 requestedDecrease);
/**
* @dev Transfer `value` amount of `token` from the calling contract to `to`. If `token` returns no value,
* non-reverting calls are assumed to be successful.
*/
function safeTransfer(IERC20 token, address to, uint256 value) internal {
_callOptionalReturn(token, abi.encodeCall(token.transfer, (to, value)));
}
/**
* @dev Transfer `value` amount of `token` from `from` to `to`, spending the approval given by `from` to the
* calling contract. If `token` returns no value, non-reverting calls are assumed to be successful.
*/
function safeTransferFrom(IERC20 token, address from, address to, uint256 value) internal {
_callOptionalReturn(token, abi.encodeCall(token.transferFrom, (from, to, value)));
}
/**
* @dev Increase the calling contract's allowance toward `spender` by `value`. If `token` returns no value,
* non-reverting calls are assumed to be successful.
*
* IMPORTANT: If the token implements ERC-7674 (ERC-20 with temporary allowance), and if the "client"
* smart contract uses ERC-7674 to set temporary allowances, then the "client" smart contract should avoid using
* this function. Performing a {safeIncreaseAllowance} or {safeDecreaseAllowance} operation on a token contract
* that has a non-zero temporary allowance (for that particular owner-spender) will result in unexpected behavior.
*/
function safeIncreaseAllowance(IERC20 token, address spender, uint256 value) internal {
uint256 oldAllowance = token.allowance(address(this), spender);
forceApprove(token, spender, oldAllowance + value);
}
/**
* @dev Decrease the calling contract's allowance toward `spender` by `requestedDecrease`. If `token` returns no
* value, non-reverting calls are assumed to be successful.
*
* IMPORTANT: If the token implements ERC-7674 (ERC-20 with temporary allowance), and if the "client"
* smart contract uses ERC-7674 to set temporary allowances, then the "client" smart contract should avoid using
* this function. Performing a {safeIncreaseAllowance} or {safeDecreaseAllowance} operation on a token contract
* that has a non-zero temporary allowance (for that particular owner-spender) will result in unexpected behavior.
*/
function safeDecreaseAllowance(IERC20 token, address spender, uint256 requestedDecrease) internal {
unchecked {
uint256 currentAllowance = token.allowance(address(this), spender);
if (currentAllowance < requestedDecrease) {
revert SafeERC20FailedDecreaseAllowance(spender, currentAllowance, requestedDecrease);
}
forceApprove(token, spender, currentAllowance - requestedDecrease);
}
}
/**
* @dev Set the calling contract's allowance toward `spender` to `value`. If `token` returns no value,
* non-reverting calls are assumed to be successful. Meant to be used with tokens that require the approval
* to be set to zero before setting it to a non-zero value, such as USDT.
*
* NOTE: If the token implements ERC-7674, this function will not modify any temporary allowance. This function
* only sets the "standard" allowance. Any temporary allowance will remain active, in addition to the value being
* set here.
*/
function forceApprove(IERC20 token, address spender, uint256 value) internal {
bytes memory approvalCall = abi.encodeCall(token.approve, (spender, value));
if (!_callOptionalReturnBool(token, approvalCall)) {
_callOptionalReturn(token, abi.encodeCall(token.approve, (spender, 0)));
_callOptionalReturn(token, approvalCall);
}
}
/**
* @dev Performs an {ERC1363} transferAndCall, with a fallback to the simple {ERC20} transfer if the target has no
* code. This can be used to implement an {ERC721}-like safe transfer that rely on {ERC1363} checks when
* targeting contracts.
*
* Reverts if the returned value is other than `true`.
*/
function transferAndCallRelaxed(IERC1363 token, address to, uint256 value, bytes memory data) internal {
if (to.code.length == 0) {
safeTransfer(token, to, value);
} else if (!token.transferAndCall(to, value, data)) {
revert SafeERC20FailedOperation(address(token));
}
}
/**
* @dev Performs an {ERC1363} transferFromAndCall, with a fallback to the simple {ERC20} transferFrom if the target
* has no code. This can be used to implement an {ERC721}-like safe transfer that rely on {ERC1363} checks when
* targeting contracts.
*
* Reverts if the returned value is other than `true`.
*/
function transferFromAndCallRelaxed(
IERC1363 token,
address from,
address to,
uint256 value,
bytes memory data
) internal {
if (to.code.length == 0) {
safeTransferFrom(token, from, to, value);
} else if (!token.transferFromAndCall(from, to, value, data)) {
revert SafeERC20FailedOperation(address(token));
}
}
/**
* @dev Performs an {ERC1363} approveAndCall, with a fallback to the simple {ERC20} approve if the target has no
* code. This can be used to implement an {ERC721}-like safe transfer that rely on {ERC1363} checks when
* targeting contracts.
*
* NOTE: When the recipient address (`to`) has no code (i.e. is an EOA), this function behaves as {forceApprove}.
* Opposedly, when the recipient address (`to`) has code, this function only attempts to call {ERC1363-approveAndCall}
* once without retrying, and relies on the returned value to be true.
*
* Reverts if the returned value is other than `true`.
*/
function approveAndCallRelaxed(IERC1363 token, address to, uint256 value, bytes memory data) internal {
if (to.code.length == 0) {
forceApprove(token, to, value);
} else if (!token.approveAndCall(to, value, data)) {
revert SafeERC20FailedOperation(address(token));
}
}
/**
* @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).
*
* This is a variant of {_callOptionalReturnBool} that reverts if call fails to meet the requirements.
*/
function _callOptionalReturn(IERC20 token, bytes memory data) private {
uint256 returnSize;
uint256 returnValue;
assembly ("memory-safe") {
let success := call(gas(), token, 0, add(data, 0x20), mload(data), 0, 0x20)
// bubble errors
if iszero(success) {
let ptr := mload(0x40)
returndatacopy(ptr, 0, returndatasize())
revert(ptr, returndatasize())
}
returnSize := returndatasize()
returnValue := mload(0)
}
if (returnSize == 0 ? address(token).code.length == 0 : returnValue != 1) {
revert SafeERC20FailedOperation(address(token));
}
}
/**
* @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).
*
* This is a variant of {_callOptionalReturn} that silently catches all reverts and returns a bool instead.
*/
function _callOptionalReturnBool(IERC20 token, bytes memory data) private returns (bool) {
bool success;
uint256 returnSize;
uint256 returnValue;
assembly ("memory-safe") {
success := call(gas(), token, 0, add(data, 0x20), mload(data), 0, 0x20)
returnSize := returndatasize()
returnValue := mload(0)
}
return success && (returnSize == 0 ? address(token).code.length > 0 : returnValue == 1);
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.1.0) (utils/math/Math.sol)
pragma solidity ^0.8.20;
import {Panic} from "../Panic.sol";
import {SafeCast} from "./SafeCast.sol";
/**
* @dev Standard math utilities missing in the Solidity language.
*/
library Math {
enum Rounding {
Floor, // Toward negative infinity
Ceil, // Toward positive infinity
Trunc, // Toward zero
Expand // Away from zero
}
/**
* @dev Returns the addition of two unsigned integers, with an success flag (no overflow).
*/
function tryAdd(uint256 a, uint256 b) internal pure returns (bool success, uint256 result) {
unchecked {
uint256 c = a + b;
if (c < a) return (false, 0);
return (true, c);
}
}
/**
* @dev Returns the subtraction of two unsigned integers, with an success flag (no overflow).
*/
function trySub(uint256 a, uint256 b) internal pure returns (bool success, uint256 result) {
unchecked {
if (b > a) return (false, 0);
return (true, a - b);
}
}
/**
* @dev Returns the multiplication of two unsigned integers, with an success flag (no overflow).
*/
function tryMul(uint256 a, uint256 b) internal pure returns (bool success, uint256 result) {
unchecked {
// Gas optimization: this is cheaper than requiring 'a' not being zero, but the
// benefit is lost if 'b' is also tested.
// See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522
if (a == 0) return (true, 0);
uint256 c = a * b;
if (c / a != b) return (false, 0);
return (true, c);
}
}
/**
* @dev Returns the division of two unsigned integers, with a success flag (no division by zero).
*/
function tryDiv(uint256 a, uint256 b) internal pure returns (bool success, uint256 result) {
unchecked {
if (b == 0) return (false, 0);
return (true, a / b);
}
}
/**
* @dev Returns the remainder of dividing two unsigned integers, with a success flag (no division by zero).
*/
function tryMod(uint256 a, uint256 b) internal pure returns (bool success, uint256 result) {
unchecked {
if (b == 0) return (false, 0);
return (true, a % b);
}
}
/**
* @dev Branchless ternary evaluation for `a ? b : c`. Gas costs are constant.
*
* IMPORTANT: This function may reduce bytecode size and consume less gas when used standalone.
* However, the compiler may optimize Solidity ternary operations (i.e. `a ? b : c`) to only compute
* one branch when needed, making this function more expensive.
*/
function ternary(bool condition, uint256 a, uint256 b) internal pure returns (uint256) {
unchecked {
// branchless ternary works because:
// b ^ (a ^ b) == a
// b ^ 0 == b
return b ^ ((a ^ b) * SafeCast.toUint(condition));
}
}
/**
* @dev Returns the largest of two numbers.
*/
function max(uint256 a, uint256 b) internal pure returns (uint256) {
return ternary(a > b, a, b);
}
/**
* @dev Returns the smallest of two numbers.
*/
function min(uint256 a, uint256 b) internal pure returns (uint256) {
return ternary(a < b, a, b);
}
/**
* @dev Returns the average of two numbers. The result is rounded towards
* zero.
*/
function average(uint256 a, uint256 b) internal pure returns (uint256) {
// (a + b) / 2 can overflow.
return (a & b) + (a ^ b) / 2;
}
/**
* @dev Returns the ceiling of the division of two numbers.
*
* This differs from standard division with `/` in that it rounds towards infinity instead
* of rounding towards zero.
*/
function ceilDiv(uint256 a, uint256 b) internal pure returns (uint256) {
if (b == 0) {
// Guarantee the same behavior as in a regular Solidity division.
Panic.panic(Panic.DIVISION_BY_ZERO);
}
// The following calculation ensures accurate ceiling division without overflow.
// Since a is non-zero, (a - 1) / b will not overflow.
// The largest possible result occurs when (a - 1) / b is type(uint256).max,
// but the largest value we can obtain is type(uint256).max - 1, which happens
// when a = type(uint256).max and b = 1.
unchecked {
return SafeCast.toUint(a > 0) * ((a - 1) / b + 1);
}
}
/**
* @dev Calculates floor(x * y / denominator) with full precision. Throws if result overflows a uint256 or
* denominator == 0.
*
* Original credit to Remco Bloemen under MIT license (https://xn--2-umb.com/21/muldiv) with further edits by
* Uniswap Labs also under MIT license.
*/
function mulDiv(uint256 x, uint256 y, uint256 denominator) internal pure returns (uint256 result) {
unchecked {
// 512-bit multiply [prod1 prod0] = x * y. Compute the product mod 2²⁵⁶ and mod 2²⁵⁶ - 1, then use
// the Chinese Remainder Theorem to reconstruct the 512 bit result. The result is stored in two 256
// variables such that product = prod1 * 2²⁵⁶ + prod0.
uint256 prod0 = x * y; // Least significant 256 bits of the product
uint256 prod1; // Most significant 256 bits of the product
assembly {
let mm := mulmod(x, y, not(0))
prod1 := sub(sub(mm, prod0), lt(mm, prod0))
}
// Handle non-overflow cases, 256 by 256 division.
if (prod1 == 0) {
// Solidity will revert if denominator == 0, unlike the div opcode on its own.
// The surrounding unchecked block does not change this fact.
// See https://docs.soliditylang.org/en/latest/control-structures.html#checked-or-unchecked-arithmetic.
return prod0 / denominator;
}
// Make sure the result is less than 2²⁵⁶. Also prevents denominator == 0.
if (denominator <= prod1) {
Panic.panic(ternary(denominator == 0, Panic.DIVISION_BY_ZERO, Panic.UNDER_OVERFLOW));
}
///////////////////////////////////////////////
// 512 by 256 division.
///////////////////////////////////////////////
// Make division exact by subtracting the remainder from [prod1 prod0].
uint256 remainder;
assembly {
// Compute remainder using mulmod.
remainder := mulmod(x, y, denominator)
// Subtract 256 bit number from 512 bit number.
prod1 := sub(prod1, gt(remainder, prod0))
prod0 := sub(prod0, remainder)
}
// Factor powers of two out of denominator and compute largest power of two divisor of denominator.
// Always >= 1. See https://cs.stackexchange.com/q/138556/92363.
uint256 twos = denominator & (0 - denominator);
assembly {
// Divide denominator by twos.
denominator := div(denominator, twos)
// Divide [prod1 prod0] by twos.
prod0 := div(prod0, twos)
// Flip twos such that it is 2²⁵⁶ / twos. If twos is zero, then it becomes one.
twos := add(div(sub(0, twos), twos), 1)
}
// Shift in bits from prod1 into prod0.
prod0 |= prod1 * twos;
// Invert denominator mod 2²⁵⁶. Now that denominator is an odd number, it has an inverse modulo 2²⁵⁶ such
// that denominator * inv ≡ 1 mod 2²⁵⁶. Compute the inverse by starting with a seed that is correct for
// four bits. That is, denominator * inv ≡ 1 mod 2⁴.
uint256 inverse = (3 * denominator) ^ 2;
// Use the Newton-Raphson iteration to improve the precision. Thanks to Hensel's lifting lemma, this also
// works in modular arithmetic, doubling the correct bits in each step.
inverse *= 2 - denominator * inverse; // inverse mod 2⁸
inverse *= 2 - denominator * inverse; // inverse mod 2¹⁶
inverse *= 2 - denominator * inverse; // inverse mod 2³²
inverse *= 2 - denominator * inverse; // inverse mod 2⁶⁴
inverse *= 2 - denominator * inverse; // inverse mod 2¹²⁸
inverse *= 2 - denominator * inverse; // inverse mod 2²⁵⁶
// Because the division is now exact we can divide by multiplying with the modular inverse of denominator.
// This will give us the correct result modulo 2²⁵⁶. Since the preconditions guarantee that the outcome is
// less than 2²⁵⁶, this is the final result. We don't need to compute the high bits of the result and prod1
// is no longer required.
result = prod0 * inverse;
return result;
}
}
/**
* @dev Calculates x * y / denominator with full precision, following the selected rounding direction.
*/
function mulDiv(uint256 x, uint256 y, uint256 denominator, Rounding rounding) internal pure returns (uint256) {
return mulDiv(x, y, denominator) + SafeCast.toUint(unsignedRoundsUp(rounding) && mulmod(x, y, denominator) > 0);
}
/**
* @dev Calculate the modular multiplicative inverse of a number in Z/nZ.
*
* If n is a prime, then Z/nZ is a field. In that case all elements are inversible, except 0.
* If n is not a prime, then Z/nZ is not a field, and some elements might not be inversible.
*
* If the input value is not inversible, 0 is returned.
*
* NOTE: If you know for sure that n is (big) a prime, it may be cheaper to use Fermat's little theorem and get the
* inverse using `Math.modExp(a, n - 2, n)`. See {invModPrime}.
*/
function invMod(uint256 a, uint256 n) internal pure returns (uint256) {
unchecked {
if (n == 0) return 0;
// The inverse modulo is calculated using the Extended Euclidean Algorithm (iterative version)
// Used to compute integers x and y such that: ax + ny = gcd(a, n).
// When the gcd is 1, then the inverse of a modulo n exists and it's x.
// ax + ny = 1
// ax = 1 + (-y)n
// ax ≡ 1 (mod n) # x is the inverse of a modulo n
// If the remainder is 0 the gcd is n right away.
uint256 remainder = a % n;
uint256 gcd = n;
// Therefore the initial coefficients are:
// ax + ny = gcd(a, n) = n
// 0a + 1n = n
int256 x = 0;
int256 y = 1;
while (remainder != 0) {
uint256 quotient = gcd / remainder;
(gcd, remainder) = (
// The old remainder is the next gcd to try.
remainder,
// Compute the next remainder.
// Can't overflow given that (a % gcd) * (gcd // (a % gcd)) <= gcd
// where gcd is at most n (capped to type(uint256).max)
gcd - remainder * quotient
);
(x, y) = (
// Increment the coefficient of a.
y,
// Decrement the coefficient of n.
// Can overflow, but the result is casted to uint256 so that the
// next value of y is "wrapped around" to a value between 0 and n - 1.
x - y * int256(quotient)
);
}
if (gcd != 1) return 0; // No inverse exists.
return ternary(x < 0, n - uint256(-x), uint256(x)); // Wrap the result if it's negative.
}
}
/**
* @dev Variant of {invMod}. More efficient, but only works if `p` is known to be a prime greater than `2`.
*
* From https://en.wikipedia.org/wiki/Fermat%27s_little_theorem[Fermat's little theorem], we know that if p is
* prime, then `a**(p-1) ≡ 1 mod p`. As a consequence, we have `a * a**(p-2) ≡ 1 mod p`, which means that
* `a**(p-2)` is the modular multiplicative inverse of a in Fp.
*
* NOTE: this function does NOT check that `p` is a prime greater than `2`.
*/
function invModPrime(uint256 a, uint256 p) internal view returns (uint256) {
unchecked {
return Math.modExp(a, p - 2, p);
}
}
/**
* @dev Returns the modular exponentiation of the specified base, exponent and modulus (b ** e % m)
*
* Requirements:
* - modulus can't be zero
* - underlying staticcall to precompile must succeed
*
* IMPORTANT: The result is only valid if the underlying call succeeds. When using this function, make
* sure the chain you're using it on supports the precompiled contract for modular exponentiation
* at address 0x05 as specified in https://eips.ethereum.org/EIPS/eip-198[EIP-198]. Otherwise,
* the underlying function will succeed given the lack of a revert, but the result may be incorrectly
* interpreted as 0.
*/
function modExp(uint256 b, uint256 e, uint256 m) internal view returns (uint256) {
(bool success, uint256 result) = tryModExp(b, e, m);
if (!success) {
Panic.panic(Panic.DIVISION_BY_ZERO);
}
return result;
}
/**
* @dev Returns the modular exponentiation of the specified base, exponent and modulus (b ** e % m).
* It includes a success flag indicating if the operation succeeded. Operation will be marked as failed if trying
* to operate modulo 0 or if the underlying precompile reverted.
*
* IMPORTANT: The result is only valid if the success flag is true. When using this function, make sure the chain
* you're using it on supports the precompiled contract for modular exponentiation at address 0x05 as specified in
* https://eips.ethereum.org/EIPS/eip-198[EIP-198]. Otherwise, the underlying function will succeed given the lack
* of a revert, but the result may be incorrectly interpreted as 0.
*/
function tryModExp(uint256 b, uint256 e, uint256 m) internal view returns (bool success, uint256 result) {
if (m == 0) return (false, 0);
assembly ("memory-safe") {
let ptr := mload(0x40)
// | Offset | Content | Content (Hex) |
// |-----------|------------|--------------------------------------------------------------------|
// | 0x00:0x1f | size of b | 0x0000000000000000000000000000000000000000000000000000000000000020 |
// | 0x20:0x3f | size of e | 0x0000000000000000000000000000000000000000000000000000000000000020 |
// | 0x40:0x5f | size of m | 0x0000000000000000000000000000000000000000000000000000000000000020 |
// | 0x60:0x7f | value of b | 0x<.............................................................b> |
// | 0x80:0x9f | value of e | 0x<.............................................................e> |
// | 0xa0:0xbf | value of m | 0x<.............................................................m> |
mstore(ptr, 0x20)
mstore(add(ptr, 0x20), 0x20)
mstore(add(ptr, 0x40), 0x20)
mstore(add(ptr, 0x60), b)
mstore(add(ptr, 0x80), e)
mstore(add(ptr, 0xa0), m)
// Given the result < m, it's guaranteed to fit in 32 bytes,
// so we can use the memory scratch space located at offset 0.
success := staticcall(gas(), 0x05, ptr, 0xc0, 0x00, 0x20)
result := mload(0x00)
}
}
/**
* @dev Variant of {modExp} that supports inputs of arbitrary length.
*/
function modExp(bytes memory b, bytes memory e, bytes memory m) internal view returns (bytes memory) {
(bool success, bytes memory result) = tryModExp(b, e, m);
if (!success) {
Panic.panic(Panic.DIVISION_BY_ZERO);
}
return result;
}
/**
* @dev Variant of {tryModExp} that supports inputs of arbitrary length.
*/
function tryModExp(
bytes memory b,
bytes memory e,
bytes memory m
) internal view returns (bool success, bytes memory result) {
if (_zeroBytes(m)) return (false, new bytes(0));
uint256 mLen = m.length;
// Encode call args in result and move the free memory pointer
result = abi.encodePacked(b.length, e.length, mLen, b, e, m);
assembly ("memory-safe") {
let dataPtr := add(result, 0x20)
// Write result on top of args to avoid allocating extra memory.
success := staticcall(gas(), 0x05, dataPtr, mload(result), dataPtr, mLen)
// Overwrite the length.
// result.length > returndatasize() is guaranteed because returndatasize() == m.length
mstore(result, mLen)
// Set the memory pointer after the returned data.
mstore(0x40, add(dataPtr, mLen))
}
}
/**
* @dev Returns whether the provided byte array is zero.
*/
function _zeroBytes(bytes memory byteArray) private pure returns (bool) {
for (uint256 i = 0; i < byteArray.length; ++i) {
if (byteArray[i] != 0) {
return false;
}
}
return true;
}
/**
* @dev Returns the square root of a number. If the number is not a perfect square, the value is rounded
* towards zero.
*
* This method is based on Newton's method for computing square roots; the algorithm is restricted to only
* using integer operations.
*/
function sqrt(uint256 a) internal pure returns (uint256) {
unchecked {
// Take care of easy edge cases when a == 0 or a == 1
if (a <= 1) {
return a;
}
// In this function, we use Newton's method to get a root of `f(x) := x² - a`. It involves building a
// sequence x_n that converges toward sqrt(a). For each iteration x_n, we also define the error between
// the current value as `ε_n = | x_n - sqrt(a) |`.
//
// For our first estimation, we consider `e` the smallest power of 2 which is bigger than the square root
// of the target. (i.e. `2**(e-1) ≤ sqrt(a) < 2**e`). We know that `e ≤ 128` because `(2¹²⁸)² = 2²⁵⁶` is
// bigger than any uint256.
//
// By noticing that
// `2**(e-1) ≤ sqrt(a) < 2**e → (2**(e-1))² ≤ a < (2**e)² → 2**(2*e-2) ≤ a < 2**(2*e)`
// we can deduce that `e - 1` is `log2(a) / 2`. We can thus compute `x_n = 2**(e-1)` using a method similar
// to the msb function.
uint256 aa = a;
uint256 xn = 1;
if (aa >= (1 << 128)) {
aa >>= 128;
xn <<= 64;
}
if (aa >= (1 << 64)) {
aa >>= 64;
xn <<= 32;
}
if (aa >= (1 << 32)) {
aa >>= 32;
xn <<= 16;
}
if (aa >= (1 << 16)) {
aa >>= 16;
xn <<= 8;
}
if (aa >= (1 << 8)) {
aa >>= 8;
xn <<= 4;
}
if (aa >= (1 << 4)) {
aa >>= 4;
xn <<= 2;
}
if (aa >= (1 << 2)) {
xn <<= 1;
}
// We now have x_n such that `x_n = 2**(e-1) ≤ sqrt(a) < 2**e = 2 * x_n`. This implies ε_n ≤ 2**(e-1).
//
// We can refine our estimation by noticing that the middle of that interval minimizes the error.
// If we move x_n to equal 2**(e-1) + 2**(e-2), then we reduce the error to ε_n ≤ 2**(e-2).
// This is going to be our x_0 (and ε_0)
xn = (3 * xn) >> 1; // ε_0 := | x_0 - sqrt(a) | ≤ 2**(e-2)
// From here, Newton's method give us:
// x_{n+1} = (x_n + a / x_n) / 2
//
// One should note that:
// x_{n+1}² - a = ((x_n + a / x_n) / 2)² - a
// = ((x_n² + a) / (2 * x_n))² - a
// = (x_n⁴ + 2 * a * x_n² + a²) / (4 * x_n²) - a
// = (x_n⁴ + 2 * a * x_n² + a² - 4 * a * x_n²) / (4 * x_n²)
// = (x_n⁴ - 2 * a * x_n² + a²) / (4 * x_n²)
// = (x_n² - a)² / (2 * x_n)²
// = ((x_n² - a) / (2 * x_n))²
// ≥ 0
// Which proves that for all n ≥ 1, sqrt(a) ≤ x_n
//
// This gives us the proof of quadratic convergence of the sequence:
// ε_{n+1} = | x_{n+1} - sqrt(a) |
// = | (x_n + a / x_n) / 2 - sqrt(a) |
// = | (x_n² + a - 2*x_n*sqrt(a)) / (2 * x_n) |
// = | (x_n - sqrt(a))² / (2 * x_n) |
// = | ε_n² / (2 * x_n) |
// = ε_n² / | (2 * x_n) |
//
// For the first iteration, we have a special case where x_0 is known:
// ε_1 = ε_0² / | (2 * x_0) |
// ≤ (2**(e-2))² / (2 * (2**(e-1) + 2**(e-2)))
// ≤ 2**(2*e-4) / (3 * 2**(e-1))
// ≤ 2**(e-3) / 3
// ≤ 2**(e-3-log2(3))
// ≤ 2**(e-4.5)
//
// For the following iterations, we use the fact that, 2**(e-1) ≤ sqrt(a) ≤ x_n:
// ε_{n+1} = ε_n² / | (2 * x_n) |
// ≤ (2**(e-k))² / (2 * 2**(e-1))
// ≤ 2**(2*e-2*k) / 2**e
// ≤ 2**(e-2*k)
xn = (xn + a / xn) >> 1; // ε_1 := | x_1 - sqrt(a) | ≤ 2**(e-4.5) -- special case, see above
xn = (xn + a / xn) >> 1; // ε_2 := | x_2 - sqrt(a) | ≤ 2**(e-9) -- general case with k = 4.5
xn = (xn + a / xn) >> 1; // ε_3 := | x_3 - sqrt(a) | ≤ 2**(e-18) -- general case with k = 9
xn = (xn + a / xn) >> 1; // ε_4 := | x_4 - sqrt(a) | ≤ 2**(e-36) -- general case with k = 18
xn = (xn + a / xn) >> 1; // ε_5 := | x_5 - sqrt(a) | ≤ 2**(e-72) -- general case with k = 36
xn = (xn + a / xn) >> 1; // ε_6 := | x_6 - sqrt(a) | ≤ 2**(e-144) -- general case with k = 72
// Because e ≤ 128 (as discussed during the first estimation phase), we know have reached a precision
// ε_6 ≤ 2**(e-144) < 1. Given we're operating on integers, then we can ensure that xn is now either
// sqrt(a) or sqrt(a) + 1.
return xn - SafeCast.toUint(xn > a / xn);
}
}
/**
* @dev Calculates sqrt(a), following the selected rounding direction.
*/
function sqrt(uint256 a, Rounding rounding) internal pure returns (uint256) {
unchecked {
uint256 result = sqrt(a);
return result + SafeCast.toUint(unsignedRoundsUp(rounding) && result * result < a);
}
}
/**
* @dev Return the log in base 2 of a positive value rounded towards zero.
* Returns 0 if given 0.
*/
function log2(uint256 value) internal pure returns (uint256) {
uint256 result = 0;
uint256 exp;
unchecked {
exp = 128 * SafeCast.toUint(value > (1 << 128) - 1);
value >>= exp;
result += exp;
exp = 64 * SafeCast.toUint(value > (1 << 64) - 1);
value >>= exp;
result += exp;
exp = 32 * SafeCast.toUint(value > (1 << 32) - 1);
value >>= exp;
result += exp;
exp = 16 * SafeCast.toUint(value > (1 << 16) - 1);
value >>= exp;
result += exp;
exp = 8 * SafeCast.toUint(value > (1 << 8) - 1);
value >>= exp;
result += exp;
exp = 4 * SafeCast.toUint(value > (1 << 4) - 1);
value >>= exp;
result += exp;
exp = 2 * SafeCast.toUint(value > (1 << 2) - 1);
value >>= exp;
result += exp;
result += SafeCast.toUint(value > 1);
}
return result;
}
/**
* @dev Return the log in base 2, following the selected rounding direction, of a positive value.
* Returns 0 if given 0.
*/
function log2(uint256 value, Rounding rounding) internal pure returns (uint256) {
unchecked {
uint256 result = log2(value);
return result + SafeCast.toUint(unsignedRoundsUp(rounding) && 1 << result < value);
}
}
/**
* @dev Return the log in base 10 of a positive value rounded towards zero.
* Returns 0 if given 0.
*/
function log10(uint256 value) internal pure returns (uint256) {
uint256 result = 0;
unchecked {
if (value >= 10 ** 64) {
value /= 10 ** 64;
result += 64;
}
if (value >= 10 ** 32) {
value /= 10 ** 32;
result += 32;
}
if (value >= 10 ** 16) {
value /= 10 ** 16;
result += 16;
}
if (value >= 10 ** 8) {
value /= 10 ** 8;
result += 8;
}
if (value >= 10 ** 4) {
value /= 10 ** 4;
result += 4;
}
if (value >= 10 ** 2) {
value /= 10 ** 2;
result += 2;
}
if (value >= 10 ** 1) {
result += 1;
}
}
return result;
}
/**
* @dev Return the log in base 10, following the selected rounding direction, of a positive value.
* Returns 0 if given 0.
*/
function log10(uint256 value, Rounding rounding) internal pure returns (uint256) {
unchecked {
uint256 result = log10(value);
return result + SafeCast.toUint(unsignedRoundsUp(rounding) && 10 ** result < value);
}
}
/**
* @dev Return the log in base 256 of a positive value rounded towards zero.
* Returns 0 if given 0.
*
* Adding one to the result gives the number of pairs of hex symbols needed to represent `value` as a hex string.
*/
function log256(uint256 value) internal pure returns (uint256) {
uint256 result = 0;
uint256 isGt;
unchecked {
isGt = SafeCast.toUint(value > (1 << 128) - 1);
value >>= isGt * 128;
result += isGt * 16;
isGt = SafeCast.toUint(value > (1 << 64) - 1);
value >>= isGt * 64;
result += isGt * 8;
isGt = SafeCast.toUint(value > (1 << 32) - 1);
value >>= isGt * 32;
result += isGt * 4;
isGt = SafeCast.toUint(value > (1 << 16) - 1);
value >>= isGt * 16;
result += isGt * 2;
result += SafeCast.toUint(value > (1 << 8) - 1);
}
return result;
}
/**
* @dev Return the log in base 256, following the selected rounding direction, of a positive value.
* Returns 0 if given 0.
*/
function log256(uint256 value, Rounding rounding) internal pure returns (uint256) {
unchecked {
uint256 result = log256(value);
return result + SafeCast.toUint(unsignedRoundsUp(rounding) && 1 << (result << 3) < value);
}
}
/**
* @dev Returns whether a provided rounding mode is considered rounding up for unsigned integers.
*/
function unsignedRoundsUp(Rounding rounding) internal pure returns (bool) {
return uint8(rounding) % 2 == 1;
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.1.0) (proxy/beacon/BeaconProxy.sol)
pragma solidity ^0.8.20;
import {IBeacon} from "./IBeacon.sol";
import {Proxy} from "../Proxy.sol";
import {ERC1967Utils} from "../ERC1967/ERC1967Utils.sol";
/**
* @dev This contract implements a proxy that gets the implementation address for each call from an {UpgradeableBeacon}.
*
* The beacon address can only be set once during construction, and cannot be changed afterwards. It is stored in an
* immutable variable to avoid unnecessary storage reads, and also in the beacon storage slot specified by
* https://eips.ethereum.org/EIPS/eip-1967[ERC-1967] so that it can be accessed externally.
*
* CAUTION: Since the beacon address can never be changed, you must ensure that you either control the beacon, or trust
* the beacon to not upgrade the implementation maliciously.
*
* IMPORTANT: Do not use the implementation logic to modify the beacon storage slot. Doing so would leave the proxy in
* an inconsistent state where the beacon storage slot does not match the beacon address.
*/
contract BeaconProxy is Proxy {
// An immutable address for the beacon to avoid unnecessary SLOADs before each delegate call.
address private immutable _beacon;
/**
* @dev Initializes the proxy with `beacon`.
*
* If `data` is nonempty, it's used as data in a delegate call to the implementation returned by the beacon. This
* will typically be an encoded function call, and allows initializing the storage of the proxy like a Solidity
* constructor.
*
* Requirements:
*
* - `beacon` must be a contract with the interface {IBeacon}.
* - If `data` is empty, `msg.value` must be zero.
*/
constructor(address beacon, bytes memory data) payable {
ERC1967Utils.upgradeBeaconToAndCall(beacon, data);
_beacon = beacon;
}
/**
* @dev Returns the current implementation address of the associated beacon.
*/
function _implementation() internal view virtual override returns (address) {
return IBeacon(_getBeacon()).implementation();
}
/**
* @dev Returns the beacon.
*/
function _getBeacon() internal view virtual returns (address) {
return _beacon;
}
}// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity ^0.8.0;
/// @title The interface for the CL gauge Factory
/// @notice Deploys CL gauges
interface IClGaugeFactory {
/// @dev Emitted when the implementation returned by the beacon is changed.
event Upgraded(address indexed implementation);
/// @notice Emitted when a gauge is created
/// @param pool The address of the pool
/// @param pool The address of the created gauge
event GaugeCreated(address indexed pool, address gauge);
/// @notice Emitted when the NFP Manager is changed
/// @param newNfpManager The address of the new NFP Manager
/// @param oldNfpManager The address of the old NFP Manager
event NfpManagerChanged(address indexed newNfpManager, address indexed oldNfpManager);
/// @notice Emitted when the Fee Collector is changed
/// @param newFeeCollector The address of the new NFP Manager
/// @param oldFeeCollector The address of the old NFP Manager
event FeeCollectorChanged(address indexed newFeeCollector, address indexed oldFeeCollector);
/// @notice Emitted when the Voter is changed
/// @param newVoter The address of the new Voter
/// @param oldVoter The address of the old Voter
event VoterChanged(address indexed newVoter, address indexed oldVoter);
/// @notice Returns the NFP Manager address
function nfpManager() external view returns (address);
/// @notice Set new NFP Manager
function setNfpManager(address _nfpManager) external;
/// @notice Returns Voter
function voter() external view returns (address);
/// @notice Returns the gauge address for a given pool, or address 0 if it does not exist
/// @param pool The pool address
/// @return gauge The gauge address
function getGauge(address pool) external view returns (address gauge);
/// @notice Returns the address of the fee collector contract
/// @dev Fee collector decides where the protocol fees go (fee distributor, treasury, etc.)
function feeCollector() external view returns (address);
/// @notice Creates a gauge for the given pool
/// @param pool One of the desired gauge
/// @return gauge The address of the newly created gauge
function createGauge(address pool) external returns (address gauge);
/// @notice returns the GaugeV3 implementation
function implementation() external returns (address);
/// @notice Sets implementation for all GaugeV3s
function setImplementation(address _newImplementation) external;
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.1.0) (proxy/ERC1967/ERC1967Utils.sol)
pragma solidity ^0.8.21;
import {IBeacon} from "../beacon/IBeacon.sol";
import {IERC1967} from "../../interfaces/IERC1967.sol";
import {Address} from "../../utils/Address.sol";
import {StorageSlot} from "../../utils/StorageSlot.sol";
/**
* @dev This library provides getters and event emitting update functions for
* https://eips.ethereum.org/EIPS/eip-1967[ERC-1967] slots.
*/
library ERC1967Utils {
/**
* @dev Storage slot with the address of the current implementation.
* This is the keccak-256 hash of "eip1967.proxy.implementation" subtracted by 1.
*/
// solhint-disable-next-line private-vars-leading-underscore
bytes32 internal constant IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;
/**
* @dev The `implementation` of the proxy is invalid.
*/
error ERC1967InvalidImplementation(address implementation);
/**
* @dev The `admin` of the proxy is invalid.
*/
error ERC1967InvalidAdmin(address admin);
/**
* @dev The `beacon` of the proxy is invalid.
*/
error ERC1967InvalidBeacon(address beacon);
/**
* @dev An upgrade function sees `msg.value > 0` that may be lost.
*/
error ERC1967NonPayable();
/**
* @dev Returns the current implementation address.
*/
function getImplementation() internal view returns (address) {
return StorageSlot.getAddressSlot(IMPLEMENTATION_SLOT).value;
}
/**
* @dev Stores a new address in the ERC-1967 implementation slot.
*/
function _setImplementation(address newImplementation) private {
if (newImplementation.code.length == 0) {
revert ERC1967InvalidImplementation(newImplementation);
}
StorageSlot.getAddressSlot(IMPLEMENTATION_SLOT).value = newImplementation;
}
/**
* @dev Performs implementation upgrade with additional setup call if data is nonempty.
* This function is payable only if the setup call is performed, otherwise `msg.value` is rejected
* to avoid stuck value in the contract.
*
* Emits an {IERC1967-Upgraded} event.
*/
function upgradeToAndCall(address newImplementation, bytes memory data) internal {
_setImplementation(newImplementation);
emit IERC1967.Upgraded(newImplementation);
if (data.length > 0) {
Address.functionDelegateCall(newImplementation, data);
} else {
_checkNonPayable();
}
}
/**
* @dev Storage slot with the admin of the contract.
* This is the keccak-256 hash of "eip1967.proxy.admin" subtracted by 1.
*/
// solhint-disable-next-line private-vars-leading-underscore
bytes32 internal constant ADMIN_SLOT = 0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103;
/**
* @dev Returns the current admin.
*
* TIP: To get this value clients can read directly from the storage slot shown below (specified by ERC-1967) using
* the https://eth.wiki/json-rpc/API#eth_getstorageat[`eth_getStorageAt`] RPC call.
* `0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103`
*/
function getAdmin() internal view returns (address) {
return StorageSlot.getAddressSlot(ADMIN_SLOT).value;
}
/**
* @dev Stores a new address in the ERC-1967 admin slot.
*/
function _setAdmin(address newAdmin) private {
if (newAdmin == address(0)) {
revert ERC1967InvalidAdmin(address(0));
}
StorageSlot.getAddressSlot(ADMIN_SLOT).value = newAdmin;
}
/**
* @dev Changes the admin of the proxy.
*
* Emits an {IERC1967-AdminChanged} event.
*/
function changeAdmin(address newAdmin) internal {
emit IERC1967.AdminChanged(getAdmin(), newAdmin);
_setAdmin(newAdmin);
}
/**
* @dev The storage slot of the UpgradeableBeacon contract which defines the implementation for this proxy.
* This is the keccak-256 hash of "eip1967.proxy.beacon" subtracted by 1.
*/
// solhint-disable-next-line private-vars-leading-underscore
bytes32 internal constant BEACON_SLOT = 0xa3f0ad74e5423aebfd80d3ef4346578335a9a72aeaee59ff6cb3582b35133d50;
/**
* @dev Returns the current beacon.
*/
function getBeacon() internal view returns (address) {
return StorageSlot.getAddressSlot(BEACON_SLOT).value;
}
/**
* @dev Stores a new beacon in the ERC-1967 beacon slot.
*/
function _setBeacon(address newBeacon) private {
if (newBeacon.code.length == 0) {
revert ERC1967InvalidBeacon(newBeacon);
}
StorageSlot.getAddressSlot(BEACON_SLOT).value = newBeacon;
address beaconImplementation = IBeacon(newBeacon).implementation();
if (beaconImplementation.code.length == 0) {
revert ERC1967InvalidImplementation(beaconImplementation);
}
}
/**
* @dev Change the beacon and trigger a setup call if data is nonempty.
* This function is payable only if the setup call is performed, otherwise `msg.value` is rejected
* to avoid stuck value in the contract.
*
* Emits an {IERC1967-BeaconUpgraded} event.
*
* CAUTION: Invoking this function has no effect on an instance of {BeaconProxy} since v5, since
* it uses an immutable beacon without looking at the value of the ERC-1967 beacon slot for
* efficiency.
*/
function upgradeBeaconToAndCall(address newBeacon, bytes memory data) internal {
_setBeacon(newBeacon);
emit IERC1967.BeaconUpgraded(newBeacon);
if (data.length > 0) {
Address.functionDelegateCall(IBeacon(newBeacon).implementation(), data);
} else {
_checkNonPayable();
}
}
/**
* @dev Reverts if `msg.value` is not zero. It can be used to avoid `msg.value` stuck in the contract
* if an upgrade doesn't perform an initialization call.
*/
function _checkNonPayable() private {
if (msg.value > 0) {
revert ERC1967NonPayable();
}
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.1.0) (proxy/ERC1967/ERC1967Proxy.sol)
pragma solidity ^0.8.20;
import {Proxy} from "../Proxy.sol";
import {ERC1967Utils} from "./ERC1967Utils.sol";
/**
* @dev This contract implements an upgradeable proxy. It is upgradeable because calls are delegated to an
* implementation address that can be changed. This address is stored in storage in the location specified by
* https://eips.ethereum.org/EIPS/eip-1967[ERC-1967], so that it doesn't conflict with the storage layout of the
* implementation behind the proxy.
*/
contract ERC1967Proxy is Proxy {
/**
* @dev Initializes the upgradeable proxy with an initial implementation specified by `implementation`.
*
* If `_data` is nonempty, it's used as data in a delegate call to `implementation`. This will typically be an
* encoded function call, and allows initializing the storage of the proxy like a Solidity constructor.
*
* Requirements:
*
* - If `data` is empty, `msg.value` must be zero.
*/
constructor(address implementation, bytes memory _data) payable {
ERC1967Utils.upgradeToAndCall(implementation, _data);
}
/**
* @dev Returns the current implementation address.
*
* TIP: To get this value clients can read directly from the storage slot shown below (specified by ERC-1967) using
* the https://eth.wiki/json-rpc/API#eth_getstorageat[`eth_getStorageAt`] RPC call.
* `0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc`
*/
function _implementation() internal view virtual override returns (address) {
return ERC1967Utils.getImplementation();
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (interfaces/IERC1967.sol)
pragma solidity ^0.8.20;
/**
* @dev ERC-1967: Proxy Storage Slots. This interface contains the events defined in the ERC.
*/
interface IERC1967 {
/**
* @dev Emitted when the implementation is upgraded.
*/
event Upgraded(address indexed implementation);
/**
* @dev Emitted when the admin account has changed.
*/
event AdminChanged(address previousAdmin, address newAdmin);
/**
* @dev Emitted when the beacon is changed.
*/
event BeaconUpgraded(address indexed beacon);
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.1.0) (proxy/transparent/ProxyAdmin.sol)
pragma solidity ^0.8.20;
import {ITransparentUpgradeableProxy} from "./TransparentUpgradeableProxy.sol";
import {Ownable} from "../../access/Ownable.sol";
/**
* @dev This is an auxiliary contract meant to be assigned as the admin of a {TransparentUpgradeableProxy}. For an
* explanation of why you would want to use this see the documentation for {TransparentUpgradeableProxy}.
*/
contract ProxyAdmin is Ownable {
/**
* @dev The version of the upgrade interface of the contract. If this getter is missing, both `upgrade(address,address)`
* and `upgradeAndCall(address,address,bytes)` are present, and `upgrade` must be used if no function should be called,
* while `upgradeAndCall` will invoke the `receive` function if the third argument is the empty byte string.
* If the getter returns `"5.0.0"`, only `upgradeAndCall(address,address,bytes)` is present, and the third argument must
* be the empty byte string if no function should be called, making it impossible to invoke the `receive` function
* during an upgrade.
*/
string public constant UPGRADE_INTERFACE_VERSION = "5.0.0";
/**
* @dev Sets the initial owner who can perform upgrades.
*/
constructor(address initialOwner) Ownable(initialOwner) {}
/**
* @dev Upgrades `proxy` to `implementation` and calls a function on the new implementation.
* See {TransparentUpgradeableProxy-_dispatchUpgradeToAndCall}.
*
* Requirements:
*
* - This contract must be the admin of `proxy`.
* - If `data` is empty, `msg.value` must be zero.
*/
function upgradeAndCall(
ITransparentUpgradeableProxy proxy,
address implementation,
bytes memory data
) public payable virtual onlyOwner {
proxy.upgradeToAndCall{value: msg.value}(implementation, data);
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.1.0) (access/IAccessControl.sol)
pragma solidity ^0.8.20;
/**
* @dev External interface of AccessControl declared to support ERC-165 detection.
*/
interface IAccessControl {
/**
* @dev The `account` is missing a role.
*/
error AccessControlUnauthorizedAccount(address account, bytes32 neededRole);
/**
* @dev The caller of a function is not the expected one.
*
* NOTE: Don't confuse with {AccessControlUnauthorizedAccount}.
*/
error AccessControlBadConfirmation();
/**
* @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.
*/
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. This account bears the admin role (for the granted role).
* Expected in cases where the role was granted using the internal {AccessControl-_grantRole}.
*/
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 `callerConfirmation`.
*/
function renounceRole(bytes32 role, address callerConfirmation) external;
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.1) (utils/Context.sol)
pragma solidity ^0.8.20;
import {Initializable} from "../proxy/utils/Initializable.sol";
/**
* @dev Provides information about the current execution context, including the
* sender of the transaction and its data. While these are generally available
* via msg.sender and msg.data, they should not be accessed in such a direct
* manner, since when dealing with meta-transactions the account sending and
* paying for execution may not be the actual sender (as far as an application
* is concerned).
*
* This contract is only required for intermediate, library-like contracts.
*/
abstract contract ContextUpgradeable is Initializable {
function __Context_init() internal onlyInitializing {
}
function __Context_init_unchained() internal onlyInitializing {
}
function _msgSender() internal view virtual returns (address) {
return msg.sender;
}
function _msgData() internal view virtual returns (bytes calldata) {
return msg.data;
}
function _contextSuffixLength() internal view virtual returns (uint256) {
return 0;
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.1.0) (utils/introspection/ERC165.sol)
pragma solidity ^0.8.20;
import {IERC165} from "@openzeppelin/contracts/utils/introspection/IERC165.sol";
import {Initializable} from "../../proxy/utils/Initializable.sol";
/**
* @dev Implementation of the {IERC165} interface.
*
* Contracts that want to implement ERC-165 should inherit from this contract and override {supportsInterface} to check
* for the additional interface id that will be supported. For example:
*
* ```solidity
* function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
* return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId);
* }
* ```
*/
abstract contract ERC165Upgradeable is Initializable, IERC165 {
function __ERC165_init() internal onlyInitializing {
}
function __ERC165_init_unchained() internal onlyInitializing {
}
/**
* @dev See {IERC165-supportsInterface}.
*/
function supportsInterface(bytes4 interfaceId) public view virtual returns (bool) {
return interfaceId == type(IERC165).interfaceId;
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.1) (utils/Context.sol)
pragma solidity ^0.8.20;
/**
* @dev Provides information about the current execution context, including the
* sender of the transaction and its data. While these are generally available
* via msg.sender and msg.data, they should not be accessed in such a direct
* manner, since when dealing with meta-transactions the account sending and
* paying for execution may not be the actual sender (as far as an application
* is concerned).
*
* This contract is only required for intermediate, library-like contracts.
*/
abstract contract Context {
function _msgSender() internal view virtual returns (address) {
return msg.sender;
}
function _msgData() internal view virtual returns (bytes calldata) {
return msg.data;
}
function _contextSuffixLength() internal view virtual returns (uint256) {
return 0;
}
}// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity >=0.7.5;
pragma abicoder v2;
/// @title Creates and initializes V3 Pools
/// @notice Provides a method for creating and initializing a pool, if necessary, for bundling with other methods that
/// require the pool to exist.
interface IPoolInitializer {
/// @notice Creates a new pool if it does not exist, then initializes if not initialized
/// @dev This method can be bundled with others via IMulticall for the first action (e.g. mint) performed against a pool
/// @param token0 The contract address of token0 of the pool
/// @param token1 The contract address of token1 of the pool
/// @param tickSpacing The tickSpacing of the v3 pool for the specified token pair
/// @param sqrtPriceX96 The initial square root price of the pool as a Q64.96 value
/// @return pool Returns the pool address based on the pair of tokens and fee, will return the newly created pool address if necessary
function createAndInitializePoolIfNecessary(
address token0,
address token1,
int24 tickSpacing,
uint160 sqrtPriceX96
) external payable returns (address pool);
}// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity >=0.7.5;
/// @title Periphery Payments
/// @notice Functions to ease deposits and withdrawals of ETH
interface IPeripheryPayments {
/// @notice Unwraps the contract's WETH9 balance and sends it to recipient as ETH.
/// @dev The amountMinimum parameter prevents malicious contracts from stealing WETH9 from users.
/// @param amountMinimum The minimum amount of WETH9 to unwrap
/// @param recipient The address receiving ETH
function unwrapWETH9(uint256 amountMinimum, address recipient) external payable;
/// @notice Refunds any ETH balance held by this contract to the `msg.sender`
/// @dev Useful for bundling with mint or increase liquidity that uses ether, or exact output swaps
/// that use ether for the input amount
function refundETH() external payable;
/// @notice Transfers the full amount of a token held by this contract to recipient
/// @dev The amountMinimum parameter prevents malicious contracts from stealing the token from users
/// @param token The contract address of the token which will be transferred to `recipient`
/// @param amountMinimum The minimum amount of token required for a transfer
/// @param recipient The destination address of the token
function sweepToken(
address token,
uint256 amountMinimum,
address recipient
) external payable;
}// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity >=0.5.0;
/// @title Immutable state
/// @notice Functions that return immutable state of the router
interface IPeripheryImmutableState {
/// @return Returns the address of the Uniswap V3 deployer
function deployer() external view returns (address);
/// @return Returns the address of WETH9
function WETH9() external view returns (address);
}// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity >=0.5.0;
/// @title Provides functions for deriving a pool address from the deployer, tokens, and the fee
library PoolAddress {
bytes32 internal constant POOL_INIT_CODE_HASH = 0x892f127ed4b26ca352056c8fb54585a3268f76f97fdd84d5836ef4bda8d8c685;
/// @notice The identifying key of the pool
struct PoolKey {
address token0;
address token1;
int24 tickSpacing;
}
/// @notice Returns PoolKey: the ordered tokens with the matched fee levels
/// @param tokenA The first token of a pool, unsorted
/// @param tokenB The second token of a pool, unsorted
/// @param tickSpacing The tickSpacing of the pool
/// @return Poolkey The pool details with ordered token0 and token1 assignments
function getPoolKey(address tokenA, address tokenB, int24 tickSpacing) internal pure returns (PoolKey memory) {
if (tokenA > tokenB) (tokenA, tokenB) = (tokenB, tokenA);
return PoolKey({token0: tokenA, token1: tokenB, tickSpacing: tickSpacing});
}
/// @notice Deterministically computes the pool address given the deployer and PoolKey
/// @param deployer The Uniswap V3 deployer contract address
/// @param key The PoolKey
/// @return pool The contract address of the V3 pool
function computeAddress(address deployer, PoolKey memory key) internal pure returns (address pool) {
require(key.token0 < key.token1, "!TokenOrder");
pool = address(
uint160(
uint256(
keccak256(
abi.encodePacked(
hex'ff',
deployer,
keccak256(abi.encode(key.token0, key.token1, key.tickSpacing)),
POOL_INIT_CODE_HASH
)
)
)
)
);
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.1.0) (token/ERC721/IERC721.sol)
pragma solidity ^0.8.20;
import {IERC165} from "../../utils/introspection/IERC165.sol";
/**
* @dev Required interface of an ERC-721 compliant contract.
*/
interface IERC721 is IERC165 {
/**
* @dev Emitted when `tokenId` token is transferred from `from` to `to`.
*/
event Transfer(address indexed from, address indexed to, uint256 indexed tokenId);
/**
* @dev Emitted when `owner` enables `approved` to manage the `tokenId` token.
*/
event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId);
/**
* @dev Emitted when `owner` enables or disables (`approved`) `operator` to manage all of its assets.
*/
event ApprovalForAll(address indexed owner, address indexed operator, bool approved);
/**
* @dev Returns the number of tokens in ``owner``'s account.
*/
function balanceOf(address owner) external view returns (uint256 balance);
/**
* @dev Returns the owner of the `tokenId` token.
*
* Requirements:
*
* - `tokenId` must exist.
*/
function ownerOf(uint256 tokenId) external view returns (address owner);
/**
* @dev Safely transfers `tokenId` token from `from` to `to`.
*
* Requirements:
*
* - `from` cannot be the zero address.
* - `to` cannot be the zero address.
* - `tokenId` token must exist and be owned by `from`.
* - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.
* - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon
* a safe transfer.
*
* Emits a {Transfer} event.
*/
function safeTransferFrom(address from, address to, uint256 tokenId, bytes calldata data) external;
/**
* @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients
* are aware of the ERC-721 protocol to prevent tokens from being forever locked.
*
* Requirements:
*
* - `from` cannot be the zero address.
* - `to` cannot be the zero address.
* - `tokenId` token must exist and be owned by `from`.
* - If the caller is not `from`, it must have been allowed to move this token by either {approve} or
* {setApprovalForAll}.
* - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon
* a safe transfer.
*
* Emits a {Transfer} event.
*/
function safeTransferFrom(address from, address to, uint256 tokenId) external;
/**
* @dev Transfers `tokenId` token from `from` to `to`.
*
* WARNING: Note that the caller is responsible to confirm that the recipient is capable of receiving ERC-721
* or else they may be permanently lost. Usage of {safeTransferFrom} prevents loss, though the caller must
* understand this adds an external call which potentially creates a reentrancy vulnerability.
*
* Requirements:
*
* - `from` cannot be the zero address.
* - `to` cannot be the zero address.
* - `tokenId` token must be owned by `from`.
* - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.
*
* Emits a {Transfer} event.
*/
function transferFrom(address from, address to, uint256 tokenId) external;
/**
* @dev Gives permission to `to` to transfer `tokenId` token to another account.
* The approval is cleared when the token is transferred.
*
* Only a single account can be approved at a time, so approving the zero address clears previous approvals.
*
* Requirements:
*
* - The caller must own the token or be an approved operator.
* - `tokenId` must exist.
*
* Emits an {Approval} event.
*/
function approve(address to, uint256 tokenId) external;
/**
* @dev Approve or remove `operator` as an operator for the caller.
* Operators can call {transferFrom} or {safeTransferFrom} for any token owned by the caller.
*
* Requirements:
*
* - The `operator` cannot be the address zero.
*
* Emits an {ApprovalForAll} event.
*/
function setApprovalForAll(address operator, bool approved) external;
/**
* @dev Returns the account approved for `tokenId` token.
*
* Requirements:
*
* - `tokenId` must exist.
*/
function getApproved(uint256 tokenId) external view returns (address operator);
/**
* @dev Returns if the `operator` is allowed to manage all of the assets of `owner`.
*
* See {setApprovalForAll}
*/
function isApprovedForAll(address owner, address operator) external view returns (bool);
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (token/ERC721/extensions/IERC721Metadata.sol)
pragma solidity ^0.8.20;
import {IERC721} from "../IERC721.sol";
/**
* @title ERC-721 Non-Fungible Token Standard, optional metadata extension
* @dev See https://eips.ethereum.org/EIPS/eip-721
*/
interface IERC721Metadata is IERC721 {
/**
* @dev Returns the token collection name.
*/
function name() external view returns (string memory);
/**
* @dev Returns the token collection symbol.
*/
function symbol() external view returns (string memory);
/**
* @dev Returns the Uniform Resource Identifier (URI) for `tokenId` token.
*/
function tokenURI(uint256 tokenId) external view returns (string memory);
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (token/ERC721/extensions/IERC721Enumerable.sol)
pragma solidity ^0.8.20;
import {IERC721} from "../IERC721.sol";
/**
* @title ERC-721 Non-Fungible Token Standard, optional enumeration extension
* @dev See https://eips.ethereum.org/EIPS/eip-721
*/
interface IERC721Enumerable is IERC721 {
/**
* @dev Returns the total amount of tokens stored by the contract.
*/
function totalSupply() external view returns (uint256);
/**
* @dev Returns a token ID owned by `owner` at a given `index` of its token list.
* Use along with {balanceOf} to enumerate all of ``owner``'s tokens.
*/
function tokenOfOwnerByIndex(address owner, uint256 index) external view returns (uint256);
/**
* @dev Returns a token ID at a given `index` of all the tokens stored by the contract.
* Use along with {totalSupply} to enumerate all tokens.
*/
function tokenByIndex(uint256 index) external view returns (uint256);
}// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity >=0.5.0;
/// @title Errors emitted by the NonFungiblePositionManager
/// @notice Contains all events emitted by the NfpManager
interface IPeripheryErrors {
error InvalidTokenId(uint256 tokenId);
error CheckSlippage();
error NotCleared();
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.1.0) (interfaces/IERC1363.sol)
pragma solidity ^0.8.20;
import {IERC20} from "./IERC20.sol";
import {IERC165} from "./IERC165.sol";
/**
* @title IERC1363
* @dev Interface of the ERC-1363 standard as defined in the https://eips.ethereum.org/EIPS/eip-1363[ERC-1363].
*
* Defines an extension interface for ERC-20 tokens that supports executing code on a recipient contract
* after `transfer` or `transferFrom`, or code on a spender contract after `approve`, in a single transaction.
*/
interface IERC1363 is IERC20, IERC165 {
/*
* Note: the ERC-165 identifier for this interface is 0xb0202a11.
* 0xb0202a11 ===
* bytes4(keccak256('transferAndCall(address,uint256)')) ^
* bytes4(keccak256('transferAndCall(address,uint256,bytes)')) ^
* bytes4(keccak256('transferFromAndCall(address,address,uint256)')) ^
* bytes4(keccak256('transferFromAndCall(address,address,uint256,bytes)')) ^
* bytes4(keccak256('approveAndCall(address,uint256)')) ^
* bytes4(keccak256('approveAndCall(address,uint256,bytes)'))
*/
/**
* @dev Moves a `value` amount of tokens from the caller's account to `to`
* and then calls {IERC1363Receiver-onTransferReceived} on `to`.
* @param to The address which you want to transfer to.
* @param value The amount of tokens to be transferred.
* @return A boolean value indicating whether the operation succeeded unless throwing.
*/
function transferAndCall(address to, uint256 value) external returns (bool);
/**
* @dev Moves a `value` amount of tokens from the caller's account to `to`
* and then calls {IERC1363Receiver-onTransferReceived} on `to`.
* @param to The address which you want to transfer to.
* @param value The amount of tokens to be transferred.
* @param data Additional data with no specified format, sent in call to `to`.
* @return A boolean value indicating whether the operation succeeded unless throwing.
*/
function transferAndCall(address to, uint256 value, bytes calldata data) external returns (bool);
/**
* @dev Moves a `value` amount of tokens from `from` to `to` using the allowance mechanism
* and then calls {IERC1363Receiver-onTransferReceived} on `to`.
* @param from The address which you want to send tokens from.
* @param to The address which you want to transfer to.
* @param value The amount of tokens to be transferred.
* @return A boolean value indicating whether the operation succeeded unless throwing.
*/
function transferFromAndCall(address from, address to, uint256 value) external returns (bool);
/**
* @dev Moves a `value` amount of tokens from `from` to `to` using the allowance mechanism
* and then calls {IERC1363Receiver-onTransferReceived} on `to`.
* @param from The address which you want to send tokens from.
* @param to The address which you want to transfer to.
* @param value The amount of tokens to be transferred.
* @param data Additional data with no specified format, sent in call to `to`.
* @return A boolean value indicating whether the operation succeeded unless throwing.
*/
function transferFromAndCall(address from, address to, uint256 value, bytes calldata data) external returns (bool);
/**
* @dev Sets a `value` amount of tokens as the allowance of `spender` over the
* caller's tokens and then calls {IERC1363Spender-onApprovalReceived} on `spender`.
* @param spender The address which will spend the funds.
* @param value The amount of tokens to be spent.
* @return A boolean value indicating whether the operation succeeded unless throwing.
*/
function approveAndCall(address spender, uint256 value) external returns (bool);
/**
* @dev Sets a `value` amount of tokens as the allowance of `spender` over the
* caller's tokens and then calls {IERC1363Spender-onApprovalReceived} on `spender`.
* @param spender The address which will spend the funds.
* @param value The amount of tokens to be spent.
* @param data Additional data with no specified format, sent in call to `spender`.
* @return A boolean value indicating whether the operation succeeded unless throwing.
*/
function approveAndCall(address spender, uint256 value, bytes calldata data) external returns (bool);
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.1.0) (utils/Address.sol)
pragma solidity ^0.8.20;
import {Errors} from "./Errors.sol";
/**
* @dev Collection of functions related to the address type
*/
library Address {
/**
* @dev There's no code at `target` (it is not a contract).
*/
error AddressEmptyCode(address target);
/**
* @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://consensys.net/diligence/blog/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.8.20/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].
*/
function sendValue(address payable recipient, uint256 amount) internal {
if (address(this).balance < amount) {
revert Errors.InsufficientBalance(address(this).balance, amount);
}
(bool success, ) = recipient.call{value: amount}("");
if (!success) {
revert Errors.FailedCall();
}
}
/**
* @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 or custom error, it is bubbled
* up by this function (like regular Solidity function calls). However, if
* the call reverted with no returned reason, this function reverts with a
* {Errors.FailedCall} error.
*
* 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.
*/
function functionCall(address target, bytes memory data) internal returns (bytes memory) {
return functionCallWithValue(target, data, 0);
}
/**
* @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`.
*/
function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) {
if (address(this).balance < value) {
revert Errors.InsufficientBalance(address(this).balance, value);
}
(bool success, bytes memory returndata) = target.call{value: value}(data);
return verifyCallResultFromTarget(target, success, returndata);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but performing a static call.
*/
function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {
(bool success, bytes memory returndata) = target.staticcall(data);
return verifyCallResultFromTarget(target, success, returndata);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but performing a delegate call.
*/
function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {
(bool success, bytes memory returndata) = target.delegatecall(data);
return verifyCallResultFromTarget(target, success, returndata);
}
/**
* @dev Tool to verify that a low level call to smart-contract was successful, and reverts if the target
* was not a contract or bubbling up the revert reason (falling back to {Errors.FailedCall}) in case
* of an unsuccessful call.
*/
function verifyCallResultFromTarget(
address target,
bool success,
bytes memory returndata
) internal view returns (bytes memory) {
if (!success) {
_revert(returndata);
} else {
// only check if target is a contract if the call was successful and the return data is empty
// otherwise we already know that it was a contract
if (returndata.length == 0 && target.code.length == 0) {
revert AddressEmptyCode(target);
}
return returndata;
}
}
/**
* @dev Tool to verify that a low level call was successful, and reverts if it wasn't, either by bubbling the
* revert reason or with a default {Errors.FailedCall} error.
*/
function verifyCallResult(bool success, bytes memory returndata) internal pure returns (bytes memory) {
if (!success) {
_revert(returndata);
} else {
return returndata;
}
}
/**
* @dev Reverts with returndata if present. Otherwise reverts with {Errors.FailedCall}.
*/
function _revert(bytes memory returndata) 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
assembly ("memory-safe") {
let returndata_size := mload(returndata)
revert(add(32, returndata), returndata_size)
}
} else {
revert Errors.FailedCall();
}
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.1.0) (utils/Panic.sol)
pragma solidity ^0.8.20;
/**
* @dev Helper library for emitting standardized panic codes.
*
* ```solidity
* contract Example {
* using Panic for uint256;
*
* // Use any of the declared internal constants
* function foo() { Panic.GENERIC.panic(); }
*
* // Alternatively
* function foo() { Panic.panic(Panic.GENERIC); }
* }
* ```
*
* Follows the list from https://github.com/ethereum/solidity/blob/v0.8.24/libsolutil/ErrorCodes.h[libsolutil].
*
* _Available since v5.1._
*/
// slither-disable-next-line unused-state
library Panic {
/// @dev generic / unspecified error
uint256 internal constant GENERIC = 0x00;
/// @dev used by the assert() builtin
uint256 internal constant ASSERT = 0x01;
/// @dev arithmetic underflow or overflow
uint256 internal constant UNDER_OVERFLOW = 0x11;
/// @dev division or modulo by zero
uint256 internal constant DIVISION_BY_ZERO = 0x12;
/// @dev enum conversion error
uint256 internal constant ENUM_CONVERSION_ERROR = 0x21;
/// @dev invalid encoding in storage
uint256 internal constant STORAGE_ENCODING_ERROR = 0x22;
/// @dev empty array pop
uint256 internal constant EMPTY_ARRAY_POP = 0x31;
/// @dev array out of bounds access
uint256 internal constant ARRAY_OUT_OF_BOUNDS = 0x32;
/// @dev resource error (too large allocation or too large array)
uint256 internal constant RESOURCE_ERROR = 0x41;
/// @dev calling invalid internal function
uint256 internal constant INVALID_INTERNAL_FUNCTION = 0x51;
/// @dev Reverts with a panic code. Recommended to use with
/// the internal constants with predefined codes.
function panic(uint256 code) internal pure {
assembly ("memory-safe") {
mstore(0x00, 0x4e487b71)
mstore(0x20, code)
revert(0x1c, 0x24)
}
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.1.0) (utils/math/SafeCast.sol)
// This file was procedurally generated from scripts/generate/templates/SafeCast.js.
pragma solidity ^0.8.20;
/**
* @dev Wrappers over Solidity's uintXX/intXX/bool 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.
*/
library SafeCast {
/**
* @dev Value doesn't fit in an uint of `bits` size.
*/
error SafeCastOverflowedUintDowncast(uint8 bits, uint256 value);
/**
* @dev An int value doesn't fit in an uint of `bits` size.
*/
error SafeCastOverflowedIntToUint(int256 value);
/**
* @dev Value doesn't fit in an int of `bits` size.
*/
error SafeCastOverflowedIntDowncast(uint8 bits, int256 value);
/**
* @dev An uint value doesn't fit in an int of `bits` size.
*/
error SafeCastOverflowedUintToInt(uint256 value);
/**
* @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
*/
function toUint248(uint256 value) internal pure returns (uint248) {
if (value > type(uint248).max) {
revert SafeCastOverflowedUintDowncast(248, value);
}
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
*/
function toUint240(uint256 value) internal pure returns (uint240) {
if (value > type(uint240).max) {
revert SafeCastOverflowedUintDowncast(240, value);
}
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
*/
function toUint232(uint256 value) internal pure returns (uint232) {
if (value > type(uint232).max) {
revert SafeCastOverflowedUintDowncast(232, value);
}
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
*/
function toUint224(uint256 value) internal pure returns (uint224) {
if (value > type(uint224).max) {
revert SafeCastOverflowedUintDowncast(224, value);
}
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
*/
function toUint216(uint256 value) internal pure returns (uint216) {
if (value > type(uint216).max) {
revert SafeCastOverflowedUintDowncast(216, value);
}
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
*/
function toUint208(uint256 value) internal pure returns (uint208) {
if (value > type(uint208).max) {
revert SafeCastOverflowedUintDowncast(208, value);
}
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
*/
function toUint200(uint256 value) internal pure returns (uint200) {
if (value > type(uint200).max) {
revert SafeCastOverflowedUintDowncast(200, value);
}
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
*/
function toUint192(uint256 value) internal pure returns (uint192) {
if (value > type(uint192).max) {
revert SafeCastOverflowedUintDowncast(192, value);
}
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
*/
function toUint184(uint256 value) internal pure returns (uint184) {
if (value > type(uint184).max) {
revert SafeCastOverflowedUintDowncast(184, value);
}
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
*/
function toUint176(uint256 value) internal pure returns (uint176) {
if (value > type(uint176).max) {
revert SafeCastOverflowedUintDowncast(176, value);
}
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
*/
function toUint168(uint256 value) internal pure returns (uint168) {
if (value > type(uint168).max) {
revert SafeCastOverflowedUintDowncast(168, value);
}
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
*/
function toUint160(uint256 value) internal pure returns (uint160) {
if (value > type(uint160).max) {
revert SafeCastOverflowedUintDowncast(160, value);
}
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
*/
function toUint152(uint256 value) internal pure returns (uint152) {
if (value > type(uint152).max) {
revert SafeCastOverflowedUintDowncast(152, value);
}
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
*/
function toUint144(uint256 value) internal pure returns (uint144) {
if (value > type(uint144).max) {
revert SafeCastOverflowedUintDowncast(144, value);
}
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
*/
function toUint136(uint256 value) internal pure returns (uint136) {
if (value > type(uint136).max) {
revert SafeCastOverflowedUintDowncast(136, value);
}
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
*/
function toUint128(uint256 value) internal pure returns (uint128) {
if (value > type(uint128).max) {
revert SafeCastOverflowedUintDowncast(128, value);
}
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
*/
function toUint120(uint256 value) internal pure returns (uint120) {
if (value > type(uint120).max) {
revert SafeCastOverflowedUintDowncast(120, value);
}
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
*/
function toUint112(uint256 value) internal pure returns (uint112) {
if (value > type(uint112).max) {
revert SafeCastOverflowedUintDowncast(112, value);
}
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
*/
function toUint104(uint256 value) internal pure returns (uint104) {
if (value > type(uint104).max) {
revert SafeCastOverflowedUintDowncast(104, value);
}
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
*/
function toUint96(uint256 value) internal pure returns (uint96) {
if (value > type(uint96).max) {
revert SafeCastOverflowedUintDowncast(96, value);
}
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
*/
function toUint88(uint256 value) internal pure returns (uint88) {
if (value > type(uint88).max) {
revert SafeCastOverflowedUintDowncast(88, value);
}
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
*/
function toUint80(uint256 value) internal pure returns (uint80) {
if (value > type(uint80).max) {
revert SafeCastOverflowedUintDowncast(80, value);
}
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
*/
function toUint72(uint256 value) internal pure returns (uint72) {
if (value > type(uint72).max) {
revert SafeCastOverflowedUintDowncast(72, value);
}
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
*/
function toUint64(uint256 value) internal pure returns (uint64) {
if (value > type(uint64).max) {
revert SafeCastOverflowedUintDowncast(64, value);
}
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
*/
function toUint56(uint256 value) internal pure returns (uint56) {
if (value > type(uint56).max) {
revert SafeCastOverflowedUintDowncast(56, value);
}
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
*/
function toUint48(uint256 value) internal pure returns (uint48) {
if (value > type(uint48).max) {
revert SafeCastOverflowedUintDowncast(48, value);
}
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
*/
function toUint40(uint256 value) internal pure returns (uint40) {
if (value > type(uint40).max) {
revert SafeCastOverflowedUintDowncast(40, value);
}
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
*/
function toUint32(uint256 value) internal pure returns (uint32) {
if (value > type(uint32).max) {
revert SafeCastOverflowedUintDowncast(32, value);
}
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
*/
function toUint24(uint256 value) internal pure returns (uint24) {
if (value > type(uint24).max) {
revert SafeCastOverflowedUintDowncast(24, value);
}
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
*/
function toUint16(uint256 value) internal pure returns (uint16) {
if (value > type(uint16).max) {
revert SafeCastOverflowedUintDowncast(16, value);
}
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
*/
function toUint8(uint256 value) internal pure returns (uint8) {
if (value > type(uint8).max) {
revert SafeCastOverflowedUintDowncast(8, value);
}
return uint8(value);
}
/**
* @dev Converts a signed int256 into an unsigned uint256.
*
* Requirements:
*
* - input must be greater than or equal to 0.
*/
function toUint256(int256 value) internal pure returns (uint256) {
if (value < 0) {
revert SafeCastOverflowedIntToUint(value);
}
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
*/
function toInt248(int256 value) internal pure returns (int248 downcasted) {
downcasted = int248(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(248, value);
}
}
/**
* @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
*/
function toInt240(int256 value) internal pure returns (int240 downcasted) {
downcasted = int240(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(240, value);
}
}
/**
* @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
*/
function toInt232(int256 value) internal pure returns (int232 downcasted) {
downcasted = int232(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(232, value);
}
}
/**
* @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
*/
function toInt224(int256 value) internal pure returns (int224 downcasted) {
downcasted = int224(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(224, value);
}
}
/**
* @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
*/
function toInt216(int256 value) internal pure returns (int216 downcasted) {
downcasted = int216(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(216, value);
}
}
/**
* @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
*/
function toInt208(int256 value) internal pure returns (int208 downcasted) {
downcasted = int208(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(208, value);
}
}
/**
* @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
*/
function toInt200(int256 value) internal pure returns (int200 downcasted) {
downcasted = int200(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(200, value);
}
}
/**
* @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
*/
function toInt192(int256 value) internal pure returns (int192 downcasted) {
downcasted = int192(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(192, value);
}
}
/**
* @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
*/
function toInt184(int256 value) internal pure returns (int184 downcasted) {
downcasted = int184(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(184, value);
}
}
/**
* @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
*/
function toInt176(int256 value) internal pure returns (int176 downcasted) {
downcasted = int176(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(176, value);
}
}
/**
* @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
*/
function toInt168(int256 value) internal pure returns (int168 downcasted) {
downcasted = int168(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(168, value);
}
}
/**
* @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
*/
function toInt160(int256 value) internal pure returns (int160 downcasted) {
downcasted = int160(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(160, value);
}
}
/**
* @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
*/
function toInt152(int256 value) internal pure returns (int152 downcasted) {
downcasted = int152(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(152, value);
}
}
/**
* @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
*/
function toInt144(int256 value) internal pure returns (int144 downcasted) {
downcasted = int144(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(144, value);
}
}
/**
* @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
*/
function toInt136(int256 value) internal pure returns (int136 downcasted) {
downcasted = int136(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(136, value);
}
}
/**
* @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
*/
function toInt128(int256 value) internal pure returns (int128 downcasted) {
downcasted = int128(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(128, value);
}
}
/**
* @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
*/
function toInt120(int256 value) internal pure returns (int120 downcasted) {
downcasted = int120(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(120, value);
}
}
/**
* @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
*/
function toInt112(int256 value) internal pure returns (int112 downcasted) {
downcasted = int112(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(112, value);
}
}
/**
* @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
*/
function toInt104(int256 value) internal pure returns (int104 downcasted) {
downcasted = int104(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(104, value);
}
}
/**
* @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
*/
function toInt96(int256 value) internal pure returns (int96 downcasted) {
downcasted = int96(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(96, value);
}
}
/**
* @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
*/
function toInt88(int256 value) internal pure returns (int88 downcasted) {
downcasted = int88(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(88, value);
}
}
/**
* @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
*/
function toInt80(int256 value) internal pure returns (int80 downcasted) {
downcasted = int80(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(80, value);
}
}
/**
* @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
*/
function toInt72(int256 value) internal pure returns (int72 downcasted) {
downcasted = int72(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(72, value);
}
}
/**
* @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
*/
function toInt64(int256 value) internal pure returns (int64 downcasted) {
downcasted = int64(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(64, value);
}
}
/**
* @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
*/
function toInt56(int256 value) internal pure returns (int56 downcasted) {
downcasted = int56(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(56, value);
}
}
/**
* @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
*/
function toInt48(int256 value) internal pure returns (int48 downcasted) {
downcasted = int48(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(48, value);
}
}
/**
* @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
*/
function toInt40(int256 value) internal pure returns (int40 downcasted) {
downcasted = int40(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(40, value);
}
}
/**
* @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
*/
function toInt32(int256 value) internal pure returns (int32 downcasted) {
downcasted = int32(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(32, value);
}
}
/**
* @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
*/
function toInt24(int256 value) internal pure returns (int24 downcasted) {
downcasted = int24(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(24, value);
}
}
/**
* @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
*/
function toInt16(int256 value) internal pure returns (int16 downcasted) {
downcasted = int16(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(16, value);
}
}
/**
* @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
*/
function toInt8(int256 value) internal pure returns (int8 downcasted) {
downcasted = int8(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(8, value);
}
}
/**
* @dev Converts an unsigned uint256 into a signed int256.
*
* Requirements:
*
* - input must be less than or equal to maxInt256.
*/
function toInt256(uint256 value) internal pure returns (int256) {
// Note: Unsafe cast below is okay because `type(int256).max` is guaranteed to be positive
if (value > uint256(type(int256).max)) {
revert SafeCastOverflowedUintToInt(value);
}
return int256(value);
}
/**
* @dev Cast a boolean (false or true) to a uint256 (0 or 1) with no jump.
*/
function toUint(bool b) internal pure returns (uint256 u) {
assembly ("memory-safe") {
u := iszero(iszero(b))
}
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (proxy/beacon/IBeacon.sol)
pragma solidity ^0.8.20;
/**
* @dev This is the interface that {BeaconProxy} expects of its beacon.
*/
interface IBeacon {
/**
* @dev Must return an address that can be used as a delegate call target.
*
* {UpgradeableBeacon} will check that this address is a contract.
*/
function implementation() external view returns (address);
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (proxy/Proxy.sol)
pragma solidity ^0.8.20;
/**
* @dev This abstract contract provides a fallback function that delegates all calls to another contract using the EVM
* instruction `delegatecall`. We refer to the second contract as the _implementation_ behind the proxy, and it has to
* be specified by overriding the virtual {_implementation} function.
*
* Additionally, delegation to the implementation can be triggered manually through the {_fallback} function, or to a
* different contract through the {_delegate} function.
*
* The success and return data of the delegated call will be returned back to the caller of the proxy.
*/
abstract contract Proxy {
/**
* @dev Delegates the current call to `implementation`.
*
* This function does not return to its internal call site, it will return directly to the external caller.
*/
function _delegate(address implementation) internal virtual {
assembly {
// Copy msg.data. We take full control of memory in this inline assembly
// block because it will not return to Solidity code. We overwrite the
// Solidity scratch pad at memory position 0.
calldatacopy(0, 0, calldatasize())
// Call the implementation.
// out and outsize are 0 because we don't know the size yet.
let result := delegatecall(gas(), implementation, 0, calldatasize(), 0, 0)
// Copy the returned data.
returndatacopy(0, 0, returndatasize())
switch result
// delegatecall returns 0 on error.
case 0 {
revert(0, returndatasize())
}
default {
return(0, returndatasize())
}
}
}
/**
* @dev This is a virtual function that should be overridden so it returns the address to which the fallback
* function and {_fallback} should delegate.
*/
function _implementation() internal view virtual returns (address);
/**
* @dev Delegates the current call to the address returned by `_implementation()`.
*
* This function does not return to its internal call site, it will return directly to the external caller.
*/
function _fallback() internal virtual {
_delegate(_implementation());
}
/**
* @dev Fallback function that delegates calls to the address returned by `_implementation()`. Will run if no other
* function in the contract matches the call data.
*/
fallback() external payable virtual {
_fallback();
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.1.0) (utils/StorageSlot.sol)
// This file was procedurally generated from scripts/generate/templates/StorageSlot.js.
pragma solidity ^0.8.20;
/**
* @dev Library for reading and writing primitive types to specific storage slots.
*
* Storage slots are often used to avoid storage conflict when dealing with upgradeable contracts.
* This library helps with reading and writing to such slots without the need for inline assembly.
*
* The functions in this library return Slot structs that contain a `value` member that can be used to read or write.
*
* Example usage to set ERC-1967 implementation slot:
* ```solidity
* contract ERC1967 {
* // Define the slot. Alternatively, use the SlotDerivation library to derive the slot.
* bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;
*
* function _getImplementation() internal view returns (address) {
* return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value;
* }
*
* function _setImplementation(address newImplementation) internal {
* require(newImplementation.code.length > 0);
* StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation;
* }
* }
* ```
*
* TIP: Consider using this library along with {SlotDerivation}.
*/
library StorageSlot {
struct AddressSlot {
address value;
}
struct BooleanSlot {
bool value;
}
struct Bytes32Slot {
bytes32 value;
}
struct Uint256Slot {
uint256 value;
}
struct Int256Slot {
int256 value;
}
struct StringSlot {
string value;
}
struct BytesSlot {
bytes value;
}
/**
* @dev Returns an `AddressSlot` with member `value` located at `slot`.
*/
function getAddressSlot(bytes32 slot) internal pure returns (AddressSlot storage r) {
assembly ("memory-safe") {
r.slot := slot
}
}
/**
* @dev Returns a `BooleanSlot` with member `value` located at `slot`.
*/
function getBooleanSlot(bytes32 slot) internal pure returns (BooleanSlot storage r) {
assembly ("memory-safe") {
r.slot := slot
}
}
/**
* @dev Returns a `Bytes32Slot` with member `value` located at `slot`.
*/
function getBytes32Slot(bytes32 slot) internal pure returns (Bytes32Slot storage r) {
assembly ("memory-safe") {
r.slot := slot
}
}
/**
* @dev Returns a `Uint256Slot` with member `value` located at `slot`.
*/
function getUint256Slot(bytes32 slot) internal pure returns (Uint256Slot storage r) {
assembly ("memory-safe") {
r.slot := slot
}
}
/**
* @dev Returns a `Int256Slot` with member `value` located at `slot`.
*/
function getInt256Slot(bytes32 slot) internal pure returns (Int256Slot storage r) {
assembly ("memory-safe") {
r.slot := slot
}
}
/**
* @dev Returns a `StringSlot` with member `value` located at `slot`.
*/
function getStringSlot(bytes32 slot) internal pure returns (StringSlot storage r) {
assembly ("memory-safe") {
r.slot := slot
}
}
/**
* @dev Returns an `StringSlot` representation of the string storage pointer `store`.
*/
function getStringSlot(string storage store) internal pure returns (StringSlot storage r) {
assembly ("memory-safe") {
r.slot := store.slot
}
}
/**
* @dev Returns a `BytesSlot` with member `value` located at `slot`.
*/
function getBytesSlot(bytes32 slot) internal pure returns (BytesSlot storage r) {
assembly ("memory-safe") {
r.slot := slot
}
}
/**
* @dev Returns an `BytesSlot` representation of the bytes storage pointer `store`.
*/
function getBytesSlot(bytes storage store) internal pure returns (BytesSlot storage r) {
assembly ("memory-safe") {
r.slot := store.slot
}
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (access/Ownable.sol)
pragma solidity ^0.8.20;
import {Context} from "../utils/Context.sol";
/**
* @dev Contract module which provides a basic access control mechanism, where
* there is an account (an owner) that can be granted exclusive access to
* specific functions.
*
* The initial owner is set to the address provided by the deployer. This can
* later be changed with {transferOwnership}.
*
* This module is used through inheritance. It will make available the modifier
* `onlyOwner`, which can be applied to your functions to restrict their use to
* the owner.
*/
abstract contract Ownable is Context {
address private _owner;
/**
* @dev The caller account is not authorized to perform an operation.
*/
error OwnableUnauthorizedAccount(address account);
/**
* @dev The owner is not a valid owner account. (eg. `address(0)`)
*/
error OwnableInvalidOwner(address owner);
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
/**
* @dev Initializes the contract setting the address provided by the deployer as the initial owner.
*/
constructor(address initialOwner) {
if (initialOwner == address(0)) {
revert OwnableInvalidOwner(address(0));
}
_transferOwnership(initialOwner);
}
/**
* @dev Throws if called by any account other than the owner.
*/
modifier onlyOwner() {
_checkOwner();
_;
}
/**
* @dev Returns the address of the current owner.
*/
function owner() public view virtual returns (address) {
return _owner;
}
/**
* @dev Throws if the sender is not the owner.
*/
function _checkOwner() internal view virtual {
if (owner() != _msgSender()) {
revert OwnableUnauthorizedAccount(_msgSender());
}
}
/**
* @dev Leaves the contract without owner. It will not be possible to call
* `onlyOwner` functions. Can only be called by the current owner.
*
* NOTE: Renouncing ownership will leave the contract without an owner,
* thereby disabling any functionality that is only available to the owner.
*/
function renounceOwnership() public virtual onlyOwner {
_transferOwnership(address(0));
}
/**
* @dev Transfers ownership of the contract to a new account (`newOwner`).
* Can only be called by the current owner.
*/
function transferOwnership(address newOwner) public virtual onlyOwner {
if (newOwner == address(0)) {
revert OwnableInvalidOwner(address(0));
}
_transferOwnership(newOwner);
}
/**
* @dev Transfers ownership of the contract to a new account (`newOwner`).
* Internal function without access restriction.
*/
function _transferOwnership(address newOwner) internal virtual {
address oldOwner = _owner;
_owner = newOwner;
emit OwnershipTransferred(oldOwner, newOwner);
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.1.0) (utils/introspection/IERC165.sol)
pragma solidity ^0.8.20;
/**
* @dev Interface of the ERC-165 standard, as defined in the
* https://eips.ethereum.org/EIPS/eip-165[ERC].
*
* Implementers can declare support of contract interfaces, which can then be
* queried by others ({ERC165Checker}).
*
* For an implementation, see {ERC165}.
*/
interface IERC165 {
/**
* @dev Returns true if this contract implements the interface defined by
* `interfaceId`. See the corresponding
* https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[ERC section]
* to learn more about how these ids are created.
*
* This function call must use less than 30 000 gas.
*/
function supportsInterface(bytes4 interfaceId) external view returns (bool);
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (interfaces/IERC20.sol)
pragma solidity ^0.8.20;
import {IERC20} from "../token/ERC20/IERC20.sol";// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (interfaces/IERC165.sol)
pragma solidity ^0.8.20;
import {IERC165} from "../utils/introspection/IERC165.sol";// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.1.0) (utils/Errors.sol)
pragma solidity ^0.8.20;
/**
* @dev Collection of common custom errors used in multiple contracts
*
* IMPORTANT: Backwards compatibility is not guaranteed in future versions of the library.
* It is recommended to avoid relying on the error API for critical functionality.
*
* _Available since v5.1._
*/
library Errors {
/**
* @dev The ETH balance of the account is not enough to perform the operation.
*/
error InsufficientBalance(uint256 balance, uint256 needed);
/**
* @dev A call to an address target failed. The target may have reverted.
*/
error FailedCall();
/**
* @dev The deployment failed.
*/
error FailedDeployment();
/**
* @dev A necessary precompile is missing.
*/
error MissingPrecompile(address);
}{
"remappings": [
"@layerzerolabs/=node_modules/@layerzerolabs/",
"@layerzerolabs/lz-evm-protocol-v2/=node_modules/@layerzerolabs/lz-evm-protocol-v2/",
"@openzeppelin-contracts-upgradeable/=dependencies/@openzeppelin-contracts-upgradeable-5.1.0/",
"@openzeppelin-contracts/contracts/=dependencies/@openzeppelin-contracts-5.1.0/",
"@openzeppelin/contracts-upgradeable/=dependencies/@openzeppelin-contracts-upgradeable-5.1.0/",
"@openzeppelin/contracts/=dependencies/@openzeppelin-contracts-5.1.0/",
"erc4626-tests/=dependencies/erc4626-property-tests-1.0/",
"forge-std/=dependencies/forge-std-1.9.4/src/",
"permit2/=lib/permit2/",
"@openzeppelin-3.4.2/=node_modules/@openzeppelin-3.4.2/",
"@openzeppelin-contracts-5.1.0/=dependencies/@openzeppelin-contracts-5.1.0/",
"@openzeppelin-contracts-upgradeable-5.1.0/=dependencies/@openzeppelin-contracts-upgradeable-5.1.0/",
"@uniswap/=node_modules/@uniswap/",
"base64-sol/=node_modules/base64-sol/",
"erc4626-property-tests-1.0/=dependencies/erc4626-property-tests-1.0/",
"eth-gas-reporter/=node_modules/eth-gas-reporter/",
"forge-std-1.9.4/=dependencies/forge-std-1.9.4/src/",
"hardhat/=node_modules/hardhat/",
"solidity-bytes-utils/=node_modules/solidity-bytes-utils/",
"solmate/=node_modules/solmate/"
],
"optimizer": {
"enabled": true,
"runs": 200
},
"metadata": {
"useLiteralContent": false,
"bytecodeHash": "ipfs",
"appendCBOR": true
},
"outputSelection": {
"*": {
"*": [
"evm.bytecode",
"evm.deployedBytecode",
"devdoc",
"userdoc",
"metadata",
"abi"
]
}
},
"evmVersion": "paris",
"viaIR": true
}Contract Security Audit
- No Contract Security Audit Submitted- Submit Audit Here
Contract ABI
API[{"inputs":[],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[],"name":"AccessControlBadConfirmation","type":"error"},{"inputs":[{"internalType":"address","name":"account","type":"address"},{"internalType":"bytes32","name":"neededRole","type":"bytes32"}],"name":"AccessControlUnauthorizedAccount","type":"error"},{"inputs":[],"name":"InvalidInitialization","type":"error"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"KICK_FORBIDDEN","type":"error"},{"inputs":[],"name":"LENGTH_MISMATCH","type":"error"},{"inputs":[{"internalType":"bytes","name":"","type":"bytes"}],"name":"MANUAL_EXECUTION_FAILURE","type":"error"},{"inputs":[{"internalType":"address","name":"caller","type":"address"}],"name":"NOT_AUTHORIZED","type":"error"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"NOT_TIMELOCK","type":"error"},{"inputs":[],"name":"NotInitializing","type":"error"},{"inputs":[],"name":"SAME_ADDRESS","type":"error"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint64","name":"version","type":"uint64"}],"name":"Initialized","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"bytes32","name":"previousAdminRole","type":"bytes32"},{"indexed":true,"internalType":"bytes32","name":"newAdminRole","type":"bytes32"}],"name":"RoleAdminChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":true,"internalType":"address","name":"sender","type":"address"}],"name":"RoleGranted","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":true,"internalType":"address","name":"sender","type":"address"}],"name":"RoleRevoked","type":"event"},{"inputs":[],"name":"DEFAULT_ADMIN_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"PROTOCOL_OPERATOR","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"SWAP_FEE_SETTER","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address[]","name":"_pools","type":"address[]"},{"internalType":"address[]","name":"_rewards","type":"address[]"},{"internalType":"bool[]","name":"_addReward","type":"bool[]"}],"name":"augmentGaugeRewardsForPair","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"clGaugeFactory","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"tokenA","type":"address"},{"internalType":"address","name":"tokenB","type":"address"},{"internalType":"int24","name":"tickSpacing","type":"int24"}],"name":"createCLGauge","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_feeRecipient","type":"address"}],"name":"createFeeDistributorWithRecipient","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_pool","type":"address"}],"name":"createLegacyGauge","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"int24","name":"tickSpacing","type":"int24"},{"internalType":"uint24","name":"initialFee","type":"uint24"}],"name":"enableTickSpacing","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_target","type":"address"},{"internalType":"bytes","name":"_payload","type":"bytes"}],"name":"execute","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"feeCollector","outputs":[{"internalType":"contract IFeeCollector","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"feeDistributorFactory","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"feeRecipientFactory","outputs":[{"internalType":"contract IFeeRecipientFactory","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"gaugeFactory","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"}],"name":"getRoleAdmin","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"uint256","name":"index","type":"uint256"}],"name":"getRoleMember","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"}],"name":"getRoleMemberCount","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"}],"name":"getRoleMembers","outputs":[{"internalType":"address[]","name":"","type":"address[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address[]","name":"_token","type":"address[]"},{"internalType":"bool[]","name":"_whitelisted","type":"bool[]"}],"name":"governanceWhitelist","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"grantRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"hasRole","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"components":[{"internalType":"address","name":"timelock","type":"address"},{"internalType":"address","name":"treasury","type":"address"},{"internalType":"address","name":"voter","type":"address"},{"internalType":"address","name":"minter","type":"address"},{"internalType":"address","name":"xRam","type":"address"},{"internalType":"address","name":"r33","type":"address"},{"internalType":"address","name":"ramsesV3PoolFactory","type":"address"},{"internalType":"address","name":"poolFactory","type":"address"},{"internalType":"address","name":"clGaugeFactory","type":"address"},{"internalType":"address","name":"gaugeFactory","type":"address"},{"internalType":"address","name":"feeRecipientFactory","type":"address"},{"internalType":"address","name":"feeDistributorFactory","type":"address"},{"internalType":"address","name":"feeCollector","type":"address"},{"internalType":"address","name":"voteModule","type":"address"}],"internalType":"struct IAccessHub.InitParams","name":"params","type":"tuple"}],"name":"initialize","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"components":[{"internalType":"address","name":"ram","type":"address"},{"internalType":"address","name":"legacyFactory","type":"address"},{"internalType":"address","name":"gauges","type":"address"},{"internalType":"address","name":"feeDistributorFactory","type":"address"},{"internalType":"address","name":"minter","type":"address"},{"internalType":"address","name":"msig","type":"address"},{"internalType":"address","name":"xRam","type":"address"},{"internalType":"address","name":"clFactory","type":"address"},{"internalType":"address","name":"clGaugeFactory","type":"address"},{"internalType":"address","name":"nfpManager","type":"address"},{"internalType":"address","name":"feeRecipientFactory","type":"address"},{"internalType":"address","name":"voteModule","type":"address"}],"internalType":"struct IVoter.InitializationParams","name":"inputs","type":"tuple"}],"name":"initializeVoter","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address[]","name":"_pairs","type":"address[]"}],"name":"killGauge","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_operator","type":"address"}],"name":"migrateOperator","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"minter","outputs":[{"internalType":"contract IMinter","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"operatorRedeemXRam","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"poolFactory","outputs":[{"internalType":"contract IPairFactory","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"r33","outputs":[{"internalType":"contract IREX33","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"ramsesV3PoolFactory","outputs":[{"internalType":"contract IRamsesV3Factory","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"components":[{"internalType":"address","name":"timelock","type":"address"},{"internalType":"address","name":"treasury","type":"address"},{"internalType":"address","name":"voter","type":"address"},{"internalType":"address","name":"minter","type":"address"},{"internalType":"address","name":"xRam","type":"address"},{"internalType":"address","name":"r33","type":"address"},{"internalType":"address","name":"ramsesV3PoolFactory","type":"address"},{"internalType":"address","name":"poolFactory","type":"address"},{"internalType":"address","name":"clGaugeFactory","type":"address"},{"internalType":"address","name":"gaugeFactory","type":"address"},{"internalType":"address","name":"feeRecipientFactory","type":"address"},{"internalType":"address","name":"feeDistributorFactory","type":"address"},{"internalType":"address","name":"feeCollector","type":"address"},{"internalType":"address","name":"voteModule","type":"address"}],"internalType":"struct IAccessHub.InitParams","name":"params","type":"tuple"}],"name":"reinit","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_gauge","type":"address"},{"internalType":"address","name":"_voter","type":"address"},{"internalType":"address","name":"_nfpManager","type":"address"},{"internalType":"address","name":"_feeCollector","type":"address"},{"internalType":"address","name":"_pool","type":"address"}],"name":"reinitializeV3Gauge","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address[]","name":"_pools","type":"address[]"},{"internalType":"address[]","name":"_rewards","type":"address[]"}],"name":"removeFeeDistributorRewards","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"callerConfirmation","type":"address"}],"name":"renounceRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address[]","name":"_tokens","type":"address[]"},{"internalType":"uint256[]","name":"_amounts","type":"uint256[]"}],"name":"rescueTrappedTokens","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_gauge","type":"address"},{"internalType":"uint256","name":"_period","type":"uint256"}],"name":"retrieveStuckEmissionsToGovernance","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address[]","name":"_pairs","type":"address[]"}],"name":"reviveGauge","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"revokeRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address[]","name":"_candidates","type":"address[]"},{"internalType":"bool[]","name":"_exempt","type":"bool[]"}],"name":"setCooldownExemption","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_multiplier","type":"uint256"}],"name":"setEmissionsMultiplierInMinter","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_pct","type":"uint256"}],"name":"setEmissionsRatioInVoter","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_feeCollector","type":"address"}],"name":"setFeeCollectorAccessHub","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_feeCollector","type":"address"}],"name":"setFeeCollectorInClGaugeFactory","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_newFeeCollector","type":"address"}],"name":"setFeeCollectorInFactoryV3","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address[]","name":"_pairs","type":"address[]"},{"internalType":"address[]","name":"_feeRecipients","type":"address[]"}],"name":"setFeeRecipientLegacyBatched","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address[]","name":"_pools","type":"address[]"},{"internalType":"uint24[]","name":"_feeProtocol","type":"uint24[]"}],"name":"setFeeSplitCL","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address[]","name":"_pools","type":"address[]"},{"internalType":"uint256[]","name":"_feeSplits","type":"uint256[]"}],"name":"setFeeSplitLegacy","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bool","name":"status","type":"bool"}],"name":"setFeeSplitWhenNoGauge","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_feeToTreasury","type":"uint256"}],"name":"setFeeToTreasuryInFeeRecipientFactory","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint24","name":"_feeProtocolGlobal","type":"uint24"}],"name":"setGlobalClFeeProtocol","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_fee","type":"uint256"}],"name":"setLegacyFeeGlobal","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_feeSplit","type":"uint256"}],"name":"setLegacyFeeSplitGlobal","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_newGovernor","type":"address"}],"name":"setNewGovernorInVoter","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_newDuration","type":"uint256"}],"name":"setNewRebaseStreamingDuration","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_timelock","type":"address"}],"name":"setNewTimelock","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_newCooldown","type":"uint256"}],"name":"setNewVoteModuleCooldown","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_pair","type":"address"},{"internalType":"bool","name":"_status","type":"bool"}],"name":"setSkimEnabledLegacy","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address[]","name":"_pools","type":"address[]"},{"internalType":"uint24[]","name":"_swapFees","type":"uint24[]"}],"name":"setSwapFees","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_timeThreshold","type":"uint256"}],"name":"setTimeThresholdForRewarder","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_treasuryFees","type":"uint256"}],"name":"setTreasuryFeesInFeeCollector","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newTreasury","type":"address"}],"name":"setTreasuryInFeeCollector","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_treasury","type":"address"}],"name":"setTreasuryInFeeRecipientFactory","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_treasury","type":"address"}],"name":"setTreasuryInLegacyFactory","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_newImplementation","type":"address"}],"name":"setV3FactoryImplementation","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_voter","type":"address"}],"name":"setVoterAddressInFactoryV3","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_voter","type":"address"}],"name":"setVoterInFeeRecipientFactory","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_voter","type":"address"}],"name":"setVoterInLegacyFactory","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes4","name":"interfaceId","type":"bytes4"}],"name":"supportsInterface","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"timelock","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bool","name":"enable","type":"bool"}],"name":"toggleXRamGovernance","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_newOperator","type":"address"}],"name":"transferOperatorInR33","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address[]","name":"_who","type":"address[]"},{"internalType":"bool[]","name":"_whitelisted","type":"bool[]"}],"name":"transferWhitelistInXRam","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"treasury","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_gauge","type":"address"},{"internalType":"address","name":"_newFeeDistributor","type":"address"}],"name":"updateFeeDistributorForGauge","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"voteModule","outputs":[{"internalType":"contract IVoteModule","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"voter","outputs":[{"internalType":"contract IVoter","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"xRam","outputs":[{"internalType":"contract IXRex","name":"","type":"address"}],"stateMutability":"view","type":"function"}]Contract Creation Code
6080806040523460d2577ff0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a005460ff8160401c1660c1576002600160401b03196001600160401b03821601605c575b604051613d1090816100d88239f35b6001600160401b0319166001600160401b039081177ff0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a005581527fc7f505b2f371ae2175ee4913f4499e1f2633a7b5936321eed1cdaeb6115181d290602090a13880604d565b63f92ee8a960e01b60005260046000fd5b600080fdfe6080604052600436101561001257600080fd5b6000803560e01c806204b863146131b957806301ffc9a71461314857806302be9a90146130c8578063075461721461309f578063085210001461304e5780630a2e3e27146130255780630c2e061f14612fba5780630d52333c14612f915780631123363414612f6857806311b285fc14612ee85780631cff79cd14612dcb5780631eadbd8b14612d52578063239a5f2314612ce3578063248a9ca314612cbc5780632a59c80614612c605780632d5012c7146129b95780632eb647951461298c5780632f2ff15d1461295a57806336568abe146129155780633abdbf2a146128b35780633eadd56e146128575780634135afbe146127d75780634219dc40146127ae5780634345f59a1461269b57806346c96aac1461267257806349fe8228146126035780634b866660146125835780634b9880c11461251757806352cce43b1461245457806352e0970f146123e55780635cb62a081461238957806361d027b3146123605780636379808f146122f1578063671fe0351461226d578063687b01351461221157806369e0bc05146120ab5780636d93e35f14611fde57806373449da314611f6b57806378b1a8c714611f425780637bebe38114611f1957806380a1ebbb14611e5357806382169aec14611d1a57806382c6e1a614611caf57806385caf28b14611c8657806389872f3314611be75780638cb422f014611bbe5780638d3aa1c914611b3e5780639010d07c14611aeb5780639029105814611a8657806390bcc5a21461184057806391d14854146117e75780639647d141146117be578063a217fddf146117a2578063a3246ad3146116e5578063a71504ad14611689578063aad929331461162d578063ab0e0192146115be578063ac33ef8514611595578063ad2d343b14611470578063ba01351014611414578063be02ec381461121b578063beb7dc3414611181578063c415b95c14611158578063c9d068fd146110d8578063ca15c873146110a1578063ca1699e814610f48578063d1798fc114610eec578063d1cf58f214610e1e578063d32af6c114610df5578063d33219b414610dce578063d547741f14610d93578063d5b69f8314610b53578063d6e0950914610ad3578063de10f4ae146108ff578063e4bc04c11461086f578063ecd9c12f1461040e5763eee0fdb41461036b57600080fd5b346103f95760403660031901126103f957806004358060020b80910361040b576024359062ffffff8216809203610409576103a4613642565b6009546001600160a01b031691823b156104075760448492836040519586948593633bb83f6d60e21b8552600485015260248401525af180156103fc576103e85750f35b816103f29161338b565b6103f95780f35b80fd5b6040513d84823e3d90fd5b505b505b50fd5b50346103f9576101c03660031901126103f957600080516020613c9b8339815191525460ff8160401c1615906001600160401b03811680159081610867575b600114908161085d575b159081610854575b506108455767ffffffffffffffff198116600117600080516020613c9b8339815191525581610818575b506001600160a01b0361049a613569565b83546001600160a01b03191691161782556001600160a01b036104bb61357f565b166001600160601b0360a01b600154161760015560018060a01b036104de61345b565b166001600160601b0360a01b600554161760055560018060a01b03610501613471565b166001600160601b0360a01b600654161760065560018060a01b03610524613487565b166001600160601b0360a01b600754161760075560018060a01b0361054761349d565b166001600160601b0360a01b600854161760085560018060a01b0361056a6134b3565b166001600160601b0360a01b600954161760095560018060a01b0361058d6134c9565b166001600160601b0360a01b600a541617600a5560018060a01b036105b06134df565b166001600160601b0360a01b600b541617600b5560018060a01b036105d36134f6565b166001600160601b0360a01b600c541617600c5560018060a01b036105f661350d565b166001600160601b0360a01b600d541617600d5560018060a01b03610619613524565b166001600160601b0360a01b600254161760025560018060a01b0361063c61353b565b166001600160601b0360a01b600354161760035560018060a01b0361065f613552565b166001600160601b0360a01b600454161760045561067b61357f565b61068481613778565b6107d7575b5061069261357f565b61069b81613828565b610796575b506106a961357f565b6106b2816138d2565b610763575b506106c0613569565b6106c9816138d2565b610730575b506106d65780f35b68ff000000000000000019600080516020613c9b8339815191525416600080516020613c9b833981519152557fc7f505b2f371ae2175ee4913f4499e1f2633a7b5936321eed1cdaeb6115181d2602060405160018152a180f35b828052600080516020613c3b8339815191526020526040832061075c916001600160a01b031690613abb565b50386106ce565b828052600080516020613c3b8339815191526020526040832061078f916001600160a01b031690613abb565b50386106b7565b600080516020613cbb8339815191528352600080516020613c3b833981519152602052604083206107d0916001600160a01b031690613abb565b50386106a0565b600080516020613c7b8339815191528352600080516020613c3b83398151915260205260408320610811916001600160a01b031690613abb565b5038610689565b68ffffffffffffffffff19166801000000000000000117600080516020613c9b8339815191525538610489565b63f92ee8a960e01b8352600483fd5b9050153861045f565b303b159150610457565b83915061044d565b50346103f95760403660031901126103f9578061088a613289565b6108926132a4565b906108a93360018060a01b036001541633146133c2565b6005546001600160a01b031691823b156104075760405163e4bc04c160e01b81526001600160a01b039283166004820152911660248201529082908290818381604481015b03925af180156103fc576103e85750f35b50346103f9576101c03660031901126103f95760015461092b9033906001600160a01b031681146133c2565b6001600160a01b0361093b61345b565b166001600160601b0360a01b600554161760055560018060a01b0361095e613471565b166001600160601b0360a01b600654161760065560018060a01b03610981613487565b166001600160601b0360a01b600754161760075560018060a01b036109a461349d565b166001600160601b0360a01b600854161760085560018060a01b036109c76134b3565b166001600160601b0360a01b600954161760095560018060a01b036109ea6134c9565b166001600160601b0360a01b600a541617600a5560018060a01b03610a0d6134df565b166001600160601b0360a01b600b541617600b5560018060a01b03610a306134f6565b166001600160601b0360a01b600c541617600c5560018060a01b03610a5361350d565b166001600160601b0360a01b600d541617600d5560018060a01b03610a76613524565b166001600160601b0360a01b600254161760025560018060a01b03610a9961353b565b166001600160601b0360a01b600354161760035560018060a01b03610abc613552565b166001600160601b0360a01b600454161760045580f35b50346103f95760203660031901126103f95780610aee613289565b600154610b079033906001600160a01b031681146133c2565b600a546001600160a01b031690813b1561040957604051634bc2a65760e01b81526001600160a01b0390911660048201529082908290602490829084905af180156103fc576103e85750f35b50346103f9576101803660031901126103f957604051906101808201918083106001600160401b03841117610d7f578192604052610b8f613289565b8152610b996132a4565b9060208101918252610ba96132ba565b9060408101918252610bb96132d0565b60608201908152610bc86132e6565b6080830190815260a4356001600160a01b0381168103610d7b5760a0840190815260c4356001600160a01b0381168103610d775760c0850190815260e4356001600160a01b0381168103610d735760e0860190815261010435906001600160a01b0382168203610d6f57610100870191825261012435926001600160a01b0384168403610d6b57610120880193845261014435946001600160a01b0386168603610d6757610140890195865261016435966001600160a01b0388168803610d63576101608a01978852600154610caa9033906001600160a01b031681146133c2565b6005546001600160a01b031698893b15610d5f57604051634d014f7f60e01b81529a516001600160a01b0390811660048d01529c518d1660248c01529a518c1660448b015299518b1660648a015298518a1660848901529751891660a48801529651881660c48701529551871660e486015294518616610104850152935185166101248401529251841661014483015291519092166101648301528290829081835a9261018493f180156103fc576103e85750f35b8d80fd5b8c80fd5b8b80fd5b8a80fd5b8980fd5b8880fd5b8780fd5b8680fd5b634e487b7160e01b82526041600452602482fd5b50346103f95760403660031901126103f957610dca600435610db36132a4565b90610dc5610dc082613414565b6136a2565b613734565b5080f35b50346103f957806003193601126103f957546040516001600160a01b039091168152602090f35b50346103f957806003193601126103f957600b546040516001600160a01b039091168152602090f35b50346103f95760603660031901126103f957610e38613289565b610e406132a4565b90604435918260020b809303610ee8576064602092610e5d613642565b6005546040516368e7ac7960e11b81526001600160a01b039283166004820152938216602485015260448401959095529193849283918791165af19081156103fc5760209291610ebb575b506040516001600160a01b039091168152f35b610edb9150823d8411610ee1575b610ed3818361338b565b810190613616565b38610ea8565b503d610ec9565b8380fd5b50346103f95760203660031901126103f957610f06613642565b60075481906001600160a01b0316803b1561040b578180916024604051809481936332fef3cf60e01b835260043560048401525af180156103fc576103e85750f35b50346103f95760603660031901126103f9576004356001600160401b03811161109d57610f7990369060040161330b565b906024356001600160401b038111610ee857610f9990369060040161330b565b90506044356001600160401b03811161109957610fba90369060040161330b565b929091610fc5613642565b83818614918261108f575b5050156110805760055490936001600160a01b0390911690855b818110610ff5578680f35b611008611003828489613435565b613595565b6040516302045be960e41b81526001600160a01b03909116600482015290602082602481875afa91821561107557600192611059575b5061105261104d828888613435565b613635565b5001610fea565b6110709060203d8111610ee157610ed3818361338b565b61103e565b6040513d8a823e3d90fd5b63899ef10d60e01b8552600485fd5b1490508338610fd0565b8480fd5b5080fd5b50346103f95760203660031901126103f95760406020916004358152600080516020613c3b83398151915283522054604051908152f35b50346103f95760203660031901126103f957806110f3613289565b60015461110c9033906001600160a01b031681146133c2565b600a546001600160a01b031690813b1561040957604051630787a21360e51b81526001600160a01b0390911660048201529082908290602490829084905af180156103fc576103e85750f35b50346103f957806003193601126103f957600c546040516001600160a01b039091168152602090f35b50346103f957806111913661333b565b90919261119c613642565b6007546001600160a01b031690813b15611217576111d39060405195632fadf70d60e21b87526040600488015260448701916135d1565b848103600319016024860152828152916001600160fb1b038111611217578560208682968196829560051b809285830137010301925af180156103fc576103e85750f35b8580fd5b50346103f95760203660031901126103f957806004356001600160401b03811161040b5761124d90369060040161330b565b9190611257613642565b815b838110611264578280f35b611272611003828685613435565b600c546001600160a01b031690813b1561109957604051632a54db0160e01b81526001600160a01b03909116600482018190529185908290602490829084905af19081156113cb5785916113ff575b50506005546040516302045be960e41b8152600481018390526001600160a01b0390911690602081602481855afa9081156113f45786916113d6575b50813b156112175760405163992a793360e01b81526001600160a01b0390911660048201529085908290602490829084905af19081156113cb5785916113b6575b50506009546001600160a01b031690813b15611099578491604483926040519485938492637ab4974d60e01b84526004840152600560248401525af19081156113ab578491611392575b5050600101611259565b8161139c9161338b565b6113a7578238611388565b8280fd5b6040513d86823e3d90fd5b816113c09161338b565b610ee857833861133e565b6040513d87823e3d90fd5b6113ee915060203d8111610ee157610ed3818361338b565b386112fd565b6040513d88823e3d90fd5b816114099161338b565b610ee85783386112c1565b50346103f95760203660031901126103f95761142e613642565b60055481906001600160a01b0316803b1561040b5781809160246040518094819363078a3b1960e11b835260043560048401525af180156103fc576103e85750f35b50346103f95761147f3661333b565b929091600080516020613c7b8339815191528552600080516020613c5b8339815191526020526040852060018060a01b03331660005260205260ff604060002054168015611581575b6114d39033906133c2565b83810361108057908491825b8181106114ea578380f35b6009546001600160a01b0316611504611003838587613435565b611517611512848a8a613435565b6135c1565b823b15610d7b57604051637ab4974d60e01b81526001600160a01b0392909216600483015262ffffff1660248201529085908290604490829084905af19081156113cb57859161156c575b50506001016114df565b816115769161338b565b610ee8578338611562565b506005546001600160a01b031633146114c8565b50346103f957806003193601126103f9576009546040516001600160a01b039091168152602090f35b50346103f95760203660031901126103f957806115d9613289565b6115e1613642565b600b546001600160a01b031690813b1561040957604051630787a21360e51b81526001600160a01b0390911660048201529082908290602490829084905af180156103fc576103e85750f35b50346103f95760203660031901126103f957611647613642565b60055481906001600160a01b0316803b1561040b5781809160246040518094819363aad9293360e01b835260043560048401525af180156103fc576103e85750f35b50346103f95760203660031901126103f9576116a3613642565b600b5481906001600160a01b0316803b1561040b5781809160246040518094819363019494b360e01b835260043560048401525af180156103fc576103e85750f35b50346103f95760203660031901126103f9576004358152600080516020613c3b83398151915260205260408120604051908160208254918281520190819285526020852090855b81811061178c575050508261174291038361338b565b604051928392602084019060208552518091526040840192915b81811061176a575050500390f35b82516001600160a01b031684528594506020938401939092019160010161175c565b825484526020909301926001928301920161172c565b50346103f957806003193601126103f957602090604051908152f35b50346103f957806003193601126103f9576004546040516001600160a01b039091168152602090f35b50346103f95760403660031901126103f95760406118036132a4565b916004358152600080516020613c5b833981519152602052209060018060a01b0316600052602052602060ff604060002054166040519015158152f35b50346103f95760203660031901126103f9576004356001600160401b03811161109d5761187190369060040161330b565b9061187a613642565b825b828110611887578380f35b83611896611003838686613435565b600c546001600160a01b0316803b156113a757604051632a54db0160e01b815283816024818360018060a01b038816968760048401525af19081156113ab578491611a71575b50506005546040516302045be960e41b815260048101929092526001600160a01b031690602081602481855afa9081156113ab578491611a53575b50813b15610ee857604051639f06247b60e01b81526001600160a01b0390911660048201529083908290602490829084905af1908115611a48578391611a33575b505060095460405163149fad2f60e21b81526001600160a01b039091169190602081600481865afa9081156113ab5784916119f6575b50823b15610ee857604051637ab4974d60e01b81526001600160a01b0392909216600483015262ffffff1660248201529082908290604490829084905af180156103fc576119e1575b505060010161187c565b816119eb9161338b565b610ee85783386119d7565b90506020813d8211611a2b575b81611a106020938361338b565b81010312610ee8575162ffffff81168103610ee8573861198e565b3d9150611a03565b81611a3d9161338b565b61109d578138611958565b6040513d85823e3d90fd5b611a6b915060203d8111610ee157610ed3818361338b565b38611917565b81611a7b9161338b565b6113a75782386118dc565b50346103f95760203660031901126103f95780611aa16132fc565b611aa9613642565b600a546001600160a01b031690813b15610409578291602483926040519485938492631205220b60e31b8452151560048401525af180156103fc576103e85750f35b50346103f95760403660031901126103f957611b256020916004358152600080516020613c3b833981519152835260406024359120613aa3565b905460405160039290921b1c6001600160a01b03168152f35b50346103f95760203660031901126103f95780611b59613289565b600154611b729033906001600160a01b031681146133c2565b600b546001600160a01b031690813b1561040957604051634bc2a65760e01b81526001600160a01b0390911660048201529082908290602490829084905af180156103fc576103e85750f35b50346103f957806003193601126103f9576020604051600080516020613c7b8339815191528152f35b50346103f95760203660031901126103f957611c016132fc565b611c09613642565b15611c4a5760075481906001600160a01b0316803b1561040b57818091600460405180948193631fa5d41d60e11b83525af180156103fc576103e857505080f35b60075481906001600160a01b0316803b1561040b57818091600460405180948193638456cb5960e01b83525af180156103fc576103e857505080f35b50346103f957806003193601126103f957600d546040516001600160a01b039091168152602090f35b50346103f95760203660031901126103f9578060043562ffffff811680910361040b57611cda613642565b6009546001600160a01b031690813b156104095782916024839260405194859384926307fe355160e41b845260048401525af180156103fc576103e85750f35b50346103f957611d293661333b565b909291611d34613642565b8181036110805790849291835b818110611d4c578480f35b611d5a61104d828589613435565b15611dda576005546001600160a01b0316611d79611003838588613435565b813b15610d7b57604051634d8c928d60e11b81526001600160a01b0390911660048201529086908290602490829084905af19081156113f4578691611dc5575b50506001905b01611d41565b81611dcf9161338b565b611099578438611db9565b6005546001600160a01b0316611df4611003838588613435565b813b15610d7b57604051639c7f331560e01b81526001600160a01b0390911660048201529086908290602490829084905af19081156113f4578691611e3e575b5050600190611dbf565b81611e489161338b565b611099578438611e34565b50346103f95780611e633661333b565b9391611e7d9391933360018060a01b0385541633146133eb565b825b818110611e8a578380f35b600d546001600160a01b0316611ea4611003838587613435565b611eb261104d848a8a613435565b823b15610d7b5760405163638b9ba560e11b81526001600160a01b03929092166004830152151560248201529085908290604490829084905af19081156113cb578591611f04575b5050600101611e7f565b81611f0e9161338b565b610ee8578338611efa565b50346103f957806003193601126103f9576002546040516001600160a01b039091168152602090f35b50346103f957806003193601126103f9576020604051600080516020613cbb8339815191528152f35b50346103f95760203660031901126103f957806020611f88613289565b611f90613642565b6005546040516352fa180f60e11b81526001600160a01b039283166004820152938492602492849291165af19081156103fc5760209291610ebb57506040516001600160a01b039091168152f35b50346103f957611fed3661333b565b9290916120063360018060a01b036001541633146133c2565b83810361108057908491825b81811061201d578380f35b600a546001600160a01b0316612037611003838587613435565b612045611003848a8a613435565b823b15610d7b5760405163270401cb60e01b81526001600160a01b039283166004820152911660248201529085908290604490829084905af19081156113cb578591612096575b5050600101612012565b816120a09161338b565b610ee857833861208c565b50346103f9576120ba3661333b565b6120c693919293613642565b80840361108057908491825b8581106120dd578380f35b6005546001600160a01b03166120f7611003838987613435565b6040516302045be960e41b81526001600160a01b039091166004820152602081602481855afa9081156113f45786916121f3575b50604051630f55858b60e41b81526001600160a01b039091166004820152602081602481855afa9081156113f45786916121d5575b5061216f61100384868a613435565b823b15610d7b5760405163234823d760e01b81526001600160a01b039283166004820152911660248201529085908290604490829084905af19081156113cb5785916121c0575b50506001016120d2565b816121ca9161338b565b610ee85783386121b6565b6121ed915060203d8111610ee157610ed3818361338b565b38612160565b61220b915060203d8111610ee157610ed3818361338b565b3861212b565b50346103f95760203660031901126103f95761222b613642565b600a5481906001600160a01b0316803b1561040b578180916024604051809481936369fe0e2d60e01b835260043560048401525af180156103fc576103e85750f35b50346103f95760203660031901126103f95780602061228a613289565b6001546122a39033906001600160a01b031681146133c2565b60055460405163671fe03560e01b81526001600160a01b039283166004820152938492602492849291165af19081156103fc5760209291610ebb57506040516001600160a01b039091168152f35b50346103f95760203660031901126103f9578061230c613289565b612314613642565b6007546001600160a01b031690813b1561040957604051636379808f60e01b81526001600160a01b0390911660048201529082908290602490829084905af180156103fc576103e85750f35b50346103f957806003193601126103f9576001546040516001600160a01b039091168152602090f35b50346103f95760203660031901126103f9576123a3613642565b600a5481906001600160a01b0316803b1561040b578180916024604051809481936366cb150360e11b835260043560048401525af180156103fc576103e85750f35b50346103f95760203660031901126103f95780612400613289565b612408613642565b600c546001600160a01b031690813b1561040957604051630787a21360e51b81526001600160a01b0390911660048201529082908290602490829084905af180156103fc576103e85750f35b50346103f9576124633661333b565b61246e949394613642565b808303612508576007546001600160a01b031694853b15611099576124ae602091604051956394126bb160e01b87526040600488015260448701916135d1565b84810360031901602486015282815201919084905b8082106124e657505050818394818581819503925af180156103fc576103e85750f35b9091928335801515809103610d7b5781526020908101930191600101906124c3565b63899ef10d60e01b8452600484fd5b50346103f95760203660031901126103f95780546125419033906001600160a01b031681146133eb565b600d5481906001600160a01b0316803b1561040b57818091602460405180948193637c78e0f560e11b835260043560048401525af180156103fc576103e85750f35b50346103f95760203660031901126103f9578061259e613289565b6001546125b79033906001600160a01b031681146133c2565b6002546001600160a01b031690813b1561040957604051636bc26a1360e11b81526001600160a01b0390911660048201529082908290602490829084905af180156103fc576103e85750f35b50346103f95760203660031901126103f9578061261e613289565b612626613642565b6005546001600160a01b031690813b156104095760405163c42cf53560e01b81526001600160a01b0390911660048201529082908290602490829084905af180156103fc576103e85750f35b50346103f957806003193601126103f9576005546040516001600160a01b039091168152602090f35b50346103f9576126aa3661333b565b600080516020613c7b8339815191528552600080516020613c5b8339815191526020908152604080872033600090815292529020549293919260ff16801561279a575b6126f89033906133c2565b80840361108057908491825b85811061270f578380f35b600a546001600160a01b0316612729611003838987613435565b612734838589613435565b35823b15610d7b5760405163203e180f60e11b81526001600160a01b0392909216600483015260248201529085908290604490829084905af19081156113cb578591612785575b5050600101612704565b8161278f9161338b565b610ee857833861277b565b506005546001600160a01b031633146126ed565b50346103f957806003193601126103f957600a546040516001600160a01b039091168152602090f35b50346103f95760203660031901126103f957806127f2613289565b60015461280b9033906001600160a01b031681146133c2565b6009546001600160a01b031690813b15610409576040516301485b9d60e71b81526001600160a01b0390911660048201529082908290602490829084905af180156103fc576103e85750f35b50346103f95760203660031901126103f957612871613642565b60065481906001600160a01b0316803b1561040b5781809160246040518094819363d47ffef160e01b835260043560048401525af180156103fc576103e85750f35b50346103f95760203660031901126103f9576128cd613289565b81546001600160a01b038116916128e6338085146133eb565b6001600160a01b0316918214612906576001600160a01b03191617815580f35b63cb10513560e01b8352600483fd5b50346103f95760403660031901126103f95761292f6132a4565b336001600160a01b0382160361294b57610dca90600435613734565b63334bd91960e11b8252600482fd5b50346103f95760403660031901126103f957610dca60043561297a6132a4565b90612987610dc082613414565b6136ec565b50346103f95760203660031901126103f95780546129b69033906001600160a01b031681146133eb565b80f35b50346103f9576129c83661333b565b929091600080516020613c7b8339815191528552600080516020613c5b8339815191526020526040852060018060a01b03331660005260205260ff6040600020541615612c3b5783810361108057908491825b818110612a26578380f35b6009546001600160a01b03166020612a42611003848688613435565b6040516342378e9560e01b81526001600160a01b03909116600482015291829060249082905afa9081156113cb578591612c1d575b5015612b11576009546001600160a01b0316612a97611003838587613435565b612aa5611512848a8a613435565b823b15610d7b5760405163ba364c3d60e01b81526001600160a01b0392909216600483015262ffffff1660248201529085908290604490829084905af19081156113cb578591612afc575b50506001905b01612a1b565b81612b069161338b565b610ee8578338612af0565b600a546001600160a01b0316612b2b611003838587613435565b60405163e5e31b1360e01b81526001600160a01b039091166004820152602081602481855afa9081156113f4578691612bef575b50612b6e575b50600190612af6565b612b7c611003838587613435565b612b8a611512848a8a613435565b823b15610d7b5760405163a93a897d60e01b81526001600160a01b03909216600483015262ffffff1660248201529085908290604490829084905af19081156113cb578591612bda575b50612b65565b81612be49161338b565b610ee8578338612bd4565b612c10915060203d8111612c16575b612c08818361338b565b8101906135a9565b38612b5f565b503d612bfe565b612c35915060203d8111612c1657612c08818361338b565b38612a77565b63e2517d3f60e01b855233600452600080516020613c7b833981519152602452604485fd5b50346103f95760203660031901126103f957612c7a613642565b600c5481906001600160a01b0316803b1561040b57818091602460405180948193633638348360e21b835260043560048401525af180156103fc576103e85750f35b50346103f95760203660031901126103f9576020612cdb600435613414565b604051908152f35b50346103f95760203660031901126103f95780612cfe613289565b612d06613642565b6008546001600160a01b031690813b15610409576040516329605e7760e01b81526001600160a01b0390911660048201529082908290602490829084905af180156103fc576103e85750f35b50346103f95760403660031901126103f95780612d6d613289565b60243590811515820361040957612d82613642565b600a546001600160a01b031691823b156104075760405163e0bd111d60e01b81526001600160a01b039092166004830152151560248201529082908290818381604481016108ee565b50346103f95760403660031901126103f957612de5613289565b6024356001600160401b0381116113a757366023820112156113a757828160040135926001600160401b03841161109d576024830192602485369201011161109d578154829190612e429033906001600160a01b031681146133eb565b60405185858237828187810182815203925af13d15612ee3573d6001600160401b038111612ecf5760405190612e82601f8201601f19166020018361338b565b81528460203d92013e5b15612e95578280f35b8160449293604051948593634715803360e01b85526020600486015281602486015285850137828201840152601f01601f19168101030190fd5b634e487b7160e01b85526041600452602485fd5b612e8c565b50346103f95760203660031901126103f95780612f03613289565b600154612f1c9033906001600160a01b031681146133c2565b6002546001600160a01b031690813b15610409576040516301485b9d60e71b81526001600160a01b0390911660048201529082908290602490829084905af180156103fc576103e85750f35b50346103f957806003193601126103f9576007546040516001600160a01b039091168152602090f35b50346103f957806003193601126103f9576003546040516001600160a01b039091168152602090f35b50346103f95760403660031901126103f95780612fd5613289565b612fdd613642565b6005546001600160a01b0316803b1561040957604051635824780d60e01b81526001600160a01b039092166004830152602480359083015282908290818381604481016108ee565b50346103f957806003193601126103f9576008546040516001600160a01b039091168152602090f35b50346103f95760203660031901126103f957613068613289565b6001546130819033906001600160a01b031681146133c2565b60018060a01b03166001600160601b0360a01b600c541617600c5580f35b50346103f957806003193601126103f9576006546040516001600160a01b039091168152602090f35b50346103f95760203660031901126103f957806130e3613289565b6001546130fc9033906001600160a01b031681146133c2565b6009546001600160a01b031690813b1561040957604051634bc2a65760e01b81526001600160a01b0390911660048201529082908290602490829084905af180156103fc576103e85750f35b50346103f95760203660031901126103f95760043563ffffffff60e01b811680910361109d57602090635a05180f60e01b811490811561318e575b506040519015158152f35b637965db0b60e01b8114915081156131a8575b5082613183565b6301ffc9a760e01b149050826131a1565b50346103f95760a03660031901126103f9576131d3613289565b816131dc6132a4565b916131e56132ba565b6131ed6132d0565b936131f66132e6565b9261320d3360018060a01b036001541633146133c2565b6001600160a01b031690813b156110995760405163f27ebced60e01b81526001600160a01b0391821660048201529281166024840152948516604483015291909316606484015281908390608490829084905af1801561327c5761326e5780f35b6132779161338b565b388180f35b50604051903d90823e3d90fd5b600435906001600160a01b038216820361329f57565b600080fd5b602435906001600160a01b038216820361329f57565b604435906001600160a01b038216820361329f57565b606435906001600160a01b038216820361329f57565b608435906001600160a01b038216820361329f57565b60043590811515820361329f57565b9181601f8401121561329f578235916001600160401b03831161329f576020808501948460051b01011161329f57565b604060031982011261329f576004356001600160401b03811161329f57816133659160040161330b565b92909291602435906001600160401b03821161329f576133879160040161330b565b9091565b90601f801991011681019081106001600160401b038211176133ac57604052565b634e487b7160e01b600052604160045260246000fd5b156133ca5750565b632bc10c3360e01b60009081526001600160a01b0391909116600452602490fd5b156133f35750565b636241d8a560e11b60009081526001600160a01b0391909116600452602490fd5b600052600080516020613c5b83398151915260205260016040600020015490565b91908110156134455760051b0190565b634e487b7160e01b600052603260045260246000fd5b6044356001600160a01b038116810361329f5790565b6064356001600160a01b038116810361329f5790565b6084356001600160a01b038116810361329f5790565b60a4356001600160a01b038116810361329f5790565b60c4356001600160a01b038116810361329f5790565b60e4356001600160a01b038116810361329f5790565b610144356001600160a01b038116810361329f5790565b610184356001600160a01b038116810361329f5790565b6101a4356001600160a01b038116810361329f5790565b610104356001600160a01b038116810361329f5790565b610124356001600160a01b038116810361329f5790565b610164356001600160a01b038116810361329f5790565b6004356001600160a01b038116810361329f5790565b6024356001600160a01b038116810361329f5790565b356001600160a01b038116810361329f5790565b9081602091031261329f5751801515810361329f5790565b3562ffffff8116810361329f5790565b916020908281520191906000905b8082106135ec5750505090565b90919283359060018060a01b03821680920361329f576020816001938293520194019201906135df565b9081602091031261329f57516001600160a01b038116810361329f5790565b35801515810361329f5790565b3360009081527f3b05fb06f7501e09d6a8a50c59dac59cd7c8dab47e848ae345bfca5e4d5d9e3c602052604090205460ff161561367b57565b63e2517d3f60e01b60005233600452600080516020613cbb83398151915260245260446000fd5b6000818152600080516020613c5b8339815191526020908152604080832033845290915290205460ff16156136d45750565b63e2517d3f60e01b6000523360045260245260446000fd5b6136f6828261396c565b918261370157505090565b6000918252600080516020613c3b8339815191526020526040909120613730916001600160a01b031690613abb565b5090565b61373e8282613a03565b918261374957505090565b6000918252600080516020613c3b8339815191526020526040909120613730916001600160a01b031690613b31565b6001600160a01b03811660009081527f9eacbbea19e14d84ae6fc89bafe3fe4134e0cfcdae6894d6d7239131d0cd8325602052604090205460ff16613822576001600160a01b031660008181527f9eacbbea19e14d84ae6fc89bafe3fe4134e0cfcdae6894d6d7239131d0cd832560205260408120805460ff19166001179055339190600080516020613c7b83398151915290600080516020613c1b8339815191529080a4600190565b50600090565b6001600160a01b03811660009081527f3b05fb06f7501e09d6a8a50c59dac59cd7c8dab47e848ae345bfca5e4d5d9e3c602052604090205460ff16613822576001600160a01b031660008181527f3b05fb06f7501e09d6a8a50c59dac59cd7c8dab47e848ae345bfca5e4d5d9e3c60205260408120805460ff19166001179055339190600080516020613cbb83398151915290600080516020613c1b8339815191529080a4600190565b6001600160a01b03811660009081527fb7db2dd08fcb62d0c9e08c51941cae53c267786a0b75803fb7960902fc8ef97d602052604090205460ff16613822576001600160a01b031660008181527fb7db2dd08fcb62d0c9e08c51941cae53c267786a0b75803fb7960902fc8ef97d60205260408120805460ff19166001179055339190600080516020613c1b8339815191528180a4600190565b6000818152600080516020613c5b833981519152602090815260408083206001600160a01b038616845290915290205460ff166139fc576000818152600080516020613c5b833981519152602090815260408083206001600160a01b0395909516808452949091528120805460ff1916600117905533929190600080516020613c1b8339815191529080a4600190565b5050600090565b6000818152600080516020613c5b833981519152602090815260408083206001600160a01b038616845290915290205460ff16156139fc576000818152600080516020613c5b833981519152602090815260408083206001600160a01b0395909516808452949091528120805460ff19169055339291907ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b9080a4600190565b80548210156134455760005260206000200190600090565b6001810190826000528160205260406000205415600014613b29578054680100000000000000008110156133ac57613b14613afd826001879401855584613aa3565b819391549060031b91821b91600019901b19161790565b90555491600052602052604060002055600190565b505050600090565b9060018201918160005282602052604060002054801515600014613c11576000198101818111613bfb578254600019810191908211613bfb57818103613bc4575b50505080548015613bae576000190190613b8c8282613aa3565b8154906000199060031b1b191690555560005260205260006040812055600190565b634e487b7160e01b600052603160045260246000fd5b613be4613bd4613afd9386613aa3565b90549060031b1c92839286613aa3565b905560005283602052604060002055388080613b72565b634e487b7160e01b600052601160045260246000fd5b5050505060009056fe2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0dc1f6fe24621ce81ec5827caf0253cadb74709b061630e6b55e8237170593200002dd7bc7dec4dceedda775e58dd541e08a116c6c53815c0bd028192f7b6268000cee480c05aeabaa18fb824cd297ccabddb1b1a9a83b28d3f07e85c0cd25c459f0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a00b3072e349cf62590698516830b9ea81d68c974027ccbf3c77e3d2a88743208e5a2646970667358221220036c8e8383f3cf768c50ca1d9990f7a5018795892c3b4f5b664ea835795c9a4d64736f6c634300081c0033
Deployed Bytecode
0x6080604052600436101561001257600080fd5b6000803560e01c806204b863146131b957806301ffc9a71461314857806302be9a90146130c8578063075461721461309f578063085210001461304e5780630a2e3e27146130255780630c2e061f14612fba5780630d52333c14612f915780631123363414612f6857806311b285fc14612ee85780631cff79cd14612dcb5780631eadbd8b14612d52578063239a5f2314612ce3578063248a9ca314612cbc5780632a59c80614612c605780632d5012c7146129b95780632eb647951461298c5780632f2ff15d1461295a57806336568abe146129155780633abdbf2a146128b35780633eadd56e146128575780634135afbe146127d75780634219dc40146127ae5780634345f59a1461269b57806346c96aac1461267257806349fe8228146126035780634b866660146125835780634b9880c11461251757806352cce43b1461245457806352e0970f146123e55780635cb62a081461238957806361d027b3146123605780636379808f146122f1578063671fe0351461226d578063687b01351461221157806369e0bc05146120ab5780636d93e35f14611fde57806373449da314611f6b57806378b1a8c714611f425780637bebe38114611f1957806380a1ebbb14611e5357806382169aec14611d1a57806382c6e1a614611caf57806385caf28b14611c8657806389872f3314611be75780638cb422f014611bbe5780638d3aa1c914611b3e5780639010d07c14611aeb5780639029105814611a8657806390bcc5a21461184057806391d14854146117e75780639647d141146117be578063a217fddf146117a2578063a3246ad3146116e5578063a71504ad14611689578063aad929331461162d578063ab0e0192146115be578063ac33ef8514611595578063ad2d343b14611470578063ba01351014611414578063be02ec381461121b578063beb7dc3414611181578063c415b95c14611158578063c9d068fd146110d8578063ca15c873146110a1578063ca1699e814610f48578063d1798fc114610eec578063d1cf58f214610e1e578063d32af6c114610df5578063d33219b414610dce578063d547741f14610d93578063d5b69f8314610b53578063d6e0950914610ad3578063de10f4ae146108ff578063e4bc04c11461086f578063ecd9c12f1461040e5763eee0fdb41461036b57600080fd5b346103f95760403660031901126103f957806004358060020b80910361040b576024359062ffffff8216809203610409576103a4613642565b6009546001600160a01b031691823b156104075760448492836040519586948593633bb83f6d60e21b8552600485015260248401525af180156103fc576103e85750f35b816103f29161338b565b6103f95780f35b80fd5b6040513d84823e3d90fd5b505b505b50fd5b50346103f9576101c03660031901126103f957600080516020613c9b8339815191525460ff8160401c1615906001600160401b03811680159081610867575b600114908161085d575b159081610854575b506108455767ffffffffffffffff198116600117600080516020613c9b8339815191525581610818575b506001600160a01b0361049a613569565b83546001600160a01b03191691161782556001600160a01b036104bb61357f565b166001600160601b0360a01b600154161760015560018060a01b036104de61345b565b166001600160601b0360a01b600554161760055560018060a01b03610501613471565b166001600160601b0360a01b600654161760065560018060a01b03610524613487565b166001600160601b0360a01b600754161760075560018060a01b0361054761349d565b166001600160601b0360a01b600854161760085560018060a01b0361056a6134b3565b166001600160601b0360a01b600954161760095560018060a01b0361058d6134c9565b166001600160601b0360a01b600a541617600a5560018060a01b036105b06134df565b166001600160601b0360a01b600b541617600b5560018060a01b036105d36134f6565b166001600160601b0360a01b600c541617600c5560018060a01b036105f661350d565b166001600160601b0360a01b600d541617600d5560018060a01b03610619613524565b166001600160601b0360a01b600254161760025560018060a01b0361063c61353b565b166001600160601b0360a01b600354161760035560018060a01b0361065f613552565b166001600160601b0360a01b600454161760045561067b61357f565b61068481613778565b6107d7575b5061069261357f565b61069b81613828565b610796575b506106a961357f565b6106b2816138d2565b610763575b506106c0613569565b6106c9816138d2565b610730575b506106d65780f35b68ff000000000000000019600080516020613c9b8339815191525416600080516020613c9b833981519152557fc7f505b2f371ae2175ee4913f4499e1f2633a7b5936321eed1cdaeb6115181d2602060405160018152a180f35b828052600080516020613c3b8339815191526020526040832061075c916001600160a01b031690613abb565b50386106ce565b828052600080516020613c3b8339815191526020526040832061078f916001600160a01b031690613abb565b50386106b7565b600080516020613cbb8339815191528352600080516020613c3b833981519152602052604083206107d0916001600160a01b031690613abb565b50386106a0565b600080516020613c7b8339815191528352600080516020613c3b83398151915260205260408320610811916001600160a01b031690613abb565b5038610689565b68ffffffffffffffffff19166801000000000000000117600080516020613c9b8339815191525538610489565b63f92ee8a960e01b8352600483fd5b9050153861045f565b303b159150610457565b83915061044d565b50346103f95760403660031901126103f9578061088a613289565b6108926132a4565b906108a93360018060a01b036001541633146133c2565b6005546001600160a01b031691823b156104075760405163e4bc04c160e01b81526001600160a01b039283166004820152911660248201529082908290818381604481015b03925af180156103fc576103e85750f35b50346103f9576101c03660031901126103f95760015461092b9033906001600160a01b031681146133c2565b6001600160a01b0361093b61345b565b166001600160601b0360a01b600554161760055560018060a01b0361095e613471565b166001600160601b0360a01b600654161760065560018060a01b03610981613487565b166001600160601b0360a01b600754161760075560018060a01b036109a461349d565b166001600160601b0360a01b600854161760085560018060a01b036109c76134b3565b166001600160601b0360a01b600954161760095560018060a01b036109ea6134c9565b166001600160601b0360a01b600a541617600a5560018060a01b03610a0d6134df565b166001600160601b0360a01b600b541617600b5560018060a01b03610a306134f6565b166001600160601b0360a01b600c541617600c5560018060a01b03610a5361350d565b166001600160601b0360a01b600d541617600d5560018060a01b03610a76613524565b166001600160601b0360a01b600254161760025560018060a01b03610a9961353b565b166001600160601b0360a01b600354161760035560018060a01b03610abc613552565b166001600160601b0360a01b600454161760045580f35b50346103f95760203660031901126103f95780610aee613289565b600154610b079033906001600160a01b031681146133c2565b600a546001600160a01b031690813b1561040957604051634bc2a65760e01b81526001600160a01b0390911660048201529082908290602490829084905af180156103fc576103e85750f35b50346103f9576101803660031901126103f957604051906101808201918083106001600160401b03841117610d7f578192604052610b8f613289565b8152610b996132a4565b9060208101918252610ba96132ba565b9060408101918252610bb96132d0565b60608201908152610bc86132e6565b6080830190815260a4356001600160a01b0381168103610d7b5760a0840190815260c4356001600160a01b0381168103610d775760c0850190815260e4356001600160a01b0381168103610d735760e0860190815261010435906001600160a01b0382168203610d6f57610100870191825261012435926001600160a01b0384168403610d6b57610120880193845261014435946001600160a01b0386168603610d6757610140890195865261016435966001600160a01b0388168803610d63576101608a01978852600154610caa9033906001600160a01b031681146133c2565b6005546001600160a01b031698893b15610d5f57604051634d014f7f60e01b81529a516001600160a01b0390811660048d01529c518d1660248c01529a518c1660448b015299518b1660648a015298518a1660848901529751891660a48801529651881660c48701529551871660e486015294518616610104850152935185166101248401529251841661014483015291519092166101648301528290829081835a9261018493f180156103fc576103e85750f35b8d80fd5b8c80fd5b8b80fd5b8a80fd5b8980fd5b8880fd5b8780fd5b8680fd5b634e487b7160e01b82526041600452602482fd5b50346103f95760403660031901126103f957610dca600435610db36132a4565b90610dc5610dc082613414565b6136a2565b613734565b5080f35b50346103f957806003193601126103f957546040516001600160a01b039091168152602090f35b50346103f957806003193601126103f957600b546040516001600160a01b039091168152602090f35b50346103f95760603660031901126103f957610e38613289565b610e406132a4565b90604435918260020b809303610ee8576064602092610e5d613642565b6005546040516368e7ac7960e11b81526001600160a01b039283166004820152938216602485015260448401959095529193849283918791165af19081156103fc5760209291610ebb575b506040516001600160a01b039091168152f35b610edb9150823d8411610ee1575b610ed3818361338b565b810190613616565b38610ea8565b503d610ec9565b8380fd5b50346103f95760203660031901126103f957610f06613642565b60075481906001600160a01b0316803b1561040b578180916024604051809481936332fef3cf60e01b835260043560048401525af180156103fc576103e85750f35b50346103f95760603660031901126103f9576004356001600160401b03811161109d57610f7990369060040161330b565b906024356001600160401b038111610ee857610f9990369060040161330b565b90506044356001600160401b03811161109957610fba90369060040161330b565b929091610fc5613642565b83818614918261108f575b5050156110805760055490936001600160a01b0390911690855b818110610ff5578680f35b611008611003828489613435565b613595565b6040516302045be960e41b81526001600160a01b03909116600482015290602082602481875afa91821561107557600192611059575b5061105261104d828888613435565b613635565b5001610fea565b6110709060203d8111610ee157610ed3818361338b565b61103e565b6040513d8a823e3d90fd5b63899ef10d60e01b8552600485fd5b1490508338610fd0565b8480fd5b5080fd5b50346103f95760203660031901126103f95760406020916004358152600080516020613c3b83398151915283522054604051908152f35b50346103f95760203660031901126103f957806110f3613289565b60015461110c9033906001600160a01b031681146133c2565b600a546001600160a01b031690813b1561040957604051630787a21360e51b81526001600160a01b0390911660048201529082908290602490829084905af180156103fc576103e85750f35b50346103f957806003193601126103f957600c546040516001600160a01b039091168152602090f35b50346103f957806111913661333b565b90919261119c613642565b6007546001600160a01b031690813b15611217576111d39060405195632fadf70d60e21b87526040600488015260448701916135d1565b848103600319016024860152828152916001600160fb1b038111611217578560208682968196829560051b809285830137010301925af180156103fc576103e85750f35b8580fd5b50346103f95760203660031901126103f957806004356001600160401b03811161040b5761124d90369060040161330b565b9190611257613642565b815b838110611264578280f35b611272611003828685613435565b600c546001600160a01b031690813b1561109957604051632a54db0160e01b81526001600160a01b03909116600482018190529185908290602490829084905af19081156113cb5785916113ff575b50506005546040516302045be960e41b8152600481018390526001600160a01b0390911690602081602481855afa9081156113f45786916113d6575b50813b156112175760405163992a793360e01b81526001600160a01b0390911660048201529085908290602490829084905af19081156113cb5785916113b6575b50506009546001600160a01b031690813b15611099578491604483926040519485938492637ab4974d60e01b84526004840152600560248401525af19081156113ab578491611392575b5050600101611259565b8161139c9161338b565b6113a7578238611388565b8280fd5b6040513d86823e3d90fd5b816113c09161338b565b610ee857833861133e565b6040513d87823e3d90fd5b6113ee915060203d8111610ee157610ed3818361338b565b386112fd565b6040513d88823e3d90fd5b816114099161338b565b610ee85783386112c1565b50346103f95760203660031901126103f95761142e613642565b60055481906001600160a01b0316803b1561040b5781809160246040518094819363078a3b1960e11b835260043560048401525af180156103fc576103e85750f35b50346103f95761147f3661333b565b929091600080516020613c7b8339815191528552600080516020613c5b8339815191526020526040852060018060a01b03331660005260205260ff604060002054168015611581575b6114d39033906133c2565b83810361108057908491825b8181106114ea578380f35b6009546001600160a01b0316611504611003838587613435565b611517611512848a8a613435565b6135c1565b823b15610d7b57604051637ab4974d60e01b81526001600160a01b0392909216600483015262ffffff1660248201529085908290604490829084905af19081156113cb57859161156c575b50506001016114df565b816115769161338b565b610ee8578338611562565b506005546001600160a01b031633146114c8565b50346103f957806003193601126103f9576009546040516001600160a01b039091168152602090f35b50346103f95760203660031901126103f957806115d9613289565b6115e1613642565b600b546001600160a01b031690813b1561040957604051630787a21360e51b81526001600160a01b0390911660048201529082908290602490829084905af180156103fc576103e85750f35b50346103f95760203660031901126103f957611647613642565b60055481906001600160a01b0316803b1561040b5781809160246040518094819363aad9293360e01b835260043560048401525af180156103fc576103e85750f35b50346103f95760203660031901126103f9576116a3613642565b600b5481906001600160a01b0316803b1561040b5781809160246040518094819363019494b360e01b835260043560048401525af180156103fc576103e85750f35b50346103f95760203660031901126103f9576004358152600080516020613c3b83398151915260205260408120604051908160208254918281520190819285526020852090855b81811061178c575050508261174291038361338b565b604051928392602084019060208552518091526040840192915b81811061176a575050500390f35b82516001600160a01b031684528594506020938401939092019160010161175c565b825484526020909301926001928301920161172c565b50346103f957806003193601126103f957602090604051908152f35b50346103f957806003193601126103f9576004546040516001600160a01b039091168152602090f35b50346103f95760403660031901126103f95760406118036132a4565b916004358152600080516020613c5b833981519152602052209060018060a01b0316600052602052602060ff604060002054166040519015158152f35b50346103f95760203660031901126103f9576004356001600160401b03811161109d5761187190369060040161330b565b9061187a613642565b825b828110611887578380f35b83611896611003838686613435565b600c546001600160a01b0316803b156113a757604051632a54db0160e01b815283816024818360018060a01b038816968760048401525af19081156113ab578491611a71575b50506005546040516302045be960e41b815260048101929092526001600160a01b031690602081602481855afa9081156113ab578491611a53575b50813b15610ee857604051639f06247b60e01b81526001600160a01b0390911660048201529083908290602490829084905af1908115611a48578391611a33575b505060095460405163149fad2f60e21b81526001600160a01b039091169190602081600481865afa9081156113ab5784916119f6575b50823b15610ee857604051637ab4974d60e01b81526001600160a01b0392909216600483015262ffffff1660248201529082908290604490829084905af180156103fc576119e1575b505060010161187c565b816119eb9161338b565b610ee85783386119d7565b90506020813d8211611a2b575b81611a106020938361338b565b81010312610ee8575162ffffff81168103610ee8573861198e565b3d9150611a03565b81611a3d9161338b565b61109d578138611958565b6040513d85823e3d90fd5b611a6b915060203d8111610ee157610ed3818361338b565b38611917565b81611a7b9161338b565b6113a75782386118dc565b50346103f95760203660031901126103f95780611aa16132fc565b611aa9613642565b600a546001600160a01b031690813b15610409578291602483926040519485938492631205220b60e31b8452151560048401525af180156103fc576103e85750f35b50346103f95760403660031901126103f957611b256020916004358152600080516020613c3b833981519152835260406024359120613aa3565b905460405160039290921b1c6001600160a01b03168152f35b50346103f95760203660031901126103f95780611b59613289565b600154611b729033906001600160a01b031681146133c2565b600b546001600160a01b031690813b1561040957604051634bc2a65760e01b81526001600160a01b0390911660048201529082908290602490829084905af180156103fc576103e85750f35b50346103f957806003193601126103f9576020604051600080516020613c7b8339815191528152f35b50346103f95760203660031901126103f957611c016132fc565b611c09613642565b15611c4a5760075481906001600160a01b0316803b1561040b57818091600460405180948193631fa5d41d60e11b83525af180156103fc576103e857505080f35b60075481906001600160a01b0316803b1561040b57818091600460405180948193638456cb5960e01b83525af180156103fc576103e857505080f35b50346103f957806003193601126103f957600d546040516001600160a01b039091168152602090f35b50346103f95760203660031901126103f9578060043562ffffff811680910361040b57611cda613642565b6009546001600160a01b031690813b156104095782916024839260405194859384926307fe355160e41b845260048401525af180156103fc576103e85750f35b50346103f957611d293661333b565b909291611d34613642565b8181036110805790849291835b818110611d4c578480f35b611d5a61104d828589613435565b15611dda576005546001600160a01b0316611d79611003838588613435565b813b15610d7b57604051634d8c928d60e11b81526001600160a01b0390911660048201529086908290602490829084905af19081156113f4578691611dc5575b50506001905b01611d41565b81611dcf9161338b565b611099578438611db9565b6005546001600160a01b0316611df4611003838588613435565b813b15610d7b57604051639c7f331560e01b81526001600160a01b0390911660048201529086908290602490829084905af19081156113f4578691611e3e575b5050600190611dbf565b81611e489161338b565b611099578438611e34565b50346103f95780611e633661333b565b9391611e7d9391933360018060a01b0385541633146133eb565b825b818110611e8a578380f35b600d546001600160a01b0316611ea4611003838587613435565b611eb261104d848a8a613435565b823b15610d7b5760405163638b9ba560e11b81526001600160a01b03929092166004830152151560248201529085908290604490829084905af19081156113cb578591611f04575b5050600101611e7f565b81611f0e9161338b565b610ee8578338611efa565b50346103f957806003193601126103f9576002546040516001600160a01b039091168152602090f35b50346103f957806003193601126103f9576020604051600080516020613cbb8339815191528152f35b50346103f95760203660031901126103f957806020611f88613289565b611f90613642565b6005546040516352fa180f60e11b81526001600160a01b039283166004820152938492602492849291165af19081156103fc5760209291610ebb57506040516001600160a01b039091168152f35b50346103f957611fed3661333b565b9290916120063360018060a01b036001541633146133c2565b83810361108057908491825b81811061201d578380f35b600a546001600160a01b0316612037611003838587613435565b612045611003848a8a613435565b823b15610d7b5760405163270401cb60e01b81526001600160a01b039283166004820152911660248201529085908290604490829084905af19081156113cb578591612096575b5050600101612012565b816120a09161338b565b610ee857833861208c565b50346103f9576120ba3661333b565b6120c693919293613642565b80840361108057908491825b8581106120dd578380f35b6005546001600160a01b03166120f7611003838987613435565b6040516302045be960e41b81526001600160a01b039091166004820152602081602481855afa9081156113f45786916121f3575b50604051630f55858b60e41b81526001600160a01b039091166004820152602081602481855afa9081156113f45786916121d5575b5061216f61100384868a613435565b823b15610d7b5760405163234823d760e01b81526001600160a01b039283166004820152911660248201529085908290604490829084905af19081156113cb5785916121c0575b50506001016120d2565b816121ca9161338b565b610ee85783386121b6565b6121ed915060203d8111610ee157610ed3818361338b565b38612160565b61220b915060203d8111610ee157610ed3818361338b565b3861212b565b50346103f95760203660031901126103f95761222b613642565b600a5481906001600160a01b0316803b1561040b578180916024604051809481936369fe0e2d60e01b835260043560048401525af180156103fc576103e85750f35b50346103f95760203660031901126103f95780602061228a613289565b6001546122a39033906001600160a01b031681146133c2565b60055460405163671fe03560e01b81526001600160a01b039283166004820152938492602492849291165af19081156103fc5760209291610ebb57506040516001600160a01b039091168152f35b50346103f95760203660031901126103f9578061230c613289565b612314613642565b6007546001600160a01b031690813b1561040957604051636379808f60e01b81526001600160a01b0390911660048201529082908290602490829084905af180156103fc576103e85750f35b50346103f957806003193601126103f9576001546040516001600160a01b039091168152602090f35b50346103f95760203660031901126103f9576123a3613642565b600a5481906001600160a01b0316803b1561040b578180916024604051809481936366cb150360e11b835260043560048401525af180156103fc576103e85750f35b50346103f95760203660031901126103f95780612400613289565b612408613642565b600c546001600160a01b031690813b1561040957604051630787a21360e51b81526001600160a01b0390911660048201529082908290602490829084905af180156103fc576103e85750f35b50346103f9576124633661333b565b61246e949394613642565b808303612508576007546001600160a01b031694853b15611099576124ae602091604051956394126bb160e01b87526040600488015260448701916135d1565b84810360031901602486015282815201919084905b8082106124e657505050818394818581819503925af180156103fc576103e85750f35b9091928335801515809103610d7b5781526020908101930191600101906124c3565b63899ef10d60e01b8452600484fd5b50346103f95760203660031901126103f95780546125419033906001600160a01b031681146133eb565b600d5481906001600160a01b0316803b1561040b57818091602460405180948193637c78e0f560e11b835260043560048401525af180156103fc576103e85750f35b50346103f95760203660031901126103f9578061259e613289565b6001546125b79033906001600160a01b031681146133c2565b6002546001600160a01b031690813b1561040957604051636bc26a1360e11b81526001600160a01b0390911660048201529082908290602490829084905af180156103fc576103e85750f35b50346103f95760203660031901126103f9578061261e613289565b612626613642565b6005546001600160a01b031690813b156104095760405163c42cf53560e01b81526001600160a01b0390911660048201529082908290602490829084905af180156103fc576103e85750f35b50346103f957806003193601126103f9576005546040516001600160a01b039091168152602090f35b50346103f9576126aa3661333b565b600080516020613c7b8339815191528552600080516020613c5b8339815191526020908152604080872033600090815292529020549293919260ff16801561279a575b6126f89033906133c2565b80840361108057908491825b85811061270f578380f35b600a546001600160a01b0316612729611003838987613435565b612734838589613435565b35823b15610d7b5760405163203e180f60e11b81526001600160a01b0392909216600483015260248201529085908290604490829084905af19081156113cb578591612785575b5050600101612704565b8161278f9161338b565b610ee857833861277b565b506005546001600160a01b031633146126ed565b50346103f957806003193601126103f957600a546040516001600160a01b039091168152602090f35b50346103f95760203660031901126103f957806127f2613289565b60015461280b9033906001600160a01b031681146133c2565b6009546001600160a01b031690813b15610409576040516301485b9d60e71b81526001600160a01b0390911660048201529082908290602490829084905af180156103fc576103e85750f35b50346103f95760203660031901126103f957612871613642565b60065481906001600160a01b0316803b1561040b5781809160246040518094819363d47ffef160e01b835260043560048401525af180156103fc576103e85750f35b50346103f95760203660031901126103f9576128cd613289565b81546001600160a01b038116916128e6338085146133eb565b6001600160a01b0316918214612906576001600160a01b03191617815580f35b63cb10513560e01b8352600483fd5b50346103f95760403660031901126103f95761292f6132a4565b336001600160a01b0382160361294b57610dca90600435613734565b63334bd91960e11b8252600482fd5b50346103f95760403660031901126103f957610dca60043561297a6132a4565b90612987610dc082613414565b6136ec565b50346103f95760203660031901126103f95780546129b69033906001600160a01b031681146133eb565b80f35b50346103f9576129c83661333b565b929091600080516020613c7b8339815191528552600080516020613c5b8339815191526020526040852060018060a01b03331660005260205260ff6040600020541615612c3b5783810361108057908491825b818110612a26578380f35b6009546001600160a01b03166020612a42611003848688613435565b6040516342378e9560e01b81526001600160a01b03909116600482015291829060249082905afa9081156113cb578591612c1d575b5015612b11576009546001600160a01b0316612a97611003838587613435565b612aa5611512848a8a613435565b823b15610d7b5760405163ba364c3d60e01b81526001600160a01b0392909216600483015262ffffff1660248201529085908290604490829084905af19081156113cb578591612afc575b50506001905b01612a1b565b81612b069161338b565b610ee8578338612af0565b600a546001600160a01b0316612b2b611003838587613435565b60405163e5e31b1360e01b81526001600160a01b039091166004820152602081602481855afa9081156113f4578691612bef575b50612b6e575b50600190612af6565b612b7c611003838587613435565b612b8a611512848a8a613435565b823b15610d7b5760405163a93a897d60e01b81526001600160a01b03909216600483015262ffffff1660248201529085908290604490829084905af19081156113cb578591612bda575b50612b65565b81612be49161338b565b610ee8578338612bd4565b612c10915060203d8111612c16575b612c08818361338b565b8101906135a9565b38612b5f565b503d612bfe565b612c35915060203d8111612c1657612c08818361338b565b38612a77565b63e2517d3f60e01b855233600452600080516020613c7b833981519152602452604485fd5b50346103f95760203660031901126103f957612c7a613642565b600c5481906001600160a01b0316803b1561040b57818091602460405180948193633638348360e21b835260043560048401525af180156103fc576103e85750f35b50346103f95760203660031901126103f9576020612cdb600435613414565b604051908152f35b50346103f95760203660031901126103f95780612cfe613289565b612d06613642565b6008546001600160a01b031690813b15610409576040516329605e7760e01b81526001600160a01b0390911660048201529082908290602490829084905af180156103fc576103e85750f35b50346103f95760403660031901126103f95780612d6d613289565b60243590811515820361040957612d82613642565b600a546001600160a01b031691823b156104075760405163e0bd111d60e01b81526001600160a01b039092166004830152151560248201529082908290818381604481016108ee565b50346103f95760403660031901126103f957612de5613289565b6024356001600160401b0381116113a757366023820112156113a757828160040135926001600160401b03841161109d576024830192602485369201011161109d578154829190612e429033906001600160a01b031681146133eb565b60405185858237828187810182815203925af13d15612ee3573d6001600160401b038111612ecf5760405190612e82601f8201601f19166020018361338b565b81528460203d92013e5b15612e95578280f35b8160449293604051948593634715803360e01b85526020600486015281602486015285850137828201840152601f01601f19168101030190fd5b634e487b7160e01b85526041600452602485fd5b612e8c565b50346103f95760203660031901126103f95780612f03613289565b600154612f1c9033906001600160a01b031681146133c2565b6002546001600160a01b031690813b15610409576040516301485b9d60e71b81526001600160a01b0390911660048201529082908290602490829084905af180156103fc576103e85750f35b50346103f957806003193601126103f9576007546040516001600160a01b039091168152602090f35b50346103f957806003193601126103f9576003546040516001600160a01b039091168152602090f35b50346103f95760403660031901126103f95780612fd5613289565b612fdd613642565b6005546001600160a01b0316803b1561040957604051635824780d60e01b81526001600160a01b039092166004830152602480359083015282908290818381604481016108ee565b50346103f957806003193601126103f9576008546040516001600160a01b039091168152602090f35b50346103f95760203660031901126103f957613068613289565b6001546130819033906001600160a01b031681146133c2565b60018060a01b03166001600160601b0360a01b600c541617600c5580f35b50346103f957806003193601126103f9576006546040516001600160a01b039091168152602090f35b50346103f95760203660031901126103f957806130e3613289565b6001546130fc9033906001600160a01b031681146133c2565b6009546001600160a01b031690813b1561040957604051634bc2a65760e01b81526001600160a01b0390911660048201529082908290602490829084905af180156103fc576103e85750f35b50346103f95760203660031901126103f95760043563ffffffff60e01b811680910361109d57602090635a05180f60e01b811490811561318e575b506040519015158152f35b637965db0b60e01b8114915081156131a8575b5082613183565b6301ffc9a760e01b149050826131a1565b50346103f95760a03660031901126103f9576131d3613289565b816131dc6132a4565b916131e56132ba565b6131ed6132d0565b936131f66132e6565b9261320d3360018060a01b036001541633146133c2565b6001600160a01b031690813b156110995760405163f27ebced60e01b81526001600160a01b0391821660048201529281166024840152948516604483015291909316606484015281908390608490829084905af1801561327c5761326e5780f35b6132779161338b565b388180f35b50604051903d90823e3d90fd5b600435906001600160a01b038216820361329f57565b600080fd5b602435906001600160a01b038216820361329f57565b604435906001600160a01b038216820361329f57565b606435906001600160a01b038216820361329f57565b608435906001600160a01b038216820361329f57565b60043590811515820361329f57565b9181601f8401121561329f578235916001600160401b03831161329f576020808501948460051b01011161329f57565b604060031982011261329f576004356001600160401b03811161329f57816133659160040161330b565b92909291602435906001600160401b03821161329f576133879160040161330b565b9091565b90601f801991011681019081106001600160401b038211176133ac57604052565b634e487b7160e01b600052604160045260246000fd5b156133ca5750565b632bc10c3360e01b60009081526001600160a01b0391909116600452602490fd5b156133f35750565b636241d8a560e11b60009081526001600160a01b0391909116600452602490fd5b600052600080516020613c5b83398151915260205260016040600020015490565b91908110156134455760051b0190565b634e487b7160e01b600052603260045260246000fd5b6044356001600160a01b038116810361329f5790565b6064356001600160a01b038116810361329f5790565b6084356001600160a01b038116810361329f5790565b60a4356001600160a01b038116810361329f5790565b60c4356001600160a01b038116810361329f5790565b60e4356001600160a01b038116810361329f5790565b610144356001600160a01b038116810361329f5790565b610184356001600160a01b038116810361329f5790565b6101a4356001600160a01b038116810361329f5790565b610104356001600160a01b038116810361329f5790565b610124356001600160a01b038116810361329f5790565b610164356001600160a01b038116810361329f5790565b6004356001600160a01b038116810361329f5790565b6024356001600160a01b038116810361329f5790565b356001600160a01b038116810361329f5790565b9081602091031261329f5751801515810361329f5790565b3562ffffff8116810361329f5790565b916020908281520191906000905b8082106135ec5750505090565b90919283359060018060a01b03821680920361329f576020816001938293520194019201906135df565b9081602091031261329f57516001600160a01b038116810361329f5790565b35801515810361329f5790565b3360009081527f3b05fb06f7501e09d6a8a50c59dac59cd7c8dab47e848ae345bfca5e4d5d9e3c602052604090205460ff161561367b57565b63e2517d3f60e01b60005233600452600080516020613cbb83398151915260245260446000fd5b6000818152600080516020613c5b8339815191526020908152604080832033845290915290205460ff16156136d45750565b63e2517d3f60e01b6000523360045260245260446000fd5b6136f6828261396c565b918261370157505090565b6000918252600080516020613c3b8339815191526020526040909120613730916001600160a01b031690613abb565b5090565b61373e8282613a03565b918261374957505090565b6000918252600080516020613c3b8339815191526020526040909120613730916001600160a01b031690613b31565b6001600160a01b03811660009081527f9eacbbea19e14d84ae6fc89bafe3fe4134e0cfcdae6894d6d7239131d0cd8325602052604090205460ff16613822576001600160a01b031660008181527f9eacbbea19e14d84ae6fc89bafe3fe4134e0cfcdae6894d6d7239131d0cd832560205260408120805460ff19166001179055339190600080516020613c7b83398151915290600080516020613c1b8339815191529080a4600190565b50600090565b6001600160a01b03811660009081527f3b05fb06f7501e09d6a8a50c59dac59cd7c8dab47e848ae345bfca5e4d5d9e3c602052604090205460ff16613822576001600160a01b031660008181527f3b05fb06f7501e09d6a8a50c59dac59cd7c8dab47e848ae345bfca5e4d5d9e3c60205260408120805460ff19166001179055339190600080516020613cbb83398151915290600080516020613c1b8339815191529080a4600190565b6001600160a01b03811660009081527fb7db2dd08fcb62d0c9e08c51941cae53c267786a0b75803fb7960902fc8ef97d602052604090205460ff16613822576001600160a01b031660008181527fb7db2dd08fcb62d0c9e08c51941cae53c267786a0b75803fb7960902fc8ef97d60205260408120805460ff19166001179055339190600080516020613c1b8339815191528180a4600190565b6000818152600080516020613c5b833981519152602090815260408083206001600160a01b038616845290915290205460ff166139fc576000818152600080516020613c5b833981519152602090815260408083206001600160a01b0395909516808452949091528120805460ff1916600117905533929190600080516020613c1b8339815191529080a4600190565b5050600090565b6000818152600080516020613c5b833981519152602090815260408083206001600160a01b038616845290915290205460ff16156139fc576000818152600080516020613c5b833981519152602090815260408083206001600160a01b0395909516808452949091528120805460ff19169055339291907ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b9080a4600190565b80548210156134455760005260206000200190600090565b6001810190826000528160205260406000205415600014613b29578054680100000000000000008110156133ac57613b14613afd826001879401855584613aa3565b819391549060031b91821b91600019901b19161790565b90555491600052602052604060002055600190565b505050600090565b9060018201918160005282602052604060002054801515600014613c11576000198101818111613bfb578254600019810191908211613bfb57818103613bc4575b50505080548015613bae576000190190613b8c8282613aa3565b8154906000199060031b1b191690555560005260205260006040812055600190565b634e487b7160e01b600052603160045260246000fd5b613be4613bd4613afd9386613aa3565b90549060031b1c92839286613aa3565b905560005283602052604060002055388080613b72565b634e487b7160e01b600052601160045260246000fd5b5050505060009056fe2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0dc1f6fe24621ce81ec5827caf0253cadb74709b061630e6b55e8237170593200002dd7bc7dec4dceedda775e58dd541e08a116c6c53815c0bd028192f7b6268000cee480c05aeabaa18fb824cd297ccabddb1b1a9a83b28d3f07e85c0cd25c459f0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a00b3072e349cf62590698516830b9ea81d68c974027ccbf3c77e3d2a88743208e5a2646970667358221220036c8e8383f3cf768c50ca1d9990f7a5018795892c3b4f5b664ea835795c9a4d64736f6c634300081c0033
Loading...
Loading
Loading...
Loading
Loading...
Loading
Net Worth in USD
$0.00
Net Worth in ETH
Multichain Portfolio | 35 Chains
| Chain | Token | Portfolio % | Price | Amount | Value |
|---|
Loading...
Loading
Loading...
Loading
Loading...
Loading
[ Download: CSV Export ]
A contract address hosts a smart contract, which is a set of code stored on the blockchain that runs when predetermined conditions are met. Learn more about addresses in our Knowledge Base.