// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (utils/Address.sol)
pragma solidity ^0.8.20;
/**
* @dev Collection of functions related to the address type
*/
library Address {
/**
* @dev The ETH balance of the account is not enough to perform the operation.
*/
error AddressInsufficientBalance(address account);
/**
* @dev There's no code at `target` (it is not a contract).
*/
error AddressEmptyCode(address target);
/**
* @dev A call to an address target failed. The target may have reverted.
*/
error FailedInnerCall();
/**
* @dev Replacement for Solidity's `transfer`: sends `amount` wei to
* `recipient`, forwarding all available gas and reverting on errors.
*
* https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost
* of certain opcodes, possibly making contracts go over the 2300 gas limit
* imposed by `transfer`, making them unable to receive funds via
* `transfer`. {sendValue} removes this limitation.
*
* https://consensys.net/diligence/blog/2019/09/stop-using-soliditys-transfer-now/[Learn more].
*
* IMPORTANT: because control is transferred to `recipient`, care must be
* taken to not create reentrancy vulnerabilities. Consider using
* {ReentrancyGuard} or the
* https://solidity.readthedocs.io/en/v0.8.20/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].
*/
function sendValue(address payable recipient, uint256 amount) internal {
if (address(this).balance < amount) {
revert AddressInsufficientBalance(address(this));
}
(bool success, ) = recipient.call{value: amount}("");
if (!success) {
revert FailedInnerCall();
}
}
/**
* @dev Performs a Solidity function call using a low level `call`. A
* plain `call` is an unsafe replacement for a function call: use this
* function instead.
*
* If `target` reverts with a revert reason or custom error, it is bubbled
* up by this function (like regular Solidity function calls). However, if
* the call reverted with no returned reason, this function reverts with a
* {FailedInnerCall} error.
*
* Returns the raw returned data. To convert to the expected return value,
* use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].
*
* Requirements:
*
* - `target` must be a contract.
* - calling `target` with `data` must not revert.
*/
function functionCall(address target, bytes memory data) internal returns (bytes memory) {
return functionCallWithValue(target, data, 0);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but also transferring `value` wei to `target`.
*
* Requirements:
*
* - the calling contract must have an ETH balance of at least `value`.
* - the called Solidity function must be `payable`.
*/
function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) {
if (address(this).balance < value) {
revert AddressInsufficientBalance(address(this));
}
(bool success, bytes memory returndata) = target.call{value: value}(data);
return verifyCallResultFromTarget(target, success, returndata);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but performing a static call.
*/
function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {
(bool success, bytes memory returndata) = target.staticcall(data);
return verifyCallResultFromTarget(target, success, returndata);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but performing a delegate call.
*/
function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {
(bool success, bytes memory returndata) = target.delegatecall(data);
return verifyCallResultFromTarget(target, success, returndata);
}
/**
* @dev Tool to verify that a low level call to smart-contract was successful, and reverts if the target
* was not a contract or bubbling up the revert reason (falling back to {FailedInnerCall}) in case of an
* unsuccessful call.
*/
function verifyCallResultFromTarget(
address target,
bool success,
bytes memory returndata
) internal view returns (bytes memory) {
if (!success) {
_revert(returndata);
} else {
// only check if target is a contract if the call was successful and the return data is empty
// otherwise we already know that it was a contract
if (returndata.length == 0 && target.code.length == 0) {
revert AddressEmptyCode(target);
}
return returndata;
}
}
/**
* @dev Tool to verify that a low level call was successful, and reverts if it wasn't, either by bubbling the
* revert reason or with a default {FailedInnerCall} error.
*/
function verifyCallResult(bool success, bytes memory returndata) internal pure returns (bytes memory) {
if (!success) {
_revert(returndata);
} else {
return returndata;
}
}
/**
* @dev Reverts with returndata if present. Otherwise reverts with {FailedInnerCall}.
*/
function _revert(bytes memory returndata) private pure {
// Look for revert reason and bubble it up if present
if (returndata.length > 0) {
// The easiest way to bubble the revert reason is using memory via assembly
/// @solidity memory-safe-assembly
assembly {
let returndata_size := mload(returndata)
revert(add(32, returndata), returndata_size)
}
} else {
revert FailedInnerCall();
}
}
}
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.1) (utils/Context.sol)
pragma solidity ^0.8.20;
/**
* @dev Provides information about the current execution context, including the
* sender of the transaction and its data. While these are generally available
* via msg.sender and msg.data, they should not be accessed in such a direct
* manner, since when dealing with meta-transactions the account sending and
* paying for execution may not be the actual sender (as far as an application
* is concerned).
*
* This contract is only required for intermediate, library-like contracts.
*/
abstract contract Context {
function _msgSender() internal view virtual returns (address) {
return msg.sender;
}
function _msgData() internal view virtual returns (bytes calldata) {
return msg.data;
}
function _contextSuffixLength() internal view virtual returns (uint256) {
return 0;
}
}
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (utils/introspection/IERC165.sol)
pragma solidity ^0.8.20;
/**
* @dev Interface of the ERC165 standard, as defined in the
* https://eips.ethereum.org/EIPS/eip-165[EIP].
*
* Implementers can declare support of contract interfaces, which can then be
* queried by others ({ERC165Checker}).
*
* For an implementation, see {ERC165}.
*/
interface IERC165 {
/**
* @dev Returns true if this contract implements the interface defined by
* `interfaceId`. See the corresponding
* https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section]
* to learn more about how these ids are created.
*
* This function call must use less than 30 000 gas.
*/
function supportsInterface(bytes4 interfaceId) external view returns (bool);
}
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (token/ERC20/IERC20.sol)
pragma solidity ^0.8.20;
/**
* @dev Interface of the ERC20 standard as defined in the EIP.
*/
interface IERC20 {
/**
* @dev Emitted when `value` tokens are moved from one account (`from`) to
* another (`to`).
*
* Note that `value` may be zero.
*/
event Transfer(address indexed from, address indexed to, uint256 value);
/**
* @dev Emitted when the allowance of a `spender` for an `owner` is set by
* a call to {approve}. `value` is the new allowance.
*/
event Approval(address indexed owner, address indexed spender, uint256 value);
/**
* @dev Returns the value of tokens in existence.
*/
function totalSupply() external view returns (uint256);
/**
* @dev Returns the value of tokens owned by `account`.
*/
function balanceOf(address account) external view returns (uint256);
/**
* @dev Moves a `value` amount of tokens from the caller's account to `to`.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transfer(address to, uint256 value) external returns (bool);
/**
* @dev Returns the remaining number of tokens that `spender` will be
* allowed to spend on behalf of `owner` through {transferFrom}. This is
* zero by default.
*
* This value changes when {approve} or {transferFrom} are called.
*/
function allowance(address owner, address spender) external view returns (uint256);
/**
* @dev Sets a `value` amount of tokens as the allowance of `spender` over the
* caller's tokens.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* IMPORTANT: Beware that changing an allowance with this method brings the risk
* that someone may use both the old and the new allowance by unfortunate
* transaction ordering. One possible solution to mitigate this race
* condition is to first reduce the spender's allowance to 0 and set the
* desired value afterwards:
* https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
*
* Emits an {Approval} event.
*/
function approve(address spender, uint256 value) external returns (bool);
/**
* @dev Moves a `value` amount of tokens from `from` to `to` using the
* allowance mechanism. `value` is then deducted from the caller's
* allowance.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transferFrom(address from, address to, uint256 value) external returns (bool);
}
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (token/ERC20/extensions/IERC20Permit.sol)
pragma solidity ^0.8.20;
/**
* @dev Interface of the ERC20 Permit extension allowing approvals to be made via signatures, as defined in
* https://eips.ethereum.org/EIPS/eip-2612[EIP-2612].
*
* Adds the {permit} method, which can be used to change an account's ERC20 allowance (see {IERC20-allowance}) by
* presenting a message signed by the account. By not relying on {IERC20-approve}, the token holder account doesn't
* need to send a transaction, and thus is not required to hold Ether at all.
*
* ==== Security Considerations
*
* There are two important considerations concerning the use of `permit`. The first is that a valid permit signature
* expresses an allowance, and it should not be assumed to convey additional meaning. In particular, it should not be
* considered as an intention to spend the allowance in any specific way. The second is that because permits have
* built-in replay protection and can be submitted by anyone, they can be frontrun. A protocol that uses permits should
* take this into consideration and allow a `permit` call to fail. Combining these two aspects, a pattern that may be
* generally recommended is:
*
* ```solidity
* function doThingWithPermit(..., uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s) public {
* try token.permit(msg.sender, address(this), value, deadline, v, r, s) {} catch {}
* doThing(..., value);
* }
*
* function doThing(..., uint256 value) public {
* token.safeTransferFrom(msg.sender, address(this), value);
* ...
* }
* ```
*
* Observe that: 1) `msg.sender` is used as the owner, leaving no ambiguity as to the signer intent, and 2) the use of
* `try/catch` allows the permit to fail and makes the code tolerant to frontrunning. (See also
* {SafeERC20-safeTransferFrom}).
*
* Additionally, note that smart contract wallets (such as Argent or Safe) are not able to produce permit signatures, so
* contracts should have entry points that don't rely on permit.
*/
interface IERC20Permit {
/**
* @dev Sets `value` as the allowance of `spender` over ``owner``'s tokens,
* given ``owner``'s signed approval.
*
* IMPORTANT: The same issues {IERC20-approve} has related to transaction
* ordering also apply here.
*
* Emits an {Approval} event.
*
* Requirements:
*
* - `spender` cannot be the zero address.
* - `deadline` must be a timestamp in the future.
* - `v`, `r` and `s` must be a valid `secp256k1` signature from `owner`
* over the EIP712-formatted function arguments.
* - the signature must use ``owner``'s current nonce (see {nonces}).
*
* For more information on the signature format, see the
* https://eips.ethereum.org/EIPS/eip-2612#specification[relevant EIP
* section].
*
* CAUTION: See Security Considerations above.
*/
function permit(
address owner,
address spender,
uint256 value,
uint256 deadline,
uint8 v,
bytes32 r,
bytes32 s
) external;
/**
* @dev Returns the current nonce for `owner`. This value must be
* included whenever a signature is generated for {permit}.
*
* Every successful call to {permit} increases ``owner``'s nonce by one. This
* prevents a signature from being used multiple times.
*/
function nonces(address owner) external view returns (uint256);
/**
* @dev Returns the domain separator used in the encoding of the signature for {permit}, as defined by {EIP712}.
*/
// solhint-disable-next-line func-name-mixedcase
function DOMAIN_SEPARATOR() external view returns (bytes32);
}
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (token/ERC721/IERC721.sol)
pragma solidity ^0.8.20;
import {IERC165} from "../../utils/introspection/IERC165.sol";
/**
* @dev Required interface of an ERC721 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 ERC721 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 ERC721
* or else they may be permanently lost. Usage of {safeTransferFrom} prevents loss, though the caller must
* understand this adds an external call which potentially creates a reentrancy vulnerability.
*
* Requirements:
*
* - `from` cannot be the zero address.
* - `to` cannot be the zero address.
* - `tokenId` token must be owned by `from`.
* - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.
*
* Emits a {Transfer} event.
*/
function transferFrom(address from, address to, uint256 tokenId) external;
/**
* @dev Gives permission to `to` to transfer `tokenId` token to another account.
* The approval is cleared when the token is transferred.
*
* Only a single account can be approved at a time, so approving the zero address clears previous approvals.
*
* Requirements:
*
* - The caller must own the token or be an approved operator.
* - `tokenId` must exist.
*
* Emits an {Approval} event.
*/
function approve(address to, uint256 tokenId) external;
/**
* @dev Approve or remove `operator` as an operator for the caller.
* Operators can call {transferFrom} or {safeTransferFrom} for any token owned by the caller.
*
* Requirements:
*
* - The `operator` cannot be the address zero.
*
* Emits an {ApprovalForAll} event.
*/
function setApprovalForAll(address operator, bool approved) external;
/**
* @dev Returns the account approved for `tokenId` token.
*
* Requirements:
*
* - `tokenId` must exist.
*/
function getApproved(uint256 tokenId) external view returns (address operator);
/**
* @dev Returns if the `operator` is allowed to manage all of the assets of `owner`.
*
* See {setApprovalForAll}
*/
function isApprovedForAll(address owner, address operator) external view returns (bool);
}
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (token/ERC721/extensions/IERC721Enumerable.sol)
pragma solidity ^0.8.20;
import {IERC721} from "../IERC721.sol";
/**
* @title ERC-721 Non-Fungible Token Standard, optional enumeration extension
* @dev See https://eips.ethereum.org/EIPS/eip-721
*/
interface IERC721Enumerable is IERC721 {
/**
* @dev Returns the total amount of tokens stored by the contract.
*/
function totalSupply() external view returns (uint256);
/**
* @dev Returns a token ID owned by `owner` at a given `index` of its token list.
* Use along with {balanceOf} to enumerate all of ``owner``'s tokens.
*/
function tokenOfOwnerByIndex(address owner, uint256 index) external view returns (uint256);
/**
* @dev Returns a token ID at a given `index` of all the tokens stored by the contract.
* Use along with {totalSupply} to enumerate all tokens.
*/
function tokenByIndex(uint256 index) external view returns (uint256);
}
// SPDX-License-Identifier: MIT
pragma solidity =0.8.24;
import {IERC721Enumerable} from "@openzeppelin/contracts/token/ERC721/extensions/IERC721Enumerable.sol";
import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol";
interface INAP721SingleToken {
/**
* @dev Struct representing the data of a NFT
* @param owner The address of the NFT owner
* @param assuranceActivationPrice The price paid for activating assurance
* @param collateralActivationPrice The price paid for activating collateral
* @param assuranceDeactivationProfit The profit made from deactivating assurance
* @param collateralDeactivationProfit The profit made from deactivating collateral
*/
struct NftData {
address owner;
uint256 assuranceActivationPrice;
uint256 collateralActivationPrice;
uint256 assuranceDeactivationProfit;
uint256 collateralDeactivationProfit;
}
/**
* @dev Struct representing the data of a token activation.
* @param amountInA The amount of token A used for activation.
* @param amountInB The amount of token B used for activation.
* @param path The path of tokens exchanged during activation.
* @param totalAmountInA The total amount of token A spent for activation.
*/
struct ActivationData {
uint256 amountInA;
uint256 amountInB;
address[] path;
uint256 totalAmountInA;
}
/**
* @dev Emitted in case of emergency withdrawal.
* @param token The address of the token being withdrawn.
* @param to The address where the tokens are being withdrawn to.
* @param amount The amount of tokens being withdrawn.
*/
event EmergencyWithdraw(address token, address to, uint256 amount);
/**
* @dev Emitted when tokens are deactivated
* @param tokenIds An array of token IDs that were deactivated
* @param deactivationProfits The total amount of profits generated from the deactivation
* @dev The profits are calculated as the difference between the token price and deactivation fee percentage
*/
event DeactivateTokens(
uint256[] tokenIds,
uint256[] costForEachNFT,
uint256 deactivationProfits
);
/**
* @dev Emitted when tokens are activated
* @param tokenIds An array of token IDs that were activated
* @param activationPrices The total amount of prices paid for the activation
*/
event ActivateTokens(uint256[] tokenIds, uint256[] costForEachNFT, uint256 activationPrices);
/**
* @dev Emitted when the maximum number of deactivations per interval is updated
* @param maxDeactivationsPerPeriod The new maximum number of deactivations per interval
*/
event MaxDeactivationsPerIntervalUpdated(uint256 maxDeactivationsPerPeriod);
/**
* @dev Emitted when the interval duration is updated
* @param newPeriodDuration The new interval duration in blocks
* @param periodDurationUpdatedAt The block of the interval duration update
*/
event IntervalDurationUpdated(uint64 newPeriodDuration, uint64 periodDurationUpdatedAt);
/**
* @dev Emitted when the deactivation fee percentage is updated
* @param newDeactivationFeePercentage The new deactivation fee percentage
*/
event DeactivationFeePercentageUpdated(uint16 newDeactivationFeePercentage);
/**
* @dev Emits on initialization
*/
event ContractInitialized(
IERC20 _assuranceToken,
IERC20 _b01Token,
address _nft,
address _feeRecipient,
address _treasury,
uint16 _treasuryFeePercentage,
uint16 _deactivationFeePercentage,
uint16 _NFTDeactivationPercentage
);
event DistributorProcessFailed();
/**
* @dev Error thrown when the provided deactivation fee percentage is invalid
* @param deactivationFeePercentage The invalid deactivation fee percentage
*/
error InvalidDeactivationFeePercentage(uint16 deactivationFeePercentage);
/**
* @dev Error thrown when the maximum number of deactivations per interval has been exceeded
* @param period The interval period in blocks
* @param maxDeactivationsPerPeriod The maximum number of deactivations allowed per interval
* @param deactivationsCount The number of deactivations that exceeded the maximum allowed
*/
error MaxDeactivationAmountPerIntervalExceeded(
uint64 period,
uint256 maxDeactivationsPerPeriod,
uint16 deactivationsCount
);
/**
* @dev Error thrown when given token is not supported
*/
error InvalidToken(address token);
/**
* @dev Error thrown when price exceeds caller's amount in limit
*/
error PriceExceedsAmountInMax(uint256 amountInMax, uint256 amountIn);
/**
* @dev Error thrown when added liquidity is less than expected
*/
error InsufficientLiquidityAdded(uint256 liquidity, uint256 totalActivationPrice);
/**
* @dev Error thrown when deactivation profit is less than expected
*/
error DeactivationProfitAmountLessThanMin(
uint256 deactivationProfit,
uint256 minDeactivationProfit
);
/**
* @dev Error thrown when user tries to activate/deactivate token that is no longer inside NAP
*/
error TokenIsGone(uint256 TokenId);
/**
* @notice Activates a batch of tokens by transferring them from the contract to the specified recipient.
* @dev This function takes an array of token IDs and transfers them from the contract to the specified recipient.
* It also charges the caller the total activation price based on the number of tokens being activated.
* @param tokenIds The array of token IDs to activate.
* @param to The address of the recipient who will receive the activated tokens.
* @return totalActivationPrice The total activation price.
*/
function activateTokens(
uint256[] calldata tokenIds,
address to
) external returns (uint256 totalActivationPrice);
/**
* @dev Deactivates NFTs by transferring them from the caller to this contract and
* transfer B01 with `tokenPrice` subtracted by deactivation fee percentage
* @param tokenIds Array of token IDs to be deactivated.
* @param to Address to which the tokenOut would be transferred.
* @return deactivationProfitAmount The total deactivation profit.
*/
function deactivateTokens(
uint256[] calldata tokenIds,
uint256 deactivationProfitAmountMin,
address to,
bool interfaceFeeEnabled
) external returns (uint256 deactivationProfitAmount);
/**
* @notice Sets the deactivation fee percentage to the specified value
* @param newDeactivationFeePercentage The new deactivation fee percentage
*/
function setDeactivationFeePercentage(uint16 newDeactivationFeePercentage) external;
/**
* @notice Sets the minimal number of tokens that can be deactivated in a single interval to the specified value
* @param newMinDeactivationsPerInterval The new minimal number of tokens that can be deactivated in a single interval
*/
function setMinDeactivationsPerInterval(uint16 newMinDeactivationsPerInterval) external;
/**
* @dev Returns the current interval index.
*/
function getCurrentInterval() external view returns (uint64);
/**
* @dev Calculates the deactivation profit for the given tokens.
* @return amountOut The total deactivation profit, in wei.
*/
function getDeactivationProfit(
address caller,
uint256[] memory nftsToBeDeactivated,
bool interfaceFeeEnabled
) external view returns (uint256 amountOut);
/**
* @notice Calculates the number of available deactivations per current interval.
* @return The number of available deactivations.
*/
function getAvailableDeactivationCount() external view returns (uint16);
/**
* @dev Returns the NFT contract used by the NAP contract.
* @return The NFT contract address.
*/
function nft() external view returns (IERC721Enumerable);
/**
* @dev Returns the assuranceToken contract used by the NAP contract.
* @return The assuranceToken contract address.
*/
function assuranceToken() external view returns (IERC20);
/**
* @dev Returns the address of the fee recipient for this contract.
* @return The address of the fee recipient.
*/
function feeRecipient() external view returns (address);
/**
* @dev Returns the deactivation fee percentage for this contract.
* @return The deactivation fee percentage, represented as a number between 0 and 10000.
*/
function deactivationFeePercentage() external view returns (uint16);
/**
* @dev Returns the current duration of each interval, in blocks.
* @return The current interval duration, in blocks.
*/
function INTERVAL_DURATION() external view returns (uint64);
/**
* @dev Returns the blocks of the last time the interval duration was updated.
* @return The blocks of the last interval duration update.
*/
function intervalDurationUpdatedAt() external view returns (uint64);
/**
* @dev Returns the minimal number of deactivations allowed per interval for this contract.
* @return The minimal number of deactivations allowed per interval.
*/
function minimalDeactivationAmountPerInterval() external view returns (uint16);
/**
* @dev Returns the number of deactivations that occurred in the given interval.
* @param intervalIndex The index of the interval to check.
* @return The number of deactivations that occurred in the given interval.
*/
function deactivationsCountByInterval(uint64 intervalIndex) external view returns (uint16);
}
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.19;
interface IUniswapV2Router01 {
function factory() external pure returns (address);
function WETH() external pure returns (address);
function addLiquidity(
address tokenA,
address tokenB,
uint amountADesired,
uint amountBDesired,
uint amountAMin,
uint amountBMin,
address to,
uint deadline
) external returns (uint amountA, uint amountB, uint liquidity);
function addLiquidityETH(
address token,
uint amountTokenDesired,
uint amountTokenMin,
uint amountETHMin,
address to,
uint deadline
) external payable returns (uint amountToken, uint amountETH, uint liquidity);
function removeLiquidity(
address tokenA,
address tokenB,
uint liquidity,
uint amountAMin,
uint amountBMin,
address to,
uint deadline
) external returns (uint amountA, uint amountB);
function removeLiquidityETH(
address token,
uint liquidity,
uint amountTokenMin,
uint amountETHMin,
address to,
uint deadline
) external returns (uint amountToken, uint amountETH);
function removeLiquidityWithPermit(
address tokenA,
address tokenB,
uint liquidity,
uint amountAMin,
uint amountBMin,
address to,
uint deadline,
bool approveMax, uint8 v, bytes32 r, bytes32 s
) external returns (uint amountA, uint amountB);
function removeLiquidityETHWithPermit(
address token,
uint liquidity,
uint amountTokenMin,
uint amountETHMin,
address to,
uint deadline,
bool approveMax, uint8 v, bytes32 r, bytes32 s
) external returns (uint amountToken, uint amountETH);
function swapExactTokensForTokens(
uint amountIn,
uint amountOutMin,
address[] calldata path,
address to,
uint deadline
) external returns (uint[] memory amounts);
function swapTokensForExactTokens(
uint amountOut,
uint amountInMax,
address[] calldata path,
address to,
uint deadline
) external returns (uint[] memory amounts);
function swapExactETHForTokens(uint amountOutMin, address[] calldata path, address to, uint deadline)
external
payable
returns (uint[] memory amounts);
function swapTokensForExactETH(uint amountOut, uint amountInMax, address[] calldata path, address to, uint deadline)
external
returns (uint[] memory amounts);
function swapExactTokensForETH(uint amountIn, uint amountOutMin, address[] calldata path, address to, uint deadline)
external
returns (uint[] memory amounts);
function swapETHForExactTokens(uint amountOut, address[] calldata path, address to, uint deadline)
external
payable
returns (uint[] memory amounts);
function quote(uint amountA, uint reserveA, uint reserveB) external pure returns (uint amountB);
function getAmountOut(uint amountIn, uint reserveIn, uint reserveOut) external pure returns (uint amountOut);
function getAmountIn(uint amountOut, uint reserveIn, uint reserveOut) external pure returns (uint amountIn);
function getAmountsOut(uint amountIn, address[] calldata path) external view returns (uint[] memory amounts);
function getAmountsIn(uint amountOut, address[] calldata path) external view returns (uint[] memory amounts);
}
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.19;
import "./IUniswapV2Router01.sol";
interface IUniswapV2Router02 is IUniswapV2Router01 {
function removeLiquidityETHSupportingFeeOnTransferTokens(
address token,
uint liquidity,
uint amountTokenMin,
uint amountETHMin,
address to,
uint deadline
) external returns (uint amountETH);
function removeLiquidityETHWithPermitSupportingFeeOnTransferTokens(
address token,
uint liquidity,
uint amountTokenMin,
uint amountETHMin,
address to,
uint deadline,
bool approveMax, uint8 v, bytes32 r, bytes32 s
) external returns (uint amountETH);
function swapExactTokensForTokensSupportingFeeOnTransferTokens(
uint amountIn,
uint amountOutMin,
address[] calldata path,
address to,
uint deadline
) external;
function swapExactETHForTokensSupportingFeeOnTransferTokens(
uint amountOutMin,
address[] calldata path,
address to,
uint deadline
) external payable;
function swapExactTokensForETHSupportingFeeOnTransferTokens(
uint amountIn,
uint amountOutMin,
address[] calldata path,
address to,
uint deadline
) external;
}
/// SPDX-License-Identifier: MIT
pragma solidity =0.8.24;
import {SafeCast} from "@openzeppelin/contracts/utils/math/SafeCast.sol";
import {ReentrancyGuard} from "@openzeppelin/contracts/utils/ReentrancyGuard.sol";
import {Ownable} from "@openzeppelin/contracts/access/Ownable.sol";
import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import {SafeERC20} from "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
import {IERC721Enumerable} from "@openzeppelin/contracts/token/ERC721/extensions/IERC721Enumerable.sol";
import {IUniswapV2Router02} from "libs/uniswap-v2/contracts/interfaces/IUniswapV2Router02.sol";
import {INAP721SingleToken} from "../interfaces/INAP721SingleToken.sol";
/// @title NAP721
/// @notice Manages NAP protocol functions
/// @dev Inherits from Ownable for access control and uses SafeERC20 for token operations.
contract NAP721SingleToken is Ownable(msg.sender), INAP721SingleToken, ReentrancyGuard {
using SafeCast for uint256;
using SafeERC20 for IERC20;
uint16 private constant DENOMINATOR = 10_000;
uint256 public constant INTERFACE_FEE = 150;
uint64 public constant INTERVAL_DURATION = 1 days;
uint256 public b01Threshold = 100e18;
IERC721Enumerable public nft;
IERC20 public assuranceToken;
IERC20 public b01Token;
address public feeRecipient;
address public treasury;
address public interfaceFeeReceiver;
uint16 public treasuryFeePercentage;
uint16 public deactivationFeePercentage;
uint64 public intervalDurationUpdatedAt;
uint16 public minimalDeactivationAmountPerInterval;
mapping(uint64 => uint16) public deactivationsCountByInterval;
mapping(uint64 => uint16) public activationsCountByInterval;
/// @notice Creates a new NAP721SingleToken contract instance
/// @dev _NFTDeactivationPercentage's Denominator is 10_000
/// @dev some variables have no name, to have backward compatibility with regular NAP721
/// @param _assuranceToken Address of the assurance token contract.
/// @param _b01Token Additional ERC20 token for contract logic.
/// @param _nft Address of the NFT contract.
/// @param _feeRecipient Address where fees will be sent.
/// @param _treasury Address of the treasury for receiving a portion of the fees.
/// @param _deactivationFeePercentage Percentage of the token price to charge as a fee when deactivating tokens.
/// @param _NFTDeactivationPercentage Percentage of NFTs to be deactivated
constructor(
IERC20 _assuranceToken,
IERC20,
IERC20 _b01Token,
address _nft,
address _feeRecipient,
address _treasury,
address _interfaceFeeReceiver,
IUniswapV2Router02,
uint16 _treasuryFeePercentage,
uint16 _deactivationFeePercentage,
uint16 _NFTDeactivationPercentage
) {
require(_assuranceToken != IERC20(address(0)), "Invalid Assurance Token");
require(_feeRecipient != address(0), "Invalid FeeRecipient");
require(_interfaceFeeReceiver != address(0), "Invalid Interface Fee Receiver");
require(_nft != address(0), "Invalid NFT Address");
require(_treasury != address(0), "Invalid Treasury");
require(_deactivationFeePercentage <= 10_000, "Deactivation Fee must be <= 100%");
require(_NFTDeactivationPercentage >= 100, "Invalid deactivationPercentage"); // 1%
nft = IERC721Enumerable(_nft);
assuranceToken = _assuranceToken;
b01Token = _b01Token;
feeRecipient = _feeRecipient;
treasury = _treasury;
interfaceFeeReceiver = _interfaceFeeReceiver;
intervalDurationUpdatedAt = uint64(block.timestamp);
setTreasuryFeePercentage(_treasuryFeePercentage);
setDeactivationFeePercentage(_deactivationFeePercentage);
setMinDeactivationsPerInterval(_NFTDeactivationPercentage);
emit ContractInitialized(
assuranceToken,
b01Token,
address(nft),
feeRecipient,
treasury,
treasuryFeePercentage,
deactivationFeePercentage,
_NFTDeactivationPercentage
);
}
/// @notice Activates the specified NFT tokens
/// @param tokenIds Array of NFT token IDs to activate
/// @param to Address to receive the activated NFT tokens
/// @return totalActivationPrice Total amount of `tokenIn` used for activation
function activateTokens(
uint256[] calldata tokenIds,
address to
) public virtual nonReentrant returns (uint256) {
require(tokenIds.length != 0, "Invalid tokenIds");
require(to != address(0), "Invalid address to");
(uint256[] memory costForEachNFT, uint256 totalAmountOfTokens) = calculateActivationCostFor(
tokenIds
);
require(totalAmountOfTokens != 0, "INVALID ACTIVATION COST");
IERC20(assuranceToken).safeTransferFrom(msg.sender, address(this), totalAmountOfTokens);
activationsCountByInterval[getCurrentInterval()] += (tokenIds.length).toUint16();
for (uint256 i; i < tokenIds.length; ++i) {
if (nft.ownerOf(tokenIds[i]) != address(this)) {
revert TokenIsGone(tokenIds[i]);
}
nft.safeTransferFrom(address(this), to, tokenIds[i]);
}
(bool success, ) = feeRecipient.call(abi.encodeWithSignature("process()"));
if (!success) {
emit DistributorProcessFailed();
}
emit ActivateTokens(tokenIds, costForEachNFT, totalAmountOfTokens);
return totalAmountOfTokens;
}
/// @notice Deactivates the specified NFT tokens
/// @param tokenIds Array of NFT token IDs to deactivate
/// @param deactivationProfitAmountMin Minimum amount of `tokenOut` expected to receive after deactivation
/// @param to Address to receive the `tokenOut` after deactivation
/// @param interfaceFeeEnabled Boolean indicating whether the interface fee should be enabled
/// @return deactivationAmount Actual amount of `tokenOut` received after deactivation
function deactivateTokens(
uint256[] calldata tokenIds,
uint256 deactivationProfitAmountMin,
address to,
bool interfaceFeeEnabled
) public virtual nonReentrant returns (uint256 deactivationAmount) {
require(to != address(0), "Invalid address to");
require(tokenIds.length > 0, "No token IDs provided");
uint16 tokenIdsLength = (tokenIds.length).toUint16();
(
uint256[] memory costForEachNFT,
uint256 totalDeactivationProfit
) = calculateDeactivationCostFor(tokenIds);
require(totalDeactivationProfit != 0, "INVALID PROFIT");
// Check if the new deactivations count exceeds the maximum allowed deactivations for the interval
checkDeactivations(tokenIdsLength);
deactivationsCountByInterval[getCurrentInterval()] += tokenIdsLength;
for (uint256 i; i < tokenIdsLength; ++i) {
nft.safeTransferFrom(msg.sender, address(this), tokenIds[i]);
}
deactivationAmount = _processDeactivation(totalDeactivationProfit, to, interfaceFeeEnabled);
if (deactivationAmount < deactivationProfitAmountMin) {
revert DeactivationProfitAmountLessThanMin(
totalDeactivationProfit,
deactivationProfitAmountMin
);
}
(bool success, ) = feeRecipient.call(abi.encodeWithSignature("process()"));
if (!success) {
emit DistributorProcessFailed();
}
emit DeactivateTokens(tokenIds, costForEachNFT, deactivationAmount);
}
function checkDeactivations(uint16 tokenIdsLength) internal view virtual {
uint64 maxDeactivationAvailable = getAvailableDeactivationCount();
require(
tokenIdsLength <= maxDeactivationAvailable,
"MaxDeactivationAmountPerIntervalExceeded"
);
}
/// @notice Allows the contract owner to emergency withdraw a specified asset to a designated receiver address.
/// @dev The asset must not be the assurance token, to prevent rugpulls.
/// @param asset The address of the asset to be withdrawn.
/// @param receiver The address that will receive the withdrawn asset.
function emergencyWithdraw(address asset, address receiver) external virtual onlyOwner {
require(asset != address(assuranceToken), "asset can't be NAP collateral"); // Say NO to rugpull
require(asset != address(0), "asset token invalid");
require(receiver != address(0), "receiver can't be zero address");
uint256 amount = IERC20(asset).balanceOf(address(this));
IERC20(asset).safeTransfer(receiver, amount);
emit EmergencyWithdraw(msg.sender, receiver, amount);
}
/// @dev The names were left out to silence the compiler
function onERC721Received(
address,
address,
uint256,
bytes calldata
) external pure returns (bytes4) {
return bytes4(keccak256("onERC721Received(address,address,uint256,bytes)"));
}
/// @notice Returns the number of deactivations available in the current interval
/// @return Available deactivation count for the current interval
function getAvailableDeactivationCount() public view virtual returns (uint16) {
uint64 currentInterval = getCurrentInterval();
if (
activationsCountByInterval[currentInterval] + minimalDeactivationAmountPerInterval <=
deactivationsCountByInterval[currentInterval]
) {
return 0;
}
return
activationsCountByInterval[currentInterval] +
minimalDeactivationAmountPerInterval -
deactivationsCountByInterval[currentInterval]; // Activations + minimal - deactivations
}
/// @notice Calculates the current price of one NFT based on Token balance and total NFT supply
/// @return The current price of one NFT in terms of Token
function getNFTPrice() public view virtual returns (uint256) {
return (assuranceToken.balanceOf(address(this)) / nft.totalSupply());
}
/// @notice Calculates the current interval index based on timestamp since last update.
/// @return The index of the current interval.
function getCurrentInterval() public view virtual returns (uint64) {
return (uint64(block.timestamp) - intervalDurationUpdatedAt) / INTERVAL_DURATION;
}
/// @dev Calculates the deactivation profit for a given number of tokens
/// @return nftsToBeDeactivated nfts to be deactivated
/// @notice This function provides a way to estimate the profit from deactivating tokens before actually performing the deactivation
function getDeactivationProfit(
address caller,
uint256[] memory nftsToBeDeactivated,
bool interfaceFeeEnabled
) public view virtual returns (uint256) {
(, uint256 totalLiquidityAmount) = calculateDeactivationCostFor(nftsToBeDeactivated);
if (totalLiquidityAmount == 0) {
return 0;
}
(, uint256 amountOut) = calculateDeactivationCostFor(nftsToBeDeactivated);
uint256 interfaceFee;
if (address(b01Token) == address(0)) {
interfaceFee = INTERFACE_FEE;
} else {
interfaceFee = (interfaceFeeEnabled == true && b01Token.balanceOf(caller) < b01Threshold)
? INTERFACE_FEE
: 0;
}
uint256 totalFeePercentage = deactivationFeePercentage +
treasuryFeePercentage +
interfaceFee; // treasuryFee == project fee
uint256 deactivationFee = (amountOut * totalFeePercentage) / DENOMINATOR;
return amountOut - deactivationFee;
}
/// @notice Sets the deactivation fee percentage for the NAP721 contract.
/// @param newDeactivationFeePercentage The new deactivation fee percentage to be set.
function setDeactivationFeePercentage(
uint16 newDeactivationFeePercentage
) public virtual onlyOwner {
require(newDeactivationFeePercentage != 0, "Invalid DeactivationFee");
if (newDeactivationFeePercentage > 10_000) {
revert InvalidDeactivationFeePercentage(newDeactivationFeePercentage);
}
deactivationFeePercentage = newDeactivationFeePercentage;
emit DeactivationFeePercentageUpdated(newDeactivationFeePercentage);
}
/// @notice Sets the minimum b01 threshold for treasuryFeeLess transfer.
/// @param newB01Threshold The new threshold.
function setB01Threshold(uint256 newB01Threshold) public virtual onlyOwner {
b01Threshold = newB01Threshold;
}
/// @notice Sets the treasury fee percentage for the NAP721 contract.
/// @param _treasuryFeePercentage The new treasury fee percentage to be set.
function setTreasuryFeePercentage(uint16 _treasuryFeePercentage) public virtual onlyOwner {
require(_treasuryFeePercentage <= 100, "InvalidTreasuryFee");
treasuryFeePercentage = _treasuryFeePercentage;
}
/// @notice Sets the minimal number of deactivations allowed per interval.
/// @param newMinDeactivationsPerIntervalPercentage The new percentage of total NFT supply to set as the minimal deactivations per interval.
function setMinDeactivationsPerInterval(
uint16 newMinDeactivationsPerIntervalPercentage
) public virtual onlyOwner {
require(
newMinDeactivationsPerIntervalPercentage >= 100,
"Invalid newMinDeactivationsPerIntervalPercentage"
); // Minimum 1% of total supply
minimalDeactivationAmountPerInterval = uint16(
((nft.totalSupply() * uint256(newMinDeactivationsPerIntervalPercentage)) / DENOMINATOR)
);
emit MaxDeactivationsPerIntervalUpdated(minimalDeactivationAmountPerInterval);
}
/// @notice Calculates the activation cost for a batch of NFTs.
/// @param nftsToBeActivated Array of NFT token IDs for which to calculate the activation cost.
/// @return costs Array of activation costs for each NFT.
/// @return sum Total activation cost for all NFTs.
/// @dev This function calculates the cost for each NFT by dividing the current token balance by the total NFT supply on hand,
/// incrementally adding the cost of each NFT to a running total.
function calculateActivationCostFor(
uint256[] memory nftsToBeActivated
) public view virtual returns (uint256[] memory, uint256) {
uint256[] memory costs = new uint256[](nftsToBeActivated.length);
// Calculate the sum of the first nftsToBeDeactivatedAmount terms of the sequence
uint256 sum;
uint256 numerator = assuranceToken.balanceOf(address(this));
uint256 denominator = getAmountNFTsInMarket();
for (uint256 i; i < nftsToBeActivated.length; ++i) {
costs[i] = (numerator + sum) / denominator;
sum += (numerator + sum) / denominator;
denominator++;
}
return (costs, sum);
}
/// @notice Calculates the deactivation cost for a batch of NFTs based on the current token balance and total NFT supply.
/// @param nftsToBeDeactivated Array of NFT token IDs for which to calculate the deactivation cost.
/// @return costs Array of deactivation costs for each NFT.
/// @return sum Total deactivation cost for all NFTs.
/// @dev This function calculates the cost for each NFT by dividing the remaining token balance by the total NFT supply after each calculation,
/// incrementally adding the cost of each NFT to a running total.
function calculateDeactivationCostFor(
uint256[] memory nftsToBeDeactivated
) public view virtual returns (uint256[] memory, uint256) {
uint256 nftsToBeDeactivatedAmount = nftsToBeDeactivated.length;
uint256[] memory costs = new uint256[](nftsToBeDeactivatedAmount);
uint256 numerator = assuranceToken.balanceOf(address(this));
uint256 denominator = getAmountNFTsInMarket();
// Calculate the sum of the first nftsToBeDeactivatedAmount terms of the sequence
uint256 sum;
for (uint256 i; i < nftsToBeDeactivatedAmount; ++i) {
costs[i] = (numerator - sum) / denominator;
sum += (numerator - sum) / denominator;
denominator--;
}
// Return the deactivation cost
return (costs, sum);
}
/// @notice Calculates the number of NFTs currently available in the market.
/// @dev Subtracts the number of NFTs held by the contract from the total supply.
function getAmountNFTsInMarket() public view returns (uint256) {
return nft.totalSupply() - nft.balanceOf(address(this));
}
function _processDeactivation(
uint256 _deactivationProfitAmount,
address _to,
bool interfaceFeeEnabled
) internal returns (uint256 deactivationAmount) {
IERC20 tokenOut = IERC20(assuranceToken);
uint256 treasuryFee = (_deactivationProfitAmount * treasuryFeePercentage) / DENOMINATOR;
tokenOut.safeTransfer(treasury, treasuryFee);
uint256 interfaceFee;
// If b01 address is set or UI fee is enabled and caller (user) has less tokens than feeLess threshold take UI fee
if (address(b01Token) == address(0)) {
interfaceFee = (_deactivationProfitAmount * INTERFACE_FEE) / DENOMINATOR;
tokenOut.safeTransfer(interfaceFeeReceiver, interfaceFee);
} else {
if (interfaceFeeEnabled && b01Token.balanceOf(msg.sender) < b01Threshold) {
interfaceFee = (_deactivationProfitAmount * INTERFACE_FEE) / DENOMINATOR;
tokenOut.safeTransfer(interfaceFeeReceiver, interfaceFee);
}
}
uint256 feeRecipientFee = (_deactivationProfitAmount * deactivationFeePercentage) /
DENOMINATOR;
tokenOut.safeTransfer(feeRecipient, feeRecipientFee);
deactivationAmount =
_deactivationProfitAmount -
treasuryFee -
feeRecipientFee -
interfaceFee;
tokenOut.safeTransfer(_to, deactivationAmount);
}
}
/// SPDX-License-Identifier: MIT
pragma solidity =0.8.24;
import {NAP721SingleToken, IERC20, IUniswapV2Router02} from "../naps/NAP721SingleToken.sol";
/// @title NAP721 single token with irremovable treasury fee
/// @notice Manages NAP protocol functions
/// @dev Inherits from Ownable for access control and uses SafeERC20 for token operations.
/// @notice treasury, interfaceFeeReceiver and uniswapRouter are already unchangeable
contract NAP721SingleTokenWithIrremovableTreasuryFee is NAP721SingleToken {
constructor(
IERC20 _assuranceToken,
IERC20 _collateralToken,
IERC20 _b01Token,
address _nft,
address _feeRecipient,
address _treasury,
address _interfaceFeeReceiver,
IUniswapV2Router02 _uniswapRouter,
uint16 _treasuryFeePercentage,
uint16 _deactivationFeePercentage,
uint16 _NFTDeactivationPercentage
)
NAP721SingleToken(
_assuranceToken,
_collateralToken,
_b01Token,
_nft,
_feeRecipient,
_treasury,
_interfaceFeeReceiver,
_uniswapRouter,
_treasuryFeePercentage,
_deactivationFeePercentage,
_NFTDeactivationPercentage
)
{
require(_treasuryFeePercentage != 0, "Invalid Treasury Fee");
treasuryFeePercentage = _treasuryFeePercentage;
}
// This is dummy function to disable treasuryFee changing
function setTreasuryFeePercentage(
uint16 _treasuryFeePercentage
) public override(NAP721SingleToken) onlyOwner {}
// This is dummy function to disable B01Threshold changing
function setB01Threshold(uint256 newB01Threshold) public override(NAP721SingleToken) onlyOwner {}
function setDeactivationFeePercentage(
uint16 newDeactivationFeePercentage
) public virtual override onlyOwner {
require(newDeactivationFeePercentage != 0, "Invalid DeactivationFee");
require(newDeactivationFeePercentage <= 9_750, "Deactivation Fee must be <= 100%");
deactivationFeePercentage = newDeactivationFeePercentage;
emit DeactivationFeePercentageUpdated(newDeactivationFeePercentage);
}
}
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (access/Ownable.sol)
pragma solidity ^0.8.20;
import {Context} from "../utils/Context.sol";
/**
* @dev Contract module which provides a basic access control mechanism, where
* there is an account (an owner) that can be granted exclusive access to
* specific functions.
*
* The initial owner is set to the address provided by the deployer. This can
* later be changed with {transferOwnership}.
*
* This module is used through inheritance. It will make available the modifier
* `onlyOwner`, which can be applied to your functions to restrict their use to
* the owner.
*/
abstract contract Ownable is Context {
address private _owner;
/**
* @dev The caller account is not authorized to perform an operation.
*/
error OwnableUnauthorizedAccount(address account);
/**
* @dev The owner is not a valid owner account. (eg. `address(0)`)
*/
error OwnableInvalidOwner(address owner);
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
/**
* @dev Initializes the contract setting the address provided by the deployer as the initial owner.
*/
constructor(address initialOwner) {
if (initialOwner == address(0)) {
revert OwnableInvalidOwner(address(0));
}
_transferOwnership(initialOwner);
}
/**
* @dev Throws if called by any account other than the owner.
*/
modifier onlyOwner() {
_checkOwner();
_;
}
/**
* @dev Returns the address of the current owner.
*/
function owner() public view virtual returns (address) {
return _owner;
}
/**
* @dev Throws if the sender is not the owner.
*/
function _checkOwner() internal view virtual {
if (owner() != _msgSender()) {
revert OwnableUnauthorizedAccount(_msgSender());
}
}
/**
* @dev Leaves the contract without owner. It will not be possible to call
* `onlyOwner` functions. Can only be called by the current owner.
*
* NOTE: Renouncing ownership will leave the contract without an owner,
* thereby disabling any functionality that is only available to the owner.
*/
function renounceOwnership() public virtual onlyOwner {
_transferOwnership(address(0));
}
/**
* @dev Transfers ownership of the contract to a new account (`newOwner`).
* Can only be called by the current owner.
*/
function transferOwnership(address newOwner) public virtual onlyOwner {
if (newOwner == address(0)) {
revert OwnableInvalidOwner(address(0));
}
_transferOwnership(newOwner);
}
/**
* @dev Transfers ownership of the contract to a new account (`newOwner`).
* Internal function without access restriction.
*/
function _transferOwnership(address newOwner) internal virtual {
address oldOwner = _owner;
_owner = newOwner;
emit OwnershipTransferred(oldOwner, newOwner);
}
}
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (utils/ReentrancyGuard.sol)
pragma solidity ^0.8.20;
/**
* @dev Contract module that helps prevent reentrant calls to a function.
*
* Inheriting from `ReentrancyGuard` will make the {nonReentrant} modifier
* available, which can be applied to functions to make sure there are no nested
* (reentrant) calls to them.
*
* Note that because there is a single `nonReentrant` guard, functions marked as
* `nonReentrant` may not call one another. This can be worked around by making
* those functions `private`, and then adding `external` `nonReentrant` entry
* points to them.
*
* TIP: If you would like to learn more about reentrancy and alternative ways
* to protect against it, check out our blog post
* https://blog.openzeppelin.com/reentrancy-after-istanbul/[Reentrancy After Istanbul].
*/
abstract contract ReentrancyGuard {
// Booleans are more expensive than uint256 or any type that takes up a full
// word because each write operation emits an extra SLOAD to first read the
// slot's contents, replace the bits taken up by the boolean, and then write
// back. This is the compiler's defense against contract upgrades and
// pointer aliasing, and it cannot be disabled.
// The values being non-zero value makes deployment a bit more expensive,
// but in exchange the refund on every call to nonReentrant will be lower in
// amount. Since refunds are capped to a percentage of the total
// transaction's gas, it is best to keep them low in cases like this one, to
// increase the likelihood of the full refund coming into effect.
uint256 private constant NOT_ENTERED = 1;
uint256 private constant ENTERED = 2;
uint256 private _status;
/**
* @dev Unauthorized reentrant call.
*/
error ReentrancyGuardReentrantCall();
constructor() {
_status = NOT_ENTERED;
}
/**
* @dev Prevents a contract from calling itself, directly or indirectly.
* Calling a `nonReentrant` function from another `nonReentrant`
* function is not supported. It is possible to prevent this from happening
* by making the `nonReentrant` function external, and making it call a
* `private` function that does the actual work.
*/
modifier nonReentrant() {
_nonReentrantBefore();
_;
_nonReentrantAfter();
}
function _nonReentrantBefore() private {
// On the first call to nonReentrant, _status will be NOT_ENTERED
if (_status == ENTERED) {
revert ReentrancyGuardReentrantCall();
}
// Any calls to nonReentrant after this point will fail
_status = ENTERED;
}
function _nonReentrantAfter() private {
// By storing the original value once again, a refund is triggered (see
// https://eips.ethereum.org/EIPS/eip-2200)
_status = NOT_ENTERED;
}
/**
* @dev Returns true if the reentrancy guard is currently set to "entered", which indicates there is a
* `nonReentrant` function in the call stack.
*/
function _reentrancyGuardEntered() internal view returns (bool) {
return _status == ENTERED;
}
}
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (utils/math/SafeCast.sol)
// This file was procedurally generated from scripts/generate/templates/SafeCast.js.
pragma solidity ^0.8.20;
/**
* @dev Wrappers over Solidity's uintXX/intXX casting operators with added overflow
* checks.
*
* Downcasting from uint256/int256 in Solidity does not revert on overflow. This can
* easily result in undesired exploitation or bugs, since developers usually
* assume that overflows raise errors. `SafeCast` restores this intuition by
* reverting the transaction when such an operation overflows.
*
* Using this library instead of the unchecked operations eliminates an entire
* class of bugs, so it's recommended to use it always.
*/
library SafeCast {
/**
* @dev Value doesn't fit in an uint of `bits` size.
*/
error SafeCastOverflowedUintDowncast(uint8 bits, uint256 value);
/**
* @dev An int value doesn't fit in an uint of `bits` size.
*/
error SafeCastOverflowedIntToUint(int256 value);
/**
* @dev Value doesn't fit in an int of `bits` size.
*/
error SafeCastOverflowedIntDowncast(uint8 bits, int256 value);
/**
* @dev An uint value doesn't fit in an int of `bits` size.
*/
error SafeCastOverflowedUintToInt(uint256 value);
/**
* @dev Returns the downcasted uint248 from uint256, reverting on
* overflow (when the input is greater than largest uint248).
*
* Counterpart to Solidity's `uint248` operator.
*
* Requirements:
*
* - input must fit into 248 bits
*/
function toUint248(uint256 value) internal pure returns (uint248) {
if (value > type(uint248).max) {
revert SafeCastOverflowedUintDowncast(248, value);
}
return uint248(value);
}
/**
* @dev Returns the downcasted uint240 from uint256, reverting on
* overflow (when the input is greater than largest uint240).
*
* Counterpart to Solidity's `uint240` operator.
*
* Requirements:
*
* - input must fit into 240 bits
*/
function toUint240(uint256 value) internal pure returns (uint240) {
if (value > type(uint240).max) {
revert SafeCastOverflowedUintDowncast(240, value);
}
return uint240(value);
}
/**
* @dev Returns the downcasted uint232 from uint256, reverting on
* overflow (when the input is greater than largest uint232).
*
* Counterpart to Solidity's `uint232` operator.
*
* Requirements:
*
* - input must fit into 232 bits
*/
function toUint232(uint256 value) internal pure returns (uint232) {
if (value > type(uint232).max) {
revert SafeCastOverflowedUintDowncast(232, value);
}
return uint232(value);
}
/**
* @dev Returns the downcasted uint224 from uint256, reverting on
* overflow (when the input is greater than largest uint224).
*
* Counterpart to Solidity's `uint224` operator.
*
* Requirements:
*
* - input must fit into 224 bits
*/
function toUint224(uint256 value) internal pure returns (uint224) {
if (value > type(uint224).max) {
revert SafeCastOverflowedUintDowncast(224, value);
}
return uint224(value);
}
/**
* @dev Returns the downcasted uint216 from uint256, reverting on
* overflow (when the input is greater than largest uint216).
*
* Counterpart to Solidity's `uint216` operator.
*
* Requirements:
*
* - input must fit into 216 bits
*/
function toUint216(uint256 value) internal pure returns (uint216) {
if (value > type(uint216).max) {
revert SafeCastOverflowedUintDowncast(216, value);
}
return uint216(value);
}
/**
* @dev Returns the downcasted uint208 from uint256, reverting on
* overflow (when the input is greater than largest uint208).
*
* Counterpart to Solidity's `uint208` operator.
*
* Requirements:
*
* - input must fit into 208 bits
*/
function toUint208(uint256 value) internal pure returns (uint208) {
if (value > type(uint208).max) {
revert SafeCastOverflowedUintDowncast(208, value);
}
return uint208(value);
}
/**
* @dev Returns the downcasted uint200 from uint256, reverting on
* overflow (when the input is greater than largest uint200).
*
* Counterpart to Solidity's `uint200` operator.
*
* Requirements:
*
* - input must fit into 200 bits
*/
function toUint200(uint256 value) internal pure returns (uint200) {
if (value > type(uint200).max) {
revert SafeCastOverflowedUintDowncast(200, value);
}
return uint200(value);
}
/**
* @dev Returns the downcasted uint192 from uint256, reverting on
* overflow (when the input is greater than largest uint192).
*
* Counterpart to Solidity's `uint192` operator.
*
* Requirements:
*
* - input must fit into 192 bits
*/
function toUint192(uint256 value) internal pure returns (uint192) {
if (value > type(uint192).max) {
revert SafeCastOverflowedUintDowncast(192, value);
}
return uint192(value);
}
/**
* @dev Returns the downcasted uint184 from uint256, reverting on
* overflow (when the input is greater than largest uint184).
*
* Counterpart to Solidity's `uint184` operator.
*
* Requirements:
*
* - input must fit into 184 bits
*/
function toUint184(uint256 value) internal pure returns (uint184) {
if (value > type(uint184).max) {
revert SafeCastOverflowedUintDowncast(184, value);
}
return uint184(value);
}
/**
* @dev Returns the downcasted uint176 from uint256, reverting on
* overflow (when the input is greater than largest uint176).
*
* Counterpart to Solidity's `uint176` operator.
*
* Requirements:
*
* - input must fit into 176 bits
*/
function toUint176(uint256 value) internal pure returns (uint176) {
if (value > type(uint176).max) {
revert SafeCastOverflowedUintDowncast(176, value);
}
return uint176(value);
}
/**
* @dev Returns the downcasted uint168 from uint256, reverting on
* overflow (when the input is greater than largest uint168).
*
* Counterpart to Solidity's `uint168` operator.
*
* Requirements:
*
* - input must fit into 168 bits
*/
function toUint168(uint256 value) internal pure returns (uint168) {
if (value > type(uint168).max) {
revert SafeCastOverflowedUintDowncast(168, value);
}
return uint168(value);
}
/**
* @dev Returns the downcasted uint160 from uint256, reverting on
* overflow (when the input is greater than largest uint160).
*
* Counterpart to Solidity's `uint160` operator.
*
* Requirements:
*
* - input must fit into 160 bits
*/
function toUint160(uint256 value) internal pure returns (uint160) {
if (value > type(uint160).max) {
revert SafeCastOverflowedUintDowncast(160, value);
}
return uint160(value);
}
/**
* @dev Returns the downcasted uint152 from uint256, reverting on
* overflow (when the input is greater than largest uint152).
*
* Counterpart to Solidity's `uint152` operator.
*
* Requirements:
*
* - input must fit into 152 bits
*/
function toUint152(uint256 value) internal pure returns (uint152) {
if (value > type(uint152).max) {
revert SafeCastOverflowedUintDowncast(152, value);
}
return uint152(value);
}
/**
* @dev Returns the downcasted uint144 from uint256, reverting on
* overflow (when the input is greater than largest uint144).
*
* Counterpart to Solidity's `uint144` operator.
*
* Requirements:
*
* - input must fit into 144 bits
*/
function toUint144(uint256 value) internal pure returns (uint144) {
if (value > type(uint144).max) {
revert SafeCastOverflowedUintDowncast(144, value);
}
return uint144(value);
}
/**
* @dev Returns the downcasted uint136 from uint256, reverting on
* overflow (when the input is greater than largest uint136).
*
* Counterpart to Solidity's `uint136` operator.
*
* Requirements:
*
* - input must fit into 136 bits
*/
function toUint136(uint256 value) internal pure returns (uint136) {
if (value > type(uint136).max) {
revert SafeCastOverflowedUintDowncast(136, value);
}
return uint136(value);
}
/**
* @dev Returns the downcasted uint128 from uint256, reverting on
* overflow (when the input is greater than largest uint128).
*
* Counterpart to Solidity's `uint128` operator.
*
* Requirements:
*
* - input must fit into 128 bits
*/
function toUint128(uint256 value) internal pure returns (uint128) {
if (value > type(uint128).max) {
revert SafeCastOverflowedUintDowncast(128, value);
}
return uint128(value);
}
/**
* @dev Returns the downcasted uint120 from uint256, reverting on
* overflow (when the input is greater than largest uint120).
*
* Counterpart to Solidity's `uint120` operator.
*
* Requirements:
*
* - input must fit into 120 bits
*/
function toUint120(uint256 value) internal pure returns (uint120) {
if (value > type(uint120).max) {
revert SafeCastOverflowedUintDowncast(120, value);
}
return uint120(value);
}
/**
* @dev Returns the downcasted uint112 from uint256, reverting on
* overflow (when the input is greater than largest uint112).
*
* Counterpart to Solidity's `uint112` operator.
*
* Requirements:
*
* - input must fit into 112 bits
*/
function toUint112(uint256 value) internal pure returns (uint112) {
if (value > type(uint112).max) {
revert SafeCastOverflowedUintDowncast(112, value);
}
return uint112(value);
}
/**
* @dev Returns the downcasted uint104 from uint256, reverting on
* overflow (when the input is greater than largest uint104).
*
* Counterpart to Solidity's `uint104` operator.
*
* Requirements:
*
* - input must fit into 104 bits
*/
function toUint104(uint256 value) internal pure returns (uint104) {
if (value > type(uint104).max) {
revert SafeCastOverflowedUintDowncast(104, value);
}
return uint104(value);
}
/**
* @dev Returns the downcasted uint96 from uint256, reverting on
* overflow (when the input is greater than largest uint96).
*
* Counterpart to Solidity's `uint96` operator.
*
* Requirements:
*
* - input must fit into 96 bits
*/
function toUint96(uint256 value) internal pure returns (uint96) {
if (value > type(uint96).max) {
revert SafeCastOverflowedUintDowncast(96, value);
}
return uint96(value);
}
/**
* @dev Returns the downcasted uint88 from uint256, reverting on
* overflow (when the input is greater than largest uint88).
*
* Counterpart to Solidity's `uint88` operator.
*
* Requirements:
*
* - input must fit into 88 bits
*/
function toUint88(uint256 value) internal pure returns (uint88) {
if (value > type(uint88).max) {
revert SafeCastOverflowedUintDowncast(88, value);
}
return uint88(value);
}
/**
* @dev Returns the downcasted uint80 from uint256, reverting on
* overflow (when the input is greater than largest uint80).
*
* Counterpart to Solidity's `uint80` operator.
*
* Requirements:
*
* - input must fit into 80 bits
*/
function toUint80(uint256 value) internal pure returns (uint80) {
if (value > type(uint80).max) {
revert SafeCastOverflowedUintDowncast(80, value);
}
return uint80(value);
}
/**
* @dev Returns the downcasted uint72 from uint256, reverting on
* overflow (when the input is greater than largest uint72).
*
* Counterpart to Solidity's `uint72` operator.
*
* Requirements:
*
* - input must fit into 72 bits
*/
function toUint72(uint256 value) internal pure returns (uint72) {
if (value > type(uint72).max) {
revert SafeCastOverflowedUintDowncast(72, value);
}
return uint72(value);
}
/**
* @dev Returns the downcasted uint64 from uint256, reverting on
* overflow (when the input is greater than largest uint64).
*
* Counterpart to Solidity's `uint64` operator.
*
* Requirements:
*
* - input must fit into 64 bits
*/
function toUint64(uint256 value) internal pure returns (uint64) {
if (value > type(uint64).max) {
revert SafeCastOverflowedUintDowncast(64, value);
}
return uint64(value);
}
/**
* @dev Returns the downcasted uint56 from uint256, reverting on
* overflow (when the input is greater than largest uint56).
*
* Counterpart to Solidity's `uint56` operator.
*
* Requirements:
*
* - input must fit into 56 bits
*/
function toUint56(uint256 value) internal pure returns (uint56) {
if (value > type(uint56).max) {
revert SafeCastOverflowedUintDowncast(56, value);
}
return uint56(value);
}
/**
* @dev Returns the downcasted uint48 from uint256, reverting on
* overflow (when the input is greater than largest uint48).
*
* Counterpart to Solidity's `uint48` operator.
*
* Requirements:
*
* - input must fit into 48 bits
*/
function toUint48(uint256 value) internal pure returns (uint48) {
if (value > type(uint48).max) {
revert SafeCastOverflowedUintDowncast(48, value);
}
return uint48(value);
}
/**
* @dev Returns the downcasted uint40 from uint256, reverting on
* overflow (when the input is greater than largest uint40).
*
* Counterpart to Solidity's `uint40` operator.
*
* Requirements:
*
* - input must fit into 40 bits
*/
function toUint40(uint256 value) internal pure returns (uint40) {
if (value > type(uint40).max) {
revert SafeCastOverflowedUintDowncast(40, value);
}
return uint40(value);
}
/**
* @dev Returns the downcasted uint32 from uint256, reverting on
* overflow (when the input is greater than largest uint32).
*
* Counterpart to Solidity's `uint32` operator.
*
* Requirements:
*
* - input must fit into 32 bits
*/
function toUint32(uint256 value) internal pure returns (uint32) {
if (value > type(uint32).max) {
revert SafeCastOverflowedUintDowncast(32, value);
}
return uint32(value);
}
/**
* @dev Returns the downcasted uint24 from uint256, reverting on
* overflow (when the input is greater than largest uint24).
*
* Counterpart to Solidity's `uint24` operator.
*
* Requirements:
*
* - input must fit into 24 bits
*/
function toUint24(uint256 value) internal pure returns (uint24) {
if (value > type(uint24).max) {
revert SafeCastOverflowedUintDowncast(24, value);
}
return uint24(value);
}
/**
* @dev Returns the downcasted uint16 from uint256, reverting on
* overflow (when the input is greater than largest uint16).
*
* Counterpart to Solidity's `uint16` operator.
*
* Requirements:
*
* - input must fit into 16 bits
*/
function toUint16(uint256 value) internal pure returns (uint16) {
if (value > type(uint16).max) {
revert SafeCastOverflowedUintDowncast(16, value);
}
return uint16(value);
}
/**
* @dev Returns the downcasted uint8 from uint256, reverting on
* overflow (when the input is greater than largest uint8).
*
* Counterpart to Solidity's `uint8` operator.
*
* Requirements:
*
* - input must fit into 8 bits
*/
function toUint8(uint256 value) internal pure returns (uint8) {
if (value > type(uint8).max) {
revert SafeCastOverflowedUintDowncast(8, value);
}
return uint8(value);
}
/**
* @dev Converts a signed int256 into an unsigned uint256.
*
* Requirements:
*
* - input must be greater than or equal to 0.
*/
function toUint256(int256 value) internal pure returns (uint256) {
if (value < 0) {
revert SafeCastOverflowedIntToUint(value);
}
return uint256(value);
}
/**
* @dev Returns the downcasted int248 from int256, reverting on
* overflow (when the input is less than smallest int248 or
* greater than largest int248).
*
* Counterpart to Solidity's `int248` operator.
*
* Requirements:
*
* - input must fit into 248 bits
*/
function toInt248(int256 value) internal pure returns (int248 downcasted) {
downcasted = int248(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(248, value);
}
}
/**
* @dev Returns the downcasted int240 from int256, reverting on
* overflow (when the input is less than smallest int240 or
* greater than largest int240).
*
* Counterpart to Solidity's `int240` operator.
*
* Requirements:
*
* - input must fit into 240 bits
*/
function toInt240(int256 value) internal pure returns (int240 downcasted) {
downcasted = int240(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(240, value);
}
}
/**
* @dev Returns the downcasted int232 from int256, reverting on
* overflow (when the input is less than smallest int232 or
* greater than largest int232).
*
* Counterpart to Solidity's `int232` operator.
*
* Requirements:
*
* - input must fit into 232 bits
*/
function toInt232(int256 value) internal pure returns (int232 downcasted) {
downcasted = int232(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(232, value);
}
}
/**
* @dev Returns the downcasted int224 from int256, reverting on
* overflow (when the input is less than smallest int224 or
* greater than largest int224).
*
* Counterpart to Solidity's `int224` operator.
*
* Requirements:
*
* - input must fit into 224 bits
*/
function toInt224(int256 value) internal pure returns (int224 downcasted) {
downcasted = int224(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(224, value);
}
}
/**
* @dev Returns the downcasted int216 from int256, reverting on
* overflow (when the input is less than smallest int216 or
* greater than largest int216).
*
* Counterpart to Solidity's `int216` operator.
*
* Requirements:
*
* - input must fit into 216 bits
*/
function toInt216(int256 value) internal pure returns (int216 downcasted) {
downcasted = int216(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(216, value);
}
}
/**
* @dev Returns the downcasted int208 from int256, reverting on
* overflow (when the input is less than smallest int208 or
* greater than largest int208).
*
* Counterpart to Solidity's `int208` operator.
*
* Requirements:
*
* - input must fit into 208 bits
*/
function toInt208(int256 value) internal pure returns (int208 downcasted) {
downcasted = int208(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(208, value);
}
}
/**
* @dev Returns the downcasted int200 from int256, reverting on
* overflow (when the input is less than smallest int200 or
* greater than largest int200).
*
* Counterpart to Solidity's `int200` operator.
*
* Requirements:
*
* - input must fit into 200 bits
*/
function toInt200(int256 value) internal pure returns (int200 downcasted) {
downcasted = int200(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(200, value);
}
}
/**
* @dev Returns the downcasted int192 from int256, reverting on
* overflow (when the input is less than smallest int192 or
* greater than largest int192).
*
* Counterpart to Solidity's `int192` operator.
*
* Requirements:
*
* - input must fit into 192 bits
*/
function toInt192(int256 value) internal pure returns (int192 downcasted) {
downcasted = int192(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(192, value);
}
}
/**
* @dev Returns the downcasted int184 from int256, reverting on
* overflow (when the input is less than smallest int184 or
* greater than largest int184).
*
* Counterpart to Solidity's `int184` operator.
*
* Requirements:
*
* - input must fit into 184 bits
*/
function toInt184(int256 value) internal pure returns (int184 downcasted) {
downcasted = int184(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(184, value);
}
}
/**
* @dev Returns the downcasted int176 from int256, reverting on
* overflow (when the input is less than smallest int176 or
* greater than largest int176).
*
* Counterpart to Solidity's `int176` operator.
*
* Requirements:
*
* - input must fit into 176 bits
*/
function toInt176(int256 value) internal pure returns (int176 downcasted) {
downcasted = int176(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(176, value);
}
}
/**
* @dev Returns the downcasted int168 from int256, reverting on
* overflow (when the input is less than smallest int168 or
* greater than largest int168).
*
* Counterpart to Solidity's `int168` operator.
*
* Requirements:
*
* - input must fit into 168 bits
*/
function toInt168(int256 value) internal pure returns (int168 downcasted) {
downcasted = int168(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(168, value);
}
}
/**
* @dev Returns the downcasted int160 from int256, reverting on
* overflow (when the input is less than smallest int160 or
* greater than largest int160).
*
* Counterpart to Solidity's `int160` operator.
*
* Requirements:
*
* - input must fit into 160 bits
*/
function toInt160(int256 value) internal pure returns (int160 downcasted) {
downcasted = int160(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(160, value);
}
}
/**
* @dev Returns the downcasted int152 from int256, reverting on
* overflow (when the input is less than smallest int152 or
* greater than largest int152).
*
* Counterpart to Solidity's `int152` operator.
*
* Requirements:
*
* - input must fit into 152 bits
*/
function toInt152(int256 value) internal pure returns (int152 downcasted) {
downcasted = int152(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(152, value);
}
}
/**
* @dev Returns the downcasted int144 from int256, reverting on
* overflow (when the input is less than smallest int144 or
* greater than largest int144).
*
* Counterpart to Solidity's `int144` operator.
*
* Requirements:
*
* - input must fit into 144 bits
*/
function toInt144(int256 value) internal pure returns (int144 downcasted) {
downcasted = int144(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(144, value);
}
}
/**
* @dev Returns the downcasted int136 from int256, reverting on
* overflow (when the input is less than smallest int136 or
* greater than largest int136).
*
* Counterpart to Solidity's `int136` operator.
*
* Requirements:
*
* - input must fit into 136 bits
*/
function toInt136(int256 value) internal pure returns (int136 downcasted) {
downcasted = int136(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(136, value);
}
}
/**
* @dev Returns the downcasted int128 from int256, reverting on
* overflow (when the input is less than smallest int128 or
* greater than largest int128).
*
* Counterpart to Solidity's `int128` operator.
*
* Requirements:
*
* - input must fit into 128 bits
*/
function toInt128(int256 value) internal pure returns (int128 downcasted) {
downcasted = int128(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(128, value);
}
}
/**
* @dev Returns the downcasted int120 from int256, reverting on
* overflow (when the input is less than smallest int120 or
* greater than largest int120).
*
* Counterpart to Solidity's `int120` operator.
*
* Requirements:
*
* - input must fit into 120 bits
*/
function toInt120(int256 value) internal pure returns (int120 downcasted) {
downcasted = int120(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(120, value);
}
}
/**
* @dev Returns the downcasted int112 from int256, reverting on
* overflow (when the input is less than smallest int112 or
* greater than largest int112).
*
* Counterpart to Solidity's `int112` operator.
*
* Requirements:
*
* - input must fit into 112 bits
*/
function toInt112(int256 value) internal pure returns (int112 downcasted) {
downcasted = int112(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(112, value);
}
}
/**
* @dev Returns the downcasted int104 from int256, reverting on
* overflow (when the input is less than smallest int104 or
* greater than largest int104).
*
* Counterpart to Solidity's `int104` operator.
*
* Requirements:
*
* - input must fit into 104 bits
*/
function toInt104(int256 value) internal pure returns (int104 downcasted) {
downcasted = int104(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(104, value);
}
}
/**
* @dev Returns the downcasted int96 from int256, reverting on
* overflow (when the input is less than smallest int96 or
* greater than largest int96).
*
* Counterpart to Solidity's `int96` operator.
*
* Requirements:
*
* - input must fit into 96 bits
*/
function toInt96(int256 value) internal pure returns (int96 downcasted) {
downcasted = int96(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(96, value);
}
}
/**
* @dev Returns the downcasted int88 from int256, reverting on
* overflow (when the input is less than smallest int88 or
* greater than largest int88).
*
* Counterpart to Solidity's `int88` operator.
*
* Requirements:
*
* - input must fit into 88 bits
*/
function toInt88(int256 value) internal pure returns (int88 downcasted) {
downcasted = int88(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(88, value);
}
}
/**
* @dev Returns the downcasted int80 from int256, reverting on
* overflow (when the input is less than smallest int80 or
* greater than largest int80).
*
* Counterpart to Solidity's `int80` operator.
*
* Requirements:
*
* - input must fit into 80 bits
*/
function toInt80(int256 value) internal pure returns (int80 downcasted) {
downcasted = int80(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(80, value);
}
}
/**
* @dev Returns the downcasted int72 from int256, reverting on
* overflow (when the input is less than smallest int72 or
* greater than largest int72).
*
* Counterpart to Solidity's `int72` operator.
*
* Requirements:
*
* - input must fit into 72 bits
*/
function toInt72(int256 value) internal pure returns (int72 downcasted) {
downcasted = int72(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(72, value);
}
}
/**
* @dev Returns the downcasted int64 from int256, reverting on
* overflow (when the input is less than smallest int64 or
* greater than largest int64).
*
* Counterpart to Solidity's `int64` operator.
*
* Requirements:
*
* - input must fit into 64 bits
*/
function toInt64(int256 value) internal pure returns (int64 downcasted) {
downcasted = int64(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(64, value);
}
}
/**
* @dev Returns the downcasted int56 from int256, reverting on
* overflow (when the input is less than smallest int56 or
* greater than largest int56).
*
* Counterpart to Solidity's `int56` operator.
*
* Requirements:
*
* - input must fit into 56 bits
*/
function toInt56(int256 value) internal pure returns (int56 downcasted) {
downcasted = int56(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(56, value);
}
}
/**
* @dev Returns the downcasted int48 from int256, reverting on
* overflow (when the input is less than smallest int48 or
* greater than largest int48).
*
* Counterpart to Solidity's `int48` operator.
*
* Requirements:
*
* - input must fit into 48 bits
*/
function toInt48(int256 value) internal pure returns (int48 downcasted) {
downcasted = int48(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(48, value);
}
}
/**
* @dev Returns the downcasted int40 from int256, reverting on
* overflow (when the input is less than smallest int40 or
* greater than largest int40).
*
* Counterpart to Solidity's `int40` operator.
*
* Requirements:
*
* - input must fit into 40 bits
*/
function toInt40(int256 value) internal pure returns (int40 downcasted) {
downcasted = int40(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(40, value);
}
}
/**
* @dev Returns the downcasted int32 from int256, reverting on
* overflow (when the input is less than smallest int32 or
* greater than largest int32).
*
* Counterpart to Solidity's `int32` operator.
*
* Requirements:
*
* - input must fit into 32 bits
*/
function toInt32(int256 value) internal pure returns (int32 downcasted) {
downcasted = int32(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(32, value);
}
}
/**
* @dev Returns the downcasted int24 from int256, reverting on
* overflow (when the input is less than smallest int24 or
* greater than largest int24).
*
* Counterpart to Solidity's `int24` operator.
*
* Requirements:
*
* - input must fit into 24 bits
*/
function toInt24(int256 value) internal pure returns (int24 downcasted) {
downcasted = int24(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(24, value);
}
}
/**
* @dev Returns the downcasted int16 from int256, reverting on
* overflow (when the input is less than smallest int16 or
* greater than largest int16).
*
* Counterpart to Solidity's `int16` operator.
*
* Requirements:
*
* - input must fit into 16 bits
*/
function toInt16(int256 value) internal pure returns (int16 downcasted) {
downcasted = int16(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(16, value);
}
}
/**
* @dev Returns the downcasted int8 from int256, reverting on
* overflow (when the input is less than smallest int8 or
* greater than largest int8).
*
* Counterpart to Solidity's `int8` operator.
*
* Requirements:
*
* - input must fit into 8 bits
*/
function toInt8(int256 value) internal pure returns (int8 downcasted) {
downcasted = int8(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(8, value);
}
}
/**
* @dev Converts an unsigned uint256 into a signed int256.
*
* Requirements:
*
* - input must be less than or equal to maxInt256.
*/
function toInt256(uint256 value) internal pure returns (int256) {
// Note: Unsafe cast below is okay because `type(int256).max` is guaranteed to be positive
if (value > uint256(type(int256).max)) {
revert SafeCastOverflowedUintToInt(value);
}
return int256(value);
}
}
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (token/ERC20/utils/SafeERC20.sol)
pragma solidity ^0.8.20;
import {IERC20} from "../IERC20.sol";
import {IERC20Permit} from "../extensions/IERC20Permit.sol";
import {Address} from "../../../utils/Address.sol";
/**
* @title SafeERC20
* @dev Wrappers around ERC20 operations that throw on failure (when the token
* contract returns false). Tokens that return no value (and instead revert or
* throw on failure) are also supported, non-reverting calls are assumed to be
* successful.
* To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract,
* which allows you to call the safe operations as `token.safeTransfer(...)`, etc.
*/
library SafeERC20 {
using Address for address;
/**
* @dev An operation with an ERC20 token failed.
*/
error SafeERC20FailedOperation(address token);
/**
* @dev Indicates a failed `decreaseAllowance` request.
*/
error SafeERC20FailedDecreaseAllowance(address spender, uint256 currentAllowance, uint256 requestedDecrease);
/**
* @dev Transfer `value` amount of `token` from the calling contract to `to`. If `token` returns no value,
* non-reverting calls are assumed to be successful.
*/
function safeTransfer(IERC20 token, address to, uint256 value) internal {
_callOptionalReturn(token, abi.encodeCall(token.transfer, (to, value)));
}
/**
* @dev Transfer `value` amount of `token` from `from` to `to`, spending the approval given by `from` to the
* calling contract. If `token` returns no value, non-reverting calls are assumed to be successful.
*/
function safeTransferFrom(IERC20 token, address from, address to, uint256 value) internal {
_callOptionalReturn(token, abi.encodeCall(token.transferFrom, (from, to, value)));
}
/**
* @dev Increase the calling contract's allowance toward `spender` by `value`. If `token` returns no value,
* non-reverting calls are assumed to be successful.
*/
function safeIncreaseAllowance(IERC20 token, address spender, uint256 value) internal {
uint256 oldAllowance = token.allowance(address(this), spender);
forceApprove(token, spender, oldAllowance + value);
}
/**
* @dev Decrease the calling contract's allowance toward `spender` by `requestedDecrease`. If `token` returns no
* value, non-reverting calls are assumed to be successful.
*/
function safeDecreaseAllowance(IERC20 token, address spender, uint256 requestedDecrease) internal {
unchecked {
uint256 currentAllowance = token.allowance(address(this), spender);
if (currentAllowance < requestedDecrease) {
revert SafeERC20FailedDecreaseAllowance(spender, currentAllowance, requestedDecrease);
}
forceApprove(token, spender, currentAllowance - requestedDecrease);
}
}
/**
* @dev Set the calling contract's allowance toward `spender` to `value`. If `token` returns no value,
* non-reverting calls are assumed to be successful. Meant to be used with tokens that require the approval
* to be set to zero before setting it to a non-zero value, such as USDT.
*/
function forceApprove(IERC20 token, address spender, uint256 value) internal {
bytes memory approvalCall = abi.encodeCall(token.approve, (spender, value));
if (!_callOptionalReturnBool(token, approvalCall)) {
_callOptionalReturn(token, abi.encodeCall(token.approve, (spender, 0)));
_callOptionalReturn(token, approvalCall);
}
}
/**
* @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement
* on the return value: the return value is optional (but if data is returned, it must not be false).
* @param token The token targeted by the call.
* @param data The call data (encoded using abi.encode or one of its variants).
*/
function _callOptionalReturn(IERC20 token, bytes memory data) private {
// We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since
// we're implementing it ourselves. We use {Address-functionCall} to perform this call, which verifies that
// the target address contains contract code and also asserts for success in the low-level call.
bytes memory returndata = address(token).functionCall(data);
if (returndata.length != 0 && !abi.decode(returndata, (bool))) {
revert SafeERC20FailedOperation(address(token));
}
}
/**
* @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement
* on the return value: the return value is optional (but if data is returned, it must not be false).
* @param token The token targeted by the call.
* @param data The call data (encoded using abi.encode or one of its variants).
*
* This is a variant of {_callOptionalReturn} that silents catches all reverts and returns a bool instead.
*/
function _callOptionalReturnBool(IERC20 token, bytes memory data) private returns (bool) {
// We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since
// we're implementing it ourselves. We cannot use {Address-functionCall} here since this should return false
// and not revert is the subcall reverts.
(bool success, bytes memory returndata) = address(token).call(data);
return success && (returndata.length == 0 || abi.decode(returndata, (bool))) && address(token).code.length > 0;
}
}
{
"compilationTarget": {
"contracts/implementations/NAP721SingleTokenWithIrremovableTreasuryFee.sol": "NAP721SingleTokenWithIrremovableTreasuryFee"
},
"evmVersion": "paris",
"libraries": {},
"metadata": {
"bytecodeHash": "ipfs"
},
"optimizer": {
"enabled": true,
"runs": 200
},
"remappings": [
":@arbitrum/=node_modules/@arbitrum/",
":@chainlink/=node_modules/@chainlink/",
":@eth-optimism/=node_modules/@chainlink/contracts-ccip/node_modules/@eth-optimism/",
":@offchainlabs/=node_modules/@offchainlabs/",
":@openzeppelin/=node_modules/@openzeppelin/",
":@scroll-tech/=node_modules/@scroll-tech/",
":@uniswap/=node_modules/@uniswap/",
":base64-sol/=node_modules/base64-sol/",
":ds-test/=lib/murky/lib/forge-std/lib/ds-test/src/",
":erc721a/=node_modules/erc721a/",
":eth-gas-reporter/=node_modules/eth-gas-reporter/",
":forge-std/=lib/forge-std/src/",
":hardhat-deploy/=node_modules/hardhat-deploy/",
":hardhat/=node_modules/hardhat/",
":openzeppelin-contracts/=lib/murky/lib/openzeppelin-contracts/"
]
}
[{"inputs":[{"internalType":"contract IERC20","name":"_assuranceToken","type":"address"},{"internalType":"contract IERC20","name":"_collateralToken","type":"address"},{"internalType":"contract IERC20","name":"_b01Token","type":"address"},{"internalType":"address","name":"_nft","type":"address"},{"internalType":"address","name":"_feeRecipient","type":"address"},{"internalType":"address","name":"_treasury","type":"address"},{"internalType":"address","name":"_interfaceFeeReceiver","type":"address"},{"internalType":"contract IUniswapV2Router02","name":"_uniswapRouter","type":"address"},{"internalType":"uint16","name":"_treasuryFeePercentage","type":"uint16"},{"internalType":"uint16","name":"_deactivationFeePercentage","type":"uint16"},{"internalType":"uint16","name":"_NFTDeactivationPercentage","type":"uint16"}],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[{"internalType":"address","name":"target","type":"address"}],"name":"AddressEmptyCode","type":"error"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"AddressInsufficientBalance","type":"error"},{"inputs":[{"internalType":"uint256","name":"deactivationProfit","type":"uint256"},{"internalType":"uint256","name":"minDeactivationProfit","type":"uint256"}],"name":"DeactivationProfitAmountLessThanMin","type":"error"},{"inputs":[],"name":"FailedInnerCall","type":"error"},{"inputs":[{"internalType":"uint256","name":"liquidity","type":"uint256"},{"internalType":"uint256","name":"totalActivationPrice","type":"uint256"}],"name":"InsufficientLiquidityAdded","type":"error"},{"inputs":[{"internalType":"uint16","name":"deactivationFeePercentage","type":"uint16"}],"name":"InvalidDeactivationFeePercentage","type":"error"},{"inputs":[{"internalType":"address","name":"token","type":"address"}],"name":"InvalidToken","type":"error"},{"inputs":[{"internalType":"uint64","name":"period","type":"uint64"},{"internalType":"uint256","name":"maxDeactivationsPerPeriod","type":"uint256"},{"internalType":"uint16","name":"deactivationsCount","type":"uint16"}],"name":"MaxDeactivationAmountPerIntervalExceeded","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":[{"internalType":"uint256","name":"amountInMax","type":"uint256"},{"internalType":"uint256","name":"amountIn","type":"uint256"}],"name":"PriceExceedsAmountInMax","type":"error"},{"inputs":[],"name":"ReentrancyGuardReentrantCall","type":"error"},{"inputs":[{"internalType":"uint8","name":"bits","type":"uint8"},{"internalType":"uint256","name":"value","type":"uint256"}],"name":"SafeCastOverflowedUintDowncast","type":"error"},{"inputs":[{"internalType":"address","name":"token","type":"address"}],"name":"SafeERC20FailedOperation","type":"error"},{"inputs":[{"internalType":"uint256","name":"TokenId","type":"uint256"}],"name":"TokenIsGone","type":"error"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256[]","name":"tokenIds","type":"uint256[]"},{"indexed":false,"internalType":"uint256[]","name":"costForEachNFT","type":"uint256[]"},{"indexed":false,"internalType":"uint256","name":"activationPrices","type":"uint256"}],"name":"ActivateTokens","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"contract IERC20","name":"_assuranceToken","type":"address"},{"indexed":false,"internalType":"contract IERC20","name":"_b01Token","type":"address"},{"indexed":false,"internalType":"address","name":"_nft","type":"address"},{"indexed":false,"internalType":"address","name":"_feeRecipient","type":"address"},{"indexed":false,"internalType":"address","name":"_treasury","type":"address"},{"indexed":false,"internalType":"uint16","name":"_treasuryFeePercentage","type":"uint16"},{"indexed":false,"internalType":"uint16","name":"_deactivationFeePercentage","type":"uint16"},{"indexed":false,"internalType":"uint16","name":"_NFTDeactivationPercentage","type":"uint16"}],"name":"ContractInitialized","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256[]","name":"tokenIds","type":"uint256[]"},{"indexed":false,"internalType":"uint256[]","name":"costForEachNFT","type":"uint256[]"},{"indexed":false,"internalType":"uint256","name":"deactivationProfits","type":"uint256"}],"name":"DeactivateTokens","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint16","name":"newDeactivationFeePercentage","type":"uint16"}],"name":"DeactivationFeePercentageUpdated","type":"event"},{"anonymous":false,"inputs":[],"name":"DistributorProcessFailed","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"token","type":"address"},{"indexed":false,"internalType":"address","name":"to","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"EmergencyWithdraw","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint64","name":"newPeriodDuration","type":"uint64"},{"indexed":false,"internalType":"uint64","name":"periodDurationUpdatedAt","type":"uint64"}],"name":"IntervalDurationUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"maxDeactivationsPerPeriod","type":"uint256"}],"name":"MaxDeactivationsPerIntervalUpdated","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"},{"inputs":[],"name":"INTERFACE_FEE","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"INTERVAL_DURATION","outputs":[{"internalType":"uint64","name":"","type":"uint64"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256[]","name":"tokenIds","type":"uint256[]"},{"internalType":"address","name":"to","type":"address"}],"name":"activateTokens","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint64","name":"","type":"uint64"}],"name":"activationsCountByInterval","outputs":[{"internalType":"uint16","name":"","type":"uint16"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"assuranceToken","outputs":[{"internalType":"contract IERC20","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"b01Threshold","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"b01Token","outputs":[{"internalType":"contract IERC20","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256[]","name":"nftsToBeActivated","type":"uint256[]"}],"name":"calculateActivationCostFor","outputs":[{"internalType":"uint256[]","name":"","type":"uint256[]"},{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256[]","name":"nftsToBeDeactivated","type":"uint256[]"}],"name":"calculateDeactivationCostFor","outputs":[{"internalType":"uint256[]","name":"","type":"uint256[]"},{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256[]","name":"tokenIds","type":"uint256[]"},{"internalType":"uint256","name":"deactivationProfitAmountMin","type":"uint256"},{"internalType":"address","name":"to","type":"address"},{"internalType":"bool","name":"interfaceFeeEnabled","type":"bool"}],"name":"deactivateTokens","outputs":[{"internalType":"uint256","name":"deactivationAmount","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"deactivationFeePercentage","outputs":[{"internalType":"uint16","name":"","type":"uint16"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint64","name":"","type":"uint64"}],"name":"deactivationsCountByInterval","outputs":[{"internalType":"uint16","name":"","type":"uint16"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"asset","type":"address"},{"internalType":"address","name":"receiver","type":"address"}],"name":"emergencyWithdraw","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"feeRecipient","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getAmountNFTsInMarket","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getAvailableDeactivationCount","outputs":[{"internalType":"uint16","name":"","type":"uint16"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getCurrentInterval","outputs":[{"internalType":"uint64","name":"","type":"uint64"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"caller","type":"address"},{"internalType":"uint256[]","name":"nftsToBeDeactivated","type":"uint256[]"},{"internalType":"bool","name":"interfaceFeeEnabled","type":"bool"}],"name":"getDeactivationProfit","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getNFTPrice","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"interfaceFeeReceiver","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"intervalDurationUpdatedAt","outputs":[{"internalType":"uint64","name":"","type":"uint64"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"minimalDeactivationAmountPerInterval","outputs":[{"internalType":"uint16","name":"","type":"uint16"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"nft","outputs":[{"internalType":"contract IERC721Enumerable","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"address","name":"","type":"address"},{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"bytes","name":"","type":"bytes"}],"name":"onERC721Received","outputs":[{"internalType":"bytes4","name":"","type":"bytes4"}],"stateMutability":"pure","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"newB01Threshold","type":"uint256"}],"name":"setB01Threshold","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint16","name":"newDeactivationFeePercentage","type":"uint16"}],"name":"setDeactivationFeePercentage","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint16","name":"newMinDeactivationsPerIntervalPercentage","type":"uint16"}],"name":"setMinDeactivationsPerInterval","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint16","name":"_treasuryFeePercentage","type":"uint16"}],"name":"setTreasuryFeePercentage","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"treasury","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"treasuryFeePercentage","outputs":[{"internalType":"uint16","name":"","type":"uint16"}],"stateMutability":"view","type":"function"}]