More Info
Private Name Tags
ContractCreator
Latest 25 from a total of 7,892 transactions
Transaction Hash |
Method
|
Block
|
From
|
To
|
|||||
---|---|---|---|---|---|---|---|---|---|
Claim | 14817499 | 981 days ago | IN | 0 ETH | 0.00079557 | ||||
Claim | 14350772 | 1055 days ago | IN | 0 ETH | 0.00236642 | ||||
Claim | 14350772 | 1055 days ago | IN | 0 ETH | 0.00218657 | ||||
Claim | 14350644 | 1055 days ago | IN | 0 ETH | 0.00473285 | ||||
Claim | 14350644 | 1055 days ago | IN | 0 ETH | 0.00473285 | ||||
Claim | 14350644 | 1055 days ago | IN | 0 ETH | 0.00473285 | ||||
Claim | 14350644 | 1055 days ago | IN | 0 ETH | 0.00473285 | ||||
Claim | 14146575 | 1086 days ago | IN | 0 ETH | 0.00328633 | ||||
Claim | 14120918 | 1090 days ago | IN | 0 ETH | 0.01983284 | ||||
Claim | 14120897 | 1090 days ago | IN | 0 ETH | 0.0165703 | ||||
Claim | 14120866 | 1090 days ago | IN | 0 ETH | 0.01876302 | ||||
Claim | 14120797 | 1090 days ago | IN | 0 ETH | 0.02570282 | ||||
Claim | 14120702 | 1090 days ago | IN | 0 ETH | 0.00739186 | ||||
Claim | 14120692 | 1090 days ago | IN | 0 ETH | 0.01109523 | ||||
Claim | 14119508 | 1090 days ago | IN | 0 ETH | 0.00810454 | ||||
Claim | 14116005 | 1091 days ago | IN | 0 ETH | 0.01308813 | ||||
Claim | 14114361 | 1091 days ago | IN | 0 ETH | 0.01324374 | ||||
Claim | 14113569 | 1091 days ago | IN | 0 ETH | 0.00687206 | ||||
Claim | 14113456 | 1091 days ago | IN | 0 ETH | 0.00831014 | ||||
Claim | 14113242 | 1091 days ago | IN | 0 ETH | 0.00550232 | ||||
Claim | 14112211 | 1092 days ago | IN | 0 ETH | 0.00650483 | ||||
Claim | 14111767 | 1092 days ago | IN | 0 ETH | 0.00687943 | ||||
Claim | 14110642 | 1092 days ago | IN | 0 ETH | 0.01018117 | ||||
Claim | 14110110 | 1092 days ago | IN | 0 ETH | 0.01243924 | ||||
Claim | 14108874 | 1092 days ago | IN | 0 ETH | 0.00963018 |
View more zero value Internal Transactions in Advanced View mode
Advanced mode:
Loading...
Loading
Contract Source Code Verified (Exact Match)
Contract Name:
Rewards
Compiler Version
v0.7.6+commit.7338295f
Optimization Enabled:
Yes with 9999 runs
Other Settings:
default evmVersion
Contract Source Code (Solidity Standard Json-Input format)
// SPDX-License-Identifier: Apache-2.0 pragma solidity 0.7.6; pragma experimental ABIEncoderV2; import "@openzeppelin/contracts/access/Ownable.sol"; import "@openzeppelin/contracts/math/SafeMath.sol"; import "@openzeppelin/contracts/token/ERC20/IERC20.sol"; import "./interfaces/IBarn.sol"; contract Rewards is Ownable { using SafeMath for uint256; uint256 constant decimals = 10 ** 18; struct Pull { address source; uint256 startTs; uint256 endTs; uint256 totalDuration; uint256 totalAmount; } Pull public pullFeature; bool public disabled; uint256 public lastPullTs; uint256 public balanceBefore; uint256 public currentMultiplier; mapping(address => uint256) public userMultiplier; mapping(address => uint256) public owed; IBarn public barn; IERC20 public rewardToken; event Claim(address indexed user, uint256 amount); constructor(address _owner, address _token, address _barn) { require(_token != address(0), "reward token must not be 0x0"); require(_barn != address(0), "barn address must not be 0x0"); transferOwnership(_owner); rewardToken = IERC20(_token); barn = IBarn(_barn); } // registerUserAction is called by the Barn every time the user does a deposit or withdrawal in order to // account for the changes in reward that the user should get // it updates the amount owed to the user without transferring the funds function registerUserAction(address user) public { require(msg.sender == address(barn), 'only callable by barn'); _calculateOwed(user); } // claim calculates the currently owed reward and transfers the funds to the user function claim() public returns (uint256){ _calculateOwed(msg.sender); uint256 amount = owed[msg.sender]; require(amount > 0, "nothing to claim"); owed[msg.sender] = 0; rewardToken.transfer(msg.sender, amount); // acknowledge the amount that was transferred to the user ackFunds(); emit Claim(msg.sender, amount); return amount; } // ackFunds checks the difference between the last known balance of `token` and the current one // if it goes up, the multiplier is re-calculated // if it goes down, it only updates the known balance function ackFunds() public { uint256 balanceNow = rewardToken.balanceOf(address(this)); if (balanceNow == 0 || balanceNow <= balanceBefore) { balanceBefore = balanceNow; return; } uint256 totalStakedBond = barn.bondStaked(); // if there's no bond staked, it doesn't make sense to ackFunds because there's nobody to distribute them to // and the calculation would fail anyways due to division by 0 if (totalStakedBond == 0) { return; } uint256 diff = balanceNow.sub(balanceBefore); uint256 multiplier = currentMultiplier.add(diff.mul(decimals).div(totalStakedBond)); balanceBefore = balanceNow; currentMultiplier = multiplier; } // setupPullToken is used to setup the rewards system; only callable by contract owner // set source to address(0) to disable the functionality function setupPullToken(address source, uint256 startTs, uint256 endTs, uint256 amount) public { require(msg.sender == owner(), "!owner"); require(!disabled, "contract is disabled"); if (pullFeature.source != address(0)) { require(source == address(0), "contract is already set up, source must be 0x0"); disabled = true; } else { require(source != address(0), "contract is not setup, source must be != 0x0"); } if (source == address(0)) { require(startTs == 0, "disable contract: startTs must be 0"); require(endTs == 0, "disable contract: endTs must be 0"); require(amount == 0, "disable contract: amount must be 0"); } else { require(endTs > startTs, "setup contract: endTs must be greater than startTs"); require(amount > 0, "setup contract: amount must be greater than 0"); } pullFeature.source = source; pullFeature.startTs = startTs; pullFeature.endTs = endTs; pullFeature.totalDuration = endTs.sub(startTs); pullFeature.totalAmount = amount; if (lastPullTs < startTs) { lastPullTs = startTs; } } // setBarn sets the address of the BarnBridge Barn into the state variable function setBarn(address _barn) public { require(_barn != address(0), 'barn address must not be 0x0'); require(msg.sender == owner(), '!owner'); barn = IBarn(_barn); } // _pullToken calculates the amount based on the time passed since the last pull relative // to the total amount of time that the pull functionality is active and executes a transferFrom from the // address supplied as `pullTokenFrom`, if enabled function _pullToken() internal { if ( pullFeature.source == address(0) || block.timestamp < pullFeature.startTs ) { return; } uint256 timestampCap = pullFeature.endTs; if (block.timestamp < pullFeature.endTs) { timestampCap = block.timestamp; } if (lastPullTs >= timestampCap) { return; } uint256 timeSinceLastPull = timestampCap.sub(lastPullTs); uint256 shareToPull = timeSinceLastPull.mul(decimals).div(pullFeature.totalDuration); uint256 amountToPull = pullFeature.totalAmount.mul(shareToPull).div(decimals); lastPullTs = block.timestamp; rewardToken.transferFrom(pullFeature.source, address(this), amountToPull); } // _calculateOwed calculates and updates the total amount that is owed to an user and updates the user's multiplier // to the current value // it automatically attempts to pull the token from the source and acknowledge the funds function _calculateOwed(address user) internal { _pullToken(); ackFunds(); uint256 reward = _userPendingReward(user); owed[user] = owed[user].add(reward); userMultiplier[user] = currentMultiplier; } // _userPendingReward calculates the reward that should be based on the current multiplier / anything that's not included in the `owed[user]` value // it does not represent the entire reward that's due to the user unless added on top of `owed[user]` function _userPendingReward(address user) internal view returns (uint256) { uint256 multiplier = currentMultiplier.sub(userMultiplier[user]); return barn.balanceOf(user).mul(multiplier).div(decimals); } }
// SPDX-License-Identifier: Apache-2.0 pragma solidity 0.7.6; pragma experimental ABIEncoderV2; import "./interfaces/IDiamondCut.sol"; import "./interfaces/IDiamondLoupe.sol"; import "./libraries/LibDiamond.sol"; import "./libraries/LibOwnership.sol"; import "./libraries/LibDiamondStorage.sol"; import "./interfaces/IERC165.sol"; import "./interfaces/IERC173.sol"; contract Barn { constructor(IDiamondCut.FacetCut[] memory _diamondCut, address _owner) payable { require(_owner != address(0), "owner must not be 0x0"); LibDiamond.diamondCut(_diamondCut, address(0), new bytes(0)); LibOwnership.setContractOwner(_owner); LibDiamondStorage.DiamondStorage storage ds = LibDiamondStorage.diamondStorage(); // adding ERC165 data ds.supportedInterfaces[type(IERC165).interfaceId] = true; ds.supportedInterfaces[type(IDiamondCut).interfaceId] = true; ds.supportedInterfaces[type(IDiamondLoupe).interfaceId] = true; ds.supportedInterfaces[type(IERC173).interfaceId] = true; } // Find facet for function that is called and execute the // function if a facet is found and return any value. fallback() external payable { LibDiamondStorage.DiamondStorage storage ds = LibDiamondStorage.diamondStorage(); address facet = address(bytes20(ds.facets[msg.sig].facetAddress)); require(facet != address(0), "Diamond: Function does not exist"); assembly { calldatacopy(0, 0, calldatasize()) let result := delegatecall(gas(), facet, 0, calldatasize(), 0, 0) returndatacopy(0, 0, returndatasize()) switch result case 0 { revert(0, returndatasize()) } default { return (0, returndatasize()) } } } receive() external payable {} }
// SPDX-License-Identifier: Apache-2.0 pragma solidity 0.7.6; pragma experimental ABIEncoderV2; interface IDiamondCut { enum FacetCutAction {Add, Replace, Remove} // Add=0, Replace=1, Remove=2 struct FacetCut { address facetAddress; FacetCutAction action; bytes4[] functionSelectors; } /// @notice Add/replace/remove any number of functions and optionally execute /// a function with delegatecall /// @param _diamondCut Contains the facet addresses and function selectors /// @param _init The address of the contract or facet to execute _calldata /// @param _calldata A function call, including function selector and arguments /// _calldata is executed with delegatecall on _init function diamondCut( FacetCut[] calldata _diamondCut, address _init, bytes calldata _calldata ) external; event DiamondCut(FacetCut[] _diamondCut, address _init, bytes _calldata); }
// SPDX-License-Identifier: Apache-2.0 pragma solidity 0.7.6; pragma experimental ABIEncoderV2; // A loupe is a small magnifying glass used to look at diamonds. // These functions look at diamonds interface IDiamondLoupe { /// These functions are expected to be called frequently /// by tools. struct Facet { address facetAddress; bytes4[] functionSelectors; } /// @notice Gets all facet addresses and their four byte function selectors. /// @return facets_ Facet function facets() external view returns (Facet[] memory facets_); /// @notice Gets all the function selectors supported by a specific facet. /// @param _facet The facet address. /// @return facetFunctionSelectors_ function facetFunctionSelectors(address _facet) external view returns (bytes4[] memory facetFunctionSelectors_); /// @notice Get all the facet addresses used by a diamond. /// @return facetAddresses_ function facetAddresses() external view returns (address[] memory facetAddresses_); /// @notice Gets the facet that supports the given selector. /// @dev If facet is not found return address(0). /// @param _functionSelector The function selector. /// @return facetAddress_ The facet address. function facetAddress(bytes4 _functionSelector) external view returns (address facetAddress_); }
// SPDX-License-Identifier: Apache-2.0 pragma solidity 0.7.6; pragma experimental ABIEncoderV2; import "../interfaces/IDiamondCut.sol"; import "./LibDiamondStorage.sol"; library LibDiamond { event DiamondCut(IDiamondCut.FacetCut[] _diamondCut, address _init, bytes _calldata); // Internal function version of diamondCut // This code is almost the same as the external diamondCut, // except it is using 'Facet[] memory _diamondCut' instead of // 'Facet[] calldata _diamondCut'. // The code is duplicated to prevent copying calldata to memory which // causes an error for a two dimensional array. function diamondCut( IDiamondCut.FacetCut[] memory _diamondCut, address _init, bytes memory _calldata ) internal { uint256 selectorCount = LibDiamondStorage.diamondStorage().selectors.length; for (uint256 facetIndex; facetIndex < _diamondCut.length; facetIndex++) { selectorCount = executeDiamondCut(selectorCount, _diamondCut[facetIndex]); } emit DiamondCut(_diamondCut, _init, _calldata); initializeDiamondCut(_init, _calldata); } // executeDiamondCut takes one single FacetCut action and executes it // if FacetCutAction can't be identified, it reverts function executeDiamondCut(uint256 selectorCount, IDiamondCut.FacetCut memory cut) internal returns (uint256) { require(cut.functionSelectors.length > 0, "LibDiamond: No selectors in facet to cut"); if (cut.action == IDiamondCut.FacetCutAction.Add) { require(cut.facetAddress != address(0), "LibDiamond: add facet address can't be address(0)"); enforceHasContractCode(cut.facetAddress, "LibDiamond: add facet must have code"); return _handleAddCut(selectorCount, cut); } if (cut.action == IDiamondCut.FacetCutAction.Replace) { require(cut.facetAddress != address(0), "LibDiamond: remove facet address can't be address(0)"); enforceHasContractCode(cut.facetAddress, "LibDiamond: remove facet must have code"); return _handleReplaceCut(selectorCount, cut); } if (cut.action == IDiamondCut.FacetCutAction.Remove) { require(cut.facetAddress == address(0), "LibDiamond: remove facet address must be address(0)"); return _handleRemoveCut(selectorCount, cut); } revert("LibDiamondCut: Incorrect FacetCutAction"); } // _handleAddCut executes a cut with the type Add // it reverts if the selector already exists function _handleAddCut(uint256 selectorCount, IDiamondCut.FacetCut memory cut) internal returns (uint256) { LibDiamondStorage.DiamondStorage storage ds = LibDiamondStorage.diamondStorage(); for (uint256 selectorIndex; selectorIndex < cut.functionSelectors.length; selectorIndex++) { bytes4 selector = cut.functionSelectors[selectorIndex]; address oldFacetAddress = ds.facets[selector].facetAddress; require(oldFacetAddress == address(0), "LibDiamondCut: Can't add function that already exists"); ds.facets[selector] = LibDiamondStorage.Facet( cut.facetAddress, uint16(selectorCount) ); ds.selectors.push(selector); selectorCount++; } return selectorCount; } // _handleReplaceCut executes a cut with the type Replace // it does not allow replacing immutable functions // it does not allow replacing with the same function // it does not allow replacing a function that does not exist function _handleReplaceCut(uint256 selectorCount, IDiamondCut.FacetCut memory cut) internal returns (uint256) { LibDiamondStorage.DiamondStorage storage ds = LibDiamondStorage.diamondStorage(); for (uint256 selectorIndex; selectorIndex < cut.functionSelectors.length; selectorIndex++) { bytes4 selector = cut.functionSelectors[selectorIndex]; address oldFacetAddress = ds.facets[selector].facetAddress; // only useful if immutable functions exist require(oldFacetAddress != address(this), "LibDiamondCut: Can't replace immutable function"); require(oldFacetAddress != cut.facetAddress, "LibDiamondCut: Can't replace function with same function"); require(oldFacetAddress != address(0), "LibDiamondCut: Can't replace function that doesn't exist"); // replace old facet address ds.facets[selector].facetAddress = cut.facetAddress; } return selectorCount; } // _handleRemoveCut executes a cut with the type Remove // for efficiency, the selector to be deleted is replaced with the last one and then the last one is popped // it reverts if the function doesn't exist or it's immutable function _handleRemoveCut(uint256 selectorCount, IDiamondCut.FacetCut memory cut) internal returns (uint256) { LibDiamondStorage.DiamondStorage storage ds = LibDiamondStorage.diamondStorage(); for (uint256 selectorIndex; selectorIndex < cut.functionSelectors.length; selectorIndex++) { bytes4 selector = cut.functionSelectors[selectorIndex]; LibDiamondStorage.Facet memory oldFacet = ds.facets[selector]; require(oldFacet.facetAddress != address(0), "LibDiamondCut: Can't remove function that doesn't exist"); require(oldFacet.facetAddress != address(this), "LibDiamondCut: Can't remove immutable function."); // replace selector with last selector if (oldFacet.selectorPosition != selectorCount - 1) { bytes4 lastSelector = ds.selectors[selectorCount - 1]; ds.selectors[oldFacet.selectorPosition] = lastSelector; ds.facets[lastSelector].selectorPosition = oldFacet.selectorPosition; } // delete last selector ds.selectors.pop(); delete ds.facets[selector]; selectorCount--; } return selectorCount; } function initializeDiamondCut(address _init, bytes memory _calldata) internal { if (_init == address(0)) { require(_calldata.length == 0, "LibDiamondCut: _init is address(0) but _calldata is not empty"); return; } require(_calldata.length > 0, "LibDiamondCut: _calldata is empty but _init is not address(0)"); if (_init != address(this)) { enforceHasContractCode(_init, "LibDiamondCut: _init address has no code"); } (bool success, bytes memory error) = _init.delegatecall(_calldata); if (!success) { if (error.length > 0) { // bubble up the error revert(string(error)); } else { revert("LibDiamondCut: _init function reverted"); } } } function enforceHasContractCode(address _contract, string memory _errorMessage) internal view { uint256 contractSize; assembly { contractSize := extcodesize(_contract) } require(contractSize > 0, _errorMessage); } }
// SPDX-License-Identifier: Apache-2.0 pragma solidity 0.7.6; pragma experimental ABIEncoderV2; import "./LibDiamondStorage.sol"; library LibOwnership { event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); function setContractOwner(address _newOwner) internal { LibDiamondStorage.DiamondStorage storage ds = LibDiamondStorage.diamondStorage(); address previousOwner = ds.contractOwner; require(previousOwner != _newOwner, "Previous owner and new owner must be different"); ds.contractOwner = _newOwner; emit OwnershipTransferred(previousOwner, _newOwner); } function contractOwner() internal view returns (address contractOwner_) { contractOwner_ = LibDiamondStorage.diamondStorage().contractOwner; } function enforceIsContractOwner() view internal { require(msg.sender == LibDiamondStorage.diamondStorage().contractOwner, "Must be contract owner"); } modifier onlyOwner { require(msg.sender == LibDiamondStorage.diamondStorage().contractOwner, "Must be contract owner"); _; } }
// SPDX-License-Identifier: Apache-2.0 pragma solidity 0.7.6; pragma experimental ABIEncoderV2; library LibDiamondStorage { bytes32 constant DIAMOND_STORAGE_POSITION = keccak256("diamond.standard.diamond.storage"); struct Facet { address facetAddress; uint16 selectorPosition; } struct DiamondStorage { // function selector => facet address and selector position in selectors array mapping(bytes4 => Facet) facets; bytes4[] selectors; // ERC165 mapping(bytes4 => bool) supportedInterfaces; // owner of the contract address contractOwner; } function diamondStorage() internal pure returns (DiamondStorage storage ds) { bytes32 position = DIAMOND_STORAGE_POSITION; assembly { ds.slot := position } } }
// SPDX-License-Identifier: Apache-2.0 pragma solidity 0.7.6; pragma experimental ABIEncoderV2; interface IERC165 { /// @notice Query if a contract implements an interface /// @param interfaceId The interface identifier, as specified in ERC-165 /// @dev Interface identification is specified in ERC-165. This function /// uses less than 30,000 gas. /// @return `true` if the contract implements `interfaceID` and /// `interfaceID` is not 0xffffffff, `false` otherwise function supportsInterface(bytes4 interfaceId) external view returns (bool); }
// SPDX-License-Identifier: Apache-2.0 pragma solidity 0.7.6; /// @title ERC-173 Contract Ownership Standard /// Note: the ERC-165 identifier for this interface is 0x7f5828d0 /* is ERC165 */ interface IERC173 { /// @dev This emits when ownership of a contract changes. event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); /// @notice Get the address of the owner /// @return owner_ The address of the owner. function owner() external view returns (address owner_); /// @notice Set the address of the new owner of the contract /// @dev Set _newOwner to address(0) to renounce any ownership. /// @param _newOwner The address of the new owner of the contract function transferOwnership(address _newOwner) external; }
// SPDX-License-Identifier: Apache-2.0 pragma solidity 0.7.6; import "../libraries/LibOwnership.sol"; import "../interfaces/IERC173.sol"; contract OwnershipFacet is IERC173 { function transferOwnership(address _newOwner) external override { LibOwnership.enforceIsContractOwner(); LibOwnership.setContractOwner(_newOwner); } function owner() external override view returns (address owner_) { owner_ = LibOwnership.contractOwner(); } }
// SPDX-License-Identifier: Apache-2.0 pragma solidity 0.7.6; pragma experimental ABIEncoderV2; import "../interfaces/IDiamondCut.sol"; import "../libraries/LibDiamond.sol"; import "../libraries/LibOwnership.sol"; contract DiamondCutFacet is IDiamondCut { /// @notice Add/replace/remove any number of functions and optionally execute /// a function with delegatecall /// @param _diamondCut Contains the facet addresses and function selectors /// @param _init The address of the contract or facet to execute _calldata /// @param _calldata A function call, including function selector and arguments /// _calldata is executed with delegatecall on _init function diamondCut( FacetCut[] calldata _diamondCut, address _init, bytes calldata _calldata ) external override { LibOwnership.enforceIsContractOwner(); uint256 selectorCount = LibDiamondStorage.diamondStorage().selectors.length; for (uint256 facetIndex; facetIndex < _diamondCut.length; facetIndex++) { FacetCut memory cut; cut.action = _diamondCut[facetIndex].action; cut.facetAddress = _diamondCut[facetIndex].facetAddress; cut.functionSelectors = _diamondCut[facetIndex].functionSelectors; selectorCount = LibDiamond.executeDiamondCut(selectorCount, cut); } emit DiamondCut(_diamondCut, _init, _calldata); LibDiamond.initializeDiamondCut(_init, _calldata); } }
// SPDX-License-Identifier: Apache-2.0 pragma solidity 0.7.6; pragma experimental ABIEncoderV2; import "../libraries/LibDiamondStorage.sol"; import "../interfaces/IDiamondLoupe.sol"; import "../interfaces/IERC165.sol"; contract DiamondLoupeFacet is IDiamondLoupe, IERC165 { // Diamond Loupe Functions //////////////////////////////////////////////////////////////////// /// These functions are expected to be called frequently by tools. // // struct Facet { // address facetAddress; // bytes4[] functionSelectors; // } /// @notice Gets all facets and their selectors. /// @return facets_ Facet function facets() external override view returns (Facet[] memory facets_) { LibDiamondStorage.DiamondStorage storage ds = LibDiamondStorage.diamondStorage(); uint256 selectorCount = ds.selectors.length; // create an array set to the maximum size possible facets_ = new Facet[](selectorCount); // create an array for counting the number of selectors for each facet uint8[] memory numFacetSelectors = new uint8[](selectorCount); // total number of facets uint256 numFacets; // loop through function selectors for (uint256 selectorIndex; selectorIndex < selectorCount; selectorIndex++) { bytes4 selector = ds.selectors[selectorIndex]; address facetAddress_ = ds.facets[selector].facetAddress; bool continueLoop = false; // find the functionSelectors array for selector and add selector to it for (uint256 facetIndex; facetIndex < numFacets; facetIndex++) { if (facets_[facetIndex].facetAddress == facetAddress_) { facets_[facetIndex].functionSelectors[numFacetSelectors[facetIndex]] = selector; // probably will never have more than 256 functions from one facet contract require(numFacetSelectors[facetIndex] < 255); numFacetSelectors[facetIndex]++; continueLoop = true; break; } } // if functionSelectors array exists for selector then continue loop if (continueLoop) { continueLoop = false; continue; } // create a new functionSelectors array for selector facets_[numFacets].facetAddress = facetAddress_; facets_[numFacets].functionSelectors = new bytes4[](selectorCount); facets_[numFacets].functionSelectors[0] = selector; numFacetSelectors[numFacets] = 1; numFacets++; } for (uint256 facetIndex; facetIndex < numFacets; facetIndex++) { uint256 numSelectors = numFacetSelectors[facetIndex]; bytes4[] memory selectors = facets_[facetIndex].functionSelectors; // setting the number of selectors assembly { mstore(selectors, numSelectors) } } // setting the number of facets assembly { mstore(facets_, numFacets) } } /// @notice Gets all the function selectors supported by a specific facet. /// @param _facet The facet address. /// @return _facetFunctionSelectors The selectors associated with a facet address. function facetFunctionSelectors(address _facet) external override view returns (bytes4[] memory _facetFunctionSelectors) { LibDiamondStorage.DiamondStorage storage ds = LibDiamondStorage.diamondStorage(); uint256 selectorCount = ds.selectors.length; uint256 numSelectors; _facetFunctionSelectors = new bytes4[](selectorCount); // loop through function selectors for (uint256 selectorIndex; selectorIndex < selectorCount; selectorIndex++) { bytes4 selector = ds.selectors[selectorIndex]; address facetAddress_ = ds.facets[selector].facetAddress; if (_facet == facetAddress_) { _facetFunctionSelectors[numSelectors] = selector; numSelectors++; } } // Set the number of selectors in the array assembly { mstore(_facetFunctionSelectors, numSelectors) } } /// @notice Get all the facet addresses used by a diamond. /// @return facetAddresses_ function facetAddresses() external override view returns (address[] memory facetAddresses_) { LibDiamondStorage.DiamondStorage storage ds = LibDiamondStorage.diamondStorage(); uint256 selectorCount = ds.selectors.length; // create an array set to the maximum size possible facetAddresses_ = new address[](selectorCount); uint256 numFacets; // loop through function selectors for (uint256 selectorIndex; selectorIndex < selectorCount; selectorIndex++) { bytes4 selector = ds.selectors[selectorIndex]; address facetAddress_ = ds.facets[selector].facetAddress; bool continueLoop = false; // see if we have collected the address already and break out of loop if we have for (uint256 facetIndex; facetIndex < numFacets; facetIndex++) { if (facetAddress_ == facetAddresses_[facetIndex]) { continueLoop = true; break; } } // continue loop if we already have the address if (continueLoop) { continueLoop = false; continue; } // include address facetAddresses_[numFacets] = facetAddress_; numFacets++; } // Set the number of facet addresses in the array assembly { mstore(facetAddresses_, numFacets) } } /// @notice Gets the facet address that supports the given selector. /// @dev If facet is not found return address(0). /// @param _functionSelector The function selector. /// @return facetAddress_ The facet address. function facetAddress(bytes4 _functionSelector) external override view returns (address facetAddress_) { LibDiamondStorage.DiamondStorage storage ds = LibDiamondStorage.diamondStorage(); facetAddress_ = ds.facets[_functionSelector].facetAddress; } // This implements ERC-165. function supportsInterface(bytes4 _interfaceId) external override view returns (bool) { LibDiamondStorage.DiamondStorage storage ds = LibDiamondStorage.diamondStorage(); return ds.supportedInterfaces[_interfaceId]; } }
// SPDX-License-Identifier: Apache-2.0 pragma solidity 0.7.6; pragma experimental ABIEncoderV2; import "../libraries/LibBarnStorage.sol"; import "../libraries/LibOwnership.sol"; contract ChangeRewardsFacet { function changeRewardsAddress(address _rewards) public { LibOwnership.enforceIsContractOwner(); LibBarnStorage.Storage storage ds = LibBarnStorage.barnStorage(); ds.rewards = IRewards(_rewards); } }
// SPDX-License-Identifier: Apache-2.0 pragma solidity 0.7.6; pragma experimental ABIEncoderV2; import "@openzeppelin/contracts/token/ERC20/IERC20.sol"; import "../interfaces/IRewards.sol"; library LibBarnStorage { bytes32 constant STORAGE_POSITION = keccak256("com.barnbridge.barn.storage"); struct Checkpoint { uint256 timestamp; uint256 amount; } struct Stake { uint256 timestamp; uint256 amount; uint256 expiryTimestamp; address delegatedTo; } struct Storage { bool initialized; // mapping of user address to history of Stake objects // every user action creates a new object in the history mapping(address => Stake[]) userStakeHistory; // array of bond staked Checkpoint // deposits/withdrawals create a new object in the history (max one per block) Checkpoint[] bondStakedHistory; // mapping of user address to history of delegated power // every delegate/stopDelegate call create a new checkpoint (max one per block) mapping(address => Checkpoint[]) delegatedPowerHistory; IERC20 bond; IRewards rewards; } function barnStorage() internal pure returns (Storage storage ds) { bytes32 position = STORAGE_POSITION; assembly { ds.slot := position } } }
// SPDX-License-Identifier: MIT pragma solidity ^0.7.0; /** * @dev Interface of the ERC20 standard as defined in the EIP. */ interface IERC20 { /** * @dev Returns the amount of tokens in existence. */ function totalSupply() external view returns (uint256); /** * @dev Returns the amount of tokens owned by `account`. */ function balanceOf(address account) external view returns (uint256); /** * @dev Moves `amount` tokens from the caller's account to `recipient`. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transfer(address recipient, uint256 amount) external returns (bool); /** * @dev Returns the remaining number of tokens that `spender` will be * allowed to spend on behalf of `owner` through {transferFrom}. This is * zero by default. * * This value changes when {approve} or {transferFrom} are called. */ function allowance(address owner, address spender) external view returns (uint256); /** * @dev Sets `amount` as the allowance of `spender` over the caller's tokens. * * Returns a boolean value indicating whether the operation succeeded. * * IMPORTANT: Beware that changing an allowance with this method brings the risk * that someone may use both the old and the new allowance by unfortunate * transaction ordering. One possible solution to mitigate this race * condition is to first reduce the spender's allowance to 0 and set the * desired value afterwards: * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 * * Emits an {Approval} event. */ function approve(address spender, uint256 amount) external returns (bool); /** * @dev Moves `amount` tokens from `sender` to `recipient` using the * allowance mechanism. `amount` is then deducted from the caller's * allowance. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transferFrom(address sender, address recipient, uint256 amount) external returns (bool); /** * @dev Emitted when `value` tokens are moved from one account (`from`) to * another (`to`). * * Note that `value` may be zero. */ event Transfer(address indexed from, address indexed to, uint256 value); /** * @dev Emitted when the allowance of a `spender` for an `owner` is set by * a call to {approve}. `value` is the new allowance. */ event Approval(address indexed owner, address indexed spender, uint256 value); }
// SPDX-License-Identifier: Apache-2.0 pragma solidity 0.7.6; pragma experimental ABIEncoderV2; interface IRewards { function registerUserAction(address user) external; }
// SPDX-License-Identifier: Apache-2.0 pragma solidity 0.7.6; import "../interfaces/IRewards.sol"; contract BarnMock { IRewards public r; uint256 public bondStaked; mapping(address => uint256) private balances; function setRewards(address rewards) public { r = IRewards(rewards); } function callRegisterUserAction(address user) public { return r.registerUserAction(user); } function deposit(address user, uint256 amount) public { callRegisterUserAction(user); balances[user] = balances[user] + amount; bondStaked = bondStaked + amount; } function withdraw(address user, uint256 amount) public { require(balances[user] >= amount, "insufficient balance"); callRegisterUserAction(user); balances[user] = balances[user] - amount; bondStaked = bondStaked - amount; } function balanceOf(address user) public view returns (uint256) { return balances[user]; } }
// SPDX-License-Identifier: MIT pragma solidity ^0.7.0; import "../GSN/Context.sol"; /** * @dev Contract module which provides a basic access control mechanism, where * there is an account (an owner) that can be granted exclusive access to * specific functions. * * By default, the owner account will be the one that deploys the contract. This * can later be changed with {transferOwnership}. * * This module is used through inheritance. It will make available the modifier * `onlyOwner`, which can be applied to your functions to restrict their use to * the owner. */ abstract contract Ownable is Context { address private _owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); /** * @dev Initializes the contract setting the deployer as the initial owner. */ constructor () { address msgSender = _msgSender(); _owner = msgSender; emit OwnershipTransferred(address(0), msgSender); } /** * @dev Returns the address of the current owner. */ function owner() public view returns (address) { return _owner; } /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { require(_owner == _msgSender(), "Ownable: caller is not the owner"); _; } /** * @dev Leaves the contract without owner. It will not be possible to call * `onlyOwner` functions anymore. Can only be called by the current owner. * * NOTE: Renouncing ownership will leave the contract without an owner, * thereby removing any functionality that is only available to the owner. */ function renounceOwnership() public virtual onlyOwner { emit OwnershipTransferred(_owner, address(0)); _owner = address(0); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Can only be called by the current owner. */ function transferOwnership(address newOwner) public virtual onlyOwner { require(newOwner != address(0), "Ownable: new owner is the zero address"); emit OwnershipTransferred(_owner, newOwner); _owner = newOwner; } }
// SPDX-License-Identifier: MIT pragma solidity ^0.7.0; /** * @dev Wrappers over Solidity's arithmetic operations with added overflow * checks. * * Arithmetic operations in Solidity wrap on overflow. This can easily result * in bugs, because programmers usually assume that an overflow raises an * error, which is the standard behavior in high level programming languages. * `SafeMath` restores this intuition by reverting the transaction when an * operation overflows. * * Using this library instead of the unchecked operations eliminates an entire * class of bugs, so it's recommended to use it always. */ library SafeMath { /** * @dev Returns the addition of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `+` operator. * * Requirements: * * - Addition cannot overflow. */ function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; require(c >= a, "SafeMath: addition overflow"); return c; } /** * @dev Returns the subtraction of two unsigned integers, reverting on * overflow (when the result is negative). * * Counterpart to Solidity's `-` operator. * * Requirements: * * - Subtraction cannot overflow. */ function sub(uint256 a, uint256 b) internal pure returns (uint256) { return sub(a, b, "SafeMath: subtraction overflow"); } /** * @dev Returns the subtraction of two unsigned integers, reverting with custom message on * overflow (when the result is negative). * * Counterpart to Solidity's `-` operator. * * Requirements: * * - Subtraction cannot overflow. */ function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b <= a, errorMessage); uint256 c = a - b; return c; } /** * @dev Returns the multiplication of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `*` operator. * * Requirements: * * - Multiplication cannot overflow. */ function mul(uint256 a, uint256 b) internal pure returns (uint256) { // Gas optimization: this is cheaper than requiring 'a' not being zero, but the // benefit is lost if 'b' is also tested. // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522 if (a == 0) { return 0; } uint256 c = a * b; require(c / a == b, "SafeMath: multiplication overflow"); return c; } /** * @dev Returns the integer division of two unsigned integers. Reverts on * division by zero. The result is rounded towards zero. * * Counterpart to Solidity's `/` operator. Note: this function uses a * `revert` opcode (which leaves remaining gas untouched) while Solidity * uses an invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function div(uint256 a, uint256 b) internal pure returns (uint256) { return div(a, b, "SafeMath: division by zero"); } /** * @dev Returns the integer division of two unsigned integers. Reverts with custom message on * division by zero. The result is rounded towards zero. * * Counterpart to Solidity's `/` operator. Note: this function uses a * `revert` opcode (which leaves remaining gas untouched) while Solidity * uses an invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b > 0, errorMessage); uint256 c = a / b; // assert(a == b * c + a % b); // There is no case in which this doesn't hold return c; } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * Reverts when dividing by zero. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function mod(uint256 a, uint256 b) internal pure returns (uint256) { return mod(a, b, "SafeMath: modulo by zero"); } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * Reverts with custom message when dividing by zero. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b != 0, errorMessage); return a % b; } }
// SPDX-License-Identifier: Apache-2.0 pragma solidity 0.7.6; pragma experimental ABIEncoderV2; import "../libraries/LibBarnStorage.sol"; interface IBarn { // deposit allows a user to add more bond to his staked balance function deposit(uint256 amount) external; // withdraw allows a user to withdraw funds if the balance is not locked function withdraw(uint256 amount) external; // lock a user's currently staked balance until timestamp & add the bonus to his voting power function lock(uint256 timestamp) external; // delegate allows a user to delegate his voting power to another user function delegate(address to) external; // stopDelegate allows a user to take back the delegated voting power function stopDelegate() external; // lock the balance of a proposal creator until the voting ends; only callable by DAO function lockCreatorBalance(address user, uint256 timestamp) external; // balanceOf returns the current BOND balance of a user (bonus not included) function balanceOf(address user) external view returns (uint256); // balanceAtTs returns the amount of BOND that the user currently staked (bonus NOT included) function balanceAtTs(address user, uint256 timestamp) external view returns (uint256); // stakeAtTs returns the Stake object of the user that was valid at `timestamp` function stakeAtTs(address user, uint256 timestamp) external view returns (LibBarnStorage.Stake memory); // votingPower returns the voting power (bonus included) + delegated voting power for a user at the current block function votingPower(address user) external view returns (uint256); // votingPowerAtTs returns the voting power (bonus included) + delegated voting power for a user at a point in time function votingPowerAtTs(address user, uint256 timestamp) external view returns (uint256); // bondStaked returns the total raw amount of BOND staked at the current block function bondStaked() external view returns (uint256); // bondStakedAtTs returns the total raw amount of BOND users have deposited into the contract // it does not include any bonus function bondStakedAtTs(uint256 timestamp) external view returns (uint256); // delegatedPower returns the total voting power that a user received from other users function delegatedPower(address user) external view returns (uint256); // delegatedPowerAtTs returns the total voting power that a user received from other users at a point in time function delegatedPowerAtTs(address user, uint256 timestamp) external view returns (uint256); // multiplierAtTs calculates the multiplier at a given timestamp based on the user's stake a the given timestamp // it includes the decay mechanism function multiplierAtTs(address user, uint256 timestamp) external view returns (uint256); // userLockedUntil returns the timestamp until the user's balance is locked function userLockedUntil(address user) external view returns (uint256); // userDidDelegate returns the address to which a user delegated their voting power; address(0) if not delegated function userDelegatedTo(address user) external view returns (address); // bondCirculatingSupply returns the current circulating supply of BOND function bondCirculatingSupply() external view returns (uint256); }
// SPDX-License-Identifier: MIT pragma solidity ^0.7.0; /* * @dev Provides information about the current execution context, including the * sender of the transaction and its data. While these are generally available * via msg.sender and msg.data, they should not be accessed in such a direct * manner, since when dealing with GSN meta-transactions the account sending and * paying for execution may not be the actual sender (as far as an application * is concerned). * * This contract is only required for intermediate, library-like contracts. */ abstract contract Context { function _msgSender() internal view virtual returns (address payable) { return msg.sender; } function _msgData() internal view virtual returns (bytes memory) { this; // silence state mutability warning without generating bytecode - see https://github.com/ethereum/solidity/issues/2691 return msg.data; } }
// SPDX-License-Identifier: Apache-2.0 pragma solidity 0.7.6; import "../interfaces/IBarn.sol"; import "@openzeppelin/contracts/token/ERC20/IERC20.sol"; import "@openzeppelin/contracts/math/SafeMath.sol"; contract MulticallMock { using SafeMath for uint256; IBarn barn; IERC20 bond; constructor(address _barn, address _bond) { barn = IBarn(_barn); bond = IERC20(_bond); } function multiDelegate(uint256 amount, address user1, address user2) public { bond.approve(address(barn), amount); barn.deposit(amount); barn.delegate(user1); barn.delegate(user2); barn.delegate(user1); } function multiDeposit(uint256 amount) public { bond.approve(address(barn), amount.mul(3)); barn.deposit(amount); barn.deposit(amount); barn.deposit(amount); } }
// SPDX-License-Identifier: MIT pragma solidity ^0.7.0; import "../../GSN/Context.sol"; import "./IERC20.sol"; import "../../math/SafeMath.sol"; import "../../utils/Address.sol"; /** * @dev Implementation of the {IERC20} interface. * * This implementation is agnostic to the way tokens are created. This means * that a supply mechanism has to be added in a derived contract using {_mint}. * For a generic mechanism see {ERC20PresetMinterPauser}. * * TIP: For a detailed writeup see our guide * https://forum.zeppelin.solutions/t/how-to-implement-erc20-supply-mechanisms/226[How * to implement supply mechanisms]. * * We have followed general OpenZeppelin guidelines: functions revert instead * of returning `false` on failure. This behavior is nonetheless conventional * and does not conflict with the expectations of ERC20 applications. * * Additionally, an {Approval} event is emitted on calls to {transferFrom}. * This allows applications to reconstruct the allowance for all accounts just * by listening to said events. Other implementations of the EIP may not emit * these events, as it isn't required by the specification. * * Finally, the non-standard {decreaseAllowance} and {increaseAllowance} * functions have been added to mitigate the well-known issues around setting * allowances. See {IERC20-approve}. */ contract ERC20 is Context, IERC20 { using SafeMath for uint256; using Address for address; mapping (address => uint256) private _balances; mapping (address => mapping (address => uint256)) private _allowances; uint256 private _totalSupply; string private _name; string private _symbol; uint8 private _decimals; /** * @dev Sets the values for {name} and {symbol}, initializes {decimals} with * a default value of 18. * * To select a different value for {decimals}, use {_setupDecimals}. * * All three of these values are immutable: they can only be set once during * construction. */ constructor (string memory name_, string memory symbol_) { _name = name_; _symbol = symbol_; _decimals = 18; } /** * @dev Returns the name of the token. */ function name() public view returns (string memory) { return _name; } /** * @dev Returns the symbol of the token, usually a shorter version of the * name. */ function symbol() public view returns (string memory) { return _symbol; } /** * @dev Returns the number of decimals used to get its user representation. * For example, if `decimals` equals `2`, a balance of `505` tokens should * be displayed to a user as `5,05` (`505 / 10 ** 2`). * * Tokens usually opt for a value of 18, imitating the relationship between * Ether and Wei. This is the value {ERC20} uses, unless {_setupDecimals} is * called. * * NOTE: This information is only used for _display_ purposes: it in * no way affects any of the arithmetic of the contract, including * {IERC20-balanceOf} and {IERC20-transfer}. */ function decimals() public view returns (uint8) { return _decimals; } /** * @dev See {IERC20-totalSupply}. */ function totalSupply() public view override returns (uint256) { return _totalSupply; } /** * @dev See {IERC20-balanceOf}. */ function balanceOf(address account) public view override returns (uint256) { return _balances[account]; } /** * @dev See {IERC20-transfer}. * * Requirements: * * - `recipient` cannot be the zero address. * - the caller must have a balance of at least `amount`. */ function transfer(address recipient, uint256 amount) public virtual override returns (bool) { _transfer(_msgSender(), recipient, amount); return true; } /** * @dev See {IERC20-allowance}. */ function allowance(address owner, address spender) public view virtual override returns (uint256) { return _allowances[owner][spender]; } /** * @dev See {IERC20-approve}. * * Requirements: * * - `spender` cannot be the zero address. */ function approve(address spender, uint256 amount) public virtual override returns (bool) { _approve(_msgSender(), spender, amount); return true; } /** * @dev See {IERC20-transferFrom}. * * Emits an {Approval} event indicating the updated allowance. This is not * required by the EIP. See the note at the beginning of {ERC20}; * * Requirements: * - `sender` and `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. * - the caller must have allowance for ``sender``'s tokens of at least * `amount`. */ function transferFrom(address sender, address recipient, uint256 amount) public virtual override returns (bool) { _transfer(sender, recipient, amount); _approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance")); return true; } /** * @dev Atomically increases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. */ function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].add(addedValue)); return true; } /** * @dev Atomically decreases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. * - `spender` must have allowance for the caller of at least * `subtractedValue`. */ function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, "ERC20: decreased allowance below zero")); return true; } /** * @dev Moves tokens `amount` from `sender` to `recipient`. * * This is internal function is equivalent to {transfer}, and can be used to * e.g. implement automatic token fees, slashing mechanisms, etc. * * Emits a {Transfer} event. * * Requirements: * * - `sender` cannot be the zero address. * - `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. */ function _transfer(address sender, address recipient, uint256 amount) internal virtual { require(sender != address(0), "ERC20: transfer from the zero address"); require(recipient != address(0), "ERC20: transfer to the zero address"); _beforeTokenTransfer(sender, recipient, amount); _balances[sender] = _balances[sender].sub(amount, "ERC20: transfer amount exceeds balance"); _balances[recipient] = _balances[recipient].add(amount); emit Transfer(sender, recipient, amount); } /** @dev Creates `amount` tokens and assigns them to `account`, increasing * the total supply. * * Emits a {Transfer} event with `from` set to the zero address. * * Requirements * * - `to` cannot be the zero address. */ function _mint(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: mint to the zero address"); _beforeTokenTransfer(address(0), account, amount); _totalSupply = _totalSupply.add(amount); _balances[account] = _balances[account].add(amount); emit Transfer(address(0), account, amount); } /** * @dev Destroys `amount` tokens from `account`, reducing the * total supply. * * Emits a {Transfer} event with `to` set to the zero address. * * Requirements * * - `account` cannot be the zero address. * - `account` must have at least `amount` tokens. */ function _burn(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: burn from the zero address"); _beforeTokenTransfer(account, address(0), amount); _balances[account] = _balances[account].sub(amount, "ERC20: burn amount exceeds balance"); _totalSupply = _totalSupply.sub(amount); emit Transfer(account, address(0), amount); } /** * @dev Sets `amount` as the allowance of `spender` over the `owner` s tokens. * * This internal function is equivalent to `approve`, and can be used to * e.g. set automatic allowances for certain subsystems, etc. * * Emits an {Approval} event. * * Requirements: * * - `owner` cannot be the zero address. * - `spender` cannot be the zero address. */ function _approve(address owner, address spender, uint256 amount) internal virtual { require(owner != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); _allowances[owner][spender] = amount; emit Approval(owner, spender, amount); } /** * @dev Sets {decimals} to a value other than the default one of 18. * * WARNING: This function should only be called from the constructor. Most * applications that interact with token contracts will not expect * {decimals} to ever change, and may work incorrectly if it does. */ function _setupDecimals(uint8 decimals_) internal { _decimals = decimals_; } /** * @dev Hook that is called before any transfer of tokens. This includes * minting and burning. * * Calling conditions: * * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens * will be to transferred to `to`. * - when `from` is zero, `amount` tokens will be minted for `to`. * - when `to` is zero, `amount` of ``from``'s tokens will be burned. * - `from` and `to` are never both zero. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _beforeTokenTransfer(address from, address to, uint256 amount) internal virtual { } }
// SPDX-License-Identifier: MIT pragma solidity ^0.7.0; /** * @dev Collection of functions related to the address type */ library Address { /** * @dev Returns true if `account` is a contract. * * [IMPORTANT] * ==== * It is unsafe to assume that an address for which this function returns * false is an externally-owned account (EOA) and not a contract. * * Among others, `isContract` will return false for the following * types of addresses: * * - an externally-owned account * - a contract in construction * - an address where a contract will be created * - an address where a contract lived, but was destroyed * ==== */ function isContract(address account) internal view returns (bool) { // According to EIP-1052, 0x0 is the value returned for not-yet created accounts // and 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470 is returned // for accounts without code, i.e. `keccak256('')` bytes32 codehash; bytes32 accountHash = 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470; // solhint-disable-next-line no-inline-assembly assembly { codehash := extcodehash(account) } return (codehash != accountHash && codehash != 0x0); } /** * @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"); // solhint-disable-next-line avoid-low-level-calls, avoid-call-value (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"); return _functionCallWithValue(target, data, value, errorMessage); } function _functionCallWithValue(address target, bytes memory data, uint256 weiValue, string memory errorMessage) private returns (bytes memory) { require(isContract(target), "Address: call to non-contract"); // solhint-disable-next-line avoid-low-level-calls (bool success, bytes memory returndata) = target.call{ value: weiValue }(data); 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 // solhint-disable-next-line no-inline-assembly assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } } }
// SPDX-License-Identifier: Apache-2.0 pragma solidity 0.7.6; import "@openzeppelin/contracts/token/ERC20/ERC20.sol"; contract ERC20Mock is ERC20("ERC20Mock", "MCK") { bool public transferFromCalled = false; bool public transferCalled = false; address public transferRecipient = address(0); uint256 public transferAmount = 0; function mint(address user, uint256 amount) public { _mint(user, amount); } function burnFrom(address user, uint256 amount) public { _burn(user, amount); } function transferFrom(address sender, address recipient, uint256 amount) public virtual override returns (bool) { transferFromCalled = true; return super.transferFrom(sender, recipient, amount); } function transfer(address recipient, uint256 amount) public virtual override returns (bool) { transferCalled = true; transferRecipient = recipient; transferAmount = amount; return super.transfer(recipient, amount); } }
// SPDX-License-Identifier: Apache-2.0 pragma solidity 0.7.6; pragma experimental ABIEncoderV2; import "../interfaces/IBarn.sol"; import "../libraries/LibBarnStorage.sol"; import "../libraries/LibOwnership.sol"; import "@openzeppelin/contracts/math/SafeMath.sol"; import "@openzeppelin/contracts/token/ERC20/IERC20.sol"; contract BarnFacet { using SafeMath for uint256; uint256 constant public MAX_LOCK = 365 days; uint256 constant BASE_MULTIPLIER = 1e18; event Deposit(address indexed user, uint256 amount, uint256 newBalance); event Withdraw(address indexed user, uint256 amountWithdrew, uint256 amountLeft); event Lock(address indexed user, uint256 timestamp); event Delegate(address indexed from, address indexed to); event DelegatedPowerIncreased(address indexed from, address indexed to, uint256 amount, uint256 to_newDelegatedPower); event DelegatedPowerDecreased(address indexed from, address indexed to, uint256 amount, uint256 to_newDelegatedPower); function initBarn(address _bond, address _rewards) public { require(_bond != address(0), "BOND address must not be 0x0"); LibBarnStorage.Storage storage ds = LibBarnStorage.barnStorage(); require(!ds.initialized, "Barn: already initialized"); LibOwnership.enforceIsContractOwner(); ds.initialized = true; ds.bond = IERC20(_bond); ds.rewards = IRewards(_rewards); } // deposit allows a user to add more bond to his staked balance function deposit(uint256 amount) public { require(amount > 0, "Amount must be greater than 0"); LibBarnStorage.Storage storage ds = LibBarnStorage.barnStorage(); uint256 allowance = ds.bond.allowance(msg.sender, address(this)); require(allowance >= amount, "Token allowance too small"); // this must be called before the user's balance is updated so the rewards contract can calculate // the amount owed correctly if (address(ds.rewards) != address(0)) { ds.rewards.registerUserAction(msg.sender); } uint256 newBalance = balanceOf(msg.sender).add(amount); _updateUserBalance(ds.userStakeHistory[msg.sender], newBalance); _updateLockedBond(bondStakedAtTs(block.timestamp).add(amount)); address delegatedTo = userDelegatedTo(msg.sender); if (delegatedTo != address(0)) { uint256 newDelegatedPower = delegatedPower(delegatedTo).add(amount); _updateDelegatedPower(ds.delegatedPowerHistory[delegatedTo], newDelegatedPower); emit DelegatedPowerIncreased(msg.sender, delegatedTo, amount, newDelegatedPower); } ds.bond.transferFrom(msg.sender, address(this), amount); emit Deposit(msg.sender, amount, newBalance); } // withdraw allows a user to withdraw funds if the balance is not locked function withdraw(uint256 amount) public { require(amount > 0, "Amount must be greater than 0"); require(userLockedUntil(msg.sender) <= block.timestamp, "User balance is locked"); uint256 balance = balanceOf(msg.sender); require(balance >= amount, "Insufficient balance"); LibBarnStorage.Storage storage ds = LibBarnStorage.barnStorage(); // this must be called before the user's balance is updated so the rewards contract can calculate // the amount owed correctly if (address(ds.rewards) != address(0)) { ds.rewards.registerUserAction(msg.sender); } _updateUserBalance(ds.userStakeHistory[msg.sender], balance.sub(amount)); _updateLockedBond(bondStakedAtTs(block.timestamp).sub(amount)); address delegatedTo = userDelegatedTo(msg.sender); if (delegatedTo != address(0)) { uint256 newDelegatedPower = delegatedPower(delegatedTo).sub(amount); _updateDelegatedPower(ds.delegatedPowerHistory[delegatedTo], newDelegatedPower); emit DelegatedPowerDecreased(msg.sender, delegatedTo, amount, newDelegatedPower); } ds.bond.transfer(msg.sender, amount); emit Withdraw(msg.sender, amount, balance.sub(amount)); } // lock a user's currently staked balance until timestamp & add the bonus to his voting power function lock(uint256 timestamp) public { require(timestamp > block.timestamp, "Timestamp must be in the future"); require(timestamp <= block.timestamp + MAX_LOCK, "Timestamp too big"); require(balanceOf(msg.sender) > 0, "Sender has no balance"); LibBarnStorage.Storage storage ds = LibBarnStorage.barnStorage(); LibBarnStorage.Stake[] storage checkpoints = ds.userStakeHistory[msg.sender]; LibBarnStorage.Stake storage currentStake = checkpoints[checkpoints.length - 1]; require(timestamp > currentStake.expiryTimestamp, "New timestamp lower than current lock timestamp"); _updateUserLock(checkpoints, timestamp); emit Lock(msg.sender, timestamp); } function depositAndLock(uint256 amount, uint256 timestamp) public { deposit(amount); lock(timestamp); } // delegate allows a user to delegate his voting power to another user function delegate(address to) public { require(msg.sender != to, "Can't delegate to self"); uint256 senderBalance = balanceOf(msg.sender); require(senderBalance > 0, "No balance to delegate"); LibBarnStorage.Storage storage ds = LibBarnStorage.barnStorage(); emit Delegate(msg.sender, to); address delegatedTo = userDelegatedTo(msg.sender); if (delegatedTo != address(0)) { uint256 newDelegatedPower = delegatedPower(delegatedTo).sub(senderBalance); _updateDelegatedPower(ds.delegatedPowerHistory[delegatedTo], newDelegatedPower); emit DelegatedPowerDecreased(msg.sender, delegatedTo, senderBalance, newDelegatedPower); } if (to != address(0)) { uint256 newDelegatedPower = delegatedPower(to).add(senderBalance); _updateDelegatedPower(ds.delegatedPowerHistory[to], newDelegatedPower); emit DelegatedPowerIncreased(msg.sender, to, senderBalance, newDelegatedPower); } _updateUserDelegatedTo(ds.userStakeHistory[msg.sender], to); } // stopDelegate allows a user to take back the delegated voting power function stopDelegate() public { return delegate(address(0)); } // balanceOf returns the current BOND balance of a user (bonus not included) function balanceOf(address user) public view returns (uint256) { return balanceAtTs(user, block.timestamp); } // balanceAtTs returns the amount of BOND that the user currently staked (bonus NOT included) function balanceAtTs(address user, uint256 timestamp) public view returns (uint256) { LibBarnStorage.Stake memory stake = stakeAtTs(user, timestamp); return stake.amount; } // stakeAtTs returns the Stake object of the user that was valid at `timestamp` function stakeAtTs(address user, uint256 timestamp) public view returns (LibBarnStorage.Stake memory) { LibBarnStorage.Storage storage ds = LibBarnStorage.barnStorage(); LibBarnStorage.Stake[] storage stakeHistory = ds.userStakeHistory[user]; if (stakeHistory.length == 0 || timestamp < stakeHistory[0].timestamp) { return LibBarnStorage.Stake(block.timestamp, 0, block.timestamp, address(0)); } uint256 min = 0; uint256 max = stakeHistory.length - 1; if (timestamp >= stakeHistory[max].timestamp) { return stakeHistory[max]; } // binary search of the value in the array while (max > min) { uint256 mid = (max + min + 1) / 2; if (stakeHistory[mid].timestamp <= timestamp) { min = mid; } else { max = mid - 1; } } return stakeHistory[min]; } // votingPower returns the voting power (bonus included) + delegated voting power for a user at the current block function votingPower(address user) public view returns (uint256) { return votingPowerAtTs(user, block.timestamp); } // votingPowerAtTs returns the voting power (bonus included) + delegated voting power for a user at a point in time function votingPowerAtTs(address user, uint256 timestamp) public view returns (uint256) { LibBarnStorage.Stake memory stake = stakeAtTs(user, timestamp); uint256 ownVotingPower; // if the user delegated his voting power to another user, then he doesn't have any voting power left if (stake.delegatedTo != address(0)) { ownVotingPower = 0; } else { uint256 balance = stake.amount; uint256 multiplier = _stakeMultiplier(stake, timestamp); ownVotingPower = balance.mul(multiplier).div(BASE_MULTIPLIER); } uint256 delegatedVotingPower = delegatedPowerAtTs(user, timestamp); return ownVotingPower.add(delegatedVotingPower); } // bondStaked returns the total raw amount of BOND staked at the current block function bondStaked() public view returns (uint256) { return bondStakedAtTs(block.timestamp); } // bondStakedAtTs returns the total raw amount of BOND users have deposited into the contract // it does not include any bonus function bondStakedAtTs(uint256 timestamp) public view returns (uint256) { return _checkpointsBinarySearch(LibBarnStorage.barnStorage().bondStakedHistory, timestamp); } // delegatedPower returns the total voting power that a user received from other users function delegatedPower(address user) public view returns (uint256) { return delegatedPowerAtTs(user, block.timestamp); } // delegatedPowerAtTs returns the total voting power that a user received from other users at a point in time function delegatedPowerAtTs(address user, uint256 timestamp) public view returns (uint256) { return _checkpointsBinarySearch(LibBarnStorage.barnStorage().delegatedPowerHistory[user], timestamp); } // same as multiplierAtTs but for the current block timestamp function multiplierOf(address user) public view returns (uint256) { return multiplierAtTs(user, block.timestamp); } // multiplierAtTs calculates the multiplier at a given timestamp based on the user's stake a the given timestamp // it includes the decay mechanism function multiplierAtTs(address user, uint256 timestamp) public view returns (uint256) { LibBarnStorage.Stake memory stake = stakeAtTs(user, timestamp); return _stakeMultiplier(stake, timestamp); } // userLockedUntil returns the timestamp until the user's balance is locked function userLockedUntil(address user) public view returns (uint256) { LibBarnStorage.Stake memory c = stakeAtTs(user, block.timestamp); return c.expiryTimestamp; } // userDelegatedTo returns the address to which a user delegated their voting power; address(0) if not delegated function userDelegatedTo(address user) public view returns (address) { LibBarnStorage.Stake memory c = stakeAtTs(user, block.timestamp); return c.delegatedTo; } // _checkpointsBinarySearch executes a binary search on a list of checkpoints that's sorted chronologically // looking for the closest checkpoint that matches the specified timestamp function _checkpointsBinarySearch(LibBarnStorage.Checkpoint[] storage checkpoints, uint256 timestamp) internal view returns (uint256) { if (checkpoints.length == 0 || timestamp < checkpoints[0].timestamp) { return 0; } uint256 min = 0; uint256 max = checkpoints.length - 1; if (timestamp >= checkpoints[max].timestamp) { return checkpoints[max].amount; } // binary search of the value in the array while (max > min) { uint256 mid = (max + min + 1) / 2; if (checkpoints[mid].timestamp <= timestamp) { min = mid; } else { max = mid - 1; } } return checkpoints[min].amount; } // _stakeMultiplier calculates the multiplier for the given stake at the given timestamp function _stakeMultiplier(LibBarnStorage.Stake memory stake, uint256 timestamp) internal view returns (uint256) { if (timestamp >= stake.expiryTimestamp) { return BASE_MULTIPLIER; } uint256 diff = stake.expiryTimestamp - timestamp; if (diff >= MAX_LOCK) { return BASE_MULTIPLIER.mul(2); } return BASE_MULTIPLIER.add(diff.mul(BASE_MULTIPLIER).div(MAX_LOCK)); } // _updateUserBalance manages an array of checkpoints // if there's already a checkpoint for the same timestamp, the amount is updated // otherwise, a new checkpoint is inserted function _updateUserBalance(LibBarnStorage.Stake[] storage checkpoints, uint256 amount) internal { if (checkpoints.length == 0) { checkpoints.push(LibBarnStorage.Stake(block.timestamp, amount, block.timestamp, address(0))); } else { LibBarnStorage.Stake storage old = checkpoints[checkpoints.length - 1]; if (old.timestamp == block.timestamp) { old.amount = amount; } else { checkpoints.push(LibBarnStorage.Stake(block.timestamp, amount, old.expiryTimestamp, old.delegatedTo)); } } } // _updateUserLock updates the expiry timestamp on the user's stake // it assumes that if the user already has a balance, which is checked for in the lock function // then there must be at least 1 checkpoint function _updateUserLock(LibBarnStorage.Stake[] storage checkpoints, uint256 expiryTimestamp) internal { LibBarnStorage.Stake storage old = checkpoints[checkpoints.length - 1]; if (old.timestamp < block.timestamp) { checkpoints.push(LibBarnStorage.Stake(block.timestamp, old.amount, expiryTimestamp, old.delegatedTo)); } else { old.expiryTimestamp = expiryTimestamp; } } // _updateUserDelegatedTo updates the delegateTo property on the user's stake // it assumes that if the user already has a balance, which is checked for in the delegate function // then there must be at least 1 checkpoint function _updateUserDelegatedTo(LibBarnStorage.Stake[] storage checkpoints, address to) internal { LibBarnStorage.Stake storage old = checkpoints[checkpoints.length - 1]; if (old.timestamp < block.timestamp) { checkpoints.push(LibBarnStorage.Stake(block.timestamp, old.amount, old.expiryTimestamp, to)); } else { old.delegatedTo = to; } } // _updateDelegatedPower updates the power delegated TO the user in the checkpoints history function _updateDelegatedPower(LibBarnStorage.Checkpoint[] storage checkpoints, uint256 amount) internal { if (checkpoints.length == 0 || checkpoints[checkpoints.length - 1].timestamp < block.timestamp) { checkpoints.push(LibBarnStorage.Checkpoint(block.timestamp, amount)); } else { LibBarnStorage.Checkpoint storage old = checkpoints[checkpoints.length - 1]; old.amount = amount; } } // _updateLockedBond stores the new `amount` into the BOND locked history function _updateLockedBond(uint256 amount) internal { LibBarnStorage.Storage storage ds = LibBarnStorage.barnStorage(); if (ds.bondStakedHistory.length == 0 || ds.bondStakedHistory[ds.bondStakedHistory.length - 1].timestamp < block.timestamp) { ds.bondStakedHistory.push(LibBarnStorage.Checkpoint(block.timestamp, amount)); } else { LibBarnStorage.Checkpoint storage old = ds.bondStakedHistory[ds.bondStakedHistory.length - 1]; old.amount = amount; } } }
{ "optimizer": { "enabled": true, "runs": 9999 }, "outputSelection": { "*": { "*": [ "evm.bytecode", "evm.deployedBytecode", "abi" ] } }, "libraries": {} }
Contract Security Audit
- No Contract Security Audit Submitted- Submit Audit Here
[{"inputs":[{"internalType":"address","name":"_owner","type":"address"},{"internalType":"address","name":"_token","type":"address"},{"internalType":"address","name":"_barn","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"user","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"Claim","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"previousOwner","type":"address"},{"indexed":true,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnershipTransferred","type":"event"},{"inputs":[],"name":"ackFunds","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"balanceBefore","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"barn","outputs":[{"internalType":"contract IBarn","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"claim","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"currentMultiplier","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"disabled","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"lastPullTs","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"owed","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"pullFeature","outputs":[{"internalType":"address","name":"source","type":"address"},{"internalType":"uint256","name":"startTs","type":"uint256"},{"internalType":"uint256","name":"endTs","type":"uint256"},{"internalType":"uint256","name":"totalDuration","type":"uint256"},{"internalType":"uint256","name":"totalAmount","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"user","type":"address"}],"name":"registerUserAction","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"rewardToken","outputs":[{"internalType":"contract IERC20","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_barn","type":"address"}],"name":"setBarn","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"source","type":"address"},{"internalType":"uint256","name":"startTs","type":"uint256"},{"internalType":"uint256","name":"endTs","type":"uint256"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"setupPullToken","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"userMultiplier","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"}]
Contract Creation Code
60806040523480156200001157600080fd5b50604051620019ae380380620019ae833981016040819052620000349162000231565b60006200004062000112565b600080546001600160a01b0319166001600160a01b0383169081178255604051929350916000805160206200198e833981519152908290a3506001600160a01b038216620000ab5760405162461bcd60e51b8152600401620000a2906200027a565b60405180910390fd5b6001600160a01b038116620000d45760405162461bcd60e51b8152600401620000a290620002b1565b620000df8362000116565b600d80546001600160a01b039384166001600160a01b031991821617909155600c805492909316911617905550620002e8565b3390565b6200012062000112565b6000546001600160a01b0390811691161462000183576040805162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015290519081900360640190fd5b6001600160a01b038116620001ca5760405162461bcd60e51b8152600401808060200182810382526026815260200180620019686026913960400191505060405180910390fd5b600080546040516001600160a01b03808516939216916000805160206200198e83398151915291a3600080546001600160a01b0319166001600160a01b0392909216919091179055565b80516001600160a01b03811681146200022c57600080fd5b919050565b60008060006060848603121562000246578283fd5b620002518462000214565b9250620002616020850162000214565b9150620002716040850162000214565b90509250925092565b6020808252601c908201527f72657761726420746f6b656e206d757374206e6f742062652030783000000000604082015260600190565b6020808252601c908201527f6261726e2061646472657373206d757374206e6f742062652030783000000000604082015260600190565b61167080620002f86000396000f3fe608060405234801561001057600080fd5b506004361061011b5760003560e01c806377b28482116100b2578063b1a03b6b11610081578063ee07080511610066578063ee070805146101fd578063f2fde38b14610212578063f7c618c1146102255761011b565b8063b1a03b6b146101d7578063df18e047146101ea5761011b565b806377b28482146101ac5780638da5cb5b146101bf57806394b5798a146101c7578063acfd9325146101cf5761011b565b80634e71d92d116100ee5780634e71d92d1461018157806366a7d821146101895780636fbaaa1e1461019c578063715018a6146101a45761011b565b8063100223bb14610120578063194f480e1461013e5780633b342a85146101535780634831976c14610168575b600080fd5b61012861022d565b60405161013591906115ea565b60405180910390f35b610146610233565b604051610135919061118e565b610166610161366004611104565b61024f565b005b610170610324565b604051610135959493929190611206565b61012861034f565b610166610197366004611104565b61049f565b6101286104e2565b6101666104e8565b6101666101ba36600461111e565b6105ce565b610146610823565b61012861083f565b610166610845565b6101286101e5366004611104565b610a0d565b6101286101f8366004611104565b610a1f565b610205610a31565b6040516101359190611241565b610166610220366004611104565b610a3a565b610146610b90565b60075481565b600c5473ffffffffffffffffffffffffffffffffffffffff1681565b73ffffffffffffffffffffffffffffffffffffffff811661028b5760405162461bcd60e51b8152600401610282906114c2565b60405180910390fd5b610293610823565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16146102dd5760405162461bcd60e51b8152600401610282906115b3565b600c80547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff92909216919091179055565b60015460025460035460045460055473ffffffffffffffffffffffffffffffffffffffff9094169385565b600061035a33610bac565b336000908152600b6020526040902054806103875760405162461bcd60e51b81526004016102829061139a565b336000818152600b602052604080822091909155600d5490517fa9059cbb00000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff9091169163a9059cbb916103f1919085906004016111af565b602060405180830381600087803b15801561040b57600080fd5b505af115801561041f573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906104439190611156565b5061044c610845565b3373ffffffffffffffffffffffffffffffffffffffff167f47cee97cb7acd717b3c0aa1435d004cd5b3c8c57d70dbceb4e4458bbd60e39d48260405161049291906115ea565b60405180910390a2905090565b600c5473ffffffffffffffffffffffffffffffffffffffff1633146104d65760405162461bcd60e51b81526004016102829061124c565b6104df81610bac565b50565b60095481565b6104f0610c39565b60005473ffffffffffffffffffffffffffffffffffffffff90811691161461055f576040805162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015290519081900360640190fd5b6000805460405173ffffffffffffffffffffffffffffffffffffffff909116907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0908390a3600080547fffffffffffffffffffffffff0000000000000000000000000000000000000000169055565b6105d6610823565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16146106205760405162461bcd60e51b8152600401610282906115b3565b60065460ff16156106435760405162461bcd60e51b8152600401610282906113d1565b60015473ffffffffffffffffffffffffffffffffffffffff16156106c55773ffffffffffffffffffffffffffffffffffffffff8416156106955760405162461bcd60e51b8152600401610282906112e0565b600680547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff001660011790556106f8565b73ffffffffffffffffffffffffffffffffffffffff84166106f85760405162461bcd60e51b81526004016102829061133d565b73ffffffffffffffffffffffffffffffffffffffff84166107725782156107315760405162461bcd60e51b8152600401610282906114f9565b811561074f5760405162461bcd60e51b815260040161028290611556565b801561076d5760405162461bcd60e51b815260040161028290611408565b6107b1565b8282116107915760405162461bcd60e51b815260040161028290611465565b600081116107b15760405162461bcd60e51b815260040161028290611283565b600180547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff8616179055600283905560038290556108058284610c3d565b600455600581905560075483111561081d5760078390555b50505050565b60005473ffffffffffffffffffffffffffffffffffffffff1690565b60085481565b600d546040517f70a0823100000000000000000000000000000000000000000000000000000000815260009173ffffffffffffffffffffffffffffffffffffffff16906370a082319061089c90309060040161118e565b60206040518083038186803b1580156108b457600080fd5b505afa1580156108c8573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906108ec9190611176565b90508015806108fd57506008548111155b1561090a57600855610a0b565b600c54604080517fc2077e81000000000000000000000000000000000000000000000000000000008152905160009273ffffffffffffffffffffffffffffffffffffffff169163c2077e81916004808301926020929190829003018186803b15801561097557600080fd5b505afa158015610989573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906109ad9190611176565b9050806109bb575050610a0b565b60006109d260085484610c3d90919063ffffffff16565b905060006109fe6109f5846109ef85670de0b6b3a7640000610c88565b90610ce1565b60095490610d23565b6008949094555050506009555b565b600a6020526000908152604090205481565b600b6020526000908152604090205481565b60065460ff1681565b610a42610c39565b60005473ffffffffffffffffffffffffffffffffffffffff908116911614610ab1576040805162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015290519081900360640190fd5b73ffffffffffffffffffffffffffffffffffffffff8116610b035760405162461bcd60e51b81526004018080602001828103825260268152602001806115f46026913960400191505060405180910390fd5b6000805460405173ffffffffffffffffffffffffffffffffffffffff808516939216917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e091a3600080547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff92909216919091179055565b600d5473ffffffffffffffffffffffffffffffffffffffff1681565b610bb4610d7d565b610bbc610845565b6000610bc782610ee5565b73ffffffffffffffffffffffffffffffffffffffff83166000908152600b6020526040902054909150610bfa9082610d23565b73ffffffffffffffffffffffffffffffffffffffff9092166000908152600b6020908152604080832094909455600954600a9091529290209190915550565b3390565b6000610c7f83836040518060400160405280601e81526020017f536166654d6174683a207375627472616374696f6e206f766572666c6f770000815250610fe4565b90505b92915050565b600082610c9757506000610c82565b82820282848281610ca457fe5b0414610c7f5760405162461bcd60e51b815260040180806020018281038252602181526020018061161a6021913960400191505060405180910390fd5b6000610c7f83836040518060400160405280601a81526020017f536166654d6174683a206469766973696f6e206279207a65726f00000000000081525061107b565b600082820183811015610c7f576040805162461bcd60e51b815260206004820152601b60248201527f536166654d6174683a206164646974696f6e206f766572666c6f770000000000604482015290519081900360640190fd5b60015473ffffffffffffffffffffffffffffffffffffffff161580610da3575060025442105b15610dad57610a0b565b60035442811115610dbb5750425b8060075410610dca5750610a0b565b6000610de160075483610c3d90919063ffffffff16565b600454909150600090610e00906109ef84670de0b6b3a7640000610c88565b90506000610e28670de0b6b3a76400006109ef84600160040154610c8890919063ffffffff16565b42600755600d546001546040517f23b872dd00000000000000000000000000000000000000000000000000000000815292935073ffffffffffffffffffffffffffffffffffffffff918216926323b872dd92610e8c921690309086906004016111d5565b602060405180830381600087803b158015610ea657600080fd5b505af1158015610eba573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610ede9190611156565b5050505050565b73ffffffffffffffffffffffffffffffffffffffff81166000908152600a60205260408120546009548291610f1a9190610c3d565b600c546040517f70a08231000000000000000000000000000000000000000000000000000000008152919250610fdb91670de0b6b3a7640000916109ef91859173ffffffffffffffffffffffffffffffffffffffff16906370a0823190610f85908a9060040161118e565b60206040518083038186803b158015610f9d57600080fd5b505afa158015610fb1573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610fd59190611176565b90610c88565b9150505b919050565b600081848411156110735760405162461bcd60e51b81526004018080602001828103825283818151815260200191508051906020019080838360005b83811015611038578181015183820152602001611020565b50505050905090810190601f1680156110655780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b505050900390565b600081836110ca5760405162461bcd60e51b8152602060048201818152835160248401528351909283926044909101919085019080838360008315611038578181015183820152602001611020565b5060008385816110d657fe5b0495945050505050565b803573ffffffffffffffffffffffffffffffffffffffff81168114610fdf57600080fd5b600060208284031215611115578081fd5b610c7f826110e0565b60008060008060808587031215611133578283fd5b61113c856110e0565b966020860135965060408601359560600135945092505050565b600060208284031215611167578081fd5b81518015158114610c7f578182fd5b600060208284031215611187578081fd5b5051919050565b73ffffffffffffffffffffffffffffffffffffffff91909116815260200190565b73ffffffffffffffffffffffffffffffffffffffff929092168252602082015260400190565b73ffffffffffffffffffffffffffffffffffffffff9384168152919092166020820152604081019190915260600190565b73ffffffffffffffffffffffffffffffffffffffff959095168552602085019390935260408401919091526060830152608082015260a00190565b901515815260200190565b60208082526015908201527f6f6e6c792063616c6c61626c65206279206261726e0000000000000000000000604082015260600190565b6020808252602d908201527f736574757020636f6e74726163743a20616d6f756e74206d757374206265206760408201527f726561746572207468616e203000000000000000000000000000000000000000606082015260800190565b6020808252602e908201527f636f6e747261637420697320616c7265616479207365742075702c20736f757260408201527f6365206d75737420626520307830000000000000000000000000000000000000606082015260800190565b6020808252602c908201527f636f6e7472616374206973206e6f742073657475702c20736f75726365206d7560408201527f737420626520213d203078300000000000000000000000000000000000000000606082015260800190565b60208082526010908201527f6e6f7468696e6720746f20636c61696d00000000000000000000000000000000604082015260600190565b60208082526014908201527f636f6e74726163742069732064697361626c6564000000000000000000000000604082015260600190565b60208082526022908201527f64697361626c6520636f6e74726163743a20616d6f756e74206d75737420626560408201527f2030000000000000000000000000000000000000000000000000000000000000606082015260800190565b60208082526032908201527f736574757020636f6e74726163743a20656e645473206d75737420626520677260408201527f6561746572207468616e20737461727454730000000000000000000000000000606082015260800190565b6020808252601c908201527f6261726e2061646472657373206d757374206e6f742062652030783000000000604082015260600190565b60208082526023908201527f64697361626c6520636f6e74726163743a2073746172745473206d757374206260408201527f6520300000000000000000000000000000000000000000000000000000000000606082015260800190565b60208082526021908201527f64697361626c6520636f6e74726163743a20656e645473206d7573742062652060408201527f3000000000000000000000000000000000000000000000000000000000000000606082015260800190565b60208082526006908201527f216f776e65720000000000000000000000000000000000000000000000000000604082015260600190565b9081526020019056fe4f776e61626c653a206e6577206f776e657220697320746865207a65726f2061646472657373536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f77a26469706673582212207d247d8ed91b871edc5d442d65ce783bb6381f7c70230169a8c9122b7dc3c75b64736f6c634300070600334f776e61626c653a206e6577206f776e657220697320746865207a65726f20616464726573738be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e000000000000000000000000089d652c64d7cee18f5df53b24d9d29d130b187980000000000000000000000000391d2021f89dc339f60fff84546ea23e337750f00000000000000000000000010e138877df69ca44fdc68655f86c88cde142d7f
Deployed Bytecode
0x608060405234801561001057600080fd5b506004361061011b5760003560e01c806377b28482116100b2578063b1a03b6b11610081578063ee07080511610066578063ee070805146101fd578063f2fde38b14610212578063f7c618c1146102255761011b565b8063b1a03b6b146101d7578063df18e047146101ea5761011b565b806377b28482146101ac5780638da5cb5b146101bf57806394b5798a146101c7578063acfd9325146101cf5761011b565b80634e71d92d116100ee5780634e71d92d1461018157806366a7d821146101895780636fbaaa1e1461019c578063715018a6146101a45761011b565b8063100223bb14610120578063194f480e1461013e5780633b342a85146101535780634831976c14610168575b600080fd5b61012861022d565b60405161013591906115ea565b60405180910390f35b610146610233565b604051610135919061118e565b610166610161366004611104565b61024f565b005b610170610324565b604051610135959493929190611206565b61012861034f565b610166610197366004611104565b61049f565b6101286104e2565b6101666104e8565b6101666101ba36600461111e565b6105ce565b610146610823565b61012861083f565b610166610845565b6101286101e5366004611104565b610a0d565b6101286101f8366004611104565b610a1f565b610205610a31565b6040516101359190611241565b610166610220366004611104565b610a3a565b610146610b90565b60075481565b600c5473ffffffffffffffffffffffffffffffffffffffff1681565b73ffffffffffffffffffffffffffffffffffffffff811661028b5760405162461bcd60e51b8152600401610282906114c2565b60405180910390fd5b610293610823565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16146102dd5760405162461bcd60e51b8152600401610282906115b3565b600c80547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff92909216919091179055565b60015460025460035460045460055473ffffffffffffffffffffffffffffffffffffffff9094169385565b600061035a33610bac565b336000908152600b6020526040902054806103875760405162461bcd60e51b81526004016102829061139a565b336000818152600b602052604080822091909155600d5490517fa9059cbb00000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff9091169163a9059cbb916103f1919085906004016111af565b602060405180830381600087803b15801561040b57600080fd5b505af115801561041f573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906104439190611156565b5061044c610845565b3373ffffffffffffffffffffffffffffffffffffffff167f47cee97cb7acd717b3c0aa1435d004cd5b3c8c57d70dbceb4e4458bbd60e39d48260405161049291906115ea565b60405180910390a2905090565b600c5473ffffffffffffffffffffffffffffffffffffffff1633146104d65760405162461bcd60e51b81526004016102829061124c565b6104df81610bac565b50565b60095481565b6104f0610c39565b60005473ffffffffffffffffffffffffffffffffffffffff90811691161461055f576040805162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015290519081900360640190fd5b6000805460405173ffffffffffffffffffffffffffffffffffffffff909116907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0908390a3600080547fffffffffffffffffffffffff0000000000000000000000000000000000000000169055565b6105d6610823565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16146106205760405162461bcd60e51b8152600401610282906115b3565b60065460ff16156106435760405162461bcd60e51b8152600401610282906113d1565b60015473ffffffffffffffffffffffffffffffffffffffff16156106c55773ffffffffffffffffffffffffffffffffffffffff8416156106955760405162461bcd60e51b8152600401610282906112e0565b600680547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff001660011790556106f8565b73ffffffffffffffffffffffffffffffffffffffff84166106f85760405162461bcd60e51b81526004016102829061133d565b73ffffffffffffffffffffffffffffffffffffffff84166107725782156107315760405162461bcd60e51b8152600401610282906114f9565b811561074f5760405162461bcd60e51b815260040161028290611556565b801561076d5760405162461bcd60e51b815260040161028290611408565b6107b1565b8282116107915760405162461bcd60e51b815260040161028290611465565b600081116107b15760405162461bcd60e51b815260040161028290611283565b600180547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff8616179055600283905560038290556108058284610c3d565b600455600581905560075483111561081d5760078390555b50505050565b60005473ffffffffffffffffffffffffffffffffffffffff1690565b60085481565b600d546040517f70a0823100000000000000000000000000000000000000000000000000000000815260009173ffffffffffffffffffffffffffffffffffffffff16906370a082319061089c90309060040161118e565b60206040518083038186803b1580156108b457600080fd5b505afa1580156108c8573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906108ec9190611176565b90508015806108fd57506008548111155b1561090a57600855610a0b565b600c54604080517fc2077e81000000000000000000000000000000000000000000000000000000008152905160009273ffffffffffffffffffffffffffffffffffffffff169163c2077e81916004808301926020929190829003018186803b15801561097557600080fd5b505afa158015610989573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906109ad9190611176565b9050806109bb575050610a0b565b60006109d260085484610c3d90919063ffffffff16565b905060006109fe6109f5846109ef85670de0b6b3a7640000610c88565b90610ce1565b60095490610d23565b6008949094555050506009555b565b600a6020526000908152604090205481565b600b6020526000908152604090205481565b60065460ff1681565b610a42610c39565b60005473ffffffffffffffffffffffffffffffffffffffff908116911614610ab1576040805162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015290519081900360640190fd5b73ffffffffffffffffffffffffffffffffffffffff8116610b035760405162461bcd60e51b81526004018080602001828103825260268152602001806115f46026913960400191505060405180910390fd5b6000805460405173ffffffffffffffffffffffffffffffffffffffff808516939216917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e091a3600080547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff92909216919091179055565b600d5473ffffffffffffffffffffffffffffffffffffffff1681565b610bb4610d7d565b610bbc610845565b6000610bc782610ee5565b73ffffffffffffffffffffffffffffffffffffffff83166000908152600b6020526040902054909150610bfa9082610d23565b73ffffffffffffffffffffffffffffffffffffffff9092166000908152600b6020908152604080832094909455600954600a9091529290209190915550565b3390565b6000610c7f83836040518060400160405280601e81526020017f536166654d6174683a207375627472616374696f6e206f766572666c6f770000815250610fe4565b90505b92915050565b600082610c9757506000610c82565b82820282848281610ca457fe5b0414610c7f5760405162461bcd60e51b815260040180806020018281038252602181526020018061161a6021913960400191505060405180910390fd5b6000610c7f83836040518060400160405280601a81526020017f536166654d6174683a206469766973696f6e206279207a65726f00000000000081525061107b565b600082820183811015610c7f576040805162461bcd60e51b815260206004820152601b60248201527f536166654d6174683a206164646974696f6e206f766572666c6f770000000000604482015290519081900360640190fd5b60015473ffffffffffffffffffffffffffffffffffffffff161580610da3575060025442105b15610dad57610a0b565b60035442811115610dbb5750425b8060075410610dca5750610a0b565b6000610de160075483610c3d90919063ffffffff16565b600454909150600090610e00906109ef84670de0b6b3a7640000610c88565b90506000610e28670de0b6b3a76400006109ef84600160040154610c8890919063ffffffff16565b42600755600d546001546040517f23b872dd00000000000000000000000000000000000000000000000000000000815292935073ffffffffffffffffffffffffffffffffffffffff918216926323b872dd92610e8c921690309086906004016111d5565b602060405180830381600087803b158015610ea657600080fd5b505af1158015610eba573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610ede9190611156565b5050505050565b73ffffffffffffffffffffffffffffffffffffffff81166000908152600a60205260408120546009548291610f1a9190610c3d565b600c546040517f70a08231000000000000000000000000000000000000000000000000000000008152919250610fdb91670de0b6b3a7640000916109ef91859173ffffffffffffffffffffffffffffffffffffffff16906370a0823190610f85908a9060040161118e565b60206040518083038186803b158015610f9d57600080fd5b505afa158015610fb1573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610fd59190611176565b90610c88565b9150505b919050565b600081848411156110735760405162461bcd60e51b81526004018080602001828103825283818151815260200191508051906020019080838360005b83811015611038578181015183820152602001611020565b50505050905090810190601f1680156110655780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b505050900390565b600081836110ca5760405162461bcd60e51b8152602060048201818152835160248401528351909283926044909101919085019080838360008315611038578181015183820152602001611020565b5060008385816110d657fe5b0495945050505050565b803573ffffffffffffffffffffffffffffffffffffffff81168114610fdf57600080fd5b600060208284031215611115578081fd5b610c7f826110e0565b60008060008060808587031215611133578283fd5b61113c856110e0565b966020860135965060408601359560600135945092505050565b600060208284031215611167578081fd5b81518015158114610c7f578182fd5b600060208284031215611187578081fd5b5051919050565b73ffffffffffffffffffffffffffffffffffffffff91909116815260200190565b73ffffffffffffffffffffffffffffffffffffffff929092168252602082015260400190565b73ffffffffffffffffffffffffffffffffffffffff9384168152919092166020820152604081019190915260600190565b73ffffffffffffffffffffffffffffffffffffffff959095168552602085019390935260408401919091526060830152608082015260a00190565b901515815260200190565b60208082526015908201527f6f6e6c792063616c6c61626c65206279206261726e0000000000000000000000604082015260600190565b6020808252602d908201527f736574757020636f6e74726163743a20616d6f756e74206d757374206265206760408201527f726561746572207468616e203000000000000000000000000000000000000000606082015260800190565b6020808252602e908201527f636f6e747261637420697320616c7265616479207365742075702c20736f757260408201527f6365206d75737420626520307830000000000000000000000000000000000000606082015260800190565b6020808252602c908201527f636f6e7472616374206973206e6f742073657475702c20736f75726365206d7560408201527f737420626520213d203078300000000000000000000000000000000000000000606082015260800190565b60208082526010908201527f6e6f7468696e6720746f20636c61696d00000000000000000000000000000000604082015260600190565b60208082526014908201527f636f6e74726163742069732064697361626c6564000000000000000000000000604082015260600190565b60208082526022908201527f64697361626c6520636f6e74726163743a20616d6f756e74206d75737420626560408201527f2030000000000000000000000000000000000000000000000000000000000000606082015260800190565b60208082526032908201527f736574757020636f6e74726163743a20656e645473206d75737420626520677260408201527f6561746572207468616e20737461727454730000000000000000000000000000606082015260800190565b6020808252601c908201527f6261726e2061646472657373206d757374206e6f742062652030783000000000604082015260600190565b60208082526023908201527f64697361626c6520636f6e74726163743a2073746172745473206d757374206260408201527f6520300000000000000000000000000000000000000000000000000000000000606082015260800190565b60208082526021908201527f64697361626c6520636f6e74726163743a20656e645473206d7573742062652060408201527f3000000000000000000000000000000000000000000000000000000000000000606082015260800190565b60208082526006908201527f216f776e65720000000000000000000000000000000000000000000000000000604082015260600190565b9081526020019056fe4f776e61626c653a206e6577206f776e657220697320746865207a65726f2061646472657373536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f77a26469706673582212207d247d8ed91b871edc5d442d65ce783bb6381f7c70230169a8c9122b7dc3c75b64736f6c63430007060033
Constructor Arguments (ABI-Encoded and is the last bytes of the Contract Creation Code above)
00000000000000000000000089d652c64d7cee18f5df53b24d9d29d130b187980000000000000000000000000391d2021f89dc339f60fff84546ea23e337750f00000000000000000000000010e138877df69ca44fdc68655f86c88cde142d7f
-----Decoded View---------------
Arg [0] : _owner (address): 0x89d652C64d7CeE18F5DF53B24d9D29D130b18798
Arg [1] : _token (address): 0x0391D2021f89DC339F60Fff84546EA23E337750f
Arg [2] : _barn (address): 0x10e138877df69Ca44Fdc68655f86c88CDe142D7F
-----Encoded View---------------
3 Constructor Arguments found :
Arg [0] : 00000000000000000000000089d652c64d7cee18f5df53b24d9d29d130b18798
Arg [1] : 0000000000000000000000000391d2021f89dc339f60fff84546ea23e337750f
Arg [2] : 00000000000000000000000010e138877df69ca44fdc68655f86c88cde142d7f
Loading...
Loading
Loading...
Loading
Multichain Portfolio | 30 Chains
Chain | Token | Portfolio % | Price | Amount | Value |
---|---|---|---|---|---|
ETH | 100.00% | $0.385621 | 0.6118 | $0.2359 |
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.