Address Contract Partially Verified
Address
0x26227ACE40de5671e8355fCAFf65a0522aa7b303
Balance
0 ETH
Nonce
1
Code Size
4403 bytes
Creator
0xB4cDc16E...Ca5A at tx 0x315ee08d...a187e0
Indexed Transactions
0 (1 on-chain, 1.5% indexed)
Contract Bytecode
4403 bytes
0x6080604052600436106100dc575f3560e01c80638ce744261161007c578063c415b95c11610057578063c415b95c146102ac578063ee0b9e1a146102de578063fd7fd3a9146102fd578063fd9be5221461032b575f5ffd5b80638ce744261461020d578063913e77ad146102405780639b09890814610273575f5ffd5b80633fc8cef3116100b75780633fc8cef3146101515780634018e9f61461019c5780634cd7ef9c146101cf57806372e57eaa146101ee575f5ffd5b806302fb1eec146100e75780631c4324551461011d5780631e47aaa014610132575f5ffd5b366100e357005b5f5ffd5b3480156100f2575f5ffd5b50610106610101366004610d4d565b61034a565b60405160ff90911681526020015b60405180910390f35b61013061012b366004610da7565b6103cd565b005b34801561013d575f5ffd5b5061010661014c366004610de1565b610561565b34801561015c575f5ffd5b506101847f000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc281565b6040516001600160a01b039091168152602001610114565b3480156101a7575f5ffd5b506101067f000000000000000000000000000000000000000000000000000000000000000381565b3480156101da575f5ffd5b506101306101e9366004610e4a565b6105e5565b3480156101f9575f5ffd5b50610106610208366004610eb1565b610689565b348015610218575f5ffd5b506101847f00000000000000000000000040ffe85a28dc9993541449464d7529a92214296081565b34801561024b575f5ffd5b506101847f00000000000000000000000057831ff185b25d772c32dac532f962041c736bd081565b34801561027e575f5ffd5b5061029e61028d366004610fd2565b60016020525f908152604090205481565b604051908152602001610114565b3480156102b7575f5ffd5b507f00000000000000000000000057831ff185b25d772c32dac532f962041c736bd0610184565b3480156102e9575f5ffd5b5061029e6102f8366004610fe9565b610710565b348015610308575f5ffd5b50610106610317366004611011565b5f6020819052908152604090205460ff1681565b348015610336575f5ffd5b50610130610345366004611031565b61076b565b60405160ff7f00000000000000000000000000000000000000000000000000000000000000031681525f907fe188a18138f4f3ddbaea4a8e8b9a7241e53aecf8f1c9cb7200371a199a7267e69060200160405180910390a1507f000000000000000000000000000000000000000000000000000000000000000395945050505050565b336001600160a01b037f00000000000000000000000040ffe85a28dc9993541449464d7529a922142960161461044a5760405162461bcd60e51b815260206004820152600d60248201527f6f6e6c792070726f746f636f6c0000000000000000000000000000000000000060448201526064015b60405180910390fd5b6001600160a01b0382166104a7578034146104a75760405162461bcd60e51b815260206004820152600e60248201527f696e76616c696420616d6f756e740000000000000000000000000000000000006044820152606401610441565b6040516bffffffffffffffffffffffff19606085811b8216602084015284901b1660348201525f906048016040516020818303038152906040528051906020012090508160015f8381526020019081526020015f205f82825461050a919061106d565b9091555050604080516001600160a01b038087168252851660208201529081018390527f652893d29fd820a4f183b65e6138f2125655352c510e215ab9202d37bd46a4d1906060015b60405180910390a150505050565b60405160ff7f00000000000000000000000000000000000000000000000000000000000000031681525f907fe188a18138f4f3ddbaea4a8e8b9a7241e53aecf8f1c9cb7200371a199a7267e69060200160405180910390a1507f00000000000000000000000000000000000000000000000000000000000000039695505050505050565b336001600160a01b037f00000000000000000000000057831ff185b25d772c32dac532f962041c736bd0161461065d5760405162461bcd60e51b815260206004820152600e60248201527f6f6e6c7920636f6c6c6563746f720000000000000000000000000000000000006044820152606401610441565b6001600160a01b03919091165f908152602081905260409020805460ff191660ff909216919091179055565b60808101516001600160a01b03165f9081526020819052604081205460ff168082036106d257507f00000000000000000000000000000000000000000000000000000000000000035b60405160ff821681527fe188a18138f4f3ddbaea4a8e8b9a7241e53aecf8f1c9cb7200371a199a7267e69060200160405180910390a1949350505050565b6040516bffffffffffffffffffffffff19606084811b8216602084015283901b1660348201525f90819060480160408051601f1981840301815291815281516020928301205f90815260019092529020549150505b92915050565b816001600160a01b03811661079d57507f000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc25b6040516bffffffffffffffffffffffff1933606090811b8216602084015283901b1660348201525f906048016040516020818303038152906040528051906020012090508260015f8381526020019081526020015f205410156108425760405162461bcd60e51b815260206004820152601460248201527f696e73756666696369656e742062616c616e63650000000000000000000000006044820152606401610441565b5f818152600160205260408120805485929061085f908490611080565b90915550506001600160a01b03841661099b576040517f2e1a7d4d000000000000000000000000000000000000000000000000000000008152600481018490527f000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc26001600160a01b031690632e1a7d4d906024015f604051808303815f87803b1580156108ea575f5ffd5b505af11580156108fc573d5f5f3e3d5ffd5b50506040515f925033915085908381818185875af1925050503d805f811461093f576040519150601f19603f3d011682016040523d82523d5f602084013e610944565b606091505b50509050806109955760405162461bcd60e51b815260206004820152601560248201527f4574686572207472616e73666572206661696c656400000000000000000000006044820152606401610441565b506109af565b6109af6001600160a01b03851633856109ee565b604080516001600160a01b0386168152602081018590527f78473f3f373f7673597f4f0fa5873cb4d375fea6d4339ad6b56dbd411513cb3f9101610553565b604080516001600160a01b038416602482015260448082018490528251808303909101815260649091019091526020810180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167fa9059cbb00000000000000000000000000000000000000000000000000000000179052610a6e908490610a73565b505050565b5f610ac7826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b0316610b599092919063ffffffff16565b905080515f1480610ae7575080806020019051810190610ae79190611093565b610a6e5760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e60448201527f6f742073756363656564000000000000000000000000000000000000000000006064820152608401610441565b6060610b6784845f85610b6f565b949350505050565b606082471015610be75760405162461bcd60e51b815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f60448201527f722063616c6c00000000000000000000000000000000000000000000000000006064820152608401610441565b5f5f866001600160a01b03168587604051610c0291906110b2565b5f6040518083038185875af1925050503d805f8114610c3c576040519150601f19603f3d011682016040523d82523d5f602084013e610c41565b606091505b5091509150610c5287838387610c5d565b979650505050505050565b60608315610ccb5782515f03610cc4576001600160a01b0385163b610cc45760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000006044820152606401610441565b5081610b67565b610b678383815115610ce05781518083602001fd5b8060405162461bcd60e51b815260040161044191906110c8565b803567ffffffffffffffff81168114610d11575f5ffd5b919050565b80356001600160a01b0381168114610d11575f5ffd5b803561ffff81168114610d11575f5ffd5b803560ff81168114610d11575f5ffd5b5f5f5f5f5f60a08688031215610d61575f5ffd5b610d6a86610cfa565b9450610d7860208701610d16565b935060408601359250610d8d60608701610d2c565b9150610d9b60808701610d3d565b90509295509295909350565b5f5f5f60608486031215610db9575f5ffd5b610dc284610d16565b9250610dd060208501610d16565b929592945050506040919091013590565b5f5f5f5f5f5f60c08789031215610df6575f5ffd5b610dff87610d3d565b9550610e0d60208801610d16565b945060408701359350610e2260608801610d16565b9250610e3060808801610d16565b9150610e3e60a08801610d3d565b90509295509295509295565b5f5f60408385031215610e5b575f5ffd5b610e6483610d16565b9150610e7260208401610d3d565b90509250929050565b6040516101c0810167ffffffffffffffff81118282101715610eab57634e487b7160e01b5f52604160045260245ffd5b60405290565b5f5f5f838503610200811215610ec5575f5ffd5b610ece85610d16565b9350602085013592506101c0603f1982011215610ee9575f5ffd5b50610ef2610e7b565b610efe60408601610d3d565b81526060850135602082015260808501356040820152610f2060a08601610d2c565b606082015260c0850135608082015260e085013560a0820152610f466101008601610cfa565b60c0820152610f586101208601610cfa565b60e0820152610f6a6101408601610cfa565b610100820152610f7d6101608601610cfa565b610120820152610f906101808601610cfa565b610140820152610fa36101a08601610d3d565b610160820152610fb66101c08601610d3d565b6101808201526101e094909401356101a0850152509093909250565b5f60208284031215610fe2575f5ffd5b5035919050565b5f5f60408385031215610ffa575f5ffd5b61100383610d16565b9150610e7260208401610d16565b5f60208284031215611021575f5ffd5b61102a82610d16565b9392505050565b5f5f60408385031215611042575f5ffd5b61104b83610d16565b946020939093013593505050565b634e487b7160e01b5f52601160045260245ffd5b8082018082111561076557610765611059565b8181038181111561076557610765611059565b5f602082840312156110a3575f5ffd5b8151801515811461102a575f5ffd5b5f82518060208501845e5f920191825250919050565b602081525f82518060208401528060208501604085015e5f604082850101526040601f19601f8301168401019150509291505056fea26469706673582212201711d9188216aa54d94238b85bf3f0e8aaf14f94e9dc64661f65dddc53f5358964736f6c634300081c0033
Verified Source Code Partial Match
Compiler: v0.8.28+commit.7893614a
EVM: prague
Optimization: Yes (1000 runs)
IERC20.sol 78 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (token/ERC20/IERC20.sol)
pragma solidity ^0.8.0;
/**
* @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 amount of tokens in existence.
*/
function totalSupply() external view returns (uint256);
/**
* @dev Returns the amount of tokens owned by `account`.
*/
function balanceOf(address account) external view returns (uint256);
/**
* @dev Moves `amount` 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 amount) 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 `amount` 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 amount) external returns (bool);
/**
* @dev Moves `amount` tokens from `from` to `to` using the
* allowance mechanism. `amount` 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 amount) external returns (bool);
}
IERC20Permit.sol 60 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (token/ERC20/extensions/IERC20Permit.sol)
pragma solidity ^0.8.0;
/**
* @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.
*/
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].
*/
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);
}
SafeERC20.sol 143 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.3) (token/ERC20/utils/SafeERC20.sol)
pragma solidity ^0.8.0;
import "../IERC20.sol";
import "../extensions/IERC20Permit.sol";
import "../../../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 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.encodeWithSelector(token.transfer.selector, 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.encodeWithSelector(token.transferFrom.selector, from, to, value));
}
/**
* @dev Deprecated. This function has issues similar to the ones found in
* {IERC20-approve}, and its usage is discouraged.
*
* Whenever possible, use {safeIncreaseAllowance} and
* {safeDecreaseAllowance} instead.
*/
function safeApprove(IERC20 token, address spender, uint256 value) internal {
// safeApprove should only be called when setting an initial allowance,
// or when resetting it to zero. To increase and decrease it, use
// 'safeIncreaseAllowance' and 'safeDecreaseAllowance'
require(
(value == 0) || (token.allowance(address(this), spender) == 0),
"SafeERC20: approve from non-zero to non-zero allowance"
);
_callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, 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);
_callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, oldAllowance + value));
}
/**
* @dev Decrease the calling contract's allowance toward `spender` by `value`. If `token` returns no value,
* non-reverting calls are assumed to be successful.
*/
function safeDecreaseAllowance(IERC20 token, address spender, uint256 value) internal {
unchecked {
uint256 oldAllowance = token.allowance(address(this), spender);
require(oldAllowance >= value, "SafeERC20: decreased allowance below zero");
_callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, oldAllowance - value));
}
}
/**
* @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.encodeWithSelector(token.approve.selector, spender, value);
if (!_callOptionalReturnBool(token, approvalCall)) {
_callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, 0));
_callOptionalReturn(token, approvalCall);
}
}
/**
* @dev Use a ERC-2612 signature to set the `owner` approval toward `spender` on `token`.
* Revert on invalid signature.
*/
function safePermit(
IERC20Permit token,
address owner,
address spender,
uint256 value,
uint256 deadline,
uint8 v,
bytes32 r,
bytes32 s
) internal {
uint256 nonceBefore = token.nonces(owner);
token.permit(owner, spender, value, deadline, v, r, s);
uint256 nonceAfter = token.nonces(owner);
require(nonceAfter == nonceBefore + 1, "SafeERC20: permit did not succeed");
}
/**
* @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, "SafeERC20: low-level call failed");
require(returndata.length == 0 || abi.decode(returndata, (bool)), "SafeERC20: ERC20 operation did not succeed");
}
/**
* @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.isContract(address(token));
}
}
Address.sol 244 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (utils/Address.sol)
pragma solidity ^0.8.1;
/**
* @dev Collection of functions related to the address type
*/
library Address {
/**
* @dev Returns true if `account` is a contract.
*
* [IMPORTANT]
* ====
* It is unsafe to assume that an address for which this function returns
* false is an externally-owned account (EOA) and not a contract.
*
* Among others, `isContract` will return false for the following
* types of addresses:
*
* - an externally-owned account
* - a contract in construction
* - an address where a contract will be created
* - an address where a contract lived, but was destroyed
*
* Furthermore, `isContract` will also return true if the target contract within
* the same transaction is already scheduled for destruction by `SELFDESTRUCT`,
* which only has an effect at the end of a transaction.
* ====
*
* [IMPORTANT]
* ====
* You shouldn't rely on `isContract` to protect against flash loan attacks!
*
* Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets
* like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract
* constructor.
* ====
*/
function isContract(address account) internal view returns (bool) {
// This method relies on extcodesize/address.code.length, which returns 0
// for contracts in construction, since the code is only stored at the end
// of the constructor execution.
return account.code.length > 0;
}
/**
* @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.0/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].
*/
function sendValue(address payable recipient, uint256 amount) internal {
require(address(this).balance >= amount, "Address: insufficient balance");
(bool success, ) = recipient.call{value: amount}("");
require(success, "Address: unable to send value, recipient may have reverted");
}
/**
* @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, it is bubbled up by this
* function (like regular Solidity function calls).
*
* 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.
*
* _Available since v3.1._
*/
function functionCall(address target, bytes memory data) internal returns (bytes memory) {
return functionCallWithValue(target, data, 0, "Address: low-level call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with
* `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCall(
address target,
bytes memory data,
string memory errorMessage
) internal returns (bytes memory) {
return functionCallWithValue(target, data, 0, errorMessage);
}
/**
* @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`.
*
* _Available since v3.1._
*/
function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) {
return functionCallWithValue(target, data, value, "Address: low-level call with value failed");
}
/**
* @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but
* with `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCallWithValue(
address target,
bytes memory data,
uint256 value,
string memory errorMessage
) internal returns (bytes memory) {
require(address(this).balance >= value, "Address: insufficient balance for call");
(bool success, bytes memory returndata) = target.call{value: value}(data);
return verifyCallResultFromTarget(target, success, returndata, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but performing a static call.
*
* _Available since v3.3._
*/
function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {
return functionStaticCall(target, data, "Address: low-level static call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
* but performing a static call.
*
* _Available since v3.3._
*/
function functionStaticCall(
address target,
bytes memory data,
string memory errorMessage
) internal view returns (bytes memory) {
(bool success, bytes memory returndata) = target.staticcall(data);
return verifyCallResultFromTarget(target, success, returndata, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but performing a delegate call.
*
* _Available since v3.4._
*/
function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {
return functionDelegateCall(target, data, "Address: low-level delegate call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
* but performing a delegate call.
*
* _Available since v3.4._
*/
function functionDelegateCall(
address target,
bytes memory data,
string memory errorMessage
) internal returns (bytes memory) {
(bool success, bytes memory returndata) = target.delegatecall(data);
return verifyCallResultFromTarget(target, success, returndata, errorMessage);
}
/**
* @dev Tool to verify that a low level call to smart-contract was successful, and revert (either by bubbling
* the revert reason or using the provided one) in case of unsuccessful call or if target was not a contract.
*
* _Available since v4.8._
*/
function verifyCallResultFromTarget(
address target,
bool success,
bytes memory returndata,
string memory errorMessage
) internal view returns (bytes memory) {
if (success) {
if (returndata.length == 0) {
// only check isContract if the call was successful and the return data is empty
// otherwise we already know that it was a contract
require(isContract(target), "Address: call to non-contract");
}
return returndata;
} else {
_revert(returndata, errorMessage);
}
}
/**
* @dev Tool to verify that a low level call was successful, and revert if it wasn't, either by bubbling the
* revert reason or using the provided one.
*
* _Available since v4.3._
*/
function verifyCallResult(
bool success,
bytes memory returndata,
string memory errorMessage
) internal pure returns (bytes memory) {
if (success) {
return returndata;
} else {
_revert(returndata, errorMessage);
}
}
function _revert(bytes memory returndata, string memory errorMessage) 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(errorMessage);
}
}
}
FeeManager.sol 106 lines
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import "./interfaces/IFeeManager.sol";
import "./interfaces/IWETH.sol";
import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
contract FeeManager is IFeeManager {
using SafeERC20 for IERC20;
address public immutable protocol;
address public immutable collector;
IWETH public immutable weth;
uint8 public immutable baseBps;
mapping (address => uint8) public referrerToBps;
mapping (bytes32 => uint256) public relayerFees;
constructor(address _protocol, address _collector, address _weth, uint8 _baseBps) {
protocol = _protocol;
collector = _collector;
weth = IWETH(_weth);
baseBps = _baseBps;
}
function calcProtocolBps(
uint64 amountIn,
address tokenIn,
bytes32 tokenOut,
uint16 destChain,
uint8 referrerBps
) external override returns (uint8) {
emit ProtocolFeeCalced(baseBps);
return baseBps;
}
function calcSwiftProtocolBps(
address tokenIn,
uint256 amountIn,
OrderParams memory params
) external override returns (uint8) {
uint8 protocolBps = referrerToBps[address(uint160(uint256(params.referrerAddr)))];
if (protocolBps == 0) {
protocolBps = baseBps;
}
emit ProtocolFeeCalced(protocolBps);
return protocolBps;
}
function calcFastMCTPProtocolBps(
uint8 payloadType,
address localToken,
uint256 recievedAmount,
address tokenOut,
address referrerAddr,
uint8 referrerBps
) external returns (uint8) {
emit ProtocolFeeCalced(baseBps);
return baseBps;
}
function depositFee(address owner, address token, uint256 amount) payable external override {
require(msg.sender == protocol, 'only protocol');
if (token == address(0)) {
require(msg.value == amount, 'invalid amount');
}
bytes32 key = keccak256(abi.encodePacked(owner, token));
relayerFees[key] += amount;
emit FeeDeposited(owner, token, amount);
}
function withdrawFee(address token, uint256 amount) external override {
address ercToken = token;
if (token == address(0)) {
ercToken = address(weth);
}
bytes32 key = keccak256(abi.encodePacked(msg.sender, ercToken));
require(relayerFees[key] >= amount, 'insufficient balance');
relayerFees[key] -= amount;
if (token == address(0)) {
weth.withdraw(amount);
(bool success, ) = payable(msg.sender).call{value: amount}('');
require(success, 'Ether transfer failed');
} else {
IERC20(token).safeTransfer(msg.sender, amount);
}
emit FeeWithdrawn(token, amount);
}
function feeCollector() external view override returns (address) {
return collector;
}
function getRelayerFee(address relayer, address token) external view returns (uint256) {
bytes32 key = keccak256(abi.encodePacked(relayer, token));
return relayerFees[key];
}
function setReferrerBps(address referrerAddr, uint8 bps) external {
require(msg.sender == collector, 'only collector');
referrerToBps[referrerAddr] = bps;
}
receive() external payable {}
}
IFeeManager.sol 38 lines
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import "../swift/SwiftStructs.sol";
interface IFeeManager {
event ProtocolFeeCalced(uint8 bps);
event FeeDeposited(address relayer, address token, uint256 amount);
event FeeWithdrawn(address token, uint256 amount);
function calcProtocolBps(
uint64 amountIn,
address tokenIn,
bytes32 tokenOut,
uint16 destChain,
uint8 referrerBps
) external returns (uint8);
function calcSwiftProtocolBps(
address tokenIn,
uint256 amountIn,
OrderParams memory params
) external returns (uint8);
function calcFastMCTPProtocolBps(
uint8 payloadType,
address localToken,
uint256 recievedAmount,
address tokenOut,
address referrerAddr,
uint8 referrerBps
) external returns (uint8);
function feeCollector() external view returns (address);
function depositFee(address owner, address token, uint256 amount) payable external;
function withdrawFee(address token, uint256 amount) external;
}
IWETH.sol 10 lines
// SPDX-License-Identifier: Apache 2
pragma solidity ^0.8.0;
import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
interface IWETH is IERC20 {
function deposit() external payable;
function withdraw(uint amount) external;
}
SwiftStructs.sol 156 lines
struct Order {
Status status;
uint64 amountIn;
uint16 destChainId;
}
struct OrderParams {
uint8 payloadType;
bytes32 trader;
bytes32 destAddr;
uint16 destChainId;
bytes32 referrerAddr;
bytes32 tokenOut;
uint64 minAmountOut;
uint64 gasDrop;
uint64 cancelFee;
uint64 refundFee;
uint64 deadline;
uint8 referrerBps;
uint8 auctionMode;
bytes32 random;
}
struct ExtraParams {
uint16 srcChainId;
bytes32 tokenIn;
uint8 protocolBps;
bytes32 customPayloadHash;
}
struct PermitParams {
uint256 value;
uint256 deadline;
uint8 v;
bytes32 r;
bytes32 s;
}
struct Key {
uint8 payloadType;
bytes32 trader;
uint16 srcChainId;
bytes32 tokenIn;
bytes32 destAddr;
uint16 destChainId;
bytes32 tokenOut;
uint64 minAmountOut;
uint64 gasDrop;
uint64 cancelFee;
uint64 refundFee;
uint64 deadline;
bytes32 referrerAddr;
uint8 referrerBps;
uint8 protocolBps;
uint8 auctionMode;
bytes32 random;
bytes32 customPayloadHash;
}
struct PaymentParams {
uint8 payloadType;
bytes32 orderHash;
uint64 promisedAmount;
uint64 minAmountOut;
address destAddr;
address tokenOut;
uint64 gasDrop;
bool batch;
}
enum Status {
CREATED,
FULFILLED,
SETTLED,
UNLOCKED,
CANCELED,
REFUNDED
}
enum Action {
INVALID,
FULFILL,
UNLOCK,
REFUND,
BATCH_UNLOCK,
COMPRESSED_UNLOCK,
SET_REFUND_VERIFIER,
RESCUE
}
enum AuctionMode {
INVALID,
LIMIT_ORDER,
ENGLISH
}
struct UnlockMsg {
uint8 action;
bytes32 orderHash;
uint16 srcChainId;
bytes32 tokenIn;
bytes32 referrerAddr;
uint8 referrerBps;
uint8 protocolBps;
bytes32 unlockReceiver;
bytes32 driver;
uint64 fulfillTime;
}
uint constant UNLOCK_MSG_SIZE = 172; // excluding the action field
struct RefundMsg {
uint8 action;
bytes32 orderHash;
uint16 srcChainId;
bytes32 tokenIn;
bytes32 trader;
bytes32 canceler;
uint64 cancelFee;
uint64 refundFee;
}
struct FulfillMsg {
uint8 action;
bytes32 orderHash;
bytes32 driver;
uint64 promisedAmount;
uint16 penaltyPeriod;
}
struct TransferParams {
address from;
uint256 validAfter;
uint256 validBefore;
}
struct UnlockParams {
bytes32 recipient;
bytes32 driver;
bool batch;
}
struct RescueMsg {
uint8 action;
uint16 chainId;
bytes32 orderHash;
uint8 orderStatus;
address token;
uint64 amount;
}
struct RefundVerifier {
uint8 action;
address verifier;
uint16 emitterChainId;
bytes32 emitterAddr;
}
Read Contract
baseBps 0x4018e9f6 → uint8
collector 0x913e77ad → address
feeCollector 0xc415b95c → address
getRelayerFee 0xee0b9e1a → uint256
protocol 0x8ce74426 → address
referrerToBps 0xfd7fd3a9 → uint8
relayerFees 0x9b098908 → uint256
weth 0x3fc8cef3 → address
Write Contract 6 functions
These functions modify contract state and require a wallet transaction to execute.
calcFastMCTPProtocolBps 0x1e47aaa0
uint8 payloadType
address localToken
uint256 recievedAmount
address tokenOut
address referrerAddr
uint8 referrerBps
returns: uint8
calcProtocolBps 0x02fb1eec
uint64 amountIn
address tokenIn
bytes32 tokenOut
uint16 destChain
uint8 referrerBps
returns: uint8
calcSwiftProtocolBps 0x98cdbbb2
address tokenIn
uint256 amountIn
tuple params
returns: uint8
depositFee 0x1c432455
address owner
address token
uint256 amount
setReferrerBps 0x4cd7ef9c
address referrerAddr
uint8 bps
withdrawFee 0xfd9be522
address token
uint256 amount
Token Balances (3) $5.18
View Transfers →Recent Transactions
This address has 1 on-chain transactions, but only 1.5% of the chain is indexed. Transactions will appear as indexing progresses. View on Etherscan →