Warning! Contract bytecode has been changed and doesn't match the verified one. Therefore, interaction with this smart contract may be risky.
- Contract name:
- XBURN
- Optimization enabled
- true
- Compiler version
- v0.8.26+commit.8a97fa7a
- Optimization runs
- 200
- EVM Version
- paris
- Verified at
- 2024-10-27T19:08:54.211327Z
Constructor Arguments
0x00000000000000000000000067361bdf355a485a9d3841ba58308e48ac13f953
Arg [0] (address) : 0x67361bdf355a485a9d3841ba58308e48ac13f953
contracts/XBURN.sol
// SPDX-License-Identifier: MIT
pragma solidity =0.8.26 ^0.8.20;
// lib/openzeppelin-contracts/contracts/interfaces/draft-IERC6093.sol
// OpenZeppelin Contracts (last updated v5.0.0) (interfaces/draft-IERC6093.sol)
/**
* @dev Standard ERC20 Errors
* Interface of the https://eips.ethereum.org/EIPS/eip-6093[ERC-6093] custom errors for ERC20 tokens.
*/
interface IERC20Errors {
/**
* @dev Indicates an error related to the current `balance` of a `sender`. Used in transfers.
* @param sender Address whose tokens are being transferred.
* @param balance Current balance for the interacting account.
* @param needed Minimum amount required to perform a transfer.
*/
error ERC20InsufficientBalance(address sender, uint256 balance, uint256 needed);
/**
* @dev Indicates a failure with the token `sender`. Used in transfers.
* @param sender Address whose tokens are being transferred.
*/
error ERC20InvalidSender(address sender);
/**
* @dev Indicates a failure with the token `receiver`. Used in transfers.
* @param receiver Address to which tokens are being transferred.
*/
error ERC20InvalidReceiver(address receiver);
/**
* @dev Indicates a failure with the `spender`’s `allowance`. Used in transfers.
* @param spender Address that may be allowed to operate on tokens without being their owner.
* @param allowance Amount of tokens a `spender` is allowed to operate with.
* @param needed Minimum amount required to perform a transfer.
*/
error ERC20InsufficientAllowance(address spender, uint256 allowance, uint256 needed);
/**
* @dev Indicates a failure with the `approver` of a token to be approved. Used in approvals.
* @param approver Address initiating an approval operation.
*/
error ERC20InvalidApprover(address approver);
/**
* @dev Indicates a failure with the `spender` to be approved. Used in approvals.
* @param spender Address that may be allowed to operate on tokens without being their owner.
*/
error ERC20InvalidSpender(address spender);
}
/**
* @dev Standard ERC721 Errors
* Interface of the https://eips.ethereum.org/EIPS/eip-6093[ERC-6093] custom errors for ERC721 tokens.
*/
interface IERC721Errors {
/**
* @dev Indicates that an address can't be an owner. For example, `address(0)` is a forbidden owner in EIP-20.
* Used in balance queries.
* @param owner Address of the current owner of a token.
*/
error ERC721InvalidOwner(address owner);
/**
* @dev Indicates a `tokenId` whose `owner` is the zero address.
* @param tokenId Identifier number of a token.
*/
error ERC721NonexistentToken(uint256 tokenId);
/**
* @dev Indicates an error related to the ownership over a particular token. Used in transfers.
* @param sender Address whose tokens are being transferred.
* @param tokenId Identifier number of a token.
* @param owner Address of the current owner of a token.
*/
error ERC721IncorrectOwner(address sender, uint256 tokenId, address owner);
/**
* @dev Indicates a failure with the token `sender`. Used in transfers.
* @param sender Address whose tokens are being transferred.
*/
error ERC721InvalidSender(address sender);
/**
* @dev Indicates a failure with the token `receiver`. Used in transfers.
* @param receiver Address to which tokens are being transferred.
*/
error ERC721InvalidReceiver(address receiver);
/**
* @dev Indicates a failure with the `operator`’s approval. Used in transfers.
* @param operator Address that may be allowed to operate on tokens without being their owner.
* @param tokenId Identifier number of a token.
*/
error ERC721InsufficientApproval(address operator, uint256 tokenId);
/**
* @dev Indicates a failure with the `approver` of a token to be approved. Used in approvals.
* @param approver Address initiating an approval operation.
*/
error ERC721InvalidApprover(address approver);
/**
* @dev Indicates a failure with the `operator` to be approved. Used in approvals.
* @param operator Address that may be allowed to operate on tokens without being their owner.
*/
error ERC721InvalidOperator(address operator);
}
/**
* @dev Standard ERC1155 Errors
* Interface of the https://eips.ethereum.org/EIPS/eip-6093[ERC-6093] custom errors for ERC1155 tokens.
*/
interface IERC1155Errors {
/**
* @dev Indicates an error related to the current `balance` of a `sender`. Used in transfers.
* @param sender Address whose tokens are being transferred.
* @param balance Current balance for the interacting account.
* @param needed Minimum amount required to perform a transfer.
* @param tokenId Identifier number of a token.
*/
error ERC1155InsufficientBalance(address sender, uint256 balance, uint256 needed, uint256 tokenId);
/**
* @dev Indicates a failure with the token `sender`. Used in transfers.
* @param sender Address whose tokens are being transferred.
*/
error ERC1155InvalidSender(address sender);
/**
* @dev Indicates a failure with the token `receiver`. Used in transfers.
* @param receiver Address to which tokens are being transferred.
*/
error ERC1155InvalidReceiver(address receiver);
/**
* @dev Indicates a failure with the `operator`’s approval. Used in transfers.
* @param operator Address that may be allowed to operate on tokens without being their owner.
* @param owner Address of the current owner of a token.
*/
error ERC1155MissingApprovalForAll(address operator, address owner);
/**
* @dev Indicates a failure with the `approver` of a token to be approved. Used in approvals.
* @param approver Address initiating an approval operation.
*/
error ERC1155InvalidApprover(address approver);
/**
* @dev Indicates a failure with the `operator` to be approved. Used in approvals.
* @param operator Address that may be allowed to operate on tokens without being their owner.
*/
error ERC1155InvalidOperator(address operator);
/**
* @dev Indicates an array length mismatch between ids and values in a safeBatchTransferFrom operation.
* Used in batch transfers.
* @param idsLength Length of the array of token identifiers
* @param valuesLength Length of the array of token amounts
*/
error ERC1155InvalidArrayLength(uint256 idsLength, uint256 valuesLength);
}
// lib/openzeppelin-contracts/contracts/token/ERC20/IERC20.sol
// OpenZeppelin Contracts (last updated v5.0.0) (token/ERC20/IERC20.sol)
/**
* @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);
}
// lib/openzeppelin-contracts/contracts/token/ERC20/extensions/IERC20Permit.sol
// OpenZeppelin Contracts (last updated v5.0.0) (token/ERC20/extensions/IERC20Permit.sol)
/**
* @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);
}
// lib/openzeppelin-contracts/contracts/utils/Address.sol
// OpenZeppelin Contracts (last updated v5.0.0) (utils/Address.sol)
/**
* @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();
}
}
}
// lib/openzeppelin-contracts/contracts/utils/Context.sol
// OpenZeppelin Contracts (last updated v5.0.1) (utils/Context.sol)
/**
* @dev Provides information about the current execution context, including the
* sender of the transaction and its data. While these are generally available
* via msg.sender and msg.data, they should not be accessed in such a direct
* manner, since when dealing with meta-transactions the account sending and
* paying for execution may not be the actual sender (as far as an application
* is concerned).
*
* This contract is only required for intermediate, library-like contracts.
*/
abstract contract 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;
}
}
// lib/openzeppelin-contracts/contracts/utils/ReentrancyGuard.sol
// OpenZeppelin Contracts (last updated v5.0.0) (utils/ReentrancyGuard.sol)
/**
* @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;
}
}
// src/const/Constants.sol
// Token addresses
address constant X = address(0xA6C4790cc7Aa22CA27327Cb83276F2aBD687B55b);
address constant PVOLT = address(0x74758472AddC95944769E8aDac07E391c31cAc82);
// Distribution addresses
address constant GENESIS_WALLET = address(0xF8e6beB518b7Ea2c932414F7fc50F466B3e1D89e);
address constant BURN_WALLET = address(0x0000000000000000000000000000000000000369);
address constant LIQUIDITY_PROVIDER = address(0xC2C920A656DF618f95dBDb492D24b1A9eD812718);
address constant BNB_PVOLT_V1_ADDR = address(0x1759e91E3Fd2c8F7eB009f36e427AE3b92Fb078f);
address constant RAFFLE_GAME_ADDR = address(0xd119A3E1730A6b5384621e492d3DE3d245b05671);
uint64 constant BNB_XBURN_AND_VAULT = 0.73e18; // 73%
uint64 constant LP_XBURN = 0.04e18; // 4% XBURN/X and XBURN/WPLS
uint64 constant GENESIS = 0.03e18; // 3%
uint64 constant RAFFLE_GAME_POT = 0.01e18; // 1%
uint64 constant BNB_X = 0.02e18; // 2%
uint64 constant BNB_PVOLT_V1 = 0.05e18; // 5%
uint64 constant LP_PVOLT = 0.12e18; // 12% WPLS, PLSX, HEX, ATROPA, DAI, TEDDY, X, XBURN
uint64 constant DISTRIBUTION_FROM_THE_VAULT = 0.2e18; // 20%
uint96 constant INITIAL_PLS_FOR_LIQ = 112_000_000 ether;
uint96 constant AUCTION_EMIT = 100_000_000 ether;
uint96 constant INITIAL_XBURN_FOR_LIQ = 5_000_000 ether;
// src/interfaces/IPulseX.sol
interface IPulseXFactory {
function createPair(address tokenA, address tokenB) external returns (address pair);
function getPair(address tokenA, address tokenB) external returns (address pair);
}
interface IPulseXRouter {
function factory() external pure returns (address);
function WPLS() external pure returns (address);
function addLiquidityETH(
address token,
uint256 amountTokenDesired,
uint256 amountTokenMin,
uint256 amountETHMin,
address to,
uint256 deadline
) external payable returns (uint256 amountToken, uint256 amountETH, uint256 liquidity);
function addLiquidity(
address tokenA,
address tokenB,
uint256 amountADesired,
uint256 amountBDesired,
uint256 amountAMin,
uint256 amountBMin,
address to,
uint256 deadline
) external returns (uint256 amountA, uint256 amountB, uint256 liquidity);
function removeLiquidityETHSupportingFeeOnTransferTokens(
address token,
uint256 liquidity,
uint256 amountTokenMin,
uint256 amountETHMin,
address to,
uint256 deadline
) external returns (uint256 amountETH);
function removeLiquidity(
address tokenA,
address tokenB,
uint256 liquidity,
uint256 amountAMin,
uint256 amountBMin,
address to,
uint256 deadline
) external returns (uint256 amountA, uint256 amountB);
function swapExactTokensForTokens(
uint256 amountIn,
uint256 amountOutMin,
address[] calldata path,
address to,
uint256 deadline
) external returns (uint256[] memory amounts);
function swapExactTokensForETHSupportingFeeOnTransferTokens(
uint256 amountIn,
uint256 amountOutMin,
address[] calldata path,
address to,
uint256 deadline
) external;
function swapExactETHForTokensSupportingFeeOnTransferTokens(
uint256 amountOutMin,
address[] calldata path,
address to,
uint256 deadline
) external payable;
function swapExactETHForTokens(uint256 amountOutMin, address[] calldata path, address to, uint256 deadline)
external
payable
returns (uint256[] memory amounts);
}
interface PulseXPair {
function token0() external pure returns (address);
function token1() external pure returns (address);
function getReserves() external view returns (uint112 reserve0, uint112 reserve1, uint32 blockTimestampLast);
}
// src/utils/Errors.sol
contract Errors {
error Address0();
error Amount0();
error Expired();
modifier notAmount0(uint256 a) {
_notAmount0(a);
_;
}
modifier notExpired(uint32 _deadline) {
if (block.timestamp > _deadline) revert Expired();
_;
}
modifier notAddress0(address a) {
_notAddress0(a);
_;
}
function _notAddress0(address a) internal pure {
if (a == address(0)) revert Address0();
}
function _notAmount0(uint256 a) internal pure {
if (a == 0) revert Amount0();
}
}
// src/utils/Math.sol
/* solhint-disable func-visibility, no-inline-assembly */
error Math__toInt256_overflow();
error Math__toUint64_overflow();
error Math__add_overflow_signed();
error Math__sub_overflow_signed();
error Math__mul_overflow_signed();
error Math__mul_overflow();
error Math__div_overflow();
uint256 constant WAD = 1e18;
/// @dev Taken from https://github.com/Vectorized/solady/blob/6d706e05ef43cbed234c648f83c55f3a4bb0a520/src/utils/SafeCastLib.sol#L367
function toInt256(uint256 x) pure returns (int256) {
if (x >= 1 << 255) revert Math__toInt256_overflow();
return int256(x);
}
/// @dev Taken from https://github.com/Vectorized/solady/blob/6d706e05ef43cbed234c648f83c55f3a4bb0a520/src/utils/SafeCastLib.sol#L53
function toUint64(uint256 x) pure returns (uint64) {
if (x >= 1 << 64) revert Math__toUint64_overflow();
return uint64(x);
}
/// @dev Taken from https://github.com/Vectorized/solady/blob/6d706e05ef43cbed234c648f83c55f3a4bb0a520/src/utils/FixedPointMathLib.sol#L602
function abs(int256 x) pure returns (uint256 z) {
assembly ("memory-safe") {
let mask := sub(0, shr(255, x))
z := xor(mask, add(mask, x))
}
}
/// @dev Taken from https://github.com/Vectorized/solady/blob/6d706e05ef43cbed234c648f83c55f3a4bb0a520/src/utils/FixedPointMathLib.sol#L620
function min_0(uint256 x, uint256 y) pure returns (uint256 z) {
assembly ("memory-safe") {
z := xor(x, mul(xor(x, y), lt(y, x)))
}
}
/// @dev Taken from https://github.com/Vectorized/solady/blob/6d706e05ef43cbed234c648f83c55f3a4bb0a520/src/utils/FixedPointMathLib.sol#L628
function min_1(int256 x, int256 y) pure returns (int256 z) {
assembly ("memory-safe") {
z := xor(x, mul(xor(x, y), slt(y, x)))
}
}
/// @dev Taken from https://github.com/Vectorized/solady/blob/6d706e05ef43cbed234c648f83c55f3a4bb0a520/src/utils/FixedPointMathLib.sol#L636
function max(uint256 x, uint256 y) pure returns (uint256 z) {
assembly ("memory-safe") {
z := xor(x, mul(xor(x, y), gt(y, x)))
}
}
/// @dev Taken from https://github.com/makerdao/dss/blob/fa4f6630afb0624d04a003e920b0d71a00331d98/src/vat.sol#L74
function add(uint256 x, int256 y) pure returns (uint256 z) {
assembly ("memory-safe") {
z := add(x, y)
}
if ((y > 0 && z < x) || (y < 0 && z > x)) {
revert Math__add_overflow_signed();
}
}
/// @dev Taken from https://github.com/makerdao/dss/blob/fa4f6630afb0624d04a003e920b0d71a00331d98/src/vat.sol#L79
function sub(uint256 x, int256 y) pure returns (uint256 z) {
assembly ("memory-safe") {
z := sub(x, y)
}
if ((y > 0 && z > x) || (y < 0 && z < x)) {
revert Math__sub_overflow_signed();
}
}
/// @dev Taken from https://github.com/makerdao/dss/blob/fa4f6630afb0624d04a003e920b0d71a00331d98/src/vat.sol#L84
function mul(uint256 x, int256 y) pure returns (int256 z) {
unchecked {
z = int256(x) * y;
if (int256(x) < 0 || (y != 0 && z / y != int256(x))) {
revert Math__mul_overflow_signed();
}
}
}
/// @dev Equivalent to `(x * y) / WAD` rounded down.
/// @dev Taken from https://github.com/Vectorized/solady/blob/6d706e05ef43cbed234c648f83c55f3a4bb0a520/src/utils/FixedPointMathLib.sol#L54
function wmul_0(uint256 x, uint256 y) pure returns (uint256 z) {
assembly ("memory-safe") {
// Equivalent to `require(y == 0 || x <= type(uint256).max / y)`.
if mul(y, gt(x, div(not(0), y))) {
// Store the function selector of `Math__mul_overflow()`.
mstore(0x00, 0xc4c5d7f5)
// Revert with (offset, size).
revert(0x1c, 0x04)
}
z := div(mul(x, y), WAD)
}
}
function wmul_1(uint256 x, int256 y) pure returns (int256 z) {
unchecked {
z = mul(x, y) / int256(WAD);
}
}
/// @dev Equivalent to `(x * y) / WAD` rounded up.
/// @dev Taken from https://github.com/Vectorized/solady/blob/969a78905274b32cdb7907398c443f7ea212e4f4/src/utils/FixedPointMathLib.sol#L69C22-L69C22
function wmulUp(uint256 x, uint256 y) pure returns (uint256 z) {
/// @solidity memory-safe-assembly
assembly {
// Equivalent to `require(y == 0 || x <= type(uint256).max / y)`.
if mul(y, gt(x, div(not(0), y))) {
// Store the function selector of `Math__mul_overflow()`.
mstore(0x00, 0xc4c5d7f5)
// Revert with (offset, size).
revert(0x1c, 0x04)
}
z := add(iszero(iszero(mod(mul(x, y), WAD))), div(mul(x, y), WAD))
}
}
/// @dev Equivalent to `(x * WAD) / y` rounded down.
/// @dev Taken from https://github.com/Vectorized/solady/blob/6d706e05ef43cbed234c648f83c55f3a4bb0a520/src/utils/FixedPointMathLib.sol#L84
function wdiv(uint256 x, uint256 y) pure returns (uint256 z) {
assembly ("memory-safe") {
// Equivalent to `require(y != 0 && (WAD == 0 || x <= type(uint256).max / WAD))`.
if iszero(mul(y, iszero(mul(WAD, gt(x, div(not(0), WAD)))))) {
// Store the function selector of `Math__div_overflow()`.
mstore(0x00, 0xbcbede65)
// Revert with (offset, size).
revert(0x1c, 0x04)
}
z := div(mul(x, WAD), y)
}
}
/// @dev Equivalent to `(x * WAD) / y` rounded up.
/// @dev Taken from https://github.com/Vectorized/solady/blob/969a78905274b32cdb7907398c443f7ea212e4f4/src/utils/FixedPointMathLib.sol#L99
function wdivUp(uint256 x, uint256 y) pure returns (uint256 z) {
/// @solidity memory-safe-assembly
assembly {
// Equivalent to `require(y != 0 && (WAD == 0 || x <= type(uint256).max / WAD))`.
if iszero(mul(y, iszero(mul(WAD, gt(x, div(not(0), WAD)))))) {
// Store the function selector of `Math__div_overflow()`.
mstore(0x00, 0xbcbede65)
// Revert with (offset, size).
revert(0x1c, 0x04)
}
z := add(iszero(iszero(mod(mul(x, WAD), y))), div(mul(x, WAD), y))
}
}
/// @dev Taken from https://github.com/makerdao/dss/blob/fa4f6630afb0624d04a003e920b0d71a00331d98/src/jug.sol#L62
function wpow_0(uint256 x, uint256 n, uint256 b) pure returns (uint256 z) {
unchecked {
assembly ("memory-safe") {
switch n
case 0 { z := b }
default {
switch x
case 0 { z := 0 }
default {
switch mod(n, 2)
case 0 { z := b }
default { z := x }
let half := div(b, 2) // for rounding.
for { n := div(n, 2) } n { n := div(n, 2) } {
let xx := mul(x, x)
if shr(128, x) { revert(0, 0) }
let xxRound := add(xx, half)
if lt(xxRound, xx) { revert(0, 0) }
x := div(xxRound, b)
if mod(n, 2) {
let zx := mul(z, x)
if and(iszero(iszero(x)), iszero(eq(div(zx, x), z))) { revert(0, 0) }
let zxRound := add(zx, half)
if lt(zxRound, zx) { revert(0, 0) }
z := div(zxRound, b)
}
}
}
}
}
}
}
/// @dev Taken from https://github.com/Vectorized/solady/blob/cde0a5fb594da8655ba6bfcdc2e40a7c870c0cc0/src/utils/FixedPointMathLib.sol#L110
/// @dev Equivalent to `x` to the power of `y`.
/// because `x ** y = (e ** ln(x)) ** y = e ** (ln(x) * y)`.
function wpow_1(int256 x, int256 y) pure returns (int256) {
// Using `ln(x)` means `x` must be greater than 0.
return wexp((wln(x) * y) / int256(WAD));
}
/// @dev Taken from https://github.com/Vectorized/solady/blob/cde0a5fb594da8655ba6bfcdc2e40a7c870c0cc0/src/utils/FixedPointMathLib.sol#L116
/// @dev Returns `exp(x)`, denominated in `WAD`.
function wexp(int256 x) pure returns (int256 r) {
unchecked {
// When the result is < 0.5 we return zero. This happens when
// x <= floor(log(0.5e18) * 1e18) ~ -42e18
if (x <= -42139678854452767551) return r;
/// @solidity memory-safe-assembly
assembly {
// When the result is > (2**255 - 1) / 1e18 we can not represent it as an
// int. This happens when x >= floor(log((2**255 - 1) / 1e18) * 1e18) ~ 135.
if iszero(slt(x, 135305999368893231589)) {
mstore(0x00, 0xa37bfec9) // `ExpOverflow()`.
revert(0x1c, 0x04)
}
}
// x is now in the range (-42, 136) * 1e18. Convert to (-42, 136) * 2**96
// for more intermediate precision and a binary basis. This base conversion
// is a multiplication by 1e18 / 2**96 = 5**18 / 2**78.
x = (x << 78) / 5 ** 18;
// Reduce range of x to (-½ ln 2, ½ ln 2) * 2**96 by factoring out powers
// of two such that exp(x) = exp(x') * 2**k, where k is an integer.
// Solving this gives k = round(x / log(2)) and x' = x - k * log(2).
int256 k = ((x << 96) / 54916777467707473351141471128 + 2 ** 95) >> 96;
x = x - k * 54916777467707473351141471128;
// k is in the range [-61, 195].
// Evaluate using a (6, 7)-term rational approximation.
// p is made monic, we'll multiply by a scale factor later.
int256 y = x + 1346386616545796478920950773328;
y = ((y * x) >> 96) + 57155421227552351082224309758442;
int256 p = y + x - 94201549194550492254356042504812;
p = ((p * y) >> 96) + 28719021644029726153956944680412240;
p = p * x + (4385272521454847904659076985693276 << 96);
// We leave p in 2**192 basis so we don't need to scale it back up for the division.
int256 q = x - 2855989394907223263936484059900;
q = ((q * x) >> 96) + 50020603652535783019961831881945;
q = ((q * x) >> 96) - 533845033583426703283633433725380;
q = ((q * x) >> 96) + 3604857256930695427073651918091429;
q = ((q * x) >> 96) - 14423608567350463180887372962807573;
q = ((q * x) >> 96) + 26449188498355588339934803723976023;
/// @solidity memory-safe-assembly
assembly {
// Div in assembly because solidity adds a zero check despite the unchecked.
// The q polynomial won't have zeros in the domain as all its roots are complex.
// No scaling is necessary because p is already 2**96 too large.
r := sdiv(p, q)
}
// r should be in the range (0.09, 0.25) * 2**96.
// We now need to multiply r by:
// * the scale factor s = ~6.031367120.
// * the 2**k factor from the range reduction.
// * the 1e18 / 2**96 factor for base conversion.
// We do this all at once, with an intermediate result in 2**213
// basis, so the final right shift is always by a positive amount.
r = int256((uint256(r) * 3822833074963236453042738258902158003155416615667) >> uint256(195 - k));
}
}
/// @dev Taken from https://github.com/Vectorized/solady/blob/cde0a5fb594da8655ba6bfcdc2e40a7c870c0cc0/src/utils/FixedPointMathLib.sol#L184
/// @dev Returns `ln(x)`, denominated in `WAD`.
function wln(int256 x) pure returns (int256 r) {
unchecked {
/// @solidity memory-safe-assembly
assembly {
if iszero(sgt(x, 0)) {
mstore(0x00, 0x1615e638) // `LnWadUndefined()`.
revert(0x1c, 0x04)
}
}
// We want to convert x from 10**18 fixed point to 2**96 fixed point.
// We do this by multiplying by 2**96 / 10**18. But since
// ln(x * C) = ln(x) + ln(C), we can simply do nothing here
// and add ln(2**96 / 10**18) at the end.
// Compute k = log2(x) - 96, t = 159 - k = 255 - log2(x) = 255 ^ log2(x).
int256 t;
/// @solidity memory-safe-assembly
assembly {
t := shl(7, lt(0xffffffffffffffffffffffffffffffff, x))
t := or(t, shl(6, lt(0xffffffffffffffff, shr(t, x))))
t := or(t, shl(5, lt(0xffffffff, shr(t, x))))
t := or(t, shl(4, lt(0xffff, shr(t, x))))
t := or(t, shl(3, lt(0xff, shr(t, x))))
// forgefmt: disable-next-item
t := xor(
t,
byte(
and(
0x1f,
shr(shr(t, x), 0x8421084210842108cc6318c6db6d54be)
),
0xf8f9f9faf9fdfafbf9fdfcfdfafbfcfef9fafdfafcfcfbfefafafcfbffffffff
)
)
}
// Reduce range of x to (1, 2) * 2**96
// ln(2^k * x) = k * ln(2) + ln(x)
x = int256(uint256(x << uint256(t)) >> 159);
// Evaluate using a (8, 8)-term rational approximation.
// p is made monic, we will multiply by a scale factor later.
int256 p = x + 3273285459638523848632254066296;
p = ((p * x) >> 96) + 24828157081833163892658089445524;
p = ((p * x) >> 96) + 43456485725739037958740375743393;
p = ((p * x) >> 96) - 11111509109440967052023855526967;
p = ((p * x) >> 96) - 45023709667254063763336534515857;
p = ((p * x) >> 96) - 14706773417378608786704636184526;
p = p * x - (795164235651350426258249787498 << 96);
// We leave p in 2**192 basis so we don't need to scale it back up for the division.
// q is monic by convention.
int256 q = x + 5573035233440673466300451813936;
q = ((q * x) >> 96) + 71694874799317883764090561454958;
q = ((q * x) >> 96) + 283447036172924575727196451306956;
q = ((q * x) >> 96) + 401686690394027663651624208769553;
q = ((q * x) >> 96) + 204048457590392012362485061816622;
q = ((q * x) >> 96) + 31853899698501571402653359427138;
q = ((q * x) >> 96) + 909429971244387300277376558375;
/// @solidity memory-safe-assembly
assembly {
// Div in assembly because solidity adds a zero check despite the unchecked.
// The q polynomial is known not to have zeros in the domain.
// No scaling required because p is already 2**96 too large.
r := sdiv(p, q)
}
// r is in the range (0, 0.125) * 2**96
// Finalization, we need to:
// * multiply by the scale factor s = 5.549…
// * add ln(2**96 / 10**18)
// * add k * ln(2)
// * multiply by 10**18 / 2**96 = 5**18 >> 78
// mul s * 5e18 * 2**96, base is now 5**18 * 2**192
r *= 1677202110996718588342820967067443963516166;
// add ln(2) * k * 5e18 * 2**192
r += 16597577552685614221487285958193947469193820559219878177908093499208371 * (159 - t);
// add ln(2**96 / 10**18) * 5e18 * 2**192
r += 600920179829731861736702779321621459595472258049074101567377883020018308;
// base conversion: mul 2**18 / 2**192
r >>= 174;
}
}
/// @dev Returns the square root of `x`, rounded down.
function sqrt(uint256 x) pure returns (uint256 z) {
/// @solidity memory-safe-assembly
assembly {
// `floor(sqrt(2**15)) = 181`. `sqrt(2**15) - 181 = 2.84`.
z := 181 // The "correct" value is 1, but this saves a multiplication later.
// This segment is to get a reasonable initial estimate for the Babylonian method. With a bad
// start, the correct # of bits increases ~linearly each iteration instead of ~quadratically.
// Let `y = x / 2**r`. We check `y >= 2**(k + 8)`
// but shift right by `k` bits to ensure that if `x >= 256`, then `y >= 256`.
let r := shl(7, lt(0xffffffffffffffffffffffffffffffffff, x))
r := or(r, shl(6, lt(0xffffffffffffffffff, shr(r, x))))
r := or(r, shl(5, lt(0xffffffffff, shr(r, x))))
r := or(r, shl(4, lt(0xffffff, shr(r, x))))
z := shl(shr(1, r), z)
// Goal was to get `z*z*y` within a small factor of `x`. More iterations could
// get y in a tighter range. Currently, we will have y in `[256, 256*(2**16))`.
// We ensured `y >= 256` so that the relative difference between `y` and `y+1` is small.
// That's not possible if `x < 256` but we can just verify those cases exhaustively.
// Now, `z*z*y <= x < z*z*(y+1)`, and `y <= 2**(16+8)`, and either `y >= 256`, or `x < 256`.
// Correctness can be checked exhaustively for `x < 256`, so we assume `y >= 256`.
// Then `z*sqrt(y)` is within `sqrt(257)/sqrt(256)` of `sqrt(x)`, or about 20bps.
// For `s` in the range `[1/256, 256]`, the estimate `f(s) = (181/1024) * (s+1)`
// is in the range `(1/2.84 * sqrt(s), 2.84 * sqrt(s))`,
// with largest error when `s = 1` and when `s = 256` or `1/256`.
// Since `y` is in `[256, 256*(2**16))`, let `a = y/65536`, so that `a` is in `[1/256, 256)`.
// Then we can estimate `sqrt(y)` using
// `sqrt(65536) * 181/1024 * (a + 1) = 181/4 * (y + 65536)/65536 = 181 * (y + 65536)/2**18`.
// There is no overflow risk here since `y < 2**136` after the first branch above.
z := shr(18, mul(z, add(shr(r, x), 65536))) // A `mul()` is saved from starting `z` at 181.
// Given the worst case multiplicative error of 2.84 above, 7 iterations should be enough.
z := shr(1, add(z, div(x, z)))
z := shr(1, add(z, div(x, z)))
z := shr(1, add(z, div(x, z)))
z := shr(1, add(z, div(x, z)))
z := shr(1, add(z, div(x, z)))
z := shr(1, add(z, div(x, z)))
z := shr(1, add(z, div(x, z)))
// If `x+1` is a perfect square, the Babylonian method cycles between
// `floor(sqrt(x))` and `ceil(sqrt(x))`. This statement ensures we return floor.
// See: https://en.wikipedia.org/wiki/Integer_square_root#Using_only_integer_division
z := sub(z, lt(div(x, z), z))
}
}
// src/utils/Time.sol
library Time {
function blockTs() internal view returns (uint32 ts) {
assembly {
ts := timestamp()
}
}
function dayCountByT(uint32 t) internal pure returns (uint32 dayCount) {
assembly {
let adjustedTime := sub(t, 50400)
dayCount := div(adjustedTime, 86400)
}
}
function daysSince(uint32 t) public view returns (uint32 daysPassed) {
assembly {
let currentTime := timestamp()
daysPassed := div(sub(currentTime, t), 86400)
}
}
function hoursSince(uint32 t) public view returns (uint32 hoursPassed) {
assembly {
let currentTime := timestamp()
hoursPassed := div(sub(currentTime, t), 3600)
}
}
}
// lib/openzeppelin-contracts/contracts/access/Ownable.sol
// OpenZeppelin Contracts (last updated v5.0.0) (access/Ownable.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);
}
}
// lib/openzeppelin-contracts/contracts/token/ERC20/extensions/IERC20Metadata.sol
// OpenZeppelin Contracts (last updated v5.0.0) (token/ERC20/extensions/IERC20Metadata.sol)
/**
* @dev Interface for the optional metadata functions from the ERC20 standard.
*/
interface IERC20Metadata is IERC20 {
/**
* @dev Returns the name of the token.
*/
function name() external view returns (string memory);
/**
* @dev Returns the symbol of the token.
*/
function symbol() external view returns (string memory);
/**
* @dev Returns the decimals places of the token.
*/
function decimals() external view returns (uint8);
}
// lib/openzeppelin-contracts/contracts/token/ERC20/utils/SafeERC20.sol
// OpenZeppelin Contracts (last updated v5.0.0) (token/ERC20/utils/SafeERC20.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;
}
}
// lib/openzeppelin-contracts/contracts/token/ERC20/ERC20.sol
// OpenZeppelin Contracts (last updated v5.0.0) (token/ERC20/ERC20.sol)
/**
* @dev Implementation of the {IERC20} interface.
*
* This implementation is agnostic to the way tokens are created. This means
* that a supply mechanism has to be added in a derived contract using {_mint}.
*
* TIP: For a detailed writeup see our guide
* https://forum.openzeppelin.com/t/how-to-implement-erc20-supply-mechanisms/226[How
* to implement supply mechanisms].
*
* The default value of {decimals} is 18. To change this, you should override
* this function so it returns a different value.
*
* We have followed general OpenZeppelin Contracts guidelines: functions revert
* instead returning `false` on failure. This behavior is nonetheless
* conventional and does not conflict with the expectations of ERC20
* applications.
*
* Additionally, an {Approval} event is emitted on calls to {transferFrom}.
* This allows applications to reconstruct the allowance for all accounts just
* by listening to said events. Other implementations of the EIP may not emit
* these events, as it isn't required by the specification.
*/
abstract contract ERC20 is Context, IERC20, IERC20Metadata, IERC20Errors {
mapping(address account => uint256) private _balances;
mapping(address account => mapping(address spender => uint256)) private _allowances;
uint256 private _totalSupply;
string private _name;
string private _symbol;
/**
* @dev Sets the values for {name} and {symbol}.
*
* All two of these values are immutable: they can only be set once during
* construction.
*/
constructor(string memory name_, string memory symbol_) {
_name = name_;
_symbol = symbol_;
}
/**
* @dev Returns the name of the token.
*/
function name() public view virtual returns (string memory) {
return _name;
}
/**
* @dev Returns the symbol of the token, usually a shorter version of the
* name.
*/
function symbol() public view virtual returns (string memory) {
return _symbol;
}
/**
* @dev Returns the number of decimals used to get its user representation.
* For example, if `decimals` equals `2`, a balance of `505` tokens should
* be displayed to a user as `5.05` (`505 / 10 ** 2`).
*
* Tokens usually opt for a value of 18, imitating the relationship between
* Ether and Wei. This is the default value returned by this function, unless
* it's overridden.
*
* NOTE: This information is only used for _display_ purposes: it in
* no way affects any of the arithmetic of the contract, including
* {IERC20-balanceOf} and {IERC20-transfer}.
*/
function decimals() public view virtual returns (uint8) {
return 18;
}
/**
* @dev See {IERC20-totalSupply}.
*/
function totalSupply() public view virtual returns (uint256) {
return _totalSupply;
}
/**
* @dev See {IERC20-balanceOf}.
*/
function balanceOf(address account) public view virtual returns (uint256) {
return _balances[account];
}
/**
* @dev See {IERC20-transfer}.
*
* Requirements:
*
* - `to` cannot be the zero address.
* - the caller must have a balance of at least `value`.
*/
function transfer(address to, uint256 value) public virtual returns (bool) {
address owner = _msgSender();
_transfer(owner, to, value);
return true;
}
/**
* @dev See {IERC20-allowance}.
*/
function allowance(address owner, address spender) public view virtual returns (uint256) {
return _allowances[owner][spender];
}
/**
* @dev See {IERC20-approve}.
*
* NOTE: If `value` is the maximum `uint256`, the allowance is not updated on
* `transferFrom`. This is semantically equivalent to an infinite approval.
*
* Requirements:
*
* - `spender` cannot be the zero address.
*/
function approve(address spender, uint256 value) public virtual returns (bool) {
address owner = _msgSender();
_approve(owner, spender, value);
return true;
}
/**
* @dev See {IERC20-transferFrom}.
*
* Emits an {Approval} event indicating the updated allowance. This is not
* required by the EIP. See the note at the beginning of {ERC20}.
*
* NOTE: Does not update the allowance if the current allowance
* is the maximum `uint256`.
*
* Requirements:
*
* - `from` and `to` cannot be the zero address.
* - `from` must have a balance of at least `value`.
* - the caller must have allowance for ``from``'s tokens of at least
* `value`.
*/
function transferFrom(address from, address to, uint256 value) public virtual returns (bool) {
address spender = _msgSender();
_spendAllowance(from, spender, value);
_transfer(from, to, value);
return true;
}
/**
* @dev Moves a `value` amount of tokens from `from` to `to`.
*
* This internal function is equivalent to {transfer}, and can be used to
* e.g. implement automatic token fees, slashing mechanisms, etc.
*
* Emits a {Transfer} event.
*
* NOTE: This function is not virtual, {_update} should be overridden instead.
*/
function _transfer(address from, address to, uint256 value) internal {
if (from == address(0)) {
revert ERC20InvalidSender(address(0));
}
if (to == address(0)) {
revert ERC20InvalidReceiver(address(0));
}
_update(from, to, value);
}
/**
* @dev Transfers a `value` amount of tokens from `from` to `to`, or alternatively mints (or burns) if `from`
* (or `to`) is the zero address. All customizations to transfers, mints, and burns should be done by overriding
* this function.
*
* Emits a {Transfer} event.
*/
function _update(address from, address to, uint256 value) internal virtual {
if (from == address(0)) {
// Overflow check required: The rest of the code assumes that totalSupply never overflows
_totalSupply += value;
} else {
uint256 fromBalance = _balances[from];
if (fromBalance < value) {
revert ERC20InsufficientBalance(from, fromBalance, value);
}
unchecked {
// Overflow not possible: value <= fromBalance <= totalSupply.
_balances[from] = fromBalance - value;
}
}
if (to == address(0)) {
unchecked {
// Overflow not possible: value <= totalSupply or value <= fromBalance <= totalSupply.
_totalSupply -= value;
}
} else {
unchecked {
// Overflow not possible: balance + value is at most totalSupply, which we know fits into a uint256.
_balances[to] += value;
}
}
emit Transfer(from, to, value);
}
/**
* @dev Creates a `value` amount of tokens and assigns them to `account`, by transferring it from address(0).
* Relies on the `_update` mechanism
*
* Emits a {Transfer} event with `from` set to the zero address.
*
* NOTE: This function is not virtual, {_update} should be overridden instead.
*/
function _mint(address account, uint256 value) internal {
if (account == address(0)) {
revert ERC20InvalidReceiver(address(0));
}
_update(address(0), account, value);
}
/**
* @dev Destroys a `value` amount of tokens from `account`, lowering the total supply.
* Relies on the `_update` mechanism.
*
* Emits a {Transfer} event with `to` set to the zero address.
*
* NOTE: This function is not virtual, {_update} should be overridden instead
*/
function _burn(address account, uint256 value) internal {
if (account == address(0)) {
revert ERC20InvalidSender(address(0));
}
_update(account, address(0), value);
}
/**
* @dev Sets `value` as the allowance of `spender` over the `owner` s tokens.
*
* This internal function is equivalent to `approve`, and can be used to
* e.g. set automatic allowances for certain subsystems, etc.
*
* Emits an {Approval} event.
*
* Requirements:
*
* - `owner` cannot be the zero address.
* - `spender` cannot be the zero address.
*
* Overrides to this logic should be done to the variant with an additional `bool emitEvent` argument.
*/
function _approve(address owner, address spender, uint256 value) internal {
_approve(owner, spender, value, true);
}
/**
* @dev Variant of {_approve} with an optional flag to enable or disable the {Approval} event.
*
* By default (when calling {_approve}) the flag is set to true. On the other hand, approval changes made by
* `_spendAllowance` during the `transferFrom` operation set the flag to false. This saves gas by not emitting any
* `Approval` event during `transferFrom` operations.
*
* Anyone who wishes to continue emitting `Approval` events on the`transferFrom` operation can force the flag to
* true using the following override:
* ```
* function _approve(address owner, address spender, uint256 value, bool) internal virtual override {
* super._approve(owner, spender, value, true);
* }
* ```
*
* Requirements are the same as {_approve}.
*/
function _approve(address owner, address spender, uint256 value, bool emitEvent) internal virtual {
if (owner == address(0)) {
revert ERC20InvalidApprover(address(0));
}
if (spender == address(0)) {
revert ERC20InvalidSpender(address(0));
}
_allowances[owner][spender] = value;
if (emitEvent) {
emit Approval(owner, spender, value);
}
}
/**
* @dev Updates `owner` s allowance for `spender` based on spent `value`.
*
* Does not update the allowance value in case of infinite allowance.
* Revert if not enough allowance is available.
*
* Does not emit an {Approval} event.
*/
function _spendAllowance(address owner, address spender, uint256 value) internal virtual {
uint256 currentAllowance = allowance(owner, spender);
if (currentAllowance != type(uint256).max) {
if (currentAllowance < value) {
revert ERC20InsufficientAllowance(spender, currentAllowance, value);
}
unchecked {
_approve(owner, spender, currentAllowance - value, false);
}
}
}
}
// src/core/XBURNBuyAndBurn.sol
contract XBURNBuyAndBurn is ReentrancyGuard {
address public immutable burnWallet = address(0x0000000000000000000000000000000000000369);
address private xburnContractAddress;
address public theVaultAddress;
IPulseXRouter public pulseXRouter;
uint256 public buyAndBurnInterval;
uint256 public capPerSwap;
uint256 public _lastBuyAndBurnCallTime;
address public _owner;
uint256 public _totalCollectedFunds;
uint256 public _collectedFunds;
event BoughtAndBurntSuccess(uint256 amount);
event BoughtAndBurntFailed(uint256 amount);
event SwapXburnSucceed(uint256 amount);
event SwapXburnFailed(uint256 amount);
event PLSReceived(address sender, uint256 amount);
modifier onlyOwner() {
require(msg.sender == _owner, "Caller is not an owner");
_;
}
modifier onlyAfterInterval() {
require(block.timestamp >= _lastBuyAndBurnCallTime + buyAndBurnInterval, "Buy and burn can only be performed after the minimum interval");
_;
}
constructor(
address owner,
address theVault,
address xburn
) {
pulseXRouter = IPulseXRouter(address(0x165C3410fC91EF562C50559f7d2289fEbed552d9));
xburnContractAddress = xburn;
theVaultAddress = theVault;
_owner = owner;
_lastBuyAndBurnCallTime = 0;
buyAndBurnInterval = 60 minutes;
capPerSwap = 600_000 ether;
}
receive() external payable {
_collectedFunds += msg.value;
_totalCollectedFunds += msg.value;
emit PLSReceived(msg.sender, msg.value);
}
fallback() external payable {
_collectedFunds += msg.value;
_totalCollectedFunds += msg.value;
emit PLSReceived(msg.sender, msg.value);
}
function setXburnContractAddress(address contractAddress) external onlyOwner {
require(contractAddress != address(0), "Contract address cannot be a zero address");
xburnContractAddress = contractAddress;
}
function setVaultAddress(address contractAddress) external onlyOwner {
require(contractAddress != address(0), "Contract address cannot be a zero address");
theVaultAddress = contractAddress;
}
function setRouter(address routerAddress) external onlyOwner {
require(routerAddress != address(0), "Router address cannot be a zero address");
pulseXRouter = IPulseXRouter(address(routerAddress));
}
function getPLSBalance() public view returns (uint256) {
return payable(address(this)).balance;
}
function buyAndBurn() public nonReentrant onlyAfterInterval {
require(address(this).balance >= capPerSwap, "Insufficient PLS balance for swap");
swapForXburn(capPerSwap);
_lastBuyAndBurnCallTime = block.timestamp;
}
function swapForXburn(uint256 tokenAmount) private {
IERC20 xburn = IERC20(address(xburnContractAddress));
xburn.approve(address(pulseXRouter), tokenAmount);
address[] memory path = new address[](2);
path[0] = pulseXRouter.WPLS();
path[1] = address(xburnContractAddress);
try pulseXRouter.swapExactETHForTokens{value: tokenAmount}(
0,
path,
address(this),
block.timestamp + 600
) returns (uint256[] memory amounts) {
uint256 out = amounts[1];
uint256 toVault = (out * 0.55e18) / 1e18;
uint256 toBurn = (out * 0.45e18) / 1e18;
xburn.transfer(theVaultAddress, toVault);
xburn.transfer(burnWallet, toBurn);
emit BoughtAndBurntSuccess(toBurn);
} catch {
emit BoughtAndBurntFailed(capPerSwap);
}
}
function setCapPerSwap(uint256 cap) public onlyOwner {
require(cap >= 100_000 ether && cap <= 1_000_000_000 ether, "Cap per swap must be between 100,000 and 1,000,000,000");
capPerSwap = cap;
}
function setInterval(uint256 interval) public onlyOwner {
require(interval >= 1 minutes && interval <= 5 hours, "Interval must be between 1 minute and 5 hours");
buyAndBurnInterval = interval;
}
}
// src/core/XBURNAuction.sol
struct LP {
bool hasLP;
bool isXburnToken0;
}
struct DailyStatistic {
uint128 xburnEmitted;
uint128 pulseDeposited;
}
contract XBURNAuction is Ownable, Errors {
using SafeERC20 for ERC20;
using SafeERC20 for IXBURN;
IXBURN immutable xburn;
address public bnb;
address public bnbX;
address public liquidityProvider;
uint32 public immutable startTimestamp;
address public immutable pulsePair;
LP public lp;
IPulseXRouter public pulseXRouter = IPulseXRouter(address(0x165C3410fC91EF562C50559f7d2289fEbed552d9));
XBURNVault public theVault;
mapping(address => mapping(uint32 day => uint256 amount)) public depositOf;
mapping(uint32 day => DailyStatistic) public dailyStats;
uint256 public totalPulseDeposited;
event UserDeposit(address indexed user, uint256 indexed amount, uint32 indexed day, uint256 timestamp);
event UserClaimed(address indexed user, uint256 indexed xburnAmount, uint32 indexed day, uint256 depositAmount, uint256 timestamp);
event InitializeLiquiditySuccess();
event InitializeLiquidityFail();
constructor(uint32 _startTimestamp, address _xburn, address _owner) Ownable(_owner) {
xburn = IXBURN(_xburn);
startTimestamp = _startTimestamp;
}
function setTheVault(address _theVault) external onlyOwner {
theVault = XBURNVault(_theVault);
}
function setBuyAndBurn(address _bnb) external onlyOwner {
bnb = _bnb;
}
function setBuyAndBurnX(address _bnbX) external onlyOwner {
bnbX = _bnbX;
}
function deposit() external payable notAmount0(msg.value) {
if (startTimestamp > Time.blockTs()) revert("Auctions not started yet");
_updateAuction();
uint32 daySinceStart = Time.daysSince(startTimestamp) + 1;
DailyStatistic storage stats = dailyStats[daySinceStart];
_distribute(msg.value);
depositOf[msg.sender][daySinceStart] += msg.value;
stats.pulseDeposited += uint128(msg.value);
totalPulseDeposited += uint128(msg.value);
emit UserDeposit(msg.sender, msg.value, daySinceStart, block.timestamp);
}
function claim(uint32 _day) public {
uint32 daySinceStart = Time.daysSince(startTimestamp) + 1;
if (_day == daySinceStart) revert("Claimable only the next day");
uint256 toClaim = amountToClaim(msg.sender, _day);
if (toClaim == 0) revert("Nothing to claim");
emit UserClaimed(msg.sender, toClaim, _day, depositOf[msg.sender][_day], block.timestamp);
xburn.safeTransfer(msg.sender, toClaim);
depositOf[msg.sender][_day] = 0;
}
function batchClaim(uint32[] calldata _days) external {
for (uint256 i; i < _days.length; ++i) {
claim(_days[i]);
}
}
function batchClaimableAmount(address _user, uint32[] calldata _days) public view returns (uint256 toClaim) {
for (uint256 i; i < _days.length; ++i) {
toClaim += amountToClaim(_user, _days[i]);
}
}
function amountToClaim(address _user, uint32 _day) public view returns (uint256 toClaim) {
uint256 depositAmount = depositOf[_user][_day];
DailyStatistic memory stats = dailyStats[_day];
return (depositAmount * stats.xburnEmitted) / stats.pulseDeposited;
}
function addLiquidityToXburnPulsePool() external onlyOwner {
_addLiquidityToXburnPulsePool();
}
function _addLiquidityToXburnPulsePool() internal {
if (lp.hasLP) revert("Liquidity already added");
if (payable(address(this)).balance < INITIAL_PLS_FOR_LIQ) {
revert("Not enough pulse for liquidity");
}
xburn.emitForLp();
xburn.approve(address(pulseXRouter), INITIAL_XBURN_FOR_LIQ);
try pulseXRouter.addLiquidityETH{value: INITIAL_PLS_FOR_LIQ}(address(xburn), INITIAL_XBURN_FOR_LIQ, 0, 0, address(this), block.timestamp + 200) {
lp.hasLP = true;
emit InitializeLiquiditySuccess();
} catch {
emit InitializeLiquidityFail();
}
}
function _distribute(uint256 _amount) internal {
uint256 pulse = payable(address(this)).balance;
if (!lp.hasLP) {
if (pulse <= INITIAL_PLS_FOR_LIQ) {
return;
} else {
_amount = uint192(pulse - INITIAL_PLS_FOR_LIQ);
_addLiquidityToXburnPulsePool();
}
}
uint256 toBnB = wmul_0(_amount, BNB_XBURN_AND_VAULT);
uint256 toBnBpVolt = wmul_0(_amount, BNB_PVOLT_V1);
uint256 toXburnLP = wmul_0(_amount, LP_XBURN);
uint256 topVoltLP = wmul_0(_amount, LP_PVOLT);
uint256 toGenesis = wmul_0(_amount, GENESIS);
uint256 toRaffleGame = wmul_0(_amount, RAFFLE_GAME_POT);
uint256 toBnBX = wmul_0(_amount, BNB_X);
payable(address(bnb)).call{value: toBnB}("");
payable(address(bnbX)).call{value: toBnBX}("");
payable(address(BNB_PVOLT_V1_ADDR)).call{value: toBnBpVolt}("");
payable(address(GENESIS_WALLET)).call{value: toGenesis}("");
payable(address(LIQUIDITY_PROVIDER)).call{value: toXburnLP + topVoltLP}("");
payable(address(RAFFLE_GAME_ADDR)).call{value: toRaffleGame}("");
}
function _updateAuction() internal {
uint32 daySinceStart = Time.daysSince(startTimestamp) + 1;
if (dailyStats[daySinceStart].xburnEmitted != 0) return;
if (daySinceStart > 10 && xburn.balanceOf(address(theVault)) == 0) revert("Treasury is empty");
uint256 emitted = daySinceStart <= 10 ? xburn.emitForAuction() : theVault.emitForAuction();
dailyStats[daySinceStart].xburnEmitted = uint128(emitted);
}
}
// src/core/XBURNVault.sol
contract XBURNVault {
using SafeERC20 for IXBURN;
IXBURN immutable xburn;
address immutable auction;
error TheVault__OnlyAuction();
constructor(address _auction, address _xburn) {
auction = _auction;
xburn = IXBURN(_xburn);
}
modifier onlyAuction() {
_onlyAuction();
_;
}
function emitForAuction() external onlyAuction returns (uint256 emitted) {
uint256 balanceOf = xburn.balanceOf(address(this));
emitted = wmul_0(balanceOf, DISTRIBUTION_FROM_THE_VAULT);
xburn.safeTransfer(msg.sender, emitted);
}
function _onlyAuction() internal view {
if (msg.sender != auction) revert TheVault__OnlyAuction();
}
}
// src/interfaces/IXBURN.sol
interface IXBURN is IERC20 {
function auction() external view returns (XBURNAuction);
function buyAndBurn() external view returns (XBURNBuyAndBurn);
function pool() external view returns (address);
function theVault() external view returns (XBURNVault);
function burn(uint256 amount) external;
function emitForAuction() external returns (uint256 emitted);
function emitForLp() external returns (uint256 emitted);
}
// src/core/XBURN.sol
contract XBURN is ERC20, Ownable, Errors {
address public immutable pulsePool;
address public immutable xPool;
address public immutable pVoltPool;
bool public liquidityProviderInitialized = false;
address public liquidityProvider;
IPulseXRouter public pulseXRouter = IPulseXRouter(address(0x165C3410fC91EF562C50559f7d2289fEbed552d9));
XBURNAuction public auction;
XBURNBuyAndBurn public buyAndBurn;
XBURNVault public theVault;
error XBURN__OnlyAuction();
modifier onlyAuction() {
_onlyAuction();
_;
}
constructor(address _owner) ERC20("XBURN.win", "XBURN") Ownable(_owner) {
_mint(LIQUIDITY_PROVIDER, 50_000_000 ether);
pulsePool = IPulseXFactory(pulseXRouter.factory()).createPair(address(this), pulseXRouter.WPLS());
xPool = IPulseXFactory(pulseXRouter.factory()).createPair(address(this), X);
pVoltPool = IPulseXFactory(pulseXRouter.factory()).createPair(address(this), PVOLT);
}
function setXburnAuction(address _xburnAuction) external onlyOwner {
auction = XBURNAuction(_xburnAuction);
theVault = auction.theVault();
}
function setBuyAndBurn(address payable _xburnBuyAndBurn) external onlyOwner {
buyAndBurn = XBURNBuyAndBurn(_xburnBuyAndBurn);
}
function emitForAuction() external onlyAuction returns (uint256 emitted) {
emitted = AUCTION_EMIT;
_mint(address(auction), emitted);
}
function emitForLp() external onlyAuction returns (uint256 emitted) {
emitted = INITIAL_XBURN_FOR_LIQ;
_mint(address(auction), emitted);
}
function _onlyAuction() internal view {
if (msg.sender != address(auction)) revert XBURN__OnlyAuction();
}
}
Compiler Settings
{"outputSelection":{"*":{"*":["abi","evm.bytecode","evm.deployedBytecode","evm.methodIdentifiers","metadata"],"":["ast"]}},"optimizer":{"runs":200,"enabled":true},"libraries":{},"evmVersion":"paris"}
Contract ABI
[{"type":"constructor","stateMutability":"nonpayable","inputs":[{"type":"address","name":"_owner","internalType":"address"}]},{"type":"error","name":"Address0","inputs":[]},{"type":"error","name":"Amount0","inputs":[]},{"type":"error","name":"ERC20InsufficientAllowance","inputs":[{"type":"address","name":"spender","internalType":"address"},{"type":"uint256","name":"allowance","internalType":"uint256"},{"type":"uint256","name":"needed","internalType":"uint256"}]},{"type":"error","name":"ERC20InsufficientBalance","inputs":[{"type":"address","name":"sender","internalType":"address"},{"type":"uint256","name":"balance","internalType":"uint256"},{"type":"uint256","name":"needed","internalType":"uint256"}]},{"type":"error","name":"ERC20InvalidApprover","inputs":[{"type":"address","name":"approver","internalType":"address"}]},{"type":"error","name":"ERC20InvalidReceiver","inputs":[{"type":"address","name":"receiver","internalType":"address"}]},{"type":"error","name":"ERC20InvalidSender","inputs":[{"type":"address","name":"sender","internalType":"address"}]},{"type":"error","name":"ERC20InvalidSpender","inputs":[{"type":"address","name":"spender","internalType":"address"}]},{"type":"error","name":"Expired","inputs":[]},{"type":"error","name":"OwnableInvalidOwner","inputs":[{"type":"address","name":"owner","internalType":"address"}]},{"type":"error","name":"OwnableUnauthorizedAccount","inputs":[{"type":"address","name":"account","internalType":"address"}]},{"type":"error","name":"XBURN__OnlyAuction","inputs":[]},{"type":"event","name":"Approval","inputs":[{"type":"address","name":"owner","internalType":"address","indexed":true},{"type":"address","name":"spender","internalType":"address","indexed":true},{"type":"uint256","name":"value","internalType":"uint256","indexed":false}],"anonymous":false},{"type":"event","name":"OwnershipTransferred","inputs":[{"type":"address","name":"previousOwner","internalType":"address","indexed":true},{"type":"address","name":"newOwner","internalType":"address","indexed":true}],"anonymous":false},{"type":"event","name":"Transfer","inputs":[{"type":"address","name":"from","internalType":"address","indexed":true},{"type":"address","name":"to","internalType":"address","indexed":true},{"type":"uint256","name":"value","internalType":"uint256","indexed":false}],"anonymous":false},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"allowance","inputs":[{"type":"address","name":"owner","internalType":"address"},{"type":"address","name":"spender","internalType":"address"}]},{"type":"function","stateMutability":"nonpayable","outputs":[{"type":"bool","name":"","internalType":"bool"}],"name":"approve","inputs":[{"type":"address","name":"spender","internalType":"address"},{"type":"uint256","name":"value","internalType":"uint256"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"","internalType":"contract XBURNAuction"}],"name":"auction","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"balanceOf","inputs":[{"type":"address","name":"account","internalType":"address"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"","internalType":"contract XBURNBuyAndBurn"}],"name":"buyAndBurn","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint8","name":"","internalType":"uint8"}],"name":"decimals","inputs":[]},{"type":"function","stateMutability":"nonpayable","outputs":[{"type":"uint256","name":"emitted","internalType":"uint256"}],"name":"emitForAuction","inputs":[]},{"type":"function","stateMutability":"nonpayable","outputs":[{"type":"uint256","name":"emitted","internalType":"uint256"}],"name":"emitForLp","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"","internalType":"address"}],"name":"liquidityProvider","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"bool","name":"","internalType":"bool"}],"name":"liquidityProviderInitialized","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"string","name":"","internalType":"string"}],"name":"name","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"","internalType":"address"}],"name":"owner","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"","internalType":"address"}],"name":"pVoltPool","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"","internalType":"address"}],"name":"pulsePool","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"","internalType":"contract IPulseXRouter"}],"name":"pulseXRouter","inputs":[]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"renounceOwnership","inputs":[]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"setBuyAndBurn","inputs":[{"type":"address","name":"_xburnBuyAndBurn","internalType":"address payable"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"setXburnAuction","inputs":[{"type":"address","name":"_xburnAuction","internalType":"address"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"string","name":"","internalType":"string"}],"name":"symbol","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"","internalType":"contract XBURNVault"}],"name":"theVault","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"totalSupply","inputs":[]},{"type":"function","stateMutability":"nonpayable","outputs":[{"type":"bool","name":"","internalType":"bool"}],"name":"transfer","inputs":[{"type":"address","name":"to","internalType":"address"},{"type":"uint256","name":"value","internalType":"uint256"}]},{"type":"function","stateMutability":"nonpayable","outputs":[{"type":"bool","name":"","internalType":"bool"}],"name":"transferFrom","inputs":[{"type":"address","name":"from","internalType":"address"},{"type":"address","name":"to","internalType":"address"},{"type":"uint256","name":"value","internalType":"uint256"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"transferOwnership","inputs":[{"type":"address","name":"newOwner","internalType":"address"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"","internalType":"address"}],"name":"xPool","inputs":[]}]
Contract Creation Code
0x60e06040526005805460ff60a01b19169055600780546001600160a01b03191673165c3410fc91ef562c50559f7d2289febed552d917905534801561004357600080fd5b506040516114213803806114218339810160408190526100629161064e565b80604051806040016040528060098152602001682c212aa927173bb4b760b91b815250604051806040016040528060058152602001642c212aa92760d91b81525081600390816100b2919061071d565b5060046100bf828261071d565b5050506001600160a01b0381166100f157604051631e4fbdf760e01b8152600060048201526024015b60405180910390fd5b6100fa81610498565b5061012473c2c920a656df618f95dbdb492d24b1a9ed8127186a295be96e640669720000006104ea565b600760009054906101000a90046001600160a01b03166001600160a01b031663c45a01556040518163ffffffff1660e01b8152600401602060405180830381865afa158015610177573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061019b919061064e565b6001600160a01b031663c9c6539630600760009054906101000a90046001600160a01b03166001600160a01b031663ef8ef56f6040518163ffffffff1660e01b8152600401602060405180830381865afa1580156101fd573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610221919061064e565b6040516001600160e01b031960e085901b1681526001600160a01b039283166004820152911660248201526044016020604051808303816000875af115801561026e573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610292919061064e565b6001600160a01b039081166080526007546040805163c45a015560e01b81529051919092169163c45a01559160048083019260209291908290030181865afa1580156102e2573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610306919061064e565b6040516364e329cb60e11b815230600482015273a6c4790cc7aa22ca27327cb83276f2abd687b55b60248201526001600160a01b03919091169063c9c65396906044016020604051808303816000875af1158015610368573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061038c919061064e565b6001600160a01b0390811660a0526007546040805163c45a015560e01b81529051919092169163c45a01559160048083019260209291908290030181865afa1580156103dc573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610400919061064e565b6040516364e329cb60e11b81523060048201527374758472addc95944769e8adac07e391c31cac8260248201526001600160a01b03919091169063c9c65396906044016020604051808303816000875af1158015610462573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610486919061064e565b6001600160a01b031660c05250610802565b600580546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b6001600160a01b0382166105145760405163ec442f0560e01b8152600060048201526024016100e8565b61052060008383610524565b5050565b6001600160a01b03831661054f57806002600082825461054491906107db565b909155506105c19050565b6001600160a01b038316600090815260208190526040902054818110156105a25760405163391434e360e21b81526001600160a01b038516600482015260248101829052604481018390526064016100e8565b6001600160a01b03841660009081526020819052604090209082900390555b6001600160a01b0382166105dd576002805482900390556105fc565b6001600160a01b03821660009081526020819052604090208054820190555b816001600160a01b0316836001600160a01b03167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef8360405161064191815260200190565b60405180910390a3505050565b60006020828403121561066057600080fd5b81516001600160a01b038116811461067757600080fd5b9392505050565b634e487b7160e01b600052604160045260246000fd5b600181811c908216806106a857607f821691505b6020821081036106c857634e487b7160e01b600052602260045260246000fd5b50919050565b601f82111561071857806000526020600020601f840160051c810160208510156106f55750805b601f840160051c820191505b818110156107155760008155600101610701565b50505b505050565b81516001600160401b038111156107365761073661067e565b61074a816107448454610694565b846106ce565b6020601f82116001811461077e57600083156107665750848201515b600019600385901b1c1916600184901b178455610715565b600084815260208120601f198516915b828110156107ae578785015182556020948501946001909201910161078e565b50848210156107cc5786840151600019600387901b60f8161c191681555b50505050600190811b01905550565b808201808211156107fc57634e487b7160e01b600052601160045260246000fd5b92915050565b60805160a05160c051610bf061083160003960006103ac01526000610223015260006103310152610bf06000f3fe608060405234801561001057600080fd5b50600436106101735760003560e01c8063715018a6116100de578063aa6df29911610097578063dd62ed3e11610071578063dd62ed3e14610353578063e087b8641461038c578063f2fde38b14610394578063fef549bd146103a757600080fd5b8063aa6df29914610306578063aec9b6f414610319578063da9670d51461032c57600080fd5b8063715018a6146102ac5780637d9f6db5146102b457806387d5979a146102c75780638da5cb5b146102da57806395d89b41146102eb578063a9059cbb146102f357600080fd5b80632f5ccacb116101305780632f5ccacb146101fb578063313ce5671461020f5780633339d2461461021e5780635b8bec551461025d578063643e206b1461027057806370a082311461028357600080fd5b806306fdde0314610178578063095ea7b3146101965780630e7f6d54146101b957806318160ddd146101ce5780631faa362c146101e057806323b872dd146101e8575b600080fd5b6101806103ce565b60405161018d9190610a15565b60405180910390f35b6101a96101a4366004610a78565b610460565b604051901515815260200161018d565b6101cc6101c7366004610aa4565b61047a565b005b6002545b60405190815260200161018d565b6101d26104a4565b6101a96101f6366004610ac8565b6104d5565b6005546101a990600160a01b900460ff1681565b6040516012815260200161018d565b6102457f000000000000000000000000000000000000000000000000000000000000000081565b6040516001600160a01b03909116815260200161018d565b600654610245906001600160a01b031681565b6101cc61027e366004610aa4565b6104f9565b6101d2610291366004610aa4565b6001600160a01b031660009081526020819052604090205490565b6101cc6105a1565b600854610245906001600160a01b031681565b600a54610245906001600160a01b031681565b6005546001600160a01b0316610245565b6101806105b5565b6101a9610301366004610a78565b6105c4565b600954610245906001600160a01b031681565b600754610245906001600160a01b031681565b6102457f000000000000000000000000000000000000000000000000000000000000000081565b6101d2610361366004610b09565b6001600160a01b03918216600090815260016020908152604080832093909416825291909152205490565b6101d26105d2565b6101cc6103a2366004610aa4565b610600565b6102457f000000000000000000000000000000000000000000000000000000000000000081565b6060600380546103dd90610b42565b80601f016020809104026020016040519081016040528092919081815260200182805461040990610b42565b80156104565780601f1061042b57610100808354040283529160200191610456565b820191906000526020600020905b81548152906001019060200180831161043957829003601f168201915b5050505050905090565b60003361046e818585610643565b60019150505b92915050565b610482610655565b600980546001600160a01b0319166001600160a01b0392909216919091179055565b60006104ae610682565b506008546a0422ca8b0a00a425000000906104d2906001600160a01b0316826106ad565b90565b6000336104e38582856106e7565b6104ee858585610765565b506001949350505050565b610501610655565b600880546001600160a01b0319166001600160a01b038316908117909155604080516343eacbcd60e11b815290516387d5979a916004808201926020929091908290030181865afa15801561055a573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061057e9190610b7c565b600a80546001600160a01b0319166001600160a01b039290921691909117905550565b6105a9610655565b6105b360006107c4565b565b6060600480546103dd90610b42565b60003361046e818585610765565b60006105dc610682565b506008546a52b7d2dcc80cd2e4000000906104d2906001600160a01b0316826106ad565b610608610655565b6001600160a01b03811661063757604051631e4fbdf760e01b8152600060048201526024015b60405180910390fd5b610640816107c4565b50565b6106508383836001610816565b505050565b6005546001600160a01b031633146105b35760405163118cdaa760e01b815233600482015260240161062e565b6008546001600160a01b031633146105b35760405163b3f7061d60e01b815260040160405180910390fd5b6001600160a01b0382166106d75760405163ec442f0560e01b81526000600482015260240161062e565b6106e3600083836108eb565b5050565b6001600160a01b03838116600090815260016020908152604080832093861683529290522054600019811461075f578181101561075057604051637dc7a0d960e11b81526001600160a01b0384166004820152602481018290526044810183905260640161062e565b61075f84848484036000610816565b50505050565b6001600160a01b03831661078f57604051634b637e8f60e11b81526000600482015260240161062e565b6001600160a01b0382166107b95760405163ec442f0560e01b81526000600482015260240161062e565b6106508383836108eb565b600580546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b6001600160a01b0384166108405760405163e602df0560e01b81526000600482015260240161062e565b6001600160a01b03831661086a57604051634a1406b160e11b81526000600482015260240161062e565b6001600160a01b038085166000908152600160209081526040808320938716835292905220829055801561075f57826001600160a01b0316846001600160a01b03167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925846040516108dd91815260200190565b60405180910390a350505050565b6001600160a01b03831661091657806002600082825461090b9190610b99565b909155506109889050565b6001600160a01b038316600090815260208190526040902054818110156109695760405163391434e360e21b81526001600160a01b0385166004820152602481018290526044810183905260640161062e565b6001600160a01b03841660009081526020819052604090209082900390555b6001600160a01b0382166109a4576002805482900390556109c3565b6001600160a01b03821660009081526020819052604090208054820190555b816001600160a01b0316836001600160a01b03167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef83604051610a0891815260200190565b60405180910390a3505050565b602081526000825180602084015260005b81811015610a435760208186018101516040868401015201610a26565b506000604082850101526040601f19601f83011684010191505092915050565b6001600160a01b038116811461064057600080fd5b60008060408385031215610a8b57600080fd5b8235610a9681610a63565b946020939093013593505050565b600060208284031215610ab657600080fd5b8135610ac181610a63565b9392505050565b600080600060608486031215610add57600080fd5b8335610ae881610a63565b92506020840135610af881610a63565b929592945050506040919091013590565b60008060408385031215610b1c57600080fd5b8235610b2781610a63565b91506020830135610b3781610a63565b809150509250929050565b600181811c90821680610b5657607f821691505b602082108103610b7657634e487b7160e01b600052602260045260246000fd5b50919050565b600060208284031215610b8e57600080fd5b8151610ac181610a63565b8082018082111561047457634e487b7160e01b600052601160045260246000fdfea2646970667358221220c891dd1c20dc4d283634b53edff97e938b101750b540c8933faf7617e447b42e64736f6c634300081a003300000000000000000000000067361bdf355a485a9d3841ba58308e48ac13f953
Deployed ByteCode
0x608060405234801561001057600080fd5b50600436106101735760003560e01c8063715018a6116100de578063aa6df29911610097578063dd62ed3e11610071578063dd62ed3e14610353578063e087b8641461038c578063f2fde38b14610394578063fef549bd146103a757600080fd5b8063aa6df29914610306578063aec9b6f414610319578063da9670d51461032c57600080fd5b8063715018a6146102ac5780637d9f6db5146102b457806387d5979a146102c75780638da5cb5b146102da57806395d89b41146102eb578063a9059cbb146102f357600080fd5b80632f5ccacb116101305780632f5ccacb146101fb578063313ce5671461020f5780633339d2461461021e5780635b8bec551461025d578063643e206b1461027057806370a082311461028357600080fd5b806306fdde0314610178578063095ea7b3146101965780630e7f6d54146101b957806318160ddd146101ce5780631faa362c146101e057806323b872dd146101e8575b600080fd5b6101806103ce565b60405161018d9190610a15565b60405180910390f35b6101a96101a4366004610a78565b610460565b604051901515815260200161018d565b6101cc6101c7366004610aa4565b61047a565b005b6002545b60405190815260200161018d565b6101d26104a4565b6101a96101f6366004610ac8565b6104d5565b6005546101a990600160a01b900460ff1681565b6040516012815260200161018d565b6102457f00000000000000000000000090284ed2be98857afa0e8d9f78ff072ec2118fa881565b6040516001600160a01b03909116815260200161018d565b600654610245906001600160a01b031681565b6101cc61027e366004610aa4565b6104f9565b6101d2610291366004610aa4565b6001600160a01b031660009081526020819052604090205490565b6101cc6105a1565b600854610245906001600160a01b031681565b600a54610245906001600160a01b031681565b6005546001600160a01b0316610245565b6101806105b5565b6101a9610301366004610a78565b6105c4565b600954610245906001600160a01b031681565b600754610245906001600160a01b031681565b6102457f00000000000000000000000059f65729f6d1ed391a5dc124fb83eeb8ede3743381565b6101d2610361366004610b09565b6001600160a01b03918216600090815260016020908152604080832093909416825291909152205490565b6101d26105d2565b6101cc6103a2366004610aa4565b610600565b6102457f0000000000000000000000005991694df49d1a73818b3d89fb8ce989471c9caf81565b6060600380546103dd90610b42565b80601f016020809104026020016040519081016040528092919081815260200182805461040990610b42565b80156104565780601f1061042b57610100808354040283529160200191610456565b820191906000526020600020905b81548152906001019060200180831161043957829003601f168201915b5050505050905090565b60003361046e818585610643565b60019150505b92915050565b610482610655565b600980546001600160a01b0319166001600160a01b0392909216919091179055565b60006104ae610682565b506008546a0422ca8b0a00a425000000906104d2906001600160a01b0316826106ad565b90565b6000336104e38582856106e7565b6104ee858585610765565b506001949350505050565b610501610655565b600880546001600160a01b0319166001600160a01b038316908117909155604080516343eacbcd60e11b815290516387d5979a916004808201926020929091908290030181865afa15801561055a573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061057e9190610b7c565b600a80546001600160a01b0319166001600160a01b039290921691909117905550565b6105a9610655565b6105b360006107c4565b565b6060600480546103dd90610b42565b60003361046e818585610765565b60006105dc610682565b506008546a52b7d2dcc80cd2e4000000906104d2906001600160a01b0316826106ad565b610608610655565b6001600160a01b03811661063757604051631e4fbdf760e01b8152600060048201526024015b60405180910390fd5b610640816107c4565b50565b6106508383836001610816565b505050565b6005546001600160a01b031633146105b35760405163118cdaa760e01b815233600482015260240161062e565b6008546001600160a01b031633146105b35760405163b3f7061d60e01b815260040160405180910390fd5b6001600160a01b0382166106d75760405163ec442f0560e01b81526000600482015260240161062e565b6106e3600083836108eb565b5050565b6001600160a01b03838116600090815260016020908152604080832093861683529290522054600019811461075f578181101561075057604051637dc7a0d960e11b81526001600160a01b0384166004820152602481018290526044810183905260640161062e565b61075f84848484036000610816565b50505050565b6001600160a01b03831661078f57604051634b637e8f60e11b81526000600482015260240161062e565b6001600160a01b0382166107b95760405163ec442f0560e01b81526000600482015260240161062e565b6106508383836108eb565b600580546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b6001600160a01b0384166108405760405163e602df0560e01b81526000600482015260240161062e565b6001600160a01b03831661086a57604051634a1406b160e11b81526000600482015260240161062e565b6001600160a01b038085166000908152600160209081526040808320938716835292905220829055801561075f57826001600160a01b0316846001600160a01b03167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925846040516108dd91815260200190565b60405180910390a350505050565b6001600160a01b03831661091657806002600082825461090b9190610b99565b909155506109889050565b6001600160a01b038316600090815260208190526040902054818110156109695760405163391434e360e21b81526001600160a01b0385166004820152602481018290526044810183905260640161062e565b6001600160a01b03841660009081526020819052604090209082900390555b6001600160a01b0382166109a4576002805482900390556109c3565b6001600160a01b03821660009081526020819052604090208054820190555b816001600160a01b0316836001600160a01b03167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef83604051610a0891815260200190565b60405180910390a3505050565b602081526000825180602084015260005b81811015610a435760208186018101516040868401015201610a26565b506000604082850101526040601f19601f83011684010191505092915050565b6001600160a01b038116811461064057600080fd5b60008060408385031215610a8b57600080fd5b8235610a9681610a63565b946020939093013593505050565b600060208284031215610ab657600080fd5b8135610ac181610a63565b9392505050565b600080600060608486031215610add57600080fd5b8335610ae881610a63565b92506020840135610af881610a63565b929592945050506040919091013590565b60008060408385031215610b1c57600080fd5b8235610b2781610a63565b91506020830135610b3781610a63565b809150509250929050565b600181811c90821680610b5657607f821691505b602082108103610b7657634e487b7160e01b600052602260045260246000fd5b50919050565b600060208284031215610b8e57600080fd5b8151610ac181610a63565b8082018082111561047457634e487b7160e01b600052601160045260246000fdfea2646970667358221220c891dd1c20dc4d283634b53edff97e938b101750b540c8933faf7617e447b42e64736f6c634300081a0033