Overview
CELO Balance
0 CELO
CELO Value
$0.00More Info
Private Name Tags
ContractCreator:
Multichain Info
N/A
Latest 1 from a total of 1 transactions
Transaction Hash |
Method
|
Block
|
From
|
To
|
Value | ||||
---|---|---|---|---|---|---|---|---|---|
0x60a06040 | 15114464 | 560 days ago | IN | Create: UBIScheme | 0 CELO | 0.0003778 |
Loading...
Loading
Contract Name:
UBIScheme
Compiler Version
v0.8.8+commit.dddeac2f
Optimization Enabled:
Yes with 0 runs
Other Settings:
default evmVersion
Contract Source Code (Solidity Standard Json-Input format)
// SPDX-License-Identifier: MIXED // License-Identifier: MIT pragma solidity >=0.8.0; import "../utils/DAOUpgradeableContract.sol"; import "../utils/NameService.sol"; import "../Interfaces.sol"; import "../governance/ClaimersDistribution.sol"; /* @title Dynamic amount-per-day UBI scheme allowing claim once a day */ contract UBIScheme is DAOUpgradeableContract { struct Day { mapping(address => bool) hasClaimed; uint256 amountOfClaimers; uint256 claimAmount; } //daily statistics mapping(uint256 => Day) public claimDay; //last ubi claim of user mapping(address => uint256) public lastClaimed; //current day since start of contract uint256 public currentDay; //starting date of contract, used to determine the hour where daily ubi cycle starts uint256 public periodStart; // Result of distribution formula // calculated each day uint256 public dailyUbi; // Limits the gas for each iteration at `fishMulti` uint256 public iterationGasLimit; // Tracks the active users number. It changes when // a new user claim for the first time or when a user // has been fished uint256 public activeUsersCount; // Tracks the last withdrawal day of funds from avatar. // Withdraw occures on the first daily claim or the // first daily fish only uint256 public lastWithdrawDay; // How long can a user be inactive. // After those days the user can be fished // (see `fish` notes) uint256 public maxInactiveDays; // Whether to withdraw GD from avatar // before daily ubi calculation bool public shouldWithdrawFromDAO; //number of days of each UBI pool cycle //dailyPool = Pool/cycleLength uint256 public cycleLength; //the amount of G$ UBI pool for each day in the cycle to be divided by active users uint256 public dailyCyclePool; //timestamp of current cycle start uint256 public startOfCycle; //should be 0 for starters so distributionFormula detects new cycle on first day claim uint256 public currentCycleLength; //dont use first claim, and give ubi as usual bool public useFirstClaimPool; //minimum amount of users to divide the pool for, renamed from defaultDailyUbi uint256 public minActiveUsers; // A pool of GD to give to activated users, // since they will enter the UBI pool // calculations only in the next day, // meaning they can only claim in the next // day IFirstClaimPool public firstClaimPool; struct Funds { // marks if the funds for a specific day has // withdrawn from avatar bool hasWithdrawn; // total GD held after withdrawing uint256 openAmount; } // Tracks the daily withdraws and the actual amount // at the begining of a trading day mapping(uint256 => Funds) public dailyUBIHistory; // Marks users that have been fished to avoid // double fishing mapping(address => bool) public fishedUsersAddresses; // Total claims per user stat mapping(address => uint256) public totalClaimsPerUser; bool public paused; // Emits when a withdraw has been succeded event WithdrawFromDao(uint256 prevBalance, uint256 newBalance); // Emits when a user is activated event ActivatedUser(address indexed account); // Emits when a fish has been succeded event InactiveUserFished( address indexed caller, address indexed fished_account, uint256 claimAmount ); // Emits when finishing a `multi fish` execution. // Indicates the number of users from the given // array who actually been fished. it might not // be finished going over all the array if there // no gas left. event TotalFished(uint256 total); // Emits when daily ubi is calculated event UBICalculated(uint256 day, uint256 dailyUbi, uint256 blockNumber); //Emits whenever a new multi day cycle starts event UBICycleCalculated( uint256 day, uint256 pool, uint256 cycleLength, uint256 dailyUBIPool ); event UBIClaimed(address indexed claimer, uint256 amount); event CycleLengthSet(uint256 newCycleLength); event DaySet(uint256 newDay); event ShouldWithdrawFromDAOSet(bool ShouldWithdrawFromDAO); /** * @dev Constructor * @param _ns the DAO * @param _firstClaimPool A pool for GD to give out to activated users * @param _maxInactiveDays Days of grace without claiming request */ function initialize( INameService _ns, IFirstClaimPool _firstClaimPool, uint256 _maxInactiveDays ) public initializer { require(_maxInactiveDays > 0, "Max inactive days cannot be zero"); setDAO(_ns); maxInactiveDays = _maxInactiveDays; firstClaimPool = _firstClaimPool; shouldWithdrawFromDAO = false; cycleLength = 90; //90 days iterationGasLimit = 150000; periodStart = (block.timestamp / (1 days)) * 1 days + 12 hours; //set start time to GMT noon startOfCycle = periodStart; useFirstClaimPool = address(_firstClaimPool) != address(0); minActiveUsers = 1000; } function setUseFirstClaimPool(bool _use) public { _onlyAvatar(); useFirstClaimPool = _use; } /** * @dev function that gets the amount of people who claimed on the given day * @param day the day to get claimer count from, with 0 being the starting day * @return an integer indicating the amount of people who claimed that day */ function getClaimerCount(uint256 day) public view returns (uint256) { return claimDay[day].amountOfClaimers; } /** * @dev function that gets the amount that was claimed on the given day * @param day the day to get claimer count from, with 0 being the starting day * @return an integer indicating the amount that has been claimed on the given day */ function getClaimAmount(uint256 day) public view returns (uint256) { return claimDay[day].claimAmount; } /** * @dev function that gets count of claimers and amount claimed for the current day * @return the count of claimers and the amount claimed. */ function getDailyStats() public view returns (uint256, uint256) { uint256 today = (block.timestamp - periodStart) / 1 days; return (getClaimerCount(today), getClaimAmount(today)); } modifier requireStarted() { require( paused == false && periodStart > 0 && block.timestamp >= periodStart, "not in periodStarted or paused" ); _; } /** * @dev On a daily basis UBIScheme withdraws tokens from GoodDao. * Emits event with caller address and last day balance and the * updated balance. */ function _withdrawFromDao() internal { IGoodDollar token = nativeToken(); uint256 prevBalance = token.balanceOf(address(this)); uint256 toWithdraw = token.balanceOf(address(avatar)); dao.genericCall( address(token), abi.encodeWithSignature( "transfer(address,uint256)", address(this), toWithdraw ), address(avatar), 0 ); uint256 newBalance = prevBalance + toWithdraw; require( newBalance == token.balanceOf(address(this)), "DAO transfer has failed" ); emit WithdrawFromDao(prevBalance, newBalance); } /** * @dev sets the ubi calculation cycle length * @param _newLength the new length in days */ function setCycleLength(uint256 _newLength) public { _onlyAvatar(); require(_newLength > 0, "cycle must be at least 1 day long"); cycleLength = _newLength; currentCycleLength = 0; //this will trigger a distributionFormula on next claim day emit CycleLengthSet(_newLength); } /** * @dev returns the day count since start of current cycle */ function currentDayInCycle() public view returns (uint256) { return (block.timestamp - startOfCycle) / (1 days); } /** * @dev The claim calculation formula. Divide the daily pool with * the sum of the active users. * the daily balance is determined by dividing current pool by the cycle length * @return The amount of GoodDollar the user can claim */ function distributionFormula() internal returns (uint256) { setDay(); // on first day or once in 24 hrs calculate distribution //on day 0 all users receive from firstclaim pool if (currentDay != lastWithdrawDay || dailyUbi == 0) { IGoodDollar token = nativeToken(); uint256 currentBalance = token.balanceOf(address(this)); //start early cycle if we can increase the daily UBI pool bool shouldStartEarlyCycle = currentBalance / cycleLength > dailyCyclePool; if ( currentDayInCycle() >= currentCycleLength || shouldStartEarlyCycle ) //start of cycle or first time { if (shouldWithdrawFromDAO) _withdrawFromDao(); currentBalance = token.balanceOf(address(this)); dailyCyclePool = currentBalance / cycleLength; currentCycleLength = cycleLength; startOfCycle = (block.timestamp / (1 hours)) * 1 hours; //start at a round hour emit UBICycleCalculated( currentDay, currentBalance, cycleLength, dailyCyclePool ); } lastWithdrawDay = currentDay; Funds storage funds = dailyUBIHistory[currentDay]; funds.hasWithdrawn = shouldWithdrawFromDAO; funds.openAmount = currentBalance; dailyUbi = dailyCyclePool / max(activeUsersCount, minActiveUsers); //update minActiveUsers as claimers grow minActiveUsers = max(activeUsersCount / 2, minActiveUsers); emit UBICalculated(currentDay, dailyUbi, block.number); } return dailyUbi; } function max(uint256 a, uint256 b) private pure returns (uint256) { return a >= b ? a : b; } /** *@dev Sets the currentDay variable to amount of days * since start of contract. */ function setDay() public { uint256 day = (block.timestamp - periodStart) / (1 days); if (day > currentDay) { currentDay = day; emit DaySet(day); } } /** * @dev Checks if the given account has claimed today * @param account to check * @return True if the given user has already claimed today */ function hasClaimed(address account) public view returns (bool) { return claimDay[currentDay].hasClaimed[account]; } /** * @dev Checks if the given account has been owned by a registered user. * @param _account to check * @return True for an existing user. False for a new user */ function isNotNewUser(address _account) public view returns (bool) { if (lastClaimed[_account] > 0) { // the sender is not registered return true; } return false; } /** * @dev Checks weather the given address is owned by an active user. * A registered user is a user that claimed at least one time. An * active user is a user that claimed at least one time but claimed * at least one time in the last `maxInactiveDays` days. A user that * has not claimed for `maxInactiveDays` is an inactive user. * @param _account to check * @return True for active user */ function isActiveUser(address _account) public view returns (bool) { uint256 _lastClaimed = lastClaimed[_account]; if (isNotNewUser(_account)) { uint256 daysSinceLastClaim = (block.timestamp - _lastClaimed) / (1 days); if (daysSinceLastClaim < maxInactiveDays) { // active user return true; } } return false; } /** * @dev Transfers `amount` DAO tokens to `account`. Updates stats * and emits an event in case of claimed. * In case that `isFirstTime` is true, it awards the user. * @param _account the account which recieves the funds * @param _target the recipient of funds * @param _amount the amount to transfer * @param _isClaimed true for claimed * @param _isFirstTime true for new user or fished user */ function _transferTokens( address _account, address _target, uint256 _amount, bool _isClaimed, bool _isFirstTime ) internal { // updates the stats if (_isClaimed || _isFirstTime) { //in case of fishing dont update stats claimDay[currentDay].amountOfClaimers += 1; claimDay[currentDay].hasClaimed[_account] = true; lastClaimed[_account] = block.timestamp; totalClaimsPerUser[_account] += 1; } // awards a new user or a fished user if (_isFirstTime) { uint256 awardAmount = firstClaimPool.awardUser(_target); claimDay[currentDay].claimAmount += awardAmount; emit UBIClaimed(_account, awardAmount); } else { if (_isClaimed) { claimDay[currentDay].claimAmount += _amount; emit UBIClaimed(_account, _amount); } IGoodDollar token = nativeToken(); require(token.transfer(_target, _amount), "claim transfer failed"); } } function estimateNextDailyUBI() public view returns (uint256) { uint256 currentBalance = nativeToken().balanceOf(address(this)); //start early cycle if we can increase the daily UBI pool bool shouldStartEarlyCycle = currentBalance / cycleLength > dailyCyclePool; uint256 _dailyCyclePool = dailyCyclePool; uint256 _dailyUbi; if ( currentDayInCycle() >= currentCycleLength || shouldStartEarlyCycle ) //start of cycle or first time { _dailyCyclePool = currentBalance / cycleLength; } _dailyUbi = _dailyCyclePool / max(activeUsersCount, minActiveUsers); return _dailyUbi; } function checkEntitlement() public view returns (uint256) { return checkEntitlement(msg.sender); } /** * @dev Checks the amount which the sender address is eligible to claim for, * regardless if they have been whitelisted or not. In case the user is * active, then the current day must be equal to the actual day, i.e. claim * or fish has already been executed today. * @return The amount of GD tokens the address can claim. */ function checkEntitlement(address _member) public view returns (uint256) { if (block.timestamp < periodStart) return 0; //not started // new user or inactive should recieve the first claim reward if ( useFirstClaimPool && (!isNotNewUser(_member) || fishedUsersAddresses[_member]) ) { return firstClaimPool.claimAmount(); } // current day has already been updated which means // that the dailyUbi has been updated if ( currentDay == (block.timestamp - periodStart) / (1 days) && dailyUbi > 0 ) { return hasClaimed(_member) ? 0 : dailyUbi; } return estimateNextDailyUBI(); } /** * @dev Function for claiming UBI. Requires contract to be active. Calls distributionFormula, * calculats the amount the account can claims, and transfers the amount to the account. * Emits the address of account and amount claimed. * @param _account The claimer account * @param _target recipient of funds * @return A bool indicating if UBI was claimed */ function _claim(address _account, address _target) internal returns (bool) { // calculats the formula up today ie on day 0 there are no active users, on day 1 any user // (new or active) will trigger the calculation with the active users count of the day before // and so on. the new or inactive users that will become active today, will not take into account // within the calculation. uint256 newDistribution = distributionFormula(); // active user which has not claimed today yet, ie user last claimed < today if ( isNotNewUser(_account) && !fishedUsersAddresses[_account] && !hasClaimed(_account) ) { _transferTokens(_account, _target, newDistribution, true, false); return true; } else if (!isNotNewUser(_account) || fishedUsersAddresses[_account]) { // a unregistered or fished user activeUsersCount += 1; fishedUsersAddresses[_account] = false; if (useFirstClaimPool) { _transferTokens(_account, _target, 0, false, true); } else { _transferTokens(_account, _target, newDistribution, true, false); } emit ActivatedUser(_account); return true; } return false; } /** * @dev Function for claiming UBI. Requires contract to be active and claimer to be whitelisted. * Calls distributionFormula, calculats the amount the caller can claim, and transfers the amount * to the caller. Emits the address of caller and amount claimed. * @return A bool indicating if UBI was claimed */ function claim() public requireStarted returns (bool) { address whitelistedRoot = IIdentityV2(nameService.getAddress("IDENTITY")) .getWhitelistedRoot(msg.sender); require(whitelistedRoot != address(0), "UBIScheme: not whitelisted"); bool didClaim = _claim(whitelistedRoot, msg.sender); address claimerDistribution = nameService.getAddress("GDAO_CLAIMERS"); if (didClaim && claimerDistribution != address(0)) { ClaimersDistribution(claimerDistribution).updateClaim(whitelistedRoot); } return didClaim; } /** * @dev In order to update users from active to inactive, we give out incentive to people * to update the status of inactive users, this action is called "Fishing". Anyone can * send a tx to the contract to mark inactive users. The "fisherman" receives a reward * equal to the daily UBI (ie instead of the “fished” user). User that “last claimed” > 14 * can be "fished" and made inactive (reduces active users count by one). Requires * contract to be active. * @param _account to fish * @return A bool indicating if UBI was fished */ function fish(address _account) public requireStarted returns (bool) { // checking if the account exists. that's been done because that // will prevent trying to fish non-existence accounts in the system require( isNotNewUser(_account) && !isActiveUser(_account), "is not an inactive user" ); require(!fishedUsersAddresses[_account], "already fished"); fishedUsersAddresses[_account] = true; // marking the account as fished so it won't refish // making sure that the calculation will be with the correct number of active users in case // that the fisher is the first to make the calculation today uint256 newDistribution = distributionFormula(); if (activeUsersCount > 0) { activeUsersCount -= 1; } _transferTokens(msg.sender, msg.sender, newDistribution, false, false); emit InactiveUserFished(msg.sender, _account, newDistribution); return true; } /** * @dev executes `fish` with multiple addresses. emits the number of users from the given * array who actually been tried being fished. * @param _accounts to fish * @return A bool indicating if all the UBIs were fished */ function fishMulti(address[] memory _accounts) public requireStarted returns (uint256) { for (uint256 i = 0; i < _accounts.length; ++i) { if (gasleft() < iterationGasLimit) { emit TotalFished(i); return i; } if ( isNotNewUser(_accounts[i]) && !isActiveUser(_accounts[i]) && !fishedUsersAddresses[_accounts[i]] ) { require(fish(_accounts[i]), "fish has failed"); } } emit TotalFished(_accounts.length); return _accounts.length; } /** * @dev Sets whether to also withdraw GD from avatar for UBI * @param _shouldWithdraw boolean if to withdraw */ function setShouldWithdrawFromDAO(bool _shouldWithdraw) public { _onlyAvatar(); shouldWithdrawFromDAO = _shouldWithdraw; emit ShouldWithdrawFromDAOSet(shouldWithdrawFromDAO); } function pause(bool _pause) public { _onlyAvatar(); paused = _pause; } // function upgrade() public { // _onlyAvatar(); // paused = true; // activeUsersCount = 50000; //estimated // dailyUbi = 0; //required so distributionformula will trigger // cycleLength = 30; // currentCycleLength = 0; //this will trigger a new cycle calculation in distribution formula // startOfCycle = block.timestamp - 91 days; //this will trigger a new calculation in distributionFormula // periodStart = 1646136000; // maxDailyUBI = 50000; // distributionFormula(); // emit CycleLengthSet(cycleLength); // } function setActiveUserCount(uint256 _activeUserCount) public { _onlyAvatar(); activeUsersCount = _activeUserCount; } }
// SPDX-License-Identifier: MIT pragma solidity >=0.8.0; import "@openzeppelin/contracts-upgradeable/proxy/utils/UUPSUpgradeable.sol"; import "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol"; import "./DAOContract.sol"; /** @title Simple contract that adds upgradability to DAOContract */ contract DAOUpgradeableContract is Initializable, UUPSUpgradeable, DAOContract { function _authorizeUpgrade(address) internal virtual override { _onlyAvatar(); } }
// SPDX-License-Identifier: MIT pragma solidity >=0.8.0; import "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol"; import "@openzeppelin/contracts-upgradeable/proxy/utils/UUPSUpgradeable.sol"; import "../DAOStackInterfaces.sol"; /** @title Simple name to address resolver */ contract NameService is Initializable, UUPSUpgradeable { mapping(bytes32 => address) public addresses; Controller public dao; event AddressChanged(string name ,address addr); function initialize( Controller _dao, bytes32[] memory _nameHashes, address[] memory _addresses ) public virtual initializer { dao = _dao; for (uint256 i = 0; i < _nameHashes.length; i++) { addresses[_nameHashes[i]] = _addresses[i]; } addresses[keccak256(bytes("CONTROLLER"))] = address(_dao); addresses[keccak256(bytes("AVATAR"))] = address(_dao.avatar()); } function _authorizeUpgrade(address) internal override { _onlyAvatar(); } function _onlyAvatar() internal view { require( address(dao.avatar()) == msg.sender, "only avatar can call this method" ); } function setAddress(string memory name, address addr) external { _onlyAvatar(); addresses[keccak256(bytes(name))] = addr; emit AddressChanged(name, addr); } function setAddresses(bytes32[] calldata hash, address[] calldata addrs) external { _onlyAvatar(); for (uint256 i = 0; i < hash.length; i++) { addresses[hash[i]] = addrs[i]; } } function getAddress(string memory name) external view returns (address) { return addresses[keccak256(bytes(name))]; } }
// SPDX-License-Identifier: MIT import { DataTypes } from "./utils/DataTypes.sol"; pragma solidity >=0.8.0; pragma experimental ABIEncoderV2; interface ERC20 { function balanceOf(address addr) external view returns (uint256); function transfer(address to, uint256 amount) external returns (bool); function approve(address spender, uint256 amount) external returns (bool); function decimals() external view returns (uint8); function mint(address to, uint256 mintAmount) external returns (uint256); function burn(uint256 amount) external; function totalSupply() external view returns (uint256); function allowance(address owner, address spender) external view returns (uint256); function transferFrom( address sender, address recipient, uint256 amount ) external returns (bool); function name() external view returns (string memory); function symbol() external view returns (string memory); event Transfer(address indexed from, address indexed to, uint256 amount); event Transfer( address indexed from, address indexed to, uint256 amount, bytes data ); } interface cERC20 is ERC20 { function mint(uint256 mintAmount) external returns (uint256); function redeemUnderlying(uint256 mintAmount) external returns (uint256); function redeem(uint256 mintAmount) external returns (uint256); function exchangeRateCurrent() external returns (uint256); function exchangeRateStored() external view returns (uint256); function underlying() external returns (address); } interface IGoodDollar is ERC20 { function getFees(uint256 value) external view returns (uint256, bool); function burn(uint256 amount) external; function burnFrom(address account, uint256 amount) external; function renounceMinter() external; function addMinter(address minter) external; function isMinter(address minter) external view returns (bool); function transferAndCall( address to, uint256 value, bytes calldata data ) external returns (bool); function formula() external view returns (address); function setIdentity(address identity) external; function identity() external view returns (address); function owner() external view returns (address); } interface IERC2917 is ERC20 { /// @dev This emit when interests amount per block is changed by the owner of the contract. /// It emits with the old interests amount and the new interests amount. event InterestRatePerBlockChanged(uint256 oldValue, uint256 newValue); /// @dev This emit when a users' productivity has changed /// It emits with the user's address and the the value after the change. event ProductivityIncreased(address indexed user, uint256 value); /// @dev This emit when a users' productivity has changed /// It emits with the user's address and the the value after the change. event ProductivityDecreased(address indexed user, uint256 value); /// @dev Return the current contract's interests rate per block. /// @return The amount of interests currently producing per each block. function interestsPerBlock() external view returns (uint256); /// @notice Change the current contract's interests rate. /// @dev Note the best practice will be restrict the gross product provider's contract address to call this. /// @return The true/fase to notice that the value has successfully changed or not, when it succeed, it will emite the InterestRatePerBlockChanged event. function changeInterestRatePerBlock(uint256 value) external returns (bool); /// @notice It will get the productivity of given user. /// @dev it will return 0 if user has no productivity proved in the contract. /// @return user's productivity and overall productivity. function getProductivity(address user) external view returns (uint256, uint256); /// @notice increase a user's productivity. /// @dev Note the best practice will be restrict the callee to prove of productivity's contract address. /// @return true to confirm that the productivity added success. function increaseProductivity(address user, uint256 value) external returns (bool); /// @notice decrease a user's productivity. /// @dev Note the best practice will be restrict the callee to prove of productivity's contract address. /// @return true to confirm that the productivity removed success. function decreaseProductivity(address user, uint256 value) external returns (bool); /// @notice take() will return the interests that callee will get at current block height. /// @dev it will always calculated by block.number, so it will change when block height changes. /// @return amount of the interests that user are able to mint() at current block height. function take() external view returns (uint256); /// @notice similar to take(), but with the block height joined to calculate return. /// @dev for instance, it returns (_amount, _block), which means at block height _block, the callee has accumulated _amount of interests. /// @return amount of interests and the block height. function takeWithBlock() external view returns (uint256, uint256); /// @notice mint the avaiable interests to callee. /// @dev once it mint, the amount of interests will transfer to callee's address. /// @return the amount of interests minted. function mint() external returns (uint256); } interface Staking { struct Staker { // The staked DAI amount uint256 stakedDAI; // The latest block number which the // staker has staked tokens uint256 lastStake; } function stakeDAI(uint256 amount) external; function withdrawStake() external; function stakers(address staker) external view returns (Staker memory); } interface Uniswap { function swapExactETHForTokens( uint256 amountOutMin, address[] calldata path, address to, uint256 deadline ) external payable returns (uint256[] memory amounts); function swapExactTokensForETH( uint256 amountIn, uint256 amountOutMin, address[] calldata path, address to, uint256 deadline ) external returns (uint256[] memory amounts); function swapExactTokensForTokens( uint256 amountIn, uint256 amountOutMin, address[] calldata path, address to, uint256 deadline ) external returns (uint256[] memory amounts); function WETH() external pure returns (address); function factory() external pure returns (address); function quote( uint256 amountA, uint256 reserveA, uint256 reserveB ) external pure returns (uint256 amountB); function getAmountIn( uint256 amountOut, uint256 reserveIn, uint256 reserveOut ) external pure returns (uint256 amountIn); function getAmountOut( uint256 amountI, uint256 reserveIn, uint256 reserveOut ) external pure returns (uint256 amountOut); function getAmountsOut(uint256 amountIn, address[] memory path) external pure returns (uint256[] memory amounts); } interface UniswapFactory { function getPair(address tokenA, address tokenB) external view returns (address); } interface UniswapPair { function getReserves() external view returns ( uint112 reserve0, uint112 reserve1, uint32 blockTimestampLast ); function kLast() external view returns (uint256); function token0() external view returns (address); function token1() external view returns (address); function totalSupply() external view returns (uint256); function balanceOf(address owner) external view returns (uint256); } interface Reserve { function buy( address _buyWith, uint256 _tokenAmount, uint256 _minReturn ) external returns (uint256); } interface IIdentity { function isWhitelisted(address user) external view returns (bool); function addWhitelistedWithDID(address account, string memory did) external; function removeWhitelisted(address account) external; function addBlacklisted(address account) external; function removeBlacklisted(address account) external; function isBlacklisted(address user) external view returns (bool); function addIdentityAdmin(address account) external returns (bool); function setAvatar(address _avatar) external; function isIdentityAdmin(address account) external view returns (bool); function owner() external view returns (address); function removeContract(address account) external; function isDAOContract(address account) external view returns (bool); function addrToDID(address account) external view returns (string memory); event WhitelistedAdded(address user); } interface IIdentityV2 is IIdentity { function addWhitelistedWithDIDAndChain( address account, string memory did, uint256 orgChainId, uint256 dateAuthenticated ) external; function getWhitelistedRoot(address account) external view returns (address root); } interface IUBIScheme { function currentDay() external view returns (uint256); function periodStart() external view returns (uint256); function hasClaimed(address claimer) external view returns (bool); } interface IFirstClaimPool { function awardUser(address user) external returns (uint256); function claimAmount() external view returns (uint256); } interface ProxyAdmin { function getProxyImplementation(address proxy) external view returns (address); function getProxyAdmin(address proxy) external view returns (address); function upgrade(address proxy, address implementation) external; function owner() external view returns (address); function transferOwnership(address newOwner) external; function upgradeAndCall( address proxy, address implementation, bytes memory data ) external; } /** * @dev Interface for chainlink oracles to obtain price datas */ interface AggregatorV3Interface { function decimals() external view returns (uint8); function description() external view returns (string memory); function version() external view returns (uint256); // getRoundData and latestRoundData should both raise "No data present" // if they do not have data to report, instead of returning unset values // which could be misinterpreted as actual reported values. function getRoundData(uint80 _roundId) external view returns ( uint80 roundId, int256 answer, uint256 startedAt, uint256 updatedAt, uint80 answeredInRound ); function latestAnswer() external view returns (int256); } /** @dev interface for AAVE lending Pool */ interface ILendingPool { /** * @dev Deposits an `amount` of underlying asset into the reserve, receiving in return overlying aTokens. * - E.g. User deposits 100 USDC and gets in return 100 aUSDC * @param asset The address of the underlying asset to deposit * @param amount The amount to be deposited * @param onBehalfOf The address that will receive the aTokens, same as msg.sender if the user * wants to receive them on his own wallet, or a different address if the beneficiary of aTokens * is a different wallet * @param referralCode Code used to register the integrator originating the operation, for potential rewards. * 0 if the action is executed directly by the user, without any middle-man **/ function deposit( address asset, uint256 amount, address onBehalfOf, uint16 referralCode ) external; /** * @dev Withdraws an `amount` of underlying asset from the reserve, burning the equivalent aTokens owned * E.g. User has 100 aUSDC, calls withdraw() and receives 100 USDC, burning the 100 aUSDC * @param asset The address of the underlying asset to withdraw * @param amount The underlying amount to be withdrawn * - Send the value type(uint256).max in order to withdraw the whole aToken balance * @param to Address that will receive the underlying, same as msg.sender if the user * wants to receive it on his own wallet, or a different address if the beneficiary is a * different wallet * @return The final amount withdrawn **/ function withdraw( address asset, uint256 amount, address to ) external returns (uint256); /** * @dev Returns the state and configuration of the reserve * @param asset The address of the underlying asset of the reserve * @return The state of the reserve **/ function getReserveData(address asset) external view returns (DataTypes.ReserveData memory); } interface IDonationStaking { function stakeDonations() external payable; } interface INameService { function getAddress(string memory _name) external view returns (address); } interface IAaveIncentivesController { /** * @dev Claims reward for an user, on all the assets of the lending pool, accumulating the pending rewards * @param amount Amount of rewards to claim * @param to Address that will be receiving the rewards * @return Rewards claimed **/ function claimRewards( address[] calldata assets, uint256 amount, address to ) external returns (uint256); /** * @dev Returns the total of rewards of an user, already accrued + not yet accrued * @param user The address of the user * @return The rewards **/ function getRewardsBalance(address[] calldata assets, address user) external view returns (uint256); } interface IGoodStaking { function collectUBIInterest(address recipient) external returns ( uint256, uint256, uint256 ); function iToken() external view returns (address); function currentGains( bool _returnTokenBalanceInUSD, bool _returnTokenGainsInUSD ) external view returns ( uint256, uint256, uint256, uint256, uint256 ); function getRewardEarned(address user) external view returns (uint256); function getGasCostForInterestTransfer() external view returns (uint256); function rewardsMinted( address user, uint256 rewardsPerBlock, uint256 blockStart, uint256 blockEnd ) external returns (uint256); } interface IHasRouter { function getRouter() external view returns (Uniswap); } interface IAdminWallet { function addAdmins(address payable[] memory _admins) external; function removeAdmins(address[] memory _admins) external; function owner() external view returns (address); function transferOwnership(address _owner) external; } interface IMultichainRouter { // Swaps `amount` `token` from this chain to `toChainID` chain with recipient `to` function anySwapOut( address token, address to, uint256 amount, uint256 toChainID ) external; // Swaps `amount` `token` from this chain to `toChainID` chain with recipient `to` function anySwapOutUnderlying( address token, address to, uint256 amount, uint256 toChainID ) external; }
// SPDX-License-Identifier: MIT pragma solidity >=0.8.0; import "../utils/DAOUpgradeableContract.sol"; import "../utils/NameService.sol"; import "../Interfaces.sol"; import "../governance/GReputation.sol"; /** * ClaimersDistribution providers callbacks that can be used by UBIScheme to update when a citizen * has claimed. * It will distribute GDAO each month pro rata based on number of claims */ contract ClaimersDistribution is DAOUpgradeableContract { ///@notice reputation to distribute each month, will effect next month when set uint256 public monthlyReputationDistribution; ///@notice month number since epoch uint256 public currentMonth; struct MonthData { mapping(address => uint256) claims; //claims per user in month uint256 totalClaims; // total claims in month uint256 monthlyDistribution; //monthlyReputationDistribution at the time when _updateMonth was called } ///@notice keep track of each month distribution data mapping(uint256 => MonthData) public months; ///@notice marks last month user claimed reputation for mapping(address => uint256) public lastMonthClaimed; ///@notice tracks timestamp of last time user claimed UBI mapping(address => uint256) public lastUpdated; event ReputationEarned( address claimer, uint256 month, uint256 claims, uint256 reputation ); event MonthlyDistributionSet(uint256 reputationAmount); function initialize(INameService _ns) public initializer { monthlyReputationDistribution = 4000000 ether; //4M as specified in specs _updateMonth(); setDAO(_ns); } /** * @dev update the monthly reputation distribution. only avatar can do that. * @param newMonthlyReputationDistribution the new reputation amount to distribute */ function setMonthlyReputationDistribution( uint256 newMonthlyReputationDistribution ) external { _onlyAvatar(); monthlyReputationDistribution = newMonthlyReputationDistribution; emit MonthlyDistributionSet(newMonthlyReputationDistribution); } /** * @dev internal function to switch to new month. records for new month the current monthlyReputationDistribution */ function _updateMonth() internal { uint256 month = block.timestamp / 30 days; if (month != currentMonth) { //update new month currentMonth = month; months[currentMonth] .monthlyDistribution = monthlyReputationDistribution; } } /** * @dev increase user count of claims if he claimed today. (called automatically by latest version of UBIScheme) * @param _claimer the user to update */ function updateClaim(address _claimer) external { IUBIScheme ubi = IUBIScheme(nameService.getAddress("UBISCHEME")); require( ubi.hasClaimed(_claimer), "ClaimersDistribution: didn't claim today" ); require( ubi.currentDay() * 1 days + ubi.periodStart() > lastUpdated[_claimer], "ClaimersDistribution: already updated" ); _updateMonth(); lastUpdated[_claimer] = block.timestamp; months[currentMonth].claims[_claimer] += 1; months[currentMonth].totalClaims += 1; uint256 prevMonth = currentMonth - 1; if (lastMonthClaimed[_claimer] >= prevMonth) return; claimReputation(_claimer); } /** * @dev helper func * @return number of UBI claims user performed this month */ function getMonthClaims(address _claimer) public view returns (uint256) { return months[currentMonth].claims[_claimer]; } /** * @dev mints reputation to user according to his share in last month claims * @param _claimer the user to distribute reputation to */ function claimReputation(address _claimer) public { uint256 prevMonth = currentMonth - 1; uint256 monthlyDist = months[prevMonth].monthlyDistribution; uint256 userClaims = months[prevMonth].claims[_claimer]; if ( lastMonthClaimed[_claimer] < prevMonth && userClaims > 0 && monthlyDist > 0 ) { lastMonthClaimed[_claimer] = prevMonth; uint256 userShare = (monthlyDist * userClaims) / months[prevMonth].totalClaims; if (userShare > 0) { GReputation grep = GReputation( nameService.getAddress("REPUTATION") ); grep.mint(_claimer, userShare); emit ReputationEarned( _claimer, prevMonth, userClaims, userShare ); } } } }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "../ERC1967/ERC1967UpgradeUpgradeable.sol"; import "./Initializable.sol"; /** * @dev An upgradeability mechanism designed for UUPS proxies. The functions included here can perform an upgrade of an * {ERC1967Proxy}, when this contract is set as the implementation behind such a proxy. * * A security mechanism ensures that an upgrade does not turn off upgradeability accidentally, although this risk is * reinstated if the upgrade retains upgradeability but removes the security mechanism, e.g. by replacing * `UUPSUpgradeable` with a custom implementation of upgrades. * * The {_authorizeUpgrade} function must be overridden to include access restriction to the upgrade mechanism. * * _Available since v4.1._ */ abstract contract UUPSUpgradeable is Initializable, ERC1967UpgradeUpgradeable { function __UUPSUpgradeable_init() internal initializer { __ERC1967Upgrade_init_unchained(); __UUPSUpgradeable_init_unchained(); } function __UUPSUpgradeable_init_unchained() internal initializer { } /// @custom:oz-upgrades-unsafe-allow state-variable-immutable state-variable-assignment address private immutable __self = address(this); /** * @dev Check that the execution is being performed through a delegatecall call and that the execution context is * a proxy contract with an implementation (as defined in ERC1967) pointing to self. This should only be the case * for UUPS and transparent proxies that are using the current contract as their implementation. Execution of a * function through ERC1167 minimal proxies (clones) would not normally pass this test, but is not guaranteed to * fail. */ modifier onlyProxy() { require(address(this) != __self, "Function must be called through delegatecall"); require(_getImplementation() == __self, "Function must be called through active proxy"); _; } /** * @dev Upgrade the implementation of the proxy to `newImplementation`. * * Calls {_authorizeUpgrade}. * * Emits an {Upgraded} event. */ function upgradeTo(address newImplementation) external virtual onlyProxy { _authorizeUpgrade(newImplementation); _upgradeToAndCallSecure(newImplementation, new bytes(0), false); } /** * @dev Upgrade the implementation of the proxy to `newImplementation`, and subsequently execute the function call * encoded in `data`. * * Calls {_authorizeUpgrade}. * * Emits an {Upgraded} event. */ function upgradeToAndCall(address newImplementation, bytes memory data) external payable virtual onlyProxy { _authorizeUpgrade(newImplementation); _upgradeToAndCallSecure(newImplementation, data, true); } /** * @dev Function that should revert when `msg.sender` is not authorized to upgrade the contract. Called by * {upgradeTo} and {upgradeToAndCall}. * * Normally, this function will use an xref:access.adoc[access control] modifier such as {Ownable-onlyOwner}. * * ```solidity * function _authorizeUpgrade(address) internal override onlyOwner {} * ``` */ function _authorizeUpgrade(address newImplementation) internal virtual; uint256[50] private __gap; }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /** * @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. */ 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() { require(_initializing || !_initialized, "Initializable: contract is already initialized"); bool isTopLevelCall = !_initializing; if (isTopLevelCall) { _initializing = true; _initialized = true; } _; if (isTopLevelCall) { _initializing = false; } } }
// SPDX-License-Identifier: MIT pragma solidity >=0.8.0; import "../DAOStackInterfaces.sol"; import "../Interfaces.sol"; /** @title Simple contract that keeps DAO contracts registery */ contract DAOContract { Controller public dao; address public avatar; INameService public nameService; function _onlyAvatar() internal view { require( address(dao.avatar()) == msg.sender, "only avatar can call this method" ); } function setDAO(INameService _ns) internal { nameService = _ns; updateAvatar(); } function updateAvatar() public { dao = Controller(nameService.getAddress("CONTROLLER")); avatar = dao.avatar(); } function nativeToken() public view returns (IGoodDollar) { return IGoodDollar(nameService.getAddress("GOODDOLLAR")); } uint256[50] private gap; }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.2; import "../beacon/IBeaconUpgradeable.sol"; import "../../utils/AddressUpgradeable.sol"; import "../../utils/StorageSlotUpgradeable.sol"; import "../utils/Initializable.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 ERC1967UpgradeUpgradeable is Initializable { function __ERC1967Upgrade_init() internal initializer { __ERC1967Upgrade_init_unchained(); } function __ERC1967Upgrade_init_unchained() internal initializer { } // 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 StorageSlotUpgradeable.getAddressSlot(_IMPLEMENTATION_SLOT).value; } /** * @dev Stores a new address in the EIP1967 implementation slot. */ function _setImplementation(address newImplementation) private { require(AddressUpgradeable.isContract(newImplementation), "ERC1967: new implementation is not a contract"); StorageSlotUpgradeable.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) { _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) { _functionDelegateCall(newImplementation, data); } // Perform rollback test if not already in progress StorageSlotUpgradeable.BooleanSlot storage rollbackTesting = StorageSlotUpgradeable.getBooleanSlot(_ROLLBACK_SLOT); if (!rollbackTesting.value) { // Trigger rollback using upgradeTo from the new implementation rollbackTesting.value = true; _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 StorageSlotUpgradeable.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"); StorageSlotUpgradeable.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 StorageSlotUpgradeable.getAddressSlot(_BEACON_SLOT).value; } /** * @dev Stores a new beacon in the EIP1967 beacon slot. */ function _setBeacon(address newBeacon) private { require(AddressUpgradeable.isContract(newBeacon), "ERC1967: new beacon is not a contract"); require( AddressUpgradeable.isContract(IBeaconUpgradeable(newBeacon).implementation()), "ERC1967: beacon implementation is not a contract" ); StorageSlotUpgradeable.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) { _functionDelegateCall(IBeaconUpgradeable(newBeacon).implementation(), data); } } /** * @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) private returns (bytes memory) { require(AddressUpgradeable.isContract(target), "Address: delegate call to non-contract"); // solhint-disable-next-line avoid-low-level-calls (bool success, bytes memory returndata) = target.delegatecall(data); return AddressUpgradeable.verifyCallResult(success, returndata, "Address: low-level delegate call failed"); } uint256[50] private __gap; }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /** * @dev This is the interface that {BeaconProxy} expects of its beacon. */ interface IBeaconUpgradeable { /** * @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); }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /** * @dev Collection of functions related to the address type */ library AddressUpgradeable { /** * @dev Returns true if `account` is a contract. * * [IMPORTANT] * ==== * It is unsafe to assume that an address for which this function returns * false is an externally-owned account (EOA) and not a contract. * * Among others, `isContract` will return false for the following * types of addresses: * * - an externally-owned account * - a contract in construction * - an address where a contract will be created * - an address where a contract lived, but was destroyed * ==== */ function isContract(address account) internal view returns (bool) { // This method relies on extcodesize, which returns 0 for contracts in // construction, since the code is only stored at the end of the // constructor execution. uint256 size; assembly { size := extcodesize(account) } return size > 0; } /** * @dev Replacement for Solidity's `transfer`: sends `amount` wei to * `recipient`, forwarding all available gas and reverting on errors. * * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost * of certain opcodes, possibly making contracts go over the 2300 gas limit * imposed by `transfer`, making them unable to receive funds via * `transfer`. {sendValue} removes this limitation. * * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more]. * * IMPORTANT: because control is transferred to `recipient`, care must be * taken to not create reentrancy vulnerabilities. Consider using * {ReentrancyGuard} or the * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. */ function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, "Address: insufficient balance"); (bool success, ) = recipient.call{value: amount}(""); require(success, "Address: unable to send value, recipient may have reverted"); } /** * @dev Performs a Solidity function call using a low level `call`. A * plain `call` is an unsafe replacement for a function call: use this * function instead. * * If `target` reverts with a revert reason, it is bubbled up by this * function (like regular Solidity function calls). * * Returns the raw returned data. To convert to the expected return value, * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`]. * * Requirements: * * - `target` must be a contract. * - calling `target` with `data` must not revert. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCall(target, data, "Address: low-level call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with * `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { return functionCallWithValue(target, data, 0, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but also transferring `value` wei to `target`. * * Requirements: * * - the calling contract must have an ETH balance of at least `value`. * - the called Solidity function must be `payable`. * * _Available since v3.1._ */ function functionCallWithValue( address target, bytes memory data, uint256 value ) internal returns (bytes memory) { return functionCallWithValue(target, data, value, "Address: low-level call with value failed"); } /** * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but * with `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCallWithValue( address target, bytes memory data, uint256 value, string memory errorMessage ) internal returns (bytes memory) { require(address(this).balance >= value, "Address: insufficient balance for call"); require(isContract(target), "Address: call to non-contract"); (bool success, bytes memory returndata) = target.call{value: value}(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) { return functionStaticCall(target, data, "Address: low-level static call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall( address target, bytes memory data, string memory errorMessage ) internal view returns (bytes memory) { require(isContract(target), "Address: static call to non-contract"); (bool success, bytes memory returndata) = target.staticcall(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the * revert reason using the provided one. * * _Available since v4.3._ */ function verifyCallResult( bool success, bytes memory returndata, string memory errorMessage ) internal pure returns (bytes memory) { if (success) { return returndata; } else { // Look for revert reason and bubble it up if present if (returndata.length > 0) { // The easiest way to bubble the revert reason is using memory via assembly assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } } }
// SPDX-License-Identifier: MIT 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 StorageSlotUpgradeable { 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 } } }
// SPDX-License-Identifier: MIT pragma solidity >=0.8.0; interface Avatar { function nativeToken() external view returns (address); function nativeReputation() external view returns (address); function owner() external view returns (address); } interface Controller { event RegisterScheme(address indexed _sender, address indexed _scheme); event UnregisterScheme(address indexed _sender, address indexed _scheme); function genericCall( address _contract, bytes calldata _data, address _avatar, uint256 _value ) external returns (bool, bytes memory); function avatar() external view returns (address); function unregisterScheme(address _scheme, address _avatar) external returns (bool); function unregisterSelf(address _avatar) external returns (bool); function registerScheme( address _scheme, bytes32 _paramsHash, bytes4 _permissions, address _avatar ) external returns (bool); function isSchemeRegistered(address _scheme, address _avatar) external view returns (bool); function getSchemePermissions(address _scheme, address _avatar) external view returns (bytes4); function addGlobalConstraint( address _constraint, bytes32 _paramHash, address _avatar ) external returns (bool); function mintTokens( uint256 _amount, address _beneficiary, address _avatar ) external returns (bool); function externalTokenTransfer( address _token, address _recipient, uint256 _amount, address _avatar ) external returns (bool); function sendEther( uint256 _amountInWei, address payable _to, address _avatar ) external returns (bool); } interface GlobalConstraintInterface { enum CallPhase { Pre, Post, PreAndPost } function pre( address _scheme, bytes32 _params, bytes32 _method ) external returns (bool); /** * @dev when return if this globalConstraints is pre, post or both. * @return CallPhase enum indication Pre, Post or PreAndPost. */ function when() external returns (CallPhase); } interface ReputationInterface { function balanceOf(address _user) external view returns (uint256); function balanceOfAt(address _user, uint256 _blockNumber) external view returns (uint256); function getVotes(address _user) external view returns (uint256); function getVotesAt( address _user, bool _global, uint256 _blockNumber ) external view returns (uint256); function totalSupply() external view returns (uint256); function totalSupplyAt(uint256 _blockNumber) external view returns (uint256); function delegateOf(address _user) external returns (address); } interface SchemeRegistrar { function proposeScheme( Avatar _avatar, address _scheme, bytes32 _parametersHash, bytes4 _permissions, string memory _descriptionHash ) external returns (bytes32); event NewSchemeProposal( address indexed _avatar, bytes32 indexed _proposalId, address indexed _intVoteInterface, address _scheme, bytes32 _parametersHash, bytes4 _permissions, string _descriptionHash ); } interface IntVoteInterface { event NewProposal( bytes32 indexed _proposalId, address indexed _organization, uint256 _numOfChoices, address _proposer, bytes32 _paramsHash ); event ExecuteProposal( bytes32 indexed _proposalId, address indexed _organization, uint256 _decision, uint256 _totalReputation ); event VoteProposal( bytes32 indexed _proposalId, address indexed _organization, address indexed _voter, uint256 _vote, uint256 _reputation ); event CancelProposal( bytes32 indexed _proposalId, address indexed _organization ); event CancelVoting( bytes32 indexed _proposalId, address indexed _organization, address indexed _voter ); /** * @dev register a new proposal with the given parameters. Every proposal has a unique ID which is being * generated by calculating keccak256 of a incremented counter. * @param _numOfChoices number of voting choices * @param _proposalParameters defines the parameters of the voting machine used for this proposal * @param _proposer address * @param _organization address - if this address is zero the msg.sender will be used as the organization address. * @return proposal's id. */ function propose( uint256 _numOfChoices, bytes32 _proposalParameters, address _proposer, address _organization ) external returns (bytes32); function vote( bytes32 _proposalId, uint256 _vote, uint256 _rep, address _voter ) external returns (bool); function cancelVote(bytes32 _proposalId) external; function getNumberOfChoices(bytes32 _proposalId) external view returns (uint256); function isVotable(bytes32 _proposalId) external view returns (bool); /** * @dev voteStatus returns the reputation voted for a proposal for a specific voting choice. * @param _proposalId the ID of the proposal * @param _choice the index in the * @return voted reputation for the given choice */ function voteStatus(bytes32 _proposalId, uint256 _choice) external view returns (uint256); /** * @dev isAbstainAllow returns if the voting machine allow abstain (0) * @return bool true or false */ function isAbstainAllow() external pure returns (bool); /** * @dev getAllowedRangeOfChoices returns the allowed range of choices for a voting machine. * @return min - minimum number of choices max - maximum number of choices */ function getAllowedRangeOfChoices() external pure returns (uint256 min, uint256 max); }
// SPDX-License-Identifier: MIT pragma solidity >=0.8.0; library DataTypes { // refer to the whitepaper, section 1.1 basic concepts for a formal description of these properties. struct ReserveData { //stores the reserve configuration ReserveConfigurationMap configuration; //the liquidity index. Expressed in ray uint128 liquidityIndex; //variable borrow index. Expressed in ray uint128 variableBorrowIndex; //the current supply rate. Expressed in ray uint128 currentLiquidityRate; //the current variable borrow rate. Expressed in ray uint128 currentVariableBorrowRate; //the current stable borrow rate. Expressed in ray uint128 currentStableBorrowRate; uint40 lastUpdateTimestamp; //tokens addresses address aTokenAddress; address stableDebtTokenAddress; address variableDebtTokenAddress; //address of the interest rate strategy address interestRateStrategyAddress; //the id of the reserve. Represents the position in the list of the active reserves uint8 id; } struct ReserveConfigurationMap { //bit 0-15: LTV //bit 16-31: Liq. threshold //bit 32-47: Liq. bonus //bit 48-55: Decimals //bit 56: Reserve is active //bit 57: reserve is frozen //bit 58: borrowing is enabled //bit 59: stable rate borrowing enabled //bit 60-63: reserved //bit 64-79: reserve factor uint256 data; } enum InterestRateMode { NONE, STABLE, VARIABLE } }
// SPDX-License-Identifier: MIT pragma solidity >=0.8.0; import "./Reputation.sol"; import "../Interfaces.sol"; /** * @title GReputation extends Reputation with delegation and cross blockchain merkle states * @dev NOTICE: this breaks DAOStack nativeReputation usage, since it is not possiible to upgrade * the original nativeReputation token. it means you can no longer rely on avatar.nativeReputation() or controller.nativeReputation() * to return the current reputation token. * The DAO avatar will be the owner of this reputation token and not the Controller. * Minting by the DAO will be done using controller.genericCall and not via controller.mintReputation */ contract GReputation is Reputation { bytes32 public constant ROOT_STATE = keccak256("rootState"); /// @notice The EIP-712 typehash for the contract's domain bytes32 public constant DOMAIN_TYPEHASH = keccak256( "EIP712Domain(string name,uint256 chainId,address verifyingContract)" ); /// @notice The EIP-712 typehash for the delegation struct used by the contract bytes32 public constant DELEGATION_TYPEHASH = keccak256("Delegation(address delegate,uint256 nonce,uint256 expiry)"); /// @notice describe a single blockchain states /// @param stateHash the hash with the reputation state /// @param hashType the type of hash. currently just 0 = merkle tree root hash /// @param totalSupply the totalSupply at the blockchain /// @param blockNumber the effective blocknumber struct BlockchainState { bytes32 stateHash; uint256 hashType; uint256 totalSupply; uint256 blockNumber; uint256[5] __reserevedSpace; } /// @notice A record of states for signing / validating signatures mapping(address => uint256) public nonces; /// @notice mapping from blockchain id hash to list of states mapping(bytes32 => BlockchainState[]) public blockchainStates; /// @notice mapping from stateHash to the user balance can be >0 only after supplying state proof mapping(bytes32 => mapping(address => uint256)) public stateHashBalances; /// @notice list of blockchains having a statehash for easy iteration bytes32[] public activeBlockchains; /// @notice keep map of user -> delegate mapping(address => address) public delegates; /// @notice map of user non delegated + delegated votes to user. this is used for actual voting mapping(address => uint256[]) public activeVotes; /// @notice keep map of address -> reputation recipient, an address can set that its earned rep will go to another address mapping(address => address) public reputationRecipients; /// @notice An event thats emitted when a delegate account's vote balance changes event DelegateVotesChanged( address indexed delegate, address indexed delegator, uint256 previousBalance, uint256 newBalance ); event StateHash(string blockchain, bytes32 merkleRoot, uint256 totalSupply); event StateHashProof( string blockchain, address indexed user, uint256 repBalance ); /** * @dev initialize */ function initialize( INameService _ns, string calldata _stateId, bytes32 _stateHash, uint256 _totalSupply ) external initializer { __Reputation_init(_ns); if (_totalSupply > 0) _setBlockchainStateHash(_stateId, _stateHash, _totalSupply); } function updateDAO(INameService _ns) public { if (address(nameService) == address(0)) { setDAO(_ns); _setupRole(DEFAULT_ADMIN_ROLE, address(avatar)); _setupRole(MINTER_ROLE, address(avatar)); } } function _canMint() internal view override { require( _msgSender() == nameService.getAddress("GDAO_CLAIMERS") || _msgSender() == nameService.getAddress("GDAO_STAKING") || _msgSender() == nameService.getAddress("GDAO_STAKERS") || hasRole(MINTER_ROLE, _msgSender()), "GReputation: need minter role or be GDAO contract" ); } function _mint(address _user, uint256 _amount) internal override returns (uint256) { return _mint(_user, _amount, false); } /// @notice internal function that overrides Reputation.sol with consideration to delegation /// @param _user the address to mint for /// @param _amount the amount of rep to mint /// @return the actual amount minted function _mint( address _user, uint256 _amount, bool ignoreRepTarget ) internal returns (uint256) { address repTarget = reputationRecipients[_user]; repTarget = ignoreRepTarget == false && repTarget != address(0) ? repTarget : _user; super._mint(repTarget, _amount); //set self as initial delegator address delegator = delegates[repTarget]; if (delegator == address(0)) { delegates[repTarget] = repTarget; delegator = repTarget; } uint256 previousVotes = getVotesAt(delegator, false, block.number); _updateDelegateVotes( delegator, repTarget, previousVotes, previousVotes + _amount ); return _amount; } /// @notice internal function that overrides Reputation.sol with consideration to delegation /// @param _user the address to burn from /// @param _amount the amount of rep to mint /// @return the actual amount burned function _burn(address _user, uint256 _amount) internal override returns (uint256) { uint256 amountBurned = super._burn(_user, _amount); address delegator = delegates[_user]; delegator = delegator != address(0) ? delegator : _user; delegates[_user] = delegator; uint256 previousVotes = getVotesAt(delegator, false, block.number); _updateDelegateVotes( delegator, _user, previousVotes, previousVotes - amountBurned ); return amountBurned; } /// @notice sets the state hash of a blockchain, can only be called by owner /// @param _id the string name of the blockchain (will be hashed to produce byte32 id) /// @param _hash the state hash /// @param _totalSupply total supply of reputation on the specific blockchain function setBlockchainStateHash( string memory _id, bytes32 _hash, uint256 _totalSupply ) public { _onlyAvatar(); _setBlockchainStateHash(_id, _hash, _totalSupply); } /// @notice sets the state hash of a blockchain, can only be called by owner /// @param _id the string name of the blockchain (will be hashed to produce byte32 id) /// @param _hash the state hash /// @param _totalSupply total supply of reputation on the specific blockchain function _setBlockchainStateHash( string memory _id, bytes32 _hash, uint256 _totalSupply ) internal { bytes32 idHash = keccak256(bytes(_id)); //dont consider rootState as blockchain, it is a special state hash bool isRootState = idHash == ROOT_STATE; require( !isRootState || totalSupplyLocalAt(block.number) == 0, "rootState already created" ); if (isRootState) { updateValueAtNow(totalSupplyHistory, _totalSupply); } uint256 i = 0; for (; !isRootState && i < activeBlockchains.length; i++) { if (activeBlockchains[i] == idHash) break; } //if new blockchain if (!isRootState && i == activeBlockchains.length) { activeBlockchains.push(idHash); } BlockchainState memory state; state.stateHash = _hash; state.totalSupply = _totalSupply; state.blockNumber = block.number; blockchainStates[idHash].push(state); emit StateHash(_id, _hash, _totalSupply); } /// @notice get the number of active votes a user holds after delegation (vs the basic balance of reputation he holds) /// @param _user the user to get active votes for /// @param _global wether to include reputation from other blockchains /// @param _blockNumber get votes state at specific block /// @return the number of votes function getVotesAt( address _user, bool _global, uint256 _blockNumber ) public view returns (uint256) { uint256 startingBalance = getValueAt(activeVotes[_user], _blockNumber); if (_global) { for (uint256 i = 0; i < activeBlockchains.length; i++) { startingBalance += getVotesAtBlockchain( activeBlockchains[i], _user, _blockNumber ); } } return startingBalance; } /** * @notice returns aggregated active votes in all blockchains and delegated * @param _user the user to get active votes for * @return the number of votes */ function getVotes(address _user) public view returns (uint256) { return getVotesAt(_user, true, block.number); } /** * @notice same as getVotes, be compatible with metamask */ function balanceOf(address _user) public view returns (uint256 balance) { return getVotesAt(_user, block.number); } /** same as getVotes be compatible with compound */ function getCurrentVotes(address _user) public view returns (uint256) { return getVotesAt(_user, true, block.number); } function getPriorVotes(address _user, uint256 _block) public view returns (uint256) { return getVotesAt(_user, true, _block); } /** * @notice returns aggregated active votes in all blockchains and delegated at specific block * @param _user user to get active votes for * @param _blockNumber get votes state at specific block * @return the number of votes */ function getVotesAt(address _user, uint256 _blockNumber) public view returns (uint256) { return getVotesAt(_user, true, _blockNumber); } /** * @notice returns total supply in current blockchain * @param _blockNumber get total supply at specific block * @return the totaly supply */ function totalSupplyLocal(uint256 _blockNumber) public view returns (uint256) { return totalSupplyLocalAt(_blockNumber); } /** * @notice returns total supply in all blockchain aggregated * @param _blockNumber get total supply at specific block * @return the totaly supply */ function totalSupplyAt(uint256 _blockNumber) public view returns (uint256) { uint256 startingSupply = totalSupplyLocalAt(_blockNumber); for (uint256 i = 0; i < activeBlockchains.length; i++) { startingSupply += totalSupplyAtBlockchain( activeBlockchains[i], _blockNumber ); } return startingSupply; } /// @dev This function makes it easy to get the total number of reputation /// @return The total number of reputation function totalSupply() public view returns (uint256) { return totalSupplyAt(block.number); } /// @notice get the number of active votes a user holds after delegation in specific blockchain /// @param _id the keccak hash of the blockchain string id /// @param _user the user to get active votes for /// @param _blockNumber get votes state at specific block /// @return the number of votes function getVotesAtBlockchain( bytes32 _id, address _user, uint256 _blockNumber ) public view returns (uint256) { BlockchainState[] storage states = blockchainStates[_id]; int256 i = int256(states.length); if (i == 0) return 0; BlockchainState storage state = states[uint256(i - 1)]; for (i = i - 1; i >= 0; i--) { if (state.blockNumber <= _blockNumber) break; state = states[uint256(i - 1)]; } if (i < 0) return 0; return stateHashBalances[state.stateHash][_user]; } /** * @notice returns total supply in a specific blockchain * @param _blockNumber get total supply at specific block * @return the totaly supply */ function totalSupplyAtBlockchain(bytes32 _id, uint256 _blockNumber) public view returns (uint256) { BlockchainState[] storage states = blockchainStates[_id]; int256 i; if (states.length == 0) return 0; for (i = int256(states.length - 1); i >= 0; i--) { if (states[uint256(i)].blockNumber <= _blockNumber) break; } if (i < 0) return 0; BlockchainState storage state = states[uint256(i)]; return state.totalSupply; } /** * @notice prove user balance in a specific blockchain state hash * @dev "rootState" is a special state that can be supplied once, and actually mints reputation on the current blockchain * we use non sorted merkle tree, as sorting while preparing merkle tree is heavy * @param _id the string id of the blockchain we supply proof for * @param _user the user to prove his balance * @param _balance the balance we are prooving * @param _proof array of byte32 with proof data (currently merkle tree path) * @param _nodeIndex index of node in the tree (for unsorted merkle tree proof) * @return true if proof is valid */ function proveBalanceOfAtBlockchain( string memory _id, address _user, uint256 _balance, bytes32[] memory _proof, uint256 _nodeIndex ) public returns (bool) { bytes32 idHash = keccak256(bytes(_id)); require( blockchainStates[idHash].length > 0, "no state found for given _id" ); bytes32 stateHash = blockchainStates[idHash][ blockchainStates[idHash].length - 1 ].stateHash; //this is specifically important for rootState that should update real balance only once require( stateHashBalances[stateHash][_user] == 0, "stateHash already proved" ); bytes32 leafHash = keccak256(abi.encode(_user, _balance)); bool isProofValid = checkProofOrdered( _proof, stateHash, leafHash, _nodeIndex ); require(isProofValid, "invalid merkle proof"); //if initiial state then set real balance if (idHash == ROOT_STATE) { uint256 curTotalSupply = totalSupplyLocalAt(block.number); // on proof for ROOT_HASH we force to ignore the repTarget, so it is the same wallet address receiving the reputation (prevent double voting power on snapshot) // also it should behave the same as blockchain sync proof which also doesnt use repTarget, but updates the same address as in the proof _mint(_user, _balance, true); updateValueAtNow(totalSupplyHistory, curTotalSupply); // we undo the totalsupply, as we alredy set the totalsupply of the airdrop } //if proof is valid then set balances stateHashBalances[stateHash][_user] = _balance; emit StateHashProof(_id, _user, _balance); return true; } /// @notice returns current delegate of _user /// @param _user the delegatee /// @return the address of the delegate (can be _user if no delegate or 0x0 if _user doesnt exists) function delegateOf(address _user) public view returns (address) { return delegates[_user]; } /// @notice delegate votes to another user /// @param _delegate the recipient of votes function delegateTo(address _delegate) public { return _delegateTo(_msgSender(), _delegate); } /// @notice cancel user delegation /// @dev makes user his own delegate function undelegate() public { return _delegateTo(_msgSender(), _msgSender()); } /** * @notice Delegates votes from signatory to `delegate` * @param _delegate The address to delegate votes to * @param _nonce The contract state required to match the signature * @param _expiry The time at which to expire the signature * @param _v The recovery byte of the signature * @param _r Half of the ECDSA signature pair * @param _s Half of the ECDSA signature pair */ function delegateBySig( address _delegate, uint256 _nonce, uint256 _expiry, uint8 _v, bytes32 _r, bytes32 _s ) public { bytes32 domainSeparator = keccak256( abi.encode( DOMAIN_TYPEHASH, keccak256(bytes(name)), getChainId(), address(this) ) ); bytes32 structHash = keccak256( abi.encode(DELEGATION_TYPEHASH, _delegate, _nonce, _expiry) ); bytes32 digest = keccak256( abi.encodePacked("\x19\x01", domainSeparator, structHash) ); address signatory = ecrecover(digest, _v, _r, _s); require( signatory != address(0), "GReputation::delegateBySig: invalid signature" ); require( _nonce == nonces[signatory]++, "GReputation::delegateBySig: invalid nonce" ); require( block.timestamp <= _expiry, "GReputation::delegateBySig: signature expired" ); return _delegateTo(signatory, _delegate); } /// @notice internal function to delegate votes to another user /// @param _user the source of votes (delegator) /// @param _delegate the recipient of votes function _delegateTo(address _user, address _delegate) internal { require( _delegate != address(0), "GReputation::delegate can't delegate to null address" ); address curDelegator = delegates[_user]; require(curDelegator != _delegate, "already delegating to delegator"); delegates[_user] = _delegate; // remove votes from current delegator uint256 coreBalance = balanceOfLocalAt(_user, block.number); //redundant check - should not be possible to have address 0 as delegator if (curDelegator != address(0)) { uint256 removeVotes = getVotesAt(curDelegator, false, block.number); _updateDelegateVotes( curDelegator, _user, removeVotes, removeVotes - coreBalance ); } //move votes to new delegator uint256 addVotes = getVotesAt(_delegate, false, block.number); _updateDelegateVotes(_delegate, _user, addVotes, addVotes + coreBalance); } /// @notice internal function to update delegated votes, emits event with changes /// @param _delegate the delegate whose record we are updating /// @param _delegator the delegator /// @param _oldVotes the delegate previous votes /// @param _newVotes the delegate votes after the change function _updateDelegateVotes( address _delegate, address _delegator, uint256 _oldVotes, uint256 _newVotes ) internal { updateValueAtNow(activeVotes[_delegate], _newVotes); emit DelegateVotesChanged(_delegate, _delegator, _oldVotes, _newVotes); } // from StorJ -- https://github.com/nginnever/storj-audit-verifier/blob/master/contracts/MerkleVerifyv3.sol /** * @dev non sorted merkle tree proof check */ function checkProofOrdered( bytes32[] memory _proof, bytes32 _root, bytes32 _hash, uint256 _index ) public pure returns (bool) { // use the index to determine the node ordering // index ranges 1 to n bytes32 proofElement; bytes32 computedHash = _hash; uint256 remaining; for (uint256 j = 0; j < _proof.length; j++) { proofElement = _proof[j]; // calculate remaining elements in proof remaining = _proof.length - j; // we don't assume that the tree is padded to a power of 2 // if the index is odd then the proof will start with a hash at a higher // layer, so we have to adjust the index to be the index at that layer while (remaining > 0 && _index % 2 == 1 && _index > 2**remaining) { _index = _index / 2 + 1; } if (_index % 2 == 0) { computedHash = keccak256(abi.encodePacked(proofElement, computedHash)); _index = _index / 2; } else { computedHash = keccak256(abi.encodePacked(computedHash, proofElement)); _index = _index / 2 + 1; } } return computedHash == _root; } /// @notice helper function to get current chain id /// @return chain id function getChainId() internal view returns (uint256) { uint256 chainId; assembly { chainId := chainid() } return chainId; } function setReputationRecipient(address _target) public { reputationRecipients[msg.sender] = _target; } }
// SPDX-License-Identifier: GPL-3.0 pragma solidity >=0.8.0; import "@openzeppelin/contracts-upgradeable/access/AccessControlUpgradeable.sol"; import "../utils/DAOUpgradeableContract.sol"; /** * based on https://github.com/daostack/infra/blob/60a79a1be02942174e21156c3c9655a7f0695dbd/contracts/Reputation.sol * @title Reputation system * @dev A DAO has Reputation System which allows peers to rate other peers in order to build trust . * A reputation is used to assign influence measure to a DAO'S peers. * Reputation is similar to regular tokens but with one crucial difference: It is non-transferable. * The Reputation contract maintain a map of address to reputation value. * It provides an only minter role functions to mint and burn reputation _to (or _from) a specific address. */ contract Reputation is DAOUpgradeableContract, AccessControlUpgradeable { bytes32 public constant MINTER_ROLE = keccak256("MINTER_ROLE"); string public name; string public symbol; uint8 public decimals; //Number of decimals of the smallest unit // Event indicating minting of reputation to an address. event Mint(address indexed _to, uint256 _amount); // Event indicating burning of reputation for an address. event Burn(address indexed _from, uint256 _amount); uint256 private constant ZERO_HALF_256 = 0xffffffffffffffffffffffffffffffff; /// @dev `Checkpoint` is the structure that attaches a block number to a /// given value, the block number attached is the one that last changed the /// value //Checkpoint is uint256 : // bits 0-127 `fromBlock` is the block number that the value was generated from // bits 128-255 `value` is the amount of reputation at a specific block number // `balances` is the map that tracks the balance of each address, in this // contract when the balance changes the block number that the change // occurred is also included in the map mapping(address => uint256[]) public balances; // Tracks the history of the `totalSupply` of the reputation uint256[] public totalSupplyHistory; /** * @dev initialize */ function initialize(INameService _ns) public initializer { __Reputation_init(_ns); } function __Reputation_init(INameService _ns) internal { decimals = 18; name = "GoodDAO"; symbol = "GOOD"; __Context_init_unchained(); __ERC165_init_unchained(); __AccessControl_init_unchained(); if (address(_ns) != address(0)) { setDAO(_ns); _setupRole(DEFAULT_ADMIN_ROLE, address(avatar)); _setupRole(MINTER_ROLE, address(avatar)); } } function _canMint() internal view virtual { require(hasRole(MINTER_ROLE, _msgSender()), "Reputation: need minter role"); } /// @notice Generates `_amount` reputation that are assigned to `_owner` /// @param _user The address that will be assigned the new reputation /// @param _amount The quantity of reputation generated /// @return True if the reputation are generated correctly function mint(address _user, uint256 _amount) public returns (bool) { _canMint(); _mint(_user, _amount); return true; } function _mint(address _user, uint256 _amount) internal virtual returns (uint256) { uint256 curTotalSupply = totalSupplyLocalAt(block.number); uint256 previousBalanceTo = balanceOfLocalAt(_user, block.number); updateValueAtNow(totalSupplyHistory, curTotalSupply + _amount); updateValueAtNow(balances[_user], previousBalanceTo + _amount); emit Mint(_user, _amount); return _amount; } /// @notice Burns `_amount` reputation from `_owner` /// @param _user The address that will lose the reputation /// @param _amount The quantity of reputation to burn /// @return True if the reputation are burned correctly function burn(address _user, uint256 _amount) public returns (bool) { //user can burn his own rep other wise we check _canMint if (_user != _msgSender()) _canMint(); _burn(_user, _amount); return true; } function _burn(address _user, uint256 _amount) internal virtual returns (uint256) { uint256 curTotalSupply = totalSupplyLocalAt(block.number); uint256 amountBurned = _amount; uint256 previousBalanceFrom = balanceOfLocalAt(_user, block.number); if (previousBalanceFrom < amountBurned) { amountBurned = previousBalanceFrom; } updateValueAtNow(totalSupplyHistory, curTotalSupply - amountBurned); updateValueAtNow(balances[_user], previousBalanceFrom - amountBurned); emit Burn(_user, amountBurned); return amountBurned; } function balanceOfLocal(address _owner) public view returns (uint256) { return balanceOfLocalAt(_owner, block.number); } /// @dev Queries the balance of `_owner` at a specific `_blockNumber` /// @param _owner The address from which the balance will be retrieved /// @param _blockNumber The block number when the balance is queried /// @return The balance at `_blockNumber` function balanceOfLocalAt(address _owner, uint256 _blockNumber) public view virtual returns (uint256) { if ( (balances[_owner].length == 0) || (uint128(balances[_owner][0]) > _blockNumber) ) { return 0; // This will return the expected balance during normal situations } else { return getValueAt(balances[_owner], _blockNumber); } } function totalSupplyLocal() public view virtual returns (uint256) { return totalSupplyLocalAt(block.number); } /// @notice Total amount of reputation at a specific `_blockNumber`. /// @param _blockNumber The block number when the totalSupply is queried /// @return The total amount of reputation at `_blockNumber` function totalSupplyLocalAt(uint256 _blockNumber) public view virtual returns (uint256) { if ( (totalSupplyHistory.length == 0) || (uint128(totalSupplyHistory[0]) > _blockNumber) ) { return 0; // This will return the expected totalSupply during normal situations } else { return getValueAt(totalSupplyHistory, _blockNumber); } } //////////////// // Internal helper functions to query and set a value in a snapshot array //////////////// /// @dev `getValueAt` retrieves the number of reputation at a given block number /// @param checkpoints The history of values being queried /// @param _block The block number to retrieve the value at /// @return The number of reputation being queried function getValueAt(uint256[] storage checkpoints, uint256 _block) internal view returns (uint256) { uint256 len = checkpoints.length; if (len == 0) { return 0; } // Shortcut for the actual value uint256 cur = checkpoints[len - 1]; if (_block >= uint128(cur)) { return cur >> 128; } if (_block < uint128(checkpoints[0])) { return 0; } // Binary search of the value in the array uint256 min = 0; uint256 max = len - 1; while (max > min) { uint256 mid = (max + min + 1) / 2; if (uint128(checkpoints[mid]) <= _block) { min = mid; } else { max = mid - 1; } } return checkpoints[min] >> 128; } /// @dev `updateValueAtNow` used to update the `balances` map and the /// `totalSupplyHistory` /// @param checkpoints The history of data being updated /// @param _value The new number of reputation function updateValueAtNow(uint256[] storage checkpoints, uint256 _value) internal { require(uint128(_value) == _value, "reputation overflow"); //check value is in the 128 bits bounderies if ( (checkpoints.length == 0) || (uint128(checkpoints[checkpoints.length - 1]) < block.number) ) { checkpoints.push(uint256(uint128(block.number)) | (_value << 128)); } else { checkpoints[checkpoints.length - 1] = uint256( (checkpoints[checkpoints.length - 1] & uint256(ZERO_HALF_256)) | (_value << 128) ); } } }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "./IAccessControlUpgradeable.sol"; import "../utils/ContextUpgradeable.sol"; import "../utils/StringsUpgradeable.sol"; import "../utils/introspection/ERC165Upgradeable.sol"; import "../proxy/utils/Initializable.sol"; /** * @dev Contract module that allows children to implement role-based access * control mechanisms. This is a lightweight version that doesn't allow enumerating role * members except through off-chain means by accessing the contract event logs. Some * applications may benefit from on-chain enumerability, for those cases see * {AccessControlEnumerable}. * * Roles are referred to by their `bytes32` identifier. These should be exposed * in the external API and be unique. The best way to achieve this is by * using `public constant` hash digests: * * ``` * bytes32 public constant MY_ROLE = keccak256("MY_ROLE"); * ``` * * Roles can be used to represent a set of permissions. To restrict access to a * function call, use {hasRole}: * * ``` * function foo() public { * require(hasRole(MY_ROLE, msg.sender)); * ... * } * ``` * * Roles can be granted and revoked dynamically via the {grantRole} and * {revokeRole} functions. Each role has an associated admin role, and only * accounts that have a role's admin role can call {grantRole} and {revokeRole}. * * By default, the admin role for all roles is `DEFAULT_ADMIN_ROLE`, which means * that only accounts with this role will be able to grant or revoke other * roles. More complex role relationships can be created by using * {_setRoleAdmin}. * * WARNING: The `DEFAULT_ADMIN_ROLE` is also its own admin: it has permission to * grant and revoke this role. Extra precautions should be taken to secure * accounts that have been granted it. */ abstract contract AccessControlUpgradeable is Initializable, ContextUpgradeable, IAccessControlUpgradeable, ERC165Upgradeable { function __AccessControl_init() internal initializer { __Context_init_unchained(); __ERC165_init_unchained(); __AccessControl_init_unchained(); } function __AccessControl_init_unchained() internal initializer { } struct RoleData { mapping(address => bool) members; bytes32 adminRole; } mapping(bytes32 => RoleData) private _roles; bytes32 public constant DEFAULT_ADMIN_ROLE = 0x00; /** * @dev Modifier that checks that an account has a specific role. Reverts * with a standardized message including the required role. * * The format of the revert reason is given by the following regular expression: * * /^AccessControl: account (0x[0-9a-f]{40}) is missing role (0x[0-9a-f]{64})$/ * * _Available since v4.1._ */ modifier onlyRole(bytes32 role) { _checkRole(role, _msgSender()); _; } /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { return interfaceId == type(IAccessControlUpgradeable).interfaceId || super.supportsInterface(interfaceId); } /** * @dev Returns `true` if `account` has been granted `role`. */ function hasRole(bytes32 role, address account) public view override returns (bool) { return _roles[role].members[account]; } /** * @dev Revert with a standard message if `account` is missing `role`. * * The format of the revert reason is given by the following regular expression: * * /^AccessControl: account (0x[0-9a-f]{40}) is missing role (0x[0-9a-f]{64})$/ */ function _checkRole(bytes32 role, address account) internal view { if (!hasRole(role, account)) { revert( string( abi.encodePacked( "AccessControl: account ", StringsUpgradeable.toHexString(uint160(account), 20), " is missing role ", StringsUpgradeable.toHexString(uint256(role), 32) ) ) ); } } /** * @dev Returns the admin role that controls `role`. See {grantRole} and * {revokeRole}. * * To change a role's admin, use {_setRoleAdmin}. */ function getRoleAdmin(bytes32 role) public view override returns (bytes32) { return _roles[role].adminRole; } /** * @dev Grants `role` to `account`. * * If `account` had not been already granted `role`, emits a {RoleGranted} * event. * * Requirements: * * - the caller must have ``role``'s admin role. */ function grantRole(bytes32 role, address account) public virtual override onlyRole(getRoleAdmin(role)) { _grantRole(role, account); } /** * @dev Revokes `role` from `account`. * * If `account` had been granted `role`, emits a {RoleRevoked} event. * * Requirements: * * - the caller must have ``role``'s admin role. */ function revokeRole(bytes32 role, address account) public virtual override onlyRole(getRoleAdmin(role)) { _revokeRole(role, account); } /** * @dev Revokes `role` from the calling account. * * Roles are often managed via {grantRole} and {revokeRole}: this function's * purpose is to provide a mechanism for accounts to lose their privileges * if they are compromised (such as when a trusted device is misplaced). * * If the calling account had been granted `role`, emits a {RoleRevoked} * event. * * Requirements: * * - the caller must be `account`. */ function renounceRole(bytes32 role, address account) public virtual override { require(account == _msgSender(), "AccessControl: can only renounce roles for self"); _revokeRole(role, account); } /** * @dev Grants `role` to `account`. * * If `account` had not been already granted `role`, emits a {RoleGranted} * event. Note that unlike {grantRole}, this function doesn't perform any * checks on the calling account. * * [WARNING] * ==== * This function should only be called from the constructor when setting * up the initial roles for the system. * * Using this function in any other way is effectively circumventing the admin * system imposed by {AccessControl}. * ==== */ function _setupRole(bytes32 role, address account) internal virtual { _grantRole(role, account); } /** * @dev Sets `adminRole` as ``role``'s admin role. * * Emits a {RoleAdminChanged} event. */ function _setRoleAdmin(bytes32 role, bytes32 adminRole) internal virtual { bytes32 previousAdminRole = getRoleAdmin(role); _roles[role].adminRole = adminRole; emit RoleAdminChanged(role, previousAdminRole, adminRole); } function _grantRole(bytes32 role, address account) private { if (!hasRole(role, account)) { _roles[role].members[account] = true; emit RoleGranted(role, account, _msgSender()); } } function _revokeRole(bytes32 role, address account) private { if (hasRole(role, account)) { _roles[role].members[account] = false; emit RoleRevoked(role, account, _msgSender()); } } uint256[49] private __gap; }
// SPDX-License-Identifier: MIT 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; }
// SPDX-License-Identifier: MIT 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 initializer { __Context_init_unchained(); } function __Context_init_unchained() internal initializer { } function _msgSender() internal view virtual returns (address) { return msg.sender; } function _msgData() internal view virtual returns (bytes calldata) { return msg.data; } uint256[50] private __gap; }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /** * @dev String operations. */ library StringsUpgradeable { bytes16 private constant _HEX_SYMBOLS = "0123456789abcdef"; /** * @dev Converts a `uint256` to its ASCII `string` decimal representation. */ function toString(uint256 value) internal pure returns (string memory) { // Inspired by OraclizeAPI's implementation - MIT licence // https://github.com/oraclize/ethereum-api/blob/b42146b063c7d6ee1358846c198246239e9360e8/oraclizeAPI_0.4.25.sol if (value == 0) { return "0"; } uint256 temp = value; uint256 digits; while (temp != 0) { digits++; temp /= 10; } bytes memory buffer = new bytes(digits); while (value != 0) { digits -= 1; buffer[digits] = bytes1(uint8(48 + uint256(value % 10))); value /= 10; } return string(buffer); } /** * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation. */ function toHexString(uint256 value) internal pure returns (string memory) { if (value == 0) { return "0x00"; } uint256 temp = value; uint256 length = 0; while (temp != 0) { length++; temp >>= 8; } return toHexString(value, length); } /** * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length. */ function toHexString(uint256 value, uint256 length) internal pure returns (string memory) { bytes memory buffer = new bytes(2 * length + 2); buffer[0] = "0"; buffer[1] = "x"; for (uint256 i = 2 * length + 1; i > 1; --i) { buffer[i] = _HEX_SYMBOLS[value & 0xf]; value >>= 4; } require(value == 0, "Strings: hex length insufficient"); return string(buffer); } }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "./IERC165Upgradeable.sol"; import "../../proxy/utils/Initializable.sol"; /** * @dev Implementation of the {IERC165} interface. * * Contracts that want to implement ERC165 should inherit from this contract and override {supportsInterface} to check * for the additional interface id that will be supported. For example: * * ```solidity * function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { * return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId); * } * ``` * * Alternatively, {ERC165Storage} provides an easier to use but more expensive implementation. */ abstract contract ERC165Upgradeable is Initializable, IERC165Upgradeable { function __ERC165_init() internal initializer { __ERC165_init_unchained(); } function __ERC165_init_unchained() internal initializer { } /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { return interfaceId == type(IERC165Upgradeable).interfaceId; } uint256[50] private __gap; }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /** * @dev Interface of the ERC165 standard, as defined in the * https://eips.ethereum.org/EIPS/eip-165[EIP]. * * Implementers can declare support of contract interfaces, which can then be * queried by others ({ERC165Checker}). * * For an implementation, see {ERC165}. */ interface IERC165Upgradeable { /** * @dev Returns true if this contract implements the interface defined by * `interfaceId`. See the corresponding * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section] * to learn more about how these ids are created. * * This function call must use less than 30 000 gas. */ function supportsInterface(bytes4 interfaceId) external view returns (bool); }
{ "optimizer": { "enabled": true, "runs": 0 }, "outputSelection": { "*": { "*": [ "evm.bytecode", "evm.deployedBytecode", "devdoc", "userdoc", "metadata", "abi" ] } }, "libraries": {} }
Contract Security Audit
- No Contract Security Audit Submitted- Submit Audit Here
[{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"account","type":"address"}],"name":"ActivatedUser","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"previousAdmin","type":"address"},{"indexed":false,"internalType":"address","name":"newAdmin","type":"address"}],"name":"AdminChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"beacon","type":"address"}],"name":"BeaconUpgraded","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"newCycleLength","type":"uint256"}],"name":"CycleLengthSet","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"newDay","type":"uint256"}],"name":"DaySet","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"caller","type":"address"},{"indexed":true,"internalType":"address","name":"fished_account","type":"address"},{"indexed":false,"internalType":"uint256","name":"claimAmount","type":"uint256"}],"name":"InactiveUserFished","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"bool","name":"ShouldWithdrawFromDAO","type":"bool"}],"name":"ShouldWithdrawFromDAOSet","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"total","type":"uint256"}],"name":"TotalFished","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"day","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"dailyUbi","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"blockNumber","type":"uint256"}],"name":"UBICalculated","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"claimer","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"UBIClaimed","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"day","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"pool","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"cycleLength","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"dailyUBIPool","type":"uint256"}],"name":"UBICycleCalculated","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"implementation","type":"address"}],"name":"Upgraded","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"prevBalance","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"newBalance","type":"uint256"}],"name":"WithdrawFromDao","type":"event"},{"inputs":[],"name":"activeUsersCount","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"avatar","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_member","type":"address"}],"name":"checkEntitlement","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"checkEntitlement","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"claim","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"claimDay","outputs":[{"internalType":"uint256","name":"amountOfClaimers","type":"uint256"},{"internalType":"uint256","name":"claimAmount","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"currentCycleLength","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"currentDay","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"currentDayInCycle","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"cycleLength","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"dailyCyclePool","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"dailyUBIHistory","outputs":[{"internalType":"bool","name":"hasWithdrawn","type":"bool"},{"internalType":"uint256","name":"openAmount","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"dailyUbi","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"dao","outputs":[{"internalType":"contract Controller","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"estimateNextDailyUBI","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"firstClaimPool","outputs":[{"internalType":"contract IFirstClaimPool","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_account","type":"address"}],"name":"fish","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address[]","name":"_accounts","type":"address[]"}],"name":"fishMulti","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"fishedUsersAddresses","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"day","type":"uint256"}],"name":"getClaimAmount","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"day","type":"uint256"}],"name":"getClaimerCount","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getDailyStats","outputs":[{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"hasClaimed","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"contract INameService","name":"_ns","type":"address"},{"internalType":"contract IFirstClaimPool","name":"_firstClaimPool","type":"address"},{"internalType":"uint256","name":"_maxInactiveDays","type":"uint256"}],"name":"initialize","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_account","type":"address"}],"name":"isActiveUser","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_account","type":"address"}],"name":"isNotNewUser","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"iterationGasLimit","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"lastClaimed","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"lastWithdrawDay","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"maxInactiveDays","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"minActiveUsers","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"nameService","outputs":[{"internalType":"contract INameService","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"nativeToken","outputs":[{"internalType":"contract IGoodDollar","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bool","name":"_pause","type":"bool"}],"name":"pause","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"paused","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"periodStart","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_activeUserCount","type":"uint256"}],"name":"setActiveUserCount","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_newLength","type":"uint256"}],"name":"setCycleLength","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"setDay","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bool","name":"_shouldWithdraw","type":"bool"}],"name":"setShouldWithdrawFromDAO","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bool","name":"_use","type":"bool"}],"name":"setUseFirstClaimPool","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"shouldWithdrawFromDAO","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"startOfCycle","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"totalClaimsPerUser","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"updateAvatar","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newImplementation","type":"address"}],"name":"upgradeTo","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newImplementation","type":"address"},{"internalType":"bytes","name":"data","type":"bytes"}],"name":"upgradeToAndCall","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[],"name":"useFirstClaimPool","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"}]
Contract Creation Code
60a06040523060601b60805234801561001757600080fd5b5060805160601c612c9d61004b60003960008181610e2d01528181610e6d015281816112cf015261130f0152612c9d6000f3fe6080604052600436106102235760003560e01c8063013eba921461022857806302329a2914610268578063069786ea1461028a5780630ce82d67146102b45780631248b101146102c95780631794bb3c146103005780631a787f2e146103205780631b3c90a8146103405780631bbc644c146103555780631d8f5ea91461038557806322b457271461039b5780633659cfe6146103b157806337658574146103d15780633d84ceca146103e75780633e6326fc146104075780634162169f146104345780634202d21414610454578063456ac1c2146104745780634b4c71801461048e5780634e71d92d146104a85780634f1ef286146104bd5780635231e2f0146104d0578063560796d1146105005780635aef7de6146105515780635c9302c9146105715780635c975abb1461058757806373b2e80e146105a1578063741470ac146105c15780638081cbbd146105d75780638fd247d2146105f757806398d6621b146106175780639dc2c0331461062c578063a21f698a14610642578063b656223d14610662578063ba07541014610678578063c033abf21461068e578063c1337508146106a4578063c7713870146106c4578063c7a76adf146106d9578063cc054dfc146106f9578063cef6360014610726578063d6a9f61814610746578063d7c4cbb814610766578063dddc36161461077c578063de1de3a014610791578063e1758bd8146107b1578063eac471a0146107c6578063eda4e6d6146107dc575b600080fd5b34801561023457600080fd5b50610255610243366004612645565b609b6020526000908152604090205481565b6040519081526020015b60405180910390f35b34801561027457600080fd5b50610288610283366004612670565b6107f2565b005b34801561029657600080fd5b5061029f61080d565b6040805192835260208301919091520161025f565b3480156102c057600080fd5b5061025561084b565b3480156102d557600080fd5b5061029f6102e436600461268d565b609a602052600090815260409020600181015460029091015482565b34801561030c57600080fd5b5061028861031b3660046126a6565b61086e565b34801561032c57600080fd5b5061025561033b366004612645565b610a03565b34801561034c57600080fd5b50610288610b3a565b34801561036157600080fd5b50610375610370366004612645565b610c7f565b604051901515815260200161025f565b34801561039157600080fd5b50610255609e5481565b3480156103a757600080fd5b5061025560a05481565b3480156103bd57600080fd5b506102886103cc366004612645565b610e22565b3480156103dd57600080fd5b5061025560a95481565b3480156103f357600080fd5b5061028861040236600461268d565b610eeb565b34801561041357600080fd5b50606754610427906001600160a01b031681565b60405161025f91906126e7565b34801561044057600080fd5b50606554610427906001600160a01b031681565b34801561046057600080fd5b5061037561046f366004612645565b610f8e565b34801561048057600080fd5b5060a3546103759060ff1681565b34801561049a57600080fd5b5060a8546103759060ff1681565b3480156104b457600080fd5b50610375610ff0565b6102886104cb366004612768565b6112c4565b3480156104dc57600080fd5b506103756104eb366004612645565b60ac6020526000908152604090205460ff1681565b34801561050c57600080fd5b5061053a61051b36600461268d565b60ab602052600090815260409020805460019091015460ff9091169082565b60408051921515835260208301919091520161025f565b34801561055d57600080fd5b50606654610427906001600160a01b031681565b34801561057d57600080fd5b50610255609c5481565b34801561059357600080fd5b5060ae546103759060ff1681565b3480156105ad57600080fd5b506103756105bc366004612645565b61137e565b3480156105cd57600080fd5b5061025560a75481565b3480156105e357600080fd5b5060aa54610427906001600160a01b031681565b34801561060357600080fd5b5061028861061236600461268d565b6113aa565b34801561062357600080fd5b506102556113b7565b34801561063857600080fd5b5061025560a55481565b34801561064e57600080fd5b5061037561065d366004612645565b6113c2565b34801561066e57600080fd5b5061025560a25481565b34801561068457600080fd5b5061025560a65481565b34801561069a57600080fd5b50610255609f5481565b3480156106b057600080fd5b506102556106bf3660046127fa565b6113e8565b3480156106d057600080fd5b5061025561159d565b3480156106e557600080fd5b506102556106f436600461268d565b61168f565b34801561070557600080fd5b50610255610714366004612645565b60ad6020526000908152604090205481565b34801561073257600080fd5b5061025561074136600461268d565b6116a4565b34801561075257600080fd5b50610288610761366004612670565b6116b9565b34801561077257600080fd5b5061025560a15481565b34801561078857600080fd5b506102886116d4565b34801561079d57600080fd5b506102886107ac366004612670565b611733565b3480156107bd57600080fd5b50610427611782565b3480156107d257600080fd5b5061025560a45481565b3480156107e857600080fd5b50610255609d5481565b6107fa611819565b60ae805460ff1916911515919091179055565b600080600062015180609d544261082491906128c1565b61082e91906128d8565b90506108398161168f565b610842826116a4565b92509250509091565b60006201518060a6544261085f91906128c1565b61086991906128d8565b905090565b600054610100900460ff1680610887575060005460ff16155b6108ef5760405162461bcd60e51b815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201526d191e481a5b9a5d1a585b1a5e995960921b60648201526084015b60405180910390fd5b600054610100900460ff16158015610911576000805461ffff19166101011790555b600082116109615760405162461bcd60e51b815260206004820181905260248201527f4d617820696e61637469766520646179732063616e6e6f74206265207a65726f60448201526064016108e6565b61096a846118ed565b60a282905560aa80546001600160a01b0319166001600160a01b03851617905560a3805460ff19169055605a60a455620249f0609f556109ad62015180426128d8565b6109ba90620151806128fa565b6109c69061a8c0612919565b609d81905560a65560a8805460ff19166001600160a01b03851615151790556103e860a95580156109fd576000805461ff00191690555b50505050565b6000609d54421015610a1757506000919050565b60a85460ff168015610a515750610a2d826113c2565b1580610a5157506001600160a01b038216600090815260ac602052604090205460ff165b15610ae25760aa60009054906101000a90046001600160a01b03166001600160a01b031663830953ab6040518163ffffffff1660e01b815260040160206040518083038186803b158015610aa457600080fd5b505afa158015610ab8573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610adc9190612931565b92915050565b62015180609d5442610af491906128c1565b610afe91906128d8565b609c54148015610b1057506000609e54115b15610b3257610b1e8261137e565b610b2a57609e54610adc565b600092915050565b610adc61159d565b60675460405163bf40fac160e01b815260206004820152600a60248201526921a7a72a2927a62622a960b11b60448201526001600160a01b039091169063bf40fac19060640160206040518083038186803b158015610b9857600080fd5b505afa158015610bac573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610bd0919061294a565b606580546001600160a01b0319166001600160a01b0392909216918217905560408051632d77bef360e11b81529051635aef7de691600480820192602092909190829003018186803b158015610c2557600080fd5b505afa158015610c39573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610c5d919061294a565b606680546001600160a01b0319166001600160a01b0392909216919091179055565b60ae5460009060ff16158015610c9757506000609d54115b8015610ca55750609d544210155b610cc15760405162461bcd60e51b81526004016108e690612967565b610cca826113c2565b8015610cdc5750610cda82610f8e565b155b610d225760405162461bcd60e51b815260206004820152601760248201527634b9903737ba1030b71034b730b1ba34bb32903ab9b2b960491b60448201526064016108e6565b6001600160a01b038216600090815260ac602052604090205460ff1615610d7c5760405162461bcd60e51b815260206004820152600e60248201526d185b1c9958591e48199a5cda195960921b60448201526064016108e6565b6001600160a01b038216600090815260ac60205260408120805460ff19166001179055610da7611910565b60a05490915015610dcb57600160a06000828254610dc591906128c1565b90915550505b610dd9333383600080611bc0565b6040518181526001600160a01b0384169033907f3c91d315d82534112f8ce552cb79133a14191077a2d715fd65cabd026fc27c749060200160405180910390a350600192915050565b306001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000161415610e6b5760405162461bcd60e51b81526004016108e69061299e565b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316610e9d611e77565b6001600160a01b031614610ec35760405162461bcd60e51b81526004016108e6906129d8565b610ecc81611e93565b60408051600080825260208201909252610ee891839190611e9b565b50565b610ef3611819565b60008111610f4d5760405162461bcd60e51b815260206004820152602160248201527f6379636c65206d757374206265206174206c65617374203120646179206c6f6e6044820152606760f81b60648201526084016108e6565b60a4819055600060a7556040518181527fa61e6cca2c12e2a0a493683acfe95b034f0f50d793434f4dfe3ba06ea201f344906020015b60405180910390a150565b6001600160a01b0381166000908152609b6020526040812054610fb0836113c2565b15610fe757600062015180610fc583426128c1565b610fcf91906128d8565b905060a254811015610fe5575060019392505050565b505b50600092915050565b60ae5460009060ff1615801561100857506000609d54115b80156110165750609d544210155b6110325760405162461bcd60e51b81526004016108e690612967565b60675460405163bf40fac160e01b81526020600482015260086024820152674944454e5449545960c01b60448201526000916001600160a01b03169063bf40fac19060640160206040518083038186803b15801561108f57600080fd5b505afa1580156110a3573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906110c7919061294a565b6001600160a01b0316632d0e9b46336040518263ffffffff1660e01b81526004016110f291906126e7565b60206040518083038186803b15801561110a57600080fd5b505afa15801561111e573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611142919061294a565b90506001600160a01b0381166111975760405162461bcd60e51b815260206004820152601a60248201527915509254d8da195b594e881b9bdd081dda1a5d195b1a5cdd195960321b60448201526064016108e6565b60006111a38233611fdb565b60675460405163bf40fac160e01b815260206004820152600d60248201526c4744414f5f434c41494d45525360981b60448201529192506000916001600160a01b039091169063bf40fac19060640160206040518083038186803b15801561120a57600080fd5b505afa15801561121e573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611242919061294a565b905081801561125957506001600160a01b03811615155b156112bd5760405163748abee960e11b81526001600160a01b0382169063e9157dd29061128a9086906004016126e7565b600060405180830381600087803b1580156112a457600080fd5b505af11580156112b8573d6000803e3d6000fd5b505050505b5091505090565b306001600160a01b037f000000000000000000000000000000000000000000000000000000000000000016141561130d5760405162461bcd60e51b81526004016108e69061299e565b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031661133f611e77565b6001600160a01b0316146113655760405162461bcd60e51b81526004016108e6906129d8565b61136e82611e93565b61137a82826001611e9b565b5050565b609c546000908152609a602090815260408083206001600160a01b039094168352929052205460ff1690565b6113b2611819565b60a055565b600061086933610a03565b6001600160a01b0381166000908152609b602052604081205415610b2a57506001919050565b60ae5460009060ff1615801561140057506000609d54115b801561140e5750609d544210155b61142a5760405162461bcd60e51b81526004016108e690612967565b60005b825181101561156f57609f545a101561146757604051818152600080516020612c488339815191529060200160405180910390a192915050565b61148983828151811061147c5761147c612a12565b60200260200101516113c2565b80156114b457506114b28382815181106114a5576114a5612a12565b6020026020010151610f8e565b155b80156114fa575060ac60008483815181106114d1576114d1612a12565b6020908102919091018101516001600160a01b031682528101919091526040016000205460ff16155b1561155f5761152183828151811061151457611514612a12565b6020026020010151610c7f565b61155f5760405162461bcd60e51b815260206004820152600f60248201526e199a5cda081a185cc819985a5b1959608a1b60448201526064016108e6565b61156881612a28565b905061142d565b50600080516020612c48833981519152825160405161159091815260200190565b60405180910390a1505190565b6000806115a8611782565b6001600160a01b03166370a08231306040518263ffffffff1660e01b81526004016115d391906126e7565b60206040518083038186803b1580156115eb57600080fd5b505afa1580156115ff573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906116239190612931565b9050600060a55460a4548361163891906128d8565b119050600060a5549050600060a75461164f61084b565b1015806116595750825b1561166e5760a45461166b90856128d8565b91505b61167c60a05460a954612126565b61168690836128d8565b95945050505050565b6000908152609a602052604090206001015490565b6000908152609a602052604090206002015490565b6116c1611819565b60a8805460ff1916911515919091179055565b600062015180609d54426116e891906128c1565b6116f291906128d8565b9050609c54811115610ee857609c8190556040518181527f67eb03bd555181f9dd23f546e4331ddfb8b4a7d0c8d261ba44e037f30ce894ea90602001610f83565b61173b611819565b60a3805460ff191682151590811790915560405160ff909116151581527f6cd9a0fd2e006be39a9918bf56c85cae1d4f4599474483ff18cb93355ebaaf8e90602001610f83565b60675460405163bf40fac160e01b815260206004820152600a60248201526923a7a7a22227a62620a960b11b60448201526000916001600160a01b03169063bf40fac19060640160206040518083038186803b1580156117e157600080fd5b505afa1580156117f5573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610869919061294a565b60655460408051632d77bef360e11b8152905133926001600160a01b031691635aef7de6916004808301926020929190829003018186803b15801561185d57600080fd5b505afa158015611871573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611895919061294a565b6001600160a01b0316146118eb5760405162461bcd60e51b815260206004820181905260248201527f6f6e6c79206176617461722063616e2063616c6c2074686973206d6574686f6460448201526064016108e6565b565b606780546001600160a01b0319166001600160a01b038316179055610ee8610b3a565b600061191a6116d4565b60a154609c5414158061192d5750609e54155b15611bb957600061193c611782565b90506000816001600160a01b03166370a08231306040518263ffffffff1660e01b815260040161196c91906126e7565b60206040518083038186803b15801561198457600080fd5b505afa158015611998573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906119bc9190612931565b9050600060a55460a454836119d191906128d8565b11905060a7546119df61084b565b1015806119e95750805b15611b015760a35460ff1615611a0157611a0161213f565b6040516370a0823160e01b81526001600160a01b038416906370a0823190611a2d9030906004016126e7565b60206040518083038186803b158015611a4557600080fd5b505afa158015611a59573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611a7d9190612931565b915060a45482611a8d91906128d8565b60a55560a45460a755611aa2610e10426128d8565b611aae90610e106128fa565b60a655609c5460a45460a554604080519384526020840186905283019190915260608201527f83e0d535b9e84324e0a25922406398d6ff5f96d0c686204ee490e16d7670566f9060800160405180910390a15b609c5460a1819055600090815260ab6020526040902060a354815460ff191660ff90911615151781556001810183905560a05460a954611b419190612126565b60a554611b4e91906128d8565b609e5560a054611b6c90611b64906002906128d8565b60a954612126565b60a955609c54609e546040805192835260208301919091524382820152517f836fa39995340265746dfe9587d9fe5c5de35b7bce778afd9b124ce1cfeafdc49181900360600190a1505050505b50609e5490565b8180611bc95750805b15611c57576001609a6000609c5481526020019081526020016000206001016000828254611bf79190612919565b9091555050609c546000908152609a602090815260408083206001600160a01b03891684528252808320805460ff19166001908117909155609b835281842042905560ad9092528220805491929091611c51908490612919565b90915550505b8015611d415760aa54604051636bf2228d60e11b81526000916001600160a01b03169063d7e4451a90611c8e9088906004016126e7565b602060405180830381600087803b158015611ca857600080fd5b505af1158015611cbc573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611ce09190612931565b905080609a6000609c5481526020019081526020016000206002016000828254611d0a9190612919565b90915550506040518181526001600160a01b03871690600080516020612be18339815191529060200160405180910390a250611e70565b8115611d9d57609c546000908152609a602052604081206002018054859290611d6b908490612919565b90915550506040518381526001600160a01b03861690600080516020612be18339815191529060200160405180910390a25b6000611da7611782565b60405163a9059cbb60e01b81529091506001600160a01b0382169063a9059cbb90611dd89088908890600401612a43565b602060405180830381600087803b158015611df257600080fd5b505af1158015611e06573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611e2a9190612a5c565b611e6e5760405162461bcd60e51b815260206004820152601560248201527418db185a5b481d1c985b9cd9995c8819985a5b1959605a1b60448201526064016108e6565b505b5050505050565b600080516020612c01833981519152546001600160a01b031690565b610ee8611819565b6000611ea5611e77565b9050611eb084612442565b600083511180611ebd5750815b15611ece57611ecc84846124d5565b505b7f4910fdfa16fed3260ed0e7147f7cc6da11a60208b5b9406d12a635614ffd9143805460ff16611e7057805460ff19166001178155604051611f49908690611f1a9085906024016126e7565b60408051601f198184030181529190526020810180516001600160e01b0316631b2ce7f360e11b1790526124d5565b50805460ff19168155611f5a611e77565b6001600160a01b0316826001600160a01b031614611fd25760405162461bcd60e51b815260206004820152602f60248201527f45524331393637557067726164653a207570677261646520627265616b73206660448201526e75727468657220757067726164657360881b60648201526084016108e6565b611e70856125b7565b600080611fe6611910565b9050611ff1846113c2565b801561201657506001600160a01b038416600090815260ac602052604090205460ff16155b801561202857506120268461137e565b155b156120465761203c84848360016000611bc0565b6001915050610adc565b61204f846113c2565b158061207357506001600160a01b038416600090815260ac602052604090205460ff165b1561211c57600160a0600082825461208b9190612919565b90915550506001600160a01b038416600090815260ac60205260409020805460ff1916905560a85460ff16156120cf576120ca84846000806001611bc0565b6120de565b6120de84848360016000611bc0565b6040516001600160a01b038516907f2f9cfaa2a5c422dfab45f7d0da071f030fc2d3a7a1f0a255c028eff9b6d3d93690600090a26001915050610adc565b5060009392505050565b6000818310156121365781612138565b825b9392505050565b6000612149611782565b90506000816001600160a01b03166370a08231306040518263ffffffff1660e01b815260040161217991906126e7565b60206040518083038186803b15801561219157600080fd5b505afa1580156121a5573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906121c99190612931565b6066546040516370a0823160e01b81529192506000916001600160a01b03858116926370a082319261220192909116906004016126e7565b60206040518083038186803b15801561221957600080fd5b505afa15801561222d573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906122519190612931565b6065546040519192506001600160a01b03169063d1b7089a90859061227c9030908690602401612a43565b60408051601f198184030181529181526020820180516001600160e01b031663a9059cbb60e01b179052606654905160e085901b6001600160e01b03191681526122d79392916001600160a01b031690600090600401612ad1565b600060405180830381600087803b1580156122f157600080fd5b505af1158015612305573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f1916820160405261232d9190810190612b05565b506000905061233c8284612919565b6040516370a0823160e01b81529091506001600160a01b038516906370a082319061236b9030906004016126e7565b60206040518083038186803b15801561238357600080fd5b505afa158015612397573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906123bb9190612931565b81146124035760405162461bcd60e51b8152602060048201526017602482015276111053c81d1c985b9cd9995c881a185cc819985a5b1959604a1b60448201526064016108e6565b60408051848152602081018390527f3107ec7eaa50b775d2486c7a394472235804b6fe1c0d4b7bd1d79b09df60f2ba910160405180910390a150505050565b803b6124a65760405162461bcd60e51b815260206004820152602d60248201527f455243313936373a206e657720696d706c656d656e746174696f6e206973206e60448201526c1bdd08184818dbdb9d1c9858dd609a1b60648201526084016108e6565b600080516020612c0183398151915280546001600160a01b0319166001600160a01b0392909216919091179055565b6060823b6125345760405162461bcd60e51b815260206004820152602660248201527f416464726573733a2064656c65676174652063616c6c20746f206e6f6e2d636f6044820152651b9d1c9858dd60d21b60648201526084016108e6565b600080846001600160a01b03168460405161254f9190612b91565b600060405180830381855af49150503d806000811461258a576040519150601f19603f3d011682016040523d82523d6000602084013e61258f565b606091505b50915091506116868282604051806060016040528060278152602001612c21602791396125f7565b6125c081612442565b6040516001600160a01b038216907fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b90600090a250565b60608315612606575081612138565b8251156126165782518084602001fd5b8160405162461bcd60e51b81526004016108e69190612bad565b6001600160a01b0381168114610ee857600080fd5b60006020828403121561265757600080fd5b813561213881612630565b8015158114610ee857600080fd5b60006020828403121561268257600080fd5b813561213881612662565b60006020828403121561269f57600080fd5b5035919050565b6000806000606084860312156126bb57600080fd5b83356126c681612630565b925060208401356126d681612630565b929592945050506040919091013590565b6001600160a01b0391909116815260200190565b634e487b7160e01b600052604160045260246000fd5b604051601f8201601f191681016001600160401b0381118282101715612739576127396126fb565b604052919050565b60006001600160401b0382111561275a5761275a6126fb565b50601f01601f191660200190565b6000806040838503121561277b57600080fd5b823561278681612630565b915060208301356001600160401b038111156127a157600080fd5b8301601f810185136127b257600080fd5b80356127c56127c082612741565b612711565b8181528660208385010111156127da57600080fd5b816020840160208301376000602083830101528093505050509250929050565b6000602080838503121561280d57600080fd5b82356001600160401b038082111561282457600080fd5b818501915085601f83011261283857600080fd5b81358181111561284a5761284a6126fb565b8060051b915061285b848301612711565b818152918301840191848101908884111561287557600080fd5b938501935b8385101561289f578435925061288f83612630565b828252938501939085019061287a565b98975050505050505050565b634e487b7160e01b600052601160045260246000fd5b6000828210156128d3576128d36128ab565b500390565b6000826128f557634e487b7160e01b600052601260045260246000fd5b500490565b6000816000190483118215151615612914576129146128ab565b500290565b6000821982111561292c5761292c6128ab565b500190565b60006020828403121561294357600080fd5b5051919050565b60006020828403121561295c57600080fd5b815161213881612630565b6020808252601e908201527f6e6f7420696e20706572696f6453746172746564206f72207061757365640000604082015260600190565b6020808252602c90820152600080516020612bc183398151915260408201526b19195b1959d85d1958d85b1b60a21b606082015260800190565b6020808252602c90820152600080516020612bc183398151915260408201526b6163746976652070726f787960a01b606082015260800190565b634e487b7160e01b600052603260045260246000fd5b6000600019821415612a3c57612a3c6128ab565b5060010190565b6001600160a01b03929092168252602082015260400190565b600060208284031215612a6e57600080fd5b815161213881612662565b60005b83811015612a94578181015183820152602001612a7c565b838111156109fd5750506000910152565b60008151808452612abd816020860160208601612a79565b601f01601f19169290920160200192915050565b600060018060a01b03808716835260806020840152612af36080840187612aa5565b94166040830152506060015292915050565b60008060408385031215612b1857600080fd5b8251612b2381612662565b60208401519092506001600160401b03811115612b3f57600080fd5b8301601f81018513612b5057600080fd5b8051612b5e6127c082612741565b818152866020838501011115612b7357600080fd5b612b84826020830160208601612a79565b8093505050509250929050565b60008251612ba3818460208701612a79565b9190910192915050565b6020815260006121386020830184612aa556fe46756e6374696f6e206d7573742062652063616c6c6564207468726f7567682089ed24731df6b066e4c5186901fffdba18cd9a10f07494aff900bdee260d1304360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c206661696c656472b174db45b7e58932cb0c6bf37a7158f40424a078b07677d823cafdb3db540fa2646970667358221220892b4bbc6662a30b9c597d1a4dc5bc2f471cdbc5d20e07f875bf7e08de84569d64736f6c63430008080033
Deployed Bytecode
0x6080604052600436106102235760003560e01c8063013eba921461022857806302329a2914610268578063069786ea1461028a5780630ce82d67146102b45780631248b101146102c95780631794bb3c146103005780631a787f2e146103205780631b3c90a8146103405780631bbc644c146103555780631d8f5ea91461038557806322b457271461039b5780633659cfe6146103b157806337658574146103d15780633d84ceca146103e75780633e6326fc146104075780634162169f146104345780634202d21414610454578063456ac1c2146104745780634b4c71801461048e5780634e71d92d146104a85780634f1ef286146104bd5780635231e2f0146104d0578063560796d1146105005780635aef7de6146105515780635c9302c9146105715780635c975abb1461058757806373b2e80e146105a1578063741470ac146105c15780638081cbbd146105d75780638fd247d2146105f757806398d6621b146106175780639dc2c0331461062c578063a21f698a14610642578063b656223d14610662578063ba07541014610678578063c033abf21461068e578063c1337508146106a4578063c7713870146106c4578063c7a76adf146106d9578063cc054dfc146106f9578063cef6360014610726578063d6a9f61814610746578063d7c4cbb814610766578063dddc36161461077c578063de1de3a014610791578063e1758bd8146107b1578063eac471a0146107c6578063eda4e6d6146107dc575b600080fd5b34801561023457600080fd5b50610255610243366004612645565b609b6020526000908152604090205481565b6040519081526020015b60405180910390f35b34801561027457600080fd5b50610288610283366004612670565b6107f2565b005b34801561029657600080fd5b5061029f61080d565b6040805192835260208301919091520161025f565b3480156102c057600080fd5b5061025561084b565b3480156102d557600080fd5b5061029f6102e436600461268d565b609a602052600090815260409020600181015460029091015482565b34801561030c57600080fd5b5061028861031b3660046126a6565b61086e565b34801561032c57600080fd5b5061025561033b366004612645565b610a03565b34801561034c57600080fd5b50610288610b3a565b34801561036157600080fd5b50610375610370366004612645565b610c7f565b604051901515815260200161025f565b34801561039157600080fd5b50610255609e5481565b3480156103a757600080fd5b5061025560a05481565b3480156103bd57600080fd5b506102886103cc366004612645565b610e22565b3480156103dd57600080fd5b5061025560a95481565b3480156103f357600080fd5b5061028861040236600461268d565b610eeb565b34801561041357600080fd5b50606754610427906001600160a01b031681565b60405161025f91906126e7565b34801561044057600080fd5b50606554610427906001600160a01b031681565b34801561046057600080fd5b5061037561046f366004612645565b610f8e565b34801561048057600080fd5b5060a3546103759060ff1681565b34801561049a57600080fd5b5060a8546103759060ff1681565b3480156104b457600080fd5b50610375610ff0565b6102886104cb366004612768565b6112c4565b3480156104dc57600080fd5b506103756104eb366004612645565b60ac6020526000908152604090205460ff1681565b34801561050c57600080fd5b5061053a61051b36600461268d565b60ab602052600090815260409020805460019091015460ff9091169082565b60408051921515835260208301919091520161025f565b34801561055d57600080fd5b50606654610427906001600160a01b031681565b34801561057d57600080fd5b50610255609c5481565b34801561059357600080fd5b5060ae546103759060ff1681565b3480156105ad57600080fd5b506103756105bc366004612645565b61137e565b3480156105cd57600080fd5b5061025560a75481565b3480156105e357600080fd5b5060aa54610427906001600160a01b031681565b34801561060357600080fd5b5061028861061236600461268d565b6113aa565b34801561062357600080fd5b506102556113b7565b34801561063857600080fd5b5061025560a55481565b34801561064e57600080fd5b5061037561065d366004612645565b6113c2565b34801561066e57600080fd5b5061025560a25481565b34801561068457600080fd5b5061025560a65481565b34801561069a57600080fd5b50610255609f5481565b3480156106b057600080fd5b506102556106bf3660046127fa565b6113e8565b3480156106d057600080fd5b5061025561159d565b3480156106e557600080fd5b506102556106f436600461268d565b61168f565b34801561070557600080fd5b50610255610714366004612645565b60ad6020526000908152604090205481565b34801561073257600080fd5b5061025561074136600461268d565b6116a4565b34801561075257600080fd5b50610288610761366004612670565b6116b9565b34801561077257600080fd5b5061025560a15481565b34801561078857600080fd5b506102886116d4565b34801561079d57600080fd5b506102886107ac366004612670565b611733565b3480156107bd57600080fd5b50610427611782565b3480156107d257600080fd5b5061025560a45481565b3480156107e857600080fd5b50610255609d5481565b6107fa611819565b60ae805460ff1916911515919091179055565b600080600062015180609d544261082491906128c1565b61082e91906128d8565b90506108398161168f565b610842826116a4565b92509250509091565b60006201518060a6544261085f91906128c1565b61086991906128d8565b905090565b600054610100900460ff1680610887575060005460ff16155b6108ef5760405162461bcd60e51b815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201526d191e481a5b9a5d1a585b1a5e995960921b60648201526084015b60405180910390fd5b600054610100900460ff16158015610911576000805461ffff19166101011790555b600082116109615760405162461bcd60e51b815260206004820181905260248201527f4d617820696e61637469766520646179732063616e6e6f74206265207a65726f60448201526064016108e6565b61096a846118ed565b60a282905560aa80546001600160a01b0319166001600160a01b03851617905560a3805460ff19169055605a60a455620249f0609f556109ad62015180426128d8565b6109ba90620151806128fa565b6109c69061a8c0612919565b609d81905560a65560a8805460ff19166001600160a01b03851615151790556103e860a95580156109fd576000805461ff00191690555b50505050565b6000609d54421015610a1757506000919050565b60a85460ff168015610a515750610a2d826113c2565b1580610a5157506001600160a01b038216600090815260ac602052604090205460ff165b15610ae25760aa60009054906101000a90046001600160a01b03166001600160a01b031663830953ab6040518163ffffffff1660e01b815260040160206040518083038186803b158015610aa457600080fd5b505afa158015610ab8573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610adc9190612931565b92915050565b62015180609d5442610af491906128c1565b610afe91906128d8565b609c54148015610b1057506000609e54115b15610b3257610b1e8261137e565b610b2a57609e54610adc565b600092915050565b610adc61159d565b60675460405163bf40fac160e01b815260206004820152600a60248201526921a7a72a2927a62622a960b11b60448201526001600160a01b039091169063bf40fac19060640160206040518083038186803b158015610b9857600080fd5b505afa158015610bac573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610bd0919061294a565b606580546001600160a01b0319166001600160a01b0392909216918217905560408051632d77bef360e11b81529051635aef7de691600480820192602092909190829003018186803b158015610c2557600080fd5b505afa158015610c39573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610c5d919061294a565b606680546001600160a01b0319166001600160a01b0392909216919091179055565b60ae5460009060ff16158015610c9757506000609d54115b8015610ca55750609d544210155b610cc15760405162461bcd60e51b81526004016108e690612967565b610cca826113c2565b8015610cdc5750610cda82610f8e565b155b610d225760405162461bcd60e51b815260206004820152601760248201527634b9903737ba1030b71034b730b1ba34bb32903ab9b2b960491b60448201526064016108e6565b6001600160a01b038216600090815260ac602052604090205460ff1615610d7c5760405162461bcd60e51b815260206004820152600e60248201526d185b1c9958591e48199a5cda195960921b60448201526064016108e6565b6001600160a01b038216600090815260ac60205260408120805460ff19166001179055610da7611910565b60a05490915015610dcb57600160a06000828254610dc591906128c1565b90915550505b610dd9333383600080611bc0565b6040518181526001600160a01b0384169033907f3c91d315d82534112f8ce552cb79133a14191077a2d715fd65cabd026fc27c749060200160405180910390a350600192915050565b306001600160a01b037f000000000000000000000000ba56f9643c5dcf4b51daadccb29a24e82fe36eaa161415610e6b5760405162461bcd60e51b81526004016108e69061299e565b7f000000000000000000000000ba56f9643c5dcf4b51daadccb29a24e82fe36eaa6001600160a01b0316610e9d611e77565b6001600160a01b031614610ec35760405162461bcd60e51b81526004016108e6906129d8565b610ecc81611e93565b60408051600080825260208201909252610ee891839190611e9b565b50565b610ef3611819565b60008111610f4d5760405162461bcd60e51b815260206004820152602160248201527f6379636c65206d757374206265206174206c65617374203120646179206c6f6e6044820152606760f81b60648201526084016108e6565b60a4819055600060a7556040518181527fa61e6cca2c12e2a0a493683acfe95b034f0f50d793434f4dfe3ba06ea201f344906020015b60405180910390a150565b6001600160a01b0381166000908152609b6020526040812054610fb0836113c2565b15610fe757600062015180610fc583426128c1565b610fcf91906128d8565b905060a254811015610fe5575060019392505050565b505b50600092915050565b60ae5460009060ff1615801561100857506000609d54115b80156110165750609d544210155b6110325760405162461bcd60e51b81526004016108e690612967565b60675460405163bf40fac160e01b81526020600482015260086024820152674944454e5449545960c01b60448201526000916001600160a01b03169063bf40fac19060640160206040518083038186803b15801561108f57600080fd5b505afa1580156110a3573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906110c7919061294a565b6001600160a01b0316632d0e9b46336040518263ffffffff1660e01b81526004016110f291906126e7565b60206040518083038186803b15801561110a57600080fd5b505afa15801561111e573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611142919061294a565b90506001600160a01b0381166111975760405162461bcd60e51b815260206004820152601a60248201527915509254d8da195b594e881b9bdd081dda1a5d195b1a5cdd195960321b60448201526064016108e6565b60006111a38233611fdb565b60675460405163bf40fac160e01b815260206004820152600d60248201526c4744414f5f434c41494d45525360981b60448201529192506000916001600160a01b039091169063bf40fac19060640160206040518083038186803b15801561120a57600080fd5b505afa15801561121e573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611242919061294a565b905081801561125957506001600160a01b03811615155b156112bd5760405163748abee960e11b81526001600160a01b0382169063e9157dd29061128a9086906004016126e7565b600060405180830381600087803b1580156112a457600080fd5b505af11580156112b8573d6000803e3d6000fd5b505050505b5091505090565b306001600160a01b037f000000000000000000000000ba56f9643c5dcf4b51daadccb29a24e82fe36eaa16141561130d5760405162461bcd60e51b81526004016108e69061299e565b7f000000000000000000000000ba56f9643c5dcf4b51daadccb29a24e82fe36eaa6001600160a01b031661133f611e77565b6001600160a01b0316146113655760405162461bcd60e51b81526004016108e6906129d8565b61136e82611e93565b61137a82826001611e9b565b5050565b609c546000908152609a602090815260408083206001600160a01b039094168352929052205460ff1690565b6113b2611819565b60a055565b600061086933610a03565b6001600160a01b0381166000908152609b602052604081205415610b2a57506001919050565b60ae5460009060ff1615801561140057506000609d54115b801561140e5750609d544210155b61142a5760405162461bcd60e51b81526004016108e690612967565b60005b825181101561156f57609f545a101561146757604051818152600080516020612c488339815191529060200160405180910390a192915050565b61148983828151811061147c5761147c612a12565b60200260200101516113c2565b80156114b457506114b28382815181106114a5576114a5612a12565b6020026020010151610f8e565b155b80156114fa575060ac60008483815181106114d1576114d1612a12565b6020908102919091018101516001600160a01b031682528101919091526040016000205460ff16155b1561155f5761152183828151811061151457611514612a12565b6020026020010151610c7f565b61155f5760405162461bcd60e51b815260206004820152600f60248201526e199a5cda081a185cc819985a5b1959608a1b60448201526064016108e6565b61156881612a28565b905061142d565b50600080516020612c48833981519152825160405161159091815260200190565b60405180910390a1505190565b6000806115a8611782565b6001600160a01b03166370a08231306040518263ffffffff1660e01b81526004016115d391906126e7565b60206040518083038186803b1580156115eb57600080fd5b505afa1580156115ff573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906116239190612931565b9050600060a55460a4548361163891906128d8565b119050600060a5549050600060a75461164f61084b565b1015806116595750825b1561166e5760a45461166b90856128d8565b91505b61167c60a05460a954612126565b61168690836128d8565b95945050505050565b6000908152609a602052604090206001015490565b6000908152609a602052604090206002015490565b6116c1611819565b60a8805460ff1916911515919091179055565b600062015180609d54426116e891906128c1565b6116f291906128d8565b9050609c54811115610ee857609c8190556040518181527f67eb03bd555181f9dd23f546e4331ddfb8b4a7d0c8d261ba44e037f30ce894ea90602001610f83565b61173b611819565b60a3805460ff191682151590811790915560405160ff909116151581527f6cd9a0fd2e006be39a9918bf56c85cae1d4f4599474483ff18cb93355ebaaf8e90602001610f83565b60675460405163bf40fac160e01b815260206004820152600a60248201526923a7a7a22227a62620a960b11b60448201526000916001600160a01b03169063bf40fac19060640160206040518083038186803b1580156117e157600080fd5b505afa1580156117f5573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610869919061294a565b60655460408051632d77bef360e11b8152905133926001600160a01b031691635aef7de6916004808301926020929190829003018186803b15801561185d57600080fd5b505afa158015611871573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611895919061294a565b6001600160a01b0316146118eb5760405162461bcd60e51b815260206004820181905260248201527f6f6e6c79206176617461722063616e2063616c6c2074686973206d6574686f6460448201526064016108e6565b565b606780546001600160a01b0319166001600160a01b038316179055610ee8610b3a565b600061191a6116d4565b60a154609c5414158061192d5750609e54155b15611bb957600061193c611782565b90506000816001600160a01b03166370a08231306040518263ffffffff1660e01b815260040161196c91906126e7565b60206040518083038186803b15801561198457600080fd5b505afa158015611998573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906119bc9190612931565b9050600060a55460a454836119d191906128d8565b11905060a7546119df61084b565b1015806119e95750805b15611b015760a35460ff1615611a0157611a0161213f565b6040516370a0823160e01b81526001600160a01b038416906370a0823190611a2d9030906004016126e7565b60206040518083038186803b158015611a4557600080fd5b505afa158015611a59573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611a7d9190612931565b915060a45482611a8d91906128d8565b60a55560a45460a755611aa2610e10426128d8565b611aae90610e106128fa565b60a655609c5460a45460a554604080519384526020840186905283019190915260608201527f83e0d535b9e84324e0a25922406398d6ff5f96d0c686204ee490e16d7670566f9060800160405180910390a15b609c5460a1819055600090815260ab6020526040902060a354815460ff191660ff90911615151781556001810183905560a05460a954611b419190612126565b60a554611b4e91906128d8565b609e5560a054611b6c90611b64906002906128d8565b60a954612126565b60a955609c54609e546040805192835260208301919091524382820152517f836fa39995340265746dfe9587d9fe5c5de35b7bce778afd9b124ce1cfeafdc49181900360600190a1505050505b50609e5490565b8180611bc95750805b15611c57576001609a6000609c5481526020019081526020016000206001016000828254611bf79190612919565b9091555050609c546000908152609a602090815260408083206001600160a01b03891684528252808320805460ff19166001908117909155609b835281842042905560ad9092528220805491929091611c51908490612919565b90915550505b8015611d415760aa54604051636bf2228d60e11b81526000916001600160a01b03169063d7e4451a90611c8e9088906004016126e7565b602060405180830381600087803b158015611ca857600080fd5b505af1158015611cbc573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611ce09190612931565b905080609a6000609c5481526020019081526020016000206002016000828254611d0a9190612919565b90915550506040518181526001600160a01b03871690600080516020612be18339815191529060200160405180910390a250611e70565b8115611d9d57609c546000908152609a602052604081206002018054859290611d6b908490612919565b90915550506040518381526001600160a01b03861690600080516020612be18339815191529060200160405180910390a25b6000611da7611782565b60405163a9059cbb60e01b81529091506001600160a01b0382169063a9059cbb90611dd89088908890600401612a43565b602060405180830381600087803b158015611df257600080fd5b505af1158015611e06573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611e2a9190612a5c565b611e6e5760405162461bcd60e51b815260206004820152601560248201527418db185a5b481d1c985b9cd9995c8819985a5b1959605a1b60448201526064016108e6565b505b5050505050565b600080516020612c01833981519152546001600160a01b031690565b610ee8611819565b6000611ea5611e77565b9050611eb084612442565b600083511180611ebd5750815b15611ece57611ecc84846124d5565b505b7f4910fdfa16fed3260ed0e7147f7cc6da11a60208b5b9406d12a635614ffd9143805460ff16611e7057805460ff19166001178155604051611f49908690611f1a9085906024016126e7565b60408051601f198184030181529190526020810180516001600160e01b0316631b2ce7f360e11b1790526124d5565b50805460ff19168155611f5a611e77565b6001600160a01b0316826001600160a01b031614611fd25760405162461bcd60e51b815260206004820152602f60248201527f45524331393637557067726164653a207570677261646520627265616b73206660448201526e75727468657220757067726164657360881b60648201526084016108e6565b611e70856125b7565b600080611fe6611910565b9050611ff1846113c2565b801561201657506001600160a01b038416600090815260ac602052604090205460ff16155b801561202857506120268461137e565b155b156120465761203c84848360016000611bc0565b6001915050610adc565b61204f846113c2565b158061207357506001600160a01b038416600090815260ac602052604090205460ff165b1561211c57600160a0600082825461208b9190612919565b90915550506001600160a01b038416600090815260ac60205260409020805460ff1916905560a85460ff16156120cf576120ca84846000806001611bc0565b6120de565b6120de84848360016000611bc0565b6040516001600160a01b038516907f2f9cfaa2a5c422dfab45f7d0da071f030fc2d3a7a1f0a255c028eff9b6d3d93690600090a26001915050610adc565b5060009392505050565b6000818310156121365781612138565b825b9392505050565b6000612149611782565b90506000816001600160a01b03166370a08231306040518263ffffffff1660e01b815260040161217991906126e7565b60206040518083038186803b15801561219157600080fd5b505afa1580156121a5573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906121c99190612931565b6066546040516370a0823160e01b81529192506000916001600160a01b03858116926370a082319261220192909116906004016126e7565b60206040518083038186803b15801561221957600080fd5b505afa15801561222d573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906122519190612931565b6065546040519192506001600160a01b03169063d1b7089a90859061227c9030908690602401612a43565b60408051601f198184030181529181526020820180516001600160e01b031663a9059cbb60e01b179052606654905160e085901b6001600160e01b03191681526122d79392916001600160a01b031690600090600401612ad1565b600060405180830381600087803b1580156122f157600080fd5b505af1158015612305573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f1916820160405261232d9190810190612b05565b506000905061233c8284612919565b6040516370a0823160e01b81529091506001600160a01b038516906370a082319061236b9030906004016126e7565b60206040518083038186803b15801561238357600080fd5b505afa158015612397573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906123bb9190612931565b81146124035760405162461bcd60e51b8152602060048201526017602482015276111053c81d1c985b9cd9995c881a185cc819985a5b1959604a1b60448201526064016108e6565b60408051848152602081018390527f3107ec7eaa50b775d2486c7a394472235804b6fe1c0d4b7bd1d79b09df60f2ba910160405180910390a150505050565b803b6124a65760405162461bcd60e51b815260206004820152602d60248201527f455243313936373a206e657720696d706c656d656e746174696f6e206973206e60448201526c1bdd08184818dbdb9d1c9858dd609a1b60648201526084016108e6565b600080516020612c0183398151915280546001600160a01b0319166001600160a01b0392909216919091179055565b6060823b6125345760405162461bcd60e51b815260206004820152602660248201527f416464726573733a2064656c65676174652063616c6c20746f206e6f6e2d636f6044820152651b9d1c9858dd60d21b60648201526084016108e6565b600080846001600160a01b03168460405161254f9190612b91565b600060405180830381855af49150503d806000811461258a576040519150601f19603f3d011682016040523d82523d6000602084013e61258f565b606091505b50915091506116868282604051806060016040528060278152602001612c21602791396125f7565b6125c081612442565b6040516001600160a01b038216907fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b90600090a250565b60608315612606575081612138565b8251156126165782518084602001fd5b8160405162461bcd60e51b81526004016108e69190612bad565b6001600160a01b0381168114610ee857600080fd5b60006020828403121561265757600080fd5b813561213881612630565b8015158114610ee857600080fd5b60006020828403121561268257600080fd5b813561213881612662565b60006020828403121561269f57600080fd5b5035919050565b6000806000606084860312156126bb57600080fd5b83356126c681612630565b925060208401356126d681612630565b929592945050506040919091013590565b6001600160a01b0391909116815260200190565b634e487b7160e01b600052604160045260246000fd5b604051601f8201601f191681016001600160401b0381118282101715612739576127396126fb565b604052919050565b60006001600160401b0382111561275a5761275a6126fb565b50601f01601f191660200190565b6000806040838503121561277b57600080fd5b823561278681612630565b915060208301356001600160401b038111156127a157600080fd5b8301601f810185136127b257600080fd5b80356127c56127c082612741565b612711565b8181528660208385010111156127da57600080fd5b816020840160208301376000602083830101528093505050509250929050565b6000602080838503121561280d57600080fd5b82356001600160401b038082111561282457600080fd5b818501915085601f83011261283857600080fd5b81358181111561284a5761284a6126fb565b8060051b915061285b848301612711565b818152918301840191848101908884111561287557600080fd5b938501935b8385101561289f578435925061288f83612630565b828252938501939085019061287a565b98975050505050505050565b634e487b7160e01b600052601160045260246000fd5b6000828210156128d3576128d36128ab565b500390565b6000826128f557634e487b7160e01b600052601260045260246000fd5b500490565b6000816000190483118215151615612914576129146128ab565b500290565b6000821982111561292c5761292c6128ab565b500190565b60006020828403121561294357600080fd5b5051919050565b60006020828403121561295c57600080fd5b815161213881612630565b6020808252601e908201527f6e6f7420696e20706572696f6453746172746564206f72207061757365640000604082015260600190565b6020808252602c90820152600080516020612bc183398151915260408201526b19195b1959d85d1958d85b1b60a21b606082015260800190565b6020808252602c90820152600080516020612bc183398151915260408201526b6163746976652070726f787960a01b606082015260800190565b634e487b7160e01b600052603260045260246000fd5b6000600019821415612a3c57612a3c6128ab565b5060010190565b6001600160a01b03929092168252602082015260400190565b600060208284031215612a6e57600080fd5b815161213881612662565b60005b83811015612a94578181015183820152602001612a7c565b838111156109fd5750506000910152565b60008151808452612abd816020860160208601612a79565b601f01601f19169290920160200192915050565b600060018060a01b03808716835260806020840152612af36080840187612aa5565b94166040830152506060015292915050565b60008060408385031215612b1857600080fd5b8251612b2381612662565b60208401519092506001600160401b03811115612b3f57600080fd5b8301601f81018513612b5057600080fd5b8051612b5e6127c082612741565b818152866020838501011115612b7357600080fd5b612b84826020830160208601612a79565b8093505050509250929050565b60008251612ba3818460208701612a79565b9190910192915050565b6020815260006121386020830184612aa556fe46756e6374696f6e206d7573742062652063616c6c6564207468726f7567682089ed24731df6b066e4c5186901fffdba18cd9a10f07494aff900bdee260d1304360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c206661696c656472b174db45b7e58932cb0c6bf37a7158f40424a078b07677d823cafdb3db540fa2646970667358221220892b4bbc6662a30b9c597d1a4dc5bc2f471cdbc5d20e07f875bf7e08de84569d64736f6c63430008080033
Loading...
Loading
Loading...
Loading
[ Download: CSV Export ]
A contract address hosts a smart contract, which is a set of code stored on the blockchain that runs when predetermined conditions are met. Learn more about addresses in our Knowledge Base.