Warning! Contract bytecode has been changed and doesn't match the verified one. Therefore, interaction with this smart contract may be risky.
This contract has been verified via Sourcify.
View contract in Sourcify repository
- Contract name:
- VoucherKernel
- Optimization enabled
- true
- Compiler version
- v0.7.6+commit.7338295f
- Optimization runs
- 200
- EVM Version
- istanbul
- Verified at
- 2026-06-08T06:12:29.070484Z
Constructor Arguments
4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65720000000000000000000000000a393aef6dbcd7e7088acf323f9d28b093b9ab5a000000000000000000000000244154f58e9bf6c15c3a09846efb7becfe92a880000000000000000000000000cf6d79e65c49a93a42dd8c474b46998eea4adec8000000000000000000000000de41a99562ada9ee04d9750c99a91c1181ebd875
Arg [0] (address) : 0x6c6572206973206e6f7420746865206f776e6572
Arg [1] (address) : 0x0a393aef6dbcd7e7088acf323f9d28b093b9ab5a
Arg [2] (address) : 0x244154f58e9bf6c15c3a09846efb7becfe92a880
Arg [3] (address) : 0xcf6d79e65c49a93a42dd8c474b46998eea4adec8
contracts/VoucherKernel.sol
// SPDX-License-Identifier: LGPL-3.0-or-later
pragma solidity 0.7.6;
import "@openzeppelin/contracts/utils/ReentrancyGuard.sol";
import "@openzeppelin/contracts/utils/Address.sol";
import "@openzeppelin/contracts/access/Ownable.sol";
import "@openzeppelin/contracts/utils/Pausable.sol";
import "@openzeppelin/contracts/math/SafeMath.sol";
import "@openzeppelin/contracts/token/ERC721/IERC721Receiver.sol";
import "./interfaces/IVoucherSets.sol";
import "./interfaces/IVouchers.sol";
import "./interfaces/IVoucherKernel.sol";
import {Entity, PaymentMethod, VoucherState, VoucherStatus, isStateCommitted, isStateRedemptionSigned, isStateRefunded, isStateExpired, isStatus, determineStatus} from "./UsingHelpers.sol";
/**
* @title VoucherKernel contract controls the core business logic
* @dev Notes:
* - The usage of block.timestamp is honored since vouchers are defined currently with day-precision.
* See: https://ethereum.stackexchange.com/questions/5924/how-do-ethereum-mining-nodes-maintain-a-time-consistent-with-the-network/5931#5931
*/
// solhint-disable-next-line
contract VoucherKernel is IVoucherKernel, Ownable, Pausable, ReentrancyGuard {
using Address for address;
using SafeMath for uint256;
//constant for setting complain and cancel periods
uint256 internal constant WEEK = 7 * 1 days;
//ERC1155 contract representing voucher sets
address private voucherSetTokenAddress;
//ERC721 contract representing vouchers;
address private voucherTokenAddress;
//promise for an asset could be reusable, but simplified here for brevity
struct Promise {
bytes32 promiseId;
uint256 nonce; //the asset that is offered
address seller; //the seller who created the promise
//we simplify the value for the demoapp, otherwise voucher details would be packed in one bytes32 field value
uint256 validFrom;
uint256 validTo;
uint256 price;
uint256 depositSe;
uint256 depositBu;
uint256 idx;
}
struct VoucherPaymentMethod {
PaymentMethod paymentMethod;
address addressTokenPrice;
address addressTokenDeposits;
}
address private bosonRouterAddress; //address of the Boson Router contract
address private cashierAddress; //address of the Cashier contract
mapping(bytes32 => Promise) private promises; //promises to deliver goods or services
mapping(address => uint256) private tokenNonces; //mapping between seller address and its own nonces. Every time seller creates supply ID it gets incremented. Used to avoid duplicate ID's
mapping(uint256 => VoucherPaymentMethod) private paymentDetails; // tokenSupplyId to VoucherPaymentMethod
bytes32[] private promiseKeys;
mapping(uint256 => bytes32) private ordersPromise; //mapping between an order (supply a.k.a. VoucherSet) and a promise
mapping(uint256 => VoucherStatus) private vouchersStatus; //recording the vouchers evolution
//ID reqs
mapping(uint256 => uint256) private typeCounters; //counter for ID of a particular type of NFT
uint256 private constant MASK_TYPE = uint256(type(uint128).max) << 128; //the type mask in the upper 128 bits
//1111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
uint256 private constant MASK_NF_INDEX = type(uint128).max; //the non-fungible index mask in the lower 128
//0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000011111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111
uint256 private constant TYPE_NF_BIT = 1 << 255; //the first bit represents an NFT type
//1000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
uint256 private typeId; //base token type ... 127-bits cover 1.701411835*10^38 types (not differentiating between FTs and NFTs)
/* Token IDs:
Fungibles: 0, followed by 127-bit FT type ID, in the upper 128 bits, followed by 0 in lower 128-bits
<0><uint127: base token id><uint128: 0>
Non-fungible VoucherSets (supply tokens): 1, followed by 127-bit NFT type ID, in the upper 128 bits, followed by 0 in lower 128-bits
<1><uint127: base token id><uint128: 0
Non-fungible vouchers: 1, followed by 127-bit NFT type ID, in the upper 128 bits, followed by a 1-based index of an NFT token ID.
<1><uint127: base token id><uint128: index of non-fungible>
*/
uint256 private complainPeriod;
uint256 private cancelFaultPeriod;
event LogPromiseCreated(
bytes32 indexed _promiseId,
uint256 indexed _nonce,
address indexed _seller,
uint256 _validFrom,
uint256 _validTo,
uint256 _idx
);
event LogVoucherCommitted(
uint256 indexed _tokenIdSupply,
uint256 _tokenIdVoucher,
address _issuer,
address _holder,
bytes32 _promiseId
);
event LogVoucherRedeemed(
uint256 _tokenIdVoucher,
address _holder,
bytes32 _promiseId
);
event LogVoucherRefunded(uint256 _tokenIdVoucher);
event LogVoucherComplain(uint256 _tokenIdVoucher);
event LogVoucherFaultCancel(uint256 _tokenIdVoucher);
event LogExpirationTriggered(uint256 _tokenIdVoucher, address _triggeredBy);
event LogFinalizeVoucher(uint256 _tokenIdVoucher, address _triggeredBy);
event LogBosonRouterSet(address _newBosonRouter, address _triggeredBy);
event LogCashierSet(address _newCashier, address _triggeredBy);
event LogVoucherTokenContractSet(address _newTokenContract, address _triggeredBy);
event LogVoucherSetTokenContractSet(address _newTokenContract, address _triggeredBy);
event LogComplainPeriodChanged(
uint256 _newComplainPeriod,
address _triggeredBy
);
event LogCancelFaultPeriodChanged(
uint256 _newCancelFaultPeriod,
address _triggeredBy
);
event LogVoucherSetFaultCancel(uint256 _tokenIdSupply, address _issuer);
event LogFundsReleased(
uint256 _tokenIdVoucher,
uint8 _type //0 .. payment, 1 .. deposits
);
/**
* @notice Checks that only the BosonRouter contract can call a function
*/
modifier onlyFromRouter() {
require(msg.sender == bosonRouterAddress, "UNAUTHORIZED_BR");
_;
}
/**
* @notice Checks that only the Cashier contract can call a function
*/
modifier onlyFromCashier() {
require(msg.sender == cashierAddress, "UNAUTHORIZED_C");
_;
}
/**
* @notice Checks that only the owver of the specified voucher can call a function
*/
modifier onlyVoucherOwner(uint256 _tokenIdVoucher, address _sender) {
//check authorization
require(
IVouchers(voucherTokenAddress).ownerOf(_tokenIdVoucher) == _sender,
"UNAUTHORIZED_V"
);
_;
}
modifier notZeroAddress(address _addressToCheck) {
require(_addressToCheck != address(0), "0A");
_;
}
/**
* @notice Construct and initialze the contract. Iniialises associated contract addresses, the complain period, and the cancel or fault period
* @param _bosonRouterAddress address of the associated BosonRouter contract
* @param _cashierAddress address of the associated Cashier contract
* @param _voucherSetTokenAddress address of the associated ERC1155 contract instance
* @param _voucherTokenAddress address of the associated ERC721 contract instance
*/
constructor(address _bosonRouterAddress, address _cashierAddress, address _voucherSetTokenAddress, address _voucherTokenAddress)
notZeroAddress(_bosonRouterAddress)
notZeroAddress(_cashierAddress)
notZeroAddress(_voucherSetTokenAddress)
notZeroAddress(_voucherTokenAddress)
{
bosonRouterAddress = _bosonRouterAddress;
cashierAddress = _cashierAddress;
voucherSetTokenAddress = _voucherSetTokenAddress;
voucherTokenAddress = _voucherTokenAddress;
emit LogBosonRouterSet(_bosonRouterAddress, msg.sender);
emit LogCashierSet(_cashierAddress, msg.sender);
emit LogVoucherSetTokenContractSet(_voucherSetTokenAddress, msg.sender);
emit LogVoucherTokenContractSet(_voucherTokenAddress, msg.sender);
setComplainPeriod(WEEK);
setCancelFaultPeriod(WEEK);
}
/**
* @notice Pause the process of interaction with voucherID's (ERC-721), in case of emergency.
* Only BR contract is in control of this function.
*/
function pause() external override onlyFromRouter {
_pause();
}
/**
* @notice Unpause the process of interaction with voucherID's (ERC-721).
* Only BR contract is in control of this function.
*/
function unpause() external override onlyFromRouter {
_unpause();
}
/**
* @notice Creating a new promise for goods or services.
* Can be reused, e.g. for making different batches of these (in the future).
* @param _seller seller of the promise
* @param _validFrom Start of valid period
* @param _validTo End of valid period
* @param _price Price (payment amount)
* @param _depositSe Seller's deposit
* @param _depositBu Buyer's deposit
*/
function createTokenSupplyId(
address _seller,
uint256 _validFrom,
uint256 _validTo,
uint256 _price,
uint256 _depositSe,
uint256 _depositBu,
uint256 _quantity
)
external
override
nonReentrant
onlyFromRouter
returns (uint256) {
require(_quantity > 0, "INVALID_QUANTITY");
// solhint-disable-next-line not-rely-on-time
require(_validTo >= block.timestamp + 5 minutes, "INVALID_VALIDITY_TO");
require(_validTo >= _validFrom.add(5 minutes), "VALID_FROM_MUST_BE_AT_LEAST_5_MINUTES_LESS_THAN_VALID_TO");
bytes32 key;
key = keccak256(
abi.encodePacked(_seller, tokenNonces[_seller]++, _validFrom, _validTo, address(this))
);
if (promiseKeys.length > 0) {
require(
promiseKeys[promises[key].idx] != key,
"PROMISE_ALREADY_EXISTS"
);
}
promises[key] = Promise({
promiseId: key,
nonce: tokenNonces[_seller],
seller: _seller,
validFrom: _validFrom,
validTo: _validTo,
price: _price,
depositSe: _depositSe,
depositBu: _depositBu,
idx: promiseKeys.length
});
promiseKeys.push(key);
emit LogPromiseCreated(
key,
tokenNonces[_seller],
_seller,
_validFrom,
_validTo,
promiseKeys.length - 1
);
return createOrder(_seller, key, _quantity);
}
/**
* @notice Creates a Payment method struct recording the details on how the seller requires to receive Price and Deposits for a certain Voucher Set.
* @param _tokenIdSupply _tokenIdSupply of the voucher set this is related to
* @param _paymentMethod might be ETHETH, ETHTKN, TKNETH or TKNTKN
* @param _tokenPrice token address which will hold the funds for the price of the voucher
* @param _tokenDeposits token address which will hold the funds for the deposits of the voucher
*/
function createPaymentMethod(
uint256 _tokenIdSupply,
PaymentMethod _paymentMethod,
address _tokenPrice,
address _tokenDeposits
) external override onlyFromRouter {
paymentDetails[_tokenIdSupply] = VoucherPaymentMethod({
paymentMethod: _paymentMethod,
addressTokenPrice: _tokenPrice,
addressTokenDeposits: _tokenDeposits
});
}
/**
* @notice Create an order for offering a certain quantity of an asset
* This creates a listing in a marketplace, technically as an ERC-1155 non-fungible token with supply.
* @param _seller seller of the promise
* @param _promiseId ID of a promise (simplified into asset for demo)
* @param _quantity Quantity of assets on offer
*/
function createOrder(
address _seller,
bytes32 _promiseId,
uint256 _quantity
) private returns (uint256) {
//create & assign a new non-fungible type
typeId++;
uint256 tokenIdSupply = TYPE_NF_BIT | (typeId << 128); //upper bit is 1, followed by sequence, leaving lower 128-bits as 0;
ordersPromise[tokenIdSupply] = _promiseId;
IVoucherSets(voucherSetTokenAddress).mint(
_seller,
tokenIdSupply,
_quantity,
""
);
return tokenIdSupply;
}
/**
* @notice Fill Voucher Order, iff funds paid, then extract & mint NFT to the voucher holder
* @param _tokenIdSupply ID of the supply token (ERC-1155)
* @param _issuer Address of the token's issuer
* @param _holder Address of the recipient of the voucher (ERC-721)
* @param _paymentMethod method being used for that particular order that needs to be fulfilled
*/
function fillOrder(
uint256 _tokenIdSupply,
address _issuer,
address _holder,
PaymentMethod _paymentMethod
)
external
override
onlyFromRouter
nonReentrant
{
require(_doERC721HolderCheck(_issuer, _holder, _tokenIdSupply), "UNSUPPORTED_ERC721_RECEIVED");
PaymentMethod paymentMethod = getVoucherPaymentMethod(_tokenIdSupply);
//checks
require(paymentMethod == _paymentMethod, "Incorrect Payment Method");
checkOrderFillable(_tokenIdSupply, _issuer, _holder);
//close order
uint256 voucherTokenId = extract721(_issuer, _holder, _tokenIdSupply);
emit LogVoucherCommitted(
_tokenIdSupply,
voucherTokenId,
_issuer,
_holder,
getPromiseIdFromVoucherId(voucherTokenId)
);
}
/**
* @notice Check if holder is a contract that supports ERC721
* @dev ERC-721
* https://github.com/OpenZeppelin/openzeppelin-contracts/blob/v4.4.0-rc.0/contracts/token/ERC721/ERC721.sol
* @param _from Address of sender
* @param _to Address of recipient
* @param _tokenId ID of the token
*/
function _doERC721HolderCheck(
address _from,
address _to,
uint256 _tokenId
) internal returns (bool) {
if (_to.isContract()) {
try IERC721Receiver(_to).onERC721Received(_msgSender(), _from, _tokenId, "") returns (bytes4 retval) {
return retval == IERC721Receiver.onERC721Received.selector;
} catch (bytes memory reason) {
if (reason.length == 0) {
revert("UNSUPPORTED_ERC721_RECEIVED");
} else {
assembly {
revert(add(32, reason), mload(reason))
}
}
}
} else {
return true;
}
}
/**
* @notice Check order is fillable
* @dev Will throw if checks don't pass
* @param _tokenIdSupply ID of the supply token
* @param _issuer Address of the token's issuer
* @param _holder Address of the recipient of the voucher (ERC-721)
*/
function checkOrderFillable(
uint256 _tokenIdSupply,
address _issuer,
address _holder
) internal view notZeroAddress(_holder) {
require(_tokenIdSupply != 0, "UNSPECIFIED_ID");
require(
IVoucherSets(voucherSetTokenAddress).balanceOf(_issuer, _tokenIdSupply) > 0,
"OFFER_EMPTY"
);
bytes32 promiseKey = ordersPromise[_tokenIdSupply];
require(
promises[promiseKey].validTo >= block.timestamp,
"OFFER_EXPIRED"
);
}
/**
* @notice Extract a standard non-fungible token ERC-721 from a supply stored in ERC-1155
* @dev Token ID is derived following the same principles for both ERC-1155 and ERC-721
* @param _issuer The address of the token issuer
* @param _to The address of the token holder
* @param _tokenIdSupply ID of the token type
* @return ID of the voucher token
*/
function extract721(
address _issuer,
address _to,
uint256 _tokenIdSupply
) internal returns (uint256) {
IVoucherSets(voucherSetTokenAddress).burn(_issuer, _tokenIdSupply, 1); // This is hardcoded as 1 on purpose
//calculate tokenId
uint256 voucherTokenId =
_tokenIdSupply | ++typeCounters[_tokenIdSupply];
//set status
vouchersStatus[voucherTokenId].status = determineStatus(
vouchersStatus[voucherTokenId].status,
VoucherState.COMMIT
);
vouchersStatus[voucherTokenId].isPaymentReleased = false;
vouchersStatus[voucherTokenId].isDepositsReleased = false;
vouchersStatus[voucherTokenId].seller = getSupplyHolder(_tokenIdSupply);
//mint voucher NFT as ERC-721
IVouchers(voucherTokenAddress).mint(_to, voucherTokenId);
return voucherTokenId;
}
/* solhint-disable */
/**
* @notice Redemption of the vouchers promise
* @param _tokenIdVoucher ID of the voucher
* @param _messageSender account that called the fn from the BR contract
*/
function redeem(uint256 _tokenIdVoucher, address _messageSender)
external
override
whenNotPaused
onlyFromRouter
onlyVoucherOwner(_tokenIdVoucher, _messageSender)
{
//check status
require(
isStateCommitted(vouchersStatus[_tokenIdVoucher].status),
"ALREADY_PROCESSED"
);
//check validity period
isInValidityPeriod(_tokenIdVoucher);
Promise memory tPromise =
promises[getPromiseIdFromVoucherId(_tokenIdVoucher)];
vouchersStatus[_tokenIdVoucher].complainPeriodStart = block.timestamp;
vouchersStatus[_tokenIdVoucher].status = determineStatus(
vouchersStatus[_tokenIdVoucher].status,
VoucherState.REDEEM
);
emit LogVoucherRedeemed(
_tokenIdVoucher,
_messageSender,
tPromise.promiseId
);
}
// // // // // // // //
// UNHAPPY PATH
// // // // // // // //
/**
* @notice Refunding a voucher
* @param _tokenIdVoucher ID of the voucher
* @param _messageSender account that called the fn from the BR contract
*/
function refund(uint256 _tokenIdVoucher, address _messageSender)
external
override
whenNotPaused
onlyFromRouter
onlyVoucherOwner(_tokenIdVoucher, _messageSender)
{
require(
isStateCommitted(vouchersStatus[_tokenIdVoucher].status),
"INAPPLICABLE_STATUS"
);
//check validity period
isInValidityPeriod(_tokenIdVoucher);
vouchersStatus[_tokenIdVoucher].complainPeriodStart = block.timestamp;
vouchersStatus[_tokenIdVoucher].status = determineStatus(
vouchersStatus[_tokenIdVoucher].status,
VoucherState.REFUND
);
emit LogVoucherRefunded(_tokenIdVoucher);
}
/**
* @notice Issue a complaint for a voucher
* @param _tokenIdVoucher ID of the voucher
* @param _messageSender account that called the fn from the BR contract
*/
function complain(uint256 _tokenIdVoucher, address _messageSender)
external
override
whenNotPaused
onlyFromRouter
onlyVoucherOwner(_tokenIdVoucher, _messageSender)
{
checkIfApplicableAndResetPeriod(_tokenIdVoucher, VoucherState.COMPLAIN);
}
/**
* @notice Cancel/Fault transaction by the Seller, admitting to a fault or backing out of the deal
* @param _tokenIdVoucher ID of the voucher
* @param _messageSender account that called the fn from the BR contract
*/
function cancelOrFault(uint256 _tokenIdVoucher, address _messageSender)
external
override
onlyFromRouter
whenNotPaused
{
require(
vouchersStatus[_tokenIdVoucher].seller ==_messageSender,
"UNAUTHORIZED_COF"
);
checkIfApplicableAndResetPeriod(_tokenIdVoucher, VoucherState.CANCEL_FAULT);
}
/**
* @notice Check if voucher status can be changed into desired new status. If yes, the waiting period is resetted, depending on what new status is.
* @param _tokenIdVoucher ID of the voucher
* @param _newStatus desired new status, can be {COF, COMPLAIN}
*/
function checkIfApplicableAndResetPeriod(uint256 _tokenIdVoucher, VoucherState _newStatus)
internal
{
uint8 tStatus = vouchersStatus[_tokenIdVoucher].status;
require(
!isStatus(tStatus, VoucherState.FINAL),
"ALREADY_FINALIZED"
);
string memory revertReasonAlready;
string memory revertReasonExpired;
if (_newStatus == VoucherState.COMPLAIN) {
revertReasonAlready = "ALREADY_COMPLAINED";
revertReasonExpired = "COMPLAINPERIOD_EXPIRED";
} else {
revertReasonAlready = "ALREADY_CANCELFAULT";
revertReasonExpired = "COFPERIOD_EXPIRED";
}
require(
!isStatus(tStatus, _newStatus),
revertReasonAlready
);
Promise memory tPromise =
promises[getPromiseIdFromVoucherId(_tokenIdVoucher)];
if (
isStateRedemptionSigned(tStatus) ||
isStateRefunded(tStatus)
) {
require(
block.timestamp <=
vouchersStatus[_tokenIdVoucher].complainPeriodStart +
complainPeriod +
cancelFaultPeriod,
revertReasonExpired
);
} else if (isStateExpired(tStatus)) {
//if redeemed or refunded
require(
block.timestamp <=
tPromise.validTo + complainPeriod + cancelFaultPeriod,
revertReasonExpired
);
} else if (
//if the opposite of what is the desired new state. When doing COMPLAIN we need to check if already in COF (and vice versa), since the waiting periods are different.
// VoucherState.COMPLAIN has enum index value 2, while VoucherState.CANCEL_FAULT has enum index value 1. To check the opposite status we use transformation "% 2 + 1" which maps 2 to 1 and 1 to 2
isStatus(vouchersStatus[_tokenIdVoucher].status, VoucherState((uint8(_newStatus) % 2 + 1))) // making it VoucherState.COMPLAIN or VoucherState.CANCEL_FAULT (opposite to new status)
) {
uint256 waitPeriod = _newStatus == VoucherState.COMPLAIN ? vouchersStatus[_tokenIdVoucher].complainPeriodStart +
complainPeriod : vouchersStatus[_tokenIdVoucher].cancelFaultPeriodStart + cancelFaultPeriod;
require(
block.timestamp <= waitPeriod,
revertReasonExpired
);
} else if (_newStatus != VoucherState.COMPLAIN && isStateCommitted(tStatus)) {
//if committed only (applicable only in COF)
require(
block.timestamp <=
tPromise.validTo + complainPeriod + cancelFaultPeriod,
"COFPERIOD_EXPIRED"
);
} else {
revert("INAPPLICABLE_STATUS");
}
vouchersStatus[_tokenIdVoucher].status = determineStatus(
tStatus,
_newStatus
);
if (_newStatus == VoucherState.COMPLAIN) {
if (!isStatus(tStatus, VoucherState.CANCEL_FAULT)) {
vouchersStatus[_tokenIdVoucher].cancelFaultPeriodStart = block
.timestamp; //COF period starts
}
emit LogVoucherComplain(_tokenIdVoucher);
} else {
if (!isStatus(tStatus, VoucherState.COMPLAIN)) {
vouchersStatus[_tokenIdVoucher].complainPeriodStart = block
.timestamp; //complain period starts
}
emit LogVoucherFaultCancel(_tokenIdVoucher);
}
}
/**
* @notice Cancel/Fault transaction by the Seller, cancelling the remaining uncommitted voucher set so that seller prevents buyers from committing to vouchers for items no longer in exchange.
* @param _tokenIdSupply ID of the voucher set
* @param _issuer owner of the voucher
*/
function cancelOrFaultVoucherSet(uint256 _tokenIdSupply, address _issuer)
external
override
onlyFromRouter
nonReentrant
whenNotPaused
returns (uint256)
{
require(getSupplyHolder(_tokenIdSupply) == _issuer, "UNAUTHORIZED_COF");
uint256 remQty = getRemQtyForSupply(_tokenIdSupply, _issuer);
require(remQty > 0, "OFFER_EMPTY");
IVoucherSets(voucherSetTokenAddress).burn(_issuer, _tokenIdSupply, remQty);
emit LogVoucherSetFaultCancel(_tokenIdSupply, _issuer);
return remQty;
}
// // // // // // // //
// BACK-END PROCESS
// // // // // // // //
/**
* @notice Mark voucher token that the payment was released
* @param _tokenIdVoucher ID of the voucher token
*/
function setPaymentReleased(uint256 _tokenIdVoucher)
external
override
onlyFromCashier
{
require(_tokenIdVoucher != 0, "UNSPECIFIED_ID");
vouchersStatus[_tokenIdVoucher].isPaymentReleased = true;
emit LogFundsReleased(_tokenIdVoucher, 0);
}
/**
* @notice Mark voucher token that the deposits were released
* @dev Currently Cashier makes a check that _amount > 0. If onlyFromCashier is ever removed, this function should check that _amount > 0
* @param _tokenIdVoucher ID of the voucher token
* @param _to recipient, one of {ISSUER, HOLDER, POOL}
* @param _amount amount that was released in the transaction
*/
function setDepositsReleased(uint256 _tokenIdVoucher, Entity _to, uint256 _amount)
external
override
onlyFromCashier
{
require(_tokenIdVoucher != 0, "UNSPECIFIED_ID");
vouchersStatus[_tokenIdVoucher].depositReleased.status |= (ONE << uint8(_to));
vouchersStatus[_tokenIdVoucher].depositReleased.releasedAmount = uint248(uint256(vouchersStatus[_tokenIdVoucher].depositReleased.releasedAmount).add(_amount));
if (vouchersStatus[_tokenIdVoucher].depositReleased.releasedAmount == getTotalDepositsForVoucher(_tokenIdVoucher)) {
vouchersStatus[_tokenIdVoucher].isDepositsReleased = true;
emit LogFundsReleased(_tokenIdVoucher, 1);
}
}
/**
* @notice Tells if part of the deposit, belonging to entity, was released already
* @param _tokenIdVoucher ID of the voucher token
* @param _to recipient, one of {ISSUER, HOLDER, POOL}
*/
function isDepositReleased(uint256 _tokenIdVoucher, Entity _to) external view override returns (bool){
return (vouchersStatus[_tokenIdVoucher].depositReleased.status >> uint8(_to)) & ONE == 1;
}
/**
* @notice Mark voucher token as expired
* @param _tokenIdVoucher ID of the voucher token
*/
function triggerExpiration(uint256 _tokenIdVoucher) external override {
require(_tokenIdVoucher != 0, "UNSPECIFIED_ID");
Promise memory tPromise =
promises[getPromiseIdFromVoucherId(_tokenIdVoucher)];
require(tPromise.validTo < block.timestamp && isStateCommitted(vouchersStatus[_tokenIdVoucher].status),'INAPPLICABLE_STATUS');
vouchersStatus[_tokenIdVoucher].status = determineStatus(
vouchersStatus[_tokenIdVoucher].status,
VoucherState.EXPIRE
);
emit LogExpirationTriggered(_tokenIdVoucher, msg.sender);
}
/**
* @notice Mark voucher token to the final status
* @param _tokenIdVoucher ID of the voucher token
*/
function triggerFinalizeVoucher(uint256 _tokenIdVoucher) external override {
require(_tokenIdVoucher != 0, "UNSPECIFIED_ID");
uint8 tStatus = vouchersStatus[_tokenIdVoucher].status;
require(!isStatus(tStatus, VoucherState.FINAL), "ALREADY_FINALIZED");
bool mark;
Promise memory tPromise =
promises[getPromiseIdFromVoucherId(_tokenIdVoucher)];
if (isStatus(tStatus, VoucherState.COMPLAIN)) {
if (isStatus(tStatus, VoucherState.CANCEL_FAULT)) {
//if COMPLAIN && COF: then final
mark = true;
} else if (
block.timestamp >=
vouchersStatus[_tokenIdVoucher].cancelFaultPeriodStart +
cancelFaultPeriod
) {
//if COMPLAIN: then final after cof period
mark = true;
}
} else if (
isStatus(tStatus, VoucherState.CANCEL_FAULT) &&
block.timestamp >=
vouchersStatus[_tokenIdVoucher].complainPeriodStart + complainPeriod
) {
//if COF: then final after complain period
mark = true;
} else if (
isStateRedemptionSigned(tStatus) || isStateRefunded(tStatus)
) {
//if RDM/RFND NON_COMPLAIN: then final after complainPeriodStart + complainPeriod
if (
block.timestamp >=
vouchersStatus[_tokenIdVoucher].complainPeriodStart +
complainPeriod
) {
mark = true;
}
} else if (isStateExpired(tStatus)) {
//if EXP NON_COMPLAIN: then final after validTo + complainPeriod
if (block.timestamp >= tPromise.validTo + complainPeriod) {
mark = true;
}
}
require(mark, 'INAPPLICABLE_STATUS');
vouchersStatus[_tokenIdVoucher].status = determineStatus(
tStatus,
VoucherState.FINAL
);
emit LogFinalizeVoucher(_tokenIdVoucher, msg.sender);
}
/* solhint-enable */
// // // // // // // //
// UTILS
// // // // // // // //
/**
* @notice Set the address of the new holder of a _tokenIdSupply on transfer
* @param _tokenIdSupply _tokenIdSupply which will be transferred
* @param _newSeller new holder of the supply
*/
function setSupplyHolderOnTransfer(
uint256 _tokenIdSupply,
address _newSeller
) external override onlyFromCashier {
bytes32 promiseKey = ordersPromise[_tokenIdSupply];
promises[promiseKey].seller = _newSeller;
}
/**
* @notice Set the address of the Boson Router contract
* @param _bosonRouterAddress The address of the BR contract
*/
function setBosonRouterAddress(address _bosonRouterAddress)
external
override
onlyOwner
whenPaused
notZeroAddress(_bosonRouterAddress)
{
bosonRouterAddress = _bosonRouterAddress;
emit LogBosonRouterSet(_bosonRouterAddress, msg.sender);
}
/**
* @notice Set the address of the Cashier contract
* @param _cashierAddress The address of the Cashier contract
*/
function setCashierAddress(address _cashierAddress)
external
override
onlyOwner
whenPaused
notZeroAddress(_cashierAddress)
{
cashierAddress = _cashierAddress;
emit LogCashierSet(_cashierAddress, msg.sender);
}
/**
* @notice Set the address of the Vouchers token contract, an ERC721 contract
* @param _voucherTokenAddress The address of the Vouchers token contract
*/
function setVoucherTokenAddress(address _voucherTokenAddress)
external
override
onlyOwner
notZeroAddress(_voucherTokenAddress)
whenPaused
{
voucherTokenAddress = _voucherTokenAddress;
emit LogVoucherTokenContractSet(_voucherTokenAddress, msg.sender);
}
/**
* @notice Set the address of the Voucher Sets token contract, an ERC1155 contract
* @param _voucherSetTokenAddress The address of the Vouchers token contract
*/
function setVoucherSetTokenAddress(address _voucherSetTokenAddress)
external
override
onlyOwner
notZeroAddress(_voucherSetTokenAddress)
whenPaused
{
voucherSetTokenAddress = _voucherSetTokenAddress;
emit LogVoucherSetTokenContractSet(_voucherSetTokenAddress, msg.sender);
}
/**
* @notice Set the general complain period, should be used sparingly as it has significant consequences. Here done simply for demo purposes.
* @param _complainPeriod the new value for complain period (in number of seconds)
*/
function setComplainPeriod(uint256 _complainPeriod)
public
override
onlyOwner
{
complainPeriod = _complainPeriod;
emit LogComplainPeriodChanged(_complainPeriod, msg.sender);
}
/**
* @notice Set the general cancelOrFault period, should be used sparingly as it has significant consequences. Here done simply for demo purposes.
* @param _cancelFaultPeriod the new value for cancelOrFault period (in number of seconds)
*/
function setCancelFaultPeriod(uint256 _cancelFaultPeriod)
public
override
onlyOwner
{
cancelFaultPeriod = _cancelFaultPeriod;
emit LogCancelFaultPeriodChanged(_cancelFaultPeriod, msg.sender);
}
// // // // // // // //
// GETTERS
// // // // // // // //
/**
* @notice Get the promise ID at specific index
* @param _idx Index in the array of promise keys
* @return Promise ID
*/
function getPromiseKey(uint256 _idx)
external
view
override
returns (bytes32)
{
return promiseKeys[_idx];
}
/**
* @notice Get the supply token ID from a voucher token
* @param _tokenIdVoucher ID of the voucher token
* @return ID of the supply token
*/
function getIdSupplyFromVoucher(uint256 _tokenIdVoucher)
public
pure
override
returns (uint256)
{
uint256 tokenIdSupply = _tokenIdVoucher & MASK_TYPE;
require(tokenIdSupply !=0, "INEXISTENT_SUPPLY");
return tokenIdSupply;
}
/**
* @notice Get the promise ID from a voucher token
* @param _tokenIdVoucher ID of the voucher token
* @return ID of the promise
*/
function getPromiseIdFromVoucherId(uint256 _tokenIdVoucher)
public
view
override
returns (bytes32)
{
require(_tokenIdVoucher != 0, "UNSPECIFIED_ID");
uint256 tokenIdSupply = getIdSupplyFromVoucher(_tokenIdVoucher);
return promises[ordersPromise[tokenIdSupply]].promiseId;
}
/**
* @notice Get the remaining quantity left in supply of tokens (e.g ERC-721 left in ERC-1155) of an account
* @param _tokenSupplyId Token supply ID
* @param _tokenSupplyOwner holder of the Token Supply
* @return remaining quantity
*/
function getRemQtyForSupply(uint256 _tokenSupplyId, address _tokenSupplyOwner)
public
view
override
returns (uint256)
{
return IVoucherSets(voucherSetTokenAddress).balanceOf(_tokenSupplyOwner, _tokenSupplyId);
}
/**
* @notice Get all necessary funds for a supply token
* @param _tokenIdSupply ID of the supply token
* @return returns a tuple (Payment amount, Seller's deposit, Buyer's deposit)
*/
function getOrderCosts(uint256 _tokenIdSupply)
external
view
override
returns (
uint256,
uint256,
uint256
)
{
bytes32 promiseKey = ordersPromise[_tokenIdSupply];
return (
promises[promiseKey].price,
promises[promiseKey].depositSe,
promises[promiseKey].depositBu
);
}
/**
* @notice Get the sum of buyer and seller deposit for the voucher
* @param _tokenIdVoucher ID of the voucher token
*/
function getTotalDepositsForVoucher(uint256 _tokenIdVoucher)
internal
view
returns (
uint256
)
{
bytes32 promiseKey = getPromiseIdFromVoucherId(_tokenIdVoucher);
return promises[promiseKey].depositSe.add(promises[promiseKey].depositBu);
}
/**
* @notice Get Buyer costs required to make an order for a supply token
* @param _tokenIdSupply ID of the supply token
* @return returns a tuple (Payment amount, Buyer's deposit)
*/
function getBuyerOrderCosts(uint256 _tokenIdSupply)
external
view
override
returns (uint256, uint256)
{
bytes32 promiseKey = ordersPromise[_tokenIdSupply];
return (promises[promiseKey].price, promises[promiseKey].depositBu);
}
/**
* @notice Get Seller deposit
* @param _tokenIdSupply ID of the supply token
* @return returns sellers deposit
*/
function getSellerDeposit(uint256 _tokenIdSupply)
external
view
override
returns (uint256)
{
bytes32 promiseKey = ordersPromise[_tokenIdSupply];
return promises[promiseKey].depositSe;
}
/**
* @notice Get the holder of a supply
* @param _tokenIdSupply ID of the order (aka VoucherSet) which is mapped to the corresponding Promise.
* @return Address of the holder
*/
function getSupplyHolder(uint256 _tokenIdSupply)
public
view
override
returns (address)
{
bytes32 promiseKey = ordersPromise[_tokenIdSupply];
return promises[promiseKey].seller;
}
/**
* @notice Get the issuer of a voucher
* @param _voucherTokenId ID of the voucher token
* @return Address of the seller, when voucher was created
*/
function getVoucherSeller(uint256 _voucherTokenId) external view override returns (address) {
return vouchersStatus[_voucherTokenId].seller;
}
/**
* @notice Get promise data not retrieved by other accessor functions
* @param _promiseKey ID of the promise
* @return promise data not returned by other accessor methods
*/
function getPromiseData(bytes32 _promiseKey)
external
view
override
returns (bytes32, uint256, uint256, uint256, uint256 )
{
Promise memory tPromise = promises[_promiseKey];
return (tPromise.promiseId, tPromise.nonce, tPromise.validFrom, tPromise.validTo, tPromise.idx);
}
/**
* @notice Get the current status of a voucher
* @param _tokenIdVoucher ID of the voucher token
* @return Status of the voucher (via enum)
*/
function getVoucherStatus(uint256 _tokenIdVoucher)
external
view
override
returns (
uint8,
bool,
bool,
uint256,
uint256
)
{
return (
vouchersStatus[_tokenIdVoucher].status,
vouchersStatus[_tokenIdVoucher].isPaymentReleased,
vouchersStatus[_tokenIdVoucher].isDepositsReleased,
vouchersStatus[_tokenIdVoucher].complainPeriodStart,
vouchersStatus[_tokenIdVoucher].cancelFaultPeriodStart
);
}
/**
* @notice Get the holder of a voucher
* @param _tokenIdVoucher ID of the voucher token
* @return Address of the holder
*/
function getVoucherHolder(uint256 _tokenIdVoucher)
external
view
override
returns (address)
{
return IVouchers(voucherTokenAddress).ownerOf(_tokenIdVoucher);
}
/**
* @notice Get the address of the token where the price for the supply is held
* @param _tokenIdSupply ID of the voucher supply token
* @return Address of the token
*/
function getVoucherPriceToken(uint256 _tokenIdSupply)
external
view
override
returns (address)
{
return paymentDetails[_tokenIdSupply].addressTokenPrice;
}
/**
* @notice Get the address of the token where the deposits for the supply are held
* @param _tokenIdSupply ID of the voucher supply token
* @return Address of the token
*/
function getVoucherDepositToken(uint256 _tokenIdSupply)
external
view
override
returns (address)
{
return paymentDetails[_tokenIdSupply].addressTokenDeposits;
}
/**
* @notice Get the payment method for a particular _tokenIdSupply
* @param _tokenIdSupply ID of the voucher supply token
* @return payment method
*/
function getVoucherPaymentMethod(uint256 _tokenIdSupply)
public
view
override
returns (PaymentMethod)
{
return paymentDetails[_tokenIdSupply].paymentMethod;
}
/**
* @notice Checks whether a voucher is in valid period for redemption (between start date and end date)
* @param _tokenIdVoucher ID of the voucher token
*/
function isInValidityPeriod(uint256 _tokenIdVoucher)
public
view
override
returns (bool)
{
//check validity period
Promise memory tPromise =
promises[getPromiseIdFromVoucherId(_tokenIdVoucher)];
require(tPromise.validFrom <= block.timestamp, "INVALID_VALIDITY_FROM");
require(tPromise.validTo >= block.timestamp, "INVALID_VALIDITY_TO");
return true;
}
/**
* @notice Checks whether a voucher is in valid state to be transferred. If either payments or deposits are released, voucher could not be transferred
* @param _tokenIdVoucher ID of the voucher token
*/
function isVoucherTransferable(uint256 _tokenIdVoucher)
external
view
override
returns (bool)
{
return
!(vouchersStatus[_tokenIdVoucher].isPaymentReleased ||
vouchersStatus[_tokenIdVoucher].isDepositsReleased);
}
/**
* @notice Get address of the Boson Router to which this contract points
* @return Address of the Boson Router contract
*/
function getBosonRouterAddress()
external
view
override
returns (address)
{
return bosonRouterAddress;
}
/**
* @notice Get address of the Cashier contract to which this contract points
* @return Address of the Cashier contract
*/
function getCashierAddress()
external
view
override
returns (address)
{
return cashierAddress;
}
/**
* @notice Get the token nonce for a seller
* @param _seller Address of the seller
* @return The seller's nonce
*/
function getTokenNonce(address _seller)
external
view
override
returns (uint256)
{
return tokenNonces[_seller];
}
/**
* @notice Get the current type Id
* @return type Id
*/
function getTypeId()
external
view
override
returns (uint256)
{
return typeId;
}
/**
* @notice Get the complain period
* @return complain period
*/
function getComplainPeriod()
external
view
override
returns (uint256)
{
return complainPeriod;
}
/**
* @notice Get the cancel or fault period
* @return cancel or fault period
*/
function getCancelFaultPeriod()
external
view
override
returns (uint256)
{
return cancelFaultPeriod;
}
/**
* @notice Get the promise ID from a voucher set
* @param _tokenIdSupply ID of the voucher token
* @return ID of the promise
*/
function getPromiseIdFromSupplyId(uint256 _tokenIdSupply)
external
view
override
returns (bytes32)
{
return ordersPromise[_tokenIdSupply];
}
/**
* @notice Get the address of the Vouchers token contract, an ERC721 contract
* @return Address of Vouchers contract
*/
function getVoucherTokenAddress()
external
view
override
returns (address)
{
return voucherTokenAddress;
}
/**
* @notice Get the address of the VoucherSets token contract, an ERC155 contract
* @return Address of VoucherSets contract
*/
function getVoucherSetTokenAddress()
external
view
override
returns (address)
{
return voucherSetTokenAddress;
}
}
/IERC1155MetadataURI.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.7.0;
import "./IERC1155.sol";
/**
* @dev Interface of the optional ERC1155MetadataExtension interface, as defined
* in the https://eips.ethereum.org/EIPS/eip-1155#metadata-extensions[EIP].
*
* _Available since v3.1._
*/
interface IERC1155MetadataURI is IERC1155 {
/**
* @dev Returns the URI for token type `id`.
*
* If the `\{id\}` substring is present in the URI, it must be replaced by
* clients with the actual token type ID.
*/
function uri(uint256 id) external view returns (string memory);
}
/Pausable.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.7.0;
import "./Context.sol";
/**
* @dev Contract module which allows children to implement an emergency stop
* mechanism that can be triggered by an authorized account.
*
* This module is used through inheritance. It will make available the
* modifiers `whenNotPaused` and `whenPaused`, which can be applied to
* the functions of your contract. Note that they will not be pausable by
* simply including this module, only once the modifiers are put in place.
*/
abstract contract Pausable is Context {
/**
* @dev Emitted when the pause is triggered by `account`.
*/
event Paused(address account);
/**
* @dev Emitted when the pause is lifted by `account`.
*/
event Unpaused(address account);
bool private _paused;
/**
* @dev Initializes the contract in unpaused state.
*/
constructor () {
_paused = false;
}
/**
* @dev Returns true if the contract is paused, and false otherwise.
*/
function paused() public view virtual returns (bool) {
return _paused;
}
/**
* @dev Modifier to make a function callable only when the contract is not paused.
*
* Requirements:
*
* - The contract must not be paused.
*/
modifier whenNotPaused() {
require(!paused(), "Pausable: paused");
_;
}
/**
* @dev Modifier to make a function callable only when the contract is paused.
*
* Requirements:
*
* - The contract must be paused.
*/
modifier whenPaused() {
require(paused(), "Pausable: not paused");
_;
}
/**
* @dev Triggers stopped state.
*
* Requirements:
*
* - The contract must not be paused.
*/
function _pause() internal virtual whenNotPaused {
_paused = true;
emit Paused(_msgSender());
}
/**
* @dev Returns to normal state.
*
* Requirements:
*
* - The contract must be paused.
*/
function _unpause() internal virtual whenPaused {
_paused = false;
emit Unpaused(_msgSender());
}
}
/IERC721Receiver.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.7.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);
}
/IERC721Metadata.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.7.0;
import "./IERC721.sol";
/**
* @title ERC-721 Non-Fungible Token Standard, optional metadata extension
* @dev See https://eips.ethereum.org/EIPS/eip-721
*/
interface IERC721Metadata is IERC721 {
/**
* @dev Returns the token collection name.
*/
function name() external view returns (string memory);
/**
* @dev Returns the token collection symbol.
*/
function symbol() external view returns (string memory);
/**
* @dev Returns the Uniform Resource Identifier (URI) for `tokenId` token.
*/
function tokenURI(uint256 tokenId) external view returns (string memory);
}
/IERC1155.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.7.0;
import "../../introspection/IERC165.sol";
/**
* @dev Required interface of an ERC1155 compliant contract, as defined in the
* https://eips.ethereum.org/EIPS/eip-1155[EIP].
*
* _Available since v3.1._
*/
interface IERC1155 is IERC165 {
/**
* @dev Emitted when `value` tokens of token type `id` are transferred from `from` to `to` by `operator`.
*/
event TransferSingle(address indexed operator, address indexed from, address indexed to, uint256 id, uint256 value);
/**
* @dev Equivalent to multiple {TransferSingle} events, where `operator`, `from` and `to` are the same for all
* transfers.
*/
event TransferBatch(address indexed operator, address indexed from, address indexed to, uint256[] ids, uint256[] values);
/**
* @dev Emitted when `account` grants or revokes permission to `operator` to transfer their tokens, according to
* `approved`.
*/
event ApprovalForAll(address indexed account, address indexed operator, bool approved);
/**
* @dev Emitted when the URI for token type `id` changes to `value`, if it is a non-programmatic URI.
*
* If an {URI} event was emitted for `id`, the standard
* https://eips.ethereum.org/EIPS/eip-1155#metadata-extensions[guarantees] that `value` will equal the value
* returned by {IERC1155MetadataURI-uri}.
*/
event URI(string value, uint256 indexed id);
/**
* @dev Returns the amount of tokens of token type `id` owned by `account`.
*
* Requirements:
*
* - `account` cannot be the zero address.
*/
function balanceOf(address account, uint256 id) external view returns (uint256);
/**
* @dev xref:ROOT:erc1155.adoc#batch-operations[Batched] version of {balanceOf}.
*
* Requirements:
*
* - `accounts` and `ids` must have the same length.
*/
function balanceOfBatch(address[] calldata accounts, uint256[] calldata ids) external view returns (uint256[] memory);
/**
* @dev Grants or revokes permission to `operator` to transfer the caller's tokens, according to `approved`,
*
* Emits an {ApprovalForAll} event.
*
* Requirements:
*
* - `operator` cannot be the caller.
*/
function setApprovalForAll(address operator, bool approved) external;
/**
* @dev Returns true if `operator` is approved to transfer ``account``'s tokens.
*
* See {setApprovalForAll}.
*/
function isApprovedForAll(address account, address operator) external view returns (bool);
/**
* @dev Transfers `amount` tokens of token type `id` from `from` to `to`.
*
* Emits a {TransferSingle} event.
*
* Requirements:
*
* - `to` cannot be the zero address.
* - If the caller is not `from`, it must be have been approved to spend ``from``'s tokens via {setApprovalForAll}.
* - `from` must have a balance of tokens of type `id` of at least `amount`.
* - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155Received} and return the
* acceptance magic value.
*/
function safeTransferFrom(address from, address to, uint256 id, uint256 amount, bytes calldata data) external;
/**
* @dev xref:ROOT:erc1155.adoc#batch-operations[Batched] version of {safeTransferFrom}.
*
* Emits a {TransferBatch} event.
*
* Requirements:
*
* - `ids` and `amounts` must have the same length.
* - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155BatchReceived} and return the
* acceptance magic value.
*/
function safeBatchTransferFrom(address from, address to, uint256[] calldata ids, uint256[] calldata amounts, bytes calldata data) external;
}
/ReentrancyGuard.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.7.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;
}
}
/IERC165.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.7.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);
}
/IERC721.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.7.0;
import "../../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;
}
/Ownable.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.7.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 () {
address msgSender = _msgSender();
_owner = msgSender;
emit OwnershipTransferred(address(0), 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 {
emit OwnershipTransferred(_owner, address(0));
_owner = address(0);
}
/**
* @dev Transfers ownership of the contract to a new account (`newOwner`).
* Can only be called by the current owner.
*/
function transferOwnership(address newOwner) public virtual onlyOwner {
require(newOwner != address(0), "Ownable: new owner is the zero address");
emit OwnershipTransferred(_owner, newOwner);
_owner = newOwner;
}
}
/Context.sol
// SPDX-License-Identifier: MIT
pragma solidity >=0.6.0 <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 GSN meta-transactions the account sending and
* paying for execution may not be the actual sender (as far as an application
* is concerned).
*
* This contract is only required for intermediate, library-like contracts.
*/
abstract contract Context {
function _msgSender() internal view virtual returns (address payable) {
return msg.sender;
}
function _msgData() internal view virtual returns (bytes memory) {
this; // silence state mutability warning without generating bytecode - see https://github.com/ethereum/solidity/issues/2691
return msg.data;
}
}
/Address.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.7.0;
/**
* @dev Collection of functions related to the address type
*/
library Address {
/**
* @dev Returns true if `account` is a contract.
*
* [IMPORTANT]
* ====
* It is unsafe to assume that an address for which this function returns
* false is an externally-owned account (EOA) and not a contract.
*
* Among others, `isContract` will return false for the following
* types of addresses:
*
* - an externally-owned account
* - a contract in construction
* - an address where a contract will be created
* - an address where a contract lived, but was destroyed
* ====
*/
function isContract(address account) internal view returns (bool) {
// 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;
// solhint-disable-next-line no-inline-assembly
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");
// solhint-disable-next-line avoid-low-level-calls, avoid-call-value
(bool success, ) = recipient.call{ value: amount }("");
require(success, "Address: unable to send value, recipient may have reverted");
}
/**
* @dev Performs a Solidity function call using a low level `call`. A
* plain`call` is an unsafe replacement for a function call: use this
* function instead.
*
* If `target` reverts with a revert reason, it is bubbled up by this
* function (like regular Solidity function calls).
*
* Returns the raw returned data. To convert to the expected return value,
* use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].
*
* Requirements:
*
* - `target` must be a contract.
* - calling `target` with `data` must not revert.
*
* _Available since v3.1._
*/
function functionCall(address target, bytes memory data) internal returns (bytes memory) {
return functionCall(target, data, "Address: low-level call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with
* `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) {
return functionCallWithValue(target, data, 0, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but also transferring `value` wei to `target`.
*
* Requirements:
*
* - the calling contract must have an ETH balance of at least `value`.
* - the called Solidity function must be `payable`.
*
* _Available since v3.1._
*/
function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) {
return functionCallWithValue(target, data, value, "Address: low-level call with value failed");
}
/**
* @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but
* with `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCallWithValue(address target, bytes memory data, uint256 value, string memory errorMessage) internal returns (bytes memory) {
require(address(this).balance >= value, "Address: insufficient balance for call");
require(isContract(target), "Address: call to non-contract");
// solhint-disable-next-line avoid-low-level-calls
(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");
// solhint-disable-next-line avoid-low-level-calls
(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");
// solhint-disable-next-line avoid-low-level-calls
(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
// solhint-disable-next-line no-inline-assembly
assembly {
let returndata_size := mload(returndata)
revert(add(32, returndata), returndata_size)
}
} else {
revert(errorMessage);
}
}
}
}
/SafeMath.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.7.0;
/**
* @dev Wrappers over Solidity's arithmetic operations with added overflow
* checks.
*
* Arithmetic operations in Solidity wrap on overflow. This can easily result
* in bugs, because programmers usually assume that an overflow raises an
* error, which is the standard behavior in high level programming languages.
* `SafeMath` restores this intuition by reverting the transaction when an
* operation overflows.
*
* Using this library instead of the unchecked operations eliminates an entire
* class of bugs, so it's recommended to use it always.
*/
library SafeMath {
/**
* @dev Returns the addition of two unsigned integers, with an overflow flag.
*
* _Available since v3.4._
*/
function tryAdd(uint256 a, uint256 b) internal pure returns (bool, uint256) {
uint256 c = a + b;
if (c < a) return (false, 0);
return (true, c);
}
/**
* @dev Returns the substraction of two unsigned integers, with an overflow flag.
*
* _Available since v3.4._
*/
function trySub(uint256 a, uint256 b) internal pure returns (bool, uint256) {
if (b > a) return (false, 0);
return (true, a - b);
}
/**
* @dev Returns the multiplication of two unsigned integers, with an overflow flag.
*
* _Available since v3.4._
*/
function tryMul(uint256 a, uint256 b) internal pure returns (bool, uint256) {
// Gas optimization: this is cheaper than requiring 'a' not being zero, but the
// benefit is lost if 'b' is also tested.
// See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522
if (a == 0) return (true, 0);
uint256 c = a * b;
if (c / a != b) return (false, 0);
return (true, c);
}
/**
* @dev Returns the division of two unsigned integers, with a division by zero flag.
*
* _Available since v3.4._
*/
function tryDiv(uint256 a, uint256 b) internal pure returns (bool, uint256) {
if (b == 0) return (false, 0);
return (true, a / b);
}
/**
* @dev Returns the remainder of dividing two unsigned integers, with a division by zero flag.
*
* _Available since v3.4._
*/
function tryMod(uint256 a, uint256 b) internal pure returns (bool, uint256) {
if (b == 0) return (false, 0);
return (true, a % b);
}
/**
* @dev Returns the addition of two unsigned integers, reverting on
* overflow.
*
* Counterpart to Solidity's `+` operator.
*
* Requirements:
*
* - Addition cannot overflow.
*/
function add(uint256 a, uint256 b) internal pure returns (uint256) {
uint256 c = a + b;
require(c >= a, "SafeMath: addition overflow");
return c;
}
/**
* @dev Returns the subtraction of two unsigned integers, reverting on
* overflow (when the result is negative).
*
* Counterpart to Solidity's `-` operator.
*
* Requirements:
*
* - Subtraction cannot overflow.
*/
function sub(uint256 a, uint256 b) internal pure returns (uint256) {
require(b <= a, "SafeMath: subtraction overflow");
return a - b;
}
/**
* @dev Returns the multiplication of two unsigned integers, reverting on
* overflow.
*
* Counterpart to Solidity's `*` operator.
*
* Requirements:
*
* - Multiplication cannot overflow.
*/
function mul(uint256 a, uint256 b) internal pure returns (uint256) {
if (a == 0) return 0;
uint256 c = a * b;
require(c / a == b, "SafeMath: multiplication overflow");
return c;
}
/**
* @dev Returns the integer division of two unsigned integers, reverting on
* division by zero. The result is rounded towards zero.
*
* Counterpart to Solidity's `/` operator. Note: this function uses a
* `revert` opcode (which leaves remaining gas untouched) while Solidity
* uses an invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function div(uint256 a, uint256 b) internal pure returns (uint256) {
require(b > 0, "SafeMath: division by zero");
return a / b;
}
/**
* @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
* reverting when dividing by zero.
*
* Counterpart to Solidity's `%` operator. This function uses a `revert`
* opcode (which leaves remaining gas untouched) while Solidity uses an
* invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function mod(uint256 a, uint256 b) internal pure returns (uint256) {
require(b > 0, "SafeMath: modulo by zero");
return a % b;
}
/**
* @dev Returns the subtraction of two unsigned integers, reverting with custom message on
* overflow (when the result is negative).
*
* CAUTION: This function is deprecated because it requires allocating memory for the error
* message unnecessarily. For custom revert reasons use {trySub}.
*
* Counterpart to Solidity's `-` operator.
*
* Requirements:
*
* - Subtraction cannot overflow.
*/
function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b <= a, errorMessage);
return a - b;
}
/**
* @dev Returns the integer division of two unsigned integers, reverting with custom message on
* division by zero. The result is rounded towards zero.
*
* CAUTION: This function is deprecated because it requires allocating memory for the error
* message unnecessarily. For custom revert reasons use {tryDiv}.
*
* Counterpart to Solidity's `/` operator. Note: this function uses a
* `revert` opcode (which leaves remaining gas untouched) while Solidity
* uses an invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b > 0, errorMessage);
return a / b;
}
/**
* @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
* reverting with custom message when dividing by zero.
*
* CAUTION: This function is deprecated because it requires allocating memory for the error
* message unnecessarily. For custom revert reasons use {tryMod}.
*
* Counterpart to Solidity's `%` operator. This function uses a `revert`
* opcode (which leaves remaining gas untouched) while Solidity uses an
* invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b > 0, errorMessage);
return a % b;
}
}
/IVoucherKernel.sol
// SPDX-License-Identifier: LGPL-3.0-or-later
pragma solidity 0.7.6;
import "./../UsingHelpers.sol";
interface IVoucherKernel {
/**
* @notice Pause the process of interaction with voucherID's (ERC-721), in case of emergency.
* Only Cashier contract is in control of this function.
*/
function pause() external;
/**
* @notice Unpause the process of interaction with voucherID's (ERC-721).
* Only Cashier contract is in control of this function.
*/
function unpause() external;
/**
* @notice Creating a new promise for goods or services.
* Can be reused, e.g. for making different batches of these (but not in prototype).
* @param _seller seller of the promise
* @param _validFrom Start of valid period
* @param _validTo End of valid period
* @param _price Price (payment amount)
* @param _depositSe Seller's deposit
* @param _depositBu Buyer's deposit
*/
function createTokenSupplyId(
address _seller,
uint256 _validFrom,
uint256 _validTo,
uint256 _price,
uint256 _depositSe,
uint256 _depositBu,
uint256 _quantity
) external returns (uint256);
/**
* @notice Creates a Payment method struct recording the details on how the seller requires to receive Price and Deposits for a certain Voucher Set.
* @param _tokenIdSupply _tokenIdSupply of the voucher set this is related to
* @param _paymentMethod might be ETHETH, ETHTKN, TKNETH or TKNTKN
* @param _tokenPrice token address which will hold the funds for the price of the voucher
* @param _tokenDeposits token address which will hold the funds for the deposits of the voucher
*/
function createPaymentMethod(
uint256 _tokenIdSupply,
PaymentMethod _paymentMethod,
address _tokenPrice,
address _tokenDeposits
) external;
/**
* @notice Mark voucher token that the payment was released
* @param _tokenIdVoucher ID of the voucher token
*/
function setPaymentReleased(uint256 _tokenIdVoucher) external;
/**
* @notice Mark voucher token that the deposits were released
* @param _tokenIdVoucher ID of the voucher token
* @param _to recipient, one of {ISSUER, HOLDER, POOL}
* @param _amount amount that was released in the transaction
*/
function setDepositsReleased(
uint256 _tokenIdVoucher,
Entity _to,
uint256 _amount
) external;
/**
* @notice Tells if part of the deposit, belonging to entity, was released already
* @param _tokenIdVoucher ID of the voucher token
* @param _to recipient, one of {ISSUER, HOLDER, POOL}
*/
function isDepositReleased(uint256 _tokenIdVoucher, Entity _to)
external
returns (bool);
/**
* @notice Redemption of the vouchers promise
* @param _tokenIdVoucher ID of the voucher
* @param _messageSender owner of the voucher
*/
function redeem(uint256 _tokenIdVoucher, address _messageSender) external;
/**
* @notice Refunding a voucher
* @param _tokenIdVoucher ID of the voucher
* @param _messageSender owner of the voucher
*/
function refund(uint256 _tokenIdVoucher, address _messageSender) external;
/**
* @notice Issue a complain for a voucher
* @param _tokenIdVoucher ID of the voucher
* @param _messageSender owner of the voucher
*/
function complain(uint256 _tokenIdVoucher, address _messageSender) external;
/**
* @notice Cancel/Fault transaction by the Seller, admitting to a fault or backing out of the deal
* @param _tokenIdVoucher ID of the voucher
* @param _messageSender owner of the voucher set (seller)
*/
function cancelOrFault(uint256 _tokenIdVoucher, address _messageSender)
external;
/**
* @notice Cancel/Fault transaction by the Seller, cancelling the remaining uncommitted voucher set so that seller prevents buyers from committing to vouchers for items no longer in exchange.
* @param _tokenIdSupply ID of the voucher
* @param _issuer owner of the voucher
*/
function cancelOrFaultVoucherSet(uint256 _tokenIdSupply, address _issuer)
external
returns (uint256);
/**
* @notice Fill Voucher Order, iff funds paid, then extract & mint NFT to the voucher holder
* @param _tokenIdSupply ID of the supply token (ERC-1155)
* @param _issuer Address of the token's issuer
* @param _holder Address of the recipient of the voucher (ERC-721)
* @param _paymentMethod method being used for that particular order that needs to be fulfilled
*/
function fillOrder(
uint256 _tokenIdSupply,
address _issuer,
address _holder,
PaymentMethod _paymentMethod
) external;
/**
* @notice Mark voucher token as expired
* @param _tokenIdVoucher ID of the voucher token
*/
function triggerExpiration(uint256 _tokenIdVoucher) external;
/**
* @notice Mark voucher token to the final status
* @param _tokenIdVoucher ID of the voucher token
*/
function triggerFinalizeVoucher(uint256 _tokenIdVoucher) external;
/**
* @notice Set the address of the new holder of a _tokenIdSupply on transfer
* @param _tokenIdSupply _tokenIdSupply which will be transferred
* @param _newSeller new holder of the supply
*/
function setSupplyHolderOnTransfer(
uint256 _tokenIdSupply,
address _newSeller
) external;
/**
* @notice Set the general cancelOrFault period, should be used sparingly as it has significant consequences. Here done simply for demo purposes.
* @param _cancelFaultPeriod the new value for cancelOrFault period (in number of seconds)
*/
function setCancelFaultPeriod(uint256 _cancelFaultPeriod) external;
/**
* @notice Set the address of the Boson Router contract
* @param _bosonRouterAddress The address of the BR contract
*/
function setBosonRouterAddress(address _bosonRouterAddress) external;
/**
* @notice Set the address of the Cashier contract
* @param _cashierAddress The address of the Cashier contract
*/
function setCashierAddress(address _cashierAddress) external;
/**
* @notice Set the address of the Vouchers token contract, an ERC721 contract
* @param _voucherTokenAddress The address of the Vouchers token contract
*/
function setVoucherTokenAddress(address _voucherTokenAddress) external;
/**
* @notice Set the address of the Voucher Sets token contract, an ERC1155 contract
* @param _voucherSetTokenAddress The address of the Voucher Sets token contract
*/
function setVoucherSetTokenAddress(address _voucherSetTokenAddress)
external;
/**
* @notice Set the general complain period, should be used sparingly as it has significant consequences. Here done simply for demo purposes.
* @param _complainPeriod the new value for complain period (in number of seconds)
*/
function setComplainPeriod(uint256 _complainPeriod) external;
/**
* @notice Get the promise ID at specific index
* @param _idx Index in the array of promise keys
* @return Promise ID
*/
function getPromiseKey(uint256 _idx) external view returns (bytes32);
/**
* @notice Get the address of the token where the price for the supply is held
* @param _tokenIdSupply ID of the voucher token
* @return Address of the token
*/
function getVoucherPriceToken(uint256 _tokenIdSupply)
external
view
returns (address);
/**
* @notice Get the address of the token where the deposits for the supply are held
* @param _tokenIdSupply ID of the voucher token
* @return Address of the token
*/
function getVoucherDepositToken(uint256 _tokenIdSupply)
external
view
returns (address);
/**
* @notice Get Buyer costs required to make an order for a supply token
* @param _tokenIdSupply ID of the supply token
* @return returns a tuple (Payment amount, Buyer's deposit)
*/
function getBuyerOrderCosts(uint256 _tokenIdSupply)
external
view
returns (uint256, uint256);
/**
* @notice Get Seller deposit
* @param _tokenIdSupply ID of the supply token
* @return returns sellers deposit
*/
function getSellerDeposit(uint256 _tokenIdSupply)
external
view
returns (uint256);
/**
* @notice Get the promise ID from a voucher token
* @param _tokenIdVoucher ID of the voucher token
* @return ID of the promise
*/
function getIdSupplyFromVoucher(uint256 _tokenIdVoucher)
external
pure
returns (uint256);
/**
* @notice Get the promise ID from a voucher token
* @param _tokenIdVoucher ID of the voucher token
* @return ID of the promise
*/
function getPromiseIdFromVoucherId(uint256 _tokenIdVoucher)
external
view
returns (bytes32);
/**
* @notice Get all necessary funds for a supply token
* @param _tokenIdSupply ID of the supply token
* @return returns a tuple (Payment amount, Seller's deposit, Buyer's deposit)
*/
function getOrderCosts(uint256 _tokenIdSupply)
external
view
returns (
uint256,
uint256,
uint256
);
/**
* @notice Get the remaining quantity left in supply of tokens (e.g ERC-721 left in ERC-1155) of an account
* @param _tokenSupplyId Token supply ID
* @param _owner holder of the Token Supply
* @return remaining quantity
*/
function getRemQtyForSupply(uint256 _tokenSupplyId, address _owner)
external
view
returns (uint256);
/**
* @notice Get the payment method for a particular _tokenIdSupply
* @param _tokenIdSupply ID of the voucher supply token
* @return payment method
*/
function getVoucherPaymentMethod(uint256 _tokenIdSupply)
external
view
returns (PaymentMethod);
/**
* @notice Get the current status of a voucher
* @param _tokenIdVoucher ID of the voucher token
* @return Status of the voucher (via enum)
*/
function getVoucherStatus(uint256 _tokenIdVoucher)
external
view
returns (
uint8,
bool,
bool,
uint256,
uint256
);
/**
* @notice Get the holder of a supply
* @param _tokenIdSupply _tokenIdSupply ID of the order (aka VoucherSet) which is mapped to the corresponding Promise.
* @return Address of the holder
*/
function getSupplyHolder(uint256 _tokenIdSupply)
external
view
returns (address);
/**
* @notice Get the issuer of a voucher
* @param _voucherTokenId ID of the voucher token
* @return Address of the seller, when voucher was created
*/
function getVoucherSeller(uint256 _voucherTokenId)
external
view
returns (address);
/**
* @notice Get the holder of a voucher
* @param _tokenIdVoucher ID of the voucher token
* @return Address of the holder
*/
function getVoucherHolder(uint256 _tokenIdVoucher)
external
view
returns (address);
/**
* @notice Checks whether a voucher is in valid period for redemption (between start date and end date)
* @param _tokenIdVoucher ID of the voucher token
*/
function isInValidityPeriod(uint256 _tokenIdVoucher)
external
view
returns (bool);
/**
* @notice Checks whether a voucher is in valid state to be transferred. If either payments or deposits are released, voucher could not be transferred
* @param _tokenIdVoucher ID of the voucher token
*/
function isVoucherTransferable(uint256 _tokenIdVoucher)
external
view
returns (bool);
/**
* @notice Get address of the Boson Router contract to which this contract points
* @return Address of the Boson Router contract
*/
function getBosonRouterAddress() external view returns (address);
/**
* @notice Get address of the Cashier contract to which this contract points
* @return Address of the Cashier contract
*/
function getCashierAddress() external view returns (address);
/**
* @notice Get the token nonce for a seller
* @param _seller Address of the seller
* @return The seller's
*/
function getTokenNonce(address _seller) external view returns (uint256);
/**
* @notice Get the current type Id
* @return type Id
*/
function getTypeId() external view returns (uint256);
/**
* @notice Get the complain period
* @return complain period
*/
function getComplainPeriod() external view returns (uint256);
/**
* @notice Get the cancel or fault period
* @return cancel or fault period
*/
function getCancelFaultPeriod() external view returns (uint256);
/**
* @notice Get promise data not retrieved by other accessor functions
* @param _promiseKey ID of the promise
* @return promise data not returned by other accessor methods
*/
function getPromiseData(bytes32 _promiseKey)
external
view
returns (
bytes32,
uint256,
uint256,
uint256,
uint256
);
/**
* @notice Get the promise ID from a voucher set
* @param _tokenIdSupply ID of the voucher token
* @return ID of the promise
*/
function getPromiseIdFromSupplyId(uint256 _tokenIdSupply)
external
view
returns (bytes32);
/**
* @notice Get the address of the Vouchers token contract, an ERC721 contract
* @return Address of Vouchers contract
*/
function getVoucherTokenAddress() external view returns (address);
/**
* @notice Get the address of the VoucherSets token contract, an ERC155 contract
* @return Address of VoucherSets contract
*/
function getVoucherSetTokenAddress() external view returns (address);
}
/IVoucherSets.sol
// SPDX-License-Identifier: LGPL-3.0-or-later
pragma solidity 0.7.6;
import "@openzeppelin/contracts/token/ERC1155/IERC1155.sol";
import "@openzeppelin/contracts/token/ERC1155/IERC1155MetadataURI.sol";
interface IVoucherSets is IERC1155, IERC1155MetadataURI {
/**
* @notice Pause the Cashier && the Voucher Kernel contracts in case of emergency.
* All functions related to creating new batch, requestVoucher or withdraw will be paused, hence cannot be executed.
* There is special function for withdrawing funds if contract is paused.
*/
function pause() external;
/**
* @notice Unpause the Cashier && the Voucher Kernel contracts.
* All functions related to creating new batch, requestVoucher or withdraw will be unpaused.
*/
function unpause() external;
/**
* @notice Mint an amount of a desired token
* Currently no restrictions as to who is allowed to mint - so, it is external.
* @dev ERC-1155
* @param _to owner of the minted token
* @param _tokenId ID of the token to be minted
* @param _value Amount of the token to be minted
* @param _data Additional data forwarded to onERC1155BatchReceived if _to is a contract
*/
function mint(
address _to,
uint256 _tokenId,
uint256 _value,
bytes calldata _data
) external;
/**
* @notice Burn an amount of tokens with the given ID
* @dev ERC-1155
* @param _account Account which owns the token
* @param _tokenId ID of the token
* @param _value Amount of the token
*/
function burn(
address _account,
uint256 _tokenId,
uint256 _value
) external;
/**
* @notice Set the address of the VoucherKernel contract
* @param _voucherKernelAddress The address of the Voucher Kernel contract
*/
function setVoucherKernelAddress(address _voucherKernelAddress) external;
/**
* @notice Set the address of the Cashier contract
* @param _cashierAddress The address of the Cashier contract
*/
function setCashierAddress(address _cashierAddress) external;
/**
* @notice Get the address of Voucher Kernel contract
* @return Address of Voucher Kernel contract
*/
function getVoucherKernelAddress() external view returns (address);
/**
* @notice Get the address of Cashier contract
* @return Address of Cashier address
*/
function getCashierAddress() external view returns (address);
}
/IVouchers.sol
// SPDX-License-Identifier: LGPL-3.0-or-later
pragma solidity 0.7.6;
import "@openzeppelin/contracts/token/ERC721/IERC721.sol";
import "@openzeppelin/contracts/token/ERC721/IERC721Metadata.sol";
interface IVouchers is IERC721, IERC721Metadata {
/**
* @notice Pause the Cashier && the Voucher Kernel contracts in case of emergency.
* All functions related to creating new batch, requestVoucher or withdraw will be paused, hence cannot be executed.
* There is special function for withdrawing funds if contract is paused.
*/
function pause() external;
/**
* @notice Unpause the Cashier && the Voucher Kernel contracts.
* All functions related to creating new batch, requestVoucher or withdraw will be unpaused.
*/
function unpause() external;
/**
* @notice Function to mint tokens.
* @dev ERC-721
* @param _to The address that will receive the minted tokens.
* @param _tokenId The token id to mint.
* @return A boolean that indicates if the operation was successful.
*/
function mint(address _to, uint256 _tokenId) external returns (bool);
/**
* @notice Set the address of the VoucherKernel contract
* @param _voucherKernelAddress The address of the Voucher Kernel contract
*/
function setVoucherKernelAddress(address _voucherKernelAddress) external;
/**
* @notice Set the address of the Cashier contract
* @param _cashierAddress The address of the Cashier contract
*/
function setCashierAddress(address _cashierAddress) external;
/**
* @notice Get the address of Voucher Kernel contract
* @return Address of Voucher Kernel contract
*/
function getVoucherKernelAddress() external view returns (address);
/**
* @notice Get the address of Cashier contract
* @return Address of Cashier address
*/
function getCashierAddress() external view returns (address);
}
/UsingHelpers.sol
// SPDX-License-Identifier: LGPL-3.0-or-later
pragma solidity 0.7.6;
// Those are the payment methods we are using throughout the system.
// Depending on how to user choose to interact with it's funds we store the method, so we could distribute its tokens afterwise
enum PaymentMethod {
ETHETH,
ETHTKN,
TKNETH,
TKNTKN
}
enum Entity {ISSUER, HOLDER, POOL}
enum VoucherState {FINAL, CANCEL_FAULT, COMPLAIN, EXPIRE, REFUND, REDEEM, COMMIT}
/* Status of the voucher in 8 bits:
[6:COMMITTED] [5:REDEEMED] [4:REFUNDED] [3:EXPIRED] [2:COMPLAINED] [1:CANCELORFAULT] [0:FINAL]
*/
enum Condition {NOT_SET, BALANCE, OWNERSHIP} //Describes what kind of condition must be met for a conditional commit
struct ConditionalCommitInfo {
uint256 conditionalTokenId;
uint256 threshold;
Condition condition;
address gateAddress;
bool registerConditionalCommit;
}
uint8 constant ONE = 1;
struct VoucherDetails {
uint256 tokenIdSupply;
uint256 tokenIdVoucher;
address issuer;
address holder;
uint256 price;
uint256 depositSe;
uint256 depositBu;
PaymentMethod paymentMethod;
VoucherStatus currStatus;
}
struct VoucherStatus {
address seller;
uint8 status;
bool isPaymentReleased;
bool isDepositsReleased;
DepositsReleased depositReleased;
uint256 complainPeriodStart;
uint256 cancelFaultPeriodStart;
}
struct DepositsReleased {
uint8 status;
uint248 releasedAmount;
}
/**
* @notice Based on its lifecycle, voucher can have many different statuses. Checks whether a voucher is in Committed state.
* @param _status current status of a voucher.
*/
function isStateCommitted(uint8 _status) pure returns (bool) {
return _status == determineStatus(0, VoucherState.COMMIT);
}
/**
* @notice Based on its lifecycle, voucher can have many different statuses. Checks whether a voucher is in RedemptionSigned state.
* @param _status current status of a voucher.
*/
function isStateRedemptionSigned(uint8 _status)
pure
returns (bool)
{
return _status == determineStatus(determineStatus(0, VoucherState.COMMIT), VoucherState.REDEEM);
}
/**
* @notice Based on its lifecycle, voucher can have many different statuses. Checks whether a voucher is in Refunded state.
* @param _status current status of a voucher.
*/
function isStateRefunded(uint8 _status) pure returns (bool) {
return _status == determineStatus(determineStatus(0, VoucherState.COMMIT), VoucherState.REFUND);
}
/**
* @notice Based on its lifecycle, voucher can have many different statuses. Checks whether a voucher is in Expired state.
* @param _status current status of a voucher.
*/
function isStateExpired(uint8 _status) pure returns (bool) {
return _status == determineStatus(determineStatus(0, VoucherState.COMMIT), VoucherState.EXPIRE);
}
/**
* @notice Based on its lifecycle, voucher can have many different statuses. Checks the current status a voucher is at.
* @param _status current status of a voucher.
* @param _idx status to compare.
*/
function isStatus(uint8 _status, VoucherState _idx) pure returns (bool) {
return (_status >> uint8(_idx)) & ONE == 1;
}
/**
* @notice Set voucher status.
* @param _status previous status.
* @param _changeIdx next status.
*/
function determineStatus(uint8 _status, VoucherState _changeIdx)
pure
returns (uint8)
{
return _status | (ONE << uint8(_changeIdx));
}
Compiler Settings
{"remappings":[],"optimizer":{"runs":200,"enabled":true},"metadata":{"bytecodeHash":"ipfs"},"libraries":{},"evmVersion":"istanbul","compilationTarget":{"contracts/VoucherKernel.sol":"VoucherKernel"}}
Contract ABI
[{"type":"constructor","stateMutability":"nonpayable","inputs":[{"type":"address","name":"_bosonRouterAddress","internalType":"address"},{"type":"address","name":"_cashierAddress","internalType":"address"},{"type":"address","name":"_voucherSetTokenAddress","internalType":"address"},{"type":"address","name":"_voucherTokenAddress","internalType":"address"}]},{"type":"event","name":"LogBosonRouterSet","inputs":[{"type":"address","name":"_newBosonRouter","internalType":"address","indexed":false},{"type":"address","name":"_triggeredBy","internalType":"address","indexed":false}],"anonymous":false},{"type":"event","name":"LogCancelFaultPeriodChanged","inputs":[{"type":"uint256","name":"_newCancelFaultPeriod","internalType":"uint256","indexed":false},{"type":"address","name":"_triggeredBy","internalType":"address","indexed":false}],"anonymous":false},{"type":"event","name":"LogCashierSet","inputs":[{"type":"address","name":"_newCashier","internalType":"address","indexed":false},{"type":"address","name":"_triggeredBy","internalType":"address","indexed":false}],"anonymous":false},{"type":"event","name":"LogComplainPeriodChanged","inputs":[{"type":"uint256","name":"_newComplainPeriod","internalType":"uint256","indexed":false},{"type":"address","name":"_triggeredBy","internalType":"address","indexed":false}],"anonymous":false},{"type":"event","name":"LogExpirationTriggered","inputs":[{"type":"uint256","name":"_tokenIdVoucher","internalType":"uint256","indexed":false},{"type":"address","name":"_triggeredBy","internalType":"address","indexed":false}],"anonymous":false},{"type":"event","name":"LogFinalizeVoucher","inputs":[{"type":"uint256","name":"_tokenIdVoucher","internalType":"uint256","indexed":false},{"type":"address","name":"_triggeredBy","internalType":"address","indexed":false}],"anonymous":false},{"type":"event","name":"LogFundsReleased","inputs":[{"type":"uint256","name":"_tokenIdVoucher","internalType":"uint256","indexed":false},{"type":"uint8","name":"_type","internalType":"uint8","indexed":false}],"anonymous":false},{"type":"event","name":"LogPromiseCreated","inputs":[{"type":"bytes32","name":"_promiseId","internalType":"bytes32","indexed":true},{"type":"uint256","name":"_nonce","internalType":"uint256","indexed":true},{"type":"address","name":"_seller","internalType":"address","indexed":true},{"type":"uint256","name":"_validFrom","internalType":"uint256","indexed":false},{"type":"uint256","name":"_validTo","internalType":"uint256","indexed":false},{"type":"uint256","name":"_idx","internalType":"uint256","indexed":false}],"anonymous":false},{"type":"event","name":"LogVoucherCommitted","inputs":[{"type":"uint256","name":"_tokenIdSupply","internalType":"uint256","indexed":true},{"type":"uint256","name":"_tokenIdVoucher","internalType":"uint256","indexed":false},{"type":"address","name":"_issuer","internalType":"address","indexed":false},{"type":"address","name":"_holder","internalType":"address","indexed":false},{"type":"bytes32","name":"_promiseId","internalType":"bytes32","indexed":false}],"anonymous":false},{"type":"event","name":"LogVoucherComplain","inputs":[{"type":"uint256","name":"_tokenIdVoucher","internalType":"uint256","indexed":false}],"anonymous":false},{"type":"event","name":"LogVoucherFaultCancel","inputs":[{"type":"uint256","name":"_tokenIdVoucher","internalType":"uint256","indexed":false}],"anonymous":false},{"type":"event","name":"LogVoucherRedeemed","inputs":[{"type":"uint256","name":"_tokenIdVoucher","internalType":"uint256","indexed":false},{"type":"address","name":"_holder","internalType":"address","indexed":false},{"type":"bytes32","name":"_promiseId","internalType":"bytes32","indexed":false}],"anonymous":false},{"type":"event","name":"LogVoucherRefunded","inputs":[{"type":"uint256","name":"_tokenIdVoucher","internalType":"uint256","indexed":false}],"anonymous":false},{"type":"event","name":"LogVoucherSetFaultCancel","inputs":[{"type":"uint256","name":"_tokenIdSupply","internalType":"uint256","indexed":false},{"type":"address","name":"_issuer","internalType":"address","indexed":false}],"anonymous":false},{"type":"event","name":"LogVoucherSetTokenContractSet","inputs":[{"type":"address","name":"_newTokenContract","internalType":"address","indexed":false},{"type":"address","name":"_triggeredBy","internalType":"address","indexed":false}],"anonymous":false},{"type":"event","name":"LogVoucherTokenContractSet","inputs":[{"type":"address","name":"_newTokenContract","internalType":"address","indexed":false},{"type":"address","name":"_triggeredBy","internalType":"address","indexed":false}],"anonymous":false},{"type":"event","name":"OwnershipTransferred","inputs":[{"type":"address","name":"previousOwner","internalType":"address","indexed":true},{"type":"address","name":"newOwner","internalType":"address","indexed":true}],"anonymous":false},{"type":"event","name":"Paused","inputs":[{"type":"address","name":"account","internalType":"address","indexed":false}],"anonymous":false},{"type":"event","name":"Unpaused","inputs":[{"type":"address","name":"account","internalType":"address","indexed":false}],"anonymous":false},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"cancelOrFault","inputs":[{"type":"uint256","name":"_tokenIdVoucher","internalType":"uint256"},{"type":"address","name":"_messageSender","internalType":"address"}]},{"type":"function","stateMutability":"nonpayable","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"cancelOrFaultVoucherSet","inputs":[{"type":"uint256","name":"_tokenIdSupply","internalType":"uint256"},{"type":"address","name":"_issuer","internalType":"address"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"complain","inputs":[{"type":"uint256","name":"_tokenIdVoucher","internalType":"uint256"},{"type":"address","name":"_messageSender","internalType":"address"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"createPaymentMethod","inputs":[{"type":"uint256","name":"_tokenIdSupply","internalType":"uint256"},{"type":"uint8","name":"_paymentMethod","internalType":"enum PaymentMethod"},{"type":"address","name":"_tokenPrice","internalType":"address"},{"type":"address","name":"_tokenDeposits","internalType":"address"}]},{"type":"function","stateMutability":"nonpayable","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"createTokenSupplyId","inputs":[{"type":"address","name":"_seller","internalType":"address"},{"type":"uint256","name":"_validFrom","internalType":"uint256"},{"type":"uint256","name":"_validTo","internalType":"uint256"},{"type":"uint256","name":"_price","internalType":"uint256"},{"type":"uint256","name":"_depositSe","internalType":"uint256"},{"type":"uint256","name":"_depositBu","internalType":"uint256"},{"type":"uint256","name":"_quantity","internalType":"uint256"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"fillOrder","inputs":[{"type":"uint256","name":"_tokenIdSupply","internalType":"uint256"},{"type":"address","name":"_issuer","internalType":"address"},{"type":"address","name":"_holder","internalType":"address"},{"type":"uint8","name":"_paymentMethod","internalType":"enum PaymentMethod"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"","internalType":"address"}],"name":"getBosonRouterAddress","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"},{"type":"uint256","name":"","internalType":"uint256"}],"name":"getBuyerOrderCosts","inputs":[{"type":"uint256","name":"_tokenIdSupply","internalType":"uint256"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"getCancelFaultPeriod","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"","internalType":"address"}],"name":"getCashierAddress","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"getComplainPeriod","inputs":[]},{"type":"function","stateMutability":"pure","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"getIdSupplyFromVoucher","inputs":[{"type":"uint256","name":"_tokenIdVoucher","internalType":"uint256"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"},{"type":"uint256","name":"","internalType":"uint256"},{"type":"uint256","name":"","internalType":"uint256"}],"name":"getOrderCosts","inputs":[{"type":"uint256","name":"_tokenIdSupply","internalType":"uint256"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"bytes32","name":"","internalType":"bytes32"},{"type":"uint256","name":"","internalType":"uint256"},{"type":"uint256","name":"","internalType":"uint256"},{"type":"uint256","name":"","internalType":"uint256"},{"type":"uint256","name":"","internalType":"uint256"}],"name":"getPromiseData","inputs":[{"type":"bytes32","name":"_promiseKey","internalType":"bytes32"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"bytes32","name":"","internalType":"bytes32"}],"name":"getPromiseIdFromSupplyId","inputs":[{"type":"uint256","name":"_tokenIdSupply","internalType":"uint256"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"bytes32","name":"","internalType":"bytes32"}],"name":"getPromiseIdFromVoucherId","inputs":[{"type":"uint256","name":"_tokenIdVoucher","internalType":"uint256"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"bytes32","name":"","internalType":"bytes32"}],"name":"getPromiseKey","inputs":[{"type":"uint256","name":"_idx","internalType":"uint256"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"getRemQtyForSupply","inputs":[{"type":"uint256","name":"_tokenSupplyId","internalType":"uint256"},{"type":"address","name":"_tokenSupplyOwner","internalType":"address"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"getSellerDeposit","inputs":[{"type":"uint256","name":"_tokenIdSupply","internalType":"uint256"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"","internalType":"address"}],"name":"getSupplyHolder","inputs":[{"type":"uint256","name":"_tokenIdSupply","internalType":"uint256"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"getTokenNonce","inputs":[{"type":"address","name":"_seller","internalType":"address"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"getTypeId","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"","internalType":"address"}],"name":"getVoucherDepositToken","inputs":[{"type":"uint256","name":"_tokenIdSupply","internalType":"uint256"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"","internalType":"address"}],"name":"getVoucherHolder","inputs":[{"type":"uint256","name":"_tokenIdVoucher","internalType":"uint256"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint8","name":"","internalType":"enum PaymentMethod"}],"name":"getVoucherPaymentMethod","inputs":[{"type":"uint256","name":"_tokenIdSupply","internalType":"uint256"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"","internalType":"address"}],"name":"getVoucherPriceToken","inputs":[{"type":"uint256","name":"_tokenIdSupply","internalType":"uint256"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"","internalType":"address"}],"name":"getVoucherSeller","inputs":[{"type":"uint256","name":"_voucherTokenId","internalType":"uint256"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"","internalType":"address"}],"name":"getVoucherSetTokenAddress","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint8","name":"","internalType":"uint8"},{"type":"bool","name":"","internalType":"bool"},{"type":"bool","name":"","internalType":"bool"},{"type":"uint256","name":"","internalType":"uint256"},{"type":"uint256","name":"","internalType":"uint256"}],"name":"getVoucherStatus","inputs":[{"type":"uint256","name":"_tokenIdVoucher","internalType":"uint256"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"","internalType":"address"}],"name":"getVoucherTokenAddress","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"bool","name":"","internalType":"bool"}],"name":"isDepositReleased","inputs":[{"type":"uint256","name":"_tokenIdVoucher","internalType":"uint256"},{"type":"uint8","name":"_to","internalType":"enum Entity"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"bool","name":"","internalType":"bool"}],"name":"isInValidityPeriod","inputs":[{"type":"uint256","name":"_tokenIdVoucher","internalType":"uint256"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"bool","name":"","internalType":"bool"}],"name":"isVoucherTransferable","inputs":[{"type":"uint256","name":"_tokenIdVoucher","internalType":"uint256"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"","internalType":"address"}],"name":"owner","inputs":[]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"pause","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"bool","name":"","internalType":"bool"}],"name":"paused","inputs":[]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"redeem","inputs":[{"type":"uint256","name":"_tokenIdVoucher","internalType":"uint256"},{"type":"address","name":"_messageSender","internalType":"address"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"refund","inputs":[{"type":"uint256","name":"_tokenIdVoucher","internalType":"uint256"},{"type":"address","name":"_messageSender","internalType":"address"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"renounceOwnership","inputs":[]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"setBosonRouterAddress","inputs":[{"type":"address","name":"_bosonRouterAddress","internalType":"address"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"setCancelFaultPeriod","inputs":[{"type":"uint256","name":"_cancelFaultPeriod","internalType":"uint256"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"setCashierAddress","inputs":[{"type":"address","name":"_cashierAddress","internalType":"address"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"setComplainPeriod","inputs":[{"type":"uint256","name":"_complainPeriod","internalType":"uint256"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"setDepositsReleased","inputs":[{"type":"uint256","name":"_tokenIdVoucher","internalType":"uint256"},{"type":"uint8","name":"_to","internalType":"enum Entity"},{"type":"uint256","name":"_amount","internalType":"uint256"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"setPaymentReleased","inputs":[{"type":"uint256","name":"_tokenIdVoucher","internalType":"uint256"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"setSupplyHolderOnTransfer","inputs":[{"type":"uint256","name":"_tokenIdSupply","internalType":"uint256"},{"type":"address","name":"_newSeller","internalType":"address"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"setVoucherSetTokenAddress","inputs":[{"type":"address","name":"_voucherSetTokenAddress","internalType":"address"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"setVoucherTokenAddress","inputs":[{"type":"address","name":"_voucherTokenAddress","internalType":"address"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"transferOwnership","inputs":[{"type":"address","name":"newOwner","internalType":"address"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"triggerExpiration","inputs":[{"type":"uint256","name":"_tokenIdVoucher","internalType":"uint256"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"triggerFinalizeVoucher","inputs":[{"type":"uint256","name":"_tokenIdVoucher","internalType":"uint256"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"unpause","inputs":[]}]
Contract Creation Code
0x60806040523480156200001157600080fd5b506040516200465338038062004653833981810160405260808110156200003757600080fd5b508051602082015160408301516060909301519192909160006200005a62000331565b600080546001600160a01b0319166001600160a01b0383169081178255604051929350917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0908290a3506000805460ff60a01b1916905560018055836001600160a01b038116620000f7576040805162461bcd60e51b8152602060048201526002602482015261304160f01b604482015290519081900360640190fd5b836001600160a01b03811662000139576040805162461bcd60e51b8152602060048201526002602482015261304160f01b604482015290519081900360640190fd5b836001600160a01b0381166200017b576040805162461bcd60e51b8152602060048201526002602482015261304160f01b604482015290519081900360640190fd5b836001600160a01b038116620001bd576040805162461bcd60e51b8152602060048201526002602482015261304160f01b604482015290519081900360640190fd5b600480546001600160a01b03808b166001600160a01b03199283168117909355600580548b8316908416179055600280548a831690841617905560038054918916919092161790556040805191825233602083015280517fac81fe7dd460bb5162a4a7d8fb92a13bd2baf450914fc6b1c4cc3180eba55af09281900390910190a1604080516001600160a01b038916815233602082015281517fcd124a0a6c3182c7bb77b8052823a4bf7d0a4c90016ffc4d53b969f98d3f8b88929181900390910190a1604080516001600160a01b038816815233602082015281517f44c64b6c77fcb5df7b63c64b6346b9674961739187051adbf249bf8133974cad929181900390910190a1604080516001600160a01b038716815233602082015281517fb54ffecf5d152884be12f7742b1a1f9e4baa17fc9e2e9586546450645a59a38d929181900390910190a16200031562093a8062000335565b6200032362093a80620003df565b505050505050505062000498565b3390565b6200033f62000331565b6001600160a01b03166200035262000489565b6001600160a01b0316146200039d576040805162461bcd60e51b8152602060048201819052602482015260008051602062004633833981519152604482015290519081900360640190fd5b600e8190556040805182815233602082015281517f08bf60d0e489e33912f3ba0f81f21c6f2ad2499a36dfebfb6cfbfefcc49f3cca929181900390910190a150565b620003e962000331565b6001600160a01b0316620003fc62000489565b6001600160a01b03161462000447576040805162461bcd60e51b8152602060048201819052602482015260008051602062004633833981519152604482015290519081900360640190fd5b600f8190556040805182815233602082015281517fff783d200775c8efda1ff912a95c6b9561e641cc8695e015340f06a5b3024f12929181900390910190a150565b6000546001600160a01b031690565b61418b80620004a86000396000f3fe608060405234801561001057600080fd5b506004361061030c5760003560e01c8063905fc23c1161019d578063c099a7c4116100e9578063ea5416a5116100a2578063f5d7aa181161007c578063f5d7aa181461098f578063f75951ce146109bb578063f9d93099146109d8578063fad4ee94146109e05761030c565b8063ea5416a514610926578063ede808971461094c578063f2fde38b146109695761030c565b8063c099a7c414610822578063cf5c900814610848578063d40ffcf814610885578063d887b4e7146108a2578063e31a0079146108dd578063e875a613146109095761030c565b80639a751bbd11610156578063a98af76611610130578063a98af76614610793578063b3b3baa7146107b9578063bc0d753d146107df578063bd17de40146107fc5761030c565b80639a751bbd14610702578063a1e5e3f91461071f578063a74ae5da146107675761030c565b8063905fc23c14610667578063911e3f46146106a757806392924d85146106af578063936768ca146106b757806397f9e52a146106dd5780639a0271e1146106e55761030c565b806365c303bc1161025c5780637bde82f21161021557806388106323116101ef57806388106323146105f957806388c25607146106165780638990834b146106425780638da5cb5b1461065f5761030c565b80637bde82f2146105a857806381dc8119146105d45780638456cb59146105f15761030c565b806365c303bc1461050657806366db9a09146105235780636bac352b1461054f578063715018a614610557578063755495161461055f5780637ad226dc1461057c5761030c565b8063352c00f5116102c957806346aee52e116102a357806346aee52e146104935780634ddffea6146104b05780635b479d1a146104cd5780635c975abb146104fe5761030c565b8063352c00f5146104555780633f4ba83a1461045d578063455e42f2146104675761030c565b806304fbe03114610311578063065ef53e1461036d5780631af2a6a8146103755780631cf7955d146103925780631f38585f146103d0578063325a7a8414610409575b600080fd5b61035b600480360360e081101561032757600080fd5b506001600160a01b038135169060208101359060408101359060608101359060808101359060a08101359060c00135610a16565b60408051918252519081900360200190f35b61035b610e68565b61035b6004803603602081101561038b57600080fd5b5035610e6e565b6103af600480360360208110156103a857600080fd5b5035610ed0565b604051808260038111156103bf57fe5b815260200191505060405180910390f35b6103ed600480360360208110156103e657600080fd5b5035610ee5565b604080516001600160a01b039092168252519081900360200190f35b6104266004803603602081101561041f57600080fd5b5035610f10565b6040805160ff909616865293151560208601529115158484015260608401526080830152519081900360a00190f35b6103ed610f51565b610465610f60565b005b61035b6004803603604081101561047d57600080fd5b50803590602001356001600160a01b0316610fbb565b61035b600480360360208110156104a957600080fd5b503561122d565b6103ed600480360360208110156104c657600080fd5b503561123f565b6104ea600480360360208110156104e357600080fd5b503561125a565b604080519115158252519081900360200190f35b6104ea61129a565b6104656004803603602081101561051c57600080fd5b50356112aa565b6104656004803603604081101561053957600080fd5b50803590602001356001600160a01b0316611598565b6103ed611712565b610465611721565b6104656004803603602081101561057557600080fd5b50356117cd565b6104656004803603604081101561059257600080fd5b50803590602001356001600160a01b03166118be565b610465600480360360408110156105be57600080fd5b50803590602001356001600160a01b0316611b2c565b61035b600480360360208110156105ea57600080fd5b5035611e3e565b610465611e5f565b61035b6004803603602081101561060f57600080fd5b5035611eb8565b6104656004803603604081101561062c57600080fd5b50803590602001356001600160a01b0316611eda565b6104656004803603602081101561065857600080fd5b5035611f68565b6103ed61200c565b6104656004803603608081101561067d57600080fd5b5080359060208101356001600160a01b03908116916040810135909116906060013560ff1661201b565b61035b612221565b61035b612227565b6104ea600480360360408110156106cd57600080fd5b508035906020013560ff1661222d565b6103ed61226b565b6104ea600480360360208110156106fb57600080fd5b503561227a565b6103ed6004803603602081101561071857600080fd5b50356123b2565b61073c6004803603602081101561073557600080fd5b50356123d0565b6040805195865260208601949094528484019290925260608401526080830152519081900360a00190f35b6104656004803603606081101561077d57600080fd5b5080359060ff602082013516906040013561245d565b610465600480360360208110156107a957600080fd5b50356001600160a01b0316612604565b610465600480360360208110156107cf57600080fd5b50356001600160a01b0316612752565b61035b600480360360208110156107f557600080fd5b50356128a0565b6104656004803603602081101561081257600080fd5b50356001600160a01b0316612913565b6104656004803603602081101561083857600080fd5b50356001600160a01b0316612a61565b6104656004803603608081101561085e57600080fd5b5080359060ff602082013516906001600160a01b0360408201358116916060013516612baf565b6104656004803603602081101561089b57600080fd5b5035612ca6565b6108bf600480360360208110156108b857600080fd5b5035612e7f565b60408051938452602084019290925282820152519081900360600190f35b61035b600480360360408110156108f357600080fd5b50803590602001356001600160a01b0316612eb2565b6103ed6004803603602081101561091f57600080fd5b5035612f3b565b61035b6004803603602081101561093c57600080fd5b50356001600160a01b0316612f5b565b6104656004803603602081101561096257600080fd5b5035612f76565b6104656004803603602081101561097f57600080fd5b50356001600160a01b031661301a565b610465600480360360408110156109a557600080fd5b50803590602001356001600160a01b031661311c565b6103ed600480360360208110156109d157600080fd5b503561322a565b6103ed6132a8565b6109fd600480360360208110156109f657600080fd5b50356132b7565b6040805192835260208301919091528051918290030190f35b600060026001541415610a70576040805162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c00604482015290519081900360640190fd5b60026001556004546001600160a01b03163314610ac6576040805162461bcd60e51b815260206004820152600f60248201526e2aa720aaaa2427a924ad22a22fa12960891b604482015290519081900360640190fd5b60008211610b0e576040805162461bcd60e51b815260206004820152601060248201526f494e56414c49445f5155414e5449545960801b604482015290519081900360640190fd5b4261012c01861015610b5d576040805162461bcd60e51b8152602060048201526013602482015272494e56414c49445f56414c49444954595f544f60681b604482015290519081900360640190fd5b610b698761012c6132e1565b861015610ba75760405162461bcd60e51b81526004018080602001828103825260388152602001806140fe6038913960400191505060405180910390fd5b6001600160a01b038816600090815260076020908152604091829020805460018101909155825160608c811b6bffffffffffffffffffffffff1916828501526034820192909252605481018b9052607481018a90523090911b60948201528251808203608801815260a8909101909252815191012060095415610c9c57600081815260066020526040902060080154600980548392908110610c4557fe5b90600052602060002001541415610c9c576040805162461bcd60e51b815260206004820152601660248201527550524f4d4953455f414c52454144595f45584953545360501b604482015290519081900360640190fd5b604051806101200160405280828152602001600760008c6001600160a01b03166001600160a01b031681526020019081526020016000205481526020018a6001600160a01b0316815260200189815260200188815260200187815260200186815260200185815260200160098054905081525060066000838152602001908152602001600020600082015181600001556020820151816001015560408201518160020160006101000a8154816001600160a01b0302191690836001600160a01b03160217905550606082015181600301556080820151816004015560a0820151816005015560c0820151816006015560e0820151816007015561010082015181600801559050506009819080600181540180825580915050600190039060005260206000200160009091909190915055886001600160a01b0316600760008b6001600160a01b03166001600160a01b0316815260200190815260200160002054827fc05e9e3de4c67624681fddccb848a2f81797e05e1c09faf702ed3c526a6660e08b8b60016009805490500360405180848152602001838152602001828152602001935050505060405180910390a4610e57898285613342565b600180559998505050505050505050565b600e5490565b60006fffffffffffffffffffffffffffffffff19821680610eca576040805162461bcd60e51b8152602060048201526011602482015270494e4558495354454e545f535550504c5960781b604482015290519081900360640190fd5b92915050565b60009081526008602052604090205460ff1690565b6000908152600a6020908152604080832054835260069091529020600201546001600160a01b031690565b6000908152600b602052604090208054600282015460039092015460ff600160a01b8304811694600160a81b8404821694600160b01b909404909116929190565b6002546001600160a01b031690565b6004546001600160a01b03163314610fb1576040805162461bcd60e51b815260206004820152600f60248201526e2aa720aaaa2427a924ad22a22fa12960891b604482015290519081900360640190fd5b610fb96133f3565b565b6004546000906001600160a01b0316331461100f576040805162461bcd60e51b815260206004820152600f60248201526e2aa720aaaa2427a924ad22a22fa12960891b604482015290519081900360640190fd5b60026001541415611067576040805162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c00604482015290519081900360640190fd5b600260015561107461129a565b156110b9576040805162461bcd60e51b815260206004820152601060248201526f14185d5cd8589b194e881c185d5cd95960821b604482015290519081900360640190fd5b816001600160a01b03166110cc84610ee5565b6001600160a01b03161461111a576040805162461bcd60e51b815260206004820152601060248201526f2aa720aaaa2427a924ad22a22fa1a7a360811b604482015290519081900360640190fd5b60006111268484612eb2565b90506000811161116b576040805162461bcd60e51b815260206004820152600b60248201526a4f464645525f454d50545960a81b604482015290519081900360640190fd5b60025460408051637a94c56560e11b81526001600160a01b03868116600483015260248201889052604482018590529151919092169163f5298aca91606480830192600092919082900301818387803b1580156111c757600080fd5b505af11580156111db573d6000803e3d6000fd5b5050604080518781526001600160a01b038716602082015281517fd771b32487969df897bdfc40b573cff1c37f81bc0e62b60cacc027d0efd6d33f9450908190039091019150a1600180559392505050565b6000908152600a602052604090205490565b6000908152600b60205260409020546001600160a01b031690565b6000818152600b6020526040812054600160a81b900460ff168061129357506000828152600b6020526040902054600160b01b900460ff165b1592915050565b600054600160a01b900460ff1690565b806112ed576040805162461bcd60e51b815260206004820152600e60248201526d155394d41150d25192515117d25160921b604482015290519081900360640190fd5b6000818152600b6020526040812054600160a01b900460ff1690611312908290613496565b15611358576040805162461bcd60e51b81526020600482015260116024820152701053149150511657d19253905312569151607a1b604482015290519081900360640190fd5b60008060066000611368866128a0565b81526020808201929092526040908101600020815161012081018352815481526001820154938101939093526002808201546001600160a01b0316928401929092526003810154606084015260048101546080840152600581015460a0840152600681015460c0840152600781015460e0840152600801546101008301529091506113f4908490613496565b1561143857611404836001613496565b156114125760019150611433565b600f546000858152600b602052604090206003015401421061143357600191505b6114d6565b611443836001613496565b80156114645750600e546000858152600b6020526040902060020154014210155b1561147257600191506114d6565b61147b836134be565b8061148a575061148a836134e5565b156114b457600e546000858152600b602052604090206002015401421061143357600191506114d6565b6114bd836134fd565b156114d657600e5481608001510142106114d657600191505b8161151e576040805162461bcd60e51b8152602060048201526013602482015272494e4150504c494341424c455f53544154555360681b604482015290519081900360640190fd5b611529836000613511565b6000858152600b6020908152604091829020805460ff94909416600160a01b0260ff60a01b19909416939093179092558051868152339281019290925280517f28c953c622aa90e006382693080fb83e2add147a386446e0f24572c6b071adfa9281900390910190a150505050565b6115a061129a565b156115e5576040805162461bcd60e51b815260206004820152601060248201526f14185d5cd8589b194e881c185d5cd95960821b604482015290519081900360640190fd5b6004546001600160a01b03163314611636576040805162461bcd60e51b815260206004820152600f60248201526e2aa720aaaa2427a924ad22a22fa12960891b604482015290519081900360640190fd5b600354604080516331a9108f60e11b8152600481018590529051849284926001600160a01b0380851693921691636352211e91602480820192602092909190829003018186803b15801561168957600080fd5b505afa15801561169d573d6000803e3d6000fd5b505050506040513d60208110156116b357600080fd5b50516001600160a01b031614611701576040805162461bcd60e51b815260206004820152600e60248201526d2aa720aaaa2427a924ad22a22fab60911b604482015290519081900360640190fd5b61170c846002613533565b50505050565b6003546001600160a01b031690565b611729613b4b565b6001600160a01b031661173a61200c565b6001600160a01b031614611783576040805162461bcd60e51b81526020600482018190526024820152600080516020614136833981519152604482015290519081900360640190fd5b600080546040516001600160a01b03909116907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0908390a3600080546001600160a01b0319169055565b6005546001600160a01b0316331461181d576040805162461bcd60e51b815260206004820152600e60248201526d554e415554484f52495a45445f4360901b604482015290519081900360640190fd5b80611860576040805162461bcd60e51b815260206004820152600e60248201526d155394d41150d25192515117d25160921b604482015290519081900360640190fd5b6000818152600b60209081526040808320805460ff60a81b1916600160a81b17905580518481529182019290925281517ff570ce8ad3bc67469a0b8e53a32bba1edd0105fc668c1278225660d2291cc554929181900390910190a150565b6118c661129a565b1561190b576040805162461bcd60e51b815260206004820152601060248201526f14185d5cd8589b194e881c185d5cd95960821b604482015290519081900360640190fd5b6004546001600160a01b0316331461195c576040805162461bcd60e51b815260206004820152600f60248201526e2aa720aaaa2427a924ad22a22fa12960891b604482015290519081900360640190fd5b600354604080516331a9108f60e11b8152600481018590529051849284926001600160a01b0380851693921691636352211e91602480820192602092909190829003018186803b1580156119af57600080fd5b505afa1580156119c3573d6000803e3d6000fd5b505050506040513d60208110156119d957600080fd5b50516001600160a01b031614611a27576040805162461bcd60e51b815260206004820152600e60248201526d2aa720aaaa2427a924ad22a22fab60911b604482015290519081900360640190fd5b6000848152600b6020526040902054611a4990600160a01b900460ff16613b4f565b611a90576040805162461bcd60e51b8152602060048201526013602482015272494e4150504c494341424c455f53544154555360681b604482015290519081900360640190fd5b611a998461227a565b506000848152600b6020526040902042600282015554611ac490600160a01b900460ff166004613511565b6000858152600b6020908152604091829020805460ff94909416600160a01b0260ff60a01b1990941693909317909255805186815290517f66d163993c35c8d3a90f3fbce008096384de89ec441c60c9b9f79aaad36616ff929181900390910190a150505050565b611b3461129a565b15611b79576040805162461bcd60e51b815260206004820152601060248201526f14185d5cd8589b194e881c185d5cd95960821b604482015290519081900360640190fd5b6004546001600160a01b03163314611bca576040805162461bcd60e51b815260206004820152600f60248201526e2aa720aaaa2427a924ad22a22fa12960891b604482015290519081900360640190fd5b600354604080516331a9108f60e11b8152600481018590529051849284926001600160a01b0380851693921691636352211e91602480820192602092909190829003018186803b158015611c1d57600080fd5b505afa158015611c31573d6000803e3d6000fd5b505050506040513d6020811015611c4757600080fd5b50516001600160a01b031614611c95576040805162461bcd60e51b815260206004820152600e60248201526d2aa720aaaa2427a924ad22a22fab60911b604482015290519081900360640190fd5b6000848152600b6020526040902054611cb790600160a01b900460ff16613b4f565b611cfc576040805162461bcd60e51b81526020600482015260116024820152701053149150511657d41493d0d154d4d151607a1b604482015290519081900360640190fd5b611d058461227a565b50600060066000611d15876128a0565b815260208082019290925260409081016000908120825161012081018452815481526001820154818601526002808301546001600160a01b031682860152600383015460608301526004830154608083015260058084015460a0840152600684015460c0840152600784015460e08401526008909301546101008301528a8452600b9095529290912042938101939093559154909250611dc091600160a01b90910460ff1690613511565b6000868152600b6020908152604091829020805460ff94909416600160a01b0260ff60a01b1990941693909317909255825181518881526001600160a01b0388169381019390935282820152517f43a88bfc6f85aab9491c25f0ce50c4046d7cb7d4dc209b40914a2574d9855a5c9181900360600190a15050505050565b600060098281548110611e4d57fe5b90600052602060002001549050919050565b6004546001600160a01b03163314611eb0576040805162461bcd60e51b815260206004820152600f60248201526e2aa720aaaa2427a924ad22a22fa12960891b604482015290519081900360640190fd5b610fb9613b5d565b6000908152600a60209081526040808320548352600691829052909120015490565b6005546001600160a01b03163314611f2a576040805162461bcd60e51b815260206004820152600e60248201526d554e415554484f52495a45445f4360901b604482015290519081900360640190fd5b6000918252600a60209081526040808420548452600690915290912060020180546001600160a01b0319166001600160a01b03909216919091179055565b611f70613b4b565b6001600160a01b0316611f8161200c565b6001600160a01b031614611fca576040805162461bcd60e51b81526020600482018190526024820152600080516020614136833981519152604482015290519081900360640190fd5b600e8190556040805182815233602082015281517f08bf60d0e489e33912f3ba0f81f21c6f2ad2499a36dfebfb6cfbfefcc49f3cca929181900390910190a150565b6000546001600160a01b031690565b6004546001600160a01b0316331461206c576040805162461bcd60e51b815260206004820152600f60248201526e2aa720aaaa2427a924ad22a22fa12960891b604482015290519081900360640190fd5b600260015414156120c4576040805162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c00604482015290519081900360640190fd5b60026001556120d4838386613be6565b612125576040805162461bcd60e51b815260206004820152601b60248201527f554e535550504f525445445f4552433732315f52454345495645440000000000604482015290519081900360640190fd5b600061213085610ed0565b905081600381111561213e57fe5b81600381111561214a57fe5b1461219c576040805162461bcd60e51b815260206004820152601860248201527f496e636f7272656374205061796d656e74204d6574686f640000000000000000604482015290519081900360640190fd5b6121a7858585613d55565b60006121b4858588613f07565b9050857f4f17cb1f319637be1ba65b1b9008aff4c7e12e6d306ce8b5ec4c39827a952eca8287876121e4866128a0565b604080519485526001600160a01b03938416602086015291909216838201526060830191909152519081900360800190a250506001805550505050565b600d5490565b600f5490565b6000600182600281111561223d57fe5b6000858152600b6020526040902060019081015460ff9081169281169290921c929092161614905092915050565b6004546001600160a01b031690565b6000806006600061228a856128a0565b815260208082019290925260409081016000208151610120810183528154815260018201549381019390935260028101546001600160a01b03169183019190915260038101546060830181905260048201546080840152600582015460a0840152600682015460c0840152600782015460e084015260089091015461010083015290915042101561235a576040805162461bcd60e51b8152602060048201526015602482015274494e56414c49445f56414c49444954595f46524f4d60581b604482015290519081900360640190fd5b42816080015110156123a9576040805162461bcd60e51b8152602060048201526013602482015272494e56414c49445f56414c49444954595f544f60681b604482015290519081900360640190fd5b50600192915050565b6000908152600860205260409020600101546001600160a01b031690565b6000908152600660208181526040928390208351610120810185528154808252600183015493820184905260028301546001600160a01b031695820195909552600382015460608201819052600483015460808301819052600584015460a08401529483015460c0830152600783015460e083015260089092015461010090910181905293949193909291565b6005546001600160a01b031633146124ad576040805162461bcd60e51b815260206004820152600e60248201526d554e415554484f52495a45445f4360901b604482015290519081900360640190fd5b826124f0576040805162461bcd60e51b815260206004820152600e60248201526d155394d41150d25192515117d25160921b604482015290519081900360640190fd5b8160028111156124fc57fe5b6000848152600b602052604090206001908101805460ff19811660ff9485169390931b9084161790921617908190556125439061010090046001600160f81b0316826132e1565b6000848152600b6020526040902060010180546001600160f81b03929092166101000260ff90921691909117905561257a8361409f565b6000848152600b602052604090206001015461010090046001600160f81b031614156125ff576000838152600b6020908152604091829020805460ff60b01b1916600160b01b179055815185815260019181019190915281517ff570ce8ad3bc67469a0b8e53a32bba1edd0105fc668c1278225660d2291cc554929181900390910190a15b505050565b61260c613b4b565b6001600160a01b031661261d61200c565b6001600160a01b031614612666576040805162461bcd60e51b81526020600482018190526024820152600080516020614136833981519152604482015290519081900360640190fd5b806001600160a01b0381166126a7576040805162461bcd60e51b8152602060048201526002602482015261304160f01b604482015290519081900360640190fd5b6126af61129a565b6126f7576040805162461bcd60e51b815260206004820152601460248201527314185d5cd8589b194e881b9bdd081c185d5cd95960621b604482015290519081900360640190fd5b600280546001600160a01b0319166001600160a01b0384169081179091556040805191825233602083015280517f44c64b6c77fcb5df7b63c64b6346b9674961739187051adbf249bf8133974cad9281900390910190a15050565b61275a613b4b565b6001600160a01b031661276b61200c565b6001600160a01b0316146127b4576040805162461bcd60e51b81526020600482018190526024820152600080516020614136833981519152604482015290519081900360640190fd5b806001600160a01b0381166127f5576040805162461bcd60e51b8152602060048201526002602482015261304160f01b604482015290519081900360640190fd5b6127fd61129a565b612845576040805162461bcd60e51b815260206004820152601460248201527314185d5cd8589b194e881b9bdd081c185d5cd95960621b604482015290519081900360640190fd5b600380546001600160a01b0319166001600160a01b0384169081179091556040805191825233602083015280517fb54ffecf5d152884be12f7742b1a1f9e4baa17fc9e2e9586546450645a59a38d9281900390910190a15050565b6000816128e5576040805162461bcd60e51b815260206004820152600e60248201526d155394d41150d25192515117d25160921b604482015290519081900360640190fd5b60006128f083610e6e565b6000908152600a6020908152604080832054835260069091529020549392505050565b61291b613b4b565b6001600160a01b031661292c61200c565b6001600160a01b031614612975576040805162461bcd60e51b81526020600482018190526024820152600080516020614136833981519152604482015290519081900360640190fd5b61297d61129a565b6129c5576040805162461bcd60e51b815260206004820152601460248201527314185d5cd8589b194e881b9bdd081c185d5cd95960621b604482015290519081900360640190fd5b806001600160a01b038116612a06576040805162461bcd60e51b8152602060048201526002602482015261304160f01b604482015290519081900360640190fd5b600480546001600160a01b0319166001600160a01b0384169081179091556040805191825233602083015280517fac81fe7dd460bb5162a4a7d8fb92a13bd2baf450914fc6b1c4cc3180eba55af09281900390910190a15050565b612a69613b4b565b6001600160a01b0316612a7a61200c565b6001600160a01b031614612ac3576040805162461bcd60e51b81526020600482018190526024820152600080516020614136833981519152604482015290519081900360640190fd5b612acb61129a565b612b13576040805162461bcd60e51b815260206004820152601460248201527314185d5cd8589b194e881b9bdd081c185d5cd95960621b604482015290519081900360640190fd5b806001600160a01b038116612b54576040805162461bcd60e51b8152602060048201526002602482015261304160f01b604482015290519081900360640190fd5b600580546001600160a01b0319166001600160a01b0384169081179091556040805191825233602083015280517fcd124a0a6c3182c7bb77b8052823a4bf7d0a4c90016ffc4d53b969f98d3f8b889281900390910190a15050565b6004546001600160a01b03163314612c00576040805162461bcd60e51b815260206004820152600f60248201526e2aa720aaaa2427a924ad22a22fa12960891b604482015290519081900360640190fd5b6040518060600160405280846003811115612c1757fe5b81526001600160a01b03808516602080840191909152908416604092830152600087815260089091522081518154829060ff19166001836003811115612c5957fe5b021790555060208201518154610100600160a81b0319166101006001600160a01b0392831602178255604090920151600190910180546001600160a01b0319169190921617905550505050565b80612ce9576040805162461bcd60e51b815260206004820152600e60248201526d155394d41150d25192515117d25160921b604482015290519081900360640190fd5b600060066000612cf8846128a0565b815260208082019290925260409081016000208151610120810183528154815260018201549381019390935260028101546001600160a01b03169183019190915260038101546060830152600481015460808301819052600582015460a0840152600682015460c0840152600782015460e084015260089091015461010083015290915042118015612da757506000828152600b6020526040902054612da790600160a01b900460ff16613b4f565b612dee576040805162461bcd60e51b8152602060048201526013602482015272494e4150504c494341424c455f53544154555360681b604482015290519081900360640190fd5b6000828152600b6020526040902054612e1290600160a01b900460ff166003613511565b6000838152600b6020908152604091829020805460ff94909416600160a01b0260ff60a01b19909416939093179092558051848152339281019290925280517f0fbb6c447a631ca170fad3c540d76f932db4c444d82bc160f7e3eebc6a5f67409281900390910190a15050565b6000818152600a602090815260408083205483526006918290529091206005810154918101546007909101549193909250565b60025460408051627eeac760e11b81526001600160a01b038481166004830152602482018690529151600093929092169162fdd58e91604480820192602092909190829003018186803b158015612f0857600080fd5b505afa158015612f1c573d6000803e3d6000fd5b505050506040513d6020811015612f3257600080fd5b50519392505050565b60009081526008602052604090205461010090046001600160a01b031690565b6001600160a01b031660009081526007602052604090205490565b612f7e613b4b565b6001600160a01b0316612f8f61200c565b6001600160a01b031614612fd8576040805162461bcd60e51b81526020600482018190526024820152600080516020614136833981519152604482015290519081900360640190fd5b600f8190556040805182815233602082015281517fff783d200775c8efda1ff912a95c6b9561e641cc8695e015340f06a5b3024f12929181900390910190a150565b613022613b4b565b6001600160a01b031661303361200c565b6001600160a01b03161461307c576040805162461bcd60e51b81526020600482018190526024820152600080516020614136833981519152604482015290519081900360640190fd5b6001600160a01b0381166130c15760405162461bcd60e51b81526004018080602001828103825260268152602001806140d86026913960400191505060405180910390fd5b600080546040516001600160a01b03808516939216917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e091a3600080546001600160a01b0319166001600160a01b0392909216919091179055565b6004546001600160a01b0316331461316d576040805162461bcd60e51b815260206004820152600f60248201526e2aa720aaaa2427a924ad22a22fa12960891b604482015290519081900360640190fd5b61317561129a565b156131ba576040805162461bcd60e51b815260206004820152601060248201526f14185d5cd8589b194e881c185d5cd95960821b604482015290519081900360640190fd5b6000828152600b60205260409020546001600160a01b0382811691161461321b576040805162461bcd60e51b815260206004820152601060248201526f2aa720aaaa2427a924ad22a22fa1a7a360811b604482015290519081900360640190fd5b613226826001613533565b5050565b600354604080516331a9108f60e11b81526004810184905290516000926001600160a01b031691636352211e916024808301926020929190829003018186803b15801561327657600080fd5b505afa15801561328a573d6000803e3d6000fd5b505050506040513d60208110156132a057600080fd5b505192915050565b6005546001600160a01b031690565b6000908152600a602090815260408083205483526006909152902060058101546007909101549091565b60008282018381101561333b576040805162461bcd60e51b815260206004820152601b60248201527f536166654d6174683a206164646974696f6e206f766572666c6f770000000000604482015290519081900360640190fd5b9392505050565b600d805460010190819055600160ff1b608091821b176000818152600a6020526040808220869055600254815163731133e960e01b81526001600160a01b038981166004830152602482018690526044820188905260648201969096526084810184905291519294169163731133e99160a480820192879290919082900301818387803b1580156133d257600080fd5b505af11580156133e6573d6000803e3d6000fd5b5092979650505050505050565b6133fb61129a565b613443576040805162461bcd60e51b815260206004820152601460248201527314185d5cd8589b194e881b9bdd081c185d5cd95960621b604482015290519081900360640190fd5b6000805460ff60a01b191690557f5db9ee0a495bf2e6ff9c91a7834c1ba4fdd244a5e8aa4e537bd38aeae4b073aa613479613b4b565b604080516001600160a01b039092168252519081900360200190a1565b600060018260068111156134a657fe5b60ff168460ff16901c1660ff16600114905092915050565b60006134d66134cf60006006613511565b6005613511565b60ff168260ff16149050919050565b60006134d66134f660006006613511565b6004613511565b60006134d661350e60006006613511565b60035b600081600681111561351f57fe5b60ff16600160ff16901b8317905092915050565b6000828152600b6020526040812054600160a01b900460ff1690613558908290613496565b1561359e576040805162461bcd60e51b81526020600482015260116024820152701053149150511657d19253905312569151607a1b604482015290519081900360640190fd5b60608060028460068111156135af57fe5b141561361857604051806040016040528060128152602001711053149150511657d0d3d35413105253915160721b81525091506040518060400160405280601681526020017510d3d354131052539411549253d117d156141254915160521b8152509050613673565b604051806040016040528060138152602001721053149150511657d0d05390d1531190555315606a1b81525091506040518060400160405280601181526020017010d3d19411549253d117d1561412549151607a1b81525090505b61367d8385613496565b1582906137085760405162461bcd60e51b81526004018080602001828103825283818151815260200191508051906020019080838360005b838110156136cd5781810151838201526020016136b5565b50505050905090810190601f1680156136fa5780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b50600060066000613718886128a0565b815260208082019290925260409081016000208151610120810183528154815260018201549381019390935260028101546001600160a01b0316918301919091526003810154606083015260048101546080830152600581015460a0830152600681015460c0830152600781015460e08301526008015461010082015290506137a0846134be565b806137af57506137af846134e5565b1561382557600f54600e546000888152600b6020526040902060020154849291010142111561381f5760405162461bcd60e51b81526020600482018181528351602484015283519092839260449091019190850190808383600083156136cd5781810151838201526020016136b5565b50613a44565b61382e846134fd565b1561389057600f54600e5482608001510101421115829061381f5760405162461bcd60e51b81526020600482018181528351602484015283519092839260449091019190850190808383600083156136cd5781810151838201526020016136b5565b6000868152600b60205260409020546138dc90600160a01b900460ff1660028760068111156138bb57fe5b60ff16816138c557fe5b0660010160ff1660068111156138d757fe5b613496565b1561398257600060028660068111156138f157fe5b1461391157600f546000888152600b602052604090206003015401613928565b600e546000888152600b6020526040902060020154015b905080421115839061397b5760405162461bcd60e51b81526020600482018181528351602484015283519092839260449091019190850190808383600083156136cd5781810151838201526020016136b5565b5050613a44565b600285600681111561399057fe5b141580156139a257506139a284613b4f565b15613a0157600f54600e54826080015101014211156139fc576040805162461bcd60e51b815260206004820152601160248201527010d3d19411549253d117d1561412549151607a1b604482015290519081900360640190fd5b613a44565b6040805162461bcd60e51b8152602060048201526013602482015272494e4150504c494341424c455f53544154555360681b604482015290519081900360640190fd5b613a4e8486613511565b6000878152600b60205260409020805460ff92909216600160a01b0260ff60a01b199092169190911790556002856006811115613a8757fe5b1415613aea57613a98846001613496565b613ab2576000868152600b60205260409020426003909101555b6040805187815290517f0411cc6d1d8430de89b9f9fdd063617e55946cddb8538d3407f516882db594559181900360200190a1613b43565b613af5846002613496565b613b0f576000868152600b60205260409020426002909101555b6040805187815290517f125d1de9ad96c695c95a8de033058d2c00835a1e0cbf24b7fa3de72f603c87099181900360200190a15b505050505050565b3390565b60006134d660006006613511565b613b6561129a565b15613baa576040805162461bcd60e51b815260206004820152601060248201526f14185d5cd8589b194e881c185d5cd95960821b604482015290519081900360640190fd5b6000805460ff60a01b1916600160a01b1790557f62e78cea01bee320cd4e420270b5ea74000d11b0c9f74754ebdbfc544b05a258613479613b4b565b6000613bfa836001600160a01b03166140d1565b15613d4d57826001600160a01b031663150b7a02613c16613b4b565b86856040518463ffffffff1660e01b815260040180846001600160a01b03168152602001836001600160a01b0316815260200182815260200180602001828103825260008152602001945050505050602060405180830381600087803b158015613c7f57600080fd5b505af1925050508015613ca457506040513d6020811015613c9f57600080fd5b505160015b613d33573d808015613cd2576040519150601f19603f3d011682016040523d82523d6000602084013e613cd7565b606091505b508051613d2b576040805162461bcd60e51b815260206004820152601b60248201527f554e535550504f525445445f4552433732315f52454345495645440000000000604482015290519081900360640190fd5b805181602001fd5b6001600160e01b031916630a85bd0160e11b14905061333b565b50600161333b565b806001600160a01b038116613d96576040805162461bcd60e51b8152602060048201526002602482015261304160f01b604482015290519081900360640190fd5b83613dd9576040805162461bcd60e51b815260206004820152600e60248201526d155394d41150d25192515117d25160921b604482015290519081900360640190fd5b60025460408051627eeac760e11b81526001600160a01b038681166004830152602482018890529151600093929092169162fdd58e91604480820192602092909190829003018186803b158015613e2f57600080fd5b505afa158015613e43573d6000803e3d6000fd5b505050506040513d6020811015613e5957600080fd5b505111613e9b576040805162461bcd60e51b815260206004820152600b60248201526a4f464645525f454d50545960a81b604482015290519081900360640190fd5b6000848152600a6020908152604080832054808452600690925290912060040154421115613f00576040805162461bcd60e51b815260206004820152600d60248201526c13d191915497d1561412549151609a1b604482015290519081900360640190fd5b5050505050565b60025460408051637a94c56560e11b81526001600160a01b03868116600483015260248201859052600160448301529151600093929092169163f5298aca91606480820192869290919082900301818387803b158015613f6657600080fd5b505af1158015613f7a573d6000803e3d6000fd5b5050506000838152600c602090815260408083208054600101908190558617808452600b90925290912054909150613fbd90600160a01b900460ff166006613511565b6000828152600b60205260409020805461ffff60a81b1960ff93909316600160a01b0260ff60a01b1990911617919091169055613ff983610ee5565b6000828152600b6020908152604080832080546001600160a01b0319166001600160a01b0395861617905560035481516340c10f1960e01b815289861660048201526024810187905291519416936340c10f1993604480840194938390030190829087803b15801561406a57600080fd5b505af115801561407e573d6000803e3d6000fd5b505050506040513d602081101561409457600080fd5b509095945050505050565b6000806140ab836128a0565b6000818152600660208190526040909120600781015491015491925061333b91906132e1565b3b15159056fe4f776e61626c653a206e6577206f776e657220697320746865207a65726f206164647265737356414c49445f46524f4d5f4d5553545f42455f41545f4c454153545f355f4d494e555445535f4c4553535f5448414e5f56414c49445f544f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572a26469706673582212205d7a1a308dd4dd60884a3be5a8ee33e7c39f6aa8857cdea91761128882364e8564736f6c634300070600334f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65720000000000000000000000000a393aef6dbcd7e7088acf323f9d28b093b9ab5a000000000000000000000000244154f58e9bf6c15c3a09846efb7becfe92a880000000000000000000000000cf6d79e65c49a93a42dd8c474b46998eea4adec8000000000000000000000000de41a99562ada9ee04d9750c99a91c1181ebd875
Deployed ByteCode
0x608060405234801561001057600080fd5b506004361061030c5760003560e01c8063905fc23c1161019d578063c099a7c4116100e9578063ea5416a5116100a2578063f5d7aa181161007c578063f5d7aa181461098f578063f75951ce146109bb578063f9d93099146109d8578063fad4ee94146109e05761030c565b8063ea5416a514610926578063ede808971461094c578063f2fde38b146109695761030c565b8063c099a7c414610822578063cf5c900814610848578063d40ffcf814610885578063d887b4e7146108a2578063e31a0079146108dd578063e875a613146109095761030c565b80639a751bbd11610156578063a98af76611610130578063a98af76614610793578063b3b3baa7146107b9578063bc0d753d146107df578063bd17de40146107fc5761030c565b80639a751bbd14610702578063a1e5e3f91461071f578063a74ae5da146107675761030c565b8063905fc23c14610667578063911e3f46146106a757806392924d85146106af578063936768ca146106b757806397f9e52a146106dd5780639a0271e1146106e55761030c565b806365c303bc1161025c5780637bde82f21161021557806388106323116101ef57806388106323146105f957806388c25607146106165780638990834b146106425780638da5cb5b1461065f5761030c565b80637bde82f2146105a857806381dc8119146105d45780638456cb59146105f15761030c565b806365c303bc1461050657806366db9a09146105235780636bac352b1461054f578063715018a614610557578063755495161461055f5780637ad226dc1461057c5761030c565b8063352c00f5116102c957806346aee52e116102a357806346aee52e146104935780634ddffea6146104b05780635b479d1a146104cd5780635c975abb146104fe5761030c565b8063352c00f5146104555780633f4ba83a1461045d578063455e42f2146104675761030c565b806304fbe03114610311578063065ef53e1461036d5780631af2a6a8146103755780631cf7955d146103925780631f38585f146103d0578063325a7a8414610409575b600080fd5b61035b600480360360e081101561032757600080fd5b506001600160a01b038135169060208101359060408101359060608101359060808101359060a08101359060c00135610a16565b60408051918252519081900360200190f35b61035b610e68565b61035b6004803603602081101561038b57600080fd5b5035610e6e565b6103af600480360360208110156103a857600080fd5b5035610ed0565b604051808260038111156103bf57fe5b815260200191505060405180910390f35b6103ed600480360360208110156103e657600080fd5b5035610ee5565b604080516001600160a01b039092168252519081900360200190f35b6104266004803603602081101561041f57600080fd5b5035610f10565b6040805160ff909616865293151560208601529115158484015260608401526080830152519081900360a00190f35b6103ed610f51565b610465610f60565b005b61035b6004803603604081101561047d57600080fd5b50803590602001356001600160a01b0316610fbb565b61035b600480360360208110156104a957600080fd5b503561122d565b6103ed600480360360208110156104c657600080fd5b503561123f565b6104ea600480360360208110156104e357600080fd5b503561125a565b604080519115158252519081900360200190f35b6104ea61129a565b6104656004803603602081101561051c57600080fd5b50356112aa565b6104656004803603604081101561053957600080fd5b50803590602001356001600160a01b0316611598565b6103ed611712565b610465611721565b6104656004803603602081101561057557600080fd5b50356117cd565b6104656004803603604081101561059257600080fd5b50803590602001356001600160a01b03166118be565b610465600480360360408110156105be57600080fd5b50803590602001356001600160a01b0316611b2c565b61035b600480360360208110156105ea57600080fd5b5035611e3e565b610465611e5f565b61035b6004803603602081101561060f57600080fd5b5035611eb8565b6104656004803603604081101561062c57600080fd5b50803590602001356001600160a01b0316611eda565b6104656004803603602081101561065857600080fd5b5035611f68565b6103ed61200c565b6104656004803603608081101561067d57600080fd5b5080359060208101356001600160a01b03908116916040810135909116906060013560ff1661201b565b61035b612221565b61035b612227565b6104ea600480360360408110156106cd57600080fd5b508035906020013560ff1661222d565b6103ed61226b565b6104ea600480360360208110156106fb57600080fd5b503561227a565b6103ed6004803603602081101561071857600080fd5b50356123b2565b61073c6004803603602081101561073557600080fd5b50356123d0565b6040805195865260208601949094528484019290925260608401526080830152519081900360a00190f35b6104656004803603606081101561077d57600080fd5b5080359060ff602082013516906040013561245d565b610465600480360360208110156107a957600080fd5b50356001600160a01b0316612604565b610465600480360360208110156107cf57600080fd5b50356001600160a01b0316612752565b61035b600480360360208110156107f557600080fd5b50356128a0565b6104656004803603602081101561081257600080fd5b50356001600160a01b0316612913565b6104656004803603602081101561083857600080fd5b50356001600160a01b0316612a61565b6104656004803603608081101561085e57600080fd5b5080359060ff602082013516906001600160a01b0360408201358116916060013516612baf565b6104656004803603602081101561089b57600080fd5b5035612ca6565b6108bf600480360360208110156108b857600080fd5b5035612e7f565b60408051938452602084019290925282820152519081900360600190f35b61035b600480360360408110156108f357600080fd5b50803590602001356001600160a01b0316612eb2565b6103ed6004803603602081101561091f57600080fd5b5035612f3b565b61035b6004803603602081101561093c57600080fd5b50356001600160a01b0316612f5b565b6104656004803603602081101561096257600080fd5b5035612f76565b6104656004803603602081101561097f57600080fd5b50356001600160a01b031661301a565b610465600480360360408110156109a557600080fd5b50803590602001356001600160a01b031661311c565b6103ed600480360360208110156109d157600080fd5b503561322a565b6103ed6132a8565b6109fd600480360360208110156109f657600080fd5b50356132b7565b6040805192835260208301919091528051918290030190f35b600060026001541415610a70576040805162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c00604482015290519081900360640190fd5b60026001556004546001600160a01b03163314610ac6576040805162461bcd60e51b815260206004820152600f60248201526e2aa720aaaa2427a924ad22a22fa12960891b604482015290519081900360640190fd5b60008211610b0e576040805162461bcd60e51b815260206004820152601060248201526f494e56414c49445f5155414e5449545960801b604482015290519081900360640190fd5b4261012c01861015610b5d576040805162461bcd60e51b8152602060048201526013602482015272494e56414c49445f56414c49444954595f544f60681b604482015290519081900360640190fd5b610b698761012c6132e1565b861015610ba75760405162461bcd60e51b81526004018080602001828103825260388152602001806140fe6038913960400191505060405180910390fd5b6001600160a01b038816600090815260076020908152604091829020805460018101909155825160608c811b6bffffffffffffffffffffffff1916828501526034820192909252605481018b9052607481018a90523090911b60948201528251808203608801815260a8909101909252815191012060095415610c9c57600081815260066020526040902060080154600980548392908110610c4557fe5b90600052602060002001541415610c9c576040805162461bcd60e51b815260206004820152601660248201527550524f4d4953455f414c52454144595f45584953545360501b604482015290519081900360640190fd5b604051806101200160405280828152602001600760008c6001600160a01b03166001600160a01b031681526020019081526020016000205481526020018a6001600160a01b0316815260200189815260200188815260200187815260200186815260200185815260200160098054905081525060066000838152602001908152602001600020600082015181600001556020820151816001015560408201518160020160006101000a8154816001600160a01b0302191690836001600160a01b03160217905550606082015181600301556080820151816004015560a0820151816005015560c0820151816006015560e0820151816007015561010082015181600801559050506009819080600181540180825580915050600190039060005260206000200160009091909190915055886001600160a01b0316600760008b6001600160a01b03166001600160a01b0316815260200190815260200160002054827fc05e9e3de4c67624681fddccb848a2f81797e05e1c09faf702ed3c526a6660e08b8b60016009805490500360405180848152602001838152602001828152602001935050505060405180910390a4610e57898285613342565b600180559998505050505050505050565b600e5490565b60006fffffffffffffffffffffffffffffffff19821680610eca576040805162461bcd60e51b8152602060048201526011602482015270494e4558495354454e545f535550504c5960781b604482015290519081900360640190fd5b92915050565b60009081526008602052604090205460ff1690565b6000908152600a6020908152604080832054835260069091529020600201546001600160a01b031690565b6000908152600b602052604090208054600282015460039092015460ff600160a01b8304811694600160a81b8404821694600160b01b909404909116929190565b6002546001600160a01b031690565b6004546001600160a01b03163314610fb1576040805162461bcd60e51b815260206004820152600f60248201526e2aa720aaaa2427a924ad22a22fa12960891b604482015290519081900360640190fd5b610fb96133f3565b565b6004546000906001600160a01b0316331461100f576040805162461bcd60e51b815260206004820152600f60248201526e2aa720aaaa2427a924ad22a22fa12960891b604482015290519081900360640190fd5b60026001541415611067576040805162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c00604482015290519081900360640190fd5b600260015561107461129a565b156110b9576040805162461bcd60e51b815260206004820152601060248201526f14185d5cd8589b194e881c185d5cd95960821b604482015290519081900360640190fd5b816001600160a01b03166110cc84610ee5565b6001600160a01b03161461111a576040805162461bcd60e51b815260206004820152601060248201526f2aa720aaaa2427a924ad22a22fa1a7a360811b604482015290519081900360640190fd5b60006111268484612eb2565b90506000811161116b576040805162461bcd60e51b815260206004820152600b60248201526a4f464645525f454d50545960a81b604482015290519081900360640190fd5b60025460408051637a94c56560e11b81526001600160a01b03868116600483015260248201889052604482018590529151919092169163f5298aca91606480830192600092919082900301818387803b1580156111c757600080fd5b505af11580156111db573d6000803e3d6000fd5b5050604080518781526001600160a01b038716602082015281517fd771b32487969df897bdfc40b573cff1c37f81bc0e62b60cacc027d0efd6d33f9450908190039091019150a1600180559392505050565b6000908152600a602052604090205490565b6000908152600b60205260409020546001600160a01b031690565b6000818152600b6020526040812054600160a81b900460ff168061129357506000828152600b6020526040902054600160b01b900460ff165b1592915050565b600054600160a01b900460ff1690565b806112ed576040805162461bcd60e51b815260206004820152600e60248201526d155394d41150d25192515117d25160921b604482015290519081900360640190fd5b6000818152600b6020526040812054600160a01b900460ff1690611312908290613496565b15611358576040805162461bcd60e51b81526020600482015260116024820152701053149150511657d19253905312569151607a1b604482015290519081900360640190fd5b60008060066000611368866128a0565b81526020808201929092526040908101600020815161012081018352815481526001820154938101939093526002808201546001600160a01b0316928401929092526003810154606084015260048101546080840152600581015460a0840152600681015460c0840152600781015460e0840152600801546101008301529091506113f4908490613496565b1561143857611404836001613496565b156114125760019150611433565b600f546000858152600b602052604090206003015401421061143357600191505b6114d6565b611443836001613496565b80156114645750600e546000858152600b6020526040902060020154014210155b1561147257600191506114d6565b61147b836134be565b8061148a575061148a836134e5565b156114b457600e546000858152600b602052604090206002015401421061143357600191506114d6565b6114bd836134fd565b156114d657600e5481608001510142106114d657600191505b8161151e576040805162461bcd60e51b8152602060048201526013602482015272494e4150504c494341424c455f53544154555360681b604482015290519081900360640190fd5b611529836000613511565b6000858152600b6020908152604091829020805460ff94909416600160a01b0260ff60a01b19909416939093179092558051868152339281019290925280517f28c953c622aa90e006382693080fb83e2add147a386446e0f24572c6b071adfa9281900390910190a150505050565b6115a061129a565b156115e5576040805162461bcd60e51b815260206004820152601060248201526f14185d5cd8589b194e881c185d5cd95960821b604482015290519081900360640190fd5b6004546001600160a01b03163314611636576040805162461bcd60e51b815260206004820152600f60248201526e2aa720aaaa2427a924ad22a22fa12960891b604482015290519081900360640190fd5b600354604080516331a9108f60e11b8152600481018590529051849284926001600160a01b0380851693921691636352211e91602480820192602092909190829003018186803b15801561168957600080fd5b505afa15801561169d573d6000803e3d6000fd5b505050506040513d60208110156116b357600080fd5b50516001600160a01b031614611701576040805162461bcd60e51b815260206004820152600e60248201526d2aa720aaaa2427a924ad22a22fab60911b604482015290519081900360640190fd5b61170c846002613533565b50505050565b6003546001600160a01b031690565b611729613b4b565b6001600160a01b031661173a61200c565b6001600160a01b031614611783576040805162461bcd60e51b81526020600482018190526024820152600080516020614136833981519152604482015290519081900360640190fd5b600080546040516001600160a01b03909116907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0908390a3600080546001600160a01b0319169055565b6005546001600160a01b0316331461181d576040805162461bcd60e51b815260206004820152600e60248201526d554e415554484f52495a45445f4360901b604482015290519081900360640190fd5b80611860576040805162461bcd60e51b815260206004820152600e60248201526d155394d41150d25192515117d25160921b604482015290519081900360640190fd5b6000818152600b60209081526040808320805460ff60a81b1916600160a81b17905580518481529182019290925281517ff570ce8ad3bc67469a0b8e53a32bba1edd0105fc668c1278225660d2291cc554929181900390910190a150565b6118c661129a565b1561190b576040805162461bcd60e51b815260206004820152601060248201526f14185d5cd8589b194e881c185d5cd95960821b604482015290519081900360640190fd5b6004546001600160a01b0316331461195c576040805162461bcd60e51b815260206004820152600f60248201526e2aa720aaaa2427a924ad22a22fa12960891b604482015290519081900360640190fd5b600354604080516331a9108f60e11b8152600481018590529051849284926001600160a01b0380851693921691636352211e91602480820192602092909190829003018186803b1580156119af57600080fd5b505afa1580156119c3573d6000803e3d6000fd5b505050506040513d60208110156119d957600080fd5b50516001600160a01b031614611a27576040805162461bcd60e51b815260206004820152600e60248201526d2aa720aaaa2427a924ad22a22fab60911b604482015290519081900360640190fd5b6000848152600b6020526040902054611a4990600160a01b900460ff16613b4f565b611a90576040805162461bcd60e51b8152602060048201526013602482015272494e4150504c494341424c455f53544154555360681b604482015290519081900360640190fd5b611a998461227a565b506000848152600b6020526040902042600282015554611ac490600160a01b900460ff166004613511565b6000858152600b6020908152604091829020805460ff94909416600160a01b0260ff60a01b1990941693909317909255805186815290517f66d163993c35c8d3a90f3fbce008096384de89ec441c60c9b9f79aaad36616ff929181900390910190a150505050565b611b3461129a565b15611b79576040805162461bcd60e51b815260206004820152601060248201526f14185d5cd8589b194e881c185d5cd95960821b604482015290519081900360640190fd5b6004546001600160a01b03163314611bca576040805162461bcd60e51b815260206004820152600f60248201526e2aa720aaaa2427a924ad22a22fa12960891b604482015290519081900360640190fd5b600354604080516331a9108f60e11b8152600481018590529051849284926001600160a01b0380851693921691636352211e91602480820192602092909190829003018186803b158015611c1d57600080fd5b505afa158015611c31573d6000803e3d6000fd5b505050506040513d6020811015611c4757600080fd5b50516001600160a01b031614611c95576040805162461bcd60e51b815260206004820152600e60248201526d2aa720aaaa2427a924ad22a22fab60911b604482015290519081900360640190fd5b6000848152600b6020526040902054611cb790600160a01b900460ff16613b4f565b611cfc576040805162461bcd60e51b81526020600482015260116024820152701053149150511657d41493d0d154d4d151607a1b604482015290519081900360640190fd5b611d058461227a565b50600060066000611d15876128a0565b815260208082019290925260409081016000908120825161012081018452815481526001820154818601526002808301546001600160a01b031682860152600383015460608301526004830154608083015260058084015460a0840152600684015460c0840152600784015460e08401526008909301546101008301528a8452600b9095529290912042938101939093559154909250611dc091600160a01b90910460ff1690613511565b6000868152600b6020908152604091829020805460ff94909416600160a01b0260ff60a01b1990941693909317909255825181518881526001600160a01b0388169381019390935282820152517f43a88bfc6f85aab9491c25f0ce50c4046d7cb7d4dc209b40914a2574d9855a5c9181900360600190a15050505050565b600060098281548110611e4d57fe5b90600052602060002001549050919050565b6004546001600160a01b03163314611eb0576040805162461bcd60e51b815260206004820152600f60248201526e2aa720aaaa2427a924ad22a22fa12960891b604482015290519081900360640190fd5b610fb9613b5d565b6000908152600a60209081526040808320548352600691829052909120015490565b6005546001600160a01b03163314611f2a576040805162461bcd60e51b815260206004820152600e60248201526d554e415554484f52495a45445f4360901b604482015290519081900360640190fd5b6000918252600a60209081526040808420548452600690915290912060020180546001600160a01b0319166001600160a01b03909216919091179055565b611f70613b4b565b6001600160a01b0316611f8161200c565b6001600160a01b031614611fca576040805162461bcd60e51b81526020600482018190526024820152600080516020614136833981519152604482015290519081900360640190fd5b600e8190556040805182815233602082015281517f08bf60d0e489e33912f3ba0f81f21c6f2ad2499a36dfebfb6cfbfefcc49f3cca929181900390910190a150565b6000546001600160a01b031690565b6004546001600160a01b0316331461206c576040805162461bcd60e51b815260206004820152600f60248201526e2aa720aaaa2427a924ad22a22fa12960891b604482015290519081900360640190fd5b600260015414156120c4576040805162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c00604482015290519081900360640190fd5b60026001556120d4838386613be6565b612125576040805162461bcd60e51b815260206004820152601b60248201527f554e535550504f525445445f4552433732315f52454345495645440000000000604482015290519081900360640190fd5b600061213085610ed0565b905081600381111561213e57fe5b81600381111561214a57fe5b1461219c576040805162461bcd60e51b815260206004820152601860248201527f496e636f7272656374205061796d656e74204d6574686f640000000000000000604482015290519081900360640190fd5b6121a7858585613d55565b60006121b4858588613f07565b9050857f4f17cb1f319637be1ba65b1b9008aff4c7e12e6d306ce8b5ec4c39827a952eca8287876121e4866128a0565b604080519485526001600160a01b03938416602086015291909216838201526060830191909152519081900360800190a250506001805550505050565b600d5490565b600f5490565b6000600182600281111561223d57fe5b6000858152600b6020526040902060019081015460ff9081169281169290921c929092161614905092915050565b6004546001600160a01b031690565b6000806006600061228a856128a0565b815260208082019290925260409081016000208151610120810183528154815260018201549381019390935260028101546001600160a01b03169183019190915260038101546060830181905260048201546080840152600582015460a0840152600682015460c0840152600782015460e084015260089091015461010083015290915042101561235a576040805162461bcd60e51b8152602060048201526015602482015274494e56414c49445f56414c49444954595f46524f4d60581b604482015290519081900360640190fd5b42816080015110156123a9576040805162461bcd60e51b8152602060048201526013602482015272494e56414c49445f56414c49444954595f544f60681b604482015290519081900360640190fd5b50600192915050565b6000908152600860205260409020600101546001600160a01b031690565b6000908152600660208181526040928390208351610120810185528154808252600183015493820184905260028301546001600160a01b031695820195909552600382015460608201819052600483015460808301819052600584015460a08401529483015460c0830152600783015460e083015260089092015461010090910181905293949193909291565b6005546001600160a01b031633146124ad576040805162461bcd60e51b815260206004820152600e60248201526d554e415554484f52495a45445f4360901b604482015290519081900360640190fd5b826124f0576040805162461bcd60e51b815260206004820152600e60248201526d155394d41150d25192515117d25160921b604482015290519081900360640190fd5b8160028111156124fc57fe5b6000848152600b602052604090206001908101805460ff19811660ff9485169390931b9084161790921617908190556125439061010090046001600160f81b0316826132e1565b6000848152600b6020526040902060010180546001600160f81b03929092166101000260ff90921691909117905561257a8361409f565b6000848152600b602052604090206001015461010090046001600160f81b031614156125ff576000838152600b6020908152604091829020805460ff60b01b1916600160b01b179055815185815260019181019190915281517ff570ce8ad3bc67469a0b8e53a32bba1edd0105fc668c1278225660d2291cc554929181900390910190a15b505050565b61260c613b4b565b6001600160a01b031661261d61200c565b6001600160a01b031614612666576040805162461bcd60e51b81526020600482018190526024820152600080516020614136833981519152604482015290519081900360640190fd5b806001600160a01b0381166126a7576040805162461bcd60e51b8152602060048201526002602482015261304160f01b604482015290519081900360640190fd5b6126af61129a565b6126f7576040805162461bcd60e51b815260206004820152601460248201527314185d5cd8589b194e881b9bdd081c185d5cd95960621b604482015290519081900360640190fd5b600280546001600160a01b0319166001600160a01b0384169081179091556040805191825233602083015280517f44c64b6c77fcb5df7b63c64b6346b9674961739187051adbf249bf8133974cad9281900390910190a15050565b61275a613b4b565b6001600160a01b031661276b61200c565b6001600160a01b0316146127b4576040805162461bcd60e51b81526020600482018190526024820152600080516020614136833981519152604482015290519081900360640190fd5b806001600160a01b0381166127f5576040805162461bcd60e51b8152602060048201526002602482015261304160f01b604482015290519081900360640190fd5b6127fd61129a565b612845576040805162461bcd60e51b815260206004820152601460248201527314185d5cd8589b194e881b9bdd081c185d5cd95960621b604482015290519081900360640190fd5b600380546001600160a01b0319166001600160a01b0384169081179091556040805191825233602083015280517fb54ffecf5d152884be12f7742b1a1f9e4baa17fc9e2e9586546450645a59a38d9281900390910190a15050565b6000816128e5576040805162461bcd60e51b815260206004820152600e60248201526d155394d41150d25192515117d25160921b604482015290519081900360640190fd5b60006128f083610e6e565b6000908152600a6020908152604080832054835260069091529020549392505050565b61291b613b4b565b6001600160a01b031661292c61200c565b6001600160a01b031614612975576040805162461bcd60e51b81526020600482018190526024820152600080516020614136833981519152604482015290519081900360640190fd5b61297d61129a565b6129c5576040805162461bcd60e51b815260206004820152601460248201527314185d5cd8589b194e881b9bdd081c185d5cd95960621b604482015290519081900360640190fd5b806001600160a01b038116612a06576040805162461bcd60e51b8152602060048201526002602482015261304160f01b604482015290519081900360640190fd5b600480546001600160a01b0319166001600160a01b0384169081179091556040805191825233602083015280517fac81fe7dd460bb5162a4a7d8fb92a13bd2baf450914fc6b1c4cc3180eba55af09281900390910190a15050565b612a69613b4b565b6001600160a01b0316612a7a61200c565b6001600160a01b031614612ac3576040805162461bcd60e51b81526020600482018190526024820152600080516020614136833981519152604482015290519081900360640190fd5b612acb61129a565b612b13576040805162461bcd60e51b815260206004820152601460248201527314185d5cd8589b194e881b9bdd081c185d5cd95960621b604482015290519081900360640190fd5b806001600160a01b038116612b54576040805162461bcd60e51b8152602060048201526002602482015261304160f01b604482015290519081900360640190fd5b600580546001600160a01b0319166001600160a01b0384169081179091556040805191825233602083015280517fcd124a0a6c3182c7bb77b8052823a4bf7d0a4c90016ffc4d53b969f98d3f8b889281900390910190a15050565b6004546001600160a01b03163314612c00576040805162461bcd60e51b815260206004820152600f60248201526e2aa720aaaa2427a924ad22a22fa12960891b604482015290519081900360640190fd5b6040518060600160405280846003811115612c1757fe5b81526001600160a01b03808516602080840191909152908416604092830152600087815260089091522081518154829060ff19166001836003811115612c5957fe5b021790555060208201518154610100600160a81b0319166101006001600160a01b0392831602178255604090920151600190910180546001600160a01b0319169190921617905550505050565b80612ce9576040805162461bcd60e51b815260206004820152600e60248201526d155394d41150d25192515117d25160921b604482015290519081900360640190fd5b600060066000612cf8846128a0565b815260208082019290925260409081016000208151610120810183528154815260018201549381019390935260028101546001600160a01b03169183019190915260038101546060830152600481015460808301819052600582015460a0840152600682015460c0840152600782015460e084015260089091015461010083015290915042118015612da757506000828152600b6020526040902054612da790600160a01b900460ff16613b4f565b612dee576040805162461bcd60e51b8152602060048201526013602482015272494e4150504c494341424c455f53544154555360681b604482015290519081900360640190fd5b6000828152600b6020526040902054612e1290600160a01b900460ff166003613511565b6000838152600b6020908152604091829020805460ff94909416600160a01b0260ff60a01b19909416939093179092558051848152339281019290925280517f0fbb6c447a631ca170fad3c540d76f932db4c444d82bc160f7e3eebc6a5f67409281900390910190a15050565b6000818152600a602090815260408083205483526006918290529091206005810154918101546007909101549193909250565b60025460408051627eeac760e11b81526001600160a01b038481166004830152602482018690529151600093929092169162fdd58e91604480820192602092909190829003018186803b158015612f0857600080fd5b505afa158015612f1c573d6000803e3d6000fd5b505050506040513d6020811015612f3257600080fd5b50519392505050565b60009081526008602052604090205461010090046001600160a01b031690565b6001600160a01b031660009081526007602052604090205490565b612f7e613b4b565b6001600160a01b0316612f8f61200c565b6001600160a01b031614612fd8576040805162461bcd60e51b81526020600482018190526024820152600080516020614136833981519152604482015290519081900360640190fd5b600f8190556040805182815233602082015281517fff783d200775c8efda1ff912a95c6b9561e641cc8695e015340f06a5b3024f12929181900390910190a150565b613022613b4b565b6001600160a01b031661303361200c565b6001600160a01b03161461307c576040805162461bcd60e51b81526020600482018190526024820152600080516020614136833981519152604482015290519081900360640190fd5b6001600160a01b0381166130c15760405162461bcd60e51b81526004018080602001828103825260268152602001806140d86026913960400191505060405180910390fd5b600080546040516001600160a01b03808516939216917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e091a3600080546001600160a01b0319166001600160a01b0392909216919091179055565b6004546001600160a01b0316331461316d576040805162461bcd60e51b815260206004820152600f60248201526e2aa720aaaa2427a924ad22a22fa12960891b604482015290519081900360640190fd5b61317561129a565b156131ba576040805162461bcd60e51b815260206004820152601060248201526f14185d5cd8589b194e881c185d5cd95960821b604482015290519081900360640190fd5b6000828152600b60205260409020546001600160a01b0382811691161461321b576040805162461bcd60e51b815260206004820152601060248201526f2aa720aaaa2427a924ad22a22fa1a7a360811b604482015290519081900360640190fd5b613226826001613533565b5050565b600354604080516331a9108f60e11b81526004810184905290516000926001600160a01b031691636352211e916024808301926020929190829003018186803b15801561327657600080fd5b505afa15801561328a573d6000803e3d6000fd5b505050506040513d60208110156132a057600080fd5b505192915050565b6005546001600160a01b031690565b6000908152600a602090815260408083205483526006909152902060058101546007909101549091565b60008282018381101561333b576040805162461bcd60e51b815260206004820152601b60248201527f536166654d6174683a206164646974696f6e206f766572666c6f770000000000604482015290519081900360640190fd5b9392505050565b600d805460010190819055600160ff1b608091821b176000818152600a6020526040808220869055600254815163731133e960e01b81526001600160a01b038981166004830152602482018690526044820188905260648201969096526084810184905291519294169163731133e99160a480820192879290919082900301818387803b1580156133d257600080fd5b505af11580156133e6573d6000803e3d6000fd5b5092979650505050505050565b6133fb61129a565b613443576040805162461bcd60e51b815260206004820152601460248201527314185d5cd8589b194e881b9bdd081c185d5cd95960621b604482015290519081900360640190fd5b6000805460ff60a01b191690557f5db9ee0a495bf2e6ff9c91a7834c1ba4fdd244a5e8aa4e537bd38aeae4b073aa613479613b4b565b604080516001600160a01b039092168252519081900360200190a1565b600060018260068111156134a657fe5b60ff168460ff16901c1660ff16600114905092915050565b60006134d66134cf60006006613511565b6005613511565b60ff168260ff16149050919050565b60006134d66134f660006006613511565b6004613511565b60006134d661350e60006006613511565b60035b600081600681111561351f57fe5b60ff16600160ff16901b8317905092915050565b6000828152600b6020526040812054600160a01b900460ff1690613558908290613496565b1561359e576040805162461bcd60e51b81526020600482015260116024820152701053149150511657d19253905312569151607a1b604482015290519081900360640190fd5b60608060028460068111156135af57fe5b141561361857604051806040016040528060128152602001711053149150511657d0d3d35413105253915160721b81525091506040518060400160405280601681526020017510d3d354131052539411549253d117d156141254915160521b8152509050613673565b604051806040016040528060138152602001721053149150511657d0d05390d1531190555315606a1b81525091506040518060400160405280601181526020017010d3d19411549253d117d1561412549151607a1b81525090505b61367d8385613496565b1582906137085760405162461bcd60e51b81526004018080602001828103825283818151815260200191508051906020019080838360005b838110156136cd5781810151838201526020016136b5565b50505050905090810190601f1680156136fa5780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b50600060066000613718886128a0565b815260208082019290925260409081016000208151610120810183528154815260018201549381019390935260028101546001600160a01b0316918301919091526003810154606083015260048101546080830152600581015460a0830152600681015460c0830152600781015460e08301526008015461010082015290506137a0846134be565b806137af57506137af846134e5565b1561382557600f54600e546000888152600b6020526040902060020154849291010142111561381f5760405162461bcd60e51b81526020600482018181528351602484015283519092839260449091019190850190808383600083156136cd5781810151838201526020016136b5565b50613a44565b61382e846134fd565b1561389057600f54600e5482608001510101421115829061381f5760405162461bcd60e51b81526020600482018181528351602484015283519092839260449091019190850190808383600083156136cd5781810151838201526020016136b5565b6000868152600b60205260409020546138dc90600160a01b900460ff1660028760068111156138bb57fe5b60ff16816138c557fe5b0660010160ff1660068111156138d757fe5b613496565b1561398257600060028660068111156138f157fe5b1461391157600f546000888152600b602052604090206003015401613928565b600e546000888152600b6020526040902060020154015b905080421115839061397b5760405162461bcd60e51b81526020600482018181528351602484015283519092839260449091019190850190808383600083156136cd5781810151838201526020016136b5565b5050613a44565b600285600681111561399057fe5b141580156139a257506139a284613b4f565b15613a0157600f54600e54826080015101014211156139fc576040805162461bcd60e51b815260206004820152601160248201527010d3d19411549253d117d1561412549151607a1b604482015290519081900360640190fd5b613a44565b6040805162461bcd60e51b8152602060048201526013602482015272494e4150504c494341424c455f53544154555360681b604482015290519081900360640190fd5b613a4e8486613511565b6000878152600b60205260409020805460ff92909216600160a01b0260ff60a01b199092169190911790556002856006811115613a8757fe5b1415613aea57613a98846001613496565b613ab2576000868152600b60205260409020426003909101555b6040805187815290517f0411cc6d1d8430de89b9f9fdd063617e55946cddb8538d3407f516882db594559181900360200190a1613b43565b613af5846002613496565b613b0f576000868152600b60205260409020426002909101555b6040805187815290517f125d1de9ad96c695c95a8de033058d2c00835a1e0cbf24b7fa3de72f603c87099181900360200190a15b505050505050565b3390565b60006134d660006006613511565b613b6561129a565b15613baa576040805162461bcd60e51b815260206004820152601060248201526f14185d5cd8589b194e881c185d5cd95960821b604482015290519081900360640190fd5b6000805460ff60a01b1916600160a01b1790557f62e78cea01bee320cd4e420270b5ea74000d11b0c9f74754ebdbfc544b05a258613479613b4b565b6000613bfa836001600160a01b03166140d1565b15613d4d57826001600160a01b031663150b7a02613c16613b4b565b86856040518463ffffffff1660e01b815260040180846001600160a01b03168152602001836001600160a01b0316815260200182815260200180602001828103825260008152602001945050505050602060405180830381600087803b158015613c7f57600080fd5b505af1925050508015613ca457506040513d6020811015613c9f57600080fd5b505160015b613d33573d808015613cd2576040519150601f19603f3d011682016040523d82523d6000602084013e613cd7565b606091505b508051613d2b576040805162461bcd60e51b815260206004820152601b60248201527f554e535550504f525445445f4552433732315f52454345495645440000000000604482015290519081900360640190fd5b805181602001fd5b6001600160e01b031916630a85bd0160e11b14905061333b565b50600161333b565b806001600160a01b038116613d96576040805162461bcd60e51b8152602060048201526002602482015261304160f01b604482015290519081900360640190fd5b83613dd9576040805162461bcd60e51b815260206004820152600e60248201526d155394d41150d25192515117d25160921b604482015290519081900360640190fd5b60025460408051627eeac760e11b81526001600160a01b038681166004830152602482018890529151600093929092169162fdd58e91604480820192602092909190829003018186803b158015613e2f57600080fd5b505afa158015613e43573d6000803e3d6000fd5b505050506040513d6020811015613e5957600080fd5b505111613e9b576040805162461bcd60e51b815260206004820152600b60248201526a4f464645525f454d50545960a81b604482015290519081900360640190fd5b6000848152600a6020908152604080832054808452600690925290912060040154421115613f00576040805162461bcd60e51b815260206004820152600d60248201526c13d191915497d1561412549151609a1b604482015290519081900360640190fd5b5050505050565b60025460408051637a94c56560e11b81526001600160a01b03868116600483015260248201859052600160448301529151600093929092169163f5298aca91606480820192869290919082900301818387803b158015613f6657600080fd5b505af1158015613f7a573d6000803e3d6000fd5b5050506000838152600c602090815260408083208054600101908190558617808452600b90925290912054909150613fbd90600160a01b900460ff166006613511565b6000828152600b60205260409020805461ffff60a81b1960ff93909316600160a01b0260ff60a01b1990911617919091169055613ff983610ee5565b6000828152600b6020908152604080832080546001600160a01b0319166001600160a01b0395861617905560035481516340c10f1960e01b815289861660048201526024810187905291519416936340c10f1993604480840194938390030190829087803b15801561406a57600080fd5b505af115801561407e573d6000803e3d6000fd5b505050506040513d602081101561409457600080fd5b509095945050505050565b6000806140ab836128a0565b6000818152600660208190526040909120600781015491015491925061333b91906132e1565b3b15159056fe4f776e61626c653a206e6577206f776e657220697320746865207a65726f206164647265737356414c49445f46524f4d5f4d5553545f42455f41545f4c454153545f355f4d494e555445535f4c4553535f5448414e5f56414c49445f544f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572a26469706673582212205d7a1a308dd4dd60884a3be5a8ee33e7c39f6aa8857cdea91761128882364e8564736f6c63430007060033