Source Code
| Transaction Hash |
|
Block
|
From
|
To
|
|||||
|---|---|---|---|---|---|---|---|---|---|
Latest 1 internal transaction
Advanced mode:
| Parent Transaction Hash | Block | From | To | |||
|---|---|---|---|---|---|---|
| 17489581 | 320 days ago | Contract Creation | 0 FRAX |
Cross-Chain Transactions
Loading...
Loading
Contract Name:
BatchSwapFacet
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 { LibFees } from "../../Shared/Libraries/LibFees.sol";
import { LibAsset } from "../../Shared/Libraries/LibAsset.sol";
import { LibSwap } from "../../Shared/Libraries/LibSwap.sol";
import { IBatchSwapFacet } from "../Interfaces/IBatchSwapFacet.sol";
import { Swapper } from "../../Shared/Helpers/Swapper.sol";
import { RefundNative } from "../../Shared/Helpers/RefundNative.sol";
import { SwapData, SwapInfo, FeeType, FeeInfo } from "../../Shared/Types.sol";
import { ZeroAddress, SwapCallFailed, ContractCallNotAllowed, IntegratorNotAllowed, InvalidAmount, AllSwapsFailed } from "../../Shared/ErrorsNew.sol";
contract BatchSwapFacet is IBatchSwapFacet, Swapper, RefundNative {
function batchSwap(bytes32 _transactionId, address _integrator, address _recipient, SwapData[] calldata _data, bool[] calldata _isDirectTransfer) external payable refundExcessNative(msg.sender) {
if (_recipient == address(0)) revert ZeroAddress();
if (!LibFees.isIntegratorAllowed(_integrator)) revert IntegratorNotAllowed();
uint256 length = _data.length;
SwapInfo[] memory swapInfo = new SwapInfo[](length);
for (uint256 i = 0; i < length; ) {
SwapData memory swapData = _data[i];
bool isDirectTransfer = _isDirectTransfer[i];
if (!LibAsset.isNativeToken(swapData.from)) {
LibAsset.permitAndTransferFromErc20(swapData.from, msg.sender, address(this), swapData.fromAmount, _data[i].permit);
}
(uint256 leftoverFromAmount, uint256 returnToAmount) = isDirectTransfer ? _executeSwaps(_data[i], _recipient, false) : _executeSwaps(_data[i], 0, false);
if (leftoverFromAmount != 0 && !LibAsset.isNativeToken(swapData.from)) LibAsset.transferToken(swapData.from, msg.sender, leftoverFromAmount);
if (!isDirectTransfer) LibAsset.transferToken(swapData.to, _recipient, returnToAmount);
swapInfo[i] = SwapInfo(swapData.callTo, swapData.from, swapData.to, swapData.fromAmount, leftoverFromAmount, returnToAmount);
unchecked {
++i;
}
}
emit MultiSwapped(_transactionId, _integrator, msg.sender, _recipient, swapInfo);
}
}// 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; error OnlyContractOwner(); error NoTransferToNullAddress(); error NativeTransferFailed(); error NullAddrIsNotAValidSpender(); error NullAddrIsNotAnERC20Token(); error InvalidAmount(); error InsufficientBalance(uint256 amount, uint256 contractBalance); error ZeroAddress(); error AlreadyInitialized(); error NotAContract(); error InvalidContract(); error CannotAuthorizeSelf(); error UnAuthorized(); error InvalidFee(); error InvalidFixedNativeFee(); error InvalidReceiver(); error InformationMismatch(); error InvalidSendingToken(); error NativeTokenNotSupported(); error InvalidDestinationChain(); error CannotBridgeToSameNetwork(); error IntegratorNotAllowed(); error ContractCallNotAllowed(); error NoSwapFromZeroBalance(); error SlippageTooLow(uint256 minAmount, uint256 returnAmount); error SwapCallFailed(bytes reason); error BridgeCallFailed(bytes reason); error UnAuthorizedCallToFunction(); error TokenInformationMismatch(); error FeeTooHigh(); error NotInitialized(); error UnauthorizedCaller(); error InvalidSwapDetails(); error UnAuthorizedCall(address); error BridgeNotAdded(address); error InvalidLength(); error AllSwapsFailed(); error AdapterCallFailed(bytes res); error AdapterNotWhitelisted(address adapter); error AdapterNotAdded(address adapter); error NativeCallFailed(bytes reason); error Erc20CallFailed(bytes reason); error NotNativeToken();
// SPDX-License-Identifier: UNLICENSED
pragma solidity 0.8.19;
import { LibAsset } from "../Libraries/LibAsset.sol";
abstract contract RefundNative {
/// @dev Refunds any excess native asset sent to the contract after the main function
/// @notice Refunds any excess native asset sent to the contract after the main function
/// @param _refundee Address to send refunds to
modifier refundExcessNative(address _refundee) {
uint256 initialBalance = address(this).balance - msg.value;
_;
uint256 finalBalance = address(this).balance;
if (finalBalance > initialBalance) LibAsset.transferToken(LibAsset._NATIVE_TOKEN, _refundee, finalBalance - initialBalance);
}
}// SPDX-License-Identifier: MIT
pragma solidity 0.8.19;
import { SwapData } from "../Types.sol";
import { LibAsset } from "../Libraries/LibAsset.sol";
import { LibAllowList } from "../Libraries/LibAllowList.sol";
import { LibSwap } from "../Libraries/LibSwap.sol";
import { ContractCallNotAllowed, ZeroAddress, SwapCallFailed, ZeroAddress, NoSwapFromZeroBalance, InvalidContract } from "../ErrorsNew.sol";
/// @title Swapper
/// @notice Abstract contract to provide swap functionality
abstract contract Swapper {
/* ========= INTERNAL ========= */
function _validateSwapData(SwapData calldata _swapData) internal view {
if (!LibAllowList.contractIsAllowed(_swapData.callTo) || !LibAllowList.contractIsAllowed(_swapData.approveTo)) revert ContractCallNotAllowed();
if (!LibAsset.isContract(_swapData.callTo)) revert InvalidContract();
if (_swapData.fromAmount == 0) revert NoSwapFromZeroBalance();
}
function _executeSwaps(SwapData calldata _swapData, uint256 _totalTokenFees, bool _withoutRevert) internal returns (uint256 leftoverFromAmount, uint256 returnToAmount) {
_validateSwapData(_swapData);
(leftoverFromAmount, returnToAmount) = LibSwap.swap(_swapData, _totalTokenFees, _withoutRevert);
}
function _executeSwaps(SwapData calldata _swapData, address _recipient, bool _withoutRevert) internal returns (uint256 leftoverFromAmount, uint256 returnToAmount) {
_validateSwapData(_swapData);
(leftoverFromAmount, returnToAmount) = LibSwap.swapDirectTransfer(_swapData, _recipient, _withoutRevert);
(_swapData, _withoutRevert, _recipient);
}
}// SPDX-License-Identifier: MIT
pragma solidity 0.8.19;
interface IPermit2 {
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;
}
function permit(address owner, PermitSingle memory permitSingle, bytes calldata signature) external;
function transferFrom(address from, address to, uint160 amount, address token) external;
function permitTransferFrom(PermitTransferFrom memory permit, SignatureTransferDetails calldata transferDetails, address owner, bytes calldata signature) external;
}// SPDX-License-Identifier: MIT
pragma solidity 0.8.19;
/// @title Contains 512-bit math functions
/// @notice Facilitates multiplication and division that can have overflow of an intermediate value without any loss of precision
/// @dev Handles "phantom overflow" i.e., allows multiplication and division where an intermediate value overflows 256 bits
/// https://github.com/Cryptorubic/multi-proxy-rubic/blob/master/src/Libraries/FullMath.sol
library FullMath {
/// @notice Calculates floor(a×b÷denominator) with full precision. Throws if result overflows a uint256 or denominator == 0
/// @param a The multiplicand
/// @param b The multiplier
/// @param denominator The divisor
/// @return result The 256-bit result
/// @dev Credit to Remco Bloemen under MIT license https://xn--2-umb.com/21/muldiv
function mulDiv(uint256 a, uint256 b, uint256 denominator) internal pure returns (uint256 result) {
unchecked {
// 512-bit multiply [prod1 prod0] = a * b
// Compute the product mod 2**256 and mod 2**256 - 1
// then use the Chinese Remainder Theorem to reconstruct
// the 512 bit result. The result is stored in two 256
// variables such that product = prod1 * 2**256 + prod0
uint256 prod0; // Least significant 256 bits of the product
uint256 prod1; // Most significant 256 bits of the product
assembly {
let mm := mulmod(a, b, not(0))
prod0 := mul(a, b)
prod1 := sub(sub(mm, prod0), lt(mm, prod0))
}
// Handle non-overflow cases, 256 by 256 division
if (prod1 == 0) {
require(denominator != 0);
assembly {
result := div(prod0, denominator)
}
return result;
}
// Make sure the result is less than 2**256.
// Also prevents denominator == 0
require(denominator > prod1);
///////////////////////////////////////////////
// 512 by 256 division.
///////////////////////////////////////////////
// Make division exact by subtracting the remainder from [prod1 prod0]
// Compute remainder using mulmod
uint256 remainder;
assembly {
remainder := mulmod(a, b, denominator)
}
// Subtract 256 bit number from 512 bit number
assembly {
prod1 := sub(prod1, gt(remainder, prod0))
prod0 := sub(prod0, remainder)
}
// Factor powers of two out of denominator
// Compute largest power of two divisor of denominator.
// Always >= 1.
uint256 twos = (0 - denominator) & denominator;
// Divide denominator by power of two
assembly {
denominator := div(denominator, twos)
}
// Divide [prod1 prod0] by the factors of two
assembly {
prod0 := div(prod0, twos)
}
// Shift in bits from prod1 into prod0. For this we need
// to flip `twos` such that it is 2**256 / twos.
// If twos is zero, then it becomes one
assembly {
twos := add(div(sub(0, twos), twos), 1)
}
prod0 |= prod1 * twos;
// Invert denominator mod 2**256
// Now that denominator is an odd number, it has an inverse
// modulo 2**256 such that denominator * inv = 1 mod 2**256.
// Compute the inverse by starting with a seed that is correct
// correct for four bits. That is, denominator * inv = 1 mod 2**4
uint256 inv = (3 * denominator) ^ 2;
// Now use Newton-Raphson iteration to improve the precision.
// Thanks to Hensel's lifting lemma, this also works in modular
// arithmetic, doubling the correct bits in each step.
inv *= 2 - denominator * inv; // inverse mod 2**8
inv *= 2 - denominator * inv; // inverse mod 2**16
inv *= 2 - denominator * inv; // inverse mod 2**32
inv *= 2 - denominator * inv; // inverse mod 2**64
inv *= 2 - denominator * inv; // inverse mod 2**128
inv *= 2 - denominator * inv; // inverse mod 2**256
// Because the division is now exact we can divide by multiplying
// with the modular inverse of denominator. This will give us the
// correct result modulo 2**256. Since the precoditions guarantee
// that the outcome is less than 2**256, this is the final result.
// We don't need to compute the high bits of the result and prod1
// is no longer required.
result = prod0 * inv;
return result;
}
}
}// SPDX-License-Identifier: MIT
pragma solidity 0.8.19;
import { InvalidContract } from "../ErrorsNew.sol";
import { AllowList } from "../Types.sol";
struct AllowListStorage {
mapping(address => AllowList) allowlist;
}
/// @title Lib Allow List
/// @notice Library for managing and accessing the conract address allow list
library LibAllowList {
bytes32 internal constant NAMESPACE = keccak256("dzap.library.allow.list");
/// @dev Adds a contract address to the allow list
/// @param _contract the contract address to add
function addAllowedContract(address _contract) internal {
_checkAddress(_contract);
AllowListStorage storage als = _getStorage();
if (als.allowlist[_contract].isAllowed) return;
als.allowlist[_contract].isAllowed = true;
}
/// @dev Remove a contract address from the allow list
/// @param _contract the contract address to remove
function removeAllowedContract(address _contract) internal {
AllowListStorage storage als = _getStorage();
if (!als.allowlist[_contract].isAllowed) {
return;
}
als.allowlist[_contract].isAllowed = false;
}
/// @dev Add a selector to the allow list
/// @param _selector the selector to add
function addAllowedSelector(address _contract, bytes4 _selector) internal {
_checkAddress(_contract);
_getStorage().allowlist[_contract].selectorAllowList[_selector] = true;
}
/// @dev Removes a selector from the allow list
/// @param _selector the selector to remove
function removeAllowedSelector(address _contract, bytes4 _selector) internal {
_getStorage().allowlist[_contract].selectorAllowList[_selector] = false;
}
/// @dev Checks whether a contract address has been added to the allow list
/// @param _contract the contract address to check
function contractIsAllowed(address _contract) internal view returns (bool) {
return _getStorage().allowlist[_contract].isAllowed;
}
/// @dev Returns if selector has been added to the allow list
/// @param _selector the selector to check
function selectorIsAllowed(address _contract, bytes4 _selector) internal view returns (bool) {
return _getStorage().allowlist[_contract].selectorAllowList[_selector];
}
/// @dev Fetch local storage struct
function _getStorage() internal pure returns (AllowListStorage storage als) {
bytes32 position = NAMESPACE;
// solhint-disable-next-line no-inline-assembly
assembly {
als.slot := position
}
}
/// @dev Contains business logic for validating a contract address.
/// @param _contract address of the dex to check
function _checkAddress(address _contract) private view {
if (_contract == address(0) || _contract.code.length == 0) revert InvalidContract();
}
}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 { LibFees } from "../Libraries/LibFees.sol";
import { LibPermit } from "../Libraries/LibPermit.sol";
import { FeeType, SwapData, PermitType, FeeInfo } from "../Types.sol";
import { NoTransferToNullAddress, InsufficientBalance, NativeTransferFailed, NullAddrIsNotAValidSpender, NullAddrIsNotAnERC20Token, InvalidAmount, IntegratorNotAllowed } from "../ErrorsNew.sol";
/// @title LibAsset
/// @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 {
address internal constant _NATIVE_TOKEN = 0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE;
/// @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));
}
function getBalance(address _token, address _recipient) internal view returns (uint256) {
return _token == _NATIVE_TOKEN ? _recipient.balance : IERC20(_token).balanceOf(_recipient);
}
/// @notice If the current allowance is insufficient, the allowance for a given spender
function approveERC20(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.safeIncreaseAllowance(IERC20(_token), _spender, _amount - allowance);
}
/// @notice Transfers ether from the inheriting contract to a given recipient
function transferNativeToken(address _recipient, uint256 _amount) internal {
if (_recipient == address(0)) revert NoTransferToNullAddress();
if (_amount > address(this).balance) revert InsufficientBalance(_amount, address(this).balance);
(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 (isNativeToken(_token)) revert NullAddrIsNotAnERC20Token();
uint256 assetBalance = IERC20(_token).balanceOf(address(this));
if (_amount > assetBalance) revert InsufficientBalance(_amount, assetBalance);
SafeERC20.safeTransfer(IERC20(_token), _recipient, _amount);
}
/// @notice Transfers tokens from a sender to a given recipient
function transferFromERC20(address _token, address _from, address _to, uint256 _amount) internal {
IERC20 token = IERC20(_token);
uint256 prevBalance = token.balanceOf(_to);
SafeERC20.safeTransferFrom(token, _from, _to, _amount);
if (token.balanceOf(_to) - prevBalance != _amount) {
revert InvalidAmount();
}
}
/// @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);
}
}
/// @dev Use permit2 to approve token
function permitAndTransferFromErc20(address _token, address _from, address _to, uint256 _amount, bytes calldata permit_) internal {
(PermitType permitType, bytes memory data) = abi.decode(permit_, (PermitType, bytes));
if (permitType == PermitType.PERMIT2_APPROVE) {
LibPermit.permit2ApproveAndTransfer(_from, _to, uint160(_amount), _token, data);
} else if (permitType == PermitType.PERMIT) {
if (data.length != 0) LibPermit.permit(_token, data);
transferFromERC20(_token, _from, _to, _amount);
} else {
LibPermit.permit2TransferFrom(_token, data, _amount);
}
}
function deposit(FeeInfo memory feeInfo, address _token, uint256 _amount, bytes calldata _permit) internal returns (uint256 totalFee, uint256 dZapShare) {
if (!LibAsset.isNativeToken(_token)) {
permitAndTransferFromErc20(_token, msg.sender, address(this), _amount, _permit);
}
(totalFee, dZapShare) = LibFees.calculateTokenFees(_amount, feeInfo);
}
function deposit(FeeInfo memory feeInfo, SwapData calldata _swap) internal returns (uint256 totalFee, uint256 dZapShare) {
if (!LibAsset.isNativeToken(_swap.from)) {
permitAndTransferFromErc20(_swap.from, msg.sender, address(this), _swap.fromAmount, _swap.permit);
}
(totalFee, dZapShare) = LibFees.calculateTokenFees(_swap.fromAmount, feeInfo);
}
// @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;
}
/* ========= INTERNAL ========= */
}// SPDX-License-Identifier: MIT
pragma solidity 0.8.19;
import { FullMath } from "../Libraries/FullMath.sol";
import { LibAsset } from "../Libraries/LibAsset.sol";
import { IntegratorInfo, FeeType, FeeInfo } from "../Types.sol";
import { IntegratorNotAllowed } from "../ErrorsNew.sol";
struct FeesStorage {
mapping(address => IntegratorInfo) integratorInfo;
uint256 maxTokenFee;
uint256 maxFixedNativeFeeAmount;
address protocolFeeVault;
bool initialized;
}
/// @title LibFees
/// @notice This library contains helpers for calculating and transferring fees
library LibFees {
bytes32 internal constant _FEE_STORAGE_SLOT = keccak256("dzap.storage.library.fees");
uint256 internal constant _BPS_DENOMINATOR = 1e6; // 4 basis points
event TokenFee(bytes32 indexed transactionId, address indexed integrator, FeeType feeType, address token, uint256 dzapFee, uint256 integratorFee);
event FixedNativeFee(bytes32 indexed transactionId, address indexed integrator, FeeType feeType, uint256 dzapFee, uint256 integratorFee);
function feesStorage() internal pure returns (FeesStorage storage ds) {
bytes32 slot = _FEE_STORAGE_SLOT;
assembly {
ds.slot := slot
}
}
function accrueFixedNativeFees(address _integrator, FeeType _feeType) internal {
FeesStorage storage fs = feesStorage();
FeeInfo memory feeInfo = fs.integratorInfo[_integrator].feeInfo[_feeType];
uint256 fixedNativeFeeAmount = feeInfo.fixedNativeFeeAmount;
if (fixedNativeFeeAmount != 0) {
uint256 dzapShare = (fixedNativeFeeAmount * feeInfo.dzapFixedNativeShare) / _BPS_DENOMINATOR;
if (fixedNativeFeeAmount > dzapShare) LibAsset.transferNativeToken(_integrator, fixedNativeFeeAmount - dzapShare);
if (dzapShare != 0) LibAsset.transferNativeToken(fs.protocolFeeVault, dzapShare);
}
}
function accrueTokenFees(address _integrator, address _token, uint256 _integratorFee, uint256 _dZapFee) internal {
if (_integratorFee != 0) LibAsset.transferToken(_token, _integrator, _integratorFee);
if (_dZapFee != 0) LibAsset.transferToken(_token, feesStorage().protocolFeeVault, _dZapFee);
}
function calcFixedNativeFees(FeeType _feeType, address _integrator) internal view returns (uint256 fixedNativeFeeAmount, uint256 dzapShare) {
FeeInfo memory feeInfo = feesStorage().integratorInfo[_integrator].feeInfo[_feeType];
fixedNativeFeeAmount = feeInfo.fixedNativeFeeAmount;
if (fixedNativeFeeAmount != 0) dzapShare = (fixedNativeFeeAmount * feeInfo.dzapFixedNativeShare) / _BPS_DENOMINATOR;
}
function calculateTokenFees(uint256 _amountWithFee, FeeInfo memory _feeInfo) internal pure returns (uint256 totalFee, uint256 dZapShare) {
if (_feeInfo.tokenFee != 0) {
totalFee = FullMath.mulDiv(_amountWithFee, _feeInfo.tokenFee, _BPS_DENOMINATOR);
dZapShare = FullMath.mulDiv(totalFee, _feeInfo.dzapTokenShare, _BPS_DENOMINATOR);
}
}
function getIntegratorFeeInfo(address _integrator, FeeType _feeType) internal view returns (FeeInfo memory feeInfo) {
if (!LibFees.isIntegratorAllowed(_integrator)) revert IntegratorNotAllowed();
return feesStorage().integratorInfo[_integrator].feeInfo[_feeType];
}
function isIntegratorAllowed(address _integrator) internal view returns (bool) {
FeesStorage storage fs = feesStorage();
return fs.integratorInfo[_integrator].status;
}
}// SPDX-License-Identifier: MIT
pragma solidity 0.8.19;
import "@openzeppelin/contracts/token/ERC20/extensions/IERC20Permit.sol";
import "../Interfaces/IPermit2.sol";
struct PermitStorage {
address permit2;
bool initialized;
}
/// @title LibPermit
/// @notice This library contains helpers for using permit and permit2
library LibPermit {
error InvalidPermitData();
error InvalidPermit();
bytes32 internal constant _PERMIT_STORAGE_SLOT = keccak256("dzap.storage.library.permit");
function permitStorage() internal pure returns (PermitStorage storage ps) {
bytes32 slot = _PERMIT_STORAGE_SLOT;
assembly {
ps.slot := slot
}
}
function permit2() internal view returns (address) {
return permitStorage().permit2;
}
function permit2ApproveAndTransfer(address _from, address _to, uint160 _amount, address _token, bytes memory data) internal {
permit2Approve(_token, data);
IPermit2(permit2()).transferFrom(_from, _to, uint160(_amount), _token);
}
function permit2Approve(address _token, bytes memory _data) internal {
IPermit2 _permit2 = IPermit2(permit2());
if (_data.length != 0) {
(uint160 allowanceAmount, uint48 nonce, uint48 expiration, uint256 sigDeadline, bytes memory signature) = abi.decode(_data, (uint160, uint48, uint48, uint256, bytes));
_permit2.permit(msg.sender, IPermit2.PermitSingle(IPermit2.PermitDetails(_token, allowanceAmount, expiration, nonce), address(this), sigDeadline), signature);
}
}
function permit2TransferFrom(address _token, bytes memory _data, uint256 amount_) internal {
(uint256 nonce, uint256 deadline, bytes memory signature) = abi.decode(_data, (uint256, uint256, bytes));
IPermit2(permit2()).permitTransferFrom(IPermit2.PermitTransferFrom(IPermit2.TokenPermissions(_token, amount_), nonce, deadline), IPermit2.SignatureTransferDetails(address(this), amount_), msg.sender, signature);
}
function permit(address _token, bytes memory _data) internal {
if (_data.length == 32 * 7) {
(bool success, ) = _token.call(abi.encodePacked(IERC20Permit.permit.selector, _data));
if (!success) revert InvalidPermit();
} else revert InvalidPermitData();
}
}// SPDX-License-Identifier: MIT
pragma solidity 0.8.19;
import { LibAsset } from "../Libraries/LibAsset.sol";
import { IERC20 } from "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import { SwapData } from "../Types.sol";
import { SwapCallFailed, SlippageTooLow } from "../ErrorsNew.sol";
/// @title LibSwap
/// @notice This library contains helpers for doing swap
library LibSwap {
function swap(SwapData calldata _swapData, uint256 _totalTokenFees, bool _withoutRevert) internal returns (uint256 leftoverFromAmount, uint256 returnToAmount) {
uint256 fromAmount = _swapData.fromAmount - _totalTokenFees;
uint256 initialFromBalance = LibAsset.getOwnBalance(_swapData.from) - fromAmount;
uint256 initialToBalance = LibAsset.getOwnBalance(_swapData.to);
uint256 nativeValue;
if (LibAsset.isNativeToken(_swapData.from)) {
nativeValue = fromAmount;
} else {
LibAsset.approveERC20(_swapData.from, _swapData.approveTo, fromAmount);
}
(bool success, bytes memory res) = _swapData.callTo.call{ value: nativeValue }(_swapData.swapCallData);
if (!success) {
if (_withoutRevert) {
return (0, 0);
}
revert SwapCallFailed(res);
}
returnToAmount = LibAsset.getOwnBalance(_swapData.to) - initialToBalance;
if (returnToAmount < _swapData.minToAmount) revert SlippageTooLow(_swapData.minToAmount, returnToAmount);
uint256 finalFromBalance = LibAsset.getOwnBalance(_swapData.from);
if (finalFromBalance > initialFromBalance) {
leftoverFromAmount = finalFromBalance - initialFromBalance;
}
}
function swapDirectTransfer(SwapData calldata _swapData, address _recipient, bool _withoutRevert) internal returns (uint256 leftoverFromAmount, uint256 returnToAmount) {
uint256 initialFromBalance = LibAsset.getOwnBalance(_swapData.from) - _swapData.fromAmount;
uint256 initialToBalance = LibAsset.getBalance(_swapData.to, _recipient);
uint256 nativeValue;
if (LibAsset.isNativeToken(_swapData.from)) {
nativeValue = _swapData.fromAmount;
} else {
LibAsset.approveERC20(_swapData.from, _swapData.approveTo, _swapData.fromAmount);
}
(bool success, bytes memory res) = _swapData.callTo.call{ value: nativeValue }(_swapData.swapCallData);
if (!success) {
if (_withoutRevert) {
return (0, 0);
}
revert SwapCallFailed(res);
}
returnToAmount = LibAsset.getBalance(_swapData.to, _recipient) - initialToBalance;
if (returnToAmount < _swapData.minToAmount) {
revert SlippageTooLow(_swapData.minToAmount, returnToAmount);
}
uint256 finalFromBalance = LibAsset.getOwnBalance(_swapData.from);
if (finalFromBalance > initialFromBalance) {
leftoverFromAmount = finalFromBalance - initialFromBalance;
}
}
function swapErc20ToErc20(SwapData calldata _swapData, address _recipient) internal returns (uint256 leftoverFromAmount, uint256 returnToAmount) {
uint256 initialFromBalance = IERC20(_swapData.from).balanceOf(address(this)) - _swapData.fromAmount;
uint256 initialToBalance = IERC20(_swapData.to).balanceOf(_recipient);
LibAsset.approveERC20(_swapData.from, _swapData.approveTo, _swapData.fromAmount);
(bool success, bytes memory res) = _swapData.callTo.call(_swapData.swapCallData);
if (!success) revert SwapCallFailed(res);
returnToAmount = IERC20(_swapData.to).balanceOf(_recipient) - initialToBalance;
if (returnToAmount < _swapData.minToAmount) {
revert SlippageTooLow(_swapData.minToAmount, returnToAmount);
}
uint256 finalFromBalance = LibAsset.getOwnBalance(_swapData.from);
if (finalFromBalance > initialFromBalance) {
leftoverFromAmount = finalFromBalance - initialFromBalance;
}
}
function swapErc20ToNative(SwapData calldata _swapData, address _recipient) internal returns (uint256 leftoverFromAmount, uint256 returnToAmount) {
uint256 initialFromBalance = IERC20(_swapData.from).balanceOf(address(this)) - _swapData.fromAmount;
uint256 initialToBalance = _recipient.balance;
LibAsset.approveERC20(_swapData.from, _swapData.approveTo, _swapData.fromAmount);
(bool success, bytes memory res) = _swapData.callTo.call(_swapData.swapCallData);
if (!success) revert SwapCallFailed(res);
returnToAmount = _recipient.balance - initialToBalance;
if (returnToAmount < _swapData.minToAmount) {
revert SlippageTooLow(_swapData.minToAmount, returnToAmount);
}
uint256 finalFromBalance = LibAsset.getOwnBalance(_swapData.from);
if (finalFromBalance > initialFromBalance) {
leftoverFromAmount = finalFromBalance - initialFromBalance;
}
}
function swapNativeToErc20(SwapData calldata _swapData, address _recipient) internal returns (uint256 leftoverFromAmount, uint256 returnToAmount) {
uint256 initialFromBalance = address(this).balance - _swapData.fromAmount;
uint256 initialToBalance = IERC20(_swapData.to).balanceOf(_recipient);
(bool success, bytes memory res) = _swapData.callTo.call{ value: _swapData.fromAmount }(_swapData.swapCallData);
if (!success) revert SwapCallFailed(res);
returnToAmount = IERC20(_swapData.to).balanceOf(_recipient) - initialToBalance;
if (returnToAmount < _swapData.minToAmount) {
revert SlippageTooLow(_swapData.minToAmount, returnToAmount);
}
uint256 finalFromBalance = address(this).balance;
if (finalFromBalance > initialFromBalance) {
leftoverFromAmount = finalFromBalance - initialFromBalance;
}
}
}// SPDX-License-Identifier: MIT
pragma solidity 0.8.19;
enum FeeType {
BRIDGE,
SWAP
}
enum PermitType {
PERMIT,
PERMIT2_TRANSFER_FROM,
PERMIT2_APPROVE
}
struct AllowList {
bool isAllowed;
mapping(bytes4 => bool) selectorAllowList;
}
struct FeeInfo {
uint256 tokenFee; // ex 1%
uint256 fixedNativeFeeAmount; // ex 0.5 Matic
uint256 dzapTokenShare; // 50%, 50% of the total 1% fee
uint256 dzapFixedNativeShare; // 50%, 50% of the total fixedFeeAmount fee
}
struct IntegratorInfo {
bool status;
mapping(FeeType => FeeInfo) feeInfo;
}
struct SwapData {
address callTo; // router, dex, aggregator
address approveTo;
address from;
address to;
uint256 fromAmount; // totalAmountWithFee
uint256 minToAmount; // fro amountWithoutFee
bytes swapCallData; // from : amountWithoutFee
bytes permit;
}
struct SwapInfo {
address dex;
address fromToken;
address toToken;
uint256 fromAmount;
uint256 leftOverFromAmount;
uint256 returnToAmount;
}// SPDX-License-Identifier: MIT
pragma solidity 0.8.19;
import { SwapData, SwapInfo } from "../../Shared/Types.sol";
interface IBatchSwapFacet {
/* ========= EVENTS ========= */
event MultiSwapped(bytes32 indexed transactionId, address indexed integrator, address indexed sender, address recipient, SwapInfo[] swapInfo);
/* ========= EXTERNAL ========= */
function batchSwap(bytes32 _transactionId, address _integrator, address _recipient, SwapData[] calldata _data, bool[] calldata _isDirectTransfer) external payable;
}{
"optimizer": {
"enabled": true,
"runs": 300
},
"viaIR": true,
"outputSelection": {
"*": {
"*": [
"evm.bytecode",
"evm.deployedBytecode",
"devdoc",
"userdoc",
"metadata",
"abi"
]
}
},
"metadata": {
"useLiteralContent": true
},
"libraries": {}
}Contract Security Audit
- No Contract Security Audit Submitted- Submit Audit Here
Contract ABI
API[{"inputs":[],"name":"ContractCallNotAllowed","type":"error"},{"inputs":[{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"uint256","name":"contractBalance","type":"uint256"}],"name":"InsufficientBalance","type":"error"},{"inputs":[],"name":"IntegratorNotAllowed","type":"error"},{"inputs":[],"name":"InvalidAmount","type":"error"},{"inputs":[],"name":"InvalidContract","type":"error"},{"inputs":[],"name":"InvalidPermit","type":"error"},{"inputs":[],"name":"InvalidPermitData","type":"error"},{"inputs":[],"name":"NativeTransferFailed","type":"error"},{"inputs":[],"name":"NoSwapFromZeroBalance","type":"error"},{"inputs":[],"name":"NoTransferToNullAddress","type":"error"},{"inputs":[],"name":"NullAddrIsNotAValidSpender","type":"error"},{"inputs":[],"name":"NullAddrIsNotAnERC20Token","type":"error"},{"inputs":[{"internalType":"uint256","name":"minAmount","type":"uint256"},{"internalType":"uint256","name":"returnAmount","type":"uint256"}],"name":"SlippageTooLow","type":"error"},{"inputs":[{"internalType":"bytes","name":"reason","type":"bytes"}],"name":"SwapCallFailed","type":"error"},{"inputs":[],"name":"ZeroAddress","type":"error"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"transactionId","type":"bytes32"},{"indexed":true,"internalType":"address","name":"integrator","type":"address"},{"indexed":true,"internalType":"address","name":"sender","type":"address"},{"indexed":false,"internalType":"address","name":"recipient","type":"address"},{"components":[{"internalType":"address","name":"dex","type":"address"},{"internalType":"address","name":"fromToken","type":"address"},{"internalType":"address","name":"toToken","type":"address"},{"internalType":"uint256","name":"fromAmount","type":"uint256"},{"internalType":"uint256","name":"leftOverFromAmount","type":"uint256"},{"internalType":"uint256","name":"returnToAmount","type":"uint256"}],"indexed":false,"internalType":"struct SwapInfo[]","name":"swapInfo","type":"tuple[]"}],"name":"MultiSwapped","type":"event"},{"inputs":[{"internalType":"bytes32","name":"_transactionId","type":"bytes32"},{"internalType":"address","name":"_integrator","type":"address"},{"internalType":"address","name":"_recipient","type":"address"},{"components":[{"internalType":"address","name":"callTo","type":"address"},{"internalType":"address","name":"approveTo","type":"address"},{"internalType":"address","name":"from","type":"address"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"fromAmount","type":"uint256"},{"internalType":"uint256","name":"minToAmount","type":"uint256"},{"internalType":"bytes","name":"swapCallData","type":"bytes"},{"internalType":"bytes","name":"permit","type":"bytes"}],"internalType":"struct SwapData[]","name":"_data","type":"tuple[]"},{"internalType":"bool[]","name":"_isDirectTransfer","type":"bool[]"}],"name":"batchSwap","outputs":[],"stateMutability":"payable","type":"function"}]Contract Creation Code
60808060405234610016576116be908161001c8239f35b600080fdfe6080604052600436101561001257600080fd5b60003560e01c63fd00fd221461002757600080fd5b60a0366003190112610893576024356001600160a01b0381168103610893576001600160a01b036044351660443503610893576064356001600160401b03811161089357610079903690600401610df0565b91906084356001600160401b0381116108935761009a903690600401610df0565b936100a53447610e20565b946001600160a01b036044351615610dca576001600160a01b0385166000527fadf38b383de83e03163f4bb9c9eeeeff060c277df907ebce1fd27038d38e2e0860205260ff6040600020541615610db8576100ff82610ec8565b9361010d6040519586610ea7565b82855261011983610ec8565b60005b601f1982018110610d7757505060005b8381106102915787878760405190604082016001600160a01b0360443516835260406020840152815180915260609060208285019301916000905b82821061022a57505050507fe614e35f0880bd7ec24e2a0cf663357023c534156e6f25a01a237b1eea7a761a6001600160a01b033394169280600435930390a447908082116101b257005b6101bb91610e20565b806101c257005b3315610218574781116101fa57600080808093335af16101e06111c7565b50156101e857005b604051633d2cec6f60e21b8152600490fd5b604490476040519163cf47918160e01b835260048301526024820152fd5b6040516321f7434560e01b8152600490fd5b90919293602060c060019260a088516001600160a01b0381511683526001600160a01b038582015116858401526001600160a01b036040820151166040840152868101518784015260808082015190840152015160a0820152019501920190929192610167565b61029c818584610edf565b610100813603126108935760405190816101008101106001600160401b0361010084011117610a235761010082016040526102d681610ddc565b82526102e460208201610ddc565b60208301526102f560408201610ddc565b604083015261030660608201610ddc565b60608301526080810135608083015260a081013560a08301526001600160401b0360c082013511610893576103413660c08301358301610f1c565b60c08301526001600160401b0360e0820135116108935761036990369060e081013501610f1c565b60e082015283821015610d6157600582901b8601358015159003610893576001600160a01b0360408201511673eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee810361075f575b508160051b860135600014610642576103cb828685610edf565b6103d481610fbd565b60006103ea6103e560408401610fa9565b61142a565b6103f960808401358092610e20565b9060008061041460443561040f60608901610fa9565b611622565b928173eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee6001600160a01b0361043f60408b01610fa9565b1614831461061a57505b61045287610fa9565b9061046060c0890189610f63565b9190826040519384928337810185815203925af161047c6111c7565b90156105f1575061049e9061049960443561040f60608801610fa9565b610e20565b9260a08101358085106105d35750906104c26103e560406001989796959401610fa9565b8181116105c2575b50505b80151580610597575b61057a575b8360051b8901351561055b575b6001600160a01b03835116926001600160a01b036040820151169060806001600160a01b03606083015116910151916040519561052487610e43565b8652602086015260408501526060840152608083015260a08201526105498289610f95565b526105548188610f95565b500161012c565b610575826044356001600160a01b0360608701511661107b565b6104e8565b61059281336001600160a01b0360408701511661107b565b6104db565b5073eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee6001600160a01b0360408501511614156104d6565b6105cc9250610e20565b38806104ca565b604490856040519163a81ff3b360e01b835260048301526024820152fd5b60405163729a0b5b60e01b8152602060048201529081906106169060248301906113ad565b0390fd5b9061063d9061062b60408a01610fa9565b61063760208b01610fa9565b906114c3565b610449565b61064d828685610edf565b61065681610fbd565b60006080820135610670816104996103e560408701610fa9565b906000806106836103e560608801610fa9565b928173eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee6001600160a01b036106ae60408b01610fa9565b1614831461074957505b6106c187610fa9565b906106cf60c0890189610f63565b9190826040519384928337810185815203925af16106eb6111c7565b90156105f15750610705906104996103e560608701610fa9565b9260a08101358085106105d35750906107296103e560406001989796959401610fa9565b818111610738575b50506104cd565b6107429250610e20565b3880610731565b9061075a9061062b60408a01610fa9565b6106b8565b608082015161077c610772858988610edf565b60e0810190610f63565b604082828101031261089357600382351015610893576001600160401b03602083013511610893576107b690820160208301358301610f1c565b908035600203610a3957506001600160a01b037fa5e67a2ca7abbd3d386941b8010a32368804ac328a911a128f9ea68fdba5470f541690805180610898575b5050506001600160a01b037fa5e67a2ca7abbd3d386941b8010a32368804ac328a911a128f9ea68fdba5470f541690813b156108935760846001600160a01b0391600080946040519687958694631b63c28b60e11b865233600487015230602487015216604485015260648401525af1801561088757610878575b505b386103b1565b61088190610e94565b38610870565b6040513d6000823e3d90fd5b600080fd5b60a0828281010312610893576020820151916001600160a01b0383168303610893576108c6604082016113d2565b916108d3606083016113d2565b9060808301519260a0810151916001600160401b0383116108935761090192602080928401019201016113e5565b92604051948560808101106001600160401b03608088011117610a235765ffffffffffff926001600160a01b038492608089016040528b89521660208801521660408601521660608401526040519261095984610e79565b83523060208401526040830152823b15610893576109fe926040600080948251968795869485936302b67b5760e41b855233600486015265ffffffffffff606082516001600160a01b0381511660248901526001600160a01b036020820151166044890152828582015116606489015201511660848601526001600160a01b0360208201511660a4860152015160c484015261010060e48401526101048301906113ad565b03925af1801561088757610a14575b80806107f5565b610a1d90610e94565b38610a0d565b634e487b7160e01b600052604160045260246000fd5b91929135610bff57805180610b7a575b50506040516370a0823160e01b8152306004820152602081602481855afa90811561088757600091610b48575b506040516323b872dd60e01b6020820152336024820152306044820152836064820152606481528060a08101106001600160401b0360a083011117610a2357602492610acb8260a060209401604052826111f7565b6040516370a0823160e01b815230600482015293849182905afa801561088757600090610b14575b610afd9250610e20565b146108725760405163162908e360e11b8152600490fd5b506020823d602011610b40575b81610b2e60209383610ea7565b8101031261089357610afd9151610af3565b3d9150610b21565b90506020813d602011610b72575b81610b6360209383610ea7565b81010312610893575138610a76565b3d9150610b56565b60e003610bed5760008091604051610bc0602482602081019463d505accf60e01b8652610bb0815180926020868601910161138a565b8101036004810184520182610ea7565b519082855af1610bce6111c7565b5015610bdb573880610a49565b60405163ddafbaef60e01b8152600490fd5b604051636abdccad60e11b8152600490fd5b909181518201606083820312610893576020830151906040840151936060810151916001600160401b03831161089357610c409260208092019201016113e5565b926001600160a01b037fa5e67a2ca7abbd3d386941b8010a32368804ac328a911a128f9ea68fdba5470f54169160405195610c7a87610e5e565b865283602087015260405195610c8f87610e79565b86526020860152604085015260405191610ca883610e5e565b3083526020830152803b156108935760406000610d2495610d3d829684519889978896879563187945bd60e11b8752610cf8600488018251602080916001600160a01b0381511684520151910152565b6020818101516044890152910151606487015281516001600160a01b03166084870152015160a4850152565b3360c484015261010060e48401526101048301906113ad565b03925af1801561088757610d52575b50610872565b610d5b90610e94565b38610d4c565b634e487b7160e01b600052603260045260246000fd5b602090604051610d8681610e43565b60008152600083820152600060408201526000606082015260006080820152600060a082015282828a0101520161011c565b604051630f52085360e31b8152600490fd5b60405163d92e233d60e01b8152600490fd5b35906001600160a01b038216820361089357565b9181601f84011215610893578235916001600160401b038311610893576020808501948460051b01011161089357565b91908203918211610e2d57565b634e487b7160e01b600052601160045260246000fd5b60c081019081106001600160401b03821117610a2357604052565b604081019081106001600160401b03821117610a2357604052565b606081019081106001600160401b03821117610a2357604052565b6001600160401b038111610a2357604052565b90601f801991011681019081106001600160401b03821117610a2357604052565b6001600160401b038111610a235760051b60200190565b9190811015610d615760051b8101359060fe1981360301821215610893570190565b6001600160401b038111610a2357601f01601f191660200190565b81601f8201121561089357803590610f3382610f01565b92610f416040519485610ea7565b8284526020838301011161089357816000926020809301838601378301015290565b903590601e198136030182121561089357018035906001600160401b0382116108935760200191813603831361089357565b8051821015610d615760209160051b010190565b356001600160a01b03811681036108935790565b60ff611003610fcb83610fa9565b6001600160a01b03166000527f87c11dafdbe0f066e67358ee4040ba0de12255453b9477c97fa61212e07ca30c602052604060002090565b5416158015611061575b61104f5761101a81610fa9565b3b1561103d57608001351561102b57565b60405163391b81e760e21b8152600490fd5b6040516303777f6960e51b8152600490fd5b604051632514e60160e21b8152600490fd5b5060ff611073610fcb60208401610fa9565b54161561100d565b8261108557505050565b6001600160a01b0390811673eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee81036110f25750811615610218574782116110d357600080809381935af16110cb6111c7565b50156101e857565b60405163cf47918160e01b815260048101839052476024820152604490fd5b6040516370a0823160e01b815230600482015290929150602081602481865afa90811561088757600091611193575b50808411611175575060405163a9059cbb60e01b60208201526001600160a01b0390911660248201526044810192909252611173919061116e82606481015b03601f198101845283610ea7565b6111f7565b565b836044916040519163cf47918160e01b835260048301526024820152fd5b906020823d82116111bf575b816111ac60209383610ea7565b810103126111bc57505138611121565b80fd5b3d915061119f565b3d156111f2573d906111d882610f01565b916111e66040519384610ea7565b82523d6000602084013e565b606090565b6001600160a01b03169061125760405161121081610e5e565b6020938482527f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564858301526000808587829751910182855af16112516111c7565b916112f1565b8051918215918483156112c9575b5050509050156112725750565b6084906040519062461bcd60e51b82526004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b6064820152fd5b9193818094500103126112ed578201519081151582036111bc575080388084611265565b5080fd5b919290156113535750815115611305575090565b3b1561130e5790565b60405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000006044820152606490fd5b8251909150156113665750805190602001fd5b60405162461bcd60e51b8152602060048201529081906106169060248301906113ad565b60005b83811061139d5750506000910152565b818101518382015260200161138d565b906020916113c68151809281855285808601910161138a565b601f01601f1916010190565b519065ffffffffffff8216820361089357565b81601f820112156108935780516113fb81610f01565b926114096040519485610ea7565b8184526020828401011161089357611427916020808501910161138a565b90565b6000906001600160a01b031673eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee81036114575750504790565b6020602491604051928380926370a0823160e01b82523060048301525afa9182156114b757809261148757505090565b9091506020823d82116114af575b816114a260209383610ea7565b810103126111bc57505190565b3d9150611495565b604051903d90823e3d90fd5b6001600160a01b03908183161561161057604051636eb1769f60e11b8082523060048301526001600160a01b03851660248301526020959390921692908581604481875afa908115610887576000916115e3575b50818110611528575b505050505050565b61153191610e20565b6040519182523060048301526001600160a01b03841660248301528482604481865afa918215610887576000926115b4575b508101809111610e2d5760405163095ea7b360e01b948101949094526001600160a01b03909216602484015260448301919091526115a9919061116e8260648101611160565b388080808080611520565b90918582813d83116115dc575b6115cb8183610ea7565b810103126111bc5750519038611563565b503d6115c1565b908682813d8311611609575b6115f98183610ea7565b810103126111bc57505138611517565b503d6115ef565b6040516363ba9bff60e01b8152600490fd5b6001600160a01b0380911660009173eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee8214600014611655575050503190565b6024602092939460405194859384926370a0823160e01b84521660048301525afa9182156114b75780926114875750509056fea26469706673582212202f8d6b362d8d4249c9d38fd64de5be16a74a36a54b5c76ce583de82738eeb73964736f6c63430008130033
Deployed Bytecode
0x6080604052600436101561001257600080fd5b60003560e01c63fd00fd221461002757600080fd5b60a0366003190112610893576024356001600160a01b0381168103610893576001600160a01b036044351660443503610893576064356001600160401b03811161089357610079903690600401610df0565b91906084356001600160401b0381116108935761009a903690600401610df0565b936100a53447610e20565b946001600160a01b036044351615610dca576001600160a01b0385166000527fadf38b383de83e03163f4bb9c9eeeeff060c277df907ebce1fd27038d38e2e0860205260ff6040600020541615610db8576100ff82610ec8565b9361010d6040519586610ea7565b82855261011983610ec8565b60005b601f1982018110610d7757505060005b8381106102915787878760405190604082016001600160a01b0360443516835260406020840152815180915260609060208285019301916000905b82821061022a57505050507fe614e35f0880bd7ec24e2a0cf663357023c534156e6f25a01a237b1eea7a761a6001600160a01b033394169280600435930390a447908082116101b257005b6101bb91610e20565b806101c257005b3315610218574781116101fa57600080808093335af16101e06111c7565b50156101e857005b604051633d2cec6f60e21b8152600490fd5b604490476040519163cf47918160e01b835260048301526024820152fd5b6040516321f7434560e01b8152600490fd5b90919293602060c060019260a088516001600160a01b0381511683526001600160a01b038582015116858401526001600160a01b036040820151166040840152868101518784015260808082015190840152015160a0820152019501920190929192610167565b61029c818584610edf565b610100813603126108935760405190816101008101106001600160401b0361010084011117610a235761010082016040526102d681610ddc565b82526102e460208201610ddc565b60208301526102f560408201610ddc565b604083015261030660608201610ddc565b60608301526080810135608083015260a081013560a08301526001600160401b0360c082013511610893576103413660c08301358301610f1c565b60c08301526001600160401b0360e0820135116108935761036990369060e081013501610f1c565b60e082015283821015610d6157600582901b8601358015159003610893576001600160a01b0360408201511673eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee810361075f575b508160051b860135600014610642576103cb828685610edf565b6103d481610fbd565b60006103ea6103e560408401610fa9565b61142a565b6103f960808401358092610e20565b9060008061041460443561040f60608901610fa9565b611622565b928173eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee6001600160a01b0361043f60408b01610fa9565b1614831461061a57505b61045287610fa9565b9061046060c0890189610f63565b9190826040519384928337810185815203925af161047c6111c7565b90156105f1575061049e9061049960443561040f60608801610fa9565b610e20565b9260a08101358085106105d35750906104c26103e560406001989796959401610fa9565b8181116105c2575b50505b80151580610597575b61057a575b8360051b8901351561055b575b6001600160a01b03835116926001600160a01b036040820151169060806001600160a01b03606083015116910151916040519561052487610e43565b8652602086015260408501526060840152608083015260a08201526105498289610f95565b526105548188610f95565b500161012c565b610575826044356001600160a01b0360608701511661107b565b6104e8565b61059281336001600160a01b0360408701511661107b565b6104db565b5073eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee6001600160a01b0360408501511614156104d6565b6105cc9250610e20565b38806104ca565b604490856040519163a81ff3b360e01b835260048301526024820152fd5b60405163729a0b5b60e01b8152602060048201529081906106169060248301906113ad565b0390fd5b9061063d9061062b60408a01610fa9565b61063760208b01610fa9565b906114c3565b610449565b61064d828685610edf565b61065681610fbd565b60006080820135610670816104996103e560408701610fa9565b906000806106836103e560608801610fa9565b928173eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee6001600160a01b036106ae60408b01610fa9565b1614831461074957505b6106c187610fa9565b906106cf60c0890189610f63565b9190826040519384928337810185815203925af16106eb6111c7565b90156105f15750610705906104996103e560608701610fa9565b9260a08101358085106105d35750906107296103e560406001989796959401610fa9565b818111610738575b50506104cd565b6107429250610e20565b3880610731565b9061075a9061062b60408a01610fa9565b6106b8565b608082015161077c610772858988610edf565b60e0810190610f63565b604082828101031261089357600382351015610893576001600160401b03602083013511610893576107b690820160208301358301610f1c565b908035600203610a3957506001600160a01b037fa5e67a2ca7abbd3d386941b8010a32368804ac328a911a128f9ea68fdba5470f541690805180610898575b5050506001600160a01b037fa5e67a2ca7abbd3d386941b8010a32368804ac328a911a128f9ea68fdba5470f541690813b156108935760846001600160a01b0391600080946040519687958694631b63c28b60e11b865233600487015230602487015216604485015260648401525af1801561088757610878575b505b386103b1565b61088190610e94565b38610870565b6040513d6000823e3d90fd5b600080fd5b60a0828281010312610893576020820151916001600160a01b0383168303610893576108c6604082016113d2565b916108d3606083016113d2565b9060808301519260a0810151916001600160401b0383116108935761090192602080928401019201016113e5565b92604051948560808101106001600160401b03608088011117610a235765ffffffffffff926001600160a01b038492608089016040528b89521660208801521660408601521660608401526040519261095984610e79565b83523060208401526040830152823b15610893576109fe926040600080948251968795869485936302b67b5760e41b855233600486015265ffffffffffff606082516001600160a01b0381511660248901526001600160a01b036020820151166044890152828582015116606489015201511660848601526001600160a01b0360208201511660a4860152015160c484015261010060e48401526101048301906113ad565b03925af1801561088757610a14575b80806107f5565b610a1d90610e94565b38610a0d565b634e487b7160e01b600052604160045260246000fd5b91929135610bff57805180610b7a575b50506040516370a0823160e01b8152306004820152602081602481855afa90811561088757600091610b48575b506040516323b872dd60e01b6020820152336024820152306044820152836064820152606481528060a08101106001600160401b0360a083011117610a2357602492610acb8260a060209401604052826111f7565b6040516370a0823160e01b815230600482015293849182905afa801561088757600090610b14575b610afd9250610e20565b146108725760405163162908e360e11b8152600490fd5b506020823d602011610b40575b81610b2e60209383610ea7565b8101031261089357610afd9151610af3565b3d9150610b21565b90506020813d602011610b72575b81610b6360209383610ea7565b81010312610893575138610a76565b3d9150610b56565b60e003610bed5760008091604051610bc0602482602081019463d505accf60e01b8652610bb0815180926020868601910161138a565b8101036004810184520182610ea7565b519082855af1610bce6111c7565b5015610bdb573880610a49565b60405163ddafbaef60e01b8152600490fd5b604051636abdccad60e11b8152600490fd5b909181518201606083820312610893576020830151906040840151936060810151916001600160401b03831161089357610c409260208092019201016113e5565b926001600160a01b037fa5e67a2ca7abbd3d386941b8010a32368804ac328a911a128f9ea68fdba5470f54169160405195610c7a87610e5e565b865283602087015260405195610c8f87610e79565b86526020860152604085015260405191610ca883610e5e565b3083526020830152803b156108935760406000610d2495610d3d829684519889978896879563187945bd60e11b8752610cf8600488018251602080916001600160a01b0381511684520151910152565b6020818101516044890152910151606487015281516001600160a01b03166084870152015160a4850152565b3360c484015261010060e48401526101048301906113ad565b03925af1801561088757610d52575b50610872565b610d5b90610e94565b38610d4c565b634e487b7160e01b600052603260045260246000fd5b602090604051610d8681610e43565b60008152600083820152600060408201526000606082015260006080820152600060a082015282828a0101520161011c565b604051630f52085360e31b8152600490fd5b60405163d92e233d60e01b8152600490fd5b35906001600160a01b038216820361089357565b9181601f84011215610893578235916001600160401b038311610893576020808501948460051b01011161089357565b91908203918211610e2d57565b634e487b7160e01b600052601160045260246000fd5b60c081019081106001600160401b03821117610a2357604052565b604081019081106001600160401b03821117610a2357604052565b606081019081106001600160401b03821117610a2357604052565b6001600160401b038111610a2357604052565b90601f801991011681019081106001600160401b03821117610a2357604052565b6001600160401b038111610a235760051b60200190565b9190811015610d615760051b8101359060fe1981360301821215610893570190565b6001600160401b038111610a2357601f01601f191660200190565b81601f8201121561089357803590610f3382610f01565b92610f416040519485610ea7565b8284526020838301011161089357816000926020809301838601378301015290565b903590601e198136030182121561089357018035906001600160401b0382116108935760200191813603831361089357565b8051821015610d615760209160051b010190565b356001600160a01b03811681036108935790565b60ff611003610fcb83610fa9565b6001600160a01b03166000527f87c11dafdbe0f066e67358ee4040ba0de12255453b9477c97fa61212e07ca30c602052604060002090565b5416158015611061575b61104f5761101a81610fa9565b3b1561103d57608001351561102b57565b60405163391b81e760e21b8152600490fd5b6040516303777f6960e51b8152600490fd5b604051632514e60160e21b8152600490fd5b5060ff611073610fcb60208401610fa9565b54161561100d565b8261108557505050565b6001600160a01b0390811673eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee81036110f25750811615610218574782116110d357600080809381935af16110cb6111c7565b50156101e857565b60405163cf47918160e01b815260048101839052476024820152604490fd5b6040516370a0823160e01b815230600482015290929150602081602481865afa90811561088757600091611193575b50808411611175575060405163a9059cbb60e01b60208201526001600160a01b0390911660248201526044810192909252611173919061116e82606481015b03601f198101845283610ea7565b6111f7565b565b836044916040519163cf47918160e01b835260048301526024820152fd5b906020823d82116111bf575b816111ac60209383610ea7565b810103126111bc57505138611121565b80fd5b3d915061119f565b3d156111f2573d906111d882610f01565b916111e66040519384610ea7565b82523d6000602084013e565b606090565b6001600160a01b03169061125760405161121081610e5e565b6020938482527f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564858301526000808587829751910182855af16112516111c7565b916112f1565b8051918215918483156112c9575b5050509050156112725750565b6084906040519062461bcd60e51b82526004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b6064820152fd5b9193818094500103126112ed578201519081151582036111bc575080388084611265565b5080fd5b919290156113535750815115611305575090565b3b1561130e5790565b60405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000006044820152606490fd5b8251909150156113665750805190602001fd5b60405162461bcd60e51b8152602060048201529081906106169060248301906113ad565b60005b83811061139d5750506000910152565b818101518382015260200161138d565b906020916113c68151809281855285808601910161138a565b601f01601f1916010190565b519065ffffffffffff8216820361089357565b81601f820112156108935780516113fb81610f01565b926114096040519485610ea7565b8184526020828401011161089357611427916020808501910161138a565b90565b6000906001600160a01b031673eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee81036114575750504790565b6020602491604051928380926370a0823160e01b82523060048301525afa9182156114b757809261148757505090565b9091506020823d82116114af575b816114a260209383610ea7565b810103126111bc57505190565b3d9150611495565b604051903d90823e3d90fd5b6001600160a01b03908183161561161057604051636eb1769f60e11b8082523060048301526001600160a01b03851660248301526020959390921692908581604481875afa908115610887576000916115e3575b50818110611528575b505050505050565b61153191610e20565b6040519182523060048301526001600160a01b03841660248301528482604481865afa918215610887576000926115b4575b508101809111610e2d5760405163095ea7b360e01b948101949094526001600160a01b03909216602484015260448301919091526115a9919061116e8260648101611160565b388080808080611520565b90918582813d83116115dc575b6115cb8183610ea7565b810103126111bc5750519038611563565b503d6115c1565b908682813d8311611609575b6115f98183610ea7565b810103126111bc57505138611517565b503d6115ef565b6040516363ba9bff60e01b8152600490fd5b6001600160a01b0380911660009173eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee8214600014611655575050503190565b6024602092939460405194859384926370a0823160e01b84521660048301525afa9182156114b75780926114875750509056fea26469706673582212202f8d6b362d8d4249c9d38fd64de5be16a74a36a54b5c76ce583de82738eeb73964736f6c63430008130033
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.