Source Code
More Info
Private Name Tags
ContractCreator
TokenTracker
Latest 1 internal transaction
| Parent Transaction Hash | Block | From | To | |||
|---|---|---|---|---|---|---|
| 41072554 | 88 days ago | Contract Creation | 0 ETH |
Cross-Chain Transactions
Loading...
Loading
Similar Match Source Code This contract matches the deployed Bytecode of the Source Code for Contract 0x067D7809...c42B9E89A The constructor portion of the code might be different and could alter the actual behaviour of the contract
Contract Name:
ArtistToken
Compiler Version
v0.8.29+commit.ab55807c
Optimization Enabled:
Yes with 1000 runs
Other Settings:
cancun EvmVersion
Contract Source Code (Solidity Standard Json-Input format)
// SPDX-License-Identifier: BUSL-1.1
pragma solidity ^0.8.28;
import {Withdrawable} from "./helpers/Withdrawable.sol";
import {IArtistTokenFactory} from "./interfaces/IArtistTokenFactory.sol";
import {Ownable, Ownable2Step} from "openzeppelin-contracts/access/Ownable2Step.sol";
import {IERC20} from "openzeppelin-contracts/interfaces/IERC20.sol";
import {IERC4626} from "openzeppelin-contracts/interfaces/IERC4626.sol";
import {Initializable} from "openzeppelin-contracts/proxy/utils/Initializable.sol";
import {ERC1155} from "openzeppelin-contracts/token/ERC1155/ERC1155.sol";
import {SafeERC20} from "openzeppelin-contracts/token/ERC20/utils/SafeERC20.sol";
import {ReentrancyGuardTransient} from "openzeppelin-contracts/utils/ReentrancyGuardTransient.sol";
/// @title ArtistToken
/// @notice An ERC1155 token contract for a single artist token with interest-generating capabilities for the artist.
contract ArtistToken is ERC1155, ReentrancyGuardTransient, Ownable2Step, Withdrawable, Initializable {
using SafeERC20 for IERC20;
// =============================================================
// ERRORS
// =============================================================
/// @notice Error thrown when the total principal is insufficient for the refund amount.
error InsufficientPrincipal();
/// @notice Error thrown when the shares received from depositing into a vault are less than expected.
error InsufficientSharesReceived();
/// @notice Error thrown when the shares redeemed from withdrawing from a vault are greater than expected.
error ExcessiveSharesRedeemed();
/// @notice Error thrown when attempting to update the URI after it has been made immutable.
error MetadataUriImmutable();
/// @notice Error thrown when attempting to migrate from a vault to the same vault.
error SameVault();
/// @notice Error thrown when attempting to withdraw from a vault that was never used.
error VaultNeverUsed();
/// @notice Error thrown when the vault provided is not approved in the ArtistTokenFactory.
error VaultNotApproved();
/// @notice Error thrown when the provided ERC4626 vault's `asset` is not the payment token and is thus incompatible.
error VaultIncompatible();
// =============================================================
// EVENTS
// =============================================================
/**
* @notice Emitted when deposits are made and tokens are minted.
*
* @param account Address of the account that received the minted ERC1155 ArtistTokens
* @param tokensMinted Number of ERC1155 ArtistTokens minted
* @param deposit Amount of ERC20 payment token assets deposited into the vault
* @param vault Address of the ERC4626 vault into which the assets were deposited
* @param sharesReceived Number of vault shares received in exchange for the deposit
*/
event DepositAndMint(
address indexed account, uint256 tokensMinted, uint256 deposit, address vault, uint256 sharesReceived
);
/**
* @notice Emitted when tokens are burned and the corresponding assets are withdrawn.
*
* @param account Address of the account that burned the ERC1155 ArtistTokens
* @param tokensBurned Number of ERC1155 ArtistTokens burned
* @param withdrawal Amount of ERC20 payment token assets withdrawn from the vault to the account
* @param vault Address of the ERC4626 vault from which the assets were withdrawn
* @param sharesRedeemed Number of shares redeemed in exchange for the withdrawal from the vault
*/
event BurnAndWithdraw(
address indexed account, uint256 tokensBurned, uint256 withdrawal, address vault, uint256 sharesRedeemed
);
/**
* @notice Emitted when the artist withdraws interest from the vault.
*
* @param to Address of the account that received the interest
* @param withdrawal Amount of interest withdrawn from the vault in the ERC20 payment token
* @param sharesRedeemed Number of shares redeemed in exchange for the withdrawal from the current vault
*/
event WithdrawInterest(address indexed to, uint256 withdrawal, uint256 sharesRedeemed);
/**
* @notice Emitted when deposits are migrated from one vault to another.
*
* @param fromVault Address of the old ERC4626 vault
* @param toVault Address of the new ERC4626 vault
* @param assetsTransferred Amount of ERC20 payment token assets transferred from the old vault to the new vault
* @param oldVaultSharesRedeemed Number of shares redeemed in exchange for the withdrawal from the old vault
* @param newVaultSharesReceived Number of shares received in exchange for depositing into the new vault
*/
event MigrateDeposits(
address indexed fromVault,
address indexed toVault,
uint256 assetsTransferred,
uint256 oldVaultSharesRedeemed,
uint256 newVaultSharesReceived
);
/**
* @notice Emitted when the contract is deployed.
*
* @param factory Address of the factory that deployed this contract
* @param paymentToken Address of the ERC20 payment token
* @param owner Address of the contract owner (artist wallet)
* @param mintPrice The price for minting an artist token, denominated in the payment token
* @param tokenId The token ID of the ERC1155 artist token
*/
event Deployed(
address indexed factory, address indexed paymentToken, address owner, uint256 mintPrice, uint256 tokenId
);
/// @notice Emitted when the token URI is locked (made immutable).
event MetadataUriLocked();
// =============================================================
// CONSTANTS
// =============================================================
/// @notice The token ID of the artist token.
uint256 public constant TOKEN_ID = 1;
// =============================================================
// IMMUTABLES
// =============================================================
/// @notice The address of the factory that deployed this contract.
address public immutable FACTORY;
/// @notice The address of the ERC20 payment token (e.g., USDC).
address public immutable PAYMENT_TOKEN;
/**
* @notice The price for minting an artist token, denominated in the payment token (including decimals).
* @dev This should always be a single "unit" of the payment token. For example, for USDC, 1_000_000 = $1.
*/
uint256 public immutable MINT_PRICE;
// =============================================================
// STORAGE VARIABLES
// =============================================================
/// @notice The ERC4626 vault that generates yield/interest for the artist.
IERC4626 public vault;
/// @notice Mapping to track if a vault has been used by this contract for deposits.
mapping(address vault => bool wasUsed) public wasUsedVault;
/// @notice The total principal deposited (user deposits, not including interest).
uint256 public principalDeposit;
/// @notice Flag indicating whether the metadata URI is locked (immutable if set to true).
bool public metadataUriLocked;
// =============================================================
// CONSTRUCTOR / INITIALIZATION
// =============================================================
/**
* @notice Constructor for the ArtistToken contract.
*
* @dev Sets immutables - other variables are set in initialize.
*
* @param artist_ Address of the artist wallet
* @param paymentToken Address of the ERC20 payment token
* @param mintPrice Price per token mint, denominated in the payment token
*/
constructor(address artist_, address paymentToken, uint256 mintPrice) ERC1155("") Ownable(artist_) {
// Set immutables
FACTORY = msg.sender;
PAYMENT_TOKEN = paymentToken;
MINT_PRICE = mintPrice;
emit Deployed({
factory: msg.sender,
paymentToken: paymentToken,
owner: artist_,
mintPrice: mintPrice,
tokenId: TOKEN_ID
});
}
/**
* @notice Initializes the contract with initial parameters.
*
* @dev Can only be called once by the factory.
*
* @param vault_ Address of the yield-generating / interest-generating ERC4626 vault
* @param metadataUri_ URI for token metadata
*/
function initialize(address vault_, string calldata metadataUri_) external initializer {
// ----- CHECKS -----
if (msg.sender != FACTORY) revert Unauthorized();
if (!IArtistTokenFactory(FACTORY).isApprovedVault(vault_)) revert VaultNotApproved();
// Sanity check - the factory allowlist _should_ take care of this,
// but we want to be extra careful and make sure the ERC4626 vault `asset` is compatible with the payment token for this contract
if (IERC4626(vault_).asset() != PAYMENT_TOKEN) revert VaultIncompatible();
// Set metadata URI
_setURI(metadataUri_);
// Set vault
wasUsedVault[vault_] = true;
vault = IERC4626(vault_);
emit MigrateDeposits({
fromVault: address(0),
toVault: vault_,
assetsTransferred: 0,
oldVaultSharesRedeemed: 0,
newVaultSharesReceived: 0
});
// Approve the vault to transfer the payment token on behalf of this contract
_approveMaxVault(vault_);
}
// =============================================================
// EXTERNAL FUNCTIONS
// =============================================================
/**
* @notice Mints new tokens to the specified account.
*
* @dev Intentionally non-pausable, even if the vault has an adverse event, because the supply of artist tokens should always be uncapped.
* @dev This function does not have a vault parameter like burn() because we are always depositing into the current vault.
*
* @param account Address to receive the tokens
* @param amount Number of artist tokens to mint
* @param minSharesReceived Minimum number of vault shares expected to be received when depositing into the vault
*/
function mint(address account, uint256 amount, uint256 minSharesReceived) external nonReentrant {
_depositAndMint(account, amount, minSharesReceived);
}
/**
* @notice Burns tokens from the specified account.
*
* @param account The address of the account to burn the tokens from
* @param amount The amount of artist tokens to burn
* @param vault_ The address of the ERC4626 vault to withdraw from
* @param maxSharesRedeemed The maximum number of shares to redeem when withdrawing from the vault
*/
function burn(address account, uint256 amount, address vault_, uint256 maxSharesRedeemed) external nonReentrant {
_burnAndWithdraw(account, amount, vault_, maxSharesRedeemed);
}
// =============================================================
// ARTIST FUNCTIONS
// =============================================================
/**
* @notice Withdraws a specific amount of interest to the artist's wallet.
*
* @dev We explicitly pass an amount to account for scenarios where the vault's rounding may be unreliable,
* where attempting to withdraw the theoretical "maximum" would fail due to rounding issues.
* So, we pass the amount to withdraw rather than rely on calculations that may be affected by rounding discrepancies.
* @dev We revert if (getWithdrawableBalance() < principalDeposit) so the artist cannot withdraw more than the available interest.
*
* @param to The address to withdraw the interest to
* @param interestAmount The amount of interest to withdraw
* @param maxSharesRedeemed The maximum number of shares to redeem when withdrawing from the vault
*/
function withdrawInterest(address to, uint256 interestAmount, uint256 maxSharesRedeemed)
external
onlyOwner
nonReentrant
{
_withdrawInterest(to, interestAmount, maxSharesRedeemed);
}
/**
* @notice Migrates deposits from the current vault to a new vault.
*
* @dev This function withdraws the _currently withdrawable_ assets from the current vault and deposits them into the new one.
* This might mean some assets are left behind, but they could be recovered when liquidity becomes available by calling continueMigration().
*
* @param newVault The address of the new vault (must be an ERC4626 vault)
* @param maxSharesRedeemed The maximum number of shares to be redeemed when withdrawing from the old vault
* @param minSharesReceived The minimum number of shares expected to be received when depositing into the new vault
* @param maxAmountToMigrate The maximum amount of assets to migrate (in case maxWithdraw() returns an incorrect value for some reason)
*/
function migrate(address newVault, uint256 maxSharesRedeemed, uint256 minSharesReceived, uint256 maxAmountToMigrate)
external
onlyOwner
nonReentrant
{
_migrate({
oldVault: address(vault),
newVault: newVault,
maxSharesRedeemed: maxSharesRedeemed,
minSharesReceived: minSharesReceived,
maxAmountToMigrate: maxAmountToMigrate
});
}
/**
* @notice Continues migration from an old vault to the current vault.
*
* @dev This function withdraws the _currently withdrawable_ assets from the old vault and deposits them into the current vault.
* It might not be possible to migrate all deposits in a single operation due to liquidity or withdrawal limits,
* so there needs to be a way to continue a migration that previously occurred.
*
* @param oldVault The address of the old vault (must be an ERC4626 vault)
* @param maxSharesRedeemed The maximum number of shares to be redeemed when withdrawing from the old vault
* @param minSharesReceived The minimum number of shares expected to be received when depositing into the new vault
* @param maxAmountToMigrate The maximum amount of assets to migrate (in case maxWithdraw() returns an incorrect value for some reason)
*/
function continueMigration(
address oldVault,
uint256 maxSharesRedeemed,
uint256 minSharesReceived,
uint256 maxAmountToMigrate
) external onlyOwner nonReentrant {
_migrate({
oldVault: oldVault,
newVault: address(vault),
maxSharesRedeemed: maxSharesRedeemed,
minSharesReceived: minSharesReceived,
maxAmountToMigrate: maxAmountToMigrate
});
}
/**
* @notice Updates the token metadata URI.
*
* @param newMetadataUri The new URI for the token metadata
*/
function setMetadataUri(string calldata newMetadataUri) external onlyOwner nonReentrant {
_setURI(newMetadataUri);
}
/**
* @notice Makes the token URI immutable, preventing any future updates.
*
* @dev Once called, this action cannot be undone.
*/
function makeUriImmutable() external onlyOwner nonReentrant {
metadataUriLocked = true;
emit MetadataUriLocked();
}
// =============================================================
// INTERNAL FUNCTIONS
// =============================================================
/**
* @notice Mints new tokens to the specified account in exchange for payment in the ERC20 payment token,
* and deposits the payment token into the current vault.
*
* @dev Intentionally non-pausable, even if the vault has an adverse event, because the supply of artist tokens should always be uncapped.
* @dev We revert if `sharesReceived == 0` because the artist token should never receive 0 shares for a vault deposit.
*
* @param account Address to receive the tokens
* @param tokenAmount Number of artist tokens to mint
* @param minSharesReceived Minimum number of vault shares expected to be received when depositing into the current vault
*/
function _depositAndMint(address account, uint256 tokenAmount, uint256 minSharesReceived) internal {
// ----- EFFECTS -----
uint256 totalPayment = MINT_PRICE * tokenAmount;
principalDeposit += totalPayment;
// ----- INTERACTIONS -----
// Process the payment first to prevent the recipient from temporarily holding both the token and the asset
// during checkOnERC1155Received() - which could effectively be utilized as a flash loan
IERC20(PAYMENT_TOKEN).safeTransferFrom({from: msg.sender, to: address(this), value: totalPayment});
// Deposit the payment token into the current vault
uint256 sharesReceived = vault.deposit(totalPayment, address(this));
if (sharesReceived == 0) revert InsufficientSharesReceived();
if (sharesReceived < minSharesReceived) revert InsufficientSharesReceived();
// Mint the artist tokens to the account
_mint(account, TOKEN_ID, tokenAmount, "");
emit DepositAndMint({
account: account,
tokensMinted: tokenAmount,
deposit: totalPayment,
vault: address(vault),
sharesReceived: sharesReceived
});
}
/**
* @notice Burns tokens from the specified account and withdraws the corresponding amount of assets from the specified vault.
*
* @dev The vault address is passed as a parameter to allow users to burn tokens and withdraw from any vault previously used by this
* ArtistToken contract. This is necessary so users can access their funds even when they are spread across multiple vaults due to a partial migration.
* @dev The vault specified by a user must be true in the `wasUsedVault` mapping, which tracks all vaults that have ever held funds for this ArtistToken contract.
*
* @param account The address of the account to burn tokens from
* @param tokenAmount The number of artist tokens to burn
* @param vault_ The address of the ERC4626 vault to withdraw from
* @param maxSharesRedeemed The maximum number of shares to be redeemed when withdrawing from the vault
*/
function _burnAndWithdraw(address account, uint256 tokenAmount, address vault_, uint256 maxSharesRedeemed)
internal
{
// ----- CHECKS -----
if (account != msg.sender && !isApprovedForAll(account, msg.sender)) {
revert ERC1155MissingApprovalForAll(msg.sender, account);
}
if (!wasUsedVault[vault_]) revert VaultNeverUsed();
uint256 refundAmount = MINT_PRICE * tokenAmount;
if (refundAmount > principalDeposit) revert InsufficientPrincipal();
// ----- EFFECTS -----
principalDeposit -= refundAmount;
// ----- INTERACTIONS -----
// Intentionally burn tokens first before sending refund,
// to prevent the recipient from temporarily holding both the artist tokens and the payment token
_burn(account, TOKEN_ID, tokenAmount);
// Withdraw from the specified vault and send the assets to the specified account
uint256 sharesRedeemed = IERC4626(vault_).withdraw(refundAmount, account, address(this));
if (sharesRedeemed > maxSharesRedeemed) revert ExcessiveSharesRedeemed();
emit BurnAndWithdraw({
account: account,
tokensBurned: tokenAmount,
withdrawal: refundAmount,
vault: vault_,
sharesRedeemed: sharesRedeemed
});
}
/**
* @notice Withdraws a specific amount of interest to the artist's wallet.
*
* @dev We explicitly pass an amount to account for scenarios where the vault's rounding may be unreliable,
* where attempting to withdraw the theoretical "maximum" would fail due to rounding issues.
* So, we pass the amount to withdraw rather than rely on calculations that may be affected by rounding discrepancies.
* @dev We revert if (getWithdrawableBalance() < principalDeposit) so the artist cannot withdraw more than the available interest.
*
* @param to The address to withdraw the interest to
* @param interestAmount The amount of interest to withdraw
* @param maxSharesRedeemed The maximum number of shares to redeem when withdrawing from the vault
*/
function _withdrawInterest(address to, uint256 interestAmount, uint256 maxSharesRedeemed) internal {
// ----- INTERACTIONS -----
// Use address(this) for owner since the artist token contract holds shares of the vault
uint256 sharesRedeemed = vault.withdraw(interestAmount, to, address(this));
// ----- POST CHECKS -----
// No more than `maxSharesRedeemed` were redeemed (in case the vault rounding was unreliable)
if (sharesRedeemed > maxSharesRedeemed) revert ExcessiveSharesRedeemed();
// The artist is not able to dip into user deposits when withdrawing interest
if (getWithdrawableBalance() < principalDeposit) revert InsufficientPrincipal();
// ----- EVENTS -----
emit WithdrawInterest({to: to, withdrawal: interestAmount, sharesRedeemed: sharesRedeemed});
}
/**
* @notice Migrates deposits from an old vault to a new vault.
*
* @dev This function withdraws the _currently withdrawable_ assets from the old vault and deposits them into the new one.
* This might mean some assets are left behind, but they could be recovered when liquidity is available by calling continueMigration().
*
* @param oldVault The address of the old vault (must be an ERC4626 vault)
* @param newVault The address of the new vault (must be an ERC4626 vault)
* @param maxSharesRedeemed The maximum number of shares to be redeemed when withdrawing from the old vault
* @param minSharesReceived The minimum number of shares expected to be received when depositing into the new vault
* @param maxAmountToMigrate The maximum amount of assets to migrate (in case maxWithdraw() returns an incorrect value for some reason)
*/
function _migrate(
address oldVault,
address newVault,
uint256 maxSharesRedeemed,
uint256 minSharesReceived,
uint256 maxAmountToMigrate
) internal {
// ----- CHECKS -----
// We can't migrate from a vault to that same vault
if (oldVault == newVault) revert SameVault();
// We can't migrate assets from a vault we've never used before
if (!wasUsedVault[oldVault]) revert VaultNeverUsed();
// We can't migrate to a vault that isn't on the factory's allowlist
if (!IArtistTokenFactory(FACTORY).isApprovedVault(newVault)) revert VaultNotApproved();
// Sanity check - the factory allowlist _should_ take care of this,
// but we want to be extra careful and make sure the ERC4626 vault `asset` is compatible with the payment token for this contract
if (IERC4626(newVault).asset() != PAYMENT_TOKEN) revert VaultIncompatible();
// ----- EFFECTS -----
wasUsedVault[newVault] = true;
vault = IERC4626(newVault);
// ----- INTERACTIONS -----
// Determine how much of the ERC20 payment token to migrate from the old vault to the new vault
// The migration amount is the minimum of the `maxWithdrawableAmount` and the `maxAmountToMigrate`
uint256 maxWithdrawableAmount = IERC4626(oldVault).maxWithdraw(address(this));
uint256 migrateAmount = maxWithdrawableAmount > maxAmountToMigrate ? maxAmountToMigrate : maxWithdrawableAmount;
// Withdraw from old ERC4626 vault
uint256 sharesRedeemed = IERC4626(oldVault).withdraw(migrateAmount, address(this), address(this));
if (sharesRedeemed > maxSharesRedeemed) revert ExcessiveSharesRedeemed();
// Revoke the allowance for the old vault.
IERC20(PAYMENT_TOKEN).forceApprove(oldVault, 0);
// Deposit into new ERC4626 vault
_approveMaxVault(newVault);
uint256 sharesReceived = IERC4626(newVault).deposit(migrateAmount, address(this));
if (sharesReceived == 0) revert InsufficientSharesReceived();
if (sharesReceived < minSharesReceived) revert InsufficientSharesReceived();
emit MigrateDeposits({
fromVault: oldVault,
toVault: newVault,
assetsTransferred: migrateAmount,
oldVaultSharesRedeemed: sharesRedeemed,
newVaultSharesReceived: sharesReceived
});
}
/**
* @notice Approve the ERC4626 vault address to spend the maximum amount of payment token assets.
*
* @dev We check elsewhere that the vault's `asset` is the same as the payment token for this contract.
*
* @param vaultToApprove The ERC4626 vault address to approve
*/
function _approveMaxVault(address vaultToApprove) internal {
IERC20(PAYMENT_TOKEN).forceApprove(vaultToApprove, type(uint256).max);
}
// =============================================================
// VIEW FUNCTIONS
// =============================================================
/**
* @notice Get the address of the artist (the contract owner).
*
* @return The address of the artist
*/
function artist() external view returns (address) {
return owner();
}
/**
* @notice Get the expected total balance of this artist token contract in the current vault.
*
* @dev This represents the sum of all payments made from minting artist tokens plus any expected yield/interest generated.
* @dev If there is a non-zero balance in a previously used vault due to a partial migration, it will not be included in this calculation.
*
* @return expectedVaultAssets The expected total balance of this artist token contract including accrued interest, denominated in payment token units
*/
function getExpectedTotalBalance() public view returns (uint256 expectedVaultAssets) {
return getExpectedTotalBalance(address(vault));
}
/**
* @notice Get the expected total balance of this artist token contract in a specific vault.
*
* @dev This represents the sum of all payments made from minting artist tokens plus any expected yield/interest generated.
* @dev If there is a non-zero balance in another vault due to a partial migration, it will not be included in this calculation.
*
* @param vault_ The address of the ERC4626 vault to get the total balance from
*
* @return expectedVaultAssets The expected total balance of this artist token contract including accrued interest, denominated in payment token units
*/
function getExpectedTotalBalance(address vault_) public view returns (uint256 expectedVaultAssets) {
uint256 vaultShares = IERC4626(vault_).balanceOf(address(this));
expectedVaultAssets = IERC4626(vault_).previewRedeem(vaultShares);
}
/**
* @notice Get the total withdrawable balance of this artist token contract in the current vault.
*
* @dev This represents the maximum amount of assets that can be withdrawn from the vault at this moment.
* This takes into account withdrawal limits and timelocks (unlike getExpectedTotalBalance()).
* @dev If there is a non-zero balance in a previously used vault due to a partial migration, it will not be included in this calculation.
*
* @return vaultAssets The total withdrawable balance of this artist token contract, denominated in payment token units
*/
function getWithdrawableBalance() public view returns (uint256 vaultAssets) {
return getWithdrawableBalance(address(vault));
}
/**
* @notice Get the total withdrawable balance of this artist token contract in a specific vault.
*
* @dev This represents the maximum amount of assets that can be withdrawn from the vault at this moment.
* This takes into account withdrawal limits and timelocks (unlike getExpectedTotalBalance()).
* @dev If there is a non-zero balance in another vault due to a partial migration, it will not be included in this calculation.
*
* @param vault_ The address of the ERC4626 vault to get the total withdrawable balance from
*
* @return vaultAssets The total withdrawable balance of this artist token contract, denominated in payment token units
*/
function getWithdrawableBalance(address vault_) public view returns (uint256 vaultAssets) {
return IERC4626(vault_).maxWithdraw(address(this));
}
/**
* @notice Calculate the expected total interest in the current vault.
*
* @dev This represents the expected total balance of this artist token contract in the current vault minus user deposits (i.e., principalDeposit).
* @dev If there is a non-zero balance in a previously used vault due to a partial migration, it will not be included in this calculation.
*
* @return expectedInterest The expected total interest accrued in the current vault, denominated in payment token units
*/
function getExpectedTotalInterest() public view returns (uint256 expectedInterest) {
uint256 expectedTotalBalance = getExpectedTotalBalance();
if (expectedTotalBalance < principalDeposit) return 0;
expectedInterest = expectedTotalBalance - principalDeposit;
}
/**
* @notice Calculate the total interest available to withdraw from the current vault at this moment.
*
* @dev This represents the total withdrawable balance of this artist token contract in the current vault minus user deposits (i.e., principalDeposit).
* @dev If there is a non-zero balance in a previously used vault due to a partial migration, it will not be included in this calculation.
*
* @return interest The total interest available to withdraw from the current vault, denominated in payment token units
*/
function getWithdrawableInterest() public view returns (uint256 interest) {
uint256 withdrawableBalance = getWithdrawableBalance();
if (withdrawableBalance < principalDeposit) return 0;
interest = withdrawableBalance - principalDeposit;
}
// =============================================================
// INTERNAL OVERRIDE FUNCTIONS
// =============================================================
/**
* @notice Override for ERC1155 _setURI with metadata lock check and emitted event.
*
* @param newMetadataUri The new metadata URI to set
*/
function _setURI(string memory newMetadataUri) internal override {
if (metadataUriLocked) revert MetadataUriImmutable();
super._setURI(newMetadataUri);
emit URI(newMetadataUri, TOKEN_ID);
}
/**
* @notice Override for Withdrawable so the owner/artist can rescue ETH, ERC20, ERC721, and ERC1155 tokens
* that would otherwise be lost if sent to this contract.
*
* @return bool True if the caller is authorized to withdraw
*/
function _canWithdraw() internal view override returns (bool) {
return msg.sender == owner();
}
/**
* @notice Override for Withdrawable to check if a token is protected (non-withdrawable).
*
* @dev The ERC20 "shares" from any ERC4626 vault used by this artist token should NOT be withdrawable by the owner/artist.
*
* @param token The token address to check
*
* @return bool True if the token is protected from withdrawal
*/
function _isProtectedToken(address token) internal view override returns (bool) {
return wasUsedVault[token];
}
// =============================================================
// INTERFACE
// =============================================================
/// @dev See {IERC165-supportsInterface}.
function supportsInterface(bytes4 interfaceId) public view virtual override(ERC1155, Withdrawable) returns (bool) {
return ERC1155.supportsInterface(interfaceId) || Withdrawable.supportsInterface(interfaceId)
|| super.supportsInterface(interfaceId);
}
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.28;
import {IERC1155} from "openzeppelin-contracts/interfaces/IERC1155.sol";
import {IERC20} from "openzeppelin-contracts/interfaces/IERC20.sol";
import {IERC721} from "openzeppelin-contracts/interfaces/IERC721.sol";
import {SafeERC20} from "openzeppelin-contracts/token/ERC20/utils/SafeERC20.sol";
import {ERC1155Holder} from "openzeppelin-contracts/token/ERC1155/utils/ERC1155Holder.sol";
import {ERC721Holder} from "openzeppelin-contracts/token/ERC721/utils/ERC721Holder.sol";
/// @notice Abstract contract that provides the ability to withdraw ETH, ERC20, ERC721, and ERC1155 tokens.
/// @dev The implementing contract will need to implement/override the _canWithdraw() function.
abstract contract Withdrawable is ERC721Holder, ERC1155Holder {
using SafeERC20 for IERC20;
// =============================================================
// EVENTS
// =============================================================
/// @notice Emitted when ETH is withdrawn from the contract.
event WithdrawnETH(address receiver, uint256 amount);
/// @notice Emitted when an ERC20 token is withdrawn from the contract.
event WithdrawnERC20(address receiver, address token, uint256 amount);
/// @notice Emitted when an ERC721 token is withdrawn from the contract.
event WithdrawnERC721(address receiver, address token, uint256 tokenId);
/// @notice Emitted when an ERC1155 token is withdrawn from the contract.
event WithdrawnERC1155(address receiver, address token, uint256 tokenId, uint256 amount);
// =============================================================
// ERRORS
// =============================================================
/// @notice Error emitted when the caller is not authorized to withdraw funds.
error Unauthorized();
/// @notice Error emitted when the provided address is the zero address.
error AddressZero();
/// @notice Error emitted when the provided asset is protected (non-withdrawable).
error ProtectedToken();
/// @notice Error emitted when the provided amount to withdraw exceeds the contract's balance.
error InsufficientBalance();
/// @notice Error emitted when the withdrawal fails.
error WithdrawalFailed();
// =============================================================
// MODIFIERS
// =============================================================
/// @notice Modifier that checks if the caller is authorized to withdraw funds.
modifier canWithdraw() {
if (!_canWithdraw()) revert Unauthorized();
_;
}
// =============================================================
// WITHDRAW ETH
// =============================================================
/// @notice Withdraws all ETH from the contract to the specified receiver address.
/// The `canWithdraw` modifier makes this function safe and callable only by authorized addresses.
// slither-disable-next-line arbitrary-send-eth
function withdraw(address receiver) external canWithdraw {
if (receiver == address(0)) revert AddressZero();
emit WithdrawnETH(receiver, address(this).balance);
(bool sent,) = payable(receiver).call{value: address(this).balance}("");
if (!sent) revert WithdrawalFailed();
}
// =============================================================
// WITHDRAW ERC20
// =============================================================
/// @notice Withdraws all ERC20 tokens from the contract to the specified receiver address.
function withdrawERC20(address receiver, address token) external canWithdraw {
uint256 totalBalance = IERC20(token).balanceOf(address(this));
_withdrawERC20(receiver, token, totalBalance);
}
/// @dev Withdraws `amount` of an ERC20 token from the contract.
function _withdrawERC20(address receiver, address token, uint256 amount) internal {
if (receiver == address(0)) revert AddressZero();
if (token == address(0)) revert AddressZero();
if (_isProtectedToken(token)) revert ProtectedToken();
IERC20 erc20 = IERC20(token);
if (erc20.balanceOf(address(this)) < amount) revert InsufficientBalance();
emit WithdrawnERC20(receiver, token, amount);
erc20.safeTransfer(receiver, amount);
}
// =============================================================
// WITHDRAW ERC721
// =============================================================
/// @notice Withdraws an ERC721 token from the contract to the specified receiver address.
function withdrawERC721(address receiver, address token, uint256 tokenId) external canWithdraw {
if (receiver == address(0)) revert AddressZero();
if (token == address(0)) revert AddressZero();
if (_isProtectedToken(token)) revert ProtectedToken();
emit WithdrawnERC721(receiver, token, tokenId);
IERC721 erc721 = IERC721(token);
erc721.safeTransferFrom(address(this), receiver, tokenId);
}
// =============================================================
// WITHDRAW ERC1155
// =============================================================
/// @notice Withdraws all ERC1155 tokens from the contract to the specified receiver address.
function withdrawERC1155(address receiver, address token, uint256 tokenId, bytes calldata data)
external
canWithdraw
{
uint256 totalBalance = IERC1155(token).balanceOf(address(this), tokenId);
_withdrawERC1155({receiver: receiver, token: token, tokenId: tokenId, amount: totalBalance, data: data});
}
/// @dev Withdraws `amount` of an ERC1155 token from the contract.
function _withdrawERC1155(address receiver, address token, uint256 tokenId, uint256 amount, bytes calldata data)
internal
{
if (receiver == address(0)) revert AddressZero();
if (token == address(0)) revert AddressZero();
if (_isProtectedToken(token)) revert ProtectedToken();
IERC1155 erc1155 = IERC1155(token);
if (erc1155.balanceOf(address(this), tokenId) < amount) revert InsufficientBalance();
emit WithdrawnERC1155(receiver, token, tokenId, amount);
erc1155.safeTransferFrom({from: address(this), to: receiver, id: tokenId, value: amount, data: data});
}
// =============================================================
// INTERNAL FUNCTIONS
// =============================================================
/**
* @dev Checks if the caller is authorized to withdraw funds.
*
* @return bool True if the caller is authorized, false otherwise
*/
function _canWithdraw() internal view virtual returns (bool);
/**
* @dev Checks whether the given token is protected (non-withdrawable).
*
* @param token The address of the token to check
*
* @return bool True if the token is protected, false otherwise
*/
function _isProtectedToken(address token) internal view virtual returns (bool);
// =============================================================
// INTERFACE
// =============================================================
/// @dev See {IERC165-supportsInterface}.
function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
return super.supportsInterface(interfaceId);
}
}// SPDX-License-Identifier: BUSL-1.1
pragma solidity ^0.8.28;
/// @notice Minimal interface for the ArtistTokenFactory.
interface IArtistTokenFactory {
/// @notice The address of the ERC20 payment token used for minting ArtistTokens created by this factory.
function PAYMENT_TOKEN() external view returns (address);
/// @notice The price for minting one ArtistToken created by this factory, denominated in the payment token.
function MINT_PRICE() external view returns (uint256);
/**
* @notice Checks whether an ArtistToken exists (i.e., the ArtistToken has been created by the factory).
*
* @param artistToken The address of the ArtistToken to check
*
* @return exists True if the ArtistToken exists, false otherwise
*/
function isArtistToken(address artistToken) external view returns (bool exists);
/**
* @notice Checks if a vault is approved for use.
*
* @param vault The address of the vault to check
*
* @return isApproved True if the vault is approved, false otherwise
*/
function isApprovedVault(address vault) external view returns (bool isApproved);
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.1.0) (access/Ownable2Step.sol)
pragma solidity ^0.8.20;
import {Ownable} from "./Ownable.sol";
/**
* @dev Contract module which provides access control mechanism, where
* there is an account (an owner) that can be granted exclusive access to
* specific functions.
*
* This extension of the {Ownable} contract includes a two-step mechanism to transfer
* ownership, where the new owner must call {acceptOwnership} in order to replace the
* old one. This can help prevent common mistakes, such as transfers of ownership to
* incorrect accounts, or to contracts that are unable to interact with the
* permission system.
*
* The initial owner is specified at deployment time in the constructor for `Ownable`. This
* can later be changed with {transferOwnership} and {acceptOwnership}.
*
* This module is used through inheritance. It will make available all functions
* from parent (Ownable).
*/
abstract contract Ownable2Step is Ownable {
address private _pendingOwner;
event OwnershipTransferStarted(address indexed previousOwner, address indexed newOwner);
/**
* @dev Returns the address of the pending owner.
*/
function pendingOwner() public view virtual returns (address) {
return _pendingOwner;
}
/**
* @dev Starts the ownership transfer of the contract to a new account. Replaces the pending transfer if there is one.
* Can only be called by the current owner.
*
* Setting `newOwner` to the zero address is allowed; this can be used to cancel an initiated ownership transfer.
*/
function transferOwnership(address newOwner) public virtual override onlyOwner {
_pendingOwner = newOwner;
emit OwnershipTransferStarted(owner(), newOwner);
}
/**
* @dev Transfers ownership of the contract to a new account (`newOwner`) and deletes any pending owner.
* Internal function without access restriction.
*/
function _transferOwnership(address newOwner) internal virtual override {
delete _pendingOwner;
super._transferOwnership(newOwner);
}
/**
* @dev The new owner accepts the ownership transfer.
*/
function acceptOwnership() public virtual {
address sender = _msgSender();
if (pendingOwner() != sender) {
revert OwnableUnauthorizedAccount(sender);
}
_transferOwnership(sender);
}
}// 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.0.0) (proxy/utils/Initializable.sol)
pragma solidity ^0.8.20;
/**
* @dev This is a base contract to aid in writing upgradeable contracts, or any kind of contract that will be deployed
* behind a proxy. Since proxied contracts do not make use of a constructor, it's common to move constructor logic to an
* external initializer function, usually called `initialize`. It then becomes necessary to protect this initializer
* function so it can only be called once. The {initializer} modifier provided by this contract will have this effect.
*
* The initialization functions use a version number. Once a version number is used, it is consumed and cannot be
* reused. This mechanism prevents re-execution of each "step" but allows the creation of new initialization steps in
* case an upgrade adds a module that needs to be initialized.
*
* For example:
*
* [.hljs-theme-light.nopadding]
* ```solidity
* contract MyToken is ERC20Upgradeable {
* function initialize() initializer public {
* __ERC20_init("MyToken", "MTK");
* }
* }
*
* contract MyTokenV2 is MyToken, ERC20PermitUpgradeable {
* function initializeV2() reinitializer(2) public {
* __ERC20Permit_init("MyToken");
* }
* }
* ```
*
* TIP: To avoid leaving the proxy in an uninitialized state, the initializer function should be called as early as
* possible by providing the encoded function call as the `_data` argument to {ERC1967Proxy-constructor}.
*
* CAUTION: When used with inheritance, manual care must be taken to not invoke a parent initializer twice, or to ensure
* that all initializers are idempotent. This is not verified automatically as constructors are by Solidity.
*
* [CAUTION]
* ====
* Avoid leaving a contract uninitialized.
*
* An uninitialized contract can be taken over by an attacker. This applies to both a proxy and its implementation
* contract, which may impact the proxy. To prevent the implementation contract from being used, you should invoke
* the {_disableInitializers} function in the constructor to automatically lock it when it is deployed:
*
* [.hljs-theme-light.nopadding]
* ```
* /// @custom:oz-upgrades-unsafe-allow constructor
* constructor() {
* _disableInitializers();
* }
* ```
* ====
*/
abstract contract Initializable {
/**
* @dev Storage of the initializable contract.
*
* It's implemented on a custom ERC-7201 namespace to reduce the risk of storage collisions
* when using with upgradeable contracts.
*
* @custom:storage-location erc7201:openzeppelin.storage.Initializable
*/
struct InitializableStorage {
/**
* @dev Indicates that the contract has been initialized.
*/
uint64 _initialized;
/**
* @dev Indicates that the contract is in the process of being initialized.
*/
bool _initializing;
}
// keccak256(abi.encode(uint256(keccak256("openzeppelin.storage.Initializable")) - 1)) & ~bytes32(uint256(0xff))
bytes32 private constant INITIALIZABLE_STORAGE = 0xf0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a00;
/**
* @dev The contract is already initialized.
*/
error InvalidInitialization();
/**
* @dev The contract is not initializing.
*/
error NotInitializing();
/**
* @dev Triggered when the contract has been initialized or reinitialized.
*/
event Initialized(uint64 version);
/**
* @dev A modifier that defines a protected initializer function that can be invoked at most once. In its scope,
* `onlyInitializing` functions can be used to initialize parent contracts.
*
* Similar to `reinitializer(1)`, except that in the context of a constructor an `initializer` may be invoked any
* number of times. This behavior in the constructor can be useful during testing and is not expected to be used in
* production.
*
* Emits an {Initialized} event.
*/
modifier initializer() {
// solhint-disable-next-line var-name-mixedcase
InitializableStorage storage $ = _getInitializableStorage();
// Cache values to avoid duplicated sloads
bool isTopLevelCall = !$._initializing;
uint64 initialized = $._initialized;
// Allowed calls:
// - initialSetup: the contract is not in the initializing state and no previous version was
// initialized
// - construction: the contract is initialized at version 1 (no reininitialization) and the
// current contract is just being deployed
bool initialSetup = initialized == 0 && isTopLevelCall;
bool construction = initialized == 1 && address(this).code.length == 0;
if (!initialSetup && !construction) {
revert InvalidInitialization();
}
$._initialized = 1;
if (isTopLevelCall) {
$._initializing = true;
}
_;
if (isTopLevelCall) {
$._initializing = false;
emit Initialized(1);
}
}
/**
* @dev A modifier that defines a protected reinitializer function that can be invoked at most once, and only if the
* contract hasn't been initialized to a greater version before. In its scope, `onlyInitializing` functions can be
* used to initialize parent contracts.
*
* A reinitializer may be used after the original initialization step. This is essential to configure modules that
* are added through upgrades and that require initialization.
*
* When `version` is 1, this modifier is similar to `initializer`, except that functions marked with `reinitializer`
* cannot be nested. If one is invoked in the context of another, execution will revert.
*
* Note that versions can jump in increments greater than 1; this implies that if multiple reinitializers coexist in
* a contract, executing them in the right order is up to the developer or operator.
*
* WARNING: Setting the version to 2**64 - 1 will prevent any future reinitialization.
*
* Emits an {Initialized} event.
*/
modifier reinitializer(uint64 version) {
// solhint-disable-next-line var-name-mixedcase
InitializableStorage storage $ = _getInitializableStorage();
if ($._initializing || $._initialized >= version) {
revert InvalidInitialization();
}
$._initialized = version;
$._initializing = true;
_;
$._initializing = false;
emit Initialized(version);
}
/**
* @dev Modifier to protect an initialization function so that it can only be invoked by functions with the
* {initializer} and {reinitializer} modifiers, directly or indirectly.
*/
modifier onlyInitializing() {
_checkInitializing();
_;
}
/**
* @dev Reverts if the contract is not in an initializing state. See {onlyInitializing}.
*/
function _checkInitializing() internal view virtual {
if (!_isInitializing()) {
revert NotInitializing();
}
}
/**
* @dev Locks the contract, preventing any future reinitialization. This cannot be part of an initializer call.
* Calling this in the constructor of a contract will prevent that contract from being initialized or reinitialized
* to any version. It is recommended to use this to lock implementation contracts that are designed to be called
* through proxies.
*
* Emits an {Initialized} event the first time it is successfully executed.
*/
function _disableInitializers() internal virtual {
// solhint-disable-next-line var-name-mixedcase
InitializableStorage storage $ = _getInitializableStorage();
if ($._initializing) {
revert InvalidInitialization();
}
if ($._initialized != type(uint64).max) {
$._initialized = type(uint64).max;
emit Initialized(type(uint64).max);
}
}
/**
* @dev Returns the highest version that has been initialized. See {reinitializer}.
*/
function _getInitializedVersion() internal view returns (uint64) {
return _getInitializableStorage()._initialized;
}
/**
* @dev Returns `true` if the contract is currently initializing. See {onlyInitializing}.
*/
function _isInitializing() internal view returns (bool) {
return _getInitializableStorage()._initializing;
}
/**
* @dev Returns a pointer to the storage namespace.
*/
// solhint-disable-next-line var-name-mixedcase
function _getInitializableStorage() private pure returns (InitializableStorage storage $) {
assembly {
$.slot := INITIALIZABLE_STORAGE
}
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.1.0) (token/ERC1155/ERC1155.sol)
pragma solidity ^0.8.20;
import {IERC1155} from "./IERC1155.sol";
import {IERC1155MetadataURI} from "./extensions/IERC1155MetadataURI.sol";
import {ERC1155Utils} from "./utils/ERC1155Utils.sol";
import {Context} from "../../utils/Context.sol";
import {IERC165, ERC165} from "../../utils/introspection/ERC165.sol";
import {Arrays} from "../../utils/Arrays.sol";
import {IERC1155Errors} from "../../interfaces/draft-IERC6093.sol";
/**
* @dev Implementation of the basic standard multi-token.
* See https://eips.ethereum.org/EIPS/eip-1155
* Originally based on code by Enjin: https://github.com/enjin/erc-1155
*/
abstract contract ERC1155 is Context, ERC165, IERC1155, IERC1155MetadataURI, IERC1155Errors {
using Arrays for uint256[];
using Arrays for address[];
mapping(uint256 id => mapping(address account => uint256)) private _balances;
mapping(address account => mapping(address operator => bool)) private _operatorApprovals;
// Used as the URI for all token types by relying on ID substitution, e.g. https://token-cdn-domain/{id}.json
string private _uri;
/**
* @dev See {_setURI}.
*/
constructor(string memory uri_) {
_setURI(uri_);
}
/**
* @dev See {IERC165-supportsInterface}.
*/
function supportsInterface(bytes4 interfaceId) public view virtual override(ERC165, IERC165) returns (bool) {
return
interfaceId == type(IERC1155).interfaceId ||
interfaceId == type(IERC1155MetadataURI).interfaceId ||
super.supportsInterface(interfaceId);
}
/**
* @dev See {IERC1155MetadataURI-uri}.
*
* This implementation returns the same URI for *all* token types. It relies
* on the token type ID substitution mechanism
* https://eips.ethereum.org/EIPS/eip-1155#metadata[defined in the ERC].
*
* Clients calling this function must replace the `\{id\}` substring with the
* actual token type ID.
*/
function uri(uint256 /* id */) public view virtual returns (string memory) {
return _uri;
}
/**
* @dev See {IERC1155-balanceOf}.
*/
function balanceOf(address account, uint256 id) public view virtual returns (uint256) {
return _balances[id][account];
}
/**
* @dev See {IERC1155-balanceOfBatch}.
*
* Requirements:
*
* - `accounts` and `ids` must have the same length.
*/
function balanceOfBatch(
address[] memory accounts,
uint256[] memory ids
) public view virtual returns (uint256[] memory) {
if (accounts.length != ids.length) {
revert ERC1155InvalidArrayLength(ids.length, accounts.length);
}
uint256[] memory batchBalances = new uint256[](accounts.length);
for (uint256 i = 0; i < accounts.length; ++i) {
batchBalances[i] = balanceOf(accounts.unsafeMemoryAccess(i), ids.unsafeMemoryAccess(i));
}
return batchBalances;
}
/**
* @dev See {IERC1155-setApprovalForAll}.
*/
function setApprovalForAll(address operator, bool approved) public virtual {
_setApprovalForAll(_msgSender(), operator, approved);
}
/**
* @dev See {IERC1155-isApprovedForAll}.
*/
function isApprovedForAll(address account, address operator) public view virtual returns (bool) {
return _operatorApprovals[account][operator];
}
/**
* @dev See {IERC1155-safeTransferFrom}.
*/
function safeTransferFrom(address from, address to, uint256 id, uint256 value, bytes memory data) public virtual {
address sender = _msgSender();
if (from != sender && !isApprovedForAll(from, sender)) {
revert ERC1155MissingApprovalForAll(sender, from);
}
_safeTransferFrom(from, to, id, value, data);
}
/**
* @dev See {IERC1155-safeBatchTransferFrom}.
*/
function safeBatchTransferFrom(
address from,
address to,
uint256[] memory ids,
uint256[] memory values,
bytes memory data
) public virtual {
address sender = _msgSender();
if (from != sender && !isApprovedForAll(from, sender)) {
revert ERC1155MissingApprovalForAll(sender, from);
}
_safeBatchTransferFrom(from, to, ids, values, data);
}
/**
* @dev Transfers a `value` amount of tokens of type `id` from `from` to `to`. Will mint (or burn) if `from`
* (or `to`) is the zero address.
*
* Emits a {TransferSingle} event if the arrays contain one element, and {TransferBatch} otherwise.
*
* Requirements:
*
* - If `to` refers to a smart contract, it must implement either {IERC1155Receiver-onERC1155Received}
* or {IERC1155Receiver-onERC1155BatchReceived} and return the acceptance magic value.
* - `ids` and `values` must have the same length.
*
* NOTE: The ERC-1155 acceptance check is not performed in this function. See {_updateWithAcceptanceCheck} instead.
*/
function _update(address from, address to, uint256[] memory ids, uint256[] memory values) internal virtual {
if (ids.length != values.length) {
revert ERC1155InvalidArrayLength(ids.length, values.length);
}
address operator = _msgSender();
for (uint256 i = 0; i < ids.length; ++i) {
uint256 id = ids.unsafeMemoryAccess(i);
uint256 value = values.unsafeMemoryAccess(i);
if (from != address(0)) {
uint256 fromBalance = _balances[id][from];
if (fromBalance < value) {
revert ERC1155InsufficientBalance(from, fromBalance, value, id);
}
unchecked {
// Overflow not possible: value <= fromBalance
_balances[id][from] = fromBalance - value;
}
}
if (to != address(0)) {
_balances[id][to] += value;
}
}
if (ids.length == 1) {
uint256 id = ids.unsafeMemoryAccess(0);
uint256 value = values.unsafeMemoryAccess(0);
emit TransferSingle(operator, from, to, id, value);
} else {
emit TransferBatch(operator, from, to, ids, values);
}
}
/**
* @dev Version of {_update} that performs the token acceptance check by calling
* {IERC1155Receiver-onERC1155Received} or {IERC1155Receiver-onERC1155BatchReceived} on the receiver address if it
* contains code (eg. is a smart contract at the moment of execution).
*
* IMPORTANT: Overriding this function is discouraged because it poses a reentrancy risk from the receiver. So any
* update to the contract state after this function would break the check-effect-interaction pattern. Consider
* overriding {_update} instead.
*/
function _updateWithAcceptanceCheck(
address from,
address to,
uint256[] memory ids,
uint256[] memory values,
bytes memory data
) internal virtual {
_update(from, to, ids, values);
if (to != address(0)) {
address operator = _msgSender();
if (ids.length == 1) {
uint256 id = ids.unsafeMemoryAccess(0);
uint256 value = values.unsafeMemoryAccess(0);
ERC1155Utils.checkOnERC1155Received(operator, from, to, id, value, data);
} else {
ERC1155Utils.checkOnERC1155BatchReceived(operator, from, to, ids, values, data);
}
}
}
/**
* @dev Transfers a `value` tokens of token type `id` from `from` to `to`.
*
* Emits a {TransferSingle} event.
*
* Requirements:
*
* - `to` cannot be the zero address.
* - `from` must have a balance of tokens of type `id` of at least `value` amount.
* - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155Received} and return the
* acceptance magic value.
*/
function _safeTransferFrom(address from, address to, uint256 id, uint256 value, bytes memory data) internal {
if (to == address(0)) {
revert ERC1155InvalidReceiver(address(0));
}
if (from == address(0)) {
revert ERC1155InvalidSender(address(0));
}
(uint256[] memory ids, uint256[] memory values) = _asSingletonArrays(id, value);
_updateWithAcceptanceCheck(from, to, ids, values, data);
}
/**
* @dev xref:ROOT:erc1155.adoc#batch-operations[Batched] version of {_safeTransferFrom}.
*
* Emits a {TransferBatch} event.
*
* Requirements:
*
* - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155BatchReceived} and return the
* acceptance magic value.
* - `ids` and `values` must have the same length.
*/
function _safeBatchTransferFrom(
address from,
address to,
uint256[] memory ids,
uint256[] memory values,
bytes memory data
) internal {
if (to == address(0)) {
revert ERC1155InvalidReceiver(address(0));
}
if (from == address(0)) {
revert ERC1155InvalidSender(address(0));
}
_updateWithAcceptanceCheck(from, to, ids, values, data);
}
/**
* @dev Sets a new URI for all token types, by relying on the token type ID
* substitution mechanism
* https://eips.ethereum.org/EIPS/eip-1155#metadata[defined in the ERC].
*
* By this mechanism, any occurrence of the `\{id\}` substring in either the
* URI or any of the values in the JSON file at said URI will be replaced by
* clients with the token type ID.
*
* For example, the `https://token-cdn-domain/\{id\}.json` URI would be
* interpreted by clients as
* `https://token-cdn-domain/000000000000000000000000000000000000000000000000000000000004cce0.json`
* for token type ID 0x4cce0.
*
* See {uri}.
*
* Because these URIs cannot be meaningfully represented by the {URI} event,
* this function emits no events.
*/
function _setURI(string memory newuri) internal virtual {
_uri = newuri;
}
/**
* @dev Creates a `value` amount of tokens of type `id`, and assigns them to `to`.
*
* Emits a {TransferSingle} event.
*
* Requirements:
*
* - `to` cannot be the zero address.
* - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155Received} and return the
* acceptance magic value.
*/
function _mint(address to, uint256 id, uint256 value, bytes memory data) internal {
if (to == address(0)) {
revert ERC1155InvalidReceiver(address(0));
}
(uint256[] memory ids, uint256[] memory values) = _asSingletonArrays(id, value);
_updateWithAcceptanceCheck(address(0), to, ids, values, data);
}
/**
* @dev xref:ROOT:erc1155.adoc#batch-operations[Batched] version of {_mint}.
*
* Emits a {TransferBatch} event.
*
* Requirements:
*
* - `ids` and `values` must have the same length.
* - `to` cannot be the zero address.
* - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155BatchReceived} and return the
* acceptance magic value.
*/
function _mintBatch(address to, uint256[] memory ids, uint256[] memory values, bytes memory data) internal {
if (to == address(0)) {
revert ERC1155InvalidReceiver(address(0));
}
_updateWithAcceptanceCheck(address(0), to, ids, values, data);
}
/**
* @dev Destroys a `value` amount of tokens of type `id` from `from`
*
* Emits a {TransferSingle} event.
*
* Requirements:
*
* - `from` cannot be the zero address.
* - `from` must have at least `value` amount of tokens of type `id`.
*/
function _burn(address from, uint256 id, uint256 value) internal {
if (from == address(0)) {
revert ERC1155InvalidSender(address(0));
}
(uint256[] memory ids, uint256[] memory values) = _asSingletonArrays(id, value);
_updateWithAcceptanceCheck(from, address(0), ids, values, "");
}
/**
* @dev xref:ROOT:erc1155.adoc#batch-operations[Batched] version of {_burn}.
*
* Emits a {TransferBatch} event.
*
* Requirements:
*
* - `from` cannot be the zero address.
* - `from` must have at least `value` amount of tokens of type `id`.
* - `ids` and `values` must have the same length.
*/
function _burnBatch(address from, uint256[] memory ids, uint256[] memory values) internal {
if (from == address(0)) {
revert ERC1155InvalidSender(address(0));
}
_updateWithAcceptanceCheck(from, address(0), ids, values, "");
}
/**
* @dev Approve `operator` to operate on all of `owner` tokens
*
* Emits an {ApprovalForAll} event.
*
* Requirements:
*
* - `operator` cannot be the zero address.
*/
function _setApprovalForAll(address owner, address operator, bool approved) internal virtual {
if (operator == address(0)) {
revert ERC1155InvalidOperator(address(0));
}
_operatorApprovals[owner][operator] = approved;
emit ApprovalForAll(owner, operator, approved);
}
/**
* @dev Creates an array in memory with only one value for each of the elements provided.
*/
function _asSingletonArrays(
uint256 element1,
uint256 element2
) private pure returns (uint256[] memory array1, uint256[] memory array2) {
assembly ("memory-safe") {
// Load the free memory pointer
array1 := mload(0x40)
// Set array length to 1
mstore(array1, 1)
// Store the single element at the next word after the length (where content starts)
mstore(add(array1, 0x20), element1)
// Repeat for next array locating it right after the first array
array2 := add(array1, 0x40)
mstore(array2, 1)
mstore(add(array2, 0x20), element2)
// Update the free memory pointer by pointing after the second array
mstore(0x40, add(array2, 0x40))
}
}
}// 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.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.0.0) (interfaces/IERC1155.sol)
pragma solidity ^0.8.20;
import {IERC1155} from "../token/ERC1155/IERC1155.sol";// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (interfaces/IERC721.sol)
pragma solidity ^0.8.20;
import {IERC721} from "../token/ERC721/IERC721.sol";// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.1.0) (token/ERC1155/utils/ERC1155Holder.sol)
pragma solidity ^0.8.20;
import {IERC165, ERC165} from "../../../utils/introspection/ERC165.sol";
import {IERC1155Receiver} from "../IERC1155Receiver.sol";
/**
* @dev Simple implementation of `IERC1155Receiver` that will allow a contract to hold ERC-1155 tokens.
*
* IMPORTANT: When inheriting this contract, you must include a way to use the received tokens, otherwise they will be
* stuck.
*/
abstract contract ERC1155Holder is ERC165, IERC1155Receiver {
/**
* @dev See {IERC165-supportsInterface}.
*/
function supportsInterface(bytes4 interfaceId) public view virtual override(ERC165, IERC165) returns (bool) {
return interfaceId == type(IERC1155Receiver).interfaceId || super.supportsInterface(interfaceId);
}
function onERC1155Received(
address,
address,
uint256,
uint256,
bytes memory
) public virtual override returns (bytes4) {
return this.onERC1155Received.selector;
}
function onERC1155BatchReceived(
address,
address,
uint256[] memory,
uint256[] memory,
bytes memory
) public virtual override returns (bytes4) {
return this.onERC1155BatchReceived.selector;
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (token/ERC721/utils/ERC721Holder.sol)
pragma solidity ^0.8.20;
import {IERC721Receiver} from "../IERC721Receiver.sol";
/**
* @dev Implementation of the {IERC721Receiver} interface.
*
* Accepts all token transfers.
* Make sure the contract is able to use its token with {IERC721-safeTransferFrom}, {IERC721-approve} or
* {IERC721-setApprovalForAll}.
*/
abstract contract ERC721Holder is IERC721Receiver {
/**
* @dev See {IERC721Receiver-onERC721Received}.
*
* Always returns `IERC721Receiver.onERC721Received.selector`.
*/
function onERC721Received(address, address, uint256, bytes memory) public virtual returns (bytes4) {
return this.onERC721Received.selector;
}
}// 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) (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/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.1.0) (token/ERC1155/IERC1155.sol)
pragma solidity ^0.8.20;
import {IERC165} from "../../utils/introspection/IERC165.sol";
/**
* @dev Required interface of an ERC-1155 compliant contract, as defined in the
* https://eips.ethereum.org/EIPS/eip-1155[ERC].
*/
interface IERC1155 is IERC165 {
/**
* @dev Emitted when `value` amount of tokens of type `id` are transferred from `from` to `to` by `operator`.
*/
event TransferSingle(address indexed operator, address indexed from, address indexed to, uint256 id, uint256 value);
/**
* @dev Equivalent to multiple {TransferSingle} events, where `operator`, `from` and `to` are the same for all
* transfers.
*/
event TransferBatch(
address indexed operator,
address indexed from,
address indexed to,
uint256[] ids,
uint256[] values
);
/**
* @dev Emitted when `account` grants or revokes permission to `operator` to transfer their tokens, according to
* `approved`.
*/
event ApprovalForAll(address indexed account, address indexed operator, bool approved);
/**
* @dev Emitted when the URI for token type `id` changes to `value`, if it is a non-programmatic URI.
*
* If an {URI} event was emitted for `id`, the standard
* https://eips.ethereum.org/EIPS/eip-1155#metadata-extensions[guarantees] that `value` will equal the value
* returned by {IERC1155MetadataURI-uri}.
*/
event URI(string value, uint256 indexed id);
/**
* @dev Returns the value of tokens of token type `id` owned by `account`.
*/
function balanceOf(address account, uint256 id) external view returns (uint256);
/**
* @dev xref:ROOT:erc1155.adoc#batch-operations[Batched] version of {balanceOf}.
*
* Requirements:
*
* - `accounts` and `ids` must have the same length.
*/
function balanceOfBatch(
address[] calldata accounts,
uint256[] calldata ids
) external view returns (uint256[] memory);
/**
* @dev Grants or revokes permission to `operator` to transfer the caller's tokens, according to `approved`,
*
* Emits an {ApprovalForAll} event.
*
* Requirements:
*
* - `operator` cannot be the zero address.
*/
function setApprovalForAll(address operator, bool approved) external;
/**
* @dev Returns true if `operator` is approved to transfer ``account``'s tokens.
*
* See {setApprovalForAll}.
*/
function isApprovedForAll(address account, address operator) external view returns (bool);
/**
* @dev Transfers a `value` amount of tokens of type `id` from `from` to `to`.
*
* WARNING: This function can potentially allow a reentrancy attack when transferring tokens
* to an untrusted contract, when invoking {onERC1155Received} on the receiver.
* Ensure to follow the checks-effects-interactions pattern and consider employing
* reentrancy guards when interacting with untrusted contracts.
*
* Emits a {TransferSingle} event.
*
* Requirements:
*
* - `to` cannot be the zero address.
* - If the caller is not `from`, it must have been approved to spend ``from``'s tokens via {setApprovalForAll}.
* - `from` must have a balance of tokens of type `id` of at least `value` amount.
* - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155Received} and return the
* acceptance magic value.
*/
function safeTransferFrom(address from, address to, uint256 id, uint256 value, bytes calldata data) external;
/**
* @dev xref:ROOT:erc1155.adoc#batch-operations[Batched] version of {safeTransferFrom}.
*
* WARNING: This function can potentially allow a reentrancy attack when transferring tokens
* to an untrusted contract, when invoking {onERC1155BatchReceived} on the receiver.
* Ensure to follow the checks-effects-interactions pattern and consider employing
* reentrancy guards when interacting with untrusted contracts.
*
* Emits either a {TransferSingle} or a {TransferBatch} event, depending on the length of the array arguments.
*
* Requirements:
*
* - `ids` and `values` must have the same length.
* - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155BatchReceived} and return the
* acceptance magic value.
*/
function safeBatchTransferFrom(
address from,
address to,
uint256[] calldata ids,
uint256[] calldata values,
bytes calldata data
) external;
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.1.0) (token/ERC1155/extensions/IERC1155MetadataURI.sol)
pragma solidity ^0.8.20;
import {IERC1155} from "../IERC1155.sol";
/**
* @dev Interface of the optional ERC1155MetadataExtension interface, as defined
* in the https://eips.ethereum.org/EIPS/eip-1155#metadata-extensions[ERC].
*/
interface IERC1155MetadataURI is IERC1155 {
/**
* @dev Returns the URI for token type `id`.
*
* If the `\{id\}` substring is present in the URI, it must be replaced by
* clients with the actual token type ID.
*/
function uri(uint256 id) external view returns (string memory);
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.1.0) (token/ERC1155/utils/ERC1155Utils.sol)
pragma solidity ^0.8.20;
import {IERC1155Receiver} from "../IERC1155Receiver.sol";
import {IERC1155Errors} from "../../../interfaces/draft-IERC6093.sol";
/**
* @dev Library that provide common ERC-1155 utility functions.
*
* See https://eips.ethereum.org/EIPS/eip-1155[ERC-1155].
*
* _Available since v5.1._
*/
library ERC1155Utils {
/**
* @dev Performs an acceptance check for the provided `operator` by calling {IERC1155-onERC1155Received}
* on the `to` address. The `operator` is generally the address that initiated the token transfer (i.e. `msg.sender`).
*
* The acceptance call is not executed and treated as a no-op if the target address doesn't contain code (i.e. an EOA).
* Otherwise, the recipient must implement {IERC1155Receiver-onERC1155Received} and return the acceptance magic value to accept
* the transfer.
*/
function checkOnERC1155Received(
address operator,
address from,
address to,
uint256 id,
uint256 value,
bytes memory data
) internal {
if (to.code.length > 0) {
try IERC1155Receiver(to).onERC1155Received(operator, from, id, value, data) returns (bytes4 response) {
if (response != IERC1155Receiver.onERC1155Received.selector) {
// Tokens rejected
revert IERC1155Errors.ERC1155InvalidReceiver(to);
}
} catch (bytes memory reason) {
if (reason.length == 0) {
// non-IERC1155Receiver implementer
revert IERC1155Errors.ERC1155InvalidReceiver(to);
} else {
assembly ("memory-safe") {
revert(add(32, reason), mload(reason))
}
}
}
}
}
/**
* @dev Performs a batch acceptance check for the provided `operator` by calling {IERC1155-onERC1155BatchReceived}
* on the `to` address. The `operator` is generally the address that initiated the token transfer (i.e. `msg.sender`).
*
* The acceptance call is not executed and treated as a no-op if the target address doesn't contain code (i.e. an EOA).
* Otherwise, the recipient must implement {IERC1155Receiver-onERC1155Received} and return the acceptance magic value to accept
* the transfer.
*/
function checkOnERC1155BatchReceived(
address operator,
address from,
address to,
uint256[] memory ids,
uint256[] memory values,
bytes memory data
) internal {
if (to.code.length > 0) {
try IERC1155Receiver(to).onERC1155BatchReceived(operator, from, ids, values, data) returns (
bytes4 response
) {
if (response != IERC1155Receiver.onERC1155BatchReceived.selector) {
// Tokens rejected
revert IERC1155Errors.ERC1155InvalidReceiver(to);
}
} catch (bytes memory reason) {
if (reason.length == 0) {
// non-IERC1155Receiver implementer
revert IERC1155Errors.ERC1155InvalidReceiver(to);
} else {
assembly ("memory-safe") {
revert(add(32, reason), mload(reason))
}
}
}
}
}
}// 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/introspection/ERC165.sol)
pragma solidity ^0.8.20;
import {IERC165} from "./IERC165.sol";
/**
* @dev Implementation of the {IERC165} interface.
*
* Contracts that want to implement ERC-165 should inherit from this contract and override {supportsInterface} to check
* for the additional interface id that will be supported. For example:
*
* ```solidity
* function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
* return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId);
* }
* ```
*/
abstract contract ERC165 is IERC165 {
/**
* @dev See {IERC165-supportsInterface}.
*/
function supportsInterface(bytes4 interfaceId) public view virtual returns (bool) {
return interfaceId == type(IERC165).interfaceId;
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.1.0) (utils/Arrays.sol)
// This file was procedurally generated from scripts/generate/templates/Arrays.js.
pragma solidity ^0.8.20;
import {Comparators} from "./Comparators.sol";
import {SlotDerivation} from "./SlotDerivation.sol";
import {StorageSlot} from "./StorageSlot.sol";
import {Math} from "./math/Math.sol";
/**
* @dev Collection of functions related to array types.
*/
library Arrays {
using SlotDerivation for bytes32;
using StorageSlot for bytes32;
/**
* @dev Sort an array of uint256 (in memory) following the provided comparator function.
*
* This function does the sorting "in place", meaning that it overrides the input. The object is returned for
* convenience, but that returned value can be discarded safely if the caller has a memory pointer to the array.
*
* NOTE: this function's cost is `O(n · log(n))` in average and `O(n²)` in the worst case, with n the length of the
* array. Using it in view functions that are executed through `eth_call` is safe, but one should be very careful
* when executing this as part of a transaction. If the array being sorted is too large, the sort operation may
* consume more gas than is available in a block, leading to potential DoS.
*
* IMPORTANT: Consider memory side-effects when using custom comparator functions that access memory in an unsafe way.
*/
function sort(
uint256[] memory array,
function(uint256, uint256) pure returns (bool) comp
) internal pure returns (uint256[] memory) {
_quickSort(_begin(array), _end(array), comp);
return array;
}
/**
* @dev Variant of {sort} that sorts an array of uint256 in increasing order.
*/
function sort(uint256[] memory array) internal pure returns (uint256[] memory) {
sort(array, Comparators.lt);
return array;
}
/**
* @dev Sort an array of address (in memory) following the provided comparator function.
*
* This function does the sorting "in place", meaning that it overrides the input. The object is returned for
* convenience, but that returned value can be discarded safely if the caller has a memory pointer to the array.
*
* NOTE: this function's cost is `O(n · log(n))` in average and `O(n²)` in the worst case, with n the length of the
* array. Using it in view functions that are executed through `eth_call` is safe, but one should be very careful
* when executing this as part of a transaction. If the array being sorted is too large, the sort operation may
* consume more gas than is available in a block, leading to potential DoS.
*
* IMPORTANT: Consider memory side-effects when using custom comparator functions that access memory in an unsafe way.
*/
function sort(
address[] memory array,
function(address, address) pure returns (bool) comp
) internal pure returns (address[] memory) {
sort(_castToUint256Array(array), _castToUint256Comp(comp));
return array;
}
/**
* @dev Variant of {sort} that sorts an array of address in increasing order.
*/
function sort(address[] memory array) internal pure returns (address[] memory) {
sort(_castToUint256Array(array), Comparators.lt);
return array;
}
/**
* @dev Sort an array of bytes32 (in memory) following the provided comparator function.
*
* This function does the sorting "in place", meaning that it overrides the input. The object is returned for
* convenience, but that returned value can be discarded safely if the caller has a memory pointer to the array.
*
* NOTE: this function's cost is `O(n · log(n))` in average and `O(n²)` in the worst case, with n the length of the
* array. Using it in view functions that are executed through `eth_call` is safe, but one should be very careful
* when executing this as part of a transaction. If the array being sorted is too large, the sort operation may
* consume more gas than is available in a block, leading to potential DoS.
*
* IMPORTANT: Consider memory side-effects when using custom comparator functions that access memory in an unsafe way.
*/
function sort(
bytes32[] memory array,
function(bytes32, bytes32) pure returns (bool) comp
) internal pure returns (bytes32[] memory) {
sort(_castToUint256Array(array), _castToUint256Comp(comp));
return array;
}
/**
* @dev Variant of {sort} that sorts an array of bytes32 in increasing order.
*/
function sort(bytes32[] memory array) internal pure returns (bytes32[] memory) {
sort(_castToUint256Array(array), Comparators.lt);
return array;
}
/**
* @dev Performs a quick sort of a segment of memory. The segment sorted starts at `begin` (inclusive), and stops
* at end (exclusive). Sorting follows the `comp` comparator.
*
* Invariant: `begin <= end`. This is the case when initially called by {sort} and is preserved in subcalls.
*
* IMPORTANT: Memory locations between `begin` and `end` are not validated/zeroed. This function should
* be used only if the limits are within a memory array.
*/
function _quickSort(uint256 begin, uint256 end, function(uint256, uint256) pure returns (bool) comp) private pure {
unchecked {
if (end - begin < 0x40) return;
// Use first element as pivot
uint256 pivot = _mload(begin);
// Position where the pivot should be at the end of the loop
uint256 pos = begin;
for (uint256 it = begin + 0x20; it < end; it += 0x20) {
if (comp(_mload(it), pivot)) {
// If the value stored at the iterator's position comes before the pivot, we increment the
// position of the pivot and move the value there.
pos += 0x20;
_swap(pos, it);
}
}
_swap(begin, pos); // Swap pivot into place
_quickSort(begin, pos, comp); // Sort the left side of the pivot
_quickSort(pos + 0x20, end, comp); // Sort the right side of the pivot
}
}
/**
* @dev Pointer to the memory location of the first element of `array`.
*/
function _begin(uint256[] memory array) private pure returns (uint256 ptr) {
assembly ("memory-safe") {
ptr := add(array, 0x20)
}
}
/**
* @dev Pointer to the memory location of the first memory word (32bytes) after `array`. This is the memory word
* that comes just after the last element of the array.
*/
function _end(uint256[] memory array) private pure returns (uint256 ptr) {
unchecked {
return _begin(array) + array.length * 0x20;
}
}
/**
* @dev Load memory word (as a uint256) at location `ptr`.
*/
function _mload(uint256 ptr) private pure returns (uint256 value) {
assembly {
value := mload(ptr)
}
}
/**
* @dev Swaps the elements memory location `ptr1` and `ptr2`.
*/
function _swap(uint256 ptr1, uint256 ptr2) private pure {
assembly {
let value1 := mload(ptr1)
let value2 := mload(ptr2)
mstore(ptr1, value2)
mstore(ptr2, value1)
}
}
/// @dev Helper: low level cast address memory array to uint256 memory array
function _castToUint256Array(address[] memory input) private pure returns (uint256[] memory output) {
assembly {
output := input
}
}
/// @dev Helper: low level cast bytes32 memory array to uint256 memory array
function _castToUint256Array(bytes32[] memory input) private pure returns (uint256[] memory output) {
assembly {
output := input
}
}
/// @dev Helper: low level cast address comp function to uint256 comp function
function _castToUint256Comp(
function(address, address) pure returns (bool) input
) private pure returns (function(uint256, uint256) pure returns (bool) output) {
assembly {
output := input
}
}
/// @dev Helper: low level cast bytes32 comp function to uint256 comp function
function _castToUint256Comp(
function(bytes32, bytes32) pure returns (bool) input
) private pure returns (function(uint256, uint256) pure returns (bool) output) {
assembly {
output := input
}
}
/**
* @dev Searches a sorted `array` and returns the first index that contains
* a value greater or equal to `element`. If no such index exists (i.e. all
* values in the array are strictly less than `element`), the array length is
* returned. Time complexity O(log n).
*
* NOTE: The `array` is expected to be sorted in ascending order, and to
* contain no repeated elements.
*
* IMPORTANT: Deprecated. This implementation behaves as {lowerBound} but lacks
* support for repeated elements in the array. The {lowerBound} function should
* be used instead.
*/
function findUpperBound(uint256[] storage array, uint256 element) internal view returns (uint256) {
uint256 low = 0;
uint256 high = array.length;
if (high == 0) {
return 0;
}
while (low < high) {
uint256 mid = Math.average(low, high);
// Note that mid will always be strictly less than high (i.e. it will be a valid array index)
// because Math.average rounds towards zero (it does integer division with truncation).
if (unsafeAccess(array, mid).value > element) {
high = mid;
} else {
low = mid + 1;
}
}
// At this point `low` is the exclusive upper bound. We will return the inclusive upper bound.
if (low > 0 && unsafeAccess(array, low - 1).value == element) {
return low - 1;
} else {
return low;
}
}
/**
* @dev Searches an `array` sorted in ascending order and returns the first
* index that contains a value greater or equal than `element`. If no such index
* exists (i.e. all values in the array are strictly less than `element`), the array
* length is returned. Time complexity O(log n).
*
* See C++'s https://en.cppreference.com/w/cpp/algorithm/lower_bound[lower_bound].
*/
function lowerBound(uint256[] storage array, uint256 element) internal view returns (uint256) {
uint256 low = 0;
uint256 high = array.length;
if (high == 0) {
return 0;
}
while (low < high) {
uint256 mid = Math.average(low, high);
// Note that mid will always be strictly less than high (i.e. it will be a valid array index)
// because Math.average rounds towards zero (it does integer division with truncation).
if (unsafeAccess(array, mid).value < element) {
// this cannot overflow because mid < high
unchecked {
low = mid + 1;
}
} else {
high = mid;
}
}
return low;
}
/**
* @dev Searches an `array` sorted in ascending order and returns the first
* index that contains a value strictly greater than `element`. If no such index
* exists (i.e. all values in the array are strictly less than `element`), the array
* length is returned. Time complexity O(log n).
*
* See C++'s https://en.cppreference.com/w/cpp/algorithm/upper_bound[upper_bound].
*/
function upperBound(uint256[] storage array, uint256 element) internal view returns (uint256) {
uint256 low = 0;
uint256 high = array.length;
if (high == 0) {
return 0;
}
while (low < high) {
uint256 mid = Math.average(low, high);
// Note that mid will always be strictly less than high (i.e. it will be a valid array index)
// because Math.average rounds towards zero (it does integer division with truncation).
if (unsafeAccess(array, mid).value > element) {
high = mid;
} else {
// this cannot overflow because mid < high
unchecked {
low = mid + 1;
}
}
}
return low;
}
/**
* @dev Same as {lowerBound}, but with an array in memory.
*/
function lowerBoundMemory(uint256[] memory array, uint256 element) internal pure returns (uint256) {
uint256 low = 0;
uint256 high = array.length;
if (high == 0) {
return 0;
}
while (low < high) {
uint256 mid = Math.average(low, high);
// Note that mid will always be strictly less than high (i.e. it will be a valid array index)
// because Math.average rounds towards zero (it does integer division with truncation).
if (unsafeMemoryAccess(array, mid) < element) {
// this cannot overflow because mid < high
unchecked {
low = mid + 1;
}
} else {
high = mid;
}
}
return low;
}
/**
* @dev Same as {upperBound}, but with an array in memory.
*/
function upperBoundMemory(uint256[] memory array, uint256 element) internal pure returns (uint256) {
uint256 low = 0;
uint256 high = array.length;
if (high == 0) {
return 0;
}
while (low < high) {
uint256 mid = Math.average(low, high);
// Note that mid will always be strictly less than high (i.e. it will be a valid array index)
// because Math.average rounds towards zero (it does integer division with truncation).
if (unsafeMemoryAccess(array, mid) > element) {
high = mid;
} else {
// this cannot overflow because mid < high
unchecked {
low = mid + 1;
}
}
}
return low;
}
/**
* @dev Access an array in an "unsafe" way. Skips solidity "index-out-of-range" check.
*
* WARNING: Only use if you are certain `pos` is lower than the array length.
*/
function unsafeAccess(address[] storage arr, uint256 pos) internal pure returns (StorageSlot.AddressSlot storage) {
bytes32 slot;
assembly ("memory-safe") {
slot := arr.slot
}
return slot.deriveArray().offset(pos).getAddressSlot();
}
/**
* @dev Access an array in an "unsafe" way. Skips solidity "index-out-of-range" check.
*
* WARNING: Only use if you are certain `pos` is lower than the array length.
*/
function unsafeAccess(bytes32[] storage arr, uint256 pos) internal pure returns (StorageSlot.Bytes32Slot storage) {
bytes32 slot;
assembly ("memory-safe") {
slot := arr.slot
}
return slot.deriveArray().offset(pos).getBytes32Slot();
}
/**
* @dev Access an array in an "unsafe" way. Skips solidity "index-out-of-range" check.
*
* WARNING: Only use if you are certain `pos` is lower than the array length.
*/
function unsafeAccess(uint256[] storage arr, uint256 pos) internal pure returns (StorageSlot.Uint256Slot storage) {
bytes32 slot;
assembly ("memory-safe") {
slot := arr.slot
}
return slot.deriveArray().offset(pos).getUint256Slot();
}
/**
* @dev Access an array in an "unsafe" way. Skips solidity "index-out-of-range" check.
*
* WARNING: Only use if you are certain `pos` is lower than the array length.
*/
function unsafeMemoryAccess(address[] memory arr, uint256 pos) internal pure returns (address res) {
assembly {
res := mload(add(add(arr, 0x20), mul(pos, 0x20)))
}
}
/**
* @dev Access an array in an "unsafe" way. Skips solidity "index-out-of-range" check.
*
* WARNING: Only use if you are certain `pos` is lower than the array length.
*/
function unsafeMemoryAccess(bytes32[] memory arr, uint256 pos) internal pure returns (bytes32 res) {
assembly {
res := mload(add(add(arr, 0x20), mul(pos, 0x20)))
}
}
/**
* @dev Access an array in an "unsafe" way. Skips solidity "index-out-of-range" check.
*
* WARNING: Only use if you are certain `pos` is lower than the array length.
*/
function unsafeMemoryAccess(uint256[] memory arr, uint256 pos) internal pure returns (uint256 res) {
assembly {
res := mload(add(add(arr, 0x20), mul(pos, 0x20)))
}
}
/**
* @dev Helper to set the length of an dynamic array. Directly writing to `.length` is forbidden.
*
* WARNING: this does not clear elements if length is reduced, of initialize elements if length is increased.
*/
function unsafeSetLength(address[] storage array, uint256 len) internal {
assembly ("memory-safe") {
sstore(array.slot, len)
}
}
/**
* @dev Helper to set the length of an dynamic array. Directly writing to `.length` is forbidden.
*
* WARNING: this does not clear elements if length is reduced, of initialize elements if length is increased.
*/
function unsafeSetLength(bytes32[] storage array, uint256 len) internal {
assembly ("memory-safe") {
sstore(array.slot, len)
}
}
/**
* @dev Helper to set the length of an dynamic array. Directly writing to `.length` is forbidden.
*
* WARNING: this does not clear elements if length is reduced, of initialize elements if length is increased.
*/
function unsafeSetLength(uint256[] storage array, uint256 len) internal {
assembly ("memory-safe") {
sstore(array.slot, len)
}
}
}// 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.1.0) (interfaces/IERC1363.sol)
pragma solidity ^0.8.20;
import {IERC20} from "./IERC20.sol";
import {IERC165} from "./IERC165.sol";
/**
* @title IERC1363
* @dev Interface of the ERC-1363 standard as defined in the https://eips.ethereum.org/EIPS/eip-1363[ERC-1363].
*
* Defines an extension interface for ERC-20 tokens that supports executing code on a recipient contract
* after `transfer` or `transferFrom`, or code on a spender contract after `approve`, in a single transaction.
*/
interface IERC1363 is IERC20, IERC165 {
/*
* Note: the ERC-165 identifier for this interface is 0xb0202a11.
* 0xb0202a11 ===
* bytes4(keccak256('transferAndCall(address,uint256)')) ^
* bytes4(keccak256('transferAndCall(address,uint256,bytes)')) ^
* bytes4(keccak256('transferFromAndCall(address,address,uint256)')) ^
* bytes4(keccak256('transferFromAndCall(address,address,uint256,bytes)')) ^
* bytes4(keccak256('approveAndCall(address,uint256)')) ^
* bytes4(keccak256('approveAndCall(address,uint256,bytes)'))
*/
/**
* @dev Moves a `value` amount of tokens from the caller's account to `to`
* and then calls {IERC1363Receiver-onTransferReceived} on `to`.
* @param to The address which you want to transfer to.
* @param value The amount of tokens to be transferred.
* @return A boolean value indicating whether the operation succeeded unless throwing.
*/
function transferAndCall(address to, uint256 value) external returns (bool);
/**
* @dev Moves a `value` amount of tokens from the caller's account to `to`
* and then calls {IERC1363Receiver-onTransferReceived} on `to`.
* @param to The address which you want to transfer to.
* @param value The amount of tokens to be transferred.
* @param data Additional data with no specified format, sent in call to `to`.
* @return A boolean value indicating whether the operation succeeded unless throwing.
*/
function transferAndCall(address to, uint256 value, bytes calldata data) external returns (bool);
/**
* @dev Moves a `value` amount of tokens from `from` to `to` using the allowance mechanism
* and then calls {IERC1363Receiver-onTransferReceived} on `to`.
* @param from The address which you want to send tokens from.
* @param to The address which you want to transfer to.
* @param value The amount of tokens to be transferred.
* @return A boolean value indicating whether the operation succeeded unless throwing.
*/
function transferFromAndCall(address from, address to, uint256 value) external returns (bool);
/**
* @dev Moves a `value` amount of tokens from `from` to `to` using the allowance mechanism
* and then calls {IERC1363Receiver-onTransferReceived} on `to`.
* @param from The address which you want to send tokens from.
* @param to The address which you want to transfer to.
* @param value The amount of tokens to be transferred.
* @param data Additional data with no specified format, sent in call to `to`.
* @return A boolean value indicating whether the operation succeeded unless throwing.
*/
function transferFromAndCall(address from, address to, uint256 value, bytes calldata data) external returns (bool);
/**
* @dev Sets a `value` amount of tokens as the allowance of `spender` over the
* caller's tokens and then calls {IERC1363Spender-onApprovalReceived} on `spender`.
* @param spender The address which will spend the funds.
* @param value The amount of tokens to be spent.
* @return A boolean value indicating whether the operation succeeded unless throwing.
*/
function approveAndCall(address spender, uint256 value) external returns (bool);
/**
* @dev Sets a `value` amount of tokens as the allowance of `spender` over the
* caller's tokens and then calls {IERC1363Spender-onApprovalReceived} on `spender`.
* @param spender The address which will spend the funds.
* @param value The amount of tokens to be spent.
* @param data Additional data with no specified format, sent in call to `spender`.
* @return A boolean value indicating whether the operation succeeded unless throwing.
*/
function approveAndCall(address spender, uint256 value, bytes calldata data) external returns (bool);
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.1.0) (utils/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) (token/ERC721/IERC721.sol)
pragma solidity ^0.8.20;
import {IERC165} from "../../utils/introspection/IERC165.sol";
/**
* @dev Required interface of an ERC-721 compliant contract.
*/
interface IERC721 is IERC165 {
/**
* @dev Emitted when `tokenId` token is transferred from `from` to `to`.
*/
event Transfer(address indexed from, address indexed to, uint256 indexed tokenId);
/**
* @dev Emitted when `owner` enables `approved` to manage the `tokenId` token.
*/
event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId);
/**
* @dev Emitted when `owner` enables or disables (`approved`) `operator` to manage all of its assets.
*/
event ApprovalForAll(address indexed owner, address indexed operator, bool approved);
/**
* @dev Returns the number of tokens in ``owner``'s account.
*/
function balanceOf(address owner) external view returns (uint256 balance);
/**
* @dev Returns the owner of the `tokenId` token.
*
* Requirements:
*
* - `tokenId` must exist.
*/
function ownerOf(uint256 tokenId) external view returns (address owner);
/**
* @dev Safely transfers `tokenId` token from `from` to `to`.
*
* Requirements:
*
* - `from` cannot be the zero address.
* - `to` cannot be the zero address.
* - `tokenId` token must exist and be owned by `from`.
* - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.
* - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon
* a safe transfer.
*
* Emits a {Transfer} event.
*/
function safeTransferFrom(address from, address to, uint256 tokenId, bytes calldata data) external;
/**
* @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients
* are aware of the ERC-721 protocol to prevent tokens from being forever locked.
*
* Requirements:
*
* - `from` cannot be the zero address.
* - `to` cannot be the zero address.
* - `tokenId` token must exist and be owned by `from`.
* - If the caller is not `from`, it must have been allowed to move this token by either {approve} or
* {setApprovalForAll}.
* - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon
* a safe transfer.
*
* Emits a {Transfer} event.
*/
function safeTransferFrom(address from, address to, uint256 tokenId) external;
/**
* @dev Transfers `tokenId` token from `from` to `to`.
*
* WARNING: Note that the caller is responsible to confirm that the recipient is capable of receiving ERC-721
* or else they may be permanently lost. Usage of {safeTransferFrom} prevents loss, though the caller must
* understand this adds an external call which potentially creates a reentrancy vulnerability.
*
* Requirements:
*
* - `from` cannot be the zero address.
* - `to` cannot be the zero address.
* - `tokenId` token must be owned by `from`.
* - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.
*
* Emits a {Transfer} event.
*/
function transferFrom(address from, address to, uint256 tokenId) external;
/**
* @dev Gives permission to `to` to transfer `tokenId` token to another account.
* The approval is cleared when the token is transferred.
*
* Only a single account can be approved at a time, so approving the zero address clears previous approvals.
*
* Requirements:
*
* - The caller must own the token or be an approved operator.
* - `tokenId` must exist.
*
* Emits an {Approval} event.
*/
function approve(address to, uint256 tokenId) external;
/**
* @dev Approve or remove `operator` as an operator for the caller.
* Operators can call {transferFrom} or {safeTransferFrom} for any token owned by the caller.
*
* Requirements:
*
* - The `operator` cannot be the address zero.
*
* Emits an {ApprovalForAll} event.
*/
function setApprovalForAll(address operator, bool approved) external;
/**
* @dev Returns the account approved for `tokenId` token.
*
* Requirements:
*
* - `tokenId` must exist.
*/
function getApproved(uint256 tokenId) external view returns (address operator);
/**
* @dev Returns if the `operator` is allowed to manage all of the assets of `owner`.
*
* See {setApprovalForAll}
*/
function isApprovedForAll(address owner, address operator) external view returns (bool);
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.1.0) (token/ERC1155/IERC1155Receiver.sol)
pragma solidity ^0.8.20;
import {IERC165} from "../../utils/introspection/IERC165.sol";
/**
* @dev Interface that must be implemented by smart contracts in order to receive
* ERC-1155 token transfers.
*/
interface IERC1155Receiver is IERC165 {
/**
* @dev Handles the receipt of a single ERC-1155 token type. This function is
* called at the end of a `safeTransferFrom` after the balance has been updated.
*
* NOTE: To accept the transfer, this must return
* `bytes4(keccak256("onERC1155Received(address,address,uint256,uint256,bytes)"))`
* (i.e. 0xf23a6e61, or its own function selector).
*
* @param operator The address which initiated the transfer (i.e. msg.sender)
* @param from The address which previously owned the token
* @param id The ID of the token being transferred
* @param value The amount of tokens being transferred
* @param data Additional data with no specified format
* @return `bytes4(keccak256("onERC1155Received(address,address,uint256,uint256,bytes)"))` if transfer is allowed
*/
function onERC1155Received(
address operator,
address from,
uint256 id,
uint256 value,
bytes calldata data
) external returns (bytes4);
/**
* @dev Handles the receipt of a multiple ERC-1155 token types. This function
* is called at the end of a `safeBatchTransferFrom` after the balances have
* been updated.
*
* NOTE: To accept the transfer(s), this must return
* `bytes4(keccak256("onERC1155BatchReceived(address,address,uint256[],uint256[],bytes)"))`
* (i.e. 0xbc197c81, or its own function selector).
*
* @param operator The address which initiated the batch transfer (i.e. msg.sender)
* @param from The address which previously owned the token
* @param ids An array containing ids of each token being transferred (order and length must match values array)
* @param values An array containing amounts of each token being transferred (order and length must match ids array)
* @param data Additional data with no specified format
* @return `bytes4(keccak256("onERC1155BatchReceived(address,address,uint256[],uint256[],bytes)"))` if transfer is allowed
*/
function onERC1155BatchReceived(
address operator,
address from,
uint256[] calldata ids,
uint256[] calldata values,
bytes calldata data
) external returns (bytes4);
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.1.0) (token/ERC721/IERC721Receiver.sol)
pragma solidity ^0.8.20;
/**
* @title ERC-721 token receiver interface
* @dev Interface for any contract that wants to support safeTransfers
* from ERC-721 asset contracts.
*/
interface IERC721Receiver {
/**
* @dev Whenever an {IERC721} `tokenId` token is transferred to this contract via {IERC721-safeTransferFrom}
* by `operator` from `from`, this function is called.
*
* It must return its Solidity selector to confirm the token transfer.
* If any other value is returned or the interface is not implemented by the recipient, the transfer will be
* reverted.
*
* The selector can be obtained in Solidity with `IERC721Receiver.onERC721Received.selector`.
*/
function onERC721Received(
address operator,
address from,
uint256 tokenId,
bytes calldata data
) external returns (bytes4);
}// 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/Comparators.sol)
pragma solidity ^0.8.20;
/**
* @dev Provides a set of functions to compare values.
*
* _Available since v5.1._
*/
library Comparators {
function lt(uint256 a, uint256 b) internal pure returns (bool) {
return a < b;
}
function gt(uint256 a, uint256 b) internal pure returns (bool) {
return a > b;
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.1.0) (utils/SlotDerivation.sol)
// This file was procedurally generated from scripts/generate/templates/SlotDerivation.js.
pragma solidity ^0.8.20;
/**
* @dev Library for computing storage (and transient storage) locations from namespaces and deriving slots
* corresponding to standard patterns. The derivation method for array and mapping matches the storage layout used by
* the solidity language / compiler.
*
* See https://docs.soliditylang.org/en/v0.8.20/internals/layout_in_storage.html#mappings-and-dynamic-arrays[Solidity docs for mappings and dynamic arrays.].
*
* Example usage:
* ```solidity
* contract Example {
* // Add the library methods
* using StorageSlot for bytes32;
* using SlotDerivation for bytes32;
*
* // Declare a namespace
* string private constant _NAMESPACE = "<namespace>" // eg. OpenZeppelin.Slot
*
* function setValueInNamespace(uint256 key, address newValue) internal {
* _NAMESPACE.erc7201Slot().deriveMapping(key).getAddressSlot().value = newValue;
* }
*
* function getValueInNamespace(uint256 key) internal view returns (address) {
* return _NAMESPACE.erc7201Slot().deriveMapping(key).getAddressSlot().value;
* }
* }
* ```
*
* TIP: Consider using this library along with {StorageSlot}.
*
* NOTE: This library provides a way to manipulate storage locations in a non-standard way. Tooling for checking
* upgrade safety will ignore the slots accessed through this library.
*
* _Available since v5.1._
*/
library SlotDerivation {
/**
* @dev Derive an ERC-7201 slot from a string (namespace).
*/
function erc7201Slot(string memory namespace) internal pure returns (bytes32 slot) {
assembly ("memory-safe") {
mstore(0x00, sub(keccak256(add(namespace, 0x20), mload(namespace)), 1))
slot := and(keccak256(0x00, 0x20), not(0xff))
}
}
/**
* @dev Add an offset to a slot to get the n-th element of a structure or an array.
*/
function offset(bytes32 slot, uint256 pos) internal pure returns (bytes32 result) {
unchecked {
return bytes32(uint256(slot) + pos);
}
}
/**
* @dev Derive the location of the first element in an array from the slot where the length is stored.
*/
function deriveArray(bytes32 slot) internal pure returns (bytes32 result) {
assembly ("memory-safe") {
mstore(0x00, slot)
result := keccak256(0x00, 0x20)
}
}
/**
* @dev Derive the location of a mapping element from the key.
*/
function deriveMapping(bytes32 slot, address key) internal pure returns (bytes32 result) {
assembly ("memory-safe") {
mstore(0x00, and(key, shr(96, not(0))))
mstore(0x20, slot)
result := keccak256(0x00, 0x40)
}
}
/**
* @dev Derive the location of a mapping element from the key.
*/
function deriveMapping(bytes32 slot, bool key) internal pure returns (bytes32 result) {
assembly ("memory-safe") {
mstore(0x00, iszero(iszero(key)))
mstore(0x20, slot)
result := keccak256(0x00, 0x40)
}
}
/**
* @dev Derive the location of a mapping element from the key.
*/
function deriveMapping(bytes32 slot, bytes32 key) internal pure returns (bytes32 result) {
assembly ("memory-safe") {
mstore(0x00, key)
mstore(0x20, slot)
result := keccak256(0x00, 0x40)
}
}
/**
* @dev Derive the location of a mapping element from the key.
*/
function deriveMapping(bytes32 slot, uint256 key) internal pure returns (bytes32 result) {
assembly ("memory-safe") {
mstore(0x00, key)
mstore(0x20, slot)
result := keccak256(0x00, 0x40)
}
}
/**
* @dev Derive the location of a mapping element from the key.
*/
function deriveMapping(bytes32 slot, int256 key) internal pure returns (bytes32 result) {
assembly ("memory-safe") {
mstore(0x00, key)
mstore(0x20, slot)
result := keccak256(0x00, 0x40)
}
}
/**
* @dev Derive the location of a mapping element from the key.
*/
function deriveMapping(bytes32 slot, string memory key) internal pure returns (bytes32 result) {
assembly ("memory-safe") {
let length := mload(key)
let begin := add(key, 0x20)
let end := add(begin, length)
let cache := mload(end)
mstore(end, slot)
result := keccak256(begin, add(length, 0x20))
mstore(end, cache)
}
}
/**
* @dev Derive the location of a mapping element from the key.
*/
function deriveMapping(bytes32 slot, bytes memory key) internal pure returns (bytes32 result) {
assembly ("memory-safe") {
let length := mload(key)
let begin := add(key, 0x20)
let end := add(begin, length)
let cache := mload(end)
mstore(end, slot)
result := keccak256(begin, add(length, 0x20))
mstore(end, cache)
}
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.1.0) (utils/StorageSlot.sol)
// This file was procedurally generated from scripts/generate/templates/StorageSlot.js.
pragma solidity ^0.8.20;
/**
* @dev Library for reading and writing primitive types to specific storage slots.
*
* Storage slots are often used to avoid storage conflict when dealing with upgradeable contracts.
* This library helps with reading and writing to such slots without the need for inline assembly.
*
* The functions in this library return Slot structs that contain a `value` member that can be used to read or write.
*
* Example usage to set ERC-1967 implementation slot:
* ```solidity
* contract ERC1967 {
* // Define the slot. Alternatively, use the SlotDerivation library to derive the slot.
* bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;
*
* function _getImplementation() internal view returns (address) {
* return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value;
* }
*
* function _setImplementation(address newImplementation) internal {
* require(newImplementation.code.length > 0);
* StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation;
* }
* }
* ```
*
* TIP: Consider using this library along with {SlotDerivation}.
*/
library StorageSlot {
struct AddressSlot {
address value;
}
struct BooleanSlot {
bool value;
}
struct Bytes32Slot {
bytes32 value;
}
struct Uint256Slot {
uint256 value;
}
struct Int256Slot {
int256 value;
}
struct StringSlot {
string value;
}
struct BytesSlot {
bytes value;
}
/**
* @dev Returns an `AddressSlot` with member `value` located at `slot`.
*/
function getAddressSlot(bytes32 slot) internal pure returns (AddressSlot storage r) {
assembly ("memory-safe") {
r.slot := slot
}
}
/**
* @dev Returns a `BooleanSlot` with member `value` located at `slot`.
*/
function getBooleanSlot(bytes32 slot) internal pure returns (BooleanSlot storage r) {
assembly ("memory-safe") {
r.slot := slot
}
}
/**
* @dev Returns a `Bytes32Slot` with member `value` located at `slot`.
*/
function getBytes32Slot(bytes32 slot) internal pure returns (Bytes32Slot storage r) {
assembly ("memory-safe") {
r.slot := slot
}
}
/**
* @dev Returns a `Uint256Slot` with member `value` located at `slot`.
*/
function getUint256Slot(bytes32 slot) internal pure returns (Uint256Slot storage r) {
assembly ("memory-safe") {
r.slot := slot
}
}
/**
* @dev Returns a `Int256Slot` with member `value` located at `slot`.
*/
function getInt256Slot(bytes32 slot) internal pure returns (Int256Slot storage r) {
assembly ("memory-safe") {
r.slot := slot
}
}
/**
* @dev Returns a `StringSlot` with member `value` located at `slot`.
*/
function getStringSlot(bytes32 slot) internal pure returns (StringSlot storage r) {
assembly ("memory-safe") {
r.slot := slot
}
}
/**
* @dev Returns an `StringSlot` representation of the string storage pointer `store`.
*/
function getStringSlot(string storage store) internal pure returns (StringSlot storage r) {
assembly ("memory-safe") {
r.slot := store.slot
}
}
/**
* @dev Returns a `BytesSlot` with member `value` located at `slot`.
*/
function getBytesSlot(bytes32 slot) internal pure returns (BytesSlot storage r) {
assembly ("memory-safe") {
r.slot := slot
}
}
/**
* @dev Returns an `BytesSlot` representation of the bytes storage pointer `store`.
*/
function getBytesSlot(bytes storage store) internal pure returns (BytesSlot storage r) {
assembly ("memory-safe") {
r.slot := store.slot
}
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.1.0) (utils/math/Math.sol)
pragma solidity ^0.8.20;
import {Panic} from "../Panic.sol";
import {SafeCast} from "./SafeCast.sol";
/**
* @dev Standard math utilities missing in the Solidity language.
*/
library Math {
enum Rounding {
Floor, // Toward negative infinity
Ceil, // Toward positive infinity
Trunc, // Toward zero
Expand // Away from zero
}
/**
* @dev Returns the addition of two unsigned integers, with an success flag (no overflow).
*/
function tryAdd(uint256 a, uint256 b) internal pure returns (bool success, uint256 result) {
unchecked {
uint256 c = a + b;
if (c < a) return (false, 0);
return (true, c);
}
}
/**
* @dev Returns the subtraction of two unsigned integers, with an success flag (no overflow).
*/
function trySub(uint256 a, uint256 b) internal pure returns (bool success, uint256 result) {
unchecked {
if (b > a) return (false, 0);
return (true, a - b);
}
}
/**
* @dev Returns the multiplication of two unsigned integers, with an success flag (no overflow).
*/
function tryMul(uint256 a, uint256 b) internal pure returns (bool success, uint256 result) {
unchecked {
// Gas optimization: this is cheaper than requiring 'a' not being zero, but the
// benefit is lost if 'b' is also tested.
// See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522
if (a == 0) return (true, 0);
uint256 c = a * b;
if (c / a != b) return (false, 0);
return (true, c);
}
}
/**
* @dev Returns the division of two unsigned integers, with a success flag (no division by zero).
*/
function tryDiv(uint256 a, uint256 b) internal pure returns (bool success, uint256 result) {
unchecked {
if (b == 0) return (false, 0);
return (true, a / b);
}
}
/**
* @dev Returns the remainder of dividing two unsigned integers, with a success flag (no division by zero).
*/
function tryMod(uint256 a, uint256 b) internal pure returns (bool success, uint256 result) {
unchecked {
if (b == 0) return (false, 0);
return (true, a % b);
}
}
/**
* @dev Branchless ternary evaluation for `a ? b : c`. Gas costs are constant.
*
* IMPORTANT: This function may reduce bytecode size and consume less gas when used standalone.
* However, the compiler may optimize Solidity ternary operations (i.e. `a ? b : c`) to only compute
* one branch when needed, making this function more expensive.
*/
function ternary(bool condition, uint256 a, uint256 b) internal pure returns (uint256) {
unchecked {
// branchless ternary works because:
// b ^ (a ^ b) == a
// b ^ 0 == b
return b ^ ((a ^ b) * SafeCast.toUint(condition));
}
}
/**
* @dev Returns the largest of two numbers.
*/
function max(uint256 a, uint256 b) internal pure returns (uint256) {
return ternary(a > b, a, b);
}
/**
* @dev Returns the smallest of two numbers.
*/
function min(uint256 a, uint256 b) internal pure returns (uint256) {
return ternary(a < b, a, b);
}
/**
* @dev Returns the average of two numbers. The result is rounded towards
* zero.
*/
function average(uint256 a, uint256 b) internal pure returns (uint256) {
// (a + b) / 2 can overflow.
return (a & b) + (a ^ b) / 2;
}
/**
* @dev Returns the ceiling of the division of two numbers.
*
* This differs from standard division with `/` in that it rounds towards infinity instead
* of rounding towards zero.
*/
function ceilDiv(uint256 a, uint256 b) internal pure returns (uint256) {
if (b == 0) {
// Guarantee the same behavior as in a regular Solidity division.
Panic.panic(Panic.DIVISION_BY_ZERO);
}
// The following calculation ensures accurate ceiling division without overflow.
// Since a is non-zero, (a - 1) / b will not overflow.
// The largest possible result occurs when (a - 1) / b is type(uint256).max,
// but the largest value we can obtain is type(uint256).max - 1, which happens
// when a = type(uint256).max and b = 1.
unchecked {
return SafeCast.toUint(a > 0) * ((a - 1) / b + 1);
}
}
/**
* @dev Calculates floor(x * y / denominator) with full precision. Throws if result overflows a uint256 or
* denominator == 0.
*
* Original credit to Remco Bloemen under MIT license (https://xn--2-umb.com/21/muldiv) with further edits by
* Uniswap Labs also under MIT license.
*/
function mulDiv(uint256 x, uint256 y, uint256 denominator) internal pure returns (uint256 result) {
unchecked {
// 512-bit multiply [prod1 prod0] = x * y. Compute the product mod 2²⁵⁶ and mod 2²⁵⁶ - 1, then use
// the Chinese Remainder Theorem to reconstruct the 512 bit result. The result is stored in two 256
// variables such that product = prod1 * 2²⁵⁶ + prod0.
uint256 prod0 = x * y; // Least significant 256 bits of the product
uint256 prod1; // Most significant 256 bits of the product
assembly {
let mm := mulmod(x, y, not(0))
prod1 := sub(sub(mm, prod0), lt(mm, prod0))
}
// Handle non-overflow cases, 256 by 256 division.
if (prod1 == 0) {
// Solidity will revert if denominator == 0, unlike the div opcode on its own.
// The surrounding unchecked block does not change this fact.
// See https://docs.soliditylang.org/en/latest/control-structures.html#checked-or-unchecked-arithmetic.
return prod0 / denominator;
}
// Make sure the result is less than 2²⁵⁶. Also prevents denominator == 0.
if (denominator <= prod1) {
Panic.panic(ternary(denominator == 0, Panic.DIVISION_BY_ZERO, Panic.UNDER_OVERFLOW));
}
///////////////////////////////////////////////
// 512 by 256 division.
///////////////////////////////////////////////
// Make division exact by subtracting the remainder from [prod1 prod0].
uint256 remainder;
assembly {
// Compute remainder using mulmod.
remainder := mulmod(x, y, denominator)
// Subtract 256 bit number from 512 bit number.
prod1 := sub(prod1, gt(remainder, prod0))
prod0 := sub(prod0, remainder)
}
// Factor powers of two out of denominator and compute largest power of two divisor of denominator.
// Always >= 1. See https://cs.stackexchange.com/q/138556/92363.
uint256 twos = denominator & (0 - denominator);
assembly {
// Divide denominator by twos.
denominator := div(denominator, twos)
// Divide [prod1 prod0] by twos.
prod0 := div(prod0, twos)
// Flip twos such that it is 2²⁵⁶ / twos. If twos is zero, then it becomes one.
twos := add(div(sub(0, twos), twos), 1)
}
// Shift in bits from prod1 into prod0.
prod0 |= prod1 * twos;
// Invert denominator mod 2²⁵⁶. Now that denominator is an odd number, it has an inverse modulo 2²⁵⁶ such
// that denominator * inv ≡ 1 mod 2²⁵⁶. Compute the inverse by starting with a seed that is correct for
// four bits. That is, denominator * inv ≡ 1 mod 2⁴.
uint256 inverse = (3 * denominator) ^ 2;
// Use the Newton-Raphson iteration to improve the precision. Thanks to Hensel's lifting lemma, this also
// works in modular arithmetic, doubling the correct bits in each step.
inverse *= 2 - denominator * inverse; // inverse mod 2⁸
inverse *= 2 - denominator * inverse; // inverse mod 2¹⁶
inverse *= 2 - denominator * inverse; // inverse mod 2³²
inverse *= 2 - denominator * inverse; // inverse mod 2⁶⁴
inverse *= 2 - denominator * inverse; // inverse mod 2¹²⁸
inverse *= 2 - denominator * inverse; // inverse mod 2²⁵⁶
// Because the division is now exact we can divide by multiplying with the modular inverse of denominator.
// This will give us the correct result modulo 2²⁵⁶. Since the preconditions guarantee that the outcome is
// less than 2²⁵⁶, this is the final result. We don't need to compute the high bits of the result and prod1
// is no longer required.
result = prod0 * inverse;
return result;
}
}
/**
* @dev Calculates x * y / denominator with full precision, following the selected rounding direction.
*/
function mulDiv(uint256 x, uint256 y, uint256 denominator, Rounding rounding) internal pure returns (uint256) {
return mulDiv(x, y, denominator) + SafeCast.toUint(unsignedRoundsUp(rounding) && mulmod(x, y, denominator) > 0);
}
/**
* @dev Calculate the modular multiplicative inverse of a number in Z/nZ.
*
* If n is a prime, then Z/nZ is a field. In that case all elements are inversible, except 0.
* If n is not a prime, then Z/nZ is not a field, and some elements might not be inversible.
*
* If the input value is not inversible, 0 is returned.
*
* NOTE: If you know for sure that n is (big) a prime, it may be cheaper to use Fermat's little theorem and get the
* inverse using `Math.modExp(a, n - 2, n)`. See {invModPrime}.
*/
function invMod(uint256 a, uint256 n) internal pure returns (uint256) {
unchecked {
if (n == 0) return 0;
// The inverse modulo is calculated using the Extended Euclidean Algorithm (iterative version)
// Used to compute integers x and y such that: ax + ny = gcd(a, n).
// When the gcd is 1, then the inverse of a modulo n exists and it's x.
// ax + ny = 1
// ax = 1 + (-y)n
// ax ≡ 1 (mod n) # x is the inverse of a modulo n
// If the remainder is 0 the gcd is n right away.
uint256 remainder = a % n;
uint256 gcd = n;
// Therefore the initial coefficients are:
// ax + ny = gcd(a, n) = n
// 0a + 1n = n
int256 x = 0;
int256 y = 1;
while (remainder != 0) {
uint256 quotient = gcd / remainder;
(gcd, remainder) = (
// The old remainder is the next gcd to try.
remainder,
// Compute the next remainder.
// Can't overflow given that (a % gcd) * (gcd // (a % gcd)) <= gcd
// where gcd is at most n (capped to type(uint256).max)
gcd - remainder * quotient
);
(x, y) = (
// Increment the coefficient of a.
y,
// Decrement the coefficient of n.
// Can overflow, but the result is casted to uint256 so that the
// next value of y is "wrapped around" to a value between 0 and n - 1.
x - y * int256(quotient)
);
}
if (gcd != 1) return 0; // No inverse exists.
return ternary(x < 0, n - uint256(-x), uint256(x)); // Wrap the result if it's negative.
}
}
/**
* @dev Variant of {invMod}. More efficient, but only works if `p` is known to be a prime greater than `2`.
*
* From https://en.wikipedia.org/wiki/Fermat%27s_little_theorem[Fermat's little theorem], we know that if p is
* prime, then `a**(p-1) ≡ 1 mod p`. As a consequence, we have `a * a**(p-2) ≡ 1 mod p`, which means that
* `a**(p-2)` is the modular multiplicative inverse of a in Fp.
*
* NOTE: this function does NOT check that `p` is a prime greater than `2`.
*/
function invModPrime(uint256 a, uint256 p) internal view returns (uint256) {
unchecked {
return Math.modExp(a, p - 2, p);
}
}
/**
* @dev Returns the modular exponentiation of the specified base, exponent and modulus (b ** e % m)
*
* Requirements:
* - modulus can't be zero
* - underlying staticcall to precompile must succeed
*
* IMPORTANT: The result is only valid if the underlying call succeeds. When using this function, make
* sure the chain you're using it on supports the precompiled contract for modular exponentiation
* at address 0x05 as specified in https://eips.ethereum.org/EIPS/eip-198[EIP-198]. Otherwise,
* the underlying function will succeed given the lack of a revert, but the result may be incorrectly
* interpreted as 0.
*/
function modExp(uint256 b, uint256 e, uint256 m) internal view returns (uint256) {
(bool success, uint256 result) = tryModExp(b, e, m);
if (!success) {
Panic.panic(Panic.DIVISION_BY_ZERO);
}
return result;
}
/**
* @dev Returns the modular exponentiation of the specified base, exponent and modulus (b ** e % m).
* It includes a success flag indicating if the operation succeeded. Operation will be marked as failed if trying
* to operate modulo 0 or if the underlying precompile reverted.
*
* IMPORTANT: The result is only valid if the success flag is true. When using this function, make sure the chain
* you're using it on supports the precompiled contract for modular exponentiation at address 0x05 as specified in
* https://eips.ethereum.org/EIPS/eip-198[EIP-198]. Otherwise, the underlying function will succeed given the lack
* of a revert, but the result may be incorrectly interpreted as 0.
*/
function tryModExp(uint256 b, uint256 e, uint256 m) internal view returns (bool success, uint256 result) {
if (m == 0) return (false, 0);
assembly ("memory-safe") {
let ptr := mload(0x40)
// | Offset | Content | Content (Hex) |
// |-----------|------------|--------------------------------------------------------------------|
// | 0x00:0x1f | size of b | 0x0000000000000000000000000000000000000000000000000000000000000020 |
// | 0x20:0x3f | size of e | 0x0000000000000000000000000000000000000000000000000000000000000020 |
// | 0x40:0x5f | size of m | 0x0000000000000000000000000000000000000000000000000000000000000020 |
// | 0x60:0x7f | value of b | 0x<.............................................................b> |
// | 0x80:0x9f | value of e | 0x<.............................................................e> |
// | 0xa0:0xbf | value of m | 0x<.............................................................m> |
mstore(ptr, 0x20)
mstore(add(ptr, 0x20), 0x20)
mstore(add(ptr, 0x40), 0x20)
mstore(add(ptr, 0x60), b)
mstore(add(ptr, 0x80), e)
mstore(add(ptr, 0xa0), m)
// Given the result < m, it's guaranteed to fit in 32 bytes,
// so we can use the memory scratch space located at offset 0.
success := staticcall(gas(), 0x05, ptr, 0xc0, 0x00, 0x20)
result := mload(0x00)
}
}
/**
* @dev Variant of {modExp} that supports inputs of arbitrary length.
*/
function modExp(bytes memory b, bytes memory e, bytes memory m) internal view returns (bytes memory) {
(bool success, bytes memory result) = tryModExp(b, e, m);
if (!success) {
Panic.panic(Panic.DIVISION_BY_ZERO);
}
return result;
}
/**
* @dev Variant of {tryModExp} that supports inputs of arbitrary length.
*/
function tryModExp(
bytes memory b,
bytes memory e,
bytes memory m
) internal view returns (bool success, bytes memory result) {
if (_zeroBytes(m)) return (false, new bytes(0));
uint256 mLen = m.length;
// Encode call args in result and move the free memory pointer
result = abi.encodePacked(b.length, e.length, mLen, b, e, m);
assembly ("memory-safe") {
let dataPtr := add(result, 0x20)
// Write result on top of args to avoid allocating extra memory.
success := staticcall(gas(), 0x05, dataPtr, mload(result), dataPtr, mLen)
// Overwrite the length.
// result.length > returndatasize() is guaranteed because returndatasize() == m.length
mstore(result, mLen)
// Set the memory pointer after the returned data.
mstore(0x40, add(dataPtr, mLen))
}
}
/**
* @dev Returns whether the provided byte array is zero.
*/
function _zeroBytes(bytes memory byteArray) private pure returns (bool) {
for (uint256 i = 0; i < byteArray.length; ++i) {
if (byteArray[i] != 0) {
return false;
}
}
return true;
}
/**
* @dev Returns the square root of a number. If the number is not a perfect square, the value is rounded
* towards zero.
*
* This method is based on Newton's method for computing square roots; the algorithm is restricted to only
* using integer operations.
*/
function sqrt(uint256 a) internal pure returns (uint256) {
unchecked {
// Take care of easy edge cases when a == 0 or a == 1
if (a <= 1) {
return a;
}
// In this function, we use Newton's method to get a root of `f(x) := x² - a`. It involves building a
// sequence x_n that converges toward sqrt(a). For each iteration x_n, we also define the error between
// the current value as `ε_n = | x_n - sqrt(a) |`.
//
// For our first estimation, we consider `e` the smallest power of 2 which is bigger than the square root
// of the target. (i.e. `2**(e-1) ≤ sqrt(a) < 2**e`). We know that `e ≤ 128` because `(2¹²⁸)² = 2²⁵⁶` is
// bigger than any uint256.
//
// By noticing that
// `2**(e-1) ≤ sqrt(a) < 2**e → (2**(e-1))² ≤ a < (2**e)² → 2**(2*e-2) ≤ a < 2**(2*e)`
// we can deduce that `e - 1` is `log2(a) / 2`. We can thus compute `x_n = 2**(e-1)` using a method similar
// to the msb function.
uint256 aa = a;
uint256 xn = 1;
if (aa >= (1 << 128)) {
aa >>= 128;
xn <<= 64;
}
if (aa >= (1 << 64)) {
aa >>= 64;
xn <<= 32;
}
if (aa >= (1 << 32)) {
aa >>= 32;
xn <<= 16;
}
if (aa >= (1 << 16)) {
aa >>= 16;
xn <<= 8;
}
if (aa >= (1 << 8)) {
aa >>= 8;
xn <<= 4;
}
if (aa >= (1 << 4)) {
aa >>= 4;
xn <<= 2;
}
if (aa >= (1 << 2)) {
xn <<= 1;
}
// We now have x_n such that `x_n = 2**(e-1) ≤ sqrt(a) < 2**e = 2 * x_n`. This implies ε_n ≤ 2**(e-1).
//
// We can refine our estimation by noticing that the middle of that interval minimizes the error.
// If we move x_n to equal 2**(e-1) + 2**(e-2), then we reduce the error to ε_n ≤ 2**(e-2).
// This is going to be our x_0 (and ε_0)
xn = (3 * xn) >> 1; // ε_0 := | x_0 - sqrt(a) | ≤ 2**(e-2)
// From here, Newton's method give us:
// x_{n+1} = (x_n + a / x_n) / 2
//
// One should note that:
// x_{n+1}² - a = ((x_n + a / x_n) / 2)² - a
// = ((x_n² + a) / (2 * x_n))² - a
// = (x_n⁴ + 2 * a * x_n² + a²) / (4 * x_n²) - a
// = (x_n⁴ + 2 * a * x_n² + a² - 4 * a * x_n²) / (4 * x_n²)
// = (x_n⁴ - 2 * a * x_n² + a²) / (4 * x_n²)
// = (x_n² - a)² / (2 * x_n)²
// = ((x_n² - a) / (2 * x_n))²
// ≥ 0
// Which proves that for all n ≥ 1, sqrt(a) ≤ x_n
//
// This gives us the proof of quadratic convergence of the sequence:
// ε_{n+1} = | x_{n+1} - sqrt(a) |
// = | (x_n + a / x_n) / 2 - sqrt(a) |
// = | (x_n² + a - 2*x_n*sqrt(a)) / (2 * x_n) |
// = | (x_n - sqrt(a))² / (2 * x_n) |
// = | ε_n² / (2 * x_n) |
// = ε_n² / | (2 * x_n) |
//
// For the first iteration, we have a special case where x_0 is known:
// ε_1 = ε_0² / | (2 * x_0) |
// ≤ (2**(e-2))² / (2 * (2**(e-1) + 2**(e-2)))
// ≤ 2**(2*e-4) / (3 * 2**(e-1))
// ≤ 2**(e-3) / 3
// ≤ 2**(e-3-log2(3))
// ≤ 2**(e-4.5)
//
// For the following iterations, we use the fact that, 2**(e-1) ≤ sqrt(a) ≤ x_n:
// ε_{n+1} = ε_n² / | (2 * x_n) |
// ≤ (2**(e-k))² / (2 * 2**(e-1))
// ≤ 2**(2*e-2*k) / 2**e
// ≤ 2**(e-2*k)
xn = (xn + a / xn) >> 1; // ε_1 := | x_1 - sqrt(a) | ≤ 2**(e-4.5) -- special case, see above
xn = (xn + a / xn) >> 1; // ε_2 := | x_2 - sqrt(a) | ≤ 2**(e-9) -- general case with k = 4.5
xn = (xn + a / xn) >> 1; // ε_3 := | x_3 - sqrt(a) | ≤ 2**(e-18) -- general case with k = 9
xn = (xn + a / xn) >> 1; // ε_4 := | x_4 - sqrt(a) | ≤ 2**(e-36) -- general case with k = 18
xn = (xn + a / xn) >> 1; // ε_5 := | x_5 - sqrt(a) | ≤ 2**(e-72) -- general case with k = 36
xn = (xn + a / xn) >> 1; // ε_6 := | x_6 - sqrt(a) | ≤ 2**(e-144) -- general case with k = 72
// Because e ≤ 128 (as discussed during the first estimation phase), we know have reached a precision
// ε_6 ≤ 2**(e-144) < 1. Given we're operating on integers, then we can ensure that xn is now either
// sqrt(a) or sqrt(a) + 1.
return xn - SafeCast.toUint(xn > a / xn);
}
}
/**
* @dev Calculates sqrt(a), following the selected rounding direction.
*/
function sqrt(uint256 a, Rounding rounding) internal pure returns (uint256) {
unchecked {
uint256 result = sqrt(a);
return result + SafeCast.toUint(unsignedRoundsUp(rounding) && result * result < a);
}
}
/**
* @dev Return the log in base 2 of a positive value rounded towards zero.
* Returns 0 if given 0.
*/
function log2(uint256 value) internal pure returns (uint256) {
uint256 result = 0;
uint256 exp;
unchecked {
exp = 128 * SafeCast.toUint(value > (1 << 128) - 1);
value >>= exp;
result += exp;
exp = 64 * SafeCast.toUint(value > (1 << 64) - 1);
value >>= exp;
result += exp;
exp = 32 * SafeCast.toUint(value > (1 << 32) - 1);
value >>= exp;
result += exp;
exp = 16 * SafeCast.toUint(value > (1 << 16) - 1);
value >>= exp;
result += exp;
exp = 8 * SafeCast.toUint(value > (1 << 8) - 1);
value >>= exp;
result += exp;
exp = 4 * SafeCast.toUint(value > (1 << 4) - 1);
value >>= exp;
result += exp;
exp = 2 * SafeCast.toUint(value > (1 << 2) - 1);
value >>= exp;
result += exp;
result += SafeCast.toUint(value > 1);
}
return result;
}
/**
* @dev Return the log in base 2, following the selected rounding direction, of a positive value.
* Returns 0 if given 0.
*/
function log2(uint256 value, Rounding rounding) internal pure returns (uint256) {
unchecked {
uint256 result = log2(value);
return result + SafeCast.toUint(unsignedRoundsUp(rounding) && 1 << result < value);
}
}
/**
* @dev Return the log in base 10 of a positive value rounded towards zero.
* Returns 0 if given 0.
*/
function log10(uint256 value) internal pure returns (uint256) {
uint256 result = 0;
unchecked {
if (value >= 10 ** 64) {
value /= 10 ** 64;
result += 64;
}
if (value >= 10 ** 32) {
value /= 10 ** 32;
result += 32;
}
if (value >= 10 ** 16) {
value /= 10 ** 16;
result += 16;
}
if (value >= 10 ** 8) {
value /= 10 ** 8;
result += 8;
}
if (value >= 10 ** 4) {
value /= 10 ** 4;
result += 4;
}
if (value >= 10 ** 2) {
value /= 10 ** 2;
result += 2;
}
if (value >= 10 ** 1) {
result += 1;
}
}
return result;
}
/**
* @dev Return the log in base 10, following the selected rounding direction, of a positive value.
* Returns 0 if given 0.
*/
function log10(uint256 value, Rounding rounding) internal pure returns (uint256) {
unchecked {
uint256 result = log10(value);
return result + SafeCast.toUint(unsignedRoundsUp(rounding) && 10 ** result < value);
}
}
/**
* @dev Return the log in base 256 of a positive value rounded towards zero.
* Returns 0 if given 0.
*
* Adding one to the result gives the number of pairs of hex symbols needed to represent `value` as a hex string.
*/
function log256(uint256 value) internal pure returns (uint256) {
uint256 result = 0;
uint256 isGt;
unchecked {
isGt = SafeCast.toUint(value > (1 << 128) - 1);
value >>= isGt * 128;
result += isGt * 16;
isGt = SafeCast.toUint(value > (1 << 64) - 1);
value >>= isGt * 64;
result += isGt * 8;
isGt = SafeCast.toUint(value > (1 << 32) - 1);
value >>= isGt * 32;
result += isGt * 4;
isGt = SafeCast.toUint(value > (1 << 16) - 1);
value >>= isGt * 16;
result += isGt * 2;
result += SafeCast.toUint(value > (1 << 8) - 1);
}
return result;
}
/**
* @dev Return the log in base 256, following the selected rounding direction, of a positive value.
* Returns 0 if given 0.
*/
function log256(uint256 value, Rounding rounding) internal pure returns (uint256) {
unchecked {
uint256 result = log256(value);
return result + SafeCast.toUint(unsignedRoundsUp(rounding) && 1 << (result << 3) < value);
}
}
/**
* @dev Returns whether a provided rounding mode is considered rounding up for unsigned integers.
*/
function unsignedRoundsUp(Rounding rounding) internal pure returns (bool) {
return uint8(rounding) % 2 == 1;
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (interfaces/IERC165.sol)
pragma solidity ^0.8.20;
import {IERC165} from "../utils/introspection/IERC165.sol";// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.1.0) (utils/Panic.sol)
pragma solidity ^0.8.20;
/**
* @dev Helper library for emitting standardized panic codes.
*
* ```solidity
* contract Example {
* using Panic for uint256;
*
* // Use any of the declared internal constants
* function foo() { Panic.GENERIC.panic(); }
*
* // Alternatively
* function foo() { Panic.panic(Panic.GENERIC); }
* }
* ```
*
* Follows the list from https://github.com/ethereum/solidity/blob/v0.8.24/libsolutil/ErrorCodes.h[libsolutil].
*
* _Available since v5.1._
*/
// slither-disable-next-line unused-state
library Panic {
/// @dev generic / unspecified error
uint256 internal constant GENERIC = 0x00;
/// @dev used by the assert() builtin
uint256 internal constant ASSERT = 0x01;
/// @dev arithmetic underflow or overflow
uint256 internal constant UNDER_OVERFLOW = 0x11;
/// @dev division or modulo by zero
uint256 internal constant DIVISION_BY_ZERO = 0x12;
/// @dev enum conversion error
uint256 internal constant ENUM_CONVERSION_ERROR = 0x21;
/// @dev invalid encoding in storage
uint256 internal constant STORAGE_ENCODING_ERROR = 0x22;
/// @dev empty array pop
uint256 internal constant EMPTY_ARRAY_POP = 0x31;
/// @dev array out of bounds access
uint256 internal constant ARRAY_OUT_OF_BOUNDS = 0x32;
/// @dev resource error (too large allocation or too large array)
uint256 internal constant RESOURCE_ERROR = 0x41;
/// @dev calling invalid internal function
uint256 internal constant INVALID_INTERNAL_FUNCTION = 0x51;
/// @dev Reverts with a panic code. Recommended to use with
/// the internal constants with predefined codes.
function panic(uint256 code) internal pure {
assembly ("memory-safe") {
mstore(0x00, 0x4e487b71)
mstore(0x20, code)
revert(0x1c, 0x24)
}
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.1.0) (utils/math/SafeCast.sol)
// This file was procedurally generated from scripts/generate/templates/SafeCast.js.
pragma solidity ^0.8.20;
/**
* @dev Wrappers over Solidity's uintXX/intXX/bool casting operators with added overflow
* checks.
*
* Downcasting from uint256/int256 in Solidity does not revert on overflow. This can
* easily result in undesired exploitation or bugs, since developers usually
* assume that overflows raise errors. `SafeCast` restores this intuition by
* reverting the transaction when such an operation overflows.
*
* Using this library instead of the unchecked operations eliminates an entire
* class of bugs, so it's recommended to use it always.
*/
library SafeCast {
/**
* @dev Value doesn't fit in an uint of `bits` size.
*/
error SafeCastOverflowedUintDowncast(uint8 bits, uint256 value);
/**
* @dev An int value doesn't fit in an uint of `bits` size.
*/
error SafeCastOverflowedIntToUint(int256 value);
/**
* @dev Value doesn't fit in an int of `bits` size.
*/
error SafeCastOverflowedIntDowncast(uint8 bits, int256 value);
/**
* @dev An uint value doesn't fit in an int of `bits` size.
*/
error SafeCastOverflowedUintToInt(uint256 value);
/**
* @dev Returns the downcasted uint248 from uint256, reverting on
* overflow (when the input is greater than largest uint248).
*
* Counterpart to Solidity's `uint248` operator.
*
* Requirements:
*
* - input must fit into 248 bits
*/
function toUint248(uint256 value) internal pure returns (uint248) {
if (value > type(uint248).max) {
revert SafeCastOverflowedUintDowncast(248, value);
}
return uint248(value);
}
/**
* @dev Returns the downcasted uint240 from uint256, reverting on
* overflow (when the input is greater than largest uint240).
*
* Counterpart to Solidity's `uint240` operator.
*
* Requirements:
*
* - input must fit into 240 bits
*/
function toUint240(uint256 value) internal pure returns (uint240) {
if (value > type(uint240).max) {
revert SafeCastOverflowedUintDowncast(240, value);
}
return uint240(value);
}
/**
* @dev Returns the downcasted uint232 from uint256, reverting on
* overflow (when the input is greater than largest uint232).
*
* Counterpart to Solidity's `uint232` operator.
*
* Requirements:
*
* - input must fit into 232 bits
*/
function toUint232(uint256 value) internal pure returns (uint232) {
if (value > type(uint232).max) {
revert SafeCastOverflowedUintDowncast(232, value);
}
return uint232(value);
}
/**
* @dev Returns the downcasted uint224 from uint256, reverting on
* overflow (when the input is greater than largest uint224).
*
* Counterpart to Solidity's `uint224` operator.
*
* Requirements:
*
* - input must fit into 224 bits
*/
function toUint224(uint256 value) internal pure returns (uint224) {
if (value > type(uint224).max) {
revert SafeCastOverflowedUintDowncast(224, value);
}
return uint224(value);
}
/**
* @dev Returns the downcasted uint216 from uint256, reverting on
* overflow (when the input is greater than largest uint216).
*
* Counterpart to Solidity's `uint216` operator.
*
* Requirements:
*
* - input must fit into 216 bits
*/
function toUint216(uint256 value) internal pure returns (uint216) {
if (value > type(uint216).max) {
revert SafeCastOverflowedUintDowncast(216, value);
}
return uint216(value);
}
/**
* @dev Returns the downcasted uint208 from uint256, reverting on
* overflow (when the input is greater than largest uint208).
*
* Counterpart to Solidity's `uint208` operator.
*
* Requirements:
*
* - input must fit into 208 bits
*/
function toUint208(uint256 value) internal pure returns (uint208) {
if (value > type(uint208).max) {
revert SafeCastOverflowedUintDowncast(208, value);
}
return uint208(value);
}
/**
* @dev Returns the downcasted uint200 from uint256, reverting on
* overflow (when the input is greater than largest uint200).
*
* Counterpart to Solidity's `uint200` operator.
*
* Requirements:
*
* - input must fit into 200 bits
*/
function toUint200(uint256 value) internal pure returns (uint200) {
if (value > type(uint200).max) {
revert SafeCastOverflowedUintDowncast(200, value);
}
return uint200(value);
}
/**
* @dev Returns the downcasted uint192 from uint256, reverting on
* overflow (when the input is greater than largest uint192).
*
* Counterpart to Solidity's `uint192` operator.
*
* Requirements:
*
* - input must fit into 192 bits
*/
function toUint192(uint256 value) internal pure returns (uint192) {
if (value > type(uint192).max) {
revert SafeCastOverflowedUintDowncast(192, value);
}
return uint192(value);
}
/**
* @dev Returns the downcasted uint184 from uint256, reverting on
* overflow (when the input is greater than largest uint184).
*
* Counterpart to Solidity's `uint184` operator.
*
* Requirements:
*
* - input must fit into 184 bits
*/
function toUint184(uint256 value) internal pure returns (uint184) {
if (value > type(uint184).max) {
revert SafeCastOverflowedUintDowncast(184, value);
}
return uint184(value);
}
/**
* @dev Returns the downcasted uint176 from uint256, reverting on
* overflow (when the input is greater than largest uint176).
*
* Counterpart to Solidity's `uint176` operator.
*
* Requirements:
*
* - input must fit into 176 bits
*/
function toUint176(uint256 value) internal pure returns (uint176) {
if (value > type(uint176).max) {
revert SafeCastOverflowedUintDowncast(176, value);
}
return uint176(value);
}
/**
* @dev Returns the downcasted uint168 from uint256, reverting on
* overflow (when the input is greater than largest uint168).
*
* Counterpart to Solidity's `uint168` operator.
*
* Requirements:
*
* - input must fit into 168 bits
*/
function toUint168(uint256 value) internal pure returns (uint168) {
if (value > type(uint168).max) {
revert SafeCastOverflowedUintDowncast(168, value);
}
return uint168(value);
}
/**
* @dev Returns the downcasted uint160 from uint256, reverting on
* overflow (when the input is greater than largest uint160).
*
* Counterpart to Solidity's `uint160` operator.
*
* Requirements:
*
* - input must fit into 160 bits
*/
function toUint160(uint256 value) internal pure returns (uint160) {
if (value > type(uint160).max) {
revert SafeCastOverflowedUintDowncast(160, value);
}
return uint160(value);
}
/**
* @dev Returns the downcasted uint152 from uint256, reverting on
* overflow (when the input is greater than largest uint152).
*
* Counterpart to Solidity's `uint152` operator.
*
* Requirements:
*
* - input must fit into 152 bits
*/
function toUint152(uint256 value) internal pure returns (uint152) {
if (value > type(uint152).max) {
revert SafeCastOverflowedUintDowncast(152, value);
}
return uint152(value);
}
/**
* @dev Returns the downcasted uint144 from uint256, reverting on
* overflow (when the input is greater than largest uint144).
*
* Counterpart to Solidity's `uint144` operator.
*
* Requirements:
*
* - input must fit into 144 bits
*/
function toUint144(uint256 value) internal pure returns (uint144) {
if (value > type(uint144).max) {
revert SafeCastOverflowedUintDowncast(144, value);
}
return uint144(value);
}
/**
* @dev Returns the downcasted uint136 from uint256, reverting on
* overflow (when the input is greater than largest uint136).
*
* Counterpart to Solidity's `uint136` operator.
*
* Requirements:
*
* - input must fit into 136 bits
*/
function toUint136(uint256 value) internal pure returns (uint136) {
if (value > type(uint136).max) {
revert SafeCastOverflowedUintDowncast(136, value);
}
return uint136(value);
}
/**
* @dev Returns the downcasted uint128 from uint256, reverting on
* overflow (when the input is greater than largest uint128).
*
* Counterpart to Solidity's `uint128` operator.
*
* Requirements:
*
* - input must fit into 128 bits
*/
function toUint128(uint256 value) internal pure returns (uint128) {
if (value > type(uint128).max) {
revert SafeCastOverflowedUintDowncast(128, value);
}
return uint128(value);
}
/**
* @dev Returns the downcasted uint120 from uint256, reverting on
* overflow (when the input is greater than largest uint120).
*
* Counterpart to Solidity's `uint120` operator.
*
* Requirements:
*
* - input must fit into 120 bits
*/
function toUint120(uint256 value) internal pure returns (uint120) {
if (value > type(uint120).max) {
revert SafeCastOverflowedUintDowncast(120, value);
}
return uint120(value);
}
/**
* @dev Returns the downcasted uint112 from uint256, reverting on
* overflow (when the input is greater than largest uint112).
*
* Counterpart to Solidity's `uint112` operator.
*
* Requirements:
*
* - input must fit into 112 bits
*/
function toUint112(uint256 value) internal pure returns (uint112) {
if (value > type(uint112).max) {
revert SafeCastOverflowedUintDowncast(112, value);
}
return uint112(value);
}
/**
* @dev Returns the downcasted uint104 from uint256, reverting on
* overflow (when the input is greater than largest uint104).
*
* Counterpart to Solidity's `uint104` operator.
*
* Requirements:
*
* - input must fit into 104 bits
*/
function toUint104(uint256 value) internal pure returns (uint104) {
if (value > type(uint104).max) {
revert SafeCastOverflowedUintDowncast(104, value);
}
return uint104(value);
}
/**
* @dev Returns the downcasted uint96 from uint256, reverting on
* overflow (when the input is greater than largest uint96).
*
* Counterpart to Solidity's `uint96` operator.
*
* Requirements:
*
* - input must fit into 96 bits
*/
function toUint96(uint256 value) internal pure returns (uint96) {
if (value > type(uint96).max) {
revert SafeCastOverflowedUintDowncast(96, value);
}
return uint96(value);
}
/**
* @dev Returns the downcasted uint88 from uint256, reverting on
* overflow (when the input is greater than largest uint88).
*
* Counterpart to Solidity's `uint88` operator.
*
* Requirements:
*
* - input must fit into 88 bits
*/
function toUint88(uint256 value) internal pure returns (uint88) {
if (value > type(uint88).max) {
revert SafeCastOverflowedUintDowncast(88, value);
}
return uint88(value);
}
/**
* @dev Returns the downcasted uint80 from uint256, reverting on
* overflow (when the input is greater than largest uint80).
*
* Counterpart to Solidity's `uint80` operator.
*
* Requirements:
*
* - input must fit into 80 bits
*/
function toUint80(uint256 value) internal pure returns (uint80) {
if (value > type(uint80).max) {
revert SafeCastOverflowedUintDowncast(80, value);
}
return uint80(value);
}
/**
* @dev Returns the downcasted uint72 from uint256, reverting on
* overflow (when the input is greater than largest uint72).
*
* Counterpart to Solidity's `uint72` operator.
*
* Requirements:
*
* - input must fit into 72 bits
*/
function toUint72(uint256 value) internal pure returns (uint72) {
if (value > type(uint72).max) {
revert SafeCastOverflowedUintDowncast(72, value);
}
return uint72(value);
}
/**
* @dev Returns the downcasted uint64 from uint256, reverting on
* overflow (when the input is greater than largest uint64).
*
* Counterpart to Solidity's `uint64` operator.
*
* Requirements:
*
* - input must fit into 64 bits
*/
function toUint64(uint256 value) internal pure returns (uint64) {
if (value > type(uint64).max) {
revert SafeCastOverflowedUintDowncast(64, value);
}
return uint64(value);
}
/**
* @dev Returns the downcasted uint56 from uint256, reverting on
* overflow (when the input is greater than largest uint56).
*
* Counterpart to Solidity's `uint56` operator.
*
* Requirements:
*
* - input must fit into 56 bits
*/
function toUint56(uint256 value) internal pure returns (uint56) {
if (value > type(uint56).max) {
revert SafeCastOverflowedUintDowncast(56, value);
}
return uint56(value);
}
/**
* @dev Returns the downcasted uint48 from uint256, reverting on
* overflow (when the input is greater than largest uint48).
*
* Counterpart to Solidity's `uint48` operator.
*
* Requirements:
*
* - input must fit into 48 bits
*/
function toUint48(uint256 value) internal pure returns (uint48) {
if (value > type(uint48).max) {
revert SafeCastOverflowedUintDowncast(48, value);
}
return uint48(value);
}
/**
* @dev Returns the downcasted uint40 from uint256, reverting on
* overflow (when the input is greater than largest uint40).
*
* Counterpart to Solidity's `uint40` operator.
*
* Requirements:
*
* - input must fit into 40 bits
*/
function toUint40(uint256 value) internal pure returns (uint40) {
if (value > type(uint40).max) {
revert SafeCastOverflowedUintDowncast(40, value);
}
return uint40(value);
}
/**
* @dev Returns the downcasted uint32 from uint256, reverting on
* overflow (when the input is greater than largest uint32).
*
* Counterpart to Solidity's `uint32` operator.
*
* Requirements:
*
* - input must fit into 32 bits
*/
function toUint32(uint256 value) internal pure returns (uint32) {
if (value > type(uint32).max) {
revert SafeCastOverflowedUintDowncast(32, value);
}
return uint32(value);
}
/**
* @dev Returns the downcasted uint24 from uint256, reverting on
* overflow (when the input is greater than largest uint24).
*
* Counterpart to Solidity's `uint24` operator.
*
* Requirements:
*
* - input must fit into 24 bits
*/
function toUint24(uint256 value) internal pure returns (uint24) {
if (value > type(uint24).max) {
revert SafeCastOverflowedUintDowncast(24, value);
}
return uint24(value);
}
/**
* @dev Returns the downcasted uint16 from uint256, reverting on
* overflow (when the input is greater than largest uint16).
*
* Counterpart to Solidity's `uint16` operator.
*
* Requirements:
*
* - input must fit into 16 bits
*/
function toUint16(uint256 value) internal pure returns (uint16) {
if (value > type(uint16).max) {
revert SafeCastOverflowedUintDowncast(16, value);
}
return uint16(value);
}
/**
* @dev Returns the downcasted uint8 from uint256, reverting on
* overflow (when the input is greater than largest uint8).
*
* Counterpart to Solidity's `uint8` operator.
*
* Requirements:
*
* - input must fit into 8 bits
*/
function toUint8(uint256 value) internal pure returns (uint8) {
if (value > type(uint8).max) {
revert SafeCastOverflowedUintDowncast(8, value);
}
return uint8(value);
}
/**
* @dev Converts a signed int256 into an unsigned uint256.
*
* Requirements:
*
* - input must be greater than or equal to 0.
*/
function toUint256(int256 value) internal pure returns (uint256) {
if (value < 0) {
revert SafeCastOverflowedIntToUint(value);
}
return uint256(value);
}
/**
* @dev Returns the downcasted int248 from int256, reverting on
* overflow (when the input is less than smallest int248 or
* greater than largest int248).
*
* Counterpart to Solidity's `int248` operator.
*
* Requirements:
*
* - input must fit into 248 bits
*/
function toInt248(int256 value) internal pure returns (int248 downcasted) {
downcasted = int248(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(248, value);
}
}
/**
* @dev Returns the downcasted int240 from int256, reverting on
* overflow (when the input is less than smallest int240 or
* greater than largest int240).
*
* Counterpart to Solidity's `int240` operator.
*
* Requirements:
*
* - input must fit into 240 bits
*/
function toInt240(int256 value) internal pure returns (int240 downcasted) {
downcasted = int240(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(240, value);
}
}
/**
* @dev Returns the downcasted int232 from int256, reverting on
* overflow (when the input is less than smallest int232 or
* greater than largest int232).
*
* Counterpart to Solidity's `int232` operator.
*
* Requirements:
*
* - input must fit into 232 bits
*/
function toInt232(int256 value) internal pure returns (int232 downcasted) {
downcasted = int232(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(232, value);
}
}
/**
* @dev Returns the downcasted int224 from int256, reverting on
* overflow (when the input is less than smallest int224 or
* greater than largest int224).
*
* Counterpart to Solidity's `int224` operator.
*
* Requirements:
*
* - input must fit into 224 bits
*/
function toInt224(int256 value) internal pure returns (int224 downcasted) {
downcasted = int224(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(224, value);
}
}
/**
* @dev Returns the downcasted int216 from int256, reverting on
* overflow (when the input is less than smallest int216 or
* greater than largest int216).
*
* Counterpart to Solidity's `int216` operator.
*
* Requirements:
*
* - input must fit into 216 bits
*/
function toInt216(int256 value) internal pure returns (int216 downcasted) {
downcasted = int216(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(216, value);
}
}
/**
* @dev Returns the downcasted int208 from int256, reverting on
* overflow (when the input is less than smallest int208 or
* greater than largest int208).
*
* Counterpart to Solidity's `int208` operator.
*
* Requirements:
*
* - input must fit into 208 bits
*/
function toInt208(int256 value) internal pure returns (int208 downcasted) {
downcasted = int208(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(208, value);
}
}
/**
* @dev Returns the downcasted int200 from int256, reverting on
* overflow (when the input is less than smallest int200 or
* greater than largest int200).
*
* Counterpart to Solidity's `int200` operator.
*
* Requirements:
*
* - input must fit into 200 bits
*/
function toInt200(int256 value) internal pure returns (int200 downcasted) {
downcasted = int200(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(200, value);
}
}
/**
* @dev Returns the downcasted int192 from int256, reverting on
* overflow (when the input is less than smallest int192 or
* greater than largest int192).
*
* Counterpart to Solidity's `int192` operator.
*
* Requirements:
*
* - input must fit into 192 bits
*/
function toInt192(int256 value) internal pure returns (int192 downcasted) {
downcasted = int192(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(192, value);
}
}
/**
* @dev Returns the downcasted int184 from int256, reverting on
* overflow (when the input is less than smallest int184 or
* greater than largest int184).
*
* Counterpart to Solidity's `int184` operator.
*
* Requirements:
*
* - input must fit into 184 bits
*/
function toInt184(int256 value) internal pure returns (int184 downcasted) {
downcasted = int184(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(184, value);
}
}
/**
* @dev Returns the downcasted int176 from int256, reverting on
* overflow (when the input is less than smallest int176 or
* greater than largest int176).
*
* Counterpart to Solidity's `int176` operator.
*
* Requirements:
*
* - input must fit into 176 bits
*/
function toInt176(int256 value) internal pure returns (int176 downcasted) {
downcasted = int176(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(176, value);
}
}
/**
* @dev Returns the downcasted int168 from int256, reverting on
* overflow (when the input is less than smallest int168 or
* greater than largest int168).
*
* Counterpart to Solidity's `int168` operator.
*
* Requirements:
*
* - input must fit into 168 bits
*/
function toInt168(int256 value) internal pure returns (int168 downcasted) {
downcasted = int168(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(168, value);
}
}
/**
* @dev Returns the downcasted int160 from int256, reverting on
* overflow (when the input is less than smallest int160 or
* greater than largest int160).
*
* Counterpart to Solidity's `int160` operator.
*
* Requirements:
*
* - input must fit into 160 bits
*/
function toInt160(int256 value) internal pure returns (int160 downcasted) {
downcasted = int160(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(160, value);
}
}
/**
* @dev Returns the downcasted int152 from int256, reverting on
* overflow (when the input is less than smallest int152 or
* greater than largest int152).
*
* Counterpart to Solidity's `int152` operator.
*
* Requirements:
*
* - input must fit into 152 bits
*/
function toInt152(int256 value) internal pure returns (int152 downcasted) {
downcasted = int152(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(152, value);
}
}
/**
* @dev Returns the downcasted int144 from int256, reverting on
* overflow (when the input is less than smallest int144 or
* greater than largest int144).
*
* Counterpart to Solidity's `int144` operator.
*
* Requirements:
*
* - input must fit into 144 bits
*/
function toInt144(int256 value) internal pure returns (int144 downcasted) {
downcasted = int144(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(144, value);
}
}
/**
* @dev Returns the downcasted int136 from int256, reverting on
* overflow (when the input is less than smallest int136 or
* greater than largest int136).
*
* Counterpart to Solidity's `int136` operator.
*
* Requirements:
*
* - input must fit into 136 bits
*/
function toInt136(int256 value) internal pure returns (int136 downcasted) {
downcasted = int136(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(136, value);
}
}
/**
* @dev Returns the downcasted int128 from int256, reverting on
* overflow (when the input is less than smallest int128 or
* greater than largest int128).
*
* Counterpart to Solidity's `int128` operator.
*
* Requirements:
*
* - input must fit into 128 bits
*/
function toInt128(int256 value) internal pure returns (int128 downcasted) {
downcasted = int128(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(128, value);
}
}
/**
* @dev Returns the downcasted int120 from int256, reverting on
* overflow (when the input is less than smallest int120 or
* greater than largest int120).
*
* Counterpart to Solidity's `int120` operator.
*
* Requirements:
*
* - input must fit into 120 bits
*/
function toInt120(int256 value) internal pure returns (int120 downcasted) {
downcasted = int120(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(120, value);
}
}
/**
* @dev Returns the downcasted int112 from int256, reverting on
* overflow (when the input is less than smallest int112 or
* greater than largest int112).
*
* Counterpart to Solidity's `int112` operator.
*
* Requirements:
*
* - input must fit into 112 bits
*/
function toInt112(int256 value) internal pure returns (int112 downcasted) {
downcasted = int112(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(112, value);
}
}
/**
* @dev Returns the downcasted int104 from int256, reverting on
* overflow (when the input is less than smallest int104 or
* greater than largest int104).
*
* Counterpart to Solidity's `int104` operator.
*
* Requirements:
*
* - input must fit into 104 bits
*/
function toInt104(int256 value) internal pure returns (int104 downcasted) {
downcasted = int104(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(104, value);
}
}
/**
* @dev Returns the downcasted int96 from int256, reverting on
* overflow (when the input is less than smallest int96 or
* greater than largest int96).
*
* Counterpart to Solidity's `int96` operator.
*
* Requirements:
*
* - input must fit into 96 bits
*/
function toInt96(int256 value) internal pure returns (int96 downcasted) {
downcasted = int96(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(96, value);
}
}
/**
* @dev Returns the downcasted int88 from int256, reverting on
* overflow (when the input is less than smallest int88 or
* greater than largest int88).
*
* Counterpart to Solidity's `int88` operator.
*
* Requirements:
*
* - input must fit into 88 bits
*/
function toInt88(int256 value) internal pure returns (int88 downcasted) {
downcasted = int88(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(88, value);
}
}
/**
* @dev Returns the downcasted int80 from int256, reverting on
* overflow (when the input is less than smallest int80 or
* greater than largest int80).
*
* Counterpart to Solidity's `int80` operator.
*
* Requirements:
*
* - input must fit into 80 bits
*/
function toInt80(int256 value) internal pure returns (int80 downcasted) {
downcasted = int80(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(80, value);
}
}
/**
* @dev Returns the downcasted int72 from int256, reverting on
* overflow (when the input is less than smallest int72 or
* greater than largest int72).
*
* Counterpart to Solidity's `int72` operator.
*
* Requirements:
*
* - input must fit into 72 bits
*/
function toInt72(int256 value) internal pure returns (int72 downcasted) {
downcasted = int72(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(72, value);
}
}
/**
* @dev Returns the downcasted int64 from int256, reverting on
* overflow (when the input is less than smallest int64 or
* greater than largest int64).
*
* Counterpart to Solidity's `int64` operator.
*
* Requirements:
*
* - input must fit into 64 bits
*/
function toInt64(int256 value) internal pure returns (int64 downcasted) {
downcasted = int64(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(64, value);
}
}
/**
* @dev Returns the downcasted int56 from int256, reverting on
* overflow (when the input is less than smallest int56 or
* greater than largest int56).
*
* Counterpart to Solidity's `int56` operator.
*
* Requirements:
*
* - input must fit into 56 bits
*/
function toInt56(int256 value) internal pure returns (int56 downcasted) {
downcasted = int56(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(56, value);
}
}
/**
* @dev Returns the downcasted int48 from int256, reverting on
* overflow (when the input is less than smallest int48 or
* greater than largest int48).
*
* Counterpart to Solidity's `int48` operator.
*
* Requirements:
*
* - input must fit into 48 bits
*/
function toInt48(int256 value) internal pure returns (int48 downcasted) {
downcasted = int48(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(48, value);
}
}
/**
* @dev Returns the downcasted int40 from int256, reverting on
* overflow (when the input is less than smallest int40 or
* greater than largest int40).
*
* Counterpart to Solidity's `int40` operator.
*
* Requirements:
*
* - input must fit into 40 bits
*/
function toInt40(int256 value) internal pure returns (int40 downcasted) {
downcasted = int40(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(40, value);
}
}
/**
* @dev Returns the downcasted int32 from int256, reverting on
* overflow (when the input is less than smallest int32 or
* greater than largest int32).
*
* Counterpart to Solidity's `int32` operator.
*
* Requirements:
*
* - input must fit into 32 bits
*/
function toInt32(int256 value) internal pure returns (int32 downcasted) {
downcasted = int32(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(32, value);
}
}
/**
* @dev Returns the downcasted int24 from int256, reverting on
* overflow (when the input is less than smallest int24 or
* greater than largest int24).
*
* Counterpart to Solidity's `int24` operator.
*
* Requirements:
*
* - input must fit into 24 bits
*/
function toInt24(int256 value) internal pure returns (int24 downcasted) {
downcasted = int24(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(24, value);
}
}
/**
* @dev Returns the downcasted int16 from int256, reverting on
* overflow (when the input is less than smallest int16 or
* greater than largest int16).
*
* Counterpart to Solidity's `int16` operator.
*
* Requirements:
*
* - input must fit into 16 bits
*/
function toInt16(int256 value) internal pure returns (int16 downcasted) {
downcasted = int16(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(16, value);
}
}
/**
* @dev Returns the downcasted int8 from int256, reverting on
* overflow (when the input is less than smallest int8 or
* greater than largest int8).
*
* Counterpart to Solidity's `int8` operator.
*
* Requirements:
*
* - input must fit into 8 bits
*/
function toInt8(int256 value) internal pure returns (int8 downcasted) {
downcasted = int8(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(8, value);
}
}
/**
* @dev Converts an unsigned uint256 into a signed int256.
*
* Requirements:
*
* - input must be less than or equal to maxInt256.
*/
function toInt256(uint256 value) internal pure returns (int256) {
// Note: Unsafe cast below is okay because `type(int256).max` is guaranteed to be positive
if (value > uint256(type(int256).max)) {
revert SafeCastOverflowedUintToInt(value);
}
return int256(value);
}
/**
* @dev Cast a boolean (false or true) to a uint256 (0 or 1) with no jump.
*/
function toUint(bool b) internal pure returns (uint256 u) {
assembly ("memory-safe") {
u := iszero(iszero(b))
}
}
}{
"remappings": [
"erc4626-tests/=dependencies/erc4626-tests-232ff9b/",
"forge-std/=dependencies/forge-std-1.9.6/src/",
"metamorpho/=dependencies/metamorpho-bcd05f8/",
"morpho-blue/=dependencies/morpho-blue-8ae3d84/",
"openzeppelin-contracts/=dependencies/@openzeppelin-contracts-5.2.0/",
"halmos-cheatcodes/=dependencies/halmos-cheatcodes-0.2.6/src/",
"@openzeppelin-contracts-5.2.0/=dependencies/@openzeppelin-contracts-5.2.0/",
"@openzeppelin/contracts/=dependencies/metamorpho-bcd05f8/lib/openzeppelin-contracts/contracts/",
"ds-test/=dependencies/morpho-blue-8ae3d84/lib/forge-std/lib/ds-test/src/",
"erc4626-tests-232ff9b/=dependencies/erc4626-tests-232ff9b/",
"forge-std-1.9.6/=dependencies/forge-std-1.9.6/src/",
"halmos-cheatcodes-0.2.6/=dependencies/halmos-cheatcodes-0.2.6/src/",
"metamorpho-bcd05f8/=dependencies/metamorpho-bcd05f8/",
"morpho-blue-8ae3d84/=dependencies/morpho-blue-8ae3d84/",
"morpho-blue-irm/=dependencies/metamorpho-bcd05f8/lib/morpho-blue-irm/src/",
"solmate/=dependencies/metamorpho-bcd05f8/lib/morpho-blue-irm/lib/solmate/src/"
],
"optimizer": {
"enabled": true,
"runs": 1000
},
"metadata": {
"useLiteralContent": false,
"bytecodeHash": "ipfs",
"appendCBOR": true
},
"outputSelection": {
"*": {
"*": [
"evm.bytecode",
"evm.deployedBytecode",
"devdoc",
"userdoc",
"metadata",
"abi"
]
}
},
"evmVersion": "cancun",
"viaIR": false
}Contract Security Audit
- No Contract Security Audit Submitted- Submit Audit Here
Contract ABI
API[{"inputs":[{"internalType":"address","name":"artist_","type":"address"},{"internalType":"address","name":"paymentToken","type":"address"},{"internalType":"uint256","name":"mintPrice","type":"uint256"}],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[],"name":"AddressZero","type":"error"},{"inputs":[{"internalType":"address","name":"sender","type":"address"},{"internalType":"uint256","name":"balance","type":"uint256"},{"internalType":"uint256","name":"needed","type":"uint256"},{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"ERC1155InsufficientBalance","type":"error"},{"inputs":[{"internalType":"address","name":"approver","type":"address"}],"name":"ERC1155InvalidApprover","type":"error"},{"inputs":[{"internalType":"uint256","name":"idsLength","type":"uint256"},{"internalType":"uint256","name":"valuesLength","type":"uint256"}],"name":"ERC1155InvalidArrayLength","type":"error"},{"inputs":[{"internalType":"address","name":"operator","type":"address"}],"name":"ERC1155InvalidOperator","type":"error"},{"inputs":[{"internalType":"address","name":"receiver","type":"address"}],"name":"ERC1155InvalidReceiver","type":"error"},{"inputs":[{"internalType":"address","name":"sender","type":"address"}],"name":"ERC1155InvalidSender","type":"error"},{"inputs":[{"internalType":"address","name":"operator","type":"address"},{"internalType":"address","name":"owner","type":"address"}],"name":"ERC1155MissingApprovalForAll","type":"error"},{"inputs":[],"name":"ExcessiveSharesRedeemed","type":"error"},{"inputs":[],"name":"InsufficientBalance","type":"error"},{"inputs":[],"name":"InsufficientPrincipal","type":"error"},{"inputs":[],"name":"InsufficientSharesReceived","type":"error"},{"inputs":[],"name":"InvalidInitialization","type":"error"},{"inputs":[],"name":"MetadataUriImmutable","type":"error"},{"inputs":[],"name":"NotInitializing","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":"ProtectedToken","type":"error"},{"inputs":[],"name":"ReentrancyGuardReentrantCall","type":"error"},{"inputs":[{"internalType":"address","name":"token","type":"address"}],"name":"SafeERC20FailedOperation","type":"error"},{"inputs":[],"name":"SameVault","type":"error"},{"inputs":[],"name":"Unauthorized","type":"error"},{"inputs":[],"name":"VaultIncompatible","type":"error"},{"inputs":[],"name":"VaultNeverUsed","type":"error"},{"inputs":[],"name":"VaultNotApproved","type":"error"},{"inputs":[],"name":"WithdrawalFailed","type":"error"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":true,"internalType":"address","name":"operator","type":"address"},{"indexed":false,"internalType":"bool","name":"approved","type":"bool"}],"name":"ApprovalForAll","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":false,"internalType":"uint256","name":"tokensBurned","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"withdrawal","type":"uint256"},{"indexed":false,"internalType":"address","name":"vault","type":"address"},{"indexed":false,"internalType":"uint256","name":"sharesRedeemed","type":"uint256"}],"name":"BurnAndWithdraw","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"factory","type":"address"},{"indexed":true,"internalType":"address","name":"paymentToken","type":"address"},{"indexed":false,"internalType":"address","name":"owner","type":"address"},{"indexed":false,"internalType":"uint256","name":"mintPrice","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"Deployed","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":false,"internalType":"uint256","name":"tokensMinted","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"deposit","type":"uint256"},{"indexed":false,"internalType":"address","name":"vault","type":"address"},{"indexed":false,"internalType":"uint256","name":"sharesReceived","type":"uint256"}],"name":"DepositAndMint","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint64","name":"version","type":"uint64"}],"name":"Initialized","type":"event"},{"anonymous":false,"inputs":[],"name":"MetadataUriLocked","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"fromVault","type":"address"},{"indexed":true,"internalType":"address","name":"toVault","type":"address"},{"indexed":false,"internalType":"uint256","name":"assetsTransferred","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"oldVaultSharesRedeemed","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"newVaultSharesReceived","type":"uint256"}],"name":"MigrateDeposits","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"previousOwner","type":"address"},{"indexed":true,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnershipTransferStarted","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":"address","name":"operator","type":"address"},{"indexed":true,"internalType":"address","name":"from","type":"address"},{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":false,"internalType":"uint256[]","name":"ids","type":"uint256[]"},{"indexed":false,"internalType":"uint256[]","name":"values","type":"uint256[]"}],"name":"TransferBatch","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"operator","type":"address"},{"indexed":true,"internalType":"address","name":"from","type":"address"},{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":false,"internalType":"uint256","name":"id","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"value","type":"uint256"}],"name":"TransferSingle","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"string","name":"value","type":"string"},{"indexed":true,"internalType":"uint256","name":"id","type":"uint256"}],"name":"URI","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":false,"internalType":"uint256","name":"withdrawal","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"sharesRedeemed","type":"uint256"}],"name":"WithdrawInterest","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"receiver","type":"address"},{"indexed":false,"internalType":"address","name":"token","type":"address"},{"indexed":false,"internalType":"uint256","name":"tokenId","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"WithdrawnERC1155","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"receiver","type":"address"},{"indexed":false,"internalType":"address","name":"token","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"WithdrawnERC20","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"receiver","type":"address"},{"indexed":false,"internalType":"address","name":"token","type":"address"},{"indexed":false,"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"WithdrawnERC721","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"receiver","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"WithdrawnETH","type":"event"},{"inputs":[],"name":"FACTORY","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"MINT_PRICE","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"PAYMENT_TOKEN","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"TOKEN_ID","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"acceptOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"artist","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"},{"internalType":"uint256","name":"id","type":"uint256"}],"name":"balanceOf","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address[]","name":"accounts","type":"address[]"},{"internalType":"uint256[]","name":"ids","type":"uint256[]"}],"name":"balanceOfBatch","outputs":[{"internalType":"uint256[]","name":"","type":"uint256[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"address","name":"vault_","type":"address"},{"internalType":"uint256","name":"maxSharesRedeemed","type":"uint256"}],"name":"burn","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"oldVault","type":"address"},{"internalType":"uint256","name":"maxSharesRedeemed","type":"uint256"},{"internalType":"uint256","name":"minSharesReceived","type":"uint256"},{"internalType":"uint256","name":"maxAmountToMigrate","type":"uint256"}],"name":"continueMigration","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"vault_","type":"address"}],"name":"getExpectedTotalBalance","outputs":[{"internalType":"uint256","name":"expectedVaultAssets","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getExpectedTotalBalance","outputs":[{"internalType":"uint256","name":"expectedVaultAssets","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getExpectedTotalInterest","outputs":[{"internalType":"uint256","name":"expectedInterest","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"vault_","type":"address"}],"name":"getWithdrawableBalance","outputs":[{"internalType":"uint256","name":"vaultAssets","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getWithdrawableBalance","outputs":[{"internalType":"uint256","name":"vaultAssets","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getWithdrawableInterest","outputs":[{"internalType":"uint256","name":"interest","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"vault_","type":"address"},{"internalType":"string","name":"metadataUri_","type":"string"}],"name":"initialize","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"},{"internalType":"address","name":"operator","type":"address"}],"name":"isApprovedForAll","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"makeUriImmutable","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"metadataUriLocked","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"newVault","type":"address"},{"internalType":"uint256","name":"maxSharesRedeemed","type":"uint256"},{"internalType":"uint256","name":"minSharesReceived","type":"uint256"},{"internalType":"uint256","name":"maxAmountToMigrate","type":"uint256"}],"name":"migrate","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"uint256","name":"minSharesReceived","type":"uint256"}],"name":"mint","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"address","name":"","type":"address"},{"internalType":"uint256[]","name":"","type":"uint256[]"},{"internalType":"uint256[]","name":"","type":"uint256[]"},{"internalType":"bytes","name":"","type":"bytes"}],"name":"onERC1155BatchReceived","outputs":[{"internalType":"bytes4","name":"","type":"bytes4"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"address","name":"","type":"address"},{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"bytes","name":"","type":"bytes"}],"name":"onERC1155Received","outputs":[{"internalType":"bytes4","name":"","type":"bytes4"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"address","name":"","type":"address"},{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"bytes","name":"","type":"bytes"}],"name":"onERC721Received","outputs":[{"internalType":"bytes4","name":"","type":"bytes4"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"pendingOwner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"principalDeposit","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"from","type":"address"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256[]","name":"ids","type":"uint256[]"},{"internalType":"uint256[]","name":"values","type":"uint256[]"},{"internalType":"bytes","name":"data","type":"bytes"}],"name":"safeBatchTransferFrom","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"from","type":"address"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"id","type":"uint256"},{"internalType":"uint256","name":"value","type":"uint256"},{"internalType":"bytes","name":"data","type":"bytes"}],"name":"safeTransferFrom","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"operator","type":"address"},{"internalType":"bool","name":"approved","type":"bool"}],"name":"setApprovalForAll","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"string","name":"newMetadataUri","type":"string"}],"name":"setMetadataUri","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes4","name":"interfaceId","type":"bytes4"}],"name":"supportsInterface","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"uri","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"vault","outputs":[{"internalType":"contract IERC4626","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"vault","type":"address"}],"name":"wasUsedVault","outputs":[{"internalType":"bool","name":"wasUsed","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"receiver","type":"address"}],"name":"withdraw","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"receiver","type":"address"},{"internalType":"address","name":"token","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"},{"internalType":"bytes","name":"data","type":"bytes"}],"name":"withdrawERC1155","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"receiver","type":"address"},{"internalType":"address","name":"token","type":"address"}],"name":"withdrawERC20","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"receiver","type":"address"},{"internalType":"address","name":"token","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"withdrawERC721","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"interestAmount","type":"uint256"},{"internalType":"uint256","name":"maxSharesRedeemed","type":"uint256"}],"name":"withdrawInterest","outputs":[],"stateMutability":"nonpayable","type":"function"}]Contract Creation Code
0x60e060405234801561000f575f5ffd5b50604051613c4a380380613c4a83398101604081905261002e916101e8565b60408051602081019091525f81528390610047816100e7565b506001600160a01b03811661007557604051631e4fbdf760e01b81525f600482015260240160405180910390fd5b61007e81610150565b503360808190526001600160a01b0383811660a081905260c08490526040805192871683526020830185905260019083015291907fee75a0a1ab7e3c38933495a3673f5a264be8736792dbc28465d3bb3896ca064c9060600160405180910390a35050506103a8565b60085460ff161561010b5760405163450e224f60e11b815260040160405180910390fd5b6101148161016c565b60017f6bb7ff708619ba0610cba295a58592e0451dee2622938c8755667688daf3529b826040516101459190610221565b60405180910390a250565b600480546001600160a01b03191690556101698161017c565b50565b600261017882826102ee565b5050565b600380546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0905f90a35050565b80516001600160a01b03811681146101e3575f5ffd5b919050565b5f5f5f606084860312156101fa575f5ffd5b610203846101cd565b9250610211602085016101cd565b9150604084015190509250925092565b602081525f82518060208401528060208501604085015e5f604082850101526040601f19601f83011684010191505092915050565b634e487b7160e01b5f52604160045260245ffd5b600181811c9082168061027e57607f821691505b60208210810361029c57634e487b7160e01b5f52602260045260245ffd5b50919050565b601f8211156102e957805f5260205f20601f840160051c810160208510156102c75750805b601f840160051c820191505b818110156102e6575f81556001016102d3565b50505b505050565b81516001600160401b0381111561030757610307610256565b61031b81610315845461026a565b846102a2565b6020601f82116001811461034d575f83156103365750848201515b5f19600385901b1c1916600184901b1784556102e6565b5f84815260208120601f198516915b8281101561037c578785015182556020948501946001909201910161035c565b508482101561039957868401515f19600387901b60f8161c191681555b50505050600190811b01905550565b60805160a05160c0516138326104185f395f818161059501528181611d50015261234601525f81816104e2015281816113050152818161195c01528181611b5e01528181611d9a015261254301525f818161040f015281816112210152818161127d01526118d401526138325ff3fe608060405234801561000f575f5ffd5b50600436106102d7575f3560e01c8063843592d311610187578063d0c797e0116100dd578063f23a6e6111610093578063f399e22e1161006e578063f399e22e1461066c578063fbfa77cf1461067f578063fe61617b14610692575f5ffd5b8063f23a6e6114610627578063f242432a14610646578063f2fde38b14610659575f5ffd5b8063e30c3978116100c3578063e30c3978146105c8578063e985e9c5146105d9578063ee42427814610614575f5ffd5b8063d0c797e0146105b7578063df87f50d146105bf575f5ffd5b80639456fbcc1161013d578063bc197c8111610118578063bc197c8114610569578063be788e7014610588578063c002d23d14610590575f5ffd5b80639456fbcc14610530578063a22cb46514610543578063aae085bc14610556575f5ffd5b806389a890021161016d57806389a89002146105045780638da5cb5b1461050c5780638f22b90f1461051d575f5ffd5b8063843592d3146104ca578063877c86fb146104dd575f5ffd5b806327b09ed51161023c57806343bc1612116101f2578063715018a6116101cd578063715018a6146104b257806379ba5097146104ba57806380c13e91146104c2575f5ffd5b806343bc1612146104775780634e1273f41461047f57806351cff8d91461049f575f5ffd5b80632eb2c2d6116102225780632eb2c2d6146104495780632ee3d2d61461045c5780634025feb214610464575f5ffd5b806327b09ed5146103f75780632dd310001461040a575f5ffd5b80631130630c11610291578063150b7a0211610277578063150b7a0214610387578063156e29f6146103d75780631791ec53146103ea575f5ffd5b80631130630c1461036c578063136a92b41461037f575f5ffd5b806305149ba4116102c157806305149ba4146103245780630576d8e9146103395780630e89341c1461034c575f5ffd5b8062fdd58e146102db57806301ffc9a714610301575b5f5ffd5b6102ee6102e9366004612d98565b6106b4565b6040519081526020015b60405180910390f35b61031461030f366004612dd7565b6106db565b60405190151581526020016102f8565b610337610332366004612e37565b610703565b005b610337610347366004612ea5565b6107ac565b61035f61035a366004612edd565b6107e4565b6040516102f89190612f22565b61033761037a366004612f34565b610876565b6102ee6108d0565b6103be610395366004613024565b7f150b7a0200000000000000000000000000000000000000000000000000000000949350505050565b6040516001600160e01b031990911681526020016102f8565b6103376103e536600461308c565b610900565b6008546103149060ff1681565b6102ee6104053660046130be565b610920565b6104317f000000000000000000000000000000000000000000000000000000000000000081565b6040516001600160a01b0390911681526020016102f8565b610337610457366004613166565b610a14565b6102ee610a96565b610337610472366004613219565b610ab2565b610431610c2d565b61049261048d366004613257565b610c40565b6040516102f89190613356565b6103376104ad3660046130be565b610d0b565b610337610e20565b610337610e33565b6102ee610e77565b6102ee6104d83660046130be565b610e81565b6104317f000000000000000000000000000000000000000000000000000000000000000081565b6102ee600181565b6003546001600160a01b0316610431565b61033761052b36600461308c565b610ee9565b61033761053e366004613368565b610f04565b6103376105513660046133ac565b610f9d565b6103376105643660046133d8565b610fa8565b6103be610577366004613166565b63bc197c8160e01b95945050505050565b6102ee610fbc565b6102ee7f000000000000000000000000000000000000000000000000000000000000000081565b610337610fd3565b6102ee60075481565b6004546001600160a01b0316610431565b6103146105e7366004613368565b6001600160a01b039182165f90815260016020908152604080832093909416825291909152205460ff1690565b610337610622366004612ea5565b611020565b6103be61063536600461341d565b63f23a6e6160e01b95945050505050565b61033761065436600461341d565b611049565b6103376106673660046130be565b6110c6565b61033761067a366004613475565b611137565b600554610431906001600160a01b031681565b6103146106a03660046130be565b60066020525f908152604090205460ff1681565b5f818152602081815260408083206001600160a01b03861684529091529020545b92915050565b5f6106e5826114c3565b806106f457506106f48261155d565b806106d557506106d58261155d565b61070b611567565b610727576040516282b42960e81b815260040160405180910390fd5b604051627eeac760e11b8152306004820152602481018490525f906001600160a01b0386169062fdd58e90604401602060405180830381865afa158015610770573d5f5f3e3d5ffd5b505050506040513d601f19601f8201168201806040525081019061079491906134c6565b90506107a4868686848787611593565b505050505050565b6107b461177f565b6107bc6117ac565b6005546107d69085906001600160a01b0316858585611832565b6107de611c9d565b50505050565b6060600280546107f3906134dd565b80601f016020809104026020016040519081016040528092919081815260200182805461081f906134dd565b801561086a5780601f106108415761010080835404028352916020019161086a565b820191905f5260205f20905b81548152906001019060200180831161084d57829003601f168201915b50505050509050919050565b61087e61177f565b6108866117ac565b6108c482828080601f0160208091040260200160405190810160405280939291908181526020018383808284375f92019190915250611cc792505050565b6108cc611c9d565b5050565b5f5f6108da610a96565b90506007548110156108ed575f91505090565b6007546108fa9082613529565b91505090565b6109086117ac565b610913838383611d49565b61091b611c9d565b505050565b6040516370a0823160e01b81523060048201525f9081906001600160a01b038416906370a0823190602401602060405180830381865afa158015610966573d5f5f3e3d5ffd5b505050506040513d601f19601f8201168201806040525081019061098a91906134c6565b6040517f4cdad506000000000000000000000000000000000000000000000000000000008152600481018290529091506001600160a01b03841690634cdad50690602401602060405180830381865afa1580156109e9573d5f5f3e3d5ffd5b505050506040513d601f19601f82011682018060405250810190610a0d91906134c6565b9392505050565b336001600160a01b0386168114801590610a5357506001600160a01b038087165f9081526001602090815260408083209385168352929052205460ff16155b15610a895760405163711bec9160e11b81526001600160a01b038083166004830152871660248201526044015b60405180910390fd5b6107a48686868686611ef0565b6005545f90610aad906001600160a01b0316610920565b905090565b610aba611567565b610ad6576040516282b42960e81b815260040160405180910390fd5b6001600160a01b038316610afd57604051639fabe1c160e01b815260040160405180910390fd5b6001600160a01b038216610b2457604051639fabe1c160e01b815260040160405180910390fd5b6001600160a01b0382165f9081526006602052604090205460ff1615610b5d5760405163093e1cdb60e01b815260040160405180910390fd5b604080516001600160a01b038086168252841660208201529081018290527f5b917925bb22ff9e97a81b93b142d472716ae03595d90b9c9aff99456b7fb9f99060600160405180910390a16040517f42842e0e0000000000000000000000000000000000000000000000000000000081523060048201526001600160a01b038481166024830152604482018390528391908216906342842e0e906064015f604051808303815f87803b158015610c11575f5ffd5b505af1158015610c23573d5f5f3e3d5ffd5b5050505050505050565b5f610aad6003546001600160a01b031690565b60608151835114610c715781518351604051635b05999160e01b815260048101929092526024820152604401610a80565b5f835167ffffffffffffffff811115610c8c57610c8c612f73565b604051908082528060200260200182016040528015610cb5578160200160208202803683370190505b5090505f5b8451811015610d0357602080820286010151610cde906020808402870101516106b4565b828281518110610cf057610cf061353c565b6020908102919091010152600101610cba565b509392505050565b610d13611567565b610d2f576040516282b42960e81b815260040160405180910390fd5b6001600160a01b038116610d5657604051639fabe1c160e01b815260040160405180910390fd5b604080516001600160a01b03831681524760208201527f5817fe91d2748c33f168d8a78037fc073adaf6ec8e3613a758d44a2cfae4563d910160405180910390a15f816001600160a01b0316476040515f6040518083038185875af1925050503d805f8114610de0576040519150601f19603f3d011682016040523d82523d5f602084013e610de5565b606091505b50509050806108cc576040517f27fcd9d100000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b610e2861177f565b610e315f611f55565b565b60045433906001600160a01b03168114610e6b5760405163118cdaa760e01b81526001600160a01b0382166004820152602401610a80565b610e7481611f55565b50565b5f5f6108da610fbc565b60405163ce96cb7760e01b81523060048201525f906001600160a01b0383169063ce96cb7790602401602060405180830381865afa158015610ec5573d5f5f3e3d5ffd5b505050506040513d601f19601f820116820180604052508101906106d591906134c6565b610ef161177f565b610ef96117ac565b610913838383611f6e565b610f0c611567565b610f28576040516282b42960e81b815260040160405180910390fd5b6040516370a0823160e01b81523060048201525f906001600160a01b038316906370a0823190602401602060405180830381865afa158015610f6c573d5f5f3e3d5ffd5b505050506040513d601f19601f82011682018060405250810190610f9091906134c6565b905061091b83838361207f565b6108cc3383836121ee565b610fb06117ac565b6107d68484848461229c565b6005545f90610aad906001600160a01b0316610e81565b610fdb61177f565b610fe36117ac565b6008805460ff191660011790556040517f3c3e8aa6d479534e8e372d558c5af1c88715e2b7afaf11052b26bd0da3e47f5a905f90a1610e31611c9d565b61102861177f565b6110306117ac565b6005546107d6906001600160a01b031685858585611832565b336001600160a01b038616811480159061108857506001600160a01b038087165f9081526001602090815260408083209385168352929052205460ff16155b156110b95760405163711bec9160e11b81526001600160a01b03808316600483015287166024820152604401610a80565b6107a486868686866124aa565b6110ce61177f565b600480546001600160a01b0383166001600160a01b031990911681179091556110ff6003546001600160a01b031690565b6001600160a01b03167f38d16b8cac22d99fc7c124b9cd0de2d3fa1faef420bfe791d8c362d765e2270060405160405180910390a350565b7ff0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a00805468010000000000000000810460ff16159067ffffffffffffffff165f811580156111815750825b90505f8267ffffffffffffffff16600114801561119d5750303b155b9050811580156111ab575080155b156111e2576040517ff92ee8a900000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b845467ffffffffffffffff19166001178555831561121657845468ff00000000000000001916680100000000000000001785555b336001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000161461125e576040516282b42960e81b815260040160405180910390fd5b60405163df78a62560e01b81526001600160a01b0389811660048301527f0000000000000000000000000000000000000000000000000000000000000000169063df78a62590602401602060405180830381865afa1580156112c2573d5f5f3e3d5ffd5b505050506040513d601f19601f820116820180604052508101906112e69190613550565b6113035760405163135c860560e01b815260040160405180910390fd5b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316886001600160a01b03166338d52e0f6040518163ffffffff1660e01b8152600401602060405180830381865afa158015611369573d5f5f3e3d5ffd5b505050506040513d601f19601f8201168201806040525081019061138d919061356b565b6001600160a01b0316146113b45760405163ca6117c560e01b815260040160405180910390fd5b6113f287878080601f0160208091040260200160405190810160405280939291908181526020018383808284375f92019190915250611cc792505050565b6001600160a01b0388165f818152600660209081526040808320805460ff19166001179055600580546001600160a01b03191685179055805183815291820183905281018290527f4c024dd11ca48373811b395158318a8a78991d69dc1a2d10ef5e38229224e92b9060600160405180910390a361146f88612536565b8315610c2357845468ff000000000000000019168555604051600181527fc7f505b2f371ae2175ee4913f4499e1f2633a7b5936321eed1cdaeb6115181d29060200160405180910390a15050505050505050565b5f6001600160e01b031982167fd9b67a2600000000000000000000000000000000000000000000000000000000148061152557506001600160e01b031982167f0e89341c00000000000000000000000000000000000000000000000000000000145b806106d557507f01ffc9a7000000000000000000000000000000000000000000000000000000006001600160e01b03198316146106d5565b5f6106d58261256b565b5f61157a6003546001600160a01b031690565b6001600160a01b0316336001600160a01b031614905090565b6001600160a01b0386166115ba57604051639fabe1c160e01b815260040160405180910390fd5b6001600160a01b0385166115e157604051639fabe1c160e01b815260040160405180910390fd5b6001600160a01b0385165f9081526006602052604090205460ff161561161a5760405163093e1cdb60e01b815260040160405180910390fd5b604051627eeac760e11b815230600482015260248101859052859084906001600160a01b0383169062fdd58e90604401602060405180830381865afa158015611665573d5f5f3e3d5ffd5b505050506040513d601f19601f8201168201806040525081019061168991906134c6565b10156116a857604051631e9acf1760e31b815260040160405180910390fd5b604080516001600160a01b03808a16825288166020820152908101869052606081018590527f47613189d8ac063d8106d0cbe9e94996721c3109e0ed2b8fb9a2d54fdaf32e2d9060800160405180910390a16040517ff242432a0000000000000000000000000000000000000000000000000000000081526001600160a01b0382169063f242432a906117499030908b908a908a908a908a90600401613586565b5f604051808303815f87803b158015611760575f5ffd5b505af1158015611772573d5f5f3e3d5ffd5b5050505050505050505050565b6003546001600160a01b03163314610e315760405163118cdaa760e01b8152336004820152602401610a80565b7f9b779b17422d0df92223018b32b4d1fa46e071723d6817e2486d003becc55f005c15611805576040517f3ee5aeb500000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b610e3160017f9b779b17422d0df92223018b32b4d1fa46e071723d6817e2486d003becc55f005b906125a8565b836001600160a01b0316856001600160a01b03160361187d576040517ff4d1987f00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6001600160a01b0385165f9081526006602052604090205460ff166118b5576040516305c9c98760e01b815260040160405180910390fd5b60405163df78a62560e01b81526001600160a01b0385811660048301527f0000000000000000000000000000000000000000000000000000000000000000169063df78a62590602401602060405180830381865afa158015611919573d5f5f3e3d5ffd5b505050506040513d601f19601f8201168201806040525081019061193d9190613550565b61195a5760405163135c860560e01b815260040160405180910390fd5b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316846001600160a01b03166338d52e0f6040518163ffffffff1660e01b8152600401602060405180830381865afa1580156119c0573d5f5f3e3d5ffd5b505050506040513d601f19601f820116820180604052508101906119e4919061356b565b6001600160a01b031614611a0b5760405163ca6117c560e01b815260040160405180910390fd5b6001600160a01b038481165f81815260066020526040808220805460ff19166001179055600580546001600160a01b031916909317909255905163ce96cb7760e01b8152306004820152909187169063ce96cb7790602401602060405180830381865afa158015611a7e573d5f5f3e3d5ffd5b505050506040513d601f19601f82011682018060405250810190611aa291906134c6565b90505f828211611ab25781611ab4565b825b604051632d182be560e21b815260048101829052306024820181905260448201529091505f906001600160a01b0389169063b460af94906064016020604051808303815f875af1158015611b0a573d5f5f3e3d5ffd5b505050506040513d601f19601f82011682018060405250810190611b2e91906134c6565b905085811115611b5157604051638937604760e01b815260040160405180910390fd5b611b856001600160a01b037f000000000000000000000000000000000000000000000000000000000000000016895f6125af565b611b8e87612536565b604051636e553f6560e01b8152600481018390523060248201525f906001600160a01b03891690636e553f65906044016020604051808303815f875af1158015611bda573d5f5f3e3d5ffd5b505050506040513d601f19601f82011682018060405250810190611bfe91906134c6565b9050805f03611c205760405163ded0dce560e01b815260040160405180910390fd5b85811015611c415760405163ded0dce560e01b815260040160405180910390fd5b60408051848152602081018490529081018290526001600160a01b03808a1691908b16907f4c024dd11ca48373811b395158318a8a78991d69dc1a2d10ef5e38229224e92b9060600160405180910390a3505050505050505050565b610e315f7f9b779b17422d0df92223018b32b4d1fa46e071723d6817e2486d003becc55f0061182c565b60085460ff1615611d04576040517f8a1c449e00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b611d0d816126af565b60017f6bb7ff708619ba0610cba295a58592e0451dee2622938c8755667688daf3529b82604051611d3e9190612f22565b60405180910390a250565b5f611d74837f00000000000000000000000000000000000000000000000000000000000000006135e2565b90508060075f828254611d8791906135f9565b90915550611dc290506001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000163330846126bb565b600554604051636e553f6560e01b8152600481018390523060248201525f916001600160a01b031690636e553f65906044016020604051808303815f875af1158015611e10573d5f5f3e3d5ffd5b505050506040513d601f19601f82011682018060405250810190611e3491906134c6565b9050805f03611e565760405163ded0dce560e01b815260040160405180910390fd5b82811015611e775760405163ded0dce560e01b815260040160405180910390fd5b611e928560018660405180602001604052805f8152506126f4565b60055460408051868152602081018590526001600160a01b0392831681830152606081018490529051918716917f3814c54f05c4e44d9082928a6fbb1a4fce70bfdd38cfaab9fa84e2cdb3d7fcbe9181900360800190a25050505050565b6001600160a01b038416611f1957604051632bfa23e760e11b81525f6004820152602401610a80565b6001600160a01b038516611f4157604051626a0d4560e21b81525f6004820152602401610a80565b611f4e858585858561274b565b5050505050565b600480546001600160a01b0319169055610e748161279e565b600554604051632d182be560e21b8152600481018490526001600160a01b0385811660248301523060448301525f92169063b460af94906064016020604051808303815f875af1158015611fc4573d5f5f3e3d5ffd5b505050506040513d601f19601f82011682018060405250810190611fe891906134c6565b90508181111561200b57604051638937604760e01b815260040160405180910390fd5b600754612016610fbc565b10156120355760405163d24a69a560e01b815260040160405180910390fd5b60408051848152602081018390526001600160a01b038616917f311c0edd26c5d78e8109d3d9731d5916b3cc0114c05d5d2cef337e67c2305ced910160405180910390a250505050565b6001600160a01b0383166120a657604051639fabe1c160e01b815260040160405180910390fd5b6001600160a01b0382166120cd57604051639fabe1c160e01b815260040160405180910390fd5b6001600160a01b0382165f9081526006602052604090205460ff16156121065760405163093e1cdb60e01b815260040160405180910390fd5b6040516370a0823160e01b8152306004820152829082906001600160a01b038316906370a0823190602401602060405180830381865afa15801561214c573d5f5f3e3d5ffd5b505050506040513d601f19601f8201168201806040525081019061217091906134c6565b101561218f57604051631e9acf1760e31b815260040160405180910390fd5b604080516001600160a01b038087168252851660208201529081018390527f31e3f58fbb760a4c31ae5c6416229fca813390b5fa0de533ee4cef14b2b344db9060600160405180910390a16107de6001600160a01b03821685846127ef565b6001600160a01b038216612230576040517fced3e1000000000000000000000000000000000000000000000000000000000081525f6004820152602401610a80565b6001600160a01b038381165f81815260016020908152604080832094871680845294825291829020805460ff191686151590811790915591519182527f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c31910160405180910390a3505050565b6001600160a01b03841633148015906122d857506001600160a01b0384165f90815260016020908152604080832033845290915290205460ff16155b156123075760405163711bec9160e11b81523360048201526001600160a01b0385166024820152604401610a80565b6001600160a01b0382165f9081526006602052604090205460ff1661233f576040516305c9c98760e01b815260040160405180910390fd5b5f61236a847f00000000000000000000000000000000000000000000000000000000000000006135e2565b905060075481111561238f5760405163d24a69a560e01b815260040160405180910390fd5b8060075f8282546123a09190613529565b909155506123b2905085600186612820565b604051632d182be560e21b8152600481018290526001600160a01b0386811660248301523060448301525f919085169063b460af94906064016020604051808303815f875af1158015612407573d5f5f3e3d5ffd5b505050506040513d601f19601f8201168201806040525081019061242b91906134c6565b90508281111561244e57604051638937604760e01b815260040160405180910390fd5b60408051868152602081018490526001600160a01b0386811682840152606082018490529151918816917fc4870f180a23dec674d5dbbea9de7abefeb08f2ed7e4cad9b7bb3b9942b4de699181900360800190a2505050505050565b6001600160a01b0384166124d357604051632bfa23e760e11b81525f6004820152602401610a80565b6001600160a01b0385166124fb57604051626a0d4560e21b81525f6004820152602401610a80565b6040805160018082526020820186905281830190815260608201859052608082019092529061252d878784848761274b565b50505050505050565b610e746001600160a01b037f000000000000000000000000000000000000000000000000000000000000000016825f196125af565b5f6001600160e01b031982167f4e2312e00000000000000000000000000000000000000000000000000000000014806106d557506106d5826114c3565b80825d5050565b604080516001600160a01b038416602482015260448082018490528251808303909101815260649091019091526020810180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167f095ea7b30000000000000000000000000000000000000000000000000000000017905261262e8482612886565b6107de576040516001600160a01b0384811660248301525f60448301526126a591869182169063095ea7b3906064015b604051602081830303815290604052915060e01b6020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff83818316178352505050506128cf565b6107de84826128cf565b60026108cc8282613650565b6040516001600160a01b0384811660248301528381166044830152606482018390526107de9186918216906323b872dd9060840161265e565b6001600160a01b03841661271d57604051632bfa23e760e11b81525f6004820152602401610a80565b604080516001808252602082018690528183019081526060820185905260808201909252906107a45f878484875b61275785858585612954565b6001600160a01b03841615611f4e57825133906001036127905760208481015190840151612789838989858589612b7c565b50506107a4565b6107a4818787878787612c9d565b600380546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0905f90a35050565b6040516001600160a01b0383811660248301526044820183905261091b91859182169063a9059cbb9060640161265e565b6001600160a01b03831661284857604051626a0d4560e21b81525f6004820152602401610a80565b604080516001808252602082018590528183019081526060820184905260a082019092525f60808201818152919291611f4e9187918590859061274b565b5f5f5f5f60205f8651602088015f8a5af192503d91505f5190508280156128c5575081156128b757806001146128c5565b5f866001600160a01b03163b115b9695505050505050565b5f5f60205f8451602086015f885af1806128ee576040513d5f823e3d81fd5b50505f513d91508115612905578060011415612912565b6001600160a01b0384163b155b156107de576040517f5274afe70000000000000000000000000000000000000000000000000000000081526001600160a01b0385166004820152602401610a80565b80518251146129835781518151604051635b05999160e01b815260048101929092526024820152604401610a80565b335f5b8351811015612a9e576020818102858101820151908501909101516001600160a01b03881615612a50575f828152602081815260408083206001600160a01b038c16845290915290205481811015612a2a576040517f03dee4c50000000000000000000000000000000000000000000000000000000081526001600160a01b038a166004820152602481018290526044810183905260648101849052608401610a80565b5f838152602081815260408083206001600160a01b038d16845290915290209082900390555b6001600160a01b03871615612a94575f828152602081815260408083206001600160a01b038b16845290915281208054839290612a8e9084906135f9565b90915550505b5050600101612986565b508251600103612b1e5760208301515f906020840151909150856001600160a01b0316876001600160a01b0316846001600160a01b03167fc3d58168c5ae7397731d063d5bbf3d657854427343f4c083240f7aacaa2d0f628585604051612b0f929190918252602082015260400190565b60405180910390a45050611f4e565b836001600160a01b0316856001600160a01b0316826001600160a01b03167f4a39dc06d4c0dbc64b70af90fd698a233a518aa5d07e595d983b8c0526c8f7fb8686604051612b6d92919061370b565b60405180910390a45050505050565b6001600160a01b0384163b156107a45760405163f23a6e6160e01b81526001600160a01b0385169063f23a6e6190612bc09089908990889088908890600401613738565b6020604051808303815f875af1925050508015612bfa575060408051601f3d908101601f19168201909252612bf79181019061377f565b60015b612c61573d808015612c27576040519150601f19603f3d011682016040523d82523d5f602084013e612c2c565b606091505b5080515f03612c5957604051632bfa23e760e11b81526001600160a01b0386166004820152602401610a80565b805181602001fd5b6001600160e01b0319811663f23a6e6160e01b1461252d57604051632bfa23e760e11b81526001600160a01b0386166004820152602401610a80565b6001600160a01b0384163b156107a45760405163bc197c8160e01b81526001600160a01b0385169063bc197c8190612ce1908990899088908890889060040161379a565b6020604051808303815f875af1925050508015612d1b575060408051601f3d908101601f19168201909252612d189181019061377f565b60015b612d48573d808015612c27576040519150601f19603f3d011682016040523d82523d5f602084013e612c2c565b6001600160e01b0319811663bc197c8160e01b1461252d57604051632bfa23e760e11b81526001600160a01b0386166004820152602401610a80565b6001600160a01b0381168114610e74575f5ffd5b5f5f60408385031215612da9575f5ffd5b8235612db481612d84565b946020939093013593505050565b6001600160e01b031981168114610e74575f5ffd5b5f60208284031215612de7575f5ffd5b8135610a0d81612dc2565b5f5f83601f840112612e02575f5ffd5b50813567ffffffffffffffff811115612e19575f5ffd5b602083019150836020828501011115612e30575f5ffd5b9250929050565b5f5f5f5f5f60808688031215612e4b575f5ffd5b8535612e5681612d84565b94506020860135612e6681612d84565b935060408601359250606086013567ffffffffffffffff811115612e88575f5ffd5b612e9488828901612df2565b969995985093965092949392505050565b5f5f5f5f60808587031215612eb8575f5ffd5b8435612ec381612d84565b966020860135965060408601359560600135945092505050565b5f60208284031215612eed575f5ffd5b5035919050565b5f81518084528060208401602086015e5f602082860101526020601f19601f83011685010191505092915050565b602081525f610a0d6020830184612ef4565b5f5f60208385031215612f45575f5ffd5b823567ffffffffffffffff811115612f5b575f5ffd5b612f6785828601612df2565b90969095509350505050565b634e487b7160e01b5f52604160045260245ffd5b604051601f8201601f1916810167ffffffffffffffff81118282101715612fb057612fb0612f73565b604052919050565b5f82601f830112612fc7575f5ffd5b813567ffffffffffffffff811115612fe157612fe1612f73565b612ff4601f8201601f1916602001612f87565b818152846020838601011115613008575f5ffd5b816020850160208301375f918101602001919091529392505050565b5f5f5f5f60808587031215613037575f5ffd5b843561304281612d84565b9350602085013561305281612d84565b925060408501359150606085013567ffffffffffffffff811115613074575f5ffd5b61308087828801612fb8565b91505092959194509250565b5f5f5f6060848603121561309e575f5ffd5b83356130a981612d84565b95602085013595506040909401359392505050565b5f602082840312156130ce575f5ffd5b8135610a0d81612d84565b5f67ffffffffffffffff8211156130f2576130f2612f73565b5060051b60200190565b5f82601f83011261310b575f5ffd5b813561311e613119826130d9565b612f87565b8082825260208201915060208360051b86010192508583111561313f575f5ffd5b602085015b8381101561315c578035835260209283019201613144565b5095945050505050565b5f5f5f5f5f60a0868803121561317a575f5ffd5b853561318581612d84565b9450602086013561319581612d84565b9350604086013567ffffffffffffffff8111156131b0575f5ffd5b6131bc888289016130fc565b935050606086013567ffffffffffffffff8111156131d8575f5ffd5b6131e4888289016130fc565b925050608086013567ffffffffffffffff811115613200575f5ffd5b61320c88828901612fb8565b9150509295509295909350565b5f5f5f6060848603121561322b575f5ffd5b833561323681612d84565b9250602084013561324681612d84565b929592945050506040919091013590565b5f5f60408385031215613268575f5ffd5b823567ffffffffffffffff81111561327e575f5ffd5b8301601f8101851361328e575f5ffd5b803561329c613119826130d9565b8082825260208201915060208360051b8501019250878311156132bd575f5ffd5b6020840193505b828410156132e85783356132d781612d84565b8252602093840193909101906132c4565b9450505050602083013567ffffffffffffffff811115613306575f5ffd5b613312858286016130fc565b9150509250929050565b5f8151808452602084019350602083015f5b8281101561334c57815186526020958601959091019060010161332e565b5093949350505050565b602081525f610a0d602083018461331c565b5f5f60408385031215613379575f5ffd5b823561338481612d84565b9150602083013561339481612d84565b809150509250929050565b8015158114610e74575f5ffd5b5f5f604083850312156133bd575f5ffd5b82356133c881612d84565b915060208301356133948161339f565b5f5f5f5f608085870312156133eb575f5ffd5b84356133f681612d84565b935060208501359250604085013561340d81612d84565b9396929550929360600135925050565b5f5f5f5f5f60a08688031215613431575f5ffd5b853561343c81612d84565b9450602086013561344c81612d84565b93506040860135925060608601359150608086013567ffffffffffffffff811115613200575f5ffd5b5f5f5f60408486031215613487575f5ffd5b833561349281612d84565b9250602084013567ffffffffffffffff8111156134ad575f5ffd5b6134b986828701612df2565b9497909650939450505050565b5f602082840312156134d6575f5ffd5b5051919050565b600181811c908216806134f157607f821691505b60208210810361350f57634e487b7160e01b5f52602260045260245ffd5b50919050565b634e487b7160e01b5f52601160045260245ffd5b818103818111156106d5576106d5613515565b634e487b7160e01b5f52603260045260245ffd5b5f60208284031215613560575f5ffd5b8151610a0d8161339f565b5f6020828403121561357b575f5ffd5b8151610a0d81612d84565b6001600160a01b03871681526001600160a01b038616602082015284604082015283606082015260a060808201528160a0820152818360c08301375f81830160c090810191909152601f909201601f1916010195945050505050565b80820281158282048414176106d5576106d5613515565b808201808211156106d5576106d5613515565b601f82111561091b57805f5260205f20601f840160051c810160208510156136315750805b601f840160051c820191505b81811015611f4e575f815560010161363d565b815167ffffffffffffffff81111561366a5761366a612f73565b61367e8161367884546134dd565b8461360c565b6020601f8211600181146136b0575f83156136995750848201515b5f19600385901b1c1916600184901b178455611f4e565b5f84815260208120601f198516915b828110156136df57878501518255602094850194600190920191016136bf565b50848210156136fc57868401515f19600387901b60f8161c191681555b50505050600190811b01905550565b604081525f61371d604083018561331c565b828103602084015261372f818561331c565b95945050505050565b6001600160a01b03861681526001600160a01b038516602082015283604082015282606082015260a060808201525f61377460a0830184612ef4565b979650505050505050565b5f6020828403121561378f575f5ffd5b8151610a0d81612dc2565b6001600160a01b03861681526001600160a01b038516602082015260a060408201525f6137ca60a083018661331c565b82810360608401526137dc818661331c565b905082810360808401526137f08185612ef4565b9897505050505050505056fea2646970667358221220ea982608a37d898420037a6c52304413e9eb0761f00234276a23b924633cdb3664736f6c634300081d00330000000000000000000000005904bc13a6383dc7ab3ebe4a86efabdac634b596000000000000000000000000833589fcd6edb6e08f4c7c32d4f71b54bda0291300000000000000000000000000000000000000000000000000000000000f4240
Deployed Bytecode
0x608060405234801561000f575f5ffd5b50600436106102d7575f3560e01c8063843592d311610187578063d0c797e0116100dd578063f23a6e6111610093578063f399e22e1161006e578063f399e22e1461066c578063fbfa77cf1461067f578063fe61617b14610692575f5ffd5b8063f23a6e6114610627578063f242432a14610646578063f2fde38b14610659575f5ffd5b8063e30c3978116100c3578063e30c3978146105c8578063e985e9c5146105d9578063ee42427814610614575f5ffd5b8063d0c797e0146105b7578063df87f50d146105bf575f5ffd5b80639456fbcc1161013d578063bc197c8111610118578063bc197c8114610569578063be788e7014610588578063c002d23d14610590575f5ffd5b80639456fbcc14610530578063a22cb46514610543578063aae085bc14610556575f5ffd5b806389a890021161016d57806389a89002146105045780638da5cb5b1461050c5780638f22b90f1461051d575f5ffd5b8063843592d3146104ca578063877c86fb146104dd575f5ffd5b806327b09ed51161023c57806343bc1612116101f2578063715018a6116101cd578063715018a6146104b257806379ba5097146104ba57806380c13e91146104c2575f5ffd5b806343bc1612146104775780634e1273f41461047f57806351cff8d91461049f575f5ffd5b80632eb2c2d6116102225780632eb2c2d6146104495780632ee3d2d61461045c5780634025feb214610464575f5ffd5b806327b09ed5146103f75780632dd310001461040a575f5ffd5b80631130630c11610291578063150b7a0211610277578063150b7a0214610387578063156e29f6146103d75780631791ec53146103ea575f5ffd5b80631130630c1461036c578063136a92b41461037f575f5ffd5b806305149ba4116102c157806305149ba4146103245780630576d8e9146103395780630e89341c1461034c575f5ffd5b8062fdd58e146102db57806301ffc9a714610301575b5f5ffd5b6102ee6102e9366004612d98565b6106b4565b6040519081526020015b60405180910390f35b61031461030f366004612dd7565b6106db565b60405190151581526020016102f8565b610337610332366004612e37565b610703565b005b610337610347366004612ea5565b6107ac565b61035f61035a366004612edd565b6107e4565b6040516102f89190612f22565b61033761037a366004612f34565b610876565b6102ee6108d0565b6103be610395366004613024565b7f150b7a0200000000000000000000000000000000000000000000000000000000949350505050565b6040516001600160e01b031990911681526020016102f8565b6103376103e536600461308c565b610900565b6008546103149060ff1681565b6102ee6104053660046130be565b610920565b6104317f0000000000000000000000008f06a896d93ee35fa03b3fac9be5cd349e824a6d81565b6040516001600160a01b0390911681526020016102f8565b610337610457366004613166565b610a14565b6102ee610a96565b610337610472366004613219565b610ab2565b610431610c2d565b61049261048d366004613257565b610c40565b6040516102f89190613356565b6103376104ad3660046130be565b610d0b565b610337610e20565b610337610e33565b6102ee610e77565b6102ee6104d83660046130be565b610e81565b6104317f000000000000000000000000833589fcd6edb6e08f4c7c32d4f71b54bda0291381565b6102ee600181565b6003546001600160a01b0316610431565b61033761052b36600461308c565b610ee9565b61033761053e366004613368565b610f04565b6103376105513660046133ac565b610f9d565b6103376105643660046133d8565b610fa8565b6103be610577366004613166565b63bc197c8160e01b95945050505050565b6102ee610fbc565b6102ee7f00000000000000000000000000000000000000000000000000000000000f424081565b610337610fd3565b6102ee60075481565b6004546001600160a01b0316610431565b6103146105e7366004613368565b6001600160a01b039182165f90815260016020908152604080832093909416825291909152205460ff1690565b610337610622366004612ea5565b611020565b6103be61063536600461341d565b63f23a6e6160e01b95945050505050565b61033761065436600461341d565b611049565b6103376106673660046130be565b6110c6565b61033761067a366004613475565b611137565b600554610431906001600160a01b031681565b6103146106a03660046130be565b60066020525f908152604090205460ff1681565b5f818152602081815260408083206001600160a01b03861684529091529020545b92915050565b5f6106e5826114c3565b806106f457506106f48261155d565b806106d557506106d58261155d565b61070b611567565b610727576040516282b42960e81b815260040160405180910390fd5b604051627eeac760e11b8152306004820152602481018490525f906001600160a01b0386169062fdd58e90604401602060405180830381865afa158015610770573d5f5f3e3d5ffd5b505050506040513d601f19601f8201168201806040525081019061079491906134c6565b90506107a4868686848787611593565b505050505050565b6107b461177f565b6107bc6117ac565b6005546107d69085906001600160a01b0316858585611832565b6107de611c9d565b50505050565b6060600280546107f3906134dd565b80601f016020809104026020016040519081016040528092919081815260200182805461081f906134dd565b801561086a5780601f106108415761010080835404028352916020019161086a565b820191905f5260205f20905b81548152906001019060200180831161084d57829003601f168201915b50505050509050919050565b61087e61177f565b6108866117ac565b6108c482828080601f0160208091040260200160405190810160405280939291908181526020018383808284375f92019190915250611cc792505050565b6108cc611c9d565b5050565b5f5f6108da610a96565b90506007548110156108ed575f91505090565b6007546108fa9082613529565b91505090565b6109086117ac565b610913838383611d49565b61091b611c9d565b505050565b6040516370a0823160e01b81523060048201525f9081906001600160a01b038416906370a0823190602401602060405180830381865afa158015610966573d5f5f3e3d5ffd5b505050506040513d601f19601f8201168201806040525081019061098a91906134c6565b6040517f4cdad506000000000000000000000000000000000000000000000000000000008152600481018290529091506001600160a01b03841690634cdad50690602401602060405180830381865afa1580156109e9573d5f5f3e3d5ffd5b505050506040513d601f19601f82011682018060405250810190610a0d91906134c6565b9392505050565b336001600160a01b0386168114801590610a5357506001600160a01b038087165f9081526001602090815260408083209385168352929052205460ff16155b15610a895760405163711bec9160e11b81526001600160a01b038083166004830152871660248201526044015b60405180910390fd5b6107a48686868686611ef0565b6005545f90610aad906001600160a01b0316610920565b905090565b610aba611567565b610ad6576040516282b42960e81b815260040160405180910390fd5b6001600160a01b038316610afd57604051639fabe1c160e01b815260040160405180910390fd5b6001600160a01b038216610b2457604051639fabe1c160e01b815260040160405180910390fd5b6001600160a01b0382165f9081526006602052604090205460ff1615610b5d5760405163093e1cdb60e01b815260040160405180910390fd5b604080516001600160a01b038086168252841660208201529081018290527f5b917925bb22ff9e97a81b93b142d472716ae03595d90b9c9aff99456b7fb9f99060600160405180910390a16040517f42842e0e0000000000000000000000000000000000000000000000000000000081523060048201526001600160a01b038481166024830152604482018390528391908216906342842e0e906064015f604051808303815f87803b158015610c11575f5ffd5b505af1158015610c23573d5f5f3e3d5ffd5b5050505050505050565b5f610aad6003546001600160a01b031690565b60608151835114610c715781518351604051635b05999160e01b815260048101929092526024820152604401610a80565b5f835167ffffffffffffffff811115610c8c57610c8c612f73565b604051908082528060200260200182016040528015610cb5578160200160208202803683370190505b5090505f5b8451811015610d0357602080820286010151610cde906020808402870101516106b4565b828281518110610cf057610cf061353c565b6020908102919091010152600101610cba565b509392505050565b610d13611567565b610d2f576040516282b42960e81b815260040160405180910390fd5b6001600160a01b038116610d5657604051639fabe1c160e01b815260040160405180910390fd5b604080516001600160a01b03831681524760208201527f5817fe91d2748c33f168d8a78037fc073adaf6ec8e3613a758d44a2cfae4563d910160405180910390a15f816001600160a01b0316476040515f6040518083038185875af1925050503d805f8114610de0576040519150601f19603f3d011682016040523d82523d5f602084013e610de5565b606091505b50509050806108cc576040517f27fcd9d100000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b610e2861177f565b610e315f611f55565b565b60045433906001600160a01b03168114610e6b5760405163118cdaa760e01b81526001600160a01b0382166004820152602401610a80565b610e7481611f55565b50565b5f5f6108da610fbc565b60405163ce96cb7760e01b81523060048201525f906001600160a01b0383169063ce96cb7790602401602060405180830381865afa158015610ec5573d5f5f3e3d5ffd5b505050506040513d601f19601f820116820180604052508101906106d591906134c6565b610ef161177f565b610ef96117ac565b610913838383611f6e565b610f0c611567565b610f28576040516282b42960e81b815260040160405180910390fd5b6040516370a0823160e01b81523060048201525f906001600160a01b038316906370a0823190602401602060405180830381865afa158015610f6c573d5f5f3e3d5ffd5b505050506040513d601f19601f82011682018060405250810190610f9091906134c6565b905061091b83838361207f565b6108cc3383836121ee565b610fb06117ac565b6107d68484848461229c565b6005545f90610aad906001600160a01b0316610e81565b610fdb61177f565b610fe36117ac565b6008805460ff191660011790556040517f3c3e8aa6d479534e8e372d558c5af1c88715e2b7afaf11052b26bd0da3e47f5a905f90a1610e31611c9d565b61102861177f565b6110306117ac565b6005546107d6906001600160a01b031685858585611832565b336001600160a01b038616811480159061108857506001600160a01b038087165f9081526001602090815260408083209385168352929052205460ff16155b156110b95760405163711bec9160e11b81526001600160a01b03808316600483015287166024820152604401610a80565b6107a486868686866124aa565b6110ce61177f565b600480546001600160a01b0383166001600160a01b031990911681179091556110ff6003546001600160a01b031690565b6001600160a01b03167f38d16b8cac22d99fc7c124b9cd0de2d3fa1faef420bfe791d8c362d765e2270060405160405180910390a350565b7ff0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a00805468010000000000000000810460ff16159067ffffffffffffffff165f811580156111815750825b90505f8267ffffffffffffffff16600114801561119d5750303b155b9050811580156111ab575080155b156111e2576040517ff92ee8a900000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b845467ffffffffffffffff19166001178555831561121657845468ff00000000000000001916680100000000000000001785555b336001600160a01b037f0000000000000000000000008f06a896d93ee35fa03b3fac9be5cd349e824a6d161461125e576040516282b42960e81b815260040160405180910390fd5b60405163df78a62560e01b81526001600160a01b0389811660048301527f0000000000000000000000008f06a896d93ee35fa03b3fac9be5cd349e824a6d169063df78a62590602401602060405180830381865afa1580156112c2573d5f5f3e3d5ffd5b505050506040513d601f19601f820116820180604052508101906112e69190613550565b6113035760405163135c860560e01b815260040160405180910390fd5b7f000000000000000000000000833589fcd6edb6e08f4c7c32d4f71b54bda029136001600160a01b0316886001600160a01b03166338d52e0f6040518163ffffffff1660e01b8152600401602060405180830381865afa158015611369573d5f5f3e3d5ffd5b505050506040513d601f19601f8201168201806040525081019061138d919061356b565b6001600160a01b0316146113b45760405163ca6117c560e01b815260040160405180910390fd5b6113f287878080601f0160208091040260200160405190810160405280939291908181526020018383808284375f92019190915250611cc792505050565b6001600160a01b0388165f818152600660209081526040808320805460ff19166001179055600580546001600160a01b03191685179055805183815291820183905281018290527f4c024dd11ca48373811b395158318a8a78991d69dc1a2d10ef5e38229224e92b9060600160405180910390a361146f88612536565b8315610c2357845468ff000000000000000019168555604051600181527fc7f505b2f371ae2175ee4913f4499e1f2633a7b5936321eed1cdaeb6115181d29060200160405180910390a15050505050505050565b5f6001600160e01b031982167fd9b67a2600000000000000000000000000000000000000000000000000000000148061152557506001600160e01b031982167f0e89341c00000000000000000000000000000000000000000000000000000000145b806106d557507f01ffc9a7000000000000000000000000000000000000000000000000000000006001600160e01b03198316146106d5565b5f6106d58261256b565b5f61157a6003546001600160a01b031690565b6001600160a01b0316336001600160a01b031614905090565b6001600160a01b0386166115ba57604051639fabe1c160e01b815260040160405180910390fd5b6001600160a01b0385166115e157604051639fabe1c160e01b815260040160405180910390fd5b6001600160a01b0385165f9081526006602052604090205460ff161561161a5760405163093e1cdb60e01b815260040160405180910390fd5b604051627eeac760e11b815230600482015260248101859052859084906001600160a01b0383169062fdd58e90604401602060405180830381865afa158015611665573d5f5f3e3d5ffd5b505050506040513d601f19601f8201168201806040525081019061168991906134c6565b10156116a857604051631e9acf1760e31b815260040160405180910390fd5b604080516001600160a01b03808a16825288166020820152908101869052606081018590527f47613189d8ac063d8106d0cbe9e94996721c3109e0ed2b8fb9a2d54fdaf32e2d9060800160405180910390a16040517ff242432a0000000000000000000000000000000000000000000000000000000081526001600160a01b0382169063f242432a906117499030908b908a908a908a908a90600401613586565b5f604051808303815f87803b158015611760575f5ffd5b505af1158015611772573d5f5f3e3d5ffd5b5050505050505050505050565b6003546001600160a01b03163314610e315760405163118cdaa760e01b8152336004820152602401610a80565b7f9b779b17422d0df92223018b32b4d1fa46e071723d6817e2486d003becc55f005c15611805576040517f3ee5aeb500000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b610e3160017f9b779b17422d0df92223018b32b4d1fa46e071723d6817e2486d003becc55f005b906125a8565b836001600160a01b0316856001600160a01b03160361187d576040517ff4d1987f00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6001600160a01b0385165f9081526006602052604090205460ff166118b5576040516305c9c98760e01b815260040160405180910390fd5b60405163df78a62560e01b81526001600160a01b0385811660048301527f0000000000000000000000008f06a896d93ee35fa03b3fac9be5cd349e824a6d169063df78a62590602401602060405180830381865afa158015611919573d5f5f3e3d5ffd5b505050506040513d601f19601f8201168201806040525081019061193d9190613550565b61195a5760405163135c860560e01b815260040160405180910390fd5b7f000000000000000000000000833589fcd6edb6e08f4c7c32d4f71b54bda029136001600160a01b0316846001600160a01b03166338d52e0f6040518163ffffffff1660e01b8152600401602060405180830381865afa1580156119c0573d5f5f3e3d5ffd5b505050506040513d601f19601f820116820180604052508101906119e4919061356b565b6001600160a01b031614611a0b5760405163ca6117c560e01b815260040160405180910390fd5b6001600160a01b038481165f81815260066020526040808220805460ff19166001179055600580546001600160a01b031916909317909255905163ce96cb7760e01b8152306004820152909187169063ce96cb7790602401602060405180830381865afa158015611a7e573d5f5f3e3d5ffd5b505050506040513d601f19601f82011682018060405250810190611aa291906134c6565b90505f828211611ab25781611ab4565b825b604051632d182be560e21b815260048101829052306024820181905260448201529091505f906001600160a01b0389169063b460af94906064016020604051808303815f875af1158015611b0a573d5f5f3e3d5ffd5b505050506040513d601f19601f82011682018060405250810190611b2e91906134c6565b905085811115611b5157604051638937604760e01b815260040160405180910390fd5b611b856001600160a01b037f000000000000000000000000833589fcd6edb6e08f4c7c32d4f71b54bda0291316895f6125af565b611b8e87612536565b604051636e553f6560e01b8152600481018390523060248201525f906001600160a01b03891690636e553f65906044016020604051808303815f875af1158015611bda573d5f5f3e3d5ffd5b505050506040513d601f19601f82011682018060405250810190611bfe91906134c6565b9050805f03611c205760405163ded0dce560e01b815260040160405180910390fd5b85811015611c415760405163ded0dce560e01b815260040160405180910390fd5b60408051848152602081018490529081018290526001600160a01b03808a1691908b16907f4c024dd11ca48373811b395158318a8a78991d69dc1a2d10ef5e38229224e92b9060600160405180910390a3505050505050505050565b610e315f7f9b779b17422d0df92223018b32b4d1fa46e071723d6817e2486d003becc55f0061182c565b60085460ff1615611d04576040517f8a1c449e00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b611d0d816126af565b60017f6bb7ff708619ba0610cba295a58592e0451dee2622938c8755667688daf3529b82604051611d3e9190612f22565b60405180910390a250565b5f611d74837f00000000000000000000000000000000000000000000000000000000000f42406135e2565b90508060075f828254611d8791906135f9565b90915550611dc290506001600160a01b037f000000000000000000000000833589fcd6edb6e08f4c7c32d4f71b54bda02913163330846126bb565b600554604051636e553f6560e01b8152600481018390523060248201525f916001600160a01b031690636e553f65906044016020604051808303815f875af1158015611e10573d5f5f3e3d5ffd5b505050506040513d601f19601f82011682018060405250810190611e3491906134c6565b9050805f03611e565760405163ded0dce560e01b815260040160405180910390fd5b82811015611e775760405163ded0dce560e01b815260040160405180910390fd5b611e928560018660405180602001604052805f8152506126f4565b60055460408051868152602081018590526001600160a01b0392831681830152606081018490529051918716917f3814c54f05c4e44d9082928a6fbb1a4fce70bfdd38cfaab9fa84e2cdb3d7fcbe9181900360800190a25050505050565b6001600160a01b038416611f1957604051632bfa23e760e11b81525f6004820152602401610a80565b6001600160a01b038516611f4157604051626a0d4560e21b81525f6004820152602401610a80565b611f4e858585858561274b565b5050505050565b600480546001600160a01b0319169055610e748161279e565b600554604051632d182be560e21b8152600481018490526001600160a01b0385811660248301523060448301525f92169063b460af94906064016020604051808303815f875af1158015611fc4573d5f5f3e3d5ffd5b505050506040513d601f19601f82011682018060405250810190611fe891906134c6565b90508181111561200b57604051638937604760e01b815260040160405180910390fd5b600754612016610fbc565b10156120355760405163d24a69a560e01b815260040160405180910390fd5b60408051848152602081018390526001600160a01b038616917f311c0edd26c5d78e8109d3d9731d5916b3cc0114c05d5d2cef337e67c2305ced910160405180910390a250505050565b6001600160a01b0383166120a657604051639fabe1c160e01b815260040160405180910390fd5b6001600160a01b0382166120cd57604051639fabe1c160e01b815260040160405180910390fd5b6001600160a01b0382165f9081526006602052604090205460ff16156121065760405163093e1cdb60e01b815260040160405180910390fd5b6040516370a0823160e01b8152306004820152829082906001600160a01b038316906370a0823190602401602060405180830381865afa15801561214c573d5f5f3e3d5ffd5b505050506040513d601f19601f8201168201806040525081019061217091906134c6565b101561218f57604051631e9acf1760e31b815260040160405180910390fd5b604080516001600160a01b038087168252851660208201529081018390527f31e3f58fbb760a4c31ae5c6416229fca813390b5fa0de533ee4cef14b2b344db9060600160405180910390a16107de6001600160a01b03821685846127ef565b6001600160a01b038216612230576040517fced3e1000000000000000000000000000000000000000000000000000000000081525f6004820152602401610a80565b6001600160a01b038381165f81815260016020908152604080832094871680845294825291829020805460ff191686151590811790915591519182527f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c31910160405180910390a3505050565b6001600160a01b03841633148015906122d857506001600160a01b0384165f90815260016020908152604080832033845290915290205460ff16155b156123075760405163711bec9160e11b81523360048201526001600160a01b0385166024820152604401610a80565b6001600160a01b0382165f9081526006602052604090205460ff1661233f576040516305c9c98760e01b815260040160405180910390fd5b5f61236a847f00000000000000000000000000000000000000000000000000000000000f42406135e2565b905060075481111561238f5760405163d24a69a560e01b815260040160405180910390fd5b8060075f8282546123a09190613529565b909155506123b2905085600186612820565b604051632d182be560e21b8152600481018290526001600160a01b0386811660248301523060448301525f919085169063b460af94906064016020604051808303815f875af1158015612407573d5f5f3e3d5ffd5b505050506040513d601f19601f8201168201806040525081019061242b91906134c6565b90508281111561244e57604051638937604760e01b815260040160405180910390fd5b60408051868152602081018490526001600160a01b0386811682840152606082018490529151918816917fc4870f180a23dec674d5dbbea9de7abefeb08f2ed7e4cad9b7bb3b9942b4de699181900360800190a2505050505050565b6001600160a01b0384166124d357604051632bfa23e760e11b81525f6004820152602401610a80565b6001600160a01b0385166124fb57604051626a0d4560e21b81525f6004820152602401610a80565b6040805160018082526020820186905281830190815260608201859052608082019092529061252d878784848761274b565b50505050505050565b610e746001600160a01b037f000000000000000000000000833589fcd6edb6e08f4c7c32d4f71b54bda0291316825f196125af565b5f6001600160e01b031982167f4e2312e00000000000000000000000000000000000000000000000000000000014806106d557506106d5826114c3565b80825d5050565b604080516001600160a01b038416602482015260448082018490528251808303909101815260649091019091526020810180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167f095ea7b30000000000000000000000000000000000000000000000000000000017905261262e8482612886565b6107de576040516001600160a01b0384811660248301525f60448301526126a591869182169063095ea7b3906064015b604051602081830303815290604052915060e01b6020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff83818316178352505050506128cf565b6107de84826128cf565b60026108cc8282613650565b6040516001600160a01b0384811660248301528381166044830152606482018390526107de9186918216906323b872dd9060840161265e565b6001600160a01b03841661271d57604051632bfa23e760e11b81525f6004820152602401610a80565b604080516001808252602082018690528183019081526060820185905260808201909252906107a45f878484875b61275785858585612954565b6001600160a01b03841615611f4e57825133906001036127905760208481015190840151612789838989858589612b7c565b50506107a4565b6107a4818787878787612c9d565b600380546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0905f90a35050565b6040516001600160a01b0383811660248301526044820183905261091b91859182169063a9059cbb9060640161265e565b6001600160a01b03831661284857604051626a0d4560e21b81525f6004820152602401610a80565b604080516001808252602082018590528183019081526060820184905260a082019092525f60808201818152919291611f4e9187918590859061274b565b5f5f5f5f60205f8651602088015f8a5af192503d91505f5190508280156128c5575081156128b757806001146128c5565b5f866001600160a01b03163b115b9695505050505050565b5f5f60205f8451602086015f885af1806128ee576040513d5f823e3d81fd5b50505f513d91508115612905578060011415612912565b6001600160a01b0384163b155b156107de576040517f5274afe70000000000000000000000000000000000000000000000000000000081526001600160a01b0385166004820152602401610a80565b80518251146129835781518151604051635b05999160e01b815260048101929092526024820152604401610a80565b335f5b8351811015612a9e576020818102858101820151908501909101516001600160a01b03881615612a50575f828152602081815260408083206001600160a01b038c16845290915290205481811015612a2a576040517f03dee4c50000000000000000000000000000000000000000000000000000000081526001600160a01b038a166004820152602481018290526044810183905260648101849052608401610a80565b5f838152602081815260408083206001600160a01b038d16845290915290209082900390555b6001600160a01b03871615612a94575f828152602081815260408083206001600160a01b038b16845290915281208054839290612a8e9084906135f9565b90915550505b5050600101612986565b508251600103612b1e5760208301515f906020840151909150856001600160a01b0316876001600160a01b0316846001600160a01b03167fc3d58168c5ae7397731d063d5bbf3d657854427343f4c083240f7aacaa2d0f628585604051612b0f929190918252602082015260400190565b60405180910390a45050611f4e565b836001600160a01b0316856001600160a01b0316826001600160a01b03167f4a39dc06d4c0dbc64b70af90fd698a233a518aa5d07e595d983b8c0526c8f7fb8686604051612b6d92919061370b565b60405180910390a45050505050565b6001600160a01b0384163b156107a45760405163f23a6e6160e01b81526001600160a01b0385169063f23a6e6190612bc09089908990889088908890600401613738565b6020604051808303815f875af1925050508015612bfa575060408051601f3d908101601f19168201909252612bf79181019061377f565b60015b612c61573d808015612c27576040519150601f19603f3d011682016040523d82523d5f602084013e612c2c565b606091505b5080515f03612c5957604051632bfa23e760e11b81526001600160a01b0386166004820152602401610a80565b805181602001fd5b6001600160e01b0319811663f23a6e6160e01b1461252d57604051632bfa23e760e11b81526001600160a01b0386166004820152602401610a80565b6001600160a01b0384163b156107a45760405163bc197c8160e01b81526001600160a01b0385169063bc197c8190612ce1908990899088908890889060040161379a565b6020604051808303815f875af1925050508015612d1b575060408051601f3d908101601f19168201909252612d189181019061377f565b60015b612d48573d808015612c27576040519150601f19603f3d011682016040523d82523d5f602084013e612c2c565b6001600160e01b0319811663bc197c8160e01b1461252d57604051632bfa23e760e11b81526001600160a01b0386166004820152602401610a80565b6001600160a01b0381168114610e74575f5ffd5b5f5f60408385031215612da9575f5ffd5b8235612db481612d84565b946020939093013593505050565b6001600160e01b031981168114610e74575f5ffd5b5f60208284031215612de7575f5ffd5b8135610a0d81612dc2565b5f5f83601f840112612e02575f5ffd5b50813567ffffffffffffffff811115612e19575f5ffd5b602083019150836020828501011115612e30575f5ffd5b9250929050565b5f5f5f5f5f60808688031215612e4b575f5ffd5b8535612e5681612d84565b94506020860135612e6681612d84565b935060408601359250606086013567ffffffffffffffff811115612e88575f5ffd5b612e9488828901612df2565b969995985093965092949392505050565b5f5f5f5f60808587031215612eb8575f5ffd5b8435612ec381612d84565b966020860135965060408601359560600135945092505050565b5f60208284031215612eed575f5ffd5b5035919050565b5f81518084528060208401602086015e5f602082860101526020601f19601f83011685010191505092915050565b602081525f610a0d6020830184612ef4565b5f5f60208385031215612f45575f5ffd5b823567ffffffffffffffff811115612f5b575f5ffd5b612f6785828601612df2565b90969095509350505050565b634e487b7160e01b5f52604160045260245ffd5b604051601f8201601f1916810167ffffffffffffffff81118282101715612fb057612fb0612f73565b604052919050565b5f82601f830112612fc7575f5ffd5b813567ffffffffffffffff811115612fe157612fe1612f73565b612ff4601f8201601f1916602001612f87565b818152846020838601011115613008575f5ffd5b816020850160208301375f918101602001919091529392505050565b5f5f5f5f60808587031215613037575f5ffd5b843561304281612d84565b9350602085013561305281612d84565b925060408501359150606085013567ffffffffffffffff811115613074575f5ffd5b61308087828801612fb8565b91505092959194509250565b5f5f5f6060848603121561309e575f5ffd5b83356130a981612d84565b95602085013595506040909401359392505050565b5f602082840312156130ce575f5ffd5b8135610a0d81612d84565b5f67ffffffffffffffff8211156130f2576130f2612f73565b5060051b60200190565b5f82601f83011261310b575f5ffd5b813561311e613119826130d9565b612f87565b8082825260208201915060208360051b86010192508583111561313f575f5ffd5b602085015b8381101561315c578035835260209283019201613144565b5095945050505050565b5f5f5f5f5f60a0868803121561317a575f5ffd5b853561318581612d84565b9450602086013561319581612d84565b9350604086013567ffffffffffffffff8111156131b0575f5ffd5b6131bc888289016130fc565b935050606086013567ffffffffffffffff8111156131d8575f5ffd5b6131e4888289016130fc565b925050608086013567ffffffffffffffff811115613200575f5ffd5b61320c88828901612fb8565b9150509295509295909350565b5f5f5f6060848603121561322b575f5ffd5b833561323681612d84565b9250602084013561324681612d84565b929592945050506040919091013590565b5f5f60408385031215613268575f5ffd5b823567ffffffffffffffff81111561327e575f5ffd5b8301601f8101851361328e575f5ffd5b803561329c613119826130d9565b8082825260208201915060208360051b8501019250878311156132bd575f5ffd5b6020840193505b828410156132e85783356132d781612d84565b8252602093840193909101906132c4565b9450505050602083013567ffffffffffffffff811115613306575f5ffd5b613312858286016130fc565b9150509250929050565b5f8151808452602084019350602083015f5b8281101561334c57815186526020958601959091019060010161332e565b5093949350505050565b602081525f610a0d602083018461331c565b5f5f60408385031215613379575f5ffd5b823561338481612d84565b9150602083013561339481612d84565b809150509250929050565b8015158114610e74575f5ffd5b5f5f604083850312156133bd575f5ffd5b82356133c881612d84565b915060208301356133948161339f565b5f5f5f5f608085870312156133eb575f5ffd5b84356133f681612d84565b935060208501359250604085013561340d81612d84565b9396929550929360600135925050565b5f5f5f5f5f60a08688031215613431575f5ffd5b853561343c81612d84565b9450602086013561344c81612d84565b93506040860135925060608601359150608086013567ffffffffffffffff811115613200575f5ffd5b5f5f5f60408486031215613487575f5ffd5b833561349281612d84565b9250602084013567ffffffffffffffff8111156134ad575f5ffd5b6134b986828701612df2565b9497909650939450505050565b5f602082840312156134d6575f5ffd5b5051919050565b600181811c908216806134f157607f821691505b60208210810361350f57634e487b7160e01b5f52602260045260245ffd5b50919050565b634e487b7160e01b5f52601160045260245ffd5b818103818111156106d5576106d5613515565b634e487b7160e01b5f52603260045260245ffd5b5f60208284031215613560575f5ffd5b8151610a0d8161339f565b5f6020828403121561357b575f5ffd5b8151610a0d81612d84565b6001600160a01b03871681526001600160a01b038616602082015284604082015283606082015260a060808201528160a0820152818360c08301375f81830160c090810191909152601f909201601f1916010195945050505050565b80820281158282048414176106d5576106d5613515565b808201808211156106d5576106d5613515565b601f82111561091b57805f5260205f20601f840160051c810160208510156136315750805b601f840160051c820191505b81811015611f4e575f815560010161363d565b815167ffffffffffffffff81111561366a5761366a612f73565b61367e8161367884546134dd565b8461360c565b6020601f8211600181146136b0575f83156136995750848201515b5f19600385901b1c1916600184901b178455611f4e565b5f84815260208120601f198516915b828110156136df57878501518255602094850194600190920191016136bf565b50848210156136fc57868401515f19600387901b60f8161c191681555b50505050600190811b01905550565b604081525f61371d604083018561331c565b828103602084015261372f818561331c565b95945050505050565b6001600160a01b03861681526001600160a01b038516602082015283604082015282606082015260a060808201525f61377460a0830184612ef4565b979650505050505050565b5f6020828403121561378f575f5ffd5b8151610a0d81612dc2565b6001600160a01b03861681526001600160a01b038516602082015260a060408201525f6137ca60a083018661331c565b82810360608401526137dc818661331c565b905082810360808401526137f08185612ef4565b9897505050505050505056fea2646970667358221220ea982608a37d898420037a6c52304413e9eb0761f00234276a23b924633cdb3664736f6c634300081d0033
Loading...
Loading
Loading...
Loading
Loading...
Loading
Net Worth in USD
$0.00
Net Worth in ETH
0
Multichain Portfolio | 32 Chains
| Chain | Token | Portfolio % | Price | Amount | Value |
|---|
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.