Latest 24 from a total of 24 transactions
| Transaction Hash |
Method
|
Block
|
From
|
|
To
|
||||
|---|---|---|---|---|---|---|---|---|---|
| Revoke Role | 21702597 | 319 days ago | IN | 0 ETH | 0.00025315 | ||||
| Withdraw From Sy... | 21702320 | 319 days ago | IN | 0 ETH | 0.00241504 | ||||
| Deposit To Symbi... | 21702307 | 319 days ago | IN | 0 ETH | 0.00292904 | ||||
| Deposit To Level... | 21702165 | 319 days ago | IN | 0 ETH | 0.00053844 | ||||
| Withdraw From Yi... | 21702160 | 319 days ago | IN | 0 ETH | 0.00201723 | ||||
| Approve Spender | 21702145 | 319 days ago | IN | 0 ETH | 0.00043158 | ||||
| Approve Spender | 21702144 | 319 days ago | IN | 0 ETH | 0.00044473 | ||||
| Deposit For Yiel... | 21702101 | 319 days ago | IN | 0 ETH | 0.00294507 | ||||
| Deposit For Yiel... | 21702095 | 319 days ago | IN | 0 ETH | 0.00278074 | ||||
| Grant Role | 21702093 | 319 days ago | IN | 0 ETH | 0.00038359 | ||||
| Set Treasury | 21698703 | 320 days ago | IN | 0 ETH | 0.00014942 | ||||
| Grant Role | 21698702 | 320 days ago | IN | 0 ETH | 0.00025488 | ||||
| Revoke Role | 21698701 | 320 days ago | IN | 0 ETH | 0.00013663 | ||||
| Grant Role | 21698700 | 320 days ago | IN | 0 ETH | 0.00025128 | ||||
| Grant Role | 21698699 | 320 days ago | IN | 0 ETH | 0.00025094 | ||||
| Grant Role | 21698698 | 320 days ago | IN | 0 ETH | 0.00024608 | ||||
| Grant Role | 21698697 | 320 days ago | IN | 0 ETH | 0.00024342 | ||||
| Grant Role | 21698696 | 320 days ago | IN | 0 ETH | 0.00024304 | ||||
| Grant Role | 21698695 | 320 days ago | IN | 0 ETH | 0.0002489 | ||||
| Set Allowlist | 21698694 | 320 days ago | IN | 0 ETH | 0.0002504 | ||||
| Set Allowlist | 21698693 | 320 days ago | IN | 0 ETH | 0.00024683 | ||||
| Set Yield Manage... | 21698692 | 320 days ago | IN | 0 ETH | 0.00024964 | ||||
| Set Yield Manage... | 21698681 | 320 days ago | IN | 0 ETH | 0.00022807 | ||||
| Transfer Admin | 21698681 | 320 days ago | IN | 0 ETH | 0.00034084 |
View more zero value Internal Transactions in Advanced View mode
Advanced mode:
Loading...
Loading
Cross-Chain Transactions
Loading...
Loading
Contract Source Code Verified (Exact Match)
Contract Name:
SymbioticReserveManager
Compiler Version
v0.8.25+commit.b61c2a91
Optimization Enabled:
Yes with 200 runs
Other Settings:
cancun EvmVersion
Contract Source Code (Solidity Standard Json-Input format)
// SPDX-License-Identifier: BUSL-1.1
pragma solidity >=0.8.19;
import "./LevelBaseReserveManager.sol";
import "../interfaces/ISymbioticVault.sol" as ISymbioticVault;
import "../interfaces/ILevelSymbioticReserveManager.sol";
/**
* @title Symbiotic Reserve Manager
* @notice This contract stores and manages reserves to be deployed to Symbiotic.
*/
contract SymbioticReserveManager is LevelBaseReserveManager, ISymbioticReserveManager {
using SafeERC20 for IERC20;
/* --------------- CONSTRUCTOR --------------- */
constructor(IlvlUSD _lvlusd, IStakedlvlUSD _stakedlvlUSD, address _admin, address _allowlister)
LevelBaseReserveManager(_lvlusd, _stakedlvlUSD, _admin, _allowlister)
{}
/* --------------- EXTERNAL --------------- */
function depositToSymbiotic(address vault, uint256 amount)
external
onlyRole(MANAGER_AGENT_ROLE)
whenNotPaused
returns (uint256 depositedAmount, uint256 mintedShares)
{
address collateral = ISymbioticVault.IVault(vault).collateral();
IERC20(collateral).forceApprove(vault, amount);
(depositedAmount, mintedShares) = ISymbioticVault.IVault(vault).deposit(address(this), amount);
emit DepositedToSymbiotic(amount, vault);
}
function withdrawFromSymbiotic(address vault, uint256 amount)
external
onlyRole(MANAGER_AGENT_ROLE)
whenNotPaused
returns (uint256 burnedShares, uint256 mintedShares)
{
(burnedShares, mintedShares) = ISymbioticVault.IVault(vault).withdraw(address(this), amount);
emit WithdrawnFromSymbiotic(amount, vault);
}
function claimFromSymbiotic(address vault, uint256 epoch)
external
onlyRole(MANAGER_AGENT_ROLE)
whenNotPaused
returns (uint256 amount)
{
amount = ISymbioticVault.IVault(vault).claim(address(this), epoch);
emit ClaimedFromSymbiotic(epoch, amount, vault);
}
}// SPDX-License-Identifier: BUSL-1.1
pragma solidity >=0.8.19;
import "../interfaces/ILevelBaseReserveManager.sol";
import "../interfaces/IlvlUSD.sol";
import "../interfaces/ILevelMinting.sol";
import "../interfaces/IStakedlvlUSD.sol";
import "../interfaces/ILevelBaseYieldManager.sol";
import {SingleAdminAccessControl} from "../auth/v5/SingleAdminAccessControl.sol";
import {WrappedRebasingERC20} from "../WrappedRebasingERC20.sol";
import "@openzeppelin/contracts/utils/ReentrancyGuard.sol";
import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
import {SafeCast} from "@openzeppelin/contracts/utils/math/SafeCast.sol";
import {Pausable} from "@openzeppelin/contracts/utils/Pausable.sol";
import {ERC20} from "@openzeppelin/contracts/token/ERC20/ERC20.sol";
import {FixedPointMathLib} from "solmate/utils/FixedPointMathLib.sol";
/**
* @title Level Base Reserve Manager
* @notice This is the superclass for all reserve managers
* to inherit common functionality. It is _not_ intended
* to be deployed on its own.
*/
abstract contract LevelBaseReserveManager is
ILevelBaseReserveManager,
SingleAdminAccessControl,
Pausable
{
using FixedPointMathLib for uint256;
using SafeCast for uint256;
using SafeERC20 for IERC20;
event EtherReceived(address indexed sender, uint256 amount);
event FallbackCalled(address indexed sender, uint256 amount, bytes data);
/// @notice role that sets the addresses where funds can be sent from this contract
bytes32 private constant ALLOWLIST_ROLE = keccak256("ALLOWLIST_ROLE");
/// @notice role that deposits to/withdraws from a yield strategy or a restaking protocol
bytes32 internal constant MANAGER_AGENT_ROLE =
keccak256("MANAGER_AGENT_ROLE");
/// @notice role that pauses the contract
bytes32 private constant PAUSER_ROLE = keccak256("PAUSER_ROLE");
/* --------------- STATE VARIABLES --------------- */
/// @notice address that receives the yield
address public treasury;
/// @notice basis points of the max slippage threshold
uint16 constant MAX_BASIS_POINTS = 1e4;
/// @notice basis points of the rake
uint16 public rakeBasisPoints;
uint16 public constant MAX_RAKE_BASIS_POINTS = 5000; // 50%
/// @notice basis points of max slippage threshold
uint16 public maxSlippageThresholdBasisPoints;
IlvlUSD public immutable lvlUSD;
uint256 public immutable lvlUsdDecimals;
ILevelMinting public immutable levelMinting;
mapping(address => bool) public allowlist;
IStakedlvlUSD stakedlvlUSD;
// mapping of native token address to yield manager responsible for handling that token
mapping(address => ILevelBaseYieldManager) yieldManager;
/* --------------- CONSTRUCTOR --------------- */
constructor(
IlvlUSD _lvlUSD,
IStakedlvlUSD _stakedlvlUSD,
address _admin,
address _allowlister
) {
if (address(_lvlUSD) == address(0)) revert InvalidlvlUSDAddress();
if (_admin == address(0)) revert InvalidZeroAddress();
lvlUSD = _lvlUSD;
lvlUsdDecimals = _lvlUSD.decimals();
levelMinting = ILevelMinting(_lvlUSD.minter());
stakedlvlUSD = _stakedlvlUSD;
maxSlippageThresholdBasisPoints = 5; // 0.05%
_grantRole(DEFAULT_ADMIN_ROLE, _admin);
_grantRole(ALLOWLIST_ROLE, _allowlister);
_grantRole(PAUSER_ROLE, _admin);
}
/* --------------- EXTERNAL --------------- */
/**
* @notice Convert `amount` of `token` to a yield bearing version
* (ie wrapped Aave USDT if token is USDT)
* @param token address of the token
* @param amount amount to deposit
* @dev only callable by manager agent
*/
function depositForYield(
address token,
uint256 amount
) external onlyRole(MANAGER_AGENT_ROLE) whenNotPaused {
IERC20(token).forceApprove(address(yieldManager[token]), amount);
yieldManager[token].depositForYield(token, amount);
emit DepositedToYieldManager(
token,
address(yieldManager[token]),
amount
);
}
/**
* @notice Convert `amount` of `token` from a yield bearing version
* (ie wrapped Aave USDT if token is USDT) to the native version (ie USDT)
* @param token address of the token
* @param amount amount to withdraw
* @dev only callable by manager agent
*/
function withdrawFromYieldManager(
address token,
uint256 amount
) external onlyRole(MANAGER_AGENT_ROLE) whenNotPaused {
yieldManager[token].withdraw(token, amount);
emit WithdrawnFromYieldManager(
token,
address(yieldManager[token]),
amount
);
}
/**
* @notice Deposit collateral to level minting contract, to be made available
* for redemptions
* @param token address of the collateral token
* @param amount amount of collateral to deposit
* @dev only callable by manager agent
*/
function depositToLevelMinting(
address token,
uint256 amount
) external onlyRole(MANAGER_AGENT_ROLE) whenNotPaused {
IERC20(token).safeTransfer(address(levelMinting), amount);
emit DepositedToLevelMinting(amount);
}
/**
* @notice Take a rake from the amount and transfer it to the treasury
* @param token address of the token to take rake from
* @param amount amount of token to take rake from
* @return rake amount taken
* @return remainder amount after rake
*/
function _takeRake(
address token,
uint256 amount
) internal returns (uint256, uint256) {
if (treasury == address(0)) {
revert TreasuryNotSet();
}
if (rakeBasisPoints == 0 || amount == 0) {
return (0, amount);
}
uint256 rake = amount.mulDivUp(rakeBasisPoints, MAX_BASIS_POINTS);
uint256 remainder = amount - rake;
IERC20(token).safeTransfer(treasury, rake);
return (rake, remainder);
}
/**
* @notice Rewards staked lvlUSD with lvlUSD. The admin should call
* mint lvlUSD before calling this function
* @param amount amount of lvlUSD to reward
* @dev only callable by admin
*/
function _rewardStakedlvlUSD(uint256 amount) internal whenNotPaused {
IERC20(lvlUSD).forceApprove(address(stakedlvlUSD), amount);
stakedlvlUSD.transferInRewards(amount);
}
/**
* @notice Mint lvlUSD using collateral
* @param collateral address of the collateral token
* @param collateralAmount amount of collateral to mint lvlUSD with
* @dev only callable by admin
*/
function _mintlvlUSD(
address collateral,
uint256 collateralAmount
) internal whenNotPaused {
IERC20(collateral).forceApprove(
address(levelMinting),
collateralAmount
);
uint256 collateralDecimals = ERC20(collateral).decimals();
uint256 lvlUSDAmount;
if (collateralDecimals < lvlUsdDecimals) {
lvlUSDAmount =
collateralAmount *
(10 ** (lvlUsdDecimals - collateralDecimals));
} else {
lvlUSDAmount =
collateralAmount /
(10 ** (collateralDecimals - lvlUsdDecimals));
}
// Apply max slippage threshold
lvlUSDAmount -= lvlUSDAmount.mulDivDown(
maxSlippageThresholdBasisPoints,
MAX_BASIS_POINTS
);
ILevelMinting.Order memory order = ILevelMinting.Order(
ILevelMinting.OrderType.MINT,
address(this), // benefactor
address(this), // beneficiary
collateral, // collateral
collateralAmount, // collateral amount
lvlUSDAmount // expected minimum level USD amount to receive to this contract
);
levelMinting.mintDefault(order);
}
function rewardStakedlvlUSD(
address token
) external onlyRole(MANAGER_AGENT_ROLE) whenNotPaused {
uint amount = yieldManager[token].collectYield(token);
(, uint256 collateralAmount) = _takeRake(token, amount);
if (collateralAmount == 0) {
revert InvalidAmount();
}
uint lvlUSDBalBefore = lvlUSD.balanceOf(address(this));
_mintlvlUSD(token, collateralAmount);
uint lvlUSDBalAfter = lvlUSD.balanceOf(address(this));
_rewardStakedlvlUSD(lvlUSDBalAfter - lvlUSDBalBefore);
}
/** Rescue functions- only callable by admin for emergencies */
/**
* @notice Approve spender to spend a certain amount of token
* @param token address of the token
* @param spender address of the spender
* @param amount amount to approve
* @dev only callable by admin
*/
function approveSpender(
address token,
address spender,
uint256 amount
) external onlyRole(DEFAULT_ADMIN_ROLE) whenNotPaused {
IERC20(token).forceApprove(spender, amount);
}
/**
* @notice Transfer ERC20 token to a recipient
* @param tokenAddress address of the token
* @param tokenReceiver address of the recipient
* @param tokenAmount amount of token to transfer
* @dev only callable by admin
*/
function transferERC20(
address tokenAddress,
address tokenReceiver,
uint256 tokenAmount
) external onlyRole(DEFAULT_ADMIN_ROLE) whenNotPaused {
if (allowlist[tokenReceiver]) {
IERC20(tokenAddress).safeTransfer(tokenReceiver, tokenAmount);
} else {
revert InvalidRecipient();
}
}
/**
* @notice Transfer ETH to a recipient
* @param _to address of the recipient
* @param _amount amount of ETH to transfer
* @dev only callable by admin
*/
function transferEth(
address payable _to,
uint256 _amount
) external onlyRole(DEFAULT_ADMIN_ROLE) whenNotPaused {
if (allowlist[_to]) {
(bool success, ) = _to.call{value: _amount}("");
require(success, "Failed to send Ether");
} else {
revert InvalidRecipient();
}
}
// Receive function - Called when ETH is sent with empty calldata
receive() external payable {
emit EtherReceived(msg.sender, msg.value);
}
// Fallback function - Called when ETH is sent with non-empty calldata
fallback() external payable {
emit FallbackCalled(msg.sender, msg.value, msg.data);
}
/* --------------- SETTERS --------------- */
function setPaused(bool paused) external onlyRole(PAUSER_ROLE) {
if (paused) {
_pause();
} else {
_unpause();
}
}
function setAllowlist(
address recipient,
bool isAllowlisted
) external onlyRole(ALLOWLIST_ROLE) whenNotPaused {
allowlist[recipient] = isAllowlisted;
}
function setStakedlvlUSDAddress(
address newAddress
) external onlyRole(DEFAULT_ADMIN_ROLE) {
stakedlvlUSD = IStakedlvlUSD(newAddress);
}
function setYieldManager(
address token,
address baseYieldManager
) external onlyRole(DEFAULT_ADMIN_ROLE) {
yieldManager[token] = ILevelBaseYieldManager(baseYieldManager);
emit YieldManagerSetForToken(token, address(yieldManager[token]));
}
function setTreasury(
address _treasury
) external onlyRole(DEFAULT_ADMIN_ROLE) {
treasury = _treasury;
}
function setRakeBasisPoints(
uint16 _rakeBasisPoints
) external onlyRole(DEFAULT_ADMIN_ROLE) {
if (_rakeBasisPoints > MAX_RAKE_BASIS_POINTS) {
revert InvalidAmount();
}
rakeBasisPoints = _rakeBasisPoints;
}
function setMaxSlippageThresholdBasisPoints(
uint16 _maxSlippageThresholdBasisPoints
) external onlyRole(DEFAULT_ADMIN_ROLE) {
require(
_maxSlippageThresholdBasisPoints <= MAX_BASIS_POINTS,
"Slippage threshold cannot exceed max basis points"
);
maxSlippageThresholdBasisPoints = _maxSlippageThresholdBasisPoints;
}
}// SPDX-License-Identifier: BUSL-1.1
pragma solidity 0.8.25;
import {IVaultStorage} from "./ISymbioticVaultStorage.sol";
interface IVault is IVaultStorage {
error AlreadyClaimed();
error AlreadySet();
error DepositLimitReached();
error InsufficientClaim();
error InsufficientDeposit();
error InsufficientWithdrawal();
error InvalidAccount();
error InvalidCaptureEpoch();
error InvalidClaimer();
error InvalidCollateral();
error InvalidEpoch();
error InvalidEpochDuration();
error InvalidLengthEpochs();
error InvalidOnBehalfOf();
error InvalidRecipient();
error MissingRoles();
error NoDepositLimit();
error NoDepositWhitelist();
error NotDelegator();
error NotSlasher();
error NotWhitelistedDepositor();
error TooMuchWithdraw();
/**
* @notice Initial parameters needed for a vault deployment.
* @param collateral vault's underlying collateral
* @param delegator vault's delegator to delegate the stake to networks and operators
* @param slasher vault's slasher to provide a slashing mechanism to networks
* @param burner vault's burner to issue debt to (e.g., 0xdEaD or some unwrapper contract)
* @param epochDuration duration of the vault epoch (it determines sync points for withdrawals)
* @param depositWhitelist if enabling deposit whitelist
* @param isDepositLimit if enabling deposit limit
* @param depositLimit deposit limit (maximum amount of the collateral that can be in the vault simultaneously)
* @param defaultAdminRoleHolder address of the initial DEFAULT_ADMIN_ROLE holder
* @param depositWhitelistSetRoleHolder address of the initial DEPOSIT_WHITELIST_SET_ROLE holder
* @param depositorWhitelistRoleHolder address of the initial DEPOSITOR_WHITELIST_ROLE holder
* @param isDepositLimitSetRoleHolder address of the initial IS_DEPOSIT_LIMIT_SET_ROLE holder
* @param depositLimitSetRoleHolder address of the initial DEPOSIT_LIMIT_SET_ROLE holder
*/
struct InitParams {
address collateral;
address delegator;
address slasher;
address burner;
uint48 epochDuration;
bool depositWhitelist;
bool isDepositLimit;
uint256 depositLimit;
address defaultAdminRoleHolder;
address depositWhitelistSetRoleHolder;
address depositorWhitelistRoleHolder;
address isDepositLimitSetRoleHolder;
address depositLimitSetRoleHolder;
}
/**
* @notice Hints for an active balance.
* @param activeSharesOfHint hint for the active shares of checkpoint
* @param activeStakeHint hint for the active stake checkpoint
* @param activeSharesHint hint for the active shares checkpoint
*/
struct ActiveBalanceOfHints {
bytes activeSharesOfHint;
bytes activeStakeHint;
bytes activeSharesHint;
}
/**
* @notice Emitted when a deposit is made.
* @param depositor account that made the deposit
* @param onBehalfOf account the deposit was made on behalf of
* @param amount amount of the collateral deposited
* @param shares amount of the active shares minted
*/
event Deposit(
address indexed depositor,
address indexed onBehalfOf,
uint256 amount,
uint256 shares
);
/**
* @notice Emitted when a withdrawal is made.
* @param withdrawer account that made the withdrawal
* @param claimer account that needs to claim the withdrawal
* @param amount amount of the collateral withdrawn
* @param burnedShares amount of the active shares burned
* @param mintedShares amount of the epoch withdrawal shares minted
*/
event Withdraw(
address indexed withdrawer,
address indexed claimer,
uint256 amount,
uint256 burnedShares,
uint256 mintedShares
);
/**
* @notice Emitted when a claim is made.
* @param claimer account that claimed
* @param recipient account that received the collateral
* @param epoch epoch the collateral was claimed for
* @param amount amount of the collateral claimed
*/
event Claim(
address indexed claimer,
address indexed recipient,
uint256 epoch,
uint256 amount
);
/**
* @notice Emitted when a batch claim is made.
* @param claimer account that claimed
* @param recipient account that received the collateral
* @param epochs epochs the collateral was claimed for
* @param amount amount of the collateral claimed
*/
event ClaimBatch(
address indexed claimer,
address indexed recipient,
uint256[] epochs,
uint256 amount
);
/**
* @notice Emitted when a slash happened.
* @param slasher address of the slasher
* @param slashedAmount amount of the collateral slashed
*/
event OnSlash(address indexed slasher, uint256 slashedAmount);
/**
* @notice Emitted when a deposit whitelist status is enabled/disabled.
* @param status if enabled deposit whitelist
*/
event SetDepositWhitelist(bool status);
/**
* @notice Emitted when a depositor whitelist status is set.
* @param account account for which the whitelist status is set
* @param status if whitelisted the account
*/
event SetDepositorWhitelistStatus(address indexed account, bool status);
/**
* @notice Emitted when a deposit limit status is enabled/disabled.
* @param status if enabled deposit limit
*/
event SetIsDepositLimit(bool status);
/**
* @notice Emitted when a deposit limit is set.
* @param limit deposit limit (maximum amount of the collateral that can be in the vault simultaneously)
*/
event SetDepositLimit(uint256 limit);
/**
* @notice Get a total amount of the collateral that can be slashed.
* @return total amount of the slashable collateral
*/
function totalStake() external view returns (uint256);
/**
* @notice Get an active balance for a particular account at a given timestamp using hints.
* @param account account to get the active balance for
* @param timestamp time point to get the active balance for the account at
* @param hints hints for checkpoints' indexes
* @return active balance for the account at the timestamp
*/
function activeBalanceOfAt(
address account,
uint48 timestamp,
bytes calldata hints
) external view returns (uint256);
/**
* @notice Get an active balance for a particular account.
* @param account account to get the active balance for
* @return active balance for the account
*/
function activeBalanceOf(address account) external view returns (uint256);
/**
* @notice Get withdrawals for a particular account at a given epoch (zero if claimed).
* @param epoch epoch to get the withdrawals for the account at
* @param account account to get the withdrawals for
* @return withdrawals for the account at the epoch
*/
function withdrawalsOf(
uint256 epoch,
address account
) external view returns (uint256);
/**
* @notice Get a total amount of the collateral that can be slashed for a given account.
* @return total amount of the slashable collateral
*/
function balanceOf(address account) external view returns (uint256);
/**
* @notice Deposit collateral into the vault.
* @param onBehalfOf account the deposit is made on behalf of
* @param amount amount of the collateral to deposit
* @return depositedAmount amount of the collateral deposited
* @return mintedShares amount of the active shares minted
*/
function deposit(
address onBehalfOf,
uint256 amount
) external returns (uint256 depositedAmount, uint256 mintedShares);
/**
* @notice Withdraw collateral from the vault (it will be claimable after the next epoch).
* @param claimer account that needs to claim the withdrawal
* @param amount amount of the collateral to withdraw
* @return burnedShares amount of the active shares burned
* @return mintedShares amount of the epoch withdrawal shares minted
*/
function withdraw(
address claimer,
uint256 amount
) external returns (uint256 burnedShares, uint256 mintedShares);
/**
* @notice Claim collateral from the vault.
* @param recipient account that receives the collateral
* @param epoch epoch to claim the collateral for
* @return amount amount of the collateral claimed
*/
function claim(
address recipient,
uint256 epoch
) external returns (uint256 amount);
/**
* @notice Claim collateral from the vault for multiple epochs.
* @param recipient account that receives the collateral
* @param epochs epochs to claim the collateral for
* @return amount amount of the collateral claimed
*/
function claimBatch(
address recipient,
uint256[] calldata epochs
) external returns (uint256 amount);
/**
* @notice Slash callback for burning collateral.
* @param slashedAmount amount to slash
* @param captureTimestamp time point when the stake was captured
* @dev Only the slasher can call this function.
*/
function onSlash(uint256 slashedAmount, uint48 captureTimestamp) external;
/**
* @notice Enable/disable deposit whitelist.
* @param status if enabling deposit whitelist
* @dev Only a DEPOSIT_WHITELIST_SET_ROLE holder can call this function.
*/
function setDepositWhitelist(bool status) external;
/**
* @notice Set a depositor whitelist status.
* @param account account for which the whitelist status is set
* @param status if whitelisting the account
* @dev Only a DEPOSITOR_WHITELIST_ROLE holder can call this function.
*/
function setDepositorWhitelistStatus(address account, bool status) external;
/**
* @notice Enable/disable deposit limit.
* @param status if enabling deposit limit
* @dev Only a IS_DEPOSIT_LIMIT_SET_ROLE holder can call this function.
*/
function setIsDepositLimit(bool status) external;
/**
* @notice Set a deposit limit.
* @param limit deposit limit (maximum amount of the collateral that can be in the vault simultaneously)
* @dev Only a DEPOSIT_LIMIT_SET_ROLE holder can call this function.
*/
function setDepositLimit(uint256 limit) external;
}// SPDX-License-Identifier: BUSL-1.1
pragma solidity ^0.8.20;
import "./ILevelMinting.sol";
interface ISymbioticReserveManager {
event DepositedToSymbiotic(uint256 amount, address symbioticVault);
event WithdrawnFromSymbiotic(uint256 amount, address symbioticVault);
event ClaimedFromSymbiotic(
uint256 epoch,
uint256 amount,
address symbioticVault
);
function depositToSymbiotic(
address vault,
uint256 amount
) external returns (uint256 depositedAmount, uint256 mintedShares);
function withdrawFromSymbiotic(
address vault,
uint256 amount
) external returns (uint256 burnedShares, uint256 mintedShares);
function claimFromSymbiotic(
address vault,
uint256 epoch
) external returns (uint256 amount);
}// SPDX-License-Identifier: BUSL-1.1
pragma solidity >=0.8.19;
import "./IlvlUSD.sol";
import "./ILevelMinting.sol";
import "./IStakedlvlUSD.sol";
import "./ILevelBaseYieldManager.sol";
interface ILevelBaseReserveManager {
/* Events */
event DepositedToYieldManager(
address token,
address yieldManager,
uint256 amount
);
event WithdrawnFromYieldManager(
address token,
address yieldManager,
uint256 amount
);
event DepositedToLevelMinting(uint256 amount);
event YieldManagerSetForToken(address token, address yieldManager);
/* Errors */
error InvalidlvlUSDAddress();
error InvalidZeroAddress();
error TreasuryNotSet();
error InvalidAmount();
error InvalidRecipient();
/* Functions */
function treasury() external view returns (address);
function rakeBasisPoints() external view returns (uint16);
function maxSlippageThresholdBasisPoints() external view returns (uint16);
function lvlUSD() external view returns (IlvlUSD);
function lvlUsdDecimals() external view returns (uint256);
function levelMinting() external view returns (ILevelMinting);
function allowlist(address) external view returns (bool);
function depositForYield(address token, uint256 amount) external;
function withdrawFromYieldManager(address token, uint256 amount) external;
function depositToLevelMinting(address token, uint256 amount) external;
// function rewardStakedlvlUSD(uint256 amount) external;
// function mintlvlUSD(address collateral, uint256 amount) external;
function approveSpender(
address token,
address spender,
uint256 amount
) external;
function transferERC20(
address tokenAddress,
address tokenReceiver,
uint256 tokenAmount
) external;
function transferEth(address payable _to, uint256 _amount) external;
function setPaused(bool paused) external;
function setAllowlist(address recipient, bool isAllowlisted) external;
function setStakedlvlUSDAddress(address newAddress) external;
function setYieldManager(address token, address baseYieldManager) external;
function setTreasury(address _treasury) external;
function setRakeBasisPoints(uint16 _rakeBasisPoints) external;
function setMaxSlippageThresholdBasisPoints(
uint16 _maxSlippageThresholdBasisPoints
) external;
}// SPDX-License-Identifier: GPL-3.0
pragma solidity >=0.8.19;
import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import "@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol";
import "@openzeppelin/contracts/token/ERC20/extensions/IERC20Permit.sol";
interface IlvlUSD is IERC20, IERC20Permit, IERC20Metadata {
function mint(address _to, uint256 _amount) external;
function burn(uint256 _amount) external;
function burnFrom(address account, uint256 amount) external;
function grantRole(bytes32 role, address account) external;
function setMinter(address newMinter) external;
function minter() external returns (address);
function denylisted(address user) external returns (bool);
}// SPDX-License-Identifier: BUSL-1.1
pragma solidity >=0.8.19;
import "./ILevelMintingEvents.sol";
interface ILevelMinting is ILevelMintingEvents {
enum Role {
Minter,
Redeemer
}
enum OrderType {
MINT,
REDEEM
}
enum SignatureType {
EIP712
}
struct Signature {
SignatureType signature_type;
bytes signature_bytes;
}
struct Route {
address[] addresses;
uint256[] ratios;
}
struct Order {
OrderType order_type;
address benefactor;
address beneficiary;
address collateral_asset;
uint256 collateral_amount;
uint256 lvlusd_amount;
}
struct UserCooldown {
uint104 cooldownStart;
Order order;
}
error Duplicate();
error InvalidAddress();
error InvalidlvlUSDAddress();
error InvalidZeroAddress();
error InvalidAssetAddress();
error InvalidReserveAddress();
error InvalidOrder();
error InvalidAffirmedAmount();
error InvalidAmount();
error InvalidRoute();
error InvalidRatios();
error UnsupportedAsset();
error NoAssetsProvided();
error InvalidCooldown();
error OperationNotAllowed();
error InvalidNonce();
error TransferFailed();
error MaxMintPerBlockExceeded();
error MaxRedeemPerBlockExceeded();
error MsgSenderIsNotBenefactor();
error OracleUndefined();
error OraclePriceIsZero();
error MinimumlvlUSDAmountNotMet();
error MinimumCollateralAmountNotMet();
error OraclesLengthNotEqualToAssetsLength();
// function hashOrder(Order calldata order) external view returns (bytes32);
function verifyOrder(Order calldata order) external view returns (bool);
function verifyRoute(Route calldata route, OrderType order_type) external view returns (bool);
function mint(Order calldata order, Route calldata route) external;
function mintDefault(Order calldata order) external;
function initiateRedeem(Order memory order) external;
function completeRedeem(address token) external;
function getPriceAndDecimals(address collateralToken) external view returns (int256, uint256);
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;
interface IStakedlvlUSD {
// Events //
/// @notice Event emitted when the rewards are received
event RewardsReceived(uint256 indexed amount);
/// @notice Event emitted when frozen funds are received
event FrozenFundsReceived(uint256 indexed amount);
/// @notice Event emitted when the balance from an FULL_RESTRICTED_STAKER_ROLE user are redistributed
event LockedAmountRedistributed(
address indexed from,
address indexed to,
uint256 amount
);
/// @notice Event emitted when a FREEZER_ROLE user freezes an amount of the reserve
event FrozenAmountUpdated(uint256 amount);
event FrozenAmountWithdrawn(address indexed frozenReceiver, uint256 amount);
event FrozenReceiverSet(
address indexed oldReceiver,
address indexed newReceiver
);
event FrozenReceiverSettingRenounced();
event FreezablePercentageUpdated(
uint16 oldFreezablePercentage,
uint16 newFreezablePercentage
);
// Errors //
/// @notice Error emitted shares or assets equal zero.
error InvalidAmount();
/// @notice Error emitted when owner attempts to rescue lvlUSD tokens.
error InvalidToken();
/// @notice Error emitted when slippage is exceeded on a deposit or withdrawal
error SlippageExceeded();
/// @notice Error emitted when a small non-zero share amount remains, which risks donations attack
error MinSharesViolation();
/// @notice Error emitted when owner is not allowed to perform an operation
error OperationNotAllowed();
/// @notice Error emitted when there is still unvested amount
error StillVesting();
/// @notice Error emitted when owner or denylist manager attempts to denylist owner
error CantDenylistOwner();
/// @notice Error emitted when the zero address is given
error InvalidZeroAddress();
/// @notice Error emitted when there is not enough balance
error InsufficientBalance();
/// @notice Error emitted when the caller cannot set a freezer
error SettingFrozenReceiverDisabled();
/// @notice Error emitted when trying to freeze more than max freezable
error ExceedsFreezable();
function transferInRewards(uint256 amount) external;
function rescueTokens(address token, uint256 amount, address to) external;
function getUnvestedAmount() external view returns (uint256);
}// SPDX-License-Identifier: BUSL-1.1
pragma solidity ^0.8.20;
interface ILevelBaseYieldManager {
function setWrapperForToken(address token, address wrapper) external;
function approveSpender(
address token,
address spender,
uint256 amount
) external;
function depositForYield(address token, uint256 amount) external;
function collectYield(address token) external returns (uint256);
function withdraw(address token, uint256 amount) external;
/// @notice Treasury is the zero address
error TreasuryNotSet();
/// @notice Zero address error
error ZeroAddress();
}// SPDX-License-Identifier: GPL-3.0
pragma solidity >=0.8.19;
import "@openzeppelin/contracts/access/AccessControl.sol";
import "@openzeppelin/contracts/interfaces/IERC5313.sol";
import "../../interfaces/ISingleAdminAccessControl.sol";
/**
* @title SingleAdminAccessControl
* @notice SingleAdminAccessControl is a contract that provides a single admin role with timelock
* @notice This contract is a simplified alternative to OpenZeppelin's AccessControlDefaultAdminRules
* @dev Added 3-day timelock for admin transfers
*/
abstract contract SingleAdminAccessControl is
IERC5313,
ISingleAdminAccessControl,
AccessControl
{
address private _currentDefaultAdmin;
address private _pendingDefaultAdmin;
// New variables for timelock
uint256 public constant TIMELOCK_DELAY = 3 days;
uint256 private _transferRequestTime;
error TimelockNotExpired(uint256 remainingTime);
error NoActiveTransferRequest();
error TransferAlreadyInProgress();
// Add this event to ISingleAdminAccessControl.sol
event AdminTransferCancelled(
address indexed currentAdmin,
address indexed pendingAdmin
);
modifier notAdmin(bytes32 role) {
if (role == DEFAULT_ADMIN_ROLE) revert InvalidAdminChange();
_;
}
/// @notice Transfer the admin role to a new address
/// @notice This can ONLY be executed by the current admin
/// @notice Initiates a transfer request with a 3-day timelock
/// @param newAdmin address of the new admin
function transferAdmin(
address newAdmin
) external onlyRole(DEFAULT_ADMIN_ROLE) {
if (newAdmin == msg.sender) revert InvalidAdminChange();
if (newAdmin == address(0)) revert InvalidAdminChange();
if (_transferRequestTime != 0) revert TransferAlreadyInProgress();
_pendingDefaultAdmin = newAdmin;
_transferRequestTime = block.timestamp;
emit AdminTransferRequested(_currentDefaultAdmin, newAdmin);
}
/// @notice Cancel a pending admin transfer request
/// @notice Can only be called by the current admin
function cancelTransferAdmin() external onlyRole(DEFAULT_ADMIN_ROLE) {
if (_pendingDefaultAdmin == address(0))
revert NoActiveTransferRequest();
delete _pendingDefaultAdmin;
delete _transferRequestTime;
emit AdminTransferCancelled(_currentDefaultAdmin, _pendingDefaultAdmin);
}
/// @notice Accept the admin role transfer after timelock expires
/// @notice Can only be called by the pending admin after the timelock period
function acceptAdmin() external {
if (msg.sender != _pendingDefaultAdmin) revert NotPendingAdmin();
if (_transferRequestTime == 0) revert NoActiveTransferRequest();
uint256 timeElapsed = block.timestamp - _transferRequestTime;
if (timeElapsed < TIMELOCK_DELAY) {
revert TimelockNotExpired(TIMELOCK_DELAY - timeElapsed);
}
_grantRole(DEFAULT_ADMIN_ROLE, msg.sender);
}
/// @notice Check the remaining time until a transfer can be accepted
/// @return remaining time in seconds, 0 if no active transfer or if timelock has expired
function getTransferTimelockStatus() external view returns (uint256) {
if (_pendingDefaultAdmin == address(0) || _transferRequestTime == 0) {
return 0;
}
uint256 timeElapsed = block.timestamp - _transferRequestTime;
if (timeElapsed >= TIMELOCK_DELAY) {
return 0;
}
return TIMELOCK_DELAY - timeElapsed;
}
/// @notice grant a role
/// @notice can only be executed by the current single admin
/// @notice admin role cannot be granted externally
/// @param role bytes32
/// @param account address
function grantRole(
bytes32 role,
address account
) public override onlyRole(DEFAULT_ADMIN_ROLE) notAdmin(role) {
_grantRole(role, account);
}
/// @notice revoke a role
/// @notice can only be executed by the current admin
/// @notice admin role cannot be revoked
/// @param role bytes32
/// @param account address
function revokeRole(
bytes32 role,
address account
) public override onlyRole(DEFAULT_ADMIN_ROLE) notAdmin(role) {
_revokeRole(role, account);
}
/// @notice renounce the role of msg.sender
/// @notice admin role cannot be renounced
/// @param role bytes32
/// @param account address
function renounceRole(
bytes32 role,
address account
) public virtual override notAdmin(role) {
super.renounceRole(role, account);
}
/**
* @dev See {IERC5313-owner}.
*/
function owner() public view virtual returns (address) {
return _currentDefaultAdmin;
}
/**
* @notice no way to change admin without removing old admin first
*/
function _grantRole(
bytes32 role,
address account
) internal override returns (bool) {
if (role == DEFAULT_ADMIN_ROLE) {
emit AdminTransferred(_currentDefaultAdmin, account);
_revokeRole(DEFAULT_ADMIN_ROLE, _currentDefaultAdmin);
_currentDefaultAdmin = account;
delete _pendingDefaultAdmin;
delete _transferRequestTime;
}
return super._grantRole(role, account);
}
}// SPDX-License-Identifier: BUSL-1.1
// OpenZeppelin Contracts (last updated v5.0.0) (token/ERC20/extensions/ERC20Wrapper.sol)
pragma solidity ^0.8.20;
import {IERC20, IERC20Metadata, ERC20} from "@openzeppelin/contracts/token/ERC20/ERC20.sol";
import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
import "./auth/v5/SingleAdminAccessControl.sol";
import {IERC20Errors} from "@openzeppelin/contracts/interfaces/draft-IERC6093.sol";
import "./interfaces/aave/IRewardsController.sol";
/**
* @dev Extension of the ERC-20 token contract to support token wrapping.
*
* Users can deposit and withdraw "underlying tokens" and receive a matching number of "wrapped tokens". This is useful
* in conjunction with other modules. For example, combining this wrapping mechanism with {ERC20Votes} will allow the
* wrapping of an existing "basic" ERC-20 into a governance token.
*
* WARNING: Any mechanism in which the underlying token changes the {balanceOf} of an account without an explicit transfer
* may desynchronize this contract's supply and its underlying balance. Please exercise caution when wrapping tokens that
* may undercollateralize the wrapper (i.e. wrapper's total supply is higher than its underlying balance). See {claimAllRewards}
* for recovering value accrued to the wrapper.
*/
contract WrappedRebasingERC20 is ERC20, SingleAdminAccessControl {
using SafeERC20 for IERC20;
IERC20 private immutable _underlying;
bytes32 public RECOVERER_ROLE = keccak256("RECOVERER_ROLE");
/**
* @dev The underlying token couldn't be wrapped.
*/
error ERC20InvalidUnderlying(address token);
constructor(
IERC20 underlyingToken,
string memory name,
string memory symbol
) ERC20(name, symbol) {
if (underlyingToken == this) {
revert ERC20InvalidUnderlying(address(this));
}
_underlying = underlyingToken;
_grantRole(DEFAULT_ADMIN_ROLE, msg.sender);
}
/**
* @dev See {ERC20-decimals}.
*/
function decimals() public view virtual override returns (uint8) {
try IERC20Metadata(address(_underlying)).decimals() returns (
uint8 value
) {
return value;
} catch {
return super.decimals();
}
}
/**
* @dev Returns the address of the underlying ERC-20 token that is being wrapped.
*/
function underlying() public view returns (IERC20) {
return _underlying;
}
/**
* @dev Allow a user to deposit underlying tokens and mint the corresponding number of wrapped tokens.
*/
function depositFor(
address account,
uint256 value
) public virtual returns (bool) {
address sender = _msgSender();
if (sender == address(this)) {
revert IERC20Errors.ERC20InvalidSender(address(this));
}
if (account == address(this)) {
revert IERC20Errors.ERC20InvalidReceiver(account);
}
SafeERC20.safeTransferFrom(_underlying, sender, address(this), value);
_mint(account, value);
return true;
}
/**
* @dev Allow a user to burn a number of wrapped tokens and withdraw the corresponding number of underlying tokens.
*/
function withdrawTo(
address account,
uint256 value
) public virtual returns (bool) {
if (account == address(this)) {
revert IERC20Errors.ERC20InvalidReceiver(account);
}
_burn(_msgSender(), value);
SafeERC20.safeTransfer(_underlying, account, value);
return true;
}
/**
* @dev Mint wrapped token to cover any underlyingTokens that would have been transferred by mistake or acquired from
* rebasing mechanisms. Internal function that can be exposed with access control if desired.
*/
function recoverUnderlying()
external
onlyRole(RECOVERER_ROLE)
returns (uint256)
{
address sender = _msgSender();
uint256 value = _underlying.balanceOf(address(this)) - totalSupply();
if (value > 0) {
SafeERC20.safeTransfer(_underlying, sender, value);
}
return value;
}
/**
* @dev Recover any ERC20 tokens that were accidentally sent to this contract.
* Can only be called by admin. Cannot recover the underlying token - use claimAllRewards() for that.
* @param tokenAddress The token contract address to recover
* @param tokenReceiver The address to send the tokens to
* @param tokenAmount The amount of tokens to recover
*/
function transferERC20(
address tokenAddress,
address tokenReceiver,
uint256 tokenAmount
) external onlyRole(DEFAULT_ADMIN_ROLE) {
require(
tokenAddress != address(_underlying),
"Use recover instead of transferERC20 to recover underlying."
);
require(tokenReceiver != address(0), "Invalid recipient");
IERC20(tokenAddress).safeTransfer(tokenReceiver, tokenAmount);
}
/**
* @dev Recover ETH that was accidentally sent to this contract.
* Can only be called by admin.
* @param _to The address to send the ETH to
*/
function transferEth(
address payable _to,
uint256 _amount
) external onlyRole(DEFAULT_ADMIN_ROLE) {
(bool success, ) = _to.call{value: _amount}("");
require(success, "Failed to send Ether");
}
/**
* @dev Claim Aave rewards
* @param rewardsController Aave rewards controller contract
* @param assets tokens to claim
* @param to The address to send the rewards to
*/
function claimAllRewards(
address rewardsController,
address[] calldata assets,
address to
)
external
onlyRole(DEFAULT_ADMIN_ROLE)
returns (address[] memory rewardsList, uint256[] memory claimedAmounts)
{
return
IRewardsController(rewardsController).claimAllRewards(assets, to);
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (utils/ReentrancyGuard.sol)
pragma solidity ^0.8.20;
/**
* @dev Contract module that helps prevent reentrant calls to a function.
*
* Inheriting from `ReentrancyGuard` will make the {nonReentrant} modifier
* available, which can be applied to functions to make sure there are no nested
* (reentrant) calls to them.
*
* Note that because there is a single `nonReentrant` guard, functions marked as
* `nonReentrant` may not call one another. This can be worked around by making
* those functions `private`, and then adding `external` `nonReentrant` entry
* points to them.
*
* TIP: If you would like to learn more about reentrancy and alternative ways
* to protect against it, check out our blog post
* https://blog.openzeppelin.com/reentrancy-after-istanbul/[Reentrancy After Istanbul].
*/
abstract contract ReentrancyGuard {
// Booleans are more expensive than uint256 or any type that takes up a full
// word because each write operation emits an extra SLOAD to first read the
// slot's contents, replace the bits taken up by the boolean, and then write
// back. This is the compiler's defense against contract upgrades and
// pointer aliasing, and it cannot be disabled.
// The values being non-zero value makes deployment a bit more expensive,
// but in exchange the refund on every call to nonReentrant will be lower in
// amount. Since refunds are capped to a percentage of the total
// transaction's gas, it is best to keep them low in cases like this one, to
// increase the likelihood of the full refund coming into effect.
uint256 private constant NOT_ENTERED = 1;
uint256 private constant ENTERED = 2;
uint256 private _status;
/**
* @dev Unauthorized reentrant call.
*/
error ReentrancyGuardReentrantCall();
constructor() {
_status = NOT_ENTERED;
}
/**
* @dev Prevents a contract from calling itself, directly or indirectly.
* Calling a `nonReentrant` function from another `nonReentrant`
* function is not supported. It is possible to prevent this from happening
* by making the `nonReentrant` function external, and making it call a
* `private` function that does the actual work.
*/
modifier nonReentrant() {
_nonReentrantBefore();
_;
_nonReentrantAfter();
}
function _nonReentrantBefore() private {
// On the first call to nonReentrant, _status will be NOT_ENTERED
if (_status == ENTERED) {
revert ReentrancyGuardReentrantCall();
}
// Any calls to nonReentrant after this point will fail
_status = ENTERED;
}
function _nonReentrantAfter() private {
// By storing the original value once again, a refund is triggered (see
// https://eips.ethereum.org/EIPS/eip-2200)
_status = NOT_ENTERED;
}
/**
* @dev Returns true if the reentrancy guard is currently set to "entered", which indicates there is a
* `nonReentrant` function in the call stack.
*/
function _reentrancyGuardEntered() internal view returns (bool) {
return _status == ENTERED;
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (token/ERC20/utils/SafeERC20.sol)
pragma solidity ^0.8.20;
import {IERC20} from "../IERC20.sol";
import {IERC20Permit} from "../extensions/IERC20Permit.sol";
import {Address} from "../../../utils/Address.sol";
/**
* @title SafeERC20
* @dev Wrappers around ERC20 operations that throw on failure (when the token
* contract returns false). Tokens that return no value (and instead revert or
* throw on failure) are also supported, non-reverting calls are assumed to be
* successful.
* To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract,
* which allows you to call the safe operations as `token.safeTransfer(...)`, etc.
*/
library SafeERC20 {
using Address for address;
/**
* @dev An operation with an ERC20 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.
*/
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.
*/
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.
*/
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 Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement
* on the return value: the return value is optional (but if data is returned, it must not be false).
* @param token The token targeted by the call.
* @param data The call data (encoded using abi.encode or one of its variants).
*/
function _callOptionalReturn(IERC20 token, bytes memory data) private {
// We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since
// we're implementing it ourselves. We use {Address-functionCall} to perform this call, which verifies that
// the target address contains contract code and also asserts for success in the low-level call.
bytes memory returndata = address(token).functionCall(data);
if (returndata.length != 0 && !abi.decode(returndata, (bool))) {
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 silents catches all reverts and returns a bool instead.
*/
function _callOptionalReturnBool(IERC20 token, bytes memory data) private returns (bool) {
// We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since
// we're implementing it ourselves. We cannot use {Address-functionCall} here since this should return false
// and not revert is the subcall reverts.
(bool success, bytes memory returndata) = address(token).call(data);
return success && (returndata.length == 0 || abi.decode(returndata, (bool))) && address(token).code.length > 0;
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.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 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);
}
}// 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: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (token/ERC20/ERC20.sol)
pragma solidity ^0.8.20;
import {IERC20} from "./IERC20.sol";
import {IERC20Metadata} from "./extensions/IERC20Metadata.sol";
import {Context} from "../../utils/Context.sol";
import {IERC20Errors} from "../../interfaces/draft-IERC6093.sol";
/**
* @dev Implementation of the {IERC20} interface.
*
* This implementation is agnostic to the way tokens are created. This means
* that a supply mechanism has to be added in a derived contract using {_mint}.
*
* TIP: For a detailed writeup see our guide
* https://forum.openzeppelin.com/t/how-to-implement-erc20-supply-mechanisms/226[How
* to implement supply mechanisms].
*
* The default value of {decimals} is 18. To change this, you should override
* this function so it returns a different value.
*
* We have followed general OpenZeppelin Contracts guidelines: functions revert
* instead returning `false` on failure. This behavior is nonetheless
* conventional and does not conflict with the expectations of ERC20
* applications.
*
* Additionally, an {Approval} event is emitted on calls to {transferFrom}.
* This allows applications to reconstruct the allowance for all accounts just
* by listening to said events. Other implementations of the EIP may not emit
* these events, as it isn't required by the specification.
*/
abstract contract ERC20 is Context, IERC20, IERC20Metadata, IERC20Errors {
mapping(address account => uint256) private _balances;
mapping(address account => mapping(address spender => uint256)) private _allowances;
uint256 private _totalSupply;
string private _name;
string private _symbol;
/**
* @dev Sets the values for {name} and {symbol}.
*
* All two of these values are immutable: they can only be set once during
* construction.
*/
constructor(string memory name_, string memory symbol_) {
_name = name_;
_symbol = symbol_;
}
/**
* @dev Returns the name of the token.
*/
function name() public view virtual returns (string memory) {
return _name;
}
/**
* @dev Returns the symbol of the token, usually a shorter version of the
* name.
*/
function symbol() public view virtual returns (string memory) {
return _symbol;
}
/**
* @dev Returns the number of decimals used to get its user representation.
* For example, if `decimals` equals `2`, a balance of `505` tokens should
* be displayed to a user as `5.05` (`505 / 10 ** 2`).
*
* Tokens usually opt for a value of 18, imitating the relationship between
* Ether and Wei. This is the default value returned by this function, unless
* it's overridden.
*
* NOTE: This information is only used for _display_ purposes: it in
* no way affects any of the arithmetic of the contract, including
* {IERC20-balanceOf} and {IERC20-transfer}.
*/
function decimals() public view virtual returns (uint8) {
return 18;
}
/**
* @dev See {IERC20-totalSupply}.
*/
function totalSupply() public view virtual returns (uint256) {
return _totalSupply;
}
/**
* @dev See {IERC20-balanceOf}.
*/
function balanceOf(address account) public view virtual returns (uint256) {
return _balances[account];
}
/**
* @dev See {IERC20-transfer}.
*
* Requirements:
*
* - `to` cannot be the zero address.
* - the caller must have a balance of at least `value`.
*/
function transfer(address to, uint256 value) public virtual returns (bool) {
address owner = _msgSender();
_transfer(owner, to, value);
return true;
}
/**
* @dev See {IERC20-allowance}.
*/
function allowance(address owner, address spender) public view virtual returns (uint256) {
return _allowances[owner][spender];
}
/**
* @dev See {IERC20-approve}.
*
* NOTE: If `value` is the maximum `uint256`, the allowance is not updated on
* `transferFrom`. This is semantically equivalent to an infinite approval.
*
* Requirements:
*
* - `spender` cannot be the zero address.
*/
function approve(address spender, uint256 value) public virtual returns (bool) {
address owner = _msgSender();
_approve(owner, spender, value);
return true;
}
/**
* @dev See {IERC20-transferFrom}.
*
* Emits an {Approval} event indicating the updated allowance. This is not
* required by the EIP. See the note at the beginning of {ERC20}.
*
* NOTE: Does not update the allowance if the current allowance
* is the maximum `uint256`.
*
* Requirements:
*
* - `from` and `to` cannot be the zero address.
* - `from` must have a balance of at least `value`.
* - the caller must have allowance for ``from``'s tokens of at least
* `value`.
*/
function transferFrom(address from, address to, uint256 value) public virtual returns (bool) {
address spender = _msgSender();
_spendAllowance(from, spender, value);
_transfer(from, to, value);
return true;
}
/**
* @dev Moves a `value` amount of tokens from `from` to `to`.
*
* This internal function is equivalent to {transfer}, and can be used to
* e.g. implement automatic token fees, slashing mechanisms, etc.
*
* Emits a {Transfer} event.
*
* NOTE: This function is not virtual, {_update} should be overridden instead.
*/
function _transfer(address from, address to, uint256 value) internal {
if (from == address(0)) {
revert ERC20InvalidSender(address(0));
}
if (to == address(0)) {
revert ERC20InvalidReceiver(address(0));
}
_update(from, to, value);
}
/**
* @dev Transfers a `value` amount of tokens from `from` to `to`, or alternatively mints (or burns) if `from`
* (or `to`) is the zero address. All customizations to transfers, mints, and burns should be done by overriding
* this function.
*
* Emits a {Transfer} event.
*/
function _update(address from, address to, uint256 value) internal virtual {
if (from == address(0)) {
// Overflow check required: The rest of the code assumes that totalSupply never overflows
_totalSupply += value;
} else {
uint256 fromBalance = _balances[from];
if (fromBalance < value) {
revert ERC20InsufficientBalance(from, fromBalance, value);
}
unchecked {
// Overflow not possible: value <= fromBalance <= totalSupply.
_balances[from] = fromBalance - value;
}
}
if (to == address(0)) {
unchecked {
// Overflow not possible: value <= totalSupply or value <= fromBalance <= totalSupply.
_totalSupply -= value;
}
} else {
unchecked {
// Overflow not possible: balance + value is at most totalSupply, which we know fits into a uint256.
_balances[to] += value;
}
}
emit Transfer(from, to, value);
}
/**
* @dev Creates a `value` amount of tokens and assigns them to `account`, by transferring it from address(0).
* Relies on the `_update` mechanism
*
* Emits a {Transfer} event with `from` set to the zero address.
*
* NOTE: This function is not virtual, {_update} should be overridden instead.
*/
function _mint(address account, uint256 value) internal {
if (account == address(0)) {
revert ERC20InvalidReceiver(address(0));
}
_update(address(0), account, value);
}
/**
* @dev Destroys a `value` amount of tokens from `account`, lowering the total supply.
* Relies on the `_update` mechanism.
*
* Emits a {Transfer} event with `to` set to the zero address.
*
* NOTE: This function is not virtual, {_update} should be overridden instead
*/
function _burn(address account, uint256 value) internal {
if (account == address(0)) {
revert ERC20InvalidSender(address(0));
}
_update(account, address(0), value);
}
/**
* @dev Sets `value` as the allowance of `spender` over the `owner` s tokens.
*
* This internal function is equivalent to `approve`, and can be used to
* e.g. set automatic allowances for certain subsystems, etc.
*
* Emits an {Approval} event.
*
* Requirements:
*
* - `owner` cannot be the zero address.
* - `spender` cannot be the zero address.
*
* Overrides to this logic should be done to the variant with an additional `bool emitEvent` argument.
*/
function _approve(address owner, address spender, uint256 value) internal {
_approve(owner, spender, value, true);
}
/**
* @dev Variant of {_approve} with an optional flag to enable or disable the {Approval} event.
*
* By default (when calling {_approve}) the flag is set to true. On the other hand, approval changes made by
* `_spendAllowance` during the `transferFrom` operation set the flag to false. This saves gas by not emitting any
* `Approval` event during `transferFrom` operations.
*
* Anyone who wishes to continue emitting `Approval` events on the`transferFrom` operation can force the flag to
* true using the following override:
* ```
* function _approve(address owner, address spender, uint256 value, bool) internal virtual override {
* super._approve(owner, spender, value, true);
* }
* ```
*
* Requirements are the same as {_approve}.
*/
function _approve(address owner, address spender, uint256 value, bool emitEvent) internal virtual {
if (owner == address(0)) {
revert ERC20InvalidApprover(address(0));
}
if (spender == address(0)) {
revert ERC20InvalidSpender(address(0));
}
_allowances[owner][spender] = value;
if (emitEvent) {
emit Approval(owner, spender, value);
}
}
/**
* @dev Updates `owner` s allowance for `spender` based on spent `value`.
*
* Does not update the allowance value in case of infinite allowance.
* Revert if not enough allowance is available.
*
* Does not emit an {Approval} event.
*/
function _spendAllowance(address owner, address spender, uint256 value) internal virtual {
uint256 currentAllowance = allowance(owner, spender);
if (currentAllowance != type(uint256).max) {
if (currentAllowance < value) {
revert ERC20InsufficientAllowance(spender, currentAllowance, value);
}
unchecked {
_approve(owner, spender, currentAllowance - value, false);
}
}
}
}// SPDX-License-Identifier: AGPL-3.0-only
pragma solidity >=0.8.0;
/// @notice Arithmetic library with operations for fixed-point numbers.
/// @author Solmate (https://github.com/transmissions11/solmate/blob/main/src/utils/FixedPointMathLib.sol)
/// @author Inspired by USM (https://github.com/usmfum/USM/blob/master/contracts/WadMath.sol)
library FixedPointMathLib {
/*//////////////////////////////////////////////////////////////
SIMPLIFIED FIXED POINT OPERATIONS
//////////////////////////////////////////////////////////////*/
uint256 internal constant MAX_UINT256 = 2**256 - 1;
uint256 internal constant WAD = 1e18; // The scalar of ETH and most ERC20s.
function mulWadDown(uint256 x, uint256 y) internal pure returns (uint256) {
return mulDivDown(x, y, WAD); // Equivalent to (x * y) / WAD rounded down.
}
function mulWadUp(uint256 x, uint256 y) internal pure returns (uint256) {
return mulDivUp(x, y, WAD); // Equivalent to (x * y) / WAD rounded up.
}
function divWadDown(uint256 x, uint256 y) internal pure returns (uint256) {
return mulDivDown(x, WAD, y); // Equivalent to (x * WAD) / y rounded down.
}
function divWadUp(uint256 x, uint256 y) internal pure returns (uint256) {
return mulDivUp(x, WAD, y); // Equivalent to (x * WAD) / y rounded up.
}
/*//////////////////////////////////////////////////////////////
LOW LEVEL FIXED POINT OPERATIONS
//////////////////////////////////////////////////////////////*/
function mulDivDown(
uint256 x,
uint256 y,
uint256 denominator
) internal pure returns (uint256 z) {
/// @solidity memory-safe-assembly
assembly {
// Equivalent to require(denominator != 0 && (y == 0 || x <= type(uint256).max / y))
if iszero(mul(denominator, iszero(mul(y, gt(x, div(MAX_UINT256, y)))))) {
revert(0, 0)
}
// Divide x * y by the denominator.
z := div(mul(x, y), denominator)
}
}
function mulDivUp(
uint256 x,
uint256 y,
uint256 denominator
) internal pure returns (uint256 z) {
/// @solidity memory-safe-assembly
assembly {
// Equivalent to require(denominator != 0 && (y == 0 || x <= type(uint256).max / y))
if iszero(mul(denominator, iszero(mul(y, gt(x, div(MAX_UINT256, y)))))) {
revert(0, 0)
}
// If x * y modulo the denominator is strictly greater than 0,
// 1 is added to round up the division of x * y by the denominator.
z := add(gt(mod(mul(x, y), denominator), 0), div(mul(x, y), denominator))
}
}
function rpow(
uint256 x,
uint256 n,
uint256 scalar
) internal pure returns (uint256 z) {
/// @solidity memory-safe-assembly
assembly {
switch x
case 0 {
switch n
case 0 {
// 0 ** 0 = 1
z := scalar
}
default {
// 0 ** n = 0
z := 0
}
}
default {
switch mod(n, 2)
case 0 {
// If n is even, store scalar in z for now.
z := scalar
}
default {
// If n is odd, store x in z for now.
z := x
}
// Shifting right by 1 is like dividing by 2.
let half := shr(1, scalar)
for {
// Shift n right by 1 before looping to halve it.
n := shr(1, n)
} n {
// Shift n right by 1 each iteration to halve it.
n := shr(1, n)
} {
// Revert immediately if x ** 2 would overflow.
// Equivalent to iszero(eq(div(xx, x), x)) here.
if shr(128, x) {
revert(0, 0)
}
// Store x squared.
let xx := mul(x, x)
// Round to the nearest number.
let xxRound := add(xx, half)
// Revert if xx + half overflowed.
if lt(xxRound, xx) {
revert(0, 0)
}
// Set x to scaled xxRound.
x := div(xxRound, scalar)
// If n is even:
if mod(n, 2) {
// Compute z * x.
let zx := mul(z, x)
// If z * x overflowed:
if iszero(eq(div(zx, x), z)) {
// Revert if x is non-zero.
if iszero(iszero(x)) {
revert(0, 0)
}
}
// Round to the nearest number.
let zxRound := add(zx, half)
// Revert if zx + half overflowed.
if lt(zxRound, zx) {
revert(0, 0)
}
// Return properly scaled zxRound.
z := div(zxRound, scalar)
}
}
}
}
}
/*//////////////////////////////////////////////////////////////
GENERAL NUMBER UTILITIES
//////////////////////////////////////////////////////////////*/
function sqrt(uint256 x) internal pure returns (uint256 z) {
/// @solidity memory-safe-assembly
assembly {
let y := x // We start y at x, which will help us make our initial estimate.
z := 181 // The "correct" value is 1, but this saves a multiplication later.
// This segment is to get a reasonable initial estimate for the Babylonian method. With a bad
// start, the correct # of bits increases ~linearly each iteration instead of ~quadratically.
// We check y >= 2^(k + 8) but shift right by k bits
// each branch to ensure that if x >= 256, then y >= 256.
if iszero(lt(y, 0x10000000000000000000000000000000000)) {
y := shr(128, y)
z := shl(64, z)
}
if iszero(lt(y, 0x1000000000000000000)) {
y := shr(64, y)
z := shl(32, z)
}
if iszero(lt(y, 0x10000000000)) {
y := shr(32, y)
z := shl(16, z)
}
if iszero(lt(y, 0x1000000)) {
y := shr(16, y)
z := shl(8, z)
}
// Goal was to get z*z*y within a small factor of x. More iterations could
// get y in a tighter range. Currently, we will have y in [256, 256*2^16).
// We ensured y >= 256 so that the relative difference between y and y+1 is small.
// That's not possible if x < 256 but we can just verify those cases exhaustively.
// Now, z*z*y <= x < z*z*(y+1), and y <= 2^(16+8), and either y >= 256, or x < 256.
// Correctness can be checked exhaustively for x < 256, so we assume y >= 256.
// Then z*sqrt(y) is within sqrt(257)/sqrt(256) of sqrt(x), or about 20bps.
// For s in the range [1/256, 256], the estimate f(s) = (181/1024) * (s+1) is in the range
// (1/2.84 * sqrt(s), 2.84 * sqrt(s)), with largest error when s = 1 and when s = 256 or 1/256.
// Since y is in [256, 256*2^16), let a = y/65536, so that a is in [1/256, 256). Then we can estimate
// sqrt(y) using sqrt(65536) * 181/1024 * (a + 1) = 181/4 * (y + 65536)/65536 = 181 * (y + 65536)/2^18.
// There is no overflow risk here since y < 2^136 after the first branch above.
z := shr(18, mul(z, add(y, 65536))) // A mul() is saved from starting z at 181.
// Given the worst case multiplicative error of 2.84 above, 7 iterations should be enough.
z := shr(1, add(z, div(x, z)))
z := shr(1, add(z, div(x, z)))
z := shr(1, add(z, div(x, z)))
z := shr(1, add(z, div(x, z)))
z := shr(1, add(z, div(x, z)))
z := shr(1, add(z, div(x, z)))
z := shr(1, add(z, div(x, z)))
// If x+1 is a perfect square, the Babylonian method cycles between
// floor(sqrt(x)) and ceil(sqrt(x)). This statement ensures we return floor.
// See: https://en.wikipedia.org/wiki/Integer_square_root#Using_only_integer_division
// Since the ceil is rare, we save gas on the assignment and repeat division in the rare case.
// If you don't care whether the floor or ceil square root is returned, you can remove this statement.
z := sub(z, lt(div(x, z), z))
}
}
function unsafeMod(uint256 x, uint256 y) internal pure returns (uint256 z) {
/// @solidity memory-safe-assembly
assembly {
// Mod x by y. Note this will return
// 0 instead of reverting if y is zero.
z := mod(x, y)
}
}
function unsafeDiv(uint256 x, uint256 y) internal pure returns (uint256 r) {
/// @solidity memory-safe-assembly
assembly {
// Divide x by y. Note this will return
// 0 instead of reverting if y is zero.
r := div(x, y)
}
}
function unsafeDivUp(uint256 x, uint256 y) internal pure returns (uint256 z) {
/// @solidity memory-safe-assembly
assembly {
// Add 1 to x * y if x % y > 0. Note this will
// return 0 instead of reverting if y is zero.
z := add(gt(mod(x, y), 0), div(x, y))
}
}
}// SPDX-License-Identifier: BUSL-1.1
pragma solidity 0.8.25;
interface IVaultStorage {
error InvalidTimestamp();
error NoPreviousEpoch();
/**
* @notice Get a deposit whitelist enabler/disabler's role.
* @return identifier of the whitelist enabler/disabler role
*/
function DEPOSIT_WHITELIST_SET_ROLE() external view returns (bytes32);
/**
* @notice Get a depositor whitelist status setter's role.
* @return identifier of the depositor whitelist status setter role
*/
function DEPOSITOR_WHITELIST_ROLE() external view returns (bytes32);
/**
* @notice Get a deposit limit enabler/disabler's role.
* @return identifier of the deposit limit enabler/disabler role
*/
function IS_DEPOSIT_LIMIT_SET_ROLE() external view returns (bytes32);
/**
* @notice Get a deposit limit setter's role.
* @return identifier of the deposit limit setter role
*/
function DEPOSIT_LIMIT_SET_ROLE() external view returns (bytes32);
/**
* @notice Get the delegator factory's address.
* @return address of the delegator factory
*/
function DELEGATOR_FACTORY() external view returns (address);
/**
* @notice Get the slasher factory's address.
* @return address of the slasher factory
*/
function SLASHER_FACTORY() external view returns (address);
/**
* @notice Get a vault collateral.
* @return address of the underlying collateral
*/
function collateral() external view returns (address);
/**
* @dev Get a burner to issue debt to (e.g., 0xdEaD or some unwrapper contract).
* @return address of the burner
*/
function burner() external view returns (address);
/**
* @notice Get a delegator (it delegates the vault's stake to networks and operators).
* @return address of the delegator
*/
function delegator() external view returns (address);
/**
* @notice Get a slasher (it provides networks a slashing mechanism).
* @return address of the slasher
*/
function slasher() external view returns (address);
/**
* @notice Get a time point of the epoch duration set.
* @return time point of the epoch duration set
*/
function epochDurationInit() external view returns (uint48);
/**
* @notice Get a duration of the vault epoch.
* @return duration of the epoch
*/
function epochDuration() external view returns (uint48);
/**
* @notice Get an epoch at a given timestamp.
* @param timestamp time point to get the epoch at
* @return epoch at the timestamp
* @dev Reverts if the timestamp is less than the start of the epoch 0.
*/
function epochAt(uint48 timestamp) external view returns (uint256);
/**
* @notice Get a current vault epoch.
* @return current epoch
*/
function currentEpoch() external view returns (uint256);
/**
* @notice Get a start of the current vault epoch.
* @return start of the current epoch
*/
function currentEpochStart() external view returns (uint48);
/**
* @notice Get a start of the previous vault epoch.
* @return start of the previous epoch
* @dev Reverts if the current epoch is 0.
*/
function previousEpochStart() external view returns (uint48);
/**
* @notice Get a start of the next vault epoch.
* @return start of the next epoch
*/
function nextEpochStart() external view returns (uint48);
/**
* @notice Get if the deposit whitelist is enabled.
* @return if the deposit whitelist is enabled
*/
function depositWhitelist() external view returns (bool);
/**
* @notice Get if a given account is whitelisted as a depositor.
* @param account address to check
* @return if the account is whitelisted as a depositor
*/
function isDepositorWhitelisted(
address account
) external view returns (bool);
/**
* @notice Get if the deposit limit is set.
* @return if the deposit limit is set
*/
function isDepositLimit() external view returns (bool);
/**
* @notice Get a deposit limit (maximum amount of the collateral that can be in the vault simultaneously).
* @return deposit limit
*/
function depositLimit() external view returns (uint256);
/**
* @notice Get a total number of active shares in the vault at a given timestamp using a hint.
* @param timestamp time point to get the total number of active shares at
* @param hint hint for the checkpoint index
* @return total number of active shares at the timestamp
*/
function activeSharesAt(
uint48 timestamp,
bytes memory hint
) external view returns (uint256);
/**
* @notice Get a total number of active shares in the vault.
* @return total number of active shares
*/
function activeShares() external view returns (uint256);
/**
* @notice Get a total amount of active stake in the vault at a given timestamp using a hint.
* @param timestamp time point to get the total active stake at
* @param hint hint for the checkpoint index
* @return total amount of active stake at the timestamp
*/
function activeStakeAt(
uint48 timestamp,
bytes memory hint
) external view returns (uint256);
/**
* @notice Get a total amount of active stake in the vault.
* @return total amount of active stake
*/
function activeStake() external view returns (uint256);
/**
* @notice Get a total number of active shares for a particular account at a given timestamp using a hint.
* @param account account to get the number of active shares for
* @param timestamp time point to get the number of active shares for the account at
* @param hint hint for the checkpoint index
* @return number of active shares for the account at the timestamp
*/
function activeSharesOfAt(
address account,
uint48 timestamp,
bytes memory hint
) external view returns (uint256);
/**
* @notice Get a number of active shares for a particular account.
* @param account account to get the number of active shares for
* @return number of active shares for the account
*/
function activeSharesOf(address account) external view returns (uint256);
/**
* @notice Get a total amount of the withdrawals at a given epoch.
* @param epoch epoch to get the total amount of the withdrawals at
* @return total amount of the withdrawals at the epoch
*/
function withdrawals(uint256 epoch) external view returns (uint256);
/**
* @notice Get a total number of withdrawal shares at a given epoch.
* @param epoch epoch to get the total number of withdrawal shares at
* @return total number of withdrawal shares at the epoch
*/
function withdrawalShares(uint256 epoch) external view returns (uint256);
/**
* @notice Get a number of withdrawal shares for a particular account at a given epoch (zero if claimed).
* @param epoch epoch to get the number of withdrawal shares for the account at
* @param account account to get the number of withdrawal shares for
* @return number of withdrawal shares for the account at the epoch
*/
function withdrawalSharesOf(
uint256 epoch,
address account
) external view returns (uint256);
/**
* @notice Get if the withdrawals are claimed for a particular account at a given epoch.
* @param epoch epoch to check the withdrawals for the account at
* @param account account to check the withdrawals for
* @return if the withdrawals are claimed for the account at the epoch
*/
function isWithdrawalsClaimed(
uint256 epoch,
address account
) external view returns (bool);
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (token/ERC20/IERC20.sol)
pragma solidity ^0.8.20;
/**
* @dev Interface of the ERC20 standard as defined in the EIP.
*/
interface IERC20 {
/**
* @dev Emitted when `value` tokens are moved from one account (`from`) to
* another (`to`).
*
* Note that `value` may be zero.
*/
event Transfer(address indexed from, address indexed to, uint256 value);
/**
* @dev Emitted when the allowance of a `spender` for an `owner` is set by
* a call to {approve}. `value` is the new allowance.
*/
event Approval(address indexed owner, address indexed spender, uint256 value);
/**
* @dev Returns the 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) (token/ERC20/extensions/IERC20Metadata.sol)
pragma solidity ^0.8.20;
import {IERC20} from "../IERC20.sol";
/**
* @dev Interface for the optional metadata functions from the ERC20 standard.
*/
interface IERC20Metadata is IERC20 {
/**
* @dev Returns the name of the token.
*/
function name() external view returns (string memory);
/**
* @dev Returns the symbol of the token.
*/
function symbol() external view returns (string memory);
/**
* @dev Returns the decimals places of the token.
*/
function decimals() external view returns (uint8);
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (token/ERC20/extensions/IERC20Permit.sol)
pragma solidity ^0.8.20;
/**
* @dev Interface of the ERC20 Permit extension allowing approvals to be made via signatures, as defined in
* https://eips.ethereum.org/EIPS/eip-2612[EIP-2612].
*
* Adds the {permit} method, which can be used to change an account's ERC20 allowance (see {IERC20-allowance}) by
* presenting a message signed by the account. By not relying on {IERC20-approve}, the token holder account doesn't
* need to send a transaction, and thus is not required to hold Ether at all.
*
* ==== Security Considerations
*
* There are two important considerations concerning the use of `permit`. The first is that a valid permit signature
* expresses an allowance, and it should not be assumed to convey additional meaning. In particular, it should not be
* considered as an intention to spend the allowance in any specific way. The second is that because permits have
* built-in replay protection and can be submitted by anyone, they can be frontrun. A protocol that uses permits should
* take this into consideration and allow a `permit` call to fail. Combining these two aspects, a pattern that may be
* generally recommended is:
*
* ```solidity
* function doThingWithPermit(..., uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s) public {
* try token.permit(msg.sender, address(this), value, deadline, v, r, s) {} catch {}
* doThing(..., value);
* }
*
* function doThing(..., uint256 value) public {
* token.safeTransferFrom(msg.sender, address(this), value);
* ...
* }
* ```
*
* Observe that: 1) `msg.sender` is used as the owner, leaving no ambiguity as to the signer intent, and 2) the use of
* `try/catch` allows the permit to fail and makes the code tolerant to frontrunning. (See also
* {SafeERC20-safeTransferFrom}).
*
* Additionally, note that smart contract wallets (such as Argent or Safe) are not able to produce permit signatures, so
* contracts should have entry points that don't rely on permit.
*/
interface IERC20Permit {
/**
* @dev Sets `value` as the allowance of `spender` over ``owner``'s tokens,
* given ``owner``'s signed approval.
*
* IMPORTANT: The same issues {IERC20-approve} has related to transaction
* ordering also apply here.
*
* Emits an {Approval} event.
*
* Requirements:
*
* - `spender` cannot be the zero address.
* - `deadline` must be a timestamp in the future.
* - `v`, `r` and `s` must be a valid `secp256k1` signature from `owner`
* over the EIP712-formatted function arguments.
* - the signature must use ``owner``'s current nonce (see {nonces}).
*
* For more information on the signature format, see the
* https://eips.ethereum.org/EIPS/eip-2612#specification[relevant EIP
* section].
*
* CAUTION: See Security Considerations above.
*/
function permit(
address owner,
address spender,
uint256 value,
uint256 deadline,
uint8 v,
bytes32 r,
bytes32 s
) external;
/**
* @dev Returns the current nonce for `owner`. This value must be
* included whenever a signature is generated for {permit}.
*
* Every successful call to {permit} increases ``owner``'s nonce by one. This
* prevents a signature from being used multiple times.
*/
function nonces(address owner) external view returns (uint256);
/**
* @dev Returns the domain separator used in the encoding of the signature for {permit}, as defined by {EIP712}.
*/
// solhint-disable-next-line func-name-mixedcase
function DOMAIN_SEPARATOR() external view returns (bytes32);
}// SPDX-License-Identifier: BUSL-1.1
pragma solidity >=0.8.19;
interface ILevelMintingEvents {
/// @notice Event emitted when contract receives ETH
event Received(address, uint256);
/// @notice Event emitted when lvlUSD is minted
event Mint(
address minter,
address benefactor,
address beneficiary,
address indexed collateral_asset,
uint256 indexed collateral_amount,
uint256 indexed lvlusd_amount
);
/// @notice Event emitted when funds are redeemed
event Redeem(
address redeemer,
address benefactor,
address beneficiary,
address indexed collateral_asset,
uint256 indexed collateral_amount,
uint256 indexed lvlusd_amount
);
/// @notice Event emitted when reserve wallet is added
event ReserveWalletAdded(address wallet);
/// @notice Event emitted when a reserve wallet is removed
event ReserveWalletRemoved(address wallet);
/// @notice Event emitted when a supported asset is added
event AssetAdded(address indexed asset);
/// @notice Event emitted when a supported asset is removed
event AssetRemoved(address indexed asset);
/// @notice Event emitted when a redeemable asset is removed
event RedeemableAssetRemoved(address indexed asset);
// @notice Event emitted when a reserve address is added
event ReserveAddressAdded(address indexed reserve);
// @notice Event emitted when a reserve address is removed
event ReserveAddressRemoved(address indexed reserve);
/// @notice Event emitted when assets are moved to reserve provider wallet
event ReserveTransfer(
address indexed wallet,
address indexed asset,
uint256 amount
);
/// @notice Event emitted when lvlUSD is set
event lvlUSDSet(address indexed lvlUSD);
/// @notice Event emitted when the max mint per block is changed
event MaxMintPerBlockChanged(
uint256 indexed oldMaxMintPerBlock,
uint256 indexed newMaxMintPerBlock
);
/// @notice Event emitted when the max redeem per block is changed
event MaxRedeemPerBlockChanged(
uint256 indexed oldMaxRedeemPerBlock,
uint256 indexed newMaxRedeemPerBlock
);
/// @notice Event emitted when a delegated signer is added, enabling it to sign orders on behalf of another address
event DelegatedSignerAdded(
address indexed signer,
address indexed delegator
);
/// @notice Event emitted when a delegated signer is removed
event DelegatedSignerRemoved(
address indexed signer,
address indexed delegator
);
event RedeemInitiated(
address user,
address token,
uint collateral_amount,
uint lvlusd_amount
);
event RedeemCompleted(
address user,
address token,
uint collateral_amount,
uint lvlusd_amount
);
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (access/AccessControl.sol)
pragma solidity ^0.8.20;
import {IAccessControl} from "./IAccessControl.sol";
import {Context} from "../utils/Context.sol";
import {ERC165} from "../utils/introspection/ERC165.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 AccessControl is Context, IAccessControl, ERC165 {
struct RoleData {
mapping(address account => bool) hasRole;
bytes32 adminRole;
}
mapping(bytes32 role => RoleData) private _roles;
bytes32 public constant DEFAULT_ADMIN_ROLE = 0x00;
/**
* @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);
_;
}
/**
* @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) {
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) {
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 {
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) {
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) {
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.0.0) (interfaces/IERC5313.sol)
pragma solidity ^0.8.20;
/**
* @dev Interface for the Light Contract Ownership Standard.
*
* A standardized minimal interface required to identify an account that controls a contract
*/
interface IERC5313 {
/**
* @dev Gets the address of the owner.
*/
function owner() external view returns (address);
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.19;
interface ISingleAdminAccessControl {
error InvalidAdminChange();
error NotPendingAdmin();
event AdminTransferred(address indexed oldAdmin, address indexed newAdmin);
event AdminTransferRequested(
address indexed oldAdmin,
address indexed newAdmin
);
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (interfaces/draft-IERC6093.sol)
pragma solidity ^0.8.20;
/**
* @dev Standard ERC20 Errors
* Interface of the https://eips.ethereum.org/EIPS/eip-6093[ERC-6093] custom errors for ERC20 tokens.
*/
interface IERC20Errors {
/**
* @dev Indicates an error related to the current `balance` of a `sender`. Used in transfers.
* @param sender Address whose tokens are being transferred.
* @param balance Current balance for the interacting account.
* @param needed Minimum amount required to perform a transfer.
*/
error ERC20InsufficientBalance(address sender, uint256 balance, uint256 needed);
/**
* @dev Indicates a failure with the token `sender`. Used in transfers.
* @param sender Address whose tokens are being transferred.
*/
error ERC20InvalidSender(address sender);
/**
* @dev Indicates a failure with the token `receiver`. Used in transfers.
* @param receiver Address to which tokens are being transferred.
*/
error ERC20InvalidReceiver(address receiver);
/**
* @dev Indicates a failure with the `spender`’s `allowance`. Used in transfers.
* @param spender Address that may be allowed to operate on tokens without being their owner.
* @param allowance Amount of tokens a `spender` is allowed to operate with.
* @param needed Minimum amount required to perform a transfer.
*/
error ERC20InsufficientAllowance(address spender, uint256 allowance, uint256 needed);
/**
* @dev Indicates a failure with the `approver` of a token to be approved. Used in approvals.
* @param approver Address initiating an approval operation.
*/
error ERC20InvalidApprover(address approver);
/**
* @dev Indicates a failure with the `spender` to be approved. Used in approvals.
* @param spender Address that may be allowed to operate on tokens without being their owner.
*/
error ERC20InvalidSpender(address spender);
}
/**
* @dev Standard ERC721 Errors
* Interface of the https://eips.ethereum.org/EIPS/eip-6093[ERC-6093] custom errors for ERC721 tokens.
*/
interface IERC721Errors {
/**
* @dev Indicates that an address can't be an owner. For example, `address(0)` is a forbidden owner in EIP-20.
* Used in balance queries.
* @param owner Address of the current owner of a token.
*/
error ERC721InvalidOwner(address owner);
/**
* @dev Indicates a `tokenId` whose `owner` is the zero address.
* @param tokenId Identifier number of a token.
*/
error ERC721NonexistentToken(uint256 tokenId);
/**
* @dev Indicates an error related to the ownership over a particular token. Used in transfers.
* @param sender Address whose tokens are being transferred.
* @param tokenId Identifier number of a token.
* @param owner Address of the current owner of a token.
*/
error ERC721IncorrectOwner(address sender, uint256 tokenId, address owner);
/**
* @dev Indicates a failure with the token `sender`. Used in transfers.
* @param sender Address whose tokens are being transferred.
*/
error ERC721InvalidSender(address sender);
/**
* @dev Indicates a failure with the token `receiver`. Used in transfers.
* @param receiver Address to which tokens are being transferred.
*/
error ERC721InvalidReceiver(address receiver);
/**
* @dev Indicates a failure with the `operator`’s approval. Used in transfers.
* @param operator Address that may be allowed to operate on tokens without being their owner.
* @param tokenId Identifier number of a token.
*/
error ERC721InsufficientApproval(address operator, uint256 tokenId);
/**
* @dev Indicates a failure with the `approver` of a token to be approved. Used in approvals.
* @param approver Address initiating an approval operation.
*/
error ERC721InvalidApprover(address approver);
/**
* @dev Indicates a failure with the `operator` to be approved. Used in approvals.
* @param operator Address that may be allowed to operate on tokens without being their owner.
*/
error ERC721InvalidOperator(address operator);
}
/**
* @dev Standard ERC1155 Errors
* Interface of the https://eips.ethereum.org/EIPS/eip-6093[ERC-6093] custom errors for ERC1155 tokens.
*/
interface IERC1155Errors {
/**
* @dev Indicates an error related to the current `balance` of a `sender`. Used in transfers.
* @param sender Address whose tokens are being transferred.
* @param balance Current balance for the interacting account.
* @param needed Minimum amount required to perform a transfer.
* @param tokenId Identifier number of a token.
*/
error ERC1155InsufficientBalance(address sender, uint256 balance, uint256 needed, uint256 tokenId);
/**
* @dev Indicates a failure with the token `sender`. Used in transfers.
* @param sender Address whose tokens are being transferred.
*/
error ERC1155InvalidSender(address sender);
/**
* @dev Indicates a failure with the token `receiver`. Used in transfers.
* @param receiver Address to which tokens are being transferred.
*/
error ERC1155InvalidReceiver(address receiver);
/**
* @dev Indicates a failure with the `operator`’s approval. Used in transfers.
* @param operator Address that may be allowed to operate on tokens without being their owner.
* @param owner Address of the current owner of a token.
*/
error ERC1155MissingApprovalForAll(address operator, address owner);
/**
* @dev Indicates a failure with the `approver` of a token to be approved. Used in approvals.
* @param approver Address initiating an approval operation.
*/
error ERC1155InvalidApprover(address approver);
/**
* @dev Indicates a failure with the `operator` to be approved. Used in approvals.
* @param operator Address that may be allowed to operate on tokens without being their owner.
*/
error ERC1155InvalidOperator(address operator);
/**
* @dev Indicates an array length mismatch between ids and values in a safeBatchTransferFrom operation.
* Used in batch transfers.
* @param idsLength Length of the array of token identifiers
* @param valuesLength Length of the array of token amounts
*/
error ERC1155InvalidArrayLength(uint256 idsLength, uint256 valuesLength);
}// SPDX-License-Identifier: AGPL-3.0
pragma solidity ^0.8.10;
import {IRewardsDistributor} from "./IRewardsDistributor.sol";
import {ITransferStrategyBase} from "./ITransferStrategyBase.sol";
import {IEACAggregatorProxy} from "./IEACAggregatorProxy.sol";
import {RewardsDataTypes} from "./RewardsDataTypes.sol";
/**
* @title IRewardsController
* @author Aave
* @notice Defines the basic interface for a Rewards Controller.
*/
interface IRewardsController is IRewardsDistributor {
/**
* @dev Emitted when a new address is whitelisted as claimer of rewards on behalf of a user
* @param user The address of the user
* @param claimer The address of the claimer
*/
event ClaimerSet(address indexed user, address indexed claimer);
/**
* @dev Emitted when rewards are claimed
* @param user The address of the user rewards has been claimed on behalf of
* @param reward The address of the token reward is claimed
* @param to The address of the receiver of the rewards
* @param claimer The address of the claimer
* @param amount The amount of rewards claimed
*/
event RewardsClaimed(
address indexed user,
address indexed reward,
address indexed to,
address claimer,
uint256 amount
);
/**
* @dev Emitted when a transfer strategy is installed for the reward distribution
* @param reward The address of the token reward
* @param transferStrategy The address of TransferStrategy contract
*/
event TransferStrategyInstalled(
address indexed reward,
address indexed transferStrategy
);
/**
* @dev Emitted when the reward oracle is updated
* @param reward The address of the token reward
* @param rewardOracle The address of oracle
*/
event RewardOracleUpdated(
address indexed reward,
address indexed rewardOracle
);
/**
* @dev Whitelists an address to claim the rewards on behalf of another address
* @param user The address of the user
* @param claimer The address of the claimer
*/
function setClaimer(address user, address claimer) external;
/**
* @dev Sets a TransferStrategy logic contract that determines the logic of the rewards transfer
* @param reward The address of the reward token
* @param transferStrategy The address of the TransferStrategy logic contract
*/
function setTransferStrategy(
address reward,
ITransferStrategyBase transferStrategy
) external;
/**
* @dev Sets an Aave Oracle contract to enforce rewards with a source of value.
* @notice At the moment of reward configuration, the Incentives Controller performs
* a check to see if the reward asset oracle is compatible with IEACAggregator proxy.
* This check is enforced for integrators to be able to show incentives at
* the current Aave UI without the need to setup an external price registry
* @param reward The address of the reward to set the price aggregator
* @param rewardOracle The address of price aggregator that follows IEACAggregatorProxy interface
*/
function setRewardOracle(
address reward,
IEACAggregatorProxy rewardOracle
) external;
/**
* @dev Get the price aggregator oracle address
* @param reward The address of the reward
* @return The price oracle of the reward
*/
function getRewardOracle(address reward) external view returns (address);
/**
* @dev Returns the whitelisted claimer for a certain address (0x0 if not set)
* @param user The address of the user
* @return The claimer address
*/
function getClaimer(address user) external view returns (address);
/**
* @dev Returns the Transfer Strategy implementation contract address being used for a reward address
* @param reward The address of the reward
* @return The address of the TransferStrategy contract
*/
function getTransferStrategy(
address reward
) external view returns (address);
/**
* @dev Configure assets to incentivize with an emission of rewards per second until the end of distribution.
* @param config The assets configuration input, the list of structs contains the following fields:
* uint104 emissionPerSecond: The emission per second following rewards unit decimals.
* uint256 totalSupply: The total supply of the asset to incentivize
* uint40 distributionEnd: The end of the distribution of the incentives for an asset
* address asset: The asset address to incentivize
* address reward: The reward token address
* ITransferStrategy transferStrategy: The TransferStrategy address with the install hook and claim logic.
* IEACAggregatorProxy rewardOracle: The Price Oracle of a reward to visualize the incentives at the UI Frontend.
* Must follow Chainlink Aggregator IEACAggregatorProxy interface to be compatible.
*/
function configureAssets(
RewardsDataTypes.RewardsConfigInput[] memory config
) external;
/**
* @dev Called by the corresponding asset on transfer hook in order to update the rewards distribution.
* @dev The units of `totalSupply` and `userBalance` should be the same.
* @param user The address of the user whose asset balance has changed
* @param totalSupply The total supply of the asset prior to user balance change
* @param userBalance The previous user balance prior to balance change
**/
function handleAction(
address user,
uint256 totalSupply,
uint256 userBalance
) external;
/**
* @dev Claims reward for a user to the desired address, on all the assets of the pool, accumulating the pending rewards
* @param assets List of assets to check eligible distributions before claiming rewards
* @param amount The amount of rewards to claim
* @param to The address that will be receiving the rewards
* @param reward The address of the reward token
* @return The amount of rewards claimed
**/
function claimRewards(
address[] calldata assets,
uint256 amount,
address to,
address reward
) external returns (uint256);
/**
* @dev Claims reward for a user on behalf, on all the assets of the pool, accumulating the pending rewards. The
* caller must be whitelisted via "allowClaimOnBehalf" function by the RewardsAdmin role manager
* @param assets The list of assets to check eligible distributions before claiming rewards
* @param amount The amount of rewards to claim
* @param user The address to check and claim rewards
* @param to The address that will be receiving the rewards
* @param reward The address of the reward token
* @return The amount of rewards claimed
**/
function claimRewardsOnBehalf(
address[] calldata assets,
uint256 amount,
address user,
address to,
address reward
) external returns (uint256);
/**
* @dev Claims reward for msg.sender, on all the assets of the pool, accumulating the pending rewards
* @param assets The list of assets to check eligible distributions before claiming rewards
* @param amount The amount of rewards to claim
* @param reward The address of the reward token
* @return The amount of rewards claimed
**/
function claimRewardsToSelf(
address[] calldata assets,
uint256 amount,
address reward
) external returns (uint256);
/**
* @dev Claims all rewards for a user to the desired address, on all the assets of the pool, accumulating the pending rewards
* @param assets The list of assets to check eligible distributions before claiming rewards
* @param to The address that will be receiving the rewards
* @return rewardsList List of addresses of the reward tokens
* @return claimedAmounts List that contains the claimed amount per reward, following same order as "rewardList"
**/
function claimAllRewards(
address[] calldata assets,
address to
)
external
returns (address[] memory rewardsList, uint256[] memory claimedAmounts);
/**
* @dev Claims all rewards for a user on behalf, on all the assets of the pool, accumulating the pending rewards. The caller must
* be whitelisted via "allowClaimOnBehalf" function by the RewardsAdmin role manager
* @param assets The list of assets to check eligible distributions before claiming rewards
* @param user The address to check and claim rewards
* @param to The address that will be receiving the rewards
* @return rewardsList List of addresses of the reward tokens
* @return claimedAmounts List that contains the claimed amount per reward, following same order as "rewardsList"
**/
function claimAllRewardsOnBehalf(
address[] calldata assets,
address user,
address to
)
external
returns (address[] memory rewardsList, uint256[] memory claimedAmounts);
/**
* @dev Claims all reward for msg.sender, on all the assets of the pool, accumulating the pending rewards
* @param assets The list of assets to check eligible distributions before claiming rewards
* @return rewardsList List of addresses of the reward tokens
* @return claimedAmounts List that contains the claimed amount per reward, following same order as "rewardsList"
**/
function claimAllRewardsToSelf(
address[] calldata assets
)
external
returns (address[] memory rewardsList, uint256[] memory claimedAmounts);
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (utils/Address.sol)
pragma solidity ^0.8.20;
/**
* @dev Collection of functions related to the address type
*/
library Address {
/**
* @dev The ETH balance of the account is not enough to perform the operation.
*/
error AddressInsufficientBalance(address account);
/**
* @dev There's no code at `target` (it is not a contract).
*/
error AddressEmptyCode(address target);
/**
* @dev A call to an address target failed. The target may have reverted.
*/
error FailedInnerCall();
/**
* @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 AddressInsufficientBalance(address(this));
}
(bool success, ) = recipient.call{value: amount}("");
if (!success) {
revert FailedInnerCall();
}
}
/**
* @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
* {FailedInnerCall} 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 AddressInsufficientBalance(address(this));
}
(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 {FailedInnerCall}) 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 {FailedInnerCall} 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 {FailedInnerCall}.
*/
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
/// @solidity memory-safe-assembly
assembly {
let returndata_size := mload(returndata)
revert(add(32, returndata), returndata_size)
}
} else {
revert FailedInnerCall();
}
}
}// 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: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (access/IAccessControl.sol)
pragma solidity ^0.8.20;
/**
* @dev External interface of AccessControl declared to support ERC165 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, an admin role
* bearer except when using {AccessControl-_setupRole}.
*/
event RoleGranted(bytes32 indexed role, address indexed account, address indexed sender);
/**
* @dev Emitted when `account` is revoked `role`.
*
* `sender` is the account that originated the contract call:
* - if using `revokeRole`, it is the admin role bearer
* - if using `renounceRole`, it is the role bearer (i.e. `account`)
*/
event RoleRevoked(bytes32 indexed role, address indexed account, address indexed sender);
/**
* @dev Returns `true` if `account` has been granted `role`.
*/
function hasRole(bytes32 role, address account) external view returns (bool);
/**
* @dev Returns the admin role that controls `role`. See {grantRole} and
* {revokeRole}.
*
* To change a role's admin, use {AccessControl-_setRoleAdmin}.
*/
function getRoleAdmin(bytes32 role) external view returns (bytes32);
/**
* @dev Grants `role` to `account`.
*
* If `account` had not been already granted `role`, emits a {RoleGranted}
* event.
*
* Requirements:
*
* - the caller must have ``role``'s admin role.
*/
function grantRole(bytes32 role, address account) external;
/**
* @dev Revokes `role` from `account`.
*
* If `account` had been granted `role`, emits a {RoleRevoked} event.
*
* Requirements:
*
* - the caller must have ``role``'s admin role.
*/
function revokeRole(bytes32 role, address account) external;
/**
* @dev Revokes `role` from the calling account.
*
* Roles are often managed via {grantRole} and {revokeRole}: this function's
* purpose is to provide a mechanism for accounts to lose their privileges
* if they are compromised (such as when a trusted device is misplaced).
*
* If the calling account had been granted `role`, emits a {RoleRevoked}
* event.
*
* Requirements:
*
* - the caller must be `callerConfirmation`.
*/
function renounceRole(bytes32 role, address callerConfirmation) external;
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (utils/introspection/ERC165.sol)
pragma solidity ^0.8.20;
import {IERC165} from "./IERC165.sol";
/**
* @dev Implementation of the {IERC165} interface.
*
* Contracts that want to implement ERC165 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 ERC165 is IERC165 {
/**
* @dev See {IERC165-supportsInterface}.
*/
function supportsInterface(bytes4 interfaceId) public view virtual returns (bool) {
return interfaceId == type(IERC165).interfaceId;
}
}// SPDX-License-Identifier: AGPL-3.0
pragma solidity ^0.8.10;
/**
* @title IRewardsDistributor
* @author Aave
* @notice Defines the basic interface for a Rewards Distributor.
*/
interface IRewardsDistributor {
/**
* @dev Emitted when the configuration of the rewards of an asset is updated.
* @param asset The address of the incentivized asset
* @param reward The address of the reward token
* @param oldEmission The old emissions per second value of the reward distribution
* @param newEmission The new emissions per second value of the reward distribution
* @param oldDistributionEnd The old end timestamp of the reward distribution
* @param newDistributionEnd The new end timestamp of the reward distribution
* @param assetIndex The index of the asset distribution
*/
event AssetConfigUpdated(
address indexed asset,
address indexed reward,
uint256 oldEmission,
uint256 newEmission,
uint256 oldDistributionEnd,
uint256 newDistributionEnd,
uint256 assetIndex
);
/**
* @dev Emitted when rewards of an asset are accrued on behalf of a user.
* @param asset The address of the incentivized asset
* @param reward The address of the reward token
* @param user The address of the user that rewards are accrued on behalf of
* @param assetIndex The index of the asset distribution
* @param userIndex The index of the asset distribution on behalf of the user
* @param rewardsAccrued The amount of rewards accrued
*/
event Accrued(
address indexed asset,
address indexed reward,
address indexed user,
uint256 assetIndex,
uint256 userIndex,
uint256 rewardsAccrued
);
/**
* @dev Sets the end date for the distribution
* @param asset The asset to incentivize
* @param reward The reward token that incentives the asset
* @param newDistributionEnd The end date of the incentivization, in unix time format
**/
function setDistributionEnd(
address asset,
address reward,
uint32 newDistributionEnd
) external;
/**
* @dev Sets the emission per second of a set of reward distributions
* @param asset The asset is being incentivized
* @param rewards List of reward addresses are being distributed
* @param newEmissionsPerSecond List of new reward emissions per second
*/
function setEmissionPerSecond(
address asset,
address[] calldata rewards,
uint88[] calldata newEmissionsPerSecond
) external;
/**
* @dev Gets the end date for the distribution
* @param asset The incentivized asset
* @param reward The reward token of the incentivized asset
* @return The timestamp with the end of the distribution, in unix time format
**/
function getDistributionEnd(
address asset,
address reward
) external view returns (uint256);
/**
* @dev Returns the index of a user on a reward distribution
* @param user Address of the user
* @param asset The incentivized asset
* @param reward The reward token of the incentivized asset
* @return The current user asset index, not including new distributions
**/
function getUserAssetIndex(
address user,
address asset,
address reward
) external view returns (uint256);
/**
* @dev Returns the configuration of the distribution reward for a certain asset
* @param asset The incentivized asset
* @param reward The reward token of the incentivized asset
* @return The index of the asset distribution
* @return The emission per second of the reward distribution
* @return The timestamp of the last update of the index
* @return The timestamp of the distribution end
**/
function getRewardsData(
address asset,
address reward
) external view returns (uint256, uint256, uint256, uint256);
/**
* @dev Calculates the next value of an specific distribution index, with validations.
* @param asset The incentivized asset
* @param reward The reward token of the incentivized asset
* @return The old index of the asset distribution
* @return The new index of the asset distribution
**/
function getAssetIndex(
address asset,
address reward
) external view returns (uint256, uint256);
/**
* @dev Returns the list of available reward token addresses of an incentivized asset
* @param asset The incentivized asset
* @return List of rewards addresses of the input asset
**/
function getRewardsByAsset(
address asset
) external view returns (address[] memory);
/**
* @dev Returns the list of available reward addresses
* @return List of rewards supported in this contract
**/
function getRewardsList() external view returns (address[] memory);
/**
* @dev Returns the accrued rewards balance of a user, not including virtually accrued rewards since last distribution.
* @param user The address of the user
* @param reward The address of the reward token
* @return Unclaimed rewards, not including new distributions
**/
function getUserAccruedRewards(
address user,
address reward
) external view returns (uint256);
/**
* @dev Returns a single rewards balance of a user, including virtually accrued and unrealized claimable rewards.
* @param assets List of incentivized assets to check eligible distributions
* @param user The address of the user
* @param reward The address of the reward token
* @return The rewards amount
**/
function getUserRewards(
address[] calldata assets,
address user,
address reward
) external view returns (uint256);
/**
* @dev Returns a list all rewards of a user, including already accrued and unrealized claimable rewards
* @param assets List of incentivized assets to check eligible distributions
* @param user The address of the user
* @return The list of reward addresses
* @return The list of unclaimed amount of rewards
**/
function getAllUserRewards(
address[] calldata assets,
address user
) external view returns (address[] memory, uint256[] memory);
/**
* @dev Returns the decimals of an asset to calculate the distribution delta
* @param asset The address to retrieve decimals
* @return The decimals of an underlying asset
*/
function getAssetDecimals(address asset) external view returns (uint8);
/**
* @dev Returns the address of the emission manager
* @return The address of the EmissionManager
*/
function EMISSION_MANAGER() external view returns (address);
/**
* @dev Returns the address of the emission manager.
* Deprecated: This getter is maintained for compatibility purposes. Use the `EMISSION_MANAGER()` function instead.
* @return The address of the EmissionManager
*/
function getEmissionManager() external view returns (address);
}// SPDX-License-Identifier: AGPL-3.0
pragma solidity ^0.8.10;
interface ITransferStrategyBase {
event EmergencyWithdrawal(
address indexed caller,
address indexed token,
address indexed to,
uint256 amount
);
/**
* @dev Perform custom transfer logic via delegate call from source contract to a TransferStrategy implementation
* @param to Account to transfer rewards
* @param reward Address of the reward token
* @param amount Amount to transfer to the "to" address parameter
* @return Returns true bool if transfer logic succeeds
*/
function performTransfer(
address to,
address reward,
uint256 amount
) external returns (bool);
/**
* @return Returns the address of the Incentives Controller
*/
function getIncentivesController() external view returns (address);
/**
* @return Returns the address of the Rewards admin
*/
function getRewardsAdmin() external view returns (address);
/**
* @dev Perform an emergency token withdrawal only callable by the Rewards admin
* @param token Address of the token to withdraw funds from this contract
* @param to Address of the recipient of the withdrawal
* @param amount Amount of the withdrawal
*/
function emergencyWithdrawal(
address token,
address to,
uint256 amount
) external;
}// SPDX-License-Identifier: AGPL-3.0
pragma solidity ^0.8.10;
interface IEACAggregatorProxy {
function decimals() external view returns (uint8);
function latestAnswer() external view returns (int256);
function latestTimestamp() external view returns (uint256);
function latestRound() external view returns (uint256);
function getAnswer(uint256 roundId) external view returns (int256);
function getTimestamp(uint256 roundId) external view returns (uint256);
event AnswerUpdated(
int256 indexed current,
uint256 indexed roundId,
uint256 timestamp
);
event NewRound(uint256 indexed roundId, address indexed startedBy);
}// SPDX-License-Identifier: AGPL-3.0
pragma solidity ^0.8.10;
import {ITransferStrategyBase} from "./ITransferStrategyBase.sol";
import {IEACAggregatorProxy} from "./IEACAggregatorProxy.sol";
library RewardsDataTypes {
struct RewardsConfigInput {
uint88 emissionPerSecond;
uint256 totalSupply;
uint32 distributionEnd;
address asset;
address reward;
ITransferStrategyBase transferStrategy;
IEACAggregatorProxy rewardOracle;
}
struct UserAssetBalance {
address asset;
uint256 userBalance;
uint256 totalSupply;
}
struct UserData {
// Liquidity index of the reward distribution for the user
uint104 index;
// Amount of accrued rewards for the user since last user index update
uint128 accrued;
}
struct RewardData {
// Liquidity index of the reward distribution
uint104 index;
// Amount of reward tokens distributed per second
uint88 emissionPerSecond;
// Timestamp of the last reward index update
uint32 lastUpdateTimestamp;
// The end of the distribution of rewards (in seconds)
uint32 distributionEnd;
// Map of user addresses and their rewards data (userAddress => userData)
mapping(address => UserData) usersData;
}
struct AssetData {
// Map of reward token addresses and their data (rewardTokenAddress => rewardData)
mapping(address => RewardData) rewards;
// List of reward token addresses for the asset
mapping(uint128 => address) availableRewards;
// Count of reward tokens for the asset
uint128 availableRewardsCount;
// Number of decimals of the asset
uint8 decimals;
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (utils/introspection/IERC165.sol)
pragma solidity ^0.8.20;
/**
* @dev Interface of the ERC165 standard, as defined in the
* https://eips.ethereum.org/EIPS/eip-165[EIP].
*
* 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[EIP 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);
}{
"remappings": [
"ds-test/=lib/ds-test/src/",
"forge-std/=lib/forge-std/src/",
"@openzeppelin/contracts/=lib/openzeppelin-contracts/contracts/",
"@openzeppelin-4.9.0/contracts/=lib/openzeppelin-contracts-4.9.0/contracts/",
"@openzeppelin-upgradeable/=lib/openzeppelin-contracts-upgradeable/contracts/",
"@solmate/=lib/solmate/",
"@openzeppelin-upgrades/=lib/openzeppelin-foundry-upgrades/",
"@openzeppelin/contracts-upgradeable/=lib/openzeppelin-contracts-upgradeable/contracts/",
"aave-v3-core/=lib/aave-v3-core/",
"erc4626-tests/=lib/openzeppelin-contracts-upgradeable/lib/erc4626-tests/",
"halmos-cheatcodes/=lib/openzeppelin-contracts-upgradeable/lib/halmos-cheatcodes/src/",
"openzeppelin-contracts-4.9.0/=lib/openzeppelin-contracts-4.9.0/",
"openzeppelin-contracts-upgradeable/=lib/openzeppelin-contracts-upgradeable/",
"openzeppelin-contracts/=lib/openzeppelin-contracts/",
"openzeppelin-foundry-upgrades/=lib/openzeppelin-foundry-upgrades/src/",
"openzeppelin/=lib/openzeppelin-contracts-4.9.0/contracts/",
"solidity-stringutils/=lib/openzeppelin-foundry-upgrades/lib/solidity-stringutils/",
"solmate/=lib/solmate/src/"
],
"optimizer": {
"enabled": true,
"runs": 200
},
"metadata": {
"useLiteralContent": false,
"bytecodeHash": "ipfs",
"appendCBOR": true
},
"outputSelection": {
"*": {
"*": [
"evm.bytecode",
"evm.deployedBytecode",
"devdoc",
"userdoc",
"metadata",
"abi"
]
}
},
"evmVersion": "cancun",
"viaIR": false,
"libraries": {}
}Contract Security Audit
- No Contract Security Audit Submitted- Submit Audit Here
Contract ABI
API[{"inputs":[{"internalType":"contract IlvlUSD","name":"_lvlusd","type":"address"},{"internalType":"contract IStakedlvlUSD","name":"_stakedlvlUSD","type":"address"},{"internalType":"address","name":"_admin","type":"address"},{"internalType":"address","name":"_allowlister","type":"address"}],"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":[{"internalType":"address","name":"target","type":"address"}],"name":"AddressEmptyCode","type":"error"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"AddressInsufficientBalance","type":"error"},{"inputs":[],"name":"EnforcedPause","type":"error"},{"inputs":[],"name":"ExpectedPause","type":"error"},{"inputs":[],"name":"FailedInnerCall","type":"error"},{"inputs":[],"name":"InvalidAdminChange","type":"error"},{"inputs":[],"name":"InvalidAmount","type":"error"},{"inputs":[],"name":"InvalidRecipient","type":"error"},{"inputs":[],"name":"InvalidZeroAddress","type":"error"},{"inputs":[],"name":"InvalidlvlUSDAddress","type":"error"},{"inputs":[],"name":"NoActiveTransferRequest","type":"error"},{"inputs":[],"name":"NotPendingAdmin","type":"error"},{"inputs":[{"internalType":"address","name":"token","type":"address"}],"name":"SafeERC20FailedOperation","type":"error"},{"inputs":[{"internalType":"uint256","name":"remainingTime","type":"uint256"}],"name":"TimelockNotExpired","type":"error"},{"inputs":[],"name":"TransferAlreadyInProgress","type":"error"},{"inputs":[],"name":"TreasuryNotSet","type":"error"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"currentAdmin","type":"address"},{"indexed":true,"internalType":"address","name":"pendingAdmin","type":"address"}],"name":"AdminTransferCancelled","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"oldAdmin","type":"address"},{"indexed":true,"internalType":"address","name":"newAdmin","type":"address"}],"name":"AdminTransferRequested","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"oldAdmin","type":"address"},{"indexed":true,"internalType":"address","name":"newAdmin","type":"address"}],"name":"AdminTransferred","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"epoch","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"},{"indexed":false,"internalType":"address","name":"symbioticVault","type":"address"}],"name":"ClaimedFromSymbiotic","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"DepositedToLevelMinting","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"},{"indexed":false,"internalType":"address","name":"symbioticVault","type":"address"}],"name":"DepositedToSymbiotic","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"token","type":"address"},{"indexed":false,"internalType":"address","name":"yieldManager","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"DepositedToYieldManager","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"sender","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"EtherReceived","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"sender","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"},{"indexed":false,"internalType":"bytes","name":"data","type":"bytes"}],"name":"FallbackCalled","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"account","type":"address"}],"name":"Paused","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"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"account","type":"address"}],"name":"Unpaused","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"},{"indexed":false,"internalType":"address","name":"symbioticVault","type":"address"}],"name":"WithdrawnFromSymbiotic","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"token","type":"address"},{"indexed":false,"internalType":"address","name":"yieldManager","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"WithdrawnFromYieldManager","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"token","type":"address"},{"indexed":false,"internalType":"address","name":"yieldManager","type":"address"}],"name":"YieldManagerSetForToken","type":"event"},{"stateMutability":"payable","type":"fallback"},{"inputs":[],"name":"DEFAULT_ADMIN_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"MAX_RAKE_BASIS_POINTS","outputs":[{"internalType":"uint16","name":"","type":"uint16"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"TIMELOCK_DELAY","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"acceptAdmin","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"allowlist","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"token","type":"address"},{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"approveSpender","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"cancelTransferAdmin","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"vault","type":"address"},{"internalType":"uint256","name":"epoch","type":"uint256"}],"name":"claimFromSymbiotic","outputs":[{"internalType":"uint256","name":"amount","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"token","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"depositForYield","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"token","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"depositToLevelMinting","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"vault","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"depositToSymbiotic","outputs":[{"internalType":"uint256","name":"depositedAmount","type":"uint256"},{"internalType":"uint256","name":"mintedShares","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"}],"name":"getRoleAdmin","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getTransferTimelockStatus","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","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":[],"name":"levelMinting","outputs":[{"internalType":"contract ILevelMinting","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"lvlUSD","outputs":[{"internalType":"contract IlvlUSD","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"lvlUsdDecimals","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"maxSlippageThresholdBasisPoints","outputs":[{"internalType":"uint16","name":"","type":"uint16"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"paused","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"rakeBasisPoints","outputs":[{"internalType":"uint16","name":"","type":"uint16"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"renounceRole","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":"token","type":"address"}],"name":"rewardStakedlvlUSD","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"recipient","type":"address"},{"internalType":"bool","name":"isAllowlisted","type":"bool"}],"name":"setAllowlist","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint16","name":"_maxSlippageThresholdBasisPoints","type":"uint16"}],"name":"setMaxSlippageThresholdBasisPoints","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bool","name":"paused","type":"bool"}],"name":"setPaused","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint16","name":"_rakeBasisPoints","type":"uint16"}],"name":"setRakeBasisPoints","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newAddress","type":"address"}],"name":"setStakedlvlUSDAddress","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_treasury","type":"address"}],"name":"setTreasury","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"token","type":"address"},{"internalType":"address","name":"baseYieldManager","type":"address"}],"name":"setYieldManager","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":[{"internalType":"address","name":"newAdmin","type":"address"}],"name":"transferAdmin","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"tokenAddress","type":"address"},{"internalType":"address","name":"tokenReceiver","type":"address"},{"internalType":"uint256","name":"tokenAmount","type":"uint256"}],"name":"transferERC20","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address payable","name":"_to","type":"address"},{"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"transferEth","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"treasury","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"vault","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"withdrawFromSymbiotic","outputs":[{"internalType":"uint256","name":"burnedShares","type":"uint256"},{"internalType":"uint256","name":"mintedShares","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"token","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"withdrawFromYieldManager","outputs":[],"stateMutability":"nonpayable","type":"function"},{"stateMutability":"payable","type":"receive"}]Contract Creation Code
60e060405234801561000f575f80fd5b506040516129b53803806129b583398101604081905261002e916103dd565b6004805460ff19169055838383836001600160a01b038416610063576040516319936d2560e01b815260040160405180910390fd5b6001600160a01b03821661008a5760405163f6b2911f60e01b815260040160405180910390fd5b6001600160a01b03841660808190526040805163313ce56760e01b8152905163313ce567916004808201926020929091908290030181865afa1580156100d2573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906100f69190610439565b60ff1660a08181525050836001600160a01b031663075461726040518163ffffffff1660e01b81526004016020604051808303815f875af115801561013d573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906101619190610460565b6001600160a01b0390811660c052600680546001600160a01b0319169185169190911790556004805461ffff60b81b1916600560b81b1790556101a45f83610208565b506101cf7f26a560d834a19637eccba4611bbc09fb32970bb627da0a70f14f83fdc9822cbc82610208565b506101fa7f65d7a28e3265b37a6474929f336521b332c1681b933f6cb9f3376673440d862a83610208565b50505050505050505061047b565b5f8261028b576001546040516001600160a01b038085169216907ff8ccb027dfcd135e000e9d45e6cc2d662578a8825d4c45b5e32e0adf67e79ec6905f90a360015461025e905f906001600160a01b031661029e565b50600180546001600160a01b0384166001600160a01b0319918216179091556002805490911690555f6003555b6102958383610326565b90505b92915050565b5f828152602081815260408083206001600160a01b038516845290915281205460ff161561031f575f838152602081815260408083206001600160a01b0386168085529252808320805460ff1916905551339286917ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b9190a4506001610298565b505f610298565b5f828152602081815260408083206001600160a01b038516845290915281205460ff1661031f575f838152602081815260408083206001600160a01b03861684529091529020805460ff1916600117905561037e3390565b6001600160a01b0316826001600160a01b0316847f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a4506001610298565b6001600160a01b03811681146103da575f80fd5b50565b5f805f80608085870312156103f0575f80fd5b84516103fb816103c6565b602086015190945061040c816103c6565b604086015190935061041d816103c6565b606086015190925061042e816103c6565b939692955090935050565b5f60208284031215610449575f80fd5b815160ff81168114610459575f80fd5b9392505050565b5f60208284031215610470575f80fd5b8151610459816103c6565b60805160a05160c0516124d16104e45f395f81816106970152818161151b015281816119c50152611b8701525f818161052101528181611a5301528181611a7f0152611ac401525f8181610590015281816112a4015281816113380152611c1e01526124d15ff3fe608060405260043610610233575f3560e01c806391d148541161012d578063b12527f8116100aa578063de1da1791161006e578063de1da17914610749578063e9bb84c214610768578063ee47481214610787578063ef756632146107a6578063f0f44260146107c557610270565b8063b12527f8146106b9578063b55dd256146106d8578063bf253d37146106ec578063cfed96861461070b578063d547741f1461072a57610270565b8063a217fddf116100f1578063a217fddf14610611578063a6f4180c14610624578063a7cd52cb14610639578063ad1aca0614610667578063ae2e41a01461068657610270565b806391d148541461056057806397d92d721461057f578063984a1f72146105b25780639db5dbe4146105d15780639f8e4e48146105f057610270565b806357c19780116101bb578063662d2ebf1161017f578063662d2ebf146104a957806375829def146104bd57806379b4963a146104dc57806387b27665146105105780638da5cb5b1461054357610270565b806357c19780146103ed5780635ba1c1a91461040c5780635c975abb146104225780635f33e73f1461043957806361d027b31461046d57610270565b806322604de21161020257806322604de214610343578063248a9ca3146103625780632f2ff15d1461039057806336568abe146103af578063384896e5146103ce57610270565b806301ffc9a7146102ad5780630dd9a8be146102e15780630e18b6811461030e57806316c38b3c1461032457610270565b366102705760405134815233907f1e57e3bb474320be3d2c77138f75b7c3941292d647f5f9634e33a8e94e0e069b906020015b60405180910390a2005b336001600160a01b03167faca09dd456ca888dccf8cc966e382e6e3042bb7e4d2d7815015f844edeafce42345f3660405161026693929190612032565b3480156102b8575f80fd5b506102cc6102c7366004612067565b6107e4565b60405190151581526020015b60405180910390f35b3480156102ec575f80fd5b506103006102fb3660046120a2565b61081a565b6040519081526020016102d8565b348015610319575f80fd5b506103226108fb565b005b34801561032f575f80fd5b5061032261033e3660046120d9565b6109a4565b34801561034e575f80fd5b5061032261035d3660046120f4565b6109e4565b34801561036d575f80fd5b5061030061037c366004612132565b5f9081526020819052604090206001015490565b34801561039b575f80fd5b506103226103aa366004612149565b610a10565b3480156103ba575f80fd5b506103226103c9366004612149565b610a4a565b3480156103d9575f80fd5b506103226103e8366004612177565b610a78565b3480156103f8575f80fd5b506103226104073660046120a2565b610aee565b348015610417575f80fd5b506103006203f48081565b34801561042d575f80fd5b5060045460ff166102cc565b348015610444575f80fd5b506104586104533660046120a2565b610bfc565b604080519283526020830191909152016102d8565b348015610478575f80fd5b506004546104919061010090046001600160a01b031681565b6040516001600160a01b0390911681526020016102d8565b3480156104b4575f80fd5b50610322610d51565b3480156104c8575f80fd5b506103226104d73660046121a3565b610dd4565b3480156104e7575f80fd5b506004546104fd90600160b81b900461ffff1681565b60405161ffff90911681526020016102d8565b34801561051b575f80fd5b506103007f000000000000000000000000000000000000000000000000000000000000000081565b34801561054e575f80fd5b506001546001600160a01b0316610491565b34801561056b575f80fd5b506102cc61057a366004612149565b610ea5565b34801561058a575f80fd5b506104917f000000000000000000000000000000000000000000000000000000000000000081565b3480156105bd575f80fd5b506103226105cc3660046121be565b610ecd565b3480156105dc575f80fd5b506103226105eb3660046120f4565b610f21565b3480156105fb575f80fd5b506004546104fd90600160a81b900461ffff1681565b34801561061c575f80fd5b506103005f81565b34801561062f575f80fd5b506104fd61138881565b348015610644575f80fd5b506102cc6106533660046121a3565b60056020525f908152604090205460ff1681565b348015610672575f80fd5b506103226106813660046120a2565b610f85565b348015610691575f80fd5b506104917f000000000000000000000000000000000000000000000000000000000000000081565b3480156106c4575f80fd5b506103226106d33660046121df565b611070565b3480156106e3575f80fd5b506103006110cd565b3480156106f7575f80fd5b506103226107063660046121be565b611126565b348015610716575f80fd5b506103226107253660046121a3565b6111c3565b348015610735575f80fd5b50610322610744366004612149565b6113c5565b348015610754575f80fd5b506103226107633660046121a3565b6113f8565b348015610773575f80fd5b506103226107823660046120a2565b611425565b348015610792575f80fd5b506103226107a13660046120a2565b6114ed565b3480156107b1575f80fd5b506104586107c03660046120a2565b611570565b3480156107d0575f80fd5b506103226107df3660046121a3565b61164d565b5f6001600160e01b03198216637965db0b60e01b148061081457506301ffc9a760e01b6001600160e01b03198316145b92915050565b5f5f8051602061247c83398151915261083281611680565b61083a61168d565b604051635569f64b60e11b8152306004820152602481018490526001600160a01b0385169063aad3ec96906044016020604051808303815f875af1158015610884573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906108a8919061220b565b60408051858152602081018390526001600160a01b0387168183015290519193507fb93d57f59ac9e9808c96ca20b5c846870cc761711843f8ff9af0eca04d497651919081900360600190a15092915050565b6002546001600160a01b031633146109265760405163058d9a1b60e01b815260040160405180910390fd5b6003545f0361094857604051632becf27f60e21b815260040160405180910390fd5b5f600354426109579190612236565b90506203f48081101561099657610971816203f480612236565b6040516396a5c63160e01b815260040161098d91815260200190565b60405180910390fd5b6109a05f336116b3565b5050565b7f65d7a28e3265b37a6474929f336521b332c1681b933f6cb9f3376673440d862a6109ce81611680565b81156109dc576109a0611747565b6109a06117a1565b5f6109ee81611680565b6109f661168d565b610a0a6001600160a01b03851684846117da565b50505050565b5f610a1a81611680565b8280610a395760405163318bd07d60e11b815260040160405180910390fd5b610a4384846116b3565b5050505050565b8180610a695760405163318bd07d60e11b815260040160405180910390fd5b610a738383611897565b505050565b5f610a8281611680565b6001600160a01b038381165f8181526007602090815260409182902080546001600160a01b031916948716948517905581519283528201929092527f5604e7de4bccebfbd5e0b9ac94f9cc3c7095c1984d17006bc8ee6d537c6fbc9f91015b60405180910390a1505050565b5f8051602061247c833981519152610b0581611680565b610b0d61168d565b6001600160a01b038084165f81815260076020526040902054610b319216846117da565b6001600160a01b038381165f818152600760205260409081902054905162af832f60e71b8152600481019290925260248201859052909116906357c19780906044015f604051808303815f87803b158015610b8a575f80fd5b505af1158015610b9c573d5f803e3d5ffd5b505050506001600160a01b038381165f81815260076020908152604091829020548251938452909316928201929092529081018390527f9597a3204de231fac10f5ef611bbb352358a8a9902edd7b16c483f609d388e8190606001610ae1565b5f805f8051602061247c833981519152610c1581611680565b610c1d61168d565b5f856001600160a01b031663d8dfeb456040518163ffffffff1660e01b8152600401602060405180830381865afa158015610c5a573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190610c7e9190612249565b9050610c946001600160a01b03821687876117da565b6040516311f9fbc960e21b8152306004820152602481018690526001600160a01b038716906347e7ef249060440160408051808303815f875af1158015610cdd573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190610d019190612264565b604080518881526001600160a01b038a1660208201529296509094507fde0eb244e3c90006aa3734883e3766ed0f58856db94f5fa5400ead01f0f5c345910160405180910390a150509250929050565b5f610d5b81611680565b6002546001600160a01b0316610d8457604051632becf27f60e21b815260040160405180910390fd5b600280546001600160a01b03191690555f60038190556001546040516001600160a01b03909116907f3793833b9ab43215ac21b7766b4196d31276ccf43ec6edeade82fbd6946aac0a908390a350565b5f610dde81611680565b336001600160a01b03831603610e075760405163318bd07d60e11b815260040160405180910390fd5b6001600160a01b038216610e2e5760405163318bd07d60e11b815260040160405180910390fd5b60035415610e4f57604051633a76bcd760e11b815260040160405180910390fd5b600280546001600160a01b0319166001600160a01b0384811691821790925542600355600154604051919216907fefdcbba819467e00b0262c12892dda980bac68580b72178e57a162368b808766905f90a35050565b5f918252602082815260408084206001600160a01b0393909316845291905290205460ff1690565b5f610ed781611680565b61138861ffff83161115610efe5760405163162908e360e11b815260040160405180910390fd5b506004805461ffff909216600160a81b0261ffff60a81b19909216919091179055565b5f610f2b81611680565b610f3361168d565b6001600160a01b0383165f9081526005602052604090205460ff1615610f6c57610f676001600160a01b03851684846118ca565b610a0a565b604051634e46966960e11b815260040160405180910390fd5b5f8051602061247c833981519152610f9c81611680565b610fa461168d565b6001600160a01b038381165f818152600760205260409081902054905163f3fef3a360e01b81526004810192909252602482018590529091169063f3fef3a3906044015f604051808303815f87803b158015610ffe575f80fd5b505af1158015611010573d5f803e3d5ffd5b505050506001600160a01b038381165f81815260076020908152604091829020548251938452909316928201929092529081018390527feea1588af3d64fe1e043382e5b530073a6ccb9cd49967ee782adb853e50103fb90606001610ae1565b7f26a560d834a19637eccba4611bbc09fb32970bb627da0a70f14f83fdc9822cbc61109a81611680565b6110a261168d565b506001600160a01b03919091165f908152600560205260409020805460ff1916911515919091179055565b6002545f906001600160a01b031615806110e75750600354155b156110f157505f90565b5f600354426111009190612236565b90506203f4808110611113575f91505090565b611120816203f480612236565b91505090565b5f61113081611680565b61271061ffff831611156111a05760405162461bcd60e51b815260206004820152603160248201527f536c697070616765207468726573686f6c642063616e6e6f7420657863656564604482015270206d617820626173697320706f696e747360781b606482015260840161098d565b506004805461ffff909216600160b81b0261ffff60b81b19909216919091179055565b5f8051602061247c8339815191526111da81611680565b6111e261168d565b6001600160a01b038281165f81815260076020526040808220549051630accf83160e31b8152600481019390935290921690635667c188906024016020604051808303815f875af1158015611239573d5f803e3d5ffd5b505050506040513d601f19601f8201168201806040525081019061125d919061220b565b90505f61126a84836118fb565b915050805f0361128d5760405163162908e360e11b815260040160405180910390fd5b6040516370a0823160e01b81523060048201525f907f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316906370a0823190602401602060405180830381865afa1580156112f1573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190611315919061220b565b905061132185836119ae565b6040516370a0823160e01b81523060048201525f907f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316906370a0823190602401602060405180830381865afa158015611385573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906113a9919061220b565b90506113bd6113b88383612236565b611c05565b505050505050565b5f6113cf81611680565b82806113ee5760405163318bd07d60e11b815260040160405180910390fd5b610a438484611c9c565b5f61140281611680565b50600680546001600160a01b0319166001600160a01b0392909216919091179055565b5f61142f81611680565b61143761168d565b6001600160a01b0383165f9081526005602052604090205460ff1615610f6c575f836001600160a01b0316836040515f6040518083038185875af1925050503d805f81146114a0576040519150601f19603f3d011682016040523d82523d5f602084013e6114a5565b606091505b5050905080610a0a5760405162461bcd60e51b81526020600482015260146024820152732330b4b632b2103a379039b2b7321022ba3432b960611b604482015260640161098d565b5f8051602061247c83398151915261150481611680565b61150c61168d565b6115406001600160a01b0384167f0000000000000000000000000000000000000000000000000000000000000000846118ca565b6040518281527fedaa1042e6d95ec26c59b285ed8756cbe2ab6bcc4d23537e2c4017fcdd89f26790602001610ae1565b5f805f8051602061247c83398151915261158981611680565b61159161168d565b60405163f3fef3a360e01b8152306004820152602481018590526001600160a01b0386169063f3fef3a39060440160408051808303815f875af11580156115da573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906115fe9190612264565b604080518781526001600160a01b03891660208201529295509093507f86544495b74537b7510ccc1f1f0fd7db1f2fbfbba180d9c7b7710e88b9578f2c910160405180910390a1509250929050565b5f61165781611680565b50600480546001600160a01b0390921661010002610100600160a81b0319909216919091179055565b61168a8133611d0c565b50565b60045460ff16156116b15760405163d93c066560e01b815260040160405180910390fd5b565b5f82611736576001546040516001600160a01b038085169216907ff8ccb027dfcd135e000e9d45e6cc2d662578a8825d4c45b5e32e0adf67e79ec6905f90a3600154611709905f906001600160a01b0316611c9c565b50600180546001600160a01b0384166001600160a01b0319918216179091556002805490911690555f6003555b6117408383611d45565b9392505050565b61174f61168d565b6004805460ff191660011790557f62e78cea01bee320cd4e420270b5ea74000d11b0c9f74754ebdbfc544b05a2586117843390565b6040516001600160a01b03909116815260200160405180910390a1565b6117a9611dcd565b6004805460ff191690557f5db9ee0a495bf2e6ff9c91a7834c1ba4fdd244a5e8aa4e537bd38aeae4b073aa33611784565b604080516001600160a01b038416602482015260448082018490528251808303909101815260649091019091526020810180516001600160e01b031663095ea7b360e01b17905261182b8482611df0565b610a0a576040516001600160a01b0384811660248301525f604483015261188d91869182169063095ea7b3906064015b604051602081830303815290604052915060e01b6020820180516001600160e01b038381831617835250505050611e91565b610a0a8482611e91565b6001600160a01b03811633146118c05760405163334bd91960e11b815260040160405180910390fd5b610a738282611c9c565b6040516001600160a01b03838116602483015260448201839052610a7391859182169063a9059cbb9060640161185b565b6004545f90819061010090046001600160a01b031661192d5760405163b2c4cce960e01b815260040160405180910390fd5b600454600160a81b900461ffff161580611945575082155b1561195457505f9050816119a7565b6004545f90611972908590600160a81b900461ffff16612710611ef2565b90505f61197f8286612236565b6004549091506119a1906001600160a01b0388811691610100900416846118ca565b90925090505b9250929050565b6119b661168d565b6119ea6001600160a01b0383167f0000000000000000000000000000000000000000000000000000000000000000836117da565b5f826001600160a01b031663313ce5676040518163ffffffff1660e01b8152600401602060405180830381865afa158015611a27573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190611a4b9190612286565b60ff1690505f7f0000000000000000000000000000000000000000000000000000000000000000821015611abf57611aa3827f0000000000000000000000000000000000000000000000000000000000000000612236565b611aae90600a612386565b611ab89084612391565b9050611b01565b611ae97f000000000000000000000000000000000000000000000000000000000000000083612236565b611af490600a612386565b611afe90846123a8565b90505b600454611b1d908290600160b81b900461ffff16612710611f15565b611b279082612236565b90505f6040518060c001604052805f6001811115611b4757611b476123c7565b8152602001306001600160a01b03168152602001306001600160a01b03168152602001866001600160a01b031681526020018581526020018381525090507f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316637abed79d826040518263ffffffff1660e01b8152600401611bd191906123db565b5f604051808303815f87803b158015611be8575f80fd5b505af1158015611bfa573d5f803e3d5ffd5b505050505050505050565b611c0d61168d565b600654611c47906001600160a01b037f000000000000000000000000000000000000000000000000000000000000000081169116836117da565b600654604051630c80ef1160e41b8152600481018390526001600160a01b039091169063c80ef110906024015f604051808303815f87803b158015611c8a575f80fd5b505af1158015610a43573d5f803e3d5ffd5b5f611ca78383610ea5565b15611d05575f838152602081815260408083206001600160a01b0386168085529252808320805460ff1916905551339286917ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b9190a4506001610814565b505f610814565b611d168282610ea5565b6109a05760405163e2517d3f60e01b81526001600160a01b03821660048201526024810183905260440161098d565b5f611d508383610ea5565b611d05575f838152602081815260408083206001600160a01b03861684529091529020805460ff19166001179055611d853390565b6001600160a01b0316826001600160a01b0316847f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a4506001610814565b60045460ff166116b157604051638dfc202b60e01b815260040160405180910390fd5b5f805f846001600160a01b031684604051611e0b919061244a565b5f604051808303815f865af19150503d805f8114611e44576040519150601f19603f3d011682016040523d82523d5f602084013e611e49565b606091505b5091509150818015611e73575080511580611e73575080806020019051810190611e739190612460565b8015611e8857505f856001600160a01b03163b115b95945050505050565b5f611ea56001600160a01b03841683611f30565b905080515f14158015611ec9575080806020019051810190611ec79190612460565b155b15610a7357604051635274afe760e01b81526001600160a01b038416600482015260240161098d565b5f825f190484118302158202611f06575f80fd5b50910281810615159190040190565b5f825f190484118302158202611f29575f80fd5b5091020490565b606061174083835f845f80856001600160a01b03168486604051611f54919061244a565b5f6040518083038185875af1925050503d805f8114611f8e576040519150601f19603f3d011682016040523d82523d5f602084013e611f93565b606091505b5091509150611fa3868383611fad565b9695505050505050565b606082611fc257611fbd82612009565b611740565b8151158015611fd957506001600160a01b0384163b155b1561200257604051639996b31560e01b81526001600160a01b038516600482015260240161098d565b5080611740565b8051156120195780518082602001fd5b604051630a12f52160e11b815260040160405180910390fd5b83815260406020820152816040820152818360608301375f818301606090810191909152601f909201601f1916010192915050565b5f60208284031215612077575f80fd5b81356001600160e01b031981168114611740575f80fd5b6001600160a01b038116811461168a575f80fd5b5f80604083850312156120b3575f80fd5b82356120be8161208e565b946020939093013593505050565b801515811461168a575f80fd5b5f602082840312156120e9575f80fd5b8135611740816120cc565b5f805f60608486031215612106575f80fd5b83356121118161208e565b925060208401356121218161208e565b929592945050506040919091013590565b5f60208284031215612142575f80fd5b5035919050565b5f806040838503121561215a575f80fd5b82359150602083013561216c8161208e565b809150509250929050565b5f8060408385031215612188575f80fd5b82356121938161208e565b9150602083013561216c8161208e565b5f602082840312156121b3575f80fd5b81356117408161208e565b5f602082840312156121ce575f80fd5b813561ffff81168114611740575f80fd5b5f80604083850312156121f0575f80fd5b82356121fb8161208e565b9150602083013561216c816120cc565b5f6020828403121561221b575f80fd5b5051919050565b634e487b7160e01b5f52601160045260245ffd5b8181038181111561081457610814612222565b5f60208284031215612259575f80fd5b81516117408161208e565b5f8060408385031215612275575f80fd5b505080516020909101519092909150565b5f60208284031215612296575f80fd5b815160ff81168114611740575f80fd5b600181815b808511156122e057815f19048211156122c6576122c6612222565b808516156122d357918102915b93841c93908002906122ab565b509250929050565b5f826122f657506001610814565b8161230257505f610814565b816001811461231857600281146123225761233e565b6001915050610814565b60ff84111561233357612333612222565b50506001821b610814565b5060208310610133831016604e8410600b8410161715612361575081810a610814565b61236b83836122a6565b805f190482111561237e5761237e612222565b029392505050565b5f61174083836122e8565b808202811582820484141761081457610814612222565b5f826123c257634e487b7160e01b5f52601260045260245ffd5b500490565b634e487b7160e01b5f52602160045260245ffd5b815160c0820190600281106123fe57634e487b7160e01b5f52602160045260245ffd5b80835250602083015160018060a01b03808216602085015280604086015116604085015280606086015116606085015250506080830151608083015260a083015160a083015292915050565b5f82518060208501845e5f920191825250919050565b5f60208284031215612470575f80fd5b8151611740816120cc56fefa43c681b8469d52726371b68b5ada1ab8b9c81dd2e3b645d00330167490d8dda2646970667358221220683b3995f0b89b492a025dddfcfdc911140fa57ceb72dec03a6927e32a61ca0364736f6c634300081900330000000000000000000000007c1156e515aa1a2e851674120074968c905aaf3700000000000000000000000000000000000000000000000000000000000000000000000000000000000000005b5004f1bc12c66f94782070032a6eadc6821a3e0000000000000000000000005b5004f1bc12c66f94782070032a6eadc6821a3e
Deployed Bytecode
0x608060405260043610610233575f3560e01c806391d148541161012d578063b12527f8116100aa578063de1da1791161006e578063de1da17914610749578063e9bb84c214610768578063ee47481214610787578063ef756632146107a6578063f0f44260146107c557610270565b8063b12527f8146106b9578063b55dd256146106d8578063bf253d37146106ec578063cfed96861461070b578063d547741f1461072a57610270565b8063a217fddf116100f1578063a217fddf14610611578063a6f4180c14610624578063a7cd52cb14610639578063ad1aca0614610667578063ae2e41a01461068657610270565b806391d148541461056057806397d92d721461057f578063984a1f72146105b25780639db5dbe4146105d15780639f8e4e48146105f057610270565b806357c19780116101bb578063662d2ebf1161017f578063662d2ebf146104a957806375829def146104bd57806379b4963a146104dc57806387b27665146105105780638da5cb5b1461054357610270565b806357c19780146103ed5780635ba1c1a91461040c5780635c975abb146104225780635f33e73f1461043957806361d027b31461046d57610270565b806322604de21161020257806322604de214610343578063248a9ca3146103625780632f2ff15d1461039057806336568abe146103af578063384896e5146103ce57610270565b806301ffc9a7146102ad5780630dd9a8be146102e15780630e18b6811461030e57806316c38b3c1461032457610270565b366102705760405134815233907f1e57e3bb474320be3d2c77138f75b7c3941292d647f5f9634e33a8e94e0e069b906020015b60405180910390a2005b336001600160a01b03167faca09dd456ca888dccf8cc966e382e6e3042bb7e4d2d7815015f844edeafce42345f3660405161026693929190612032565b3480156102b8575f80fd5b506102cc6102c7366004612067565b6107e4565b60405190151581526020015b60405180910390f35b3480156102ec575f80fd5b506103006102fb3660046120a2565b61081a565b6040519081526020016102d8565b348015610319575f80fd5b506103226108fb565b005b34801561032f575f80fd5b5061032261033e3660046120d9565b6109a4565b34801561034e575f80fd5b5061032261035d3660046120f4565b6109e4565b34801561036d575f80fd5b5061030061037c366004612132565b5f9081526020819052604090206001015490565b34801561039b575f80fd5b506103226103aa366004612149565b610a10565b3480156103ba575f80fd5b506103226103c9366004612149565b610a4a565b3480156103d9575f80fd5b506103226103e8366004612177565b610a78565b3480156103f8575f80fd5b506103226104073660046120a2565b610aee565b348015610417575f80fd5b506103006203f48081565b34801561042d575f80fd5b5060045460ff166102cc565b348015610444575f80fd5b506104586104533660046120a2565b610bfc565b604080519283526020830191909152016102d8565b348015610478575f80fd5b506004546104919061010090046001600160a01b031681565b6040516001600160a01b0390911681526020016102d8565b3480156104b4575f80fd5b50610322610d51565b3480156104c8575f80fd5b506103226104d73660046121a3565b610dd4565b3480156104e7575f80fd5b506004546104fd90600160b81b900461ffff1681565b60405161ffff90911681526020016102d8565b34801561051b575f80fd5b506103007f000000000000000000000000000000000000000000000000000000000000001281565b34801561054e575f80fd5b506001546001600160a01b0316610491565b34801561056b575f80fd5b506102cc61057a366004612149565b610ea5565b34801561058a575f80fd5b506104917f0000000000000000000000007c1156e515aa1a2e851674120074968c905aaf3781565b3480156105bd575f80fd5b506103226105cc3660046121be565b610ecd565b3480156105dc575f80fd5b506103226105eb3660046120f4565b610f21565b3480156105fb575f80fd5b506004546104fd90600160a81b900461ffff1681565b34801561061c575f80fd5b506103005f81565b34801561062f575f80fd5b506104fd61138881565b348015610644575f80fd5b506102cc6106533660046121a3565b60056020525f908152604090205460ff1681565b348015610672575f80fd5b506103226106813660046120a2565b610f85565b348015610691575f80fd5b506104917f0000000000000000000000008e7046e27d14d09bdacde9260ff7c8c2be68a41f81565b3480156106c4575f80fd5b506103226106d33660046121df565b611070565b3480156106e3575f80fd5b506103006110cd565b3480156106f7575f80fd5b506103226107063660046121be565b611126565b348015610716575f80fd5b506103226107253660046121a3565b6111c3565b348015610735575f80fd5b50610322610744366004612149565b6113c5565b348015610754575f80fd5b506103226107633660046121a3565b6113f8565b348015610773575f80fd5b506103226107823660046120a2565b611425565b348015610792575f80fd5b506103226107a13660046120a2565b6114ed565b3480156107b1575f80fd5b506104586107c03660046120a2565b611570565b3480156107d0575f80fd5b506103226107df3660046121a3565b61164d565b5f6001600160e01b03198216637965db0b60e01b148061081457506301ffc9a760e01b6001600160e01b03198316145b92915050565b5f5f8051602061247c83398151915261083281611680565b61083a61168d565b604051635569f64b60e11b8152306004820152602481018490526001600160a01b0385169063aad3ec96906044016020604051808303815f875af1158015610884573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906108a8919061220b565b60408051858152602081018390526001600160a01b0387168183015290519193507fb93d57f59ac9e9808c96ca20b5c846870cc761711843f8ff9af0eca04d497651919081900360600190a15092915050565b6002546001600160a01b031633146109265760405163058d9a1b60e01b815260040160405180910390fd5b6003545f0361094857604051632becf27f60e21b815260040160405180910390fd5b5f600354426109579190612236565b90506203f48081101561099657610971816203f480612236565b6040516396a5c63160e01b815260040161098d91815260200190565b60405180910390fd5b6109a05f336116b3565b5050565b7f65d7a28e3265b37a6474929f336521b332c1681b933f6cb9f3376673440d862a6109ce81611680565b81156109dc576109a0611747565b6109a06117a1565b5f6109ee81611680565b6109f661168d565b610a0a6001600160a01b03851684846117da565b50505050565b5f610a1a81611680565b8280610a395760405163318bd07d60e11b815260040160405180910390fd5b610a4384846116b3565b5050505050565b8180610a695760405163318bd07d60e11b815260040160405180910390fd5b610a738383611897565b505050565b5f610a8281611680565b6001600160a01b038381165f8181526007602090815260409182902080546001600160a01b031916948716948517905581519283528201929092527f5604e7de4bccebfbd5e0b9ac94f9cc3c7095c1984d17006bc8ee6d537c6fbc9f91015b60405180910390a1505050565b5f8051602061247c833981519152610b0581611680565b610b0d61168d565b6001600160a01b038084165f81815260076020526040902054610b319216846117da565b6001600160a01b038381165f818152600760205260409081902054905162af832f60e71b8152600481019290925260248201859052909116906357c19780906044015f604051808303815f87803b158015610b8a575f80fd5b505af1158015610b9c573d5f803e3d5ffd5b505050506001600160a01b038381165f81815260076020908152604091829020548251938452909316928201929092529081018390527f9597a3204de231fac10f5ef611bbb352358a8a9902edd7b16c483f609d388e8190606001610ae1565b5f805f8051602061247c833981519152610c1581611680565b610c1d61168d565b5f856001600160a01b031663d8dfeb456040518163ffffffff1660e01b8152600401602060405180830381865afa158015610c5a573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190610c7e9190612249565b9050610c946001600160a01b03821687876117da565b6040516311f9fbc960e21b8152306004820152602481018690526001600160a01b038716906347e7ef249060440160408051808303815f875af1158015610cdd573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190610d019190612264565b604080518881526001600160a01b038a1660208201529296509094507fde0eb244e3c90006aa3734883e3766ed0f58856db94f5fa5400ead01f0f5c345910160405180910390a150509250929050565b5f610d5b81611680565b6002546001600160a01b0316610d8457604051632becf27f60e21b815260040160405180910390fd5b600280546001600160a01b03191690555f60038190556001546040516001600160a01b03909116907f3793833b9ab43215ac21b7766b4196d31276ccf43ec6edeade82fbd6946aac0a908390a350565b5f610dde81611680565b336001600160a01b03831603610e075760405163318bd07d60e11b815260040160405180910390fd5b6001600160a01b038216610e2e5760405163318bd07d60e11b815260040160405180910390fd5b60035415610e4f57604051633a76bcd760e11b815260040160405180910390fd5b600280546001600160a01b0319166001600160a01b0384811691821790925542600355600154604051919216907fefdcbba819467e00b0262c12892dda980bac68580b72178e57a162368b808766905f90a35050565b5f918252602082815260408084206001600160a01b0393909316845291905290205460ff1690565b5f610ed781611680565b61138861ffff83161115610efe5760405163162908e360e11b815260040160405180910390fd5b506004805461ffff909216600160a81b0261ffff60a81b19909216919091179055565b5f610f2b81611680565b610f3361168d565b6001600160a01b0383165f9081526005602052604090205460ff1615610f6c57610f676001600160a01b03851684846118ca565b610a0a565b604051634e46966960e11b815260040160405180910390fd5b5f8051602061247c833981519152610f9c81611680565b610fa461168d565b6001600160a01b038381165f818152600760205260409081902054905163f3fef3a360e01b81526004810192909252602482018590529091169063f3fef3a3906044015f604051808303815f87803b158015610ffe575f80fd5b505af1158015611010573d5f803e3d5ffd5b505050506001600160a01b038381165f81815260076020908152604091829020548251938452909316928201929092529081018390527feea1588af3d64fe1e043382e5b530073a6ccb9cd49967ee782adb853e50103fb90606001610ae1565b7f26a560d834a19637eccba4611bbc09fb32970bb627da0a70f14f83fdc9822cbc61109a81611680565b6110a261168d565b506001600160a01b03919091165f908152600560205260409020805460ff1916911515919091179055565b6002545f906001600160a01b031615806110e75750600354155b156110f157505f90565b5f600354426111009190612236565b90506203f4808110611113575f91505090565b611120816203f480612236565b91505090565b5f61113081611680565b61271061ffff831611156111a05760405162461bcd60e51b815260206004820152603160248201527f536c697070616765207468726573686f6c642063616e6e6f7420657863656564604482015270206d617820626173697320706f696e747360781b606482015260840161098d565b506004805461ffff909216600160b81b0261ffff60b81b19909216919091179055565b5f8051602061247c8339815191526111da81611680565b6111e261168d565b6001600160a01b038281165f81815260076020526040808220549051630accf83160e31b8152600481019390935290921690635667c188906024016020604051808303815f875af1158015611239573d5f803e3d5ffd5b505050506040513d601f19601f8201168201806040525081019061125d919061220b565b90505f61126a84836118fb565b915050805f0361128d5760405163162908e360e11b815260040160405180910390fd5b6040516370a0823160e01b81523060048201525f907f0000000000000000000000007c1156e515aa1a2e851674120074968c905aaf376001600160a01b0316906370a0823190602401602060405180830381865afa1580156112f1573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190611315919061220b565b905061132185836119ae565b6040516370a0823160e01b81523060048201525f907f0000000000000000000000007c1156e515aa1a2e851674120074968c905aaf376001600160a01b0316906370a0823190602401602060405180830381865afa158015611385573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906113a9919061220b565b90506113bd6113b88383612236565b611c05565b505050505050565b5f6113cf81611680565b82806113ee5760405163318bd07d60e11b815260040160405180910390fd5b610a438484611c9c565b5f61140281611680565b50600680546001600160a01b0319166001600160a01b0392909216919091179055565b5f61142f81611680565b61143761168d565b6001600160a01b0383165f9081526005602052604090205460ff1615610f6c575f836001600160a01b0316836040515f6040518083038185875af1925050503d805f81146114a0576040519150601f19603f3d011682016040523d82523d5f602084013e6114a5565b606091505b5050905080610a0a5760405162461bcd60e51b81526020600482015260146024820152732330b4b632b2103a379039b2b7321022ba3432b960611b604482015260640161098d565b5f8051602061247c83398151915261150481611680565b61150c61168d565b6115406001600160a01b0384167f0000000000000000000000008e7046e27d14d09bdacde9260ff7c8c2be68a41f846118ca565b6040518281527fedaa1042e6d95ec26c59b285ed8756cbe2ab6bcc4d23537e2c4017fcdd89f26790602001610ae1565b5f805f8051602061247c83398151915261158981611680565b61159161168d565b60405163f3fef3a360e01b8152306004820152602481018590526001600160a01b0386169063f3fef3a39060440160408051808303815f875af11580156115da573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906115fe9190612264565b604080518781526001600160a01b03891660208201529295509093507f86544495b74537b7510ccc1f1f0fd7db1f2fbfbba180d9c7b7710e88b9578f2c910160405180910390a1509250929050565b5f61165781611680565b50600480546001600160a01b0390921661010002610100600160a81b0319909216919091179055565b61168a8133611d0c565b50565b60045460ff16156116b15760405163d93c066560e01b815260040160405180910390fd5b565b5f82611736576001546040516001600160a01b038085169216907ff8ccb027dfcd135e000e9d45e6cc2d662578a8825d4c45b5e32e0adf67e79ec6905f90a3600154611709905f906001600160a01b0316611c9c565b50600180546001600160a01b0384166001600160a01b0319918216179091556002805490911690555f6003555b6117408383611d45565b9392505050565b61174f61168d565b6004805460ff191660011790557f62e78cea01bee320cd4e420270b5ea74000d11b0c9f74754ebdbfc544b05a2586117843390565b6040516001600160a01b03909116815260200160405180910390a1565b6117a9611dcd565b6004805460ff191690557f5db9ee0a495bf2e6ff9c91a7834c1ba4fdd244a5e8aa4e537bd38aeae4b073aa33611784565b604080516001600160a01b038416602482015260448082018490528251808303909101815260649091019091526020810180516001600160e01b031663095ea7b360e01b17905261182b8482611df0565b610a0a576040516001600160a01b0384811660248301525f604483015261188d91869182169063095ea7b3906064015b604051602081830303815290604052915060e01b6020820180516001600160e01b038381831617835250505050611e91565b610a0a8482611e91565b6001600160a01b03811633146118c05760405163334bd91960e11b815260040160405180910390fd5b610a738282611c9c565b6040516001600160a01b03838116602483015260448201839052610a7391859182169063a9059cbb9060640161185b565b6004545f90819061010090046001600160a01b031661192d5760405163b2c4cce960e01b815260040160405180910390fd5b600454600160a81b900461ffff161580611945575082155b1561195457505f9050816119a7565b6004545f90611972908590600160a81b900461ffff16612710611ef2565b90505f61197f8286612236565b6004549091506119a1906001600160a01b0388811691610100900416846118ca565b90925090505b9250929050565b6119b661168d565b6119ea6001600160a01b0383167f0000000000000000000000008e7046e27d14d09bdacde9260ff7c8c2be68a41f836117da565b5f826001600160a01b031663313ce5676040518163ffffffff1660e01b8152600401602060405180830381865afa158015611a27573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190611a4b9190612286565b60ff1690505f7f0000000000000000000000000000000000000000000000000000000000000012821015611abf57611aa3827f0000000000000000000000000000000000000000000000000000000000000012612236565b611aae90600a612386565b611ab89084612391565b9050611b01565b611ae97f000000000000000000000000000000000000000000000000000000000000001283612236565b611af490600a612386565b611afe90846123a8565b90505b600454611b1d908290600160b81b900461ffff16612710611f15565b611b279082612236565b90505f6040518060c001604052805f6001811115611b4757611b476123c7565b8152602001306001600160a01b03168152602001306001600160a01b03168152602001866001600160a01b031681526020018581526020018381525090507f0000000000000000000000008e7046e27d14d09bdacde9260ff7c8c2be68a41f6001600160a01b0316637abed79d826040518263ffffffff1660e01b8152600401611bd191906123db565b5f604051808303815f87803b158015611be8575f80fd5b505af1158015611bfa573d5f803e3d5ffd5b505050505050505050565b611c0d61168d565b600654611c47906001600160a01b037f0000000000000000000000007c1156e515aa1a2e851674120074968c905aaf3781169116836117da565b600654604051630c80ef1160e41b8152600481018390526001600160a01b039091169063c80ef110906024015f604051808303815f87803b158015611c8a575f80fd5b505af1158015610a43573d5f803e3d5ffd5b5f611ca78383610ea5565b15611d05575f838152602081815260408083206001600160a01b0386168085529252808320805460ff1916905551339286917ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b9190a4506001610814565b505f610814565b611d168282610ea5565b6109a05760405163e2517d3f60e01b81526001600160a01b03821660048201526024810183905260440161098d565b5f611d508383610ea5565b611d05575f838152602081815260408083206001600160a01b03861684529091529020805460ff19166001179055611d853390565b6001600160a01b0316826001600160a01b0316847f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a4506001610814565b60045460ff166116b157604051638dfc202b60e01b815260040160405180910390fd5b5f805f846001600160a01b031684604051611e0b919061244a565b5f604051808303815f865af19150503d805f8114611e44576040519150601f19603f3d011682016040523d82523d5f602084013e611e49565b606091505b5091509150818015611e73575080511580611e73575080806020019051810190611e739190612460565b8015611e8857505f856001600160a01b03163b115b95945050505050565b5f611ea56001600160a01b03841683611f30565b905080515f14158015611ec9575080806020019051810190611ec79190612460565b155b15610a7357604051635274afe760e01b81526001600160a01b038416600482015260240161098d565b5f825f190484118302158202611f06575f80fd5b50910281810615159190040190565b5f825f190484118302158202611f29575f80fd5b5091020490565b606061174083835f845f80856001600160a01b03168486604051611f54919061244a565b5f6040518083038185875af1925050503d805f8114611f8e576040519150601f19603f3d011682016040523d82523d5f602084013e611f93565b606091505b5091509150611fa3868383611fad565b9695505050505050565b606082611fc257611fbd82612009565b611740565b8151158015611fd957506001600160a01b0384163b155b1561200257604051639996b31560e01b81526001600160a01b038516600482015260240161098d565b5080611740565b8051156120195780518082602001fd5b604051630a12f52160e11b815260040160405180910390fd5b83815260406020820152816040820152818360608301375f818301606090810191909152601f909201601f1916010192915050565b5f60208284031215612077575f80fd5b81356001600160e01b031981168114611740575f80fd5b6001600160a01b038116811461168a575f80fd5b5f80604083850312156120b3575f80fd5b82356120be8161208e565b946020939093013593505050565b801515811461168a575f80fd5b5f602082840312156120e9575f80fd5b8135611740816120cc565b5f805f60608486031215612106575f80fd5b83356121118161208e565b925060208401356121218161208e565b929592945050506040919091013590565b5f60208284031215612142575f80fd5b5035919050565b5f806040838503121561215a575f80fd5b82359150602083013561216c8161208e565b809150509250929050565b5f8060408385031215612188575f80fd5b82356121938161208e565b9150602083013561216c8161208e565b5f602082840312156121b3575f80fd5b81356117408161208e565b5f602082840312156121ce575f80fd5b813561ffff81168114611740575f80fd5b5f80604083850312156121f0575f80fd5b82356121fb8161208e565b9150602083013561216c816120cc565b5f6020828403121561221b575f80fd5b5051919050565b634e487b7160e01b5f52601160045260245ffd5b8181038181111561081457610814612222565b5f60208284031215612259575f80fd5b81516117408161208e565b5f8060408385031215612275575f80fd5b505080516020909101519092909150565b5f60208284031215612296575f80fd5b815160ff81168114611740575f80fd5b600181815b808511156122e057815f19048211156122c6576122c6612222565b808516156122d357918102915b93841c93908002906122ab565b509250929050565b5f826122f657506001610814565b8161230257505f610814565b816001811461231857600281146123225761233e565b6001915050610814565b60ff84111561233357612333612222565b50506001821b610814565b5060208310610133831016604e8410600b8410161715612361575081810a610814565b61236b83836122a6565b805f190482111561237e5761237e612222565b029392505050565b5f61174083836122e8565b808202811582820484141761081457610814612222565b5f826123c257634e487b7160e01b5f52601260045260245ffd5b500490565b634e487b7160e01b5f52602160045260245ffd5b815160c0820190600281106123fe57634e487b7160e01b5f52602160045260245ffd5b80835250602083015160018060a01b03808216602085015280604086015116604085015280606086015116606085015250506080830151608083015260a083015160a083015292915050565b5f82518060208501845e5f920191825250919050565b5f60208284031215612470575f80fd5b8151611740816120cc56fefa43c681b8469d52726371b68b5ada1ab8b9c81dd2e3b645d00330167490d8dda2646970667358221220683b3995f0b89b492a025dddfcfdc911140fa57ceb72dec03a6927e32a61ca0364736f6c63430008190033
Constructor Arguments (ABI-Encoded and is the last bytes of the Contract Creation Code above)
0000000000000000000000007c1156e515aa1a2e851674120074968c905aaf3700000000000000000000000000000000000000000000000000000000000000000000000000000000000000005b5004f1bc12c66f94782070032a6eadc6821a3e0000000000000000000000005b5004f1bc12c66f94782070032a6eadc6821a3e
-----Decoded View---------------
Arg [0] : _lvlusd (address): 0x7C1156E515aA1A2E851674120074968C905aAF37
Arg [1] : _stakedlvlUSD (address): 0x0000000000000000000000000000000000000000
Arg [2] : _admin (address): 0x5b5004f1bC12C66F94782070032a6eAdC6821a3e
Arg [3] : _allowlister (address): 0x5b5004f1bC12C66F94782070032a6eAdC6821a3e
-----Encoded View---------------
4 Constructor Arguments found :
Arg [0] : 0000000000000000000000007c1156e515aa1a2e851674120074968c905aaf37
Arg [1] : 0000000000000000000000000000000000000000000000000000000000000000
Arg [2] : 0000000000000000000000005b5004f1bc12c66f94782070032a6eadc6821a3e
Arg [3] : 0000000000000000000000005b5004f1bc12c66f94782070032a6eadc6821a3e
Loading...
Loading
Loading...
Loading
Multichain Portfolio | 34 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.