Overview
ETH Balance
0 ETH
Eth Value
$0.00More Info
Private Name Tags
ContractCreator
Transaction Hash |
Method
|
Block
|
From
|
To
|
|||||
---|---|---|---|---|---|---|---|---|---|
Latest 1 internal transaction
Advanced mode:
Parent Transaction Hash | Block |
From
|
To
|
|||
---|---|---|---|---|---|---|
20727149 | 144 days ago | Contract Creation | 0 ETH |
Loading...
Loading
Contract Source Code Verified (Exact Match)
Contract Name:
AaveWrapper
Compiler Version
v0.8.24+commit.e11b9ed9
Optimization Enabled:
Yes with 10000 runs
Other Settings:
london EvmVersion
Contract Source Code (Solidity Standard Json-Input format)
// SPDX-License-Identifier: MIT // Thanks to ultrasecr.eth pragma solidity ^0.8.19; import { Registry } from "src/Registry.sol"; import { IPool } from "./interfaces/IPool.sol"; import { IPoolDataProvider } from "./interfaces/IPoolDataProvider.sol"; import { IFlashLoanReceiverV2V3 } from "./interfaces/IFlashLoanReceiverV2V3.sol"; import { Math } from "@openzeppelin/contracts/utils/math/Math.sol"; import { BaseWrapper, IERC7399, IERC20 } from "../BaseWrapper.sol"; import { Arrays } from "../utils/Arrays.sol"; import { WAD } from "../utils/constants.sol"; /// @dev Aave Flash Lender that uses the Aave Pool as source of liquidity. /// Aave doesn't allow flow splitting or pushing repayments, so this wrapper is completely vanilla. contract AaveWrapper is BaseWrapper, IFlashLoanReceiverV2V3 { using Arrays for *; error NotPool(); error NotInitiator(); // solhint-disable-next-line var-name-mixedcase address public immutable ADDRESSES_PROVIDER; // solhint-disable-next-line var-name-mixedcase address public immutable POOL; // solhint-disable-next-line var-name-mixedcase address public immutable LENDING_POOL; IPoolDataProvider public immutable dataProvider; bool public immutable isV2; constructor(Registry reg, string memory name) { address pool; (pool, ADDRESSES_PROVIDER, dataProvider, isV2) = abi.decode(reg.getSafe(string.concat(name, "Wrapper")), (address, address, IPoolDataProvider, bool)); POOL = pool; LENDING_POOL = pool; } /// @inheritdoc IERC7399 function maxFlashLoan(address asset) external view returns (uint256) { return _maxFlashLoan(asset); } /// @inheritdoc IERC7399 function flashFee(address asset, uint256 amount) external view returns (uint256) { uint256 max = _maxFlashLoan(asset); require(max > 0, "Unsupported currency"); return amount >= max ? type(uint256).max : _flashFee(amount); } /// @inheritdoc IFlashLoanReceiverV2V3 function executeOperation( address[] calldata assets, uint256[] calldata amounts, uint256[] calldata fees, address initiator, bytes calldata params ) external override returns (bool) { if (msg.sender != address(POOL)) revert NotPool(); if (initiator != address(this)) revert NotInitiator(); _bridgeToCallback(assets[0], amounts[0], fees[0], params); return true; } function _flashLoan(address asset, uint256 amount, bytes memory data) internal virtual override { IPool(POOL).flashLoan({ receiverAddress: address(this), assets: asset.toArray(), amounts: amount.toArray(), interestRateModes: 0.toArray(), // NONE onBehalfOf: address(this), params: data, referralCode: 0 }); } function _maxFlashLoan(address asset) internal view returns (uint256 max) { (,,,,,,,, bool isActive, bool isFrozen) = dataProvider.getReserveConfigurationData(asset); (address aTokenAddress,,) = dataProvider.getReserveTokensAddresses(asset); bool isFlashLoanEnabled = isV2 ? true : dataProvider.getFlashLoanEnabled(asset); max = !isFrozen && isActive && isFlashLoanEnabled ? IERC20(asset).balanceOf(aTokenAddress) : 0; } function _flashFee(uint256 amount) internal view virtual returns (uint256) { return Math.mulDiv(amount, IPool(POOL).FLASHLOAN_PREMIUM_TOTAL() * 0.0001e18, WAD, Math.Rounding.Ceil); } }
// SPDX-License-Identifier: MIT pragma solidity >=0.8.19; import { AccessControl } from "@openzeppelin/contracts/access/AccessControl.sol"; contract Registry is AccessControl { bytes32 public constant USER = keccak256("USER"); event Registered(string key, bytes value); error NotFound(); mapping(string key => bytes value) public get; constructor(address[] memory owners, address[] memory users) { for (uint256 i = 0; i < owners.length; i++) { _grantRole(DEFAULT_ADMIN_ROLE, owners[i]); } for (uint256 i = 0; i < users.length; i++) { _grantRole(USER, users[i]); } } function set(string memory key, bytes memory value) external onlyRole(USER) { get[key] = value; emit Registered(key, value); } function getSafe(string calldata key) external view returns (bytes memory result) { result = get[key]; if (result.length == 0) { revert NotFound(); } } }
// SPDX-License-Identifier: AGPL-3.0 pragma solidity ^0.8.19; /** * @title IPool * @author Aave * @notice Defines the basic interface for an Aave Pool. */ interface IPool { /** * @notice Allows smartcontracts to access the liquidity of the pool within one transaction, * as long as the amount taken plus a fee is returned. * @dev IMPORTANT There are security concerns for developers of flashloan receiver contracts that must be kept * into consideration. For further details please visit https://docs.aave.com/developers/ * @param receiverAddress The address of the contract receiving the funds, implementing IFlashLoanReceiver interface * @param assets The addresses of the assets being flash-borrowed * @param amounts The amounts of the assets being flash-borrowed * @param interestRateModes Types of the debt to open if the flash loan is not returned: * 0 -> Don"t open any debt, just revert if funds can"t be transferred from the receiver * 1 -> Open debt at stable rate for the value of the amount flash-borrowed to the `onBehalfOf` address * 2 -> Open debt at variable rate for the value of the amount flash-borrowed to the `onBehalfOf` address * @param onBehalfOf The address that will receive the debt in the case of using on `modes` 1 or 2 * @param params Variadic packed params to pass to the receiver as extra information * @param referralCode The code used to register the integrator originating the operation, for potential rewards. * 0 if the action is executed directly by the user, without any middle-man */ function flashLoan( address receiverAddress, address[] calldata assets, uint256[] calldata amounts, uint256[] calldata interestRateModes, address onBehalfOf, bytes calldata params, uint16 referralCode ) external; /** * @notice Returns the total fee on flash loans * @return The total fee on flashloans */ function FLASHLOAN_PREMIUM_TOTAL() external view returns (uint128); }
// SPDX-License-Identifier: AGPL-3.0 pragma solidity ^0.8.19; /** * @title IPoolDataProvider * @author Aave * @notice Defines the basic interface of a PoolDataProvider */ interface IPoolDataProvider { /** * @notice Returns the configuration data of the reserve * @dev Not returning borrow and supply caps for compatibility, nor pause flag * @param asset The address of the underlying asset of the reserve * @return decimals The number of decimals of the reserve * @return ltv The ltv of the reserve * @return liquidationThreshold The liquidationThreshold of the reserve * @return liquidationBonus The liquidationBonus of the reserve * @return reserveFactor The reserveFactor of the reserve * @return usageAsCollateralEnabled True if the usage as collateral is enabled, false otherwise * @return borrowingEnabled True if borrowing is enabled, false otherwise * @return stableBorrowRateEnabled True if stable rate borrowing is enabled, false otherwise * @return isActive True if it is active, false otherwise * @return isFrozen True if it is frozen, false otherwise */ function getReserveConfigurationData(address asset) external view returns ( uint256 decimals, uint256 ltv, uint256 liquidationThreshold, uint256 liquidationBonus, uint256 reserveFactor, bool usageAsCollateralEnabled, bool borrowingEnabled, bool stableBorrowRateEnabled, bool isActive, bool isFrozen ); /** * @notice Returns the token addresses of the reserve * @param asset The address of the underlying asset of the reserve * @return aTokenAddress The AToken address of the reserve * @return stableDebtTokenAddress The StableDebtToken address of the reserve * @return variableDebtTokenAddress The VariableDebtToken address of the reserve */ function getReserveTokensAddresses(address asset) external view returns (address aTokenAddress, address stableDebtTokenAddress, address variableDebtTokenAddress); /** * @notice Returns whether the reserve has FlashLoans enabled or disabled * @param asset The address of the underlying asset of the reserve * @return True if FlashLoans are enabled, false otherwise */ function getFlashLoanEnabled(address asset) external view returns (bool); }
// SPDX-License-Identifier: AGPL-3.0 pragma solidity ^0.8.19; /** * @title IFlashLoanReceiver interface * @notice Interface for the Aave fee IFlashLoanReceiver (V2/V3 compatible). * @author Aave * @dev implement this interface to develop a flashloan-compatible flashLoanReceiver contract * */ interface IFlashLoanReceiverV2V3 { function executeOperation( address[] calldata assets, uint256[] calldata amounts, uint256[] calldata premiums, address initiator, bytes calldata params ) external returns (bool); function ADDRESSES_PROVIDER() external view returns (address); function LENDING_POOL() external view returns (address); function POOL() external view returns (address); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (utils/math/Math.sol) pragma solidity ^0.8.20; /** * @dev Standard math utilities missing in the Solidity language. */ library Math { /** * @dev Muldiv operation overflow. */ error MathOverflowedMulDiv(); enum Rounding { Floor, // Toward negative infinity Ceil, // Toward positive infinity Trunc, // Toward zero Expand // Away from zero } /** * @dev Returns the addition of two unsigned integers, with an overflow flag. */ function tryAdd(uint256 a, uint256 b) internal pure returns (bool, uint256) { unchecked { uint256 c = a + b; if (c < a) return (false, 0); return (true, c); } } /** * @dev Returns the subtraction of two unsigned integers, with an overflow flag. */ function trySub(uint256 a, uint256 b) internal pure returns (bool, uint256) { unchecked { if (b > a) return (false, 0); return (true, a - b); } } /** * @dev Returns the multiplication of two unsigned integers, with an overflow flag. */ function tryMul(uint256 a, uint256 b) internal pure returns (bool, uint256) { unchecked { // Gas optimization: this is cheaper than requiring 'a' not being zero, but the // benefit is lost if 'b' is also tested. // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522 if (a == 0) return (true, 0); uint256 c = a * b; if (c / a != b) return (false, 0); return (true, c); } } /** * @dev Returns the division of two unsigned integers, with a division by zero flag. */ function tryDiv(uint256 a, uint256 b) internal pure returns (bool, uint256) { unchecked { if (b == 0) return (false, 0); return (true, a / b); } } /** * @dev Returns the remainder of dividing two unsigned integers, with a division by zero flag. */ function tryMod(uint256 a, uint256 b) internal pure returns (bool, uint256) { unchecked { if (b == 0) return (false, 0); return (true, a % b); } } /** * @dev Returns the largest of two numbers. */ function max(uint256 a, uint256 b) internal pure returns (uint256) { return a > b ? a : b; } /** * @dev Returns the smallest of two numbers. */ function min(uint256 a, uint256 b) internal pure returns (uint256) { return a < b ? a : b; } /** * @dev Returns the average of two numbers. The result is rounded towards * zero. */ function average(uint256 a, uint256 b) internal pure returns (uint256) { // (a + b) / 2 can overflow. return (a & b) + (a ^ b) / 2; } /** * @dev Returns the ceiling of the division of two numbers. * * This differs from standard division with `/` in that it rounds towards infinity instead * of rounding towards zero. */ function ceilDiv(uint256 a, uint256 b) internal pure returns (uint256) { if (b == 0) { // Guarantee the same behavior as in a regular Solidity division. return a / b; } // (a + b - 1) / b can overflow on addition, so we distribute. return a == 0 ? 0 : (a - 1) / b + 1; } /** * @notice Calculates floor(x * y / denominator) with full precision. Throws if result overflows a uint256 or * denominator == 0. * @dev Original credit to Remco Bloemen under MIT license (https://xn--2-umb.com/21/muldiv) with further edits by * Uniswap Labs also under MIT license. */ function mulDiv(uint256 x, uint256 y, uint256 denominator) internal pure returns (uint256 result) { unchecked { // 512-bit multiply [prod1 prod0] = x * y. Compute the product mod 2^256 and mod 2^256 - 1, then use // use the Chinese Remainder Theorem to reconstruct the 512 bit result. The result is stored in two 256 // variables such that product = prod1 * 2^256 + prod0. uint256 prod0 = x * y; // Least significant 256 bits of the product uint256 prod1; // Most significant 256 bits of the product assembly { let mm := mulmod(x, y, not(0)) prod1 := sub(sub(mm, prod0), lt(mm, prod0)) } // Handle non-overflow cases, 256 by 256 division. if (prod1 == 0) { // Solidity will revert if denominator == 0, unlike the div opcode on its own. // The surrounding unchecked block does not change this fact. // See https://docs.soliditylang.org/en/latest/control-structures.html#checked-or-unchecked-arithmetic. return prod0 / denominator; } // Make sure the result is less than 2^256. Also prevents denominator == 0. if (denominator <= prod1) { revert MathOverflowedMulDiv(); } /////////////////////////////////////////////// // 512 by 256 division. /////////////////////////////////////////////// // Make division exact by subtracting the remainder from [prod1 prod0]. uint256 remainder; assembly { // Compute remainder using mulmod. remainder := mulmod(x, y, denominator) // Subtract 256 bit number from 512 bit number. prod1 := sub(prod1, gt(remainder, prod0)) prod0 := sub(prod0, remainder) } // Factor powers of two out of denominator and compute largest power of two divisor of denominator. // Always >= 1. See https://cs.stackexchange.com/q/138556/92363. uint256 twos = denominator & (0 - denominator); assembly { // Divide denominator by twos. denominator := div(denominator, twos) // Divide [prod1 prod0] by twos. prod0 := div(prod0, twos) // Flip twos such that it is 2^256 / twos. If twos is zero, then it becomes one. twos := add(div(sub(0, twos), twos), 1) } // Shift in bits from prod1 into prod0. prod0 |= prod1 * twos; // Invert denominator mod 2^256. Now that denominator is an odd number, it has an inverse modulo 2^256 such // that denominator * inv = 1 mod 2^256. Compute the inverse by starting with a seed that is correct for // four bits. That is, denominator * inv = 1 mod 2^4. uint256 inverse = (3 * denominator) ^ 2; // Use the Newton-Raphson iteration to improve the precision. Thanks to Hensel's lifting lemma, this also // works in modular arithmetic, doubling the correct bits in each step. inverse *= 2 - denominator * inverse; // inverse mod 2^8 inverse *= 2 - denominator * inverse; // inverse mod 2^16 inverse *= 2 - denominator * inverse; // inverse mod 2^32 inverse *= 2 - denominator * inverse; // inverse mod 2^64 inverse *= 2 - denominator * inverse; // inverse mod 2^128 inverse *= 2 - denominator * inverse; // inverse mod 2^256 // Because the division is now exact we can divide by multiplying with the modular inverse of denominator. // This will give us the correct result modulo 2^256. Since the preconditions guarantee that the outcome is // less than 2^256, this is the final result. We don't need to compute the high bits of the result and prod1 // is no longer required. result = prod0 * inverse; return result; } } /** * @notice Calculates x * y / denominator with full precision, following the selected rounding direction. */ function mulDiv(uint256 x, uint256 y, uint256 denominator, Rounding rounding) internal pure returns (uint256) { uint256 result = mulDiv(x, y, denominator); if (unsignedRoundsUp(rounding) && mulmod(x, y, denominator) > 0) { result += 1; } return result; } /** * @dev Returns the square root of a number. If the number is not a perfect square, the value is rounded * towards zero. * * Inspired by Henry S. Warren, Jr.'s "Hacker's Delight" (Chapter 11). */ function sqrt(uint256 a) internal pure returns (uint256) { if (a == 0) { return 0; } // For our first guess, we get the biggest power of 2 which is smaller than the square root of the target. // // We know that the "msb" (most significant bit) of our target number `a` is a power of 2 such that we have // `msb(a) <= a < 2*msb(a)`. This value can be written `msb(a)=2**k` with `k=log2(a)`. // // This can be rewritten `2**log2(a) <= a < 2**(log2(a) + 1)` // → `sqrt(2**k) <= sqrt(a) < sqrt(2**(k+1))` // → `2**(k/2) <= sqrt(a) < 2**((k+1)/2) <= 2**(k/2 + 1)` // // Consequently, `2**(log2(a) / 2)` is a good first approximation of `sqrt(a)` with at least 1 correct bit. uint256 result = 1 << (log2(a) >> 1); // At this point `result` is an estimation with one bit of precision. We know the true value is a uint128, // since it is the square root of a uint256. Newton's method converges quadratically (precision doubles at // every iteration). We thus need at most 7 iteration to turn our partial result with one bit of precision // into the expected uint128 result. unchecked { result = (result + a / result) >> 1; result = (result + a / result) >> 1; result = (result + a / result) >> 1; result = (result + a / result) >> 1; result = (result + a / result) >> 1; result = (result + a / result) >> 1; result = (result + a / result) >> 1; return min(result, a / result); } } /** * @notice Calculates sqrt(a), following the selected rounding direction. */ function sqrt(uint256 a, Rounding rounding) internal pure returns (uint256) { unchecked { uint256 result = sqrt(a); return result + (unsignedRoundsUp(rounding) && result * result < a ? 1 : 0); } } /** * @dev Return the log in base 2 of a positive value rounded towards zero. * Returns 0 if given 0. */ function log2(uint256 value) internal pure returns (uint256) { uint256 result = 0; unchecked { if (value >> 128 > 0) { value >>= 128; result += 128; } if (value >> 64 > 0) { value >>= 64; result += 64; } if (value >> 32 > 0) { value >>= 32; result += 32; } if (value >> 16 > 0) { value >>= 16; result += 16; } if (value >> 8 > 0) { value >>= 8; result += 8; } if (value >> 4 > 0) { value >>= 4; result += 4; } if (value >> 2 > 0) { value >>= 2; result += 2; } if (value >> 1 > 0) { result += 1; } } return result; } /** * @dev Return the log in base 2, following the selected rounding direction, of a positive value. * Returns 0 if given 0. */ function log2(uint256 value, Rounding rounding) internal pure returns (uint256) { unchecked { uint256 result = log2(value); return result + (unsignedRoundsUp(rounding) && 1 << result < value ? 1 : 0); } } /** * @dev Return the log in base 10 of a positive value rounded towards zero. * Returns 0 if given 0. */ function log10(uint256 value) internal pure returns (uint256) { uint256 result = 0; unchecked { if (value >= 10 ** 64) { value /= 10 ** 64; result += 64; } if (value >= 10 ** 32) { value /= 10 ** 32; result += 32; } if (value >= 10 ** 16) { value /= 10 ** 16; result += 16; } if (value >= 10 ** 8) { value /= 10 ** 8; result += 8; } if (value >= 10 ** 4) { value /= 10 ** 4; result += 4; } if (value >= 10 ** 2) { value /= 10 ** 2; result += 2; } if (value >= 10 ** 1) { result += 1; } } return result; } /** * @dev Return the log in base 10, following the selected rounding direction, of a positive value. * Returns 0 if given 0. */ function log10(uint256 value, Rounding rounding) internal pure returns (uint256) { unchecked { uint256 result = log10(value); return result + (unsignedRoundsUp(rounding) && 10 ** result < value ? 1 : 0); } } /** * @dev Return the log in base 256 of a positive value rounded towards zero. * Returns 0 if given 0. * * Adding one to the result gives the number of pairs of hex symbols needed to represent `value` as a hex string. */ function log256(uint256 value) internal pure returns (uint256) { uint256 result = 0; unchecked { if (value >> 128 > 0) { value >>= 128; result += 16; } if (value >> 64 > 0) { value >>= 64; result += 8; } if (value >> 32 > 0) { value >>= 32; result += 4; } if (value >> 16 > 0) { value >>= 16; result += 2; } if (value >> 8 > 0) { result += 1; } } return result; } /** * @dev Return the log in base 256, following the selected rounding direction, of a positive value. * Returns 0 if given 0. */ function log256(uint256 value, Rounding rounding) internal pure returns (uint256) { unchecked { uint256 result = log256(value); return result + (unsignedRoundsUp(rounding) && 1 << (result << 3) < value ? 1 : 0); } } /** * @dev Returns whether a provided rounding mode is considered rounding up for unsigned integers. */ function unsignedRoundsUp(Rounding rounding) internal pure returns (bool) { return uint8(rounding) % 2 == 1; } }
// SPDX-License-Identifier: MIT // Thanks to ultrasecr.eth pragma solidity ^0.8.19; import { IERC7399 } from "./interfaces/IERC7399.sol"; import { IERC20Metadata as IERC20 } from "@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol"; import { SafeERC20 } from "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol"; import { FunctionCodec } from "./utils/FunctionCodec.sol"; /// @dev All ERC7399 flash loan wrappers have the same general structure. /// - The ERC7399 `flash` function is the entry point for the flash loan. /// - The wrapper calls the underlying lender flash lender on their non-ERC7399 flash lending call to borrow the funds. /// - The lender sends the funds to the wrapper. /// - The wrapper receives the callback from the lender. /// - The wrapper sends the funds to the loan receiver. /// - The wrapper calls the callback supplied by the original borrower. /// - The callback from the original borrower executes. /// - Depending on the lender, the wrapper may have to approve it to pull the repayment. /// - If there is any data to return, it is kept in a storage variable. /// - The wrapper exits the callback. /// - The lender verifies or pulls the repayment. /// - The wrapper returns to the original borrower the stored result of its callback. abstract contract BaseWrapper is IERC7399 { using SafeERC20 for IERC20; struct Data { address loanReceiver; address initiator; function(address, address, address, uint256, uint256, bytes memory) external returns (bytes memory) callback; bytes initiatorData; } bytes internal _callbackResult; /// @inheritdoc IERC7399 /// @dev The entry point for the ERC7399 flash loan. Packs data to convert the legacy flash loan into an ERC7399 /// flash loan. Then it calls the legacy flash loan. Once the flash loan is done, checks if there is any return /// data and returns it. function flash( address loanReceiver, address asset, uint256 amount, bytes calldata initiatorData, function(address, address, address, uint256, uint256, bytes memory) external returns (bytes memory) callback ) external returns (bytes memory result) { Data memory data = Data({ loanReceiver: loanReceiver, initiator: msg.sender, callback: callback, initiatorData: initiatorData }); return _flash(asset, amount, data); } /// @dev Alternative entry point for the ERC7399 flash loan, without function pointers. Packs data to convert the /// legacy flash loan into an ERC7399 flash loan. Then it calls the legacy flash loan. Once the flash loan is done, /// checks if there is any return data and returns it. function flash( address loanReceiver, address asset, uint256 amount, bytes calldata initiatorData, address callbackTarget, bytes4 callbackSelector ) external returns (bytes memory result) { Data memory data = Data({ loanReceiver: loanReceiver, initiator: msg.sender, callback: FunctionCodec.decodeFunction(callbackTarget, callbackSelector), initiatorData: initiatorData }); return _flash(asset, amount, data); } function _flash(address asset, uint256 amount, Data memory data) internal virtual returns (bytes memory result) { _flashLoan(asset, amount, abi.encode(data)); result = _callbackResult; // Avoid storage write if not needed if (result.length > 0) { delete _callbackResult; } return result; } /// @dev Call the legacy flashloan function in the child contract. This is where we borrow from Aave, Uniswap, etc. function _flashLoan(address asset, uint256 amount, bytes memory data) internal virtual; /// @dev Handle the common parts of bridging the callback from legacy to ERC7399. Transfer the funds to the loan /// receiver. Call the callback supplied by the original borrower. Approve the repayment if necessary. If there is /// any result, it is kept in a storage variable to be retrieved on `flash` after the legacy flash loan is finished. function _bridgeToCallback(address asset, uint256 amount, uint256 fee, bytes memory params) internal { Data memory data = abi.decode(params, (Data)); _transferAssets(asset, amount, data.loanReceiver); // call the callback and tell the callback receiver to repay the loan to this contract bytes memory result = data.callback(data.initiator, _repayTo(), address(asset), amount, fee, data.initiatorData); _approveRepayment(asset, amount, fee); if (result.length > 0) { // if there's any result, it is kept in a storage variable to be retrieved later in this tx _callbackResult = result; } } /// @dev Transfer the assets to the loan receiver. /// Override it if the provider can send the funds directly function _transferAssets(address asset, uint256 amount, address loanReceiver) internal virtual { IERC20(asset).safeTransfer(loanReceiver, amount); } /// @dev Approve the repayment of the loan to the provider if needed. /// Override it if the provider can receive the funds directly and you want to avoid the if condition function _approveRepayment(address asset, uint256 amount, uint256 fee) internal virtual { if (_repayTo() == address(this)) { IERC20(asset).forceApprove(msg.sender, amount + fee); } } /// @dev Where should the end client send the funds to repay the loan /// Override it if the provider can receive the funds directly function _repayTo() internal view virtual returns (address) { return address(this); } }
// SPDX-License-Identifier: MIT // Thanks to ultrasecr.eth pragma solidity ^0.8.19; library Arrays { function toArray(uint256 n) internal pure returns (uint256[] memory arr) { arr = new uint256[](1); arr[0] = n; } function toArray(address a) internal pure returns (address[] memory arr) { arr = new address[](1); arr[0] = a; } function toArray(address a, address b) internal pure returns (address[] memory arr) { arr = new address[](2); arr[0] = a; arr[1] = b; } }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.19; uint256 constant WAD = 1e18;
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (access/AccessControl.sol) pragma solidity ^0.8.20; import {IAccessControl} from "./IAccessControl.sol"; import {Context} from "../utils/Context.sol"; import {ERC165} from "../utils/introspection/ERC165.sol"; /** * @dev Contract module that allows children to implement role-based access * control mechanisms. This is a lightweight version that doesn't allow enumerating role * members except through off-chain means by accessing the contract event logs. Some * applications may benefit from on-chain enumerability, for those cases see * {AccessControlEnumerable}. * * Roles are referred to by their `bytes32` identifier. These should be exposed * in the external API and be unique. The best way to achieve this is by * using `public constant` hash digests: * * ```solidity * bytes32 public constant MY_ROLE = keccak256("MY_ROLE"); * ``` * * Roles can be used to represent a set of permissions. To restrict access to a * function call, use {hasRole}: * * ```solidity * function foo() public { * require(hasRole(MY_ROLE, msg.sender)); * ... * } * ``` * * Roles can be granted and revoked dynamically via the {grantRole} and * {revokeRole} functions. Each role has an associated admin role, and only * accounts that have a role's admin role can call {grantRole} and {revokeRole}. * * By default, the admin role for all roles is `DEFAULT_ADMIN_ROLE`, which means * that only accounts with this role will be able to grant or revoke other * roles. More complex role relationships can be created by using * {_setRoleAdmin}. * * WARNING: The `DEFAULT_ADMIN_ROLE` is also its own admin: it has permission to * grant and revoke this role. Extra precautions should be taken to secure * accounts that have been granted it. We recommend using {AccessControlDefaultAdminRules} * to enforce additional security measures for this role. */ abstract contract AccessControl is Context, IAccessControl, ERC165 { struct RoleData { mapping(address account => bool) hasRole; bytes32 adminRole; } mapping(bytes32 role => RoleData) private _roles; bytes32 public constant DEFAULT_ADMIN_ROLE = 0x00; /** * @dev Modifier that checks that an account has a specific role. Reverts * with an {AccessControlUnauthorizedAccount} error including the required role. */ modifier onlyRole(bytes32 role) { _checkRole(role); _; } /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { return interfaceId == type(IAccessControl).interfaceId || super.supportsInterface(interfaceId); } /** * @dev Returns `true` if `account` has been granted `role`. */ function hasRole(bytes32 role, address account) public view virtual returns (bool) { return _roles[role].hasRole[account]; } /** * @dev Reverts with an {AccessControlUnauthorizedAccount} error if `_msgSender()` * is missing `role`. Overriding this function changes the behavior of the {onlyRole} modifier. */ function _checkRole(bytes32 role) internal view virtual { _checkRole(role, _msgSender()); } /** * @dev Reverts with an {AccessControlUnauthorizedAccount} error if `account` * is missing `role`. */ function _checkRole(bytes32 role, address account) internal view virtual { if (!hasRole(role, account)) { revert AccessControlUnauthorizedAccount(account, role); } } /** * @dev Returns the admin role that controls `role`. See {grantRole} and * {revokeRole}. * * To change a role's admin, use {_setRoleAdmin}. */ function getRoleAdmin(bytes32 role) public view virtual returns (bytes32) { return _roles[role].adminRole; } /** * @dev Grants `role` to `account`. * * If `account` had not been already granted `role`, emits a {RoleGranted} * event. * * Requirements: * * - the caller must have ``role``'s admin role. * * May emit a {RoleGranted} event. */ function grantRole(bytes32 role, address account) public virtual onlyRole(getRoleAdmin(role)) { _grantRole(role, account); } /** * @dev Revokes `role` from `account`. * * If `account` had been granted `role`, emits a {RoleRevoked} event. * * Requirements: * * - the caller must have ``role``'s admin role. * * May emit a {RoleRevoked} event. */ function revokeRole(bytes32 role, address account) public virtual onlyRole(getRoleAdmin(role)) { _revokeRole(role, account); } /** * @dev Revokes `role` from the calling account. * * Roles are often managed via {grantRole} and {revokeRole}: this function's * purpose is to provide a mechanism for accounts to lose their privileges * if they are compromised (such as when a trusted device is misplaced). * * If the calling account had been revoked `role`, emits a {RoleRevoked} * event. * * Requirements: * * - the caller must be `callerConfirmation`. * * May emit a {RoleRevoked} event. */ function renounceRole(bytes32 role, address callerConfirmation) public virtual { if (callerConfirmation != _msgSender()) { revert AccessControlBadConfirmation(); } _revokeRole(role, callerConfirmation); } /** * @dev Sets `adminRole` as ``role``'s admin role. * * Emits a {RoleAdminChanged} event. */ function _setRoleAdmin(bytes32 role, bytes32 adminRole) internal virtual { bytes32 previousAdminRole = getRoleAdmin(role); _roles[role].adminRole = adminRole; emit RoleAdminChanged(role, previousAdminRole, adminRole); } /** * @dev Attempts to grant `role` to `account` and returns a boolean indicating if `role` was granted. * * Internal function without access restriction. * * May emit a {RoleGranted} event. */ function _grantRole(bytes32 role, address account) internal virtual returns (bool) { if (!hasRole(role, account)) { _roles[role].hasRole[account] = true; emit RoleGranted(role, account, _msgSender()); return true; } else { return false; } } /** * @dev Attempts to revoke `role` to `account` and returns a boolean indicating if `role` was revoked. * * Internal function without access restriction. * * May emit a {RoleRevoked} event. */ function _revokeRole(bytes32 role, address account) internal virtual returns (bool) { if (hasRole(role, account)) { _roles[role].hasRole[account] = false; emit RoleRevoked(role, account, _msgSender()); return true; } else { return false; } } }
// SPDX-License-Identifier: CC0 pragma solidity >=0.8.19; /// @dev Specification for flash lenders compatible with ERC-7399 interface IERC7399 { /// @dev The amount of currency available to be lent. /// @param asset The loan currency. /// @return The amount of `asset` that can be borrowed. function maxFlashLoan(address asset) external view returns (uint256); /// @dev The fee to be charged for a given loan. /// @param asset The loan currency. /// @param amount The amount of assets lent. /// @return The amount of `asset` to be charged for the loan, on top of the returned principal. function flashFee(address asset, uint256 amount) external view returns (uint256); /// @dev Initiate a flash loan. /// @param loanReceiver The address receiving the flash loan /// @param asset The asset to be loaned /// @param amount The amount to loaned /// @param data The ABI encoded user data /// @param callback The address and signature of the callback function /// @return result ABI encoded result of the callback function flash( address loanReceiver, address asset, uint256 amount, bytes calldata data, /// @dev callback. This is a combination of the callback receiver address, and the signature of callback /// function. It is encoded packed as 20 bytes + 4 bytes. /// @dev the return of the callback function is not encoded in the parameter, but must be `returns (bytes /// memory)` for compliance with the standard. /// @param initiator The address that called this function /// @param paymentReceiver The address that needs to receive the amount plus fee at the end of the callback /// @param asset The asset to be loaned /// @param amount The amount to loaned /// @param fee The fee to be paid /// @param data The ABI encoded data to be passed to the callback /// @return result ABI encoded result of the callback function(address, address, address, uint256, uint256, bytes memory) external returns (bytes memory) callback ) external returns (bytes memory); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.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 ERC20 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: MIT // OpenZeppelin Contracts (last updated v5.0.0) (token/ERC20/utils/SafeERC20.sol) pragma solidity ^0.8.20; import {IERC20} from "../IERC20.sol"; import {IERC20Permit} from "../extensions/IERC20Permit.sol"; import {Address} from "../../../utils/Address.sol"; /** * @title SafeERC20 * @dev Wrappers around ERC20 operations that throw on failure (when the token * contract returns false). Tokens that return no value (and instead revert or * throw on failure) are also supported, non-reverting calls are assumed to be * successful. * To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract, * which allows you to call the safe operations as `token.safeTransfer(...)`, etc. */ library SafeERC20 { using Address for address; /** * @dev An operation with an ERC20 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. */ 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. */ 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. */ 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 Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement * on the return value: the return value is optional (but if data is returned, it must not be false). * @param token The token targeted by the call. * @param data The call data (encoded using abi.encode or one of its variants). */ function _callOptionalReturn(IERC20 token, bytes memory data) private { // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since // we're implementing it ourselves. We use {Address-functionCall} to perform this call, which verifies that // the target address contains contract code and also asserts for success in the low-level call. bytes memory returndata = address(token).functionCall(data); if (returndata.length != 0 && !abi.decode(returndata, (bool))) { 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 silents catches all reverts and returns a bool instead. */ function _callOptionalReturnBool(IERC20 token, bytes memory data) private returns (bool) { // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since // we're implementing it ourselves. We cannot use {Address-functionCall} here since this should return false // and not revert is the subcall reverts. (bool success, bytes memory returndata) = address(token).call(data); return success && (returndata.length == 0 || abi.decode(returndata, (bool))) && address(token).code.length > 0; } }
// SPDX-License-Identifier: MIT // Thanks to ultrasecr.eth pragma solidity ^0.8.19; library FunctionCodec { function encodeParams(address contractAddr, bytes4 selector) internal pure returns (bytes24) { return bytes24(bytes20(contractAddr)) | bytes24(selector) >> 160; } function decodeParams(bytes24 encoded) internal pure returns (address contractAddr, bytes4 selector) { contractAddr = address(bytes20(encoded)); selector = bytes4(encoded << 160); } function encodeFunction( function(address, address, address, uint256, uint256, bytes memory) external returns (bytes memory) f ) internal pure returns (bytes24) { return encodeParams(f.address, f.selector); } function decodeFunction( address contractAddr, bytes4 selector ) internal pure returns (function(address, address, address, uint256, uint256, bytes memory) external returns (bytes memory) f) { uint32 s = uint32(selector); // solhint-disable-next-line no-inline-assembly assembly { f.address := contractAddr f.selector := s } } function decodeFunction(bytes24 encoded) internal pure returns (function(address, address, address, uint256, uint256, bytes memory) external returns (bytes memory) f) { (address contractAddr, bytes4 selector) = decodeParams(encoded); return decodeFunction(contractAddr, selector); } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (access/IAccessControl.sol) pragma solidity ^0.8.20; /** * @dev External interface of AccessControl declared to support ERC165 detection. */ interface IAccessControl { /** * @dev The `account` is missing a role. */ error AccessControlUnauthorizedAccount(address account, bytes32 neededRole); /** * @dev The caller of a function is not the expected one. * * NOTE: Don't confuse with {AccessControlUnauthorizedAccount}. */ error AccessControlBadConfirmation(); /** * @dev Emitted when `newAdminRole` is set as ``role``'s admin role, replacing `previousAdminRole` * * `DEFAULT_ADMIN_ROLE` is the starting admin for all roles, despite * {RoleAdminChanged} not being emitted signaling this. */ event RoleAdminChanged(bytes32 indexed role, bytes32 indexed previousAdminRole, bytes32 indexed newAdminRole); /** * @dev Emitted when `account` is granted `role`. * * `sender` is the account that originated the contract call, an admin role * bearer except when using {AccessControl-_setupRole}. */ event RoleGranted(bytes32 indexed role, address indexed account, address indexed sender); /** * @dev Emitted when `account` is revoked `role`. * * `sender` is the account that originated the contract call: * - if using `revokeRole`, it is the admin role bearer * - if using `renounceRole`, it is the role bearer (i.e. `account`) */ event RoleRevoked(bytes32 indexed role, address indexed account, address indexed sender); /** * @dev Returns `true` if `account` has been granted `role`. */ function hasRole(bytes32 role, address account) external view returns (bool); /** * @dev Returns the admin role that controls `role`. See {grantRole} and * {revokeRole}. * * To change a role's admin, use {AccessControl-_setRoleAdmin}. */ function getRoleAdmin(bytes32 role) external view returns (bytes32); /** * @dev Grants `role` to `account`. * * If `account` had not been already granted `role`, emits a {RoleGranted} * event. * * Requirements: * * - the caller must have ``role``'s admin role. */ function grantRole(bytes32 role, address account) external; /** * @dev Revokes `role` from `account`. * * If `account` had been granted `role`, emits a {RoleRevoked} event. * * Requirements: * * - the caller must have ``role``'s admin role. */ function revokeRole(bytes32 role, address account) external; /** * @dev Revokes `role` from the calling account. * * Roles are often managed via {grantRole} and {revokeRole}: this function's * purpose is to provide a mechanism for accounts to lose their privileges * if they are compromised (such as when a trusted device is misplaced). * * If the calling account had been granted `role`, emits a {RoleRevoked} * event. * * Requirements: * * - the caller must be `callerConfirmation`. */ function renounceRole(bytes32 role, address callerConfirmation) external; }
// 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: MIT // OpenZeppelin Contracts (last updated v5.0.0) (utils/introspection/ERC165.sol) pragma solidity ^0.8.20; import {IERC165} from "./IERC165.sol"; /** * @dev Implementation of the {IERC165} interface. * * Contracts that want to implement ERC165 should inherit from this contract and override {supportsInterface} to check * for the additional interface id that will be supported. For example: * * ```solidity * function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { * return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId); * } * ``` */ abstract contract ERC165 is IERC165 { /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual returns (bool) { return interfaceId == type(IERC165).interfaceId; } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (token/ERC20/IERC20.sol) pragma solidity ^0.8.20; /** * @dev Interface of the ERC20 standard as defined in the EIP. */ interface IERC20 { /** * @dev Emitted when `value` tokens are moved from one account (`from`) to * another (`to`). * * Note that `value` may be zero. */ event Transfer(address indexed from, address indexed to, uint256 value); /** * @dev Emitted when the allowance of a `spender` for an `owner` is set by * a call to {approve}. `value` is the new allowance. */ event Approval(address indexed owner, address indexed spender, uint256 value); /** * @dev Returns the 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.0.0) (token/ERC20/extensions/IERC20Permit.sol) pragma solidity ^0.8.20; /** * @dev Interface of the ERC20 Permit extension allowing approvals to be made via signatures, as defined in * https://eips.ethereum.org/EIPS/eip-2612[EIP-2612]. * * Adds the {permit} method, which can be used to change an account's ERC20 allowance (see {IERC20-allowance}) by * presenting a message signed by the account. By not relying on {IERC20-approve}, the token holder account doesn't * need to send a transaction, and thus is not required to hold Ether at all. * * ==== Security Considerations * * There are two important considerations concerning the use of `permit`. The first is that a valid permit signature * expresses an allowance, and it should not be assumed to convey additional meaning. In particular, it should not be * considered as an intention to spend the allowance in any specific way. The second is that because permits have * built-in replay protection and can be submitted by anyone, they can be frontrun. A protocol that uses permits should * take this into consideration and allow a `permit` call to fail. Combining these two aspects, a pattern that may be * generally recommended is: * * ```solidity * function doThingWithPermit(..., uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s) public { * try token.permit(msg.sender, address(this), value, deadline, v, r, s) {} catch {} * doThing(..., value); * } * * function doThing(..., uint256 value) public { * token.safeTransferFrom(msg.sender, address(this), value); * ... * } * ``` * * Observe that: 1) `msg.sender` is used as the owner, leaving no ambiguity as to the signer intent, and 2) the use of * `try/catch` allows the permit to fail and makes the code tolerant to frontrunning. (See also * {SafeERC20-safeTransferFrom}). * * Additionally, note that smart contract wallets (such as Argent or Safe) are not able to produce permit signatures, so * contracts should have entry points that don't rely on permit. */ interface IERC20Permit { /** * @dev Sets `value` as the allowance of `spender` over ``owner``'s tokens, * given ``owner``'s signed approval. * * IMPORTANT: The same issues {IERC20-approve} has related to transaction * ordering also apply here. * * Emits an {Approval} event. * * Requirements: * * - `spender` cannot be the zero address. * - `deadline` must be a timestamp in the future. * - `v`, `r` and `s` must be a valid `secp256k1` signature from `owner` * over the EIP712-formatted function arguments. * - the signature must use ``owner``'s current nonce (see {nonces}). * * For more information on the signature format, see the * https://eips.ethereum.org/EIPS/eip-2612#specification[relevant EIP * section]. * * CAUTION: See Security Considerations above. */ function permit( address owner, address spender, uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s ) external; /** * @dev Returns the current nonce for `owner`. This value must be * included whenever a signature is generated for {permit}. * * Every successful call to {permit} increases ``owner``'s nonce by one. This * prevents a signature from being used multiple times. */ function nonces(address owner) external view returns (uint256); /** * @dev Returns the domain separator used in the encoding of the signature for {permit}, as defined by {EIP712}. */ // solhint-disable-next-line func-name-mixedcase function DOMAIN_SEPARATOR() external view returns (bytes32); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (utils/Address.sol) pragma solidity ^0.8.20; /** * @dev Collection of functions related to the address type */ library Address { /** * @dev The ETH balance of the account is not enough to perform the operation. */ error AddressInsufficientBalance(address account); /** * @dev There's no code at `target` (it is not a contract). */ error AddressEmptyCode(address target); /** * @dev A call to an address target failed. The target may have reverted. */ error FailedInnerCall(); /** * @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 AddressInsufficientBalance(address(this)); } (bool success, ) = recipient.call{value: amount}(""); if (!success) { revert FailedInnerCall(); } } /** * @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 * {FailedInnerCall} 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 AddressInsufficientBalance(address(this)); } (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 {FailedInnerCall}) 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 {FailedInnerCall} 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 {FailedInnerCall}. */ 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 /// @solidity memory-safe-assembly assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert FailedInnerCall(); } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (utils/introspection/IERC165.sol) pragma solidity ^0.8.20; /** * @dev Interface of the ERC165 standard, as defined in the * https://eips.ethereum.org/EIPS/eip-165[EIP]. * * 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[EIP 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); }
{ "remappings": [ "forge-std/=lib/forge-std/src/", "erc7399/=lib/erc7399/src/", "@openzeppelin/contracts/=lib/openzeppelin-contracts/contracts/", "ds-test/=lib/forge-std/lib/ds-test/src/", "erc3156/=lib/erc3156/contracts/", "erc4626-tests/=lib/openzeppelin-contracts/lib/erc4626-tests/", "forge-gas-snapshot/=lib/forge-gas-snapshot/src/", "openzeppelin-contracts/=lib/openzeppelin-contracts/" ], "optimizer": { "enabled": true, "runs": 10000 }, "metadata": { "useLiteralContent": false, "bytecodeHash": "none", "appendCBOR": false }, "outputSelection": { "*": { "*": [ "evm.bytecode", "evm.deployedBytecode", "devdoc", "userdoc", "metadata", "abi" ] } }, "evmVersion": "london", "viaIR": false, "libraries": {} }
Contract Security Audit
- No Contract Security Audit Submitted- Submit Audit Here
[{"inputs":[{"internalType":"contract Registry","name":"reg","type":"address"},{"internalType":"string","name":"name","type":"string"}],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[{"internalType":"address","name":"target","type":"address"}],"name":"AddressEmptyCode","type":"error"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"AddressInsufficientBalance","type":"error"},{"inputs":[],"name":"FailedInnerCall","type":"error"},{"inputs":[],"name":"MathOverflowedMulDiv","type":"error"},{"inputs":[],"name":"NotInitiator","type":"error"},{"inputs":[],"name":"NotPool","type":"error"},{"inputs":[{"internalType":"address","name":"token","type":"address"}],"name":"SafeERC20FailedOperation","type":"error"},{"inputs":[],"name":"ADDRESSES_PROVIDER","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"LENDING_POOL","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"POOL","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"dataProvider","outputs":[{"internalType":"contract IPoolDataProvider","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address[]","name":"assets","type":"address[]"},{"internalType":"uint256[]","name":"amounts","type":"uint256[]"},{"internalType":"uint256[]","name":"fees","type":"uint256[]"},{"internalType":"address","name":"initiator","type":"address"},{"internalType":"bytes","name":"params","type":"bytes"}],"name":"executeOperation","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"loanReceiver","type":"address"},{"internalType":"address","name":"asset","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"bytes","name":"initiatorData","type":"bytes"},{"internalType":"function (address,address,address,uint256,uint256,bytes) external returns (bytes)","name":"callback","type":"function"}],"name":"flash","outputs":[{"internalType":"bytes","name":"result","type":"bytes"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"loanReceiver","type":"address"},{"internalType":"address","name":"asset","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"bytes","name":"initiatorData","type":"bytes"},{"internalType":"address","name":"callbackTarget","type":"address"},{"internalType":"bytes4","name":"callbackSelector","type":"bytes4"}],"name":"flash","outputs":[{"internalType":"bytes","name":"result","type":"bytes"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"asset","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"flashFee","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"isV2","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"asset","type":"address"}],"name":"maxFlashLoan","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"}]
Contract Creation Code
6101206040523480156200001257600080fd5b50604051620022d1380380620022d18339810160408190526200003591620001e1565b6000826001600160a01b031663375eb9ed836040516020016200005991906200024c565b6040516020818303038152906040526040518263ffffffff1660e01b815260040162000086919062000279565b600060405180830381865afa158015620000a4573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052620000ce9190810190620002ae565b806020019051810190620000e3919062000303565b1515610100526001600160a01b0390811660e0529081166080521660a081905260c052506200036f915050565b6001600160a01b03811681146200012657600080fd5b50565b634e487b7160e01b600052604160045260246000fd5b60005b838110156200015c57818101518382015260200162000142565b50506000910152565b60006001600160401b038084111562000182576200018262000129565b604051601f8501601f19908116603f01168101908282118183101715620001ad57620001ad62000129565b81604052809350858152868686011115620001c757600080fd5b620001d78660208301876200013f565b5050509392505050565b60008060408385031215620001f557600080fd5b8251620002028162000110565b60208401519092506001600160401b038111156200021f57600080fd5b8301601f810185136200023157600080fd5b620002428582516020840162000165565b9150509250929050565b60008251620002608184602087016200013f565b662bb930b83832b960c91b920191825250600701919050565b60208152600082518060208401526200029a8160408501602087016200013f565b601f01601f19169190910160400192915050565b600060208284031215620002c157600080fd5b81516001600160401b03811115620002d857600080fd5b8201601f81018413620002ea57600080fd5b620002fb8482516020840162000165565b949350505050565b600080600080608085870312156200031a57600080fd5b8451620003278162000110565b60208601519094506200033a8162000110565b60408601519093506200034d8162000110565b606086015190925080151581146200036457600080fd5b939692955090935050565b60805160a05160c05160e05161010051611eed620003e460003960008181610119015261080c0152600081816101de015281816106d2015281816107500152610874015260006102050152600081816101910152818161031301528181610aaa0152610b6b0152600060c80152611eed6000f3fe608060405234801561001057600080fd5b50600436106100be5760003560e01c8063920f5c8411610076578063b334ed861161005b578063b334ed86146101d9578063b4dcfc7714610200578063d9d98ce41461022757600080fd5b8063920f5c84146101b3578063af2511c0146101c657600080fd5b806340a08f10116100a757806340a08f101461014b578063613255ab1461016b5780637535d2461461018c57600080fd5b80630542975c146100c35780632d94a2d014610114575b600080fd5b6100ea7f000000000000000000000000000000000000000000000000000000000000000081565b60405173ffffffffffffffffffffffffffffffffffffffff90911681526020015b60405180910390f35b61013b7f000000000000000000000000000000000000000000000000000000000000000081565b604051901515815260200161010b565b61015e6101593660046113a0565b61023a565b60405161010b91906114a6565b61017e6101793660046114b9565b6102e8565b60405190815260200161010b565b6100ea7f000000000000000000000000000000000000000000000000000000000000000081565b61013b6101c136600461151b565b6102f9565b61015e6101d43660046115f6565b610464565b6100ea7f000000000000000000000000000000000000000000000000000000000000000081565b6100ea7f000000000000000000000000000000000000000000000000000000000000000081565b61017e6102353660046116b4565b6104f4565b6060600060405180608001604052808a73ffffffffffffffffffffffffffffffffffffffff1681526020013373ffffffffffffffffffffffffffffffffffffffff168152602001858563ffffffff169060201b1760401b815260200187878080601f016020809104026020016040519081016040528093929190818152602001838380828437600092019190915250505091525090506102db8888836105b1565b9998505050505050505050565b60006102f382610686565b92915050565b60003373ffffffffffffffffffffffffffffffffffffffff7f0000000000000000000000000000000000000000000000000000000000000000161461036a576040517f6f61f64100000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b73ffffffffffffffffffffffffffffffffffffffff841630146103b9576040517f42b5e35a00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6104548a8a60008181106103cf576103cf6116e0565b90506020020160208101906103e491906114b9565b898960008181106103f7576103f76116e0565b9050602002013588886000818110610411576104116116e0565b9050602002013586868080601f0160208091040260200160405190810160405280939291908181526020018383808284376000920191909152506109a292505050565b5060019998505050505050505050565b6040805160808101825273ffffffffffffffffffffffffffffffffffffffff891681523360208201526060916000919081018560e086901c63ffffffff169060201b1760401b815260200187878080601f016020809104026020016040519081016040528093929190818152602001838380828437600092019190915250505091525090506102db8888836105b1565b60008061050084610686565b905060008111610571576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601460248201527f556e737570706f727465642063757272656e637900000000000000000000000060448201526064015b60405180910390fd5b808310156105875761058283610aa2565b6105a9565b7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff5b949350505050565b60606105dd8484846040516020016105c9919061170f565b604051602081830303815290604052610b69565b600080546105ea90611784565b80601f016020809104026020016040519081016040528092919081815260200182805461061690611784565b80156106635780601f1061063857610100808354040283529160200191610663565b820191906000526020600020905b81548152906001019060200180831161064657829003601f168201915b5050505050905060008151111561067f5761067f6000806112b9565b9392505050565b6040517f3e15014100000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff8281166004830152600091829182917f000000000000000000000000000000000000000000000000000000000000000090911690633e1501419060240161014060405180830381865afa15801561071c573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061074091906117ec565b99509950505050505050505060007f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff1663d2493b6c866040518263ffffffff1660e01b81526004016107c3919073ffffffffffffffffffffffffffffffffffffffff91909116815260200190565b606060405180830381865afa1580156107e0573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906108049190611883565b5050905060007f00000000000000000000000000000000000000000000000000000000000000006108e4576040517fd7ed3ef400000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff87811660048301527f0000000000000000000000000000000000000000000000000000000000000000169063d7ed3ef490602401602060405180830381865afa1580156108bb573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906108df91906118d0565b6108e7565b60015b9050821580156108f45750835b80156108fd5750805b610908576000610998565b6040517f70a0823100000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff83811660048301528716906370a0823190602401602060405180830381865afa158015610974573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061099891906118eb565b9695505050505050565b6000818060200190518101906109b891906119cf565b90506109c985858360000151610c2c565b600081604001518060601c9060401c63ffffffff1683602001516109ea3090565b89898988606001516040518763ffffffff1660e01b8152600401610a1396959493929190611a8b565b6000604051808303816000875af1158015610a32573d6000803e3d6000fd5b505050506040513d6000823e601f3d9081017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0168201604052610a789190810190611ae4565b9050610a85868686610c52565b805115610a9a576000610a988282611b61565b505b505050505050565b60006102f3827f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff1663074b2e436040518163ffffffff1660e01b8152600401602060405180830381865afa158015610b13573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610b379190611c7b565b610b4790655af3107a4000611cdc565b6fffffffffffffffffffffffffffffffff16670de0b6b3a76400006001610c7e565b7f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff1663ab9c4b5d30610bc58673ffffffffffffffffffffffffffffffffffffffff16610ccf565b610bce86610d44565b610bd86000610d44565b308760006040518863ffffffff1660e01b8152600401610bfe9796959493929190611d4c565b600060405180830381600087803b158015610c1857600080fd5b505af1158015610a98573d6000803e3d6000fd5b610c4d73ffffffffffffffffffffffffffffffffffffffff84168284610d8b565b505050565b610c4d33610c608385611e17565b73ffffffffffffffffffffffffffffffffffffffff86169190610e0c565b600080610c8c868686610eea565b9050610c9783610fe5565b8015610cb3575060008480610cae57610cae611e2a565b868809115b15610cc657610cc3600182611e17565b90505b95945050505050565b604080516001808252818301909252606091602080830190803683370190505090508181600081518110610d0557610d056116e0565b602002602001019073ffffffffffffffffffffffffffffffffffffffff16908173ffffffffffffffffffffffffffffffffffffffff1681525050919050565b604080516001808252818301909252606091602080830190803683370190505090508181600081518110610d7a57610d7a6116e0565b602002602001018181525050919050565b60405173ffffffffffffffffffffffffffffffffffffffff838116602483015260448201839052610c4d91859182169063a9059cbb906064015b604051602081830303815290604052915060e01b6020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff8381831617835250505050611012565b6040805173ffffffffffffffffffffffffffffffffffffffff8416602482015260448082018490528251808303909101815260649091019091526020810180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167f095ea7b300000000000000000000000000000000000000000000000000000000179052610e9884826110a8565b610ee45760405173ffffffffffffffffffffffffffffffffffffffff848116602483015260006044830152610eda91869182169063095ea7b390606401610dc5565b610ee48482611012565b50505050565b6000838302817fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8587098281108382030391505080600003610f3f57838281610f3557610f35611e2a565b049250505061067f565b808411610f78576040517f227bc15300000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6000848688096000868103871696879004966002600389028118808a02820302808a02820302808a02820302808a02820302808a02820302808a02909103029181900381900460010186841190950394909402919094039290920491909117919091029150509392505050565b60006002826003811115610ffb57610ffb611e59565b6110059190611e88565b60ff166001149050919050565b600061103473ffffffffffffffffffffffffffffffffffffffff841683611165565b9050805160001415801561105957508080602001905181019061105791906118d0565b155b15610c4d576040517f5274afe700000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff84166004820152602401610568565b60008060008473ffffffffffffffffffffffffffffffffffffffff16846040516110d29190611ed1565b6000604051808303816000865af19150503d806000811461110f576040519150601f19603f3d011682016040523d82523d6000602084013e611114565b606091505b509150915081801561113e57508051158061113e57508080602001905181019061113e91906118d0565b8015610cc657505050505073ffffffffffffffffffffffffffffffffffffffff163b151590565b606061067f83836000846000808573ffffffffffffffffffffffffffffffffffffffff1684866040516111989190611ed1565b60006040518083038185875af1925050503d80600081146111d5576040519150601f19603f3d011682016040523d82523d6000602084013e6111da565b606091505b50915091506109988683836060826111fa576111f582611274565b61067f565b815115801561121e575073ffffffffffffffffffffffffffffffffffffffff84163b155b1561126d576040517f9996b31500000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff85166004820152602401610568565b508061067f565b8051156112845780518082602001fd5b6040517f1425ea4200000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b50565b5080546112c590611784565b6000825580601f106112d5575050565b601f0160209004906000526020600020908101906112b691905b8082111561130357600081556001016112ef565b5090565b73ffffffffffffffffffffffffffffffffffffffff811681146112b657600080fd5b60008083601f84011261133b57600080fd5b50813567ffffffffffffffff81111561135357600080fd5b60208301915083602082850101111561136b57600080fd5b9250929050565b7fffffffffffffffffffffffffffffffffffffffffffffffff0000000000000000811681146112b657600080fd5b600080600080600080600060a0888a0312156113bb57600080fd5b87356113c681611307565b965060208801356113d681611307565b955060408801359450606088013567ffffffffffffffff8111156113f957600080fd5b6114058a828b01611329565b909550935050608088013561141981611372565b8060601c925063ffffffff8160401c1691505092959891949750929550565b60005b8381101561145357818101518382015260200161143b565b50506000910152565b60008151808452611474816020860160208601611438565b601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0169290920160200192915050565b60208152600061067f602083018461145c565b6000602082840312156114cb57600080fd5b813561067f81611307565b60008083601f8401126114e857600080fd5b50813567ffffffffffffffff81111561150057600080fd5b6020830191508360208260051b850101111561136b57600080fd5b600080600080600080600080600060a08a8c03121561153957600080fd5b893567ffffffffffffffff8082111561155157600080fd5b61155d8d838e016114d6565b909b50995060208c013591508082111561157657600080fd5b6115828d838e016114d6565b909950975060408c013591508082111561159b57600080fd5b6115a78d838e016114d6565b909750955060608c013591506115bc82611307565b90935060808b013590808211156115d257600080fd5b506115df8c828d01611329565b915080935050809150509295985092959850929598565b600080600080600080600060c0888a03121561161157600080fd5b873561161c81611307565b9650602088013561162c81611307565b955060408801359450606088013567ffffffffffffffff81111561164f57600080fd5b61165b8a828b01611329565b909550935050608088013561166f81611307565b915060a08801357fffffffff00000000000000000000000000000000000000000000000000000000811681146116a457600080fd5b8091505092959891949750929550565b600080604083850312156116c757600080fd5b82356116d281611307565b946020939093013593505050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b60208152600073ffffffffffffffffffffffffffffffffffffffff808451166020840152806020850151166040840152507fffffffffffffffffffffffffffffffffffffffffffffffff0000000000000000604084015116606083015260608301516080808401526105a960a084018261145c565b600181811c9082168061179857607f821691505b6020821081036117d1577f4e487b7100000000000000000000000000000000000000000000000000000000600052602260045260246000fd5b50919050565b805180151581146117e757600080fd5b919050565b6000806000806000806000806000806101408b8d03121561180c57600080fd5b8a51995060208b0151985060408b0151975060608b0151965060808b0151955061183860a08c016117d7565b945061184660c08c016117d7565b935061185460e08c016117d7565b92506118636101008c016117d7565b91506118726101208c016117d7565b90509295989b9194979a5092959850565b60008060006060848603121561189857600080fd5b83516118a381611307565b60208501519093506118b481611307565b60408501519092506118c581611307565b809150509250925092565b6000602082840312156118e257600080fd5b61067f826117d7565b6000602082840312156118fd57600080fd5b5051919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b600082601f83011261194457600080fd5b815167ffffffffffffffff8082111561195f5761195f611904565b604051601f83017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0908116603f011681019082821181831017156119a5576119a5611904565b816040528381528660208588010111156119be57600080fd5b610998846020830160208901611438565b6000602082840312156119e157600080fd5b815167ffffffffffffffff808211156119f957600080fd5b9083019060808286031215611a0d57600080fd5b604051608081018181108382111715611a2857611a28611904565b6040528251611a3681611307565b81526020830151611a4681611307565b60208201526040830151611a5981611372565b6040820152606083015182811115611a7057600080fd5b611a7c87828601611933565b60608301525095945050505050565b600073ffffffffffffffffffffffffffffffffffffffff8089168352808816602084015280871660408401525084606083015283608083015260c060a0830152611ad860c083018461145c565b98975050505050505050565b600060208284031215611af657600080fd5b815167ffffffffffffffff811115611b0d57600080fd5b6105a984828501611933565b601f821115610c4d576000816000526020600020601f850160051c81016020861015611b425750805b601f850160051c820191505b81811015610a9a57828155600101611b4e565b815167ffffffffffffffff811115611b7b57611b7b611904565b611b8f81611b898454611784565b84611b19565b602080601f831160018114611be25760008415611bac5750858301515b7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff600386901b1c1916600185901b178555610a9a565b6000858152602081207fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe08616915b82811015611c2f57888601518255948401946001909101908401611c10565b5085821015611c6b57878501517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff600388901b60f8161c191681555b5050505050600190811b01905550565b600060208284031215611c8d57600080fd5b81516fffffffffffffffffffffffffffffffff8116811461067f57600080fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b6fffffffffffffffffffffffffffffffff818116838216028082169190828114611d0857611d08611cad565b505092915050565b60008151808452602080850194506020840160005b83811015611d4157815187529582019590820190600101611d25565b509495945050505050565b600060e0820173ffffffffffffffffffffffffffffffffffffffff808b168452602060e06020860152828b518085526101008701915060208d01945060005b81811015611da9578551851683529483019491830191600101611d8b565b50508581036040870152611dbd818c611d10565b93505050508281036060840152611dd48188611d10565b73ffffffffffffffffffffffffffffffffffffffff87166080850152905082810360a0840152611e04818661145c565b915050611ad860c083018461ffff169052565b808201808211156102f3576102f3611cad565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052602160045260246000fd5b600060ff831680611ec2577f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b8060ff84160691505092915050565b60008251611ee3818460208701611438565b919091019291505056000000000000000000000000a348320114210b8f4eaf1b0795aa8f70803a93ea0000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000000b5a65726f4c656e64425443000000000000000000000000000000000000000000
Deployed Bytecode
0x608060405234801561001057600080fd5b50600436106100be5760003560e01c8063920f5c8411610076578063b334ed861161005b578063b334ed86146101d9578063b4dcfc7714610200578063d9d98ce41461022757600080fd5b8063920f5c84146101b3578063af2511c0146101c657600080fd5b806340a08f10116100a757806340a08f101461014b578063613255ab1461016b5780637535d2461461018c57600080fd5b80630542975c146100c35780632d94a2d014610114575b600080fd5b6100ea7f00000000000000000000000017878afdd5772f4ec93c265ac7ad8e2b29abb85781565b60405173ffffffffffffffffffffffffffffffffffffffff90911681526020015b60405180910390f35b61013b7f000000000000000000000000000000000000000000000000000000000000000081565b604051901515815260200161010b565b61015e6101593660046113a0565b61023a565b60405161010b91906114a6565b61017e6101793660046114b9565b6102e8565b60405190815260200161010b565b6100ea7f000000000000000000000000cd2b31071119d7ea449a9d211ac8ebf7ee97f98781565b61013b6101c136600461151b565b6102f9565b61015e6101d43660046115f6565b610464565b6100ea7f00000000000000000000000031063f7ca8ef4089db0dedf8d6e35690b468a61181565b6100ea7f000000000000000000000000cd2b31071119d7ea449a9d211ac8ebf7ee97f98781565b61017e6102353660046116b4565b6104f4565b6060600060405180608001604052808a73ffffffffffffffffffffffffffffffffffffffff1681526020013373ffffffffffffffffffffffffffffffffffffffff168152602001858563ffffffff169060201b1760401b815260200187878080601f016020809104026020016040519081016040528093929190818152602001838380828437600092019190915250505091525090506102db8888836105b1565b9998505050505050505050565b60006102f382610686565b92915050565b60003373ffffffffffffffffffffffffffffffffffffffff7f000000000000000000000000cd2b31071119d7ea449a9d211ac8ebf7ee97f987161461036a576040517f6f61f64100000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b73ffffffffffffffffffffffffffffffffffffffff841630146103b9576040517f42b5e35a00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6104548a8a60008181106103cf576103cf6116e0565b90506020020160208101906103e491906114b9565b898960008181106103f7576103f76116e0565b9050602002013588886000818110610411576104116116e0565b9050602002013586868080601f0160208091040260200160405190810160405280939291908181526020018383808284376000920191909152506109a292505050565b5060019998505050505050505050565b6040805160808101825273ffffffffffffffffffffffffffffffffffffffff891681523360208201526060916000919081018560e086901c63ffffffff169060201b1760401b815260200187878080601f016020809104026020016040519081016040528093929190818152602001838380828437600092019190915250505091525090506102db8888836105b1565b60008061050084610686565b905060008111610571576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601460248201527f556e737570706f727465642063757272656e637900000000000000000000000060448201526064015b60405180910390fd5b808310156105875761058283610aa2565b6105a9565b7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff5b949350505050565b60606105dd8484846040516020016105c9919061170f565b604051602081830303815290604052610b69565b600080546105ea90611784565b80601f016020809104026020016040519081016040528092919081815260200182805461061690611784565b80156106635780601f1061063857610100808354040283529160200191610663565b820191906000526020600020905b81548152906001019060200180831161064657829003601f168201915b5050505050905060008151111561067f5761067f6000806112b9565b9392505050565b6040517f3e15014100000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff8281166004830152600091829182917f00000000000000000000000031063f7ca8ef4089db0dedf8d6e35690b468a61190911690633e1501419060240161014060405180830381865afa15801561071c573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061074091906117ec565b99509950505050505050505060007f00000000000000000000000031063f7ca8ef4089db0dedf8d6e35690b468a61173ffffffffffffffffffffffffffffffffffffffff1663d2493b6c866040518263ffffffff1660e01b81526004016107c3919073ffffffffffffffffffffffffffffffffffffffff91909116815260200190565b606060405180830381865afa1580156107e0573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906108049190611883565b5050905060007f00000000000000000000000000000000000000000000000000000000000000006108e4576040517fd7ed3ef400000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff87811660048301527f00000000000000000000000031063f7ca8ef4089db0dedf8d6e35690b468a611169063d7ed3ef490602401602060405180830381865afa1580156108bb573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906108df91906118d0565b6108e7565b60015b9050821580156108f45750835b80156108fd5750805b610908576000610998565b6040517f70a0823100000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff83811660048301528716906370a0823190602401602060405180830381865afa158015610974573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061099891906118eb565b9695505050505050565b6000818060200190518101906109b891906119cf565b90506109c985858360000151610c2c565b600081604001518060601c9060401c63ffffffff1683602001516109ea3090565b89898988606001516040518763ffffffff1660e01b8152600401610a1396959493929190611a8b565b6000604051808303816000875af1158015610a32573d6000803e3d6000fd5b505050506040513d6000823e601f3d9081017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0168201604052610a789190810190611ae4565b9050610a85868686610c52565b805115610a9a576000610a988282611b61565b505b505050505050565b60006102f3827f000000000000000000000000cd2b31071119d7ea449a9d211ac8ebf7ee97f98773ffffffffffffffffffffffffffffffffffffffff1663074b2e436040518163ffffffff1660e01b8152600401602060405180830381865afa158015610b13573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610b379190611c7b565b610b4790655af3107a4000611cdc565b6fffffffffffffffffffffffffffffffff16670de0b6b3a76400006001610c7e565b7f000000000000000000000000cd2b31071119d7ea449a9d211ac8ebf7ee97f98773ffffffffffffffffffffffffffffffffffffffff1663ab9c4b5d30610bc58673ffffffffffffffffffffffffffffffffffffffff16610ccf565b610bce86610d44565b610bd86000610d44565b308760006040518863ffffffff1660e01b8152600401610bfe9796959493929190611d4c565b600060405180830381600087803b158015610c1857600080fd5b505af1158015610a98573d6000803e3d6000fd5b610c4d73ffffffffffffffffffffffffffffffffffffffff84168284610d8b565b505050565b610c4d33610c608385611e17565b73ffffffffffffffffffffffffffffffffffffffff86169190610e0c565b600080610c8c868686610eea565b9050610c9783610fe5565b8015610cb3575060008480610cae57610cae611e2a565b868809115b15610cc657610cc3600182611e17565b90505b95945050505050565b604080516001808252818301909252606091602080830190803683370190505090508181600081518110610d0557610d056116e0565b602002602001019073ffffffffffffffffffffffffffffffffffffffff16908173ffffffffffffffffffffffffffffffffffffffff1681525050919050565b604080516001808252818301909252606091602080830190803683370190505090508181600081518110610d7a57610d7a6116e0565b602002602001018181525050919050565b60405173ffffffffffffffffffffffffffffffffffffffff838116602483015260448201839052610c4d91859182169063a9059cbb906064015b604051602081830303815290604052915060e01b6020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff8381831617835250505050611012565b6040805173ffffffffffffffffffffffffffffffffffffffff8416602482015260448082018490528251808303909101815260649091019091526020810180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167f095ea7b300000000000000000000000000000000000000000000000000000000179052610e9884826110a8565b610ee45760405173ffffffffffffffffffffffffffffffffffffffff848116602483015260006044830152610eda91869182169063095ea7b390606401610dc5565b610ee48482611012565b50505050565b6000838302817fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8587098281108382030391505080600003610f3f57838281610f3557610f35611e2a565b049250505061067f565b808411610f78576040517f227bc15300000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6000848688096000868103871696879004966002600389028118808a02820302808a02820302808a02820302808a02820302808a02820302808a02909103029181900381900460010186841190950394909402919094039290920491909117919091029150509392505050565b60006002826003811115610ffb57610ffb611e59565b6110059190611e88565b60ff166001149050919050565b600061103473ffffffffffffffffffffffffffffffffffffffff841683611165565b9050805160001415801561105957508080602001905181019061105791906118d0565b155b15610c4d576040517f5274afe700000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff84166004820152602401610568565b60008060008473ffffffffffffffffffffffffffffffffffffffff16846040516110d29190611ed1565b6000604051808303816000865af19150503d806000811461110f576040519150601f19603f3d011682016040523d82523d6000602084013e611114565b606091505b509150915081801561113e57508051158061113e57508080602001905181019061113e91906118d0565b8015610cc657505050505073ffffffffffffffffffffffffffffffffffffffff163b151590565b606061067f83836000846000808573ffffffffffffffffffffffffffffffffffffffff1684866040516111989190611ed1565b60006040518083038185875af1925050503d80600081146111d5576040519150601f19603f3d011682016040523d82523d6000602084013e6111da565b606091505b50915091506109988683836060826111fa576111f582611274565b61067f565b815115801561121e575073ffffffffffffffffffffffffffffffffffffffff84163b155b1561126d576040517f9996b31500000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff85166004820152602401610568565b508061067f565b8051156112845780518082602001fd5b6040517f1425ea4200000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b50565b5080546112c590611784565b6000825580601f106112d5575050565b601f0160209004906000526020600020908101906112b691905b8082111561130357600081556001016112ef565b5090565b73ffffffffffffffffffffffffffffffffffffffff811681146112b657600080fd5b60008083601f84011261133b57600080fd5b50813567ffffffffffffffff81111561135357600080fd5b60208301915083602082850101111561136b57600080fd5b9250929050565b7fffffffffffffffffffffffffffffffffffffffffffffffff0000000000000000811681146112b657600080fd5b600080600080600080600060a0888a0312156113bb57600080fd5b87356113c681611307565b965060208801356113d681611307565b955060408801359450606088013567ffffffffffffffff8111156113f957600080fd5b6114058a828b01611329565b909550935050608088013561141981611372565b8060601c925063ffffffff8160401c1691505092959891949750929550565b60005b8381101561145357818101518382015260200161143b565b50506000910152565b60008151808452611474816020860160208601611438565b601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0169290920160200192915050565b60208152600061067f602083018461145c565b6000602082840312156114cb57600080fd5b813561067f81611307565b60008083601f8401126114e857600080fd5b50813567ffffffffffffffff81111561150057600080fd5b6020830191508360208260051b850101111561136b57600080fd5b600080600080600080600080600060a08a8c03121561153957600080fd5b893567ffffffffffffffff8082111561155157600080fd5b61155d8d838e016114d6565b909b50995060208c013591508082111561157657600080fd5b6115828d838e016114d6565b909950975060408c013591508082111561159b57600080fd5b6115a78d838e016114d6565b909750955060608c013591506115bc82611307565b90935060808b013590808211156115d257600080fd5b506115df8c828d01611329565b915080935050809150509295985092959850929598565b600080600080600080600060c0888a03121561161157600080fd5b873561161c81611307565b9650602088013561162c81611307565b955060408801359450606088013567ffffffffffffffff81111561164f57600080fd5b61165b8a828b01611329565b909550935050608088013561166f81611307565b915060a08801357fffffffff00000000000000000000000000000000000000000000000000000000811681146116a457600080fd5b8091505092959891949750929550565b600080604083850312156116c757600080fd5b82356116d281611307565b946020939093013593505050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b60208152600073ffffffffffffffffffffffffffffffffffffffff808451166020840152806020850151166040840152507fffffffffffffffffffffffffffffffffffffffffffffffff0000000000000000604084015116606083015260608301516080808401526105a960a084018261145c565b600181811c9082168061179857607f821691505b6020821081036117d1577f4e487b7100000000000000000000000000000000000000000000000000000000600052602260045260246000fd5b50919050565b805180151581146117e757600080fd5b919050565b6000806000806000806000806000806101408b8d03121561180c57600080fd5b8a51995060208b0151985060408b0151975060608b0151965060808b0151955061183860a08c016117d7565b945061184660c08c016117d7565b935061185460e08c016117d7565b92506118636101008c016117d7565b91506118726101208c016117d7565b90509295989b9194979a5092959850565b60008060006060848603121561189857600080fd5b83516118a381611307565b60208501519093506118b481611307565b60408501519092506118c581611307565b809150509250925092565b6000602082840312156118e257600080fd5b61067f826117d7565b6000602082840312156118fd57600080fd5b5051919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b600082601f83011261194457600080fd5b815167ffffffffffffffff8082111561195f5761195f611904565b604051601f83017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0908116603f011681019082821181831017156119a5576119a5611904565b816040528381528660208588010111156119be57600080fd5b610998846020830160208901611438565b6000602082840312156119e157600080fd5b815167ffffffffffffffff808211156119f957600080fd5b9083019060808286031215611a0d57600080fd5b604051608081018181108382111715611a2857611a28611904565b6040528251611a3681611307565b81526020830151611a4681611307565b60208201526040830151611a5981611372565b6040820152606083015182811115611a7057600080fd5b611a7c87828601611933565b60608301525095945050505050565b600073ffffffffffffffffffffffffffffffffffffffff8089168352808816602084015280871660408401525084606083015283608083015260c060a0830152611ad860c083018461145c565b98975050505050505050565b600060208284031215611af657600080fd5b815167ffffffffffffffff811115611b0d57600080fd5b6105a984828501611933565b601f821115610c4d576000816000526020600020601f850160051c81016020861015611b425750805b601f850160051c820191505b81811015610a9a57828155600101611b4e565b815167ffffffffffffffff811115611b7b57611b7b611904565b611b8f81611b898454611784565b84611b19565b602080601f831160018114611be25760008415611bac5750858301515b7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff600386901b1c1916600185901b178555610a9a565b6000858152602081207fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe08616915b82811015611c2f57888601518255948401946001909101908401611c10565b5085821015611c6b57878501517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff600388901b60f8161c191681555b5050505050600190811b01905550565b600060208284031215611c8d57600080fd5b81516fffffffffffffffffffffffffffffffff8116811461067f57600080fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b6fffffffffffffffffffffffffffffffff818116838216028082169190828114611d0857611d08611cad565b505092915050565b60008151808452602080850194506020840160005b83811015611d4157815187529582019590820190600101611d25565b509495945050505050565b600060e0820173ffffffffffffffffffffffffffffffffffffffff808b168452602060e06020860152828b518085526101008701915060208d01945060005b81811015611da9578551851683529483019491830191600101611d8b565b50508581036040870152611dbd818c611d10565b93505050508281036060840152611dd48188611d10565b73ffffffffffffffffffffffffffffffffffffffff87166080850152905082810360a0840152611e04818661145c565b915050611ad860c083018461ffff169052565b808201808211156102f3576102f3611cad565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052602160045260246000fd5b600060ff831680611ec2577f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b8060ff84160691505092915050565b60008251611ee3818460208701611438565b919091019291505056
Constructor Arguments (ABI-Encoded and is the last bytes of the Contract Creation Code above)
000000000000000000000000a348320114210b8f4eaf1b0795aa8f70803a93ea0000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000000b5a65726f4c656e64425443000000000000000000000000000000000000000000
-----Encoded View---------------
4 Constructor Arguments found :
Arg [0] : 000000000000000000000000a348320114210b8f4eaf1b0795aa8f70803a93ea
Arg [1] : 0000000000000000000000000000000000000000000000000000000000000040
Arg [2] : 000000000000000000000000000000000000000000000000000000000000000b
Arg [3] : 5a65726f4c656e64425443000000000000000000000000000000000000000000
Loading...
Loading
Loading...
Loading
Multichain Portfolio | 30 Chains
Chain | Token | Portfolio % | Price | Amount | Value |
---|
Loading...
Loading
[ Download: CSV Export ]
A contract address hosts a smart contract, which is a set of code stored on the blockchain that runs when predetermined conditions are met. Learn more about addresses in our Knowledge Base.