Overview
S Balance
0 S
S Value
-More Info
Private Name Tags
ContractCreator
Loading...
Loading
Contract Source Code Verified (Exact Match)
Contract Name:
FlashLoanAggregator
Compiler Version
v0.8.23+commit.f704f362
Optimization Enabled:
Yes with 999 runs
Other Settings:
paris EvmVersion
Contract Source Code (Solidity Standard Json-Input format)
// SPDX-License-Identifier: GPL-2.0-or-later pragma solidity 0.8.23; import "@openzeppelin/contracts/access/Ownable.sol"; import { IERC20 } from "@openzeppelin/contracts/token/ERC20/IERC20.sol"; import "./interfaces/IFlashLoanAggregator.sol"; import "./interfaces/IWagmiLeverageFlashCallback.sol"; import "./interfaces/IUniswapV3FlashCallback.sol"; import "./interfaces/abstract/ILiquidityManager.sol"; import "./interfaces/IUniswapV3Pool.sol"; import "@aave/core-v3/contracts/protocol/libraries/configuration/ReserveConfiguration.sol"; import { DataTypes } from "@aave/core-v3/contracts/protocol/libraries/types/DataTypes.sol"; import { TransferHelper } from "./libraries/TransferHelper.sol"; import { IFlashLoanSimpleReceiver } from "@aave/core-v3/contracts/flashloan/interfaces/IFlashLoanSimpleReceiver.sol"; import { IPoolAddressesProvider } from "@aave/core-v3/contracts/interfaces/IPoolAddressesProvider.sol"; import { IPool } from "@aave/core-v3/contracts/interfaces/IPool.sol"; // import "hardhat/console.sol"; /** * @title FlashLoanAggregator * @dev This contract serves as an aggregator for flash loans from different protocols. * It defines various data structures and modifiers used in the contract. */ contract FlashLoanAggregator is Ownable, IFlashLoanAggregator, IFlashLoanSimpleReceiver, IUniswapV3FlashCallback { using TransferHelper for address; using ReserveConfiguration for DataTypes.ReserveConfigurationMap; enum Protocol { UNKNOWN, UNISWAP, AAVE } struct Debt { Protocol protocol; address creditor; uint256 body; uint256 interest; } struct UniswapV3Identifier { bool enabled; address factoryV3; bytes32 initCodeHash; string name; } struct CallbackDataExt { address recipient; uint256 currentIndex; uint256 amount; uint256 prevBalance; Debt[] debts; bytes originData; } uint256 public constant version = 1.0; IPoolAddressesProvider public override ADDRESSES_PROVIDER; IPool public override POOL; UniswapV3Identifier[] public uniswapV3Dexes; mapping(bytes32 => bool) public uniswapDexIsExists; mapping(address => bool) public wagmiLeverageContracts; /** * @dev Modifier to restrict access to only contracts registered as Wagmi Leverage contracts. */ modifier onlyWagmiLeverage() { require(wagmiLeverageContracts[msg.sender], "IC"); _; } /** * @dev Modifier to check if the provided index is within the range of the uniswapV3Dexes array. * @param indx The index to check. */ modifier correctIndx(uint256 indx) { require(uniswapV3Dexes.length > indx, "II"); _; } event UniswapV3DexAdded(address factoryV3, bytes32 initCodeHash, string name); event UniswapV3DexChanged(address factoryV3, bytes32 initCodeHash, string name); error CollectedAmountIsNotEnough(uint256 desiredAmount, uint256 collectedAmount); error FlashLoanZeroLiquidity(address pool); error FlashLoanAaveZeroLiquidity(); /** * @dev Constructor function that initializes the contract with a Uniswap V3 Dex. * @param factoryV3 The address of the Uniswap V3 factory. * @param initCodeHash The init code hash of the Uniswap V3 factory. * @param name The name of the Uniswap V3 Dex. */ constructor( address aaveAddressProvider, //https://docs.aave.com/developers/deployed-contracts/v3-mainnet address factoryV3, bytes32 initCodeHash, string memory name ) { bytes32 nameHash = keccak256(abi.encodePacked(name)); _addUniswapV3Dex(factoryV3, initCodeHash, nameHash, name); if (aaveAddressProvider != address(0)) { ADDRESSES_PROVIDER = IPoolAddressesProvider(aaveAddressProvider); POOL = IPool(ADDRESSES_PROVIDER.getPool()); } } /** * @dev Initializes the Aave protocol by setting the Aave address provider and the Aave pool. * @param aaveAddressProvider The address of the Aave address provider contract. * @notice This function can only be called by the contract owner. * @notice The Aave address provider must not be the zero address. * @notice The Aave pool must not have been initialized before. */ function initAave(address aaveAddressProvider) external onlyOwner { require(aaveAddressProvider != address(0)); require(address(POOL) == address(0)); ADDRESSES_PROVIDER = IPoolAddressesProvider(aaveAddressProvider); POOL = IPool(ADDRESSES_PROVIDER.getPool()); } /** * @dev Sets the address of the Wagmi Leverage contract. * @param _wagmiLeverageAddress The address of the Wagmi Leverage contract. */ function setWagmiLeverageAddress(address _wagmiLeverageAddress) external onlyOwner { wagmiLeverageContracts[_wagmiLeverageAddress] = true; } /** * @dev Adds a Uniswap V3 DEX to the FlashLoanAggregator contract. * @param factoryV3 The address of the Uniswap V3 factory contract. * @param initCodeHash The init code hash of the Uniswap V3 factory contract. * @param name The name of the Uniswap V3 DEX. * Requirements: * - Only the contract owner can call this function. * - The Uniswap V3 DEX with the given name must not already exist. */ function addUniswapV3Dex( address factoryV3, bytes32 initCodeHash, string calldata name ) external onlyOwner { bytes32 nameHash = keccak256(abi.encodePacked(name)); require(!uniswapDexIsExists[nameHash], "DE"); _addUniswapV3Dex(factoryV3, initCodeHash, nameHash, name); } function _addUniswapV3Dex( address factoryV3, bytes32 initCodeHash, bytes32 nameHash, string memory name ) private { uniswapV3Dexes.push( UniswapV3Identifier({ enabled: true, factoryV3: factoryV3, initCodeHash: initCodeHash, name: name }) ); uniswapDexIsExists[nameHash] = true; emit UniswapV3DexAdded(factoryV3, initCodeHash, name); } /** * @dev Edits the Uniswap V3 DEX configuration at the specified index. * @param enabled Whether the DEX is enabled or not. * @param factoryV3 The address of the Uniswap V3 factory contract. * @param initCodeHash The init code hash of the Uniswap V3 pair contract. * @param indx The index of the DEX in the `uniswapV3Dexes` array. * Requirements: * - The caller must be the contract owner. * - The `indx` must be a valid index in the `uniswapV3Dexes` array. */ function editUniswapV3Dex( bool enabled, address factoryV3, bytes32 initCodeHash, uint256 indx ) external correctIndx(indx) onlyOwner { UniswapV3Identifier storage dex = uniswapV3Dexes[indx]; dex.enabled = enabled; dex.factoryV3 = factoryV3; dex.initCodeHash = initCodeHash; emit UniswapV3DexChanged(factoryV3, initCodeHash, dex.name); } /** * @dev Executes a flash loan by interacting with different protocols based on the specified route. * @param amount The amount of the flash loan. * @param data Additional data for the flash loan. * @notice Only callable by the `onlyWagmiLeverage` modifier. * @notice Supports flash loans from Uniswap and Aave protocols. * @notice Reverts if the specified route is not supported. */ function flashLoan(uint256 amount, bytes calldata data) external onlyWagmiLeverage { ILiquidityManager.CallbackData memory decodedData = abi.decode( data, (ILiquidityManager.CallbackData) ); ILiquidityManager.FlashLoanParams[] memory flashLoanParams = decodedData .routes .flashLoanParams; require(flashLoanParams.length > 0, "FLP"); Protocol protocol = Protocol(flashLoanParams[0].protocol); Debt[] memory debts = new Debt[](flashLoanParams.length); uint256 saleTokenBalance = decodedData.saleToken.getBalance(); if (protocol == Protocol.UNISWAP) { address pool = _getUniswapV3Pool(decodedData.saleToken, flashLoanParams[0].data); (uint256 flashAmount0, uint256 flashAmount1) = _maxUniPoolFlashAmt( decodedData.saleToken, pool, amount ); IUniswapV3Pool(pool).flash( address(this), flashAmount0, flashAmount1, abi.encode( CallbackDataExt({ recipient: msg.sender, amount: amount, currentIndex: 0, prevBalance: saleTokenBalance, debts: debts, originData: data }) ) ); } else if (protocol == Protocol.AAVE) { require(address(POOL) != address(0), "Aave not initialized"); uint256 maxAmount = checkAaveFlashReserve(decodedData.saleToken); if (maxAmount == 0) { revert FlashLoanAaveZeroLiquidity(); } POOL.flashLoanSimple( address(this), decodedData.saleToken, amount > maxAmount ? maxAmount : amount, abi.encode( CallbackDataExt({ recipient: msg.sender, amount: amount, currentIndex: 0, prevBalance: saleTokenBalance, debts: debts, originData: data }) ), 0 ); } else { revert("UFP"); } } function checkAaveFlashReserve(address asset) public view returns (uint256 amount) { DataTypes.ReserveData memory reserve = POOL.getReserveData(asset); uint128 premium = POOL.FLASHLOAN_PREMIUM_TOTAL(); DataTypes.ReserveConfigurationMap memory configuration = reserve.configuration; if ( premium > 100 || configuration.getPaused() || !configuration.getActive() || !configuration.getFlashLoanEnabled() ) { return 0; } amount = asset.getBalanceOf(reserve.aTokenAddress); } function executeOperation( address /*asset*/, uint256 /*amount*/, uint256 premium, address initiator, bytes calldata data ) external override returns (bool) { assert(initiator == address(this)); _excuteCallback(premium, data); return true; } function algebraFlashCallback(uint256 fee0, uint256 fee1, bytes calldata data) external { _excuteCallback(fee0 + fee1, data); } function pancakeV3FlashCallback(uint256 fee0, uint256 fee1, bytes calldata data) external { _excuteCallback(fee0 + fee1, data); } function uniswapV3FlashCallback(uint256 fee0, uint256 fee1, bytes calldata data) external { _excuteCallback(fee0 + fee1, data); } /** * @dev Calculates the maximum flash loan amount for a given token and pool. * @param token The address of the token. * @param pool The address of the Uniswap V3 pool. * @param amount The desired flash loan amount. * @return flashAmount0 The maximum amount of token0 that can be borrowed. * @return flashAmount1 The maximum amount of token1 that can be borrowed. * @dev This function checks the liquidity of the pool and the balance of the token in the pool. * If the pool has zero liquidity or the token balance is zero, it reverts with an error. * Otherwise, it calculates the maximum flash loan amount based on the available token balance. * If `zeroForSaleToken` is true, `flashAmount0` will be set to `flashAmt`, otherwise `flashAmount1` will be set to `flashAmt`. */ function _maxUniPoolFlashAmt( address token, address pool, uint256 amount ) private view returns (uint256 flashAmount0, uint256 flashAmount1) { uint256 flashAmt = token.getBalanceOf(pool); if (flashAmt == 0 || IUniswapV3Pool(pool).liquidity() == 0) { revert FlashLoanZeroLiquidity(pool); } address token0 = IUniswapV3Pool(pool).token0(); bool zeroForSaleToken = token0 == token; flashAmt = flashAmt > amount ? amount : flashAmt; (flashAmount0, flashAmount1) = zeroForSaleToken ? (flashAmt, uint256(0)) : (uint256(0), flashAmt); } /** * @dev Retrieves the address of a Uniswap V3 pool based on the provided parameters. * @param saleToken The address of the token being sold. * @param leverageData The encoded data containing the pool fee tiers, second token address, and DEX index. * @return pool The address of the Uniswap V3 pool. * @dev This function decodes the `leverageData` and retrieves the necessary information to compute the pool address. * @dev It checks if the specified DEX is enabled before computing the pool address. * @dev The pool address is computed using the `computePoolAddress` function with the provided parameters. */ function _getUniswapV3Pool( address saleToken, bytes memory leverageData ) private view returns (address pool) { (uint24 poolfeeTiers, address secondToken, uint256 dexIndx) = abi.decode( leverageData, (uint24, address, uint256) ); UniswapV3Identifier memory dex = uniswapV3Dexes[dexIndx]; require(dex.enabled, "DXE"); pool = _computePoolAddress( poolfeeTiers, saleToken, secondToken, dex.factoryV3, dex.initCodeHash ); } /** * @dev Computes the address of a Uniswap V3 pool based on the provided parameters. * Not applicable for the zkSync. * * This function calculates the address of a Uniswap V3 pool contract using the token addresses and fee. * It follows the same logic as Uniswap's pool initialization process. * * @param fee The fee level of the pool. * @param tokenA The address of one of the tokens in the pair. * @param tokenB The address of the other token in the pair. * @param factoryV3 The address of the Uniswap V3 factory contract. * @param initCodeHash The hash of the pool initialization code. * @return pool The computed address of the Uniswap V3 pool. */ function _computePoolAddress( uint24 fee, address tokenA, address tokenB, address factoryV3, bytes32 initCodeHash ) private pure returns (address pool) { if (tokenA > tokenB) (tokenA, tokenB) = (tokenB, tokenA); // dinamic fee support( algebra ) bytes32 pHash = fee > 0 ? keccak256(abi.encode(tokenA, tokenB, fee)) : keccak256(abi.encode(tokenA, tokenB)); pool = address( uint160(uint256(keccak256(abi.encodePacked(hex"ff", factoryV3, pHash, initCodeHash)))) ); } function _tryApprove(address token, uint256 amount) private returns (bool) { (bool success, bytes memory data) = token.call( abi.encodeWithSelector(IERC20.approve.selector, address(POOL), amount) ); return success && (data.length == 0 || abi.decode(data, (bool))); } function _aaveFlashApprove(address token, uint256 amount) internal { if (!_tryApprove(token, amount)) { require(_tryApprove(token, 0), "AFA0"); require(_tryApprove(token, amount), "AFA"); } } /** * @dev Private function to repay flash loans after execution. * This function handles the repayment of multiple debts that arose during flash loan operations. * It ensures the correct amounts are repaid to the corresponding creditors, and performs approval * for token transfer if needed. The function supports both AAVE and UNISWAP protocols and is designed * to work with arrays of debt structs which contain information about debts from various protocols. * * If the last protocol used in the series of flash loans was AAVE, the function approves the AAVE * lending pool to pull the repayment amount and settles UNISWAP debts directly by transferring funds. * * Conversely, if the last protocol was UNISWAP, the function directly transfers the needed funds to * settle the debt and handles the AAVE debt separately by performing a token approval. * * Any protocols other than AAVE or UNISWAP will cause the transaction to revert. * * @param lastProto The protocol used in the last taken flash loan. * @param token The ERC20 token address that was used for the flash loans. * @param lastAmtWithPremium The cumulative flash loan amount including any premiums/fees from the last flash loan taken. * @param debts An array of Debt structs containing details about each individual debt accrued through the flash loan sequence. */ function _repayFlashLoans( Protocol lastProto, address token, uint256 lastAmtWithPremium, Debt[] memory debts ) private { // Check if the last flash loan was taken from the AAVE protocol if (lastProto == Protocol.AAVE) { // Approve the AAVE contract to pull the repayment amount including premiums _aaveFlashApprove(token, lastAmtWithPremium); // Iterate over the array of debts to process repayments // if we have already processed the AAVE protocol we do not expect it for (uint256 i = 0; i < debts.length; ) { Debt memory debt = debts[i]; // Exit loop if creditor address is zero indicating no more debts if (debt.creditor == address(0)) { break; } // Handle UNISWAP debt repayment by transferring tokens directly to creditor if (debt.protocol == Protocol.UNISWAP) { token.safeTransfer(debt.creditor, debt.body + debt.interest); } else { revert("REA"); } unchecked { ++i; } } // Check if the last flash loan was taken from the UNISWAP protocol } else if (lastProto == Protocol.UNISWAP) { // Directly transfer the loan amount plus premium to the sender for final UNISWAP loan settlement token.safeTransfer(msg.sender, lastAmtWithPremium); for (uint256 i = 0; i < debts.length; ) { Debt memory debt = debts[i]; if (debt.creditor == address(0)) { break; } if (debt.protocol == Protocol.AAVE) { // Approve repayment for AAVE debts _aaveFlashApprove(token, debt.body + debt.interest); } else if (debt.protocol == Protocol.UNISWAP) { // Transfer tokens directly for UNISWAP debts token.safeTransfer(debt.creditor, debt.body + debt.interest); } else { revert("REU"); } unchecked { ++i; } } } else { revert("RE UFP"); } } /** * @dev Internal function that executes a flash loan callback. * It processes the received data, performs checks based on the protocol, * and handles repayment of debts or initiation of subsequent flash loans. * * The function decodes the `data` parameter to extract the callback details and then, * depending on the state of the flash loan process (e.g., if this is an intermediary step * in a sequence of flash loans, or the final callback), it either performs the necessary payouts * and calls the user's callback function, or it encodes new data and triggers another flash loan. * * Additionally, the function enforces security by requiring that it is called only by the expected * sources (like a specific Uniswap pool or the AAVE lending pool) according to the loan protocol used. * It supports different protocols like Uniswap or AAVE for the execution of flash loans. * * @param premium The fee or interest amount associated with the flash loan. * @param data Encoded data containing all relevant information to perform callbacks and repayments. */ function _excuteCallback(uint256 premium, bytes calldata data) internal { // Decode the extended callback data structure CallbackDataExt memory decodedDataExt = abi.decode(data, (CallbackDataExt)); // Decode the original callback data sent by the user ILiquidityManager.CallbackData memory decodedData = abi.decode( decodedDataExt.originData, (ILiquidityManager.CallbackData) ); // Extract the current flash loan parameters from the route provided in the callback data ILiquidityManager.FlashLoanParams memory flashParams = decodedData.routes.flashLoanParams[ decodedDataExt.currentIndex ]; // Determine the protocol used for the current flash loan Protocol protocol = Protocol(flashParams.protocol); if (protocol == Protocol.UNISWAP) { require( msg.sender == _getUniswapV3Pool(decodedData.saleToken, flashParams.data), "IPC" ); } else if (protocol == Protocol.AAVE) { require(msg.sender == address(POOL), "IPC"); } else { revert("IPC UFP"); } uint256 flashBalance = decodedData.saleToken.getBalance(); // Check if enough funds were received to cover the loan or if this is the last loan step if ( flashBalance >= decodedDataExt.amount || decodedDataExt.currentIndex == decodedData.routes.flashLoanParams.length - 1 ) { // Compute total interest including premiums of intermediate steps uint256 interest = premium; // Process recorded debt information for each protocol involved in the loan series uint256 debtsLength = decodedDataExt.debts.length; for (uint256 i = 0; i < debtsLength; ) { // Terminate early if we hit an empty creditor slot if (decodedDataExt.debts[i].creditor == address(0)) { break; } unchecked { // Accumulate interest from each debt interest += decodedDataExt.debts[i].interest; ++i; } } // Transfer the flashBalance to the recipient decodedData.saleToken.safeTransfer(decodedDataExt.recipient, flashBalance); // Invoke the WagmiLeverage callback function with updated parameters IWagmiLeverageFlashCallback(decodedDataExt.recipient).wagmiLeverageFlashCallback( flashBalance < decodedDataExt.amount ? flashBalance : decodedDataExt.amount, interest, decodedDataExt.originData ); uint256 lastPayment = flashBalance - decodedDataExt.prevBalance + premium; // Repay all flash loans that have been taken out across different protocols _repayFlashLoans(protocol, decodedData.saleToken, lastPayment, decodedDataExt.debts); } else { // If not enough funds, prepare for the next flash loan in the series uint256 nextIndx = decodedDataExt.currentIndex + 1; // Record the current debt for the ongoing protocol decodedDataExt.debts[decodedDataExt.currentIndex] = Debt({ protocol: protocol, creditor: msg.sender, body: flashBalance - decodedDataExt.prevBalance, interest: premium }); // Encode data for the next flash loan callback bytes memory nextData = abi.encode( CallbackDataExt({ recipient: decodedDataExt.recipient, amount: decodedDataExt.amount, currentIndex: nextIndx, prevBalance: flashBalance, debts: decodedDataExt.debts, originData: decodedDataExt.originData }) ); // Set up next flash loan params flashParams = decodedData.routes.flashLoanParams[nextIndx]; protocol = Protocol(flashParams.protocol); // Trigger the next flash loan based on the protocol if (protocol == Protocol.UNISWAP) { address pool = _getUniswapV3Pool(decodedData.saleToken, flashParams.data); (uint256 flashAmount0, uint256 flashAmount1) = _maxUniPoolFlashAmt( decodedData.saleToken, pool, decodedDataExt.amount - flashBalance ); IUniswapV3Pool(pool).flash(address(this), flashAmount0, flashAmount1, nextData); } else if (protocol == Protocol.AAVE) { uint256 maxAmount = checkAaveFlashReserve(decodedData.saleToken); if (maxAmount == 0) { revert FlashLoanAaveZeroLiquidity(); } uint256 amount = decodedDataExt.amount - flashBalance; POOL.flashLoanSimple( address(this), decodedData.saleToken, amount > maxAmount ? maxAmount : amount, nextData, 0 ); } else { revert("UFP"); } } } }
// SPDX-License-Identifier: AGPL-3.0 pragma solidity ^0.8.0; import {IPoolAddressesProvider} from '../../interfaces/IPoolAddressesProvider.sol'; import {IPool} from '../../interfaces/IPool.sol'; /** * @title IFlashLoanSimpleReceiver * @author Aave * @notice Defines the basic interface of a flashloan-receiver contract. * @dev Implement this interface to develop a flashloan-compatible flashLoanReceiver contract */ interface IFlashLoanSimpleReceiver { /** * @notice Executes an operation after receiving the flash-borrowed asset * @dev Ensure that the contract can return the debt + premium, e.g., has * enough funds to repay and has approved the Pool to pull the total amount * @param asset The address of the flash-borrowed asset * @param amount The amount of the flash-borrowed asset * @param premium The fee of the flash-borrowed asset * @param initiator The address of the flashloan initiator * @param params The byte-encoded params passed when initiating the flashloan * @return True if the execution of the operation succeeds, false otherwise */ function executeOperation( address asset, uint256 amount, uint256 premium, address initiator, bytes calldata params ) external returns (bool); function ADDRESSES_PROVIDER() external view returns (IPoolAddressesProvider); function POOL() external view returns (IPool); }
// SPDX-License-Identifier: AGPL-3.0 pragma solidity ^0.8.0; import {IPoolAddressesProvider} from './IPoolAddressesProvider.sol'; import {DataTypes} from '../protocol/libraries/types/DataTypes.sol'; /** * @title IPool * @author Aave * @notice Defines the basic interface for an Aave Pool. */ interface IPool { /** * @dev Emitted on mintUnbacked() * @param reserve The address of the underlying asset of the reserve * @param user The address initiating the supply * @param onBehalfOf The beneficiary of the supplied assets, receiving the aTokens * @param amount The amount of supplied assets * @param referralCode The referral code used */ event MintUnbacked( address indexed reserve, address user, address indexed onBehalfOf, uint256 amount, uint16 indexed referralCode ); /** * @dev Emitted on backUnbacked() * @param reserve The address of the underlying asset of the reserve * @param backer The address paying for the backing * @param amount The amount added as backing * @param fee The amount paid in fees */ event BackUnbacked(address indexed reserve, address indexed backer, uint256 amount, uint256 fee); /** * @dev Emitted on supply() * @param reserve The address of the underlying asset of the reserve * @param user The address initiating the supply * @param onBehalfOf The beneficiary of the supply, receiving the aTokens * @param amount The amount supplied * @param referralCode The referral code used */ event Supply( address indexed reserve, address user, address indexed onBehalfOf, uint256 amount, uint16 indexed referralCode ); /** * @dev Emitted on withdraw() * @param reserve The address of the underlying asset being withdrawn * @param user The address initiating the withdrawal, owner of aTokens * @param to The address that will receive the underlying * @param amount The amount to be withdrawn */ event Withdraw(address indexed reserve, address indexed user, address indexed to, uint256 amount); /** * @dev Emitted on borrow() and flashLoan() when debt needs to be opened * @param reserve The address of the underlying asset being borrowed * @param user The address of the user initiating the borrow(), receiving the funds on borrow() or just * initiator of the transaction on flashLoan() * @param onBehalfOf The address that will be getting the debt * @param amount The amount borrowed out * @param interestRateMode The rate mode: 1 for Stable, 2 for Variable * @param borrowRate The numeric rate at which the user has borrowed, expressed in ray * @param referralCode The referral code used */ event Borrow( address indexed reserve, address user, address indexed onBehalfOf, uint256 amount, DataTypes.InterestRateMode interestRateMode, uint256 borrowRate, uint16 indexed referralCode ); /** * @dev Emitted on repay() * @param reserve The address of the underlying asset of the reserve * @param user The beneficiary of the repayment, getting his debt reduced * @param repayer The address of the user initiating the repay(), providing the funds * @param amount The amount repaid * @param useATokens True if the repayment is done using aTokens, `false` if done with underlying asset directly */ event Repay( address indexed reserve, address indexed user, address indexed repayer, uint256 amount, bool useATokens ); /** * @dev Emitted on swapBorrowRateMode() * @param reserve The address of the underlying asset of the reserve * @param user The address of the user swapping his rate mode * @param interestRateMode The current interest rate mode of the position being swapped: 1 for Stable, 2 for Variable */ event SwapBorrowRateMode( address indexed reserve, address indexed user, DataTypes.InterestRateMode interestRateMode ); /** * @dev Emitted on borrow(), repay() and liquidationCall() when using isolated assets * @param asset The address of the underlying asset of the reserve * @param totalDebt The total isolation mode debt for the reserve */ event IsolationModeTotalDebtUpdated(address indexed asset, uint256 totalDebt); /** * @dev Emitted when the user selects a certain asset category for eMode * @param user The address of the user * @param categoryId The category id */ event UserEModeSet(address indexed user, uint8 categoryId); /** * @dev Emitted on setUserUseReserveAsCollateral() * @param reserve The address of the underlying asset of the reserve * @param user The address of the user enabling the usage as collateral */ event ReserveUsedAsCollateralEnabled(address indexed reserve, address indexed user); /** * @dev Emitted on setUserUseReserveAsCollateral() * @param reserve The address of the underlying asset of the reserve * @param user The address of the user enabling the usage as collateral */ event ReserveUsedAsCollateralDisabled(address indexed reserve, address indexed user); /** * @dev Emitted on rebalanceStableBorrowRate() * @param reserve The address of the underlying asset of the reserve * @param user The address of the user for which the rebalance has been executed */ event RebalanceStableBorrowRate(address indexed reserve, address indexed user); /** * @dev Emitted on flashLoan() * @param target The address of the flash loan receiver contract * @param initiator The address initiating the flash loan * @param asset The address of the asset being flash borrowed * @param amount The amount flash borrowed * @param interestRateMode The flashloan mode: 0 for regular flashloan, 1 for Stable debt, 2 for Variable debt * @param premium The fee flash borrowed * @param referralCode The referral code used */ event FlashLoan( address indexed target, address initiator, address indexed asset, uint256 amount, DataTypes.InterestRateMode interestRateMode, uint256 premium, uint16 indexed referralCode ); /** * @dev Emitted when a borrower is liquidated. * @param collateralAsset The address of the underlying asset used as collateral, to receive as result of the liquidation * @param debtAsset The address of the underlying borrowed asset to be repaid with the liquidation * @param user The address of the borrower getting liquidated * @param debtToCover The debt amount of borrowed `asset` the liquidator wants to cover * @param liquidatedCollateralAmount The amount of collateral received by the liquidator * @param liquidator The address of the liquidator * @param receiveAToken True if the liquidators wants to receive the collateral aTokens, `false` if he wants * to receive the underlying collateral asset directly */ event LiquidationCall( address indexed collateralAsset, address indexed debtAsset, address indexed user, uint256 debtToCover, uint256 liquidatedCollateralAmount, address liquidator, bool receiveAToken ); /** * @dev Emitted when the state of a reserve is updated. * @param reserve The address of the underlying asset of the reserve * @param liquidityRate The next liquidity rate * @param stableBorrowRate The next stable borrow rate * @param variableBorrowRate The next variable borrow rate * @param liquidityIndex The next liquidity index * @param variableBorrowIndex The next variable borrow index */ event ReserveDataUpdated( address indexed reserve, uint256 liquidityRate, uint256 stableBorrowRate, uint256 variableBorrowRate, uint256 liquidityIndex, uint256 variableBorrowIndex ); /** * @dev Emitted when the protocol treasury receives minted aTokens from the accrued interest. * @param reserve The address of the reserve * @param amountMinted The amount minted to the treasury */ event MintedToTreasury(address indexed reserve, uint256 amountMinted); /** * @notice Mints an `amount` of aTokens to the `onBehalfOf` * @param asset The address of the underlying asset to mint * @param amount The amount to mint * @param onBehalfOf The address that will receive the aTokens * @param referralCode 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 mintUnbacked( address asset, uint256 amount, address onBehalfOf, uint16 referralCode ) external; /** * @notice Back the current unbacked underlying with `amount` and pay `fee`. * @param asset The address of the underlying asset to back * @param amount The amount to back * @param fee The amount paid in fees * @return The backed amount */ function backUnbacked(address asset, uint256 amount, uint256 fee) external returns (uint256); /** * @notice Supplies an `amount` of underlying asset into the reserve, receiving in return overlying aTokens. * - E.g. User supplies 100 USDC and gets in return 100 aUSDC * @param asset The address of the underlying asset to supply * @param amount The amount to be supplied * @param onBehalfOf The address that will receive the aTokens, same as msg.sender if the user * wants to receive them on his own wallet, or a different address if the beneficiary of aTokens * is a different wallet * @param referralCode 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 supply(address asset, uint256 amount, address onBehalfOf, uint16 referralCode) external; /** * @notice Supply with transfer approval of asset to be supplied done via permit function * see: https://eips.ethereum.org/EIPS/eip-2612 and https://eips.ethereum.org/EIPS/eip-713 * @param asset The address of the underlying asset to supply * @param amount The amount to be supplied * @param onBehalfOf The address that will receive the aTokens, same as msg.sender if the user * wants to receive them on his own wallet, or a different address if the beneficiary of aTokens * is a different wallet * @param deadline The deadline timestamp that the permit is valid * @param referralCode 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 * @param permitV The V parameter of ERC712 permit sig * @param permitR The R parameter of ERC712 permit sig * @param permitS The S parameter of ERC712 permit sig */ function supplyWithPermit( address asset, uint256 amount, address onBehalfOf, uint16 referralCode, uint256 deadline, uint8 permitV, bytes32 permitR, bytes32 permitS ) external; /** * @notice Withdraws an `amount` of underlying asset from the reserve, burning the equivalent aTokens owned * E.g. User has 100 aUSDC, calls withdraw() and receives 100 USDC, burning the 100 aUSDC * @param asset The address of the underlying asset to withdraw * @param amount The underlying amount to be withdrawn * - Send the value type(uint256).max in order to withdraw the whole aToken balance * @param to The address that will receive the underlying, same as msg.sender if the user * wants to receive it on his own wallet, or a different address if the beneficiary is a * different wallet * @return The final amount withdrawn */ function withdraw(address asset, uint256 amount, address to) external returns (uint256); /** * @notice Allows users to borrow a specific `amount` of the reserve underlying asset, provided that the borrower * already supplied enough collateral, or he was given enough allowance by a credit delegator on the * corresponding debt token (StableDebtToken or VariableDebtToken) * - E.g. User borrows 100 USDC passing as `onBehalfOf` his own address, receiving the 100 USDC in his wallet * and 100 stable/variable debt tokens, depending on the `interestRateMode` * @param asset The address of the underlying asset to borrow * @param amount The amount to be borrowed * @param interestRateMode The interest rate mode at which the user wants to borrow: 1 for Stable, 2 for Variable * @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 * @param onBehalfOf The address of the user who will receive the debt. Should be the address of the borrower itself * calling the function if he wants to borrow against his own collateral, or the address of the credit delegator * if he has been given credit delegation allowance */ function borrow( address asset, uint256 amount, uint256 interestRateMode, uint16 referralCode, address onBehalfOf ) external; /** * @notice Repays a borrowed `amount` on a specific reserve, burning the equivalent debt tokens owned * - E.g. User repays 100 USDC, burning 100 variable/stable debt tokens of the `onBehalfOf` address * @param asset The address of the borrowed underlying asset previously borrowed * @param amount The amount to repay * - Send the value type(uint256).max in order to repay the whole debt for `asset` on the specific `debtMode` * @param interestRateMode The interest rate mode at of the debt the user wants to repay: 1 for Stable, 2 for Variable * @param onBehalfOf The address of the user who will get his debt reduced/removed. Should be the address of the * user calling the function if he wants to reduce/remove his own debt, or the address of any other * other borrower whose debt should be removed * @return The final amount repaid */ function repay( address asset, uint256 amount, uint256 interestRateMode, address onBehalfOf ) external returns (uint256); /** * @notice Repay with transfer approval of asset to be repaid done via permit function * see: https://eips.ethereum.org/EIPS/eip-2612 and https://eips.ethereum.org/EIPS/eip-713 * @param asset The address of the borrowed underlying asset previously borrowed * @param amount The amount to repay * - Send the value type(uint256).max in order to repay the whole debt for `asset` on the specific `debtMode` * @param interestRateMode The interest rate mode at of the debt the user wants to repay: 1 for Stable, 2 for Variable * @param onBehalfOf Address of the user who will get his debt reduced/removed. Should be the address of the * user calling the function if he wants to reduce/remove his own debt, or the address of any other * other borrower whose debt should be removed * @param deadline The deadline timestamp that the permit is valid * @param permitV The V parameter of ERC712 permit sig * @param permitR The R parameter of ERC712 permit sig * @param permitS The S parameter of ERC712 permit sig * @return The final amount repaid */ function repayWithPermit( address asset, uint256 amount, uint256 interestRateMode, address onBehalfOf, uint256 deadline, uint8 permitV, bytes32 permitR, bytes32 permitS ) external returns (uint256); /** * @notice Repays a borrowed `amount` on a specific reserve using the reserve aTokens, burning the * equivalent debt tokens * - E.g. User repays 100 USDC using 100 aUSDC, burning 100 variable/stable debt tokens * @dev Passing uint256.max as amount will clean up any residual aToken dust balance, if the user aToken * balance is not enough to cover the whole debt * @param asset The address of the borrowed underlying asset previously borrowed * @param amount The amount to repay * - Send the value type(uint256).max in order to repay the whole debt for `asset` on the specific `debtMode` * @param interestRateMode The interest rate mode at of the debt the user wants to repay: 1 for Stable, 2 for Variable * @return The final amount repaid */ function repayWithATokens( address asset, uint256 amount, uint256 interestRateMode ) external returns (uint256); /** * @notice Allows a borrower to swap his debt between stable and variable mode, or vice versa * @param asset The address of the underlying asset borrowed * @param interestRateMode The current interest rate mode of the position being swapped: 1 for Stable, 2 for Variable */ function swapBorrowRateMode(address asset, uint256 interestRateMode) external; /** * @notice Rebalances the stable interest rate of a user to the current stable rate defined on the reserve. * - Users can be rebalanced if the following conditions are satisfied: * 1. Usage ratio is above 95% * 2. the current supply APY is below REBALANCE_UP_THRESHOLD * maxVariableBorrowRate, which means that too * much has been borrowed at a stable rate and suppliers are not earning enough * @param asset The address of the underlying asset borrowed * @param user The address of the user to be rebalanced */ function rebalanceStableBorrowRate(address asset, address user) external; /** * @notice Allows suppliers to enable/disable a specific supplied asset as collateral * @param asset The address of the underlying asset supplied * @param useAsCollateral True if the user wants to use the supply as collateral, false otherwise */ function setUserUseReserveAsCollateral(address asset, bool useAsCollateral) external; /** * @notice Function to liquidate a non-healthy position collateral-wise, with Health Factor below 1 * - The caller (liquidator) covers `debtToCover` amount of debt of the user getting liquidated, and receives * a proportionally amount of the `collateralAsset` plus a bonus to cover market risk * @param collateralAsset The address of the underlying asset used as collateral, to receive as result of the liquidation * @param debtAsset The address of the underlying borrowed asset to be repaid with the liquidation * @param user The address of the borrower getting liquidated * @param debtToCover The debt amount of borrowed `asset` the liquidator wants to cover * @param receiveAToken True if the liquidators wants to receive the collateral aTokens, `false` if he wants * to receive the underlying collateral asset directly */ function liquidationCall( address collateralAsset, address debtAsset, address user, uint256 debtToCover, bool receiveAToken ) external; /** * @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 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 IFlashLoanSimpleReceiver interface * @param asset The address of the asset being flash-borrowed * @param amount The amount of the asset being flash-borrowed * @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 flashLoanSimple( address receiverAddress, address asset, uint256 amount, bytes calldata params, uint16 referralCode ) external; /** * @notice Returns the user account data across all the reserves * @param user The address of the user * @return totalCollateralBase The total collateral of the user in the base currency used by the price feed * @return totalDebtBase The total debt of the user in the base currency used by the price feed * @return availableBorrowsBase The borrowing power left of the user in the base currency used by the price feed * @return currentLiquidationThreshold The liquidation threshold of the user * @return ltv The loan to value of The user * @return healthFactor The current health factor of the user */ function getUserAccountData( address user ) external view returns ( uint256 totalCollateralBase, uint256 totalDebtBase, uint256 availableBorrowsBase, uint256 currentLiquidationThreshold, uint256 ltv, uint256 healthFactor ); /** * @notice Initializes a reserve, activating it, assigning an aToken and debt tokens and an * interest rate strategy * @dev Only callable by the PoolConfigurator contract * @param asset The address of the underlying asset of the reserve * @param aTokenAddress The address of the aToken that will be assigned to the reserve * @param stableDebtAddress The address of the StableDebtToken that will be assigned to the reserve * @param variableDebtAddress The address of the VariableDebtToken that will be assigned to the reserve * @param interestRateStrategyAddress The address of the interest rate strategy contract */ function initReserve( address asset, address aTokenAddress, address stableDebtAddress, address variableDebtAddress, address interestRateStrategyAddress ) external; /** * @notice Drop a reserve * @dev Only callable by the PoolConfigurator contract * @param asset The address of the underlying asset of the reserve */ function dropReserve(address asset) external; /** * @notice Updates the address of the interest rate strategy contract * @dev Only callable by the PoolConfigurator contract * @param asset The address of the underlying asset of the reserve * @param rateStrategyAddress The address of the interest rate strategy contract */ function setReserveInterestRateStrategyAddress( address asset, address rateStrategyAddress ) external; /** * @notice Sets the configuration bitmap of the reserve as a whole * @dev Only callable by the PoolConfigurator contract * @param asset The address of the underlying asset of the reserve * @param configuration The new configuration bitmap */ function setConfiguration( address asset, DataTypes.ReserveConfigurationMap calldata configuration ) external; /** * @notice Returns the configuration of the reserve * @param asset The address of the underlying asset of the reserve * @return The configuration of the reserve */ function getConfiguration( address asset ) external view returns (DataTypes.ReserveConfigurationMap memory); /** * @notice Returns the configuration of the user across all the reserves * @param user The user address * @return The configuration of the user */ function getUserConfiguration( address user ) external view returns (DataTypes.UserConfigurationMap memory); /** * @notice Returns the normalized income of the reserve * @param asset The address of the underlying asset of the reserve * @return The reserve's normalized income */ function getReserveNormalizedIncome(address asset) external view returns (uint256); /** * @notice Returns the normalized variable debt per unit of asset * @dev WARNING: This function is intended to be used primarily by the protocol itself to get a * "dynamic" variable index based on time, current stored index and virtual rate at the current * moment (approx. a borrower would get if opening a position). This means that is always used in * combination with variable debt supply/balances. * If using this function externally, consider that is possible to have an increasing normalized * variable debt that is not equivalent to how the variable debt index would be updated in storage * (e.g. only updates with non-zero variable debt supply) * @param asset The address of the underlying asset of the reserve * @return The reserve normalized variable debt */ function getReserveNormalizedVariableDebt(address asset) external view returns (uint256); /** * @notice Returns the state and configuration of the reserve * @param asset The address of the underlying asset of the reserve * @return The state and configuration data of the reserve */ function getReserveData(address asset) external view returns (DataTypes.ReserveData memory); /** * @notice Validates and finalizes an aToken transfer * @dev Only callable by the overlying aToken of the `asset` * @param asset The address of the underlying asset of the aToken * @param from The user from which the aTokens are transferred * @param to The user receiving the aTokens * @param amount The amount being transferred/withdrawn * @param balanceFromBefore The aToken balance of the `from` user before the transfer * @param balanceToBefore The aToken balance of the `to` user before the transfer */ function finalizeTransfer( address asset, address from, address to, uint256 amount, uint256 balanceFromBefore, uint256 balanceToBefore ) external; /** * @notice Returns the list of the underlying assets of all the initialized reserves * @dev It does not include dropped reserves * @return The addresses of the underlying assets of the initialized reserves */ function getReservesList() external view returns (address[] memory); /** * @notice Returns the address of the underlying asset of a reserve by the reserve id as stored in the DataTypes.ReserveData struct * @param id The id of the reserve as stored in the DataTypes.ReserveData struct * @return The address of the reserve associated with id */ function getReserveAddressById(uint16 id) external view returns (address); /** * @notice Returns the PoolAddressesProvider connected to this contract * @return The address of the PoolAddressesProvider */ function ADDRESSES_PROVIDER() external view returns (IPoolAddressesProvider); /** * @notice Updates the protocol fee on the bridging * @param bridgeProtocolFee The part of the premium sent to the protocol treasury */ function updateBridgeProtocolFee(uint256 bridgeProtocolFee) external; /** * @notice Updates flash loan premiums. Flash loan premium consists of two parts: * - A part is sent to aToken holders as extra, one time accumulated interest * - A part is collected by the protocol treasury * @dev The total premium is calculated on the total borrowed amount * @dev The premium to protocol is calculated on the total premium, being a percentage of `flashLoanPremiumTotal` * @dev Only callable by the PoolConfigurator contract * @param flashLoanPremiumTotal The total premium, expressed in bps * @param flashLoanPremiumToProtocol The part of the premium sent to the protocol treasury, expressed in bps */ function updateFlashloanPremiums( uint128 flashLoanPremiumTotal, uint128 flashLoanPremiumToProtocol ) external; /** * @notice Configures a new category for the eMode. * @dev In eMode, the protocol allows very high borrowing power to borrow assets of the same category. * The category 0 is reserved as it's the default for volatile assets * @param id The id of the category * @param config The configuration of the category */ function configureEModeCategory(uint8 id, DataTypes.EModeCategory memory config) external; /** * @notice Returns the data of an eMode category * @param id The id of the category * @return The configuration data of the category */ function getEModeCategoryData(uint8 id) external view returns (DataTypes.EModeCategory memory); /** * @notice Allows a user to use the protocol in eMode * @param categoryId The id of the category */ function setUserEMode(uint8 categoryId) external; /** * @notice Returns the eMode the user is using * @param user The address of the user * @return The eMode id */ function getUserEMode(address user) external view returns (uint256); /** * @notice Resets the isolation mode total debt of the given asset to zero * @dev It requires the given asset has zero debt ceiling * @param asset The address of the underlying asset to reset the isolationModeTotalDebt */ function resetIsolationModeTotalDebt(address asset) external; /** * @notice Returns the percentage of available liquidity that can be borrowed at once at stable rate * @return The percentage of available liquidity to borrow, expressed in bps */ function MAX_STABLE_RATE_BORROW_SIZE_PERCENT() external view returns (uint256); /** * @notice Returns the total fee on flash loans * @return The total fee on flashloans */ function FLASHLOAN_PREMIUM_TOTAL() external view returns (uint128); /** * @notice Returns the part of the bridge fees sent to protocol * @return The bridge fee sent to the protocol treasury */ function BRIDGE_PROTOCOL_FEE() external view returns (uint256); /** * @notice Returns the part of the flashloan fees sent to protocol * @return The flashloan fee sent to the protocol treasury */ function FLASHLOAN_PREMIUM_TO_PROTOCOL() external view returns (uint128); /** * @notice Returns the maximum number of reserves supported to be listed in this Pool * @return The maximum number of reserves supported */ function MAX_NUMBER_RESERVES() external view returns (uint16); /** * @notice Mints the assets accrued through the reserve factor to the treasury in the form of aTokens * @param assets The list of reserves for which the minting needs to be executed */ function mintToTreasury(address[] calldata assets) external; /** * @notice Rescue and transfer tokens locked in this contract * @param token The address of the token * @param to The address of the recipient * @param amount The amount of token to transfer */ function rescueTokens(address token, address to, uint256 amount) external; /** * @notice Supplies an `amount` of underlying asset into the reserve, receiving in return overlying aTokens. * - E.g. User supplies 100 USDC and gets in return 100 aUSDC * @dev Deprecated: Use the `supply` function instead * @param asset The address of the underlying asset to supply * @param amount The amount to be supplied * @param onBehalfOf The address that will receive the aTokens, same as msg.sender if the user * wants to receive them on his own wallet, or a different address if the beneficiary of aTokens * is a different wallet * @param referralCode 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 deposit(address asset, uint256 amount, address onBehalfOf, uint16 referralCode) external; }
// SPDX-License-Identifier: AGPL-3.0 pragma solidity ^0.8.0; /** * @title IPoolAddressesProvider * @author Aave * @notice Defines the basic interface for a Pool Addresses Provider. */ interface IPoolAddressesProvider { /** * @dev Emitted when the market identifier is updated. * @param oldMarketId The old id of the market * @param newMarketId The new id of the market */ event MarketIdSet(string indexed oldMarketId, string indexed newMarketId); /** * @dev Emitted when the pool is updated. * @param oldAddress The old address of the Pool * @param newAddress The new address of the Pool */ event PoolUpdated(address indexed oldAddress, address indexed newAddress); /** * @dev Emitted when the pool configurator is updated. * @param oldAddress The old address of the PoolConfigurator * @param newAddress The new address of the PoolConfigurator */ event PoolConfiguratorUpdated(address indexed oldAddress, address indexed newAddress); /** * @dev Emitted when the price oracle is updated. * @param oldAddress The old address of the PriceOracle * @param newAddress The new address of the PriceOracle */ event PriceOracleUpdated(address indexed oldAddress, address indexed newAddress); /** * @dev Emitted when the ACL manager is updated. * @param oldAddress The old address of the ACLManager * @param newAddress The new address of the ACLManager */ event ACLManagerUpdated(address indexed oldAddress, address indexed newAddress); /** * @dev Emitted when the ACL admin is updated. * @param oldAddress The old address of the ACLAdmin * @param newAddress The new address of the ACLAdmin */ event ACLAdminUpdated(address indexed oldAddress, address indexed newAddress); /** * @dev Emitted when the price oracle sentinel is updated. * @param oldAddress The old address of the PriceOracleSentinel * @param newAddress The new address of the PriceOracleSentinel */ event PriceOracleSentinelUpdated(address indexed oldAddress, address indexed newAddress); /** * @dev Emitted when the pool data provider is updated. * @param oldAddress The old address of the PoolDataProvider * @param newAddress The new address of the PoolDataProvider */ event PoolDataProviderUpdated(address indexed oldAddress, address indexed newAddress); /** * @dev Emitted when a new proxy is created. * @param id The identifier of the proxy * @param proxyAddress The address of the created proxy contract * @param implementationAddress The address of the implementation contract */ event ProxyCreated( bytes32 indexed id, address indexed proxyAddress, address indexed implementationAddress ); /** * @dev Emitted when a new non-proxied contract address is registered. * @param id The identifier of the contract * @param oldAddress The address of the old contract * @param newAddress The address of the new contract */ event AddressSet(bytes32 indexed id, address indexed oldAddress, address indexed newAddress); /** * @dev Emitted when the implementation of the proxy registered with id is updated * @param id The identifier of the contract * @param proxyAddress The address of the proxy contract * @param oldImplementationAddress The address of the old implementation contract * @param newImplementationAddress The address of the new implementation contract */ event AddressSetAsProxy( bytes32 indexed id, address indexed proxyAddress, address oldImplementationAddress, address indexed newImplementationAddress ); /** * @notice Returns the id of the Aave market to which this contract points to. * @return The market id */ function getMarketId() external view returns (string memory); /** * @notice Associates an id with a specific PoolAddressesProvider. * @dev This can be used to create an onchain registry of PoolAddressesProviders to * identify and validate multiple Aave markets. * @param newMarketId The market id */ function setMarketId(string calldata newMarketId) external; /** * @notice Returns an address by its identifier. * @dev The returned address might be an EOA or a contract, potentially proxied * @dev It returns ZERO if there is no registered address with the given id * @param id The id * @return The address of the registered for the specified id */ function getAddress(bytes32 id) external view returns (address); /** * @notice General function to update the implementation of a proxy registered with * certain `id`. If there is no proxy registered, it will instantiate one and * set as implementation the `newImplementationAddress`. * @dev IMPORTANT Use this function carefully, only for ids that don't have an explicit * setter function, in order to avoid unexpected consequences * @param id The id * @param newImplementationAddress The address of the new implementation */ function setAddressAsProxy(bytes32 id, address newImplementationAddress) external; /** * @notice Sets an address for an id replacing the address saved in the addresses map. * @dev IMPORTANT Use this function carefully, as it will do a hard replacement * @param id The id * @param newAddress The address to set */ function setAddress(bytes32 id, address newAddress) external; /** * @notice Returns the address of the Pool proxy. * @return The Pool proxy address */ function getPool() external view returns (address); /** * @notice Updates the implementation of the Pool, or creates a proxy * setting the new `pool` implementation when the function is called for the first time. * @param newPoolImpl The new Pool implementation */ function setPoolImpl(address newPoolImpl) external; /** * @notice Returns the address of the PoolConfigurator proxy. * @return The PoolConfigurator proxy address */ function getPoolConfigurator() external view returns (address); /** * @notice Updates the implementation of the PoolConfigurator, or creates a proxy * setting the new `PoolConfigurator` implementation when the function is called for the first time. * @param newPoolConfiguratorImpl The new PoolConfigurator implementation */ function setPoolConfiguratorImpl(address newPoolConfiguratorImpl) external; /** * @notice Returns the address of the price oracle. * @return The address of the PriceOracle */ function getPriceOracle() external view returns (address); /** * @notice Updates the address of the price oracle. * @param newPriceOracle The address of the new PriceOracle */ function setPriceOracle(address newPriceOracle) external; /** * @notice Returns the address of the ACL manager. * @return The address of the ACLManager */ function getACLManager() external view returns (address); /** * @notice Updates the address of the ACL manager. * @param newAclManager The address of the new ACLManager */ function setACLManager(address newAclManager) external; /** * @notice Returns the address of the ACL admin. * @return The address of the ACL admin */ function getACLAdmin() external view returns (address); /** * @notice Updates the address of the ACL admin. * @param newAclAdmin The address of the new ACL admin */ function setACLAdmin(address newAclAdmin) external; /** * @notice Returns the address of the price oracle sentinel. * @return The address of the PriceOracleSentinel */ function getPriceOracleSentinel() external view returns (address); /** * @notice Updates the address of the price oracle sentinel. * @param newPriceOracleSentinel The address of the new PriceOracleSentinel */ function setPriceOracleSentinel(address newPriceOracleSentinel) external; /** * @notice Returns the address of the data provider. * @return The address of the DataProvider */ function getPoolDataProvider() external view returns (address); /** * @notice Updates the address of the data provider. * @param newDataProvider The address of the new DataProvider */ function setPoolDataProvider(address newDataProvider) external; }
// SPDX-License-Identifier: BUSL-1.1 pragma solidity ^0.8.0; import {Errors} from '../helpers/Errors.sol'; import {DataTypes} from '../types/DataTypes.sol'; /** * @title ReserveConfiguration library * @author Aave * @notice Implements the bitmap logic to handle the reserve configuration */ library ReserveConfiguration { uint256 internal constant LTV_MASK = 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF0000; // prettier-ignore uint256 internal constant LIQUIDATION_THRESHOLD_MASK = 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF0000FFFF; // prettier-ignore uint256 internal constant LIQUIDATION_BONUS_MASK = 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF0000FFFFFFFF; // prettier-ignore uint256 internal constant DECIMALS_MASK = 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF00FFFFFFFFFFFF; // prettier-ignore uint256 internal constant ACTIVE_MASK = 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFFFFFFFFFFF; // prettier-ignore uint256 internal constant FROZEN_MASK = 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFDFFFFFFFFFFFFFF; // prettier-ignore uint256 internal constant BORROWING_MASK = 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFBFFFFFFFFFFFFFF; // prettier-ignore uint256 internal constant STABLE_BORROWING_MASK = 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF7FFFFFFFFFFFFFF; // prettier-ignore uint256 internal constant PAUSED_MASK = 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFFFFFFFFFFFF; // prettier-ignore uint256 internal constant BORROWABLE_IN_ISOLATION_MASK = 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFDFFFFFFFFFFFFFFF; // prettier-ignore uint256 internal constant SILOED_BORROWING_MASK = 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFBFFFFFFFFFFFFFFF; // prettier-ignore uint256 internal constant FLASHLOAN_ENABLED_MASK = 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF7FFFFFFFFFFFFFFF; // prettier-ignore uint256 internal constant RESERVE_FACTOR_MASK = 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF0000FFFFFFFFFFFFFFFF; // prettier-ignore uint256 internal constant BORROW_CAP_MASK = 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF000000000FFFFFFFFFFFFFFFFFFFF; // prettier-ignore uint256 internal constant SUPPLY_CAP_MASK = 0xFFFFFFFFFFFFFFFFFFFFFFFFFF000000000FFFFFFFFFFFFFFFFFFFFFFFFFFFFF; // prettier-ignore uint256 internal constant LIQUIDATION_PROTOCOL_FEE_MASK = 0xFFFFFFFFFFFFFFFFFFFFFF0000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF; // prettier-ignore uint256 internal constant EMODE_CATEGORY_MASK = 0xFFFFFFFFFFFFFFFFFFFF00FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF; // prettier-ignore uint256 internal constant UNBACKED_MINT_CAP_MASK = 0xFFFFFFFFFFF000000000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF; // prettier-ignore uint256 internal constant DEBT_CEILING_MASK = 0xF0000000000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF; // prettier-ignore /// @dev For the LTV, the start bit is 0 (up to 15), hence no bitshifting is needed uint256 internal constant LIQUIDATION_THRESHOLD_START_BIT_POSITION = 16; uint256 internal constant LIQUIDATION_BONUS_START_BIT_POSITION = 32; uint256 internal constant RESERVE_DECIMALS_START_BIT_POSITION = 48; uint256 internal constant IS_ACTIVE_START_BIT_POSITION = 56; uint256 internal constant IS_FROZEN_START_BIT_POSITION = 57; uint256 internal constant BORROWING_ENABLED_START_BIT_POSITION = 58; uint256 internal constant STABLE_BORROWING_ENABLED_START_BIT_POSITION = 59; uint256 internal constant IS_PAUSED_START_BIT_POSITION = 60; uint256 internal constant BORROWABLE_IN_ISOLATION_START_BIT_POSITION = 61; uint256 internal constant SILOED_BORROWING_START_BIT_POSITION = 62; uint256 internal constant FLASHLOAN_ENABLED_START_BIT_POSITION = 63; uint256 internal constant RESERVE_FACTOR_START_BIT_POSITION = 64; uint256 internal constant BORROW_CAP_START_BIT_POSITION = 80; uint256 internal constant SUPPLY_CAP_START_BIT_POSITION = 116; uint256 internal constant LIQUIDATION_PROTOCOL_FEE_START_BIT_POSITION = 152; uint256 internal constant EMODE_CATEGORY_START_BIT_POSITION = 168; uint256 internal constant UNBACKED_MINT_CAP_START_BIT_POSITION = 176; uint256 internal constant DEBT_CEILING_START_BIT_POSITION = 212; uint256 internal constant MAX_VALID_LTV = 65535; uint256 internal constant MAX_VALID_LIQUIDATION_THRESHOLD = 65535; uint256 internal constant MAX_VALID_LIQUIDATION_BONUS = 65535; uint256 internal constant MAX_VALID_DECIMALS = 255; uint256 internal constant MAX_VALID_RESERVE_FACTOR = 65535; uint256 internal constant MAX_VALID_BORROW_CAP = 68719476735; uint256 internal constant MAX_VALID_SUPPLY_CAP = 68719476735; uint256 internal constant MAX_VALID_LIQUIDATION_PROTOCOL_FEE = 65535; uint256 internal constant MAX_VALID_EMODE_CATEGORY = 255; uint256 internal constant MAX_VALID_UNBACKED_MINT_CAP = 68719476735; uint256 internal constant MAX_VALID_DEBT_CEILING = 1099511627775; uint256 public constant DEBT_CEILING_DECIMALS = 2; uint16 public constant MAX_RESERVES_COUNT = 128; /** * @notice Sets the Loan to Value of the reserve * @param self The reserve configuration * @param ltv The new ltv */ function setLtv(DataTypes.ReserveConfigurationMap memory self, uint256 ltv) internal pure { require(ltv <= MAX_VALID_LTV, Errors.INVALID_LTV); self.data = (self.data & LTV_MASK) | ltv; } /** * @notice Gets the Loan to Value of the reserve * @param self The reserve configuration * @return The loan to value */ function getLtv(DataTypes.ReserveConfigurationMap memory self) internal pure returns (uint256) { return self.data & ~LTV_MASK; } /** * @notice Sets the liquidation threshold of the reserve * @param self The reserve configuration * @param threshold The new liquidation threshold */ function setLiquidationThreshold( DataTypes.ReserveConfigurationMap memory self, uint256 threshold ) internal pure { require(threshold <= MAX_VALID_LIQUIDATION_THRESHOLD, Errors.INVALID_LIQ_THRESHOLD); self.data = (self.data & LIQUIDATION_THRESHOLD_MASK) | (threshold << LIQUIDATION_THRESHOLD_START_BIT_POSITION); } /** * @notice Gets the liquidation threshold of the reserve * @param self The reserve configuration * @return The liquidation threshold */ function getLiquidationThreshold( DataTypes.ReserveConfigurationMap memory self ) internal pure returns (uint256) { return (self.data & ~LIQUIDATION_THRESHOLD_MASK) >> LIQUIDATION_THRESHOLD_START_BIT_POSITION; } /** * @notice Sets the liquidation bonus of the reserve * @param self The reserve configuration * @param bonus The new liquidation bonus */ function setLiquidationBonus( DataTypes.ReserveConfigurationMap memory self, uint256 bonus ) internal pure { require(bonus <= MAX_VALID_LIQUIDATION_BONUS, Errors.INVALID_LIQ_BONUS); self.data = (self.data & LIQUIDATION_BONUS_MASK) | (bonus << LIQUIDATION_BONUS_START_BIT_POSITION); } /** * @notice Gets the liquidation bonus of the reserve * @param self The reserve configuration * @return The liquidation bonus */ function getLiquidationBonus( DataTypes.ReserveConfigurationMap memory self ) internal pure returns (uint256) { return (self.data & ~LIQUIDATION_BONUS_MASK) >> LIQUIDATION_BONUS_START_BIT_POSITION; } /** * @notice Sets the decimals of the underlying asset of the reserve * @param self The reserve configuration * @param decimals The decimals */ function setDecimals( DataTypes.ReserveConfigurationMap memory self, uint256 decimals ) internal pure { require(decimals <= MAX_VALID_DECIMALS, Errors.INVALID_DECIMALS); self.data = (self.data & DECIMALS_MASK) | (decimals << RESERVE_DECIMALS_START_BIT_POSITION); } /** * @notice Gets the decimals of the underlying asset of the reserve * @param self The reserve configuration * @return The decimals of the asset */ function getDecimals( DataTypes.ReserveConfigurationMap memory self ) internal pure returns (uint256) { return (self.data & ~DECIMALS_MASK) >> RESERVE_DECIMALS_START_BIT_POSITION; } /** * @notice Sets the active state of the reserve * @param self The reserve configuration * @param active The active state */ function setActive(DataTypes.ReserveConfigurationMap memory self, bool active) internal pure { self.data = (self.data & ACTIVE_MASK) | (uint256(active ? 1 : 0) << IS_ACTIVE_START_BIT_POSITION); } /** * @notice Gets the active state of the reserve * @param self The reserve configuration * @return The active state */ function getActive(DataTypes.ReserveConfigurationMap memory self) internal pure returns (bool) { return (self.data & ~ACTIVE_MASK) != 0; } /** * @notice Sets the frozen state of the reserve * @param self The reserve configuration * @param frozen The frozen state */ function setFrozen(DataTypes.ReserveConfigurationMap memory self, bool frozen) internal pure { self.data = (self.data & FROZEN_MASK) | (uint256(frozen ? 1 : 0) << IS_FROZEN_START_BIT_POSITION); } /** * @notice Gets the frozen state of the reserve * @param self The reserve configuration * @return The frozen state */ function getFrozen(DataTypes.ReserveConfigurationMap memory self) internal pure returns (bool) { return (self.data & ~FROZEN_MASK) != 0; } /** * @notice Sets the paused state of the reserve * @param self The reserve configuration * @param paused The paused state */ function setPaused(DataTypes.ReserveConfigurationMap memory self, bool paused) internal pure { self.data = (self.data & PAUSED_MASK) | (uint256(paused ? 1 : 0) << IS_PAUSED_START_BIT_POSITION); } /** * @notice Gets the paused state of the reserve * @param self The reserve configuration * @return The paused state */ function getPaused(DataTypes.ReserveConfigurationMap memory self) internal pure returns (bool) { return (self.data & ~PAUSED_MASK) != 0; } /** * @notice Sets the borrowable in isolation flag for the reserve. * @dev When this flag is set to true, the asset will be borrowable against isolated collaterals and the borrowed * amount will be accumulated in the isolated collateral's total debt exposure. * @dev Only assets of the same family (eg USD stablecoins) should be borrowable in isolation mode to keep * consistency in the debt ceiling calculations. * @param self The reserve configuration * @param borrowable True if the asset is borrowable */ function setBorrowableInIsolation( DataTypes.ReserveConfigurationMap memory self, bool borrowable ) internal pure { self.data = (self.data & BORROWABLE_IN_ISOLATION_MASK) | (uint256(borrowable ? 1 : 0) << BORROWABLE_IN_ISOLATION_START_BIT_POSITION); } /** * @notice Gets the borrowable in isolation flag for the reserve. * @dev If the returned flag is true, the asset is borrowable against isolated collateral. Assets borrowed with * isolated collateral is accounted for in the isolated collateral's total debt exposure. * @dev Only assets of the same family (eg USD stablecoins) should be borrowable in isolation mode to keep * consistency in the debt ceiling calculations. * @param self The reserve configuration * @return The borrowable in isolation flag */ function getBorrowableInIsolation( DataTypes.ReserveConfigurationMap memory self ) internal pure returns (bool) { return (self.data & ~BORROWABLE_IN_ISOLATION_MASK) != 0; } /** * @notice Sets the siloed borrowing flag for the reserve. * @dev When this flag is set to true, users borrowing this asset will not be allowed to borrow any other asset. * @param self The reserve configuration * @param siloed True if the asset is siloed */ function setSiloedBorrowing( DataTypes.ReserveConfigurationMap memory self, bool siloed ) internal pure { self.data = (self.data & SILOED_BORROWING_MASK) | (uint256(siloed ? 1 : 0) << SILOED_BORROWING_START_BIT_POSITION); } /** * @notice Gets the siloed borrowing flag for the reserve. * @dev When this flag is set to true, users borrowing this asset will not be allowed to borrow any other asset. * @param self The reserve configuration * @return The siloed borrowing flag */ function getSiloedBorrowing( DataTypes.ReserveConfigurationMap memory self ) internal pure returns (bool) { return (self.data & ~SILOED_BORROWING_MASK) != 0; } /** * @notice Enables or disables borrowing on the reserve * @param self The reserve configuration * @param enabled True if the borrowing needs to be enabled, false otherwise */ function setBorrowingEnabled( DataTypes.ReserveConfigurationMap memory self, bool enabled ) internal pure { self.data = (self.data & BORROWING_MASK) | (uint256(enabled ? 1 : 0) << BORROWING_ENABLED_START_BIT_POSITION); } /** * @notice Gets the borrowing state of the reserve * @param self The reserve configuration * @return The borrowing state */ function getBorrowingEnabled( DataTypes.ReserveConfigurationMap memory self ) internal pure returns (bool) { return (self.data & ~BORROWING_MASK) != 0; } /** * @notice Enables or disables stable rate borrowing on the reserve * @param self The reserve configuration * @param enabled True if the stable rate borrowing needs to be enabled, false otherwise */ function setStableRateBorrowingEnabled( DataTypes.ReserveConfigurationMap memory self, bool enabled ) internal pure { self.data = (self.data & STABLE_BORROWING_MASK) | (uint256(enabled ? 1 : 0) << STABLE_BORROWING_ENABLED_START_BIT_POSITION); } /** * @notice Gets the stable rate borrowing state of the reserve * @param self The reserve configuration * @return The stable rate borrowing state */ function getStableRateBorrowingEnabled( DataTypes.ReserveConfigurationMap memory self ) internal pure returns (bool) { return (self.data & ~STABLE_BORROWING_MASK) != 0; } /** * @notice Sets the reserve factor of the reserve * @param self The reserve configuration * @param reserveFactor The reserve factor */ function setReserveFactor( DataTypes.ReserveConfigurationMap memory self, uint256 reserveFactor ) internal pure { require(reserveFactor <= MAX_VALID_RESERVE_FACTOR, Errors.INVALID_RESERVE_FACTOR); self.data = (self.data & RESERVE_FACTOR_MASK) | (reserveFactor << RESERVE_FACTOR_START_BIT_POSITION); } /** * @notice Gets the reserve factor of the reserve * @param self The reserve configuration * @return The reserve factor */ function getReserveFactor( DataTypes.ReserveConfigurationMap memory self ) internal pure returns (uint256) { return (self.data & ~RESERVE_FACTOR_MASK) >> RESERVE_FACTOR_START_BIT_POSITION; } /** * @notice Sets the borrow cap of the reserve * @param self The reserve configuration * @param borrowCap The borrow cap */ function setBorrowCap( DataTypes.ReserveConfigurationMap memory self, uint256 borrowCap ) internal pure { require(borrowCap <= MAX_VALID_BORROW_CAP, Errors.INVALID_BORROW_CAP); self.data = (self.data & BORROW_CAP_MASK) | (borrowCap << BORROW_CAP_START_BIT_POSITION); } /** * @notice Gets the borrow cap of the reserve * @param self The reserve configuration * @return The borrow cap */ function getBorrowCap( DataTypes.ReserveConfigurationMap memory self ) internal pure returns (uint256) { return (self.data & ~BORROW_CAP_MASK) >> BORROW_CAP_START_BIT_POSITION; } /** * @notice Sets the supply cap of the reserve * @param self The reserve configuration * @param supplyCap The supply cap */ function setSupplyCap( DataTypes.ReserveConfigurationMap memory self, uint256 supplyCap ) internal pure { require(supplyCap <= MAX_VALID_SUPPLY_CAP, Errors.INVALID_SUPPLY_CAP); self.data = (self.data & SUPPLY_CAP_MASK) | (supplyCap << SUPPLY_CAP_START_BIT_POSITION); } /** * @notice Gets the supply cap of the reserve * @param self The reserve configuration * @return The supply cap */ function getSupplyCap( DataTypes.ReserveConfigurationMap memory self ) internal pure returns (uint256) { return (self.data & ~SUPPLY_CAP_MASK) >> SUPPLY_CAP_START_BIT_POSITION; } /** * @notice Sets the debt ceiling in isolation mode for the asset * @param self The reserve configuration * @param ceiling The maximum debt ceiling for the asset */ function setDebtCeiling( DataTypes.ReserveConfigurationMap memory self, uint256 ceiling ) internal pure { require(ceiling <= MAX_VALID_DEBT_CEILING, Errors.INVALID_DEBT_CEILING); self.data = (self.data & DEBT_CEILING_MASK) | (ceiling << DEBT_CEILING_START_BIT_POSITION); } /** * @notice Gets the debt ceiling for the asset if the asset is in isolation mode * @param self The reserve configuration * @return The debt ceiling (0 = isolation mode disabled) */ function getDebtCeiling( DataTypes.ReserveConfigurationMap memory self ) internal pure returns (uint256) { return (self.data & ~DEBT_CEILING_MASK) >> DEBT_CEILING_START_BIT_POSITION; } /** * @notice Sets the liquidation protocol fee of the reserve * @param self The reserve configuration * @param liquidationProtocolFee The liquidation protocol fee */ function setLiquidationProtocolFee( DataTypes.ReserveConfigurationMap memory self, uint256 liquidationProtocolFee ) internal pure { require( liquidationProtocolFee <= MAX_VALID_LIQUIDATION_PROTOCOL_FEE, Errors.INVALID_LIQUIDATION_PROTOCOL_FEE ); self.data = (self.data & LIQUIDATION_PROTOCOL_FEE_MASK) | (liquidationProtocolFee << LIQUIDATION_PROTOCOL_FEE_START_BIT_POSITION); } /** * @dev Gets the liquidation protocol fee * @param self The reserve configuration * @return The liquidation protocol fee */ function getLiquidationProtocolFee( DataTypes.ReserveConfigurationMap memory self ) internal pure returns (uint256) { return (self.data & ~LIQUIDATION_PROTOCOL_FEE_MASK) >> LIQUIDATION_PROTOCOL_FEE_START_BIT_POSITION; } /** * @notice Sets the unbacked mint cap of the reserve * @param self The reserve configuration * @param unbackedMintCap The unbacked mint cap */ function setUnbackedMintCap( DataTypes.ReserveConfigurationMap memory self, uint256 unbackedMintCap ) internal pure { require(unbackedMintCap <= MAX_VALID_UNBACKED_MINT_CAP, Errors.INVALID_UNBACKED_MINT_CAP); self.data = (self.data & UNBACKED_MINT_CAP_MASK) | (unbackedMintCap << UNBACKED_MINT_CAP_START_BIT_POSITION); } /** * @dev Gets the unbacked mint cap of the reserve * @param self The reserve configuration * @return The unbacked mint cap */ function getUnbackedMintCap( DataTypes.ReserveConfigurationMap memory self ) internal pure returns (uint256) { return (self.data & ~UNBACKED_MINT_CAP_MASK) >> UNBACKED_MINT_CAP_START_BIT_POSITION; } /** * @notice Sets the eMode asset category * @param self The reserve configuration * @param category The asset category when the user selects the eMode */ function setEModeCategory( DataTypes.ReserveConfigurationMap memory self, uint256 category ) internal pure { require(category <= MAX_VALID_EMODE_CATEGORY, Errors.INVALID_EMODE_CATEGORY); self.data = (self.data & EMODE_CATEGORY_MASK) | (category << EMODE_CATEGORY_START_BIT_POSITION); } /** * @dev Gets the eMode asset category * @param self The reserve configuration * @return The eMode category for the asset */ function getEModeCategory( DataTypes.ReserveConfigurationMap memory self ) internal pure returns (uint256) { return (self.data & ~EMODE_CATEGORY_MASK) >> EMODE_CATEGORY_START_BIT_POSITION; } /** * @notice Sets the flashloanable flag for the reserve * @param self The reserve configuration * @param flashLoanEnabled True if the asset is flashloanable, false otherwise */ function setFlashLoanEnabled( DataTypes.ReserveConfigurationMap memory self, bool flashLoanEnabled ) internal pure { self.data = (self.data & FLASHLOAN_ENABLED_MASK) | (uint256(flashLoanEnabled ? 1 : 0) << FLASHLOAN_ENABLED_START_BIT_POSITION); } /** * @notice Gets the flashloanable flag for the reserve * @param self The reserve configuration * @return The flashloanable flag */ function getFlashLoanEnabled( DataTypes.ReserveConfigurationMap memory self ) internal pure returns (bool) { return (self.data & ~FLASHLOAN_ENABLED_MASK) != 0; } /** * @notice Gets the configuration flags of the reserve * @param self The reserve configuration * @return The state flag representing active * @return The state flag representing frozen * @return The state flag representing borrowing enabled * @return The state flag representing stableRateBorrowing enabled * @return The state flag representing paused */ function getFlags( DataTypes.ReserveConfigurationMap memory self ) internal pure returns (bool, bool, bool, bool, bool) { uint256 dataLocal = self.data; return ( (dataLocal & ~ACTIVE_MASK) != 0, (dataLocal & ~FROZEN_MASK) != 0, (dataLocal & ~BORROWING_MASK) != 0, (dataLocal & ~STABLE_BORROWING_MASK) != 0, (dataLocal & ~PAUSED_MASK) != 0 ); } /** * @notice Gets the configuration parameters of the reserve from storage * @param self The reserve configuration * @return The state param representing ltv * @return The state param representing liquidation threshold * @return The state param representing liquidation bonus * @return The state param representing reserve decimals * @return The state param representing reserve factor * @return The state param representing eMode category */ function getParams( DataTypes.ReserveConfigurationMap memory self ) internal pure returns (uint256, uint256, uint256, uint256, uint256, uint256) { uint256 dataLocal = self.data; return ( dataLocal & ~LTV_MASK, (dataLocal & ~LIQUIDATION_THRESHOLD_MASK) >> LIQUIDATION_THRESHOLD_START_BIT_POSITION, (dataLocal & ~LIQUIDATION_BONUS_MASK) >> LIQUIDATION_BONUS_START_BIT_POSITION, (dataLocal & ~DECIMALS_MASK) >> RESERVE_DECIMALS_START_BIT_POSITION, (dataLocal & ~RESERVE_FACTOR_MASK) >> RESERVE_FACTOR_START_BIT_POSITION, (dataLocal & ~EMODE_CATEGORY_MASK) >> EMODE_CATEGORY_START_BIT_POSITION ); } /** * @notice Gets the caps parameters of the reserve from storage * @param self The reserve configuration * @return The state param representing borrow cap * @return The state param representing supply cap. */ function getCaps( DataTypes.ReserveConfigurationMap memory self ) internal pure returns (uint256, uint256) { uint256 dataLocal = self.data; return ( (dataLocal & ~BORROW_CAP_MASK) >> BORROW_CAP_START_BIT_POSITION, (dataLocal & ~SUPPLY_CAP_MASK) >> SUPPLY_CAP_START_BIT_POSITION ); } }
// SPDX-License-Identifier: BUSL-1.1 pragma solidity ^0.8.0; /** * @title Errors library * @author Aave * @notice Defines the error messages emitted by the different contracts of the Aave protocol */ library Errors { string public constant CALLER_NOT_POOL_ADMIN = '1'; // 'The caller of the function is not a pool admin' string public constant CALLER_NOT_EMERGENCY_ADMIN = '2'; // 'The caller of the function is not an emergency admin' string public constant CALLER_NOT_POOL_OR_EMERGENCY_ADMIN = '3'; // 'The caller of the function is not a pool or emergency admin' string public constant CALLER_NOT_RISK_OR_POOL_ADMIN = '4'; // 'The caller of the function is not a risk or pool admin' string public constant CALLER_NOT_ASSET_LISTING_OR_POOL_ADMIN = '5'; // 'The caller of the function is not an asset listing or pool admin' string public constant CALLER_NOT_BRIDGE = '6'; // 'The caller of the function is not a bridge' string public constant ADDRESSES_PROVIDER_NOT_REGISTERED = '7'; // 'Pool addresses provider is not registered' string public constant INVALID_ADDRESSES_PROVIDER_ID = '8'; // 'Invalid id for the pool addresses provider' string public constant NOT_CONTRACT = '9'; // 'Address is not a contract' string public constant CALLER_NOT_POOL_CONFIGURATOR = '10'; // 'The caller of the function is not the pool configurator' string public constant CALLER_NOT_ATOKEN = '11'; // 'The caller of the function is not an AToken' string public constant INVALID_ADDRESSES_PROVIDER = '12'; // 'The address of the pool addresses provider is invalid' string public constant INVALID_FLASHLOAN_EXECUTOR_RETURN = '13'; // 'Invalid return value of the flashloan executor function' string public constant RESERVE_ALREADY_ADDED = '14'; // 'Reserve has already been added to reserve list' string public constant NO_MORE_RESERVES_ALLOWED = '15'; // 'Maximum amount of reserves in the pool reached' string public constant EMODE_CATEGORY_RESERVED = '16'; // 'Zero eMode category is reserved for volatile heterogeneous assets' string public constant INVALID_EMODE_CATEGORY_ASSIGNMENT = '17'; // 'Invalid eMode category assignment to asset' string public constant RESERVE_LIQUIDITY_NOT_ZERO = '18'; // 'The liquidity of the reserve needs to be 0' string public constant FLASHLOAN_PREMIUM_INVALID = '19'; // 'Invalid flashloan premium' string public constant INVALID_RESERVE_PARAMS = '20'; // 'Invalid risk parameters for the reserve' string public constant INVALID_EMODE_CATEGORY_PARAMS = '21'; // 'Invalid risk parameters for the eMode category' string public constant BRIDGE_PROTOCOL_FEE_INVALID = '22'; // 'Invalid bridge protocol fee' string public constant CALLER_MUST_BE_POOL = '23'; // 'The caller of this function must be a pool' string public constant INVALID_MINT_AMOUNT = '24'; // 'Invalid amount to mint' string public constant INVALID_BURN_AMOUNT = '25'; // 'Invalid amount to burn' string public constant INVALID_AMOUNT = '26'; // 'Amount must be greater than 0' string public constant RESERVE_INACTIVE = '27'; // 'Action requires an active reserve' string public constant RESERVE_FROZEN = '28'; // 'Action cannot be performed because the reserve is frozen' string public constant RESERVE_PAUSED = '29'; // 'Action cannot be performed because the reserve is paused' string public constant BORROWING_NOT_ENABLED = '30'; // 'Borrowing is not enabled' string public constant STABLE_BORROWING_NOT_ENABLED = '31'; // 'Stable borrowing is not enabled' string public constant NOT_ENOUGH_AVAILABLE_USER_BALANCE = '32'; // 'User cannot withdraw more than the available balance' string public constant INVALID_INTEREST_RATE_MODE_SELECTED = '33'; // 'Invalid interest rate mode selected' string public constant COLLATERAL_BALANCE_IS_ZERO = '34'; // 'The collateral balance is 0' string public constant HEALTH_FACTOR_LOWER_THAN_LIQUIDATION_THRESHOLD = '35'; // 'Health factor is lesser than the liquidation threshold' string public constant COLLATERAL_CANNOT_COVER_NEW_BORROW = '36'; // 'There is not enough collateral to cover a new borrow' string public constant COLLATERAL_SAME_AS_BORROWING_CURRENCY = '37'; // 'Collateral is (mostly) the same currency that is being borrowed' string public constant AMOUNT_BIGGER_THAN_MAX_LOAN_SIZE_STABLE = '38'; // 'The requested amount is greater than the max loan size in stable rate mode' string public constant NO_DEBT_OF_SELECTED_TYPE = '39'; // 'For repayment of a specific type of debt, the user needs to have debt that type' string public constant NO_EXPLICIT_AMOUNT_TO_REPAY_ON_BEHALF = '40'; // 'To repay on behalf of a user an explicit amount to repay is needed' string public constant NO_OUTSTANDING_STABLE_DEBT = '41'; // 'User does not have outstanding stable rate debt on this reserve' string public constant NO_OUTSTANDING_VARIABLE_DEBT = '42'; // 'User does not have outstanding variable rate debt on this reserve' string public constant UNDERLYING_BALANCE_ZERO = '43'; // 'The underlying balance needs to be greater than 0' string public constant INTEREST_RATE_REBALANCE_CONDITIONS_NOT_MET = '44'; // 'Interest rate rebalance conditions were not met' string public constant HEALTH_FACTOR_NOT_BELOW_THRESHOLD = '45'; // 'Health factor is not below the threshold' string public constant COLLATERAL_CANNOT_BE_LIQUIDATED = '46'; // 'The collateral chosen cannot be liquidated' string public constant SPECIFIED_CURRENCY_NOT_BORROWED_BY_USER = '47'; // 'User did not borrow the specified currency' string public constant INCONSISTENT_FLASHLOAN_PARAMS = '49'; // 'Inconsistent flashloan parameters' string public constant BORROW_CAP_EXCEEDED = '50'; // 'Borrow cap is exceeded' string public constant SUPPLY_CAP_EXCEEDED = '51'; // 'Supply cap is exceeded' string public constant UNBACKED_MINT_CAP_EXCEEDED = '52'; // 'Unbacked mint cap is exceeded' string public constant DEBT_CEILING_EXCEEDED = '53'; // 'Debt ceiling is exceeded' string public constant UNDERLYING_CLAIMABLE_RIGHTS_NOT_ZERO = '54'; // 'Claimable rights over underlying not zero (aToken supply or accruedToTreasury)' string public constant STABLE_DEBT_NOT_ZERO = '55'; // 'Stable debt supply is not zero' string public constant VARIABLE_DEBT_SUPPLY_NOT_ZERO = '56'; // 'Variable debt supply is not zero' string public constant LTV_VALIDATION_FAILED = '57'; // 'Ltv validation failed' string public constant INCONSISTENT_EMODE_CATEGORY = '58'; // 'Inconsistent eMode category' string public constant PRICE_ORACLE_SENTINEL_CHECK_FAILED = '59'; // 'Price oracle sentinel validation failed' string public constant ASSET_NOT_BORROWABLE_IN_ISOLATION = '60'; // 'Asset is not borrowable in isolation mode' string public constant RESERVE_ALREADY_INITIALIZED = '61'; // 'Reserve has already been initialized' string public constant USER_IN_ISOLATION_MODE_OR_LTV_ZERO = '62'; // 'User is in isolation mode or ltv is zero' string public constant INVALID_LTV = '63'; // 'Invalid ltv parameter for the reserve' string public constant INVALID_LIQ_THRESHOLD = '64'; // 'Invalid liquidity threshold parameter for the reserve' string public constant INVALID_LIQ_BONUS = '65'; // 'Invalid liquidity bonus parameter for the reserve' string public constant INVALID_DECIMALS = '66'; // 'Invalid decimals parameter of the underlying asset of the reserve' string public constant INVALID_RESERVE_FACTOR = '67'; // 'Invalid reserve factor parameter for the reserve' string public constant INVALID_BORROW_CAP = '68'; // 'Invalid borrow cap for the reserve' string public constant INVALID_SUPPLY_CAP = '69'; // 'Invalid supply cap for the reserve' string public constant INVALID_LIQUIDATION_PROTOCOL_FEE = '70'; // 'Invalid liquidation protocol fee for the reserve' string public constant INVALID_EMODE_CATEGORY = '71'; // 'Invalid eMode category for the reserve' string public constant INVALID_UNBACKED_MINT_CAP = '72'; // 'Invalid unbacked mint cap for the reserve' string public constant INVALID_DEBT_CEILING = '73'; // 'Invalid debt ceiling for the reserve string public constant INVALID_RESERVE_INDEX = '74'; // 'Invalid reserve index' string public constant ACL_ADMIN_CANNOT_BE_ZERO = '75'; // 'ACL admin cannot be set to the zero address' string public constant INCONSISTENT_PARAMS_LENGTH = '76'; // 'Array parameters that should be equal length are not' string public constant ZERO_ADDRESS_NOT_VALID = '77'; // 'Zero address not valid' string public constant INVALID_EXPIRATION = '78'; // 'Invalid expiration' string public constant INVALID_SIGNATURE = '79'; // 'Invalid signature' string public constant OPERATION_NOT_SUPPORTED = '80'; // 'Operation not supported' string public constant DEBT_CEILING_NOT_ZERO = '81'; // 'Debt ceiling is not zero' string public constant ASSET_NOT_LISTED = '82'; // 'Asset is not listed' string public constant INVALID_OPTIMAL_USAGE_RATIO = '83'; // 'Invalid optimal usage ratio' string public constant INVALID_OPTIMAL_STABLE_TO_TOTAL_DEBT_RATIO = '84'; // 'Invalid optimal stable to total debt ratio' string public constant UNDERLYING_CANNOT_BE_RESCUED = '85'; // 'The underlying asset cannot be rescued' string public constant ADDRESSES_PROVIDER_ALREADY_ADDED = '86'; // 'Reserve has already been added to reserve list' string public constant POOL_ADDRESSES_DO_NOT_MATCH = '87'; // 'The token implementation pool address and the pool address provided by the initializing pool do not match' string public constant STABLE_BORROWING_ENABLED = '88'; // 'Stable borrowing is enabled' string public constant SILOED_BORROWING_VIOLATION = '89'; // 'User is trying to borrow multiple assets including a siloed one' string public constant RESERVE_DEBT_NOT_ZERO = '90'; // the total debt of the reserve needs to be 0 string public constant FLASHLOAN_DISABLED = '91'; // FlashLoaning for this asset is disabled }
// SPDX-License-Identifier: BUSL-1.1 pragma solidity ^0.8.0; library DataTypes { struct ReserveData { //stores the reserve configuration ReserveConfigurationMap configuration; //the liquidity index. Expressed in ray uint128 liquidityIndex; //the current supply rate. Expressed in ray uint128 currentLiquidityRate; //variable borrow index. Expressed in ray uint128 variableBorrowIndex; //the current variable borrow rate. Expressed in ray uint128 currentVariableBorrowRate; //the current stable borrow rate. Expressed in ray uint128 currentStableBorrowRate; //timestamp of last update uint40 lastUpdateTimestamp; //the id of the reserve. Represents the position in the list of the active reserves uint16 id; //aToken address address aTokenAddress; //stableDebtToken address address stableDebtTokenAddress; //variableDebtToken address address variableDebtTokenAddress; //address of the interest rate strategy address interestRateStrategyAddress; //the current treasury balance, scaled uint128 accruedToTreasury; //the outstanding unbacked aTokens minted through the bridging feature uint128 unbacked; //the outstanding debt borrowed against this asset in isolation mode uint128 isolationModeTotalDebt; } struct ReserveConfigurationMap { //bit 0-15: LTV //bit 16-31: Liq. threshold //bit 32-47: Liq. bonus //bit 48-55: Decimals //bit 56: reserve is active //bit 57: reserve is frozen //bit 58: borrowing is enabled //bit 59: stable rate borrowing enabled //bit 60: asset is paused //bit 61: borrowing in isolation mode is enabled //bit 62: siloed borrowing enabled //bit 63: flashloaning enabled //bit 64-79: reserve factor //bit 80-115 borrow cap in whole tokens, borrowCap == 0 => no cap //bit 116-151 supply cap in whole tokens, supplyCap == 0 => no cap //bit 152-167 liquidation protocol fee //bit 168-175 eMode category //bit 176-211 unbacked mint cap in whole tokens, unbackedMintCap == 0 => minting disabled //bit 212-251 debt ceiling for isolation mode with (ReserveConfiguration::DEBT_CEILING_DECIMALS) decimals //bit 252-255 unused uint256 data; } struct UserConfigurationMap { /** * @dev Bitmap of the users collaterals and borrows. It is divided in pairs of bits, one pair per asset. * The first bit indicates if an asset is used as collateral by the user, the second whether an * asset is borrowed by the user. */ uint256 data; } struct EModeCategory { // each eMode category has a custom ltv and liquidation threshold uint16 ltv; uint16 liquidationThreshold; uint16 liquidationBonus; // each eMode category may or may not have a custom oracle to override the individual assets price oracles address priceSource; string label; } enum InterestRateMode {NONE, STABLE, VARIABLE} struct ReserveCache { uint256 currScaledVariableDebt; uint256 nextScaledVariableDebt; uint256 currPrincipalStableDebt; uint256 currAvgStableBorrowRate; uint256 currTotalStableDebt; uint256 nextAvgStableBorrowRate; uint256 nextTotalStableDebt; uint256 currLiquidityIndex; uint256 nextLiquidityIndex; uint256 currVariableBorrowIndex; uint256 nextVariableBorrowIndex; uint256 currLiquidityRate; uint256 currVariableBorrowRate; uint256 reserveFactor; ReserveConfigurationMap reserveConfiguration; address aTokenAddress; address stableDebtTokenAddress; address variableDebtTokenAddress; uint40 reserveLastUpdateTimestamp; uint40 stableDebtLastUpdateTimestamp; } struct ExecuteLiquidationCallParams { uint256 reservesCount; uint256 debtToCover; address collateralAsset; address debtAsset; address user; bool receiveAToken; address priceOracle; uint8 userEModeCategory; address priceOracleSentinel; } struct ExecuteSupplyParams { address asset; uint256 amount; address onBehalfOf; uint16 referralCode; } struct ExecuteBorrowParams { address asset; address user; address onBehalfOf; uint256 amount; InterestRateMode interestRateMode; uint16 referralCode; bool releaseUnderlying; uint256 maxStableRateBorrowSizePercent; uint256 reservesCount; address oracle; uint8 userEModeCategory; address priceOracleSentinel; } struct ExecuteRepayParams { address asset; uint256 amount; InterestRateMode interestRateMode; address onBehalfOf; bool useATokens; } struct ExecuteWithdrawParams { address asset; uint256 amount; address to; uint256 reservesCount; address oracle; uint8 userEModeCategory; } struct ExecuteSetUserEModeParams { uint256 reservesCount; address oracle; uint8 categoryId; } struct FinalizeTransferParams { address asset; address from; address to; uint256 amount; uint256 balanceFromBefore; uint256 balanceToBefore; uint256 reservesCount; address oracle; uint8 fromEModeCategory; } struct FlashloanParams { address receiverAddress; address[] assets; uint256[] amounts; uint256[] interestRateModes; address onBehalfOf; bytes params; uint16 referralCode; uint256 flashLoanPremiumToProtocol; uint256 flashLoanPremiumTotal; uint256 maxStableRateBorrowSizePercent; uint256 reservesCount; address addressesProvider; uint8 userEModeCategory; bool isAuthorizedFlashBorrower; } struct FlashloanSimpleParams { address receiverAddress; address asset; uint256 amount; bytes params; uint16 referralCode; uint256 flashLoanPremiumToProtocol; uint256 flashLoanPremiumTotal; } struct FlashLoanRepaymentParams { uint256 amount; uint256 totalPremium; uint256 flashLoanPremiumToProtocol; address asset; address receiverAddress; uint16 referralCode; } struct CalculateUserAccountDataParams { UserConfigurationMap userConfig; uint256 reservesCount; address user; address oracle; uint8 userEModeCategory; } struct ValidateBorrowParams { ReserveCache reserveCache; UserConfigurationMap userConfig; address asset; address userAddress; uint256 amount; InterestRateMode interestRateMode; uint256 maxStableLoanPercent; uint256 reservesCount; address oracle; uint8 userEModeCategory; address priceOracleSentinel; bool isolationModeActive; address isolationModeCollateralAddress; uint256 isolationModeDebtCeiling; } struct ValidateLiquidationCallParams { ReserveCache debtReserveCache; uint256 totalDebt; uint256 healthFactor; address priceOracleSentinel; } struct CalculateInterestRatesParams { uint256 unbacked; uint256 liquidityAdded; uint256 liquidityTaken; uint256 totalStableDebt; uint256 totalVariableDebt; uint256 averageStableBorrowRate; uint256 reserveFactor; address reserve; address aToken; } struct InitReserveParams { address asset; address aTokenAddress; address stableDebtAddress; address variableDebtAddress; address interestRateStrategyAddress; uint16 reservesCount; uint16 maxNumberReserves; } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.9.0) (access/Ownable.sol) pragma solidity ^0.8.0; import "../utils/Context.sol"; /** * @dev Contract module which provides a basic access control mechanism, where * there is an account (an owner) that can be granted exclusive access to * specific functions. * * By default, the owner account will be the one that deploys the contract. This * can later be changed with {transferOwnership}. * * This module is used through inheritance. It will make available the modifier * `onlyOwner`, which can be applied to your functions to restrict their use to * the owner. */ abstract contract Ownable is Context { address private _owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); /** * @dev Initializes the contract setting the deployer as the initial owner. */ constructor() { _transferOwnership(_msgSender()); } /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { _checkOwner(); _; } /** * @dev Returns the address of the current owner. */ function owner() public view virtual returns (address) { return _owner; } /** * @dev Throws if the sender is not the owner. */ function _checkOwner() internal view virtual { require(owner() == _msgSender(), "Ownable: caller is not the owner"); } /** * @dev Leaves the contract without owner. It will not be possible to call * `onlyOwner` functions. Can only be called by the current owner. * * NOTE: Renouncing ownership will leave the contract without an owner, * thereby disabling any functionality that is only available to the owner. */ function renounceOwnership() public virtual onlyOwner { _transferOwnership(address(0)); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Can only be called by the current owner. */ function transferOwnership(address newOwner) public virtual onlyOwner { require(newOwner != address(0), "Ownable: new owner is the zero address"); _transferOwnership(newOwner); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Internal function without access restriction. */ function _transferOwnership(address newOwner) internal virtual { address oldOwner = _owner; _owner = newOwner; emit OwnershipTransferred(oldOwner, newOwner); } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.9.0) (token/ERC20/IERC20.sol) pragma solidity ^0.8.0; /** * @dev Interface of the ERC20 standard as defined in the EIP. */ interface IERC20 { /** * @dev Emitted when `value` tokens are moved from one account (`from`) to * another (`to`). * * Note that `value` may be zero. */ event Transfer(address indexed from, address indexed to, uint256 value); /** * @dev Emitted when the allowance of a `spender` for an `owner` is set by * a call to {approve}. `value` is the new allowance. */ event Approval(address indexed owner, address indexed spender, uint256 value); /** * @dev Returns the amount of tokens in existence. */ function totalSupply() external view returns (uint256); /** * @dev Returns the amount of tokens owned by `account`. */ function balanceOf(address account) external view returns (uint256); /** * @dev Moves `amount` tokens from the caller's account to `to`. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transfer(address to, uint256 amount) external returns (bool); /** * @dev Returns the remaining number of tokens that `spender` will be * allowed to spend on behalf of `owner` through {transferFrom}. This is * zero by default. * * This value changes when {approve} or {transferFrom} are called. */ function allowance(address owner, address spender) external view returns (uint256); /** * @dev Sets `amount` as the allowance of `spender` over the caller's tokens. * * Returns a boolean value indicating whether the operation succeeded. * * IMPORTANT: Beware that changing an allowance with this method brings the risk * that someone may use both the old and the new allowance by unfortunate * transaction ordering. One possible solution to mitigate this race * condition is to first reduce the spender's allowance to 0 and set the * desired value afterwards: * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 * * Emits an {Approval} event. */ function approve(address spender, uint256 amount) external returns (bool); /** * @dev Moves `amount` tokens from `from` to `to` using the * allowance mechanism. `amount` is then deducted from the caller's * allowance. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transferFrom(address from, address to, uint256 amount) external returns (bool); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/Context.sol) pragma solidity ^0.8.0; /** * @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; } }
// SPDX-License-Identifier: MIT pragma solidity 0.8.23; import "../INonfungiblePositionManager.sol"; import "../ILightQuoterV3.sol"; interface ILiquidityManager { /** * @notice Represents information about a loan. * @dev This struct is used to store liquidity and tokenId for a loan. * @param liquidity The amount of liquidity for the loan represented by a uint128 value. * @param tokenId The token ID associated with the loan represented by a uint256 value. */ struct LoanInfo { uint128 liquidity; uint256 tokenId; } struct Amounts { uint256 amount0; uint256 amount1; } struct SqrtPriceLimitation { uint24 feeTier; uint160 sqrtPriceLimitX96; } /// @dev Struct containing parameters necessary for conducting a flash loan. /// @param protocol The identifier of the flash loan protocol (if 0, the flash loan is not used). /// @param data Arbitrary data that can be used by the flash loan protocol. struct FlashLoanParams { uint8 protocol; bytes data; } /// @dev Struct containing parameters for defining restoration routes, /// including the use of external swaps, fee tiers for internal swaps, and potential flash loan arrangements. /// @param strict If the flag strict is false, part of the profit or liquidation bonus can be used to close the position. /// @param tokenId The ID of the NFT-POS token that needs to be restored, if applicable. /// @param flashLoanParams An array of FlashLoanParams structs, detailing each flash loan involved in the route. struct FlashLoanRoutes { bool strict; FlashLoanParams[] flashLoanParams; } /** * @notice Contains parameters for restoring liquidity. * @dev This struct is used to store various parameters required for restoring liquidity. * @param zeroForSaleToken A boolean value indicating whether the token for sale is the 0th token or not. * @param totalfeesOwed The total fees owed represented by a uint256 value. * @param totalBorrowedAmount The total borrowed amount represented by a uint256 value. * @param routes An array of FlashLoanRoutes structs representing the restoration routes. * @param loans An array of LoanInfo structs representing the loans. */ struct RestoreLiquidityParams { bool zeroForSaleToken; uint256 totalfeesOwed; uint256 totalBorrowedAmount; FlashLoanRoutes routes; LoanInfo[] loans; } struct CallbackData { bool zeroForSaleToken; uint24 fee; int24 tickLower; int24 tickUpper; address saleToken; address holdToken; uint256 holdTokenDebt; uint256 vaultBodyDebt; uint256 vaultFeeDebt; Amounts amounts; LoanInfo loan; FlashLoanRoutes routes; } /** * @title NFT Position Cache Data Structure * @notice This struct holds the cache data necessary for restoring liquidity to an NFT position. * @dev Stores essential parameters for an NFT representing a position in a Uniswap-like pool. * @param tickLower The lower bound of the liquidity position's price range, represented as an int24. * @param tickUpper The upper bound of the liquidity position's price range, represented as an int24. * @param fee The fee tier of the Uniswap pool in which this liquidity will be restored, represented as a uint24. * @param liquidity The amount of NFT Position liquidity. * @param saleToken The ERC-20 sale token. * @param holdToken The ERC-20 hold token. * @param operator The address of the operator who is permitted to restore liquidity and manage this position. * @param holdTokenDebt The outstanding debt of the hold token that needs to be repaid when liquidity is restored, represented as a uint256. */ struct NftPositionCache { int24 tickLower; int24 tickUpper; uint24 fee; uint128 liquidity; address saleToken; address holdToken; address operator; uint256 holdTokenDebt; } function VAULT_ADDRESS() external view returns (address); function underlyingPositionManager() external view returns (INonfungiblePositionManager); function lightQuoterV3Address() external view returns (address); function flashLoanAggregatorAddress() external view returns (address); }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; interface IFlashLoanAggregator { function flashLoan(uint256 amount, bytes calldata data) external; }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /// @title Light Quoter Interface interface ILightQuoterV3 { /// @title Struct for "Zap In" Calculation Parameters /// @notice This struct encapsulates the various parameters required for calculating the exact amount of tokens to zap in. struct CalculateExactZapInParams { /// @notice The address of the swap pool where liquidity will be added. address swapPool; /// @notice A boolean determining which token will be used to add liquidity (true for token0 or false for token1). bool zeroForIn; /// @notice The lower bound of the tick range for the position within the pool. int24 tickLower; /// @notice The upper bound of the tick range for the position within the pool. int24 tickUpper; /// @notice The exact amount of liquidity to add to the pool. uint128 liquidityExactAmount; /// @notice The balance of the token that will be used to add liquidity. uint256 tokenInBalance; /// @notice The balance of the other token in the pool, not typically used for adding liquidity directly but necessary for calculations. uint256 tokenOutBalance; } /// @notice Calculates parameters related to "zapping in" to a position with an exact amount of liquidity. /// @dev Interacts with an on-chain liquidity pool to precisely estimate the amounts in/out to add liquidity. /// This calculation is performed using iterative methods to ensure the exactness of the resulting values. /// It uses the `getSqrtRatioAtTick` method within the loop to determine price bounds. /// This process is designed to avoid failure due to constraints such as limited input or other conditions. /// The number of iterations to reach an accurate result is bounded by a maximum value. /// @param params A `CalculateExactZapInParams` struct containing all necessary parameters to perform the calculations. /// This may include details about the liquidity pool, desired position, slippage tolerance, etc. /// @return swapAmountIn The exact total amount of input tokens required to complete the zap in operation. /// @return amount0 The exact amount of the token0 will be used for "zapping in" to a position. /// @return amount1 The exact amount of the token1 will be used for "zapping in" to a position. function calculateExactZapIn( CalculateExactZapInParams memory params ) external view returns (uint256 swapAmountIn, uint256 amount0, uint256 amount1); /** * @notice Quotes the output amount for a given input amount in a single token swap operation on Uniswap V3. * @dev This function simulates the swap and returns the estimated output amount. It does not execute the trade itself. * @param zeroForIn A boolean indicating the direction of the swap: * true for swapping the 0th token (token0) to the 1st token (token1), false for token1 to token0. * @param swapPool The address of the Uniswap V3 pool contract through which the swap will be simulated. * @param amountIn The amount of input tokens that one would like to swap. * @return sqrtPriceX96After The square root of the price after the swap, scaled by 2^96. This is the price between the two tokens in the pool post-simulation. * @return amountOut The amount of output tokens that can be expected to receive in the swap based on the current state of the pool. */ function quoteExactInputSingle( bool zeroForIn, address swapPool, uint256 amountIn ) external view returns (uint160 sqrtPriceX96After, uint256 amountOut); /** * @notice Quotes the amount of input tokens required to arrive at a specified output token amount for a single pool swap. * @dev This function performs a read-only operation to compute the necessary input amount and does not execute an actual swap. * It is useful for obtaining quotes prior to performing transactions. * @param zeroForIn A boolean that indicates the direction of the trade, true if swapping zero for in-token, false otherwise. * @param swapPool The address of the swap pool contract where the trade will take place. * @param amountOut The desired amount of output tokens. * @return sqrtPriceX96After The square root price (encoded as a 96-bit fixed point number) after the swap would occur. * @return amountIn The amount of input tokens required for the swap to achieve the desired `amountOut`. */ function quoteExactOutputSingle( bool zeroForIn, address swapPool, uint256 amountOut ) external view returns (uint160 sqrtPriceX96After, uint256 amountIn); }
// SPDX-License-Identifier: GPL-2.0-or-later pragma solidity 0.8.23; interface INonfungiblePositionManager { /// @notice Returns the position information associated with a given token ID. /// @dev Throws if the token ID is not valid. /// @param tokenId The ID of the token that represents the position /// @return nonce The nonce for permits /// @return operator The address that is approved for spending /// @return token0 The address of the token0 for a specific pool /// @return token1 The address of the token1 for a specific pool /// @return fee The fee associated with the pool /// @return tickLower The lower end of the tick range for the position /// @return tickUpper The higher end of the tick range for the position /// @return liquidity The liquidity of the position /// @return feeGrowthInside0LastX128 The fee growth of token0 as of the last action on the individual position /// @return feeGrowthInside1LastX128 The fee growth of token1 as of the last action on the individual position /// @return tokensOwed0 The uncollected amount of token0 owed to the position as of the last computation /// @return tokensOwed1 The uncollected amount of token1 owed to the position as of the last computation function positions( uint256 tokenId ) external view returns ( uint96 nonce, address operator, address token0, address token1, uint24 fee, int24 tickLower, int24 tickUpper, uint128 liquidity, uint256 feeGrowthInside0LastX128, uint256 feeGrowthInside1LastX128, uint128 tokensOwed0, uint128 tokensOwed1 ); struct MintParams { address token0; address token1; uint24 fee; int24 tickLower; int24 tickUpper; uint256 amount0Desired; uint256 amount1Desired; uint256 amount0Min; uint256 amount1Min; address recipient; uint256 deadline; } /// @notice Creates a new position wrapped in a NFT /// @dev Call this when the pool does exist and is initialized. Note that if the pool is created but not initialized /// a method does not exist, i.e. the pool is assumed to be initialized. /// @param params The params necessary to mint a position, encoded as `MintParams` in calldata /// @return tokenId The ID of the token that represents the minted position /// @return liquidity The amount of liquidity for this position /// @return amount0 The amount of token0 /// @return amount1 The amount of token1 function mint( MintParams calldata params ) external payable returns (uint256 tokenId, uint128 liquidity, uint256 amount0, uint256 amount1); struct IncreaseLiquidityParams { uint256 tokenId; uint256 amount0Desired; uint256 amount1Desired; uint256 amount0Min; uint256 amount1Min; uint256 deadline; } /// @notice Increases the amount of liquidity in a position, with tokens paid by the `msg.sender` /// @param params tokenId The ID of the token for which liquidity is being increased, /// amount0Desired The desired amount of token0 to be spent, /// amount1Desired The desired amount of token1 to be spent, /// amount0Min The minimum amount of token0 to spend, which serves as a slippage check, /// amount1Min The minimum amount of token1 to spend, which serves as a slippage check, /// deadline The time by which the transaction must be included to effect the change /// @return liquidity The new liquidity amount as a result of the increase /// @return amount0 The amount of token0 to acheive resulting liquidity /// @return amount1 The amount of token1 to acheive resulting liquidity function increaseLiquidity( IncreaseLiquidityParams calldata params ) external payable returns (uint128 liquidity, uint256 amount0, uint256 amount1); struct DecreaseLiquidityParams { uint256 tokenId; uint128 liquidity; uint256 amount0Min; uint256 amount1Min; uint256 deadline; } /// @notice Decreases the amount of liquidity in a position and accounts it to the position /// @param params tokenId The ID of the token for which liquidity is being decreased, /// amount The amount by which liquidity will be decreased, /// amount0Min The minimum amount of token0 that should be accounted for the burned liquidity, /// amount1Min The minimum amount of token1 that should be accounted for the burned liquidity, /// deadline The time by which the transaction must be included to effect the change /// @return amount0 The amount of token0 accounted to the position's tokens owed /// @return amount1 The amount of token1 accounted to the position's tokens owed function decreaseLiquidity( DecreaseLiquidityParams calldata params ) external payable returns (uint256 amount0, uint256 amount1); struct CollectParams { uint256 tokenId; address recipient; uint128 amount0Max; uint128 amount1Max; } /// @notice Collects up to a maximum amount of fees owed to a specific position to the recipient /// @param params tokenId The ID of the NFT for which tokens are being collected, /// recipient The account that should receive the tokens, /// amount0Max The maximum amount of token0 to collect, /// amount1Max The maximum amount of token1 to collect /// @return amount0 The amount of fees collected in token0 /// @return amount1 The amount of fees collected in token1 function collect( CollectParams calldata params ) external payable returns (uint256 amount0, uint256 amount1); /// @notice Burns a token ID, which deletes it from the NFT contract. The token must have 0 liquidity and all tokens /// must be collected first. /// @param tokenId The ID of the token that is being burned function burn(uint256 tokenId) external payable; /** * @notice from IERC721 * @dev Returns the owner of the `tokenId` token. * * Requirements: * * - `tokenId` must exist. */ function ownerOf(uint256 tokenId) external view returns (address owner); function approve(address to, uint256 tokenId) external; function getApproved(uint256 tokenId) external view returns (address); event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId); }
// SPDX-License-Identifier: GPL-2.0-or-later pragma solidity >=0.5.0; /// @title Callback for IUniswapV3PoolActions#flash /// @notice Any contract that calls IUniswapV3PoolActions#flash must implement this interface interface IUniswapV3FlashCallback { /// @notice Called to `msg.sender` after transferring to the recipient from IUniswapV3Pool#flash. /// @dev In the implementation you must repay the pool the tokens sent by flash plus the computed fee amounts. /// The caller of this method must be checked to be a UniswapV3Pool deployed by the canonical UniswapV3Factory. /// @param fee0 The fee amount in token0 due to the pool by the end of the flash /// @param fee1 The fee amount in token1 due to the pool by the end of the flash /// @param data Any data passed through by the caller via the IUniswapV3PoolActions#flash call function uniswapV3FlashCallback(uint256 fee0, uint256 fee1, bytes calldata data) external; }
// SPDX-License-Identifier: GPL-2.0-or-later pragma solidity >=0.5.0; import {IUniswapV3PoolImmutables} from './pool/IUniswapV3PoolImmutables.sol'; import {IUniswapV3PoolState} from './pool/IUniswapV3PoolState.sol'; import {IUniswapV3PoolDerivedState} from './pool/IUniswapV3PoolDerivedState.sol'; import {IUniswapV3PoolActions} from './pool/IUniswapV3PoolActions.sol'; import {IUniswapV3PoolOwnerActions} from './pool/IUniswapV3PoolOwnerActions.sol'; import {IUniswapV3PoolErrors} from './pool/IUniswapV3PoolErrors.sol'; import {IUniswapV3PoolEvents} from './pool/IUniswapV3PoolEvents.sol'; /// @title The interface for a Uniswap V3 Pool /// @notice A Uniswap pool facilitates swapping and automated market making between any two assets that strictly conform /// to the ERC20 specification /// @dev The pool interface is broken up into many smaller pieces interface IUniswapV3Pool is IUniswapV3PoolImmutables, IUniswapV3PoolState, IUniswapV3PoolDerivedState, IUniswapV3PoolActions, IUniswapV3PoolOwnerActions, IUniswapV3PoolErrors, IUniswapV3PoolEvents { }
// SPDX-License-Identifier: GPL-2.0-or-later pragma solidity ^0.8.0; interface IWagmiLeverageFlashCallback { function wagmiLeverageFlashCallback( uint256 bodyAmt, uint256 feeAmt, bytes calldata data ) external; }
// SPDX-License-Identifier: GPL-2.0-or-later pragma solidity >=0.5.0; /// @title Permissionless pool actions /// @notice Contains pool methods that can be called by anyone interface IUniswapV3PoolActions { /// @notice Sets the initial price for the pool /// @dev Price is represented as a sqrt(amountToken1/amountToken0) Q64.96 value /// @param sqrtPriceX96 the initial sqrt price of the pool as a Q64.96 function initialize(uint160 sqrtPriceX96) external; /// @notice Adds liquidity for the given recipient/tickLower/tickUpper position /// @dev The caller of this method receives a callback in the form of IUniswapV3MintCallback#uniswapV3MintCallback /// in which they must pay any token0 or token1 owed for the liquidity. The amount of token0/token1 due depends /// on tickLower, tickUpper, the amount of liquidity, and the current price. /// @param recipient The address for which the liquidity will be created /// @param tickLower The lower tick of the position in which to add liquidity /// @param tickUpper The upper tick of the position in which to add liquidity /// @param amount The amount of liquidity to mint /// @param data Any data that should be passed through to the callback /// @return amount0 The amount of token0 that was paid to mint the given amount of liquidity. Matches the value in the callback /// @return amount1 The amount of token1 that was paid to mint the given amount of liquidity. Matches the value in the callback function mint( address recipient, int24 tickLower, int24 tickUpper, uint128 amount, bytes calldata data ) external returns (uint256 amount0, uint256 amount1); /// @notice Collects tokens owed to a position /// @dev Does not recompute fees earned, which must be done either via mint or burn of any amount of liquidity. /// Collect must be called by the position owner. To withdraw only token0 or only token1, amount0Requested or /// amount1Requested may be set to zero. To withdraw all tokens owed, caller may pass any value greater than the /// actual tokens owed, e.g. type(uint128).max. Tokens owed may be from accumulated swap fees or burned liquidity. /// @param recipient The address which should receive the fees collected /// @param tickLower The lower tick of the position for which to collect fees /// @param tickUpper The upper tick of the position for which to collect fees /// @param amount0Requested How much token0 should be withdrawn from the fees owed /// @param amount1Requested How much token1 should be withdrawn from the fees owed /// @return amount0 The amount of fees collected in token0 /// @return amount1 The amount of fees collected in token1 function collect( address recipient, int24 tickLower, int24 tickUpper, uint128 amount0Requested, uint128 amount1Requested ) external returns (uint128 amount0, uint128 amount1); /// @notice Burn liquidity from the sender and account tokens owed for the liquidity to the position /// @dev Can be used to trigger a recalculation of fees owed to a position by calling with an amount of 0 /// @dev Fees must be collected separately via a call to #collect /// @param tickLower The lower tick of the position for which to burn liquidity /// @param tickUpper The upper tick of the position for which to burn liquidity /// @param amount How much liquidity to burn /// @return amount0 The amount of token0 sent to the recipient /// @return amount1 The amount of token1 sent to the recipient function burn( int24 tickLower, int24 tickUpper, uint128 amount ) external returns (uint256 amount0, uint256 amount1); /// @notice Swap token0 for token1, or token1 for token0 /// @dev The caller of this method receives a callback in the form of IUniswapV3SwapCallback#uniswapV3SwapCallback /// @param recipient The address to receive the output of the swap /// @param zeroForOne The direction of the swap, true for token0 to token1, false for token1 to token0 /// @param amountSpecified The amount of the swap, which implicitly configures the swap as exact input (positive), or exact output (negative) /// @param sqrtPriceLimitX96 The Q64.96 sqrt price limit. If zero for one, the price cannot be less than this /// value after the swap. If one for zero, the price cannot be greater than this value after the swap /// @param data Any data to be passed through to the callback /// @return amount0 The delta of the balance of token0 of the pool, exact when negative, minimum when positive /// @return amount1 The delta of the balance of token1 of the pool, exact when negative, minimum when positive function swap( address recipient, bool zeroForOne, int256 amountSpecified, uint160 sqrtPriceLimitX96, bytes calldata data ) external returns (int256 amount0, int256 amount1); /// @notice Receive token0 and/or token1 and pay it back, plus a fee, in the callback /// @dev The caller of this method receives a callback in the form of IUniswapV3FlashCallback#uniswapV3FlashCallback /// @dev Can be used to donate underlying tokens pro-rata to currently in-range liquidity providers by calling /// with 0 amount{0,1} and sending the donation amount(s) from the callback /// @param recipient The address which will receive the token0 and token1 amounts /// @param amount0 The amount of token0 to send /// @param amount1 The amount of token1 to send /// @param data Any data to be passed through to the callback function flash( address recipient, uint256 amount0, uint256 amount1, bytes calldata data ) external; /// @notice Increase the maximum number of price and liquidity observations that this pool will store /// @dev This method is no-op if the pool already has an observationCardinalityNext greater than or equal to /// the input observationCardinalityNext. /// @param observationCardinalityNext The desired minimum number of observations for the pool to store function increaseObservationCardinalityNext(uint16 observationCardinalityNext) external; }
// SPDX-License-Identifier: GPL-2.0-or-later pragma solidity >=0.5.0; /// @title Pool state that is not stored /// @notice Contains view functions to provide information about the pool that is computed rather than stored on the /// blockchain. The functions here may have variable gas costs. interface IUniswapV3PoolDerivedState { /// @notice Returns the cumulative tick and liquidity as of each timestamp `secondsAgo` from the current block timestamp /// @dev To get a time weighted average tick or liquidity-in-range, you must call this with two values, one representing /// the beginning of the period and another for the end of the period. E.g., to get the last hour time-weighted average tick, /// you must call it with secondsAgos = [3600, 0]. /// @dev The time weighted average tick represents the geometric time weighted average price of the pool, in /// log base sqrt(1.0001) of token1 / token0. The TickMath library can be used to go from a tick value to a ratio. /// @param secondsAgos From how long ago each cumulative tick and liquidity value should be returned /// @return tickCumulatives Cumulative tick values as of each `secondsAgos` from the current block timestamp /// @return secondsPerLiquidityCumulativeX128s Cumulative seconds per liquidity-in-range value as of each `secondsAgos` from the current block /// timestamp function observe(uint32[] calldata secondsAgos) external view returns (int56[] memory tickCumulatives, uint160[] memory secondsPerLiquidityCumulativeX128s); /// @notice Returns a snapshot of the tick cumulative, seconds per liquidity and seconds inside a tick range /// @dev Snapshots must only be compared to other snapshots, taken over a period for which a position existed. /// I.e., snapshots cannot be compared if a position is not held for the entire period between when the first /// snapshot is taken and the second snapshot is taken. /// @param tickLower The lower tick of the range /// @param tickUpper The upper tick of the range /// @return tickCumulativeInside The snapshot of the tick accumulator for the range /// @return secondsPerLiquidityInsideX128 The snapshot of seconds per liquidity for the range /// @return secondsInside The snapshot of seconds per liquidity for the range function snapshotCumulativesInside(int24 tickLower, int24 tickUpper) external view returns ( int56 tickCumulativeInside, uint160 secondsPerLiquidityInsideX128, uint32 secondsInside ); }
// SPDX-License-Identifier: GPL-2.0-or-later pragma solidity >=0.5.0; /// @title Errors emitted by a pool /// @notice Contains all events emitted by the pool interface IUniswapV3PoolErrors { error LOK(); error TLU(); error TLM(); error TUM(); error AI(); error M0(); error M1(); error AS(); error IIA(); error L(); error F0(); error F1(); }
// SPDX-License-Identifier: GPL-2.0-or-later pragma solidity >=0.5.0; /// @title Events emitted by a pool /// @notice Contains all events emitted by the pool interface IUniswapV3PoolEvents { /// @notice Emitted exactly once by a pool when #initialize is first called on the pool /// @dev Mint/Burn/Swap cannot be emitted by the pool before Initialize /// @param sqrtPriceX96 The initial sqrt price of the pool, as a Q64.96 /// @param tick The initial tick of the pool, i.e. log base 1.0001 of the starting price of the pool event Initialize(uint160 sqrtPriceX96, int24 tick); /// @notice Emitted when liquidity is minted for a given position /// @param sender The address that minted the liquidity /// @param owner The owner of the position and recipient of any minted liquidity /// @param tickLower The lower tick of the position /// @param tickUpper The upper tick of the position /// @param amount The amount of liquidity minted to the position range /// @param amount0 How much token0 was required for the minted liquidity /// @param amount1 How much token1 was required for the minted liquidity event Mint( address sender, address indexed owner, int24 indexed tickLower, int24 indexed tickUpper, uint128 amount, uint256 amount0, uint256 amount1 ); /// @notice Emitted when fees are collected by the owner of a position /// @dev Collect events may be emitted with zero amount0 and amount1 when the caller chooses not to collect fees /// @param owner The owner of the position for which fees are collected /// @param tickLower The lower tick of the position /// @param tickUpper The upper tick of the position /// @param amount0 The amount of token0 fees collected /// @param amount1 The amount of token1 fees collected event Collect( address indexed owner, address recipient, int24 indexed tickLower, int24 indexed tickUpper, uint128 amount0, uint128 amount1 ); /// @notice Emitted when a position's liquidity is removed /// @dev Does not withdraw any fees earned by the liquidity position, which must be withdrawn via #collect /// @param owner The owner of the position for which liquidity is removed /// @param tickLower The lower tick of the position /// @param tickUpper The upper tick of the position /// @param amount The amount of liquidity to remove /// @param amount0 The amount of token0 withdrawn /// @param amount1 The amount of token1 withdrawn event Burn( address indexed owner, int24 indexed tickLower, int24 indexed tickUpper, uint128 amount, uint256 amount0, uint256 amount1 ); /// @notice Emitted by the pool for any swaps between token0 and token1 /// @param sender The address that initiated the swap call, and that received the callback /// @param recipient The address that received the output of the swap /// @param amount0 The delta of the token0 balance of the pool /// @param amount1 The delta of the token1 balance of the pool /// @param sqrtPriceX96 The sqrt(price) of the pool after the swap, as a Q64.96 /// @param liquidity The liquidity of the pool after the swap /// @param tick The log base 1.0001 of price of the pool after the swap event Swap( address indexed sender, address indexed recipient, int256 amount0, int256 amount1, uint160 sqrtPriceX96, uint128 liquidity, int24 tick ); /// @notice Emitted by the pool for any flashes of token0/token1 /// @param sender The address that initiated the swap call, and that received the callback /// @param recipient The address that received the tokens from flash /// @param amount0 The amount of token0 that was flashed /// @param amount1 The amount of token1 that was flashed /// @param paid0 The amount of token0 paid for the flash, which can exceed the amount0 plus the fee /// @param paid1 The amount of token1 paid for the flash, which can exceed the amount1 plus the fee event Flash( address indexed sender, address indexed recipient, uint256 amount0, uint256 amount1, uint256 paid0, uint256 paid1 ); /// @notice Emitted by the pool for increases to the number of observations that can be stored /// @dev observationCardinalityNext is not the observation cardinality until an observation is written at the index /// just before a mint/swap/burn. /// @param observationCardinalityNextOld The previous value of the next observation cardinality /// @param observationCardinalityNextNew The updated value of the next observation cardinality event IncreaseObservationCardinalityNext( uint16 observationCardinalityNextOld, uint16 observationCardinalityNextNew ); /// @notice Emitted when the protocol fee is changed by the pool /// @param feeProtocol0Old The previous value of the token0 protocol fee /// @param feeProtocol1Old The previous value of the token1 protocol fee /// @param feeProtocol0New The updated value of the token0 protocol fee /// @param feeProtocol1New The updated value of the token1 protocol fee event SetFeeProtocol(uint8 feeProtocol0Old, uint8 feeProtocol1Old, uint8 feeProtocol0New, uint8 feeProtocol1New); /// @notice Emitted when the collected protocol fees are withdrawn by the factory owner /// @param sender The address that collects the protocol fees /// @param recipient The address that receives the collected protocol fees /// @param amount0 The amount of token0 protocol fees that is withdrawn /// @param amount0 The amount of token1 protocol fees that is withdrawn event CollectProtocol(address indexed sender, address indexed recipient, uint128 amount0, uint128 amount1); }
// SPDX-License-Identifier: GPL-2.0-or-later pragma solidity >=0.5.0; /// @title Pool state that never changes /// @notice These parameters are fixed for a pool forever, i.e., the methods will always return the same values interface IUniswapV3PoolImmutables { /// @notice The contract that deployed the pool, which must adhere to the IUniswapV3Factory interface /// @return The contract address function factory() external view returns (address); /// @notice The first of the two tokens of the pool, sorted by address /// @return The token contract address function token0() external view returns (address); /// @notice The second of the two tokens of the pool, sorted by address /// @return The token contract address function token1() external view returns (address); /// @notice The pool's fee in hundredths of a bip, i.e. 1e-6 /// @return The fee function fee() external view returns (uint24); /// @notice The pool tick spacing /// @dev Ticks can only be used at multiples of this value, minimum of 1 and always positive /// e.g.: a tickSpacing of 3 means ticks can be initialized every 3rd tick, i.e., ..., -6, -3, 0, 3, 6, ... /// This value is an int24 to avoid casting even though it is always positive. /// @return The tick spacing function tickSpacing() external view returns (int24); /// @notice The maximum amount of position liquidity that can use any tick in the range /// @dev This parameter is enforced per tick to prevent liquidity from overflowing a uint128 at any point, and /// also prevents out-of-range liquidity from being used to prevent adding in-range liquidity to a pool /// @return The max amount of liquidity per tick function maxLiquidityPerTick() external view returns (uint128); }
// SPDX-License-Identifier: GPL-2.0-or-later pragma solidity >=0.5.0; /// @title Permissioned pool actions /// @notice Contains pool methods that may only be called by the factory owner interface IUniswapV3PoolOwnerActions { /// @notice Set the denominator of the protocol's % share of the fees /// @param feeProtocol0 new protocol fee for token0 of the pool /// @param feeProtocol1 new protocol fee for token1 of the pool function setFeeProtocol(uint8 feeProtocol0, uint8 feeProtocol1) external; /// @notice Collect the protocol fee accrued to the pool /// @param recipient The address to which collected protocol fees should be sent /// @param amount0Requested The maximum amount of token0 to send, can be 0 to collect fees in only token1 /// @param amount1Requested The maximum amount of token1 to send, can be 0 to collect fees in only token0 /// @return amount0 The protocol fee collected in token0 /// @return amount1 The protocol fee collected in token1 function collectProtocol( address recipient, uint128 amount0Requested, uint128 amount1Requested ) external returns (uint128 amount0, uint128 amount1); }
// SPDX-License-Identifier: GPL-2.0-or-later pragma solidity >=0.5.0; /// @title Pool state that can change /// @notice These methods compose the pool's state, and can change with any frequency including multiple times /// per transaction interface IUniswapV3PoolState { /// @notice The 0th storage slot in the pool stores many values, and is exposed as a single method to save gas /// when accessed externally. /// @return sqrtPriceX96 The current price of the pool as a sqrt(token1/token0) Q64.96 value /// @return tick The current tick of the pool, i.e. according to the last tick transition that was run. /// This value may not always be equal to SqrtTickMath.getTickAtSqrtRatio(sqrtPriceX96) if the price is on a tick /// boundary. /// @return observationIndex The index of the last oracle observation that was written, /// @return observationCardinality The current maximum number of observations stored in the pool, /// @return observationCardinalityNext The next maximum number of observations, to be updated when the observation. /// @return feeProtocol The protocol fee for both tokens of the pool. /// Encoded as two 4 bit values, where the protocol fee of token1 is shifted 4 bits and the protocol fee of token0 /// is the lower 4 bits. Used as the denominator of a fraction of the swap fee, e.g. 4 means 1/4th of the swap fee. /// unlocked Whether the pool is currently locked to reentrancy function slot0() external view returns ( uint160 sqrtPriceX96, int24 tick, uint16 observationIndex, uint16 observationCardinality, uint16 observationCardinalityNext, uint8 feeProtocol, bool unlocked ); /// @notice The fee growth as a Q128.128 fees of token0 collected per unit of liquidity for the entire life of the pool /// @dev This value can overflow the uint256 function feeGrowthGlobal0X128() external view returns (uint256); /// @notice The fee growth as a Q128.128 fees of token1 collected per unit of liquidity for the entire life of the pool /// @dev This value can overflow the uint256 function feeGrowthGlobal1X128() external view returns (uint256); /// @notice The amounts of token0 and token1 that are owed to the protocol /// @dev Protocol fees will never exceed uint128 max in either token function protocolFees() external view returns (uint128 token0, uint128 token1); /// @notice The currently in range liquidity available to the pool /// @dev This value has no relationship to the total liquidity across all ticks /// @return The liquidity at the current price of the pool function liquidity() external view returns (uint128); /// @notice Look up information about a specific tick in the pool /// @param tick The tick to look up /// @return liquidityGross the total amount of position liquidity that uses the pool either as tick lower or /// tick upper /// @return liquidityNet how much liquidity changes when the pool price crosses the tick, /// @return feeGrowthOutside0X128 the fee growth on the other side of the tick from the current tick in token0, /// @return feeGrowthOutside1X128 the fee growth on the other side of the tick from the current tick in token1, /// @return tickCumulativeOutside the cumulative tick value on the other side of the tick from the current tick /// @return secondsPerLiquidityOutsideX128 the seconds spent per liquidity on the other side of the tick from the current tick, /// @return secondsOutside the seconds spent on the other side of the tick from the current tick, /// @return initialized Set to true if the tick is initialized, i.e. liquidityGross is greater than 0, otherwise equal to false. /// Outside values can only be used if the tick is initialized, i.e. if liquidityGross is greater than 0. /// In addition, these values are only relative and must be used only in comparison to previous snapshots for /// a specific position. function ticks(int24 tick) external view returns ( uint128 liquidityGross, int128 liquidityNet, uint256 feeGrowthOutside0X128, uint256 feeGrowthOutside1X128, int56 tickCumulativeOutside, uint160 secondsPerLiquidityOutsideX128, uint32 secondsOutside, bool initialized ); /// @notice Returns 256 packed tick initialized boolean values. See TickBitmap for more information function tickBitmap(int16 wordPosition) external view returns (uint256); /// @notice Returns the information about a position by the position's key /// @param key The position's key is a hash of a preimage composed by the owner, tickLower and tickUpper /// @return liquidity The amount of liquidity in the position, /// @return feeGrowthInside0LastX128 fee growth of token0 inside the tick range as of the last mint/burn/poke, /// @return feeGrowthInside1LastX128 fee growth of token1 inside the tick range as of the last mint/burn/poke, /// @return tokensOwed0 the computed amount of token0 owed to the position as of the last mint/burn/poke, /// @return tokensOwed1 the computed amount of token1 owed to the position as of the last mint/burn/poke function positions(bytes32 key) external view returns ( uint128 liquidity, uint256 feeGrowthInside0LastX128, uint256 feeGrowthInside1LastX128, uint128 tokensOwed0, uint128 tokensOwed1 ); /// @notice Returns data about a specific observation index /// @param index The element of the observations array to fetch /// @dev You most likely want to use #observe() instead of this method to get an observation as of some amount of time /// ago, rather than at a specific index in the array. /// @return blockTimestamp The timestamp of the observation, /// @return tickCumulative the tick multiplied by seconds elapsed for the life of the pool as of the observation timestamp, /// @return secondsPerLiquidityCumulativeX128 the seconds per in range liquidity for the life of the pool as of the observation timestamp, /// @return initialized whether the observation has been initialized and the values are safe to use function observations(uint256 index) external view returns ( uint32 blockTimestamp, int56 tickCumulative, uint160 secondsPerLiquidityCumulativeX128, bool initialized ); }
// SPDX-License-Identifier: GPL-2.0-or-later // https://github.com/Uniswap/v3-periphery/blob/main/contracts/libraries/TransferHelper.sol pragma solidity 0.8.23; import "@openzeppelin/contracts/token/ERC20/IERC20.sol"; library TransferHelper { /// @notice Transfers tokens from the targeted address to the given destination /// @notice Errors with 'STF' if transfer fails /// @param token The contract address of the token to be transferred /// @param from The originating address from which the tokens will be transferred /// @param to The destination address of the transfer /// @param value The amount to be transferred function safeTransferFrom(address token, address from, address to, uint256 value) internal { (bool success, bytes memory data) = token.call( abi.encodeWithSelector(IERC20.transferFrom.selector, from, to, value) ); require(success && (data.length == 0 || abi.decode(data, (bool))), "W-STF"); } /// @notice Transfers tokens from msg.sender to a recipient /// @dev Errors with ST if transfer fails /// @param token The contract address of the token which will be transferred /// @param to The recipient of the transfer /// @param value The value of the transfer function safeTransfer(address token, address to, uint256 value) internal { (bool success, bytes memory data) = token.call( abi.encodeWithSelector(IERC20.transfer.selector, to, value) ); require(success && (data.length == 0 || abi.decode(data, (bool))), "W-ST"); } function getBalance(address token) internal view returns (uint256 balance) { bytes memory callData = abi.encodeWithSelector(IERC20.balanceOf.selector, address(this)); (bool success, bytes memory data) = token.staticcall(callData); require(success && data.length >= 32); balance = abi.decode(data, (uint256)); } function getBalanceOf(address token, address target) internal view returns (uint256 balance) { bytes memory callData = abi.encodeWithSelector(IERC20.balanceOf.selector, target); (bool success, bytes memory data) = token.staticcall(callData); require(success && data.length >= 32); balance = abi.decode(data, (uint256)); } }
{ "viaIR": true, "evmVersion": "paris", "optimizer": { "enabled": true, "runs": 999 }, "metadata": { "bytecodeHash": "none" }, "outputSelection": { "*": { "*": [ "evm.bytecode", "evm.deployedBytecode", "devdoc", "userdoc", "metadata", "abi" ] } }, "libraries": {} }
Contract Security Audit
- No Contract Security Audit Submitted- Submit Audit Here
[{"inputs":[{"internalType":"address","name":"aaveAddressProvider","type":"address"},{"internalType":"address","name":"factoryV3","type":"address"},{"internalType":"bytes32","name":"initCodeHash","type":"bytes32"},{"internalType":"string","name":"name","type":"string"}],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[{"internalType":"uint256","name":"desiredAmount","type":"uint256"},{"internalType":"uint256","name":"collectedAmount","type":"uint256"}],"name":"CollectedAmountIsNotEnough","type":"error"},{"inputs":[],"name":"FlashLoanAaveZeroLiquidity","type":"error"},{"inputs":[{"internalType":"address","name":"pool","type":"address"}],"name":"FlashLoanZeroLiquidity","type":"error"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"previousOwner","type":"address"},{"indexed":true,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnershipTransferred","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"factoryV3","type":"address"},{"indexed":false,"internalType":"bytes32","name":"initCodeHash","type":"bytes32"},{"indexed":false,"internalType":"string","name":"name","type":"string"}],"name":"UniswapV3DexAdded","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"factoryV3","type":"address"},{"indexed":false,"internalType":"bytes32","name":"initCodeHash","type":"bytes32"},{"indexed":false,"internalType":"string","name":"name","type":"string"}],"name":"UniswapV3DexChanged","type":"event"},{"inputs":[],"name":"ADDRESSES_PROVIDER","outputs":[{"internalType":"contract IPoolAddressesProvider","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"POOL","outputs":[{"internalType":"contract IPool","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"factoryV3","type":"address"},{"internalType":"bytes32","name":"initCodeHash","type":"bytes32"},{"internalType":"string","name":"name","type":"string"}],"name":"addUniswapV3Dex","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"fee0","type":"uint256"},{"internalType":"uint256","name":"fee1","type":"uint256"},{"internalType":"bytes","name":"data","type":"bytes"}],"name":"algebraFlashCallback","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"asset","type":"address"}],"name":"checkAaveFlashReserve","outputs":[{"internalType":"uint256","name":"amount","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bool","name":"enabled","type":"bool"},{"internalType":"address","name":"factoryV3","type":"address"},{"internalType":"bytes32","name":"initCodeHash","type":"bytes32"},{"internalType":"uint256","name":"indx","type":"uint256"}],"name":"editUniswapV3Dex","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"uint256","name":"premium","type":"uint256"},{"internalType":"address","name":"initiator","type":"address"},{"internalType":"bytes","name":"data","type":"bytes"}],"name":"executeOperation","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"bytes","name":"data","type":"bytes"}],"name":"flashLoan","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"aaveAddressProvider","type":"address"}],"name":"initAave","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"fee0","type":"uint256"},{"internalType":"uint256","name":"fee1","type":"uint256"},{"internalType":"bytes","name":"data","type":"bytes"}],"name":"pancakeV3FlashCallback","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_wagmiLeverageAddress","type":"address"}],"name":"setWagmiLeverageAddress","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"name":"uniswapDexIsExists","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"uniswapV3Dexes","outputs":[{"internalType":"bool","name":"enabled","type":"bool"},{"internalType":"address","name":"factoryV3","type":"address"},{"internalType":"bytes32","name":"initCodeHash","type":"bytes32"},{"internalType":"string","name":"name","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"fee0","type":"uint256"},{"internalType":"uint256","name":"fee1","type":"uint256"},{"internalType":"bytes","name":"data","type":"bytes"}],"name":"uniswapV3FlashCallback","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"version","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"wagmiLeverageContracts","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"}]
Contract Creation Code
6080806040523462000380576200328e8038038091620000208285620004ca565b833981019060808183031262000380576200003b81620004ee565b906200004a60208201620004ee565b6040820151606083015190926001600160401b03821162000380570184601f82011215620003805780516001600160401b0381116200049e57604051956200009d601f8301601f191660200188620004ca565b818752602082840101116200038057620000be916020808801910162000503565b60008054336001600160a01b03198216811783556040519290916001600160a01b0316907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09080a36020810190620001316020828851620001238187858d0162000503565b8101038084520182620004ca565b5190206040519490608086016001600160401b038111878210176200049e576040908152600187526001600160a01b0384166020880152860184905260608601829052600354680100000000000000008110156200049e576001810180600355811015620004b4576060906003600052600360206000209102019680511515885460ff610100600160a81b03602085015160081b1692169060018060a81b0319161717885560408101516001890155015195865160018060401b0381116200049e576002820154600181811c9116801562000493575b60208210146200047d57601f811162000431575b506020601f8211600114620003a65781608096959493926002926000805160206200326e8339815191529a9b6000926200039a575b50508160011b916000199060031b1c1916179101555b60005260046020526040600020600160ff1982541617905560405193849260018060a01b03168352602083015260606040830152620002b5815180928160608601526020868601910162000503565b601f01601f19168101030190a16001600160a01b031680620002e2575b604051612d459081620005298239f35b600180546001600160a01b0319168217905560405163026b1d5f60e01b815290602090829060049082905afa9081156200038e5760009162000347575b50600280546001600160a01b0319166001600160a01b039290921691909117905538620002d2565b90506020813d60201162000385575b816200036560209383620004ca565b8101031262000380576200037990620004ee565b386200031f565b600080fd5b3d915062000356565b6040513d6000823e3d90fd5b01519050388062000250565b6002830160005260206000209860005b601f1984168110620004185750826000805160206200326e833981519152999a60029360019360809a99989796601f19811610620003fe575b505050811b0191015562000266565b015160001960f88460031b161c19169055388080620003ef565b828201518b556001909a019960209283019201620003b6565b600283016000526020600020601f830160051c81016020841062000475575b601f830160051c82018110620004685750506200021b565b6000815560010162000450565b508062000450565b634e487b7160e01b600052602260045260246000fd5b90607f169062000207565b634e487b7160e01b600052604160045260246000fd5b634e487b7160e01b600052603260045260246000fd5b601f909101601f19168101906001600160401b038211908210176200049e57604052565b51906001600160a01b03821682036200038057565b60005b838110620005175750506000910152565b81810151838201526020016200050656fe608080604052600436101561001357600080fd5b600090813560e01c9081630542975c146111dc575080631b11d0ff1461115a5780635296a43114610a7a57806354fd4d5014610a5e578063660c27b414610a21578063715018a6146109ba5780637535d24614610993578063838429931461077c5780638c97b2c51461041f5780638da5cb5b146103f9578063a1d48336146102da578063a60b0d3c146102da578063b0fb0c3a1461037e578063b6996a0014610352578063bfce5ef91461030e578063e99b3267146102df578063e9cbafb0146102da578063f2fde38b146101f35763fd5acea2146100f257600080fd5b346101f05760203660031901126101f05761010b611201565b6101136129f4565b6001600160a01b0380911680156101ec57600254918083166101e85760015491602085600473ffffffffffffffffffffffffffffffffffffffff1995848782161760015560405194859384927f026b1d5f00000000000000000000000000000000000000000000000000000000845216175afa9081156101dd57859161019f575b501691161760025580f35b90506020813d6020116101d5575b816101ba602093836113f1565b810103126101d1576101cb90611772565b38610194565b8480fd5b3d91506101ad565b6040513d87823e3d90fd5b8380fd5b8280fd5b80fd5b50346101f05760203660031901126101f05761020d611201565b6102156129f4565b6001600160a01b03809116908115610270576000548273ffffffffffffffffffffffffffffffffffffffff19821617600055167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0600080a380f35b608460405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201527f64647265737300000000000000000000000000000000000000000000000000006064820152fd5b611266565b50346101f05760203660031901126101f05760ff60406020926004358152600484522054166040519015158152f35b50346101f05760203660031901126101f0576001600160a01b03610330611201565b6103386129f4565b168152600560205260408120805460ff1916600117905580f35b50346101f05760203660031901126101f0576020610376610371611201565b611786565b604051908152f35b50346101f05760203660031901126101f057600435906003548210156101f0576001600160a01b036103af836112b0565b506103f58154916103c7600260018301549201611413565b90604051948460ff8796161515865260081c16602085015260408401526080606084015260808301906114db565b0390f35b50346101f057806003193601126101f0576001600160a01b036020915416604051908152f35b50346101f05760603660031901126101f057610439611201565b906024356044359267ffffffffffffffff938481116101e85761046090369060040161122b565b909261046a6129f4565b60405193602094858101908483833761049187828781018b838201520380845201826113f1565b519020928387526004865260ff60408820541661073857906104b4913691611542565b91604051906104c282611389565b600191828152868101906001600160a01b0380971696878352604082019086825260608301938885526003546801000000000000000081101561072457808861050e92016003556112b0565b9490946107115791610573916105376002969594511515869060ff801983541691151516179055565b51845474ffffffffffffffffffffffffffffffffffffffff001916911660081b74ffffffffffffffffffffffffffffffffffffffff0016178355565b51858201550190519889519081116106fd5761058f8254611300565b601f81116106b7575b5087601f821160011461062f57908061061e9796959493928b9c7f569b40a786964672ecd152251cbbbbe68ec24b3c562ac9fb70643a0b760804c99c92610624575b5050600019600383901b1c191690841b1790555b885260048652604088209060ff1982541617905560405194859485528401526060604084015260608301906114db565b0390a180f35b0151905038806105da565b828a52888a2090601f1983168b5b8181106106a257509183917f569b40a786964672ecd152251cbbbbe68ec24b3c562ac9fb70643a0b760804c99c9d8897969561061e9b9a999510610689575b505050811b0190556105ee565b015160001960f88460031b161c1916905538808061067c565b8d830151845592870192918b01918b0161063d565b828a52888a20601f830160051c8101918a84106106f3575b601f0160051c019085905b8281106106e8575050610598565b8b81550185906106da565b90915081906106cf565b602489634e487b7160e01b81526041600452fd5b60248d634e487b7160e01b815280600452fd5b60248d634e487b7160e01b81526041600452fd5b6064866040519062461bcd60e51b82526004820152600260248201527f44450000000000000000000000000000000000000000000000000000000000006044820152fd5b50346101f05760809060806003193601126101f05760043591821515830361098e57602435906001600160a01b0382169182810361098e57604435906064359081600354111561094a576107f16107dd61082d936107d86129f4565b6112b0565b5097889060ff801983541691151516179055565b865474ffffffffffffffffffffffffffffffffffffffff00191660089190911b74ffffffffffffffffffffffffffffffffffffffff0016178655565b60026001958260018201550190604051938452602090602085015260606040850152849582549261085d84611300565b9384606088015260018116908160001461090057506001146108a4575b867fcbd42c34d643031323994ef2ae70464a950cbbc6e8eafe97baad6f6365114962878a0388a180f35b86526020862095965086955b8388106108ed57505050509281016080019250807fcbd42c34d643031323994ef2ae70464a950cbbc6e8eafe97baad6f636511496238808061087a565b80548689018601529682019681016108b0565b925050507fcbd42c34d643031323994ef2ae70464a950cbbc6e8eafe97baad6f6365114962959650849350608092915060ff191682840152151560051b820101939238808061087a565b606460405162461bcd60e51b815260206004820152600260248201527f49490000000000000000000000000000000000000000000000000000000000006044820152fd5b600080fd5b50346101f057806003193601126101f05760206001600160a01b0360025416604051908152f35b50346101f057806003193601126101f0576109d36129f4565b60006001600160a01b03815473ffffffffffffffffffffffffffffffffffffffff1981168355167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e08280a380f35b50346101f05760203660031901126101f05760ff60406020926001600160a01b03610a4a611201565b168152600584522054166040519015158152f35b50346101f057806003193601126101f057602060405160018152f35b50346101f05760403660031901126101f05760243567ffffffffffffffff811161111257610aac90369060040161122b565b919091338252600560205260ff6040832054161561111657602083828101031261111257823567ffffffffffffffff81116101ec5783018082850103906101c082126101e85760405190610aff8261133a565b610b0881611259565b8252602081013562ffffff8116810361110a576020830152610b2c60408201611500565b6040830152610b3d60608201611500565b6060830152610b4e60808201611217565b9260808301938452610b6260a08301611217565b60a084015260c082013560c084015260e082013560e0840152610100808301359084015261012090604061011f19820112611106576040908151610ba58161136d565b8484013581526101408086013560208301529386015261015f19011261110a5760405190610bd28261136d565b6101608301356fffffffffffffffffffffffffffffffff8116810361110e57825261018083013560208301528301526101a08101359067ffffffffffffffff821161110a57019060408285880103126101d15760405190610c328261136d565b610c3b83611259565b8252602083013567ffffffffffffffff811161110657858801601f828601011215611106578084013590610c6e8261150e565b94610c7c60405196876113f1565b8286526020860191888b0160208560051b83850101011161110257602081830101925b60208560051b8385010101841061105e57505050505061016090602083019384520152519384511561101a57610d0d610ce460ff610cdc88611597565b5151166115b8565b95805192610cf18461150e565b93610cff60405195866113f1565b808552601f1993849161150e565b01875b818110610feb5750506001600160a01b0395610d2e87875116612636565b9260038a1015610fd7578960018a9b14600014610e2f5750610dc9959492610dd59492610d81610d73610db5946020610d6a8e8e511692611597565b5101519061269c565b998a8c60043592511661283e565b9a9099169660405194610d93866113a5565b3386528c60208701526004356040870152606086015260808501523691611542565b60a0820152604051948591602083016115dd565b039081018452836113f1565b803b156101d157610e0193858094604051968795869485936312439b2f60e21b85523060048601611706565b03925af18015610e2457610e1457505080f35b610e1d906113c1565b6101f05780f35b6040513d84823e3d90fd5b905060029196985096929493919614600014610f92578160025416938415610f4e57610e5d83895116611786565b978815610f24578997610ec697610ed295610eb29351169a8060043511600014610f1a57965b60405194610e90866113a5565b3386528b60208701526004356040870152606086015260808501523691611542565b60a0820152604051958691602083016115dd565b039081018552846113f1565b813b156101e85783610efc95604051968795869485936310ac2ddf60e21b855230600486016116cc565b03925af18015610e2457610f0e575080f35b610f17906113c1565b80f35b5060043596610e83565b60046040517ff7f59316000000000000000000000000000000000000000000000000000000008152fd5b606460405162461bcd60e51b815260206004820152601460248201527f41617665206e6f7420696e697469616c697a65640000000000000000000000006044820152fd5b60405162461bcd60e51b815260206004820152600360248201527f55465000000000000000000000000000000000000000000000000000000000006044820152606490fd5b602489634e487b7160e01b81526021600452fd5b602090604051610ffa81611389565b8a81528a838201528a60408201528a606082015282828901015201610d10565b606460405162461bcd60e51b815260206004820152600360248201527f464c5000000000000000000000000000000000000000000000000000000000006044820152fd5b67ffffffffffffffff8435116110fe5760408383018535018b8e0103601f1901126110fe5760405161108f8161136d565b8383018535016020013560ff811690036110fa578383018535016020810135825267ffffffffffffffff604090910135116110fa576020809281928f8e6110e991018460408b358a8c010101358b358a8c01010101611579565b838201528152019401939050610c9f565b8b80fd5b8a80fd5b8980fd5b8680fd5b8580fd5b8780fd5b5080fd5b606460405162461bcd60e51b815260206004820152600260248201527f49430000000000000000000000000000000000000000000000000000000000006044820152fd5b50346101f05760a03660031901126101f057611174611201565b506064356001600160a01b0381168091036111125760843567ffffffffffffffff81116101ec576111a990369060040161122b565b9130036111c8576111bd9250604435611b13565b602060405160018152f35b602483634e487b7160e01b81526001600452fd5b9050346111125781600319360112611112576020906001600160a01b03600154168152f35b600435906001600160a01b038216820361098e57565b35906001600160a01b038216820361098e57565b9181601f8401121561098e5782359167ffffffffffffffff831161098e576020838186019501011161098e57565b3590811515820361098e57565b3461098e57606036600319011261098e5760443567ffffffffffffffff811161098e5761129a6112ae91369060040161122b565b906112a9602435600435611732565b611b13565b005b6003548110156112ea5760039081600052027fc2575a0e9e593c00f959f8c92f12db2869c3395a3b0502d05e2516446f71f85b0190600090565b634e487b7160e01b600052603260045260246000fd5b90600182811c92168015611330575b602083101461131a57565b634e487b7160e01b600052602260045260246000fd5b91607f169161130f565b610180810190811067ffffffffffffffff82111761135757604052565b634e487b7160e01b600052604160045260246000fd5b6040810190811067ffffffffffffffff82111761135757604052565b6080810190811067ffffffffffffffff82111761135757604052565b60c0810190811067ffffffffffffffff82111761135757604052565b67ffffffffffffffff811161135757604052565b6060810190811067ffffffffffffffff82111761135757604052565b90601f8019910116810190811067ffffffffffffffff82111761135757604052565b9060405191826000825461142681611300565b908184526020946001916001811690816000146114965750600114611457575b505050611455925003836113f1565b565b600090815285812095935091905b81831061147e5750506114559350820101388080611446565b85548884018501529485019487945091830191611465565b9250505061145594925060ff191682840152151560051b820101388080611446565b60005b8381106114cb5750506000910152565b81810151838201526020016114bb565b906020916114f4815180928185528580860191016114b8565b601f01601f1916010190565b35908160020b820361098e57565b67ffffffffffffffff81116113575760051b60200190565b67ffffffffffffffff811161135757601f01601f191660200190565b92919261154e82611526565b9161155c60405193846113f1565b82948184528183011161098e578281602093846000960137010152565b9080601f8301121561098e5781602061159493359101611542565b90565b8051156112ea5760200190565b80518210156112ea5760209160051b010190565b60ff1660038110156115c75790565b634e487b7160e01b600052602160045260246000fd5b91909160209081815260e08101916001600160a01b03928386511682840152818601519060409160408501526040870151926060936060860152606088015195608096608087015260808901519660c060a088015287518094528261010088019801956000956000935b8685106116725750505050505050505060a0611594939401519060c0601f19828503019101526114db565b9091929394959697998a51805160038110156116b85782528088015183168883015283810151848301528401518482015284019986019796959460010193929190611647565b60248b634e487b7160e01b81526021600452fd5b9493600093611701926080946001600160a01b038092168952166020880152604087015260a0606087015260a08601906114db565b930152565b90926080926001600160a01b0361159496951683526020830152604082015281606082015201906114db565b9190820180921161173f57565b634e487b7160e01b600052601160045260246000fd5b51906fffffffffffffffffffffffffffffffff8216820361098e57565b51906001600160a01b038216820361098e57565b6001600160a01b039081600254169160408051937f35ea6a7500000000000000000000000000000000000000000000000000000000855282841660048601526101e08086602481855afa958615611a85576000966118ee575b505060206004918351928380927f074b2e430000000000000000000000000000000000000000000000000000000082525afa9182156118e457506000916118aa575b5060646fffffffffffffffffffffffffffffffff8551921611908115611895575b8115611881575b811561186d575b50611865576101006115949301511690612a4c565b505050600090565b678000000000000000915051161538611850565b805167010000000000000016159150611849565b80516710000000000000001615159150611842565b90506020813d6020116118dc575b816118c5602093836113f1565b8101031261098e576118d690611755565b38611821565b3d91506118b8565b513d6000823e3d90fd5b90919581833d8511611a7e575b61190581836113f1565b8101038381126111125784519384019067ffffffffffffffff9085831082841117611a6a576020136101ec57610200850190811182821017611a5657855282518152835261195560208301611755565b6020840152611965848301611755565b8484015261197560608301611755565b606084015261198660808301611755565b608084015261199760a08301611755565b60a084015260c082015164ffffffffff811681036111125760c084015260e08201519061ffff821682036101f0575060e08301526004916020916101006119df818301611772565b908301526101206119f1818301611772565b90830152610140611a03818301611772565b90830152610160611a15818301611772565b90830152610180611a27818301611755565b908301526101a0611a39818301611755565b90830152611a4b6101c0809201611755565b9082015295916117df565b602483634e487b7160e01b81526041600452fd5b602484634e487b7160e01b81526041600452fd5b503d6118fb565b83513d6000823e3d90fd5b5190811515820361098e57565b519062ffffff8216820361098e57565b51908160020b820361098e57565b15611ac257565b606460405162461bcd60e51b815260206004820152600360248201527f49504300000000000000000000000000000000000000000000000000000000006044820152fd5b9190820391821161173f57565b91929092602084828101031261098e5783359367ffffffffffffffff851161098e5760c0858201838301031261098e5760405194611b50866113a5565b611b5b818301611217565b86528181016020818101359088015260408082013590880152606080820135908801526080013567ffffffffffffffff811161098e5781830101838301601f8201121561098e57803590611bae8261150e565b91611bbc60405193846113f1565b808352602083019186860160208360071b8301011161098e579160208301925b60208360071b82010184106125a95750505050608087015260a081830101359067ffffffffffffffff821161098e57611c19938301920101611579565b8060a08501528051810160208282031261098e5760208201519167ffffffffffffffff831161098e576101c083820183031261098e5760405192611c5c8461133a565b611c6a602082840101611a90565b8452611c7a604082840101611a9d565b6020850152611c8d606082840101611aad565b6040850152611ca0608082840101611aad565b6060850152611cb360a082840101611772565b6080850152611cc660c082840101611772565b60a085015260e0818301015160c085015261010080828401015160e08601526101209081838501015190860152604061011f198385018603011261098e5760405190611d118261136d565b6101408385010151825261016083850101516020830152850152604061015f198284018503011261098e57604051611d488161136d565b611d5761018083850101611755565b81526101a0828401015160208201526101408501526101c081830101519167ffffffffffffffff831161098e5701019060408282031261098e5760405190611d9e8261136d565b611daa60208401611a90565b825260408301519067ffffffffffffffff821161098e5760208101603f83860101121561098e576020828501015190611de28261150e565b94611df060405196876113f1565b82865260208601936020830160408560051b83850101011161098e57604081830101945b60408560051b838501010186106124ea5750505050505090816020611e499301918252610160840152516020860151906115a4565b5192611e5860ff8551166115b8565b90600382101594856115c7576001830361247e57611e9690611e8e6001600160a01b03916020836080890151169101519061269c565b163314611abb565b611eac6001600160a01b03608085015116612636565b6040870151811080159061245a575b156122385781906080880151516000905b8082106121ee575b5050611ef9816001600160a01b036080880151166001600160a01b038b511690612a7a565b6001600160a01b0388511660408901518083106000146121e8575081905b60a08a015190803b1561098e57611f749460008094604051978895869485937fd6234393000000000000000000000000000000000000000000000000000000008552600485015260248401526060604484015260648301906114db565b03925af19182156121dc57608093611fa58593611faa936001600160a01b03966121cd575b5060608c015190611b06565b611732565b94015116950151936115c7576002810361208b5750611fc99084612b71565b60005b825181101561208557611fdf81846115a4565b5190602082016001600160a01b038151161561207d57825160038110156115c7576001036120395760019261202c6001600160a01b03612033935116916060604082015191015190611732565b9087612a7a565b01611fcc565b606460405162461bcd60e51b815260206004820152600360248201527f52454100000000000000000000000000000000000000000000000000000000006044820152fd5b505050915050565b50915050565b6001036121895761209d903385612a7a565b60005b8251811015612085576120b381846115a4565b51906001600160a01b036020830151161561218257815160038110156115c7576002036120ff576120f96120f38360606040600196015191015190611732565b86612b71565b016120a0565b815160038110156115c75760010361213e576121398261202c6001600160a01b036020600196015116916060604082015191015190611732565b6120f9565b606460405162461bcd60e51b815260206004820152600360248201527f52455500000000000000000000000000000000000000000000000000000000006044820152fd5b5050915050565b606460405162461bcd60e51b815260206004820152600660248201527f52452055465000000000000000000000000000000000000000000000000000006044820152fd5b6121d6906113c1565b38611f99565b6040513d6000823e3d90fd5b90611f17565b9092896001600160a01b0360206122098760808501516115a4565b51015116156122315790606061222586608060019501516115a4565b51015101930190611ecc565b5092611ed4565b9160208794969597015160018101811161173f5761225a606086015185611b06565b916040519661226888611389565b6115c75786612320946001946122a8936123029a523360208401526040830152606082015260808701516020880151916122a283836115a4565b526115a4565b506123106001600160a01b038651166040870151608088015160a089015191604051936122d4856113a5565b845286860160208501526040840152876060840152608083015260a0820152604051978891602083016115dd565b03601f1981018852876113f1565b01602061016087015101516115a4565b5161232e60ff8251166115b8565b60038110156115c757600181036123cb5750918461237a6123809360406001600160a01b0361236c608099986020838c819e0151169101519061269c565b988995015116940151611b06565b9161283e565b93909216803b1561098e576123b19360008094604051968795869485936312439b2f60e21b85523060048601611706565b03925af180156121dc576123c25750565b611455906113c1565b91939291600214159050610f92576123ef6001600160a01b03608086015116611786565b928315610f24576040612403920151611b06565b916001600160a01b036080816002541695015116928181116000146124525750925b803b1561098e576123b19360008094604051968795869485936310ac2ddf60e21b855230600486016116cc565b905092612425565b506020870151602061016086015101515190600019820191821161173f5714611ebb565b5060009450600282036124a6576124a16001600160a01b03600254163314611abb565b611e96565b606460405162461bcd60e51b815260206004820152600760248201527f49504320554650000000000000000000000000000000000000000000000000006044820152fd5b855167ffffffffffffffff811161098e5783830101906040828603601f19011261098e576040519161251b8361136d565b604081015160ff8116810361098e57835260608101519067ffffffffffffffff821161098e57019060208601605f8301121561098e5760408201519061256082611526565b9361256e60405195866113f1565b828552602088016060848601011161098e578461259860209594869560608760409a0191016114b8565b838201528152019601959050611e14565b608084898901031261098e576040516125c181611389565b8435600381101561098e57602093828592608094526125e1838901611217565b8382015260408801356040820152606088013560608201528152019401939150611bdc565b3d15612631573d9061261782611526565b9161262560405193846113f1565b82523d6000602084013e565b606090565b60405160208101906370a0823160e01b82523060248201526024815261265b816113d5565b6000928392839251915afa9061266f612606565b9180612690575b156101f0576020828051810103126101f057506020015190565b50602082511015612676565b81518260209160609182918101031261098e576126ba828501611a9d565b9060409081860151946001600160a01b039687871680970361098e57826126e29101516112b0565b509583516126ef81611389565b87549060ff821615158152898882019260081c16825261271c600260018b01549a8884019b8c5201611413565b8582015251156127fb57519651948183818b8216116127ec575b505062ffffff1680156127c55788855192818985019516855216858301528382015282815261276481611389565b519020915b51938401947fff0000000000000000000000000000000000000000000000000000000000000086526bffffffffffffffffffffffff19911b16602184015260358301526055820152605581526127be81611389565b5190201690565b5087845191818884019416845216848201528381526127e3816113d5565b51902091612769565b909350915062ffffff38612736565b60648786519062461bcd60e51b82526004820152600360248201527f44584500000000000000000000000000000000000000000000000000000000006044820152fd5b919061284a8184612a4c565b918215801561294a575b61291057906020916001600160a01b039283926004604051809681937f0dfe1681000000000000000000000000000000000000000000000000000000008352165afa9283156121dc576000936128d4575b508192938181116000146128cc5750935b169116146000146128c75760009091565b600091565b9050936128b6565b9192506020823d602011612908575b816128f0602093836113f1565b8101031261098e576129028392611772565b926128a5565b3d91506128e3565b6024826001600160a01b03604051917f2c8c621b000000000000000000000000000000000000000000000000000000008352166004820152fd5b506040517f1a6865020000000000000000000000000000000000000000000000000000000081526020816004816001600160a01b0387165afa80156121dc576000906129ab575b6fffffffffffffffffffffffffffffffff91501615612854565b506020813d6020116129ec575b816129c5602093836113f1565b8101031261098e576129e76fffffffffffffffffffffffffffffffff91611755565b612991565b3d91506129b8565b6001600160a01b03600054163303612a0857565b606460405162461bcd60e51b815260206004820152602060248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152fd5b906040516001600160a01b0360208201926370a0823160e01b84521660248201526024815261265b816113d5565b6040517fa9059cbb00000000000000000000000000000000000000000000000000000000602082019081526001600160a01b03909316602482015260448101939093526000928392908390612adc81606481015b03601f1981018352826113f1565b51925af1612ae8612606565b81612b3a575b5015612af657565b606460405162461bcd60e51b815260206004820152600460248201527f572d5354000000000000000000000000000000000000000000000000000000006044820152fd5b8051801592508215612b4f575b505038612aee565b819250906020918101031261098e576020612b6a9101611a90565b3880612b47565b90612b7c8183612cb4565b15612b85575050565b6001600160a01b0360025416604051602081019163095ea7b360e01b8352602482015260008092828260448195015260448152612bc181611389565b519082875af190612bd0612606565b82612c75575b505015612c3157612be691612cb4565b15612bed57565b606460405162461bcd60e51b815260206004820152600360248201527f41464100000000000000000000000000000000000000000000000000000000006044820152fd5b606460405162461bcd60e51b815260206004820152600460248201527f41464130000000000000000000000000000000000000000000000000000000006044820152fd5b8091925051918215928315612c8f575b5050503880612bd6565b8293509160209192810103126101f057506020612cac9101611a90565b388080612c85565b60025460405163095ea7b360e01b602082019081526001600160a01b0390921660248201526044810193909352600092839291908390612cf78160648101612ace565b51925af1612d03612606565b81612d0c575090565b8051801592508215612d1d57505090565b819250906020918101031261098e5760206115949101611a9056fea164736f6c6343000817000a569b40a786964672ecd152251cbbbbe68ec24b3c562ac9fb70643a0b760804c9000000000000000000000000000000000000000000000000000000000000000000000000000000000000000056cfc796bc88c9c7e1b38c2b0af9b7120b079aef30146866f3a846fe3c636beb2756dbd24cf321bc52c9113c837c21f47470dfeb000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000057761676d69000000000000000000000000000000000000000000000000000000
Deployed Bytecode
0x608080604052600436101561001357600080fd5b600090813560e01c9081630542975c146111dc575080631b11d0ff1461115a5780635296a43114610a7a57806354fd4d5014610a5e578063660c27b414610a21578063715018a6146109ba5780637535d24614610993578063838429931461077c5780638c97b2c51461041f5780638da5cb5b146103f9578063a1d48336146102da578063a60b0d3c146102da578063b0fb0c3a1461037e578063b6996a0014610352578063bfce5ef91461030e578063e99b3267146102df578063e9cbafb0146102da578063f2fde38b146101f35763fd5acea2146100f257600080fd5b346101f05760203660031901126101f05761010b611201565b6101136129f4565b6001600160a01b0380911680156101ec57600254918083166101e85760015491602085600473ffffffffffffffffffffffffffffffffffffffff1995848782161760015560405194859384927f026b1d5f00000000000000000000000000000000000000000000000000000000845216175afa9081156101dd57859161019f575b501691161760025580f35b90506020813d6020116101d5575b816101ba602093836113f1565b810103126101d1576101cb90611772565b38610194565b8480fd5b3d91506101ad565b6040513d87823e3d90fd5b8380fd5b8280fd5b80fd5b50346101f05760203660031901126101f05761020d611201565b6102156129f4565b6001600160a01b03809116908115610270576000548273ffffffffffffffffffffffffffffffffffffffff19821617600055167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0600080a380f35b608460405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201527f64647265737300000000000000000000000000000000000000000000000000006064820152fd5b611266565b50346101f05760203660031901126101f05760ff60406020926004358152600484522054166040519015158152f35b50346101f05760203660031901126101f0576001600160a01b03610330611201565b6103386129f4565b168152600560205260408120805460ff1916600117905580f35b50346101f05760203660031901126101f0576020610376610371611201565b611786565b604051908152f35b50346101f05760203660031901126101f057600435906003548210156101f0576001600160a01b036103af836112b0565b506103f58154916103c7600260018301549201611413565b90604051948460ff8796161515865260081c16602085015260408401526080606084015260808301906114db565b0390f35b50346101f057806003193601126101f0576001600160a01b036020915416604051908152f35b50346101f05760603660031901126101f057610439611201565b906024356044359267ffffffffffffffff938481116101e85761046090369060040161122b565b909261046a6129f4565b60405193602094858101908483833761049187828781018b838201520380845201826113f1565b519020928387526004865260ff60408820541661073857906104b4913691611542565b91604051906104c282611389565b600191828152868101906001600160a01b0380971696878352604082019086825260608301938885526003546801000000000000000081101561072457808861050e92016003556112b0565b9490946107115791610573916105376002969594511515869060ff801983541691151516179055565b51845474ffffffffffffffffffffffffffffffffffffffff001916911660081b74ffffffffffffffffffffffffffffffffffffffff0016178355565b51858201550190519889519081116106fd5761058f8254611300565b601f81116106b7575b5087601f821160011461062f57908061061e9796959493928b9c7f569b40a786964672ecd152251cbbbbe68ec24b3c562ac9fb70643a0b760804c99c92610624575b5050600019600383901b1c191690841b1790555b885260048652604088209060ff1982541617905560405194859485528401526060604084015260608301906114db565b0390a180f35b0151905038806105da565b828a52888a2090601f1983168b5b8181106106a257509183917f569b40a786964672ecd152251cbbbbe68ec24b3c562ac9fb70643a0b760804c99c9d8897969561061e9b9a999510610689575b505050811b0190556105ee565b015160001960f88460031b161c1916905538808061067c565b8d830151845592870192918b01918b0161063d565b828a52888a20601f830160051c8101918a84106106f3575b601f0160051c019085905b8281106106e8575050610598565b8b81550185906106da565b90915081906106cf565b602489634e487b7160e01b81526041600452fd5b60248d634e487b7160e01b815280600452fd5b60248d634e487b7160e01b81526041600452fd5b6064866040519062461bcd60e51b82526004820152600260248201527f44450000000000000000000000000000000000000000000000000000000000006044820152fd5b50346101f05760809060806003193601126101f05760043591821515830361098e57602435906001600160a01b0382169182810361098e57604435906064359081600354111561094a576107f16107dd61082d936107d86129f4565b6112b0565b5097889060ff801983541691151516179055565b865474ffffffffffffffffffffffffffffffffffffffff00191660089190911b74ffffffffffffffffffffffffffffffffffffffff0016178655565b60026001958260018201550190604051938452602090602085015260606040850152849582549261085d84611300565b9384606088015260018116908160001461090057506001146108a4575b867fcbd42c34d643031323994ef2ae70464a950cbbc6e8eafe97baad6f6365114962878a0388a180f35b86526020862095965086955b8388106108ed57505050509281016080019250807fcbd42c34d643031323994ef2ae70464a950cbbc6e8eafe97baad6f636511496238808061087a565b80548689018601529682019681016108b0565b925050507fcbd42c34d643031323994ef2ae70464a950cbbc6e8eafe97baad6f6365114962959650849350608092915060ff191682840152151560051b820101939238808061087a565b606460405162461bcd60e51b815260206004820152600260248201527f49490000000000000000000000000000000000000000000000000000000000006044820152fd5b600080fd5b50346101f057806003193601126101f05760206001600160a01b0360025416604051908152f35b50346101f057806003193601126101f0576109d36129f4565b60006001600160a01b03815473ffffffffffffffffffffffffffffffffffffffff1981168355167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e08280a380f35b50346101f05760203660031901126101f05760ff60406020926001600160a01b03610a4a611201565b168152600584522054166040519015158152f35b50346101f057806003193601126101f057602060405160018152f35b50346101f05760403660031901126101f05760243567ffffffffffffffff811161111257610aac90369060040161122b565b919091338252600560205260ff6040832054161561111657602083828101031261111257823567ffffffffffffffff81116101ec5783018082850103906101c082126101e85760405190610aff8261133a565b610b0881611259565b8252602081013562ffffff8116810361110a576020830152610b2c60408201611500565b6040830152610b3d60608201611500565b6060830152610b4e60808201611217565b9260808301938452610b6260a08301611217565b60a084015260c082013560c084015260e082013560e0840152610100808301359084015261012090604061011f19820112611106576040908151610ba58161136d565b8484013581526101408086013560208301529386015261015f19011261110a5760405190610bd28261136d565b6101608301356fffffffffffffffffffffffffffffffff8116810361110e57825261018083013560208301528301526101a08101359067ffffffffffffffff821161110a57019060408285880103126101d15760405190610c328261136d565b610c3b83611259565b8252602083013567ffffffffffffffff811161110657858801601f828601011215611106578084013590610c6e8261150e565b94610c7c60405196876113f1565b8286526020860191888b0160208560051b83850101011161110257602081830101925b60208560051b8385010101841061105e57505050505061016090602083019384520152519384511561101a57610d0d610ce460ff610cdc88611597565b5151166115b8565b95805192610cf18461150e565b93610cff60405195866113f1565b808552601f1993849161150e565b01875b818110610feb5750506001600160a01b0395610d2e87875116612636565b9260038a1015610fd7578960018a9b14600014610e2f5750610dc9959492610dd59492610d81610d73610db5946020610d6a8e8e511692611597565b5101519061269c565b998a8c60043592511661283e565b9a9099169660405194610d93866113a5565b3386528c60208701526004356040870152606086015260808501523691611542565b60a0820152604051948591602083016115dd565b039081018452836113f1565b803b156101d157610e0193858094604051968795869485936312439b2f60e21b85523060048601611706565b03925af18015610e2457610e1457505080f35b610e1d906113c1565b6101f05780f35b6040513d84823e3d90fd5b905060029196985096929493919614600014610f92578160025416938415610f4e57610e5d83895116611786565b978815610f24578997610ec697610ed295610eb29351169a8060043511600014610f1a57965b60405194610e90866113a5565b3386528b60208701526004356040870152606086015260808501523691611542565b60a0820152604051958691602083016115dd565b039081018552846113f1565b813b156101e85783610efc95604051968795869485936310ac2ddf60e21b855230600486016116cc565b03925af18015610e2457610f0e575080f35b610f17906113c1565b80f35b5060043596610e83565b60046040517ff7f59316000000000000000000000000000000000000000000000000000000008152fd5b606460405162461bcd60e51b815260206004820152601460248201527f41617665206e6f7420696e697469616c697a65640000000000000000000000006044820152fd5b60405162461bcd60e51b815260206004820152600360248201527f55465000000000000000000000000000000000000000000000000000000000006044820152606490fd5b602489634e487b7160e01b81526021600452fd5b602090604051610ffa81611389565b8a81528a838201528a60408201528a606082015282828901015201610d10565b606460405162461bcd60e51b815260206004820152600360248201527f464c5000000000000000000000000000000000000000000000000000000000006044820152fd5b67ffffffffffffffff8435116110fe5760408383018535018b8e0103601f1901126110fe5760405161108f8161136d565b8383018535016020013560ff811690036110fa578383018535016020810135825267ffffffffffffffff604090910135116110fa576020809281928f8e6110e991018460408b358a8c010101358b358a8c01010101611579565b838201528152019401939050610c9f565b8b80fd5b8a80fd5b8980fd5b8680fd5b8580fd5b8780fd5b5080fd5b606460405162461bcd60e51b815260206004820152600260248201527f49430000000000000000000000000000000000000000000000000000000000006044820152fd5b50346101f05760a03660031901126101f057611174611201565b506064356001600160a01b0381168091036111125760843567ffffffffffffffff81116101ec576111a990369060040161122b565b9130036111c8576111bd9250604435611b13565b602060405160018152f35b602483634e487b7160e01b81526001600452fd5b9050346111125781600319360112611112576020906001600160a01b03600154168152f35b600435906001600160a01b038216820361098e57565b35906001600160a01b038216820361098e57565b9181601f8401121561098e5782359167ffffffffffffffff831161098e576020838186019501011161098e57565b3590811515820361098e57565b3461098e57606036600319011261098e5760443567ffffffffffffffff811161098e5761129a6112ae91369060040161122b565b906112a9602435600435611732565b611b13565b005b6003548110156112ea5760039081600052027fc2575a0e9e593c00f959f8c92f12db2869c3395a3b0502d05e2516446f71f85b0190600090565b634e487b7160e01b600052603260045260246000fd5b90600182811c92168015611330575b602083101461131a57565b634e487b7160e01b600052602260045260246000fd5b91607f169161130f565b610180810190811067ffffffffffffffff82111761135757604052565b634e487b7160e01b600052604160045260246000fd5b6040810190811067ffffffffffffffff82111761135757604052565b6080810190811067ffffffffffffffff82111761135757604052565b60c0810190811067ffffffffffffffff82111761135757604052565b67ffffffffffffffff811161135757604052565b6060810190811067ffffffffffffffff82111761135757604052565b90601f8019910116810190811067ffffffffffffffff82111761135757604052565b9060405191826000825461142681611300565b908184526020946001916001811690816000146114965750600114611457575b505050611455925003836113f1565b565b600090815285812095935091905b81831061147e5750506114559350820101388080611446565b85548884018501529485019487945091830191611465565b9250505061145594925060ff191682840152151560051b820101388080611446565b60005b8381106114cb5750506000910152565b81810151838201526020016114bb565b906020916114f4815180928185528580860191016114b8565b601f01601f1916010190565b35908160020b820361098e57565b67ffffffffffffffff81116113575760051b60200190565b67ffffffffffffffff811161135757601f01601f191660200190565b92919261154e82611526565b9161155c60405193846113f1565b82948184528183011161098e578281602093846000960137010152565b9080601f8301121561098e5781602061159493359101611542565b90565b8051156112ea5760200190565b80518210156112ea5760209160051b010190565b60ff1660038110156115c75790565b634e487b7160e01b600052602160045260246000fd5b91909160209081815260e08101916001600160a01b03928386511682840152818601519060409160408501526040870151926060936060860152606088015195608096608087015260808901519660c060a088015287518094528261010088019801956000956000935b8685106116725750505050505050505060a0611594939401519060c0601f19828503019101526114db565b9091929394959697998a51805160038110156116b85782528088015183168883015283810151848301528401518482015284019986019796959460010193929190611647565b60248b634e487b7160e01b81526021600452fd5b9493600093611701926080946001600160a01b038092168952166020880152604087015260a0606087015260a08601906114db565b930152565b90926080926001600160a01b0361159496951683526020830152604082015281606082015201906114db565b9190820180921161173f57565b634e487b7160e01b600052601160045260246000fd5b51906fffffffffffffffffffffffffffffffff8216820361098e57565b51906001600160a01b038216820361098e57565b6001600160a01b039081600254169160408051937f35ea6a7500000000000000000000000000000000000000000000000000000000855282841660048601526101e08086602481855afa958615611a85576000966118ee575b505060206004918351928380927f074b2e430000000000000000000000000000000000000000000000000000000082525afa9182156118e457506000916118aa575b5060646fffffffffffffffffffffffffffffffff8551921611908115611895575b8115611881575b811561186d575b50611865576101006115949301511690612a4c565b505050600090565b678000000000000000915051161538611850565b805167010000000000000016159150611849565b80516710000000000000001615159150611842565b90506020813d6020116118dc575b816118c5602093836113f1565b8101031261098e576118d690611755565b38611821565b3d91506118b8565b513d6000823e3d90fd5b90919581833d8511611a7e575b61190581836113f1565b8101038381126111125784519384019067ffffffffffffffff9085831082841117611a6a576020136101ec57610200850190811182821017611a5657855282518152835261195560208301611755565b6020840152611965848301611755565b8484015261197560608301611755565b606084015261198660808301611755565b608084015261199760a08301611755565b60a084015260c082015164ffffffffff811681036111125760c084015260e08201519061ffff821682036101f0575060e08301526004916020916101006119df818301611772565b908301526101206119f1818301611772565b90830152610140611a03818301611772565b90830152610160611a15818301611772565b90830152610180611a27818301611755565b908301526101a0611a39818301611755565b90830152611a4b6101c0809201611755565b9082015295916117df565b602483634e487b7160e01b81526041600452fd5b602484634e487b7160e01b81526041600452fd5b503d6118fb565b83513d6000823e3d90fd5b5190811515820361098e57565b519062ffffff8216820361098e57565b51908160020b820361098e57565b15611ac257565b606460405162461bcd60e51b815260206004820152600360248201527f49504300000000000000000000000000000000000000000000000000000000006044820152fd5b9190820391821161173f57565b91929092602084828101031261098e5783359367ffffffffffffffff851161098e5760c0858201838301031261098e5760405194611b50866113a5565b611b5b818301611217565b86528181016020818101359088015260408082013590880152606080820135908801526080013567ffffffffffffffff811161098e5781830101838301601f8201121561098e57803590611bae8261150e565b91611bbc60405193846113f1565b808352602083019186860160208360071b8301011161098e579160208301925b60208360071b82010184106125a95750505050608087015260a081830101359067ffffffffffffffff821161098e57611c19938301920101611579565b8060a08501528051810160208282031261098e5760208201519167ffffffffffffffff831161098e576101c083820183031261098e5760405192611c5c8461133a565b611c6a602082840101611a90565b8452611c7a604082840101611a9d565b6020850152611c8d606082840101611aad565b6040850152611ca0608082840101611aad565b6060850152611cb360a082840101611772565b6080850152611cc660c082840101611772565b60a085015260e0818301015160c085015261010080828401015160e08601526101209081838501015190860152604061011f198385018603011261098e5760405190611d118261136d565b6101408385010151825261016083850101516020830152850152604061015f198284018503011261098e57604051611d488161136d565b611d5761018083850101611755565b81526101a0828401015160208201526101408501526101c081830101519167ffffffffffffffff831161098e5701019060408282031261098e5760405190611d9e8261136d565b611daa60208401611a90565b825260408301519067ffffffffffffffff821161098e5760208101603f83860101121561098e576020828501015190611de28261150e565b94611df060405196876113f1565b82865260208601936020830160408560051b83850101011161098e57604081830101945b60408560051b838501010186106124ea5750505050505090816020611e499301918252610160840152516020860151906115a4565b5192611e5860ff8551166115b8565b90600382101594856115c7576001830361247e57611e9690611e8e6001600160a01b03916020836080890151169101519061269c565b163314611abb565b611eac6001600160a01b03608085015116612636565b6040870151811080159061245a575b156122385781906080880151516000905b8082106121ee575b5050611ef9816001600160a01b036080880151166001600160a01b038b511690612a7a565b6001600160a01b0388511660408901518083106000146121e8575081905b60a08a015190803b1561098e57611f749460008094604051978895869485937fd6234393000000000000000000000000000000000000000000000000000000008552600485015260248401526060604484015260648301906114db565b03925af19182156121dc57608093611fa58593611faa936001600160a01b03966121cd575b5060608c015190611b06565b611732565b94015116950151936115c7576002810361208b5750611fc99084612b71565b60005b825181101561208557611fdf81846115a4565b5190602082016001600160a01b038151161561207d57825160038110156115c7576001036120395760019261202c6001600160a01b03612033935116916060604082015191015190611732565b9087612a7a565b01611fcc565b606460405162461bcd60e51b815260206004820152600360248201527f52454100000000000000000000000000000000000000000000000000000000006044820152fd5b505050915050565b50915050565b6001036121895761209d903385612a7a565b60005b8251811015612085576120b381846115a4565b51906001600160a01b036020830151161561218257815160038110156115c7576002036120ff576120f96120f38360606040600196015191015190611732565b86612b71565b016120a0565b815160038110156115c75760010361213e576121398261202c6001600160a01b036020600196015116916060604082015191015190611732565b6120f9565b606460405162461bcd60e51b815260206004820152600360248201527f52455500000000000000000000000000000000000000000000000000000000006044820152fd5b5050915050565b606460405162461bcd60e51b815260206004820152600660248201527f52452055465000000000000000000000000000000000000000000000000000006044820152fd5b6121d6906113c1565b38611f99565b6040513d6000823e3d90fd5b90611f17565b9092896001600160a01b0360206122098760808501516115a4565b51015116156122315790606061222586608060019501516115a4565b51015101930190611ecc565b5092611ed4565b9160208794969597015160018101811161173f5761225a606086015185611b06565b916040519661226888611389565b6115c75786612320946001946122a8936123029a523360208401526040830152606082015260808701516020880151916122a283836115a4565b526115a4565b506123106001600160a01b038651166040870151608088015160a089015191604051936122d4856113a5565b845286860160208501526040840152876060840152608083015260a0820152604051978891602083016115dd565b03601f1981018852876113f1565b01602061016087015101516115a4565b5161232e60ff8251166115b8565b60038110156115c757600181036123cb5750918461237a6123809360406001600160a01b0361236c608099986020838c819e0151169101519061269c565b988995015116940151611b06565b9161283e565b93909216803b1561098e576123b19360008094604051968795869485936312439b2f60e21b85523060048601611706565b03925af180156121dc576123c25750565b611455906113c1565b91939291600214159050610f92576123ef6001600160a01b03608086015116611786565b928315610f24576040612403920151611b06565b916001600160a01b036080816002541695015116928181116000146124525750925b803b1561098e576123b19360008094604051968795869485936310ac2ddf60e21b855230600486016116cc565b905092612425565b506020870151602061016086015101515190600019820191821161173f5714611ebb565b5060009450600282036124a6576124a16001600160a01b03600254163314611abb565b611e96565b606460405162461bcd60e51b815260206004820152600760248201527f49504320554650000000000000000000000000000000000000000000000000006044820152fd5b855167ffffffffffffffff811161098e5783830101906040828603601f19011261098e576040519161251b8361136d565b604081015160ff8116810361098e57835260608101519067ffffffffffffffff821161098e57019060208601605f8301121561098e5760408201519061256082611526565b9361256e60405195866113f1565b828552602088016060848601011161098e578461259860209594869560608760409a0191016114b8565b838201528152019601959050611e14565b608084898901031261098e576040516125c181611389565b8435600381101561098e57602093828592608094526125e1838901611217565b8382015260408801356040820152606088013560608201528152019401939150611bdc565b3d15612631573d9061261782611526565b9161262560405193846113f1565b82523d6000602084013e565b606090565b60405160208101906370a0823160e01b82523060248201526024815261265b816113d5565b6000928392839251915afa9061266f612606565b9180612690575b156101f0576020828051810103126101f057506020015190565b50602082511015612676565b81518260209160609182918101031261098e576126ba828501611a9d565b9060409081860151946001600160a01b039687871680970361098e57826126e29101516112b0565b509583516126ef81611389565b87549060ff821615158152898882019260081c16825261271c600260018b01549a8884019b8c5201611413565b8582015251156127fb57519651948183818b8216116127ec575b505062ffffff1680156127c55788855192818985019516855216858301528382015282815261276481611389565b519020915b51938401947fff0000000000000000000000000000000000000000000000000000000000000086526bffffffffffffffffffffffff19911b16602184015260358301526055820152605581526127be81611389565b5190201690565b5087845191818884019416845216848201528381526127e3816113d5565b51902091612769565b909350915062ffffff38612736565b60648786519062461bcd60e51b82526004820152600360248201527f44584500000000000000000000000000000000000000000000000000000000006044820152fd5b919061284a8184612a4c565b918215801561294a575b61291057906020916001600160a01b039283926004604051809681937f0dfe1681000000000000000000000000000000000000000000000000000000008352165afa9283156121dc576000936128d4575b508192938181116000146128cc5750935b169116146000146128c75760009091565b600091565b9050936128b6565b9192506020823d602011612908575b816128f0602093836113f1565b8101031261098e576129028392611772565b926128a5565b3d91506128e3565b6024826001600160a01b03604051917f2c8c621b000000000000000000000000000000000000000000000000000000008352166004820152fd5b506040517f1a6865020000000000000000000000000000000000000000000000000000000081526020816004816001600160a01b0387165afa80156121dc576000906129ab575b6fffffffffffffffffffffffffffffffff91501615612854565b506020813d6020116129ec575b816129c5602093836113f1565b8101031261098e576129e76fffffffffffffffffffffffffffffffff91611755565b612991565b3d91506129b8565b6001600160a01b03600054163303612a0857565b606460405162461bcd60e51b815260206004820152602060248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152fd5b906040516001600160a01b0360208201926370a0823160e01b84521660248201526024815261265b816113d5565b6040517fa9059cbb00000000000000000000000000000000000000000000000000000000602082019081526001600160a01b03909316602482015260448101939093526000928392908390612adc81606481015b03601f1981018352826113f1565b51925af1612ae8612606565b81612b3a575b5015612af657565b606460405162461bcd60e51b815260206004820152600460248201527f572d5354000000000000000000000000000000000000000000000000000000006044820152fd5b8051801592508215612b4f575b505038612aee565b819250906020918101031261098e576020612b6a9101611a90565b3880612b47565b90612b7c8183612cb4565b15612b85575050565b6001600160a01b0360025416604051602081019163095ea7b360e01b8352602482015260008092828260448195015260448152612bc181611389565b519082875af190612bd0612606565b82612c75575b505015612c3157612be691612cb4565b15612bed57565b606460405162461bcd60e51b815260206004820152600360248201527f41464100000000000000000000000000000000000000000000000000000000006044820152fd5b606460405162461bcd60e51b815260206004820152600460248201527f41464130000000000000000000000000000000000000000000000000000000006044820152fd5b8091925051918215928315612c8f575b5050503880612bd6565b8293509160209192810103126101f057506020612cac9101611a90565b388080612c85565b60025460405163095ea7b360e01b602082019081526001600160a01b0390921660248201526044810193909352600092839291908390612cf78160648101612ace565b51925af1612d03612606565b81612d0c575090565b8051801592508215612d1d57505090565b819250906020918101031261098e5760206115949101611a9056fea164736f6c6343000817000a
Constructor Arguments (ABI-Encoded and is the last bytes of the Contract Creation Code above)
000000000000000000000000000000000000000000000000000000000000000000000000000000000000000056cfc796bc88c9c7e1b38c2b0af9b7120b079aef30146866f3a846fe3c636beb2756dbd24cf321bc52c9113c837c21f47470dfeb000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000057761676d69000000000000000000000000000000000000000000000000000000
-----Decoded View---------------
Arg [0] : aaveAddressProvider (address): 0x0000000000000000000000000000000000000000
Arg [1] : factoryV3 (address): 0x56CFC796bC88C9c7e1b38C2b0aF9B7120B079aef
Arg [2] : initCodeHash (bytes32): 0x30146866f3a846fe3c636beb2756dbd24cf321bc52c9113c837c21f47470dfeb
Arg [3] : name (string): wagmi
-----Encoded View---------------
6 Constructor Arguments found :
Arg [0] : 0000000000000000000000000000000000000000000000000000000000000000
Arg [1] : 00000000000000000000000056cfc796bc88c9c7e1b38c2b0af9b7120b079aef
Arg [2] : 30146866f3a846fe3c636beb2756dbd24cf321bc52c9113c837c21f47470dfeb
Arg [3] : 0000000000000000000000000000000000000000000000000000000000000080
Arg [4] : 0000000000000000000000000000000000000000000000000000000000000005
Arg [5] : 7761676d69000000000000000000000000000000000000000000000000000000
Loading...
Loading
Loading...
Loading
Multichain Portfolio | 30 Chains
Chain | Token | Portfolio % | Price | Amount | Value |
---|
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.