Source Code
View more zero value Internal Transactions in Advanced View mode
Advanced mode:
Loading...
Loading
Loading...
Loading
Cross-Chain Transactions
Loading...
Loading
Contract Name:
HashflowPool
Compiler Version
v0.8.18+commit.87f61d96
Optimization Enabled:
Yes with 200 runs
Other Settings:
default evmVersion
Contract Source Code (Solidity Standard Json-Input format)
/**
* SPDX-License-Identifier: UNLICENSED
*/
pragma solidity 0.8.18;
import '@openzeppelin/contracts/proxy/utils/Initializable.sol';
import '@openzeppelin/contracts/token/ERC20/IERC20.sol';
import '@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol';
import '@openzeppelin/contracts/utils/cryptography/ECDSA.sol';
import '@openzeppelin/contracts/utils/Context.sol';
import '../interfaces/external/IWETH.sol';
import '../interfaces/IHashflowPool.sol';
import '../interfaces/IHashflowRouter.sol';
interface IERC20AllowanceExtension {
function increaseAllowance(address spender, uint256 addedValue)
external
returns (bool);
function decreaseAllowance(address spender, uint256 subtractedValue)
external
returns (bool);
}
contract HashflowPool is IHashflowPool, Initializable, Context {
using Address for address payable;
using SafeERC20 for IERC20;
using ECDSA for bytes32;
string public name;
SignerConfiguration public signerConfiguration;
address public operations;
address public router;
mapping(address => uint256) public nonces;
mapping(bytes32 => uint256) public xChainNonces;
mapping(address => bool) internal _withrawalAccountAuth;
mapping(bytes32 => bool) internal _filledXChainTxids;
address public immutable _WETH;
constructor(address weth) {
require(
weth != address(0),
'HashflowPool::constructor WETH cannot be 0 address.'
);
_WETH = weth;
}
/// @dev Fallback function to receive native token.
receive() external payable {}
/// @inheritdoc IHashflowPool
function initialize(
string memory _name,
address _signer,
address _operations,
address _router
) public override initializer {
require(
_signer != address(0),
'HashflowPool::initialize Signer cannot be 0 address.'
);
require(
_operations != address(0),
'HashflowPool::initialize Operations cannot be 0 address.'
);
require(
_router != address(0),
'HashflowPool::initialize Router cannot be 0 address.'
);
require(
bytes(_name).length > 0,
'HashflowPool::initialize Name cannot be empty'
);
name = _name;
SignerConfiguration memory signerConfig;
signerConfig.enabled = true;
signerConfig.signer = _signer;
emit UpdateSigner(_signer, address(0));
signerConfiguration = signerConfig;
operations = _operations;
router = _router;
}
modifier authorizedOperations() {
require(
_msgSender() == operations,
'HashflowPool:authorizedOperations Sender must be operator.'
);
_;
}
modifier authorizedRouter() {
require(
_msgSender() == router,
'HashflowPool::authorizedRouter Sender must be Router.'
);
_;
}
/// @inheritdoc IHashflowPool
function tradeRFQT(RFQTQuote memory quote)
external
payable
override
authorizedRouter
{
/// Trust assumption: the Router has transferred baseToken.
require(
quote.baseToken != address(0) ||
quote.externalAccount != address(0) ||
msg.value == quote.effectiveBaseTokenAmount,
'HashflowPool::tradeRFQT msg.value must equal effectiveBaseTokenAmount'
);
bytes32 quoteHash = _hashQuoteRFQT(quote);
SignerConfiguration memory signerConfig = signerConfiguration;
require(signerConfig.enabled, 'HashflowPool::tradeRFQT Disabled.');
require(
quoteHash.recover(quote.signature) == signerConfig.signer,
'HashflowPool::tradeRFQT Invalid signer.'
);
_updateNonce(quote.effectiveTrader, quote.nonce);
uint256 quoteTokenAmount = quote.quoteTokenAmount;
if (quote.effectiveBaseTokenAmount < quote.baseTokenAmount) {
quoteTokenAmount =
(quote.effectiveBaseTokenAmount * quote.quoteTokenAmount) /
quote.baseTokenAmount;
}
emit Trade(
quote.trader,
quote.effectiveTrader,
quote.txid,
quote.baseToken,
quote.quoteToken,
quote.effectiveBaseTokenAmount,
quoteTokenAmount
);
if (quote.externalAccount == address(0)) {
_transferFromPool(quote.quoteToken, quote.trader, quoteTokenAmount);
} else {
_transferFromExternalAccount(
quote.externalAccount,
quote.quoteToken,
quote.trader,
quoteTokenAmount
);
}
}
/// @inheritdoc IHashflowPool
function tradeRFQM(RFQMQuote memory quote)
external
override
authorizedRouter
{
SignerConfiguration memory signerConfig = signerConfiguration;
require(signerConfig.enabled, 'HashflowPool::tradeRFQM Disabled.');
bytes32 quoteHash = _hashQuoteRFQM(quote);
require(
quoteHash.recover(quote.makerSignature) == signerConfig.signer,
'HashflowPool::tradeRFQM Invalid signer.'
);
emit Trade(
quote.trader,
quote.trader,
quote.txid,
quote.baseToken,
quote.quoteToken,
quote.baseTokenAmount,
quote.quoteTokenAmount
);
if (quote.externalAccount == address(0)) {
_transferFromPool(
quote.quoteToken,
quote.trader,
quote.quoteTokenAmount
);
} else {
_transferFromExternalAccount(
quote.externalAccount,
quote.quoteToken,
quote.trader,
quote.quoteTokenAmount
);
}
}
/// @inheritdoc IHashflowPool
function tradeXChainRFQT(XChainRFQTQuote memory quote, address trader)
external
payable
override
authorizedRouter
{
require(
quote.srcExternalAccount != address(0) ||
quote.baseToken != address(0) ||
msg.value == quote.effectiveBaseTokenAmount,
'HashflowPool::tradeXChainRFQT msg.value must = amount'
);
SignerConfiguration memory signerConfig = signerConfiguration;
require(
signerConfig.enabled,
'HashflowPool::tradeXChainRFQT Disabled.'
);
_updateNonceXChain(quote.dstTrader, quote.nonce);
bytes32 quoteHash = _hashXChainQuoteRFQT(quote);
require(
quoteHash.recover(quote.signature) == signerConfig.signer,
'HashflowPool::tradeXChainRFQT Invalid signer'
);
uint256 effectiveQuoteTokenAmount = quote.quoteTokenAmount;
if (quote.effectiveBaseTokenAmount < quote.baseTokenAmount) {
effectiveQuoteTokenAmount =
(quote.quoteTokenAmount * quote.effectiveBaseTokenAmount) /
quote.baseTokenAmount;
}
emit XChainTrade(
quote.dstChainId,
quote.dstPool,
trader,
quote.dstTrader,
quote.txid,
quote.baseToken,
quote.quoteToken,
quote.effectiveBaseTokenAmount,
effectiveQuoteTokenAmount
);
}
/// @inheritdoc IHashflowPool
function fillXChain(
address externalAccount,
bytes32 txid,
address trader,
address quoteToken,
uint256 quoteTokenAmount
) external override authorizedRouter {
require(
!_filledXChainTxids[txid],
'HashflowPool::fillXChain Quote has been executed previously.'
);
_filledXChainTxids[txid] = true;
emit XChainTradeFill(txid);
if (externalAccount == address(0)) {
_transferFromPool(quoteToken, trader, quoteTokenAmount);
} else {
_transferFromExternalAccount(
externalAccount,
quoteToken,
trader,
quoteTokenAmount
);
}
}
/// @inheritdoc IHashflowPool
function tradeXChainRFQM(XChainRFQMQuote memory quote)
external
override
authorizedRouter
{
SignerConfiguration memory signerConfig = signerConfiguration;
require(
signerConfig.enabled,
'HashflowPool::tradeXChainRFQM Disabled.'
);
bytes32 quoteHash = _hashXChainQuoteRFQM(quote);
require(
quoteHash.recover(quote.makerSignature) == signerConfig.signer,
'HashflowPool::tradeXChainRFQM Invalid signer'
);
emit XChainTrade(
quote.dstChainId,
quote.dstPool,
quote.trader,
quote.dstTrader,
quote.txid,
quote.baseToken,
quote.quoteToken,
quote.baseTokenAmount,
quote.quoteTokenAmount
);
}
/// @inheritdoc IHashflowPool
function updateXChainPoolAuthorization(
AuthorizedXChainPool[] calldata pools,
bool status
) external override authorizedOperations {
for (uint256 i = 0; i < pools.length; i++) {
require(pools[i].pool != bytes32(0));
IHashflowRouter(router).updateXChainPoolAuthorization(
pools[i].chainId,
pools[i].pool,
status
);
}
}
/// @inheritdoc IHashflowPool
function updateXChainMessengerAuthorization(
address xChainMessenger,
bool authorized
) external override authorizedOperations {
require(
xChainMessenger != address(0),
'HashflowPool::updateXChainMessengerAuthorization Invalid messenger address.'
);
IHashflowRouter(router).updateXChainMessengerAuthorization(
xChainMessenger,
authorized
);
}
/// @dev ERC1271 implementation.
function isValidSignature(bytes32 hash, bytes memory signature)
external
view
override
returns (bytes4 magicValue)
{
if (hash.recover(signature) == signerConfiguration.signer) {
magicValue = 0x1626ba7e;
}
}
/// @inheritdoc IHashflowPool
function approveToken(
address token,
address spender,
uint256 amount
) external override authorizedOperations {
IERC20(token).forceApprove(spender, amount);
}
/// @inheritdoc IHashflowPool
function increaseTokenAllowance(
address token,
address spender,
uint256 amount
) external override authorizedOperations {
IERC20(token).safeIncreaseAllowance(spender, amount);
}
/// @inheritdoc IHashflowPool
function decreaseTokenAllowance(
address token,
address spender,
uint256 amount
) external override authorizedOperations {
IERC20(token).safeDecreaseAllowance(spender, amount);
}
/// @inheritdoc IHashflowPool
function removeLiquidity(
address token,
address recipient,
uint256 amount
) external override authorizedOperations {
SignerConfiguration memory signerConfig = signerConfiguration;
require(
signerConfig.enabled,
'HashflowPool::removeLiquidity Disabled.'
);
require(amount > 0, 'HashflowPool::removeLiquidity Invalid amount');
address _recipient;
if (recipient != address(0)) {
require(
_withrawalAccountAuth[recipient],
'HashflowPool::removeLiquidity Recipient must be hedging account'
);
_recipient = recipient;
} else {
_recipient = _msgSender();
}
emit RemoveLiquidity(token, _recipient, amount);
_transferFromPool(token, _recipient, amount);
}
/// @inheritdoc IHashflowPool
function updateWithdrawalAccount(
address[] memory withdrawalAccounts,
bool authorized
) external override authorizedOperations {
for (uint256 i = 0; i < withdrawalAccounts.length; i++) {
require(withdrawalAccounts[i] != address(0));
_withrawalAccountAuth[withdrawalAccounts[i]] = authorized;
emit UpdateWithdrawalAccount(withdrawalAccounts[i], authorized);
}
}
/// @inheritdoc IHashflowPool
function updateSigner(address newSigner)
external
override
authorizedOperations
{
require(newSigner != address(0));
SignerConfiguration memory signerConfig = signerConfiguration;
emit UpdateSigner(newSigner, signerConfig.signer);
signerConfig.signer = newSigner;
signerConfiguration = signerConfig;
}
/// @inheritdoc IHashflowPool
function killswitchOperations(bool enabled)
external
override
authorizedRouter
{
SignerConfiguration memory signerConfig = signerConfiguration;
signerConfig.enabled = enabled;
signerConfiguration = signerConfig;
}
function getReserves(address token)
external
view
override
returns (uint256)
{
return _getReserves(token);
}
/**
* @dev Prevents against replay for RFQ-T. Checks that nonces are strictly increasing.
*/
function _updateNonce(address trader, uint256 nonce) internal {
require(
nonce > nonces[trader],
'HashflowPool::_updateNonce Invalid nonce.'
);
nonces[trader] = nonce;
}
/**
* @dev Prevents against replay for X-Chain RFQ-T. Checks that nonces are strictly increasing.
*/
function _updateNonceXChain(bytes32 trader, uint256 nonce) internal {
require(
nonce > xChainNonces[trader],
'HashflowPool::_updateNonceXChain Invalid nonce.'
);
xChainNonces[trader] = nonce;
}
function _transferFromPool(
address token,
address recipient,
uint256 value
) internal {
if (token == address(0)) {
payable(recipient).sendValue(value);
} else {
IERC20(token).safeTransfer(recipient, value);
}
}
/// @dev Helper function to transfer quoteToken from external account.
function _transferFromExternalAccount(
address externalAccount,
address token,
address receiver,
uint256 value
) private {
if (token == address(0)) {
IERC20(_WETH).safeTransferFrom(
externalAccount,
address(this),
value
);
IWETH(_WETH).withdraw(value);
payable(receiver).sendValue(value);
} else {
IERC20(token).safeTransferFrom(externalAccount, receiver, value);
}
}
function _getReserves(address token) internal view returns (uint256) {
return
token == address(0)
? address(this).balance
: IERC20(token).balanceOf(address(this));
}
/**
* @dev Generates a quote hash for RFQ-t.
*/
function _hashQuoteRFQT(RFQTQuote memory quote)
private
view
returns (bytes32)
{
return
keccak256(
abi.encodePacked(
'\x19Ethereum Signed Message:\n32',
keccak256(
abi.encodePacked(
address(this),
quote.trader,
quote.effectiveTrader,
quote.externalAccount,
quote.baseToken,
quote.quoteToken,
quote.baseTokenAmount,
quote.quoteTokenAmount,
quote.nonce,
quote.quoteExpiry,
quote.txid,
block.chainid
)
)
)
);
}
function _hashQuoteRFQM(RFQMQuote memory quote)
private
view
returns (bytes32)
{
return
keccak256(
abi.encodePacked(
'\x19Ethereum Signed Message:\n32',
keccak256(
abi.encodePacked(
quote.pool,
quote.externalAccount,
quote.trader,
quote.baseToken,
quote.quoteToken,
quote.baseTokenAmount,
quote.quoteTokenAmount,
quote.quoteExpiry,
quote.txid,
block.chainid
)
)
)
);
}
function _hashXChainQuoteRFQT(XChainRFQTQuote memory quote)
private
pure
returns (bytes32)
{
bytes32 digest = keccak256(
abi.encodePacked(
keccak256(
abi.encodePacked(
quote.srcChainId,
quote.dstChainId,
quote.srcPool,
quote.dstPool,
quote.srcExternalAccount,
quote.dstExternalAccount
)
),
quote.dstTrader,
quote.baseToken,
quote.quoteToken,
quote.baseTokenAmount,
quote.quoteTokenAmount,
quote.quoteExpiry,
quote.nonce,
quote.txid,
quote.xChainMessenger
)
);
return
keccak256(
abi.encodePacked('\x19Ethereum Signed Message:\n32', digest)
);
}
function _hashXChainQuoteRFQM(XChainRFQMQuote memory quote)
private
pure
returns (bytes32)
{
return
keccak256(
abi.encodePacked(
'\x19Ethereum Signed Message:\n32',
keccak256(
abi.encodePacked(
keccak256(
abi.encodePacked(
quote.srcChainId,
quote.dstChainId,
quote.srcPool,
quote.dstPool,
quote.srcExternalAccount,
quote.dstExternalAccount
)
),
quote.trader,
quote.baseToken,
quote.quoteToken,
quote.baseTokenAmount,
quote.quoteTokenAmount,
quote.quoteExpiry,
quote.txid,
quote.xChainMessenger
)
)
)
);
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (interfaces/IERC1271.sol)
pragma solidity ^0.8.0;
/**
* @dev Interface of the ERC1271 standard signature validation method for
* contracts as defined in https://eips.ethereum.org/EIPS/eip-1271[ERC-1271].
*
* _Available since v4.1._
*/
interface IERC1271 {
/**
* @dev Should return whether the signature provided is valid for the provided data
* @param hash Hash of the data to be signed
* @param signature Signature byte array associated with _data
*/
function isValidSignature(bytes32 hash, bytes memory signature) external view returns (bytes4 magicValue);
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (proxy/utils/Initializable.sol)
pragma solidity ^0.8.2;
import "../../utils/Address.sol";
/**
* @dev This is a base contract to aid in writing upgradeable contracts, or any kind of contract that will be deployed
* behind a proxy. Since proxied contracts do not make use of a constructor, it's common to move constructor logic to an
* external initializer function, usually called `initialize`. It then becomes necessary to protect this initializer
* function so it can only be called once. The {initializer} modifier provided by this contract will have this effect.
*
* The initialization functions use a version number. Once a version number is used, it is consumed and cannot be
* reused. This mechanism prevents re-execution of each "step" but allows the creation of new initialization steps in
* case an upgrade adds a module that needs to be initialized.
*
* For example:
*
* [.hljs-theme-light.nopadding]
* ```solidity
* contract MyToken is ERC20Upgradeable {
* function initialize() initializer public {
* __ERC20_init("MyToken", "MTK");
* }
* }
*
* contract MyTokenV2 is MyToken, ERC20PermitUpgradeable {
* function initializeV2() reinitializer(2) public {
* __ERC20Permit_init("MyToken");
* }
* }
* ```
*
* TIP: To avoid leaving the proxy in an uninitialized state, the initializer function should be called as early as
* possible by providing the encoded function call as the `_data` argument to {ERC1967Proxy-constructor}.
*
* CAUTION: When used with inheritance, manual care must be taken to not invoke a parent initializer twice, or to ensure
* that all initializers are idempotent. This is not verified automatically as constructors are by Solidity.
*
* [CAUTION]
* ====
* Avoid leaving a contract uninitialized.
*
* An uninitialized contract can be taken over by an attacker. This applies to both a proxy and its implementation
* contract, which may impact the proxy. To prevent the implementation contract from being used, you should invoke
* the {_disableInitializers} function in the constructor to automatically lock it when it is deployed:
*
* [.hljs-theme-light.nopadding]
* ```
* /// @custom:oz-upgrades-unsafe-allow constructor
* constructor() {
* _disableInitializers();
* }
* ```
* ====
*/
abstract contract Initializable {
/**
* @dev Indicates that the contract has been initialized.
* @custom:oz-retyped-from bool
*/
uint8 private _initialized;
/**
* @dev Indicates that the contract is in the process of being initialized.
*/
bool private _initializing;
/**
* @dev Triggered when the contract has been initialized or reinitialized.
*/
event Initialized(uint8 version);
/**
* @dev A modifier that defines a protected initializer function that can be invoked at most once. In its scope,
* `onlyInitializing` functions can be used to initialize parent contracts.
*
* Similar to `reinitializer(1)`, except that functions marked with `initializer` can be nested in the context of a
* constructor.
*
* Emits an {Initialized} event.
*/
modifier initializer() {
bool isTopLevelCall = !_initializing;
require(
(isTopLevelCall && _initialized < 1) || (!Address.isContract(address(this)) && _initialized == 1),
"Initializable: contract is already initialized"
);
_initialized = 1;
if (isTopLevelCall) {
_initializing = true;
}
_;
if (isTopLevelCall) {
_initializing = false;
emit Initialized(1);
}
}
/**
* @dev A modifier that defines a protected reinitializer function that can be invoked at most once, and only if the
* contract hasn't been initialized to a greater version before. In its scope, `onlyInitializing` functions can be
* used to initialize parent contracts.
*
* A reinitializer may be used after the original initialization step. This is essential to configure modules that
* are added through upgrades and that require initialization.
*
* When `version` is 1, this modifier is similar to `initializer`, except that functions marked with `reinitializer`
* cannot be nested. If one is invoked in the context of another, execution will revert.
*
* Note that versions can jump in increments greater than 1; this implies that if multiple reinitializers coexist in
* a contract, executing them in the right order is up to the developer or operator.
*
* WARNING: setting the version to 255 will prevent any future reinitialization.
*
* Emits an {Initialized} event.
*/
modifier reinitializer(uint8 version) {
require(!_initializing && _initialized < version, "Initializable: contract is already initialized");
_initialized = version;
_initializing = true;
_;
_initializing = false;
emit Initialized(version);
}
/**
* @dev Modifier to protect an initialization function so that it can only be invoked by functions with the
* {initializer} and {reinitializer} modifiers, directly or indirectly.
*/
modifier onlyInitializing() {
require(_initializing, "Initializable: contract is not initializing");
_;
}
/**
* @dev Locks the contract, preventing any future reinitialization. This cannot be part of an initializer call.
* Calling this in the constructor of a contract will prevent that contract from being initialized or reinitialized
* to any version. It is recommended to use this to lock implementation contracts that are designed to be called
* through proxies.
*
* Emits an {Initialized} event the first time it is successfully executed.
*/
function _disableInitializers() internal virtual {
require(!_initializing, "Initializable: contract is initializing");
if (_initialized != type(uint8).max) {
_initialized = type(uint8).max;
emit Initialized(type(uint8).max);
}
}
/**
* @dev Returns the highest version that has been initialized. See {reinitializer}.
*/
function _getInitializedVersion() internal view returns (uint8) {
return _initialized;
}
/**
* @dev Returns `true` if the contract is currently initializing. See {onlyInitializing}.
*/
function _isInitializing() internal view returns (bool) {
return _initializing;
}
}// 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);
}// 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);
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (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. Compatible with tokens that require the approval to be set to
* 0 before setting it to a non-zero value.
*/
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));
}
}// 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);
}
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/Context.sol)
pragma solidity ^0.8.0;
/**
* @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;
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (utils/cryptography/ECDSA.sol)
pragma solidity ^0.8.0;
import "../Strings.sol";
/**
* @dev Elliptic Curve Digital Signature Algorithm (ECDSA) operations.
*
* These functions can be used to verify that a message was signed by the holder
* of the private keys of a given address.
*/
library ECDSA {
enum RecoverError {
NoError,
InvalidSignature,
InvalidSignatureLength,
InvalidSignatureS,
InvalidSignatureV // Deprecated in v4.8
}
function _throwError(RecoverError error) private pure {
if (error == RecoverError.NoError) {
return; // no error: do nothing
} else if (error == RecoverError.InvalidSignature) {
revert("ECDSA: invalid signature");
} else if (error == RecoverError.InvalidSignatureLength) {
revert("ECDSA: invalid signature length");
} else if (error == RecoverError.InvalidSignatureS) {
revert("ECDSA: invalid signature 's' value");
}
}
/**
* @dev Returns the address that signed a hashed message (`hash`) with
* `signature` or error string. This address can then be used for verification purposes.
*
* The `ecrecover` EVM opcode allows for malleable (non-unique) signatures:
* this function rejects them by requiring the `s` value to be in the lower
* half order, and the `v` value to be either 27 or 28.
*
* IMPORTANT: `hash` _must_ be the result of a hash operation for the
* verification to be secure: it is possible to craft signatures that
* recover to arbitrary addresses for non-hashed data. A safe way to ensure
* this is by receiving a hash of the original message (which may otherwise
* be too long), and then calling {toEthSignedMessageHash} on it.
*
* Documentation for signature generation:
* - with https://web3js.readthedocs.io/en/v1.3.4/web3-eth-accounts.html#sign[Web3.js]
* - with https://docs.ethers.io/v5/api/signer/#Signer-signMessage[ethers]
*
* _Available since v4.3._
*/
function tryRecover(bytes32 hash, bytes memory signature) internal pure returns (address, RecoverError) {
if (signature.length == 65) {
bytes32 r;
bytes32 s;
uint8 v;
// ecrecover takes the signature parameters, and the only way to get them
// currently is to use assembly.
/// @solidity memory-safe-assembly
assembly {
r := mload(add(signature, 0x20))
s := mload(add(signature, 0x40))
v := byte(0, mload(add(signature, 0x60)))
}
return tryRecover(hash, v, r, s);
} else {
return (address(0), RecoverError.InvalidSignatureLength);
}
}
/**
* @dev Returns the address that signed a hashed message (`hash`) with
* `signature`. This address can then be used for verification purposes.
*
* The `ecrecover` EVM opcode allows for malleable (non-unique) signatures:
* this function rejects them by requiring the `s` value to be in the lower
* half order, and the `v` value to be either 27 or 28.
*
* IMPORTANT: `hash` _must_ be the result of a hash operation for the
* verification to be secure: it is possible to craft signatures that
* recover to arbitrary addresses for non-hashed data. A safe way to ensure
* this is by receiving a hash of the original message (which may otherwise
* be too long), and then calling {toEthSignedMessageHash} on it.
*/
function recover(bytes32 hash, bytes memory signature) internal pure returns (address) {
(address recovered, RecoverError error) = tryRecover(hash, signature);
_throwError(error);
return recovered;
}
/**
* @dev Overload of {ECDSA-tryRecover} that receives the `r` and `vs` short-signature fields separately.
*
* See https://eips.ethereum.org/EIPS/eip-2098[EIP-2098 short signatures]
*
* _Available since v4.3._
*/
function tryRecover(bytes32 hash, bytes32 r, bytes32 vs) internal pure returns (address, RecoverError) {
bytes32 s = vs & bytes32(0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff);
uint8 v = uint8((uint256(vs) >> 255) + 27);
return tryRecover(hash, v, r, s);
}
/**
* @dev Overload of {ECDSA-recover} that receives the `r and `vs` short-signature fields separately.
*
* _Available since v4.2._
*/
function recover(bytes32 hash, bytes32 r, bytes32 vs) internal pure returns (address) {
(address recovered, RecoverError error) = tryRecover(hash, r, vs);
_throwError(error);
return recovered;
}
/**
* @dev Overload of {ECDSA-tryRecover} that receives the `v`,
* `r` and `s` signature fields separately.
*
* _Available since v4.3._
*/
function tryRecover(bytes32 hash, uint8 v, bytes32 r, bytes32 s) internal pure returns (address, RecoverError) {
// EIP-2 still allows signature malleability for ecrecover(). Remove this possibility and make the signature
// unique. Appendix F in the Ethereum Yellow paper (https://ethereum.github.io/yellowpaper/paper.pdf), defines
// the valid range for s in (301): 0 < s < secp256k1n ÷ 2 + 1, and for v in (302): v ∈ {27, 28}. Most
// signatures from current libraries generate a unique signature with an s-value in the lower half order.
//
// If your library generates malleable signatures, such as s-values in the upper range, calculate a new s-value
// with 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEBAAEDCE6AF48A03BBFD25E8CD0364141 - s1 and flip v from 27 to 28 or
// vice versa. If your library also generates signatures with 0/1 for v instead 27/28, add 27 to v to accept
// these malleable signatures as well.
if (uint256(s) > 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF5D576E7357A4501DDFE92F46681B20A0) {
return (address(0), RecoverError.InvalidSignatureS);
}
// If the signature is valid (and not malleable), return the signer address
address signer = ecrecover(hash, v, r, s);
if (signer == address(0)) {
return (address(0), RecoverError.InvalidSignature);
}
return (signer, RecoverError.NoError);
}
/**
* @dev Overload of {ECDSA-recover} that receives the `v`,
* `r` and `s` signature fields separately.
*/
function recover(bytes32 hash, uint8 v, bytes32 r, bytes32 s) internal pure returns (address) {
(address recovered, RecoverError error) = tryRecover(hash, v, r, s);
_throwError(error);
return recovered;
}
/**
* @dev Returns an Ethereum Signed Message, created from a `hash`. This
* produces hash corresponding to the one signed with the
* https://eth.wiki/json-rpc/API#eth_sign[`eth_sign`]
* JSON-RPC method as part of EIP-191.
*
* See {recover}.
*/
function toEthSignedMessageHash(bytes32 hash) internal pure returns (bytes32 message) {
// 32 is the length in bytes of hash,
// enforced by the type signature above
/// @solidity memory-safe-assembly
assembly {
mstore(0x00, "\x19Ethereum Signed Message:\n32")
mstore(0x1c, hash)
message := keccak256(0x00, 0x3c)
}
}
/**
* @dev Returns an Ethereum Signed Message, created from `s`. This
* produces hash corresponding to the one signed with the
* https://eth.wiki/json-rpc/API#eth_sign[`eth_sign`]
* JSON-RPC method as part of EIP-191.
*
* See {recover}.
*/
function toEthSignedMessageHash(bytes memory s) internal pure returns (bytes32) {
return keccak256(abi.encodePacked("\x19Ethereum Signed Message:\n", Strings.toString(s.length), s));
}
/**
* @dev Returns an Ethereum Signed Typed Data, created from a
* `domainSeparator` and a `structHash`. This produces hash corresponding
* to the one signed with the
* https://eips.ethereum.org/EIPS/eip-712[`eth_signTypedData`]
* JSON-RPC method as part of EIP-712.
*
* See {recover}.
*/
function toTypedDataHash(bytes32 domainSeparator, bytes32 structHash) internal pure returns (bytes32 data) {
/// @solidity memory-safe-assembly
assembly {
let ptr := mload(0x40)
mstore(ptr, "\x19\x01")
mstore(add(ptr, 0x02), domainSeparator)
mstore(add(ptr, 0x22), structHash)
data := keccak256(ptr, 0x42)
}
}
/**
* @dev Returns an Ethereum Signed Data with intended validator, created from a
* `validator` and `data` according to the version 0 of EIP-191.
*
* See {recover}.
*/
function toDataWithIntendedValidatorHash(address validator, bytes memory data) internal pure returns (bytes32) {
return keccak256(abi.encodePacked("\x19\x00", validator, data));
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (utils/math/Math.sol)
pragma solidity ^0.8.0;
/**
* @dev Standard math utilities missing in the Solidity language.
*/
library Math {
enum Rounding {
Down, // Toward negative infinity
Up, // Toward infinity
Zero // Toward zero
}
/**
* @dev Returns the largest of two numbers.
*/
function max(uint256 a, uint256 b) internal pure returns (uint256) {
return a > b ? a : b;
}
/**
* @dev Returns the smallest of two numbers.
*/
function min(uint256 a, uint256 b) internal pure returns (uint256) {
return a < b ? a : b;
}
/**
* @dev Returns the average of two numbers. The result is rounded towards
* zero.
*/
function average(uint256 a, uint256 b) internal pure returns (uint256) {
// (a + b) / 2 can overflow.
return (a & b) + (a ^ b) / 2;
}
/**
* @dev Returns the ceiling of the division of two numbers.
*
* This differs from standard division with `/` in that it rounds up instead
* of rounding down.
*/
function ceilDiv(uint256 a, uint256 b) internal pure returns (uint256) {
// (a + b - 1) / b can overflow on addition, so we distribute.
return a == 0 ? 0 : (a - 1) / b + 1;
}
/**
* @notice Calculates floor(x * y / denominator) with full precision. Throws if result overflows a uint256 or denominator == 0
* @dev Original credit to Remco Bloemen under MIT license (https://xn--2-umb.com/21/muldiv)
* with further edits by Uniswap Labs also under MIT license.
*/
function mulDiv(uint256 x, uint256 y, uint256 denominator) internal pure returns (uint256 result) {
unchecked {
// 512-bit multiply [prod1 prod0] = x * y. Compute the product mod 2^256 and mod 2^256 - 1, then use
// use the Chinese Remainder Theorem to reconstruct the 512 bit result. The result is stored in two 256
// variables such that product = prod1 * 2^256 + prod0.
uint256 prod0; // Least significant 256 bits of the product
uint256 prod1; // Most significant 256 bits of the product
assembly {
let mm := mulmod(x, y, not(0))
prod0 := mul(x, y)
prod1 := sub(sub(mm, prod0), lt(mm, prod0))
}
// Handle non-overflow cases, 256 by 256 division.
if (prod1 == 0) {
// Solidity will revert if denominator == 0, unlike the div opcode on its own.
// The surrounding unchecked block does not change this fact.
// See https://docs.soliditylang.org/en/latest/control-structures.html#checked-or-unchecked-arithmetic.
return prod0 / denominator;
}
// Make sure the result is less than 2^256. Also prevents denominator == 0.
require(denominator > prod1, "Math: mulDiv overflow");
///////////////////////////////////////////////
// 512 by 256 division.
///////////////////////////////////////////////
// Make division exact by subtracting the remainder from [prod1 prod0].
uint256 remainder;
assembly {
// Compute remainder using mulmod.
remainder := mulmod(x, y, denominator)
// Subtract 256 bit number from 512 bit number.
prod1 := sub(prod1, gt(remainder, prod0))
prod0 := sub(prod0, remainder)
}
// Factor powers of two out of denominator and compute largest power of two divisor of denominator. Always >= 1.
// See https://cs.stackexchange.com/q/138556/92363.
// Does not overflow because the denominator cannot be zero at this stage in the function.
uint256 twos = denominator & (~denominator + 1);
assembly {
// Divide denominator by twos.
denominator := div(denominator, twos)
// Divide [prod1 prod0] by twos.
prod0 := div(prod0, twos)
// Flip twos such that it is 2^256 / twos. If twos is zero, then it becomes one.
twos := add(div(sub(0, twos), twos), 1)
}
// Shift in bits from prod1 into prod0.
prod0 |= prod1 * twos;
// Invert denominator mod 2^256. Now that denominator is an odd number, it has an inverse modulo 2^256 such
// that denominator * inv = 1 mod 2^256. Compute the inverse by starting with a seed that is correct for
// four bits. That is, denominator * inv = 1 mod 2^4.
uint256 inverse = (3 * denominator) ^ 2;
// Use the Newton-Raphson iteration to improve the precision. Thanks to Hensel's lifting lemma, this also works
// in modular arithmetic, doubling the correct bits in each step.
inverse *= 2 - denominator * inverse; // inverse mod 2^8
inverse *= 2 - denominator * inverse; // inverse mod 2^16
inverse *= 2 - denominator * inverse; // inverse mod 2^32
inverse *= 2 - denominator * inverse; // inverse mod 2^64
inverse *= 2 - denominator * inverse; // inverse mod 2^128
inverse *= 2 - denominator * inverse; // inverse mod 2^256
// Because the division is now exact we can divide by multiplying with the modular inverse of denominator.
// This will give us the correct result modulo 2^256. Since the preconditions guarantee that the outcome is
// less than 2^256, this is the final result. We don't need to compute the high bits of the result and prod1
// is no longer required.
result = prod0 * inverse;
return result;
}
}
/**
* @notice Calculates x * y / denominator with full precision, following the selected rounding direction.
*/
function mulDiv(uint256 x, uint256 y, uint256 denominator, Rounding rounding) internal pure returns (uint256) {
uint256 result = mulDiv(x, y, denominator);
if (rounding == Rounding.Up && mulmod(x, y, denominator) > 0) {
result += 1;
}
return result;
}
/**
* @dev Returns the square root of a number. If the number is not a perfect square, the value is rounded down.
*
* Inspired by Henry S. Warren, Jr.'s "Hacker's Delight" (Chapter 11).
*/
function sqrt(uint256 a) internal pure returns (uint256) {
if (a == 0) {
return 0;
}
// For our first guess, we get the biggest power of 2 which is smaller than the square root of the target.
//
// We know that the "msb" (most significant bit) of our target number `a` is a power of 2 such that we have
// `msb(a) <= a < 2*msb(a)`. This value can be written `msb(a)=2**k` with `k=log2(a)`.
//
// This can be rewritten `2**log2(a) <= a < 2**(log2(a) + 1)`
// → `sqrt(2**k) <= sqrt(a) < sqrt(2**(k+1))`
// → `2**(k/2) <= sqrt(a) < 2**((k+1)/2) <= 2**(k/2 + 1)`
//
// Consequently, `2**(log2(a) / 2)` is a good first approximation of `sqrt(a)` with at least 1 correct bit.
uint256 result = 1 << (log2(a) >> 1);
// At this point `result` is an estimation with one bit of precision. We know the true value is a uint128,
// since it is the square root of a uint256. Newton's method converges quadratically (precision doubles at
// every iteration). We thus need at most 7 iteration to turn our partial result with one bit of precision
// into the expected uint128 result.
unchecked {
result = (result + a / result) >> 1;
result = (result + a / result) >> 1;
result = (result + a / result) >> 1;
result = (result + a / result) >> 1;
result = (result + a / result) >> 1;
result = (result + a / result) >> 1;
result = (result + a / result) >> 1;
return min(result, a / result);
}
}
/**
* @notice Calculates sqrt(a), following the selected rounding direction.
*/
function sqrt(uint256 a, Rounding rounding) internal pure returns (uint256) {
unchecked {
uint256 result = sqrt(a);
return result + (rounding == Rounding.Up && result * result < a ? 1 : 0);
}
}
/**
* @dev Return the log in base 2, rounded down, of a positive value.
* Returns 0 if given 0.
*/
function log2(uint256 value) internal pure returns (uint256) {
uint256 result = 0;
unchecked {
if (value >> 128 > 0) {
value >>= 128;
result += 128;
}
if (value >> 64 > 0) {
value >>= 64;
result += 64;
}
if (value >> 32 > 0) {
value >>= 32;
result += 32;
}
if (value >> 16 > 0) {
value >>= 16;
result += 16;
}
if (value >> 8 > 0) {
value >>= 8;
result += 8;
}
if (value >> 4 > 0) {
value >>= 4;
result += 4;
}
if (value >> 2 > 0) {
value >>= 2;
result += 2;
}
if (value >> 1 > 0) {
result += 1;
}
}
return result;
}
/**
* @dev Return the log in base 2, following the selected rounding direction, of a positive value.
* Returns 0 if given 0.
*/
function log2(uint256 value, Rounding rounding) internal pure returns (uint256) {
unchecked {
uint256 result = log2(value);
return result + (rounding == Rounding.Up && 1 << result < value ? 1 : 0);
}
}
/**
* @dev Return the log in base 10, rounded down, of a positive value.
* Returns 0 if given 0.
*/
function log10(uint256 value) internal pure returns (uint256) {
uint256 result = 0;
unchecked {
if (value >= 10 ** 64) {
value /= 10 ** 64;
result += 64;
}
if (value >= 10 ** 32) {
value /= 10 ** 32;
result += 32;
}
if (value >= 10 ** 16) {
value /= 10 ** 16;
result += 16;
}
if (value >= 10 ** 8) {
value /= 10 ** 8;
result += 8;
}
if (value >= 10 ** 4) {
value /= 10 ** 4;
result += 4;
}
if (value >= 10 ** 2) {
value /= 10 ** 2;
result += 2;
}
if (value >= 10 ** 1) {
result += 1;
}
}
return result;
}
/**
* @dev Return the log in base 10, following the selected rounding direction, of a positive value.
* Returns 0 if given 0.
*/
function log10(uint256 value, Rounding rounding) internal pure returns (uint256) {
unchecked {
uint256 result = log10(value);
return result + (rounding == Rounding.Up && 10 ** result < value ? 1 : 0);
}
}
/**
* @dev Return the log in base 256, rounded down, of a positive value.
* Returns 0 if given 0.
*
* Adding one to the result gives the number of pairs of hex symbols needed to represent `value` as a hex string.
*/
function log256(uint256 value) internal pure returns (uint256) {
uint256 result = 0;
unchecked {
if (value >> 128 > 0) {
value >>= 128;
result += 16;
}
if (value >> 64 > 0) {
value >>= 64;
result += 8;
}
if (value >> 32 > 0) {
value >>= 32;
result += 4;
}
if (value >> 16 > 0) {
value >>= 16;
result += 2;
}
if (value >> 8 > 0) {
result += 1;
}
}
return result;
}
/**
* @dev Return the log in base 256, following the selected rounding direction, of a positive value.
* Returns 0 if given 0.
*/
function log256(uint256 value, Rounding rounding) internal pure returns (uint256) {
unchecked {
uint256 result = log256(value);
return result + (rounding == Rounding.Up && 1 << (result << 3) < value ? 1 : 0);
}
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.8.0) (utils/math/SignedMath.sol)
pragma solidity ^0.8.0;
/**
* @dev Standard signed math utilities missing in the Solidity language.
*/
library SignedMath {
/**
* @dev Returns the largest of two signed numbers.
*/
function max(int256 a, int256 b) internal pure returns (int256) {
return a > b ? a : b;
}
/**
* @dev Returns the smallest of two signed numbers.
*/
function min(int256 a, int256 b) internal pure returns (int256) {
return a < b ? a : b;
}
/**
* @dev Returns the average of two signed numbers without overflow.
* The result is rounded towards zero.
*/
function average(int256 a, int256 b) internal pure returns (int256) {
// Formula from the book "Hacker's Delight"
int256 x = (a & b) + ((a ^ b) >> 1);
return x + (int256(uint256(x) >> 255) & (a ^ b));
}
/**
* @dev Returns the absolute unsigned value of a signed value.
*/
function abs(int256 n) internal pure returns (uint256) {
unchecked {
// must be unchecked in order to support `n = type(int256).min`
return uint256(n >= 0 ? n : -n);
}
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (utils/Strings.sol)
pragma solidity ^0.8.0;
import "./math/Math.sol";
import "./math/SignedMath.sol";
/**
* @dev String operations.
*/
library Strings {
bytes16 private constant _SYMBOLS = "0123456789abcdef";
uint8 private constant _ADDRESS_LENGTH = 20;
/**
* @dev Converts a `uint256` to its ASCII `string` decimal representation.
*/
function toString(uint256 value) internal pure returns (string memory) {
unchecked {
uint256 length = Math.log10(value) + 1;
string memory buffer = new string(length);
uint256 ptr;
/// @solidity memory-safe-assembly
assembly {
ptr := add(buffer, add(32, length))
}
while (true) {
ptr--;
/// @solidity memory-safe-assembly
assembly {
mstore8(ptr, byte(mod(value, 10), _SYMBOLS))
}
value /= 10;
if (value == 0) break;
}
return buffer;
}
}
/**
* @dev Converts a `int256` to its ASCII `string` decimal representation.
*/
function toString(int256 value) internal pure returns (string memory) {
return string(abi.encodePacked(value < 0 ? "-" : "", toString(SignedMath.abs(value))));
}
/**
* @dev Converts a `uint256` to its ASCII `string` hexadecimal representation.
*/
function toHexString(uint256 value) internal pure returns (string memory) {
unchecked {
return toHexString(value, Math.log256(value) + 1);
}
}
/**
* @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length.
*/
function toHexString(uint256 value, uint256 length) internal pure returns (string memory) {
bytes memory buffer = new bytes(2 * length + 2);
buffer[0] = "0";
buffer[1] = "x";
for (uint256 i = 2 * length + 1; i > 1; --i) {
buffer[i] = _SYMBOLS[value & 0xf];
value >>= 4;
}
require(value == 0, "Strings: hex length insufficient");
return string(buffer);
}
/**
* @dev Converts an `address` with fixed length of 20 bytes to its not checksummed ASCII `string` hexadecimal representation.
*/
function toHexString(address addr) internal pure returns (string memory) {
return toHexString(uint256(uint160(addr)), _ADDRESS_LENGTH);
}
/**
* @dev Returns true if the two strings are equal.
*/
function equal(string memory a, string memory b) internal pure returns (bool) {
return keccak256(bytes(a)) == keccak256(bytes(b));
}
}/**
* SPDX-License-Identifier: UNLICENSED
*/
pragma solidity >=0.8.0;
interface IWETH {
function deposit() external payable;
function transfer(address to, uint256 value) external returns (bool);
function withdraw(uint256) external;
}/**
* SPDX-License-Identifier: UNLICENSED
*/
pragma solidity >=0.8.0;
import '@openzeppelin/contracts/interfaces/IERC1271.sol';
import './IQuote.sol';
/// @title IHashflowPool
/// @author Victor Ionescu
/**
* Pool contract used for trading. The Pool can either hold funds or
* rely on external accounts. External accounts are used in order to preserve
* Capital Efficiency on the Market Maker side. This way, a Market Maker can
* make markets using funds that are also used on other venues.
*/
interface IHashflowPool is IQuote, IERC1271 {
/// @notice Specifies a HashflowPool on a foreign chain.
struct AuthorizedXChainPool {
uint16 chainId;
bytes32 pool;
}
/// @notice Contains a signer verification address, and whether trading is enabled.
struct SignerConfiguration {
address signer;
bool enabled;
}
/// @notice Emitted when the authorization status of a withdrawal account changes.
/// @param account The account for which the status changes.
/// @param authorized The new authorization status.
event UpdateWithdrawalAccount(address account, bool authorized);
/// @notice Emitted when the signer key used for the pool has changed.
/// @param signer The new signer key.
/// @param prevSigner The old signer key.
event UpdateSigner(address signer, address prevSigner);
/// @notice Emitted when liquidity is withdrawn from the pool.
/// @param token Token being withdrawn.
/// @param recipient Address receiving the token.
/// @param withdrawAmount Amount being withdrawn.
event RemoveLiquidity(
address token,
address recipient,
uint256 withdrawAmount
);
/// @notice Emitted when an intra-chain trade happens.
/// @param trader The trader.
/// @param effectiveTrader The effective Trader.
/// @param txid The txid of the quote.
/// @param baseToken The token the trader sold.
/// @param quoteToken The token the trader bought.
/// @param baseTokenAmount The amount of baseToken sold.
/// @param quoteTokenAmount The amount of quoteToken bought.
event Trade(
address trader,
address effectiveTrader,
bytes32 txid,
address baseToken,
address quoteToken,
uint256 baseTokenAmount,
uint256 quoteTokenAmount
);
/// @notice Emitted when a cross-chain trade happens.
/// @param dstChainId The Hashflow Chain ID for the destination chain.
/// @param dstPool The pool address on the destination chain.
/// @param trader The trader address.
/// @param txid The txid of the quote.
/// @param baseToken The token the trader sold.
/// @param quoteToken The token the trader bought.
/// @param baseTokenAmount The amount of baseToken sold.
/// @param quoteTokenAmount The amount of quoteToken bought.
event XChainTrade(
uint16 dstChainId,
bytes32 dstPool,
address trader,
bytes32 dstTrader,
bytes32 txid,
address baseToken,
bytes32 quoteToken,
uint256 baseTokenAmount,
uint256 quoteTokenAmount
);
/// @notice Emitted when a cross-chain trade is filled.
/// @param txid The txid identified the quote that was filled.
event XChainTradeFill(bytes32 txid);
/// @notice Main initializer.
/// @param name Name of the pool.
/// @param signer Signer key used for quote / deposit verification.
/// @param operations Operations key that governs the pool.
/// @param router Address of the HashflowRouter contract.
function initialize(
string calldata name,
address signer,
address operations,
address router
) external;
/// @notice Returns the pool name.
function name() external view returns (string memory);
/// @notice Returns the signer address and whether the pool is enabled.
function signerConfiguration() external view returns (address, bool);
/// @notice Returns the Operations address of this pool.
function operations() external view returns (address);
/// @notice Returns the Router contract address.
function router() external view returns (address);
/// @notice Returns the current nonce for a trader.
function nonces(address trader) external view returns (uint256);
/// @notice Removes liquidity from the pool.
/// @param token Token to withdraw.
/// @param recipient Address to send token to.
/// @param amount Amount to withdraw.
function removeLiquidity(
address token,
address recipient,
uint256 amount
) external;
/// @notice Execute an RFQ-T trade.
/// @param quote The quote to be executed.
function tradeRFQT(RFQTQuote memory quote) external payable;
/// @notice Execute an RFQ-M trade.
/// @param quote The quote to be executed.
function tradeRFQM(RFQMQuote memory quote) external;
/// @notice Execute a cross-chain RFQ-T trade.
/// @param quote The quote to be executed.
/// @param trader The account that sends baseToken on this chain.
function tradeXChainRFQT(XChainRFQTQuote memory quote, address trader)
external
payable;
/// @notice Execute a cross-chain RFQ-M trade.
/// @param quote The quote to be executed.
function tradeXChainRFQM(XChainRFQMQuote memory quote) external;
/// @notice Changes authorization for a set of pools to send X-Chain messages.
/// @param pools The pools to change authorization status for.
/// @param authorized The new authorization status.
function updateXChainPoolAuthorization(
AuthorizedXChainPool[] calldata pools,
bool authorized
) external;
/// @notice Changes authorization for an X-Chain Messenger app.
/// @param xChainMessenger The address of the Messenger app.
/// @param authorized The new authorization status.
function updateXChainMessengerAuthorization(
address xChainMessenger,
bool authorized
) external;
/// @notice Fills an x-chain order that completed on the source chain.
/// @param externalAccount The external account to fill from, if any.
/// @param txid The txid of the quote.
/// @param trader The trader to receive the funds.
/// @param quoteToken The token to be sent.
/// @param quoteTokenAmount The amount of quoteToken to be sent.
function fillXChain(
address externalAccount,
bytes32 txid,
address trader,
address quoteToken,
uint256 quoteTokenAmount
) external;
/// @notice Updates withdrawal account authorization.
/// @param withdrawalAccounts the accounts for which to update authorization status.
/// @param authorized The new authorization status.
function updateWithdrawalAccount(
address[] memory withdrawalAccounts,
bool authorized
) external;
/// @notice Updates the signer key.
/// @param signer The new signer key.
function updateSigner(address signer) external;
/// @notice Used by the router to disable pool actions (Trade, Withdraw, Deposit)
function killswitchOperations(bool enabled) external;
/// @notice Returns the token reserves for this pool.
/// @param token The token to check reserves for.
function getReserves(address token) external view returns (uint256);
/// @notice Approves a token for spend. Used for 1inch RFQ protocol.
/// @param token The address of the ERC-20 token.
/// @param spender The spender address (typically the 1inch RFQ order router)
/// @param amount The approval amount.
function approveToken(
address token,
address spender,
uint256 amount
) external;
/// @notice Increases allowance for a token. Used for 1inch RFQ protocol.
/// @param token The address of the ERC-20 token.
/// @param spender The spender address (typically the 1inch RFQ order router).
/// @param amount The approval amount.
function increaseTokenAllowance(
address token,
address spender,
uint256 amount
) external;
/// @notice Decreases allowance for a token. Used for 1inch RFQ protocol.
/// @param token The address of the ERC-20 token.
/// @param spender The spender address (typically the 1inch RFQ order router)
/// @param amount The approval amount.
function decreaseTokenAllowance(
address token,
address spender,
uint256 amount
) external;
}/**
* SPDX-License-Identifier: UNLICENSED
*/
pragma solidity >=0.8.0;
import './IQuote.sol';
/// @title IHashflowRouter
/// @author Victor Ionescu
/**
* @notice In terms of user-facing functionality, the Router is responsible for:
* - orchestrating trades
* - managing cross-chain permissions
*
* Every trade requires consent from two parties: the Trader and the Market Maker.
* However, there are two models to establish consent:
* - RFQ-T: in this model, the Market Maker provides an EIP-191 signature for the quote,
* while the Trader signs the transaction and submits it on-chain
* - RFQ-M: in this model, the Trader provides an EIP-712 signature for the quote,
* the Market Maker provides an EIP-191 signature, and a 3rd party relays the trade.
* The 3rd party can be the Market Maker itself.
*
* In terms of Hashflow internals, the Router maintains a set of authorized pool
* contracts that are allowed to be used for trading. This allowlist creates
* guarantees against malicious behavior, as documented in specific places.
*
* The Router contract is not upgradeable. In order to change functionality, a new
* Router has to be deployed, and new HashflowPool contracts have to be deployed
* by the Market Makers.
*/
/// @dev Trade / liquidity events are emitted at the HashflowPool level, rather than the router.
interface IHashflowRouter is IQuote {
/**
* @notice X-Chain message received from an X-Chain Messenger. This is used by the
* Router to communicate a fill to a HashflowPool.
*/
struct XChainFillMessage {
/// @notice The Hashflow Chain ID of the source chain.
uint16 srcHashflowChainId;
/// @notice The address of the HashflowPool on the source chain.
bytes32 srcPool;
/// @notice The HashflowPool to disburse funds on the destination chain.
address dstPool;
/**
* @notice The external account linked to the HashflowPool on the destination chain.
* If the HashflowPool holds funds, this should be bytes32(0).
*/
address dstExternalAccount;
/// @notice The recipient of the quoteToken on the destination chain.
address dstTrader;
/// @notice The token that the trader buys on the destination chain.
address quoteToken;
/// @notice The amount of quoteToken bought.
uint256 quoteTokenAmount;
/// @notice Unique identifier for the quote.
/// @dev Generated off-chain via a distributed UUID generator.
bytes32 txid;
/// @notice The caller of the trade function on the source chain.
bytes32 srcCaller;
/// @notice The contract to call, if any.
address dstContract;
/// @notice The calldata for the contract.
bytes dstContractCalldata;
}
/// @notice Emitted when the authorization status of a pool changes.
/// @param pool The pool whose status changed.
/// @param authorized The new auth status.
event UpdatePoolAuthorizaton(address pool, bool authorized);
/// @notice Emitted when a sender pool authorization changes.
/// @param pool Pool address on this chain.
/// @param otherHashflowChainId Hashflow Chain ID of the other chain.
/// @param otherChainPool Pool address on the other chain.
/// @param authorized Whether the pool is authorized.
event UpdateXChainPoolAuthorization(
address indexed pool,
uint16 otherHashflowChainId,
bytes32 otherChainPool,
bool authorized
);
/// @notice Emitted when the authorization of an x-caller changes.
/// @param pool Pool address on this chain.
/// @param otherHashflowChainId Hashflow Chain ID of the other chain.
/// @param caller Caller address on the other chain.
/// @param authorized Whether the caller is authorized.
event UpdateXChainCallerAuthorization(
address indexed pool,
uint16 otherHashflowChainId,
bytes32 caller,
bool authorized
);
/// @notice Emitted when the authorization status of an X-Chain Messenger changes for a pool.
/// @param pool Pool address for which the Messenger authorization changes.
/// @param xChainMessenger Address of the Messenger.
/// @param authorized Whether the X-Chain Messenger is authorized.
event UpdateXChainMessengerAuthorization(
address indexed pool,
address xChainMessenger,
bool authorized
);
/// @notice Emitted when the authorized status of an X-Chain Messenger changes for a callee.
/// @param callee Address of the callee.
/// @param xChainMessenger Address of the Messenger.
/// @param authorized Whether the X-Chain Messenger is authorized.
event UpdateXChainMessengerCallerAuthorization(
address indexed callee,
address xChainMessenger,
bool authorized
);
/// @notice Emitted when the Limit Order Guardian address is updated.
/// @param guardian The new Guardian address.
event UpdateLimitOrderGuardian(address guardian);
/// @notice Initializes the Router. Called one time.
/// @param factory The address of the HashflowFactory contract.
function initialize(address factory) external;
/// @notice Returns the address of the associated HashflowFactor contract.
function factory() external view returns (address);
function authorizedXChainPools(
bytes32 dstPool,
uint16 srcHChainId,
bytes32 srcPool
) external view returns (bool);
function authorizedXChainCallers(
address dstContract,
uint16 srcHashflowChainId,
bytes32 caller
) external view returns (bool);
function authorizedXChainMessengersByPool(address pool, address messenger)
external
view
returns (bool);
function authorizedXChainMessengersByCallee(
address callee,
address messenger
) external view returns (bool);
/// @notice Executes an intra-chain RFQ-T trade.
/// @param quote The quote data to be executed.
function tradeRFQT(RFQTQuote memory quote) external payable;
/// @notice Executes an intra-chain RFQ-T trade, leveraging an ERC-20 permit.
/// @param quote The quote data to be executed.
/// @dev Does not support native tokens for the baseToken.
function tradeRFQTWithPermit(
RFQTQuote memory quote,
uint256 deadline,
uint8 v,
bytes32 r,
bytes32 s,
uint256 amountToApprove
) external;
/// @notice Executes an intra-chain RFQ-T trade.
/// @param quote The quote to be executed.
function tradeRFQM(RFQMQuote memory quote) external;
/// @notice Executes an intra-chain RFQ-T trade, leveraging an ERC-20 permit.
/// @param quote The quote to be executed.
/// @param deadline The deadline of the ERC-20 permit.
/// @param v v-part of the signature.
/// @param r r-part of the signature.
/// @param s s-part of the signature.
/// @param amountToApprove The amount being approved.
function tradeRFQMWithPermit(
RFQMQuote memory quote,
uint256 deadline,
uint8 v,
bytes32 r,
bytes32 s,
uint256 amountToApprove
) external;
/// @notice Executes an intra-chain RFQ-T trade.
/// @param quote The quote to be executed.
/// @param guardianSignature A signature issued by the Limit Order Guardian.
function tradeRFQMLimitOrder(
RFQMQuote memory quote,
bytes memory guardianSignature
) external;
/// @notice Executes an intra-chain RFQ-T trade, leveraging an ERC-20 permit.
/// @param quote The quote to be executed.
/// @param guardianSignature A signature issued by the Limit Order Guardian.
/// @param deadline The deadline of the ERC-20 permit.
/// @param v v-part of the signature.
/// @param r r-part of the signature.
/// @param s s-part of the signature.
/// @param amountToApprove The amount being approved.
function tradeRFQMLimitOrderWithPermit(
RFQMQuote memory quote,
bytes memory guardianSignature,
uint256 deadline,
uint8 v,
bytes32 r,
bytes32 s,
uint256 amountToApprove
) external;
/// @notice Executes an RFQ-T cross-chain trade.
/// @param quote The quote to be executed.
/// @param dstContract The address of the contract to be called on the destination chain.
/// @param dstCalldata The calldata for the smart contract call.
function tradeXChainRFQT(
XChainRFQTQuote memory quote,
bytes32 dstContract,
bytes memory dstCalldata
) external payable;
/// @notice Executes an RFQ-T cross-chain trade, leveraging an ERC-20 permit.
/// @param quote The quote to be executed.
/// @param dstContract The address of the contract to be called on the destination chain.
/// @param dstCalldata The calldata for the smart contract call.
/// @param deadline The deadline of the ERC-20 permit.
/// @param v v-part of the signature.
/// @param r r-part of the signature.
/// @param s s-part of the signature.
/// @param amountToApprove The amount being approved.
function tradeXChainRFQTWithPermit(
XChainRFQTQuote memory quote,
bytes32 dstContract,
bytes memory dstCalldata,
uint256 deadline,
uint8 v,
bytes32 r,
bytes32 s,
uint256 amountToApprove
) external payable;
/// @notice Executes an RFQ-M cross-chain trade.
/// @param quote The quote to be executed.
/// @param dstContract The address of the contract to be called on the destination chain.
/// @param dstCalldata The calldata for the smart contract call.
function tradeXChainRFQM(
XChainRFQMQuote memory quote,
bytes32 dstContract,
bytes memory dstCalldata
) external payable;
/// @notice Similar to tradeXChainRFQm, but includes a spend permit for the baseToken.
/// @param quote The quote to be executed.
/// @param dstContract The address of the contract to be called on the destination chain.
/// @param dstCalldata The calldata for the smart contract call.
/// @param deadline The deadline of the ERC-20 permit.
/// @param v v-part of the signature.
/// @param r r-part of the signature.
/// @param s s-part of the signature.
/// @param amountToApprove The amount to approve.
function tradeXChainRFQMWithPermit(
XChainRFQMQuote memory quote,
bytes32 dstContract,
bytes memory dstCalldata,
uint256 deadline,
uint8 v,
bytes32 r,
bytes32 s,
uint256 amountToApprove
) external payable;
/// @notice Completes the second leg of a cross-chain trade.
/// @param fillMessage Payload containing information necessary to complete the trade.
function fillXChain(XChainFillMessage memory fillMessage) external;
/// @notice Returns whether the pool is authorized for trading.
/// @param pool The address of the HashflowPool.
function authorizedPools(address pool) external view returns (bool);
/// @notice Allows the owner to unauthorize a potentially compromised pool. Cannot be reverted.
/// @param pool The address of the HashflowPool.
function forceUnauthorizePool(address pool) external;
/// @notice Authorizes a HashflowPool for trading.
/// @dev Can only be called by the HashflowFactory or the admin.
function updatePoolAuthorization(address pool, bool authorized) external;
/// @notice Updates the authorization status of an X-Chain pool pair.
/// @param otherHashflowChainId The Hashflow Chain ID of the peer chain.
/// @param otherPool The 32-byte representation of the Pool address on the peer chain.
/// @param authorized Whether the pool is authorized to communicate with the sender pool.
function updateXChainPoolAuthorization(
uint16 otherHashflowChainId,
bytes32 otherPool,
bool authorized
) external;
/// @notice Updates the authorization status of an X-Chain caller.
/// @param otherHashflowChainId The Hashflow Chain ID of the peer chain.
/// @param caller The caller address.
/// @param authorized Whether the caller is authorized to send an x-call to the sender pool.
function updateXChainCallerAuthorization(
uint16 otherHashflowChainId,
bytes32 caller,
bool authorized
) external;
/// @notice Updates the authorization status of an X-Chain Messenger app.
/// @param xChainMessenger The address of the Messenger App.
/// @param authorized The new authorization status.
function updateXChainMessengerAuthorization(
address xChainMessenger,
bool authorized
) external;
/// @notice Updates the authorization status of an X-Chain Messenger app.
/// @param xChainMessenger The address of the Messenger App.
/// @param authorized The new authorization status.
function updateXChainMessengerCallerAuthorization(
address xChainMessenger,
bool authorized
) external;
/// @notice Used to stop all operations on a pool, in case of an emergency.
/// @param pool The address of the HashflowPool.
/// @param enabled Whether the pool is enabled.
function killswitchPool(address pool, bool enabled) external;
/// @notice Used to update the Limit Order Guardian.
/// @param guardian The address of the new Guardian.
function updateLimitOrderGuardian(address guardian) external;
/// @notice Allows the owner to withdraw excess funds from the Router.
/// @dev Under normal operations, the Router should not have excess funds.
function withdrawFunds(address token) external;
}/**
* SPDX-License-Identifier: UNLICENSED
*/
pragma solidity >=0.8.0;
/// @title IQuote
/// @author Victor Ionescu
/**
* @notice Interface for quote structs used for trading. There are two major types of trades:
* - intra-chain: atomic transactions within one chain
* - cross-chain: multi-leg transactions between two chains, which utilize interoperability protocols
* such as Wormhole.
*
* Separately, there are two trading modes:
* - RFQ-T: the trader signs the transaction, the market maker signs the quote
* - RFQ-M: both the trader and Market Maker sign the quote, any relayer can sign the transaction
*/
interface IQuote {
/// @notice Used for intra-chain RFQ-T trades.
struct RFQTQuote {
/// @notice The address of the HashflowPool to trade against.
address pool;
/**
* @notice The external account linked to the HashflowPool.
* If the HashflowPool holds funds, this should be address(0).
*/
address externalAccount;
/// @notice The recipient of the quoteToken at the end of the trade.
address trader;
/**
* @notice The account "effectively" making the trade (ultimately receiving the funds).
* This is commonly used by aggregators, where a proxy contract (the 'trader')
* receives the quoteToken, and the effective trader is the user initiating the call.
*
* This field DOES NOT influence movement of funds. However, it is used to check against
* quote replay.
*/
address effectiveTrader;
/// @notice The token that the trader sells.
address baseToken;
/// @notice The token that the trader buys.
address quoteToken;
/**
* @notice The amount of baseToken sold in this trade. The exchange rate
* is going to be preserved as the quoteTokenAmount / baseTokenAmount ratio.
*
* Most commonly, effectiveBaseTokenAmount will == baseTokenAmount.
*/
uint256 effectiveBaseTokenAmount;
/// @notice The max amount of baseToken sold.
uint256 baseTokenAmount;
/// @notice The amount of quoteToken bought when baseTokenAmount is sold.
uint256 quoteTokenAmount;
/// @notice The Unix timestamp (in seconds) when the quote expires.
/// @dev This gets checked against block.timestamp.
uint256 quoteExpiry;
/// @notice The nonce used by this effectiveTrader. Nonces are used to protect against replay.
uint256 nonce;
/// @notice Unique identifier for the quote.
/// @dev Generated off-chain via a distributed UUID generator.
bytes32 txid;
/// @notice Signature provided by the market maker (EIP-191).
bytes signature;
}
/// @notice Used for intra-chain RFQ-M trades.
struct RFQMQuote {
/// @notice The address of the HashflowPool to trade against.
address pool;
/**
* @notice The external account linked to the HashflowPool.
* If the HashflowPool holds funds, this should be address(0).
*/
address externalAccount;
/// @notice The account that will be debited baseToken / credited quoteToken.
address trader;
/// @notice The token that the trader sells.
address baseToken;
/// @notice The token that the trader buys.
address quoteToken;
/// @notice The amount of baseToken sold.
uint256 baseTokenAmount;
/// @notice The amount of quoteToken bought.
uint256 quoteTokenAmount;
/// @notice The Unix timestamp (in seconds) when the quote expires.
/// @dev This gets checked against block.timestamp.
uint256 quoteExpiry;
/// @notice Unique identifier for the quote.
/// @dev Generated off-chain via a distributed UUID generator.
bytes32 txid;
/// @notice Signature provided by the trader (EIP-712).
bytes takerSignature;
/// @notice Signature provided by the market maker (EIP-191).
bytes makerSignature;
}
/// @notice Used for cross-chain RFQ-T trades.
struct XChainRFQTQuote {
/// @notice The Hashflow Chain ID of the source chain.
uint16 srcChainId;
/// @notice The Hashflow Chain ID of the destination chain.
uint16 dstChainId;
/// @notice The address of the HashflowPool to trade against on the source chain.
address srcPool;
/// @notice The HashflowPool to disburse funds on the destination chain.
/// @dev This is bytes32 in order to anticipate non-EVM chains.
bytes32 dstPool;
/**
* @notice The external account linked to the HashflowPool on the source chain.
* If the HashflowPool holds funds, this should be address(0).
*/
address srcExternalAccount;
/**
* @notice The external account linked to the HashflowPool on the destination chain.
* If the HashflowPool holds funds, this should be bytes32(0).
*/
bytes32 dstExternalAccount;
/// @notice The recipient of the quoteToken on the destination chain.
bytes32 dstTrader;
/// @notice The token that the trader sells on the source chain.
address baseToken;
/// @notice The token that the trader buys on the destination chain.
bytes32 quoteToken;
/**
* @notice The amount of baseToken sold in this trade. The exchange rate
* is going to be preserved as the quoteTokenAmount / baseTokenAmount ratio.
*
* Most commonly, effectiveBaseTokenAmount will == baseTokenAmount.
*/
uint256 effectiveBaseTokenAmount;
/// @notice The amount of baseToken sold.
uint256 baseTokenAmount;
/// @notice The amount of quoteToken bought.
uint256 quoteTokenAmount;
/**
* @notice The Unix timestamp (in seconds) when the quote expire. Only enforced
* on the source chain.
*/
/// @dev This gets checked against block.timestamp.
uint256 quoteExpiry;
/// @notice The nonce used by this trader.
uint256 nonce;
/// @notice Unique identifier for the quote.
/// @dev Generated off-chain via a distributed UUID generator.
bytes32 txid;
/**
* @notice The address of the IHashflowXChainMessenger contract used for
* cross-chain communication.
*/
address xChainMessenger;
/// @notice Signature provided by the market maker (EIP-191).
bytes signature;
}
/// @notice Used for Cross-Chain RFQ-M trades.
struct XChainRFQMQuote {
/// @notice The Hashflow Chain ID of the source chain.
uint16 srcChainId;
/// @notice The Hashflow Chain ID of the destination chain.
uint16 dstChainId;
/// @notice The address of the HashflowPool to trade against on the source chain.
address srcPool;
/// @notice The HashflowPool to disburse funds on the destination chain.
/// @dev This is bytes32 in order to anticipate non-EVM chains.
bytes32 dstPool;
/**
* @notice The external account linked to the HashflowPool on the source chain.
* If the HashflowPool holds funds, this should be address(0).
*/
address srcExternalAccount;
/**
* @notice The external account linked to the HashflowPool on the destination chain.
* If the HashflowPool holds funds, this should be bytes32(0).
*/
bytes32 dstExternalAccount;
/// @notice The account that will be debited baseToken on the source chain.
address trader;
/// @notice The recipient of the quoteToken on the destination chain.
bytes32 dstTrader;
/// @notice The token that the trader sells on the source chain.
address baseToken;
/// @notice The token that the trader buys on the destination chain.
bytes32 quoteToken;
/// @notice The amount of baseToken sold.
uint256 baseTokenAmount;
/// @notice The amount of quoteToken bought.
uint256 quoteTokenAmount;
/**
* @notice The Unix timestamp (in seconds) when the quote expire. Only enforced
* on the source chain.
*/
/// @dev This gets checked against block.timestamp.
uint256 quoteExpiry;
/// @notice Unique identifier for the quote.
/// @dev Generated off-chain via a distributed UUID generator.
bytes32 txid;
/**
* @notice The address of the IHashflowXChainMessenger contract used for
* cross-chain communication.
*/
address xChainMessenger;
/// @notice Signature provided by the trader (EIP-712).
bytes takerSignature;
/// @notice Signature provided by the market maker (EIP-191).
bytes makerSignature;
}
}{
"optimizer": {
"enabled": true,
"runs": 200
},
"outputSelection": {
"*": {
"*": [
"evm.bytecode",
"evm.deployedBytecode",
"devdoc",
"userdoc",
"metadata",
"abi"
]
}
},
"libraries": {}
}Contract Security Audit
- No Contract Security Audit Submitted- Submit Audit Here
Contract ABI
API[{"inputs":[{"internalType":"address","name":"weth","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint8","name":"version","type":"uint8"}],"name":"Initialized","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"token","type":"address"},{"indexed":false,"internalType":"address","name":"recipient","type":"address"},{"indexed":false,"internalType":"uint256","name":"withdrawAmount","type":"uint256"}],"name":"RemoveLiquidity","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"trader","type":"address"},{"indexed":false,"internalType":"address","name":"effectiveTrader","type":"address"},{"indexed":false,"internalType":"bytes32","name":"txid","type":"bytes32"},{"indexed":false,"internalType":"address","name":"baseToken","type":"address"},{"indexed":false,"internalType":"address","name":"quoteToken","type":"address"},{"indexed":false,"internalType":"uint256","name":"baseTokenAmount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"quoteTokenAmount","type":"uint256"}],"name":"Trade","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"signer","type":"address"},{"indexed":false,"internalType":"address","name":"prevSigner","type":"address"}],"name":"UpdateSigner","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"account","type":"address"},{"indexed":false,"internalType":"bool","name":"authorized","type":"bool"}],"name":"UpdateWithdrawalAccount","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint16","name":"dstChainId","type":"uint16"},{"indexed":false,"internalType":"bytes32","name":"dstPool","type":"bytes32"},{"indexed":false,"internalType":"address","name":"trader","type":"address"},{"indexed":false,"internalType":"bytes32","name":"dstTrader","type":"bytes32"},{"indexed":false,"internalType":"bytes32","name":"txid","type":"bytes32"},{"indexed":false,"internalType":"address","name":"baseToken","type":"address"},{"indexed":false,"internalType":"bytes32","name":"quoteToken","type":"bytes32"},{"indexed":false,"internalType":"uint256","name":"baseTokenAmount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"quoteTokenAmount","type":"uint256"}],"name":"XChainTrade","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"bytes32","name":"txid","type":"bytes32"}],"name":"XChainTradeFill","type":"event"},{"inputs":[],"name":"_WETH","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"token","type":"address"},{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"approveToken","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"token","type":"address"},{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"decreaseTokenAllowance","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"externalAccount","type":"address"},{"internalType":"bytes32","name":"txid","type":"bytes32"},{"internalType":"address","name":"trader","type":"address"},{"internalType":"address","name":"quoteToken","type":"address"},{"internalType":"uint256","name":"quoteTokenAmount","type":"uint256"}],"name":"fillXChain","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"token","type":"address"}],"name":"getReserves","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"token","type":"address"},{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"increaseTokenAllowance","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"string","name":"_name","type":"string"},{"internalType":"address","name":"_signer","type":"address"},{"internalType":"address","name":"_operations","type":"address"},{"internalType":"address","name":"_router","type":"address"}],"name":"initialize","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"hash","type":"bytes32"},{"internalType":"bytes","name":"signature","type":"bytes"}],"name":"isValidSignature","outputs":[{"internalType":"bytes4","name":"magicValue","type":"bytes4"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bool","name":"enabled","type":"bool"}],"name":"killswitchOperations","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"name","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"nonces","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"operations","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"token","type":"address"},{"internalType":"address","name":"recipient","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"removeLiquidity","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"router","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"signerConfiguration","outputs":[{"internalType":"address","name":"signer","type":"address"},{"internalType":"bool","name":"enabled","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"components":[{"internalType":"address","name":"pool","type":"address"},{"internalType":"address","name":"externalAccount","type":"address"},{"internalType":"address","name":"trader","type":"address"},{"internalType":"address","name":"baseToken","type":"address"},{"internalType":"address","name":"quoteToken","type":"address"},{"internalType":"uint256","name":"baseTokenAmount","type":"uint256"},{"internalType":"uint256","name":"quoteTokenAmount","type":"uint256"},{"internalType":"uint256","name":"quoteExpiry","type":"uint256"},{"internalType":"bytes32","name":"txid","type":"bytes32"},{"internalType":"bytes","name":"takerSignature","type":"bytes"},{"internalType":"bytes","name":"makerSignature","type":"bytes"}],"internalType":"struct IQuote.RFQMQuote","name":"quote","type":"tuple"}],"name":"tradeRFQM","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"components":[{"internalType":"address","name":"pool","type":"address"},{"internalType":"address","name":"externalAccount","type":"address"},{"internalType":"address","name":"trader","type":"address"},{"internalType":"address","name":"effectiveTrader","type":"address"},{"internalType":"address","name":"baseToken","type":"address"},{"internalType":"address","name":"quoteToken","type":"address"},{"internalType":"uint256","name":"effectiveBaseTokenAmount","type":"uint256"},{"internalType":"uint256","name":"baseTokenAmount","type":"uint256"},{"internalType":"uint256","name":"quoteTokenAmount","type":"uint256"},{"internalType":"uint256","name":"quoteExpiry","type":"uint256"},{"internalType":"uint256","name":"nonce","type":"uint256"},{"internalType":"bytes32","name":"txid","type":"bytes32"},{"internalType":"bytes","name":"signature","type":"bytes"}],"internalType":"struct IQuote.RFQTQuote","name":"quote","type":"tuple"}],"name":"tradeRFQT","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"components":[{"internalType":"uint16","name":"srcChainId","type":"uint16"},{"internalType":"uint16","name":"dstChainId","type":"uint16"},{"internalType":"address","name":"srcPool","type":"address"},{"internalType":"bytes32","name":"dstPool","type":"bytes32"},{"internalType":"address","name":"srcExternalAccount","type":"address"},{"internalType":"bytes32","name":"dstExternalAccount","type":"bytes32"},{"internalType":"address","name":"trader","type":"address"},{"internalType":"bytes32","name":"dstTrader","type":"bytes32"},{"internalType":"address","name":"baseToken","type":"address"},{"internalType":"bytes32","name":"quoteToken","type":"bytes32"},{"internalType":"uint256","name":"baseTokenAmount","type":"uint256"},{"internalType":"uint256","name":"quoteTokenAmount","type":"uint256"},{"internalType":"uint256","name":"quoteExpiry","type":"uint256"},{"internalType":"bytes32","name":"txid","type":"bytes32"},{"internalType":"address","name":"xChainMessenger","type":"address"},{"internalType":"bytes","name":"takerSignature","type":"bytes"},{"internalType":"bytes","name":"makerSignature","type":"bytes"}],"internalType":"struct IQuote.XChainRFQMQuote","name":"quote","type":"tuple"}],"name":"tradeXChainRFQM","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"components":[{"internalType":"uint16","name":"srcChainId","type":"uint16"},{"internalType":"uint16","name":"dstChainId","type":"uint16"},{"internalType":"address","name":"srcPool","type":"address"},{"internalType":"bytes32","name":"dstPool","type":"bytes32"},{"internalType":"address","name":"srcExternalAccount","type":"address"},{"internalType":"bytes32","name":"dstExternalAccount","type":"bytes32"},{"internalType":"bytes32","name":"dstTrader","type":"bytes32"},{"internalType":"address","name":"baseToken","type":"address"},{"internalType":"bytes32","name":"quoteToken","type":"bytes32"},{"internalType":"uint256","name":"effectiveBaseTokenAmount","type":"uint256"},{"internalType":"uint256","name":"baseTokenAmount","type":"uint256"},{"internalType":"uint256","name":"quoteTokenAmount","type":"uint256"},{"internalType":"uint256","name":"quoteExpiry","type":"uint256"},{"internalType":"uint256","name":"nonce","type":"uint256"},{"internalType":"bytes32","name":"txid","type":"bytes32"},{"internalType":"address","name":"xChainMessenger","type":"address"},{"internalType":"bytes","name":"signature","type":"bytes"}],"internalType":"struct IQuote.XChainRFQTQuote","name":"quote","type":"tuple"},{"internalType":"address","name":"trader","type":"address"}],"name":"tradeXChainRFQT","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"address","name":"newSigner","type":"address"}],"name":"updateSigner","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address[]","name":"withdrawalAccounts","type":"address[]"},{"internalType":"bool","name":"authorized","type":"bool"}],"name":"updateWithdrawalAccount","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"xChainMessenger","type":"address"},{"internalType":"bool","name":"authorized","type":"bool"}],"name":"updateXChainMessengerAuthorization","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"components":[{"internalType":"uint16","name":"chainId","type":"uint16"},{"internalType":"bytes32","name":"pool","type":"bytes32"}],"internalType":"struct IHashflowPool.AuthorizedXChainPool[]","name":"pools","type":"tuple[]"},{"internalType":"bool","name":"status","type":"bool"}],"name":"updateXChainPoolAuthorization","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"name":"xChainNonces","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"stateMutability":"payable","type":"receive"}]Contract Creation Code
60a06040523480156200001157600080fd5b5060405162003aef38038062003aef8339810160408190526200003491620000c7565b6001600160a01b038116620000b55760405162461bcd60e51b815260206004820152603360248201527f48617368666c6f77506f6f6c3a3a636f6e7374727563746f722057455448206360448201527f616e6e6f74206265203020616464726573732e00000000000000000000000000606482015260840160405180910390fd5b6001600160a01b0316608052620000f9565b600060208284031215620000da57600080fd5b81516001600160a01b0381168114620000f257600080fd5b9392505050565b6080516139cc620001236000396000818161043901528181611e8f0152611ecd01526139cc6000f3fe60806040526004361061014f5760003560e01c8063a7ecd37e116100b6578063d752fab21161006f578063d752fab2146103e7578063da3e339714610407578063e0af361614610427578063e0b45f381461045b578063f34822b4146104a6578063f887ea40146104c657600080fd5b8063a7ecd37e14610341578063b39062e614610361578063b86a5dd714610381578063be99a260146103a1578063c52ac720146103c1578063ca3428d0146103d457600080fd5b80634eeaf16e116101085780634eeaf16e1461024f5780634f2896b81461026f57806376a4f1351461029c5780637ecebe00146102bc57806383ade3dc146102e95780638b33b4b21461030957600080fd5b806306fdde031461015b5780630bc33ce4146101865780631626ba7e146101a85780633020db05146101e157806337cba5fb146102015780633e99c1e41461022157600080fd5b3661015657005b600080fd5b34801561016757600080fd5b506101706104e6565b60405161017d9190612ba4565b60405180910390f35b34801561019257600080fd5b506101a66101a1366004612bf3565b610574565b005b3480156101b457600080fd5b506101c86101c3366004612d62565b6105c9565b6040516001600160e01b0319909116815260200161017d565b3480156101ed57600080fd5b506101a66101fc366004612da8565b610600565b34801561020d57600080fd5b506101a661021c366004612ed7565b6107eb565b34801561022d57600080fd5b5061024161023c366004612f0e565b61091b565b60405190815260200161017d565b34801561025b57600080fd5b506101a661026a366004612f29565b610926565b34801561027b57600080fd5b5061024161028a366004612fae565b60066020526000908152604090205481565b3480156102a857600080fd5b506101a66102b7366004612fc7565b610a5d565b3480156102c857600080fd5b506102416102d7366004612f0e565b60056020526000908152604090205481565b3480156102f557600080fd5b506101a661030436600461301c565b610b99565b34801561031557600080fd5b50600354610329906001600160a01b031681565b6040516001600160a01b03909116815260200161017d565b34801561034d57600080fd5b506101a661035c366004612f0e565b610ce0565b34801561036d57600080fd5b506101a661037c366004612bf3565b610dc7565b34801561038d57600080fd5b506101a661039c3660046130ec565b610e0e565b3480156103ad57600080fd5b506101a66103bc366004613234565b610fd4565b6101a66103cf366004613251565b611047565b6101a66103e236600461334b565b61133a565b3480156103f357600080fd5b506101a6610402366004612bf3565b6115ec565b34801561041357600080fd5b506101a6610422366004612bf3565b61180b565b34801561043357600080fd5b506103297f000000000000000000000000000000000000000000000000000000000000000081565b34801561046757600080fd5b50600254610487906001600160a01b03811690600160a01b900460ff1682565b604080516001600160a01b03909316835290151560208301520161017d565b3480156104b257600080fd5b506101a66104c136600461349f565b611852565b3480156104d257600080fd5b50600454610329906001600160a01b031681565b600180546104f390613521565b80601f016020809104026020016040519081016040528092919081815260200182805461051f90613521565b801561056c5780601f106105415761010080835404028352916020019161056c565b820191906000526020600020905b81548152906001019060200180831161054f57829003601f168201915b505050505081565b6003546001600160a01b0316336001600160a01b0316146105b05760405162461bcd60e51b81526004016105a79061355b565b60405180910390fd5b6105c46001600160a01b0384168383611be1565b505050565b6002546000906001600160a01b03166105e28484611d1d565b6001600160a01b0316036105fa5750630b135d3f60e11b5b92915050565b6004546001600160a01b0316336001600160a01b0316146106335760405162461bcd60e51b81526004016105a7906135b8565b604080518082019091526002546001600160a01b0381168252600160a01b900460ff161515602082018190526106b55760405162461bcd60e51b815260206004820152602160248201527f48617368666c6f77506f6f6c3a3a74726164655246514d2044697361626c65646044820152601760f91b60648201526084016105a7565b60006106c083611d41565b82516101408501519192506001600160a01b0316906106e0908390611d1d565b6001600160a01b0316146107465760405162461bcd60e51b815260206004820152602760248201527f48617368666c6f77506f6f6c3a3a74726164655246514d20496e76616c69642060448201526639b4b3b732b91760c91b60648201526084016105a7565b7f34f57786fb01682fb4eec88d340387ef01a168fe345ea5b76f709d4e560c10eb83604001518460400151856101000151866060015187608001518860a001518960c0015160405161079e979695949392919061360d565b60405180910390a160208301516001600160a01b03166107cf576105c4836080015184604001518560c00151611e3f565b6105c48360200151846080015185604001518660c00151611e74565b6003546001600160a01b0316336001600160a01b03161461081e5760405162461bcd60e51b81526004016105a79061355b565b6001600160a01b0382166108ae5760405162461bcd60e51b815260206004820152604b60248201527f48617368666c6f77506f6f6c3a3a75706461746558436861696e4d657373656e60448201527f676572417574686f72697a6174696f6e20496e76616c6964206d657373656e6760648201526a32b91030b2323932b9b99760a91b608482015260a4016105a7565b600480546040516337cba5fb60e01b81526001600160a01b038581169382019390935283151560248201529116906337cba5fb90604401600060405180830381600087803b1580156108ff57600080fd5b505af1158015610913573d6000803e3d6000fd5b505050505050565b60006105fa82611f5a565b6003546001600160a01b0316336001600160a01b0316146109595760405162461bcd60e51b81526004016105a79061355b565b60005b82811015610a5757600084848381811061097857610978613650565b905060400201602001350361098c57600080fd5b6004546001600160a01b0316635f43286e8585848181106109af576109af613650565b6109c59260206040909202019081019150613666565b8686858181106109d7576109d7613650565b6040805160e087901b6001600160e01b031916815261ffff9590951660048601520291909101602001356024830152508415156044820152606401600060405180830381600087803b158015610a2c57600080fd5b505af1158015610a40573d6000803e3d6000fd5b505050508080610a4f90613697565b91505061095c565b50505050565b6004546001600160a01b0316336001600160a01b031614610a905760405162461bcd60e51b81526004016105a7906135b8565b60008481526008602052604090205460ff1615610b155760405162461bcd60e51b815260206004820152603c60248201527f48617368666c6f77506f6f6c3a3a66696c6c58436861696e2051756f7465206860448201527f6173206265656e2065786563757465642070726576696f75736c792e0000000060648201526084016105a7565b60008481526008602052604090819020805460ff19166001179055517f51415fbbd9fd34f46b7cd4638c20246f7810a73254f3b06f167f7cf6ec9a042490610b609086815260200190565b60405180910390a16001600160a01b038516610b8657610b81828483611e3f565b610b92565b610b9285838584611e74565b5050505050565b6003546001600160a01b0316336001600160a01b031614610bcc5760405162461bcd60e51b81526004016105a79061355b565b60005b82518110156105c45760006001600160a01b0316838281518110610bf557610bf5613650565b60200260200101516001600160a01b031603610c1057600080fd5b8160076000858481518110610c2757610c27613650565b60200260200101516001600160a01b03166001600160a01b0316815260200190815260200160002060006101000a81548160ff0219169083151502179055507fe7727546eb44fa587c611bae55b6e330f0e9184e3d9ea1f292a06cb88699d82c838281518110610c9957610c99613650565b602002602001015183604051610cc69291906001600160a01b039290921682521515602082015260400190565b60405180910390a180610cd881613697565b915050610bcf565b6003546001600160a01b0316336001600160a01b031614610d135760405162461bcd60e51b81526004016105a79061355b565b6001600160a01b038116610d2657600080fd5b6040805180820182526002546001600160a01b03808216808452600160a01b90920460ff1615156020808501919091528451918616825281019190915290917f72959271bae82854684905271432777342373a732ba892607d189cbf5049086f910160405180910390a16001600160a01b03909116808252600280546020909301511515600160a01b026001600160a81b0319909316909117919091179055565b6003546001600160a01b0316336001600160a01b031614610dfa5760405162461bcd60e51b81526004016105a79061355b565b6105c46001600160a01b0384168383611fdf565b6004546001600160a01b0316336001600160a01b031614610e415760405162461bcd60e51b81526004016105a7906135b8565b604080518082019091526002546001600160a01b0381168252600160a01b900460ff16151560208201819052610ec95760405162461bcd60e51b815260206004820152602760248201527f48617368666c6f77506f6f6c3a3a747261646558436861696e5246514d20446960448201526639b0b13632b21760c91b60648201526084016105a7565b6000610ed48361208c565b82516102008501519192506001600160a01b031690610ef4908390611d1d565b6001600160a01b031614610f5f5760405162461bcd60e51b815260206004820152602c60248201527f48617368666c6f77506f6f6c3a3a747261646558436861696e5246514d20496e60448201526b3b30b634b21039b4b3b732b960a11b60648201526084016105a7565b7f3f72b2a38919490277652bb34955c871b20e23068c243319c9fa5e27963d9e12836020015184606001518560c001518660e00151876101a001518861010001518961012001518a61014001518b6101600151604051610fc7999897969594939291906136b0565b60405180910390a1505050565b6004546001600160a01b0316336001600160a01b0316146110075760405162461bcd60e51b81526004016105a7906135b8565b60408051808201909152600280546001600160a01b03811680845293151560209093018390526001600160a81b031916909217600160a01b909102179055565b6004546001600160a01b0316336001600160a01b03161461107a5760405162461bcd60e51b81526004016105a7906135b8565b60808101516001600160a01b03161515806110a1575060208101516001600160a01b031615155b806110af57508060c0015134145b61112f5760405162461bcd60e51b815260206004820152604560248201527f48617368666c6f77506f6f6c3a3a747261646552465154206d73672e76616c7560448201527f65206d75737420657175616c2065666665637469766542617365546f6b656e416064820152641b5bdd5b9d60da1b608482015260a4016105a7565b600061113a8261215b565b604080518082019091526002546001600160a01b0381168252600160a01b900460ff16151560208201819052919250906111c05760405162461bcd60e51b815260206004820152602160248201527f48617368666c6f77506f6f6c3a3a7472616465524651542044697361626c65646044820152601760f91b60648201526084016105a7565b80600001516001600160a01b03166111e684610180015184611d1d90919063ffffffff16565b6001600160a01b03161461124c5760405162461bcd60e51b815260206004820152602760248201527f48617368666c6f77506f6f6c3a3a74726164655246515420496e76616c69642060448201526639b4b3b732b91760c91b60648201526084016105a7565b61125f83606001518461014001516121b0565b61010083015160e084015160c0850151101561129c578360e001518461010001518560c0015161128f9190613703565b611299919061371a565b90505b7f34f57786fb01682fb4eec88d340387ef01a168fe345ea5b76f709d4e560c10eb8460400151856060015186610160015187608001518860a001518960c00151876040516112f0979695949392919061360d565b60405180910390a160208401516001600160a01b03166113225761131d8460a00151856040015183611e3f565b610a57565b610a5784602001518560a00151866040015184611e74565b6004546001600160a01b0316336001600160a01b03161461136d5760405162461bcd60e51b81526004016105a7906135b8565b60808201516001600160a01b0316151580611394575060e08201516001600160a01b031615155b806113a3575081610120015134145b61140d5760405162461bcd60e51b815260206004820152603560248201527f48617368666c6f77506f6f6c3a3a747261646558436861696e52465154206d7360448201527419cb9d985b1d59481b5d5cdd080f48185b5bdd5b9d605a1b60648201526084016105a7565b604080518082019091526002546001600160a01b0381168252600160a01b900460ff161515602082018190526114955760405162461bcd60e51b815260206004820152602760248201527f48617368666c6f77506f6f6c3a3a747261646558436861696e5246515420446960448201526639b0b13632b21760c91b60648201526084016105a7565b6114a88360c00151846101a00151612245565b60006114b3846122cc565b82516102008601519192506001600160a01b0316906114d3908390611d1d565b6001600160a01b03161461153e5760405162461bcd60e51b815260206004820152602c60248201527f48617368666c6f77506f6f6c3a3a747261646558436861696e5246515420496e60448201526b3b30b634b21039b4b3b732b960a11b60648201526084016105a7565b610160840151610140850151610120860151101561157f578461014001518561012001518661016001516115729190613703565b61157c919061371a565b90505b7f3f72b2a38919490277652bb34955c871b20e23068c243319c9fa5e27963d9e1285602001518660600151868860c00151896101c001518a60e001518b61010001518c6101200151896040516115dd999897969594939291906136b0565b60405180910390a15050505050565b6003546001600160a01b0316336001600160a01b03161461161f5760405162461bcd60e51b81526004016105a79061355b565b604080518082019091526002546001600160a01b0381168252600160a01b900460ff161515602082018190526116a75760405162461bcd60e51b815260206004820152602760248201527f48617368666c6f77506f6f6c3a3a72656d6f76654c697175696469747920446960448201526639b0b13632b21760c91b60648201526084016105a7565b6000821161170c5760405162461bcd60e51b815260206004820152602c60248201527f48617368666c6f77506f6f6c3a3a72656d6f76654c697175696469747920496e60448201526b1d985b1a5908185b5bdd5b9d60a21b60648201526084016105a7565b60006001600160a01b038416156117b2576001600160a01b03841660009081526007602052604090205460ff166117ab5760405162461bcd60e51b815260206004820152603f60248201527f48617368666c6f77506f6f6c3a3a72656d6f76654c697175696469747920526560448201527f63697069656e74206d7573742062652068656467696e67206163636f756e740060648201526084016105a7565b50826117b5565b50335b604080516001600160a01b038088168252831660208201529081018490527fd8ae9b9ba89e637bcb66a69ac91e8f688018e81d6f92c57e02226425c8efbdf69060600160405180910390a1610b92858285611e3f565b6003546001600160a01b0316336001600160a01b03161461183e5760405162461bcd60e51b81526004016105a79061355b565b6105c46001600160a01b0384168383612412565b600054610100900460ff16158080156118725750600054600160ff909116105b8061188c5750303b15801561188c575060005460ff166001145b6118ef5760405162461bcd60e51b815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201526d191e481a5b9a5d1a585b1a5e995960921b60648201526084016105a7565b6000805460ff191660011790558015611912576000805461ff0019166101001790555b6001600160a01b0384166119855760405162461bcd60e51b815260206004820152603460248201527f48617368666c6f77506f6f6c3a3a696e697469616c697a65205369676e65722060448201527331b0b73737ba10313290181030b2323932b9b99760611b60648201526084016105a7565b6001600160a01b038316611a015760405162461bcd60e51b815260206004820152603860248201527f48617368666c6f77506f6f6c3a3a696e697469616c697a65204f70657261746960448201527f6f6e732063616e6e6f74206265203020616464726573732e000000000000000060648201526084016105a7565b6001600160a01b038216611a745760405162461bcd60e51b815260206004820152603460248201527f48617368666c6f77506f6f6c3a3a696e697469616c697a6520526f757465722060448201527331b0b73737ba10313290181030b2323932b9b99760611b60648201526084016105a7565b6000855111611adb5760405162461bcd60e51b815260206004820152602d60248201527f48617368666c6f77506f6f6c3a3a696e697469616c697a65204e616d6520636160448201526c6e6e6f7420626520656d70747960981b60648201526084016105a7565b6001611ae78682613782565b5060408051808201825260016020808301919091526001600160a01b038716808352835190815260009181019190915290917f72959271bae82854684905271432777342373a732ba892607d189cbf5049086f910160405180910390a18051600280546020909301511515600160a01b026001600160a81b03199093166001600160a01b039283161792909217909155600380548583166001600160a01b03199182161790915560048054928516929091169190911790558015610b92576000805461ff0019169055604051600181527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb3847402498906020016115dd565b604051636eb1769f60e11b81523060048201526001600160a01b0383811660248301526000919085169063dd62ed3e90604401602060405180830381865afa158015611c31573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611c559190613841565b905081811015611cb95760405162461bcd60e51b815260206004820152602960248201527f5361666545524332303a2064656372656173656420616c6c6f77616e63652062604482015268656c6f77207a65726f60b81b60648201526084016105a7565b6040516001600160a01b03841660248201528282036044820152610a5790859063095ea7b360e01b906064015b60408051601f198184030181529190526020810180516001600160e01b03166001600160e01b03199093169290921790915261249d565b6000806000611d2c8585612572565b91509150611d39816125b7565b509392505050565b8051602080830151604080850151606080870151608088015160a089015160c08a015160e08b01516101008c015197519a861b6001600160601b03199081169a8c019a909a5297851b891660348b015294841b881660488a015291831b8716605c89015290911b9094166070860152608485019390935260a484019290925260c483015260e482015246610104820152600090610124015b60408051601f198184030181529082905280516020918201207f19457468657265756d205369676e6564204d6573736167653a0a33320000000091830191909152603c820152605c01604051602081830303815290604052805190602001209050919050565b6001600160a01b038316611e60576105c46001600160a01b03831682612704565b6105c46001600160a01b038416838361281d565b6001600160a01b038316611f4557611eb76001600160a01b037f00000000000000000000000000000000000000000000000000000000000000001685308461284d565b604051632e1a7d4d60e01b8152600481018290527f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031690632e1a7d4d90602401600060405180830381600087803b158015611f1957600080fd5b505af1158015611f2d573d6000803e3d6000fd5b5061131d925050506001600160a01b03831682612704565b610a576001600160a01b03841685848461284d565b60006001600160a01b03821615611fd8576040516370a0823160e01b81523060048201526001600160a01b038316906370a0823190602401602060405180830381865afa158015611faf573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611fd39190613841565b6105fa565b4792915050565b604051636eb1769f60e11b81523060048201526001600160a01b0383811660248301526000919085169063dd62ed3e90604401602060405180830381865afa15801561202f573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906120539190613841565b9050610a578463095ea7b360e01b8561206c868661385a565b6040516001600160a01b0390921660248301526044820152606401611ce6565b80516020808301516040808501516060860151608087015160a088015193516000976120bc97909695910161386d565b60408051601f19818403018152828252805160209182012060c08601516101008701516101208801516101408901516101608a01516101808b01516101a08c01516101c08d0151988b01979097526001600160601b0319606096871b8116998b019990995293851b881660548a01526068890192909252608888015260a887015260c886015260e88501919091521b1661010882015261011c01611dd9565b60003082604001518360600151846020015185608001518660a001518760e001518861010001518961014001518a61012001518b610160015146604051602001611dd99c9b9a999897969594939291906138bc565b6001600160a01b03821660009081526005602052604090205481116122295760405162461bcd60e51b815260206004820152602960248201527f48617368666c6f77506f6f6c3a3a5f7570646174654e6f6e636520496e76616c60448201526834b2103737b731b29760b91b60648201526084016105a7565b6001600160a01b03909116600090815260056020526040902055565b60008281526006602052604090205481116122ba5760405162461bcd60e51b815260206004820152602f60248201527f48617368666c6f77506f6f6c3a3a5f7570646174654e6f6e636558436861696e60448201526e1024b73b30b634b2103737b731b29760891b60648201526084016105a7565b60009182526006602052604090912055565b600080826000015183602001518460400151856060015186608001518760a001516040516020016123029695949392919061386d565b60408051808303601f19018152828252805160209182012060c087015160e08801516101008901516101408a01516101608b01516101808c01516101a08d01516101c08e01516101e08f01518a8d01999099528b8b0197909752606095861b6001600160601b0319908116878d015260748c019590955260948b019390935260b48a019190915260d489015260f48801526101148701929092529190911b166101348401528151610128818503018152610148840190925281519101207f19457468657265756d205369676e6564204d6573736167653a0a333200000000610168830152610184820181905291506101a40160405160208183030381529060405280519060200120915050919050565b604080516001600160a01b038416602482015260448082018490528251808303909101815260649091019091526020810180516001600160e01b031663095ea7b360e01b1790526124638482612885565b610a57576040516001600160a01b03841660248201526000604482015261249790859063095ea7b360e01b90606401611ce6565b610a5784825b60006124f2826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b031661292c9092919063ffffffff16565b90508051600014806125135750808060200190518101906125139190613947565b6105c45760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b60648201526084016105a7565b60008082516041036125a85760208301516040840151606085015160001a61259c87828585612943565b945094505050506125b0565b506000905060025b9250929050565b60008160048111156125cb576125cb613964565b036125d35750565b60018160048111156125e7576125e7613964565b036126345760405162461bcd60e51b815260206004820152601860248201527f45434453413a20696e76616c6964207369676e6174757265000000000000000060448201526064016105a7565b600281600481111561264857612648613964565b036126955760405162461bcd60e51b815260206004820152601f60248201527f45434453413a20696e76616c6964207369676e6174757265206c656e6774680060448201526064016105a7565b60038160048111156126a9576126a9613964565b036127015760405162461bcd60e51b815260206004820152602260248201527f45434453413a20696e76616c6964207369676e6174757265202773272076616c604482015261756560f01b60648201526084016105a7565b50565b804710156127545760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a20696e73756666696369656e742062616c616e636500000060448201526064016105a7565b6000826001600160a01b03168260405160006040518083038185875af1925050503d80600081146127a1576040519150601f19603f3d011682016040523d82523d6000602084013e6127a6565b606091505b50509050806105c45760405162461bcd60e51b815260206004820152603a60248201527f416464726573733a20756e61626c6520746f2073656e642076616c75652c207260448201527f6563697069656e74206d6179206861766520726576657274656400000000000060648201526084016105a7565b6040516001600160a01b0383166024820152604481018290526105c490849063a9059cbb60e01b90606401611ce6565b6040516001600160a01b0380851660248301528316604482015260648101829052610a579085906323b872dd60e01b90608401611ce6565b6000806000846001600160a01b0316846040516128a2919061397a565b6000604051808303816000865af19150503d80600081146128df576040519150601f19603f3d011682016040523d82523d6000602084013e6128e4565b606091505b509150915081801561290e57508051158061290e57508080602001905181019061290e9190613947565b801561292357506001600160a01b0385163b15155b95945050505050565b606061293b8484600085612a07565b949350505050565b6000807f7fffffffffffffffffffffffffffffff5d576e7357a4501ddfe92f46681b20a083111561297a57506000905060036129fe565b6040805160008082526020820180845289905260ff881692820192909252606081018690526080810185905260019060a0016020604051602081039080840390855afa1580156129ce573d6000803e3d6000fd5b5050604051601f1901519150506001600160a01b0381166129f7576000600192509250506129fe565b9150600090505b94509492505050565b606082471015612a685760405162461bcd60e51b815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f6044820152651c8818d85b1b60d21b60648201526084016105a7565b600080866001600160a01b03168587604051612a84919061397a565b60006040518083038185875af1925050503d8060008114612ac1576040519150601f19603f3d011682016040523d82523d6000602084013e612ac6565b606091505b5091509150612ad787838387612ae2565b979650505050505050565b60608315612b51578251600003612b4a576001600160a01b0385163b612b4a5760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e747261637400000060448201526064016105a7565b508161293b565b61293b8383815115612b665781518083602001fd5b8060405162461bcd60e51b81526004016105a79190612ba4565b60005b83811015612b9b578181015183820152602001612b83565b50506000910152565b6020815260008251806020840152612bc3816040850160208701612b80565b601f01601f19169190910160400192915050565b80356001600160a01b0381168114612bee57600080fd5b919050565b600080600060608486031215612c0857600080fd5b612c1184612bd7565b9250612c1f60208501612bd7565b9150604084013590509250925092565b634e487b7160e01b600052604160045260246000fd5b60405161016081016001600160401b0381118282101715612c6857612c68612c2f565b60405290565b60405161022081016001600160401b0381118282101715612c6857612c68612c2f565b6040516101a081016001600160401b0381118282101715612c6857612c68612c2f565b604051601f8201601f191681016001600160401b0381118282101715612cdc57612cdc612c2f565b604052919050565b60006001600160401b03831115612cfd57612cfd612c2f565b612d10601f8401601f1916602001612cb4565b9050828152838383011115612d2457600080fd5b828260208301376000602084830101529392505050565b600082601f830112612d4c57600080fd5b612d5b83833560208501612ce4565b9392505050565b60008060408385031215612d7557600080fd5b8235915060208301356001600160401b03811115612d9257600080fd5b612d9e85828601612d3b565b9150509250929050565b600060208284031215612dba57600080fd5b81356001600160401b0380821115612dd157600080fd5b908301906101608286031215612de657600080fd5b612dee612c45565b612df783612bd7565b8152612e0560208401612bd7565b6020820152612e1660408401612bd7565b6040820152612e2760608401612bd7565b6060820152612e3860808401612bd7565b608082015260a083013560a082015260c083013560c082015260e083013560e08201526101008084013581830152506101208084013583811115612e7b57600080fd5b612e8788828701612d3b565b8284015250506101408084013583811115612ea157600080fd5b612ead88828701612d3b565b918301919091525095945050505050565b801515811461270157600080fd5b8035612bee81612ebe565b60008060408385031215612eea57600080fd5b612ef383612bd7565b91506020830135612f0381612ebe565b809150509250929050565b600060208284031215612f2057600080fd5b612d5b82612bd7565b600080600060408486031215612f3e57600080fd5b83356001600160401b0380821115612f5557600080fd5b818601915086601f830112612f6957600080fd5b813581811115612f7857600080fd5b8760208260061b8501011115612f8d57600080fd5b60209283019550935050840135612fa381612ebe565b809150509250925092565b600060208284031215612fc057600080fd5b5035919050565b600080600080600060a08688031215612fdf57600080fd5b612fe886612bd7565b945060208601359350612ffd60408701612bd7565b925061300b60608701612bd7565b949793965091946080013592915050565b6000806040838503121561302f57600080fd5b82356001600160401b038082111561304657600080fd5b818501915085601f83011261305a57600080fd5b813560208282111561306e5761306e612c2f565b8160051b925061307f818401612cb4565b828152928401810192818101908985111561309957600080fd5b948201945b848610156130be576130af86612bd7565b8252948201949082019061309e565b96506130cd9050878201612ecc565b9450505050509250929050565b803561ffff81168114612bee57600080fd5b6000602082840312156130fe57600080fd5b81356001600160401b038082111561311557600080fd5b90830190610220828603121561312a57600080fd5b613132612c6e565b61313b836130da565b8152613149602084016130da565b602082015261315a60408401612bd7565b60408201526060830135606082015261317560808401612bd7565b608082015260a083013560a082015261319060c08401612bd7565b60c082015260e083013560e08201526101006131ad818501612bd7565b9082015261012083810135908201526101408084013590820152610160808401359082015261018080840135908201526101a080840135908201526101c06131f6818501612bd7565b908201526101e0838101358381111561320e57600080fd5b61321a88828701612d3b565b8284015250506102008084013583811115612ea157600080fd5b60006020828403121561324657600080fd5b8135612d5b81612ebe565b60006020828403121561326357600080fd5b81356001600160401b038082111561327a57600080fd5b908301906101a0828603121561328f57600080fd5b613297612c91565b6132a083612bd7565b81526132ae60208401612bd7565b60208201526132bf60408401612bd7565b60408201526132d060608401612bd7565b60608201526132e160808401612bd7565b60808201526132f260a08401612bd7565b60a082015260c0838101359082015260e0808401359082015261010080840135908201526101208084013590820152610140808401359082015261016080840135908201526101808084013583811115612ea157600080fd5b6000806040838503121561335e57600080fd5b82356001600160401b038082111561337557600080fd5b90840190610220828703121561338a57600080fd5b613392612c6e565b61339b836130da565b81526133a9602084016130da565b60208201526133ba60408401612bd7565b6040820152606083013560608201526133d560808401612bd7565b608082015260a083013560a082015260c083013560c08201526133fa60e08401612bd7565b60e0820152610100838101359082015261012080840135908201526101408084013590820152610160808401359082015261018080840135908201526101a080840135908201526101c080840135908201526101e061345a818501612bd7565b90820152610200838101358381111561347257600080fd5b61347e89828701612d3b565b82840152505080945050505061349660208401612bd7565b90509250929050565b600080600080608085870312156134b557600080fd5b84356001600160401b038111156134cb57600080fd5b8501601f810187136134dc57600080fd5b6134eb87823560208401612ce4565b9450506134fa60208601612bd7565b925061350860408601612bd7565b915061351660608601612bd7565b905092959194509250565b600181811c9082168061353557607f821691505b60208210810361355557634e487b7160e01b600052602260045260246000fd5b50919050565b6020808252603a908201527f48617368666c6f77506f6f6c3a617574686f72697a65644f7065726174696f6e60408201527f732053656e646572206d757374206265206f70657261746f722e000000000000606082015260800190565b60208082526035908201527f48617368666c6f77506f6f6c3a3a617574686f72697a6564526f75746572205360408201527432b73232b91036bab9ba103132902937baba32b91760591b606082015260800190565b6001600160a01b039788168152958716602087015260408601949094529185166060850152909316608083015260a082019290925260c081019190915260e00190565b634e487b7160e01b600052603260045260246000fd5b60006020828403121561367857600080fd5b612d5b826130da565b634e487b7160e01b600052601160045260246000fd5b6000600182016136a9576136a9613681565b5060010190565b61ffff99909916895260208901979097526001600160a01b0395861660408901526060880194909452608087019290925290921660a085015260c084019190915260e08301526101008201526101200190565b80820281158282048414176105fa576105fa613681565b60008261373757634e487b7160e01b600052601260045260246000fd5b500490565b601f8211156105c457600081815260208120601f850160051c810160208610156137635750805b601f850160051c820191505b818110156109135782815560010161376f565b81516001600160401b0381111561379b5761379b612c2f565b6137af816137a98454613521565b8461373c565b602080601f8311600181146137e457600084156137cc5750858301515b600019600386901b1c1916600185901b178555610913565b600085815260208120601f198616915b82811015613813578886015182559484019460019091019084016137f4565b50858210156138315787850151600019600388901b60f8161c191681555b5050505050600190811b01905550565b60006020828403121561385357600080fd5b5051919050565b808201808211156105fa576105fa613681565b6001600160f01b031960f097881b811682529590961b90941660028601526001600160601b0319606093841b81166004870152601886019290925290911b166038830152604c820152606c0190565b6001600160601b031960608e811b821683528d811b821660148401528c811b821660288401528b811b8216603c8401528a901b1660508201526000613910606483018a60601b6001600160601b0319169052565b506078810196909652609886019490945260b885019290925260d884015260f8830152610118820152610138019695505050505050565b60006020828403121561395957600080fd5b8151612d5b81612ebe565b634e487b7160e01b600052602160045260246000fd5b6000825161398c818460208701612b80565b919091019291505056fea2646970667358221220c26f589b7ebb50bc927555b865065439bc21d9afbe2f36c0fda198a7cf72c3dc64736f6c63430008120033000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2
Deployed Bytecode
0x60806040526004361061014f5760003560e01c8063a7ecd37e116100b6578063d752fab21161006f578063d752fab2146103e7578063da3e339714610407578063e0af361614610427578063e0b45f381461045b578063f34822b4146104a6578063f887ea40146104c657600080fd5b8063a7ecd37e14610341578063b39062e614610361578063b86a5dd714610381578063be99a260146103a1578063c52ac720146103c1578063ca3428d0146103d457600080fd5b80634eeaf16e116101085780634eeaf16e1461024f5780634f2896b81461026f57806376a4f1351461029c5780637ecebe00146102bc57806383ade3dc146102e95780638b33b4b21461030957600080fd5b806306fdde031461015b5780630bc33ce4146101865780631626ba7e146101a85780633020db05146101e157806337cba5fb146102015780633e99c1e41461022157600080fd5b3661015657005b600080fd5b34801561016757600080fd5b506101706104e6565b60405161017d9190612ba4565b60405180910390f35b34801561019257600080fd5b506101a66101a1366004612bf3565b610574565b005b3480156101b457600080fd5b506101c86101c3366004612d62565b6105c9565b6040516001600160e01b0319909116815260200161017d565b3480156101ed57600080fd5b506101a66101fc366004612da8565b610600565b34801561020d57600080fd5b506101a661021c366004612ed7565b6107eb565b34801561022d57600080fd5b5061024161023c366004612f0e565b61091b565b60405190815260200161017d565b34801561025b57600080fd5b506101a661026a366004612f29565b610926565b34801561027b57600080fd5b5061024161028a366004612fae565b60066020526000908152604090205481565b3480156102a857600080fd5b506101a66102b7366004612fc7565b610a5d565b3480156102c857600080fd5b506102416102d7366004612f0e565b60056020526000908152604090205481565b3480156102f557600080fd5b506101a661030436600461301c565b610b99565b34801561031557600080fd5b50600354610329906001600160a01b031681565b6040516001600160a01b03909116815260200161017d565b34801561034d57600080fd5b506101a661035c366004612f0e565b610ce0565b34801561036d57600080fd5b506101a661037c366004612bf3565b610dc7565b34801561038d57600080fd5b506101a661039c3660046130ec565b610e0e565b3480156103ad57600080fd5b506101a66103bc366004613234565b610fd4565b6101a66103cf366004613251565b611047565b6101a66103e236600461334b565b61133a565b3480156103f357600080fd5b506101a6610402366004612bf3565b6115ec565b34801561041357600080fd5b506101a6610422366004612bf3565b61180b565b34801561043357600080fd5b506103297f000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc281565b34801561046757600080fd5b50600254610487906001600160a01b03811690600160a01b900460ff1682565b604080516001600160a01b03909316835290151560208301520161017d565b3480156104b257600080fd5b506101a66104c136600461349f565b611852565b3480156104d257600080fd5b50600454610329906001600160a01b031681565b600180546104f390613521565b80601f016020809104026020016040519081016040528092919081815260200182805461051f90613521565b801561056c5780601f106105415761010080835404028352916020019161056c565b820191906000526020600020905b81548152906001019060200180831161054f57829003601f168201915b505050505081565b6003546001600160a01b0316336001600160a01b0316146105b05760405162461bcd60e51b81526004016105a79061355b565b60405180910390fd5b6105c46001600160a01b0384168383611be1565b505050565b6002546000906001600160a01b03166105e28484611d1d565b6001600160a01b0316036105fa5750630b135d3f60e11b5b92915050565b6004546001600160a01b0316336001600160a01b0316146106335760405162461bcd60e51b81526004016105a7906135b8565b604080518082019091526002546001600160a01b0381168252600160a01b900460ff161515602082018190526106b55760405162461bcd60e51b815260206004820152602160248201527f48617368666c6f77506f6f6c3a3a74726164655246514d2044697361626c65646044820152601760f91b60648201526084016105a7565b60006106c083611d41565b82516101408501519192506001600160a01b0316906106e0908390611d1d565b6001600160a01b0316146107465760405162461bcd60e51b815260206004820152602760248201527f48617368666c6f77506f6f6c3a3a74726164655246514d20496e76616c69642060448201526639b4b3b732b91760c91b60648201526084016105a7565b7f34f57786fb01682fb4eec88d340387ef01a168fe345ea5b76f709d4e560c10eb83604001518460400151856101000151866060015187608001518860a001518960c0015160405161079e979695949392919061360d565b60405180910390a160208301516001600160a01b03166107cf576105c4836080015184604001518560c00151611e3f565b6105c48360200151846080015185604001518660c00151611e74565b6003546001600160a01b0316336001600160a01b03161461081e5760405162461bcd60e51b81526004016105a79061355b565b6001600160a01b0382166108ae5760405162461bcd60e51b815260206004820152604b60248201527f48617368666c6f77506f6f6c3a3a75706461746558436861696e4d657373656e60448201527f676572417574686f72697a6174696f6e20496e76616c6964206d657373656e6760648201526a32b91030b2323932b9b99760a91b608482015260a4016105a7565b600480546040516337cba5fb60e01b81526001600160a01b038581169382019390935283151560248201529116906337cba5fb90604401600060405180830381600087803b1580156108ff57600080fd5b505af1158015610913573d6000803e3d6000fd5b505050505050565b60006105fa82611f5a565b6003546001600160a01b0316336001600160a01b0316146109595760405162461bcd60e51b81526004016105a79061355b565b60005b82811015610a5757600084848381811061097857610978613650565b905060400201602001350361098c57600080fd5b6004546001600160a01b0316635f43286e8585848181106109af576109af613650565b6109c59260206040909202019081019150613666565b8686858181106109d7576109d7613650565b6040805160e087901b6001600160e01b031916815261ffff9590951660048601520291909101602001356024830152508415156044820152606401600060405180830381600087803b158015610a2c57600080fd5b505af1158015610a40573d6000803e3d6000fd5b505050508080610a4f90613697565b91505061095c565b50505050565b6004546001600160a01b0316336001600160a01b031614610a905760405162461bcd60e51b81526004016105a7906135b8565b60008481526008602052604090205460ff1615610b155760405162461bcd60e51b815260206004820152603c60248201527f48617368666c6f77506f6f6c3a3a66696c6c58436861696e2051756f7465206860448201527f6173206265656e2065786563757465642070726576696f75736c792e0000000060648201526084016105a7565b60008481526008602052604090819020805460ff19166001179055517f51415fbbd9fd34f46b7cd4638c20246f7810a73254f3b06f167f7cf6ec9a042490610b609086815260200190565b60405180910390a16001600160a01b038516610b8657610b81828483611e3f565b610b92565b610b9285838584611e74565b5050505050565b6003546001600160a01b0316336001600160a01b031614610bcc5760405162461bcd60e51b81526004016105a79061355b565b60005b82518110156105c45760006001600160a01b0316838281518110610bf557610bf5613650565b60200260200101516001600160a01b031603610c1057600080fd5b8160076000858481518110610c2757610c27613650565b60200260200101516001600160a01b03166001600160a01b0316815260200190815260200160002060006101000a81548160ff0219169083151502179055507fe7727546eb44fa587c611bae55b6e330f0e9184e3d9ea1f292a06cb88699d82c838281518110610c9957610c99613650565b602002602001015183604051610cc69291906001600160a01b039290921682521515602082015260400190565b60405180910390a180610cd881613697565b915050610bcf565b6003546001600160a01b0316336001600160a01b031614610d135760405162461bcd60e51b81526004016105a79061355b565b6001600160a01b038116610d2657600080fd5b6040805180820182526002546001600160a01b03808216808452600160a01b90920460ff1615156020808501919091528451918616825281019190915290917f72959271bae82854684905271432777342373a732ba892607d189cbf5049086f910160405180910390a16001600160a01b03909116808252600280546020909301511515600160a01b026001600160a81b0319909316909117919091179055565b6003546001600160a01b0316336001600160a01b031614610dfa5760405162461bcd60e51b81526004016105a79061355b565b6105c46001600160a01b0384168383611fdf565b6004546001600160a01b0316336001600160a01b031614610e415760405162461bcd60e51b81526004016105a7906135b8565b604080518082019091526002546001600160a01b0381168252600160a01b900460ff16151560208201819052610ec95760405162461bcd60e51b815260206004820152602760248201527f48617368666c6f77506f6f6c3a3a747261646558436861696e5246514d20446960448201526639b0b13632b21760c91b60648201526084016105a7565b6000610ed48361208c565b82516102008501519192506001600160a01b031690610ef4908390611d1d565b6001600160a01b031614610f5f5760405162461bcd60e51b815260206004820152602c60248201527f48617368666c6f77506f6f6c3a3a747261646558436861696e5246514d20496e60448201526b3b30b634b21039b4b3b732b960a11b60648201526084016105a7565b7f3f72b2a38919490277652bb34955c871b20e23068c243319c9fa5e27963d9e12836020015184606001518560c001518660e00151876101a001518861010001518961012001518a61014001518b6101600151604051610fc7999897969594939291906136b0565b60405180910390a1505050565b6004546001600160a01b0316336001600160a01b0316146110075760405162461bcd60e51b81526004016105a7906135b8565b60408051808201909152600280546001600160a01b03811680845293151560209093018390526001600160a81b031916909217600160a01b909102179055565b6004546001600160a01b0316336001600160a01b03161461107a5760405162461bcd60e51b81526004016105a7906135b8565b60808101516001600160a01b03161515806110a1575060208101516001600160a01b031615155b806110af57508060c0015134145b61112f5760405162461bcd60e51b815260206004820152604560248201527f48617368666c6f77506f6f6c3a3a747261646552465154206d73672e76616c7560448201527f65206d75737420657175616c2065666665637469766542617365546f6b656e416064820152641b5bdd5b9d60da1b608482015260a4016105a7565b600061113a8261215b565b604080518082019091526002546001600160a01b0381168252600160a01b900460ff16151560208201819052919250906111c05760405162461bcd60e51b815260206004820152602160248201527f48617368666c6f77506f6f6c3a3a7472616465524651542044697361626c65646044820152601760f91b60648201526084016105a7565b80600001516001600160a01b03166111e684610180015184611d1d90919063ffffffff16565b6001600160a01b03161461124c5760405162461bcd60e51b815260206004820152602760248201527f48617368666c6f77506f6f6c3a3a74726164655246515420496e76616c69642060448201526639b4b3b732b91760c91b60648201526084016105a7565b61125f83606001518461014001516121b0565b61010083015160e084015160c0850151101561129c578360e001518461010001518560c0015161128f9190613703565b611299919061371a565b90505b7f34f57786fb01682fb4eec88d340387ef01a168fe345ea5b76f709d4e560c10eb8460400151856060015186610160015187608001518860a001518960c00151876040516112f0979695949392919061360d565b60405180910390a160208401516001600160a01b03166113225761131d8460a00151856040015183611e3f565b610a57565b610a5784602001518560a00151866040015184611e74565b6004546001600160a01b0316336001600160a01b03161461136d5760405162461bcd60e51b81526004016105a7906135b8565b60808201516001600160a01b0316151580611394575060e08201516001600160a01b031615155b806113a3575081610120015134145b61140d5760405162461bcd60e51b815260206004820152603560248201527f48617368666c6f77506f6f6c3a3a747261646558436861696e52465154206d7360448201527419cb9d985b1d59481b5d5cdd080f48185b5bdd5b9d605a1b60648201526084016105a7565b604080518082019091526002546001600160a01b0381168252600160a01b900460ff161515602082018190526114955760405162461bcd60e51b815260206004820152602760248201527f48617368666c6f77506f6f6c3a3a747261646558436861696e5246515420446960448201526639b0b13632b21760c91b60648201526084016105a7565b6114a88360c00151846101a00151612245565b60006114b3846122cc565b82516102008601519192506001600160a01b0316906114d3908390611d1d565b6001600160a01b03161461153e5760405162461bcd60e51b815260206004820152602c60248201527f48617368666c6f77506f6f6c3a3a747261646558436861696e5246515420496e60448201526b3b30b634b21039b4b3b732b960a11b60648201526084016105a7565b610160840151610140850151610120860151101561157f578461014001518561012001518661016001516115729190613703565b61157c919061371a565b90505b7f3f72b2a38919490277652bb34955c871b20e23068c243319c9fa5e27963d9e1285602001518660600151868860c00151896101c001518a60e001518b61010001518c6101200151896040516115dd999897969594939291906136b0565b60405180910390a15050505050565b6003546001600160a01b0316336001600160a01b03161461161f5760405162461bcd60e51b81526004016105a79061355b565b604080518082019091526002546001600160a01b0381168252600160a01b900460ff161515602082018190526116a75760405162461bcd60e51b815260206004820152602760248201527f48617368666c6f77506f6f6c3a3a72656d6f76654c697175696469747920446960448201526639b0b13632b21760c91b60648201526084016105a7565b6000821161170c5760405162461bcd60e51b815260206004820152602c60248201527f48617368666c6f77506f6f6c3a3a72656d6f76654c697175696469747920496e60448201526b1d985b1a5908185b5bdd5b9d60a21b60648201526084016105a7565b60006001600160a01b038416156117b2576001600160a01b03841660009081526007602052604090205460ff166117ab5760405162461bcd60e51b815260206004820152603f60248201527f48617368666c6f77506f6f6c3a3a72656d6f76654c697175696469747920526560448201527f63697069656e74206d7573742062652068656467696e67206163636f756e740060648201526084016105a7565b50826117b5565b50335b604080516001600160a01b038088168252831660208201529081018490527fd8ae9b9ba89e637bcb66a69ac91e8f688018e81d6f92c57e02226425c8efbdf69060600160405180910390a1610b92858285611e3f565b6003546001600160a01b0316336001600160a01b03161461183e5760405162461bcd60e51b81526004016105a79061355b565b6105c46001600160a01b0384168383612412565b600054610100900460ff16158080156118725750600054600160ff909116105b8061188c5750303b15801561188c575060005460ff166001145b6118ef5760405162461bcd60e51b815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201526d191e481a5b9a5d1a585b1a5e995960921b60648201526084016105a7565b6000805460ff191660011790558015611912576000805461ff0019166101001790555b6001600160a01b0384166119855760405162461bcd60e51b815260206004820152603460248201527f48617368666c6f77506f6f6c3a3a696e697469616c697a65205369676e65722060448201527331b0b73737ba10313290181030b2323932b9b99760611b60648201526084016105a7565b6001600160a01b038316611a015760405162461bcd60e51b815260206004820152603860248201527f48617368666c6f77506f6f6c3a3a696e697469616c697a65204f70657261746960448201527f6f6e732063616e6e6f74206265203020616464726573732e000000000000000060648201526084016105a7565b6001600160a01b038216611a745760405162461bcd60e51b815260206004820152603460248201527f48617368666c6f77506f6f6c3a3a696e697469616c697a6520526f757465722060448201527331b0b73737ba10313290181030b2323932b9b99760611b60648201526084016105a7565b6000855111611adb5760405162461bcd60e51b815260206004820152602d60248201527f48617368666c6f77506f6f6c3a3a696e697469616c697a65204e616d6520636160448201526c6e6e6f7420626520656d70747960981b60648201526084016105a7565b6001611ae78682613782565b5060408051808201825260016020808301919091526001600160a01b038716808352835190815260009181019190915290917f72959271bae82854684905271432777342373a732ba892607d189cbf5049086f910160405180910390a18051600280546020909301511515600160a01b026001600160a81b03199093166001600160a01b039283161792909217909155600380548583166001600160a01b03199182161790915560048054928516929091169190911790558015610b92576000805461ff0019169055604051600181527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb3847402498906020016115dd565b604051636eb1769f60e11b81523060048201526001600160a01b0383811660248301526000919085169063dd62ed3e90604401602060405180830381865afa158015611c31573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611c559190613841565b905081811015611cb95760405162461bcd60e51b815260206004820152602960248201527f5361666545524332303a2064656372656173656420616c6c6f77616e63652062604482015268656c6f77207a65726f60b81b60648201526084016105a7565b6040516001600160a01b03841660248201528282036044820152610a5790859063095ea7b360e01b906064015b60408051601f198184030181529190526020810180516001600160e01b03166001600160e01b03199093169290921790915261249d565b6000806000611d2c8585612572565b91509150611d39816125b7565b509392505050565b8051602080830151604080850151606080870151608088015160a089015160c08a015160e08b01516101008c015197519a861b6001600160601b03199081169a8c019a909a5297851b891660348b015294841b881660488a015291831b8716605c89015290911b9094166070860152608485019390935260a484019290925260c483015260e482015246610104820152600090610124015b60408051601f198184030181529082905280516020918201207f19457468657265756d205369676e6564204d6573736167653a0a33320000000091830191909152603c820152605c01604051602081830303815290604052805190602001209050919050565b6001600160a01b038316611e60576105c46001600160a01b03831682612704565b6105c46001600160a01b038416838361281d565b6001600160a01b038316611f4557611eb76001600160a01b037f000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc21685308461284d565b604051632e1a7d4d60e01b8152600481018290527f000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc26001600160a01b031690632e1a7d4d90602401600060405180830381600087803b158015611f1957600080fd5b505af1158015611f2d573d6000803e3d6000fd5b5061131d925050506001600160a01b03831682612704565b610a576001600160a01b03841685848461284d565b60006001600160a01b03821615611fd8576040516370a0823160e01b81523060048201526001600160a01b038316906370a0823190602401602060405180830381865afa158015611faf573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611fd39190613841565b6105fa565b4792915050565b604051636eb1769f60e11b81523060048201526001600160a01b0383811660248301526000919085169063dd62ed3e90604401602060405180830381865afa15801561202f573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906120539190613841565b9050610a578463095ea7b360e01b8561206c868661385a565b6040516001600160a01b0390921660248301526044820152606401611ce6565b80516020808301516040808501516060860151608087015160a088015193516000976120bc97909695910161386d565b60408051601f19818403018152828252805160209182012060c08601516101008701516101208801516101408901516101608a01516101808b01516101a08c01516101c08d0151988b01979097526001600160601b0319606096871b8116998b019990995293851b881660548a01526068890192909252608888015260a887015260c886015260e88501919091521b1661010882015261011c01611dd9565b60003082604001518360600151846020015185608001518660a001518760e001518861010001518961014001518a61012001518b610160015146604051602001611dd99c9b9a999897969594939291906138bc565b6001600160a01b03821660009081526005602052604090205481116122295760405162461bcd60e51b815260206004820152602960248201527f48617368666c6f77506f6f6c3a3a5f7570646174654e6f6e636520496e76616c60448201526834b2103737b731b29760b91b60648201526084016105a7565b6001600160a01b03909116600090815260056020526040902055565b60008281526006602052604090205481116122ba5760405162461bcd60e51b815260206004820152602f60248201527f48617368666c6f77506f6f6c3a3a5f7570646174654e6f6e636558436861696e60448201526e1024b73b30b634b2103737b731b29760891b60648201526084016105a7565b60009182526006602052604090912055565b600080826000015183602001518460400151856060015186608001518760a001516040516020016123029695949392919061386d565b60408051808303601f19018152828252805160209182012060c087015160e08801516101008901516101408a01516101608b01516101808c01516101a08d01516101c08e01516101e08f01518a8d01999099528b8b0197909752606095861b6001600160601b0319908116878d015260748c019590955260948b019390935260b48a019190915260d489015260f48801526101148701929092529190911b166101348401528151610128818503018152610148840190925281519101207f19457468657265756d205369676e6564204d6573736167653a0a333200000000610168830152610184820181905291506101a40160405160208183030381529060405280519060200120915050919050565b604080516001600160a01b038416602482015260448082018490528251808303909101815260649091019091526020810180516001600160e01b031663095ea7b360e01b1790526124638482612885565b610a57576040516001600160a01b03841660248201526000604482015261249790859063095ea7b360e01b90606401611ce6565b610a5784825b60006124f2826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b031661292c9092919063ffffffff16565b90508051600014806125135750808060200190518101906125139190613947565b6105c45760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b60648201526084016105a7565b60008082516041036125a85760208301516040840151606085015160001a61259c87828585612943565b945094505050506125b0565b506000905060025b9250929050565b60008160048111156125cb576125cb613964565b036125d35750565b60018160048111156125e7576125e7613964565b036126345760405162461bcd60e51b815260206004820152601860248201527f45434453413a20696e76616c6964207369676e6174757265000000000000000060448201526064016105a7565b600281600481111561264857612648613964565b036126955760405162461bcd60e51b815260206004820152601f60248201527f45434453413a20696e76616c6964207369676e6174757265206c656e6774680060448201526064016105a7565b60038160048111156126a9576126a9613964565b036127015760405162461bcd60e51b815260206004820152602260248201527f45434453413a20696e76616c6964207369676e6174757265202773272076616c604482015261756560f01b60648201526084016105a7565b50565b804710156127545760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a20696e73756666696369656e742062616c616e636500000060448201526064016105a7565b6000826001600160a01b03168260405160006040518083038185875af1925050503d80600081146127a1576040519150601f19603f3d011682016040523d82523d6000602084013e6127a6565b606091505b50509050806105c45760405162461bcd60e51b815260206004820152603a60248201527f416464726573733a20756e61626c6520746f2073656e642076616c75652c207260448201527f6563697069656e74206d6179206861766520726576657274656400000000000060648201526084016105a7565b6040516001600160a01b0383166024820152604481018290526105c490849063a9059cbb60e01b90606401611ce6565b6040516001600160a01b0380851660248301528316604482015260648101829052610a579085906323b872dd60e01b90608401611ce6565b6000806000846001600160a01b0316846040516128a2919061397a565b6000604051808303816000865af19150503d80600081146128df576040519150601f19603f3d011682016040523d82523d6000602084013e6128e4565b606091505b509150915081801561290e57508051158061290e57508080602001905181019061290e9190613947565b801561292357506001600160a01b0385163b15155b95945050505050565b606061293b8484600085612a07565b949350505050565b6000807f7fffffffffffffffffffffffffffffff5d576e7357a4501ddfe92f46681b20a083111561297a57506000905060036129fe565b6040805160008082526020820180845289905260ff881692820192909252606081018690526080810185905260019060a0016020604051602081039080840390855afa1580156129ce573d6000803e3d6000fd5b5050604051601f1901519150506001600160a01b0381166129f7576000600192509250506129fe565b9150600090505b94509492505050565b606082471015612a685760405162461bcd60e51b815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f6044820152651c8818d85b1b60d21b60648201526084016105a7565b600080866001600160a01b03168587604051612a84919061397a565b60006040518083038185875af1925050503d8060008114612ac1576040519150601f19603f3d011682016040523d82523d6000602084013e612ac6565b606091505b5091509150612ad787838387612ae2565b979650505050505050565b60608315612b51578251600003612b4a576001600160a01b0385163b612b4a5760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e747261637400000060448201526064016105a7565b508161293b565b61293b8383815115612b665781518083602001fd5b8060405162461bcd60e51b81526004016105a79190612ba4565b60005b83811015612b9b578181015183820152602001612b83565b50506000910152565b6020815260008251806020840152612bc3816040850160208701612b80565b601f01601f19169190910160400192915050565b80356001600160a01b0381168114612bee57600080fd5b919050565b600080600060608486031215612c0857600080fd5b612c1184612bd7565b9250612c1f60208501612bd7565b9150604084013590509250925092565b634e487b7160e01b600052604160045260246000fd5b60405161016081016001600160401b0381118282101715612c6857612c68612c2f565b60405290565b60405161022081016001600160401b0381118282101715612c6857612c68612c2f565b6040516101a081016001600160401b0381118282101715612c6857612c68612c2f565b604051601f8201601f191681016001600160401b0381118282101715612cdc57612cdc612c2f565b604052919050565b60006001600160401b03831115612cfd57612cfd612c2f565b612d10601f8401601f1916602001612cb4565b9050828152838383011115612d2457600080fd5b828260208301376000602084830101529392505050565b600082601f830112612d4c57600080fd5b612d5b83833560208501612ce4565b9392505050565b60008060408385031215612d7557600080fd5b8235915060208301356001600160401b03811115612d9257600080fd5b612d9e85828601612d3b565b9150509250929050565b600060208284031215612dba57600080fd5b81356001600160401b0380821115612dd157600080fd5b908301906101608286031215612de657600080fd5b612dee612c45565b612df783612bd7565b8152612e0560208401612bd7565b6020820152612e1660408401612bd7565b6040820152612e2760608401612bd7565b6060820152612e3860808401612bd7565b608082015260a083013560a082015260c083013560c082015260e083013560e08201526101008084013581830152506101208084013583811115612e7b57600080fd5b612e8788828701612d3b565b8284015250506101408084013583811115612ea157600080fd5b612ead88828701612d3b565b918301919091525095945050505050565b801515811461270157600080fd5b8035612bee81612ebe565b60008060408385031215612eea57600080fd5b612ef383612bd7565b91506020830135612f0381612ebe565b809150509250929050565b600060208284031215612f2057600080fd5b612d5b82612bd7565b600080600060408486031215612f3e57600080fd5b83356001600160401b0380821115612f5557600080fd5b818601915086601f830112612f6957600080fd5b813581811115612f7857600080fd5b8760208260061b8501011115612f8d57600080fd5b60209283019550935050840135612fa381612ebe565b809150509250925092565b600060208284031215612fc057600080fd5b5035919050565b600080600080600060a08688031215612fdf57600080fd5b612fe886612bd7565b945060208601359350612ffd60408701612bd7565b925061300b60608701612bd7565b949793965091946080013592915050565b6000806040838503121561302f57600080fd5b82356001600160401b038082111561304657600080fd5b818501915085601f83011261305a57600080fd5b813560208282111561306e5761306e612c2f565b8160051b925061307f818401612cb4565b828152928401810192818101908985111561309957600080fd5b948201945b848610156130be576130af86612bd7565b8252948201949082019061309e565b96506130cd9050878201612ecc565b9450505050509250929050565b803561ffff81168114612bee57600080fd5b6000602082840312156130fe57600080fd5b81356001600160401b038082111561311557600080fd5b90830190610220828603121561312a57600080fd5b613132612c6e565b61313b836130da565b8152613149602084016130da565b602082015261315a60408401612bd7565b60408201526060830135606082015261317560808401612bd7565b608082015260a083013560a082015261319060c08401612bd7565b60c082015260e083013560e08201526101006131ad818501612bd7565b9082015261012083810135908201526101408084013590820152610160808401359082015261018080840135908201526101a080840135908201526101c06131f6818501612bd7565b908201526101e0838101358381111561320e57600080fd5b61321a88828701612d3b565b8284015250506102008084013583811115612ea157600080fd5b60006020828403121561324657600080fd5b8135612d5b81612ebe565b60006020828403121561326357600080fd5b81356001600160401b038082111561327a57600080fd5b908301906101a0828603121561328f57600080fd5b613297612c91565b6132a083612bd7565b81526132ae60208401612bd7565b60208201526132bf60408401612bd7565b60408201526132d060608401612bd7565b60608201526132e160808401612bd7565b60808201526132f260a08401612bd7565b60a082015260c0838101359082015260e0808401359082015261010080840135908201526101208084013590820152610140808401359082015261016080840135908201526101808084013583811115612ea157600080fd5b6000806040838503121561335e57600080fd5b82356001600160401b038082111561337557600080fd5b90840190610220828703121561338a57600080fd5b613392612c6e565b61339b836130da565b81526133a9602084016130da565b60208201526133ba60408401612bd7565b6040820152606083013560608201526133d560808401612bd7565b608082015260a083013560a082015260c083013560c08201526133fa60e08401612bd7565b60e0820152610100838101359082015261012080840135908201526101408084013590820152610160808401359082015261018080840135908201526101a080840135908201526101c080840135908201526101e061345a818501612bd7565b90820152610200838101358381111561347257600080fd5b61347e89828701612d3b565b82840152505080945050505061349660208401612bd7565b90509250929050565b600080600080608085870312156134b557600080fd5b84356001600160401b038111156134cb57600080fd5b8501601f810187136134dc57600080fd5b6134eb87823560208401612ce4565b9450506134fa60208601612bd7565b925061350860408601612bd7565b915061351660608601612bd7565b905092959194509250565b600181811c9082168061353557607f821691505b60208210810361355557634e487b7160e01b600052602260045260246000fd5b50919050565b6020808252603a908201527f48617368666c6f77506f6f6c3a617574686f72697a65644f7065726174696f6e60408201527f732053656e646572206d757374206265206f70657261746f722e000000000000606082015260800190565b60208082526035908201527f48617368666c6f77506f6f6c3a3a617574686f72697a6564526f75746572205360408201527432b73232b91036bab9ba103132902937baba32b91760591b606082015260800190565b6001600160a01b039788168152958716602087015260408601949094529185166060850152909316608083015260a082019290925260c081019190915260e00190565b634e487b7160e01b600052603260045260246000fd5b60006020828403121561367857600080fd5b612d5b826130da565b634e487b7160e01b600052601160045260246000fd5b6000600182016136a9576136a9613681565b5060010190565b61ffff99909916895260208901979097526001600160a01b0395861660408901526060880194909452608087019290925290921660a085015260c084019190915260e08301526101008201526101200190565b80820281158282048414176105fa576105fa613681565b60008261373757634e487b7160e01b600052601260045260246000fd5b500490565b601f8211156105c457600081815260208120601f850160051c810160208610156137635750805b601f850160051c820191505b818110156109135782815560010161376f565b81516001600160401b0381111561379b5761379b612c2f565b6137af816137a98454613521565b8461373c565b602080601f8311600181146137e457600084156137cc5750858301515b600019600386901b1c1916600185901b178555610913565b600085815260208120601f198616915b82811015613813578886015182559484019460019091019084016137f4565b50858210156138315787850151600019600388901b60f8161c191681555b5050505050600190811b01905550565b60006020828403121561385357600080fd5b5051919050565b808201808211156105fa576105fa613681565b6001600160f01b031960f097881b811682529590961b90941660028601526001600160601b0319606093841b81166004870152601886019290925290911b166038830152604c820152606c0190565b6001600160601b031960608e811b821683528d811b821660148401528c811b821660288401528b811b8216603c8401528a901b1660508201526000613910606483018a60601b6001600160601b0319169052565b506078810196909652609886019490945260b885019290925260d884015260f8830152610118820152610138019695505050505050565b60006020828403121561395957600080fd5b8151612d5b81612ebe565b634e487b7160e01b600052602160045260246000fd5b6000825161398c818460208701612b80565b919091019291505056fea2646970667358221220c26f589b7ebb50bc927555b865065439bc21d9afbe2f36c0fda198a7cf72c3dc64736f6c63430008120033
Constructor Arguments (ABI-Encoded and is the last bytes of the Contract Creation Code above)
000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2
-----Decoded View---------------
Arg [0] : weth (address): 0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2
-----Encoded View---------------
1 Constructor Arguments found :
Arg [0] : 000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2
Loading...
Loading
Loading...
Loading
Net Worth in USD
$0.00
Net Worth in ETH
0
Multichain Portfolio | 33 Chains
| Chain | Token | Portfolio % | Price | Amount | Value |
|---|
Loading...
Loading
Loading...
Loading
Loading...
Loading
A contract address hosts a smart contract, which is a set of code stored on the blockchain that runs when predetermined conditions are met. Learn more about addresses in our Knowledge Base.