Source Code
Latest 1 from a total of 1 transactions
| Transaction Hash |
Method
|
Block
|
From
|
To
|
|||||
|---|---|---|---|---|---|---|---|---|---|
| Deposit | 5977103 | 143 days ago | IN | 0 ETH | 0 |
Latest 1 internal transaction
Advanced mode:
| Parent Transaction Hash | Block | From | To | |||
|---|---|---|---|---|---|---|
| 5504987 | 149 days ago | Contract Creation | 0 ETH |
Cross-Chain Transactions
Loading...
Loading
Contract Source Code Verified (Exact Match)
Contract Name:
InventoryPool01
Compiler Version
v0.8.28+commit.7893614a
Contract Source Code (Solidity Standard Json-Input format)
// SPDX-License-Identifier: GPL-3.0-or-later
pragma solidity ^0.8.0;
/*=================================================================================================*
* Nomial::InventoryPool01.sol *
*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*
* ____________________ ______(_)_____ ___ / *
* __ __ \ __ \_ __ `__ \_ /_ __ `/_ / *
* _ / / / /_/ / / / / / / / / /_/ /_ / *
* /_/ /_/\____//_/ /_/ /_//_/ \__,_/ /_/ *
*=================================================================================================*/
import {ERC4626, IERC20, ERC20} from "@openzeppelin/contracts/token/ERC20/extensions/ERC4626.sol";
import {Ownable} from "@openzeppelin/contracts/access/Ownable.sol";
import {ReentrancyGuardTransient} from "@openzeppelin/contracts/utils/ReentrancyGuardTransient.sol";
import {Math} from "@openzeppelin/contracts/utils/math/Math.sol";
import {SafeERC20} from "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
import {IInventoryPool01} from "./interfaces/IInventoryPool01.sol";
import {IInventoryPoolParams01} from "./interfaces/IInventoryPoolParams01.sol";
import {WadMath} from "./utils/WadMath.sol";
/**
* @title InventoryPool01
* @dev An ERC4626-compliant lending pool that allows borrowing by the pool owner and tracks debt
* Features include:
* - Variable interest rates based on pool utilization
* - Penalty interest for overdue loans
* - Repayment of both base debt and penalty debt
* All rates and calculations use WAD (1e18) precision
*/
contract InventoryPool01 is ERC4626, Ownable, IInventoryPool01, ReentrancyGuardTransient {
using Math for uint256;
using SafeERC20 for IERC20;
uint constant WAD = 1e18;
address constant DEAD_ADDRESS = 0x000000000000000000000000000000000000dEaD;
// 500% annual interest rate (per-second), in WAD (1e18) precision
// 500n * 10n**16n / (60n * 60n * 24n * 365n)
uint constant MAX_INTEREST_RATE = 158548959918;
/**
* @dev Represents a borrower's debt position and penalty status
* @param scaledDebt The borrower's debt amount scaled by the global accumulated interest factor
* @param penaltyCounterStart The timestamp when the penalty counter started for this borrower. 0 if not in penalty period
*/
struct Borrower {
uint scaledDebt;
uint penaltyCounterStart;
}
/// @notice The contract that defines interest rates, fees, and penalty settings for this pool
IInventoryPoolParams01 public params;
/// @notice The global accumulated interest factor used for debt scaling, stored in WAD (1e18) precision
/// @dev Although this is public, it is not recommended to read it directly. Instead use the `accumulatedInterestFactor()`
/// function which will calculate the interest factor based on the current time and the last update timestamp.
uint public storedAccInterestFactor;
/// @notice The timestamp of the last stored accumulated interest factor update
uint public lastAccumulatedInterestUpdate;
/// @notice The total scaled debt of all borrowers, used to calculate total receivables
uint public scaledReceivables;
/// @notice Maps borrower addresses to their debt positions and penalty status data
mapping(address => Borrower) public borrowers;
constructor(
IERC20 asset_,
string memory name,
string memory symbol,
uint initAmount,
address owner,
IInventoryPoolParams01 paramsContract
) ERC4626(IERC20(asset_)) ERC20(name, symbol) Ownable(owner) {
/**
* deployer is responsible for burning a small deposit to mitigate inflation attack.
* this ERC4626 implementation uses offset to make inflation attack un-profitable
* but burning a small initial deposit eliminates the possibility of a griefing attack
*/
if (initAmount > 0) {
deposit(initAmount, DEAD_ADDRESS);
}
params = paramsContract;
}
/**
* @notice Creates a new borrow position
* @dev Only callable by owner. Creates a new borrow position with the specified amount
* and transfers the borrowed assets to the recipient. Interest starts accruing immediately.
* @param amount The amount of assets to borrow
* @param borrower The address that will own the debt position
* @param recipient The address that will receive the borrowed assets
* @param expiry The timestamp after which this borrow request is no longer valid
* @param chainId The chain ID where this borrow should be executed (for cross-chain safety)
* @custom:revert Expired If the current timestamp is past the expiry
* @custom:revert WrongChainId If executed on a different chain than specified
*/
function borrow(uint amount, address borrower, address recipient, uint expiry, uint chainId) external nonReentrant() onlyOwner() {
if (block.timestamp > expiry) revert Expired();
if (block.chainid != chainId) revert WrongChainId(chainId);
_updateAccumulatedInterestFactor();
uint scaledDebt_ = amount.mulDiv(WAD, storedAccInterestFactor, Math.Rounding.Ceil) + amount.mulDiv(params.baseFee(), WAD, Math.Rounding.Ceil);
borrowers[borrower].scaledDebt += scaledDebt_;
scaledReceivables += scaledDebt_;
if (borrowers[borrower].penaltyCounterStart == 0) {
borrowers[borrower].penaltyCounterStart = block.timestamp;
}
IERC20(asset()).safeTransfer(recipient, amount);
emit Borrowed(borrower, recipient, amount);
}
/**
* @notice Repays debt for a borrower
* @dev Accepts repayment for both base debt and penalty debt. Penalty debt is paid first.
* Partial repayments of penalty debt proportionally reduce the penalty time
* Partial repayments of base debt proportionally reduce the time until penalties start.
* @param amount The amount of assets to repay
* @param borrower The address whose debt is being repaid
* @custom:revert ZeroRepayment If amount is 0
* @custom:revert NoDebt If the borrower has no outstanding debt
*/
function repay(uint amount, address borrower) public {
_repay(amount, borrower, false);
}
/**
* @notice Allows owner to forgive debt without requiring asset transfer
* @dev Similar to repay() but doesn't require actual asset transfer
* @param amount The amount of debt to forgive
* @param borrower The address whose debt is being forgiven
* @custom:revert ZeroRepayment If amount is 0
* @custom:revert NoDebt If the borrower has no outstanding debt
*/
function forgiveDebt(uint amount, address borrower) public onlyOwner() {
_repay(amount, borrower, true);
}
/**
* @notice Updates the IInventoryPoolParams01 contract address
* @dev Allows upgrading to a new parameters contract while maintaining the same pool
* @param paramsContract The address of the new IInventoryPoolParams01 contract
*/
function upgradeParamsContract(IInventoryPoolParams01 paramsContract) public onlyOwner() {
if (paramsContract == params) {
revert ParamsContractNotChanged();
}
params = paramsContract;
emit ParamsContractUpgraded(paramsContract);
}
/**
* @notice Overwrites core state of the pool
* @dev Only callable by owner. This is an emergency function that allows the pool to be recovered
* from an unexpected state, such as accumulated interest factor arithmetic overflow.
* @param newStoredAccInterestFactor The new value for storedAccInterestFactor
* @param newLastAccumulatedInterestUpdate The new timestamp for lastAccumulatedInterestUpdate
* @param newScaledReceivables The new value for scaledReceivables
*/
function overwriteCoreState(
uint newStoredAccInterestFactor,
uint newLastAccumulatedInterestUpdate,
uint newScaledReceivables
) public onlyOwner() {
storedAccInterestFactor = newStoredAccInterestFactor;
lastAccumulatedInterestUpdate = newLastAccumulatedInterestUpdate;
scaledReceivables = newScaledReceivables;
}
/**
* @notice Returns the total assets managed by this pool
* @dev Includes both the actual balance and all outstanding receivables
* @return The total assets in the pool
*/
function totalAssets() public view override(ERC4626, IInventoryPool01) returns (uint) {
return totalReceivables() + IERC20(asset()).balanceOf(address(this));
}
/**
* @notice Returns the total amount of debt owed to the pool
* @dev Includes both base debt and accrued interest for all borrowers. Does not include penalty debt
* @return The total receivables amount
*/
function totalReceivables() public view returns (uint) {
return _totalReceivables(accumulatedInterestFactor());
}
/**
* @notice Calculates the current utilization rate of the pool
* @dev Utilization = Total Receivables / Total Assets
* @return The utilization rate in WAD (1e18) precision
*/
function utilizationRate() public view returns (uint) {
uint totalReceivables_ = totalReceivables();
uint totalAssets_ = totalReceivables_ + IERC20(asset()).balanceOf(address(this));
return totalReceivables_.mulDiv(WAD, totalAssets_);
}
/**
* @notice Returns the current base debt for a borrower
* @dev Base debt includes the original borrowed amount plus accrued interest,
* but excludes any penalty interest
* @param borrower The borrower's address
* @return The current base debt amount for the borrower
*/
function baseDebt(address borrower) public view returns (uint) {
return _baseDebt(borrower, accumulatedInterestFactor());
}
/**
* @notice Returns the current penalty debt for a borrower
* @dev Penalty debt only exists after the penalty period has passed
* and is calculated based on the penalty rate
* @param borrower The borrower's address
* @return The current penalty debt amount for the borrower
*/
function penaltyDebt(address borrower) public view returns (uint) {
return _penaltyDebt(borrower, accumulatedInterestFactor());
}
/**
* @notice Returns how long a borrower has been in the penalty period
* @dev Returns 0 if not in penalty period, otherwise returns seconds since penalty started
* @param borrower The borrower's address
* @return The number of seconds in penalty period, or 0 if not in penalty period
*/
function penaltyTime(address borrower) public view returns (uint) {
uint penaltyCounterStart = borrowers[borrower].penaltyCounterStart;
if (penaltyCounterStart > 0) {
uint penaltyCounterEnd = penaltyCounterStart + params.penaltyPeriod();
if (penaltyCounterEnd < block.timestamp) {
return block.timestamp - penaltyCounterEnd;
}
}
return 0;
}
/**
* @notice Returns the accumulated interest factor for the pool
* @dev Used to calculate the base debt for borrowers
* @return The accumulated interest factor in WAD (1e18) precision
*/
function accumulatedInterestFactor() public view returns (uint) {
if (storedAccInterestFactor == 0) {
return WAD;
} else {
// newFactor = oldFactor * (1 + ratePerSecond)^secondsSinceLastUpdate
return storedAccInterestFactor.mulDiv(
WadMath.wadPow(
WAD + interestRate(),
block.timestamp - lastAccumulatedInterestUpdate
),
WAD,
Math.Rounding.Ceil
);
}
}
/**
* @notice Returns the current interest rate for the pool
* @dev The maximum interest rate is 1000% annual, represented as a per-second rate in WAD (1e18) precision
* @return The interest rate per-second in WAD (1e18) precision
*/
function interestRate() public view returns (uint) {
uint rate = params.interestRate(_utilizationRate(storedAccInterestFactor));
if (rate > MAX_INTEREST_RATE) {
return MAX_INTEREST_RATE;
}
return rate;
}
/**
* @notice Internal function to handle debt repayment
* @dev Handles both base debt and penalty debt repayment
* @param amount The amount of assets to repay
* @param borrower The borrower's address
* @param forgive If true, debt is forgiven without requiring asset transfer
* @custom:revert ZeroRepayment If amount is 0
* @custom:revert NoDebt If the borrower has no outstanding debt
*/
function _repay(uint amount, address borrower, bool forgive) internal nonReentrant() {
if (amount == 0) {
revert ZeroRepayment();
}
_updateAccumulatedInterestFactor();
uint baseDebt_ = _baseDebt(borrower, storedAccInterestFactor);
if (baseDebt_ == 0) {
revert NoDebt();
}
uint baseDebtPayment_;
uint penaltyDebt_ = _penaltyDebt(borrower, storedAccInterestFactor);
uint penaltyPayment_ = 0;
uint newPenaltyCounterStart_ = borrowers[borrower].penaltyCounterStart;
if (penaltyDebt_ > 0) {
if (amount > penaltyDebt_) {
// payment amount is greater than penalty debt.
// after penalty debt is paid, the remaining amount goes to base debt payment
baseDebtPayment_ = amount - penaltyDebt_;
// set penalty payment to full penalty debt amount
penaltyPayment_ = penaltyDebt_;
// remove all penalty time so that borrower is at the end of the penalty grace period
newPenaltyCounterStart_ += penaltyTime(borrower);
} else {
// payment amount is less than or equal to penalty debt
penaltyPayment_ = amount;
// remove penalty time proportionally to the amount of penalty debt repaid
newPenaltyCounterStart_ += penaltyTime(borrower).mulDiv(penaltyPayment_, penaltyDebt_);
}
emit PenaltyRepayment(borrower, penaltyDebt_, penaltyPayment_);
} else {
// no penalty debt, full payment amount is used to pay base debt
baseDebtPayment_ = amount;
}
if (baseDebtPayment_ > 0) {
if (baseDebtPayment_ >= baseDebt_) {
// full repayment of base debt.
// clear penalty counter start time.
newPenaltyCounterStart_ = 0;
// set base debt payment to base debt amount, in case of overpayment
baseDebtPayment_ = baseDebt_;
} else {
// partial repayment of base debt.
// decrease time until penalty based on the amount of base debt repaid.
newPenaltyCounterStart_ += (block.timestamp - newPenaltyCounterStart_).mulDiv(baseDebtPayment_, baseDebt_);
}
uint scaledDebt_ = baseDebtPayment_.mulDiv(WAD, storedAccInterestFactor, Math.Rounding.Ceil);
borrowers[borrower].scaledDebt -= scaledDebt_;
scaledReceivables -= scaledDebt_;
emit BaseDebtRepayment(borrower, baseDebt_, baseDebtPayment_);
}
// adjust penalty counter start time
borrowers[borrower].penaltyCounterStart = newPenaltyCounterStart_;
if (!forgive) {
IERC20(asset()).safeTransferFrom(msg.sender, address(this), baseDebtPayment_ + penaltyPayment_);
}
}
/**
* @notice ERC4626 override to handle deposit
* @dev Updates the accumulated interest factor after deposit, because deposit will decrease
* the utlization rate which will decrease the pool's interest rate
* @param caller The caller's address
* @param receiver The receiver's address
* @param assets The amount of assets to deposit
* @param shares The amount of shares to mint
*/
function _deposit(
address caller,
address receiver,
uint256 assets,
uint256 shares
) internal override nonReentrant() {
ERC4626._deposit(caller, receiver, assets, shares);
_updateAccumulatedInterestFactor();
}
/**
* @notice ERC4626 override to handle withdraw
* @dev Updates the accumulated interest factor after withdraw, because withdraw will increase
* the utlization rate which will increase the pool's interest rate. If a shareholder owns more
* shares than the amount of unborrowed assets, the shareholder can only withdraw up to the amount
* of unborrowed assets, otherwise an InsufficientLiquidity error will be thrown.
* @param caller The caller's address
* @param receiver The receiver's address
* @param owner The owner's address
* @param assets The amount of assets to withdraw
* @param shares The amount of shares to burn
*/
function _withdraw(
address caller,
address receiver,
address owner,
uint256 assets,
uint256 shares
) internal override nonReentrant() {
if (assets > IERC20(asset()).balanceOf(address(this))) {
revert InsufficientLiquidity();
}
ERC4626._withdraw(caller, receiver, owner, assets, shares);
_updateAccumulatedInterestFactor();
}
/**
* @notice Internal function to update the accumulated interest factor
* @dev Updates the stored accumulated interest factor and the last update timestamp
*/
function _updateAccumulatedInterestFactor () internal {
storedAccInterestFactor = accumulatedInterestFactor();
lastAccumulatedInterestUpdate = block.timestamp;
}
/**
* @notice Internal function to calculate the utilization rate
* @dev Utilization rate = Total Receivables / Total Assets
* @param accInterestFactor The accumulated interest factor
* @return The utilization rate in WAD (1e18) precision
*/
function _utilizationRate(uint accInterestFactor) internal view returns (uint) {
uint totalReceivables_ = _totalReceivables(accInterestFactor);
uint totalAssets_ = totalReceivables_ + IERC20(asset()).balanceOf(address(this));
return totalReceivables_.mulDiv(WAD, totalAssets_);
}
/**
* @notice Internal function to calculate the total receivables
* @dev Total receivables = scaled receivables * accumulated interest factor
* @param accInterestFactor The accumulated interest factor
* @return The total receivables amount
*/
function _totalReceivables(uint accInterestFactor) internal view returns (uint) {
return scaledReceivables.mulDiv(accInterestFactor, WAD);
}
/**
* @notice Internal function to calculate the base debt for a borrower
* @dev Base debt = scaled debt * accumulated interest factor
* @param borrower The borrower's address
* @param accInterestFactor The accumulated interest factor
* @return The base debt amount for the borrower
*/
function _baseDebt(address borrower, uint accInterestFactor) internal view returns (uint) {
return borrowers[borrower].scaledDebt.mulDiv(accInterestFactor, WAD);
}
/**
* @notice Internal function to calculate the penalty debt for a borrower
* @dev Penalty debt = base debt * penalty time * penalty rate
* @param borrower The borrower's address
* @param accInterestFactor The accumulated interest factor
* @return The penalty debt amount for the borrower
*/
function _penaltyDebt(address borrower, uint accInterestFactor) internal view returns (uint) {
uint penaltyTime_ = penaltyTime(borrower);
if (penaltyTime_ == 0) return 0;
return (_baseDebt(borrower, accInterestFactor) * penaltyTime_).mulDiv(params.penaltyRate(), WAD);
}
}// SPDX-License-Identifier: GPL-3.0-or-later
pragma solidity ^0.8.0;
import {IInventoryPoolParams01} from "./IInventoryPoolParams01.sol";
interface IInventoryPool01 {
event Borrowed(address indexed borrower, address indexed recipient, uint amount);
event PenaltyRepayment(address indexed borrower, uint penaltyDebt, uint penaltyPaymentAmount);
event BaseDebtRepayment(address indexed borrower, uint baseDebt, uint baseDebtPaymentAmount);
event ParamsContractUpgraded(IInventoryPoolParams01 indexed paramsContract);
error Expired();
error NoDebt();
error ZeroRepayment();
error InsufficientLiquidity();
error WrongChainId(uint chainId);
error ParamsContractNotChanged();
function borrow(uint amount, address borrower, address recipient, uint expiry, uint chainId) external;
function repay(uint amount, address borrower) external;
function upgradeParamsContract(IInventoryPoolParams01 paramsContract) external;
function totalAssets() external view returns (uint);
function totalReceivables() external view returns (uint);
function utilizationRate() external view returns (uint);
function baseDebt(address borrower) external view returns (uint);
function penaltyDebt(address borrower) external view returns (uint);
function penaltyTime(address borrower) external view returns (uint);
}// SPDX-License-Identifier: GPL-3.0-or-later
pragma solidity ^0.8.0;
interface IInventoryPoolParams01 {
error InvalidUtilizationRate(uint utilizationRate);
function baseFee() external view returns (uint);
function interestRate(uint utilizationRate) external view returns (uint);
function penaltyRate() external view returns (uint);
function penaltyPeriod() external view returns (uint);
}// SPDX-License-Identifier: GPL-3.0-or-later
pragma solidity ^0.8.0;
library WadMath {
uint256 internal constant WAD = 1e18;
uint256 internal constant halfWAD = WAD / 2;
function wad() internal pure returns (uint256) {
return WAD;
}
function halfWad() internal pure returns (uint256) {
return halfWAD;
}
function wadPow(uint256 x, uint256 n) internal pure returns (uint256 z) {
z = WAD;
while (n != 0) {
uint256 acc = x;
for (uint8 i = 0; i < 4; ++i) {
if ((n & (1 << i)) != 0) {
z = (z * acc + halfWAD) / WAD;
}
acc = (acc * acc + halfWAD) / WAD;
}
n >>= 4;
x = acc;
}
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (access/Ownable.sol)
pragma solidity ^0.8.20;
import {Context} from "../utils/Context.sol";
/**
* @dev Contract module which provides a basic access control mechanism, where
* there is an account (an owner) that can be granted exclusive access to
* specific functions.
*
* The initial owner is set to the address provided by the deployer. This can
* later be changed with {transferOwnership}.
*
* This module is used through inheritance. It will make available the modifier
* `onlyOwner`, which can be applied to your functions to restrict their use to
* the owner.
*/
abstract contract Ownable is Context {
address private _owner;
/**
* @dev The caller account is not authorized to perform an operation.
*/
error OwnableUnauthorizedAccount(address account);
/**
* @dev The owner is not a valid owner account. (eg. `address(0)`)
*/
error OwnableInvalidOwner(address owner);
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
/**
* @dev Initializes the contract setting the address provided by the deployer as the initial owner.
*/
constructor(address initialOwner) {
if (initialOwner == address(0)) {
revert OwnableInvalidOwner(address(0));
}
_transferOwnership(initialOwner);
}
/**
* @dev Throws if called by any account other than the owner.
*/
modifier onlyOwner() {
_checkOwner();
_;
}
/**
* @dev Returns the address of the current owner.
*/
function owner() public view virtual returns (address) {
return _owner;
}
/**
* @dev Throws if the sender is not the owner.
*/
function _checkOwner() internal view virtual {
if (owner() != _msgSender()) {
revert OwnableUnauthorizedAccount(_msgSender());
}
}
/**
* @dev Leaves the contract without owner. It will not be possible to call
* `onlyOwner` functions. Can only be called by the current owner.
*
* NOTE: Renouncing ownership will leave the contract without an owner,
* thereby disabling any functionality that is only available to the owner.
*/
function renounceOwnership() public virtual onlyOwner {
_transferOwnership(address(0));
}
/**
* @dev Transfers ownership of the contract to a new account (`newOwner`).
* Can only be called by the current owner.
*/
function transferOwnership(address newOwner) public virtual onlyOwner {
if (newOwner == address(0)) {
revert OwnableInvalidOwner(address(0));
}
_transferOwnership(newOwner);
}
/**
* @dev Transfers ownership of the contract to a new account (`newOwner`).
* Internal function without access restriction.
*/
function _transferOwnership(address newOwner) internal virtual {
address oldOwner = _owner;
_owner = newOwner;
emit OwnershipTransferred(oldOwner, newOwner);
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.1.0) (interfaces/IERC1363.sol)
pragma solidity ^0.8.20;
import {IERC20} from "./IERC20.sol";
import {IERC165} from "./IERC165.sol";
/**
* @title IERC1363
* @dev Interface of the ERC-1363 standard as defined in the https://eips.ethereum.org/EIPS/eip-1363[ERC-1363].
*
* Defines an extension interface for ERC-20 tokens that supports executing code on a recipient contract
* after `transfer` or `transferFrom`, or code on a spender contract after `approve`, in a single transaction.
*/
interface IERC1363 is IERC20, IERC165 {
/*
* Note: the ERC-165 identifier for this interface is 0xb0202a11.
* 0xb0202a11 ===
* bytes4(keccak256('transferAndCall(address,uint256)')) ^
* bytes4(keccak256('transferAndCall(address,uint256,bytes)')) ^
* bytes4(keccak256('transferFromAndCall(address,address,uint256)')) ^
* bytes4(keccak256('transferFromAndCall(address,address,uint256,bytes)')) ^
* bytes4(keccak256('approveAndCall(address,uint256)')) ^
* bytes4(keccak256('approveAndCall(address,uint256,bytes)'))
*/
/**
* @dev Moves a `value` amount of tokens from the caller's account to `to`
* and then calls {IERC1363Receiver-onTransferReceived} on `to`.
* @param to The address which you want to transfer to.
* @param value The amount of tokens to be transferred.
* @return A boolean value indicating whether the operation succeeded unless throwing.
*/
function transferAndCall(address to, uint256 value) external returns (bool);
/**
* @dev Moves a `value` amount of tokens from the caller's account to `to`
* and then calls {IERC1363Receiver-onTransferReceived} on `to`.
* @param to The address which you want to transfer to.
* @param value The amount of tokens to be transferred.
* @param data Additional data with no specified format, sent in call to `to`.
* @return A boolean value indicating whether the operation succeeded unless throwing.
*/
function transferAndCall(address to, uint256 value, bytes calldata data) external returns (bool);
/**
* @dev Moves a `value` amount of tokens from `from` to `to` using the allowance mechanism
* and then calls {IERC1363Receiver-onTransferReceived} on `to`.
* @param from The address which you want to send tokens from.
* @param to The address which you want to transfer to.
* @param value The amount of tokens to be transferred.
* @return A boolean value indicating whether the operation succeeded unless throwing.
*/
function transferFromAndCall(address from, address to, uint256 value) external returns (bool);
/**
* @dev Moves a `value` amount of tokens from `from` to `to` using the allowance mechanism
* and then calls {IERC1363Receiver-onTransferReceived} on `to`.
* @param from The address which you want to send tokens from.
* @param to The address which you want to transfer to.
* @param value The amount of tokens to be transferred.
* @param data Additional data with no specified format, sent in call to `to`.
* @return A boolean value indicating whether the operation succeeded unless throwing.
*/
function transferFromAndCall(address from, address to, uint256 value, bytes calldata data) external returns (bool);
/**
* @dev Sets a `value` amount of tokens as the allowance of `spender` over the
* caller's tokens and then calls {IERC1363Spender-onApprovalReceived} on `spender`.
* @param spender The address which will spend the funds.
* @param value The amount of tokens to be spent.
* @return A boolean value indicating whether the operation succeeded unless throwing.
*/
function approveAndCall(address spender, uint256 value) external returns (bool);
/**
* @dev Sets a `value` amount of tokens as the allowance of `spender` over the
* caller's tokens and then calls {IERC1363Spender-onApprovalReceived} on `spender`.
* @param spender The address which will spend the funds.
* @param value The amount of tokens to be spent.
* @param data Additional data with no specified format, sent in call to `spender`.
* @return A boolean value indicating whether the operation succeeded unless throwing.
*/
function approveAndCall(address spender, uint256 value, bytes calldata data) external returns (bool);
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (interfaces/IERC165.sol)
pragma solidity ^0.8.20;
import {IERC165} from "../utils/introspection/IERC165.sol";// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (interfaces/IERC20.sol)
pragma solidity ^0.8.20;
import {IERC20} from "../token/ERC20/IERC20.sol";// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.1.0) (interfaces/IERC4626.sol)
pragma solidity ^0.8.20;
import {IERC20} from "../token/ERC20/IERC20.sol";
import {IERC20Metadata} from "../token/ERC20/extensions/IERC20Metadata.sol";
/**
* @dev Interface of the ERC-4626 "Tokenized Vault Standard", as defined in
* https://eips.ethereum.org/EIPS/eip-4626[ERC-4626].
*/
interface IERC4626 is IERC20, IERC20Metadata {
event Deposit(address indexed sender, address indexed owner, uint256 assets, uint256 shares);
event Withdraw(
address indexed sender,
address indexed receiver,
address indexed owner,
uint256 assets,
uint256 shares
);
/**
* @dev Returns the address of the underlying token used for the Vault for accounting, depositing, and withdrawing.
*
* - MUST be an ERC-20 token contract.
* - MUST NOT revert.
*/
function asset() external view returns (address assetTokenAddress);
/**
* @dev Returns the total amount of the underlying asset that is “managed” by Vault.
*
* - SHOULD include any compounding that occurs from yield.
* - MUST be inclusive of any fees that are charged against assets in the Vault.
* - MUST NOT revert.
*/
function totalAssets() external view returns (uint256 totalManagedAssets);
/**
* @dev Returns the amount of shares that the Vault would exchange for the amount of assets provided, in an ideal
* scenario where all the conditions are met.
*
* - MUST NOT be inclusive of any fees that are charged against assets in the Vault.
* - MUST NOT show any variations depending on the caller.
* - MUST NOT reflect slippage or other on-chain conditions, when performing the actual exchange.
* - MUST NOT revert.
*
* NOTE: This calculation MAY NOT reflect the “per-user” price-per-share, and instead should reflect the
* “average-user’s” price-per-share, meaning what the average user should expect to see when exchanging to and
* from.
*/
function convertToShares(uint256 assets) external view returns (uint256 shares);
/**
* @dev Returns the amount of assets that the Vault would exchange for the amount of shares provided, in an ideal
* scenario where all the conditions are met.
*
* - MUST NOT be inclusive of any fees that are charged against assets in the Vault.
* - MUST NOT show any variations depending on the caller.
* - MUST NOT reflect slippage or other on-chain conditions, when performing the actual exchange.
* - MUST NOT revert.
*
* NOTE: This calculation MAY NOT reflect the “per-user” price-per-share, and instead should reflect the
* “average-user’s” price-per-share, meaning what the average user should expect to see when exchanging to and
* from.
*/
function convertToAssets(uint256 shares) external view returns (uint256 assets);
/**
* @dev Returns the maximum amount of the underlying asset that can be deposited into the Vault for the receiver,
* through a deposit call.
*
* - MUST return a limited value if receiver is subject to some deposit limit.
* - MUST return 2 ** 256 - 1 if there is no limit on the maximum amount of assets that may be deposited.
* - MUST NOT revert.
*/
function maxDeposit(address receiver) external view returns (uint256 maxAssets);
/**
* @dev Allows an on-chain or off-chain user to simulate the effects of their deposit at the current block, given
* current on-chain conditions.
*
* - MUST return as close to and no more than the exact amount of Vault shares that would be minted in a deposit
* call in the same transaction. I.e. deposit should return the same or more shares as previewDeposit if called
* in the same transaction.
* - MUST NOT account for deposit limits like those returned from maxDeposit and should always act as though the
* deposit would be accepted, regardless if the user has enough tokens approved, etc.
* - MUST be inclusive of deposit fees. Integrators should be aware of the existence of deposit fees.
* - MUST NOT revert.
*
* NOTE: any unfavorable discrepancy between convertToShares and previewDeposit SHOULD be considered slippage in
* share price or some other type of condition, meaning the depositor will lose assets by depositing.
*/
function previewDeposit(uint256 assets) external view returns (uint256 shares);
/**
* @dev Mints shares Vault shares to receiver by depositing exactly amount of underlying tokens.
*
* - MUST emit the Deposit event.
* - MAY support an additional flow in which the underlying tokens are owned by the Vault contract before the
* deposit execution, and are accounted for during deposit.
* - MUST revert if all of assets cannot be deposited (due to deposit limit being reached, slippage, the user not
* approving enough underlying tokens to the Vault contract, etc).
*
* NOTE: most implementations will require pre-approval of the Vault with the Vault’s underlying asset token.
*/
function deposit(uint256 assets, address receiver) external returns (uint256 shares);
/**
* @dev Returns the maximum amount of the Vault shares that can be minted for the receiver, through a mint call.
* - MUST return a limited value if receiver is subject to some mint limit.
* - MUST return 2 ** 256 - 1 if there is no limit on the maximum amount of shares that may be minted.
* - MUST NOT revert.
*/
function maxMint(address receiver) external view returns (uint256 maxShares);
/**
* @dev Allows an on-chain or off-chain user to simulate the effects of their mint at the current block, given
* current on-chain conditions.
*
* - MUST return as close to and no fewer than the exact amount of assets that would be deposited in a mint call
* in the same transaction. I.e. mint should return the same or fewer assets as previewMint if called in the
* same transaction.
* - MUST NOT account for mint limits like those returned from maxMint and should always act as though the mint
* would be accepted, regardless if the user has enough tokens approved, etc.
* - MUST be inclusive of deposit fees. Integrators should be aware of the existence of deposit fees.
* - MUST NOT revert.
*
* NOTE: any unfavorable discrepancy between convertToAssets and previewMint SHOULD be considered slippage in
* share price or some other type of condition, meaning the depositor will lose assets by minting.
*/
function previewMint(uint256 shares) external view returns (uint256 assets);
/**
* @dev Mints exactly shares Vault shares to receiver by depositing amount of underlying tokens.
*
* - MUST emit the Deposit event.
* - MAY support an additional flow in which the underlying tokens are owned by the Vault contract before the mint
* execution, and are accounted for during mint.
* - MUST revert if all of shares cannot be minted (due to deposit limit being reached, slippage, the user not
* approving enough underlying tokens to the Vault contract, etc).
*
* NOTE: most implementations will require pre-approval of the Vault with the Vault’s underlying asset token.
*/
function mint(uint256 shares, address receiver) external returns (uint256 assets);
/**
* @dev Returns the maximum amount of the underlying asset that can be withdrawn from the owner balance in the
* Vault, through a withdraw call.
*
* - MUST return a limited value if owner is subject to some withdrawal limit or timelock.
* - MUST NOT revert.
*/
function maxWithdraw(address owner) external view returns (uint256 maxAssets);
/**
* @dev Allows an on-chain or off-chain user to simulate the effects of their withdrawal at the current block,
* given current on-chain conditions.
*
* - MUST return as close to and no fewer than the exact amount of Vault shares that would be burned in a withdraw
* call in the same transaction. I.e. withdraw should return the same or fewer shares as previewWithdraw if
* called
* in the same transaction.
* - MUST NOT account for withdrawal limits like those returned from maxWithdraw and should always act as though
* the withdrawal would be accepted, regardless if the user has enough shares, etc.
* - MUST be inclusive of withdrawal fees. Integrators should be aware of the existence of withdrawal fees.
* - MUST NOT revert.
*
* NOTE: any unfavorable discrepancy between convertToShares and previewWithdraw SHOULD be considered slippage in
* share price or some other type of condition, meaning the depositor will lose assets by depositing.
*/
function previewWithdraw(uint256 assets) external view returns (uint256 shares);
/**
* @dev Burns shares from owner and sends exactly assets of underlying tokens to receiver.
*
* - MUST emit the Withdraw event.
* - MAY support an additional flow in which the underlying tokens are owned by the Vault contract before the
* withdraw execution, and are accounted for during withdraw.
* - MUST revert if all of assets cannot be withdrawn (due to withdrawal limit being reached, slippage, the owner
* not having enough shares, etc).
*
* Note that some implementations will require pre-requesting to the Vault before a withdrawal may be performed.
* Those methods should be performed separately.
*/
function withdraw(uint256 assets, address receiver, address owner) external returns (uint256 shares);
/**
* @dev Returns the maximum amount of Vault shares that can be redeemed from the owner balance in the Vault,
* through a redeem call.
*
* - MUST return a limited value if owner is subject to some withdrawal limit or timelock.
* - MUST return balanceOf(owner) if owner is not subject to any withdrawal limit or timelock.
* - MUST NOT revert.
*/
function maxRedeem(address owner) external view returns (uint256 maxShares);
/**
* @dev Allows an on-chain or off-chain user to simulate the effects of their redeemption at the current block,
* given current on-chain conditions.
*
* - MUST return as close to and no more than the exact amount of assets that would be withdrawn in a redeem call
* in the same transaction. I.e. redeem should return the same or more assets as previewRedeem if called in the
* same transaction.
* - MUST NOT account for redemption limits like those returned from maxRedeem and should always act as though the
* redemption would be accepted, regardless if the user has enough shares, etc.
* - MUST be inclusive of withdrawal fees. Integrators should be aware of the existence of withdrawal fees.
* - MUST NOT revert.
*
* NOTE: any unfavorable discrepancy between convertToAssets and previewRedeem SHOULD be considered slippage in
* share price or some other type of condition, meaning the depositor will lose assets by redeeming.
*/
function previewRedeem(uint256 shares) external view returns (uint256 assets);
/**
* @dev Burns exactly shares from owner and sends assets of underlying tokens to receiver.
*
* - MUST emit the Withdraw event.
* - MAY support an additional flow in which the underlying tokens are owned by the Vault contract before the
* redeem execution, and are accounted for during redeem.
* - MUST revert if all of shares cannot be redeemed (due to withdrawal limit being reached, slippage, the owner
* not having enough shares, etc).
*
* NOTE: some implementations will require pre-requesting to the Vault before a withdrawal may be performed.
* Those methods should be performed separately.
*/
function redeem(uint256 shares, address receiver, address owner) external returns (uint256 assets);
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.1.0) (interfaces/draft-IERC6093.sol)
pragma solidity ^0.8.20;
/**
* @dev Standard ERC-20 Errors
* Interface of the https://eips.ethereum.org/EIPS/eip-6093[ERC-6093] custom errors for ERC-20 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 ERC-721 Errors
* Interface of the https://eips.ethereum.org/EIPS/eip-6093[ERC-6093] custom errors for ERC-721 tokens.
*/
interface IERC721Errors {
/**
* @dev Indicates that an address can't be an owner. For example, `address(0)` is a forbidden owner in ERC-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 ERC-1155 Errors
* Interface of the https://eips.ethereum.org/EIPS/eip-6093[ERC-6093] custom errors for ERC-1155 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: MIT
// OpenZeppelin Contracts (last updated v5.2.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 ERC-20
* applications.
*/
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}.
*
* Skips emitting an {Approval} event indicating an allowance update. This is not
* required by the ERC. See {xref-ERC20-_approve-address-address-uint256-bool-}[_approve].
*
* 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:
*
* ```solidity
* 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: MIT
// OpenZeppelin Contracts (last updated v5.1.0) (token/ERC20/IERC20.sol)
pragma solidity ^0.8.20;
/**
* @dev Interface of the ERC-20 standard as defined in the ERC.
*/
interface IERC20 {
/**
* @dev Emitted when `value` tokens are moved from one account (`from`) to
* another (`to`).
*
* Note that `value` may be zero.
*/
event Transfer(address indexed from, address indexed to, uint256 value);
/**
* @dev Emitted when the allowance of a `spender` for an `owner` is set by
* a call to {approve}. `value` is the new allowance.
*/
event Approval(address indexed owner, address indexed spender, uint256 value);
/**
* @dev Returns the value of tokens in existence.
*/
function totalSupply() external view returns (uint256);
/**
* @dev Returns the value of tokens owned by `account`.
*/
function balanceOf(address account) external view returns (uint256);
/**
* @dev Moves a `value` amount of tokens from the caller's account to `to`.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transfer(address to, uint256 value) external returns (bool);
/**
* @dev Returns the remaining number of tokens that `spender` will be
* allowed to spend on behalf of `owner` through {transferFrom}. This is
* zero by default.
*
* This value changes when {approve} or {transferFrom} are called.
*/
function allowance(address owner, address spender) external view returns (uint256);
/**
* @dev Sets a `value` amount of tokens as the allowance of `spender` over the
* caller's tokens.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* IMPORTANT: Beware that changing an allowance with this method brings the risk
* that someone may use both the old and the new allowance by unfortunate
* transaction ordering. One possible solution to mitigate this race
* condition is to first reduce the spender's allowance to 0 and set the
* desired value afterwards:
* https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
*
* Emits an {Approval} event.
*/
function approve(address spender, uint256 value) external returns (bool);
/**
* @dev Moves a `value` amount of tokens from `from` to `to` using the
* allowance mechanism. `value` is then deducted from the caller's
* allowance.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transferFrom(address from, address to, uint256 value) external returns (bool);
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.1.0) (token/ERC20/extensions/ERC4626.sol)
pragma solidity ^0.8.20;
import {IERC20, IERC20Metadata, ERC20} from "../ERC20.sol";
import {SafeERC20} from "../utils/SafeERC20.sol";
import {IERC4626} from "../../../interfaces/IERC4626.sol";
import {Math} from "../../../utils/math/Math.sol";
/**
* @dev Implementation of the ERC-4626 "Tokenized Vault Standard" as defined in
* https://eips.ethereum.org/EIPS/eip-4626[ERC-4626].
*
* This extension allows the minting and burning of "shares" (represented using the ERC-20 inheritance) in exchange for
* underlying "assets" through standardized {deposit}, {mint}, {redeem} and {burn} workflows. This contract extends
* the ERC-20 standard. Any additional extensions included along it would affect the "shares" token represented by this
* contract and not the "assets" token which is an independent contract.
*
* [CAUTION]
* ====
* In empty (or nearly empty) ERC-4626 vaults, deposits are at high risk of being stolen through frontrunning
* with a "donation" to the vault that inflates the price of a share. This is variously known as a donation or inflation
* attack and is essentially a problem of slippage. Vault deployers can protect against this attack by making an initial
* deposit of a non-trivial amount of the asset, such that price manipulation becomes infeasible. Withdrawals may
* similarly be affected by slippage. Users can protect against this attack as well as unexpected slippage in general by
* verifying the amount received is as expected, using a wrapper that performs these checks such as
* https://github.com/fei-protocol/ERC4626#erc4626router-and-base[ERC4626Router].
*
* Since v4.9, this implementation introduces configurable virtual assets and shares to help developers mitigate that risk.
* The `_decimalsOffset()` corresponds to an offset in the decimal representation between the underlying asset's decimals
* and the vault decimals. This offset also determines the rate of virtual shares to virtual assets in the vault, which
* itself determines the initial exchange rate. While not fully preventing the attack, analysis shows that the default
* offset (0) makes it non-profitable even if an attacker is able to capture value from multiple user deposits, as a result
* of the value being captured by the virtual shares (out of the attacker's donation) matching the attacker's expected gains.
* With a larger offset, the attack becomes orders of magnitude more expensive than it is profitable. More details about the
* underlying math can be found xref:erc4626.adoc#inflation-attack[here].
*
* The drawback of this approach is that the virtual shares do capture (a very small) part of the value being accrued
* to the vault. Also, if the vault experiences losses, the users try to exit the vault, the virtual shares and assets
* will cause the first user to exit to experience reduced losses in detriment to the last users that will experience
* bigger losses. Developers willing to revert back to the pre-v4.9 behavior just need to override the
* `_convertToShares` and `_convertToAssets` functions.
*
* To learn more, check out our xref:ROOT:erc4626.adoc[ERC-4626 guide].
* ====
*/
abstract contract ERC4626 is ERC20, IERC4626 {
using Math for uint256;
IERC20 private immutable _asset;
uint8 private immutable _underlyingDecimals;
/**
* @dev Attempted to deposit more assets than the max amount for `receiver`.
*/
error ERC4626ExceededMaxDeposit(address receiver, uint256 assets, uint256 max);
/**
* @dev Attempted to mint more shares than the max amount for `receiver`.
*/
error ERC4626ExceededMaxMint(address receiver, uint256 shares, uint256 max);
/**
* @dev Attempted to withdraw more assets than the max amount for `receiver`.
*/
error ERC4626ExceededMaxWithdraw(address owner, uint256 assets, uint256 max);
/**
* @dev Attempted to redeem more shares than the max amount for `receiver`.
*/
error ERC4626ExceededMaxRedeem(address owner, uint256 shares, uint256 max);
/**
* @dev Set the underlying asset contract. This must be an ERC20-compatible contract (ERC-20 or ERC-777).
*/
constructor(IERC20 asset_) {
(bool success, uint8 assetDecimals) = _tryGetAssetDecimals(asset_);
_underlyingDecimals = success ? assetDecimals : 18;
_asset = asset_;
}
/**
* @dev Attempts to fetch the asset decimals. A return value of false indicates that the attempt failed in some way.
*/
function _tryGetAssetDecimals(IERC20 asset_) private view returns (bool ok, uint8 assetDecimals) {
(bool success, bytes memory encodedDecimals) = address(asset_).staticcall(
abi.encodeCall(IERC20Metadata.decimals, ())
);
if (success && encodedDecimals.length >= 32) {
uint256 returnedDecimals = abi.decode(encodedDecimals, (uint256));
if (returnedDecimals <= type(uint8).max) {
return (true, uint8(returnedDecimals));
}
}
return (false, 0);
}
/**
* @dev Decimals are computed by adding the decimal offset on top of the underlying asset's decimals. This
* "original" value is cached during construction of the vault contract. If this read operation fails (e.g., the
* asset has not been created yet), a default of 18 is used to represent the underlying asset's decimals.
*
* See {IERC20Metadata-decimals}.
*/
function decimals() public view virtual override(IERC20Metadata, ERC20) returns (uint8) {
return _underlyingDecimals + _decimalsOffset();
}
/** @dev See {IERC4626-asset}. */
function asset() public view virtual returns (address) {
return address(_asset);
}
/** @dev See {IERC4626-totalAssets}. */
function totalAssets() public view virtual returns (uint256) {
return _asset.balanceOf(address(this));
}
/** @dev See {IERC4626-convertToShares}. */
function convertToShares(uint256 assets) public view virtual returns (uint256) {
return _convertToShares(assets, Math.Rounding.Floor);
}
/** @dev See {IERC4626-convertToAssets}. */
function convertToAssets(uint256 shares) public view virtual returns (uint256) {
return _convertToAssets(shares, Math.Rounding.Floor);
}
/** @dev See {IERC4626-maxDeposit}. */
function maxDeposit(address) public view virtual returns (uint256) {
return type(uint256).max;
}
/** @dev See {IERC4626-maxMint}. */
function maxMint(address) public view virtual returns (uint256) {
return type(uint256).max;
}
/** @dev See {IERC4626-maxWithdraw}. */
function maxWithdraw(address owner) public view virtual returns (uint256) {
return _convertToAssets(balanceOf(owner), Math.Rounding.Floor);
}
/** @dev See {IERC4626-maxRedeem}. */
function maxRedeem(address owner) public view virtual returns (uint256) {
return balanceOf(owner);
}
/** @dev See {IERC4626-previewDeposit}. */
function previewDeposit(uint256 assets) public view virtual returns (uint256) {
return _convertToShares(assets, Math.Rounding.Floor);
}
/** @dev See {IERC4626-previewMint}. */
function previewMint(uint256 shares) public view virtual returns (uint256) {
return _convertToAssets(shares, Math.Rounding.Ceil);
}
/** @dev See {IERC4626-previewWithdraw}. */
function previewWithdraw(uint256 assets) public view virtual returns (uint256) {
return _convertToShares(assets, Math.Rounding.Ceil);
}
/** @dev See {IERC4626-previewRedeem}. */
function previewRedeem(uint256 shares) public view virtual returns (uint256) {
return _convertToAssets(shares, Math.Rounding.Floor);
}
/** @dev See {IERC4626-deposit}. */
function deposit(uint256 assets, address receiver) public virtual returns (uint256) {
uint256 maxAssets = maxDeposit(receiver);
if (assets > maxAssets) {
revert ERC4626ExceededMaxDeposit(receiver, assets, maxAssets);
}
uint256 shares = previewDeposit(assets);
_deposit(_msgSender(), receiver, assets, shares);
return shares;
}
/** @dev See {IERC4626-mint}. */
function mint(uint256 shares, address receiver) public virtual returns (uint256) {
uint256 maxShares = maxMint(receiver);
if (shares > maxShares) {
revert ERC4626ExceededMaxMint(receiver, shares, maxShares);
}
uint256 assets = previewMint(shares);
_deposit(_msgSender(), receiver, assets, shares);
return assets;
}
/** @dev See {IERC4626-withdraw}. */
function withdraw(uint256 assets, address receiver, address owner) public virtual returns (uint256) {
uint256 maxAssets = maxWithdraw(owner);
if (assets > maxAssets) {
revert ERC4626ExceededMaxWithdraw(owner, assets, maxAssets);
}
uint256 shares = previewWithdraw(assets);
_withdraw(_msgSender(), receiver, owner, assets, shares);
return shares;
}
/** @dev See {IERC4626-redeem}. */
function redeem(uint256 shares, address receiver, address owner) public virtual returns (uint256) {
uint256 maxShares = maxRedeem(owner);
if (shares > maxShares) {
revert ERC4626ExceededMaxRedeem(owner, shares, maxShares);
}
uint256 assets = previewRedeem(shares);
_withdraw(_msgSender(), receiver, owner, assets, shares);
return assets;
}
/**
* @dev Internal conversion function (from assets to shares) with support for rounding direction.
*/
function _convertToShares(uint256 assets, Math.Rounding rounding) internal view virtual returns (uint256) {
return assets.mulDiv(totalSupply() + 10 ** _decimalsOffset(), totalAssets() + 1, rounding);
}
/**
* @dev Internal conversion function (from shares to assets) with support for rounding direction.
*/
function _convertToAssets(uint256 shares, Math.Rounding rounding) internal view virtual returns (uint256) {
return shares.mulDiv(totalAssets() + 1, totalSupply() + 10 ** _decimalsOffset(), rounding);
}
/**
* @dev Deposit/mint common workflow.
*/
function _deposit(address caller, address receiver, uint256 assets, uint256 shares) internal virtual {
// If _asset is ERC-777, `transferFrom` can trigger a reentrancy BEFORE the transfer happens through the
// `tokensToSend` hook. On the other hand, the `tokenReceived` hook, that is triggered after the transfer,
// calls the vault, which is assumed not malicious.
//
// Conclusion: we need to do the transfer before we mint so that any reentrancy would happen before the
// assets are transferred and before the shares are minted, which is a valid state.
// slither-disable-next-line reentrancy-no-eth
SafeERC20.safeTransferFrom(_asset, caller, address(this), assets);
_mint(receiver, shares);
emit Deposit(caller, receiver, assets, shares);
}
/**
* @dev Withdraw/redeem common workflow.
*/
function _withdraw(
address caller,
address receiver,
address owner,
uint256 assets,
uint256 shares
) internal virtual {
if (caller != owner) {
_spendAllowance(owner, caller, shares);
}
// If _asset is ERC-777, `transfer` can trigger a reentrancy AFTER the transfer happens through the
// `tokensReceived` hook. On the other hand, the `tokensToSend` hook, that is triggered before the transfer,
// calls the vault, which is assumed not malicious.
//
// Conclusion: we need to do the transfer after the burn so that any reentrancy would happen after the
// shares are burned and after the assets are transferred, which is a valid state.
_burn(owner, shares);
SafeERC20.safeTransfer(_asset, receiver, assets);
emit Withdraw(caller, receiver, owner, assets, shares);
}
function _decimalsOffset() internal view virtual returns (uint8) {
return 0;
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.1.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 ERC-20 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.2.0) (token/ERC20/utils/SafeERC20.sol)
pragma solidity ^0.8.20;
import {IERC20} from "../IERC20.sol";
import {IERC1363} from "../../../interfaces/IERC1363.sol";
/**
* @title SafeERC20
* @dev Wrappers around ERC-20 operations that throw on failure (when the token
* contract returns false). Tokens that return no value (and instead revert or
* throw on failure) are also supported, non-reverting calls are assumed to be
* successful.
* To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract,
* which allows you to call the safe operations as `token.safeTransfer(...)`, etc.
*/
library SafeERC20 {
/**
* @dev An operation with an ERC-20 token failed.
*/
error SafeERC20FailedOperation(address token);
/**
* @dev Indicates a failed `decreaseAllowance` request.
*/
error SafeERC20FailedDecreaseAllowance(address spender, uint256 currentAllowance, uint256 requestedDecrease);
/**
* @dev Transfer `value` amount of `token` from the calling contract to `to`. If `token` returns no value,
* non-reverting calls are assumed to be successful.
*/
function safeTransfer(IERC20 token, address to, uint256 value) internal {
_callOptionalReturn(token, abi.encodeCall(token.transfer, (to, value)));
}
/**
* @dev Transfer `value` amount of `token` from `from` to `to`, spending the approval given by `from` to the
* calling contract. If `token` returns no value, non-reverting calls are assumed to be successful.
*/
function safeTransferFrom(IERC20 token, address from, address to, uint256 value) internal {
_callOptionalReturn(token, abi.encodeCall(token.transferFrom, (from, to, value)));
}
/**
* @dev Increase the calling contract's allowance toward `spender` by `value`. If `token` returns no value,
* non-reverting calls are assumed to be successful.
*
* IMPORTANT: If the token implements ERC-7674 (ERC-20 with temporary allowance), and if the "client"
* smart contract uses ERC-7674 to set temporary allowances, then the "client" smart contract should avoid using
* this function. Performing a {safeIncreaseAllowance} or {safeDecreaseAllowance} operation on a token contract
* that has a non-zero temporary allowance (for that particular owner-spender) will result in unexpected behavior.
*/
function safeIncreaseAllowance(IERC20 token, address spender, uint256 value) internal {
uint256 oldAllowance = token.allowance(address(this), spender);
forceApprove(token, spender, oldAllowance + value);
}
/**
* @dev Decrease the calling contract's allowance toward `spender` by `requestedDecrease`. If `token` returns no
* value, non-reverting calls are assumed to be successful.
*
* IMPORTANT: If the token implements ERC-7674 (ERC-20 with temporary allowance), and if the "client"
* smart contract uses ERC-7674 to set temporary allowances, then the "client" smart contract should avoid using
* this function. Performing a {safeIncreaseAllowance} or {safeDecreaseAllowance} operation on a token contract
* that has a non-zero temporary allowance (for that particular owner-spender) will result in unexpected behavior.
*/
function safeDecreaseAllowance(IERC20 token, address spender, uint256 requestedDecrease) internal {
unchecked {
uint256 currentAllowance = token.allowance(address(this), spender);
if (currentAllowance < requestedDecrease) {
revert SafeERC20FailedDecreaseAllowance(spender, currentAllowance, requestedDecrease);
}
forceApprove(token, spender, currentAllowance - requestedDecrease);
}
}
/**
* @dev Set the calling contract's allowance toward `spender` to `value`. If `token` returns no value,
* non-reverting calls are assumed to be successful. Meant to be used with tokens that require the approval
* to be set to zero before setting it to a non-zero value, such as USDT.
*
* NOTE: If the token implements ERC-7674, this function will not modify any temporary allowance. This function
* only sets the "standard" allowance. Any temporary allowance will remain active, in addition to the value being
* set here.
*/
function forceApprove(IERC20 token, address spender, uint256 value) internal {
bytes memory approvalCall = abi.encodeCall(token.approve, (spender, value));
if (!_callOptionalReturnBool(token, approvalCall)) {
_callOptionalReturn(token, abi.encodeCall(token.approve, (spender, 0)));
_callOptionalReturn(token, approvalCall);
}
}
/**
* @dev Performs an {ERC1363} transferAndCall, with a fallback to the simple {ERC20} transfer if the target has no
* code. This can be used to implement an {ERC721}-like safe transfer that rely on {ERC1363} checks when
* targeting contracts.
*
* Reverts if the returned value is other than `true`.
*/
function transferAndCallRelaxed(IERC1363 token, address to, uint256 value, bytes memory data) internal {
if (to.code.length == 0) {
safeTransfer(token, to, value);
} else if (!token.transferAndCall(to, value, data)) {
revert SafeERC20FailedOperation(address(token));
}
}
/**
* @dev Performs an {ERC1363} transferFromAndCall, with a fallback to the simple {ERC20} transferFrom if the target
* has no code. This can be used to implement an {ERC721}-like safe transfer that rely on {ERC1363} checks when
* targeting contracts.
*
* Reverts if the returned value is other than `true`.
*/
function transferFromAndCallRelaxed(
IERC1363 token,
address from,
address to,
uint256 value,
bytes memory data
) internal {
if (to.code.length == 0) {
safeTransferFrom(token, from, to, value);
} else if (!token.transferFromAndCall(from, to, value, data)) {
revert SafeERC20FailedOperation(address(token));
}
}
/**
* @dev Performs an {ERC1363} approveAndCall, with a fallback to the simple {ERC20} approve if the target has no
* code. This can be used to implement an {ERC721}-like safe transfer that rely on {ERC1363} checks when
* targeting contracts.
*
* NOTE: When the recipient address (`to`) has no code (i.e. is an EOA), this function behaves as {forceApprove}.
* Opposedly, when the recipient address (`to`) has code, this function only attempts to call {ERC1363-approveAndCall}
* once without retrying, and relies on the returned value to be true.
*
* Reverts if the returned value is other than `true`.
*/
function approveAndCallRelaxed(IERC1363 token, address to, uint256 value, bytes memory data) internal {
if (to.code.length == 0) {
forceApprove(token, to, value);
} else if (!token.approveAndCall(to, value, data)) {
revert SafeERC20FailedOperation(address(token));
}
}
/**
* @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement
* on the return value: the return value is optional (but if data is returned, it must not be false).
* @param token The token targeted by the call.
* @param data The call data (encoded using abi.encode or one of its variants).
*
* This is a variant of {_callOptionalReturnBool} that reverts if call fails to meet the requirements.
*/
function _callOptionalReturn(IERC20 token, bytes memory data) private {
uint256 returnSize;
uint256 returnValue;
assembly ("memory-safe") {
let success := call(gas(), token, 0, add(data, 0x20), mload(data), 0, 0x20)
// bubble errors
if iszero(success) {
let ptr := mload(0x40)
returndatacopy(ptr, 0, returndatasize())
revert(ptr, returndatasize())
}
returnSize := returndatasize()
returnValue := mload(0)
}
if (returnSize == 0 ? address(token).code.length == 0 : returnValue != 1) {
revert SafeERC20FailedOperation(address(token));
}
}
/**
* @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement
* on the return value: the return value is optional (but if data is returned, it must not be false).
* @param token The token targeted by the call.
* @param data The call data (encoded using abi.encode or one of its variants).
*
* This is a variant of {_callOptionalReturn} that silently catches all reverts and returns a bool instead.
*/
function _callOptionalReturnBool(IERC20 token, bytes memory data) private returns (bool) {
bool success;
uint256 returnSize;
uint256 returnValue;
assembly ("memory-safe") {
success := call(gas(), token, 0, add(data, 0x20), mload(data), 0, 0x20)
returnSize := returndatasize()
returnValue := mload(0)
}
return success && (returnSize == 0 ? address(token).code.length > 0 : returnValue == 1);
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.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.1.0) (utils/Panic.sol)
pragma solidity ^0.8.20;
/**
* @dev Helper library for emitting standardized panic codes.
*
* ```solidity
* contract Example {
* using Panic for uint256;
*
* // Use any of the declared internal constants
* function foo() { Panic.GENERIC.panic(); }
*
* // Alternatively
* function foo() { Panic.panic(Panic.GENERIC); }
* }
* ```
*
* Follows the list from https://github.com/ethereum/solidity/blob/v0.8.24/libsolutil/ErrorCodes.h[libsolutil].
*
* _Available since v5.1._
*/
// slither-disable-next-line unused-state
library Panic {
/// @dev generic / unspecified error
uint256 internal constant GENERIC = 0x00;
/// @dev used by the assert() builtin
uint256 internal constant ASSERT = 0x01;
/// @dev arithmetic underflow or overflow
uint256 internal constant UNDER_OVERFLOW = 0x11;
/// @dev division or modulo by zero
uint256 internal constant DIVISION_BY_ZERO = 0x12;
/// @dev enum conversion error
uint256 internal constant ENUM_CONVERSION_ERROR = 0x21;
/// @dev invalid encoding in storage
uint256 internal constant STORAGE_ENCODING_ERROR = 0x22;
/// @dev empty array pop
uint256 internal constant EMPTY_ARRAY_POP = 0x31;
/// @dev array out of bounds access
uint256 internal constant ARRAY_OUT_OF_BOUNDS = 0x32;
/// @dev resource error (too large allocation or too large array)
uint256 internal constant RESOURCE_ERROR = 0x41;
/// @dev calling invalid internal function
uint256 internal constant INVALID_INTERNAL_FUNCTION = 0x51;
/// @dev Reverts with a panic code. Recommended to use with
/// the internal constants with predefined codes.
function panic(uint256 code) internal pure {
assembly ("memory-safe") {
mstore(0x00, 0x4e487b71)
mstore(0x20, code)
revert(0x1c, 0x24)
}
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.1.0) (utils/ReentrancyGuardTransient.sol)
pragma solidity ^0.8.24;
import {TransientSlot} from "./TransientSlot.sol";
/**
* @dev Variant of {ReentrancyGuard} that uses transient storage.
*
* NOTE: This variant only works on networks where EIP-1153 is available.
*
* _Available since v5.1._
*/
abstract contract ReentrancyGuardTransient {
using TransientSlot for *;
// keccak256(abi.encode(uint256(keccak256("openzeppelin.storage.ReentrancyGuard")) - 1)) & ~bytes32(uint256(0xff))
bytes32 private constant REENTRANCY_GUARD_STORAGE =
0x9b779b17422d0df92223018b32b4d1fa46e071723d6817e2486d003becc55f00;
/**
* @dev Unauthorized reentrant call.
*/
error ReentrancyGuardReentrantCall();
/**
* @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 (_reentrancyGuardEntered()) {
revert ReentrancyGuardReentrantCall();
}
// Any calls to nonReentrant after this point will fail
REENTRANCY_GUARD_STORAGE.asBoolean().tstore(true);
}
function _nonReentrantAfter() private {
REENTRANCY_GUARD_STORAGE.asBoolean().tstore(false);
}
/**
* @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 REENTRANCY_GUARD_STORAGE.asBoolean().tload();
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.1.0) (utils/TransientSlot.sol)
// This file was procedurally generated from scripts/generate/templates/TransientSlot.js.
pragma solidity ^0.8.24;
/**
* @dev Library for reading and writing value-types to specific transient storage slots.
*
* Transient slots are often used to store temporary values that are removed after the current transaction.
* This library helps with reading and writing to such slots without the need for inline assembly.
*
* * Example reading and writing values using transient storage:
* ```solidity
* contract Lock {
* using TransientSlot for *;
*
* // Define the slot. Alternatively, use the SlotDerivation library to derive the slot.
* bytes32 internal constant _LOCK_SLOT = 0xf4678858b2b588224636b8522b729e7722d32fc491da849ed75b3fdf3c84f542;
*
* modifier locked() {
* require(!_LOCK_SLOT.asBoolean().tload());
*
* _LOCK_SLOT.asBoolean().tstore(true);
* _;
* _LOCK_SLOT.asBoolean().tstore(false);
* }
* }
* ```
*
* TIP: Consider using this library along with {SlotDerivation}.
*/
library TransientSlot {
/**
* @dev UDVT that represent a slot holding a address.
*/
type AddressSlot is bytes32;
/**
* @dev Cast an arbitrary slot to a AddressSlot.
*/
function asAddress(bytes32 slot) internal pure returns (AddressSlot) {
return AddressSlot.wrap(slot);
}
/**
* @dev UDVT that represent a slot holding a bool.
*/
type BooleanSlot is bytes32;
/**
* @dev Cast an arbitrary slot to a BooleanSlot.
*/
function asBoolean(bytes32 slot) internal pure returns (BooleanSlot) {
return BooleanSlot.wrap(slot);
}
/**
* @dev UDVT that represent a slot holding a bytes32.
*/
type Bytes32Slot is bytes32;
/**
* @dev Cast an arbitrary slot to a Bytes32Slot.
*/
function asBytes32(bytes32 slot) internal pure returns (Bytes32Slot) {
return Bytes32Slot.wrap(slot);
}
/**
* @dev UDVT that represent a slot holding a uint256.
*/
type Uint256Slot is bytes32;
/**
* @dev Cast an arbitrary slot to a Uint256Slot.
*/
function asUint256(bytes32 slot) internal pure returns (Uint256Slot) {
return Uint256Slot.wrap(slot);
}
/**
* @dev UDVT that represent a slot holding a int256.
*/
type Int256Slot is bytes32;
/**
* @dev Cast an arbitrary slot to a Int256Slot.
*/
function asInt256(bytes32 slot) internal pure returns (Int256Slot) {
return Int256Slot.wrap(slot);
}
/**
* @dev Load the value held at location `slot` in transient storage.
*/
function tload(AddressSlot slot) internal view returns (address value) {
assembly ("memory-safe") {
value := tload(slot)
}
}
/**
* @dev Store `value` at location `slot` in transient storage.
*/
function tstore(AddressSlot slot, address value) internal {
assembly ("memory-safe") {
tstore(slot, value)
}
}
/**
* @dev Load the value held at location `slot` in transient storage.
*/
function tload(BooleanSlot slot) internal view returns (bool value) {
assembly ("memory-safe") {
value := tload(slot)
}
}
/**
* @dev Store `value` at location `slot` in transient storage.
*/
function tstore(BooleanSlot slot, bool value) internal {
assembly ("memory-safe") {
tstore(slot, value)
}
}
/**
* @dev Load the value held at location `slot` in transient storage.
*/
function tload(Bytes32Slot slot) internal view returns (bytes32 value) {
assembly ("memory-safe") {
value := tload(slot)
}
}
/**
* @dev Store `value` at location `slot` in transient storage.
*/
function tstore(Bytes32Slot slot, bytes32 value) internal {
assembly ("memory-safe") {
tstore(slot, value)
}
}
/**
* @dev Load the value held at location `slot` in transient storage.
*/
function tload(Uint256Slot slot) internal view returns (uint256 value) {
assembly ("memory-safe") {
value := tload(slot)
}
}
/**
* @dev Store `value` at location `slot` in transient storage.
*/
function tstore(Uint256Slot slot, uint256 value) internal {
assembly ("memory-safe") {
tstore(slot, value)
}
}
/**
* @dev Load the value held at location `slot` in transient storage.
*/
function tload(Int256Slot slot) internal view returns (int256 value) {
assembly ("memory-safe") {
value := tload(slot)
}
}
/**
* @dev Store `value` at location `slot` in transient storage.
*/
function tstore(Int256Slot slot, int256 value) internal {
assembly ("memory-safe") {
tstore(slot, value)
}
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.1.0) (utils/introspection/IERC165.sol)
pragma solidity ^0.8.20;
/**
* @dev Interface of the ERC-165 standard, as defined in the
* https://eips.ethereum.org/EIPS/eip-165[ERC].
*
* Implementers can declare support of contract interfaces, which can then be
* queried by others ({ERC165Checker}).
*
* For an implementation, see {ERC165}.
*/
interface IERC165 {
/**
* @dev Returns true if this contract implements the interface defined by
* `interfaceId`. See the corresponding
* https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[ERC section]
* to learn more about how these ids are created.
*
* This function call must use less than 30 000 gas.
*/
function supportsInterface(bytes4 interfaceId) external view returns (bool);
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.1.0) (utils/math/Math.sol)
pragma solidity ^0.8.20;
import {Panic} from "../Panic.sol";
import {SafeCast} from "./SafeCast.sol";
/**
* @dev Standard math utilities missing in the Solidity language.
*/
library Math {
enum Rounding {
Floor, // Toward negative infinity
Ceil, // Toward positive infinity
Trunc, // Toward zero
Expand // Away from zero
}
/**
* @dev Returns the addition of two unsigned integers, with an success flag (no overflow).
*/
function tryAdd(uint256 a, uint256 b) internal pure returns (bool success, uint256 result) {
unchecked {
uint256 c = a + b;
if (c < a) return (false, 0);
return (true, c);
}
}
/**
* @dev Returns the subtraction of two unsigned integers, with an success flag (no overflow).
*/
function trySub(uint256 a, uint256 b) internal pure returns (bool success, uint256 result) {
unchecked {
if (b > a) return (false, 0);
return (true, a - b);
}
}
/**
* @dev Returns the multiplication of two unsigned integers, with an success flag (no overflow).
*/
function tryMul(uint256 a, uint256 b) internal pure returns (bool success, uint256 result) {
unchecked {
// Gas optimization: this is cheaper than requiring 'a' not being zero, but the
// benefit is lost if 'b' is also tested.
// See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522
if (a == 0) return (true, 0);
uint256 c = a * b;
if (c / a != b) return (false, 0);
return (true, c);
}
}
/**
* @dev Returns the division of two unsigned integers, with a success flag (no division by zero).
*/
function tryDiv(uint256 a, uint256 b) internal pure returns (bool success, uint256 result) {
unchecked {
if (b == 0) return (false, 0);
return (true, a / b);
}
}
/**
* @dev Returns the remainder of dividing two unsigned integers, with a success flag (no division by zero).
*/
function tryMod(uint256 a, uint256 b) internal pure returns (bool success, uint256 result) {
unchecked {
if (b == 0) return (false, 0);
return (true, a % b);
}
}
/**
* @dev Branchless ternary evaluation for `a ? b : c`. Gas costs are constant.
*
* IMPORTANT: This function may reduce bytecode size and consume less gas when used standalone.
* However, the compiler may optimize Solidity ternary operations (i.e. `a ? b : c`) to only compute
* one branch when needed, making this function more expensive.
*/
function ternary(bool condition, uint256 a, uint256 b) internal pure returns (uint256) {
unchecked {
// branchless ternary works because:
// b ^ (a ^ b) == a
// b ^ 0 == b
return b ^ ((a ^ b) * SafeCast.toUint(condition));
}
}
/**
* @dev Returns the largest of two numbers.
*/
function max(uint256 a, uint256 b) internal pure returns (uint256) {
return ternary(a > b, a, b);
}
/**
* @dev Returns the smallest of two numbers.
*/
function min(uint256 a, uint256 b) internal pure returns (uint256) {
return ternary(a < b, a, b);
}
/**
* @dev Returns the average of two numbers. The result is rounded towards
* zero.
*/
function average(uint256 a, uint256 b) internal pure returns (uint256) {
// (a + b) / 2 can overflow.
return (a & b) + (a ^ b) / 2;
}
/**
* @dev Returns the ceiling of the division of two numbers.
*
* This differs from standard division with `/` in that it rounds towards infinity instead
* of rounding towards zero.
*/
function ceilDiv(uint256 a, uint256 b) internal pure returns (uint256) {
if (b == 0) {
// Guarantee the same behavior as in a regular Solidity division.
Panic.panic(Panic.DIVISION_BY_ZERO);
}
// The following calculation ensures accurate ceiling division without overflow.
// Since a is non-zero, (a - 1) / b will not overflow.
// The largest possible result occurs when (a - 1) / b is type(uint256).max,
// but the largest value we can obtain is type(uint256).max - 1, which happens
// when a = type(uint256).max and b = 1.
unchecked {
return SafeCast.toUint(a > 0) * ((a - 1) / b + 1);
}
}
/**
* @dev Calculates floor(x * y / denominator) with full precision. Throws if result overflows a uint256 or
* denominator == 0.
*
* Original credit to Remco Bloemen under MIT license (https://xn--2-umb.com/21/muldiv) with further edits by
* Uniswap Labs also under MIT license.
*/
function mulDiv(uint256 x, uint256 y, uint256 denominator) internal pure returns (uint256 result) {
unchecked {
// 512-bit multiply [prod1 prod0] = x * y. Compute the product mod 2²56 and mod 2²56 - 1, then use
// the Chinese Remainder Theorem to reconstruct the 512 bit result. The result is stored in two 256
// variables such that product = prod1 * 2²56 + prod0.
uint256 prod0 = x * y; // Least significant 256 bits of the product
uint256 prod1; // Most significant 256 bits of the product
assembly {
let mm := mulmod(x, y, not(0))
prod1 := sub(sub(mm, prod0), lt(mm, prod0))
}
// Handle non-overflow cases, 256 by 256 division.
if (prod1 == 0) {
// Solidity will revert if denominator == 0, unlike the div opcode on its own.
// The surrounding unchecked block does not change this fact.
// See https://docs.soliditylang.org/en/latest/control-structures.html#checked-or-unchecked-arithmetic.
return prod0 / denominator;
}
// Make sure the result is less than 2²56. Also prevents denominator == 0.
if (denominator <= prod1) {
Panic.panic(ternary(denominator == 0, Panic.DIVISION_BY_ZERO, Panic.UNDER_OVERFLOW));
}
///////////////////////////////////////////////
// 512 by 256 division.
///////////////////////////////////////////////
// Make division exact by subtracting the remainder from [prod1 prod0].
uint256 remainder;
assembly {
// Compute remainder using mulmod.
remainder := mulmod(x, y, denominator)
// Subtract 256 bit number from 512 bit number.
prod1 := sub(prod1, gt(remainder, prod0))
prod0 := sub(prod0, remainder)
}
// Factor powers of two out of denominator and compute largest power of two divisor of denominator.
// Always >= 1. See https://cs.stackexchange.com/q/138556/92363.
uint256 twos = denominator & (0 - denominator);
assembly {
// Divide denominator by twos.
denominator := div(denominator, twos)
// Divide [prod1 prod0] by twos.
prod0 := div(prod0, twos)
// Flip twos such that it is 2²56 / twos. If twos is zero, then it becomes one.
twos := add(div(sub(0, twos), twos), 1)
}
// Shift in bits from prod1 into prod0.
prod0 |= prod1 * twos;
// Invert denominator mod 2²56. Now that denominator is an odd number, it has an inverse modulo 2²56 such
// that denominator * inv = 1 mod 2²56. Compute the inverse by starting with a seed that is correct for
// four bits. That is, denominator * inv = 1 mod 24.
uint256 inverse = (3 * denominator) ^ 2;
// Use the Newton-Raphson iteration to improve the precision. Thanks to Hensel's lifting lemma, this also
// works in modular arithmetic, doubling the correct bits in each step.
inverse *= 2 - denominator * inverse; // inverse mod 28
inverse *= 2 - denominator * inverse; // inverse mod 2¹6
inverse *= 2 - denominator * inverse; // inverse mod 2³²
inverse *= 2 - denominator * inverse; // inverse mod 264
inverse *= 2 - denominator * inverse; // inverse mod 2¹²8
inverse *= 2 - denominator * inverse; // inverse mod 2²56
// Because the division is now exact we can divide by multiplying with the modular inverse of denominator.
// This will give us the correct result modulo 2²56. Since the preconditions guarantee that the outcome is
// less than 2²56, this is the final result. We don't need to compute the high bits of the result and prod1
// is no longer required.
result = prod0 * inverse;
return result;
}
}
/**
* @dev Calculates x * y / denominator with full precision, following the selected rounding direction.
*/
function mulDiv(uint256 x, uint256 y, uint256 denominator, Rounding rounding) internal pure returns (uint256) {
return mulDiv(x, y, denominator) + SafeCast.toUint(unsignedRoundsUp(rounding) && mulmod(x, y, denominator) > 0);
}
/**
* @dev Calculate the modular multiplicative inverse of a number in Z/nZ.
*
* If n is a prime, then Z/nZ is a field. In that case all elements are inversible, except 0.
* If n is not a prime, then Z/nZ is not a field, and some elements might not be inversible.
*
* If the input value is not inversible, 0 is returned.
*
* NOTE: If you know for sure that n is (big) a prime, it may be cheaper to use Fermat's little theorem and get the
* inverse using `Math.modExp(a, n - 2, n)`. See {invModPrime}.
*/
function invMod(uint256 a, uint256 n) internal pure returns (uint256) {
unchecked {
if (n == 0) return 0;
// The inverse modulo is calculated using the Extended Euclidean Algorithm (iterative version)
// Used to compute integers x and y such that: ax + ny = gcd(a, n).
// When the gcd is 1, then the inverse of a modulo n exists and it's x.
// ax + ny = 1
// ax = 1 + (-y)n
// ax = 1 (mod n) # x is the inverse of a modulo n
// If the remainder is 0 the gcd is n right away.
uint256 remainder = a % n;
uint256 gcd = n;
// Therefore the initial coefficients are:
// ax + ny = gcd(a, n) = n
// 0a + 1n = n
int256 x = 0;
int256 y = 1;
while (remainder != 0) {
uint256 quotient = gcd / remainder;
(gcd, remainder) = (
// The old remainder is the next gcd to try.
remainder,
// Compute the next remainder.
// Can't overflow given that (a % gcd) * (gcd // (a % gcd)) <= gcd
// where gcd is at most n (capped to type(uint256).max)
gcd - remainder * quotient
);
(x, y) = (
// Increment the coefficient of a.
y,
// Decrement the coefficient of n.
// Can overflow, but the result is casted to uint256 so that the
// next value of y is "wrapped around" to a value between 0 and n - 1.
x - y * int256(quotient)
);
}
if (gcd != 1) return 0; // No inverse exists.
return ternary(x < 0, n - uint256(-x), uint256(x)); // Wrap the result if it's negative.
}
}
/**
* @dev Variant of {invMod}. More efficient, but only works if `p` is known to be a prime greater than `2`.
*
* From https://en.wikipedia.org/wiki/Fermat%27s_little_theorem[Fermat's little theorem], we know that if p is
* prime, then `a**(p-1) = 1 mod p`. As a consequence, we have `a * a**(p-2) = 1 mod p`, which means that
* `a**(p-2)` is the modular multiplicative inverse of a in Fp.
*
* NOTE: this function does NOT check that `p` is a prime greater than `2`.
*/
function invModPrime(uint256 a, uint256 p) internal view returns (uint256) {
unchecked {
return Math.modExp(a, p - 2, p);
}
}
/**
* @dev Returns the modular exponentiation of the specified base, exponent and modulus (b ** e % m)
*
* Requirements:
* - modulus can't be zero
* - underlying staticcall to precompile must succeed
*
* IMPORTANT: The result is only valid if the underlying call succeeds. When using this function, make
* sure the chain you're using it on supports the precompiled contract for modular exponentiation
* at address 0x05 as specified in https://eips.ethereum.org/EIPS/eip-198[EIP-198]. Otherwise,
* the underlying function will succeed given the lack of a revert, but the result may be incorrectly
* interpreted as 0.
*/
function modExp(uint256 b, uint256 e, uint256 m) internal view returns (uint256) {
(bool success, uint256 result) = tryModExp(b, e, m);
if (!success) {
Panic.panic(Panic.DIVISION_BY_ZERO);
}
return result;
}
/**
* @dev Returns the modular exponentiation of the specified base, exponent and modulus (b ** e % m).
* It includes a success flag indicating if the operation succeeded. Operation will be marked as failed if trying
* to operate modulo 0 or if the underlying precompile reverted.
*
* IMPORTANT: The result is only valid if the success flag is true. When using this function, make sure the chain
* you're using it on supports the precompiled contract for modular exponentiation at address 0x05 as specified in
* https://eips.ethereum.org/EIPS/eip-198[EIP-198]. Otherwise, the underlying function will succeed given the lack
* of a revert, but the result may be incorrectly interpreted as 0.
*/
function tryModExp(uint256 b, uint256 e, uint256 m) internal view returns (bool success, uint256 result) {
if (m == 0) return (false, 0);
assembly ("memory-safe") {
let ptr := mload(0x40)
// | Offset | Content | Content (Hex) |
// |-----------|------------|--------------------------------------------------------------------|
// | 0x00:0x1f | size of b | 0x0000000000000000000000000000000000000000000000000000000000000020 |
// | 0x20:0x3f | size of e | 0x0000000000000000000000000000000000000000000000000000000000000020 |
// | 0x40:0x5f | size of m | 0x0000000000000000000000000000000000000000000000000000000000000020 |
// | 0x60:0x7f | value of b | 0x<.............................................................b> |
// | 0x80:0x9f | value of e | 0x<.............................................................e> |
// | 0xa0:0xbf | value of m | 0x<.............................................................m> |
mstore(ptr, 0x20)
mstore(add(ptr, 0x20), 0x20)
mstore(add(ptr, 0x40), 0x20)
mstore(add(ptr, 0x60), b)
mstore(add(ptr, 0x80), e)
mstore(add(ptr, 0xa0), m)
// Given the result < m, it's guaranteed to fit in 32 bytes,
// so we can use the memory scratch space located at offset 0.
success := staticcall(gas(), 0x05, ptr, 0xc0, 0x00, 0x20)
result := mload(0x00)
}
}
/**
* @dev Variant of {modExp} that supports inputs of arbitrary length.
*/
function modExp(bytes memory b, bytes memory e, bytes memory m) internal view returns (bytes memory) {
(bool success, bytes memory result) = tryModExp(b, e, m);
if (!success) {
Panic.panic(Panic.DIVISION_BY_ZERO);
}
return result;
}
/**
* @dev Variant of {tryModExp} that supports inputs of arbitrary length.
*/
function tryModExp(
bytes memory b,
bytes memory e,
bytes memory m
) internal view returns (bool success, bytes memory result) {
if (_zeroBytes(m)) return (false, new bytes(0));
uint256 mLen = m.length;
// Encode call args in result and move the free memory pointer
result = abi.encodePacked(b.length, e.length, mLen, b, e, m);
assembly ("memory-safe") {
let dataPtr := add(result, 0x20)
// Write result on top of args to avoid allocating extra memory.
success := staticcall(gas(), 0x05, dataPtr, mload(result), dataPtr, mLen)
// Overwrite the length.
// result.length > returndatasize() is guaranteed because returndatasize() == m.length
mstore(result, mLen)
// Set the memory pointer after the returned data.
mstore(0x40, add(dataPtr, mLen))
}
}
/**
* @dev Returns whether the provided byte array is zero.
*/
function _zeroBytes(bytes memory byteArray) private pure returns (bool) {
for (uint256 i = 0; i < byteArray.length; ++i) {
if (byteArray[i] != 0) {
return false;
}
}
return true;
}
/**
* @dev Returns the square root of a number. If the number is not a perfect square, the value is rounded
* towards zero.
*
* This method is based on Newton's method for computing square roots; the algorithm is restricted to only
* using integer operations.
*/
function sqrt(uint256 a) internal pure returns (uint256) {
unchecked {
// Take care of easy edge cases when a == 0 or a == 1
if (a <= 1) {
return a;
}
// In this function, we use Newton's method to get a root of `f(x) := x² - a`. It involves building a
// sequence x_n that converges toward sqrt(a). For each iteration x_n, we also define the error between
// the current value as `e_n = | x_n - sqrt(a) |`.
//
// For our first estimation, we consider `e` the smallest power of 2 which is bigger than the square root
// of the target. (i.e. `2**(e-1) = sqrt(a) < 2**e`). We know that `e = 128` because `(2¹²8)² = 2²56` is
// bigger than any uint256.
//
// By noticing that
// `2**(e-1) = sqrt(a) < 2**e ? (2**(e-1))² = a < (2**e)² ? 2**(2*e-2) = a < 2**(2*e)`
// we can deduce that `e - 1` is `log2(a) / 2`. We can thus compute `x_n = 2**(e-1)` using a method similar
// to the msb function.
uint256 aa = a;
uint256 xn = 1;
if (aa >= (1 << 128)) {
aa >>= 128;
xn <<= 64;
}
if (aa >= (1 << 64)) {
aa >>= 64;
xn <<= 32;
}
if (aa >= (1 << 32)) {
aa >>= 32;
xn <<= 16;
}
if (aa >= (1 << 16)) {
aa >>= 16;
xn <<= 8;
}
if (aa >= (1 << 8)) {
aa >>= 8;
xn <<= 4;
}
if (aa >= (1 << 4)) {
aa >>= 4;
xn <<= 2;
}
if (aa >= (1 << 2)) {
xn <<= 1;
}
// We now have x_n such that `x_n = 2**(e-1) = sqrt(a) < 2**e = 2 * x_n`. This implies e_n = 2**(e-1).
//
// We can refine our estimation by noticing that the middle of that interval minimizes the error.
// If we move x_n to equal 2**(e-1) + 2**(e-2), then we reduce the error to e_n = 2**(e-2).
// This is going to be our x_0 (and e_0)
xn = (3 * xn) >> 1; // e_0 := | x_0 - sqrt(a) | = 2**(e-2)
// From here, Newton's method give us:
// x_{n+1} = (x_n + a / x_n) / 2
//
// One should note that:
// x_{n+1}² - a = ((x_n + a / x_n) / 2)² - a
// = ((x_n² + a) / (2 * x_n))² - a
// = (x_n4 + 2 * a * x_n² + a²) / (4 * x_n²) - a
// = (x_n4 + 2 * a * x_n² + a² - 4 * a * x_n²) / (4 * x_n²)
// = (x_n4 - 2 * a * x_n² + a²) / (4 * x_n²)
// = (x_n² - a)² / (2 * x_n)²
// = ((x_n² - a) / (2 * x_n))²
// = 0
// Which proves that for all n = 1, sqrt(a) = x_n
//
// This gives us the proof of quadratic convergence of the sequence:
// e_{n+1} = | x_{n+1} - sqrt(a) |
// = | (x_n + a / x_n) / 2 - sqrt(a) |
// = | (x_n² + a - 2*x_n*sqrt(a)) / (2 * x_n) |
// = | (x_n - sqrt(a))² / (2 * x_n) |
// = | e_n² / (2 * x_n) |
// = e_n² / | (2 * x_n) |
//
// For the first iteration, we have a special case where x_0 is known:
// e_1 = e_0² / | (2 * x_0) |
// = (2**(e-2))² / (2 * (2**(e-1) + 2**(e-2)))
// = 2**(2*e-4) / (3 * 2**(e-1))
// = 2**(e-3) / 3
// = 2**(e-3-log2(3))
// = 2**(e-4.5)
//
// For the following iterations, we use the fact that, 2**(e-1) = sqrt(a) = x_n:
// e_{n+1} = e_n² / | (2 * x_n) |
// = (2**(e-k))² / (2 * 2**(e-1))
// = 2**(2*e-2*k) / 2**e
// = 2**(e-2*k)
xn = (xn + a / xn) >> 1; // e_1 := | x_1 - sqrt(a) | = 2**(e-4.5) -- special case, see above
xn = (xn + a / xn) >> 1; // e_2 := | x_2 - sqrt(a) | = 2**(e-9) -- general case with k = 4.5
xn = (xn + a / xn) >> 1; // e_3 := | x_3 - sqrt(a) | = 2**(e-18) -- general case with k = 9
xn = (xn + a / xn) >> 1; // e_4 := | x_4 - sqrt(a) | = 2**(e-36) -- general case with k = 18
xn = (xn + a / xn) >> 1; // e_5 := | x_5 - sqrt(a) | = 2**(e-72) -- general case with k = 36
xn = (xn + a / xn) >> 1; // e_6 := | x_6 - sqrt(a) | = 2**(e-144) -- general case with k = 72
// Because e = 128 (as discussed during the first estimation phase), we know have reached a precision
// e_6 = 2**(e-144) < 1. Given we're operating on integers, then we can ensure that xn is now either
// sqrt(a) or sqrt(a) + 1.
return xn - SafeCast.toUint(xn > a / xn);
}
}
/**
* @dev Calculates sqrt(a), following the selected rounding direction.
*/
function sqrt(uint256 a, Rounding rounding) internal pure returns (uint256) {
unchecked {
uint256 result = sqrt(a);
return result + SafeCast.toUint(unsignedRoundsUp(rounding) && result * result < a);
}
}
/**
* @dev Return the log in base 2 of a positive value rounded towards zero.
* Returns 0 if given 0.
*/
function log2(uint256 value) internal pure returns (uint256) {
uint256 result = 0;
uint256 exp;
unchecked {
exp = 128 * SafeCast.toUint(value > (1 << 128) - 1);
value >>= exp;
result += exp;
exp = 64 * SafeCast.toUint(value > (1 << 64) - 1);
value >>= exp;
result += exp;
exp = 32 * SafeCast.toUint(value > (1 << 32) - 1);
value >>= exp;
result += exp;
exp = 16 * SafeCast.toUint(value > (1 << 16) - 1);
value >>= exp;
result += exp;
exp = 8 * SafeCast.toUint(value > (1 << 8) - 1);
value >>= exp;
result += exp;
exp = 4 * SafeCast.toUint(value > (1 << 4) - 1);
value >>= exp;
result += exp;
exp = 2 * SafeCast.toUint(value > (1 << 2) - 1);
value >>= exp;
result += exp;
result += SafeCast.toUint(value > 1);
}
return result;
}
/**
* @dev Return the log in base 2, following the selected rounding direction, of a positive value.
* Returns 0 if given 0.
*/
function log2(uint256 value, Rounding rounding) internal pure returns (uint256) {
unchecked {
uint256 result = log2(value);
return result + SafeCast.toUint(unsignedRoundsUp(rounding) && 1 << result < value);
}
}
/**
* @dev Return the log in base 10 of a positive value rounded towards zero.
* Returns 0 if given 0.
*/
function log10(uint256 value) internal pure returns (uint256) {
uint256 result = 0;
unchecked {
if (value >= 10 ** 64) {
value /= 10 ** 64;
result += 64;
}
if (value >= 10 ** 32) {
value /= 10 ** 32;
result += 32;
}
if (value >= 10 ** 16) {
value /= 10 ** 16;
result += 16;
}
if (value >= 10 ** 8) {
value /= 10 ** 8;
result += 8;
}
if (value >= 10 ** 4) {
value /= 10 ** 4;
result += 4;
}
if (value >= 10 ** 2) {
value /= 10 ** 2;
result += 2;
}
if (value >= 10 ** 1) {
result += 1;
}
}
return result;
}
/**
* @dev Return the log in base 10, following the selected rounding direction, of a positive value.
* Returns 0 if given 0.
*/
function log10(uint256 value, Rounding rounding) internal pure returns (uint256) {
unchecked {
uint256 result = log10(value);
return result + SafeCast.toUint(unsignedRoundsUp(rounding) && 10 ** result < value);
}
}
/**
* @dev Return the log in base 256 of a positive value rounded towards zero.
* Returns 0 if given 0.
*
* Adding one to the result gives the number of pairs of hex symbols needed to represent `value` as a hex string.
*/
function log256(uint256 value) internal pure returns (uint256) {
uint256 result = 0;
uint256 isGt;
unchecked {
isGt = SafeCast.toUint(value > (1 << 128) - 1);
value >>= isGt * 128;
result += isGt * 16;
isGt = SafeCast.toUint(value > (1 << 64) - 1);
value >>= isGt * 64;
result += isGt * 8;
isGt = SafeCast.toUint(value > (1 << 32) - 1);
value >>= isGt * 32;
result += isGt * 4;
isGt = SafeCast.toUint(value > (1 << 16) - 1);
value >>= isGt * 16;
result += isGt * 2;
result += SafeCast.toUint(value > (1 << 8) - 1);
}
return result;
}
/**
* @dev Return the log in base 256, following the selected rounding direction, of a positive value.
* Returns 0 if given 0.
*/
function log256(uint256 value, Rounding rounding) internal pure returns (uint256) {
unchecked {
uint256 result = log256(value);
return result + SafeCast.toUint(unsignedRoundsUp(rounding) && 1 << (result << 3) < value);
}
}
/**
* @dev Returns whether a provided rounding mode is considered rounding up for unsigned integers.
*/
function unsignedRoundsUp(Rounding rounding) internal pure returns (bool) {
return uint8(rounding) % 2 == 1;
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.1.0) (utils/math/SafeCast.sol)
// This file was procedurally generated from scripts/generate/templates/SafeCast.js.
pragma solidity ^0.8.20;
/**
* @dev Wrappers over Solidity's uintXX/intXX/bool casting operators with added overflow
* checks.
*
* Downcasting from uint256/int256 in Solidity does not revert on overflow. This can
* easily result in undesired exploitation or bugs, since developers usually
* assume that overflows raise errors. `SafeCast` restores this intuition by
* reverting the transaction when such an operation overflows.
*
* Using this library instead of the unchecked operations eliminates an entire
* class of bugs, so it's recommended to use it always.
*/
library SafeCast {
/**
* @dev Value doesn't fit in an uint of `bits` size.
*/
error SafeCastOverflowedUintDowncast(uint8 bits, uint256 value);
/**
* @dev An int value doesn't fit in an uint of `bits` size.
*/
error SafeCastOverflowedIntToUint(int256 value);
/**
* @dev Value doesn't fit in an int of `bits` size.
*/
error SafeCastOverflowedIntDowncast(uint8 bits, int256 value);
/**
* @dev An uint value doesn't fit in an int of `bits` size.
*/
error SafeCastOverflowedUintToInt(uint256 value);
/**
* @dev Returns the downcasted uint248 from uint256, reverting on
* overflow (when the input is greater than largest uint248).
*
* Counterpart to Solidity's `uint248` operator.
*
* Requirements:
*
* - input must fit into 248 bits
*/
function toUint248(uint256 value) internal pure returns (uint248) {
if (value > type(uint248).max) {
revert SafeCastOverflowedUintDowncast(248, value);
}
return uint248(value);
}
/**
* @dev Returns the downcasted uint240 from uint256, reverting on
* overflow (when the input is greater than largest uint240).
*
* Counterpart to Solidity's `uint240` operator.
*
* Requirements:
*
* - input must fit into 240 bits
*/
function toUint240(uint256 value) internal pure returns (uint240) {
if (value > type(uint240).max) {
revert SafeCastOverflowedUintDowncast(240, value);
}
return uint240(value);
}
/**
* @dev Returns the downcasted uint232 from uint256, reverting on
* overflow (when the input is greater than largest uint232).
*
* Counterpart to Solidity's `uint232` operator.
*
* Requirements:
*
* - input must fit into 232 bits
*/
function toUint232(uint256 value) internal pure returns (uint232) {
if (value > type(uint232).max) {
revert SafeCastOverflowedUintDowncast(232, value);
}
return uint232(value);
}
/**
* @dev Returns the downcasted uint224 from uint256, reverting on
* overflow (when the input is greater than largest uint224).
*
* Counterpart to Solidity's `uint224` operator.
*
* Requirements:
*
* - input must fit into 224 bits
*/
function toUint224(uint256 value) internal pure returns (uint224) {
if (value > type(uint224).max) {
revert SafeCastOverflowedUintDowncast(224, value);
}
return uint224(value);
}
/**
* @dev Returns the downcasted uint216 from uint256, reverting on
* overflow (when the input is greater than largest uint216).
*
* Counterpart to Solidity's `uint216` operator.
*
* Requirements:
*
* - input must fit into 216 bits
*/
function toUint216(uint256 value) internal pure returns (uint216) {
if (value > type(uint216).max) {
revert SafeCastOverflowedUintDowncast(216, value);
}
return uint216(value);
}
/**
* @dev Returns the downcasted uint208 from uint256, reverting on
* overflow (when the input is greater than largest uint208).
*
* Counterpart to Solidity's `uint208` operator.
*
* Requirements:
*
* - input must fit into 208 bits
*/
function toUint208(uint256 value) internal pure returns (uint208) {
if (value > type(uint208).max) {
revert SafeCastOverflowedUintDowncast(208, value);
}
return uint208(value);
}
/**
* @dev Returns the downcasted uint200 from uint256, reverting on
* overflow (when the input is greater than largest uint200).
*
* Counterpart to Solidity's `uint200` operator.
*
* Requirements:
*
* - input must fit into 200 bits
*/
function toUint200(uint256 value) internal pure returns (uint200) {
if (value > type(uint200).max) {
revert SafeCastOverflowedUintDowncast(200, value);
}
return uint200(value);
}
/**
* @dev Returns the downcasted uint192 from uint256, reverting on
* overflow (when the input is greater than largest uint192).
*
* Counterpart to Solidity's `uint192` operator.
*
* Requirements:
*
* - input must fit into 192 bits
*/
function toUint192(uint256 value) internal pure returns (uint192) {
if (value > type(uint192).max) {
revert SafeCastOverflowedUintDowncast(192, value);
}
return uint192(value);
}
/**
* @dev Returns the downcasted uint184 from uint256, reverting on
* overflow (when the input is greater than largest uint184).
*
* Counterpart to Solidity's `uint184` operator.
*
* Requirements:
*
* - input must fit into 184 bits
*/
function toUint184(uint256 value) internal pure returns (uint184) {
if (value > type(uint184).max) {
revert SafeCastOverflowedUintDowncast(184, value);
}
return uint184(value);
}
/**
* @dev Returns the downcasted uint176 from uint256, reverting on
* overflow (when the input is greater than largest uint176).
*
* Counterpart to Solidity's `uint176` operator.
*
* Requirements:
*
* - input must fit into 176 bits
*/
function toUint176(uint256 value) internal pure returns (uint176) {
if (value > type(uint176).max) {
revert SafeCastOverflowedUintDowncast(176, value);
}
return uint176(value);
}
/**
* @dev Returns the downcasted uint168 from uint256, reverting on
* overflow (when the input is greater than largest uint168).
*
* Counterpart to Solidity's `uint168` operator.
*
* Requirements:
*
* - input must fit into 168 bits
*/
function toUint168(uint256 value) internal pure returns (uint168) {
if (value > type(uint168).max) {
revert SafeCastOverflowedUintDowncast(168, value);
}
return uint168(value);
}
/**
* @dev Returns the downcasted uint160 from uint256, reverting on
* overflow (when the input is greater than largest uint160).
*
* Counterpart to Solidity's `uint160` operator.
*
* Requirements:
*
* - input must fit into 160 bits
*/
function toUint160(uint256 value) internal pure returns (uint160) {
if (value > type(uint160).max) {
revert SafeCastOverflowedUintDowncast(160, value);
}
return uint160(value);
}
/**
* @dev Returns the downcasted uint152 from uint256, reverting on
* overflow (when the input is greater than largest uint152).
*
* Counterpart to Solidity's `uint152` operator.
*
* Requirements:
*
* - input must fit into 152 bits
*/
function toUint152(uint256 value) internal pure returns (uint152) {
if (value > type(uint152).max) {
revert SafeCastOverflowedUintDowncast(152, value);
}
return uint152(value);
}
/**
* @dev Returns the downcasted uint144 from uint256, reverting on
* overflow (when the input is greater than largest uint144).
*
* Counterpart to Solidity's `uint144` operator.
*
* Requirements:
*
* - input must fit into 144 bits
*/
function toUint144(uint256 value) internal pure returns (uint144) {
if (value > type(uint144).max) {
revert SafeCastOverflowedUintDowncast(144, value);
}
return uint144(value);
}
/**
* @dev Returns the downcasted uint136 from uint256, reverting on
* overflow (when the input is greater than largest uint136).
*
* Counterpart to Solidity's `uint136` operator.
*
* Requirements:
*
* - input must fit into 136 bits
*/
function toUint136(uint256 value) internal pure returns (uint136) {
if (value > type(uint136).max) {
revert SafeCastOverflowedUintDowncast(136, value);
}
return uint136(value);
}
/**
* @dev Returns the downcasted uint128 from uint256, reverting on
* overflow (when the input is greater than largest uint128).
*
* Counterpart to Solidity's `uint128` operator.
*
* Requirements:
*
* - input must fit into 128 bits
*/
function toUint128(uint256 value) internal pure returns (uint128) {
if (value > type(uint128).max) {
revert SafeCastOverflowedUintDowncast(128, value);
}
return uint128(value);
}
/**
* @dev Returns the downcasted uint120 from uint256, reverting on
* overflow (when the input is greater than largest uint120).
*
* Counterpart to Solidity's `uint120` operator.
*
* Requirements:
*
* - input must fit into 120 bits
*/
function toUint120(uint256 value) internal pure returns (uint120) {
if (value > type(uint120).max) {
revert SafeCastOverflowedUintDowncast(120, value);
}
return uint120(value);
}
/**
* @dev Returns the downcasted uint112 from uint256, reverting on
* overflow (when the input is greater than largest uint112).
*
* Counterpart to Solidity's `uint112` operator.
*
* Requirements:
*
* - input must fit into 112 bits
*/
function toUint112(uint256 value) internal pure returns (uint112) {
if (value > type(uint112).max) {
revert SafeCastOverflowedUintDowncast(112, value);
}
return uint112(value);
}
/**
* @dev Returns the downcasted uint104 from uint256, reverting on
* overflow (when the input is greater than largest uint104).
*
* Counterpart to Solidity's `uint104` operator.
*
* Requirements:
*
* - input must fit into 104 bits
*/
function toUint104(uint256 value) internal pure returns (uint104) {
if (value > type(uint104).max) {
revert SafeCastOverflowedUintDowncast(104, value);
}
return uint104(value);
}
/**
* @dev Returns the downcasted uint96 from uint256, reverting on
* overflow (when the input is greater than largest uint96).
*
* Counterpart to Solidity's `uint96` operator.
*
* Requirements:
*
* - input must fit into 96 bits
*/
function toUint96(uint256 value) internal pure returns (uint96) {
if (value > type(uint96).max) {
revert SafeCastOverflowedUintDowncast(96, value);
}
return uint96(value);
}
/**
* @dev Returns the downcasted uint88 from uint256, reverting on
* overflow (when the input is greater than largest uint88).
*
* Counterpart to Solidity's `uint88` operator.
*
* Requirements:
*
* - input must fit into 88 bits
*/
function toUint88(uint256 value) internal pure returns (uint88) {
if (value > type(uint88).max) {
revert SafeCastOverflowedUintDowncast(88, value);
}
return uint88(value);
}
/**
* @dev Returns the downcasted uint80 from uint256, reverting on
* overflow (when the input is greater than largest uint80).
*
* Counterpart to Solidity's `uint80` operator.
*
* Requirements:
*
* - input must fit into 80 bits
*/
function toUint80(uint256 value) internal pure returns (uint80) {
if (value > type(uint80).max) {
revert SafeCastOverflowedUintDowncast(80, value);
}
return uint80(value);
}
/**
* @dev Returns the downcasted uint72 from uint256, reverting on
* overflow (when the input is greater than largest uint72).
*
* Counterpart to Solidity's `uint72` operator.
*
* Requirements:
*
* - input must fit into 72 bits
*/
function toUint72(uint256 value) internal pure returns (uint72) {
if (value > type(uint72).max) {
revert SafeCastOverflowedUintDowncast(72, value);
}
return uint72(value);
}
/**
* @dev Returns the downcasted uint64 from uint256, reverting on
* overflow (when the input is greater than largest uint64).
*
* Counterpart to Solidity's `uint64` operator.
*
* Requirements:
*
* - input must fit into 64 bits
*/
function toUint64(uint256 value) internal pure returns (uint64) {
if (value > type(uint64).max) {
revert SafeCastOverflowedUintDowncast(64, value);
}
return uint64(value);
}
/**
* @dev Returns the downcasted uint56 from uint256, reverting on
* overflow (when the input is greater than largest uint56).
*
* Counterpart to Solidity's `uint56` operator.
*
* Requirements:
*
* - input must fit into 56 bits
*/
function toUint56(uint256 value) internal pure returns (uint56) {
if (value > type(uint56).max) {
revert SafeCastOverflowedUintDowncast(56, value);
}
return uint56(value);
}
/**
* @dev Returns the downcasted uint48 from uint256, reverting on
* overflow (when the input is greater than largest uint48).
*
* Counterpart to Solidity's `uint48` operator.
*
* Requirements:
*
* - input must fit into 48 bits
*/
function toUint48(uint256 value) internal pure returns (uint48) {
if (value > type(uint48).max) {
revert SafeCastOverflowedUintDowncast(48, value);
}
return uint48(value);
}
/**
* @dev Returns the downcasted uint40 from uint256, reverting on
* overflow (when the input is greater than largest uint40).
*
* Counterpart to Solidity's `uint40` operator.
*
* Requirements:
*
* - input must fit into 40 bits
*/
function toUint40(uint256 value) internal pure returns (uint40) {
if (value > type(uint40).max) {
revert SafeCastOverflowedUintDowncast(40, value);
}
return uint40(value);
}
/**
* @dev Returns the downcasted uint32 from uint256, reverting on
* overflow (when the input is greater than largest uint32).
*
* Counterpart to Solidity's `uint32` operator.
*
* Requirements:
*
* - input must fit into 32 bits
*/
function toUint32(uint256 value) internal pure returns (uint32) {
if (value > type(uint32).max) {
revert SafeCastOverflowedUintDowncast(32, value);
}
return uint32(value);
}
/**
* @dev Returns the downcasted uint24 from uint256, reverting on
* overflow (when the input is greater than largest uint24).
*
* Counterpart to Solidity's `uint24` operator.
*
* Requirements:
*
* - input must fit into 24 bits
*/
function toUint24(uint256 value) internal pure returns (uint24) {
if (value > type(uint24).max) {
revert SafeCastOverflowedUintDowncast(24, value);
}
return uint24(value);
}
/**
* @dev Returns the downcasted uint16 from uint256, reverting on
* overflow (when the input is greater than largest uint16).
*
* Counterpart to Solidity's `uint16` operator.
*
* Requirements:
*
* - input must fit into 16 bits
*/
function toUint16(uint256 value) internal pure returns (uint16) {
if (value > type(uint16).max) {
revert SafeCastOverflowedUintDowncast(16, value);
}
return uint16(value);
}
/**
* @dev Returns the downcasted uint8 from uint256, reverting on
* overflow (when the input is greater than largest uint8).
*
* Counterpart to Solidity's `uint8` operator.
*
* Requirements:
*
* - input must fit into 8 bits
*/
function toUint8(uint256 value) internal pure returns (uint8) {
if (value > type(uint8).max) {
revert SafeCastOverflowedUintDowncast(8, value);
}
return uint8(value);
}
/**
* @dev Converts a signed int256 into an unsigned uint256.
*
* Requirements:
*
* - input must be greater than or equal to 0.
*/
function toUint256(int256 value) internal pure returns (uint256) {
if (value < 0) {
revert SafeCastOverflowedIntToUint(value);
}
return uint256(value);
}
/**
* @dev Returns the downcasted int248 from int256, reverting on
* overflow (when the input is less than smallest int248 or
* greater than largest int248).
*
* Counterpart to Solidity's `int248` operator.
*
* Requirements:
*
* - input must fit into 248 bits
*/
function toInt248(int256 value) internal pure returns (int248 downcasted) {
downcasted = int248(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(248, value);
}
}
/**
* @dev Returns the downcasted int240 from int256, reverting on
* overflow (when the input is less than smallest int240 or
* greater than largest int240).
*
* Counterpart to Solidity's `int240` operator.
*
* Requirements:
*
* - input must fit into 240 bits
*/
function toInt240(int256 value) internal pure returns (int240 downcasted) {
downcasted = int240(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(240, value);
}
}
/**
* @dev Returns the downcasted int232 from int256, reverting on
* overflow (when the input is less than smallest int232 or
* greater than largest int232).
*
* Counterpart to Solidity's `int232` operator.
*
* Requirements:
*
* - input must fit into 232 bits
*/
function toInt232(int256 value) internal pure returns (int232 downcasted) {
downcasted = int232(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(232, value);
}
}
/**
* @dev Returns the downcasted int224 from int256, reverting on
* overflow (when the input is less than smallest int224 or
* greater than largest int224).
*
* Counterpart to Solidity's `int224` operator.
*
* Requirements:
*
* - input must fit into 224 bits
*/
function toInt224(int256 value) internal pure returns (int224 downcasted) {
downcasted = int224(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(224, value);
}
}
/**
* @dev Returns the downcasted int216 from int256, reverting on
* overflow (when the input is less than smallest int216 or
* greater than largest int216).
*
* Counterpart to Solidity's `int216` operator.
*
* Requirements:
*
* - input must fit into 216 bits
*/
function toInt216(int256 value) internal pure returns (int216 downcasted) {
downcasted = int216(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(216, value);
}
}
/**
* @dev Returns the downcasted int208 from int256, reverting on
* overflow (when the input is less than smallest int208 or
* greater than largest int208).
*
* Counterpart to Solidity's `int208` operator.
*
* Requirements:
*
* - input must fit into 208 bits
*/
function toInt208(int256 value) internal pure returns (int208 downcasted) {
downcasted = int208(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(208, value);
}
}
/**
* @dev Returns the downcasted int200 from int256, reverting on
* overflow (when the input is less than smallest int200 or
* greater than largest int200).
*
* Counterpart to Solidity's `int200` operator.
*
* Requirements:
*
* - input must fit into 200 bits
*/
function toInt200(int256 value) internal pure returns (int200 downcasted) {
downcasted = int200(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(200, value);
}
}
/**
* @dev Returns the downcasted int192 from int256, reverting on
* overflow (when the input is less than smallest int192 or
* greater than largest int192).
*
* Counterpart to Solidity's `int192` operator.
*
* Requirements:
*
* - input must fit into 192 bits
*/
function toInt192(int256 value) internal pure returns (int192 downcasted) {
downcasted = int192(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(192, value);
}
}
/**
* @dev Returns the downcasted int184 from int256, reverting on
* overflow (when the input is less than smallest int184 or
* greater than largest int184).
*
* Counterpart to Solidity's `int184` operator.
*
* Requirements:
*
* - input must fit into 184 bits
*/
function toInt184(int256 value) internal pure returns (int184 downcasted) {
downcasted = int184(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(184, value);
}
}
/**
* @dev Returns the downcasted int176 from int256, reverting on
* overflow (when the input is less than smallest int176 or
* greater than largest int176).
*
* Counterpart to Solidity's `int176` operator.
*
* Requirements:
*
* - input must fit into 176 bits
*/
function toInt176(int256 value) internal pure returns (int176 downcasted) {
downcasted = int176(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(176, value);
}
}
/**
* @dev Returns the downcasted int168 from int256, reverting on
* overflow (when the input is less than smallest int168 or
* greater than largest int168).
*
* Counterpart to Solidity's `int168` operator.
*
* Requirements:
*
* - input must fit into 168 bits
*/
function toInt168(int256 value) internal pure returns (int168 downcasted) {
downcasted = int168(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(168, value);
}
}
/**
* @dev Returns the downcasted int160 from int256, reverting on
* overflow (when the input is less than smallest int160 or
* greater than largest int160).
*
* Counterpart to Solidity's `int160` operator.
*
* Requirements:
*
* - input must fit into 160 bits
*/
function toInt160(int256 value) internal pure returns (int160 downcasted) {
downcasted = int160(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(160, value);
}
}
/**
* @dev Returns the downcasted int152 from int256, reverting on
* overflow (when the input is less than smallest int152 or
* greater than largest int152).
*
* Counterpart to Solidity's `int152` operator.
*
* Requirements:
*
* - input must fit into 152 bits
*/
function toInt152(int256 value) internal pure returns (int152 downcasted) {
downcasted = int152(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(152, value);
}
}
/**
* @dev Returns the downcasted int144 from int256, reverting on
* overflow (when the input is less than smallest int144 or
* greater than largest int144).
*
* Counterpart to Solidity's `int144` operator.
*
* Requirements:
*
* - input must fit into 144 bits
*/
function toInt144(int256 value) internal pure returns (int144 downcasted) {
downcasted = int144(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(144, value);
}
}
/**
* @dev Returns the downcasted int136 from int256, reverting on
* overflow (when the input is less than smallest int136 or
* greater than largest int136).
*
* Counterpart to Solidity's `int136` operator.
*
* Requirements:
*
* - input must fit into 136 bits
*/
function toInt136(int256 value) internal pure returns (int136 downcasted) {
downcasted = int136(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(136, value);
}
}
/**
* @dev Returns the downcasted int128 from int256, reverting on
* overflow (when the input is less than smallest int128 or
* greater than largest int128).
*
* Counterpart to Solidity's `int128` operator.
*
* Requirements:
*
* - input must fit into 128 bits
*/
function toInt128(int256 value) internal pure returns (int128 downcasted) {
downcasted = int128(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(128, value);
}
}
/**
* @dev Returns the downcasted int120 from int256, reverting on
* overflow (when the input is less than smallest int120 or
* greater than largest int120).
*
* Counterpart to Solidity's `int120` operator.
*
* Requirements:
*
* - input must fit into 120 bits
*/
function toInt120(int256 value) internal pure returns (int120 downcasted) {
downcasted = int120(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(120, value);
}
}
/**
* @dev Returns the downcasted int112 from int256, reverting on
* overflow (when the input is less than smallest int112 or
* greater than largest int112).
*
* Counterpart to Solidity's `int112` operator.
*
* Requirements:
*
* - input must fit into 112 bits
*/
function toInt112(int256 value) internal pure returns (int112 downcasted) {
downcasted = int112(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(112, value);
}
}
/**
* @dev Returns the downcasted int104 from int256, reverting on
* overflow (when the input is less than smallest int104 or
* greater than largest int104).
*
* Counterpart to Solidity's `int104` operator.
*
* Requirements:
*
* - input must fit into 104 bits
*/
function toInt104(int256 value) internal pure returns (int104 downcasted) {
downcasted = int104(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(104, value);
}
}
/**
* @dev Returns the downcasted int96 from int256, reverting on
* overflow (when the input is less than smallest int96 or
* greater than largest int96).
*
* Counterpart to Solidity's `int96` operator.
*
* Requirements:
*
* - input must fit into 96 bits
*/
function toInt96(int256 value) internal pure returns (int96 downcasted) {
downcasted = int96(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(96, value);
}
}
/**
* @dev Returns the downcasted int88 from int256, reverting on
* overflow (when the input is less than smallest int88 or
* greater than largest int88).
*
* Counterpart to Solidity's `int88` operator.
*
* Requirements:
*
* - input must fit into 88 bits
*/
function toInt88(int256 value) internal pure returns (int88 downcasted) {
downcasted = int88(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(88, value);
}
}
/**
* @dev Returns the downcasted int80 from int256, reverting on
* overflow (when the input is less than smallest int80 or
* greater than largest int80).
*
* Counterpart to Solidity's `int80` operator.
*
* Requirements:
*
* - input must fit into 80 bits
*/
function toInt80(int256 value) internal pure returns (int80 downcasted) {
downcasted = int80(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(80, value);
}
}
/**
* @dev Returns the downcasted int72 from int256, reverting on
* overflow (when the input is less than smallest int72 or
* greater than largest int72).
*
* Counterpart to Solidity's `int72` operator.
*
* Requirements:
*
* - input must fit into 72 bits
*/
function toInt72(int256 value) internal pure returns (int72 downcasted) {
downcasted = int72(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(72, value);
}
}
/**
* @dev Returns the downcasted int64 from int256, reverting on
* overflow (when the input is less than smallest int64 or
* greater than largest int64).
*
* Counterpart to Solidity's `int64` operator.
*
* Requirements:
*
* - input must fit into 64 bits
*/
function toInt64(int256 value) internal pure returns (int64 downcasted) {
downcasted = int64(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(64, value);
}
}
/**
* @dev Returns the downcasted int56 from int256, reverting on
* overflow (when the input is less than smallest int56 or
* greater than largest int56).
*
* Counterpart to Solidity's `int56` operator.
*
* Requirements:
*
* - input must fit into 56 bits
*/
function toInt56(int256 value) internal pure returns (int56 downcasted) {
downcasted = int56(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(56, value);
}
}
/**
* @dev Returns the downcasted int48 from int256, reverting on
* overflow (when the input is less than smallest int48 or
* greater than largest int48).
*
* Counterpart to Solidity's `int48` operator.
*
* Requirements:
*
* - input must fit into 48 bits
*/
function toInt48(int256 value) internal pure returns (int48 downcasted) {
downcasted = int48(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(48, value);
}
}
/**
* @dev Returns the downcasted int40 from int256, reverting on
* overflow (when the input is less than smallest int40 or
* greater than largest int40).
*
* Counterpart to Solidity's `int40` operator.
*
* Requirements:
*
* - input must fit into 40 bits
*/
function toInt40(int256 value) internal pure returns (int40 downcasted) {
downcasted = int40(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(40, value);
}
}
/**
* @dev Returns the downcasted int32 from int256, reverting on
* overflow (when the input is less than smallest int32 or
* greater than largest int32).
*
* Counterpart to Solidity's `int32` operator.
*
* Requirements:
*
* - input must fit into 32 bits
*/
function toInt32(int256 value) internal pure returns (int32 downcasted) {
downcasted = int32(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(32, value);
}
}
/**
* @dev Returns the downcasted int24 from int256, reverting on
* overflow (when the input is less than smallest int24 or
* greater than largest int24).
*
* Counterpart to Solidity's `int24` operator.
*
* Requirements:
*
* - input must fit into 24 bits
*/
function toInt24(int256 value) internal pure returns (int24 downcasted) {
downcasted = int24(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(24, value);
}
}
/**
* @dev Returns the downcasted int16 from int256, reverting on
* overflow (when the input is less than smallest int16 or
* greater than largest int16).
*
* Counterpart to Solidity's `int16` operator.
*
* Requirements:
*
* - input must fit into 16 bits
*/
function toInt16(int256 value) internal pure returns (int16 downcasted) {
downcasted = int16(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(16, value);
}
}
/**
* @dev Returns the downcasted int8 from int256, reverting on
* overflow (when the input is less than smallest int8 or
* greater than largest int8).
*
* Counterpart to Solidity's `int8` operator.
*
* Requirements:
*
* - input must fit into 8 bits
*/
function toInt8(int256 value) internal pure returns (int8 downcasted) {
downcasted = int8(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(8, value);
}
}
/**
* @dev Converts an unsigned uint256 into a signed int256.
*
* Requirements:
*
* - input must be less than or equal to maxInt256.
*/
function toInt256(uint256 value) internal pure returns (int256) {
// Note: Unsafe cast below is okay because `type(int256).max` is guaranteed to be positive
if (value > uint256(type(int256).max)) {
revert SafeCastOverflowedUintToInt(value);
}
return int256(value);
}
/**
* @dev Cast a boolean (false or true) to a uint256 (0 or 1) with no jump.
*/
function toUint(bool b) internal pure returns (uint256 u) {
assembly ("memory-safe") {
u := iszero(iszero(b))
}
}
}{
"evmVersion": "prague",
"metadata": {
"appendCBOR": true,
"bytecodeHash": "none",
"useLiteralContent": false
},
"optimizer": {
"enabled": true,
"runs": 200
},
"outputSelection": {
"*": {
"*": [
"evm.bytecode",
"evm.deployedBytecode",
"abi"
]
}
},
"remappings": [
"forge-std/=deploy/forge-std/src/",
"@openzeppelin/=node_modules/@openzeppelin/",
"@nomial-contracts-v1/=deploy/nomial-contracts-v1/src/",
"nomial-contracts-v1/=deploy/nomial-contracts-v1/src/"
],
"viaIR": true
}Contract Security Audit
- No Contract Security Audit Submitted- Submit Audit Here
Contract ABI
API[{"inputs":[{"internalType":"contract IERC20","name":"asset_","type":"address"},{"internalType":"string","name":"name","type":"string"},{"internalType":"string","name":"symbol","type":"string"},{"internalType":"uint256","name":"initAmount","type":"uint256"},{"internalType":"address","name":"owner","type":"address"},{"internalType":"contract IInventoryPoolParams01","name":"paramsContract","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"allowance","type":"uint256"},{"internalType":"uint256","name":"needed","type":"uint256"}],"name":"ERC20InsufficientAllowance","type":"error"},{"inputs":[{"internalType":"address","name":"sender","type":"address"},{"internalType":"uint256","name":"balance","type":"uint256"},{"internalType":"uint256","name":"needed","type":"uint256"}],"name":"ERC20InsufficientBalance","type":"error"},{"inputs":[{"internalType":"address","name":"approver","type":"address"}],"name":"ERC20InvalidApprover","type":"error"},{"inputs":[{"internalType":"address","name":"receiver","type":"address"}],"name":"ERC20InvalidReceiver","type":"error"},{"inputs":[{"internalType":"address","name":"sender","type":"address"}],"name":"ERC20InvalidSender","type":"error"},{"inputs":[{"internalType":"address","name":"spender","type":"address"}],"name":"ERC20InvalidSpender","type":"error"},{"inputs":[{"internalType":"address","name":"receiver","type":"address"},{"internalType":"uint256","name":"assets","type":"uint256"},{"internalType":"uint256","name":"max","type":"uint256"}],"name":"ERC4626ExceededMaxDeposit","type":"error"},{"inputs":[{"internalType":"address","name":"receiver","type":"address"},{"internalType":"uint256","name":"shares","type":"uint256"},{"internalType":"uint256","name":"max","type":"uint256"}],"name":"ERC4626ExceededMaxMint","type":"error"},{"inputs":[{"internalType":"address","name":"owner","type":"address"},{"internalType":"uint256","name":"shares","type":"uint256"},{"internalType":"uint256","name":"max","type":"uint256"}],"name":"ERC4626ExceededMaxRedeem","type":"error"},{"inputs":[{"internalType":"address","name":"owner","type":"address"},{"internalType":"uint256","name":"assets","type":"uint256"},{"internalType":"uint256","name":"max","type":"uint256"}],"name":"ERC4626ExceededMaxWithdraw","type":"error"},{"inputs":[],"name":"Expired","type":"error"},{"inputs":[],"name":"InsufficientLiquidity","type":"error"},{"inputs":[],"name":"NoDebt","type":"error"},{"inputs":[{"internalType":"address","name":"owner","type":"address"}],"name":"OwnableInvalidOwner","type":"error"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"OwnableUnauthorizedAccount","type":"error"},{"inputs":[],"name":"ParamsContractNotChanged","type":"error"},{"inputs":[],"name":"ReentrancyGuardReentrantCall","type":"error"},{"inputs":[{"internalType":"address","name":"token","type":"address"}],"name":"SafeERC20FailedOperation","type":"error"},{"inputs":[{"internalType":"uint256","name":"chainId","type":"uint256"}],"name":"WrongChainId","type":"error"},{"inputs":[],"name":"ZeroRepayment","type":"error"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"owner","type":"address"},{"indexed":true,"internalType":"address","name":"spender","type":"address"},{"indexed":false,"internalType":"uint256","name":"value","type":"uint256"}],"name":"Approval","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"borrower","type":"address"},{"indexed":false,"internalType":"uint256","name":"baseDebt","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"baseDebtPaymentAmount","type":"uint256"}],"name":"BaseDebtRepayment","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"borrower","type":"address"},{"indexed":true,"internalType":"address","name":"recipient","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"Borrowed","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"sender","type":"address"},{"indexed":true,"internalType":"address","name":"owner","type":"address"},{"indexed":false,"internalType":"uint256","name":"assets","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"shares","type":"uint256"}],"name":"Deposit","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"previousOwner","type":"address"},{"indexed":true,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnershipTransferred","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"contract IInventoryPoolParams01","name":"paramsContract","type":"address"}],"name":"ParamsContractUpgraded","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"borrower","type":"address"},{"indexed":false,"internalType":"uint256","name":"penaltyDebt","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"penaltyPaymentAmount","type":"uint256"}],"name":"PenaltyRepayment","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"from","type":"address"},{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":false,"internalType":"uint256","name":"value","type":"uint256"}],"name":"Transfer","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"sender","type":"address"},{"indexed":true,"internalType":"address","name":"receiver","type":"address"},{"indexed":true,"internalType":"address","name":"owner","type":"address"},{"indexed":false,"internalType":"uint256","name":"assets","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"shares","type":"uint256"}],"name":"Withdraw","type":"event"},{"inputs":[],"name":"accumulatedInterestFactor","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"},{"internalType":"address","name":"spender","type":"address"}],"name":"allowance","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"value","type":"uint256"}],"name":"approve","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"asset","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"balanceOf","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"borrower","type":"address"}],"name":"baseDebt","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"address","name":"borrower","type":"address"},{"internalType":"address","name":"recipient","type":"address"},{"internalType":"uint256","name":"expiry","type":"uint256"},{"internalType":"uint256","name":"chainId","type":"uint256"}],"name":"borrow","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"borrowers","outputs":[{"internalType":"uint256","name":"scaledDebt","type":"uint256"},{"internalType":"uint256","name":"penaltyCounterStart","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"shares","type":"uint256"}],"name":"convertToAssets","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"assets","type":"uint256"}],"name":"convertToShares","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"decimals","outputs":[{"internalType":"uint8","name":"","type":"uint8"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"assets","type":"uint256"},{"internalType":"address","name":"receiver","type":"address"}],"name":"deposit","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"address","name":"borrower","type":"address"}],"name":"forgiveDebt","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"interestRate","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"lastAccumulatedInterestUpdate","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"maxDeposit","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"maxMint","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"}],"name":"maxRedeem","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"}],"name":"maxWithdraw","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"shares","type":"uint256"},{"internalType":"address","name":"receiver","type":"address"}],"name":"mint","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"name","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"newStoredAccInterestFactor","type":"uint256"},{"internalType":"uint256","name":"newLastAccumulatedInterestUpdate","type":"uint256"},{"internalType":"uint256","name":"newScaledReceivables","type":"uint256"}],"name":"overwriteCoreState","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"params","outputs":[{"internalType":"contract IInventoryPoolParams01","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"borrower","type":"address"}],"name":"penaltyDebt","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"borrower","type":"address"}],"name":"penaltyTime","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"assets","type":"uint256"}],"name":"previewDeposit","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"shares","type":"uint256"}],"name":"previewMint","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"shares","type":"uint256"}],"name":"previewRedeem","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"assets","type":"uint256"}],"name":"previewWithdraw","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"shares","type":"uint256"},{"internalType":"address","name":"receiver","type":"address"},{"internalType":"address","name":"owner","type":"address"}],"name":"redeem","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"address","name":"borrower","type":"address"}],"name":"repay","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"scaledReceivables","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"storedAccInterestFactor","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"symbol","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"totalAssets","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"totalReceivables","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"totalSupply","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"value","type":"uint256"}],"name":"transfer","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"from","type":"address"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"value","type":"uint256"}],"name":"transferFrom","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"contract IInventoryPoolParams01","name":"paramsContract","type":"address"}],"name":"upgradeParamsContract","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"utilizationRate","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"assets","type":"uint256"},{"internalType":"address","name":"receiver","type":"address"},{"internalType":"address","name":"owner","type":"address"}],"name":"withdraw","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"nonpayable","type":"function"}]Contract Creation Code
60c0806040523461046d57612e08803803809161001c828561068e565b833981019060c08183031261046d578051906001600160a01b038216820361046d5760208101516001600160401b03811161046d578361005d9183016106cc565b604082015190936001600160401b03821161046d5761007d9183016106cc565b6060820151608083015190936001600160a01b0382169390929184900361046d5760a001516001600160a01b038116959086900361046d578051906001600160401b0382116105915760035490600182811c92168015610684575b60208310146105735781601f849311610616575b50602090601f83116001146105b0575f926105a5575b50508160011b915f199060031b1c1916176003555b8051906001600160401b0382116105915760045490600182811c92168015610587575b60208310146105735781601f849311610505575b50602090601f831160011461049f575f92610494575b50508160011b915f199060031b1c1916176004555b61018281610712565b901561048c575b60a052608052801561047957600580546001600160a01b0319811683179091556001600160a01b03167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e05f80a380610251575b50600680546001600160a01b0319169190911790556040516121eb9081610bfd8239608051818181610515015281816106c9015281816108f501528181610dbb01528181610f1c01528181610fd4015281816110db015281816112890152818161168801526117f3015260a0518161111e0152f35b906002546001810180911161042b57602461027561026d6107c6565b6009546108f2565b6080516040516370a0823160e01b81523060048201529260209184919082906001600160a01b03165afa908115610411575f9161043f575b6102b792506107b9565b6001810180911161042b576102cc9184610a3b565b915f516020612de85f395f51905f525c61041c5760015f516020612de85f395f51905f525d60018060a01b03608051169260205f604051828101906323b872dd60e01b82523360248201523060448201528560648201526064815261033260848261068e565b519082885af115610411575f513d6104085750833b155b6103f55761dead92935061035f816002546107b9565b600255825f525f60205260405f20818154019055825f7fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef6020604051858152a360405191825260208201527fdcbc1c05240f31ff3ad067ef1ee35ce4997762752e3a095284754544f4c709d760403392a36103d86107c6565b600755426008555f5f516020612de85f395f51905f525d5f6101dc565b83635274afe760e01b5f5260045260245ffd5b60011415610349565b6040513d5f823e3d90fd5b633ee5aeb560e01b5f5260045ffd5b634e487b7160e01b5f52601160045260245ffd5b90506020823d602011610471575b8161045a6020938361068e565b8101031261046d576102b79151906102ad565b5f80fd5b3d915061044d565b631e4fbdf760e01b5f525f60045260245ffd5b506012610189565b015190505f80610164565b60045f9081528281209350601f198516905b8181106104ed57509084600195949392106104d5575b505050811b01600455610179565b01515f1960f88460031b161c191690555f80806104c7565b929360206001819287860151815501950193016104b1565b60045f529091507f8a35acfbc15ff81a39ae7d344fd709f28e8600b4aa8c65c6b64bfe7fe36bd19b601f840160051c81019160208510610569575b90601f859493920160051c01905b81811061055b575061014e565b5f815584935060010161054e565b9091508190610540565b634e487b7160e01b5f52602260045260245ffd5b91607f169161013a565b634e487b7160e01b5f52604160045260245ffd5b015190505f80610102565b60035f9081528281209350601f198516905b8181106105fe57509084600195949392106105e6575b505050811b01600355610117565b01515f1960f88460031b161c191690555f80806105d8565b929360206001819287860151815501950193016105c2565b60035f529091507fc2575a0e9e593c00f959f8c92f12db2869c3395a3b0502d05e2516446f71f85b601f840160051c8101916020851061067a575b90601f859493920160051c01905b81811061066c57506100ec565b5f815584935060010161065f565b9091508190610651565b91607f16916100d8565b601f909101601f19168101906001600160401b0382119082101761059157604052565b6001600160401b03811161059157601f01601f191660200190565b81601f8201121561046d578051906106e3826106b1565b926106f1604051948561068e565b8284526020838301011161046d57815f9260208093018386015e8301015290565b5f8091604051602081019063313ce56760e01b82526004815261073660248261068e565b51916001600160a01b03165afa3d156107b1573d90610754826106b1565b91610762604051938461068e565b82523d5f602084013e5b806107a5575b61077e575b505f905f90565b6020815191818082019384920101031261046d575160ff8111610777579060ff6001921690565b50602081511015610772565b60609061076c565b9190820180921161042b57565b600754806107db5750670de0b6b3a764000090565b6107e3610ad8565b670de0b6b3a76400000180670de0b6b3a76400001161042b57600854420342811161042b5792919083670de0b6b3a7640000916706f05b59d3b20000915b61084f57505061084c929350670de0b6b3a764000090610842828285610a3b565b92091515906107b9565b90565b9093925f915b60ff831660048110156108bf576001901b8716610899575b8061087791610be9565b85810180911161042b576001670de0b6b3a764000060ff920493011691610855565b92836108a491610be9565b85810180911161042b57670de0b6b3a764000090049261086d565b5060049690961c959394909390915085610821565b81156108de570490565b634e487b7160e01b5f52601260045260245ffd5b9190915f838202915f19858209918380841093039280840393146109745782670de0b6b3a7640000111561096257507faccb18165bd6fe31ae1cf318dc5b51eee0e1ba569b88cd74c1773b91fac106699394670de0b6b3a7640000910990828211900360ee1b910360121c170290565b634e487b71905260116020526024601cfd5b505050670de0b6b3a76400009192500490565b90670de0b6b3a76400008202905f19670de0b6b3a7640000840992828085109403938085039414610a2f5783821115610a1757670de0b6b3a7640000829109815f0382168092046002816003021880820260020302808202600203028082026002030280820260020302808202600203028091026002030293600183805f03040190848311900302920304170290565b50634e487b715f52156003026011186020526024601cfd5b509061084c92506108d4565b91818302915f1981850993838086109503948086039514610acb5784831115610ab35790829109815f0382168092046002816003021880820260020302808202600203028082026002030280820260020302808202600203028091026002030293600183805f03040190848311900302920304170290565b82634e487b715f52156003026011186020526024601cfd5b50509061084c92506108d4565b60018060a01b0360065416610af16007546009546108f2565b6080516040516370a0823160e01b815230600482015290602090829060249082906001600160a01b03165afa908115610411575f91610bb6575b5081610b3c610b42926020946107b9565b90610987565b602460405180948193630dfca69760e01b835260048301525afa908115610411575f91610b84575b506424ea4122ae8111610b7a5790565b506424ea4122ae90565b90506020813d602011610bae575b81610b9f6020938361068e565b8101031261046d57515f610b6a565b3d9150610b92565b90506020813d602011610be1575b81610bd16020938361068e565b8101031261046d57516020610b2b565b3d9150610bc4565b8181029291811591840414171561042b5756fe60806040526004361015610011575f80fd5b5f3560e01c806301e1d1141461151357806306fdde031461145857806307a2d13a146110c1578063095ea7b3146113b05780630a28a4771461139257806318160ddd1461137557806323b872dd1461133d5780632a6f30d814611165578063313ce5671461110a57806338d52e0f146110c6578063402d267d146103f25780634cdad506146110c15780634e571cb014611095578063678f45f2146110725780636890b466146110555780636c321c8a14610f965780636e553f6514610ee557806370a0823114610343578063715018a614610e8a5780637c3a00fd14610e705780638da5cb5b14610e4857806394bf804d14610d8457806395d89b4114610c8057806395f7f34d14610ac85780639deb17ea14610a9b578063a3054fad14610a7e578063a9059cbb14610a4d578063acb7081514610801578063b3d7f6b9146107e3578063b460af9414610680578063ba087652146104bd578063bd69025314610438578063bf5d50c4146103f7578063c63d75b6146103f2578063c6e6f592146102af578063ce96cb77146103cf578063cff0ab96146103a7578063d4948da51461037b578063d905777e14610343578063dc50de7414610326578063dd62ed3e146102d6578063e087c1f6146102b4578063ef8b30f7146102af578063f014f73f146102925763f2fde38b14610208575f80fd5b3461028e57602036600319011261028e57610221611575565b610229611c01565b6001600160a01b0316801561027b57600580546001600160a01b0319811683179091556001600160a01b03167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e05f80a3005b631e4fbdf760e01b5f525f60045260245ffd5b5f80fd5b3461028e575f36600319011261028e576020600954604051908152f35b611600565b3461028e575f36600319011261028e5760206102ce6118fe565b604051908152f35b3461028e57604036600319011261028e576102ef611575565b6102f761158b565b6001600160a01b039182165f908152600160209081526040808320949093168252928352819020549051908152f35b3461028e575f36600319011261028e576020600754604051908152f35b3461028e57602036600319011261028e5760206102ce610361611575565b6001600160a01b03165f9081526020819052604090205490565b3461028e57602036600319011261028e5760206102ce610399611575565b6103a16118fe565b90611f53565b3461028e575f36600319011261028e576006546040516001600160a01b039091168152602090f35b3461028e57602036600319011261028e5760206102ce6103ed611575565b6118e3565b6115a1565b3461028e57602036600319011261028e576001600160a01b03610418611575565b165f52600a6020526040805f206001815491015482519182526020820152f35b3461028e57602036600319011261028e576004356001600160a01b0381169081900361028e57610466611c01565b6006546001600160a01b03811682146104ae576001600160a01b03191681176006557fad5424a0637c534938e89f58d8927f10848741349870446fac4e7a982bf02f805f80a2005b63ceb55c3f60e01b5f5260045ffd5b3461028e576104cb366115c6565b6001600160a01b0381165f9081526020819052604090205491929180831161065e57506104f782611a1d565b91610500611bcc565b6040516370a0823160e01b81523060048201527f000000000000000000000000000000000000000000000000000000000000000094906020816024816001600160a01b038a165afa908115610653575f91610621575b508411610612576001600160a01b0383169233849003610602575b83156105ef5784826020976105898661058e9561204a565b611ced565b604051918483528583015260018060a01b0316907ffbde797d201c681b91056529119e0b02407c7bb96a4a2c75c01fc9667232c8db60403392a46105d06118fe565b600755426008555f5f51602061219f5f395f51905f525d604051908152f35b634b637e8f60e11b5f525f60045260245ffd5b61060d833383611aa5565b610571565b63bb55fd2760e01b5f5260045ffd5b90506020813d60201161064b575b8161063c6020938361161e565b8101031261028e575186610556565b3d915061062f565b6040513d5f823e3d90fd5b9250632e52afbb60e21b5f5260018060a01b031660045260245260445260645ffd5b3461028e5761068e366115c6565b61069a819392936118e3565b8083116107c157506106ab82611a4a565b916106b4611bcc565b6040516370a0823160e01b81523060048201527f000000000000000000000000000000000000000000000000000000000000000094906020816024816001600160a01b038a165afa908115610653575f9161078f575b508211610612576001600160a01b038316923384900361077f575b83156105ef5782826020976105898861073d9561204a565b604051918252838583015260018060a01b0316907ffbde797d201c681b91056529119e0b02407c7bb96a4a2c75c01fc9667232c8db60403392a46105d06118fe565b61078a853383611aa5565b610725565b90506020813d6020116107b9575b816107aa6020938361161e565b8101031261028e57518661070a565b3d915061079d565b9250633fa733bb60e21b5f5260018060a01b031660045260245260445260645ffd5b3461028e57602036600319011261028e5760206102ce6004356119ef565b3461028e57604036600319011261028e5760043561081d61158b565b610825611bcc565b8115610a3e576108336118fe565b60075542600855600754906108488282611d2f565b928315610a2f57610922936108f1935f906108638186611f53565b6001600160a01b0386165f818152600a60205260408120600101549692959194919291908615610a225750858211156109f757505f5160206121bf5f395f51905f5260406108c66108b5888895611703565b986108c0899b611710565b90611654565b965b8151908152896020820152a25b84610934575b50505f52600a602052600160405f200155611654565b30337f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031661213a565b5f5f51602061219f5f395f51905f525d005b909390928382106109ac575050807f5dc78895ffb3049298dc1a6172da123fc8a3756740617643a1c854ab6c6b1cd660405f9461099661097682985b89611c28565b855f52600a602052835f2061098c828254611703565b9055600954611703565b6009558151908152866020820152a286806108db565b6040846109966109766109f1856108c0889b9a8a996109ec7f5dc78895ffb3049298dc1a6172da123fc8a3756740617643a1c854ab6c6b1cd69a42611703565b611ea3565b97610970565b956040610a1c5f5160206121bf5f395f51905f52926108c089866109ec8b989e611710565b966108c8565b97505090949350936108d5565b6308d1fde360e11b5f5260045ffd5b6301198d0d60e21b5f5260045ffd5b3461028e57604036600319011261028e57610a73610a69611575565b6024359033611b48565b602060405160018152f35b3461028e575f36600319011261028e576020600854604051908152f35b3461028e57606036600319011261028e57610ab4611c01565b600435600755602435600855604435600955005b3461028e57604036600319011261028e57600435610ae461158b565b90610aed611c01565b610af5611bcc565b8015610a3e57610b036118fe565b60075542600855600754610b178184611d2f565b8015610a2f575f610b288386611f53565b6001600160a01b0386165f818152600a6020526040902060010154909590928215610c76578692919082821115610c4b575081610b83610b785f5160206121bf5f395f51905f5294604094611703565b956108c0839b611710565b985b82519182526020820152a25b80610bbb575b5050505f52600a602052600160405f2001555f5f51602061219f5f395f51905f525d005b81818594967f5dc78895ffb3049298dc1a6172da123fc8a3756740617643a1c854ab6c6b1cd69460409410155f14610c2c5750505f95610c16610c0083925b83611c28565b865f52600a602052845f2061098c828254611703565b60095582519182526020820152a2828080610b97565b610c00610c45826108c086866109ec610c169742611703565b98610bfa565b9391610c705f5160206121bf5f395f51905f52936108c083856109ec6040979e611710565b98610b85565b5091955050610b91565b3461028e575f36600319011261028e576040515f6004548060011c90600181168015610d7a575b602083108114610d6657828552908115610d425750600114610ce4575b610ce083610cd48185038261161e565b6040519182918261152d565b0390f35b91905060045f527f8a35acfbc15ff81a39ae7d344fd709f28e8600b4aa8c65c6b64bfe7fe36bd19b915f905b808210610d2857509091508101602001610cd4610cc4565b919260018160209254838588010152019101909291610d10565b60ff191660208086019190915291151560051b84019091019150610cd49050610cc4565b634e487b7160e01b5f52602260045260245ffd5b91607f1691610ca7565b3461028e57604036600319011261028e57600435610da061158b565b90610daa816119ef565b90610db3611bcc565b610ddf8230337f000000000000000000000000000000000000000000000000000000000000000061213a565b6001600160a01b038316908115610e3557610dfc81602095611ff0565b60405190838252848201527fdcbc1c05240f31ff3ad067ef1ee35ce4997762752e3a095284754544f4c709d760403392a36105d06118fe565b63ec442f0560e01b5f525f60045260245ffd5b3461028e575f36600319011261028e576005546040516001600160a01b039091168152602090f35b3461028e575f36600319011261028e5760206102ce6117bf565b3461028e575f36600319011261028e57610ea2611c01565b600580546001600160a01b031981169091555f906001600160a01b03167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e08280a3005b3461028e57604036600319011261028e57600435610f0161158b565b90610f0b81611a78565b90610f14611bcc565b610f408130337f000000000000000000000000000000000000000000000000000000000000000061213a565b6001600160a01b038316908115610e3557610f5d83602095611ff0565b60405190815282848201527fdcbc1c05240f31ff3ad067ef1ee35ce4997762752e3a095284754544f4c709d760403392a36105d06118fe565b3461028e575f36600319011261028e57610fb9610fb16118fe565b600954611d5a565b6040516370a0823160e01b81523060048201526020816024817f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03165afa908115610653575f91611022575b60206102ce8461101c8582611654565b90611def565b90506020813d60201161104d575b8161103d6020938361161e565b8101031261028e5751602061100c565b3d9150611030565b3461028e575f36600319011261028e5760206102ce610fb16118fe565b3461028e57602036600319011261028e5760206102ce611090611575565b611710565b3461028e57602036600319011261028e5760206102ce6110b3611575565b6110bb6118fe565b90611d2f565b611557565b3461028e575f36600319011261028e576040517f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03168152602090f35b3461028e575f36600319011261028e5760ff7f00000000000000000000000000000000000000000000000000000000000000001660ff811161115157602090604051908152f35b634e487b7160e01b5f52601160045260245ffd5b3461028e5760a036600319011261028e5760043561118161158b565b6044356001600160a01b038116929083810361028e576084356111a2611bcc565b6111aa611c01565b606435421161132e5780460361131c57506111c36118fe565b600755426008556111d660075483611c28565b6006546040516337792e1d60e11b815290602090829060049082906001600160a01b03165afa908115610653575f916112e4575b508360209361126f61124583956108c06112b6967f3fc499aeb0bb1cb58b6de8b02b3f86f4e7394e9690bef0110e32ced8a56310459a611c6d565b9760018060a01b031697885f52600a875260405f20611265828254611654565b9055600954611654565b600955865f52600a8552600160405f200154156112cf575b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316611ced565b604051908152a35f5f51602061219f5f395f51905f525d005b865f52600a855242600160405f200155611287565b939190506020843d602011611314575b816113016020938361161e565b8101031261028e5792519092908361120a565b3d91506112f4565b633881b68960e01b5f5260045260245ffd5b630407b05b60e31b5f5260045ffd5b3461028e57606036600319011261028e57610a73611359611575565b61136161158b565b60443591611370833383611aa5565b611b48565b3461028e575f36600319011261028e576020600254604051908152f35b3461028e57602036600319011261028e5760206102ce600435611a4a565b3461028e57604036600319011261028e576113c9611575565b602435903315611445576001600160a01b031690811561143257335f52600160205260405f20825f526020528060405f20556040519081527f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92560203392a3602060405160018152f35b634a1406b160e11b5f525f60045260245ffd5b63e602df0560e01b5f525f60045260245ffd5b3461028e575f36600319011261028e576040515f6003548060011c90600181168015611509575b602083108114610d6657828552908115610d4257506001146114ab57610ce083610cd48185038261161e565b91905060035f527fc2575a0e9e593c00f959f8c92f12db2869c3395a3b0502d05e2516446f71f85b915f905b8082106114ef57509091508101602001610cd4610cc4565b9192600181602092548385880101520191019092916114d7565b91607f169161147f565b3461028e575f36600319011261028e5760206102ce611661565b602060409281835280519182918282860152018484015e5f828201840152601f01601f1916010190565b3461028e57602036600319011261028e5760206102ce600435611a1d565b600435906001600160a01b038216820361028e57565b602435906001600160a01b038216820361028e57565b3461028e57602036600319011261028e576115ba611575565b5060206040515f198152f35b606090600319011261028e57600435906024356001600160a01b038116810361028e57906044356001600160a01b038116810361028e5790565b3461028e57602036600319011261028e5760206102ce600435611a78565b90601f8019910116810190811067ffffffffffffffff82111761164057604052565b634e487b7160e01b5f52604160045260245ffd5b9190820180921161115157565b61166c610fb16118fe565b6040516370a0823160e01b8152306004820152906020826024817f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03165afa908115610653575f916116cd575b6116ca9250611654565b90565b90506020823d6020116116fb575b816116e86020938361161e565b8101031261028e576116ca9151906116c0565b3d91506116db565b9190820391821161115157565b6001600160a01b03165f908152600a60205260409020600101548061173457505f90565b600654604051630c89e6f960e21b81529190602090839060049082906001600160a01b03165afa908115610653575f91611789575b6117739250611654565b42811061177f57505f90565b6116ca9042611703565b90506020823d6020116117b7575b816117a46020938361161e565b8101031261028e57611773915190611769565b3d9150611797565b60018060a01b03600654166117d8600754600954611d5a565b6040516370a0823160e01b81523060048201526020816024817f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03165afa908115610653575f916118b0575b508161101c61183c92602094611654565b602460405180948193630dfca69760e01b835260048301525afa908115610653575f9161187e575b506424ea4122ae81116118745790565b506424ea4122ae90565b90506020813d6020116118a8575b816118996020938361161e565b8101031261028e57515f611864565b3d915061188c565b90506020813d6020116118db575b816118cb6020938361161e565b8101031261028e5751602061182b565b3d91506118be565b60018060a01b03165f525f6020526116ca60405f2054611a1d565b600754806119135750670de0b6b3a764000090565b9061191c6117bf565b670de0b6b3a7640000019182670de0b6b3a7640000116111515761194260085442611703565b929083670de0b6b3a7640000926706f05b59d3b20000915b61196b5750506116ca929350611c6d565b909392915f915b60ff831660048110156119dc576001901b87166119b6575b8061199491611f40565b858101809111611151576001670de0b6b3a764000060ff920493011691611972565b92836119c191611f40565b85810180911161115157670de0b6b3a764000090049261198a565b509590929394915060041c80959061195a565b6119f7611661565b90600182018092116111515760025460018101809111611151576116ca92600192611c8f565b611a25611661565b90600182018092116111515760025460018101809111611151576116ca925f92611c8f565b600254906001820180921161115157611a61611661565b60018101809111611151576116ca92600192611c8f565b600254906001820180921161115157611a8f611661565b60018101809111611151576116ca925f92611c8f565b6001600160a01b039081165f818152600160209081526040808320948616835293905291909120549291905f198410611adf575b50505050565b828410611b25578015611445576001600160a01b03821615611432575f52600160205260405f209060018060a01b03165f5260205260405f20910390555f808080611ad9565b508290637dc7a0d960e11b5f5260018060a01b031660045260245260445260645ffd5b6001600160a01b03169081156105ef576001600160a01b0316918215610e3557815f525f60205260405f2054818110611bb357815f51602061217f5f395f51905f5292602092855f525f84520360405f2055845f525f825260405f20818154019055604051908152a3565b8263391434e360e21b5f5260045260245260445260645ffd5b5f51602061219f5f395f51905f525c611bf25760015f51602061219f5f395f51905f525d565b633ee5aeb560e01b5f5260045ffd5b6005546001600160a01b03163303611c1557565b63118cdaa760e01b5f523360045260245ffd5b90611c3c81670de0b6b3a764000084611ea3565b908015611c5957670de0b6b3a76400006116ca9309151590611654565b634e487b7160e01b5f52601260045260245ffd5b670de0b6b3a76400006116ca92611c85828285611ea3565b9209151590611654565b9291611c9c818386611ea3565b926004811015611cd9576001809116149182611cc2575b50506116ca9250151590611654565b9080925015611c59576116ca930915155f80611cb3565b634e487b7160e01b5f52602160045260245ffd5b60405163a9059cbb60e01b60208201526001600160a01b039092166024830152604480830193909352918152611d2d91611d2860648361161e565b6120e2565b565b6001600160a01b03165f908152600a60205260409020546116ca9190611d5a565b8115611c59570490565b9190915f838202915f1985820991838084109303928084039314611ddc5782670de0b6b3a76400001115611dca57507faccb18165bd6fe31ae1cf318dc5b51eee0e1ba569b88cd74c1773b91fac106699394670de0b6b3a7640000910990828211900360ee1b910360121c170290565b634e487b71905260116020526024601cfd5b505050670de0b6b3a76400009192500490565b90670de0b6b3a76400008202905f19670de0b6b3a7640000840992828085109403938085039414611e975783821115611e7f57670de0b6b3a7640000829109815f0382168092046002816003021880820260020302808202600203028082026002030280820260020302808202600203028091026002030293600183805f03040190848311900302920304170290565b50634e487b715f52156003026011186020526024601cfd5b50906116ca9250611d50565b91818302915f1981850993838086109503948086039514611f335784831115611f1b5790829109815f0382168092046002816003021880820260020302808202600203028082026002030280820260020302808202600203028091026002030293600183805f03040190848311900302920304170290565b82634e487b715f52156003026011186020526024601cfd5b5050906116ca9250611d50565b8181029291811591840414171561115157565b90611f5d82611710565b8015611fe957611f72611f7792600494611d2f565b611f40565b60065460405163d6b7494f60e01b81529260209184919082906001600160a01b03165afa908115610653575f91611fb3575b6116ca9250611d5a565b90506020823d602011611fe1575b81611fce6020938361161e565b8101031261028e576116ca915190611fa9565b3d9150611fc1565b5050505f90565b5f51602061217f5f395f51905f5260205f9261200e85600254611654565b6002556001600160a01b031693841584146120355780600254036002555b604051908152a3565b8484528382526040842081815401905561202c565b9091906001600160a01b03168061208f575f51602061217f5f395f51905f5260208461207a5f9596600254611654565b6002555b8060025403600255604051908152a3565b805f525f60205260405f20548381106120c8576020845f94955f51602061217f5f395f51905f529385875286845203604086205561207e565b915063391434e360e21b5f5260045260245260445260645ffd5b905f602091828151910182855af115610653575f513d61213157506001600160a01b0381163b155b6121115750565b635274afe760e01b5f9081526001600160a01b0391909116600452602490fd5b6001141561210a565b6040516323b872dd60e01b60208201526001600160a01b039283166024820152929091166044830152606480830193909352918152611d2d91611d2860848361161e56feddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9b779b17422d0df92223018b32b4d1fa46e071723d6817e2486d003becc55f000ddd147bde4ad9e210da1c0b4e90e3ef96e1227157856f5408b08e1a610d9c10a164736f6c634300081c000a9b779b17422d0df92223018b32b4d1fa46e071723d6817e2486d003becc55f00000000000000000000000000203a662b0bd271a6ed5a60edfbd04bfce608fd3600000000000000000000000000000000000000000000000000000000000000c0000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000186a0000000000000000000000000baba24610681fdf6a8fcb921c3074b0dd6dc57ae00000000000000000000000003136fcaab1b2fdc4e66f6ac0430f447627f843a000000000000000000000000000000000000000000000000000000000000000f4e6f6d69616c205553444320303031000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000086e55534443303031000000000000000000000000000000000000000000000000
Deployed Bytecode
0x60806040526004361015610011575f80fd5b5f3560e01c806301e1d1141461151357806306fdde031461145857806307a2d13a146110c1578063095ea7b3146113b05780630a28a4771461139257806318160ddd1461137557806323b872dd1461133d5780632a6f30d814611165578063313ce5671461110a57806338d52e0f146110c6578063402d267d146103f25780634cdad506146110c15780634e571cb014611095578063678f45f2146110725780636890b466146110555780636c321c8a14610f965780636e553f6514610ee557806370a0823114610343578063715018a614610e8a5780637c3a00fd14610e705780638da5cb5b14610e4857806394bf804d14610d8457806395d89b4114610c8057806395f7f34d14610ac85780639deb17ea14610a9b578063a3054fad14610a7e578063a9059cbb14610a4d578063acb7081514610801578063b3d7f6b9146107e3578063b460af9414610680578063ba087652146104bd578063bd69025314610438578063bf5d50c4146103f7578063c63d75b6146103f2578063c6e6f592146102af578063ce96cb77146103cf578063cff0ab96146103a7578063d4948da51461037b578063d905777e14610343578063dc50de7414610326578063dd62ed3e146102d6578063e087c1f6146102b4578063ef8b30f7146102af578063f014f73f146102925763f2fde38b14610208575f80fd5b3461028e57602036600319011261028e57610221611575565b610229611c01565b6001600160a01b0316801561027b57600580546001600160a01b0319811683179091556001600160a01b03167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e05f80a3005b631e4fbdf760e01b5f525f60045260245ffd5b5f80fd5b3461028e575f36600319011261028e576020600954604051908152f35b611600565b3461028e575f36600319011261028e5760206102ce6118fe565b604051908152f35b3461028e57604036600319011261028e576102ef611575565b6102f761158b565b6001600160a01b039182165f908152600160209081526040808320949093168252928352819020549051908152f35b3461028e575f36600319011261028e576020600754604051908152f35b3461028e57602036600319011261028e5760206102ce610361611575565b6001600160a01b03165f9081526020819052604090205490565b3461028e57602036600319011261028e5760206102ce610399611575565b6103a16118fe565b90611f53565b3461028e575f36600319011261028e576006546040516001600160a01b039091168152602090f35b3461028e57602036600319011261028e5760206102ce6103ed611575565b6118e3565b6115a1565b3461028e57602036600319011261028e576001600160a01b03610418611575565b165f52600a6020526040805f206001815491015482519182526020820152f35b3461028e57602036600319011261028e576004356001600160a01b0381169081900361028e57610466611c01565b6006546001600160a01b03811682146104ae576001600160a01b03191681176006557fad5424a0637c534938e89f58d8927f10848741349870446fac4e7a982bf02f805f80a2005b63ceb55c3f60e01b5f5260045ffd5b3461028e576104cb366115c6565b6001600160a01b0381165f9081526020819052604090205491929180831161065e57506104f782611a1d565b91610500611bcc565b6040516370a0823160e01b81523060048201527f000000000000000000000000203a662b0bd271a6ed5a60edfbd04bfce608fd3694906020816024816001600160a01b038a165afa908115610653575f91610621575b508411610612576001600160a01b0383169233849003610602575b83156105ef5784826020976105898661058e9561204a565b611ced565b604051918483528583015260018060a01b0316907ffbde797d201c681b91056529119e0b02407c7bb96a4a2c75c01fc9667232c8db60403392a46105d06118fe565b600755426008555f5f51602061219f5f395f51905f525d604051908152f35b634b637e8f60e11b5f525f60045260245ffd5b61060d833383611aa5565b610571565b63bb55fd2760e01b5f5260045ffd5b90506020813d60201161064b575b8161063c6020938361161e565b8101031261028e575186610556565b3d915061062f565b6040513d5f823e3d90fd5b9250632e52afbb60e21b5f5260018060a01b031660045260245260445260645ffd5b3461028e5761068e366115c6565b61069a819392936118e3565b8083116107c157506106ab82611a4a565b916106b4611bcc565b6040516370a0823160e01b81523060048201527f000000000000000000000000203a662b0bd271a6ed5a60edfbd04bfce608fd3694906020816024816001600160a01b038a165afa908115610653575f9161078f575b508211610612576001600160a01b038316923384900361077f575b83156105ef5782826020976105898861073d9561204a565b604051918252838583015260018060a01b0316907ffbde797d201c681b91056529119e0b02407c7bb96a4a2c75c01fc9667232c8db60403392a46105d06118fe565b61078a853383611aa5565b610725565b90506020813d6020116107b9575b816107aa6020938361161e565b8101031261028e57518661070a565b3d915061079d565b9250633fa733bb60e21b5f5260018060a01b031660045260245260445260645ffd5b3461028e57602036600319011261028e5760206102ce6004356119ef565b3461028e57604036600319011261028e5760043561081d61158b565b610825611bcc565b8115610a3e576108336118fe565b60075542600855600754906108488282611d2f565b928315610a2f57610922936108f1935f906108638186611f53565b6001600160a01b0386165f818152600a60205260408120600101549692959194919291908615610a225750858211156109f757505f5160206121bf5f395f51905f5260406108c66108b5888895611703565b986108c0899b611710565b90611654565b965b8151908152896020820152a25b84610934575b50505f52600a602052600160405f200155611654565b30337f000000000000000000000000203a662b0bd271a6ed5a60edfbd04bfce608fd366001600160a01b031661213a565b5f5f51602061219f5f395f51905f525d005b909390928382106109ac575050807f5dc78895ffb3049298dc1a6172da123fc8a3756740617643a1c854ab6c6b1cd660405f9461099661097682985b89611c28565b855f52600a602052835f2061098c828254611703565b9055600954611703565b6009558151908152866020820152a286806108db565b6040846109966109766109f1856108c0889b9a8a996109ec7f5dc78895ffb3049298dc1a6172da123fc8a3756740617643a1c854ab6c6b1cd69a42611703565b611ea3565b97610970565b956040610a1c5f5160206121bf5f395f51905f52926108c089866109ec8b989e611710565b966108c8565b97505090949350936108d5565b6308d1fde360e11b5f5260045ffd5b6301198d0d60e21b5f5260045ffd5b3461028e57604036600319011261028e57610a73610a69611575565b6024359033611b48565b602060405160018152f35b3461028e575f36600319011261028e576020600854604051908152f35b3461028e57606036600319011261028e57610ab4611c01565b600435600755602435600855604435600955005b3461028e57604036600319011261028e57600435610ae461158b565b90610aed611c01565b610af5611bcc565b8015610a3e57610b036118fe565b60075542600855600754610b178184611d2f565b8015610a2f575f610b288386611f53565b6001600160a01b0386165f818152600a6020526040902060010154909590928215610c76578692919082821115610c4b575081610b83610b785f5160206121bf5f395f51905f5294604094611703565b956108c0839b611710565b985b82519182526020820152a25b80610bbb575b5050505f52600a602052600160405f2001555f5f51602061219f5f395f51905f525d005b81818594967f5dc78895ffb3049298dc1a6172da123fc8a3756740617643a1c854ab6c6b1cd69460409410155f14610c2c5750505f95610c16610c0083925b83611c28565b865f52600a602052845f2061098c828254611703565b60095582519182526020820152a2828080610b97565b610c00610c45826108c086866109ec610c169742611703565b98610bfa565b9391610c705f5160206121bf5f395f51905f52936108c083856109ec6040979e611710565b98610b85565b5091955050610b91565b3461028e575f36600319011261028e576040515f6004548060011c90600181168015610d7a575b602083108114610d6657828552908115610d425750600114610ce4575b610ce083610cd48185038261161e565b6040519182918261152d565b0390f35b91905060045f527f8a35acfbc15ff81a39ae7d344fd709f28e8600b4aa8c65c6b64bfe7fe36bd19b915f905b808210610d2857509091508101602001610cd4610cc4565b919260018160209254838588010152019101909291610d10565b60ff191660208086019190915291151560051b84019091019150610cd49050610cc4565b634e487b7160e01b5f52602260045260245ffd5b91607f1691610ca7565b3461028e57604036600319011261028e57600435610da061158b565b90610daa816119ef565b90610db3611bcc565b610ddf8230337f000000000000000000000000203a662b0bd271a6ed5a60edfbd04bfce608fd3661213a565b6001600160a01b038316908115610e3557610dfc81602095611ff0565b60405190838252848201527fdcbc1c05240f31ff3ad067ef1ee35ce4997762752e3a095284754544f4c709d760403392a36105d06118fe565b63ec442f0560e01b5f525f60045260245ffd5b3461028e575f36600319011261028e576005546040516001600160a01b039091168152602090f35b3461028e575f36600319011261028e5760206102ce6117bf565b3461028e575f36600319011261028e57610ea2611c01565b600580546001600160a01b031981169091555f906001600160a01b03167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e08280a3005b3461028e57604036600319011261028e57600435610f0161158b565b90610f0b81611a78565b90610f14611bcc565b610f408130337f000000000000000000000000203a662b0bd271a6ed5a60edfbd04bfce608fd3661213a565b6001600160a01b038316908115610e3557610f5d83602095611ff0565b60405190815282848201527fdcbc1c05240f31ff3ad067ef1ee35ce4997762752e3a095284754544f4c709d760403392a36105d06118fe565b3461028e575f36600319011261028e57610fb9610fb16118fe565b600954611d5a565b6040516370a0823160e01b81523060048201526020816024817f000000000000000000000000203a662b0bd271a6ed5a60edfbd04bfce608fd366001600160a01b03165afa908115610653575f91611022575b60206102ce8461101c8582611654565b90611def565b90506020813d60201161104d575b8161103d6020938361161e565b8101031261028e5751602061100c565b3d9150611030565b3461028e575f36600319011261028e5760206102ce610fb16118fe565b3461028e57602036600319011261028e5760206102ce611090611575565b611710565b3461028e57602036600319011261028e5760206102ce6110b3611575565b6110bb6118fe565b90611d2f565b611557565b3461028e575f36600319011261028e576040517f000000000000000000000000203a662b0bd271a6ed5a60edfbd04bfce608fd366001600160a01b03168152602090f35b3461028e575f36600319011261028e5760ff7f00000000000000000000000000000000000000000000000000000000000000061660ff811161115157602090604051908152f35b634e487b7160e01b5f52601160045260245ffd5b3461028e5760a036600319011261028e5760043561118161158b565b6044356001600160a01b038116929083810361028e576084356111a2611bcc565b6111aa611c01565b606435421161132e5780460361131c57506111c36118fe565b600755426008556111d660075483611c28565b6006546040516337792e1d60e11b815290602090829060049082906001600160a01b03165afa908115610653575f916112e4575b508360209361126f61124583956108c06112b6967f3fc499aeb0bb1cb58b6de8b02b3f86f4e7394e9690bef0110e32ced8a56310459a611c6d565b9760018060a01b031697885f52600a875260405f20611265828254611654565b9055600954611654565b600955865f52600a8552600160405f200154156112cf575b7f000000000000000000000000203a662b0bd271a6ed5a60edfbd04bfce608fd366001600160a01b0316611ced565b604051908152a35f5f51602061219f5f395f51905f525d005b865f52600a855242600160405f200155611287565b939190506020843d602011611314575b816113016020938361161e565b8101031261028e5792519092908361120a565b3d91506112f4565b633881b68960e01b5f5260045260245ffd5b630407b05b60e31b5f5260045ffd5b3461028e57606036600319011261028e57610a73611359611575565b61136161158b565b60443591611370833383611aa5565b611b48565b3461028e575f36600319011261028e576020600254604051908152f35b3461028e57602036600319011261028e5760206102ce600435611a4a565b3461028e57604036600319011261028e576113c9611575565b602435903315611445576001600160a01b031690811561143257335f52600160205260405f20825f526020528060405f20556040519081527f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92560203392a3602060405160018152f35b634a1406b160e11b5f525f60045260245ffd5b63e602df0560e01b5f525f60045260245ffd5b3461028e575f36600319011261028e576040515f6003548060011c90600181168015611509575b602083108114610d6657828552908115610d4257506001146114ab57610ce083610cd48185038261161e565b91905060035f527fc2575a0e9e593c00f959f8c92f12db2869c3395a3b0502d05e2516446f71f85b915f905b8082106114ef57509091508101602001610cd4610cc4565b9192600181602092548385880101520191019092916114d7565b91607f169161147f565b3461028e575f36600319011261028e5760206102ce611661565b602060409281835280519182918282860152018484015e5f828201840152601f01601f1916010190565b3461028e57602036600319011261028e5760206102ce600435611a1d565b600435906001600160a01b038216820361028e57565b602435906001600160a01b038216820361028e57565b3461028e57602036600319011261028e576115ba611575565b5060206040515f198152f35b606090600319011261028e57600435906024356001600160a01b038116810361028e57906044356001600160a01b038116810361028e5790565b3461028e57602036600319011261028e5760206102ce600435611a78565b90601f8019910116810190811067ffffffffffffffff82111761164057604052565b634e487b7160e01b5f52604160045260245ffd5b9190820180921161115157565b61166c610fb16118fe565b6040516370a0823160e01b8152306004820152906020826024817f000000000000000000000000203a662b0bd271a6ed5a60edfbd04bfce608fd366001600160a01b03165afa908115610653575f916116cd575b6116ca9250611654565b90565b90506020823d6020116116fb575b816116e86020938361161e565b8101031261028e576116ca9151906116c0565b3d91506116db565b9190820391821161115157565b6001600160a01b03165f908152600a60205260409020600101548061173457505f90565b600654604051630c89e6f960e21b81529190602090839060049082906001600160a01b03165afa908115610653575f91611789575b6117739250611654565b42811061177f57505f90565b6116ca9042611703565b90506020823d6020116117b7575b816117a46020938361161e565b8101031261028e57611773915190611769565b3d9150611797565b60018060a01b03600654166117d8600754600954611d5a565b6040516370a0823160e01b81523060048201526020816024817f000000000000000000000000203a662b0bd271a6ed5a60edfbd04bfce608fd366001600160a01b03165afa908115610653575f916118b0575b508161101c61183c92602094611654565b602460405180948193630dfca69760e01b835260048301525afa908115610653575f9161187e575b506424ea4122ae81116118745790565b506424ea4122ae90565b90506020813d6020116118a8575b816118996020938361161e565b8101031261028e57515f611864565b3d915061188c565b90506020813d6020116118db575b816118cb6020938361161e565b8101031261028e5751602061182b565b3d91506118be565b60018060a01b03165f525f6020526116ca60405f2054611a1d565b600754806119135750670de0b6b3a764000090565b9061191c6117bf565b670de0b6b3a7640000019182670de0b6b3a7640000116111515761194260085442611703565b929083670de0b6b3a7640000926706f05b59d3b20000915b61196b5750506116ca929350611c6d565b909392915f915b60ff831660048110156119dc576001901b87166119b6575b8061199491611f40565b858101809111611151576001670de0b6b3a764000060ff920493011691611972565b92836119c191611f40565b85810180911161115157670de0b6b3a764000090049261198a565b509590929394915060041c80959061195a565b6119f7611661565b90600182018092116111515760025460018101809111611151576116ca92600192611c8f565b611a25611661565b90600182018092116111515760025460018101809111611151576116ca925f92611c8f565b600254906001820180921161115157611a61611661565b60018101809111611151576116ca92600192611c8f565b600254906001820180921161115157611a8f611661565b60018101809111611151576116ca925f92611c8f565b6001600160a01b039081165f818152600160209081526040808320948616835293905291909120549291905f198410611adf575b50505050565b828410611b25578015611445576001600160a01b03821615611432575f52600160205260405f209060018060a01b03165f5260205260405f20910390555f808080611ad9565b508290637dc7a0d960e11b5f5260018060a01b031660045260245260445260645ffd5b6001600160a01b03169081156105ef576001600160a01b0316918215610e3557815f525f60205260405f2054818110611bb357815f51602061217f5f395f51905f5292602092855f525f84520360405f2055845f525f825260405f20818154019055604051908152a3565b8263391434e360e21b5f5260045260245260445260645ffd5b5f51602061219f5f395f51905f525c611bf25760015f51602061219f5f395f51905f525d565b633ee5aeb560e01b5f5260045ffd5b6005546001600160a01b03163303611c1557565b63118cdaa760e01b5f523360045260245ffd5b90611c3c81670de0b6b3a764000084611ea3565b908015611c5957670de0b6b3a76400006116ca9309151590611654565b634e487b7160e01b5f52601260045260245ffd5b670de0b6b3a76400006116ca92611c85828285611ea3565b9209151590611654565b9291611c9c818386611ea3565b926004811015611cd9576001809116149182611cc2575b50506116ca9250151590611654565b9080925015611c59576116ca930915155f80611cb3565b634e487b7160e01b5f52602160045260245ffd5b60405163a9059cbb60e01b60208201526001600160a01b039092166024830152604480830193909352918152611d2d91611d2860648361161e565b6120e2565b565b6001600160a01b03165f908152600a60205260409020546116ca9190611d5a565b8115611c59570490565b9190915f838202915f1985820991838084109303928084039314611ddc5782670de0b6b3a76400001115611dca57507faccb18165bd6fe31ae1cf318dc5b51eee0e1ba569b88cd74c1773b91fac106699394670de0b6b3a7640000910990828211900360ee1b910360121c170290565b634e487b71905260116020526024601cfd5b505050670de0b6b3a76400009192500490565b90670de0b6b3a76400008202905f19670de0b6b3a7640000840992828085109403938085039414611e975783821115611e7f57670de0b6b3a7640000829109815f0382168092046002816003021880820260020302808202600203028082026002030280820260020302808202600203028091026002030293600183805f03040190848311900302920304170290565b50634e487b715f52156003026011186020526024601cfd5b50906116ca9250611d50565b91818302915f1981850993838086109503948086039514611f335784831115611f1b5790829109815f0382168092046002816003021880820260020302808202600203028082026002030280820260020302808202600203028091026002030293600183805f03040190848311900302920304170290565b82634e487b715f52156003026011186020526024601cfd5b5050906116ca9250611d50565b8181029291811591840414171561115157565b90611f5d82611710565b8015611fe957611f72611f7792600494611d2f565b611f40565b60065460405163d6b7494f60e01b81529260209184919082906001600160a01b03165afa908115610653575f91611fb3575b6116ca9250611d5a565b90506020823d602011611fe1575b81611fce6020938361161e565b8101031261028e576116ca915190611fa9565b3d9150611fc1565b5050505f90565b5f51602061217f5f395f51905f5260205f9261200e85600254611654565b6002556001600160a01b031693841584146120355780600254036002555b604051908152a3565b8484528382526040842081815401905561202c565b9091906001600160a01b03168061208f575f51602061217f5f395f51905f5260208461207a5f9596600254611654565b6002555b8060025403600255604051908152a3565b805f525f60205260405f20548381106120c8576020845f94955f51602061217f5f395f51905f529385875286845203604086205561207e565b915063391434e360e21b5f5260045260245260445260645ffd5b905f602091828151910182855af115610653575f513d61213157506001600160a01b0381163b155b6121115750565b635274afe760e01b5f9081526001600160a01b0391909116600452602490fd5b6001141561210a565b6040516323b872dd60e01b60208201526001600160a01b039283166024820152929091166044830152606480830193909352918152611d2d91611d2860848361161e56feddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9b779b17422d0df92223018b32b4d1fa46e071723d6817e2486d003becc55f000ddd147bde4ad9e210da1c0b4e90e3ef96e1227157856f5408b08e1a610d9c10a164736f6c634300081c000a
Constructor Arguments (ABI-Encoded and is the last bytes of the Contract Creation Code above)
000000000000000000000000203a662b0bd271a6ed5a60edfbd04bfce608fd3600000000000000000000000000000000000000000000000000000000000000c0000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000186a0000000000000000000000000baba24610681fdf6a8fcb921c3074b0dd6dc57ae00000000000000000000000003136fcaab1b2fdc4e66f6ac0430f447627f843a000000000000000000000000000000000000000000000000000000000000000f4e6f6d69616c205553444320303031000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000086e55534443303031000000000000000000000000000000000000000000000000
-----Decoded View---------------
Arg [0] : asset_ (address): 0x203A662b0BD271A6ed5a60EdFbd04bFce608FD36
Arg [1] : name (string): Nomial USDC 001
Arg [2] : symbol (string): nUSDC001
Arg [3] : initAmount (uint256): 100000
Arg [4] : owner (address): 0xbabA24610681FDf6A8fcb921C3074B0dd6dc57ae
Arg [5] : paramsContract (address): 0x03136fCaaB1b2Fdc4E66F6AC0430F447627F843A
-----Encoded View---------------
10 Constructor Arguments found :
Arg [0] : 000000000000000000000000203a662b0bd271a6ed5a60edfbd04bfce608fd36
Arg [1] : 00000000000000000000000000000000000000000000000000000000000000c0
Arg [2] : 0000000000000000000000000000000000000000000000000000000000000100
Arg [3] : 00000000000000000000000000000000000000000000000000000000000186a0
Arg [4] : 000000000000000000000000baba24610681fdf6a8fcb921c3074b0dd6dc57ae
Arg [5] : 00000000000000000000000003136fcaab1b2fdc4e66f6ac0430f447627f843a
Arg [6] : 000000000000000000000000000000000000000000000000000000000000000f
Arg [7] : 4e6f6d69616c2055534443203030310000000000000000000000000000000000
Arg [8] : 0000000000000000000000000000000000000000000000000000000000000008
Arg [9] : 6e55534443303031000000000000000000000000000000000000000000000000
Deployed Bytecode Sourcemap
1844:18518:0:-:0;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;;1844:18518:0;;;;;;:::i;:::-;1500:62:4;;:::i;:::-;-1:-1:-1;;;;;1844:18518:0;2627:22:4;;2623:91;;3004:6;1844:18518:0;;-1:-1:-1;;;;;;1844:18518:0;;;;;;;-1:-1:-1;;;;;1844:18518:0;3052:40:4;-1:-1:-1;;3052:40:4;1844:18518:0;2623:91:4;2672:31;;;1844:18518:0;2672:31:4;1844:18518:0;;;;;2672:31:4;1844:18518:0;;;;;;;;;;-1:-1:-1;;1844:18518:0;;;;;3445:29;1844:18518;;;;;;;;;:::i;:::-;;;;;;-1:-1:-1;;1844:18518:0;;;;;;;:::i;:::-;;;;;;;;;;;;;-1:-1:-1;;1844:18518:0;;;;;;:::i;:::-;;;:::i;:::-;-1:-1:-1;;;;;1844:18518:0;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;;1844:18518:0;;;;;3179:35;1844:18518;;;;;;;;;;;;;-1:-1:-1;;1844:18518:0;;;;;;;;:::i;:::-;-1:-1:-1;;;;;1844:18518:0;3095:9:10;1844:18518:0;;;;;;;;;;;;3004:116:10;1844:18518:0;;;;;;-1:-1:-1;;1844:18518:0;;;;;10580:51;1844:18518;;:::i;:::-;10603:27;;:::i;:::-;10580:51;;:::i;1844:18518::-;;;;;;-1:-1:-1;;1844:18518:0;;;;2785:36;1844:18518;;;-1:-1:-1;;;;;1844:18518:0;;;;;;;;;;;;;;-1:-1:-1;;1844:18518:0;;;;;;;;:::i;:::-;;:::i;:::-;;:::i;:::-;;;;;;-1:-1:-1;;1844:18518:0;;;;-1:-1:-1;;;;;1844:18518:0;;:::i;:::-;;;;3569:45;1844:18518;;;;;;3569:45;1844:18518;;3569:45;;1844:18518;;;;;;;;;;;;;;;;;-1:-1:-1;;1844:18518:0;;;;;;-1:-1:-1;;;;;1844:18518:0;;;;;;;;1500:62:4;;:::i;:::-;7475:6:0;2020:4;-1:-1:-1;;;;;1844:18518:0;;7457:24;;7453:88;;-1:-1:-1;;;;;;1844:18518:0;;;7475:6;1844:18518;7590:38;1844:18518;;7590:38;1844:18518;7453:88;7504:26;;;1844:18518;7504:26;1844:18518;;7504:26;1844:18518;;;;;;;:::i;:::-;-1:-1:-1;;;;;1844:18518:0;;3095:9:10;1844:18518:0;;;;;;;;;;;7078:16:12;;;9417:18;;;9413:106;;6378:45;;;;:::i;:::-;1181:103:17;;;:::i;:::-;1844:18518:0;;-1:-1:-1;;;17629:40:0;;17663:4;1844:18518;17629:40;;1844:18518;5846:6:12;;1844:18518:0;;;17629:40;1844:18518;-1:-1:-1;;;;;1844:18518:0;;17629:40;;;;;;;1844:18518;17629:40;;;1844:18518;17620:49;;;17616:110;;-1:-1:-1;;;;;1844:18518:0;;;735:10:15;11477:15:12;;;11473:84;;1844:18518:0;8054:21:10;;8050:89;;8177:5;;1844:18518:0;8177:5:10;;;12136:6:12;8177:5:10;;:::i;:::-;12136:6:12;:::i;:::-;1844:18518:0;;;;;;;;;;;;;;;;735:10:15;12159:49:12;1844:18518:0;735:10:15;12159:49:12;;18121:27:0;;:::i;:::-;18095:53;2020:4;18190:15;18158:47;2020:4;1844:18518;-1:-1:-1;;;;;;;;;;;3550:68:18;1844:18518:0;;;;;;8050:89:10;8098:30;;;1844:18518:0;8098:30:10;1844:18518:0;;;17629:40;1844:18518;8098:30:10;11473:84:12;11539:6;735:10:15;;11539:6:12;;:::i;:::-;11473:84;;17616:110:0;17692:23;;;1844:18518;17692:23;1844:18518;;17692:23;17629:40;;;1844:18518;17629:40;;1844:18518;17629:40;;;;;;1844:18518;17629:40;;;:::i;:::-;;;1844:18518;;;;;17629:40;;;;;;-1:-1:-1;17629:40:0;;;1844:18518;;;;;;;;;9413:106:12;9458:50;;;;;1844:18518:0;9458:50:12;1844:18518:0;;;;;;;;;;;;;;9458:50:12;1844:18518:0;;;;;;;:::i;:::-;8931:18:12;;;;;;:::i;:::-;8963;;;8959:108;;7644:44;;;;:::i;:::-;1181:103:17;;;:::i;:::-;1844:18518:0;;-1:-1:-1;;;17629:40:0;;17663:4;1844:18518;17629:40;;1844:18518;5846:6:12;;1844:18518:0;;;17629:40;1844:18518;-1:-1:-1;;;;;1844:18518:0;;17629:40;;;;;;;1844:18518;17629:40;;;1844:18518;17620:49;;;17616:110;;-1:-1:-1;;;;;1844:18518:0;;;735:10:15;11477:15:12;;;11473:84;;1844:18518:0;8054:21:10;;8050:89;;8177:5;;1844:18518:0;8177:5:10;;;12136:6:12;8177:5:10;;:::i;12136:6:12:-;1844:18518:0;;;;;;;;;;;;;;;;735:10:15;12159:49:12;1844:18518:0;735:10:15;12159:49:12;;18121:27:0;;:::i;11473:84:12:-;11539:6;735:10:15;;11539:6:12;;:::i;:::-;11473:84;;17629:40:0;;;1844:18518;17629:40;;1844:18518;17629:40;;;;;;1844:18518;17629:40;;;:::i;:::-;;;1844:18518;;;;;17629:40;;;;;;-1:-1:-1;17629:40:0;;8959:108:12;9004:52;;;;;1844:18518:0;9004:52:12;1844:18518:0;;;;;;;;;;;;;;9004:52:12;1844:18518:0;;;;;;-1:-1:-1;;1844:18518:0;;;;;7443:44:12;1844:18518:0;;7443:44:12;:::i;1844:18518:0:-;;;;;;-1:-1:-1;;1844:18518:0;;;;;;;;:::i;:::-;1181:103:17;;:::i;:::-;13194:11:0;;13190:62;;18121:27;;:::i;:::-;18095:53;2020:4;18190:15;18158:47;2020:4;13344:23;1844:18518;13324:44;;;;;:::i;:::-;13382:14;;;13378:60;;15983:34;13448:21;15983:34;13448:21;1844:18518;13500:47;;;;;:::i;:::-;-1:-1:-1;;;;;1844:18518:0;;;;;;13622:9;1844:18518;;;;;;13622:39;1844:18518;;13557:24;;1844:18518;;13557:24;;1844:18518;;13675:16;;;;-1:-1:-1;13711:21:0;;;;;;13929;-1:-1:-1;;;;;;;;;;;1844:18518:0;14185:48;13929:21;;;;;:::i;:::-;14035:30;14212:21;14035:30;14212:21;;:::i;:::-;14185:48;;:::i;:::-;13707:871;;1844:18518;;;;;;;;;;14596:57;13671:1126;14819:20;14815:949;;13671:1126;1844:18518;;;;13622:9;1844:18518;;;;;;15819:39;2020:4;15983:34;:::i;:::-;15976:4;15956:10;5846:6:12;-1:-1:-1;;;;;1844:18518:0;15983:34;:::i;:::-;1844:18518;-1:-1:-1;;;;;;;;;;;3550:68:18;1844:18518:0;14815:949;14859:29;;;;;;;;;15009:27;;;15697:56;1844:18518;;15139:28;15645:32;15499:73;15139:28;14855:611;;15499:73;;:::i;:::-;1844:18518;;;13622:9;1844:18518;;;;;15586:45;1844:18518;;;15586:45;:::i;:::-;2020:4;;15645:32;1844:18518;15645:32;:::i;:::-;;2020:4;1844:18518;;;;;;;;;;15697:56;14815:949;;;;14855:611;1844:18518;15373:15;15645:32;15499:73;15345:106;15373:15;15372:79;15373:15;;;;;:41;15697:56;15373:15;;:41;:::i;:::-;15372:79;:::i;15345:106::-;14855:611;;;13707:871;14344:24;1844:18518;14477:86;-1:-1:-1;;;;;;;;;;;14344:24:0;14504:59;14344:24;;14504:21;14344:24;;14504:21;;:::i;14477:86::-;13707:871;;;13671:1126;14761:25;;;;;;;13671:1126;;;13378:60;13419:8;;;1844:18518;13419:8;1844:18518;;13419:8;13190:62;13226:15;;;1844:18518;13226:15;1844:18518;;13226:15;1844:18518;;;;;;-1:-1:-1;;1844:18518:0;;;;3459:5:10;1844:18518:0;;:::i;:::-;;;735:10:15;;3459:5:10;:::i;:::-;1844:18518:0;;;;;;;;;;;;;-1:-1:-1;;1844:18518:0;;;;;3305:41;1844:18518;;;;;;;;;;;;;-1:-1:-1;;1844:18518:0;;;;1500:62:4;;:::i;:::-;1844:18518:0;;8338:52;2020:4;1844:18518;;8400:64;2020:4;1844:18518;;8474:40;2020:4;1844:18518;;;;;;;-1:-1:-1;;1844:18518:0;;;;;;;;:::i;:::-;1500:62:4;;;:::i;:::-;1181:103:17;;:::i;:::-;13194:11:0;;13190:62;;18121:27;;:::i;:::-;18095:53;2020:4;18190:15;18158:47;2020:4;13344:23;1844:18518;13324:44;;;;:::i;:::-;13382:14;;13378:60;;1844:18518;13500:47;;;;:::i;:::-;-1:-1:-1;;;;;1844:18518:0;;;;;;13622:9;1844:18518;;;;;;13622:39;1844:18518;;;;;13675:16;;;;13711:21;;;;;;;;;;13929;;14185:48;13929:21;-1:-1:-1;;;;;;;;;;;13929:21:0;1844:18518;13929:21;;:::i;:::-;14035:30;14212:21;14035:30;14212:21;;:::i;14185:48::-;13707:871;;1844:18518;;;;;;;;;14596:57;13671:1126;14819:20;14815:949;;13671:1126;1844:18518;;;;;13622:9;1844:18518;;;;;;15819:39;2020:4;1844:18518;-1:-1:-1;;;;;;;;;;;3550:68:18;1844:18518:0;14815:949;14859:29;;;;;15697:56;14859:29;1844:18518;14859:29;;;14855:611;14859:29;;;15009:27;;1844:18518;15139:28;15645:32;15499:73;15139:28;14855:611;;15499:73;;:::i;:::-;1844:18518;;;13622:9;1844:18518;;;;;15586:45;1844:18518;;;15586:45;:::i;15645:32::-;;2020:4;1844:18518;;;;;;;;;15697:56;14815:949;;;;;14855:611;15499:73;15345:106;15373:15;15372:79;15373:15;;:41;15645:32;15373:15;;:41;:::i;15345:106::-;14855:611;;;13707:871;14344:24;;14477:86;-1:-1:-1;;;;;;;;;;;14344:24:0;14504:59;14344:24;;14504:21;1844:18518;14344:24;14504:21;;:::i;14477:86::-;13707:871;;;13671:1126;14761:25;;;;;13671:1126;;1844:18518;;;;;;-1:-1:-1;;1844:18518:0;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;:::i;:::-;;;;;;;;:::i;:::-;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;1844:18518:0;;-1:-1:-1;1844:18518:0;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;;1844:18518:0;;;;;;;;;;;;;;;;;;;;-1:-1:-1;1844:18518:0;;-1:-1:-1;1844:18518:0;;;;;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;;1844:18518:0;;;;;;;;:::i;:::-;7443:44:12;;;;:::i;:::-;1181:103:17;;;:::i;:::-;11129:6:12;11122:4;;735:10:15;11098:6:12;11129;:::i;:::-;-1:-1:-1;;;;;1844:18518:0;;;7528:21:10;;7524:91;;7653:5;;1844:18518:0;7653:5:10;;:::i;:::-;1844:18518:0;;;;;;;;;;11185:41:12;1844:18518:0;735:10:15;11185:41:12;;18121:27:0;;:::i;7524:91:10:-;7572:32;;;1844:18518:0;7572:32:10;1844:18518:0;;;;;7572:32:10;1844:18518:0;;;;;;-1:-1:-1;;1844:18518:0;;;;1710:6:4;1844:18518:0;;;-1:-1:-1;;;;;1844:18518:0;;;;;;;;;;;;;;-1:-1:-1;;1844:18518:0;;;;;;;:::i;:::-;;;;;;-1:-1:-1;;1844:18518:0;;;;1500:62:4;;:::i;:::-;3004:6;1844:18518:0;;-1:-1:-1;;;;;;1844:18518:0;;;;;;;-1:-1:-1;;;;;1844:18518:0;3052:40:4;1844:18518:0;;3052:40:4;1844:18518:0;;;;;;;-1:-1:-1;;1844:18518:0;;;;;;;;:::i;:::-;6176:45:12;;;;:::i;:::-;1181:103:17;;;:::i;:::-;11129:6:12;11122:4;;735:10:15;11098:6:12;11129;:::i;:::-;-1:-1:-1;;;;;1844:18518:0;;;7528:21:10;;7524:91;;7653:5;;1844:18518:0;7653:5:10;;:::i;:::-;1844:18518:0;;;;;;;;;;11185:41:12;1844:18518:0;735:10:15;11185:41:12;;18121:27:0;;:::i;1844:18518::-;;;;;;-1:-1:-1;;1844:18518:0;;;;19172:48;9223:27;;:::i;:::-;19172:17;1844:18518;19172:48;:::i;:::-;1844:18518;;-1:-1:-1;;;9623:40:0;;9657:4;1844:18518;9623:40;;1844:18518;;;9623:40;1844:18518;5846:6:12;-1:-1:-1;;;;;1844:18518:0;9623:40;;;;;;;1844:18518;9623:40;;;1844:18518;;9680:43;9603:60;;;;;:::i;:::-;9680:43;;:::i;9623:40::-;;;1844:18518;9623:40;;1844:18518;9623:40;;;;;;1844:18518;9623:40;;;:::i;:::-;;;1844:18518;;;;;;9623:40;;;;;-1:-1:-1;9623:40:0;;1844:18518;;;;;;-1:-1:-1;;1844:18518:0;;;;;19172:48;9223:27;;:::i;1844:18518::-;;;;;;-1:-1:-1;;1844:18518:0;;;;;;;;:::i;:::-;;:::i;:::-;;;;;;-1:-1:-1;;1844:18518:0;;;;;10123:48;1844:18518;;:::i;:::-;10143:27;;:::i;:::-;10123:48;;:::i;1844:18518::-;;:::i;:::-;;;;;;-1:-1:-1;;1844:18518:0;;;;;;5846:6:12;-1:-1:-1;;;;;1844:18518:0;;;;;;;;;;;;-1:-1:-1;;1844:18518:0;;;;;5676:19:12;1844:18518:0;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;;1844:18518:0;;;;;;;;:::i;:::-;;;-1:-1:-1;;;;;1844:18518:0;;;;;;;;;;;1181:103:17;;:::i;:::-;1500:62:4;;:::i;:::-;1844:18518:0;;5236:15;:24;5232:46;;5292:13;;:24;5288:58;;18121:27;;;:::i;:::-;18095:53;2020:4;18190:15;18158:47;2020:4;5421:63;5440:23;1844:18518;5421:63;;:::i;:::-;5501:6;2020:4;1844:18518;;-1:-1:-1;;;5501:16:0;;1844:18518;;;;;;;;;-1:-1:-1;;;;;1844:18518:0;5501:16;;;;;;;1844:18518;5501:16;;;1844:18518;5487:56;;1844:18518;5487:56;5608:32;5421:122;5487:56;;;5832:6;5487:56;5855:37;5487:56;;:::i;5421:122::-;1844:18518;;;;;;;;;;;5553:9;1844:18518;;;;;5553:45;1844:18518;;;5553:45;:::i;:::-;2020:4;;5608:32;1844:18518;5608:32;:::i;:::-;;2020:4;1844:18518;;;5553:9;1844:18518;;;;;;5654:39;1844:18518;5654:44;5650:132;;1844:18518;5846:6:12;-1:-1:-1;;;;;1844:18518:0;5832:6;:::i;:::-;1844:18518;;;;;5855:37;1844:18518;-1:-1:-1;;;;;;;;;;;3550:68:18;1844:18518:0;5650:132;1844:18518;;;5553:9;1844:18518;;5236:15;1844:18518;;;;5714:39;2020:4;5650:132;;5501:16;;;;;1844:18518;5501:16;;1844:18518;5501:16;;;;;;1844:18518;5501:16;;;:::i;:::-;;;1844:18518;;;;;;;;;;5501:16;;;;;-1:-1:-1;5501:16:0;;5288:58;5325:21;;;1844:18518;5325:21;1844:18518;;;;5325:21;5232:46;5269:9;;;1844:18518;5269:9;1844:18518;;5269:9;1844:18518;;;;;;-1:-1:-1;;1844:18518:0;;;;4986:5:10;1844:18518:0;;:::i;:::-;;;:::i;:::-;;;735:10:15;4950:5:10;735:10:15;;4950:5:10;;:::i;:::-;4986;:::i;1844:18518:0:-;;;;;;-1:-1:-1;;1844:18518:0;;;;;2927:12:10;1844:18518:0;;;;;;;;;;;;;-1:-1:-1;;1844:18518:0;;;;;7644:44:12;1844:18518:0;;7644:44:12;:::i;1844:18518:0:-;;;;;;-1:-1:-1;;1844:18518:0;;;;;;:::i;:::-;;;735:10:15;;9813:19:10;9809:89;;-1:-1:-1;;;;;1844:18518:0;;9911:21:10;;9907:90;;735:10:15;1844:18518:0;;;;;;;;;-1:-1:-1;1844:18518:0;;;;;-1:-1:-1;1844:18518:0;2020:4;1844:18518;;;;;10085:31:10;1844:18518:0;735:10:15;10085:31:10;;1844:18518:0;;;;;;;9907:90:10;9955:31;;;1844:18518:0;9955:31:10;1844:18518:0;;;;;9955:31:10;9809:89;9855:32;;;1844:18518:0;9855:32:10;1844:18518:0;;;;;9855:32:10;1844:18518:0;;;;;;-1:-1:-1;;1844:18518:0;;;;;;;1856:5:10;1844:18518:0;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;:::i;:::-;;;;1856:5:10;1844:18518:0;;;;;;;;;;;;-1:-1:-1;1844:18518:0;;-1:-1:-1;1844:18518:0;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;;1844:18518:0;;;;;;;:::i;:::-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;;1844:18518:0;;;;:::o;:::-;;;;;;-1:-1:-1;;1844:18518:0;;;;;6378:45:12;1844:18518:0;;6378:45:12;:::i;1844:18518:0:-;;;;-1:-1:-1;;;;;1844:18518:0;;;;;;:::o;:::-;;;;-1:-1:-1;;;;;1844:18518:0;;;;;;:::o;:::-;;;;;;-1:-1:-1;;1844:18518:0;;;;;;:::i;:::-;;;;;6563:17:12;;1844:18518:0;;;;;;;;;;;;;;;;;-1:-1:-1;;;;;1844:18518:0;;;;;;;;;-1:-1:-1;;;;;1844:18518:0;;;;;;;:::o;:::-;;;;;;-1:-1:-1;;1844:18518:0;;;;;6176:45:12;1844:18518:0;;6176:45:12;:::i;1844:18518:0:-;;;;;;;;;;;;;;;;;;;;;:::o;:::-;;;;-1:-1:-1;1844:18518:0;;;;;-1:-1:-1;1844:18518:0;;;;;;;;;;;:::o;8725:171::-;19172:48;9223:27;;:::i;19172:48::-;1844:18518;;-1:-1:-1;;;8849:40:0;;8883:4;8849:40;;;1844:18518;;;;8849:40;1844:18518;5846:6:12;-1:-1:-1;;;;;1844:18518:0;8849:40;;;;;;;-1:-1:-1;8849:40:0;;;8725:171;8828:61;;;;:::i;:::-;8725:171;:::o;8849:40::-;;;1844:18518;8849:40;;1844:18518;8849:40;;;;;;1844:18518;8849:40;;;:::i;:::-;;;1844:18518;;;;8828:61;1844:18518;;8849:40;;;;;;-1:-1:-1;8849:40:0;;1844:18518;;;;;;;;;;:::o;10962:428::-;-1:-1:-1;;;;;1844:18518:0;;;;;11065:9;1844:18518;;;;;;11065:39;1844:18518;;11114:252;;11375:8;1844:18518;10962:428;:::o;11114:252::-;11204:6;2020:4;1844:18518;;-1:-1:-1;;;11204:22:0;;1844:18518;;;;;;11204:22;;1844:18518;;-1:-1:-1;;;;;1844:18518:0;11204:22;;;;;;;1844:18518;11204:22;;;11114:252;11182:44;;;;:::i;:::-;11264:15;11244:35;;11240:116;;11375:8;1844:18518;10962:428;:::o;11240:116::-;11306:35;11264:15;;11306:35;:::i;11204:22::-;;;1844:18518;11204:22;;1844:18518;11204:22;;;;;;1844:18518;11204:22;;;:::i;:::-;;;1844:18518;;;;11182:44;1844:18518;;11204:22;;;;;;-1:-1:-1;11204:22:0;;12404:251;1844:18518;;;;;12477:6;2020:4;1844:18518;19172:48;12514:23;1844:18518;19172:17;1844:18518;19172:48;:::i;:::-;1844:18518;;-1:-1:-1;;;18689:40:0;;18723:4;18689:40;;;1844:18518;;;18689:40;1844:18518;5846:6:12;-1:-1:-1;;;;;1844:18518:0;18689:40;;;;;;;1844:18518;18689:40;;;12404:251;18669:60;;;18746:43;18669:60;1844:18518;18669:60;;:::i;18746:43::-;18689:40;1844:18518;;;;;;;;;12477:62;;18689:40;12477:62;;1844:18518;12477:62;;;;;;;1844:18518;12477:62;;;12404:251;12553:24;2266:12;12553:24;;12549:79;;12404:251;:::o;12549:79::-;12593:24;2266:12;12593:24;:::o;12477:62::-;;;1844:18518;12477:62;;1844:18518;12477:62;;;;;;1844:18518;12477:62;;;:::i;:::-;;;1844:18518;;;;;12477:62;;;;;;-1:-1:-1;12477:62:0;;18689:40;;;1844:18518;18689:40;;1844:18518;18689:40;;;;;;1844:18518;18689:40;;;:::i;:::-;;;1844:18518;;;;;;18689:40;;;;;-1:-1:-1;18689:40:0;;6788:153:12;1844:18518:0;;;;;;3095:9:10;1844:18518:0;3095:9:10;1844:18518:0;;6879:55:12;1844:18518:0;3095:9:10;1844:18518:0;;6879:55:12;:::i;11609:531:0:-;11687:23;1844:18518;11687:28;;;11731:10;2020:4;11731:10;:::o;11683:451::-;11951:14;;;:::i;:::-;2020:4;1844:18518;;;2020:4;1844:18518;;;11987:47;12005:29;1844:18518;11987:15;:47;:::i;:::-;11909:143;;435:7:3;2020:4:0;679:19:3;1844:18518:0;453:321:3;460:6;;;11861:262:0;;;;;;;:::i;453:321:3:-;482:15;;;;1844:18518:0;;537:3:3;1844:18518:0;;;534:1:3;530:5;;;;;570:1;125:4;;565:12;;560:95;;537:3;679:9;;;;:::i;:::-;1844:18518:0;;;;;;;;570:1:3;2020:4:0;1844:18518;;;537:3:3;125:4;1844:18518:0;517:11:3;;;560:95;612:7;;;;;:::i;:::-;1844:18518:0;;;;;;;;2020:4;1844:18518;;;560:95:3;;530:5;;;;;;;;;534:1;1844:18518:0;756:7:3;;453:321;;;10125:213:12;10262:13;;:::i;:::-;1844:18518:0;7468:18:12;1844:18518:0;;;;;;;2927:12:10;1844:18518:0;7468:18:12;1844:18518:0;;;;;;;10248:83:12;;7468:18;10248:83;;:::i;10125:213::-;10262:13;;:::i;:::-;1844:18518:0;10278:1:12;1844:18518:0;;;;;;;2927:12:10;1844:18518:0;10278:1:12;1844:18518:0;;;;;;;10248:83:12;;1844:18518:0;10248:83:12;;:::i;9788:213::-;2927:12:10;1844:18518:0;9941:23:12;7669:18;1844:18518:0;;;;;;;9966:13:12;;:::i;:::-;7669:18;1844:18518:0;;;;;;;9911:83:12;;7669:18;9911:83;;:::i;9788:213::-;2927:12:10;1844:18518:0;9941:23:12;1844:18518:0;;;;;;;;9966:13:12;;:::i;:::-;1844:18518:0;;;;;;;;9911:83:12;;1844:18518:0;9911:83:12;;:::i;10415:476:10:-;-1:-1:-1;;;;;1844:18518:0;;;-1:-1:-1;1844:18518:0;;;;;;;;;;;;;;;;;;;;;;;;;;10415:476:10;;-1:-1:-1;;10580:36:10;;10576:309;;10415:476;;;;;:::o;10576:309::-;10636:24;;;10632:130;;9813:19;;9809:89;;-1:-1:-1;;;;;1844:18518:0;;9911:21:10;9907:90;;-1:-1:-1;1844:18518:0;3657:11:10;1844:18518:0;;;-1:-1:-1;1844:18518:0;10006:27:10;1844:18518:0;;;;;;-1:-1:-1;1844:18518:0;;;;-1:-1:-1;1844:18518:0;;;2020:4;;10576:309:10;;;;;;10632:130;10687:60;;;;;;-1:-1:-1;10687:60:10;1844:18518:0;;;;;;10687:60:10;1844:18518:0;;;;;;-1:-1:-1;10687:60:10;5393:300;-1:-1:-1;;;;;1844:18518:0;;5476:18:10;;5472:86;;-1:-1:-1;;;;;1844:18518:0;;5571:16:10;;5567:86;;1844:18518:0;5492:1:10;1844:18518:0;5492:1:10;1844:18518:0;;;5492:1:10;1844:18518:0;;6340:19:10;;;6336:115;;1844:18518:0;-1:-1:-1;;;;;;;;;;;1844:18518:0;;;;5492:1:10;1844:18518:0;5492:1:10;1844:18518:0;;;;5492:1:10;1844:18518:0;2020:4;1844:18518;5492:1:10;1844:18518:0;5492:1:10;1844:18518:0;;;5492:1:10;1844:18518:0;;;;;2020:4;;1844:18518;;;;;7083:25:10;5393:300::o;6336:115::-;6386:50;;;;5492:1;6386:50;;1844:18518:0;;;;;;5492:1:10;6386:50;1290:346:17;-1:-1:-1;;;;;;;;;;;3321:69:18;1413:93:17;;1624:4;-1:-1:-1;;;;;;;;;;;3550:68:18;1290:346:17:o;1413:93::-;1465:30;;;-1:-1:-1;1465:30:17;;-1:-1:-1;1465:30:17;1796:162:4;1710:6;1844:18518:0;-1:-1:-1;;;;;1844:18518:0;735:10:15;1855:23:4;1851:101;;1796:162::o;1851:101::-;1901:40;;;-1:-1:-1;1901:40:4;735:10:15;1901:40:4;1844:18518:0;;-1:-1:-1;1901:40:4;9291:238:20;;9418:25;;2020:4:0;9418:25:20;;:::i;:::-;9462:26;9492:25;;;;2020:4:0;9418:104:20;9492:25;;:29;;9418:104;;:::i;9492:25::-;1844:18518:0;;;-1:-1:-1;1844:18518:0;;;;;-1:-1:-1;1844:18518:0;9291:238:20;2020:4:0;9418:104:20;9291:238;9418:25;;;;;:::i;:::-;9462:26;9492:25;:29;;9418:104;;:::i;9291:238::-;;;9418:25;;;;;:::i;:::-;1844:18518:0;;;;;;;28136:1:20;1844:18518:0;;;28113:24:20;9462:59;;;;9291:238;34863:71:21;;9418:104:20;34863:71:21;;;;9418:104:20;;:::i;9462:59::-;9492:25;;;;;;;9418:104;9492:25;;:29;;9462:59;;;;1844:18518:0;;;;-1:-1:-1;1844:18518:0;;;;;-1:-1:-1;1844:18518:0;1219:160:14;1844:18518:0;;-1:-1:-1;;;1328:43:14;;;;-1:-1:-1;;;;;1844:18518:0;;;1328:43:14;;;1844:18518:0;;;;;;;;;1328:43:14;;;;;;;1844:18518:0;1328:43:14;:::i;:::-;;:::i;:::-;1219:160::o;19553:175:0:-;-1:-1:-1;;;;;1844:18518:0;-1:-1:-1;1844:18518:0;;;19660:9;1844:18518;;;;;;19660:61;;19553:175;19660:61;:::i;1844:18518::-;;;;;;;:::o;4996:4166:20:-;;;;1844:18518:0;;;;6563:17:12;;;5572:131:20;;;;;;;;;;;;;;5784:10;;5780:368;;6254:20;2020:4:0;6254:20:20;;6250:143;;6679:300;1844:18518:0;6679:300:20;;2020:4:0;6679:300:20;;;;;;;;1844:18518:0;;6679:300:20;;7243:371;;7680:21;1844:18518:0;4996:4166:20;:::o;6250:143::-;1829:135:16;;;940:4;1829:135;;;;;5780:368:20;6114:19;;;2020:4:0;6114:19:20;;;1844:18518:0;6107:26:20;:::o;4996:4166::-;;2020:4:0;1844:18518;;6563:17:12;;;2020:4:0;5572:131:20;;;;;;;;;;;;;5784:10;;5780:368;;6254:20;;;;6250:143;;2020:4:0;6679:300:20;;;1844:18518:0;;;7198:31:20;;7243:371;;;8056:1;1844:18518:0;8037:1:20;1844:18518:0;8036:21:20;1844:18518:0;;;8056:1:20;1844:18518:0;;;;;8056:1:20;1844:18518:0;;;;;8056:1:20;1844:18518:0;;;;;8056:1:20;1844:18518:0;;;;;8056:1:20;1844:18518:0;;;;;8056:1:20;1844:18518:0;;7243:371:20;;;;1844:18518:0;7243:371:20;;;6679:300;;;;;;1844:18518:0;6679:300:20;;7243:371;7680:21;1844:18518:0;4996:4166:20;:::o;6250:143::-;1829:135:16;;1844:18518:0;1829:135:16;6314:16:20;3066:5;1844:18518:0;940:4:16;3060:42:20;1829:135:16;;;;;5780:368:20;6114:19;;;;;;:::i;4996:4166::-;;1844:18518:0;;;;-1:-1:-1;;1844:18518:0;4996:4166:20;5572:131;;;;;;;;;;;;5784:10;;5780:368;;6254:20;;;;6250:143;;6679:300;;;;1844:18518:0;;;7198:31:20;;7243:371;;;8056:1;1844:18518:0;8037:1:20;1844:18518:0;8036:21:20;1844:18518:0;;;8056:1:20;1844:18518:0;;;;;8056:1:20;1844:18518:0;;;;;8056:1:20;1844:18518:0;;;;;8056:1:20;1844:18518:0;;;;;8056:1:20;1844:18518:0;;;;;8056:1:20;1844:18518:0;;7243:371:20;;;;1844:18518:0;7243:371:20;;;6679:300;;;;;;1844:18518:0;6679:300:20;;7243:371;7680:21;1844:18518:0;4996:4166:20;:::o;6250:143::-;1829:135:16;;1844:18518:0;1829:135:16;6314:16:20;3066:5;1844:18518:0;940:4:16;3060:42:20;1829:135:16;;;;;5780:368:20;6114:19;;;;;;;:::i;1844:18518:0:-;;;;;;;;;;;;;;;;:::o;20061:299::-;;20184:21;;;:::i;:::-;20219:17;;20215:31;;20265:38;:53;:38;20327:20;20265:38;;:::i;:::-;:53;:::i;:::-;20327:6;2020:4;1844:18518;;-1:-1:-1;;;20327:20:0;;1844:18518;20327:20;;1844:18518;;;;;-1:-1:-1;;;;;1844:18518:0;20327:20;;;;;;;1844:18518;20327:20;;;20061:299;20264:89;;;;:::i;20327:20::-;;;;;;;;;;;;;1844:18518;20327:20;;;:::i;:::-;;;1844:18518;;;;20264:89;1844:18518;;20327:20;;;;;;-1:-1:-1;20327:20:0;;20215:31;20238:8;;;1844:18518;20238:8;:::o;6008:1107:10:-;-1:-1:-1;;;;;;;;;;;1844:18518:0;;6008:1107:10;6233:21;1844:18518:0;6233:21:10;1844:18518:0;6233:21:10;:::i;:::-;;2020:4:0;-1:-1:-1;;;;;1844:18518:0;;6647:16:10;;1844:18518:0;;;;;6233:21:10;1844:18518:0;;6233:21:10;2020:4:0;6643:425:10;1844:18518:0;;;;;7083:25:10;6008:1107::o;6643:425::-;1844:18518:0;;;;;;;;;;;;;2020:4;;6643:425:10;;6008:1107;;;;-1:-1:-1;;;;;1844:18518:0;6097:18:10;1844:18518:0;;-1:-1:-1;;;;;;;;;;;1844:18518:0;;6233:21:10;1844:18518:0;;;6233:21:10;1844:18518:0;6233:21:10;:::i;:::-;;2020:4:0;6093:540:10;1844:18518:0;6810:21:10;1844:18518:0;;6810:21:10;2020:4:0;1844:18518;;;;;7083:25:10;6008:1107::o;6093:540::-;1844:18518:0;;;;;;;;;;6340:19:10;;;6336:115;;1844:18518:0;;;;;-1:-1:-1;;;;;;;;;;;1844:18518:0;;;;;;;;;;;2020:4;6093:540:10;;6336:115;6386:50;;;;;1844:18518:0;6386:50:10;;1844:18518:0;;;;;;;6386:50:10;7686:720:14;;-1:-1:-1;7823:421:14;7686:720;7823:421;;;;;;;;;;;;-1:-1:-1;7823:421:14;;8258:15;;-1:-1:-1;;;;;;1844:18518:0;;8276:26:14;:31;8258:68;8254:146;;7686:720;:::o;8254:146::-;-1:-1:-1;;;;8349:40:14;;;-1:-1:-1;;;;;1844:18518:0;;;;8349:40:14;1844:18518:0;;;8349:40:14;8258:68;8325:1;8310:16;;8258:68;;1618:188;1844:18518:0;;-1:-1:-1;;;1745:53:14;;;;-1:-1:-1;;;;;1844:18518:0;;;1745:53:14;;;1844:18518:0;;;;;;;;;;;;;;;;;1745:53:14;;;;;;;1844:18518:0;1745:53:14;:::i
Swarm Source
none://164736f6c634300081c000a
Loading...
Loading
Loading...
Loading
Multichain Portfolio | 34 Chains
| Chain | Token | Portfolio % | Price | Amount | Value |
|---|---|---|---|---|---|
| KATANA | 100.00% | $0.988067 | 50.1 | $49.5 |
Loading...
Loading
Loading...
Loading
Loading...
Loading
[ Download: CSV Export ]
[ 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.