Overview
ETH Balance
0 ETH
Eth Value
$0.00More Info
Private Name Tags
ContractCreator
Latest 25 from a total of 242 transactions
Transaction Hash |
Method
|
Block
|
From
|
To
|
|||||
---|---|---|---|---|---|---|---|---|---|
Swap Exact Colla... | 22296572 | 2 days ago | IN | 0.00007269 ETH | 0.00063221 | ||||
Swap Exact Colla... | 22201957 | 15 days ago | IN | 0.00006668 ETH | 0.00022311 | ||||
Swap Exact Colla... | 22187164 | 17 days ago | IN | 0.00006668 ETH | 0.00072041 | ||||
Swap Exact Colla... | 22183357 | 18 days ago | IN | 0.00006282 ETH | 0.00025948 | ||||
Swap Exact Colla... | 22183302 | 18 days ago | IN | 0.00006282 ETH | 0.00059555 | ||||
Swap Exact Colla... | 22183276 | 18 days ago | IN | 0.00006282 ETH | 0.00056017 | ||||
Swap Exact Colla... | 22158841 | 21 days ago | IN | 0.00006616 ETH | 0.00017058 | ||||
Swap Exact Colla... | 22158836 | 21 days ago | IN | 0.00006616 ETH | 0.00014725 | ||||
Swap Exact Colla... | 22144869 | 23 days ago | IN | 0.00006244 ETH | 0.00034633 | ||||
Swap Exact Colla... | 22144482 | 23 days ago | IN | 0.00006244 ETH | 0.00033006 | ||||
Swap Exact Colla... | 22138161 | 24 days ago | IN | 0.00005905 ETH | 0.00060537 | ||||
Swap Exact Colla... | 22137882 | 24 days ago | IN | 0.00005905 ETH | 0.00049187 | ||||
Swap Exact Colla... | 22137684 | 24 days ago | IN | 0.00005905 ETH | 0.00031279 | ||||
Swap Exact Colla... | 22134695 | 25 days ago | IN | 0.00005905 ETH | 0.00031809 | ||||
Swap Exact Colla... | 22134558 | 25 days ago | IN | 0.00005905 ETH | 0.00033115 | ||||
Swap Exact Colla... | 22134192 | 25 days ago | IN | 0.00005905 ETH | 0.00085256 | ||||
Swap Exact Colla... | 22119932 | 27 days ago | IN | 0.00005905 ETH | 0.00089324 | ||||
Swap Exact Colla... | 22070702 | 34 days ago | IN | 0.00006214 ETH | 0.00033861 | ||||
Swap Exact Colla... | 22064733 | 35 days ago | IN | 0.00006214 ETH | 0.00018175 | ||||
Swap Exact Colla... | 22059052 | 35 days ago | IN | 0.00006214 ETH | 0.00046874 | ||||
Swap Exact Colla... | 22058220 | 35 days ago | IN | 0.00006214 ETH | 0.00034612 | ||||
Swap Exact Colla... | 22054609 | 36 days ago | IN | 0.00006214 ETH | 0.00016688 | ||||
Swap Exact Colla... | 22045809 | 37 days ago | IN | 0.00006545 ETH | 0.00046745 | ||||
Swap Exact Colla... | 22044825 | 37 days ago | IN | 0.00006545 ETH | 0.00022356 | ||||
Swap Exact Colla... | 22034080 | 39 days ago | IN | 0.00006179 ETH | 0.00021934 |
Latest 25 internal transactions (View All)
Advanced mode:
Parent Transaction Hash | Method | Block |
From
|
To
|
|||
---|---|---|---|---|---|---|---|
Send | 22296572 | 2 days ago | 0.00007269 ETH | ||||
Send | 22201957 | 15 days ago | 0.00006668 ETH | ||||
Send | 22187164 | 17 days ago | 0.00006668 ETH | ||||
Send | 22183357 | 18 days ago | 0.00006282 ETH | ||||
Send | 22183302 | 18 days ago | 0.00006282 ETH | ||||
Send | 22183276 | 18 days ago | 0.00006282 ETH | ||||
Send | 22158841 | 21 days ago | 0.00006616 ETH | ||||
Send | 22158836 | 21 days ago | 0.00006616 ETH | ||||
Send | 22144869 | 23 days ago | 0.00006244 ETH | ||||
Send | 22144482 | 23 days ago | 0.00006244 ETH | ||||
Send | 22138161 | 24 days ago | 0.00005905 ETH | ||||
Send | 22137882 | 24 days ago | 0.00005905 ETH | ||||
Send | 22137684 | 24 days ago | 0.00005905 ETH | ||||
Send | 22134695 | 25 days ago | 0.00005905 ETH | ||||
Send | 22134558 | 25 days ago | 0.00005905 ETH | ||||
Send | 22134192 | 25 days ago | 0.00005905 ETH | ||||
Send | 22119932 | 27 days ago | 0.00005905 ETH | ||||
Send | 22070702 | 34 days ago | 0.00006214 ETH | ||||
Send | 22064733 | 35 days ago | 0.00006214 ETH | ||||
Send | 22059052 | 35 days ago | 0.00006214 ETH | ||||
Send | 22058220 | 35 days ago | 0.00006214 ETH | ||||
Send | 22054609 | 36 days ago | 0.00006214 ETH | ||||
Send | 22045809 | 37 days ago | 0.00006545 ETH | ||||
Send | 22044825 | 37 days ago | 0.00006545 ETH | ||||
Send | 22034080 | 39 days ago | 0.00006179 ETH |
Loading...
Loading
Contract Source Code Verified (Exact Match)
Contract Name:
SwapFacilitySwapAndBridgeZap
Compiler Version
v0.8.25+commit.b61c2a91
Optimization Enabled:
Yes with 200 runs
Other Settings:
cancun EvmVersion
Contract Source Code (Solidity Standard Json-Input format)
// SPDX-License-Identifier: UNLICENSED pragma solidity 0.8.25; import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol"; import {ReentrancyGuard} from "@openzeppelin/contracts/utils/ReentrancyGuard.sol"; import {Pausable} from "@openzeppelin/contracts/utils/Pausable.sol"; import {AuthNoOwner, Authority} from "../governance/AuthNoOwner.sol"; import {SafeERC20} from "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol"; import {ISwapFacility} from "../interfaces/ISwapFacility.sol"; import { IOFT, SendParam, OFTLimit, OFTReceipt, OFTFeeDetail, MessagingReceipt, MessagingFee } from "@layerzerolabs/oft-evm/contracts/interfaces/IOFT.sol"; /// @title Swap Facility /// @notice dss-lite-psm inspired swap facility for efficient 1:1 swaps between a collateral token and an OFT compatible, mintable debt token. /// @dev Input tokens are stored at a vault address. /// @dev Fees are pull-model. Accumulated, to be swept to a feeRecipient address. /// @dev collateralToken must have >= 8 and <= 18 decimals contract SwapFacilitySwapAndBridgeZap is AuthNoOwner, ReentrancyGuard, Pausable { using SafeERC20 for IERC20; ISwapFacility public immutable swapFacility; IERC20 public immutable collateralToken; IERC20 public immutable debtToken; error InvalidAddress(); error InvalidFee(); /// @notice Creates a new SwapFacility logic contract. /// @param _authority The address of the authority contract. /// @param _swapFacility The address of the swap facility contract. constructor(address _authority, address _swapFacility) ReentrancyGuard() Pausable() { if (_authority == address(0)) revert InvalidAddress(); if (_swapFacility == address(0)) revert InvalidAddress(); _initializeAuthority(_authority); swapFacility = ISwapFacility(_swapFacility); collateralToken = IERC20(address(swapFacility.collateralToken())); debtToken = IERC20(address(swapFacility.debtToken())); collateralToken.forceApprove(address(swapFacility), type(uint256).max); debtToken.forceApprove(address(swapFacility), type(uint256).max); } /* === Swap Functions === */ /// @notice Swaps an exact amount of input tokens for output tokens and sends them cross-chain via LayerZero /// @param collateralIn The amount of collateral tokens to swap /// @param sendParam The LayerZero send parameters including destination chain and recipient. /// @dev sendParam.amountLD will be overridden to the actual amount out of the swap. /// @dev sendParam.minAmountLD also factors in fees from the swap. /// @dev sendParam.minAmountLD can be considered the debtOutMin parameter from the non crosschain function variant. /// @param lzFee The LayerZero messaging fee parameters /// @param refundAddress The address to receive any excess funds /// @param deadline The timestamp by which the initial swap must be completed (does not apply to cross-chain completion) /// @return debtOut The amount of debt tokens expected to be received. Does not factor in fees or slippage from LayerZero operation. /// @return fee The fee amount charged in debt tokens function swapExactCollateralForDebtAndLZSend( uint256 collateralIn, SendParam memory sendParam, MessagingFee calldata lzFee, address refundAddress, uint256 deadline // Deadline for initial swap, not for crosschain completion ) public payable virtual whenNotPaused nonReentrant returns (uint256 debtOut, uint256 fee) { require(sendParam.composeMsg.length == 0, "No compose"); require(sendParam.oftCmd.length == 0, "No oftCmd"); if (msg.value < lzFee.nativeFee || lzFee.lzTokenFee != 0) revert InvalidFee(); // No LZ token fees collateralToken.safeTransferFrom(msg.sender, address(this), collateralIn); (debtOut, fee) = swapFacility.swapExactCollateralForDebt(collateralIn, sendParam.minAmountLD, address(this), deadline); sendParam.amountLD = debtOut; IOFT(address(debtToken)).send{value: msg.value}(sendParam, lzFee, refundAddress); // Send debt tokens cross-chain } /// @notice Global pause. function pause() external requiresAuth whenNotPaused { _pause(); } /// @notice Global unpause. function unpause() external requiresAuth whenPaused { _unpause(); } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.1.0) (token/ERC20/IERC20.sol) pragma solidity ^0.8.20; /** * @dev Interface of the ERC-20 standard as defined in the ERC. */ 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 value of tokens in existence. */ function totalSupply() external view returns (uint256); /** * @dev Returns the value of tokens owned by `account`. */ function balanceOf(address account) external view returns (uint256); /** * @dev Moves a `value` amount of 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 value) 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 a `value` amount of tokens 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 value) external returns (bool); /** * @dev Moves a `value` amount of tokens from `from` to `to` using the * allowance mechanism. `value` 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 value) external returns (bool); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.1.0) (utils/ReentrancyGuard.sol) pragma solidity ^0.8.20; /** * @dev Contract module that helps prevent reentrant calls to a function. * * Inheriting from `ReentrancyGuard` will make the {nonReentrant} modifier * available, which can be applied to functions to make sure there are no nested * (reentrant) calls to them. * * Note that because there is a single `nonReentrant` guard, functions marked as * `nonReentrant` may not call one another. This can be worked around by making * those functions `private`, and then adding `external` `nonReentrant` entry * points to them. * * TIP: If EIP-1153 (transient storage) is available on the chain you're deploying at, * consider using {ReentrancyGuardTransient} instead. * * TIP: If you would like to learn more about reentrancy and alternative ways * to protect against it, check out our blog post * https://blog.openzeppelin.com/reentrancy-after-istanbul/[Reentrancy After Istanbul]. */ abstract contract ReentrancyGuard { // Booleans are more expensive than uint256 or any type that takes up a full // word because each write operation emits an extra SLOAD to first read the // slot's contents, replace the bits taken up by the boolean, and then write // back. This is the compiler's defense against contract upgrades and // pointer aliasing, and it cannot be disabled. // The values being non-zero value makes deployment a bit more expensive, // but in exchange the refund on every call to nonReentrant will be lower in // amount. Since refunds are capped to a percentage of the total // transaction's gas, it is best to keep them low in cases like this one, to // increase the likelihood of the full refund coming into effect. uint256 private constant NOT_ENTERED = 1; uint256 private constant ENTERED = 2; uint256 private _status; /** * @dev Unauthorized reentrant call. */ error ReentrancyGuardReentrantCall(); constructor() { _status = NOT_ENTERED; } /** * @dev Prevents a contract from calling itself, directly or indirectly. * Calling a `nonReentrant` function from another `nonReentrant` * function is not supported. It is possible to prevent this from happening * by making the `nonReentrant` function external, and making it call a * `private` function that does the actual work. */ modifier nonReentrant() { _nonReentrantBefore(); _; _nonReentrantAfter(); } function _nonReentrantBefore() private { // On the first call to nonReentrant, _status will be NOT_ENTERED if (_status == ENTERED) { revert ReentrancyGuardReentrantCall(); } // Any calls to nonReentrant after this point will fail _status = ENTERED; } function _nonReentrantAfter() private { // By storing the original value once again, a refund is triggered (see // https://eips.ethereum.org/EIPS/eip-2200) _status = NOT_ENTERED; } /** * @dev Returns true if the reentrancy guard is currently set to "entered", which indicates there is a * `nonReentrant` function in the call stack. */ function _reentrancyGuardEntered() internal view returns (bool) { return _status == ENTERED; } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (utils/Pausable.sol) pragma solidity ^0.8.20; import {Context} from "../utils/Context.sol"; /** * @dev Contract module which allows children to implement an emergency stop * mechanism that can be triggered by an authorized account. * * This module is used through inheritance. It will make available the * modifiers `whenNotPaused` and `whenPaused`, which can be applied to * the functions of your contract. Note that they will not be pausable by * simply including this module, only once the modifiers are put in place. */ abstract contract Pausable is Context { bool private _paused; /** * @dev Emitted when the pause is triggered by `account`. */ event Paused(address account); /** * @dev Emitted when the pause is lifted by `account`. */ event Unpaused(address account); /** * @dev The operation failed because the contract is paused. */ error EnforcedPause(); /** * @dev The operation failed because the contract is not paused. */ error ExpectedPause(); /** * @dev Initializes the contract in unpaused state. */ constructor() { _paused = false; } /** * @dev Modifier to make a function callable only when the contract is not paused. * * Requirements: * * - The contract must not be paused. */ modifier whenNotPaused() { _requireNotPaused(); _; } /** * @dev Modifier to make a function callable only when the contract is paused. * * Requirements: * * - The contract must be paused. */ modifier whenPaused() { _requirePaused(); _; } /** * @dev Returns true if the contract is paused, and false otherwise. */ function paused() public view virtual returns (bool) { return _paused; } /** * @dev Throws if the contract is paused. */ function _requireNotPaused() internal view virtual { if (paused()) { revert EnforcedPause(); } } /** * @dev Throws if the contract is not paused. */ function _requirePaused() internal view virtual { if (!paused()) { revert ExpectedPause(); } } /** * @dev Triggers stopped state. * * Requirements: * * - The contract must not be paused. */ function _pause() internal virtual whenNotPaused { _paused = true; emit Paused(_msgSender()); } /** * @dev Returns to normal state. * * Requirements: * * - The contract must be paused. */ function _unpause() internal virtual whenPaused { _paused = false; emit Unpaused(_msgSender()); } }
// SPDX-License-Identifier: AGPL-3.0-only pragma solidity >=0.8.13; import {Authority} from "../dependencies/solmate/Auth.sol"; /// @notice Provides a flexible and updatable auth pattern which is completely separate from application logic. /// @author Solmate (https://github.com/transmissions11/solmate/blob/main/src/auth/Auth.sol) /// @author Modified from Dappsys (https://github.com/dapphub/ds-auth/blob/master/src/auth.sol) contract AuthNoOwner { event AuthorityUpdated(address indexed user, Authority indexed newAuthority); Authority private _authority; bool private _authorityInitialized; /// @notice Modifier to require caller authorization for function execution. modifier requiresAuth() virtual { require(isAuthorized(msg.sender, msg.sig), "Auth: UNAUTHORIZED"); _; } /// @notice Returns the authority contract that controls access permissions. /// @return The Authority contract instance. function authority() public view returns (Authority) { return _authority; } /// @notice Checks if the authority has been initialized. /// @notice The authority can only be initialized once. /// @return bool Returns true if the authority has been initialized, false otherwise. function authorityInitialized() public view returns (bool) { return _authorityInitialized; } /// @notice Determines if a user is authorized to call a specific function. /// @dev Memoizes the authority instance to save gas and checks if the authority allows the call. /// @param user The address of the user attempting to call the function. /// @param functionSig The signature of the function being called. /// @return bool Returns true if the user is authorized to call the function, false otherwise. function isAuthorized(address user, bytes4 functionSig) internal view virtual returns (bool) { Authority auth = _authority; // Memoizing authority saves us a warm SLOAD, around 100 gas. // Checking if the caller is the owner only after calling the authority saves gas in most cases, but be // aware that this makes protected functions uncallable even to the owner if the authority is out of order. return (address(auth) != address(0) && auth.canCall(user, address(this), functionSig)); } /// @notice Changed constructor to initialize to allow flexiblity of constructor vs initializer use /// @notice sets authorityInitiailzed flag to ensure only one use of function _initializeAuthority(address newAuthority) internal { require(address(_authority) == address(0), "Auth: authority is non-zero"); require(!_authorityInitialized, "Auth: authority already initialized"); _authority = Authority(newAuthority); _authorityInitialized = true; emit AuthorityUpdated(address(this), Authority(newAuthority)); } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.1.0) (token/ERC20/utils/SafeERC20.sol) pragma solidity ^0.8.20; import {IERC20} from "../IERC20.sol"; import {IERC1363} from "../../../interfaces/IERC1363.sol"; import {Address} from "../../../utils/Address.sol"; /** * @title SafeERC20 * @dev Wrappers around ERC-20 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 { /** * @dev An operation with an ERC-20 token failed. */ error SafeERC20FailedOperation(address token); /** * @dev Indicates a failed `decreaseAllowance` request. */ error SafeERC20FailedDecreaseAllowance(address spender, uint256 currentAllowance, uint256 requestedDecrease); /** * @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.encodeCall(token.transfer, (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.encodeCall(token.transferFrom, (from, to, 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. * * IMPORTANT: If the token implements ERC-7674 (ERC-20 with temporary allowance), and if the "client" * smart contract uses ERC-7674 to set temporary allowances, then the "client" smart contract should avoid using * this function. Performing a {safeIncreaseAllowance} or {safeDecreaseAllowance} operation on a token contract * that has a non-zero temporary allowance (for that particular owner-spender) will result in unexpected behavior. */ function safeIncreaseAllowance(IERC20 token, address spender, uint256 value) internal { uint256 oldAllowance = token.allowance(address(this), spender); forceApprove(token, spender, oldAllowance + value); } /** * @dev Decrease the calling contract's allowance toward `spender` by `requestedDecrease`. If `token` returns no * value, non-reverting calls are assumed to be successful. * * IMPORTANT: If the token implements ERC-7674 (ERC-20 with temporary allowance), and if the "client" * smart contract uses ERC-7674 to set temporary allowances, then the "client" smart contract should avoid using * this function. Performing a {safeIncreaseAllowance} or {safeDecreaseAllowance} operation on a token contract * that has a non-zero temporary allowance (for that particular owner-spender) will result in unexpected behavior. */ function safeDecreaseAllowance(IERC20 token, address spender, uint256 requestedDecrease) internal { unchecked { uint256 currentAllowance = token.allowance(address(this), spender); if (currentAllowance < requestedDecrease) { revert SafeERC20FailedDecreaseAllowance(spender, currentAllowance, requestedDecrease); } forceApprove(token, spender, currentAllowance - requestedDecrease); } } /** * @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. * * NOTE: If the token implements ERC-7674, this function will not modify any temporary allowance. This function * only sets the "standard" allowance. Any temporary allowance will remain active, in addition to the value being * set here. */ function forceApprove(IERC20 token, address spender, uint256 value) internal { bytes memory approvalCall = abi.encodeCall(token.approve, (spender, value)); if (!_callOptionalReturnBool(token, approvalCall)) { _callOptionalReturn(token, abi.encodeCall(token.approve, (spender, 0))); _callOptionalReturn(token, approvalCall); } } /** * @dev Performs an {ERC1363} transferAndCall, with a fallback to the simple {ERC20} transfer if the target has no * code. This can be used to implement an {ERC721}-like safe transfer that rely on {ERC1363} checks when * targeting contracts. * * Reverts if the returned value is other than `true`. */ function transferAndCallRelaxed(IERC1363 token, address to, uint256 value, bytes memory data) internal { if (to.code.length == 0) { safeTransfer(token, to, value); } else if (!token.transferAndCall(to, value, data)) { revert SafeERC20FailedOperation(address(token)); } } /** * @dev Performs an {ERC1363} transferFromAndCall, with a fallback to the simple {ERC20} transferFrom if the target * has no code. This can be used to implement an {ERC721}-like safe transfer that rely on {ERC1363} checks when * targeting contracts. * * Reverts if the returned value is other than `true`. */ function transferFromAndCallRelaxed( IERC1363 token, address from, address to, uint256 value, bytes memory data ) internal { if (to.code.length == 0) { safeTransferFrom(token, from, to, value); } else if (!token.transferFromAndCall(from, to, value, data)) { revert SafeERC20FailedOperation(address(token)); } } /** * @dev Performs an {ERC1363} approveAndCall, with a fallback to the simple {ERC20} approve if the target has no * code. This can be used to implement an {ERC721}-like safe transfer that rely on {ERC1363} checks when * targeting contracts. * * NOTE: When the recipient address (`to`) has no code (i.e. is an EOA), this function behaves as {forceApprove}. * Opposedly, when the recipient address (`to`) has code, this function only attempts to call {ERC1363-approveAndCall} * once without retrying, and relies on the returned value to be true. * * Reverts if the returned value is other than `true`. */ function approveAndCallRelaxed(IERC1363 token, address to, uint256 value, bytes memory data) internal { if (to.code.length == 0) { forceApprove(token, to, value); } else if (!token.approveAndCall(to, value, data)) { revert SafeERC20FailedOperation(address(token)); } } /** * @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 {_callOptionalReturnBool} that reverts if call fails to meet the requirements. */ function _callOptionalReturn(IERC20 token, bytes memory data) private { uint256 returnSize; uint256 returnValue; assembly ("memory-safe") { let success := call(gas(), token, 0, add(data, 0x20), mload(data), 0, 0x20) // bubble errors if iszero(success) { let ptr := mload(0x40) returndatacopy(ptr, 0, returndatasize()) revert(ptr, returndatasize()) } returnSize := returndatasize() returnValue := mload(0) } if (returnSize == 0 ? address(token).code.length == 0 : returnValue != 1) { revert SafeERC20FailedOperation(address(token)); } } /** * @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 silently catches all reverts and returns a bool instead. */ function _callOptionalReturnBool(IERC20 token, bytes memory data) private returns (bool) { bool success; uint256 returnSize; uint256 returnValue; assembly ("memory-safe") { success := call(gas(), token, 0, add(data, 0x20), mload(data), 0, 0x20) returnSize := returndatasize() returnValue := mload(0) } return success && (returnSize == 0 ? address(token).code.length > 0 : returnValue == 1); } }
import {SendParam, MessagingFee} from "@layerzerolabs/oft-evm/contracts/interfaces/IOFT.sol"; import {IERC20Metadata} from "@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol"; import {IVault} from "../interfaces/IVault.sol"; import {IERC20Mintable} from "../interfaces/IERC20Mintable.sol"; // SPDX-License-Identifier: UNLICENSED pragma solidity ^0.8.13; interface ISwapFacility { event SwapExactCollateralForDebt( address indexed sender, uint256 collateralIn, uint256 debtOut, uint256 fee, address indexed to ); event SwapExactDebtForCollateral( address indexed sender, uint256 debtIn, uint256 collateralOut, uint256 fee, address indexed to ); event PreMintDebt(uint256 amount); event BurnExcessDebt(uint256 amount); event CollectFees(uint256 amount); event SwapInEnabledSet(bool enabled); event SwapOutEnabledSet(bool enabled); event SwapInFeeRateSet(uint256 rate); event SwapOutFeeRateSet(uint256 rate); event MintCapSet(uint256 newCap); event PreMintedDebtTargetSet(uint256 target); event FeeRecipientSet(address indexed feeRecipient); error SwapInDisabled(); error SwapOutDisabled(); error DeadlinePassed(); error OutputTokenInvalidDecimals(uint8 decimals); error InputTokenTooFewDecimals(uint8 decimals); error InputTokenTooManyDecimals(uint8 decimals); error InputTokenInvalidDecimals(uint8 decimals); error FeeRateExceedsMax(uint256 _feeRate); error NoDebtToPreMint(); error NoExcessDebtToBurn(); error NoFeesToCollect(); error ZeroDebtIn(); error ZeroDebtOut(); error ZeroCollateralIn(); error ZeroCollateralOut(); error InsufficientOutputAmount(); error DebtInExceedsMax(uint256 debtIn, uint256 maxDebtIn); error ExceedsMintCap(uint256 debtOut); error CrosschainSwapInDisabled(); error InvalidAddress(); error InvalidFee(); error MintCapBelowPreMintedDebtTarget(uint256 mintCap, uint256 preMintedDebtTarget); error DebtMintedBelowZero(uint256 amountMinted, uint256 debtMinted); function swapExactCollateralForDebt(uint256 collateralIn, uint256 minDebtOut, address to, uint256 deadline) external returns (uint256 debtOut, uint256 fee); function swapExactDebtForCollateral(uint256 debtIn, uint256 minCollateralOut, address to, uint256 deadline) external returns (uint256 collateralOut, uint256 fee); function swapInFeeRate() external view returns (uint16); function swapOutFeeRate() external view returns (uint16); function swapInEnabled() external view returns (bool); function swapOutEnabled() external view returns (bool); function debtMinted() external view returns (uint256); function debtMintCap() external view returns (uint256); function collateralToken() external view returns (IERC20Metadata); function debtToken() external view returns (IERC20Mintable); /// @notice Holder address for the collateral tokens. /// @dev This contract must be able to freely transfer collateralToken on behalf of the vault. function vault() external view returns (IVault); /// @notice Address to receive fees, which are always taken in debt token. function feeRecipient() external view returns (address); /// @notice Precision conversion factor for collateral token, debt token is expected to always have 18 decimals. function to18ConversionFactor() external view returns (uint256); }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.20; import { MessagingReceipt, MessagingFee } from "@layerzerolabs/oapp-evm/contracts/oapp/OAppSender.sol"; /** * @dev Struct representing token parameters for the OFT send() operation. */ struct SendParam { uint32 dstEid; // Destination endpoint ID. bytes32 to; // Recipient address. uint256 amountLD; // Amount to send in local decimals. uint256 minAmountLD; // Minimum amount to send in local decimals. bytes extraOptions; // Additional options supplied by the caller to be used in the LayerZero message. bytes composeMsg; // The composed message for the send() operation. bytes oftCmd; // The OFT command to be executed, unused in default OFT implementations. } /** * @dev Struct representing OFT limit information. * @dev These amounts can change dynamically and are up the specific oft implementation. */ struct OFTLimit { uint256 minAmountLD; // Minimum amount in local decimals that can be sent to the recipient. uint256 maxAmountLD; // Maximum amount in local decimals that can be sent to the recipient. } /** * @dev Struct representing OFT receipt information. */ struct OFTReceipt { uint256 amountSentLD; // Amount of tokens ACTUALLY debited from the sender in local decimals. // @dev In non-default implementations, the amountReceivedLD COULD differ from this value. uint256 amountReceivedLD; // Amount of tokens to be received on the remote side. } /** * @dev Struct representing OFT fee details. * @dev Future proof mechanism to provide a standardized way to communicate fees to things like a UI. */ struct OFTFeeDetail { int256 feeAmountLD; // Amount of the fee in local decimals. string description; // Description of the fee. } /** * @title IOFT * @dev Interface for the OftChain (OFT) token. * @dev Does not inherit ERC20 to accommodate usage by OFTAdapter as well. * @dev This specific interface ID is '0x02e49c2c'. */ interface IOFT { // Custom error messages error InvalidLocalDecimals(); error SlippageExceeded(uint256 amountLD, uint256 minAmountLD); // Events event OFTSent( bytes32 indexed guid, // GUID of the OFT message. uint32 dstEid, // Destination Endpoint ID. address indexed fromAddress, // Address of the sender on the src chain. uint256 amountSentLD, // Amount of tokens sent in local decimals. uint256 amountReceivedLD // Amount of tokens received in local decimals. ); event OFTReceived( bytes32 indexed guid, // GUID of the OFT message. uint32 srcEid, // Source Endpoint ID. address indexed toAddress, // Address of the recipient on the dst chain. uint256 amountReceivedLD // Amount of tokens received in local decimals. ); /** * @notice Retrieves interfaceID and the version of the OFT. * @return interfaceId The interface ID. * @return version The version. * * @dev interfaceId: This specific interface ID is '0x02e49c2c'. * @dev version: Indicates a cross-chain compatible msg encoding with other OFTs. * @dev If a new feature is added to the OFT cross-chain msg encoding, the version will be incremented. * ie. localOFT version(x,1) CAN send messages to remoteOFT version(x,1) */ function oftVersion() external view returns (bytes4 interfaceId, uint64 version); /** * @notice Retrieves the address of the token associated with the OFT. * @return token The address of the ERC20 token implementation. */ function token() external view returns (address); /** * @notice Indicates whether the OFT contract requires approval of the 'token()' to send. * @return requiresApproval Needs approval of the underlying token implementation. * * @dev Allows things like wallet implementers to determine integration requirements, * without understanding the underlying token implementation. */ function approvalRequired() external view returns (bool); /** * @notice Retrieves the shared decimals of the OFT. * @return sharedDecimals The shared decimals of the OFT. */ function sharedDecimals() external view returns (uint8); /** * @notice Provides a quote for OFT-related operations. * @param _sendParam The parameters for the send operation. * @return limit The OFT limit information. * @return oftFeeDetails The details of OFT fees. * @return receipt The OFT receipt information. */ function quoteOFT( SendParam calldata _sendParam ) external view returns (OFTLimit memory, OFTFeeDetail[] memory oftFeeDetails, OFTReceipt memory); /** * @notice Provides a quote for the send() operation. * @param _sendParam The parameters for the send() operation. * @param _payInLzToken Flag indicating whether the caller is paying in the LZ token. * @return fee The calculated LayerZero messaging fee from the send() operation. * * @dev MessagingFee: LayerZero msg fee * - nativeFee: The native fee. * - lzTokenFee: The lzToken fee. */ function quoteSend(SendParam calldata _sendParam, bool _payInLzToken) external view returns (MessagingFee memory); /** * @notice Executes the send() operation. * @param _sendParam The parameters for the send operation. * @param _fee The fee information supplied by the caller. * - nativeFee: The native fee. * - lzTokenFee: The lzToken fee. * @param _refundAddress The address to receive any excess funds from fees etc. on the src. * @return receipt The LayerZero messaging receipt from the send() operation. * @return oftReceipt The OFT receipt information. * * @dev MessagingReceipt: LayerZero msg receipt * - guid: The unique identifier for the sent message. * - nonce: The nonce of the sent message. * - fee: The LayerZero fee incurred for the message. */ function send( SendParam calldata _sendParam, MessagingFee calldata _fee, address _refundAddress ) external payable returns (MessagingReceipt memory, OFTReceipt memory); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.1) (utils/Context.sol) pragma solidity ^0.8.20; /** * @dev Provides information about the current execution context, including the * sender of the transaction and its data. While these are generally available * via msg.sender and msg.data, they should not be accessed in such a direct * manner, since when dealing with meta-transactions the account sending and * paying for execution may not be the actual sender (as far as an application * is concerned). * * This contract is only required for intermediate, library-like contracts. */ abstract contract Context { function _msgSender() internal view virtual returns (address) { return msg.sender; } function _msgData() internal view virtual returns (bytes calldata) { return msg.data; } function _contextSuffixLength() internal view virtual returns (uint256) { return 0; } }
// SPDX-License-Identifier: AGPL-3.0-only pragma solidity >=0.8.0; /// @notice Provides a flexible and updatable auth pattern which is completely separate from application logic. /// @author Solmate (https://github.com/transmissions11/solmate/blob/main/src/auth/Auth.sol) /// @author Modified from Dappsys (https://github.com/dapphub/ds-auth/blob/master/src/auth.sol) abstract contract Auth { event OwnershipTransferred(address indexed user, address indexed newOwner); event AuthorityUpdated(address indexed user, Authority indexed newAuthority); address public owner; Authority public authority; constructor(address _owner, Authority _authority) { owner = _owner; authority = _authority; emit OwnershipTransferred(msg.sender, _owner); emit AuthorityUpdated(msg.sender, _authority); } modifier requiresAuth() virtual { require(isAuthorized(msg.sender, msg.sig), "UNAUTHORIZED"); _; } function isAuthorized(address user, bytes4 functionSig) internal view virtual returns (bool) { Authority auth = authority; // Memoizing authority saves us a warm SLOAD, around 100 gas. // Checking if the caller is the owner only after calling the authority saves gas in most cases, but be // aware that this makes protected functions uncallable even to the owner if the authority is out of order. return (address(auth) != address(0) && auth.canCall(user, address(this), functionSig)) || user == owner; } function setAuthority(Authority newAuthority) public virtual { // We check if the caller is the owner first because we want to ensure they can // always swap out the authority even if it's reverting or using up a lot of gas. require(msg.sender == owner || authority.canCall(msg.sender, address(this), msg.sig)); authority = newAuthority; emit AuthorityUpdated(msg.sender, newAuthority); } function transferOwnership(address newOwner) public virtual requiresAuth { owner = newOwner; emit OwnershipTransferred(msg.sender, newOwner); } } /// @notice A generic interface for a contract which provides authorization data to an Auth instance. /// @author Solmate (https://github.com/transmissions11/solmate/blob/main/src/auth/Auth.sol) /// @author Modified from Dappsys (https://github.com/dapphub/ds-auth/blob/master/src/auth.sol) interface Authority { function canCall(address user, address target, bytes4 functionSig) external view returns (bool); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.1.0) (interfaces/IERC1363.sol) pragma solidity ^0.8.20; import {IERC20} from "./IERC20.sol"; import {IERC165} from "./IERC165.sol"; /** * @title IERC1363 * @dev Interface of the ERC-1363 standard as defined in the https://eips.ethereum.org/EIPS/eip-1363[ERC-1363]. * * Defines an extension interface for ERC-20 tokens that supports executing code on a recipient contract * after `transfer` or `transferFrom`, or code on a spender contract after `approve`, in a single transaction. */ interface IERC1363 is IERC20, IERC165 { /* * Note: the ERC-165 identifier for this interface is 0xb0202a11. * 0xb0202a11 === * bytes4(keccak256('transferAndCall(address,uint256)')) ^ * bytes4(keccak256('transferAndCall(address,uint256,bytes)')) ^ * bytes4(keccak256('transferFromAndCall(address,address,uint256)')) ^ * bytes4(keccak256('transferFromAndCall(address,address,uint256,bytes)')) ^ * bytes4(keccak256('approveAndCall(address,uint256)')) ^ * bytes4(keccak256('approveAndCall(address,uint256,bytes)')) */ /** * @dev Moves a `value` amount of tokens from the caller's account to `to` * and then calls {IERC1363Receiver-onTransferReceived} on `to`. * @param to The address which you want to transfer to. * @param value The amount of tokens to be transferred. * @return A boolean value indicating whether the operation succeeded unless throwing. */ function transferAndCall(address to, uint256 value) external returns (bool); /** * @dev Moves a `value` amount of tokens from the caller's account to `to` * and then calls {IERC1363Receiver-onTransferReceived} on `to`. * @param to The address which you want to transfer to. * @param value The amount of tokens to be transferred. * @param data Additional data with no specified format, sent in call to `to`. * @return A boolean value indicating whether the operation succeeded unless throwing. */ function transferAndCall(address to, uint256 value, bytes calldata data) external returns (bool); /** * @dev Moves a `value` amount of tokens from `from` to `to` using the allowance mechanism * and then calls {IERC1363Receiver-onTransferReceived} on `to`. * @param from The address which you want to send tokens from. * @param to The address which you want to transfer to. * @param value The amount of tokens to be transferred. * @return A boolean value indicating whether the operation succeeded unless throwing. */ function transferFromAndCall(address from, address to, uint256 value) external returns (bool); /** * @dev Moves a `value` amount of tokens from `from` to `to` using the allowance mechanism * and then calls {IERC1363Receiver-onTransferReceived} on `to`. * @param from The address which you want to send tokens from. * @param to The address which you want to transfer to. * @param value The amount of tokens to be transferred. * @param data Additional data with no specified format, sent in call to `to`. * @return A boolean value indicating whether the operation succeeded unless throwing. */ function transferFromAndCall(address from, address to, uint256 value, bytes calldata data) external returns (bool); /** * @dev Sets a `value` amount of tokens as the allowance of `spender` over the * caller's tokens and then calls {IERC1363Spender-onApprovalReceived} on `spender`. * @param spender The address which will spend the funds. * @param value The amount of tokens to be spent. * @return A boolean value indicating whether the operation succeeded unless throwing. */ function approveAndCall(address spender, uint256 value) external returns (bool); /** * @dev Sets a `value` amount of tokens as the allowance of `spender` over the * caller's tokens and then calls {IERC1363Spender-onApprovalReceived} on `spender`. * @param spender The address which will spend the funds. * @param value The amount of tokens to be spent. * @param data Additional data with no specified format, sent in call to `spender`. * @return A boolean value indicating whether the operation succeeded unless throwing. */ function approveAndCall(address spender, uint256 value, bytes calldata data) external returns (bool); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.1.0) (utils/Address.sol) pragma solidity ^0.8.20; import {Errors} from "./Errors.sol"; /** * @dev Collection of functions related to the address type */ library Address { /** * @dev There's no code at `target` (it is not a contract). */ error AddressEmptyCode(address target); /** * @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.20/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. */ function sendValue(address payable recipient, uint256 amount) internal { if (address(this).balance < amount) { revert Errors.InsufficientBalance(address(this).balance, amount); } (bool success, ) = recipient.call{value: amount}(""); if (!success) { revert Errors.FailedCall(); } } /** * @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 or custom error, it is bubbled * up by this function (like regular Solidity function calls). However, if * the call reverted with no returned reason, this function reverts with a * {Errors.FailedCall} error. * * 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. */ function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCallWithValue(target, data, 0); } /** * @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`. */ function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) { if (address(this).balance < value) { revert Errors.InsufficientBalance(address(this).balance, value); } (bool success, bytes memory returndata) = target.call{value: value}(data); return verifyCallResultFromTarget(target, success, returndata); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a static call. */ function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) { (bool success, bytes memory returndata) = target.staticcall(data); return verifyCallResultFromTarget(target, success, returndata); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a delegate call. */ function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) { (bool success, bytes memory returndata) = target.delegatecall(data); return verifyCallResultFromTarget(target, success, returndata); } /** * @dev Tool to verify that a low level call to smart-contract was successful, and reverts if the target * was not a contract or bubbling up the revert reason (falling back to {Errors.FailedCall}) in case * of an unsuccessful call. */ function verifyCallResultFromTarget( address target, bool success, bytes memory returndata ) internal view returns (bytes memory) { if (!success) { _revert(returndata); } else { // only check if target is a contract if the call was successful and the return data is empty // otherwise we already know that it was a contract if (returndata.length == 0 && target.code.length == 0) { revert AddressEmptyCode(target); } return returndata; } } /** * @dev Tool to verify that a low level call was successful, and reverts if it wasn't, either by bubbling the * revert reason or with a default {Errors.FailedCall} error. */ function verifyCallResult(bool success, bytes memory returndata) internal pure returns (bytes memory) { if (!success) { _revert(returndata); } else { return returndata; } } /** * @dev Reverts with returndata if present. Otherwise reverts with {Errors.FailedCall}. */ function _revert(bytes memory returndata) 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 assembly ("memory-safe") { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert Errors.FailedCall(); } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.1.0) (token/ERC20/extensions/IERC20Metadata.sol) pragma solidity ^0.8.20; import {IERC20} from "../IERC20.sol"; /** * @dev Interface for the optional metadata functions from the ERC-20 standard. */ interface IERC20Metadata is IERC20 { /** * @dev Returns the name of the token. */ function name() external view returns (string memory); /** * @dev Returns the symbol of the token. */ function symbol() external view returns (string memory); /** * @dev Returns the decimals places of the token. */ function decimals() external view returns (uint8); }
// SPDX-License-Identifier: UNLICENSED pragma solidity ^0.8.13; interface IVault {}
// SPDX-License-Identifier: UNLICENSED pragma solidity ^0.8.13; import {IERC20} from "forge-std/interfaces/IERC20.sol"; interface IERC20Mintable is IERC20 { function mint(uint256 amount) external; function mintTo(address to, uint256 amount) external; function burn(uint256 amount) external; function burnFrom(address from, uint256 amount) external; }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.20; import { SafeERC20, IERC20 } from "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol"; import { MessagingParams, MessagingFee, MessagingReceipt } from "@layerzerolabs/lz-evm-protocol-v2/contracts/interfaces/ILayerZeroEndpointV2.sol"; import { OAppCore } from "./OAppCore.sol"; /** * @title OAppSender * @dev Abstract contract implementing the OAppSender functionality for sending messages to a LayerZero endpoint. */ abstract contract OAppSender is OAppCore { using SafeERC20 for IERC20; // Custom error messages error NotEnoughNative(uint256 msgValue); error LzTokenUnavailable(); // @dev The version of the OAppSender implementation. // @dev Version is bumped when changes are made to this contract. uint64 internal constant SENDER_VERSION = 1; /** * @notice Retrieves the OApp version information. * @return senderVersion The version of the OAppSender.sol contract. * @return receiverVersion The version of the OAppReceiver.sol contract. * * @dev Providing 0 as the default for OAppReceiver version. Indicates that the OAppReceiver is not implemented. * ie. this is a SEND only OApp. * @dev If the OApp uses both OAppSender and OAppReceiver, then this needs to be override returning the correct versions */ function oAppVersion() public view virtual returns (uint64 senderVersion, uint64 receiverVersion) { return (SENDER_VERSION, 0); } /** * @dev Internal function to interact with the LayerZero EndpointV2.quote() for fee calculation. * @param _dstEid The destination endpoint ID. * @param _message The message payload. * @param _options Additional options for the message. * @param _payInLzToken Flag indicating whether to pay the fee in LZ tokens. * @return fee The calculated MessagingFee for the message. * - nativeFee: The native fee for the message. * - lzTokenFee: The LZ token fee for the message. */ function _quote( uint32 _dstEid, bytes memory _message, bytes memory _options, bool _payInLzToken ) internal view virtual returns (MessagingFee memory fee) { return endpoint.quote( MessagingParams(_dstEid, _getPeerOrRevert(_dstEid), _message, _options, _payInLzToken), address(this) ); } /** * @dev Internal function to interact with the LayerZero EndpointV2.send() for sending a message. * @param _dstEid The destination endpoint ID. * @param _message The message payload. * @param _options Additional options for the message. * @param _fee The calculated LayerZero fee for the message. * - nativeFee: The native fee. * - lzTokenFee: The lzToken fee. * @param _refundAddress The address to receive any excess fee values sent to the endpoint. * @return receipt The receipt for the sent message. * - guid: The unique identifier for the sent message. * - nonce: The nonce of the sent message. * - fee: The LayerZero fee incurred for the message. */ function _lzSend( uint32 _dstEid, bytes memory _message, bytes memory _options, MessagingFee memory _fee, address _refundAddress ) internal virtual returns (MessagingReceipt memory receipt) { // @dev Push corresponding fees to the endpoint, any excess is sent back to the _refundAddress from the endpoint. uint256 messageValue = _payNative(_fee.nativeFee); if (_fee.lzTokenFee > 0) _payLzToken(_fee.lzTokenFee); return // solhint-disable-next-line check-send-result endpoint.send{ value: messageValue }( MessagingParams(_dstEid, _getPeerOrRevert(_dstEid), _message, _options, _fee.lzTokenFee > 0), _refundAddress ); } /** * @dev Internal function to pay the native fee associated with the message. * @param _nativeFee The native fee to be paid. * @return nativeFee The amount of native currency paid. * * @dev If the OApp needs to initiate MULTIPLE LayerZero messages in a single transaction, * this will need to be overridden because msg.value would contain multiple lzFees. * @dev Should be overridden in the event the LayerZero endpoint requires a different native currency. * @dev Some EVMs use an ERC20 as a method for paying transactions/gasFees. * @dev The endpoint is EITHER/OR, ie. it will NOT support both types of native payment at a time. */ function _payNative(uint256 _nativeFee) internal virtual returns (uint256 nativeFee) { if (msg.value != _nativeFee) revert NotEnoughNative(msg.value); return _nativeFee; } /** * @dev Internal function to pay the LZ token fee associated with the message. * @param _lzTokenFee The LZ token fee to be paid. * * @dev If the caller is trying to pay in the specified lzToken, then the lzTokenFee is passed to the endpoint. * @dev Any excess sent, is passed back to the specified _refundAddress in the _lzSend(). */ function _payLzToken(uint256 _lzTokenFee) internal virtual { // @dev Cannot cache the token because it is not immutable in the endpoint. address lzToken = endpoint.lzToken(); if (lzToken == address(0)) revert LzTokenUnavailable(); // Pay LZ token fee by sending tokens to the endpoint. IERC20(lzToken).safeTransferFrom(msg.sender, address(endpoint), _lzTokenFee); } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (interfaces/IERC20.sol) pragma solidity ^0.8.20; import {IERC20} from "../token/ERC20/IERC20.sol";
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (interfaces/IERC165.sol) pragma solidity ^0.8.20; import {IERC165} from "../utils/introspection/IERC165.sol";
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.1.0) (utils/Errors.sol) pragma solidity ^0.8.20; /** * @dev Collection of common custom errors used in multiple contracts * * IMPORTANT: Backwards compatibility is not guaranteed in future versions of the library. * It is recommended to avoid relying on the error API for critical functionality. * * _Available since v5.1._ */ library Errors { /** * @dev The ETH balance of the account is not enough to perform the operation. */ error InsufficientBalance(uint256 balance, uint256 needed); /** * @dev A call to an address target failed. The target may have reverted. */ error FailedCall(); /** * @dev The deployment failed. */ error FailedDeployment(); /** * @dev A necessary precompile is missing. */ error MissingPrecompile(address); }
// SPDX-License-Identifier: MIT pragma solidity >=0.6.2; /// @dev Interface of the ERC20 standard as defined in the EIP. /// @dev This includes the optional name, symbol, and decimals metadata. interface IERC20 { /// @dev Emitted when `value` tokens are moved from one account (`from`) to another (`to`). event Transfer(address indexed from, address indexed to, uint256 value); /// @dev Emitted when the allowance of a `spender` for an `owner` is set, where `value` /// is the new allowance. event Approval(address indexed owner, address indexed spender, uint256 value); /// @notice Returns the amount of tokens in existence. function totalSupply() external view returns (uint256); /// @notice Returns the amount of tokens owned by `account`. function balanceOf(address account) external view returns (uint256); /// @notice Moves `amount` tokens from the caller's account to `to`. function transfer(address to, uint256 amount) external returns (bool); /// @notice Returns the remaining number of tokens that `spender` is allowed /// to spend on behalf of `owner` function allowance(address owner, address spender) external view returns (uint256); /// @notice Sets `amount` as the allowance of `spender` over the caller's tokens. /// @dev Be aware of front-running risks: https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 function approve(address spender, uint256 amount) external returns (bool); /// @notice Moves `amount` tokens from `from` to `to` using the allowance mechanism. /// `amount` is then deducted from the caller's allowance. function transferFrom(address from, address to, uint256 amount) external returns (bool); /// @notice Returns the name of the token. function name() external view returns (string memory); /// @notice Returns the symbol of the token. function symbol() external view returns (string memory); /// @notice Returns the decimals places of the token. function decimals() external view returns (uint8); }
// SPDX-License-Identifier: MIT pragma solidity >=0.8.0; import { IMessageLibManager } from "./IMessageLibManager.sol"; import { IMessagingComposer } from "./IMessagingComposer.sol"; import { IMessagingChannel } from "./IMessagingChannel.sol"; import { IMessagingContext } from "./IMessagingContext.sol"; struct MessagingParams { uint32 dstEid; bytes32 receiver; bytes message; bytes options; bool payInLzToken; } struct MessagingReceipt { bytes32 guid; uint64 nonce; MessagingFee fee; } struct MessagingFee { uint256 nativeFee; uint256 lzTokenFee; } struct Origin { uint32 srcEid; bytes32 sender; uint64 nonce; } interface ILayerZeroEndpointV2 is IMessageLibManager, IMessagingComposer, IMessagingChannel, IMessagingContext { event PacketSent(bytes encodedPayload, bytes options, address sendLibrary); event PacketVerified(Origin origin, address receiver, bytes32 payloadHash); event PacketDelivered(Origin origin, address receiver); event LzReceiveAlert( address indexed receiver, address indexed executor, Origin origin, bytes32 guid, uint256 gas, uint256 value, bytes message, bytes extraData, bytes reason ); event LzTokenSet(address token); event DelegateSet(address sender, address delegate); function quote(MessagingParams calldata _params, address _sender) external view returns (MessagingFee memory); function send( MessagingParams calldata _params, address _refundAddress ) external payable returns (MessagingReceipt memory); function verify(Origin calldata _origin, address _receiver, bytes32 _payloadHash) external; function verifiable(Origin calldata _origin, address _receiver) external view returns (bool); function initializable(Origin calldata _origin, address _receiver) external view returns (bool); function lzReceive( Origin calldata _origin, address _receiver, bytes32 _guid, bytes calldata _message, bytes calldata _extraData ) external payable; // oapp can burn messages partially by calling this function with its own business logic if messages are verified in order function clear(address _oapp, Origin calldata _origin, bytes32 _guid, bytes calldata _message) external; function setLzToken(address _lzToken) external; function lzToken() external view returns (address); function nativeToken() external view returns (address); function setDelegate(address _delegate) external; function delegates(address _oapp) external view returns (address); }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.20; import { Ownable } from "@openzeppelin/contracts/access/Ownable.sol"; import { IOAppCore, ILayerZeroEndpointV2 } from "./interfaces/IOAppCore.sol"; /** * @title OAppCore * @dev Abstract contract implementing the IOAppCore interface with basic OApp configurations. */ abstract contract OAppCore is IOAppCore, Ownable { // The LayerZero endpoint associated with the given OApp ILayerZeroEndpointV2 public immutable endpoint; // Mapping to store peers associated with corresponding endpoints mapping(uint32 eid => bytes32 peer) public peers; /** * @dev Constructor to initialize the OAppCore with the provided endpoint and delegate. * @param _endpoint The address of the LOCAL Layer Zero endpoint. * @param _delegate The delegate capable of making OApp configurations inside of the endpoint. * * @dev The delegate typically should be set as the owner of the contract. */ constructor(address _endpoint, address _delegate) { endpoint = ILayerZeroEndpointV2(_endpoint); if (_delegate == address(0)) revert InvalidDelegate(); endpoint.setDelegate(_delegate); } /** * @notice Sets the peer address (OApp instance) for a corresponding endpoint. * @param _eid The endpoint ID. * @param _peer The address of the peer to be associated with the corresponding endpoint. * * @dev Only the owner/admin of the OApp can call this function. * @dev Indicates that the peer is trusted to send LayerZero messages to this OApp. * @dev Set this to bytes32(0) to remove the peer address. * @dev Peer is a bytes32 to accommodate non-evm chains. */ function setPeer(uint32 _eid, bytes32 _peer) public virtual onlyOwner { _setPeer(_eid, _peer); } /** * @notice Sets the peer address (OApp instance) for a corresponding endpoint. * @param _eid The endpoint ID. * @param _peer The address of the peer to be associated with the corresponding endpoint. * * @dev Indicates that the peer is trusted to send LayerZero messages to this OApp. * @dev Set this to bytes32(0) to remove the peer address. * @dev Peer is a bytes32 to accommodate non-evm chains. */ function _setPeer(uint32 _eid, bytes32 _peer) internal virtual { peers[_eid] = _peer; emit PeerSet(_eid, _peer); } /** * @notice Internal function to get the peer address associated with a specific endpoint; reverts if NOT set. * ie. the peer is set to bytes32(0). * @param _eid The endpoint ID. * @return peer The address of the peer associated with the specified endpoint. */ function _getPeerOrRevert(uint32 _eid) internal view virtual returns (bytes32) { bytes32 peer = peers[_eid]; if (peer == bytes32(0)) revert NoPeer(_eid); return peer; } /** * @notice Sets the delegate address for the OApp. * @param _delegate The address of the delegate to be set. * * @dev Only the owner/admin of the OApp can call this function. * @dev Provides the ability for a delegate to set configs, on behalf of the OApp, directly on the Endpoint contract. */ function setDelegate(address _delegate) public onlyOwner { endpoint.setDelegate(_delegate); } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.1.0) (utils/introspection/IERC165.sol) pragma solidity ^0.8.20; /** * @dev Interface of the ERC-165 standard, as defined in the * https://eips.ethereum.org/EIPS/eip-165[ERC]. * * Implementers can declare support of contract interfaces, which can then be * queried by others ({ERC165Checker}). * * For an implementation, see {ERC165}. */ interface IERC165 { /** * @dev Returns true if this contract implements the interface defined by * `interfaceId`. See the corresponding * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[ERC section] * to learn more about how these ids are created. * * This function call must use less than 30 000 gas. */ function supportsInterface(bytes4 interfaceId) external view returns (bool); }
// SPDX-License-Identifier: MIT pragma solidity >=0.8.0; struct SetConfigParam { uint32 eid; uint32 configType; bytes config; } interface IMessageLibManager { struct Timeout { address lib; uint256 expiry; } event LibraryRegistered(address newLib); event DefaultSendLibrarySet(uint32 eid, address newLib); event DefaultReceiveLibrarySet(uint32 eid, address newLib); event DefaultReceiveLibraryTimeoutSet(uint32 eid, address oldLib, uint256 expiry); event SendLibrarySet(address sender, uint32 eid, address newLib); event ReceiveLibrarySet(address receiver, uint32 eid, address newLib); event ReceiveLibraryTimeoutSet(address receiver, uint32 eid, address oldLib, uint256 timeout); function registerLibrary(address _lib) external; function isRegisteredLibrary(address _lib) external view returns (bool); function getRegisteredLibraries() external view returns (address[] memory); function setDefaultSendLibrary(uint32 _eid, address _newLib) external; function defaultSendLibrary(uint32 _eid) external view returns (address); function setDefaultReceiveLibrary(uint32 _eid, address _newLib, uint256 _gracePeriod) external; function defaultReceiveLibrary(uint32 _eid) external view returns (address); function setDefaultReceiveLibraryTimeout(uint32 _eid, address _lib, uint256 _expiry) external; function defaultReceiveLibraryTimeout(uint32 _eid) external view returns (address lib, uint256 expiry); function isSupportedEid(uint32 _eid) external view returns (bool); function isValidReceiveLibrary(address _receiver, uint32 _eid, address _lib) external view returns (bool); /// ------------------- OApp interfaces ------------------- function setSendLibrary(address _oapp, uint32 _eid, address _newLib) external; function getSendLibrary(address _sender, uint32 _eid) external view returns (address lib); function isDefaultSendLibrary(address _sender, uint32 _eid) external view returns (bool); function setReceiveLibrary(address _oapp, uint32 _eid, address _newLib, uint256 _gracePeriod) external; function getReceiveLibrary(address _receiver, uint32 _eid) external view returns (address lib, bool isDefault); function setReceiveLibraryTimeout(address _oapp, uint32 _eid, address _lib, uint256 _expiry) external; function receiveLibraryTimeout(address _receiver, uint32 _eid) external view returns (address lib, uint256 expiry); function setConfig(address _oapp, address _lib, SetConfigParam[] calldata _params) external; function getConfig( address _oapp, address _lib, uint32 _eid, uint32 _configType ) external view returns (bytes memory config); }
// SPDX-License-Identifier: MIT pragma solidity >=0.8.0; interface IMessagingComposer { event ComposeSent(address from, address to, bytes32 guid, uint16 index, bytes message); event ComposeDelivered(address from, address to, bytes32 guid, uint16 index); event LzComposeAlert( address indexed from, address indexed to, address indexed executor, bytes32 guid, uint16 index, uint256 gas, uint256 value, bytes message, bytes extraData, bytes reason ); function composeQueue( address _from, address _to, bytes32 _guid, uint16 _index ) external view returns (bytes32 messageHash); function sendCompose(address _to, bytes32 _guid, uint16 _index, bytes calldata _message) external; function lzCompose( address _from, address _to, bytes32 _guid, uint16 _index, bytes calldata _message, bytes calldata _extraData ) external payable; }
// SPDX-License-Identifier: MIT pragma solidity >=0.8.0; interface IMessagingChannel { event InboundNonceSkipped(uint32 srcEid, bytes32 sender, address receiver, uint64 nonce); event PacketNilified(uint32 srcEid, bytes32 sender, address receiver, uint64 nonce, bytes32 payloadHash); event PacketBurnt(uint32 srcEid, bytes32 sender, address receiver, uint64 nonce, bytes32 payloadHash); function eid() external view returns (uint32); // this is an emergency function if a message cannot be verified for some reasons // required to provide _nextNonce to avoid race condition function skip(address _oapp, uint32 _srcEid, bytes32 _sender, uint64 _nonce) external; function nilify(address _oapp, uint32 _srcEid, bytes32 _sender, uint64 _nonce, bytes32 _payloadHash) external; function burn(address _oapp, uint32 _srcEid, bytes32 _sender, uint64 _nonce, bytes32 _payloadHash) external; function nextGuid(address _sender, uint32 _dstEid, bytes32 _receiver) external view returns (bytes32); function inboundNonce(address _receiver, uint32 _srcEid, bytes32 _sender) external view returns (uint64); function outboundNonce(address _sender, uint32 _dstEid, bytes32 _receiver) external view returns (uint64); function inboundPayloadHash( address _receiver, uint32 _srcEid, bytes32 _sender, uint64 _nonce ) external view returns (bytes32); function lazyInboundNonce(address _receiver, uint32 _srcEid, bytes32 _sender) external view returns (uint64); }
// SPDX-License-Identifier: MIT pragma solidity >=0.8.0; interface IMessagingContext { function isSendingMessage() external view returns (bool); function getSendContext() external view returns (uint32 dstEid, address sender); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (access/Ownable.sol) pragma solidity ^0.8.20; import {Context} from "../utils/Context.sol"; /** * @dev Contract module which provides a basic access control mechanism, where * there is an account (an owner) that can be granted exclusive access to * specific functions. * * The initial owner is set to the address provided by the deployer. This can * later be changed with {transferOwnership}. * * This module is used through inheritance. It will make available the modifier * `onlyOwner`, which can be applied to your functions to restrict their use to * the owner. */ abstract contract Ownable is Context { address private _owner; /** * @dev The caller account is not authorized to perform an operation. */ error OwnableUnauthorizedAccount(address account); /** * @dev The owner is not a valid owner account. (eg. `address(0)`) */ error OwnableInvalidOwner(address owner); event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); /** * @dev Initializes the contract setting the address provided by the deployer as the initial owner. */ constructor(address initialOwner) { if (initialOwner == address(0)) { revert OwnableInvalidOwner(address(0)); } _transferOwnership(initialOwner); } /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { _checkOwner(); _; } /** * @dev Returns the address of the current owner. */ function owner() public view virtual returns (address) { return _owner; } /** * @dev Throws if the sender is not the owner. */ function _checkOwner() internal view virtual { if (owner() != _msgSender()) { revert OwnableUnauthorizedAccount(_msgSender()); } } /** * @dev Leaves the contract without owner. It will not be possible to call * `onlyOwner` functions. Can only be called by the current owner. * * NOTE: Renouncing ownership will leave the contract without an owner, * thereby disabling any functionality that is only available to the owner. */ function renounceOwnership() public virtual onlyOwner { _transferOwnership(address(0)); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Can only be called by the current owner. */ function transferOwnership(address newOwner) public virtual onlyOwner { if (newOwner == address(0)) { revert OwnableInvalidOwner(address(0)); } _transferOwnership(newOwner); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Internal function without access restriction. */ function _transferOwnership(address newOwner) internal virtual { address oldOwner = _owner; _owner = newOwner; emit OwnershipTransferred(oldOwner, newOwner); } }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.20; import { ILayerZeroEndpointV2 } from "@layerzerolabs/lz-evm-protocol-v2/contracts/interfaces/ILayerZeroEndpointV2.sol"; /** * @title IOAppCore */ interface IOAppCore { // Custom error messages error OnlyPeer(uint32 eid, bytes32 sender); error NoPeer(uint32 eid); error InvalidEndpointCall(); error InvalidDelegate(); // Event emitted when a peer (OApp) is set for a corresponding endpoint event PeerSet(uint32 eid, bytes32 peer); /** * @notice Retrieves the OApp version information. * @return senderVersion The version of the OAppSender.sol contract. * @return receiverVersion The version of the OAppReceiver.sol contract. */ function oAppVersion() external view returns (uint64 senderVersion, uint64 receiverVersion); /** * @notice Retrieves the LayerZero endpoint associated with the OApp. * @return iEndpoint The LayerZero endpoint as an interface. */ function endpoint() external view returns (ILayerZeroEndpointV2 iEndpoint); /** * @notice Retrieves the peer (OApp) associated with a corresponding endpoint. * @param _eid The endpoint ID. * @return peer The peer address (OApp instance) associated with the corresponding endpoint. */ function peers(uint32 _eid) external view returns (bytes32 peer); /** * @notice Sets the peer address (OApp instance) for a corresponding endpoint. * @param _eid The endpoint ID. * @param _peer The address of the peer to be associated with the corresponding endpoint. */ function setPeer(uint32 _eid, bytes32 _peer) external; /** * @notice Sets the delegate address for the OApp Core. * @param _delegate The address of the delegate to be set. */ function setDelegate(address _delegate) external; }
{ "remappings": [ "ds-test/=node_modules/@layerzerolabs/toolbox-foundry/lib/ds-test/", "forge-std/=node_modules/@layerzerolabs/toolbox-foundry/lib/forge-std/", "@layerzerolabs/=node_modules/@layerzerolabs/", "@openzeppelin/=node_modules/@openzeppelin/", "halmos-cheatcodes/=node_modules/halmos-cheatcodes/", "interfaces/=contracts/interfaces/", "mocks/=test/mocks/", "solmate/=node_modules/solmate/src/", "@arbitrum/=node_modules/@arbitrum/", "hardhat-deploy/=node_modules/hardhat-deploy/", "hardhat/=node_modules/hardhat/", "solidity-bytes-utils/=node_modules/solidity-bytes-utils/" ], "optimizer": { "enabled": true, "runs": 200 }, "metadata": { "useLiteralContent": false, "bytecodeHash": "ipfs", "appendCBOR": true }, "outputSelection": { "*": { "*": [ "evm.bytecode", "evm.deployedBytecode", "devdoc", "userdoc", "metadata", "abi" ] } }, "evmVersion": "cancun", "viaIR": false, "libraries": {} }
Contract Security Audit
- No Contract Security Audit Submitted- Submit Audit Here
Contract ABI
API[{"inputs":[{"internalType":"address","name":"_authority","type":"address"},{"internalType":"address","name":"_swapFacility","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[],"name":"EnforcedPause","type":"error"},{"inputs":[],"name":"ExpectedPause","type":"error"},{"inputs":[],"name":"InvalidAddress","type":"error"},{"inputs":[],"name":"InvalidFee","type":"error"},{"inputs":[],"name":"ReentrancyGuardReentrantCall","type":"error"},{"inputs":[{"internalType":"address","name":"token","type":"address"}],"name":"SafeERC20FailedOperation","type":"error"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"user","type":"address"},{"indexed":true,"internalType":"contract Authority","name":"newAuthority","type":"address"}],"name":"AuthorityUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"account","type":"address"}],"name":"Paused","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"account","type":"address"}],"name":"Unpaused","type":"event"},{"inputs":[],"name":"authority","outputs":[{"internalType":"contract Authority","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"authorityInitialized","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"collateralToken","outputs":[{"internalType":"contract IERC20","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"debtToken","outputs":[{"internalType":"contract IERC20","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"pause","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"paused","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"collateralIn","type":"uint256"},{"components":[{"internalType":"uint32","name":"dstEid","type":"uint32"},{"internalType":"bytes32","name":"to","type":"bytes32"},{"internalType":"uint256","name":"amountLD","type":"uint256"},{"internalType":"uint256","name":"minAmountLD","type":"uint256"},{"internalType":"bytes","name":"extraOptions","type":"bytes"},{"internalType":"bytes","name":"composeMsg","type":"bytes"},{"internalType":"bytes","name":"oftCmd","type":"bytes"}],"internalType":"struct SendParam","name":"sendParam","type":"tuple"},{"components":[{"internalType":"uint256","name":"nativeFee","type":"uint256"},{"internalType":"uint256","name":"lzTokenFee","type":"uint256"}],"internalType":"struct MessagingFee","name":"lzFee","type":"tuple"},{"internalType":"address","name":"refundAddress","type":"address"},{"internalType":"uint256","name":"deadline","type":"uint256"}],"name":"swapExactCollateralForDebtAndLZSend","outputs":[{"internalType":"uint256","name":"debtOut","type":"uint256"},{"internalType":"uint256","name":"fee","type":"uint256"}],"stateMutability":"payable","type":"function"},{"inputs":[],"name":"swapFacility","outputs":[{"internalType":"contract ISwapFacility","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"unpause","outputs":[],"stateMutability":"nonpayable","type":"function"}]
Contract Creation Code
60e060405234801561000f575f80fd5b506040516110ca3803806110ca83398101604081905261002e91610461565b600180556002805460ff191690556001600160a01b0382166100635760405163e6c4247b60e01b815260040160405180910390fd5b6001600160a01b03811661008a5760405163e6c4247b60e01b815260040160405180910390fd5b610093826101bf565b6001600160a01b038116608081905260408051632c805af560e21b8152905163b2016bd4916004808201926020929091908290030181865afa1580156100db573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906100ff9190610499565b6001600160a01b031660a0816001600160a01b0316815250506080516001600160a01b031663f8d898986040518163ffffffff1660e01b8152600401602060405180830381865afa158015610156573d5f803e3d5ffd5b505050506040513d601f19601f8201168201806040525081019061017a9190610499565b6001600160a01b0390811660c05260805160a05161019b9216905f196102d1565b60805160c0516101b8916001600160a01b03909116905f196102d1565b50506104bb565b5f546001600160a01b03161561021c5760405162461bcd60e51b815260206004820152601b60248201527f417574683a20617574686f72697479206973206e6f6e2d7a65726f000000000060448201526064015b60405180910390fd5b5f54600160a01b900460ff16156102815760405162461bcd60e51b815260206004820152602360248201527f417574683a20617574686f7269747920616c726561647920696e697469616c696044820152621e995960ea1b6064820152608401610213565b5f80546001600160a81b0319166001600160a01b038316908117600160a01b178255604051909130917fa3396fd7f6e0a21b50e5089d2da70d5ac0a3bbbd1f617a93f134b763899801989190a350565b604080516001600160a01b038416602482015260448082018490528251808303909101815260649091019091526020810180516001600160e01b0390811663095ea7b360e01b17909152610329908590839061039516565b61038f57604080516001600160a01b03851660248201525f6044808301919091528251808303909101815260649091019091526020810180516001600160e01b0390811663095ea7b360e01b179091526103859186916103de16565b61038f84826103de565b50505050565b5f805f8060205f8651602088015f8a5af192503d91505f5190508280156103d4575081156103c657806001146103d4565b5f866001600160a01b03163b115b9695505050505050565b5f8060205f8451602086015f885af1806103fd576040513d5f823e3d81fd5b50505f513d91508115610414578060011415610421565b6001600160a01b0384163b155b1561038f57604051635274afe760e01b81526001600160a01b0385166004820152602401610213565b6001600160a01b038116811461045e575f80fd5b50565b5f8060408385031215610472575f80fd5b825161047d8161044a565b602084015190925061048e8161044a565b809150509250929050565b5f602082840312156104a9575f80fd5b81516104b48161044a565b9392505050565b60805160a05160c051610bd06104fa5f395f81816101ca01526103aa01525f818161017b01526102bf01525f818161013001526103170152610bd05ff3fe608060405260043610610084575f3560e01c806397bc1e1b1161005757806397bc1e1b14610102578063ae06b7e41461011f578063b2016bd41461016a578063bf7e214f1461019d578063f8d89898146101b9575f80fd5b806306aad36e146100885780633f4ba83a146100b55780635c975abb146100cb5780638456cb59146100ee575b5f80fd5b61009b61009636600461087b565b6101ec565b604080519283526020830191909152015b60405180910390f35b3480156100c0575f80fd5b506100c961043b565b005b3480156100d6575f80fd5b5060025460ff165b60405190151581526020016100ac565b3480156100f9575f80fd5b506100c96104a3565b34801561010d575f80fd5b505f54600160a01b900460ff166100de565b34801561012a575f80fd5b506101527f000000000000000000000000000000000000000000000000000000000000000081565b6040516001600160a01b0390911681526020016100ac565b348015610175575f80fd5b506101527f000000000000000000000000000000000000000000000000000000000000000081565b3480156101a8575f80fd5b505f546001600160a01b0316610152565b3480156101c4575f80fd5b506101527f000000000000000000000000000000000000000000000000000000000000000081565b5f806101f6610509565b6101fe61052d565b60a086015151156102435760405162461bcd60e51b815260206004820152600a6024820152694e6f20636f6d706f736560b01b60448201526064015b60405180910390fd5b60c086015151156102825760405162461bcd60e51b8152602060048201526009602482015268139bc81bd99d10db5960ba1b604482015260640161023a565b84353410806102945750602085013515155b156102b2576040516358d620b360e01b815260040160405180910390fd5b6102e76001600160a01b037f00000000000000000000000000000000000000000000000000000000000000001633308a610557565b6060860151604051633cb50d7d60e01b8152600481018990526024810191909152306044820152606481018490527f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031690633cb50d7d9060840160408051808303815f875af1158015610364573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190610388919061098c565b60408089018390525163c7c7f5b360e01b815291935091506001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000169063c7c7f5b39034906103e5908a908a908a906004016109dc565b60c06040518083038185885af1158015610401573d5f803e3d5ffd5b50505050506040513d601f19601f820116820180604052508101906104269190610ae4565b505061043160018055565b9550959350505050565b610450335f356001600160e01b0319166105b7565b6104915760405162461bcd60e51b8152602060048201526012602482015271105d5d1a0e8815539055551213d49256915160721b604482015260640161023a565b610499610653565b6104a1610676565b565b6104b8335f356001600160e01b0319166105b7565b6104f95760405162461bcd60e51b8152602060048201526012602482015271105d5d1a0e8815539055551213d49256915160721b604482015260640161023a565b610501610509565b6104a16106c8565b60025460ff16156104a15760405163d93c066560e01b815260040160405180910390fd5b60026001540361055057604051633ee5aeb560e01b815260040160405180910390fd5b6002600155565b604080516001600160a01b0385811660248301528416604482015260648082018490528251808303909101815260849091019091526020810180516001600160e01b03166323b872dd60e01b1790526105b1908590610705565b50505050565b5f80546001600160a01b0316801580159061064b575060405163b700961360e01b81526001600160a01b0385811660048301523060248301526001600160e01b03198516604483015282169063b700961390606401602060405180830381865afa158015610627573d5f803e3d5ffd5b505050506040513d601f19601f8201168201806040525081019061064b9190610b74565b949350505050565b60025460ff166104a157604051638dfc202b60e01b815260040160405180910390fd5b61067e610653565b6002805460ff191690557f5db9ee0a495bf2e6ff9c91a7834c1ba4fdd244a5e8aa4e537bd38aeae4b073aa335b6040516001600160a01b03909116815260200160405180910390a1565b6106d0610509565b6002805460ff191660011790557f62e78cea01bee320cd4e420270b5ea74000d11b0c9f74754ebdbfc544b05a2586106ab3390565b5f8060205f8451602086015f885af180610724576040513d5f823e3d81fd5b50505f513d9150811561073b578060011415610748565b6001600160a01b0384163b155b156105b157604051635274afe760e01b81526001600160a01b038516600482015260240161023a565b634e487b7160e01b5f52604160045260245ffd5b60405160e0810167ffffffffffffffff811182821017156107a8576107a8610771565b60405290565b803563ffffffff811681146107c1575f80fd5b919050565b5f82601f8301126107d5575f80fd5b813567ffffffffffffffff808211156107f0576107f0610771565b604051601f8301601f19908116603f0116810190828211818310171561081857610818610771565b81604052838152866020858801011115610830575f80fd5b836020870160208301375f602085830101528094505050505092915050565b5f6040828403121561085f575f80fd5b50919050565b80356001600160a01b03811681146107c1575f80fd5b5f805f805f60c0868803121561088f575f80fd5b85359450602086013567ffffffffffffffff808211156108ad575f80fd5b9087019060e0828a0312156108c0575f80fd5b6108c8610785565b6108d1836107ae565b8152602083013560208201526040830135604082015260608301356060820152608083013582811115610902575f80fd5b61090e8b8286016107c6565b60808301525060a083013582811115610925575f80fd5b6109318b8286016107c6565b60a08301525060c083013582811115610948575f80fd5b6109548b8286016107c6565b60c08301525080965050505061096d876040880161084f565b925061097b60808701610865565b9497939650919460a0013592915050565b5f806040838503121561099d575f80fd5b505080516020909101519092909150565b5f81518084528060208401602086015e5f602082860101526020601f19601f83011685010191505092915050565b6080815263ffffffff8451166080820152602084015160a0820152604084015160c0820152606084015160e08201525f608085015160e0610100840152610a276101608401826109ae565b905060a0860151607f198085840301610120860152610a4683836109ae565b925060c08801519150808584030161014086015250610a6582826109ae565b92505050610a80602083018580358252602090810135910152565b6001600160a01b0383166060830152949350505050565b5f60408284031215610aa7575f80fd5b6040516040810181811067ffffffffffffffff82111715610aca57610aca610771565b604052825181526020928301519281019290925250919050565b5f8082840360c0811215610af6575f80fd5b6080811215610b03575f80fd5b506040516060810167ffffffffffffffff8282108183111715610b2857610b28610771565b8160405285518352602086015191508082168214610b44575f80fd5b506020820152610b578560408601610a97565b60408201529150610b6b8460808501610a97565b90509250929050565b5f60208284031215610b84575f80fd5b81518015158114610b93575f80fd5b939250505056fea2646970667358221220af1149e1ee4a28ede86c74662a359c51970ba45c215ccf709bf06978053eb0bd64736f6c63430008190033000000000000000000000000515c7d8fcb950f8b030ac08c994b37b4b8f3f7b5000000000000000000000000554335b8c994e47e6dbfdc08fa8aca0510e66ba1
Deployed Bytecode
0x608060405260043610610084575f3560e01c806397bc1e1b1161005757806397bc1e1b14610102578063ae06b7e41461011f578063b2016bd41461016a578063bf7e214f1461019d578063f8d89898146101b9575f80fd5b806306aad36e146100885780633f4ba83a146100b55780635c975abb146100cb5780638456cb59146100ee575b5f80fd5b61009b61009636600461087b565b6101ec565b604080519283526020830191909152015b60405180910390f35b3480156100c0575f80fd5b506100c961043b565b005b3480156100d6575f80fd5b5060025460ff165b60405190151581526020016100ac565b3480156100f9575f80fd5b506100c96104a3565b34801561010d575f80fd5b505f54600160a01b900460ff166100de565b34801561012a575f80fd5b506101527f000000000000000000000000554335b8c994e47e6dbfdc08fa8aca0510e66ba181565b6040516001600160a01b0390911681526020016100ac565b348015610175575f80fd5b506101527f000000000000000000000000cbb7c0000ab88b473b1f5afd9ef808440eed33bf81565b3480156101a8575f80fd5b505f546001600160a01b0316610152565b3480156101c4575f80fd5b506101527f000000000000000000000000386e7a3a0c0919c9d53c3b04ff67e73ff9e45fb681565b5f806101f6610509565b6101fe61052d565b60a086015151156102435760405162461bcd60e51b815260206004820152600a6024820152694e6f20636f6d706f736560b01b60448201526064015b60405180910390fd5b60c086015151156102825760405162461bcd60e51b8152602060048201526009602482015268139bc81bd99d10db5960ba1b604482015260640161023a565b84353410806102945750602085013515155b156102b2576040516358d620b360e01b815260040160405180910390fd5b6102e76001600160a01b037f000000000000000000000000cbb7c0000ab88b473b1f5afd9ef808440eed33bf1633308a610557565b6060860151604051633cb50d7d60e01b8152600481018990526024810191909152306044820152606481018490527f000000000000000000000000554335b8c994e47e6dbfdc08fa8aca0510e66ba16001600160a01b031690633cb50d7d9060840160408051808303815f875af1158015610364573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190610388919061098c565b60408089018390525163c7c7f5b360e01b815291935091506001600160a01b037f000000000000000000000000386e7a3a0c0919c9d53c3b04ff67e73ff9e45fb6169063c7c7f5b39034906103e5908a908a908a906004016109dc565b60c06040518083038185885af1158015610401573d5f803e3d5ffd5b50505050506040513d601f19601f820116820180604052508101906104269190610ae4565b505061043160018055565b9550959350505050565b610450335f356001600160e01b0319166105b7565b6104915760405162461bcd60e51b8152602060048201526012602482015271105d5d1a0e8815539055551213d49256915160721b604482015260640161023a565b610499610653565b6104a1610676565b565b6104b8335f356001600160e01b0319166105b7565b6104f95760405162461bcd60e51b8152602060048201526012602482015271105d5d1a0e8815539055551213d49256915160721b604482015260640161023a565b610501610509565b6104a16106c8565b60025460ff16156104a15760405163d93c066560e01b815260040160405180910390fd5b60026001540361055057604051633ee5aeb560e01b815260040160405180910390fd5b6002600155565b604080516001600160a01b0385811660248301528416604482015260648082018490528251808303909101815260849091019091526020810180516001600160e01b03166323b872dd60e01b1790526105b1908590610705565b50505050565b5f80546001600160a01b0316801580159061064b575060405163b700961360e01b81526001600160a01b0385811660048301523060248301526001600160e01b03198516604483015282169063b700961390606401602060405180830381865afa158015610627573d5f803e3d5ffd5b505050506040513d601f19601f8201168201806040525081019061064b9190610b74565b949350505050565b60025460ff166104a157604051638dfc202b60e01b815260040160405180910390fd5b61067e610653565b6002805460ff191690557f5db9ee0a495bf2e6ff9c91a7834c1ba4fdd244a5e8aa4e537bd38aeae4b073aa335b6040516001600160a01b03909116815260200160405180910390a1565b6106d0610509565b6002805460ff191660011790557f62e78cea01bee320cd4e420270b5ea74000d11b0c9f74754ebdbfc544b05a2586106ab3390565b5f8060205f8451602086015f885af180610724576040513d5f823e3d81fd5b50505f513d9150811561073b578060011415610748565b6001600160a01b0384163b155b156105b157604051635274afe760e01b81526001600160a01b038516600482015260240161023a565b634e487b7160e01b5f52604160045260245ffd5b60405160e0810167ffffffffffffffff811182821017156107a8576107a8610771565b60405290565b803563ffffffff811681146107c1575f80fd5b919050565b5f82601f8301126107d5575f80fd5b813567ffffffffffffffff808211156107f0576107f0610771565b604051601f8301601f19908116603f0116810190828211818310171561081857610818610771565b81604052838152866020858801011115610830575f80fd5b836020870160208301375f602085830101528094505050505092915050565b5f6040828403121561085f575f80fd5b50919050565b80356001600160a01b03811681146107c1575f80fd5b5f805f805f60c0868803121561088f575f80fd5b85359450602086013567ffffffffffffffff808211156108ad575f80fd5b9087019060e0828a0312156108c0575f80fd5b6108c8610785565b6108d1836107ae565b8152602083013560208201526040830135604082015260608301356060820152608083013582811115610902575f80fd5b61090e8b8286016107c6565b60808301525060a083013582811115610925575f80fd5b6109318b8286016107c6565b60a08301525060c083013582811115610948575f80fd5b6109548b8286016107c6565b60c08301525080965050505061096d876040880161084f565b925061097b60808701610865565b9497939650919460a0013592915050565b5f806040838503121561099d575f80fd5b505080516020909101519092909150565b5f81518084528060208401602086015e5f602082860101526020601f19601f83011685010191505092915050565b6080815263ffffffff8451166080820152602084015160a0820152604084015160c0820152606084015160e08201525f608085015160e0610100840152610a276101608401826109ae565b905060a0860151607f198085840301610120860152610a4683836109ae565b925060c08801519150808584030161014086015250610a6582826109ae565b92505050610a80602083018580358252602090810135910152565b6001600160a01b0383166060830152949350505050565b5f60408284031215610aa7575f80fd5b6040516040810181811067ffffffffffffffff82111715610aca57610aca610771565b604052825181526020928301519281019290925250919050565b5f8082840360c0811215610af6575f80fd5b6080811215610b03575f80fd5b506040516060810167ffffffffffffffff8282108183111715610b2857610b28610771565b8160405285518352602086015191508082168214610b44575f80fd5b506020820152610b578560408601610a97565b60408201529150610b6b8460808501610a97565b90509250929050565b5f60208284031215610b84575f80fd5b81518015158114610b93575f80fd5b939250505056fea2646970667358221220af1149e1ee4a28ede86c74662a359c51970ba45c215ccf709bf06978053eb0bd64736f6c63430008190033
Constructor Arguments (ABI-Encoded and is the last bytes of the Contract Creation Code above)
000000000000000000000000515c7d8fcb950f8b030ac08c994b37b4b8f3f7b5000000000000000000000000554335b8c994e47e6dbfdc08fa8aca0510e66ba1
-----Decoded View---------------
Arg [0] : _authority (address): 0x515C7d8Fcb950f8b030ac08C994b37b4b8F3F7B5
Arg [1] : _swapFacility (address): 0x554335b8C994E47e6dbfDC08Fa8aca0510e66BA1
-----Encoded View---------------
2 Constructor Arguments found :
Arg [0] : 000000000000000000000000515c7d8fcb950f8b030ac08c994b37b4b8f3f7b5
Arg [1] : 000000000000000000000000554335b8c994e47e6dbfdc08fa8aca0510e66ba1
Loading...
Loading
Loading...
Loading
Multichain Portfolio | 34 Chains
Chain | Token | Portfolio % | Price | Amount | Value |
---|
Loading...
Loading
Loading...
Loading
Loading...
Loading
[ Download: CSV Export ]
[ 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.