Source Code
| Transaction Hash |
|
Block
|
From
|
To
|
|||||
|---|---|---|---|---|---|---|---|---|---|
Latest 1 internal transaction
Advanced mode:
| Parent Transaction Hash | Block | From | To | |||
|---|---|---|---|---|---|---|
| 24938936 | 154 days ago | Contract Creation | 0 FRAX |
Cross-Chain Transactions
Loading...
Loading
Contract Name:
WhitelistingManagerFacet
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 { AuthorizationGuard } from "../Helpers/AuthorizationGuard.sol";
import { LibAllowList } from "../Libraries/LibAllowList.sol";
import { IWhitelistingManagerFacet } from "../Interfaces/IWhitelistingManagerFacet.sol";
/**
* @title WhitelistingManagerFacet
* @author DZap
* @notice Facet contract for managing approved DEXs, Bridges and Adapters
*/
contract WhitelistingManagerFacet is IWhitelistingManagerFacet, AuthorizationGuard {
// Events for transparency and monitoring
/* ========= VIEWS ========= */
/// @inheritdoc IWhitelistingManagerFacet
function isDexWhitelisted(address _dex) external view returns (bool) {
return LibAllowList.isDexWhitelisted(_dex);
}
/// @inheritdoc IWhitelistingManagerFacet
function isBridgeWhitelisted(address _bridge) external view returns (bool) {
return LibAllowList.isBridgeWhitelisted(_bridge);
}
/// @inheritdoc IWhitelistingManagerFacet
function isAdapterWhitelisted(address _adapter) external view returns (bool) {
return LibAllowList.isAdapterWhitelisted(_adapter);
}
/* ========= DEX MANAGEMENT FUNCTIONS ========= */
/// @inheritdoc IWhitelistingManagerFacet
function addDex(address _dex) external onlyAuthorized {
LibAllowList.addDex(_dex);
emit DexAdded(_dex);
}
/// @inheritdoc IWhitelistingManagerFacet
function removeDex(address _dex) external onlyAuthorized {
LibAllowList.removeDex(_dex);
emit DexRemoved(_dex);
}
/// @inheritdoc IWhitelistingManagerFacet
function addDexs(address[] calldata _dexs) external onlyAuthorized {
LibAllowList.addDexes(_dexs);
emit DexesAdded(_dexs);
}
/// @inheritdoc IWhitelistingManagerFacet
function removeDexs(address[] calldata _dexs) external onlyAuthorized {
LibAllowList.removeDexes(_dexs);
emit DexesRemoved(_dexs);
}
/* ========= BATCH FUNCTION ========= */
/// @inheritdoc IWhitelistingManagerFacet
function addDexesAndBridges(address[] calldata _dexs, address[] calldata _bridges) external onlyAuthorized {
LibAllowList.addDexes(_dexs);
LibAllowList.addBridges(_bridges);
emit DexesAdded(_dexs);
emit BridgesAdded(_bridges);
}
/// @inheritdoc IWhitelistingManagerFacet
function removeDexesAndBridges(address[] calldata _dexs, address[] calldata _bridges) external onlyAuthorized {
LibAllowList.removeDexes(_dexs);
LibAllowList.removeBridges(_bridges);
emit DexesRemoved(_dexs);
emit BridgesRemoved(_bridges);
}
/* ========= BRIDGE MANAGEMENT FUNCTIONS ========= */
/// @inheritdoc IWhitelistingManagerFacet
function addBridge(address _bridge) external onlyAuthorized {
LibAllowList.addBridge(_bridge);
emit BridgeAdded(_bridge);
}
/// @inheritdoc IWhitelistingManagerFacet
function removeBridge(address _bridge) external onlyAuthorized {
LibAllowList.removeBridge(_bridge);
emit BridgeRemoved(_bridge);
}
/// @inheritdoc IWhitelistingManagerFacet
function addBridges(address[] calldata _bridges) external onlyAuthorized {
LibAllowList.addBridges(_bridges);
emit BridgesAdded(_bridges);
}
/// @inheritdoc IWhitelistingManagerFacet
function removeBridges(address[] calldata _bridges) external onlyAuthorized {
LibAllowList.removeBridges(_bridges);
emit BridgesRemoved(_bridges);
}
/* ========= ADAPTERS MANAGEMENT FUNCTIONS ========= */
/// @inheritdoc IWhitelistingManagerFacet
function addAdapter(address _adapter) external onlyAuthorized {
LibAllowList.addAdapter(_adapter);
emit AdapterAdded(_adapter);
}
/// @inheritdoc IWhitelistingManagerFacet
function removeAdapter(address _adapter) external onlyAuthorized {
LibAllowList.removeAdapter(_adapter);
emit AdapterRemoved(_adapter);
}
/// @inheritdoc IWhitelistingManagerFacet
function addAdapters(address[] calldata _adapters) external onlyAuthorized {
LibAllowList.addAdapters(_adapters);
emit AdaptersAdded(_adapters);
}
/// @inheritdoc IWhitelistingManagerFacet
function removeAdapters(address[] calldata _adapters) external onlyAuthorized {
LibAllowList.removeAdapters(_adapters);
emit AdaptersRemoved(_adapters);
}
}// 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;
import { LibDiamond } from "../Libraries/LibDiamond.sol";
import { LibAccess } from "../Libraries/LibAccess.sol";
/**
* @title AuthorizationGuard
* @author DZap
* @notice Abstract contract to provide authorization functionality
*/
abstract contract AuthorizationGuard {
modifier onlyAuthorized() {
if (msg.sender != LibDiamond.contractOwner()) LibAccess.enforceAccessControl();
_;
}
}// 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 IWhitelistingManagerFacet
* @author DZap
*/
interface IWhitelistingManagerFacet {
event DexAdded(address indexed dex);
event DexRemoved(address indexed dex);
event DexesAdded(address[] dexes);
event DexesRemoved(address[] dexes);
event BridgeAdded(address indexed bridge);
event BridgeRemoved(address indexed bridge);
event BridgesAdded(address[] bridges);
event BridgesRemoved(address[] bridges);
event AdapterAdded(address indexed adapter);
event AdapterRemoved(address indexed adapter);
event AdaptersAdded(address[] adapters);
event AdaptersRemoved(address[] adapters);
/* ========= VIEWS ========= */
/// @notice checks if dex is approved or not
function isDexWhitelisted(address _dex) external view returns (bool);
/// @notice checks if bridge is approved or not
function isBridgeWhitelisted(address _bridge) external view returns (bool);
/// @notice checks if adapter is approved or not
function isAdapterWhitelisted(address _adapter) external view returns (bool);
/* ========= ADD FUNCTIONS ========= */
function addDexesAndBridges(address[] calldata _dexs, address[] calldata _bridges) external;
function removeDexesAndBridges(address[] calldata _dexs, address[] calldata _bridges) external;
/* ========= DEX MANAGEMENT FUNCTIONS ========= */
/// @notice Whitelist the address of a DEX contract to be approved for swapping.
function addDex(address _dex) external;
/// @notice Whitelist the addresses of DEX contracts to be approved for swapping.
function addDexs(address[] calldata _dexs) external;
/// @notice Remove the address of a DEX contract to be approved for swapping.
function removeDex(address _dex) external;
/// @notice Remove the addresses of DEX contracts to be approved for swapping.
function removeDexs(address[] calldata _dexs) external;
/* ========= BRIDGE MANAGEMENT FUNCTIONS ========= */
/// @notice Whitelist the address of a bridge contract to be approved for swapping.
function addBridge(address _bridge) external;
/// @notice Whitelist the addresses of bridge contracts to be approved for swapping.
function addBridges(address[] calldata _bridges) external;
/// @notice Remove the address of a bridge contract to be approved for swapping.
function removeBridge(address _bridge) external;
/// @notice Remove the addresses of bridge contracts to be approved for swapping.
function removeBridges(address[] calldata _bridges) external;
/* ========= ADAPTER MANAGEMENT FUNCTIONS ========= */
/// @notice Whitelist the address of an adapter contract to be approved for swapping.
function addAdapter(address _adapter) external;
/// @notice Whitelist the addresses of adapter contracts to be approved for swapping.
function addAdapters(address[] calldata _adapters) external;
/// @notice Remove the address of an adapter contract to be approved for swapping.
function removeAdapter(address _adapter) external;
/// @notice Remove the addresses of adapter contracts to be approved for swapping.
function removeAdapters(address[] calldata _adapters) 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 { 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;
/// 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":[{"internalType":"address","name":"adapter","type":"address"}],"name":"AdapterNotWhitelisted","type":"error"},{"inputs":[{"internalType":"address","name":"bridge","type":"address"}],"name":"BridgeNotWhitelisted","type":"error"},{"inputs":[],"name":"CannotAuthorizeSelf","type":"error"},{"inputs":[{"internalType":"address","name":"dex","type":"address"}],"name":"DexNotWhitelisted","type":"error"},{"inputs":[],"name":"NotAContract","type":"error"},{"inputs":[],"name":"UnAuthorized","type":"error"},{"inputs":[],"name":"ZeroAddress","type":"error"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"adapter","type":"address"}],"name":"AdapterAdded","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"adapter","type":"address"}],"name":"AdapterRemoved","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address[]","name":"adapters","type":"address[]"}],"name":"AdaptersAdded","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address[]","name":"adapters","type":"address[]"}],"name":"AdaptersRemoved","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"bridge","type":"address"}],"name":"BridgeAdded","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"bridge","type":"address"}],"name":"BridgeRemoved","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address[]","name":"bridges","type":"address[]"}],"name":"BridgesAdded","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address[]","name":"bridges","type":"address[]"}],"name":"BridgesRemoved","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"dex","type":"address"}],"name":"DexAdded","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"dex","type":"address"}],"name":"DexRemoved","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address[]","name":"dexes","type":"address[]"}],"name":"DexesAdded","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address[]","name":"dexes","type":"address[]"}],"name":"DexesRemoved","type":"event"},{"inputs":[{"internalType":"address","name":"_adapter","type":"address"}],"name":"addAdapter","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address[]","name":"_adapters","type":"address[]"}],"name":"addAdapters","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_bridge","type":"address"}],"name":"addBridge","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address[]","name":"_bridges","type":"address[]"}],"name":"addBridges","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_dex","type":"address"}],"name":"addDex","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address[]","name":"_dexs","type":"address[]"},{"internalType":"address[]","name":"_bridges","type":"address[]"}],"name":"addDexesAndBridges","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address[]","name":"_dexs","type":"address[]"}],"name":"addDexs","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_adapter","type":"address"}],"name":"isAdapterWhitelisted","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_bridge","type":"address"}],"name":"isBridgeWhitelisted","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_dex","type":"address"}],"name":"isDexWhitelisted","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_adapter","type":"address"}],"name":"removeAdapter","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address[]","name":"_adapters","type":"address[]"}],"name":"removeAdapters","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_bridge","type":"address"}],"name":"removeBridge","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address[]","name":"_bridges","type":"address[]"}],"name":"removeBridges","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_dex","type":"address"}],"name":"removeDex","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address[]","name":"_dexs","type":"address[]"},{"internalType":"address[]","name":"_bridges","type":"address[]"}],"name":"removeDexesAndBridges","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address[]","name":"_dexs","type":"address[]"}],"name":"removeDexs","outputs":[],"stateMutability":"nonpayable","type":"function"}]Contract Creation Code
60808060405234610016576110fd908161001c8239f35b600080fdfe6040608081526004908136101561001557600080fd5b600091823560e01c90816304df017d14610b3c5781630ad7d60214610a97578163124f1ead146109d857816320d999e81461093f57816322af17b4146108ab578163536db266146107d4578163585cd34b1461072557816360d54d411461068757816364eb7ada1461057657816367458cca14610457578163891107db146103c35781639712fdf8146102fe5781639795e52214610234578163a2d146e8146101eb578163a6c306c81461013a57508063b70baeb6146101135763f6f38e7c146100de57600080fd5b3461010f57602036600319011261010f5760209060ff6101046100ff610beb565b610d9f565b541690519015158152f35b5080fd5b503461010f57602036600319011261010f5760209060ff610104610135610beb565b610d67565b9050346101e75760203660031901126101e75780359167ffffffffffffffff83116101e3576101906101d0927f3ea0ef011e2da35caf21ef3524c0da7cc168ee27a0c9326dda77f01efc2848d094369101610c1a565b9290916001600160a01b036000805160206110a8833981519152541633036101d6575b6101c66101c1368686610c96565b610e8b565b5192839283610d1b565b0390a180f35b6101de610dd7565b6101b3565b8380fd5b8280fd5b50503461010f57602036600319011261010f5760ff816020936001600160a01b03610214610beb565b168152600080516020611088833981519152855220541690519015158152f35b50503461010f577f342ff800df0d75239d0f801a8fba4c798fac56d1e6d22a120f4baf8637ccbafd907fe1314fa3d3a334284af0f58df233222c20a829b6d3e10a35a2a766067187d16f6101d061028a36610c4b565b95926001600160a01b036000805160206110a883398151915296939296541633036102f1575b6102c36102be368484610c96565b610f30565b6102d66102d1368989610c96565b61101b565b6102e4845192839283610d1b565b0390a15192839283610d1b565b6102f9610dd7565b6102b0565b9050346101e75760203660031901126101e757610319610beb565b906001600160a01b03806000805160206110a8833981519152541633036103b6575b82169283156103a95730841461039c57823b1561038f57505061035d90610d67565b805460ff191660011790557f3cda433c5679ae4c6a5dea50840e222a42cba3695e4663de4366be89934842218280a280f35b516309ee12d560e01b8152fd5b51636d582a3160e11b8152fd5b5163d92e233d60e01b8152fd5b6103be610dd7565b61033b565b9050346101e75760203660031901126101e75780359167ffffffffffffffff83116101e3576104196101d0927f342ff800df0d75239d0f801a8fba4c798fac56d1e6d22a120f4baf8637ccbafd94369101610c1a565b9290916001600160a01b036000805160206110a88339815191525416330361044a575b6101c66102d1368686610c96565b610452610dd7565b61043c565b8391503461010f57602036600319011261010f57803567ffffffffffffffff81116101e7576104899036908301610c1a565b6000805160206110a88339815191525491936001600160a01b039283163303610569575b6104b8368387610c96565b91815b835181101561053757846104cf8286610e61565b511680156105275730811461051757803b1561050757906104f261050292610d9f565b805460ff19166001179055610e3c565b6104bb565b88516309ee12d560e01b81528790fd5b8851636d582a3160e11b81528790fd5b885163d92e233d60e01b81528790fd5b507f2894eecfa7bbc6e34a1cf3108cc45f6e97b8839583ff5311095cf822f619e2d790866101d0895192839283610d1b565b610571610dd7565b6104ad565b9050346101e75760203660031901126101e757803567ffffffffffffffff81116101e3576105a79036908301610c1a565b9190926001600160a01b0394856000805160206110a88339815191525416330361067a575b6105d7368587610c96565b93815b85518110156106485760ff6105fa896105f3848a610e61565b5116610d9f565b5416156106255780610613896105f3610620948a610e61565b805460ff19169055610e3c565b6105da565b8484896106346024948a610e61565b511690519163616d132960e01b8352820152fd5b50856101d07fd863f2729022434bd9591b60b7ecef275aa8d87317a0eb90d64fdcc6f34440de93945192839283610d1b565b610682610dd7565b6105cc565b9050346101e75760203660031901126101e7576106a2610beb565b906001600160a01b03806000805160206110a883398151915254163303610718575b82169283156103a95730841461039c57823b1561038f5750506106e690610d9f565b805460ff191660011790557fcf9c2c7f9adbb156bd76affb04df84595f8f5e69cab2e61221b05b05a902fa268280a280f35b610720610dd7565b6106c4565b9050346101e75760203660031901126101e757610740610beb565b906001600160a01b0392836000805160206110a8833981519152541633036107c7575b60ff61076e84610d9f565b5416156107b057505061078081610d9f565b805460ff19169055167fdf980d21d8c7bb34800e668dbe003299093bac8e693614151d3c57f73f98a93d8280a280f35b92602493519263616d132960e01b84521690820152fd5b6107cf610dd7565b610763565b919050346101e75760203660031901126101e7576107f0610beb565b916001600160a01b03806000805160206110a88339815191525416330361089e575b831692831561088f57308414610880573b1561087257508183526000805160206110888339815191526020528220805460ff191660011790557f7e0058dd0cbc0a8b7beaa013a4825655d8e9e81a5e2cc6582818deded0a41b998280a280f35b90516309ee12d560e01b8152fd5b509051636d582a3160e11b8152fd5b50905163d92e233d60e01b8152fd5b6108a6610dd7565b610812565b9050346101e75760203660031901126101e75780359167ffffffffffffffff83116101e3576109016101d0927fe1314fa3d3a334284af0f58df233222c20a829b6d3e10a35a2a766067187d16f94369101610c1a565b9290916001600160a01b036000805160206110a883398151915254163303610932575b6101c66102be368686610c96565b61093a610dd7565b610924565b9050346101e75760203660031901126101e75780359167ffffffffffffffff83116101e3576109956101d0927f22deecc3ac385a68fae0496127a343c27963c4e87c5aceb154d5af563458d3a594369101610c1a565b9290916001600160a01b036000805160206110a8833981519152541633036109cb575b6101c66109c6368686610c96565b610fd1565b6109d3610dd7565b6109b8565b919050346101e75760203660031901126101e7576109f4610beb565b6001600160a01b0390816000805160206110a883398151915254163303610a8a575b1691828452600080516020611088833981519152908160205260ff838620541615610a7357508284526020528220805460ff191690557f78e0a2ffcdfbbb49ba5c8050d8630fab2176d825e8360809db049cd98f462a788280a280f35b825163740bb42360e11b8152908101849052602490fd5b610a92610dd7565b610a16565b50503461010f577f22deecc3ac385a68fae0496127a343c27963c4e87c5aceb154d5af563458d3a5907f3ea0ef011e2da35caf21ef3524c0da7cc168ee27a0c9326dda77f01efc2848d06101d0610aed36610c4b565b95926001600160a01b036000805160206110a88339815191529693929654163303610b2f575b610b216101c1368484610c96565b6102d66109c6368989610c96565b610b37610dd7565b610b13565b9050346101e75760203660031901126101e757610b57610beb565b906001600160a01b0392836000805160206110a883398151915254163303610bde575b60ff610b8584610d67565b541615610bc7575050610b9781610d67565b805460ff19169055167f5d9d5034656cb3ebfb0655057cd7f9b4077a9b42ff42ce223cbac5bc586d21268280a280f35b92602493519263ed19a2c960e01b84521690820152fd5b610be6610dd7565b610b7a565b600435906001600160a01b0382168203610c0157565b600080fd5b35906001600160a01b0382168203610c0157565b9181601f84011215610c015782359167ffffffffffffffff8311610c01576020808501948460051b010111610c0157565b6040600319820112610c015767ffffffffffffffff91600435838111610c015782610c7891600401610c1a565b93909392602435918211610c0157610c9291600401610c1a565b9091565b90929167ffffffffffffffff91828511610d05578460051b9060405193601f19603f84011685019085821090821117610d0557604052839584526020809401918101928311610c0157905b828210610cee5750505050565b838091610cfa84610c06565b815201910190610ce1565b634e487b7160e01b600052604160045260246000fd5b90916040602092828482018583525201929160005b828110610d3e575050505090565b9091929382806001926001600160a01b03610d5889610c06565b16815201950193929101610d30565b6001600160a01b03166000527f03ef279dff7badd98b43464ec17f797a88e435619b3aa2c30c6c312144791197602052604060002090565b6001600160a01b03166000527f03ef279dff7badd98b43464ec17f797a88e435619b3aa2c30c6c312144791196602052604060002090565b63ffffffff60e01b600035166000527f5d54ae78bb256b3b2ab9aba21ec80ea50728352673b79651649d3494dfcade6a602052604060002033600052602052600160ff60406000205416151503610e2a57565b60405163be24598360e01b8152600490fd5b6000198114610e4b5760010190565b634e487b7160e01b600052601160045260246000fd5b8051821015610e755760209160051b010190565b634e487b7160e01b600052603260045260246000fd5b90600091825b8151811015610f2a576001600160a01b03610eac8284610e61565b5116908115610f1857308214610f0657813b15610ef457610eef91855260008051602061108883398151915260205260408520600160ff19825416179055610e3c565b610e91565b6040516309ee12d560e01b8152600490fd5b604051636d582a3160e11b8152600490fd5b60405163d92e233d60e01b8152600490fd5b50509050565b6000915b8151831015610fcc576001600160a01b039283610f518285610e61565b511660005260008051602061108883398151915260209080825260409160ff83600020541615610fa8578596610f8b85610fa19798610e61565b51166000525260002060ff198154169055610e3c565b9190610f34565b60248388610fb6878a610e61565b51915163740bb42360e11b815291166004820152fd5b915050565b60005b8151811015611017576001600160a01b03610fef8284610e61565b5116908115610f1857308214610f0657813b15610ef4576104f261101292610d67565b610fd4565b5050565b60005b8151811015611017576001600160a01b0360ff6110468261103f8587610e61565b5116610d67565b541615611064579061061361105f9261103f8386610e61565b61101e565b61107060249284610e61565b5160405163ed19a2c960e01b815291166004820152fdfe03ef279dff7badd98b43464ec17f797a88e435619b3aa2c30c6c312144791195c8fcad8db84d3cc18b4c41d551ea0ee66dd599cde068d998e57d5e09332c1320a26469706673582212204aefa41404390163306b1773c76870d4285fd8a8581ba5b27560bb05fe8648d764736f6c63430008130033
Deployed Bytecode
0x6040608081526004908136101561001557600080fd5b600091823560e01c90816304df017d14610b3c5781630ad7d60214610a97578163124f1ead146109d857816320d999e81461093f57816322af17b4146108ab578163536db266146107d4578163585cd34b1461072557816360d54d411461068757816364eb7ada1461057657816367458cca14610457578163891107db146103c35781639712fdf8146102fe5781639795e52214610234578163a2d146e8146101eb578163a6c306c81461013a57508063b70baeb6146101135763f6f38e7c146100de57600080fd5b3461010f57602036600319011261010f5760209060ff6101046100ff610beb565b610d9f565b541690519015158152f35b5080fd5b503461010f57602036600319011261010f5760209060ff610104610135610beb565b610d67565b9050346101e75760203660031901126101e75780359167ffffffffffffffff83116101e3576101906101d0927f3ea0ef011e2da35caf21ef3524c0da7cc168ee27a0c9326dda77f01efc2848d094369101610c1a565b9290916001600160a01b036000805160206110a8833981519152541633036101d6575b6101c66101c1368686610c96565b610e8b565b5192839283610d1b565b0390a180f35b6101de610dd7565b6101b3565b8380fd5b8280fd5b50503461010f57602036600319011261010f5760ff816020936001600160a01b03610214610beb565b168152600080516020611088833981519152855220541690519015158152f35b50503461010f577f342ff800df0d75239d0f801a8fba4c798fac56d1e6d22a120f4baf8637ccbafd907fe1314fa3d3a334284af0f58df233222c20a829b6d3e10a35a2a766067187d16f6101d061028a36610c4b565b95926001600160a01b036000805160206110a883398151915296939296541633036102f1575b6102c36102be368484610c96565b610f30565b6102d66102d1368989610c96565b61101b565b6102e4845192839283610d1b565b0390a15192839283610d1b565b6102f9610dd7565b6102b0565b9050346101e75760203660031901126101e757610319610beb565b906001600160a01b03806000805160206110a8833981519152541633036103b6575b82169283156103a95730841461039c57823b1561038f57505061035d90610d67565b805460ff191660011790557f3cda433c5679ae4c6a5dea50840e222a42cba3695e4663de4366be89934842218280a280f35b516309ee12d560e01b8152fd5b51636d582a3160e11b8152fd5b5163d92e233d60e01b8152fd5b6103be610dd7565b61033b565b9050346101e75760203660031901126101e75780359167ffffffffffffffff83116101e3576104196101d0927f342ff800df0d75239d0f801a8fba4c798fac56d1e6d22a120f4baf8637ccbafd94369101610c1a565b9290916001600160a01b036000805160206110a88339815191525416330361044a575b6101c66102d1368686610c96565b610452610dd7565b61043c565b8391503461010f57602036600319011261010f57803567ffffffffffffffff81116101e7576104899036908301610c1a565b6000805160206110a88339815191525491936001600160a01b039283163303610569575b6104b8368387610c96565b91815b835181101561053757846104cf8286610e61565b511680156105275730811461051757803b1561050757906104f261050292610d9f565b805460ff19166001179055610e3c565b6104bb565b88516309ee12d560e01b81528790fd5b8851636d582a3160e11b81528790fd5b885163d92e233d60e01b81528790fd5b507f2894eecfa7bbc6e34a1cf3108cc45f6e97b8839583ff5311095cf822f619e2d790866101d0895192839283610d1b565b610571610dd7565b6104ad565b9050346101e75760203660031901126101e757803567ffffffffffffffff81116101e3576105a79036908301610c1a565b9190926001600160a01b0394856000805160206110a88339815191525416330361067a575b6105d7368587610c96565b93815b85518110156106485760ff6105fa896105f3848a610e61565b5116610d9f565b5416156106255780610613896105f3610620948a610e61565b805460ff19169055610e3c565b6105da565b8484896106346024948a610e61565b511690519163616d132960e01b8352820152fd5b50856101d07fd863f2729022434bd9591b60b7ecef275aa8d87317a0eb90d64fdcc6f34440de93945192839283610d1b565b610682610dd7565b6105cc565b9050346101e75760203660031901126101e7576106a2610beb565b906001600160a01b03806000805160206110a883398151915254163303610718575b82169283156103a95730841461039c57823b1561038f5750506106e690610d9f565b805460ff191660011790557fcf9c2c7f9adbb156bd76affb04df84595f8f5e69cab2e61221b05b05a902fa268280a280f35b610720610dd7565b6106c4565b9050346101e75760203660031901126101e757610740610beb565b906001600160a01b0392836000805160206110a8833981519152541633036107c7575b60ff61076e84610d9f565b5416156107b057505061078081610d9f565b805460ff19169055167fdf980d21d8c7bb34800e668dbe003299093bac8e693614151d3c57f73f98a93d8280a280f35b92602493519263616d132960e01b84521690820152fd5b6107cf610dd7565b610763565b919050346101e75760203660031901126101e7576107f0610beb565b916001600160a01b03806000805160206110a88339815191525416330361089e575b831692831561088f57308414610880573b1561087257508183526000805160206110888339815191526020528220805460ff191660011790557f7e0058dd0cbc0a8b7beaa013a4825655d8e9e81a5e2cc6582818deded0a41b998280a280f35b90516309ee12d560e01b8152fd5b509051636d582a3160e11b8152fd5b50905163d92e233d60e01b8152fd5b6108a6610dd7565b610812565b9050346101e75760203660031901126101e75780359167ffffffffffffffff83116101e3576109016101d0927fe1314fa3d3a334284af0f58df233222c20a829b6d3e10a35a2a766067187d16f94369101610c1a565b9290916001600160a01b036000805160206110a883398151915254163303610932575b6101c66102be368686610c96565b61093a610dd7565b610924565b9050346101e75760203660031901126101e75780359167ffffffffffffffff83116101e3576109956101d0927f22deecc3ac385a68fae0496127a343c27963c4e87c5aceb154d5af563458d3a594369101610c1a565b9290916001600160a01b036000805160206110a8833981519152541633036109cb575b6101c66109c6368686610c96565b610fd1565b6109d3610dd7565b6109b8565b919050346101e75760203660031901126101e7576109f4610beb565b6001600160a01b0390816000805160206110a883398151915254163303610a8a575b1691828452600080516020611088833981519152908160205260ff838620541615610a7357508284526020528220805460ff191690557f78e0a2ffcdfbbb49ba5c8050d8630fab2176d825e8360809db049cd98f462a788280a280f35b825163740bb42360e11b8152908101849052602490fd5b610a92610dd7565b610a16565b50503461010f577f22deecc3ac385a68fae0496127a343c27963c4e87c5aceb154d5af563458d3a5907f3ea0ef011e2da35caf21ef3524c0da7cc168ee27a0c9326dda77f01efc2848d06101d0610aed36610c4b565b95926001600160a01b036000805160206110a88339815191529693929654163303610b2f575b610b216101c1368484610c96565b6102d66109c6368989610c96565b610b37610dd7565b610b13565b9050346101e75760203660031901126101e757610b57610beb565b906001600160a01b0392836000805160206110a883398151915254163303610bde575b60ff610b8584610d67565b541615610bc7575050610b9781610d67565b805460ff19169055167f5d9d5034656cb3ebfb0655057cd7f9b4077a9b42ff42ce223cbac5bc586d21268280a280f35b92602493519263ed19a2c960e01b84521690820152fd5b610be6610dd7565b610b7a565b600435906001600160a01b0382168203610c0157565b600080fd5b35906001600160a01b0382168203610c0157565b9181601f84011215610c015782359167ffffffffffffffff8311610c01576020808501948460051b010111610c0157565b6040600319820112610c015767ffffffffffffffff91600435838111610c015782610c7891600401610c1a565b93909392602435918211610c0157610c9291600401610c1a565b9091565b90929167ffffffffffffffff91828511610d05578460051b9060405193601f19603f84011685019085821090821117610d0557604052839584526020809401918101928311610c0157905b828210610cee5750505050565b838091610cfa84610c06565b815201910190610ce1565b634e487b7160e01b600052604160045260246000fd5b90916040602092828482018583525201929160005b828110610d3e575050505090565b9091929382806001926001600160a01b03610d5889610c06565b16815201950193929101610d30565b6001600160a01b03166000527f03ef279dff7badd98b43464ec17f797a88e435619b3aa2c30c6c312144791197602052604060002090565b6001600160a01b03166000527f03ef279dff7badd98b43464ec17f797a88e435619b3aa2c30c6c312144791196602052604060002090565b63ffffffff60e01b600035166000527f5d54ae78bb256b3b2ab9aba21ec80ea50728352673b79651649d3494dfcade6a602052604060002033600052602052600160ff60406000205416151503610e2a57565b60405163be24598360e01b8152600490fd5b6000198114610e4b5760010190565b634e487b7160e01b600052601160045260246000fd5b8051821015610e755760209160051b010190565b634e487b7160e01b600052603260045260246000fd5b90600091825b8151811015610f2a576001600160a01b03610eac8284610e61565b5116908115610f1857308214610f0657813b15610ef457610eef91855260008051602061108883398151915260205260408520600160ff19825416179055610e3c565b610e91565b6040516309ee12d560e01b8152600490fd5b604051636d582a3160e11b8152600490fd5b60405163d92e233d60e01b8152600490fd5b50509050565b6000915b8151831015610fcc576001600160a01b039283610f518285610e61565b511660005260008051602061108883398151915260209080825260409160ff83600020541615610fa8578596610f8b85610fa19798610e61565b51166000525260002060ff198154169055610e3c565b9190610f34565b60248388610fb6878a610e61565b51915163740bb42360e11b815291166004820152fd5b915050565b60005b8151811015611017576001600160a01b03610fef8284610e61565b5116908115610f1857308214610f0657813b15610ef4576104f261101292610d67565b610fd4565b5050565b60005b8151811015611017576001600160a01b0360ff6110468261103f8587610e61565b5116610d67565b541615611064579061061361105f9261103f8386610e61565b61101e565b61107060249284610e61565b5160405163ed19a2c960e01b815291166004820152fdfe03ef279dff7badd98b43464ec17f797a88e435619b3aa2c30c6c312144791195c8fcad8db84d3cc18b4c41d551ea0ee66dd599cde068d998e57d5e09332c1320a26469706673582212204aefa41404390163306b1773c76870d4285fd8a8581ba5b27560bb05fe8648d764736f6c63430008130033
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.