Source Code
| Transaction Hash |
|
Block
|
From
|
To
|
|||||
|---|---|---|---|---|---|---|---|---|---|
Latest 1 internal transaction
Advanced mode:
| Parent Transaction Hash | Block | From | To | |||
|---|---|---|---|---|---|---|
| 24939459 | 147 days ago | Contract Creation | 0 FRAX |
Cross-Chain Transactions
Loading...
Loading
This contract may be a proxy contract. Click on More Options and select Is this a proxy? to confirm and enable the "Read as Proxy" & "Write as Proxy" tabs.
Contract Name:
GasLessFacet
Compiler Version
v0.8.19+commit.7dd6d404
Optimization Enabled:
Yes with 300 runs
Other Settings:
default evmVersion
Contract Source Code (Solidity Standard Json-Input format)
// SPDX-License-Identifier: MIT
pragma solidity 0.8.19;
import { LibAsset } from "../Libraries/LibAsset.sol";
import { LibPermit } from "../Libraries/LibPermit.sol";
import { LibValidator } from "../Libraries/LibValidator.sol";
import { LibBridge } from "../Libraries/LibBridge.sol";
import { PermitBatchTransferFrom } from "../Interfaces/IPermit2.sol";
import { IBridge } from "../Interfaces/IBridge.sol";
import { IGasLessFacet } from "../Interfaces/IGasLessFacet.sol";
import { Swapper } from "../Helpers/Swapper.sol";
import { RefundNative } from "../Helpers/RefundNative.sol";
import { Pausable } from "../Helpers/Pausable.sol";
import { ReentrancyGuard } from "../Helpers/ReentrancyGuard.sol";
import { SwapData, BridgeSwapData, SwapExecutionData, TokenInfo, InputToken, AdapterInfo } from "../Types.sol";
/**
* @title GasLessFacet
* @author DZap
* @dev This contract enables meta-transactions for swaps and bridges, allowing users to interact with DeFi
* protocols without holding native tokens for gas fees. Executors are compensated through fees.
*
* Key Features:
* - Gasless swaps (single and multi-token)
* - Gasless bridges (single and multi-token)
* - Support for Permit2 batch transfers
* - Intent-based execution with signature verification
* - Executor fee compensation mechanism
*/
contract GasLessFacet is IBridge, IGasLessFacet, Swapper, RefundNative, Pausable, ReentrancyGuard {
/* ========= STORAGE ========= */
string internal constant _SWAP_WITNESS_TYPE_STRING =
"DZapSwapWitness witness)DZapSwapWitness(bytes32 txId,address user,bytes32 executorFeesHash,bytes32 swapDataHash)TokenPermissions(address token,uint256 amount)";
string internal constant _BRIDGE_WITNESS_TYPE_STRING =
"DZapBridgeWitness witness)DZapBridgeWitness(bytes32 txId,address user,bytes32 executorFeesHash,bytes32 swapDataHash,bytes32 adapterDataHash)TokenPermissions(address token,uint256 amount)";
bytes32 internal constant _SWAP_WITNESS_TYPEHASH =
keccak256("DZapSwapWitness(bytes32 txId,address user,bytes32 executorFeesHash,bytes32 swapDataHash)");
bytes32 internal constant _BRIDGE_WITNESS_TYPEHASH =
keccak256("DZapBridgeWitness(bytes32 txId,address user,bytes32 executorFeesHash,bytes32 swapDataHash,bytes32 adapterDataHash)");
/* ========= EXTERNAL ========= */
/// @inheritdoc IGasLessFacet
function executeSwap(
bytes32 _transactionId,
address _user,
address _integrator,
uint256 _userIntentDeadline,
bytes calldata _userIntentSignature,
bytes calldata _tokenApprovalData,
TokenInfo calldata _executorFeeInfo,
SwapData calldata _swapData,
SwapExecutionData calldata _swapExecutionData
) external whenNotPaused nonReentrant {
LibValidator.handleGasLessSwapVerification(
_user,
_userIntentDeadline,
_transactionId,
keccak256(abi.encode(_executorFeeInfo)),
keccak256(abi.encode(_swapData)),
_userIntentSignature
);
LibAsset.deposit(_user, _swapData.from, _swapData.fromAmount + _executorFeeInfo.amount, _tokenApprovalData);
if (_executorFeeInfo.token != address(0)) LibAsset.transferERC20WithoutChecks(_executorFeeInfo.token, msg.sender, _executorFeeInfo.amount);
_executeSwap(_transactionId, _user, _integrator, _swapData, _swapExecutionData, false);
emit DZapGasLessStarted(_transactionId, msg.sender, _user);
}
/// @inheritdoc IGasLessFacet
function executeMultiSwap(
bytes32 _transactionId,
address _user,
address _integrator,
uint256 _userIntentDeadline,
bytes calldata _userIntentSignature,
InputToken[] calldata _inputTokens,
TokenInfo[] calldata _executorFeeInfo,
SwapData[] calldata _swapData,
SwapExecutionData[] calldata _swapExecutionData
) external whenNotPaused nonReentrant {
LibValidator.handleGasLessSwapVerification(
_user,
_userIntentDeadline,
_transactionId,
keccak256(abi.encode(_executorFeeInfo)),
keccak256(abi.encode(_swapData)),
_userIntentSignature
);
LibAsset.depositBatch(_user, _inputTokens);
_transferExecutorFees(_executorFeeInfo);
_executeSwaps(_transactionId, _user, _integrator, _swapData, _swapExecutionData, false);
emit DZapGasLessStarted(_transactionId, msg.sender, _user);
}
/// @inheritdoc IGasLessFacet
function executeMultiSwapWithWitness(
bytes32 _transactionId,
address _user,
address _integrator,
bytes calldata _userIntentSignature,
PermitBatchTransferFrom calldata _tokenDepositDetails,
TokenInfo[] calldata _executorFeeInfo,
SwapData[] calldata _swapData,
SwapExecutionData[] calldata _swapExecutionData
) external whenNotPaused nonReentrant {
bytes32 witness = _createSwapWitnessHash(_transactionId, _user, _executorFeeInfo, _swapData);
LibPermit.permit2BatchWitnessTransferFrom(
_user,
address(this),
witness,
_tokenDepositDetails,
_userIntentSignature,
_SWAP_WITNESS_TYPE_STRING
);
_transferExecutorFees(_executorFeeInfo);
_executeSwaps(_transactionId, _user, _integrator, _swapData, _swapExecutionData, false);
emit DZapGasLessStarted(_transactionId, msg.sender, _user);
}
/// @inheritdoc IGasLessFacet
function executeBridge(
bytes32 _transactionId,
bytes calldata _bridgeFeeData,
bytes calldata _userIntentSignature,
bytes calldata _feeVerificationSignature,
uint256 _userIntentDeadline,
uint256 _bridgeFeeDeadline,
address _user,
InputToken calldata _inputToken,
TokenInfo calldata _executorFeeInfo,
AdapterInfo calldata _adapterInfo
) external payable refundExcessNative(msg.sender) whenNotPaused nonReentrant {
bytes32 adapterInfoHash = keccak256(abi.encode(_adapterInfo));
LibValidator.handleGasLessBridgeVerification(
_user,
_userIntentDeadline,
_transactionId,
keccak256(abi.encode(_executorFeeInfo)),
adapterInfoHash,
_userIntentSignature
);
LibValidator.handleFeeVerification(
_user,
_bridgeFeeDeadline,
_transactionId,
keccak256(_bridgeFeeData),
adapterInfoHash,
_feeVerificationSignature
);
LibAsset.deposit(_user, _inputToken.token, _inputToken.amount, _inputToken.permit);
if (_executorFeeInfo.token != address(0)) LibAsset.transferERC20WithoutChecks(_executorFeeInfo.token, msg.sender, _executorFeeInfo.amount);
address integrator = LibBridge.takeFee(_bridgeFeeData);
LibBridge.bridge(_adapterInfo);
emit DZapBridgeStarted(_transactionId, _user, integrator);
emit DZapGasLessStarted(_transactionId, msg.sender, _user);
}
/// @inheritdoc IGasLessFacet
function executeMultiBridge(
bytes32 _transactionId,
bytes calldata _bridgeFeeData,
bytes calldata _userIntentSignature,
bytes calldata _feeVerificationSignature,
uint256 _userIntentDeadline,
uint256 _bridgeFeeDeadline,
address _user,
InputToken[] calldata _inputTokens,
TokenInfo[] calldata _executorFeeInfo,
BridgeSwapData[] calldata _swapData,
SwapExecutionData[] calldata _swapExecutionData,
AdapterInfo[] calldata _adapterInfo
) external payable refundExcessNative(msg.sender) whenNotPaused nonReentrant {
bytes32 adapterInfoHash = keccak256(abi.encode(_adapterInfo));
LibValidator.handleGasLessSwapBridgeVerification(
_user,
_userIntentDeadline,
_transactionId,
keccak256(abi.encode(_executorFeeInfo)),
keccak256(abi.encode(_swapData)),
adapterInfoHash,
_userIntentSignature
);
LibValidator.handleFeeVerification(
_user,
_bridgeFeeDeadline,
_transactionId,
keccak256(_bridgeFeeData),
adapterInfoHash,
_feeVerificationSignature
);
LibAsset.depositBatch(_user, _inputTokens);
_transferExecutorFees(_executorFeeInfo);
address integrator = LibBridge.takeFee(_bridgeFeeData);
_executeBridgeSwaps(_transactionId, _user, integrator, _swapData, _swapExecutionData, false);
LibBridge.bridge(_adapterInfo);
emit DZapBridgeStarted(_transactionId, _user, integrator);
emit DZapGasLessStarted(_transactionId, msg.sender, _user);
}
/// @inheritdoc IGasLessFacet
function executeMultiBridgeWithWitness(
bytes32 _transactionId,
bytes calldata _bridgeFeeData,
bytes calldata _userIntentSignature,
bytes calldata _feeVerificationSignature,
uint256 _bridgeFeeDeadline,
address _user,
PermitBatchTransferFrom calldata _tokenDepositDetails,
TokenInfo[] calldata _executorFeeInfo,
BridgeSwapData[] calldata _swapData,
SwapExecutionData[] calldata _swapExecutionData,
AdapterInfo[] calldata _adapterInfo
) external payable refundExcessNative(msg.sender) whenNotPaused nonReentrant {
bytes32 adapterInfoHash = keccak256(abi.encode(_adapterInfo));
bytes32 witness = _createBridgeWitnessHash(_user, _transactionId, _executorFeeInfo, _swapData, adapterInfoHash);
LibPermit.permit2BatchWitnessTransferFrom(
_user,
address(this),
witness,
_tokenDepositDetails,
_userIntentSignature,
_BRIDGE_WITNESS_TYPE_STRING
);
address integrator = LibBridge.verifyAndTakeFee(
_user,
_bridgeFeeDeadline,
_transactionId,
adapterInfoHash,
_bridgeFeeData,
_feeVerificationSignature
);
_transferExecutorFees(_executorFeeInfo);
_executeBridgeSwaps(_transactionId, _user, integrator, _swapData, _swapExecutionData, false);
LibBridge.bridge(_adapterInfo);
emit DZapBridgeStarted(_transactionId, _user, integrator);
emit DZapGasLessStarted(_transactionId, msg.sender, _user);
}
/* ========= INTERNAL ========= */
function _transferExecutorFees(TokenInfo[] calldata _executorFeeInfo) internal {
for (uint256 i = 0; i < _executorFeeInfo.length; ) {
LibAsset.transferERC20WithoutChecks(_executorFeeInfo[i].token, msg.sender, _executorFeeInfo[i].amount);
unchecked {
++i;
}
}
}
function _createSwapWitnessHash(
bytes32 _transactionId,
address _user,
TokenInfo[] calldata _executorFeeInfo,
SwapData[] calldata _swapData
) internal pure returns (bytes32) {
return
keccak256(
abi.encode(_SWAP_WITNESS_TYPEHASH, _transactionId, _user, keccak256(abi.encode(_executorFeeInfo)), keccak256(abi.encode(_swapData)))
);
}
function _createBridgeWitnessHash(
address _user,
bytes32 _transactionIdHash,
TokenInfo[] calldata _executorFeeInfo,
BridgeSwapData[] calldata _swapData,
bytes32 _adapterInfoHash
) internal pure returns (bytes32) {
return
keccak256(
abi.encode(
_BRIDGE_WITNESS_TYPEHASH,
_transactionIdHash,
_user,
keccak256(abi.encode(_executorFeeInfo)),
keccak256(abi.encode(_swapData)),
_adapterInfoHash
)
);
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.4) (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.
*
* ==== Security Considerations
*
* There are two important considerations concerning the use of `permit`. The first is that a valid permit signature
* expresses an allowance, and it should not be assumed to convey additional meaning. In particular, it should not be
* considered as an intention to spend the allowance in any specific way. The second is that because permits have
* built-in replay protection and can be submitted by anyone, they can be frontrun. A protocol that uses permits should
* take this into consideration and allow a `permit` call to fail. Combining these two aspects, a pattern that may be
* generally recommended is:
*
* ```solidity
* function doThingWithPermit(..., uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s) public {
* try token.permit(msg.sender, address(this), value, deadline, v, r, s) {} catch {}
* doThing(..., value);
* }
*
* function doThing(..., uint256 value) public {
* token.safeTransferFrom(msg.sender, address(this), value);
* ...
* }
* ```
*
* Observe that: 1) `msg.sender` is used as the owner, leaving no ambiguity as to the signer intent, and 2) the use of
* `try/catch` allows the permit to fail and makes the code tolerant to frontrunning. (See also
* {SafeERC20-safeTransferFrom}).
*
* Additionally, note that smart contract wallets (such as Argent or Safe) are not able to produce permit signatures, so
* contracts should have entry points that don't rely on permit.
*/
interface IERC20Permit {
/**
* @dev Sets `value` as the allowance of `spender` over ``owner``'s tokens,
* given ``owner``'s signed approval.
*
* IMPORTANT: The same issues {IERC20-approve} has related to transaction
* ordering also apply here.
*
* Emits an {Approval} event.
*
* Requirements:
*
* - `spender` cannot be the zero address.
* - `deadline` must be a timestamp in the future.
* - `v`, `r` and `s` must be a valid `secp256k1` signature from `owner`
* over the EIP712-formatted function arguments.
* - the signature must use ``owner``'s current nonce (see {nonces}).
*
* For more information on the signature format, see the
* https://eips.ethereum.org/EIPS/eip-2612#specification[relevant EIP
* section].
*
* CAUTION: See Security Considerations above.
*/
function permit(
address owner,
address spender,
uint256 value,
uint256 deadline,
uint8 v,
bytes32 r,
bytes32 s
) external;
/**
* @dev Returns the current nonce for `owner`. This value must be
* included whenever a signature is generated for {permit}.
*
* Every successful call to {permit} increases ``owner``'s nonce by one. This
* prevents a signature from being used multiple times.
*/
function nonces(address owner) external view returns (uint256);
/**
* @dev Returns the domain separator used in the encoding of the signature for {permit}, as defined by {EIP712}.
*/
// solhint-disable-next-line func-name-mixedcase
function DOMAIN_SEPARATOR() external view returns (bytes32);
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated 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.3) (token/ERC20/utils/SafeERC20.sol)
pragma solidity ^0.8.0;
import "../IERC20.sol";
import "../extensions/IERC20Permit.sol";
import "../../../utils/Address.sol";
/**
* @title SafeERC20
* @dev Wrappers around ERC20 operations that throw on failure (when the token
* contract returns false). Tokens that return no value (and instead revert or
* throw on failure) are also supported, non-reverting calls are assumed to be
* successful.
* To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract,
* which allows you to call the safe operations as `token.safeTransfer(...)`, etc.
*/
library SafeERC20 {
using Address for address;
/**
* @dev Transfer `value` amount of `token` from the calling contract to `to`. If `token` returns no value,
* non-reverting calls are assumed to be successful.
*/
function safeTransfer(IERC20 token, address to, uint256 value) internal {
_callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value));
}
/**
* @dev Transfer `value` amount of `token` from `from` to `to`, spending the approval given by `from` to the
* calling contract. If `token` returns no value, non-reverting calls are assumed to be successful.
*/
function safeTransferFrom(IERC20 token, address from, address to, uint256 value) internal {
_callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value));
}
/**
* @dev Deprecated. This function has issues similar to the ones found in
* {IERC20-approve}, and its usage is discouraged.
*
* Whenever possible, use {safeIncreaseAllowance} and
* {safeDecreaseAllowance} instead.
*/
function safeApprove(IERC20 token, address spender, uint256 value) internal {
// safeApprove should only be called when setting an initial allowance,
// or when resetting it to zero. To increase and decrease it, use
// 'safeIncreaseAllowance' and 'safeDecreaseAllowance'
require(
(value == 0) || (token.allowance(address(this), spender) == 0),
"SafeERC20: approve from non-zero to non-zero allowance"
);
_callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value));
}
/**
* @dev Increase the calling contract's allowance toward `spender` by `value`. If `token` returns no value,
* non-reverting calls are assumed to be successful.
*/
function safeIncreaseAllowance(IERC20 token, address spender, uint256 value) internal {
uint256 oldAllowance = token.allowance(address(this), spender);
_callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, oldAllowance + value));
}
/**
* @dev Decrease the calling contract's allowance toward `spender` by `value`. If `token` returns no value,
* non-reverting calls are assumed to be successful.
*/
function safeDecreaseAllowance(IERC20 token, address spender, uint256 value) internal {
unchecked {
uint256 oldAllowance = token.allowance(address(this), spender);
require(oldAllowance >= value, "SafeERC20: decreased allowance below zero");
_callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, oldAllowance - value));
}
}
/**
* @dev Set the calling contract's allowance toward `spender` to `value`. If `token` returns no value,
* non-reverting calls are assumed to be successful. Meant to be used with tokens that require the approval
* to be set to zero before setting it to a non-zero value, such as USDT.
*/
function forceApprove(IERC20 token, address spender, uint256 value) internal {
bytes memory approvalCall = abi.encodeWithSelector(token.approve.selector, spender, value);
if (!_callOptionalReturnBool(token, approvalCall)) {
_callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, 0));
_callOptionalReturn(token, approvalCall);
}
}
/**
* @dev Use a ERC-2612 signature to set the `owner` approval toward `spender` on `token`.
* Revert on invalid signature.
*/
function safePermit(
IERC20Permit token,
address owner,
address spender,
uint256 value,
uint256 deadline,
uint8 v,
bytes32 r,
bytes32 s
) internal {
uint256 nonceBefore = token.nonces(owner);
token.permit(owner, spender, value, deadline, v, r, s);
uint256 nonceAfter = token.nonces(owner);
require(nonceAfter == nonceBefore + 1, "SafeERC20: permit did not succeed");
}
/**
* @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement
* on the return value: the return value is optional (but if data is returned, it must not be false).
* @param token The token targeted by the call.
* @param data The call data (encoded using abi.encode or one of its variants).
*/
function _callOptionalReturn(IERC20 token, bytes memory data) private {
// We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since
// we're implementing it ourselves. We use {Address-functionCall} to perform this call, which verifies that
// the target address contains contract code and also asserts for success in the low-level call.
bytes memory returndata = address(token).functionCall(data, "SafeERC20: low-level call failed");
require(returndata.length == 0 || abi.decode(returndata, (bool)), "SafeERC20: ERC20 operation did not succeed");
}
/**
* @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement
* on the return value: the return value is optional (but if data is returned, it must not be false).
* @param token The token targeted by the call.
* @param data The call data (encoded using abi.encode or one of its variants).
*
* This is a variant of {_callOptionalReturn} that silents catches all reverts and returns a bool instead.
*/
function _callOptionalReturnBool(IERC20 token, bytes memory data) private returns (bool) {
// We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since
// we're implementing it ourselves. We cannot use {Address-functionCall} here since this should return false
// and not revert is the subcall reverts.
(bool success, bytes memory returndata) = address(token).call(data);
return
success && (returndata.length == 0 || abi.decode(returndata, (bool))) && Address.isContract(address(token));
}
}// 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 (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: MIT pragma solidity 0.8.19; // DZap Common Errors error OnlyContractOwner(); error UnauthorizedCaller(); error UnAuthorized(); error CannotAuthorizeSelf(); error AlreadyInitialized(); error InsufficientBalance(uint256 amount, uint256 contractBalance); error SlippageTooHigh(uint256 minAmount, uint256 returnAmount); error AmountExceedsMaximum(); error TransferAmountMismatch(); error NoBridgeFromZeroAmount(); error NoSwapFromZeroAmount(); error ZeroAddress(); error NoTransferToNullAddress(); error NullAddrIsNotAValidSpender(); error NullAddrIsNotAValidRecipient(); error NativeTokenNotSupported(); error InvalidEncodedAddress(); error NotAContract(); error BridgeNotWhitelisted(address bridge); error AdapterNotWhitelisted(address adapter); error DexNotWhitelisted(address dex); error InvalidPermitType(); error CannotBridgeToSameNetwork(); error SwapCallFailed(address target, bytes4 funSig, bytes reason); error BridgeCallFailed(address target, bytes4 funSig, bytes reason); error AdapterCallFailed(address adapter, bytes res); error NativeCallFailed(bytes reason); error Erc20CallFailed(bytes reason); error NativeTransferFailed();
// SPDX-License-Identifier: MIT
pragma solidity 0.8.19;
import { LibGlobalStorage } from "../Libraries/LibGlobalStorage.sol";
/**
* @title Pausable
* @author DZap
* @notice Abstract contract that restricts function execution based on a global pause state.
* @dev Intended for use with a global storage library (LibGlobalStorage) that manages the pause flag.
*/
abstract contract Pausable {
/* ========= Errors ========= */
error ContractIsPaused();
error ContractIsNotPaused();
/* ========= Modifiers ========= */
modifier whenNotPaused() {
if (LibGlobalStorage.getPaused()) revert ContractIsPaused();
_;
}
modifier whenPaused() {
if (!LibGlobalStorage.getPaused()) revert ContractIsNotPaused();
_;
}
}// SPDX-License-Identifier: MIT
pragma solidity 0.8.19;
/**
* @title ReentrancyGuard
* @author DZap
* @notice Abstract contract to provide protection against reentrancy
*/
abstract contract ReentrancyGuard {
/* ========= Storage ========= */
bytes32 private constant NAMESPACE = keccak256("dzap.reentrancyguard");
/* ========= Types ========= */
struct ReentrancyStorage {
uint256 status;
}
/* ========= Errors ========= */
error ReentrancyError();
/* ========= Constants ========= */
uint256 private constant _NOT_ENTERED = 1;
uint256 private constant _ENTERED = 2;
/* ========= Modifiers ========= */
modifier nonReentrant() {
ReentrancyStorage storage s = reentrancyStorage();
if (s.status == _ENTERED) revert ReentrancyError();
s.status = _ENTERED;
_;
s.status = _NOT_ENTERED;
}
/* ========= Private Methods ========= */
/// @dev fetch local storage
function reentrancyStorage() private pure returns (ReentrancyStorage storage data) {
bytes32 position = NAMESPACE;
// solhint-disable-next-line no-inline-assembly
assembly {
data.slot := position
}
}
}// SPDX-License-Identifier: MIT
pragma solidity 0.8.19;
import { LibAsset } from "../Libraries/LibAsset.sol";
/**
* @title RefundNative
* @author DZap
* @notice Abstract contract to provide functionality to refund native tokens
*/
abstract contract RefundNative {
/// @dev Refunds any excess native asset sent to the contract after the main function
/// @notice Refunds any excess native asset sent to the contract after the main function
/// @param _refundee Address to send refunds to
modifier refundExcessNative(address _refundee) {
uint256 initialBalance = address(this).balance - msg.value;
_;
uint256 finalBalance = address(this).balance;
if (finalBalance > initialBalance) LibAsset.transferNativeToken(_refundee, finalBalance - initialBalance);
}
}// SPDX-License-Identifier: MIT
pragma solidity 0.8.19;
import { LibAllowList } from "../Libraries/LibAllowList.sol";
import { LibAsset } from "../Libraries/LibAsset.sol";
import { LibSwap } from "../Libraries/LibSwap.sol";
import { SwapData, SwapExecutionData, SwapInfo, BridgeSwapData } from "../Types.sol";
import { DexNotWhitelisted, NullAddrIsNotAValidRecipient, NoSwapFromZeroAmount } from "../Errors.sol";
/**
* @title Swapper
* @author DZap
* @notice Abstract contract to provide swap functionality
*/
abstract contract Swapper {
/* ========= EVENTS ========= */
event DZapTokenSwapped(bytes32 indexed transactionId, address indexed sender, address indexed integrator, SwapInfo swapInfo);
event DZapBatchTokenSwapped(bytes32 indexed transactionId, address indexed sender, address indexed integrator, SwapInfo[] swapInfo);
/* ========= INTERNAL ========= */
/// @notice Validates the swap data
function _validateSwapData(address _recipient, uint256 _fromAmount, SwapExecutionData memory _swapExecutionData) internal view {
if (!LibAllowList.isDexWhitelisted(_swapExecutionData.callTo)) revert DexNotWhitelisted(_swapExecutionData.callTo);
if (_recipient == address(0)) revert NullAddrIsNotAValidRecipient();
if (_fromAmount == 0) revert NoSwapFromZeroAmount();
}
/// @notice Executes a swap
function _executeSwap(
bytes32 _transactionId,
address _user,
address _integrator,
SwapData memory _swapData,
SwapExecutionData memory _swapExecutionData,
bool _withoutRevert
) internal {
_validateSwapData(_swapData.recipient, _swapData.fromAmount, _swapExecutionData);
uint256 returnToAmount = LibSwap.swap(
_user,
_swapData.recipient,
_swapData.from,
_swapData.to,
_swapData.fromAmount,
_swapData.minToAmount,
_swapExecutionData,
_withoutRevert
);
emit DZapTokenSwapped(
_transactionId,
_user,
_integrator,
SwapInfo(
_swapExecutionData.dex,
_swapExecutionData.callTo,
_swapData.recipient,
_swapData.from,
_swapData.to,
_swapData.fromAmount,
returnToAmount
)
);
}
/// @notice Executes multiple swaps
function _executeSwaps(
bytes32 _transactionId,
address _user,
address _integrator,
SwapData[] memory _swapData,
SwapExecutionData[] memory _swapExecutionData,
bool _withoutRevert
) internal {
uint256 length = _swapData.length;
uint256 i;
SwapInfo[] memory swapInfo = new SwapInfo[](length);
uint256 returnToAmount;
for (i; i < length; ) {
SwapData memory swapData = _swapData[i];
SwapExecutionData memory swapExecutionData = _swapExecutionData[i];
_validateSwapData(swapData.recipient, swapData.fromAmount, swapExecutionData);
returnToAmount = LibSwap.swap(
_user,
swapData.recipient,
swapData.from,
swapData.to,
swapData.fromAmount,
swapData.minToAmount,
swapExecutionData,
_withoutRevert
);
swapInfo[i] = SwapInfo(
swapExecutionData.dex,
swapExecutionData.callTo,
swapData.recipient,
swapData.from,
swapData.to,
swapData.fromAmount,
returnToAmount
);
unchecked {
++i;
}
}
if (length > 0) emit DZapBatchTokenSwapped(_transactionId, _user, _integrator, swapInfo);
}
/// @notice Executes a bridge swap
/// @dev Sweep dust if full return amount is not going to be used in bridge
function _executeBridgeSwap(
bytes32 _transactionId,
address _user,
address _integrator,
BridgeSwapData memory _swapData,
SwapExecutionData memory _swapExecutionData,
bool _withoutRevert
) internal {
_validateSwapData(_swapData.recipient, _swapData.fromAmount, _swapExecutionData);
uint256 returnToAmount = LibSwap.swap(
_user,
_swapData.recipient,
_swapData.from,
_swapData.to,
_swapData.fromAmount,
_swapData.minToAmount,
_swapExecutionData,
_withoutRevert
);
// sweep dust
if (_swapData.recipient == address(this) && !_swapData.updateBridgeInAmount) {
LibAsset.transferToken(_swapData.to, _user, returnToAmount - _swapData.minToAmount);
}
emit DZapTokenSwapped(
_transactionId,
_user,
_integrator,
SwapInfo(
_swapExecutionData.dex,
_swapExecutionData.callTo,
_swapData.recipient,
_swapData.from,
_swapData.to,
_swapData.fromAmount,
returnToAmount
)
);
}
/// @notice Executes multiple bridge swaps
/// @dev Sweep dust if full return amount is not going to be used in bridge
function _executeBridgeSwaps(
bytes32 _transactionId,
address _user,
address _integrator,
BridgeSwapData[] memory _swapData,
SwapExecutionData[] memory _swapExecutionData,
bool _withoutRevert
) internal {
uint256 length = _swapData.length;
uint256 i;
SwapInfo[] memory swapInfo = new SwapInfo[](length);
uint256 returnToAmount;
for (i; i < length; ) {
BridgeSwapData memory swapData = _swapData[i];
SwapExecutionData memory swapExecutionData = _swapExecutionData[i];
_validateSwapData(swapData.recipient, swapData.fromAmount, swapExecutionData);
returnToAmount = LibSwap.swap(
_user,
swapData.recipient,
swapData.from,
swapData.to,
swapData.fromAmount,
swapData.minToAmount,
swapExecutionData,
_withoutRevert
);
if (swapData.recipient == address(this) && !swapData.updateBridgeInAmount) {
LibAsset.transferToken(swapData.to, _user, returnToAmount - swapData.minToAmount);
}
swapInfo[i] = SwapInfo(
swapExecutionData.dex,
swapExecutionData.callTo,
swapData.recipient,
swapData.from,
swapData.to,
swapData.fromAmount,
returnToAmount
);
unchecked {
++i;
}
}
if (length > 0) emit DZapBatchTokenSwapped(_transactionId, _user, _integrator, swapInfo);
}
}// SPDX-License-Identifier: MIT
pragma solidity 0.8.19;
/**
* @title IBridge
* @author DZap
*/
interface IBridge {
/* ========= EVENTS ========= */
event DZapBridgeStarted(bytes32 indexed transactionId, address indexed user, address indexed integrator);
event BridgeStarted(
bytes32 indexed transactionId,
address indexed user,
bytes receiver,
string bridge,
address bridgeAddress,
address from,
bytes to,
uint256 amount,
uint256 destinationChainId,
bytes destinationCalldata
);
}// SPDX-License-Identifier: MIT
pragma solidity 0.8.19;
import { PermitBatchTransferFrom } from "./IPermit2.sol";
import { SwapData, BridgeSwapData, SwapExecutionData, TokenInfo, InputToken, AdapterInfo } from "../Types.sol";
/**
* @title IGasLessFacet
* @author DZap
*/
interface IGasLessFacet {
/* ========= EVENTS ========= */
event DZapGasLessStarted(bytes32 indexed _transactionId, address indexed executor, address indexed _user);
/* ========= EXTERNAL ========= */
/**
* @notice Executes a gasless token swap on behalf of a user
* @dev The executor pays gas fees and receives compensation through _executorFeeInfo.
* User must have signed an intent with the specified parameters and deadline.
*
* @param _transactionId Unique identifier to prevent replay attacks
* @param _user Address of the user initiating the swap
* @param _integrator Address of the integrator for fee sharing
* @param _userIntentDeadline Timestamp after which the user's intent expires
* @param _userIntentSignature User's signature authorizing the transaction
* @param _tokenApprovalData Encoded approval data for token transfers (simple approval, eip2612 permit, permit2 transferFrom)
* @param _executorFeeInfo Token and amount for executor compensation
* @param _swapData Configuration for the token swap (recipient, tokens, amounts, slippage)
* @param _swapExecutionData Low-level execution data (target contract, calldata)
*/
function executeSwap(
bytes32 _transactionId,
address _user,
address _integrator,
uint256 _userIntentDeadline,
bytes calldata _userIntentSignature,
bytes calldata _tokenApprovalData,
TokenInfo calldata _executorFeeInfo,
SwapData calldata _swapData,
SwapExecutionData calldata _swapExecutionData
) external;
/**
* @notice Executes multiple gasless token swaps in a single transaction
* @dev Enables complex multi-hop swaps or parallel swaps across different tokens.
* More gas-efficient than multiple single swaps and provides atomic execution.
*
* @param _transactionId Unique identifier to prevent replay attacks
* @param _user Address of the user initiating the swaps
* @param _integrator Address of the integrator for fee sharing
* @param _userIntentDeadline Timestamp after which the user's intent expires
* @param _userIntentSignature User's signature authorizing all swaps
* @param _inputTokens Array of input tokens with amounts and permissions
* @param _executorFeeInfo Array of executor fee tokens and amounts
* @param _swapData Array of swap configurations for each token pair
* @param _swapExecutionData Array of execution data for each swap
*/
function executeMultiSwap(
bytes32 _transactionId,
address _user,
address _integrator,
uint256 _userIntentDeadline,
bytes calldata _userIntentSignature,
InputToken[] calldata _inputTokens,
TokenInfo[] calldata _executorFeeInfo,
SwapData[] calldata _swapData,
SwapExecutionData[] calldata _swapExecutionData
) external;
/**
* @notice Executes multiple gasless swaps using Permit2 batch witness transfers
* @dev Uses Permit2 for gas-efficient batch token transfers with witness data.
* Eliminates need for separate token approvals by including signature-based permits.
*
* @param _transactionId Unique identifier to prevent replay attacks
* @param _user Address of the user initiating the swaps
* @param _integrator Address of the integrator for fee sharing
* @param _userIntentSignature User's signature authorizing the operation
* @param _tokenDepositDetails Permit2 batch transfer structure with witness
* @param _executorFeeInfo Array of executor fee tokens and amounts
* @param _swapData Array of swap configurations
* @param _swapExecutionData Array of execution data for each swap
*/
function executeMultiSwapWithWitness(
bytes32 _transactionId,
address _user,
address _integrator,
bytes calldata _userIntentSignature,
PermitBatchTransferFrom calldata _tokenDepositDetails,
TokenInfo[] calldata _executorFeeInfo,
SwapData[] calldata _swapData,
SwapExecutionData[] calldata _swapExecutionData
) external;
/**
* @notice Executes a gasless cross-chain bridge transaction
* @dev Enables users to bridge tokens without holding native tokens for gas.
* Includes fee verification to ensure accurate bridge costs.
*
* @param _transactionId Unique identifier for the bridge operation
* @param _bridgeFeeData Encoded FeeConfig containing integrator address and fees info.
* Used for fee distribution between integrator and protocol
* @param _userIntentSignature User's signature authorizing the bridge
* @param _feeVerificationSignature Oracle signature verifying bridge fees
* @param _userIntentDeadline Expiration time for user's intent
* @param _bridgeFeeDeadline Expiration time for fee quote
* @param _user Address of the user initiating the bridge
* @param _inputToken Token to be bridged with amount and permissions
* @param _executorFeeInfo Executor compensation details
* @param _adapterInfo Bridge adapter configuration and parameters
*/
function executeBridge(
bytes32 _transactionId,
bytes calldata _bridgeFeeData,
bytes calldata _userIntentSignature,
bytes calldata _feeVerificationSignature,
uint256 _userIntentDeadline,
uint256 _bridgeFeeDeadline,
address _user,
InputToken calldata _inputToken,
TokenInfo calldata _executorFeeInfo,
AdapterInfo calldata _adapterInfo
) external payable;
/**
* @notice Executes multiple gasless bridge transactions with optional pre-bridge swaps
* @dev Combines swapping and bridging in atomic transactions. Useful for bridging
* tokens that aren't natively supported on destination chains.
*
* @param _transactionId Unique identifier for the multi-bridge operation
* @param _bridgeFeeData Encoded FeeConfig containing integrator address and fees info.
* Used for fee distribution between integrator and protocol
* @param _userIntentSignature User's signature for the entire operation
* @param _feeVerificationSignature Oracle verification of all bridge fees
* @param _userIntentDeadline User intent expiration timestamp
* @param _bridgeFeeDeadline Bridge fee quote expiration timestamp
* @param _user Address of the user initiating the bridges
* @param _inputTokens Array of input tokens for swaps and bridges
* @param _executorFeeInfo Array of executor fees for each operation
* @param _swapData Array of swap configurations (empty if no pre-bridge swaps)
* @param _swapExecutionData Array of swap execution data
* @param _adapterInfo Array of bridge adapter configurations
*/
function executeMultiBridge(
bytes32 _transactionId,
bytes calldata _bridgeFeeData,
bytes calldata _userIntentSignature,
bytes calldata _feeVerificationSignature,
uint256 _userIntentDeadline,
uint256 _bridgeFeeDeadline,
address _user,
InputToken[] calldata _inputTokens,
TokenInfo[] calldata _executorFeeInfo,
BridgeSwapData[] calldata _swapData,
SwapExecutionData[] calldata _swapExecutionData,
AdapterInfo[] calldata _adapterInfo
) external payable;
/**
* @notice Executes multiple gasless bridges using Permit2 batch transfers
* @dev Most gas-efficient method for complex multi-bridge operations.
* Combines Permit2 batch transfers with multi-bridge execution.
*
* @param _transactionId Unique identifier for the batch bridge operation
* @param _bridgeFeeData Encoded FeeConfig containing integrator address and fees info.
* Used for fee distribution between integrator and protocol
* @param _userIntentSignature User's authorization signature
* @param _feeVerificationSignature Oracle verification of bridge fees
* @param _bridgeFeeDeadline Expiration time for fee quotes
* @param _user Address of the user initiating the operations
* @param _tokenDepositDetails Permit2 batch transfer with witness data
* @param _executorFeeInfo Array of executor compensation details
* @param _swapData Array of pre-bridge swap configurations
* @param _swapExecutionData Array of swap execution parameters
* @param _adapterInfo Array of bridge adapter configurations
*/
function executeMultiBridgeWithWitness(
bytes32 _transactionId,
bytes calldata _bridgeFeeData,
bytes calldata _userIntentSignature,
bytes calldata _feeVerificationSignature,
uint256 _bridgeFeeDeadline,
address _user,
PermitBatchTransferFrom calldata _tokenDepositDetails,
TokenInfo[] calldata _executorFeeInfo,
BridgeSwapData[] calldata _swapData,
SwapExecutionData[] calldata _swapExecutionData,
AdapterInfo[] calldata _adapterInfo
) external payable;
}// SPDX-License-Identifier: MIT
pragma solidity 0.8.19;
struct PermitDetails {
address token;
uint160 amount;
uint48 expiration;
uint48 nonce;
}
struct PermitSingle {
PermitDetails details;
address spender;
uint256 sigDeadline;
}
struct TokenPermissions {
address token;
uint256 amount;
}
struct PermitTransferFrom {
TokenPermissions permitted;
uint256 nonce;
uint256 deadline;
}
struct SignatureTransferDetails {
address to;
uint256 requestedAmount;
}
struct PermitBatchTransferFrom {
// the tokens and corresponding amounts permitted for a transfer
TokenPermissions[] permitted;
// a unique value for every token owner's signature to prevent signature replays
uint256 nonce;
// deadline on the permit signature
uint256 deadline;
}
interface IPermit2 {
function permit(address owner, PermitSingle memory permitSingle, bytes calldata signature) external;
function transferFrom(address from, address to, uint160 amount, address token) external;
function allowance(address, address, address) external view returns (uint160, uint48, uint48);
function permitWitnessTransferFrom(
PermitTransferFrom memory permit,
SignatureTransferDetails calldata transferDetails,
address owner,
bytes32 witness,
string calldata witnessTypeString,
bytes calldata signature
) external;
function permitWitnessTransferFrom(
PermitBatchTransferFrom memory permit,
SignatureTransferDetails[] calldata transferDetails,
address owner,
bytes32 witness,
string calldata witnessTypeString,
bytes calldata signature
) external;
}// SPDX-License-Identifier: MIT
pragma solidity 0.8.19;
import { LibAsset } from "../Libraries/LibAsset.sol";
import { BridgeNotWhitelisted, AdapterNotWhitelisted, DexNotWhitelisted, CannotAuthorizeSelf, NotAContract, ZeroAddress } from "../Errors.sol";
struct AllowListStorage {
mapping(address => bool) dexAllowlist;
mapping(address => bool) adaptersAllowlist;
mapping(address => bool) bridgeAllowlist;
}
/**
* @title LibAllowList
* @author DZap
* @notice Library for managing and accessing the conract address allow list
*/
library LibAllowList {
bytes32 internal constant ALLOWLIST_NAMESPACE = keccak256("dzap.library.allow.whitelist");
/// @dev Fetch local storage struct
function allowListStorage() internal pure returns (AllowListStorage storage als) {
bytes32 position = ALLOWLIST_NAMESPACE;
// solhint-disable-next-line no-inline-assembly
assembly {
als.slot := position
}
}
/* ========= VIEWS ========= */
function isDexWhitelisted(address _dex) internal view returns (bool) {
return allowListStorage().dexAllowlist[_dex];
}
function isAdapterWhitelisted(address _adapter) internal view returns (bool) {
return allowListStorage().adaptersAllowlist[_adapter];
}
function isBridgeWhitelisted(address _bridge) internal view returns (bool) {
return allowListStorage().bridgeAllowlist[_bridge];
}
/* ========= MUTATIONS ========= */
function addDex(address _dex) internal {
if (_dex == address(0)) revert ZeroAddress();
if (_dex == address(this)) revert CannotAuthorizeSelf();
if (!LibAsset.isContract(_dex)) revert NotAContract();
allowListStorage().dexAllowlist[_dex] = true;
}
function addDexes(address[] memory _dexes) internal {
AllowListStorage storage als = allowListStorage();
for (uint256 i; i < _dexes.length; ++i) {
address dex = _dexes[i];
if (dex == address(0)) revert ZeroAddress();
if (dex == address(this)) revert CannotAuthorizeSelf();
if (!LibAsset.isContract(dex)) revert NotAContract();
als.dexAllowlist[dex] = true;
}
}
function removeDex(address _dex) internal {
AllowListStorage storage als = allowListStorage();
if (!als.dexAllowlist[_dex]) {
revert DexNotWhitelisted(_dex);
}
als.dexAllowlist[_dex] = false;
}
function removeDexes(address[] memory _dexes) internal {
AllowListStorage storage als = allowListStorage();
for (uint256 i; i < _dexes.length; ++i) {
if (!als.dexAllowlist[_dexes[i]]) {
revert DexNotWhitelisted(_dexes[i]);
}
als.dexAllowlist[_dexes[i]] = false;
}
}
function addBridge(address _bridge) internal {
if (_bridge == address(0)) revert ZeroAddress();
if (_bridge == address(this)) revert CannotAuthorizeSelf();
if (!LibAsset.isContract(_bridge)) revert NotAContract();
allowListStorage().bridgeAllowlist[_bridge] = true;
}
function addBridges(address[] memory _bridges) internal {
AllowListStorage storage als = allowListStorage();
for (uint256 i; i < _bridges.length; ++i) {
address bridge = _bridges[i];
if (bridge == address(0)) revert ZeroAddress();
if (bridge == address(this)) revert CannotAuthorizeSelf();
if (!LibAsset.isContract(bridge)) revert NotAContract();
als.bridgeAllowlist[bridge] = true;
}
}
function removeBridge(address _bridge) internal {
AllowListStorage storage als = allowListStorage();
if (!als.bridgeAllowlist[_bridge]) {
revert BridgeNotWhitelisted(_bridge);
}
als.bridgeAllowlist[_bridge] = false;
}
function removeBridges(address[] memory _bridges) internal {
AllowListStorage storage als = allowListStorage();
for (uint256 i; i < _bridges.length; ++i) {
if (!als.bridgeAllowlist[_bridges[i]]) {
revert BridgeNotWhitelisted(_bridges[i]);
}
als.bridgeAllowlist[_bridges[i]] = false;
}
}
function addAdapter(address _adapter) internal {
if (_adapter == address(0)) revert ZeroAddress();
if (_adapter == address(this)) revert CannotAuthorizeSelf();
if (!LibAsset.isContract(_adapter)) revert NotAContract();
allowListStorage().adaptersAllowlist[_adapter] = true;
}
function addAdapters(address[] memory _adapters) internal {
AllowListStorage storage als = allowListStorage();
for (uint256 i; i < _adapters.length; ++i) {
address adapter = _adapters[i];
if (adapter == address(0)) revert ZeroAddress();
if (adapter == address(this)) revert CannotAuthorizeSelf();
if (!LibAsset.isContract(adapter)) revert NotAContract();
als.adaptersAllowlist[adapter] = true;
}
}
function removeAdapter(address _adapter) internal {
AllowListStorage storage als = allowListStorage();
if (!als.adaptersAllowlist[_adapter]) {
revert AdapterNotWhitelisted(_adapter);
}
als.adaptersAllowlist[_adapter] = false;
}
function removeAdapters(address[] memory _adapters) internal {
AllowListStorage storage als = allowListStorage();
for (uint256 i; i < _adapters.length; ++i) {
if (!als.adaptersAllowlist[_adapters[i]]) {
revert AdapterNotWhitelisted(_adapters[i]);
}
als.adaptersAllowlist[_adapters[i]] = false;
}
}
}// SPDX-License-Identifier: MIT
pragma solidity 0.8.19;
import { IERC20 } from "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import { SafeERC20 } from "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
import { LibPermit } from "../Libraries/LibPermit.sol";
import { PermitType, InputToken } from "../Types.sol";
import { PermitBatchTransferFrom } from "../Interfaces/IPermit2.sol";
import { NoTransferToNullAddress, NativeTransferFailed, NullAddrIsNotAValidSpender, InvalidPermitType, TransferAmountMismatch } from "../Errors.sol";
/**
* @title LibAsset
* @author DZap
* @notice This library contains helpers for dealing with onchain transfers
* of assets, including accounting for the native asset `assetId`
* conventions and any noncompliant ERC20 transfers
*/
library LibAsset {
// ============= CONSTANTS =============
address internal constant _NATIVE_TOKEN = 0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE;
// ============= BALANCE QUERY FUNCTIONS =============
/// @notice Gets the balance of the inheriting contract for the given asset
function getOwnBalance(address _token) internal view returns (uint256) {
return _token == _NATIVE_TOKEN ? address(this).balance : IERC20(_token).balanceOf(address(this));
}
/// @notice Gets the balance of the given asset for the given recipient
function getBalance(address _token, address _recipient) internal view returns (uint256) {
return _token == _NATIVE_TOKEN ? _recipient.balance : IERC20(_token).balanceOf(_recipient);
}
/// @notice Gets the balance of the given erc20 token for the given recipient
function getErc20Balance(address _token, address _recipient) internal view returns (uint256) {
return IERC20(_token).balanceOf(_recipient);
}
// ============= APPROVAL FUNCTIONS =============
/// @notice If the current allowance is insufficient, then MAX_UINT allowance for a given spender
function maxApproveERC20(address _token, address _spender, uint256 _amount) internal {
if (_spender == address(0)) revert NullAddrIsNotAValidSpender();
uint256 allowance = IERC20(_token).allowance(address(this), _spender);
if (allowance < _amount) {
SafeERC20.forceApprove(IERC20(_token), _spender, type(uint256).max);
}
}
// ============= TRANSFER FUNCTIONS =============
/// @notice Transfers ether from the inheriting contract to a given recipient
function transferNativeToken(address _recipient, uint256 _amount) internal {
if (_recipient == address(0)) revert NoTransferToNullAddress();
(bool success, ) = _recipient.call{ value: _amount }("");
if (!success) revert NativeTransferFailed();
}
/// @notice Transfers tokens from the inheriting contract to a given recipient
function transferERC20(address _token, address _recipient, uint256 _amount) internal {
if (_recipient == address(0)) revert NoTransferToNullAddress();
SafeERC20.safeTransfer(IERC20(_token), _recipient, _amount);
}
/// @notice Transfers tokens from the inheriting contract to a given recipient without checks
function transferERC20WithoutChecks(address _token, address _recipient, uint256 _amount) internal {
SafeERC20.safeTransfer(IERC20(_token), _recipient, _amount);
}
/// @notice Transfers tokens from a sender to a given recipient without checking the final balance
/// @dev need to handle deflationary, rebasing or share based tokens
function transferFromERC20WithoutChecks(address _token, address _from, address _to, uint256 _amount) internal {
SafeERC20.safeTransferFrom(IERC20(_token), _from, _to, _amount);
}
/// @notice Transfers tokens from the inheriting contract to a given recipient with balance check
function transferERC20WithBalanceCheck(address _token, address _recipient, uint256 _amount) internal {
if (_recipient == address(0)) revert NoTransferToNullAddress();
IERC20 token = IERC20(_token);
uint256 prevBalance = token.balanceOf(_recipient);
SafeERC20.safeTransfer(token, _recipient, _amount);
uint256 curr = token.balanceOf(_recipient);
if (curr < prevBalance || curr - prevBalance != _amount) {
revert TransferAmountMismatch();
}
}
/// @notice Transfers tokens from a sender to a given recipient with balance check
function transferFromERC20WithBalanceCheck(address _token, address _sender, address _recipient, uint256 _amount) internal {
if (_recipient == address(0)) revert NoTransferToNullAddress();
IERC20 token = IERC20(_token);
uint256 prevBalance = token.balanceOf(_recipient);
SafeERC20.safeTransferFrom(token, _sender, _recipient, _amount);
uint256 curr = token.balanceOf(_recipient);
if (curr < prevBalance || curr - prevBalance != _amount) {
revert TransferAmountMismatch();
}
}
/// @notice Wrapper function to transfer a given asset (native or erc20) to
/// some recipient. Should handle all non-compliant return value
/// tokens as well by using the SafeERC20 contract by open zeppelin.
function transferToken(address _token, address _recipient, uint256 _amount) internal {
if (_amount != 0) {
if (_token == _NATIVE_TOKEN) transferNativeToken(_recipient, _amount);
else transferERC20(_token, _recipient, _amount);
}
}
// ============= DEPOSIT FUNCTIONS =============
/// @notice Deposits tokens from a sender to the inheriting contract
/// @dev only handles erc20 token
function deposit(address _from, address _token, uint256 _amount, bytes calldata _permit) internal {
(PermitType permitType, bytes memory data) = abi.decode(_permit, (PermitType, bytes));
if (permitType == PermitType.PERMIT2_WITNESS_TRANSFER) {
LibPermit.permit2WitnessTransferFrom(_from, address(this), _token, _amount, data);
} else if (permitType == PermitType.PERMIT) {
if (data.length != 0) LibPermit.eip2612Permit(_from, address(this), _token, _amount, data);
transferFromERC20WithoutChecks(_token, _from, address(this), _amount);
} else if (permitType == PermitType.PERMIT2_APPROVE) {
LibPermit.permit2ApproveAndTransfer(_from, address(this), _token, uint160(_amount), data);
} else {
revert InvalidPermitType();
}
}
/// @notice Deposits tokens from a sender to the inheriting contract
function depositBatch(address _from, InputToken[] calldata erc20Tokens) internal {
uint256 i;
uint256 length = erc20Tokens.length;
for (i; i < length; ) {
deposit(_from, erc20Tokens[i].token, erc20Tokens[i].amount, erc20Tokens[i].permit);
unchecked {
++i;
}
}
}
function depositBatch(address _from, PermitBatchTransferFrom calldata permit, bytes calldata permitSignature) internal {
LibPermit.permit2BatchWitnessTransferFrom(_from, address(this), permit, permitSignature);
}
// ============= UTILITY FUNCTIONS =============
/// @notice Determines whether the given token is the native token
function isNativeToken(address _token) internal pure returns (bool) {
return _token == _NATIVE_TOKEN;
}
/// @dev Checks whether the given address is a contract and contains code
function isContract(address _contractAddr) internal view returns (bool) {
uint256 size;
// solhint-disable-next-line no-inline-assembly
assembly {
size := extcodesize(_contractAddr)
}
return size != 0;
}
}// SPDX-License-Identifier: MIT
pragma solidity 0.8.19;
import { LibAllowList } from "../../Shared/Libraries/LibAllowList.sol";
import { LibGlobalStorage } from "../../Shared/Libraries/LibGlobalStorage.sol";
import { LibValidator } from "../../Shared/Libraries/LibValidator.sol";
import { LibAsset } from "../../Shared/Libraries/LibAsset.sol";
import { AdapterInfo } from "../Types.sol";
import { FeeConfig } from "../../Shared/Types.sol";
import { AdapterNotWhitelisted, AdapterCallFailed } from "../../Shared/Errors.sol";
/**
* @title LibBridge
* @author DZap
* @notice This library contains helpers for bridging tokens
*/
library LibBridge {
/// @notice Returns true if the adapter is whitelisted
function isAdapterWhitelisted(address _adapter) internal view returns (bool) {
return LibAllowList.isAdapterWhitelisted(_adapter);
}
/// @notice Returns true if the bridge is whitelisted
function isBridgeWhitelisted(address _bridge) internal view returns (bool) {
return LibAllowList.isBridgeWhitelisted(_bridge);
}
/// @notice Verifies and takes fee
function verifyAndTakeFee(
address _user,
uint256 _deadline,
bytes32 _transactionIdHash,
bytes32 _adapterInfoHash,
bytes calldata _feeData,
bytes calldata _signature
) internal returns (address integrator) {
LibValidator.handleFeeVerification(_user, _deadline, _transactionIdHash, keccak256(_feeData), _adapterInfoHash, _signature);
return takeFee(_feeData);
}
/// @notice Takes fee
function takeFee(bytes calldata _feeData) internal returns (address integrator) {
FeeConfig memory feeInfo = abi.decode(_feeData, (FeeConfig));
address protocolFeeVault = LibGlobalStorage.getProtocolFeeVault();
uint256 i;
uint256 length = feeInfo.fees.length;
for (i; i < length; ) {
LibAsset.transferToken(feeInfo.fees[i].token, feeInfo.integrator, feeInfo.fees[i].integratorFeeAmount);
LibAsset.transferToken(feeInfo.fees[i].token, protocolFeeVault, feeInfo.fees[i].protocolFeeAmount);
unchecked {
++i;
}
}
return feeInfo.integrator;
}
/// @notice Bridges tokens
function bridge(AdapterInfo[] calldata _adapterInfo) internal {
uint256 i;
uint256 length = _adapterInfo.length;
for (i; i < length; ) {
bridge(_adapterInfo[i]);
unchecked {
++i;
}
}
}
/// @notice Bridges tokens
function bridge(AdapterInfo calldata _adapterInfo) internal {
address adapter = _adapterInfo.adapter;
if (!isAdapterWhitelisted(adapter)) revert AdapterNotWhitelisted(adapter);
(bool success, bytes memory res) = adapter.delegatecall(_adapterInfo.adapterData);
if (!success) revert AdapterCallFailed(adapter, res);
}
}// SPDX-License-Identifier: MIT
pragma solidity 0.8.19;
struct GlobalStorage {
bool initialized;
address protocolFeeVault;
address feeValidator;
address permit2;
address refundVault;
bool paused;
}
/**
* @title LibGlobalStorage
* @author DZap
* @notice This library provides functionality for managing global storage
*/
library LibGlobalStorage {
bytes32 internal constant _GLOBAL_NAMESPACE = keccak256("dzap.storage.library.global");
function globalStorage() internal pure returns (GlobalStorage storage ds) {
bytes32 slot = _GLOBAL_NAMESPACE;
assembly {
ds.slot := slot
}
}
function getRefundVault() internal view returns (address) {
return globalStorage().refundVault;
}
function getProtocolFeeVault() internal view returns (address) {
return globalStorage().protocolFeeVault;
}
function getFeeValidator() internal view returns (address) {
return globalStorage().feeValidator;
}
function getPermit2() internal view returns (address) {
return globalStorage().permit2;
}
function getPaused() internal view returns (bool) {
return globalStorage().paused;
}
}// SPDX-License-Identifier: MIT
pragma solidity 0.8.19;
import { IERC20 } from "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import { IERC20Permit } from "@openzeppelin/contracts/token/ERC20/extensions/IERC20Permit.sol";
import { LibGlobalStorage } from "./LibGlobalStorage.sol";
import { PermitTransferFrom, PermitBatchTransferFrom, SignatureTransferDetails, PermitSingle, PermitDetails, TokenPermissions, IPermit2 } from "../Interfaces/IPermit2.sol";
/**
* @title LibPermit
* @author DZap
* @notice This library contains helpers for using permit and permit2
*/
library LibPermit {
// ============= ERRORS =============
error InvalidPermit(string reason);
// ============= CONSTANTS =============
string internal constant _DZAP_TRANSFER_WITNESS_TYPE_STRING =
"DZapTransferWitness witness)DZapTransferWitness(address owner,address recipient)TokenPermissions(address token,uint256 amount)";
bytes32 internal constant _DZAP_TRANSFER_WITNESS_TYPEHASH = keccak256("DZapTransferWitness(address owner,address recipient)");
// ============= VIEW =============
/// @notice Returns the permit2 address
function permit2() private view returns (address) {
return LibGlobalStorage.getPermit2();
}
// ============= EIP-2612 PERMIT FUNCTIONS =============
/// @notice Handles eip2612 permit
function eip2612Permit(address _owner, address _spender, address _token, uint256 _amount, bytes memory _data) internal {
(uint256 deadline, uint8 v, bytes32 r, bytes32 s) = abi.decode(_data, (uint256, uint8, bytes32, bytes32));
try IERC20Permit(_token).permit(_owner, _spender, _amount, deadline, v, r, s) {} catch Error(string memory reason) {
if (IERC20(_token).allowance(_owner, _spender) < _amount) {
revert InvalidPermit(reason);
}
}
}
// ============= PERMIT2 FUNCTIONS =============
/// @notice Handles permit2 approve and transfer
function permit2ApproveAndTransfer(address _owner, address _spender, address _token, uint160 _amount, bytes memory data) internal {
permit2Approve(_owner, _spender, _token, _amount, data);
IPermit2(permit2()).transferFrom(_owner, _spender, uint160(_amount), _token);
}
/// @notice Handles permit2 approve
function permit2Approve(address _owner, address _spender, address _token, uint160 _amount, bytes memory _data) internal {
if (_data.length == 0) return;
IPermit2 permit2Contract = IPermit2(permit2());
(uint48 nonce, uint48 expiration, uint256 sigDeadline, bytes memory signature) = abi.decode(_data, (uint48, uint48, uint256, bytes));
try
permit2Contract.permit(_owner, PermitSingle(PermitDetails(_token, _amount, expiration, nonce), _spender, sigDeadline), signature)
{} catch Error(string memory reason) {
(uint256 currentAllowance, uint256 allowanceExpiration, ) = permit2Contract.allowance(_owner, _token, _spender);
if (currentAllowance < _amount || allowanceExpiration < block.timestamp) revert InvalidPermit(reason);
}
}
/// @notice Handles permit2 witness transfer from
function permit2WitnessTransferFrom(address _owner, address _recipient, address _token, uint256 _amount, bytes memory _data) internal {
(uint256 nonce, uint256 deadline, bytes memory _signature) = abi.decode(_data, (uint256, uint256, bytes));
IPermit2(permit2()).permitWitnessTransferFrom(
PermitTransferFrom(TokenPermissions(_token, _amount), nonce, deadline),
SignatureTransferDetails(_recipient, _amount),
_owner,
_createWitnessTransferFromHash(_owner, _recipient),
_DZAP_TRANSFER_WITNESS_TYPE_STRING,
_signature
);
}
/// @notice Handles permit2 batch witness transfer from
function permit2BatchWitnessTransferFrom(
address _owner,
address _recipient,
PermitBatchTransferFrom calldata permit,
bytes calldata _signature
) internal {
uint256 length = permit.permitted.length;
SignatureTransferDetails[] memory details = new SignatureTransferDetails[](length);
for (uint256 i; i < length; ) {
details[i] = SignatureTransferDetails(_recipient, permit.permitted[i].amount);
unchecked {
++i;
}
}
IPermit2(permit2()).permitWitnessTransferFrom(
permit,
details,
_owner,
_createWitnessTransferFromHash(_owner, _recipient),
_DZAP_TRANSFER_WITNESS_TYPE_STRING,
_signature
);
}
/// @notice Handles permit2 batch witness transfer from
function permit2BatchWitnessTransferFrom(
address _owner,
address _recipient,
bytes32 _witness,
PermitBatchTransferFrom calldata permit,
bytes calldata _signature,
string memory _witnessTypeString
) internal {
uint256 length = permit.permitted.length;
SignatureTransferDetails[] memory details = new SignatureTransferDetails[](length);
for (uint256 i; i < length; ) {
details[i] = SignatureTransferDetails(_recipient, permit.permitted[i].amount);
unchecked {
++i;
}
}
IPermit2(permit2()).permitWitnessTransferFrom(permit, details, _owner, _witness, _witnessTypeString, _signature);
}
/* ========= PRIVATE ========= */
function _createWitnessTransferFromHash(address _owner, address _recipient) private pure returns (bytes32) {
return keccak256(abi.encode(_DZAP_TRANSFER_WITNESS_TYPEHASH, _owner, _recipient));
}
}// SPDX-License-Identifier: MIT
pragma solidity 0.8.19;
import { LibAsset } from "../Libraries/LibAsset.sol";
import { SwapExecutionData } from "../Types.sol";
import { SwapCallFailed, SlippageTooHigh } from "../Errors.sol";
/**
* @title LibSwap
* @author DZap
* @notice This library contains helpers for doing swap
*/
library LibSwap {
function swap(
address _user,
address _recipient,
address _from,
address _to,
uint256 _fromAmount,
uint256 _minToAmount,
SwapExecutionData memory _swapExecutionData,
bool _withoutRevert
) internal returns (uint256 returnToAmount) {
address recipient = _swapExecutionData.isDirectTransfer ? _recipient : address(this);
uint256 initialToBalance = LibAsset.getBalance(_to, recipient);
uint256 nativeValue;
if (LibAsset.isNativeToken(_from)) {
nativeValue = _fromAmount;
} else {
LibAsset.maxApproveERC20(_from, _swapExecutionData.approveTo, _fromAmount);
}
(bool success, bytes memory res) = _swapExecutionData.callTo.call{ value: nativeValue }(_swapExecutionData.swapCallData);
if (!success) {
if (_withoutRevert) {
LibAsset.transferToken(_from, _user, _fromAmount);
return (0);
}
revert SwapCallFailed(_swapExecutionData.callTo, bytes4(_swapExecutionData.swapCallData), res);
}
returnToAmount = LibAsset.getBalance(_to, recipient) - initialToBalance;
if (returnToAmount < _minToAmount) revert SlippageTooHigh(_minToAmount, returnToAmount);
if (!_swapExecutionData.isDirectTransfer && _recipient != address(this)) LibAsset.transferToken(_to, _recipient, returnToAmount);
}
}// SPDX-License-Identifier: MIT
pragma solidity 0.8.19;
import { LibGlobalStorage } from "./LibGlobalStorage.sol";
import { ECDSA } from "@openzeppelin/contracts/utils/cryptography/ECDSA.sol";
struct ValidatorStorage {
mapping(address => uint256) nonce;
}
/**
* @title LibValidator
* @author DZap
* @notice This library contains helpers for validating signatures
*/
library LibValidator {
error SigDeadlineExpired();
error UnauthorizedSigner();
bytes32 internal constant _VALIDATOR_NAMESPACE = keccak256("dzap.storage.library.validator");
bytes32 private constant _DOMAIN_TYPEHASH =
keccak256("EIP712Domain(string name,string version,uint256 chainId,address verifyingContract,bytes32 salt)");
bytes32 private constant _SIGNED_GASLESS_DATA_TYPEHASH =
keccak256("SignedGasLessSwapData(bytes32 txId,address user,uint256 nonce,uint256 deadline,bytes32 executorFeesHash,bytes32 swapDataHash)");
bytes32 private constant _SIGNED_GASLESS_BRIDGE_DATA_TYPEHASH =
keccak256(
"SignedGasLessBridgeData(bytes32 txId,address user,uint256 nonce,uint256 deadline,bytes32 executorFeesHash,bytes32 adapterDataHash)"
);
bytes32 private constant _SIGNED_GASLESS_SWAP_BRIDGE_DATA_TYPEHASH =
keccak256(
"SignedGasLessSwapBridgeData(bytes32 txId,address user,uint256 nonce,uint256 deadline,bytes32 executorFeesHash,bytes32 swapDataHash,bytes32 adapterDataHash)"
);
bytes32 private constant _SIGNED_FEE_DATA_TYPEHASH =
keccak256("SignedFeeData(bytes32 txId,address user,uint256 nonce,uint256 deadline,bytes32 feeDataHash,bytes32 adapterDataHash)");
string private constant _DOMAIN_NAME = "DZapVerifier";
string private constant _VERSION = "1";
bytes32 private constant _SALT = keccak256("DZap-v0.1");
function validatorStorage() internal pure returns (ValidatorStorage storage ds) {
bytes32 slot = _VALIDATOR_NAMESPACE;
assembly {
ds.slot := slot
}
}
/// @notice Returns the nonce for a given user
function getNonce(address _user) internal view returns (uint256) {
return validatorStorage().nonce[_user];
}
/// @notice Handles gasless swap verification
function handleGasLessSwapVerification(
address _user,
uint256 _deadline,
bytes32 _transactionId,
bytes32 _executorFeesHash,
bytes32 _swapDataHash,
bytes calldata _signature
) internal {
if (_deadline < block.timestamp) revert SigDeadlineExpired();
uint256 nonce = getNonce(_user);
bytes32 msgHash = keccak256(
abi.encode(_SIGNED_GASLESS_DATA_TYPEHASH, _transactionId, _user, nonce, _deadline, _executorFeesHash, _swapDataHash)
);
_verifySignature(_user, msgHash, _signature);
_incrementNonce(_user);
}
/// @notice Handles gasless bridge verification
function handleGasLessBridgeVerification(
address _user,
uint256 _deadline,
bytes32 _transactionId,
bytes32 _executorFeesHash,
bytes32 _adapterDataHash,
bytes calldata _signature
) internal {
if (_deadline < block.timestamp) revert SigDeadlineExpired();
uint256 nonce = getNonce(_user);
bytes32 msgHash = keccak256(
abi.encode(_SIGNED_GASLESS_BRIDGE_DATA_TYPEHASH, _transactionId, _user, nonce, _deadline, _executorFeesHash, _adapterDataHash)
);
_verifySignature(_user, msgHash, _signature);
_incrementNonce(_user);
}
/// @notice Handles gasless swap bridge verification
function handleGasLessSwapBridgeVerification(
address _user,
uint256 _deadline,
bytes32 _transactionId,
bytes32 _executorFeesHash,
bytes32 _swapDataHash,
bytes32 _adapterDataHash,
bytes calldata _signature
) internal {
if (_deadline < block.timestamp) revert SigDeadlineExpired();
uint256 nonce = getNonce(_user);
bytes32 msgHash = keccak256(
abi.encode(
_SIGNED_GASLESS_SWAP_BRIDGE_DATA_TYPEHASH,
_transactionId,
_user,
nonce,
_deadline,
_executorFeesHash,
_swapDataHash,
_adapterDataHash
)
);
_verifySignature(_user, msgHash, _signature);
_incrementNonce(_user);
}
/// @notice Handles fee verification
function handleFeeVerification(
address _user,
uint256 _deadline,
bytes32 _transactionId,
bytes32 _feeDataHash,
bytes32 _adapterDataHash,
bytes calldata _signature
) internal {
if (_deadline < block.timestamp) revert SigDeadlineExpired();
address validator = LibGlobalStorage.getFeeValidator();
uint256 nonce = getNonce(_user);
bytes32 msgHash = keccak256(abi.encode(_SIGNED_FEE_DATA_TYPEHASH, _transactionId, _user, nonce, _deadline, _feeDataHash, _adapterDataHash));
_verifySignature(validator, msgHash, _signature);
_incrementNonce(_user);
}
/* ========= PRIVATE ========= */
function _getDomainSeparator() private view returns (bytes32) {
return
keccak256(abi.encode(_DOMAIN_TYPEHASH, keccak256(bytes(_DOMAIN_NAME)), keccak256(bytes(_VERSION)), block.chainid, address(this), _SALT));
}
function _verifySignature(address _signer, bytes32 _msgHash, bytes calldata _signature) private view {
bytes32 digest = keccak256(abi.encodePacked("\x19\x01", _getDomainSeparator(), _msgHash));
if (ECDSA.recover(digest, _signature) != _signer) revert UnauthorizedSigner();
}
function _incrementNonce(address _user) private {
validatorStorage().nonce[_user]++;
}
}// SPDX-License-Identifier: MIT
pragma solidity 0.8.19;
/// @title DZap Types
enum PermitType {
PERMIT, // EIP2612
PERMIT2_APPROVE,
PERMIT2_WITNESS_TRANSFER,
BATCH_PERMIT2_WITNESS_TRANSFER
}
struct InputToken {
address token;
uint256 amount;
bytes permit;
}
struct SwapInfo {
string dex;
address callTo;
address recipient;
address fromToken;
address toToken;
uint256 fromAmount;
uint256 returnToAmount;
}
struct SwapData {
address recipient;
address from;
address to;
uint256 fromAmount;
uint256 minToAmount;
}
struct BridgeSwapData {
address recipient;
address from;
address to;
uint256 fromAmount;
uint256 minToAmount;
bool updateBridgeInAmount;
}
struct SwapExecutionData {
string dex;
address callTo;
address approveTo;
bytes swapCallData;
bool isDirectTransfer;
}
struct TokenInfo {
address token;
uint256 amount;
}
struct Fees {
address token;
uint256 integratorFeeAmount;
uint256 protocolFeeAmount;
}
struct FeeConfig {
address integrator;
Fees[] fees;
}
struct AdapterInfo {
address adapter;
bytes adapterData;
}{
"optimizer": {
"enabled": true,
"runs": 300
},
"viaIR": true,
"outputSelection": {
"*": {
"*": [
"evm.bytecode",
"evm.deployedBytecode",
"devdoc",
"userdoc",
"metadata",
"abi"
]
}
}
}Contract Security Audit
- No Contract Security Audit Submitted- Submit Audit Here
Contract ABI
API[{"inputs":[{"internalType":"address","name":"adapter","type":"address"},{"internalType":"bytes","name":"res","type":"bytes"}],"name":"AdapterCallFailed","type":"error"},{"inputs":[{"internalType":"address","name":"adapter","type":"address"}],"name":"AdapterNotWhitelisted","type":"error"},{"inputs":[],"name":"ContractIsNotPaused","type":"error"},{"inputs":[],"name":"ContractIsPaused","type":"error"},{"inputs":[{"internalType":"address","name":"dex","type":"address"}],"name":"DexNotWhitelisted","type":"error"},{"inputs":[{"internalType":"string","name":"reason","type":"string"}],"name":"InvalidPermit","type":"error"},{"inputs":[],"name":"InvalidPermitType","type":"error"},{"inputs":[],"name":"NativeTransferFailed","type":"error"},{"inputs":[],"name":"NoSwapFromZeroAmount","type":"error"},{"inputs":[],"name":"NoTransferToNullAddress","type":"error"},{"inputs":[],"name":"NullAddrIsNotAValidRecipient","type":"error"},{"inputs":[],"name":"NullAddrIsNotAValidSpender","type":"error"},{"inputs":[],"name":"ReentrancyError","type":"error"},{"inputs":[],"name":"SigDeadlineExpired","type":"error"},{"inputs":[{"internalType":"uint256","name":"minAmount","type":"uint256"},{"internalType":"uint256","name":"returnAmount","type":"uint256"}],"name":"SlippageTooHigh","type":"error"},{"inputs":[{"internalType":"address","name":"target","type":"address"},{"internalType":"bytes4","name":"funSig","type":"bytes4"},{"internalType":"bytes","name":"reason","type":"bytes"}],"name":"SwapCallFailed","type":"error"},{"inputs":[],"name":"UnauthorizedSigner","type":"error"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"transactionId","type":"bytes32"},{"indexed":true,"internalType":"address","name":"user","type":"address"},{"indexed":false,"internalType":"bytes","name":"receiver","type":"bytes"},{"indexed":false,"internalType":"string","name":"bridge","type":"string"},{"indexed":false,"internalType":"address","name":"bridgeAddress","type":"address"},{"indexed":false,"internalType":"address","name":"from","type":"address"},{"indexed":false,"internalType":"bytes","name":"to","type":"bytes"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"destinationChainId","type":"uint256"},{"indexed":false,"internalType":"bytes","name":"destinationCalldata","type":"bytes"}],"name":"BridgeStarted","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"transactionId","type":"bytes32"},{"indexed":true,"internalType":"address","name":"sender","type":"address"},{"indexed":true,"internalType":"address","name":"integrator","type":"address"},{"components":[{"internalType":"string","name":"dex","type":"string"},{"internalType":"address","name":"callTo","type":"address"},{"internalType":"address","name":"recipient","type":"address"},{"internalType":"address","name":"fromToken","type":"address"},{"internalType":"address","name":"toToken","type":"address"},{"internalType":"uint256","name":"fromAmount","type":"uint256"},{"internalType":"uint256","name":"returnToAmount","type":"uint256"}],"indexed":false,"internalType":"struct SwapInfo[]","name":"swapInfo","type":"tuple[]"}],"name":"DZapBatchTokenSwapped","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"transactionId","type":"bytes32"},{"indexed":true,"internalType":"address","name":"user","type":"address"},{"indexed":true,"internalType":"address","name":"integrator","type":"address"}],"name":"DZapBridgeStarted","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"_transactionId","type":"bytes32"},{"indexed":true,"internalType":"address","name":"executor","type":"address"},{"indexed":true,"internalType":"address","name":"_user","type":"address"}],"name":"DZapGasLessStarted","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"transactionId","type":"bytes32"},{"indexed":true,"internalType":"address","name":"sender","type":"address"},{"indexed":true,"internalType":"address","name":"integrator","type":"address"},{"components":[{"internalType":"string","name":"dex","type":"string"},{"internalType":"address","name":"callTo","type":"address"},{"internalType":"address","name":"recipient","type":"address"},{"internalType":"address","name":"fromToken","type":"address"},{"internalType":"address","name":"toToken","type":"address"},{"internalType":"uint256","name":"fromAmount","type":"uint256"},{"internalType":"uint256","name":"returnToAmount","type":"uint256"}],"indexed":false,"internalType":"struct SwapInfo","name":"swapInfo","type":"tuple"}],"name":"DZapTokenSwapped","type":"event"},{"inputs":[{"internalType":"bytes32","name":"_transactionId","type":"bytes32"},{"internalType":"bytes","name":"_bridgeFeeData","type":"bytes"},{"internalType":"bytes","name":"_userIntentSignature","type":"bytes"},{"internalType":"bytes","name":"_feeVerificationSignature","type":"bytes"},{"internalType":"uint256","name":"_userIntentDeadline","type":"uint256"},{"internalType":"uint256","name":"_bridgeFeeDeadline","type":"uint256"},{"internalType":"address","name":"_user","type":"address"},{"components":[{"internalType":"address","name":"token","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"bytes","name":"permit","type":"bytes"}],"internalType":"struct InputToken","name":"_inputToken","type":"tuple"},{"components":[{"internalType":"address","name":"token","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"internalType":"struct TokenInfo","name":"_executorFeeInfo","type":"tuple"},{"components":[{"internalType":"address","name":"adapter","type":"address"},{"internalType":"bytes","name":"adapterData","type":"bytes"}],"internalType":"struct AdapterInfo","name":"_adapterInfo","type":"tuple"}],"name":"executeBridge","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"_transactionId","type":"bytes32"},{"internalType":"bytes","name":"_bridgeFeeData","type":"bytes"},{"internalType":"bytes","name":"_userIntentSignature","type":"bytes"},{"internalType":"bytes","name":"_feeVerificationSignature","type":"bytes"},{"internalType":"uint256","name":"_userIntentDeadline","type":"uint256"},{"internalType":"uint256","name":"_bridgeFeeDeadline","type":"uint256"},{"internalType":"address","name":"_user","type":"address"},{"components":[{"internalType":"address","name":"token","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"bytes","name":"permit","type":"bytes"}],"internalType":"struct InputToken[]","name":"_inputTokens","type":"tuple[]"},{"components":[{"internalType":"address","name":"token","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"internalType":"struct TokenInfo[]","name":"_executorFeeInfo","type":"tuple[]"},{"components":[{"internalType":"address","name":"recipient","type":"address"},{"internalType":"address","name":"from","type":"address"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"fromAmount","type":"uint256"},{"internalType":"uint256","name":"minToAmount","type":"uint256"},{"internalType":"bool","name":"updateBridgeInAmount","type":"bool"}],"internalType":"struct BridgeSwapData[]","name":"_swapData","type":"tuple[]"},{"components":[{"internalType":"string","name":"dex","type":"string"},{"internalType":"address","name":"callTo","type":"address"},{"internalType":"address","name":"approveTo","type":"address"},{"internalType":"bytes","name":"swapCallData","type":"bytes"},{"internalType":"bool","name":"isDirectTransfer","type":"bool"}],"internalType":"struct SwapExecutionData[]","name":"_swapExecutionData","type":"tuple[]"},{"components":[{"internalType":"address","name":"adapter","type":"address"},{"internalType":"bytes","name":"adapterData","type":"bytes"}],"internalType":"struct AdapterInfo[]","name":"_adapterInfo","type":"tuple[]"}],"name":"executeMultiBridge","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"_transactionId","type":"bytes32"},{"internalType":"bytes","name":"_bridgeFeeData","type":"bytes"},{"internalType":"bytes","name":"_userIntentSignature","type":"bytes"},{"internalType":"bytes","name":"_feeVerificationSignature","type":"bytes"},{"internalType":"uint256","name":"_bridgeFeeDeadline","type":"uint256"},{"internalType":"address","name":"_user","type":"address"},{"components":[{"components":[{"internalType":"address","name":"token","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"internalType":"struct TokenPermissions[]","name":"permitted","type":"tuple[]"},{"internalType":"uint256","name":"nonce","type":"uint256"},{"internalType":"uint256","name":"deadline","type":"uint256"}],"internalType":"struct PermitBatchTransferFrom","name":"_tokenDepositDetails","type":"tuple"},{"components":[{"internalType":"address","name":"token","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"internalType":"struct TokenInfo[]","name":"_executorFeeInfo","type":"tuple[]"},{"components":[{"internalType":"address","name":"recipient","type":"address"},{"internalType":"address","name":"from","type":"address"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"fromAmount","type":"uint256"},{"internalType":"uint256","name":"minToAmount","type":"uint256"},{"internalType":"bool","name":"updateBridgeInAmount","type":"bool"}],"internalType":"struct BridgeSwapData[]","name":"_swapData","type":"tuple[]"},{"components":[{"internalType":"string","name":"dex","type":"string"},{"internalType":"address","name":"callTo","type":"address"},{"internalType":"address","name":"approveTo","type":"address"},{"internalType":"bytes","name":"swapCallData","type":"bytes"},{"internalType":"bool","name":"isDirectTransfer","type":"bool"}],"internalType":"struct SwapExecutionData[]","name":"_swapExecutionData","type":"tuple[]"},{"components":[{"internalType":"address","name":"adapter","type":"address"},{"internalType":"bytes","name":"adapterData","type":"bytes"}],"internalType":"struct AdapterInfo[]","name":"_adapterInfo","type":"tuple[]"}],"name":"executeMultiBridgeWithWitness","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"_transactionId","type":"bytes32"},{"internalType":"address","name":"_user","type":"address"},{"internalType":"address","name":"_integrator","type":"address"},{"internalType":"uint256","name":"_userIntentDeadline","type":"uint256"},{"internalType":"bytes","name":"_userIntentSignature","type":"bytes"},{"components":[{"internalType":"address","name":"token","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"bytes","name":"permit","type":"bytes"}],"internalType":"struct InputToken[]","name":"_inputTokens","type":"tuple[]"},{"components":[{"internalType":"address","name":"token","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"internalType":"struct TokenInfo[]","name":"_executorFeeInfo","type":"tuple[]"},{"components":[{"internalType":"address","name":"recipient","type":"address"},{"internalType":"address","name":"from","type":"address"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"fromAmount","type":"uint256"},{"internalType":"uint256","name":"minToAmount","type":"uint256"}],"internalType":"struct SwapData[]","name":"_swapData","type":"tuple[]"},{"components":[{"internalType":"string","name":"dex","type":"string"},{"internalType":"address","name":"callTo","type":"address"},{"internalType":"address","name":"approveTo","type":"address"},{"internalType":"bytes","name":"swapCallData","type":"bytes"},{"internalType":"bool","name":"isDirectTransfer","type":"bool"}],"internalType":"struct SwapExecutionData[]","name":"_swapExecutionData","type":"tuple[]"}],"name":"executeMultiSwap","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"_transactionId","type":"bytes32"},{"internalType":"address","name":"_user","type":"address"},{"internalType":"address","name":"_integrator","type":"address"},{"internalType":"bytes","name":"_userIntentSignature","type":"bytes"},{"components":[{"components":[{"internalType":"address","name":"token","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"internalType":"struct TokenPermissions[]","name":"permitted","type":"tuple[]"},{"internalType":"uint256","name":"nonce","type":"uint256"},{"internalType":"uint256","name":"deadline","type":"uint256"}],"internalType":"struct PermitBatchTransferFrom","name":"_tokenDepositDetails","type":"tuple"},{"components":[{"internalType":"address","name":"token","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"internalType":"struct TokenInfo[]","name":"_executorFeeInfo","type":"tuple[]"},{"components":[{"internalType":"address","name":"recipient","type":"address"},{"internalType":"address","name":"from","type":"address"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"fromAmount","type":"uint256"},{"internalType":"uint256","name":"minToAmount","type":"uint256"}],"internalType":"struct SwapData[]","name":"_swapData","type":"tuple[]"},{"components":[{"internalType":"string","name":"dex","type":"string"},{"internalType":"address","name":"callTo","type":"address"},{"internalType":"address","name":"approveTo","type":"address"},{"internalType":"bytes","name":"swapCallData","type":"bytes"},{"internalType":"bool","name":"isDirectTransfer","type":"bool"}],"internalType":"struct SwapExecutionData[]","name":"_swapExecutionData","type":"tuple[]"}],"name":"executeMultiSwapWithWitness","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"_transactionId","type":"bytes32"},{"internalType":"address","name":"_user","type":"address"},{"internalType":"address","name":"_integrator","type":"address"},{"internalType":"uint256","name":"_userIntentDeadline","type":"uint256"},{"internalType":"bytes","name":"_userIntentSignature","type":"bytes"},{"internalType":"bytes","name":"_tokenApprovalData","type":"bytes"},{"components":[{"internalType":"address","name":"token","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"internalType":"struct TokenInfo","name":"_executorFeeInfo","type":"tuple"},{"components":[{"internalType":"address","name":"recipient","type":"address"},{"internalType":"address","name":"from","type":"address"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"fromAmount","type":"uint256"},{"internalType":"uint256","name":"minToAmount","type":"uint256"}],"internalType":"struct SwapData","name":"_swapData","type":"tuple"},{"components":[{"internalType":"string","name":"dex","type":"string"},{"internalType":"address","name":"callTo","type":"address"},{"internalType":"address","name":"approveTo","type":"address"},{"internalType":"bytes","name":"swapCallData","type":"bytes"},{"internalType":"bool","name":"isDirectTransfer","type":"bool"}],"internalType":"struct SwapExecutionData","name":"_swapExecutionData","type":"tuple"}],"name":"executeSwap","outputs":[],"stateMutability":"nonpayable","type":"function"}]Contract Creation Code
6080806040523461001657613ed2908161001c8239f35b600080fdfe61014080604052600436101561001457600080fd5b60003560e01c90816349e27c9914611481575080634a0e0fb31461119c57806356e64adf14610ef357806362ec33ab14610af4578063e48cfff6146104745763fe35a65e1461006257600080fd5b61018036600319011261046f576024356001600160401b03811161046f5761008e903690600401611679565b6044356001600160401b03811161046f576100ad903690600401611679565b916064356001600160401b03811161046f576100cd903690600401611679565b906100d661164f565b60c05260e4356001600160401b03811161046f576100f89036906004016116a6565b60a052608052610104356001600160401b03811161046f5761011e9036906004016116d6565b919061010052610124356001600160401b03811161046f57610144903690600401611736565b60e05295610144356001600160401b03811161046f576101689036906004016116a6565b939091610164356001600160401b03811161046f5761018b9036906004016116a6565b610120529661019a3447611bca565b9a60ff600080516020613e7d8339815191525460a01c1661045d576002600080516020613e3d833981519152541461044b576002600080516020613e3d833981519152556040519261012051846101f660208201928d84611c83565b039461020a601f1996878101835282611856565b519020948c6040516020810190610235816102298661010051866119d5565b03898101835282611856565b5190209561025f6040519182610253602082019560e0519087611cfb565b03908101835282611856565b51902042608435106104395761027660c0516123c2565b5495604051967f1c2d231b893879f104a293ad5705a978024fedcfb705af8832187bf40163e0c5602089015260043560408901526001600160a01b0360c051166060890152608088015260843560a088015260c087015260e0860152856101008601526101008552846101208101106001600160401b0361012087011117610423576103596103999a61038c99610384986103a39f6103739661032e918b6101206103789d016040526020815191012060c051613aac565b61033960c051613df5565b6103443689896118d3565b6020815191012060043560a43560c051613a02565b61036a60a05160805160c051612c4e565b61010051611e99565b612cac565b97369060e05190611d96565b923691611b5b565b908560c051600435612251565b6101205190612e2a565b6001600160a01b038060c051169116816004357f2f784d79e0ac264e2b2b087fdba506b5763d153d8f2fe8077b404d20a2a7109e600080a433600435600080516020613e5d833981519152600080a46001600080516020613e3d833981519152554781811161040e57005b6104219161041b91611bca565b3361242a565b005b634e487b7160e01b600052604160045260246000fd5b60405163e354457160e01b8152600490fd5b6040516329f745a760e01b8152600490fd5b6040516306d39fcd60e41b8152600490fd5b600080fd5b3461046f576003196101c03682011261046f5761048f611623565b610497611639565b916001600160401b039060843582811161046f576104b9903690600401611679565b60a43584811161046f576104d1903690600401611679565b939094604060c31936011261046f5760a03661010319011261046f576101a4351161046f5760a0906101a4353603011261046f5760ff600080516020613e7d8339815191525460a01c1661045d576002600080516020613e3d833981519152541461044b576002600080516020613e3d83398151915255604051602081019060c4356001600160a01b03811680910361046f57825260e43560408201526040815261057b816117e9565b51902091604051926001600160a01b036101043516610104350361046f576001600160a01b03610104351660208501526001600160a01b036101243516610124350361046f576001600160a01b03610124351660408501526001600160a01b0361014435169384610144350361046f576106279460608201526101643560808201526101843560a082015260a0815261061381611804565b602081519101209060043560643589613972565b60e43561016435016101643511610ade5761064e9160e43561016435016101243585612692565b6001600160a01b0361065e61188e565b16610aba575b60405191610671836117a0565b61010435835261012435602084015261014435604084015261016435606084015260808301916101843583526106ad366101a435600401611935565b926106c8846001600160a01b03875116606088015190611f90565b6001600160a01b03855116946001600160a01b03602082015116916001600160a01b0360408301511690606083015190519360808801511515600014610ab35788905b61071582856138dc565b9260009173eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee8103610921575090505b6000806001600160a01b0360208c0151169260608c0193845191602083519301915af16107636123fa565b90156108a65750509061077961077e92846138dc565b611bca565b92808410610888575082869760806001600160a01b0397980151158061087e575b61086d575b5050508360208751970151169084815116856020830151169060608760408501511693015193604051996107d78b611785565b8a5260208a015260408901526060880152608087015260a086015260c08501521680927f247ededb7c64e43522ee8e8356d61630dfd566c20710e93ab33d5ae4d8a4ab8a6001600160a01b03604051946020865216938061083f600435946020830190611f2f565b0390a433600435600080516020613e5d833981519152600080a46001600080516020613e3d83398151915255005b61087692612644565b8682816107a4565b503081141561079f565b6044908460405191633b5d56ed60e11b835260048301526024820152fd5b6001600160a01b0360208b015116915191602083519301519163ffffffff60e01b808416936004861061090a575b509061090691604051948594639c7cc24360e01b86526004860152166024840152606060448401526064830190611f0a565b0390fd5b909460040360031b85901b168416925083856108d4565b6001600160a01b0360408c015116918215610aa157604051636eb1769f60e11b81523060048201526001600160a01b0384166024820152602081604481865afa908115610a9557600091610a63575b501061097e575b5050610738565b60405163095ea7b360e01b602082018181526001600160a01b0385166024840152600019604480850191909152835290939192919060009081906109c3606487611856565b85519082865af16109d26123fa565b81610a34575b5080610a2a575b156109ec575b5050610977565b610a2193610a1c9160405191602083015260248201526000604482015260448152610a168161181f565b826124c5565b6124c5565b8a8080806109e5565b50813b15156109df565b8051801592508215610a49575b50508f6109d8565b610a5c92506020809183010191016124ad565b8f80610a41565b90506020813d602011610a8d575b81610a7e60209383611856565b8101031261046f57518e610970565b3d9150610a71565b6040513d6000823e3d90fd5b6040516363ba9bff60e01b8152600490fd5b309061070b565b610ad9610ac561188e565b60e435906001600160a01b03339116612476565b610664565b634e487b7160e01b600052601160045260246000fd5b6003196101603682011261046f576001600160401b0360243581811161046f57610b22903690600401611679565b60443583811161046f57610b3a903690600401611679565b939060643582811161046f57610b54903690600401611679565b9490966001600160a01b0360a4351660a4350361046f578360c4351161046f5760609060c4353603011261046f5760e43583811161046f57610b9a9036906004016116d6565b9790956101043585811161046f57610bb6903690600401611736565b9590926101243582811161046f57610bd29036906004016116a6565b9490926101443590811161046f57610bee9036906004016116a6565b989097610bfb3447611bca565b9d60ff600080516020613e7d8339815191525460a01c1661045d576002600080516020613e3d833981519152541461044b57610e60610e7f9c6001600160a01b039f9a8f610e6d9a8f998f610e7a9f610e6699610e40918c6103849f8f90610cd06103739a8f98610cbb610c9494610ca2610c94936002600080516020613e3d83398151915255610c9460405193849260208401611c83565b03601f198101835282611856565b602081519101209a6040519283916020830195866119d5565b51902093604051928391602083019586611cfb565b519020604051917f9e454eb6b2b030e6c117f9568a4ebdfa17f78c1ff8b3b9b29bcccfacfc3c9e93602084015260043560408401526001600160a01b0360a435166060840152608083015260a08201528460c082015260c08152610d3381611785565b602081519101209160405192610d4884611785565b60ba84527f445a61704272696467655769746e657373207769746e65737329445a6170427260208501527f696467655769746e657373286279746573333220747849642c6164647265737360408501527f20757365722c62797465733332206578656375746f7246656573486173682c6260608501527f797465733332207377617044617461486173682c62797465733332206164617060808501527f746572446174614861736829546f6b656e5065726d697373696f6e732861646460a08501527f7265737320746f6b656e2c75696e7432353620616d6f756e742900000000000060c085015260c435600401903060a435613388565b610e4b3687876118d3565b6020815191012060043560843560a435613a02565b9c611e99565b3691611d96565b908660a435600435612251565b612e2a565b166001600160a01b0360a435166004357f2f784d79e0ac264e2b2b087fdba506b5763d153d8f2fe8077b404d20a2a7109e600080a46001600160a01b0360a4351633600435600080516020613e5d833981519152600080a46001600080516020613e3d833981519152554781811161040e57005b3461046f576003196101003682011261046f57610f0e611623565b610f16611639565b916001600160401b039160643583811161046f57610f38903690600401611679565b949092846084351161046f576060906084353603011261046f5760a43584811161046f57610f6a9036906004016116d6565b91909560c43586811161046f57610f85903690600401611706565b97909660e43590811161046f57610fa09036906004016116a6565b9260ff600080516020613e7d8339815191525460a01c1661045d57600080516020613e3d8339815191529860028a541461044b5760019a611170611181986111779661116b8c8f976001600160a01b039f60026103849a5560405161100d81610c948989602084016119d5565b602081519101208960405161102b81610c948d602083019586611a16565b519020604051917f4738b29017ecc1fd734e1aaeca797eeffe89932f62dc5c6054278717e53eea43602084015260043560408401526001600160a01b0386166060840152608083015260a082015260a0815261108681611804565b60208151910120926040519361109b85611804565b609e85527f445a6170537761705769746e657373207769746e65737329445a61705377617060208601527f5769746e657373286279746573333220747849642c616464726573732075736560408601527f722c62797465733332206578656375746f7246656573486173682c627974657360608601527f33322073776170446174614861736829546f6b656e5065726d697373696f6e7360808601527f286164647265737320746f6b656e2c75696e7432353620616d6f756e7429000060a0860152608435600401913090613388565b611e99565b3691611ab5565b918460043561211b565b1633600435600080516020613e5d833981519152600080a455005b6003196101603682011261046f576001600160401b039060243582811161046f576111cb903690600401611679565b91909260443581811161046f576111e6903690600401611679565b60649291923582811161046f57611201903690600401611679565b91909561120c61164f565b958460e4351161046f5760608160e4353603011261046f5760403661010319011261046f576101443594851161046f57604090853603011261046f576112523447611bca565b9760ff600080516020613e7d8339815191525460a01c1661045d576002600080516020613e3d833981519152541461044b576002600080516020613e3d833981519152556040516020810190602082526112b681610c94604082018a600401611bf8565b5190209560405161010435906001600160a01b03821680920361046f5760208101918252610124356040820152604081526112f0816117e9565b519020944260843510610439576001600160a01b03998a98611396611401976113bd958d61140a9b611321826123c2565b5490604051917f73b66d7df0c9bcf49e2a6a8b2e449d1d904327522a59905238572195a371ad0e602084015260043560408401526001600160a01b0384166060840152608083015260843560a083015260c08201528560e082015260e081526113898161183a565b6020815191012090613aac565b61139f8b613df5565b6113aa3687876118d3565b6020815191012060043560a4358d613a02565b6113ee60e4356004016113df6113d2826118a4565b91604460e4350190611c51565b91602460e4350135908b612692565b856113f7611877565b1661146a57612cac565b91600401612e6a565b168282166004357f2f784d79e0ac264e2b2b087fdba506b5763d153d8f2fe8077b404d20a2a7109e600080a41633600435600080516020613e5d833981519152600080a46001600080516020613e3d833981519152554781811161040e57005b61037361012435338861147b611877565b16612476565b3461046f5761012036600319011261046f5760043561149e611623565b906114a7611639565b916001600160401b039060843582811161046f576114c9903690600401611679565b909460a43584811161046f576114e39036906004016116a6565b60c49591953582811161046f576114fe9036906004016116d6565b99909660e43584811161046f57611519903690600401611706565b946101043590811161046f576115339036906004016116a6565b95909360ff600080516020613e7d8339815191525460a01c166116145750600080516020613e3d8339815191529b60028d541461044b578d8b60019f8f988f976001600160a01b039f8f906115fa9f611170986103849c6115f29f8d6102536115e08f936115ed9861116b9d60026115b793556040519283916020830193846119d5565b03916115cb601f1993848101835282611856565b51902094604051938491602083019687611a16565b5190209160643587613972565b612c4e565b91848761211b565b16903390600080516020613e5d833981519152600080a455005b6306d39fcd60e41b8152600490fd5b602435906001600160a01b038216820361046f57565b604435906001600160a01b038216820361046f57565b60c435906001600160a01b038216820361046f57565b35906001600160a01b038216820361046f57565b9181601f8401121561046f578235916001600160401b03831161046f576020838186019501011161046f57565b9181601f8401121561046f578235916001600160401b03831161046f576020808501948460051b01011161046f57565b9181601f8401121561046f578235916001600160401b03831161046f576020808501948460061b01011161046f57565b9181601f8401121561046f578235916001600160401b03831161046f5760208085019460a0850201011161046f57565b9181601f8401121561046f578235916001600160401b03831161046f5760208085019460c0850201011161046f57565b602080916001600160a01b0361177b82611665565b1684520135910152565b60e081019081106001600160401b0382111761042357604052565b60a081019081106001600160401b0382111761042357604052565b6001600160401b03811161042357604052565b604081019081106001600160401b0382111761042357604052565b606081019081106001600160401b0382111761042357604052565b60c081019081106001600160401b0382111761042357604052565b608081019081106001600160401b0382111761042357604052565b61010081019081106001600160401b0382111761042357604052565b90601f801991011681019081106001600160401b0382111761042357604052565b610104356001600160a01b038116810361046f5790565b60c4356001600160a01b038116810361046f5790565b356001600160a01b038116810361046f5790565b6001600160401b03811161042357601f01601f191660200190565b9291926118df826118b8565b916118ed6040519384611856565b82948184528183011161046f578281602093846000960137010152565b9080601f8301121561046f57816020611925933591016118d3565b90565b3590811515820361046f57565b91909160a08184031261046f576040519061194f826117a0565b81938135906001600160401b039182811161046f57830181601f8201121561046f5781816020611981933591016118d3565b845261198f60208401611665565b60208501526119a060408401611665565b6040850152606083013591821161046f57826119c5608094926119d09486940161190a565b606086015201611928565b910152565b602080825281018390526040908101929060005b8281106119f7575050505090565b90919293828082611a0a60019489611766565b019501939291016119e9565b6020808252808201849052604091820193916000915b838310611a3b57505050505090565b90919293946001906001600160a01b0380611a5589611665565b16825280611a64858a01611665565b1684830152611a74858901611665565b1681850152606087810135908201526080808801359082015260a090810196019493019190611a2c565b6001600160401b0381116104235760051b60200190565b929192611ac182611a9e565b604094611ad086519283611856565b819584835260208093019160a080960285019481861161046f57925b858410611afc5750505050505050565b868483031261046f578487918451611b13816117a0565b611b1c87611665565b8152611b29838801611665565b83820152611b38868801611665565b868201526060808801359082015260808088013590820152815201930192611aec565b92919092611b6884611a9e565b91611b766040519384611856565b829480845260208094019060051b83019282841161046f5780915b848310611ba057505050505050565b82356001600160401b03811161046f578691611bbf8684938601611935565b815201920191611b91565b91908203918211610ade57565b908060209392818452848401376000828201840152601f01601f1916010190565b6001600160a01b03611c0982611665565b1682526020810135601e198236030181121561046f5701602081359101906001600160401b03811161046f57803603821361046f576040838160206119259601520191611bd7565b903590601e198136030182121561046f57018035906001600160401b03821161046f5760200191813603831361046f57565b916020908082850183865252604084019160408260051b8601019484600080925b858410611cb657505050505050505090565b9091929394959697603f198282030188528835603e1985360301811215611cf75786611ce760019387839401611bf8565b9a01980196959401929190611ca4565b8380fd5b6020808252808201849052604091820193916000915b838310611d2057505050505090565b90919293946001906001600160a01b0380611d3a89611665565b16825280611d49858a01611665565b1684830152611d59858901611665565b1684820152606080880135908201526080808801359082015260a0611d7f818901611928565b15159082015260c090810196019493019190611d11565b929192611da282611a9e565b604094611db186519283611856565b819584835260208093019160c080960285019481861161046f57925b858410611ddd5750505050505050565b868483031261046f57825190878201908282106001600160401b03831117611e5e57889287928652611e0e87611665565b8152611e1b838801611665565b83820152611e2a868801611665565b86820152606080880135908201526080808801359082015260a0611e4f818901611928565b90820152815201930192611dcd565b60246000634e487b7160e01b81526041600452fd5b9190811015611e835760061b0190565b634e487b7160e01b600052603260045260246000fd5b60005b828110611ea857505050565b80611ee1611ec1611ebc6001948787611e73565b6118a4565b6020611ece848888611e73565b0135906001600160a01b03339116612476565b01611e9c565b60005b838110611efa5750506000910152565b8181015183820152602001611eea565b90602091611f2381518092818552858086019101611ee7565b601f01601f1916010190565b9060c080611f46845160e0855260e0850190611f0a565b936001600160a01b03806020830151166020860152806040830151166040860152806060830151166060860152608082015116608085015260a081015160a0850152015191015290565b9091602001906001600160a01b0391828151166000527f03ef279dff7badd98b43464ec17f797a88e435619b3aa2c30c6c31214479119560205260ff604060002054161561200a57501615611ff85715611fe657565b6040516357b3d85d60e11b8152600490fd5b604051637c13399160e11b8152600490fd5b5160405163740bb42360e11b81529083166004820152602490fd5b9061202f82611a9e565b60409061203e82519182611856565b838152809361204f601f1991611a9e565b019160005b8381106120615750505050565b602090825161206f81611785565b6060808252600084918183850152818785015283015260006080830152600060a0830152600060c0830152828601015201612054565b8051821015611e835760209160051b010190565b602080820190808352835180925260408301928160408460051b8301019501936000915b8483106120ed5750505050505090565b909192939495848061210b600193603f198682030187528a51611f2f565b98019301930191949392906120dd565b9190939280519060009461212e83612025565b955b83811061219057505050612145575b50505050565b6121847fc9a96626eddfa02e342d5a828eed18ad376bb804eed233dcba5ec5d792df2cc2916040519182916001600160a01b03809116971695826120b9565b0390a43880808061213f565b61219a81846120a5565b516121a582846120a5565b5180916001600160a01b03808251166060918284019283928684516121c992611f90565b818551169186602096878101928080808b81885116996040978888019b848d51169d5160809e8f8b0151926121fd95613623565b9d519e01511693511694511695511696519782519a61221b8c611785565b8b528a015288015286015284015260a083015260c082015261223d82896120a5565b5261224881886120a5565b50600101612130565b9190939280519060009461226483612025565b955b83811061227a575050506121455750505050565b80612287600192856120a5565b5161229282856120a5565b51906122ae826001600160a01b03835116606084015190611f90565b6122ea826001600160a01b038351166001600160a01b036020850151166001600160a01b03604086015116606086015191608087015193613623565b90306001600160a01b0382511614806123b6575b61238b575b6001600160a01b036020845194015116906001600160a01b038151166001600160a01b036020830151169060606001600160a01b03604085015116930151936040519661234f88611785565b8752602087015260408601526060850152608084015260a083015260c0820152612379828a6120a5565b5261238481896120a5565b5001612266565b6123b16001600160a01b036040830151168d6123ab608085015186611bca565b91612644565b612303565b5060a0810151156122fe565b6001600160a01b03166000527f4f9314598fc24317d901f4a94cc5def9e3c745b0f73ff0b0e154b9953457cf83602052604060002090565b3d15612425573d9061240b826118b8565b916124196040519384611856565b82523d6000602084013e565b606090565b6001600160a01b0381161561246457600080809381935af161244a6123fa565b501561245257565b604051633d2cec6f60e21b8152600490fd5b6040516321f7434560e01b8152600490fd5b6124ab926001600160a01b036040519363a9059cbb60e01b6020860152166024840152604483015260448252610a1c8261181f565b565b9081602091031261046f5751801515810361046f5790565b604051612523916001600160a01b03166124de826117ce565b6000806020958685527f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c656487860152868151910182855af161251d6123fa565b916125ab565b805190828215928315612593575b5050501561253c5750565b6084906040519062461bcd60e51b82526004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b6064820152fd5b6125a393508201810191016124ad565b388281612531565b9192901561260d57508151156125bf575090565b3b156125c85790565b60405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000006044820152606490fd5b8251909150156126205750805190602001fd5b60405162461bcd60e51b815260206004820152908190610906906024830190611f0a565b91908161265057505050565b6001600160a01b039283169273eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee840361268257506124ab925061242a565b811615612464576124ab92612476565b919290938101916000946040938484820312612c285783359560049182881015612b6157602090818701356001600160401b0397888211612948576126d892910161190a565b9760028103612950575087518801976060818a031261294c57818101519688820151996060830151918211612948576127179290840191018301612fcd565b916001600160a01b03807f0e1ba6b8f4f66ef33154e3c1bb6c4c32cda48e0a34207b9eeeb11bd92063322f541696818a5197612752896117ce565b1687528284880152895196612766886117e9565b87528387019889528987019a8b52895192612780846117ce565b30845284840152895191848301917f266a51557d4733337e3bc8128e6cd4856463d454dce2a9f9dfcb38e4f603714083521691828b820152306060820152606081526127cb8161181f565b519020917f445a61705472616e736665725769746e657373207769746e65737329445a61708a51946127fc866117a0565b607e86528501527f5472616e736665725769746e6573732861646472657373206f776e65722c61648a8501527f647265737320726563697069656e7429546f6b656e5065726d697373696f6e7360608501527f286164647265737320746f6b656e2c75696e7432353620616d6f756e742900006080850152873b1561294857918b9897969593918995938b519c8d9a8b998a986309be14ff60e11b8a5289019051906128ba91602080916001600160a01b0381511684520151910152565b51604488015251606487015280516001600160a01b031660848701526020015160a486015260c485015260e484015261010483016101409052610144830161290191611f0a565b8281036003190161012484015261291791611f0a565b03925af190811561293f575061292b575050565b61293582916117bb565b61293c5750565b80fd5b513d84823e3d90fd5b8b80fd5b8980fd5b80919892959794965099989915600014612b6557508051806129b2575b5050506124ab95965051936323b872dd60e01b908501526001600160a01b0380931660248501523060448501526064840152606483526129ac836117a0565b166124c5565b8160809181010312612b61578681015190838101519060ff8216809203612b5d5760806060820151910151906001600160a01b039283891694853b15612b5957875163d505accf60e01b8152948b1687860152306024860152604485018990526064850152608484015260a483015260c4820152898160e48183865af19081612b46575b50612b3957600191612a46612f2e565b6308c379a014612a70575b5050612a67576124ab9596505b8695388061296d565b513d87823e3d90fd5b612a78612f4c565b80612a84575b50612a51565b8451636eb1769f60e11b81526001600160a01b0389168184019081523060208201528c95509293919290918a918391908290819060400103915afa908115612b2f579086918c91612afe575b5010612adc5780612a7e565b83516352c3687b60e11b81529182018890528190610906906024830190611f0a565b8092508a8092503d8311612b28575b612b178183611856565b8101031261046f5785905138612ad0565b503d612b0d565b85513d8d823e3d90fd5b50506124ab959650612a5e565b612b52909a919a6117bb565b9838612a36565b8d80fd5b8a80fd5b8880fd5b6001919397509895939491979814600014612c1857612b926001600160a01b03809516928383308761300f565b837f0e1ba6b8f4f66ef33154e3c1bb6c4c32cda48e0a34207b9eeeb11bd92063322f541691823b15612c1457608492858796959387938a519b8c988997631b63c28b60e11b8952169087015230602487015260448601521660648401525af1918215612c0a575050612c015750565b6124ab906117bb565b51903d90823e3d90fd5b8580fd5b8551632091924d60e21b81528790fd5b8680fd5b9190811015611e835760051b81013590605e198136030182121561046f570190565b91909160005b828110612c615750505050565b80612ca6612c75611ebc6001948789612c2c565b6020612c8284888a612c2c565b013590612c9d612c9385898b612c2c565b6040810190611c51565b92909187612692565b01612c54565b908101602090818382031261046f5782356001600160401b039384821161046f570191604093848484031261046f57845193612ce7856117ce565b612cf081611665565b85528281013591821161046f570182601f8201121561046f57803590612d1582611a9e565b93612d2287519586611856565b828552838501908460608095028401019281841161046f578501915b838310612ded575050505050808301908282526001600160a01b0394857f0e1ba6b8f4f66ef33154e3c1bb6c4c32cda48e0a34207b9eeeb11bd92063322d5460081c169160009451945b858110612d9a57505050505050511690565b80612dc889612dac60019489516120a5565b5151168a8a511685612dbf858b516120a5565b51015191612644565b612de789612dd78389516120a5565b5151168686612dbf858b516120a5565b01612d88565b848383031261046f578585918a51612e04816117e9565b612e0d86611665565b815282860135838201528b8601358c820152815201920191612d3e565b90600091825b828110612e3d5750505050565b8060051b820135603e1983360301811215612e665790612e606001928401612e6a565b01612e30565b8480fd5b612e73816118a4565b6001600160a01b03811691826000527f03ef279dff7badd98b43464ec17f797a88e435619b3aa2c30c6c31214479119660205260ff6040600020541615612f1557600091612ec682602085940190611c51565b90816040519283928337810184815203915af490612ee26123fa565b9115612eec575050565b610906604051928392632e546bb560e21b84526004840152604060248401526044830190611f0a565b60405163616d132960e01b815260048101849052602490fd5b60009060033d11612f3b57565b905060046000803e60005160e01c90565b600060443d1061192557604051600319913d83016004833e81516001600160401b03918282113d602484011117612fa957818401948551938411612fb1573d85010160208487010111612fa9575061192592910160200190611856565b949350505050565b50949350505050565b519065ffffffffffff8216820361046f57565b81601f8201121561046f578051612fe3816118b8565b92612ff16040519485611856565b8184526020828401011161046f576119259160208085019101611ee7565b919091845191600095831561334a576001600160a01b037f0e1ba6b8f4f66ef33154e3c1bb6c4c32cda48e0a34207b9eeeb11bd92063322f5416938101956080828803126133465761306360208301612fba565b9361307060408401612fba565b9460608401519360808101516001600160401b039a8b82116133425761309d926020918201920101612fcd565b926040519960808b01908b82109082111761332e576001600160a01b0365ffffffffffff939284926040528189168d5216978860208d01521660408b0152166060890152604051976130ee896117e9565b885260208801916001600160a01b038816835260408901938452863b1561294c579089929160405194859384936302b67b5760e41b85526001600160a01b03169b8c60048601525180516001600160a01b0316602486015260208101516001600160a01b03166044860152604081015165ffffffffffff1660648601526060015165ffffffffffff166084850152516001600160a01b031660a48401525160c483015260e48201610100905261010482016131a891611f0a565b038183885af1908161331b575b50613313576001946131c5612f2e565b6308c379a0146131e8575b50505050506131dc5750565b604051903d90823e3d90fd5b6131f0612f4c565b93846131fd575b506131d0565b6001600160a01b039495965060609291606491868a99604051988996879563927da10560e01b875260048701521660248501521660448301525afa91821561330857859086936132a2575b506001600160a01b03161090811561328f575b5061326a5780808080806131f7565b6040516352c3687b60e11b815260206004820152908190610906906024830190611f0a565b905065ffffffffffff429116103861325b565b9250506060823d606011613300575b816132be60609383611856565b81010312612e665781516001600160a01b0381168103612c14576001600160a01b03906132f960406132f260208701612fba565b9501612fba565b5090613248565b3d91506132b1565b6040513d87823e3d90fd5b505050505050565b613327909791976117bb565b95386131b5565b634e487b7160e01b8c52604160045260248cfd5b8c80fd5b8780fd5b50505050505050565b903590601e198136030182121561046f57018035906001600160401b03821161046f57602001918160061b3603831361046f57565b9594919390946133988480613353565b9190506133a482611a9e565b916040976133b489519485611856565b818452601f196133c383611a9e565b0160005b8181106135ff57505060005b8281106135aa575050506001600160a01b0395867f0e1ba6b8f4f66ef33154e3c1bb6c4c32cda48e0a34207b9eeeb11bd92063322f541696873b1561046f57885163fe8ec1a760e01b815260c06004820152996101248b018835368a9003601e190181121561046f5789019889356020809b01926001600160401b03821161046f578160061b3603841361046f5791818f9c93928f939a9e9c9a60608f60c4909e9c9b9a99989e0152526101448d019a9060005b818110613570575050508281013560e48d015201356101048b015260031997888b82030160248c015281808d5192838152019c01918d6000905b838210613526575050505050936134fa60009a613509958b99958d99958b991660448a0152606489015285888303016084890152611f0a565b928584030160a4860152611bd7565b03925af190811561351c5750612c015750565b513d6000823e3d90fd5b82949a9c9e6001939294969798999a9c9e50613556818d51602080916001600160a01b0381511684520151910152565b0199019101918e9b99979695949391928e9d9b999d6134c1565b92949d5092809c9e9a9c8c61358d8498999a9b9c9e600195611766565b0195019101908f9c9391928f939e9c9a9e9b99989796959b613487565b6001906135b78980613353565b906135c6836020938493611e73565b01358c51916135d4836117ce565b6001600160a01b03861683528201526135ed82886120a5565b526135f881876120a5565b50016133d3565b6020908b5161360d816117ce565b60008152826000818301528289010152016133c7565b929594909193956080820191825115156000146138d55784905b61364782886138dc565b9260006001600160a01b0380971673eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee811460001461375c5750505b6000806020840192606089855116950194855191602083519301915af19061369c6123fa565b911561370757505050906107796136b392876138dc565b958087106136e9575090859291511590816136dc575b506136d357505050565b6124ab92612644565b82163014159050386136c9565b6044908760405191633b5d56ed60e11b835260048301526024820152fd5b86905116915191602083519301519163ffffffff60e01b808416936004861061090a57509061090691604051948594639c7cc24360e01b86526004860152166024840152606060448401526064830190611f0a565b90916040918883860151169283156138c5578051636eb1769f60e11b81523060048201526001600160a01b0385166024820152602093908481604481875afa9081156138bb57879161388e575b50106137b9575b50505050613676565b805163095ea7b360e01b8482018181526001600160a01b03871660248401526000196044808501919091528352909591949190879081906137fb606489611856565b87519082885af161380a6123fa565b8161385e575b5080613854575b15613824575b50506137b0565b61384995610a1c935192830152602482015285604482015260448152610a168161181f565b38808080808061381d565b50833b1515613817565b80518015925084908315613876575b50505038613810565b61388693508201810191016124ad565b38838161386d565b90508481813d83116138b4575b6138a58183611856565b81010312612c285751386137a9565b503d61389b565b83513d89823e3d90fd5b516363ba9bff60e01b8152600490fd5b309061363d565b6001600160a01b0380911660009173eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee821460001461390f575050503190565b6024602092939460405194859384926370a0823160e01b84521660048301525afa9182156131dc57809261394257505090565b9091506020823d821161396a575b8161395d60209383611856565b8101031261293c57505190565b3d9150613950565b94919095929395428110610439576124ab966139fd95613991886123c2565b54926040519360208501957fa16c8a285e5f0c5f850b82fc099a326b2edf744d13f9a742c5cfe1ff803a8c92875260408601526001600160a01b038a166060860152608085015260a084015260c083015260e082015260e081526139f48161183a565b51902084613aac565b613df5565b9491959295428210610439576124ab966139fd956001600160a01b0391827f0e1ba6b8f4f66ef33154e3c1bb6c4c32cda48e0a34207b9eeeb11bd92063322e541694613a4d8a6123c2565b546040519460208601967fcbfee2c0e15f500ddc78e4d48ba409a821bc03215264d8922169947bac0ef178885260408701528b166060860152608085015260a084015260c083015260e082015260e08152613aa78161183a565b519020905b9092613be790613be1613bef946040966b222d30b82b32b934b334b2b960a11b60208951613ad9816117ce565b600c81520152603160f81b60208951613af1816117ce565b600181520152875160208101907fd87cd6ef79d4e2b95e15ce8abf732db51ec771f1ca2edccf22a46c729ac5647282527fa1d9b1587d1cdcf2a70ea404b54a42fe06f3d0742dc8c87336986927bf1279428a8201527fc89efdaa54c0f20c7adf612882df0950f5a951637e0307cdcb4c672f298b8bc660608201524660808201523060a08201527fab458d135ef5ffc786fd5ac1655b88a6fdc7589e65e154b5381ad419272f0c6260c082015260c08152613bab81611785565b51902090885190602082019261190160f01b84526022830152604282015260428152613bd68161181f565b5190209236916118d3565b90613d2e565b929092613c14565b6001600160a01b03809116911603613c045750565b51636518c33d60e11b8152600490fd5b6005811015613d185780613c255750565b60018103613c725760405162461bcd60e51b815260206004820152601860248201527f45434453413a20696e76616c6964207369676e617475726500000000000000006044820152606490fd5b60028103613cbf5760405162461bcd60e51b815260206004820152601f60248201527f45434453413a20696e76616c6964207369676e6174757265206c656e677468006044820152606490fd5b600314613cc857565b60405162461bcd60e51b815260206004820152602260248201527f45434453413a20696e76616c6964207369676e6174757265202773272076616c604482015261756560f01b6064820152608490fd5b634e487b7160e01b600052602160045260246000fd5b906041815114600014613d5c57613d58916020820151906060604084015193015160001a90613d66565b9091565b5050600090600290565b9291907f7fffffffffffffffffffffffffffffff5d576e7357a4501ddfe92f46681b20a08311613de95791608094939160ff602094604051948552168484015260408301526060820152600093849182805260015afa15613ddc5781516001600160a01b03811615613dd6579190565b50600190565b50604051903d90823e3d90fd5b50505050600090600390565b6001600160a01b03166000527f4f9314598fc24317d901f4a94cc5def9e3c745b0f73ff0b0e154b9953457cf83602052604060002080546000198114610ade57600101905556fea4b36ced7e8b039500cc9c7c393a04e0c8af96ee265b143e79175cc5679ca5391aae47cb9aefcb27db14106e9ac749e835533faf1d2e9ab41173ae45c19d95e20e1ba6b8f4f66ef33154e3c1bb6c4c32cda48e0a34207b9eeeb11bd920633230a2646970667358221220cbd80c0002da528bd4294cb87b903bc5f901e8e1c716b0d00e7fcd182cf7597564736f6c63430008130033
Deployed Bytecode
0x61014080604052600436101561001457600080fd5b60003560e01c90816349e27c9914611481575080634a0e0fb31461119c57806356e64adf14610ef357806362ec33ab14610af4578063e48cfff6146104745763fe35a65e1461006257600080fd5b61018036600319011261046f576024356001600160401b03811161046f5761008e903690600401611679565b6044356001600160401b03811161046f576100ad903690600401611679565b916064356001600160401b03811161046f576100cd903690600401611679565b906100d661164f565b60c05260e4356001600160401b03811161046f576100f89036906004016116a6565b60a052608052610104356001600160401b03811161046f5761011e9036906004016116d6565b919061010052610124356001600160401b03811161046f57610144903690600401611736565b60e05295610144356001600160401b03811161046f576101689036906004016116a6565b939091610164356001600160401b03811161046f5761018b9036906004016116a6565b610120529661019a3447611bca565b9a60ff600080516020613e7d8339815191525460a01c1661045d576002600080516020613e3d833981519152541461044b576002600080516020613e3d833981519152556040519261012051846101f660208201928d84611c83565b039461020a601f1996878101835282611856565b519020948c6040516020810190610235816102298661010051866119d5565b03898101835282611856565b5190209561025f6040519182610253602082019560e0519087611cfb565b03908101835282611856565b51902042608435106104395761027660c0516123c2565b5495604051967f1c2d231b893879f104a293ad5705a978024fedcfb705af8832187bf40163e0c5602089015260043560408901526001600160a01b0360c051166060890152608088015260843560a088015260c087015260e0860152856101008601526101008552846101208101106001600160401b0361012087011117610423576103596103999a61038c99610384986103a39f6103739661032e918b6101206103789d016040526020815191012060c051613aac565b61033960c051613df5565b6103443689896118d3565b6020815191012060043560a43560c051613a02565b61036a60a05160805160c051612c4e565b61010051611e99565b612cac565b97369060e05190611d96565b923691611b5b565b908560c051600435612251565b6101205190612e2a565b6001600160a01b038060c051169116816004357f2f784d79e0ac264e2b2b087fdba506b5763d153d8f2fe8077b404d20a2a7109e600080a433600435600080516020613e5d833981519152600080a46001600080516020613e3d833981519152554781811161040e57005b6104219161041b91611bca565b3361242a565b005b634e487b7160e01b600052604160045260246000fd5b60405163e354457160e01b8152600490fd5b6040516329f745a760e01b8152600490fd5b6040516306d39fcd60e41b8152600490fd5b600080fd5b3461046f576003196101c03682011261046f5761048f611623565b610497611639565b916001600160401b039060843582811161046f576104b9903690600401611679565b60a43584811161046f576104d1903690600401611679565b939094604060c31936011261046f5760a03661010319011261046f576101a4351161046f5760a0906101a4353603011261046f5760ff600080516020613e7d8339815191525460a01c1661045d576002600080516020613e3d833981519152541461044b576002600080516020613e3d83398151915255604051602081019060c4356001600160a01b03811680910361046f57825260e43560408201526040815261057b816117e9565b51902091604051926001600160a01b036101043516610104350361046f576001600160a01b03610104351660208501526001600160a01b036101243516610124350361046f576001600160a01b03610124351660408501526001600160a01b0361014435169384610144350361046f576106279460608201526101643560808201526101843560a082015260a0815261061381611804565b602081519101209060043560643589613972565b60e43561016435016101643511610ade5761064e9160e43561016435016101243585612692565b6001600160a01b0361065e61188e565b16610aba575b60405191610671836117a0565b61010435835261012435602084015261014435604084015261016435606084015260808301916101843583526106ad366101a435600401611935565b926106c8846001600160a01b03875116606088015190611f90565b6001600160a01b03855116946001600160a01b03602082015116916001600160a01b0360408301511690606083015190519360808801511515600014610ab35788905b61071582856138dc565b9260009173eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee8103610921575090505b6000806001600160a01b0360208c0151169260608c0193845191602083519301915af16107636123fa565b90156108a65750509061077961077e92846138dc565b611bca565b92808410610888575082869760806001600160a01b0397980151158061087e575b61086d575b5050508360208751970151169084815116856020830151169060608760408501511693015193604051996107d78b611785565b8a5260208a015260408901526060880152608087015260a086015260c08501521680927f247ededb7c64e43522ee8e8356d61630dfd566c20710e93ab33d5ae4d8a4ab8a6001600160a01b03604051946020865216938061083f600435946020830190611f2f565b0390a433600435600080516020613e5d833981519152600080a46001600080516020613e3d83398151915255005b61087692612644565b8682816107a4565b503081141561079f565b6044908460405191633b5d56ed60e11b835260048301526024820152fd5b6001600160a01b0360208b015116915191602083519301519163ffffffff60e01b808416936004861061090a575b509061090691604051948594639c7cc24360e01b86526004860152166024840152606060448401526064830190611f0a565b0390fd5b909460040360031b85901b168416925083856108d4565b6001600160a01b0360408c015116918215610aa157604051636eb1769f60e11b81523060048201526001600160a01b0384166024820152602081604481865afa908115610a9557600091610a63575b501061097e575b5050610738565b60405163095ea7b360e01b602082018181526001600160a01b0385166024840152600019604480850191909152835290939192919060009081906109c3606487611856565b85519082865af16109d26123fa565b81610a34575b5080610a2a575b156109ec575b5050610977565b610a2193610a1c9160405191602083015260248201526000604482015260448152610a168161181f565b826124c5565b6124c5565b8a8080806109e5565b50813b15156109df565b8051801592508215610a49575b50508f6109d8565b610a5c92506020809183010191016124ad565b8f80610a41565b90506020813d602011610a8d575b81610a7e60209383611856565b8101031261046f57518e610970565b3d9150610a71565b6040513d6000823e3d90fd5b6040516363ba9bff60e01b8152600490fd5b309061070b565b610ad9610ac561188e565b60e435906001600160a01b03339116612476565b610664565b634e487b7160e01b600052601160045260246000fd5b6003196101603682011261046f576001600160401b0360243581811161046f57610b22903690600401611679565b60443583811161046f57610b3a903690600401611679565b939060643582811161046f57610b54903690600401611679565b9490966001600160a01b0360a4351660a4350361046f578360c4351161046f5760609060c4353603011261046f5760e43583811161046f57610b9a9036906004016116d6565b9790956101043585811161046f57610bb6903690600401611736565b9590926101243582811161046f57610bd29036906004016116a6565b9490926101443590811161046f57610bee9036906004016116a6565b989097610bfb3447611bca565b9d60ff600080516020613e7d8339815191525460a01c1661045d576002600080516020613e3d833981519152541461044b57610e60610e7f9c6001600160a01b039f9a8f610e6d9a8f998f610e7a9f610e6699610e40918c6103849f8f90610cd06103739a8f98610cbb610c9494610ca2610c94936002600080516020613e3d83398151915255610c9460405193849260208401611c83565b03601f198101835282611856565b602081519101209a6040519283916020830195866119d5565b51902093604051928391602083019586611cfb565b519020604051917f9e454eb6b2b030e6c117f9568a4ebdfa17f78c1ff8b3b9b29bcccfacfc3c9e93602084015260043560408401526001600160a01b0360a435166060840152608083015260a08201528460c082015260c08152610d3381611785565b602081519101209160405192610d4884611785565b60ba84527f445a61704272696467655769746e657373207769746e65737329445a6170427260208501527f696467655769746e657373286279746573333220747849642c6164647265737360408501527f20757365722c62797465733332206578656375746f7246656573486173682c6260608501527f797465733332207377617044617461486173682c62797465733332206164617060808501527f746572446174614861736829546f6b656e5065726d697373696f6e732861646460a08501527f7265737320746f6b656e2c75696e7432353620616d6f756e742900000000000060c085015260c435600401903060a435613388565b610e4b3687876118d3565b6020815191012060043560843560a435613a02565b9c611e99565b3691611d96565b908660a435600435612251565b612e2a565b166001600160a01b0360a435166004357f2f784d79e0ac264e2b2b087fdba506b5763d153d8f2fe8077b404d20a2a7109e600080a46001600160a01b0360a4351633600435600080516020613e5d833981519152600080a46001600080516020613e3d833981519152554781811161040e57005b3461046f576003196101003682011261046f57610f0e611623565b610f16611639565b916001600160401b039160643583811161046f57610f38903690600401611679565b949092846084351161046f576060906084353603011261046f5760a43584811161046f57610f6a9036906004016116d6565b91909560c43586811161046f57610f85903690600401611706565b97909660e43590811161046f57610fa09036906004016116a6565b9260ff600080516020613e7d8339815191525460a01c1661045d57600080516020613e3d8339815191529860028a541461044b5760019a611170611181986111779661116b8c8f976001600160a01b039f60026103849a5560405161100d81610c948989602084016119d5565b602081519101208960405161102b81610c948d602083019586611a16565b519020604051917f4738b29017ecc1fd734e1aaeca797eeffe89932f62dc5c6054278717e53eea43602084015260043560408401526001600160a01b0386166060840152608083015260a082015260a0815261108681611804565b60208151910120926040519361109b85611804565b609e85527f445a6170537761705769746e657373207769746e65737329445a61705377617060208601527f5769746e657373286279746573333220747849642c616464726573732075736560408601527f722c62797465733332206578656375746f7246656573486173682c627974657360608601527f33322073776170446174614861736829546f6b656e5065726d697373696f6e7360808601527f286164647265737320746f6b656e2c75696e7432353620616d6f756e7429000060a0860152608435600401913090613388565b611e99565b3691611ab5565b918460043561211b565b1633600435600080516020613e5d833981519152600080a455005b6003196101603682011261046f576001600160401b039060243582811161046f576111cb903690600401611679565b91909260443581811161046f576111e6903690600401611679565b60649291923582811161046f57611201903690600401611679565b91909561120c61164f565b958460e4351161046f5760608160e4353603011261046f5760403661010319011261046f576101443594851161046f57604090853603011261046f576112523447611bca565b9760ff600080516020613e7d8339815191525460a01c1661045d576002600080516020613e3d833981519152541461044b576002600080516020613e3d833981519152556040516020810190602082526112b681610c94604082018a600401611bf8565b5190209560405161010435906001600160a01b03821680920361046f5760208101918252610124356040820152604081526112f0816117e9565b519020944260843510610439576001600160a01b03998a98611396611401976113bd958d61140a9b611321826123c2565b5490604051917f73b66d7df0c9bcf49e2a6a8b2e449d1d904327522a59905238572195a371ad0e602084015260043560408401526001600160a01b0384166060840152608083015260843560a083015260c08201528560e082015260e081526113898161183a565b6020815191012090613aac565b61139f8b613df5565b6113aa3687876118d3565b6020815191012060043560a4358d613a02565b6113ee60e4356004016113df6113d2826118a4565b91604460e4350190611c51565b91602460e4350135908b612692565b856113f7611877565b1661146a57612cac565b91600401612e6a565b168282166004357f2f784d79e0ac264e2b2b087fdba506b5763d153d8f2fe8077b404d20a2a7109e600080a41633600435600080516020613e5d833981519152600080a46001600080516020613e3d833981519152554781811161040e57005b61037361012435338861147b611877565b16612476565b3461046f5761012036600319011261046f5760043561149e611623565b906114a7611639565b916001600160401b039060843582811161046f576114c9903690600401611679565b909460a43584811161046f576114e39036906004016116a6565b60c49591953582811161046f576114fe9036906004016116d6565b99909660e43584811161046f57611519903690600401611706565b946101043590811161046f576115339036906004016116a6565b95909360ff600080516020613e7d8339815191525460a01c166116145750600080516020613e3d8339815191529b60028d541461044b578d8b60019f8f988f976001600160a01b039f8f906115fa9f611170986103849c6115f29f8d6102536115e08f936115ed9861116b9d60026115b793556040519283916020830193846119d5565b03916115cb601f1993848101835282611856565b51902094604051938491602083019687611a16565b5190209160643587613972565b612c4e565b91848761211b565b16903390600080516020613e5d833981519152600080a455005b6306d39fcd60e41b8152600490fd5b602435906001600160a01b038216820361046f57565b604435906001600160a01b038216820361046f57565b60c435906001600160a01b038216820361046f57565b35906001600160a01b038216820361046f57565b9181601f8401121561046f578235916001600160401b03831161046f576020838186019501011161046f57565b9181601f8401121561046f578235916001600160401b03831161046f576020808501948460051b01011161046f57565b9181601f8401121561046f578235916001600160401b03831161046f576020808501948460061b01011161046f57565b9181601f8401121561046f578235916001600160401b03831161046f5760208085019460a0850201011161046f57565b9181601f8401121561046f578235916001600160401b03831161046f5760208085019460c0850201011161046f57565b602080916001600160a01b0361177b82611665565b1684520135910152565b60e081019081106001600160401b0382111761042357604052565b60a081019081106001600160401b0382111761042357604052565b6001600160401b03811161042357604052565b604081019081106001600160401b0382111761042357604052565b606081019081106001600160401b0382111761042357604052565b60c081019081106001600160401b0382111761042357604052565b608081019081106001600160401b0382111761042357604052565b61010081019081106001600160401b0382111761042357604052565b90601f801991011681019081106001600160401b0382111761042357604052565b610104356001600160a01b038116810361046f5790565b60c4356001600160a01b038116810361046f5790565b356001600160a01b038116810361046f5790565b6001600160401b03811161042357601f01601f191660200190565b9291926118df826118b8565b916118ed6040519384611856565b82948184528183011161046f578281602093846000960137010152565b9080601f8301121561046f57816020611925933591016118d3565b90565b3590811515820361046f57565b91909160a08184031261046f576040519061194f826117a0565b81938135906001600160401b039182811161046f57830181601f8201121561046f5781816020611981933591016118d3565b845261198f60208401611665565b60208501526119a060408401611665565b6040850152606083013591821161046f57826119c5608094926119d09486940161190a565b606086015201611928565b910152565b602080825281018390526040908101929060005b8281106119f7575050505090565b90919293828082611a0a60019489611766565b019501939291016119e9565b6020808252808201849052604091820193916000915b838310611a3b57505050505090565b90919293946001906001600160a01b0380611a5589611665565b16825280611a64858a01611665565b1684830152611a74858901611665565b1681850152606087810135908201526080808801359082015260a090810196019493019190611a2c565b6001600160401b0381116104235760051b60200190565b929192611ac182611a9e565b604094611ad086519283611856565b819584835260208093019160a080960285019481861161046f57925b858410611afc5750505050505050565b868483031261046f578487918451611b13816117a0565b611b1c87611665565b8152611b29838801611665565b83820152611b38868801611665565b868201526060808801359082015260808088013590820152815201930192611aec565b92919092611b6884611a9e565b91611b766040519384611856565b829480845260208094019060051b83019282841161046f5780915b848310611ba057505050505050565b82356001600160401b03811161046f578691611bbf8684938601611935565b815201920191611b91565b91908203918211610ade57565b908060209392818452848401376000828201840152601f01601f1916010190565b6001600160a01b03611c0982611665565b1682526020810135601e198236030181121561046f5701602081359101906001600160401b03811161046f57803603821361046f576040838160206119259601520191611bd7565b903590601e198136030182121561046f57018035906001600160401b03821161046f5760200191813603831361046f57565b916020908082850183865252604084019160408260051b8601019484600080925b858410611cb657505050505050505090565b9091929394959697603f198282030188528835603e1985360301811215611cf75786611ce760019387839401611bf8565b9a01980196959401929190611ca4565b8380fd5b6020808252808201849052604091820193916000915b838310611d2057505050505090565b90919293946001906001600160a01b0380611d3a89611665565b16825280611d49858a01611665565b1684830152611d59858901611665565b1684820152606080880135908201526080808801359082015260a0611d7f818901611928565b15159082015260c090810196019493019190611d11565b929192611da282611a9e565b604094611db186519283611856565b819584835260208093019160c080960285019481861161046f57925b858410611ddd5750505050505050565b868483031261046f57825190878201908282106001600160401b03831117611e5e57889287928652611e0e87611665565b8152611e1b838801611665565b83820152611e2a868801611665565b86820152606080880135908201526080808801359082015260a0611e4f818901611928565b90820152815201930192611dcd565b60246000634e487b7160e01b81526041600452fd5b9190811015611e835760061b0190565b634e487b7160e01b600052603260045260246000fd5b60005b828110611ea857505050565b80611ee1611ec1611ebc6001948787611e73565b6118a4565b6020611ece848888611e73565b0135906001600160a01b03339116612476565b01611e9c565b60005b838110611efa5750506000910152565b8181015183820152602001611eea565b90602091611f2381518092818552858086019101611ee7565b601f01601f1916010190565b9060c080611f46845160e0855260e0850190611f0a565b936001600160a01b03806020830151166020860152806040830151166040860152806060830151166060860152608082015116608085015260a081015160a0850152015191015290565b9091602001906001600160a01b0391828151166000527f03ef279dff7badd98b43464ec17f797a88e435619b3aa2c30c6c31214479119560205260ff604060002054161561200a57501615611ff85715611fe657565b6040516357b3d85d60e11b8152600490fd5b604051637c13399160e11b8152600490fd5b5160405163740bb42360e11b81529083166004820152602490fd5b9061202f82611a9e565b60409061203e82519182611856565b838152809361204f601f1991611a9e565b019160005b8381106120615750505050565b602090825161206f81611785565b6060808252600084918183850152818785015283015260006080830152600060a0830152600060c0830152828601015201612054565b8051821015611e835760209160051b010190565b602080820190808352835180925260408301928160408460051b8301019501936000915b8483106120ed5750505050505090565b909192939495848061210b600193603f198682030187528a51611f2f565b98019301930191949392906120dd565b9190939280519060009461212e83612025565b955b83811061219057505050612145575b50505050565b6121847fc9a96626eddfa02e342d5a828eed18ad376bb804eed233dcba5ec5d792df2cc2916040519182916001600160a01b03809116971695826120b9565b0390a43880808061213f565b61219a81846120a5565b516121a582846120a5565b5180916001600160a01b03808251166060918284019283928684516121c992611f90565b818551169186602096878101928080808b81885116996040978888019b848d51169d5160809e8f8b0151926121fd95613623565b9d519e01511693511694511695511696519782519a61221b8c611785565b8b528a015288015286015284015260a083015260c082015261223d82896120a5565b5261224881886120a5565b50600101612130565b9190939280519060009461226483612025565b955b83811061227a575050506121455750505050565b80612287600192856120a5565b5161229282856120a5565b51906122ae826001600160a01b03835116606084015190611f90565b6122ea826001600160a01b038351166001600160a01b036020850151166001600160a01b03604086015116606086015191608087015193613623565b90306001600160a01b0382511614806123b6575b61238b575b6001600160a01b036020845194015116906001600160a01b038151166001600160a01b036020830151169060606001600160a01b03604085015116930151936040519661234f88611785565b8752602087015260408601526060850152608084015260a083015260c0820152612379828a6120a5565b5261238481896120a5565b5001612266565b6123b16001600160a01b036040830151168d6123ab608085015186611bca565b91612644565b612303565b5060a0810151156122fe565b6001600160a01b03166000527f4f9314598fc24317d901f4a94cc5def9e3c745b0f73ff0b0e154b9953457cf83602052604060002090565b3d15612425573d9061240b826118b8565b916124196040519384611856565b82523d6000602084013e565b606090565b6001600160a01b0381161561246457600080809381935af161244a6123fa565b501561245257565b604051633d2cec6f60e21b8152600490fd5b6040516321f7434560e01b8152600490fd5b6124ab926001600160a01b036040519363a9059cbb60e01b6020860152166024840152604483015260448252610a1c8261181f565b565b9081602091031261046f5751801515810361046f5790565b604051612523916001600160a01b03166124de826117ce565b6000806020958685527f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c656487860152868151910182855af161251d6123fa565b916125ab565b805190828215928315612593575b5050501561253c5750565b6084906040519062461bcd60e51b82526004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b6064820152fd5b6125a393508201810191016124ad565b388281612531565b9192901561260d57508151156125bf575090565b3b156125c85790565b60405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000006044820152606490fd5b8251909150156126205750805190602001fd5b60405162461bcd60e51b815260206004820152908190610906906024830190611f0a565b91908161265057505050565b6001600160a01b039283169273eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee840361268257506124ab925061242a565b811615612464576124ab92612476565b919290938101916000946040938484820312612c285783359560049182881015612b6157602090818701356001600160401b0397888211612948576126d892910161190a565b9760028103612950575087518801976060818a031261294c57818101519688820151996060830151918211612948576127179290840191018301612fcd565b916001600160a01b03807f0e1ba6b8f4f66ef33154e3c1bb6c4c32cda48e0a34207b9eeeb11bd92063322f541696818a5197612752896117ce565b1687528284880152895196612766886117e9565b87528387019889528987019a8b52895192612780846117ce565b30845284840152895191848301917f266a51557d4733337e3bc8128e6cd4856463d454dce2a9f9dfcb38e4f603714083521691828b820152306060820152606081526127cb8161181f565b519020917f445a61705472616e736665725769746e657373207769746e65737329445a61708a51946127fc866117a0565b607e86528501527f5472616e736665725769746e6573732861646472657373206f776e65722c61648a8501527f647265737320726563697069656e7429546f6b656e5065726d697373696f6e7360608501527f286164647265737320746f6b656e2c75696e7432353620616d6f756e742900006080850152873b1561294857918b9897969593918995938b519c8d9a8b998a986309be14ff60e11b8a5289019051906128ba91602080916001600160a01b0381511684520151910152565b51604488015251606487015280516001600160a01b031660848701526020015160a486015260c485015260e484015261010483016101409052610144830161290191611f0a565b8281036003190161012484015261291791611f0a565b03925af190811561293f575061292b575050565b61293582916117bb565b61293c5750565b80fd5b513d84823e3d90fd5b8b80fd5b8980fd5b80919892959794965099989915600014612b6557508051806129b2575b5050506124ab95965051936323b872dd60e01b908501526001600160a01b0380931660248501523060448501526064840152606483526129ac836117a0565b166124c5565b8160809181010312612b61578681015190838101519060ff8216809203612b5d5760806060820151910151906001600160a01b039283891694853b15612b5957875163d505accf60e01b8152948b1687860152306024860152604485018990526064850152608484015260a483015260c4820152898160e48183865af19081612b46575b50612b3957600191612a46612f2e565b6308c379a014612a70575b5050612a67576124ab9596505b8695388061296d565b513d87823e3d90fd5b612a78612f4c565b80612a84575b50612a51565b8451636eb1769f60e11b81526001600160a01b0389168184019081523060208201528c95509293919290918a918391908290819060400103915afa908115612b2f579086918c91612afe575b5010612adc5780612a7e565b83516352c3687b60e11b81529182018890528190610906906024830190611f0a565b8092508a8092503d8311612b28575b612b178183611856565b8101031261046f5785905138612ad0565b503d612b0d565b85513d8d823e3d90fd5b50506124ab959650612a5e565b612b52909a919a6117bb565b9838612a36565b8d80fd5b8a80fd5b8880fd5b6001919397509895939491979814600014612c1857612b926001600160a01b03809516928383308761300f565b837f0e1ba6b8f4f66ef33154e3c1bb6c4c32cda48e0a34207b9eeeb11bd92063322f541691823b15612c1457608492858796959387938a519b8c988997631b63c28b60e11b8952169087015230602487015260448601521660648401525af1918215612c0a575050612c015750565b6124ab906117bb565b51903d90823e3d90fd5b8580fd5b8551632091924d60e21b81528790fd5b8680fd5b9190811015611e835760051b81013590605e198136030182121561046f570190565b91909160005b828110612c615750505050565b80612ca6612c75611ebc6001948789612c2c565b6020612c8284888a612c2c565b013590612c9d612c9385898b612c2c565b6040810190611c51565b92909187612692565b01612c54565b908101602090818382031261046f5782356001600160401b039384821161046f570191604093848484031261046f57845193612ce7856117ce565b612cf081611665565b85528281013591821161046f570182601f8201121561046f57803590612d1582611a9e565b93612d2287519586611856565b828552838501908460608095028401019281841161046f578501915b838310612ded575050505050808301908282526001600160a01b0394857f0e1ba6b8f4f66ef33154e3c1bb6c4c32cda48e0a34207b9eeeb11bd92063322d5460081c169160009451945b858110612d9a57505050505050511690565b80612dc889612dac60019489516120a5565b5151168a8a511685612dbf858b516120a5565b51015191612644565b612de789612dd78389516120a5565b5151168686612dbf858b516120a5565b01612d88565b848383031261046f578585918a51612e04816117e9565b612e0d86611665565b815282860135838201528b8601358c820152815201920191612d3e565b90600091825b828110612e3d5750505050565b8060051b820135603e1983360301811215612e665790612e606001928401612e6a565b01612e30565b8480fd5b612e73816118a4565b6001600160a01b03811691826000527f03ef279dff7badd98b43464ec17f797a88e435619b3aa2c30c6c31214479119660205260ff6040600020541615612f1557600091612ec682602085940190611c51565b90816040519283928337810184815203915af490612ee26123fa565b9115612eec575050565b610906604051928392632e546bb560e21b84526004840152604060248401526044830190611f0a565b60405163616d132960e01b815260048101849052602490fd5b60009060033d11612f3b57565b905060046000803e60005160e01c90565b600060443d1061192557604051600319913d83016004833e81516001600160401b03918282113d602484011117612fa957818401948551938411612fb1573d85010160208487010111612fa9575061192592910160200190611856565b949350505050565b50949350505050565b519065ffffffffffff8216820361046f57565b81601f8201121561046f578051612fe3816118b8565b92612ff16040519485611856565b8184526020828401011161046f576119259160208085019101611ee7565b919091845191600095831561334a576001600160a01b037f0e1ba6b8f4f66ef33154e3c1bb6c4c32cda48e0a34207b9eeeb11bd92063322f5416938101956080828803126133465761306360208301612fba565b9361307060408401612fba565b9460608401519360808101516001600160401b039a8b82116133425761309d926020918201920101612fcd565b926040519960808b01908b82109082111761332e576001600160a01b0365ffffffffffff939284926040528189168d5216978860208d01521660408b0152166060890152604051976130ee896117e9565b885260208801916001600160a01b038816835260408901938452863b1561294c579089929160405194859384936302b67b5760e41b85526001600160a01b03169b8c60048601525180516001600160a01b0316602486015260208101516001600160a01b03166044860152604081015165ffffffffffff1660648601526060015165ffffffffffff166084850152516001600160a01b031660a48401525160c483015260e48201610100905261010482016131a891611f0a565b038183885af1908161331b575b50613313576001946131c5612f2e565b6308c379a0146131e8575b50505050506131dc5750565b604051903d90823e3d90fd5b6131f0612f4c565b93846131fd575b506131d0565b6001600160a01b039495965060609291606491868a99604051988996879563927da10560e01b875260048701521660248501521660448301525afa91821561330857859086936132a2575b506001600160a01b03161090811561328f575b5061326a5780808080806131f7565b6040516352c3687b60e11b815260206004820152908190610906906024830190611f0a565b905065ffffffffffff429116103861325b565b9250506060823d606011613300575b816132be60609383611856565b81010312612e665781516001600160a01b0381168103612c14576001600160a01b03906132f960406132f260208701612fba565b9501612fba565b5090613248565b3d91506132b1565b6040513d87823e3d90fd5b505050505050565b613327909791976117bb565b95386131b5565b634e487b7160e01b8c52604160045260248cfd5b8c80fd5b8780fd5b50505050505050565b903590601e198136030182121561046f57018035906001600160401b03821161046f57602001918160061b3603831361046f57565b9594919390946133988480613353565b9190506133a482611a9e565b916040976133b489519485611856565b818452601f196133c383611a9e565b0160005b8181106135ff57505060005b8281106135aa575050506001600160a01b0395867f0e1ba6b8f4f66ef33154e3c1bb6c4c32cda48e0a34207b9eeeb11bd92063322f541696873b1561046f57885163fe8ec1a760e01b815260c06004820152996101248b018835368a9003601e190181121561046f5789019889356020809b01926001600160401b03821161046f578160061b3603841361046f5791818f9c93928f939a9e9c9a60608f60c4909e9c9b9a99989e0152526101448d019a9060005b818110613570575050508281013560e48d015201356101048b015260031997888b82030160248c015281808d5192838152019c01918d6000905b838210613526575050505050936134fa60009a613509958b99958d99958b991660448a0152606489015285888303016084890152611f0a565b928584030160a4860152611bd7565b03925af190811561351c5750612c015750565b513d6000823e3d90fd5b82949a9c9e6001939294969798999a9c9e50613556818d51602080916001600160a01b0381511684520151910152565b0199019101918e9b99979695949391928e9d9b999d6134c1565b92949d5092809c9e9a9c8c61358d8498999a9b9c9e600195611766565b0195019101908f9c9391928f939e9c9a9e9b99989796959b613487565b6001906135b78980613353565b906135c6836020938493611e73565b01358c51916135d4836117ce565b6001600160a01b03861683528201526135ed82886120a5565b526135f881876120a5565b50016133d3565b6020908b5161360d816117ce565b60008152826000818301528289010152016133c7565b929594909193956080820191825115156000146138d55784905b61364782886138dc565b9260006001600160a01b0380971673eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee811460001461375c5750505b6000806020840192606089855116950194855191602083519301915af19061369c6123fa565b911561370757505050906107796136b392876138dc565b958087106136e9575090859291511590816136dc575b506136d357505050565b6124ab92612644565b82163014159050386136c9565b6044908760405191633b5d56ed60e11b835260048301526024820152fd5b86905116915191602083519301519163ffffffff60e01b808416936004861061090a57509061090691604051948594639c7cc24360e01b86526004860152166024840152606060448401526064830190611f0a565b90916040918883860151169283156138c5578051636eb1769f60e11b81523060048201526001600160a01b0385166024820152602093908481604481875afa9081156138bb57879161388e575b50106137b9575b50505050613676565b805163095ea7b360e01b8482018181526001600160a01b03871660248401526000196044808501919091528352909591949190879081906137fb606489611856565b87519082885af161380a6123fa565b8161385e575b5080613854575b15613824575b50506137b0565b61384995610a1c935192830152602482015285604482015260448152610a168161181f565b38808080808061381d565b50833b1515613817565b80518015925084908315613876575b50505038613810565b61388693508201810191016124ad565b38838161386d565b90508481813d83116138b4575b6138a58183611856565b81010312612c285751386137a9565b503d61389b565b83513d89823e3d90fd5b516363ba9bff60e01b8152600490fd5b309061363d565b6001600160a01b0380911660009173eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee821460001461390f575050503190565b6024602092939460405194859384926370a0823160e01b84521660048301525afa9182156131dc57809261394257505090565b9091506020823d821161396a575b8161395d60209383611856565b8101031261293c57505190565b3d9150613950565b94919095929395428110610439576124ab966139fd95613991886123c2565b54926040519360208501957fa16c8a285e5f0c5f850b82fc099a326b2edf744d13f9a742c5cfe1ff803a8c92875260408601526001600160a01b038a166060860152608085015260a084015260c083015260e082015260e081526139f48161183a565b51902084613aac565b613df5565b9491959295428210610439576124ab966139fd956001600160a01b0391827f0e1ba6b8f4f66ef33154e3c1bb6c4c32cda48e0a34207b9eeeb11bd92063322e541694613a4d8a6123c2565b546040519460208601967fcbfee2c0e15f500ddc78e4d48ba409a821bc03215264d8922169947bac0ef178885260408701528b166060860152608085015260a084015260c083015260e082015260e08152613aa78161183a565b519020905b9092613be790613be1613bef946040966b222d30b82b32b934b334b2b960a11b60208951613ad9816117ce565b600c81520152603160f81b60208951613af1816117ce565b600181520152875160208101907fd87cd6ef79d4e2b95e15ce8abf732db51ec771f1ca2edccf22a46c729ac5647282527fa1d9b1587d1cdcf2a70ea404b54a42fe06f3d0742dc8c87336986927bf1279428a8201527fc89efdaa54c0f20c7adf612882df0950f5a951637e0307cdcb4c672f298b8bc660608201524660808201523060a08201527fab458d135ef5ffc786fd5ac1655b88a6fdc7589e65e154b5381ad419272f0c6260c082015260c08152613bab81611785565b51902090885190602082019261190160f01b84526022830152604282015260428152613bd68161181f565b5190209236916118d3565b90613d2e565b929092613c14565b6001600160a01b03809116911603613c045750565b51636518c33d60e11b8152600490fd5b6005811015613d185780613c255750565b60018103613c725760405162461bcd60e51b815260206004820152601860248201527f45434453413a20696e76616c6964207369676e617475726500000000000000006044820152606490fd5b60028103613cbf5760405162461bcd60e51b815260206004820152601f60248201527f45434453413a20696e76616c6964207369676e6174757265206c656e677468006044820152606490fd5b600314613cc857565b60405162461bcd60e51b815260206004820152602260248201527f45434453413a20696e76616c6964207369676e6174757265202773272076616c604482015261756560f01b6064820152608490fd5b634e487b7160e01b600052602160045260246000fd5b906041815114600014613d5c57613d58916020820151906060604084015193015160001a90613d66565b9091565b5050600090600290565b9291907f7fffffffffffffffffffffffffffffff5d576e7357a4501ddfe92f46681b20a08311613de95791608094939160ff602094604051948552168484015260408301526060820152600093849182805260015afa15613ddc5781516001600160a01b03811615613dd6579190565b50600190565b50604051903d90823e3d90fd5b50505050600090600390565b6001600160a01b03166000527f4f9314598fc24317d901f4a94cc5def9e3c745b0f73ff0b0e154b9953457cf83602052604060002080546000198114610ade57600101905556fea4b36ced7e8b039500cc9c7c393a04e0c8af96ee265b143e79175cc5679ca5391aae47cb9aefcb27db14106e9ac749e835533faf1d2e9ab41173ae45c19d95e20e1ba6b8f4f66ef33154e3c1bb6c4c32cda48e0a34207b9eeeb11bd920633230a2646970667358221220cbd80c0002da528bd4294cb87b903bc5f901e8e1c716b0d00e7fcd182cf7597564736f6c63430008130033
Loading...
Loading
Loading...
Loading
Loading...
Loading
Net Worth in USD
$0.00
Net Worth in FRAX
0
Multichain Portfolio | 35 Chains
| Chain | Token | Portfolio % | Price | Amount | Value |
|---|
Loading...
Loading
Loading...
Loading
Loading...
Loading
[ Download: CSV Export ]
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.