Source Code
| Transaction Hash |
|
Block
|
From
|
To
|
|||||
|---|---|---|---|---|---|---|---|---|---|
Latest 1 internal transaction
Advanced mode:
| Parent Transaction Hash | Block | From | To | |||
|---|---|---|---|---|---|---|
| 25038670 | 150 days ago | Contract Creation | 0 FRAX |
Cross-Chain Transactions
Loading...
Loading
Contract Name:
WithdrawFacet
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 { LibDiamond } from "../Libraries/LibDiamond.sol";
import { LibAccess } from "../Libraries/LibAccess.sol";
import { LibAsset } from "../Libraries/LibAsset.sol";
import { IWithdrawFacet } from "../Interfaces/IWithdrawFacet.sol";
import { ReentrancyGuard } from "../Helpers/ReentrancyGuard.sol";
import { NotAContract, NoTransferToNullAddress } from "../Errors.sol";
/**
* @title WithdrawFacet
* @author DZap
* @notice Facet contract for withdrawing assets which are transferd by mistake
*/
contract WithdrawFacet is IWithdrawFacet, ReentrancyGuard {
error WithdrawFailed();
/* ========= MODIFIER ========= */
modifier onlyAuthorized() {
if (msg.sender != LibDiamond.contractOwner()) {
LibAccess.enforceAccessControl();
}
_;
}
/* ========= EXTERNAL ========= */
/// @inheritdoc IWithdrawFacet
function executeCallAndWithdraw(
address payable _callTo,
bytes calldata _callData,
address _token,
address _to,
uint256 _amount
) external onlyAuthorized nonReentrant {
// Check if the _callTo is a contract
bool success;
bool isContract = LibAsset.isContract(_callTo);
if (!isContract) revert NotAContract();
// solhint-disable-next-line avoid-low-level-calls
(success, ) = _callTo.call(_callData);
if (success) _withdrawToken(_token, _to, _amount);
else revert WithdrawFailed();
}
/// @inheritdoc IWithdrawFacet
function withdraw(address _token, address _to, uint256 _amount) external onlyAuthorized {
_withdrawToken(_token, _to, _amount);
}
/* ========= INTERNAL ========= */
function _withdrawToken(address _token, address _to, uint256 _amount) internal {
if (_to == address(0)) revert NoTransferToNullAddress();
LibAsset.transferToken(_token, _to, _amount);
emit LogWithdraw(_token, _to, _amount);
}
}// 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 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;
/**
* @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;
interface IDiamondCut {
enum FacetCutAction {
Add,
Replace,
Remove
}
// Add=0, Replace=1, Remove=2
struct FacetCut {
address facetAddress;
FacetCutAction action;
bytes4[] functionSelectors;
}
/// @notice Add/replace/remove any number of functions and optionally execute
/// a function with delegatecall
/// @param _diamondCut Contains the facet addresses and function selectors
/// @param _init The address of the contract or facet to execute _calldata
/// @param _calldata A function call, including function selector and arguments
/// _calldata is executed with delegatecall on _init
function diamondCut(FacetCut[] calldata _diamondCut, address _init, bytes calldata _calldata) external;
event DiamondCut(FacetCut[] _diamondCut, address _init, bytes _calldata);
}// 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;
/**
* @title IWithdrawFacet
* @author DZap
*/
interface IWithdrawFacet {
event LogWithdraw(address indexed tokenAddress, address to, uint256 amount);
/// @notice Execute call data and withdraw asset.
/// @param _callTo The address to execute the calldata on.
/// @param _callData The data to execute.
/// @param _token Asset to be withdrawn.
/// @param _to address to withdraw to.
/// @param _amount amount of asset to withdraw.
function executeCallAndWithdraw(address payable _callTo, bytes calldata _callData, address _token, address _to, uint256 _amount) external;
/// @notice Withdraw asset.
/// @param _token Asset to be withdrawn.
/// @param _to address to withdraw to.
/// @param _amount amount of asset to withdraw.
function withdraw(address _token, address _to, uint256 _amount) external;
}// SPDX-License-Identifier: MIT
pragma solidity 0.8.19;
import { CannotAuthorizeSelf, UnAuthorized } from "../Errors.sol";
struct AccessStorage {
mapping(bytes4 => mapping(address => bool)) execAccess;
}
/**
* @title LibAccess
* @author DZap
* @notice Provides functionality for managing method level access control
*/
library LibAccess {
/// Types ///
bytes32 internal constant _ACCESS_STORAGE_SLOT = keccak256("dzap.library.access.management");
/// Events ///
event AccessGranted(address indexed account, bytes4 indexed method);
event AccessRevoked(address indexed account, bytes4 indexed method);
/// @dev Fetch local storage
function accessStorage() internal pure returns (AccessStorage storage accStor) {
bytes32 position = _ACCESS_STORAGE_SLOT;
// solhint-disable-next-line no-inline-assembly
assembly {
accStor.slot := position
}
}
/// @notice Gives an address permission to execute a method
/// @param _selector The method selector to execute
/// @param _executor The address to grant permission to
function addAccess(bytes4 _selector, address _executor) internal {
if (_executor == address(this)) {
revert CannotAuthorizeSelf();
}
AccessStorage storage accStor = accessStorage();
accStor.execAccess[_selector][_executor] = true;
emit AccessGranted(_executor, _selector);
}
/// @notice Revokes permission to execute a method
/// @param _selector The method selector to execute
/// @param _executor The address to revoke permission from
function removeAccess(bytes4 _selector, address _executor) internal {
AccessStorage storage accStor = accessStorage();
accStor.execAccess[_selector][_executor] = false;
emit AccessRevoked(_executor, _selector);
}
/// @notice Enforces access control by reverting if `msg.sender`
/// has not been given permission to execute `msg.sig`
function enforceAccessControl() internal view {
AccessStorage storage accStor = accessStorage();
if (accStor.execAccess[msg.sig][msg.sender] != true) revert UnAuthorized();
}
}// 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;
/// https://github.com/Cryptorubic/multi-proxy-rubic/blob/master/src/Libraries/LibBytes.sol
library LibBytes {
// solhint-disable no-inline-assembly
// LibBytes specific errors
error SliceOverflow();
error SliceOutOfBounds();
error AddressOutOfBounds();
error UintOutOfBounds();
// -------------------------
function concat(bytes memory _preBytes, bytes memory _postBytes) internal pure returns (bytes memory) {
bytes memory tempBytes;
assembly {
// Get a location of some free memory and store it in tempBytes as
// Solidity does for memory variables.
tempBytes := mload(0x40)
// Store the length of the first bytes array at the beginning of
// the memory for tempBytes.
let length := mload(_preBytes)
mstore(tempBytes, length)
// Maintain a memory counter for the current write location in the
// temp bytes array by adding the 32 bytes for the array length to
// the starting location.
let mc := add(tempBytes, 0x20)
// Stop copying when the memory counter reaches the length of the
// first bytes array.
let end := add(mc, length)
for {
// Initialize a copy counter to the start of the _preBytes data,
// 32 bytes into its memory.
let cc := add(_preBytes, 0x20)
} lt(mc, end) {
// Increase both counters by 32 bytes each iteration.
mc := add(mc, 0x20)
cc := add(cc, 0x20)
} {
// Write the _preBytes data into the tempBytes memory 32 bytes
// at a time.
mstore(mc, mload(cc))
}
// Add the length of _postBytes to the current length of tempBytes
// and store it as the new length in the first 32 bytes of the
// tempBytes memory.
length := mload(_postBytes)
mstore(tempBytes, add(length, mload(tempBytes)))
// Move the memory counter back from a multiple of 0x20 to the
// actual end of the _preBytes data.
mc := end
// Stop copying when the memory counter reaches the new combined
// length of the arrays.
end := add(mc, length)
for {
let cc := add(_postBytes, 0x20)
} lt(mc, end) {
mc := add(mc, 0x20)
cc := add(cc, 0x20)
} {
mstore(mc, mload(cc))
}
// Update the free-memory pointer by padding our last write location
// to 32 bytes: add 31 bytes to the end of tempBytes to move to the
// next 32 byte block, then round down to the nearest multiple of
// 32. If the sum of the length of the two arrays is zero then add
// one before rounding down to leave a blank 32 bytes (the length block with 0).
mstore(
0x40,
and(
add(add(end, iszero(add(length, mload(_preBytes)))), 31),
not(31) // Round down to the nearest 32 bytes.
)
)
}
return tempBytes;
}
function concatStorage(bytes storage _preBytes, bytes memory _postBytes) internal {
assembly {
// Read the first 32 bytes of _preBytes storage, which is the length
// of the array. (We don't need to use the offset into the slot
// because arrays use the entire slot.)
let fslot := sload(_preBytes.slot)
// Arrays of 31 bytes or less have an even value in their slot,
// while longer arrays have an odd value. The actual length is
// the slot divided by two for odd values, and the lowest order
// byte divided by two for even values.
// If the slot is even, bitwise and the slot with 255 and divide by
// two to get the length. If the slot is odd, bitwise and the slot
// with -1 and divide by two.
let slength := div(and(fslot, sub(mul(0x100, iszero(and(fslot, 1))), 1)), 2)
let mlength := mload(_postBytes)
let newlength := add(slength, mlength)
// slength can contain both the length and contents of the array
// if length < 32 bytes so let's prepare for that
// v. http://solidity.readthedocs.io/en/latest/miscellaneous.html#layout-of-state-variables-in-storage
switch add(lt(slength, 32), lt(newlength, 32))
case 2 {
// Since the new array still fits in the slot, we just need to
// update the contents of the slot.
// uint256(bytes_storage) = uint256(bytes_storage) + uint256(bytes_memory) + new_length
sstore(
_preBytes.slot,
// all the modifications to the slot are inside this
// next block
add(
// we can just add to the slot contents because the
// bytes we want to change are the LSBs
fslot,
add(
mul(
div(
// load the bytes from memory
mload(add(_postBytes, 0x20)),
// zero all bytes to the right
exp(0x100, sub(32, mlength))
),
// and now shift left the number of bytes to
// leave space for the length in the slot
exp(0x100, sub(32, newlength))
),
// increase length by the double of the memory
// bytes length
mul(mlength, 2)
)
)
)
}
case 1 {
// The stored value fits in the slot, but the combined value
// will exceed it.
// get the keccak hash to get the contents of the array
mstore(0x0, _preBytes.slot)
let sc := add(keccak256(0x0, 0x20), div(slength, 32))
// save new length
sstore(_preBytes.slot, add(mul(newlength, 2), 1))
// The contents of the _postBytes array start 32 bytes into
// the structure. Our first read should obtain the `submod`
// bytes that can fit into the unused space in the last word
// of the stored array. To get this, we read 32 bytes starting
// from `submod`, so the data we read overlaps with the array
// contents by `submod` bytes. Masking the lowest-order
// `submod` bytes allows us to add that value directly to the
// stored value.
let submod := sub(32, slength)
let mc := add(_postBytes, submod)
let end := add(_postBytes, mlength)
let mask := sub(exp(0x100, submod), 1)
sstore(sc, add(and(fslot, 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00), and(mload(mc), mask)))
for {
mc := add(mc, 0x20)
sc := add(sc, 1)
} lt(mc, end) {
sc := add(sc, 1)
mc := add(mc, 0x20)
} {
sstore(sc, mload(mc))
}
mask := exp(0x100, sub(mc, end))
sstore(sc, mul(div(mload(mc), mask), mask))
}
default {
// get the keccak hash to get the contents of the array
mstore(0x0, _preBytes.slot)
// Start copying to the last used word of the stored array.
let sc := add(keccak256(0x0, 0x20), div(slength, 32))
// save new length
sstore(_preBytes.slot, add(mul(newlength, 2), 1))
// Copy over the first `submod` bytes of the new data as in
// case 1 above.
let slengthmod := mod(slength, 32)
let submod := sub(32, slengthmod)
let mc := add(_postBytes, submod)
let end := add(_postBytes, mlength)
let mask := sub(exp(0x100, submod), 1)
sstore(sc, add(sload(sc), and(mload(mc), mask)))
for {
sc := add(sc, 1)
mc := add(mc, 0x20)
} lt(mc, end) {
sc := add(sc, 1)
mc := add(mc, 0x20)
} {
sstore(sc, mload(mc))
}
mask := exp(0x100, sub(mc, end))
sstore(sc, mul(div(mload(mc), mask), mask))
}
}
}
function slice(bytes memory _bytes, uint256 _start, uint256 _length) internal pure returns (bytes memory) {
if (_length + 31 < _length) revert SliceOverflow();
if (_bytes.length < _start + _length) revert SliceOutOfBounds();
bytes memory tempBytes;
assembly {
switch iszero(_length)
case 0 {
// Get a location of some free memory and store it in tempBytes as
// Solidity does for memory variables.
tempBytes := mload(0x40)
// The first word of the slice result is potentially a partial
// word read from the original array. To read it, we calculate
// the length of that partial word and start copying that many
// bytes into the array. The first word we copy will start with
// data we don't care about, but the last `lengthmod` bytes will
// land at the beginning of the contents of the new array. When
// we're done copying, we overwrite the full first word with
// the actual length of the slice.
let lengthmod := and(_length, 31)
// The multiplication in the next line is necessary
// because when slicing multiples of 32 bytes (lengthmod == 0)
// the following copy loop was copying the origin's length
// and then ending prematurely not copying everything it should.
let mc := add(add(tempBytes, lengthmod), mul(0x20, iszero(lengthmod)))
let end := add(mc, _length)
for {
// The multiplication in the next line has the same exact purpose
// as the one above.
let cc := add(add(add(_bytes, lengthmod), mul(0x20, iszero(lengthmod))), _start)
} lt(mc, end) {
mc := add(mc, 0x20)
cc := add(cc, 0x20)
} {
mstore(mc, mload(cc))
}
mstore(tempBytes, _length)
//update free-memory pointer
//allocating the array padded to 32 bytes like the compiler does now
mstore(0x40, and(add(mc, 31), not(31)))
}
//if we want a zero-length slice let's just return a zero-length array
default {
tempBytes := mload(0x40)
//zero out the 32 bytes slice we are about to return
//we need to do it because Solidity does not garbage collect
mstore(tempBytes, 0)
mstore(0x40, add(tempBytes, 0x20))
}
}
return tempBytes;
}
function toAddress(bytes memory _bytes, uint256 _start) internal pure returns (address) {
if (_bytes.length < _start + 20) {
revert AddressOutOfBounds();
}
address tempAddress;
assembly {
tempAddress := div(mload(add(add(_bytes, 0x20), _start)), 0x1000000000000000000000000)
}
return tempAddress;
}
function toUint8(bytes memory _bytes, uint256 _start) internal pure returns (uint8) {
if (_bytes.length < _start + 1) {
revert UintOutOfBounds();
}
uint8 tempUint;
assembly {
tempUint := mload(add(add(_bytes, 0x1), _start))
}
return tempUint;
}
function toUint16(bytes memory _bytes, uint256 _start) internal pure returns (uint16) {
if (_bytes.length < _start + 2) {
revert UintOutOfBounds();
}
uint16 tempUint;
assembly {
tempUint := mload(add(add(_bytes, 0x2), _start))
}
return tempUint;
}
function toUint32(bytes memory _bytes, uint256 _start) internal pure returns (uint32) {
if (_bytes.length < _start + 4) {
revert UintOutOfBounds();
}
uint32 tempUint;
assembly {
tempUint := mload(add(add(_bytes, 0x4), _start))
}
return tempUint;
}
function toUint64(bytes memory _bytes, uint256 _start) internal pure returns (uint64) {
if (_bytes.length < _start + 8) {
revert UintOutOfBounds();
}
uint64 tempUint;
assembly {
tempUint := mload(add(add(_bytes, 0x8), _start))
}
return tempUint;
}
function toUint96(bytes memory _bytes, uint256 _start) internal pure returns (uint96) {
if (_bytes.length < _start + 12) {
revert UintOutOfBounds();
}
uint96 tempUint;
assembly {
tempUint := mload(add(add(_bytes, 0xc), _start))
}
return tempUint;
}
function toUint128(bytes memory _bytes, uint256 _start) internal pure returns (uint128) {
if (_bytes.length < _start + 16) {
revert UintOutOfBounds();
}
uint128 tempUint;
assembly {
tempUint := mload(add(add(_bytes, 0x10), _start))
}
return tempUint;
}
function toUint256(bytes memory _bytes, uint256 _start) internal pure returns (uint256) {
if (_bytes.length < _start + 32) {
revert UintOutOfBounds();
}
uint256 tempUint;
assembly {
tempUint := mload(add(add(_bytes, 0x20), _start))
}
return tempUint;
}
function toBytes32(bytes memory _bytes, uint256 _start) internal pure returns (bytes32) {
if (_bytes.length < _start + 32) {
revert UintOutOfBounds();
}
bytes32 tempBytes32;
assembly {
tempBytes32 := mload(add(add(_bytes, 0x20), _start))
}
return tempBytes32;
}
function equal(bytes memory _preBytes, bytes memory _postBytes) internal pure returns (bool) {
bool success = true;
assembly {
let length := mload(_preBytes)
// if lengths don't match the arrays are not equal
switch eq(length, mload(_postBytes))
case 1 {
// cb is a circuit breaker in the for loop since there's
// no said feature for inline assembly loops
// cb = 1 - don't breaker
// cb = 0 - break
let cb := 1
let mc := add(_preBytes, 0x20)
let end := add(mc, length)
for {
let cc := add(_postBytes, 0x20)
// the next line is the loop condition:
// while(uint256(mc < end) + cb == 2)
} eq(add(lt(mc, end), cb), 2) {
mc := add(mc, 0x20)
cc := add(cc, 0x20)
} {
// if any of these checks fails then arrays are not equal
if iszero(eq(mload(mc), mload(cc))) {
// unsuccess:
success := 0
cb := 0
}
}
}
default {
// unsuccess:
success := 0
}
}
return success;
}
function equalStorage(bytes storage _preBytes, bytes memory _postBytes) internal view returns (bool) {
bool success = true;
assembly {
// we know _preBytes_offset is 0
let fslot := sload(_preBytes.slot)
// Decode the length of the stored array like in concatStorage().
let slength := div(and(fslot, sub(mul(0x100, iszero(and(fslot, 1))), 1)), 2)
let mlength := mload(_postBytes)
// if lengths don't match the arrays are not equal
switch eq(slength, mlength)
case 1 {
// slength can contain both the length and contents of the array
// if length < 32 bytes so let's prepare for that
// v. http://solidity.readthedocs.io/en/latest/miscellaneous.html#layout-of-state-variables-in-storage
if iszero(iszero(slength)) {
switch lt(slength, 32)
case 1 {
// blank the last byte which is the length
fslot := mul(div(fslot, 0x100), 0x100)
if iszero(eq(fslot, mload(add(_postBytes, 0x20)))) {
// unsuccess:
success := 0
}
}
default {
// cb is a circuit breaker in the for loop since there's
// no said feature for inline assembly loops
// cb = 1 - don't breaker
// cb = 0 - break
let cb := 1
// get the keccak hash to get the contents of the array
mstore(0x0, _preBytes.slot)
let sc := keccak256(0x0, 0x20)
let mc := add(_postBytes, 0x20)
let end := add(mc, mlength)
// the next line is the loop condition:
// while(uint256(mc < end) + cb == 2)
// solhint-disable-next-line no-empty-blocks
for {
} eq(add(lt(mc, end), cb), 2) {
sc := add(sc, 1)
mc := add(mc, 0x20)
} {
if iszero(eq(sload(sc), mload(mc))) {
// unsuccess:
success := 0
cb := 0
}
}
}
}
}
default {
// unsuccess:
success := 0
}
}
return success;
}
function getFirst4Bytes(bytes memory data) internal pure returns (bytes4 outBytes4) {
if (data.length == 0) {
return 0x0;
}
assembly {
outBytes4 := mload(add(data, 32))
}
}
}// SPDX-License-Identifier: MIT
pragma solidity 0.8.19;
import { IDiamondCut } from "../Interfaces/IDiamondCut.sol";
import { LibUtil } from "../Libraries/LibUtil.sol";
import { OnlyContractOwner } from "../Errors.sol";
/// Implementation of EIP-2535 Diamond Standard
/// https://eips.ethereum.org/EIPS/eip-2535
library LibDiamond {
bytes32 internal constant DIAMOND_STORAGE_POSITION = keccak256("diamond.standard.diamond.storage");
// Diamond specific errors
error IncorrectFacetCutAction();
error NoSelectorsInFace();
error FunctionAlreadyExists();
error FacetAddressIsZero();
error FacetAddressIsNotZero();
error FacetContainsNoCode();
error FunctionDoesNotExist();
error FunctionIsImmutable();
error InitZeroButCalldataNotEmpty();
error CalldataEmptyButInitNotZero();
error InitReverted(bytes reason);
// ----------------
struct FacetAddressAndPosition {
address facetAddress;
uint96 functionSelectorPosition; // position in facetFunctionSelectors.functionSelectors array
}
struct FacetFunctionSelectors {
bytes4[] functionSelectors;
uint256 facetAddressPosition; // position of facetAddress in facetAddresses array
}
struct DiamondStorage {
// maps function selector to the facet address and
// the position of the selector in the facetFunctionSelectors.selectors array
mapping(bytes4 => FacetAddressAndPosition) selectorToFacetAndPosition;
// maps facet addresses to function selectors
mapping(address => FacetFunctionSelectors) facetFunctionSelectors;
// facet addresses
address[] facetAddresses;
// Used to query if a contract implements an interface.
// Used to implement ERC-165.
mapping(bytes4 => bool) supportedInterfaces;
// owner of the contract
address contractOwner;
}
function diamondStorage() internal pure returns (DiamondStorage storage ds) {
bytes32 position = DIAMOND_STORAGE_POSITION;
// solhint-disable-next-line no-inline-assembly
assembly {
ds.slot := position
}
}
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
function setContractOwner(address _newOwner) internal {
DiamondStorage storage ds = diamondStorage();
address previousOwner = ds.contractOwner;
ds.contractOwner = _newOwner;
emit OwnershipTransferred(previousOwner, _newOwner);
}
function contractOwner() internal view returns (address contractOwner_) {
contractOwner_ = diamondStorage().contractOwner;
}
function enforceIsContractOwner() internal view {
if (msg.sender != diamondStorage().contractOwner) revert OnlyContractOwner();
}
event DiamondCut(IDiamondCut.FacetCut[] _diamondCut, address _init, bytes _calldata);
// Internal function version of diamondCut
function diamondCut(IDiamondCut.FacetCut[] memory _diamondCut, address _init, bytes memory _calldata) internal {
for (uint256 facetIndex; facetIndex < _diamondCut.length; ) {
IDiamondCut.FacetCutAction action = _diamondCut[facetIndex].action;
if (action == IDiamondCut.FacetCutAction.Add) {
addFunctions(_diamondCut[facetIndex].facetAddress, _diamondCut[facetIndex].functionSelectors);
} else if (action == IDiamondCut.FacetCutAction.Replace) {
replaceFunctions(_diamondCut[facetIndex].facetAddress, _diamondCut[facetIndex].functionSelectors);
} else if (action == IDiamondCut.FacetCutAction.Remove) {
removeFunctions(_diamondCut[facetIndex].facetAddress, _diamondCut[facetIndex].functionSelectors);
} else {
revert IncorrectFacetCutAction();
}
unchecked {
++facetIndex;
}
}
emit DiamondCut(_diamondCut, _init, _calldata);
initializeDiamondCut(_init, _calldata);
}
function addFunctions(address _facetAddress, bytes4[] memory _functionSelectors) internal {
if (_functionSelectors.length == 0) {
revert NoSelectorsInFace();
}
DiamondStorage storage ds = diamondStorage();
if (LibUtil.isZeroAddress(_facetAddress)) {
revert FacetAddressIsZero();
}
uint96 selectorPosition = uint96(ds.facetFunctionSelectors[_facetAddress].functionSelectors.length);
// add new facet address if it does not exist
if (selectorPosition == 0) {
addFacet(ds, _facetAddress);
}
for (uint256 selectorIndex; selectorIndex < _functionSelectors.length; ) {
bytes4 selector = _functionSelectors[selectorIndex];
address oldFacetAddress = ds.selectorToFacetAndPosition[selector].facetAddress;
if (!LibUtil.isZeroAddress(oldFacetAddress)) {
revert FunctionAlreadyExists();
}
addFunction(ds, selector, selectorPosition, _facetAddress);
unchecked {
++selectorPosition;
++selectorIndex;
}
}
}
function replaceFunctions(address _facetAddress, bytes4[] memory _functionSelectors) internal {
if (_functionSelectors.length == 0) {
revert NoSelectorsInFace();
}
DiamondStorage storage ds = diamondStorage();
if (LibUtil.isZeroAddress(_facetAddress)) {
revert FacetAddressIsZero();
}
uint96 selectorPosition = uint96(ds.facetFunctionSelectors[_facetAddress].functionSelectors.length);
// add new facet address if it does not exist
if (selectorPosition == 0) {
addFacet(ds, _facetAddress);
}
for (uint256 selectorIndex; selectorIndex < _functionSelectors.length; ) {
bytes4 selector = _functionSelectors[selectorIndex];
address oldFacetAddress = ds.selectorToFacetAndPosition[selector].facetAddress;
if (oldFacetAddress == _facetAddress) {
revert FunctionAlreadyExists();
}
removeFunction(ds, oldFacetAddress, selector);
addFunction(ds, selector, selectorPosition, _facetAddress);
unchecked {
++selectorPosition;
++selectorIndex;
}
}
}
function removeFunctions(address _facetAddress, bytes4[] memory _functionSelectors) internal {
if (_functionSelectors.length == 0) {
revert NoSelectorsInFace();
}
DiamondStorage storage ds = diamondStorage();
// if function does not exist then do nothing and return
if (!LibUtil.isZeroAddress(_facetAddress)) {
revert FacetAddressIsNotZero();
}
for (uint256 selectorIndex; selectorIndex < _functionSelectors.length; ) {
bytes4 selector = _functionSelectors[selectorIndex];
address oldFacetAddress = ds.selectorToFacetAndPosition[selector].facetAddress;
removeFunction(ds, oldFacetAddress, selector);
unchecked {
++selectorIndex;
}
}
}
function addFacet(DiamondStorage storage ds, address _facetAddress) internal {
enforceHasContractCode(_facetAddress);
ds.facetFunctionSelectors[_facetAddress].facetAddressPosition = ds.facetAddresses.length;
ds.facetAddresses.push(_facetAddress);
}
function addFunction(DiamondStorage storage ds, bytes4 _selector, uint96 _selectorPosition, address _facetAddress) internal {
ds.selectorToFacetAndPosition[_selector].functionSelectorPosition = _selectorPosition;
ds.facetFunctionSelectors[_facetAddress].functionSelectors.push(_selector);
ds.selectorToFacetAndPosition[_selector].facetAddress = _facetAddress;
}
function removeFunction(DiamondStorage storage ds, address _facetAddress, bytes4 _selector) internal {
if (LibUtil.isZeroAddress(_facetAddress)) {
revert FunctionDoesNotExist();
}
// an immutable function is a function defined directly in a diamond
if (_facetAddress == address(this)) {
revert FunctionIsImmutable();
}
// replace selector with last selector, then delete last selector
uint256 selectorPosition = ds.selectorToFacetAndPosition[_selector].functionSelectorPosition;
uint256 lastSelectorPosition = ds.facetFunctionSelectors[_facetAddress].functionSelectors.length - 1;
// if not the same then replace _selector with lastSelector
if (selectorPosition != lastSelectorPosition) {
bytes4 lastSelector = ds.facetFunctionSelectors[_facetAddress].functionSelectors[lastSelectorPosition];
ds.facetFunctionSelectors[_facetAddress].functionSelectors[selectorPosition] = lastSelector;
ds.selectorToFacetAndPosition[lastSelector].functionSelectorPosition = uint96(selectorPosition);
}
// delete the last selector
ds.facetFunctionSelectors[_facetAddress].functionSelectors.pop();
delete ds.selectorToFacetAndPosition[_selector];
// if no more selectors for facet address then delete the facet address
if (lastSelectorPosition == 0) {
// replace facet address with last facet address and delete last facet address
uint256 lastFacetAddressPosition = ds.facetAddresses.length - 1;
uint256 facetAddressPosition = ds.facetFunctionSelectors[_facetAddress].facetAddressPosition;
if (facetAddressPosition != lastFacetAddressPosition) {
address lastFacetAddress = ds.facetAddresses[lastFacetAddressPosition];
ds.facetAddresses[facetAddressPosition] = lastFacetAddress;
ds.facetFunctionSelectors[lastFacetAddress].facetAddressPosition = facetAddressPosition;
}
ds.facetAddresses.pop();
delete ds.facetFunctionSelectors[_facetAddress].facetAddressPosition;
}
}
function initializeDiamondCut(address _init, bytes memory _calldata) internal {
if (LibUtil.isZeroAddress(_init)) {
if (_calldata.length != 0) {
revert InitZeroButCalldataNotEmpty();
}
} else {
if (_calldata.length == 0) {
revert CalldataEmptyButInitNotZero();
}
if (_init != address(this)) {
enforceHasContractCode(_init);
}
// solhint-disable-next-line avoid-low-level-calls
(bool success, bytes memory error) = _init.delegatecall(_calldata);
if (!success) {
revert InitReverted(error);
}
}
}
function enforceHasContractCode(address _contract) internal view {
uint256 contractSize;
// solhint-disable-next-line no-inline-assembly
assembly {
contractSize := extcodesize(_contract)
}
if (contractSize == 0) {
revert FacetContainsNoCode();
}
}
}// 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 "./LibBytes.sol";
library LibUtil {
using LibBytes for bytes;
function getRevertMsg(bytes memory _res) internal pure returns (string memory) {
if (_res.length < 68) return string(_res);
bytes memory revertData = _res.slice(4, _res.length - 4); // Remove the selector which is the first 4 bytes
return abi.decode(revertData, (string)); // All that remains is the revert string
}
/// @notice Determines whether the given address is the zero address
/// @param addr The address to verify
/// @return Boolean indicating if the address is the zero address
function isZeroAddress(address addr) internal pure returns (bool) {
return addr == address(0);
}
}// 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":[],"name":"NativeTransferFailed","type":"error"},{"inputs":[],"name":"NoTransferToNullAddress","type":"error"},{"inputs":[],"name":"NotAContract","type":"error"},{"inputs":[],"name":"ReentrancyError","type":"error"},{"inputs":[],"name":"UnAuthorized","type":"error"},{"inputs":[],"name":"WithdrawFailed","type":"error"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"tokenAddress","type":"address"},{"indexed":false,"internalType":"address","name":"to","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"LogWithdraw","type":"event"},{"inputs":[{"internalType":"address payable","name":"_callTo","type":"address"},{"internalType":"bytes","name":"_callData","type":"bytes"},{"internalType":"address","name":"_token","type":"address"},{"internalType":"address","name":"_to","type":"address"},{"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"executeCallAndWithdraw","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_token","type":"address"},{"internalType":"address","name":"_to","type":"address"},{"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"withdraw","outputs":[],"stateMutability":"nonpayable","type":"function"}]Contract Creation Code
6080806040523461001657610651908161001c8239f35b600080fdfe608060405260048036101561001357600080fd5b600090813560e01c80631458d7ad146100b85763d9caed121461003557600080fd5b346100b45760603660031901126100b457356001600160a01b039081811681036100b05760243582811681036100ac5761009c927fc8fcad8db84d3cc18b4c41d551ea0ee66dd599cde068d998e57d5e09332c13205416330361009f575b60443591610292565b80f35b6100a76104e2565b610093565b8380fd5b8280fd5b5080fd5b50346100b45760a03660031901126100b4578035906001600160a01b038083168093036100ac576024359167ffffffffffffffff9384841161021657366023850112156102165783820135948511610216573660248686010111610216576044359383851685036102125760643593808516850361020e577fc8fcad8db84d3cc18b4c41d551ea0ee66dd599cde068d998e57d5e09332c132054163303610201575b7fa4b36ced7e8b039500cc9c7c393a04e0c8af96ee265b143e79175cc5679ca5399560028754146101f05760028755823b156101df5791602488809493848295604051948593018337810182815203925af16101b4610252565b50156101d05750600192916101cc9160843591610292565b5580f35b604051631d42c86760e21b8152fd5b6040516309ee12d560e01b81528490fd5b6040516329f745a760e01b81528490fd5b6102096104e2565b61015a565b8780fd5b8680fd5b8580fd5b90601f8019910116810190811067ffffffffffffffff82111761023c57604052565b634e487b7160e01b600052604160045260246000fd5b3d1561028d573d9067ffffffffffffffff821161023c5760405191610281601f8201601f19166020018461021a565b82523d6000602084013e565b606090565b9190916001600160a01b0390818416156104d057826102f3575b604080516001600160a01b039095168552602085019390935216917f9207361cc2a04b9c7a06691df1eb87c6a63957ae88bf01d0d18c81e3d127209991819081015b0390a2565b80821673eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee81036103695750600080808086885af1610323610252565b5015610357576102ee7f9207361cc2a04b9c7a06691df1eb87c6a63957ae88bf01d0d18c81e3d1272099935b9350506102ac565b604051633d2cec6f60e21b8152600490fd5b60405163a9059cbb60e01b60208083019182526001600160a01b03881660248401526044808401889052835294959394929091906103a860648361021a565b60405190604082019282841067ffffffffffffffff85111761023c5761040d936040528583527f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c656486840152600080958192519082855af1610407610252565b91610547565b8051918215918483156104a9575b5050509050156104525750906102ee7f9207361cc2a04b9c7a06691df1eb87c6a63957ae88bf01d0d18c81e3d1272099939261034f565b6084906040519062461bcd60e51b82526004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b6064820152fd5b9193818094500103126100b4578201519081151582036104cd57508038808461041b565b80fd5b6040516321f7434560e01b8152600490fd5b63ffffffff60e01b600035166000527f5d54ae78bb256b3b2ab9aba21ec80ea50728352673b79651649d3494dfcade6a602052604060002033600052602052600160ff6040600020541615150361053557565b60405163be24598360e01b8152600490fd5b919290156105a9575081511561055b575090565b3b156105645790565b60405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000006044820152606490fd5b8251909150156105bc5750805190602001fd5b6040519062461bcd60e51b82528160208060048301528251908160248401526000935b828510610602575050604492506000838284010152601f80199101168101030190fd5b84810182015186860160440152938101938593506105df56fea264697066735822122073ab85478185b0bf0444e72b9192b31390aa68e4a992735f94992a8d6c0c238664736f6c63430008130033
Deployed Bytecode
0x608060405260048036101561001357600080fd5b600090813560e01c80631458d7ad146100b85763d9caed121461003557600080fd5b346100b45760603660031901126100b457356001600160a01b039081811681036100b05760243582811681036100ac5761009c927fc8fcad8db84d3cc18b4c41d551ea0ee66dd599cde068d998e57d5e09332c13205416330361009f575b60443591610292565b80f35b6100a76104e2565b610093565b8380fd5b8280fd5b5080fd5b50346100b45760a03660031901126100b4578035906001600160a01b038083168093036100ac576024359167ffffffffffffffff9384841161021657366023850112156102165783820135948511610216573660248686010111610216576044359383851685036102125760643593808516850361020e577fc8fcad8db84d3cc18b4c41d551ea0ee66dd599cde068d998e57d5e09332c132054163303610201575b7fa4b36ced7e8b039500cc9c7c393a04e0c8af96ee265b143e79175cc5679ca5399560028754146101f05760028755823b156101df5791602488809493848295604051948593018337810182815203925af16101b4610252565b50156101d05750600192916101cc9160843591610292565b5580f35b604051631d42c86760e21b8152fd5b6040516309ee12d560e01b81528490fd5b6040516329f745a760e01b81528490fd5b6102096104e2565b61015a565b8780fd5b8680fd5b8580fd5b90601f8019910116810190811067ffffffffffffffff82111761023c57604052565b634e487b7160e01b600052604160045260246000fd5b3d1561028d573d9067ffffffffffffffff821161023c5760405191610281601f8201601f19166020018461021a565b82523d6000602084013e565b606090565b9190916001600160a01b0390818416156104d057826102f3575b604080516001600160a01b039095168552602085019390935216917f9207361cc2a04b9c7a06691df1eb87c6a63957ae88bf01d0d18c81e3d127209991819081015b0390a2565b80821673eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee81036103695750600080808086885af1610323610252565b5015610357576102ee7f9207361cc2a04b9c7a06691df1eb87c6a63957ae88bf01d0d18c81e3d1272099935b9350506102ac565b604051633d2cec6f60e21b8152600490fd5b60405163a9059cbb60e01b60208083019182526001600160a01b03881660248401526044808401889052835294959394929091906103a860648361021a565b60405190604082019282841067ffffffffffffffff85111761023c5761040d936040528583527f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c656486840152600080958192519082855af1610407610252565b91610547565b8051918215918483156104a9575b5050509050156104525750906102ee7f9207361cc2a04b9c7a06691df1eb87c6a63957ae88bf01d0d18c81e3d1272099939261034f565b6084906040519062461bcd60e51b82526004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b6064820152fd5b9193818094500103126100b4578201519081151582036104cd57508038808461041b565b80fd5b6040516321f7434560e01b8152600490fd5b63ffffffff60e01b600035166000527f5d54ae78bb256b3b2ab9aba21ec80ea50728352673b79651649d3494dfcade6a602052604060002033600052602052600160ff6040600020541615150361053557565b60405163be24598360e01b8152600490fd5b919290156105a9575081511561055b575090565b3b156105645790565b60405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000006044820152606490fd5b8251909150156105bc5750805190602001fd5b6040519062461bcd60e51b82528160208060048301528251908160248401526000935b828510610602575050604492506000838284010152601f80199101168101030190fd5b84810182015186860160440152938101938593506105df56fea264697066735822122073ab85478185b0bf0444e72b9192b31390aa68e4a992735f94992a8d6c0c238664736f6c63430008130033
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.