Address Details
contract
0xD97180Ed09Fb8C4424E3Dc83EadEf85b1C8C199D
- Contract Name
- CommunityAdminImplementation
- Creator
- 0xa34737ā43edab at 0xd0218cā3c0880
- Balance
- 0 CELO ( )
- Tokens
-
Fetching tokens...
- Transactions
- 0 Transactions
- Transfers
- 0 Transfers
- Gas Used
- Fetching gas used...
- Last Balance Update
- 16363205
This contract has been verified via Sourcify.
View contract in Sourcify repository
- Contract name:
- CommunityAdminImplementation
- Optimization enabled
- true
- Compiler version
- v0.8.4+commit.c7e474f2
- Optimization runs
- 200
- EVM Version
- istanbul
- Verified at
- 2023-01-25T23:51:12.826921Z
contracts/community/CommunityAdminImplementation.sol
// SPDX-License-Identifier: Apache-2.0 pragma solidity 0.8.4; import "@openzeppelin/contracts-upgradeable/token/ERC20/IERC20Upgradeable.sol"; import "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol"; import "@openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.sol"; import "@openzeppelin/contracts-upgradeable/security/ReentrancyGuardUpgradeable.sol"; import "@openzeppelin/contracts-upgradeable/token/ERC20/utils/SafeERC20Upgradeable.sol"; import "@openzeppelin/contracts/utils/structs/EnumerableSet.sol"; import "./interfaces/ICommunity.sol"; import "./interfaces/IPreviousCommunity.sol"; import "./interfaces/CommunityAdminStorageV1.sol"; import "../governor/impactMarketCouncil/interfaces/IImpactMarketCouncil.sol"; import "./interfaces/CommunityAdminStorageV3.sol"; /** * @notice Welcome to CommunityAdmin, the main contract. This is an * administrative (for now) contract where the admins have control * over the list of communities. Being only able to add and * remove communities */ contract CommunityAdminImplementation is Initializable, OwnableUpgradeable, ReentrancyGuardUpgradeable, CommunityAdminStorageV3 { using SafeERC20Upgradeable for IERC20Upgradeable; using EnumerableSet for EnumerableSet.AddressSet; uint256 private constant DEFAULT_AMOUNT = 5e16; uint256 private constant MIN_CLAIM_AMOUNT_RATIO_PRECISION = 100; /** * @notice Triggered when a community has been added * * @param communityAddress Address of the community that has been added * @param managers Addresses of the initial managers * @param originalClaimAmount Value of the originalClaimAmount * @param maxTotalClaim Value of the maxTotalClaim * @param decreaseStep Value of the decreaseStep * @param baseInterval Value of the baseInterval * @param incrementInterval Value of the incrementInterval * @param minTranche Value of the minTranche * @param maxTranche Value of the maxTranche * * For further information regarding each parameter, see * *Community* smart contract initialize method. */ event CommunityAdded( address indexed communityAddress, address[] managers, uint256 originalClaimAmount, uint256 maxTotalClaim, uint256 decreaseStep, uint256 baseInterval, uint256 incrementInterval, uint256 minTranche, uint256 maxTranche ); /** * @notice Triggered when a community has been removed * * @param communityAddress Address of the community that has been removed */ event CommunityRemoved(address indexed communityAddress); /** * @notice Triggered when a community has been migrated * * @param managers Addresses of the new community's initial managers * @param communityAddress New community address * @param previousCommunityAddress Old community address */ event CommunityMigrated( address[] managers, address indexed communityAddress, address indexed previousCommunityAddress ); /** * @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 impactMarket Council has been updated * * @param oldImpactMarketCouncil Old impactMarket Council address * @param newImpactMarketCouncil New impactMarket Council address */ event ImpactMarketCouncilUpdated( address indexed oldImpactMarketCouncil, address indexed newImpactMarketCouncil ); /** * @notice Triggered when the ambassadors has been updated * * @param oldAmbassadors Old Ambassador address * @param newAmbassadors New Ambassador address */ event AmbassadorsUpdated(address indexed oldAmbassadors, address indexed newAmbassadors); /** * @notice Triggered when the communityMiddleProxy address has been updated * * @param oldCommunityMiddleProxy Old communityMiddleProxy address * @param newCommunityMiddleProxy New communityMiddleProxy address */ event CommunityMiddleProxyUpdated( address oldCommunityMiddleProxy, address newCommunityMiddleProxy ); /** * @notice Triggered when the communityImplementation address has been updated * * @param oldCommunityImplementation Old communityImplementation address * @param newCommunityImplementation New communityImplementation address */ event CommunityImplementationUpdated( address indexed oldCommunityImplementation, address indexed newCommunityImplementation ); /** * @notice Triggered when a community has been funded * * @param community Address of the community * @param amount Amount of the funding */ event CommunityFunded(address indexed community, uint256 amount); /** * @notice Triggered when an amount of an ERC20 has been transferred from this contract to an address * * @param token ERC20 token address * @param to Address of the receiver * @param amount Amount of the transaction */ event TransferERC20(address indexed token, address indexed to, uint256 amount); /** * @notice Enforces sender to be a valid community */ modifier onlyCommunities() { require(communities[msg.sender] == CommunityState.Valid, "CommunityAdmin: NOT_COMMUNITY"); _; } /** * @notice Enforces sender to be a valid community */ modifier onlyOwnerOrImpactMarketCouncil() { require( msg.sender == owner() || msg.sender == address(impactMarketCouncil), "CommunityAdmin: Not Owner Or ImpactMarketCouncil" ); _; } /** * @notice Used to initialize a new CommunityAdmin contract * * @param _communityImplementation Address of the Community implementation * used for deploying new communities * @param _cUSD Address of the cUSD token */ function initialize(ICommunity _communityImplementation, IERC20 _cUSD) external initializer { __Ownable_init(); __ReentrancyGuard_init(); communityImplementation = _communityImplementation; cUSD = _cUSD; communityProxyAdmin = new ProxyAdmin(); } /** * @notice Returns the current implementation version */ function getVersion() external pure override returns (uint256) { return 3; } /** * @notice Returns the address of a community from communityList * * @param _index index of the community * @return address of the community */ function communityListAt(uint256 _index) external view override returns (address) { return communityList.at(_index); } /** * @notice Returns the number of communities * * @return uint256 number of communities */ function communityListLength() external view override returns (uint256) { return communityList.length(); } /** * @notice Returns the MIN_CLAIM_AMOUNT_RATIO_PRECISION * * @return uint256 number of communities */ function minClaimAmountRatioPrecision() external pure override returns (uint256) { return MIN_CLAIM_AMOUNT_RATIO_PRECISION; } /** * @notice Returns if an address is the ambassador or entity of the community * * @return bool true if the address is an ambassador or entity of the community */ function isAmbassadorOrEntityOfCommunity(address _community, address _ambassadorOrEntity) external view override returns (bool) { return ambassadors.isAmbassadorOf(_ambassadorOrEntity, _community) || ambassadors.isEntityOf(_ambassadorOrEntity, _community); } /** * @notice Updates the address of the treasury * * @param _newTreasury address of the new treasury contract */ function updateTreasury(ITreasury _newTreasury) external override onlyOwner { emit TreasuryUpdated(address(treasury), address(_newTreasury)); treasury = _newTreasury; } /** * @notice Updates the address of the the communityImplementation * * @param _newCommunityImplementation address of the new communityImplementation contract */ function updateCommunityImplementation(ICommunity _newCommunityImplementation) external override onlyOwner { emit CommunityImplementationUpdated( address(communityImplementation), address(_newCommunityImplementation) ); communityImplementation = _newCommunityImplementation; } /** Updates the address of the backend wallet * * @param _newAuthorizedWalletAddress address of the new backend wallet */ function updateAuthorizedWalletAddress(address _newAuthorizedWalletAddress) external override onlyOwnerOrImpactMarketCouncil { authorizedWalletAddress = _newAuthorizedWalletAddress; } /** Updates the value of the minClaimAmountRatio * * @param _newMinClaimAmountRatio value of the minClaimAmountRatio * * !!! be aware that this value will be divided by MIN_CLAIM_AMOUNT_RATIO_PRECISION */ function updateMinClaimAmountRatio(uint256 _newMinClaimAmountRatio) external override onlyOwnerOrImpactMarketCouncil { require( _newMinClaimAmountRatio >= MIN_CLAIM_AMOUNT_RATIO_PRECISION, "CommunityAdmin::updateMinClaimAmountRatio: Invalid minClaimAmountRatio" ); minClaimAmountRatio = _newMinClaimAmountRatio; } /** Updates the value of the treasurySafetyPercentage * * @param _newTreasurySafetyPercentage value of the treasurySafetyPercentage * */ function updateTreasurySafetyPercentage(uint256 _newTreasurySafetyPercentage) external override onlyOwnerOrImpactMarketCouncil { require(_newTreasurySafetyPercentage > 0 && _newTreasurySafetyPercentage < 101, 'CommunityAdmin::updateTreasurySafetyPercentage: Invalid treasurySafetyPercentage'); treasurySafetyPercentage = _newTreasurySafetyPercentage; } /** Updates the value of the treasuryMinBalance * * @param _newTreasuryMinBalance value of the treasuryMinBalance * */ function updateTreasuryMinBalance(uint256 _newTreasuryMinBalance) external override onlyOwnerOrImpactMarketCouncil { treasuryMinBalance = _newTreasuryMinBalance; } /** * @notice Set an existing ambassador to an existing community * * @param _ambassador address of the ambassador * @param _communityAddress address of the community contract */ function setCommunityToAmbassador(address _ambassador, ICommunity _communityAddress) external override onlyOwnerOrImpactMarketCouncil { ambassadors.setCommunityToAmbassador(_ambassador, address(_communityAddress)); } /** * @notice Adds a new community * * @param _tokenAddress address of the token used by the community * @param _managers addresses of the community managers * @param _ambassador address of the ambassador * @param _originalClaimAmount maximum base amount to be claim by the beneficiary * @param _maxTotalClaim limit that a beneficiary can claim at in total * @param _decreaseStep value decreased from maxTotalClaim for every beneficiary added * @param _baseInterval base interval to start claiming * @param _incrementInterval increment interval used in each claim * @param _minTranche minimum amount that the community will receive when requesting funds * @param _maxTranche maximum amount that the community will receive when requesting funds * @param _maxBeneficiaries maximum number of valid beneficiaries */ function addCommunity( address _tokenAddress, address[] memory _managers, address _ambassador, uint256 _originalClaimAmount, uint256 _maxTotalClaim, uint256 _decreaseStep, uint256 _baseInterval, uint256 _incrementInterval, uint256 _minTranche, uint256 _maxTranche, uint256 _maxBeneficiaries ) external override onlyOwnerOrImpactMarketCouncil { require( _managers.length > 0, "CommunityAdmin::addCommunity: Community should have at least one manager" ); address _communityAddress = deployCommunity( _tokenAddress, _managers, _originalClaimAmount, _maxTotalClaim, _decreaseStep, _baseInterval, _incrementInterval, _minTranche, _maxTranche, _maxBeneficiaries, ICommunity(address(0)) ); require(_communityAddress != address(0), "CommunityAdmin::addCommunity: NOT_VALID"); communities[_communityAddress] = CommunityState.Valid; communityList.add(_communityAddress); ambassadors.setCommunityToAmbassador(_ambassador, address(_communityAddress)); emit CommunityAdded( _communityAddress, _managers, _originalClaimAmount, _maxTotalClaim, _decreaseStep, _baseInterval, _incrementInterval, _minTranche, _maxTranche ); transferToCommunity(ICommunity(_communityAddress), _minTranche); if (cUSD.balanceOf(address(treasury)) >= DEFAULT_AMOUNT) { treasury.transfer(cUSD, address(_managers[0]), DEFAULT_AMOUNT); } } /** * @notice Migrates a community by deploying a new contract. * * @param _managers address of the community managers * @param _previousCommunity address of the community to be migrated */ function migrateCommunity(address[] memory _managers, ICommunity _previousCommunity) external override onlyOwnerOrImpactMarketCouncil nonReentrant { require( communities[address(_previousCommunity)] != CommunityState.Migrated, "CommunityAdmin::migrateCommunity: this community has been migrated" ); communities[address(_previousCommunity)] = CommunityState.Migrated; IERC20 _previousCommunityToken = (_previousCommunity.getVersion() == 1) ? _previousCommunity.cUSD() : _previousCommunity.token(); uint256 _previousOriginalClaimAmount = (_previousCommunity.getVersion() >= 3) ? _previousCommunity.originalClaimAmount() : IPreviousCommunity(address(_previousCommunity)).claimAmount(); address newCommunityAddress = deployCommunity( address(_previousCommunityToken), _managers, _previousOriginalClaimAmount, _previousCommunity.getInitialMaxClaim(), _previousCommunity.decreaseStep(), _previousCommunity.baseInterval(), _previousCommunity.incrementInterval(), _previousCommunity.minTranche(), _previousCommunity.maxTranche(), _previousCommunity.getVersion() > 1 ? _previousCommunity.maxBeneficiaries() : 0, _previousCommunity ); require(newCommunityAddress != address(0), "CommunityAdmin::migrateCommunity: NOT_VALID"); uint256 balance = _previousCommunityToken.balanceOf(address(_previousCommunity)); _previousCommunity.transfer(_previousCommunityToken, newCommunityAddress, balance); communities[newCommunityAddress] = CommunityState.Valid; communityList.add(newCommunityAddress); emit CommunityMigrated(_managers, newCommunityAddress, address(_previousCommunity)); } /** * @notice Removes an existing community. All community funds are transferred to the treasury * * @param _community address of the community */ function removeCommunity(ICommunity _community) external override onlyOwnerOrImpactMarketCouncil nonReentrant { require( communities[address(_community)] == CommunityState.Valid, "CommunityAdmin::removeCommunity: this isn't a valid community" ); communities[address(_community)] = CommunityState.Removed; ambassadors.removeCommunity(address(_community)); IERC20 _token = (_community.getVersion() == 1) ? _community.cUSD() : _community.token(); _community.transfer(_token, address(treasury), _token.balanceOf(address(_community))); emit CommunityRemoved(address(_community)); } /** * @dev Funds an existing community if it hasn't enough funds */ function fundCommunity() external override onlyCommunities { ICommunity _community = ICommunity(msg.sender); IERC20 _token = (_community.getVersion() == 1) ? _community.cUSD() : _community.token(); uint256 _balance = _token.balanceOf(msg.sender); uint256 _amount = calculateCommunityTrancheAmount(ICommunity(msg.sender)); require(_amount > 0, "CommunityAdmin::fundCommunity: this community cannot request now"); transferToCommunity(_community, _amount); } /** * @notice Transfers an amount of an ERC20 from this contract to an address * * @param _token address of the ERC20 token * @param _to address of the receiver * @param _amount amount of the transaction */ function transfer( IERC20 _token, address _to, uint256 _amount ) external override onlyOwner nonReentrant { IERC20Upgradeable(address(_token)).safeTransfer(_to, _amount); emit TransferERC20(address(_token), _to, _amount); } /** * @notice Transfers an amount of an ERC20 from community to an address * * @param _community address of the community * @param _token address of the ERC20 token * @param _to address of the receiver * @param _amount amount of the transaction */ function transferFromCommunity( ICommunity _community, IERC20 _token, address _to, uint256 _amount ) external override onlyOwner nonReentrant { _community.transfer(_token, _to, _amount); } /** @notice Updates the beneficiary params of a community * * @param _community address of the community * @param _originalClaimAmount maximum base amount to be claim by the beneficiary * @param _maxTotalClaim limit that a beneficiary can claim in total * @param _decreaseStep value decreased from maxTotalClaim each time a is beneficiary added * @param _baseInterval base interval to start claiming * @param _incrementInterval increment interval used in each claim * @param _maxBeneficiaries maximum number of beneficiaries */ function updateBeneficiaryParams( ICommunity _community, uint256 _originalClaimAmount, uint256 _maxTotalClaim, uint256 _decreaseStep, uint256 _baseInterval, uint256 _incrementInterval, uint256 _maxBeneficiaries ) external override onlyOwnerOrImpactMarketCouncil { _community.updateBeneficiaryParams( _originalClaimAmount, _maxTotalClaim, _decreaseStep, _baseInterval, _incrementInterval ); _community.updateMaxBeneficiaries(_maxBeneficiaries); } /** @notice Updates params of a community * * @param _community address of the community * @param _minTranche minimum amount that the community will receive when requesting funds * @param _maxTranche maximum amount that the community will receive when requesting funds */ function updateCommunityParams( ICommunity _community, uint256 _minTranche, uint256 _maxTranche ) external override onlyOwnerOrImpactMarketCouncil { _community.updateCommunityParams(_minTranche, _maxTranche); } /** @notice Updates token address of a community * * @param _community address of the community * @param _newToken new token address * @param _exchangePath path used by uniswap to exchange the current tokens to the new tokens */ function updateCommunityToken( ICommunity _community, IERC20 _newToken, address[] memory _exchangePath, uint256 _originalClaimAmount, uint256 _maxTotalClaim, uint256 _decreaseStep, uint256 _baseInterval, uint256 _incrementInterval ) external override onlyOwnerOrImpactMarketCouncil { _community.updateToken( _newToken, _exchangePath, _originalClaimAmount, _maxTotalClaim, _decreaseStep, _baseInterval, _incrementInterval ); } /** * @notice Updates proxy implementation address of a community * use this only for changing the implementation for one community * for updating the implementation for (almost) all communities, just update the communityImplementation param * * @param _communityMiddleProxy address of the community * @param _newCommunityImplementation address of new implementation contract */ function updateProxyImplementation( address _communityMiddleProxy, address _newCommunityImplementation ) external override onlyOwnerOrImpactMarketCouncil { communityProxyAdmin.upgrade( TransparentUpgradeableProxy(payable(_communityMiddleProxy)), _newCommunityImplementation ); } /** * @notice Updates proxy implementation address of impactMarket council * * @param _newImpactMarketCouncil address of new implementation contract */ function updateImpactMarketCouncil(IImpactMarketCouncil _newImpactMarketCouncil) external override onlyOwner { emit ImpactMarketCouncilUpdated( address(impactMarketCouncil), address(_newImpactMarketCouncil) ); impactMarketCouncil = _newImpactMarketCouncil; } /** * @notice Updates proxy implementation address of ambassadors * * @param _newAmbassadors address of new implementation contract */ function updateAmbassadors(IAmbassadors _newAmbassadors) external override onlyOwner { emit AmbassadorsUpdated(address(ambassadors), address(_newAmbassadors)); ambassadors = _newAmbassadors; } /** * @notice Updates communityMiddleProxy address * * @param _newCommunityMiddleProxy address of new implementation contract */ function updateCommunityMiddleProxy(address _newCommunityMiddleProxy) external override onlyOwner { emit CommunityMiddleProxyUpdated(communityMiddleProxy, _newCommunityMiddleProxy); communityMiddleProxy = _newCommunityMiddleProxy; } /** * @notice Gets a community implementation address * * @param _communityProxyAddress address of the community */ function getCommunityProxyImplementation(address _communityProxyAddress) external view override returns (address) { return communityProxyAdmin.getProxyImplementation( TransparentUpgradeableProxy(payable(_communityProxyAddress)) ); } /** * @dev Transfers community tokens from the treasury to a community * * @param _community address of the community * @param _amount amount of the transaction */ function transferToCommunity(ICommunity _community, uint256 _amount) internal nonReentrant { IERC20 _token = (_community.getVersion() == 1) ? _community.cUSD() : _community.token(); if (_token.balanceOf(address(treasury)) >= _amount) { treasury.transfer(_token, address(_community), _amount); _community.addTreasuryFunds(_amount); emit CommunityFunded(address(_community), _amount); } } /** * @dev Internal implementation of deploying a new community * * @param _tokenAddress Address of the token used by the community * @param _managers addresses of the community managers * @param _originalClaimAmount base amount to be claim by the beneficiary * @param _maxTotalClaim limit that a beneficiary can claim at in total * @param _decreaseStep value decreased from maxTotalClaim for every beneficiary added * @param _baseInterval base interval to start claiming * @param _incrementInterval increment interval used in each claim * @param _minTranche minimum amount that the community will receive when requesting funds * @param _maxTranche maximum amount that the community will receive when requesting funds * @param _maxBeneficiaries maximum number of valid beneficiaries * @param _previousCommunity address of the previous community. Used for migrating communities */ function deployCommunity( address _tokenAddress, address[] memory _managers, uint256 _originalClaimAmount, uint256 _maxTotalClaim, uint256 _decreaseStep, uint256 _baseInterval, uint256 _incrementInterval, uint256 _minTranche, uint256 _maxTranche, uint256 _maxBeneficiaries, ICommunity _previousCommunity ) internal returns (address) { TransparentUpgradeableProxy _community = new TransparentUpgradeableProxy( address(communityMiddleProxy), address(communityProxyAdmin), "" ); ICommunity(address(_community)).initialize( _tokenAddress, _managers, _originalClaimAmount, _maxTotalClaim, _decreaseStep, _baseInterval, _incrementInterval, _minTranche, _maxTranche, _maxBeneficiaries, _previousCommunity ); return address(_community); } /** @dev Calculates the tranche amount of a community. * * @param _community address of the community * @return uint256 the value of the tranche amount */ function calculateCommunityTrancheAmount(ICommunity _community) public view override returns (uint256) { IERC20 _token = (_community.getVersion() == 1) ? _community.cUSD() : _community.token(); uint256 _communityBalance = _token.balanceOf(address(_community)); uint256 _minTranche = _community.minTranche(); uint256 _maxTranche = _community.maxTranche(); if ( _communityBalance >= _community.minTranche() || block.number <= _community.lastFundRequest() + _community.baseInterval() || _token.balanceOf(address(treasury)) < treasuryMinBalance || _maxTranche == 0 ) { return 0; } uint256 _validBeneficiaries = _community.validBeneficiaryCount(); uint256 _originalClaimAmount = (_community.getVersion() >= 3) ? _community.originalClaimAmount() : IPreviousCommunity(address(_community)).claimAmount(); uint256 _trancheAmount = _validBeneficiaries * _originalClaimAmount; if (_trancheAmount < _minTranche) { _trancheAmount = _minTranche; } if (_trancheAmount > _maxTranche) { _trancheAmount = _maxTranche; } uint256 _amount; if (_trancheAmount > _communityBalance) { _amount = _trancheAmount - _communityBalance; uint256 _treasurySafetyBalance = _token.balanceOf(address(treasury)) * treasurySafetyPercentage / 100; if (_amount > _treasurySafetyBalance) { _amount = _treasurySafetyBalance; } } return _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/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/CommunityAdminStorageV1.sol
// SPDX-License-Identifier: Apache-2.0 pragma solidity 0.8.4; import "@openzeppelin/contracts/token/ERC20/IERC20.sol"; import "@openzeppelin/contracts/utils/structs/EnumerableSet.sol"; import "@openzeppelin/contracts/proxy/transparent/ProxyAdmin.sol"; import "./ICommunityAdmin.sol"; import "../../treasury/interfaces/ITreasury.sol"; /** * @title Storage for CommunityAdmin * @notice For future upgrades, do not change CommunityAdminStorageV1. Create a new * contract which implements CommunityAdminStorageV1 and following the naming convention * CommunityAdminStorageVX. */ abstract contract CommunityAdminStorageV1 is ICommunityAdmin { IERC20 public override cUSD; ITreasury public override treasury; ICommunity public override communityImplementation; ProxyAdmin public override communityProxyAdmin; mapping(address => CommunityState) public override communities; EnumerableSet.AddressSet internal communityList; }
/contracts/community/interfaces/CommunityAdminStorageV2.sol
// SPDX-License-Identifier: Apache-2.0 pragma solidity 0.8.4; import "./CommunityAdminStorageV1.sol"; import "../../governor/impactMarketCouncil/interfaces/IImpactMarketCouncil.sol"; import "../../ambassadors/interfaces/IAmbassadors.sol"; /** * @title Storage for CommunityAdmin * @notice For future upgrades, do not change CommunityAdminStorageV1. Create a new * contract which implements CommunityAdminStorageV1 and following the naming convention * CommunityAdminStorageVX. */ abstract contract CommunityAdminStorageV2 is CommunityAdminStorageV1 { IImpactMarketCouncil public override impactMarketCouncil; IAmbassadors public override ambassadors; address public override communityMiddleProxy; }
/contracts/community/interfaces/CommunityAdminStorageV3.sol
// SPDX-License-Identifier: Apache-2.0 pragma solidity 0.8.4; import "./CommunityAdminStorageV2.sol"; /** * @title Storage for CommunityAdmin * @notice For future upgrades, do not change CommunityAdminStorageV2. Create a new * contract which implements CommunityAdminStorageV2 and following the naming convention * CommunityAdminStorageVX. */ abstract contract CommunityAdminStorageV3 is CommunityAdminStorageV2 { address public override authorizedWalletAddress; // when there aren't enough funds into treasury, we want to limit the beneficiary claimAmount // the claim amount will be calculated based on the community funds and the number of beneficiary // originalClaimAmount * MIN_CLAIM_AMOUNT_RATIO_PRECISION / minClaimAmountRatio <= claimAmount <= originalClaimAmount uint256 public override minClaimAmountRatio; uint256 public override treasurySafetyPercentage; uint256 public override treasuryMinBalance; }
/contracts/community/interfaces/ICommunity.sol
// SPDX-License-Identifier: Apache-2.0 pragma solidity 0.8.4; import "@openzeppelin/contracts-upgradeable/access/IAccessControlUpgradeable.sol"; import "@openzeppelin/contracts/token/ERC20/IERC20.sol"; import "./ICommunityAdmin.sol"; interface ICommunity { enum BeneficiaryState { NONE, //the beneficiary hasn't been added yet Valid, Locked, Removed } 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 Token { 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 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 tokens(uint256 _index) external view returns ( address tokenAddress, uint256 ratio, uint256 startBlock ); function tokensLength() external view returns (uint256); function isSelfFunding() external view returns (bool); 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 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 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); }
/contracts/community/interfaces/ICommunityAdmin.sol
// SPDX-License-Identifier: Apache-2.0 pragma solidity 0.8.4; import "@openzeppelin/contracts/proxy/transparent/ProxyAdmin.sol"; import "@openzeppelin/contracts/token/ERC20/IERC20.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 removeCommunity(ICommunity _community) external; function fundCommunity() external; 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/community/interfaces/IPreviousCommunity.sol
// SPDX-License-Identifier: Apache-2.0 pragma solidity 0.8.4; import "@openzeppelin/contracts/token/ERC20/IERC20.sol"; interface IPreviousCommunity { function getVersion() external pure returns(uint256); function claimAmount() external view returns(uint256); function cUSD() external view returns(IERC20); }
/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 { // }
/contracts/treasury/interfaces/ITreasury.sol
//SPDX-License-Identifier: Apache-2.0 pragma solidity 0.8.4; import "@openzeppelin/contracts/token/ERC20/IERC20.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":"AmbassadorsUpdated","inputs":[{"type":"address","name":"oldAmbassadors","internalType":"address","indexed":true},{"type":"address","name":"newAmbassadors","internalType":"address","indexed":true}],"anonymous":false},{"type":"event","name":"CommunityAdded","inputs":[{"type":"address","name":"communityAddress","internalType":"address","indexed":true},{"type":"address[]","name":"managers","internalType":"address[]","indexed":false},{"type":"uint256","name":"originalClaimAmount","internalType":"uint256","indexed":false},{"type":"uint256","name":"maxTotalClaim","internalType":"uint256","indexed":false},{"type":"uint256","name":"decreaseStep","internalType":"uint256","indexed":false},{"type":"uint256","name":"baseInterval","internalType":"uint256","indexed":false},{"type":"uint256","name":"incrementInterval","internalType":"uint256","indexed":false},{"type":"uint256","name":"minTranche","internalType":"uint256","indexed":false},{"type":"uint256","name":"maxTranche","internalType":"uint256","indexed":false}],"anonymous":false},{"type":"event","name":"CommunityFunded","inputs":[{"type":"address","name":"community","internalType":"address","indexed":true},{"type":"uint256","name":"amount","internalType":"uint256","indexed":false}],"anonymous":false},{"type":"event","name":"CommunityImplementationUpdated","inputs":[{"type":"address","name":"oldCommunityImplementation","internalType":"address","indexed":true},{"type":"address","name":"newCommunityImplementation","internalType":"address","indexed":true}],"anonymous":false},{"type":"event","name":"CommunityMiddleProxyUpdated","inputs":[{"type":"address","name":"oldCommunityMiddleProxy","internalType":"address","indexed":false},{"type":"address","name":"newCommunityMiddleProxy","internalType":"address","indexed":false}],"anonymous":false},{"type":"event","name":"CommunityMigrated","inputs":[{"type":"address[]","name":"managers","internalType":"address[]","indexed":false},{"type":"address","name":"communityAddress","internalType":"address","indexed":true},{"type":"address","name":"previousCommunityAddress","internalType":"address","indexed":true}],"anonymous":false},{"type":"event","name":"CommunityRemoved","inputs":[{"type":"address","name":"communityAddress","internalType":"address","indexed":true}],"anonymous":false},{"type":"event","name":"ImpactMarketCouncilUpdated","inputs":[{"type":"address","name":"oldImpactMarketCouncil","internalType":"address","indexed":true},{"type":"address","name":"newImpactMarketCouncil","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":"TransferERC20","inputs":[{"type":"address","name":"token","internalType":"address","indexed":true},{"type":"address","name":"to","internalType":"address","indexed":true},{"type":"uint256","name":"amount","internalType":"uint256","indexed":false}],"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":"function","stateMutability":"nonpayable","outputs":[],"name":"addCommunity","inputs":[{"type":"address","name":"_tokenAddress","internalType":"address"},{"type":"address[]","name":"_managers","internalType":"address[]"},{"type":"address","name":"_ambassador","internalType":"address"},{"type":"uint256","name":"_originalClaimAmount","internalType":"uint256"},{"type":"uint256","name":"_maxTotalClaim","internalType":"uint256"},{"type":"uint256","name":"_decreaseStep","internalType":"uint256"},{"type":"uint256","name":"_baseInterval","internalType":"uint256"},{"type":"uint256","name":"_incrementInterval","internalType":"uint256"},{"type":"uint256","name":"_minTranche","internalType":"uint256"},{"type":"uint256","name":"_maxTranche","internalType":"uint256"},{"type":"uint256","name":"_maxBeneficiaries","internalType":"uint256"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"","internalType":"contract IAmbassadors"}],"name":"ambassadors","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"","internalType":"address"}],"name":"authorizedWalletAddress","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"","internalType":"contract IERC20"}],"name":"cUSD","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"calculateCommunityTrancheAmount","inputs":[{"type":"address","name":"_community","internalType":"contract ICommunity"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint8","name":"","internalType":"enum ICommunityAdmin.CommunityState"}],"name":"communities","inputs":[{"type":"address","name":"","internalType":"address"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"","internalType":"contract ICommunity"}],"name":"communityImplementation","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"","internalType":"address"}],"name":"communityListAt","inputs":[{"type":"uint256","name":"_index","internalType":"uint256"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"communityListLength","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"","internalType":"address"}],"name":"communityMiddleProxy","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"","internalType":"contract ProxyAdmin"}],"name":"communityProxyAdmin","inputs":[]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"fundCommunity","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"","internalType":"address"}],"name":"getCommunityProxyImplementation","inputs":[{"type":"address","name":"_communityProxyAddress","internalType":"address"}]},{"type":"function","stateMutability":"pure","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"getVersion","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"","internalType":"contract IImpactMarketCouncil"}],"name":"impactMarketCouncil","inputs":[]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"initialize","inputs":[{"type":"address","name":"_communityImplementation","internalType":"contract ICommunity"},{"type":"address","name":"_cUSD","internalType":"contract IERC20"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"bool","name":"","internalType":"bool"}],"name":"isAmbassadorOrEntityOfCommunity","inputs":[{"type":"address","name":"_community","internalType":"address"},{"type":"address","name":"_ambassadorOrEntity","internalType":"address"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"migrateCommunity","inputs":[{"type":"address[]","name":"_managers","internalType":"address[]"},{"type":"address","name":"_previousCommunity","internalType":"contract ICommunity"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"minClaimAmountRatio","inputs":[]},{"type":"function","stateMutability":"pure","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"minClaimAmountRatioPrecision","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"","internalType":"address"}],"name":"owner","inputs":[]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"removeCommunity","inputs":[{"type":"address","name":"_community","internalType":"contract ICommunity"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"renounceOwnership","inputs":[]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"setCommunityToAmbassador","inputs":[{"type":"address","name":"_ambassador","internalType":"address"},{"type":"address","name":"_communityAddress","internalType":"contract ICommunity"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"transfer","inputs":[{"type":"address","name":"_token","internalType":"contract IERC20"},{"type":"address","name":"_to","internalType":"address"},{"type":"uint256","name":"_amount","internalType":"uint256"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"transferFromCommunity","inputs":[{"type":"address","name":"_community","internalType":"contract ICommunity"},{"type":"address","name":"_token","internalType":"contract IERC20"},{"type":"address","name":"_to","internalType":"address"},{"type":"uint256","name":"_amount","internalType":"uint256"}]},{"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":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"treasuryMinBalance","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"treasurySafetyPercentage","inputs":[]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"updateAmbassadors","inputs":[{"type":"address","name":"_newAmbassadors","internalType":"contract IAmbassadors"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"updateAuthorizedWalletAddress","inputs":[{"type":"address","name":"_newAuthorizedWalletAddress","internalType":"address"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"updateBeneficiaryParams","inputs":[{"type":"address","name":"_community","internalType":"contract ICommunity"},{"type":"uint256","name":"_originalClaimAmount","internalType":"uint256"},{"type":"uint256","name":"_maxTotalClaim","internalType":"uint256"},{"type":"uint256","name":"_decreaseStep","internalType":"uint256"},{"type":"uint256","name":"_baseInterval","internalType":"uint256"},{"type":"uint256","name":"_incrementInterval","internalType":"uint256"},{"type":"uint256","name":"_maxBeneficiaries","internalType":"uint256"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"updateCommunityImplementation","inputs":[{"type":"address","name":"_newCommunityImplementation","internalType":"contract ICommunity"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"updateCommunityMiddleProxy","inputs":[{"type":"address","name":"_newCommunityMiddleProxy","internalType":"address"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"updateCommunityParams","inputs":[{"type":"address","name":"_community","internalType":"contract ICommunity"},{"type":"uint256","name":"_minTranche","internalType":"uint256"},{"type":"uint256","name":"_maxTranche","internalType":"uint256"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"updateCommunityToken","inputs":[{"type":"address","name":"_community","internalType":"contract ICommunity"},{"type":"address","name":"_newToken","internalType":"contract IERC20"},{"type":"address[]","name":"_exchangePath","internalType":"address[]"},{"type":"uint256","name":"_originalClaimAmount","internalType":"uint256"},{"type":"uint256","name":"_maxTotalClaim","internalType":"uint256"},{"type":"uint256","name":"_decreaseStep","internalType":"uint256"},{"type":"uint256","name":"_baseInterval","internalType":"uint256"},{"type":"uint256","name":"_incrementInterval","internalType":"uint256"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"updateImpactMarketCouncil","inputs":[{"type":"address","name":"_newImpactMarketCouncil","internalType":"contract IImpactMarketCouncil"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"updateMinClaimAmountRatio","inputs":[{"type":"uint256","name":"_newMinClaimAmountRatio","internalType":"uint256"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"updateProxyImplementation","inputs":[{"type":"address","name":"_communityMiddleProxy","internalType":"address"},{"type":"address","name":"_newCommunityImplementation","internalType":"address"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"updateTreasury","inputs":[{"type":"address","name":"_newTreasury","internalType":"contract ITreasury"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"updateTreasuryMinBalance","inputs":[{"type":"uint256","name":"_newTreasuryMinBalance","internalType":"uint256"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"updateTreasurySafetyPercentage","inputs":[{"type":"uint256","name":"_newTreasurySafetyPercentage","internalType":"uint256"}]}]
Deployed ByteCode
0x60806040523480156200001157600080fd5b50600436106200029d5760003560e01c80638da5cb5b116200016d578063beabacc811620000d3578063e80d93a21162000092578063e80d93a214620005d1578063f00d096414620005e8578063f1df104014620005f2578063f2fde38b1462000609578063f34ded501462000620578063fbb121b9146200063757600080fd5b8063beabacc81462000561578063becc3ce31462000578578063c0b3444e146200058f578063ca5c285614620005a6578063d7599b6d14620005bd57600080fd5b80639d18788b116200012c5780639d18788b14620004f9578063af2d77f81462000510578063afae65be1462000524578063b1909ef2146200052c578063b39f7ea41462000543578063b94ef2c2146200055757600080fd5b80638da5cb5b146200048e5780638e2d90db14620004a05780638e4254f414620004b75780639263454014620004cb5780639c22d32c14620004e257600080fd5b80634e39da2311620002135780636b68b2ef11620001d25780636b68b2ef146200040d578063715018a614620004175780637c7db5d714620004215780637f2813d2146200042b5780637f51bb1f146200046057806381449efe146200047757600080fd5b80634e39da23146200038f578063502791b614620003a657806361d027b314620003ba5780636a3c386514620003ce5780636b0de23f14620003e557600080fd5b80631fccf67211620002605780631fccf672146200031f5780632de00ddc1462000333578063372a8f4d146200034a57806339f539a21462000361578063485cc955146200037857600080fd5b8063016a041614620002a25780630cb967a314620002d35780630d8e6e2c14620002ec578063174a71d714620002fe5780631d2c93591462000308575b600080fd5b609a54620002b6906001600160a01b031681565b6040516001600160a01b0390911681526020015b60405180910390f35b620002ea620002e436600462003b19565b6200064e565b005b60035b604051908152602001620002ca565b620002ea620006ed565b620002ea6200031936600462003cc7565b62000a03565b609754620002b6906001600160a01b031681565b620002ea6200034436600462003c47565b62000acc565b620002b66200035b36600462003e87565b62000b7d565b620002ea6200037236600462003b57565b62000b92565b620002ea6200038936600462003c47565b62000c10565b620002ea620003a036600462003b19565b62000d61565b609e54620002b6906001600160a01b031681565b609854620002b6906001600160a01b031681565b620002ea620003df36600462003deb565b62000dea565b620003fc620003f636600462003b57565b62000f0a565b6040519015158152602001620002ca565b620002ef60a25481565b620002ea6200102b565b620002ef60a35481565b620004516200043c36600462003b19565b609b6020526000908152604090205460ff1681565b604051620002ca919062004068565b620002ea6200047136600462003b19565b62001066565b620002ea6200048836600462003db4565b620010ef565b6033546001600160a01b0316620002b6565b620002ea620004b136600462003c5a565b6200119a565b609954620002b6906001600160a01b031681565b620002ea620004dc36600462003b19565b62001b74565b620002ea620004f336600462003e87565b62001fa4565b620002ea6200050a36600462003b94565b62002074565b60a154620002b6906001600160a01b031681565b6064620002ef565b620002ef6200053d36600462003b19565b620023fd565b60a054620002b6906001600160a01b031681565b620002ef60a45481565b620002ea6200057236600462003e42565b62002bf3565b620002ea6200058936600462003e87565b62002cb9565b620002ea620005a036600462003e87565b62002d01565b620002ea620005b736600462003b19565b62002de7565b609f54620002b6906001600160a01b031681565b620002ea620005e236600462003b19565b62002e70565b620002ef62002ef9565b620002ea6200060336600462003d1e565b62002f0c565b620002ea6200061a36600462003b19565b62002fb9565b620002ea6200063136600462003b19565b6200305b565b620002b66200064836600462003b19565b620030c0565b6033546001600160a01b03163314620006845760405162461bcd60e51b81526004016200067b9062004116565b60405180910390fd5b60a054604080516001600160a01b03928316815291831660208301527fa5c3a96c9b28d1f0ca36f6d9cc9a8cf138656ee223e4b99adf4a58d10f1048a0910160405180910390a160a080546001600160a01b0319166001600160a01b0392909216919091179055565b6001336000908152609b602052604090205460ff1660038111156200072257634e487b7160e01b600052602160045260246000fd5b14620007715760405162461bcd60e51b815260206004820152601d60248201527f436f6d6d756e69747941646d696e3a204e4f545f434f4d4d554e49545900000060448201526064016200067b565b60003390506000816001600160a01b0316630d8e6e2c6040518163ffffffff1660e01b815260040160206040518083038186803b158015620007b257600080fd5b505afa158015620007c7573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190620007ed919062003ea0565b6001146200087057816001600160a01b031663fc0c546a6040518163ffffffff1660e01b815260040160206040518083038186803b1580156200082f57600080fd5b505afa15801562000844573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906200086a919062003b38565b620008e5565b816001600160a01b0316631fccf6726040518163ffffffff1660e01b815260040160206040518083038186803b158015620008aa57600080fd5b505afa158015620008bf573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190620008e5919062003b38565b6040516370a0823160e01b81523360048201529091506000906001600160a01b038316906370a082319060240160206040518083038186803b1580156200092b57600080fd5b505afa15801562000940573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019062000966919062003ea0565b905060006200097533620023fd565b905060008111620009f1576040805162461bcd60e51b81526020600482015260248101919091527f436f6d6d756e69747941646d696e3a3a66756e64436f6d6d756e6974793a207460448201527f68697320636f6d6d756e6974792063616e6e6f742072657175657374206e6f7760648201526084016200067b565b620009fd848262003142565b50505050565b6033546001600160a01b0316331462000a305760405162461bcd60e51b81526004016200067b9062004116565b6002606554141562000a565760405162461bcd60e51b81526004016200067b9062004196565b60026065556040516317d5759960e31b81526001600160a01b0385169063beabacc89062000a8d9086908690869060040162003ff4565b600060405180830381600087803b15801562000aa857600080fd5b505af115801562000abd573d6000803e3d6000fd5b50506001606555505050505050565b6033546001600160a01b031633148062000af05750609e546001600160a01b031633145b62000b0f5760405162461bcd60e51b81526004016200067b90620040c6565b609f54604051630b78037760e21b81526001600160a01b038481166004830152838116602483015290911690632de00ddc906044015b600060405180830381600087803b15801562000b6057600080fd5b505af115801562000b75573d6000803e3d6000fd5b505050505050565b600062000b8c609c8362003480565b92915050565b6033546001600160a01b031633148062000bb65750609e546001600160a01b031633145b62000bd55760405162461bcd60e51b81526004016200067b90620040c6565b609a5460405163266a23b160e21b81526001600160a01b0384811660048301528381166024830152909116906399a88ec49060440162000b45565b600054610100900460ff1662000c2d5760005460ff161562000c31565b303b155b62000c965760405162461bcd60e51b815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201526d191e481a5b9a5d1a585b1a5e995960921b60648201526084016200067b565b600054610100900460ff1615801562000cb9576000805461ffff19166101011790555b62000cc36200348e565b62000ccd620034cc565b609980546001600160a01b038086166001600160a01b031992831617909255609780549285169290911691909117905560405162000d0b9062003a3a565b604051809103906000f08015801562000d28573d6000803e3d6000fd5b50609a80546001600160a01b0319166001600160a01b0392909216919091179055801562000d5c576000805461ff00191690555b505050565b6033546001600160a01b0316331462000d8e5760405162461bcd60e51b81526004016200067b9062004116565b609f546040516001600160a01b038084169216907fbede3ab527cb73f6396abc70a54cb6637fe75d7f41468cd7b55900027382f7db90600090a3609f80546001600160a01b0319166001600160a01b0392909216919091179055565b6033546001600160a01b031633148062000e0e5750609e546001600160a01b031633145b62000e2d5760405162461bcd60e51b81526004016200067b90620040c6565b604051632fd7910360e01b815260048101879052602481018690526044810185905260648101849052608481018390526001600160a01b03881690632fd791039060a401600060405180830381600087803b15801562000e8c57600080fd5b505af115801562000ea1573d6000803e3d6000fd5b5050604051630c17fd9560e21b8152600481018490526001600160a01b038a16925063305ff6549150602401600060405180830381600087803b15801562000ee857600080fd5b505af115801562000efd573d6000803e3d6000fd5b5050505050505050505050565b609f54604051631611acd760e31b81526001600160a01b0383811660048301528481166024830152600092169063b08d66b89060440160206040518083038186803b15801562000f5957600080fd5b505afa15801562000f6e573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019062000f94919062003ca5565b80620010245750609f5460405163cb53f50360e01b81526001600160a01b03848116600483015285811660248301529091169063cb53f5039060440160206040518083038186803b15801562000fe957600080fd5b505afa15801562000ffe573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019062001024919062003ca5565b9392505050565b6033546001600160a01b03163314620010585760405162461bcd60e51b81526004016200067b9062004116565b62001064600062003500565b565b6033546001600160a01b03163314620010935760405162461bcd60e51b81526004016200067b9062004116565b6098546040516001600160a01b038084169216907f4ab5be82436d353e61ca18726e984e561f5c1cc7c6d38b29d2553c790434705a90600090a3609880546001600160a01b0319166001600160a01b0392909216919091179055565b6033546001600160a01b0316331480620011135750609e546001600160a01b031633145b620011325760405162461bcd60e51b81526004016200067b90620040c6565b604051630644b36d60e21b815260048101839052602481018290526001600160a01b03841690631912cdb490604401600060405180830381600087803b1580156200117c57600080fd5b505af115801562001191573d6000803e3d6000fd5b50505050505050565b6033546001600160a01b0316331480620011be5750609e546001600160a01b031633145b620011dd5760405162461bcd60e51b81526004016200067b90620040c6565b60026065541415620012035760405162461bcd60e51b81526004016200067b9062004196565b600260655560036001600160a01b0382166000908152609b602052604090205460ff1660038111156200124657634e487b7160e01b600052602160045260246000fd5b1415620012c75760405162461bcd60e51b815260206004820152604260248201527f436f6d6d756e69747941646d696e3a3a6d696772617465436f6d6d756e69747960448201527f3a207468697320636f6d6d756e69747920686173206265656e206d6967726174606482015261195960f21b608482015260a4016200067b565b6001600160a01b0381166000818152609b60209081526040808320805460ff1916600317905580516303639b8b60e21b81529051929392630d8e6e2c92600480840193919291829003018186803b1580156200132257600080fd5b505afa15801562001337573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906200135d919062003ea0565b600114620013e057816001600160a01b031663fc0c546a6040518163ffffffff1660e01b815260040160206040518083038186803b1580156200139f57600080fd5b505afa158015620013b4573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190620013da919062003b38565b62001455565b816001600160a01b0316631fccf6726040518163ffffffff1660e01b815260040160206040518083038186803b1580156200141a57600080fd5b505afa1580156200142f573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019062001455919062003b38565b905060006003836001600160a01b0316630d8e6e2c6040518163ffffffff1660e01b815260040160206040518083038186803b1580156200149557600080fd5b505afa158015620014aa573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190620014d0919062003ea0565b10156200155257826001600160a01b031663830953ab6040518163ffffffff1660e01b815260040160206040518083038186803b1580156200151157600080fd5b505afa15801562001526573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906200154c919062003ea0565b620015c7565b826001600160a01b031663fb7b0a0c6040518163ffffffff1660e01b815260040160206040518083038186803b1580156200158c57600080fd5b505afa158015620015a1573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190620015c7919062003ea0565b9050600062001991838684876001600160a01b03166378ba280f6040518163ffffffff1660e01b815260040160206040518083038186803b1580156200160c57600080fd5b505afa15801562001621573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019062001647919062003ea0565b886001600160a01b031663c51fab3c6040518163ffffffff1660e01b815260040160206040518083038186803b1580156200168157600080fd5b505afa15801562001696573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190620016bc919062003ea0565b896001600160a01b0316630e5b7c536040518163ffffffff1660e01b815260040160206040518083038186803b158015620016f657600080fd5b505afa1580156200170b573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019062001731919062003ea0565b8a6001600160a01b031663597be18b6040518163ffffffff1660e01b815260040160206040518083038186803b1580156200176b57600080fd5b505afa15801562001780573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190620017a6919062003ea0565b8b6001600160a01b031663dd4414bb6040518163ffffffff1660e01b815260040160206040518083038186803b158015620017e057600080fd5b505afa158015620017f5573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906200181b919062003ea0565b8c6001600160a01b0316632b2711176040518163ffffffff1660e01b815260040160206040518083038186803b1580156200185557600080fd5b505afa1580156200186a573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019062001890919062003ea0565b60018e6001600160a01b0316630d8e6e2c6040518163ffffffff1660e01b815260040160206040518083038186803b158015620018cc57600080fd5b505afa158015620018e1573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019062001907919062003ea0565b11620019155760006200198a565b8d6001600160a01b031663a0f93a176040518163ffffffff1660e01b815260040160206040518083038186803b1580156200194f57600080fd5b505afa15801562001964573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906200198a919062003ea0565b8e62003552565b90506001600160a01b038116620019ff5760405162461bcd60e51b815260206004820152602b60248201527f436f6d6d756e69747941646d696e3a3a6d696772617465436f6d6d756e69747960448201526a0e881393d517d59053125160aa1b60648201526084016200067b565b6040516370a0823160e01b81526001600160a01b038581166004830152600091908516906370a082319060240160206040518083038186803b15801562001a4557600080fd5b505afa15801562001a5a573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019062001a80919062003ea0565b6040516317d5759960e31b81529091506001600160a01b0386169063beabacc89062001ab59087908690869060040162003ff4565b600060405180830381600087803b15801562001ad057600080fd5b505af115801562001ae5573d6000803e3d6000fd5b505050506001600160a01b0382166000908152609b60205260409020805460ff1916600117905562001b19609c8362003647565b50846001600160a01b0316826001600160a01b03167f1c73dbd6259eae88a71a197a742361367d2811051b3de2b22953065b876247af8860405162001b5f919062003f92565b60405180910390a35050600160655550505050565b6033546001600160a01b031633148062001b985750609e546001600160a01b031633145b62001bb75760405162461bcd60e51b81526004016200067b90620040c6565b6002606554141562001bdd5760405162461bcd60e51b81526004016200067b9062004196565b600260655560016001600160a01b0382166000908152609b602052604090205460ff16600381111562001c2057634e487b7160e01b600052602160045260246000fd5b1462001c955760405162461bcd60e51b815260206004820152603d60248201527f436f6d6d756e69747941646d696e3a3a72656d6f7665436f6d6d756e6974793a60448201527f20746869732069736e277420612076616c696420636f6d6d756e69747900000060648201526084016200067b565b6001600160a01b038181166000818152609b602052604090819020805460ff19166002179055609f5490516302498d1560e61b8152600481019290925290911690639263454090602401600060405180830381600087803b15801562001cfa57600080fd5b505af115801562001d0f573d6000803e3d6000fd5b505050506000816001600160a01b0316630d8e6e2c6040518163ffffffff1660e01b815260040160206040518083038186803b15801562001d4f57600080fd5b505afa15801562001d64573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019062001d8a919062003ea0565b60011462001e0d57816001600160a01b031663fc0c546a6040518163ffffffff1660e01b815260040160206040518083038186803b15801562001dcc57600080fd5b505afa15801562001de1573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019062001e07919062003b38565b62001e82565b816001600160a01b0316631fccf6726040518163ffffffff1660e01b815260040160206040518083038186803b15801562001e4757600080fd5b505afa15801562001e5c573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019062001e82919062003b38565b6098546040516370a0823160e01b81526001600160a01b038581166004830181905293945063beabacc8928592908216918316906370a082319060240160206040518083038186803b15801562001ed857600080fd5b505afa15801562001eed573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019062001f13919062003ea0565b6040518463ffffffff1660e01b815260040162001f339392919062003ff4565b600060405180830381600087803b15801562001f4e57600080fd5b505af115801562001f63573d6000803e3d6000fd5b50506040516001600160a01b03851692507fa285b77d62d36ec6881b2cbc019c53874eb061798176f3577f2beab0848d16c69150600090a250506001606555565b6033546001600160a01b031633148062001fc85750609e546001600160a01b031633145b62001fe75760405162461bcd60e51b81526004016200067b90620040c6565b60648110156200206f5760405162461bcd60e51b815260206004820152604660248201527f436f6d6d756e69747941646d696e3a3a7570646174654d696e436c61696d416d60448201527f6f756e74526174696f3a20496e76616c6964206d696e436c61696d416d6f756e60648201526574526174696f60d01b608482015260a4016200067b565b60a255565b6033546001600160a01b0316331480620020985750609e546001600160a01b031633145b620020b75760405162461bcd60e51b81526004016200067b90620040c6565b60008a5111620021415760405162461bcd60e51b815260206004820152604860248201527f436f6d6d756e69747941646d696e3a3a616464436f6d6d756e6974793a20436f60448201527f6d6d756e6974792073686f756c642068617665206174206c65617374206f6e656064820152671036b0b730b3b2b960c11b608482015260a4016200067b565b6000620021598c8c8b8b8b8b8b8b8b8b600062003552565b90506001600160a01b038116620021c35760405162461bcd60e51b815260206004820152602760248201527f436f6d6d756e69747941646d696e3a3a616464436f6d6d756e6974793a204e4f6044820152661517d59053125160ca1b60648201526084016200067b565b6001600160a01b0381166000908152609b60205260409020805460ff19166001179055620021f3609c8262003647565b50609f54604051630b78037760e21b81526001600160a01b038c81166004830152838116602483015290911690632de00ddc90604401600060405180830381600087803b1580156200224457600080fd5b505af115801562002259573d6000803e3d6000fd5b50505050806001600160a01b03167fd975f7d7350dc54e14ea0400bad2e29483d76cb8810f36f1f520d5c44c1dcf028c8b8b8b8b8b8b8b604051620022a698979695949392919062003fa7565b60405180910390a2620022ba818562003142565b6097546098546040516370a0823160e01b81526001600160a01b03918216600482015266b1a2bc2ec500009291909116906370a082319060240160206040518083038186803b1580156200230d57600080fd5b505afa15801562002322573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019062002348919062003ea0565b10620023ef576098546097548c516001600160a01b039283169263beabacc89216908e906000906200238a57634e487b7160e01b600052603260045260246000fd5b602002602001015166b1a2bc2ec500006040518463ffffffff1660e01b8152600401620023ba9392919062003ff4565b600060405180830381600087803b158015620023d557600080fd5b505af1158015620023ea573d6000803e3d6000fd5b505050505b505050505050505050505050565b600080826001600160a01b0316630d8e6e2c6040518163ffffffff1660e01b815260040160206040518083038186803b1580156200243a57600080fd5b505afa1580156200244f573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019062002475919062003ea0565b600114620024f857826001600160a01b031663fc0c546a6040518163ffffffff1660e01b815260040160206040518083038186803b158015620024b757600080fd5b505afa158015620024cc573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190620024f2919062003b38565b6200256d565b826001600160a01b0316631fccf6726040518163ffffffff1660e01b815260040160206040518083038186803b1580156200253257600080fd5b505afa15801562002547573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906200256d919062003b38565b6040516370a0823160e01b81526001600160a01b0385811660048301529192506000918316906370a082319060240160206040518083038186803b158015620025b557600080fd5b505afa158015620025ca573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190620025f0919062003ea0565b90506000846001600160a01b031663dd4414bb6040518163ffffffff1660e01b815260040160206040518083038186803b1580156200262e57600080fd5b505afa15801562002643573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019062002669919062003ea0565b90506000856001600160a01b0316632b2711176040518163ffffffff1660e01b815260040160206040518083038186803b158015620026a757600080fd5b505afa158015620026bc573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190620026e2919062003ea0565b9050856001600160a01b031663dd4414bb6040518163ffffffff1660e01b815260040160206040518083038186803b1580156200271e57600080fd5b505afa15801562002733573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019062002759919062003ea0565b831015806200285d5750856001600160a01b0316630e5b7c536040518163ffffffff1660e01b815260040160206040518083038186803b1580156200279d57600080fd5b505afa158015620027b2573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190620027d8919062003ea0565b866001600160a01b03166309c338c36040518163ffffffff1660e01b815260040160206040518083038186803b1580156200281257600080fd5b505afa15801562002827573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906200284d919062003ea0565b620028599190620041cd565b4311155b80620028ea575060a4546098546040516370a0823160e01b81526001600160a01b039182166004820152908616906370a082319060240160206040518083038186803b158015620028ad57600080fd5b505afa158015620028c2573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190620028e8919062003ea0565b105b80620028f4575080155b15620029065750600095945050505050565b6000866001600160a01b031663431a801a6040518163ffffffff1660e01b815260040160206040518083038186803b1580156200294257600080fd5b505afa15801562002957573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906200297d919062003ea0565b905060006003886001600160a01b0316630d8e6e2c6040518163ffffffff1660e01b815260040160206040518083038186803b158015620029bd57600080fd5b505afa158015620029d2573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190620029f8919062003ea0565b101562002a7a57876001600160a01b031663830953ab6040518163ffffffff1660e01b815260040160206040518083038186803b15801562002a3957600080fd5b505afa15801562002a4e573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019062002a74919062003ea0565b62002aef565b876001600160a01b031663fb7b0a0c6040518163ffffffff1660e01b815260040160206040518083038186803b15801562002ab457600080fd5b505afa15801562002ac9573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019062002aef919062003ea0565b9050600062002aff828462004209565b90508481101562002b0d5750835b8381111562002b195750825b60008682111562002be65762002b3087836200422b565b60a3546098546040516370a0823160e01b81526001600160a01b039182166004820152929350600092606492918c16906370a082319060240160206040518083038186803b15801562002b8257600080fd5b505afa15801562002b97573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019062002bbd919062003ea0565b62002bc9919062004209565b62002bd59190620041e8565b90508082111562002be4578091505b505b9998505050505050505050565b6033546001600160a01b0316331462002c205760405162461bcd60e51b81526004016200067b9062004116565b6002606554141562002c465760405162461bcd60e51b81526004016200067b9062004196565b600260655562002c616001600160a01b03841683836200365e565b816001600160a01b0316836001600160a01b03167f9b035625e569d1d2bf54830a290aefba7ab11610ba8490871dc62b86b63a89568360405162002ca791815260200190565b60405180910390a35050600160655550565b6033546001600160a01b031633148062002cdd5750609e546001600160a01b031633145b62002cfc5760405162461bcd60e51b81526004016200067b90620040c6565b60a455565b6033546001600160a01b031633148062002d255750609e546001600160a01b031633145b62002d445760405162461bcd60e51b81526004016200067b90620040c6565b60008111801562002d555750606581105b62002de25760405162461bcd60e51b815260206004820152605060248201527f436f6d6d756e69747941646d696e3a3a7570646174655472656173757279536160448201527f6665747950657263656e746167653a20496e76616c696420747265617375727960648201526f53616665747950657263656e7461676560801b608482015260a4016200067b565b60a355565b6033546001600160a01b0316331462002e145760405162461bcd60e51b81526004016200067b9062004116565b609e546040516001600160a01b038084169216907feb64427276ab0ae1551ebf3002b4c3b44251a38b60c5d25daa1dad4e05876cc490600090a3609e80546001600160a01b0319166001600160a01b0392909216919091179055565b6033546001600160a01b0316331462002e9d5760405162461bcd60e51b81526004016200067b9062004116565b6099546040516001600160a01b038084169216907f0c6ac7336660be2921bd3e55b4c1013a87f9910af2d753f099453a0ea160915a90600090a3609980546001600160a01b0319166001600160a01b0392909216919091179055565b600062002f07609c620036b2565b905090565b6033546001600160a01b031633148062002f305750609e546001600160a01b031633145b62002f4f5760405162461bcd60e51b81526004016200067b90620040c6565b604051631bc1ca3560e11b81526001600160a01b03891690633783946a9062002f89908a908a908a908a908a908a908a9060040162004018565b600060405180830381600087803b15801562002fa457600080fd5b505af1158015620023ef573d6000803e3d6000fd5b6033546001600160a01b0316331462002fe65760405162461bcd60e51b81526004016200067b9062004116565b6001600160a01b0381166200304d5760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b60648201526084016200067b565b620030588162003500565b50565b6033546001600160a01b03163314806200307f5750609e546001600160a01b031633145b6200309e5760405162461bcd60e51b81526004016200067b90620040c6565b60a180546001600160a01b0319166001600160a01b0392909216919091179055565b609a546040516310270e3d60e11b81526001600160a01b038381166004830152600092169063204e1c7a9060240160206040518083038186803b1580156200310757600080fd5b505afa1580156200311c573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019062000b8c919062003b38565b60026065541415620031685760405162461bcd60e51b81526004016200067b9062004196565b60026065819055506000826001600160a01b0316630d8e6e2c6040518163ffffffff1660e01b815260040160206040518083038186803b158015620031ac57600080fd5b505afa158015620031c1573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190620031e7919062003ea0565b6001146200326a57826001600160a01b031663fc0c546a6040518163ffffffff1660e01b815260040160206040518083038186803b1580156200322957600080fd5b505afa1580156200323e573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019062003264919062003b38565b620032df565b826001600160a01b0316631fccf6726040518163ffffffff1660e01b815260040160206040518083038186803b158015620032a457600080fd5b505afa158015620032b9573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190620032df919062003b38565b6098546040516370a0823160e01b81526001600160a01b0391821660048201529192508391908316906370a082319060240160206040518083038186803b1580156200332a57600080fd5b505afa1580156200333f573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019062003365919062003ea0565b1062003476576098546040516317d5759960e31b81526001600160a01b039091169063beabacc890620033a19084908790879060040162003ff4565b600060405180830381600087803b158015620033bc57600080fd5b505af1158015620033d1573d6000803e3d6000fd5b5050604051635c04f74160e11b8152600481018590526001600160a01b038616925063b809ee829150602401600060405180830381600087803b1580156200341857600080fd5b505af11580156200342d573d6000803e3d6000fd5b50505050826001600160a01b03167f1e951788684f9b9e5c219261ce05daaa0f58ead974c796e6311b1da4c8657af1836040516200346d91815260200190565b60405180910390a25b5050600160655550565b6000620010248383620036bd565b600054610100900460ff16620034b85760405162461bcd60e51b81526004016200067b906200414b565b620034c2620036f6565b6200106462003720565b600054610100900460ff16620034f65760405162461bcd60e51b81526004016200067b906200414b565b6200106462003755565b603380546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b60a054609a5460405160009283926001600160a01b03918216929116906200357a9062003a48565b6001600160a01b03928316815291166020820152606060408201819052600090820152608001604051809103906000f080158015620035bd573d6000803e3d6000fd5b509050806001600160a01b0316630b4e78178e8e8e8e8e8e8e8e8e8e8e6040518c63ffffffff1660e01b8152600401620036029b9a9998979695949392919062003f1c565b600060405180830381600087803b1580156200361d57600080fd5b505af115801562003632573d6000803e3d6000fd5b50929f9e505050505050505050505050505050565b600062001024836001600160a01b03841662003786565b604080516001600160a01b038416602482015260448082018490528251808303909101815260649091019091526020810180516001600160e01b031663a9059cbb60e01b17905262000d5c908490620037d8565b600062000b8c825490565b6000826000018281548110620036e357634e487b7160e01b600052603260045260246000fd5b9060005260206000200154905092915050565b600054610100900460ff16620010645760405162461bcd60e51b81526004016200067b906200414b565b600054610100900460ff166200374a5760405162461bcd60e51b81526004016200067b906200414b565b620010643362003500565b600054610100900460ff166200377f5760405162461bcd60e51b81526004016200067b906200414b565b6001606555565b6000818152600183016020526040812054620037cf5750815460018181018455600084815260208082209093018490558454848252828601909352604090209190915562000b8c565b50600062000b8c565b60006200382f826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b0316620038b19092919063ffffffff16565b80519091501562000d5c578080602001905181019062003850919062003ca5565b62000d5c5760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b60648201526084016200067b565b6060620038c28484600085620038ca565b949350505050565b6060824710156200392d5760405162461bcd60e51b815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f6044820152651c8818d85b1b60d21b60648201526084016200067b565b843b6200397d5760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e747261637400000060448201526064016200067b565b600080866001600160a01b031685876040516200399b919062003efe565b60006040518083038185875af1925050503d8060008114620039da576040519150601f19603f3d011682016040523d82523d6000602084013e620039df565b606091505b5091509150620039f1828286620039fc565b979650505050505050565b6060831562003a0d57508162001024565b82511562003a1e5782518084602001fd5b8160405162461bcd60e51b81526004016200067b919062004091565b61079780620042b783390190565b610f2f8062004a4e83390190565b803562003a6381620042a0565b919050565b600082601f83011262003a79578081fd5b8135602067ffffffffffffffff8083111562003a995762003a996200428a565b8260051b604051601f19603f8301168101818110848211171562003ac15762003ac16200428a565b6040528481528381019250868401828801850189101562003ae0578687fd5b8692505b8583101562003b0d5762003af88162003a56565b84529284019260019290920191840162003ae4565b50979650505050505050565b60006020828403121562003b2b578081fd5b81356200102481620042a0565b60006020828403121562003b4a578081fd5b81516200102481620042a0565b6000806040838503121562003b6a578081fd5b823562003b7781620042a0565b9150602083013562003b8981620042a0565b809150509250929050565b60008060008060008060008060008060006101608c8e03121562003bb6578687fd5b8b3562003bc381620042a0565b9a5060208c013567ffffffffffffffff81111562003bdf578788fd5b62003bed8e828f0162003a68565b9a505060408c013562003c0081620042a0565b9a9d999c50999a60608101359a5060808101359960a0820135995060c0820135985060e0820135975061010082013596506101208201359550610140909101359350915050565b6000806040838503121562003b6a578182fd5b6000806040838503121562003c6d578182fd5b823567ffffffffffffffff81111562003c84578283fd5b62003c928582860162003a68565b925050602083013562003b8981620042a0565b60006020828403121562003cb7578081fd5b8151801515811462001024578182fd5b6000806000806080858703121562003cdd578384fd5b843562003cea81620042a0565b9350602085013562003cfc81620042a0565b9250604085013562003d0e81620042a0565b9396929550929360600135925050565b600080600080600080600080610100898b03121562003d3b578182fd5b883562003d4881620042a0565b9750602089013562003d5a81620042a0565b9650604089013567ffffffffffffffff81111562003d76578283fd5b62003d848b828c0162003a68565b989b979a5097986060810135985060808101359760a0820135975060c0820135965060e090910135945092505050565b60008060006060848603121562003dc9578081fd5b833562003dd681620042a0565b95602085013595506040909401359392505050565b600080600080600080600060e0888a03121562003e06578081fd5b873562003e1381620042a0565b9960208901359950604089013598606081013598506080810135975060a0810135965060c00135945092505050565b60008060006060848603121562003e57578081fd5b833562003e6481620042a0565b9250602084013562003e7681620042a0565b929592945050506040919091013590565b60006020828403121562003e99578081fd5b5035919050565b60006020828403121562003eb2578081fd5b5051919050565b6000815180845260208085019450808401835b8381101562003ef35781516001600160a01b03168752958201959082019060010162003ecc565b509495945050505050565b6000825162003f1281846020870162004245565b9190910192915050565b6001600160a01b038c811682526101606020830181905260009162003f448483018f62003eb9565b604085019d909d52606084019b909b525050608081019790975260a087019590955260c086019390935260e08501919091526101008401526101208301529091166101409091015292915050565b60208152600062001024602083018462003eb9565b600061010080835262003fbd8184018c62003eb9565b602084019a909a52505060408101969096526060860194909452608085019290925260a084015260c083015260e090910152919050565b6001600160a01b039384168152919092166020820152604081019190915260600190565b6001600160a01b038816815260e0602082018190526000906200403e9083018962003eb9565b6040830197909752506060810194909452608084019290925260a083015260c09091015292915050565b60208101600483106200408b57634e487b7160e01b600052602160045260246000fd5b91905290565b6020815260008251806020840152620040b281604085016020870162004245565b601f01601f19169190910160400192915050565b60208082526030908201527f436f6d6d756e69747941646d696e3a204e6f74204f776e6572204f7220496d7060408201526f1858dd13585c9ad95d10dbdd5b98da5b60821b606082015260800190565b6020808252818101527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604082015260600190565b6020808252602b908201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960408201526a6e697469616c697a696e6760a81b606082015260800190565b6020808252601f908201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c00604082015260600190565b60008219821115620041e357620041e362004274565b500190565b6000826200420457634e487b7160e01b81526012600452602481fd5b500490565b600081600019048311821515161562004226576200422662004274565b500290565b60008282101562004240576200424062004274565b500390565b60005b838110156200426257818101518382015260200162004248565b83811115620009fd5750506000910152565b634e487b7160e01b600052601160045260246000fd5b634e487b7160e01b600052604160045260246000fd5b6001600160a01b03811681146200305857600080fdfe608060405234801561001057600080fd5b5061001a3361001f565b61006f565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b6107198061007e6000396000f3fe60806040526004361061007b5760003560e01c80639623609d1161004e5780639623609d1461011157806399a88ec414610124578063f2fde38b14610144578063f3b7dead1461016457600080fd5b8063204e1c7a14610080578063715018a6146100bc5780637eff275e146100d35780638da5cb5b146100f3575b600080fd5b34801561008c57600080fd5b506100a061009b3660046104d8565b610184565b6040516001600160a01b03909116815260200160405180910390f35b3480156100c857600080fd5b506100d1610215565b005b3480156100df57600080fd5b506100d16100ee366004610517565b610254565b3480156100ff57600080fd5b506000546001600160a01b03166100a0565b6100d161011f36600461054f565b6102de565b34801561013057600080fd5b506100d161013f366004610517565b61036f565b34801561015057600080fd5b506100d161015f3660046104d8565b6103c7565b34801561017057600080fd5b506100a061017f3660046104d8565b610462565b6000806000836001600160a01b03166040516101aa90635c60da1b60e01b815260040190565b600060405180830381855afa9150503d80600081146101e5576040519150601f19603f3d011682016040523d82523d6000602084013e6101ea565b606091505b5091509150816101f957600080fd5b8080602001905181019061020d91906104fb565b949350505050565b6000546001600160a01b031633146102485760405162461bcd60e51b815260040161023f90610683565b60405180910390fd5b6102526000610488565b565b6000546001600160a01b0316331461027e5760405162461bcd60e51b815260040161023f90610683565b6040516308f2839760e41b81526001600160a01b038281166004830152831690638f283970906024015b600060405180830381600087803b1580156102c257600080fd5b505af11580156102d6573d6000803e3d6000fd5b505050505050565b6000546001600160a01b031633146103085760405162461bcd60e51b815260040161023f90610683565b60405163278f794360e11b81526001600160a01b03841690634f1ef2869034906103389086908690600401610620565b6000604051808303818588803b15801561035157600080fd5b505af1158015610365573d6000803e3d6000fd5b5050505050505050565b6000546001600160a01b031633146103995760405162461bcd60e51b815260040161023f90610683565b604051631b2ce7f360e11b81526001600160a01b038281166004830152831690633659cfe6906024016102a8565b6000546001600160a01b031633146103f15760405162461bcd60e51b815260040161023f90610683565b6001600160a01b0381166104565760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b606482015260840161023f565b61045f81610488565b50565b6000806000836001600160a01b03166040516101aa906303e1469160e61b815260040190565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b6000602082840312156104e9578081fd5b81356104f4816106ce565b9392505050565b60006020828403121561050c578081fd5b81516104f4816106ce565b60008060408385031215610529578081fd5b8235610534816106ce565b91506020830135610544816106ce565b809150509250929050565b600080600060608486031215610563578081fd5b833561056e816106ce565b9250602084013561057e816106ce565b9150604084013567ffffffffffffffff8082111561059a578283fd5b818601915086601f8301126105ad578283fd5b8135818111156105bf576105bf6106b8565b604051601f8201601f19908116603f011681019083821181831017156105e7576105e76106b8565b816040528281528960208487010111156105ff578586fd5b82602086016020830137856020848301015280955050505050509250925092565b60018060a01b0383168152600060206040818401528351806040850152825b8181101561065b5785810183015185820160600152820161063f565b8181111561066c5783606083870101525b50601f01601f191692909201606001949350505050565b6020808252818101527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604082015260600190565b634e487b7160e01b600052604160045260246000fd5b6001600160a01b038116811461045f57600080fdfea2646970667358221220e38caf5ca305d28cfea5924808a41fd6f9ab62ed165ed1becf8858d95ea882a264736f6c63430008040033608060405260405162000f2f38038062000f2f8339810160408190526200002691620004da565b82816200005560017f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbd62000609565b60008051602062000ee8833981519152146200008157634e487b7160e01b600052600160045260246000fd5b6200008f82826000620000ff565b50620000bf905060017fb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d610462000609565b60008051602062000ec883398151915214620000eb57634e487b7160e01b600052600160045260246000fd5b620000f6826200013c565b50505062000672565b6200010a8362000197565b600082511180620001185750805b156200013757620001358383620001d960201b620002601760201c565b505b505050565b7f7e644d79422f17c01e4894b5f4f588d331ebfa28653d42ae832dc59e38c9798f6200016762000208565b604080516001600160a01b03928316815291841660208301520160405180910390a1620001948162000241565b50565b620001a281620002f6565b6040516001600160a01b038216907fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b90600090a250565b606062000201838360405180606001604052806027815260200162000f086027913962000399565b9392505050565b60006200023260008051602062000ec883398151915260001b6200047660201b620002081760201c565b546001600160a01b0316919050565b6001600160a01b038116620002ac5760405162461bcd60e51b815260206004820152602660248201527f455243313936373a206e65772061646d696e20697320746865207a65726f206160448201526564647265737360d01b60648201526084015b60405180910390fd5b80620002d560008051602062000ec883398151915260001b6200047660201b620002081760201c565b80546001600160a01b0319166001600160a01b039290921691909117905550565b6200030c816200047960201b6200028c1760201c565b620003705760405162461bcd60e51b815260206004820152602d60248201527f455243313936373a206e657720696d706c656d656e746174696f6e206973206e60448201526c1bdd08184818dbdb9d1c9858dd609a1b6064820152608401620002a3565b80620002d560008051602062000ee883398151915260001b6200047660201b620002081760201c565b6060833b620003fa5760405162461bcd60e51b815260206004820152602660248201527f416464726573733a2064656c65676174652063616c6c20746f206e6f6e2d636f6044820152651b9d1c9858dd60d21b6064820152608401620002a3565b600080856001600160a01b031685604051620004179190620005b6565b600060405180830381855af49150503d806000811462000454576040519150601f19603f3d011682016040523d82523d6000602084013e62000459565b606091505b5090925090506200046c8282866200047f565b9695505050505050565b90565b3b151590565b606083156200049057508162000201565b825115620004a15782518084602001fd5b8160405162461bcd60e51b8152600401620002a39190620005d4565b80516001600160a01b0381168114620004d557600080fd5b919050565b600080600060608486031215620004ef578283fd5b620004fa84620004bd565b92506200050a60208501620004bd565b60408501519092506001600160401b038082111562000527578283fd5b818601915086601f8301126200053b578283fd5b8151818111156200055057620005506200065c565b604051601f8201601f19908116603f011681019083821181831017156200057b576200057b6200065c565b8160405282815289602084870101111562000594578586fd5b620005a78360208301602088016200062d565b80955050505050509250925092565b60008251620005ca8184602087016200062d565b9190910192915050565b6020815260008251806020840152620005f58160408501602087016200062d565b601f01601f19169190910160400192915050565b6000828210156200062857634e487b7160e01b81526011600452602481fd5b500390565b60005b838110156200064a57818101518382015260200162000630565b83811115620001355750506000910152565b634e487b7160e01b600052604160045260246000fd5b61084680620006826000396000f3fe60806040526004361061004e5760003560e01c80633659cfe6146100655780634f1ef286146100855780635c60da1b146100985780638f283970146100c9578063f851a440146100e95761005d565b3661005d5761005b6100fe565b005b61005b6100fe565b34801561007157600080fd5b5061005b6100803660046106d6565b610118565b61005b6100933660046106f0565b61015f565b3480156100a457600080fd5b506100ad6101d0565b6040516001600160a01b03909116815260200160405180910390f35b3480156100d557600080fd5b5061005b6100e43660046106d6565b61020b565b3480156100f557600080fd5b506100ad610235565b610106610292565b610116610111610331565b61033b565b565b61012061035f565b6001600160a01b0316336001600160a01b031614156101575761015481604051806020016040528060008152506000610392565b50565b6101546100fe565b61016761035f565b6001600160a01b0316336001600160a01b031614156101c8576101c38383838080601f01602080910402602001604051908101604052809392919081815260200183838082843760009201919091525060019250610392915050565b505050565b6101c36100fe565b60006101da61035f565b6001600160a01b0316336001600160a01b03161415610200576101fb610331565b905090565b6102086100fe565b90565b61021361035f565b6001600160a01b0316336001600160a01b0316141561015757610154816103bd565b600061023f61035f565b6001600160a01b0316336001600160a01b03161415610200576101fb61035f565b606061028583836040518060600160405280602781526020016107ea60279139610411565b9392505050565b3b151590565b61029a61035f565b6001600160a01b0316336001600160a01b031614156101165760405162461bcd60e51b815260206004820152604260248201527f5472616e73706172656e745570677261646561626c6550726f78793a2061646d60448201527f696e2063616e6e6f742066616c6c6261636b20746f2070726f78792074617267606482015261195d60f21b608482015260a4015b60405180910390fd5b60006101fb6104e5565b3660008037600080366000845af43d6000803e80801561035a573d6000f35b3d6000fd5b60007fb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d61035b546001600160a01b0316919050565b61039b8361050d565b6000825111806103a85750805b156101c3576103b78383610260565b50505050565b7f7e644d79422f17c01e4894b5f4f588d331ebfa28653d42ae832dc59e38c9798f6103e661035f565b604080516001600160a01b03928316815291841660208301520160405180910390a16101548161054d565b6060833b6104705760405162461bcd60e51b815260206004820152602660248201527f416464726573733a2064656c65676174652063616c6c20746f206e6f6e2d636f6044820152651b9d1c9858dd60d21b6064820152608401610328565b600080856001600160a01b03168560405161048b919061076e565b600060405180830381855af49150503d80600081146104c6576040519150601f19603f3d011682016040523d82523d6000602084013e6104cb565b606091505b50915091506104db8282866105f6565b9695505050505050565b60007f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc610383565b6105168161062f565b6040516001600160a01b038216907fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b90600090a250565b6001600160a01b0381166105b25760405162461bcd60e51b815260206004820152602660248201527f455243313936373a206e65772061646d696e20697320746865207a65726f206160448201526564647265737360d01b6064820152608401610328565b807fb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d61035b80546001600160a01b0319166001600160a01b039290921691909117905550565b60608315610605575081610285565b8251156106155782518084602001fd5b8160405162461bcd60e51b8152600401610328919061078a565b803b6106935760405162461bcd60e51b815260206004820152602d60248201527f455243313936373a206e657720696d706c656d656e746174696f6e206973206e60448201526c1bdd08184818dbdb9d1c9858dd609a1b6064820152608401610328565b807f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc6105d5565b80356001600160a01b03811681146106d157600080fd5b919050565b6000602082840312156106e7578081fd5b610285826106ba565b600080600060408486031215610704578182fd5b61070d846106ba565b9250602084013567ffffffffffffffff80821115610729578384fd5b818601915086601f83011261073c578384fd5b81358181111561074a578485fd5b87602082850101111561075b578485fd5b6020830194508093505050509250925092565b600082516107808184602087016107bd565b9190910192915050565b60208152600082518060208401526107a98160408501602087016107bd565b601f01601f19169190910160400192915050565b60005b838110156107d85781810151838201526020016107c0565b838111156103b7575050600091015256fe416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c206661696c6564a2646970667358221220675814b80ddcb309746b9826ddefd683cc86b7ea3c0b94e9b1325c4b1e1cb1a764736f6c63430008040033b53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c206661696c6564a264697066735822122069ee6fb71b805f11fce578df08f450abc24dc5a8ee62e88b5825c60142a2c9eb64736f6c63430008040033