EVM
EVM
Overview
ETH Balance
0 ETH
ETH Value
$0.00More Info
Private Name Tags
ContractCreator
TokenTracker
Latest 16 from a total of 16 transactions
| Transaction Hash |
|
Block
|
From
|
To
|
|||||
|---|---|---|---|---|---|---|---|---|---|
| Redeem | 16202423 | 177 days ago | IN | 0 ETH | 0.00000994 | ||||
| Accept Offer | 16202405 | 177 days ago | IN | 0 ETH | 0.00006619 | ||||
| Set Target Bough... | 16202367 | 177 days ago | IN | 0 ETH | 0.00002253 | ||||
| Set New Collecti... | 16202345 | 177 days ago | IN | 0 ETH | 0.00001394 | ||||
| Set New Collecti... | 16144322 | 178 days ago | IN | 0 ETH | 0.0000148 | ||||
| Invest | 16070089 | 179 days ago | IN | 0.0004545 ETH | 0.00001186 | ||||
| Set New Collecti... | 16070064 | 179 days ago | IN | 0 ETH | 0.00001238 | ||||
| Withdraw | 16070012 | 179 days ago | IN | 0 ETH | 0.00001321 | ||||
| Allow Offer | 16069457 | 179 days ago | IN | 0 ETH | 0.00001792 | ||||
| Invest | 16063156 | 179 days ago | IN | 0.003434 ETH | 0.00001079 | ||||
| Withdraw | 15561242 | 185 days ago | IN | 0 ETH | 0.00000863 | ||||
| Withdraw | 15561222 | 185 days ago | IN | 0 ETH | 0.00000863 | ||||
| Invest | 15561200 | 185 days ago | IN | 0.00015528 ETH | 0.00001089 | ||||
| Invest | 15561069 | 185 days ago | IN | 0.00103525 ETH | 0.00001136 | ||||
| Withdraw | 15560749 | 185 days ago | IN | 0 ETH | 0.00000863 | ||||
| Invest | 15560665 | 185 days ago | IN | 0.00312 ETH | 0.00001038 |
Latest 18 internal transactions
Advanced mode:
| Parent Transaction Hash | Block | From | To | |||
|---|---|---|---|---|---|---|
| 16202423 | 177 days ago | 0.00305365 ETH | ||||
| 16202405 | 177 days ago | 0.00003084 ETH | ||||
| 16202405 | 177 days ago | 0.0030845 ETH | ||||
| 16202367 | 177 days ago | 0.00003 ETH | ||||
| 16202367 | 177 days ago | 0.00003 ETH | ||||
| 16070089 | 179 days ago | 0.0004545 ETH | ||||
| 16070089 | 179 days ago | 0.0004545 ETH | ||||
| 16070012 | 179 days ago | 0.0008585 ETH | ||||
| 16070012 | 179 days ago | 0.0008585 ETH | ||||
| 16069457 | 179 days ago | 0.003434 ETH | ||||
| 16063156 | 179 days ago | 0.003434 ETH | ||||
| 15561242 | 185 days ago | 0.0008929 ETH | ||||
| 15561222 | 185 days ago | 0.00029763 ETH | ||||
| 15561200 | 185 days ago | 0.00015528 ETH | ||||
| 15561069 | 185 days ago | 0.00103525 ETH | ||||
| 15560749 | 185 days ago | 0.00312 ETH | ||||
| 15560665 | 185 days ago | 0.00312 ETH | ||||
| 15560624 | 185 days ago | Contract Creation | 0 ETH |
Cross-Chain Transactions
Loading...
Loading
Minimal Proxy Contract for 0xf8bbfcbd0ea8a4b2e8d1bdfa6e33b4eb71c6023c
Contract Name:
Pool_Contract
Compiler Version
v0.8.24+commit.e11b9ed9
Optimization Enabled:
Yes with 200 runs
Other Settings:
paris EvmVersion
Contract Source Code (Solidity Standard Json-Input format)
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;
import {ReentrancyGuard} from "@openzeppelin/contracts/utils/ReentrancyGuard.sol";
import {OwnableUpgradeable} from "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol";
import {IERC721} from "@openzeppelin/contracts/token/ERC721/IERC721.sol";
import {IERC1155} from "@openzeppelin/contracts/token/ERC1155/IERC1155.sol";
import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import {SafeERC20} from "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
import {ERC20Upgradeable} from "@openzeppelin/contracts-upgradeable/token/ERC20/ERC20Upgradeable.sol";
import {IERC1271} from "@openzeppelin/contracts/interfaces/IERC1271.sol";
import {UUPSUpgradeable} from "@openzeppelin/contracts-upgradeable/proxy/utils/UUPSUpgradeable.sol";
import {Initializable} from "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol";
import {Helpers} from "./Helpers/Helpers.sol";
import {Validation} from "./Helpers/Validation.sol";
import {PoolState, BuyParams, Pool} from "./Helpers/Struct.sol";
import {IWETH, IDelegateRegistry, IUsePools_main} from "./interfaces/IPool.sol";
/// @title Pool Contract
/// @notice Manages NFT pools for collective ownership and fractionalization
/// @dev This contract uses the ERC20Upgradeable pattern for tokenized pool shares
/// @author UsePools Team
contract Pool_Contract is
ERC20Upgradeable,
OwnableUpgradeable,
IERC1271,
ReentrancyGuard,
Helpers,
Validation,
UUPSUpgradeable
{
using SafeERC20 for IERC20;
// Constants
/// @dev Delegate Registry address for NFT delegation rights
address private constant DELEGATE_REGISTRY =
0x00000000000000447e69651d841bD8D104Bed493;
/// @dev Rights identifier for delegation functionality
bytes32 private constant RIGHTS_ID =
0x99440d42adaa25db782a56a45d8f16c0ec377b4b15cb1dcae9f612f1f904a244;
// Immutable state variables
/// @notice WETH contract interface for ETH wrapping/unwrapping
IWETH private weth;
/// @notice Main UsePools contract interface for protocol interactions
IUsePools_main private usePools_main;
/// @notice Delegate registry for managing NFT delegation rights
IDelegateRegistry private constant delegateRegistry =
IDelegateRegistry(DELEGATE_REGISTRY);
// Storage variables
/// @notice Address of the pool creator
address public creator;
/// @notice Address of the target NFT collection
address public nftCollection;
/// @notice Creator fee percentage in basis points (e.g., 250 = 2.5%)
uint256 public creatorFee;
/// @notice Price at which the target NFT was purchased
uint256 public buyPrice;
/// @notice Token ID of the purchased NFT
uint256 public tokenId;
/// @notice Accumulated creator fees ready for withdrawal
uint256 public creatorFees;
/// @notice Total amount available for user claims
uint256 public totalClaimable;
/// @notice Counter for tracking claim rounds
uint256 public claimCounter;
/// @notice Excess amount when purchase price < total contributions
uint256 public excessAmount;
/// @notice Minimum investment amount required to participate
uint256 public constant MIN_INVESTMENT = 0.001 ether;
/// @notice Whether the target NFT is ERC721 (true) or ERC1155 (false)
bool public isERC721;
/// @notice Whether the pool can make offers on NFTs
bool public offerIsAllowed;
/// @notice Whether the pool can list NFTs for sale
bool public listingIsAllowed;
/// @notice Current state of the pool (ACTIVE, BOUGHT, SOLD, etc.)
PoolState public state;
/// @notice Tracks how much excess amount each user has claimed
/// @dev user address => amount claimed
mapping(address => uint256) public userExcessClaimed;
/// @notice Maps claim IDs to claimable amounts
/// @dev claim ID => amount available for that claim round
mapping(uint256 => uint256) public claims;
/// @notice Tracks if a user has already claimed for a specific claim ID
/// @dev user address => claim ID => has claimed
mapping(address => mapping(uint256 => bool)) public userHasAlreadyClaim;
/// @notice Tracks if a user has already redeemed their excess amount
/// @dev user address => has redeemed excess
mapping(address => bool) public userHasAlreadyRedeemedExcessAmount;
/// @notice Thrown when a user is not participating in the pool
error NOT_IN_THE_POOL();
/// @notice Thrown when a call fails
error CALL_FAILED();
// Events
/// @notice Emitted when a new pool is created
event PoolCreated(address indexed creator, address nftCollection);
/// @notice Emitted when a user's participation in the pool changes
/// @param participant Address of the participant
/// @param contribution Change in participation (positive for investment, negative for withdrawal)
event ParticipationUpdated(
address indexed participant,
int256 contribution
);
/// @notice Emitted when the target NFT is successfully purchased
/// @param poolAddress Pool contract address
/// @param buyPrice Price at which the NFT was purchased
event PoolBought(address indexed poolAddress, uint256 buyPrice);
/// @notice Emitted when a user redeems their excess amount
/// @param user Address of the user redeeming
/// @param amount Amount redeemed
event ExcessAmountRedeemed(address indexed user, uint256 amount);
/// @notice Restricts function access to pool participants or creator
/// @dev Allows either users with pool tokens or the creator to call the function
modifier onlyInThePool() {
if (!_userIsInThePool(msg.sender) && msg.sender != creator)
revert NOT_IN_THE_POOL();
_;
}
/// @custom:oz-upgrades-unsafe-allow constructor
constructor() ERC20Upgradeable() {
_disableInitializers();
}
/// @notice Initializes the contract
/// @dev Called by the factory when creating a new pool. Cannot be called again due to initializer modifier
/// @param _creator Address of the pool creator
/// @param _usePools_main Address of the main UsePools contract
/// @param _weth Address of the WETH contract
/// @param _nftCollection Address of the target NFT collection
/// @param _creatorFee Creator fee percentage in basis points
/// @param _name ERC20 token name for pool shares
/// @param _symbol ERC20 token symbol for pool shares
/// @param isDirectTokenization Whether this pool supports direct NFT tokenization
function initialize(
address _creator,
address _usePools_main,
address _weth,
address _nftCollection,
uint256 _creatorFee,
string memory _name,
string memory _symbol,
bool isDirectTokenization
) public initializer {
__ERC20_init(_name, _symbol);
__Ownable_init(_creator);
__UUPSUpgradeable_init();
weth = IWETH(_weth);
usePools_main = IUsePools_main(_usePools_main);
creator = _creator;
nftCollection = _nftCollection;
creatorFee = _creatorFee;
state = isDirectTokenization
? PoolState.DIRECT_TOKENIZATION
: PoolState.ACTIVE;
}
/// @notice Authorizes an upgrade to a new implementation
/// @dev Only the owner can authorize upgrades. Part of the UUPS pattern
/// @param newImplementation Address of the new implementation contract
function _authorizeUpgrade(
address newImplementation
) internal override onlyOwner {}
/// @notice Allows users to invest ETH in the pool
/// @dev Mints ERC20 tokens proportional to the investment amount
/// @dev If offers are allowed, automatically converts ETH to WETH
function invest() external payable nonReentrant {
_checkInvestment(state, msg.value);
uint256 amount = msg.value;
if (balanceOf(msg.sender) == 0)
_compareAmount(MIN_INVESTMENT, msg.value);
if (offerIsAllowed) _depositWETH(weth, amount);
_mint(msg.sender, amount);
emit ParticipationUpdated(msg.sender, int256(amount));
}
/// @notice Allows users to withdraw their investment
/// @dev Burns ERC20 tokens and returns proportional ETH amount
/// @dev If offers are allowed, converts WETH back to ETH before transfer
/// @param amount Amount of tokens to burn and withdraw
function withdraw(uint256 amount) external nonReentrant onlyInThePool {
_checkWithdraw(state, amount, balanceOf(msg.sender));
if (offerIsAllowed) {
uint256 wethBalance = _getWETHBalance(weth);
_compareAmount(amount, wethBalance);
weth.withdraw(amount);
}
_burn(msg.sender, amount);
_transferETH(msg.sender, amount);
emit ParticipationUpdated(msg.sender, -int256(amount));
}
/// @notice Allows offers to be made on the pool
/// @dev Converts pool funds to WETH and approves OpenSea conduit for offers
/// @dev Requires oracle signature for security
/// @param nonce Unique nonce to prevent replay attacks
/// @param oracleSignature Signature from authorized oracle
function allowOffer(
uint256 nonce,
bytes calldata oracleSignature
) external onlyInThePool {
usePools_main._verifyOracleSignature(
keccak256(abi.encodePacked(msg.sender, nonce, offerIsAllowed)),
oracleSignature
);
_checkOffer(state, offerIsAllowed);
offerIsAllowed = true;
_depositWETH(weth, totalSupply());
address conduit = usePools_main.getConduit();
_approveWETH(weth, conduit);
}
/// @notice Executes OpenSea data for buying
/// @dev Purchases the target NFT using OpenSea marketplace data
/// @dev Updates pool state to BOUGHT and handles excess funds
/// @param buyParams Parameters containing NFT details and buy price
/// @param nonce Unique nonce to prevent replay attacks
/// @param _data OpenSea transaction data for execution
/// @param oracleSignature Signature from authorized oracle
function buyTargetPool(
BuyParams memory buyParams,
uint256 nonce,
bytes calldata _data,
bytes calldata oracleSignature
) external onlyInThePool {
usePools_main._verifyOracleSignature(
keccak256(abi.encodePacked(msg.sender, nonce, offerIsAllowed)),
oracleSignature
);
address OPENSEA = usePools_main.getOpensea();
_checkBuy(state, buyParams.buyPrice, totalSupply(), OPENSEA);
uint256 poolBuyPrice = _handleBuyFee(
usePools_main.getProtocolFee(),
buyParams.buyPrice,
usePools_main.getProtocolFeeReceiver()
);
_execOpenseaData(_data, poolBuyPrice, OPENSEA);
excessAmount = address(this).balance;
state = PoolState.BOUGHT;
buyPrice = poolBuyPrice;
tokenId = buyParams.tokenId;
isERC721 = buyParams.isERC721;
_checkOwnership(nftCollection, buyParams.tokenId, buyParams.isERC721);
emit PoolBought(address(this), poolBuyPrice);
}
/// @notice Marks a target NFT as bought when acquired through offers
/// @dev Alternative to buyTargetPool when NFT was acquired via accepted offer
/// @dev Withdraws WETH, pays protocol fees, and updates pool state
/// @param _tokenId Token ID of the acquired NFT
/// @param _isERC721 Whether the NFT is ERC721 (true) or ERC1155 (false)
/// @param nonce Unique nonce to prevent replay attacks
/// @param oracleSignature Signature from authorized oracle
function setTargetBought(
uint256 _tokenId,
uint256 nonce,
bool _isERC721,
bytes calldata oracleSignature
) external onlyInThePool {
usePools_main._verifyOracleSignature(
keccak256(abi.encodePacked(msg.sender, nonce, offerIsAllowed)),
oracleSignature
);
_checkTargetBought(
_tokenId,
nftCollection,
_isERC721,
offerIsAllowed,
state
);
(uint256 _buyPrice, uint256 _protocolFeeAmount) = _getNetPrice(
usePools_main.getProtocolFee(),
totalSupply()
);
uint256 wethBalance = _getWETHBalance(weth);
_withdrawWETH(weth, wethBalance);
_transferETH(
usePools_main.getProtocolFeeReceiver(),
_protocolFeeAmount
);
excessAmount = address(this).balance;
buyPrice = _buyPrice;
tokenId = _tokenId;
isERC721 = _isERC721;
state = PoolState.BOUGHT;
emit PoolBought(address(this), buyPrice);
}
/// @notice Transfers pool tokens with additional validation
/// @dev Overrides ERC20 transfer to add pool-specific checks
/// @dev Automatically removes delegation rights if user exits pool completely
/// @param to Recipient address
/// @param amount Amount of tokens to transfer
/// @return bool Success status of the transfer
function transfer(
address to,
uint256 amount
) public virtual override returns (bool) {
address owner = _msgSender();
_checkTransfer(owner, amount);
_transfer(owner, to, amount);
return true;
}
/// @notice Transfers pool tokens on behalf of another address
/// @dev Overrides ERC20 transferFrom to add pool-specific checks
/// @dev Automatically removes delegation rights if sender exits pool completely
/// @param from Address to transfer from
/// @param to Recipient address
/// @param amount Amount of tokens to transfer
/// @return bool Success status of the transfer
function transferFrom(
address from,
address to,
uint256 amount
) public virtual override returns (bool) {
address spender = _msgSender();
_spendAllowance(from, spender, amount);
_checkTransfer(from, amount);
_transfer(from, to, amount);
return true;
}
/// @dev Internal function to validate transfers and handle delegation
/// @param from Address transferring tokens
/// @param amount Amount being transferred
function _checkTransfer(address from, uint256 amount) internal {
_checkTransferUserContributions(state, amount, balanceOf(from));
if (balanceOf(from) - amount == 0) delegation(false);
}
/// @notice Executes OpenSea data for accepting offers
/// @dev Accepts an offer on the owned NFT using OpenSea marketplace
/// @param _data OpenSea transaction data for execution
/// @param nonce Unique nonce to prevent replay attacks
/// @param oracleSignature Signature from authorized oracle
function acceptOffer(
bytes calldata _data,
uint256 nonce,
bytes calldata oracleSignature
) external onlyInThePool {
usePools_main._verifyOracleSignature(
keccak256(abi.encodePacked(msg.sender, nonce)),
oracleSignature
);
_checkAllowAcceptOffer(state, nftCollection, tokenId, isERC721);
_approveNFT(
isERC721,
nftCollection,
tokenId,
usePools_main.getConduit()
);
address OPENSEA = usePools_main.getOpensea();
_execOpenseaData(_data, 0, OPENSEA);
uint256 wethBalance = _getWETHBalance(weth);
if (wethBalance > 0) {
_withdrawWETH(weth, wethBalance);
_receive(wethBalance);
}
}
/// @notice Lists the target pool
/// @dev Enables the pool to list the owned NFT for sale on OpenSea
/// @dev Approves OpenSea conduit to transfer the NFT when sold
/// @param nonce Unique nonce to prevent replay attacks
/// @param oracleSignature Signature from authorized oracle
function listTargetPool(
uint256 nonce,
bytes calldata oracleSignature
) external onlyInThePool {
usePools_main._verifyOracleSignature(
keccak256(abi.encodePacked(msg.sender, nonce)),
oracleSignature
);
_checkAllowListTargetPool(
state,
nftCollection,
tokenId,
isERC721,
listingIsAllowed
);
listingIsAllowed = true;
address conduit = usePools_main.getConduit();
_approveNFT(isERC721, nftCollection, tokenId, conduit);
}
/// @notice Cancels an order
/// @dev Cancels an active order (offer or listing) on OpenSea
/// @param _data OpenSea transaction data for cancellation
/// @param nonce Unique nonce to prevent replay attacks
/// @param oracleSignature Signature from authorized oracle
function cancelOrder(
bytes calldata _data,
bytes calldata oracleSignature,
uint256 nonce
) external onlyInThePool {
usePools_main._verifyOracleSignature(
keccak256(abi.encodePacked(msg.sender, nonce)),
oracleSignature
);
address OPENSEA = usePools_main.getOpensea();
_execOpenseaData(_data, 0, OPENSEA);
}
/// @notice Forces the pool state to SOLD
/// @dev Used when NFT was sold outside normal flow (emergency function)
/// @dev Can only be called when pool owns an NFT that's no longer in possession
/// @param nonce Unique nonce to prevent replay attacks
/// @param oracleSignature Signature from authorized oracle
function forcePoolIsSolded(
uint256 nonce,
bytes calldata oracleSignature
) external onlyInThePool {
usePools_main._verifyOracleSignature(
keccak256(abi.encodePacked(msg.sender, nonce)),
oracleSignature
);
_checkForcePoolIsSolded(state, nftCollection, tokenId, isERC721);
state = PoolState.SOLD;
}
/// @notice Delegates rights to a user
/// @dev Manages NFT delegation rights through the delegate registry
/// @dev Only users with pool tokens can receive delegation rights
/// @param isDelegated Whether to enable or disable delegation
function delegation(bool isDelegated) public {
if (!_userIsInThePool(msg.sender)) revert NOT_IN_THE_POOL();
_checkState(state, PoolState.BOUGHT);
delegateRegistry.delegateAll(msg.sender, RIGHTS_ID, isDelegated);
}
/// @notice Checks if the contract owns the target NFT
function ownTheTarget(
uint256 _tokenId,
address _collectionToBuy,
bool _isERC721
) public view returns (bool) {
if (_isERC721) {
return IERC721(_collectionToBuy).ownerOf(_tokenId) == address(this);
} else {
return
IERC1155(_collectionToBuy).balanceOf(address(this), _tokenId) >
0;
}
}
function redeemExcessAmount() external nonReentrant onlyInThePool {
uint256 userBalance = balanceOf(msg.sender);
uint256 _totalSupply = totalSupply();
_checkWithdrawExcess(state, excessAmount, userBalance);
uint256 totalUserShare = _getClaimableAmount(
excessAmount,
userBalance,
_totalSupply
);
uint256 alreadyClaimed = userExcessClaimed[msg.sender];
_compareAmount(alreadyClaimed, totalUserShare);
uint256 claimableAmount = totalUserShare - alreadyClaimed;
_checkAmount(claimableAmount);
userExcessClaimed[msg.sender] = totalUserShare;
userHasAlreadyRedeemedExcessAmount[msg.sender] = true;
_transferETH(msg.sender, claimableAmount);
emit ExcessAmountRedeemed(msg.sender, claimableAmount);
}
function redeem(uint256 claimId) external nonReentrant onlyInThePool {
_checkAllowRedeem(
state,
totalClaimable,
userHasAlreadyClaim[msg.sender][claimId]
);
userHasAlreadyClaim[msg.sender][claimId] = true;
uint256 userBalance = balanceOf(msg.sender);
uint256 _totalSupply = totalSupply();
uint256 claimableAmount = _getClaimableAmount(
claims[claimId],
userBalance,
_totalSupply
);
uint256 excessClaimableAmount;
if (
excessAmount > 0 && !userHasAlreadyRedeemedExcessAmount[msg.sender]
) {
excessClaimableAmount = _getClaimableAmount(
excessAmount,
userBalance,
_totalSupply
);
claimableAmount += excessClaimableAmount;
userHasAlreadyRedeemedExcessAmount[msg.sender] = true;
}
_transferETH(msg.sender, claimableAmount);
}
function redeemCreatorFees() external nonReentrant onlyInThePool {
_checkRedeemCreatorFees(state, creatorFees, msg.sender, creator);
uint256 creatorFeesAmount = creatorFees;
creatorFees = 0;
_transferETH(msg.sender, creatorFeesAmount);
}
function _userIsInThePool(address user) public view returns (bool) {
return balanceOf(user) > 0;
}
/// @notice Allows the creator to deposit their NFT directly into the pool
function depositNFT(
uint256 _tokenId,
bool _isERC721
) external nonReentrant onlyInThePool {
_checkAllowDepositNFT(
state,
nftCollection,
creator,
_tokenId,
_isERC721
);
_transferNFT(
nftCollection,
_tokenId,
_isERC721,
creator,
address(this)
);
_checkOwnership(nftCollection, _tokenId, _isERC721);
_mint(creator, 1 ether);
tokenId = _tokenId;
isERC721 = _isERC721;
state = PoolState.BOUGHT;
emit PoolBought(address(this), 1 ether);
emit ParticipationUpdated(creator, int256(1 ether));
}
function withdrawNFT() external onlyInThePool {
_checkAllowWithdrawNFT(
state,
nftCollection,
isERC721,
tokenId,
totalSupply(),
balanceOf(msg.sender)
);
_burn(msg.sender, balanceOf(msg.sender));
_transferNFT(nftCollection, tokenId, isERC721, address(this), creator);
state = PoolState.ACTIVE;
tokenId = 0;
isERC721 = false;
}
function setDirectTokenization() external {
_checkAllowDirectTokenization(
state,
totalSupply(),
msg.sender,
creator
);
state = PoolState.DIRECT_TOKENIZATION;
}
function getPool() external view returns (Pool memory) {
return
Pool({
creator: creator,
escrow: address(this),
collection: nftCollection,
totalContributed: totalSupply(),
creatorFee: creatorFee,
offerIsAllowed: offerIsAllowed,
listingIsAllowed: listingIsAllowed,
state: state
});
}
/// @notice Validates signatures
function isValidSignature(
bytes32 _hash,
bytes memory _signature
) external view override returns (bytes4) {
address signer = _recoverSigner(_hash, _signature);
return
usePools_main.getOracle(signer)
? bytes4(0x1626ba7e)
: bytes4(0xffffffff);
}
/// @notice Handles receiving funds and distributing them
function _receive(uint256 amount) internal nonReentrant {
_checkAmount(amount);
address protocolFeeRecipient = usePools_main.getProtocolFeeReceiver();
uint256 protocolFee = usePools_main.getProtocolFee();
(
uint256 usersShare,
uint256 protocolShare,
uint256 creatorShare
) = _processReceivedAmount(amount, protocolFee, creatorFee, buyPrice);
creatorFees += creatorShare;
totalClaimable += usersShare;
claims[claimCounter++] = usersShare;
if (
state == PoolState.BOUGHT &&
!ownTheTarget(tokenId, nftCollection, isERC721)
) state = PoolState.SOLD;
_transferETH(protocolFeeRecipient, protocolShare);
}
function setNewCollection(
uint256 nonce,
address newCollection,
bytes calldata oracleSignature
) external onlyInThePool {
usePools_main._verifyOracleSignature(
keccak256(abi.encodePacked(msg.sender, newCollection, nonce)),
oracleSignature
);
_checkState(state, PoolState.ACTIVE);
nftCollection = newCollection;
tokenId = 0;
isERC721 = false;
}
function totalContributed() external view returns (uint256) {
return totalSupply();
}
function redeemERC20(address tokenAddress) external {
_checkTokenIsNotWETH(tokenAddress, address(weth));
address protocolFeeRecipient = usePools_main.getProtocolFeeReceiver();
require(msg.sender == protocolFeeRecipient, "Unauthorized");
uint256 balance = IERC20(tokenAddress).balanceOf(address(this));
IERC20(tokenAddress).safeTransfer(protocolFeeRecipient, balance);
}
receive() external payable {
if (msg.sender != address(weth)) _receive(msg.value);
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (access/Ownable.sol)
pragma solidity ^0.8.20;
import {ContextUpgradeable} from "../utils/ContextUpgradeable.sol";
import {Initializable} from "../proxy/utils/Initializable.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 OwnableUpgradeable is Initializable, ContextUpgradeable {
/// @custom:storage-location erc7201:openzeppelin.storage.Ownable
struct OwnableStorage {
address _owner;
}
// keccak256(abi.encode(uint256(keccak256("openzeppelin.storage.Ownable")) - 1)) & ~bytes32(uint256(0xff))
bytes32 private constant OwnableStorageLocation = 0x9016d09d72d40fdae2fd8ceac6b6234c7706214fd39c1cd1e609a0528c199300;
function _getOwnableStorage() private pure returns (OwnableStorage storage $) {
assembly {
$.slot := OwnableStorageLocation
}
}
/**
* @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.
*/
function __Ownable_init(address initialOwner) internal onlyInitializing {
__Ownable_init_unchained(initialOwner);
}
function __Ownable_init_unchained(address initialOwner) internal onlyInitializing {
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) {
OwnableStorage storage $ = _getOwnableStorage();
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 {
OwnableStorage storage $ = _getOwnableStorage();
address oldOwner = $._owner;
$._owner = newOwner;
emit OwnershipTransferred(oldOwner, newOwner);
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.3.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 reinitialization) 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 Pointer to storage slot. Allows integrators to override it with a custom storage location.
*
* NOTE: Consider following the ERC-7201 formula to derive storage locations.
*/
function _initializableStorageSlot() internal pure virtual returns (bytes32) {
return INITIALIZABLE_STORAGE;
}
/**
* @dev Returns a pointer to the storage namespace.
*/
// solhint-disable-next-line var-name-mixedcase
function _getInitializableStorage() private pure returns (InitializableStorage storage $) {
bytes32 slot = _initializableStorageSlot();
assembly {
$.slot := slot
}
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.3.0) (proxy/utils/UUPSUpgradeable.sol)
pragma solidity ^0.8.22;
import {IERC1822Proxiable} from "@openzeppelin/contracts/interfaces/draft-IERC1822.sol";
import {ERC1967Utils} from "@openzeppelin/contracts/proxy/ERC1967/ERC1967Utils.sol";
import {Initializable} from "./Initializable.sol";
/**
* @dev An upgradeability mechanism designed for UUPS proxies. The functions included here can perform an upgrade of an
* {ERC1967Proxy}, when this contract is set as the implementation behind such a proxy.
*
* A security mechanism ensures that an upgrade does not turn off upgradeability accidentally, although this risk is
* reinstated if the upgrade retains upgradeability but removes the security mechanism, e.g. by replacing
* `UUPSUpgradeable` with a custom implementation of upgrades.
*
* The {_authorizeUpgrade} function must be overridden to include access restriction to the upgrade mechanism.
*/
abstract contract UUPSUpgradeable is Initializable, IERC1822Proxiable {
/// @custom:oz-upgrades-unsafe-allow state-variable-immutable
address private immutable __self = address(this);
/**
* @dev The version of the upgrade interface of the contract. If this getter is missing, both `upgradeTo(address)`
* and `upgradeToAndCall(address,bytes)` are present, and `upgradeTo` must be used if no function should be called,
* while `upgradeToAndCall` will invoke the `receive` function if the second argument is the empty byte string.
* If the getter returns `"5.0.0"`, only `upgradeToAndCall(address,bytes)` is present, and the second argument must
* be the empty byte string if no function should be called, making it impossible to invoke the `receive` function
* during an upgrade.
*/
string public constant UPGRADE_INTERFACE_VERSION = "5.0.0";
/**
* @dev The call is from an unauthorized context.
*/
error UUPSUnauthorizedCallContext();
/**
* @dev The storage `slot` is unsupported as a UUID.
*/
error UUPSUnsupportedProxiableUUID(bytes32 slot);
/**
* @dev Check that the execution is being performed through a delegatecall call and that the execution context is
* a proxy contract with an implementation (as defined in ERC-1967) pointing to self. This should only be the case
* for UUPS and transparent proxies that are using the current contract as their implementation. Execution of a
* function through ERC-1167 minimal proxies (clones) would not normally pass this test, but is not guaranteed to
* fail.
*/
modifier onlyProxy() {
_checkProxy();
_;
}
/**
* @dev Check that the execution is not being performed through a delegate call. This allows a function to be
* callable on the implementing contract but not through proxies.
*/
modifier notDelegated() {
_checkNotDelegated();
_;
}
function __UUPSUpgradeable_init() internal onlyInitializing {
}
function __UUPSUpgradeable_init_unchained() internal onlyInitializing {
}
/**
* @dev Implementation of the ERC-1822 {proxiableUUID} function. This returns the storage slot used by the
* implementation. It is used to validate the implementation's compatibility when performing an upgrade.
*
* IMPORTANT: A proxy pointing at a proxiable contract should not be considered proxiable itself, because this risks
* bricking a proxy that upgrades to it, by delegating to itself until out of gas. Thus it is critical that this
* function revert if invoked through a proxy. This is guaranteed by the `notDelegated` modifier.
*/
function proxiableUUID() external view virtual notDelegated returns (bytes32) {
return ERC1967Utils.IMPLEMENTATION_SLOT;
}
/**
* @dev Upgrade the implementation of the proxy to `newImplementation`, and subsequently execute the function call
* encoded in `data`.
*
* Calls {_authorizeUpgrade}.
*
* Emits an {Upgraded} event.
*
* @custom:oz-upgrades-unsafe-allow-reachable delegatecall
*/
function upgradeToAndCall(address newImplementation, bytes memory data) public payable virtual onlyProxy {
_authorizeUpgrade(newImplementation);
_upgradeToAndCallUUPS(newImplementation, data);
}
/**
* @dev Reverts if the execution is not performed via delegatecall or the execution
* context is not of a proxy with an ERC-1967 compliant implementation pointing to self.
*/
function _checkProxy() internal view virtual {
if (
address(this) == __self || // Must be called through delegatecall
ERC1967Utils.getImplementation() != __self // Must be called through an active proxy
) {
revert UUPSUnauthorizedCallContext();
}
}
/**
* @dev Reverts if the execution is performed via delegatecall.
* See {notDelegated}.
*/
function _checkNotDelegated() internal view virtual {
if (address(this) != __self) {
// Must not be called through delegatecall
revert UUPSUnauthorizedCallContext();
}
}
/**
* @dev Function that should revert when `msg.sender` is not authorized to upgrade the contract. Called by
* {upgradeToAndCall}.
*
* Normally, this function will use an xref:access.adoc[access control] modifier such as {Ownable-onlyOwner}.
*
* ```solidity
* function _authorizeUpgrade(address) internal onlyOwner {}
* ```
*/
function _authorizeUpgrade(address newImplementation) internal virtual;
/**
* @dev Performs an implementation upgrade with a security check for UUPS proxies, and additional setup call.
*
* As a security check, {proxiableUUID} is invoked in the new implementation, and the return value
* is expected to be the implementation slot in ERC-1967.
*
* Emits an {IERC1967-Upgraded} event.
*/
function _upgradeToAndCallUUPS(address newImplementation, bytes memory data) private {
try IERC1822Proxiable(newImplementation).proxiableUUID() returns (bytes32 slot) {
if (slot != ERC1967Utils.IMPLEMENTATION_SLOT) {
revert UUPSUnsupportedProxiableUUID(slot);
}
ERC1967Utils.upgradeToAndCall(newImplementation, data);
} catch {
// The implementation is not UUPS
revert ERC1967Utils.ERC1967InvalidImplementation(newImplementation);
}
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.3.0) (token/ERC20/ERC20.sol)
pragma solidity ^0.8.20;
import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import {IERC20Metadata} from "@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol";
import {ContextUpgradeable} from "../../utils/ContextUpgradeable.sol";
import {IERC20Errors} from "@openzeppelin/contracts/interfaces/draft-IERC6093.sol";
import {Initializable} from "../../proxy/utils/Initializable.sol";
/**
* @dev Implementation of the {IERC20} interface.
*
* This implementation is agnostic to the way tokens are created. This means
* that a supply mechanism has to be added in a derived contract using {_mint}.
*
* TIP: For a detailed writeup see our guide
* https://forum.openzeppelin.com/t/how-to-implement-erc20-supply-mechanisms/226[How
* to implement supply mechanisms].
*
* The default value of {decimals} is 18. To change this, you should override
* this function so it returns a different value.
*
* We have followed general OpenZeppelin Contracts guidelines: functions revert
* instead returning `false` on failure. This behavior is nonetheless
* conventional and does not conflict with the expectations of ERC-20
* applications.
*/
abstract contract ERC20Upgradeable is Initializable, ContextUpgradeable, IERC20, IERC20Metadata, IERC20Errors {
/// @custom:storage-location erc7201:openzeppelin.storage.ERC20
struct ERC20Storage {
mapping(address account => uint256) _balances;
mapping(address account => mapping(address spender => uint256)) _allowances;
uint256 _totalSupply;
string _name;
string _symbol;
}
// keccak256(abi.encode(uint256(keccak256("openzeppelin.storage.ERC20")) - 1)) & ~bytes32(uint256(0xff))
bytes32 private constant ERC20StorageLocation = 0x52c63247e1f47db19d5ce0460030c497f067ca4cebf71ba98eeadabe20bace00;
function _getERC20Storage() private pure returns (ERC20Storage storage $) {
assembly {
$.slot := ERC20StorageLocation
}
}
/**
* @dev Sets the values for {name} and {symbol}.
*
* Both values are immutable: they can only be set once during construction.
*/
function __ERC20_init(string memory name_, string memory symbol_) internal onlyInitializing {
__ERC20_init_unchained(name_, symbol_);
}
function __ERC20_init_unchained(string memory name_, string memory symbol_) internal onlyInitializing {
ERC20Storage storage $ = _getERC20Storage();
$._name = name_;
$._symbol = symbol_;
}
/**
* @dev Returns the name of the token.
*/
function name() public view virtual returns (string memory) {
ERC20Storage storage $ = _getERC20Storage();
return $._name;
}
/**
* @dev Returns the symbol of the token, usually a shorter version of the
* name.
*/
function symbol() public view virtual returns (string memory) {
ERC20Storage storage $ = _getERC20Storage();
return $._symbol;
}
/**
* @dev Returns the number of decimals used to get its user representation.
* For example, if `decimals` equals `2`, a balance of `505` tokens should
* be displayed to a user as `5.05` (`505 / 10 ** 2`).
*
* Tokens usually opt for a value of 18, imitating the relationship between
* Ether and Wei. This is the default value returned by this function, unless
* it's overridden.
*
* NOTE: This information is only used for _display_ purposes: it in
* no way affects any of the arithmetic of the contract, including
* {IERC20-balanceOf} and {IERC20-transfer}.
*/
function decimals() public view virtual returns (uint8) {
return 18;
}
/**
* @dev See {IERC20-totalSupply}.
*/
function totalSupply() public view virtual returns (uint256) {
ERC20Storage storage $ = _getERC20Storage();
return $._totalSupply;
}
/**
* @dev See {IERC20-balanceOf}.
*/
function balanceOf(address account) public view virtual returns (uint256) {
ERC20Storage storage $ = _getERC20Storage();
return $._balances[account];
}
/**
* @dev See {IERC20-transfer}.
*
* Requirements:
*
* - `to` cannot be the zero address.
* - the caller must have a balance of at least `value`.
*/
function transfer(address to, uint256 value) public virtual returns (bool) {
address owner = _msgSender();
_transfer(owner, to, value);
return true;
}
/**
* @dev See {IERC20-allowance}.
*/
function allowance(address owner, address spender) public view virtual returns (uint256) {
ERC20Storage storage $ = _getERC20Storage();
return $._allowances[owner][spender];
}
/**
* @dev See {IERC20-approve}.
*
* NOTE: If `value` is the maximum `uint256`, the allowance is not updated on
* `transferFrom`. This is semantically equivalent to an infinite approval.
*
* Requirements:
*
* - `spender` cannot be the zero address.
*/
function approve(address spender, uint256 value) public virtual returns (bool) {
address owner = _msgSender();
_approve(owner, spender, value);
return true;
}
/**
* @dev See {IERC20-transferFrom}.
*
* Skips emitting an {Approval} event indicating an allowance update. This is not
* required by the ERC. See {xref-ERC20-_approve-address-address-uint256-bool-}[_approve].
*
* NOTE: Does not update the allowance if the current allowance
* is the maximum `uint256`.
*
* Requirements:
*
* - `from` and `to` cannot be the zero address.
* - `from` must have a balance of at least `value`.
* - the caller must have allowance for ``from``'s tokens of at least
* `value`.
*/
function transferFrom(address from, address to, uint256 value) public virtual returns (bool) {
address spender = _msgSender();
_spendAllowance(from, spender, value);
_transfer(from, to, value);
return true;
}
/**
* @dev Moves a `value` amount of tokens from `from` to `to`.
*
* This internal function is equivalent to {transfer}, and can be used to
* e.g. implement automatic token fees, slashing mechanisms, etc.
*
* Emits a {Transfer} event.
*
* NOTE: This function is not virtual, {_update} should be overridden instead.
*/
function _transfer(address from, address to, uint256 value) internal {
if (from == address(0)) {
revert ERC20InvalidSender(address(0));
}
if (to == address(0)) {
revert ERC20InvalidReceiver(address(0));
}
_update(from, to, value);
}
/**
* @dev Transfers a `value` amount of tokens from `from` to `to`, or alternatively mints (or burns) if `from`
* (or `to`) is the zero address. All customizations to transfers, mints, and burns should be done by overriding
* this function.
*
* Emits a {Transfer} event.
*/
function _update(address from, address to, uint256 value) internal virtual {
ERC20Storage storage $ = _getERC20Storage();
if (from == address(0)) {
// Overflow check required: The rest of the code assumes that totalSupply never overflows
$._totalSupply += value;
} else {
uint256 fromBalance = $._balances[from];
if (fromBalance < value) {
revert ERC20InsufficientBalance(from, fromBalance, value);
}
unchecked {
// Overflow not possible: value <= fromBalance <= totalSupply.
$._balances[from] = fromBalance - value;
}
}
if (to == address(0)) {
unchecked {
// Overflow not possible: value <= totalSupply or value <= fromBalance <= totalSupply.
$._totalSupply -= value;
}
} else {
unchecked {
// Overflow not possible: balance + value is at most totalSupply, which we know fits into a uint256.
$._balances[to] += value;
}
}
emit Transfer(from, to, value);
}
/**
* @dev Creates a `value` amount of tokens and assigns them to `account`, by transferring it from address(0).
* Relies on the `_update` mechanism
*
* Emits a {Transfer} event with `from` set to the zero address.
*
* NOTE: This function is not virtual, {_update} should be overridden instead.
*/
function _mint(address account, uint256 value) internal {
if (account == address(0)) {
revert ERC20InvalidReceiver(address(0));
}
_update(address(0), account, value);
}
/**
* @dev Destroys a `value` amount of tokens from `account`, lowering the total supply.
* Relies on the `_update` mechanism.
*
* Emits a {Transfer} event with `to` set to the zero address.
*
* NOTE: This function is not virtual, {_update} should be overridden instead
*/
function _burn(address account, uint256 value) internal {
if (account == address(0)) {
revert ERC20InvalidSender(address(0));
}
_update(account, address(0), value);
}
/**
* @dev Sets `value` as the allowance of `spender` over the `owner`'s tokens.
*
* This internal function is equivalent to `approve`, and can be used to
* e.g. set automatic allowances for certain subsystems, etc.
*
* Emits an {Approval} event.
*
* Requirements:
*
* - `owner` cannot be the zero address.
* - `spender` cannot be the zero address.
*
* Overrides to this logic should be done to the variant with an additional `bool emitEvent` argument.
*/
function _approve(address owner, address spender, uint256 value) internal {
_approve(owner, spender, value, true);
}
/**
* @dev Variant of {_approve} with an optional flag to enable or disable the {Approval} event.
*
* By default (when calling {_approve}) the flag is set to true. On the other hand, approval changes made by
* `_spendAllowance` during the `transferFrom` operation set the flag to false. This saves gas by not emitting any
* `Approval` event during `transferFrom` operations.
*
* Anyone who wishes to continue emitting `Approval` events on the`transferFrom` operation can force the flag to
* true using the following override:
*
* ```solidity
* function _approve(address owner, address spender, uint256 value, bool) internal virtual override {
* super._approve(owner, spender, value, true);
* }
* ```
*
* Requirements are the same as {_approve}.
*/
function _approve(address owner, address spender, uint256 value, bool emitEvent) internal virtual {
ERC20Storage storage $ = _getERC20Storage();
if (owner == address(0)) {
revert ERC20InvalidApprover(address(0));
}
if (spender == address(0)) {
revert ERC20InvalidSpender(address(0));
}
$._allowances[owner][spender] = value;
if (emitEvent) {
emit Approval(owner, spender, value);
}
}
/**
* @dev Updates `owner`'s allowance for `spender` based on spent `value`.
*
* Does not update the allowance value in case of infinite allowance.
* Revert if not enough allowance is available.
*
* Does not emit an {Approval} event.
*/
function _spendAllowance(address owner, address spender, uint256 value) internal virtual {
uint256 currentAllowance = allowance(owner, spender);
if (currentAllowance < type(uint256).max) {
if (currentAllowance < value) {
revert ERC20InsufficientAllowance(spender, currentAllowance, value);
}
unchecked {
_approve(owner, spender, currentAllowance - value, false);
}
}
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.1) (utils/Context.sol)
pragma solidity ^0.8.20;
import {Initializable} from "../proxy/utils/Initializable.sol";
/**
* @dev Provides information about the current execution context, including the
* sender of the transaction and its data. While these are generally available
* via msg.sender and msg.data, they should not be accessed in such a direct
* manner, since when dealing with meta-transactions the account sending and
* paying for execution may not be the actual sender (as far as an application
* is concerned).
*
* This contract is only required for intermediate, library-like contracts.
*/
abstract contract ContextUpgradeable is Initializable {
function __Context_init() internal onlyInitializing {
}
function __Context_init_unchained() internal onlyInitializing {
}
function _msgSender() internal view virtual returns (address) {
return msg.sender;
}
function _msgData() internal view virtual returns (bytes calldata) {
return msg.data;
}
function _contextSuffixLength() internal view virtual returns (uint256) {
return 0;
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.1.0) (interfaces/draft-IERC1822.sol)
pragma solidity ^0.8.20;
/**
* @dev ERC-1822: Universal Upgradeable Proxy Standard (UUPS) documents a method for upgradeability through a simplified
* proxy whose upgrades are fully controlled by the current implementation.
*/
interface IERC1822Proxiable {
/**
* @dev Returns the storage slot that the proxiable contract assumes is being used to store the implementation
* address.
*
* IMPORTANT: A proxy pointing at a proxiable contract should not be considered proxiable itself, because this risks
* bricking a proxy that upgrades to it, by delegating to itself until out of gas. Thus it is critical that this
* function revert if invoked through a proxy.
*/
function proxiableUUID() external view returns (bytes32);
}// 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/IERC1271.sol)
pragma solidity ^0.8.20;
/**
* @dev Interface of the ERC-1271 standard signature validation method for
* contracts as defined in https://eips.ethereum.org/EIPS/eip-1271[ERC-1271].
*/
interface IERC1271 {
/**
* @dev Should return whether the signature provided is valid for the provided data
* @param hash Hash of the data to be signed
* @param signature Signature byte array associated with _data
*/
function isValidSignature(bytes32 hash, bytes memory signature) external view returns (bytes4 magicValue);
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.1.0) (interfaces/IERC1363.sol)
pragma solidity ^0.8.20;
import {IERC20} from "./IERC20.sol";
import {IERC165} from "./IERC165.sol";
/**
* @title IERC1363
* @dev Interface of the ERC-1363 standard as defined in the https://eips.ethereum.org/EIPS/eip-1363[ERC-1363].
*
* Defines an extension interface for ERC-20 tokens that supports executing code on a recipient contract
* after `transfer` or `transferFrom`, or code on a spender contract after `approve`, in a single transaction.
*/
interface IERC1363 is IERC20, IERC165 {
/*
* Note: the ERC-165 identifier for this interface is 0xb0202a11.
* 0xb0202a11 ===
* bytes4(keccak256('transferAndCall(address,uint256)')) ^
* bytes4(keccak256('transferAndCall(address,uint256,bytes)')) ^
* bytes4(keccak256('transferFromAndCall(address,address,uint256)')) ^
* bytes4(keccak256('transferFromAndCall(address,address,uint256,bytes)')) ^
* bytes4(keccak256('approveAndCall(address,uint256)')) ^
* bytes4(keccak256('approveAndCall(address,uint256,bytes)'))
*/
/**
* @dev Moves a `value` amount of tokens from the caller's account to `to`
* and then calls {IERC1363Receiver-onTransferReceived} on `to`.
* @param to The address which you want to transfer to.
* @param value The amount of tokens to be transferred.
* @return A boolean value indicating whether the operation succeeded unless throwing.
*/
function transferAndCall(address to, uint256 value) external returns (bool);
/**
* @dev Moves a `value` amount of tokens from the caller's account to `to`
* and then calls {IERC1363Receiver-onTransferReceived} on `to`.
* @param to The address which you want to transfer to.
* @param value The amount of tokens to be transferred.
* @param data Additional data with no specified format, sent in call to `to`.
* @return A boolean value indicating whether the operation succeeded unless throwing.
*/
function transferAndCall(address to, uint256 value, bytes calldata data) external returns (bool);
/**
* @dev Moves a `value` amount of tokens from `from` to `to` using the allowance mechanism
* and then calls {IERC1363Receiver-onTransferReceived} on `to`.
* @param from The address which you want to send tokens from.
* @param to The address which you want to transfer to.
* @param value The amount of tokens to be transferred.
* @return A boolean value indicating whether the operation succeeded unless throwing.
*/
function transferFromAndCall(address from, address to, uint256 value) external returns (bool);
/**
* @dev Moves a `value` amount of tokens from `from` to `to` using the allowance mechanism
* and then calls {IERC1363Receiver-onTransferReceived} on `to`.
* @param from The address which you want to send tokens from.
* @param to The address which you want to transfer to.
* @param value The amount of tokens to be transferred.
* @param data Additional data with no specified format, sent in call to `to`.
* @return A boolean value indicating whether the operation succeeded unless throwing.
*/
function transferFromAndCall(address from, address to, uint256 value, bytes calldata data) external returns (bool);
/**
* @dev Sets a `value` amount of tokens as the allowance of `spender` over the
* caller's tokens and then calls {IERC1363Spender-onApprovalReceived} on `spender`.
* @param spender The address which will spend the funds.
* @param value The amount of tokens to be spent.
* @return A boolean value indicating whether the operation succeeded unless throwing.
*/
function approveAndCall(address spender, uint256 value) external returns (bool);
/**
* @dev Sets a `value` amount of tokens as the allowance of `spender` over the
* caller's tokens and then calls {IERC1363Spender-onApprovalReceived} on `spender`.
* @param spender The address which will spend the funds.
* @param value The amount of tokens to be spent.
* @param data Additional data with no specified format, sent in call to `spender`.
* @return A boolean value indicating whether the operation succeeded unless throwing.
*/
function approveAndCall(address spender, uint256 value, bytes calldata data) external returns (bool);
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (interfaces/IERC165.sol)
pragma solidity ^0.8.20;
import {IERC165} from "../utils/introspection/IERC165.sol";// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (interfaces/IERC1967.sol)
pragma solidity ^0.8.20;
/**
* @dev ERC-1967: Proxy Storage Slots. This interface contains the events defined in the ERC.
*/
interface IERC1967 {
/**
* @dev Emitted when the implementation is upgraded.
*/
event Upgraded(address indexed implementation);
/**
* @dev Emitted when the admin account has changed.
*/
event AdminChanged(address previousAdmin, address newAdmin);
/**
* @dev Emitted when the beacon is changed.
*/
event BeaconUpgraded(address indexed beacon);
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (interfaces/IERC20.sol)
pragma solidity ^0.8.20;
import {IERC20} from "../token/ERC20/IERC20.sol";// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (proxy/beacon/IBeacon.sol)
pragma solidity ^0.8.20;
/**
* @dev This is the interface that {BeaconProxy} expects of its beacon.
*/
interface IBeacon {
/**
* @dev Must return an address that can be used as a delegate call target.
*
* {UpgradeableBeacon} will check that this address is a contract.
*/
function implementation() external view returns (address);
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.2.0) (proxy/ERC1967/ERC1967Utils.sol)
pragma solidity ^0.8.22;
import {IBeacon} from "../beacon/IBeacon.sol";
import {IERC1967} from "../../interfaces/IERC1967.sol";
import {Address} from "../../utils/Address.sol";
import {StorageSlot} from "../../utils/StorageSlot.sol";
/**
* @dev This library provides getters and event emitting update functions for
* https://eips.ethereum.org/EIPS/eip-1967[ERC-1967] slots.
*/
library ERC1967Utils {
/**
* @dev Storage slot with the address of the current implementation.
* This is the keccak-256 hash of "eip1967.proxy.implementation" subtracted by 1.
*/
// solhint-disable-next-line private-vars-leading-underscore
bytes32 internal constant IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;
/**
* @dev The `implementation` of the proxy is invalid.
*/
error ERC1967InvalidImplementation(address implementation);
/**
* @dev The `admin` of the proxy is invalid.
*/
error ERC1967InvalidAdmin(address admin);
/**
* @dev The `beacon` of the proxy is invalid.
*/
error ERC1967InvalidBeacon(address beacon);
/**
* @dev An upgrade function sees `msg.value > 0` that may be lost.
*/
error ERC1967NonPayable();
/**
* @dev Returns the current implementation address.
*/
function getImplementation() internal view returns (address) {
return StorageSlot.getAddressSlot(IMPLEMENTATION_SLOT).value;
}
/**
* @dev Stores a new address in the ERC-1967 implementation slot.
*/
function _setImplementation(address newImplementation) private {
if (newImplementation.code.length == 0) {
revert ERC1967InvalidImplementation(newImplementation);
}
StorageSlot.getAddressSlot(IMPLEMENTATION_SLOT).value = newImplementation;
}
/**
* @dev Performs implementation upgrade with additional setup call if data is nonempty.
* This function is payable only if the setup call is performed, otherwise `msg.value` is rejected
* to avoid stuck value in the contract.
*
* Emits an {IERC1967-Upgraded} event.
*/
function upgradeToAndCall(address newImplementation, bytes memory data) internal {
_setImplementation(newImplementation);
emit IERC1967.Upgraded(newImplementation);
if (data.length > 0) {
Address.functionDelegateCall(newImplementation, data);
} else {
_checkNonPayable();
}
}
/**
* @dev Storage slot with the admin of the contract.
* This is the keccak-256 hash of "eip1967.proxy.admin" subtracted by 1.
*/
// solhint-disable-next-line private-vars-leading-underscore
bytes32 internal constant ADMIN_SLOT = 0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103;
/**
* @dev Returns the current admin.
*
* TIP: To get this value clients can read directly from the storage slot shown below (specified by ERC-1967) using
* the https://eth.wiki/json-rpc/API#eth_getstorageat[`eth_getStorageAt`] RPC call.
* `0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103`
*/
function getAdmin() internal view returns (address) {
return StorageSlot.getAddressSlot(ADMIN_SLOT).value;
}
/**
* @dev Stores a new address in the ERC-1967 admin slot.
*/
function _setAdmin(address newAdmin) private {
if (newAdmin == address(0)) {
revert ERC1967InvalidAdmin(address(0));
}
StorageSlot.getAddressSlot(ADMIN_SLOT).value = newAdmin;
}
/**
* @dev Changes the admin of the proxy.
*
* Emits an {IERC1967-AdminChanged} event.
*/
function changeAdmin(address newAdmin) internal {
emit IERC1967.AdminChanged(getAdmin(), newAdmin);
_setAdmin(newAdmin);
}
/**
* @dev The storage slot of the UpgradeableBeacon contract which defines the implementation for this proxy.
* This is the keccak-256 hash of "eip1967.proxy.beacon" subtracted by 1.
*/
// solhint-disable-next-line private-vars-leading-underscore
bytes32 internal constant BEACON_SLOT = 0xa3f0ad74e5423aebfd80d3ef4346578335a9a72aeaee59ff6cb3582b35133d50;
/**
* @dev Returns the current beacon.
*/
function getBeacon() internal view returns (address) {
return StorageSlot.getAddressSlot(BEACON_SLOT).value;
}
/**
* @dev Stores a new beacon in the ERC-1967 beacon slot.
*/
function _setBeacon(address newBeacon) private {
if (newBeacon.code.length == 0) {
revert ERC1967InvalidBeacon(newBeacon);
}
StorageSlot.getAddressSlot(BEACON_SLOT).value = newBeacon;
address beaconImplementation = IBeacon(newBeacon).implementation();
if (beaconImplementation.code.length == 0) {
revert ERC1967InvalidImplementation(beaconImplementation);
}
}
/**
* @dev Change the beacon and trigger a setup call if data is nonempty.
* This function is payable only if the setup call is performed, otherwise `msg.value` is rejected
* to avoid stuck value in the contract.
*
* Emits an {IERC1967-BeaconUpgraded} event.
*
* CAUTION: Invoking this function has no effect on an instance of {BeaconProxy} since v5, since
* it uses an immutable beacon without looking at the value of the ERC-1967 beacon slot for
* efficiency.
*/
function upgradeBeaconToAndCall(address newBeacon, bytes memory data) internal {
_setBeacon(newBeacon);
emit IERC1967.BeaconUpgraded(newBeacon);
if (data.length > 0) {
Address.functionDelegateCall(IBeacon(newBeacon).implementation(), data);
} else {
_checkNonPayable();
}
}
/**
* @dev Reverts if `msg.value` is not zero. It can be used to avoid `msg.value` stuck in the contract
* if an upgrade doesn't perform an initialization call.
*/
function _checkNonPayable() private {
if (msg.value > 0) {
revert ERC1967NonPayable();
}
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.1.0) (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/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/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.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) (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.2.0) (utils/Address.sol)
pragma solidity ^0.8.20;
import {Errors} from "./Errors.sol";
/**
* @dev Collection of functions related to the address type
*/
library Address {
/**
* @dev There's no code at `target` (it is not a contract).
*/
error AddressEmptyCode(address target);
/**
* @dev Replacement for Solidity's `transfer`: sends `amount` wei to
* `recipient`, forwarding all available gas and reverting on errors.
*
* https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost
* of certain opcodes, possibly making contracts go over the 2300 gas limit
* imposed by `transfer`, making them unable to receive funds via
* `transfer`. {sendValue} removes this limitation.
*
* https://consensys.net/diligence/blog/2019/09/stop-using-soliditys-transfer-now/[Learn more].
*
* IMPORTANT: because control is transferred to `recipient`, care must be
* taken to not create reentrancy vulnerabilities. Consider using
* {ReentrancyGuard} or the
* https://solidity.readthedocs.io/en/v0.8.20/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].
*/
function sendValue(address payable recipient, uint256 amount) internal {
if (address(this).balance < amount) {
revert Errors.InsufficientBalance(address(this).balance, amount);
}
(bool success, bytes memory returndata) = recipient.call{value: amount}("");
if (!success) {
_revert(returndata);
}
}
/**
* @dev Performs a Solidity function call using a low level `call`. A
* plain `call` is an unsafe replacement for a function call: use this
* function instead.
*
* If `target` reverts with a revert reason or custom error, it is bubbled
* up by this function (like regular Solidity function calls). However, if
* the call reverted with no returned reason, this function reverts with a
* {Errors.FailedCall} error.
*
* Returns the raw returned data. To convert to the expected return value,
* use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].
*
* Requirements:
*
* - `target` must be a contract.
* - calling `target` with `data` must not revert.
*/
function functionCall(address target, bytes memory data) internal returns (bytes memory) {
return functionCallWithValue(target, data, 0);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but also transferring `value` wei to `target`.
*
* Requirements:
*
* - the calling contract must have an ETH balance of at least `value`.
* - the called Solidity function must be `payable`.
*/
function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) {
if (address(this).balance < value) {
revert Errors.InsufficientBalance(address(this).balance, value);
}
(bool success, bytes memory returndata) = target.call{value: value}(data);
return verifyCallResultFromTarget(target, success, returndata);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but performing a static call.
*/
function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {
(bool success, bytes memory returndata) = target.staticcall(data);
return verifyCallResultFromTarget(target, success, returndata);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but performing a delegate call.
*/
function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {
(bool success, bytes memory returndata) = target.delegatecall(data);
return verifyCallResultFromTarget(target, success, returndata);
}
/**
* @dev Tool to verify that a low level call to smart-contract was successful, and reverts if the target
* was not a contract or bubbling up the revert reason (falling back to {Errors.FailedCall}) in case
* of an unsuccessful call.
*/
function verifyCallResultFromTarget(
address target,
bool success,
bytes memory returndata
) internal view returns (bytes memory) {
if (!success) {
_revert(returndata);
} else {
// only check if target is a contract if the call was successful and the return data is empty
// otherwise we already know that it was a contract
if (returndata.length == 0 && target.code.length == 0) {
revert AddressEmptyCode(target);
}
return returndata;
}
}
/**
* @dev Tool to verify that a low level call was successful, and reverts if it wasn't, either by bubbling the
* revert reason or with a default {Errors.FailedCall} error.
*/
function verifyCallResult(bool success, bytes memory returndata) internal pure returns (bytes memory) {
if (!success) {
_revert(returndata);
} else {
return returndata;
}
}
/**
* @dev Reverts with returndata if present. Otherwise reverts with {Errors.FailedCall}.
*/
function _revert(bytes memory returndata) private pure {
// Look for revert reason and bubble it up if present
if (returndata.length > 0) {
// The easiest way to bubble the revert reason is using memory via assembly
assembly ("memory-safe") {
let returndata_size := mload(returndata)
revert(add(32, returndata), returndata_size)
}
} else {
revert Errors.FailedCall();
}
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.1.0) (utils/Errors.sol)
pragma solidity ^0.8.20;
/**
* @dev Collection of common custom errors used in multiple contracts
*
* IMPORTANT: Backwards compatibility is not guaranteed in future versions of the library.
* It is recommended to avoid relying on the error API for critical functionality.
*
* _Available since v5.1._
*/
library Errors {
/**
* @dev The ETH balance of the account is not enough to perform the operation.
*/
error InsufficientBalance(uint256 balance, uint256 needed);
/**
* @dev A call to an address target failed. The target may have reverted.
*/
error FailedCall();
/**
* @dev The deployment failed.
*/
error FailedDeployment();
/**
* @dev A necessary precompile is missing.
*/
error MissingPrecompile(address);
}// 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/ReentrancyGuard.sol)
pragma solidity ^0.8.20;
/**
* @dev Contract module that helps prevent reentrant calls to a function.
*
* Inheriting from `ReentrancyGuard` will make the {nonReentrant} modifier
* available, which can be applied to functions to make sure there are no nested
* (reentrant) calls to them.
*
* Note that because there is a single `nonReentrant` guard, functions marked as
* `nonReentrant` may not call one another. This can be worked around by making
* those functions `private`, and then adding `external` `nonReentrant` entry
* points to them.
*
* TIP: If EIP-1153 (transient storage) is available on the chain you're deploying at,
* consider using {ReentrancyGuardTransient} instead.
*
* TIP: If you would like to learn more about reentrancy and alternative ways
* to protect against it, check out our blog post
* https://blog.openzeppelin.com/reentrancy-after-istanbul/[Reentrancy After Istanbul].
*/
abstract contract ReentrancyGuard {
// Booleans are more expensive than uint256 or any type that takes up a full
// word because each write operation emits an extra SLOAD to first read the
// slot's contents, replace the bits taken up by the boolean, and then write
// back. This is the compiler's defense against contract upgrades and
// pointer aliasing, and it cannot be disabled.
// The values being non-zero value makes deployment a bit more expensive,
// but in exchange the refund on every call to nonReentrant will be lower in
// amount. Since refunds are capped to a percentage of the total
// transaction's gas, it is best to keep them low in cases like this one, to
// increase the likelihood of the full refund coming into effect.
uint256 private constant NOT_ENTERED = 1;
uint256 private constant ENTERED = 2;
uint256 private _status;
/**
* @dev Unauthorized reentrant call.
*/
error ReentrancyGuardReentrantCall();
constructor() {
_status = NOT_ENTERED;
}
/**
* @dev Prevents a contract from calling itself, directly or indirectly.
* Calling a `nonReentrant` function from another `nonReentrant`
* function is not supported. It is possible to prevent this from happening
* by making the `nonReentrant` function external, and making it call a
* `private` function that does the actual work.
*/
modifier nonReentrant() {
_nonReentrantBefore();
_;
_nonReentrantAfter();
}
function _nonReentrantBefore() private {
// On the first call to nonReentrant, _status will be NOT_ENTERED
if (_status == ENTERED) {
revert ReentrancyGuardReentrantCall();
}
// Any calls to nonReentrant after this point will fail
_status = ENTERED;
}
function _nonReentrantAfter() private {
// By storing the original value once again, a refund is triggered (see
// https://eips.ethereum.org/EIPS/eip-2200)
_status = NOT_ENTERED;
}
/**
* @dev Returns true if the reentrancy guard is currently set to "entered", which indicates there is a
* `nonReentrant` function in the call stack.
*/
function _reentrancyGuardEntered() internal view returns (bool) {
return _status == ENTERED;
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.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
pragma solidity ^0.8.20;
import {IERC1155} from "@openzeppelin/contracts/token/ERC1155/IERC1155.sol";
import {IERC721} from "@openzeppelin/contracts/token/ERC721/IERC721.sol";
import {IWETH} from "../interfaces/IPool.sol";
import {Signature} from "./Signature.sol";
/// @title Helpers Contract
/// @notice Contains utility functions for pool operations and calculations
/// @dev Provides OpenSea integration, mathematical operations, and NFT handling
/// @author UsePools Team
contract Helpers is Signature {
// Constants
/// @dev OpenSea Seaport address for marketplace interactions
/// @notice This is the main OpenSea contract for executing trades
/// @notice Tracks used message hashes to prevent replay attacks
/// @dev Maps hash to boolean indicating if it has been used
mapping(bytes32 => bool) public hashUsed;
// Custom errors
/// @notice Thrown when signature length is invalid
error InvalidSignatureLength();
/// @notice Thrown when signature recovery value 'v' is invalid
error InvalidSignatureV();
/// @notice Thrown when an external call fails
error CallFailed();
/// @notice Thrown when fee transfer fails
error FEE_FAILED();
/// @notice Thrown when signature validation fails
error INVALID_SIGNATURE();
/// @notice Executes OpenSea marketplace data
/// @dev Makes a low-level call to OpenSea Seaport with provided data
/// @param data The encoded transaction data for OpenSea
/// @param value The amount of ETH to send with the transaction
/// @return success Whether the execution was successful
function _execOpenseaData(
bytes calldata data,
uint256 value,
address OPENSEA
) internal returns (bool) {
(bool success, bytes memory returnData) = OPENSEA.call{value: value}(
data
);
if (!success) {
assembly {
let returndata_size := mload(returnData)
revert(add(32, returnData), returndata_size)
}
}
return success;
}
/// @notice Checks ownership of an NFT
/// @dev Supports both ERC721 and ERC1155 standards
/// @param _tokenId The token ID to check ownership for
/// @param _collectionToBuy The NFT collection contract address
/// @param _isERC721 True if ERC721, false if ERC1155
/// @return bool True if this contract owns the specified token
function _isOwnerOfNFT(
uint256 _tokenId,
address _collectionToBuy,
bool _isERC721
) internal view returns (bool) {
return
_isERC721
? IERC721(_collectionToBuy).ownerOf(_tokenId) == address(this)
: IERC1155(_collectionToBuy).balanceOf(
address(this),
_tokenId
) > 0;
}
/// @notice Approves WETH for the conduit
function _approveWETH(
IWETH WETH,
address _conduit
) internal returns (bool) {
WETH.approve(_conduit, type(uint256).max);
return true;
}
function _depositWETH(IWETH WETH, uint256 amount) internal {
WETH.deposit{value: amount}();
}
function _withdrawWETH(IWETH WETH, uint256 amount) internal {
WETH.withdraw(amount);
}
function _getWETHBalance(IWETH WETH) internal view returns (uint256) {
return WETH.balanceOf(address(this));
}
/// @notice Approves an NFT for transfer
/// @param _isERC721 Whether the token is ERC721
/// @param _collectionToBuy The collection address
/// @param _tokenId The token ID to approve
function _approveNFT(
bool _isERC721,
address _collectionToBuy,
uint256 _tokenId,
address _conduit
) internal {
if (_isERC721) {
IERC721(_collectionToBuy).approve(_conduit, _tokenId);
} else {
IERC1155(_collectionToBuy).setApprovalForAll(_conduit, true);
}
}
function _transferNFT(
address collection,
uint256 tokenId,
bool isERC721,
address from,
address to
) internal {
if (isERC721) {
IERC721(collection).transferFrom(from, to, tokenId);
} else {
IERC1155(collection).safeTransferFrom(from, to, tokenId, 1, "");
}
}
function _transferETH(address to, uint256 amount) internal {
(bool success, ) = payable(to).call{value: amount}("");
if (!success) revert CallFailed();
}
function _getUserShare(
uint256 userContribution,
uint256 totalContributed
) internal pure returns (uint256 contributionPercentage) {
if (userContribution == 0) return 0;
assembly {
if iszero(totalContributed) {
revert(0, 0)
}
let scaledContribution := mul(userContribution, 10000)
contributionPercentage := div(scaledContribution, totalContributed)
}
}
function _getClaimableAmount(
uint256 totalClaimable,
uint256 userContribution,
uint256 totalContributed
) public pure returns (uint256 claimableAmount) {
uint256 userShare = _getUserShare(userContribution, totalContributed);
claimableAmount = (totalClaimable * userShare) / 10000;
}
function _getNetPrice(
uint256 protocolFee,
uint256 totalPrice
) internal pure returns (uint256 netPrice, uint256 feeAmount) {
netPrice = (totalPrice * 1e18) / (1e18 + protocolFee);
feeAmount = totalPrice - netPrice;
}
function _handleBuyFee(
uint256 protocolFee,
uint256 buyPrice,
address feeReceiver
) internal returns (uint256) {
(uint256 netPrice, uint256 protocolFeeAmount) = _getNetPrice(
protocolFee,
buyPrice
);
(bool success, ) = payable(feeReceiver).call{value: protocolFeeAmount}(
""
);
if (!success) revert FEE_FAILED();
return netPrice;
}
function _processReceivedAmount(
uint256 receiveAmount,
uint256 protocolFee,
uint256 creatorFee,
uint256 buyPrice
)
internal
pure
returns (uint256 userShare, uint256 protocolShare, uint256 creatorShare)
{
protocolShare = (receiveAmount * protocolFee) / 1e18;
creatorShare = (receiveAmount > buyPrice)
? ((receiveAmount - buyPrice) * creatorFee) / 1e18
: 0;
userShare = receiveAmount - protocolShare - creatorShare;
}
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.24;
/// @title Signature Utilities Contract
/// @notice Provides low-level signature handling utilities
/// @dev Contains functions for signature splitting and signer recovery
/// @author UsePools Team
contract Signature {
/// @notice Splits a signature into its r, s, v components
/// @dev Signature must be exactly 65 bytes (32 + 32 + 1)
/// @param sig The signature bytes to split
/// @return r First 32 bytes of the signature
/// @return s Second 32 bytes of the signature
/// @return v Recovery identifier (27 or 28)
function splitSignature(
bytes memory sig
) internal pure returns (bytes32 r, bytes32 s, uint8 v) {
require(sig.length == 65, "invalid signature length");
assembly {
r := mload(add(sig, 32))
s := mload(add(sig, 64))
v := byte(0, mload(add(sig, 96)))
}
}
/// @notice Recovers the signer address from a message hash and signature
/// @dev Uses ecrecover with the split signature components
/// @param _ethSignedMessageHash The Ethereum signed message hash
/// @param _signature The signature bytes
/// @return address The recovered signer address
function _recoverSigner(
bytes32 _ethSignedMessageHash,
bytes memory _signature
) internal pure returns (address) {
(bytes32 r, bytes32 s, uint8 v) = splitSignature(_signature);
return ecrecover(_ethSignedMessageHash, v, r, s);
}
}// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.24;
/// @title Struct Definitions
/// @notice Contains all data structures and enums used across the UsePools protocol
/// @dev Centralized location for type definitions to ensure consistency
/// @author UsePools Team
/// @notice Structure containing comprehensive pool information
/// @dev Used for returning complete pool state in view functions
struct Pool {
address creator;
address escrow;
address collection;
uint256 totalContributed;
uint256 creatorFee;
bool offerIsAllowed;
bool listingIsAllowed;
PoolState state;
}
/// @notice Parameters required for purchasing an NFT
/// @dev Used in buyTargetPool function to encapsulate purchase details
struct BuyParams {
bool isERC721;
uint256 tokenId;
uint256 buyPrice;
}
/// @notice Possible states of a pool throughout its lifecycle
/// @dev Used to control which operations are allowed at each stage
enum PoolState {
INACTIVE,
ACTIVE,
BOUGHT,
SOLD,
DIRECT_TOKENIZATION
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;
import {PoolState} from "./Struct.sol";
import {Helpers} from "./Helpers.sol";
/// @title Validation Contract
/// @notice Provides validation functions for pool operations and state management
/// @dev Contains all validation logic to ensure secure pool operations
/// @author UsePools Team
contract Validation is Helpers {
/// @notice Thrown when pool is in an invalid state for the requested operation
error INVALID_STATE();
/// @notice Thrown when an amount is zero or invalid
error INVALID_AMOUNT();
/// @notice Thrown when a condition check fails
error INVALID_CONDITION();
/// @notice Thrown when NFT ownership validation fails
error INVALID_OWNERSHIP();
/// @notice Thrown when an address is zero
error INVALID_ADDRESS();
/// @notice Validates that the pool is in the required state
/// @dev Used to ensure operations are only performed in appropriate pool states
/// @param state Current pool state
/// @param requiredState Required state for the operation
function _checkState(
PoolState state,
PoolState requiredState
) internal pure {
if (state != requiredState) revert INVALID_STATE();
}
/// @notice Validates that an amount is greater than zero
/// @dev Prevents zero-value operations that could cause issues
/// @param amount The amount to validate
function _checkAmount(uint256 amount) internal pure {
if (amount == 0) revert INVALID_AMOUNT();
}
function _checkAddress(address addressToCheck) internal pure {
if (addressToCheck == address(0)) revert INVALID_ADDRESS();
}
function _checkInvestment(PoolState state, uint256 amount) internal pure {
_checkState(state, PoolState.ACTIVE);
_checkAmount(amount);
}
function _compareAmount(
uint256 inferiorAmount,
uint256 superiorAmount
) internal pure {
if (inferiorAmount > superiorAmount) revert INVALID_AMOUNT();
}
function _checkWithdraw(
PoolState state,
uint256 amount,
uint256 userContributionAmount
) internal pure {
_checkState(state, PoolState.ACTIVE);
_checkAmount(amount);
_compareAmount(amount, userContributionAmount);
}
function _checkCreator(address creator, address sender) internal pure {
if (sender != creator) revert INVALID_CONDITION();
}
function _checkCondition(bool condition, bool expected) internal pure {
if (condition != expected) revert INVALID_CONDITION();
}
function _checkOffer(PoolState state, bool offerIsAllowed) internal pure {
_checkState(state, PoolState.ACTIVE);
_checkCondition(offerIsAllowed, false);
}
function _checkBuy(
PoolState state,
uint256 buyPrice,
uint256 totalContributed,
address OPENSEA
) internal pure {
_checkState(state, PoolState.ACTIVE);
_compareAmount(buyPrice, totalContributed);
_checkAddress(OPENSEA);
}
function _checkOwnership(
address collection,
uint256 tokenId,
bool isERC721
) internal view {
if (!_isOwnerOfNFT(tokenId, collection, isERC721))
revert INVALID_OWNERSHIP();
}
function _checkNotOwner(
address collection,
uint256 tokenId,
bool isERC721
) internal view {
if (_isOwnerOfNFT(tokenId, collection, isERC721))
revert INVALID_OWNERSHIP();
}
function _checkTargetBought(
uint256 tokenId,
address collection,
bool isERC721,
bool offerIsAllowed,
PoolState state
) internal view {
_checkState(state, PoolState.ACTIVE);
_checkCondition(offerIsAllowed, true);
_checkOwnership(collection, tokenId, isERC721);
}
function _checkAllowAcceptOffer(
PoolState state,
address collection,
uint256 tokenId,
bool isERC721
) internal view {
_checkState(state, PoolState.BOUGHT);
_checkOwnership(collection, tokenId, isERC721);
}
function _checkAllowListTargetPool(
PoolState state,
address collection,
uint256 tokenId,
bool isERC721,
bool listingIsAllowed
) internal view {
_checkState(state, PoolState.BOUGHT);
_checkOwnership(collection, tokenId, isERC721);
_checkCondition(listingIsAllowed, false);
}
function _checkAllowCancelOrder(PoolState state) internal pure {
_checkState(state, PoolState.BOUGHT);
}
function _checkForcePoolIsSolded(
PoolState state,
address collection,
uint256 tokenId,
bool isERC721
) internal view {
_checkState(state, PoolState.BOUGHT);
if (_isOwnerOfNFT(tokenId, collection, isERC721))
revert INVALID_OWNERSHIP();
}
function _checkWithdrawExcess(
PoolState state,
uint256 excessAmount,
uint256 userBalance
) internal pure {
_checkState(state, PoolState.BOUGHT);
_checkAmount(excessAmount);
_checkAmount(userBalance);
}
function _checkAllowRedeem(
PoolState state,
uint256 claimableAmount,
bool userHasAlreadyClaim
) internal pure {
_checkState(state, PoolState.SOLD);
_checkAmount(claimableAmount);
_checkCondition(userHasAlreadyClaim, false);
}
function _checkRedeemCreatorFees(
PoolState state,
uint256 creatorFees,
address msgSender,
address creator
) internal pure {
_checkState(state, PoolState.SOLD);
_checkAmount(creatorFees);
_checkCreator(creator, msgSender);
}
function _checkTransferUserContributions(
PoolState state,
uint256 amount,
uint256 userContributionAmount
) internal pure {
_checkState(state, PoolState.BOUGHT);
_checkAmount(amount);
_compareAmount(amount, userContributionAmount);
}
function _checkAllowDepositNFT(
PoolState state,
address collection,
address creator,
uint256 tokenId,
bool isERC721
) internal view {
_checkState(state, PoolState.DIRECT_TOKENIZATION);
_checkCreator(creator, msg.sender);
_checkNotOwner(collection, tokenId, isERC721);
}
function _checkTokenIsNotWETH(
address tokenAddress,
address weth
) internal pure {
if (tokenAddress == address(weth)) revert INVALID_CONDITION();
}
function _checkAllowWithdrawNFT(
PoolState state,
address collection,
bool isERC721,
uint256 tokenId,
uint256 totalSupply,
uint256 balanceOfOwner
) internal view {
_checkState(state, PoolState.BOUGHT);
_checkOwnership(collection, tokenId, isERC721);
_compareAmount(totalSupply, balanceOfOwner);
}
function _checkAllowDirectTokenization(
PoolState state,
uint256 totalSupply,
address msgSender,
address creator
) internal pure {
_checkState(state, PoolState.ACTIVE);
_checkCondition(totalSupply == 0, true);
_checkCreator(creator, msgSender);
}
function _checkResetPool(
PoolState state,
uint256 totalClaimable,
address msgSender,
address creator
) internal pure {
_checkState(state, PoolState.SOLD);
_checkCondition(totalClaimable == 0, true);
_checkCreator(creator, msgSender);
}
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;
interface IWETH {
function deposit() external payable;
function withdraw(uint wad) external;
function approve(address guy, uint wad) external returns (bool);
function balanceOf(address) external view returns (uint256);
}
interface IDelegateRegistry {
function delegateAll(
address to,
bytes32 rights,
bool enable
) external payable returns (bytes32 delegationHash);
}
interface IUsePools_main {
function getProtocolFee() external view returns (uint256);
function getProtocolFeeReceiver() external view returns (address);
function getConduit() external view returns (address);
function getOpensea() external view returns (address);
function getOracle(address) external view returns (bool);
function _verifyOracleSignature(
bytes32 messageHash,
bytes memory signature
) external;
}{
"viaIR": true,
"optimizer": {
"enabled": true,
"runs": 200
},
"evmVersion": "paris",
"outputSelection": {
"*": {
"*": [
"evm.bytecode",
"evm.deployedBytecode",
"devdoc",
"userdoc",
"metadata",
"abi"
]
}
},
"libraries": {}
}Contract ABI
API[{"inputs":[],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[{"internalType":"address","name":"target","type":"address"}],"name":"AddressEmptyCode","type":"error"},{"inputs":[],"name":"CALL_FAILED","type":"error"},{"inputs":[],"name":"CallFailed","type":"error"},{"inputs":[{"internalType":"address","name":"implementation","type":"address"}],"name":"ERC1967InvalidImplementation","type":"error"},{"inputs":[],"name":"ERC1967NonPayable","type":"error"},{"inputs":[{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"allowance","type":"uint256"},{"internalType":"uint256","name":"needed","type":"uint256"}],"name":"ERC20InsufficientAllowance","type":"error"},{"inputs":[{"internalType":"address","name":"sender","type":"address"},{"internalType":"uint256","name":"balance","type":"uint256"},{"internalType":"uint256","name":"needed","type":"uint256"}],"name":"ERC20InsufficientBalance","type":"error"},{"inputs":[{"internalType":"address","name":"approver","type":"address"}],"name":"ERC20InvalidApprover","type":"error"},{"inputs":[{"internalType":"address","name":"receiver","type":"address"}],"name":"ERC20InvalidReceiver","type":"error"},{"inputs":[{"internalType":"address","name":"sender","type":"address"}],"name":"ERC20InvalidSender","type":"error"},{"inputs":[{"internalType":"address","name":"spender","type":"address"}],"name":"ERC20InvalidSpender","type":"error"},{"inputs":[],"name":"FEE_FAILED","type":"error"},{"inputs":[],"name":"FailedCall","type":"error"},{"inputs":[],"name":"INVALID_ADDRESS","type":"error"},{"inputs":[],"name":"INVALID_AMOUNT","type":"error"},{"inputs":[],"name":"INVALID_CONDITION","type":"error"},{"inputs":[],"name":"INVALID_OWNERSHIP","type":"error"},{"inputs":[],"name":"INVALID_SIGNATURE","type":"error"},{"inputs":[],"name":"INVALID_STATE","type":"error"},{"inputs":[],"name":"InvalidInitialization","type":"error"},{"inputs":[],"name":"InvalidSignatureLength","type":"error"},{"inputs":[],"name":"InvalidSignatureV","type":"error"},{"inputs":[],"name":"NOT_IN_THE_POOL","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":"ReentrancyGuardReentrantCall","type":"error"},{"inputs":[{"internalType":"address","name":"token","type":"address"}],"name":"SafeERC20FailedOperation","type":"error"},{"inputs":[],"name":"UUPSUnauthorizedCallContext","type":"error"},{"inputs":[{"internalType":"bytes32","name":"slot","type":"bytes32"}],"name":"UUPSUnsupportedProxiableUUID","type":"error"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"owner","type":"address"},{"indexed":true,"internalType":"address","name":"spender","type":"address"},{"indexed":false,"internalType":"uint256","name":"value","type":"uint256"}],"name":"Approval","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"user","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"ExcessAmountRedeemed","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint64","name":"version","type":"uint64"}],"name":"Initialized","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":"participant","type":"address"},{"indexed":false,"internalType":"int256","name":"contribution","type":"int256"}],"name":"ParticipationUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"poolAddress","type":"address"},{"indexed":false,"internalType":"uint256","name":"buyPrice","type":"uint256"}],"name":"PoolBought","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"creator","type":"address"},{"indexed":false,"internalType":"address","name":"nftCollection","type":"address"}],"name":"PoolCreated","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"from","type":"address"},{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":false,"internalType":"uint256","name":"value","type":"uint256"}],"name":"Transfer","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"implementation","type":"address"}],"name":"Upgraded","type":"event"},{"inputs":[],"name":"MIN_INVESTMENT","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"UPGRADE_INTERFACE_VERSION","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"totalClaimable","type":"uint256"},{"internalType":"uint256","name":"userContribution","type":"uint256"},{"internalType":"uint256","name":"totalContributed","type":"uint256"}],"name":"_getClaimableAmount","outputs":[{"internalType":"uint256","name":"claimableAmount","type":"uint256"}],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"address","name":"user","type":"address"}],"name":"_userIsInThePool","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes","name":"_data","type":"bytes"},{"internalType":"uint256","name":"nonce","type":"uint256"},{"internalType":"bytes","name":"oracleSignature","type":"bytes"}],"name":"acceptOffer","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"nonce","type":"uint256"},{"internalType":"bytes","name":"oracleSignature","type":"bytes"}],"name":"allowOffer","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"},{"internalType":"address","name":"spender","type":"address"}],"name":"allowance","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"value","type":"uint256"}],"name":"approve","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"balanceOf","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"buyPrice","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"components":[{"internalType":"bool","name":"isERC721","type":"bool"},{"internalType":"uint256","name":"tokenId","type":"uint256"},{"internalType":"uint256","name":"buyPrice","type":"uint256"}],"internalType":"struct BuyParams","name":"buyParams","type":"tuple"},{"internalType":"uint256","name":"nonce","type":"uint256"},{"internalType":"bytes","name":"_data","type":"bytes"},{"internalType":"bytes","name":"oracleSignature","type":"bytes"}],"name":"buyTargetPool","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes","name":"_data","type":"bytes"},{"internalType":"bytes","name":"oracleSignature","type":"bytes"},{"internalType":"uint256","name":"nonce","type":"uint256"}],"name":"cancelOrder","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"claimCounter","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"claims","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"creator","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"creatorFee","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"creatorFees","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"decimals","outputs":[{"internalType":"uint8","name":"","type":"uint8"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bool","name":"isDelegated","type":"bool"}],"name":"delegation","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_tokenId","type":"uint256"},{"internalType":"bool","name":"_isERC721","type":"bool"}],"name":"depositNFT","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"excessAmount","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"nonce","type":"uint256"},{"internalType":"bytes","name":"oracleSignature","type":"bytes"}],"name":"forcePoolIsSolded","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"getPool","outputs":[{"components":[{"internalType":"address","name":"creator","type":"address"},{"internalType":"address","name":"escrow","type":"address"},{"internalType":"address","name":"collection","type":"address"},{"internalType":"uint256","name":"totalContributed","type":"uint256"},{"internalType":"uint256","name":"creatorFee","type":"uint256"},{"internalType":"bool","name":"offerIsAllowed","type":"bool"},{"internalType":"bool","name":"listingIsAllowed","type":"bool"},{"internalType":"enum PoolState","name":"state","type":"uint8"}],"internalType":"struct Pool","name":"","type":"tuple"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"name":"hashUsed","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_creator","type":"address"},{"internalType":"address","name":"_usePools_main","type":"address"},{"internalType":"address","name":"_weth","type":"address"},{"internalType":"address","name":"_nftCollection","type":"address"},{"internalType":"uint256","name":"_creatorFee","type":"uint256"},{"internalType":"string","name":"_name","type":"string"},{"internalType":"string","name":"_symbol","type":"string"},{"internalType":"bool","name":"isDirectTokenization","type":"bool"}],"name":"initialize","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"invest","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[],"name":"isERC721","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"_hash","type":"bytes32"},{"internalType":"bytes","name":"_signature","type":"bytes"}],"name":"isValidSignature","outputs":[{"internalType":"bytes4","name":"","type":"bytes4"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"nonce","type":"uint256"},{"internalType":"bytes","name":"oracleSignature","type":"bytes"}],"name":"listTargetPool","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"listingIsAllowed","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"name","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"nftCollection","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"offerIsAllowed","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_tokenId","type":"uint256"},{"internalType":"address","name":"_collectionToBuy","type":"address"},{"internalType":"bool","name":"_isERC721","type":"bool"}],"name":"ownTheTarget","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"proxiableUUID","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"claimId","type":"uint256"}],"name":"redeem","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"redeemCreatorFees","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"tokenAddress","type":"address"}],"name":"redeemERC20","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"redeemExcessAmount","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"setDirectTokenization","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"nonce","type":"uint256"},{"internalType":"address","name":"newCollection","type":"address"},{"internalType":"bytes","name":"oracleSignature","type":"bytes"}],"name":"setNewCollection","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_tokenId","type":"uint256"},{"internalType":"uint256","name":"nonce","type":"uint256"},{"internalType":"bool","name":"_isERC721","type":"bool"},{"internalType":"bytes","name":"oracleSignature","type":"bytes"}],"name":"setTargetBought","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"state","outputs":[{"internalType":"enum PoolState","name":"","type":"uint8"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"symbol","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"tokenId","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"totalClaimable","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"totalContributed","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"totalSupply","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"transfer","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"from","type":"address"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"transferFrom","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newImplementation","type":"address"},{"internalType":"bytes","name":"data","type":"bytes"}],"name":"upgradeToAndCall","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"userExcessClaimed","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"uint256","name":"","type":"uint256"}],"name":"userHasAlreadyClaim","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"userHasAlreadyRedeemedExcessAmount","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"withdraw","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"withdrawNFT","outputs":[],"stateMutability":"nonpayable","type":"function"},{"stateMutability":"payable","type":"receive"}]Loading...
Loading
Loading...
Loading
Loading...
Loading
Net Worth in USD
$0.00
Net Worth in ETH
0
Multichain Portfolio | 35 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.