Source Code
Overview
ETH Balance
0 ETH
ETH Value
$0.00
Cross-Chain Transactions
Loading...
Loading
This contract may be a proxy contract. Click on More Options and select Is this a proxy? to confirm and enable the "Read as Proxy" & "Write as Proxy" tabs.
Contract Name:
TransferAgentModule_V5
Compiler Version
v0.8.18+commit.87f61d96
Optimization Enabled:
Yes with 200 runs
Other Settings:
default evmVersion
Contract Source Code (Solidity Standard Json-Input format)
// SPDX-License-Identifier: Business Source License 1.1
pragma solidity 0.8.18;
import {AccessControlEnumerableUpgradeable} from "@openzeppelin/contracts-upgradeable/access/AccessControlEnumerableUpgradeable.sol";
import {AccessControlUpgradeable} from "@openzeppelin/contracts-upgradeable/access/AccessControlUpgradeable.sol";
import {EnumerableSetUpgradeable} from "@openzeppelin/contracts-upgradeable/utils/structs/EnumerableSetUpgradeable.sol";
import {BaseUpgradeableModule} from "../../BaseUpgradeableModule.sol";
import {IAuthorization} from "../../../../interfaces/IAuthorization.sol";
import {IAdminTransfer} from "../../../../interfaces/IAdminTransfer.sol";
import {ITransactionStorage} from "../../../../interfaces/TransactionIfaces.sol";
import {IExtendedTransactionDetail} from "../../../../interfaces/TransactionIfaces.sol";
import {ITransferAgentExt} from "../../../../interfaces/ITransferAgentExt.sol";
import {ITransferAgentXChain} from "../../../../interfaces/ITransferAgentXChain.sol";
import {IRecovery} from "../../../../interfaces/IRecovery.sol";
import {IAccountManager} from "../../../../interfaces/IAccountManager.sol";
import {MoneyMarketFund} from "../../../../MoneyMarketFund.sol";
import {ModuleRegistry} from "../../../ModuleRegistry.sol";
import {TokenRegistry} from "../../../../infrastructure/TokenRegistry.sol";
contract TransferAgentModule_V5 is
BaseUpgradeableModule,
AccessControlEnumerableUpgradeable,
ITransferAgentExt,
IRecovery,
ITransferAgentXChain
{
bytes32 public constant MODULE_ID = keccak256("MODULE_TRANSFER_AGENT");
bytes32 public constant ROLE_MODULE_OWNER = keccak256("ROLE_MODULE_OWNER");
bytes32 constant AUTHORIZATION_MODULE = keccak256("MODULE_AUTHORIZATION");
bytes32 constant TRANSACTIONAL_MODULE = keccak256("MODULE_TRANSACTIONAL");
uint256 public constant MAX_ACCOUNT_PAGE_SIZE = 50;
uint256 public constant MAX_TX_PAGE_SIZE = 50;
uint256 public constant MAX_CX_TX_PAGE_SIZE = 10;
TokenRegistry tokenRegistry;
MoneyMarketFund moneyMarketFund;
/// @dev The Id of the token associated with the settlement and div distribution of this contract
/// At the moment only a default token Id can be provided during contract initialization
/// but in the future more tokens could be used using the token registry
string tokenId;
// *********************** Events *********************** //
// ****************************************************** //
/**
* @dev This is emitted when dividends are paid to the shareholder,
* in the very unlikely scenario of rate being lower than 0 the dividend
* will be deducted from the shareholder's balance instead:
*/
event DividendDistributed(
address indexed account,
uint256 indexed date,
int256 rate,
uint256 price,
uint256 shares,
uint256 dividendCashAmount,
uint256 dividendBasis,
bool isNegativeYield
);
/// @dev This is emitted when a shareholder request is settled:
event TransactionSettled(
address indexed account,
uint256 indexed date,
uint8 indexed transactionType,
bytes32 transactionId,
uint256 price,
uint256 amount,
uint256 shares
);
/// @dev This is emitted when a share transfer is settled:
event TransferSettled(
address indexed from,
address indexed to,
uint256 indexed date,
uint8 transactionType,
bytes32 transactionId,
uint256 price,
uint256 shares
);
/// @dev This is emitted when a manual adjustment of the balance is performed by the TA:
event BalanceAdjusted(address indexed account, uint256 amount, string memo);
/// @dev This is emmited when the entire balance of an account is recovered by the TA:
event AccountRecovered(
address indexed fromAccount,
address indexed toAccount,
uint256 amount,
string memo
);
/// @dev This is emmited when a partial balance amount of an account is recovered by the TA:
event AssetRecovered(
address indexed fromAccount,
address indexed toAccount,
uint256 amount,
string memo
);
// ---------------------- Modifiers ---------------------- //
modifier onlyAdmin() {
require(
IAuthorization(modules.getModuleAddress(AUTHORIZATION_MODULE))
.isAdminAccount(msg.sender),
"CALLER_IS_NOT_AN_ADMIN"
);
_;
}
modifier onlyWhenShareholderExists(address account) {
require(
IAuthorization(modules.getModuleAddress(AUTHORIZATION_MODULE))
.isAccountAuthorized(account),
"SHAREHOLDER_DOES_NOT_EXIST"
);
_;
}
modifier onlyWithValidRate(int256 rate) {
require(rate != 0, "INVALID_DIV_RATE");
_;
}
modifier onlyValidPaginationSize(
uint256 arrayLength,
uint256 maxArraySize
) {
require(arrayLength <= maxArraySize, "INVALID_PAGINATION_SIZE");
_;
}
modifier whenTransactionsExist(address account) {
if (
ITransactionStorage(modules.getModuleAddress(TRANSACTIONAL_MODULE))
.hasTransactions(account)
) {
_;
}
}
modifier whenNotInArray(bytes32[] calldata txIds, bytes32 currentTxId) {
if (txIds.length == 0) {
_;
return;
}
bool found = false;
uint256 arrayLength = txIds.length;
for (uint256 i = 0; i < arrayLength; ) {
if (txIds[i] == currentTxId) {
found = true;
break;
}
unchecked {
i++;
}
}
if (!found) _;
}
/// @custom:oz-upgrades-unsafe-allow constructor
constructor() {
_disableInitializers();
}
function _authorizeUpgrade(
address newImplementation
) internal virtual override onlyRole(ROLE_MODULE_OWNER) {}
function getVersion() external pure virtual override returns (uint8) {
return 5;
}
// ---------------- TA operations ---------------- //
/**
* @notice Distributes dividends to the account if it has holdings.
*
* The amount of shares to distribute in the form of divideds are calculated as follows:
*
* Share dividends = (account's balance * rate) / price
*
* This operation will mint or burn shares according to the rate provided.
* If rate > 0 it will mint shares
* If rate < 0 it will burn shares
*
* @param accounts The address of the shareholders' accounts
* @param date The date of the request as a UNIX timestamp
* @param rate The rate for the given shareholder
* @param price The NAV price per share
*
*/
function distributeDividends(
address[] memory accounts,
uint256 date,
int256 rate,
uint256 price
)
external
virtual
override
onlyAdmin
onlyWithValidRate(rate)
onlyValidPaginationSize(accounts.length, MAX_ACCOUNT_PAGE_SIZE)
{
moneyMarketFund.updateLastKnownPrice(price);
for (uint i = 0; i < accounts.length; ) {
_processDividends(
accounts[i],
moneyMarketFund.balanceOf(accounts[i]),
date,
rate,
price
);
unchecked {
i++;
}
}
}
/**
* @notice Distributes dividends and settles existing requests prior to the specified date for the given account.
*
* @param accounts The address of the shareholders' accounts
* @param date The date of the request as a UNIX timestamp
* @param rate The rate
* @param price The NAV price per share
*
*/
function endOfDay(
address[] calldata accounts,
bytes32[] calldata txIds,
uint256 date,
int256 rate,
uint256 price
)
external
virtual
override
onlyAdmin
onlyWithValidRate(rate)
onlyValidPaginationSize(accounts.length, MAX_ACCOUNT_PAGE_SIZE)
onlyValidPaginationSize(txIds.length, MAX_TX_PAGE_SIZE)
{
moneyMarketFund.updateLastKnownPrice(price);
for (uint i = 0; i < accounts.length; ) {
_processDividends(
accounts[i],
moneyMarketFund.balanceOf(accounts[i]),
date,
rate,
price
);
_processSettlements(txIds, accounts[i], date, price);
unchecked {
i++;
}
}
}
/**
* @notice Settles existing requests prior to the specified date for the given account.
*
* This operation will mint or burn shares according to the request type.
*
* @param accounts The address of the shareholders' accounts
* @param date The date of the request as a UNIX timestamp
* @param price The NAV price per share
*
*/
function settleTransactions(
address[] calldata accounts,
bytes32[] calldata txIds,
uint256 date,
uint256 price
)
external
virtual
override
onlyAdmin
onlyValidPaginationSize(accounts.length, MAX_ACCOUNT_PAGE_SIZE)
onlyValidPaginationSize(txIds.length, MAX_TX_PAGE_SIZE)
{
moneyMarketFund.updateLastKnownPrice(price);
for (uint i = 0; i < accounts.length; ) {
_processSettlements(txIds, accounts[i], date, price);
unchecked {
i++;
}
}
}
/**
* @notice Distributes full or proportional dividends to the account if it has holdings.
*
* The amount of shares to distribute in the form of divideds are calculated as follows:
*
* If the adjusted shares for the account are greather than zero,
* Share dividends = (adjusted shares * rate) / price
* Otherwise,
* Share dividends = (account's balance * rate) / price
*
* This operation will mint or burn shares according to the rate provided.
* If rate > 0 it will mint shares
* If rate < 0 it will burn shares
*
* @param accounts The address of the shareholders' accounts
* @param adjustedShares The holdings to calculate the proportional yield if any
* @param date The date of the request as a UNIX timestamp
* @param rate The rate for the given shareholder
* @param price The NAV price per share
*
*/
function distributeDividends(
address[] calldata accounts,
uint256[] calldata adjustedShares,
uint256 date,
int256 rate,
uint256 price
)
external
virtual
override
onlyAdmin
onlyWithValidRate(rate)
onlyValidPaginationSize(accounts.length, MAX_ACCOUNT_PAGE_SIZE)
onlyValidPaginationSize(adjustedShares.length, MAX_ACCOUNT_PAGE_SIZE)
{
require(
accounts.length == adjustedShares.length,
"ARRAY_LENGTH_MISMATCH"
);
moneyMarketFund.updateLastKnownPrice(price);
for (uint i = 0; i < accounts.length; ) {
uint256 accountBalance;
if (adjustedShares[i] == 0) {
accountBalance = moneyMarketFund.balanceOf(accounts[i]);
} else {
accountBalance = adjustedShares[i];
}
_processDividends(accounts[i], accountBalance, date, rate, price);
unchecked {
i++;
}
}
}
/**
* @notice Distributes full or partial dividends and settles existing requests
* prior to the specified date for the given account.
*
* @param accounts The address of the shareholders' accounts
* @param adjustedShares The holdings to calculate the proportional yield if any
* @param date The date of the request as a UNIX timestamp
* @param rate The rate
* @param price The NAV price per share
*
*/
function endOfDay(
address[] calldata accounts,
uint256[] calldata adjustedShares,
bytes32[] calldata txIds,
uint256 date,
int256 rate,
uint256 price
)
external
virtual
override
onlyAdmin
onlyWithValidRate(rate)
onlyValidPaginationSize(accounts.length, MAX_ACCOUNT_PAGE_SIZE)
onlyValidPaginationSize(adjustedShares.length, MAX_ACCOUNT_PAGE_SIZE)
onlyValidPaginationSize(txIds.length, MAX_TX_PAGE_SIZE)
{
require(
accounts.length == adjustedShares.length,
"ARRAY_LENGTH_MISMATCH"
);
moneyMarketFund.updateLastKnownPrice(price);
for (uint i = 0; i < accounts.length; ) {
uint256 accountBalance;
if (adjustedShares[i] == 0) {
accountBalance = moneyMarketFund.balanceOf(accounts[i]);
} else {
accountBalance = adjustedShares[i];
}
_processDividends(accounts[i], accountBalance, date, rate, price);
_processSettlements(txIds, accounts[i], date, price);
unchecked {
i++;
}
}
}
// ---------------- TA Cross-chain operations ---------------- //
/**
* @notice Settles all the account's request given as an array of id's prior to the specified date.
*
* @param account the address of the shareholders' account
* @param requestIds an array with the id's of the requests to process
* @param date the maximum date to finish processing request from represented as a UNIX timestamp
* @param price the NAV price per share
*/
function settleCXTransactions(
address account,
bytes32[] memory requestIds,
uint256 date,
uint256 price
)
external
virtual
override
onlyAdmin
onlyWhenShareholderExists(account)
onlyValidPaginationSize(requestIds.length, MAX_CX_TX_PAGE_SIZE)
{
for (uint i = 0; i < requestIds.length; ) {
_processCXSettlement(account, requestIds[i], date, price);
unchecked {
i++;
}
}
}
/**
* @notice Settles the given cross-chain request prior to the specified date for the given account.
*
* This operation will mint or burn shares according to the request type.
*
* @param account the address of the shareholders' account
* @param requestId the id of the request to process
* @param date the maximum date to process the request represented as a UNIX timestamp
* @param price The NAV price per share
*/
function settleCXTransaction(
address account,
bytes32 requestId,
uint256 date,
uint256 price
) external virtual override onlyAdmin onlyWhenShareholderExists(account) {
moneyMarketFund.updateLastKnownPrice(price);
_processCXSettlement(account, requestId, date, price);
}
// ---------------- TA Admin operations ---------------- //
/**
* @notice Updates the current balance of a shareholder's account to a new one.
*
* @param account the address of the shareholders' account
* @param currentBalance the current account's balance
* @param newBalance the new balance for the account
* @param memo a memo for the balance adjustment operation
*/
function adjustBalance(
address account,
uint256 currentBalance,
uint256 newBalance,
string memory memo
) external virtual override onlyAdmin onlyWhenShareholderExists(account) {
require(
currentBalance == moneyMarketFund.balanceOf(account),
"CURRENT_BALANCE_MISMATCH"
);
require(
newBalance != moneyMarketFund.balanceOf(account),
"NO_ADJUSTMENT_REQUIRED"
);
if (currentBalance > newBalance) {
moneyMarketFund.burnShares(account, (currentBalance - newBalance));
emit BalanceAdjusted(account, (currentBalance - newBalance), memo);
} else {
moneyMarketFund.mintShares(account, (newBalance - currentBalance));
emit BalanceAdjusted(account, (newBalance - currentBalance), memo);
}
}
/**
* @dev Recovers the entire balance of an account
*
* @param from the account holding the balance to recover
* @param to the destination account to transfer the balance
* @param memo a memo for the recovery operation
*/
function recoverAccount(
address from,
address to,
string memory memo
) external virtual override onlyAdmin {
// Checks
require(
!ITransactionStorage(modules.getModuleAddress(TRANSACTIONAL_MODULE))
.hasTransactions(from),
"PENDING_TRANSACTIONS_EXIST"
);
require(
moneyMarketFund.getShareHoldings(from) > 0,
"ACCOUNT_HAS_NO_BALANCE"
);
uint256 balance = moneyMarketFund.getShareHoldings(from);
// Effects & Interactions
IAdminTransfer(address(moneyMarketFund)).transferShares(
from,
to,
balance
);
IAccountManager(modules.getModuleAddress(AUTHORIZATION_MODULE))
.removeAccountPostRecovery(from, to);
emit AccountRecovered(from, to, balance, memo);
}
/**
* @dev Recovers a part of the balance of an account
*
* @param from the account holding the balance amount to recover
* @param to the destination account to transfer the balance
* @param memo a memo for the recovery operation
*/
function recoverAsset(
address from,
address to,
uint256 amount,
string memory memo
) external virtual override onlyAdmin {
// Checks
require(
IAuthorization(modules.getModuleAddress(AUTHORIZATION_MODULE))
.isAccountAuthorized(from) &&
IAuthorization(modules.getModuleAddress(AUTHORIZATION_MODULE))
.isAccountAuthorized(to),
"SHAREHOLDER_DOES_NOT_EXIST"
);
uint256 balance = moneyMarketFund.getShareHoldings(from);
require(balance >= amount, "NOT_ENOUGH_BALANCE");
// Effects & Interactions
IAdminTransfer(address(moneyMarketFund)).transferShares(
from,
to,
amount
);
emit AssetRecovered(from, to, amount, memo);
}
// -------------------- Dividends -------------------- //
function _payDividend(
address account,
uint256 dividendShares
) internal virtual {
moneyMarketFund.mintShares(account, dividendShares);
}
function _handleNegativeYield(
address account,
uint256 balance,
uint256 dividendShares
) internal {
uint256 negativeYield;
if (dividendShares < balance) {
negativeYield = dividendShares;
} else {
negativeYield = balance;
}
moneyMarketFund.burnShares(account, negativeYield);
}
// -------------------- Transactions -------------------- //
function _processSettlements(
bytes32[] calldata txIds,
address account,
uint256 date,
uint256 price
) internal virtual whenTransactionsExist(account) {
bytes32[] memory pendingTxs = ITransactionStorage(
modules.getModuleAddress(TRANSACTIONAL_MODULE)
).getAccountTransactions(account);
for (uint256 i = 0; i < pendingTxs.length; ) {
bytes32 txId = pendingTxs[i];
(
uint8 txType,
address source,
address destination,
uint256 txDate,
uint256 amount,
) = IExtendedTransactionDetail(
modules.getModuleAddress(TRANSACTIONAL_MODULE)
).getExtendedTransactionDetail(txId);
require(
_isTypeSupported(ITransactionStorage.TransactionType(txType)),
"INVALID_TRANSACTION_TYPE"
);
if (txDate <= date) {
if (
_isLiquidation(ITransactionStorage.TransactionType(txType))
) {
_handleBalanceDecrease(
account,
date,
amount,
price,
txId,
ITransactionStorage.TransactionType(txType)
);
// remove settled tx from storage
ITransactionStorage(
modules.getModuleAddress(TRANSACTIONAL_MODULE)
).clearTransactionStorage(account, txId);
} else if (
_isPurchase(ITransactionStorage.TransactionType(txType))
) {
_handlePurchaseSettlement(
txIds,
account,
date,
amount,
price,
txId,
ITransactionStorage.TransactionType(txType)
);
} else if (
ITransactionStorage.TransactionType(txType) ==
ITransactionStorage.TransactionType.SHARE_TRANSFER
) {
IAdminTransfer(tokenRegistry.getTokenAddress(tokenId))
.transferShares(source, destination, amount);
// remove settled tx from storage
ITransactionStorage(
modules.getModuleAddress(TRANSACTIONAL_MODULE)
).clearTransactionStorage(account, txId);
emit TransferSettled(
source,
destination,
date,
txType,
txId,
price,
amount // shares
);
}
}
unchecked {
i++;
}
}
ITransactionStorage(modules.getModuleAddress(TRANSACTIONAL_MODULE))
.unlistFromAccountsWithPendingTransactions(account);
}
function _processCXSettlement(
address account,
bytes32 requestId,
uint256 date,
uint256 price
) internal virtual whenTransactionsExist(account) {
(
uint8 txType,
,
,
uint256 txDate,
uint256 amount,
) = IExtendedTransactionDetail(
modules.getModuleAddress(TRANSACTIONAL_MODULE)
).getExtendedTransactionDetail(requestId);
require(
_isTypeSupported(ITransactionStorage.TransactionType(txType)),
"INVALID_TRANSACTION_TYPE"
);
if (txDate <= date) {
if (
ITransactionStorage.TransactionType(txType) ==
ITransactionStorage.TransactionType.CXFER_OUT
) {
_handleBalanceDecrease(
account,
date,
amount,
price,
requestId,
ITransactionStorage.TransactionType(txType)
);
ITransactionStorage(
modules.getModuleAddress(TRANSACTIONAL_MODULE)
).clearTransactionStorage(account, requestId);
} else if (
ITransactionStorage.TransactionType(txType) ==
ITransactionStorage.TransactionType.CXFER_IN
) {
_handleBalanceIncrease(
account,
date,
amount,
price,
requestId,
ITransactionStorage.TransactionType(txType)
);
ITransactionStorage(
modules.getModuleAddress(TRANSACTIONAL_MODULE)
).clearTransactionStorage(account, requestId);
}
ITransactionStorage(modules.getModuleAddress(TRANSACTIONAL_MODULE))
.unlistFromAccountsWithPendingTransactions(account);
}
}
function _processDividends(
address account,
uint256 balance,
uint256 date,
int256 rate,
uint256 price
) internal virtual {
require(price > 0, "INVALID_PRICE");
if (balance > 0) {
uint256 dividendAmount = balance * uint256(abs(rate));
uint256 dividendShares = dividendAmount / price;
uint256 scaleFactor = moneyMarketFund.NUMBER_SCALE_FACTOR();
// a valid rate for this internal function (rate != 0) is verified
// in the calling function via the 'onlyWithValidRate' modifier
bool isNegativeYield;
if (rate > 0) {
isNegativeYield = false;
_payDividend(account, dividendShares);
} else {
// handle very unlikely scenario if occurs
isNegativeYield = true;
_handleNegativeYield(account, balance, dividendShares);
}
emit DividendDistributed(
account,
date,
rate,
price,
dividendShares,
dividendAmount / scaleFactor,
balance,
isNegativeYield
);
}
}
function _handleBalanceDecrease(
address account,
uint256 date,
uint256 amount,
uint256 price,
bytes32 txId,
ITransactionStorage.TransactionType txType
) internal virtual {
uint256 scaleFactor = moneyMarketFund.NUMBER_SCALE_FACTOR();
if (txType == ITransactionStorage.TransactionType.FULL_LIQUIDATION) {
uint256 lastBalance = moneyMarketFund.balanceOf(account);
moneyMarketFund.burnShares(account, lastBalance);
emit TransactionSettled(
account,
date,
uint8(txType),
txId,
price,
(lastBalance * price) / scaleFactor,
lastBalance
);
} else {
uint256 shares = _getQuantityOfTokens(scaleFactor, amount, price);
moneyMarketFund.burnShares(account, shares);
emit TransactionSettled(
account,
date,
uint8(txType),
txId,
price,
amount,
shares
);
}
}
function _handleBalanceIncrease(
address account,
uint256 date,
uint256 amount,
uint256 price,
bytes32 txId,
ITransactionStorage.TransactionType txType
) internal virtual {
uint256 shares = _getQuantityOfTokens(
moneyMarketFund.NUMBER_SCALE_FACTOR(),
amount,
price
);
emit TransactionSettled(
account,
date,
uint8(txType),
txId,
price,
amount,
shares
);
moneyMarketFund.mintShares(account, shares);
}
function _handlePurchaseSettlement(
bytes32[] calldata txIds,
address account,
uint256 date,
uint256 amount,
uint256 price,
bytes32 txId,
ITransactionStorage.TransactionType txType
) internal virtual whenNotInArray(txIds, txId) {
_handleBalanceIncrease(account, date, amount, price, txId, txType);
// remove settled tx from storage
ITransactionStorage(modules.getModuleAddress(TRANSACTIONAL_MODULE))
.clearTransactionStorage(account, txId);
}
function _isTypeSupported(
ITransactionStorage.TransactionType txType
) internal pure virtual returns (bool) {
return (txType == ITransactionStorage.TransactionType.AIP ||
txType == ITransactionStorage.TransactionType.CASH_PURCHASE ||
txType == ITransactionStorage.TransactionType.CASH_LIQUIDATION ||
txType == ITransactionStorage.TransactionType.FULL_LIQUIDATION ||
txType == ITransactionStorage.TransactionType.SHARE_TRANSFER ||
txType == ITransactionStorage.TransactionType.CXFER_OUT ||
txType == ITransactionStorage.TransactionType.CXFER_IN);
}
function _isPurchase(
ITransactionStorage.TransactionType txType
) internal pure virtual returns (bool) {
return (txType == ITransactionStorage.TransactionType.AIP ||
txType == ITransactionStorage.TransactionType.CASH_PURCHASE);
}
function _isLiquidation(
ITransactionStorage.TransactionType txType
) internal pure virtual returns (bool) {
return (txType ==
ITransactionStorage.TransactionType.CASH_LIQUIDATION ||
txType == ITransactionStorage.TransactionType.FULL_LIQUIDATION);
}
// ------------------------------------------------------------------- //
function _getQuantityOfTokens(
uint256 scaleFactor,
uint256 amount,
uint256 price
) internal pure virtual returns (uint256) {
return ((amount * scaleFactor) / price);
}
function abs(int x) internal pure virtual returns (int) {
require(x != type(int256).min, "ARITHMETIC_OVERFLOW");
return x >= 0 ? x : -x;
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.5.0) (access/AccessControlEnumerable.sol)
pragma solidity ^0.8.0;
import "./IAccessControlEnumerableUpgradeable.sol";
import "./AccessControlUpgradeable.sol";
import "../utils/structs/EnumerableSetUpgradeable.sol";
import "../proxy/utils/Initializable.sol";
/**
* @dev Extension of {AccessControl} that allows enumerating the members of each role.
*/
abstract contract AccessControlEnumerableUpgradeable is Initializable, IAccessControlEnumerableUpgradeable, AccessControlUpgradeable {
function __AccessControlEnumerable_init() internal onlyInitializing {
}
function __AccessControlEnumerable_init_unchained() internal onlyInitializing {
}
using EnumerableSetUpgradeable for EnumerableSetUpgradeable.AddressSet;
mapping(bytes32 => EnumerableSetUpgradeable.AddressSet) private _roleMembers;
/**
* @dev See {IERC165-supportsInterface}.
*/
function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
return interfaceId == type(IAccessControlEnumerableUpgradeable).interfaceId || super.supportsInterface(interfaceId);
}
/**
* @dev Returns one of the accounts that have `role`. `index` must be a
* value between 0 and {getRoleMemberCount}, non-inclusive.
*
* Role bearers are not sorted in any particular way, and their ordering may
* change at any point.
*
* WARNING: When using {getRoleMember} and {getRoleMemberCount}, make sure
* you perform all queries on the same block. See the following
* https://forum.openzeppelin.com/t/iterating-over-elements-on-enumerableset-in-openzeppelin-contracts/2296[forum post]
* for more information.
*/
function getRoleMember(bytes32 role, uint256 index) public view virtual override returns (address) {
return _roleMembers[role].at(index);
}
/**
* @dev Returns the number of accounts that have `role`. Can be used
* together with {getRoleMember} to enumerate all bearers of a role.
*/
function getRoleMemberCount(bytes32 role) public view virtual override returns (uint256) {
return _roleMembers[role].length();
}
/**
* @dev Overload {_grantRole} to track enumerable memberships
*/
function _grantRole(bytes32 role, address account) internal virtual override {
super._grantRole(role, account);
_roleMembers[role].add(account);
}
/**
* @dev Overload {_revokeRole} to track enumerable memberships
*/
function _revokeRole(bytes32 role, address account) internal virtual override {
super._revokeRole(role, account);
_roleMembers[role].remove(account);
}
/**
* @dev This empty reserved space is put in place to allow future versions to add new
* variables without shifting down storage in the inheritance chain.
* See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps
*/
uint256[49] private __gap;
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (access/AccessControl.sol)
pragma solidity ^0.8.0;
import "./IAccessControlUpgradeable.sol";
import "../utils/ContextUpgradeable.sol";
import "../utils/StringsUpgradeable.sol";
import "../utils/introspection/ERC165Upgradeable.sol";
import "../proxy/utils/Initializable.sol";
/**
* @dev Contract module that allows children to implement role-based access
* control mechanisms. This is a lightweight version that doesn't allow enumerating role
* members except through off-chain means by accessing the contract event logs. Some
* applications may benefit from on-chain enumerability, for those cases see
* {AccessControlEnumerable}.
*
* Roles are referred to by their `bytes32` identifier. These should be exposed
* in the external API and be unique. The best way to achieve this is by
* using `public constant` hash digests:
*
* ```solidity
* bytes32 public constant MY_ROLE = keccak256("MY_ROLE");
* ```
*
* Roles can be used to represent a set of permissions. To restrict access to a
* function call, use {hasRole}:
*
* ```solidity
* function foo() public {
* require(hasRole(MY_ROLE, msg.sender));
* ...
* }
* ```
*
* Roles can be granted and revoked dynamically via the {grantRole} and
* {revokeRole} functions. Each role has an associated admin role, and only
* accounts that have a role's admin role can call {grantRole} and {revokeRole}.
*
* By default, the admin role for all roles is `DEFAULT_ADMIN_ROLE`, which means
* that only accounts with this role will be able to grant or revoke other
* roles. More complex role relationships can be created by using
* {_setRoleAdmin}.
*
* WARNING: The `DEFAULT_ADMIN_ROLE` is also its own admin: it has permission to
* grant and revoke this role. Extra precautions should be taken to secure
* accounts that have been granted it. We recommend using {AccessControlDefaultAdminRules}
* to enforce additional security measures for this role.
*/
abstract contract AccessControlUpgradeable is Initializable, ContextUpgradeable, IAccessControlUpgradeable, ERC165Upgradeable {
function __AccessControl_init() internal onlyInitializing {
}
function __AccessControl_init_unchained() internal onlyInitializing {
}
struct RoleData {
mapping(address => bool) members;
bytes32 adminRole;
}
mapping(bytes32 => RoleData) private _roles;
bytes32 public constant DEFAULT_ADMIN_ROLE = 0x00;
/**
* @dev Modifier that checks that an account has a specific role. Reverts
* with a standardized message including the required role.
*
* The format of the revert reason is given by the following regular expression:
*
* /^AccessControl: account (0x[0-9a-f]{40}) is missing role (0x[0-9a-f]{64})$/
*
* _Available since v4.1._
*/
modifier onlyRole(bytes32 role) {
_checkRole(role);
_;
}
/**
* @dev See {IERC165-supportsInterface}.
*/
function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
return interfaceId == type(IAccessControlUpgradeable).interfaceId || super.supportsInterface(interfaceId);
}
/**
* @dev Returns `true` if `account` has been granted `role`.
*/
function hasRole(bytes32 role, address account) public view virtual override returns (bool) {
return _roles[role].members[account];
}
/**
* @dev Revert with a standard message if `_msgSender()` is missing `role`.
* Overriding this function changes the behavior of the {onlyRole} modifier.
*
* Format of the revert message is described in {_checkRole}.
*
* _Available since v4.6._
*/
function _checkRole(bytes32 role) internal view virtual {
_checkRole(role, _msgSender());
}
/**
* @dev Revert with a standard message if `account` is missing `role`.
*
* The format of the revert reason is given by the following regular expression:
*
* /^AccessControl: account (0x[0-9a-f]{40}) is missing role (0x[0-9a-f]{64})$/
*/
function _checkRole(bytes32 role, address account) internal view virtual {
if (!hasRole(role, account)) {
revert(
string(
abi.encodePacked(
"AccessControl: account ",
StringsUpgradeable.toHexString(account),
" is missing role ",
StringsUpgradeable.toHexString(uint256(role), 32)
)
)
);
}
}
/**
* @dev Returns the admin role that controls `role`. See {grantRole} and
* {revokeRole}.
*
* To change a role's admin, use {_setRoleAdmin}.
*/
function getRoleAdmin(bytes32 role) public view virtual override returns (bytes32) {
return _roles[role].adminRole;
}
/**
* @dev Grants `role` to `account`.
*
* If `account` had not been already granted `role`, emits a {RoleGranted}
* event.
*
* Requirements:
*
* - the caller must have ``role``'s admin role.
*
* May emit a {RoleGranted} event.
*/
function grantRole(bytes32 role, address account) public virtual override onlyRole(getRoleAdmin(role)) {
_grantRole(role, account);
}
/**
* @dev Revokes `role` from `account`.
*
* If `account` had been granted `role`, emits a {RoleRevoked} event.
*
* Requirements:
*
* - the caller must have ``role``'s admin role.
*
* May emit a {RoleRevoked} event.
*/
function revokeRole(bytes32 role, address account) public virtual override onlyRole(getRoleAdmin(role)) {
_revokeRole(role, account);
}
/**
* @dev Revokes `role` from the calling account.
*
* Roles are often managed via {grantRole} and {revokeRole}: this function's
* purpose is to provide a mechanism for accounts to lose their privileges
* if they are compromised (such as when a trusted device is misplaced).
*
* If the calling account had been revoked `role`, emits a {RoleRevoked}
* event.
*
* Requirements:
*
* - the caller must be `account`.
*
* May emit a {RoleRevoked} event.
*/
function renounceRole(bytes32 role, address account) public virtual override {
require(account == _msgSender(), "AccessControl: can only renounce roles for self");
_revokeRole(role, account);
}
/**
* @dev Grants `role` to `account`.
*
* If `account` had not been already granted `role`, emits a {RoleGranted}
* event. Note that unlike {grantRole}, this function doesn't perform any
* checks on the calling account.
*
* May emit a {RoleGranted} event.
*
* [WARNING]
* ====
* This function should only be called from the constructor when setting
* up the initial roles for the system.
*
* Using this function in any other way is effectively circumventing the admin
* system imposed by {AccessControl}.
* ====
*
* NOTE: This function is deprecated in favor of {_grantRole}.
*/
function _setupRole(bytes32 role, address account) internal virtual {
_grantRole(role, account);
}
/**
* @dev Sets `adminRole` as ``role``'s admin role.
*
* Emits a {RoleAdminChanged} event.
*/
function _setRoleAdmin(bytes32 role, bytes32 adminRole) internal virtual {
bytes32 previousAdminRole = getRoleAdmin(role);
_roles[role].adminRole = adminRole;
emit RoleAdminChanged(role, previousAdminRole, adminRole);
}
/**
* @dev Grants `role` to `account`.
*
* Internal function without access restriction.
*
* May emit a {RoleGranted} event.
*/
function _grantRole(bytes32 role, address account) internal virtual {
if (!hasRole(role, account)) {
_roles[role].members[account] = true;
emit RoleGranted(role, account, _msgSender());
}
}
/**
* @dev Revokes `role` from `account`.
*
* Internal function without access restriction.
*
* May emit a {RoleRevoked} event.
*/
function _revokeRole(bytes32 role, address account) internal virtual {
if (hasRole(role, account)) {
_roles[role].members[account] = false;
emit RoleRevoked(role, account, _msgSender());
}
}
/**
* @dev This empty reserved space is put in place to allow future versions to add new
* variables without shifting down storage in the inheritance chain.
* See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps
*/
uint256[49] private __gap;
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (access/IAccessControlEnumerable.sol)
pragma solidity ^0.8.0;
import "./IAccessControlUpgradeable.sol";
/**
* @dev External interface of AccessControlEnumerable declared to support ERC165 detection.
*/
interface IAccessControlEnumerableUpgradeable is IAccessControlUpgradeable {
/**
* @dev Returns one of the accounts that have `role`. `index` must be a
* value between 0 and {getRoleMemberCount}, non-inclusive.
*
* Role bearers are not sorted in any particular way, and their ordering may
* change at any point.
*
* WARNING: When using {getRoleMember} and {getRoleMemberCount}, make sure
* you perform all queries on the same block. See the following
* https://forum.openzeppelin.com/t/iterating-over-elements-on-enumerableset-in-openzeppelin-contracts/2296[forum post]
* for more information.
*/
function getRoleMember(bytes32 role, uint256 index) external view returns (address);
/**
* @dev Returns the number of accounts that have `role`. Can be used
* together with {getRoleMember} to enumerate all bearers of a role.
*/
function getRoleMemberCount(bytes32 role) external view returns (uint256);
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (access/IAccessControl.sol)
pragma solidity ^0.8.0;
/**
* @dev External interface of AccessControl declared to support ERC165 detection.
*/
interface IAccessControlUpgradeable {
/**
* @dev Emitted when `newAdminRole` is set as ``role``'s admin role, replacing `previousAdminRole`
*
* `DEFAULT_ADMIN_ROLE` is the starting admin for all roles, despite
* {RoleAdminChanged} not being emitted signaling this.
*
* _Available since v3.1._
*/
event RoleAdminChanged(bytes32 indexed role, bytes32 indexed previousAdminRole, bytes32 indexed newAdminRole);
/**
* @dev Emitted when `account` is granted `role`.
*
* `sender` is the account that originated the contract call, an admin role
* bearer except when using {AccessControl-_setupRole}.
*/
event RoleGranted(bytes32 indexed role, address indexed account, address indexed sender);
/**
* @dev Emitted when `account` is revoked `role`.
*
* `sender` is the account that originated the contract call:
* - if using `revokeRole`, it is the admin role bearer
* - if using `renounceRole`, it is the role bearer (i.e. `account`)
*/
event RoleRevoked(bytes32 indexed role, address indexed account, address indexed sender);
/**
* @dev Returns `true` if `account` has been granted `role`.
*/
function hasRole(bytes32 role, address account) external view returns (bool);
/**
* @dev Returns the admin role that controls `role`. See {grantRole} and
* {revokeRole}.
*
* To change a role's admin, use {AccessControl-_setRoleAdmin}.
*/
function getRoleAdmin(bytes32 role) external view returns (bytes32);
/**
* @dev Grants `role` to `account`.
*
* If `account` had not been already granted `role`, emits a {RoleGranted}
* event.
*
* Requirements:
*
* - the caller must have ``role``'s admin role.
*/
function grantRole(bytes32 role, address account) external;
/**
* @dev Revokes `role` from `account`.
*
* If `account` had been granted `role`, emits a {RoleRevoked} event.
*
* Requirements:
*
* - the caller must have ``role``'s admin role.
*/
function revokeRole(bytes32 role, address account) external;
/**
* @dev Revokes `role` from the calling account.
*
* Roles are often managed via {grantRole} and {revokeRole}: this function's
* purpose is to provide a mechanism for accounts to lose their privileges
* if they are compromised (such as when a trusted device is misplaced).
*
* If the calling account had been granted `role`, emits a {RoleRevoked}
* event.
*
* Requirements:
*
* - the caller must be `account`.
*/
function renounceRole(bytes32 role, address account) external;
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.5.0) (interfaces/draft-IERC1822.sol)
pragma solidity ^0.8.0;
/**
* @dev ERC1822: Universal Upgradeable Proxy Standard (UUPS) documents a method for upgradeability through a simplified
* proxy whose upgrades are fully controlled by the current implementation.
*/
interface IERC1822ProxiableUpgradeable {
/**
* @dev Returns the storage slot that the proxiable contract assumes is being used to store the implementation
* address.
*
* IMPORTANT: A proxy pointing at a proxiable contract should not be considered proxiable itself, because this risks
* bricking a proxy that upgrades to it, by delegating to itself until out of gas. Thus it is critical that this
* function revert if invoked through a proxy.
*/
function proxiableUUID() external view returns (bytes32);
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (interfaces/IERC1967.sol)
pragma solidity ^0.8.0;
/**
* @dev ERC-1967: Proxy Storage Slots. This interface contains the events defined in the ERC.
*
* _Available since v4.8.3._
*/
interface IERC1967Upgradeable {
/**
* @dev Emitted when the implementation is upgraded.
*/
event Upgraded(address indexed implementation);
/**
* @dev Emitted when the admin account has changed.
*/
event AdminChanged(address previousAdmin, address newAdmin);
/**
* @dev Emitted when the beacon is changed.
*/
event BeaconUpgraded(address indexed beacon);
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (proxy/beacon/IBeacon.sol)
pragma solidity ^0.8.0;
/**
* @dev This is the interface that {BeaconProxy} expects of its beacon.
*/
interface IBeaconUpgradeable {
/**
* @dev Must return an address that can be used as a delegate call target.
*
* {BeaconProxy} will check that this address is a contract.
*/
function implementation() external view returns (address);
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (proxy/ERC1967/ERC1967Upgrade.sol)
pragma solidity ^0.8.2;
import "../beacon/IBeaconUpgradeable.sol";
import "../../interfaces/IERC1967Upgradeable.sol";
import "../../interfaces/draft-IERC1822Upgradeable.sol";
import "../../utils/AddressUpgradeable.sol";
import "../../utils/StorageSlotUpgradeable.sol";
import "../utils/Initializable.sol";
/**
* @dev This abstract contract provides getters and event emitting update functions for
* https://eips.ethereum.org/EIPS/eip-1967[EIP1967] slots.
*
* _Available since v4.1._
*/
abstract contract ERC1967UpgradeUpgradeable is Initializable, IERC1967Upgradeable {
function __ERC1967Upgrade_init() internal onlyInitializing {
}
function __ERC1967Upgrade_init_unchained() internal onlyInitializing {
}
// This is the keccak-256 hash of "eip1967.proxy.rollback" subtracted by 1
bytes32 private constant _ROLLBACK_SLOT = 0x4910fdfa16fed3260ed0e7147f7cc6da11a60208b5b9406d12a635614ffd9143;
/**
* @dev Storage slot with the address of the current implementation.
* This is the keccak-256 hash of "eip1967.proxy.implementation" subtracted by 1, and is
* validated in the constructor.
*/
bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;
/**
* @dev Returns the current implementation address.
*/
function _getImplementation() internal view returns (address) {
return StorageSlotUpgradeable.getAddressSlot(_IMPLEMENTATION_SLOT).value;
}
/**
* @dev Stores a new address in the EIP1967 implementation slot.
*/
function _setImplementation(address newImplementation) private {
require(AddressUpgradeable.isContract(newImplementation), "ERC1967: new implementation is not a contract");
StorageSlotUpgradeable.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation;
}
/**
* @dev Perform implementation upgrade
*
* Emits an {Upgraded} event.
*/
function _upgradeTo(address newImplementation) internal {
_setImplementation(newImplementation);
emit Upgraded(newImplementation);
}
/**
* @dev Perform implementation upgrade with additional setup call.
*
* Emits an {Upgraded} event.
*/
function _upgradeToAndCall(address newImplementation, bytes memory data, bool forceCall) internal {
_upgradeTo(newImplementation);
if (data.length > 0 || forceCall) {
AddressUpgradeable.functionDelegateCall(newImplementation, data);
}
}
/**
* @dev Perform implementation upgrade with security checks for UUPS proxies, and additional setup call.
*
* Emits an {Upgraded} event.
*/
function _upgradeToAndCallUUPS(address newImplementation, bytes memory data, bool forceCall) internal {
// Upgrades from old implementations will perform a rollback test. This test requires the new
// implementation to upgrade back to the old, non-ERC1822 compliant, implementation. Removing
// this special case will break upgrade paths from old UUPS implementation to new ones.
if (StorageSlotUpgradeable.getBooleanSlot(_ROLLBACK_SLOT).value) {
_setImplementation(newImplementation);
} else {
try IERC1822ProxiableUpgradeable(newImplementation).proxiableUUID() returns (bytes32 slot) {
require(slot == _IMPLEMENTATION_SLOT, "ERC1967Upgrade: unsupported proxiableUUID");
} catch {
revert("ERC1967Upgrade: new implementation is not UUPS");
}
_upgradeToAndCall(newImplementation, data, forceCall);
}
}
/**
* @dev Storage slot with the admin of the contract.
* This is the keccak-256 hash of "eip1967.proxy.admin" subtracted by 1, and is
* validated in the constructor.
*/
bytes32 internal constant _ADMIN_SLOT = 0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103;
/**
* @dev Returns the current admin.
*/
function _getAdmin() internal view returns (address) {
return StorageSlotUpgradeable.getAddressSlot(_ADMIN_SLOT).value;
}
/**
* @dev Stores a new address in the EIP1967 admin slot.
*/
function _setAdmin(address newAdmin) private {
require(newAdmin != address(0), "ERC1967: new admin is the zero address");
StorageSlotUpgradeable.getAddressSlot(_ADMIN_SLOT).value = newAdmin;
}
/**
* @dev Changes the admin of the proxy.
*
* Emits an {AdminChanged} event.
*/
function _changeAdmin(address newAdmin) internal {
emit AdminChanged(_getAdmin(), newAdmin);
_setAdmin(newAdmin);
}
/**
* @dev The storage slot of the UpgradeableBeacon contract which defines the implementation for this proxy.
* This is bytes32(uint256(keccak256('eip1967.proxy.beacon')) - 1)) and is validated in the constructor.
*/
bytes32 internal constant _BEACON_SLOT = 0xa3f0ad74e5423aebfd80d3ef4346578335a9a72aeaee59ff6cb3582b35133d50;
/**
* @dev Returns the current beacon.
*/
function _getBeacon() internal view returns (address) {
return StorageSlotUpgradeable.getAddressSlot(_BEACON_SLOT).value;
}
/**
* @dev Stores a new beacon in the EIP1967 beacon slot.
*/
function _setBeacon(address newBeacon) private {
require(AddressUpgradeable.isContract(newBeacon), "ERC1967: new beacon is not a contract");
require(
AddressUpgradeable.isContract(IBeaconUpgradeable(newBeacon).implementation()),
"ERC1967: beacon implementation is not a contract"
);
StorageSlotUpgradeable.getAddressSlot(_BEACON_SLOT).value = newBeacon;
}
/**
* @dev Perform beacon upgrade with additional setup call. Note: This upgrades the address of the beacon, it does
* not upgrade the implementation contained in the beacon (see {UpgradeableBeacon-_setImplementation} for that).
*
* Emits a {BeaconUpgraded} event.
*/
function _upgradeBeaconToAndCall(address newBeacon, bytes memory data, bool forceCall) internal {
_setBeacon(newBeacon);
emit BeaconUpgraded(newBeacon);
if (data.length > 0 || forceCall) {
AddressUpgradeable.functionDelegateCall(IBeaconUpgradeable(newBeacon).implementation(), data);
}
}
/**
* @dev This empty reserved space is put in place to allow future versions to add new
* variables without shifting down storage in the inheritance chain.
* See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps
*/
uint256[50] private __gap;
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (proxy/utils/Initializable.sol)
pragma solidity ^0.8.2;
import "../../utils/AddressUpgradeable.sol";
/**
* @dev This is a base contract to aid in writing upgradeable contracts, or any kind of contract that will be deployed
* behind a proxy. Since proxied contracts do not make use of a constructor, it's common to move constructor logic to an
* external initializer function, usually called `initialize`. It then becomes necessary to protect this initializer
* function so it can only be called once. The {initializer} modifier provided by this contract will have this effect.
*
* The initialization functions use a version number. Once a version number is used, it is consumed and cannot be
* reused. This mechanism prevents re-execution of each "step" but allows the creation of new initialization steps in
* case an upgrade adds a module that needs to be initialized.
*
* For example:
*
* [.hljs-theme-light.nopadding]
* ```solidity
* contract MyToken is ERC20Upgradeable {
* function initialize() initializer public {
* __ERC20_init("MyToken", "MTK");
* }
* }
*
* contract MyTokenV2 is MyToken, ERC20PermitUpgradeable {
* function initializeV2() reinitializer(2) public {
* __ERC20Permit_init("MyToken");
* }
* }
* ```
*
* TIP: To avoid leaving the proxy in an uninitialized state, the initializer function should be called as early as
* possible by providing the encoded function call as the `_data` argument to {ERC1967Proxy-constructor}.
*
* CAUTION: When used with inheritance, manual care must be taken to not invoke a parent initializer twice, or to ensure
* that all initializers are idempotent. This is not verified automatically as constructors are by Solidity.
*
* [CAUTION]
* ====
* Avoid leaving a contract uninitialized.
*
* An uninitialized contract can be taken over by an attacker. This applies to both a proxy and its implementation
* contract, which may impact the proxy. To prevent the implementation contract from being used, you should invoke
* the {_disableInitializers} function in the constructor to automatically lock it when it is deployed:
*
* [.hljs-theme-light.nopadding]
* ```
* /// @custom:oz-upgrades-unsafe-allow constructor
* constructor() {
* _disableInitializers();
* }
* ```
* ====
*/
abstract contract Initializable {
/**
* @dev Indicates that the contract has been initialized.
* @custom:oz-retyped-from bool
*/
uint8 private _initialized;
/**
* @dev Indicates that the contract is in the process of being initialized.
*/
bool private _initializing;
/**
* @dev Triggered when the contract has been initialized or reinitialized.
*/
event Initialized(uint8 version);
/**
* @dev A modifier that defines a protected initializer function that can be invoked at most once. In its scope,
* `onlyInitializing` functions can be used to initialize parent contracts.
*
* Similar to `reinitializer(1)`, except that functions marked with `initializer` can be nested in the context of a
* constructor.
*
* Emits an {Initialized} event.
*/
modifier initializer() {
bool isTopLevelCall = !_initializing;
require(
(isTopLevelCall && _initialized < 1) || (!AddressUpgradeable.isContract(address(this)) && _initialized == 1),
"Initializable: contract is already initialized"
);
_initialized = 1;
if (isTopLevelCall) {
_initializing = true;
}
_;
if (isTopLevelCall) {
_initializing = false;
emit Initialized(1);
}
}
/**
* @dev A modifier that defines a protected reinitializer function that can be invoked at most once, and only if the
* contract hasn't been initialized to a greater version before. In its scope, `onlyInitializing` functions can be
* used to initialize parent contracts.
*
* A reinitializer may be used after the original initialization step. This is essential to configure modules that
* are added through upgrades and that require initialization.
*
* When `version` is 1, this modifier is similar to `initializer`, except that functions marked with `reinitializer`
* cannot be nested. If one is invoked in the context of another, execution will revert.
*
* Note that versions can jump in increments greater than 1; this implies that if multiple reinitializers coexist in
* a contract, executing them in the right order is up to the developer or operator.
*
* WARNING: setting the version to 255 will prevent any future reinitialization.
*
* Emits an {Initialized} event.
*/
modifier reinitializer(uint8 version) {
require(!_initializing && _initialized < version, "Initializable: contract is already initialized");
_initialized = version;
_initializing = true;
_;
_initializing = false;
emit Initialized(version);
}
/**
* @dev Modifier to protect an initialization function so that it can only be invoked by functions with the
* {initializer} and {reinitializer} modifiers, directly or indirectly.
*/
modifier onlyInitializing() {
require(_initializing, "Initializable: contract is not initializing");
_;
}
/**
* @dev Locks the contract, preventing any future reinitialization. This cannot be part of an initializer call.
* Calling this in the constructor of a contract will prevent that contract from being initialized or reinitialized
* to any version. It is recommended to use this to lock implementation contracts that are designed to be called
* through proxies.
*
* Emits an {Initialized} event the first time it is successfully executed.
*/
function _disableInitializers() internal virtual {
require(!_initializing, "Initializable: contract is initializing");
if (_initialized != type(uint8).max) {
_initialized = type(uint8).max;
emit Initialized(type(uint8).max);
}
}
/**
* @dev Returns the highest version that has been initialized. See {reinitializer}.
*/
function _getInitializedVersion() internal view returns (uint8) {
return _initialized;
}
/**
* @dev Returns `true` if the contract is currently initializing. See {onlyInitializing}.
*/
function _isInitializing() internal view returns (bool) {
return _initializing;
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (proxy/utils/UUPSUpgradeable.sol)
pragma solidity ^0.8.0;
import "../../interfaces/draft-IERC1822Upgradeable.sol";
import "../ERC1967/ERC1967UpgradeUpgradeable.sol";
import "./Initializable.sol";
/**
* @dev An upgradeability mechanism designed for UUPS proxies. The functions included here can perform an upgrade of an
* {ERC1967Proxy}, when this contract is set as the implementation behind such a proxy.
*
* A security mechanism ensures that an upgrade does not turn off upgradeability accidentally, although this risk is
* reinstated if the upgrade retains upgradeability but removes the security mechanism, e.g. by replacing
* `UUPSUpgradeable` with a custom implementation of upgrades.
*
* The {_authorizeUpgrade} function must be overridden to include access restriction to the upgrade mechanism.
*
* _Available since v4.1._
*/
abstract contract UUPSUpgradeable is Initializable, IERC1822ProxiableUpgradeable, ERC1967UpgradeUpgradeable {
function __UUPSUpgradeable_init() internal onlyInitializing {
}
function __UUPSUpgradeable_init_unchained() internal onlyInitializing {
}
/// @custom:oz-upgrades-unsafe-allow state-variable-immutable state-variable-assignment
address private immutable __self = address(this);
/**
* @dev Check that the execution is being performed through a delegatecall call and that the execution context is
* a proxy contract with an implementation (as defined in ERC1967) pointing to self. This should only be the case
* for UUPS and transparent proxies that are using the current contract as their implementation. Execution of a
* function through ERC1167 minimal proxies (clones) would not normally pass this test, but is not guaranteed to
* fail.
*/
modifier onlyProxy() {
require(address(this) != __self, "Function must be called through delegatecall");
require(_getImplementation() == __self, "Function must be called through active proxy");
_;
}
/**
* @dev Check that the execution is not being performed through a delegate call. This allows a function to be
* callable on the implementing contract but not through proxies.
*/
modifier notDelegated() {
require(address(this) == __self, "UUPSUpgradeable: must not be called through delegatecall");
_;
}
/**
* @dev Implementation of the ERC1822 {proxiableUUID} function. This returns the storage slot used by the
* implementation. It is used to validate the implementation's compatibility when performing an upgrade.
*
* IMPORTANT: A proxy pointing at a proxiable contract should not be considered proxiable itself, because this risks
* bricking a proxy that upgrades to it, by delegating to itself until out of gas. Thus it is critical that this
* function revert if invoked through a proxy. This is guaranteed by the `notDelegated` modifier.
*/
function proxiableUUID() external view virtual override notDelegated returns (bytes32) {
return _IMPLEMENTATION_SLOT;
}
/**
* @dev Upgrade the implementation of the proxy to `newImplementation`.
*
* Calls {_authorizeUpgrade}.
*
* Emits an {Upgraded} event.
*
* @custom:oz-upgrades-unsafe-allow-reachable delegatecall
*/
function upgradeTo(address newImplementation) public virtual onlyProxy {
_authorizeUpgrade(newImplementation);
_upgradeToAndCallUUPS(newImplementation, new bytes(0), false);
}
/**
* @dev Upgrade the implementation of the proxy to `newImplementation`, and subsequently execute the function call
* encoded in `data`.
*
* Calls {_authorizeUpgrade}.
*
* Emits an {Upgraded} event.
*
* @custom:oz-upgrades-unsafe-allow-reachable delegatecall
*/
function upgradeToAndCall(address newImplementation, bytes memory data) public payable virtual onlyProxy {
_authorizeUpgrade(newImplementation);
_upgradeToAndCallUUPS(newImplementation, data, true);
}
/**
* @dev Function that should revert when `msg.sender` is not authorized to upgrade the contract. Called by
* {upgradeTo} and {upgradeToAndCall}.
*
* Normally, this function will use an xref:access.adoc[access control] modifier such as {Ownable-onlyOwner}.
*
* ```solidity
* function _authorizeUpgrade(address) internal override onlyOwner {}
* ```
*/
function _authorizeUpgrade(address newImplementation) internal virtual;
/**
* @dev This empty reserved space is put in place to allow future versions to add new
* variables without shifting down storage in the inheritance chain.
* See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps
*/
uint256[50] private __gap;
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (token/ERC20/ERC20.sol)
pragma solidity ^0.8.0;
import "./IERC20Upgradeable.sol";
import "./extensions/IERC20MetadataUpgradeable.sol";
import "../../utils/ContextUpgradeable.sol";
import "../../proxy/utils/Initializable.sol";
/**
* @dev Implementation of the {IERC20} interface.
*
* This implementation is agnostic to the way tokens are created. This means
* that a supply mechanism has to be added in a derived contract using {_mint}.
* For a generic mechanism see {ERC20PresetMinterPauser}.
*
* TIP: For a detailed writeup see our guide
* https://forum.openzeppelin.com/t/how-to-implement-erc20-supply-mechanisms/226[How
* to implement supply mechanisms].
*
* The default value of {decimals} is 18. To change this, you should override
* this function so it returns a different value.
*
* We have followed general OpenZeppelin Contracts guidelines: functions revert
* instead returning `false` on failure. This behavior is nonetheless
* conventional and does not conflict with the expectations of ERC20
* applications.
*
* Additionally, an {Approval} event is emitted on calls to {transferFrom}.
* This allows applications to reconstruct the allowance for all accounts just
* by listening to said events. Other implementations of the EIP may not emit
* these events, as it isn't required by the specification.
*
* Finally, the non-standard {decreaseAllowance} and {increaseAllowance}
* functions have been added to mitigate the well-known issues around setting
* allowances. See {IERC20-approve}.
*/
contract ERC20Upgradeable is Initializable, ContextUpgradeable, IERC20Upgradeable, IERC20MetadataUpgradeable {
mapping(address => uint256) private _balances;
mapping(address => mapping(address => uint256)) private _allowances;
uint256 private _totalSupply;
string private _name;
string private _symbol;
/**
* @dev Sets the values for {name} and {symbol}.
*
* All two of these values are immutable: they can only be set once during
* construction.
*/
function __ERC20_init(string memory name_, string memory symbol_) internal onlyInitializing {
__ERC20_init_unchained(name_, symbol_);
}
function __ERC20_init_unchained(string memory name_, string memory symbol_) internal onlyInitializing {
_name = name_;
_symbol = symbol_;
}
/**
* @dev Returns the name of the token.
*/
function name() public view virtual override returns (string memory) {
return _name;
}
/**
* @dev Returns the symbol of the token, usually a shorter version of the
* name.
*/
function symbol() public view virtual override returns (string memory) {
return _symbol;
}
/**
* @dev Returns the number of decimals used to get its user representation.
* For example, if `decimals` equals `2`, a balance of `505` tokens should
* be displayed to a user as `5.05` (`505 / 10 ** 2`).
*
* Tokens usually opt for a value of 18, imitating the relationship between
* Ether and Wei. This is the default value returned by this function, unless
* it's overridden.
*
* NOTE: This information is only used for _display_ purposes: it in
* no way affects any of the arithmetic of the contract, including
* {IERC20-balanceOf} and {IERC20-transfer}.
*/
function decimals() public view virtual override returns (uint8) {
return 18;
}
/**
* @dev See {IERC20-totalSupply}.
*/
function totalSupply() public view virtual override returns (uint256) {
return _totalSupply;
}
/**
* @dev See {IERC20-balanceOf}.
*/
function balanceOf(address account) public view virtual override returns (uint256) {
return _balances[account];
}
/**
* @dev See {IERC20-transfer}.
*
* Requirements:
*
* - `to` cannot be the zero address.
* - the caller must have a balance of at least `amount`.
*/
function transfer(address to, uint256 amount) public virtual override returns (bool) {
address owner = _msgSender();
_transfer(owner, to, amount);
return true;
}
/**
* @dev See {IERC20-allowance}.
*/
function allowance(address owner, address spender) public view virtual override returns (uint256) {
return _allowances[owner][spender];
}
/**
* @dev See {IERC20-approve}.
*
* NOTE: If `amount` is the maximum `uint256`, the allowance is not updated on
* `transferFrom`. This is semantically equivalent to an infinite approval.
*
* Requirements:
*
* - `spender` cannot be the zero address.
*/
function approve(address spender, uint256 amount) public virtual override returns (bool) {
address owner = _msgSender();
_approve(owner, spender, amount);
return true;
}
/**
* @dev See {IERC20-transferFrom}.
*
* Emits an {Approval} event indicating the updated allowance. This is not
* required by the EIP. See the note at the beginning of {ERC20}.
*
* NOTE: Does not update the allowance if the current allowance
* is the maximum `uint256`.
*
* Requirements:
*
* - `from` and `to` cannot be the zero address.
* - `from` must have a balance of at least `amount`.
* - the caller must have allowance for ``from``'s tokens of at least
* `amount`.
*/
function transferFrom(address from, address to, uint256 amount) public virtual override returns (bool) {
address spender = _msgSender();
_spendAllowance(from, spender, amount);
_transfer(from, to, amount);
return true;
}
/**
* @dev Atomically increases the allowance granted to `spender` by the caller.
*
* This is an alternative to {approve} that can be used as a mitigation for
* problems described in {IERC20-approve}.
*
* Emits an {Approval} event indicating the updated allowance.
*
* Requirements:
*
* - `spender` cannot be the zero address.
*/
function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) {
address owner = _msgSender();
_approve(owner, spender, allowance(owner, spender) + addedValue);
return true;
}
/**
* @dev Atomically decreases the allowance granted to `spender` by the caller.
*
* This is an alternative to {approve} that can be used as a mitigation for
* problems described in {IERC20-approve}.
*
* Emits an {Approval} event indicating the updated allowance.
*
* Requirements:
*
* - `spender` cannot be the zero address.
* - `spender` must have allowance for the caller of at least
* `subtractedValue`.
*/
function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) {
address owner = _msgSender();
uint256 currentAllowance = allowance(owner, spender);
require(currentAllowance >= subtractedValue, "ERC20: decreased allowance below zero");
unchecked {
_approve(owner, spender, currentAllowance - subtractedValue);
}
return true;
}
/**
* @dev Moves `amount` of tokens from `from` to `to`.
*
* This internal function is equivalent to {transfer}, and can be used to
* e.g. implement automatic token fees, slashing mechanisms, etc.
*
* Emits a {Transfer} event.
*
* Requirements:
*
* - `from` cannot be the zero address.
* - `to` cannot be the zero address.
* - `from` must have a balance of at least `amount`.
*/
function _transfer(address from, address to, uint256 amount) internal virtual {
require(from != address(0), "ERC20: transfer from the zero address");
require(to != address(0), "ERC20: transfer to the zero address");
_beforeTokenTransfer(from, to, amount);
uint256 fromBalance = _balances[from];
require(fromBalance >= amount, "ERC20: transfer amount exceeds balance");
unchecked {
_balances[from] = fromBalance - amount;
// Overflow not possible: the sum of all balances is capped by totalSupply, and the sum is preserved by
// decrementing then incrementing.
_balances[to] += amount;
}
emit Transfer(from, to, amount);
_afterTokenTransfer(from, to, amount);
}
/** @dev Creates `amount` tokens and assigns them to `account`, increasing
* the total supply.
*
* Emits a {Transfer} event with `from` set to the zero address.
*
* Requirements:
*
* - `account` cannot be the zero address.
*/
function _mint(address account, uint256 amount) internal virtual {
require(account != address(0), "ERC20: mint to the zero address");
_beforeTokenTransfer(address(0), account, amount);
_totalSupply += amount;
unchecked {
// Overflow not possible: balance + amount is at most totalSupply + amount, which is checked above.
_balances[account] += amount;
}
emit Transfer(address(0), account, amount);
_afterTokenTransfer(address(0), account, amount);
}
/**
* @dev Destroys `amount` tokens from `account`, reducing the
* total supply.
*
* Emits a {Transfer} event with `to` set to the zero address.
*
* Requirements:
*
* - `account` cannot be the zero address.
* - `account` must have at least `amount` tokens.
*/
function _burn(address account, uint256 amount) internal virtual {
require(account != address(0), "ERC20: burn from the zero address");
_beforeTokenTransfer(account, address(0), amount);
uint256 accountBalance = _balances[account];
require(accountBalance >= amount, "ERC20: burn amount exceeds balance");
unchecked {
_balances[account] = accountBalance - amount;
// Overflow not possible: amount <= accountBalance <= totalSupply.
_totalSupply -= amount;
}
emit Transfer(account, address(0), amount);
_afterTokenTransfer(account, address(0), amount);
}
/**
* @dev Sets `amount` as the allowance of `spender` over the `owner` s tokens.
*
* This internal function is equivalent to `approve`, and can be used to
* e.g. set automatic allowances for certain subsystems, etc.
*
* Emits an {Approval} event.
*
* Requirements:
*
* - `owner` cannot be the zero address.
* - `spender` cannot be the zero address.
*/
function _approve(address owner, address spender, uint256 amount) internal virtual {
require(owner != address(0), "ERC20: approve from the zero address");
require(spender != address(0), "ERC20: approve to the zero address");
_allowances[owner][spender] = amount;
emit Approval(owner, spender, amount);
}
/**
* @dev Updates `owner` s allowance for `spender` based on spent `amount`.
*
* Does not update the allowance amount in case of infinite allowance.
* Revert if not enough allowance is available.
*
* Might emit an {Approval} event.
*/
function _spendAllowance(address owner, address spender, uint256 amount) internal virtual {
uint256 currentAllowance = allowance(owner, spender);
if (currentAllowance != type(uint256).max) {
require(currentAllowance >= amount, "ERC20: insufficient allowance");
unchecked {
_approve(owner, spender, currentAllowance - amount);
}
}
}
/**
* @dev Hook that is called before any transfer of tokens. This includes
* minting and burning.
*
* Calling conditions:
*
* - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens
* will be transferred to `to`.
* - when `from` is zero, `amount` tokens will be minted for `to`.
* - when `to` is zero, `amount` of ``from``'s tokens will be burned.
* - `from` and `to` are never both zero.
*
* To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].
*/
function _beforeTokenTransfer(address from, address to, uint256 amount) internal virtual {}
/**
* @dev Hook that is called after any transfer of tokens. This includes
* minting and burning.
*
* Calling conditions:
*
* - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens
* has been transferred to `to`.
* - when `from` is zero, `amount` tokens have been minted for `to`.
* - when `to` is zero, `amount` of ``from``'s tokens have been burned.
* - `from` and `to` are never both zero.
*
* To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].
*/
function _afterTokenTransfer(address from, address to, uint256 amount) internal virtual {}
/**
* @dev This empty reserved space is put in place to allow future versions to add new
* variables without shifting down storage in the inheritance chain.
* See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps
*/
uint256[45] private __gap;
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/IERC20Metadata.sol)
pragma solidity ^0.8.0;
import "../IERC20Upgradeable.sol";
/**
* @dev Interface for the optional metadata functions from the ERC20 standard.
*
* _Available since v4.1._
*/
interface IERC20MetadataUpgradeable is IERC20Upgradeable {
/**
* @dev Returns the name of the token.
*/
function name() external view returns (string memory);
/**
* @dev Returns the symbol of the token.
*/
function symbol() external view returns (string memory);
/**
* @dev Returns the decimals places of the token.
*/
function decimals() external view returns (uint8);
}// 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 IERC20Upgradeable {
/**
* @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) (utils/Address.sol)
pragma solidity ^0.8.1;
/**
* @dev Collection of functions related to the address type
*/
library AddressUpgradeable {
/**
* @dev Returns true if `account` is a contract.
*
* [IMPORTANT]
* ====
* It is unsafe to assume that an address for which this function returns
* false is an externally-owned account (EOA) and not a contract.
*
* Among others, `isContract` will return false for the following
* types of addresses:
*
* - an externally-owned account
* - a contract in construction
* - an address where a contract will be created
* - an address where a contract lived, but was destroyed
*
* 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
// OpenZeppelin Contracts v4.4.1 (utils/Context.sol)
pragma solidity ^0.8.0;
import "../proxy/utils/Initializable.sol";
/**
* @dev Provides information about the current execution context, including the
* sender of the transaction and its data. While these are generally available
* via msg.sender and msg.data, they should not be accessed in such a direct
* manner, since when dealing with meta-transactions the account sending and
* paying for execution may not be the actual sender (as far as an application
* is concerned).
*
* This contract is only required for intermediate, library-like contracts.
*/
abstract contract ContextUpgradeable is Initializable {
function __Context_init() internal onlyInitializing {
}
function __Context_init_unchained() internal onlyInitializing {
}
function _msgSender() internal view virtual returns (address) {
return msg.sender;
}
function _msgData() internal view virtual returns (bytes calldata) {
return msg.data;
}
/**
* @dev This empty reserved space is put in place to allow future versions to add new
* variables without shifting down storage in the inheritance chain.
* See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps
*/
uint256[50] private __gap;
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/introspection/ERC165.sol)
pragma solidity ^0.8.0;
import "./IERC165Upgradeable.sol";
import "../../proxy/utils/Initializable.sol";
/**
* @dev Implementation of the {IERC165} interface.
*
* Contracts that want to implement ERC165 should inherit from this contract and override {supportsInterface} to check
* for the additional interface id that will be supported. For example:
*
* ```solidity
* function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
* return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId);
* }
* ```
*
* Alternatively, {ERC165Storage} provides an easier to use but more expensive implementation.
*/
abstract contract ERC165Upgradeable is Initializable, IERC165Upgradeable {
function __ERC165_init() internal onlyInitializing {
}
function __ERC165_init_unchained() internal onlyInitializing {
}
/**
* @dev See {IERC165-supportsInterface}.
*/
function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
return interfaceId == type(IERC165Upgradeable).interfaceId;
}
/**
* @dev This empty reserved space is put in place to allow future versions to add new
* variables without shifting down storage in the inheritance chain.
* See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps
*/
uint256[50] private __gap;
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/introspection/IERC165.sol)
pragma solidity ^0.8.0;
/**
* @dev Interface of the ERC165 standard, as defined in the
* https://eips.ethereum.org/EIPS/eip-165[EIP].
*
* Implementers can declare support of contract interfaces, which can then be
* queried by others ({ERC165Checker}).
*
* For an implementation, see {ERC165}.
*/
interface IERC165Upgradeable {
/**
* @dev Returns true if this contract implements the interface defined by
* `interfaceId`. See the corresponding
* https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section]
* to learn more about how these ids are created.
*
* This function call must use less than 30 000 gas.
*/
function supportsInterface(bytes4 interfaceId) external view returns (bool);
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (utils/math/Math.sol)
pragma solidity ^0.8.0;
/**
* @dev Standard math utilities missing in the Solidity language.
*/
library MathUpgradeable {
enum Rounding {
Down, // Toward negative infinity
Up, // Toward infinity
Zero // Toward zero
}
/**
* @dev Returns the largest of two numbers.
*/
function max(uint256 a, uint256 b) internal pure returns (uint256) {
return a > b ? a : b;
}
/**
* @dev Returns the smallest of two numbers.
*/
function min(uint256 a, uint256 b) internal pure returns (uint256) {
return a < b ? a : b;
}
/**
* @dev Returns the average of two numbers. The result is rounded towards
* zero.
*/
function average(uint256 a, uint256 b) internal pure returns (uint256) {
// (a + b) / 2 can overflow.
return (a & b) + (a ^ b) / 2;
}
/**
* @dev Returns the ceiling of the division of two numbers.
*
* This differs from standard division with `/` in that it rounds up instead
* of rounding down.
*/
function ceilDiv(uint256 a, uint256 b) internal pure returns (uint256) {
// (a + b - 1) / b can overflow on addition, so we distribute.
return a == 0 ? 0 : (a - 1) / b + 1;
}
/**
* @notice Calculates floor(x * y / denominator) with full precision. Throws if result overflows a uint256 or denominator == 0
* @dev Original credit to Remco Bloemen under MIT license (https://xn--2-umb.com/21/muldiv)
* with further edits by Uniswap Labs also under MIT license.
*/
function mulDiv(uint256 x, uint256 y, uint256 denominator) internal pure returns (uint256 result) {
unchecked {
// 512-bit multiply [prod1 prod0] = x * y. Compute the product mod 2^256 and mod 2^256 - 1, then use
// use the Chinese Remainder Theorem to reconstruct the 512 bit result. The result is stored in two 256
// variables such that product = prod1 * 2^256 + prod0.
uint256 prod0; // Least significant 256 bits of the product
uint256 prod1; // Most significant 256 bits of the product
assembly {
let mm := mulmod(x, y, not(0))
prod0 := mul(x, y)
prod1 := sub(sub(mm, prod0), lt(mm, prod0))
}
// Handle non-overflow cases, 256 by 256 division.
if (prod1 == 0) {
// Solidity will revert if denominator == 0, unlike the div opcode on its own.
// The surrounding unchecked block does not change this fact.
// See https://docs.soliditylang.org/en/latest/control-structures.html#checked-or-unchecked-arithmetic.
return prod0 / denominator;
}
// Make sure the result is less than 2^256. Also prevents denominator == 0.
require(denominator > prod1, "Math: mulDiv overflow");
///////////////////////////////////////////////
// 512 by 256 division.
///////////////////////////////////////////////
// Make division exact by subtracting the remainder from [prod1 prod0].
uint256 remainder;
assembly {
// Compute remainder using mulmod.
remainder := mulmod(x, y, denominator)
// Subtract 256 bit number from 512 bit number.
prod1 := sub(prod1, gt(remainder, prod0))
prod0 := sub(prod0, remainder)
}
// Factor powers of two out of denominator and compute largest power of two divisor of denominator. Always >= 1.
// See https://cs.stackexchange.com/q/138556/92363.
// Does not overflow because the denominator cannot be zero at this stage in the function.
uint256 twos = denominator & (~denominator + 1);
assembly {
// Divide denominator by twos.
denominator := div(denominator, twos)
// Divide [prod1 prod0] by twos.
prod0 := div(prod0, twos)
// Flip twos such that it is 2^256 / twos. If twos is zero, then it becomes one.
twos := add(div(sub(0, twos), twos), 1)
}
// Shift in bits from prod1 into prod0.
prod0 |= prod1 * twos;
// Invert denominator mod 2^256. Now that denominator is an odd number, it has an inverse modulo 2^256 such
// that denominator * inv = 1 mod 2^256. Compute the inverse by starting with a seed that is correct for
// four bits. That is, denominator * inv = 1 mod 2^4.
uint256 inverse = (3 * denominator) ^ 2;
// Use the Newton-Raphson iteration to improve the precision. Thanks to Hensel's lifting lemma, this also works
// in modular arithmetic, doubling the correct bits in each step.
inverse *= 2 - denominator * inverse; // inverse mod 2^8
inverse *= 2 - denominator * inverse; // inverse mod 2^16
inverse *= 2 - denominator * inverse; // inverse mod 2^32
inverse *= 2 - denominator * inverse; // inverse mod 2^64
inverse *= 2 - denominator * inverse; // inverse mod 2^128
inverse *= 2 - denominator * inverse; // inverse mod 2^256
// Because the division is now exact we can divide by multiplying with the modular inverse of denominator.
// This will give us the correct result modulo 2^256. Since the preconditions guarantee that the outcome is
// less than 2^256, this is the final result. We don't need to compute the high bits of the result and prod1
// is no longer required.
result = prod0 * inverse;
return result;
}
}
/**
* @notice Calculates x * y / denominator with full precision, following the selected rounding direction.
*/
function mulDiv(uint256 x, uint256 y, uint256 denominator, Rounding rounding) internal pure returns (uint256) {
uint256 result = mulDiv(x, y, denominator);
if (rounding == Rounding.Up && mulmod(x, y, denominator) > 0) {
result += 1;
}
return result;
}
/**
* @dev Returns the square root of a number. If the number is not a perfect square, the value is rounded down.
*
* Inspired by Henry S. Warren, Jr.'s "Hacker's Delight" (Chapter 11).
*/
function sqrt(uint256 a) internal pure returns (uint256) {
if (a == 0) {
return 0;
}
// For our first guess, we get the biggest power of 2 which is smaller than the square root of the target.
//
// We know that the "msb" (most significant bit) of our target number `a` is a power of 2 such that we have
// `msb(a) <= a < 2*msb(a)`. This value can be written `msb(a)=2**k` with `k=log2(a)`.
//
// This can be rewritten `2**log2(a) <= a < 2**(log2(a) + 1)`
// → `sqrt(2**k) <= sqrt(a) < sqrt(2**(k+1))`
// → `2**(k/2) <= sqrt(a) < 2**((k+1)/2) <= 2**(k/2 + 1)`
//
// Consequently, `2**(log2(a) / 2)` is a good first approximation of `sqrt(a)` with at least 1 correct bit.
uint256 result = 1 << (log2(a) >> 1);
// At this point `result` is an estimation with one bit of precision. We know the true value is a uint128,
// since it is the square root of a uint256. Newton's method converges quadratically (precision doubles at
// every iteration). We thus need at most 7 iteration to turn our partial result with one bit of precision
// into the expected uint128 result.
unchecked {
result = (result + a / result) >> 1;
result = (result + a / result) >> 1;
result = (result + a / result) >> 1;
result = (result + a / result) >> 1;
result = (result + a / result) >> 1;
result = (result + a / result) >> 1;
result = (result + a / result) >> 1;
return min(result, a / result);
}
}
/**
* @notice Calculates sqrt(a), following the selected rounding direction.
*/
function sqrt(uint256 a, Rounding rounding) internal pure returns (uint256) {
unchecked {
uint256 result = sqrt(a);
return result + (rounding == Rounding.Up && result * result < a ? 1 : 0);
}
}
/**
* @dev Return the log in base 2, rounded down, of a positive value.
* Returns 0 if given 0.
*/
function log2(uint256 value) internal pure returns (uint256) {
uint256 result = 0;
unchecked {
if (value >> 128 > 0) {
value >>= 128;
result += 128;
}
if (value >> 64 > 0) {
value >>= 64;
result += 64;
}
if (value >> 32 > 0) {
value >>= 32;
result += 32;
}
if (value >> 16 > 0) {
value >>= 16;
result += 16;
}
if (value >> 8 > 0) {
value >>= 8;
result += 8;
}
if (value >> 4 > 0) {
value >>= 4;
result += 4;
}
if (value >> 2 > 0) {
value >>= 2;
result += 2;
}
if (value >> 1 > 0) {
result += 1;
}
}
return result;
}
/**
* @dev Return the log in base 2, following the selected rounding direction, of a positive value.
* Returns 0 if given 0.
*/
function log2(uint256 value, Rounding rounding) internal pure returns (uint256) {
unchecked {
uint256 result = log2(value);
return result + (rounding == Rounding.Up && 1 << result < value ? 1 : 0);
}
}
/**
* @dev Return the log in base 10, rounded down, of a positive value.
* Returns 0 if given 0.
*/
function log10(uint256 value) internal pure returns (uint256) {
uint256 result = 0;
unchecked {
if (value >= 10 ** 64) {
value /= 10 ** 64;
result += 64;
}
if (value >= 10 ** 32) {
value /= 10 ** 32;
result += 32;
}
if (value >= 10 ** 16) {
value /= 10 ** 16;
result += 16;
}
if (value >= 10 ** 8) {
value /= 10 ** 8;
result += 8;
}
if (value >= 10 ** 4) {
value /= 10 ** 4;
result += 4;
}
if (value >= 10 ** 2) {
value /= 10 ** 2;
result += 2;
}
if (value >= 10 ** 1) {
result += 1;
}
}
return result;
}
/**
* @dev Return the log in base 10, following the selected rounding direction, of a positive value.
* Returns 0 if given 0.
*/
function log10(uint256 value, Rounding rounding) internal pure returns (uint256) {
unchecked {
uint256 result = log10(value);
return result + (rounding == Rounding.Up && 10 ** result < value ? 1 : 0);
}
}
/**
* @dev Return the log in base 256, rounded down, of a positive value.
* Returns 0 if given 0.
*
* Adding one to the result gives the number of pairs of hex symbols needed to represent `value` as a hex string.
*/
function log256(uint256 value) internal pure returns (uint256) {
uint256 result = 0;
unchecked {
if (value >> 128 > 0) {
value >>= 128;
result += 16;
}
if (value >> 64 > 0) {
value >>= 64;
result += 8;
}
if (value >> 32 > 0) {
value >>= 32;
result += 4;
}
if (value >> 16 > 0) {
value >>= 16;
result += 2;
}
if (value >> 8 > 0) {
result += 1;
}
}
return result;
}
/**
* @dev Return the log in base 256, following the selected rounding direction, of a positive value.
* Returns 0 if given 0.
*/
function log256(uint256 value, Rounding rounding) internal pure returns (uint256) {
unchecked {
uint256 result = log256(value);
return result + (rounding == Rounding.Up && 1 << (result << 3) < value ? 1 : 0);
}
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.8.0) (utils/math/SignedMath.sol)
pragma solidity ^0.8.0;
/**
* @dev Standard signed math utilities missing in the Solidity language.
*/
library SignedMathUpgradeable {
/**
* @dev Returns the largest of two signed numbers.
*/
function max(int256 a, int256 b) internal pure returns (int256) {
return a > b ? a : b;
}
/**
* @dev Returns the smallest of two signed numbers.
*/
function min(int256 a, int256 b) internal pure returns (int256) {
return a < b ? a : b;
}
/**
* @dev Returns the average of two signed numbers without overflow.
* The result is rounded towards zero.
*/
function average(int256 a, int256 b) internal pure returns (int256) {
// Formula from the book "Hacker's Delight"
int256 x = (a & b) + ((a ^ b) >> 1);
return x + (int256(uint256(x) >> 255) & (a ^ b));
}
/**
* @dev Returns the absolute unsigned value of a signed value.
*/
function abs(int256 n) internal pure returns (uint256) {
unchecked {
// must be unchecked in order to support `n = type(int256).min`
return uint256(n >= 0 ? n : -n);
}
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (utils/StorageSlot.sol)
// This file was procedurally generated from scripts/generate/templates/StorageSlot.js.
pragma solidity ^0.8.0;
/**
* @dev Library for reading and writing primitive types to specific storage slots.
*
* Storage slots are often used to avoid storage conflict when dealing with upgradeable contracts.
* This library helps with reading and writing to such slots without the need for inline assembly.
*
* The functions in this library return Slot structs that contain a `value` member that can be used to read or write.
*
* Example usage to set ERC1967 implementation slot:
* ```solidity
* contract ERC1967 {
* bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;
*
* function _getImplementation() internal view returns (address) {
* return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value;
* }
*
* function _setImplementation(address newImplementation) internal {
* require(Address.isContract(newImplementation), "ERC1967: new implementation is not a contract");
* StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation;
* }
* }
* ```
*
* _Available since v4.1 for `address`, `bool`, `bytes32`, `uint256`._
* _Available since v4.9 for `string`, `bytes`._
*/
library StorageSlotUpgradeable {
struct AddressSlot {
address value;
}
struct BooleanSlot {
bool value;
}
struct Bytes32Slot {
bytes32 value;
}
struct Uint256Slot {
uint256 value;
}
struct StringSlot {
string value;
}
struct BytesSlot {
bytes value;
}
/**
* @dev Returns an `AddressSlot` with member `value` located at `slot`.
*/
function getAddressSlot(bytes32 slot) internal pure returns (AddressSlot storage r) {
/// @solidity memory-safe-assembly
assembly {
r.slot := slot
}
}
/**
* @dev Returns an `BooleanSlot` with member `value` located at `slot`.
*/
function getBooleanSlot(bytes32 slot) internal pure returns (BooleanSlot storage r) {
/// @solidity memory-safe-assembly
assembly {
r.slot := slot
}
}
/**
* @dev Returns an `Bytes32Slot` with member `value` located at `slot`.
*/
function getBytes32Slot(bytes32 slot) internal pure returns (Bytes32Slot storage r) {
/// @solidity memory-safe-assembly
assembly {
r.slot := slot
}
}
/**
* @dev Returns an `Uint256Slot` with member `value` located at `slot`.
*/
function getUint256Slot(bytes32 slot) internal pure returns (Uint256Slot storage r) {
/// @solidity memory-safe-assembly
assembly {
r.slot := slot
}
}
/**
* @dev Returns an `StringSlot` with member `value` located at `slot`.
*/
function getStringSlot(bytes32 slot) internal pure returns (StringSlot storage r) {
/// @solidity memory-safe-assembly
assembly {
r.slot := slot
}
}
/**
* @dev Returns an `StringSlot` representation of the string storage pointer `store`.
*/
function getStringSlot(string storage store) internal pure returns (StringSlot storage r) {
/// @solidity memory-safe-assembly
assembly {
r.slot := store.slot
}
}
/**
* @dev Returns an `BytesSlot` with member `value` located at `slot`.
*/
function getBytesSlot(bytes32 slot) internal pure returns (BytesSlot storage r) {
/// @solidity memory-safe-assembly
assembly {
r.slot := slot
}
}
/**
* @dev Returns an `BytesSlot` representation of the bytes storage pointer `store`.
*/
function getBytesSlot(bytes storage store) internal pure returns (BytesSlot storage r) {
/// @solidity memory-safe-assembly
assembly {
r.slot := store.slot
}
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (utils/Strings.sol)
pragma solidity ^0.8.0;
import "./math/MathUpgradeable.sol";
import "./math/SignedMathUpgradeable.sol";
/**
* @dev String operations.
*/
library StringsUpgradeable {
bytes16 private constant _SYMBOLS = "0123456789abcdef";
uint8 private constant _ADDRESS_LENGTH = 20;
/**
* @dev Converts a `uint256` to its ASCII `string` decimal representation.
*/
function toString(uint256 value) internal pure returns (string memory) {
unchecked {
uint256 length = MathUpgradeable.log10(value) + 1;
string memory buffer = new string(length);
uint256 ptr;
/// @solidity memory-safe-assembly
assembly {
ptr := add(buffer, add(32, length))
}
while (true) {
ptr--;
/// @solidity memory-safe-assembly
assembly {
mstore8(ptr, byte(mod(value, 10), _SYMBOLS))
}
value /= 10;
if (value == 0) break;
}
return buffer;
}
}
/**
* @dev Converts a `int256` to its ASCII `string` decimal representation.
*/
function toString(int256 value) internal pure returns (string memory) {
return string(abi.encodePacked(value < 0 ? "-" : "", toString(SignedMathUpgradeable.abs(value))));
}
/**
* @dev Converts a `uint256` to its ASCII `string` hexadecimal representation.
*/
function toHexString(uint256 value) internal pure returns (string memory) {
unchecked {
return toHexString(value, MathUpgradeable.log256(value) + 1);
}
}
/**
* @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length.
*/
function toHexString(uint256 value, uint256 length) internal pure returns (string memory) {
bytes memory buffer = new bytes(2 * length + 2);
buffer[0] = "0";
buffer[1] = "x";
for (uint256 i = 2 * length + 1; i > 1; --i) {
buffer[i] = _SYMBOLS[value & 0xf];
value >>= 4;
}
require(value == 0, "Strings: hex length insufficient");
return string(buffer);
}
/**
* @dev Converts an `address` with fixed length of 20 bytes to its not checksummed ASCII `string` hexadecimal representation.
*/
function toHexString(address addr) internal pure returns (string memory) {
return toHexString(uint256(uint160(addr)), _ADDRESS_LENGTH);
}
/**
* @dev Returns true if the two strings are equal.
*/
function equal(string memory a, string memory b) internal pure returns (bool) {
return keccak256(bytes(a)) == keccak256(bytes(b));
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (utils/structs/EnumerableSet.sol)
// This file was procedurally generated from scripts/generate/templates/EnumerableSet.js.
pragma solidity ^0.8.0;
/**
* @dev Library for managing
* https://en.wikipedia.org/wiki/Set_(abstract_data_type)[sets] of primitive
* types.
*
* Sets have the following properties:
*
* - Elements are added, removed, and checked for existence in constant time
* (O(1)).
* - Elements are enumerated in O(n). No guarantees are made on the ordering.
*
* ```solidity
* contract Example {
* // Add the library methods
* using EnumerableSet for EnumerableSet.AddressSet;
*
* // Declare a set state variable
* EnumerableSet.AddressSet private mySet;
* }
* ```
*
* As of v3.3.0, sets of type `bytes32` (`Bytes32Set`), `address` (`AddressSet`)
* and `uint256` (`UintSet`) are supported.
*
* [WARNING]
* ====
* Trying to delete such a structure from storage will likely result in data corruption, rendering the structure
* unusable.
* See https://github.com/ethereum/solidity/pull/11843[ethereum/solidity#11843] for more info.
*
* In order to clean an EnumerableSet, you can either remove all elements one by one or create a fresh instance using an
* array of EnumerableSet.
* ====
*/
library EnumerableSetUpgradeable {
// To implement this library for multiple types with as little code
// repetition as possible, we write it in terms of a generic Set type with
// bytes32 values.
// The Set implementation uses private functions, and user-facing
// implementations (such as AddressSet) are just wrappers around the
// underlying Set.
// This means that we can only create new EnumerableSets for types that fit
// in bytes32.
struct Set {
// Storage of set values
bytes32[] _values;
// Position of the value in the `values` array, plus 1 because index 0
// means a value is not in the set.
mapping(bytes32 => uint256) _indexes;
}
/**
* @dev Add a value to a set. O(1).
*
* Returns true if the value was added to the set, that is if it was not
* already present.
*/
function _add(Set storage set, bytes32 value) private returns (bool) {
if (!_contains(set, value)) {
set._values.push(value);
// The value is stored at length-1, but we add 1 to all indexes
// and use 0 as a sentinel value
set._indexes[value] = set._values.length;
return true;
} else {
return false;
}
}
/**
* @dev Removes a value from a set. O(1).
*
* Returns true if the value was removed from the set, that is if it was
* present.
*/
function _remove(Set storage set, bytes32 value) private returns (bool) {
// We read and store the value's index to prevent multiple reads from the same storage slot
uint256 valueIndex = set._indexes[value];
if (valueIndex != 0) {
// Equivalent to contains(set, value)
// To delete an element from the _values array in O(1), we swap the element to delete with the last one in
// the array, and then remove the last element (sometimes called as 'swap and pop').
// This modifies the order of the array, as noted in {at}.
uint256 toDeleteIndex = valueIndex - 1;
uint256 lastIndex = set._values.length - 1;
if (lastIndex != toDeleteIndex) {
bytes32 lastValue = set._values[lastIndex];
// Move the last value to the index where the value to delete is
set._values[toDeleteIndex] = lastValue;
// Update the index for the moved value
set._indexes[lastValue] = valueIndex; // Replace lastValue's index to valueIndex
}
// Delete the slot where the moved value was stored
set._values.pop();
// Delete the index for the deleted slot
delete set._indexes[value];
return true;
} else {
return false;
}
}
/**
* @dev Returns true if the value is in the set. O(1).
*/
function _contains(Set storage set, bytes32 value) private view returns (bool) {
return set._indexes[value] != 0;
}
/**
* @dev Returns the number of values on the set. O(1).
*/
function _length(Set storage set) private view returns (uint256) {
return set._values.length;
}
/**
* @dev Returns the value stored at position `index` in the set. O(1).
*
* Note that there are no guarantees on the ordering of values inside the
* array, and it may change when more values are added or removed.
*
* Requirements:
*
* - `index` must be strictly less than {length}.
*/
function _at(Set storage set, uint256 index) private view returns (bytes32) {
return set._values[index];
}
/**
* @dev Return the entire set in an array
*
* WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed
* to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that
* this function has an unbounded cost, and using it as part of a state-changing function may render the function
* uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.
*/
function _values(Set storage set) private view returns (bytes32[] memory) {
return set._values;
}
// Bytes32Set
struct Bytes32Set {
Set _inner;
}
/**
* @dev Add a value to a set. O(1).
*
* Returns true if the value was added to the set, that is if it was not
* already present.
*/
function add(Bytes32Set storage set, bytes32 value) internal returns (bool) {
return _add(set._inner, value);
}
/**
* @dev Removes a value from a set. O(1).
*
* Returns true if the value was removed from the set, that is if it was
* present.
*/
function remove(Bytes32Set storage set, bytes32 value) internal returns (bool) {
return _remove(set._inner, value);
}
/**
* @dev Returns true if the value is in the set. O(1).
*/
function contains(Bytes32Set storage set, bytes32 value) internal view returns (bool) {
return _contains(set._inner, value);
}
/**
* @dev Returns the number of values in the set. O(1).
*/
function length(Bytes32Set storage set) internal view returns (uint256) {
return _length(set._inner);
}
/**
* @dev Returns the value stored at position `index` in the set. O(1).
*
* Note that there are no guarantees on the ordering of values inside the
* array, and it may change when more values are added or removed.
*
* Requirements:
*
* - `index` must be strictly less than {length}.
*/
function at(Bytes32Set storage set, uint256 index) internal view returns (bytes32) {
return _at(set._inner, index);
}
/**
* @dev Return the entire set in an array
*
* WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed
* to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that
* this function has an unbounded cost, and using it as part of a state-changing function may render the function
* uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.
*/
function values(Bytes32Set storage set) internal view returns (bytes32[] memory) {
bytes32[] memory store = _values(set._inner);
bytes32[] memory result;
/// @solidity memory-safe-assembly
assembly {
result := store
}
return result;
}
// AddressSet
struct AddressSet {
Set _inner;
}
/**
* @dev Add a value to a set. O(1).
*
* Returns true if the value was added to the set, that is if it was not
* already present.
*/
function add(AddressSet storage set, address value) internal returns (bool) {
return _add(set._inner, bytes32(uint256(uint160(value))));
}
/**
* @dev Removes a value from a set. O(1).
*
* Returns true if the value was removed from the set, that is if it was
* present.
*/
function remove(AddressSet storage set, address value) internal returns (bool) {
return _remove(set._inner, bytes32(uint256(uint160(value))));
}
/**
* @dev Returns true if the value is in the set. O(1).
*/
function contains(AddressSet storage set, address value) internal view returns (bool) {
return _contains(set._inner, bytes32(uint256(uint160(value))));
}
/**
* @dev Returns the number of values in the set. O(1).
*/
function length(AddressSet storage set) internal view returns (uint256) {
return _length(set._inner);
}
/**
* @dev Returns the value stored at position `index` in the set. O(1).
*
* Note that there are no guarantees on the ordering of values inside the
* array, and it may change when more values are added or removed.
*
* Requirements:
*
* - `index` must be strictly less than {length}.
*/
function at(AddressSet storage set, uint256 index) internal view returns (address) {
return address(uint160(uint256(_at(set._inner, index))));
}
/**
* @dev Return the entire set in an array
*
* WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed
* to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that
* this function has an unbounded cost, and using it as part of a state-changing function may render the function
* uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.
*/
function values(AddressSet storage set) internal view returns (address[] memory) {
bytes32[] memory store = _values(set._inner);
address[] memory result;
/// @solidity memory-safe-assembly
assembly {
result := store
}
return result;
}
// UintSet
struct UintSet {
Set _inner;
}
/**
* @dev Add a value to a set. O(1).
*
* Returns true if the value was added to the set, that is if it was not
* already present.
*/
function add(UintSet storage set, uint256 value) internal returns (bool) {
return _add(set._inner, bytes32(value));
}
/**
* @dev Removes a value from a set. O(1).
*
* Returns true if the value was removed from the set, that is if it was
* present.
*/
function remove(UintSet storage set, uint256 value) internal returns (bool) {
return _remove(set._inner, bytes32(value));
}
/**
* @dev Returns true if the value is in the set. O(1).
*/
function contains(UintSet storage set, uint256 value) internal view returns (bool) {
return _contains(set._inner, bytes32(value));
}
/**
* @dev Returns the number of values in the set. O(1).
*/
function length(UintSet storage set) internal view returns (uint256) {
return _length(set._inner);
}
/**
* @dev Returns the value stored at position `index` in the set. O(1).
*
* Note that there are no guarantees on the ordering of values inside the
* array, and it may change when more values are added or removed.
*
* Requirements:
*
* - `index` must be strictly less than {length}.
*/
function at(UintSet storage set, uint256 index) internal view returns (uint256) {
return uint256(_at(set._inner, index));
}
/**
* @dev Return the entire set in an array
*
* WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed
* to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that
* this function has an unbounded cost, and using it as part of a state-changing function may render the function
* uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.
*/
function values(UintSet storage set) internal view returns (uint256[] memory) {
bytes32[] memory store = _values(set._inner);
uint256[] memory result;
/// @solidity memory-safe-assembly
assembly {
result := store
}
return result;
}
}// 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
// 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
// OpenZeppelin Contracts (last updated v4.9.0) (utils/structs/EnumerableSet.sol)
// This file was procedurally generated from scripts/generate/templates/EnumerableSet.js.
pragma solidity ^0.8.0;
/**
* @dev Library for managing
* https://en.wikipedia.org/wiki/Set_(abstract_data_type)[sets] of primitive
* types.
*
* Sets have the following properties:
*
* - Elements are added, removed, and checked for existence in constant time
* (O(1)).
* - Elements are enumerated in O(n). No guarantees are made on the ordering.
*
* ```solidity
* contract Example {
* // Add the library methods
* using EnumerableSet for EnumerableSet.AddressSet;
*
* // Declare a set state variable
* EnumerableSet.AddressSet private mySet;
* }
* ```
*
* As of v3.3.0, sets of type `bytes32` (`Bytes32Set`), `address` (`AddressSet`)
* and `uint256` (`UintSet`) are supported.
*
* [WARNING]
* ====
* Trying to delete such a structure from storage will likely result in data corruption, rendering the structure
* unusable.
* See https://github.com/ethereum/solidity/pull/11843[ethereum/solidity#11843] for more info.
*
* In order to clean an EnumerableSet, you can either remove all elements one by one or create a fresh instance using an
* array of EnumerableSet.
* ====
*/
library EnumerableSet {
// To implement this library for multiple types with as little code
// repetition as possible, we write it in terms of a generic Set type with
// bytes32 values.
// The Set implementation uses private functions, and user-facing
// implementations (such as AddressSet) are just wrappers around the
// underlying Set.
// This means that we can only create new EnumerableSets for types that fit
// in bytes32.
struct Set {
// Storage of set values
bytes32[] _values;
// Position of the value in the `values` array, plus 1 because index 0
// means a value is not in the set.
mapping(bytes32 => uint256) _indexes;
}
/**
* @dev Add a value to a set. O(1).
*
* Returns true if the value was added to the set, that is if it was not
* already present.
*/
function _add(Set storage set, bytes32 value) private returns (bool) {
if (!_contains(set, value)) {
set._values.push(value);
// The value is stored at length-1, but we add 1 to all indexes
// and use 0 as a sentinel value
set._indexes[value] = set._values.length;
return true;
} else {
return false;
}
}
/**
* @dev Removes a value from a set. O(1).
*
* Returns true if the value was removed from the set, that is if it was
* present.
*/
function _remove(Set storage set, bytes32 value) private returns (bool) {
// We read and store the value's index to prevent multiple reads from the same storage slot
uint256 valueIndex = set._indexes[value];
if (valueIndex != 0) {
// Equivalent to contains(set, value)
// To delete an element from the _values array in O(1), we swap the element to delete with the last one in
// the array, and then remove the last element (sometimes called as 'swap and pop').
// This modifies the order of the array, as noted in {at}.
uint256 toDeleteIndex = valueIndex - 1;
uint256 lastIndex = set._values.length - 1;
if (lastIndex != toDeleteIndex) {
bytes32 lastValue = set._values[lastIndex];
// Move the last value to the index where the value to delete is
set._values[toDeleteIndex] = lastValue;
// Update the index for the moved value
set._indexes[lastValue] = valueIndex; // Replace lastValue's index to valueIndex
}
// Delete the slot where the moved value was stored
set._values.pop();
// Delete the index for the deleted slot
delete set._indexes[value];
return true;
} else {
return false;
}
}
/**
* @dev Returns true if the value is in the set. O(1).
*/
function _contains(Set storage set, bytes32 value) private view returns (bool) {
return set._indexes[value] != 0;
}
/**
* @dev Returns the number of values on the set. O(1).
*/
function _length(Set storage set) private view returns (uint256) {
return set._values.length;
}
/**
* @dev Returns the value stored at position `index` in the set. O(1).
*
* Note that there are no guarantees on the ordering of values inside the
* array, and it may change when more values are added or removed.
*
* Requirements:
*
* - `index` must be strictly less than {length}.
*/
function _at(Set storage set, uint256 index) private view returns (bytes32) {
return set._values[index];
}
/**
* @dev Return the entire set in an array
*
* WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed
* to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that
* this function has an unbounded cost, and using it as part of a state-changing function may render the function
* uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.
*/
function _values(Set storage set) private view returns (bytes32[] memory) {
return set._values;
}
// Bytes32Set
struct Bytes32Set {
Set _inner;
}
/**
* @dev Add a value to a set. O(1).
*
* Returns true if the value was added to the set, that is if it was not
* already present.
*/
function add(Bytes32Set storage set, bytes32 value) internal returns (bool) {
return _add(set._inner, value);
}
/**
* @dev Removes a value from a set. O(1).
*
* Returns true if the value was removed from the set, that is if it was
* present.
*/
function remove(Bytes32Set storage set, bytes32 value) internal returns (bool) {
return _remove(set._inner, value);
}
/**
* @dev Returns true if the value is in the set. O(1).
*/
function contains(Bytes32Set storage set, bytes32 value) internal view returns (bool) {
return _contains(set._inner, value);
}
/**
* @dev Returns the number of values in the set. O(1).
*/
function length(Bytes32Set storage set) internal view returns (uint256) {
return _length(set._inner);
}
/**
* @dev Returns the value stored at position `index` in the set. O(1).
*
* Note that there are no guarantees on the ordering of values inside the
* array, and it may change when more values are added or removed.
*
* Requirements:
*
* - `index` must be strictly less than {length}.
*/
function at(Bytes32Set storage set, uint256 index) internal view returns (bytes32) {
return _at(set._inner, index);
}
/**
* @dev Return the entire set in an array
*
* WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed
* to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that
* this function has an unbounded cost, and using it as part of a state-changing function may render the function
* uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.
*/
function values(Bytes32Set storage set) internal view returns (bytes32[] memory) {
bytes32[] memory store = _values(set._inner);
bytes32[] memory result;
/// @solidity memory-safe-assembly
assembly {
result := store
}
return result;
}
// AddressSet
struct AddressSet {
Set _inner;
}
/**
* @dev Add a value to a set. O(1).
*
* Returns true if the value was added to the set, that is if it was not
* already present.
*/
function add(AddressSet storage set, address value) internal returns (bool) {
return _add(set._inner, bytes32(uint256(uint160(value))));
}
/**
* @dev Removes a value from a set. O(1).
*
* Returns true if the value was removed from the set, that is if it was
* present.
*/
function remove(AddressSet storage set, address value) internal returns (bool) {
return _remove(set._inner, bytes32(uint256(uint160(value))));
}
/**
* @dev Returns true if the value is in the set. O(1).
*/
function contains(AddressSet storage set, address value) internal view returns (bool) {
return _contains(set._inner, bytes32(uint256(uint160(value))));
}
/**
* @dev Returns the number of values in the set. O(1).
*/
function length(AddressSet storage set) internal view returns (uint256) {
return _length(set._inner);
}
/**
* @dev Returns the value stored at position `index` in the set. O(1).
*
* Note that there are no guarantees on the ordering of values inside the
* array, and it may change when more values are added or removed.
*
* Requirements:
*
* - `index` must be strictly less than {length}.
*/
function at(AddressSet storage set, uint256 index) internal view returns (address) {
return address(uint160(uint256(_at(set._inner, index))));
}
/**
* @dev Return the entire set in an array
*
* WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed
* to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that
* this function has an unbounded cost, and using it as part of a state-changing function may render the function
* uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.
*/
function values(AddressSet storage set) internal view returns (address[] memory) {
bytes32[] memory store = _values(set._inner);
address[] memory result;
/// @solidity memory-safe-assembly
assembly {
result := store
}
return result;
}
// UintSet
struct UintSet {
Set _inner;
}
/**
* @dev Add a value to a set. O(1).
*
* Returns true if the value was added to the set, that is if it was not
* already present.
*/
function add(UintSet storage set, uint256 value) internal returns (bool) {
return _add(set._inner, bytes32(value));
}
/**
* @dev Removes a value from a set. O(1).
*
* Returns true if the value was removed from the set, that is if it was
* present.
*/
function remove(UintSet storage set, uint256 value) internal returns (bool) {
return _remove(set._inner, bytes32(value));
}
/**
* @dev Returns true if the value is in the set. O(1).
*/
function contains(UintSet storage set, uint256 value) internal view returns (bool) {
return _contains(set._inner, bytes32(value));
}
/**
* @dev Returns the number of values in the set. O(1).
*/
function length(UintSet storage set) internal view returns (uint256) {
return _length(set._inner);
}
/**
* @dev Returns the value stored at position `index` in the set. O(1).
*
* Note that there are no guarantees on the ordering of values inside the
* array, and it may change when more values are added or removed.
*
* Requirements:
*
* - `index` must be strictly less than {length}.
*/
function at(UintSet storage set, uint256 index) internal view returns (uint256) {
return uint256(_at(set._inner, index));
}
/**
* @dev Return the entire set in an array
*
* WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed
* to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that
* this function has an unbounded cost, and using it as part of a state-changing function may render the function
* uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.
*/
function values(UintSet storage set) internal view returns (uint256[] memory) {
bytes32[] memory store = _values(set._inner);
uint256[] memory result;
/// @solidity memory-safe-assembly
assembly {
result := store
}
return result;
}
}// SPDX-License-Identifier: Business Source License 1.1
pragma solidity 0.8.18;
import {Ownable} from "@openzeppelin/contracts/access/Ownable.sol";
import {BaseUpgradeableModule} from "./modules/BaseUpgradeableModule.sol";
contract ModuleRegistry is Ownable {
mapping(bytes32 => address) private registryMap;
function registerModule(bytes32 id, address addr) external onlyOwner {
require(id != bytes4(0x0), "INVALID_MODULE_ID");
require(addr != address(0x0), "INVALID_MODULE_ADDRESS");
require(registryMap[id] == address(0x0), "MODULE_ALREADY_REGISTERED");
registryMap[id] = addr;
}
function getModuleAddress(bytes32 id) external view returns (address) {
return registryMap[id];
}
function getModuleVersion(bytes32 id) external view returns (uint8) {
return BaseUpgradeableModule(registryMap[id]).getVersion();
}
}// SPDX-License-Identifier: Business Source License 1.1
pragma solidity 0.8.18;
import "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol";
import "@openzeppelin/contracts-upgradeable/proxy/utils/UUPSUpgradeable.sol";
import {ModuleRegistry} from "../ModuleRegistry.sol";
abstract contract BaseUpgradeableModule is Initializable, UUPSUpgradeable {
ModuleRegistry modules;
function __BaseUpgradeableModule_init() internal onlyInitializing {
__UUPSUpgradeable_init();
}
function __BaseUpgradeableModule_init_unchained()
internal
onlyInitializing
{}
function getVersion() external pure virtual returns (uint8);
}// SPDX-License-Identifier: Business Source License 1.1
pragma solidity 0.8.18;
import {Ownable} from "@openzeppelin/contracts/access/Ownable.sol";
contract TokenRegistry is Ownable {
mapping(string => address) private registryMap;
function registerToken(
string memory id,
address addr
) external onlyOwner {
require(addr != address(0x0), "INVALID_TOKEN_ADDRESS");
require(registryMap[id] == address(0x0), "TOKEN_ALREADY_REGISTERED");
registryMap[id] = addr;
}
function getTokenAddress(
string memory id
) external view returns (address) {
return registryMap[id];
}
}// SPDX-License-Identifier: Business Source License 1.1
pragma solidity 0.8.18;
interface IAccountManager {
function freezeAccount(address account, string memory memo) external;
function unfreezeAccount(address account, string memory memo) external;
function isAccountFrozen(address account) external view returns (bool);
function removeAccountPostRecovery(
address from,
address to
) external;
}// SPDX-License-Identifier: Business Source License 1.1
pragma solidity 0.8.18;
interface IAdminTransfer {
function transferShares(address from, address to, uint256 amount) external;
}// SPDX-License-Identifier: Business Source License 1.1
pragma solidity 0.8.18;
interface IAuthorization {
function authorizeAccount(address account) external;
function deauthorizeAccount(address account) external;
function isAccountAuthorized(address account) external view returns (bool);
function isAdminAccount(address account) external view returns (bool);
function getAuthorizedAccountsCount() external view returns (uint256);
function getAuthorizedAccountAt(
uint256 index
) external view returns (address);
}// SPDX-License-Identifier: Business Source License 1.1
pragma solidity 0.8.18;
interface IHoldings {
function getShareHoldings(address account) external view returns (uint256);
function hasEnoughHoldings(
address account,
uint256 amount
) external view returns (bool);
function updateHolderInList(address account) external;
function removeEmptyHolderFromList(address account) external;
}// SPDX-License-Identifier: Business Source License 1.1
pragma solidity 0.8.18;
interface IRecovery {
function recoverAccount(
address from,
address to,
string memory memo
) external;
function recoverAsset(
address from,
address to,
uint256 amount,
string memory memo
) external;
}// SPDX-License-Identifier: Business Source License 1.1
pragma solidity 0.8.18;
interface ITransferAgent {
function adjustBalance(
address account,
uint256 currentBalance,
uint256 newBalance,
string memory memo
) external;
function distributeDividends(
address[] memory accounts,
uint256 date,
int256 rate,
uint256 price
) external;
function endOfDay(
address[] memory accounts,
uint256 date,
int256 rate,
uint256 price
) external;
function settleTransactions(
address[] memory accounts,
uint256 date,
uint256 price
) external;
}// SPDX-License-Identifier: Business Source License 1.1
pragma solidity 0.8.18;
interface ITransferAgentExt {
function adjustBalance(
address account,
uint256 currentBalance,
uint256 newBalance,
string memory memo
) external;
function distributeDividends(
address[] memory accounts,
uint256 date,
int256 rate,
uint256 price
) external;
function distributeDividends(
address[] calldata accounts,
uint256[] calldata adjustedShares,
uint256 date,
int256 rate,
uint256 price
) external;
function endOfDay(
address[] calldata accounts,
bytes32[] calldata txIds,
uint256 date,
int256 rate,
uint256 price
) external;
function endOfDay(
address[] calldata accounts,
uint256[] calldata adjustedShares,
bytes32[] calldata txIds,
uint256 date,
int256 rate,
uint256 price
) external;
function settleTransactions(
address[] calldata accounts,
bytes32[] calldata txIds,
uint256 date,
uint256 price
) external;
}// SPDX-License-Identifier: Business Source License 1.1
pragma solidity 0.8.18;
interface ITransferAgentXChain {
function settleCXTransactions(
address account,
bytes32[] calldata requestIds,
uint256 date,
uint256 price
) external;
function settleCXTransaction(
address account,
bytes32 requestId,
uint256 date,
uint256 price
) external;
}// SPDX-License-Identifier: Business Source License 1.1
pragma solidity 0.8.18;
import {IAuthorization} from "./IAuthorization.sol";
interface ITransactionStorage {
enum TransactionType {
INVALID,
ADJUSTMENT,
AIP,
DIVIDEND,
DIVIDEND_REINVESTMENT,
CASH_LIQUIDATION,
SHARE_LIQUIDATION,
CASH_PURCHASE,
SHARE_PURCHASE,
FULL_LIQUIDATION,
SHARE_TRANSFER,
CXFER_OUT,
CXFER_IN
}
struct TransactionDetail {
TransactionType txType;
uint256 date;
uint256 amount;
bool selfService;
}
struct ShareholderTransaction {
bytes32 txId;
TransactionDetail txDetail;
}
function clearTransactionStorage(
address account,
bytes32 requestId
) external returns (bool);
function unlistFromAccountsWithPendingTransactions(
address account
) external;
function getAccountTransactions(
address account
) external view returns (bytes32[] memory);
function getTransactionDetail(
bytes32 requestId
) external view returns (uint8, uint256, uint256, bool);
function getAccountsWithTransactions(
uint256 pageSize
) external view returns (address[] memory accounts);
function getAccountsWithTransactionsCount() external view returns (uint256);
function hasTransactions(address account) external view returns (bool);
function isFromAccount(
address account,
bytes32 requestId
) external view returns (bool);
}
// Extended interface introduced for the new Share Transfer functionality,
// it was added in TransactionalModule_V3.sol
interface IExtendedTransactionDetail is ITransactionStorage {
struct ExtendedTransactionDetail {
TransactionType txType;
uint256 date;
uint256 amount;
bool selfService;
address source;
address destination;
}
function getExtendedTransactionDetail(
bytes32 requestId
) external view returns (uint8, address, address, uint256, uint256, bool);
}
interface IShareholderTransaction {
function requestCashPurchase(
address account,
uint256 date,
uint256 amount
) external;
function requestCashLiquidation(
address account,
uint256 date,
uint256 amount
) external;
function requestFullLiquidation(address account, uint256 date) external;
}
interface IShareholderTransferTransaction {
function requestShareTransfer(
address account,
address destination,
uint256 date,
uint256 amount
) external;
}
interface IShareholderSelfServiceTransaction {
function requestSelfServiceCashPurchase(uint256 amount) external;
function requestSelfServiceCashLiquidation(uint256 amount) external;
function requestSelfServiceFullLiquidation() external;
function enableSelfService() external;
function disableSelfService() external;
function isSelfServiceEnabled() external view returns (bool);
}
interface IShareholderSelfServiceTransferTransaction {
function requestSelfServiceShareTransfer(
uint256 amount,
address destination
) external;
}
interface ITransferAgentTransaction {
function setupAIP(address account, uint256 date, uint256 amount) external;
}
interface ICancellableSelfServiceTransaction {
function cancelSelfServiceRequest(
bytes32 requestId,
string memory memo
) external;
}
interface ICancellableTransaction {
function cancelRequest(
address account,
bytes32 requestId,
string calldata memo
) external;
}// SPDX-License-Identifier: Business Source License 1.1
pragma solidity 0.8.18;
import "@openzeppelin/contracts-upgradeable/token/ERC20/ERC20Upgradeable.sol";
import "@openzeppelin/contracts-upgradeable/access/AccessControlUpgradeable.sol";
import "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol";
import "@openzeppelin/contracts-upgradeable/proxy/utils/UUPSUpgradeable.sol";
import {EnumerableSet} from "@openzeppelin/contracts/utils/structs/EnumerableSet.sol";
import {ModuleRegistry} from "./infrastructure/ModuleRegistry.sol";
import {IAuthorization} from "./interfaces/IAuthorization.sol";
import {ITransferAgent} from "./interfaces/ITransferAgent.sol";
import {IHoldings} from "./interfaces/IHoldings.sol";
/**
* @title Implementation of a Money Market Fund
*
* This implementation represents a 40 Act Fund in which all operations are cash based.
* It means all amounts passed to the contract functions with the exception of the contructor's
* _seed parameter represent the value (in terms of fiat currency) of the fund shares to buy or sell.
*
* Purchases or sells of shares requested are settled calling any of the settleTransactions or EndOfDay functions.
* The price supplied in the settlement functions corresponds to the NAV per share at the moment of the market closing.
*
*/
contract MoneyMarketFund is
Initializable,
ERC20Upgradeable,
AccessControlUpgradeable,
UUPSUpgradeable,
IHoldings
{
using EnumerableSet for EnumerableSet.AddressSet;
uint256 public constant MAX_PAGE_SIZE_BALANCE = 10;
uint256 public constant NUMBER_SCALE_FACTOR = 1E18;
bytes32 public constant ROLE_TOKEN_OWNER = keccak256("ROLE_TOKEN_OWNER");
bytes32 constant AUTHORIZATION_MODULE = keccak256("MODULE_AUTHORIZATION");
bytes32 constant TRANSACTIONAL_MODULE = keccak256("MODULE_TRANSACTIONAL");
// ******************** State Variables ******************** //
// ********************************************************* //
uint256 public lastKnownPrice;
ModuleRegistry moduleRegistry;
EnumerableSet.AddressSet accountsWithHoldings;
// ********************* Modifiers ********************* //
// ***************************************************** //
modifier onlyAdminOrWriteAccess() {
require(
IAuthorization(
moduleRegistry.getModuleAddress(AUTHORIZATION_MODULE)
).isAdminAccount(_msgSender()) ||
AccessControlUpgradeable(
moduleRegistry.getModuleAddress(AUTHORIZATION_MODULE)
).hasRole(keccak256("WRITE_ACCESS_TOKEN"), _msgSender()),
"NO_WRITE_ACCESS"
);
_;
}
// -------------------- Pagination -------------------- //
modifier onlyWithValidPageSize(uint256 pageSize, uint256 maxPageSize) {
require(
pageSize > 0 && pageSize <= maxPageSize,
"INVALID_PAGINATION_SIZE"
);
_;
}
// ********************************************************************* //
// ********************** MoneyMarketFund ********************** //
// ********************************************************************* //
/// @custom:oz-upgrades-unsafe-allow constructor
constructor() {
_disableInitializers();
}
function _initToken(address owner, uint256 seed, uint256 price) private {
lastKnownPrice = price;
if (seed > 0) {
_mint(owner, seed);
}
}
function initialize(
address _owner_,
uint256 _seed_,
uint256 _price_,
string memory _name_,
string memory _symbol_,
address _moduleRegistry_
) public initializer {
require(_owner_ != address(0), "Owner must not be empty!");
require(_moduleRegistry_ != address(0), "INVALID_REGISTRY_ADDRESS");
__ERC20_init(_name_, _symbol_);
__AccessControl_init();
__UUPSUpgradeable_init();
moduleRegistry = ModuleRegistry(_moduleRegistry_);
_grantRole(DEFAULT_ADMIN_ROLE, _owner_);
_setRoleAdmin(ROLE_TOKEN_OWNER, ROLE_TOKEN_OWNER);
_grantRole(ROLE_TOKEN_OWNER, _owner_);
_initToken(_owner_, _seed_, _price_);
}
function _authorizeUpgrade(
address newImplementation
) internal virtual override onlyRole(ROLE_TOKEN_OWNER) {}
// ************************* Public Interface ************************* //
// ******************************************************************** //
function mintShares(
address account,
uint256 shares
) external virtual onlyAdminOrWriteAccess {
_mint(account, shares);
}
function burnShares(
address account,
uint256 shares
) external virtual onlyAdminOrWriteAccess {
_burn(account, shares);
}
function updateHolderInList(
address account
) external virtual onlyAdminOrWriteAccess {
if (balanceOf(account) > 0) {
accountsWithHoldings.add(account);
} else {
accountsWithHoldings.remove(account);
}
}
function removeEmptyHolderFromList(
address account
) external virtual onlyAdminOrWriteAccess {
if (balanceOf(account) == 0) {
accountsWithHoldings.remove(account);
}
}
function updateLastKnownPrice(
uint256 price
) external virtual onlyAdminOrWriteAccess {
lastKnownPrice = price;
}
// -------------------- Utility view functions -------------------- //
function hasEnoughHoldings(
address account,
uint256 amount
) external view virtual override returns (bool) {
uint256 holdings = ((balanceOf(account) * lastKnownPrice) /
NUMBER_SCALE_FACTOR);
return (holdings > 0 && holdings >= amount);
}
function getShareHoldings(
address account
) external view virtual override returns (uint256) {
return balanceOf(account);
}
// **************** Info Query Utilities (External) **************** //
function getShareholdersWithHoldingsCount()
external
view
virtual
returns (uint256)
{
return accountsWithHoldings.length();
}
function getSharesOutstanding() external view virtual returns (uint256) {
return totalSupply();
}
function hasHoldings(address account) external view virtual returns (bool) {
return accountsWithHoldings.contains(account);
}
function getAccountsBalances(
uint256 pageSize,
uint256 startIndex
)
external
view
virtual
onlyWithValidPageSize(pageSize, MAX_PAGE_SIZE_BALANCE)
returns (
bool hasNext,
uint256 nextIndex,
address[] memory accounts,
uint256[] memory balances
)
{
uint256 count = IAuthorization(
moduleRegistry.getModuleAddress(AUTHORIZATION_MODULE)
).getAuthorizedAccountsCount();
require(startIndex <= count, "INVALID_PAGINATION_INDEX");
uint256 arraySize = pageSize;
hasNext = true;
uint256 end = startIndex + pageSize;
if (end >= count) {
end = count;
arraySize = end - startIndex;
hasNext = false;
}
accounts = new address[](arraySize);
balances = new uint256[](arraySize);
nextIndex = end;
for (uint256 i = startIndex; i < end; ) {
uint256 resIdx = i - startIndex;
accounts[resIdx] = IAuthorization(
moduleRegistry.getModuleAddress(AUTHORIZATION_MODULE)
).getAuthorizedAccountAt(i);
balances[resIdx] = balanceOf(accounts[resIdx]);
unchecked {
i++;
}
}
}
// **************** Internal Functions ***************** //
// ***************************************************** //
// -------------------- ERC20 -------------------- //
// https://docs.openzeppelin.com/contracts/4.x/api/token/erc20#ERC20-_beforeTokenTransfer-address-address-uint256-
function _beforeTokenTransfer(
address from,
address to,
uint256 amount
) internal virtual override {
super._beforeTokenTransfer(from, to, amount);
// token transfers must comply with the policy
// defined by the concrete fund implementation.
_checkTransferPolicy(from, to);
}
// -------------------- Compliance -------------------- //
// Token transfer policy for this fund
// 1. Tokens can only be minted to the admin or shareholder accounts
// 2. Only the admin account is allowed to perform token transfers (this could change in the future)
// 3. Token transfers by accounts other than the admin account will revert
function _checkTransferPolicy(
address from,
address to
) internal view virtual {
if (from == address(0)) {
// Minting policy
require(
IAuthorization(
moduleRegistry.getModuleAddress(AUTHORIZATION_MODULE)
).isAdminAccount(to) ||
IAuthorization(
moduleRegistry.getModuleAddress(AUTHORIZATION_MODULE)
).isAccountAuthorized(to),
"TRANSFER_RESTRICTION"
);
} else if (
IAuthorization(
moduleRegistry.getModuleAddress(AUTHORIZATION_MODULE)
).isAdminAccount(from)
) {
// Transfer policy
if (to != address(0)) {
require(
IAuthorization(
moduleRegistry.getModuleAddress(AUTHORIZATION_MODULE)
).isAccountAuthorized(to),
"TRANSFER_RESTRICTION"
);
}
} else if (
IAuthorization(
moduleRegistry.getModuleAddress(AUTHORIZATION_MODULE)
).isAccountAuthorized(from)
) {
// Burning policy
require(to == address(0), "TRANSFER_RESTRICTION");
} else {
// Any other transfer is restricted
revert("TRANSFER_RESTRICTION");
}
}
}{
"viaIR": true,
"optimizer": {
"enabled": true,
"runs": 200,
"details": {
"yulDetails": {
"optimizerSteps": "u"
}
}
},
"outputSelection": {
"*": {
"*": [
"evm.bytecode",
"evm.deployedBytecode",
"devdoc",
"userdoc",
"metadata",
"abi"
]
}
},
"libraries": {}
}Contract Security Audit
- No Contract Security Audit Submitted- Submit Audit Here
Contract ABI
API[{"inputs":[],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"fromAccount","type":"address"},{"indexed":true,"internalType":"address","name":"toAccount","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"},{"indexed":false,"internalType":"string","name":"memo","type":"string"}],"name":"AccountRecovered","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"previousAdmin","type":"address"},{"indexed":false,"internalType":"address","name":"newAdmin","type":"address"}],"name":"AdminChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"fromAccount","type":"address"},{"indexed":true,"internalType":"address","name":"toAccount","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"},{"indexed":false,"internalType":"string","name":"memo","type":"string"}],"name":"AssetRecovered","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"},{"indexed":false,"internalType":"string","name":"memo","type":"string"}],"name":"BalanceAdjusted","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"beacon","type":"address"}],"name":"BeaconUpgraded","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":true,"internalType":"uint256","name":"date","type":"uint256"},{"indexed":false,"internalType":"int256","name":"rate","type":"int256"},{"indexed":false,"internalType":"uint256","name":"price","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"shares","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"dividendCashAmount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"dividendBasis","type":"uint256"},{"indexed":false,"internalType":"bool","name":"isNegativeYield","type":"bool"}],"name":"DividendDistributed","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint8","name":"version","type":"uint8"}],"name":"Initialized","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"bytes32","name":"previousAdminRole","type":"bytes32"},{"indexed":true,"internalType":"bytes32","name":"newAdminRole","type":"bytes32"}],"name":"RoleAdminChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":true,"internalType":"address","name":"sender","type":"address"}],"name":"RoleGranted","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":true,"internalType":"address","name":"sender","type":"address"}],"name":"RoleRevoked","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":true,"internalType":"uint256","name":"date","type":"uint256"},{"indexed":true,"internalType":"uint8","name":"transactionType","type":"uint8"},{"indexed":false,"internalType":"bytes32","name":"transactionId","type":"bytes32"},{"indexed":false,"internalType":"uint256","name":"price","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"shares","type":"uint256"}],"name":"TransactionSettled","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"from","type":"address"},{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":true,"internalType":"uint256","name":"date","type":"uint256"},{"indexed":false,"internalType":"uint8","name":"transactionType","type":"uint8"},{"indexed":false,"internalType":"bytes32","name":"transactionId","type":"bytes32"},{"indexed":false,"internalType":"uint256","name":"price","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"shares","type":"uint256"}],"name":"TransferSettled","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"implementation","type":"address"}],"name":"Upgraded","type":"event"},{"inputs":[],"name":"DEFAULT_ADMIN_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"MAX_ACCOUNT_PAGE_SIZE","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"MAX_CX_TX_PAGE_SIZE","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"MAX_TX_PAGE_SIZE","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"MODULE_ID","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"ROLE_MODULE_OWNER","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"},{"internalType":"uint256","name":"currentBalance","type":"uint256"},{"internalType":"uint256","name":"newBalance","type":"uint256"},{"internalType":"string","name":"memo","type":"string"}],"name":"adjustBalance","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address[]","name":"accounts","type":"address[]"},{"internalType":"uint256","name":"date","type":"uint256"},{"internalType":"int256","name":"rate","type":"int256"},{"internalType":"uint256","name":"price","type":"uint256"}],"name":"distributeDividends","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address[]","name":"accounts","type":"address[]"},{"internalType":"uint256[]","name":"adjustedShares","type":"uint256[]"},{"internalType":"uint256","name":"date","type":"uint256"},{"internalType":"int256","name":"rate","type":"int256"},{"internalType":"uint256","name":"price","type":"uint256"}],"name":"distributeDividends","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address[]","name":"accounts","type":"address[]"},{"internalType":"bytes32[]","name":"txIds","type":"bytes32[]"},{"internalType":"uint256","name":"date","type":"uint256"},{"internalType":"int256","name":"rate","type":"int256"},{"internalType":"uint256","name":"price","type":"uint256"}],"name":"endOfDay","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address[]","name":"accounts","type":"address[]"},{"internalType":"uint256[]","name":"adjustedShares","type":"uint256[]"},{"internalType":"bytes32[]","name":"txIds","type":"bytes32[]"},{"internalType":"uint256","name":"date","type":"uint256"},{"internalType":"int256","name":"rate","type":"int256"},{"internalType":"uint256","name":"price","type":"uint256"}],"name":"endOfDay","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"}],"name":"getRoleAdmin","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"uint256","name":"index","type":"uint256"}],"name":"getRoleMember","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"}],"name":"getRoleMemberCount","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getVersion","outputs":[{"internalType":"uint8","name":"","type":"uint8"}],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"grantRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"hasRole","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"proxiableUUID","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"from","type":"address"},{"internalType":"address","name":"to","type":"address"},{"internalType":"string","name":"memo","type":"string"}],"name":"recoverAccount","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"from","type":"address"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"string","name":"memo","type":"string"}],"name":"recoverAsset","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"renounceRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"revokeRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"},{"internalType":"bytes32","name":"requestId","type":"bytes32"},{"internalType":"uint256","name":"date","type":"uint256"},{"internalType":"uint256","name":"price","type":"uint256"}],"name":"settleCXTransaction","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"},{"internalType":"bytes32[]","name":"requestIds","type":"bytes32[]"},{"internalType":"uint256","name":"date","type":"uint256"},{"internalType":"uint256","name":"price","type":"uint256"}],"name":"settleCXTransactions","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address[]","name":"accounts","type":"address[]"},{"internalType":"bytes32[]","name":"txIds","type":"bytes32[]"},{"internalType":"uint256","name":"date","type":"uint256"},{"internalType":"uint256","name":"price","type":"uint256"}],"name":"settleTransactions","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes4","name":"interfaceId","type":"bytes4"}],"name":"supportsInterface","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"newImplementation","type":"address"}],"name":"upgradeTo","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newImplementation","type":"address"},{"internalType":"bytes","name":"data","type":"bytes"}],"name":"upgradeToAndCall","outputs":[],"stateMutability":"payable","type":"function"}]Contract Creation Code
60a0604052346200003657620000146200003b565b604051614e9b6200023782396080518181816110ab01526111f70152614e9b90f35b600080fd5b6200004562000051565b6200004f620001a9565b565b6200004f6200004f6200004f6200004f6200004f6200004f6200004f6200004f6200004f6200004f6200004f620000be565b62000099906200009c906001600160a01b031682565b90565b6001600160a01b031690565b620000999062000083565b6200009990620000a8565b620000c930620000b3565b608052565b620000999060081c5b60ff1690565b620000999054620000ce565b60208082526027908201527f496e697469616c697a61626c653a20636f6e747261637420697320696e697469604082015266616c697a696e6760c81b606082015260800190565b156200013857565b60405162461bcd60e51b8152806200015360048201620000e9565b0390fd5b6200009990620000d7565b62000099905462000157565b620000d762000099620000999260ff1690565b906200019562000099620001a5926200016e565b825460ff191660ff919091161790565b9055565b620001c7620001c1620001bd6000620000dd565b1590565b62000130565b620001d3600062000162565b60ff908190811603620001e35750565b620001f081600062000181565b620002317f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb3847402498916200022060405190565b9182918260ff909116815260200190565b0390a156fe6080604052600436101561001257600080fd5b60003560e01c806301ffc9a7146101cd5780630d8e6e2c146101c857806323b2a067146101c3578063248a9ca3146101be5780632f2ff15d146101b9578063333b7bc3146101b457806336568abe146101af5780633659cfe6146101aa5780634f1ef286146101a557806352d1902d146101a05780637278f1ec1461019b57806372cfff3614610196578063835d87b0146101505780639010d07c1461019157806391d148541461018c5780639a290b3c14610187578063a217fddf14610182578063a41521291461017d578063bce049b714610178578063ca15c87314610173578063cbc00d9b1461016e578063d2920e5f14610169578063d547741f14610164578063da9d15b61461015f578063df55e2f91461015a578063ed2f21f514610155578063fa8e26e7146101505763fd059319036101e557610b22565b610707565b610a8b565b610a6f565b610a30565b610a03565b6109e4565b6109ab565b610990565b610974565b6108b3565b610803565b6107d8565b61077b565b610745565b6106d6565b610617565b6105ad565b610599565b6104db565b6104ae565b610493565b61045b565b61040d565b6103d8565b61024c565b610210565b6001600160e01b031981165b036101e557565b600080fd5b905035906101f7826101d2565b565b906020828203126101e55761020d916101ea565b90565b346101e55761023d61022b6102263660046101f9565b610b41565b60405191829182901515815260200190565b0390f35b60009103126101e557565b346101e55761025c366004610241565b61023d610267611d46565b6040519182918260ff909116815260200190565b6001600160a01b031690565b6001600160a01b0381166101de565b905035906101f782610287565b634e487b7160e01b600052604160045260246000fd5b90601f01601f191681019081106001600160401b038211176102da57604052565b6102a3565b906101f76102ec60405190565b92836102b9565b6001600160401b0381116102da5760208091020190565b806101de565b905035906101f78261030a565b9092919261033261032d826102f3565b6102df565b93818552602080860192028301928184116101e557915b8383106103565750505050565b602080916103648486610310565b815201920191610349565b9080601f830112156101e55781602061020d9335910161031d565b6080818303126101e55761039e8282610296565b9260208201356001600160401b0381116101e5576103c18461020d92850161036f565b936103cf8160408601610310565b93606001610310565b346101e5576103f46103eb36600461038a565b92919091612bcb565b604051005b906020828203126101e55761020d91610310565b346101e55761023d6104286104233660046103f9565b610c69565b6040519182918290815260200190565b91906040838203126101e55761020d906104528185610310565b93602001610296565b346101e5576103f461046e366004610438565b90610ca0565b61020d61020d61020d9290565b61020d600a610474565b61020d610481565b346101e5576104a3366004610241565b61023d61042861048b565b346101e5576103f46104c1366004610438565b90610efb565b906020828203126101e55761020d91610296565b346101e5576103f46104ee3660046104c7565b6112b8565b6001600160401b0381116102da57602090601f01601f19160190565b0190565b90826000939282370152565b9092919261052f61032d826104f3565b938185526020850190828401116101e5576101f792610513565b9080601f830112156101e55781602061020d9335910161051f565b9190916040818403126101e55761057b8382610296565b9260208201356001600160401b0381116101e55761020d9201610549565b6103f46105a7366004610564565b90611614565b346101e5576105bd366004610241565b61023d610428611116565b906080828203126101e5576105dd8183610296565b926105eb8260208501610296565b926105f98360408301610310565b9260608201356001600160401b0381116101e55761020d9201610549565b346101e5576103f461062a3660046105c8565b9291909161387e565b909182601f830112156101e5578135916001600160401b0383116101e55760200192602083028401116101e557565b909160a0828403126101e55781356001600160401b0381116101e5578361068a918401610633565b92909360208201356001600160401b0381116101e557816106ac918401610633565b92909361020d6106bf8460408501610310565b936106cd8160608601610310565b93608001610310565b346101e5576103f46106e9366004610662565b9594909493919361234f565b61020d6032610474565b61020d6106f5565b346101e557610717366004610241565b61023d6104286106ff565b91906040838203126101e55761020d9061073c8185610310565b93602001610310565b346101e55761023d61076161075b366004610722565b90610b7a565b604051918291826001600160a01b03909116815260200190565b346101e55761023d61022b610791366004610438565b90610c30565b916060838303126101e5576107ac8284610296565b926107ba8360208301610296565b9260408201356001600160401b0381116101e55761020d9201610549565b346101e5576103f46107eb366004610797565b91613537565b61020d6000610474565b61020d6107f1565b346101e557610813366004610241565b61023d6104286107fb565b9060c0828203126101e55781356001600160401b0381116101e55781610845918401610633565b92909360208201356001600160401b0381116101e55783610867918401610633565b92909360408201356001600160401b0381116101e55781610889918401610633565b92909361020d61089c8460608501610310565b936108aa8160808601610310565b9360a001610310565b346101e5576103f46108c636600461081e565b979690969591959492946129f6565b909291926108e561032d826102f3565b93818552602080860192028301928184116101e557915b8383106109095750505050565b602080916109178486610296565b8152019201916108fc565b9080601f830112156101e55781602061020d933591016108d5565b6080818303126101e55780356001600160401b0381116101e55782610963918301610922565b9261020d6103c18460208501610310565b346101e5576103f461098736600461093d565b9291909161213b565b346101e55761023d6104286109a63660046103f9565b610b9a565b346101e5576109bb366004610241565b61023d7f5d1b39ba4e55b62d72ae3ec4e4c13f204e62992e86e3337a3ac4a53d5bee5980610428565b346101e5576103f46109f7366004610662565b9594909493919361275e565b346101e5576103f4610a16366004610438565b90610e73565b6080818303126101e5576109638282610296565b346101e5576103f4610a43366004610a1c565b92919091612d0e565b906080828203126101e557610a618183610296565b926105eb8260208501610310565b346101e5576103f4610a82366004610a4c565b92919091613086565b346101e557610a9b366004610241565b61023d7f6664d87fbc20fa37f344a63ec498c5b7e28110a1319932173f79ba237ddcc7a3610428565b91906080838203126101e55782356001600160401b0381116101e55781610aec918501610633565b9290936020810135916001600160401b0383116101e557610b128461020d948401610633565b9390946103cf8160408601610310565b346101e5576103f4610b35366004610ac4565b949390939291926124ca565b635a05180f60e01b6001600160e01b0319821614908115610b60575090565b61020d9150610bb1565b905b600052602052604060002090565b90610b9561020d61020d93610b8d600090565b5060fc610b6a565b611ccb565b610bac61020d61020d92610b8d600090565b611c94565b637965db0b60e01b6001600160e01b0319821614908115610bd0575090565b61020d91506001600160e01b0319166301ffc9a760e01b1490565b61020d9061027b906001600160a01b031682565b61020d90610beb565b61020d90610bff565b90610b6c90610c08565b61020d905b60ff1690565b61020d9054610c1b565b61020d916000610c4d610c5393610c45600090565b5060ca610b6a565b01610c11565b610c26565b61020d9081565b61020d9054610c58565b6001610c7a61020d92610c45600090565b01610c5f565b906101f791610c96610c9182610c69565b610cce565b906101f791610caa565b906101f791610c80565b90610cc661020d610ccb93610cbf8482610f4b565b60fc610b6a565b6119f0565b50565b6101f7903390610dcb565b61020d90610474565b610474565b60005b838110610cfa5750506000910152565b8181015183820152602001610cea565b61050f610d2292602092610d1c815190565b94859290565b93849101610ce7565b610d6961020d9392610d63610d63937f416363657373436f6e74726f6c3a206163636f756e7420000000000000000000815260170190565b90610d0a565b7001034b99036b4b9b9b4b733903937b6329607d1b815260110190565b610da7610db060209361050f93610d9b815190565b80835293849260200190565b95869101610ce7565b601f01601f191690565b602080825261020d92910190610d86565b90610ddd610dd98284610c30565b1590565b610de5575050565b610e549161020d610e01610dfb610e3b946119bf565b92610cd9565b610e16602091610e1083610474565b90611875565b92610e2f610e2360405190565b94859384019283610d2b565b908103825203826102b9565b6040515b62461bcd60e51b815291829160048301610dba565b0390fd5b906101f791610e69610c9182610c69565b906101f791610e7d565b906101f791610e58565b90610e9261020d610ccb93610cbf8482610fc4565b611b2b565b15610e9e57565b60405162461bcd60e51b815260206004820152602f60248201527f416363657373436f6e74726f6c3a2063616e206f6e6c792072656e6f756e636560448201526e103937b632b9903337b91039b2b63360891b6064820152608490fd5b6101f79190610f1c610f0c3361027b565b6001600160a01b03841614610e97565b610e7d565b9060ff905b9181191691161790565b90610f4061020d610f4792151590565b8254610f21565b9055565b90610f59610dd98284610c30565b610f61575050565b610f7c6001610f77836000610c4d8760ca610b6a565b610f30565b3390610fb2610fac610fac7f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d9590565b92610c08565b92610fbc60405190565b80805b0390a4565b90610fcf8183610c30565b610fd7575050565b610fec6000610f778382610c4d8760ca610b6a565b3390610fb2610fac610fac7ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b9590565b1561102357565b60405162461bcd60e51b815260206004820152603860248201527f555550535570677261646561626c653a206d757374206e6f742062652063616c60448201527f6c6564207468726f7567682064656c656761746563616c6c00000000000000006064820152608490fd5b61020d906110df61109e30610c08565b6110d96001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000165b916001600160a01b031690565b1461101c565b61110d565b61020d7f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc610474565b5061020d6110e4565b61020d600061108e565b1561112757565b60405162461bcd60e51b815260206004820152602c60248201527f46756e6374696f6e206d7573742062652063616c6c6564207468726f7567682060448201526b19195b1959d85d1958d85b1b60a21b6064820152608490fd5b1561118857565b60405162461bcd60e51b815260206004820152602c60248201527f46756e6374696f6e206d7573742062652063616c6c6564207468726f7567682060448201526b6163746976652070726f787960a01b6064820152608490fd5b6101f7906112526111f230610c08565b6112317f00000000000000000000000000000000000000000000000000000000000000009161122a6110cc846001600160a01b031690565b1415611120565b61124c6110cc61123f6112d4565b926001600160a01b031690565b14611181565b611291565b9061126461032d836104f3565b918252565b369037565b906101f761128461127e84611257565b936104f3565b601f190160208401611269565b6101f79061129e81611d3d565b6000906112b26112ad83610474565b61126e565b9061139e565b6101f7906111e2565b61020d9061027b565b61020d90546112c1565b61020d60006112e461020d6110e4565b016112ca565b61020d7f4910fdfa16fed3260ed0e7147f7cc6da11a60208b5b9406d12a635614ffd9143610474565b905051906101f78261030a565b906020828203126101e55761020d91611313565b6040513d6000823e3d90fd5b1561134757565b60405162461bcd60e51b815260206004820152602960248201527f45524331393637557067726164653a20756e737570706f727465642070726f786044820152681a58589b195555525160ba1b6064820152608490fd5b91906113b660006113b061020d6112ea565b01610c26565b156113c65750506101f790611545565b6113f460206113dc6113d786610c08565b610c08565b6352d1902d906113eb60405190565b93849260e01b90565b825260049082905afa6000918161148d575b50611468575060405162461bcd60e51b815260206004820152602e60248201527f45524331393637557067726164653a206e657720696d706c656d656e7461746960448201526d6f6e206973206e6f74205555505360901b6064820152608490fd5b926114886101f79461148261147e61020d6110e4565b9190565b14611340565b61156d565b6114af91925060203d81116114b6575b6114a781836102b9565b810190611320565b9038611406565b503d61149d565b156114c457565b60405162461bcd60e51b815260206004820152602d60248201527f455243313936373a206e657720696d706c656d656e746174696f6e206973206e60448201526c1bdd08184818dbdb9d1c9858dd609a1b6064820152608490fd5b906001600160a01b0390610f26565b9061153e61020d610f4792610c08565b825461151f565b6101f79061155a6115558261161e565b6114bd565b600061156761020d6110e4565b0161152e565b91611577836115a9565b815161158661147e6000610474565b119081156115a1575b50611598575050565b610ccb9161167b565b90503861158f565b6115b281611545565b6115dc7fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b91610c08565b906115e660405190565b80805b0390a2565b906101f7916115ff6111f230610c08565b6101f79161160c82611d3d565b60019161139e565b906101f7916115ee565b3b61162c61147e6000610474565b1190565b61163a6027611257565b7f416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c6020820152660819985a5b195960ca1b604082015290565b61020d611630565b61020d91611687611673565b916116ac565b3d156116a75761169c3d611257565b903d6000602084013e565b606090565b60008061020d94936116bc606090565b50805190602001845af46116ce61168d565b91611720565b156116db57565b60405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000006044820152606490fd5b919290156117525750815161173861147e6000610474565b14611741575090565b61174d61020d9161161e565b6116d4565b829061175c825190565b61176961147e6000610474565b11156117785750805190602001fd5b610e5490610e3f60405190565b634e487b7160e01b600052601160045260246000fd5b818102929181159184041417156117ae57565b611785565b919082018092116117ae57565b634e487b7160e01b600052603260045260246000fd5b906117df825190565b8110156117ed570160200190565b6117c0565b80156117ae576000190190565b610c2061020d61020d9290565b61020d9061182061147e61020d9460ff1690565b901c90565b1561182c57565b60405162461bcd60e51b815280610e54600482016020808252818101527f537472696e67733a20686578206c656e67746820696e73756666696369656e74604082015260600190565b91906002926118a16112ad6118928461188d88610474565b61179b565b61189b87610474565b906117b3565b9160009060306118b96118b384610474565b866117d6565b536118f16118e8600f60fb1b9261188d6001998a95871a6118e26118dc88610474565b8b6117d6565b53610474565b61189b83610474565b905b611915575b5061020d9394509061190f61147e61020d93610474565b14611825565b9161191f86610474565b83111561198d576f181899199a1a9b1b9c1cb0b131b232b360811b611944600f610474565b82169060108210156117ed57879261196461198192611987941a60f81b90565b851a61197087896117d6565b5361197b60046117ff565b9061180c565b936117f2565b906118f3565b916118f8565b61020d9081906001600160a01b031681565b61020d60146117ff565b61020d61020d61020d9260ff1690565b6119dc6119d761020d926119d1606090565b50610bff565b611993565b610e106119e76119a5565b6119af565b1490565b90611a1361147e610ce26119d7600061020d96611a0b600090565b500194610bff565b611ab5565b80548210156117ed57611a32600191600052602060002090565b91020190600090565b9160001960089290920291821b911b610f26565b9190611a5e61020d610f479390565b908354611a3b565b90815491680100000000000000008310156102da5782611a8e9160016101f795018155611a18565b90611a4f565b9060001990610f26565b90611aae61020d610f4792610474565b8254611a94565b611ac2610dd98383611afb565b15611af457611aef91611aea906001611ae384611adf8482611a66565b5490565b9301610b6a565b611a9e565b600190565b5050600090565b611b19916001611b1492611b0d600090565b5001610b6a565b610c5f565b611b2661147e6000610474565b141590565b90611b4661147e610ce26119d7600061020d96611a0b600090565b611bd5565b919082039182116117ae57565b61020d916008021c81565b9061020d9154611b58565b634e487b7160e01b600052603160045260246000fd5b6101f791600091611a4f565b80548015611bb3576000190190611bb0611baa8383611a18565b90611b84565b55565b611b6e565b9190611a5e61020d610f4793610474565b6101f791600091611bb8565b90611be6611b148260018501610b6a565b600092611bf284610474565b8214611c455761020d92611c4b9492611c5692611c506001978893611c1f611c1986610474565b82611b4b565b88850191611c3d611c2e845490565b611c3789610474565b90611b4b565b828103611c5b575b50505090565b611b90565b01610b6a565b611bc9565b611a8e611c84611c8c94611c7b611c75611aea9589611a18565b90611b63565b92839188611a18565b888801610b6a565b388080611c45565b611caa600061020d92611ca5600090565b500190565b600061020d91611cb8600090565b50015490565b61027b61020d61020d9290565b611cf0611ceb61020d93611ce66000611cf595611ca5600090565b611cfa565b610cd9565b611cbe565b610bff565b61020d916000611c7592611d0c600090565b5001611a18565b506101f77f5d1b39ba4e55b62d72ae3ec4e4c13f204e62992e86e3337a3ac4a53d5bee5980610cce565b6101f790611d13565b61020d60056117ff565b905051906101f782610287565b906020828203126101e55761020d91611d50565b8015156101de565b905051906101f782611d71565b906020828203126101e55761020d91611d79565b15611da157565b60405162461bcd60e51b815260206004820152601660248201527521a0a62622a92fa4a9afa727aa2fa0a72fa0a226a4a760511b6044820152606490fd5b90611e329392916020611df56113d760656112ca565b6322dbefbb90611e24600080516020614e2683398151915292611e1760405190565b998a948593849360e01b90565b835260048301526024820190565b03915afa948515611ed757611e586113d7611e8397602093600091611edc575b50610c08565b63329e058790611e6c3392611e1760405190565b83526001600160a01b031660048301526024820190565b03915afa948515611ed7576101f795611ea491600091611ea9575b50611d9a565b611f48565b611eca915060203d8111611ed0575b611ec281836102b9565b810190611d86565b38611e9e565b503d611eb8565b611334565b611efc9150843d8111611f02575b611ef481836102b9565b810190611d5d565b38611e52565b503d611eea565b15611f1057565b60405162461bcd60e51b815260206004820152601060248201526f494e56414c49445f4449565f5241544560801b6044820152606490fd5b906101f7939291611f65611f5c6000610474565b845b1415611f09565b611fb6565b15611f7157565b60405162461bcd60e51b815260206004820152601760248201527f494e56414c49445f504147494e4154494f4e5f53495a450000000000000000006044820152606490fd5b906101f7939291611fdd611fc8825190565b611fd661147e61020d6106f5565b1115611f6a565b611ffc565b90611feb825190565b8110156117ed576020809102010190565b92909161200d6113d761012f6112ca565b63127d3d3f90803b156101e55761202a916000916113eb60405190565b825260048201869052602490829084905af18015611ed757612115575b506120526000610474565b61205d61020d865190565b81101561210e5761207e6120718287611fe2565b516001600160a01b031690565b906120bf60206120926113d761012f6112ca565b6370a0823190611e6c6120a8612071878d611fe2565b926120b260405190565b9586948593849360e01b90565b03915afa8015611ed757848787926120e9966120e3956000926120ee575b506145ef565b60010190565b612052565b61210791925060203d81116114b6576114a781836102b9565b90386120dd565b5050505050565b61212e9060005b61212681836102b9565b810190610241565b38612047565b503d61211c565b906101f7939291611ddf565b9061218f96959493929160206121606113d760656112ca565b6322dbefbb90611e24600080516020614e268339815191529261218260405190565b9c8d948593849360e01b90565b03915afa978815611ed7576121b46113d76121c89a602093600091611edc5750610c08565b63329e058790611e6c339261218260405190565b03915afa978815611ed7576101f7986121e891600091611ea95750611d9a565b906101f79695949392916122056121ff6000610474565b87611f5e565b6101f79695949392919061221882611fc8565b6101f79695949392919061222b84611fc8565b61224a565b91908110156117ed576020020190565b3561020d81610287565b96959392909461225e6113d761012f6112ca565b63127d3d3f90803b156101e55761227b916000916113eb60405190565b825260048201899052602490829084905af18015611ed757612339575b506122a36000610474565b8681101561232e576122be6122b982898c612230565b612240565b906122ea60208b8a611e6c6120a86122b9876122de6113d761012f6112ca565b946370a0823196612230565b03915afa908115611ed757876123226122b9858f8e9061231d8f8c886120e39b6123299e849c6000926120ee57506145ef565b612230565b8789614174565b6122a3565b505050505050509050565b61234990600061212681836102b9565b38612298565b906101f7969594939291612147565b906123a5959493929160206123766113d760656112ca565b6322dbefbb90611e24600080516020614e268339815191529261239860405190565b9b8c948593849360e01b90565b03915afa968715611ed7576123ca6113d76123de99602093600091611edc5750610c08565b63329e058790611e6c339261239860405190565b03915afa968715611ed7576101f7976123fe91600091611ea95750611d9a565b6101f795949392919061241082611fc8565b6101f795949392919061242284611fc8565b9594959291926124366113d761012f6112ca565b63127d3d3f90803b156101e55788600091611e24836124659561245860405190565b9687958694859360e01b90565b03925af18015611ed7576124b4575b5061247f6000610474565b828110156124aa57806120e3898861249e6122b96124a5968989612230565b888a614174565b61247f565b5050505050509050565b6124c490600061212681836102b9565b38612474565b906101f7959493929161235e565b906124f196959493929160206121606113d760656112ca565b03915afa978815611ed7576121b46113d76125169a602093600091611edc5750610c08565b03915afa978815611ed7576101f79861253691600091611ea95750611d9a565b906101f796959493929161254d6121ff6000610474565b6101f79695949392919061256082611fc8565b6101f79695949392919061257384611fc8565b6125c6565b1561257f57565b60405162461bcd60e51b8152602060048201526015602482015274082a4a482b2be988a9c8ea890be9a92a69a82a8869605b1b6044820152606490fd5b3561020d8161030a565b90959391969492966125d58790565b956125e289885b14612578565b6125f06113d761012f6112ca565b63127d3d3f90803b156101e55761260d916000916113eb60405190565b8252600482018a9052602490829084905af18015611ed757612748575b5060009061263782610474565b885b81101561273b57878787878d8f8961265a612655898484612230565b6125bc565b61266661147e8c610474565b036127115750509150506126b5939250602091506126886113d761012f6112ca565b611e6c61269e6122b9866370a08231958d612230565b926126a860405190565b9687948593849360e01b90565b03915afa908115611ed7576120e38a8a8a8f6126e76122b9878e936126ec9a6126399c6000916126f3575b5094612230565b6145ef565b9050612637565b61270b915060203d81116114b6576114a781836102b9565b386126e0565b926126e76122b9898098956127356126556126399d6120e39b986126ec9e9b612230565b94612230565b5098505050505050505050565b61275890600061212681836102b9565b3861262a565b906101f79695949392916124d8565b906127b7989796959493929160206127886113d760656112ca565b6322dbefbb90611e24600080516020614e26833981519152926127aa60405190565b9e8f948593849360e01b90565b03915afa998a15611ed7576127dc6113d76127f09c602093600091611edc5750610c08565b63329e058790611e6c33926127aa60405190565b03915afa998a15611ed7576101f79a61281091600091611ea95750611d9a565b906101f7989796959493929161282f6128296000610474565b89611f5e565b6101f798979695949392919061284482611fc8565b6101f798979695949392919061285984611fc8565b6101f798979695949392919061286e86611fc8565b96919897959492909861287e8a90565b98612889838b6125dc565b6128976113d761012f6112ca565b63127d3d3f90803b156101e55789600091611e24836128b99561245860405190565b03925af18015611ed7576129e0575b506000906128d582610474565b8b5b8110156129d15785908b8e8c8c8c8c8b8b8b61290361147e6128fd6126558d8787612230565b92610474565b036129a45750505050505082935090602091611e6c6120a86122b9612930966122de6113d761012f6112ca565b03915afa918215611ed7576120e38f8c8f8f926129798f928f928f906122b99261231d898c946128d79f61297f9f908c91600091612986575b505b6126e76122b9898989612230565b91614174565b90506128d5565b61299e915060203d81116114b6576114a781836102b9565b38612969565b886120e397819961231d896128d79e8a61297f9f6126556129cc916129799b6122b99b612230565b61296b565b509a5050505050505050505050565b6129f090600061212681836102b9565b386128c8565b906101f7989796959493929161276d565b90612a1d9392916020611df56113d760656112ca565b03915afa948515611ed757611e586113d7612a4297602093600091611edc5750610c08565b03915afa948515611ed7576101f795612a6291600091611ea95750611d9a565b612ab3565b15612a6e57565b60405162461bcd60e51b815260206004820152601a60248201527f5348415245484f4c4445525f444f45535f4e4f545f45584953540000000000006044820152606490fd5b90612ac99392916020611df56113d760656112ca565b03915afa948515611ed757612aee6113d7612b0697602093600091611edc5750610c08565b634753905890612afd60405190565b97889260e01b90565b82526001600160a01b038416600483015260249082905afa948515611ed7576101f795612b3b91600091612b40575b50612a67565b612b5e565b612b58915060203d8111611ed057611ec281836102b9565b38612b35565b906101f7939291612b7e612b70835190565b611fd661147e61020d610481565b90939293612b8c6000610474565b612b9761020d835190565b811015612bc357806120e38786612bb8612bb4612bbe9688611fe2565b5190565b87614536565b612b8c565b505050509050565b906101f7939291612a07565b90612bed9392916020611df56113d760656112ca565b03915afa948515611ed757611e586113d7612c1297602093600091611edc5750610c08565b03915afa948515611ed7576101f795612c3291600091611ea95750611d9a565b90612c489392916020611df56113d760656112ca565b03915afa948515611ed757612aee6113d7612c6d97602093600091611edc5750610c08565b82526001600160a01b038416600483015260249082905afa948515611ed7576101f795612ca191600091612b405750612a67565b929190612cb26113d761012f6112ca565b9363127d3d3f94803b156101e557612cd095600091612afd60405190565b825260048201879052602490829084905af1948515611ed7576101f795612cf8575b50614536565b612d0890600061212681836102b9565b38612cf2565b906101f7939291612bd7565b90612d309392916020611df56113d760656112ca565b03915afa948515611ed757611e586113d7612d5597602093600091611edc5750610c08565b03915afa948515611ed7576101f795612d7591600091611ea95750611d9a565b90612d8b9392916020611df56113d760656112ca565b03915afa948515611ed757612aee6113d7612db097602093600091611edc5750610c08565b82526001600160a01b038416600483015260249082905afa948515611ed7576101f795612de491600091612b405750612a67565b612eb3565b15612df057565b60405162461bcd60e51b815260206004820152601860248201527f43555252454e545f42414c414e43455f4d49534d4154434800000000000000006044820152606490fd5b15612e3c57565b60405162461bcd60e51b81526020600482015260166024820152751393d7d051129554d51351539517d49154555254915160521b6044820152606490fd5b6001600160a01b0390911681526040810192916101f79160200152565b0152565b90815260406020820181905261020d92910190610d86565b91612ec26113d761012f6112ca565b6370a08231906020612ed360405190565b8092612edf8560e01b90565b82526001600160a01b038816600483015260249082905afa918215611ed757612f1d612f16612f339460209460009161306f575090565b8614612de9565b612f2b6113d761012f6112ca565b6040516113eb565b82526001600160a01b038716600483015260249082905afa908115611ed757612f6d91612f6591600091613057575090565b821415612e35565b8082111561303857612f836113d761012f6112ca565b9163ee7a7c04612f938383611b4b565b843b156101e557612fc794612fbb60008094612fae60405190565b9889958694859360e01b90565b83528b60048401612e7a565b03925af1928315611ed757612fe193613022575b50611b4b565b9161300c7f9330c6882b1373237febaee5a62c00a92ab907e587503330961dfd6cdcfb73a792610c08565b926115e961301960405190565b92839283612e9b565b61303290600061212681836102b9565b38612fdb565b906130476113d761012f6112ca565b9163528c198a612f938383611b4b565b61020d915060203d81116114b6576114a781836102b9565b61020d9150853d81116114b6576114a781836102b9565b906101f7939291612d1a565b906130d6929160206130a76113d760656112ca565b6322dbefbb90611e24600080516020614e26833981519152926130c960405190565b9889948593849360e01b90565b03915afa938415611ed7576130fb6113d761310f96602093600091611edc5750610c08565b63329e058790611e6c33926130c960405190565b03915afa938415611ed7576101f79461312f91600091611ea95750611d9a565b6131e9565b1561313b57565b60405162461bcd60e51b815260206004820152601a60248201527f50454e44494e475f5452414e53414354494f4e535f45584953540000000000006044820152606490fd5b1561318757565b60405162461bcd60e51b81526020600482015260166024820152754143434f554e545f4841535f4e4f5f42414c414e434560501b6044820152606490fd5b6001600160a01b039182168152911660208201526060810192916101f79160400152565b6131f66113d760656112ca565b9261323060206322dbefbb95613217600080516020614e4683398151915290565b9061322160405190565b8080958194611e248c60e01b90565b03915afa908115611ed7576132556113d761326493602093600091611edc5750610c08565b63a0726faa906113eb60405190565b82526001600160a01b038616600483015260249082905afa908115611ed75761329c916132979160009161351f57501590565b613134565b6132aa6113d761012f6112ca565b9363975ec1b79060206132bc60405190565b80976132c88560e01b90565b82526001600160a01b038716600483015260249082905afa918215611ed75761332a966000936134fd575b5060209061330f60009461330961147e87610474565b11613180565b61331d6113d761012f6112ca565b6040515b98899260e01b90565b82526001600160a01b038716600483015260249082905afa958615611ed7576000966134dd575b506133666113d76113d76113d761012f6112ca565b9063bfc77beb91803b156101e55761338c92849161338360405190565b94859260e01b90565b82528183816133a08d8d8d600485016131c5565b03925af1908115611ed7576133dc926020926134c1575b506133c56113d760656112ca565b611e24600080516020614e268339815191526120a8565b03915afa908115611ed7576133fc916113d7916000916134a95750610c08565b63cd66171990803b156101e5576134189183916113eb60405190565b82526001600160a01b03878116600484015288166024830152604490829084905af18015611ed75761348c575b505061347a6134747f6692b4e3c4b28b711c1504f8b4278a263b7cbdfefa4782d9cbda0c8b93e8e07693610c08565b93610c08565b9361348761301960405190565b0390a3565b816134a292903d106121345761212681836102b9565b3880613445565b611efc915060203d8111611f0257611ef481836102b9565b6134d790853d87116121345761212681836102b9565b386133b7565b6134f691965060203d81116114b6576114a781836102b9565b9438613351565b602091935061351890823d81116114b6576114a781836102b9565b92906132f3565b610dd9915060203d8111611ed057611ec281836102b9565b906101f79291613092565b906135589392916020611df56113d760656112ca565b03915afa948515611ed757611e586113d761357d97602093600091611edc5750610c08565b03915afa948515611ed7576101f79561359d91600091611ea95750611d9a565b6135e3565b156135a957565b60405162461bcd60e51b81526020600482015260126024820152714e4f545f454e4f5547485f42414c414e434560701b6044820152606490fd5b9091926135f36113d760656112ca565b6322dbefbb90600080516020614e2683398151915290602061361460405190565b80926136208660e01b90565b82526004820185905260249082905afa908115611ed75761364c916113d7916000916134a95750610c08565b90634753905892602061365e60405190565b809461366a8760e01b90565b82526001600160a01b038916600483015260249082905afa928315611ed75760009361385e575b50826137af575b50506136a49150612a67565b6136c660206136b76113d761012f6112ca565b63975ec1b7906113eb60405190565b82526001600160a01b038616600483015260249082905afa8015611ed7576136f991600091613791575b508511156135a2565b61370d6113d76113d76113d761012f6112ca565b63bfc77beb90803b156101e55761372a916000916113eb60405190565b825281838161373e8b8b8b600485016131c5565b03925af18015611ed75761377b575b5061347a6134747f80f02c15a34ca436c60d73ce1a92c816ed20f071d78b8803bd8a812ee8927ba993610c08565b61378b90600061212681836102b9565b3861374d565b6137a9915060203d81116114b6576114a781836102b9565b386136f0565b6137d2925090602091611e246137c86113d760656112ca565b916120b260405190565b03915afa918215611ed757612f2b6113d76137f7946020946000916138475750610c08565b82526001600160a01b038716600483015260249082905afa8015611ed7576136a491600091613829575b503880613698565b613841915060203d8111611ed057611ec281836102b9565b38613821565b611efc9150853d8111611f0257611ef481836102b9565b61387791935060203d8111611ed057611ec281836102b9565b9138613691565b906101f7939291613542565b939291906138bd60206138a06113d760656112ca565b6322dbefbb90611e24600080516020614e468339815191526120a8565b03915afa908115611ed7576132556113d76138e293602093600091611edc5750610c08565b82526001600160a01b038616600483015260249082905afa908115611ed757600091613928575b50613915575050505050565b61391e94613bd9565b388080808061210e565b613940915060203d8111611ed057611ec281836102b9565b38613909565b9092919261395661032d826102f3565b93818552602080860192028301928184116101e557915b83831061397a5750505050565b602080916139888486611313565b81520192019161396d565b9080601f830112156101e557815161020d92602001613946565b906020828203126101e55781516001600160401b0381116101e55761020d9201613993565b60ff81166101de565b905051906101f7826139d2565b909160c0828403126101e5576139fe83836139db565b92613a0c8160208501611d50565b92613a1a8260408301611d50565b9261020d613a2b8460608501611313565b93613a398160808601611313565b9360a001611d79565b634e487b7160e01b600052602160045260246000fd5b600d1115613a6257565b613a42565b906101f782613a58565b613a8161020d61020d9260ff1690565b613a67565b15613a8d57565b60405162461bcd60e51b815260206004820152601860248201527f494e56414c49445f5452414e53414354494f4e5f5459504500000000000000006044820152606490fd5b634e487b7160e01b600052602260045260246000fd5b9060016002830492168015613b08575b6020831014613b0357565b613ad2565b91607f1691613af8565b80546000939291613b2f613b2583613ae8565b8085529360200190565b9160018116908115613b815750600114613b4857505050565b613b5b9192939450600052602060002090565b916000925b818410613b6d5750500190565b805484840152602090930192600101613b60565b92949550505060ff1916825215156020020190565b602080825261020d92910190613b12565b612e976101f794613bd2606094989795613bcb608086019a600087019060ff169052565b6020850152565b6040830152565b909493929192613bec6113d760656112ca565b926322dbefbb91600080516020614e46833981519152936020613c0e60405190565b8097613c1a8760e01b90565b82526004820188905260249082905afa958615611ed757613c4a6113d7613c599860009384916134a95750610c08565b631e251b739061332160405190565b82526001600160a01b038a16600483015260249082905afa958615611ed757600096614151575b50600095613c8d87610474565b613c9861020d835190565b8110156140c85780613cb0612bb4613cda9385611fe2565b602089613cc06113d760656112ca565b611e248b613ccd60405190565b9788948593849360e01b90565b03915afa928315611ed757613cff6113d7613d179560c0936000916134a95750610c08565b63ee80c25190613d0e60405190565b95869260e01b90565b82526004820184905260249082905afa928315611ed7578b878f8a936000808080809593949091929b61408e575b50613d5f613d5a613d5586613a71565b614c56565b613a86565b871015613d7f575b5050505050505050613d7a915060010190565b613c8d565b8799613d96613d91859a98999a613a71565b614d61565b15613e605750505094613dab613db196613a71565b946147ff565b613dd1602089613dc46113d760656112ca565b611e248b6120b260405190565b03915afa908115611ed757613df46113d76020938e936000916138475750610c08565b613e168c631ad99ccf613e21613e0960405190565b9889968795869460e01b90565b845260048401612e7a565b03925af1918215611ed757613d7a92613e44575b505b38868b878f848181613d67565b613e5b9060203d8111611ed057611ec281836102b9565b613e35565b9091979496939550613e79613e7484613a71565b614d33565b15613ea157505091613d7a979391613e95613e9c979694613a71565b958b614c46565b613e37565b9350939550809450613eb39150613a71565b613ec6613ec0600a613a67565b91613a67565b14613eda575b50505050613d7a9150613e37565b613f0e6020613eed6113d761012e6112ca565b63c409123690613f03610130926120b260405190565b835260048301613b96565b03915afa908115611ed757613f2e916113d7916000916134a95750610c08565b63bfc77beb90803b156101e557613f4a918f916113eb60405190565b8252818381613f5e8b8a8a600485016131c5565b03925af1908115611ed7578e91614071575b5050613f8960208d8d611e246137c86113d760656112ca565b03915afa8015611ed7578f8f613e16613fb06113d76020958d9760009161405a5750610c08565b91631ad99ccf613fcf613fc260405190565b9d8e968795869460e01b90565b03925af1968715611ed757613d7a9761403e575b506140116134747f50b2d180a0fa5c80b28e26e67de589695eaf94f0a306399d7dd36198ee74be3c93610c08565b9361403261401e8d610474565b968c61402960405190565b94859485613ba7565b0390a438808080613ecc565b6140559060203d8111611ed057611ec281836102b9565b613fe3565b611efc9150873d8111611f0257611ef481836102b9565b8161408792903d106121345761212681836102b9565b8c38613f70565b9350505097506140b5915060c03d81116140c1575b6140ad81836102b9565b8101906139e8565b9a92919094939a613d45565b503d6140a3565b50505050506140e89294955090602091611e246137c86113d760656112ca565b03915afa908115611ed757614108916113d7916000916134a95750610c08565b906351e7350b90823b156101e55761412992611e6c85809461245860405190565b03925af18015611ed75761413b575050565b816101f792903d106121345761212681836102b9565b61416d91963d8091833e61416581836102b9565b8101906139ad565b9438613c80565b906101f79493929161388a565b92919061419660206138a06113d760656112ca565b03915afa908115611ed7576132556113d76141bb93602093600091611edc5750610c08565b82526001600160a01b038816600483015260249082905afa908115611ed757600091614200575b506141ee575b50505050565b6141f79361421e565b388080806141e8565b614218915060203d8111611ed057611ec281836102b9565b386141e2565b92909161422e6113d760656112ca565b906322dbefbb9261424a600080516020614e4683398151915290565b92602061425660405190565b80926142628860e01b90565b82526004820187905260249082905afa908115611ed7576142936113d76142a29360c0936000916134a95750610c08565b63ee80c251906113eb60405190565b82526004820189905260249082905afa8015611ed7576000918291829190614511575b506142d5613d5a613d5584613a71565b8410156142e7575b5050505050505050565b6142f081613a71565b6142fd613ec0600b613a67565b03614438579186916143126143199594613a71565b93896147ff565b6143266113d760656112ca565b602061433160405190565b809261433d8660e01b90565b82526004820185905260249082905afa938415611ed75761436e6113d7614381966020946000916138475750610c08565b612fbb6000631ad99ccf612fae60405190565b03925af1918215611ed7576143aa9360209361441d575b505b611e246137c86113d760656112ca565b03915afa908115611ed7576143ca916113d7916000916134a95750610c08565b906351e7350b90823b156101e5576143ec92611e6c6000809461245860405190565b03925af18015611ed757614407575b808080808080806142dd565b61441790600061212681836102b9565b386143fb565b61443390843d8111611ed057611ec281836102b9565b614398565b61444481979597613a71565b614451613ec0600c613a67565b14614468575b50505050506143aa9160209161439a565b918496949161447a6144819594613a71565b9389614a56565b61448e6113d760656112ca565b602061449960405190565b80926144a58660e01b90565b82526004820185905260249082905afa938415611ed75761436e6113d76144d6966020946000916138475750610c08565b03925af1918215611ed7576143aa936020936144f6575b82948294614457565b61450c90843d8111611ed057611ec281836102b9565b6144ed565b91505061452c915060c03d81116140c1576140ad81836102b9565b50939250906142c5565b906101f7939291614181565b1561454957565b60405162461bcd60e51b815260206004820152600d60248201526c494e56414c49445f505249434560981b6044820152606490fd5b634e487b7160e01b600052601260045260246000fd5b811561459e570490565b61457e565b91946145e06145e7929897956145d960a0966145d26101f79a6145cb60c08a019e60008b0152565b6020890152565b6040870152565b6060850152565b6080830152565b019015159052565b9192939093600061460961460282610474565b8411614542565b61461281610474565b8611614621575b505050505050565b614636614630610ce284614df9565b8761179b565b6146408482614594565b9661466360206146546113d761012f6112ca565b630cd4d06e906113eb60405190565b825260049082905afa8015611ed7576146e9946146a392600092614706575b5061468c81610474565b8713156146f7579361469e8b8a614726565b614594565b6146d66146d07fe0b019f23e4f4948c15bdd9dfa8808b046568a2fda0f2978492dcc284fb79c9a98610c08565b98610474565b986146e060405190565b968796876145a3565b0390a3388080808080614619565b5060019361469e8b858b614783565b61471f91925060203d81116114b6576114a781836102b9565b9038614682565b6147346113d761012f6112ca565b9063528c198a91803b156101e557613e166000809461476261475560405190565b9788968795869460e01b90565b03925af18015611ed7576147735750565b6101f790600061212681836102b9565b9190808210156147bf5750905b61479e6113d761012f6112ca565b9063ee7a7c0491803b156101e557613e166000809461476261475560405190565b905090614790565b61020d90613a67565b610c2061020d61020d9260ff1690565b612e976101f794613bd2606094989795613bcb608086019a6000870152565b9194936148289493919360206148196113d761012f6112ca565b630cd4d06e9061332160405190565b825260049082905afa958615611ed757600096614a36575b5061484b6009613a67565b61485482613a67565b0361499c576148869650602061486e6113d761012f6112ca565b6370a082319061487d60405190565b998a9260e01b90565b82526001600160a01b038716600483015260249082905afa968715611ed75760009761497c575b506148bc6113d761012f6112ca565b63ee7a7c0490803b156101e557886000916148de836148ea9561245860405190565b83528c60048401612e7a565b03925af18015611ed757610fbf926149169261490b92614966575b506147c7565b9661469e858a61179b565b9661495361494d6149477f7014f684b5fcb50f814dbc4f6eecdf8b75ad02f7cf3411ee8f574839d892751a97610c08565b97610474565b976147d0565b9761495d60405190565b948594856147e0565b61497690600061212681836102b9565b38614905565b61499591975060203d81116114b6576114a781836102b9565b95386148ad565b9482876149a892614d8f565b946149b76113d761012f6112ca565b9063ee7a7c0491803b156101e5576149d59260009161338360405190565b82528183816149e88d8c60048401612e7a565b03925af1908115611ed757610fbf92614a059261496657506147c7565b9561495361494d6149477f7014f684b5fcb50f814dbc4f6eecdf8b75ad02f7cf3411ee8f574839d892751a97610c08565b614a4f91965060203d81116114b6576114a781836102b9565b9438614840565b93929192614a6d60206146546113d761012f6112ca565b825260049082905afa908115611ed7578486614a9b93614a9593600091614ae2575b50614d8f565b966147c7565b927f7014f684b5fcb50f814dbc4f6eecdf8b75ad02f7cf3411ee8f574839d892751a91614ad18861495361494d6149478b610c08565b0390a46147346113d761012f6112ca565b614afa915060203d81116114b6576114a781836102b9565b38614a8f565b9593919694929096614b0f8890565b976000614b1b81610474565b8a14614b9857614b2a81610474565b8a811015614b8657614b4061265582858d612230565b8814614b4e57600101614b2a565b5050909192939495969750614b6260011590565b614b70575050505050505050565b614b7997614ba6565b38808080808080806142dd565b50614b62919293949596979899501590565b50909192939495966101f798505b50509293614be794614bbb9382979386614a56565b6020614bca6113d760656112ca565b6322dbefbb90611e24600080516020614e4683398151915261269e565b03915afa8015611ed7576113d7614c08916020946000916138475750610c08565b613e166000631ad99ccf614c1e61475560405190565b03925af18015611ed757614c2f5750565b610ccb9060203d8111611ed057611ec281836102b9565b906101f797969594939291614b00565b614c606002613a67565b614c6982613a67565b14908115614d17575b8115614cfb575b8115614cdf575b8115614cc3575b8115614ca7575b8115614c98575090565b90506119ec613ec0600c613a67565b9050614cb3600b613a67565b614cbc82613a67565b1490614c8e565b9050614ccf600a613a67565b614cd882613a67565b1490614c87565b9050614ceb6009613a67565b614cf482613a67565b1490614c80565b9050614d076005613a67565b614d1082613a67565b1490614c79565b9050614d236007613a67565b614d2c82613a67565b1490614c72565b614d3d6002613a67565b614d4682613a67565b14908115614d52575090565b90506119ec613ec06007613a67565b614d6b6005613a67565b614d7482613a67565b14908115614d80575090565b90506119ec613ec06009613a67565b61469e9061020d9392614da0600090565b5061179b565b15614dad57565b60405162461bcd60e51b815260206004820152601360248201527241524954484d455449435f4f564552464c4f5760681b6044820152606490fd5b600160ff1b81146117ae5760000390565b614e09600160ff1b821415614da6565b614e136000610474565b8112614e1c5790565b61020d90614de856fe7240d65a7a839d548ca034d31c390348a6595faeb841857cd5b2bc754a8ab7721581af9f4af9a0e760a18df51c5d829f324fde9afd0a941b43dde8c5aeac07e6a264697066735822122075f4a49ddf4086b81fd2177165d5898cb5b3a92ca5f62c537fe41a996509014564736f6c63430008120033
Deployed Bytecode
0x6080604052600436101561001257600080fd5b60003560e01c806301ffc9a7146101cd5780630d8e6e2c146101c857806323b2a067146101c3578063248a9ca3146101be5780632f2ff15d146101b9578063333b7bc3146101b457806336568abe146101af5780633659cfe6146101aa5780634f1ef286146101a557806352d1902d146101a05780637278f1ec1461019b57806372cfff3614610196578063835d87b0146101505780639010d07c1461019157806391d148541461018c5780639a290b3c14610187578063a217fddf14610182578063a41521291461017d578063bce049b714610178578063ca15c87314610173578063cbc00d9b1461016e578063d2920e5f14610169578063d547741f14610164578063da9d15b61461015f578063df55e2f91461015a578063ed2f21f514610155578063fa8e26e7146101505763fd059319036101e557610b22565b610707565b610a8b565b610a6f565b610a30565b610a03565b6109e4565b6109ab565b610990565b610974565b6108b3565b610803565b6107d8565b61077b565b610745565b6106d6565b610617565b6105ad565b610599565b6104db565b6104ae565b610493565b61045b565b61040d565b6103d8565b61024c565b610210565b6001600160e01b031981165b036101e557565b600080fd5b905035906101f7826101d2565b565b906020828203126101e55761020d916101ea565b90565b346101e55761023d61022b6102263660046101f9565b610b41565b60405191829182901515815260200190565b0390f35b60009103126101e557565b346101e55761025c366004610241565b61023d610267611d46565b6040519182918260ff909116815260200190565b6001600160a01b031690565b6001600160a01b0381166101de565b905035906101f782610287565b634e487b7160e01b600052604160045260246000fd5b90601f01601f191681019081106001600160401b038211176102da57604052565b6102a3565b906101f76102ec60405190565b92836102b9565b6001600160401b0381116102da5760208091020190565b806101de565b905035906101f78261030a565b9092919261033261032d826102f3565b6102df565b93818552602080860192028301928184116101e557915b8383106103565750505050565b602080916103648486610310565b815201920191610349565b9080601f830112156101e55781602061020d9335910161031d565b6080818303126101e55761039e8282610296565b9260208201356001600160401b0381116101e5576103c18461020d92850161036f565b936103cf8160408601610310565b93606001610310565b346101e5576103f46103eb36600461038a565b92919091612bcb565b604051005b906020828203126101e55761020d91610310565b346101e55761023d6104286104233660046103f9565b610c69565b6040519182918290815260200190565b91906040838203126101e55761020d906104528185610310565b93602001610296565b346101e5576103f461046e366004610438565b90610ca0565b61020d61020d61020d9290565b61020d600a610474565b61020d610481565b346101e5576104a3366004610241565b61023d61042861048b565b346101e5576103f46104c1366004610438565b90610efb565b906020828203126101e55761020d91610296565b346101e5576103f46104ee3660046104c7565b6112b8565b6001600160401b0381116102da57602090601f01601f19160190565b0190565b90826000939282370152565b9092919261052f61032d826104f3565b938185526020850190828401116101e5576101f792610513565b9080601f830112156101e55781602061020d9335910161051f565b9190916040818403126101e55761057b8382610296565b9260208201356001600160401b0381116101e55761020d9201610549565b6103f46105a7366004610564565b90611614565b346101e5576105bd366004610241565b61023d610428611116565b906080828203126101e5576105dd8183610296565b926105eb8260208501610296565b926105f98360408301610310565b9260608201356001600160401b0381116101e55761020d9201610549565b346101e5576103f461062a3660046105c8565b9291909161387e565b909182601f830112156101e5578135916001600160401b0383116101e55760200192602083028401116101e557565b909160a0828403126101e55781356001600160401b0381116101e5578361068a918401610633565b92909360208201356001600160401b0381116101e557816106ac918401610633565b92909361020d6106bf8460408501610310565b936106cd8160608601610310565b93608001610310565b346101e5576103f46106e9366004610662565b9594909493919361234f565b61020d6032610474565b61020d6106f5565b346101e557610717366004610241565b61023d6104286106ff565b91906040838203126101e55761020d9061073c8185610310565b93602001610310565b346101e55761023d61076161075b366004610722565b90610b7a565b604051918291826001600160a01b03909116815260200190565b346101e55761023d61022b610791366004610438565b90610c30565b916060838303126101e5576107ac8284610296565b926107ba8360208301610296565b9260408201356001600160401b0381116101e55761020d9201610549565b346101e5576103f46107eb366004610797565b91613537565b61020d6000610474565b61020d6107f1565b346101e557610813366004610241565b61023d6104286107fb565b9060c0828203126101e55781356001600160401b0381116101e55781610845918401610633565b92909360208201356001600160401b0381116101e55783610867918401610633565b92909360408201356001600160401b0381116101e55781610889918401610633565b92909361020d61089c8460608501610310565b936108aa8160808601610310565b9360a001610310565b346101e5576103f46108c636600461081e565b979690969591959492946129f6565b909291926108e561032d826102f3565b93818552602080860192028301928184116101e557915b8383106109095750505050565b602080916109178486610296565b8152019201916108fc565b9080601f830112156101e55781602061020d933591016108d5565b6080818303126101e55780356001600160401b0381116101e55782610963918301610922565b9261020d6103c18460208501610310565b346101e5576103f461098736600461093d565b9291909161213b565b346101e55761023d6104286109a63660046103f9565b610b9a565b346101e5576109bb366004610241565b61023d7f5d1b39ba4e55b62d72ae3ec4e4c13f204e62992e86e3337a3ac4a53d5bee5980610428565b346101e5576103f46109f7366004610662565b9594909493919361275e565b346101e5576103f4610a16366004610438565b90610e73565b6080818303126101e5576109638282610296565b346101e5576103f4610a43366004610a1c565b92919091612d0e565b906080828203126101e557610a618183610296565b926105eb8260208501610310565b346101e5576103f4610a82366004610a4c565b92919091613086565b346101e557610a9b366004610241565b61023d7f6664d87fbc20fa37f344a63ec498c5b7e28110a1319932173f79ba237ddcc7a3610428565b91906080838203126101e55782356001600160401b0381116101e55781610aec918501610633565b9290936020810135916001600160401b0383116101e557610b128461020d948401610633565b9390946103cf8160408601610310565b346101e5576103f4610b35366004610ac4565b949390939291926124ca565b635a05180f60e01b6001600160e01b0319821614908115610b60575090565b61020d9150610bb1565b905b600052602052604060002090565b90610b9561020d61020d93610b8d600090565b5060fc610b6a565b611ccb565b610bac61020d61020d92610b8d600090565b611c94565b637965db0b60e01b6001600160e01b0319821614908115610bd0575090565b61020d91506001600160e01b0319166301ffc9a760e01b1490565b61020d9061027b906001600160a01b031682565b61020d90610beb565b61020d90610bff565b90610b6c90610c08565b61020d905b60ff1690565b61020d9054610c1b565b61020d916000610c4d610c5393610c45600090565b5060ca610b6a565b01610c11565b610c26565b61020d9081565b61020d9054610c58565b6001610c7a61020d92610c45600090565b01610c5f565b906101f791610c96610c9182610c69565b610cce565b906101f791610caa565b906101f791610c80565b90610cc661020d610ccb93610cbf8482610f4b565b60fc610b6a565b6119f0565b50565b6101f7903390610dcb565b61020d90610474565b610474565b60005b838110610cfa5750506000910152565b8181015183820152602001610cea565b61050f610d2292602092610d1c815190565b94859290565b93849101610ce7565b610d6961020d9392610d63610d63937f416363657373436f6e74726f6c3a206163636f756e7420000000000000000000815260170190565b90610d0a565b7001034b99036b4b9b9b4b733903937b6329607d1b815260110190565b610da7610db060209361050f93610d9b815190565b80835293849260200190565b95869101610ce7565b601f01601f191690565b602080825261020d92910190610d86565b90610ddd610dd98284610c30565b1590565b610de5575050565b610e549161020d610e01610dfb610e3b946119bf565b92610cd9565b610e16602091610e1083610474565b90611875565b92610e2f610e2360405190565b94859384019283610d2b565b908103825203826102b9565b6040515b62461bcd60e51b815291829160048301610dba565b0390fd5b906101f791610e69610c9182610c69565b906101f791610e7d565b906101f791610e58565b90610e9261020d610ccb93610cbf8482610fc4565b611b2b565b15610e9e57565b60405162461bcd60e51b815260206004820152602f60248201527f416363657373436f6e74726f6c3a2063616e206f6e6c792072656e6f756e636560448201526e103937b632b9903337b91039b2b63360891b6064820152608490fd5b6101f79190610f1c610f0c3361027b565b6001600160a01b03841614610e97565b610e7d565b9060ff905b9181191691161790565b90610f4061020d610f4792151590565b8254610f21565b9055565b90610f59610dd98284610c30565b610f61575050565b610f7c6001610f77836000610c4d8760ca610b6a565b610f30565b3390610fb2610fac610fac7f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d9590565b92610c08565b92610fbc60405190565b80805b0390a4565b90610fcf8183610c30565b610fd7575050565b610fec6000610f778382610c4d8760ca610b6a565b3390610fb2610fac610fac7ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b9590565b1561102357565b60405162461bcd60e51b815260206004820152603860248201527f555550535570677261646561626c653a206d757374206e6f742062652063616c60448201527f6c6564207468726f7567682064656c656761746563616c6c00000000000000006064820152608490fd5b61020d906110df61109e30610c08565b6110d96001600160a01b037f0000000000000000000000000a5e03aaa760873c22c25f132ee642a2d4cc9865165b916001600160a01b031690565b1461101c565b61110d565b61020d7f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc610474565b5061020d6110e4565b61020d600061108e565b1561112757565b60405162461bcd60e51b815260206004820152602c60248201527f46756e6374696f6e206d7573742062652063616c6c6564207468726f7567682060448201526b19195b1959d85d1958d85b1b60a21b6064820152608490fd5b1561118857565b60405162461bcd60e51b815260206004820152602c60248201527f46756e6374696f6e206d7573742062652063616c6c6564207468726f7567682060448201526b6163746976652070726f787960a01b6064820152608490fd5b6101f7906112526111f230610c08565b6112317f0000000000000000000000000a5e03aaa760873c22c25f132ee642a2d4cc98659161122a6110cc846001600160a01b031690565b1415611120565b61124c6110cc61123f6112d4565b926001600160a01b031690565b14611181565b611291565b9061126461032d836104f3565b918252565b369037565b906101f761128461127e84611257565b936104f3565b601f190160208401611269565b6101f79061129e81611d3d565b6000906112b26112ad83610474565b61126e565b9061139e565b6101f7906111e2565b61020d9061027b565b61020d90546112c1565b61020d60006112e461020d6110e4565b016112ca565b61020d7f4910fdfa16fed3260ed0e7147f7cc6da11a60208b5b9406d12a635614ffd9143610474565b905051906101f78261030a565b906020828203126101e55761020d91611313565b6040513d6000823e3d90fd5b1561134757565b60405162461bcd60e51b815260206004820152602960248201527f45524331393637557067726164653a20756e737570706f727465642070726f786044820152681a58589b195555525160ba1b6064820152608490fd5b91906113b660006113b061020d6112ea565b01610c26565b156113c65750506101f790611545565b6113f460206113dc6113d786610c08565b610c08565b6352d1902d906113eb60405190565b93849260e01b90565b825260049082905afa6000918161148d575b50611468575060405162461bcd60e51b815260206004820152602e60248201527f45524331393637557067726164653a206e657720696d706c656d656e7461746960448201526d6f6e206973206e6f74205555505360901b6064820152608490fd5b926114886101f79461148261147e61020d6110e4565b9190565b14611340565b61156d565b6114af91925060203d81116114b6575b6114a781836102b9565b810190611320565b9038611406565b503d61149d565b156114c457565b60405162461bcd60e51b815260206004820152602d60248201527f455243313936373a206e657720696d706c656d656e746174696f6e206973206e60448201526c1bdd08184818dbdb9d1c9858dd609a1b6064820152608490fd5b906001600160a01b0390610f26565b9061153e61020d610f4792610c08565b825461151f565b6101f79061155a6115558261161e565b6114bd565b600061156761020d6110e4565b0161152e565b91611577836115a9565b815161158661147e6000610474565b119081156115a1575b50611598575050565b610ccb9161167b565b90503861158f565b6115b281611545565b6115dc7fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b91610c08565b906115e660405190565b80805b0390a2565b906101f7916115ff6111f230610c08565b6101f79161160c82611d3d565b60019161139e565b906101f7916115ee565b3b61162c61147e6000610474565b1190565b61163a6027611257565b7f416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c6020820152660819985a5b195960ca1b604082015290565b61020d611630565b61020d91611687611673565b916116ac565b3d156116a75761169c3d611257565b903d6000602084013e565b606090565b60008061020d94936116bc606090565b50805190602001845af46116ce61168d565b91611720565b156116db57565b60405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000006044820152606490fd5b919290156117525750815161173861147e6000610474565b14611741575090565b61174d61020d9161161e565b6116d4565b829061175c825190565b61176961147e6000610474565b11156117785750805190602001fd5b610e5490610e3f60405190565b634e487b7160e01b600052601160045260246000fd5b818102929181159184041417156117ae57565b611785565b919082018092116117ae57565b634e487b7160e01b600052603260045260246000fd5b906117df825190565b8110156117ed570160200190565b6117c0565b80156117ae576000190190565b610c2061020d61020d9290565b61020d9061182061147e61020d9460ff1690565b901c90565b1561182c57565b60405162461bcd60e51b815280610e54600482016020808252818101527f537472696e67733a20686578206c656e67746820696e73756666696369656e74604082015260600190565b91906002926118a16112ad6118928461188d88610474565b61179b565b61189b87610474565b906117b3565b9160009060306118b96118b384610474565b866117d6565b536118f16118e8600f60fb1b9261188d6001998a95871a6118e26118dc88610474565b8b6117d6565b53610474565b61189b83610474565b905b611915575b5061020d9394509061190f61147e61020d93610474565b14611825565b9161191f86610474565b83111561198d576f181899199a1a9b1b9c1cb0b131b232b360811b611944600f610474565b82169060108210156117ed57879261196461198192611987941a60f81b90565b851a61197087896117d6565b5361197b60046117ff565b9061180c565b936117f2565b906118f3565b916118f8565b61020d9081906001600160a01b031681565b61020d60146117ff565b61020d61020d61020d9260ff1690565b6119dc6119d761020d926119d1606090565b50610bff565b611993565b610e106119e76119a5565b6119af565b1490565b90611a1361147e610ce26119d7600061020d96611a0b600090565b500194610bff565b611ab5565b80548210156117ed57611a32600191600052602060002090565b91020190600090565b9160001960089290920291821b911b610f26565b9190611a5e61020d610f479390565b908354611a3b565b90815491680100000000000000008310156102da5782611a8e9160016101f795018155611a18565b90611a4f565b9060001990610f26565b90611aae61020d610f4792610474565b8254611a94565b611ac2610dd98383611afb565b15611af457611aef91611aea906001611ae384611adf8482611a66565b5490565b9301610b6a565b611a9e565b600190565b5050600090565b611b19916001611b1492611b0d600090565b5001610b6a565b610c5f565b611b2661147e6000610474565b141590565b90611b4661147e610ce26119d7600061020d96611a0b600090565b611bd5565b919082039182116117ae57565b61020d916008021c81565b9061020d9154611b58565b634e487b7160e01b600052603160045260246000fd5b6101f791600091611a4f565b80548015611bb3576000190190611bb0611baa8383611a18565b90611b84565b55565b611b6e565b9190611a5e61020d610f4793610474565b6101f791600091611bb8565b90611be6611b148260018501610b6a565b600092611bf284610474565b8214611c455761020d92611c4b9492611c5692611c506001978893611c1f611c1986610474565b82611b4b565b88850191611c3d611c2e845490565b611c3789610474565b90611b4b565b828103611c5b575b50505090565b611b90565b01610b6a565b611bc9565b611a8e611c84611c8c94611c7b611c75611aea9589611a18565b90611b63565b92839188611a18565b888801610b6a565b388080611c45565b611caa600061020d92611ca5600090565b500190565b600061020d91611cb8600090565b50015490565b61027b61020d61020d9290565b611cf0611ceb61020d93611ce66000611cf595611ca5600090565b611cfa565b610cd9565b611cbe565b610bff565b61020d916000611c7592611d0c600090565b5001611a18565b506101f77f5d1b39ba4e55b62d72ae3ec4e4c13f204e62992e86e3337a3ac4a53d5bee5980610cce565b6101f790611d13565b61020d60056117ff565b905051906101f782610287565b906020828203126101e55761020d91611d50565b8015156101de565b905051906101f782611d71565b906020828203126101e55761020d91611d79565b15611da157565b60405162461bcd60e51b815260206004820152601660248201527521a0a62622a92fa4a9afa727aa2fa0a72fa0a226a4a760511b6044820152606490fd5b90611e329392916020611df56113d760656112ca565b6322dbefbb90611e24600080516020614e2683398151915292611e1760405190565b998a948593849360e01b90565b835260048301526024820190565b03915afa948515611ed757611e586113d7611e8397602093600091611edc575b50610c08565b63329e058790611e6c3392611e1760405190565b83526001600160a01b031660048301526024820190565b03915afa948515611ed7576101f795611ea491600091611ea9575b50611d9a565b611f48565b611eca915060203d8111611ed0575b611ec281836102b9565b810190611d86565b38611e9e565b503d611eb8565b611334565b611efc9150843d8111611f02575b611ef481836102b9565b810190611d5d565b38611e52565b503d611eea565b15611f1057565b60405162461bcd60e51b815260206004820152601060248201526f494e56414c49445f4449565f5241544560801b6044820152606490fd5b906101f7939291611f65611f5c6000610474565b845b1415611f09565b611fb6565b15611f7157565b60405162461bcd60e51b815260206004820152601760248201527f494e56414c49445f504147494e4154494f4e5f53495a450000000000000000006044820152606490fd5b906101f7939291611fdd611fc8825190565b611fd661147e61020d6106f5565b1115611f6a565b611ffc565b90611feb825190565b8110156117ed576020809102010190565b92909161200d6113d761012f6112ca565b63127d3d3f90803b156101e55761202a916000916113eb60405190565b825260048201869052602490829084905af18015611ed757612115575b506120526000610474565b61205d61020d865190565b81101561210e5761207e6120718287611fe2565b516001600160a01b031690565b906120bf60206120926113d761012f6112ca565b6370a0823190611e6c6120a8612071878d611fe2565b926120b260405190565b9586948593849360e01b90565b03915afa8015611ed757848787926120e9966120e3956000926120ee575b506145ef565b60010190565b612052565b61210791925060203d81116114b6576114a781836102b9565b90386120dd565b5050505050565b61212e9060005b61212681836102b9565b810190610241565b38612047565b503d61211c565b906101f7939291611ddf565b9061218f96959493929160206121606113d760656112ca565b6322dbefbb90611e24600080516020614e268339815191529261218260405190565b9c8d948593849360e01b90565b03915afa978815611ed7576121b46113d76121c89a602093600091611edc5750610c08565b63329e058790611e6c339261218260405190565b03915afa978815611ed7576101f7986121e891600091611ea95750611d9a565b906101f79695949392916122056121ff6000610474565b87611f5e565b6101f79695949392919061221882611fc8565b6101f79695949392919061222b84611fc8565b61224a565b91908110156117ed576020020190565b3561020d81610287565b96959392909461225e6113d761012f6112ca565b63127d3d3f90803b156101e55761227b916000916113eb60405190565b825260048201899052602490829084905af18015611ed757612339575b506122a36000610474565b8681101561232e576122be6122b982898c612230565b612240565b906122ea60208b8a611e6c6120a86122b9876122de6113d761012f6112ca565b946370a0823196612230565b03915afa908115611ed757876123226122b9858f8e9061231d8f8c886120e39b6123299e849c6000926120ee57506145ef565b612230565b8789614174565b6122a3565b505050505050509050565b61234990600061212681836102b9565b38612298565b906101f7969594939291612147565b906123a5959493929160206123766113d760656112ca565b6322dbefbb90611e24600080516020614e268339815191529261239860405190565b9b8c948593849360e01b90565b03915afa968715611ed7576123ca6113d76123de99602093600091611edc5750610c08565b63329e058790611e6c339261239860405190565b03915afa968715611ed7576101f7976123fe91600091611ea95750611d9a565b6101f795949392919061241082611fc8565b6101f795949392919061242284611fc8565b9594959291926124366113d761012f6112ca565b63127d3d3f90803b156101e55788600091611e24836124659561245860405190565b9687958694859360e01b90565b03925af18015611ed7576124b4575b5061247f6000610474565b828110156124aa57806120e3898861249e6122b96124a5968989612230565b888a614174565b61247f565b5050505050509050565b6124c490600061212681836102b9565b38612474565b906101f7959493929161235e565b906124f196959493929160206121606113d760656112ca565b03915afa978815611ed7576121b46113d76125169a602093600091611edc5750610c08565b03915afa978815611ed7576101f79861253691600091611ea95750611d9a565b906101f796959493929161254d6121ff6000610474565b6101f79695949392919061256082611fc8565b6101f79695949392919061257384611fc8565b6125c6565b1561257f57565b60405162461bcd60e51b8152602060048201526015602482015274082a4a482b2be988a9c8ea890be9a92a69a82a8869605b1b6044820152606490fd5b3561020d8161030a565b90959391969492966125d58790565b956125e289885b14612578565b6125f06113d761012f6112ca565b63127d3d3f90803b156101e55761260d916000916113eb60405190565b8252600482018a9052602490829084905af18015611ed757612748575b5060009061263782610474565b885b81101561273b57878787878d8f8961265a612655898484612230565b6125bc565b61266661147e8c610474565b036127115750509150506126b5939250602091506126886113d761012f6112ca565b611e6c61269e6122b9866370a08231958d612230565b926126a860405190565b9687948593849360e01b90565b03915afa908115611ed7576120e38a8a8a8f6126e76122b9878e936126ec9a6126399c6000916126f3575b5094612230565b6145ef565b9050612637565b61270b915060203d81116114b6576114a781836102b9565b386126e0565b926126e76122b9898098956127356126556126399d6120e39b986126ec9e9b612230565b94612230565b5098505050505050505050565b61275890600061212681836102b9565b3861262a565b906101f79695949392916124d8565b906127b7989796959493929160206127886113d760656112ca565b6322dbefbb90611e24600080516020614e26833981519152926127aa60405190565b9e8f948593849360e01b90565b03915afa998a15611ed7576127dc6113d76127f09c602093600091611edc5750610c08565b63329e058790611e6c33926127aa60405190565b03915afa998a15611ed7576101f79a61281091600091611ea95750611d9a565b906101f7989796959493929161282f6128296000610474565b89611f5e565b6101f798979695949392919061284482611fc8565b6101f798979695949392919061285984611fc8565b6101f798979695949392919061286e86611fc8565b96919897959492909861287e8a90565b98612889838b6125dc565b6128976113d761012f6112ca565b63127d3d3f90803b156101e55789600091611e24836128b99561245860405190565b03925af18015611ed7576129e0575b506000906128d582610474565b8b5b8110156129d15785908b8e8c8c8c8c8b8b8b61290361147e6128fd6126558d8787612230565b92610474565b036129a45750505050505082935090602091611e6c6120a86122b9612930966122de6113d761012f6112ca565b03915afa918215611ed7576120e38f8c8f8f926129798f928f928f906122b99261231d898c946128d79f61297f9f908c91600091612986575b505b6126e76122b9898989612230565b91614174565b90506128d5565b61299e915060203d81116114b6576114a781836102b9565b38612969565b886120e397819961231d896128d79e8a61297f9f6126556129cc916129799b6122b99b612230565b61296b565b509a5050505050505050505050565b6129f090600061212681836102b9565b386128c8565b906101f7989796959493929161276d565b90612a1d9392916020611df56113d760656112ca565b03915afa948515611ed757611e586113d7612a4297602093600091611edc5750610c08565b03915afa948515611ed7576101f795612a6291600091611ea95750611d9a565b612ab3565b15612a6e57565b60405162461bcd60e51b815260206004820152601a60248201527f5348415245484f4c4445525f444f45535f4e4f545f45584953540000000000006044820152606490fd5b90612ac99392916020611df56113d760656112ca565b03915afa948515611ed757612aee6113d7612b0697602093600091611edc5750610c08565b634753905890612afd60405190565b97889260e01b90565b82526001600160a01b038416600483015260249082905afa948515611ed7576101f795612b3b91600091612b40575b50612a67565b612b5e565b612b58915060203d8111611ed057611ec281836102b9565b38612b35565b906101f7939291612b7e612b70835190565b611fd661147e61020d610481565b90939293612b8c6000610474565b612b9761020d835190565b811015612bc357806120e38786612bb8612bb4612bbe9688611fe2565b5190565b87614536565b612b8c565b505050509050565b906101f7939291612a07565b90612bed9392916020611df56113d760656112ca565b03915afa948515611ed757611e586113d7612c1297602093600091611edc5750610c08565b03915afa948515611ed7576101f795612c3291600091611ea95750611d9a565b90612c489392916020611df56113d760656112ca565b03915afa948515611ed757612aee6113d7612c6d97602093600091611edc5750610c08565b82526001600160a01b038416600483015260249082905afa948515611ed7576101f795612ca191600091612b405750612a67565b929190612cb26113d761012f6112ca565b9363127d3d3f94803b156101e557612cd095600091612afd60405190565b825260048201879052602490829084905af1948515611ed7576101f795612cf8575b50614536565b612d0890600061212681836102b9565b38612cf2565b906101f7939291612bd7565b90612d309392916020611df56113d760656112ca565b03915afa948515611ed757611e586113d7612d5597602093600091611edc5750610c08565b03915afa948515611ed7576101f795612d7591600091611ea95750611d9a565b90612d8b9392916020611df56113d760656112ca565b03915afa948515611ed757612aee6113d7612db097602093600091611edc5750610c08565b82526001600160a01b038416600483015260249082905afa948515611ed7576101f795612de491600091612b405750612a67565b612eb3565b15612df057565b60405162461bcd60e51b815260206004820152601860248201527f43555252454e545f42414c414e43455f4d49534d4154434800000000000000006044820152606490fd5b15612e3c57565b60405162461bcd60e51b81526020600482015260166024820152751393d7d051129554d51351539517d49154555254915160521b6044820152606490fd5b6001600160a01b0390911681526040810192916101f79160200152565b0152565b90815260406020820181905261020d92910190610d86565b91612ec26113d761012f6112ca565b6370a08231906020612ed360405190565b8092612edf8560e01b90565b82526001600160a01b038816600483015260249082905afa918215611ed757612f1d612f16612f339460209460009161306f575090565b8614612de9565b612f2b6113d761012f6112ca565b6040516113eb565b82526001600160a01b038716600483015260249082905afa908115611ed757612f6d91612f6591600091613057575090565b821415612e35565b8082111561303857612f836113d761012f6112ca565b9163ee7a7c04612f938383611b4b565b843b156101e557612fc794612fbb60008094612fae60405190565b9889958694859360e01b90565b83528b60048401612e7a565b03925af1928315611ed757612fe193613022575b50611b4b565b9161300c7f9330c6882b1373237febaee5a62c00a92ab907e587503330961dfd6cdcfb73a792610c08565b926115e961301960405190565b92839283612e9b565b61303290600061212681836102b9565b38612fdb565b906130476113d761012f6112ca565b9163528c198a612f938383611b4b565b61020d915060203d81116114b6576114a781836102b9565b61020d9150853d81116114b6576114a781836102b9565b906101f7939291612d1a565b906130d6929160206130a76113d760656112ca565b6322dbefbb90611e24600080516020614e26833981519152926130c960405190565b9889948593849360e01b90565b03915afa938415611ed7576130fb6113d761310f96602093600091611edc5750610c08565b63329e058790611e6c33926130c960405190565b03915afa938415611ed7576101f79461312f91600091611ea95750611d9a565b6131e9565b1561313b57565b60405162461bcd60e51b815260206004820152601a60248201527f50454e44494e475f5452414e53414354494f4e535f45584953540000000000006044820152606490fd5b1561318757565b60405162461bcd60e51b81526020600482015260166024820152754143434f554e545f4841535f4e4f5f42414c414e434560501b6044820152606490fd5b6001600160a01b039182168152911660208201526060810192916101f79160400152565b6131f66113d760656112ca565b9261323060206322dbefbb95613217600080516020614e4683398151915290565b9061322160405190565b8080958194611e248c60e01b90565b03915afa908115611ed7576132556113d761326493602093600091611edc5750610c08565b63a0726faa906113eb60405190565b82526001600160a01b038616600483015260249082905afa908115611ed75761329c916132979160009161351f57501590565b613134565b6132aa6113d761012f6112ca565b9363975ec1b79060206132bc60405190565b80976132c88560e01b90565b82526001600160a01b038716600483015260249082905afa918215611ed75761332a966000936134fd575b5060209061330f60009461330961147e87610474565b11613180565b61331d6113d761012f6112ca565b6040515b98899260e01b90565b82526001600160a01b038716600483015260249082905afa958615611ed7576000966134dd575b506133666113d76113d76113d761012f6112ca565b9063bfc77beb91803b156101e55761338c92849161338360405190565b94859260e01b90565b82528183816133a08d8d8d600485016131c5565b03925af1908115611ed7576133dc926020926134c1575b506133c56113d760656112ca565b611e24600080516020614e268339815191526120a8565b03915afa908115611ed7576133fc916113d7916000916134a95750610c08565b63cd66171990803b156101e5576134189183916113eb60405190565b82526001600160a01b03878116600484015288166024830152604490829084905af18015611ed75761348c575b505061347a6134747f6692b4e3c4b28b711c1504f8b4278a263b7cbdfefa4782d9cbda0c8b93e8e07693610c08565b93610c08565b9361348761301960405190565b0390a3565b816134a292903d106121345761212681836102b9565b3880613445565b611efc915060203d8111611f0257611ef481836102b9565b6134d790853d87116121345761212681836102b9565b386133b7565b6134f691965060203d81116114b6576114a781836102b9565b9438613351565b602091935061351890823d81116114b6576114a781836102b9565b92906132f3565b610dd9915060203d8111611ed057611ec281836102b9565b906101f79291613092565b906135589392916020611df56113d760656112ca565b03915afa948515611ed757611e586113d761357d97602093600091611edc5750610c08565b03915afa948515611ed7576101f79561359d91600091611ea95750611d9a565b6135e3565b156135a957565b60405162461bcd60e51b81526020600482015260126024820152714e4f545f454e4f5547485f42414c414e434560701b6044820152606490fd5b9091926135f36113d760656112ca565b6322dbefbb90600080516020614e2683398151915290602061361460405190565b80926136208660e01b90565b82526004820185905260249082905afa908115611ed75761364c916113d7916000916134a95750610c08565b90634753905892602061365e60405190565b809461366a8760e01b90565b82526001600160a01b038916600483015260249082905afa928315611ed75760009361385e575b50826137af575b50506136a49150612a67565b6136c660206136b76113d761012f6112ca565b63975ec1b7906113eb60405190565b82526001600160a01b038616600483015260249082905afa8015611ed7576136f991600091613791575b508511156135a2565b61370d6113d76113d76113d761012f6112ca565b63bfc77beb90803b156101e55761372a916000916113eb60405190565b825281838161373e8b8b8b600485016131c5565b03925af18015611ed75761377b575b5061347a6134747f80f02c15a34ca436c60d73ce1a92c816ed20f071d78b8803bd8a812ee8927ba993610c08565b61378b90600061212681836102b9565b3861374d565b6137a9915060203d81116114b6576114a781836102b9565b386136f0565b6137d2925090602091611e246137c86113d760656112ca565b916120b260405190565b03915afa918215611ed757612f2b6113d76137f7946020946000916138475750610c08565b82526001600160a01b038716600483015260249082905afa8015611ed7576136a491600091613829575b503880613698565b613841915060203d8111611ed057611ec281836102b9565b38613821565b611efc9150853d8111611f0257611ef481836102b9565b61387791935060203d8111611ed057611ec281836102b9565b9138613691565b906101f7939291613542565b939291906138bd60206138a06113d760656112ca565b6322dbefbb90611e24600080516020614e468339815191526120a8565b03915afa908115611ed7576132556113d76138e293602093600091611edc5750610c08565b82526001600160a01b038616600483015260249082905afa908115611ed757600091613928575b50613915575050505050565b61391e94613bd9565b388080808061210e565b613940915060203d8111611ed057611ec281836102b9565b38613909565b9092919261395661032d826102f3565b93818552602080860192028301928184116101e557915b83831061397a5750505050565b602080916139888486611313565b81520192019161396d565b9080601f830112156101e557815161020d92602001613946565b906020828203126101e55781516001600160401b0381116101e55761020d9201613993565b60ff81166101de565b905051906101f7826139d2565b909160c0828403126101e5576139fe83836139db565b92613a0c8160208501611d50565b92613a1a8260408301611d50565b9261020d613a2b8460608501611313565b93613a398160808601611313565b9360a001611d79565b634e487b7160e01b600052602160045260246000fd5b600d1115613a6257565b613a42565b906101f782613a58565b613a8161020d61020d9260ff1690565b613a67565b15613a8d57565b60405162461bcd60e51b815260206004820152601860248201527f494e56414c49445f5452414e53414354494f4e5f5459504500000000000000006044820152606490fd5b634e487b7160e01b600052602260045260246000fd5b9060016002830492168015613b08575b6020831014613b0357565b613ad2565b91607f1691613af8565b80546000939291613b2f613b2583613ae8565b8085529360200190565b9160018116908115613b815750600114613b4857505050565b613b5b9192939450600052602060002090565b916000925b818410613b6d5750500190565b805484840152602090930192600101613b60565b92949550505060ff1916825215156020020190565b602080825261020d92910190613b12565b612e976101f794613bd2606094989795613bcb608086019a600087019060ff169052565b6020850152565b6040830152565b909493929192613bec6113d760656112ca565b926322dbefbb91600080516020614e46833981519152936020613c0e60405190565b8097613c1a8760e01b90565b82526004820188905260249082905afa958615611ed757613c4a6113d7613c599860009384916134a95750610c08565b631e251b739061332160405190565b82526001600160a01b038a16600483015260249082905afa958615611ed757600096614151575b50600095613c8d87610474565b613c9861020d835190565b8110156140c85780613cb0612bb4613cda9385611fe2565b602089613cc06113d760656112ca565b611e248b613ccd60405190565b9788948593849360e01b90565b03915afa928315611ed757613cff6113d7613d179560c0936000916134a95750610c08565b63ee80c25190613d0e60405190565b95869260e01b90565b82526004820184905260249082905afa928315611ed7578b878f8a936000808080809593949091929b61408e575b50613d5f613d5a613d5586613a71565b614c56565b613a86565b871015613d7f575b5050505050505050613d7a915060010190565b613c8d565b8799613d96613d91859a98999a613a71565b614d61565b15613e605750505094613dab613db196613a71565b946147ff565b613dd1602089613dc46113d760656112ca565b611e248b6120b260405190565b03915afa908115611ed757613df46113d76020938e936000916138475750610c08565b613e168c631ad99ccf613e21613e0960405190565b9889968795869460e01b90565b845260048401612e7a565b03925af1918215611ed757613d7a92613e44575b505b38868b878f848181613d67565b613e5b9060203d8111611ed057611ec281836102b9565b613e35565b9091979496939550613e79613e7484613a71565b614d33565b15613ea157505091613d7a979391613e95613e9c979694613a71565b958b614c46565b613e37565b9350939550809450613eb39150613a71565b613ec6613ec0600a613a67565b91613a67565b14613eda575b50505050613d7a9150613e37565b613f0e6020613eed6113d761012e6112ca565b63c409123690613f03610130926120b260405190565b835260048301613b96565b03915afa908115611ed757613f2e916113d7916000916134a95750610c08565b63bfc77beb90803b156101e557613f4a918f916113eb60405190565b8252818381613f5e8b8a8a600485016131c5565b03925af1908115611ed7578e91614071575b5050613f8960208d8d611e246137c86113d760656112ca565b03915afa8015611ed7578f8f613e16613fb06113d76020958d9760009161405a5750610c08565b91631ad99ccf613fcf613fc260405190565b9d8e968795869460e01b90565b03925af1968715611ed757613d7a9761403e575b506140116134747f50b2d180a0fa5c80b28e26e67de589695eaf94f0a306399d7dd36198ee74be3c93610c08565b9361403261401e8d610474565b968c61402960405190565b94859485613ba7565b0390a438808080613ecc565b6140559060203d8111611ed057611ec281836102b9565b613fe3565b611efc9150873d8111611f0257611ef481836102b9565b8161408792903d106121345761212681836102b9565b8c38613f70565b9350505097506140b5915060c03d81116140c1575b6140ad81836102b9565b8101906139e8565b9a92919094939a613d45565b503d6140a3565b50505050506140e89294955090602091611e246137c86113d760656112ca565b03915afa908115611ed757614108916113d7916000916134a95750610c08565b906351e7350b90823b156101e55761412992611e6c85809461245860405190565b03925af18015611ed75761413b575050565b816101f792903d106121345761212681836102b9565b61416d91963d8091833e61416581836102b9565b8101906139ad565b9438613c80565b906101f79493929161388a565b92919061419660206138a06113d760656112ca565b03915afa908115611ed7576132556113d76141bb93602093600091611edc5750610c08565b82526001600160a01b038816600483015260249082905afa908115611ed757600091614200575b506141ee575b50505050565b6141f79361421e565b388080806141e8565b614218915060203d8111611ed057611ec281836102b9565b386141e2565b92909161422e6113d760656112ca565b906322dbefbb9261424a600080516020614e4683398151915290565b92602061425660405190565b80926142628860e01b90565b82526004820187905260249082905afa908115611ed7576142936113d76142a29360c0936000916134a95750610c08565b63ee80c251906113eb60405190565b82526004820189905260249082905afa8015611ed7576000918291829190614511575b506142d5613d5a613d5584613a71565b8410156142e7575b5050505050505050565b6142f081613a71565b6142fd613ec0600b613a67565b03614438579186916143126143199594613a71565b93896147ff565b6143266113d760656112ca565b602061433160405190565b809261433d8660e01b90565b82526004820185905260249082905afa938415611ed75761436e6113d7614381966020946000916138475750610c08565b612fbb6000631ad99ccf612fae60405190565b03925af1918215611ed7576143aa9360209361441d575b505b611e246137c86113d760656112ca565b03915afa908115611ed7576143ca916113d7916000916134a95750610c08565b906351e7350b90823b156101e5576143ec92611e6c6000809461245860405190565b03925af18015611ed757614407575b808080808080806142dd565b61441790600061212681836102b9565b386143fb565b61443390843d8111611ed057611ec281836102b9565b614398565b61444481979597613a71565b614451613ec0600c613a67565b14614468575b50505050506143aa9160209161439a565b918496949161447a6144819594613a71565b9389614a56565b61448e6113d760656112ca565b602061449960405190565b80926144a58660e01b90565b82526004820185905260249082905afa938415611ed75761436e6113d76144d6966020946000916138475750610c08565b03925af1918215611ed7576143aa936020936144f6575b82948294614457565b61450c90843d8111611ed057611ec281836102b9565b6144ed565b91505061452c915060c03d81116140c1576140ad81836102b9565b50939250906142c5565b906101f7939291614181565b1561454957565b60405162461bcd60e51b815260206004820152600d60248201526c494e56414c49445f505249434560981b6044820152606490fd5b634e487b7160e01b600052601260045260246000fd5b811561459e570490565b61457e565b91946145e06145e7929897956145d960a0966145d26101f79a6145cb60c08a019e60008b0152565b6020890152565b6040870152565b6060850152565b6080830152565b019015159052565b9192939093600061460961460282610474565b8411614542565b61461281610474565b8611614621575b505050505050565b614636614630610ce284614df9565b8761179b565b6146408482614594565b9661466360206146546113d761012f6112ca565b630cd4d06e906113eb60405190565b825260049082905afa8015611ed7576146e9946146a392600092614706575b5061468c81610474565b8713156146f7579361469e8b8a614726565b614594565b6146d66146d07fe0b019f23e4f4948c15bdd9dfa8808b046568a2fda0f2978492dcc284fb79c9a98610c08565b98610474565b986146e060405190565b968796876145a3565b0390a3388080808080614619565b5060019361469e8b858b614783565b61471f91925060203d81116114b6576114a781836102b9565b9038614682565b6147346113d761012f6112ca565b9063528c198a91803b156101e557613e166000809461476261475560405190565b9788968795869460e01b90565b03925af18015611ed7576147735750565b6101f790600061212681836102b9565b9190808210156147bf5750905b61479e6113d761012f6112ca565b9063ee7a7c0491803b156101e557613e166000809461476261475560405190565b905090614790565b61020d90613a67565b610c2061020d61020d9260ff1690565b612e976101f794613bd2606094989795613bcb608086019a6000870152565b9194936148289493919360206148196113d761012f6112ca565b630cd4d06e9061332160405190565b825260049082905afa958615611ed757600096614a36575b5061484b6009613a67565b61485482613a67565b0361499c576148869650602061486e6113d761012f6112ca565b6370a082319061487d60405190565b998a9260e01b90565b82526001600160a01b038716600483015260249082905afa968715611ed75760009761497c575b506148bc6113d761012f6112ca565b63ee7a7c0490803b156101e557886000916148de836148ea9561245860405190565b83528c60048401612e7a565b03925af18015611ed757610fbf926149169261490b92614966575b506147c7565b9661469e858a61179b565b9661495361494d6149477f7014f684b5fcb50f814dbc4f6eecdf8b75ad02f7cf3411ee8f574839d892751a97610c08565b97610474565b976147d0565b9761495d60405190565b948594856147e0565b61497690600061212681836102b9565b38614905565b61499591975060203d81116114b6576114a781836102b9565b95386148ad565b9482876149a892614d8f565b946149b76113d761012f6112ca565b9063ee7a7c0491803b156101e5576149d59260009161338360405190565b82528183816149e88d8c60048401612e7a565b03925af1908115611ed757610fbf92614a059261496657506147c7565b9561495361494d6149477f7014f684b5fcb50f814dbc4f6eecdf8b75ad02f7cf3411ee8f574839d892751a97610c08565b614a4f91965060203d81116114b6576114a781836102b9565b9438614840565b93929192614a6d60206146546113d761012f6112ca565b825260049082905afa908115611ed7578486614a9b93614a9593600091614ae2575b50614d8f565b966147c7565b927f7014f684b5fcb50f814dbc4f6eecdf8b75ad02f7cf3411ee8f574839d892751a91614ad18861495361494d6149478b610c08565b0390a46147346113d761012f6112ca565b614afa915060203d81116114b6576114a781836102b9565b38614a8f565b9593919694929096614b0f8890565b976000614b1b81610474565b8a14614b9857614b2a81610474565b8a811015614b8657614b4061265582858d612230565b8814614b4e57600101614b2a565b5050909192939495969750614b6260011590565b614b70575050505050505050565b614b7997614ba6565b38808080808080806142dd565b50614b62919293949596979899501590565b50909192939495966101f798505b50509293614be794614bbb9382979386614a56565b6020614bca6113d760656112ca565b6322dbefbb90611e24600080516020614e4683398151915261269e565b03915afa8015611ed7576113d7614c08916020946000916138475750610c08565b613e166000631ad99ccf614c1e61475560405190565b03925af18015611ed757614c2f5750565b610ccb9060203d8111611ed057611ec281836102b9565b906101f797969594939291614b00565b614c606002613a67565b614c6982613a67565b14908115614d17575b8115614cfb575b8115614cdf575b8115614cc3575b8115614ca7575b8115614c98575090565b90506119ec613ec0600c613a67565b9050614cb3600b613a67565b614cbc82613a67565b1490614c8e565b9050614ccf600a613a67565b614cd882613a67565b1490614c87565b9050614ceb6009613a67565b614cf482613a67565b1490614c80565b9050614d076005613a67565b614d1082613a67565b1490614c79565b9050614d236007613a67565b614d2c82613a67565b1490614c72565b614d3d6002613a67565b614d4682613a67565b14908115614d52575090565b90506119ec613ec06007613a67565b614d6b6005613a67565b614d7482613a67565b14908115614d80575090565b90506119ec613ec06009613a67565b61469e9061020d9392614da0600090565b5061179b565b15614dad57565b60405162461bcd60e51b815260206004820152601360248201527241524954484d455449435f4f564552464c4f5760681b6044820152606490fd5b600160ff1b81146117ae5760000390565b614e09600160ff1b821415614da6565b614e136000610474565b8112614e1c5790565b61020d90614de856fe7240d65a7a839d548ca034d31c390348a6595faeb841857cd5b2bc754a8ab7721581af9f4af9a0e760a18df51c5d829f324fde9afd0a941b43dde8c5aeac07e6a264697066735822122075f4a49ddf4086b81fd2177165d5898cb5b3a92ca5f62c537fe41a996509014564736f6c63430008120033
Loading...
Loading
Loading...
Loading
Loading...
Loading
Net Worth in USD
$0.00
Net Worth in ETH
0
Multichain Portfolio | 34 Chains
| Chain | Token | Portfolio % | Price | Amount | Value |
|---|
Loading...
Loading
Loading...
Loading
Loading...
Loading
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.