Address Contract Verified
Address
0x1698a3e248FF7F0f1f91FE82Eedaa3F1212D1F7F
Balance
0 ETH
Nonce
1
Code Size
4996 bytes
Creator
0xDc036423...3fF2 at tx 0xeb9274fa...fa6244
Indexed Transactions
0
Contract Bytecode
4996 bytes
0x608080604052600436101561001357600080fd5b600090813560e01c90816204dce314610cfb575080631020b1b214610cdd578063120ec08614610cbf5780632ec49c4114610ca15780635283837e14610b0757806357441c8f14610ae4578063715018a614610a7f5780637263779114610a2b57806379ba5097146109a65780638da5cb5b1461097f578063b86832281461095c578063c71f815d1461091a578063cd7dbdd9146108fc578063d531054e146108d7578063d78a6e21146102c9578063d7e0aace146102a6578063d936547e14610264578063e30c39781461023b578063f2fde38b146101c85763f3c4b704146100fc57600080fd5b346101c55760403660031901126101c55760043567ffffffffffffffff81116101c157366023820112156101c157806004013567ffffffffffffffff81116101bd573660248260051b840101116101bd57602435918215158093036101b957610166929192610d78565b60ff849216915b838110156101b5576024600582901b830101356001600160a01b03811691908290036101b157908552600760205260408520805460ff19168417905560010161016d565b8580fd5b8480f35b8380fd5b8280fd5b5080fd5b80fd5b50346101c55760203660031901126101c5576004356001600160a01b038116908190036101c1576101f7610d78565b600180546001600160a01b0319168217905581546001600160a01b03167f38d16b8cac22d99fc7c124b9cd0de2d3fa1faef420bfe791d8c362d765e227008380a380f35b50346101c557806003193601126101c5576001546040516001600160a01b039091168152602090f35b50346101c55760203660031901126101c5576004356001600160a01b038116908190036101c15760408260ff9260209452600784522054166040519015158152f35b50346101c55760203660031901126101c5576102c0610d78565b60043560045580f35b50346101c55760603660031901126101c55760043590604435338252600760205260ff604083205416156108c85761030c60065463ffffffff6005541690610d55565b42106108b957426006556040516370a0823160e01b815230600482015260208160248173e9a53c43a0b58706e67341c4055de861e29ee9435afa9081156106b7578391610887575b50808391600254811061086d575b50801561085e5760025490818111156108565750905b1561084657609661ffff60015460a01c160261ffff811690810361083257606461ffff91045b168082029082820414821517156108325760405163a9059cbb60e01b6020820190815233602483015261271090920460448083018290528252929161042991869182916103ec606482610d1d565b51908273e9a53c43a0b58706e67341c4055de861e29ee9435af161040e6112ad565b9073e9a53c43a0b58706e67341c4055de861e29ee9436112ed565b8051908115159182610817575b50506107f0570383156107e157829360405190636eb1769f60e11b8252306004830152737a250d5630b4cf539739df2c5dacb4c659f2488d602483015260208260448173e9a53c43a0b58706e67341c4055de861e29ee9435afa9182156107d657859284918491610797575b50906104ad91610d55565b828060405192602084019063095ea7b360e01b8252737a250d5630b4cf539739df2c5dacb4c659f2488d60248601526044850152604484526104f0606485610d1d565b8351908273e9a53c43a0b58706e67341c4055de861e29ee9435af16105136112ad565b81610768575b508061074a575b156106e4575b5060405190610536606083610d1d565b60028252604036602084013773e9a53c43a0b58706e67341c4055de861e29ee94361056083611105565b526105bb61056d83611128565b7f0000000000000000000000004bd0f1886010253a18bbb401a788d8972c155b9d6001600160a01b0316908190526040516338ed173960e01b815290969095869485943092600487016111be565b038183737a250d5630b4cf539739df2c5dacb4c659f2488d5af180156106b7576106c2575b506040516370a0823160e01b8152306004820152602081602481855afa9081156106b7578391610685575b50813b15610681578291602483926040519586938492630852cd8d60e31b845260048401525af1801561067457610664575b7fa0fd03f88165f654ebe32949d70ea031e17b72959483ac8c9ebe73888bb601278180a180f35b61066d91610d1d565b388161063d565b50604051903d90823e3d90fd5b5050fd5b90506020813d6020116106af575b816106a060209383610d1d565b8101031261068157513861060b565b3d9150610693565b6040513d85823e3d90fd5b6106dd903d8085833e6106d58183610d1d565b810190611138565b50386105e0565b6107449061072a60405163095ea7b360e01b6020820152737a250d5630b4cf539739df2c5dacb4c659f2488d60248201528560448201526044815261072a606482610d1d565b73e9a53c43a0b58706e67341c4055de861e29ee94361123f565b38610526565b5073e9a53c43a0b58706e67341c4055de861e29ee9433b1515610520565b805180159250821561077d575b505038610519565b6107909250602080918301019101611227565b3880610775565b935050506020823d6020116107ce575b816107b460209383610d1d565b810103126107ca576104ad8386935190916104a2565b8480fd5b3d91506107a7565b6040513d87823e3d90fd5b632b0039c760e21b8352600483fd5b635274afe760e01b845273e9a53c43a0b58706e67341c4055de861e29ee943600452602484fd5b61082a9250602080918301019101611227565b153880610436565b634e487b7160e01b84526011600452602484fd5b61ffff8060015460a01c1661039e565b905090610378565b632fc532ad60e11b8452600484fd5b91505061087d8260243583610da1565b9081119038610362565b90506020813d6020116108b1575b816108a260209383610d1d565b810103126101bd575138610354565b3d9150610895565b63b0782df760e01b8252600482fd5b632b0039c760e21b8252600482fd5b50346101c557806003193601126101c557602061ffff60015460a01c16604051908152f35b50346101c557806003193601126101c5576020600354604051908152f35b50346101c55760203660031901126101c55760043563ffffffff81168091036101c157610945610d78565b80156108c85763ffffffff19600554161760055580f35b50346101c55760203660031901126101c557610976610d78565b60043560035580f35b50346101c557806003193601126101c557546040516001600160a01b039091168152602090f35b50346101c557806003193601126101c557600154336001600160a01b0390911603610a1857600180546001600160a01b0319908116909155815433918116821783556001600160a01b03167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e08380a380f35b63118cdaa760e01b815233600452602490fd5b50346101c55760203660031901126101c55760043561ffff81168082036101bd576103e890610a58610d78565b116108c8576001805461ffff60a01b191660a09290921b61ffff60a01b1691909117905580f35b50346101c557806003193601126101c557610a98610d78565b600180546001600160a01b03199081169091558154908116825581906001600160a01b03167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e08280a380f35b50346101c55760203660031901126101c557610afe610d78565b60043560025580f35b50346101c557806003193601126101c5576040516370a0823160e01b8152306004820152819060208160248173e9a53c43a0b58706e67341c4055de861e29ee9435afa908115610c96578291610c64575b506040516370a0823160e01b815230600482015292602084602481735c47902c8c80779cb99235e42c354e53f38c3b0d5afa928315610c58578093610c23575b60809450600254938484109384610c17575b948495818111600014610c0f5750935b610bf0575b5050610bd660065463ffffffff6005541690610d55565b916040519315158452602084015260408301526060820152f35b6003549250905081811115610c0857505b3880610bbf565b9050610c01565b905093610bba565b60045482119450610baa565b92506020843d602011610c50575b81610c3e60209383610d1d565b810103126101bd576080935192610b98565b3d9150610c31565b604051903d90823e3d90fd5b90506020813d602011610c8e575b81610c7f60209383610d1d565b810103126101c1575138610b58565b3d9150610c72565b6040513d84823e3d90fd5b50346101c557806003193601126101c5576020600454604051908152f35b50346101c557806003193601126101c5576020600654604051908152f35b50346101c557806003193601126101c5576020600254604051908152f35b9050346101c157816003193601126101c15760209063ffffffff600554168152f35b90601f8019910116810190811067ffffffffffffffff821117610d3f57604052565b634e487b7160e01b600052604160045260246000fd5b91908201809211610d6257565b634e487b7160e01b600052601160045260246000fd5b6000546001600160a01b03163303610d8c57565b63118cdaa760e01b6000523360045260246000fd5b906040516370a0823160e01b8152306004820152602081602481735c47902c8c80779cb99235e42c354e53f38c3b0d5afa908115610fb7576000916110d3575b5060045481106110cc5760035490818111156110c45750925b81156110b357604051636eb1769f60e11b8152306004820152737a250d5630b4cf539739df2c5dacb4c659f2488d602482015291602083604481735c47902c8c80779cb99235e42c354e53f38c3b0d5afa8015610fb7578593600091611076575b50600093610e6891610d55565b838060405192602084019063095ea7b360e01b8252737a250d5630b4cf539739df2c5dacb4c659f2488d6024860152604485015260448452610eab606485610d1d565b83519082735c47902c8c80779cb99235e42c354e53f38c3b0d5af1610ece6112ad565b81611047575b5080611029575b15610fc3575b50610f5b60405192610ef4606085610d1d565b600284526040366020860137735c47902c8c80779cb99235e42c354e53f38c3b0d610f1e85611105565b5273e9a53c43a0b58706e67341c4055de861e29ee943610f3d85611128565b526040516338ed173960e01b815296879485943092600487016111be565b038183737a250d5630b4cf539739df2c5dacb4c659f2488d5af1918215610fb757610f9992610f9291600091610f9c575b50611128565b5190610d55565b90565b610fb191503d806000833e6106d58183610d1d565b38610f8c565b6040513d6000823e3d90fd5b6110239061100960405163095ea7b360e01b6020820152737a250d5630b4cf539739df2c5dacb4c659f2488d602482015286604482015260448152611009606482610d1d565b735c47902c8c80779cb99235e42c354e53f38c3b0d61123f565b38610ee1565b50735c47902c8c80779cb99235e42c354e53f38c3b0d3b1515610edb565b805180159250821561105c575b505038610ed4565b61106f9250602080918301019101611227565b3880611054565b9350506020833d6020116110ab575b8161109260209383610d1d565b810103126110a65791518492906000610e5b565b600080fd5b3d9150611085565b632b0039c760e21b60005260046000fd5b905092610dfa565b5050905090565b906020823d6020116110fd575b816110ed60209383610d1d565b810103126101c557505138610de1565b3d91506110e0565b8051156111125760200190565b634e487b7160e01b600052603260045260246000fd5b8051600110156111125760400190565b6020818303126110a65780519067ffffffffffffffff82116110a657019080601f830112156110a65781519167ffffffffffffffff8311610d3f578260051b90602082019361118a6040519586610d1d565b84526020808501928201019283116110a657602001905b8282106111ae5750505090565b81518152602091820191016111a1565b92919594939560a08401918452602084015260a060408401528151809152602060c0840192019060005b818110611208575050506001600160a01b03909416606082015260800152565b82516001600160a01b03168452602093840193909201916001016111e8565b908160209103126110a6575180151581036110a65790565b6000806112689260018060a01b03169360208151910182865af16112616112ad565b90836112ed565b8051908115159182611292575b505061127e5750565b635274afe760e01b60005260045260246000fd5b6112a59250602080918301019101611227565b153880611275565b3d156112e8573d9067ffffffffffffffff8211610d3f57604051916112dc601f8201601f191660200184610d1d565b82523d6000602084013e565b606090565b90611313575080511561130257805190602001fd5b630a12f52160e11b60005260046000fd5b81511580611345575b611324575090565b639996b31560e01b60009081526001600160a01b0391909116600452602490fd5b50803b1561131c56fea26469706673582212209896c0446ef0cdd2494d17116511c9826765db954c0bf8862425c81f3880508064736f6c634300081a0033
Verified Source Code Full Match
Compiler: v0.8.26+commit.8a97fa7a
EVM: paris
Optimization: Yes (200 runs)
Ownable.sol 100 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (access/Ownable.sol)
pragma solidity ^0.8.20;
import {Context} from "../utils/Context.sol";
/**
* @dev Contract module which provides a basic access control mechanism, where
* there is an account (an owner) that can be granted exclusive access to
* specific functions.
*
* The initial owner is set to the address provided by the deployer. This can
* later be changed with {transferOwnership}.
*
* This module is used through inheritance. It will make available the modifier
* `onlyOwner`, which can be applied to your functions to restrict their use to
* the owner.
*/
abstract contract Ownable is Context {
address private _owner;
/**
* @dev The caller account is not authorized to perform an operation.
*/
error OwnableUnauthorizedAccount(address account);
/**
* @dev The owner is not a valid owner account. (eg. `address(0)`)
*/
error OwnableInvalidOwner(address owner);
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
/**
* @dev Initializes the contract setting the address provided by the deployer as the initial owner.
*/
constructor(address initialOwner) {
if (initialOwner == address(0)) {
revert OwnableInvalidOwner(address(0));
}
_transferOwnership(initialOwner);
}
/**
* @dev Throws if called by any account other than the owner.
*/
modifier onlyOwner() {
_checkOwner();
_;
}
/**
* @dev Returns the address of the current owner.
*/
function owner() public view virtual returns (address) {
return _owner;
}
/**
* @dev Throws if the sender is not the owner.
*/
function _checkOwner() internal view virtual {
if (owner() != _msgSender()) {
revert OwnableUnauthorizedAccount(_msgSender());
}
}
/**
* @dev Leaves the contract without owner. It will not be possible to call
* `onlyOwner` functions. Can only be called by the current owner.
*
* NOTE: Renouncing ownership will leave the contract without an owner,
* thereby disabling any functionality that is only available to the owner.
*/
function renounceOwnership() public virtual onlyOwner {
_transferOwnership(address(0));
}
/**
* @dev Transfers ownership of the contract to a new account (`newOwner`).
* Can only be called by the current owner.
*/
function transferOwnership(address newOwner) public virtual onlyOwner {
if (newOwner == address(0)) {
revert OwnableInvalidOwner(address(0));
}
_transferOwnership(newOwner);
}
/**
* @dev Transfers ownership of the contract to a new account (`newOwner`).
* Internal function without access restriction.
*/
function _transferOwnership(address newOwner) internal virtual {
address oldOwner = _owner;
_owner = newOwner;
emit OwnershipTransferred(oldOwner, newOwner);
}
}
Ownable2Step.sol 59 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (access/Ownable2Step.sol)
pragma solidity ^0.8.20;
import {Ownable} from "./Ownable.sol";
/**
* @dev Contract module which provides access control mechanism, where
* there is an account (an owner) that can be granted exclusive access to
* specific functions.
*
* The initial owner is specified at deployment time in the constructor for `Ownable`. This
* can later be changed with {transferOwnership} and {acceptOwnership}.
*
* This module is used through inheritance. It will make available all functions
* from parent (Ownable).
*/
abstract contract Ownable2Step is Ownable {
address private _pendingOwner;
event OwnershipTransferStarted(address indexed previousOwner, address indexed newOwner);
/**
* @dev Returns the address of the pending owner.
*/
function pendingOwner() public view virtual returns (address) {
return _pendingOwner;
}
/**
* @dev Starts the ownership transfer of the contract to a new account. Replaces the pending transfer if there is one.
* Can only be called by the current owner.
*/
function transferOwnership(address newOwner) public virtual override onlyOwner {
_pendingOwner = newOwner;
emit OwnershipTransferStarted(owner(), newOwner);
}
/**
* @dev Transfers ownership of the contract to a new account (`newOwner`) and deletes any pending owner.
* Internal function without access restriction.
*/
function _transferOwnership(address newOwner) internal virtual override {
delete _pendingOwner;
super._transferOwnership(newOwner);
}
/**
* @dev The new owner accepts the ownership transfer.
*/
function acceptOwnership() public virtual {
address sender = _msgSender();
if (pendingOwner() != sender) {
revert OwnableUnauthorizedAccount(sender);
}
_transferOwnership(sender);
}
}
IERC20.sol 6 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (interfaces/IERC20.sol)
pragma solidity ^0.8.20;
import {IERC20} from "../token/ERC20/IERC20.sol";
IERC20Permit.sol 83 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (token/ERC20/extensions/IERC20Permit.sol)
pragma solidity ^0.8.20;
/**
* @dev Interface of the ERC20 Permit extension allowing approvals to be made via signatures, as defined in
* https://eips.ethereum.org/EIPS/eip-2612[EIP-2612].
*
* Adds the {permit} method, which can be used to change an account's ERC20 allowance (see {IERC20-allowance}) by
* presenting a message signed by the account. By not relying on {IERC20-approve}, the token holder account doesn't
* need to send a transaction, and thus is not required to hold Ether at all.
*
* ==== Security Considerations
*
* There are two important considerations concerning the use of `permit`. The first is that a valid permit signature
* expresses an allowance, and it should not be assumed to convey additional meaning. In particular, it should not be
* considered as an intention to spend the allowance in any specific way. The second is that because permits have
* built-in replay protection and can be submitted by anyone, they can be frontrun. A protocol that uses permits should
* take this into consideration and allow a `permit` call to fail. Combining these two aspects, a pattern that may be
* generally recommended is:
*
* ```solidity
* function doThingWithPermit(..., uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s) public {
* try token.permit(msg.sender, address(this), value, deadline, v, r, s) {} catch {}
* doThing(..., value);
* }
*
* function doThing(..., uint256 value) public {
* token.safeTransferFrom(msg.sender, address(this), value);
* ...
* }
* ```
*
* Observe that: 1) `msg.sender` is used as the owner, leaving no ambiguity as to the signer intent, and 2) the use of
* `try/catch` allows the permit to fail and makes the code tolerant to frontrunning. (See also
* {SafeERC20-safeTransferFrom}).
*
* Additionally, note that smart contract wallets (such as Argent or Safe) are not able to produce permit signatures, so
* contracts should have entry points that don't rely on permit.
*/
interface IERC20Permit {
/**
* @dev Sets `value` as the allowance of `spender` over ``owner``'s tokens,
* given ``owner``'s signed approval.
*
* IMPORTANT: The same issues {IERC20-approve} has related to transaction
* ordering also apply here.
*
* Emits an {Approval} event.
*
* Requirements:
*
* - `spender` cannot be the zero address.
* - `deadline` must be a timestamp in the future.
* - `v`, `r` and `s` must be a valid `secp256k1` signature from `owner`
* over the EIP712-formatted function arguments.
* - the signature must use ``owner``'s current nonce (see {nonces}).
*
* For more information on the signature format, see the
* https://eips.ethereum.org/EIPS/eip-2612#specification[relevant EIP
* section].
*
* CAUTION: See Security Considerations above.
*/
function permit(address owner, address spender, uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s)
external;
/**
* @dev Returns the current nonce for `owner`. This value must be
* included whenever a signature is generated for {permit}.
*
* Every successful call to {permit} increases ``owner``'s nonce by one. This
* prevents a signature from being used multiple times.
*/
function nonces(address owner) external view returns (uint256);
/**
* @dev Returns the domain separator used in the encoding of the signature for {permit}, as defined by {EIP712}.
*/
// solhint-disable-next-line func-name-mixedcase
function DOMAIN_SEPARATOR() external view returns (bytes32);
}
IERC20.sol 79 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (token/ERC20/IERC20.sol)
pragma solidity ^0.8.20;
/**
* @dev Interface of the ERC20 standard as defined in the EIP.
*/
interface IERC20 {
/**
* @dev Emitted when `value` tokens are moved from one account (`from`) to
* another (`to`).
*
* Note that `value` may be zero.
*/
event Transfer(address indexed from, address indexed to, uint256 value);
/**
* @dev Emitted when the allowance of a `spender` for an `owner` is set by
* a call to {approve}. `value` is the new allowance.
*/
event Approval(address indexed owner, address indexed spender, uint256 value);
/**
* @dev Returns the value of tokens in existence.
*/
function totalSupply() external view returns (uint256);
/**
* @dev Returns the value of tokens owned by `account`.
*/
function balanceOf(address account) external view returns (uint256);
/**
* @dev Moves a `value` amount of tokens from the caller's account to `to`.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transfer(address to, uint256 value) external returns (bool);
/**
* @dev Returns the remaining number of tokens that `spender` will be
* allowed to spend on behalf of `owner` through {transferFrom}. This is
* zero by default.
*
* This value changes when {approve} or {transferFrom} are called.
*/
function allowance(address owner, address spender) external view returns (uint256);
/**
* @dev Sets a `value` amount of tokens as the allowance of `spender` over the
* caller's tokens.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* IMPORTANT: Beware that changing an allowance with this method brings the risk
* that someone may use both the old and the new allowance by unfortunate
* transaction ordering. One possible solution to mitigate this race
* condition is to first reduce the spender's allowance to 0 and set the
* desired value afterwards:
* https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
*
* Emits an {Approval} event.
*/
function approve(address spender, uint256 value) external returns (bool);
/**
* @dev Moves a `value` amount of tokens from `from` to `to` using the
* allowance mechanism. `value` is then deducted from the caller's
* allowance.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transferFrom(address from, address to, uint256 value) external returns (bool);
}
SafeERC20.sol 118 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (token/ERC20/utils/SafeERC20.sol)
pragma solidity ^0.8.20;
import {IERC20} from "../IERC20.sol";
import {IERC20Permit} from "../extensions/IERC20Permit.sol";
import {Address} from "../../../utils/Address.sol";
/**
* @title SafeERC20
* @dev Wrappers around ERC20 operations that throw on failure (when the token
* contract returns false). Tokens that return no value (and instead revert or
* throw on failure) are also supported, non-reverting calls are assumed to be
* successful.
* To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract,
* which allows you to call the safe operations as `token.safeTransfer(...)`, etc.
*/
library SafeERC20 {
using Address for address;
/**
* @dev An operation with an ERC20 token failed.
*/
error SafeERC20FailedOperation(address token);
/**
* @dev Indicates a failed `decreaseAllowance` request.
*/
error SafeERC20FailedDecreaseAllowance(address spender, uint256 currentAllowance, uint256 requestedDecrease);
/**
* @dev Transfer `value` amount of `token` from the calling contract to `to`. If `token` returns no value,
* non-reverting calls are assumed to be successful.
*/
function safeTransfer(IERC20 token, address to, uint256 value) internal {
_callOptionalReturn(token, abi.encodeCall(token.transfer, (to, value)));
}
/**
* @dev Transfer `value` amount of `token` from `from` to `to`, spending the approval given by `from` to the
* calling contract. If `token` returns no value, non-reverting calls are assumed to be successful.
*/
function safeTransferFrom(IERC20 token, address from, address to, uint256 value) internal {
_callOptionalReturn(token, abi.encodeCall(token.transferFrom, (from, to, value)));
}
/**
* @dev Increase the calling contract's allowance toward `spender` by `value`. If `token` returns no value,
* non-reverting calls are assumed to be successful.
*/
function safeIncreaseAllowance(IERC20 token, address spender, uint256 value) internal {
uint256 oldAllowance = token.allowance(address(this), spender);
forceApprove(token, spender, oldAllowance + value);
}
/**
* @dev Decrease the calling contract's allowance toward `spender` by `requestedDecrease`. If `token` returns no
* value, non-reverting calls are assumed to be successful.
*/
function safeDecreaseAllowance(IERC20 token, address spender, uint256 requestedDecrease) internal {
unchecked {
uint256 currentAllowance = token.allowance(address(this), spender);
if (currentAllowance < requestedDecrease) {
revert SafeERC20FailedDecreaseAllowance(spender, currentAllowance, requestedDecrease);
}
forceApprove(token, spender, currentAllowance - requestedDecrease);
}
}
/**
* @dev Set the calling contract's allowance toward `spender` to `value`. If `token` returns no value,
* non-reverting calls are assumed to be successful. Meant to be used with tokens that require the approval
* to be set to zero before setting it to a non-zero value, such as USDT.
*/
function forceApprove(IERC20 token, address spender, uint256 value) internal {
bytes memory approvalCall = abi.encodeCall(token.approve, (spender, value));
if (!_callOptionalReturnBool(token, approvalCall)) {
_callOptionalReturn(token, abi.encodeCall(token.approve, (spender, 0)));
_callOptionalReturn(token, approvalCall);
}
}
/**
* @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement
* on the return value: the return value is optional (but if data is returned, it must not be false).
* @param token The token targeted by the call.
* @param data The call data (encoded using abi.encode or one of its variants).
*/
function _callOptionalReturn(IERC20 token, bytes memory data) private {
// We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since
// we're implementing it ourselves. We use {Address-functionCall} to perform this call, which verifies that
// the target address contains contract code and also asserts for success in the low-level call.
bytes memory returndata = address(token).functionCall(data);
if (returndata.length != 0 && !abi.decode(returndata, (bool))) {
revert SafeERC20FailedOperation(address(token));
}
}
/**
* @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement
* on the return value: the return value is optional (but if data is returned, it must not be false).
* @param token The token targeted by the call.
* @param data The call data (encoded using abi.encode or one of its variants).
*
* This is a variant of {_callOptionalReturn} that silents catches all reverts and returns a bool instead.
*/
function _callOptionalReturnBool(IERC20 token, bytes memory data) private returns (bool) {
// We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since
// we're implementing it ourselves. We cannot use {Address-functionCall} here since this should return false
// and not revert is the subcall reverts.
(bool success, bytes memory returndata) = address(token).call(data);
return success && (returndata.length == 0 || abi.decode(returndata, (bool))) && address(token).code.length > 0;
}
}
Address.sol 159 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (utils/Address.sol)
pragma solidity ^0.8.20;
/**
* @dev Collection of functions related to the address type
*/
library Address {
/**
* @dev The ETH balance of the account is not enough to perform the operation.
*/
error AddressInsufficientBalance(address account);
/**
* @dev There's no code at `target` (it is not a contract).
*/
error AddressEmptyCode(address target);
/**
* @dev A call to an address target failed. The target may have reverted.
*/
error FailedInnerCall();
/**
* @dev Replacement for Solidity's `transfer`: sends `amount` wei to
* `recipient`, forwarding all available gas and reverting on errors.
*
* https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost
* of certain opcodes, possibly making contracts go over the 2300 gas limit
* imposed by `transfer`, making them unable to receive funds via
* `transfer`. {sendValue} removes this limitation.
*
* https://consensys.net/diligence/blog/2019/09/stop-using-soliditys-transfer-now/[Learn more].
*
* IMPORTANT: because control is transferred to `recipient`, care must be
* taken to not create reentrancy vulnerabilities. Consider using
* {ReentrancyGuard} or the
* https://solidity.readthedocs.io/en/v0.8.20/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].
*/
function sendValue(address payable recipient, uint256 amount) internal {
if (address(this).balance < amount) {
revert AddressInsufficientBalance(address(this));
}
(bool success,) = recipient.call{value: amount}("");
if (!success) {
revert FailedInnerCall();
}
}
/**
* @dev Performs a Solidity function call using a low level `call`. A
* plain `call` is an unsafe replacement for a function call: use this
* function instead.
*
* If `target` reverts with a revert reason or custom error, it is bubbled
* up by this function (like regular Solidity function calls). However, if
* the call reverted with no returned reason, this function reverts with a
* {FailedInnerCall} error.
*
* Returns the raw returned data. To convert to the expected return value,
* use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].
*
* Requirements:
*
* - `target` must be a contract.
* - calling `target` with `data` must not revert.
*/
function functionCall(address target, bytes memory data) internal returns (bytes memory) {
return functionCallWithValue(target, data, 0);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but also transferring `value` wei to `target`.
*
* Requirements:
*
* - the calling contract must have an ETH balance of at least `value`.
* - the called Solidity function must be `payable`.
*/
function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) {
if (address(this).balance < value) {
revert AddressInsufficientBalance(address(this));
}
(bool success, bytes memory returndata) = target.call{value: value}(data);
return verifyCallResultFromTarget(target, success, returndata);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but performing a static call.
*/
function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {
(bool success, bytes memory returndata) = target.staticcall(data);
return verifyCallResultFromTarget(target, success, returndata);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but performing a delegate call.
*/
function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {
(bool success, bytes memory returndata) = target.delegatecall(data);
return verifyCallResultFromTarget(target, success, returndata);
}
/**
* @dev Tool to verify that a low level call to smart-contract was successful, and reverts if the target
* was not a contract or bubbling up the revert reason (falling back to {FailedInnerCall}) in case of an
* unsuccessful call.
*/
function verifyCallResultFromTarget(address target, bool success, bytes memory returndata)
internal
view
returns (bytes memory)
{
if (!success) {
_revert(returndata);
} else {
// only check if target is a contract if the call was successful and the return data is empty
// otherwise we already know that it was a contract
if (returndata.length == 0 && target.code.length == 0) {
revert AddressEmptyCode(target);
}
return returndata;
}
}
/**
* @dev Tool to verify that a low level call was successful, and reverts if it wasn't, either by bubbling the
* revert reason or with a default {FailedInnerCall} error.
*/
function verifyCallResult(bool success, bytes memory returndata) internal pure returns (bytes memory) {
if (!success) {
_revert(returndata);
} else {
return returndata;
}
}
/**
* @dev Reverts with returndata if present. Otherwise reverts with {FailedInnerCall}.
*/
function _revert(bytes memory returndata) private pure {
// Look for revert reason and bubble it up if present
if (returndata.length > 0) {
// The easiest way to bubble the revert reason is using memory via assembly
/// @solidity memory-safe-assembly
assembly {
let returndata_size := mload(returndata)
revert(add(32, returndata), returndata_size)
}
} else {
revert FailedInnerCall();
}
}
}
Context.sol 28 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.1) (utils/Context.sol)
pragma solidity ^0.8.20;
/**
* @dev Provides information about the current execution context, including the
* sender of the transaction and its data. While these are generally available
* via msg.sender and msg.data, they should not be accessed in such a direct
* manner, since when dealing with meta-transactions the account sending and
* paying for execution may not be the actual sender (as far as an application
* is concerned).
*
* This contract is only required for intermediate, library-like contracts.
*/
abstract contract Context {
function _msgSender() internal view virtual returns (address) {
return msg.sender;
}
function _msgData() internal view virtual returns (bytes calldata) {
return msg.data;
}
function _contextSuffixLength() internal view virtual returns (uint256) {
return 0;
}
}
IUniswapV2Router01.sol 121 lines
pragma solidity >=0.6.2;
interface IUniswapV2Router01 {
function factory() external pure returns (address);
function WETH() external pure returns (address);
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 addLiquidityETH(
address token,
uint256 amountTokenDesired,
uint256 amountTokenMin,
uint256 amountETHMin,
address to,
uint256 deadline
) external payable returns (uint256 amountToken, uint256 amountETH, uint256 liquidity);
function removeLiquidity(
address tokenA,
address tokenB,
uint256 liquidity,
uint256 amountAMin,
uint256 amountBMin,
address to,
uint256 deadline
) external returns (uint256 amountA, uint256 amountB);
function removeLiquidityETH(
address token,
uint256 liquidity,
uint256 amountTokenMin,
uint256 amountETHMin,
address to,
uint256 deadline
) external returns (uint256 amountToken, uint256 amountETH);
function removeLiquidityWithPermit(
address tokenA,
address tokenB,
uint256 liquidity,
uint256 amountAMin,
uint256 amountBMin,
address to,
uint256 deadline,
bool approveMax,
uint8 v,
bytes32 r,
bytes32 s
) external returns (uint256 amountA, uint256 amountB);
function removeLiquidityETHWithPermit(
address token,
uint256 liquidity,
uint256 amountTokenMin,
uint256 amountETHMin,
address to,
uint256 deadline,
bool approveMax,
uint8 v,
bytes32 r,
bytes32 s
) external returns (uint256 amountToken, uint256 amountETH);
function swapExactTokensForTokens(
uint256 amountIn,
uint256 amountOutMin,
address[] calldata path,
address to,
uint256 deadline
) external returns (uint256[] memory amounts);
function swapTokensForExactTokens(
uint256 amountOut,
uint256 amountInMax,
address[] calldata path,
address to,
uint256 deadline
) external returns (uint256[] memory amounts);
function swapExactETHForTokens(uint256 amountOutMin, address[] calldata path, address to, uint256 deadline)
external
payable
returns (uint256[] memory amounts);
function swapTokensForExactETH(
uint256 amountOut,
uint256 amountInMax,
address[] calldata path,
address to,
uint256 deadline
) external returns (uint256[] memory amounts);
function swapExactTokensForETH(
uint256 amountIn,
uint256 amountOutMin,
address[] calldata path,
address to,
uint256 deadline
) external returns (uint256[] memory amounts);
function swapETHForExactTokens(uint256 amountOut, address[] calldata path, address to, uint256 deadline)
external
payable
returns (uint256[] memory amounts);
function quote(uint256 amountA, uint256 reserveA, uint256 reserveB) external pure returns (uint256 amountB);
function getAmountOut(uint256 amountIn, uint256 reserveIn, uint256 reserveOut)
external
pure
returns (uint256 amountOut);
function getAmountIn(uint256 amountOut, uint256 reserveIn, uint256 reserveOut)
external
pure
returns (uint256 amountIn);
function getAmountsOut(uint256 amountIn, address[] calldata path)
external
view
returns (uint256[] memory amounts);
function getAmountsIn(uint256 amountOut, address[] calldata path)
external
view
returns (uint256[] memory amounts);
}
IUniswapV2Router02.sol 47 lines
pragma solidity >=0.6.2;
import "./IUniswapV2Router01.sol";
interface IUniswapV2Router02 is IUniswapV2Router01 {
function removeLiquidityETHSupportingFeeOnTransferTokens(
address token,
uint256 liquidity,
uint256 amountTokenMin,
uint256 amountETHMin,
address to,
uint256 deadline
) external returns (uint256 amountETH);
function removeLiquidityETHWithPermitSupportingFeeOnTransferTokens(
address token,
uint256 liquidity,
uint256 amountTokenMin,
uint256 amountETHMin,
address to,
uint256 deadline,
bool approveMax,
uint8 v,
bytes32 r,
bytes32 s
) external returns (uint256 amountETH);
function swapExactTokensForTokensSupportingFeeOnTransferTokens(
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 swapExactTokensForETHSupportingFeeOnTransferTokens(
uint256 amountIn,
uint256 amountOutMin,
address[] calldata path,
address to,
uint256 deadline
) external;
}
IERC20Burnable.sol 8 lines
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.24;
import "@openzeppelin/contracts/interfaces/IERC20.sol";
interface IERC20Burnable is IERC20 {
function burn(uint256 value) external;
}
ITitanOnBurn.sol 6 lines
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.10;
interface ITitanOnBurn {
function onBurn(address user, uint256 amount) external;
}
IWETH9.sol 13 lines
// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity ^0.8.10;
import "@openzeppelin/contracts/interfaces/IERC20.sol";
/// @title Interface for WETH9
interface IWETH9 is IERC20 {
/// @notice Deposit ether to get wrapped ether
function deposit() external payable;
/// @notice Withdraw wrapped ether to get ether
function withdraw(uint256) external;
}
constants.sol 89 lines
// SPDX-License-Identifier: UNLICENSED pragma solidity ^0.8.26; import "../interfaces/ITitanOnBurn.sol"; import "@openzeppelin/contracts/interfaces/IERC20.sol"; // ===================== Contract Addresses ===================================== address constant WETH9 = 0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2; address constant TITANX = 0xF19308F923582A6f7c465e5CE7a9Dc1BEC6665B1; address constant X28 = 0x5c47902c8C80779CB99235E42C354E53F38C3B0d; address constant HYPER = 0xE2cfD7a01ec63875cd9Da6C7c1B7025166c2fA2F; address constant HELIOS = 0x2614f29C39dE46468A921Fd0b41fdd99A01f2EDf; address constant BLAZE = 0xfcd7cceE4071aA4ecFAC1683b7CC0aFeCAF42A36; address constant FLUX = 0xBFDE5ac4f5Adb419A931a5bF64B0f3BB5a623d06; address constant E280 = 0xe9A53C43a0B58706e67341C4055de861e29Ee943; address constant BLAZE_STAKING = 0xBc0043bc5b0c394D9d05d49768f9548F8CF9587b; address constant FLUX_STAKING = 0xd605a87187563C94c577a6E57e4a36eC8433B9aE; address constant TITANX_WETH_POOL = 0xc45A81BC23A64eA556ab4CdF08A86B61cdcEEA8b; address constant TITANX_X28_POOL = 0x99f60479da6A49D55eBA34893958cdAACc710eE9; address constant TITANX_HYPER_POOL = 0x14d725edB1299fF560d96f42462f0234B65B00AF; address constant TITANX_HELIOS_POOL = 0x2C83C54C5612BfD62a78124D4A0eA001278a689c; address constant INFERNO = 0x00F116ac0c304C570daAA68FA6c30a86A04B5C5F; address constant TITANX_INFERNO_POOL = 0x1E90B67149e688DfB95fD73Acacd8ADefd16d88D; address constant INFERNO_FLUX_POOL = 0x09848D115e085942E6fa9D85b6B6C73fb0E63CB1; // ===================== MINT =================================================== uint256 constant PRESALE_LENGTH = 28 days; uint256 constant COOLDOWN_PERIOD = 48 hours; uint256 constant LP_POOL_SIZE = 200_000_000_000 ether; uint8 constant PERCENTAGE_BASE = 100; uint16 constant BPS_BASE = 100_00; uint256 constant COMMON_BASE_PRICE = 100_000_000 ether; uint256 constant RARE_BASE_PRICE = 1_000_000_000 ether; uint256 constant LEGENDARY_BASE_PRICE = 10_000_000_000 ether; uint16 constant COMMON_BASE_MULTIPLIER = 10; uint16 constant RARE_BASE_MULTIPLIER = 100; uint16 constant LEGENDARY_BASE_MULTIPLIER = 1000; // ===================== NFT =================================================== uint8 constant NFT_CLAIM_COOLDOWN = 2; uint256 constant BITPOS_NFT_TIER = 0; uint256 constant BITMASK_NFT_TIER = (1 << 8) - 1; uint256 constant BITPOS_MULTIPLIER = 8; uint256 constant BITMASK_MULTIPLIER = (1 << 16) - 1; uint256 constant BITPOS_MINT_CYCLE = 24; uint256 constant BITMASK_MINT_CYCLE = (1 << 32) - 1; uint256 constant BITPOS_BURN_CYCLE = 56; uint256 constant BITMASK_BURN_CYCLE = (1 << 32) - 1; uint256 constant BITPOS_BURN_ADDRESS = 88; uint256 constant BITMASK_BURN_ADDRESS = (1 << 160) - 1; // ===================== VAULT ================================================== uint256 constant CYCLE_COOLDOWN = 9 days; uint16 constant BANK_ALLOCATION_BPS = 80_00; uint64 constant GENESIS_BASE_BPS = 8_00 * uint64(BPS_BASE); uint64 constant HOLDER_BASE_BPS = 10_00 * uint64(BPS_BASE); uint64 constant DIANOND_BASE_BPS = 2_00 * uint64(BPS_BASE); uint16 constant DIAMOND_HAND_PAYOUT_BPS = 8_00; uint16 constant CYCLE_COMPOUND_REDUCTION = 2_00; // ===================== UNISWAP Interface ====================================== address constant UNISWAP_V2_FACTORY = 0x5C69bEe701ef814a2B6a3EDD4B1652CB9cc5aA6f; address constant UNISWAP_V2_ROUTER = 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D; address constant UNISWAP_V3_ROUTER = 0xE592427A0AEce92De3Edee1F18E0157C05861564; uint24 constant POOL_FEE_1PERCENT = 10000; // ===================== Interface IDs ========================================== bytes4 constant INTERFACE_ID_ERC165 = 0x01ffc9a7; bytes4 constant INTERFACE_ID_ERC20 = type(IERC20).interfaceId; bytes4 constant INTERFACE_ID_ERC721 = 0x80ac58cd; bytes4 constant INTERFACE_ID_ERC721Metadata = 0x5b5e139f; bytes4 constant INTERFACE_ID_ITITANONBURN = type(ITitanOnBurn).interfaceId;
StaxBuyBurn.sol 199 lines
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.26;
import "@openzeppelin/contracts/interfaces/IERC20.sol";
import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
import "@openzeppelin/contracts/access/Ownable2Step.sol";
import "@uniswap/v2-periphery/contracts/interfaces/IUniswapV2Router02.sol";
import "./interfaces/IERC20Burnable.sol";
import "./interfaces/IWETH9.sol";
import "./lib/constants.sol";
/// @title Stax Buy & Burn Contract
contract StaxBuyBurn is Ownable2Step {
using SafeERC20 for IERC20;
using SafeERC20 for IERC20Burnable;
// -------------------------- STATE VARIABLES -------------------------- //
address immutable STAX;
/// @notice Incentive fee amount, measured in basis points (100 bps = 1%).
uint16 public incentiveFeeBps = 30;
/// @notice The maximum amount of ELMNT that can be swapped per Buy & Burn.
uint256 public capPerSwapE280;
/// @notice The maximum amount of X28/E280 that can be swapped per Buy & Burn.
uint256 public capPerSwapX28 = 3_000_000_000 ether;
/// @notice The minimum amount of X28 tokens to trigger X28/ELMNT swap.
uint256 public minSwapAmountX28 = 1_000_000_000 ether;
/// @notice Cooldown for Buy & Burns in seconds.
uint32 public buyBurnInterval = 1 hours;
/// @notice Time of the last Buy & Burn in seconds.
uint256 public lastBuyBurn;
/// @notice Whitelisted addresses to run Buy & Burn.
mapping(address account => bool) public whitelisted;
// ------------------------------- EVENTS ------------------------------ //
event BuyBurn();
// ------------------------------- ERRORS ------------------------------ //
error Prohibited();
error Cooldown();
error ZeroAddress();
error NoAllocation();
// ----------------------------- CONSTRUCTOR --------------------------- //
constructor(address _owner, address _stax) Ownable(_owner) {
if (_stax == address(0)) revert ZeroAddress();
STAX = _stax;
}
// --------------------------- PUBLIC FUNCTIONS ------------------------ //
/// @notice Buys and burns the Stax tokens using ELMNT and X28 balance.
/// @param minStaxAmount The minimum amount out for ELMNT -> Stax swap.
/// @param minE280Amount The minimum amount out for the X28 -> ELMNT swap (if applicalbe).
/// @param deadline The deadline for the swaps.
function buyAndBurn(uint256 minStaxAmount, uint256 minE280Amount, uint256 deadline) external {
if (!whitelisted[msg.sender]) revert Prohibited();
if (block.timestamp < lastBuyBurn + buyBurnInterval) revert Cooldown();
lastBuyBurn = block.timestamp;
uint256 e280Balance = IERC20(E280).balanceOf(address(this));
bool additionalSwap;
if (e280Balance < capPerSwapE280) {
uint256 e280BalanceAfterSwap = _handleX28BalanceCheck(e280Balance, minE280Amount, deadline);
additionalSwap = e280BalanceAfterSwap > e280Balance;
e280Balance = e280BalanceAfterSwap;
}
if (e280Balance == 0) revert NoAllocation();
uint256 amountToSwap = e280Balance > capPerSwapE280 ? capPerSwapE280 : e280Balance;
amountToSwap = _processIncentiveFee(amountToSwap, additionalSwap);
_swapE280toStax(amountToSwap, minStaxAmount, deadline);
_handleStaxBurn();
emit BuyBurn();
}
// ----------------------- ADMINISTRATIVE FUNCTIONS -------------------- //
/// @notice Sets the incentive fee basis points (bps) for Buy & Burns.
/// @param bps The incentive fee in basis points (0 - 1000), (100 bps = 1%).
function setIncentiveFee(uint16 bps) external onlyOwner {
if (bps > 1000) revert Prohibited();
incentiveFeeBps = bps;
}
/// @notice Sets the Buy & Burn interval.
/// @param limit The new interval in seconds.
function setBuyBurnInterval(uint32 limit) external onlyOwner {
if (limit == 0) revert Prohibited();
buyBurnInterval = limit;
}
/// @notice Sets the cap per swap for ELMNT -> Stax swaps.
/// @param limit The new cap limit in WEI applied to ELMNT balance.
function setCapPerSwapE280(uint256 limit) external onlyOwner {
capPerSwapE280 = limit;
}
/// @notice Sets the cap per swap for X28 -> ELMNT swaps.
/// @param limit The new cap limit in WEI applied to X28 balance.
function setCapPerSwapX28(uint256 limit) external onlyOwner {
capPerSwapX28 = limit;
}
/// @notice Sets the new minimum threshold for triggering the X28/ELMNT swap.
/// @param limit The new threshold in WEI applied to X28 balance.
function setMinSwapAmountX28(uint256 limit) external onlyOwner {
minSwapAmountX28 = limit;
}
/// @notice Sets the whitelist status for provided addresses for Buy & Burn.
/// @param accounts List of wallets which status will be changed.
/// @param isWhitelisted Status to be set.
function setWhitelisted(address[] calldata accounts, bool isWhitelisted) external onlyOwner {
for (uint256 i = 0; i < accounts.length; i++) {
whitelisted[accounts[i]] = isWhitelisted;
}
}
// ---------------------------- VIEW FUNCTIONS ------------------------- //
/// @notice Get the Buy & Burn information for the next call.
/// @return isX28SwapPossible Will the X28 swap be performed on the next call.
/// @return nextE280Swap Amount of E280 used in the next call.
/// @return nextX28Swap Amount of X28 used in the next call.
/// @return nextBuyBurn Time when next Buy & Burn will be available (in seconds).
function getBuyBurnParams()
public
view
returns (bool isX28SwapPossible, uint256 nextE280Swap, uint256 nextX28Swap, uint256 nextBuyBurn)
{
uint256 e280Balance = IERC20(E280).balanceOf(address(this));
uint256 x28Balance = IERC20(X28).balanceOf(address(this));
isX28SwapPossible = e280Balance < capPerSwapE280 && x28Balance > minSwapAmountX28;
nextE280Swap = e280Balance > capPerSwapE280 ? capPerSwapE280 : e280Balance;
if (isX28SwapPossible) nextX28Swap = x28Balance > capPerSwapX28 ? capPerSwapX28 : x28Balance;
nextBuyBurn = lastBuyBurn + buyBurnInterval;
}
// -------------------------- INTERNAL FUNCTIONS ----------------------- //
function _handleX28BalanceCheck(uint256 currentE280Balance, uint256 minE280Amount, uint256 deadline)
internal
returns (uint256)
{
uint256 x28Balance = IERC20(X28).balanceOf(address(this));
if (x28Balance < minSwapAmountX28) return currentE280Balance;
uint256 amountToSwap = x28Balance > capPerSwapX28 ? capPerSwapX28 : x28Balance;
uint256 swappedAmount = _swapX28toE280(amountToSwap, minE280Amount, deadline);
return currentE280Balance + swappedAmount;
}
function _processIncentiveFee(uint256 e280Amount, bool additionalSwap) internal returns (uint256) {
uint16 _incentiveFeeBps = additionalSwap ? (incentiveFeeBps * 150) / 100 : incentiveFeeBps;
uint256 incentiveFee = e280Amount * _incentiveFeeBps / BPS_BASE;
IERC20(E280).safeTransfer(msg.sender, incentiveFee);
unchecked {
return e280Amount - incentiveFee;
}
}
function _handleStaxBurn() internal {
IERC20Burnable stax = IERC20Burnable(STAX);
uint256 amountToBurn = stax.balanceOf(address(this));
stax.burn(amountToBurn);
}
function _swapE280toStax(uint256 amountIn, uint256 minAmountOut, uint256 deadline) internal {
if (minAmountOut == 0) revert Prohibited();
IERC20(E280).safeIncreaseAllowance(UNISWAP_V2_ROUTER, amountIn);
address[] memory path = new address[](2);
path[0] = E280;
path[1] = STAX;
IUniswapV2Router02(UNISWAP_V2_ROUTER).swapExactTokensForTokens(
amountIn, minAmountOut, path, address(this), deadline
);
}
function _swapX28toE280(uint256 amountIn, uint256 minAmountOut, uint256 deadline) private returns (uint256) {
if (minAmountOut == 0) revert Prohibited();
IERC20(X28).safeIncreaseAllowance(UNISWAP_V2_ROUTER, amountIn);
address[] memory path = new address[](2);
path[0] = X28;
path[1] = E280;
uint256[] memory amounts = IUniswapV2Router02(UNISWAP_V2_ROUTER).swapExactTokensForTokens(
amountIn, minAmountOut, path, address(this), deadline
);
return amounts[1];
}
}
Read Contract
buyBurnInterval 0x0004dce3 → uint32
capPerSwapE280 0x1020b1b2 → uint256
capPerSwapX28 0xcd7dbdd9 → uint256
getBuyBurnParams 0x5283837e → bool, uint256, uint256, uint256
incentiveFeeBps 0xd531054e → uint16
lastBuyBurn 0x120ec086 → uint256
minSwapAmountX28 0x2ec49c41 → uint256
owner 0x8da5cb5b → address
pendingOwner 0xe30c3978 → address
whitelisted 0xd936547e → bool
Write Contract 10 functions
These functions modify contract state and require a wallet transaction to execute.
acceptOwnership 0x79ba5097
No parameters
buyAndBurn 0xd78a6e21
uint256 minStaxAmount
uint256 minE280Amount
uint256 deadline
renounceOwnership 0x715018a6
No parameters
setBuyBurnInterval 0xc71f815d
uint32 limit
setCapPerSwapE280 0x57441c8f
uint256 limit
setCapPerSwapX28 0xb8683228
uint256 limit
setIncentiveFee 0x72637791
uint16 bps
setMinSwapAmountX28 0xd7e0aace
uint256 limit
setWhitelisted 0xf3c4b704
address[] accounts
bool isWhitelisted
transferOwnership 0xf2fde38b
address newOwner
Recent Transactions
No transactions found for this address