Source Code
Overview
ETH Balance
0 ETH
More Info
ContractCreator
Multichain Info
N/A
Latest 25 from a total of 28 transactions
| Transaction Hash |
Method
|
Block
|
From
|
To
|
Amount
|
||||
|---|---|---|---|---|---|---|---|---|---|
| Wrap Batch | 8959527 | 96 days ago | IN | 0 ETH | 0.00048853 | ||||
| Wrap Batch | 7425289 | 314 days ago | IN | 0 ETH | 0.00641015 | ||||
| Wrap Batch | 7425263 | 314 days ago | IN | 0 ETH | 0.0059988 | ||||
| Wrap Batch | 7425224 | 314 days ago | IN | 0 ETH | 0.00543494 | ||||
| Wrap Batch | 7425148 | 314 days ago | IN | 0 ETH | 0.00530626 | ||||
| Wrap Batch | 7425121 | 314 days ago | IN | 0 ETH | 0.00527621 | ||||
| Wrap Batch | 7425056 | 314 days ago | IN | 0 ETH | 0.00496938 | ||||
| Wrap Batch | 7424980 | 314 days ago | IN | 0 ETH | 0.00474225 | ||||
| Wrap Batch | 7424968 | 314 days ago | IN | 0 ETH | 0.00482413 | ||||
| Wrap Batch | 7424959 | 314 days ago | IN | 0 ETH | 0.00825772 | ||||
| Wrap Batch | 7394346 | 318 days ago | IN | 0 ETH | 0.00116444 | ||||
| Wrap Batch | 7358382 | 323 days ago | IN | 0 ETH | 0.00324707 | ||||
| Wrap Batch | 7337064 | 327 days ago | IN | 0 ETH | 0.0053765 | ||||
| Wrap Batch | 7305951 | 331 days ago | IN | 0 ETH | 0.01169199 | ||||
| Wrap Batch | 7304539 | 331 days ago | IN | 0 ETH | 0.02000061 | ||||
| Wrap Batch | 7304472 | 331 days ago | IN | 0 ETH | 0.02111417 | ||||
| Wrap Batch | 7296902 | 332 days ago | IN | 0 ETH | 0.01760037 | ||||
| Wrap Batch | 7260834 | 338 days ago | IN | 0 ETH | 0.00047578 | ||||
| Wrap Batch | 7260829 | 338 days ago | IN | 0 ETH | 0.00084339 | ||||
| Wrap Batch | 7257101 | 338 days ago | IN | 0 ETH | 0.00711686 | ||||
| Wrap Batch | 7257091 | 338 days ago | IN | 0 ETH | 0.00720026 | ||||
| Wrap Batch | 7253170 | 339 days ago | IN | 0 ETH | 0.0033011 | ||||
| Wrap Batch | 7226593 | 343 days ago | IN | 0 ETH | 0.00049167 | ||||
| Wrap Batch | 7221837 | 344 days ago | IN | 0 ETH | 0.00189868 | ||||
| Wrap Batch | 7136536 | 356 days ago | IN | 0 ETH | 0.0036554 |
Advanced mode: Intended for advanced users or developers and will display all Internal Transactions including zero value transfers.
Latest 25 internal transactions (View All)
Advanced mode:
| Parent Transaction Hash | Method | Block |
From
|
To
|
Amount
|
|||
|---|---|---|---|---|---|---|---|---|
| Transfer* | 8959527 | 96 days ago | 0 ETH | |||||
| Transfer* | 8959527 | 96 days ago | 0 ETH | |||||
| Transfer* | 7425289 | 314 days ago | 0 ETH | |||||
| Transfer* | 7425289 | 314 days ago | 0 ETH | |||||
| Transfer* | 7425263 | 314 days ago | 0 ETH | |||||
| Transfer* | 7425263 | 314 days ago | 0 ETH | |||||
| Transfer* | 7425224 | 314 days ago | 0 ETH | |||||
| Transfer* | 7425224 | 314 days ago | 0 ETH | |||||
| Transfer* | 7425148 | 314 days ago | 0 ETH | |||||
| Transfer* | 7425148 | 314 days ago | 0 ETH | |||||
| Transfer* | 7425121 | 314 days ago | 0 ETH | |||||
| Transfer* | 7425121 | 314 days ago | 0 ETH | |||||
| Transfer* | 7425056 | 314 days ago | 0 ETH | |||||
| Transfer* | 7425056 | 314 days ago | 0 ETH | |||||
| Transfer* | 7424980 | 314 days ago | 0 ETH | |||||
| Transfer* | 7424980 | 314 days ago | 0 ETH | |||||
| Transfer* | 7424968 | 314 days ago | 0 ETH | |||||
| Transfer* | 7424968 | 314 days ago | 0 ETH | |||||
| Transfer* | 7424959 | 314 days ago | 0 ETH | |||||
| Transfer* | 7424959 | 314 days ago | 0 ETH | |||||
| Transfer* | 7424959 | 314 days ago | 0 ETH | |||||
| Transfer* | 7424959 | 314 days ago | 0 ETH | |||||
| Transfer* | 7394346 | 318 days ago | 0 ETH | |||||
| Transfer* | 7394346 | 318 days ago | 0 ETH | |||||
| Transfer* | 7358382 | 323 days ago | 0 ETH |
Loading...
Loading
Loading...
Loading
Contract Name:
BatchWorkerV2
Compiler Version
v0.8.21+commit.d9974bed
Optimization Enabled:
Yes with 200 runs
Other Settings:
paris EvmVersion
Contract Source Code (Solidity Standard Json-Input format)
// SPDX-License-Identifier: MIT
// ENVELOP(NIFTSY) protocol V1 for NFT. Batch Worker
import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
import "../interfaces/ITrustedWrapperV2.sol";
import "@envelop-protocol-v1/interfaces/IERC20Extended.sol";
import "@envelop-subscription/contracts/ServiceProviderOwnable.sol";
pragma solidity 0.8.21;
contract BatchWorkerV2 is ServiceProviderOwnable {
using SafeERC20 for IERC20Extended;
ITrustedWrapperV2 public trustedWrapper;
constructor (address _subscrRegistry)
ServiceProviderOwnable(_subscrRegistry)
{}
function wrapBatch(
ETypes.INData[] calldata _inDataS,
ETypes.AssetItem[] calldata _collateralERC20,
address[] memory _receivers
) public payable {
_checkAndFixSubscription(msg.sender);
require(
_inDataS.length == _receivers.length,
"Array params must have equal length"
);
// make wNFTs
for (uint256 i = 0; i < _inDataS.length; i++) {
// wrap
trustedWrapper.wrapUnsafe{value: (msg.value / _receivers.length)}(
_inDataS[i],
_collateralERC20,
_receivers[i]
);
// Transfer original NFTs to wrapper
if (_inDataS[i].inAsset.asset.assetType == ETypes.AssetType.ERC721 ||
_inDataS[i].inAsset.asset.assetType == ETypes.AssetType.ERC1155 )
{
trustedWrapper.transferIn(
_inDataS[i].inAsset,
msg.sender
);
}
}
ETypes.AssetItem memory totalERC20Collateral;
uint256 totalNativeAmount;
for (uint256 i = 0; i < _collateralERC20.length; i ++) {
if (_collateralERC20[i].asset.assetType == ETypes.AssetType.ERC20) {
totalERC20Collateral.asset.assetType = _collateralERC20[i].asset.assetType;
totalERC20Collateral.asset.contractAddress = _collateralERC20[i].asset.contractAddress;
totalERC20Collateral.tokenId = _collateralERC20[i].tokenId;
// We need construct totalERC20Collateral due make one transfer
// instead of maked wNFT counts
totalERC20Collateral.amount = _collateralERC20[i].amount * _receivers.length;
uint256 amountTransfered = trustedWrapper.transferIn(
totalERC20Collateral,
msg.sender
);
require(amountTransfered == totalERC20Collateral.amount, "Check transfer ERC20 amount fail");
}
if (_collateralERC20[i].asset.assetType == ETypes.AssetType.NATIVE) {
totalNativeAmount += _collateralERC20[i].amount * _receivers.length;
}
}
require(totalNativeAmount == msg.value, "Native amount check failed");
}
function addCollateralBatch(
address[] calldata _wNFTAddress,
uint256[] calldata _wNFTTokenId,
ETypes.AssetItem[] calldata _collateralERC20
) public payable {
_checkAndFixSubscription(msg.sender);
require(_wNFTAddress.length == _wNFTTokenId.length, "Array params must have equal length");
for (uint256 i = 0; i < _collateralERC20.length; i ++) {
if (_collateralERC20[i].asset.assetType == ETypes.AssetType.ERC20) {
// 1. Transfer all erc20 tokens to BatchWorker
IERC20Extended(_collateralERC20[i].asset.contractAddress).safeTransferFrom(
msg.sender,
address(this),
_collateralERC20[i].amount * _wNFTAddress.length
);
// 2. approve for spending to wrapper
IERC20Extended(_collateralERC20[i].asset.contractAddress).safeIncreaseAllowance(
address(trustedWrapper),
_collateralERC20[i].amount * _wNFTAddress.length
);
}
}
uint256 valuePerWNFT = msg.value / _wNFTAddress.length;
for (uint256 i = 0; i < _wNFTAddress.length; i ++){
trustedWrapper.addCollateral{value: valuePerWNFT}(
_wNFTAddress[i],
_wNFTTokenId[i],
_collateralERC20
);
}
if (valuePerWNFT * _wNFTAddress.length < msg.value ){
address payable s = payable(msg.sender);
s.transfer(msg.value - valuePerWNFT * _wNFTAddress.length);
}
}
////////////////////////////////////////
// Admin functions ///
////////////////////////////////////////
function setTrustedWrapper(address _wrapper) public onlyOwner {
trustedWrapper = ITrustedWrapperV2(_wrapper);
require(trustedWrapper.trustedOperator(address(this)), "Only for exact wrapper");
}
/////////////////////////////////////////////////////////////////////
function checkUser(address _user) external view returns (bool ok, bool needFix) {
return _checkUserSubscription(_user);
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.3) (token/ERC20/utils/SafeERC20.sol)
pragma solidity ^0.8.0;
import "../IERC20.sol";
import "../extensions/IERC20Permit.sol";
import "../../../utils/Address.sol";
/**
* @title SafeERC20
* @dev Wrappers around ERC20 operations that throw on failure (when the token
* contract returns false). Tokens that return no value (and instead revert or
* throw on failure) are also supported, non-reverting calls are assumed to be
* successful.
* To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract,
* which allows you to call the safe operations as `token.safeTransfer(...)`, etc.
*/
library SafeERC20 {
using Address for address;
/**
* @dev Transfer `value` amount of `token` from the calling contract to `to`. If `token` returns no value,
* non-reverting calls are assumed to be successful.
*/
function safeTransfer(IERC20 token, address to, uint256 value) internal {
_callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value));
}
/**
* @dev Transfer `value` amount of `token` from `from` to `to`, spending the approval given by `from` to the
* calling contract. If `token` returns no value, non-reverting calls are assumed to be successful.
*/
function safeTransferFrom(IERC20 token, address from, address to, uint256 value) internal {
_callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value));
}
/**
* @dev Deprecated. This function has issues similar to the ones found in
* {IERC20-approve}, and its usage is discouraged.
*
* Whenever possible, use {safeIncreaseAllowance} and
* {safeDecreaseAllowance} instead.
*/
function safeApprove(IERC20 token, address spender, uint256 value) internal {
// safeApprove should only be called when setting an initial allowance,
// or when resetting it to zero. To increase and decrease it, use
// 'safeIncreaseAllowance' and 'safeDecreaseAllowance'
require(
(value == 0) || (token.allowance(address(this), spender) == 0),
"SafeERC20: approve from non-zero to non-zero allowance"
);
_callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value));
}
/**
* @dev Increase the calling contract's allowance toward `spender` by `value`. If `token` returns no value,
* non-reverting calls are assumed to be successful.
*/
function safeIncreaseAllowance(IERC20 token, address spender, uint256 value) internal {
uint256 oldAllowance = token.allowance(address(this), spender);
_callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, oldAllowance + value));
}
/**
* @dev Decrease the calling contract's allowance toward `spender` by `value`. If `token` returns no value,
* non-reverting calls are assumed to be successful.
*/
function safeDecreaseAllowance(IERC20 token, address spender, uint256 value) internal {
unchecked {
uint256 oldAllowance = token.allowance(address(this), spender);
require(oldAllowance >= value, "SafeERC20: decreased allowance below zero");
_callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, oldAllowance - value));
}
}
/**
* @dev Set the calling contract's allowance toward `spender` to `value`. If `token` returns no value,
* non-reverting calls are assumed to be successful. Meant to be used with tokens that require the approval
* to be set to zero before setting it to a non-zero value, such as USDT.
*/
function forceApprove(IERC20 token, address spender, uint256 value) internal {
bytes memory approvalCall = abi.encodeWithSelector(token.approve.selector, spender, value);
if (!_callOptionalReturnBool(token, approvalCall)) {
_callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, 0));
_callOptionalReturn(token, approvalCall);
}
}
/**
* @dev Use a ERC-2612 signature to set the `owner` approval toward `spender` on `token`.
* Revert on invalid signature.
*/
function safePermit(
IERC20Permit token,
address owner,
address spender,
uint256 value,
uint256 deadline,
uint8 v,
bytes32 r,
bytes32 s
) internal {
uint256 nonceBefore = token.nonces(owner);
token.permit(owner, spender, value, deadline, v, r, s);
uint256 nonceAfter = token.nonces(owner);
require(nonceAfter == nonceBefore + 1, "SafeERC20: permit did not succeed");
}
/**
* @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement
* on the return value: the return value is optional (but if data is returned, it must not be false).
* @param token The token targeted by the call.
* @param data The call data (encoded using abi.encode or one of its variants).
*/
function _callOptionalReturn(IERC20 token, bytes memory data) private {
// We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since
// we're implementing it ourselves. We use {Address-functionCall} to perform this call, which verifies that
// the target address contains contract code and also asserts for success in the low-level call.
bytes memory returndata = address(token).functionCall(data, "SafeERC20: low-level call failed");
require(returndata.length == 0 || abi.decode(returndata, (bool)), "SafeERC20: ERC20 operation did not succeed");
}
/**
* @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement
* on the return value: the return value is optional (but if data is returned, it must not be false).
* @param token The token targeted by the call.
* @param data The call data (encoded using abi.encode or one of its variants).
*
* This is a variant of {_callOptionalReturn} that silents catches all reverts and returns a bool instead.
*/
function _callOptionalReturnBool(IERC20 token, bytes memory data) private returns (bool) {
// We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since
// we're implementing it ourselves. We cannot use {Address-functionCall} here since this should return false
// and not revert is the subcall reverts.
(bool success, bytes memory returndata) = address(token).call(data);
return
success && (returndata.length == 0 || abi.decode(returndata, (bool))) && Address.isContract(address(token));
}
}// SPDX-License-Identifier: MIT
pragma solidity 0.8.21;
import "@envelop-protocol-v1/interfaces/IWrapper.sol";
interface ITrustedWrapperV2 is IWrapper {
function trustedOperator(address _operator) external view returns(bool);
function wrapUnsafe(
ETypes.INData calldata _inData,
ETypes.AssetItem[] calldata _collateral,
address _wrappFor
)
external
payable
returns (ETypes.AssetItem memory);
function transferIn(
ETypes.AssetItem memory _assetItem,
address _from
)
external
payable
returns (uint256 _transferedValue);
}// SPDX-License-Identifier: MIT
pragma solidity 0.8.21;
import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
interface IERC20Extended is IERC20 {
function mint(address _to, uint256 _value) external;
}// SPDX-License-Identifier: MIT
// ENVELOP(NIFTSY) Subscription Registry Contract V2
/// The subscription platform operates with the following role model
/// (it is assumed that the actor with the role is implemented as a contract).
/// `Service Provider` is a contract whose services are sold by subscription.
/// `Agent` - a contract that sells a subscription on behalf ofservice provider.
/// May receive sales commission
/// `Platform` - SubscriptionRegistry contract that performs processingsubscriptions,
/// fares, tickets
pragma solidity 0.8.21;
import "@openzeppelin/contracts/access/Ownable.sol";
import "./ServiceProvider.sol";
/// @title ServiceProviderOwnable contract
/// @author Envelop project Team
/// @notice Contract implements Ownable pattern for service providers.
/// @dev Inherit this code in service provider contract that
/// want use subscription.
contract ServiceProviderOwnable is ServiceProvider, Ownable {
constructor(address _subscrRegistry)
ServiceProvider(_subscrRegistry)
{
}
///////////////////////////////////////
// Admin functions ///
////////////////////////////////////////
function newTariff(Tariff memory _newTariff) external onlyOwner returns(uint256 tariffIndex) {
tariffIndex = _registerServiceTariff(_newTariff);
}
function registerServiceTariff(Tariff memory _newTariff)
external onlyOwner returns(uint256)
{
return _registerServiceTariff(_newTariff);
}
function editServiceTariff(
uint256 _tariffIndex,
uint256 _timelockPeriod,
uint256 _ticketValidPeriod,
uint256 _counter,
bool _isAvailable,
address _beneficiary
) external onlyOwner
{
_editServiceTariff(
_tariffIndex,
_timelockPeriod,
_ticketValidPeriod,
_counter,
_isAvailable,
_beneficiary
);
}
function addPayOption(
uint256 _tariffIndex,
address _paymentToken,
uint256 _paymentAmount,
uint16 _agentFeePercent
) external onlyOwner returns(uint256 index)
{
index = _addTariffPayOption(
_tariffIndex,
_paymentToken,
_paymentAmount,
_agentFeePercent
);
}
function editPayOption(
uint256 _tariffIndex,
uint256 _payWithIndex,
address _paymentToken,
uint256 _paymentAmount,
uint16 _agentFeePercent
) external onlyOwner
{
_editTariffPayOption(
_tariffIndex,
_payWithIndex,
_paymentToken,
_paymentAmount,
_agentFeePercent
);
}
function authorizeAgentForService(
address _agent,
uint256[] memory _serviceTariffIndexes
) external onlyOwner returns (uint256[] memory actualTariffs)
{
actualTariffs = _authorizeAgentForService(
_agent,
_serviceTariffIndexes
);
}
function setSubscriptionRegistry(address _subscrRegistry) external onlyOwner {
subscriptionRegistry = ISubscriptionRegistry(_subscrRegistry);
}
function setSubscriptionOnOff(bool _isEnable) external onlyOwner {
isEnabled = _isEnable;
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (token/ERC20/IERC20.sol)
pragma solidity ^0.8.0;
/**
* @dev Interface of the ERC20 standard as defined in the EIP.
*/
interface IERC20 {
/**
* @dev Emitted when `value` tokens are moved from one account (`from`) to
* another (`to`).
*
* Note that `value` may be zero.
*/
event Transfer(address indexed from, address indexed to, uint256 value);
/**
* @dev Emitted when the allowance of a `spender` for an `owner` is set by
* a call to {approve}. `value` is the new allowance.
*/
event Approval(address indexed owner, address indexed spender, uint256 value);
/**
* @dev Returns the amount of tokens in existence.
*/
function totalSupply() external view returns (uint256);
/**
* @dev Returns the amount of tokens owned by `account`.
*/
function balanceOf(address account) external view returns (uint256);
/**
* @dev Moves `amount` tokens from the caller's account to `to`.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transfer(address to, uint256 amount) external returns (bool);
/**
* @dev Returns the remaining number of tokens that `spender` will be
* allowed to spend on behalf of `owner` through {transferFrom}. This is
* zero by default.
*
* This value changes when {approve} or {transferFrom} are called.
*/
function allowance(address owner, address spender) external view returns (uint256);
/**
* @dev Sets `amount` as the allowance of `spender` over the caller's tokens.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* IMPORTANT: Beware that changing an allowance with this method brings the risk
* that someone may use both the old and the new allowance by unfortunate
* transaction ordering. One possible solution to mitigate this race
* condition is to first reduce the spender's allowance to 0 and set the
* desired value afterwards:
* https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
*
* Emits an {Approval} event.
*/
function approve(address spender, uint256 amount) external returns (bool);
/**
* @dev Moves `amount` tokens from `from` to `to` using the
* allowance mechanism. `amount` is then deducted from the caller's
* allowance.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transferFrom(address from, address to, uint256 amount) external returns (bool);
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (token/ERC20/extensions/IERC20Permit.sol)
pragma solidity ^0.8.0;
/**
* @dev Interface of the ERC20 Permit extension allowing approvals to be made via signatures, as defined in
* https://eips.ethereum.org/EIPS/eip-2612[EIP-2612].
*
* Adds the {permit} method, which can be used to change an account's ERC20 allowance (see {IERC20-allowance}) by
* presenting a message signed by the account. By not relying on {IERC20-approve}, the token holder account doesn't
* need to send a transaction, and thus is not required to hold Ether at all.
*/
interface IERC20Permit {
/**
* @dev Sets `value` as the allowance of `spender` over ``owner``'s tokens,
* given ``owner``'s signed approval.
*
* IMPORTANT: The same issues {IERC20-approve} has related to transaction
* ordering also apply here.
*
* Emits an {Approval} event.
*
* Requirements:
*
* - `spender` cannot be the zero address.
* - `deadline` must be a timestamp in the future.
* - `v`, `r` and `s` must be a valid `secp256k1` signature from `owner`
* over the EIP712-formatted function arguments.
* - the signature must use ``owner``'s current nonce (see {nonces}).
*
* For more information on the signature format, see the
* https://eips.ethereum.org/EIPS/eip-2612#specification[relevant EIP
* section].
*/
function permit(
address owner,
address spender,
uint256 value,
uint256 deadline,
uint8 v,
bytes32 r,
bytes32 s
) external;
/**
* @dev Returns the current nonce for `owner`. This value must be
* included whenever a signature is generated for {permit}.
*
* Every successful call to {permit} increases ``owner``'s nonce by one. This
* prevents a signature from being used multiple times.
*/
function nonces(address owner) external view returns (uint256);
/**
* @dev Returns the domain separator used in the encoding of the signature for {permit}, as defined by {EIP712}.
*/
// solhint-disable-next-line func-name-mixedcase
function DOMAIN_SEPARATOR() external view returns (bytes32);
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (utils/Address.sol)
pragma solidity ^0.8.1;
/**
* @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
*
* Furthermore, `isContract` will also return true if the target contract within
* the same transaction is already scheduled for destruction by `SELFDESTRUCT`,
* which only has an effect at the end of a transaction.
* ====
*
* [IMPORTANT]
* ====
* You shouldn't rely on `isContract` to protect against flash loan attacks!
*
* Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets
* like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract
* constructor.
* ====
*/
function isContract(address account) internal view returns (bool) {
// This method relies on extcodesize/address.code.length, which returns 0
// for contracts in construction, since the code is only stored at the end
// of the constructor execution.
return account.code.length > 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://consensys.net/diligence/blog/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.8.0/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].
*/
function sendValue(address payable recipient, uint256 amount) internal {
require(address(this).balance >= amount, "Address: insufficient balance");
(bool success, ) = recipient.call{value: amount}("");
require(success, "Address: unable to send value, recipient may have reverted");
}
/**
* @dev Performs a Solidity function call using a low level `call`. A
* plain `call` is an unsafe replacement for a function call: use this
* function instead.
*
* If `target` reverts with a revert reason, it is bubbled up by this
* function (like regular Solidity function calls).
*
* Returns the raw returned data. To convert to the expected return value,
* use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].
*
* Requirements:
*
* - `target` must be a contract.
* - calling `target` with `data` must not revert.
*
* _Available since v3.1._
*/
function functionCall(address target, bytes memory data) internal returns (bytes memory) {
return functionCallWithValue(target, data, 0, "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");
(bool success, bytes memory returndata) = target.call{value: value}(data);
return verifyCallResultFromTarget(target, 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) {
(bool success, bytes memory returndata) = target.staticcall(data);
return verifyCallResultFromTarget(target, 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) {
(bool success, bytes memory returndata) = target.delegatecall(data);
return verifyCallResultFromTarget(target, success, returndata, errorMessage);
}
/**
* @dev Tool to verify that a low level call to smart-contract was successful, and revert (either by bubbling
* the revert reason or using the provided one) in case of unsuccessful call or if target was not a contract.
*
* _Available since v4.8._
*/
function verifyCallResultFromTarget(
address target,
bool success,
bytes memory returndata,
string memory errorMessage
) internal view returns (bytes memory) {
if (success) {
if (returndata.length == 0) {
// only check isContract if the call was successful and the return data is empty
// otherwise we already know that it was a contract
require(isContract(target), "Address: call to non-contract");
}
return returndata;
} else {
_revert(returndata, errorMessage);
}
}
/**
* @dev Tool to verify that a low level call was successful, and revert if it wasn't, either by bubbling the
* revert reason or using the provided one.
*
* _Available since v4.3._
*/
function verifyCallResult(
bool success,
bytes memory returndata,
string memory errorMessage
) internal pure returns (bytes memory) {
if (success) {
return returndata;
} else {
_revert(returndata, errorMessage);
}
}
function _revert(bytes memory returndata, string memory errorMessage) private pure {
// 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
/// @solidity memory-safe-assembly
assembly {
let returndata_size := mload(returndata)
revert(add(32, returndata), returndata_size)
}
} else {
revert(errorMessage);
}
}
}// SPDX-License-Identifier: MIT
pragma solidity 0.8.21;
//import "@openzeppelin/contracts/token/ERC721/extensions/IERC721Enumerable.sol";
import "../contracts/LibEnvelopTypes.sol";
interface IWrapper {
event WrappedV1(
address indexed inAssetAddress,
address indexed outAssetAddress,
uint256 indexed inAssetTokenId,
uint256 outTokenId,
address wnftFirstOwner,
uint256 nativeCollateralAmount,
bytes2 rules
);
event UnWrappedV1(
address indexed wrappedAddress,
address indexed originalAddress,
uint256 indexed wrappedId,
uint256 originalTokenId,
address beneficiary,
uint256 nativeCollateralAmount,
bytes2 rules
);
event CollateralAdded(
address indexed wrappedAddress,
uint256 indexed wrappedId,
uint8 assetType,
address collateralAddress,
uint256 collateralTokenId,
uint256 collateralBalance
);
event PartialUnWrapp(
address indexed wrappedAddress,
uint256 indexed wrappedId,
uint256 lastCollateralIndex
);
event SuspiciousFail(
address indexed wrappedAddress,
uint256 indexed wrappedId,
address indexed failedContractAddress
);
event EnvelopFee(
address indexed receiver,
address indexed wNFTConatract,
uint256 indexed wNFTTokenId,
uint256 amount
);
function wrap(
ETypes.INData calldata _inData,
ETypes.AssetItem[] calldata _collateral,
address _wrappFor
)
external
payable
returns (ETypes.AssetItem memory);
// function wrapUnsafe(
// ETypes.INData calldata _inData,
// ETypes.AssetItem[] calldata _collateral,
// address _wrappFor
// )
// external
// payable
// returns (ETypes.AssetItem memory);
function addCollateral(
address _wNFTAddress,
uint256 _wNFTTokenId,
ETypes.AssetItem[] calldata _collateral
) external payable;
// function addCollateralUnsafe(
// address _wNFTAddress,
// uint256 _wNFTTokenId,
// ETypes.AssetItem[] calldata _collateral
// )
// external
// payable;
function unWrap(
address _wNFTAddress,
uint256 _wNFTTokenId
) external;
function unWrap(
ETypes.AssetType _wNFTType,
address _wNFTAddress,
uint256 _wNFTTokenId
) external;
function unWrap(
ETypes.AssetType _wNFTType,
address _wNFTAddress,
uint256 _wNFTTokenId,
bool _isEmergency
) external;
function chargeFees(
address _wNFTAddress,
uint256 _wNFTTokenId,
address _from,
address _to,
bytes1 _feeType
)
external
returns (bool);
//////////////////////////////////////////////////////////////////////
function MAX_COLLATERAL_SLOTS() external view returns (uint256);
function protocolTechToken() external view returns (address);
function protocolWhiteList() external view returns (address);
function getWrappedToken(address _wNFTAddress, uint256 _wNFTTokenId)
external
view
returns (ETypes.WNFT memory);
function getOriginalURI(address _wNFTAddress, uint256 _wNFTTokenId)
external
view
returns(string memory);
function getCollateralBalanceAndIndex(
address _wNFTAddress,
uint256 _wNFTTokenId,
ETypes.AssetType _collateralType,
address _erc,
uint256 _tokenId
) external view returns (uint256, uint256);
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (access/Ownable.sol)
pragma solidity ^0.8.0;
import "../utils/Context.sol";
/**
* @dev Contract module which provides a basic access control mechanism, where
* there is an account (an owner) that can be granted exclusive access to
* specific functions.
*
* By default, the owner account will be the one that deploys the contract. This
* can later be changed with {transferOwnership}.
*
* This module is used through inheritance. It will make available the modifier
* `onlyOwner`, which can be applied to your functions to restrict their use to
* the owner.
*/
abstract contract Ownable is Context {
address private _owner;
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
/**
* @dev Initializes the contract setting the deployer as the initial owner.
*/
constructor() {
_transferOwnership(_msgSender());
}
/**
* @dev Throws if called by any account other than the owner.
*/
modifier onlyOwner() {
_checkOwner();
_;
}
/**
* @dev Returns the address of the current owner.
*/
function owner() public view virtual returns (address) {
return _owner;
}
/**
* @dev Throws if the sender is not the owner.
*/
function _checkOwner() internal view virtual {
require(owner() == _msgSender(), "Ownable: caller is not the owner");
}
/**
* @dev Leaves the contract without owner. It will not be possible to call
* `onlyOwner` functions. Can only be called by the current owner.
*
* NOTE: Renouncing ownership will leave the contract without an owner,
* thereby disabling any functionality that is only available to the owner.
*/
function renounceOwnership() public virtual onlyOwner {
_transferOwnership(address(0));
}
/**
* @dev Transfers ownership of the contract to a new account (`newOwner`).
* Can only be called by the current owner.
*/
function transferOwnership(address newOwner) public virtual onlyOwner {
require(newOwner != address(0), "Ownable: new owner is the zero address");
_transferOwnership(newOwner);
}
/**
* @dev Transfers ownership of the contract to a new account (`newOwner`).
* Internal function without access restriction.
*/
function _transferOwnership(address newOwner) internal virtual {
address oldOwner = _owner;
_owner = newOwner;
emit OwnershipTransferred(oldOwner, newOwner);
}
}// SPDX-License-Identifier: MIT
// ENVELOP(NIFTSY) Subscription Registry Contract V2
/// The subscription platform operates with the following role model
/// (it is assumed that the actor with the role is implemented as a contract).
/// `Service Provider` is a contract whose services are sold by subscription.
/// `Agent` - a contract that sells a subscription on behalf ofservice provider.
/// May receive sales commission
/// `Platform` - SubscriptionRegistry contract that performs processingsubscriptions,
/// fares, tickets
pragma solidity 0.8.21;
import "../interfaces/ISubscriptionRegistry.sol";
/// @title ServiceProvider abstract contract
/// @author Envelop project Team
/// @notice Abstract contract implements subscribing features.
/// For use with SubscriptionRegestry
/// @dev Use this code in service provider contract that
/// want use subscription. One contract = one servie
/// Please see example folder
abstract contract ServiceProvider {
address public serviceProvider;
ISubscriptionRegistry public subscriptionRegistry;
bool public isEnabled = true;
constructor(address _subscrRegistry) {
require(_subscrRegistry != address(0), 'Non zero only');
serviceProvider = address(this);
subscriptionRegistry = ISubscriptionRegistry(_subscrRegistry);
}
function _registerServiceTariff(Tariff memory _newTariff)
internal virtual returns(uint256)
{
return subscriptionRegistry.registerServiceTariff(_newTariff);
}
function _editServiceTariff(
uint256 _tariffIndex,
uint256 _timelockPeriod,
uint256 _ticketValidPeriod,
uint256 _counter,
bool _isAvailable,
address _beneficiary
) internal virtual
{
subscriptionRegistry.editServiceTariff(
_tariffIndex,
_timelockPeriod,
_ticketValidPeriod,
_counter,
_isAvailable,
_beneficiary
);
}
function _addTariffPayOption(
uint256 _tariffIndex,
address _paymentToken,
uint256 _paymentAmount,
uint16 _agentFeePercent
) internal virtual returns(uint256)
{
return subscriptionRegistry.addTariffPayOption(
_tariffIndex,
_paymentToken,
_paymentAmount,
_agentFeePercent
);
}
function _editTariffPayOption(
uint256 _tariffIndex,
uint256 _payWithIndex,
address _paymentToken,
uint256 _paymentAmount,
uint16 _agentFeePercent
) internal virtual
{
subscriptionRegistry.editTariffPayOption(
_tariffIndex,
_payWithIndex,
_paymentToken,
_paymentAmount,
_agentFeePercent
);
}
function _authorizeAgentForService(
address _agent,
uint256[] memory _serviceTariffIndexes
) internal virtual returns (uint256[] memory)
{
// TODO Check agent
return subscriptionRegistry.authorizeAgentForService(
_agent,
_serviceTariffIndexes
);
}
////////////////////////////
// Main USAGE //
////////////////////////////
function _checkAndFixSubscription(address _user)
internal
returns (bool ok)
{
if (isEnabled) {
ok = subscriptionRegistry.checkAndFixUserSubscription(
_user
);
} else {
ok = true;
}
}
function _checkUserSubscription(address _user)
internal
view
returns (bool ok, bool needFix)
{
if (isEnabled) {
(ok, needFix) = subscriptionRegistry.checkUserSubscription(
_user,
address(this)
);
} else {
ok = true;
}
}
}// SPDX-License-Identifier: MIT
// ENVELOP(NIFTSY) protocol V1 for NFT.
pragma solidity 0.8.21;
/// @title Flibrary ETypes in Envelop PrtocolV1
/// @author Envelop Team
/// @notice This contract implement main protocol's data types
library ETypes {
enum AssetType {EMPTY, NATIVE, ERC20, ERC721, ERC1155, FUTURE1, FUTURE2, FUTURE3}
struct Asset {
AssetType assetType;
address contractAddress;
}
struct AssetItem {
Asset asset;
uint256 tokenId;
uint256 amount;
}
struct NFTItem {
address contractAddress;
uint256 tokenId;
}
struct Fee {
bytes1 feeType;
uint256 param;
address token;
}
struct Lock {
bytes1 lockType;
uint256 param;
}
struct Royalty {
address beneficiary;
uint16 percent;
}
struct WNFT {
AssetItem inAsset;
AssetItem[] collateral;
address unWrapDestination;
Fee[] fees;
Lock[] locks;
Royalty[] royalties;
bytes2 rules;
}
struct INData {
AssetItem inAsset;
address unWrapDestination;
Fee[] fees;
Lock[] locks;
Royalty[] royalties;
AssetType outType;
uint256 outBalance; //0- for 721 and any amount for 1155
bytes2 rules;
}
struct WhiteListItem {
bool enabledForFee;
bool enabledForCollateral;
bool enabledRemoveFromCollateral;
address transferFeeModel;
}
struct Rules {
bytes2 onlythis;
bytes2 disabled;
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/Context.sol)
pragma solidity ^0.8.0;
/**
* @dev Provides information about the current execution context, including the
* sender of the transaction and its data. While these are generally available
* via msg.sender and msg.data, they should not be accessed in such a direct
* manner, since when dealing with meta-transactions the account sending and
* paying for execution may not be the actual sender (as far as an application
* is concerned).
*
* This contract is only required for intermediate, library-like contracts.
*/
abstract contract Context {
function _msgSender() internal view virtual returns (address) {
return msg.sender;
}
function _msgData() internal view virtual returns (bytes calldata) {
return msg.data;
}
}// SPDX-License-Identifier: MIT
pragma solidity 0.8.21;
import {SubscriptionType, PayOption, Tariff, Ticket} from "../contracts/SubscriptionRegistry.sol";
interface ISubscriptionRegistry {
/**
* @notice Add new tariff for caller
* @dev Call this method from ServiceProvider
* for setup new tariff
* using `Tariff` data type(please see above)
*
* @param _newTariff full encded Tariff object
* @return last added tariff index in Tariff[] array
* for current Service Provider (msg.sender)
*/
function registerServiceTariff(Tariff calldata _newTariff) external returns(uint256);
/**
* @notice Authorize agent for caller service provider
* @dev Call this method from ServiceProvider
*
* @param _agent - address of contract that implement Agent role
* @param _serviceTariffIndexes - array of index in `availableTariffs` array
* that available for given `_agent`
* @return full array of actual tarifs for this agent
*/
function authorizeAgentForService(
address _agent,
uint256[] calldata _serviceTariffIndexes
) external returns (uint256[] memory);
/**
* @notice By Ticket for subscription
* @dev Call this method from Agent
*
* @param _service - Service Provider address
* @param _tariffIndex - index in `availableTariffs` array
* @param _payWithIndex - index in `tariff.payWith` array
* @param _buyFor - address for whome this ticket would be bought
* @param _payer - address of payer for this ticket
* @return ticket structure that would be use for validate service process
*/
function buySubscription(
address _service,
uint256 _tariffIndex,
uint256 _payWithIndex,
address _buyFor,
address _payer
) external payable returns(Ticket memory ticket);
/**
* @notice Edit tariff for caller
* @dev Call this method from ServiceProvider
* for setup new tariff
* using `Tariff` data type(please see above)
*
* @param _tariffIndex - index in `availableTariffs` array
* @param _timelockPeriod - see SubscriptionType notice above
* @param _ticketValidPeriod - see SubscriptionType notice above
* @param _counter - see SubscriptionType notice above
* @param _isAvailable - see SubscriptionType notice above
* @param _beneficiary - see SubscriptionType notice above
*/
function editServiceTariff(
uint256 _tariffIndex,
uint256 _timelockPeriod,
uint256 _ticketValidPeriod,
uint256 _counter,
bool _isAvailable,
address _beneficiary
) external;
/**
* @notice Add tariff PayOption for exact service
* @dev Call this method from ServiceProvider
* for add tariff PayOption
*
* @param _tariffIndex - index in `availableTariffs` array
* @param _paymentToken - see PayOption notice above
* @param _paymentAmount - see PayOption notice above
* @param _agentFeePercent - see PayOption notice above
* @return last added PaymentOption index in array
* for _tariffIndex Tariff of caller Service Provider (msg.sender)
*/
function addTariffPayOption(
uint256 _tariffIndex,
address _paymentToken,
uint256 _paymentAmount,
uint16 _agentFeePercent
) external returns(uint256);
/**
* @notice Edit tariff PayOption for exact service
* @dev Call this method from ServiceProvider
* for edit tariff PayOption
*
* @param _tariffIndex - index in `availableTariffs` array
* @param _payWithIndex - index in `tariff.payWith` array
* @param _paymentToken - see PayOption notice above
* @param _paymentAmount - see PayOption notice above
* @param _agentFeePercent - see PayOption notice above
* for _tariffIndex Tariff of caller Service Provider (msg.sender)
*/
function editTariffPayOption(
uint256 _tariffIndex,
uint256 _payWithIndex,
address _paymentToken,
uint256 _paymentAmount,
uint16 _agentFeePercent
) external;
/**
* @notice Check that `_user` have still valid ticket for this service.
* @dev Call this method from any context
*
* @param _user - address of user who has an ticket and who trying get service
* @param _service - address of Service Provider
* @return ok True in case ticket is valid
* @return needFix True in case ticket has counter > 0
*/
function checkUserSubscription(
address _user,
address _service
) external view returns (bool ok, bool needFix);
/**
* @notice Check that `_user` have still valid ticket for this service.
* Decrement ticket counter in case it > 0
* @dev Call this method from ServiceProvider
*
* @param _user - address of user who has an ticket and who trying get service
* @return ok True in case ticket is valid
*/
function checkAndFixUserSubscription(address _user) external returns (bool ok);
/**
* @notice Decrement ticket counter in case it > 0
* @dev Call this method from new SubscriptionRegistry in case of upgrade
*
* @param _user - address of user who has an ticket and who trying get service
* @param _serviceFromProxy - address of service from more new SubscriptionRegistry contract
*/
function fixUserSubscription(address _user, address _serviceFromProxy) external;
/**
* @notice Returns `_user` ticket for this service.
* @dev Call this method from any context
*
* @param _user - address of user who has an ticket and who trying get service
* @param _service - address of Service Provider
* @return ticket
*/
function getUserTicketForService(
address _service,
address _user
) external view returns(Ticket memory);
/**
* @notice Returns array of Tariff for `_service`
* @dev Call this method from any context
*
* @param _service - address of Service Provider
* @return Tariff array
*/
function getTariffsForService(address _service) external view returns (Tariff[] memory);
/**
* @notice Returns ticket price include any fees
* @dev Call this method from any context
*
* @param _service - address of Service Provider
* @param _tariffIndex - index in `availableTariffs` array
* @param _payWithIndex - index in `tariff.payWith` array
* @return tulpe with payment token an ticket price
*/
function getTicketPrice(
address _service,
uint256 _tariffIndex,
uint256 _payWithIndex
) external view returns (address, uint256);
/**
* @notice Returns array of Tariff for `_service` assigned to `_agent`
* @dev Call this method from any context
*
* @param _agent - address of Agent
* @param _service - address of Service Provider
* @return Tariff array
*/
function getAvailableAgentsTariffForService(
address _agent,
address _service
) external view returns(Tariff[] memory);
}// SPDX-License-Identifier: MIT
// ENVELOP(NIFTSY) Team. Subscription Registry Contract V2
pragma solidity 0.8.21;
import "@openzeppelin/contracts/access/Ownable.sol";
import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
import "@envelop-protocol-v1/interfaces/ITrustedWrapper.sol";
import "@envelop-protocol-v1/contracts/LibEnvelopTypes.sol";
import "../interfaces/ISubscriptionRegistry.sol";
/// The subscription platform operates with the following role model
/// (it is assumed that the actor with the role is implemented as a contract).
/// `Service Provider` is a contract whose services are sold by subscription.
/// `Agent` - a contract that sells a subscription on behalf ofservice provider.
/// May receive sales commission
/// `Platform` - SubscriptionRegistry contract that performs processingsubscriptions,
/// fares, tickets
struct SubscriptionType {
uint256 timelockPeriod; // in seconds e.g. 3600*24*30*12 = 31104000 = 1 year
uint256 ticketValidPeriod; // in seconds e.g. 3600*24*30 = 2592000 = 1 month
uint256 counter; // For case when ticket valid for N usage, e.g. for Min N NFTs
bool isAvailable; // USe for stop using tariff because we can`t remove tariff from array
address beneficiary; // Who will receive payment for tickets
}
struct PayOption {
address paymentToken; // token contract address or zero address for native token(ETC etc)
uint256 paymentAmount; // ticket price exclude any fees
uint16 agentFeePercent; // 100%-10000, 20%-2000, 3%-300
}
struct Tariff {
SubscriptionType subscription; // link to subscriptionType
PayOption[] payWith; // payment option array. Use it for price in defferent tokens
}
// native subscribtionManager tickets format
struct Ticket {
uint256 validUntil; // Unixdate, tickets not valid after
uint256 countsLeft; // for tarif with fixed use counter
}
/// @title Base contract in Envelop Subscription Platform
/// @author Envelop Team
/// @notice You can use this contract for make and operate any on-chain subscriptions
/// @dev Contract that performs processing subscriptions, fares(tariffs), tickets
/// @custom:please see example folder.
contract SubscriptionRegistry is Ownable {
using SafeERC20 for IERC20;
uint256 constant public PERCENT_DENOMINATOR = 10000;
/// @notice Envelop Multisig contract
address public platformOwner;
/// @notice Platform owner can receive fee from each payments
uint16 public platformFeePercent = 50; // 100%-10000, 20%-2000, 3%-300
/// @notice address used for wrapp & lock incoming assets
address public mainWrapper;
/// @notice Used in case upgrade this contract
address public previousRegistry;
/// @notice Used in case upgrade this contract
address public proxyRegistry;
/// @notice Only white listed assets can be used on platform
mapping(address => bool) public whiteListedForPayments;
/// @notice from service(=smart contract address) to tarifs
mapping(address => Tariff[]) public availableTariffs;
/// @notice from service to agent to available tarifs(tarif index);
mapping(address => mapping(address => uint256[])) public agentServiceRegistry;
/// @notice mapping from user addres to service contract address to ticket
mapping(address => mapping(address => Ticket)) public userTickets;
event PlatfromFeeChanged(uint16 indexed newPercent);
event WhitelistPaymentTokenChanged(address indexed asset, bool indexed state);
event TariffChanged(address indexed service, uint256 indexed tariffIndex);
event TicketIssued(
address indexed service,
address indexed agent,
address indexed forUser,
uint256 tariffIndex
);
constructor(address _platformOwner) {
require(_platformOwner != address(0),'Zero platform fee receiver');
platformOwner = _platformOwner;
}
/**
* @notice Add new tariff for caller
* @dev Call this method from ServiceProvider
* for setup new tariff
* using `Tariff` data type(please see above)
*
* @param _newTariff full encded Tariff object
* @return last added tariff index in Tariff[] array
* for current Service Provider (msg.sender)
*/
function registerServiceTariff(Tariff calldata _newTariff)
external
returns(uint256)
{
// TODO
// Tarif structure check
// PayWith array whiteList check
return _addTariff(msg.sender, _newTariff);
}
/**
* @notice Edit tariff for caller
* @dev Call this method from ServiceProvider
* for setup new tariff
* using `Tariff` data type(please see above)
*
* @param _tariffIndex - index in `availableTariffs` array
* @param _timelockPeriod - see SubscriptionType notice above
* @param _ticketValidPeriod - see SubscriptionType notice above
* @param _counter - see SubscriptionType notice above
* @param _isAvailable - see SubscriptionType notice above
* @param _beneficiary - see SubscriptionType notice above
*/
function editServiceTariff(
uint256 _tariffIndex,
uint256 _timelockPeriod,
uint256 _ticketValidPeriod,
uint256 _counter,
bool _isAvailable,
address _beneficiary
)
external
{
// TODO
// Tariff structure check
// PayWith array whiteList check
_editTariff(
msg.sender,
_tariffIndex,
_timelockPeriod,
_ticketValidPeriod,
_counter,
_isAvailable,
_beneficiary
);
}
/**
* @notice Add tariff PayOption for exact service
* @dev Call this method from ServiceProvider
* for add tariff PayOption
*
* @param _tariffIndex - index in `availableTariffs` array
* @param _paymentToken - see PayOption notice above
* @param _paymentAmount - see PayOption notice above
* @param _agentFeePercent - see PayOption notice above
* @return last added PaymentOption index in array
* for _tariffIndex Tariff of caller Service Provider (msg.sender)
*/
function addTariffPayOption(
uint256 _tariffIndex,
address _paymentToken,
uint256 _paymentAmount,
uint16 _agentFeePercent
) external returns(uint256)
{
return _addTariffPayOption(
msg.sender,
_tariffIndex,
_paymentToken,
_paymentAmount,
_agentFeePercent
);
}
/**
* @notice Edit tariff PayOption for exact service
* @dev Call this method from ServiceProvider
* for edit tariff PayOption
*
* @param _tariffIndex - index in `availableTariffs` array
* @param _payWithIndex - index in `tariff.payWith` array
* @param _paymentToken - see PayOption notice above
* @param _paymentAmount - see PayOption notice above
* @param _agentFeePercent - see PayOption notice above
* for _tariffIndex Tariff of caller Service Provider (msg.sender)
*/
function editTariffPayOption(
uint256 _tariffIndex,
uint256 _payWithIndex,
address _paymentToken,
uint256 _paymentAmount,
uint16 _agentFeePercent
) external
{
_editTariffPayOption(
msg.sender,
_tariffIndex,
_payWithIndex,
_paymentToken,
_paymentAmount,
_agentFeePercent
);
}
/**
* @notice Authorize agent for caller service provider
* @dev Call this method from ServiceProvider
*
* @param _agent - address of contract that implement Agent role
* @param _serviceTariffIndexes - array of index in `availableTariffs` array
* that available for given `_agent`
* @return full array of actual tarifs for this agent
*/
function authorizeAgentForService(
address _agent,
uint256[] calldata _serviceTariffIndexes
) external virtual returns (uint256[] memory)
{
// remove previouse tariffs
delete agentServiceRegistry[msg.sender][_agent];
uint256[] storage currentServiceTariffsOfAgent = agentServiceRegistry[msg.sender][_agent];
// check that adding tariffs still available
for(uint256 i; i < _serviceTariffIndexes.length; ++ i) {
if (availableTariffs[msg.sender][_serviceTariffIndexes[i]].subscription.isAvailable){
currentServiceTariffsOfAgent.push(_serviceTariffIndexes[i]);
}
}
return currentServiceTariffsOfAgent;
}
/**
* @notice By Ticket for subscription
* @dev Call this method from Agent
*
* @param _service - Service Provider address
* @param _tariffIndex - index in `availableTariffs` array
* @param _payWithIndex - index in `tariff.payWith` array
* @param _buyFor - address for whome this ticket would be bought
* @param _payer - address of payer for this ticket
* @return ticket structure that would be use for validate service process
*/
function buySubscription(
address _service,
uint256 _tariffIndex,
uint256 _payWithIndex,
address _buyFor,
address _payer
) external
payable
returns(Ticket memory ticket) {
// Cant buy ticket for nobody
require(_buyFor != address(0),'Cant buy ticket for nobody');
require(
availableTariffs[_service][_tariffIndex].subscription.isAvailable,
'This subscription not available'
);
// Not used in this implementation
// require(
// availableTariffs[_service][_tariffIndex].payWith[_payWithIndex].paymentAmount > 0,
// 'This Payment option not available'
// );
// Check that agent is authorized for purchace of this service
require(
_isAgentAuthorized(msg.sender, _service, _tariffIndex),
'Agent not authorized for this service tariff'
);
(bool isValid, bool needFix) = _isTicketValid(_buyFor, _service);
require(!isValid, 'Only one valid ticket at time');
//lets safe user ticket (only one ticket available in this version)
ticket = Ticket(
availableTariffs[_service][_tariffIndex].subscription.ticketValidPeriod + block.timestamp,
availableTariffs[_service][_tariffIndex].subscription.counter
);
userTickets[_buyFor][_service] = ticket;
// Lets receive payment tokens FROM sender
if (availableTariffs[_service][_tariffIndex].payWith[_payWithIndex].paymentAmount > 0){
_processPayment(_service, _tariffIndex, _payWithIndex, _payer);
}
emit TicketIssued(_service, msg.sender, _buyFor, _tariffIndex);
}
/**
* @notice Check that `_user` have still valid ticket for this service.
* Decrement ticket counter in case it > 0
* @dev Call this method from ServiceProvider
*
* @param _user - address of user who has an ticket and who trying get service
* @return ok True in case ticket is valid
*/
function checkAndFixUserSubscription(
address _user
) external returns (bool ok){
address _service = msg.sender;
// Check user ticket
(bool isValid, bool needFix) = _isTicketValid(_user, msg.sender);
// Proxy to previos
if (!isValid && previousRegistry != address(0)) {
(isValid, needFix) = ISubscriptionRegistry(previousRegistry).checkUserSubscription(
_user,
_service
);
// Case when valid ticket stored in previousManager
if (isValid ) {
if (needFix){
ISubscriptionRegistry(previousRegistry).fixUserSubscription(
_user,
_service
);
}
ok = true;
return ok;
}
}
require(isValid,'Valid ticket not found');
// Fix action (for subscription with counter)
if (needFix){
_fixUserSubscription(_user, msg.sender);
}
ok = true;
}
/**
* @notice Decrement ticket counter in case it > 0
* @dev Call this method from new SubscriptionRegistry in case of upgrade
*
* @param _user - address of user who has an ticket and who trying get service
* @param _serviceFromProxy - address of service from more new SubscriptionRegistry contract
*/
function fixUserSubscription(
address _user,
address _serviceFromProxy
) public {
require(proxyRegistry !=address(0) && msg.sender == proxyRegistry,
'Only for future registry'
);
_fixUserSubscription(_user, _serviceFromProxy);
}
////////////////////////////////////////////////////////////////
/**
* @notice Check that `_user` have still valid ticket for this service.
* @dev Call this method from any context
*
* @param _user - address of user who has an ticket and who trying get service
* @param _service - address of Service Provider
* @return ok True in case ticket is valid
* @return needFix True in case ticket has counter > 0
*/
function checkUserSubscription(
address _user,
address _service
) external view returns (bool ok, bool needFix) {
(ok, needFix) = _isTicketValid(_user, _service);
if (!ok && previousRegistry != address(0)) {
(ok, needFix) = ISubscriptionRegistry(previousRegistry).checkUserSubscription(
_user,
_service
);
}
}
/**
* @notice Returns `_user` ticket for this service.
* @dev Call this method from any context
*
* @param _user - address of user who has an ticket and who trying get service
* @param _service - address of Service Provider
* @return ticket
*/
function getUserTicketForService(
address _service,
address _user
) public view returns(Ticket memory)
{
return userTickets[_user][_service];
}
/**
* @notice Returns array of Tariff for `_service`
* @dev Call this method from any context
*
* @param _service - address of Service Provider
* @return Tariff array
*/
function getTariffsForService(address _service) external view returns (Tariff[] memory) {
return availableTariffs[_service];
}
/**
* @notice Returns ticket price include any fees
* @dev Call this method from any context
*
* @param _service - address of Service Provider
* @param _tariffIndex - index in `availableTariffs` array
* @param _payWithIndex - index in `tariff.payWith` array
* @return tulpe with payment token an ticket price
*/
function getTicketPrice(
address _service,
uint256 _tariffIndex,
uint256 _payWithIndex
) public view virtual returns (address, uint256)
{
if (availableTariffs[_service][_tariffIndex].subscription.timelockPeriod != 0)
{
return(
availableTariffs[_service][_tariffIndex].payWith[_payWithIndex].paymentToken,
availableTariffs[_service][_tariffIndex].payWith[_payWithIndex].paymentAmount
);
} else {
return(
availableTariffs[_service][_tariffIndex].payWith[_payWithIndex].paymentToken,
availableTariffs[_service][_tariffIndex].payWith[_payWithIndex].paymentAmount
+ availableTariffs[_service][_tariffIndex].payWith[_payWithIndex].paymentAmount
*availableTariffs[_service][_tariffIndex].payWith[_payWithIndex].agentFeePercent
/PERCENT_DENOMINATOR
+ availableTariffs[_service][_tariffIndex].payWith[_payWithIndex].paymentAmount
*_platformFeePercent(_service, _tariffIndex, _payWithIndex)
/PERCENT_DENOMINATOR
);
}
}
/**
* @notice Returns array of Tariff for `_service` assigned to `_agent`
* @dev Call this method from any context
*
* @param _agent - address of Agent
* @param _service - address of Service Provider
* @return tuple with two arrays: indexes and Tariffs
*/
function getAvailableAgentsTariffForService(
address _agent,
address _service
) external view virtual returns(uint256[] memory, Tariff[] memory)
{
//First need get count of tarifs that still available
uint256 availableCount;
for (uint256 i; i < agentServiceRegistry[_service][_agent].length; ++i){
if (availableTariffs[_service][
agentServiceRegistry[_service][_agent][i]
].subscription.isAvailable
) {++availableCount;}
}
Tariff[] memory tariffs = new Tariff[](availableCount);
uint256[] memory indexes = new uint256[](availableCount);
for (uint256 i; i < agentServiceRegistry[_service][_agent].length; ++i){
if (availableTariffs[_service][
agentServiceRegistry[_service][_agent][i]
].subscription.isAvailable
)
{
tariffs[availableCount - 1] = availableTariffs[_service][
agentServiceRegistry[_service][_agent][i]
];
indexes[availableCount - 1] = agentServiceRegistry[_service][_agent][i];
--availableCount;
}
}
return (indexes, tariffs);
}
////////////////////////////////////////////////////////////////
////////// Admins //////
////////////////////////////////////////////////////////////////
function setAssetForPaymentState(address _asset, bool _isEnable)
external onlyOwner
{
whiteListedForPayments[_asset] = _isEnable;
emit WhitelistPaymentTokenChanged(_asset, _isEnable);
}
function setMainWrapper(address _wrapper) external onlyOwner {
mainWrapper = _wrapper;
}
function setPlatformOwner(address _newOwner) external {
require(msg.sender == platformOwner, 'Only platform owner');
require(_newOwner != address(0),'Zero platform fee receiver');
platformOwner = _newOwner;
}
function setPlatformFeePercent(uint16 _newPercent) external {
require(msg.sender == platformOwner, 'Only platform owner');
platformFeePercent = _newPercent;
emit PlatfromFeeChanged(platformFeePercent);
}
function setPreviousRegistry(address _registry) external onlyOwner {
previousRegistry = _registry;
}
function setProxyRegistry(address _registry) external onlyOwner {
proxyRegistry = _registry;
}
/////////////////////////////////////////////////////////////////////
function _processPayment(
address _service,
uint256 _tariffIndex,
uint256 _payWithIndex,
address _payer
)
internal
virtual
returns(bool)
{
// there are two payment method for this implementation.
// 1. with wrap and lock in asset (no fees)
// 2. simple payment (agent & platform fee enabled)
if (availableTariffs[_service][_tariffIndex].subscription.timelockPeriod != 0){
require(msg.value == 0, 'Ether Not accepted in this method');
// 1. with wrap and lock in asset
IERC20(
availableTariffs[_service][_tariffIndex].payWith[_payWithIndex].paymentToken
).safeTransferFrom(
_payer,
address(this),
availableTariffs[_service][_tariffIndex].payWith[_payWithIndex].paymentAmount
);
// Lets approve received for wrap
IERC20(
availableTariffs[_service][_tariffIndex].payWith[_payWithIndex].paymentToken
).safeApprove(
mainWrapper,
availableTariffs[_service][_tariffIndex].payWith[_payWithIndex].paymentAmount
);
// Lets wrap with timelock and appropriate params
ETypes.INData memory _inData;
ETypes.AssetItem[] memory _collateralERC20 = new ETypes.AssetItem[](1);
ETypes.Lock[] memory timeLock = new ETypes.Lock[](1);
// Only need set timelock for this wNFT
timeLock[0] = ETypes.Lock(
0x00, // timelock
availableTariffs[_service][_tariffIndex].subscription.timelockPeriod + block.timestamp
);
_inData = ETypes.INData(
ETypes.AssetItem(
ETypes.Asset(ETypes.AssetType.EMPTY, address(0)),
0,0
), // INAsset
address(0), // Unwrap destinition
new ETypes.Fee[](0), // Fees
//new ETypes.Lock[](0), // Locks
timeLock,
new ETypes.Royalty[](0), // Royalties
ETypes.AssetType.ERC721, // Out type
0, // Out Balance
0x0000 // Rules
);
_collateralERC20[0] = ETypes.AssetItem(
ETypes.Asset(
ETypes.AssetType.ERC20,
availableTariffs[_service][_tariffIndex].payWith[_payWithIndex].paymentToken
),
0,
availableTariffs[_service][_tariffIndex].payWith[_payWithIndex].paymentAmount
);
ITrustedWrapper(mainWrapper).wrap(
_inData,
_collateralERC20,
_payer
);
} else {
// 2. simple payment
if (availableTariffs[_service][_tariffIndex]
.payWith[_payWithIndex]
.paymentToken != address(0)
)
{
// pay with erc20
require(msg.value == 0, 'Ether Not accepted in this method');
// 2.1. Body payment
IERC20(
availableTariffs[_service][_tariffIndex].payWith[_payWithIndex].paymentToken
).safeTransferFrom(
_payer,
availableTariffs[_service][_tariffIndex].subscription.beneficiary,
availableTariffs[_service][_tariffIndex].payWith[_payWithIndex].paymentAmount
);
// 2.2. Agent fee payment
IERC20(
availableTariffs[_service][_tariffIndex].payWith[_payWithIndex].paymentToken
).safeTransferFrom(
_payer,
msg.sender,
availableTariffs[_service][_tariffIndex].payWith[_payWithIndex].paymentAmount
*availableTariffs[_service][_tariffIndex].payWith[_payWithIndex].agentFeePercent
/PERCENT_DENOMINATOR
);
// 2.3. Platform fee
uint256 _pFee = _platformFeePercent(_service, _tariffIndex, _payWithIndex);
if (_pFee > 0) {
IERC20(
availableTariffs[_service][_tariffIndex].payWith[_payWithIndex].paymentToken
).safeTransferFrom(
_payer,
platformOwner, //
availableTariffs[_service][_tariffIndex].payWith[_payWithIndex].paymentAmount
*_pFee
/PERCENT_DENOMINATOR
);
}
} else {
// pay with native token(eth, bnb, etc)
(, uint256 needPay) = getTicketPrice(_service, _tariffIndex,_payWithIndex);
require(msg.value >= needPay, 'Not enough ether');
// 2.4. Body ether payment
sendValue(
payable(availableTariffs[_service][_tariffIndex].subscription.beneficiary),
availableTariffs[_service][_tariffIndex].payWith[_payWithIndex].paymentAmount
);
// 2.5. Agent fee payment
sendValue(
payable(msg.sender),
availableTariffs[_service][_tariffIndex].payWith[_payWithIndex].paymentAmount
*availableTariffs[_service][_tariffIndex].payWith[_payWithIndex].agentFeePercent
/PERCENT_DENOMINATOR
);
// 2.3. Platform fee
uint256 _pFee = _platformFeePercent(_service, _tariffIndex, _payWithIndex);
if (_pFee > 0) {
sendValue(
payable(platformOwner),
availableTariffs[_service][_tariffIndex].payWith[_payWithIndex].paymentAmount
*_pFee
/PERCENT_DENOMINATOR
);
}
// return change
if ((msg.value - needPay) > 0) {
address payable s = payable(_payer);
s.transfer(msg.value - needPay);
}
}
}
}
// In this impementation params not used.
// Can be ovveriden in other cases
function _platformFeePercent(
address _service,
uint256 _tariffIndex,
uint256 _payWithIndex
) internal view virtual returns(uint256)
{
return platformFeePercent;
}
function _addTariff(address _service, Tariff calldata _newTariff)
internal returns(uint256)
{
require (_newTariff.payWith.length > 0, 'No payment method');
for (uint256 i; i < _newTariff.payWith.length; ++i){
require(
whiteListedForPayments[_newTariff.payWith[i].paymentToken],
'Not whitelisted for payments'
);
}
require(
_newTariff.subscription.ticketValidPeriod > 0
|| _newTariff.subscription.counter > 0,
'Tariff has no valid ticket option'
);
availableTariffs[_service].push(_newTariff);
emit TariffChanged(_service, availableTariffs[_service].length - 1);
return availableTariffs[_service].length - 1;
}
function _editTariff(
address _service,
uint256 _tariffIndex,
uint256 _timelockPeriod,
uint256 _ticketValidPeriod,
uint256 _counter,
bool _isAvailable,
address _beneficiary
) internal
{
availableTariffs[_service][_tariffIndex].subscription.timelockPeriod = _timelockPeriod;
availableTariffs[_service][_tariffIndex].subscription.ticketValidPeriod = _ticketValidPeriod;
availableTariffs[_service][_tariffIndex].subscription.counter = _counter;
availableTariffs[_service][_tariffIndex].subscription.isAvailable = _isAvailable;
availableTariffs[_service][_tariffIndex].subscription.beneficiary = _beneficiary;
emit TariffChanged(_service, _tariffIndex);
}
function _addTariffPayOption(
address _service,
uint256 _tariffIndex,
address _paymentToken,
uint256 _paymentAmount,
uint16 _agentFeePercent
) internal returns(uint256)
{
require(whiteListedForPayments[_paymentToken], 'Not whitelisted for payments');
availableTariffs[_service][_tariffIndex].payWith.push(
PayOption(_paymentToken, _paymentAmount, _agentFeePercent)
);
emit TariffChanged(_service, _tariffIndex);
return availableTariffs[_service][_tariffIndex].payWith.length - 1;
}
function _editTariffPayOption(
address _service,
uint256 _tariffIndex,
uint256 _payWithIndex,
address _paymentToken,
uint256 _paymentAmount,
uint16 _agentFeePercent
) internal
{
require(whiteListedForPayments[_paymentToken], 'Not whitelisted for payments');
availableTariffs[_service][_tariffIndex].payWith[_payWithIndex]
= PayOption(_paymentToken, _paymentAmount, _agentFeePercent);
emit TariffChanged(_service, _tariffIndex);
}
function _fixUserSubscription(
address _user,
address _service
) internal {
// Fix action (for subscription with counter)
if (userTickets[_user][_service].countsLeft > 0) {
-- userTickets[_user][_service].countsLeft;
}
}
function _isTicketValid(address _user, address _service)
internal
view
returns (bool isValid, bool needFix )
{
isValid = userTickets[_user][_service].validUntil > block.timestamp
|| userTickets[_user][_service].countsLeft > 0;
needFix = userTickets[_user][_service].countsLeft > 0;
}
function _isAgentAuthorized(
address _agent,
address _service,
uint256 _tariffIndex
)
internal
view
returns(bool authorized)
{
for (uint256 i; i < agentServiceRegistry[_service][_agent].length; ++ i){
if (agentServiceRegistry[_service][_agent][i] == _tariffIndex){
authorized = true;
return authorized;
}
}
}
function sendValue(address payable recipient, uint256 amount) internal {
require(address(this).balance >= amount, "Address: insufficient balance");
(bool success, ) = recipient.call{value: amount}("");
require(success, "Address: unable to send value, recipient may have reverted");
}
}// SPDX-License-Identifier: MIT
pragma solidity 0.8.21;
import "./IWrapper.sol";
interface ITrustedWrapper is IWrapper {
function trustedOperator() external view returns(address);
function wrapUnsafe(
ETypes.INData calldata _inData,
ETypes.AssetItem[] calldata _collateral,
address _wrappFor
)
external
payable
returns (ETypes.AssetItem memory);
function transferIn(
ETypes.AssetItem memory _assetItem,
address _from
)
external
payable
returns (uint256 _transferedValue);
}{
"remappings": [
"@uniswap/=lib/",
"@openzeppelin/=lib/openzeppelin-contracts/",
"@envelop-protocol-v1/=lib/envelop-protocol-v1/",
"@envelop-subscription/=lib/subscription/",
"ds-test/=lib/openzeppelin-contracts/lib/forge-std/lib/ds-test/src/",
"envelop-protocol-v1/=lib/envelop-protocol-v1/",
"erc4626-tests/=lib/openzeppelin-contracts/lib/erc4626-tests/",
"forge-std/=lib/forge-std/src/",
"openzeppelin-contracts/=lib/openzeppelin-contracts/",
"openzeppelin/=lib/openzeppelin-contracts/contracts/",
"subscription/=lib/subscription/"
],
"optimizer": {
"enabled": true,
"runs": 200
},
"metadata": {
"useLiteralContent": false,
"bytecodeHash": "ipfs",
"appendCBOR": true
},
"outputSelection": {
"*": {
"*": [
"evm.bytecode",
"evm.deployedBytecode",
"devdoc",
"userdoc",
"metadata",
"abi"
]
}
},
"evmVersion": "paris",
"viaIR": false,
"libraries": {}
}Contract ABI
API[{"inputs":[{"internalType":"address","name":"_subscrRegistry","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"previousOwner","type":"address"},{"indexed":true,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnershipTransferred","type":"event"},{"inputs":[{"internalType":"address[]","name":"_wNFTAddress","type":"address[]"},{"internalType":"uint256[]","name":"_wNFTTokenId","type":"uint256[]"},{"components":[{"components":[{"internalType":"enum ETypes.AssetType","name":"assetType","type":"uint8"},{"internalType":"address","name":"contractAddress","type":"address"}],"internalType":"struct ETypes.Asset","name":"asset","type":"tuple"},{"internalType":"uint256","name":"tokenId","type":"uint256"},{"internalType":"uint256","name":"amount","type":"uint256"}],"internalType":"struct ETypes.AssetItem[]","name":"_collateralERC20","type":"tuple[]"}],"name":"addCollateralBatch","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_tariffIndex","type":"uint256"},{"internalType":"address","name":"_paymentToken","type":"address"},{"internalType":"uint256","name":"_paymentAmount","type":"uint256"},{"internalType":"uint16","name":"_agentFeePercent","type":"uint16"}],"name":"addPayOption","outputs":[{"internalType":"uint256","name":"index","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_agent","type":"address"},{"internalType":"uint256[]","name":"_serviceTariffIndexes","type":"uint256[]"}],"name":"authorizeAgentForService","outputs":[{"internalType":"uint256[]","name":"actualTariffs","type":"uint256[]"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_user","type":"address"}],"name":"checkUser","outputs":[{"internalType":"bool","name":"ok","type":"bool"},{"internalType":"bool","name":"needFix","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_tariffIndex","type":"uint256"},{"internalType":"uint256","name":"_payWithIndex","type":"uint256"},{"internalType":"address","name":"_paymentToken","type":"address"},{"internalType":"uint256","name":"_paymentAmount","type":"uint256"},{"internalType":"uint16","name":"_agentFeePercent","type":"uint16"}],"name":"editPayOption","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_tariffIndex","type":"uint256"},{"internalType":"uint256","name":"_timelockPeriod","type":"uint256"},{"internalType":"uint256","name":"_ticketValidPeriod","type":"uint256"},{"internalType":"uint256","name":"_counter","type":"uint256"},{"internalType":"bool","name":"_isAvailable","type":"bool"},{"internalType":"address","name":"_beneficiary","type":"address"}],"name":"editServiceTariff","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"isEnabled","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"components":[{"components":[{"internalType":"uint256","name":"timelockPeriod","type":"uint256"},{"internalType":"uint256","name":"ticketValidPeriod","type":"uint256"},{"internalType":"uint256","name":"counter","type":"uint256"},{"internalType":"bool","name":"isAvailable","type":"bool"},{"internalType":"address","name":"beneficiary","type":"address"}],"internalType":"struct SubscriptionType","name":"subscription","type":"tuple"},{"components":[{"internalType":"address","name":"paymentToken","type":"address"},{"internalType":"uint256","name":"paymentAmount","type":"uint256"},{"internalType":"uint16","name":"agentFeePercent","type":"uint16"}],"internalType":"struct PayOption[]","name":"payWith","type":"tuple[]"}],"internalType":"struct Tariff","name":"_newTariff","type":"tuple"}],"name":"newTariff","outputs":[{"internalType":"uint256","name":"tariffIndex","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"components":[{"components":[{"internalType":"uint256","name":"timelockPeriod","type":"uint256"},{"internalType":"uint256","name":"ticketValidPeriod","type":"uint256"},{"internalType":"uint256","name":"counter","type":"uint256"},{"internalType":"bool","name":"isAvailable","type":"bool"},{"internalType":"address","name":"beneficiary","type":"address"}],"internalType":"struct SubscriptionType","name":"subscription","type":"tuple"},{"components":[{"internalType":"address","name":"paymentToken","type":"address"},{"internalType":"uint256","name":"paymentAmount","type":"uint256"},{"internalType":"uint16","name":"agentFeePercent","type":"uint16"}],"internalType":"struct PayOption[]","name":"payWith","type":"tuple[]"}],"internalType":"struct Tariff","name":"_newTariff","type":"tuple"}],"name":"registerServiceTariff","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"serviceProvider","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bool","name":"_isEnable","type":"bool"}],"name":"setSubscriptionOnOff","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_subscrRegistry","type":"address"}],"name":"setSubscriptionRegistry","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_wrapper","type":"address"}],"name":"setTrustedWrapper","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"subscriptionRegistry","outputs":[{"internalType":"contract ISubscriptionRegistry","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"trustedWrapper","outputs":[{"internalType":"contract ITrustedWrapperV2","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"components":[{"components":[{"components":[{"internalType":"enum ETypes.AssetType","name":"assetType","type":"uint8"},{"internalType":"address","name":"contractAddress","type":"address"}],"internalType":"struct ETypes.Asset","name":"asset","type":"tuple"},{"internalType":"uint256","name":"tokenId","type":"uint256"},{"internalType":"uint256","name":"amount","type":"uint256"}],"internalType":"struct ETypes.AssetItem","name":"inAsset","type":"tuple"},{"internalType":"address","name":"unWrapDestination","type":"address"},{"components":[{"internalType":"bytes1","name":"feeType","type":"bytes1"},{"internalType":"uint256","name":"param","type":"uint256"},{"internalType":"address","name":"token","type":"address"}],"internalType":"struct ETypes.Fee[]","name":"fees","type":"tuple[]"},{"components":[{"internalType":"bytes1","name":"lockType","type":"bytes1"},{"internalType":"uint256","name":"param","type":"uint256"}],"internalType":"struct ETypes.Lock[]","name":"locks","type":"tuple[]"},{"components":[{"internalType":"address","name":"beneficiary","type":"address"},{"internalType":"uint16","name":"percent","type":"uint16"}],"internalType":"struct ETypes.Royalty[]","name":"royalties","type":"tuple[]"},{"internalType":"enum ETypes.AssetType","name":"outType","type":"uint8"},{"internalType":"uint256","name":"outBalance","type":"uint256"},{"internalType":"bytes2","name":"rules","type":"bytes2"}],"internalType":"struct ETypes.INData[]","name":"_inDataS","type":"tuple[]"},{"components":[{"components":[{"internalType":"enum ETypes.AssetType","name":"assetType","type":"uint8"},{"internalType":"address","name":"contractAddress","type":"address"}],"internalType":"struct ETypes.Asset","name":"asset","type":"tuple"},{"internalType":"uint256","name":"tokenId","type":"uint256"},{"internalType":"uint256","name":"amount","type":"uint256"}],"internalType":"struct ETypes.AssetItem[]","name":"_collateralERC20","type":"tuple[]"},{"internalType":"address[]","name":"_receivers","type":"address[]"}],"name":"wrapBatch","outputs":[],"stateMutability":"payable","type":"function"}]Contract Creation Code
60806040526001805460ff60a01b1916600160a01b1790553480156200002457600080fd5b50604051620025c7380380620025c783398101604081905262000047916200012e565b80806001600160a01b038116620000945760405162461bcd60e51b815260206004820152600d60248201526c4e6f6e207a65726f206f6e6c7960981b604482015260640160405180910390fd5b60008054306001600160a01b031991821617909155600180549091166001600160a01b0392909216919091179055620000d4620000ce3390565b620000dc565b505062000160565b600280546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b6000602082840312156200014157600080fd5b81516001600160a01b03811681146200015957600080fd5b9392505050565b61245780620001706000396000f3fe6080604052600436106101145760003560e01c806378451d00116100a0578063a3fafd0511610064578063a3fafd05146102e7578063abba145b14610314578063adae3ebf14610334578063f2fde38b14610354578063fb8adca41461037457600080fd5b806378451d0014610119578063796352d6146102765780638d69e95e146102895780638da5cb5b146102a95780639ec30e4a146102c757600080fd5b80635751869b116100e75780635751869b146101dd57806363c7832b146101fd5780636aa633b6146102105780636f1c156714610241578063715018a61461026157600080fd5b80630c5620d6146101195780631e9d48cf1461014c5780631f16aef31461018357806320da7170146101a5575b600080fd5b34801561012557600080fd5b506101396101343660046116df565b610394565b6040519081526020015b60405180910390f35b34801561015857600080fd5b5061016c6101673660046117ac565b6103ad565b604080519215158352901515602083015201610143565b34801561018f57600080fd5b506101a361019e3660046117c9565b6103c2565b005b3480156101b157600080fd5b506001546101c5906001600160a01b031681565b6040516001600160a01b039091168152602001610143565b3480156101e957600080fd5b506101a36101f8366004611827565b6103e0565b6101a361020b366004611908565b6103fc565b34801561021c57600080fd5b5060015461023190600160a01b900460ff1681565b6040519015158152602001610143565b34801561024d57600080fd5b506101a361025c3660046117ac565b610696565b34801561026d57600080fd5b506101a3610761565b6101a36102843660046119a1565b61077a565b34801561029557600080fd5b506000546101c5906001600160a01b031681565b3480156102b557600080fd5b506002546001600160a01b03166101c5565b3480156102d357600080fd5b506101a36102e23660046117ac565b610cb8565b3480156102f357600080fd5b50610307610302366004611a93565b610ce2565b6040516101439190611b73565b34801561032057600080fd5b506101a361032f366004611b86565b610cfd565b34801561034057600080fd5b506003546101c5906001600160a01b031681565b34801561036057600080fd5b506101a361036f3660046117ac565b610d23565b34801561038057600080fd5b5061013961038f366004611ba3565b610d99565b600061039e610db8565b6103a782610e12565b92915050565b6000806103b983610e85565b91509150915091565b6103ca610db8565b6103d8868686868686610f22565b505050505050565b6103e8610db8565b6103f58585858585610fad565b5050505050565b61040533611027565b5084831461042e5760405162461bcd60e51b815260040161042590611beb565b60405180910390fd5b60005b8181101561056557600283838381811061044d5761044d611c44565b6104639260206080909202019081019150611c72565b600781111561047457610474611c2e565b03610553576104e133308886868681811061049157610491611c44565b905060800201606001356104a59190611ca5565b8686868181106104b7576104b7611c44565b6104d092604060809092020190810191506020016117ac565b6001600160a01b03169291906110b4565b600354610553906001600160a01b03168785858581811061050457610504611c44565b905060800201606001356105189190611ca5565b85858581811061052a5761052a611c44565b61054392604060809092020190810191506020016117ac565b6001600160a01b03169190611125565b8061055d81611cbc565b915050610431565b5060006105728634611cd5565b905060005b86811015610637576003546001600160a01b03166391ddb146838a8a858181106105a3576105a3611c44565b90506020020160208101906105b891906117ac565b8989868181106105ca576105ca611c44565b9050602002013588886040518663ffffffff1660e01b81526004016105f29493929190611d9e565b6000604051808303818588803b15801561060b57600080fd5b505af115801561061f573d6000803e3d6000fd5b5050505050808061062f90611cbc565b915050610577565b50346106438783611ca5565b101561068d5733806108fc6106588985611ca5565b6106629034611dd0565b6040518115909202916000818181858888f1935050505015801561068a573d6000803e3d6000fd5b50505b50505050505050565b61069e610db8565b600380546001600160a01b0319166001600160a01b03831690811790915560405163146d77bb60e21b81523060048201526351b5deec90602401602060405180830381865afa1580156106f5573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906107199190611de3565b61075e5760405162461bcd60e51b815260206004820152601660248201527527b7363c903337b91032bc30b1ba103bb930b83832b960511b6044820152606401610425565b50565b610769610db8565b61077360006111d2565b565b919050565b61078333611027565b50805184146107a45760405162461bcd60e51b815260040161042590611beb565b60005b848110156109ba5760035482516001600160a01b0390911690639a251c29906107d09034611cd5565b8888858181106107e2576107e2611c44565b90506020028101906107f49190611e00565b878787878151811061080857610808611c44565b60200260200101516040518663ffffffff1660e01b815260040161082f9493929190611fe0565b60806040518083038185885af115801561084d573d6000803e3d6000fd5b50505050506040513d601f19601f820116820180604052508101906108729190612106565b50600386868381811061088757610887611c44565b90506020028101906108999190611e00565b6108a7906020810190611c72565b60078111156108b8576108b8611c2e565b1480610906575060048686838181106108d3576108d3611c44565b90506020028101906108e59190611e00565b6108f3906020810190611c72565b600781111561090457610904611c2e565b145b156109a8576003546001600160a01b03166397da0ceb87878481811061092e5761092e611c44565b90506020028101906109409190611e00565b6040516001600160e01b031960e084901b1681526109639190339060040161217d565b6020604051808303816000875af1158015610982573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906109a691906121a3565b505b806109b281611cbc565b9150506107a7565b506040805160a0810182526000606082018181526080830182905282526020820181905291810182905290805b84811015610c68576002868683818110610a0357610a03611c44565b610a199260206080909202019081019150611c72565b6007811115610a2a57610a2a611c2e565b03610be157858582818110610a4157610a41611c44565b610a579260206080909202019081019150611c72565b8351906007811115610a6b57610a6b611c2e565b90816007811115610a7e57610a7e611c2e565b905250858582818110610a9357610a93611c44565b610aac92604060809092020190810191506020016117ac565b83516001600160a01b03909116602090910152858582818110610ad157610ad1611c44565b905060800201604001358360200181815250508351868683818110610af857610af8611c44565b90506080020160600135610b0c9190611ca5565b60408085019190915260035490516397da0ceb60e01b81526000916001600160a01b0316906397da0ceb90610b4790879033906004016121bc565b6020604051808303816000875af1158015610b66573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610b8a91906121a3565b905083604001518114610bdf5760405162461bcd60e51b815260206004820181905260248201527f436865636b207472616e7366657220455243323020616d6f756e74206661696c6044820152606401610425565b505b6001868683818110610bf557610bf5611c44565b610c0b9260206080909202019081019150611c72565b6007811115610c1c57610c1c611c2e565b03610c56578351868683818110610c3557610c35611c44565b90506080020160600135610c499190611ca5565b610c53908361220c565b91505b80610c6081611cbc565b9150506109e7565b5034811461068d5760405162461bcd60e51b815260206004820152601a60248201527f4e617469766520616d6f756e7420636865636b206661696c65640000000000006044820152606401610425565b610cc0610db8565b600180546001600160a01b0319166001600160a01b0392909216919091179055565b6060610cec610db8565b610cf68383611224565b9392505050565b610d05610db8565b60018054911515600160a01b0260ff60a01b19909216919091179055565b610d2b610db8565b6001600160a01b038116610d905760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b6064820152608401610425565b61075e816111d2565b6000610da3610db8565b610daf8585858561129e565b95945050505050565b6002546001600160a01b031633146107735760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152606401610425565b6001546040516278451d60e81b81526000916001600160a01b0316906378451d0090610e4290859060040161221f565b6020604051808303816000875af1158015610e61573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906103a791906121a3565b6001546000908190600160a01b900460ff1615610f195760015460405163496d511d60e11b81526001600160a01b038581166004830152306024830152909116906392daa23a906044016040805180830381865afa158015610eeb573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610f0f91906122d5565b9092509050915091565b60019150915091565b600154604051631f16aef360e01b81526004810188905260248101879052604481018690526064810185905283151560848201526001600160a01b0383811660a483015290911690631f16aef39060c401600060405180830381600087803b158015610f8d57600080fd5b505af1158015610fa1573d6000803e3d6000fd5b50505050505050505050565b60015460405163650aac6160e01b815260048101879052602481018690526001600160a01b0385811660448301526064820185905261ffff841660848301529091169063650aac619060a401600060405180830381600087803b15801561101357600080fd5b505af115801561068a573d6000803e3d6000fd5b600154600090600160a01b900460ff16156110ac57600154604051632e5f2cf160e01b81526001600160a01b03848116600483015290911690632e5f2cf1906024016020604051808303816000875af1158015611088573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906103a79190611de3565b506001919050565b6040516001600160a01b038085166024830152831660448201526064810182905261111f9085906323b872dd60e01b906084015b60408051601f198184030181529190526020810180516001600160e01b03166001600160e01b03199093169290921790915261132f565b50505050565b604051636eb1769f60e11b81523060048201526001600160a01b0383811660248301526000919085169063dd62ed3e90604401602060405180830381865afa158015611175573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061119991906121a3565b905061111f8463095ea7b360e01b856111b2868661220c565b6040516001600160a01b03909216602483015260448201526064016110e8565b600280546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b60015460405163a3fafd0560e01b81526060916001600160a01b03169063a3fafd0590611257908690869060040161230f565b6000604051808303816000875af1158015611276573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052610cf69190810190612333565b600154604051639aab948160e01b8152600481018690526001600160a01b0385811660248301526044820185905261ffff841660648301526000921690639aab9481906084016020604051808303816000875af1158015611303573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610daf91906121a3565b949350505050565b6000611384826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b03166114099092919063ffffffff16565b90508051600014806113a55750808060200190518101906113a59190611de3565b6114045760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b6064820152608401610425565b505050565b6060611327848460008585600080866001600160a01b0316858760405161143091906123dc565b60006040518083038185875af1925050503d806000811461146d576040519150601f19603f3d011682016040523d82523d6000602084013e611472565b606091505b50915091506114838783838761148e565b979650505050505050565b606083156114fd5782516000036114f6576001600160a01b0385163b6114f65760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000006044820152606401610425565b5081611327565b61132783838151156115125781518083602001fd5b8060405162461bcd60e51b815260040161042591906123ee565b634e487b7160e01b600052604160045260246000fd5b604051606081016001600160401b03811182821017156115645761156461152c565b60405290565b604080519081016001600160401b03811182821017156115645761156461152c565b60405160a081016001600160401b03811182821017156115645761156461152c565b604051601f8201601f191681016001600160401b03811182821017156115d6576115d661152c565b604052919050565b801515811461075e57600080fd5b6001600160a01b038116811461075e57600080fd5b60006001600160401b0382111561161a5761161a61152c565b5060051b60200190565b803561ffff8116811461077557600080fd5b600082601f83011261164757600080fd5b8135602061165c61165783611601565b6115ae565b8281526060928302850182019282820191908785111561167b57600080fd5b8387015b858110156116d25781818a0312156116975760008081fd5b61169f611542565b81356116aa816115ec565b8152818601358682015260406116c1818401611624565b90820152845292840192810161167f565b5090979650505050505050565b6000602082840312156116f157600080fd5b81356001600160401b038082111561170857600080fd5b9083019081850360c081121561171d57600080fd5b61172561156a565b60a082121561173357600080fd5b61173b61158c565b91508335825260208401356020830152604084013560408301526060840135611763816115de565b60608301526080840135611776816115ec565b608083015290815260a0830135908282111561179157600080fd5b61179d87838601611636565b60208201529695505050505050565b6000602082840312156117be57600080fd5b8135610cf6816115ec565b60008060008060008060c087890312156117e257600080fd5b863595506020870135945060408701359350606087013592506080870135611809816115de565b915060a0870135611819816115ec565b809150509295509295509295565b600080600080600060a0868803121561183f57600080fd5b85359450602086013593506040860135611858816115ec565b92506060860135915061186d60808701611624565b90509295509295909350565b60008083601f84011261188b57600080fd5b5081356001600160401b038111156118a257600080fd5b6020830191508360208260051b85010111156118bd57600080fd5b9250929050565b60008083601f8401126118d657600080fd5b5081356001600160401b038111156118ed57600080fd5b6020830191508360208260071b85010111156118bd57600080fd5b6000806000806000806060878903121561192157600080fd5b86356001600160401b038082111561193857600080fd5b6119448a838b01611879565b9098509650602089013591508082111561195d57600080fd5b6119698a838b01611879565b9096509450604089013591508082111561198257600080fd5b5061198f89828a016118c4565b979a9699509497509295939492505050565b6000806000806000606086880312156119b957600080fd5b85356001600160401b03808211156119d057600080fd5b6119dc89838a01611879565b90975095506020915087820135818111156119f657600080fd5b611a028a828b016118c4565b909650945050604088013581811115611a1a57600080fd5b88019050601f81018913611a2d57600080fd5b8035611a3b61165782611601565b81815260059190911b8201830190838101908b831115611a5a57600080fd5b928401925b82841015611a81578335611a72816115ec565b82529284019290840190611a5f565b80955050505050509295509295909350565b60008060408385031215611aa657600080fd5b8235611ab1816115ec565b91506020838101356001600160401b03811115611acd57600080fd5b8401601f81018613611ade57600080fd5b8035611aec61165782611601565b81815260059190911b82018301908381019088831115611b0b57600080fd5b928401925b82841015611b2957833582529284019290840190611b10565b80955050505050509250929050565b600081518084526020808501945080840160005b83811015611b6857815187529582019590820190600101611b4c565b509495945050505050565b602081526000610cf66020830184611b38565b600060208284031215611b9857600080fd5b8135610cf6816115de565b60008060008060808587031215611bb957600080fd5b843593506020850135611bcb816115ec565b925060408501359150611be060608601611624565b905092959194509250565b60208082526023908201527f417272617920706172616d73206d757374206861766520657175616c206c656e6040820152620cee8d60eb1b606082015260800190565b634e487b7160e01b600052602160045260246000fd5b634e487b7160e01b600052603260045260246000fd5b6008811061075e57600080fd5b803561077581611c5a565b600060208284031215611c8457600080fd5b8135610cf681611c5a565b634e487b7160e01b600052601160045260246000fd5b80820281158282048414176103a7576103a7611c8f565b600060018201611cce57611cce611c8f565b5060010190565b600082611cf257634e487b7160e01b600052601260045260246000fd5b500490565b60088110611d1557634e487b7160e01b600052602160045260246000fd5b9052565b8035611d2481611c5a565b611d2e8382611cf7565b506020810135611d3d816115ec565b6001600160a01b0316602083015260408181013590830152606090810135910152565b81835260208301925060008160005b84811015611d9457611d818683611d19565b6080958601959190910190600101611d6f565b5093949350505050565b60018060a01b0385168152836020820152606060408201526000611dc6606083018486611d60565b9695505050505050565b818103818111156103a7576103a7611c8f565b600060208284031215611df557600080fd5b8151610cf6816115de565b6000823561015e19833603018112611e1757600080fd5b9190910192915050565b6000808335601e19843603018112611e3857600080fd5b83016020810192503590506001600160401b03811115611e5757600080fd5b6060810236038213156118bd57600080fd5b80356001600160f81b03198116811461077557600080fd5b8183526000602080850194508260005b85811015611b68576001600160f81b0319611eab83611e69565b1687528282013583880152604080830135611ec5816115ec565b6001600160a01b0316908801526060968701969190910190600101611e91565b6000808335601e19843603018112611efc57600080fd5b83016020810192503590506001600160401b03811115611f1b57600080fd5b8060061b36038213156118bd57600080fd5b8183526000602080850194508260005b85811015611b68576001600160f81b0319611f5783611e69565b168752818301358388015260409687019690910190600101611f3d565b8183526000602080850194508260005b85811015611b68578135611f97816115ec565b6001600160a01b0316875261ffff611fb0838501611624565b16878401526040968701969190910190600101611f84565b80356001600160f01b03198116811461077557600080fd5b60608152611ff16060820186611d19565b60006080860135612001816115ec565b6001600160a01b031660e083015261201c60a0870187611e21565b61016061010081818701526120366101c087018486611e81565b935061204560c08b018b611ee5565b9350605f196101208189880301818a0152612061878785611f2d565b965061207060e08e018e611ee5565b96509250610140828a890301818b015261208b888886611f74565b9750612098858f01611c67565b96506120a6868b0188611cf7565b818e01356101808b01526120bb818f01611fc8565b96505050505050506120da6101a08501826001600160f01b0319169052565b5082810360208401526120ee818688611d60565b915050610daf60408301846001600160a01b03169052565b6000818303608081121561211957600080fd5b612121611542565b604082121561212f57600080fd5b61213761156a565b9150835161214481611c5a565b82526020840151612154816115ec565b806020840152508181526040840151602082015260608401516040820152809250505092915050565b60a0810161218b8285611d19565b6001600160a01b039290921660809190910152919050565b6000602082840312156121b557600080fd5b5051919050565b600060a08201905083516121d1838251611cf7565b6020908101516001600160a01b0390811684830152908501516040808501919091529094015160608301529190921660809092019190915290565b808201808211156103a7576103a7611c8f565b602080825282518051838301528082015160408085019190915280820151606080860191909152808301511515608080870191909152909201516001600160a01b0390811660a08601528584015160c080870152805160e08701819052600095949185019386939290916101008901905b808610156122c7578651805186168352888101518984015284015161ffff1684830152958701956001959095019490820190612290565b509998505050505050505050565b600080604083850312156122e857600080fd5b82516122f3816115de565b6020840151909250612304816115de565b809150509250929050565b6001600160a01b038316815260406020820181905260009061132790830184611b38565b6000602080838503121561234657600080fd5b82516001600160401b0381111561235c57600080fd5b8301601f8101851361236d57600080fd5b805161237b61165782611601565b81815260059190911b8201830190838101908783111561239a57600080fd5b928401925b828410156114835783518252928401929084019061239f565b60005b838110156123d35781810151838201526020016123bb565b50506000910152565b60008251611e178184602087016123b8565b602081526000825180602084015261240d8160408501602087016123b8565b601f01601f1916919091016040019291505056fea2646970667358221220cc0f15c22105a400addb0162982acfbb6a5f2f4df7f80387b43e0fe85495e39664736f6c63430008150033000000000000000000000000ec7ec220de84f3bdedd2b5174225d8c84e1ffd00
Deployed Bytecode
0x6080604052600436106101145760003560e01c806378451d00116100a0578063a3fafd0511610064578063a3fafd05146102e7578063abba145b14610314578063adae3ebf14610334578063f2fde38b14610354578063fb8adca41461037457600080fd5b806378451d0014610119578063796352d6146102765780638d69e95e146102895780638da5cb5b146102a95780639ec30e4a146102c757600080fd5b80635751869b116100e75780635751869b146101dd57806363c7832b146101fd5780636aa633b6146102105780636f1c156714610241578063715018a61461026157600080fd5b80630c5620d6146101195780631e9d48cf1461014c5780631f16aef31461018357806320da7170146101a5575b600080fd5b34801561012557600080fd5b506101396101343660046116df565b610394565b6040519081526020015b60405180910390f35b34801561015857600080fd5b5061016c6101673660046117ac565b6103ad565b604080519215158352901515602083015201610143565b34801561018f57600080fd5b506101a361019e3660046117c9565b6103c2565b005b3480156101b157600080fd5b506001546101c5906001600160a01b031681565b6040516001600160a01b039091168152602001610143565b3480156101e957600080fd5b506101a36101f8366004611827565b6103e0565b6101a361020b366004611908565b6103fc565b34801561021c57600080fd5b5060015461023190600160a01b900460ff1681565b6040519015158152602001610143565b34801561024d57600080fd5b506101a361025c3660046117ac565b610696565b34801561026d57600080fd5b506101a3610761565b6101a36102843660046119a1565b61077a565b34801561029557600080fd5b506000546101c5906001600160a01b031681565b3480156102b557600080fd5b506002546001600160a01b03166101c5565b3480156102d357600080fd5b506101a36102e23660046117ac565b610cb8565b3480156102f357600080fd5b50610307610302366004611a93565b610ce2565b6040516101439190611b73565b34801561032057600080fd5b506101a361032f366004611b86565b610cfd565b34801561034057600080fd5b506003546101c5906001600160a01b031681565b34801561036057600080fd5b506101a361036f3660046117ac565b610d23565b34801561038057600080fd5b5061013961038f366004611ba3565b610d99565b600061039e610db8565b6103a782610e12565b92915050565b6000806103b983610e85565b91509150915091565b6103ca610db8565b6103d8868686868686610f22565b505050505050565b6103e8610db8565b6103f58585858585610fad565b5050505050565b61040533611027565b5084831461042e5760405162461bcd60e51b815260040161042590611beb565b60405180910390fd5b60005b8181101561056557600283838381811061044d5761044d611c44565b6104639260206080909202019081019150611c72565b600781111561047457610474611c2e565b03610553576104e133308886868681811061049157610491611c44565b905060800201606001356104a59190611ca5565b8686868181106104b7576104b7611c44565b6104d092604060809092020190810191506020016117ac565b6001600160a01b03169291906110b4565b600354610553906001600160a01b03168785858581811061050457610504611c44565b905060800201606001356105189190611ca5565b85858581811061052a5761052a611c44565b61054392604060809092020190810191506020016117ac565b6001600160a01b03169190611125565b8061055d81611cbc565b915050610431565b5060006105728634611cd5565b905060005b86811015610637576003546001600160a01b03166391ddb146838a8a858181106105a3576105a3611c44565b90506020020160208101906105b891906117ac565b8989868181106105ca576105ca611c44565b9050602002013588886040518663ffffffff1660e01b81526004016105f29493929190611d9e565b6000604051808303818588803b15801561060b57600080fd5b505af115801561061f573d6000803e3d6000fd5b5050505050808061062f90611cbc565b915050610577565b50346106438783611ca5565b101561068d5733806108fc6106588985611ca5565b6106629034611dd0565b6040518115909202916000818181858888f1935050505015801561068a573d6000803e3d6000fd5b50505b50505050505050565b61069e610db8565b600380546001600160a01b0319166001600160a01b03831690811790915560405163146d77bb60e21b81523060048201526351b5deec90602401602060405180830381865afa1580156106f5573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906107199190611de3565b61075e5760405162461bcd60e51b815260206004820152601660248201527527b7363c903337b91032bc30b1ba103bb930b83832b960511b6044820152606401610425565b50565b610769610db8565b61077360006111d2565b565b919050565b61078333611027565b50805184146107a45760405162461bcd60e51b815260040161042590611beb565b60005b848110156109ba5760035482516001600160a01b0390911690639a251c29906107d09034611cd5565b8888858181106107e2576107e2611c44565b90506020028101906107f49190611e00565b878787878151811061080857610808611c44565b60200260200101516040518663ffffffff1660e01b815260040161082f9493929190611fe0565b60806040518083038185885af115801561084d573d6000803e3d6000fd5b50505050506040513d601f19601f820116820180604052508101906108729190612106565b50600386868381811061088757610887611c44565b90506020028101906108999190611e00565b6108a7906020810190611c72565b60078111156108b8576108b8611c2e565b1480610906575060048686838181106108d3576108d3611c44565b90506020028101906108e59190611e00565b6108f3906020810190611c72565b600781111561090457610904611c2e565b145b156109a8576003546001600160a01b03166397da0ceb87878481811061092e5761092e611c44565b90506020028101906109409190611e00565b6040516001600160e01b031960e084901b1681526109639190339060040161217d565b6020604051808303816000875af1158015610982573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906109a691906121a3565b505b806109b281611cbc565b9150506107a7565b506040805160a0810182526000606082018181526080830182905282526020820181905291810182905290805b84811015610c68576002868683818110610a0357610a03611c44565b610a199260206080909202019081019150611c72565b6007811115610a2a57610a2a611c2e565b03610be157858582818110610a4157610a41611c44565b610a579260206080909202019081019150611c72565b8351906007811115610a6b57610a6b611c2e565b90816007811115610a7e57610a7e611c2e565b905250858582818110610a9357610a93611c44565b610aac92604060809092020190810191506020016117ac565b83516001600160a01b03909116602090910152858582818110610ad157610ad1611c44565b905060800201604001358360200181815250508351868683818110610af857610af8611c44565b90506080020160600135610b0c9190611ca5565b60408085019190915260035490516397da0ceb60e01b81526000916001600160a01b0316906397da0ceb90610b4790879033906004016121bc565b6020604051808303816000875af1158015610b66573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610b8a91906121a3565b905083604001518114610bdf5760405162461bcd60e51b815260206004820181905260248201527f436865636b207472616e7366657220455243323020616d6f756e74206661696c6044820152606401610425565b505b6001868683818110610bf557610bf5611c44565b610c0b9260206080909202019081019150611c72565b6007811115610c1c57610c1c611c2e565b03610c56578351868683818110610c3557610c35611c44565b90506080020160600135610c499190611ca5565b610c53908361220c565b91505b80610c6081611cbc565b9150506109e7565b5034811461068d5760405162461bcd60e51b815260206004820152601a60248201527f4e617469766520616d6f756e7420636865636b206661696c65640000000000006044820152606401610425565b610cc0610db8565b600180546001600160a01b0319166001600160a01b0392909216919091179055565b6060610cec610db8565b610cf68383611224565b9392505050565b610d05610db8565b60018054911515600160a01b0260ff60a01b19909216919091179055565b610d2b610db8565b6001600160a01b038116610d905760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b6064820152608401610425565b61075e816111d2565b6000610da3610db8565b610daf8585858561129e565b95945050505050565b6002546001600160a01b031633146107735760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152606401610425565b6001546040516278451d60e81b81526000916001600160a01b0316906378451d0090610e4290859060040161221f565b6020604051808303816000875af1158015610e61573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906103a791906121a3565b6001546000908190600160a01b900460ff1615610f195760015460405163496d511d60e11b81526001600160a01b038581166004830152306024830152909116906392daa23a906044016040805180830381865afa158015610eeb573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610f0f91906122d5565b9092509050915091565b60019150915091565b600154604051631f16aef360e01b81526004810188905260248101879052604481018690526064810185905283151560848201526001600160a01b0383811660a483015290911690631f16aef39060c401600060405180830381600087803b158015610f8d57600080fd5b505af1158015610fa1573d6000803e3d6000fd5b50505050505050505050565b60015460405163650aac6160e01b815260048101879052602481018690526001600160a01b0385811660448301526064820185905261ffff841660848301529091169063650aac619060a401600060405180830381600087803b15801561101357600080fd5b505af115801561068a573d6000803e3d6000fd5b600154600090600160a01b900460ff16156110ac57600154604051632e5f2cf160e01b81526001600160a01b03848116600483015290911690632e5f2cf1906024016020604051808303816000875af1158015611088573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906103a79190611de3565b506001919050565b6040516001600160a01b038085166024830152831660448201526064810182905261111f9085906323b872dd60e01b906084015b60408051601f198184030181529190526020810180516001600160e01b03166001600160e01b03199093169290921790915261132f565b50505050565b604051636eb1769f60e11b81523060048201526001600160a01b0383811660248301526000919085169063dd62ed3e90604401602060405180830381865afa158015611175573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061119991906121a3565b905061111f8463095ea7b360e01b856111b2868661220c565b6040516001600160a01b03909216602483015260448201526064016110e8565b600280546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b60015460405163a3fafd0560e01b81526060916001600160a01b03169063a3fafd0590611257908690869060040161230f565b6000604051808303816000875af1158015611276573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052610cf69190810190612333565b600154604051639aab948160e01b8152600481018690526001600160a01b0385811660248301526044820185905261ffff841660648301526000921690639aab9481906084016020604051808303816000875af1158015611303573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610daf91906121a3565b949350505050565b6000611384826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b03166114099092919063ffffffff16565b90508051600014806113a55750808060200190518101906113a59190611de3565b6114045760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b6064820152608401610425565b505050565b6060611327848460008585600080866001600160a01b0316858760405161143091906123dc565b60006040518083038185875af1925050503d806000811461146d576040519150601f19603f3d011682016040523d82523d6000602084013e611472565b606091505b50915091506114838783838761148e565b979650505050505050565b606083156114fd5782516000036114f6576001600160a01b0385163b6114f65760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000006044820152606401610425565b5081611327565b61132783838151156115125781518083602001fd5b8060405162461bcd60e51b815260040161042591906123ee565b634e487b7160e01b600052604160045260246000fd5b604051606081016001600160401b03811182821017156115645761156461152c565b60405290565b604080519081016001600160401b03811182821017156115645761156461152c565b60405160a081016001600160401b03811182821017156115645761156461152c565b604051601f8201601f191681016001600160401b03811182821017156115d6576115d661152c565b604052919050565b801515811461075e57600080fd5b6001600160a01b038116811461075e57600080fd5b60006001600160401b0382111561161a5761161a61152c565b5060051b60200190565b803561ffff8116811461077557600080fd5b600082601f83011261164757600080fd5b8135602061165c61165783611601565b6115ae565b8281526060928302850182019282820191908785111561167b57600080fd5b8387015b858110156116d25781818a0312156116975760008081fd5b61169f611542565b81356116aa816115ec565b8152818601358682015260406116c1818401611624565b90820152845292840192810161167f565b5090979650505050505050565b6000602082840312156116f157600080fd5b81356001600160401b038082111561170857600080fd5b9083019081850360c081121561171d57600080fd5b61172561156a565b60a082121561173357600080fd5b61173b61158c565b91508335825260208401356020830152604084013560408301526060840135611763816115de565b60608301526080840135611776816115ec565b608083015290815260a0830135908282111561179157600080fd5b61179d87838601611636565b60208201529695505050505050565b6000602082840312156117be57600080fd5b8135610cf6816115ec565b60008060008060008060c087890312156117e257600080fd5b863595506020870135945060408701359350606087013592506080870135611809816115de565b915060a0870135611819816115ec565b809150509295509295509295565b600080600080600060a0868803121561183f57600080fd5b85359450602086013593506040860135611858816115ec565b92506060860135915061186d60808701611624565b90509295509295909350565b60008083601f84011261188b57600080fd5b5081356001600160401b038111156118a257600080fd5b6020830191508360208260051b85010111156118bd57600080fd5b9250929050565b60008083601f8401126118d657600080fd5b5081356001600160401b038111156118ed57600080fd5b6020830191508360208260071b85010111156118bd57600080fd5b6000806000806000806060878903121561192157600080fd5b86356001600160401b038082111561193857600080fd5b6119448a838b01611879565b9098509650602089013591508082111561195d57600080fd5b6119698a838b01611879565b9096509450604089013591508082111561198257600080fd5b5061198f89828a016118c4565b979a9699509497509295939492505050565b6000806000806000606086880312156119b957600080fd5b85356001600160401b03808211156119d057600080fd5b6119dc89838a01611879565b90975095506020915087820135818111156119f657600080fd5b611a028a828b016118c4565b909650945050604088013581811115611a1a57600080fd5b88019050601f81018913611a2d57600080fd5b8035611a3b61165782611601565b81815260059190911b8201830190838101908b831115611a5a57600080fd5b928401925b82841015611a81578335611a72816115ec565b82529284019290840190611a5f565b80955050505050509295509295909350565b60008060408385031215611aa657600080fd5b8235611ab1816115ec565b91506020838101356001600160401b03811115611acd57600080fd5b8401601f81018613611ade57600080fd5b8035611aec61165782611601565b81815260059190911b82018301908381019088831115611b0b57600080fd5b928401925b82841015611b2957833582529284019290840190611b10565b80955050505050509250929050565b600081518084526020808501945080840160005b83811015611b6857815187529582019590820190600101611b4c565b509495945050505050565b602081526000610cf66020830184611b38565b600060208284031215611b9857600080fd5b8135610cf6816115de565b60008060008060808587031215611bb957600080fd5b843593506020850135611bcb816115ec565b925060408501359150611be060608601611624565b905092959194509250565b60208082526023908201527f417272617920706172616d73206d757374206861766520657175616c206c656e6040820152620cee8d60eb1b606082015260800190565b634e487b7160e01b600052602160045260246000fd5b634e487b7160e01b600052603260045260246000fd5b6008811061075e57600080fd5b803561077581611c5a565b600060208284031215611c8457600080fd5b8135610cf681611c5a565b634e487b7160e01b600052601160045260246000fd5b80820281158282048414176103a7576103a7611c8f565b600060018201611cce57611cce611c8f565b5060010190565b600082611cf257634e487b7160e01b600052601260045260246000fd5b500490565b60088110611d1557634e487b7160e01b600052602160045260246000fd5b9052565b8035611d2481611c5a565b611d2e8382611cf7565b506020810135611d3d816115ec565b6001600160a01b0316602083015260408181013590830152606090810135910152565b81835260208301925060008160005b84811015611d9457611d818683611d19565b6080958601959190910190600101611d6f565b5093949350505050565b60018060a01b0385168152836020820152606060408201526000611dc6606083018486611d60565b9695505050505050565b818103818111156103a7576103a7611c8f565b600060208284031215611df557600080fd5b8151610cf6816115de565b6000823561015e19833603018112611e1757600080fd5b9190910192915050565b6000808335601e19843603018112611e3857600080fd5b83016020810192503590506001600160401b03811115611e5757600080fd5b6060810236038213156118bd57600080fd5b80356001600160f81b03198116811461077557600080fd5b8183526000602080850194508260005b85811015611b68576001600160f81b0319611eab83611e69565b1687528282013583880152604080830135611ec5816115ec565b6001600160a01b0316908801526060968701969190910190600101611e91565b6000808335601e19843603018112611efc57600080fd5b83016020810192503590506001600160401b03811115611f1b57600080fd5b8060061b36038213156118bd57600080fd5b8183526000602080850194508260005b85811015611b68576001600160f81b0319611f5783611e69565b168752818301358388015260409687019690910190600101611f3d565b8183526000602080850194508260005b85811015611b68578135611f97816115ec565b6001600160a01b0316875261ffff611fb0838501611624565b16878401526040968701969190910190600101611f84565b80356001600160f01b03198116811461077557600080fd5b60608152611ff16060820186611d19565b60006080860135612001816115ec565b6001600160a01b031660e083015261201c60a0870187611e21565b61016061010081818701526120366101c087018486611e81565b935061204560c08b018b611ee5565b9350605f196101208189880301818a0152612061878785611f2d565b965061207060e08e018e611ee5565b96509250610140828a890301818b015261208b888886611f74565b9750612098858f01611c67565b96506120a6868b0188611cf7565b818e01356101808b01526120bb818f01611fc8565b96505050505050506120da6101a08501826001600160f01b0319169052565b5082810360208401526120ee818688611d60565b915050610daf60408301846001600160a01b03169052565b6000818303608081121561211957600080fd5b612121611542565b604082121561212f57600080fd5b61213761156a565b9150835161214481611c5a565b82526020840151612154816115ec565b806020840152508181526040840151602082015260608401516040820152809250505092915050565b60a0810161218b8285611d19565b6001600160a01b039290921660809190910152919050565b6000602082840312156121b557600080fd5b5051919050565b600060a08201905083516121d1838251611cf7565b6020908101516001600160a01b0390811684830152908501516040808501919091529094015160608301529190921660809092019190915290565b808201808211156103a7576103a7611c8f565b602080825282518051838301528082015160408085019190915280820151606080860191909152808301511515608080870191909152909201516001600160a01b0390811660a08601528584015160c080870152805160e08701819052600095949185019386939290916101008901905b808610156122c7578651805186168352888101518984015284015161ffff1684830152958701956001959095019490820190612290565b509998505050505050505050565b600080604083850312156122e857600080fd5b82516122f3816115de565b6020840151909250612304816115de565b809150509250929050565b6001600160a01b038316815260406020820181905260009061132790830184611b38565b6000602080838503121561234657600080fd5b82516001600160401b0381111561235c57600080fd5b8301601f8101851361236d57600080fd5b805161237b61165782611601565b81815260059190911b8201830190838101908783111561239a57600080fd5b928401925b828410156114835783518252928401929084019061239f565b60005b838110156123d35781810151838201526020016123bb565b50506000910152565b60008251611e178184602087016123b8565b602081526000825180602084015261240d8160408501602087016123b8565b601f01601f1916919091016040019291505056fea2646970667358221220cc0f15c22105a400addb0162982acfbb6a5f2f4df7f80387b43e0fe85495e39664736f6c63430008150033
Constructor Arguments (ABI-Encoded and is the last bytes of the Contract Creation Code above)
000000000000000000000000ec7ec220de84f3bdedd2b5174225d8c84e1ffd00
-----Decoded View---------------
Arg [0] : _subscrRegistry (address): 0xEC7EC220dE84F3BdeDD2b5174225d8c84E1fFD00
-----Encoded View---------------
1 Constructor Arguments found :
Arg [0] : 000000000000000000000000ec7ec220de84f3bdedd2b5174225d8c84e1ffd00
Loading...
Loading
Loading...
Loading
Loading...
Loading
[ Download: CSV Export ]
A contract address hosts a smart contract, which is a set of code stored on the blockchain that runs when predetermined conditions are met. Learn more about addresses in our Knowledge Base.