Overview
ETH Balance
0 ETH
Eth Value
$0.00More Info
Private Name Tags
ContractCreator
View more zero value Internal Transactions in Advanced View mode
Advanced mode:
Loading...
Loading
Contract Source Code Verified (Exact Match)
Contract Name:
WETHGateway
Compiler Version
v0.8.4+commit.c7e474f2
Optimization Enabled:
Yes with 200 runs
Other Settings:
istanbul EvmVersion
Contract Source Code (Solidity Standard Json-Input format)
// SPDX-License-Identifier: agpl-3.0 pragma solidity 0.8.4; import {ERC721HolderUpgradeable} from "@openzeppelin/contracts-upgradeable/token/ERC721/utils/ERC721HolderUpgradeable.sol"; import {IERC721Upgradeable} from "@openzeppelin/contracts-upgradeable/token/ERC721/IERC721Upgradeable.sol"; import {Errors} from "../libraries/helpers/Errors.sol"; import {IWETH} from "../interfaces/IWETH.sol"; import {IDebtMarket} from "../interfaces/IDebtMarket.sol"; import {IWETHGateway} from "../interfaces/IWETHGateway.sol"; import {ILendPoolAddressesProvider} from "../interfaces/ILendPoolAddressesProvider.sol"; import {ILendPool} from "../interfaces/ILendPool.sol"; import {ILendPoolLoan} from "../interfaces/ILendPoolLoan.sol"; import {IUToken} from "../interfaces/IUToken.sol"; import {DataTypes} from "../libraries/types/DataTypes.sol"; import {EmergencyTokenRecoveryUpgradeable} from "./EmergencyTokenRecoveryUpgradeable.sol"; contract WETHGateway is IWETHGateway, ERC721HolderUpgradeable, EmergencyTokenRecoveryUpgradeable { /*////////////////////////////////////////////////////////////// Structs //////////////////////////////////////////////////////////////*/ /** * @notice Struct containing local variables for the Guard modifier. * @param cachedPoolLoan The cached instance of the lend pool loan contract. * @param loanId The ID of the loan. * @param loan The loan data. */ struct GuardVars { ILendPoolLoan cachedPoolLoan; uint256 loanId; DataTypes.LoanData loan; } /*////////////////////////////////////////////////////////////// GENERAL VARIABLES //////////////////////////////////////////////////////////////*/ ILendPoolAddressesProvider internal _addressProvider; IWETH internal WETH; mapping(address => bool) internal _callerWhitelists; uint256 private constant _NOT_ENTERED = 0; uint256 private constant _ENTERED = 1; uint256 private _status; /*////////////////////////////////////////////////////////////// MODIFIERS //////////////////////////////////////////////////////////////*/ modifier loanReserveShouldBeWETH(address nftAsset, uint256 tokenId) { GuardVars memory vars; vars.cachedPoolLoan = _getLendPoolLoan(); vars.loanId = vars.cachedPoolLoan.getCollateralLoanId(nftAsset, tokenId); require(vars.loanId > 0, "collateral loan id not exist"); vars.loan = vars.cachedPoolLoan.getLoan(vars.loanId); require(vars.loan.reserveAsset == address(WETH), "loan reserve not WETH"); _; } /** * @dev Prevents a contract from calling itself, directly or indirectly. * Calling a `nonReentrant` function from another `nonReentrant` * function is not supported. It is possible to prevent this from happening * by making the `nonReentrant` function external, and making it call a * `private` function that does the actual work. */ modifier nonReentrant() { // On the first call to nonReentrant, _notEntered will be true require(_status != _ENTERED, "ReentrancyGuard: reentrant call"); // Any calls to nonReentrant after this point will fail _status = _ENTERED; _; // By storing the original value once again, a refund is triggered (see // https://eips.ethereum.org/EIPS/eip-2200) _status = _NOT_ENTERED; } /*////////////////////////////////////////////////////////////// INITIALIZERS //////////////////////////////////////////////////////////////*/ /// @custom:oz-upgrades-unsafe-allow constructor constructor() initializer {} /** * @dev Sets the WETH address and the LendPoolAddressesProvider address. Infinite approves lend pool. * @param weth Address of the Wrapped Ether contract **/ function initialize(address addressProvider, address weth) public initializer { __ERC721Holder_init(); __EmergencyTokenRecovery_init(); _addressProvider = ILendPoolAddressesProvider(addressProvider); WETH = IWETH(weth); WETH.approve(address(_getLendPool()), type(uint256).max); } /*////////////////////////////////////////////////////////////// Fallback and Receive Functions //////////////////////////////////////////////////////////////*/ /** * @dev Only WETH contract is allowed to transfer ETH here. Prevent other addresses to send Ether to this contract. */ receive() external payable { require(msg.sender == address(WETH), "Receive not allowed"); } /** * @dev Revert fallback calls */ fallback() external payable { revert("Fallback not allowed"); } /*////////////////////////////////////////////////////////////// MAIN LOGIC //////////////////////////////////////////////////////////////*/ /** * @dev approves the lendpool for the given NFT assets * @param nftAssets the array of nft assets */ function authorizeLendPoolNFT(address[] calldata nftAssets) external nonReentrant onlyOwner { uint256 nftAssetsLength = nftAssets.length; for (uint256 i; i < nftAssetsLength; ) { IERC721Upgradeable(nftAssets[i]).setApprovalForAll(address(_getLendPool()), true); unchecked { ++i; } } } /** * @dev authorizes/unauthorizes a list of callers for the whitelist * @param callers the array of callers to be authorized * @param flag the flag to authorize/unauthorize */ function authorizeCallerWhitelist(address[] calldata callers, bool flag) external nonReentrant onlyOwner { uint256 callerLength = callers.length; for (uint256 i; i < callerLength; ) { _callerWhitelists[callers[i]] = flag; unchecked { i = i + 1; } } } /** * @inheritdoc IWETHGateway */ function depositETH(address onBehalfOf, uint16 referralCode) external payable override nonReentrant { _checkValidCallerAndOnBehalfOf(onBehalfOf); ILendPool cachedPool = _getLendPool(); WETH.deposit{value: msg.value}(); cachedPool.deposit(address(WETH), msg.value, onBehalfOf, referralCode); } /** * @inheritdoc IWETHGateway */ function withdrawETH(uint256 amount, address to) external override nonReentrant { _checkValidCallerAndOnBehalfOf(to); ILendPool cachedPool = _getLendPool(); IUToken uWETH = IUToken(cachedPool.getReserveData(address(WETH)).uTokenAddress); uint256 userBalance = uWETH.balanceOf(msg.sender); uint256 amountToWithdraw = amount; // if amount is equal to uint(-1), the user wants to redeem everything if (amount == type(uint256).max) { amountToWithdraw = userBalance; } uWETH.transferFrom(msg.sender, address(this), amountToWithdraw); cachedPool.withdraw(address(WETH), amountToWithdraw, address(this)); WETH.withdraw(amountToWithdraw); _safeTransferETH(to, amountToWithdraw); } /** * @inheritdoc IWETHGateway */ function borrowETH( uint256 amount, address nftAsset, uint256 nftTokenId, address onBehalfOf, uint16 referralCode ) external override nonReentrant { _checkValidCallerAndOnBehalfOf(onBehalfOf); ILendPool cachedPool = _getLendPool(); ILendPoolLoan cachedPoolLoan = _getLendPoolLoan(); uint256 loanId = cachedPoolLoan.getCollateralLoanId(nftAsset, nftTokenId); if (loanId == 0) { IERC721Upgradeable(nftAsset).safeTransferFrom(msg.sender, address(this), nftTokenId); } cachedPool.borrow(address(WETH), amount, nftAsset, nftTokenId, onBehalfOf, referralCode); WETH.withdraw(amount); _safeTransferETH(onBehalfOf, amount); } /** * @inheritdoc IWETHGateway */ function repayETH( address nftAsset, uint256 nftTokenId, uint256 amount ) external payable override nonReentrant returns (uint256, bool) { (uint256 repayAmount, bool repayAll) = _repayETH(nftAsset, nftTokenId, amount, 0); // refund remaining dust eth if (msg.value > repayAmount) { _safeTransferETH(msg.sender, msg.value - repayAmount); } return (repayAmount, repayAll); } function auctionETH( address nftAsset, uint256 nftTokenId, address onBehalfOf ) external payable override nonReentrant loanReserveShouldBeWETH(nftAsset, nftTokenId) { _checkValidCallerAndOnBehalfOf(onBehalfOf); ILendPool cachedPool = _getLendPool(); WETH.deposit{value: msg.value}(); cachedPool.auction(nftAsset, nftTokenId, msg.value, onBehalfOf); } function redeemETH( address nftAsset, uint256 nftTokenId, uint256 amount, uint256 bidFine ) external payable override nonReentrant loanReserveShouldBeWETH(nftAsset, nftTokenId) returns (uint256) { ILendPool cachedPool = _getLendPool(); require(msg.value >= (amount + bidFine), "msg.value is less than redeem amount"); WETH.deposit{value: msg.value}(); uint256 paybackAmount = cachedPool.redeem(nftAsset, nftTokenId, amount, bidFine); // refund remaining dust eth if (msg.value > paybackAmount) { WETH.withdraw(msg.value - paybackAmount); _safeTransferETH(msg.sender, msg.value - paybackAmount); } return paybackAmount; } function liquidateETH( address nftAsset, uint256 nftTokenId ) external payable override nonReentrant loanReserveShouldBeWETH(nftAsset, nftTokenId) returns (uint256) { ILendPool cachedPool = _getLendPool(); if (msg.value > 0) { WETH.deposit{value: msg.value}(); } uint256 extraAmount = cachedPool.liquidate(nftAsset, nftTokenId, msg.value); if (msg.value > extraAmount) { WETH.withdraw(msg.value - extraAmount); _safeTransferETH(msg.sender, msg.value - extraAmount); } return (extraAmount); } function bidDebtETH( address nftAsset, uint256 nftTokenId, address onBehalfOf ) external payable override nonReentrant loanReserveShouldBeWETH(nftAsset, nftTokenId) { bytes32 DEBT_MARKET = keccak256("DEBT_MARKET"); IDebtMarket debtMarketAddress = IDebtMarket(_addressProvider.getAddress(DEBT_MARKET)); if (msg.value > 0) { WETH.deposit{value: msg.value}(); } if (WETH.allowance(address(this), address(debtMarketAddress)) == 0) { WETH.approve(address(debtMarketAddress), type(uint256).max); } debtMarketAddress.bid(nftAsset, nftTokenId, msg.value, onBehalfOf); } function buyDebtETH( address nftAsset, uint256 nftTokenId, address onBehalfOf ) external payable override nonReentrant loanReserveShouldBeWETH(nftAsset, nftTokenId) { bytes32 DEBT_MARKET = keccak256("DEBT_MARKET"); IDebtMarket debtMarketAddress = IDebtMarket(_addressProvider.getAddress(DEBT_MARKET)); if (msg.value > 0) { WETH.deposit{value: msg.value}(); } if (WETH.allowance(address(this), address(debtMarketAddress)) == 0) { WETH.approve(address(debtMarketAddress), type(uint256).max); } debtMarketAddress.buy(nftAsset, nftTokenId, onBehalfOf, msg.value); } /** @dev Executes the buyout for an NFT with a non-healthy position collateral-wise * @param nftAsset The address of the underlying NFT used as collateral * @param nftTokenId The token ID of the underlying NFT used as collateral * @param onBehalfOf The address that will receive the NFT, same as msg.sender if the user * wants to receive them on his own wallet, or a different address if the beneficiary of the NFT * is a different wallet **/ function buyoutETH(address nftAsset, uint256 nftTokenId, address onBehalfOf) external payable override nonReentrant { _checkValidCallerAndOnBehalfOf(onBehalfOf); ILendPool cachedPool = _getLendPool(); ILendPoolLoan cachedPoolLoan = _getLendPoolLoan(); uint256 loanId = cachedPoolLoan.getCollateralLoanId(nftAsset, nftTokenId); require(loanId > 0, "collateral loan id not exist"); DataTypes.LoanData memory loan = cachedPoolLoan.getLoan(loanId); require(loan.reserveAsset == address(WETH), "loan reserve not WETH"); if (msg.value > 0) { WETH.deposit{value: msg.value}(); } cachedPool.buyout(nftAsset, nftTokenId, onBehalfOf); } /*////////////////////////////////////////////////////////////// INTERNALS //////////////////////////////////////////////////////////////*/ /** * @dev repays a borrow on the WETH reserve, for the specified amount (or for the whole amount, if uint256(-1) is specified). * @param nftAsset The address of the underlying NFT used as collateral * @param nftTokenId The token ID of the underlying NFT used as collateral * @param amount the amount to repay, or uint256(-1) if the user wants to repay everything * @param accAmount the accumulated amount */ function _repayETH( address nftAsset, uint256 nftTokenId, uint256 amount, uint256 accAmount ) internal loanReserveShouldBeWETH(nftAsset, nftTokenId) returns (uint256, bool) { ILendPoolLoan cachedPoolLoan = _getLendPoolLoan(); uint256 loanId = cachedPoolLoan.getCollateralLoanId(nftAsset, nftTokenId); (, uint256 repayDebtAmount) = cachedPoolLoan.getLoanReserveBorrowAmount(loanId); if (amount < repayDebtAmount) { repayDebtAmount = amount; } require(msg.value >= (accAmount + repayDebtAmount), "msg.value is less than repay amount"); WETH.deposit{value: repayDebtAmount}(); (uint256 paybackAmount, bool burn) = _getLendPool().repay(nftAsset, nftTokenId, amount); return (paybackAmount, burn); } /** * @dev transfer ETH to an address, revert if it fails. * @param to recipient of the transfer * @param value the amount to send */ function _safeTransferETH(address to, uint256 value) internal { (bool success, ) = to.call{value: value}(new bytes(0)); require(success, "ETH_TRANSFER_FAILED"); } /** * @notice returns the LendPool address */ function _getLendPool() internal view returns (ILendPool) { return ILendPool(_addressProvider.getLendPool()); } /** * @notice returns the LendPoolLoan address */ function _getLendPoolLoan() internal view returns (ILendPoolLoan) { return ILendPoolLoan(_addressProvider.getLendPoolLoan()); } /** * @dev checks if caller's approved address is valid * @param onBehalfOf the address to check approval of the caller */ function _checkValidCallerAndOnBehalfOf(address onBehalfOf) internal view { require( (onBehalfOf == _msgSender()) || (_callerWhitelists[_msgSender()] == true), Errors.CALLER_NOT_ONBEHALFOF_OR_IN_WHITELIST ); } /*////////////////////////////////////////////////////////////// GETTERS & SETTERS //////////////////////////////////////////////////////////////*/ /** * @dev checks if caller is whitelisted * @param caller the caller to check */ function isCallerInWhitelist(address caller) external view returns (bool) { return _callerWhitelists[caller]; } /** * @dev Get WETH address used by WETHGateway */ function getWETHAddress() external view returns (address) { return address(WETH); } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (access/Ownable.sol) pragma solidity ^0.8.0; import "../utils/ContextUpgradeable.sol"; import "../proxy/utils/Initializable.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 OwnableUpgradeable is Initializable, ContextUpgradeable { address private _owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); /** * @dev Initializes the contract setting the deployer as the initial owner. */ function __Ownable_init() internal onlyInitializing { __Context_init_unchained(); __Ownable_init_unchained(); } function __Ownable_init_unchained() internal onlyInitializing { _transferOwnership(_msgSender()); } /** * @dev Returns the address of the current owner. */ function owner() public view virtual returns (address) { return _owner; } /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { require(owner() == _msgSender(), "Ownable: caller is not the owner"); _; } /** * @dev Leaves the contract without owner. It will not be possible to call * `onlyOwner` functions anymore. Can only be called by the current owner. * * NOTE: Renouncing ownership will leave the contract without an owner, * thereby removing 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); } uint256[49] private __gap; }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (proxy/utils/Initializable.sol) pragma solidity ^0.8.0; import "../../utils/AddressUpgradeable.sol"; /** * @dev This is a base contract to aid in writing upgradeable contracts, or any kind of contract that will be deployed * behind a proxy. Since a proxied contract can't have a constructor, it's common to move constructor logic to an * external initializer function, usually called `initialize`. It then becomes necessary to protect this initializer * function so it can only be called once. The {initializer} modifier provided by this contract will have this effect. * * TIP: To avoid leaving the proxy in an uninitialized state, the initializer function should be called as early as * possible by providing the encoded function call as the `_data` argument to {ERC1967Proxy-constructor}. * * CAUTION: When used with inheritance, manual care must be taken to not invoke a parent initializer twice, or to ensure * that all initializers are idempotent. This is not verified automatically as constructors are by Solidity. * * [CAUTION] * ==== * Avoid leaving a contract uninitialized. * * An uninitialized contract can be taken over by an attacker. This applies to both a proxy and its implementation * contract, which may impact the proxy. To initialize the implementation contract, you can either invoke the * initializer manually, or you can include a constructor to automatically mark it as initialized when it is deployed: * * [.hljs-theme-light.nopadding] * ``` * /// @custom:oz-upgrades-unsafe-allow constructor * constructor() initializer {} * ``` * ==== */ abstract contract Initializable { /** * @dev Indicates that the contract has been initialized. */ bool private _initialized; /** * @dev Indicates that the contract is in the process of being initialized. */ bool private _initializing; /** * @dev Modifier to protect an initializer function from being invoked twice. */ modifier initializer() { // If the contract is initializing we ignore whether _initialized is set in order to support multiple // inheritance patterns, but we only do this in the context of a constructor, because in other contexts the // contract may have been reentered. require(_initializing ? _isConstructor() : !_initialized, "Initializable: contract is already initialized"); bool isTopLevelCall = !_initializing; if (isTopLevelCall) { _initializing = true; _initialized = true; } _; if (isTopLevelCall) { _initializing = false; } } /** * @dev Modifier to protect an initialization function so that it can only be invoked by functions with the * {initializer} modifier, directly or indirectly. */ modifier onlyInitializing() { require(_initializing, "Initializable: contract is not initializing"); _; } function _isConstructor() private view returns (bool) { return !AddressUpgradeable.isContract(address(this)); } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/IERC20Metadata.sol) pragma solidity ^0.8.0; import "../IERC20Upgradeable.sol"; /** * @dev Interface for the optional metadata functions from the ERC20 standard. * * _Available since v4.1._ */ interface IERC20MetadataUpgradeable is IERC20Upgradeable { /** * @dev Returns the name of the token. */ function name() external view returns (string memory); /** * @dev Returns the symbol of the token. */ function symbol() external view returns (string memory); /** * @dev Returns the decimals places of the token. */ function decimals() external view returns (uint8); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (token/ERC20/IERC20.sol) pragma solidity ^0.8.0; /** * @dev Interface of the ERC20 standard as defined in the EIP. */ interface IERC20Upgradeable { /** * @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 `recipient`. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transfer(address recipient, 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 `sender` to `recipient` 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 sender, address recipient, uint256 amount ) external returns (bool); /** * @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); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (token/ERC721/IERC721Receiver.sol) pragma solidity ^0.8.0; /** * @title ERC721 token receiver interface * @dev Interface for any contract that wants to support safeTransfers * from ERC721 asset contracts. */ interface IERC721ReceiverUpgradeable { /** * @dev Whenever an {IERC721} `tokenId` token is transferred to this contract via {IERC721-safeTransferFrom} * by `operator` from `from`, this function is called. * * It must return its Solidity selector to confirm the token transfer. * If any other value is returned or the interface is not implemented by the recipient, the transfer will be reverted. * * The selector can be obtained in Solidity with `IERC721.onERC721Received.selector`. */ function onERC721Received( address operator, address from, uint256 tokenId, bytes calldata data ) external returns (bytes4); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (token/ERC721/IERC721.sol) pragma solidity ^0.8.0; import "../../utils/introspection/IERC165Upgradeable.sol"; /** * @dev Required interface of an ERC721 compliant contract. */ interface IERC721Upgradeable is IERC165Upgradeable { /** * @dev Emitted when `tokenId` token is transferred from `from` to `to`. */ event Transfer(address indexed from, address indexed to, uint256 indexed tokenId); /** * @dev Emitted when `owner` enables `approved` to manage the `tokenId` token. */ event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId); /** * @dev Emitted when `owner` enables or disables (`approved`) `operator` to manage all of its assets. */ event ApprovalForAll(address indexed owner, address indexed operator, bool approved); /** * @dev Returns the number of tokens in ``owner``'s account. */ function balanceOf(address owner) external view returns (uint256 balance); /** * @dev Returns the owner of the `tokenId` token. * * Requirements: * * - `tokenId` must exist. */ function ownerOf(uint256 tokenId) external view returns (address owner); /** * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients * are aware of the ERC721 protocol to prevent tokens from being forever locked. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If the caller is not `from`, it must be have been allowed to move this token by either {approve} or {setApprovalForAll}. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function safeTransferFrom( address from, address to, uint256 tokenId ) external; /** * @dev Transfers `tokenId` token from `from` to `to`. * * WARNING: Usage of this method is discouraged, use {safeTransferFrom} whenever possible. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must be owned by `from`. * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}. * * Emits a {Transfer} event. */ function transferFrom( address from, address to, uint256 tokenId ) external; /** * @dev Gives permission to `to` to transfer `tokenId` token to another account. * The approval is cleared when the token is transferred. * * Only a single account can be approved at a time, so approving the zero address clears previous approvals. * * Requirements: * * - The caller must own the token or be an approved operator. * - `tokenId` must exist. * * Emits an {Approval} event. */ function approve(address to, uint256 tokenId) external; /** * @dev Returns the account approved for `tokenId` token. * * Requirements: * * - `tokenId` must exist. */ function getApproved(uint256 tokenId) external view returns (address operator); /** * @dev Approve or remove `operator` as an operator for the caller. * Operators can call {transferFrom} or {safeTransferFrom} for any token owned by the caller. * * Requirements: * * - The `operator` cannot be the caller. * * Emits an {ApprovalForAll} event. */ function setApprovalForAll(address operator, bool _approved) external; /** * @dev Returns if the `operator` is allowed to manage all of the assets of `owner`. * * See {setApprovalForAll} */ function isApprovedForAll(address owner, address operator) external view returns (bool); /** * @dev Safely transfers `tokenId` token from `from` to `to`. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function safeTransferFrom( address from, address to, uint256 tokenId, bytes calldata data ) external; }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (token/ERC721/utils/ERC721Holder.sol) pragma solidity ^0.8.0; import "../IERC721ReceiverUpgradeable.sol"; import "../../../proxy/utils/Initializable.sol"; /** * @dev Implementation of the {IERC721Receiver} interface. * * Accepts all token transfers. * Make sure the contract is able to use its token with {IERC721-safeTransferFrom}, {IERC721-approve} or {IERC721-setApprovalForAll}. */ contract ERC721HolderUpgradeable is Initializable, IERC721ReceiverUpgradeable { function __ERC721Holder_init() internal onlyInitializing { __ERC721Holder_init_unchained(); } function __ERC721Holder_init_unchained() internal onlyInitializing { } /** * @dev See {IERC721Receiver-onERC721Received}. * * Always returns `IERC721Receiver.onERC721Received.selector`. */ function onERC721Received( address, address, uint256, bytes memory ) public virtual override returns (bytes4) { return this.onERC721Received.selector; } uint256[50] private __gap; }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/Address.sol) pragma solidity ^0.8.0; /** * @dev Collection of functions related to the address type */ library AddressUpgradeable { /** * @dev Returns true if `account` is a contract. * * [IMPORTANT] * ==== * It is unsafe to assume that an address for which this function returns * false is an externally-owned account (EOA) and not a contract. * * Among others, `isContract` will return false for the following * types of addresses: * * - an externally-owned account * - a contract in construction * - an address where a contract will be created * - an address where a contract lived, but was destroyed * ==== */ function isContract(address account) internal view returns (bool) { // This method relies on extcodesize, which returns 0 for contracts in // construction, since the code is only stored at the end of the // constructor execution. uint256 size; assembly { size := extcodesize(account) } return size > 0; } /** * @dev Replacement for Solidity's `transfer`: sends `amount` wei to * `recipient`, forwarding all available gas and reverting on errors. * * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost * of certain opcodes, possibly making contracts go over the 2300 gas limit * imposed by `transfer`, making them unable to receive funds via * `transfer`. {sendValue} removes this limitation. * * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more]. * * IMPORTANT: because control is transferred to `recipient`, care must be * taken to not create reentrancy vulnerabilities. Consider using * {ReentrancyGuard} or the * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. */ function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, "Address: insufficient balance"); (bool success, ) = recipient.call{value: amount}(""); require(success, "Address: unable to send value, recipient may have reverted"); } /** * @dev Performs a Solidity function call using a low level `call`. A * plain `call` is an unsafe replacement for a function call: use this * function instead. * * If `target` reverts with a revert reason, it is bubbled up by this * function (like regular Solidity function calls). * * Returns the raw returned data. To convert to the expected return value, * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`]. * * Requirements: * * - `target` must be a contract. * - calling `target` with `data` must not revert. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCall(target, data, "Address: low-level call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with * `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { return functionCallWithValue(target, data, 0, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but also transferring `value` wei to `target`. * * Requirements: * * - the calling contract must have an ETH balance of at least `value`. * - the called Solidity function must be `payable`. * * _Available since v3.1._ */ function functionCallWithValue( address target, bytes memory data, uint256 value ) internal returns (bytes memory) { return functionCallWithValue(target, data, value, "Address: low-level call with value failed"); } /** * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but * with `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCallWithValue( address target, bytes memory data, uint256 value, string memory errorMessage ) internal returns (bytes memory) { require(address(this).balance >= value, "Address: insufficient balance for call"); require(isContract(target), "Address: call to non-contract"); (bool success, bytes memory returndata) = target.call{value: value}(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) { return functionStaticCall(target, data, "Address: low-level static call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall( address target, bytes memory data, string memory errorMessage ) internal view returns (bytes memory) { require(isContract(target), "Address: static call to non-contract"); (bool success, bytes memory returndata) = target.staticcall(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the * revert reason using the provided one. * * _Available since v4.3._ */ function verifyCallResult( bool success, bytes memory returndata, string memory errorMessage ) internal pure returns (bytes memory) { if (success) { return returndata; } else { // Look for revert reason and bubble it up if present if (returndata.length > 0) { // The easiest way to bubble the revert reason is using memory via assembly assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/Context.sol) pragma solidity ^0.8.0; import "../proxy/utils/Initializable.sol"; /** * @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 ContextUpgradeable is Initializable { function __Context_init() internal onlyInitializing { __Context_init_unchained(); } function __Context_init_unchained() internal onlyInitializing { } function _msgSender() internal view virtual returns (address) { return msg.sender; } function _msgData() internal view virtual returns (bytes calldata) { return msg.data; } uint256[50] private __gap; }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/Counters.sol) pragma solidity ^0.8.0; /** * @title Counters * @author Matt Condon (@shrugs) * @dev Provides counters that can only be incremented, decremented or reset. This can be used e.g. to track the number * of elements in a mapping, issuing ERC721 ids, or counting request ids. * * Include with `using Counters for Counters.Counter;` */ library CountersUpgradeable { struct Counter { // This variable should never be directly accessed by users of the library: interactions must be restricted to // the library's function. As of Solidity v0.5.2, this cannot be enforced, though there is a proposal to add // this feature: see https://github.com/ethereum/solidity/issues/4637 uint256 _value; // default: 0 } function current(Counter storage counter) internal view returns (uint256) { return counter._value; } function increment(Counter storage counter) internal { unchecked { counter._value += 1; } } function decrement(Counter storage counter) internal { uint256 value = counter._value; require(value > 0, "Counter: decrement overflow"); unchecked { counter._value = value - 1; } } function reset(Counter storage counter) internal { counter._value = 0; } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/introspection/IERC165.sol) pragma solidity ^0.8.0; /** * @dev Interface of the ERC165 standard, as defined in the * https://eips.ethereum.org/EIPS/eip-165[EIP]. * * Implementers can declare support of contract interfaces, which can then be * queried by others ({ERC165Checker}). * * For an implementation, see {ERC165}. */ interface IERC165Upgradeable { /** * @dev Returns true if this contract implements the interface defined by * `interfaceId`. See the corresponding * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section] * to learn more about how these ids are created. * * This function call must use less than 30 000 gas. */ function supportsInterface(bytes4 interfaceId) external view returns (bool); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (token/ERC20/IERC20.sol) pragma solidity ^0.8.0; /** * @dev Interface of the ERC20 standard as defined in the EIP. */ interface IERC20 { /** * @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 `recipient`. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transfer(address recipient, 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 `sender` to `recipient` 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 sender, address recipient, uint256 amount ) external returns (bool); /** * @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); }
// SPDX-License-Identifier: agpl-3.0 pragma solidity 0.8.4; import {DataTypes} from "../libraries/types/DataTypes.sol"; import {CountersUpgradeable} from "@openzeppelin/contracts-upgradeable/utils/CountersUpgradeable.sol"; interface IDebtMarket { /*////////////////////////////////////////////////////////////// EVENTS //////////////////////////////////////////////////////////////*/ /** * @dev Emitted on initialization to share location of dependent notes * @param pool The address of the associated lend pool */ event Initialized(address indexed pool); /** * @dev Emitted when a debt listing is created with a fixed price * @param debtId The debt listing identifier * @param debtor The owner of the debt listing * @param nftAsset The address of the underlying NFT used as collateral * @param tokenId The token id of the underlying NFT used as collateral * @param sellType The type of sell ( Fixed price or Auction ) * @param state The state of the actual debt offer ( New,Active,Sold,Canceled ) * @param sellPrice The price for to sell the debt * @param reserveAsset The asset from the reserve * @param debtAmount The total debt value */ event DebtListingCreated( uint256 debtId, address debtor, address indexed nftAsset, uint256 indexed tokenId, DataTypes.DebtMarketType indexed sellType, DataTypes.DebtMarketState state, uint256 sellPrice, address reserveAsset, uint256 debtAmount, uint256 auctionEndTimestamp, uint256 startBiddingPrice ); /** * @dev Emitted when a debt with auction listing is created * @param debtId The debt listing identifier * @param debtor The owner of the debt listing * @param nftAsset The address of the underlying NFT used as collateral * @param tokenId The token id of the underlying NFT used as collateral * @param sellType The type of sell ( Fixed price or Auction ) * @param state The state of the actual debt offer ( New,Active,Sold,Canceled ) * @param sellPrice The price for to sell the debt * @param reserveAsset The asset from the reserve * @param debtAmount The total debt value */ event DebtAuctionCreated( uint256 debtId, address debtor, address indexed nftAsset, uint256 indexed tokenId, DataTypes.DebtMarketType indexed sellType, DataTypes.DebtMarketState state, uint256 sellPrice, address reserveAsset, uint256 debtAmount ); /** * @dev Emitted when a debt listing is canceled * @param onBehalfOf Address of the user who will receive * @param debtId The debt listing identifier * @param marketListing The object of the debt * @param totalByCollection Total debts listings by collection from the actual debtId collection * @param totalByUserAndCollection Total debts listings by user from the actual debtId user */ event DebtListingCanceled( address indexed onBehalfOf, uint256 indexed debtId, DataTypes.DebtMarketListing marketListing, uint256 totalByCollection, uint256 totalByUserAndCollection ); /** * @dev Emitted when a bid is placed on a debt listing with auction * @param bidderAddress Address of the last bidder * @param reserveAsset The asset from the reserve * @param nftAsset The address of the underlying NFT used as collateral * @param tokenId The token id of the underlying NFT used as collateral * @param debtId The debt listing identifier * @param bidPrice Amount that bidder spend on the bid */ event BidPlaced( address bidderAddress, address reserveAsset, address indexed nftAsset, uint256 indexed tokenId, uint256 debtId, uint256 bidPrice ); /** * @dev Emitted when a debt is bought * @param from Address of owner of the debt * @param to Buyer address * @param debtId The debt listing identifier */ event DebtSold(address indexed from, address indexed to, uint256 indexed debtId); /** * @dev Emitted when a debt is claimed * @param from Address of owner of the debt * @param to Claimer address * @param debtId The debt listing identifier */ event DebtClaimed(address indexed from, address indexed to, uint256 indexed debtId); /** * @dev Emited when a new address is authorized to cancel debt listings * @param authorizedAddress Address to authorize */ event AuthorizedAddressChanged(address indexed authorizedAddress, bool isAuthorized); /** * @dev Emitted when the pause is triggered. */ event Paused(); /** * @dev Emitted when the pause is lifted. */ event Unpaused(); /*////////////////////////////////////////////////////////////// MAIN LOGIC //////////////////////////////////////////////////////////////*/ function createDebtListing( address nftAsset, uint256 tokenId, uint256 sellPrice, address onBehalfOf, uint256 startBiddingPrice, uint256 auctionEndTimestamp ) external; function cancelDebtListing(address nftAsset, uint256 tokenId) external; function buy(address nftAsset, uint256 tokenId, address onBehalfOf, uint256 amount) external; function bid(address nftAsset, uint256 tokenId, uint256 bidPrice, address onBehalfOf) external; function claim(address nftAsset, uint256 tokenId, address onBehalfOf) external; /*////////////////////////////////////////////////////////////// GETTERS & SETTERS //////////////////////////////////////////////////////////////*/ function getDebtId(address nftAsset, uint256 tokenId) external view returns (uint256); function getDebt(uint256 debtId) external view returns (DataTypes.DebtMarketListing memory sellDebt); function getDebtIdTracker() external view returns (CountersUpgradeable.Counter memory); function setDeltaBidPercent(uint256 value) external; function setAuthorizedAddress(address newAuthorizedAddress, bool val) external; function paused() external view returns (bool); function setPause(bool val) external; }
// SPDX-License-Identifier: agpl-3.0 pragma solidity 0.8.4; interface IIncentivesController { /** * @dev Called by the corresponding asset on any update that affects the rewards distribution * @param asset The address of the user * @param totalSupply The total supply of the asset in the lending pool * @param userBalance The balance of the user of the asset in the lending pool **/ function handleAction( address asset, uint256 totalSupply, uint256 userBalance ) external; }
// SPDX-License-Identifier: agpl-3.0 pragma solidity 0.8.4; import {ILendPoolAddressesProvider} from "./ILendPoolAddressesProvider.sol"; import {IUToken} from "./IUToken.sol"; import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol"; import {IERC721Upgradeable} from "@openzeppelin/contracts-upgradeable/token/ERC721/IERC721Upgradeable.sol"; import {DataTypes} from "../libraries/types/DataTypes.sol"; interface ILendPool { /*////////////////////////////////////////////////////////////// EVENTS //////////////////////////////////////////////////////////////*/ /** * @dev Emitted when _rescuer is modified in the LendPool * @param newRescuer The address of the new rescuer **/ event RescuerChanged(address indexed newRescuer); /** * @dev Emitted on deposit() * @param user The address initiating the deposit * @param amount The amount deposited * @param reserve The address of the underlying asset of the reserve * @param onBehalfOf The beneficiary of the deposit, receiving the uTokens * @param referral The referral code used **/ event Deposit( address user, address indexed reserve, uint256 amount, address indexed onBehalfOf, uint16 indexed referral ); /** * @dev Emitted on withdraw() * @param user The address initiating the withdrawal, owner of uTokens * @param reserve The address of the underlyng asset being withdrawn * @param amount The amount to be withdrawn * @param to Address that will receive the underlying **/ event Withdraw(address indexed user, address indexed reserve, uint256 amount, address indexed to); /** * @dev Emitted on borrow() when loan needs to be opened * @param user The address of the user initiating the borrow(), receiving the funds * @param reserve The address of the underlying asset being borrowed * @param amount The amount borrowed out * @param nftAsset The address of the underlying NFT used as collateral * @param nftTokenId The token id of the underlying NFT used as collateral * @param onBehalfOf The address that will be getting the loan * @param referral The referral code used * @param nftConfigFee an estimated gas cost fee for configuring the NFT **/ event Borrow( address user, address indexed reserve, uint256 amount, address nftAsset, uint256 nftTokenId, address indexed onBehalfOf, uint256 borrowRate, uint256 loanId, uint16 indexed referral, uint256 nftConfigFee ); /** * @dev Emitted on repay() * @param user The address of the user initiating the repay(), providing the funds * @param reserve The address of the underlying asset of the reserve * @param amount The amount repaid * @param nftAsset The address of the underlying NFT used as collateral * @param nftTokenId The token id of the underlying NFT used as collateral * @param borrower The beneficiary of the repayment, getting his debt reduced * @param loanId The loan ID of the NFT loans **/ event Repay( address user, address indexed reserve, uint256 amount, address indexed nftAsset, uint256 nftTokenId, address indexed borrower, uint256 loanId ); /** * @dev Emitted when a borrower's loan is auctioned. * @param user The address of the user initiating the auction * @param reserve The address of the underlying asset of the reserve * @param bidPrice The price of the underlying reserve given by the bidder * @param nftAsset The address of the underlying NFT used as collateral * @param nftTokenId The token id of the underlying NFT used as collateral * @param onBehalfOf The address that will be getting the NFT * @param loanId The loan ID of the NFT loans **/ event Auction( address user, address indexed reserve, uint256 bidPrice, address indexed nftAsset, uint256 nftTokenId, address onBehalfOf, address indexed borrower, uint256 loanId ); /** * @dev Emitted on redeem() * @param user The address of the user initiating the redeem(), providing the funds * @param reserve The address of the underlying asset of the reserve * @param borrowAmount The borrow amount repaid * @param nftAsset The address of the underlying NFT used as collateral * @param nftTokenId The token id of the underlying NFT used as collateral * @param loanId The loan ID of the NFT loans **/ event Redeem( address user, address indexed reserve, uint256 borrowAmount, uint256 fineAmount, address indexed nftAsset, uint256 nftTokenId, address indexed borrower, uint256 loanId ); /** * @dev Emitted when a borrower's loan is liquidated. * @param user The address of the user initiating the auction * @param reserve The address of the underlying asset of the reserve * @param repayAmount The amount of reserve repaid by the liquidator * @param remainAmount The amount of reserve received by the borrower * @param loanId The loan ID of the NFT loans **/ event Liquidate( address user, address indexed reserve, uint256 repayAmount, uint256 remainAmount, address indexed nftAsset, uint256 nftTokenId, address indexed borrower, uint256 loanId ); /** * @dev Emitted when an NFT is purchased via Buyout. * @param user The address of the user initiating the Buyout * @param reserve The address of the underlying asset of the reserve * @param buyoutAmount The amount of reserve paid by the buyer * @param borrowAmount The loan borrowed amount * @param nftAsset The amount of reserve received by the borrower * @param nftTokenId The token id of the underlying NFT used as collateral * @param borrower The loan borrower address * @param onBehalfOf The receiver of the underlying NFT * @param loanId The loan ID of the NFT loans **/ event Buyout( address user, address indexed reserve, uint256 buyoutAmount, uint256 borrowAmount, address indexed nftAsset, uint256 nftTokenId, address borrower, address onBehalfOf, uint256 indexed loanId ); /** * @dev Emitted when an NFT configuration is triggered. * @param user The NFT holder * @param nftAsset The NFT collection address * @param nftTokenId The NFT token Id **/ event ValuationApproved(address indexed user, address indexed nftAsset, uint256 indexed nftTokenId); /** * @dev Emitted when the pause is triggered. */ event Paused(); /** * @dev Emitted when the pause is lifted. */ event Unpaused(); /** * @dev Emitted when the pause time is updated. */ event PausedTimeUpdated(uint256 startTime, uint256 durationTime); /** * @dev Emitted when the state of a reserve is updated. NOTE: This event is actually declared * in the ReserveLogic library and emitted in the updateInterestRates() function. Since the function is internal, * the event will actually be fired by the LendPool contract. The event is therefore replicated here so it * gets added to the LendPool ABI * @param reserve The address of the underlying asset of the reserve * @param liquidityRate The new liquidity rate * @param variableBorrowRate The new variable borrow rate * @param liquidityIndex The new liquidity index * @param variableBorrowIndex The new variable borrow index **/ event ReserveDataUpdated( address indexed reserve, uint256 liquidityRate, uint256 variableBorrowRate, uint256 liquidityIndex, uint256 variableBorrowIndex ); /** @dev Emitted after the address of the interest rate strategy contract has been updated */ event ReserveInterestRateAddressChanged(address indexed asset, address indexed rateAddress); /** @dev Emitted after setting the configuration bitmap of the reserve as a whole */ event ReserveConfigurationChanged(address indexed asset, uint256 configuration); /** @dev Emitted after setting the configuration bitmap of the NFT collection as a whole */ event NftConfigurationChanged(address indexed asset, uint256 configuration); /** @dev Emitted after setting the configuration bitmap of the NFT as a whole */ event NftConfigurationByIdChanged(address indexed asset, uint256 indexed nftTokenId, uint256 configuration); /** @dev Emitted after setting the new safe health factor value for redeems */ event SafeHealthFactorUpdated(uint256 indexed newSafeHealthFactor); /*////////////////////////////////////////////////////////////// RESCUERS //////////////////////////////////////////////////////////////*/ /** * @notice Returns current rescuer * @return Rescuer's address */ function rescuer() external view returns (address); /** * @notice Assigns the rescuer role to a given address. * @param newRescuer New rescuer's address */ function updateRescuer(address newRescuer) external; /** * @notice Rescue tokens or ETH locked up in this contract. * @param tokenContract ERC20 token contract address * @param to Recipient address * @param amount Amount to withdraw * @param rescueETH bool to know if we want to rescue ETH or other token */ function rescue(IERC20 tokenContract, address to, uint256 amount, bool rescueETH) external; /** * @notice Rescue NFTs locked up in this contract. * @param nftAsset ERC721 asset contract address * @param tokenId ERC721 token id * @param to Recipient address */ function rescueNFT(IERC721Upgradeable nftAsset, uint256 tokenId, address to) external; /*////////////////////////////////////////////////////////////// MAIN LOGIC //////////////////////////////////////////////////////////////*/ /** * @dev Deposits an `amount` of underlying asset into the reserve, receiving in return overlying uTokens. * - E.g. User deposits 100 USDC and gets in return 100 uusdc * @param reserve The address of the underlying asset to deposit * @param amount The amount to be deposited * @param onBehalfOf The address that will receive the uTokens, same as msg.sender if the user * wants to receive them on his own wallet, or a different address if the beneficiary of uTokens * 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 reserve, uint256 amount, address onBehalfOf, uint16 referralCode) external; /** * @dev Withdraws an `amount` of underlying asset from the reserve, burning the equivalent uTokens owned * E.g. User has 100 uusdc, calls withdraw() and receives 100 USDC, burning the 100 uusdc * @param reserve 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 uToken balance * @param to 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 reserve, uint256 amount, address to) external returns (uint256); /** * @dev Allows users to borrow a specific `amount` of the reserve underlying asset, provided that the borrower * already deposited enough collateral * - E.g. User borrows 100 USDC, receiving the 100 USDC in his wallet * and lock collateral asset in contract * @param reserveAsset The address of the underlying asset to borrow * @param amount The amount to be borrowed * @param nftAsset The address of the underlying NFT used as collateral * @param nftTokenId The token ID of the underlying NFT used as collateral * @param onBehalfOf Address of the user who will receive the loan. 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 * @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 borrow( address reserveAsset, uint256 amount, address nftAsset, uint256 nftTokenId, address onBehalfOf, uint16 referralCode ) external; /** * @notice Repays a borrowed `amount` on a specific reserve, burning the equivalent loan owned * - E.g. User repays 100 USDC, burning loan and receives collateral asset * @param nftAsset The address of the underlying NFT used as collateral * @param nftTokenId The token ID of the underlying NFT used as collateral * @param amount The amount to repay * @return The final amount repaid, loan is burned or not **/ function repay(address nftAsset, uint256 nftTokenId, uint256 amount) external returns (uint256, bool); /** * @dev Function to auction a non-healthy position collateral-wise * - The caller (liquidator) want to buy collateral asset of the user getting liquidated * @param nftAsset The address of the underlying NFT used as collateral * @param nftTokenId The token ID of the underlying NFT used as collateral * @param bidPrice The bid price of the liquidator want to buy the underlying NFT * @param onBehalfOf Address of the user who will get the underlying NFT, same as msg.sender if the user * wants to receive them on his own wallet, or a different address if the beneficiary of NFT * is a different wallet **/ function auction(address nftAsset, uint256 nftTokenId, uint256 bidPrice, address onBehalfOf) external; /** * @dev Function to buyout a non-healthy position collateral-wise * - The bidder want to buy collateral asset of the user getting liquidated * @param nftAsset The address of the underlying NFT used as collateral * @param nftTokenId The token ID of the underlying NFT used as collateral * @param onBehalfOf Address of the user who will get the underlying NFT, same as msg.sender if the user * wants to receive them on his own wallet, or a different address if the beneficiary of NFT * is a different wallet **/ function buyout(address nftAsset, uint256 nftTokenId, address onBehalfOf) external; /** * @notice Redeem a NFT loan which state is in Auction * - E.g. User repays 100 USDC, burning loan and receives collateral asset * @param nftAsset The address of the underlying NFT used as collateral * @param nftTokenId The token ID of the underlying NFT used as collateral * @param amount The amount to repay the debt * @param bidFine The amount of bid fine **/ function redeem(address nftAsset, uint256 nftTokenId, uint256 amount, uint256 bidFine) external returns (uint256); /** * @dev Function to liquidate a non-healthy position collateral-wise * - The caller (liquidator) buy collateral asset of the user getting liquidated, and receives * the collateral asset * @param nftAsset The address of the underlying NFT used as collateral * @param nftTokenId The token ID of the underlying NFT used as collateral **/ function liquidate(address nftAsset, uint256 nftTokenId, uint256 amount) external returns (uint256); /** * @dev Approves valuation of an NFT for a user * @dev Just the NFT holder can trigger the configuration * @param nftAsset The address of the underlying NFT used as collateral * @param nftTokenId The token ID of the underlying NFT used as collateral **/ function approveValuation(address nftAsset, uint256 nftTokenId) external payable; /** * @dev Validates and finalizes an uToken transfer * - Only callable by the overlying uToken of the `asset` * @param asset The address of the underlying asset of the uToken * @param from The user from which the uTokens are transferred * @param to The user receiving the uTokens * @param amount The amount being transferred/withdrawn * @param balanceFromBefore The uToken balance of the `from` user before the transfer * @param balanceToBefore The uToken balance of the `to` user before the transfer */ function finalizeTransfer( address asset, address from, address to, uint256 amount, uint256 balanceFromBefore, uint256 balanceToBefore ) external view; /** * @dev Initializes a reserve, activating it, assigning an uToken and nft loan and an * interest rate strategy * - Only callable by the LendPoolConfigurator contract * @param asset The address of the underlying asset of the reserve * @param uTokenAddress The address of the uToken that will be assigned to the reserve * @param debtTokenAddress The address of the debtToken that will be assigned to the reserve * @param interestRateAddress The address of the interest rate strategy contract **/ function initReserve( address asset, address uTokenAddress, address debtTokenAddress, address interestRateAddress ) external; /** * @dev Initializes a nft, activating it, assigning nft loan and an * interest rate strategy * - Only callable by the LendPoolConfigurator contract * @param asset The address of the underlying asset of the nft **/ function initNft(address asset, address uNftAddress) external; /** * @dev Transfer the last bid amount to the bidder * @param reserveAsset address of the reserver asset (WETH) * @param bidder the bidder address * @param bidAmount the bid amount */ function transferBidAmount(address reserveAsset, address bidder, uint256 bidAmount) external; /*////////////////////////////////////////////////////////////// GETTERS & SETTERS //////////////////////////////////////////////////////////////*/ /** * @dev Returns the cached LendPoolAddressesProvider connected to this contract **/ function getAddressesProvider() external view returns (ILendPoolAddressesProvider); /** * @dev Returns the normalized income 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); /** * @dev Returns the normalized variable debt per unit of asset * @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); /** * @dev Returns the state and configuration of the reserve * @param asset The address of the underlying asset of the reserve * @return The state of the reserve **/ function getReserveData(address asset) external view returns (DataTypes.ReserveData memory); /** * @dev Returns the list of the initialized reserves * @return the list of initialized reserves **/ function getReservesList() external view returns (address[] memory); /** * @dev Returns the state and configuration of the nft * @param asset The address of the underlying asset of the nft * @return The status of the nft **/ function getNftData(address asset) external view returns (DataTypes.NftData memory); /** * @dev Returns the configuration of the nft asset * @param asset The address of the underlying asset of the nft * @param tokenId NFT asset ID * @return The configuration of the nft asset **/ function getNftAssetConfig( address asset, uint256 tokenId ) external view returns (DataTypes.NftConfigurationMap memory); /** * @dev Returns the loan data of the NFT * @param nftAsset The address of the NFT * @param reserveAsset The address of the Reserve * @return totalCollateralInETH the total collateral in ETH of the NFT * @return totalCollateralInReserve the total collateral in Reserve of the NFT * @return availableBorrowsInETH the borrowing power in ETH of the NFT * @return availableBorrowsInReserve the borrowing power in Reserve of the NFT * @return ltv the loan to value of the user * @return liquidationThreshold the liquidation threshold of the NFT * @return liquidationBonus the liquidation bonus of the NFT **/ function getNftCollateralData( address nftAsset, uint256 nftTokenId, address reserveAsset ) external view returns ( uint256 totalCollateralInETH, uint256 totalCollateralInReserve, uint256 availableBorrowsInETH, uint256 availableBorrowsInReserve, uint256 ltv, uint256 liquidationThreshold, uint256 liquidationBonus ); /** * @dev Returns the debt data of the NFT * @param nftAsset The address of the NFT * @param nftTokenId The token id of the NFT * @return loanId the loan id of the NFT * @return reserveAsset the address of the Reserve * @return totalCollateral the total power of the NFT * @return totalDebt the total debt of the NFT * @return availableBorrows the borrowing power left of the NFT * @return healthFactor the current health factor of the NFT **/ function getNftDebtData( address nftAsset, uint256 nftTokenId ) external view returns ( uint256 loanId, address reserveAsset, uint256 totalCollateral, uint256 totalDebt, uint256 availableBorrows, uint256 healthFactor ); /** * @dev Returns the auction data of the NFT * @param nftAsset The address of the NFT * @param nftTokenId The token id of the NFT * @return loanId the loan id of the NFT * @return bidderAddress the highest bidder address of the loan * @return bidPrice the highest bid price in Reserve of the loan * @return bidBorrowAmount the borrow amount in Reserve of the loan * @return bidFine the penalty fine of the loan **/ function getNftAuctionData( address nftAsset, uint256 nftTokenId ) external view returns (uint256 loanId, address bidderAddress, uint256 bidPrice, uint256 bidBorrowAmount, uint256 bidFine); /** * @dev Returns the list of nft addresses in the protocol **/ function getNftsList() external view returns (address[] memory); /** * @dev Returns the configuration of the reserve * @param asset The address of the underlying asset of the reserve * @return The configuration of the reserve **/ function getReserveConfiguration(address asset) external view returns (DataTypes.ReserveConfigurationMap memory); /** * @dev Sets the configuration bitmap of the reserve as a whole * - Only callable by the LendPoolConfigurator contract * @param asset The address of the underlying asset of the reserve * @param configuration The new configuration bitmap **/ function setReserveConfiguration(address asset, uint256 configuration) external; /** * @dev Returns the configuration of the NFT * @param asset The address of the asset of the NFT * @return The configuration of the NFT **/ function getNftConfiguration(address asset) external view returns (DataTypes.NftConfigurationMap memory); /** * @dev Sets the configuration bitmap of the NFT as a whole * - Only callable by the LendPoolConfigurator contract * @param asset The address of the asset of the NFT * @param configuration The new configuration bitmap **/ function setNftConfiguration(address asset, uint256 configuration) external; /** * @dev Returns the configuration of the NFT * @param asset The address of the asset of the NFT * @param tokenId the Token Id of the NFT * @return The configuration of the NFT **/ function getNftConfigByTokenId( address asset, uint256 tokenId ) external view returns (DataTypes.NftConfigurationMap memory); /** * @dev Sets the configuration bitmap of the NFT as a whole * - Only callable by the LendPoolConfigurator contract * @param asset The address of the asset of the NFT * @param nftTokenId the NFT tokenId * @param configuration The new configuration bitmap **/ function setNftConfigByTokenId(address asset, uint256 nftTokenId, uint256 configuration) external; /** * @dev Returns if the LendPool is paused */ function paused() external view returns (bool); /** * @dev Set the _pause state of a reserve * - Only callable by the LendPool contract * @param val `true` to pause the reserve, `false` to un-pause it */ function setPause(bool val) external; /** * @dev Returns the _pause time of a reserve */ function getPausedTime() external view returns (uint256, uint256); /** * @dev Set the _pause state of the auctions * @param startTime when it will start to pause * @param durationTime how long it will pause */ function setPausedTime(uint256 startTime, uint256 durationTime) external; /** * @dev Returns the bidDelta percentage - debt compounded + fees. **/ function getBidDelta() external view returns (uint256); /** * @dev sets the bidDelta percentage - debt compounded + fees. * @param bidDelta the amount to charge to the user **/ function setBidDelta(uint256 bidDelta) external; /** * @dev Returns the max timeframe between NFT config triggers and borrows **/ function getTimeframe() external view returns (uint256); /** * @dev Sets the max timeframe between NFT config triggers and borrows * @param timeframe the number of seconds for the timeframe **/ function setTimeframe(uint256 timeframe) external; /** * @dev Returns the configFee amount **/ function getConfigFee() external view returns (uint256); /** * @dev sets the fee for configuringNFTAsCollateral * @param configFee the amount to charge to the user **/ function setConfigFee(uint256 configFee) external; /** * @dev Returns the auctionDurationConfigFee amount **/ function getAuctionDurationConfigFee() external view returns (uint256); /** * @dev sets the fee to be charged on first bid on nft * @param auctionDurationConfigFee the amount to charge to the user **/ function setAuctionDurationConfigFee(uint256 auctionDurationConfigFee) external; /** * @dev Returns the maximum number of reserves supported to be listed in this LendPool */ function getMaxNumberOfReserves() external view returns (uint256); /** * @dev Sets the max number of reserves in the protocol * @param val the value to set the max number of reserves **/ function setMaxNumberOfReserves(uint256 val) external; /** * @notice Returns current safe health factor * @return The safe health factor value */ function getSafeHealthFactor() external view returns (uint256); /** * @notice Update the safe health factor value for redeems * @param newSafeHealthFactor New safe health factor value */ function updateSafeHealthFactor(uint256 newSafeHealthFactor) external; /** * @dev Returns the maximum number of nfts supported to be listed in this LendPool */ function getMaxNumberOfNfts() external view returns (uint256); /** * @dev Sets the max number of NFTs in the protocol * @param val the value to set the max number of NFTs **/ function setMaxNumberOfNfts(uint256 val) external; /** * @dev Returns the fee percentage for liquidations **/ function getLiquidateFeePercentage() external view returns (uint256); /** * @dev Sets the fee percentage for liquidations * @param percentage the fee percentage to be set **/ function setLiquidateFeePercentage(uint256 percentage) external; /** * @dev Updates the address of the interest rate strategy contract * - Only callable by the LendPoolConfigurator contract * @param asset The address of the underlying asset of the reserve * @param rateAddress The address of the interest rate strategy contract **/ function setReserveInterestRateAddress(address asset, address rateAddress) external; /** * @dev Sets the max supply and token ID for a given asset * @param asset The address to set the data * @param maxSupply The max supply value * @param maxTokenId The max token ID value **/ function setNftMaxSupplyAndTokenId(address asset, uint256 maxSupply, uint256 maxTokenId) external; /** * @dev Updates the liquidity cumulative index and the variable borrow index. * @param reserve the reserve object **/ function updateReserveState(address reserve) external; /** * @dev Updates the reserve current stable borrow rate, the current variable borrow rate and the current liquidity rate * @param reserve The address of the reserve to be updated **/ function updateReserveInterestRates(address reserve) external; }
// SPDX-License-Identifier: agpl-3.0 pragma solidity 0.8.4; /** * @title LendPoolAddressesProvider contract * @dev Main registry of addresses part of or connected to the protocol, including permissioned roles * - Acting also as factory of proxies and admin of those, so with right to change its implementations * - Owned by the Unlockd Governance * @author BendDao; Forked and edited by Unlockd **/ interface ILendPoolAddressesProvider { event MarketIdSet(string newMarketId); event LendPoolUpdated(address indexed newAddress, bytes encodedCallData); event ConfigurationAdminUpdated(address indexed newAddress); event EmergencyAdminUpdated(address indexed newAddress); event LendPoolConfiguratorUpdated(address indexed newAddress, bytes encodedCallData); event ReserveOracleUpdated(address indexed newAddress); event NftOracleUpdated(address indexed newAddress); event LendPoolLoanUpdated(address indexed newAddress, bytes encodedCallData); event ProxyCreated(bytes32 id, address indexed newAddress); event AddressSet(bytes32 id, address indexed newAddress, bool hasProxy, bytes encodedCallData); event UNFTRegistryUpdated(address indexed newAddress); event IncentivesControllerUpdated(address indexed newAddress); event UIDataProviderUpdated(address indexed newAddress); event UnlockdDataProviderUpdated(address indexed newAddress); event WalletBalanceProviderUpdated(address indexed newAddress); event LendPoolLiquidatorUpdated(address indexed newAddress); event LtvManagerUpdated(address indexed newAddress); /** * @dev Returns the id of the Unlockd market to which this contracts points to * @return The market id **/ function getMarketId() external view returns (string memory); /** * @dev Allows to set the market which this LendPoolAddressesProvider represents * @param marketId The market id */ function setMarketId(string calldata marketId) external; /** * @dev Sets an address for an id replacing the address saved in the addresses map * 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; /** * @dev 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 `implementationAddress` * 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 impl The address of the new implementation */ function setAddressAsProxy(bytes32 id, address impl, bytes memory encodedCallData) external; /** * @dev Returns an address by id * @return The address */ function getAddress(bytes32 id) external view returns (address); /** * @dev Returns the address of the LendPool proxy * @return The LendPool proxy address **/ function getLendPool() external view returns (address); /** * @dev Updates the implementation of the LendPool, or creates the proxy * setting the new `pool` implementation on the first time calling it * @param pool The new LendPool implementation * @param encodedCallData calldata to execute **/ function setLendPoolImpl(address pool, bytes memory encodedCallData) external; /** * @dev Returns the address of the LendPoolConfigurator proxy * @return The LendPoolConfigurator proxy address **/ function getLendPoolConfigurator() external view returns (address); /** * @dev Updates the implementation of the LendPoolConfigurator, or creates the proxy * setting the new `configurator` implementation on the first time calling it * @param configurator The new LendPoolConfigurator implementation * @param encodedCallData calldata to execute **/ function setLendPoolConfiguratorImpl(address configurator, bytes memory encodedCallData) external; /** * @dev returns the address of the LendPool admin * @return the LendPoolAdmin address **/ function getPoolAdmin() external view returns (address); /** * @dev sets the address of the LendPool admin * @param admin the LendPoolAdmin address **/ function setPoolAdmin(address admin) external; /** * @dev returns the address of the emergency admin * @return the EmergencyAdmin address **/ function getEmergencyAdmin() external view returns (address); /** * @dev sets the address of the emergency admin * @param admin the EmergencyAdmin address **/ function setEmergencyAdmin(address admin) external; /** * @dev returns the address of the reserve oracle * @return the ReserveOracle address **/ function getReserveOracle() external view returns (address); /** * @dev sets the address of the reserve oracle * @param reserveOracle the ReserveOracle address **/ function setReserveOracle(address reserveOracle) external; /** * @dev returns the address of the NFT oracle * @return the NFTOracle address **/ function getNFTOracle() external view returns (address); /** * @dev sets the address of the NFT oracle * @param nftOracle the NFTOracle address **/ function setNFTOracle(address nftOracle) external; /** * @dev returns the address of the lendpool loan * @return the LendPoolLoan address **/ function getLendPoolLoan() external view returns (address); /** * @dev sets the address of the lendpool loan * @param loan the LendPoolLoan address * @param encodedCallData calldata to execute **/ function setLendPoolLoanImpl(address loan, bytes memory encodedCallData) external; /** * @dev returns the address of the UNFT Registry * @return the UNFTRegistry address **/ function getUNFTRegistry() external view returns (address); /** * @dev sets the address of the UNFT registry * @param factory the UNFTRegistry address **/ function setUNFTRegistry(address factory) external; /** * @dev returns the address of the incentives controller * @return the IncentivesController address **/ function getIncentivesController() external view returns (address); /** * @dev sets the address of the incentives controller * @param controller the IncentivesController address **/ function setIncentivesController(address controller) external; /** * @dev returns the address of the UI data provider * @return the UIDataProvider address **/ function getUIDataProvider() external view returns (address); /** * @dev sets the address of the UI data provider * @param provider the UIDataProvider address **/ function setUIDataProvider(address provider) external; /** * @dev returns the address of the Unlockd data provider * @return the UnlockdDataProvider address **/ function getUnlockdDataProvider() external view returns (address); /** * @dev sets the address of the Unlockd data provider * @param provider the UnlockdDataProvider address **/ function setUnlockdDataProvider(address provider) external; /** * @dev returns the address of the wallet balance provider * @return the WalletBalanceProvider address **/ function getWalletBalanceProvider() external view returns (address); /** * @dev sets the address of the wallet balance provider * @param provider the WalletBalanceProvider address **/ function setWalletBalanceProvider(address provider) external; /** * @dev returns the address of the LendPool liquidator contract **/ function getLendPoolLiquidator() external view returns (address); /** * @dev sets the address of the LendPool liquidator contract * @param liquidator the LendPool liquidator address **/ function setLendPoolLiquidator(address liquidator) external; }
// SPDX-License-Identifier: agpl-3.0 pragma solidity 0.8.4; import {DataTypes} from "../libraries/types/DataTypes.sol"; import {CountersUpgradeable} from "@openzeppelin/contracts-upgradeable/utils/CountersUpgradeable.sol"; interface ILendPoolLoan { /** * @dev Emitted on initialization to share location of dependent notes * @param pool The address of the associated lend pool */ event Initialized(address indexed pool); /** * @dev Emitted when a loan is created * @param user The address initiating the action */ event LoanCreated( address indexed user, address indexed onBehalfOf, uint256 indexed loanId, address nftAsset, uint256 nftTokenId, address reserveAsset, uint256 amount, uint256 borrowIndex ); /** * @dev Emitted when a loan is updated * @param user The address initiating the action */ event LoanUpdated( address indexed user, uint256 indexed loanId, address nftAsset, uint256 nftTokenId, address reserveAsset, uint256 amountAdded, uint256 amountTaken, uint256 borrowIndex ); /** * @dev Emitted when a loan is repaid by the borrower * @param user The address initiating the action */ event LoanRepaid( address indexed user, uint256 indexed loanId, address nftAsset, uint256 nftTokenId, address reserveAsset, uint256 amount, uint256 borrowIndex ); /** * @dev Emitted when a loan is auction by the liquidator * @param user The address initiating the action */ event LoanAuctioned( address indexed user, uint256 indexed loanId, address nftAsset, uint256 nftTokenId, uint256 amount, uint256 borrowIndex, address bidder, uint256 price, address previousBidder, uint256 previousPrice ); /** * @dev Emitted when a loan is bought out * @param loanId The loanId that was bought out */ event LoanBoughtOut( address indexed user, uint256 indexed loanId, address nftAsset, uint256 nftTokenId, uint256 bidBorrowAmount, uint256 borrowIndex, uint256 buyoutAmount ); /** * @dev Emitted when a loan is redeemed * @param user The address initiating the action */ event LoanRedeemed( address indexed user, uint256 indexed loanId, address nftAsset, uint256 nftTokenId, address reserveAsset, uint256 amountTaken, uint256 borrowIndex ); /** * @dev Emitted when a loan is liquidate by the liquidator * @param user The address initiating the action */ event LoanLiquidated( address indexed user, uint256 indexed loanId, address nftAsset, uint256 nftTokenId, address reserveAsset, uint256 amount, uint256 borrowIndex ); /** * @dev Emitted when a loan is liquidated in an external market */ event LoanLiquidatedMarket( uint256 indexed loanId, address nftAsset, uint256 nftTokenId, address reserveAsset, uint256 amount, uint256 borrowIndex ); function initNft(address nftAsset, address uNftAddress) external; /** * @dev Create store a loan object with some params * @param initiator The address of the user initiating the borrow * @param onBehalfOf The address receiving the loan * @param nftAsset The address of the underlying NFT asset * @param nftTokenId The token Id of the underlying NFT asset * @param uNftAddress The address of the uNFT token * @param reserveAsset The address of the underlying reserve asset * @param amount The loan amount * @param borrowIndex The index to get the scaled loan amount */ function createLoan( address initiator, address onBehalfOf, address nftAsset, uint256 nftTokenId, address uNftAddress, address reserveAsset, uint256 amount, uint256 borrowIndex ) external returns (uint256); /** * @dev Update the given loan with some params * * Requirements: * - The caller must be a holder of the loan * - The loan must be in state Active * @param initiator The address of the user updating the loan * @param loanId The loan ID * @param amountAdded The amount added to the loan * @param amountTaken The amount taken from the loan * @param borrowIndex The index to get the scaled loan amount */ function updateLoan( address initiator, uint256 loanId, uint256 amountAdded, uint256 amountTaken, uint256 borrowIndex ) external; /** * @dev Repay the given loan * * Requirements: * - The caller must be a holder of the loan * - The caller must send in principal + interest * - The loan must be in state Active * * @param initiator The address of the user initiating the repay * @param loanId The loan getting burned * @param uNftAddress The address of uNFT * @param amount The amount repaid * @param borrowIndex The index to get the scaled loan amount */ function repayLoan( address initiator, uint256 loanId, address uNftAddress, uint256 amount, uint256 borrowIndex ) external; /** * @dev Auction the given loan * * Requirements: * - The price must be greater than current highest price * - The loan must be in state Active or Auction * * @param initiator The address of the user initiating the auction * @param loanId The loan getting auctioned * @param bidPrice The bid price of this auction */ function auctionLoan( address initiator, uint256 loanId, address onBehalfOf, uint256 bidPrice, uint256 borrowAmount, uint256 borrowIndex ) external; /** * @dev Buyout the given loan * * Requirements: * - The price has to be the valuation price of the nft * - The loan must be in state Active or Auction */ function buyoutLoan( address initiator, uint256 loanId, address uNftAddress, uint256 borrowAmount, uint256 borrowIndex, uint256 buyoutAmount ) external; /** * @dev Redeem the given loan with some params * * Requirements: * - The caller must be a holder of the loan * - The loan must be in state Auction * @param initiator The address of the user initiating the borrow * @param loanId The loan getting redeemed * @param amountTaken The taken amount * @param borrowIndex The index to get the scaled loan amount */ function redeemLoan(address initiator, uint256 loanId, uint256 amountTaken, uint256 borrowIndex) external; /** * @dev Liquidate the given loan * * Requirements: * - The caller must send in principal + interest * - The loan must be in state Active * * @param initiator The address of the user initiating the auction * @param loanId The loan getting burned * @param uNftAddress The address of uNFT * @param borrowAmount The borrow amount * @param borrowIndex The index to get the scaled loan amount */ function liquidateLoan( address initiator, uint256 loanId, address uNftAddress, uint256 borrowAmount, uint256 borrowIndex ) external; /** * @dev Liquidate the given loan on an external market * @param loanId The loan getting burned * @param uNftAddress The address of the underlying uNft * @param borrowAmount Amount borrowed in the loan * @param borrowIndex The reserve index */ function liquidateLoanMarket(uint256 loanId, address uNftAddress, uint256 borrowAmount, uint256 borrowIndex) external; /** * @dev Updates the `_marketAdapters` mapping, setting the params to * valid/unvalid adapters through the `flag` parameter * @param adapters The adapters addresses to be updated * @param flag `true` to set addresses as valid adapters, `false` otherwise */ function updateMarketAdapters(address[] calldata adapters, bool flag) external; /** * @dev returns the borrower of a specific loan * param loanId the loan to get the borrower from */ function borrowerOf(uint256 loanId) external view returns (address); /** * @dev returns the loan corresponding to a specific NFT * param nftAsset the underlying NFT asset * param tokenId the underlying token ID for the NFT */ function getCollateralLoanId(address nftAsset, uint256 nftTokenId) external view returns (uint256); /** * @dev returns the loan corresponding to a specific loan Id * param loanId the loan Id */ function getLoan(uint256 loanId) external view returns (DataTypes.LoanData memory loanData); /** * @dev returns the collateral and reserve corresponding to a specific loan * param loanId the loan Id */ function getLoanCollateralAndReserve( uint256 loanId ) external view returns (address nftAsset, uint256 nftTokenId, address reserveAsset, uint256 scaledAmount); /** * @dev returns the reserve and borrow __scaled__ amount corresponding to a specific loan * param loanId the loan Id */ function getLoanReserveBorrowScaledAmount(uint256 loanId) external view returns (address, uint256); /** * @dev returns the reserve and borrow amount corresponding to a specific loan * param loanId the loan Id */ function getLoanReserveBorrowAmount(uint256 loanId) external view returns (address, uint256); function getLoanHighestBid(uint256 loanId) external view returns (address, uint256); /** * @dev returns the collateral amount for a given NFT * param nftAsset the underlying NFT asset */ function getNftCollateralAmount(address nftAsset) external view returns (uint256); /** * @dev returns the collateral amount for a given NFT and a specific user * param user the user * param nftAsset the underlying NFT asset */ function getUserNftCollateralAmount(address user, address nftAsset) external view returns (uint256); /** * @dev returns the counter tracker for all the loan ID's in the protocol */ function getLoanIdTracker() external view returns (CountersUpgradeable.Counter memory); function reMintUNFT(address nftAsset, uint256 tokenId, address oldOnBehalfOf, address newOnBehalfOf) external; }
// SPDX-License-Identifier: agpl-3.0 pragma solidity 0.8.4; /** * @dev Interface for a permittable ERC721 contract * See https://eips.ethereum.org/EIPS/eip-2612[EIP-2612]. * * Adds the {permit} method, which can be used to change an account's ERC72 allowance (see {IERC721-allowance}) by * presenting a message signed by the account. By not relying on {IERC721-approve}, the token holder account doesn't * need to send a transaction, and thus is not required to hold Ether at all. */ interface IPunks { /** * @dev returns the balance of an account * @param account the given account **/ function balanceOf(address account) external view returns (uint256); /** * @dev returns the address of a punk given its index * @param punkIndex the index **/ function punkIndexToAddress(uint256 punkIndex) external view returns (address owner); /** * @dev buys a punk * @param punkIndex the index of the punk to buy **/ function buyPunk(uint256 punkIndex) external; /** * @dev transfers a punk * @param to the recipient address * @param punkIndex the index of the punk to transfer **/ function transferPunk(address to, uint256 punkIndex) external; }
// SPDX-License-Identifier: agpl-3.0 pragma solidity 0.8.4; interface IScaledBalanceToken { /** * @dev Returns the scaled balance of the user. The scaled balance is the sum of all the * updated stored balance divided by the reserve's liquidity index at the moment of the update * @param user The user whose balance is calculated * @return The scaled balance of the user **/ function scaledBalanceOf(address user) external view returns (uint256); /** * @dev Returns the scaled balance of the user and the scaled total supply. * @param user The address of the user * @return The scaled balance of the user * @return The scaled balance and the scaled total supply **/ function getScaledUserBalanceAndSupply(address user) external view returns (uint256, uint256); /** * @dev Returns the scaled total supply of the variable debt token. Represents sum(debt/index) * @return The scaled total supply **/ function scaledTotalSupply() external view returns (uint256); }
// SPDX-License-Identifier: agpl-3.0 pragma solidity 0.8.4; import {ILendPoolAddressesProvider} from "./ILendPoolAddressesProvider.sol"; import {IIncentivesController} from "./IIncentivesController.sol"; import {IScaledBalanceToken} from "./IScaledBalanceToken.sol"; import {IERC20Upgradeable} from "@openzeppelin/contracts-upgradeable/token/ERC20/IERC20Upgradeable.sol"; import {IERC20MetadataUpgradeable} from "@openzeppelin/contracts-upgradeable/token/ERC20/extensions/IERC20MetadataUpgradeable.sol"; interface IUToken is IScaledBalanceToken, IERC20Upgradeable, IERC20MetadataUpgradeable { /** * @dev Emitted when an uToken is initialized * @param underlyingAsset The address of the underlying asset * @param pool The address of the associated lending pool * @param treasury The address of the treasury * @param incentivesController The address of the incentives controller for this uToken **/ event Initialized( address indexed underlyingAsset, address indexed pool, address treasury, address incentivesController ); /** * @dev Initializes the bToken * @param addressProvider The address of the address provider where this bToken will be used * @param treasury The address of the Unlockd treasury, receiving the fees on this bToken * @param underlyingAsset The address of the underlying asset of this bToken * @param uTokenDecimals The amount of token decimals * @param uTokenName The name of the token * @param uTokenSymbol The token symbol */ function initialize( ILendPoolAddressesProvider addressProvider, address treasury, address underlyingAsset, uint8 uTokenDecimals, string calldata uTokenName, string calldata uTokenSymbol ) external; /** * @dev Emitted after the mint action * @param from The address performing the mint * @param value The amount being * @param index The new liquidity index of the reserve **/ event Mint(address indexed from, uint256 value, uint256 index); /** * @dev Emitted after setting of addresses as managers * @param managers the managers to be updated * @param flag `true` to set addresses as managers, `false` otherwise **/ event UTokenManagersUpdated(address[] indexed managers, bool flag); /** * @dev Mints `amount` uTokens to `user` * @param user The address receiving the minted tokens * @param amount The amount of tokens getting minted * @param index The new liquidity index of the reserve * @return `true` if the the previous balance of the user was 0 */ function mint(address user, uint256 amount, uint256 index) external returns (bool); /** * @dev Emitted after uTokens are burned * @param from The owner of the uTokens, getting them burned * @param target The address that will receive the underlying * @param value The amount being burned * @param index The new liquidity index of the reserve **/ event Burn(address indexed from, address indexed target, uint256 value, uint256 index); /** * @dev Emitted during the transfer action * @param from The user whose tokens are being transferred * @param to The recipient * @param value The amount being transferred * @param index The new liquidity index of the reserve **/ event BalanceTransfer(address indexed from, address indexed to, uint256 value, uint256 index); /** * @dev Emitted when treasury address is updated in utoken * @param _newTreasuryAddress The new treasury address **/ event TreasuryAddressUpdated(address indexed _newTreasuryAddress); /** @dev Emitted after sweeping liquidity from the uToken to deposit it to external lending protocol * @param uToken The uToken swept * @param underlyingAsset The underlying asset from the uToken * @param amount The amount deposited to the lending protocol */ event UTokenSwept(address indexed uToken, address indexed underlyingAsset, uint256 indexed amount); /** * @dev Takes reserve liquidity from uToken and deposits it to external lening protocol **/ function sweepUToken() external; /** * @dev Burns uTokens from `user` and sends the equivalent amount of underlying to `receiverOfUnderlying` * @param user The owner of the uTokens, getting them burned * @param receiverOfUnderlying The address that will receive the underlying * @param amount The amount being burned * @param index The new liquidity index of the reserve **/ function burn(address user, address receiverOfUnderlying, uint256 amount, uint256 index) external; /** * @dev Mints uTokens to the reserve treasury * @param amount The amount of tokens getting minted * @param index The new liquidity index of the reserve */ function mintToTreasury(uint256 amount, uint256 index) external; /** * @dev Deposits `amount` to the lending protocol currently active * @param amount The amount of tokens to deposit */ function depositReserves(uint256 amount) external; /** * @dev Withdraws `amount` from the lending protocol currently active * @param amount The amount of tokens to withdraw */ function withdrawReserves(uint256 amount) external returns (uint256); /** * @dev Transfers the underlying asset to `target`. Used by the LendPool to transfer * assets in borrow() and withdraw() * @param user The recipient of the underlying * @param amount The amount getting transferred * @return The amount transferred **/ function transferUnderlyingTo(address user, uint256 amount) external returns (uint256); /** * @dev Returns the scaled balance of the user and the scaled total supply. * @return The available liquidity in reserve **/ function getAvailableLiquidity() external view returns (uint256); /** * @dev Returns the address of the incentives controller contract **/ function getIncentivesController() external view returns (IIncentivesController); /** * @dev Returns the address of the underlying asset of this uToken **/ function UNDERLYING_ASSET_ADDRESS() external view returns (address); /** * @dev Returns the address of the treasury set to this uToken **/ function RESERVE_TREASURY_ADDRESS() external view returns (address); /** * @dev Sets the address of the treasury to this uToken **/ function setTreasuryAddress(address treasury) external; /** * @dev Updates the uToken manager addresses **/ function updateUTokenManagers(address[] calldata managers, bool flag) external; }
// SPDX-License-Identifier: agpl-3.0 pragma solidity 0.8.4; interface IWETH { function deposit() external payable; function withdraw(uint256) external; function approve(address guy, uint256 wad) external returns (bool); function balanceOf(address guy) external returns (uint256); function allowance(address owner, address spender) external returns (uint256); function transferFrom(address src, address dst, uint256 wad) external returns (bool); }
// SPDX-License-Identifier: agpl-3.0 pragma solidity 0.8.4; interface IWETHGateway { /** * @dev deposits WETH into the reserve, using native ETH. A corresponding amount of the overlying asset (uTokens) * is minted. * @param onBehalfOf address of the user who will receive the uTokens representing the deposit * @param referralCode integrators are assigned a referral code and can potentially receive rewards. **/ function depositETH(address onBehalfOf, uint16 referralCode) external payable; /** * @dev withdraws the WETH _reserves of msg.sender. * @param amount amount of uWETH to withdraw and receive native ETH * @param to address of the user who will receive native ETH */ function withdrawETH(uint256 amount, address to) external; /** * @dev borrow WETH, unwraps to ETH and send both the ETH and DebtTokens to msg.sender, via `approveDelegation` and onBehalf argument in `LendPool.borrow`. * @param amount the amount of ETH to borrow * @param nftAsset The address of the underlying NFT used as collateral * @param nftTokenId The token ID of the underlying NFT used as collateral * @param onBehalfOf Address of the user who will receive the loan. 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 * @param referralCode integrators are assigned a referral code and can potentially receive rewards */ function borrowETH( uint256 amount, address nftAsset, uint256 nftTokenId, address onBehalfOf, uint16 referralCode ) external; /** * @dev repays a borrow on the WETH reserve, for the specified amount (or for the whole amount, if uint256(-1) is specified). * @param nftAsset The address of the underlying NFT used as collateral * @param nftTokenId The token ID of the underlying NFT used as collateral * @param amount the amount to repay, or uint256(-1) if the user wants to repay everything */ function repayETH(address nftAsset, uint256 nftTokenId, uint256 amount) external payable returns (uint256, bool); /** * @dev auction a borrow on the WETH reserve * @param nftAsset The address of the underlying NFT used as collateral * @param nftTokenId The token ID of the underlying NFT used as collateral * @param onBehalfOf Address of the user who will receive the underlying NFT used as collateral. * Should be the address of the borrower itself calling the function if he wants to borrow against his own collateral. */ function auctionETH(address nftAsset, uint256 nftTokenId, address onBehalfOf) external payable; /** * @dev redeems a borrow on the WETH reserve * @param nftAsset The address of the underlying NFT used as collateral * @param nftTokenId The token ID of the underlying NFT used as collateral * @param amount The amount to repay the debt * @param bidFine The amount of bid fine */ function redeemETH( address nftAsset, uint256 nftTokenId, uint256 amount, uint256 bidFine ) external payable returns (uint256); /** * @dev liquidates a borrow on the WETH reserve * @param nftAsset The address of the underlying NFT used as collateral * @param nftTokenId The token ID of the underlying NFT used as collateral */ function liquidateETH(address nftAsset, uint256 nftTokenId) external payable returns (uint256); /** @dev Executes the buyout for an NFT with a non-healthy position collateral-wise * @param nftAsset The address of the underlying NFT used as collateral * @param nftTokenId The token ID of the underlying NFT used as collateral * @param onBehalfOf The address that will receive the NFT, same as msg.sender if the user * wants to receive them on his own wallet, or a different address if the beneficiary of the NFT * is a different wallet **/ function buyoutETH(address nftAsset, uint256 nftTokenId, address onBehalfOf) external payable; /** * @dev buy a debt on the WETH reserve * @param nftAsset The address of the debt NFT used as collateral * @param nftTokenId The token ID of the debt NFT used as collateral */ function buyDebtETH(address nftAsset, uint256 nftTokenId, address onBehalfOf) external payable; /** * @dev bids a debt on the WETH reserve * @param nftAsset The address of the debt NFT used as collateral * @param nftTokenId The token ID of the debt NFT used as collateral */ function bidDebtETH(address nftAsset, uint256 nftTokenId, address onBehalfOf) external payable; }
// SPDX-License-Identifier: agpl-3.0 pragma solidity 0.8.4; /** * @title Errors library * @author BendDao; Forked and edited by Unlockd * @notice Defines the error messages emitted by the different contracts of the Unlockd protocol */ library Errors { enum ReturnCode { SUCCESS, FAILED } string public constant SUCCESS = "0"; //common errors string public constant CALLER_NOT_POOL_ADMIN = "100"; // 'The caller must be the pool admin' string public constant CALLER_NOT_ADDRESS_PROVIDER = "101"; string public constant INVALID_FROM_BALANCE_AFTER_TRANSFER = "102"; string public constant INVALID_TO_BALANCE_AFTER_TRANSFER = "103"; string public constant CALLER_NOT_ONBEHALFOF_OR_IN_WHITELIST = "104"; string public constant CALLER_NOT_POOL_LIQUIDATOR = "105"; string public constant INVALID_ZERO_ADDRESS = "106"; string public constant CALLER_NOT_LTV_MANAGER = "107"; string public constant CALLER_NOT_PRICE_MANAGER = "108"; string public constant CALLER_NOT_UTOKEN_MANAGER = "109"; //math library errors string public constant MATH_MULTIPLICATION_OVERFLOW = "200"; string public constant MATH_ADDITION_OVERFLOW = "201"; string public constant MATH_DIVISION_BY_ZERO = "202"; //validation & check errors string public constant VL_INVALID_AMOUNT = "301"; // 'Amount must be greater than 0' string public constant VL_NO_ACTIVE_RESERVE = "302"; // 'Action requires an active reserve' string public constant VL_RESERVE_FROZEN = "303"; // 'Action cannot be performed because the reserve is frozen' string public constant VL_NOT_ENOUGH_AVAILABLE_USER_BALANCE = "304"; // 'User cannot withdraw more than the available balance' string public constant VL_BORROWING_NOT_ENABLED = "305"; // 'Borrowing is not enabled' string public constant VL_COLLATERAL_BALANCE_IS_0 = "306"; // 'The collateral balance is 0' string public constant VL_HEALTH_FACTOR_LOWER_THAN_LIQUIDATION_THRESHOLD = "307"; // 'Health factor is lesser than the liquidation threshold' string public constant VL_COLLATERAL_CANNOT_COVER_NEW_BORROW = "308"; // 'There is not enough collateral to cover a new borrow' string public constant VL_NO_DEBT_OF_SELECTED_TYPE = "309"; // 'for repayment of stable debt, the user needs to have stable debt, otherwise, he needs to have variable debt' string public constant VL_NO_ACTIVE_NFT = "310"; string public constant VL_NFT_FROZEN = "311"; string public constant VL_SPECIFIED_CURRENCY_NOT_BORROWED_BY_USER = "312"; // 'User did not borrow the specified currency' string public constant VL_INVALID_HEALTH_FACTOR = "313"; string public constant VL_INVALID_ONBEHALFOF_ADDRESS = "314"; string public constant VL_INVALID_TARGET_ADDRESS = "315"; string public constant VL_INVALID_RESERVE_ADDRESS = "316"; string public constant VL_SPECIFIED_LOAN_NOT_BORROWED_BY_USER = "317"; string public constant VL_SPECIFIED_RESERVE_NOT_BORROWED_BY_USER = "318"; string public constant VL_HEALTH_FACTOR_HIGHER_THAN_LIQUIDATION_THRESHOLD = "319"; string public constant VL_TIMEFRAME_EXCEEDED = "320"; string public constant VL_VALUE_EXCEED_TREASURY_BALANCE = "321"; //lend pool errors string public constant LP_CALLER_NOT_LEND_POOL_CONFIGURATOR = "400"; // 'The caller of the function is not the lending pool configurator' string public constant LP_IS_PAUSED = "401"; // 'Pool is paused' string public constant LP_NO_MORE_RESERVES_ALLOWED = "402"; string public constant LP_NOT_CONTRACT = "403"; string public constant LP_BORROW_NOT_EXCEED_LIQUIDATION_THRESHOLD = "404"; string public constant LP_BORROW_IS_EXCEED_LIQUIDATION_PRICE = "405"; string public constant LP_NO_MORE_NFTS_ALLOWED = "406"; string public constant LP_INVALID_USER_NFT_AMOUNT = "407"; string public constant LP_INCONSISTENT_PARAMS = "408"; string public constant LP_NFT_IS_NOT_USED_AS_COLLATERAL = "409"; string public constant LP_CALLER_MUST_BE_AN_UTOKEN = "410"; string public constant LP_INVALID_NFT_AMOUNT = "411"; string public constant LP_NFT_HAS_USED_AS_COLLATERAL = "412"; string public constant LP_DELEGATE_CALL_FAILED = "413"; string public constant LP_AMOUNT_LESS_THAN_EXTRA_DEBT = "414"; string public constant LP_AMOUNT_LESS_THAN_REDEEM_THRESHOLD = "415"; string public constant LP_AMOUNT_GREATER_THAN_MAX_REPAY = "416"; string public constant LP_NFT_TOKEN_ID_EXCEED_MAX_LIMIT = "417"; string public constant LP_NFT_SUPPLY_NUM_EXCEED_MAX_LIMIT = "418"; string public constant LP_CALLER_NOT_LEND_POOL_LIQUIDATOR_NOR_GATEWAY = "419"; string public constant LP_CONSECUTIVE_BIDS_NOT_ALLOWED = "420"; string public constant LP_INVALID_OVERFLOW_VALUE = "421"; string public constant LP_CALLER_NOT_NFT_HOLDER = "422"; string public constant LP_NFT_NOT_ALLOWED_TO_SELL = "423"; string public constant LP_RESERVES_WITHOUT_ENOUGH_LIQUIDITY = "424"; string public constant LP_COLLECTION_NOT_SUPPORTED = "425"; string public constant LP_MSG_VALUE_DIFFERENT_FROM_CONFIG_FEE = "426"; string public constant LP_INVALID_SAFE_HEALTH_FACTOR = "427"; string public constant LP_AMOUNT_LESS_THAN_DEBT = "428"; string public constant LP_AMOUNT_DIFFERENT_FROM_REQUIRED_BUYOUT_PRICE = "429"; string public constant LP_CALLER_NOT_DEBT_TOKEN_MANAGER = "430"; string public constant LP_CALLER_NOT_RESERVOIR_OR_DEBT_MARKET = "431"; string public constant LP_AMOUNT_LESS_THAN_BUYOUT_PRICE = "432"; //lend pool loan errors string public constant LPL_CLAIM_HASNT_STARTED_YET = "479"; string public constant LPL_INVALID_LOAN_STATE = "480"; string public constant LPL_INVALID_LOAN_AMOUNT = "481"; string public constant LPL_INVALID_TAKEN_AMOUNT = "482"; string public constant LPL_AMOUNT_OVERFLOW = "483"; string public constant LPL_BID_PRICE_LESS_THAN_DEBT_PRICE = "484"; string public constant LPL_BID_PRICE_LESS_THAN_HIGHEST_PRICE = "485"; string public constant LPL_BID_REDEEM_DURATION_HAS_END = "486"; string public constant LPL_BID_USER_NOT_SAME = "487"; string public constant LPL_BID_REPAY_AMOUNT_NOT_ENOUGH = "488"; string public constant LPL_BID_AUCTION_DURATION_HAS_END = "489"; string public constant LPL_BID_AUCTION_DURATION_NOT_END = "490"; string public constant LPL_BID_PRICE_LESS_THAN_BORROW = "491"; string public constant LPL_INVALID_BIDDER_ADDRESS = "492"; string public constant LPL_AMOUNT_LESS_THAN_BID_FINE = "493"; string public constant LPL_INVALID_BID_FINE = "494"; string public constant LPL_BID_PRICE_LESS_THAN_MIN_BID_REQUIRED = "495"; string public constant LPL_BID_NOT_BUYOUT_PRICE = "496"; string public constant LPL_BUYOUT_DURATION_HAS_END = "497"; string public constant LPL_BUYOUT_PRICE_LESS_THAN_BORROW = "498"; string public constant LPL_CALLER_MUST_BE_MARKET_ADAPTER = "499"; //common token errors string public constant CT_CALLER_MUST_BE_LEND_POOL = "500"; // 'The caller of this function must be a lending pool' string public constant CT_INVALID_MINT_AMOUNT = "501"; //invalid amount to mint string public constant CT_INVALID_BURN_AMOUNT = "502"; //invalid amount to burn string public constant CT_BORROW_ALLOWANCE_NOT_ENOUGH = "503"; string public constant CT_CALLER_MUST_BE_DEBT_MARKET = "504"; // 'The caller of this function must be a debt market' //reserve logic errors string public constant RL_RESERVE_ALREADY_INITIALIZED = "601"; // 'Reserve has already been initialized' string public constant RL_LIQUIDITY_INDEX_OVERFLOW = "602"; // Liquidity index overflows uint128 string public constant RL_VARIABLE_BORROW_INDEX_OVERFLOW = "603"; // Variable borrow index overflows uint128 string public constant RL_LIQUIDITY_RATE_OVERFLOW = "604"; // Liquidity rate overflows uint128 string public constant RL_VARIABLE_BORROW_RATE_OVERFLOW = "605"; // Variable borrow rate overflows uint128 //configure errors string public constant LPC_RESERVE_LIQUIDITY_NOT_0 = "700"; // 'The liquidity of the reserve needs to be 0' string public constant LPC_INVALID_CONFIGURATION = "701"; // 'Invalid risk parameters for the reserve' string public constant LPC_CALLER_NOT_EMERGENCY_ADMIN = "702"; // 'The caller must be the emergency admin' string public constant LPC_INVALID_UNFT_ADDRESS = "703"; string public constant LPC_INVALIED_LOAN_ADDRESS = "704"; string public constant LPC_NFT_LIQUIDITY_NOT_0 = "705"; string public constant LPC_PARAMS_MISMATCH = "706"; // NFT assets & token ids mismatch string public constant LPC_FEE_PERCENTAGE_TOO_HIGH = "707"; string public constant LPC_INVALID_LTVMANAGER_ADDRESS = "708"; string public constant LPC_INCONSISTENT_PARAMS = "709"; string public constant LPC_INVALID_SAFE_HEALTH_FACTOR = "710"; //reserve config errors string public constant RC_INVALID_LTV = "730"; string public constant RC_INVALID_LIQ_THRESHOLD = "731"; string public constant RC_INVALID_LIQ_BONUS = "732"; string public constant RC_INVALID_DECIMALS = "733"; string public constant RC_INVALID_RESERVE_FACTOR = "734"; string public constant RC_INVALID_REDEEM_DURATION = "735"; string public constant RC_INVALID_AUCTION_DURATION = "736"; string public constant RC_INVALID_REDEEM_FINE = "737"; string public constant RC_INVALID_REDEEM_THRESHOLD = "738"; string public constant RC_INVALID_MIN_BID_FINE = "739"; string public constant RC_INVALID_MAX_BID_FINE = "740"; string public constant RC_INVALID_MAX_CONFIG_TIMESTAMP = "741"; //address provider erros string public constant LPAPR_PROVIDER_NOT_REGISTERED = "760"; // 'Provider is not registered' string public constant LPAPR_INVALID_ADDRESSES_PROVIDER_ID = "761"; //NFTOracleErrors string public constant NFTO_INVALID_PRICEM_ADDRESS = "900"; //Debt Market string public constant DM_CALLER_NOT_THE_OWNER = "1000"; string public constant DM_DEBT_SHOULD_EXIST = "1001"; string public constant DM_INVALID_AMOUNT = "1002"; string public constant DM_FAIL_ON_SEND_ETH = "1003"; string public constant DM_DEBT_SHOULD_NOT_BE_SOLD = "1004"; string public constant DM_DEBT_ALREADY_EXIST = "1005"; string public constant DM_LOAN_SHOULD_EXIST = "1006"; string public constant DM_AUCTION_ALREADY_ENDED = "1007"; string public constant DM_BID_PRICE_HIGHER_THAN_SELL_PRICE = "1008"; string public constant DM_BID_PRICE_LESS_THAN_PREVIOUS_BID = "1009"; string public constant DM_INVALID_SELL_TYPE = "1010"; string public constant DM_AUCTION_NOT_ALREADY_ENDED = "1011"; string public constant DM_INVALID_CLAIM_RECEIVER = "1012"; string public constant DM_AMOUNT_DIFFERENT_FROM_SELL_PRICE = "1013"; string public constant DM_BID_PRICE_LESS_THAN_MIN_BID_PRICE = "1014"; string public constant DM_BORROWED_AMOUNT_DIVERGED = "1015"; string public constant DM_INVALID_AUTHORIZED_ADDRESS = "1016"; string public constant DM_CALLER_NOT_THE_OWNER_OR_AUTHORIZED = "1017"; string public constant DM_INVALID_DELTA_BID_PERCENT = "1018"; string public constant DM_IS_PAUSED = "1019"; }
// SPDX-License-Identifier: agpl-3.0 pragma solidity 0.8.4; library DataTypes { struct ReserveData { //stores the reserve configuration ReserveConfigurationMap configuration; //the liquidity index. Expressed in ray uint128 liquidityIndex; //variable borrow index. Expressed in ray uint128 variableBorrowIndex; //the current supply rate. Expressed in ray uint128 currentLiquidityRate; //the current variable borrow rate. Expressed in ray uint128 currentVariableBorrowRate; uint40 lastUpdateTimestamp; //tokens addresses address uTokenAddress; address debtTokenAddress; //address of the interest rate strategy address interestRateAddress; //the id of the reserve. Represents the position in the list of the active reserves uint8 id; } struct NftData { //stores the nft configuration NftConfigurationMap configuration; //address of the uNFT contract address uNftAddress; //the id of the nft. Represents the position in the list of the active nfts uint8 id; uint256 maxSupply; uint256 maxTokenId; } 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-63: reserved //bit 64-79: reserve factor uint256 data; } struct NftConfigurationMap { //bit 0-15: LTV //bit 16-31: Liq. threshold //bit 32-47: Liq. bonus //bit 56: NFT is active //bit 57: NFT is frozen //bit 64-71: Redeem duration //bit 72-79: Auction duration //bit 80-95: Redeem fine //bit 96-111: Redeem threshold //bit 112-127: Min bid fine //bit 128-159: Timestamp Config uint256 data; } /** * @dev Enum describing the current state of a loan * State change flow: * Created -> Active -> Repaid * -> Auction -> Defaulted */ enum LoanState { // We need a default that is not 'Created' - this is the zero value None, // The loan data is stored, but not initiated yet. Created, // The loan has been initialized, funds have been delivered to the borrower and the collateral is held. Active, // The loan is in auction, higest price liquidator will got chance to claim it. Auction, // The loan has been repaid, and the collateral has been returned to the borrower. This is a terminal state. Repaid, // The loan was delinquent and collateral claimed by the liquidator. This is a terminal state. Defaulted } struct LoanData { //the id of the nft loan uint256 loanId; //the current state of the loan LoanState state; //address of borrower address borrower; //address of nft asset token address nftAsset; //the id of nft token uint256 nftTokenId; //address of reserve asset token address reserveAsset; //scaled borrow amount. Expressed in ray uint256 scaledAmount; //start time of first bid time uint256 bidStartTimestamp; //bidder address of higest bid address bidderAddress; //price of higest bid uint256 bidPrice; //borrow amount of loan uint256 bidBorrowAmount; //bidder address of first bid address firstBidderAddress; } struct ExecuteDepositParams { address initiator; address asset; uint256 amount; address onBehalfOf; uint16 referralCode; } struct ExecuteWithdrawParams { address initiator; address asset; uint256 amount; address to; } struct ExecuteBorrowParams { address initiator; address asset; uint256 amount; address nftAsset; uint256 nftTokenId; address onBehalfOf; uint16 referralCode; } struct ExecuteRepayParams { address initiator; address nftAsset; uint256 nftTokenId; uint256 amount; } struct ExecuteAuctionParams { address initiator; address nftAsset; uint256 nftTokenId; uint256 bidPrice; address onBehalfOf; uint256 auctionDurationConfigFee; uint256 bidDelta; } struct ExecuteRedeemParams { address initiator; address nftAsset; uint256 nftTokenId; uint256 amount; uint256 bidFine; uint256 safeHealthFactor; } struct ExecuteLiquidateParams { address initiator; address nftAsset; uint256 nftTokenId; uint256 amount; } struct ExecuteBuyoutParams { address initiator; address nftAsset; uint256 nftTokenId; address onBehalfOf; } struct ExecuteLiquidateMarketsParams { address nftAsset; uint256 nftTokenId; uint256 liquidateFeePercentage; uint256 amountOutMin; } struct ExecuteLendPoolStates { uint256 pauseStartTime; uint256 pauseDurationTime; } struct ExecuteYearnParams { address underlyingAsset; uint256 amount; } enum DebtMarketType { FixedPrice, //0 Auction, //1 Mixed //2 } enum DebtMarketState { //No bids New, //Exist bids Active, //Is sold Sold, Canceled } struct DebtMarketListing { uint256 debtId; address debtor; address nftAsset; uint256 tokenId; DebtMarketType sellType; DebtMarketState state; uint256 sellPrice; address reserveAsset; uint256 scaledAmount; address bidderAddress; uint256 bidPrice; uint256 auctionEndTimestamp; uint256 startBiddingPrice; } }
// SPDX-License-Identifier: agpl-3.0 pragma solidity 0.8.4; import {OwnableUpgradeable} from "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol"; import {IERC20Upgradeable} from "@openzeppelin/contracts-upgradeable/token/ERC20/IERC20Upgradeable.sol"; import {IERC721Upgradeable} from "@openzeppelin/contracts-upgradeable/token/ERC721/IERC721Upgradeable.sol"; import {IPunks} from "../interfaces/IPunks.sol"; /** * @title EmergencyTokenRecovery * @notice Add Emergency Recovery Logic to contract implementation ; Forked and edited by Unlockd **/ abstract contract EmergencyTokenRecoveryUpgradeable is OwnableUpgradeable { /*////////////////////////////////////////////////////////////// EVENTS //////////////////////////////////////////////////////////////*/ event EmergencyEtherTransfer(address indexed to, uint256 amount); /*////////////////////////////////////////////////////////////// INITIALIZERS //////////////////////////////////////////////////////////////*/ function __EmergencyTokenRecovery_init() internal onlyInitializing { __Ownable_init(); } /*////////////////////////////////////////////////////////////// MAIN LOGIC //////////////////////////////////////////////////////////////*/ /** * @dev transfer ERC20 from the utility contract, for ERC20 recovery in case of stuck tokens due * direct transfers to the contract address. * @param token token to transfer * @param to recipient of the transfer * @param amount amount to send */ function emergencyERC20Transfer(address token, address to, uint256 amount) external onlyOwner { IERC20Upgradeable(token).transfer(to, amount); } /** * @dev transfer ERC721 from the utility contract, for ERC721 recovery in case of stuck tokens due * direct transfers to the contract address. * @param token token to transfer * @param to recipient of the transfer * @param id token id to send */ function emergencyERC721Transfer(address token, address to, uint256 id) external onlyOwner { IERC721Upgradeable(token).safeTransferFrom(address(this), to, id); } /** * @dev transfer CryptoPunks from the utility contract, for punks recovery in case of stuck punks * due direct transfers to the contract address. * @param to recipient of the transfer * @param index punk index to send */ function emergencyPunksTransfer(address punks, address to, uint256 index) external onlyOwner { IPunks(punks).transferPunk(to, index); } /** * @dev transfer native Ether from the utility contract, for native Ether recovery in case of stuck Ether * due selfdestructs or transfer ether to pre-computated contract address before deployment. * @param to recipient of the transfer * @param amount amount to send */ function emergencyEtherTransfer(address to, uint256 amount) external onlyOwner { (bool success, ) = to.call{value: amount}(new bytes(0)); require(success, "ETH_TRANSFER_FAILED"); emit EmergencyEtherTransfer(to, amount); } uint256[50] private __gap; }
{ "optimizer": { "enabled": true, "runs": 200 }, "evmVersion": "istanbul", "outputSelection": { "*": { "*": [ "evm.bytecode", "evm.deployedBytecode", "devdoc", "userdoc", "metadata", "abi" ] } }, "libraries": {} }
Contract Security Audit
- No Contract Security Audit Submitted- Submit Audit Here
[{"inputs":[],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"EmergencyEtherTransfer","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"previousOwner","type":"address"},{"indexed":true,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnershipTransferred","type":"event"},{"stateMutability":"payable","type":"fallback"},{"inputs":[{"internalType":"address","name":"nftAsset","type":"address"},{"internalType":"uint256","name":"nftTokenId","type":"uint256"},{"internalType":"address","name":"onBehalfOf","type":"address"}],"name":"auctionETH","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"address[]","name":"callers","type":"address[]"},{"internalType":"bool","name":"flag","type":"bool"}],"name":"authorizeCallerWhitelist","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address[]","name":"nftAssets","type":"address[]"}],"name":"authorizeLendPoolNFT","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"nftAsset","type":"address"},{"internalType":"uint256","name":"nftTokenId","type":"uint256"},{"internalType":"address","name":"onBehalfOf","type":"address"}],"name":"bidDebtETH","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"address","name":"nftAsset","type":"address"},{"internalType":"uint256","name":"nftTokenId","type":"uint256"},{"internalType":"address","name":"onBehalfOf","type":"address"},{"internalType":"uint16","name":"referralCode","type":"uint16"}],"name":"borrowETH","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"nftAsset","type":"address"},{"internalType":"uint256","name":"nftTokenId","type":"uint256"},{"internalType":"address","name":"onBehalfOf","type":"address"}],"name":"buyDebtETH","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"address","name":"nftAsset","type":"address"},{"internalType":"uint256","name":"nftTokenId","type":"uint256"},{"internalType":"address","name":"onBehalfOf","type":"address"}],"name":"buyoutETH","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"address","name":"onBehalfOf","type":"address"},{"internalType":"uint16","name":"referralCode","type":"uint16"}],"name":"depositETH","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"address","name":"token","type":"address"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"emergencyERC20Transfer","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"token","type":"address"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"id","type":"uint256"}],"name":"emergencyERC721Transfer","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"emergencyEtherTransfer","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"punks","type":"address"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"index","type":"uint256"}],"name":"emergencyPunksTransfer","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"getWETHAddress","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"addressProvider","type":"address"},{"internalType":"address","name":"weth","type":"address"}],"name":"initialize","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"caller","type":"address"}],"name":"isCallerInWhitelist","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"nftAsset","type":"address"},{"internalType":"uint256","name":"nftTokenId","type":"uint256"}],"name":"liquidateETH","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"address","name":"","type":"address"},{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"bytes","name":"","type":"bytes"}],"name":"onERC721Received","outputs":[{"internalType":"bytes4","name":"","type":"bytes4"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"nftAsset","type":"address"},{"internalType":"uint256","name":"nftTokenId","type":"uint256"},{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"uint256","name":"bidFine","type":"uint256"}],"name":"redeemETH","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"payable","type":"function"},{"inputs":[],"name":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"nftAsset","type":"address"},{"internalType":"uint256","name":"nftTokenId","type":"uint256"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"repayETH","outputs":[{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"address","name":"to","type":"address"}],"name":"withdrawETH","outputs":[],"stateMutability":"nonpayable","type":"function"},{"stateMutability":"payable","type":"receive"}]
Contract Creation Code
60806040523480156200001157600080fd5b50600054610100900460ff166200002f5760005460ff161562000039565b62000039620000de565b620000a15760405162461bcd60e51b815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201526d191e481a5b9a5d1a585b1a5e995960921b606482015260840160405180910390fd5b600054610100900460ff16158015620000c4576000805461ffff19166101011790555b8015620000d7576000805461ff00191690555b5062000102565b6000620000f630620000fc60201b6200267f1760201c565b15905090565b3b151590565b6137b080620001126000396000f3fe6080604052600436106101445760003560e01c806389cbe656116100b6578063a9f189151161006f578063a9f189151461041f578063affa881714610440578063ceac58c01461045e578063d8a2332014610471578063eed88b8d14610491578063f2fde38b146104b1576101a0565b806389cbe656146103365780638da5cb5b1461035e57806395d201151461039057806395f3e238146103a35780639c748eff146103ec578063a59edbd11461040c576101a0565b8063485cc95511610108578063485cc9551461029b57806358c22be7146102bb5780636cb5f035146102ce578063715018a6146102e15780637194a0ea146102f65780638393152314610316576101a0565b8063059398a0146101df578063150b7a02146101ff578063281d64031461024857806336118b521461025b578063482876671461027b576101a0565b366101a05760ca546001600160a01b0316331461019e5760405162461bcd60e51b8152602060048201526013602482015272149958d95a5d99481b9bdd08185b1b1bddd959606a1b60448201526064015b60405180910390fd5b005b60405162461bcd60e51b815260206004820152601460248201527311985b1b189858dac81b9bdd08185b1b1bddd95960621b6044820152606401610195565b3480156101eb57600080fd5b5061019e6101fa366004612fb7565b6104d1565b34801561020b57600080fd5b5061022a61021a366004612ff7565b630a85bd0160e11b949350505050565b6040516001600160e01b031990911681526020015b60405180910390f35b61019e61025636600461313f565b610560565b34801561026757600080fd5b5061019e61027636600461342a565b6107e5565b34801561028757600080fd5b5061019e6102963660046131ee565b610abe565b3480156102a757600080fd5b5061019e6102b6366004612f7f565b610bdd565b61019e6102c93660046130b3565b610d56565b61019e6102dc36600461313f565b610e7e565b3480156102ed57600080fd5b5061019e6112bf565b34801561030257600080fd5b5061019e610311366004612fb7565b6112f5565b34801561032257600080fd5b5061019e610331366004612fb7565b61135a565b610349610344366004613180565b61140a565b6040805192835290151560208301520161023f565b34801561036a57600080fd5b506065546001600160a01b03165b6040516001600160a01b03909116815260200161023f565b61019e61039e36600461313f565b611474565b3480156103af57600080fd5b506103dc6103be366004612f40565b6001600160a01b0316600090815260cb602052604090205460ff1690565b604051901515815260200161023f565b3480156103f857600080fd5b5061019e61040736600461344e565b6116d3565b61019e61041a36600461313f565b611908565b61043261042d3660046130e7565b611d0c565b60405190815260200161023f565b34801561044c57600080fd5b5060ca546001600160a01b0316610378565b61043261046c3660046131b4565b612048565b34801561047d57600080fd5b5061019e61048c36600461322e565b6123eb565b34801561049d57600080fd5b5061019e6104ac3660046130e7565b6124bf565b3480156104bd57600080fd5b5061019e6104cc366004612f40565b6125e4565b6065546001600160a01b031633146104fb5760405162461bcd60e51b815260040161019590613563565b6040516322dca8bb60e21b81526001600160a01b03841690638b72a2ec9061052990859085906004016134e8565b600060405180830381600087803b15801561054357600080fd5b505af1158015610557573d6000803e3d6000fd5b50505050505050565b600160cc5414156105835760405162461bcd60e51b81526004016101959061361a565b600160cc5561059181612685565b600061059b6126ee565b905060006105a7612770565b90506000816001600160a01b0316631637369c87876040518363ffffffff1660e01b81526004016105d99291906134e8565b60206040518083038186803b1580156105f157600080fd5b505afa158015610605573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906106299190613412565b90506000811161064b5760405162461bcd60e51b815260040161019590613598565b604051632820036560e11b8152600481018290526000906001600160a01b0384169063504006ca906024016101806040518083038186803b15801561068f57600080fd5b505afa1580156106a3573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906106c79190613294565b60ca5460a08201519192506001600160a01b039182169116146106fc5760405162461bcd60e51b815260040161019590613534565b341561076c5760ca60009054906101000a90046001600160a01b03166001600160a01b031663d0e30db0346040518263ffffffff1660e01b81526004016000604051808303818588803b15801561075257600080fd5b505af1158015610766573d6000803e3d6000fd5b50505050505b604051631ae3fab960e31b81526001600160a01b03888116600483015260248201889052868116604483015285169063d71fd5c8906064015b600060405180830381600087803b1580156107bf57600080fd5b505af11580156107d3573d6000803e3d6000fd5b5050600060cc55505050505050505050565b600160cc5414156108085760405162461bcd60e51b81526004016101959061361a565b600160cc5561081681612685565b60006108206126ee565b60ca546040516335ea6a7560e01b81526001600160a01b039182166004820152919250600091908316906335ea6a75906024016101406040518083038186803b15801561086c57600080fd5b505afa158015610880573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906108a49190613355565b60c001516040516370a0823160e01b81523360048201529091506000906001600160a01b038316906370a082319060240160206040518083038186803b1580156108ed57600080fd5b505afa158015610901573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906109259190613412565b9050846000198114156109355750805b6040516323b872dd60e01b8152336004820152306024820152604481018290526001600160a01b038416906323b872dd90606401602060405180830381600087803b15801561098357600080fd5b505af1158015610997573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906109bb9190613278565b5060ca54604051631a4ca37b60e21b81526001600160a01b03918216600482015260248101839052306044820152908516906369328dec90606401602060405180830381600087803b158015610a1057600080fd5b505af1158015610a24573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610a489190613412565b5060ca54604051632e1a7d4d60e01b8152600481018390526001600160a01b0390911690632e1a7d4d90602401600060405180830381600087803b158015610a8f57600080fd5b505af1158015610aa3573d6000803e3d6000fd5b50505050610ab185826127b5565b5050600060cc5550505050565b600160cc541415610ae15760405162461bcd60e51b81526004016101959061361a565b600160cc556065546001600160a01b03163314610b105760405162461bcd60e51b815260040161019590613563565b8060005b81811015610bd257838382818110610b3c57634e487b7160e01b600052603260045260246000fd5b9050602002016020810190610b519190612f40565b6001600160a01b031663a22cb465610b676126ee565b6040516001600160e01b031960e084901b1681526001600160a01b03909116600482015260016024820152604401600060405180830381600087803b158015610baf57600080fd5b505af1158015610bc3573d6000803e3d6000fd5b50505050806001019050610b14565b5050600060cc555050565b600054610100900460ff16610bf85760005460ff1615610bfc565b303b155b610c5f5760405162461bcd60e51b815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201526d191e481a5b9a5d1a585b1a5e995960921b6064820152608401610195565b600054610100900460ff16158015610c81576000805461ffff19166101011790555b610c89612868565b610c91612897565b60c980546001600160a01b038086166001600160a01b03199283161790925560ca8054928516929091168217905563095ea7b3610ccc6126ee565b6000196040518363ffffffff1660e01b8152600401610cec9291906134e8565b602060405180830381600087803b158015610d0657600080fd5b505af1158015610d1a573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610d3e9190613278565b508015610d51576000805461ff00191690555b505050565b600160cc541415610d795760405162461bcd60e51b81526004016101959061361a565b600160cc55610d8782612685565b6000610d916126ee565b905060ca60009054906101000a90046001600160a01b03166001600160a01b031663d0e30db0346040518263ffffffff1660e01b81526004016000604051808303818588803b158015610de357600080fd5b505af1158015610df7573d6000803e3d6000fd5b505060ca5460405163e8eda9df60e01b81526001600160a01b039182166004820152346024820152878216604482015261ffff87166064820152908516935063e8eda9df92506084019050600060405180830381600087803b158015610e5c57600080fd5b505af1158015610e70573d6000803e3d6000fd5b5050600060cc555050505050565b600160cc541415610ea15760405162461bcd60e51b81526004016101959061361a565b600160cc558282610eb0612dba565b610eb8612770565b6001600160a01b031680825260405163058dcda760e21b8152631637369c90610ee790869086906004016134e8565b60206040518083038186803b158015610eff57600080fd5b505afa158015610f13573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610f379190613412565b60208201819052610f5a5760405162461bcd60e51b815260040161019590613598565b80516020820151604051632820036560e11b81526001600160a01b039092169163504006ca91610f909160040190815260200190565b6101806040518083038186803b158015610fa957600080fd5b505afa158015610fbd573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610fe19190613294565b6040820181905260ca5460a0909101516001600160a01b0390811691161461101b5760405162461bcd60e51b815260040161019590613534565b60c9546040516321f8a72160e01b81527f7c617de58ecde9b6796870984f6da6b2111adce1343a91b9baefbb06f8616ca060048201819052916000916001600160a01b03909116906321f8a7219060240160206040518083038186803b15801561108457600080fd5b505afa158015611098573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906110bc9190612f63565b9050341561112e5760ca60009054906101000a90046001600160a01b03166001600160a01b031663d0e30db0346040518263ffffffff1660e01b81526004016000604051808303818588803b15801561111457600080fd5b505af1158015611128573d6000803e3d6000fd5b50505050505b60ca54604051636eb1769f60e11b81523060048201526001600160a01b0383811660248301529091169063dd62ed3e90604401602060405180830381600087803b15801561117b57600080fd5b505af115801561118f573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906111b39190613412565b61123f5760ca5460405163095ea7b360e01b81526001600160a01b039091169063095ea7b3906111eb908490600019906004016134e8565b602060405180830381600087803b15801561120557600080fd5b505af1158015611219573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061123d9190613278565b505b60405163059ffdbb60e51b81526001600160a01b03898116600483015260248201899052878116604483015234606483015282169063b3ffb760906084015b600060405180830381600087803b15801561129857600080fd5b505af11580156112ac573d6000803e3d6000fd5b5050600060cc5550505050505050505050565b6065546001600160a01b031633146112e95760405162461bcd60e51b815260040161019590613563565b6112f360006128c6565b565b6065546001600160a01b0316331461131f5760405162461bcd60e51b815260040161019590613563565b604051632142170760e11b81523060048201526001600160a01b038381166024830152604482018390528416906342842e0e90606401610529565b6065546001600160a01b031633146113845760405162461bcd60e51b815260040161019590613563565b60405163a9059cbb60e01b81526001600160a01b0384169063a9059cbb906113b290859085906004016134e8565b602060405180830381600087803b1580156113cc57600080fd5b505af11580156113e0573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906114049190613278565b50505050565b600080600160cc5414156114305760405162461bcd60e51b81526004016101959061361a565b600160cc5560008061144487878784612918565b9150915081341115611463576114633361145e84346136e8565b6127b5565b600060cc5590969095509350505050565b600160cc5414156114975760405162461bcd60e51b81526004016101959061361a565b600160cc5582826114a6612dba565b6114ae612770565b6001600160a01b031680825260405163058dcda760e21b8152631637369c906114dd90869086906004016134e8565b60206040518083038186803b1580156114f557600080fd5b505afa158015611509573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061152d9190613412565b602082018190526115505760405162461bcd60e51b815260040161019590613598565b80516020820151604051632820036560e11b81526001600160a01b039092169163504006ca916115869160040190815260200190565b6101806040518083038186803b15801561159f57600080fd5b505afa1580156115b3573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906115d79190613294565b6040820181905260ca5460a0909101516001600160a01b039081169116146116115760405162461bcd60e51b815260040161019590613534565b61161a84612685565b60006116246126ee565b905060ca60009054906101000a90046001600160a01b03166001600160a01b031663d0e30db0346040518263ffffffff1660e01b81526004016000604051808303818588803b15801561167657600080fd5b505af115801561168a573d6000803e3d6000fd5b505060405163a4c0166b60e01b81526001600160a01b038b81166004830152602482018b905234604483015289811660648301528516935063a4c0166b925060840190506107a5565b600160cc5414156116f65760405162461bcd60e51b81526004016101959061361a565b600160cc5561170482612685565b600061170e6126ee565b9050600061171a612770565b90506000816001600160a01b0316631637369c88886040518363ffffffff1660e01b815260040161174c9291906134e8565b60206040518083038186803b15801561176457600080fd5b505afa158015611778573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061179c9190613412565b90508061180a57604051632142170760e11b8152336004820152306024820152604481018790526001600160a01b038816906342842e0e90606401600060405180830381600087803b1580156117f157600080fd5b505af1158015611805573d6000803e3d6000fd5b505050505b60ca54604051635b294d7760e11b81526001600160a01b039182166004820152602481018a9052888216604482015260648101889052868216608482015261ffff861660a48201529084169063b6529aee9060c401600060405180830381600087803b15801561187957600080fd5b505af115801561188d573d6000803e3d6000fd5b505060ca54604051632e1a7d4d60e01b8152600481018c90526001600160a01b039091169250632e1a7d4d9150602401600060405180830381600087803b1580156118d757600080fd5b505af11580156118eb573d6000803e3d6000fd5b505050506118f985896127b5565b5050600060cc55505050505050565b600160cc54141561192b5760405162461bcd60e51b81526004016101959061361a565b600160cc55828261193a612dba565b611942612770565b6001600160a01b031680825260405163058dcda760e21b8152631637369c9061197190869086906004016134e8565b60206040518083038186803b15801561198957600080fd5b505afa15801561199d573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906119c19190613412565b602082018190526119e45760405162461bcd60e51b815260040161019590613598565b80516020820151604051632820036560e11b81526001600160a01b039092169163504006ca91611a1a9160040190815260200190565b6101806040518083038186803b158015611a3357600080fd5b505afa158015611a47573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611a6b9190613294565b6040820181905260ca5460a0909101516001600160a01b03908116911614611aa55760405162461bcd60e51b815260040161019590613534565b60c9546040516321f8a72160e01b81527f7c617de58ecde9b6796870984f6da6b2111adce1343a91b9baefbb06f8616ca060048201819052916000916001600160a01b03909116906321f8a7219060240160206040518083038186803b158015611b0e57600080fd5b505afa158015611b22573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611b469190612f63565b90503415611bb85760ca60009054906101000a90046001600160a01b03166001600160a01b031663d0e30db0346040518263ffffffff1660e01b81526004016000604051808303818588803b158015611b9e57600080fd5b505af1158015611bb2573d6000803e3d6000fd5b50505050505b60ca54604051636eb1769f60e11b81523060048201526001600160a01b0383811660248301529091169063dd62ed3e90604401602060405180830381600087803b158015611c0557600080fd5b505af1158015611c19573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611c3d9190613412565b611cc95760ca5460405163095ea7b360e01b81526001600160a01b039091169063095ea7b390611c75908490600019906004016134e8565b602060405180830381600087803b158015611c8f57600080fd5b505af1158015611ca3573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611cc79190613278565b505b60405163a7ff3b2360e01b81526001600160a01b03898116600483015260248201899052346044830152878116606483015282169063a7ff3b239060840161127e565b6000600160cc541415611d315760405162461bcd60e51b81526004016101959061361a565b600160cc558282611d40612dba565b611d48612770565b6001600160a01b031680825260405163058dcda760e21b8152631637369c90611d7790869086906004016134e8565b60206040518083038186803b158015611d8f57600080fd5b505afa158015611da3573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611dc79190613412565b60208201819052611dea5760405162461bcd60e51b815260040161019590613598565b80516020820151604051632820036560e11b81526001600160a01b039092169163504006ca91611e209160040190815260200190565b6101806040518083038186803b158015611e3957600080fd5b505afa158015611e4d573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611e719190613294565b6040820181905260ca5460a0909101516001600160a01b03908116911614611eab5760405162461bcd60e51b815260040161019590613534565b6000611eb56126ee565b90503415611f275760ca60009054906101000a90046001600160a01b03166001600160a01b031663d0e30db0346040518263ffffffff1660e01b81526004016000604051808303818588803b158015611f0d57600080fd5b505af1158015611f21573d6000803e3d6000fd5b50505050505b6040516301c40a1760e21b81526001600160a01b0388811660048301526024820188905234604483015260009190831690630710285c90606401602060405180830381600087803b158015611f7b57600080fd5b505af1158015611f8f573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611fb39190613412565b9050803411156120385760ca546001600160a01b0316632e1a7d4d611fd883346136e8565b6040518263ffffffff1660e01b8152600401611ff691815260200190565b600060405180830381600087803b15801561201057600080fd5b505af1158015612024573d6000803e3d6000fd5b5050505061203833823461145e91906136e8565b600060cc55979650505050505050565b6000600160cc54141561206d5760405162461bcd60e51b81526004016101959061361a565b600160cc55848461207c612dba565b612084612770565b6001600160a01b031680825260405163058dcda760e21b8152631637369c906120b390869086906004016134e8565b60206040518083038186803b1580156120cb57600080fd5b505afa1580156120df573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906121039190613412565b602082018190526121265760405162461bcd60e51b815260040161019590613598565b80516020820151604051632820036560e11b81526001600160a01b039092169163504006ca9161215c9160040190815260200190565b6101806040518083038186803b15801561217557600080fd5b505afa158015612189573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906121ad9190613294565b6040820181905260ca5460a0909101516001600160a01b039081169116146121e75760405162461bcd60e51b815260040161019590613534565b60006121f16126ee565b90506121fd86886136d0565b3410156122585760405162461bcd60e51b8152602060048201526024808201527f6d73672e76616c7565206973206c657373207468616e2072656465656d20616d6044820152631bdd5b9d60e21b6064820152608401610195565b60ca60009054906101000a90046001600160a01b03166001600160a01b031663d0e30db0346040518263ffffffff1660e01b81526004016000604051808303818588803b1580156122a857600080fd5b505af11580156122bc573d6000803e3d6000fd5b505060405163ea2092f360e01b81526001600160a01b038d81166004830152602482018d9052604482018c9052606482018b9052600094508516925063ea2092f39150608401602060405180830381600087803b15801561231c57600080fd5b505af1158015612330573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906123549190613412565b9050803411156123d95760ca546001600160a01b0316632e1a7d4d61237983346136e8565b6040518263ffffffff1660e01b815260040161239791815260200190565b600060405180830381600087803b1580156123b157600080fd5b505af11580156123c5573d6000803e3d6000fd5b505050506123d933823461145e91906136e8565b600060cc559998505050505050505050565b600160cc54141561240e5760405162461bcd60e51b81526004016101959061361a565b600160cc556065546001600160a01b0316331461243d5760405162461bcd60e51b815260040161019590613563565b8160005b818110156124b3578260cb600087878581811061246e57634e487b7160e01b600052603260045260246000fd5b90506020020160208101906124839190612f40565b6001600160a01b031681526020810191909152604001600020805460ff1916911515919091179055600101612441565b5050600060cc55505050565b6065546001600160a01b031633146124e95760405162461bcd60e51b815260040161019590613563565b604080516000808252602082019092526001600160a01b03841690839060405161251391906134cc565b60006040518083038185875af1925050503d8060008114612550576040519150601f19603f3d011682016040523d82523d6000602084013e612555565b606091505b505090508061259c5760405162461bcd60e51b815260206004820152601360248201527211551217d514905394d1915497d19052531151606a1b6044820152606401610195565b826001600160a01b03167f71c3b69ecd4f336ba362d69703465c0d62d5041f2bbd97d22c847659b60c05b9836040516125d791815260200190565b60405180910390a2505050565b6065546001600160a01b0316331461260e5760405162461bcd60e51b815260040161019590613563565b6001600160a01b0381166126735760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b6064820152608401610195565b61267c816128c6565b50565b3b151590565b6001600160a01b0381163314806126b0575033600090815260cb602052604090205460ff1615156001145b604051806040016040528060038152602001620c4c0d60ea1b815250906126ea5760405162461bcd60e51b81526004016101959190613501565b5050565b60c954604080516311ead9ef60e31b815290516000926001600160a01b031691638f56cf78916004808301926020929190829003018186803b15801561273357600080fd5b505afa158015612747573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061276b9190612f63565b905090565b60c9546040805163035e6e4d60e41b815290516000926001600160a01b0316916335e6e4d0916004808301926020929190829003018186803b15801561273357600080fd5b604080516000808252602082019092526001600160a01b0384169083906040516127df91906134cc565b60006040518083038185875af1925050503d806000811461281c576040519150601f19603f3d011682016040523d82523d6000602084013e612821565b606091505b5050905080610d515760405162461bcd60e51b815260206004820152601360248201527211551217d514905394d1915497d19052531151606a1b6044820152606401610195565b600054610100900460ff1661288f5760405162461bcd60e51b8152600401610195906135cf565b6112f3612d31565b600054610100900460ff166128be5760405162461bcd60e51b8152600401610195906135cf565b6112f3612d58565b606580546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b6000808585612925612dba565b61292d612770565b6001600160a01b031680825260405163058dcda760e21b8152631637369c9061295c90869086906004016134e8565b60206040518083038186803b15801561297457600080fd5b505afa158015612988573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906129ac9190613412565b602082018190526129cf5760405162461bcd60e51b815260040161019590613598565b80516020820151604051632820036560e11b81526001600160a01b039092169163504006ca91612a059160040190815260200190565b6101806040518083038186803b158015612a1e57600080fd5b505afa158015612a32573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612a569190613294565b6040820181905260ca5460a0909101516001600160a01b03908116911614612a905760405162461bcd60e51b815260040161019590613534565b6000612a9a612770565b90506000816001600160a01b0316631637369c8c8c6040518363ffffffff1660e01b8152600401612acc9291906134e8565b60206040518083038186803b158015612ae457600080fd5b505afa158015612af8573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612b1c9190613412565b604051632bf25fe760e11b8152600481018290529091506000906001600160a01b038416906357e4bfce90602401604080518083038186803b158015612b6157600080fd5b505afa158015612b75573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612b999190613112565b915050808a1015612ba75750885b612bb1818a6136d0565b341015612c0c5760405162461bcd60e51b815260206004820152602360248201527f6d73672e76616c7565206973206c657373207468616e20726570617920616d6f6044820152621d5b9d60ea1b6064820152608401610195565b60ca60009054906101000a90046001600160a01b03166001600160a01b031663d0e30db0826040518263ffffffff1660e01b81526004016000604051808303818588803b158015612c5c57600080fd5b505af1158015612c70573d6000803e3d6000fd5b5050505050600080612c806126ee565b6001600160a01b0316638cd2e0c78f8f8f6040518463ffffffff1660e01b8152600401612ccb939291906001600160a01b039390931683526020830191909152604082015260600190565b6040805180830381600087803b158015612ce457600080fd5b505af1158015612cf8573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612d1c91906134a8565b909f909e509c50505050505050505050505050565b600054610100900460ff166112f35760405162461bcd60e51b8152600401610195906135cf565b600054610100900460ff16612d7f5760405162461bcd60e51b8152600401610195906135cf565b612d87612d31565b6112f3600054610100900460ff16612db15760405162461bcd60e51b8152600401610195906135cf565b6112f3336128c6565b6040805160608101825260008082526020820152908101612e3960408051610180810190915260008082526020820190815260006020820181905260408201819052606082018190526080820181905260a0820181905260c0820181905260e08201819052610100820181905261012082018190526101409091015290565b905290565b8051612e4981613757565b919050565b60008083601f840112612e5f578081fd5b50813567ffffffffffffffff811115612e76578182fd5b6020830191508360208260051b8501011115612e9157600080fd5b9250929050565b805160068110612e4957600080fd5b600060208284031215612eb8578081fd5b6040516020810181811067ffffffffffffffff82111715612edb57612edb613741565b6040529151825250919050565b80516fffffffffffffffffffffffffffffffff81168114612e4957600080fd5b803561ffff81168114612e4957600080fd5b805164ffffffffff81168114612e4957600080fd5b805160ff81168114612e4957600080fd5b600060208284031215612f51578081fd5b8135612f5c81613757565b9392505050565b600060208284031215612f74578081fd5b8151612f5c81613757565b60008060408385031215612f91578081fd5b8235612f9c81613757565b91506020830135612fac81613757565b809150509250929050565b600080600060608486031215612fcb578081fd5b8335612fd681613757565b92506020840135612fe681613757565b929592945050506040919091013590565b6000806000806080858703121561300c578081fd5b843561301781613757565b935060208581013561302881613757565b935060408601359250606086013567ffffffffffffffff8082111561304b578384fd5b818801915088601f83011261305e578384fd5b81358181111561307057613070613741565b613082601f8201601f1916850161369f565b91508082528984828501011115613097578485fd5b8084840185840137810190920192909252939692955090935050565b600080604083850312156130c5578081fd5b82356130d081613757565b91506130de60208401612f08565b90509250929050565b600080604083850312156130f9578182fd5b823561310481613757565b946020939093013593505050565b60008060408385031215613124578182fd5b825161312f81613757565b6020939093015192949293505050565b600080600060608486031215613153578081fd5b833561315e81613757565b925060208401359150604084013561317581613757565b809150509250925092565b600080600060608486031215613194578081fd5b833561319f81613757565b95602085013595506040909401359392505050565b600080600080608085870312156131c9578182fd5b84356131d481613757565b966020860135965060408601359560600135945092505050565b60008060208385031215613200578182fd5b823567ffffffffffffffff811115613216578283fd5b61322285828601612e4e565b90969095509350505050565b600080600060408486031215613242578081fd5b833567ffffffffffffffff811115613258578182fd5b61326486828701612e4e565b90945092505060208401356131758161376c565b600060208284031215613289578081fd5b8151612f5c8161376c565b600061018082840312156132a6578081fd5b6132ae613651565b825181526132be60208401612e98565b60208201526132cf60408401612e3e565b60408201526132e060608401612e3e565b6060820152608083015160808201526132fb60a08401612e3e565b60a082015260c083015160c082015260e083015160e0820152610100613322818501612e3e565b908201526101208381015190820152610140808401519082015261016061334a818501612e3e565b908201529392505050565b60006101408284031215613367578081fd5b61336f61367b565b6133798484612ea7565b815261338760208401612ee8565b602082015261339860408401612ee8565b60408201526133a960608401612ee8565b60608201526133ba60808401612ee8565b60808201526133cb60a08401612f1a565b60a08201526133dc60c08401612e3e565b60c08201526133ed60e08401612e3e565b60e0820152610100613400818501612e3e565b9082015261012061334a848201612f2f565b600060208284031215613423578081fd5b5051919050565b6000806040838503121561343c578182fd5b823591506020830135612fac81613757565b600080600080600060a08688031215613465578283fd5b85359450602086013561347781613757565b935060408601359250606086013561348e81613757565b915061349c60808701612f08565b90509295509295909350565b600080604083850312156134ba578182fd5b825191506020830151612fac8161376c565b600082516134de8184602087016136ff565b9190910192915050565b6001600160a01b03929092168252602082015260400190565b60208152600082518060208401526135208160408501602087016136ff565b601f01601f19169190910160400192915050565b6020808252601590820152740d8dec2dc40e4cae6cae4ecca40dcdee840ae8aa89605b1b604082015260600190565b6020808252818101527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604082015260600190565b6020808252601c908201527f636f6c6c61746572616c206c6f616e206964206e6f7420657869737400000000604082015260600190565b6020808252602b908201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960408201526a6e697469616c697a696e6760a81b606082015260800190565b6020808252601f908201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c00604082015260600190565b604051610180810167ffffffffffffffff8111828210171561367557613675613741565b60405290565b604051610140810167ffffffffffffffff8111828210171561367557613675613741565b604051601f8201601f1916810167ffffffffffffffff811182821017156136c8576136c8613741565b604052919050565b600082198211156136e3576136e361372b565b500190565b6000828210156136fa576136fa61372b565b500390565b60005b8381101561371a578181015183820152602001613702565b838111156114045750506000910152565b634e487b7160e01b600052601160045260246000fd5b634e487b7160e01b600052604160045260246000fd5b6001600160a01b038116811461267c57600080fd5b801515811461267c57600080fdfea26469706673582212207213e6baf98df0591240332ba990b6589eb1556292bd96ccfa737ce84b0ae6c664736f6c63430008040033
Deployed Bytecode
0x6080604052600436106101445760003560e01c806389cbe656116100b6578063a9f189151161006f578063a9f189151461041f578063affa881714610440578063ceac58c01461045e578063d8a2332014610471578063eed88b8d14610491578063f2fde38b146104b1576101a0565b806389cbe656146103365780638da5cb5b1461035e57806395d201151461039057806395f3e238146103a35780639c748eff146103ec578063a59edbd11461040c576101a0565b8063485cc95511610108578063485cc9551461029b57806358c22be7146102bb5780636cb5f035146102ce578063715018a6146102e15780637194a0ea146102f65780638393152314610316576101a0565b8063059398a0146101df578063150b7a02146101ff578063281d64031461024857806336118b521461025b578063482876671461027b576101a0565b366101a05760ca546001600160a01b0316331461019e5760405162461bcd60e51b8152602060048201526013602482015272149958d95a5d99481b9bdd08185b1b1bddd959606a1b60448201526064015b60405180910390fd5b005b60405162461bcd60e51b815260206004820152601460248201527311985b1b189858dac81b9bdd08185b1b1bddd95960621b6044820152606401610195565b3480156101eb57600080fd5b5061019e6101fa366004612fb7565b6104d1565b34801561020b57600080fd5b5061022a61021a366004612ff7565b630a85bd0160e11b949350505050565b6040516001600160e01b031990911681526020015b60405180910390f35b61019e61025636600461313f565b610560565b34801561026757600080fd5b5061019e61027636600461342a565b6107e5565b34801561028757600080fd5b5061019e6102963660046131ee565b610abe565b3480156102a757600080fd5b5061019e6102b6366004612f7f565b610bdd565b61019e6102c93660046130b3565b610d56565b61019e6102dc36600461313f565b610e7e565b3480156102ed57600080fd5b5061019e6112bf565b34801561030257600080fd5b5061019e610311366004612fb7565b6112f5565b34801561032257600080fd5b5061019e610331366004612fb7565b61135a565b610349610344366004613180565b61140a565b6040805192835290151560208301520161023f565b34801561036a57600080fd5b506065546001600160a01b03165b6040516001600160a01b03909116815260200161023f565b61019e61039e36600461313f565b611474565b3480156103af57600080fd5b506103dc6103be366004612f40565b6001600160a01b0316600090815260cb602052604090205460ff1690565b604051901515815260200161023f565b3480156103f857600080fd5b5061019e61040736600461344e565b6116d3565b61019e61041a36600461313f565b611908565b61043261042d3660046130e7565b611d0c565b60405190815260200161023f565b34801561044c57600080fd5b5060ca546001600160a01b0316610378565b61043261046c3660046131b4565b612048565b34801561047d57600080fd5b5061019e61048c36600461322e565b6123eb565b34801561049d57600080fd5b5061019e6104ac3660046130e7565b6124bf565b3480156104bd57600080fd5b5061019e6104cc366004612f40565b6125e4565b6065546001600160a01b031633146104fb5760405162461bcd60e51b815260040161019590613563565b6040516322dca8bb60e21b81526001600160a01b03841690638b72a2ec9061052990859085906004016134e8565b600060405180830381600087803b15801561054357600080fd5b505af1158015610557573d6000803e3d6000fd5b50505050505050565b600160cc5414156105835760405162461bcd60e51b81526004016101959061361a565b600160cc5561059181612685565b600061059b6126ee565b905060006105a7612770565b90506000816001600160a01b0316631637369c87876040518363ffffffff1660e01b81526004016105d99291906134e8565b60206040518083038186803b1580156105f157600080fd5b505afa158015610605573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906106299190613412565b90506000811161064b5760405162461bcd60e51b815260040161019590613598565b604051632820036560e11b8152600481018290526000906001600160a01b0384169063504006ca906024016101806040518083038186803b15801561068f57600080fd5b505afa1580156106a3573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906106c79190613294565b60ca5460a08201519192506001600160a01b039182169116146106fc5760405162461bcd60e51b815260040161019590613534565b341561076c5760ca60009054906101000a90046001600160a01b03166001600160a01b031663d0e30db0346040518263ffffffff1660e01b81526004016000604051808303818588803b15801561075257600080fd5b505af1158015610766573d6000803e3d6000fd5b50505050505b604051631ae3fab960e31b81526001600160a01b03888116600483015260248201889052868116604483015285169063d71fd5c8906064015b600060405180830381600087803b1580156107bf57600080fd5b505af11580156107d3573d6000803e3d6000fd5b5050600060cc55505050505050505050565b600160cc5414156108085760405162461bcd60e51b81526004016101959061361a565b600160cc5561081681612685565b60006108206126ee565b60ca546040516335ea6a7560e01b81526001600160a01b039182166004820152919250600091908316906335ea6a75906024016101406040518083038186803b15801561086c57600080fd5b505afa158015610880573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906108a49190613355565b60c001516040516370a0823160e01b81523360048201529091506000906001600160a01b038316906370a082319060240160206040518083038186803b1580156108ed57600080fd5b505afa158015610901573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906109259190613412565b9050846000198114156109355750805b6040516323b872dd60e01b8152336004820152306024820152604481018290526001600160a01b038416906323b872dd90606401602060405180830381600087803b15801561098357600080fd5b505af1158015610997573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906109bb9190613278565b5060ca54604051631a4ca37b60e21b81526001600160a01b03918216600482015260248101839052306044820152908516906369328dec90606401602060405180830381600087803b158015610a1057600080fd5b505af1158015610a24573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610a489190613412565b5060ca54604051632e1a7d4d60e01b8152600481018390526001600160a01b0390911690632e1a7d4d90602401600060405180830381600087803b158015610a8f57600080fd5b505af1158015610aa3573d6000803e3d6000fd5b50505050610ab185826127b5565b5050600060cc5550505050565b600160cc541415610ae15760405162461bcd60e51b81526004016101959061361a565b600160cc556065546001600160a01b03163314610b105760405162461bcd60e51b815260040161019590613563565b8060005b81811015610bd257838382818110610b3c57634e487b7160e01b600052603260045260246000fd5b9050602002016020810190610b519190612f40565b6001600160a01b031663a22cb465610b676126ee565b6040516001600160e01b031960e084901b1681526001600160a01b03909116600482015260016024820152604401600060405180830381600087803b158015610baf57600080fd5b505af1158015610bc3573d6000803e3d6000fd5b50505050806001019050610b14565b5050600060cc555050565b600054610100900460ff16610bf85760005460ff1615610bfc565b303b155b610c5f5760405162461bcd60e51b815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201526d191e481a5b9a5d1a585b1a5e995960921b6064820152608401610195565b600054610100900460ff16158015610c81576000805461ffff19166101011790555b610c89612868565b610c91612897565b60c980546001600160a01b038086166001600160a01b03199283161790925560ca8054928516929091168217905563095ea7b3610ccc6126ee565b6000196040518363ffffffff1660e01b8152600401610cec9291906134e8565b602060405180830381600087803b158015610d0657600080fd5b505af1158015610d1a573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610d3e9190613278565b508015610d51576000805461ff00191690555b505050565b600160cc541415610d795760405162461bcd60e51b81526004016101959061361a565b600160cc55610d8782612685565b6000610d916126ee565b905060ca60009054906101000a90046001600160a01b03166001600160a01b031663d0e30db0346040518263ffffffff1660e01b81526004016000604051808303818588803b158015610de357600080fd5b505af1158015610df7573d6000803e3d6000fd5b505060ca5460405163e8eda9df60e01b81526001600160a01b039182166004820152346024820152878216604482015261ffff87166064820152908516935063e8eda9df92506084019050600060405180830381600087803b158015610e5c57600080fd5b505af1158015610e70573d6000803e3d6000fd5b5050600060cc555050505050565b600160cc541415610ea15760405162461bcd60e51b81526004016101959061361a565b600160cc558282610eb0612dba565b610eb8612770565b6001600160a01b031680825260405163058dcda760e21b8152631637369c90610ee790869086906004016134e8565b60206040518083038186803b158015610eff57600080fd5b505afa158015610f13573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610f379190613412565b60208201819052610f5a5760405162461bcd60e51b815260040161019590613598565b80516020820151604051632820036560e11b81526001600160a01b039092169163504006ca91610f909160040190815260200190565b6101806040518083038186803b158015610fa957600080fd5b505afa158015610fbd573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610fe19190613294565b6040820181905260ca5460a0909101516001600160a01b0390811691161461101b5760405162461bcd60e51b815260040161019590613534565b60c9546040516321f8a72160e01b81527f7c617de58ecde9b6796870984f6da6b2111adce1343a91b9baefbb06f8616ca060048201819052916000916001600160a01b03909116906321f8a7219060240160206040518083038186803b15801561108457600080fd5b505afa158015611098573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906110bc9190612f63565b9050341561112e5760ca60009054906101000a90046001600160a01b03166001600160a01b031663d0e30db0346040518263ffffffff1660e01b81526004016000604051808303818588803b15801561111457600080fd5b505af1158015611128573d6000803e3d6000fd5b50505050505b60ca54604051636eb1769f60e11b81523060048201526001600160a01b0383811660248301529091169063dd62ed3e90604401602060405180830381600087803b15801561117b57600080fd5b505af115801561118f573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906111b39190613412565b61123f5760ca5460405163095ea7b360e01b81526001600160a01b039091169063095ea7b3906111eb908490600019906004016134e8565b602060405180830381600087803b15801561120557600080fd5b505af1158015611219573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061123d9190613278565b505b60405163059ffdbb60e51b81526001600160a01b03898116600483015260248201899052878116604483015234606483015282169063b3ffb760906084015b600060405180830381600087803b15801561129857600080fd5b505af11580156112ac573d6000803e3d6000fd5b5050600060cc5550505050505050505050565b6065546001600160a01b031633146112e95760405162461bcd60e51b815260040161019590613563565b6112f360006128c6565b565b6065546001600160a01b0316331461131f5760405162461bcd60e51b815260040161019590613563565b604051632142170760e11b81523060048201526001600160a01b038381166024830152604482018390528416906342842e0e90606401610529565b6065546001600160a01b031633146113845760405162461bcd60e51b815260040161019590613563565b60405163a9059cbb60e01b81526001600160a01b0384169063a9059cbb906113b290859085906004016134e8565b602060405180830381600087803b1580156113cc57600080fd5b505af11580156113e0573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906114049190613278565b50505050565b600080600160cc5414156114305760405162461bcd60e51b81526004016101959061361a565b600160cc5560008061144487878784612918565b9150915081341115611463576114633361145e84346136e8565b6127b5565b600060cc5590969095509350505050565b600160cc5414156114975760405162461bcd60e51b81526004016101959061361a565b600160cc5582826114a6612dba565b6114ae612770565b6001600160a01b031680825260405163058dcda760e21b8152631637369c906114dd90869086906004016134e8565b60206040518083038186803b1580156114f557600080fd5b505afa158015611509573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061152d9190613412565b602082018190526115505760405162461bcd60e51b815260040161019590613598565b80516020820151604051632820036560e11b81526001600160a01b039092169163504006ca916115869160040190815260200190565b6101806040518083038186803b15801561159f57600080fd5b505afa1580156115b3573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906115d79190613294565b6040820181905260ca5460a0909101516001600160a01b039081169116146116115760405162461bcd60e51b815260040161019590613534565b61161a84612685565b60006116246126ee565b905060ca60009054906101000a90046001600160a01b03166001600160a01b031663d0e30db0346040518263ffffffff1660e01b81526004016000604051808303818588803b15801561167657600080fd5b505af115801561168a573d6000803e3d6000fd5b505060405163a4c0166b60e01b81526001600160a01b038b81166004830152602482018b905234604483015289811660648301528516935063a4c0166b925060840190506107a5565b600160cc5414156116f65760405162461bcd60e51b81526004016101959061361a565b600160cc5561170482612685565b600061170e6126ee565b9050600061171a612770565b90506000816001600160a01b0316631637369c88886040518363ffffffff1660e01b815260040161174c9291906134e8565b60206040518083038186803b15801561176457600080fd5b505afa158015611778573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061179c9190613412565b90508061180a57604051632142170760e11b8152336004820152306024820152604481018790526001600160a01b038816906342842e0e90606401600060405180830381600087803b1580156117f157600080fd5b505af1158015611805573d6000803e3d6000fd5b505050505b60ca54604051635b294d7760e11b81526001600160a01b039182166004820152602481018a9052888216604482015260648101889052868216608482015261ffff861660a48201529084169063b6529aee9060c401600060405180830381600087803b15801561187957600080fd5b505af115801561188d573d6000803e3d6000fd5b505060ca54604051632e1a7d4d60e01b8152600481018c90526001600160a01b039091169250632e1a7d4d9150602401600060405180830381600087803b1580156118d757600080fd5b505af11580156118eb573d6000803e3d6000fd5b505050506118f985896127b5565b5050600060cc55505050505050565b600160cc54141561192b5760405162461bcd60e51b81526004016101959061361a565b600160cc55828261193a612dba565b611942612770565b6001600160a01b031680825260405163058dcda760e21b8152631637369c9061197190869086906004016134e8565b60206040518083038186803b15801561198957600080fd5b505afa15801561199d573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906119c19190613412565b602082018190526119e45760405162461bcd60e51b815260040161019590613598565b80516020820151604051632820036560e11b81526001600160a01b039092169163504006ca91611a1a9160040190815260200190565b6101806040518083038186803b158015611a3357600080fd5b505afa158015611a47573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611a6b9190613294565b6040820181905260ca5460a0909101516001600160a01b03908116911614611aa55760405162461bcd60e51b815260040161019590613534565b60c9546040516321f8a72160e01b81527f7c617de58ecde9b6796870984f6da6b2111adce1343a91b9baefbb06f8616ca060048201819052916000916001600160a01b03909116906321f8a7219060240160206040518083038186803b158015611b0e57600080fd5b505afa158015611b22573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611b469190612f63565b90503415611bb85760ca60009054906101000a90046001600160a01b03166001600160a01b031663d0e30db0346040518263ffffffff1660e01b81526004016000604051808303818588803b158015611b9e57600080fd5b505af1158015611bb2573d6000803e3d6000fd5b50505050505b60ca54604051636eb1769f60e11b81523060048201526001600160a01b0383811660248301529091169063dd62ed3e90604401602060405180830381600087803b158015611c0557600080fd5b505af1158015611c19573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611c3d9190613412565b611cc95760ca5460405163095ea7b360e01b81526001600160a01b039091169063095ea7b390611c75908490600019906004016134e8565b602060405180830381600087803b158015611c8f57600080fd5b505af1158015611ca3573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611cc79190613278565b505b60405163a7ff3b2360e01b81526001600160a01b03898116600483015260248201899052346044830152878116606483015282169063a7ff3b239060840161127e565b6000600160cc541415611d315760405162461bcd60e51b81526004016101959061361a565b600160cc558282611d40612dba565b611d48612770565b6001600160a01b031680825260405163058dcda760e21b8152631637369c90611d7790869086906004016134e8565b60206040518083038186803b158015611d8f57600080fd5b505afa158015611da3573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611dc79190613412565b60208201819052611dea5760405162461bcd60e51b815260040161019590613598565b80516020820151604051632820036560e11b81526001600160a01b039092169163504006ca91611e209160040190815260200190565b6101806040518083038186803b158015611e3957600080fd5b505afa158015611e4d573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611e719190613294565b6040820181905260ca5460a0909101516001600160a01b03908116911614611eab5760405162461bcd60e51b815260040161019590613534565b6000611eb56126ee565b90503415611f275760ca60009054906101000a90046001600160a01b03166001600160a01b031663d0e30db0346040518263ffffffff1660e01b81526004016000604051808303818588803b158015611f0d57600080fd5b505af1158015611f21573d6000803e3d6000fd5b50505050505b6040516301c40a1760e21b81526001600160a01b0388811660048301526024820188905234604483015260009190831690630710285c90606401602060405180830381600087803b158015611f7b57600080fd5b505af1158015611f8f573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611fb39190613412565b9050803411156120385760ca546001600160a01b0316632e1a7d4d611fd883346136e8565b6040518263ffffffff1660e01b8152600401611ff691815260200190565b600060405180830381600087803b15801561201057600080fd5b505af1158015612024573d6000803e3d6000fd5b5050505061203833823461145e91906136e8565b600060cc55979650505050505050565b6000600160cc54141561206d5760405162461bcd60e51b81526004016101959061361a565b600160cc55848461207c612dba565b612084612770565b6001600160a01b031680825260405163058dcda760e21b8152631637369c906120b390869086906004016134e8565b60206040518083038186803b1580156120cb57600080fd5b505afa1580156120df573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906121039190613412565b602082018190526121265760405162461bcd60e51b815260040161019590613598565b80516020820151604051632820036560e11b81526001600160a01b039092169163504006ca9161215c9160040190815260200190565b6101806040518083038186803b15801561217557600080fd5b505afa158015612189573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906121ad9190613294565b6040820181905260ca5460a0909101516001600160a01b039081169116146121e75760405162461bcd60e51b815260040161019590613534565b60006121f16126ee565b90506121fd86886136d0565b3410156122585760405162461bcd60e51b8152602060048201526024808201527f6d73672e76616c7565206973206c657373207468616e2072656465656d20616d6044820152631bdd5b9d60e21b6064820152608401610195565b60ca60009054906101000a90046001600160a01b03166001600160a01b031663d0e30db0346040518263ffffffff1660e01b81526004016000604051808303818588803b1580156122a857600080fd5b505af11580156122bc573d6000803e3d6000fd5b505060405163ea2092f360e01b81526001600160a01b038d81166004830152602482018d9052604482018c9052606482018b9052600094508516925063ea2092f39150608401602060405180830381600087803b15801561231c57600080fd5b505af1158015612330573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906123549190613412565b9050803411156123d95760ca546001600160a01b0316632e1a7d4d61237983346136e8565b6040518263ffffffff1660e01b815260040161239791815260200190565b600060405180830381600087803b1580156123b157600080fd5b505af11580156123c5573d6000803e3d6000fd5b505050506123d933823461145e91906136e8565b600060cc559998505050505050505050565b600160cc54141561240e5760405162461bcd60e51b81526004016101959061361a565b600160cc556065546001600160a01b0316331461243d5760405162461bcd60e51b815260040161019590613563565b8160005b818110156124b3578260cb600087878581811061246e57634e487b7160e01b600052603260045260246000fd5b90506020020160208101906124839190612f40565b6001600160a01b031681526020810191909152604001600020805460ff1916911515919091179055600101612441565b5050600060cc55505050565b6065546001600160a01b031633146124e95760405162461bcd60e51b815260040161019590613563565b604080516000808252602082019092526001600160a01b03841690839060405161251391906134cc565b60006040518083038185875af1925050503d8060008114612550576040519150601f19603f3d011682016040523d82523d6000602084013e612555565b606091505b505090508061259c5760405162461bcd60e51b815260206004820152601360248201527211551217d514905394d1915497d19052531151606a1b6044820152606401610195565b826001600160a01b03167f71c3b69ecd4f336ba362d69703465c0d62d5041f2bbd97d22c847659b60c05b9836040516125d791815260200190565b60405180910390a2505050565b6065546001600160a01b0316331461260e5760405162461bcd60e51b815260040161019590613563565b6001600160a01b0381166126735760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b6064820152608401610195565b61267c816128c6565b50565b3b151590565b6001600160a01b0381163314806126b0575033600090815260cb602052604090205460ff1615156001145b604051806040016040528060038152602001620c4c0d60ea1b815250906126ea5760405162461bcd60e51b81526004016101959190613501565b5050565b60c954604080516311ead9ef60e31b815290516000926001600160a01b031691638f56cf78916004808301926020929190829003018186803b15801561273357600080fd5b505afa158015612747573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061276b9190612f63565b905090565b60c9546040805163035e6e4d60e41b815290516000926001600160a01b0316916335e6e4d0916004808301926020929190829003018186803b15801561273357600080fd5b604080516000808252602082019092526001600160a01b0384169083906040516127df91906134cc565b60006040518083038185875af1925050503d806000811461281c576040519150601f19603f3d011682016040523d82523d6000602084013e612821565b606091505b5050905080610d515760405162461bcd60e51b815260206004820152601360248201527211551217d514905394d1915497d19052531151606a1b6044820152606401610195565b600054610100900460ff1661288f5760405162461bcd60e51b8152600401610195906135cf565b6112f3612d31565b600054610100900460ff166128be5760405162461bcd60e51b8152600401610195906135cf565b6112f3612d58565b606580546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b6000808585612925612dba565b61292d612770565b6001600160a01b031680825260405163058dcda760e21b8152631637369c9061295c90869086906004016134e8565b60206040518083038186803b15801561297457600080fd5b505afa158015612988573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906129ac9190613412565b602082018190526129cf5760405162461bcd60e51b815260040161019590613598565b80516020820151604051632820036560e11b81526001600160a01b039092169163504006ca91612a059160040190815260200190565b6101806040518083038186803b158015612a1e57600080fd5b505afa158015612a32573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612a569190613294565b6040820181905260ca5460a0909101516001600160a01b03908116911614612a905760405162461bcd60e51b815260040161019590613534565b6000612a9a612770565b90506000816001600160a01b0316631637369c8c8c6040518363ffffffff1660e01b8152600401612acc9291906134e8565b60206040518083038186803b158015612ae457600080fd5b505afa158015612af8573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612b1c9190613412565b604051632bf25fe760e11b8152600481018290529091506000906001600160a01b038416906357e4bfce90602401604080518083038186803b158015612b6157600080fd5b505afa158015612b75573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612b999190613112565b915050808a1015612ba75750885b612bb1818a6136d0565b341015612c0c5760405162461bcd60e51b815260206004820152602360248201527f6d73672e76616c7565206973206c657373207468616e20726570617920616d6f6044820152621d5b9d60ea1b6064820152608401610195565b60ca60009054906101000a90046001600160a01b03166001600160a01b031663d0e30db0826040518263ffffffff1660e01b81526004016000604051808303818588803b158015612c5c57600080fd5b505af1158015612c70573d6000803e3d6000fd5b5050505050600080612c806126ee565b6001600160a01b0316638cd2e0c78f8f8f6040518463ffffffff1660e01b8152600401612ccb939291906001600160a01b039390931683526020830191909152604082015260600190565b6040805180830381600087803b158015612ce457600080fd5b505af1158015612cf8573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612d1c91906134a8565b909f909e509c50505050505050505050505050565b600054610100900460ff166112f35760405162461bcd60e51b8152600401610195906135cf565b600054610100900460ff16612d7f5760405162461bcd60e51b8152600401610195906135cf565b612d87612d31565b6112f3600054610100900460ff16612db15760405162461bcd60e51b8152600401610195906135cf565b6112f3336128c6565b6040805160608101825260008082526020820152908101612e3960408051610180810190915260008082526020820190815260006020820181905260408201819052606082018190526080820181905260a0820181905260c0820181905260e08201819052610100820181905261012082018190526101409091015290565b905290565b8051612e4981613757565b919050565b60008083601f840112612e5f578081fd5b50813567ffffffffffffffff811115612e76578182fd5b6020830191508360208260051b8501011115612e9157600080fd5b9250929050565b805160068110612e4957600080fd5b600060208284031215612eb8578081fd5b6040516020810181811067ffffffffffffffff82111715612edb57612edb613741565b6040529151825250919050565b80516fffffffffffffffffffffffffffffffff81168114612e4957600080fd5b803561ffff81168114612e4957600080fd5b805164ffffffffff81168114612e4957600080fd5b805160ff81168114612e4957600080fd5b600060208284031215612f51578081fd5b8135612f5c81613757565b9392505050565b600060208284031215612f74578081fd5b8151612f5c81613757565b60008060408385031215612f91578081fd5b8235612f9c81613757565b91506020830135612fac81613757565b809150509250929050565b600080600060608486031215612fcb578081fd5b8335612fd681613757565b92506020840135612fe681613757565b929592945050506040919091013590565b6000806000806080858703121561300c578081fd5b843561301781613757565b935060208581013561302881613757565b935060408601359250606086013567ffffffffffffffff8082111561304b578384fd5b818801915088601f83011261305e578384fd5b81358181111561307057613070613741565b613082601f8201601f1916850161369f565b91508082528984828501011115613097578485fd5b8084840185840137810190920192909252939692955090935050565b600080604083850312156130c5578081fd5b82356130d081613757565b91506130de60208401612f08565b90509250929050565b600080604083850312156130f9578182fd5b823561310481613757565b946020939093013593505050565b60008060408385031215613124578182fd5b825161312f81613757565b6020939093015192949293505050565b600080600060608486031215613153578081fd5b833561315e81613757565b925060208401359150604084013561317581613757565b809150509250925092565b600080600060608486031215613194578081fd5b833561319f81613757565b95602085013595506040909401359392505050565b600080600080608085870312156131c9578182fd5b84356131d481613757565b966020860135965060408601359560600135945092505050565b60008060208385031215613200578182fd5b823567ffffffffffffffff811115613216578283fd5b61322285828601612e4e565b90969095509350505050565b600080600060408486031215613242578081fd5b833567ffffffffffffffff811115613258578182fd5b61326486828701612e4e565b90945092505060208401356131758161376c565b600060208284031215613289578081fd5b8151612f5c8161376c565b600061018082840312156132a6578081fd5b6132ae613651565b825181526132be60208401612e98565b60208201526132cf60408401612e3e565b60408201526132e060608401612e3e565b6060820152608083015160808201526132fb60a08401612e3e565b60a082015260c083015160c082015260e083015160e0820152610100613322818501612e3e565b908201526101208381015190820152610140808401519082015261016061334a818501612e3e565b908201529392505050565b60006101408284031215613367578081fd5b61336f61367b565b6133798484612ea7565b815261338760208401612ee8565b602082015261339860408401612ee8565b60408201526133a960608401612ee8565b60608201526133ba60808401612ee8565b60808201526133cb60a08401612f1a565b60a08201526133dc60c08401612e3e565b60c08201526133ed60e08401612e3e565b60e0820152610100613400818501612e3e565b9082015261012061334a848201612f2f565b600060208284031215613423578081fd5b5051919050565b6000806040838503121561343c578182fd5b823591506020830135612fac81613757565b600080600080600060a08688031215613465578283fd5b85359450602086013561347781613757565b935060408601359250606086013561348e81613757565b915061349c60808701612f08565b90509295509295909350565b600080604083850312156134ba578182fd5b825191506020830151612fac8161376c565b600082516134de8184602087016136ff565b9190910192915050565b6001600160a01b03929092168252602082015260400190565b60208152600082518060208401526135208160408501602087016136ff565b601f01601f19169190910160400192915050565b6020808252601590820152740d8dec2dc40e4cae6cae4ecca40dcdee840ae8aa89605b1b604082015260600190565b6020808252818101527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604082015260600190565b6020808252601c908201527f636f6c6c61746572616c206c6f616e206964206e6f7420657869737400000000604082015260600190565b6020808252602b908201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960408201526a6e697469616c697a696e6760a81b606082015260800190565b6020808252601f908201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c00604082015260600190565b604051610180810167ffffffffffffffff8111828210171561367557613675613741565b60405290565b604051610140810167ffffffffffffffff8111828210171561367557613675613741565b604051601f8201601f1916810167ffffffffffffffff811182821017156136c8576136c8613741565b604052919050565b600082198211156136e3576136e361372b565b500190565b6000828210156136fa576136fa61372b565b500390565b60005b8381101561371a578181015183820152602001613702565b838111156114045750506000910152565b634e487b7160e01b600052601160045260246000fd5b634e487b7160e01b600052604160045260246000fd5b6001600160a01b038116811461267c57600080fd5b801515811461267c57600080fdfea26469706673582212207213e6baf98df0591240332ba990b6589eb1556292bd96ccfa737ce84b0ae6c664736f6c63430008040033
Loading...
Loading
Loading...
Loading
Multichain Portfolio | 31 Chains
Chain | Token | Portfolio % | Price | Amount | Value |
---|
Loading...
Loading
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.