Source Code
| Transaction Hash |
|
Block
|
From
|
To
|
|||||
|---|---|---|---|---|---|---|---|---|---|
Latest 1 internal transaction
Advanced mode:
| Parent Transaction Hash | Block | From | To | |||
|---|---|---|---|---|---|---|
| 17489584 | 319 days ago | Contract Creation | 0 FRAX |
Cross-Chain Transactions
Loading...
Loading
Contract Name:
CrossChainFacet
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 { LibBridge } from "../Libraries/LibBridge.sol";
import { RefundNative } from "../../Shared/Helpers/RefundNative.sol";
import { ICrossChainFacet } from "../Interfaces/ICrossChainFacet.sol";
import { CrossChainData, GenericBridgeData } from "../Types.sol";
import { FeeType, SwapData, SwapInfo, FeeInfo } from "../../Shared/Types.sol";
/// @title CrossChain Facet
/// @notice Provides functionality for bridging tokens across chains
contract CrossChainFacet is ICrossChainFacet, RefundNative {
/* ========= EXTERNAL ========= */
function bridge(bytes32 _transactionId, address _integrator, GenericBridgeData memory _bridgeData, CrossChainData calldata _genericData) external payable refundExcessNative(msg.sender) {
LibBridge.bridge(_integrator, LibFees.getIntegratorFeeInfo(_integrator, FeeType.BRIDGE), _bridgeData, _genericData);
LibFees.accrueFixedNativeFees(_integrator, FeeType.BRIDGE);
emit BridgeTransferStarted(_transactionId, _integrator, msg.sender, _bridgeData);
}
function bridgeMultipleTokens(bytes32 _transactionId, address _integrator, GenericBridgeData[] memory _bridgeData, CrossChainData[] calldata _genericData) external payable refundExcessNative(msg.sender) {
uint256 length = _bridgeData.length;
FeeInfo memory feeInfo = LibFees.getIntegratorFeeInfo(_integrator, FeeType.BRIDGE);
for (uint256 i; i < length; ) {
LibBridge.bridge(_integrator, feeInfo, _bridgeData[i], _genericData[i]);
unchecked {
++i;
}
}
LibFees.accrueFixedNativeFees(_integrator, FeeType.BRIDGE);
emit MultiTokenBridgeTransferStarted(_transactionId, _integrator, msg.sender, _bridgeData);
}
function swapAndBridge(bytes32 _transactionId, address _integrator, GenericBridgeData[] memory _bridgeData, SwapData[] calldata _swapData, CrossChainData[] calldata _genericData) external payable refundExcessNative(msg.sender) {
uint256 length = _bridgeData.length;
uint256 swapCount;
SwapInfo[] memory swapInfo = new SwapInfo[](_swapData.length);
FeeInfo memory feeInfo = LibFees.getIntegratorFeeInfo(_integrator, FeeType.BRIDGE);
for (uint256 i; i < length; ) {
GenericBridgeData memory bridgeData = _bridgeData[i];
if (bridgeData.hasSourceSwaps) {
swapInfo[swapCount] = LibBridge.swapAndBridge(_integrator, feeInfo, bridgeData, _genericData[i], _swapData[swapCount]);
unchecked {
++swapCount;
}
} else {
// dstSwap or simple bridge
LibBridge.bridgeWithoutSwapAndDestCallCheck(_integrator, feeInfo, bridgeData, _genericData[i]);
}
unchecked {
++i;
}
}
LibFees.accrueFixedNativeFees(_integrator, FeeType.BRIDGE);
emit SwapBridgeTransferStarted(_transactionId, _integrator, msg.sender, _bridgeData, 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;
import { GenericBridgeData, CrossChainData } from "../Types.sol";
import { SwapInfo, SwapData } from "../../Shared/Types.sol";
interface ICrossChainFacet {
/* ========= EVENTS ========= */
event BridgeTransferStarted(bytes32 indexed transactionId, address indexed integrator, address indexed sender, GenericBridgeData bridgeData);
event MultiTokenBridgeTransferStarted(bytes32 indexed transactionId, address indexed integrator, address indexed sender, GenericBridgeData[] bridgeData);
event SwapBridgeTransferStarted(bytes32 indexed transactionId, address indexed integrator, address indexed sender, GenericBridgeData[] bridgeData, SwapInfo[] swapInfo);
/* ========= EXTERNAL ========= */
/// @notice Bridges tokens via arbitrary cross-chain provider
/// @param _bridgeData the core information needed for bridging
/// @param _genericData contains bridge contract call data
function bridge(bytes32 _transactionId, address _integrator, GenericBridgeData memory _bridgeData, CrossChainData calldata _genericData) external payable;
/// @notice Bridges multiple tokens via arbitrary cross-chain provider
/// @param _bridgeData the core information needed for bridging
/// @param _genericData contains bridge contract call data
function bridgeMultipleTokens(bytes32 _transactionId, address _integrator, GenericBridgeData[] memory _bridgeData, CrossChainData[] calldata _genericData) external payable;
/// @notice Bridges multiple tokens via arbitrary cross-chain provider with swaps on src or dst chain
/// @param _bridgeData the core information needed for bridging
/// @param _swapData an array of swap related data for performing swaps before bridging
/// @param _genericData contains bridge contract call data
function swapAndBridge(bytes32 _transactionId, address _integrator, GenericBridgeData[] memory _bridgeData, SwapData[] calldata _swapData, CrossChainData[] calldata _genericData) external payable;
}// SPDX-License-Identifier: MIT
pragma solidity 0.8.19;
import { LibAsset } from "../../Shared/Libraries/LibAsset.sol";
import { LibFees } from "../../Shared/Libraries/LibFees.sol";
import { LibSwap } from "../../Shared/Libraries/LibSwap.sol";
import { LibValidatable } from "../Libraries/LibValidatable.sol";
import { LibBridgeStorage } from "../Libraries/LibBridgeStorage.sol";
import { FeeInfo, SwapInfo, SwapData } from "../../Shared/Types.sol";
import { GenericBridgeData, CrossChainData, CrossChainAllowedList, TransferData } from "../Types.sol";
import { UnAuthorizedCall, BridgeCallFailed, InvalidSwapDetails, SlippageTooLow } from "../../Shared/ErrorsNew.sol";
/// @notice Provides mappings for all facets that may need them
library LibBridge {
function bridge(address _integrator, FeeInfo memory _feeInfo, GenericBridgeData memory _bridgeData, CrossChainData calldata _crossChainData) internal {
LibValidatable.doesNotContainSourceSwapOrDestinationCall(_bridgeData.hasSourceSwaps, _bridgeData.hasDestinationCall);
_bridge(_integrator, _feeInfo, _bridgeData, _crossChainData);
}
function bridgeWithoutSwapAndDestCallCheck(address _integrator, FeeInfo memory _feeInfo, GenericBridgeData memory _bridgeData, CrossChainData calldata _crossChainData) internal {
_bridge(_integrator, _feeInfo, _bridgeData, _crossChainData);
}
function swapAndBridge(address _integrator, FeeInfo memory _feeInfo, GenericBridgeData memory _bridgeData, CrossChainData calldata _crossChainData, SwapData calldata _swapData) internal returns (SwapInfo memory) {
LibValidatable.validateData(_bridgeData);
LibValidatable.validateCrossChainData(_crossChainData);
LibValidatable.validateSwapData(_swapData);
if (_swapData.to != _bridgeData.from) revert InvalidSwapDetails();
(uint256 totalFee, uint256 dZapShare) = LibAsset.deposit(_feeInfo, _swapData.from, _swapData.fromAmount, _swapData.permit);
(uint256 leftoverFromAmount, uint256 returnToAmount) = LibSwap.swap(_swapData, totalFee, false);
if (returnToAmount < _bridgeData.minAmountIn) revert SlippageTooLow(_bridgeData.minAmountIn, returnToAmount);
bytes memory bridgeCalldata = _patchGenericCrossChainData(_bridgeData, _crossChainData, returnToAmount);
_startBridge(_bridgeData.from, _crossChainData.callTo, _crossChainData.approveTo, bridgeCalldata, _bridgeData.minAmountIn, _crossChainData.extraNative);
LibFees.accrueTokenFees(_integrator, _swapData.from, totalFee - dZapShare, dZapShare);
if (leftoverFromAmount != 0) LibAsset.transferToken(_swapData.from, msg.sender, leftoverFromAmount);
if (returnToAmount > _bridgeData.minAmountIn) LibAsset.transferToken(_swapData.to, msg.sender, returnToAmount - _bridgeData.minAmountIn);
return SwapInfo(_swapData.callTo, _swapData.from, _swapData.to, _swapData.fromAmount, leftoverFromAmount, returnToAmount);
}
function transferBridge(address _integrator, FeeInfo memory _feeInfo, GenericBridgeData memory _bridgeData, TransferData calldata _transferData) internal {
LibValidatable.validateData(_bridgeData);
LibValidatable.doesNotContainSourceSwapOrDestinationCall(_bridgeData.hasSourceSwaps, _bridgeData.hasDestinationCall);
_transferBridge(_integrator, _feeInfo, _bridgeData, _transferData);
}
function transferBridgeWithoutSwapAndDestCallCheck(address _integrator, FeeInfo memory _feeInfo, GenericBridgeData memory _bridgeData, TransferData calldata _transferData) internal {
LibValidatable.validateData(_bridgeData);
_transferBridge(_integrator, _feeInfo, _bridgeData, _transferData);
}
function swapAndBridgeViaTransfer(address _integrator, FeeInfo memory _feeInfo, GenericBridgeData memory _bridgeData, TransferData calldata _transferData, SwapData calldata _swapData) internal returns (SwapInfo memory) {
LibValidatable.validateData(_bridgeData);
LibValidatable.validateSwapData(_swapData);
if (_swapData.to != _bridgeData.from) revert InvalidSwapDetails();
(uint256 totalFee, uint256 dZapShare) = LibAsset.deposit(_feeInfo, _swapData.from, _swapData.fromAmount, _swapData.permit);
(uint256 leftoverFromAmount, uint256 returnToAmount) = LibSwap.swap(_swapData, totalFee, false);
if (returnToAmount < _bridgeData.minAmountIn) revert SlippageTooLow(_bridgeData.minAmountIn, returnToAmount);
_bridgeData.minAmountIn = returnToAmount;
if (LibAsset.isNativeToken(_bridgeData.from)) {
LibAsset.transferNativeToken(_transferData.transferTo, _bridgeData.minAmountIn);
} else {
LibAsset.transferERC20(_bridgeData.from, _transferData.transferTo, _bridgeData.minAmountIn);
}
LibFees.accrueTokenFees(_integrator, _swapData.from, totalFee - dZapShare, dZapShare);
if (leftoverFromAmount != 0) LibAsset.transferToken(_swapData.from, msg.sender, leftoverFromAmount);
return SwapInfo(_swapData.callTo, _swapData.from, _swapData.to, _swapData.fromAmount, leftoverFromAmount, returnToAmount);
}
function _startBridge(address _from, address _callTo, address _approveTo, bytes memory _callData, uint256 _minAmountIn, uint256 _extraNative) private {
uint256 nativeValue;
if (LibAsset.isNativeToken(_from)) {
nativeValue = _minAmountIn;
} else {
LibAsset.approveERC20(_from, _approveTo, _minAmountIn);
}
(bool success, bytes memory res) = _callTo.call{ value: nativeValue + _extraNative }(_callData);
if (!success) {
revert BridgeCallFailed(res);
}
}
function _bridge(address _integrator, FeeInfo memory _feeInfo, GenericBridgeData memory _bridgeData, CrossChainData calldata _crossChainData) private {
LibValidatable.validateData(_bridgeData);
LibValidatable.validateCrossChainData(_crossChainData);
(uint256 totalFee, uint256 dZapShare) = LibAsset.deposit(_feeInfo, _bridgeData.from, _bridgeData.minAmountIn, _crossChainData.permit);
_bridgeData.minAmountIn -= totalFee;
LibFees.accrueTokenFees(_integrator, _bridgeData.from, totalFee - dZapShare, dZapShare);
_startBridge(_bridgeData.from, _crossChainData.callTo, _crossChainData.approveTo, _crossChainData.callData, _bridgeData.minAmountIn, _crossChainData.extraNative);
}
function _patchGenericCrossChainData(GenericBridgeData memory _bridgeData, CrossChainData calldata _crossChainData, uint256 amount) private view returns (bytes memory) {
uint256 offset = LibBridgeStorage.getCrossChainStorage().allowlist[_crossChainData.callTo].selectorToInfo[bytes4(_crossChainData.callData[:4])];
if (offset != 0) {
_bridgeData.minAmountIn = amount;
return bytes.concat(_crossChainData.callData[:offset], abi.encode(amount), _crossChainData.callData[offset + 32:]);
} else return _crossChainData.callData;
}
function _transferBridge(address _integrator, FeeInfo memory _feeInfo, GenericBridgeData memory _bridgeData, TransferData calldata _transferData) internal {
(uint256 totalFee, uint256 dZapShare) = LibAsset.deposit(_feeInfo, _bridgeData.from, _bridgeData.minAmountIn, _transferData.permit);
_bridgeData.minAmountIn -= totalFee;
if (LibAsset.isNativeToken(_bridgeData.from)) {
LibAsset.transferNativeToken(_transferData.transferTo, _bridgeData.minAmountIn);
} else {
LibAsset.transferERC20(_bridgeData.from, _transferData.transferTo, _bridgeData.minAmountIn);
}
LibFees.accrueTokenFees(_integrator, _bridgeData.from, totalFee - dZapShare, dZapShare);
}
function swap(address _integrator, FeeInfo memory _feeInfo, GenericBridgeData memory _bridgeData, SwapData calldata _swapData) internal returns (SwapInfo memory) {
LibValidatable.validateSwapData(_swapData);
if (_swapData.to != _bridgeData.from) revert InvalidSwapDetails();
(uint256 totalFee, uint256 dZapShare) = LibAsset.deposit(_feeInfo, _swapData.from, _swapData.fromAmount, _swapData.permit);
(uint256 leftoverFromAmount, uint256 returnToAmount) = LibSwap.swap(_swapData, totalFee, false);
if (returnToAmount < _bridgeData.minAmountIn) revert SlippageTooLow(_bridgeData.minAmountIn, returnToAmount);
LibFees.accrueTokenFees(_integrator, _swapData.from, totalFee - dZapShare, dZapShare);
if (leftoverFromAmount != 0) LibAsset.transferToken(_swapData.from, msg.sender, leftoverFromAmount);
if (returnToAmount > _bridgeData.minAmountIn) LibAsset.transferToken(_swapData.to, msg.sender, returnToAmount - _bridgeData.minAmountIn);
return SwapInfo(_swapData.callTo, _swapData.from, _swapData.to, _swapData.fromAmount, leftoverFromAmount, returnToAmount);
}
}// SPDX-License-Identifier: MIT
pragma solidity 0.8.19;
import { CrossChainStorage } from "../Types.sol";
/// @notice Provides mappings for all facets that may need them
library LibBridgeStorage {
bytes32 internal constant CROSS_CHAIN_NAMESPACE = keccak256("dzap.library.cross.chain.allowed.list");
/// @dev Fetch local storage for Generic Cross Chain
function getCrossChainStorage() internal pure returns (CrossChainStorage storage cs) {
bytes32 position = CROSS_CHAIN_NAMESPACE;
// solhint-disable-next-line no-inline-assembly
assembly {
cs.slot := position
}
}
}// SPDX-License-Identifier: UNLICENSED
pragma solidity 0.8.19;
import { LibAsset } from "../../Shared/Libraries/LibAsset.sol";
import { LibAllowList } from "../../Shared/Libraries/LibAllowList.sol";
import { LibBridgeStorage } from "../Libraries/LibBridgeStorage.sol";
import { InformationMismatch, CannotBridgeToSameNetwork, InvalidAmount, NotAContract, InvalidContract, InvalidLength, ContractCallNotAllowed, NoSwapFromZeroBalance, UnAuthorizedCall } from "../../Shared/ErrorsNew.sol";
import { BridgeData, GenericBridgeData, CrossChainData } from "../Types.sol";
import { SwapData } from "../../Shared/Types.sol";
library LibValidatable {
uint256 internal constant _MAX_ADDRESS_LENGTH = 255;
function validateSwapData(SwapData calldata _swapData) internal view {
if (!LibAllowList.contractIsAllowed(_swapData.callTo)) revert UnAuthorizedCall(_swapData.callTo);
if (!LibAsset.isContract(_swapData.callTo)) revert InvalidContract();
if (_swapData.fromAmount == 0) revert NoSwapFromZeroBalance();
}
function validateData(GenericBridgeData memory _bridgeData) internal view {
if (_bridgeData.to.length > _MAX_ADDRESS_LENGTH || _bridgeData.receiver.length > _MAX_ADDRESS_LENGTH) revert InvalidLength();
if (_bridgeData.minAmountIn == 0) revert InvalidAmount();
if (_bridgeData.destinationChainId == block.chainid) revert CannotBridgeToSameNetwork();
}
function validateCrossChainData(CrossChainData calldata _crossChainData) internal view {
if (!LibAsset.isContract(_crossChainData.callTo)) revert NotAContract();
if (!LibBridgeStorage.getCrossChainStorage().allowlist[_crossChainData.callTo].isWhitelisted) revert UnAuthorizedCall(_crossChainData.callTo);
}
function hasSourceSwaps(bool _hasSourceSwaps) internal pure {
if (!_hasSourceSwaps) revert InformationMismatch();
}
function doesNotContainSourceSwaps(bool _hasSourceSwaps) internal pure {
if (_hasSourceSwaps) revert InformationMismatch();
}
function doesNotContainDestinationCall(bool _hasDestinationCall) internal pure {
if (_hasDestinationCall) revert InformationMismatch();
}
function doesNotContainSourceSwapOrDestinationCall(bool _hasSourceSwaps, bool _hasDestinationCall) internal pure {
if (_hasSourceSwaps) revert InformationMismatch();
if (_hasDestinationCall) revert InformationMismatch();
}
}// SPDX-License-Identifier: MIT
pragma solidity 0.8.19;
struct CrossChainAllowedList {
mapping(bytes4 => uint256) selectorToInfo;
bool isWhitelisted;
}
struct CrossChainStorage {
mapping(address => CrossChainAllowedList) allowlist;
mapping(address => bool) adaptersAllowlist;
}
struct TransferData {
address transferTo;
bytes permit;
}
struct CrossChainData {
address callTo;
address approveTo;
uint256 extraNative;
bytes permit;
bytes callData;
}
struct BridgeData {
string bridge;
address from;
address to;
address receiver;
bool hasSourceSwaps;
bool hasDestinationCall;
uint256 minAmountIn;
uint256 destinationChainId;
}
struct GenericBridgeData {
string bridge;
bytes to;
bytes receiver;
address from;
bool hasSourceSwaps;
bool hasDestinationCall;
uint256 minAmountIn;
uint256 destinationChainId;
}
struct RelayData {
bytes32 requestId;
bytes permit;
}
struct GasZipData {
bytes32 recipient; // EVM addresses need to be padded with trailing 0s,
uint256 destChains; // short Chains
uint256 depositAmount;
}
struct AdapterData {
address adapter;
bytes data;
bytes permit;
}// 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;
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;
}{
"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":[{"internalType":"bytes","name":"reason","type":"bytes"}],"name":"BridgeCallFailed","type":"error"},{"inputs":[],"name":"CannotBridgeToSameNetwork","type":"error"},{"inputs":[],"name":"InformationMismatch","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":"InvalidLength","type":"error"},{"inputs":[],"name":"InvalidPermit","type":"error"},{"inputs":[],"name":"InvalidPermitData","type":"error"},{"inputs":[],"name":"InvalidSwapDetails","type":"error"},{"inputs":[],"name":"NativeTransferFailed","type":"error"},{"inputs":[],"name":"NoSwapFromZeroBalance","type":"error"},{"inputs":[],"name":"NoTransferToNullAddress","type":"error"},{"inputs":[],"name":"NotAContract","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":[{"internalType":"address","name":"","type":"address"}],"name":"UnAuthorizedCall","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"},{"components":[{"internalType":"string","name":"bridge","type":"string"},{"internalType":"bytes","name":"to","type":"bytes"},{"internalType":"bytes","name":"receiver","type":"bytes"},{"internalType":"address","name":"from","type":"address"},{"internalType":"bool","name":"hasSourceSwaps","type":"bool"},{"internalType":"bool","name":"hasDestinationCall","type":"bool"},{"internalType":"uint256","name":"minAmountIn","type":"uint256"},{"internalType":"uint256","name":"destinationChainId","type":"uint256"}],"indexed":false,"internalType":"struct GenericBridgeData","name":"bridgeData","type":"tuple"}],"name":"BridgeTransferStarted","type":"event"},{"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"},{"components":[{"internalType":"string","name":"bridge","type":"string"},{"internalType":"bytes","name":"to","type":"bytes"},{"internalType":"bytes","name":"receiver","type":"bytes"},{"internalType":"address","name":"from","type":"address"},{"internalType":"bool","name":"hasSourceSwaps","type":"bool"},{"internalType":"bool","name":"hasDestinationCall","type":"bool"},{"internalType":"uint256","name":"minAmountIn","type":"uint256"},{"internalType":"uint256","name":"destinationChainId","type":"uint256"}],"indexed":false,"internalType":"struct GenericBridgeData[]","name":"bridgeData","type":"tuple[]"}],"name":"MultiTokenBridgeTransferStarted","type":"event"},{"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"},{"components":[{"internalType":"string","name":"bridge","type":"string"},{"internalType":"bytes","name":"to","type":"bytes"},{"internalType":"bytes","name":"receiver","type":"bytes"},{"internalType":"address","name":"from","type":"address"},{"internalType":"bool","name":"hasSourceSwaps","type":"bool"},{"internalType":"bool","name":"hasDestinationCall","type":"bool"},{"internalType":"uint256","name":"minAmountIn","type":"uint256"},{"internalType":"uint256","name":"destinationChainId","type":"uint256"}],"indexed":false,"internalType":"struct GenericBridgeData[]","name":"bridgeData","type":"tuple[]"},{"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":"SwapBridgeTransferStarted","type":"event"},{"inputs":[{"internalType":"bytes32","name":"_transactionId","type":"bytes32"},{"internalType":"address","name":"_integrator","type":"address"},{"components":[{"internalType":"string","name":"bridge","type":"string"},{"internalType":"bytes","name":"to","type":"bytes"},{"internalType":"bytes","name":"receiver","type":"bytes"},{"internalType":"address","name":"from","type":"address"},{"internalType":"bool","name":"hasSourceSwaps","type":"bool"},{"internalType":"bool","name":"hasDestinationCall","type":"bool"},{"internalType":"uint256","name":"minAmountIn","type":"uint256"},{"internalType":"uint256","name":"destinationChainId","type":"uint256"}],"internalType":"struct GenericBridgeData","name":"_bridgeData","type":"tuple"},{"components":[{"internalType":"address","name":"callTo","type":"address"},{"internalType":"address","name":"approveTo","type":"address"},{"internalType":"uint256","name":"extraNative","type":"uint256"},{"internalType":"bytes","name":"permit","type":"bytes"},{"internalType":"bytes","name":"callData","type":"bytes"}],"internalType":"struct CrossChainData","name":"_genericData","type":"tuple"}],"name":"bridge","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"_transactionId","type":"bytes32"},{"internalType":"address","name":"_integrator","type":"address"},{"components":[{"internalType":"string","name":"bridge","type":"string"},{"internalType":"bytes","name":"to","type":"bytes"},{"internalType":"bytes","name":"receiver","type":"bytes"},{"internalType":"address","name":"from","type":"address"},{"internalType":"bool","name":"hasSourceSwaps","type":"bool"},{"internalType":"bool","name":"hasDestinationCall","type":"bool"},{"internalType":"uint256","name":"minAmountIn","type":"uint256"},{"internalType":"uint256","name":"destinationChainId","type":"uint256"}],"internalType":"struct GenericBridgeData[]","name":"_bridgeData","type":"tuple[]"},{"components":[{"internalType":"address","name":"callTo","type":"address"},{"internalType":"address","name":"approveTo","type":"address"},{"internalType":"uint256","name":"extraNative","type":"uint256"},{"internalType":"bytes","name":"permit","type":"bytes"},{"internalType":"bytes","name":"callData","type":"bytes"}],"internalType":"struct CrossChainData[]","name":"_genericData","type":"tuple[]"}],"name":"bridgeMultipleTokens","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"_transactionId","type":"bytes32"},{"internalType":"address","name":"_integrator","type":"address"},{"components":[{"internalType":"string","name":"bridge","type":"string"},{"internalType":"bytes","name":"to","type":"bytes"},{"internalType":"bytes","name":"receiver","type":"bytes"},{"internalType":"address","name":"from","type":"address"},{"internalType":"bool","name":"hasSourceSwaps","type":"bool"},{"internalType":"bool","name":"hasDestinationCall","type":"bool"},{"internalType":"uint256","name":"minAmountIn","type":"uint256"},{"internalType":"uint256","name":"destinationChainId","type":"uint256"}],"internalType":"struct GenericBridgeData[]","name":"_bridgeData","type":"tuple[]"},{"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":"_swapData","type":"tuple[]"},{"components":[{"internalType":"address","name":"callTo","type":"address"},{"internalType":"address","name":"approveTo","type":"address"},{"internalType":"uint256","name":"extraNative","type":"uint256"},{"internalType":"bytes","name":"permit","type":"bytes"},{"internalType":"bytes","name":"callData","type":"bytes"}],"internalType":"struct CrossChainData[]","name":"_genericData","type":"tuple[]"}],"name":"swapAndBridge","outputs":[],"stateMutability":"payable","type":"function"}]Contract Creation Code
6080806040523461001657612081908161001c8239f35b600080fdfe60a0604052600436101561001257600080fd5b60003560e01c806373de905e146108465780639560c279146107795763f2bfe6d41461003d57600080fd5b60a036600319011261072557610051610937565b60805267ffffffffffffffff60443581811161072557610075903690600401610b82565b6064358281116107255761008d903690600401610c03565b919092608435908111610725576100a8903690600401610c03565b9290936100b6473490610c34565b948351916000916100c685610a09565b966100d460405198896109e7565b8588526100e086610a09565b60005b601f19820181106107625750506100fb608051611e74565b906000945b868610610207578a8a8a610115608051611c99565b61012a60405191604083526040830190610d54565b6020908281038284015281808551928381520194019160005b8281106101ad575050505033917f7100e53eb3aac320a51df570e0e4b2871832f7f8135fb72e265f4f56e79d46df6001600160a01b03608051169280600435930390a4479080821161019157005b61019a91610c34565b806101a157005b6101ab9033611634565b005b909192948260c060019260a089516001600160a01b038082511684528086830151168685015260408201511660408401526060808201519084015260808101516080840152015160a0820152019601910192919092610143565b610211868a610d1e565b5160808101511561074057610227878487610d32565b908983101561072a5760fe19873603018360051b88013512156107255761024c610db0565b506102568161111f565b61025f8261118e565b6001600160a01b036102788460051b8901358901610e19565b166000527f87c11dafdbe0f066e67358ee4040ba0de12255453b9477c97fa61212e07ca30c60205260ff60406000205416156106f4576102bf8360051b8801358801610e19565b3b156106e25760808360051b88013588010135156106d0576102eb60608460051b890135890101610e19565b6001600160a01b03806060840151169116036106be5760409061034661031a838660051b8b01358b0101610e19565b610331600587901b8b01358b0160e0810190610e2d565b9160808860051b8d01358d010135908a6116a6565b906000946103858b61038061037b61036a8660808d60051b86013586010135610c34565b9889938c60051b8101350101610e19565b611fb2565b610c34565b946000808d6103a161037b60608d60051b840135840101610e19565b938b73eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee6001600160a01b036103d56040879460051b870135870101610e19565b1614841461068557505b6104098c6103f48160051b8501358501610e19565b9360059190911b8101350160c0810190610e2d565b9190826040519384928337810185815203925af1610425610e6d565b901561065c57506104479061038061037b60608f8c60051b8101350101610e19565b9460a08860051b8d01358d01013580871061063e575061047461037b60408e8b60051b8101350101610e19565b81811161062b575b505060c084015180861061060d57508f90948b60c08661050f6105a4978c9a976104e88960019f9a60019f9d6104b3918b91610fd9565b906001600160a01b03606088015116916104cc82610e19565b6104d860208401610e19565b9060408b8b015194013594610e9d565b6105068261050060408c60051b8a01358a0101610e19565b92610c34565b90608051611da7565b876105ea575b01518083116105ba575b50506105328360051b8d01358d01610e19565b946001600160a01b038d81610565606061055660408a60051b860135860101610e19565b938960051b8101350101610e19565b91816040519a6105748c61094d565b168a5216602089015216604087015260808d8560051b8101350101356060870152608086015260a0850152610d1e565b526105af818d610d1e565b5001955b0194610100565b6105db6105d460606105e3948860051b8101350101610e19565b9184610c34565b90339061153d565b8b3861051f565b610608883361060360408a60051b880135880101610e19565b61153d565b610515565b604490866040519163a81ff3b360e01b835260048301526024820152fd5b610636929750610c34565b94388061047c565b604490876040519163a81ff3b360e01b835260048301526024820152fd5b60405163729a0b5b60e01b815260206004820152908190610681906024830190610c7a565b0390fd5b906106b9908d6106b360206106a460408460051b890135890101610e19565b9260051b870135870101610e19565b90611221565b6103df565b6040516310ec1e7b60e11b8152600490fd5b60405163391b81e760e21b8152600490fd5b6040516303777f6960e51b8152600490fd5b6024610707888560051b81013501610e19565b6001600160a01b0360405191632cbf75f960e01b8352166004820152fd5b600080fd5b634e487b7160e01b600052603260045260246000fd5b9561075d60019297610753838689610d32565b9086608051610f29565b6105b3565b60209061076d610db0565b82828d010152016100e3565b6003196080368201126107255761078e610937565b67ffffffffffffffff91604435838111610725576107b0903690600401610a9f565b906064359384116107255760a0908436030112610725576107e86107d43447610c34565b93600401826107e285611e74565b85610de2565b6107f182611c99565b60405190602082527f9b3f3eeeff2d4b02d97c87aef001ca8800386a80d1c1af89970e03e02fcc031a6001600160a01b033394169280610838600435946020830190610c9f565b0390a4479080821161019157005b60803660031901126107255761085a610937565b67ffffffffffffffff906044358281116107255761087c903690600401610b82565b9160643590811161072557610895903690600401610c03565b9092906108a23447610c34565b938251916108af85611e74565b9060005b84811061090d578787876108c682611c99565b60405190602082527fcec71c1e3443762470423056741f346979df345f8b71d2ea5ab10523439322496001600160a01b033394169280610838600435946020830190610d54565b8061093161091d60019389610d1e565b51610929838689610d32565b90868b610de2565b016108b3565b602435906001600160a01b038216820361072557565b60c0810190811067ffffffffffffffff82111761096957604052565b634e487b7160e01b600052604160045260246000fd5b6040810190811067ffffffffffffffff82111761096957604052565b6060810190811067ffffffffffffffff82111761096957604052565b67ffffffffffffffff811161096957604052565b6080810190811067ffffffffffffffff82111761096957604052565b90601f8019910116810190811067ffffffffffffffff82111761096957604052565b67ffffffffffffffff81116109695760051b60200190565b67ffffffffffffffff811161096957601f01601f191660200190565b929192610a4982610a21565b91610a5760405193846109e7565b829481845281830111610725578281602093846000960137010152565b9080601f8301121561072557816020610a8f93359101610a3d565b90565b3590811515820361072557565b9190916101009081818503126107255760405191820167ffffffffffffffff9083811082821117610969576040528294823582811161072557830181601f820112156107255781816020610af593359101610a3d565b845260208301358281116107255781610b0f918501610a74565b6020850152604083013591821161072557610b2b918301610a74565b604083015260608101356001600160a01b03811681036107255760e09182916060850152610b5b60808201610a92565b6080850152610b6c60a08201610a92565b60a085015260c081013560c08501520135910152565b9080601f8301121561072557813590610b9a82610a09565b92610ba860405194856109e7565b828452602092838086019160051b8301019280841161072557848301915b848310610bd65750505050505090565b823567ffffffffffffffff8111610725578691610bf884848094890101610a9f565b815201920191610bc6565b9181601f840112156107255782359167ffffffffffffffff8311610725576020808501948460051b01011161072557565b91908203918211610c4157565b634e487b7160e01b600052601160045260246000fd5b60005b838110610c6a5750506000910152565b8181015183820152602001610c5a565b90602091610c9381518092818552858086019101610c57565b601f01601f1916010190565b9060e080610ce0610cce610cbc8651610100808852870190610c7a565b60208701518682036020880152610c7a565b60408601518582036040870152610c7a565b936001600160a01b03606082015116606085015260808101511515608085015260a0810151151560a085015260c081015160c0850152015191015290565b805182101561072a5760209160051b010190565b919081101561072a5760051b81013590609e1981360301821215610725570190565b908082519081815260208091019281808460051b8301019501936000915b848310610d825750505050505090565b9091929394958480610da0600193601f198682030187528a51610c9f565b9801930193019194939290610d72565b60405190610dbd8261094d565b8160a06000918281528260208201528260408201528260608201528260808201520152565b9291906080820151151560a0830151151590610e0757610e0757610e0593610f29565b565b604051631437241760e21b8152600490fd5b356001600160a01b03811681036107255790565b903590601e1981360301821215610725570180359067ffffffffffffffff82116107255760200191813603831361072557565b91908201809211610c4157565b3d15610e98573d90610e7e82610a21565b91610e8c60405193846109e7565b82523d6000602084013e565b606090565b94600095948695610ed99394879173eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee6001600160a01b038216148914610f1857505050610e60565b602083519301915af1610eea610e6d565b9015610ef35750565b6040516343373c4f60e01b815260206004820152908190610681906024830190610c7a565b90610f24929391611221565b610e60565b90604092610e059492610f3b8261111f565b610f448461118e565b610f9b6060830191610f786001600160a01b039460c0868651169101968751610f7060608b018b610e2d565b9390926116a6565b9190610f85818851610c34565b8752610f95838787511692610c34565b91611da7565b511690610fa783610e19565b610fd3610fb660208601610e19565b92610fc46080870187610e2d565b97909151960135963691610a3d565b92610e9d565b916001600160a01b03610feb83610e19565b1690600091825260207f8e6e95df1ece690939b98cef864b1c94a5769d9a8dd8de14e3577126a9e3083e81526040832093608081019461102b8683610e2d565b6004116110e857356001600160e01b0319168552825260408420549586156111045760c08491015261105d8582610e2d565b87969196116111005761108590604051928484019586528484526110808461097f565b610e2d565b8388939293018089116110ec5781106110e857918795939186610a8f9896940393604051998a97858901376110c7888801918583019388855251938491610c57565b019180601f19978886019301019083013701908152039081018352826109e7565b8580fd5b634e487b7160e01b87526011600452602487fd5b8480fd5b50915050610a8f9350611118929150610e2d565b3691610a3d565b60ff60208201515111801561117f575b61116d5760c08101511561115b5760e00151461461114957565b604051634ac09ad360e01b8152600490fd5b60405163162908e360e11b8152600490fd5b60405163251f56a160e21b8152600490fd5b5060ff6040820151511161112f565b61119781610e19565b3b1561120f576001600160a01b0390816111b082610e19565b166000527f8e6e95df1ece690939b98cef864b1c94a5769d9a8dd8de14e3577126a9e3083e60205260ff60016040600020015416156111ed575050565b906111f9602492610e19565b604051632cbf75f960e01b815291166004820152fd5b6040516309ee12d560e01b8152600490fd5b9291926001600160a01b03908183161561139857604051636eb1769f60e11b8082523060048301526001600160a01b038516602483015260209693909216928682604481875afa91821561135d57600092611369575b50808210611289575b50505050509050565b9061129391610c34565b6040519182523060048301526001600160a01b0384166024830152908581604481865afa90811561135d5760009161132b575b509461130d6112dc61131b936113209798610e60565b60405195869363095ea7b360e01b9085015260248401602090939291936001600160a01b0360408201951681520152565b03601f1981018452836109e7565b6113aa565b803880808080611280565b908682813d8311611356575b61134181836109e7565b8101031261135357505161130d6112c6565b80fd5b503d611337565b6040513d6000823e3d90fd5b90918782813d8311611391575b61138081836109e7565b810103126113535750519038611277565b503d611376565b6040516363ba9bff60e01b8152600490fd5b6001600160a01b03169061140a6040516113c38161097f565b6020938482527f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564858301526000808587829751910182855af1611404610e6d565b916114a4565b80519182159184831561147c575b5050509050156114255750565b6084906040519062461bcd60e51b82526004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b6064820152fd5b9193818094500103126114a057820151908115158203611353575080388084611418565b5080fd5b9192901561150657508151156114b8575090565b3b156114c15790565b60405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000006044820152606490fd5b8251909150156115195750805190602001fd5b60405162461bcd60e51b815260206004820152908190610681906024830190610c7a565b8261154757505050565b6001600160a01b031673eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee8103611576575090610e0591611634565b906040516370a0823160e01b8152306004820152602081602481865afa90811561135d57600091611603575b508084116115e5575060405163a9059cbb60e01b60208201526001600160a01b0390911660248201526044810192909252610e05919061131b826064810161130d565b836044916040519163cf47918160e01b835260048301526024820152fd5b906020823d821161162c575b8161161c602093836109e7565b81010312611353575051386115a2565b3d915061160f565b6001600160a01b038116156116945747821161167557600080809381935af161165b610e6d565b501561166357565b604051633d2cec6f60e21b8152600490fd5b60405163cf47918160e01b815260048101839052476024820152604490fd5b6040516321f7434560e01b8152600490fd5b919290936000946001600160a01b03918282169073eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee8203611712575b50505050508291815190816116ed575b5050509091565b604092945061170a93509061170191611e01565b92015182611e01565b3880806116e6565b84016040928386830312611c95578535956003871015611c91576020928382013567ffffffffffffffff928382116119725761174f929101610a74565b916002880361197a57508596507fa5e67a2ca7abbd3d386941b8010a32368804ac328a911a128f9ea68fdba5470f95939495928484541691835180611811575b5050505050541692833b1561180d5790608487928385519687948593631b63c28b60e11b85523360048601523060248601528b16604485015260648401525af190811561180457509084916117ec575b50505b38808080806116d6565b6117f5906109b7565b6118005782386117df565b8280fd5b513d86823e3d90fd5b8680fd5b90919293809596500160a0858203126119765782850151928984168094036119725761183e898701611f5d565b9561184b60608201611f5d565b9360808201519360a083015191821161196e5761186e9290840191018301611f70565b9289519461187b866109cb565b8986528286015265ffffffffffff96878092168b8701521660608501528851936118a48561099b565b845280840190308252898501928352853b1561196a5789516302b67b5760e41b8152336004820152945180518c166024870152908101518b166044860152808a0151871660648601526060015190951660848401529351881660a4830152925160c482015261010060e4820152918991839182908490829061192b90610104830190610c7a565b03925af18015611960578592918991611947575b80808061178f565b611953919293506109b7565b61180d578390873861193f565b84513d8a823e3d90fd5b8d80fd5b8f80fd5b8c80fd5b8b80fd5b929590949615600014611b435750805180611ac2575b5050508351916370a0823160e01b8084523060048501528484602481865afa938415611ab8578994611a89575b5085516323b872dd60e01b8682015233602482015230604482015260648082018a905281529160a0830190811183821017610969578592611a00918852846113aa565b602486518094819382523060048301525afa908115611a7f57908692918891611a4b575b50611a30929350610c34565b03611a3b57506117e2565b5163162908e360e11b8152600490fd5b9250509181813d8311611a78575b611a6381836109e7565b81010312610725575184918291611a30611a24565b503d611a59565b84513d89823e3d90fd5b9093508481813d8311611ab1575b611aa181836109e7565b81010312610725575192386119bd565b503d611a97565b86513d8b823e3d90fd5b60e003611b325788918291828851611b076024828b81019563d505accf60e01b8752611af78d82519283918686019101610c57565b81010360048101845201826109e7565b51925af1611b13610e6d565b5015611b2157388080611990565b835163ddafbaef60e01b8152600490fd5b8551636abdccad60e11b8152600490fd5b81518201969593925090606081880312611c915783810151948682015197606083015191821161197657611b7d9290860191018501611f70565b907fa5e67a2ca7abbd3d386941b8010a32368804ac328a911a128f9ea68fdba5470f541692855192611bae8461097f565b83528881840152855192611bc18461099b565b835280830194855285830196875288865191611bdc8361097f565b308352820152833b15611c9157855163187945bd60e11b8152925180516001600160a01b0316600485015260200151602484015291958994879493859387938593611c6793611c4e92909151604487015251606486015280516001600160a01b031660848601526020015160a4850152565b3360c484015261010060e4840152610104830190610c7a565b03925af19081156118045750611c7e575b506117e2565b611c8a909391936109b7565b9138611c78565b8980fd5b8880fd5b6001611cd7826001600160a01b03166000527fadf38b383de83e03163f4bb9c9eeeeff060c277df907ebce1fd27038d38e2e08602052604060002090565b016000805260205260406000206060604051611cf2816109cb565b825481526003600184015493846020840152600281015460408401520154918291015281158015611d24575b50505050565b81830291838304141715610c4157620f42409004918183809311611d8c575b5050611d52575b808080611d1e565b611d86906001600160a01b037fadf38b383de83e03163f4bb9c9eeeeff060c277df907ebce1fd27038d38e2e0b5416611634565b38611d4a565b611d9f92611d9991610c34565b90611634565b803880611d43565b90929180611df0575b505080611dbb575050565b610e05916001600160a01b037fadf38b383de83e03163f4bb9c9eeeeff060c277df907ebce1fd27038d38e2e0b54169061153d565b611dfa918461153d565b3880611db0565b90919060001983820983820291828083109203948286039260009614611e6657620f4240918383111561180d577fde8f6cefed634549b62c77574f722e1ac57e23f24d8fd5cb790fb65668c261399596500990828211900360fa1b910360061c170290565b505050620f42409192500490565b60606040918251611e84816109cb565b60009281848093528260208201528286820152015260ff611ed7826001600160a01b03166000527fadf38b383de83e03163f4bb9c9eeeeff060c277df907ebce1fd27038d38e2e08602052604060002090565b541615611f4c576003916001600160a01b0384921681527fadf38b383de83e03163f4bb9c9eeeeff060c277df907ebce1fd27038d38e2e0860205260018282200181805260205220825192611f2b846109cb565b81548452600182015460208501526002820154908401520154606082015290565b8251630f52085360e31b8152600490fd5b519065ffffffffffff8216820361072557565b81601f82011215610725578051611f8681610a21565b92611f9460405194856109e7565b8184526020828401011161072557610a8f9160208085019101610c57565b6000906001600160a01b031673eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee8103611fdf5750504790565b6020602491604051928380926370a0823160e01b82523060048301525afa91821561203f57809261200f57505090565b9091506020823d8211612037575b8161202a602093836109e7565b8101031261135357505190565b3d915061201d565b604051903d90823e3d90fdfea26469706673582212205e8d62865d649fd647681db77e28a612b886e6aca7cc096835ab47ebdbba8c0264736f6c63430008130033
Deployed Bytecode
0x60a0604052600436101561001257600080fd5b60003560e01c806373de905e146108465780639560c279146107795763f2bfe6d41461003d57600080fd5b60a036600319011261072557610051610937565b60805267ffffffffffffffff60443581811161072557610075903690600401610b82565b6064358281116107255761008d903690600401610c03565b919092608435908111610725576100a8903690600401610c03565b9290936100b6473490610c34565b948351916000916100c685610a09565b966100d460405198896109e7565b8588526100e086610a09565b60005b601f19820181106107625750506100fb608051611e74565b906000945b868610610207578a8a8a610115608051611c99565b61012a60405191604083526040830190610d54565b6020908281038284015281808551928381520194019160005b8281106101ad575050505033917f7100e53eb3aac320a51df570e0e4b2871832f7f8135fb72e265f4f56e79d46df6001600160a01b03608051169280600435930390a4479080821161019157005b61019a91610c34565b806101a157005b6101ab9033611634565b005b909192948260c060019260a089516001600160a01b038082511684528086830151168685015260408201511660408401526060808201519084015260808101516080840152015160a0820152019601910192919092610143565b610211868a610d1e565b5160808101511561074057610227878487610d32565b908983101561072a5760fe19873603018360051b88013512156107255761024c610db0565b506102568161111f565b61025f8261118e565b6001600160a01b036102788460051b8901358901610e19565b166000527f87c11dafdbe0f066e67358ee4040ba0de12255453b9477c97fa61212e07ca30c60205260ff60406000205416156106f4576102bf8360051b8801358801610e19565b3b156106e25760808360051b88013588010135156106d0576102eb60608460051b890135890101610e19565b6001600160a01b03806060840151169116036106be5760409061034661031a838660051b8b01358b0101610e19565b610331600587901b8b01358b0160e0810190610e2d565b9160808860051b8d01358d010135908a6116a6565b906000946103858b61038061037b61036a8660808d60051b86013586010135610c34565b9889938c60051b8101350101610e19565b611fb2565b610c34565b946000808d6103a161037b60608d60051b840135840101610e19565b938b73eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee6001600160a01b036103d56040879460051b870135870101610e19565b1614841461068557505b6104098c6103f48160051b8501358501610e19565b9360059190911b8101350160c0810190610e2d565b9190826040519384928337810185815203925af1610425610e6d565b901561065c57506104479061038061037b60608f8c60051b8101350101610e19565b9460a08860051b8d01358d01013580871061063e575061047461037b60408e8b60051b8101350101610e19565b81811161062b575b505060c084015180861061060d57508f90948b60c08661050f6105a4978c9a976104e88960019f9a60019f9d6104b3918b91610fd9565b906001600160a01b03606088015116916104cc82610e19565b6104d860208401610e19565b9060408b8b015194013594610e9d565b6105068261050060408c60051b8a01358a0101610e19565b92610c34565b90608051611da7565b876105ea575b01518083116105ba575b50506105328360051b8d01358d01610e19565b946001600160a01b038d81610565606061055660408a60051b860135860101610e19565b938960051b8101350101610e19565b91816040519a6105748c61094d565b168a5216602089015216604087015260808d8560051b8101350101356060870152608086015260a0850152610d1e565b526105af818d610d1e565b5001955b0194610100565b6105db6105d460606105e3948860051b8101350101610e19565b9184610c34565b90339061153d565b8b3861051f565b610608883361060360408a60051b880135880101610e19565b61153d565b610515565b604490866040519163a81ff3b360e01b835260048301526024820152fd5b610636929750610c34565b94388061047c565b604490876040519163a81ff3b360e01b835260048301526024820152fd5b60405163729a0b5b60e01b815260206004820152908190610681906024830190610c7a565b0390fd5b906106b9908d6106b360206106a460408460051b890135890101610e19565b9260051b870135870101610e19565b90611221565b6103df565b6040516310ec1e7b60e11b8152600490fd5b60405163391b81e760e21b8152600490fd5b6040516303777f6960e51b8152600490fd5b6024610707888560051b81013501610e19565b6001600160a01b0360405191632cbf75f960e01b8352166004820152fd5b600080fd5b634e487b7160e01b600052603260045260246000fd5b9561075d60019297610753838689610d32565b9086608051610f29565b6105b3565b60209061076d610db0565b82828d010152016100e3565b6003196080368201126107255761078e610937565b67ffffffffffffffff91604435838111610725576107b0903690600401610a9f565b906064359384116107255760a0908436030112610725576107e86107d43447610c34565b93600401826107e285611e74565b85610de2565b6107f182611c99565b60405190602082527f9b3f3eeeff2d4b02d97c87aef001ca8800386a80d1c1af89970e03e02fcc031a6001600160a01b033394169280610838600435946020830190610c9f565b0390a4479080821161019157005b60803660031901126107255761085a610937565b67ffffffffffffffff906044358281116107255761087c903690600401610b82565b9160643590811161072557610895903690600401610c03565b9092906108a23447610c34565b938251916108af85611e74565b9060005b84811061090d578787876108c682611c99565b60405190602082527fcec71c1e3443762470423056741f346979df345f8b71d2ea5ab10523439322496001600160a01b033394169280610838600435946020830190610d54565b8061093161091d60019389610d1e565b51610929838689610d32565b90868b610de2565b016108b3565b602435906001600160a01b038216820361072557565b60c0810190811067ffffffffffffffff82111761096957604052565b634e487b7160e01b600052604160045260246000fd5b6040810190811067ffffffffffffffff82111761096957604052565b6060810190811067ffffffffffffffff82111761096957604052565b67ffffffffffffffff811161096957604052565b6080810190811067ffffffffffffffff82111761096957604052565b90601f8019910116810190811067ffffffffffffffff82111761096957604052565b67ffffffffffffffff81116109695760051b60200190565b67ffffffffffffffff811161096957601f01601f191660200190565b929192610a4982610a21565b91610a5760405193846109e7565b829481845281830111610725578281602093846000960137010152565b9080601f8301121561072557816020610a8f93359101610a3d565b90565b3590811515820361072557565b9190916101009081818503126107255760405191820167ffffffffffffffff9083811082821117610969576040528294823582811161072557830181601f820112156107255781816020610af593359101610a3d565b845260208301358281116107255781610b0f918501610a74565b6020850152604083013591821161072557610b2b918301610a74565b604083015260608101356001600160a01b03811681036107255760e09182916060850152610b5b60808201610a92565b6080850152610b6c60a08201610a92565b60a085015260c081013560c08501520135910152565b9080601f8301121561072557813590610b9a82610a09565b92610ba860405194856109e7565b828452602092838086019160051b8301019280841161072557848301915b848310610bd65750505050505090565b823567ffffffffffffffff8111610725578691610bf884848094890101610a9f565b815201920191610bc6565b9181601f840112156107255782359167ffffffffffffffff8311610725576020808501948460051b01011161072557565b91908203918211610c4157565b634e487b7160e01b600052601160045260246000fd5b60005b838110610c6a5750506000910152565b8181015183820152602001610c5a565b90602091610c9381518092818552858086019101610c57565b601f01601f1916010190565b9060e080610ce0610cce610cbc8651610100808852870190610c7a565b60208701518682036020880152610c7a565b60408601518582036040870152610c7a565b936001600160a01b03606082015116606085015260808101511515608085015260a0810151151560a085015260c081015160c0850152015191015290565b805182101561072a5760209160051b010190565b919081101561072a5760051b81013590609e1981360301821215610725570190565b908082519081815260208091019281808460051b8301019501936000915b848310610d825750505050505090565b9091929394958480610da0600193601f198682030187528a51610c9f565b9801930193019194939290610d72565b60405190610dbd8261094d565b8160a06000918281528260208201528260408201528260608201528260808201520152565b9291906080820151151560a0830151151590610e0757610e0757610e0593610f29565b565b604051631437241760e21b8152600490fd5b356001600160a01b03811681036107255790565b903590601e1981360301821215610725570180359067ffffffffffffffff82116107255760200191813603831361072557565b91908201809211610c4157565b3d15610e98573d90610e7e82610a21565b91610e8c60405193846109e7565b82523d6000602084013e565b606090565b94600095948695610ed99394879173eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee6001600160a01b038216148914610f1857505050610e60565b602083519301915af1610eea610e6d565b9015610ef35750565b6040516343373c4f60e01b815260206004820152908190610681906024830190610c7a565b90610f24929391611221565b610e60565b90604092610e059492610f3b8261111f565b610f448461118e565b610f9b6060830191610f786001600160a01b039460c0868651169101968751610f7060608b018b610e2d565b9390926116a6565b9190610f85818851610c34565b8752610f95838787511692610c34565b91611da7565b511690610fa783610e19565b610fd3610fb660208601610e19565b92610fc46080870187610e2d565b97909151960135963691610a3d565b92610e9d565b916001600160a01b03610feb83610e19565b1690600091825260207f8e6e95df1ece690939b98cef864b1c94a5769d9a8dd8de14e3577126a9e3083e81526040832093608081019461102b8683610e2d565b6004116110e857356001600160e01b0319168552825260408420549586156111045760c08491015261105d8582610e2d565b87969196116111005761108590604051928484019586528484526110808461097f565b610e2d565b8388939293018089116110ec5781106110e857918795939186610a8f9896940393604051998a97858901376110c7888801918583019388855251938491610c57565b019180601f19978886019301019083013701908152039081018352826109e7565b8580fd5b634e487b7160e01b87526011600452602487fd5b8480fd5b50915050610a8f9350611118929150610e2d565b3691610a3d565b60ff60208201515111801561117f575b61116d5760c08101511561115b5760e00151461461114957565b604051634ac09ad360e01b8152600490fd5b60405163162908e360e11b8152600490fd5b60405163251f56a160e21b8152600490fd5b5060ff6040820151511161112f565b61119781610e19565b3b1561120f576001600160a01b0390816111b082610e19565b166000527f8e6e95df1ece690939b98cef864b1c94a5769d9a8dd8de14e3577126a9e3083e60205260ff60016040600020015416156111ed575050565b906111f9602492610e19565b604051632cbf75f960e01b815291166004820152fd5b6040516309ee12d560e01b8152600490fd5b9291926001600160a01b03908183161561139857604051636eb1769f60e11b8082523060048301526001600160a01b038516602483015260209693909216928682604481875afa91821561135d57600092611369575b50808210611289575b50505050509050565b9061129391610c34565b6040519182523060048301526001600160a01b0384166024830152908581604481865afa90811561135d5760009161132b575b509461130d6112dc61131b936113209798610e60565b60405195869363095ea7b360e01b9085015260248401602090939291936001600160a01b0360408201951681520152565b03601f1981018452836109e7565b6113aa565b803880808080611280565b908682813d8311611356575b61134181836109e7565b8101031261135357505161130d6112c6565b80fd5b503d611337565b6040513d6000823e3d90fd5b90918782813d8311611391575b61138081836109e7565b810103126113535750519038611277565b503d611376565b6040516363ba9bff60e01b8152600490fd5b6001600160a01b03169061140a6040516113c38161097f565b6020938482527f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564858301526000808587829751910182855af1611404610e6d565b916114a4565b80519182159184831561147c575b5050509050156114255750565b6084906040519062461bcd60e51b82526004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b6064820152fd5b9193818094500103126114a057820151908115158203611353575080388084611418565b5080fd5b9192901561150657508151156114b8575090565b3b156114c15790565b60405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000006044820152606490fd5b8251909150156115195750805190602001fd5b60405162461bcd60e51b815260206004820152908190610681906024830190610c7a565b8261154757505050565b6001600160a01b031673eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee8103611576575090610e0591611634565b906040516370a0823160e01b8152306004820152602081602481865afa90811561135d57600091611603575b508084116115e5575060405163a9059cbb60e01b60208201526001600160a01b0390911660248201526044810192909252610e05919061131b826064810161130d565b836044916040519163cf47918160e01b835260048301526024820152fd5b906020823d821161162c575b8161161c602093836109e7565b81010312611353575051386115a2565b3d915061160f565b6001600160a01b038116156116945747821161167557600080809381935af161165b610e6d565b501561166357565b604051633d2cec6f60e21b8152600490fd5b60405163cf47918160e01b815260048101839052476024820152604490fd5b6040516321f7434560e01b8152600490fd5b919290936000946001600160a01b03918282169073eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee8203611712575b50505050508291815190816116ed575b5050509091565b604092945061170a93509061170191611e01565b92015182611e01565b3880806116e6565b84016040928386830312611c95578535956003871015611c91576020928382013567ffffffffffffffff928382116119725761174f929101610a74565b916002880361197a57508596507fa5e67a2ca7abbd3d386941b8010a32368804ac328a911a128f9ea68fdba5470f95939495928484541691835180611811575b5050505050541692833b1561180d5790608487928385519687948593631b63c28b60e11b85523360048601523060248601528b16604485015260648401525af190811561180457509084916117ec575b50505b38808080806116d6565b6117f5906109b7565b6118005782386117df565b8280fd5b513d86823e3d90fd5b8680fd5b90919293809596500160a0858203126119765782850151928984168094036119725761183e898701611f5d565b9561184b60608201611f5d565b9360808201519360a083015191821161196e5761186e9290840191018301611f70565b9289519461187b866109cb565b8986528286015265ffffffffffff96878092168b8701521660608501528851936118a48561099b565b845280840190308252898501928352853b1561196a5789516302b67b5760e41b8152336004820152945180518c166024870152908101518b166044860152808a0151871660648601526060015190951660848401529351881660a4830152925160c482015261010060e4820152918991839182908490829061192b90610104830190610c7a565b03925af18015611960578592918991611947575b80808061178f565b611953919293506109b7565b61180d578390873861193f565b84513d8a823e3d90fd5b8d80fd5b8f80fd5b8c80fd5b8b80fd5b929590949615600014611b435750805180611ac2575b5050508351916370a0823160e01b8084523060048501528484602481865afa938415611ab8578994611a89575b5085516323b872dd60e01b8682015233602482015230604482015260648082018a905281529160a0830190811183821017610969578592611a00918852846113aa565b602486518094819382523060048301525afa908115611a7f57908692918891611a4b575b50611a30929350610c34565b03611a3b57506117e2565b5163162908e360e11b8152600490fd5b9250509181813d8311611a78575b611a6381836109e7565b81010312610725575184918291611a30611a24565b503d611a59565b84513d89823e3d90fd5b9093508481813d8311611ab1575b611aa181836109e7565b81010312610725575192386119bd565b503d611a97565b86513d8b823e3d90fd5b60e003611b325788918291828851611b076024828b81019563d505accf60e01b8752611af78d82519283918686019101610c57565b81010360048101845201826109e7565b51925af1611b13610e6d565b5015611b2157388080611990565b835163ddafbaef60e01b8152600490fd5b8551636abdccad60e11b8152600490fd5b81518201969593925090606081880312611c915783810151948682015197606083015191821161197657611b7d9290860191018501611f70565b907fa5e67a2ca7abbd3d386941b8010a32368804ac328a911a128f9ea68fdba5470f541692855192611bae8461097f565b83528881840152855192611bc18461099b565b835280830194855285830196875288865191611bdc8361097f565b308352820152833b15611c9157855163187945bd60e11b8152925180516001600160a01b0316600485015260200151602484015291958994879493859387938593611c6793611c4e92909151604487015251606486015280516001600160a01b031660848601526020015160a4850152565b3360c484015261010060e4840152610104830190610c7a565b03925af19081156118045750611c7e575b506117e2565b611c8a909391936109b7565b9138611c78565b8980fd5b8880fd5b6001611cd7826001600160a01b03166000527fadf38b383de83e03163f4bb9c9eeeeff060c277df907ebce1fd27038d38e2e08602052604060002090565b016000805260205260406000206060604051611cf2816109cb565b825481526003600184015493846020840152600281015460408401520154918291015281158015611d24575b50505050565b81830291838304141715610c4157620f42409004918183809311611d8c575b5050611d52575b808080611d1e565b611d86906001600160a01b037fadf38b383de83e03163f4bb9c9eeeeff060c277df907ebce1fd27038d38e2e0b5416611634565b38611d4a565b611d9f92611d9991610c34565b90611634565b803880611d43565b90929180611df0575b505080611dbb575050565b610e05916001600160a01b037fadf38b383de83e03163f4bb9c9eeeeff060c277df907ebce1fd27038d38e2e0b54169061153d565b611dfa918461153d565b3880611db0565b90919060001983820983820291828083109203948286039260009614611e6657620f4240918383111561180d577fde8f6cefed634549b62c77574f722e1ac57e23f24d8fd5cb790fb65668c261399596500990828211900360fa1b910360061c170290565b505050620f42409192500490565b60606040918251611e84816109cb565b60009281848093528260208201528286820152015260ff611ed7826001600160a01b03166000527fadf38b383de83e03163f4bb9c9eeeeff060c277df907ebce1fd27038d38e2e08602052604060002090565b541615611f4c576003916001600160a01b0384921681527fadf38b383de83e03163f4bb9c9eeeeff060c277df907ebce1fd27038d38e2e0860205260018282200181805260205220825192611f2b846109cb565b81548452600182015460208501526002820154908401520154606082015290565b8251630f52085360e31b8152600490fd5b519065ffffffffffff8216820361072557565b81601f82011215610725578051611f8681610a21565b92611f9460405194856109e7565b8184526020828401011161072557610a8f9160208085019101610c57565b6000906001600160a01b031673eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee8103611fdf5750504790565b6020602491604051928380926370a0823160e01b82523060048301525afa91821561203f57809261200f57505090565b9091506020823d8211612037575b8161202a602093836109e7565b8101031261135357505190565b3d915061201d565b604051903d90823e3d90fdfea26469706673582212205e8d62865d649fd647681db77e28a612b886e6aca7cc096835ab47ebdbba8c0264736f6c63430008130033
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.