Address Details
contract
0xF9163f95DF91ad103659cb7C8936Aceb63c7E410
- Contract Name
- DepositImplementation
- Creator
- 0xa34737–43edab at 0x0e12f1–df8b2d
- Balance
- 0 CELO ( )
- Locked CELO Balance
- 0.00 CELO
- Voting CELO Balance
- 0.00 CELO
- Pending Unlocked Gold
- 0.00 CELO
- Tokens
-
Fetching tokens...
- Transactions
- 2 Transactions
- Transfers
- 0 Transfers
- Gas Used
- 97,418
- Last Balance Update
- 25332403
This contract has been verified via Sourcify.
View contract in Sourcify repository
- Contract name:
- DepositImplementation
- Optimization enabled
- true
- Compiler version
- v0.8.4+commit.c7e474f2
- Optimization runs
- 200
- EVM Version
- istanbul
- Verified at
- 2023-02-07T11:19:53.222311Z
contracts/deposit/DepositImplementation.sol
//SPDX-License-Identifier: Apache-2.0 pragma solidity 0.8.4; import "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol"; import "@openzeppelin/contracts-upgradeable/security/PausableUpgradeable.sol"; import "@openzeppelin/contracts-upgradeable/security/ReentrancyGuardUpgradeable.sol"; import "@openzeppelin/contracts-upgradeable/token/ERC20/utils/SafeERC20Upgradeable.sol"; import "./interfaces/DepositStorageV1.sol"; import "../externalInterfaces/aave/IAToken.sol"; contract DepositImplementation is Initializable, OwnableUpgradeable, PausableUpgradeable, ReentrancyGuardUpgradeable, DepositStorageV1 { using SafeERC20Upgradeable for IERC20; using EnumerableSet for EnumerableSet.AddressSet; /** * @notice Triggered when a token has been added * * @param tokenAddress Address of the token */ event TokenAdded(address indexed tokenAddress); /** * @notice Triggered when a token has been removed * * @param tokenAddress Address of the token */ event TokenRemoved(address indexed tokenAddress); /** * @notice Triggered when the treasury address has been updated * * @param oldTreasury Old treasury address * @param newTreasury New treasury address */ event TreasuryUpdated(address indexed oldTreasury, address indexed newTreasury); /** * @notice Triggered when the donationMiner address has been updated * * @param oldDonationMiner Old donationMiner address * @param newDonationMiner New donationMiner address */ event DonationMinerUpdated(address indexed oldDonationMiner, address indexed newDonationMiner); /** * @notice Triggered when LendingPool has been updated * * @param oldLendingPool Old lendingPool address * @param newLendingPool New lendingPool address */ event LendingPoolUpdated(address indexed oldLendingPool, address indexed newLendingPool); /** * @notice Triggered when an amount of an ERC20 has been deposited * * @param depositorAddress The address of the depositor that makes the deposit * @param token ERC20 token address * @param amount Amount of the deposit */ event DepositAdded(address indexed depositorAddress, address indexed token, uint256 amount); /** * @notice Triggered when an amount of an ERC20 has been withdrawn * * @param depositorAddress The address of the depositor that makes the withdrawal * @param token ERC20 token address * @param amount Amount of the withdrawal * @param interest Interest earned (and donated to DonationMiner) */ event Withdraw( address indexed depositorAddress, address indexed token, uint256 amount, uint256 interest ); /** * @notice Triggered when the interest of an amount of an ERC20 has been donated * * @param depositorAddress The address of the depositor * @param token ERC20 token address * @param amount Amount of the withdrawal * @param interest Interest earned (and donated to DonationMiner) */ event DonateInterest( address indexed depositorAddress, address indexed token, uint256 amount, uint256 interest ); /** * @notice Used to initialize a new DonationMiner contract * * @param _treasury Address of the Treasury * @param _lendingPool Address of the LendingPool */ function initialize( ITreasury _treasury, IDonationMiner _donationMiner, ILendingPool _lendingPool, address[] memory _tokenListAddresses ) public initializer { require(address(_treasury) != address(0), "Deposit::initialize: invalid _treasury address"); require( address(_lendingPool) != address(0), "Deposit::initialize: invalid _lendingPool address" ); __Ownable_init(); __Pausable_init(); __ReentrancyGuard_init(); treasury = _treasury; donationMiner = _donationMiner; lendingPool = _lendingPool; uint256 _index; uint256 _numberOfTokens = _tokenListAddresses.length; for (; _index < _numberOfTokens; _index++) { _tokenList.add(_tokenListAddresses[_index]); IERC20(_tokenListAddresses[_index]).approve(address(lendingPool), type(uint256).max); IERC20(_tokenListAddresses[_index]).approve(address(donationMiner), type(uint256).max); emit TokenAdded(_tokenListAddresses[_index]); } } /** * @notice Returns the current implementation version */ function getVersion() external pure override returns (uint256) { return 1; } function token(address _tokenAddress) external view override returns (uint256 totalAmount, uint256 depositorListLength) { Token storage _token = _tokens[_tokenAddress]; return (_token.totalAmount, _token.depositorList.length()); } function tokenDepositorListAt(address _tokenAddress, uint256 _index) external view override returns (address) { return _tokens[_tokenAddress].depositorList.at(_index); } /** * @notice Returns the number of tokens * * @return uint256 number of tokens */ function tokenListLength() external view override returns (uint256) { return _tokenList.length(); } /** * @notice Returns the address of a token from tokenList * * @param _index index of the token * @return address of the token */ function tokenListAt(uint256 _index) external view override returns (address) { return _tokenList.at(_index); } /** * @notice Returns if an address is an accepted token * * @param _tokenAddress token address to be checked * @return bool true if the tokenAddress is an accepted token */ function isToken(address _tokenAddress) public view override returns (bool) { return _tokenList.contains(_tokenAddress); } function tokenDepositor(address _tokenAddress, address _depositorAddress) external view override returns (uint256 amount, uint256 scaledBalance) { Depositor memory _depositor = _tokens[_tokenAddress].depositors[_depositorAddress]; return (_depositor.amount, _depositor.scaledBalance); } /** * @notice Updates Treasury address * * @param _newTreasury address of new treasury contract */ function updateTreasury(ITreasury _newTreasury) external override onlyOwner { emit TreasuryUpdated(address(treasury), address(_newTreasury)); treasury = _newTreasury; } /** * @notice Updates DonationMiner address * * @param _newDonationMiner address of new donationMiner contract */ function updateDonationMiner(IDonationMiner _newDonationMiner) external override onlyOwner { emit DonationMinerUpdated(address(donationMiner), address(_newDonationMiner)); donationMiner = _newDonationMiner; } /** * @notice Updates the LendingPool contract address * * @param _newLendingPool address of the new LendingPool contract */ function updateLendingPool(ILendingPool _newLendingPool) external override onlyOwner { emit LendingPoolUpdated(address(lendingPool), address(_newLendingPool)); lendingPool = _newLendingPool; } function addToken(address _tokenAddress) public override onlyOwner { require(!isToken(_tokenAddress), "Deposit::addToken: token already added"); require( treasury.isToken(_tokenAddress), "Deposit::addToken: it must be a valid treasury token" ); require( lendingPool.getReserveData(_tokenAddress).aTokenAddress != address(0), "Deposit::addToken: it must be a valid lendingPool token" ); _tokenList.add(_tokenAddress); IERC20(_tokenAddress).approve(address(lendingPool), type(uint256).max); IERC20(_tokenAddress).approve(address(donationMiner), type(uint256).max); emit TokenAdded(_tokenAddress); } function removeToken(address _tokenAddress) external override onlyOwner { require(isToken(_tokenAddress), "Deposit::removeToken: this is not a token"); _tokenList.remove(_tokenAddress); emit TokenRemoved(_tokenAddress); } function deposit(address _tokenAddress, uint256 _amount) external override whenNotPaused nonReentrant { require(isToken(_tokenAddress), "Deposit::deposit: this is not a token"); require(_amount > 0, "Deposit::deposit: invalid amount"); IERC20Upgradeable(_tokenAddress).safeTransferFrom(msg.sender, address(this), _amount); IAToken aToken = IAToken(lendingPool.getReserveData(_tokenAddress).aTokenAddress); uint256 _beforeScaledBalance = aToken.scaledBalanceOf(address(this)); lendingPool.deposit(_tokenAddress, _amount, address(this), 0); uint256 _afterScaledBalance = aToken.scaledBalanceOf(address(this)); Token storage _token = _tokens[_tokenAddress]; _token.depositorList.add(msg.sender); _token.totalAmount += _amount; Depositor storage _depositor = _token.depositors[msg.sender]; _depositor.amount += _amount; _depositor.scaledBalance += _afterScaledBalance - _beforeScaledBalance; emit DepositAdded(msg.sender, _tokenAddress, _amount); } function withdraw(address _tokenAddress, uint256 _amount) external override whenNotPaused nonReentrant { Token storage _token = _tokens[_tokenAddress]; Depositor storage _depositor = _token.depositors[msg.sender]; require(_amount <= _depositor.amount, "Deposit::withdraw: invalid amount"); if (_amount == _depositor.amount) { _token.depositorList.remove(msg.sender); } IAToken aToken = IAToken(lendingPool.getReserveData(_tokenAddress).aTokenAddress); uint256 _beforeScaledBalance = aToken.scaledBalanceOf(address(this)); uint256 _withdrawScaledBalanceShare = (_amount * _depositor.scaledBalance) / _depositor.amount; uint256 _withdrawBalanceShare = (_withdrawScaledBalanceShare * aToken.balanceOf(address(this))) / _beforeScaledBalance; uint256 _interest = _withdrawBalanceShare - _amount; lendingPool.withdraw(_tokenAddress, _amount, msg.sender); lendingPool.withdraw(_tokenAddress, _interest, address(this)); donationMiner.donate(IERC20(_tokenAddress), _interest, msg.sender); _token.totalAmount -= _amount; _depositor.amount -= _amount; _depositor.scaledBalance -= _withdrawScaledBalanceShare; // uint256 _afterScaledBalance = aToken.scaledBalanceOf(address(this)); // uint256 _diffScaledBalance = _beforeScaledBalance - _afterScaledBalance; // uint256 _interest = _diffScaledBalance * aToken.balanceOf(address(this)) / _afterScaledBalance; // // console.log('_beforeScaledBalance: ', _beforeScaledBalance); // console.log('_afterScaledBalance: ', _afterScaledBalance); // console.log('_diffScaledBalance1: ', _diffScaledBalance); // console.log('_diffScaledBalance2: ', _withdrawScaledBalanceShare); // console.log('balance: ', aToken.balanceOf(address(this))); // console.log('_interest1: ', _interest); // console.log('_interest2: ', (_diffScaledBalance * lendingPool.getReserveNormalizedIncome(_tokenAddress) + 1e27/2) / 1e27); // console.log('lendingPool.getReserveNormalizedIncome(address(aToken): ', lendingPool.getReserveNormalizedIncome(_tokenAddress)); // console.log('_withdrawBalanceShare: ', _withdrawBalanceShare); emit Withdraw(msg.sender, _tokenAddress, _amount, _interest); } function donateInterest( address _depositorAddress, address _tokenAddress, uint256 _amount ) external override whenNotPaused nonReentrant { Token storage _token = _tokens[_tokenAddress]; Depositor storage _depositor = _token.depositors[_depositorAddress]; require(_amount <= _depositor.amount, "Deposit::donateInterest: invalid amount"); IAToken aToken = IAToken(lendingPool.getReserveData(_tokenAddress).aTokenAddress); uint256 _beforeScaledBalance = aToken.scaledBalanceOf(address(this)); uint256 _withdrawScaledBalanceShare = (_amount * _depositor.scaledBalance) / _depositor.amount; uint256 _withdrawBalanceShare = (_withdrawScaledBalanceShare * aToken.balanceOf(address(this))) / _beforeScaledBalance; uint256 _interest = _withdrawBalanceShare - _amount; lendingPool.withdraw(_tokenAddress, _interest, address(this)); uint256 _afterScaledBalance = aToken.scaledBalanceOf(address(this)); donationMiner.donate(IERC20(_tokenAddress), _interest, _depositorAddress); _depositor.scaledBalance -= _beforeScaledBalance - _afterScaledBalance; emit DonateInterest(_depositorAddress, _tokenAddress, _amount, _interest); } function interest( address _depositorAddress, address _tokenAddress, uint256 _amount ) external view override returns (uint256) { Token storage _token = _tokens[_tokenAddress]; Depositor storage _depositor = _token.depositors[_depositorAddress]; require(_amount <= _depositor.amount, "Deposit::donateInterest: invalid amount"); IAToken aToken = IAToken(lendingPool.getReserveData(_tokenAddress).aTokenAddress); uint256 _beforeScaledBalance = aToken.scaledBalanceOf(address(this)); uint256 _withdrawScaledBalanceShare = (_amount * _depositor.scaledBalance) / _depositor.amount; uint256 _withdrawBalanceShare = (_withdrawScaledBalanceShare * aToken.balanceOf(address(this))) / _beforeScaledBalance; return _withdrawBalanceShare - _amount; } }
/_openzeppelin/contracts/access/Ownable.sol
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (access/Ownable.sol) pragma solidity ^0.8.0; import "../utils/Context.sol"; /** * @dev Contract module which provides a basic access control mechanism, where * there is an account (an owner) that can be granted exclusive access to * specific functions. * * By default, the owner account will be the one that deploys the contract. This * can later be changed with {transferOwnership}. * * This module is used through inheritance. It will make available the modifier * `onlyOwner`, which can be applied to your functions to restrict their use to * the owner. */ abstract contract Ownable is Context { address private _owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); /** * @dev Initializes the contract setting the deployer as the initial owner. */ constructor() { _transferOwnership(_msgSender()); } /** * @dev 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); } }
/_openzeppelin/contracts/proxy/ERC1967/ERC1967Proxy.sol
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (proxy/ERC1967/ERC1967Proxy.sol) pragma solidity ^0.8.0; import "../Proxy.sol"; import "./ERC1967Upgrade.sol"; /** * @dev This contract implements an upgradeable proxy. It is upgradeable because calls are delegated to an * implementation address that can be changed. This address is stored in storage in the location specified by * https://eips.ethereum.org/EIPS/eip-1967[EIP1967], so that it doesn't conflict with the storage layout of the * implementation behind the proxy. */ contract ERC1967Proxy is Proxy, ERC1967Upgrade { /** * @dev Initializes the upgradeable proxy with an initial implementation specified by `_logic`. * * If `_data` is nonempty, it's used as data in a delegate call to `_logic`. This will typically be an encoded * function call, and allows initializating the storage of the proxy like a Solidity constructor. */ constructor(address _logic, bytes memory _data) payable { assert(_IMPLEMENTATION_SLOT == bytes32(uint256(keccak256("eip1967.proxy.implementation")) - 1)); _upgradeToAndCall(_logic, _data, false); } /** * @dev Returns the current implementation address. */ function _implementation() internal view virtual override returns (address impl) { return ERC1967Upgrade._getImplementation(); } }
/_openzeppelin/contracts/proxy/ERC1967/ERC1967Upgrade.sol
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (proxy/ERC1967/ERC1967Upgrade.sol) pragma solidity ^0.8.2; import "../beacon/IBeacon.sol"; import "../../utils/Address.sol"; import "../../utils/StorageSlot.sol"; /** * @dev This abstract contract provides getters and event emitting update functions for * https://eips.ethereum.org/EIPS/eip-1967[EIP1967] slots. * * _Available since v4.1._ * * @custom:oz-upgrades-unsafe-allow delegatecall */ abstract contract ERC1967Upgrade { // This is the keccak-256 hash of "eip1967.proxy.rollback" subtracted by 1 bytes32 private constant _ROLLBACK_SLOT = 0x4910fdfa16fed3260ed0e7147f7cc6da11a60208b5b9406d12a635614ffd9143; /** * @dev Storage slot with the address of the current implementation. * This is the keccak-256 hash of "eip1967.proxy.implementation" subtracted by 1, and is * validated in the constructor. */ bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc; /** * @dev Emitted when the implementation is upgraded. */ event Upgraded(address indexed implementation); /** * @dev Returns the current implementation address. */ function _getImplementation() internal view returns (address) { return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value; } /** * @dev Stores a new address in the EIP1967 implementation slot. */ function _setImplementation(address newImplementation) private { require(Address.isContract(newImplementation), "ERC1967: new implementation is not a contract"); StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation; } /** * @dev Perform implementation upgrade * * Emits an {Upgraded} event. */ function _upgradeTo(address newImplementation) internal { _setImplementation(newImplementation); emit Upgraded(newImplementation); } /** * @dev Perform implementation upgrade with additional setup call. * * Emits an {Upgraded} event. */ function _upgradeToAndCall( address newImplementation, bytes memory data, bool forceCall ) internal { _upgradeTo(newImplementation); if (data.length > 0 || forceCall) { Address.functionDelegateCall(newImplementation, data); } } /** * @dev Perform implementation upgrade with security checks for UUPS proxies, and additional setup call. * * Emits an {Upgraded} event. */ function _upgradeToAndCallSecure( address newImplementation, bytes memory data, bool forceCall ) internal { address oldImplementation = _getImplementation(); // Initial upgrade and setup call _setImplementation(newImplementation); if (data.length > 0 || forceCall) { Address.functionDelegateCall(newImplementation, data); } // Perform rollback test if not already in progress StorageSlot.BooleanSlot storage rollbackTesting = StorageSlot.getBooleanSlot(_ROLLBACK_SLOT); if (!rollbackTesting.value) { // Trigger rollback using upgradeTo from the new implementation rollbackTesting.value = true; Address.functionDelegateCall( newImplementation, abi.encodeWithSignature("upgradeTo(address)", oldImplementation) ); rollbackTesting.value = false; // Check rollback was effective require(oldImplementation == _getImplementation(), "ERC1967Upgrade: upgrade breaks further upgrades"); // Finally reset to the new implementation and log the upgrade _upgradeTo(newImplementation); } } /** * @dev Storage slot with the admin of the contract. * This is the keccak-256 hash of "eip1967.proxy.admin" subtracted by 1, and is * validated in the constructor. */ bytes32 internal constant _ADMIN_SLOT = 0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103; /** * @dev Emitted when the admin account has changed. */ event AdminChanged(address previousAdmin, address newAdmin); /** * @dev Returns the current admin. */ function _getAdmin() internal view returns (address) { return StorageSlot.getAddressSlot(_ADMIN_SLOT).value; } /** * @dev Stores a new address in the EIP1967 admin slot. */ function _setAdmin(address newAdmin) private { require(newAdmin != address(0), "ERC1967: new admin is the zero address"); StorageSlot.getAddressSlot(_ADMIN_SLOT).value = newAdmin; } /** * @dev Changes the admin of the proxy. * * Emits an {AdminChanged} event. */ function _changeAdmin(address newAdmin) internal { emit AdminChanged(_getAdmin(), newAdmin); _setAdmin(newAdmin); } /** * @dev The storage slot of the UpgradeableBeacon contract which defines the implementation for this proxy. * This is bytes32(uint256(keccak256('eip1967.proxy.beacon')) - 1)) and is validated in the constructor. */ bytes32 internal constant _BEACON_SLOT = 0xa3f0ad74e5423aebfd80d3ef4346578335a9a72aeaee59ff6cb3582b35133d50; /** * @dev Emitted when the beacon is upgraded. */ event BeaconUpgraded(address indexed beacon); /** * @dev Returns the current beacon. */ function _getBeacon() internal view returns (address) { return StorageSlot.getAddressSlot(_BEACON_SLOT).value; } /** * @dev Stores a new beacon in the EIP1967 beacon slot. */ function _setBeacon(address newBeacon) private { require(Address.isContract(newBeacon), "ERC1967: new beacon is not a contract"); require( Address.isContract(IBeacon(newBeacon).implementation()), "ERC1967: beacon implementation is not a contract" ); StorageSlot.getAddressSlot(_BEACON_SLOT).value = newBeacon; } /** * @dev Perform beacon upgrade with additional setup call. Note: This upgrades the address of the beacon, it does * not upgrade the implementation contained in the beacon (see {UpgradeableBeacon-_setImplementation} for that). * * Emits a {BeaconUpgraded} event. */ function _upgradeBeaconToAndCall( address newBeacon, bytes memory data, bool forceCall ) internal { _setBeacon(newBeacon); emit BeaconUpgraded(newBeacon); if (data.length > 0 || forceCall) { Address.functionDelegateCall(IBeacon(newBeacon).implementation(), data); } } }
/_openzeppelin/contracts/proxy/Proxy.sol
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (proxy/Proxy.sol) pragma solidity ^0.8.0; /** * @dev This abstract contract provides a fallback function that delegates all calls to another contract using the EVM * instruction `delegatecall`. We refer to the second contract as the _implementation_ behind the proxy, and it has to * be specified by overriding the virtual {_implementation} function. * * Additionally, delegation to the implementation can be triggered manually through the {_fallback} function, or to a * different contract through the {_delegate} function. * * The success and return data of the delegated call will be returned back to the caller of the proxy. */ abstract contract Proxy { /** * @dev Delegates the current call to `implementation`. * * This function does not return to its internall call site, it will return directly to the external caller. */ function _delegate(address implementation) internal virtual { assembly { // Copy msg.data. We take full control of memory in this inline assembly // block because it will not return to Solidity code. We overwrite the // Solidity scratch pad at memory position 0. calldatacopy(0, 0, calldatasize()) // Call the implementation. // out and outsize are 0 because we don't know the size yet. let result := delegatecall(gas(), implementation, 0, calldatasize(), 0, 0) // Copy the returned data. returndatacopy(0, 0, returndatasize()) switch result // delegatecall returns 0 on error. case 0 { revert(0, returndatasize()) } default { return(0, returndatasize()) } } } /** * @dev This is a virtual function that should be overriden so it returns the address to which the fallback function * and {_fallback} should delegate. */ function _implementation() internal view virtual returns (address); /** * @dev Delegates the current call to the address returned by `_implementation()`. * * This function does not return to its internall call site, it will return directly to the external caller. */ function _fallback() internal virtual { _beforeFallback(); _delegate(_implementation()); } /** * @dev Fallback function that delegates calls to the address returned by `_implementation()`. Will run if no other * function in the contract matches the call data. */ fallback() external payable virtual { _fallback(); } /** * @dev Fallback function that delegates calls to the address returned by `_implementation()`. Will run if call data * is empty. */ receive() external payable virtual { _fallback(); } /** * @dev Hook that is called before falling back to the implementation. Can happen as part of a manual `_fallback` * call, or as part of the Solidity `fallback` or `receive` functions. * * If overriden should call `super._beforeFallback()`. */ function _beforeFallback() internal virtual {} }
/_openzeppelin/contracts/proxy/beacon/IBeacon.sol
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (proxy/beacon/IBeacon.sol) pragma solidity ^0.8.0; /** * @dev This is the interface that {BeaconProxy} expects of its beacon. */ interface IBeacon { /** * @dev Must return an address that can be used as a delegate call target. * * {BeaconProxy} will check that this address is a contract. */ function implementation() external view returns (address); }
/_openzeppelin/contracts/proxy/transparent/ProxyAdmin.sol
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (proxy/transparent/ProxyAdmin.sol) pragma solidity ^0.8.0; import "./TransparentUpgradeableProxy.sol"; import "../../access/Ownable.sol"; /** * @dev This is an auxiliary contract meant to be assigned as the admin of a {TransparentUpgradeableProxy}. For an * explanation of why you would want to use this see the documentation for {TransparentUpgradeableProxy}. */ contract ProxyAdmin is Ownable { /** * @dev Returns the current implementation of `proxy`. * * Requirements: * * - This contract must be the admin of `proxy`. */ function getProxyImplementation(TransparentUpgradeableProxy proxy) public view virtual returns (address) { // We need to manually run the static call since the getter cannot be flagged as view // bytes4(keccak256("implementation()")) == 0x5c60da1b (bool success, bytes memory returndata) = address(proxy).staticcall(hex"5c60da1b"); require(success); return abi.decode(returndata, (address)); } /** * @dev Returns the current admin of `proxy`. * * Requirements: * * - This contract must be the admin of `proxy`. */ function getProxyAdmin(TransparentUpgradeableProxy proxy) public view virtual returns (address) { // We need to manually run the static call since the getter cannot be flagged as view // bytes4(keccak256("admin()")) == 0xf851a440 (bool success, bytes memory returndata) = address(proxy).staticcall(hex"f851a440"); require(success); return abi.decode(returndata, (address)); } /** * @dev Changes the admin of `proxy` to `newAdmin`. * * Requirements: * * - This contract must be the current admin of `proxy`. */ function changeProxyAdmin(TransparentUpgradeableProxy proxy, address newAdmin) public virtual onlyOwner { proxy.changeAdmin(newAdmin); } /** * @dev Upgrades `proxy` to `implementation`. See {TransparentUpgradeableProxy-upgradeTo}. * * Requirements: * * - This contract must be the admin of `proxy`. */ function upgrade(TransparentUpgradeableProxy proxy, address implementation) public virtual onlyOwner { proxy.upgradeTo(implementation); } /** * @dev Upgrades `proxy` to `implementation` and calls a function on the new implementation. See * {TransparentUpgradeableProxy-upgradeToAndCall}. * * Requirements: * * - This contract must be the admin of `proxy`. */ function upgradeAndCall( TransparentUpgradeableProxy proxy, address implementation, bytes memory data ) public payable virtual onlyOwner { proxy.upgradeToAndCall{value: msg.value}(implementation, data); } }
/_openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.sol
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (proxy/transparent/TransparentUpgradeableProxy.sol) pragma solidity ^0.8.0; import "../ERC1967/ERC1967Proxy.sol"; /** * @dev This contract implements a proxy that is upgradeable by an admin. * * To avoid https://medium.com/nomic-labs-blog/malicious-backdoors-in-ethereum-proxies-62629adf3357[proxy selector * clashing], which can potentially be used in an attack, this contract uses the * https://blog.openzeppelin.com/the-transparent-proxy-pattern/[transparent proxy pattern]. This pattern implies two * things that go hand in hand: * * 1. If any account other than the admin calls the proxy, the call will be forwarded to the implementation, even if * that call matches one of the admin functions exposed by the proxy itself. * 2. If the admin calls the proxy, it can access the admin functions, but its calls will never be forwarded to the * implementation. If the admin tries to call a function on the implementation it will fail with an error that says * "admin cannot fallback to proxy target". * * These properties mean that the admin account can only be used for admin actions like upgrading the proxy or changing * the admin, so it's best if it's a dedicated account that is not used for anything else. This will avoid headaches due * to sudden errors when trying to call a function from the proxy implementation. * * Our recommendation is for the dedicated account to be an instance of the {ProxyAdmin} contract. If set up this way, * you should think of the `ProxyAdmin` instance as the real administrative interface of your proxy. */ contract TransparentUpgradeableProxy is ERC1967Proxy { /** * @dev Initializes an upgradeable proxy managed by `_admin`, backed by the implementation at `_logic`, and * optionally initialized with `_data` as explained in {ERC1967Proxy-constructor}. */ constructor( address _logic, address admin_, bytes memory _data ) payable ERC1967Proxy(_logic, _data) { assert(_ADMIN_SLOT == bytes32(uint256(keccak256("eip1967.proxy.admin")) - 1)); _changeAdmin(admin_); } /** * @dev Modifier used internally that will delegate the call to the implementation unless the sender is the admin. */ modifier ifAdmin() { if (msg.sender == _getAdmin()) { _; } else { _fallback(); } } /** * @dev Returns the current admin. * * NOTE: Only the admin can call this function. See {ProxyAdmin-getProxyAdmin}. * * TIP: To get this value clients can read directly from the storage slot shown below (specified by EIP1967) using the * https://eth.wiki/json-rpc/API#eth_getstorageat[`eth_getStorageAt`] RPC call. * `0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103` */ function admin() external ifAdmin returns (address admin_) { admin_ = _getAdmin(); } /** * @dev Returns the current implementation. * * NOTE: Only the admin can call this function. See {ProxyAdmin-getProxyImplementation}. * * TIP: To get this value clients can read directly from the storage slot shown below (specified by EIP1967) using the * https://eth.wiki/json-rpc/API#eth_getstorageat[`eth_getStorageAt`] RPC call. * `0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc` */ function implementation() external ifAdmin returns (address implementation_) { implementation_ = _implementation(); } /** * @dev Changes the admin of the proxy. * * Emits an {AdminChanged} event. * * NOTE: Only the admin can call this function. See {ProxyAdmin-changeProxyAdmin}. */ function changeAdmin(address newAdmin) external virtual ifAdmin { _changeAdmin(newAdmin); } /** * @dev Upgrade the implementation of the proxy. * * NOTE: Only the admin can call this function. See {ProxyAdmin-upgrade}. */ function upgradeTo(address newImplementation) external ifAdmin { _upgradeToAndCall(newImplementation, bytes(""), false); } /** * @dev Upgrade the implementation of the proxy, and then call a function from the new implementation as specified * by `data`, which should be an encoded function call. This is useful to initialize new storage variables in the * proxied contract. * * NOTE: Only the admin can call this function. See {ProxyAdmin-upgradeAndCall}. */ function upgradeToAndCall(address newImplementation, bytes calldata data) external payable ifAdmin { _upgradeToAndCall(newImplementation, data, true); } /** * @dev Returns the current admin. */ function _admin() internal view virtual returns (address) { return _getAdmin(); } /** * @dev Makes sure the admin cannot access the fallback function. See {Proxy-_beforeFallback}. */ function _beforeFallback() internal virtual override { require(msg.sender != _getAdmin(), "TransparentUpgradeableProxy: admin cannot fallback to proxy target"); super._beforeFallback(); } }
/_openzeppelin/contracts/token/ERC20/IERC20.sol
// 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); }
/_openzeppelin/contracts/utils/Address.sol
// 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 Address { /** * @dev Returns true if `account` is a contract. * * [IMPORTANT] * ==== * It is unsafe to assume that an address for which this function returns * false is an externally-owned account (EOA) and not a contract. * * Among others, `isContract` will return false for the following * types of addresses: * * - an externally-owned account * - a contract in construction * - an address where a contract will be created * - an address where a contract lived, but was destroyed * ==== */ 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 Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) { return functionDelegateCall(target, data, "Address: low-level delegate call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { require(isContract(target), "Address: delegate call to non-contract"); (bool success, bytes memory returndata) = target.delegatecall(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); } } } }
/_openzeppelin/contracts/utils/Context.sol
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/Context.sol) pragma solidity ^0.8.0; /** * @dev Provides information about the current execution context, including the * sender of the transaction and its data. While these are generally available * via msg.sender and msg.data, they should not be accessed in such a direct * manner, since when dealing with meta-transactions the account sending and * paying for execution may not be the actual sender (as far as an application * is concerned). * * This contract is only required for intermediate, library-like contracts. */ abstract contract Context { function _msgSender() internal view virtual returns (address) { return msg.sender; } function _msgData() internal view virtual returns (bytes calldata) { return msg.data; } }
/_openzeppelin/contracts/utils/StorageSlot.sol
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/StorageSlot.sol) pragma solidity ^0.8.0; /** * @dev Library for reading and writing primitive types to specific storage slots. * * Storage slots are often used to avoid storage conflict when dealing with upgradeable contracts. * This library helps with reading and writing to such slots without the need for inline assembly. * * The functions in this library return Slot structs that contain a `value` member that can be used to read or write. * * Example usage to set ERC1967 implementation slot: * ``` * contract ERC1967 { * bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc; * * function _getImplementation() internal view returns (address) { * return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value; * } * * function _setImplementation(address newImplementation) internal { * require(Address.isContract(newImplementation), "ERC1967: new implementation is not a contract"); * StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation; * } * } * ``` * * _Available since v4.1 for `address`, `bool`, `bytes32`, and `uint256`._ */ library StorageSlot { struct AddressSlot { address value; } struct BooleanSlot { bool value; } struct Bytes32Slot { bytes32 value; } struct Uint256Slot { uint256 value; } /** * @dev Returns an `AddressSlot` with member `value` located at `slot`. */ function getAddressSlot(bytes32 slot) internal pure returns (AddressSlot storage r) { assembly { r.slot := slot } } /** * @dev Returns an `BooleanSlot` with member `value` located at `slot`. */ function getBooleanSlot(bytes32 slot) internal pure returns (BooleanSlot storage r) { assembly { r.slot := slot } } /** * @dev Returns an `Bytes32Slot` with member `value` located at `slot`. */ function getBytes32Slot(bytes32 slot) internal pure returns (Bytes32Slot storage r) { assembly { r.slot := slot } } /** * @dev Returns an `Uint256Slot` with member `value` located at `slot`. */ function getUint256Slot(bytes32 slot) internal pure returns (Uint256Slot storage r) { assembly { r.slot := slot } } }
/_openzeppelin/contracts/utils/structs/EnumerableSet.sol
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/structs/EnumerableSet.sol) pragma solidity ^0.8.0; /** * @dev Library for managing * https://en.wikipedia.org/wiki/Set_(abstract_data_type)[sets] of primitive * types. * * Sets have the following properties: * * - Elements are added, removed, and checked for existence in constant time * (O(1)). * - Elements are enumerated in O(n). No guarantees are made on the ordering. * * ``` * contract Example { * // Add the library methods * using EnumerableSet for EnumerableSet.AddressSet; * * // Declare a set state variable * EnumerableSet.AddressSet private mySet; * } * ``` * * As of v3.3.0, sets of type `bytes32` (`Bytes32Set`), `address` (`AddressSet`) * and `uint256` (`UintSet`) are supported. */ library EnumerableSet { // To implement this library for multiple types with as little code // repetition as possible, we write it in terms of a generic Set type with // bytes32 values. // The Set implementation uses private functions, and user-facing // implementations (such as AddressSet) are just wrappers around the // underlying Set. // This means that we can only create new EnumerableSets for types that fit // in bytes32. struct Set { // Storage of set values bytes32[] _values; // Position of the value in the `values` array, plus 1 because index 0 // means a value is not in the set. mapping(bytes32 => uint256) _indexes; } /** * @dev Add a value to a set. O(1). * * Returns true if the value was added to the set, that is if it was not * already present. */ function _add(Set storage set, bytes32 value) private returns (bool) { if (!_contains(set, value)) { set._values.push(value); // The value is stored at length-1, but we add 1 to all indexes // and use 0 as a sentinel value set._indexes[value] = set._values.length; return true; } else { return false; } } /** * @dev Removes a value from a set. O(1). * * Returns true if the value was removed from the set, that is if it was * present. */ function _remove(Set storage set, bytes32 value) private returns (bool) { // We read and store the value's index to prevent multiple reads from the same storage slot uint256 valueIndex = set._indexes[value]; if (valueIndex != 0) { // Equivalent to contains(set, value) // To delete an element from the _values array in O(1), we swap the element to delete with the last one in // the array, and then remove the last element (sometimes called as 'swap and pop'). // This modifies the order of the array, as noted in {at}. uint256 toDeleteIndex = valueIndex - 1; uint256 lastIndex = set._values.length - 1; if (lastIndex != toDeleteIndex) { bytes32 lastvalue = set._values[lastIndex]; // Move the last value to the index where the value to delete is set._values[toDeleteIndex] = lastvalue; // Update the index for the moved value set._indexes[lastvalue] = valueIndex; // Replace lastvalue's index to valueIndex } // Delete the slot where the moved value was stored set._values.pop(); // Delete the index for the deleted slot delete set._indexes[value]; return true; } else { return false; } } /** * @dev Returns true if the value is in the set. O(1). */ function _contains(Set storage set, bytes32 value) private view returns (bool) { return set._indexes[value] != 0; } /** * @dev Returns the number of values on the set. O(1). */ function _length(Set storage set) private view returns (uint256) { return set._values.length; } /** * @dev Returns the value stored at position `index` in the set. O(1). * * Note that there are no guarantees on the ordering of values inside the * array, and it may change when more values are added or removed. * * Requirements: * * - `index` must be strictly less than {length}. */ function _at(Set storage set, uint256 index) private view returns (bytes32) { return set._values[index]; } /** * @dev Return the entire set in an array * * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that * this function has an unbounded cost, and using it as part of a state-changing function may render the function * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block. */ function _values(Set storage set) private view returns (bytes32[] memory) { return set._values; } // Bytes32Set struct Bytes32Set { Set _inner; } /** * @dev Add a value to a set. O(1). * * Returns true if the value was added to the set, that is if it was not * already present. */ function add(Bytes32Set storage set, bytes32 value) internal returns (bool) { return _add(set._inner, value); } /** * @dev Removes a value from a set. O(1). * * Returns true if the value was removed from the set, that is if it was * present. */ function remove(Bytes32Set storage set, bytes32 value) internal returns (bool) { return _remove(set._inner, value); } /** * @dev Returns true if the value is in the set. O(1). */ function contains(Bytes32Set storage set, bytes32 value) internal view returns (bool) { return _contains(set._inner, value); } /** * @dev Returns the number of values in the set. O(1). */ function length(Bytes32Set storage set) internal view returns (uint256) { return _length(set._inner); } /** * @dev Returns the value stored at position `index` in the set. O(1). * * Note that there are no guarantees on the ordering of values inside the * array, and it may change when more values are added or removed. * * Requirements: * * - `index` must be strictly less than {length}. */ function at(Bytes32Set storage set, uint256 index) internal view returns (bytes32) { return _at(set._inner, index); } /** * @dev Return the entire set in an array * * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that * this function has an unbounded cost, and using it as part of a state-changing function may render the function * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block. */ function values(Bytes32Set storage set) internal view returns (bytes32[] memory) { return _values(set._inner); } // AddressSet struct AddressSet { Set _inner; } /** * @dev Add a value to a set. O(1). * * Returns true if the value was added to the set, that is if it was not * already present. */ function add(AddressSet storage set, address value) internal returns (bool) { return _add(set._inner, bytes32(uint256(uint160(value)))); } /** * @dev Removes a value from a set. O(1). * * Returns true if the value was removed from the set, that is if it was * present. */ function remove(AddressSet storage set, address value) internal returns (bool) { return _remove(set._inner, bytes32(uint256(uint160(value)))); } /** * @dev Returns true if the value is in the set. O(1). */ function contains(AddressSet storage set, address value) internal view returns (bool) { return _contains(set._inner, bytes32(uint256(uint160(value)))); } /** * @dev Returns the number of values in the set. O(1). */ function length(AddressSet storage set) internal view returns (uint256) { return _length(set._inner); } /** * @dev Returns the value stored at position `index` in the set. O(1). * * Note that there are no guarantees on the ordering of values inside the * array, and it may change when more values are added or removed. * * Requirements: * * - `index` must be strictly less than {length}. */ function at(AddressSet storage set, uint256 index) internal view returns (address) { return address(uint160(uint256(_at(set._inner, index)))); } /** * @dev Return the entire set in an array * * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that * this function has an unbounded cost, and using it as part of a state-changing function may render the function * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block. */ function values(AddressSet storage set) internal view returns (address[] memory) { bytes32[] memory store = _values(set._inner); address[] memory result; assembly { result := store } return result; } // UintSet struct UintSet { Set _inner; } /** * @dev Add a value to a set. O(1). * * Returns true if the value was added to the set, that is if it was not * already present. */ function add(UintSet storage set, uint256 value) internal returns (bool) { return _add(set._inner, bytes32(value)); } /** * @dev Removes a value from a set. O(1). * * Returns true if the value was removed from the set, that is if it was * present. */ function remove(UintSet storage set, uint256 value) internal returns (bool) { return _remove(set._inner, bytes32(value)); } /** * @dev Returns true if the value is in the set. O(1). */ function contains(UintSet storage set, uint256 value) internal view returns (bool) { return _contains(set._inner, bytes32(value)); } /** * @dev Returns the number of values on the set. O(1). */ function length(UintSet storage set) internal view returns (uint256) { return _length(set._inner); } /** * @dev Returns the value stored at position `index` in the set. O(1). * * Note that there are no guarantees on the ordering of values inside the * array, and it may change when more values are added or removed. * * Requirements: * * - `index` must be strictly less than {length}. */ function at(UintSet storage set, uint256 index) internal view returns (uint256) { return uint256(_at(set._inner, index)); } /** * @dev Return the entire set in an array * * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that * this function has an unbounded cost, and using it as part of a state-changing function may render the function * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block. */ function values(UintSet storage set) internal view returns (uint256[] memory) { bytes32[] memory store = _values(set._inner); uint256[] memory result; assembly { result := store } return result; } }
/_openzeppelin/contracts-upgradeable/access/IAccessControlUpgradeable.sol
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (access/IAccessControl.sol) pragma solidity ^0.8.0; /** * @dev External interface of AccessControl declared to support ERC165 detection. */ interface IAccessControlUpgradeable { /** * @dev Emitted when `newAdminRole` is set as ``role``'s admin role, replacing `previousAdminRole` * * `DEFAULT_ADMIN_ROLE` is the starting admin for all roles, despite * {RoleAdminChanged} not being emitted signaling this. * * _Available since v3.1._ */ event RoleAdminChanged(bytes32 indexed role, bytes32 indexed previousAdminRole, bytes32 indexed newAdminRole); /** * @dev Emitted when `account` is granted `role`. * * `sender` is the account that originated the contract call, an admin role * bearer except when using {AccessControl-_setupRole}. */ event RoleGranted(bytes32 indexed role, address indexed account, address indexed sender); /** * @dev Emitted when `account` is revoked `role`. * * `sender` is the account that originated the contract call: * - if using `revokeRole`, it is the admin role bearer * - if using `renounceRole`, it is the role bearer (i.e. `account`) */ event RoleRevoked(bytes32 indexed role, address indexed account, address indexed sender); /** * @dev Returns `true` if `account` has been granted `role`. */ function hasRole(bytes32 role, address account) external view returns (bool); /** * @dev Returns the admin role that controls `role`. See {grantRole} and * {revokeRole}. * * To change a role's admin, use {AccessControl-_setRoleAdmin}. */ function getRoleAdmin(bytes32 role) external view returns (bytes32); /** * @dev Grants `role` to `account`. * * If `account` had not been already granted `role`, emits a {RoleGranted} * event. * * Requirements: * * - the caller must have ``role``'s admin role. */ function grantRole(bytes32 role, address account) external; /** * @dev Revokes `role` from `account`. * * If `account` had been granted `role`, emits a {RoleRevoked} event. * * Requirements: * * - the caller must have ``role``'s admin role. */ function revokeRole(bytes32 role, address account) external; /** * @dev Revokes `role` from the calling account. * * Roles are often managed via {grantRole} and {revokeRole}: this function's * purpose is to provide a mechanism for accounts to lose their privileges * if they are compromised (such as when a trusted device is misplaced). * * If the calling account had been granted `role`, emits a {RoleRevoked} * event. * * Requirements: * * - the caller must be `account`. */ function renounceRole(bytes32 role, address account) external; }
/_openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol
// 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; }
/_openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol
// 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)); } }
/_openzeppelin/contracts-upgradeable/security/PausableUpgradeable.sol
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (security/Pausable.sol) pragma solidity ^0.8.0; import "../utils/ContextUpgradeable.sol"; import "../proxy/utils/Initializable.sol"; /** * @dev Contract module which allows children to implement an emergency stop * mechanism that can be triggered by an authorized account. * * This module is used through inheritance. It will make available the * modifiers `whenNotPaused` and `whenPaused`, which can be applied to * the functions of your contract. Note that they will not be pausable by * simply including this module, only once the modifiers are put in place. */ abstract contract PausableUpgradeable is Initializable, ContextUpgradeable { /** * @dev Emitted when the pause is triggered by `account`. */ event Paused(address account); /** * @dev Emitted when the pause is lifted by `account`. */ event Unpaused(address account); bool private _paused; /** * @dev Initializes the contract in unpaused state. */ function __Pausable_init() internal onlyInitializing { __Context_init_unchained(); __Pausable_init_unchained(); } function __Pausable_init_unchained() internal onlyInitializing { _paused = false; } /** * @dev Returns true if the contract is paused, and false otherwise. */ function paused() public view virtual returns (bool) { return _paused; } /** * @dev Modifier to make a function callable only when the contract is not paused. * * Requirements: * * - The contract must not be paused. */ modifier whenNotPaused() { require(!paused(), "Pausable: paused"); _; } /** * @dev Modifier to make a function callable only when the contract is paused. * * Requirements: * * - The contract must be paused. */ modifier whenPaused() { require(paused(), "Pausable: not paused"); _; } /** * @dev Triggers stopped state. * * Requirements: * * - The contract must not be paused. */ function _pause() internal virtual whenNotPaused { _paused = true; emit Paused(_msgSender()); } /** * @dev Returns to normal state. * * Requirements: * * - The contract must be paused. */ function _unpause() internal virtual whenPaused { _paused = false; emit Unpaused(_msgSender()); } uint256[49] private __gap; }
/_openzeppelin/contracts-upgradeable/security/ReentrancyGuardUpgradeable.sol
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (security/ReentrancyGuard.sol) pragma solidity ^0.8.0; import "../proxy/utils/Initializable.sol"; /** * @dev Contract module that helps prevent reentrant calls to a function. * * Inheriting from `ReentrancyGuard` will make the {nonReentrant} modifier * available, which can be applied to functions to make sure there are no nested * (reentrant) calls to them. * * Note that because there is a single `nonReentrant` guard, functions marked as * `nonReentrant` may not call one another. This can be worked around by making * those functions `private`, and then adding `external` `nonReentrant` entry * points to them. * * TIP: If you would like to learn more about reentrancy and alternative ways * to protect against it, check out our blog post * https://blog.openzeppelin.com/reentrancy-after-istanbul/[Reentrancy After Istanbul]. */ abstract contract ReentrancyGuardUpgradeable is Initializable { // Booleans are more expensive than uint256 or any type that takes up a full // word because each write operation emits an extra SLOAD to first read the // slot's contents, replace the bits taken up by the boolean, and then write // back. This is the compiler's defense against contract upgrades and // pointer aliasing, and it cannot be disabled. // The values being non-zero value makes deployment a bit more expensive, // but in exchange the refund on every call to nonReentrant will be lower in // amount. Since refunds are capped to a percentage of the total // transaction's gas, it is best to keep them low in cases like this one, to // increase the likelihood of the full refund coming into effect. uint256 private constant _NOT_ENTERED = 1; uint256 private constant _ENTERED = 2; uint256 private _status; function __ReentrancyGuard_init() internal onlyInitializing { __ReentrancyGuard_init_unchained(); } function __ReentrancyGuard_init_unchained() internal onlyInitializing { _status = _NOT_ENTERED; } /** * @dev Prevents a contract from calling itself, directly or indirectly. * Calling a `nonReentrant` function from another `nonReentrant` * function is not supported. It is possible to prevent this from happening * by making the `nonReentrant` function external, and making it call a * `private` function that does the actual work. */ modifier nonReentrant() { // 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; } uint256[49] private __gap; }
/_openzeppelin/contracts-upgradeable/token/ERC20/IERC20Upgradeable.sol
// 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); }
/_openzeppelin/contracts-upgradeable/token/ERC20/utils/SafeERC20Upgradeable.sol
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (token/ERC20/utils/SafeERC20.sol) pragma solidity ^0.8.0; import "../IERC20Upgradeable.sol"; import "../../../utils/AddressUpgradeable.sol"; /** * @title SafeERC20 * @dev Wrappers around ERC20 operations that throw on failure (when the token * contract returns false). Tokens that return no value (and instead revert or * throw on failure) are also supported, non-reverting calls are assumed to be * successful. * To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract, * which allows you to call the safe operations as `token.safeTransfer(...)`, etc. */ library SafeERC20Upgradeable { using AddressUpgradeable for address; function safeTransfer( IERC20Upgradeable token, address to, uint256 value ) internal { _callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value)); } function safeTransferFrom( IERC20Upgradeable token, address from, address to, uint256 value ) internal { _callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value)); } /** * @dev Deprecated. This function has issues similar to the ones found in * {IERC20-approve}, and its usage is discouraged. * * Whenever possible, use {safeIncreaseAllowance} and * {safeDecreaseAllowance} instead. */ function safeApprove( IERC20Upgradeable token, address spender, uint256 value ) internal { // safeApprove should only be called when setting an initial allowance, // or when resetting it to zero. To increase and decrease it, use // 'safeIncreaseAllowance' and 'safeDecreaseAllowance' require( (value == 0) || (token.allowance(address(this), spender) == 0), "SafeERC20: approve from non-zero to non-zero allowance" ); _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value)); } function safeIncreaseAllowance( IERC20Upgradeable token, address spender, uint256 value ) internal { uint256 newAllowance = token.allowance(address(this), spender) + value; _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance)); } function safeDecreaseAllowance( IERC20Upgradeable token, address spender, uint256 value ) internal { unchecked { uint256 oldAllowance = token.allowance(address(this), spender); require(oldAllowance >= value, "SafeERC20: decreased allowance below zero"); uint256 newAllowance = oldAllowance - value; _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance)); } } /** * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement * on the return value: the return value is optional (but if data is returned, it must not be false). * @param token The token targeted by the call. * @param data The call data (encoded using abi.encode or one of its variants). */ function _callOptionalReturn(IERC20Upgradeable token, bytes memory data) private { // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since // we're implementing it ourselves. We use {Address.functionCall} to perform this call, which verifies that // the target address contains contract code and also asserts for success in the low-level call. bytes memory returndata = address(token).functionCall(data, "SafeERC20: low-level call failed"); if (returndata.length > 0) { // Return data is optional require(abi.decode(returndata, (bool)), "SafeERC20: ERC20 operation did not succeed"); } } }
/_openzeppelin/contracts-upgradeable/utils/AddressUpgradeable.sol
// 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); } } } }
/_openzeppelin/contracts-upgradeable/utils/ContextUpgradeable.sol
// 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; }
/contracts/ambassadors/interfaces/IAmbassadors.sol
// SPDX-License-Identifier: Apache-2.0 pragma solidity 0.8.4; interface IAmbassadors { function getVersion() external pure returns(uint256); function isAmbassador(address _ambassador) external view returns (bool); function isAmbassadorOf(address _ambassador, address _community) external view returns (bool); function isEntityOf(address _ambassador, address _entityAddress) external view returns (bool); function isAmbassadorAt(address _ambassador, address _entityAddress) external view returns (bool); function addEntity(address _entity) external; function removeEntity(address _entity) external; function replaceEntityAccount(address _entity, address _newEntity) external; function addAmbassador(address _ambassador) external; function removeAmbassador(address _ambassador) external; function replaceAmbassadorAccount(address _ambassador, address _newAmbassador) external; function replaceAmbassador(address _oldAmbassador, address _newAmbassador) external; function transferAmbassador(address _ambassador, address _toEntity, bool _keepCommunities) external; function transferCommunityToAmbassador(address _to, address _community) external; function setCommunityToAmbassador(address _ambassador, address _community) external; function removeCommunity(address _community) external; }
/contracts/community/interfaces/ICommunity.sol
// SPDX-License-Identifier: Apache-2.0 pragma solidity 0.8.4; import "@openzeppelin/contracts-upgradeable/access/IAccessControlUpgradeable.sol"; import {IERC20Upgradeable as IERC20} from "@openzeppelin/contracts-upgradeable/token/ERC20/IERC20Upgradeable.sol"; import "./ICommunityAdmin.sol"; interface ICommunity { enum BeneficiaryState { NONE, //the beneficiary hasn't been added yet Valid, Locked, Removed, AddressChanged, Copied //the beneficiary has been moved in a copy community } struct Beneficiary { BeneficiaryState state; //beneficiary state uint256 claims; //total number of claims uint256 claimedAmount; //total amount of tokens received //(based on token ratios when there are more than one token) uint256 lastClaim; //block number of the last claim mapping(address => uint256) claimedAmounts; } struct TokenUpdates { address tokenAddress; //address of the token uint256 ratio; //ratio between maxClaim and previous token maxClaim uint256 startBlock; //the number of the block from which the this token was "active" } function initialize( address _tokenAddress, address[] memory _managers, uint256 _claimAmount, uint256 _maxClaim, uint256 _decreaseStep, uint256 _baseInterval, uint256 _incrementInterval, uint256 _minTranche, uint256 _maxTranche, uint256 _maxBeneficiaries, ICommunity _previousCommunity ) external; function getVersion() external pure returns(uint256); function previousCommunity() external view returns(ICommunity); function copyOf() external view returns(ICommunity); function copies() external view returns(address[] memory); function originalClaimAmount() external view returns(uint256); function claimAmount() external view returns(uint256); function baseInterval() external view returns(uint256); function incrementInterval() external view returns(uint256); function maxClaim() external view returns(uint256); function maxTotalClaim() external view returns(uint256); function validBeneficiaryCount() external view returns(uint); function maxBeneficiaries() external view returns(uint); function treasuryFunds() external view returns(uint); function privateFunds() external view returns(uint); function communityAdmin() external view returns(ICommunityAdmin); function cUSD() external view returns(IERC20); function token() external view returns(IERC20); function tokenList() external view returns(address[] memory); function locked() external view returns(bool); function beneficiaries(address _beneficiaryAddress) external view returns( BeneficiaryState state, uint256 claims, uint256 claimedAmount, uint256 lastClaim ); function beneficiaryClaimedAmounts(address _beneficiaryAddress) external view returns (uint256[] memory claimedAmounts); function decreaseStep() external view returns(uint); function beneficiaryListAt(uint256 _index) external view returns (address); function impactMarketAddress() external pure returns (address); function beneficiaryListLength() external view returns (uint256); function minTranche() external view returns(uint256); function maxTranche() external view returns(uint256); function lastFundRequest() external view returns(uint256); function tokenUpdates(uint256 _index) external view returns ( address tokenAddress, uint256 ratio, uint256 startBlock ); function tokenUpdatesLength() external view returns (uint256); function isSelfFunding() external view returns (bool); function setBeneficiaryState(address _beneficiaryAddress, BeneficiaryState _state) external; function updateCommunityAdmin(ICommunityAdmin _communityAdmin) external; function updatePreviousCommunity(ICommunity _newPreviousCommunity) external; function updateBeneficiaryParams( uint256 _claimAmount, uint256 _maxClaim, uint256 _decreaseStep, uint256 _baseInterval, uint256 _incrementInterval ) external; function updateCommunityParams( uint256 _minTranche, uint256 _maxTranche ) external; function updateMaxBeneficiaries(uint256 _newMaxBeneficiaries) external; function updateToken( IERC20 _newToken, address[] calldata _exchangePath, uint256 _claimAmount, uint256 _maxClaim, uint256 _decreaseStep, uint256 _baseInterval, uint256 _incrementInterval ) external; function donate(address _sender, uint256 _amount) external; function addTreasuryFunds(uint256 _amount) external; function transfer(IERC20 _token, address _to, uint256 _amount) external; function addManager(address _managerAddress) external; function removeManager(address _managerAddress) external; function addBeneficiary(address _beneficiaryAddress) external; function addBeneficiaries(address[] memory _beneficiaryAddresses) external; function addBeneficiariesUsingSignature( address[] memory _beneficiaryAddresses, uint256 _expirationTimestamp, bytes calldata _signature ) external; function copyBeneficiaries(address[] memory _beneficiaryAddresses) external; function lockBeneficiary(address _beneficiaryAddress) external; function lockBeneficiaries(address[] memory _beneficiaryAddresses) external; function lockBeneficiariesUsingSignature( address[] memory _beneficiaryAddresses, uint256 _expirationTimestamp, bytes calldata _signature ) external; function unlockBeneficiary(address _beneficiaryAddress) external; function unlockBeneficiaries(address[] memory _beneficiaryAddresses) external; function unlockBeneficiariesUsingSignature( address[] memory _beneficiaryAddresses, uint256 _expirationTimestamp, bytes calldata _signature ) external; function removeBeneficiary(address _beneficiaryAddress) external; function removeBeneficiaries(address[] memory _beneficiaryAddresses) external; function removeBeneficiariesUsingSignature( address[] memory _beneficiaryAddresses, uint256 _expirationTimestamp, bytes calldata _signature ) external; function changeBeneficiaryAddressByManager(address _oldBeneficiaryAddress, address _newBeneficiaryAddress) external; function changeBeneficiaryAddress(address _newBeneficiaryAddress) external; function claim() external; function lastInterval(address _beneficiaryAddress) external view returns (uint256); function claimCooldown(address _beneficiaryAddress) external view returns (uint256); function lock() external; function unlock() external; function requestFunds() external; function beneficiaryJoinFromMigrated(address _beneficiaryAddress) external; function getInitialMaxClaim() external view returns (uint256); function addCopy(ICommunity _copy) external; function copyCommunityDetails(ICommunity _originalCommunity) external; }
/contracts/community/interfaces/ICommunityAdmin.sol
// SPDX-License-Identifier: Apache-2.0 pragma solidity 0.8.4; import "@openzeppelin/contracts/proxy/transparent/ProxyAdmin.sol"; import {IERC20Upgradeable as IERC20} from "@openzeppelin/contracts-upgradeable/token/ERC20/IERC20Upgradeable.sol"; import "./ICommunity.sol"; import "../../treasury/interfaces/ITreasury.sol"; import "../../governor/impactMarketCouncil/interfaces/IImpactMarketCouncil.sol"; import "../../ambassadors/interfaces/IAmbassadors.sol"; interface ICommunityAdmin { enum CommunityState { NONE, Valid, Removed, Migrated } function getVersion() external pure returns(uint256); function cUSD() external view returns(IERC20); function treasury() external view returns(ITreasury); function impactMarketCouncil() external view returns(IImpactMarketCouncil); function ambassadors() external view returns(IAmbassadors); function communityMiddleProxy() external view returns(address); function authorizedWalletAddress() external view returns(address); function minClaimAmountRatio() external view returns(uint256); function minClaimAmountRatioPrecision() external view returns(uint256); function communities(address _community) external view returns(CommunityState); function communityImplementation() external view returns(ICommunity); function communityProxyAdmin() external view returns(ProxyAdmin); function communityListAt(uint256 _index) external view returns (address); function communityListLength() external view returns (uint256); function treasurySafetyPercentage() external view returns (uint256); function treasuryMinBalance() external view returns (uint256); function isAmbassadorOrEntityOfCommunity(address _community, address _ambassadorOrEntity) external view returns (bool); function updateTreasury(ITreasury _newTreasury) external; function updateImpactMarketCouncil(IImpactMarketCouncil _newImpactMarketCouncil) external; function updateAmbassadors(IAmbassadors _newAmbassadors) external; function updateCommunityMiddleProxy(address _communityMiddleProxy) external; function updateCommunityImplementation(ICommunity _communityImplementation_) external; function updateAuthorizedWalletAddress(address _newSignerAddress) external; function updateMinClaimAmountRatio(uint256 _newMinClaimAmountRatio) external; function updateTreasurySafetyPercentage(uint256 _newTreasurySafetyPercentage) external; function updateTreasuryMinBalance(uint256 _newTreasuryMinBalance) external; function setCommunityToAmbassador(address _ambassador, ICommunity _communityAddress) external; function updateBeneficiaryParams( ICommunity _community, uint256 _claimAmount, uint256 _maxClaim, uint256 _decreaseStep, uint256 _baseInterval, uint256 _incrementInterval, uint256 _maxBeneficiaries ) external; function updateCommunityParams( ICommunity _community, uint256 _minTranche, uint256 _maxTranche ) external; function updateProxyImplementation(address _communityMiddleProxy, address _newLogic) external; function updateCommunityToken( ICommunity _community, IERC20 _newToken, address[] memory _exchangePath, uint256 _claimAmount, uint256 _maxClaim, uint256 _decreaseStep, uint256 _baseInterval, uint256 _incrementInterval ) external; function addCommunity( address _tokenAddress, address[] memory _managers, address _ambassador, uint256 _claimAmount, uint256 _maxClaim, uint256 _decreaseStep, uint256 _baseInterval, uint256 _incrementInterval, uint256 _minTranche, uint256 _maxTranche, uint256 _maxBeneficiaries ) external; function migrateCommunity( address[] memory _managers, ICommunity _previousCommunity ) external; function splitCommunity( ICommunity _community, uint256 _numberOfCopies, address _ambassador, address[] memory _managers ) external; function removeCommunity(ICommunity _community) external; function fundCommunity() external returns(uint256); function calculateCommunityTrancheAmount(ICommunity _community) external view returns (uint256); function transfer(IERC20 _token, address _to, uint256 _amount) external; function transferFromCommunity( ICommunity _community, IERC20 _token, address _to, uint256 _amount ) external; function getCommunityProxyImplementation(address _communityProxyAddress) external view returns(address); }
/contracts/deposit/interfaces/DepositStorageV1.sol
// SPDX-License-Identifier: Apache-2.0 pragma solidity 0.8.4; import "./IDeposit.sol"; /** * @title Storage for Deposit * @notice For future upgrades, do not change DepositStorageV1. Create a new * contract which implements DepositStorageV1 and following the naming convention * DepositStorageVx. */ abstract contract DepositStorageV1 is IDeposit { ITreasury public override treasury; IDonationMiner public override donationMiner; ILendingPool public override lendingPool; EnumerableSet.AddressSet internal _tokenList; mapping(address => Token) internal _tokens; }
/contracts/deposit/interfaces/IDeposit.sol
//SPDX-License-Identifier: Apache-2.0 pragma solidity 0.8.4; import {IERC20Upgradeable as IERC20} from "@openzeppelin/contracts-upgradeable/token/ERC20/IERC20Upgradeable.sol"; import "@openzeppelin/contracts/utils/structs/EnumerableSet.sol"; import "../../externalInterfaces/aave/ILendingPool.sol"; import "../../donationMiner/interfaces/IDonationMiner.sol"; interface IDeposit { struct Depositor { uint256 amount; uint256 scaledBalance; } struct Token { uint256 totalAmount; EnumerableSet.AddressSet depositorList; mapping(address => Depositor) depositors; } function getVersion() external pure returns(uint256); function lendingPool() external view returns(ILendingPool); function treasury() external view returns (ITreasury); function donationMiner() external view returns (IDonationMiner); function token(address _tokenAddress) external view returns(uint256 totalAmount, uint256 depositorListLength); function tokenDepositorListAt(address _tokenAddress, uint256 _index) external view returns(address); function tokenListLength() external view returns (uint256); function tokenListAt(uint256 _index) external view returns (address); function isToken(address _tokenAddress) external view returns (bool); function tokenDepositor(address _tokenAddress, address _depositorAddress) external view returns (uint256 amount, uint256 scaledBalance); function updateTreasury(ITreasury _newTreasury) external; function updateDonationMiner(IDonationMiner _newDonationMiner) external; function updateLendingPool(ILendingPool _lendingPool) external; function addToken(address _tokenAddress) external; function removeToken(address _tokenAddress) external; function deposit(address _tokenAddress, uint256 _amount) external; function withdraw(address _tokenAddress, uint256 _amount) external; function donateInterest(address _depositorAddress, address _tokenAddress, uint256 _amount) external; function interest(address _depositorAddress, address _tokenAddress, uint256 _amount) external view returns (uint256); }
/contracts/donationMiner/interfaces/IDonationMiner.sol
//SPDX-License-Identifier: Apache-2.0 pragma solidity 0.8.4; import {IERC20Upgradeable as IERC20} from "@openzeppelin/contracts-upgradeable/token/ERC20/IERC20Upgradeable.sol"; import "../../community/interfaces/ICommunityAdmin.sol"; import "../../treasury/interfaces/ITreasury.sol"; import "../../staking/interfaces/IStaking.sol"; interface IDonationMiner { struct RewardPeriod { //reward tokens created per block uint256 rewardPerBlock; //reward tokens from previous periods + reward tokens from this reward period uint256 rewardAmount; //block number at which reward period starts uint256 startBlock; //block number at which reward period ends uint256 endBlock; //total of donations for this rewardPeriod uint256 donationsAmount; //amounts donated by every donor in this rewardPeriod mapping(address => uint256) donorAmounts; uint256 againstPeriods; //total stake amount at the end of this rewardPeriod uint256 stakesAmount; //ratio between 1 cUSD donated and 1 PACT staked uint256 stakingDonationRatio; //true if user has staked/unstaked in this reward period mapping(address => bool) hasSetStakeAmount; //stake amount of a user at the end of this reward period; //if a user doesn't stake/unstake in a reward period, // this value will remain 0 (and hasSetStakeAmount will be false) //if hasNewStakeAmount is false it means the donorStakeAmount // is the same as the last reward period where hasSetStakeAmount is true mapping(address => uint256) donorStakeAmounts; } struct Donor { uint256 lastClaim; //last reward period index for which the donor has claimed the reward; used until v2 uint256 rewardPeriodsCount; //total number of reward periods in which the donor donated mapping(uint256 => uint256) rewardPeriods; //list of all reward period ids in which the donor donated uint256 lastClaimPeriod; //last reward period id for which the donor has claimed the reward } struct Donation { address donor; //address of the donner address target; //address of the receiver (community or treasury) uint256 rewardPeriod; //number of the reward period in which the donation was made uint256 blockNumber; //number of the block in which the donation was executed uint256 amount; //the convertedAmount value IERC20 token; //address of the token uint256 initialAmount; //number of tokens donated } function getVersion() external pure returns(uint256); function cUSD() external view returns (IERC20); function PACT() external view returns (IERC20); function treasury() external view returns (ITreasury); function staking() external view returns (IStaking); function rewardPeriodSize() external view returns (uint256); function decayNumerator() external view returns (uint256); function decayDenominator() external view returns (uint256); function stakingDonationRatio() external view returns (uint256); function communityDonationRatio() external view returns (uint256); function rewardPeriodCount() external view returns (uint256); function donationCount() external view returns (uint256); function rewardPeriods(uint256 _period) external view returns ( uint256 rewardPerBlock, uint256 rewardAmount, uint256 startBlock, uint256 endBlock, uint256 donationsAmount, uint256 againstPeriods, uint256 stakesAmount, uint256 stakingDonationRatio ); function rewardPeriodDonorAmount(uint256 _period, address _donor) external view returns (uint256); function rewardPeriodDonorStakeAmounts(uint256 _period, address _donor) external view returns (uint256); function donors(address _donor) external view returns ( uint256 rewardPeriodsCount, uint256 lastClaim, uint256 lastClaimPeriod ); function donorRewardPeriod(address _donor, uint256 _rewardPeriodIndex) external view returns (uint256); function donations(uint256 _index) external view returns ( address donor, address target, uint256 rewardPeriod, uint256 blockNumber, uint256 amount, IERC20 token, uint256 initialAmount ); function claimDelay() external view returns (uint256); function againstPeriods() external view returns (uint256); function updateRewardPeriodParams( uint256 _newRewardPeriodSize, uint256 _newDecayNumerator, uint256 _newDecayDenominator ) external; function updateClaimDelay(uint256 _newClaimDelay) external; function updateStakingDonationRatio(uint256 _newStakingDonationRatio) external; function updateCommunityDonationRatio(uint256 _newCommunityDonationRatio) external; function updateAgainstPeriods(uint256 _newAgainstPeriods) external; function updateTreasury(ITreasury _newTreasury) external; function updateStaking(IStaking _newStaking) external; function donate(IERC20 _token, uint256 _amount, address _delegateAddress) external; function donateToCommunity(ICommunity _community, IERC20 _token, uint256 _amount, address _delegateAddress) external; function claimRewards() external; function claimRewardsPartial(uint256 _lastPeriodNumber) external; function stakeRewards() external; function stakeRewardsPartial(uint256 _lastPeriodNumber) external; function calculateClaimableRewards(address _donor) external returns (uint256); function calculateClaimableRewardsByPeriodNumber(address _donor, uint256 _lastPeriodNumber) external returns (uint256); function estimateClaimableReward(address _donor) external view returns (uint256); function estimateClaimableRewardAdvance(address _donor) external view returns (uint256); function estimateClaimableRewardByStaking(address _donor) external view returns (uint256); function apr(address _stakeholderAddress) external view returns (uint256); function generalApr() external view returns (uint256); function lastPeriodsDonations(address _donor) external view returns (uint256 donorAmount, uint256 totalAmount); function transfer(IERC20 _token, address _to, uint256 _amount) external; function setStakingAmounts(address _holderAddress, uint256 _holderStakeAmount, uint256 _totalStakesAmount) external; function currentRewardPeriodNumber() external view returns (uint256); }
/contracts/externalInterfaces/aave/DataTypes.sol
// SPDX-License-Identifier: Apache-2.0 pragma solidity 0.8.4; library DataTypes { // refer to the whitepaper, section 1.1 basic concepts for a formal description of these properties. 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; //the current stable borrow rate. Expressed in ray uint128 currentStableBorrowRate; uint40 lastUpdateTimestamp; //tokens addresses address aTokenAddress; address stableDebtTokenAddress; address variableDebtTokenAddress; //address of the interest rate strategy address interestRateStrategyAddress; //the id of the reserve. Represents the position in the list of the active reserves uint8 id; } 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 UserConfigurationMap { uint256 data; } enum InterestRateMode {NONE, STABLE, VARIABLE} }
/contracts/externalInterfaces/aave/IAToken.sol
// SPDX-License-Identifier: Apache-2.0 pragma solidity 0.8.4; import {IERC20 as IERC20Aave} from "@openzeppelin/contracts/token/ERC20/IERC20.sol"; import {IScaledBalanceToken} from './IScaledBalanceToken.sol'; import {IInitializableAToken} from './IInitializableAToken.sol'; import {IAaveIncentivesController} from './IAaveIncentivesController.sol'; interface IAToken is IERC20Aave, IScaledBalanceToken, IInitializableAToken { /** * @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 Mints `amount` aTokens 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 aTokens are burned * @param from The owner of the aTokens, 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 Burns aTokens from `user` and sends the equivalent amount of underlying to `receiverOfUnderlying` * @param user The owner of the aTokens, 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 aTokens 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 Transfers aTokens in the event of a borrow being liquidated, in case the liquidators reclaims the aToken * @param from The address getting liquidated, current owner of the aTokens * @param to The recipient * @param value The amount of tokens getting transferred **/ function transferOnLiquidation( address from, address to, uint256 value ) external; /** * @dev Transfers the underlying asset to `target`. Used by the LendingPool to transfer * assets in borrow(), withdraw() and flashLoan() * @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 Invoked to execute actions on the aToken side after a repayment. * @param user The user executing the repayment * @param amount The amount getting repaid **/ function handleRepayment(address user, uint256 amount) external; /** * @dev Returns the address of the incentives controller contract **/ function getIncentivesController() external view returns (IAaveIncentivesController); /** * @dev Returns the address of the underlying asset of this aToken (E.g. WETH for aWETH) **/ function UNDERLYING_ASSET_ADDRESS() external view returns (address); }
/contracts/externalInterfaces/aave/IAaveIncentivesController.sol
// SPDX-License-Identifier: Apache-2.0 pragma solidity 0.8.4; pragma experimental ABIEncoderV2; interface IAaveIncentivesController { event RewardsAccrued(address indexed user, uint256 amount); event RewardsClaimed(address indexed user, address indexed to, uint256 amount); event RewardsClaimed( address indexed user, address indexed to, address indexed claimer, uint256 amount ); event ClaimerSet(address indexed user, address indexed claimer); /* * @dev Returns the configuration of the distribution for a certain asset * @param asset The address of the reference asset of the distribution * @return The asset index, the emission per second and the last updated timestamp **/ function getAssetData(address asset) external view returns ( uint256, uint256, uint256 ); /* * LEGACY ************************** * @dev Returns the configuration of the distribution for a certain asset * @param asset The address of the reference asset of the distribution * @return The asset index, the emission per second and the last updated timestamp **/ function assets(address asset) external view returns ( uint128, uint128, uint256 ); /** * @dev Whitelists an address to claim the rewards on behalf of another address * @param user The address of the user * @param claimer The address of the claimer */ function setClaimer(address user, address claimer) external; /** * @dev Returns the whitelisted claimer for a certain address (0x0 if not set) * @param user The address of the user * @return The claimer address */ function getClaimer(address user) external view returns (address); /** * @dev Configure assets for a certain rewards emission * @param assets The assets to incentivize * @param emissionsPerSecond The emission for each asset */ function configureAssets(address[] calldata assets, uint256[] calldata emissionsPerSecond) external; /** * @dev Called by the corresponding asset on any update that affects the rewards distribution * @param asset The address of the user * @param userBalance The balance of the user of the asset in the lending pool * @param totalSupply The total supply of the asset in the lending pool **/ function handleAction( address asset, uint256 userBalance, uint256 totalSupply ) external; /** * @dev Returns the total of rewards of an user, already accrued + not yet accrued * @param user The address of the user * @return The rewards **/ function getRewardsBalance(address[] calldata assets, address user) external view returns (uint256); /** * @dev Claims reward for an user, on all the assets of the lending pool, accumulating the pending rewards * @param amount Amount of rewards to claim * @param to Address that will be receiving the rewards * @return Rewards claimed **/ function claimRewards( address[] calldata assets, uint256 amount, address to ) external returns (uint256); /** * @dev Claims reward for an user on behalf, on all the assets of the lending pool, accumulating the pending rewards. The caller must * be whitelisted via "allowClaimOnBehalf" function by the RewardsAdmin role manager * @param amount Amount of rewards to claim * @param user Address to check and claim rewards * @param to Address that will be receiving the rewards * @return Rewards claimed **/ function claimRewardsOnBehalf( address[] calldata assets, uint256 amount, address user, address to ) external returns (uint256); /** * @dev returns the unclaimed rewards of the user * @param user the address of the user * @return the unclaimed user rewards */ function getUserUnclaimedRewards(address user) external view returns (uint256); /** * @dev returns the unclaimed rewards of the user * @param user the address of the user * @param asset The asset to incentivize * @return the user index for the asset */ function getUserAssetData(address user, address asset) external view returns (uint256); /** * @dev for backward compatibility with previous implementation of the Incentives controller */ function REWARD_TOKEN() external view returns (address); /** * @dev for backward compatibility with previous implementation of the Incentives controller */ function PRECISION() external view returns (uint8); /** * @dev Gets the distribution end timestamp of the emissions */ function DISTRIBUTION_END() external view returns (uint256); }
/contracts/externalInterfaces/aave/IInitializableAToken.sol
// SPDX-License-Identifier: Apache-2.0 pragma solidity 0.8.4; import {ILendingPool} from './ILendingPool.sol'; import {IAaveIncentivesController} from './IAaveIncentivesController.sol'; /** * @title IInitializableAToken * @notice Interface for the initialize function on AToken * @author Aave **/ interface IInitializableAToken { /** * @dev Emitted when an aToken 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 aToken * @param aTokenDecimals the decimals of the underlying * @param aTokenName the name of the aToken * @param aTokenSymbol the symbol of the aToken * @param params A set of encoded parameters for additional initialization **/ event Initialized( address indexed underlyingAsset, address indexed pool, address treasury, address incentivesController, uint8 aTokenDecimals, string aTokenName, string aTokenSymbol, bytes params ); /** * @dev Initializes the aToken * @param pool The address of the lending pool where this aToken will be used * @param treasury The address of the Aave treasury, receiving the fees on this aToken * @param underlyingAsset The address of the underlying asset of this aToken (E.g. WETH for aWETH) * @param incentivesController The smart contract managing potential incentives distribution * @param aTokenDecimals The decimals of the aToken, same as the underlying asset's * @param aTokenName The name of the aToken * @param aTokenSymbol The symbol of the aToken */ function initialize( ILendingPool pool, address treasury, address underlyingAsset, IAaveIncentivesController incentivesController, uint8 aTokenDecimals, string calldata aTokenName, string calldata aTokenSymbol, bytes calldata params ) external; }
/contracts/externalInterfaces/aave/ILendingPool.sol
// SPDX-License-Identifier: Apache-2.0 pragma solidity 0.8.4; import {ILendingPoolAddressesProvider} from './ILendingPoolAddressesProvider.sol'; import {DataTypes} from './DataTypes.sol'; interface ILendingPool { /** * @dev Emitted on deposit() * @param reserve The address of the underlying asset of the reserve * @param user The address initiating the deposit * @param onBehalfOf The beneficiary of the deposit, receiving the aTokens * @param amount The amount deposited * @param referral The referral code used **/ event Deposit( address indexed reserve, address user, address indexed onBehalfOf, uint256 amount, uint16 indexed referral ); /** * @dev Emitted on withdraw() * @param reserve The address of the underlyng asset being withdrawn * @param user The address initiating the withdrawal, owner of aTokens * @param to Address that will receive the underlying * @param amount The amount to be withdrawn **/ event Withdraw(address indexed reserve, address indexed user, address indexed to, uint256 amount); /** * @dev Emitted on borrow() and flashLoan() when debt needs to be opened * @param reserve The address of the underlying asset being borrowed * @param user The address of the user initiating the borrow(), receiving the funds on borrow() or just * initiator of the transaction on flashLoan() * @param onBehalfOf The address that will be getting the debt * @param amount The amount borrowed out * @param borrowRateMode The rate mode: 1 for Stable, 2 for Variable * @param borrowRate The numeric rate at which the user has borrowed * @param referral The referral code used **/ event Borrow( address indexed reserve, address user, address indexed onBehalfOf, uint256 amount, uint256 borrowRateMode, uint256 borrowRate, uint16 indexed referral ); /** * @dev Emitted on repay() * @param reserve The address of the underlying asset of the reserve * @param user The beneficiary of the repayment, getting his debt reduced * @param repayer The address of the user initiating the repay(), providing the funds * @param amount The amount repaid **/ event Repay( address indexed reserve, address indexed user, address indexed repayer, uint256 amount ); /** * @dev Emitted on swapBorrowRateMode() * @param reserve The address of the underlying asset of the reserve * @param user The address of the user swapping his rate mode * @param rateMode The rate mode that the user wants to swap to **/ event Swap(address indexed reserve, address indexed user, uint256 rateMode); /** * @dev Emitted on setUserUseReserveAsCollateral() * @param reserve The address of the underlying asset of the reserve * @param user The address of the user enabling the usage as collateral **/ event ReserveUsedAsCollateralEnabled(address indexed reserve, address indexed user); /** * @dev Emitted on setUserUseReserveAsCollateral() * @param reserve The address of the underlying asset of the reserve * @param user The address of the user enabling the usage as collateral **/ event ReserveUsedAsCollateralDisabled(address indexed reserve, address indexed user); /** * @dev Emitted on rebalanceStableBorrowRate() * @param reserve The address of the underlying asset of the reserve * @param user The address of the user for which the rebalance has been executed **/ event RebalanceStableBorrowRate(address indexed reserve, address indexed user); /** * @dev Emitted on flashLoan() * @param target The address of the flash loan receiver contract * @param initiator The address initiating the flash loan * @param asset The address of the asset being flash borrowed * @param amount The amount flash borrowed * @param premium The fee flash borrowed * @param referralCode The referral code used **/ event FlashLoan( address indexed target, address indexed initiator, address indexed asset, uint256 amount, uint256 premium, uint16 referralCode ); /** * @dev Emitted when the pause is triggered. */ event Paused(); /** * @dev Emitted when the pause is lifted. */ event Unpaused(); /** * @dev Emitted when a borrower is liquidated. This event is emitted by the LendingPool via * LendingPoolCollateral manager using a DELEGATECALL * This allows to have the events in the generated ABI for LendingPool. * @param collateralAsset The address of the underlying asset used as collateral, to receive as result of the liquidation * @param debtAsset The address of the underlying borrowed asset to be repaid with the liquidation * @param user The address of the borrower getting liquidated * @param debtToCover The debt amount of borrowed `asset` the liquidator wants to cover * @param liquidatedCollateralAmount The amount of collateral received by the liiquidator * @param liquidator The address of the liquidator * @param receiveAToken `true` if the liquidators wants to receive the collateral aTokens, `false` if he wants * to receive the underlying collateral asset directly **/ event LiquidationCall( address indexed collateralAsset, address indexed debtAsset, address indexed user, uint256 debtToCover, uint256 liquidatedCollateralAmount, address liquidator, bool receiveAToken ); /** * @dev Emitted when the state of a reserve is updated. 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 LendingPool contract. The event is therefore replicated here so it * gets added to the LendingPool ABI * @param reserve The address of the underlying asset of the reserve * @param liquidityRate The new liquidity rate * @param stableBorrowRate The new stable borrow 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 stableBorrowRate, uint256 variableBorrowRate, uint256 liquidityIndex, uint256 variableBorrowIndex ); /** * @dev Deposits an `amount` of underlying asset into the reserve, receiving in return overlying aTokens. * - E.g. User deposits 100 USDC and gets in return 100 aUSDC * @param asset The address of the underlying asset to deposit * @param amount The amount to be deposited * @param onBehalfOf The address that will receive the aTokens, same as msg.sender if the user * wants to receive them on his own wallet, or a different address if the beneficiary of aTokens * is a different wallet * @param referralCode Code used to register the integrator originating the operation, for potential rewards. * 0 if the action is executed directly by the user, without any middle-man **/ function deposit( address asset, uint256 amount, address onBehalfOf, uint16 referralCode ) external; /** * @dev Withdraws an `amount` of underlying asset from the reserve, burning the equivalent aTokens owned * E.g. User has 100 aUSDC, calls withdraw() and receives 100 USDC, burning the 100 aUSDC * @param asset The address of the underlying asset to withdraw * @param amount The underlying amount to be withdrawn * - Send the value type(uint256).max in order to withdraw the whole aToken balance * @param to Address that will receive the underlying, same as msg.sender if the user * wants to receive it on his own wallet, or a different address if the beneficiary is a * different wallet * @return The final amount withdrawn **/ function withdraw( address asset, uint256 amount, address to ) external returns (uint256); /** * @dev Allows users to borrow a specific `amount` of the reserve underlying asset, provided that the borrower * already deposited enough collateral, or he was given enough allowance by a credit delegator on the * corresponding debt token (StableDebtToken or VariableDebtToken) * - E.g. User borrows 100 USDC passing as `onBehalfOf` his own address, receiving the 100 USDC in his wallet * and 100 stable/variable debt tokens, depending on the `interestRateMode` * @param asset The address of the underlying asset to borrow * @param amount The amount to be borrowed * @param interestRateMode The interest rate mode at which the user wants to borrow: 1 for Stable, 2 for Variable * @param referralCode Code used to register the integrator originating the operation, for potential rewards. * 0 if the action is executed directly by the user, without any middle-man * @param onBehalfOf Address of the user who will receive the debt. Should be the address of the borrower itself * calling the function if he wants to borrow against his own collateral, or the address of the credit delegator * if he has been given credit delegation allowance **/ function borrow( address asset, uint256 amount, uint256 interestRateMode, uint16 referralCode, address onBehalfOf ) external; /** * @notice Repays a borrowed `amount` on a specific reserve, burning the equivalent debt tokens owned * - E.g. User repays 100 USDC, burning 100 variable/stable debt tokens of the `onBehalfOf` address * @param asset The address of the borrowed underlying asset previously borrowed * @param amount The amount to repay * - Send the value type(uint256).max in order to repay the whole debt for `asset` on the specific `debtMode` * @param rateMode The interest rate mode at of the debt the user wants to repay: 1 for Stable, 2 for Variable * @param onBehalfOf Address of the user who will get his debt reduced/removed. Should be the address of the * user calling the function if he wants to reduce/remove his own debt, or the address of any other * other borrower whose debt should be removed * @return The final amount repaid **/ function repay( address asset, uint256 amount, uint256 rateMode, address onBehalfOf ) external returns (uint256); /** * @dev Allows a borrower to swap his debt between stable and variable mode, or viceversa * @param asset The address of the underlying asset borrowed * @param rateMode The rate mode that the user wants to swap to **/ function swapBorrowRateMode(address asset, uint256 rateMode) external; /** * @dev Rebalances the stable interest rate of a user to the current stable rate defined on the reserve. * - Users can be rebalanced if the following conditions are satisfied: * 1. Usage ratio is above 95% * 2. the current deposit APY is below REBALANCE_UP_THRESHOLD * maxVariableBorrowRate, which means that too much has been * borrowed at a stable rate and depositors are not earning enough * @param asset The address of the underlying asset borrowed * @param user The address of the user to be rebalanced **/ function rebalanceStableBorrowRate(address asset, address user) external; /** * @dev Allows depositors to enable/disable a specific deposited asset as collateral * @param asset The address of the underlying asset deposited * @param useAsCollateral `true` if the user wants to use the deposit as collateral, `false` otherwise **/ function setUserUseReserveAsCollateral(address asset, bool useAsCollateral) external; /** * @dev Function to liquidate a non-healthy position collateral-wise, with Health Factor below 1 * - The caller (liquidator) covers `debtToCover` amount of debt of the user getting liquidated, and receives * a proportionally amount of the `collateralAsset` plus a bonus to cover market risk * @param collateralAsset The address of the underlying asset used as collateral, to receive as result of the liquidation * @param debtAsset The address of the underlying borrowed asset to be repaid with the liquidation * @param user The address of the borrower getting liquidated * @param debtToCover The debt amount of borrowed `asset` the liquidator wants to cover * @param receiveAToken `true` if the liquidators wants to receive the collateral aTokens, `false` if he wants * to receive the underlying collateral asset directly **/ function liquidationCall( address collateralAsset, address debtAsset, address user, uint256 debtToCover, bool receiveAToken ) external; /** * @dev Allows smartcontracts to access the liquidity of the pool within one transaction, * as long as the amount taken plus a fee is returned. * IMPORTANT There are security concerns for developers of flashloan receiver contracts that must be kept into consideration. * For further details please visit https://developers.aave.com * @param receiverAddress The address of the contract receiving the funds, implementing the IFlashLoanReceiver interface * @param assets The addresses of the assets being flash-borrowed * @param amounts The amounts amounts being flash-borrowed * @param modes Types of the debt to open if the flash loan is not returned: * 0 -> Don't open any debt, just revert if funds can't be transferred from the receiver * 1 -> Open debt at stable rate for the value of the amount flash-borrowed to the `onBehalfOf` address * 2 -> Open debt at variable rate for the value of the amount flash-borrowed to the `onBehalfOf` address * @param onBehalfOf The address that will receive the debt in the case of using on `modes` 1 or 2 * @param params Variadic packed params to pass to the receiver as extra information * @param referralCode Code used to register the integrator originating the operation, for potential rewards. * 0 if the action is executed directly by the user, without any middle-man **/ function flashLoan( address receiverAddress, address[] calldata assets, uint256[] calldata amounts, uint256[] calldata modes, address onBehalfOf, bytes calldata params, uint16 referralCode ) external; /** * @dev Returns the user account data across all the reserves * @param user The address of the user * @return totalCollateralETH the total collateral in ETH of the user * @return totalDebtETH the total debt in ETH of the user * @return availableBorrowsETH the borrowing power left of the user * @return currentLiquidationThreshold the liquidation threshold of the user * @return ltv the loan to value of the user * @return healthFactor the current health factor of the user **/ function getUserAccountData(address user) external view returns ( uint256 totalCollateralETH, uint256 totalDebtETH, uint256 availableBorrowsETH, uint256 currentLiquidationThreshold, uint256 ltv, uint256 healthFactor ); function initReserve( address reserve, address aTokenAddress, address stableDebtAddress, address variableDebtAddress, address interestRateStrategyAddress ) external; function setReserveInterestRateStrategyAddress(address reserve, address rateStrategyAddress) external; function setConfiguration(address reserve, uint256 configuration) external; /** * @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 getConfiguration(address asset) external view returns (DataTypes.ReserveConfigurationMap memory); /** * @dev Returns the configuration of the user across all the reserves * @param user The user address * @return The configuration of the user **/ function getUserConfiguration(address user) external view returns (DataTypes.UserConfigurationMap memory); /** * @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); function finalizeTransfer( address asset, address from, address to, uint256 amount, uint256 balanceFromAfter, uint256 balanceToBefore ) external; function getReservesList() external view returns (address[] memory); function getAddressesProvider() external view returns (ILendingPoolAddressesProvider); function setPause(bool val) external; function paused() external view returns (bool); }
/contracts/externalInterfaces/aave/ILendingPoolAddressesProvider.sol
// SPDX-License-Identifier: Apache-2.0 pragma solidity 0.8.4; /** * @title LendingPoolAddressesProvider 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 Aave Governance * @author Aave **/ interface ILendingPoolAddressesProvider { event MarketIdSet(string newMarketId); event LendingPoolUpdated(address indexed newAddress); event ConfigurationAdminUpdated(address indexed newAddress); event EmergencyAdminUpdated(address indexed newAddress); event LendingPoolConfiguratorUpdated(address indexed newAddress); event LendingPoolCollateralManagerUpdated(address indexed newAddress); event PriceOracleUpdated(address indexed newAddress); event LendingRateOracleUpdated(address indexed newAddress); event ProxyCreated(bytes32 id, address indexed newAddress); event AddressSet(bytes32 id, address indexed newAddress, bool hasProxy); function getMarketId() external view returns (string memory); function setMarketId(string calldata marketId) external; function setAddress(bytes32 id, address newAddress) external; function setAddressAsProxy(bytes32 id, address impl) external; function getAddress(bytes32 id) external view returns (address); function getLendingPool() external view returns (address); function setLendingPoolImpl(address pool) external; function getLendingPoolConfigurator() external view returns (address); function setLendingPoolConfiguratorImpl(address configurator) external; function getLendingPoolCollateralManager() external view returns (address); function setLendingPoolCollateralManager(address manager) external; function getPoolAdmin() external view returns (address); function setPoolAdmin(address admin) external; function getEmergencyAdmin() external view returns (address); function setEmergencyAdmin(address admin) external; function getPriceOracle() external view returns (address); function setPriceOracle(address priceOracle) external; function getLendingRateOracle() external view returns (address); function setLendingRateOracle(address lendingRateOracle) external; }
/contracts/externalInterfaces/aave/IScaledBalanceToken.sol
// SPDX-License-Identifier: Apache-2.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); }
/contracts/externalInterfaces/openzeppelin/IMintableERC20.sol
//SPDX-License-Identifier: Apache-2.0 pragma solidity 0.8.4; interface IMintableERC20 { function mint(address _account, uint96 _amount) external; function burn(address _account, uint96 _amount) external; function totalSupply() external view returns (uint256); function balanceOf(address _account) external view returns (uint256); function transfer(address _recipient, uint256 _amount) external returns (bool); function allowance(address _owner, address _spender) external view returns (uint256); function approve(address _spender, uint256 _amount) external returns (bool); function transferFrom( address _sender, address _recipient, uint256 _amount ) external returns (bool); }
/contracts/governor/impactMarketCouncil/interfaces/IImpactMarketCouncil.sol
// SPDX-License-Identifier: Apache-2.0 pragma solidity 0.8.4; import "@openzeppelin/contracts/proxy/transparent/ProxyAdmin.sol"; interface IImpactMarketCouncil { struct Proposal { // Unique id for looking up a proposal uint256 id; // Creator of the proposal address proposer; // The block at which voting ends: votes must be cast prior to this block uint256 endBlock; // Current number of votes in favor of this proposal uint256 forVotes; // Current number of votes in opposition to this proposal uint256 againstVotes; // Current number of votes for abstaining for this proposal uint256 abstainVotes; // Flag marking whether the proposal has been canceled bool canceled; // Flag marking whether the proposal has been executed bool executed; } /// @notice Ballot receipt record for a voter struct Receipt { // Whether or not a vote has been cast bool hasVoted; // Whether or not the voter supports the proposal or abstains uint8 support; // The number of votes the voter had, which were cast uint96 votes; } /// @notice Possible states that a proposal may be in enum ProposalState { Pending, Active, Canceled, Expired, Succeeded, Executed } }
/contracts/staking/interfaces/IStaking.sol
//SPDX-License-Identifier: Apache-2.0 pragma solidity 0.8.4; import {IERC20Upgradeable as IERC20} from "@openzeppelin/contracts-upgradeable/token/ERC20/IERC20Upgradeable.sol"; import "../../donationMiner/interfaces/IDonationMiner.sol"; import "../../externalInterfaces/openzeppelin/IMintableERC20.sol"; interface IStaking { struct Unstake { uint256 amount; //amount unstaked uint256 cooldownBlock; //first block number that will allow holder to claim this unstake } struct Holder { uint256 amount; // amount of PACT that are staked by holder uint256 nextUnstakeId; // Unstake[] unstakes; //list of all unstakes amount } function getVersion() external pure returns(uint256); function updateCooldown(uint256 _newCooldown) external; function PACT() external view returns (IERC20); function SPACT() external view returns (IMintableERC20); function donationMiner() external view returns (IDonationMiner); function cooldown() external view returns(uint256); function currentTotalAmount() external view returns(uint256); function stakeholderAmount(address _holderAddress) external view returns(uint256); function stakeholder(address _holderAddress) external view returns (uint256 amount, uint256 nextUnstakeId, uint256 unstakeListLength, uint256 unstakedAmount); function stakeholderUnstakeAt(address _holderAddress, uint256 _unstakeIndex) external view returns (Unstake memory); function stakeholdersListAt(uint256 _index) external view returns (address); function stakeholdersListLength() external view returns (uint256); function stake(address _holder, uint256 _amount) external; function unstake(uint256 _amount) external; function claim() external; function claimPartial(uint256 _lastUnstakeId) external; function claimAmount(address _holderAddress) external view returns (uint256); }
/contracts/treasury/interfaces/ITreasury.sol
//SPDX-License-Identifier: Apache-2.0 pragma solidity 0.8.4; import {IERC20Upgradeable as IERC20} from "@openzeppelin/contracts-upgradeable/token/ERC20/IERC20Upgradeable.sol"; import "../../community/interfaces/ICommunityAdmin.sol"; import "./IUniswapV2Router.sol"; interface ITreasury { struct Token { uint256 rate; address[] exchangePath; } function getVersion() external pure returns(uint256); function communityAdmin() external view returns(ICommunityAdmin); function uniswapRouter() external view returns(IUniswapV2Router); function updateCommunityAdmin(ICommunityAdmin _communityAdmin) external; function updateUniswapRouter(IUniswapV2Router _uniswapRouter) external; function transfer(IERC20 _token, address _to, uint256 _amount) external; function isToken(address _tokenAddress) external view returns (bool); function tokenListLength() external view returns (uint256); function tokenListAt(uint256 _index) external view returns (address); function tokens(address _tokenAddress) external view returns (uint256 rate, address[] memory exchangePath); function setToken(address _tokenAddress, uint256 _rate, address[] calldata _exchangePath) external; function removeToken(address _tokenAddress) external; function getConvertedAmount(address _tokenAddress, uint256 _amount) external view returns (uint256); function convertAmount( address _tokenAddress, uint256 _amountIn, uint256 _amountOutMin, address[] memory _exchangePath, uint256 _deadline ) external; }
/contracts/treasury/interfaces/IUniswapV2Router.sol
// SPDX-License-Identifier: Apache-2.0 pragma solidity 0.8.4; interface IUniswapV2Router { function factory() external pure returns (address); function addLiquidity( address tokenA, address tokenB, uint amountADesired, uint amountBDesired, uint amountAMin, uint amountBMin, address to, uint deadline ) external returns (uint amountA, uint amountB, uint liquidity); function removeLiquidity( address tokenA, address tokenB, uint liquidity, uint amountAMin, uint amountBMin, address to, uint deadline ) external returns (uint amountA, uint amountB); function removeLiquidityWithPermit( address tokenA, address tokenB, uint liquidity, uint amountAMin, uint amountBMin, address to, uint deadline, bool approveMax, uint8 v, bytes32 r, bytes32 s ) external returns (uint amountA, uint amountB); function swapExactTokensForTokens( uint amountIn, uint amountOutMin, address[] calldata path, address to, uint deadline ) external returns (uint[] memory amounts); function swapTokensForExactTokens( uint amountOut, uint amountInMax, address[] calldata path, address to, uint deadline ) external returns (uint[] memory amounts); function quote(uint amountA, uint reserveA, uint reserveB) external pure returns (uint amountB); function getAmountOut(uint amountIn, uint reserveIn, uint reserveOut) external pure returns (uint amountOut); function getAmountIn(uint amountOut, uint reserveIn, uint reserveOut) external pure returns (uint amountIn); function getAmountsOut(uint amountIn, address[] calldata path) external view returns (uint[] memory amounts); function getAmountsIn(uint amountOut, address[] calldata path) external view returns (uint[] memory amounts); function swapExactTokensForTokensSupportingFeeOnTransferTokens( uint amountIn, uint amountOutMin, address[] calldata path, address to, uint deadline ) external; function pairFor(address tokenA, address tokenB) external view returns (address); }
Contract ABI
[{"type":"event","name":"DepositAdded","inputs":[{"type":"address","name":"depositorAddress","internalType":"address","indexed":true},{"type":"address","name":"token","internalType":"address","indexed":true},{"type":"uint256","name":"amount","internalType":"uint256","indexed":false}],"anonymous":false},{"type":"event","name":"DonateInterest","inputs":[{"type":"address","name":"depositorAddress","internalType":"address","indexed":true},{"type":"address","name":"token","internalType":"address","indexed":true},{"type":"uint256","name":"amount","internalType":"uint256","indexed":false},{"type":"uint256","name":"interest","internalType":"uint256","indexed":false}],"anonymous":false},{"type":"event","name":"DonationMinerUpdated","inputs":[{"type":"address","name":"oldDonationMiner","internalType":"address","indexed":true},{"type":"address","name":"newDonationMiner","internalType":"address","indexed":true}],"anonymous":false},{"type":"event","name":"LendingPoolUpdated","inputs":[{"type":"address","name":"oldLendingPool","internalType":"address","indexed":true},{"type":"address","name":"newLendingPool","internalType":"address","indexed":true}],"anonymous":false},{"type":"event","name":"OwnershipTransferred","inputs":[{"type":"address","name":"previousOwner","internalType":"address","indexed":true},{"type":"address","name":"newOwner","internalType":"address","indexed":true}],"anonymous":false},{"type":"event","name":"Paused","inputs":[{"type":"address","name":"account","internalType":"address","indexed":false}],"anonymous":false},{"type":"event","name":"TokenAdded","inputs":[{"type":"address","name":"tokenAddress","internalType":"address","indexed":true}],"anonymous":false},{"type":"event","name":"TokenRemoved","inputs":[{"type":"address","name":"tokenAddress","internalType":"address","indexed":true}],"anonymous":false},{"type":"event","name":"TreasuryUpdated","inputs":[{"type":"address","name":"oldTreasury","internalType":"address","indexed":true},{"type":"address","name":"newTreasury","internalType":"address","indexed":true}],"anonymous":false},{"type":"event","name":"Unpaused","inputs":[{"type":"address","name":"account","internalType":"address","indexed":false}],"anonymous":false},{"type":"event","name":"Withdraw","inputs":[{"type":"address","name":"depositorAddress","internalType":"address","indexed":true},{"type":"address","name":"token","internalType":"address","indexed":true},{"type":"uint256","name":"amount","internalType":"uint256","indexed":false},{"type":"uint256","name":"interest","internalType":"uint256","indexed":false}],"anonymous":false},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"addToken","inputs":[{"type":"address","name":"_tokenAddress","internalType":"address"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"deposit","inputs":[{"type":"address","name":"_tokenAddress","internalType":"address"},{"type":"uint256","name":"_amount","internalType":"uint256"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"donateInterest","inputs":[{"type":"address","name":"_depositorAddress","internalType":"address"},{"type":"address","name":"_tokenAddress","internalType":"address"},{"type":"uint256","name":"_amount","internalType":"uint256"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"","internalType":"contract IDonationMiner"}],"name":"donationMiner","inputs":[]},{"type":"function","stateMutability":"pure","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"getVersion","inputs":[]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"initialize","inputs":[{"type":"address","name":"_treasury","internalType":"contract ITreasury"},{"type":"address","name":"_donationMiner","internalType":"contract IDonationMiner"},{"type":"address","name":"_lendingPool","internalType":"contract ILendingPool"},{"type":"address[]","name":"_tokenListAddresses","internalType":"address[]"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"interest","inputs":[{"type":"address","name":"_depositorAddress","internalType":"address"},{"type":"address","name":"_tokenAddress","internalType":"address"},{"type":"uint256","name":"_amount","internalType":"uint256"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"bool","name":"","internalType":"bool"}],"name":"isToken","inputs":[{"type":"address","name":"_tokenAddress","internalType":"address"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"","internalType":"contract ILendingPool"}],"name":"lendingPool","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"","internalType":"address"}],"name":"owner","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"bool","name":"","internalType":"bool"}],"name":"paused","inputs":[]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"removeToken","inputs":[{"type":"address","name":"_tokenAddress","internalType":"address"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"renounceOwnership","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"totalAmount","internalType":"uint256"},{"type":"uint256","name":"depositorListLength","internalType":"uint256"}],"name":"token","inputs":[{"type":"address","name":"_tokenAddress","internalType":"address"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"amount","internalType":"uint256"},{"type":"uint256","name":"scaledBalance","internalType":"uint256"}],"name":"tokenDepositor","inputs":[{"type":"address","name":"_tokenAddress","internalType":"address"},{"type":"address","name":"_depositorAddress","internalType":"address"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"","internalType":"address"}],"name":"tokenDepositorListAt","inputs":[{"type":"address","name":"_tokenAddress","internalType":"address"},{"type":"uint256","name":"_index","internalType":"uint256"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"","internalType":"address"}],"name":"tokenListAt","inputs":[{"type":"uint256","name":"_index","internalType":"uint256"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"tokenListLength","inputs":[]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"transferOwnership","inputs":[{"type":"address","name":"newOwner","internalType":"address"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"","internalType":"contract ITreasury"}],"name":"treasury","inputs":[]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"updateDonationMiner","inputs":[{"type":"address","name":"_newDonationMiner","internalType":"contract IDonationMiner"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"updateLendingPool","inputs":[{"type":"address","name":"_newLendingPool","internalType":"contract ILendingPool"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"updateTreasury","inputs":[{"type":"address","name":"_newTreasury","internalType":"contract ITreasury"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"withdraw","inputs":[{"type":"address","name":"_tokenAddress","internalType":"address"},{"type":"uint256","name":"_amount","internalType":"uint256"}]}]
Contract Creation Code
0x608060405234801561001057600080fd5b50612b34806100206000396000f3fe608060405234801561001057600080fd5b50600436106101585760003560e01c80637f51bb1f116100c3578063d48bfca71161007c578063d48bfca714610319578063e36d4f3e1461032c578063e6bfbfd81461033f578063f0367db514610352578063f2fde38b14610365578063f3fef3a31461037857600080fd5b80637f51bb1f146102b457806383912426146102c75780638da5cb5b146102da5780639a552a29146102eb578063a59a9973146102f3578063c89fc9a71461030657600080fd5b806347e7ef241161011557806347e7ef24146102555780635c975abb146102685780635fa7b5841461027357806361d027b3146102865780636d46a1db14610299578063715018a6146102ac57600080fd5b80630b9b1f9a1461015d5780630d8e6e2c1461017257806312cf28841461018857806319f373611461019b57806332b194b5146101be5780633ede2d67146101e9575b600080fd5b61017061016b36600461252c565b61038b565b005b60015b6040519081526020015b60405180910390f35b610175610196366004612580565b61041a565b6101ae6101a936600461252c565b610638565b604051901515815260200161017f565b6101d16101cc3660046127e3565b61064b565b6040516001600160a01b03909116815260200161017f565b6102406101f7366004612548565b6001600160a01b03918216600090815260ce6020908152604080832093909416825260039092018252829020825180840190935280548084526001909101549290910182905291565b6040805192835260208301919091520161017f565b6101706102633660046125c0565b610658565b60655460ff166101ae565b61017061028136600461252c565b610a37565b60c9546101d1906001600160a01b031681565b6102406102a736600461252c565b610b0b565b610170610b3e565b6101706102c236600461252c565b610b74565b6101d16102d53660046125c0565b610bfa565b6033546001600160a01b03166101d1565b610175610c1f565b60cb546101d1906001600160a01b031681565b61017061031436600461252c565b610c30565b61017061032736600461252c565b610cb6565b60ca546101d1906001600160a01b031681565b61017061034d36600461260b565b61107e565b610170610360366004612580565b61148c565b61017061037336600461252c565b6118de565b6101706103863660046125c0565b611979565b6033546001600160a01b031633146103be5760405162461bcd60e51b81526004016103b5906128af565b60405180910390fd5b60cb546040516001600160a01b038084169216907fb8852e851bdabda04c25661cfbfa7b09b3019206382f067a349af593e883214a90600090a360cb80546001600160a01b0319166001600160a01b0392909216919091179055565b6001600160a01b03808316600090815260ce60209081526040808320938716835260038401909152812080549192918411156104685760405162461bcd60e51b81526004016103b5906128e4565b60cb546040516335ea6a7560e01b81526001600160a01b03878116600483015260009216906335ea6a75906024016101806040518083038186803b1580156104af57600080fd5b505afa1580156104c3573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906104e791906126f7565b60e00151604051630ed1279f60e11b81523060048201529091506000906001600160a01b03831690631da24f3e9060240160206040518083038186803b15801561053057600080fd5b505afa158015610544573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061056891906127fb565b8354600185015491925060009161057f9089612a40565b6105899190612a20565b6040516370a0823160e01b815230600482015290915060009083906001600160a01b038616906370a082319060240160206040518083038186803b1580156105d057600080fd5b505afa1580156105e4573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061060891906127fb565b6106129084612a40565b61061c9190612a20565b90506106288882612a5f565b96505050505050505b9392505050565b600061064560cc83611e39565b92915050565b600061064560cc83611e5b565b60655460ff161561067b5760405162461bcd60e51b81526004016103b590612885565b6002609754141561069e5760405162461bcd60e51b81526004016103b590612976565b60026097556106ac82610638565b6107065760405162461bcd60e51b815260206004820152602560248201527f4465706f7369743a3a6465706f7369743a2074686973206973206e6f742061206044820152643a37b5b2b760d91b60648201526084016103b5565b600081116107565760405162461bcd60e51b815260206004820181905260248201527f4465706f7369743a3a6465706f7369743a20696e76616c696420616d6f756e7460448201526064016103b5565b61076b6001600160a01b038316333084611e67565b60cb546040516335ea6a7560e01b81526001600160a01b03848116600483015260009216906335ea6a75906024016101806040518083038186803b1580156107b257600080fd5b505afa1580156107c6573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906107ea91906126f7565b60e00151604051630ed1279f60e11b81523060048201529091506000906001600160a01b03831690631da24f3e9060240160206040518083038186803b15801561083357600080fd5b505afa158015610847573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061086b91906127fb565b60cb5460405163e8eda9df60e01b81526001600160a01b038781166004830152602482018790523060448301526000606483015292935091169063e8eda9df90608401600060405180830381600087803b1580156108c857600080fd5b505af11580156108dc573d6000803e3d6000fd5b5050604051630ed1279f60e11b8152306004820152600092506001600160a01b0385169150631da24f3e9060240160206040518083038186803b15801561092257600080fd5b505afa158015610936573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061095a91906127fb565b6001600160a01b038616600090815260ce602052604090209091506109826001820133611ec7565b50848160000160008282546109979190612a08565b909155505033600090815260038201602052604081208054909187918391906109c1908490612a08565b909155506109d190508484612a5f565b8160010160008282546109e49190612a08565b90915550506040518681526001600160a01b0388169033907f63d8d7d5e63e9840ec91a12a160d27b7cfab294f6ba070b7359692acfe6b03bf9060200160405180910390a3505060016097555050505050565b6033546001600160a01b03163314610a615760405162461bcd60e51b81526004016103b5906128af565b610a6a81610638565b610ac85760405162461bcd60e51b815260206004820152602960248201527f4465706f7369743a3a72656d6f7665546f6b656e3a2074686973206973206e6f6044820152683a1030903a37b5b2b760b91b60648201526084016103b5565b610ad360cc82611edc565b506040516001600160a01b038216907f4c910b69fe65a61f7531b9c5042b2329ca7179c77290aa7e2eb3afa3c8511fd390600090a250565b6001600160a01b038116600090815260ce602052604081208054829190610b3460018301611ef1565b9250925050915091565b6033546001600160a01b03163314610b685760405162461bcd60e51b81526004016103b5906128af565b610b726000611efb565b565b6033546001600160a01b03163314610b9e5760405162461bcd60e51b81526004016103b5906128af565b60c9546040516001600160a01b038084169216907f4ab5be82436d353e61ca18726e984e561f5c1cc7c6d38b29d2553c790434705a90600090a360c980546001600160a01b0319166001600160a01b0392909216919091179055565b6001600160a01b038216600090815260ce602052604081206106319060010183611e5b565b6000610c2b60cc611ef1565b905090565b6033546001600160a01b03163314610c5a5760405162461bcd60e51b81526004016103b5906128af565b60ca546040516001600160a01b038084169216907f9ee32924c063f6e43d6d525cb33e456e4c81879e8b46e925685714c3273f554990600090a360ca80546001600160a01b0319166001600160a01b0392909216919091179055565b6033546001600160a01b03163314610ce05760405162461bcd60e51b81526004016103b5906128af565b610ce981610638565b15610d455760405162461bcd60e51b815260206004820152602660248201527f4465706f7369743a3a616464546f6b656e3a20746f6b656e20616c726561647960448201526508185919195960d21b60648201526084016103b5565b60c9546040516319f3736160e01b81526001600160a01b038381166004830152909116906319f373619060240160206040518083038186803b158015610d8a57600080fd5b505afa158015610d9e573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610dc291906125eb565b610e2b5760405162461bcd60e51b815260206004820152603460248201527f4465706f7369743a3a616464546f6b656e3a206974206d7573742062652061206044820152733b30b634b2103a3932b0b9bab93c903a37b5b2b760611b60648201526084016103b5565b60cb546040516335ea6a7560e01b81526001600160a01b03838116600483015260009216906335ea6a75906024016101806040518083038186803b158015610e7257600080fd5b505afa158015610e86573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610eaa91906126f7565b60e001516001600160a01b03161415610f2b5760405162461bcd60e51b815260206004820152603760248201527f4465706f7369743a3a616464546f6b656e3a206974206d75737420626520612060448201527f76616c6964206c656e64696e67506f6f6c20746f6b656e00000000000000000060648201526084016103b5565b610f3660cc82611ec7565b5060cb5460405163095ea7b360e01b81526001600160a01b03918216600482015260001960248201529082169063095ea7b390604401602060405180830381600087803b158015610f8657600080fd5b505af1158015610f9a573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610fbe91906125eb565b5060ca5460405163095ea7b360e01b81526001600160a01b03918216600482015260001960248201529082169063095ea7b390604401602060405180830381600087803b15801561100e57600080fd5b505af1158015611022573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061104691906125eb565b506040516001600160a01b038216907f784c8f4dbf0ffedd6e72c76501c545a70f8b203b30a26ce542bf92ba87c248a490600090a250565b600054610100900460ff166110995760005460ff161561109d565b303b155b6111005760405162461bcd60e51b815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201526d191e481a5b9a5d1a585b1a5e995960921b60648201526084016103b5565b600054610100900460ff16158015611122576000805461ffff19166101011790555b6001600160a01b03851661118f5760405162461bcd60e51b815260206004820152602e60248201527f4465706f7369743a3a696e697469616c697a653a20696e76616c6964205f747260448201526d656173757279206164647265737360901b60648201526084016103b5565b6001600160a01b0383166111ff5760405162461bcd60e51b815260206004820152603160248201527f4465706f7369743a3a696e697469616c697a653a20696e76616c6964205f6c656044820152706e64696e67506f6f6c206164647265737360781b60648201526084016103b5565b611207611f4d565b61120f611f84565b611217611fbb565b60c980546001600160a01b038088166001600160a01b03199283161790925560ca805487841690831617905560cb80549286169290911691909117905581516000905b808210156114715761129d84838151811061128557634e487b7160e01b600052603260045260246000fd5b602002602001015160cc611ec790919063ffffffff16565b508382815181106112be57634e487b7160e01b600052603260045260246000fd5b602090810291909101015160cb5460405163095ea7b360e01b81526001600160a01b039182166004820152600019602482015291169063095ea7b390604401602060405180830381600087803b15801561131757600080fd5b505af115801561132b573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061134f91906125eb565b5083828151811061137057634e487b7160e01b600052603260045260246000fd5b602090810291909101015160ca5460405163095ea7b360e01b81526001600160a01b039182166004820152600019602482015291169063095ea7b390604401602060405180830381600087803b1580156113c957600080fd5b505af11580156113dd573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061140191906125eb565b5083828151811061142257634e487b7160e01b600052603260045260246000fd5b60200260200101516001600160a01b03167f784c8f4dbf0ffedd6e72c76501c545a70f8b203b30a26ce542bf92ba87c248a460405160405180910390a28161146981612aa2565b92505061125a565b50508015611485576000805461ff00191690555b5050505050565b60655460ff16156114af5760405162461bcd60e51b81526004016103b590612885565b600260975414156114d25760405162461bcd60e51b81526004016103b590612976565b60026097556001600160a01b03808316600090815260ce60209081526040808320938716835260038401909152902080548311156115225760405162461bcd60e51b81526004016103b5906128e4565b60cb546040516335ea6a7560e01b81526001600160a01b03868116600483015260009216906335ea6a75906024016101806040518083038186803b15801561156957600080fd5b505afa15801561157d573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906115a191906126f7565b60e00151604051630ed1279f60e11b81523060048201529091506000906001600160a01b03831690631da24f3e9060240160206040518083038186803b1580156115ea57600080fd5b505afa1580156115fe573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061162291906127fb565b835460018501549192506000916116399088612a40565b6116439190612a20565b6040516370a0823160e01b815230600482015290915060009083906001600160a01b038616906370a082319060240160206040518083038186803b15801561168a57600080fd5b505afa15801561169e573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906116c291906127fb565b6116cc9084612a40565b6116d69190612a20565b905060006116e48883612a5f565b60cb54604051631a4ca37b60e21b81529192506001600160a01b0316906369328dec90611719908c908590309060040161282f565b602060405180830381600087803b15801561173357600080fd5b505af1158015611747573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061176b91906127fb565b50604051630ed1279f60e11b81523060048201526000906001600160a01b03871690631da24f3e9060240160206040518083038186803b1580156117ae57600080fd5b505afa1580156117c2573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906117e691906127fb565b905060ca60009054906101000a90046001600160a01b03166001600160a01b0316630d1e9b4a8b848e6040518463ffffffff1660e01b815260040161182d9392919061282f565b600060405180830381600087803b15801561184757600080fd5b505af115801561185b573d6000803e3d6000fd5b50505050808561186b9190612a5f565b87600101600082825461187e9190612a5f565b9091555050604080518a8152602081018490526001600160a01b03808d1692908e16917f29bac1f9afd8b3833ccc04f651c41fc95c0dde3b19f65d1f2a334afa69e8166a910160405180910390a350506001609755505050505050505050565b6033546001600160a01b031633146119085760405162461bcd60e51b81526004016103b5906128af565b6001600160a01b03811661196d5760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b60648201526084016103b5565b61197681611efb565b50565b60655460ff161561199c5760405162461bcd60e51b81526004016103b590612885565b600260975414156119bf5760405162461bcd60e51b81526004016103b590612976565b60026097556001600160a01b038216600090815260ce60209081526040808320338452600381019092529091208054831115611a475760405162461bcd60e51b815260206004820152602160248201527f4465706f7369743a3a77697468647261773a20696e76616c696420616d6f756e6044820152601d60fa1b60648201526084016103b5565b8054831415611a5f57611a5d6001830133611edc565b505b60cb546040516335ea6a7560e01b81526001600160a01b03868116600483015260009216906335ea6a75906024016101806040518083038186803b158015611aa657600080fd5b505afa158015611aba573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611ade91906126f7565b60e00151604051630ed1279f60e11b81523060048201529091506000906001600160a01b03831690631da24f3e9060240160206040518083038186803b158015611b2757600080fd5b505afa158015611b3b573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611b5f91906127fb565b83546001850154919250600091611b769088612a40565b611b809190612a20565b6040516370a0823160e01b815230600482015290915060009083906001600160a01b038616906370a082319060240160206040518083038186803b158015611bc757600080fd5b505afa158015611bdb573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611bff91906127fb565b611c099084612a40565b611c139190612a20565b90506000611c218883612a5f565b60cb54604051631a4ca37b60e21b81529192506001600160a01b0316906369328dec90611c56908c908c90339060040161282f565b602060405180830381600087803b158015611c7057600080fd5b505af1158015611c84573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611ca891906127fb565b5060cb54604051631a4ca37b60e21b81526001600160a01b03909116906369328dec90611cdd908c908590309060040161282f565b602060405180830381600087803b158015611cf757600080fd5b505af1158015611d0b573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611d2f91906127fb565b5060ca5460405163068f4da560e11b81526001600160a01b0390911690630d1e9b4a90611d64908c908590339060040161282f565b600060405180830381600087803b158015611d7e57600080fd5b505af1158015611d92573d6000803e3d6000fd5b5050505087876000016000828254611daa9190612a5f565b9091555050855488908790600090611dc3908490612a5f565b9250508190555082866001016000828254611dde9190612a5f565b909155505060408051898152602081018390526001600160a01b038b169133917ff341246adaac6f497bc2a656f546ab9e182111d630394f0c57c710a59a2cb567910160405180910390a35050600160975550505050505050565b6001600160a01b03811660009081526001830160205260408120541515610631565b60006106318383611fea565b604080516001600160a01b0385811660248301528416604482015260648082018490528251808303909101815260849091019091526020810180516001600160e01b03166323b872dd60e01b179052611ec1908590612022565b50505050565b6000610631836001600160a01b0384166120f9565b6000610631836001600160a01b038416612148565b6000610645825490565b603380546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b600054610100900460ff16611f745760405162461bcd60e51b81526004016103b59061292b565b611f7c612265565b610b7261228c565b600054610100900460ff16611fab5760405162461bcd60e51b81526004016103b59061292b565b611fb3612265565b610b726122bc565b600054610100900460ff16611fe25760405162461bcd60e51b81526004016103b59061292b565b610b726122ef565b600082600001828154811061200f57634e487b7160e01b600052603260045260246000fd5b9060005260206000200154905092915050565b6000612077826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b031661231d9092919063ffffffff16565b8051909150156120f4578080602001905181019061209591906125eb565b6120f45760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b60648201526084016103b5565b505050565b600081815260018301602052604081205461214057508154600181810184556000848152602080822090930184905584548482528286019093526040902091909155610645565b506000610645565b6000818152600183016020526040812054801561225b57600061216c600183612a5f565b855490915060009061218090600190612a5f565b90508181146122015760008660000182815481106121ae57634e487b7160e01b600052603260045260246000fd5b90600052602060002001549050808760000184815481106121df57634e487b7160e01b600052603260045260246000fd5b6000918252602080832090910192909255918252600188019052604090208390555b855486908061222057634e487b7160e01b600052603160045260246000fd5b600190038181906000526020600020016000905590558560010160008681526020019081526020016000206000905560019350505050610645565b6000915050610645565b600054610100900460ff16610b725760405162461bcd60e51b81526004016103b59061292b565b600054610100900460ff166122b35760405162461bcd60e51b81526004016103b59061292b565b610b7233611efb565b600054610100900460ff166122e35760405162461bcd60e51b81526004016103b59061292b565b6065805460ff19169055565b600054610100900460ff166123165760405162461bcd60e51b81526004016103b59061292b565b6001609755565b606061232c8484600085612334565b949350505050565b6060824710156123955760405162461bcd60e51b815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f6044820152651c8818d85b1b60d21b60648201526084016103b5565b843b6123e35760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e747261637400000060448201526064016103b5565b600080866001600160a01b031685876040516123ff9190612813565b60006040518083038185875af1925050503d806000811461243c576040519150601f19603f3d011682016040523d82523d6000602084013e612441565b606091505b509150915061245182828661245c565b979650505050505050565b6060831561246b575081610631565b82511561247b5782518084602001fd5b8160405162461bcd60e51b81526004016103b59190612852565b80516124a081612ae9565b919050565b6000602082840312156124b6578081fd5b6040516020810181811067ffffffffffffffff821117156124d9576124d9612ad3565b6040529151825250919050565b80516fffffffffffffffffffffffffffffffff811681146124a057600080fd5b805164ffffffffff811681146124a057600080fd5b805160ff811681146124a057600080fd5b60006020828403121561253d578081fd5b813561063181612ae9565b6000806040838503121561255a578081fd5b823561256581612ae9565b9150602083013561257581612ae9565b809150509250929050565b600080600060608486031215612594578081fd5b833561259f81612ae9565b925060208401356125af81612ae9565b929592945050506040919091013590565b600080604083850312156125d2578182fd5b82356125dd81612ae9565b946020939093013593505050565b6000602082840312156125fc578081fd5b81518015158114610631578182fd5b60008060008060808587031215612620578081fd5b843561262b81612ae9565b935060208581013561263c81612ae9565b9350604086013561264c81612ae9565b9250606086013567ffffffffffffffff80821115612668578384fd5b818801915088601f83011261267b578384fd5b81358181111561268d5761268d612ad3565b8060051b915061269e8483016129d7565b8181528481019084860184860187018d10156126b8578788fd5b8795505b838610156126e657803594506126d185612ae9565b848352600195909501949186019186016126bc565b50989b979a50959850505050505050565b60006101808284031215612709578081fd5b6127116129ad565b61271b84846124a5565b8152612729602084016124e6565b602082015261273a604084016124e6565b604082015261274b606084016124e6565b606082015261275c608084016124e6565b608082015261276d60a084016124e6565b60a082015261277e60c08401612506565b60c082015261278f60e08401612495565b60e08201526101006127a2818501612495565b908201526101206127b4848201612495565b908201526101406127c6848201612495565b908201526101606127d884820161251b565b908201529392505050565b6000602082840312156127f4578081fd5b5035919050565b60006020828403121561280c578081fd5b5051919050565b60008251612825818460208701612a76565b9190910192915050565b6001600160a01b0393841681526020810192909252909116604082015260600190565b6020815260008251806020840152612871816040850160208701612a76565b601f01601f19169190910160400192915050565b60208082526010908201526f14185d5cd8589b194e881c185d5cd95960821b604082015260600190565b6020808252818101527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604082015260600190565b60208082526027908201527f4465706f7369743a3a646f6e617465496e7465726573743a20696e76616c696460408201526608185b5bdd5b9d60ca1b606082015260800190565b6020808252602b908201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960408201526a6e697469616c697a696e6760a81b606082015260800190565b6020808252601f908201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c00604082015260600190565b604051610180810167ffffffffffffffff811182821017156129d1576129d1612ad3565b60405290565b604051601f8201601f1916810167ffffffffffffffff81118282101715612a0057612a00612ad3565b604052919050565b60008219821115612a1b57612a1b612abd565b500190565b600082612a3b57634e487b7160e01b81526012600452602481fd5b500490565b6000816000190483118215151615612a5a57612a5a612abd565b500290565b600082821015612a7157612a71612abd565b500390565b60005b83811015612a91578181015183820152602001612a79565b83811115611ec15750506000910152565b6000600019821415612ab657612ab6612abd565b5060010190565b634e487b7160e01b600052601160045260246000fd5b634e487b7160e01b600052604160045260246000fd5b6001600160a01b038116811461197657600080fdfea264697066735822122013af2458f075989876465212728a9c1ab3e60b12298a194e960053965899493a64736f6c63430008040033
Deployed ByteCode
0x608060405234801561001057600080fd5b50600436106101585760003560e01c80637f51bb1f116100c3578063d48bfca71161007c578063d48bfca714610319578063e36d4f3e1461032c578063e6bfbfd81461033f578063f0367db514610352578063f2fde38b14610365578063f3fef3a31461037857600080fd5b80637f51bb1f146102b457806383912426146102c75780638da5cb5b146102da5780639a552a29146102eb578063a59a9973146102f3578063c89fc9a71461030657600080fd5b806347e7ef241161011557806347e7ef24146102555780635c975abb146102685780635fa7b5841461027357806361d027b3146102865780636d46a1db14610299578063715018a6146102ac57600080fd5b80630b9b1f9a1461015d5780630d8e6e2c1461017257806312cf28841461018857806319f373611461019b57806332b194b5146101be5780633ede2d67146101e9575b600080fd5b61017061016b36600461252c565b61038b565b005b60015b6040519081526020015b60405180910390f35b610175610196366004612580565b61041a565b6101ae6101a936600461252c565b610638565b604051901515815260200161017f565b6101d16101cc3660046127e3565b61064b565b6040516001600160a01b03909116815260200161017f565b6102406101f7366004612548565b6001600160a01b03918216600090815260ce6020908152604080832093909416825260039092018252829020825180840190935280548084526001909101549290910182905291565b6040805192835260208301919091520161017f565b6101706102633660046125c0565b610658565b60655460ff166101ae565b61017061028136600461252c565b610a37565b60c9546101d1906001600160a01b031681565b6102406102a736600461252c565b610b0b565b610170610b3e565b6101706102c236600461252c565b610b74565b6101d16102d53660046125c0565b610bfa565b6033546001600160a01b03166101d1565b610175610c1f565b60cb546101d1906001600160a01b031681565b61017061031436600461252c565b610c30565b61017061032736600461252c565b610cb6565b60ca546101d1906001600160a01b031681565b61017061034d36600461260b565b61107e565b610170610360366004612580565b61148c565b61017061037336600461252c565b6118de565b6101706103863660046125c0565b611979565b6033546001600160a01b031633146103be5760405162461bcd60e51b81526004016103b5906128af565b60405180910390fd5b60cb546040516001600160a01b038084169216907fb8852e851bdabda04c25661cfbfa7b09b3019206382f067a349af593e883214a90600090a360cb80546001600160a01b0319166001600160a01b0392909216919091179055565b6001600160a01b03808316600090815260ce60209081526040808320938716835260038401909152812080549192918411156104685760405162461bcd60e51b81526004016103b5906128e4565b60cb546040516335ea6a7560e01b81526001600160a01b03878116600483015260009216906335ea6a75906024016101806040518083038186803b1580156104af57600080fd5b505afa1580156104c3573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906104e791906126f7565b60e00151604051630ed1279f60e11b81523060048201529091506000906001600160a01b03831690631da24f3e9060240160206040518083038186803b15801561053057600080fd5b505afa158015610544573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061056891906127fb565b8354600185015491925060009161057f9089612a40565b6105899190612a20565b6040516370a0823160e01b815230600482015290915060009083906001600160a01b038616906370a082319060240160206040518083038186803b1580156105d057600080fd5b505afa1580156105e4573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061060891906127fb565b6106129084612a40565b61061c9190612a20565b90506106288882612a5f565b96505050505050505b9392505050565b600061064560cc83611e39565b92915050565b600061064560cc83611e5b565b60655460ff161561067b5760405162461bcd60e51b81526004016103b590612885565b6002609754141561069e5760405162461bcd60e51b81526004016103b590612976565b60026097556106ac82610638565b6107065760405162461bcd60e51b815260206004820152602560248201527f4465706f7369743a3a6465706f7369743a2074686973206973206e6f742061206044820152643a37b5b2b760d91b60648201526084016103b5565b600081116107565760405162461bcd60e51b815260206004820181905260248201527f4465706f7369743a3a6465706f7369743a20696e76616c696420616d6f756e7460448201526064016103b5565b61076b6001600160a01b038316333084611e67565b60cb546040516335ea6a7560e01b81526001600160a01b03848116600483015260009216906335ea6a75906024016101806040518083038186803b1580156107b257600080fd5b505afa1580156107c6573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906107ea91906126f7565b60e00151604051630ed1279f60e11b81523060048201529091506000906001600160a01b03831690631da24f3e9060240160206040518083038186803b15801561083357600080fd5b505afa158015610847573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061086b91906127fb565b60cb5460405163e8eda9df60e01b81526001600160a01b038781166004830152602482018790523060448301526000606483015292935091169063e8eda9df90608401600060405180830381600087803b1580156108c857600080fd5b505af11580156108dc573d6000803e3d6000fd5b5050604051630ed1279f60e11b8152306004820152600092506001600160a01b0385169150631da24f3e9060240160206040518083038186803b15801561092257600080fd5b505afa158015610936573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061095a91906127fb565b6001600160a01b038616600090815260ce602052604090209091506109826001820133611ec7565b50848160000160008282546109979190612a08565b909155505033600090815260038201602052604081208054909187918391906109c1908490612a08565b909155506109d190508484612a5f565b8160010160008282546109e49190612a08565b90915550506040518681526001600160a01b0388169033907f63d8d7d5e63e9840ec91a12a160d27b7cfab294f6ba070b7359692acfe6b03bf9060200160405180910390a3505060016097555050505050565b6033546001600160a01b03163314610a615760405162461bcd60e51b81526004016103b5906128af565b610a6a81610638565b610ac85760405162461bcd60e51b815260206004820152602960248201527f4465706f7369743a3a72656d6f7665546f6b656e3a2074686973206973206e6f6044820152683a1030903a37b5b2b760b91b60648201526084016103b5565b610ad360cc82611edc565b506040516001600160a01b038216907f4c910b69fe65a61f7531b9c5042b2329ca7179c77290aa7e2eb3afa3c8511fd390600090a250565b6001600160a01b038116600090815260ce602052604081208054829190610b3460018301611ef1565b9250925050915091565b6033546001600160a01b03163314610b685760405162461bcd60e51b81526004016103b5906128af565b610b726000611efb565b565b6033546001600160a01b03163314610b9e5760405162461bcd60e51b81526004016103b5906128af565b60c9546040516001600160a01b038084169216907f4ab5be82436d353e61ca18726e984e561f5c1cc7c6d38b29d2553c790434705a90600090a360c980546001600160a01b0319166001600160a01b0392909216919091179055565b6001600160a01b038216600090815260ce602052604081206106319060010183611e5b565b6000610c2b60cc611ef1565b905090565b6033546001600160a01b03163314610c5a5760405162461bcd60e51b81526004016103b5906128af565b60ca546040516001600160a01b038084169216907f9ee32924c063f6e43d6d525cb33e456e4c81879e8b46e925685714c3273f554990600090a360ca80546001600160a01b0319166001600160a01b0392909216919091179055565b6033546001600160a01b03163314610ce05760405162461bcd60e51b81526004016103b5906128af565b610ce981610638565b15610d455760405162461bcd60e51b815260206004820152602660248201527f4465706f7369743a3a616464546f6b656e3a20746f6b656e20616c726561647960448201526508185919195960d21b60648201526084016103b5565b60c9546040516319f3736160e01b81526001600160a01b038381166004830152909116906319f373619060240160206040518083038186803b158015610d8a57600080fd5b505afa158015610d9e573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610dc291906125eb565b610e2b5760405162461bcd60e51b815260206004820152603460248201527f4465706f7369743a3a616464546f6b656e3a206974206d7573742062652061206044820152733b30b634b2103a3932b0b9bab93c903a37b5b2b760611b60648201526084016103b5565b60cb546040516335ea6a7560e01b81526001600160a01b03838116600483015260009216906335ea6a75906024016101806040518083038186803b158015610e7257600080fd5b505afa158015610e86573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610eaa91906126f7565b60e001516001600160a01b03161415610f2b5760405162461bcd60e51b815260206004820152603760248201527f4465706f7369743a3a616464546f6b656e3a206974206d75737420626520612060448201527f76616c6964206c656e64696e67506f6f6c20746f6b656e00000000000000000060648201526084016103b5565b610f3660cc82611ec7565b5060cb5460405163095ea7b360e01b81526001600160a01b03918216600482015260001960248201529082169063095ea7b390604401602060405180830381600087803b158015610f8657600080fd5b505af1158015610f9a573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610fbe91906125eb565b5060ca5460405163095ea7b360e01b81526001600160a01b03918216600482015260001960248201529082169063095ea7b390604401602060405180830381600087803b15801561100e57600080fd5b505af1158015611022573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061104691906125eb565b506040516001600160a01b038216907f784c8f4dbf0ffedd6e72c76501c545a70f8b203b30a26ce542bf92ba87c248a490600090a250565b600054610100900460ff166110995760005460ff161561109d565b303b155b6111005760405162461bcd60e51b815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201526d191e481a5b9a5d1a585b1a5e995960921b60648201526084016103b5565b600054610100900460ff16158015611122576000805461ffff19166101011790555b6001600160a01b03851661118f5760405162461bcd60e51b815260206004820152602e60248201527f4465706f7369743a3a696e697469616c697a653a20696e76616c6964205f747260448201526d656173757279206164647265737360901b60648201526084016103b5565b6001600160a01b0383166111ff5760405162461bcd60e51b815260206004820152603160248201527f4465706f7369743a3a696e697469616c697a653a20696e76616c6964205f6c656044820152706e64696e67506f6f6c206164647265737360781b60648201526084016103b5565b611207611f4d565b61120f611f84565b611217611fbb565b60c980546001600160a01b038088166001600160a01b03199283161790925560ca805487841690831617905560cb80549286169290911691909117905581516000905b808210156114715761129d84838151811061128557634e487b7160e01b600052603260045260246000fd5b602002602001015160cc611ec790919063ffffffff16565b508382815181106112be57634e487b7160e01b600052603260045260246000fd5b602090810291909101015160cb5460405163095ea7b360e01b81526001600160a01b039182166004820152600019602482015291169063095ea7b390604401602060405180830381600087803b15801561131757600080fd5b505af115801561132b573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061134f91906125eb565b5083828151811061137057634e487b7160e01b600052603260045260246000fd5b602090810291909101015160ca5460405163095ea7b360e01b81526001600160a01b039182166004820152600019602482015291169063095ea7b390604401602060405180830381600087803b1580156113c957600080fd5b505af11580156113dd573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061140191906125eb565b5083828151811061142257634e487b7160e01b600052603260045260246000fd5b60200260200101516001600160a01b03167f784c8f4dbf0ffedd6e72c76501c545a70f8b203b30a26ce542bf92ba87c248a460405160405180910390a28161146981612aa2565b92505061125a565b50508015611485576000805461ff00191690555b5050505050565b60655460ff16156114af5760405162461bcd60e51b81526004016103b590612885565b600260975414156114d25760405162461bcd60e51b81526004016103b590612976565b60026097556001600160a01b03808316600090815260ce60209081526040808320938716835260038401909152902080548311156115225760405162461bcd60e51b81526004016103b5906128e4565b60cb546040516335ea6a7560e01b81526001600160a01b03868116600483015260009216906335ea6a75906024016101806040518083038186803b15801561156957600080fd5b505afa15801561157d573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906115a191906126f7565b60e00151604051630ed1279f60e11b81523060048201529091506000906001600160a01b03831690631da24f3e9060240160206040518083038186803b1580156115ea57600080fd5b505afa1580156115fe573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061162291906127fb565b835460018501549192506000916116399088612a40565b6116439190612a20565b6040516370a0823160e01b815230600482015290915060009083906001600160a01b038616906370a082319060240160206040518083038186803b15801561168a57600080fd5b505afa15801561169e573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906116c291906127fb565b6116cc9084612a40565b6116d69190612a20565b905060006116e48883612a5f565b60cb54604051631a4ca37b60e21b81529192506001600160a01b0316906369328dec90611719908c908590309060040161282f565b602060405180830381600087803b15801561173357600080fd5b505af1158015611747573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061176b91906127fb565b50604051630ed1279f60e11b81523060048201526000906001600160a01b03871690631da24f3e9060240160206040518083038186803b1580156117ae57600080fd5b505afa1580156117c2573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906117e691906127fb565b905060ca60009054906101000a90046001600160a01b03166001600160a01b0316630d1e9b4a8b848e6040518463ffffffff1660e01b815260040161182d9392919061282f565b600060405180830381600087803b15801561184757600080fd5b505af115801561185b573d6000803e3d6000fd5b50505050808561186b9190612a5f565b87600101600082825461187e9190612a5f565b9091555050604080518a8152602081018490526001600160a01b03808d1692908e16917f29bac1f9afd8b3833ccc04f651c41fc95c0dde3b19f65d1f2a334afa69e8166a910160405180910390a350506001609755505050505050505050565b6033546001600160a01b031633146119085760405162461bcd60e51b81526004016103b5906128af565b6001600160a01b03811661196d5760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b60648201526084016103b5565b61197681611efb565b50565b60655460ff161561199c5760405162461bcd60e51b81526004016103b590612885565b600260975414156119bf5760405162461bcd60e51b81526004016103b590612976565b60026097556001600160a01b038216600090815260ce60209081526040808320338452600381019092529091208054831115611a475760405162461bcd60e51b815260206004820152602160248201527f4465706f7369743a3a77697468647261773a20696e76616c696420616d6f756e6044820152601d60fa1b60648201526084016103b5565b8054831415611a5f57611a5d6001830133611edc565b505b60cb546040516335ea6a7560e01b81526001600160a01b03868116600483015260009216906335ea6a75906024016101806040518083038186803b158015611aa657600080fd5b505afa158015611aba573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611ade91906126f7565b60e00151604051630ed1279f60e11b81523060048201529091506000906001600160a01b03831690631da24f3e9060240160206040518083038186803b158015611b2757600080fd5b505afa158015611b3b573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611b5f91906127fb565b83546001850154919250600091611b769088612a40565b611b809190612a20565b6040516370a0823160e01b815230600482015290915060009083906001600160a01b038616906370a082319060240160206040518083038186803b158015611bc757600080fd5b505afa158015611bdb573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611bff91906127fb565b611c099084612a40565b611c139190612a20565b90506000611c218883612a5f565b60cb54604051631a4ca37b60e21b81529192506001600160a01b0316906369328dec90611c56908c908c90339060040161282f565b602060405180830381600087803b158015611c7057600080fd5b505af1158015611c84573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611ca891906127fb565b5060cb54604051631a4ca37b60e21b81526001600160a01b03909116906369328dec90611cdd908c908590309060040161282f565b602060405180830381600087803b158015611cf757600080fd5b505af1158015611d0b573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611d2f91906127fb565b5060ca5460405163068f4da560e11b81526001600160a01b0390911690630d1e9b4a90611d64908c908590339060040161282f565b600060405180830381600087803b158015611d7e57600080fd5b505af1158015611d92573d6000803e3d6000fd5b5050505087876000016000828254611daa9190612a5f565b9091555050855488908790600090611dc3908490612a5f565b9250508190555082866001016000828254611dde9190612a5f565b909155505060408051898152602081018390526001600160a01b038b169133917ff341246adaac6f497bc2a656f546ab9e182111d630394f0c57c710a59a2cb567910160405180910390a35050600160975550505050505050565b6001600160a01b03811660009081526001830160205260408120541515610631565b60006106318383611fea565b604080516001600160a01b0385811660248301528416604482015260648082018490528251808303909101815260849091019091526020810180516001600160e01b03166323b872dd60e01b179052611ec1908590612022565b50505050565b6000610631836001600160a01b0384166120f9565b6000610631836001600160a01b038416612148565b6000610645825490565b603380546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b600054610100900460ff16611f745760405162461bcd60e51b81526004016103b59061292b565b611f7c612265565b610b7261228c565b600054610100900460ff16611fab5760405162461bcd60e51b81526004016103b59061292b565b611fb3612265565b610b726122bc565b600054610100900460ff16611fe25760405162461bcd60e51b81526004016103b59061292b565b610b726122ef565b600082600001828154811061200f57634e487b7160e01b600052603260045260246000fd5b9060005260206000200154905092915050565b6000612077826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b031661231d9092919063ffffffff16565b8051909150156120f4578080602001905181019061209591906125eb565b6120f45760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b60648201526084016103b5565b505050565b600081815260018301602052604081205461214057508154600181810184556000848152602080822090930184905584548482528286019093526040902091909155610645565b506000610645565b6000818152600183016020526040812054801561225b57600061216c600183612a5f565b855490915060009061218090600190612a5f565b90508181146122015760008660000182815481106121ae57634e487b7160e01b600052603260045260246000fd5b90600052602060002001549050808760000184815481106121df57634e487b7160e01b600052603260045260246000fd5b6000918252602080832090910192909255918252600188019052604090208390555b855486908061222057634e487b7160e01b600052603160045260246000fd5b600190038181906000526020600020016000905590558560010160008681526020019081526020016000206000905560019350505050610645565b6000915050610645565b600054610100900460ff16610b725760405162461bcd60e51b81526004016103b59061292b565b600054610100900460ff166122b35760405162461bcd60e51b81526004016103b59061292b565b610b7233611efb565b600054610100900460ff166122e35760405162461bcd60e51b81526004016103b59061292b565b6065805460ff19169055565b600054610100900460ff166123165760405162461bcd60e51b81526004016103b59061292b565b6001609755565b606061232c8484600085612334565b949350505050565b6060824710156123955760405162461bcd60e51b815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f6044820152651c8818d85b1b60d21b60648201526084016103b5565b843b6123e35760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e747261637400000060448201526064016103b5565b600080866001600160a01b031685876040516123ff9190612813565b60006040518083038185875af1925050503d806000811461243c576040519150601f19603f3d011682016040523d82523d6000602084013e612441565b606091505b509150915061245182828661245c565b979650505050505050565b6060831561246b575081610631565b82511561247b5782518084602001fd5b8160405162461bcd60e51b81526004016103b59190612852565b80516124a081612ae9565b919050565b6000602082840312156124b6578081fd5b6040516020810181811067ffffffffffffffff821117156124d9576124d9612ad3565b6040529151825250919050565b80516fffffffffffffffffffffffffffffffff811681146124a057600080fd5b805164ffffffffff811681146124a057600080fd5b805160ff811681146124a057600080fd5b60006020828403121561253d578081fd5b813561063181612ae9565b6000806040838503121561255a578081fd5b823561256581612ae9565b9150602083013561257581612ae9565b809150509250929050565b600080600060608486031215612594578081fd5b833561259f81612ae9565b925060208401356125af81612ae9565b929592945050506040919091013590565b600080604083850312156125d2578182fd5b82356125dd81612ae9565b946020939093013593505050565b6000602082840312156125fc578081fd5b81518015158114610631578182fd5b60008060008060808587031215612620578081fd5b843561262b81612ae9565b935060208581013561263c81612ae9565b9350604086013561264c81612ae9565b9250606086013567ffffffffffffffff80821115612668578384fd5b818801915088601f83011261267b578384fd5b81358181111561268d5761268d612ad3565b8060051b915061269e8483016129d7565b8181528481019084860184860187018d10156126b8578788fd5b8795505b838610156126e657803594506126d185612ae9565b848352600195909501949186019186016126bc565b50989b979a50959850505050505050565b60006101808284031215612709578081fd5b6127116129ad565b61271b84846124a5565b8152612729602084016124e6565b602082015261273a604084016124e6565b604082015261274b606084016124e6565b606082015261275c608084016124e6565b608082015261276d60a084016124e6565b60a082015261277e60c08401612506565b60c082015261278f60e08401612495565b60e08201526101006127a2818501612495565b908201526101206127b4848201612495565b908201526101406127c6848201612495565b908201526101606127d884820161251b565b908201529392505050565b6000602082840312156127f4578081fd5b5035919050565b60006020828403121561280c578081fd5b5051919050565b60008251612825818460208701612a76565b9190910192915050565b6001600160a01b0393841681526020810192909252909116604082015260600190565b6020815260008251806020840152612871816040850160208701612a76565b601f01601f19169190910160400192915050565b60208082526010908201526f14185d5cd8589b194e881c185d5cd95960821b604082015260600190565b6020808252818101527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604082015260600190565b60208082526027908201527f4465706f7369743a3a646f6e617465496e7465726573743a20696e76616c696460408201526608185b5bdd5b9d60ca1b606082015260800190565b6020808252602b908201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960408201526a6e697469616c697a696e6760a81b606082015260800190565b6020808252601f908201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c00604082015260600190565b604051610180810167ffffffffffffffff811182821017156129d1576129d1612ad3565b60405290565b604051601f8201601f1916810167ffffffffffffffff81118282101715612a0057612a00612ad3565b604052919050565b60008219821115612a1b57612a1b612abd565b500190565b600082612a3b57634e487b7160e01b81526012600452602481fd5b500490565b6000816000190483118215151615612a5a57612a5a612abd565b500290565b600082821015612a7157612a71612abd565b500390565b60005b83811015612a91578181015183820152602001612a79565b83811115611ec15750506000910152565b6000600019821415612ab657612ab6612abd565b5060010190565b634e487b7160e01b600052601160045260246000fd5b634e487b7160e01b600052604160045260246000fd5b6001600160a01b038116811461197657600080fdfea264697066735822122013af2458f075989876465212728a9c1ab3e60b12298a194e960053965899493a64736f6c63430008040033