More Info
Private Name Tags
Latest 25 from a total of 18,519 transactions
Transaction Hash |
Method
|
Block
|
From
|
To
|
|||||
---|---|---|---|---|---|---|---|---|---|
Redeem | 21255480 | 63 days ago | IN | 0 ETH | 0.00146712 | ||||
Redeem | 21185850 | 73 days ago | IN | 0 ETH | 0.00393221 | ||||
Redeem | 21158513 | 76 days ago | IN | 0 ETH | 0.00395918 | ||||
Print Reserved T... | 20684581 | 143 days ago | IN | 0 ETH | 0.00029651 | ||||
Deploy | 20145430 | 218 days ago | IN | 0 ETH | 0.0009386 | ||||
Redeem | 19844416 | 260 days ago | IN | 0 ETH | 0.00057512 | ||||
Redeem | 19622848 | 291 days ago | IN | 0 ETH | 0.00222136 | ||||
Redeem | 19601299 | 294 days ago | IN | 0 ETH | 0.00151698 | ||||
Migrate | 19471275 | 312 days ago | IN | 0 ETH | 0.00363539 | ||||
Tap | 19442576 | 316 days ago | IN | 0 ETH | 0.00511987 | ||||
Configure | 19390457 | 324 days ago | IN | 0 ETH | 0.0087139 | ||||
Redeem | 19348190 | 330 days ago | IN | 0 ETH | 0.0093881 | ||||
Configure | 19301462 | 336 days ago | IN | 0 ETH | 0.00427913 | ||||
Redeem | 19281443 | 339 days ago | IN | 0 ETH | 0.00468559 | ||||
Redeem | 19237608 | 345 days ago | IN | 0 ETH | 0.00342987 | ||||
Redeem | 19179589 | 353 days ago | IN | 0 ETH | 0.00467787 | ||||
Redeem | 19165102 | 355 days ago | IN | 0 ETH | 0.00317381 | ||||
Redeem | 19132103 | 360 days ago | IN | 0 ETH | 0.00273627 | ||||
Redeem | 19066690 | 369 days ago | IN | 0 ETH | 0.00127525 | ||||
Redeem | 19064135 | 369 days ago | IN | 0 ETH | 0.00221877 | ||||
Redeem | 19041176 | 373 days ago | IN | 0 ETH | 0.00441215 | ||||
Configure | 19013290 | 376 days ago | IN | 0 ETH | 0.00358814 | ||||
Redeem | 18916786 | 390 days ago | IN | 0 ETH | 0.0019535 | ||||
Redeem | 18876520 | 396 days ago | IN | 0 ETH | 0.00367019 | ||||
Redeem | 18869338 | 397 days ago | IN | 0 ETH | 0.00254731 |
Latest 25 internal transactions (View All)
Advanced mode:
Parent Transaction Hash | Block |
From
|
To
|
|||
---|---|---|---|---|---|---|
21255480 | 63 days ago | 0.02039087 ETH | ||||
21185850 | 73 days ago | 0.08156351 ETH | ||||
21158513 | 76 days ago | 0.02993513 ETH | ||||
19844416 | 260 days ago | 0.81563519 ETH | ||||
19622848 | 291 days ago | 0.19575244 ETH | ||||
19601299 | 294 days ago | 0.04078175 ETH | ||||
19471275 | 312 days ago | 4.505 ETH | ||||
19442576 | 316 days ago | 0.25 ETH | ||||
19348190 | 330 days ago | 0.07340716 ETH | ||||
19281443 | 339 days ago | 0.08156351 ETH | ||||
19237608 | 345 days ago | 0.40781759 ETH | ||||
19179589 | 353 days ago | 0.08156351 ETH | ||||
19165102 | 355 days ago | 0.02039087 ETH | ||||
19132103 | 360 days ago | 0.04078175 ETH | ||||
19066690 | 369 days ago | 0.04078175 ETH | ||||
19064135 | 369 days ago | 0.20380847 ETH | ||||
19041176 | 373 days ago | 0.15 ETH | ||||
18916786 | 390 days ago | 0.16312703 ETH | ||||
18876520 | 396 days ago | 0.16312703 ETH | ||||
18869338 | 397 days ago | 0.08156351 ETH | ||||
18770081 | 411 days ago | 0.2730832 ETH | ||||
18704466 | 420 days ago | 0.02446905 ETH | ||||
18619866 | 432 days ago | 0.08156351 ETH | ||||
18605521 | 434 days ago | 0.02854723 ETH | ||||
18585169 | 437 days ago | 0.08156351 ETH |
Loading...
Loading
Contract Source Code Verified (Exact Match)
Contract Name:
TerminalV1_1
Compiler Version
v0.8.6+commit.11564f7e
Optimization Enabled:
Yes with 10000 runs
Other Settings:
default evmVersion
Contract Source Code (Solidity Standard Json-Input format)
// SPDX-License-Identifier: MIT pragma solidity 0.8.6; import '@openzeppelin/contracts/security/ReentrancyGuard.sol'; import '@openzeppelin/contracts/utils/Address.sol'; import '@paulrberg/contracts/math/PRBMath.sol'; import '@paulrberg/contracts/math/PRBMathUD60x18.sol'; import './interfaces/ITerminalV1_1.sol'; import './abstract/JuiceboxProject.sol'; import './abstract/Operatable.sol'; import './libraries/Operations.sol'; /** ───────────────────────────────────────────────────────────────────────────────────────────────── ─────────██████──███████──██████──██████████──██████████████──██████████████──████████████████─── ─────────██░░██──███░░██──██░░██──██░░░░░░██──██░░░░░░░░░░██──██░░░░░░░░░░██──██░░░░░░░░░░░░██─── ─────────██░░██──███░░██──██░░██──████░░████──██░░██████████──██░░██████████──██░░████████░░██─── ─────────██░░██──███░░██──██░░██────██░░██────██░░██──────────██░░██──────────██░░██────██░░██─── ─────────██░░██──███░░██──██░░██────██░░██────██░░██──────────██░░██████████──██░░████████░░██─── ─────────██░░██──███░░██──██░░██────██░░██────██░░██──────────██░░░░░░░░░░██──██░░░░░░░░░░░░██─── ─██████──██░░██──███░░██──██░░██────██░░██────██░░██──────────██░░██████████──██░░██████░░████─── ─██░░██──██░░██──███░░██──██░░██────██░░██────██░░██──────────██░░██──────────██░░██──██░░██───── ─██░░██████░░██──███░░██████░░██──████░░████──██░░██████████──██░░██████████──██░░██──██░░██████─ ─██░░░░░░░░░░██──███░░░░░░░░░░██──██░░░░░░██──██░░░░░░░░░░██──██░░░░░░░░░░██──██░░██──██░░░░░░██─ ─██████████████──███████████████──██████████──██████████████──██████████████──██████──██████████─ ─────────────────────────────────────────────────────────────────────────────────────────── @notice This contract manages the Juicebox ecosystem, serves as a payment terminal, and custodies all funds. @dev A project can transfer its funds, along with the power to reconfigure and mint/burn their Tickets, from this contract to another allowed terminal contract at any time. */ contract TerminalV1_1 is Operatable, ITerminalV1_1, ITerminal, ReentrancyGuard, Ownable { // --- private stored properties --- // // The difference between the processed ticket tracker of a project and the project's ticket's total supply is the amount of tickets that // still need to have reserves printed against them. mapping(uint256 => int256) private _processedTicketTrackerOf; address private constant _deadAddress = address(0x000000000000000000000000000000000000dEaD); // --- public immutable stored properties --- // /// @notice The Projects contract which mints ERC-721's that represent project ownership and transfers. IProjects public immutable override projects; /// @notice The contract storing all funding cycle configurations. IFundingCycles public immutable override fundingCycles; /// @notice The contract that manages Ticket printing and redeeming. ITicketBooth public immutable override ticketBooth; /// @notice The contract that stores mods for each project. IModStore public immutable override modStore; /// @notice The prices feeds. IPrices public immutable override prices; /// @notice The directory of terminals. ITerminalDirectory public immutable override terminalDirectory; // --- public stored properties --- // /// @notice The amount of ETH that each project is responsible for. mapping(uint256 => uint256) public override balanceOf; /// @notice The percent fee the Juicebox project takes from tapped amounts. Out of 200. uint256 public override fee = 10; // Whether or not a particular contract is available for projects to migrate their funds and Tickets to. mapping(ITerminal => bool) public override migrationIsAllowed; // --- external views --- // /** @notice Gets the current overflowed amount for a specified project. @param _projectId The ID of the project to get overflow for. @return overflow The current overflow of funds for the project. */ function currentOverflowOf(uint256 _projectId) external view override returns (uint256 overflow) { // Get a reference to the project's current funding cycle. FundingCycle memory _fundingCycle = fundingCycles.currentOf(_projectId); return _overflowFrom(_fundingCycle); } /** @notice Gets the amount of reserved tickets that a project has. @param _projectId The ID of the project to get overflow for. @param _reservedRate The reserved rate to use to make the calculation. @return amount overflow The current overflow of funds for the project. */ function reservedTicketBalanceOf(uint256 _projectId, uint256 _reservedRate) external view override returns (uint256) { return _reservedTicketAmountFrom( _processedTicketTrackerOf[_projectId], _reservedRate, ticketBooth.totalSupplyOf(_projectId) ); } // --- public views --- // /** @notice The amount of tokens that can be claimed by the given address. @dev The _account must have at least _count tickets for the specified project. @dev If there is a funding cycle reconfiguration ballot open for the project, the project's current bonding curve is bypassed. @dev No more than the overflow can be claimable. @param _account The address to get an amount for. @param _projectId The ID of the project to get a claimable amount for. @param _count The number of Tickets that would be redeemed to get the resulting amount. @return _claimableOverflow amount The amount of tokens that can be claimed. */ function claimableOverflowOf( address _account, uint256 _projectId, uint256 _count ) public view override returns (uint256 _claimableOverflow) { // The holder must have the specified number of the project's tickets. require( ticketBooth.balanceOf(_account, _projectId) >= _count, 'TV1_1::claimableOverflow: INSUFFICIENT_TICKETS' ); // Get a reference to the current funding cycle for the project. FundingCycle memory _fundingCycle = fundingCycles.currentOf(_projectId); // There's no overflow if there's no funding cycle. if (_fundingCycle.number == 0) return 0; // Get the amount of current overflow. uint256 _overflow = _overflowFrom(_fundingCycle); // The redeemable amount is the current overflow. _claimableOverflow = _overflow; // Add any amount from the funding cycle's treasury extension if there is one. if (uint160(_fundingCycle.metadata >> 34) > 0) _claimableOverflow = _claimableOverflow + ITreasuryExtension(address(uint160(_fundingCycle.metadata >> 34))).ETHValue(_projectId); if (_claimableOverflow == 0) // If there is no redeemable overflow, nothing is claimable. return 0; // Get the total number of tickets in circulation. uint256 _totalSupply = ticketBooth.totalSupplyOf(_projectId); // Get the number of reserved tickets the project has. // The reserved rate is in bits 8-15 of the metadata. uint256 _reservedTicketAmount = _reservedTicketAmountFrom( _processedTicketTrackerOf[_projectId], uint256(uint8(_fundingCycle.metadata >> 8)), _totalSupply ); // If there are reserved tickets, add them to the total supply. if (_reservedTicketAmount > 0) _totalSupply = _totalSupply + _reservedTicketAmount; // If the amount being redeemed is the the total supply, return the rest of the overflow. if (_count == _totalSupply) // Only return up to the overflow amount. return _claimableOverflow > _overflow ? _overflow : _claimableOverflow; // Get a reference to the linear proportion. uint256 _base = PRBMath.mulDiv(_claimableOverflow, _count, _totalSupply); // Use the reconfiguration bonding curve if the queued cycle is pending approval according to the previous funding cycle's ballot. uint256 _bondingCurveRate = fundingCycles.currentBallotStateOf(_projectId) == BallotState.Active // The reconfiguration bonding curve rate is stored in bytes 24-31 of the metadata property. ? uint256(uint8(_fundingCycle.metadata >> 24)) // The bonding curve rate is stored in bytes 16-23 of the data property after. : uint256(uint8(_fundingCycle.metadata >> 16)); // The bonding curve formula. // https://www.desmos.com/calculator/sp9ru6zbpk // where x is _count, o is _currentOverflow, s is _totalSupply, and r is _bondingCurveRate. // These conditions are all part of the same curve. Edge conditions are separated because fewer operation are necessary. if (_bondingCurveRate == 200) { _claimableOverflow = _base; } else if (_bondingCurveRate == 0) { _claimableOverflow = PRBMath.mulDiv(_base, _count, _totalSupply); } else { _claimableOverflow = PRBMath.mulDiv( _base, _bondingCurveRate + PRBMath.mulDiv(_count, 200 - _bondingCurveRate, _totalSupply), 200 ); } // Only return up to the overflow amount. if (_claimableOverflow > _overflow) return _overflow; } // --- external transactions --- // /** @param _projects A Projects contract which mints ERC-721's that represent project ownership and transfers. @param _fundingCycles A funding cycle configuration store. @param _ticketBooth A contract that manages Ticket printing and redeeming. @param _operatorStore A contract storing operator assignments. @param _modStore A storage for a project's mods. @param _prices A price feed contract to use. @param _terminalDirectory A directory of a project's current Juicebox terminal to receive payments in. */ constructor( IProjects _projects, IFundingCycles _fundingCycles, ITicketBooth _ticketBooth, IOperatorStore _operatorStore, IModStore _modStore, IPrices _prices, ITerminalDirectory _terminalDirectory, address _owner ) Operatable(_operatorStore) { require( _projects != IProjects(address(0)) && _fundingCycles != IFundingCycles(address(0)) && _ticketBooth != ITicketBooth(address(0)) && _modStore != IModStore(address(0)) && _prices != IPrices(address(0)) && _terminalDirectory != ITerminalDirectory(address(0)) && _owner != address(0), 'TerminalV1: ZERO_ADDRESS' ); projects = _projects; fundingCycles = _fundingCycles; ticketBooth = _ticketBooth; modStore = _modStore; prices = _prices; terminalDirectory = _terminalDirectory; transferOwnership(_owner); } /** @notice Deploys a project. This will mint an ERC-721 into the `_owner`'s account, configure a first funding cycle, and set up any mods. @dev Each operation withing this transaction can be done in sequence separately. @dev Anyone can deploy a project on an owner's behalf. @param _owner The address that will own the project. @param _handle The project's unique handle. @param _uri A link to information about the project and this funding cycle. @param _properties The funding cycle configuration. @dev _properties.target The amount that the project wants to receive in this funding cycle. Sent as a wad. @dev _properties.currency The currency of the `target`. Send 0 for ETH or 1 for USD. @dev _properties.duration The duration of the funding stage for which the `target` amount is needed. Measured in days. Send 0 for a boundless cycle reconfigurable at any time. @dev _properties.cycleLimit The number of cycles that this configuration should last for before going back to the last permanent. This has no effect for a project's first funding cycle. @dev _properties.discountRate A number from 0-200 indicating how valuable a contribution to this funding stage is compared to the project's previous funding stage. If it's 200, each funding stage will have equal weight. If the number is 180, a contribution to the next funding stage will only give you 90% of tickets given to a contribution of the same amount during the current funding stage. If the number is 0, an non-recurring funding stage will get made. @dev _properties.ballot The new ballot that will be used to approve subsequent reconfigurations. @param _metadata A struct specifying the TerminalV1 specific params _bondingCurveRate, and _reservedRate. @dev _metadata.reservedRate A number from 0-200 indicating the percentage of each contribution's tickets that will be reserved for the project owner. @dev _metadata.bondingCurveRate The rate from 0-200 at which a project's Tickets can be redeemed for surplus. The bonding curve formula is https://www.desmos.com/calculator/sp9ru6zbpk where x is _count, o is _currentOverflow, s is _totalSupply, and r is _bondingCurveRate. @dev _metadata.reconfigurationBondingCurveRate The bonding curve rate to apply when there is an active ballot. @param _payoutMods Any payout mods to set. @param _ticketMods Any ticket mods to set. */ function deploy( address _owner, bytes32 _handle, string calldata _uri, FundingCycleProperties calldata _properties, FundingCycleMetadata2 calldata _metadata, PayoutMod[] memory _payoutMods, TicketMod[] memory _ticketMods ) external override { // Make sure the metadata checks out. If it does, return a packed version of it. uint256 _packedMetadata = _validateAndPackFundingCycleMetadata(_metadata); // Create the project for the owner. uint256 _projectId = projects.create(_owner, _handle, _uri, this); // Configure the funding stage's state. FundingCycle memory _fundingCycle = fundingCycles.configure( _projectId, _properties, _packedMetadata, fee, true ); // Set payout mods if there are any. if (_payoutMods.length > 0) modStore.setPayoutMods(_projectId, _fundingCycle.configured, _payoutMods); // Set ticket mods if there are any. if (_ticketMods.length > 0) modStore.setTicketMods(_projectId, _fundingCycle.configured, _ticketMods); } /** @notice Configures the properties of the current funding cycle if the project hasn't distributed tickets yet, or sets the properties of the proposed funding cycle that will take effect once the current one expires if it is approved by the current funding cycle's ballot. @dev Only a project's owner or a designated operator can configure its funding cycles. @param _projectId The ID of the project being reconfigured. @param _properties The funding cycle configuration. @dev _properties.target The amount that the project wants to receive in this funding stage. Sent as a wad. @dev _properties.currency The currency of the `target`. Send 0 for ETH or 1 for USD. @dev _properties.duration The duration of the funding stage for which the `target` amount is needed. Measured in days. Send 0 for a boundless cycle reconfigurable at any time. @dev _properties.cycleLimit The number of cycles that this configuration should last for before going back to the last permanent. This has no effect for a project's first funding cycle. @dev _properties.discountRate A number from 0-200 indicating how valuable a contribution to this funding stage is compared to the project's previous funding stage. If it's 200, each funding stage will have equal weight. If the number is 180, a contribution to the next funding stage will only give you 90% of tickets given to a contribution of the same amount during the current funding stage. If the number is 0, an non-recurring funding stage will get made. @dev _properties.ballot The new ballot that will be used to approve subsequent reconfigurations. @param _metadata A struct specifying the TerminalV1 specific params _bondingCurveRate, and _reservedRate. @dev _metadata.reservedRate A number from 0-200 indicating the percentage of each contribution's tickets that will be reserved for the project owner. @dev _metadata.bondingCurveRate The rate from 0-200 at which a project's Tickets can be redeemed for surplus. The bonding curve formula is https://www.desmos.com/calculator/sp9ru6zbpk where x is _count, o is _currentOverflow, s is _totalSupply, and r is _bondingCurveRate. @dev _metadata.reconfigurationBondingCurveRate The bonding curve rate to apply when there is an active ballot. @return The ID of the funding cycle that was successfully configured. */ function configure( uint256 _projectId, FundingCycleProperties calldata _properties, FundingCycleMetadata2 calldata _metadata, PayoutMod[] memory _payoutMods, TicketMod[] memory _ticketMods ) external override requirePermission(projects.ownerOf(_projectId), _projectId, Operations.Configure) returns (uint256) { // Make sure the metadata is validated, and pack it into a uint256. uint256 _packedMetadata = _validateAndPackFundingCycleMetadata(_metadata); // Configure the funding stage's state. FundingCycle memory _fundingCycle = fundingCycles.configure( _projectId, _properties, _packedMetadata, fee, false ); // Set payout mods for the new configuration if there are any. if (_payoutMods.length > 0) modStore.setPayoutMods(_projectId, _fundingCycle.configured, _payoutMods); // Set payout mods for the new configuration if there are any. if (_ticketMods.length > 0) modStore.setTicketMods(_projectId, _fundingCycle.configured, _ticketMods); return _fundingCycle.id; } /** @notice Allows a project to print tickets for a specified beneficiary. @dev Only a project's owner or a designated operator can print tickets. @param _projectId The ID of the project to print tickets for. @param _amount The amount of tickets to print. @param _beneficiary The address to send the printed tickets to. @param _memo A memo to leave with the printing. @param _preferUnstakedTickets If there is a preference to unstake the printed tickets. */ function printTickets( uint256 _projectId, uint256 _amount, address _beneficiary, string memory _memo, bool _preferUnstakedTickets ) external override requirePermission(projects.ownerOf(_projectId), _projectId, Operations.PrintTickets) { // Can't send to the zero address. require(_beneficiary != address(0), 'TV1_1::printTickets: ZERO_ADDRESS'); // Get a reference to the current funding cycle for the project. FundingCycle memory _fundingCycle = fundingCycles.currentOf(_projectId); // Make sure printing is allowed if a funding cycle exists. require( _fundingCycle.number == 0 || ((_fundingCycle.metadata >> 33) & 1) == 1, 'TV1_1::printTickets: NOT_ALLOWED' ); // Set the preconfigure tickets as processed so that reserved tickets cant be minted against them. // Make sure int casting isnt overflowing the int. 2^255 - 1 is the largest number that can be stored in an int. require( _processedTicketTrackerOf[_projectId] < 0 || uint256(_processedTicketTrackerOf[_projectId]) + _amount <= uint256(type(int256).max), 'TV1_1::printTickets: INT_LIMIT_REACHED' ); _processedTicketTrackerOf[_projectId] = _processedTicketTrackerOf[_projectId] + int256(_amount); // Print the project's tickets for the beneficiary. ticketBooth.print(_beneficiary, _projectId, _amount, _preferUnstakedTickets); emit PrintTickets(_projectId, _beneficiary, _amount, _memo, msg.sender); } /** @notice A function that burns the supply of the dead address for a project. @dev Callable by anyone. @param _projectId The ID of the project whose tokens are being burned. */ function burnFromDeadAddress(uint256 _projectId) external override { uint256 _deadBalance = ticketBooth.balanceOf(_deadAddress, _projectId); require(_deadBalance > 0, '0x00 NOTHING_TO_BURN'); ticketBooth.redeem(_deadAddress, _projectId, _deadBalance, true); } /** @notice Contribute ETH to a project. @dev Print's the project's tickets proportional to the amount of the contribution. @dev The msg.value is the amount of the contribution in wei. @param _projectId The ID of the project being contribute to. @param _beneficiary The address to print Tickets for. @param _memo A memo that will be included in the published event. @param _preferUnstakedTickets Whether ERC20's should be unstaked automatically if they have been issued. @return The ID of the funding cycle that the payment was made during. */ function pay( uint256 _projectId, address _beneficiary, string calldata _memo, bool _preferUnstakedTickets ) external payable override returns (uint256) { // Positive payments only. require(msg.value > 0, 'TV1_1::pay: BAD_AMOUNT'); // Cant send tickets to the zero address. require(_beneficiary != address(0), 'TV1_1::pay: ZERO_ADDRESS'); return _pay(_projectId, msg.value, _beneficiary, _memo, _preferUnstakedTickets); } /** @notice Tap into funds that have been contributed to a project's current funding cycle. @dev Anyone can tap funds on a project's behalf. @param _projectId The ID of the project to which the funding cycle being tapped belongs. @param _amount The amount being tapped, in the funding cycle's currency. @param _currency The expected currency being tapped. @param _minReturnedWei The minimum number of wei that the amount should be valued at. @return The ID of the funding cycle that was tapped. */ function tap( uint256 _projectId, uint256 _amount, uint256 _currency, uint256 _minReturnedWei ) external override nonReentrant returns (uint256) { // Register the funds as tapped. Get the ID of the funding cycle that was tapped. FundingCycle memory _fundingCycle = fundingCycles.tap(_projectId, _amount); // If there's no funding cycle, there are no funds to tap. if (_fundingCycle.id == 0) return 0; // Make sure the currency's match. require(_currency == _fundingCycle.currency, 'TV1_1::tap: UNEXPECTED_CURRENCY'); // Get a reference to this project's current balance, including any earned yield. // Get the currency price of ETH. uint256 _ethPrice = prices.getETHPriceFor(_fundingCycle.currency); // Get the price of ETH. // The amount of ETH that is being tapped. uint256 _tappedWeiAmount = PRBMathUD60x18.div(_amount, _ethPrice); // The amount being tapped must be at least as much as was expected. require(_minReturnedWei <= _tappedWeiAmount, 'TV1_1::tap: INADEQUATE'); // Get a reference to this project's current balance, including any earned yield. uint256 _balance = balanceOf[_fundingCycle.projectId]; // The amount being tapped must be available. require(_tappedWeiAmount <= _balance, 'TV1_1::tap: INSUFFICIENT_FUNDS'); // Removed the tapped funds from the project's balance. balanceOf[_projectId] = _balance - _tappedWeiAmount; // Get a reference to the project owner, which will receive the admin's tickets from paying the fee, // and receive any extra tapped funds not allocated to mods. address payable _projectOwner = payable(projects.ownerOf(_fundingCycle.projectId)); // Get a reference to the handle of the project paying the fee and sending payouts. bytes32 _handle = projects.handleOf(_projectId); // Take a fee from the _tappedWeiAmount, if needed. // The project's owner will be the beneficiary of the resulting printed tickets from the governance project. uint256 _feeAmount = _fundingCycle.fee > 0 ? _takeFee( _tappedWeiAmount, _fundingCycle.fee, _projectOwner, string(bytes.concat('Fee from @', _handle)) ) : 0; // Payout to mods and get a reference to the leftover transfer amount after all mods have been paid. // The net transfer amount is the tapped amount minus the fee. uint256 _leftoverTransferAmount = _distributeToPayoutMods( _fundingCycle, _tappedWeiAmount - _feeAmount, string(bytes.concat('Payout from @', _handle)) ); // Transfer any remaining balance to the beneficiary. if (_leftoverTransferAmount > 0) Address.sendValue(_projectOwner, _leftoverTransferAmount); emit Tap( _fundingCycle.id, _fundingCycle.projectId, _projectOwner, _amount, _fundingCycle.currency, _tappedWeiAmount - _feeAmount, _leftoverTransferAmount, _feeAmount, msg.sender ); return _fundingCycle.id; } /** @notice Addresses can redeem their Tickets to claim the project's overflowed ETH. @dev Only a ticket's holder or a designated operator can redeem it. @param _account The account to redeem tickets for. @param _projectId The ID of the project to which the Tickets being redeemed belong. @param _count The number of Tickets to redeem. @param _minReturnedWei The minimum amount of Wei expected in return. @param _beneficiary The address to send the ETH to. @param _preferUnstaked If the preference is to redeem tickets that have been converted to ERC-20s. @return amount The amount of ETH that the tickets were redeemed for. */ function redeem( address _account, uint256 _projectId, uint256 _count, uint256 _minReturnedWei, address payable _beneficiary, bool _preferUnstaked ) external override nonReentrant requirePermissionAllowingWildcardDomain(_account, _projectId, Operations.Redeem) returns (uint256 amount) { // There must be an amount specified to redeem. require(_count > 0, 'TV1_1::redeem: NO_OP'); // Can't send claimed funds to the zero address. require(_beneficiary != address(0), 'TV1_1::redeem: ZERO_ADDRESS'); // The amount of ETH claimable by the message sender from the specified project by redeeming the specified number of tickets. amount = claimableOverflowOf(_account, _projectId, _count); // The amount being claimed must be at least as much as was expected. require(amount >= _minReturnedWei, 'TV1_1::redeem: INADEQUATE'); if (amount > 0) // Remove the redeemed funds from the project's balance. balanceOf[_projectId] = balanceOf[_projectId] - amount; // Get a reference to the processed ticket tracker for the project. int256 _processedTicketTracker = _processedTicketTrackerOf[_projectId]; // Subtract the count from the processed ticket tracker. // Subtract from processed tickets so that the difference between whats been processed and the // total supply remains the same. // If there are at least as many processed tickets as there are tickets being redeemed, // the processed ticket tracker of the project will be positive. Otherwise it will be negative. _processedTicketTrackerOf[_projectId] = _processedTicketTracker < 0 // If the tracker is negative, add the count and reverse it. ? -int256(uint256(-_processedTicketTracker) + _count) // the tracker is less than the count, subtract it from the count and reverse it. : _processedTicketTracker < int256(_count) ? -(int256(_count) - _processedTicketTracker) // simply subtract otherwise. : _processedTicketTracker - int256(_count); // Redeem the tickets, which burns them. ticketBooth.redeem(_account, _projectId, _count, _preferUnstaked); if (amount > 0) // Transfer funds to the specified address. Address.sendValue(_beneficiary, amount); emit Redeem(_account, _beneficiary, _projectId, _count, amount, msg.sender); } /** @notice Allows a project owner to migrate its funds and operations to a new contract. @dev Only a project's owner or a designated operator can migrate it. @param _projectId The ID of the project being migrated. @param _to The contract that will gain the project's funds. */ function migrate(uint256 _projectId, ITerminal _to) external override requirePermission(projects.ownerOf(_projectId), _projectId, Operations.Migrate) nonReentrant { // This TerminalV1 must be the project's current terminal. require(terminalDirectory.terminalOf(_projectId) == this, 'TV1_1::migrate: UNAUTHORIZED'); // The migration destination must be allowed. require(migrationIsAllowed[_to], 'TV1_1::migrate: NOT_ALLOWED'); // All reserved tickets must be printed before migrating. if (uint256(_processedTicketTrackerOf[_projectId]) != ticketBooth.totalSupplyOf(_projectId)) printReservedTickets(_projectId); // Get a reference to this project's current balance, included any earned yield. uint256 _balanceOf = balanceOf[_projectId]; // Set the balance to 0. balanceOf[_projectId] = 0; // Move the funds to the new contract if needed. if (_balanceOf > 0) _to.addToBalance{value: _balanceOf}(_projectId); // Switch the direct payment terminal. terminalDirectory.setTerminal(_projectId, _to); emit Migrate(_projectId, _to, _balanceOf, msg.sender); } /** @notice Receives and allocates funds belonging to the specified project. @param _projectId The ID of the project to which the funds received belong. */ function addToBalance(uint256 _projectId) external payable override { // The amount must be positive. require(msg.value > 0, 'TV1_1::addToBalance: BAD_AMOUNT'); // If moving funds over, make sure the tokens moving over are also if (terminalDirectory.terminalOf(_projectId) != this) _processedTicketTrackerOf[_projectId] = int256(ticketBooth.totalSupplyOf(_projectId)); balanceOf[_projectId] = balanceOf[_projectId] + msg.value; emit AddToBalance(_projectId, msg.value, msg.sender); } /** @notice Adds to the contract addresses that projects can migrate their Tickets to. @dev Only governance can add a contract to the migration allow list. @param _contract The contract to allow. */ function allowMigration(ITerminal _contract) external override onlyOwner { // Can't allow the zero address. require(_contract != ITerminal(address(0)), 'TV1_1::allowMigration: ZERO_ADDRESS'); // Can't migrate to this same contract require(_contract != this, 'TV1_1::allowMigration: NO_OP'); // Set the contract as allowed migrationIsAllowed[_contract] = true; emit AllowMigration(_contract); } /** @notice Allow the admin to change the fee. @dev Only funding cycle reconfigurations after the new fee is set will use the new fee. All future funding cycles based on configurations made in the past will use the fee that was set at the time of the configuration. @dev Only the owner can set a new fee. @dev The max fee is 5%. @param _fee The new fee percent. Out of 200. */ function setFee(uint256 _fee) external override onlyOwner { // Fee must be under 5%. require(_fee <= 10, 'TV1_1::setFee: BAD_FEE'); // Set the fee. fee = _fee; emit SetFee(_fee); } // --- public transactions --- // /** @notice Prints all reserved tickets for a project. @param _projectId The ID of the project to which the reserved tickets belong. @return amount The amount of tickets that are being printed. */ function printReservedTickets(uint256 _projectId) public override returns (uint256 amount) { // Get the current funding cycle to read the reserved rate from. FundingCycle memory _fundingCycle = fundingCycles.currentOf(_projectId); // If there's no funding cycle, there's no reserved tickets to print. if (_fundingCycle.id == 0) return 0; // Get a reference to new total supply of tickets before printing reserved tickets. uint256 _totalTickets = ticketBooth.totalSupplyOf(_projectId); // Get a reference to the number of tickets that need to be printed. // If there's no funding cycle, there's no tickets to print. // The reserved rate is in bits 8-15 of the metadata. amount = _reservedTicketAmountFrom( _processedTicketTrackerOf[_projectId], uint256(uint8(_fundingCycle.metadata >> 8)), _totalTickets ); // Make sure int casting isnt overflowing the int. 2^255 - 1 is the largest number that can be stored in an int. require( _totalTickets + amount <= uint256(type(int256).max), 'TV1_1::printReservedTickets: INT_LIMIT_REACHED' ); // Set the tracker to be the new total supply. _processedTicketTrackerOf[_projectId] = int256(_totalTickets + amount); // If needed istribute tickets to mods and get a reference to the leftover amount to print after all mods have had their share printed. uint256 _leftoverTicketAmount = amount == 0 ? 0 : _distributeToTicketMods(_fundingCycle, amount); // Get a reference to the project owner. address _owner = projects.ownerOf(_projectId); // Print any remaining reserved tickets to the owner. if (_leftoverTicketAmount > 0) ticketBooth.print(_owner, _projectId, _leftoverTicketAmount, false); emit PrintReserveTickets( _fundingCycle.id, _projectId, _owner, amount, _leftoverTicketAmount, msg.sender ); } // --- private helper functions --- // /** @notice Pays out the mods for the specified funding cycle. @param _fundingCycle The funding cycle to base the distribution on. @param _amount The total amount being paid out. @param _memo A memo to send along with project payouts. @return leftoverAmount If the mod percents dont add up to 100%, the leftover amount is returned. */ function _distributeToPayoutMods( FundingCycle memory _fundingCycle, uint256 _amount, string memory _memo ) private returns (uint256 leftoverAmount) { // Set the leftover amount to the initial amount. leftoverAmount = _amount; // Get a reference to the project's payout mods. PayoutMod[] memory _mods = modStore.payoutModsOf( _fundingCycle.projectId, _fundingCycle.configured ); if (_mods.length == 0) return leftoverAmount; //Transfer between all mods. for (uint256 _i = 0; _i < _mods.length; _i++) { // Get a reference to the mod being iterated on. PayoutMod memory _mod = _mods[_i]; // The amount to send towards mods. Mods percents are out of 10000. uint256 _modCut = PRBMath.mulDiv(_amount, _mod.percent, 10000); if (_modCut > 0) { // Transfer ETH to the mod. // If there's an allocator set, transfer to its `allocate` function. if (_mod.allocator != IModAllocator(address(0))) { _mod.allocator.allocate{value: _modCut}( _fundingCycle.projectId, _mod.projectId, _mod.beneficiary ); } else if (_mod.projectId != 0) { // Otherwise, if a project is specified, make a payment to it. // Get a reference to the Juicebox terminal being used. ITerminal _terminal = terminalDirectory.terminalOf(_mod.projectId); // The project must have a terminal to send funds to. require(_terminal != ITerminal(address(0)), 'TV1_1::tap: BAD_MOD'); // Save gas if this contract is being used as the terminal. if (_terminal == this) { _pay(_mod.projectId, _modCut, _mod.beneficiary, _memo, _mod.preferUnstaked); } else { _terminal.pay{value: _modCut}( _mod.projectId, _mod.beneficiary, _memo, _mod.preferUnstaked ); } } else { // Otherwise, send the funds directly to the beneficiary. Address.sendValue(_mod.beneficiary, _modCut); } } // Subtract from the amount to be sent to the beneficiary. leftoverAmount = leftoverAmount - _modCut; emit DistributeToPayoutMod( _fundingCycle.id, _fundingCycle.projectId, _mod, _modCut, msg.sender ); } } /** @notice distributed tickets to the mods for the specified funding cycle. @param _fundingCycle The funding cycle to base the ticket distribution on. @param _amount The total amount of tickets to print. @return leftoverAmount If the mod percents dont add up to 100%, the leftover amount is returned. */ function _distributeToTicketMods(FundingCycle memory _fundingCycle, uint256 _amount) private returns (uint256 leftoverAmount) { // Set the leftover amount to the initial amount. leftoverAmount = _amount; // Get a reference to the project's ticket mods. TicketMod[] memory _mods = modStore.ticketModsOf( _fundingCycle.projectId, _fundingCycle.configured ); //Transfer between all mods. for (uint256 _i = 0; _i < _mods.length; _i++) { // Get a reference to the mod being iterated on. TicketMod memory _mod = _mods[_i]; // The amount to send towards mods. Mods percents are out of 10000. uint256 _modCut = PRBMath.mulDiv(_amount, _mod.percent, 10000); // Print tickets for the mod if needed. if (_modCut > 0) ticketBooth.print(_mod.beneficiary, _fundingCycle.projectId, _modCut, _mod.preferUnstaked); // Subtract from the amount to be sent to the beneficiary. leftoverAmount = leftoverAmount - _modCut; emit DistributeToTicketMod( _fundingCycle.id, _fundingCycle.projectId, _mod, _modCut, msg.sender ); } } /** @notice See the documentation for 'pay'. */ function _pay( uint256 _projectId, uint256 _amount, address _beneficiary, string memory _memo, bool _preferUnstakedTickets ) private returns (uint256) { // Get a reference to the current funding cycle for the project. FundingCycle memory _fundingCycle = fundingCycles.currentOf(_projectId); // Make sure its not paused. require(((_fundingCycle.metadata >> 32) & 1) == 0, 'TV1_1::pay: PAUSED'); // Use the funding cycle's weight if it exists. Otherwise use the base weight. uint256 _weight = _fundingCycle.number == 0 ? fundingCycles.BASE_WEIGHT() : _fundingCycle.weight; // Multiply the amount by the funding cycle's weight to determine the amount of tickets to print. uint256 _weightedAmount = PRBMathUD60x18.mul(_amount, _weight); // Use the funding cycle's reserved rate if it exists. Otherwise don't set a reserved rate. // The reserved rate is stored in bytes 8-15 of the metadata property. uint256 _reservedRate = _fundingCycle.number == 0 ? 0 : uint256(uint8(_fundingCycle.metadata >> 8)); // Only print the tickets that are unreserved. uint256 _unreservedWeightedAmount = PRBMath.mulDiv(_weightedAmount, 200 - _reservedRate, 200); // Add to the balance of the project. balanceOf[_projectId] = balanceOf[_projectId] + _amount; // If theres an unreserved weighted amount, print tickets representing this amount for the beneficiary. if (_unreservedWeightedAmount > 0) { // If there's no funding cycle, track this payment as having been made before a configuration. if (_fundingCycle.number == 0) { // Mark the premined tickets as processed so that reserved tickets can't later be printed against them. // Make sure int casting isnt overflowing the int. 2^255 - 1 is the largest number that can be stored in an int. require( _processedTicketTrackerOf[_projectId] < 0 || uint256(_processedTicketTrackerOf[_projectId]) + uint256(_weightedAmount) <= uint256(type(int256).max), 'TV1_1::pay INT_LIMIT_REACHED' ); _processedTicketTrackerOf[_projectId] = _processedTicketTrackerOf[_projectId] + int256(_unreservedWeightedAmount); } // Print the project's tickets for the beneficiary. ticketBooth.print( _beneficiary, _projectId, _unreservedWeightedAmount, _preferUnstakedTickets ); } else if (_weightedAmount > 0) { // If there is no unreserved weight amount but there is a weighted amount, // the full weighted amount should be explicitly tracked as reserved since no unreserved tickets were printed. // Subtract the total weighted amount from the tracker so the full reserved ticket amount can be printed later. // Make sure int casting isnt overflowing the int. 2^255 - 1 is the largest number that can be stored in an int. require( _processedTicketTrackerOf[_projectId] > 0 || uint256(-_processedTicketTrackerOf[_projectId]) + uint256(_weightedAmount) <= uint256(type(int256).max), 'TV1_1::printTickets: INT_LIMIT_REACHED' ); _processedTicketTrackerOf[_projectId] = _processedTicketTrackerOf[_projectId] - int256(_weightedAmount); } emit Pay( _fundingCycle.id, _projectId, _beneficiary, _amount, _unreservedWeightedAmount, _weightedAmount, _memo, msg.sender ); return _fundingCycle.id; } /** @notice Gets the amount overflowed in relation to the provided funding cycle. @dev This amount changes as the price of ETH changes against the funding cycle's currency. @param _currentFundingCycle The ID of the funding cycle to base the overflow on. @return overflow The current overflow of funds. */ function _overflowFrom(FundingCycle memory _currentFundingCycle) private view returns (uint256) { // Get the current price of ETH. uint256 _ethPrice = prices.getETHPriceFor(_currentFundingCycle.currency); // Get a reference to the amount still tappable in the current funding cycle. uint256 _limit = _currentFundingCycle.target - _currentFundingCycle.tapped; // The amount of ETH that the owner could currently still tap if its available. This amount isn't considered overflow. uint256 _ethLimit = _limit == 0 ? 0 : PRBMathUD60x18.div(_limit, _ethPrice); // Get the current balance of the project. uint256 _balanceOf = balanceOf[_currentFundingCycle.projectId]; // Overflow is the balance of this project minus the reserved amount. return _balanceOf < _ethLimit ? 0 : _balanceOf - _ethLimit; } /** @notice Gets the amount of reserved tickets currently tracked for a project given a reserved rate. @param _processedTicketTracker The tracker to make the calculation with. @param _reservedRate The reserved rate to use to make the calculation. @param _totalEligibleTickets The total amount to make the calculation with. @return amount reserved ticket amount. */ function _reservedTicketAmountFrom( int256 _processedTicketTracker, uint256 _reservedRate, uint256 _totalEligibleTickets ) private pure returns (uint256) { // Get a reference to the amount of tickets that are unprocessed. uint256 _unprocessedTicketBalanceOf = _processedTicketTracker >= 0 // preconfigure tickets shouldn't contribute to the reserved ticket amount. ? _totalEligibleTickets - uint256(_processedTicketTracker) : _totalEligibleTickets + uint256(-_processedTicketTracker); // If there are no unprocessed tickets, return. if (_unprocessedTicketBalanceOf == 0) return 0; // If all tickets are reserved, return the full unprocessed amount. if (_reservedRate == 200) return _unprocessedTicketBalanceOf; return PRBMath.mulDiv(_unprocessedTicketBalanceOf, 200, 200 - _reservedRate) - _unprocessedTicketBalanceOf; } /** @notice Validate and pack the funding cycle metadata. @param _metadata The metadata to validate and pack. @return packed The packed uint256 of all metadata params. The first 8 bytes specify the version. */ function _validateAndPackFundingCycleMetadata(FundingCycleMetadata2 memory _metadata) private pure returns (uint256 packed) { // The reserved project ticket rate must be less than or equal to 200. require( _metadata.reservedRate <= 200, 'TV1_1::_validateAndPackFundingCycleMetadata: BAD_RESERVED_RATE' ); // The bonding curve rate must be between 0 and 200. require( _metadata.bondingCurveRate <= 200, 'TV1_1::_validateAndPackFundingCycleMetadata: BAD_BONDING_CURVE_RATE' ); // The reconfiguration bonding curve rate must be less than or equal to 200. require( _metadata.reconfigurationBondingCurveRate <= 200, 'TV1_1::_validateAndPackFundingCycleMetadata: BAD_RECONFIGURATION_BONDING_CURVE_RATE' ); // version 1 in the first 8 bits. packed = 1; // reserved rate in bits 8-15. packed |= _metadata.reservedRate << 8; // bonding curve in bits 16-23. packed |= _metadata.bondingCurveRate << 16; // reconfiguration bonding curve rate in bits 24-31. packed |= _metadata.reconfigurationBondingCurveRate << 24; // pay paused rate in bit 32. if (_metadata.payIsPaused) packed |= 1 << 32; // ticket printing allowed in bit 33. if (_metadata.ticketPrintingIsAllowed) packed |= 1 << 33; // treasury extension address in bits 34-193. packed |= uint256(uint160(address(_metadata.treasuryExtension))) << 34; } /** @notice Takes a fee into the Governance contract's project. @param _from The amount to take a fee from. @param _percent The percent fee to take. Out of 200. @param _beneficiary The address to print governance's tickets for. @param _memo A memo to send with the fee. @return feeAmount The amount of the fee taken. */ function _takeFee( uint256 _from, uint256 _percent, address _beneficiary, string memory _memo ) private returns (uint256 feeAmount) { // The amount of ETH from the _tappedAmount to pay as a fee. feeAmount = _from - PRBMath.mulDiv(_from, 200, _percent + 200); // Nothing to do if there's no fee to take. if (feeAmount == 0) return 0; // When processing the admin fee, save gas if the admin is using this contract as its terminal. if (terminalDirectory.terminalOf(1) == this) { // Use the local pay call. _pay(1, feeAmount, _beneficiary, _memo, false); } else { // Get the terminal for this contract's project. ITerminal _terminal = terminalDirectory.terminalOf(1); // There must be a terminal. require(_terminal != ITerminal(address(0)), 'TV1_1::_takeFee: TERMINAL_NOT_FOUND'); _terminal.pay{value: feeAmount}(1, _beneficiary, _memo, false); } } }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /** * @dev Contract module that helps prevent reentrant calls to a function. * * Inheriting from `ReentrancyGuard` will make the {nonReentrant} modifier * available, which can be applied to functions to make sure there are no nested * (reentrant) calls to them. * * Note that because there is a single `nonReentrant` guard, functions marked as * `nonReentrant` may not call one another. This can be worked around by making * those functions `private`, and then adding `external` `nonReentrant` entry * points to them. * * TIP: If you would like to learn more about reentrancy and alternative ways * to protect against it, check out our blog post * https://blog.openzeppelin.com/reentrancy-after-istanbul/[Reentrancy After Istanbul]. */ abstract contract ReentrancyGuard { // Booleans are more expensive than uint256 or any type that takes up a full // word because each write operation emits an extra SLOAD to first read the // slot's contents, replace the bits taken up by the boolean, and then write // back. This is the compiler's defense against contract upgrades and // pointer aliasing, and it cannot be disabled. // The values being non-zero value makes deployment a bit more expensive, // but in exchange the refund on every call to nonReentrant will be lower in // amount. Since refunds are capped to a percentage of the total // transaction's gas, it is best to keep them low in cases like this one, to // increase the likelihood of the full refund coming into effect. uint256 private constant _NOT_ENTERED = 1; uint256 private constant _ENTERED = 2; uint256 private _status; constructor() { _status = _NOT_ENTERED; } /** * @dev Prevents a contract from calling itself, directly or indirectly. * Calling a `nonReentrant` function from another `nonReentrant` * function is not supported. It is possible to prevent this from happening * by making the `nonReentrant` function external, and make it call a * `private` function that does the actual work. */ modifier nonReentrant() { // On the first call to nonReentrant, _notEntered will be true require(_status != _ENTERED, "ReentrancyGuard: reentrant call"); // Any calls to nonReentrant after this point will fail _status = _ENTERED; _; // By storing the original value once again, a refund is triggered (see // https://eips.ethereum.org/EIPS/eip-2200) _status = _NOT_ENTERED; } }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /** * @dev Collection of functions related to the address type */ library Address { /** * @dev Returns true if `account` is a contract. * * [IMPORTANT] * ==== * It is unsafe to assume that an address for which this function returns * false is an externally-owned account (EOA) and not a contract. * * Among others, `isContract` will return false for the following * types of addresses: * * - an externally-owned account * - a contract in construction * - an address where a contract will be created * - an address where a contract lived, but was destroyed * ==== */ function isContract(address account) internal view returns (bool) { // This method relies on extcodesize, which returns 0 for contracts in // construction, since the code is only stored at the end of the // constructor execution. uint256 size; assembly { size := extcodesize(account) } return size > 0; } /** * @dev Replacement for Solidity's `transfer`: sends `amount` wei to * `recipient`, forwarding all available gas and reverting on errors. * * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost * of certain opcodes, possibly making contracts go over the 2300 gas limit * imposed by `transfer`, making them unable to receive funds via * `transfer`. {sendValue} removes this limitation. * * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more]. * * IMPORTANT: because control is transferred to `recipient`, care must be * taken to not create reentrancy vulnerabilities. Consider using * {ReentrancyGuard} or the * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. */ function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, "Address: insufficient balance"); (bool success, ) = recipient.call{value: amount}(""); require(success, "Address: unable to send value, recipient may have reverted"); } /** * @dev Performs a Solidity function call using a low level `call`. A * plain `call` is an unsafe replacement for a function call: use this * function instead. * * If `target` reverts with a revert reason, it is bubbled up by this * function (like regular Solidity function calls). * * Returns the raw returned data. To convert to the expected return value, * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`]. * * Requirements: * * - `target` must be a contract. * - calling `target` with `data` must not revert. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCall(target, data, "Address: low-level call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with * `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { return functionCallWithValue(target, data, 0, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but also transferring `value` wei to `target`. * * Requirements: * * - the calling contract must have an ETH balance of at least `value`. * - the called Solidity function must be `payable`. * * _Available since v3.1._ */ function functionCallWithValue( address target, bytes memory data, uint256 value ) internal returns (bytes memory) { return functionCallWithValue(target, data, value, "Address: low-level call with value failed"); } /** * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but * with `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCallWithValue( address target, bytes memory data, uint256 value, string memory errorMessage ) internal returns (bytes memory) { require(address(this).balance >= value, "Address: insufficient balance for call"); require(isContract(target), "Address: call to non-contract"); (bool success, bytes memory returndata) = target.call{value: value}(data); return _verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) { return functionStaticCall(target, data, "Address: low-level static call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall( address target, bytes memory data, string memory errorMessage ) internal view returns (bytes memory) { require(isContract(target), "Address: static call to non-contract"); (bool success, bytes memory returndata) = target.staticcall(data); return _verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) { return functionDelegateCall(target, data, "Address: low-level delegate call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { require(isContract(target), "Address: delegate call to non-contract"); (bool success, bytes memory returndata) = target.delegatecall(data); return _verifyCallResult(success, returndata, errorMessage); } function _verifyCallResult( bool success, bytes memory returndata, string memory errorMessage ) private pure returns (bytes memory) { if (success) { return returndata; } else { // Look for revert reason and bubble it up if present if (returndata.length > 0) { // The easiest way to bubble the revert reason is using memory via assembly assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } } }
// SPDX-License-Identifier: UNLICENSED pragma solidity >=0.8.4; import "prb-math/contracts/PRBMath.sol";
// SPDX-License-Identifier: UNLICENSED pragma solidity >=0.8.4; import "prb-math/contracts/PRBMathUD60x18.sol";
// SPDX-License-Identifier: MIT pragma solidity 0.8.6; import '@openzeppelin/contracts/token/ERC721/IERC721.sol'; import './ITicketBooth.sol'; import './IFundingCycles.sol'; import './IYielder.sol'; import './IProjects.sol'; import './IModStore.sol'; import './ITerminal.sol'; import './IOperatorStore.sol'; import './ITreasuryExtension.sol'; struct FundingCycleMetadata2 { uint256 reservedRate; uint256 bondingCurveRate; uint256 reconfigurationBondingCurveRate; bool payIsPaused; bool ticketPrintingIsAllowed; ITreasuryExtension treasuryExtension; } interface ITerminalV1_1 { event Pay( uint256 indexed fundingCycleId, uint256 indexed projectId, address indexed beneficiary, uint256 amount, uint256 beneficiaryTokens, uint256 totalTokens, string note, address caller ); event AddToBalance(uint256 indexed projectId, uint256 value, address caller); event AllowMigration(ITerminal allowed); event Migrate(uint256 indexed projectId, ITerminal indexed to, uint256 _amount, address caller); event Configure(uint256 indexed fundingCycleId, uint256 indexed projectId, address caller); event Tap( uint256 indexed fundingCycleId, uint256 indexed projectId, address indexed beneficiary, uint256 amount, uint256 currency, uint256 netTransferAmount, uint256 beneficiaryTransferAmount, uint256 govFeeAmount, address caller ); event Redeem( address indexed holder, address indexed beneficiary, uint256 indexed _projectId, uint256 amount, uint256 returnAmount, address caller ); event PrintReserveTickets( uint256 indexed fundingCycleId, uint256 indexed projectId, address indexed beneficiary, uint256 count, uint256 beneficiaryTicketAmount, address caller ); event DistributeToPayoutMod( uint256 indexed fundingCycleId, uint256 indexed projectId, PayoutMod mod, uint256 modCut, address caller ); event DistributeToTicketMod( uint256 indexed fundingCycleId, uint256 indexed projectId, TicketMod mod, uint256 modCut, address caller ); event PrintTickets( uint256 indexed projectId, address indexed beneficiary, uint256 amount, string memo, address caller ); event Deposit(uint256 amount); event EnsureTargetLocalWei(uint256 target); event SetYielder(IYielder newYielder); event SetFee(uint256 _amount); event SetTargetLocalWei(uint256 amount); function projects() external view returns (IProjects); function fundingCycles() external view returns (IFundingCycles); function ticketBooth() external view returns (ITicketBooth); function prices() external view returns (IPrices); function modStore() external view returns (IModStore); function reservedTicketBalanceOf(uint256 _projectId, uint256 _reservedRate) external view returns (uint256); function balanceOf(uint256 _projectId) external view returns (uint256); function currentOverflowOf(uint256 _projectId) external view returns (uint256); function claimableOverflowOf( address _account, uint256 _amount, uint256 _projectId ) external view returns (uint256); function fee() external view returns (uint256); function deploy( address _owner, bytes32 _handle, string calldata _uri, FundingCycleProperties calldata _properties, FundingCycleMetadata2 calldata _metadata, PayoutMod[] memory _payoutMods, TicketMod[] memory _ticketMods ) external; function configure( uint256 _projectId, FundingCycleProperties calldata _properties, FundingCycleMetadata2 calldata _metadata, PayoutMod[] memory _payoutMods, TicketMod[] memory _ticketMods ) external returns (uint256); function printTickets( uint256 _projectId, uint256 _amount, address _beneficiary, string memory _memo, bool _preferUnstakedTickets ) external; function tap( uint256 _projectId, uint256 _amount, uint256 _currency, uint256 _minReturnedWei ) external returns (uint256); function redeem( address _account, uint256 _projectId, uint256 _amount, uint256 _minReturnedWei, address payable _beneficiary, bool _preferUnstaked ) external returns (uint256 returnAmount); function printReservedTickets(uint256 _projectId) external returns (uint256 reservedTicketsToPrint); function setFee(uint256 _fee) external; function burnFromDeadAddress(uint256 _projectId) external; }
// SPDX-License-Identifier: MIT pragma solidity 0.8.6; import "@openzeppelin/contracts/token/ERC721/IERC721Receiver.sol"; import "@openzeppelin/contracts/access/Ownable.sol"; import "@openzeppelin/contracts/utils/Address.sol"; import "./../interfaces/ITerminalV1.sol"; /** @notice A contract that inherits from JuiceboxProject can use Juicebox as a business-model-as-a-service. @dev The owner of the contract makes admin decisions such as: - Which address is the funding cycle owner, which can tap funds from the funding cycle. - Should this project's Tickets be migrated to a new TerminalV1. */ abstract contract JuiceboxProject is IERC721Receiver, Ownable { /// @notice The direct deposit terminals. ITerminalDirectory public immutable terminalDirectory; /// @notice The ID of the project that should be used to forward this contract's received payments. uint256 public projectId; /** @param _projectId The ID of the project that should be used to forward this contract's received payments. @param _terminalDirectory A directory of a project's current Juicebox terminal to receive payments in. */ constructor(uint256 _projectId, ITerminalDirectory _terminalDirectory) { projectId = _projectId; terminalDirectory = _terminalDirectory; } receive() external payable {} /** @notice Withdraws funds stored in this contract. @param _beneficiary The address to send the funds to. @param _amount The amount to send. */ function withdraw(address payable _beneficiary, uint256 _amount) external onlyOwner { Address.sendValue(_beneficiary, _amount); } /** @notice Allows the project that is being managed to be set. @param _projectId The ID of the project that is being managed. */ function setProjectId(uint256 _projectId) external onlyOwner { projectId = _projectId; } /** @notice Make a payment to this project. @param _beneficiary The address who will receive tickets from this fee. @param _memo A memo that will be included in the published event. @param _preferUnstakedTickets Whether ERC20's should be claimed automatically if they have been issued. */ function pay( address _beneficiary, string calldata _memo, bool _preferUnstakedTickets ) external payable { require(projectId != 0, "JuiceboxProject::pay: PROJECT_NOT_FOUND"); // Get the terminal for this contract's project. ITerminal _terminal = terminalDirectory.terminalOf(projectId); // There must be a terminal. require( _terminal != ITerminal(address(0)), "JuiceboxProject::pay: TERMINAL_NOT_FOUND" ); _terminal.pay{value: msg.value}( projectId, _beneficiary, _memo, _preferUnstakedTickets ); } /** @notice Transfer the ownership of the project to a new owner. @dev This contract will no longer be able to reconfigure or tap funds from this project. @param _projects The projects contract. @param _newOwner The new project owner. @param _projectId The ID of the project to transfer ownership of. @param _data Arbitrary data to include in the transaction. */ function transferProjectOwnership( IProjects _projects, address _newOwner, uint256 _projectId, bytes calldata _data ) external onlyOwner { _projects.safeTransferFrom(address(this), _newOwner, _projectId, _data); } /** @notice Allows this contract to receive a project. */ function onERC721Received( address, address, uint256, bytes calldata ) public pure override returns (bytes4) { return this.onERC721Received.selector; } function setOperator( IOperatorStore _operatorStore, address _operator, uint256 _projectId, uint256[] calldata _permissionIndexes ) external onlyOwner { _operatorStore.setOperator(_operator, _projectId, _permissionIndexes); } function setOperators( IOperatorStore _operatorStore, address[] calldata _operators, uint256[] calldata _projectIds, uint256[][] calldata _permissionIndexes ) external onlyOwner { _operatorStore.setOperators( _operators, _projectIds, _permissionIndexes ); } /** @notice Take a fee for this project from this contract. @param _amount The payment amount. @param _beneficiary The address who will receive tickets from this fee. @param _memo A memo that will be included in the published event. @param _preferUnstakedTickets Whether ERC20's should be claimed automatically if they have been issued. */ function _takeFee( uint256 _amount, address _beneficiary, string memory _memo, bool _preferUnstakedTickets ) internal { require(projectId != 0, "JuiceboxProject::takeFee: PROJECT_NOT_FOUND"); // Find the terminal for this contract's project. ITerminal _terminal = terminalDirectory.terminalOf(projectId); // There must be a terminal. require( _terminal != ITerminal(address(0)), "JuiceboxProject::takeFee: TERMINAL_NOT_FOUND" ); // There must be enough funds in the contract to take the fee. require( address(this).balance >= _amount, "JuiceboxProject::takeFee: INSUFFICIENT_FUNDS" ); // Send funds to the terminal. _terminal.pay{value: _amount}( projectId, _beneficiary, _memo, _preferUnstakedTickets ); } }
// SPDX-License-Identifier: MIT pragma solidity 0.8.6; import "./../interfaces/IOperatable.sol"; abstract contract Operatable is IOperatable { modifier requirePermission( address _account, uint256 _domain, uint256 _index ) { require( msg.sender == _account || operatorStore.hasPermission( msg.sender, _account, _domain, _index ), "Operatable: UNAUTHORIZED" ); _; } modifier requirePermissionAllowingWildcardDomain( address _account, uint256 _domain, uint256 _index ) { require( msg.sender == _account || operatorStore.hasPermission( msg.sender, _account, _domain, _index ) || operatorStore.hasPermission(msg.sender, _account, 0, _index), "Operatable: UNAUTHORIZED" ); _; } modifier requirePermissionAcceptingAlternateAddress( address _account, uint256 _domain, uint256 _index, address _alternate ) { require( msg.sender == _account || operatorStore.hasPermission( msg.sender, _account, _domain, _index ) || msg.sender == _alternate, "Operatable: UNAUTHORIZED" ); _; } /// @notice A contract storing operator assignments. IOperatorStore public immutable override operatorStore; /** @param _operatorStore A contract storing operator assignments. */ constructor(IOperatorStore _operatorStore) { operatorStore = _operatorStore; } }
// SPDX-License-Identifier: MIT pragma solidity 0.8.6; library Operations { uint256 public constant Configure = 1; uint256 public constant PrintPreminedTickets = 2; uint256 public constant Redeem = 3; uint256 public constant Migrate = 4; uint256 public constant SetHandle = 5; uint256 public constant SetUri = 6; uint256 public constant ClaimHandle = 7; uint256 public constant RenewHandle = 8; uint256 public constant Issue = 9; uint256 public constant Stake = 10; uint256 public constant Unstake = 11; uint256 public constant Transfer = 12; uint256 public constant Lock = 13; uint256 public constant SetPayoutMods = 14; uint256 public constant SetTicketMods = 15; uint256 public constant SetTerminal = 16; uint256 public constant PrintTickets = 17; }
// SPDX-License-Identifier: WTFPL pragma solidity >=0.8.4; /// @notice Emitted when the result overflows uint256. error PRBMath__MulDivFixedPointOverflow(uint256 prod1); /// @notice Emitted when the result overflows uint256. error PRBMath__MulDivOverflow(uint256 prod1, uint256 denominator); /// @notice Emitted when one of the inputs is type(int256).min. error PRBMath__MulDivSignedInputTooSmall(); /// @notice Emitted when the intermediary absolute result overflows int256. error PRBMath__MulDivSignedOverflow(uint256 rAbs); /// @notice Emitted when the input is MIN_SD59x18. error PRBMathSD59x18__AbsInputTooSmall(); /// @notice Emitted when ceiling a number overflows SD59x18. error PRBMathSD59x18__CeilOverflow(int256 x); /// @notice Emitted when one of the inputs is MIN_SD59x18. error PRBMathSD59x18__DivInputTooSmall(); /// @notice Emitted when one of the intermediary unsigned results overflows SD59x18. error PRBMathSD59x18__DivOverflow(uint256 rAbs); /// @notice Emitted when the input is greater than 133.084258667509499441. error PRBMathSD59x18__ExpInputTooBig(int256 x); /// @notice Emitted when the input is greater than 192. error PRBMathSD59x18__Exp2InputTooBig(int256 x); /// @notice Emitted when flooring a number underflows SD59x18. error PRBMathSD59x18__FloorUnderflow(int256 x); /// @notice Emitted when converting a basic integer to the fixed-point format overflows SD59x18. error PRBMathSD59x18__FromIntOverflow(int256 x); /// @notice Emitted when converting a basic integer to the fixed-point format underflows SD59x18. error PRBMathSD59x18__FromIntUnderflow(int256 x); /// @notice Emitted when the product of the inputs is negative. error PRBMathSD59x18__GmNegativeProduct(int256 x, int256 y); /// @notice Emitted when multiplying the inputs overflows SD59x18. error PRBMathSD59x18__GmOverflow(int256 x, int256 y); /// @notice Emitted when the input is less than or equal to zero. error PRBMathSD59x18__LogInputTooSmall(int256 x); /// @notice Emitted when one of the inputs is MIN_SD59x18. error PRBMathSD59x18__MulInputTooSmall(); /// @notice Emitted when the intermediary absolute result overflows SD59x18. error PRBMathSD59x18__MulOverflow(uint256 rAbs); /// @notice Emitted when the intermediary absolute result overflows SD59x18. error PRBMathSD59x18__PowuOverflow(uint256 rAbs); /// @notice Emitted when the input is negative. error PRBMathSD59x18__SqrtNegativeInput(int256 x); /// @notice Emitted when the calculting the square root overflows SD59x18. error PRBMathSD59x18__SqrtOverflow(int256 x); /// @notice Emitted when addition overflows UD60x18. error PRBMathUD60x18__AddOverflow(uint256 x, uint256 y); /// @notice Emitted when ceiling a number overflows UD60x18. error PRBMathUD60x18__CeilOverflow(uint256 x); /// @notice Emitted when the input is greater than 133.084258667509499441. error PRBMathUD60x18__ExpInputTooBig(uint256 x); /// @notice Emitted when the input is greater than 192. error PRBMathUD60x18__Exp2InputTooBig(uint256 x); /// @notice Emitted when converting a basic integer to the fixed-point format format overflows UD60x18. error PRBMathUD60x18__FromUintOverflow(uint256 x); /// @notice Emitted when multiplying the inputs overflows UD60x18. error PRBMathUD60x18__GmOverflow(uint256 x, uint256 y); /// @notice Emitted when the input is less than 1. error PRBMathUD60x18__LogInputTooSmall(uint256 x); /// @notice Emitted when the calculting the square root overflows UD60x18. error PRBMathUD60x18__SqrtOverflow(uint256 x); /// @notice Emitted when subtraction underflows UD60x18. error PRBMathUD60x18__SubUnderflow(uint256 x, uint256 y); /// @dev Common mathematical functions used in both PRBMathSD59x18 and PRBMathUD60x18. Note that this shared library /// does not always assume the signed 59.18-decimal fixed-point or the unsigned 60.18-decimal fixed-point /// representation. When it does not, it is explictly mentioned in the NatSpec documentation. library PRBMath { /// STRUCTS /// struct SD59x18 { int256 value; } struct UD60x18 { uint256 value; } /// STORAGE /// /// @dev How many trailing decimals can be represented. uint256 internal constant SCALE = 1e18; /// @dev Largest power of two divisor of SCALE. uint256 internal constant SCALE_LPOTD = 262144; /// @dev SCALE inverted mod 2^256. uint256 internal constant SCALE_INVERSE = 78156646155174841979727994598816262306175212592076161876661508869554232690281; /// FUNCTIONS /// /// @notice Calculates the binary exponent of x using the binary fraction method. /// @dev Has to use 192.64-bit fixed-point numbers. /// See https://ethereum.stackexchange.com/a/96594/24693. /// @param x The exponent as an unsigned 192.64-bit fixed-point number. /// @return result The result as an unsigned 60.18-decimal fixed-point number. function exp2(uint256 x) internal pure returns (uint256 result) { unchecked { // Start from 0.5 in the 192.64-bit fixed-point format. result = 0x800000000000000000000000000000000000000000000000; // Multiply the result by root(2, 2^-i) when the bit at position i is 1. None of the intermediary results overflows // because the initial result is 2^191 and all magic factors are less than 2^65. if (x & 0x8000000000000000 > 0) { result = (result * 0x16A09E667F3BCC909) >> 64; } if (x & 0x4000000000000000 > 0) { result = (result * 0x1306FE0A31B7152DF) >> 64; } if (x & 0x2000000000000000 > 0) { result = (result * 0x1172B83C7D517ADCE) >> 64; } if (x & 0x1000000000000000 > 0) { result = (result * 0x10B5586CF9890F62A) >> 64; } if (x & 0x800000000000000 > 0) { result = (result * 0x1059B0D31585743AE) >> 64; } if (x & 0x400000000000000 > 0) { result = (result * 0x102C9A3E778060EE7) >> 64; } if (x & 0x200000000000000 > 0) { result = (result * 0x10163DA9FB33356D8) >> 64; } if (x & 0x100000000000000 > 0) { result = (result * 0x100B1AFA5ABCBED61) >> 64; } if (x & 0x80000000000000 > 0) { result = (result * 0x10058C86DA1C09EA2) >> 64; } if (x & 0x40000000000000 > 0) { result = (result * 0x1002C605E2E8CEC50) >> 64; } if (x & 0x20000000000000 > 0) { result = (result * 0x100162F3904051FA1) >> 64; } if (x & 0x10000000000000 > 0) { result = (result * 0x1000B175EFFDC76BA) >> 64; } if (x & 0x8000000000000 > 0) { result = (result * 0x100058BA01FB9F96D) >> 64; } if (x & 0x4000000000000 > 0) { result = (result * 0x10002C5CC37DA9492) >> 64; } if (x & 0x2000000000000 > 0) { result = (result * 0x1000162E525EE0547) >> 64; } if (x & 0x1000000000000 > 0) { result = (result * 0x10000B17255775C04) >> 64; } if (x & 0x800000000000 > 0) { result = (result * 0x1000058B91B5BC9AE) >> 64; } if (x & 0x400000000000 > 0) { result = (result * 0x100002C5C89D5EC6D) >> 64; } if (x & 0x200000000000 > 0) { result = (result * 0x10000162E43F4F831) >> 64; } if (x & 0x100000000000 > 0) { result = (result * 0x100000B1721BCFC9A) >> 64; } if (x & 0x80000000000 > 0) { result = (result * 0x10000058B90CF1E6E) >> 64; } if (x & 0x40000000000 > 0) { result = (result * 0x1000002C5C863B73F) >> 64; } if (x & 0x20000000000 > 0) { result = (result * 0x100000162E430E5A2) >> 64; } if (x & 0x10000000000 > 0) { result = (result * 0x1000000B172183551) >> 64; } if (x & 0x8000000000 > 0) { result = (result * 0x100000058B90C0B49) >> 64; } if (x & 0x4000000000 > 0) { result = (result * 0x10000002C5C8601CC) >> 64; } if (x & 0x2000000000 > 0) { result = (result * 0x1000000162E42FFF0) >> 64; } if (x & 0x1000000000 > 0) { result = (result * 0x10000000B17217FBB) >> 64; } if (x & 0x800000000 > 0) { result = (result * 0x1000000058B90BFCE) >> 64; } if (x & 0x400000000 > 0) { result = (result * 0x100000002C5C85FE3) >> 64; } if (x & 0x200000000 > 0) { result = (result * 0x10000000162E42FF1) >> 64; } if (x & 0x100000000 > 0) { result = (result * 0x100000000B17217F8) >> 64; } if (x & 0x80000000 > 0) { result = (result * 0x10000000058B90BFC) >> 64; } if (x & 0x40000000 > 0) { result = (result * 0x1000000002C5C85FE) >> 64; } if (x & 0x20000000 > 0) { result = (result * 0x100000000162E42FF) >> 64; } if (x & 0x10000000 > 0) { result = (result * 0x1000000000B17217F) >> 64; } if (x & 0x8000000 > 0) { result = (result * 0x100000000058B90C0) >> 64; } if (x & 0x4000000 > 0) { result = (result * 0x10000000002C5C860) >> 64; } if (x & 0x2000000 > 0) { result = (result * 0x1000000000162E430) >> 64; } if (x & 0x1000000 > 0) { result = (result * 0x10000000000B17218) >> 64; } if (x & 0x800000 > 0) { result = (result * 0x1000000000058B90C) >> 64; } if (x & 0x400000 > 0) { result = (result * 0x100000000002C5C86) >> 64; } if (x & 0x200000 > 0) { result = (result * 0x10000000000162E43) >> 64; } if (x & 0x100000 > 0) { result = (result * 0x100000000000B1721) >> 64; } if (x & 0x80000 > 0) { result = (result * 0x10000000000058B91) >> 64; } if (x & 0x40000 > 0) { result = (result * 0x1000000000002C5C8) >> 64; } if (x & 0x20000 > 0) { result = (result * 0x100000000000162E4) >> 64; } if (x & 0x10000 > 0) { result = (result * 0x1000000000000B172) >> 64; } if (x & 0x8000 > 0) { result = (result * 0x100000000000058B9) >> 64; } if (x & 0x4000 > 0) { result = (result * 0x10000000000002C5D) >> 64; } if (x & 0x2000 > 0) { result = (result * 0x1000000000000162E) >> 64; } if (x & 0x1000 > 0) { result = (result * 0x10000000000000B17) >> 64; } if (x & 0x800 > 0) { result = (result * 0x1000000000000058C) >> 64; } if (x & 0x400 > 0) { result = (result * 0x100000000000002C6) >> 64; } if (x & 0x200 > 0) { result = (result * 0x10000000000000163) >> 64; } if (x & 0x100 > 0) { result = (result * 0x100000000000000B1) >> 64; } if (x & 0x80 > 0) { result = (result * 0x10000000000000059) >> 64; } if (x & 0x40 > 0) { result = (result * 0x1000000000000002C) >> 64; } if (x & 0x20 > 0) { result = (result * 0x10000000000000016) >> 64; } if (x & 0x10 > 0) { result = (result * 0x1000000000000000B) >> 64; } if (x & 0x8 > 0) { result = (result * 0x10000000000000006) >> 64; } if (x & 0x4 > 0) { result = (result * 0x10000000000000003) >> 64; } if (x & 0x2 > 0) { result = (result * 0x10000000000000001) >> 64; } if (x & 0x1 > 0) { result = (result * 0x10000000000000001) >> 64; } // We're doing two things at the same time: // // 1. Multiply the result by 2^n + 1, where "2^n" is the integer part and the one is added to account for // the fact that we initially set the result to 0.5. This is accomplished by subtracting from 191 // rather than 192. // 2. Convert the result to the unsigned 60.18-decimal fixed-point format. // // This works because 2^(191-ip) = 2^ip / 2^191, where "ip" is the integer part "2^n". result *= SCALE; result >>= (191 - (x >> 64)); } } /// @notice Finds the zero-based index of the first one in the binary representation of x. /// @dev See the note on msb in the "Find First Set" Wikipedia article https://en.wikipedia.org/wiki/Find_first_set /// @param x The uint256 number for which to find the index of the most significant bit. /// @return msb The index of the most significant bit as an uint256. function mostSignificantBit(uint256 x) internal pure returns (uint256 msb) { if (x >= 2**128) { x >>= 128; msb += 128; } if (x >= 2**64) { x >>= 64; msb += 64; } if (x >= 2**32) { x >>= 32; msb += 32; } if (x >= 2**16) { x >>= 16; msb += 16; } if (x >= 2**8) { x >>= 8; msb += 8; } if (x >= 2**4) { x >>= 4; msb += 4; } if (x >= 2**2) { x >>= 2; msb += 2; } if (x >= 2**1) { // No need to shift x any more. msb += 1; } } /// @notice Calculates floor(x*y÷denominator) with full precision. /// /// @dev Credit to Remco Bloemen under MIT license https://xn--2-umb.com/21/muldiv. /// /// Requirements: /// - The denominator cannot be zero. /// - The result must fit within uint256. /// /// Caveats: /// - This function does not work with fixed-point numbers. /// /// @param x The multiplicand as an uint256. /// @param y The multiplier as an uint256. /// @param denominator The divisor as an uint256. /// @return result The result as an uint256. function mulDiv( uint256 x, uint256 y, uint256 denominator ) internal pure returns (uint256 result) { // 512-bit multiply [prod1 prod0] = x * y. Compute the product mod 2^256 and mod 2^256 - 1, then use // use the Chinese Remainder Theorem to reconstruct the 512 bit result. The result is stored in two 256 // variables such that product = prod1 * 2^256 + prod0. uint256 prod0; // Least significant 256 bits of the product uint256 prod1; // Most significant 256 bits of the product assembly { let mm := mulmod(x, y, not(0)) prod0 := mul(x, y) prod1 := sub(sub(mm, prod0), lt(mm, prod0)) } // Handle non-overflow cases, 256 by 256 division. if (prod1 == 0) { unchecked { result = prod0 / denominator; } return result; } // Make sure the result is less than 2^256. Also prevents denominator == 0. if (prod1 >= denominator) { revert PRBMath__MulDivOverflow(prod1, denominator); } /////////////////////////////////////////////// // 512 by 256 division. /////////////////////////////////////////////// // Make division exact by subtracting the remainder from [prod1 prod0]. uint256 remainder; assembly { // Compute remainder using mulmod. remainder := mulmod(x, y, denominator) // Subtract 256 bit number from 512 bit number. prod1 := sub(prod1, gt(remainder, prod0)) prod0 := sub(prod0, remainder) } // Factor powers of two out of denominator and compute largest power of two divisor of denominator. Always >= 1. // See https://cs.stackexchange.com/q/138556/92363. unchecked { // Does not overflow because the denominator cannot be zero at this stage in the function. uint256 lpotdod = denominator & (~denominator + 1); assembly { // Divide denominator by lpotdod. denominator := div(denominator, lpotdod) // Divide [prod1 prod0] by lpotdod. prod0 := div(prod0, lpotdod) // Flip lpotdod such that it is 2^256 / lpotdod. If lpotdod is zero, then it becomes one. lpotdod := add(div(sub(0, lpotdod), lpotdod), 1) } // Shift in bits from prod1 into prod0. prod0 |= prod1 * lpotdod; // Invert denominator mod 2^256. Now that denominator is an odd number, it has an inverse modulo 2^256 such // that denominator * inv = 1 mod 2^256. Compute the inverse by starting with a seed that is correct for // four bits. That is, denominator * inv = 1 mod 2^4. uint256 inverse = (3 * denominator) ^ 2; // Now use Newton-Raphson iteration to improve the precision. Thanks to Hensel's lifting lemma, this also works // in modular arithmetic, doubling the correct bits in each step. inverse *= 2 - denominator * inverse; // inverse mod 2^8 inverse *= 2 - denominator * inverse; // inverse mod 2^16 inverse *= 2 - denominator * inverse; // inverse mod 2^32 inverse *= 2 - denominator * inverse; // inverse mod 2^64 inverse *= 2 - denominator * inverse; // inverse mod 2^128 inverse *= 2 - denominator * inverse; // inverse mod 2^256 // Because the division is now exact we can divide by multiplying with the modular inverse of denominator. // This will give us the correct result modulo 2^256. Since the preconditions guarantee that the outcome is // less than 2^256, this is the final result. We don't need to compute the high bits of the result and prod1 // is no longer required. result = prod0 * inverse; return result; } } /// @notice Calculates floor(x*y÷1e18) with full precision. /// /// @dev Variant of "mulDiv" with constant folding, i.e. in which the denominator is always 1e18. Before returning the /// final result, we add 1 if (x * y) % SCALE >= HALF_SCALE. Without this, 6.6e-19 would be truncated to 0 instead of /// being rounded to 1e-18. See "Listing 6" and text above it at https://accu.org/index.php/journals/1717. /// /// Requirements: /// - The result must fit within uint256. /// /// Caveats: /// - The body is purposely left uncommented; see the NatSpec comments in "PRBMath.mulDiv" to understand how this works. /// - It is assumed that the result can never be type(uint256).max when x and y solve the following two equations: /// 1. x * y = type(uint256).max * SCALE /// 2. (x * y) % SCALE >= SCALE / 2 /// /// @param x The multiplicand as an unsigned 60.18-decimal fixed-point number. /// @param y The multiplier as an unsigned 60.18-decimal fixed-point number. /// @return result The result as an unsigned 60.18-decimal fixed-point number. function mulDivFixedPoint(uint256 x, uint256 y) internal pure returns (uint256 result) { uint256 prod0; uint256 prod1; assembly { let mm := mulmod(x, y, not(0)) prod0 := mul(x, y) prod1 := sub(sub(mm, prod0), lt(mm, prod0)) } if (prod1 >= SCALE) { revert PRBMath__MulDivFixedPointOverflow(prod1); } uint256 remainder; uint256 roundUpUnit; assembly { remainder := mulmod(x, y, SCALE) roundUpUnit := gt(remainder, 499999999999999999) } if (prod1 == 0) { unchecked { result = (prod0 / SCALE) + roundUpUnit; return result; } } assembly { result := add( mul( or( div(sub(prod0, remainder), SCALE_LPOTD), mul(sub(prod1, gt(remainder, prod0)), add(div(sub(0, SCALE_LPOTD), SCALE_LPOTD), 1)) ), SCALE_INVERSE ), roundUpUnit ) } } /// @notice Calculates floor(x*y÷denominator) with full precision. /// /// @dev An extension of "mulDiv" for signed numbers. Works by computing the signs and the absolute values separately. /// /// Requirements: /// - None of the inputs can be type(int256).min. /// - The result must fit within int256. /// /// @param x The multiplicand as an int256. /// @param y The multiplier as an int256. /// @param denominator The divisor as an int256. /// @return result The result as an int256. function mulDivSigned( int256 x, int256 y, int256 denominator ) internal pure returns (int256 result) { if (x == type(int256).min || y == type(int256).min || denominator == type(int256).min) { revert PRBMath__MulDivSignedInputTooSmall(); } // Get hold of the absolute values of x, y and the denominator. uint256 ax; uint256 ay; uint256 ad; unchecked { ax = x < 0 ? uint256(-x) : uint256(x); ay = y < 0 ? uint256(-y) : uint256(y); ad = denominator < 0 ? uint256(-denominator) : uint256(denominator); } // Compute the absolute value of (x*y)÷denominator. The result must fit within int256. uint256 rAbs = mulDiv(ax, ay, ad); if (rAbs > uint256(type(int256).max)) { revert PRBMath__MulDivSignedOverflow(rAbs); } // Get the signs of x, y and the denominator. uint256 sx; uint256 sy; uint256 sd; assembly { sx := sgt(x, sub(0, 1)) sy := sgt(y, sub(0, 1)) sd := sgt(denominator, sub(0, 1)) } // XOR over sx, sy and sd. This is checking whether there are one or three negative signs in the inputs. // If yes, the result should be negative. result = sx ^ sy ^ sd == 0 ? -int256(rAbs) : int256(rAbs); } /// @notice Calculates the square root of x, rounding down. /// @dev Uses the Babylonian method https://en.wikipedia.org/wiki/Methods_of_computing_square_roots#Babylonian_method. /// /// Caveats: /// - This function does not work with fixed-point numbers. /// /// @param x The uint256 number for which to calculate the square root. /// @return result The result as an uint256. function sqrt(uint256 x) internal pure returns (uint256 result) { if (x == 0) { return 0; } // Set the initial guess to the closest power of two that is higher than x. uint256 xAux = uint256(x); result = 1; if (xAux >= 0x100000000000000000000000000000000) { xAux >>= 128; result <<= 64; } if (xAux >= 0x10000000000000000) { xAux >>= 64; result <<= 32; } if (xAux >= 0x100000000) { xAux >>= 32; result <<= 16; } if (xAux >= 0x10000) { xAux >>= 16; result <<= 8; } if (xAux >= 0x100) { xAux >>= 8; result <<= 4; } if (xAux >= 0x10) { xAux >>= 4; result <<= 2; } if (xAux >= 0x8) { result <<= 1; } // The operations can never overflow because the result is max 2^127 when it enters this block. unchecked { result = (result + x / result) >> 1; result = (result + x / result) >> 1; result = (result + x / result) >> 1; result = (result + x / result) >> 1; result = (result + x / result) >> 1; result = (result + x / result) >> 1; result = (result + x / result) >> 1; // Seven iterations should be enough uint256 roundedDownResult = x / result; return result >= roundedDownResult ? roundedDownResult : result; } } }
// SPDX-License-Identifier: WTFPL pragma solidity >=0.8.4; import "./PRBMath.sol"; /// @title PRBMathUD60x18 /// @author Paul Razvan Berg /// @notice Smart contract library for advanced fixed-point math that works with uint256 numbers considered to have 18 /// trailing decimals. We call this number representation unsigned 60.18-decimal fixed-point, since there can be up to 60 /// digits in the integer part and up to 18 decimals in the fractional part. The numbers are bound by the minimum and the /// maximum values permitted by the Solidity type uint256. library PRBMathUD60x18 { /// @dev Half the SCALE number. uint256 internal constant HALF_SCALE = 5e17; /// @dev log2(e) as an unsigned 60.18-decimal fixed-point number. uint256 internal constant LOG2_E = 1442695040888963407; /// @dev The maximum value an unsigned 60.18-decimal fixed-point number can have. uint256 internal constant MAX_UD60x18 = 115792089237316195423570985008687907853269984665640564039457584007913129639935; /// @dev The maximum whole value an unsigned 60.18-decimal fixed-point number can have. uint256 internal constant MAX_WHOLE_UD60x18 = 115792089237316195423570985008687907853269984665640564039457000000000000000000; /// @dev How many trailing decimals can be represented. uint256 internal constant SCALE = 1e18; /// @notice Calculates arithmetic average of x and y, rounding down. /// @param x The first operand as an unsigned 60.18-decimal fixed-point number. /// @param y The second operand as an unsigned 60.18-decimal fixed-point number. /// @return result The arithmetic average as an unsigned 60.18-decimal fixed-point number. function avg(uint256 x, uint256 y) internal pure returns (uint256 result) { // The operations can never overflow. unchecked { // The last operand checks if both x and y are odd and if that is the case, we add 1 to the result. We need // to do this because if both numbers are odd, the 0.5 remainder gets truncated twice. result = (x >> 1) + (y >> 1) + (x & y & 1); } } /// @notice Yields the least unsigned 60.18 decimal fixed-point number greater than or equal to x. /// /// @dev Optimised for fractional value inputs, because for every whole value there are (1e18 - 1) fractional counterparts. /// See https://en.wikipedia.org/wiki/Floor_and_ceiling_functions. /// /// Requirements: /// - x must be less than or equal to MAX_WHOLE_UD60x18. /// /// @param x The unsigned 60.18-decimal fixed-point number to ceil. /// @param result The least integer greater than or equal to x, as an unsigned 60.18-decimal fixed-point number. function ceil(uint256 x) internal pure returns (uint256 result) { if (x > MAX_WHOLE_UD60x18) { revert PRBMathUD60x18__CeilOverflow(x); } assembly { // Equivalent to "x % SCALE" but faster. let remainder := mod(x, SCALE) // Equivalent to "SCALE - remainder" but faster. let delta := sub(SCALE, remainder) // Equivalent to "x + delta * (remainder > 0 ? 1 : 0)" but faster. result := add(x, mul(delta, gt(remainder, 0))) } } /// @notice Divides two unsigned 60.18-decimal fixed-point numbers, returning a new unsigned 60.18-decimal fixed-point number. /// /// @dev Uses mulDiv to enable overflow-safe multiplication and division. /// /// Requirements: /// - The denominator cannot be zero. /// /// @param x The numerator as an unsigned 60.18-decimal fixed-point number. /// @param y The denominator as an unsigned 60.18-decimal fixed-point number. /// @param result The quotient as an unsigned 60.18-decimal fixed-point number. function div(uint256 x, uint256 y) internal pure returns (uint256 result) { result = PRBMath.mulDiv(x, SCALE, y); } /// @notice Returns Euler's number as an unsigned 60.18-decimal fixed-point number. /// @dev See https://en.wikipedia.org/wiki/E_(mathematical_constant). function e() internal pure returns (uint256 result) { result = 2718281828459045235; } /// @notice Calculates the natural exponent of x. /// /// @dev Based on the insight that e^x = 2^(x * log2(e)). /// /// Requirements: /// - All from "log2". /// - x must be less than 133.084258667509499441. /// /// @param x The exponent as an unsigned 60.18-decimal fixed-point number. /// @return result The result as an unsigned 60.18-decimal fixed-point number. function exp(uint256 x) internal pure returns (uint256 result) { // Without this check, the value passed to "exp2" would be greater than 192. if (x >= 133084258667509499441) { revert PRBMathUD60x18__ExpInputTooBig(x); } // Do the fixed-point multiplication inline to save gas. unchecked { uint256 doubleScaleProduct = x * LOG2_E; result = exp2((doubleScaleProduct + HALF_SCALE) / SCALE); } } /// @notice Calculates the binary exponent of x using the binary fraction method. /// /// @dev See https://ethereum.stackexchange.com/q/79903/24693. /// /// Requirements: /// - x must be 192 or less. /// - The result must fit within MAX_UD60x18. /// /// @param x The exponent as an unsigned 60.18-decimal fixed-point number. /// @return result The result as an unsigned 60.18-decimal fixed-point number. function exp2(uint256 x) internal pure returns (uint256 result) { // 2^192 doesn't fit within the 192.64-bit format used internally in this function. if (x >= 192e18) { revert PRBMathUD60x18__Exp2InputTooBig(x); } unchecked { // Convert x to the 192.64-bit fixed-point format. uint256 x192x64 = (x << 64) / SCALE; // Pass x to the PRBMath.exp2 function, which uses the 192.64-bit fixed-point number representation. result = PRBMath.exp2(x192x64); } } /// @notice Yields the greatest unsigned 60.18 decimal fixed-point number less than or equal to x. /// @dev Optimised for fractional value inputs, because for every whole value there are (1e18 - 1) fractional counterparts. /// See https://en.wikipedia.org/wiki/Floor_and_ceiling_functions. /// @param x The unsigned 60.18-decimal fixed-point number to floor. /// @param result The greatest integer less than or equal to x, as an unsigned 60.18-decimal fixed-point number. function floor(uint256 x) internal pure returns (uint256 result) { assembly { // Equivalent to "x % SCALE" but faster. let remainder := mod(x, SCALE) // Equivalent to "x - remainder * (remainder > 0 ? 1 : 0)" but faster. result := sub(x, mul(remainder, gt(remainder, 0))) } } /// @notice Yields the excess beyond the floor of x. /// @dev Based on the odd function definition https://en.wikipedia.org/wiki/Fractional_part. /// @param x The unsigned 60.18-decimal fixed-point number to get the fractional part of. /// @param result The fractional part of x as an unsigned 60.18-decimal fixed-point number. function frac(uint256 x) internal pure returns (uint256 result) { assembly { result := mod(x, SCALE) } } /// @notice Converts a number from basic integer form to unsigned 60.18-decimal fixed-point representation. /// /// @dev Requirements: /// - x must be less than or equal to MAX_UD60x18 divided by SCALE. /// /// @param x The basic integer to convert. /// @param result The same number in unsigned 60.18-decimal fixed-point representation. function fromUint(uint256 x) internal pure returns (uint256 result) { unchecked { if (x > MAX_UD60x18 / SCALE) { revert PRBMathUD60x18__FromUintOverflow(x); } result = x * SCALE; } } /// @notice Calculates geometric mean of x and y, i.e. sqrt(x * y), rounding down. /// /// @dev Requirements: /// - x * y must fit within MAX_UD60x18, lest it overflows. /// /// @param x The first operand as an unsigned 60.18-decimal fixed-point number. /// @param y The second operand as an unsigned 60.18-decimal fixed-point number. /// @return result The result as an unsigned 60.18-decimal fixed-point number. function gm(uint256 x, uint256 y) internal pure returns (uint256 result) { if (x == 0) { return 0; } unchecked { // Checking for overflow this way is faster than letting Solidity do it. uint256 xy = x * y; if (xy / x != y) { revert PRBMathUD60x18__GmOverflow(x, y); } // We don't need to multiply by the SCALE here because the x*y product had already picked up a factor of SCALE // during multiplication. See the comments within the "sqrt" function. result = PRBMath.sqrt(xy); } } /// @notice Calculates 1 / x, rounding towards zero. /// /// @dev Requirements: /// - x cannot be zero. /// /// @param x The unsigned 60.18-decimal fixed-point number for which to calculate the inverse. /// @return result The inverse as an unsigned 60.18-decimal fixed-point number. function inv(uint256 x) internal pure returns (uint256 result) { unchecked { // 1e36 is SCALE * SCALE. result = 1e36 / x; } } /// @notice Calculates the natural logarithm of x. /// /// @dev Based on the insight that ln(x) = log2(x) / log2(e). /// /// Requirements: /// - All from "log2". /// /// Caveats: /// - All from "log2". /// - This doesn't return exactly 1 for 2.718281828459045235, for that we would need more fine-grained precision. /// /// @param x The unsigned 60.18-decimal fixed-point number for which to calculate the natural logarithm. /// @return result The natural logarithm as an unsigned 60.18-decimal fixed-point number. function ln(uint256 x) internal pure returns (uint256 result) { // Do the fixed-point multiplication inline to save gas. This is overflow-safe because the maximum value that log2(x) // can return is 196205294292027477728. unchecked { result = (log2(x) * SCALE) / LOG2_E; } } /// @notice Calculates the common logarithm of x. /// /// @dev First checks if x is an exact power of ten and it stops if yes. If it's not, calculates the common /// logarithm based on the insight that log10(x) = log2(x) / log2(10). /// /// Requirements: /// - All from "log2". /// /// Caveats: /// - All from "log2". /// /// @param x The unsigned 60.18-decimal fixed-point number for which to calculate the common logarithm. /// @return result The common logarithm as an unsigned 60.18-decimal fixed-point number. function log10(uint256 x) internal pure returns (uint256 result) { if (x < SCALE) { revert PRBMathUD60x18__LogInputTooSmall(x); } // Note that the "mul" in this block is the assembly multiplication operation, not the "mul" function defined // in this contract. // prettier-ignore assembly { switch x case 1 { result := mul(SCALE, sub(0, 18)) } case 10 { result := mul(SCALE, sub(1, 18)) } case 100 { result := mul(SCALE, sub(2, 18)) } case 1000 { result := mul(SCALE, sub(3, 18)) } case 10000 { result := mul(SCALE, sub(4, 18)) } case 100000 { result := mul(SCALE, sub(5, 18)) } case 1000000 { result := mul(SCALE, sub(6, 18)) } case 10000000 { result := mul(SCALE, sub(7, 18)) } case 100000000 { result := mul(SCALE, sub(8, 18)) } case 1000000000 { result := mul(SCALE, sub(9, 18)) } case 10000000000 { result := mul(SCALE, sub(10, 18)) } case 100000000000 { result := mul(SCALE, sub(11, 18)) } case 1000000000000 { result := mul(SCALE, sub(12, 18)) } case 10000000000000 { result := mul(SCALE, sub(13, 18)) } case 100000000000000 { result := mul(SCALE, sub(14, 18)) } case 1000000000000000 { result := mul(SCALE, sub(15, 18)) } case 10000000000000000 { result := mul(SCALE, sub(16, 18)) } case 100000000000000000 { result := mul(SCALE, sub(17, 18)) } case 1000000000000000000 { result := 0 } case 10000000000000000000 { result := SCALE } case 100000000000000000000 { result := mul(SCALE, 2) } case 1000000000000000000000 { result := mul(SCALE, 3) } case 10000000000000000000000 { result := mul(SCALE, 4) } case 100000000000000000000000 { result := mul(SCALE, 5) } case 1000000000000000000000000 { result := mul(SCALE, 6) } case 10000000000000000000000000 { result := mul(SCALE, 7) } case 100000000000000000000000000 { result := mul(SCALE, 8) } case 1000000000000000000000000000 { result := mul(SCALE, 9) } case 10000000000000000000000000000 { result := mul(SCALE, 10) } case 100000000000000000000000000000 { result := mul(SCALE, 11) } case 1000000000000000000000000000000 { result := mul(SCALE, 12) } case 10000000000000000000000000000000 { result := mul(SCALE, 13) } case 100000000000000000000000000000000 { result := mul(SCALE, 14) } case 1000000000000000000000000000000000 { result := mul(SCALE, 15) } case 10000000000000000000000000000000000 { result := mul(SCALE, 16) } case 100000000000000000000000000000000000 { result := mul(SCALE, 17) } case 1000000000000000000000000000000000000 { result := mul(SCALE, 18) } case 10000000000000000000000000000000000000 { result := mul(SCALE, 19) } case 100000000000000000000000000000000000000 { result := mul(SCALE, 20) } case 1000000000000000000000000000000000000000 { result := mul(SCALE, 21) } case 10000000000000000000000000000000000000000 { result := mul(SCALE, 22) } case 100000000000000000000000000000000000000000 { result := mul(SCALE, 23) } case 1000000000000000000000000000000000000000000 { result := mul(SCALE, 24) } case 10000000000000000000000000000000000000000000 { result := mul(SCALE, 25) } case 100000000000000000000000000000000000000000000 { result := mul(SCALE, 26) } case 1000000000000000000000000000000000000000000000 { result := mul(SCALE, 27) } case 10000000000000000000000000000000000000000000000 { result := mul(SCALE, 28) } case 100000000000000000000000000000000000000000000000 { result := mul(SCALE, 29) } case 1000000000000000000000000000000000000000000000000 { result := mul(SCALE, 30) } case 10000000000000000000000000000000000000000000000000 { result := mul(SCALE, 31) } case 100000000000000000000000000000000000000000000000000 { result := mul(SCALE, 32) } case 1000000000000000000000000000000000000000000000000000 { result := mul(SCALE, 33) } case 10000000000000000000000000000000000000000000000000000 { result := mul(SCALE, 34) } case 100000000000000000000000000000000000000000000000000000 { result := mul(SCALE, 35) } case 1000000000000000000000000000000000000000000000000000000 { result := mul(SCALE, 36) } case 10000000000000000000000000000000000000000000000000000000 { result := mul(SCALE, 37) } case 100000000000000000000000000000000000000000000000000000000 { result := mul(SCALE, 38) } case 1000000000000000000000000000000000000000000000000000000000 { result := mul(SCALE, 39) } case 10000000000000000000000000000000000000000000000000000000000 { result := mul(SCALE, 40) } case 100000000000000000000000000000000000000000000000000000000000 { result := mul(SCALE, 41) } case 1000000000000000000000000000000000000000000000000000000000000 { result := mul(SCALE, 42) } case 10000000000000000000000000000000000000000000000000000000000000 { result := mul(SCALE, 43) } case 100000000000000000000000000000000000000000000000000000000000000 { result := mul(SCALE, 44) } case 1000000000000000000000000000000000000000000000000000000000000000 { result := mul(SCALE, 45) } case 10000000000000000000000000000000000000000000000000000000000000000 { result := mul(SCALE, 46) } case 100000000000000000000000000000000000000000000000000000000000000000 { result := mul(SCALE, 47) } case 1000000000000000000000000000000000000000000000000000000000000000000 { result := mul(SCALE, 48) } case 10000000000000000000000000000000000000000000000000000000000000000000 { result := mul(SCALE, 49) } case 100000000000000000000000000000000000000000000000000000000000000000000 { result := mul(SCALE, 50) } case 1000000000000000000000000000000000000000000000000000000000000000000000 { result := mul(SCALE, 51) } case 10000000000000000000000000000000000000000000000000000000000000000000000 { result := mul(SCALE, 52) } case 100000000000000000000000000000000000000000000000000000000000000000000000 { result := mul(SCALE, 53) } case 1000000000000000000000000000000000000000000000000000000000000000000000000 { result := mul(SCALE, 54) } case 10000000000000000000000000000000000000000000000000000000000000000000000000 { result := mul(SCALE, 55) } case 100000000000000000000000000000000000000000000000000000000000000000000000000 { result := mul(SCALE, 56) } case 1000000000000000000000000000000000000000000000000000000000000000000000000000 { result := mul(SCALE, 57) } case 10000000000000000000000000000000000000000000000000000000000000000000000000000 { result := mul(SCALE, 58) } case 100000000000000000000000000000000000000000000000000000000000000000000000000000 { result := mul(SCALE, 59) } default { result := MAX_UD60x18 } } if (result == MAX_UD60x18) { // Do the fixed-point division inline to save gas. The denominator is log2(10). unchecked { result = (log2(x) * SCALE) / 3321928094887362347; } } } /// @notice Calculates the binary logarithm of x. /// /// @dev Based on the iterative approximation algorithm. /// https://en.wikipedia.org/wiki/Binary_logarithm#Iterative_approximation /// /// Requirements: /// - x must be greater than or equal to SCALE, otherwise the result would be negative. /// /// Caveats: /// - The results are nor perfectly accurate to the last decimal, due to the lossy precision of the iterative approximation. /// /// @param x The unsigned 60.18-decimal fixed-point number for which to calculate the binary logarithm. /// @return result The binary logarithm as an unsigned 60.18-decimal fixed-point number. function log2(uint256 x) internal pure returns (uint256 result) { if (x < SCALE) { revert PRBMathUD60x18__LogInputTooSmall(x); } unchecked { // Calculate the integer part of the logarithm and add it to the result and finally calculate y = x * 2^(-n). uint256 n = PRBMath.mostSignificantBit(x / SCALE); // The integer part of the logarithm as an unsigned 60.18-decimal fixed-point number. The operation can't overflow // because n is maximum 255 and SCALE is 1e18. result = n * SCALE; // This is y = x * 2^(-n). uint256 y = x >> n; // If y = 1, the fractional part is zero. if (y == SCALE) { return result; } // Calculate the fractional part via the iterative approximation. // The "delta >>= 1" part is equivalent to "delta /= 2", but shifting bits is faster. for (uint256 delta = HALF_SCALE; delta > 0; delta >>= 1) { y = (y * y) / SCALE; // Is y^2 > 2 and so in the range [2,4)? if (y >= 2 * SCALE) { // Add the 2^(-m) factor to the logarithm. result += delta; // Corresponds to z/2 on Wikipedia. y >>= 1; } } } } /// @notice Multiplies two unsigned 60.18-decimal fixed-point numbers together, returning a new unsigned 60.18-decimal /// fixed-point number. /// @dev See the documentation for the "PRBMath.mulDivFixedPoint" function. /// @param x The multiplicand as an unsigned 60.18-decimal fixed-point number. /// @param y The multiplier as an unsigned 60.18-decimal fixed-point number. /// @return result The product as an unsigned 60.18-decimal fixed-point number. function mul(uint256 x, uint256 y) internal pure returns (uint256 result) { result = PRBMath.mulDivFixedPoint(x, y); } /// @notice Returns PI as an unsigned 60.18-decimal fixed-point number. function pi() internal pure returns (uint256 result) { result = 3141592653589793238; } /// @notice Raises x to the power of y. /// /// @dev Based on the insight that x^y = 2^(log2(x) * y). /// /// Requirements: /// - All from "exp2", "log2" and "mul". /// /// Caveats: /// - All from "exp2", "log2" and "mul". /// - Assumes 0^0 is 1. /// /// @param x Number to raise to given power y, as an unsigned 60.18-decimal fixed-point number. /// @param y Exponent to raise x to, as an unsigned 60.18-decimal fixed-point number. /// @return result x raised to power y, as an unsigned 60.18-decimal fixed-point number. function pow(uint256 x, uint256 y) internal pure returns (uint256 result) { if (x == 0) { result = y == 0 ? SCALE : uint256(0); } else { result = exp2(mul(log2(x), y)); } } /// @notice Raises x (unsigned 60.18-decimal fixed-point number) to the power of y (basic unsigned integer) using the /// famous algorithm "exponentiation by squaring". /// /// @dev See https://en.wikipedia.org/wiki/Exponentiation_by_squaring /// /// Requirements: /// - The result must fit within MAX_UD60x18. /// /// Caveats: /// - All from "mul". /// - Assumes 0^0 is 1. /// /// @param x The base as an unsigned 60.18-decimal fixed-point number. /// @param y The exponent as an uint256. /// @return result The result as an unsigned 60.18-decimal fixed-point number. function powu(uint256 x, uint256 y) internal pure returns (uint256 result) { // Calculate the first iteration of the loop in advance. result = y & 1 > 0 ? x : SCALE; // Equivalent to "for(y /= 2; y > 0; y /= 2)" but faster. for (y >>= 1; y > 0; y >>= 1) { x = PRBMath.mulDivFixedPoint(x, x); // Equivalent to "y % 2 == 1" but faster. if (y & 1 > 0) { result = PRBMath.mulDivFixedPoint(result, x); } } } /// @notice Returns 1 as an unsigned 60.18-decimal fixed-point number. function scale() internal pure returns (uint256 result) { result = SCALE; } /// @notice Calculates the square root of x, rounding down. /// @dev Uses the Babylonian method https://en.wikipedia.org/wiki/Methods_of_computing_square_roots#Babylonian_method. /// /// Requirements: /// - x must be less than MAX_UD60x18 / SCALE. /// /// @param x The unsigned 60.18-decimal fixed-point number for which to calculate the square root. /// @return result The result as an unsigned 60.18-decimal fixed-point . function sqrt(uint256 x) internal pure returns (uint256 result) { unchecked { if (x > MAX_UD60x18 / SCALE) { revert PRBMathUD60x18__SqrtOverflow(x); } // Multiply x by the SCALE to account for the factor of SCALE that is picked up when multiplying two unsigned // 60.18-decimal fixed-point numbers together (in this case, those two numbers are both the square root). result = PRBMath.sqrt(x * SCALE); } } /// @notice Converts a unsigned 60.18-decimal fixed-point number to basic integer form, rounding down in the process. /// @param x The unsigned 60.18-decimal fixed-point number to convert. /// @return result The same number in basic integer form. function toUint(uint256 x) internal pure returns (uint256 result) { unchecked { result = x / SCALE; } } }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "../../utils/introspection/IERC165.sol"; /** * @dev Required interface of an ERC721 compliant contract. */ interface IERC721 is IERC165 { /** * @dev Emitted when `tokenId` token is transferred from `from` to `to`. */ event Transfer(address indexed from, address indexed to, uint256 indexed tokenId); /** * @dev Emitted when `owner` enables `approved` to manage the `tokenId` token. */ event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId); /** * @dev Emitted when `owner` enables or disables (`approved`) `operator` to manage all of its assets. */ event ApprovalForAll(address indexed owner, address indexed operator, bool approved); /** * @dev Returns the number of tokens in ``owner``'s account. */ function balanceOf(address owner) external view returns (uint256 balance); /** * @dev Returns the owner of the `tokenId` token. * * Requirements: * * - `tokenId` must exist. */ function ownerOf(uint256 tokenId) external view returns (address owner); /** * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients * are aware of the ERC721 protocol to prevent tokens from being forever locked. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If the caller is not `from`, it must be have been allowed to move this token by either {approve} or {setApprovalForAll}. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function safeTransferFrom( address from, address to, uint256 tokenId ) external; /** * @dev Transfers `tokenId` token from `from` to `to`. * * WARNING: Usage of this method is discouraged, use {safeTransferFrom} whenever possible. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must be owned by `from`. * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}. * * Emits a {Transfer} event. */ function transferFrom( address from, address to, uint256 tokenId ) external; /** * @dev Gives permission to `to` to transfer `tokenId` token to another account. * The approval is cleared when the token is transferred. * * Only a single account can be approved at a time, so approving the zero address clears previous approvals. * * Requirements: * * - The caller must own the token or be an approved operator. * - `tokenId` must exist. * * Emits an {Approval} event. */ function approve(address to, uint256 tokenId) external; /** * @dev Returns the account approved for `tokenId` token. * * Requirements: * * - `tokenId` must exist. */ function getApproved(uint256 tokenId) external view returns (address operator); /** * @dev Approve or remove `operator` as an operator for the caller. * Operators can call {transferFrom} or {safeTransferFrom} for any token owned by the caller. * * Requirements: * * - The `operator` cannot be the caller. * * Emits an {ApprovalForAll} event. */ function setApprovalForAll(address operator, bool _approved) external; /** * @dev Returns if the `operator` is allowed to manage all of the assets of `owner`. * * See {setApprovalForAll} */ function isApprovedForAll(address owner, address operator) external view returns (bool); /** * @dev Safely transfers `tokenId` token from `from` to `to`. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function safeTransferFrom( address from, address to, uint256 tokenId, bytes calldata data ) external; }
// SPDX-License-Identifier: MIT pragma solidity 0.8.6; import "./IProjects.sol"; import "./IOperatorStore.sol"; import "./ITickets.sol"; interface ITicketBooth { event Issue( uint256 indexed projectId, string name, string symbol, address caller ); event Print( address indexed holder, uint256 indexed projectId, uint256 amount, bool convertedTickets, bool preferUnstakedTickets, address controller ); event Redeem( address indexed holder, uint256 indexed projectId, uint256 amount, uint256 stakedTickets, bool preferUnstaked, address controller ); event Stake( address indexed holder, uint256 indexed projectId, uint256 amount, address caller ); event Unstake( address indexed holder, uint256 indexed projectId, uint256 amount, address caller ); event Lock( address indexed holder, uint256 indexed projectId, uint256 amount, address caller ); event Unlock( address indexed holder, uint256 indexed projectId, uint256 amount, address caller ); event Transfer( address indexed holder, uint256 indexed projectId, address indexed recipient, uint256 amount, address caller ); function ticketsOf(uint256 _projectId) external view returns (ITickets); function projects() external view returns (IProjects); function lockedBalanceOf(address _holder, uint256 _projectId) external view returns (uint256); function lockedBalanceBy( address _operator, address _holder, uint256 _projectId ) external view returns (uint256); function stakedBalanceOf(address _holder, uint256 _projectId) external view returns (uint256); function stakedTotalSupplyOf(uint256 _projectId) external view returns (uint256); function totalSupplyOf(uint256 _projectId) external view returns (uint256); function balanceOf(address _holder, uint256 _projectId) external view returns (uint256 _result); function issue( uint256 _projectId, string calldata _name, string calldata _symbol ) external; function print( address _holder, uint256 _projectId, uint256 _amount, bool _preferUnstakedTickets ) external; function redeem( address _holder, uint256 _projectId, uint256 _amount, bool _preferUnstaked ) external; function stake( address _holder, uint256 _projectId, uint256 _amount ) external; function unstake( address _holder, uint256 _projectId, uint256 _amount ) external; function lock( address _holder, uint256 _projectId, uint256 _amount ) external; function unlock( address _holder, uint256 _projectId, uint256 _amount ) external; function transfer( address _holder, uint256 _projectId, uint256 _amount, address _recipient ) external; }
// SPDX-License-Identifier: MIT pragma solidity 0.8.6; import "./IPrices.sol"; import "./IProjects.sol"; import "./IFundingCycleBallot.sol"; /// @notice The funding cycle structure represents a project stewarded by an address, and accounts for which addresses have helped sustain the project. struct FundingCycle { // A unique number that's incremented for each new funding cycle, starting with 1. uint256 id; // The ID of the project contract that this funding cycle belongs to. uint256 projectId; // The number of this funding cycle for the project. uint256 number; // The ID of a previous funding cycle that this one is based on. uint256 basedOn; // The time when this funding cycle was last configured. uint256 configured; // The number of cycles that this configuration should last for before going back to the last permanent. uint256 cycleLimit; // A number determining the amount of redistribution shares this funding cycle will issue to each sustainer. uint256 weight; // The ballot contract to use to determine a subsequent funding cycle's reconfiguration status. IFundingCycleBallot ballot; // The time when this funding cycle will become active. uint256 start; // The number of seconds until this funding cycle's surplus is redistributed. uint256 duration; // The amount that this funding cycle is targeting in terms of the currency. uint256 target; // The currency that the target is measured in. uint256 currency; // The percentage of each payment to send as a fee to the Juicebox admin. uint256 fee; // A percentage indicating how much more weight to give a funding cycle compared to its predecessor. uint256 discountRate; // The amount of available funds that have been tapped by the project in terms of the currency. uint256 tapped; // A packed list of extra data. The first 8 bytes are reserved for versioning. uint256 metadata; } struct FundingCycleProperties { uint256 target; uint256 currency; uint256 duration; uint256 cycleLimit; uint256 discountRate; IFundingCycleBallot ballot; } interface IFundingCycles { event Configure( uint256 indexed fundingCycleId, uint256 indexed projectId, uint256 reconfigured, FundingCycleProperties _properties, uint256 metadata, address caller ); event Tap( uint256 indexed fundingCycleId, uint256 indexed projectId, uint256 amount, uint256 newTappedAmount, address caller ); event Init( uint256 indexed fundingCycleId, uint256 indexed projectId, uint256 number, uint256 previous, uint256 weight, uint256 start ); function latestIdOf(uint256 _projectId) external view returns (uint256); function count() external view returns (uint256); function BASE_WEIGHT() external view returns (uint256); function MAX_CYCLE_LIMIT() external view returns (uint256); function get(uint256 _fundingCycleId) external view returns (FundingCycle memory); function queuedOf(uint256 _projectId) external view returns (FundingCycle memory); function currentOf(uint256 _projectId) external view returns (FundingCycle memory); function currentBallotStateOf(uint256 _projectId) external view returns (BallotState); function configure( uint256 _projectId, FundingCycleProperties calldata _properties, uint256 _metadata, uint256 _fee, bool _configureActiveFundingCycle ) external returns (FundingCycle memory fundingCycle); function tap(uint256 _projectId, uint256 _amount) external returns (FundingCycle memory fundingCycle); }
// SPDX-License-Identifier: MIT pragma solidity 0.8.6; import "@openzeppelin/contracts/token/ERC20/IERC20.sol"; import "./ITerminalV1.sol"; // In constructure, give unlimited access for TerminalV1 to take money from this. interface IYielder { function deposited() external view returns (uint256); function getCurrentBalance() external view returns (uint256); function deposit() external payable; function withdraw(uint256 _amount, address payable _beneficiary) external; function withdrawAll(address payable _beneficiary) external returns (uint256); }
// SPDX-License-Identifier: MIT pragma solidity 0.8.6; import "@openzeppelin/contracts/token/ERC721/IERC721.sol"; import "./ITerminal.sol"; import "./IOperatorStore.sol"; interface IProjects is IERC721 { event Create( uint256 indexed projectId, address indexed owner, bytes32 indexed handle, string uri, ITerminal terminal, address caller ); event SetHandle( uint256 indexed projectId, bytes32 indexed handle, address caller ); event SetUri(uint256 indexed projectId, string uri, address caller); event TransferHandle( uint256 indexed projectId, address indexed to, bytes32 indexed handle, bytes32 newHandle, address caller ); event ClaimHandle( address indexed account, uint256 indexed projectId, bytes32 indexed handle, address caller ); event ChallengeHandle( bytes32 indexed handle, uint256 challengeExpiry, address caller ); event RenewHandle( bytes32 indexed handle, uint256 indexed projectId, address caller ); function count() external view returns (uint256); function uriOf(uint256 _projectId) external view returns (string memory); function handleOf(uint256 _projectId) external returns (bytes32 handle); function projectFor(bytes32 _handle) external returns (uint256 projectId); function transferAddressFor(bytes32 _handle) external returns (address receiver); function challengeExpiryOf(bytes32 _handle) external returns (uint256); function exists(uint256 _projectId) external view returns (bool); function create( address _owner, bytes32 _handle, string calldata _uri, ITerminal _terminal ) external returns (uint256 id); function setHandle(uint256 _projectId, bytes32 _handle) external; function setUri(uint256 _projectId, string calldata _uri) external; function transferHandle( uint256 _projectId, address _to, bytes32 _newHandle ) external returns (bytes32 _handle); function claimHandle( bytes32 _handle, address _for, uint256 _projectId ) external; }
// SPDX-License-Identifier: MIT pragma solidity 0.8.6; import "./IOperatorStore.sol"; import "./IProjects.sol"; import "./IModAllocator.sol"; struct PayoutMod { bool preferUnstaked; uint16 percent; uint48 lockedUntil; address payable beneficiary; IModAllocator allocator; uint56 projectId; } struct TicketMod { bool preferUnstaked; uint16 percent; uint48 lockedUntil; address payable beneficiary; } interface IModStore { event SetPayoutMod( uint256 indexed projectId, uint256 indexed configuration, PayoutMod mods, address caller ); event SetTicketMod( uint256 indexed projectId, uint256 indexed configuration, TicketMod mods, address caller ); function projects() external view returns (IProjects); function payoutModsOf(uint256 _projectId, uint256 _configuration) external view returns (PayoutMod[] memory); function ticketModsOf(uint256 _projectId, uint256 _configuration) external view returns (TicketMod[] memory); function setPayoutMods( uint256 _projectId, uint256 _configuration, PayoutMod[] memory _mods ) external; function setTicketMods( uint256 _projectId, uint256 _configuration, TicketMod[] memory _mods ) external; }
// SPDX-License-Identifier: MIT pragma solidity 0.8.6; import './ITerminalDirectory.sol'; interface ITerminal { function terminalDirectory() external view returns (ITerminalDirectory); function migrationIsAllowed(ITerminal _terminal) external view returns (bool); function pay( uint256 _projectId, address _beneficiary, string calldata _memo, bool _preferUnstakedTickets ) external payable returns (uint256 fundingCycleId); function addToBalance(uint256 _projectId) external payable; function allowMigration(ITerminal _contract) external; function migrate(uint256 _projectId, ITerminal _to) external; }
// SPDX-License-Identifier: MIT pragma solidity 0.8.6; interface IOperatorStore { event SetOperator( address indexed operator, address indexed account, uint256 indexed domain, uint256[] permissionIndexes, uint256 packed ); function permissionsOf( address _operator, address _account, uint256 _domain ) external view returns (uint256); function hasPermission( address _operator, address _account, uint256 _domain, uint256 _permissionIndex ) external view returns (bool); function hasPermissions( address _operator, address _account, uint256 _domain, uint256[] calldata _permissionIndexes ) external view returns (bool); function setOperator( address _operator, uint256 _domain, uint256[] calldata _permissionIndexes ) external; function setOperators( address[] calldata _operators, uint256[] calldata _domains, uint256[][] calldata _permissionIndexes ) external; }
// SPDX-License-Identifier: MIT pragma solidity 0.8.6; interface ITreasuryExtension { function ETHValue(uint256 _projectId) external view returns (uint256); }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /** * @dev Interface of the ERC165 standard, as defined in the * https://eips.ethereum.org/EIPS/eip-165[EIP]. * * Implementers can declare support of contract interfaces, which can then be * queried by others ({ERC165Checker}). * * For an implementation, see {ERC165}. */ interface IERC165 { /** * @dev Returns true if this contract implements the interface defined by * `interfaceId`. See the corresponding * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section] * to learn more about how these ids are created. * * This function call must use less than 30 000 gas. */ function supportsInterface(bytes4 interfaceId) external view returns (bool); }
// SPDX-License-Identifier: MIT pragma solidity 0.8.6; import "@openzeppelin/contracts/token/ERC20/IERC20.sol"; interface ITickets is IERC20 { function print(address _account, uint256 _amount) external; function redeem(address _account, uint256 _amount) external; }
// SPDX-License-Identifier: MIT pragma solidity 0.8.6; import "./IDirectPaymentAddress.sol"; import "./ITerminal.sol"; import "./IProjects.sol"; import "./IProjects.sol"; interface ITerminalDirectory { event DeployAddress( uint256 indexed projectId, string memo, address indexed caller ); event SetTerminal( uint256 indexed projectId, ITerminal indexed terminal, address caller ); event SetPayerPreferences( address indexed account, address beneficiary, bool preferUnstakedTickets ); function projects() external view returns (IProjects); function terminalOf(uint256 _projectId) external view returns (ITerminal); function beneficiaryOf(address _account) external returns (address); function unstakedTicketsPreferenceOf(address _account) external returns (bool); function addressesOf(uint256 _projectId) external view returns (IDirectPaymentAddress[] memory); function deployAddress(uint256 _projectId, string calldata _memo) external; function setTerminal(uint256 _projectId, ITerminal _terminal) external; function setPayerPreferences( address _beneficiary, bool _preferUnstakedTickets ) external; }
// SPDX-License-Identifier: MIT pragma solidity 0.8.6; import "./ITerminalDirectory.sol"; import "./ITerminal.sol"; interface IDirectPaymentAddress { event Forward( address indexed payer, uint256 indexed projectId, address beneficiary, uint256 value, string memo, bool preferUnstakedTickets ); function terminalDirectory() external returns (ITerminalDirectory); function projectId() external returns (uint256); function memo() external returns (string memory); }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /** * @dev Interface of the ERC20 standard as defined in the EIP. */ interface IERC20 { /** * @dev Returns the amount of tokens in existence. */ function totalSupply() external view returns (uint256); /** * @dev Returns the amount of tokens owned by `account`. */ function balanceOf(address account) external view returns (uint256); /** * @dev Moves `amount` tokens from the caller's account to `recipient`. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transfer(address recipient, uint256 amount) external returns (bool); /** * @dev Returns the remaining number of tokens that `spender` will be * allowed to spend on behalf of `owner` through {transferFrom}. This is * zero by default. * * This value changes when {approve} or {transferFrom} are called. */ function allowance(address owner, address spender) external view returns (uint256); /** * @dev Sets `amount` as the allowance of `spender` over the caller's tokens. * * Returns a boolean value indicating whether the operation succeeded. * * IMPORTANT: Beware that changing an allowance with this method brings the risk * that someone may use both the old and the new allowance by unfortunate * transaction ordering. One possible solution to mitigate this race * condition is to first reduce the spender's allowance to 0 and set the * desired value afterwards: * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 * * Emits an {Approval} event. */ function approve(address spender, uint256 amount) external returns (bool); /** * @dev Moves `amount` tokens from `sender` to `recipient` using the * allowance mechanism. `amount` is then deducted from the caller's * allowance. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transferFrom( address sender, address recipient, uint256 amount ) external returns (bool); /** * @dev Emitted when `value` tokens are moved from one account (`from`) to * another (`to`). * * Note that `value` may be zero. */ event Transfer(address indexed from, address indexed to, uint256 value); /** * @dev Emitted when the allowance of a `spender` for an `owner` is set by * a call to {approve}. `value` is the new allowance. */ event Approval(address indexed owner, address indexed spender, uint256 value); }
// SPDX-License-Identifier: MIT pragma solidity 0.8.6; import "@chainlink/contracts/src/v0.6/interfaces/AggregatorV3Interface.sol"; interface IPrices { event AddFeed(uint256 indexed currency, AggregatorV3Interface indexed feed); function feedDecimalAdjuster(uint256 _currency) external returns (uint256); function targetDecimals() external returns (uint256); function feedFor(uint256 _currency) external returns (AggregatorV3Interface); function getETHPriceFor(uint256 _currency) external view returns (uint256); function addFeed(AggregatorV3Interface _priceFeed, uint256 _currency) external; }
// SPDX-License-Identifier: MIT pragma solidity 0.8.6; import "./ITerminalV1.sol"; enum BallotState { Approved, Active, Failed, Standby } interface IFundingCycleBallot { function duration() external view returns (uint256); function state(uint256 _fundingCycleId, uint256 _configured) external view returns (BallotState); }
// SPDX-License-Identifier: MIT pragma solidity >=0.6.0; interface AggregatorV3Interface { function decimals() external view returns (uint8); function description() external view returns (string memory); function version() external view returns (uint256); // getRoundData and latestRoundData should both raise "No data present" // if they do not have data to report, instead of returning unset values // which could be misinterpreted as actual reported values. function getRoundData(uint80 _roundId) external view returns ( uint80 roundId, int256 answer, uint256 startedAt, uint256 updatedAt, uint80 answeredInRound ); function latestRoundData() external view returns ( uint80 roundId, int256 answer, uint256 startedAt, uint256 updatedAt, uint80 answeredInRound ); }
// SPDX-License-Identifier: MIT pragma solidity 0.8.6; import '@openzeppelin/contracts/token/ERC721/IERC721.sol'; import './ITicketBooth.sol'; import './IFundingCycles.sol'; import './IYielder.sol'; import './IProjects.sol'; import './IModStore.sol'; import './IPrices.sol'; import './ITerminal.sol'; import './IOperatorStore.sol'; struct FundingCycleMetadata { uint256 reservedRate; uint256 bondingCurveRate; uint256 reconfigurationBondingCurveRate; } interface ITerminalV1 { event Pay( uint256 indexed fundingCycleId, uint256 indexed projectId, address indexed beneficiary, uint256 amount, string note, address caller ); event AddToBalance(uint256 indexed projectId, uint256 value, address caller); event AllowMigration(ITerminal allowed); event Migrate(uint256 indexed projectId, ITerminal indexed to, uint256 _amount, address caller); event Configure(uint256 indexed fundingCycleId, uint256 indexed projectId, address caller); event Tap( uint256 indexed fundingCycleId, uint256 indexed projectId, address indexed beneficiary, uint256 amount, uint256 currency, uint256 netTransferAmount, uint256 beneficiaryTransferAmount, uint256 govFeeAmount, address caller ); event Redeem( address indexed holder, address indexed beneficiary, uint256 indexed _projectId, uint256 amount, uint256 returnAmount, address caller ); event PrintReserveTickets( uint256 indexed fundingCycleId, uint256 indexed projectId, address indexed beneficiary, uint256 count, uint256 beneficiaryTicketAmount, address caller ); event DistributeToPayoutMod( uint256 indexed fundingCycleId, uint256 indexed projectId, PayoutMod mod, uint256 modCut, address caller ); event DistributeToTicketMod( uint256 indexed fundingCycleId, uint256 indexed projectId, TicketMod mod, uint256 modCut, address caller ); event AppointGovernance(address governance); event AcceptGovernance(address governance); event PrintPreminedTickets( uint256 indexed projectId, address indexed beneficiary, uint256 amount, uint256 currency, string memo, address caller ); event Deposit(uint256 amount); event EnsureTargetLocalWei(uint256 target); event SetYielder(IYielder newYielder); event SetFee(uint256 _amount); event SetTargetLocalWei(uint256 amount); function governance() external view returns (address payable); function pendingGovernance() external view returns (address payable); function projects() external view returns (IProjects); function fundingCycles() external view returns (IFundingCycles); function ticketBooth() external view returns (ITicketBooth); function prices() external view returns (IPrices); function modStore() external view returns (IModStore); function reservedTicketBalanceOf(uint256 _projectId, uint256 _reservedRate) external view returns (uint256); function canPrintPreminedTickets(uint256 _projectId) external view returns (bool); function balanceOf(uint256 _projectId) external view returns (uint256); function currentOverflowOf(uint256 _projectId) external view returns (uint256); function claimableOverflowOf( address _account, uint256 _amount, uint256 _projectId ) external view returns (uint256); function fee() external view returns (uint256); function deploy( address _owner, bytes32 _handle, string calldata _uri, FundingCycleProperties calldata _properties, FundingCycleMetadata calldata _metadata, PayoutMod[] memory _payoutMods, TicketMod[] memory _ticketMods ) external; function configure( uint256 _projectId, FundingCycleProperties calldata _properties, FundingCycleMetadata calldata _metadata, PayoutMod[] memory _payoutMods, TicketMod[] memory _ticketMods ) external returns (uint256); function printPreminedTickets( uint256 _projectId, uint256 _amount, uint256 _currency, address _beneficiary, string memory _memo, bool _preferUnstakedTickets ) external; function tap( uint256 _projectId, uint256 _amount, uint256 _currency, uint256 _minReturnedWei ) external returns (uint256); function redeem( address _account, uint256 _projectId, uint256 _amount, uint256 _minReturnedWei, address payable _beneficiary, bool _preferUnstaked ) external returns (uint256 returnAmount); function printReservedTickets(uint256 _projectId) external returns (uint256 reservedTicketsToPrint); function setFee(uint256 _fee) external; function appointGovernance(address payable _pendingGovernance) external; function acceptGovernance() external; }
// SPDX-License-Identifier: MIT pragma solidity 0.8.6; interface IModAllocator { event Allocate( uint256 indexed projectId, uint256 indexed forProjectId, address indexed beneficiary, uint256 amount, address caller ); function allocate( uint256 _projectId, uint256 _forProjectId, address _beneficiary ) external payable; }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /** * @title ERC721 token receiver interface * @dev Interface for any contract that wants to support safeTransfers * from ERC721 asset contracts. */ interface IERC721Receiver { /** * @dev Whenever an {IERC721} `tokenId` token is transferred to this contract via {IERC721-safeTransferFrom} * by `operator` from `from`, this function is called. * * It must return its Solidity selector to confirm the token transfer. * If any other value is returned or the interface is not implemented by the recipient, the transfer will be reverted. * * The selector can be obtained in Solidity with `IERC721.onERC721Received.selector`. */ function onERC721Received( address operator, address from, uint256 tokenId, bytes calldata data ) external returns (bytes4); }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "../utils/Context.sol"; /** * @dev Contract module which provides a basic access control mechanism, where * there is an account (an owner) that can be granted exclusive access to * specific functions. * * By default, the owner account will be the one that deploys the contract. This * can later be changed with {transferOwnership}. * * This module is used through inheritance. It will make available the modifier * `onlyOwner`, which can be applied to your functions to restrict their use to * the owner. */ abstract contract Ownable is Context { address private _owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); /** * @dev Initializes the contract setting the deployer as the initial owner. */ constructor() { _setOwner(_msgSender()); } /** * @dev Returns the address of the current owner. */ function owner() public view virtual returns (address) { return _owner; } /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { require(owner() == _msgSender(), "Ownable: caller is not the owner"); _; } /** * @dev Leaves the contract without owner. It will not be possible to call * `onlyOwner` functions anymore. Can only be called by the current owner. * * NOTE: Renouncing ownership will leave the contract without an owner, * thereby removing any functionality that is only available to the owner. */ function renounceOwnership() public virtual onlyOwner { _setOwner(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"); _setOwner(newOwner); } function _setOwner(address newOwner) private { address oldOwner = _owner; _owner = newOwner; emit OwnershipTransferred(oldOwner, newOwner); } }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /* * @dev Provides information about the current execution context, including the * sender of the transaction and its data. While these are generally available * via msg.sender and msg.data, they should not be accessed in such a direct * manner, since when dealing with meta-transactions the account sending and * paying for execution may not be the actual sender (as far as an application * is concerned). * * This contract is only required for intermediate, library-like contracts. */ abstract contract Context { function _msgSender() internal view virtual returns (address) { return msg.sender; } function _msgData() internal view virtual returns (bytes calldata) { return msg.data; } }
// SPDX-License-Identifier: MIT pragma solidity 0.8.6; import "./IOperatorStore.sol"; interface IOperatable { function operatorStore() external view returns (IOperatorStore); }
{ "optimizer": { "enabled": true, "runs": 10000 }, "outputSelection": { "*": { "*": [ "evm.bytecode", "evm.deployedBytecode", "devdoc", "userdoc", "metadata", "abi" ] } }, "metadata": { "useLiteralContent": true }, "libraries": {} }
Contract Security Audit
- No Contract Security Audit Submitted- Submit Audit Here
[{"inputs":[{"internalType":"contract IProjects","name":"_projects","type":"address"},{"internalType":"contract IFundingCycles","name":"_fundingCycles","type":"address"},{"internalType":"contract ITicketBooth","name":"_ticketBooth","type":"address"},{"internalType":"contract IOperatorStore","name":"_operatorStore","type":"address"},{"internalType":"contract IModStore","name":"_modStore","type":"address"},{"internalType":"contract IPrices","name":"_prices","type":"address"},{"internalType":"contract ITerminalDirectory","name":"_terminalDirectory","type":"address"},{"internalType":"address","name":"_owner","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[{"internalType":"uint256","name":"prod1","type":"uint256"}],"name":"PRBMath__MulDivFixedPointOverflow","type":"error"},{"inputs":[{"internalType":"uint256","name":"prod1","type":"uint256"},{"internalType":"uint256","name":"denominator","type":"uint256"}],"name":"PRBMath__MulDivOverflow","type":"error"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"projectId","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"value","type":"uint256"},{"indexed":false,"internalType":"address","name":"caller","type":"address"}],"name":"AddToBalance","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"contract ITerminal","name":"allowed","type":"address"}],"name":"AllowMigration","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"fundingCycleId","type":"uint256"},{"indexed":true,"internalType":"uint256","name":"projectId","type":"uint256"},{"indexed":false,"internalType":"address","name":"caller","type":"address"}],"name":"Configure","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"Deposit","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"fundingCycleId","type":"uint256"},{"indexed":true,"internalType":"uint256","name":"projectId","type":"uint256"},{"components":[{"internalType":"bool","name":"preferUnstaked","type":"bool"},{"internalType":"uint16","name":"percent","type":"uint16"},{"internalType":"uint48","name":"lockedUntil","type":"uint48"},{"internalType":"address payable","name":"beneficiary","type":"address"},{"internalType":"contract IModAllocator","name":"allocator","type":"address"},{"internalType":"uint56","name":"projectId","type":"uint56"}],"indexed":false,"internalType":"struct PayoutMod","name":"mod","type":"tuple"},{"indexed":false,"internalType":"uint256","name":"modCut","type":"uint256"},{"indexed":false,"internalType":"address","name":"caller","type":"address"}],"name":"DistributeToPayoutMod","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"fundingCycleId","type":"uint256"},{"indexed":true,"internalType":"uint256","name":"projectId","type":"uint256"},{"components":[{"internalType":"bool","name":"preferUnstaked","type":"bool"},{"internalType":"uint16","name":"percent","type":"uint16"},{"internalType":"uint48","name":"lockedUntil","type":"uint48"},{"internalType":"address payable","name":"beneficiary","type":"address"}],"indexed":false,"internalType":"struct TicketMod","name":"mod","type":"tuple"},{"indexed":false,"internalType":"uint256","name":"modCut","type":"uint256"},{"indexed":false,"internalType":"address","name":"caller","type":"address"}],"name":"DistributeToTicketMod","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"target","type":"uint256"}],"name":"EnsureTargetLocalWei","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"projectId","type":"uint256"},{"indexed":true,"internalType":"contract ITerminal","name":"to","type":"address"},{"indexed":false,"internalType":"uint256","name":"_amount","type":"uint256"},{"indexed":false,"internalType":"address","name":"caller","type":"address"}],"name":"Migrate","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"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"fundingCycleId","type":"uint256"},{"indexed":true,"internalType":"uint256","name":"projectId","type":"uint256"},{"indexed":true,"internalType":"address","name":"beneficiary","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"beneficiaryTokens","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"totalTokens","type":"uint256"},{"indexed":false,"internalType":"string","name":"note","type":"string"},{"indexed":false,"internalType":"address","name":"caller","type":"address"}],"name":"Pay","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"fundingCycleId","type":"uint256"},{"indexed":true,"internalType":"uint256","name":"projectId","type":"uint256"},{"indexed":true,"internalType":"address","name":"beneficiary","type":"address"},{"indexed":false,"internalType":"uint256","name":"count","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"beneficiaryTicketAmount","type":"uint256"},{"indexed":false,"internalType":"address","name":"caller","type":"address"}],"name":"PrintReserveTickets","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"projectId","type":"uint256"},{"indexed":true,"internalType":"address","name":"beneficiary","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"},{"indexed":false,"internalType":"string","name":"memo","type":"string"},{"indexed":false,"internalType":"address","name":"caller","type":"address"}],"name":"PrintTickets","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"holder","type":"address"},{"indexed":true,"internalType":"address","name":"beneficiary","type":"address"},{"indexed":true,"internalType":"uint256","name":"_projectId","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"returnAmount","type":"uint256"},{"indexed":false,"internalType":"address","name":"caller","type":"address"}],"name":"Redeem","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"SetFee","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"SetTargetLocalWei","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"contract IYielder","name":"newYielder","type":"address"}],"name":"SetYielder","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"fundingCycleId","type":"uint256"},{"indexed":true,"internalType":"uint256","name":"projectId","type":"uint256"},{"indexed":true,"internalType":"address","name":"beneficiary","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"currency","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"netTransferAmount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"beneficiaryTransferAmount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"govFeeAmount","type":"uint256"},{"indexed":false,"internalType":"address","name":"caller","type":"address"}],"name":"Tap","type":"event"},{"inputs":[{"internalType":"uint256","name":"_projectId","type":"uint256"}],"name":"addToBalance","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"contract ITerminal","name":"_contract","type":"address"}],"name":"allowMigration","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"balanceOf","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_projectId","type":"uint256"}],"name":"burnFromDeadAddress","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_account","type":"address"},{"internalType":"uint256","name":"_projectId","type":"uint256"},{"internalType":"uint256","name":"_count","type":"uint256"}],"name":"claimableOverflowOf","outputs":[{"internalType":"uint256","name":"_claimableOverflow","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_projectId","type":"uint256"},{"components":[{"internalType":"uint256","name":"target","type":"uint256"},{"internalType":"uint256","name":"currency","type":"uint256"},{"internalType":"uint256","name":"duration","type":"uint256"},{"internalType":"uint256","name":"cycleLimit","type":"uint256"},{"internalType":"uint256","name":"discountRate","type":"uint256"},{"internalType":"contract IFundingCycleBallot","name":"ballot","type":"address"}],"internalType":"struct FundingCycleProperties","name":"_properties","type":"tuple"},{"components":[{"internalType":"uint256","name":"reservedRate","type":"uint256"},{"internalType":"uint256","name":"bondingCurveRate","type":"uint256"},{"internalType":"uint256","name":"reconfigurationBondingCurveRate","type":"uint256"},{"internalType":"bool","name":"payIsPaused","type":"bool"},{"internalType":"bool","name":"ticketPrintingIsAllowed","type":"bool"},{"internalType":"contract ITreasuryExtension","name":"treasuryExtension","type":"address"}],"internalType":"struct FundingCycleMetadata2","name":"_metadata","type":"tuple"},{"components":[{"internalType":"bool","name":"preferUnstaked","type":"bool"},{"internalType":"uint16","name":"percent","type":"uint16"},{"internalType":"uint48","name":"lockedUntil","type":"uint48"},{"internalType":"address payable","name":"beneficiary","type":"address"},{"internalType":"contract IModAllocator","name":"allocator","type":"address"},{"internalType":"uint56","name":"projectId","type":"uint56"}],"internalType":"struct PayoutMod[]","name":"_payoutMods","type":"tuple[]"},{"components":[{"internalType":"bool","name":"preferUnstaked","type":"bool"},{"internalType":"uint16","name":"percent","type":"uint16"},{"internalType":"uint48","name":"lockedUntil","type":"uint48"},{"internalType":"address payable","name":"beneficiary","type":"address"}],"internalType":"struct TicketMod[]","name":"_ticketMods","type":"tuple[]"}],"name":"configure","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_projectId","type":"uint256"}],"name":"currentOverflowOf","outputs":[{"internalType":"uint256","name":"overflow","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_owner","type":"address"},{"internalType":"bytes32","name":"_handle","type":"bytes32"},{"internalType":"string","name":"_uri","type":"string"},{"components":[{"internalType":"uint256","name":"target","type":"uint256"},{"internalType":"uint256","name":"currency","type":"uint256"},{"internalType":"uint256","name":"duration","type":"uint256"},{"internalType":"uint256","name":"cycleLimit","type":"uint256"},{"internalType":"uint256","name":"discountRate","type":"uint256"},{"internalType":"contract IFundingCycleBallot","name":"ballot","type":"address"}],"internalType":"struct FundingCycleProperties","name":"_properties","type":"tuple"},{"components":[{"internalType":"uint256","name":"reservedRate","type":"uint256"},{"internalType":"uint256","name":"bondingCurveRate","type":"uint256"},{"internalType":"uint256","name":"reconfigurationBondingCurveRate","type":"uint256"},{"internalType":"bool","name":"payIsPaused","type":"bool"},{"internalType":"bool","name":"ticketPrintingIsAllowed","type":"bool"},{"internalType":"contract ITreasuryExtension","name":"treasuryExtension","type":"address"}],"internalType":"struct FundingCycleMetadata2","name":"_metadata","type":"tuple"},{"components":[{"internalType":"bool","name":"preferUnstaked","type":"bool"},{"internalType":"uint16","name":"percent","type":"uint16"},{"internalType":"uint48","name":"lockedUntil","type":"uint48"},{"internalType":"address payable","name":"beneficiary","type":"address"},{"internalType":"contract IModAllocator","name":"allocator","type":"address"},{"internalType":"uint56","name":"projectId","type":"uint56"}],"internalType":"struct PayoutMod[]","name":"_payoutMods","type":"tuple[]"},{"components":[{"internalType":"bool","name":"preferUnstaked","type":"bool"},{"internalType":"uint16","name":"percent","type":"uint16"},{"internalType":"uint48","name":"lockedUntil","type":"uint48"},{"internalType":"address payable","name":"beneficiary","type":"address"}],"internalType":"struct TicketMod[]","name":"_ticketMods","type":"tuple[]"}],"name":"deploy","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"fee","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"fundingCycles","outputs":[{"internalType":"contract IFundingCycles","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_projectId","type":"uint256"},{"internalType":"contract ITerminal","name":"_to","type":"address"}],"name":"migrate","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"contract ITerminal","name":"","type":"address"}],"name":"migrationIsAllowed","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"modStore","outputs":[{"internalType":"contract IModStore","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"operatorStore","outputs":[{"internalType":"contract IOperatorStore","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_projectId","type":"uint256"},{"internalType":"address","name":"_beneficiary","type":"address"},{"internalType":"string","name":"_memo","type":"string"},{"internalType":"bool","name":"_preferUnstakedTickets","type":"bool"}],"name":"pay","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"payable","type":"function"},{"inputs":[],"name":"prices","outputs":[{"internalType":"contract IPrices","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_projectId","type":"uint256"}],"name":"printReservedTickets","outputs":[{"internalType":"uint256","name":"amount","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_projectId","type":"uint256"},{"internalType":"uint256","name":"_amount","type":"uint256"},{"internalType":"address","name":"_beneficiary","type":"address"},{"internalType":"string","name":"_memo","type":"string"},{"internalType":"bool","name":"_preferUnstakedTickets","type":"bool"}],"name":"printTickets","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"projects","outputs":[{"internalType":"contract IProjects","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_account","type":"address"},{"internalType":"uint256","name":"_projectId","type":"uint256"},{"internalType":"uint256","name":"_count","type":"uint256"},{"internalType":"uint256","name":"_minReturnedWei","type":"uint256"},{"internalType":"address payable","name":"_beneficiary","type":"address"},{"internalType":"bool","name":"_preferUnstaked","type":"bool"}],"name":"redeem","outputs":[{"internalType":"uint256","name":"amount","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_projectId","type":"uint256"},{"internalType":"uint256","name":"_reservedRate","type":"uint256"}],"name":"reservedTicketBalanceOf","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_fee","type":"uint256"}],"name":"setFee","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_projectId","type":"uint256"},{"internalType":"uint256","name":"_amount","type":"uint256"},{"internalType":"uint256","name":"_currency","type":"uint256"},{"internalType":"uint256","name":"_minReturnedWei","type":"uint256"}],"name":"tap","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"terminalDirectory","outputs":[{"internalType":"contract ITerminalDirectory","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"ticketBooth","outputs":[{"internalType":"contract ITicketBooth","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"}]
Contract Creation Code
610160604052600a6004553480156200001757600080fd5b5060405162006447380380620064478339810160408190526200003a91620002b1565b606085901b6001600160601b03191660805260016000556200005c336200018e565b6001600160a01b038816158015906200007d57506001600160a01b03871615155b80156200009257506001600160a01b03861615155b8015620000a757506001600160a01b03841615155b8015620000bc57506001600160a01b03831615155b8015620000d157506001600160a01b03821615155b8015620000e657506001600160a01b03811615155b620001385760405162461bcd60e51b815260206004820152601860248201527f5465726d696e616c56313a205a45524f5f41444452455353000000000000000060448201526064015b60405180910390fd5b6001600160601b0319606089811b821660a05288811b821660c05287811b821660e05285811b82166101005284811b82166101205283901b16610140526200018081620001e0565b505050505050505062000388565b600180546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b6001546001600160a01b031633146200023c5760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657260448201526064016200012f565b6001600160a01b038116620002a35760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b60648201526084016200012f565b620002ae816200018e565b50565b600080600080600080600080610100898b031215620002cf57600080fd5b8851620002dc8162000372565b60208a0151909850620002ef8162000372565b60408a0151909750620003028162000372565b60608a0151909650620003158162000372565b60808a0151909550620003288162000372565b60a08a01519094506200033b8162000372565b60c08a01519093506200034e8162000372565b60e08a0151909250620003618162000372565b809150509295985092959890939650565b6001600160a01b0381168114620002ae57600080fd5b60805160601c60a05160601c60c05160601c60e05160601c6101005160601c6101205160601c6101405160601c615ef86200054f600039600081816102d601528181611e30015281816121060152818161238201528181613ca001528181613d70015261414f015260008181610559015281816108a201526144b001526000818161049101528181611aaa01528181611b5001528181613508015281816135ae01528181613f600152614a1b01526000818161041001528181610d2801528181610fe40152818161167d01528181611f97015281816124390152818161257d01528181612ac401528181612baa01528181612cc201528181612e25015281816130b401528181613a610152614b460152600081816103370152818161077d01528181610e470152818161110d015281816119c30152818161289301528181612d66015281816131a60152818161342101528181613745015261383801526000818161037e01528181610a4001528181610aff0152818161191901528181611bf60152818161263c01528181612fe5015261325e0152600081816104c5015281816112fc015281816113c801528181611cd90152818161271f01526133410152615ef86000f3fe6080604052600436106101b75760003560e01c806392ad35f3116100ec578063af82d3be1161008a578063ddca3f4311610064578063ddca3f431461057b578063ddfd414a14610591578063e0f793db146105b1578063f2fde38b146105d157600080fd5b8063af82d3be146104e7578063b9f1109114610507578063d3419bf31461054757600080fd5b80639c0eee02116100c65780639c0eee02146104325780639cc7f70814610452578063a7c3cca11461047f578063ad007d63146104b357600080fd5b806392ad35f3146103be5780639713eea6146103de5780639b602d60146103fe57600080fd5b806369fe0e2d11610159578063882af66711610133578063882af667146103255780638a19e355146103595780638b79543c1461036c5780638da5cb5b146103a057600080fd5b806369fe0e2d146102a45780636abcf8e3146102c4578063715018a61461031057600080fd5b80633015a5b5116101955780633015a5b514610222578063308a20ad146102425780633cc83ca614610264578063405b84fa1461028457600080fd5b806302c8986f146101bc57806308014ddc146101e25780632e9d3b8f14610202575b600080fd5b6101cf6101ca366004615525565b6105f1565b6040519081526020015b60405180910390f35b3480156101ee57600080fd5b506101cf6101fd36600461574b565b6106eb565b34801561020e57600080fd5b506101cf61021d3660046150af565b610ce5565b34801561022e57600080fd5b506101cf61023d3660046150e4565b611240565b34801561024e57600080fd5b5061026261025d366004614fa1565b611752565b005b34801561027057600080fd5b5061026261027f366004614fdb565b6118fa565b34801561029057600080fd5b5061026261029f366004615599565b611bc7565b3480156102b057600080fd5b506102626102bf36600461550c565b6121b4565b3480156102d057600080fd5b506102f87f000000000000000000000000000000000000000000000000000000000000000081565b6040516001600160a01b0390911681526020016101d9565b34801561031c57600080fd5b50610262612293565b34801561033157600080fd5b506102f87f000000000000000000000000000000000000000000000000000000000000000081565b61026261036736600461550c565b6122f9565b34801561037857600080fd5b506102f87f000000000000000000000000000000000000000000000000000000000000000081565b3480156103ac57600080fd5b506001546001600160a01b03166102f8565b3480156103ca57600080fd5b506101cf6103d936600461565d565b612538565b3480156103ea57600080fd5b506102626103f936600461567f565b61260d565b34801561040a57600080fd5b506102f87f000000000000000000000000000000000000000000000000000000000000000081565b34801561043e57600080fd5b5061026261044d36600461550c565b612b71565b34801561045e57600080fd5b506101cf61046d36600461550c565b60036020526000908152604090205481565b34801561048b57600080fd5b506102f87f000000000000000000000000000000000000000000000000000000000000000081565b3480156104bf57600080fd5b506102f87f000000000000000000000000000000000000000000000000000000000000000081565b3480156104f357600080fd5b506101cf61050236600461550c565b612d2a565b34801561051357600080fd5b50610537610522366004614fa1565b60056020526000908152604090205460ff1681565b60405190151581526020016101d9565b34801561055357600080fd5b506102f87f000000000000000000000000000000000000000000000000000000000000000081565b34801561058757600080fd5b506101cf60045481565b34801561059d57600080fd5b506101cf6105ac36600461550c565b61316a565b3480156105bd57600080fd5b506101cf6105cc3660046155c9565b61322c565b3480156105dd57600080fd5b506102626105ec366004614fa1565b613627565b60008034116106475760405162461bcd60e51b815260206004820152601660248201527f5456315f313a3a7061793a204241445f414d4f554e540000000000000000000060448201526064015b60405180910390fd5b6001600160a01b03851661069d5760405162461bcd60e51b815260206004820152601860248201527f5456315f313a3a7061793a205a45524f5f414444524553530000000000000000604482015260640161063e565b6106e186348787878080601f016020809104026020016040519081016040528093929190818152602001838380828437600092019190915250899250613709915050565b9695505050505050565b6000600260005414156107405760405162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c00604482015260640161063e565b600260009081556040517f1ee2c9bf00000000000000000000000000000000000000000000000000000000815260048101879052602481018690527f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031690631ee2c9bf9060440161020060405180830381600087803b1580156107ca57600080fd5b505af11580156107de573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610802919061543f565b8051909150610815576000915050610cd8565b80610160015184146108695760405162461bcd60e51b815260206004820152601f60248201527f5456315f313a3a7461703a20554e45585045435445445f43555252454e435900604482015260640161063e565b6101608101516040517f9fa937230000000000000000000000000000000000000000000000000000000081526000916001600160a01b037f00000000000000000000000000000000000000000000000000000000000000001691639fa93723916108d99160040190815260200190565b60206040518083038186803b1580156108f157600080fd5b505afa158015610905573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906109299190615373565b905060006109378783613c22565b9050808511156109895760405162461bcd60e51b815260206004820152601660248201527f5456315f313a3a7461703a20494e414445515541544500000000000000000000604482015260640161063e565b602080840151600090815260039091526040902054808211156109ee5760405162461bcd60e51b815260206004820152601e60248201527f5456315f313a3a7461703a20494e53554646494349454e545f46554e44530000604482015260640161063e565b6109f88282615cf2565b60008a81526003602090815260408083209390935586015191517f6352211e0000000000000000000000000000000000000000000000000000000081526004810192909252907f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031690636352211e9060240160206040518083038186803b158015610a8a57600080fd5b505afa158015610a9e573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610ac29190614fbe565b6040517f49491987000000000000000000000000000000000000000000000000000000008152600481018c90529091506000906001600160a01b037f00000000000000000000000000000000000000000000000000000000000000001690634949198790602401602060405180830381600087803b158015610b4357600080fd5b505af1158015610b57573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610b7b9190615373565b905060008087610180015111610b92576000610be7565b6101808701516040517f4665652066726f6d2040000000000000000000000000000000000000000000006020820152602a8101849052610be79187918690604a01604051602081830303815290604052613c37565b90506000610c4088610bf98489615cf2565b6040517f5061796f75742066726f6d2040000000000000000000000000000000000000006020820152602d8101879052604d01604051602081830303815290604052613f1c565b90508015610c5257610c52848261438d565b836001600160a01b0316886020015189600001517fe7f36a5ce6404ca99aa79e20649f15a86eed188b6362c51d0302ba182b7af3b88f8c6101600151878c610c9a9190615cf2565b6040805193845260208401929092529082015260608101869052608081018790523360a082015260c00160405180910390a450509451955050505050505b6001600055949350505050565b6040517efdd58e0000000000000000000000000000000000000000000000000000000081526001600160a01b0384811660048301526024820184905260009183917f0000000000000000000000000000000000000000000000000000000000000000169062fdd58e9060440160206040518083038186803b158015610d6957600080fd5b505afa158015610d7d573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610da19190615373565b1015610e155760405162461bcd60e51b815260206004820152602e60248201527f5456315f313a3a636c61696d61626c654f766572666c6f773a20494e5355464660448201527f494349454e545f5449434b455453000000000000000000000000000000000000606482015260840161063e565b6040517f43a266c2000000000000000000000000000000000000000000000000000000008152600481018490526000907f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316906343a266c2906024016102006040518083038186803b158015610e9257600080fd5b505afa158015610ea6573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610eca919061543f565b9050806040015160001415610ee3576000915050611239565b6000610eee826144ab565b905080925060006022836101e00151901c6001600160a01b03161115610fa2576022826101e00151901c6001600160a01b031663b37961da866040518263ffffffff1660e01b8152600401610f4591815260200190565b60206040518083038186803b158015610f5d57600080fd5b505afa158015610f71573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610f959190615373565b610f9f9084615c66565b92505b82610fb257600092505050611239565b6040517f75b0d9cd000000000000000000000000000000000000000000000000000000008152600481018690526000907f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316906375b0d9cd9060240160206040518083038186803b15801561102e57600080fd5b505afa158015611042573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906110669190615373565b9050600061109460026000898152602001908152602001600020546008866101e00151901c60ff16846145c1565b905080156110a9576110a68183615c66565b91505b818614156110cb578285116110be57846110c0565b825b945050505050611239565b60006110d8868885614634565b9050600060016040517fc55f571c000000000000000000000000000000000000000000000000000000008152600481018b90527f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03169063c55f571c9060240160206040518083038186803b15801561115757600080fd5b505afa15801561116b573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061118f919061538c565b60038111156111a0576111a0615dd9565b146111b7576010866101e00151901c60ff166111c5565b6018866101e00151901c60ff165b90508060c814156111d85781965061121c565b806111ef576111e8828986614634565b965061121c565b611219826112088a6112028560c8615cf2565b88614634565b6112129084615c66565b60c8614634565b96505b8487111561123257849650505050505050611239565b5050505050505b9392505050565b6000600260005414156112955760405162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c00604482015260640161063e565b600260005586866003336001600160a01b038416148061137657506040517fc161c93f0000000000000000000000000000000000000000000000000000000081523360048201526001600160a01b03848116602483015260448201849052606482018390527f0000000000000000000000000000000000000000000000000000000000000000169063c161c93f9060840160206040518083038186803b15801561133e57600080fd5b505afa158015611352573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906113769190615356565b8061144257506040517fc161c93f0000000000000000000000000000000000000000000000000000000081523360048201526001600160a01b03848116602483015260006044830152606482018390527f0000000000000000000000000000000000000000000000000000000000000000169063c161c93f9060840160206040518083038186803b15801561140a57600080fd5b505afa15801561141e573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906114429190615356565b61148e5760405162461bcd60e51b815260206004820152601860248201527f4f706572617461626c653a20554e415554484f52495a45440000000000000000604482015260640161063e565b600088116114de5760405162461bcd60e51b815260206004820152601460248201527f5456315f313a3a72656465656d3a204e4f5f4f50000000000000000000000000604482015260640161063e565b6001600160a01b0386166115345760405162461bcd60e51b815260206004820152601b60248201527f5456315f313a3a72656465656d3a205a45524f5f414444524553530000000000604482015260640161063e565b61153f8a8a8a610ce5565b9350868410156115915760405162461bcd60e51b815260206004820152601960248201527f5456315f313a3a72656465656d3a20494e414445515541544500000000000000604482015260640161063e565b83156115c1576000898152600360205260409020546115b1908590615cf2565b60008a8152600360205260409020555b600089815260026020526040812054908112611600578881126115ed576115e88982615c7e565b61161d565b6115f7818a615c7e565b6115e890615d42565b8861160a82615d42565b6116149190615c66565b61161d90615d42565b60008b8152600260205260409081902091909155517f65e0d7310000000000000000000000000000000000000000000000000000000081526001600160a01b038c81166004830152602482018c9052604482018b905287151560648301527f000000000000000000000000000000000000000000000000000000000000000016906365e0d73190608401600060405180830381600087803b1580156116c157600080fd5b505af11580156116d5573d6000803e3d6000fd5b5050505060008511156116ec576116ec878661438d565b604080518a815260208101879052338183015290518b916001600160a01b038a811692908f16917f78ce282a3b64e54349642ee14253bf3ca2a4c69b6e479d57d196027f1d0a514e919081900360600190a4505060016000555090979650505050505050565b6001546001600160a01b031633146117ac5760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015260640161063e565b6001600160a01b0381166118285760405162461bcd60e51b815260206004820152602360248201527f5456315f313a3a616c6c6f774d6967726174696f6e3a205a45524f5f4144445260448201527f4553530000000000000000000000000000000000000000000000000000000000606482015260840161063e565b6001600160a01b0381163014156118815760405162461bcd60e51b815260206004820152601c60248201527f5456315f313a3a616c6c6f774d6967726174696f6e3a204e4f5f4f5000000000604482015260640161063e565b6001600160a01b03811660008181526005602090815260409182902080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0016600117905590519182527fdbee026e3c3dc50322e5f718d6bf90a96cefdc9e2bfa693436d0e1ddf600d1cc91015b60405180910390a150565b600061191361190e368690038601866153ad565b614739565b905060007f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03166317753c468b8b8b8b306040518663ffffffff1660e01b815260040161196b9594939291906157ca565b602060405180830381600087803b15801561198557600080fd5b505af1158015611999573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906119bd9190615373565b905060007f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316638a1b0eb483898660045460016040518663ffffffff1660e01b8152600401611a18959493929190615912565b61020060405180830381600087803b158015611a3357600080fd5b505af1158015611a47573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611a6b919061543f565b855190915015611b145760808101516040517fa67e210a0000000000000000000000000000000000000000000000000000000081526001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000169163a67e210a91611ae19186918a90600401615989565b600060405180830381600087803b158015611afb57600080fd5b505af1158015611b0f573d6000803e3d6000fd5b505050505b835115611bba5760808101516040517febe352a40000000000000000000000000000000000000000000000000000000081526001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000169163ebe352a491611b879186918990600401615a35565b600060405180830381600087803b158015611ba157600080fd5b505af1158015611bb5573d6000803e3d6000fd5b505050505b5050505050505050505050565b6040517f6352211e000000000000000000000000000000000000000000000000000000008152600481018390527f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031690636352211e9060240160206040518083038186803b158015611c4057600080fd5b505afa158015611c54573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611c789190614fbe565b826004336001600160a01b0384161480611d5357506040517fc161c93f0000000000000000000000000000000000000000000000000000000081523360048201526001600160a01b03848116602483015260448201849052606482018390527f0000000000000000000000000000000000000000000000000000000000000000169063c161c93f9060840160206040518083038186803b158015611d1b57600080fd5b505afa158015611d2f573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611d539190615356565b611d9f5760405162461bcd60e51b815260206004820152601860248201527f4f706572617461626c653a20554e415554484f52495a45440000000000000000604482015260640161063e565b60026000541415611df25760405162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c00604482015260640161063e565b60026000556040517f4fe0eced0000000000000000000000000000000000000000000000000000000081526004810186905230906001600160a01b037f00000000000000000000000000000000000000000000000000000000000000001690634fe0eced9060240160206040518083038186803b158015611e7257600080fd5b505afa158015611e86573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611eaa9190614fbe565b6001600160a01b031614611f005760405162461bcd60e51b815260206004820152601c60248201527f5456315f313a3a6d6967726174653a20554e415554484f52495a454400000000604482015260640161063e565b6001600160a01b03841660009081526005602052604090205460ff16611f685760405162461bcd60e51b815260206004820152601b60248201527f5456315f313a3a6d6967726174653a204e4f545f414c4c4f5745440000000000604482015260640161063e565b6040517f75b0d9cd000000000000000000000000000000000000000000000000000000008152600481018690527f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316906375b0d9cd9060240160206040518083038186803b158015611fe157600080fd5b505afa158015611ff5573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906120199190615373565b600086815260026020526040902054146120385761203685612d2a565b505b6000858152600360205260408120805491905580156120c7576040517f8a19e355000000000000000000000000000000000000000000000000000000008152600481018790526001600160a01b03861690638a19e3559083906024016000604051808303818588803b1580156120ad57600080fd5b505af11580156120c1573d6000803e3d6000fd5b50505050505b6040517f9fc9ea47000000000000000000000000000000000000000000000000000000008152600481018790526001600160a01b0386811660248301527f00000000000000000000000000000000000000000000000000000000000000001690639fc9ea4790604401600060405180830381600087803b15801561214a57600080fd5b505af115801561215e573d6000803e3d6000fd5b5050604080518481523360208201526001600160a01b03891693508992507fa7519e5f94697b7f53e97c5eb46a0c730a296ab686ab8fd333835c5f735784eb910160405180910390a35050600160005550505050565b6001546001600160a01b0316331461220e5760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015260640161063e565b600a81111561225f5760405162461bcd60e51b815260206004820152601660248201527f5456315f313a3a7365744665653a204241445f46454500000000000000000000604482015260640161063e565b60048190556040518181527e172ddfc5ae88d08b3de01a5a187667c37a5a53989e8c175055cb6c993792a7906020016118ef565b6001546001600160a01b031633146122ed5760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015260640161063e565b6122f7600061496d565b565b600034116123495760405162461bcd60e51b815260206004820152601f60248201527f5456315f313a3a616464546f42616c616e63653a204241445f414d4f554e5400604482015260640161063e565b6040517f4fe0eced0000000000000000000000000000000000000000000000000000000081526004810182905230906001600160a01b037f00000000000000000000000000000000000000000000000000000000000000001690634fe0eced9060240160206040518083038186803b1580156123c457600080fd5b505afa1580156123d8573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906123fc9190614fbe565b6001600160a01b0316146124cb576040517f75b0d9cd000000000000000000000000000000000000000000000000000000008152600481018290527f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316906375b0d9cd9060240160206040518083038186803b15801561248357600080fd5b505afa158015612497573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906124bb9190615373565b6000828152600260205260409020555b6000818152600360205260409020546124e5903490615c66565b600082815260036020908152604091829020929092558051348152339281019290925282917f08534c4f6026a713959f9286d994e8430e6d0fd11045360abf782bacaa288d43910160405180910390a250565b6000828152600260205260408082205490517f75b0d9cd00000000000000000000000000000000000000000000000000000000815260048101859052612604919084907f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316906375b0d9cd9060240160206040518083038186803b1580156125c757600080fd5b505afa1580156125db573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906125ff9190615373565b6145c1565b90505b92915050565b6040517f6352211e000000000000000000000000000000000000000000000000000000008152600481018690527f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031690636352211e9060240160206040518083038186803b15801561268657600080fd5b505afa15801561269a573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906126be9190614fbe565b856011336001600160a01b038416148061279957506040517fc161c93f0000000000000000000000000000000000000000000000000000000081523360048201526001600160a01b03848116602483015260448201849052606482018390527f0000000000000000000000000000000000000000000000000000000000000000169063c161c93f9060840160206040518083038186803b15801561276157600080fd5b505afa158015612775573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906127999190615356565b6127e55760405162461bcd60e51b815260206004820152601860248201527f4f706572617461626c653a20554e415554484f52495a45440000000000000000604482015260640161063e565b6001600160a01b0386166128615760405162461bcd60e51b815260206004820152602160248201527f5456315f313a3a7072696e745469636b6574733a205a45524f5f41444452455360448201527f5300000000000000000000000000000000000000000000000000000000000000606482015260840161063e565b6040517f43a266c2000000000000000000000000000000000000000000000000000000008152600481018990526000907f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316906343a266c2906024016102006040518083038186803b1580156128de57600080fd5b505afa1580156128f2573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612916919061543f565b905080604001516000148061293757506021816101e00151901c6001166001145b6129835760405162461bcd60e51b815260206004820181905260248201527f5456315f313a3a7072696e745469636b6574733a204e4f545f414c4c4f574544604482015260640161063e565b60008981526002602052604081205412806129d857506000898152600260205260409020547f7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff906129d5908a90615c66565b11155b612a4a5760405162461bcd60e51b815260206004820152602660248201527f5456315f313a3a7072696e745469636b6574733a20494e545f4c494d49545f5260448201527f4541434845440000000000000000000000000000000000000000000000000000606482015260840161063e565b600089815260026020526040902054612a64908990615bf2565b60008a8152600260205260409081902091909155517fe0826c890000000000000000000000000000000000000000000000000000000081526001600160a01b038881166004830152602482018b9052604482018a905286151560648301527f0000000000000000000000000000000000000000000000000000000000000000169063e0826c8990608401600060405180830381600087803b158015612b0857600080fd5b505af1158015612b1c573d6000803e3d6000fd5b50505050866001600160a01b0316897fb745c0ba548003047e8dc09b0dbf5eaed8ae262b5fe0221b4439af8cc40199058a8933604051612b5e939291906158e0565b60405180910390a3505050505050505050565b6040517efdd58e00000000000000000000000000000000000000000000000000000000815261dead6004820152602481018290526000907f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03169062fdd58e9060440160206040518083038186803b158015612bf357600080fd5b505afa158015612c07573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612c2b9190615373565b905060008111612c7d5760405162461bcd60e51b815260206004820152601460248201527f30783030204e4f5448494e475f544f5f4255524e000000000000000000000000604482015260640161063e565b6040517f65e0d73100000000000000000000000000000000000000000000000000000000815261dead60048201526024810183905260448101829052600160648201527f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316906365e0d73190608401600060405180830381600087803b158015612d0e57600080fd5b505af1158015612d22573d6000803e3d6000fd5b505050505050565b6040517f43a266c20000000000000000000000000000000000000000000000000000000081526004810182905260009081906001600160a01b037f000000000000000000000000000000000000000000000000000000000000000016906343a266c2906024016102006040518083038186803b158015612da957600080fd5b505afa158015612dbd573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612de1919061543f565b8051909150612df35750600092915050565b6040517f75b0d9cd000000000000000000000000000000000000000000000000000000008152600481018490526000907f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316906375b0d9cd9060240160206040518083038186803b158015612e6f57600080fd5b505afa158015612e83573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612ea79190615373565b9050612ed360026000868152602001908152602001600020546008846101e00151901c60ff16836145c1565b92507f7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff612f008483615c66565b1115612f745760405162461bcd60e51b815260206004820152602e60248201527f5456315f313a3a7072696e7452657365727665645469636b6574733a20494e5460448201527f5f4c494d49545f52454143484544000000000000000000000000000000000000606482015260840161063e565b612f7e8382615c66565b6000858152600260205260408120919091558315612fa557612fa083856149d7565b612fa8565b60005b6040517f6352211e000000000000000000000000000000000000000000000000000000008152600481018790529091506000906001600160a01b037f00000000000000000000000000000000000000000000000000000000000000001690636352211e9060240160206040518083038186803b15801561302757600080fd5b505afa15801561303b573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061305f9190614fbe565b90508115613111576040517fe0826c890000000000000000000000000000000000000000000000000000000081526001600160a01b0382811660048301526024820188905260448201849052600060648301527f0000000000000000000000000000000000000000000000000000000000000000169063e0826c8990608401600060405180830381600087803b1580156130f857600080fd5b505af115801561310c573d6000803e3d6000fd5b505050505b83516040805187815260208101859052338183015290516001600160a01b03841692899290917f54ad84f37b2d6ff349b859f99f05bceaba2ee199cde3b63ae47c38f5d6116c0d9181900360600190a450505050919050565b6040517f43a266c20000000000000000000000000000000000000000000000000000000081526004810182905260009081906001600160a01b037f000000000000000000000000000000000000000000000000000000000000000016906343a266c2906024016102006040518083038186803b1580156131e957600080fd5b505afa1580156131fd573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613221919061543f565b9050611239816144ab565b6040517f6352211e000000000000000000000000000000000000000000000000000000008152600481018690526000907f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031690636352211e9060240160206040518083038186803b1580156132a857600080fd5b505afa1580156132bc573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906132e09190614fbe565b866001336001600160a01b03841614806133bb57506040517fc161c93f0000000000000000000000000000000000000000000000000000000081523360048201526001600160a01b03848116602483015260448201849052606482018390527f0000000000000000000000000000000000000000000000000000000000000000169063c161c93f9060840160206040518083038186803b15801561338357600080fd5b505afa158015613397573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906133bb9190615356565b6134075760405162461bcd60e51b815260206004820152601860248201527f4f706572617461626c653a20554e415554484f52495a45440000000000000000604482015260640161063e565b600061341b61190e368a90038a018a6153ad565b905060007f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316638a1b0eb48c8c8560045460006040518663ffffffff1660e01b8152600401613476959493929190615912565b61020060405180830381600087803b15801561349157600080fd5b505af11580156134a5573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906134c9919061543f565b8851909150156135725760808101516040517fa67e210a0000000000000000000000000000000000000000000000000000000081526001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000169163a67e210a9161353f918f918d90600401615989565b600060405180830381600087803b15801561355957600080fd5b505af115801561356d573d6000803e3d6000fd5b505050505b8651156136185760808101516040517febe352a40000000000000000000000000000000000000000000000000000000081526001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000169163ebe352a4916135e5918f918c90600401615a35565b600060405180830381600087803b1580156135ff57600080fd5b505af1158015613613573d6000803e3d6000fd5b505050505b519a9950505050505050505050565b6001546001600160a01b031633146136815760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015260640161063e565b6001600160a01b0381166136fd5760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201527f6464726573730000000000000000000000000000000000000000000000000000606482015260840161063e565b6137068161496d565b50565b6040517f43a266c20000000000000000000000000000000000000000000000000000000081526004810186905260009081906001600160a01b037f000000000000000000000000000000000000000000000000000000000000000016906343a266c2906024016102006040518083038186803b15801561378857600080fd5b505afa15801561379c573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906137c0919061543f565b90506020816101e00151901c60011660001461381e5760405162461bcd60e51b815260206004820152601260248201527f5456315f313a3a7061793a205041555345440000000000000000000000000000604482015260640161063e565b60008160400151600014613836578160c001516138c7565b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031663e16fd0ec6040518163ffffffff1660e01b815260040160206040518083038186803b15801561388f57600080fd5b505afa1580156138a3573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906138c79190615373565b905060006138d58883614c4f565b9050600083604001516000146138f7576008846101e00151901c60ff166138fa565b60005b9050600061390d836112128460c8615cf2565b60008c81526003602052604090205490915061392a908b90615c66565b60008c8152600360205260409020558015613ac2576040850151613a135760008b815260026020526040812054128061399d575060008b8152600260205260409020547f7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff9061399a908590615c66565b11155b6139e95760405162461bcd60e51b815260206004820152601c60248201527f5456315f313a3a70617920494e545f4c494d49545f5245414348454400000000604482015260640161063e565b60008b815260026020526040902054613a03908290615bf2565b60008c8152600260205260409020555b6040517fe0826c890000000000000000000000000000000000000000000000000000000081526001600160a01b038a81166004830152602482018d90526044820183905288151560648301527f0000000000000000000000000000000000000000000000000000000000000000169063e0826c8990608401600060405180830381600087803b158015613aa557600080fd5b505af1158015613ab9573d6000803e3d6000fd5b50505050613bc3565b8215613bc35760008b8152600260205260408120541380613b27575060008b8152600260205260409020547f7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff908490613b1a90615d42565b613b249190615c66565b11155b613b995760405162461bcd60e51b815260206004820152602660248201527f5456315f313a3a7072696e745469636b6574733a20494e545f4c494d49545f5260448201527f4541434845440000000000000000000000000000000000000000000000000000606482015260840161063e565b60008b815260026020526040902054613bb3908490615c7e565b60008c8152600260205260409020555b886001600160a01b03168b86600001517fd595184f93e5de76e6c92bf66d279d827d0be8fad5cec3a420d86716e1a665328d85888e33604051613c0a959493929190615abc565b60405180910390a45050915198975050505050505050565b600061260483670de0b6b3a764000084614634565b6000613c4e8560c8613c498782615c66565b614634565b613c589086615cf2565b905080613c6757506000613f14565b6040517f4fe0eced0000000000000000000000000000000000000000000000000000000081526001600482015230906001600160a01b037f00000000000000000000000000000000000000000000000000000000000000001690634fe0eced9060240160206040518083038186803b158015613ce257600080fd5b505afa158015613cf6573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613d1a9190614fbe565b6001600160a01b03161415613d3e57613d3860018285856000613709565b50613f14565b6040517f4fe0eced000000000000000000000000000000000000000000000000000000008152600160048201526000907f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031690634fe0eced9060240160206040518083038186803b158015613dba57600080fd5b505afa158015613dce573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613df29190614fbe565b90506001600160a01b038116613e705760405162461bcd60e51b815260206004820152602360248201527f5456315f313a3a5f74616b654665653a205445524d494e414c5f4e4f545f464f60448201527f554e440000000000000000000000000000000000000000000000000000000000606482015260840161063e565b6040517f02c8986f0000000000000000000000000000000000000000000000000000000081526001600160a01b038216906302c8986f908490613ebf906001908990899060009060040161581e565b6020604051808303818588803b158015613ed857600080fd5b505af1158015613eec573d6000803e3d6000fd5b50505050506040513d601f19601f82011682018060405250810190613f119190615373565b50505b949350505050565b602083015160808401516040517f7559aaaa0000000000000000000000000000000000000000000000000000000081526004810192909252602482015282906000907f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031690637559aaaa9060440160006040518083038186803b158015613faa57600080fd5b505afa158015613fbe573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052613fe6919081019061514b565b9050805160001415613ff85750611239565b60005b815181101561438457600082828151811061401857614018615e08565b60200260200101519050600061403987836020015161ffff16612710614634565b9050801561431e5760808201516001600160a01b0316156140fc576080820151602089015160a084015160608501516040517fec695ef7000000000000000000000000000000000000000000000000000000008152600481019390935266ffffffffffffff90911660248301526001600160a01b0390811660448301529091169063ec695ef79083906064016000604051808303818588803b1580156140de57600080fd5b505af11580156140f2573d6000803e3d6000fd5b505050505061431e565b60a082015166ffffffffffffff16156143105760a08201516040517f4fe0eced00000000000000000000000000000000000000000000000000000000815266ffffffffffffff90911660048201526000907f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031690634fe0eced9060240160206040518083038186803b15801561419957600080fd5b505afa1580156141ad573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906141d19190614fbe565b90506001600160a01b0381166142295760405162461bcd60e51b815260206004820152601360248201527f5456315f313a3a7461703a204241445f4d4f4400000000000000000000000000604482015260640161063e565b6001600160a01b0381163014156142625761425c8360a0015166ffffffffffffff168385606001518a8760000151613709565b5061430a565b60a0830151606084015184516040517f02c8986f0000000000000000000000000000000000000000000000000000000081526001600160a01b038516936302c8986f9387936142b6938e9190600401615afc565b6020604051808303818588803b1580156142cf57600080fd5b505af11580156142e3573d6000803e3d6000fd5b50505050506040513d601f19601f820116820180604052508101906143089190615373565b505b5061431e565b61431e82606001518261438d565b6143288186615cf2565b9450876020015188600001517fd37e528ac0cd9d9eeaa32903a436be474cce5651f7d3313a580ceacdae5cb34584843360405161436793929190615859565b60405180910390a35050808061437c90615d09565b915050613ffb565b50509392505050565b804710156143dd5760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a20696e73756666696369656e742062616c616e6365000000604482015260640161063e565b6000826001600160a01b03168260405160006040518083038185875af1925050503d806000811461442a576040519150601f19603f3d011682016040523d82523d6000602084013e61442f565b606091505b50509050806144a65760405162461bcd60e51b815260206004820152603a60248201527f416464726573733a20756e61626c6520746f2073656e642076616c75652c207260448201527f6563697069656e74206d61792068617665207265766572746564000000000000606482015260840161063e565b505050565b6000807f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316639fa937238461016001516040518263ffffffff1660e01b815260040161450191815260200190565b60206040518083038186803b15801561451957600080fd5b505afa15801561452d573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906145519190615373565b90506000836101c0015184610140015161456b9190615cf2565b9050600081156145845761457f8284613c22565b614587565b60005b6020808701516000908152600390915260409020549091508181106145b5576145b08282615cf2565b6106e1565b60009695505050505050565b60008060008512156145e5576145d685615d42565b6145e09084615c66565b6145ef565b6145ef8584615cf2565b905080614600576000915050611239565b8360c81415614610579050611239565b806146218160c8613c498882615cf2565b61462b9190615cf2565b95945050505050565b600080807fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff858709858702925082811083820303915050806000141561468d5783828161468357614683615daa565b0492505050611239565b8381106146d0576040517f773cc18c000000000000000000000000000000000000000000000000000000008152600481018290526024810185905260440161063e565b60008486880960026001871981018816978890046003810283188082028403028082028403028082028403028082028403028082028403029081029092039091026000889003889004909101858311909403939093029303949094049190911702949350505050565b600060c8826000015111156147b65760405162461bcd60e51b815260206004820152603e60248201527f5456315f313a3a5f76616c6964617465416e645061636b46756e64696e67437960448201527f636c654d657461646174613a204241445f52455345525645445f524154450000606482015260840161063e565b60c8826020015111156148575760405162461bcd60e51b815260206004820152604360248201527f5456315f313a3a5f76616c6964617465416e645061636b46756e64696e67437960448201527f636c654d657461646174613a204241445f424f4e44494e475f43555256455f5260648201527f4154450000000000000000000000000000000000000000000000000000000000608482015260a40161063e565b60c8826040015111156148f85760405162461bcd60e51b815260206004820152605360248201527f5456315f313a3a5f76616c6964617465416e645061636b46756e64696e67437960448201527f636c654d657461646174613a204241445f5245434f4e46494755524154494f4e60648201527f5f424f4e44494e475f43555256455f5241544500000000000000000000000000608482015260a40161063e565b50805160208201516040830151606084015160189190911b60109290921b60089390931b9290921717600117901561493257640100000000175b81608001511561494457640200000000175b60a0919091015160221b7803fffffffffffffffffffffffffffffffffffffffc00000000161790565b600180546001600160a01b038381167fffffffffffffffffffffffff0000000000000000000000000000000000000000831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b602082015160808301516040517f4833b5120000000000000000000000000000000000000000000000000000000081526004810192909252602482015281906000907f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031690634833b5129060440160006040518083038186803b158015614a6557600080fd5b505afa158015614a79573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052614aa19190810190615262565b905060005b8151811015614c47576000828281518110614ac357614ac3615e08565b602002602001015190506000614ae486836020015161ffff16612710614634565b90508015614ba5576060820151602088015183516040517fe0826c890000000000000000000000000000000000000000000000000000000081526001600160a01b039384166004820152602481019290925260448201849052151560648201527f00000000000000000000000000000000000000000000000000000000000000009091169063e0826c8990608401600060405180830381600087803b158015614b8c57600080fd5b505af1158015614ba0573d6000803e3d6000fd5b505050505b614baf8186615cf2565b6020808901518951604080518751151581528785015161ffff16948101949094528087015165ffffffffffff16908401526060808701516001600160a01b031690840152608083018590523360a084015292975091907fe499491e3f5b7f35b5078102c27aa039bbde7ed027b91c996ac41e15d8f87d5c9060c00160405180910390a350508080614c3f90615d09565b915050614aa6565b505092915050565b60006126048383600080807fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff848609848602925082811083820303915050670de0b6b3a76400008110614cd1576040517fd31b34020000000000000000000000000000000000000000000000000000000081526004810182905260240161063e565b600080670de0b6b3a76400008688099150506706f05b59d3b1ffff811182614d0b5780670de0b6b3a7640000850401945050505050612607565b6204000082850304939091119091037d40000000000000000000000000000000000000000000000000000000000002919091177faccb18165bd6fe31ae1cf318dc5b51eee0e1ba569b88cd74c1773b91fac106690201905092915050565b600082601f830112614d7a57600080fd5b81356020614d8f614d8a83615bce565b615b9d565b8281528181019085830160c080860288018501891015614dae57600080fd5b6000805b87811015614e4c5782848c031215614dc8578182fd5b614dd0615b2d565b8435614ddb81615e7b565b815284880135614dea81615e89565b81890152604085810135614dfd81615e99565b90820152606085810135614e1081615e66565b90820152608085810135614e2381615e66565b9082015260a085810135614e3681615ead565b9082015286529486019492820192600101614db2565b50929998505050505050505050565b600082601f830112614e6c57600080fd5b81356020614e7c614d8a83615bce565b80838252828201915082860187848660071b8901011115614e9c57600080fd5b6000805b86811015614f1757608080848c031215614eb8578283fd5b614ec0615b56565b8435614ecb81615e7b565b815284880135614eda81615e89565b81890152604085810135614eed81615e99565b90820152606085810135614f0081615e66565b908201528652948601949290920191600101614ea0565b509198975050505050505050565b8035614f3081615e7b565b919050565b8051614f3081615e66565b60008083601f840112614f5257600080fd5b50813567ffffffffffffffff811115614f6a57600080fd5b602083019150836020828501011115614f8257600080fd5b9250929050565b600060c08284031215614f9b57600080fd5b50919050565b600060208284031215614fb357600080fd5b813561123981615e66565b600060208284031215614fd057600080fd5b815161123981615e66565b600080600080600080600080610220898b031215614ff857600080fd5b883561500381615e66565b975060208901359650604089013567ffffffffffffffff8082111561502757600080fd5b6150338c838d01614f40565b90985096508691506150488c60608d01614f89565b95506150588c6101208d01614f89565b94506101e08b013591508082111561506f57600080fd5b61507b8c838d01614d69565b93506102008b013591508082111561509257600080fd5b5061509f8b828c01614e5b565b9150509295985092959890939650565b6000806000606084860312156150c457600080fd5b83356150cf81615e66565b95602085013595506040909401359392505050565b60008060008060008060c087890312156150fd57600080fd5b863561510881615e66565b9550602087013594506040870135935060608701359250608087013561512d81615e66565b915060a087013561513d81615e7b565b809150509295509295509295565b6000602080838503121561515e57600080fd5b825167ffffffffffffffff81111561517557600080fd5b8301601f8101851361518657600080fd5b8051615194614d8a82615bce565b8181528381019083850160c0808502860187018a10156151b357600080fd5b60009550855b858110156152535781838c0312156151cf578687fd5b6151d7615b2d565b83516151e281615e7b565b8152838901516151f181615e89565b818a015260408481015161520481615e99565b9082015260608481015161521781615e66565b9082015260808481015161522a81615e66565b9082015260a08481015161523d81615ead565b90820152855293870193918101916001016151b9565b50919998505050505050505050565b6000602080838503121561527557600080fd5b825167ffffffffffffffff81111561528c57600080fd5b8301601f8101851361529d57600080fd5b80516152ab614d8a82615bce565b80828252848201915084840188868560071b87010111156152cb57600080fd5b60009450845b8481101561534857608080838c0312156152e9578687fd5b6152f1615b56565b83516152fc81615e7b565b81528389015161530b81615e89565b818a015260408481015161531e81615e99565b9082015260608481015161533181615e66565b9082015285529387019391909101906001016152d1565b509098975050505050505050565b60006020828403121561536857600080fd5b815161123981615e7b565b60006020828403121561538557600080fd5b5051919050565b60006020828403121561539e57600080fd5b81516004811061123957600080fd5b600060c082840312156153bf57600080fd5b60405160c0810181811067ffffffffffffffff821117156153e2576153e2615e37565b8060405250823581526020830135602082015260408301356040820152606083013561540d81615e7b565b6060820152608083013561542081615e7b565b608082015260a083013561543381615e66565b60a08201529392505050565b6000610200828403121561545257600080fd5b61545a615b79565b825181526020830151602082015260408301516040820152606083015160608201526080830151608082015260a083015160a082015260c083015160c08201526154a660e08401614f35565b60e0820152610100838101519082015261012080840151908201526101408084015190820152610160808401519082015261018080840151908201526101a080840151908201526101c080840151908201526101e0928301519281019290925250919050565b60006020828403121561551e57600080fd5b5035919050565b60008060008060006080868803121561553d57600080fd5b85359450602086013561554f81615e66565b9350604086013567ffffffffffffffff81111561556b57600080fd5b61557788828901614f40565b909450925050606086013561558b81615e7b565b809150509295509295909350565b600080604083850312156155ac57600080fd5b8235915060208301356155be81615e66565b809150509250929050565b60008060008060006101e086880312156155e257600080fd5b853594506155f38760208801614f89565b93506156028760e08801614f89565b92506101a086013567ffffffffffffffff8082111561562057600080fd5b61562c89838a01614d69565b93506101c088013591508082111561564357600080fd5b5061565088828901614e5b565b9150509295509295909350565b6000806040838503121561567057600080fd5b50508035926020909101359150565b600080600080600060a0868803121561569757600080fd5b85359450602080870135945060408701356156b181615e66565b9350606087013567ffffffffffffffff808211156156ce57600080fd5b818901915089601f8301126156e257600080fd5b8135818111156156f4576156f4615e37565b61570684601f19601f84011601615b9d565b91508082528a8482850101111561571c57600080fd5b808484018584013760008482840101525080945050505061573f60808701614f25565b90509295509295909350565b6000806000806080858703121561576157600080fd5b5050823594602084013594506040840135936060013592509050565b6000815180845260005b818110156157a357602081850181015186830182015201615787565b818111156157b5576000602083870101525b50601f01601f19169290920160200192915050565b60006001600160a01b03808816835286602084015260806040840152846080840152848660a0850137600060a0868501015260a0601f19601f87011684010191508084166060840152509695505050505050565b8481526001600160a01b0384166020820152608060408201526000615846608083018561577d565b9050821515606083015295945050505050565b61010081016158c3828680511515825261ffff602082015116602083015265ffffffffffff604082015116604083015260608101516001600160a01b038082166060850152806080840151166080850152505066ffffffffffffff60a08201511660a08301525050565b8360c08301526001600160a01b03831660e0830152949350505050565b8381526060602082015260006158f9606083018561577d565b90506001600160a01b0383166040830152949350505050565b60006101408201905086825285356020830152602086013560408301526040860135606083015260608601356080830152608086013560a083015260a086013561595b81615e66565b6001600160a01b031660c083015260e082019490945261010081019290925215156101209091015292915050565b6000606082018583526020858185015260606040850152818551808452608086019150828701935060005b8181101561534857615a2283865180511515825261ffff602082015116602083015265ffffffffffff604082015116604083015260608101516001600160a01b038082166060850152806080840151166080850152505066ffffffffffffff60a08201511660a08301525050565b9383019360c092909201916001016159b4565b600060608201858352602085818501526060604085015281855180845260809350838601915082870160005b8281101561525357615aac84835180511515825261ffff602082015116602083015265ffffffffffff60408201511660408301526001600160a01b0360608201511660608301525050565b9285019290840190600101615a61565b85815284602082015283604082015260a060608201526000615ae160a083018561577d565b90506001600160a01b03831660808301529695505050505050565b66ffffffffffffff851681526001600160a01b0384166020820152608060408201526000615846608083018561577d565b60405160c0810167ffffffffffffffff81118282101715615b5057615b50615e37565b60405290565b6040516080810167ffffffffffffffff81118282101715615b5057615b50615e37565b604051610200810167ffffffffffffffff81118282101715615b5057615b50615e37565b604051601f8201601f1916810167ffffffffffffffff81118282101715615bc657615bc6615e37565b604052919050565b600067ffffffffffffffff821115615be857615be8615e37565b5060051b60200190565b6000808212827f7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff03841381151615615c2c57615c2c615d7b565b827f8000000000000000000000000000000000000000000000000000000000000000038412811615615c6057615c60615d7b565b50500190565b60008219821115615c7957615c79615d7b565b500190565b6000808312837f800000000000000000000000000000000000000000000000000000000000000001831281151615615cb857615cb8615d7b565b837f7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff018313811615615cec57615cec615d7b565b50500390565b600082821015615d0457615d04615d7b565b500390565b60007fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff821415615d3b57615d3b615d7b565b5060010190565b60007f8000000000000000000000000000000000000000000000000000000000000000821415615d7457615d74615d7b565b5060000390565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052602160045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b6001600160a01b038116811461370657600080fd5b801515811461370657600080fd5b61ffff8116811461370657600080fd5b65ffffffffffff8116811461370657600080fd5b66ffffffffffffff8116811461370657600080fdfea2646970667358221220cee00c005eda902e3e3944b90b9665c0ae0c5171e6d0af961f2dfdadb5b5fb8764736f6c634300080600330000000000000000000000009b5a4053ffbb11ca9cd858aaee43cc95ab435418000000000000000000000000f507b2a1dd7439201eb07f11e1d62afb29216e2e000000000000000000000000ee2ebccb7cdb34a8a822b589f9e8427c24351bfc000000000000000000000000ab47304d987390e27ce3bc0fa4fe31e3a98b0db2000000000000000000000000b9e4b658298c7a36bdf4c2832042a5d6700c3ab8000000000000000000000000a9537cc42555564206d4e57c0eb6943d56e83a3000000000000000000000000046c9999a2edcd5aa177ed7e8af90c68b7d75ba46000000000000000000000000af28bcb48c40dbc86f52d459a6562f658fc94b1e
Deployed Bytecode
0x6080604052600436106101b75760003560e01c806392ad35f3116100ec578063af82d3be1161008a578063ddca3f4311610064578063ddca3f431461057b578063ddfd414a14610591578063e0f793db146105b1578063f2fde38b146105d157600080fd5b8063af82d3be146104e7578063b9f1109114610507578063d3419bf31461054757600080fd5b80639c0eee02116100c65780639c0eee02146104325780639cc7f70814610452578063a7c3cca11461047f578063ad007d63146104b357600080fd5b806392ad35f3146103be5780639713eea6146103de5780639b602d60146103fe57600080fd5b806369fe0e2d11610159578063882af66711610133578063882af667146103255780638a19e355146103595780638b79543c1461036c5780638da5cb5b146103a057600080fd5b806369fe0e2d146102a45780636abcf8e3146102c4578063715018a61461031057600080fd5b80633015a5b5116101955780633015a5b514610222578063308a20ad146102425780633cc83ca614610264578063405b84fa1461028457600080fd5b806302c8986f146101bc57806308014ddc146101e25780632e9d3b8f14610202575b600080fd5b6101cf6101ca366004615525565b6105f1565b6040519081526020015b60405180910390f35b3480156101ee57600080fd5b506101cf6101fd36600461574b565b6106eb565b34801561020e57600080fd5b506101cf61021d3660046150af565b610ce5565b34801561022e57600080fd5b506101cf61023d3660046150e4565b611240565b34801561024e57600080fd5b5061026261025d366004614fa1565b611752565b005b34801561027057600080fd5b5061026261027f366004614fdb565b6118fa565b34801561029057600080fd5b5061026261029f366004615599565b611bc7565b3480156102b057600080fd5b506102626102bf36600461550c565b6121b4565b3480156102d057600080fd5b506102f87f00000000000000000000000046c9999a2edcd5aa177ed7e8af90c68b7d75ba4681565b6040516001600160a01b0390911681526020016101d9565b34801561031c57600080fd5b50610262612293565b34801561033157600080fd5b506102f87f000000000000000000000000f507b2a1dd7439201eb07f11e1d62afb29216e2e81565b61026261036736600461550c565b6122f9565b34801561037857600080fd5b506102f87f0000000000000000000000009b5a4053ffbb11ca9cd858aaee43cc95ab43541881565b3480156103ac57600080fd5b506001546001600160a01b03166102f8565b3480156103ca57600080fd5b506101cf6103d936600461565d565b612538565b3480156103ea57600080fd5b506102626103f936600461567f565b61260d565b34801561040a57600080fd5b506102f87f000000000000000000000000ee2ebccb7cdb34a8a822b589f9e8427c24351bfc81565b34801561043e57600080fd5b5061026261044d36600461550c565b612b71565b34801561045e57600080fd5b506101cf61046d36600461550c565b60036020526000908152604090205481565b34801561048b57600080fd5b506102f87f000000000000000000000000b9e4b658298c7a36bdf4c2832042a5d6700c3ab881565b3480156104bf57600080fd5b506102f87f000000000000000000000000ab47304d987390e27ce3bc0fa4fe31e3a98b0db281565b3480156104f357600080fd5b506101cf61050236600461550c565b612d2a565b34801561051357600080fd5b50610537610522366004614fa1565b60056020526000908152604090205460ff1681565b60405190151581526020016101d9565b34801561055357600080fd5b506102f87f000000000000000000000000a9537cc42555564206d4e57c0eb6943d56e83a3081565b34801561058757600080fd5b506101cf60045481565b34801561059d57600080fd5b506101cf6105ac36600461550c565b61316a565b3480156105bd57600080fd5b506101cf6105cc3660046155c9565b61322c565b3480156105dd57600080fd5b506102626105ec366004614fa1565b613627565b60008034116106475760405162461bcd60e51b815260206004820152601660248201527f5456315f313a3a7061793a204241445f414d4f554e540000000000000000000060448201526064015b60405180910390fd5b6001600160a01b03851661069d5760405162461bcd60e51b815260206004820152601860248201527f5456315f313a3a7061793a205a45524f5f414444524553530000000000000000604482015260640161063e565b6106e186348787878080601f016020809104026020016040519081016040528093929190818152602001838380828437600092019190915250899250613709915050565b9695505050505050565b6000600260005414156107405760405162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c00604482015260640161063e565b600260009081556040517f1ee2c9bf00000000000000000000000000000000000000000000000000000000815260048101879052602481018690527f000000000000000000000000f507b2a1dd7439201eb07f11e1d62afb29216e2e6001600160a01b031690631ee2c9bf9060440161020060405180830381600087803b1580156107ca57600080fd5b505af11580156107de573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610802919061543f565b8051909150610815576000915050610cd8565b80610160015184146108695760405162461bcd60e51b815260206004820152601f60248201527f5456315f313a3a7461703a20554e45585045435445445f43555252454e435900604482015260640161063e565b6101608101516040517f9fa937230000000000000000000000000000000000000000000000000000000081526000916001600160a01b037f000000000000000000000000a9537cc42555564206d4e57c0eb6943d56e83a301691639fa93723916108d99160040190815260200190565b60206040518083038186803b1580156108f157600080fd5b505afa158015610905573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906109299190615373565b905060006109378783613c22565b9050808511156109895760405162461bcd60e51b815260206004820152601660248201527f5456315f313a3a7461703a20494e414445515541544500000000000000000000604482015260640161063e565b602080840151600090815260039091526040902054808211156109ee5760405162461bcd60e51b815260206004820152601e60248201527f5456315f313a3a7461703a20494e53554646494349454e545f46554e44530000604482015260640161063e565b6109f88282615cf2565b60008a81526003602090815260408083209390935586015191517f6352211e0000000000000000000000000000000000000000000000000000000081526004810192909252907f0000000000000000000000009b5a4053ffbb11ca9cd858aaee43cc95ab4354186001600160a01b031690636352211e9060240160206040518083038186803b158015610a8a57600080fd5b505afa158015610a9e573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610ac29190614fbe565b6040517f49491987000000000000000000000000000000000000000000000000000000008152600481018c90529091506000906001600160a01b037f0000000000000000000000009b5a4053ffbb11ca9cd858aaee43cc95ab4354181690634949198790602401602060405180830381600087803b158015610b4357600080fd5b505af1158015610b57573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610b7b9190615373565b905060008087610180015111610b92576000610be7565b6101808701516040517f4665652066726f6d2040000000000000000000000000000000000000000000006020820152602a8101849052610be79187918690604a01604051602081830303815290604052613c37565b90506000610c4088610bf98489615cf2565b6040517f5061796f75742066726f6d2040000000000000000000000000000000000000006020820152602d8101879052604d01604051602081830303815290604052613f1c565b90508015610c5257610c52848261438d565b836001600160a01b0316886020015189600001517fe7f36a5ce6404ca99aa79e20649f15a86eed188b6362c51d0302ba182b7af3b88f8c6101600151878c610c9a9190615cf2565b6040805193845260208401929092529082015260608101869052608081018790523360a082015260c00160405180910390a450509451955050505050505b6001600055949350505050565b6040517efdd58e0000000000000000000000000000000000000000000000000000000081526001600160a01b0384811660048301526024820184905260009183917f000000000000000000000000ee2ebccb7cdb34a8a822b589f9e8427c24351bfc169062fdd58e9060440160206040518083038186803b158015610d6957600080fd5b505afa158015610d7d573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610da19190615373565b1015610e155760405162461bcd60e51b815260206004820152602e60248201527f5456315f313a3a636c61696d61626c654f766572666c6f773a20494e5355464660448201527f494349454e545f5449434b455453000000000000000000000000000000000000606482015260840161063e565b6040517f43a266c2000000000000000000000000000000000000000000000000000000008152600481018490526000907f000000000000000000000000f507b2a1dd7439201eb07f11e1d62afb29216e2e6001600160a01b0316906343a266c2906024016102006040518083038186803b158015610e9257600080fd5b505afa158015610ea6573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610eca919061543f565b9050806040015160001415610ee3576000915050611239565b6000610eee826144ab565b905080925060006022836101e00151901c6001600160a01b03161115610fa2576022826101e00151901c6001600160a01b031663b37961da866040518263ffffffff1660e01b8152600401610f4591815260200190565b60206040518083038186803b158015610f5d57600080fd5b505afa158015610f71573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610f959190615373565b610f9f9084615c66565b92505b82610fb257600092505050611239565b6040517f75b0d9cd000000000000000000000000000000000000000000000000000000008152600481018690526000907f000000000000000000000000ee2ebccb7cdb34a8a822b589f9e8427c24351bfc6001600160a01b0316906375b0d9cd9060240160206040518083038186803b15801561102e57600080fd5b505afa158015611042573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906110669190615373565b9050600061109460026000898152602001908152602001600020546008866101e00151901c60ff16846145c1565b905080156110a9576110a68183615c66565b91505b818614156110cb578285116110be57846110c0565b825b945050505050611239565b60006110d8868885614634565b9050600060016040517fc55f571c000000000000000000000000000000000000000000000000000000008152600481018b90527f000000000000000000000000f507b2a1dd7439201eb07f11e1d62afb29216e2e6001600160a01b03169063c55f571c9060240160206040518083038186803b15801561115757600080fd5b505afa15801561116b573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061118f919061538c565b60038111156111a0576111a0615dd9565b146111b7576010866101e00151901c60ff166111c5565b6018866101e00151901c60ff165b90508060c814156111d85781965061121c565b806111ef576111e8828986614634565b965061121c565b611219826112088a6112028560c8615cf2565b88614634565b6112129084615c66565b60c8614634565b96505b8487111561123257849650505050505050611239565b5050505050505b9392505050565b6000600260005414156112955760405162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c00604482015260640161063e565b600260005586866003336001600160a01b038416148061137657506040517fc161c93f0000000000000000000000000000000000000000000000000000000081523360048201526001600160a01b03848116602483015260448201849052606482018390527f000000000000000000000000ab47304d987390e27ce3bc0fa4fe31e3a98b0db2169063c161c93f9060840160206040518083038186803b15801561133e57600080fd5b505afa158015611352573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906113769190615356565b8061144257506040517fc161c93f0000000000000000000000000000000000000000000000000000000081523360048201526001600160a01b03848116602483015260006044830152606482018390527f000000000000000000000000ab47304d987390e27ce3bc0fa4fe31e3a98b0db2169063c161c93f9060840160206040518083038186803b15801561140a57600080fd5b505afa15801561141e573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906114429190615356565b61148e5760405162461bcd60e51b815260206004820152601860248201527f4f706572617461626c653a20554e415554484f52495a45440000000000000000604482015260640161063e565b600088116114de5760405162461bcd60e51b815260206004820152601460248201527f5456315f313a3a72656465656d3a204e4f5f4f50000000000000000000000000604482015260640161063e565b6001600160a01b0386166115345760405162461bcd60e51b815260206004820152601b60248201527f5456315f313a3a72656465656d3a205a45524f5f414444524553530000000000604482015260640161063e565b61153f8a8a8a610ce5565b9350868410156115915760405162461bcd60e51b815260206004820152601960248201527f5456315f313a3a72656465656d3a20494e414445515541544500000000000000604482015260640161063e565b83156115c1576000898152600360205260409020546115b1908590615cf2565b60008a8152600360205260409020555b600089815260026020526040812054908112611600578881126115ed576115e88982615c7e565b61161d565b6115f7818a615c7e565b6115e890615d42565b8861160a82615d42565b6116149190615c66565b61161d90615d42565b60008b8152600260205260409081902091909155517f65e0d7310000000000000000000000000000000000000000000000000000000081526001600160a01b038c81166004830152602482018c9052604482018b905287151560648301527f000000000000000000000000ee2ebccb7cdb34a8a822b589f9e8427c24351bfc16906365e0d73190608401600060405180830381600087803b1580156116c157600080fd5b505af11580156116d5573d6000803e3d6000fd5b5050505060008511156116ec576116ec878661438d565b604080518a815260208101879052338183015290518b916001600160a01b038a811692908f16917f78ce282a3b64e54349642ee14253bf3ca2a4c69b6e479d57d196027f1d0a514e919081900360600190a4505060016000555090979650505050505050565b6001546001600160a01b031633146117ac5760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015260640161063e565b6001600160a01b0381166118285760405162461bcd60e51b815260206004820152602360248201527f5456315f313a3a616c6c6f774d6967726174696f6e3a205a45524f5f4144445260448201527f4553530000000000000000000000000000000000000000000000000000000000606482015260840161063e565b6001600160a01b0381163014156118815760405162461bcd60e51b815260206004820152601c60248201527f5456315f313a3a616c6c6f774d6967726174696f6e3a204e4f5f4f5000000000604482015260640161063e565b6001600160a01b03811660008181526005602090815260409182902080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0016600117905590519182527fdbee026e3c3dc50322e5f718d6bf90a96cefdc9e2bfa693436d0e1ddf600d1cc91015b60405180910390a150565b600061191361190e368690038601866153ad565b614739565b905060007f0000000000000000000000009b5a4053ffbb11ca9cd858aaee43cc95ab4354186001600160a01b03166317753c468b8b8b8b306040518663ffffffff1660e01b815260040161196b9594939291906157ca565b602060405180830381600087803b15801561198557600080fd5b505af1158015611999573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906119bd9190615373565b905060007f000000000000000000000000f507b2a1dd7439201eb07f11e1d62afb29216e2e6001600160a01b0316638a1b0eb483898660045460016040518663ffffffff1660e01b8152600401611a18959493929190615912565b61020060405180830381600087803b158015611a3357600080fd5b505af1158015611a47573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611a6b919061543f565b855190915015611b145760808101516040517fa67e210a0000000000000000000000000000000000000000000000000000000081526001600160a01b037f000000000000000000000000b9e4b658298c7a36bdf4c2832042a5d6700c3ab8169163a67e210a91611ae19186918a90600401615989565b600060405180830381600087803b158015611afb57600080fd5b505af1158015611b0f573d6000803e3d6000fd5b505050505b835115611bba5760808101516040517febe352a40000000000000000000000000000000000000000000000000000000081526001600160a01b037f000000000000000000000000b9e4b658298c7a36bdf4c2832042a5d6700c3ab8169163ebe352a491611b879186918990600401615a35565b600060405180830381600087803b158015611ba157600080fd5b505af1158015611bb5573d6000803e3d6000fd5b505050505b5050505050505050505050565b6040517f6352211e000000000000000000000000000000000000000000000000000000008152600481018390527f0000000000000000000000009b5a4053ffbb11ca9cd858aaee43cc95ab4354186001600160a01b031690636352211e9060240160206040518083038186803b158015611c4057600080fd5b505afa158015611c54573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611c789190614fbe565b826004336001600160a01b0384161480611d5357506040517fc161c93f0000000000000000000000000000000000000000000000000000000081523360048201526001600160a01b03848116602483015260448201849052606482018390527f000000000000000000000000ab47304d987390e27ce3bc0fa4fe31e3a98b0db2169063c161c93f9060840160206040518083038186803b158015611d1b57600080fd5b505afa158015611d2f573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611d539190615356565b611d9f5760405162461bcd60e51b815260206004820152601860248201527f4f706572617461626c653a20554e415554484f52495a45440000000000000000604482015260640161063e565b60026000541415611df25760405162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c00604482015260640161063e565b60026000556040517f4fe0eced0000000000000000000000000000000000000000000000000000000081526004810186905230906001600160a01b037f00000000000000000000000046c9999a2edcd5aa177ed7e8af90c68b7d75ba461690634fe0eced9060240160206040518083038186803b158015611e7257600080fd5b505afa158015611e86573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611eaa9190614fbe565b6001600160a01b031614611f005760405162461bcd60e51b815260206004820152601c60248201527f5456315f313a3a6d6967726174653a20554e415554484f52495a454400000000604482015260640161063e565b6001600160a01b03841660009081526005602052604090205460ff16611f685760405162461bcd60e51b815260206004820152601b60248201527f5456315f313a3a6d6967726174653a204e4f545f414c4c4f5745440000000000604482015260640161063e565b6040517f75b0d9cd000000000000000000000000000000000000000000000000000000008152600481018690527f000000000000000000000000ee2ebccb7cdb34a8a822b589f9e8427c24351bfc6001600160a01b0316906375b0d9cd9060240160206040518083038186803b158015611fe157600080fd5b505afa158015611ff5573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906120199190615373565b600086815260026020526040902054146120385761203685612d2a565b505b6000858152600360205260408120805491905580156120c7576040517f8a19e355000000000000000000000000000000000000000000000000000000008152600481018790526001600160a01b03861690638a19e3559083906024016000604051808303818588803b1580156120ad57600080fd5b505af11580156120c1573d6000803e3d6000fd5b50505050505b6040517f9fc9ea47000000000000000000000000000000000000000000000000000000008152600481018790526001600160a01b0386811660248301527f00000000000000000000000046c9999a2edcd5aa177ed7e8af90c68b7d75ba461690639fc9ea4790604401600060405180830381600087803b15801561214a57600080fd5b505af115801561215e573d6000803e3d6000fd5b5050604080518481523360208201526001600160a01b03891693508992507fa7519e5f94697b7f53e97c5eb46a0c730a296ab686ab8fd333835c5f735784eb910160405180910390a35050600160005550505050565b6001546001600160a01b0316331461220e5760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015260640161063e565b600a81111561225f5760405162461bcd60e51b815260206004820152601660248201527f5456315f313a3a7365744665653a204241445f46454500000000000000000000604482015260640161063e565b60048190556040518181527e172ddfc5ae88d08b3de01a5a187667c37a5a53989e8c175055cb6c993792a7906020016118ef565b6001546001600160a01b031633146122ed5760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015260640161063e565b6122f7600061496d565b565b600034116123495760405162461bcd60e51b815260206004820152601f60248201527f5456315f313a3a616464546f42616c616e63653a204241445f414d4f554e5400604482015260640161063e565b6040517f4fe0eced0000000000000000000000000000000000000000000000000000000081526004810182905230906001600160a01b037f00000000000000000000000046c9999a2edcd5aa177ed7e8af90c68b7d75ba461690634fe0eced9060240160206040518083038186803b1580156123c457600080fd5b505afa1580156123d8573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906123fc9190614fbe565b6001600160a01b0316146124cb576040517f75b0d9cd000000000000000000000000000000000000000000000000000000008152600481018290527f000000000000000000000000ee2ebccb7cdb34a8a822b589f9e8427c24351bfc6001600160a01b0316906375b0d9cd9060240160206040518083038186803b15801561248357600080fd5b505afa158015612497573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906124bb9190615373565b6000828152600260205260409020555b6000818152600360205260409020546124e5903490615c66565b600082815260036020908152604091829020929092558051348152339281019290925282917f08534c4f6026a713959f9286d994e8430e6d0fd11045360abf782bacaa288d43910160405180910390a250565b6000828152600260205260408082205490517f75b0d9cd00000000000000000000000000000000000000000000000000000000815260048101859052612604919084907f000000000000000000000000ee2ebccb7cdb34a8a822b589f9e8427c24351bfc6001600160a01b0316906375b0d9cd9060240160206040518083038186803b1580156125c757600080fd5b505afa1580156125db573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906125ff9190615373565b6145c1565b90505b92915050565b6040517f6352211e000000000000000000000000000000000000000000000000000000008152600481018690527f0000000000000000000000009b5a4053ffbb11ca9cd858aaee43cc95ab4354186001600160a01b031690636352211e9060240160206040518083038186803b15801561268657600080fd5b505afa15801561269a573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906126be9190614fbe565b856011336001600160a01b038416148061279957506040517fc161c93f0000000000000000000000000000000000000000000000000000000081523360048201526001600160a01b03848116602483015260448201849052606482018390527f000000000000000000000000ab47304d987390e27ce3bc0fa4fe31e3a98b0db2169063c161c93f9060840160206040518083038186803b15801561276157600080fd5b505afa158015612775573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906127999190615356565b6127e55760405162461bcd60e51b815260206004820152601860248201527f4f706572617461626c653a20554e415554484f52495a45440000000000000000604482015260640161063e565b6001600160a01b0386166128615760405162461bcd60e51b815260206004820152602160248201527f5456315f313a3a7072696e745469636b6574733a205a45524f5f41444452455360448201527f5300000000000000000000000000000000000000000000000000000000000000606482015260840161063e565b6040517f43a266c2000000000000000000000000000000000000000000000000000000008152600481018990526000907f000000000000000000000000f507b2a1dd7439201eb07f11e1d62afb29216e2e6001600160a01b0316906343a266c2906024016102006040518083038186803b1580156128de57600080fd5b505afa1580156128f2573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612916919061543f565b905080604001516000148061293757506021816101e00151901c6001166001145b6129835760405162461bcd60e51b815260206004820181905260248201527f5456315f313a3a7072696e745469636b6574733a204e4f545f414c4c4f574544604482015260640161063e565b60008981526002602052604081205412806129d857506000898152600260205260409020547f7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff906129d5908a90615c66565b11155b612a4a5760405162461bcd60e51b815260206004820152602660248201527f5456315f313a3a7072696e745469636b6574733a20494e545f4c494d49545f5260448201527f4541434845440000000000000000000000000000000000000000000000000000606482015260840161063e565b600089815260026020526040902054612a64908990615bf2565b60008a8152600260205260409081902091909155517fe0826c890000000000000000000000000000000000000000000000000000000081526001600160a01b038881166004830152602482018b9052604482018a905286151560648301527f000000000000000000000000ee2ebccb7cdb34a8a822b589f9e8427c24351bfc169063e0826c8990608401600060405180830381600087803b158015612b0857600080fd5b505af1158015612b1c573d6000803e3d6000fd5b50505050866001600160a01b0316897fb745c0ba548003047e8dc09b0dbf5eaed8ae262b5fe0221b4439af8cc40199058a8933604051612b5e939291906158e0565b60405180910390a3505050505050505050565b6040517efdd58e00000000000000000000000000000000000000000000000000000000815261dead6004820152602481018290526000907f000000000000000000000000ee2ebccb7cdb34a8a822b589f9e8427c24351bfc6001600160a01b03169062fdd58e9060440160206040518083038186803b158015612bf357600080fd5b505afa158015612c07573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612c2b9190615373565b905060008111612c7d5760405162461bcd60e51b815260206004820152601460248201527f30783030204e4f5448494e475f544f5f4255524e000000000000000000000000604482015260640161063e565b6040517f65e0d73100000000000000000000000000000000000000000000000000000000815261dead60048201526024810183905260448101829052600160648201527f000000000000000000000000ee2ebccb7cdb34a8a822b589f9e8427c24351bfc6001600160a01b0316906365e0d73190608401600060405180830381600087803b158015612d0e57600080fd5b505af1158015612d22573d6000803e3d6000fd5b505050505050565b6040517f43a266c20000000000000000000000000000000000000000000000000000000081526004810182905260009081906001600160a01b037f000000000000000000000000f507b2a1dd7439201eb07f11e1d62afb29216e2e16906343a266c2906024016102006040518083038186803b158015612da957600080fd5b505afa158015612dbd573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612de1919061543f565b8051909150612df35750600092915050565b6040517f75b0d9cd000000000000000000000000000000000000000000000000000000008152600481018490526000907f000000000000000000000000ee2ebccb7cdb34a8a822b589f9e8427c24351bfc6001600160a01b0316906375b0d9cd9060240160206040518083038186803b158015612e6f57600080fd5b505afa158015612e83573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612ea79190615373565b9050612ed360026000868152602001908152602001600020546008846101e00151901c60ff16836145c1565b92507f7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff612f008483615c66565b1115612f745760405162461bcd60e51b815260206004820152602e60248201527f5456315f313a3a7072696e7452657365727665645469636b6574733a20494e5460448201527f5f4c494d49545f52454143484544000000000000000000000000000000000000606482015260840161063e565b612f7e8382615c66565b6000858152600260205260408120919091558315612fa557612fa083856149d7565b612fa8565b60005b6040517f6352211e000000000000000000000000000000000000000000000000000000008152600481018790529091506000906001600160a01b037f0000000000000000000000009b5a4053ffbb11ca9cd858aaee43cc95ab4354181690636352211e9060240160206040518083038186803b15801561302757600080fd5b505afa15801561303b573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061305f9190614fbe565b90508115613111576040517fe0826c890000000000000000000000000000000000000000000000000000000081526001600160a01b0382811660048301526024820188905260448201849052600060648301527f000000000000000000000000ee2ebccb7cdb34a8a822b589f9e8427c24351bfc169063e0826c8990608401600060405180830381600087803b1580156130f857600080fd5b505af115801561310c573d6000803e3d6000fd5b505050505b83516040805187815260208101859052338183015290516001600160a01b03841692899290917f54ad84f37b2d6ff349b859f99f05bceaba2ee199cde3b63ae47c38f5d6116c0d9181900360600190a450505050919050565b6040517f43a266c20000000000000000000000000000000000000000000000000000000081526004810182905260009081906001600160a01b037f000000000000000000000000f507b2a1dd7439201eb07f11e1d62afb29216e2e16906343a266c2906024016102006040518083038186803b1580156131e957600080fd5b505afa1580156131fd573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613221919061543f565b9050611239816144ab565b6040517f6352211e000000000000000000000000000000000000000000000000000000008152600481018690526000907f0000000000000000000000009b5a4053ffbb11ca9cd858aaee43cc95ab4354186001600160a01b031690636352211e9060240160206040518083038186803b1580156132a857600080fd5b505afa1580156132bc573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906132e09190614fbe565b866001336001600160a01b03841614806133bb57506040517fc161c93f0000000000000000000000000000000000000000000000000000000081523360048201526001600160a01b03848116602483015260448201849052606482018390527f000000000000000000000000ab47304d987390e27ce3bc0fa4fe31e3a98b0db2169063c161c93f9060840160206040518083038186803b15801561338357600080fd5b505afa158015613397573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906133bb9190615356565b6134075760405162461bcd60e51b815260206004820152601860248201527f4f706572617461626c653a20554e415554484f52495a45440000000000000000604482015260640161063e565b600061341b61190e368a90038a018a6153ad565b905060007f000000000000000000000000f507b2a1dd7439201eb07f11e1d62afb29216e2e6001600160a01b0316638a1b0eb48c8c8560045460006040518663ffffffff1660e01b8152600401613476959493929190615912565b61020060405180830381600087803b15801561349157600080fd5b505af11580156134a5573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906134c9919061543f565b8851909150156135725760808101516040517fa67e210a0000000000000000000000000000000000000000000000000000000081526001600160a01b037f000000000000000000000000b9e4b658298c7a36bdf4c2832042a5d6700c3ab8169163a67e210a9161353f918f918d90600401615989565b600060405180830381600087803b15801561355957600080fd5b505af115801561356d573d6000803e3d6000fd5b505050505b8651156136185760808101516040517febe352a40000000000000000000000000000000000000000000000000000000081526001600160a01b037f000000000000000000000000b9e4b658298c7a36bdf4c2832042a5d6700c3ab8169163ebe352a4916135e5918f918c90600401615a35565b600060405180830381600087803b1580156135ff57600080fd5b505af1158015613613573d6000803e3d6000fd5b505050505b519a9950505050505050505050565b6001546001600160a01b031633146136815760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015260640161063e565b6001600160a01b0381166136fd5760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201527f6464726573730000000000000000000000000000000000000000000000000000606482015260840161063e565b6137068161496d565b50565b6040517f43a266c20000000000000000000000000000000000000000000000000000000081526004810186905260009081906001600160a01b037f000000000000000000000000f507b2a1dd7439201eb07f11e1d62afb29216e2e16906343a266c2906024016102006040518083038186803b15801561378857600080fd5b505afa15801561379c573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906137c0919061543f565b90506020816101e00151901c60011660001461381e5760405162461bcd60e51b815260206004820152601260248201527f5456315f313a3a7061793a205041555345440000000000000000000000000000604482015260640161063e565b60008160400151600014613836578160c001516138c7565b7f000000000000000000000000f507b2a1dd7439201eb07f11e1d62afb29216e2e6001600160a01b031663e16fd0ec6040518163ffffffff1660e01b815260040160206040518083038186803b15801561388f57600080fd5b505afa1580156138a3573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906138c79190615373565b905060006138d58883614c4f565b9050600083604001516000146138f7576008846101e00151901c60ff166138fa565b60005b9050600061390d836112128460c8615cf2565b60008c81526003602052604090205490915061392a908b90615c66565b60008c8152600360205260409020558015613ac2576040850151613a135760008b815260026020526040812054128061399d575060008b8152600260205260409020547f7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff9061399a908590615c66565b11155b6139e95760405162461bcd60e51b815260206004820152601c60248201527f5456315f313a3a70617920494e545f4c494d49545f5245414348454400000000604482015260640161063e565b60008b815260026020526040902054613a03908290615bf2565b60008c8152600260205260409020555b6040517fe0826c890000000000000000000000000000000000000000000000000000000081526001600160a01b038a81166004830152602482018d90526044820183905288151560648301527f000000000000000000000000ee2ebccb7cdb34a8a822b589f9e8427c24351bfc169063e0826c8990608401600060405180830381600087803b158015613aa557600080fd5b505af1158015613ab9573d6000803e3d6000fd5b50505050613bc3565b8215613bc35760008b8152600260205260408120541380613b27575060008b8152600260205260409020547f7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff908490613b1a90615d42565b613b249190615c66565b11155b613b995760405162461bcd60e51b815260206004820152602660248201527f5456315f313a3a7072696e745469636b6574733a20494e545f4c494d49545f5260448201527f4541434845440000000000000000000000000000000000000000000000000000606482015260840161063e565b60008b815260026020526040902054613bb3908490615c7e565b60008c8152600260205260409020555b886001600160a01b03168b86600001517fd595184f93e5de76e6c92bf66d279d827d0be8fad5cec3a420d86716e1a665328d85888e33604051613c0a959493929190615abc565b60405180910390a45050915198975050505050505050565b600061260483670de0b6b3a764000084614634565b6000613c4e8560c8613c498782615c66565b614634565b613c589086615cf2565b905080613c6757506000613f14565b6040517f4fe0eced0000000000000000000000000000000000000000000000000000000081526001600482015230906001600160a01b037f00000000000000000000000046c9999a2edcd5aa177ed7e8af90c68b7d75ba461690634fe0eced9060240160206040518083038186803b158015613ce257600080fd5b505afa158015613cf6573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613d1a9190614fbe565b6001600160a01b03161415613d3e57613d3860018285856000613709565b50613f14565b6040517f4fe0eced000000000000000000000000000000000000000000000000000000008152600160048201526000907f00000000000000000000000046c9999a2edcd5aa177ed7e8af90c68b7d75ba466001600160a01b031690634fe0eced9060240160206040518083038186803b158015613dba57600080fd5b505afa158015613dce573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613df29190614fbe565b90506001600160a01b038116613e705760405162461bcd60e51b815260206004820152602360248201527f5456315f313a3a5f74616b654665653a205445524d494e414c5f4e4f545f464f60448201527f554e440000000000000000000000000000000000000000000000000000000000606482015260840161063e565b6040517f02c8986f0000000000000000000000000000000000000000000000000000000081526001600160a01b038216906302c8986f908490613ebf906001908990899060009060040161581e565b6020604051808303818588803b158015613ed857600080fd5b505af1158015613eec573d6000803e3d6000fd5b50505050506040513d601f19601f82011682018060405250810190613f119190615373565b50505b949350505050565b602083015160808401516040517f7559aaaa0000000000000000000000000000000000000000000000000000000081526004810192909252602482015282906000907f000000000000000000000000b9e4b658298c7a36bdf4c2832042a5d6700c3ab86001600160a01b031690637559aaaa9060440160006040518083038186803b158015613faa57600080fd5b505afa158015613fbe573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052613fe6919081019061514b565b9050805160001415613ff85750611239565b60005b815181101561438457600082828151811061401857614018615e08565b60200260200101519050600061403987836020015161ffff16612710614634565b9050801561431e5760808201516001600160a01b0316156140fc576080820151602089015160a084015160608501516040517fec695ef7000000000000000000000000000000000000000000000000000000008152600481019390935266ffffffffffffff90911660248301526001600160a01b0390811660448301529091169063ec695ef79083906064016000604051808303818588803b1580156140de57600080fd5b505af11580156140f2573d6000803e3d6000fd5b505050505061431e565b60a082015166ffffffffffffff16156143105760a08201516040517f4fe0eced00000000000000000000000000000000000000000000000000000000815266ffffffffffffff90911660048201526000907f00000000000000000000000046c9999a2edcd5aa177ed7e8af90c68b7d75ba466001600160a01b031690634fe0eced9060240160206040518083038186803b15801561419957600080fd5b505afa1580156141ad573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906141d19190614fbe565b90506001600160a01b0381166142295760405162461bcd60e51b815260206004820152601360248201527f5456315f313a3a7461703a204241445f4d4f4400000000000000000000000000604482015260640161063e565b6001600160a01b0381163014156142625761425c8360a0015166ffffffffffffff168385606001518a8760000151613709565b5061430a565b60a0830151606084015184516040517f02c8986f0000000000000000000000000000000000000000000000000000000081526001600160a01b038516936302c8986f9387936142b6938e9190600401615afc565b6020604051808303818588803b1580156142cf57600080fd5b505af11580156142e3573d6000803e3d6000fd5b50505050506040513d601f19601f820116820180604052508101906143089190615373565b505b5061431e565b61431e82606001518261438d565b6143288186615cf2565b9450876020015188600001517fd37e528ac0cd9d9eeaa32903a436be474cce5651f7d3313a580ceacdae5cb34584843360405161436793929190615859565b60405180910390a35050808061437c90615d09565b915050613ffb565b50509392505050565b804710156143dd5760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a20696e73756666696369656e742062616c616e6365000000604482015260640161063e565b6000826001600160a01b03168260405160006040518083038185875af1925050503d806000811461442a576040519150601f19603f3d011682016040523d82523d6000602084013e61442f565b606091505b50509050806144a65760405162461bcd60e51b815260206004820152603a60248201527f416464726573733a20756e61626c6520746f2073656e642076616c75652c207260448201527f6563697069656e74206d61792068617665207265766572746564000000000000606482015260840161063e565b505050565b6000807f000000000000000000000000a9537cc42555564206d4e57c0eb6943d56e83a306001600160a01b0316639fa937238461016001516040518263ffffffff1660e01b815260040161450191815260200190565b60206040518083038186803b15801561451957600080fd5b505afa15801561452d573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906145519190615373565b90506000836101c0015184610140015161456b9190615cf2565b9050600081156145845761457f8284613c22565b614587565b60005b6020808701516000908152600390915260409020549091508181106145b5576145b08282615cf2565b6106e1565b60009695505050505050565b60008060008512156145e5576145d685615d42565b6145e09084615c66565b6145ef565b6145ef8584615cf2565b905080614600576000915050611239565b8360c81415614610579050611239565b806146218160c8613c498882615cf2565b61462b9190615cf2565b95945050505050565b600080807fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff858709858702925082811083820303915050806000141561468d5783828161468357614683615daa565b0492505050611239565b8381106146d0576040517f773cc18c000000000000000000000000000000000000000000000000000000008152600481018290526024810185905260440161063e565b60008486880960026001871981018816978890046003810283188082028403028082028403028082028403028082028403028082028403029081029092039091026000889003889004909101858311909403939093029303949094049190911702949350505050565b600060c8826000015111156147b65760405162461bcd60e51b815260206004820152603e60248201527f5456315f313a3a5f76616c6964617465416e645061636b46756e64696e67437960448201527f636c654d657461646174613a204241445f52455345525645445f524154450000606482015260840161063e565b60c8826020015111156148575760405162461bcd60e51b815260206004820152604360248201527f5456315f313a3a5f76616c6964617465416e645061636b46756e64696e67437960448201527f636c654d657461646174613a204241445f424f4e44494e475f43555256455f5260648201527f4154450000000000000000000000000000000000000000000000000000000000608482015260a40161063e565b60c8826040015111156148f85760405162461bcd60e51b815260206004820152605360248201527f5456315f313a3a5f76616c6964617465416e645061636b46756e64696e67437960448201527f636c654d657461646174613a204241445f5245434f4e46494755524154494f4e60648201527f5f424f4e44494e475f43555256455f5241544500000000000000000000000000608482015260a40161063e565b50805160208201516040830151606084015160189190911b60109290921b60089390931b9290921717600117901561493257640100000000175b81608001511561494457640200000000175b60a0919091015160221b7803fffffffffffffffffffffffffffffffffffffffc00000000161790565b600180546001600160a01b038381167fffffffffffffffffffffffff0000000000000000000000000000000000000000831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b602082015160808301516040517f4833b5120000000000000000000000000000000000000000000000000000000081526004810192909252602482015281906000907f000000000000000000000000b9e4b658298c7a36bdf4c2832042a5d6700c3ab86001600160a01b031690634833b5129060440160006040518083038186803b158015614a6557600080fd5b505afa158015614a79573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052614aa19190810190615262565b905060005b8151811015614c47576000828281518110614ac357614ac3615e08565b602002602001015190506000614ae486836020015161ffff16612710614634565b90508015614ba5576060820151602088015183516040517fe0826c890000000000000000000000000000000000000000000000000000000081526001600160a01b039384166004820152602481019290925260448201849052151560648201527f000000000000000000000000ee2ebccb7cdb34a8a822b589f9e8427c24351bfc9091169063e0826c8990608401600060405180830381600087803b158015614b8c57600080fd5b505af1158015614ba0573d6000803e3d6000fd5b505050505b614baf8186615cf2565b6020808901518951604080518751151581528785015161ffff16948101949094528087015165ffffffffffff16908401526060808701516001600160a01b031690840152608083018590523360a084015292975091907fe499491e3f5b7f35b5078102c27aa039bbde7ed027b91c996ac41e15d8f87d5c9060c00160405180910390a350508080614c3f90615d09565b915050614aa6565b505092915050565b60006126048383600080807fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff848609848602925082811083820303915050670de0b6b3a76400008110614cd1576040517fd31b34020000000000000000000000000000000000000000000000000000000081526004810182905260240161063e565b600080670de0b6b3a76400008688099150506706f05b59d3b1ffff811182614d0b5780670de0b6b3a7640000850401945050505050612607565b6204000082850304939091119091037d40000000000000000000000000000000000000000000000000000000000002919091177faccb18165bd6fe31ae1cf318dc5b51eee0e1ba569b88cd74c1773b91fac106690201905092915050565b600082601f830112614d7a57600080fd5b81356020614d8f614d8a83615bce565b615b9d565b8281528181019085830160c080860288018501891015614dae57600080fd5b6000805b87811015614e4c5782848c031215614dc8578182fd5b614dd0615b2d565b8435614ddb81615e7b565b815284880135614dea81615e89565b81890152604085810135614dfd81615e99565b90820152606085810135614e1081615e66565b90820152608085810135614e2381615e66565b9082015260a085810135614e3681615ead565b9082015286529486019492820192600101614db2565b50929998505050505050505050565b600082601f830112614e6c57600080fd5b81356020614e7c614d8a83615bce565b80838252828201915082860187848660071b8901011115614e9c57600080fd5b6000805b86811015614f1757608080848c031215614eb8578283fd5b614ec0615b56565b8435614ecb81615e7b565b815284880135614eda81615e89565b81890152604085810135614eed81615e99565b90820152606085810135614f0081615e66565b908201528652948601949290920191600101614ea0565b509198975050505050505050565b8035614f3081615e7b565b919050565b8051614f3081615e66565b60008083601f840112614f5257600080fd5b50813567ffffffffffffffff811115614f6a57600080fd5b602083019150836020828501011115614f8257600080fd5b9250929050565b600060c08284031215614f9b57600080fd5b50919050565b600060208284031215614fb357600080fd5b813561123981615e66565b600060208284031215614fd057600080fd5b815161123981615e66565b600080600080600080600080610220898b031215614ff857600080fd5b883561500381615e66565b975060208901359650604089013567ffffffffffffffff8082111561502757600080fd5b6150338c838d01614f40565b90985096508691506150488c60608d01614f89565b95506150588c6101208d01614f89565b94506101e08b013591508082111561506f57600080fd5b61507b8c838d01614d69565b93506102008b013591508082111561509257600080fd5b5061509f8b828c01614e5b565b9150509295985092959890939650565b6000806000606084860312156150c457600080fd5b83356150cf81615e66565b95602085013595506040909401359392505050565b60008060008060008060c087890312156150fd57600080fd5b863561510881615e66565b9550602087013594506040870135935060608701359250608087013561512d81615e66565b915060a087013561513d81615e7b565b809150509295509295509295565b6000602080838503121561515e57600080fd5b825167ffffffffffffffff81111561517557600080fd5b8301601f8101851361518657600080fd5b8051615194614d8a82615bce565b8181528381019083850160c0808502860187018a10156151b357600080fd5b60009550855b858110156152535781838c0312156151cf578687fd5b6151d7615b2d565b83516151e281615e7b565b8152838901516151f181615e89565b818a015260408481015161520481615e99565b9082015260608481015161521781615e66565b9082015260808481015161522a81615e66565b9082015260a08481015161523d81615ead565b90820152855293870193918101916001016151b9565b50919998505050505050505050565b6000602080838503121561527557600080fd5b825167ffffffffffffffff81111561528c57600080fd5b8301601f8101851361529d57600080fd5b80516152ab614d8a82615bce565b80828252848201915084840188868560071b87010111156152cb57600080fd5b60009450845b8481101561534857608080838c0312156152e9578687fd5b6152f1615b56565b83516152fc81615e7b565b81528389015161530b81615e89565b818a015260408481015161531e81615e99565b9082015260608481015161533181615e66565b9082015285529387019391909101906001016152d1565b509098975050505050505050565b60006020828403121561536857600080fd5b815161123981615e7b565b60006020828403121561538557600080fd5b5051919050565b60006020828403121561539e57600080fd5b81516004811061123957600080fd5b600060c082840312156153bf57600080fd5b60405160c0810181811067ffffffffffffffff821117156153e2576153e2615e37565b8060405250823581526020830135602082015260408301356040820152606083013561540d81615e7b565b6060820152608083013561542081615e7b565b608082015260a083013561543381615e66565b60a08201529392505050565b6000610200828403121561545257600080fd5b61545a615b79565b825181526020830151602082015260408301516040820152606083015160608201526080830151608082015260a083015160a082015260c083015160c08201526154a660e08401614f35565b60e0820152610100838101519082015261012080840151908201526101408084015190820152610160808401519082015261018080840151908201526101a080840151908201526101c080840151908201526101e0928301519281019290925250919050565b60006020828403121561551e57600080fd5b5035919050565b60008060008060006080868803121561553d57600080fd5b85359450602086013561554f81615e66565b9350604086013567ffffffffffffffff81111561556b57600080fd5b61557788828901614f40565b909450925050606086013561558b81615e7b565b809150509295509295909350565b600080604083850312156155ac57600080fd5b8235915060208301356155be81615e66565b809150509250929050565b60008060008060006101e086880312156155e257600080fd5b853594506155f38760208801614f89565b93506156028760e08801614f89565b92506101a086013567ffffffffffffffff8082111561562057600080fd5b61562c89838a01614d69565b93506101c088013591508082111561564357600080fd5b5061565088828901614e5b565b9150509295509295909350565b6000806040838503121561567057600080fd5b50508035926020909101359150565b600080600080600060a0868803121561569757600080fd5b85359450602080870135945060408701356156b181615e66565b9350606087013567ffffffffffffffff808211156156ce57600080fd5b818901915089601f8301126156e257600080fd5b8135818111156156f4576156f4615e37565b61570684601f19601f84011601615b9d565b91508082528a8482850101111561571c57600080fd5b808484018584013760008482840101525080945050505061573f60808701614f25565b90509295509295909350565b6000806000806080858703121561576157600080fd5b5050823594602084013594506040840135936060013592509050565b6000815180845260005b818110156157a357602081850181015186830182015201615787565b818111156157b5576000602083870101525b50601f01601f19169290920160200192915050565b60006001600160a01b03808816835286602084015260806040840152846080840152848660a0850137600060a0868501015260a0601f19601f87011684010191508084166060840152509695505050505050565b8481526001600160a01b0384166020820152608060408201526000615846608083018561577d565b9050821515606083015295945050505050565b61010081016158c3828680511515825261ffff602082015116602083015265ffffffffffff604082015116604083015260608101516001600160a01b038082166060850152806080840151166080850152505066ffffffffffffff60a08201511660a08301525050565b8360c08301526001600160a01b03831660e0830152949350505050565b8381526060602082015260006158f9606083018561577d565b90506001600160a01b0383166040830152949350505050565b60006101408201905086825285356020830152602086013560408301526040860135606083015260608601356080830152608086013560a083015260a086013561595b81615e66565b6001600160a01b031660c083015260e082019490945261010081019290925215156101209091015292915050565b6000606082018583526020858185015260606040850152818551808452608086019150828701935060005b8181101561534857615a2283865180511515825261ffff602082015116602083015265ffffffffffff604082015116604083015260608101516001600160a01b038082166060850152806080840151166080850152505066ffffffffffffff60a08201511660a08301525050565b9383019360c092909201916001016159b4565b600060608201858352602085818501526060604085015281855180845260809350838601915082870160005b8281101561525357615aac84835180511515825261ffff602082015116602083015265ffffffffffff60408201511660408301526001600160a01b0360608201511660608301525050565b9285019290840190600101615a61565b85815284602082015283604082015260a060608201526000615ae160a083018561577d565b90506001600160a01b03831660808301529695505050505050565b66ffffffffffffff851681526001600160a01b0384166020820152608060408201526000615846608083018561577d565b60405160c0810167ffffffffffffffff81118282101715615b5057615b50615e37565b60405290565b6040516080810167ffffffffffffffff81118282101715615b5057615b50615e37565b604051610200810167ffffffffffffffff81118282101715615b5057615b50615e37565b604051601f8201601f1916810167ffffffffffffffff81118282101715615bc657615bc6615e37565b604052919050565b600067ffffffffffffffff821115615be857615be8615e37565b5060051b60200190565b6000808212827f7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff03841381151615615c2c57615c2c615d7b565b827f8000000000000000000000000000000000000000000000000000000000000000038412811615615c6057615c60615d7b565b50500190565b60008219821115615c7957615c79615d7b565b500190565b6000808312837f800000000000000000000000000000000000000000000000000000000000000001831281151615615cb857615cb8615d7b565b837f7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff018313811615615cec57615cec615d7b565b50500390565b600082821015615d0457615d04615d7b565b500390565b60007fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff821415615d3b57615d3b615d7b565b5060010190565b60007f8000000000000000000000000000000000000000000000000000000000000000821415615d7457615d74615d7b565b5060000390565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052602160045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b6001600160a01b038116811461370657600080fd5b801515811461370657600080fd5b61ffff8116811461370657600080fd5b65ffffffffffff8116811461370657600080fd5b66ffffffffffffff8116811461370657600080fdfea2646970667358221220cee00c005eda902e3e3944b90b9665c0ae0c5171e6d0af961f2dfdadb5b5fb8764736f6c63430008060033
Constructor Arguments (ABI-Encoded and is the last bytes of the Contract Creation Code above)
0000000000000000000000009b5a4053ffbb11ca9cd858aaee43cc95ab435418000000000000000000000000f507b2a1dd7439201eb07f11e1d62afb29216e2e000000000000000000000000ee2ebccb7cdb34a8a822b589f9e8427c24351bfc000000000000000000000000ab47304d987390e27ce3bc0fa4fe31e3a98b0db2000000000000000000000000b9e4b658298c7a36bdf4c2832042a5d6700c3ab8000000000000000000000000a9537cc42555564206d4e57c0eb6943d56e83a3000000000000000000000000046c9999a2edcd5aa177ed7e8af90c68b7d75ba46000000000000000000000000af28bcb48c40dbc86f52d459a6562f658fc94b1e
-----Decoded View---------------
Arg [0] : _projects (address): 0x9b5a4053FfBB11cA9cd858AAEE43cc95ab435418
Arg [1] : _fundingCycles (address): 0xf507B2A1dD7439201eb07F11E1d62AfB29216e2E
Arg [2] : _ticketBooth (address): 0xee2eBCcB7CDb34a8A822b589F9E8427C24351bfc
Arg [3] : _operatorStore (address): 0xab47304D987390E27Ce3BC0fA4Fe31E3A98B0db2
Arg [4] : _modStore (address): 0xB9E4B658298C7A36BdF4C2832042A5D6700c3Ab8
Arg [5] : _prices (address): 0xa9537Cc42555564206D4E57c0eb6943d56E83A30
Arg [6] : _terminalDirectory (address): 0x46C9999A2EDCD5aA177ed7E8af90c68b7d75Ba46
Arg [7] : _owner (address): 0xAF28bcB48C40dBC86f52D459A6562F658fc94B1e
-----Encoded View---------------
8 Constructor Arguments found :
Arg [0] : 0000000000000000000000009b5a4053ffbb11ca9cd858aaee43cc95ab435418
Arg [1] : 000000000000000000000000f507b2a1dd7439201eb07f11e1d62afb29216e2e
Arg [2] : 000000000000000000000000ee2ebccb7cdb34a8a822b589f9e8427c24351bfc
Arg [3] : 000000000000000000000000ab47304d987390e27ce3bc0fa4fe31e3a98b0db2
Arg [4] : 000000000000000000000000b9e4b658298c7a36bdf4c2832042a5d6700c3ab8
Arg [5] : 000000000000000000000000a9537cc42555564206d4e57c0eb6943d56e83a30
Arg [6] : 00000000000000000000000046c9999a2edcd5aa177ed7e8af90c68b7d75ba46
Arg [7] : 000000000000000000000000af28bcb48c40dbc86f52d459a6562f658fc94b1e
Loading...
Loading
Loading...
Loading
Loading...
Loading
[ Download: CSV Export ]
[ 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.