Source Code
Overview
MON Balance
MON Value
$0.00Loading...
Loading
Similar Match Source Code This contract matches the deployed Bytecode of the Source Code for Contract 0x5D63378C...Ce71FeF99 The constructor portion of the code might be different and could alter the actual behaviour of the contract
Contract Name:
MultiAccountV2
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: SYMM-Core-Business-Source-License-1.1
// This contract is licensed under the SYMM Core Business Source License 1.1
// Copyright (c) 2023 Symmetry Labs AG
// For more information, see https://docs.symm.io/legal-disclaimer/license
pragma solidity >=0.8.18;
import './MultiAccount.sol';
contract MultiAccountV2 is MultiAccount {
mapping(address => address) public referrals; // user -> referrer
/// @custom:oz-upgrades-unsafe-allow constructor
constructor() {
_disableInitializers();
}
/**
* @dev Sets multiple referrals for users. Only callable by an account with the SETTER_ROLE.
* @param _referrals An array of Referral structs containing user and referrer addresses.
*/
function setReferrals(Referral[] calldata _referrals) external onlyRole(SETTER_ROLE) {
// This function is kept for backward compatibility and does not perform any action.
for (uint256 i = 0; i < _referrals.length; i++) {
referrals[_referrals[i].user] = _referrals[i].referrer;
emit SetReferral(_referrals[i].user, _referrals[i].referrer);
}
}
/**
* @dev Adds a new account for the caller with the specified name and links the creator to his referrer.
* @param name The name of the new account.
* @param referrer The address of the referrer.
*/
function addAccountWithReferral(string memory name, address referrer) external whenNotPaused {
require(referrals[msg.sender] == address(0), 'MultiAccount: Referral already set');
referrals[msg.sender] = referrer;
emit SetReferral(msg.sender, referrer);
this.addAccount(name);
}
/**
* @dev Adds a new account for the caller with the specified name, links the creator to his referrer, deposits and allocates the specified amount.
* @param name The name of the new account.
* @param referrer The address of the referrer.
* @param amount The amount to deposit and allocate.
*/
function addAccountWithReferralAndDepositAndAllocate(string memory name, address referrer, uint256 amount) external whenNotPaused {
this.addAccountWithReferral(name, referrer);
this.depositAndAllocateForAccount(accounts[msg.sender][accounts[msg.sender].length - 1].accountAddress, amount);
}
}// 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 {Initializable} from "../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 {
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);
_;
}
function __AccessControl_init() internal onlyInitializing {
}
function __AccessControl_init_unchained() internal onlyInitializing {
}
/**
* @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/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 v4.4.1 (interfaces/IERC20.sol) pragma solidity ^0.8.0; import "../token/ERC20/IERC20Upgradeable.sol";
// 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.7.0) (security/Pausable.sol)
pragma solidity ^0.8.0;
import "../utils/ContextUpgradeable.sol";
import {Initializable} from "../proxy/utils/Initializable.sol";
/**
* @dev Contract module which allows children to implement an emergency stop
* mechanism that can be triggered by an authorized account.
*
* This module is used through inheritance. It will make available the
* modifiers `whenNotPaused` and `whenPaused`, which can be applied to
* the functions of your contract. Note that they will not be pausable by
* simply including this module, only once the modifiers are put in place.
*/
abstract contract PausableUpgradeable is Initializable, ContextUpgradeable {
/**
* @dev Emitted when the pause is triggered by `account`.
*/
event Paused(address account);
/**
* @dev Emitted when the pause is lifted by `account`.
*/
event Unpaused(address account);
bool private _paused;
/**
* @dev Initializes the contract in unpaused state.
*/
function __Pausable_init() internal onlyInitializing {
__Pausable_init_unchained();
}
function __Pausable_init_unchained() internal onlyInitializing {
_paused = false;
}
/**
* @dev Modifier to make a function callable only when the contract is not paused.
*
* Requirements:
*
* - The contract must not be paused.
*/
modifier whenNotPaused() {
_requireNotPaused();
_;
}
/**
* @dev Modifier to make a function callable only when the contract is paused.
*
* Requirements:
*
* - The contract must be paused.
*/
modifier whenPaused() {
_requirePaused();
_;
}
/**
* @dev Returns true if the contract is paused, and false otherwise.
*/
function paused() public view virtual returns (bool) {
return _paused;
}
/**
* @dev Throws if the contract is paused.
*/
function _requireNotPaused() internal view virtual {
require(!paused(), "Pausable: paused");
}
/**
* @dev Throws if the contract is not paused.
*/
function _requirePaused() internal view virtual {
require(paused(), "Pausable: not paused");
}
/**
* @dev Triggers stopped state.
*
* Requirements:
*
* - The contract must not be paused.
*/
function _pause() internal virtual whenNotPaused {
_paused = true;
emit Paused(_msgSender());
}
/**
* @dev Returns to normal state.
*
* Requirements:
*
* - The contract must be paused.
*/
function _unpause() internal virtual whenPaused {
_paused = false;
emit Unpaused(_msgSender());
}
/**
* @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.4) (token/ERC20/extensions/IERC20Permit.sol)
pragma solidity ^0.8.0;
/**
* @dev Interface of the ERC20 Permit extension allowing approvals to be made via signatures, as defined in
* https://eips.ethereum.org/EIPS/eip-2612[EIP-2612].
*
* Adds the {permit} method, which can be used to change an account's ERC20 allowance (see {IERC20-allowance}) by
* presenting a message signed by the account. By not relying on {IERC20-approve}, the token holder account doesn't
* need to send a transaction, and thus is not required to hold Ether at all.
*
* ==== Security Considerations
*
* There are two important considerations concerning the use of `permit`. The first is that a valid permit signature
* expresses an allowance, and it should not be assumed to convey additional meaning. In particular, it should not be
* considered as an intention to spend the allowance in any specific way. The second is that because permits have
* built-in replay protection and can be submitted by anyone, they can be frontrun. A protocol that uses permits should
* take this into consideration and allow a `permit` call to fail. Combining these two aspects, a pattern that may be
* generally recommended is:
*
* ```solidity
* function doThingWithPermit(..., uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s) public {
* try token.permit(msg.sender, address(this), value, deadline, v, r, s) {} catch {}
* doThing(..., value);
* }
*
* function doThing(..., uint256 value) public {
* token.safeTransferFrom(msg.sender, address(this), value);
* ...
* }
* ```
*
* Observe that: 1) `msg.sender` is used as the owner, leaving no ambiguity as to the signer intent, and 2) the use of
* `try/catch` allows the permit to fail and makes the code tolerant to frontrunning. (See also
* {SafeERC20-safeTransferFrom}).
*
* Additionally, note that smart contract wallets (such as Argent or Safe) are not able to produce permit signatures, so
* contracts should have entry points that don't rely on permit.
*/
interface IERC20PermitUpgradeable {
/**
* @dev Sets `value` as the allowance of `spender` over ``owner``'s tokens,
* given ``owner``'s signed approval.
*
* IMPORTANT: The same issues {IERC20-approve} has related to transaction
* ordering also apply here.
*
* Emits an {Approval} event.
*
* Requirements:
*
* - `spender` cannot be the zero address.
* - `deadline` must be a timestamp in the future.
* - `v`, `r` and `s` must be a valid `secp256k1` signature from `owner`
* over the EIP712-formatted function arguments.
* - the signature must use ``owner``'s current nonce (see {nonces}).
*
* For more information on the signature format, see the
* https://eips.ethereum.org/EIPS/eip-2612#specification[relevant EIP
* section].
*
* CAUTION: See Security Considerations above.
*/
function permit(
address owner,
address spender,
uint256 value,
uint256 deadline,
uint8 v,
bytes32 r,
bytes32 s
) external;
/**
* @dev Returns the current nonce for `owner`. This value must be
* included whenever a signature is generated for {permit}.
*
* Every successful call to {permit} increases ``owner``'s nonce by one. This
* prevents a signature from being used multiple times.
*/
function nonces(address owner) external view returns (uint256);
/**
* @dev Returns the domain separator used in the encoding of the signature for {permit}, as defined by {EIP712}.
*/
// solhint-disable-next-line func-name-mixedcase
function DOMAIN_SEPARATOR() external view returns (bytes32);
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (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.3) (token/ERC20/utils/SafeERC20.sol)
pragma solidity ^0.8.0;
import "../IERC20Upgradeable.sol";
import "../extensions/IERC20PermitUpgradeable.sol";
import "../../../utils/AddressUpgradeable.sol";
/**
* @title SafeERC20
* @dev Wrappers around ERC20 operations that throw on failure (when the token
* contract returns false). Tokens that return no value (and instead revert or
* throw on failure) are also supported, non-reverting calls are assumed to be
* successful.
* To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract,
* which allows you to call the safe operations as `token.safeTransfer(...)`, etc.
*/
library SafeERC20Upgradeable {
using AddressUpgradeable for address;
/**
* @dev Transfer `value` amount of `token` from the calling contract to `to`. If `token` returns no value,
* non-reverting calls are assumed to be successful.
*/
function safeTransfer(IERC20Upgradeable token, address to, uint256 value) internal {
_callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value));
}
/**
* @dev Transfer `value` amount of `token` from `from` to `to`, spending the approval given by `from` to the
* calling contract. If `token` returns no value, non-reverting calls are assumed to be successful.
*/
function safeTransferFrom(IERC20Upgradeable token, address from, address to, uint256 value) internal {
_callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value));
}
/**
* @dev Deprecated. This function has issues similar to the ones found in
* {IERC20-approve}, and its usage is discouraged.
*
* Whenever possible, use {safeIncreaseAllowance} and
* {safeDecreaseAllowance} instead.
*/
function safeApprove(IERC20Upgradeable token, address spender, uint256 value) internal {
// safeApprove should only be called when setting an initial allowance,
// or when resetting it to zero. To increase and decrease it, use
// 'safeIncreaseAllowance' and 'safeDecreaseAllowance'
require(
(value == 0) || (token.allowance(address(this), spender) == 0),
"SafeERC20: approve from non-zero to non-zero allowance"
);
_callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value));
}
/**
* @dev Increase the calling contract's allowance toward `spender` by `value`. If `token` returns no value,
* non-reverting calls are assumed to be successful.
*/
function safeIncreaseAllowance(IERC20Upgradeable token, address spender, uint256 value) internal {
uint256 oldAllowance = token.allowance(address(this), spender);
_callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, oldAllowance + value));
}
/**
* @dev Decrease the calling contract's allowance toward `spender` by `value`. If `token` returns no value,
* non-reverting calls are assumed to be successful.
*/
function safeDecreaseAllowance(IERC20Upgradeable token, address spender, uint256 value) internal {
unchecked {
uint256 oldAllowance = token.allowance(address(this), spender);
require(oldAllowance >= value, "SafeERC20: decreased allowance below zero");
_callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, oldAllowance - value));
}
}
/**
* @dev Set the calling contract's allowance toward `spender` to `value`. If `token` returns no value,
* non-reverting calls are assumed to be successful. Meant to be used with tokens that require the approval
* to be set to zero before setting it to a non-zero value, such as USDT.
*/
function forceApprove(IERC20Upgradeable token, address spender, uint256 value) internal {
bytes memory approvalCall = abi.encodeWithSelector(token.approve.selector, spender, value);
if (!_callOptionalReturnBool(token, approvalCall)) {
_callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, 0));
_callOptionalReturn(token, approvalCall);
}
}
/**
* @dev Use a ERC-2612 signature to set the `owner` approval toward `spender` on `token`.
* Revert on invalid signature.
*/
function safePermit(
IERC20PermitUpgradeable token,
address owner,
address spender,
uint256 value,
uint256 deadline,
uint8 v,
bytes32 r,
bytes32 s
) internal {
uint256 nonceBefore = token.nonces(owner);
token.permit(owner, spender, value, deadline, v, r, s);
uint256 nonceAfter = token.nonces(owner);
require(nonceAfter == nonceBefore + 1, "SafeERC20: permit did not succeed");
}
/**
* @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement
* on the return value: the return value is optional (but if data is returned, it must not be false).
* @param token The token targeted by the call.
* @param data The call data (encoded using abi.encode or one of its variants).
*/
function _callOptionalReturn(IERC20Upgradeable token, bytes memory data) private {
// We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since
// we're implementing it ourselves. We use {Address-functionCall} to perform this call, which verifies that
// the target address contains contract code and also asserts for success in the low-level call.
bytes memory returndata = address(token).functionCall(data, "SafeERC20: low-level call failed");
require(returndata.length == 0 || abi.decode(returndata, (bool)), "SafeERC20: ERC20 operation did not succeed");
}
/**
* @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement
* on the return value: the return value is optional (but if data is returned, it must not be false).
* @param token The token targeted by the call.
* @param data The call data (encoded using abi.encode or one of its variants).
*
* This is a variant of {_callOptionalReturn} that silents catches all reverts and returns a bool instead.
*/
function _callOptionalReturnBool(IERC20Upgradeable token, bytes memory data) private returns (bool) {
// We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since
// we're implementing it ourselves. We cannot use {Address-functionCall} here since this should return false
// and not revert is the subcall reverts.
(bool success, bytes memory returndata) = address(token).call(data);
return
success && (returndata.length == 0 || abi.decode(returndata, (bool))) && AddressUpgradeable.isContract(address(token));
}
}// 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 (last updated v4.9.4) (utils/Context.sol)
pragma solidity ^0.8.0;
import {Initializable} from "../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;
}
function _contextSuffixLength() internal view virtual returns (uint256) {
return 0;
}
/**
* @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 {Initializable} from "../../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/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 v4.4.1 (token/ERC20/extensions/IERC20Metadata.sol)
pragma solidity ^0.8.0;
import "../IERC20.sol";
/**
* @dev Interface for the optional metadata functions from the ERC20 standard.
*
* _Available since v4.1._
*/
interface IERC20Metadata is IERC20 {
/**
* @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 IERC20 {
/**
* @dev Emitted when `value` tokens are moved from one account (`from`) to
* another (`to`).
*
* Note that `value` may be zero.
*/
event Transfer(address indexed from, address indexed to, uint256 value);
/**
* @dev Emitted when the allowance of a `spender` for an `owner` is set by
* a call to {approve}. `value` is the new allowance.
*/
event Approval(address indexed owner, address indexed spender, uint256 value);
/**
* @dev Returns the amount of tokens in existence.
*/
function totalSupply() external view returns (uint256);
/**
* @dev Returns the amount of tokens owned by `account`.
*/
function balanceOf(address account) external view returns (uint256);
/**
* @dev Moves `amount` tokens from the caller's account to `to`.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transfer(address to, uint256 amount) external returns (bool);
/**
* @dev Returns the remaining number of tokens that `spender` will be
* allowed to spend on behalf of `owner` through {transferFrom}. This is
* zero by default.
*
* This value changes when {approve} or {transferFrom} are called.
*/
function allowance(address owner, address spender) external view returns (uint256);
/**
* @dev Sets `amount` as the allowance of `spender` over the caller's tokens.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* IMPORTANT: Beware that changing an allowance with this method brings the risk
* that someone may use both the old and the new allowance by unfortunate
* transaction ordering. One possible solution to mitigate this race
* condition is to first reduce the spender's allowance to 0 and set the
* desired value afterwards:
* https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
*
* Emits an {Approval} event.
*/
function approve(address spender, uint256 amount) external returns (bool);
/**
* @dev Moves `amount` tokens from `from` to `to` using the
* allowance mechanism. `amount` is then deducted from the caller's
* allowance.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transferFrom(address from, address to, uint256 amount) external returns (bool);
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (utils/math/SafeMath.sol)
pragma solidity ^0.8.0;
// CAUTION
// This version of SafeMath should only be used with Solidity 0.8 or later,
// because it relies on the compiler's built in overflow checks.
/**
* @dev Wrappers over Solidity's arithmetic operations.
*
* NOTE: `SafeMath` is generally not needed starting with Solidity 0.8, since the compiler
* now has built in overflow checking.
*/
library SafeMath {
/**
* @dev Returns the addition of two unsigned integers, with an overflow flag.
*
* _Available since v3.4._
*/
function tryAdd(uint256 a, uint256 b) internal pure returns (bool, uint256) {
unchecked {
uint256 c = a + b;
if (c < a) return (false, 0);
return (true, c);
}
}
/**
* @dev Returns the subtraction of two unsigned integers, with an overflow flag.
*
* _Available since v3.4._
*/
function trySub(uint256 a, uint256 b) internal pure returns (bool, uint256) {
unchecked {
if (b > a) return (false, 0);
return (true, a - b);
}
}
/**
* @dev Returns the multiplication of two unsigned integers, with an overflow flag.
*
* _Available since v3.4._
*/
function tryMul(uint256 a, uint256 b) internal pure returns (bool, uint256) {
unchecked {
// Gas optimization: this is cheaper than requiring 'a' not being zero, but the
// benefit is lost if 'b' is also tested.
// See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522
if (a == 0) return (true, 0);
uint256 c = a * b;
if (c / a != b) return (false, 0);
return (true, c);
}
}
/**
* @dev Returns the division of two unsigned integers, with a division by zero flag.
*
* _Available since v3.4._
*/
function tryDiv(uint256 a, uint256 b) internal pure returns (bool, uint256) {
unchecked {
if (b == 0) return (false, 0);
return (true, a / b);
}
}
/**
* @dev Returns the remainder of dividing two unsigned integers, with a division by zero flag.
*
* _Available since v3.4._
*/
function tryMod(uint256 a, uint256 b) internal pure returns (bool, uint256) {
unchecked {
if (b == 0) return (false, 0);
return (true, a % b);
}
}
/**
* @dev Returns the addition of two unsigned integers, reverting on
* overflow.
*
* Counterpart to Solidity's `+` operator.
*
* Requirements:
*
* - Addition cannot overflow.
*/
function add(uint256 a, uint256 b) internal pure returns (uint256) {
return a + b;
}
/**
* @dev Returns the subtraction of two unsigned integers, reverting on
* overflow (when the result is negative).
*
* Counterpart to Solidity's `-` operator.
*
* Requirements:
*
* - Subtraction cannot overflow.
*/
function sub(uint256 a, uint256 b) internal pure returns (uint256) {
return a - b;
}
/**
* @dev Returns the multiplication of two unsigned integers, reverting on
* overflow.
*
* Counterpart to Solidity's `*` operator.
*
* Requirements:
*
* - Multiplication cannot overflow.
*/
function mul(uint256 a, uint256 b) internal pure returns (uint256) {
return a * b;
}
/**
* @dev Returns the integer division of two unsigned integers, reverting on
* division by zero. The result is rounded towards zero.
*
* Counterpart to Solidity's `/` operator.
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function div(uint256 a, uint256 b) internal pure returns (uint256) {
return a / b;
}
/**
* @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
* reverting when dividing by zero.
*
* Counterpart to Solidity's `%` operator. This function uses a `revert`
* opcode (which leaves remaining gas untouched) while Solidity uses an
* invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function mod(uint256 a, uint256 b) internal pure returns (uint256) {
return a % b;
}
/**
* @dev Returns the subtraction of two unsigned integers, reverting with custom message on
* overflow (when the result is negative).
*
* CAUTION: This function is deprecated because it requires allocating memory for the error
* message unnecessarily. For custom revert reasons use {trySub}.
*
* Counterpart to Solidity's `-` operator.
*
* Requirements:
*
* - Subtraction cannot overflow.
*/
function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
unchecked {
require(b <= a, errorMessage);
return a - b;
}
}
/**
* @dev Returns the integer division of two unsigned integers, reverting with custom message on
* division by zero. The result is rounded towards zero.
*
* Counterpart to Solidity's `/` operator. Note: this function uses a
* `revert` opcode (which leaves remaining gas untouched) while Solidity
* uses an invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
unchecked {
require(b > 0, errorMessage);
return a / b;
}
}
/**
* @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
* reverting with custom message when dividing by zero.
*
* CAUTION: This function is deprecated because it requires allocating memory for the error
* message unnecessarily. For custom revert reasons use {tryMod}.
*
* Counterpart to Solidity's `%` operator. This function uses a `revert`
* opcode (which leaves remaining gas untouched) while Solidity uses an
* invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
unchecked {
require(b > 0, errorMessage);
return a % b;
}
}
}// SPDX-License-Identifier: SYMM-Core-Business-Source-License-1.1
// This contract is licensed under the SYMM Core Business Source License 1.1
// Copyright (c) 2023 Symmetry Labs AG
// For more information, see https://docs.symm.io/legal-disclaimer/license
pragma solidity >=0.8.18;
interface IAccountEvents {
event Deposit(address sender, address user, uint256 amount);
event Withdraw(address sender, address user, uint256 amount);
event AllocatePartyA(address user, uint256 amount, uint256 newAllocatedBalance);
event AllocatePartyA(address user, uint256 amount); // For backward compatibility, will be removed in future
event DeallocatePartyA(address user, uint256 amount, uint256 newAllocatedBalance);
event DeallocatePartyA(address user, uint256 amount); // For backward compatibility, will be removed in future
event InternalTransfer(address sender, address user, uint256 userNewAllocatedBalance, uint256 amount);
event AllocateForPartyB(address partyB, address partyA, uint256 amount, uint256 newAllocatedBalance);
event AllocateForPartyB(address partyB, address partyA, uint256 amount); // For backward compatibility, will be removed in future
event DeallocateForPartyB(address partyB, address partyA, uint256 amount, uint256 newAllocatedBalance);
event DeallocateForPartyB(address partyB, address partyA, uint256 amount); // For backward compatibility, will be removed in future
event TransferAllocation(
uint256 amount,
address origin,
uint256 originNewAllocatedBalance,
address recipient,
uint256 recipientNewAllocatedBalance
);
event TransferAllocation(uint256 amount, address origin, address recipient); // For backward compatibility, will be removed in future
event DepositToReserveVault(address sender, address partyB, uint256 amount);
event WithdrawFromReserveVault(address partyB, uint256 amount);
}// SPDX-License-Identifier: SYMM-Core-Business-Source-License-1.1
// This contract is licensed under the SYMM Core Business Source License 1.1
// Copyright (c) 2023 Symmetry Labs AG
// For more information, see https://docs.symm.io/legal-disclaimer/license
pragma solidity >=0.8.18;
import "./IAccountEvents.sol";
import "../../storages/MuonStorage.sol";
interface IAccountFacet is IAccountEvents {
//Party A
function deposit(uint256 amount) external;
function depositFor(address user, uint256 amount) external;
function withdraw(uint256 amount) external;
function withdrawTo(address user, uint256 amount) external;
function allocate(uint256 amount) external;
function depositAndAllocate(uint256 amount) external;
function deallocate(uint256 amount, SingleUpnlSig memory upnlSig) external;
function internalTransfer(address user, uint256 amount) external;
// PartyB
function allocateForPartyB(uint256 amount, address partyA) external;
function deallocateForPartyB(uint256 amount, address partyA, SingleUpnlSig memory upnlSig) external;
function transferAllocation(uint256 amount, address origin, address recipient, SingleUpnlSig memory upnlSig) external;
function depositToReserveVault(uint256 amount, address partyB) external;
function withdrawFromReserveVault(uint256 amount) external;
}// SPDX-License-Identifier: SYMM-Core-Business-Source-License-1.1
// This contract is licensed under the SYMM Core Business Source License 1.1
// Copyright (c) 2023 Symmetry Labs AG
// For more information, see https://docs.symm.io/legal-disclaimer/license
pragma solidity >=0.8.18;
interface IBridgeEvents {
event TransferToBridge(address user, uint256 amount, address bridgeAddress, uint256 transactionId);
event WithdrawReceivedBridgeValue(uint256 transactionId);
event SuspendBridgeTransaction(uint256 transactionId);
event RestoreBridgeTransaction(uint256 transactionId, uint256 validAmount);
event WithdrawReceivedBridgeValues(uint256[] transactionIds);
}// SPDX-License-Identifier: SYMM-Core-Business-Source-License-1.1
// This contract is licensed under the SYMM Core Business Source License 1.1
// Copyright (c) 2023 Symmetry Labs AG
// For more information, see https://docs.symm.io/legal-disclaimer/license
pragma solidity >=0.8.18;
import "./IBridgeEvents.sol";
interface IBridgeFacet is IBridgeEvents {
function transferToBridge(uint256 amount, address bridgeAddress) external;
function suspendBridgeTransaction(uint256 transactionId) external;
function restoreBridgeTransaction(uint256 transactionId, uint256 validAmount) external;
function withdrawReceivedBridgeValue(uint256 transactionId) external;
function withdrawReceivedBridgeValues(uint256[] memory transactionIds) external;
}// SPDX-License-Identifier: SYMM-Core-Business-Source-License-1.1
// This contract is licensed under the SYMM Core Business Source License 1.1
// Copyright (c) 2023 Symmetry Labs AG
// For more information, see https://docs.symm.io/legal-disclaimer/license
pragma solidity >=0.8.18;
interface IControlEvents {
event RoleGranted(bytes32 role, address user);
event RoleRevoked(bytes32 role, address user);
event SetMuonConfig(uint256 upnlValidTime, uint256 priceValidTime);
event SetMuonIds(uint256 muonAppId, address gateway, uint256 x, uint8 parity);
event SetCollateral(address collateral);
event AddSymbol(
uint256 symbolId,
string name,
uint256 minAcceptableQuoteValue,
uint256 minAcceptablePortionLF,
uint256 tradingFee,
uint256 maxLeverage,
uint256 fundingRateEpochDuration,
uint256 fundingRateWindowTime
);
event SetFeeCollector(address affiliate, address oldFeeCollector, address newFeeCollector);
event SetDefaultFeeCollector(address oldDefaultFeeCollector, address newDefaultFeeCollector);
event SetSymbolValidationState(uint256 symbolId, bool oldState, bool isValid);
event SetSymbolFundingState(uint256 symbolId, uint256 fundingRateEpochDuration, uint256 fundingRateWindowTime);
event SetSymbolAcceptableValues(
uint256 symbolId,
uint256 oldMinAcceptableQuoteValue,
uint256 oldMinAcceptablePortionLF,
uint256 minAcceptableQuoteValue,
uint256 minAcceptablePortionLF
);
event SetSymbolTradingFee(uint256 symbolId, uint256 oldTradingFee, uint256 tradingFee);
event SetSymbolMaxSlippage(uint256 symbolId, uint256 oldMaxSlippage, uint256 maxSlippage);
event SetSymbolMaxLeverage(uint256 symbolId, uint256 oldMaxLeverage, uint256 maxLeverage);
event SetDeallocateCooldown(uint256 oldDeallocateCooldown, uint256 newDeallocateCooldown);
event SetForceCancelCooldown(uint256 oldForceCancelCooldown, uint256 newForceCancelCooldown);
event SetForceCloseCooldowns(
uint256 oldForceCloseFirstCooldown,
uint256 newForceCloseFirstCooldown,
uint256 oldForceCloseSecondCooldown,
uint256 newForceCloseSecondCooldown
);
event SetForceClosePricePenalty(uint256 oldPricePenalty, uint256 newPricePenalty);
event SetForceCloseMinSigPeriod(uint256 oldCloseMinSigPeriod, uint256 newCloseMinSigPeriod);
event SetForceCancelCloseCooldown(uint256 oldForceCancelCloseCooldown, uint256 newForceCancelCloseCooldown);
event SetSettlementCooldown(uint256 oldSettlementCooldown, uint256 newSettlementCooldown);
event SetLiquidatorShare(uint256 oldLiquidatorShare, uint256 newLiquidatorShare);
event SetForceCloseGapRatio(uint256 symbolId, uint256 oldForceCloseGapRatio, uint256 newForceCloseGapRatio);
event SetPendingQuotesValidLength(uint256 oldPendingQuotesValidLength, uint256 newPendingQuotesValidLength);
event SetDeallocateDebounceTime(uint256 oldDeallocateDebounceTime, uint256 newDeallocateDebounceTime);
event SetInvalidBridgedAmountsPool(address oldInvalidBridgedAmountsPool, address newInvalidBridgedAmountsPool);
event PauseGlobal();
event PauseLiquidation();
event PauseAccounting();
event PausePartyAActions();
event PausePartyBActions();
event PauseInternalTransfer();
event ActiveEmergencyMode();
event UnpauseGlobal();
event UnpauseLiquidation();
event UnpauseAccounting();
event UnpausePartyAActions();
event UnpausePartyBActions();
event UnpauseInternalTransfer();
event DeactiveEmergencyMode();
event SetLiquidationTimeout(uint256 oldLiquidationTimeout, uint256 newLiquidationTimeout);
event SetSuspendedAddress(address user, bool isSuspended);
event SetPartyBEmergencyStatus(address partyB, bool status);
event SetBalanceLimitPerUser(uint256 balanceLimitPerUser);
event RegisterPartyB(address partyB);
event DeregisterPartyB(address partyB, uint256 index);
event RegisterAffiliate(address affilate);
event DeregisterAffiliate(address affilate);
event AddBridge(address bridge);
event RemoveBridge(address bridge);
}// SPDX-License-Identifier: SYMM-Core-Business-Source-License-1.1
// This contract is licensed under the SYMM Core Business Source License 1.1
// Copyright (c) 2023 Symmetry Labs AG
// For more information, see https://docs.symm.io/legal-disclaimer/license
pragma solidity >=0.8.18;
import "./IControlEvents.sol";
import "../../storages/SymbolStorage.sol";
import "../../storages/MuonStorage.sol";
interface IControlFacet is IControlEvents {
function transferOwnership(address owner) external;
function setAdmin(address user) external;
function grantRole(address user, bytes32 role) external;
function revokeRole(address user, bytes32 role) external;
function registerPartyB(address partyB) external;
function deregisterPartyB(address partyB, uint256 index) external;
function registerAffiliate(address affiliate) external;
function deregisterAffiliate(address affiliate) external;
function setMuonConfig(uint256 upnlValidTime, uint256 priceValidTime) external;
function setMuonIds(uint256 muonAppId, address validGateway, PublicKey memory publicKey) external;
function setCollateral(address collateral) external;
// Symbol State
function addSymbol(
string memory name,
uint256 minAcceptableQuoteValue,
uint256 minAcceptablePortionLF,
uint256 tradingFee,
uint256 maxLeverage,
uint256 fundingRateEpochDuration,
uint256 fundingRateWindowTime
) external;
function addSymbols(Symbol[] memory symbols) external;
function setSymbolFundingState(uint256 symbolId, uint256 fundingRateEpochDuration, uint256 fundingRateWindowTime) external;
function setSymbolValidationState(uint256 symbolId, bool isValid) external;
function setSymbolMaxLeverage(uint256 symbolId, uint256 maxLeverage) external;
function setSymbolAcceptableValues(uint256 symbolId, uint256 minAcceptableQuoteValue, uint256 minAcceptablePortionLF) external;
function setSymbolTradingFee(uint256 symbolId, uint256 tradingFee) external;
/////////////////////////////////////
// CoolDowns
function setDeallocateCooldown(uint256 deallocateCooldown) external;
function setForceCancelCooldown(uint256 forceCancelCooldown) external;
function setForceCloseCooldowns(uint256 forceCloseFirstCooldown, uint256 forceCloseSecondCooldown) external;
function setForceClosePricePenalty(uint256 forceClosePricePenalty) external;
function setForceCloseMinSigPeriod(uint256 forceCloseMinSigPeriod) external;
function setForceCancelCloseCooldown(uint256 forceCancelCloseCooldown) external;
function setLiquidatorShare(uint256 liquidatorShare) external;
function setForceCloseGapRatio(uint256 symbolId, uint256 forceCloseGapRatio) external;
function setPendingQuotesValidLength(uint256 pendingQuotesValidLength) external;
function setDeallocateDebounceTime(uint256 deallocateDebounceTime) external;
function setInvalidBridgedAmountsPool(address pool) external;
function setSettlementCooldown(uint256 settlementCooldown) external;
// Pause State
function setFeeCollector(address affiliate, address feeCollector) external;
function pauseGlobal() external;
function pauseLiquidation() external;
function pauseAccounting() external;
function pausePartyAActions() external;
function pausePartyBActions() external;
function activeEmergencyMode() external;
function unpauseGlobal() external;
function unpauseLiquidation() external;
function unpauseAccounting() external;
function unpausePartyAActions() external;
function unpausePartyBActions() external;
function setLiquidationTimeout(uint256 liquidationTimeout) external;
function suspendedAddress(address user) external;
function unsuspendedAddress(address user) external;
function deactiveEmergencyMode() external;
function setBalanceLimitPerUser(uint256 balanceLimitPerUser) external;
function setPartyBEmergencyStatus(address[] memory partyBs, bool status) external;
function addBridge(address bridge) external;
function removeBridge(address bridge) external;
}// SPDX-License-Identifier: GPL-3.0-or-later pragma solidity >=0.8.18; /******************************************************************************\ * Author: Nick Mudge <[email protected]> (https://twitter.com/mudgen) * EIP-2535 Diamonds: https://eips.ethereum.org/EIPS/eip-2535 /******************************************************************************/ interface IDiamondCut { // Add=0, Replace=1, Remove=2 enum FacetCutAction { Add, Replace, Remove } struct FacetCut { address facetAddress; FacetCutAction action; bytes4[] functionSelectors; } /// @notice Add/replace/remove any number of functions and optionally execute /// a function with delegatecall /// @param _diamondCut Contains the facet addresses and function selectors /// @param _init The address of the contract or facet to execute _calldata /// @param _calldata A function call, including function selector and arguments /// _calldata is executed with delegatecall on _init function diamondCut(FacetCut[] calldata _diamondCut, address _init, bytes calldata _calldata) external; event DiamondCut(FacetCut[] _diamondCut, address _init, bytes _calldata); }
// SPDX-License-Identifier: GPL-3.0-or-later pragma solidity >=0.8.18; /******************************************************************************\ * Author: Nick Mudge <[email protected]> (https://twitter.com/mudgen) * EIP-2535 Diamonds: https://eips.ethereum.org/EIPS/eip-2535 /******************************************************************************/ // A loupe is a small magnifying glass used to look at diamonds. // These functions look at diamonds interface IDiamondLoupe { struct Facet { address facetAddress; bytes4[] functionSelectors; } /// @notice Gets all facet addresses and their four byte function selectors. /// @return facets_ Facet function facets() external view returns (Facet[] memory facets_); /// @notice Gets all the function selectors supported by a specific facet. /// @param _facet The facet address. /// @return facetFunctionSelectors_ function facetFunctionSelectors(address _facet) external view returns (bytes4[] memory facetFunctionSelectors_); /// @notice Get all the facet addresses used by a diamond. /// @return facetAddresses_ function facetAddresses() external view returns (address[] memory facetAddresses_); /// @notice Gets the facet that supports the given selector. /// @dev If facet is not found return address(0). /// @param _functionSelector The function selector. /// @return facetAddress_ The facet address. function facetAddress(bytes4 _functionSelector) external view returns (address facetAddress_); }
// SPDX-License-Identifier: SYMM-Core-Business-Source-License-1.1
// This contract is licensed under the SYMM Core Business Source License 1.1
// Copyright (c) 2023 Symmetry Labs AG
// For more information, see https://docs.symm.io/legal-disclaimer/license
pragma solidity >=0.8.18;
import "../../storages/QuoteStorage.sol";
interface ForceActionsFacetEvents {
event ForceCancelQuote(uint256 quoteId, QuoteStatus quoteStatus);
event ForceCancelCloseRequest(uint256 quoteId, QuoteStatus quoteStatus, uint256 closeId);
event ForceCancelCloseRequest(uint256 quoteId, QuoteStatus quoteStatus); // For backward compatibility, will be removed in future
event ForceClosePosition(
uint256 quoteId,
address partyA,
address partyB,
uint256 filledAmount,
uint256 closedPrice,
QuoteStatus quoteStatus,
uint256 closeId
);
event ForceClosePosition(uint256 quoteId, address partyA, address partyB, uint256 filledAmount, uint256 closedPrice, QuoteStatus quoteStatus); // For backward compatibility, will be removed in future
}// SPDX-License-Identifier: SYMM-Core-Business-Source-License-1.1
// This contract is licensed under the SYMM Core Business Source License 1.1
// Copyright (c) 2023 Symmetry Labs AG
// For more information, see https://docs.symm.io/legal-disclaimer/license
pragma solidity >=0.8.18;
import "../../storages/MuonStorage.sol";
import "./ForceActionsFacetEvents.sol";
interface IForceActionsFacet is ForceActionsFacetEvents {
function forceCancelQuote(uint256 quoteId) external;
function forceCancelCloseRequest(uint256 quoteId) external;
function forceClosePosition(uint256 quoteId, HighLowPriceSig memory sig) external;
function settleAndForceClosePosition(
uint256 quoteId,
HighLowPriceSig memory highLowPriceSig,
SettlementSig memory settleSig,
uint256[] memory updatedPrices
) external;
}// SPDX-License-Identifier: SYMM-Core-Business-Source-License-1.1
// This contract is licensed under the SYMM Core Business Source License 1.1
// Copyright (c) 2023 Symmetry Labs AG
// For more information, see https://docs.symm.io/legal-disclaimer/license
pragma solidity >=0.8.18;
interface IFundingRateEvents {
event ChargeFundingRate(address partyB, address partyA, uint256[] quoteIds, int256[] rates);
}// SPDX-License-Identifier: SYMM-Core-Business-Source-License-1.1
// This contract is licensed under the SYMM Core Business Source License 1.1
// Copyright (c) 2023 Symmetry Labs AG
// For more information, see https://docs.symm.io/legal-disclaimer/license
pragma solidity >=0.8.18;
import "./IFundingRateEvents.sol";
import "../../storages/MuonStorage.sol";
interface IFundingRateFacet is IFundingRateEvents {
function chargeFundingRate(address partyA, uint256[] memory quoteIds, int256[] memory rates, PairUpnlSig memory upnlSig) external;
}// SPDX-License-Identifier: SYMM-Core-Business-Source-License-1.1
// This contract is licensed under the SYMM Core Business Source License 1.1
// Copyright (c) 2023 Symmetry Labs AG
// For more information, see https://docs.symm.io/legal-disclaimer/license
pragma solidity >=0.8.18;
import "../../interfaces/IPartiesEvents.sol";
interface ILiquidationEvents is IPartiesEvents {
event LiquidatePartyA(address liquidator, address partyA, uint256 allocatedBalance, int256 upnl, int256 totalUnrealizedLoss, bytes liquidationId);
event LiquidatePartyA(address liquidator, address partyA, uint256 allocatedBalance, int256 upnl, int256 totalUnrealizedLoss); // For backward compatibility, will be removed in future
event DeferredLiquidatePartyA(
address liquidator,
address partyA,
uint256 allocatedBalance,
int256 upnl,
int256 totalUnrealizedLoss,
bytes liquidationId,
uint256 liquidationBlockNumber,
uint256 liquidationTimestamp,
uint256 liquidationAllocatedBalance
);
event LiquidatePositionsPartyA(
address liquidator,
address partyA,
uint256[] quoteIds,
uint256[] liquidatedAmounts,
uint256[] closeIds,
bytes liquidationId
);
event LiquidatePositionsPartyA(address liquidator, address partyA, uint256[] quoteIds); // For backward compatibility, will be removed in future
event LiquidatePendingPositionsPartyA(address liquidator, address partyA, uint256[] quoteIds, uint256[] liquidatedAmounts, bytes liquidationId);
event LiquidatePendingPositionsPartyA(address liquidator, address partyA); // For backward compatibility, will be removed in future
event SettlePartyALiquidation(address partyA, address[] partyBs, int256[] amounts, bytes liquidationId);
event SettlePartyALiquidation(address partyA, address[] partyBs, int256[] amounts); // For backward compatibility, will be removed in future
event LiquidationDisputed(address partyA, bytes liquidationId);
event LiquidationDisputed(address partyA); // For backward compatibility, will be removed in future
event ResolveLiquidationDispute(address partyA, address[] partyBs, int256[] amounts, bool disputed, bytes liquidationId);
event ResolveLiquidationDispute(address partyA, address[] partyBs, int256[] amounts, bool disputed); // For backward compatibility, will be removed in future
event FullyLiquidatedPartyA(address partyA, bytes liquidationId);
event FullyLiquidatedPartyA(address partyA); // For backward compatibility, will be removed in future
event LiquidatePositionsPartyB(
address liquidator,
address partyB,
address partyA,
uint256[] quoteIds,
uint256[] liquidatedAmounts,
uint256[] closeIds
);
event LiquidatePositionsPartyB(address liquidator, address partyB, address partyA, uint256[] quoteIds); // For backward compatibility, will be removed in future
event FullyLiquidatedPartyB(address partyB, address partyA);
event SetSymbolsPrices(address liquidator, address partyA, uint256[] symbolIds, uint256[] prices, bytes liquidationId);
event SetSymbolsPrices(address liquidator, address partyA, uint256[] symbolIds, uint256[] prices); // For backward compatibility, will be removed in future
event DisputeForLiquidation(address liquidator, address partyA, bytes liquidationId);
}// SPDX-License-Identifier: SYMM-Core-Business-Source-License-1.1
// This contract is licensed under the SYMM Core Business Source License 1.1
// Copyright (c) 2023 Symmetry Labs AG
// For more information, see https://docs.symm.io/legal-disclaimer/license
pragma solidity >=0.8.18;
import "./ILiquidationEvents.sol";
import "../../storages/AccountStorage.sol";
import "../../storages/MuonStorage.sol";
interface ILiquidationFacet is ILiquidationEvents {
function liquidatePartyA(address partyA, LiquidationSig memory liquidationSig) external;
function setSymbolsPrice(address partyA, LiquidationSig memory liquidationSig) external;
function deferredLiquidatePartyA(address partyA, DeferredLiquidationSig memory liquidationSig) external;
function deferredSetSymbolsPrice(address partyA, DeferredLiquidationSig memory liquidationSig) external;
function liquidatePendingPositionsPartyA(address partyA) external;
function liquidatePositionsPartyA(address partyA, uint256[] memory quoteIds) external;
function settlePartyALiquidation(address partyA, address[] memory partyBs) external;
function resolveLiquidationDispute(address partyA, address[] memory partyBs, int256[] memory amounts, bool disputed) external;
function liquidatePartyB(address partyB, address partyA, SingleUpnlSig memory upnlSig) external;
function liquidatePositionsPartyB(address partyB, address partyA, QuotePriceSig memory priceSig) external;
}// SPDX-License-Identifier: SYMM-Core-Business-Source-License-1.1
// This contract is licensed under the SYMM Core Business Source License 1.1
// Copyright (c) 2023 Symmetry Labs AG
// For more information, see https://docs.symm.io/legal-disclaimer/license
pragma solidity >=0.8.18;
import "../../storages/QuoteStorage.sol";
import "../../interfaces/IPartiesEvents.sol";
interface IPartyAEvents is IPartiesEvents {
event RequestToCancelQuote(address partyA, address partyB, QuoteStatus quoteStatus, uint256 quoteId);
event RequestToClosePosition(
address partyA,
address partyB,
uint256 quoteId,
uint256 closePrice,
uint256 quantityToClose,
OrderType orderType,
uint256 deadline,
QuoteStatus quoteStatus,
uint256 closeId
);
event RequestToClosePosition(
address partyA,
address partyB,
uint256 quoteId,
uint256 closePrice,
uint256 quantityToClose,
OrderType orderType,
uint256 deadline,
QuoteStatus quoteStatus
); // For backward compatibility, will be removed in future
event RequestToCancelCloseRequest(address partyA, address partyB, uint256 quoteId, QuoteStatus quoteStatus, uint256 closeId);
event RequestToCancelCloseRequest(address partyA, address partyB, uint256 quoteId, QuoteStatus quoteStatus); // For backward compatibility, will be removed in future
}// SPDX-License-Identifier: SYMM-Core-Business-Source-License-1.1
// This contract is licensed under the SYMM Core Business Source License 1.1
// Copyright (c) 2023 Symmetry Labs AG
// For more information, see https://docs.symm.io/legal-disclaimer/license
pragma solidity >=0.8.18;
import "./IPartyAEvents.sol";
import "../../storages/MuonStorage.sol";
interface IPartyAFacet is IPartyAEvents {
function sendQuote(
address[] memory partyBsWhiteList,
uint256 symbolId,
PositionType positionType,
OrderType orderType,
uint256 price,
uint256 quantity,
uint256 cva,
uint256 lf,
uint256 partyAmm,
uint256 partyBmm,
uint256 maxFundingRate,
uint256 deadline,
SingleUpnlAndPriceSig memory upnlSig
) external;
function sendQuoteWithAffiliate(
address[] memory partyBsWhiteList,
uint256 symbolId,
PositionType positionType,
OrderType orderType,
uint256 price,
uint256 quantity,
uint256 cva,
uint256 lf,
uint256 partyAmm,
uint256 partyBmm,
uint256 maxFundingRate,
uint256 deadline,
address affiliate,
SingleUpnlAndPriceSig memory upnlSig
) external returns (uint256);
function expireQuote(uint256[] memory expiredQuoteIds) external;
function requestToCancelQuote(uint256 quoteId) external;
function requestToClosePosition(uint256 quoteId, uint256 closePrice, uint256 quantityToClose, OrderType orderType, uint256 deadline) external;
function requestToCancelCloseRequest(uint256 quoteId) external;
}// SPDX-License-Identifier: SYMM-Core-Business-Source-License-1.1
// This contract is licensed under the SYMM Core Business Source License 1.1
// Copyright (c) 2023 Symmetry Labs AG
// For more information, see https://docs.symm.io/legal-disclaimer/license
pragma solidity >=0.8.18;
import "../PartyBPositionActions/IPartyBPositionActionsEvents.sol";
import "../PartyBQuoteActions/IPartyBQuoteActionsEvents.sol";
interface IPartyBGroupActionsEvents is IPartyBPositionActionsEvents, IPartyBQuoteActionsEvents {}// SPDX-License-Identifier: SYMM-Core-Business-Source-License-1.1
// This contract is licensed under the SYMM Core Business Source License 1.1
// Copyright (c) 2023 Symmetry Labs AG
// For more information, see https://docs.symm.io/legal-disclaimer/license
pragma solidity >=0.8.18;
import "./IPartyBGroupActionsEvents.sol";
import "../../storages/MuonStorage.sol";
interface IPartyBGroupActionsFacet is IPartyBGroupActionsEvents {
function lockAndOpenQuote(
uint256 quoteId,
uint256 filledAmount,
uint256 openedPrice,
SingleUpnlSig memory upnlSig,
PairUpnlAndPriceSig memory pairUpnlSig
) external;
}// SPDX-License-Identifier: SYMM-Core-Business-Source-License-1.1
// This contract is licensed under the SYMM Core Business Source License 1.1
// Copyright (c) 2023 Symmetry Labs AG
// For more information, see https://docs.symm.io/legal-disclaimer/license
pragma solidity >=0.8.18;
import "../../interfaces/IPartiesEvents.sol";
interface IPartyBPositionActionsEvents is IPartiesEvents {
event AcceptCancelCloseRequest(uint256 quoteId, QuoteStatus quoteStatus, uint256 closeId);
event AcceptCancelCloseRequest(uint256 quoteId, QuoteStatus quoteStatus); // For backward compatibility, will be removed in future
event EmergencyClosePosition(
uint256 quoteId,
address partyA,
address partyB,
uint256 filledAmount,
uint256 closedPrice,
QuoteStatus quoteStatus,
uint256 closeId
);
event EmergencyClosePosition(uint256 quoteId, address partyA, address partyB, uint256 filledAmount, uint256 closedPrice, QuoteStatus quoteStatus); // For backward compatibility, will be removed in future
}// SPDX-License-Identifier: SYMM-Core-Business-Source-License-1.1
// This contract is licensed under the SYMM Core Business Source License 1.1
// Copyright (c) 2023 Symmetry Labs AG
// For more information, see https://docs.symm.io/legal-disclaimer/license
pragma solidity >=0.8.18;
import "./IPartyBPositionActionsEvents.sol";
interface IPartyBPositionActionsFacet is IPartyBPositionActionsEvents {
function openPosition(uint256 quoteId, uint256 filledAmount, uint256 openedPrice, PairUpnlAndPriceSig memory upnlSig) external;
function fillCloseRequest(uint256 quoteId, uint256 filledAmount, uint256 closedPrice, PairUpnlAndPriceSig memory upnlSig) external;
function acceptCancelCloseRequest(uint256 quoteId) external;
function emergencyClosePosition(uint256 quoteId, PairUpnlAndPriceSig memory upnlSig) external;
}// SPDX-License-Identifier: SYMM-Core-Business-Source-License-1.1
// This contract is licensed under the SYMM Core Business Source License 1.1
// Copyright (c) 2023 Symmetry Labs AG
// For more information, see https://docs.symm.io/legal-disclaimer/license
pragma solidity >=0.8.18;
import "../../interfaces/IPartiesEvents.sol";
interface IPartyBQuoteActionsEvents is IPartiesEvents {
event LockQuote(address partyB, uint256 quoteId);
event AllocatePartyB(address partyB, address partyA, uint256 amount);
event UnlockQuote(address partyB, uint256 quoteId, QuoteStatus quoteStatus);
}// SPDX-License-Identifier: SYMM-Core-Business-Source-License-1.1
// This contract is licensed under the SYMM Core Business Source License 1.1
// Copyright (c) 2023 Symmetry Labs AG
// For more information, see https://docs.symm.io/legal-disclaimer/license
pragma solidity >=0.8.18;
import "./IPartyBQuoteActionsEvents.sol";
import "../../storages/MuonStorage.sol";
interface IPartyBQuoteActionsFacet is IPartyBQuoteActionsEvents {
function lockQuote(uint256 quoteId, SingleUpnlSig memory upnlSig) external;
function unlockQuote(uint256 quoteId) external;
function acceptCancelRequest(uint256 quoteId) external;
}// SPDX-License-Identifier: SYMM-Core-Business-Source-License-1.1
// This contract is licensed under the SYMM Core Business Source License 1.1
// Copyright (c) 2023 Symmetry Labs AG
// For more information, see https://docs.symm.io/legal-disclaimer/license
pragma solidity >=0.8.18;
import "../../storages/MuonStorage.sol";
import "./SettlementFacetEvents.sol";
interface ISettlementFacet is SettlementFacetEvents {
function settleUpnl(SettlementSig memory settleSig, uint256[] memory updatedPrices, address partyA) external;
}// SPDX-License-Identifier: SYMM-Core-Business-Source-License-1.1
// This contract is licensed under the SYMM Core Business Source License 1.1
// Copyright (c) 2023 Symmetry Labs AG
// For more information, see https://docs.symm.io/legal-disclaimer/license
pragma solidity >=0.8.18;
import "../../storages/MuonStorage.sol";
interface SettlementFacetEvents {
event SettleUpnl(
QuoteSettlementData[] settlementData,
uint256[] updatedPrices,
address partyA,
uint256 newPartyAAllocatedBalance,
uint256[] newPartyBsAllocatedBalances
);
}// SPDX-License-Identifier: SYMM-Core-Business-Source-License-1.1
// This contract is licensed under the SYMM Core Business Source License 1.1
// Copyright (c) 2023 Symmetry Labs AG
// For more information, see https://docs.symm.io/legal-disclaimer/license
pragma solidity >=0.8.18;
import "../../storages/AccountStorage.sol";
import "../../storages/SymbolStorage.sol";
import "../../storages/MuonStorage.sol";
import "../../storages/BridgeStorage.sol";
interface IViewFacet {
struct Bitmap {
uint256 size;
BitmapElement[] elements;
}
struct BitmapElement {
uint256 offset;
uint256 bitmap;
}
// Account
function balanceOf(address user) external view returns (uint256);
function partyAStats(
address partyA
)
external
view
returns (bool, uint256, uint256, uint256, uint256, uint256, uint256, uint256, uint256, uint256, uint256, uint256, uint256, uint256);
function balanceInfoOfPartyA(
address partyA
) external view returns (uint256, uint256, uint256, uint256, uint256, uint256, uint256, uint256, uint256);
function balanceInfoOfPartyB(
address partyB,
address partyA
) external view returns (uint256, uint256, uint256, uint256, uint256, uint256, uint256, uint256, uint256);
function allocatedBalanceOfPartyA(address partyA) external view returns (uint256);
function allocatedBalanceOfPartyB(address partyB, address partyA) external view returns (uint256);
function balanceOfReserveVault(address partyB) external view returns (uint256);
function allocatedBalanceOfPartyBs(address partyA, address[] memory partyBs) external view returns (uint256[] memory);
function withdrawCooldownOf(address user) external view returns (uint256);
function nonceOfPartyA(address partyA) external view returns (uint256);
function nonceOfPartyB(address partyB, address partyA) external view returns (uint256);
function isSuspended(address user) external view returns (bool);
function getLiquidatedStateOfPartyA(address partyA) external view returns (LiquidationDetail memory);
function getDeallocateDebounceTime() external view returns (uint256);
function getInvalidBridgedAmountsPool() external view returns (address);
function getSettlementStates(address partyA, address[] memory partyBs) external view returns (SettlementState[] memory);
///////////////////////////////////////////
// Symbols
function getSymbol(uint256 symbolId) external view returns (Symbol memory);
function getSymbols(uint256 start, uint256 size) external view returns (Symbol[] memory);
function symbolsByQuoteId(uint256[] memory quoteIds) external view returns (Symbol[] memory);
function symbolNameByQuoteId(uint256[] memory quoteIds) external view returns (string[] memory);
function symbolNameById(uint256[] memory symbolIds) external view returns (string[] memory);
////////////////////////////////////
// Quotes
function getQuote(uint256 quoteId) external view returns (Quote memory);
function getQuotesByParent(uint256 quoteId, uint256 size) external view returns (Quote[] memory);
function quoteIdsOf(address partyA, uint256 start, uint256 size) external view returns (uint256[] memory);
function getQuotes(address partyA, uint256 start, uint256 size) external view returns (Quote[] memory);
function quotesLength(address user) external view returns (uint256);
function partyAPositionsCount(address partyA) external view returns (uint256);
function getBridgeTransactions(address bridge, uint256 start, uint256 size) external view returns (BridgeTransaction[] memory);
function getPartyAOpenPositions(address partyA, uint256 start, uint256 size) external view returns (Quote[] memory);
function getPartyBOpenPositions(address partyB, address partyA, uint256 start, uint256 size) external view returns (Quote[] memory);
function getPositionsFilteredByPartyB(address partyB, uint256 start, uint256 size) external view returns (Quote[] memory);
function getOpenPositionsFilteredByPartyB(address partyB, uint256 start, uint256 size) external view returns (Quote[] memory);
function getActivePositionsFilteredByPartyB(address partyB, uint256 start, uint256 size) external view returns (Quote[] memory);
function partyBPositionsCount(address partyB, address partyA) external view returns (uint256);
function getPartyAPendingQuotes(address partyA) external view returns (uint256[] memory);
function getPartyBPendingQuotes(address partyB, address partyA) external view returns (uint256[] memory);
function getQuotesWithBitmap(Bitmap calldata bitmap, uint256 gasNeededForReturn) external view returns (Quote[] memory quotes);
/////////////////////////////////////
// Role
function hasRole(address user, bytes32 role) external view returns (bool);
function getRoleHash(string memory str) external pure returns (bytes32);
//////////////////////////////////////
// MA
function getCollateral() external view returns (address);
function getFeeCollector(address affiliate) external view returns (address);
function getDefaultFeeCollector() external view returns (address);
function isPartyALiquidated(address partyA) external view returns (bool);
function isPartyBLiquidated(address partyB, address partyA) external view returns (bool);
function isPartyB(address user) external view returns (bool);
function isAffiliate(address affiliate) external view returns (bool);
function pendingQuotesValidLength() external view returns (uint256);
function forceCloseGapRatio(uint256 symbolId) external view returns (uint256);
function forceClosePricePenalty() external view returns (uint256);
function forceCloseMinSigPeriod() external view returns (uint256);
function liquidatorShare() external view returns (uint256);
function liquidationTimeout() external view returns (uint256);
function partyBLiquidationTimestamp(address partyB, address partyA) external view returns (uint256);
function coolDownsOfMA() external view returns (uint256, uint256, uint256, uint256);
function settlementCooldown() external view returns (uint256);
function lastUpnlSettlementTimestamp(address senderPartyB, address targetPartyB, address partyA) external view returns (uint256);
///////////////////////////////////////////
function getMuonConfig() external view returns (uint256 upnlValidTime, uint256 priceValidTime);
function getMuonIds() external view returns (uint256 muonAppId, PublicKey memory muonPublicKey, address validGateway);
function pauseState()
external
view
returns (
bool globalPaused,
bool liquidationPaused,
bool accountingPaused,
bool partyBActionsPaused,
bool partyAActionsPaused,
bool internalTransferPaused,
bool emergencyMode
);
function getPartyBEmergencyStatus(address partyB) external view returns (bool isEmergency);
function getBalanceLimitPerUser() external view returns (uint256);
function verifyMuonTSSAndGateway(bytes32 hash, SchnorrSign memory sign, bytes memory gatewaySignature) external view;
function getNextQuoteId() external view returns (uint256);
function getBridgeTransaction(uint256 transactionId) external view returns (BridgeTransaction memory);
function getNextBridgeTransactionId() external view returns (uint256);
}// SPDX-License-Identifier: SYMM-Core-Business-Source-License-1.1
// This contract is licensed under the SYMM Core Business Source License 1.1
// Copyright (c) 2023 Symmetry Labs AG
// For more information, see https://docs.symm.io/legal-disclaimer/license
pragma solidity >=0.8.18;
interface IMultiAccount {
struct Account {
address accountAddress;
string name;
}
struct Referral {
address user;
address referrer;
}
event SetAccountImplementation(bytes oldAddress, bytes newAddress);
event SetAccountsAdmin(address oldAddress, address newAddress);
event SetSymmioAddress(address oldAddress, address newAddress);
event DeployContract(address sender, address contractAddress);
event AddAccount(address user, address account, string name);
event EditAccountName(address user, address account, string newName);
event DepositForAccount(address user, address account, uint256 amount);
event AllocateForAccount(address user, address account, uint256 amount);
event WithdrawFromAccount(address user, address account, uint256 amount);
event Call(address user, address account, bytes _callData, bool _success, bytes _resultData);
event DelegateAccess(address account, address target, bytes4 selector, bool state);
event DelegateAccesses(address account, address target, bytes4[] selector, bool state);
event ProposeToRevokeAccesses(address account, address target, bytes4[] selector);
event SetRevokeCooldown(uint256 oldCooldown, uint256 newCooldown);
event SetReferral(address user, address referrer);
}// SPDX-License-Identifier: SYMM-Core-Business-Source-License-1.1
// This contract is licensed under the SYMM Core Business Source License 1.1
// Copyright (c) 2023 Symmetry Labs AG
// For more information, see https://docs.symm.io/legal-disclaimer/license
pragma solidity >=0.8.18;
import "../storages/QuoteStorage.sol";
import "../storages/MuonStorage.sol";
interface IPartiesEvents {
event AcceptCancelRequest(uint256 quoteId, QuoteStatus quoteStatus);
event SendQuote(
address partyA,
uint256 quoteId,
address[] partyBsWhiteList,
uint256 symbolId,
PositionType positionType,
OrderType orderType,
uint256 price,
uint256 marketPrice,
uint256 quantity,
uint256 cva,
uint256 lf,
uint256 partyAmm,
uint256 partyBmm,
uint256 tradingFee,
uint256 deadline
);
event ExpireQuote(QuoteStatus quoteStatus, uint256 quoteId); // For backward compatibility, will be removed in future
event ExpireQuoteOpen(QuoteStatus quoteStatus, uint256 quoteId);
event ExpireQuoteClose(QuoteStatus quoteStatus, uint256 quoteId, uint256 closeId);
event OpenPosition(uint256 quoteId, address partyA, address partyB, uint256 filledAmount, uint256 openedPrice);
event FillCloseRequest(
uint256 quoteId,
address partyA,
address partyB,
uint256 filledAmount,
uint256 closedPrice,
QuoteStatus quoteStatus,
uint256 closeId
);
event FillCloseRequest(uint256 quoteId, address partyA, address partyB, uint256 filledAmount, uint256 closedPrice, QuoteStatus quoteStatus); // For backward compatibility, will be removed in future
event LiquidatePartyB(address liquidator, address partyB, address partyA, uint256 partyBAllocatedBalance, int256 upnl);
}// SPDX-License-Identifier: SYMM-Core-Business-Source-License-1.1
// This contract is licensed under the SYMM Core Business Source License 1.1
// Copyright (c) 2023 Symmetry Labs AG
// For more information, see https://docs.symm.io/legal-disclaimer/license
pragma solidity >=0.8.18;
import "../facets/Account/IAccountFacet.sol";
import "../facets/Control/IControlFacet.sol";
import "../facets/FundingRate/IFundingRateFacet.sol";
import "../facets/liquidation/ILiquidationFacet.sol";
import "../facets/PartyA/IPartyAFacet.sol";
import "../facets/Bridge/IBridgeFacet.sol";
import "../facets/ViewFacet/IViewFacet.sol";
import "../facets/DiamondCut/IDiamondCut.sol";
import "../facets/DiamondLoup/IDiamondLoupe.sol";
import "../facets/PartyBQuoteActions/IPartyBQuoteActionsFacet.sol";
import "../facets/PartyBPositionActions/IPartyBPositionActionsFacet.sol";
import "../facets/PartyBGroupActions/IPartyBGroupActionsFacet.sol";
import "../facets/ForceActions/IForceActionsFacet.sol";
import "../facets/Settlement/ISettlementFacet.sol";
interface ISymmio is
IAccountFacet,
IControlFacet,
IFundingRateFacet,
IBridgeFacet,
ISettlementFacet,
IForceActionsFacet,
IPartyBQuoteActionsFacet,
IPartyBGroupActionsFacet,
IPartyBPositionActionsFacet,
IPartyAFacet,
ILiquidationFacet,
IViewFacet,
IDiamondCut,
IDiamondLoupe
{
// Copied from SharedEvents library
enum BalanceChangeType {
ALLOCATE,
DEALLOCATE,
PLATFORM_FEE_IN,
PLATFORM_FEE_OUT,
REALIZED_PNL_IN,
REALIZED_PNL_OUT,
CVA_IN,
CVA_OUT,
LF_IN,
LF_OUT,
FUNDING_FEE_IN,
FUNDING_FEE_OUT
}
// Copied from SharedEvents library
event BalanceChangePartyA(address indexed partyA, uint256 amount, BalanceChangeType _type);
// Copied from SharedEvents library
event BalanceChangePartyB(address indexed partyB, address indexed partyA, uint256 amount, BalanceChangeType _type);
}// SPDX-License-Identifier: SYMM-Core-Business-Source-License-1.1
// This contract is licensed under the SYMM Core Business Source License 1.1
// Copyright (c) 2023 Symmetry Labs AG
// For more information, see https://docs.symm.io/legal-disclaimer/license
pragma solidity >=0.8.18;
interface ISymmioPartyA {
function _approve(address token, uint256 amount) external;
function _call(bytes calldata _callData) external returns (bool _success, bytes memory _resultData);
function withdrawERC20(address token, uint256 amount) external;
}// SPDX-License-Identifier: SYMM-Core-Business-Source-License-1.1
// This contract is licensed under the SYMM Core Business Source License 1.1
// Copyright (c) 2023 Symmetry Labs AG
// For more information, see https://docs.symm.io/legal-disclaimer/license
pragma solidity >=0.8.18;
import "@openzeppelin/contracts/utils/math/SafeMath.sol";
import "../storages/QuoteStorage.sol";
library LockedValuesOps {
using SafeMath for uint256;
/**
* @notice Adds the values of two LockedValues structs.
* @param self The LockedValues struct to which values will be added.
* @param a The LockedValues struct containing values to be added.
* @return The updated LockedValues struct.
*/
function add(LockedValues storage self, LockedValues memory a) internal returns (LockedValues storage) {
self.cva = self.cva.add(a.cva);
self.partyAmm = self.partyAmm.add(a.partyAmm);
self.partyBmm = self.partyBmm.add(a.partyBmm);
self.lf = self.lf.add(a.lf);
return self;
}
/**
* @notice Adds the locked values of a quote to a LockedValues struct.
* @param self The LockedValues struct to which values will be added.
* @param quote The Quote struct containing locked values to be added.
* @return The updated LockedValues struct.
*/
function addQuote(LockedValues storage self, Quote storage quote) internal returns (LockedValues storage) {
return add(self, quote.lockedValues);
}
/**
* @notice Subtracts the values of two LockedValues structs.
* @param self The LockedValues struct from which values will be subtracted.
* @param a The LockedValues struct containing values to be subtracted.
* @return The updated LockedValues struct.
*/
function sub(LockedValues storage self, LockedValues memory a) internal returns (LockedValues storage) {
self.cva = self.cva.sub(a.cva);
self.partyAmm = self.partyAmm.sub(a.partyAmm);
self.partyBmm = self.partyBmm.sub(a.partyBmm);
self.lf = self.lf.sub(a.lf);
return self;
}
/**
* @notice Subtracts the locked values of a quote from a LockedValues struct.
* @param self The LockedValues struct from which values will be subtracted.
* @param quote The Quote struct containing locked values to be subtracted.
* @return The updated LockedValues struct.
*/
function subQuote(LockedValues storage self, Quote storage quote) internal returns (LockedValues storage) {
return sub(self, quote.lockedValues);
}
/**
* @notice Sets all values of a LockedValues struct to zero.
* @param self The LockedValues struct to be zeroed.
* @return The updated LockedValues struct.
*/
function makeZero(LockedValues storage self) internal returns (LockedValues storage) {
self.cva = 0;
self.partyAmm = 0;
self.partyBmm = 0;
self.lf = 0;
return self;
}
/**
* @notice Calculates the total locked balance for Party A.
* @param self The LockedValues struct containing locked values.
* @return The total locked balance for Party A.
*/
function totalForPartyA(LockedValues memory self) internal pure returns (uint256) {
return self.cva + self.partyAmm + self.lf;
}
/**
* @notice Calculates the total locked balance for Party B.
* @param self The LockedValues struct containing locked values.
* @return The total locked balance for Party B.
*/
function totalForPartyB(LockedValues memory self) internal pure returns (uint256) {
return self.cva + self.partyBmm + self.lf;
}
/**
* @notice Multiplies all values of a LockedValues struct by a scalar value.
* @param self The LockedValues struct to be multiplied.
* @param a The scalar value to multiply by.
* @return The updated LockedValues struct.
*/
function mul(LockedValues storage self, uint256 a) internal returns (LockedValues storage) {
self.cva = self.cva.mul(a);
self.partyAmm = self.partyAmm.mul(a);
self.partyBmm = self.partyBmm.mul(a);
self.lf = self.lf.mul(a);
return self;
}
/**
* @notice Multiplies all values of a LockedValues struct by a scalar value (memory version).
* @param self The LockedValues struct to be multiplied.
* @param a The scalar value to multiply by.
* @return The updated LockedValues struct.
*/
function mulMem(LockedValues memory self, uint256 a) internal pure returns (LockedValues memory) {
LockedValues memory lockedValues = LockedValues(self.cva.mul(a), self.lf.mul(a), self.partyAmm.mul(a), self.partyBmm.mul(a));
return lockedValues;
}
/**
* @notice Divides all values of a LockedValues struct by a scalar value.
* @param self The LockedValues struct to be divided.
* @param a The scalar value to divide by.
* @return The updated LockedValues struct.
*/
function div(LockedValues storage self, uint256 a) internal returns (LockedValues storage) {
self.cva = self.cva.div(a);
self.partyAmm = self.partyAmm.div(a);
self.partyBmm = self.partyBmm.div(a);
self.lf = self.lf.div(a);
return self;
}
/**
* @notice Divides all values of a LockedValues struct by a scalar value (memory version).
* @param self The LockedValues struct to be divided.
* @param a The scalar value to divide by.
* @return The updated LockedValues struct.
*/
function divMem(LockedValues memory self, uint256 a) internal pure returns (LockedValues memory) {
LockedValues memory lockedValues = LockedValues(self.cva.div(a), self.lf.div(a), self.partyAmm.div(a), self.partyBmm.div(a));
return lockedValues;
}
}// SPDX-License-Identifier: SYMM-Core-Business-Source-License-1.1
// This contract is licensed under the SYMM Core Business Source License 1.1
// Copyright (c) 2023 Symmetry Labs AG
// For more information, see https://docs.symm.io/legal-disclaimer/license
pragma solidity >=0.8.18;
import "@openzeppelin/contracts-upgradeable/security/PausableUpgradeable.sol";
import "@openzeppelin/contracts-upgradeable/access/AccessControlUpgradeable.sol";
import "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol";
import "@openzeppelin/contracts-upgradeable/interfaces/IERC20Upgradeable.sol";
import "@openzeppelin/contracts-upgradeable/token/ERC20/utils/SafeERC20Upgradeable.sol";
import "@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol";
import "../interfaces/ISymmio.sol";
import "../interfaces/ISymmioPartyA.sol";
import "../interfaces/IMultiAccount.sol";
contract MultiAccount is IMultiAccount, Initializable, PausableUpgradeable, AccessControlUpgradeable {
using SafeERC20Upgradeable for IERC20Upgradeable;
bytes32 public constant SETTER_ROLE = keccak256("SETTER_ROLE");
bytes32 public constant PAUSER_ROLE = keccak256("PAUSER_ROLE");
bytes32 public constant UNPAUSER_ROLE = keccak256("UNPAUSER_ROLE");
mapping(address => Account[]) public accounts; // User to their accounts mapping
mapping(address => uint256) public indexOfAccount; // Account to its index mapping
mapping(address => address) public owners; // Account to its owner mapping
address public accountsAdmin; // Admin address for the accounts
address public symmioAddress; // Address of the Symmio platform
uint256 public saltCounter; // Counter for generating unique addresses with create2
bytes public accountImplementation;
mapping(address => mapping(address => mapping(bytes4 => bool))) public delegatedAccesses; // account -> target -> selector -> state
uint256 public revokeCooldown;
mapping(address => mapping(address => mapping(bytes4 => uint256))) public revokeProposalTimestamp; // account -> target -> selector -> timestamp
// Modifier to check if the sender is the owner of the account
modifier onlyOwner(address account, address sender) {
require(owners[account] == sender, "MultiAccount: Sender isn't owner of account");
_;
}
/// @custom:oz-upgrades-unsafe-allow constructor
constructor() {
_disableInitializers();
}
/**
* @dev Initializes the contract with necessary parameters.
* @param admin The admin address for the accounts contracts.
* @param symmioAddress_ The address of the Symmio platform.
* @param accountImplementation_ The bytecode of the account implementation contract.
*/
function initialize(address admin, address symmioAddress_, bytes memory accountImplementation_) public initializer {
__Pausable_init();
__AccessControl_init();
_grantRole(DEFAULT_ADMIN_ROLE, admin);
_grantRole(PAUSER_ROLE, admin);
_grantRole(UNPAUSER_ROLE, admin);
_grantRole(SETTER_ROLE, admin);
accountsAdmin = admin;
symmioAddress = symmioAddress_;
accountImplementation = accountImplementation_;
}
/**
* @dev Allows the owner of an account to delegate access to a specific function selector of a target contract.
* @param account The address of the account.
* @param target The address of the target contract.
* @param selector The function selector.
* @param state The state indicating whether access is granted or revoked.
*/
function delegateAccess(address account, address target, bytes4 selector, bool state) external onlyOwner(account, msg.sender) {
require(target != msg.sender && target != account, "MultiAccount: Invalid target");
require(state, "MultiAccount: Invalid state");
emit DelegateAccess(account, target, selector, state);
delegatedAccesses[account][target][selector] = state;
}
/**
* @dev Allows the owner of an account to delegate access to a single target contract and multiple function selectors.
* @param account The address of the account.
* @param target The address of the target contract.
* @param selector An array of function selectors.
* @param state The state indicating whether access is granted or revoked.
*/
function delegateAccesses(address account, address target, bytes4[] memory selector, bool state) external onlyOwner(account, msg.sender) {
require(target != msg.sender && target != account, "MultiAccount: Invalid target");
require(state, "MultiAccount: Invalid state");
for (uint256 i = selector.length; i != 0; i--) {
delegatedAccesses[account][target][selector[i - 1]] = state;
}
emit DelegateAccesses(account, target, selector, state);
}
/**
* @dev Allows the owner of an account to propose revoke access from a single target contract and multiple function selectors.
* @param account The address of the account.
* @param target The address of the target contract.
* @param selector An array of function selectors.
*/
function proposeToRevokeAccesses(address account, address target, bytes4[] memory selector) external onlyOwner(account, msg.sender) {
require(target != msg.sender && target != account, "MultiAccount: Invalid target");
for (uint256 i = selector.length; i != 0; i--) {
revokeProposalTimestamp[account][target][selector[i - 1]] = block.timestamp;
}
emit ProposeToRevokeAccesses(account, target, selector);
}
/**
* @dev Allows the owner of an account to revoke access from a single target contract and multiple function selectors.
* @param account The address of the account.
* @param target The address of the target contract.
* @param selector An array of function selectors.
*/
function revokeAccesses(address account, address target, bytes4[] memory selector) external onlyOwner(account, msg.sender) {
require(target != msg.sender && target != account, "MultiAccount: Invalid target");
for (uint256 i = selector.length; i != 0; i--) {
require(revokeProposalTimestamp[account][target][selector[i - 1]] != 0, "MultiAccount: Revoke access not proposed");
require(
revokeProposalTimestamp[account][target][selector[i - 1]] + revokeCooldown <= block.timestamp,
"MultiAccount: Cooldown not reached"
);
delegatedAccesses[account][target][selector[i - 1]] = false;
revokeProposalTimestamp[account][target][selector[i - 1]] = 0;
}
emit DelegateAccesses(account, target, selector, false);
}
/**
* @dev Sets the implementation contract for the account.
* @param accountImplementation_ The bytecodes of the new implementation contract.
*/
function setAccountImplementation(bytes memory accountImplementation_) external onlyRole(SETTER_ROLE) {
emit SetAccountImplementation(accountImplementation, accountImplementation_);
accountImplementation = accountImplementation_;
}
/**
* @dev Sets the Admin for the accounts.
* @param admin The Address of the new accounts admin.
*/
function setAccountsAdmin(address admin) external onlyRole(SETTER_ROLE) {
emit SetAccountsAdmin(accountsAdmin, admin);
accountsAdmin = admin;
}
/**
* @dev Sets the revoke cooldown.
* @param cooldown the new revoke cooldown.
*/
function setRevokeCooldown(uint256 cooldown) external onlyRole(SETTER_ROLE) {
emit SetRevokeCooldown(revokeCooldown, cooldown);
revokeCooldown = cooldown;
}
/**
* @dev Sets the address of the Symmio platform.
* @param addr The address of the Symmio platform.
*/
function setSymmioAddress(address addr) external onlyRole(SETTER_ROLE) {
emit SetSymmioAddress(symmioAddress, addr);
symmioAddress = addr;
}
/**
* @dev Internal function to deploy a new party A account contract.
* @return account The address of the newly deployed account contract.
*/
function _deployPartyA() internal returns (address account) {
bytes32 salt = keccak256(abi.encodePacked("MultiAccount_", saltCounter));
saltCounter += 1;
bytes memory bytecode = abi.encodePacked(accountImplementation, abi.encode(accountsAdmin, address(this), symmioAddress));
account = _deployContract(bytecode, salt);
return account;
}
/**
* @dev Internal function to deploy a contract with create2.
* @param bytecode The bytecode of the contract to be deployed.
* @param salt The salt used for contract deployment.
* @return contractAddress The address of the deployed contract.
*/
function _deployContract(bytes memory bytecode, bytes32 salt) internal returns (address contractAddress) {
assembly {
contractAddress := create2(0, add(bytecode, 32), mload(bytecode), salt)
}
require(contractAddress != address(0), "MultiAccount: create2 failed");
emit DeployContract(msg.sender, contractAddress);
return contractAddress;
}
/**
* @dev Pauses the contract, preventing execution of transactions.
*/
function pause() external onlyRole(PAUSER_ROLE) {
_pause();
}
/**
* @dev Unpauses the contract, allowing execution of transactions.
*/
function unpause() external onlyRole(UNPAUSER_ROLE) {
_unpause();
}
//////////////////////////////// Account Management ////////////////////////////////////
/**
* @dev Adds a new account for the caller with the specified name.
* @param name The name of the new account.
*/
function addAccount(string memory name) external whenNotPaused {
address account = _deployPartyA();
indexOfAccount[account] = accounts[msg.sender].length;
accounts[msg.sender].push(Account(account, name));
owners[account] = msg.sender;
emit AddAccount(msg.sender, account, name);
}
/**
* @dev Edits the name of the specified account.
* @param accountAddress The address of the account to edit.
* @param name The new name for the account.
*/
function editAccountName(address accountAddress, string memory name) external whenNotPaused {
uint256 index = indexOfAccount[accountAddress];
accounts[msg.sender][index].name = name;
emit EditAccountName(msg.sender, accountAddress, name);
}
/**
* @dev Deposits funds into the specified account.
* @param account The address of the account to deposit funds into.
* @param amount The amount of funds to deposit.
*/
function depositForAccount(address account, uint256 amount) external onlyOwner(account, msg.sender) whenNotPaused {
address collateral = ISymmio(symmioAddress).getCollateral();
IERC20Upgradeable(collateral).safeTransferFrom(msg.sender, address(this), amount);
IERC20Upgradeable(collateral).safeApprove(symmioAddress, amount);
ISymmio(symmioAddress).depositFor(account, amount);
emit DepositForAccount(msg.sender, account, amount);
}
/**
* @dev Deposits funds into the specified account and allocates them.
* @param account The address of the account to deposit and allocate funds.
* @param amount The amount of funds to deposit and allocate.
*/
function depositAndAllocateForAccount(address account, uint256 amount) external onlyOwner(account, msg.sender) whenNotPaused {
address collateral = ISymmio(symmioAddress).getCollateral();
IERC20Upgradeable(collateral).safeTransferFrom(msg.sender, address(this), amount);
IERC20Upgradeable(collateral).safeApprove(symmioAddress, amount);
ISymmio(symmioAddress).depositFor(account, amount);
uint256 amountWith18Decimals = (amount * 1e18) / (10 ** IERC20Metadata(collateral).decimals());
bytes memory _callData = abi.encodeWithSignature("allocate(uint256)", amountWith18Decimals);
innerCall(account, _callData);
emit DepositForAccount(msg.sender, account, amount);
emit AllocateForAccount(msg.sender, account, amountWith18Decimals);
}
/**
* @dev Withdraws funds from the specified account.
* @param account The address of the account to withdraw funds from.
* @param amount The amount of funds to withdraw.
*/
function withdrawFromAccount(address account, uint256 amount) external onlyOwner(account, msg.sender) whenNotPaused {
bytes memory _callData = abi.encodeWithSignature("withdrawTo(address,uint256)", owners[account], amount);
emit WithdrawFromAccount(msg.sender, account, amount);
innerCall(account, _callData);
}
function innerCall(address account, bytes memory _callData) internal {
(bool _success, bytes memory _resultData) = ISymmioPartyA(account)._call(_callData);
emit Call(msg.sender, account, _callData, _success, _resultData);
if (!_success) {
assembly {
revert(add(_resultData, 32), mload(_resultData))
}
}
}
/**
* @dev Executes a series of calls on behalf of the specified account.
* @param account The address of the account to execute the calls on behalf of.
* @param _callDatas An array of call data to execute.
*/
function _call(address account, bytes[] memory _callDatas) public whenNotPaused {
bool isOwner = owners[account] == msg.sender;
for (uint8 i; i < _callDatas.length; i++) {
bytes memory _callData = _callDatas[i];
if (!isOwner) {
require(_callData.length >= 4, "MultiAccount: Invalid call data");
bytes4 functionSelector;
assembly {
functionSelector := mload(add(_callData, 0x20))
}
require(delegatedAccesses[account][msg.sender][functionSelector], "MultiAccount: Unauthorized access");
}
innerCall(account, _callData);
}
}
//////////////////////////////// VIEWS ////////////////////////////////////
/**
* @dev Returns the number of accounts belonging to the specified user.
* @param user The address of the user.
* @return The number of accounts.
*/
function getAccountsLength(address user) external view returns (uint256) {
return accounts[user].length;
}
/**
* @dev Returns an array of accounts belonging to the specified user.
* @param user The address of the user.
* @param start The index to start retrieving accounts from.
* @param size The maximum number of accounts to retrieve.
* @return An array of Account structures.
*/
function getAccounts(address user, uint256 start, uint256 size) external view returns (Account[] memory) {
uint256 len = size > accounts[user].length - start ? accounts[user].length - start : size;
Account[] memory userAccounts = new Account[](len);
for (uint256 i = start; i < start + len; i++) {
userAccounts[i - start] = accounts[user][i];
}
return userAccounts;
}
}// SPDX-License-Identifier: SYMM-Core-Business-Source-License-1.1
// This contract is licensed under the SYMM Core Business Source License 1.1
// Copyright (c) 2023 Symmetry Labs AG
// For more information, see https://docs.symm.io/legal-disclaimer/license
pragma solidity >=0.8.18;
import "../libraries/LibLockedValues.sol";
enum LiquidationType {
NONE,
NORMAL,
LATE,
OVERDUE
}
struct SettlementState {
int256 actualAmount;
int256 expectedAmount;
uint256 cva;
bool pending;
}
struct LiquidationDetail {
bytes liquidationId;
LiquidationType liquidationType;
int256 upnl;
int256 totalUnrealizedLoss;
uint256 deficit;
uint256 liquidationFee;
uint256 timestamp;
uint256 involvedPartyBCounts;
int256 partyAAccumulatedUpnl;
bool disputed;
uint256 liquidationTimestamp;
}
struct Price {
uint256 price;
uint256 timestamp;
}
library AccountStorage {
bytes32 internal constant ACCOUNT_STORAGE_SLOT = keccak256("diamond.standard.storage.account");
struct Layout {
// Users deposited amounts
mapping(address => uint256) balances;
mapping(address => uint256) allocatedBalances;
// position value will become pending locked before openPosition and will be locked after that
mapping(address => LockedValues) pendingLockedBalances;
mapping(address => LockedValues) lockedBalances;
mapping(address => mapping(address => uint256)) partyBAllocatedBalances;
mapping(address => mapping(address => LockedValues)) partyBPendingLockedBalances;
mapping(address => mapping(address => LockedValues)) partyBLockedBalances;
mapping(address => uint256) withdrawCooldown; // is better to call lastDeallocateTime
mapping(address => uint256) partyANonces;
mapping(address => mapping(address => uint256)) partyBNonces;
mapping(address => bool) suspendedAddresses;
mapping(address => LiquidationDetail) liquidationDetails;
mapping(address => mapping(uint256 => Price)) symbolsPrices;
mapping(address => address[]) liquidators;
mapping(address => uint256) partyAReimbursement;
// partyA => partyB => SettlementState
mapping(address => mapping(address => SettlementState)) settlementStates;
mapping(address => uint256) reserveVault;
}
function layout() internal pure returns (Layout storage l) {
bytes32 slot = ACCOUNT_STORAGE_SLOT;
assembly {
l.slot := slot
}
}
}// SPDX-License-Identifier: SYMM-Core-Business-Source-License-1.1
// This contract is licensed under the SYMM Core Business Source License 1.1
// Copyright (c) 2023 Symmetry Labs AG
// For more information, see https://docs.symm.io/legal-disclaimer/license
pragma solidity >=0.8.18;
struct BridgeTransaction {
uint256 id;
uint256 amount;
address user;
address bridge;
uint256 timestamp;
BridgeTransactionStatus status;
}
enum BridgeTransactionStatus {
RECEIVED,
SUSPENDED,
WITHDRAWN
}
library BridgeStorage {
bytes32 internal constant BRIDGE_STORAGE_SLOT = keccak256("diamond.standard.storage.bridge");
struct Layout {
mapping(address => bool) bridges;
mapping(uint256 => BridgeTransaction) bridgeTransactions;
mapping(address => uint256[]) bridgeTransactionIds;
uint256 lastId;
address invalidBridgedAmountsPool;
}
function layout() internal pure returns (Layout storage l) {
bytes32 slot = BRIDGE_STORAGE_SLOT;
assembly {
l.slot := slot
}
}
}// SPDX-License-Identifier: SYMM-Core-Business-Source-License-1.1
// This contract is licensed under the SYMM Core Business Source License 1.1
// Copyright (c) 2023 Symmetry Labs AG
// For more information, see https://docs.symm.io/legal-disclaimer/license
pragma solidity >=0.8.18;
import "../libraries/LibLockedValues.sol";
struct SchnorrSign {
uint256 signature;
address owner;
address nonce;
}
struct PublicKey {
uint256 x;
uint8 parity;
}
struct SingleUpnlSig {
bytes reqId;
uint256 timestamp;
int256 upnl;
bytes gatewaySignature;
SchnorrSign sigs;
}
struct SingleUpnlAndPriceSig {
bytes reqId;
uint256 timestamp;
int256 upnl;
uint256 price;
bytes gatewaySignature;
SchnorrSign sigs;
}
struct PairUpnlSig {
bytes reqId;
uint256 timestamp;
int256 upnlPartyA;
int256 upnlPartyB;
bytes gatewaySignature;
SchnorrSign sigs;
}
struct PairUpnlAndPriceSig {
bytes reqId;
uint256 timestamp;
int256 upnlPartyA;
int256 upnlPartyB;
uint256 price;
bytes gatewaySignature;
SchnorrSign sigs;
}
struct PairUpnlAndPricesSig {
bytes reqId;
uint256 timestamp;
int256 upnlPartyA;
int256 upnlPartyB;
uint256[] symbolIds;
uint256[] prices;
bytes gatewaySignature;
SchnorrSign sigs;
}
struct DeferredLiquidationSig {
bytes reqId; // Unique identifier for the liquidation request
uint256 timestamp; // Timestamp when the liquidation signature was created
uint256 liquidationBlockNumber; // Block number at which the user became insolvent
uint256 liquidationTimestamp; // Timestamp when the user became insolvent
uint256 liquidationAllocatedBalance; // User's allocated balance at the time of insolvency
bytes liquidationId; // Unique identifier for the liquidation event
int256 upnl; // User's unrealized profit and loss at the time of insolvency
int256 totalUnrealizedLoss; // Total unrealized loss of the user at the time of insolvency
uint256[] symbolIds; // List of symbol IDs involved in the liquidation
uint256[] prices; // Corresponding prices of the symbols involved in the liquidation
bytes gatewaySignature; // Signature from the gateway for verification
SchnorrSign sigs; // Schnorr signature for additional verification
}
struct LiquidationSig {
bytes reqId; // Unique identifier for the liquidation request
uint256 timestamp; // Timestamp when the liquidation signature was created
bytes liquidationId; // Unique identifier for the liquidation event
int256 upnl; // User's unrealized profit and loss at the time of insolvency
int256 totalUnrealizedLoss; // Total unrealized loss of the user at the time of insolvency
uint256[] symbolIds; // List of symbol IDs involved in the liquidation
uint256[] prices; // Corresponding prices of the symbols involved in the liquidation
bytes gatewaySignature; // Signature from the gateway for verification
SchnorrSign sigs; // Schnorr signature for additional verification
}
struct QuotePriceSig {
bytes reqId;
uint256 timestamp;
uint256[] quoteIds;
uint256[] prices;
bytes gatewaySignature;
SchnorrSign sigs;
}
struct HighLowPriceSig {
bytes reqId;
uint256 timestamp;
uint256 symbolId;
uint256 highest;
uint256 lowest;
uint256 averagePrice;
uint256 startTime;
uint256 endTime;
int256 upnlPartyB;
int256 upnlPartyA;
uint256 currentPrice;
bytes gatewaySignature;
SchnorrSign sigs;
}
struct QuoteSettlementData {
uint256 quoteId;
uint256 currentPrice;
uint8 partyBUpnlIndex;
}
struct SettlementSig {
bytes reqId;
uint256 timestamp;
QuoteSettlementData[] quotesSettlementsData;
int256[] upnlPartyBs;
int256 upnlPartyA;
bytes gatewaySignature;
SchnorrSign sigs;
}
library MuonStorage {
bytes32 internal constant MUON_STORAGE_SLOT = keccak256("diamond.standard.storage.muon");
struct Layout {
uint256 upnlValidTime;
uint256 priceValidTime;
uint256 priceQuantityValidTime; // UNUSED: Should be deleted later
uint256 muonAppId;
PublicKey muonPublicKey;
address validGateway;
}
function layout() internal pure returns (Layout storage l) {
bytes32 slot = MUON_STORAGE_SLOT;
assembly {
l.slot := slot
}
}
}// SPDX-License-Identifier: SYMM-Core-Business-Source-License-1.1
// This contract is licensed under the SYMM Core Business Source License 1.1
// Copyright (c) 2023 Symmetry Labs AG
// For more information, see https://docs.symm.io/legal-disclaimer/license
pragma solidity >=0.8.18;
enum PositionType {
LONG,
SHORT
}
enum OrderType {
LIMIT,
MARKET
}
enum QuoteStatus {
PENDING, //0
LOCKED, //1
CANCEL_PENDING, //2
CANCELED, //3
OPENED, //4
CLOSE_PENDING, //5
CANCEL_CLOSE_PENDING, //6
CLOSED, //7
LIQUIDATED, //8
EXPIRED, //9
LIQUIDATED_PENDING //10
}
struct LockedValues {
uint256 cva;
uint256 lf;
uint256 partyAmm;
uint256 partyBmm;
}
struct Quote {
uint256 id;
address[] partyBsWhiteList;
uint256 symbolId;
PositionType positionType;
OrderType orderType;
// Price of quote which PartyB opened in 18 decimals
uint256 openedPrice;
uint256 initialOpenedPrice;
// Price of quote which PartyA requested in 18 decimals
uint256 requestedOpenPrice;
uint256 marketPrice;
// Quantity of quote which PartyA requested in 18 decimals
uint256 quantity;
// Quantity of quote which PartyB has closed until now in 18 decimals
uint256 closedAmount;
LockedValues initialLockedValues;
LockedValues lockedValues;
uint256 maxFundingRate;
address partyA;
address partyB;
QuoteStatus quoteStatus;
uint256 avgClosedPrice;
uint256 requestedClosePrice;
uint256 quantityToClose;
// handle partially open position
uint256 parentId;
uint256 createTimestamp;
uint256 statusModifyTimestamp;
uint256 lastFundingPaymentTimestamp;
uint256 deadline;
uint256 tradingFee;
address affiliate;
}
library QuoteStorage {
bytes32 internal constant QUOTE_STORAGE_SLOT = keccak256("diamond.standard.storage.quote");
struct Layout {
mapping(address => uint256[]) quoteIdsOf;
mapping(uint256 => Quote) quotes;
mapping(address => uint256) partyAPositionsCount;
mapping(address => mapping(address => uint256)) partyBPositionsCount;
mapping(address => uint256[]) partyAPendingQuotes;
mapping(address => mapping(address => uint256[])) partyBPendingQuotes;
mapping(address => uint256[]) partyAOpenPositions;
mapping(uint256 => uint256) partyAPositionsIndex;
mapping(address => mapping(address => uint256[])) partyBOpenPositions;
mapping(uint256 => uint256) partyBPositionsIndex;
uint256 lastId;
uint256 lastCloseId;
mapping(uint256 => uint256) closeIds;
}
function layout() internal pure returns (Layout storage l) {
bytes32 slot = QUOTE_STORAGE_SLOT;
assembly {
l.slot := slot
}
}
}// SPDX-License-Identifier: SYMM-Core-Business-Source-License-1.1
// This contract is licensed under the SYMM Core Business Source License 1.1
// Copyright (c) 2023 Symmetry Labs AG
// For more information, see https://docs.symm.io/legal-disclaimer/license
pragma solidity >=0.8.18;
struct Symbol {
uint256 symbolId;
string name;
bool isValid;
uint256 minAcceptableQuoteValue;
uint256 minAcceptablePortionLF;
uint256 tradingFee;
uint256 maxLeverage;
uint256 fundingRateEpochDuration;
uint256 fundingRateWindowTime;
}
library SymbolStorage {
bytes32 internal constant SYMBOL_STORAGE_SLOT = keccak256("diamond.standard.storage.symbol");
struct Layout {
mapping(uint256 => Symbol) symbols;
uint256 lastId;
mapping(uint256 => uint256) forceCloseGapRatio; // symbolId -> forceCloseGapRatio
}
function layout() internal pure returns (Layout storage l) {
bytes32 slot = SYMBOL_STORAGE_SLOT;
assembly {
l.slot := slot
}
}
}{
"metadata": {
"bytecodeHash": "none"
},
"optimizer": {
"enabled": true,
"runs": 200
},
"viaIR": true,
"outputSelection": {
"*": {
"*": [
"evm.bytecode",
"evm.deployedBytecode",
"devdoc",
"userdoc",
"metadata",
"abi"
]
}
}
}Contract Security Audit
- No Contract Security Audit Submitted- Submit Audit Here
Contract ABI
API[{"inputs":[],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"user","type":"address"},{"indexed":false,"internalType":"address","name":"account","type":"address"},{"indexed":false,"internalType":"string","name":"name","type":"string"}],"name":"AddAccount","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"user","type":"address"},{"indexed":false,"internalType":"address","name":"account","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"AllocateForAccount","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"user","type":"address"},{"indexed":false,"internalType":"address","name":"account","type":"address"},{"indexed":false,"internalType":"bytes","name":"_callData","type":"bytes"},{"indexed":false,"internalType":"bool","name":"_success","type":"bool"},{"indexed":false,"internalType":"bytes","name":"_resultData","type":"bytes"}],"name":"Call","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"account","type":"address"},{"indexed":false,"internalType":"address","name":"target","type":"address"},{"indexed":false,"internalType":"bytes4","name":"selector","type":"bytes4"},{"indexed":false,"internalType":"bool","name":"state","type":"bool"}],"name":"DelegateAccess","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"account","type":"address"},{"indexed":false,"internalType":"address","name":"target","type":"address"},{"indexed":false,"internalType":"bytes4[]","name":"selector","type":"bytes4[]"},{"indexed":false,"internalType":"bool","name":"state","type":"bool"}],"name":"DelegateAccesses","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"sender","type":"address"},{"indexed":false,"internalType":"address","name":"contractAddress","type":"address"}],"name":"DeployContract","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"user","type":"address"},{"indexed":false,"internalType":"address","name":"account","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"DepositForAccount","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"user","type":"address"},{"indexed":false,"internalType":"address","name":"account","type":"address"},{"indexed":false,"internalType":"string","name":"newName","type":"string"}],"name":"EditAccountName","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint8","name":"version","type":"uint8"}],"name":"Initialized","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"account","type":"address"}],"name":"Paused","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"account","type":"address"},{"indexed":false,"internalType":"address","name":"target","type":"address"},{"indexed":false,"internalType":"bytes4[]","name":"selector","type":"bytes4[]"}],"name":"ProposeToRevokeAccesses","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":false,"internalType":"bytes","name":"oldAddress","type":"bytes"},{"indexed":false,"internalType":"bytes","name":"newAddress","type":"bytes"}],"name":"SetAccountImplementation","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"oldAddress","type":"address"},{"indexed":false,"internalType":"address","name":"newAddress","type":"address"}],"name":"SetAccountsAdmin","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"user","type":"address"},{"indexed":false,"internalType":"address","name":"referrer","type":"address"}],"name":"SetReferral","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"oldCooldown","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"newCooldown","type":"uint256"}],"name":"SetRevokeCooldown","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"oldAddress","type":"address"},{"indexed":false,"internalType":"address","name":"newAddress","type":"address"}],"name":"SetSymmioAddress","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"account","type":"address"}],"name":"Unpaused","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"user","type":"address"},{"indexed":false,"internalType":"address","name":"account","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"WithdrawFromAccount","type":"event"},{"inputs":[],"name":"DEFAULT_ADMIN_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"PAUSER_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"SETTER_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"UNPAUSER_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"},{"internalType":"bytes[]","name":"_callDatas","type":"bytes[]"}],"name":"_call","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"accountImplementation","outputs":[{"internalType":"bytes","name":"","type":"bytes"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"uint256","name":"","type":"uint256"}],"name":"accounts","outputs":[{"internalType":"address","name":"accountAddress","type":"address"},{"internalType":"string","name":"name","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"accountsAdmin","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"string","name":"name","type":"string"}],"name":"addAccount","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"string","name":"name","type":"string"},{"internalType":"address","name":"referrer","type":"address"}],"name":"addAccountWithReferral","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"string","name":"name","type":"string"},{"internalType":"address","name":"referrer","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"addAccountWithReferralAndDepositAndAllocate","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"},{"internalType":"address","name":"target","type":"address"},{"internalType":"bytes4","name":"selector","type":"bytes4"},{"internalType":"bool","name":"state","type":"bool"}],"name":"delegateAccess","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"},{"internalType":"address","name":"target","type":"address"},{"internalType":"bytes4[]","name":"selector","type":"bytes4[]"},{"internalType":"bool","name":"state","type":"bool"}],"name":"delegateAccesses","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"address","name":"","type":"address"},{"internalType":"bytes4","name":"","type":"bytes4"}],"name":"delegatedAccesses","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"depositAndAllocateForAccount","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"depositForAccount","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"accountAddress","type":"address"},{"internalType":"string","name":"name","type":"string"}],"name":"editAccountName","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"user","type":"address"},{"internalType":"uint256","name":"start","type":"uint256"},{"internalType":"uint256","name":"size","type":"uint256"}],"name":"getAccounts","outputs":[{"components":[{"internalType":"address","name":"accountAddress","type":"address"},{"internalType":"string","name":"name","type":"string"}],"internalType":"struct IMultiAccount.Account[]","name":"","type":"tuple[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"user","type":"address"}],"name":"getAccountsLength","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","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":"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":[{"internalType":"address","name":"","type":"address"}],"name":"indexOfAccount","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"admin","type":"address"},{"internalType":"address","name":"symmioAddress_","type":"address"},{"internalType":"bytes","name":"accountImplementation_","type":"bytes"}],"name":"initialize","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"owners","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"pause","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"paused","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"},{"internalType":"address","name":"target","type":"address"},{"internalType":"bytes4[]","name":"selector","type":"bytes4[]"}],"name":"proposeToRevokeAccesses","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"referrals","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"renounceRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"},{"internalType":"address","name":"target","type":"address"},{"internalType":"bytes4[]","name":"selector","type":"bytes4[]"}],"name":"revokeAccesses","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"revokeCooldown","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"address","name":"","type":"address"},{"internalType":"bytes4","name":"","type":"bytes4"}],"name":"revokeProposalTimestamp","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"revokeRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"saltCounter","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes","name":"accountImplementation_","type":"bytes"}],"name":"setAccountImplementation","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"admin","type":"address"}],"name":"setAccountsAdmin","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"components":[{"internalType":"address","name":"user","type":"address"},{"internalType":"address","name":"referrer","type":"address"}],"internalType":"struct IMultiAccount.Referral[]","name":"_referrals","type":"tuple[]"}],"name":"setReferrals","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"cooldown","type":"uint256"}],"name":"setRevokeCooldown","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"addr","type":"address"}],"name":"setSymmioAddress","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":[],"name":"symmioAddress","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"unpause","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"withdrawFromAccount","outputs":[],"stateMutability":"nonpayable","type":"function"}]Contract Creation Code
0x6080604052346200002e576200001462000033565b6200001e62000033565b604051613dd89081620000dd8239f35b600080fd5b60005460ff8160081c16620000875760ff80821603620000505750565b60ff90811916176000557f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb3847402498602060405160ff8152a1565b60405162461bcd60e51b815260206004820152602760248201527f496e697469616c697a61626c653a20636f6e747261637420697320696e697469604482015266616c697a696e6760c81b6064820152608490fdfe6080604052600436101561001257600080fd5b60003560e01c806301569e3a146102d757806301ffc9a7146102d2578063022914a7146102cd57806311464fbe146102c8578063248a9ca3146102c3578063288409bb146102be5780632ad26a04146102b95780632f2ff15d146102b457806331e69d2d146102af578063342fcda9146102aa57806336568abe146102a557806337f93b08146102a05780633f4ba83a1461029b5780634ebabea1146102965780635c975abb146102915780636a29dfbf1461028c5780637278b28f146102875780637e206dca1461028257806382a7e5331461027d5780638456cb591461027857806387524581146102735780638b5afd2b1461026e57806391d148541461026957806394aee4221461026457806395c7d0ec1461025f57806395d4609d1461025a5780639b0c03de146102555780639ca423b314610250578063a04c68091461024b578063a2011b3f14610246578063a217fddf14610241578063a58c99d71461023c578063b9c9b3f214610237578063bd367d8e14610232578063beca59171461022d578063c110221414610228578063cf7a1d7714610223578063d547741f1461021e578063d9c2337c14610219578063e5b00c2a14610214578063e63ab1e91461020f578063f462e6821461020a578063f7420276146102055763fb1bb9de1461020057600080fd5b612628565b6125d5565b6125b7565b61258e565b612480565b6122f7565b6122b5565b612197565b612098565b611f7f565b611ed0565b611e8b565b611d09565b611ced565b611cb2565b611c94565b611c55565b611c18565b611bb4565b611a6e565b6118ff565b6118a9565b61186c565b6117e9565b61156b565b61141b565b6112d8565b6112af565b6111d1565b61116a565b610ffa565b610ed6565b610ead565b610e15565b610c82565b6109cf565b610902565b610743565b610657565b610628565b610555565b6103da565b610384565b6102f2565b6001600160a01b038116036102ed57565b600080fd5b346102ed5760203660031901126102ed5760043561030f816102dc565b610317612663565b60cd54604080516001600160a01b03808416825284811660208301529293917ff78ccdf5924090b2ab6627ac5da4ec5affed73d47c6bc6c8a4620a0d5ed57bc891a16001600160a01b031990921691161760cd55005b604435906001600160e01b0319821682036102ed57565b346102ed5760203660031901126102ed5760043563ffffffff60e01b81168091036102ed57602090637965db0b60e01b81149081156103c9575b506040519015158152f35b6301ffc9a760e01b149050386103be565b346102ed5760203660031901126102ed5760206004356103f9816102dc565b60018060a01b0380911660005260cb825260406000205416604051908152f35b60009103126102ed57565b634e487b7160e01b600052600060045260246000fd5b90600182811c9216801561046a575b602083101461045457565b634e487b7160e01b600052602260045260246000fd5b91607f1691610449565b634e487b7160e01b600052604160045260246000fd5b6001600160401b03811161049d57604052565b610474565b604081019081106001600160401b0382111761049d57604052565b606081019081106001600160401b0382111761049d57604052565b90601f801991011681019081106001600160401b0382111761049d57604052565b60005b83811061050c5750506000910152565b81810151838201526020016104fc565b90602091610535815180928185528580860191016104f9565b601f01601f1916010190565b90602061055292818152019061051c565b90565b346102ed5760008060031936011261062557604051908060cf546105788161043a565b808552916001918083169081156105fb57506001146105b2575b6105ae856105a2818703826104d8565b60405191829182610541565b0390f35b925060cf8352600080516020613d8c8339815191525b8284106105e35750505081016020016105a2826105ae610592565b805460208587018101919091529093019281016105c8565b8695506105ae969350602092506105a294915060ff191682840152151560051b8201019293610592565b80fd5b346102ed5760203660031901126102ed5760043560005260976020526020600160406000200154604051908152f35b346102ed5760203660031901126102ed57600435610674816102dc565b61067c612663565b60cc54604080516001600160a01b03808416825284811660208301529293917fc0c0a485d5a9547b687095c9652fe0811abc1379aa253cc64a91be08804b895691a16001600160a01b031990921691161760cc55005b604051906106df826104a2565b565b6001600160401b03811161049d57601f01601f191660200190565b81601f820112156102ed57803590610713826106e1565b9261072160405194856104d8565b828452602083830101116102ed57816000926020809301838601378301015290565b346102ed5760203660031901126102ed576004356001600160401b0381116102ed576107947f1deb86e124d1a5f3b49977292b48e989b984bcd8944cfb14d63c8880482f2cff9136906004016106fc565b61079c61330c565b61085360ce546107e46107df60405160208101906c4d756c74694163636f756e745f60981b825284602d820152602d81526107d6816104bd565b51902092612a15565b60ce55565b60cc5460cd54604080516001600160a01b0393841660208201523091810191909152911660608083019190915281526108429061084e90601f199061082a6080826104d8565b60405193849161083c60208401613495565b906127c0565b039081018352826104d8565b613512565b33600090815260c960205260409020546001600160a01b038216600090815260ca602052604090205533600090815260c9602052604090206108af906108976106d2565b6001600160a01b038416815290846020830152613350565b6001600160a01b038116600090815260cb602052604090206108ed9033905b80546001600160a01b0319166001600160a01b03909216919091179055565b6108fd604051928392338461346c565b0390a1005b346102ed5760403660031901126102ed57600435602435610922816102dc565b600091808352609760205261093d600160408520015461270d565b8083526097602090815260408085206001600160a01b0385166000908152925290205460ff161561096c578280f35b8083526097602090815260408085206001600160a01b038516600090815292529020805460ff1916600117905533916001600160a01b0316907f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d8480a438808280f35b346102ed576040806003193601126102ed576004356109ed816102dc565b6024359060018060a01b0390600093828216855260209260cb8452610a18338284892054161461305c565b610a2061330c565b60cd546004908590610a4890610a3c906001600160a01b031681565b6001600160a01b031690565b8451635c1548fb60e01b815292839182905afa908115610c33578791610c55575b501690610a78853033856135cd565b60cd54610a909086906001600160a01b031684613698565b60cd54610aa790610a3c906001600160a01b031681565b91823b15610c515781516317a790f160e11b81526001600160a01b0385166004820152602481018790529287908490604490829084905af1928315610c3357600493610c38575b5084610af9876129f8565b9183519485809263313ce56760e01b82525afa908115610c33577f13b84d799b5b8b235eafe52313197bb3dbf3d5c36c2ac0b62e4c45cc4d3a958e96610bb1610b7b610bd793610b757fb92f7c65176e3a873589352927ba42330e95085f34ab1a9721f2135b94a5188396610c00998e91610c06575b50613935565b90613946565b85516390ca796b60e01b998101999099526024890181905297610bab81604481015b03601f1981018352826104d8565b876139a9565b83513381526001600160a01b038716602082015260408101919091529081906060820190565b0390a1513381526001600160a01b03909216602083015260408201929092529081906060820190565b0390a180f35b610c2691508c8d3d10610c2c575b610c1e81836104d8565b81019061391c565b38610b6f565b503d610c14565b6135c1565b80610c45610c4b9261048a565b80610419565b38610aee565b8680fd5b610c759150853d8711610c7b575b610c6d81836104d8565b8101906135ac565b38610a69565b503d610c63565b346102ed5760403660031901126102ed57600435610c9f816102dc565b6001600160a01b03808216600090815260cb602052604081205490929160243591610ccd908216331461305c565b610cd561330c565b60cd54600490602090610cf290610a3c906001600160a01b031681565b604051635c1548fb60e01b815292839182905afa918215610c3357610d3a9284928791610df7575b5016610d28823033846135cd565b60cd546001600160a01b031690613698565b60cd54610d5190610a3c906001600160a01b031681565b91823b15610df3576040516317a790f160e11b81526001600160a01b0382166004820152602481018390529284908490604490829084905af1928315610c33577fb92f7c65176e3a873589352927ba42330e95085f34ab1a9721f2135b94a5188393610de0575b50604080513381526001600160a01b0390921660208301528101919091528060608101610c00565b80610c45610ded9261048a565b38610db8565b8380fd5b610e0f915060203d8111610c7b57610c6d81836104d8565b38610d1a565b346102ed5760403660031901126102ed57602435610e32816102dc565b336001600160a01b03821603610e5057610e4e9060043561294f565b005b60405162461bcd60e51b815260206004820152602f60248201527f416363657373436f6e74726f6c3a2063616e206f6e6c792072656e6f756e636560448201526e103937b632b9903337b91039b2b63360891b6064820152608490fd5b346102ed5760003660031901126102ed5760cc546040516001600160a01b039091168152602090f35b346102ed5760003660031901126102ed57610eef6126b8565b60335460ff811615610f2e5760ff19166033557f5db9ee0a495bf2e6ff9c91a7834c1ba4fdd244a5e8aa4e537bd38aeae4b073aa6020604051338152a1005b60405162461bcd60e51b815260206004820152601460248201527314185d5cd8589b194e881b9bdd081c185d5cd95960621b6044820152606490fd5b6001600160401b03811161049d5760051b60200190565b81601f820112156102ed57803591610f9883610f6a565b92610fa660405194856104d8565b808452602092838086019260051b8201019283116102ed578301905b828210610fd0575050505090565b81356001600160e01b0319811681036102ed578152908301908301610fc2565b801515036102ed57565b346102ed5760803660031901126102ed57600435611017816102dc565b602435611023816102dc565b6044356001600160401b0381116102ed57611042903690600401610f81565b906064359261105084610ff0565b60018060a01b039384821693600094808652602060cb815261109360409861107e33828c8c2054161461305c565b87168333821415918261115f575b50506130bc565b61109c84613108565b8251805b6110d95750505090610c00917f41e2c91b7cd59c2d41cfac17496b166b244a4921d4a1c926b4a7132b6c66906e959651948594856131f9565b61115990611154866111436111098b8e8e8a815260d08a52209060018060a01b0316600052602052604060002090565b61112c61111e61111887613154565b8b613170565b516001600160e01b03191690565b63ffffffff60e01b16600052602052604060002090565b9060ff801983541691151516179055565b612a89565b806110a0565b14159050833861108c565b346102ed5760003660031901126102ed57602060ff603354166040519015158152f35b60606003198201126102ed576004356111a5816102dc565b916024356111b2816102dc565b91604435906001600160401b0382116102ed5761055291600401610f81565b346102ed576111df3661118d565b919060018060a01b039182811692600093808552602060cb815261122360409361120f3382878b2054161461305c565b86168333821415918261115f5750506130bc565b8651805b61125f575050507f64930ca7235077162dd09f78d211b233f0f505f794151b9ecfaa6680bf00ead69394610c0091519384938461322f565b6112a99083885260d2835261128887868a209060018060a01b0316600052602052604060002090565b6112a3429161112c61111e8d61129d87613154565b90613170565b55612a89565b80611227565b346102ed5760003660031901126102ed5760cd546040516001600160a01b039091168152602090f35b346102ed576020806003193601126102ed57600435906001600160401b03908183116102ed57366023840112156102ed5782600401359182116102ed576024830192602436918460061b0101116102ed57611331612663565b60005b82811061133d57005b807f3576c10a3107273bc6535da3c7aef2a8fa869e980ce766193ce37d026d90fb378361136e611416948789613cfc565b0135611379816102dc565b611384838789613cfc565b3561138e816102dc565b6001600160a01b03908116600090815260d3875260409081902080546001600160a01b031916939092169290921790556113c9838789613cfc565b356113d3816102dc565b61140e866113e2868a8c613cfc565b0135926113ee846102dc565b516001600160a01b03928316815292909116602083015281906040820190565b0390a1613cb1565b611334565b346102ed576020806003193601126102ed576001600160401b036004358181116102ed5761144d9036906004016106fc565b91611456612663565b7f4ec7166fdb5f155366ddacdab9af9c74d038015a7570252e40c6c82346308ad7604051604081528061149b61148e604083016116c1565b828103868401528761051c565b0390a1825191821161049d576114bb826114b660cf5461043a565b612d7c565b80601f83116001146114f6575081926000926114eb575b5050600019600383901b1c191660019190911b1760cf55005b0151905038806114d2565b90601f1983169361151760cf600052600080516020613d8c83398151915290565b926000905b868210611553575050836001951061153a575b505050811b0160cf55005b015160001960f88460031b161c1916905538808061152f565b8060018596829496860151815501950193019061151c565b346102ed5760008060031936011261062557600080516020613dac8339815191528152609760209081526040808320336000908152925290205460ff16156115ef576115b561330c565b600160ff1960335416176033557f62e78cea01bee320cd4e420270b5ea74000d11b0c9f74754ebdbfc544b05a2586020604051338152a180f35b611686604861166e61160033612ae1565b610b9d61160b612b61565b6040519485937f416363657373436f6e74726f6c3a206163636f756e7420000000000000000000602086015261164b8151809260206037890191016104f9565b84017001034b99036b4b9b9b4b733903937b6329607d1b603782015201906127c0565b60405162461bcd60e51b815291829160048301610541565b0390fd5b634e487b7160e01b600052603260045260246000fd5b80548210156116bc5760005260206000209060011b0190600090565b61168a565b60cf54600092916116d18261043a565b8082529160019081811690811561173657506001146116ef57505050565b9192935060cf600052600080516020613d8c833981519152916000925b84841061171e57505060209250010190565b8054602085850181019190915290930192810161170c565b915050602093945060ff929192191683830152151560051b010190565b90600092918054916117648361043a565b9182825260019384811690816000146117c65750600114611786575b50505050565b90919394506000526020928360002092846000945b8386106117b2575050505001019038808080611780565b80548587018301529401938590820161179b565b9294505050602093945060ff191683830152151560051b01019038808080611780565b346102ed576040806003193601126102ed57600435611807816102dc565b60243560018060a01b0380921660005260c96020528260002080548210156102ed5761185761183b6105ae936001936116a0565b50938454169361185086518094819301611753565b03826104d8565b8351938493845280602085015283019061051c565b346102ed5760203660031901126102ed57600435611889816102dc565b60018060a01b031660005260c96020526020604060002054604051908152f35b346102ed5760403660031901126102ed57602060ff6118f36024356118cd816102dc565b6004356000526097845260406000209060018060a01b0316600052602052604060002090565b54166040519015158152f35b346102ed5760403660031901126102ed5760043561191c816102dc565b6119ef60243560018060a01b03927f40e4447d271dea2a920b9669d305a3255d8783d59b016237e63b106f1c9dd5fa6119e7836119c087851697600098808a5260cb602052611972338360408d2054161461305c565b61197a61330c565b895260cb60209081526040808b2054905163040b850f60e31b92810192909252919091166001600160a01b031660248201526044808201979097529586526064866104d8565b604080513381526001600160a01b0386166020820152908101919091529081906060820190565b0390a16139a9565b80f35b602080820190808352835180925260409283810182858560051b8401019601946000925b858410611a27575050505050505090565b909192939495968580611a5d600193603f1986820301885286838d51878060a01b0381511684520151918185820152019061051c565b990194019401929594939190611a16565b346102ed5760603660031901126102ed57600435611a8b816102dc565b60243560443560018060a01b03831660005260c9602052604060002054828103908111611b7257811115611b6c57506001600160a01b038216600090815260c960205260409020611ade90829054613163565b905b611ae982613c50565b92815b611af68484612a23565b811015611b5e57611b5781611b51611b2c611af694611b278760018060a01b031660005260c9602052604060002090565b6116a0565b50611b40611b3a8885613163565b91613cc0565b611b4a828b613170565b5288613170565b50613cb1565b9050611aec565b604051806105ae87826119f2565b90611ae0565b6129e2565b60609060031901126102ed57600435611b8f816102dc565b90602435611b9c816102dc565b906044356001600160e01b0319811681036102ed5790565b346102ed576020611c0f611bf7611bca36611b77565b929160018060a01b031660005260d2855260406000209060018060a01b0316600052602052604060002090565b9063ffffffff60e01b16600052602052604060002090565b54604051908152f35b346102ed5760203660031901126102ed57600435611c35816102dc565b60018060a01b031660005260ca6020526020604060002054604051908152f35b346102ed5760203660031901126102ed576020600435611c74816102dc565b60018060a01b0380911660005260d3825260406000205416604051908152f35b346102ed5760003660031901126102ed57602060ce54604051908152f35b346102ed5760003660031901126102ed5760206040517f61c92169ef077349011ff0b1383c894d86c5f0b41d986366b58a6cf31e93beda8152f35b346102ed5760003660031901126102ed57602060405160008152f35b346102ed57611d173661118d565b919060018060a01b0391611d5783821660009481865260cb602052611d4333826040892054161461305c565b841690338214159182611e805750506130bc565b8351805b611d925750610c007f41e2c91b7cd59c2d41cfac17496b166b244a4921d4a1c926b4a7132b6c66906e9394604051938493846131c2565b611e7a90611dea611de2611dd386611dbc8760018060a01b031660005260d2602052604060002090565b9060018060a01b0316600052602052604060002090565b61112c61111e61111886613154565b541515613258565b611e26611e10611dd386611dbc8760018060a01b031660005260d2602052604060002090565b54611e1f429160d15490612a23565b11156132b5565b611e56611e4c611dd386611dbc8760018060a01b031660005260d0602052604060002090565b805460ff19169055565b846112a3611dd386611dbc8760018060a01b031660005260d2602052604060002090565b80611d5b565b14159050388061108c565b346102ed57602060ff6118f3611bf7611ea336611b77565b929160018060a01b031660005260d0865260406000209060018060a01b0316600052602052604060002090565b346102ed5760403660031901126102ed57600435611eed816102dc565b60248035916001600160401b03928381116102ed57366023820112156102ed57806004013592611f1c84610f6a565b93611f2a60405195866104d8565b808552602095828787019260051b850101933685116102ed57838101925b858410611f5957610e4e8888613af0565b83358381116102ed578991611f7483928836918701016106fc565b815201930192611f48565b346102ed5760603660031901126102ed576004356001600160401b0381116102ed57611faf9036906004016106fc565b60243590611fbc826102dc565b611fc461330c565b303b156102ed57604051906372d8061560e11b82528180611fec600095869460048401613d63565b038183305af18015610c3357612085575b5033600090815260c9602052604090208054612034916120269161202090613154565b906116a0565b50546001600160a01b031690565b81303b15610625576040516331e69d2d60e01b81526001600160a01b0392909216600483015260448035602484015282908183305af18015610c3357612078575080f35b80610c456119ef9261048a565b80610c456120929261048a565b38611ffd565b346102ed5760803660031901126102ed576004356120b5816102dc565b6119ef6024356120c4816102dc565b6111436120cf61036d565b611bf7606435936120df85610ff0565b60018060a01b038097167fc6c2cef2fe1f0545b232744fc2812ca3a23cdb770794c9c7458ea69f6d9be7ff6080600099838b5260cb6020526121298b82604033922054161461305c565b8416338114158061218d575b61213e906130bc565b61214789613108565b60405190848252602082015263ffffffff60e01b871660408201528815156060820152a1875260d0602052604087209060018060a01b0316600052602052604060002090565b5080841415612135565b346102ed5760603660031901126102ed576004356121b4816102dc565b6024356121c0816102dc565b604435906001600160401b0382116102ed576121e36122259236906004016106fc565b906000549361220960ff8660081c1615809681976122a7575b8115612287575b50612d02565b8461221c600160ff196000541617600055565b61226e57612ed7565b61222b57005b61223b61ff001960005416600055565b604051600181527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb38474024989080602081016108fd565b61228261010061ff00196000541617600055565b612ed7565b303b15915081612299575b5038612203565b6001915060ff161438612292565b600160ff82161091506121fc565b346102ed5760403660031901126102ed57610e4e6024356004356122d8826102dc565b8060005260976020526122f260016040600020015461270d565b61294f565b346102ed5760403660031901126102ed57600435612314816102dc565b6001600160401b03906024358281116102ed576123359036906004016106fc565b61233d61330c565b60009160018060a01b038116835260209360ca855261236a604085205433865260c98752604086206116a0565b5090600180920191845191821161049d5761238f82612389855461043a565b85612dcb565b86601f83116001146123f5575081809187987f13bbfc66aca7f597c509c7eb717cafee4ae3fc31a77f4bbb22b333e81369276d98936123ea575b501b916000199060031b1c19161790555b610c00604051928392338461346c565b8701519250386123c9565b601f9291921982169761240d85600052602060002090565b9188905b8a8210612469575050827f13bbfc66aca7f597c509c7eb717cafee4ae3fc31a77f4bbb22b333e81369276d989910612450575b5050811b0190556123da565b86015160001960f88460031b161c191690553880612444565b808684958294958c01518155019401920190612411565b346102ed5760403660031901126102ed576004356001600160401b0381116102ed576124b09036906004016106fc565b7f3576c10a3107273bc6535da3c7aef2a8fa869e980ce766193ce37d026d90fb376125456024356124e0816102dc565b6124e861330c565b33600090815260d3602052604090205461250b906001600160a01b031615613d0c565b33600090815260d3602052604090206125259082906108ce565b604080513381526001600160a01b03909216602083015290918291820190565b0390a1303b156102ed57600061256f9160405180938192630ab49a8160e21b835260048301610541565b038183305af18015610c335761258157005b80610c45610e4e9261048a565b346102ed5760003660031901126102ed576020604051600080516020613dac8339815191528152f35b346102ed5760003660031901126102ed57602060d154604051908152f35b346102ed5760203660031901126102ed576004356125f1612663565b7f41a6e3ea336979dfead544a7561ccbf3fbbbf13c4405cc4ce398afaebf4b1498604060d1548151908152836020820152a160d155005b346102ed5760003660031901126102ed5760206040517f427da25fe773164f88948d3e215c94b6554e2ed5e5f203a821c9f2f6131cf75a8152f35b3360009081527f0ba47cfd5e746a7a77d10576777b78a793709d8d5c4bbd732c557bc9a64bb31b602052604090205460ff161561269c57565b611686604861166e6126ad33612ae1565b610b9d61160b612be0565b3360009081527f4f911b9375d0b52c272a370588b5a39d3b1a324938ee95e0e2faf0b3b468c710602052604090205460ff16156126f157565b611686604861166e61270233612ae1565b610b9d61160b612c71565b600081815260976020908152604080832033845290915290205460ff16156127325750565b61273b33612ae1565b612743612a30565b91603061274f84612a5b565b53607861275b84612a68565b5360415b6001811161277e57611686604861166e85610b9d8861160b8815612a96565b90600f81169060108210156116bc576127bb916f181899199a1a9b1b9c1cb0b131b232b360811b901a6127b18487612a78565b5360041c91612a89565b61275f565b906127d3602092828151948592016104f9565b0190565b6001600160a01b03811660009081527f793844da0378ca0230b21a4013ef02cf55735b90b39c85241478ff94b5eceb2860205260408120600080516020613dac8339815191529060ff905b54161561282e57505050565b8082526097602090815260408084206001600160a01b038616600090815292529020805460ff1916600117905533926001600160a01b0316917f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d9080a4565b6001600160a01b03811660009081527f4f911b9375d0b52c272a370588b5a39d3b1a324938ee95e0e2faf0b3b468c710602052604081207f427da25fe773164f88948d3e215c94b6554e2ed5e5f203a821c9f2f6131cf75a9060ff90612822565b6001600160a01b03811660009081527f0ba47cfd5e746a7a77d10576777b78a793709d8d5c4bbd732c557bc9a64bb31b602052604081207f61c92169ef077349011ff0b1383c894d86c5f0b41d986366b58a6cf31e93beda9060ff90612822565b600090808252609760205260ff61297b84604085209060018060a01b0316600052602052604060002090565b541661298657505050565b8082526097602090815260408084206001600160a01b038616600090815292529020805460ff1916905533926001600160a01b0316917ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b9080a4565b634e487b7160e01b600052601160045260246000fd5b90670de0b6b3a764000091828102928184041490151715611b7257565b9060018201809211611b7257565b91908201809211611b7257565b60405190608082018281106001600160401b0382111761049d57604052604282526060366020840137565b8051156116bc5760200190565b8051600110156116bc5760210190565b9081518110156116bc570160200190565b8015611b72576000190190565b15612a9d57565b606460405162461bcd60e51b815260206004820152602060248201527f537472696e67733a20686578206c656e67746820696e73756666696369656e746044820152fd5b60405190612aee826104bd565b602a825260403660208401376030612b0583612a5b565b536078612b1183612a68565b536029905b60018211612b2957610552915015612a96565b600f81169060108210156116bc57612b5b916f181899199a1a9b1b9c1cb0b131b232b360811b901a6127b18486612a78565b90612b16565b600080516020613dac833981519152612b78612a30565b906030612b8483612a5b565b536078612b9083612a68565b536041905b60018211612ba857610552915015612a96565b600f81169060108210156116bc57612bda916f181899199a1a9b1b9c1cb0b131b232b360811b901a6127b18486612a78565b90612b95565b7f61c92169ef077349011ff0b1383c894d86c5f0b41d986366b58a6cf31e93beda612c09612a30565b906030612c1583612a5b565b536078612c2183612a68565b536041905b60018211612c3957610552915015612a96565b600f81169060108210156116bc57612c6b916f181899199a1a9b1b9c1cb0b131b232b360811b901a6127b18486612a78565b90612c26565b7f427da25fe773164f88948d3e215c94b6554e2ed5e5f203a821c9f2f6131cf75a612c9a612a30565b906030612ca683612a5b565b536078612cb283612a68565b536041905b60018211612cca57610552915015612a96565b600f81169060108210156116bc57612cfc916f181899199a1a9b1b9c1cb0b131b232b360811b901a6127b18486612a78565b90612cb7565b15612d0957565b60405162461bcd60e51b815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201526d191e481a5b9a5d1a585b1a5e995960921b6064820152608490fd5b818110612d70575050565b60008155600101612d65565b90601f8211612d89575050565b6106df9160cf600052600080516020613d8c833981519152906020601f840160051c83019310612dc1575b601f0160051c0190612d65565b9091508190612db4565b9190601f8111612dda57505050565b6106df926000526020600020906020601f840160051c83019310612dc157601f0160051c0190612d65565b9081516001600160401b03811161049d57612e25816114b660cf5461043a565b602080601f8311600114612e615750819293600092612e56575b50508160011b916000199060031b1c19161760cf55565b015190503880612e3f565b90601f19831694612e8260cf600052600080516020613d8c83398151915290565b926000905b878210612ebf575050836001959610612ea6575b505050811b0160cf55565b015160001960f88460031b161c19169055388080612e9b565b80600185968294968601518155019501930190612e87565b6106df9291612f9b91600060ff815460081c16612ef381612ffc565b612efc81612ffc565b612f1060ff19918260335416603355612ffc565b8180526097602090815260408084206001600160a01b0386166000908152925290205460ff1615612fa0575b5050612f47816127d7565b612f508161288d565b612f59816128ee565b60018060a01b03166bffffffffffffffffffffffff60a01b60cc54161760cc5560018060a01b03166bffffffffffffffffffffffff60a01b60cd54161760cd55565b612e05565b8180526097602090815260408084206001600160a01b0386166000818152919093522080549290921660011790915533917f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d8180a43880612f3c565b1561300357565b60405162461bcd60e51b815260206004820152602b60248201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960448201526a6e697469616c697a696e6760a81b6064820152608490fd5b1561306357565b60405162461bcd60e51b815260206004820152602b60248201527f4d756c74694163636f756e743a2053656e6465722069736e2774206f776e657260448201526a081bd9881858d8dbdd5b9d60aa1b6064820152608490fd5b156130c357565b60405162461bcd60e51b815260206004820152601c60248201527f4d756c74694163636f756e743a20496e76616c696420746172676574000000006044820152606490fd5b1561310f57565b60405162461bcd60e51b815260206004820152601b60248201527f4d756c74694163636f756e743a20496e76616c696420737461746500000000006044820152606490fd5b600019810191908211611b7257565b91908203918211611b7257565b80518210156116bc5760209160051b010190565b90815180825260208080930193019160005b8281106131a4575050505090565b83516001600160e01b03191685529381019392810192600101613196565b6001600160a01b039182168152911660208201526080604082018190529092916000916060916131f491860190613184565b930152565b926132279160609396959660018060a01b038092168652166020850152608060408501526080840190613184565b931515910152565b6001600160a01b0391821681529116602082015260606040820181905261055292910190613184565b1561325f57565b60405162461bcd60e51b815260206004820152602860248201527f4d756c74694163636f756e743a205265766f6b6520616363657373206e6f74206044820152671c1c9bdc1bdcd95960c21b6064820152608490fd5b156132bc57565b60405162461bcd60e51b815260206004820152602260248201527f4d756c74694163636f756e743a20436f6f6c646f776e206e6f74207265616368604482015261195960f21b6064820152608490fd5b60ff6033541661331857565b60405162461bcd60e51b815260206004820152601060248201526f14185d5cd8589b194e881c185d5cd95960821b6044820152606490fd5b80546801000000000000000081101561049d576133749060019283820181556116a0565b61346757825181546001600160a01b0319166001600160a01b0391909116178155810191602080910151908151916001600160401b03831161049d576133c4836133be875461043a565b87612dcb565b81601f84116001146133fd57509282939183926000946133f2575b50501b916000199060031b1c1916179055565b0151925038806133df565b919083601f19811661341488600052602060002090565b946000905b8883831061344d5750505010613434575b505050811b019055565b015160001960f88460031b161c1916905538808061342a565b858701518855909601959485019487935090810190613419565b610424565b6001600160a01b039182168152911660208201526060604082018190526105529291019061051c565b60cf54600092916134a58261043a565b916001908181169081156134ff57506001146134c057505050565b909192935060cf600052600080516020613d8c833981519152906000915b8483106134ec575050500190565b81816020925485870152019201916134de565b60ff191683525050811515909102019150565b6020815191016000f56001600160a01b0381161561356757604080513381526001600160a01b03831660208201527f6cbd957809e2aaf4d5e36136d06e71215f53a984b218c6d501e22f91d348d9ce9190a190565b60405162461bcd60e51b815260206004820152601c60248201527f4d756c74694163636f756e743a2063726561746532206661696c6564000000006044820152606490fd5b908160209103126102ed5751610552816102dc565b6040513d6000823e3d90fd5b6040516323b872dd60e01b60208201526001600160a01b03928316602482015292909116604483015260648201929092526106df9161361982608481015b03601f1981018452836104d8565b613774565b908160209103126102ed575190565b1561363457565b60405162461bcd60e51b815260206004820152603660248201527f5361666545524332303a20617070726f76652066726f6d206e6f6e2d7a65726f60448201527520746f206e6f6e2d7a65726f20616c6c6f77616e636560501b6064820152608490fd5b919091811580156136e6575b6106df936136b46136199261362d565b60405163095ea7b360e01b60208201526001600160a01b0390911660248201526044810193909352826064810161360b565b50604051636eb1769f60e11b81523060048201526001600160a01b038416602482015292602084806044810103816001600160a01b0386165afa908115610c33576136b4613619926106df96600091613746575b501592505093506136a4565b613767915060203d811161376d575b61375f81836104d8565b81019061361e565b3861373a565b503d613755565b60018060a01b0316906137f160405161378c816104a2565b6020938482527f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564858301526000808587829751910182855af13d15613887573d916137d6836106e1565b926137e460405194856104d8565b83523d868885013e61388b565b90815190838215928315613864575b50505090501561380d5750565b6084906040519062461bcd60e51b82526004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b6064820152fd5b848092939450010312610625575081015161387e81610ff0565b80388381613800565b6060915b919290156138ed575081511561389f575090565b3b156138a85790565b60405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000006044820152606490fd5b8251909150156139005750805190602001fd5b60405162461bcd60e51b81529081906116869060048301610541565b908160209103126102ed575160ff811681036102ed5790565b60ff16604d8111611b7257600a0a90565b8115613950570490565b634e487b7160e01b600052601260045260246000fd5b6001600160a01b0391821681529116602082015260a06040820181905261055294926139949183019061051c565b9215156060820152608081840391015261051c565b60405163316fdd9760e11b815260009290918383806139cb8560048301610541565b0381836001600160a01b0386165af1938415610c335780938195613a34575b5050907f268e99f0b37c8146a6aea7c6af329e3924d9c92c4386be924c2990926d99b66191613a2185856040519485943386613966565b0390a115613a2c5750565b602081519101fd5b91945092503d8084833e613a4881836104d8565b81019260408285031261062557815191613a6183610ff0565b6020810151906001600160401b038211613aec570184601f82011215613ae857805191613a8d836106e1565b95613a9b60405197886104d8565b8387526020848401011161062557507f268e99f0b37c8146a6aea7c6af329e3924d9c92c4386be924c2990926d99b661939291613ade91602080880191016104f9565b92939091386139ea565b5080fd5b8280fd5b613af861330c565b60018060a01b039081811660005260209160cb83526040600020541691600092331415925b845160ff821690811015613ba65784613b39613b469288613170565b5190613b5a575b846139a9565b60ff809116908114611b7257600101613b1d565b613b68600482511015613bae565b613ba1613b9c613b9586840151611bf733611dbc8b60018060a01b031660005260d0602052604060002090565b5460ff1690565b613bfa565b613b40565b505050505050565b15613bb557565b60405162461bcd60e51b815260206004820152601f60248201527f4d756c74694163636f756e743a20496e76616c69642063616c6c2064617461006044820152606490fd5b15613c0157565b60405162461bcd60e51b815260206004820152602160248201527f4d756c74694163636f756e743a20556e617574686f72697a65642061636365736044820152607360f81b6064820152608490fd5b90613c5a82610f6a565b6040613c68815192836104d8565b8382528193613c79601f1991610f6a565b0191600091825b848110613c8e575050505050565b6020908251613c9c816104a2565b85815282606081830152828601015201613c80565b6000198114611b725760010190565b9060016020604051613cd1816104a2565b613cf88195848060a01b038154168352613cf16040518096819301611753565b03846104d8565b0152565b91908110156116bc5760061b0190565b15613d1357565b60405162461bcd60e51b815260206004820152602260248201527f4d756c74694163636f756e743a20526566657272616c20616c72656164792073604482015261195d60f21b6064820152608490fd5b90613d7b60209194939460408452604084019061051c565b6001600160a01b0390941691015256feacb8d954e2cfef495862221e91bd7523613cf8808827cb33edfe4904cc51bf2965d7a28e3265b37a6474929f336521b332c1681b933f6cb9f3376673440d862aa164736f6c6343000812000a
Deployed Bytecode
0x6080604052600436101561001257600080fd5b60003560e01c806301569e3a146102d757806301ffc9a7146102d2578063022914a7146102cd57806311464fbe146102c8578063248a9ca3146102c3578063288409bb146102be5780632ad26a04146102b95780632f2ff15d146102b457806331e69d2d146102af578063342fcda9146102aa57806336568abe146102a557806337f93b08146102a05780633f4ba83a1461029b5780634ebabea1146102965780635c975abb146102915780636a29dfbf1461028c5780637278b28f146102875780637e206dca1461028257806382a7e5331461027d5780638456cb591461027857806387524581146102735780638b5afd2b1461026e57806391d148541461026957806394aee4221461026457806395c7d0ec1461025f57806395d4609d1461025a5780639b0c03de146102555780639ca423b314610250578063a04c68091461024b578063a2011b3f14610246578063a217fddf14610241578063a58c99d71461023c578063b9c9b3f214610237578063bd367d8e14610232578063beca59171461022d578063c110221414610228578063cf7a1d7714610223578063d547741f1461021e578063d9c2337c14610219578063e5b00c2a14610214578063e63ab1e91461020f578063f462e6821461020a578063f7420276146102055763fb1bb9de1461020057600080fd5b612628565b6125d5565b6125b7565b61258e565b612480565b6122f7565b6122b5565b612197565b612098565b611f7f565b611ed0565b611e8b565b611d09565b611ced565b611cb2565b611c94565b611c55565b611c18565b611bb4565b611a6e565b6118ff565b6118a9565b61186c565b6117e9565b61156b565b61141b565b6112d8565b6112af565b6111d1565b61116a565b610ffa565b610ed6565b610ead565b610e15565b610c82565b6109cf565b610902565b610743565b610657565b610628565b610555565b6103da565b610384565b6102f2565b6001600160a01b038116036102ed57565b600080fd5b346102ed5760203660031901126102ed5760043561030f816102dc565b610317612663565b60cd54604080516001600160a01b03808416825284811660208301529293917ff78ccdf5924090b2ab6627ac5da4ec5affed73d47c6bc6c8a4620a0d5ed57bc891a16001600160a01b031990921691161760cd55005b604435906001600160e01b0319821682036102ed57565b346102ed5760203660031901126102ed5760043563ffffffff60e01b81168091036102ed57602090637965db0b60e01b81149081156103c9575b506040519015158152f35b6301ffc9a760e01b149050386103be565b346102ed5760203660031901126102ed5760206004356103f9816102dc565b60018060a01b0380911660005260cb825260406000205416604051908152f35b60009103126102ed57565b634e487b7160e01b600052600060045260246000fd5b90600182811c9216801561046a575b602083101461045457565b634e487b7160e01b600052602260045260246000fd5b91607f1691610449565b634e487b7160e01b600052604160045260246000fd5b6001600160401b03811161049d57604052565b610474565b604081019081106001600160401b0382111761049d57604052565b606081019081106001600160401b0382111761049d57604052565b90601f801991011681019081106001600160401b0382111761049d57604052565b60005b83811061050c5750506000910152565b81810151838201526020016104fc565b90602091610535815180928185528580860191016104f9565b601f01601f1916010190565b90602061055292818152019061051c565b90565b346102ed5760008060031936011261062557604051908060cf546105788161043a565b808552916001918083169081156105fb57506001146105b2575b6105ae856105a2818703826104d8565b60405191829182610541565b0390f35b925060cf8352600080516020613d8c8339815191525b8284106105e35750505081016020016105a2826105ae610592565b805460208587018101919091529093019281016105c8565b8695506105ae969350602092506105a294915060ff191682840152151560051b8201019293610592565b80fd5b346102ed5760203660031901126102ed5760043560005260976020526020600160406000200154604051908152f35b346102ed5760203660031901126102ed57600435610674816102dc565b61067c612663565b60cc54604080516001600160a01b03808416825284811660208301529293917fc0c0a485d5a9547b687095c9652fe0811abc1379aa253cc64a91be08804b895691a16001600160a01b031990921691161760cc55005b604051906106df826104a2565b565b6001600160401b03811161049d57601f01601f191660200190565b81601f820112156102ed57803590610713826106e1565b9261072160405194856104d8565b828452602083830101116102ed57816000926020809301838601378301015290565b346102ed5760203660031901126102ed576004356001600160401b0381116102ed576107947f1deb86e124d1a5f3b49977292b48e989b984bcd8944cfb14d63c8880482f2cff9136906004016106fc565b61079c61330c565b61085360ce546107e46107df60405160208101906c4d756c74694163636f756e745f60981b825284602d820152602d81526107d6816104bd565b51902092612a15565b60ce55565b60cc5460cd54604080516001600160a01b0393841660208201523091810191909152911660608083019190915281526108429061084e90601f199061082a6080826104d8565b60405193849161083c60208401613495565b906127c0565b039081018352826104d8565b613512565b33600090815260c960205260409020546001600160a01b038216600090815260ca602052604090205533600090815260c9602052604090206108af906108976106d2565b6001600160a01b038416815290846020830152613350565b6001600160a01b038116600090815260cb602052604090206108ed9033905b80546001600160a01b0319166001600160a01b03909216919091179055565b6108fd604051928392338461346c565b0390a1005b346102ed5760403660031901126102ed57600435602435610922816102dc565b600091808352609760205261093d600160408520015461270d565b8083526097602090815260408085206001600160a01b0385166000908152925290205460ff161561096c578280f35b8083526097602090815260408085206001600160a01b038516600090815292529020805460ff1916600117905533916001600160a01b0316907f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d8480a438808280f35b346102ed576040806003193601126102ed576004356109ed816102dc565b6024359060018060a01b0390600093828216855260209260cb8452610a18338284892054161461305c565b610a2061330c565b60cd546004908590610a4890610a3c906001600160a01b031681565b6001600160a01b031690565b8451635c1548fb60e01b815292839182905afa908115610c33578791610c55575b501690610a78853033856135cd565b60cd54610a909086906001600160a01b031684613698565b60cd54610aa790610a3c906001600160a01b031681565b91823b15610c515781516317a790f160e11b81526001600160a01b0385166004820152602481018790529287908490604490829084905af1928315610c3357600493610c38575b5084610af9876129f8565b9183519485809263313ce56760e01b82525afa908115610c33577f13b84d799b5b8b235eafe52313197bb3dbf3d5c36c2ac0b62e4c45cc4d3a958e96610bb1610b7b610bd793610b757fb92f7c65176e3a873589352927ba42330e95085f34ab1a9721f2135b94a5188396610c00998e91610c06575b50613935565b90613946565b85516390ca796b60e01b998101999099526024890181905297610bab81604481015b03601f1981018352826104d8565b876139a9565b83513381526001600160a01b038716602082015260408101919091529081906060820190565b0390a1513381526001600160a01b03909216602083015260408201929092529081906060820190565b0390a180f35b610c2691508c8d3d10610c2c575b610c1e81836104d8565b81019061391c565b38610b6f565b503d610c14565b6135c1565b80610c45610c4b9261048a565b80610419565b38610aee565b8680fd5b610c759150853d8711610c7b575b610c6d81836104d8565b8101906135ac565b38610a69565b503d610c63565b346102ed5760403660031901126102ed57600435610c9f816102dc565b6001600160a01b03808216600090815260cb602052604081205490929160243591610ccd908216331461305c565b610cd561330c565b60cd54600490602090610cf290610a3c906001600160a01b031681565b604051635c1548fb60e01b815292839182905afa918215610c3357610d3a9284928791610df7575b5016610d28823033846135cd565b60cd546001600160a01b031690613698565b60cd54610d5190610a3c906001600160a01b031681565b91823b15610df3576040516317a790f160e11b81526001600160a01b0382166004820152602481018390529284908490604490829084905af1928315610c33577fb92f7c65176e3a873589352927ba42330e95085f34ab1a9721f2135b94a5188393610de0575b50604080513381526001600160a01b0390921660208301528101919091528060608101610c00565b80610c45610ded9261048a565b38610db8565b8380fd5b610e0f915060203d8111610c7b57610c6d81836104d8565b38610d1a565b346102ed5760403660031901126102ed57602435610e32816102dc565b336001600160a01b03821603610e5057610e4e9060043561294f565b005b60405162461bcd60e51b815260206004820152602f60248201527f416363657373436f6e74726f6c3a2063616e206f6e6c792072656e6f756e636560448201526e103937b632b9903337b91039b2b63360891b6064820152608490fd5b346102ed5760003660031901126102ed5760cc546040516001600160a01b039091168152602090f35b346102ed5760003660031901126102ed57610eef6126b8565b60335460ff811615610f2e5760ff19166033557f5db9ee0a495bf2e6ff9c91a7834c1ba4fdd244a5e8aa4e537bd38aeae4b073aa6020604051338152a1005b60405162461bcd60e51b815260206004820152601460248201527314185d5cd8589b194e881b9bdd081c185d5cd95960621b6044820152606490fd5b6001600160401b03811161049d5760051b60200190565b81601f820112156102ed57803591610f9883610f6a565b92610fa660405194856104d8565b808452602092838086019260051b8201019283116102ed578301905b828210610fd0575050505090565b81356001600160e01b0319811681036102ed578152908301908301610fc2565b801515036102ed57565b346102ed5760803660031901126102ed57600435611017816102dc565b602435611023816102dc565b6044356001600160401b0381116102ed57611042903690600401610f81565b906064359261105084610ff0565b60018060a01b039384821693600094808652602060cb815261109360409861107e33828c8c2054161461305c565b87168333821415918261115f575b50506130bc565b61109c84613108565b8251805b6110d95750505090610c00917f41e2c91b7cd59c2d41cfac17496b166b244a4921d4a1c926b4a7132b6c66906e959651948594856131f9565b61115990611154866111436111098b8e8e8a815260d08a52209060018060a01b0316600052602052604060002090565b61112c61111e61111887613154565b8b613170565b516001600160e01b03191690565b63ffffffff60e01b16600052602052604060002090565b9060ff801983541691151516179055565b612a89565b806110a0565b14159050833861108c565b346102ed5760003660031901126102ed57602060ff603354166040519015158152f35b60606003198201126102ed576004356111a5816102dc565b916024356111b2816102dc565b91604435906001600160401b0382116102ed5761055291600401610f81565b346102ed576111df3661118d565b919060018060a01b039182811692600093808552602060cb815261122360409361120f3382878b2054161461305c565b86168333821415918261115f5750506130bc565b8651805b61125f575050507f64930ca7235077162dd09f78d211b233f0f505f794151b9ecfaa6680bf00ead69394610c0091519384938461322f565b6112a99083885260d2835261128887868a209060018060a01b0316600052602052604060002090565b6112a3429161112c61111e8d61129d87613154565b90613170565b55612a89565b80611227565b346102ed5760003660031901126102ed5760cd546040516001600160a01b039091168152602090f35b346102ed576020806003193601126102ed57600435906001600160401b03908183116102ed57366023840112156102ed5782600401359182116102ed576024830192602436918460061b0101116102ed57611331612663565b60005b82811061133d57005b807f3576c10a3107273bc6535da3c7aef2a8fa869e980ce766193ce37d026d90fb378361136e611416948789613cfc565b0135611379816102dc565b611384838789613cfc565b3561138e816102dc565b6001600160a01b03908116600090815260d3875260409081902080546001600160a01b031916939092169290921790556113c9838789613cfc565b356113d3816102dc565b61140e866113e2868a8c613cfc565b0135926113ee846102dc565b516001600160a01b03928316815292909116602083015281906040820190565b0390a1613cb1565b611334565b346102ed576020806003193601126102ed576001600160401b036004358181116102ed5761144d9036906004016106fc565b91611456612663565b7f4ec7166fdb5f155366ddacdab9af9c74d038015a7570252e40c6c82346308ad7604051604081528061149b61148e604083016116c1565b828103868401528761051c565b0390a1825191821161049d576114bb826114b660cf5461043a565b612d7c565b80601f83116001146114f6575081926000926114eb575b5050600019600383901b1c191660019190911b1760cf55005b0151905038806114d2565b90601f1983169361151760cf600052600080516020613d8c83398151915290565b926000905b868210611553575050836001951061153a575b505050811b0160cf55005b015160001960f88460031b161c1916905538808061152f565b8060018596829496860151815501950193019061151c565b346102ed5760008060031936011261062557600080516020613dac8339815191528152609760209081526040808320336000908152925290205460ff16156115ef576115b561330c565b600160ff1960335416176033557f62e78cea01bee320cd4e420270b5ea74000d11b0c9f74754ebdbfc544b05a2586020604051338152a180f35b611686604861166e61160033612ae1565b610b9d61160b612b61565b6040519485937f416363657373436f6e74726f6c3a206163636f756e7420000000000000000000602086015261164b8151809260206037890191016104f9565b84017001034b99036b4b9b9b4b733903937b6329607d1b603782015201906127c0565b60405162461bcd60e51b815291829160048301610541565b0390fd5b634e487b7160e01b600052603260045260246000fd5b80548210156116bc5760005260206000209060011b0190600090565b61168a565b60cf54600092916116d18261043a565b8082529160019081811690811561173657506001146116ef57505050565b9192935060cf600052600080516020613d8c833981519152916000925b84841061171e57505060209250010190565b8054602085850181019190915290930192810161170c565b915050602093945060ff929192191683830152151560051b010190565b90600092918054916117648361043a565b9182825260019384811690816000146117c65750600114611786575b50505050565b90919394506000526020928360002092846000945b8386106117b2575050505001019038808080611780565b80548587018301529401938590820161179b565b9294505050602093945060ff191683830152151560051b01019038808080611780565b346102ed576040806003193601126102ed57600435611807816102dc565b60243560018060a01b0380921660005260c96020528260002080548210156102ed5761185761183b6105ae936001936116a0565b50938454169361185086518094819301611753565b03826104d8565b8351938493845280602085015283019061051c565b346102ed5760203660031901126102ed57600435611889816102dc565b60018060a01b031660005260c96020526020604060002054604051908152f35b346102ed5760403660031901126102ed57602060ff6118f36024356118cd816102dc565b6004356000526097845260406000209060018060a01b0316600052602052604060002090565b54166040519015158152f35b346102ed5760403660031901126102ed5760043561191c816102dc565b6119ef60243560018060a01b03927f40e4447d271dea2a920b9669d305a3255d8783d59b016237e63b106f1c9dd5fa6119e7836119c087851697600098808a5260cb602052611972338360408d2054161461305c565b61197a61330c565b895260cb60209081526040808b2054905163040b850f60e31b92810192909252919091166001600160a01b031660248201526044808201979097529586526064866104d8565b604080513381526001600160a01b0386166020820152908101919091529081906060820190565b0390a16139a9565b80f35b602080820190808352835180925260409283810182858560051b8401019601946000925b858410611a27575050505050505090565b909192939495968580611a5d600193603f1986820301885286838d51878060a01b0381511684520151918185820152019061051c565b990194019401929594939190611a16565b346102ed5760603660031901126102ed57600435611a8b816102dc565b60243560443560018060a01b03831660005260c9602052604060002054828103908111611b7257811115611b6c57506001600160a01b038216600090815260c960205260409020611ade90829054613163565b905b611ae982613c50565b92815b611af68484612a23565b811015611b5e57611b5781611b51611b2c611af694611b278760018060a01b031660005260c9602052604060002090565b6116a0565b50611b40611b3a8885613163565b91613cc0565b611b4a828b613170565b5288613170565b50613cb1565b9050611aec565b604051806105ae87826119f2565b90611ae0565b6129e2565b60609060031901126102ed57600435611b8f816102dc565b90602435611b9c816102dc565b906044356001600160e01b0319811681036102ed5790565b346102ed576020611c0f611bf7611bca36611b77565b929160018060a01b031660005260d2855260406000209060018060a01b0316600052602052604060002090565b9063ffffffff60e01b16600052602052604060002090565b54604051908152f35b346102ed5760203660031901126102ed57600435611c35816102dc565b60018060a01b031660005260ca6020526020604060002054604051908152f35b346102ed5760203660031901126102ed576020600435611c74816102dc565b60018060a01b0380911660005260d3825260406000205416604051908152f35b346102ed5760003660031901126102ed57602060ce54604051908152f35b346102ed5760003660031901126102ed5760206040517f61c92169ef077349011ff0b1383c894d86c5f0b41d986366b58a6cf31e93beda8152f35b346102ed5760003660031901126102ed57602060405160008152f35b346102ed57611d173661118d565b919060018060a01b0391611d5783821660009481865260cb602052611d4333826040892054161461305c565b841690338214159182611e805750506130bc565b8351805b611d925750610c007f41e2c91b7cd59c2d41cfac17496b166b244a4921d4a1c926b4a7132b6c66906e9394604051938493846131c2565b611e7a90611dea611de2611dd386611dbc8760018060a01b031660005260d2602052604060002090565b9060018060a01b0316600052602052604060002090565b61112c61111e61111886613154565b541515613258565b611e26611e10611dd386611dbc8760018060a01b031660005260d2602052604060002090565b54611e1f429160d15490612a23565b11156132b5565b611e56611e4c611dd386611dbc8760018060a01b031660005260d0602052604060002090565b805460ff19169055565b846112a3611dd386611dbc8760018060a01b031660005260d2602052604060002090565b80611d5b565b14159050388061108c565b346102ed57602060ff6118f3611bf7611ea336611b77565b929160018060a01b031660005260d0865260406000209060018060a01b0316600052602052604060002090565b346102ed5760403660031901126102ed57600435611eed816102dc565b60248035916001600160401b03928381116102ed57366023820112156102ed57806004013592611f1c84610f6a565b93611f2a60405195866104d8565b808552602095828787019260051b850101933685116102ed57838101925b858410611f5957610e4e8888613af0565b83358381116102ed578991611f7483928836918701016106fc565b815201930192611f48565b346102ed5760603660031901126102ed576004356001600160401b0381116102ed57611faf9036906004016106fc565b60243590611fbc826102dc565b611fc461330c565b303b156102ed57604051906372d8061560e11b82528180611fec600095869460048401613d63565b038183305af18015610c3357612085575b5033600090815260c9602052604090208054612034916120269161202090613154565b906116a0565b50546001600160a01b031690565b81303b15610625576040516331e69d2d60e01b81526001600160a01b0392909216600483015260448035602484015282908183305af18015610c3357612078575080f35b80610c456119ef9261048a565b80610c456120929261048a565b38611ffd565b346102ed5760803660031901126102ed576004356120b5816102dc565b6119ef6024356120c4816102dc565b6111436120cf61036d565b611bf7606435936120df85610ff0565b60018060a01b038097167fc6c2cef2fe1f0545b232744fc2812ca3a23cdb770794c9c7458ea69f6d9be7ff6080600099838b5260cb6020526121298b82604033922054161461305c565b8416338114158061218d575b61213e906130bc565b61214789613108565b60405190848252602082015263ffffffff60e01b871660408201528815156060820152a1875260d0602052604087209060018060a01b0316600052602052604060002090565b5080841415612135565b346102ed5760603660031901126102ed576004356121b4816102dc565b6024356121c0816102dc565b604435906001600160401b0382116102ed576121e36122259236906004016106fc565b906000549361220960ff8660081c1615809681976122a7575b8115612287575b50612d02565b8461221c600160ff196000541617600055565b61226e57612ed7565b61222b57005b61223b61ff001960005416600055565b604051600181527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb38474024989080602081016108fd565b61228261010061ff00196000541617600055565b612ed7565b303b15915081612299575b5038612203565b6001915060ff161438612292565b600160ff82161091506121fc565b346102ed5760403660031901126102ed57610e4e6024356004356122d8826102dc565b8060005260976020526122f260016040600020015461270d565b61294f565b346102ed5760403660031901126102ed57600435612314816102dc565b6001600160401b03906024358281116102ed576123359036906004016106fc565b61233d61330c565b60009160018060a01b038116835260209360ca855261236a604085205433865260c98752604086206116a0565b5090600180920191845191821161049d5761238f82612389855461043a565b85612dcb565b86601f83116001146123f5575081809187987f13bbfc66aca7f597c509c7eb717cafee4ae3fc31a77f4bbb22b333e81369276d98936123ea575b501b916000199060031b1c19161790555b610c00604051928392338461346c565b8701519250386123c9565b601f9291921982169761240d85600052602060002090565b9188905b8a8210612469575050827f13bbfc66aca7f597c509c7eb717cafee4ae3fc31a77f4bbb22b333e81369276d989910612450575b5050811b0190556123da565b86015160001960f88460031b161c191690553880612444565b808684958294958c01518155019401920190612411565b346102ed5760403660031901126102ed576004356001600160401b0381116102ed576124b09036906004016106fc565b7f3576c10a3107273bc6535da3c7aef2a8fa869e980ce766193ce37d026d90fb376125456024356124e0816102dc565b6124e861330c565b33600090815260d3602052604090205461250b906001600160a01b031615613d0c565b33600090815260d3602052604090206125259082906108ce565b604080513381526001600160a01b03909216602083015290918291820190565b0390a1303b156102ed57600061256f9160405180938192630ab49a8160e21b835260048301610541565b038183305af18015610c335761258157005b80610c45610e4e9261048a565b346102ed5760003660031901126102ed576020604051600080516020613dac8339815191528152f35b346102ed5760003660031901126102ed57602060d154604051908152f35b346102ed5760203660031901126102ed576004356125f1612663565b7f41a6e3ea336979dfead544a7561ccbf3fbbbf13c4405cc4ce398afaebf4b1498604060d1548151908152836020820152a160d155005b346102ed5760003660031901126102ed5760206040517f427da25fe773164f88948d3e215c94b6554e2ed5e5f203a821c9f2f6131cf75a8152f35b3360009081527f0ba47cfd5e746a7a77d10576777b78a793709d8d5c4bbd732c557bc9a64bb31b602052604090205460ff161561269c57565b611686604861166e6126ad33612ae1565b610b9d61160b612be0565b3360009081527f4f911b9375d0b52c272a370588b5a39d3b1a324938ee95e0e2faf0b3b468c710602052604090205460ff16156126f157565b611686604861166e61270233612ae1565b610b9d61160b612c71565b600081815260976020908152604080832033845290915290205460ff16156127325750565b61273b33612ae1565b612743612a30565b91603061274f84612a5b565b53607861275b84612a68565b5360415b6001811161277e57611686604861166e85610b9d8861160b8815612a96565b90600f81169060108210156116bc576127bb916f181899199a1a9b1b9c1cb0b131b232b360811b901a6127b18487612a78565b5360041c91612a89565b61275f565b906127d3602092828151948592016104f9565b0190565b6001600160a01b03811660009081527f793844da0378ca0230b21a4013ef02cf55735b90b39c85241478ff94b5eceb2860205260408120600080516020613dac8339815191529060ff905b54161561282e57505050565b8082526097602090815260408084206001600160a01b038616600090815292529020805460ff1916600117905533926001600160a01b0316917f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d9080a4565b6001600160a01b03811660009081527f4f911b9375d0b52c272a370588b5a39d3b1a324938ee95e0e2faf0b3b468c710602052604081207f427da25fe773164f88948d3e215c94b6554e2ed5e5f203a821c9f2f6131cf75a9060ff90612822565b6001600160a01b03811660009081527f0ba47cfd5e746a7a77d10576777b78a793709d8d5c4bbd732c557bc9a64bb31b602052604081207f61c92169ef077349011ff0b1383c894d86c5f0b41d986366b58a6cf31e93beda9060ff90612822565b600090808252609760205260ff61297b84604085209060018060a01b0316600052602052604060002090565b541661298657505050565b8082526097602090815260408084206001600160a01b038616600090815292529020805460ff1916905533926001600160a01b0316917ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b9080a4565b634e487b7160e01b600052601160045260246000fd5b90670de0b6b3a764000091828102928184041490151715611b7257565b9060018201809211611b7257565b91908201809211611b7257565b60405190608082018281106001600160401b0382111761049d57604052604282526060366020840137565b8051156116bc5760200190565b8051600110156116bc5760210190565b9081518110156116bc570160200190565b8015611b72576000190190565b15612a9d57565b606460405162461bcd60e51b815260206004820152602060248201527f537472696e67733a20686578206c656e67746820696e73756666696369656e746044820152fd5b60405190612aee826104bd565b602a825260403660208401376030612b0583612a5b565b536078612b1183612a68565b536029905b60018211612b2957610552915015612a96565b600f81169060108210156116bc57612b5b916f181899199a1a9b1b9c1cb0b131b232b360811b901a6127b18486612a78565b90612b16565b600080516020613dac833981519152612b78612a30565b906030612b8483612a5b565b536078612b9083612a68565b536041905b60018211612ba857610552915015612a96565b600f81169060108210156116bc57612bda916f181899199a1a9b1b9c1cb0b131b232b360811b901a6127b18486612a78565b90612b95565b7f61c92169ef077349011ff0b1383c894d86c5f0b41d986366b58a6cf31e93beda612c09612a30565b906030612c1583612a5b565b536078612c2183612a68565b536041905b60018211612c3957610552915015612a96565b600f81169060108210156116bc57612c6b916f181899199a1a9b1b9c1cb0b131b232b360811b901a6127b18486612a78565b90612c26565b7f427da25fe773164f88948d3e215c94b6554e2ed5e5f203a821c9f2f6131cf75a612c9a612a30565b906030612ca683612a5b565b536078612cb283612a68565b536041905b60018211612cca57610552915015612a96565b600f81169060108210156116bc57612cfc916f181899199a1a9b1b9c1cb0b131b232b360811b901a6127b18486612a78565b90612cb7565b15612d0957565b60405162461bcd60e51b815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201526d191e481a5b9a5d1a585b1a5e995960921b6064820152608490fd5b818110612d70575050565b60008155600101612d65565b90601f8211612d89575050565b6106df9160cf600052600080516020613d8c833981519152906020601f840160051c83019310612dc1575b601f0160051c0190612d65565b9091508190612db4565b9190601f8111612dda57505050565b6106df926000526020600020906020601f840160051c83019310612dc157601f0160051c0190612d65565b9081516001600160401b03811161049d57612e25816114b660cf5461043a565b602080601f8311600114612e615750819293600092612e56575b50508160011b916000199060031b1c19161760cf55565b015190503880612e3f565b90601f19831694612e8260cf600052600080516020613d8c83398151915290565b926000905b878210612ebf575050836001959610612ea6575b505050811b0160cf55565b015160001960f88460031b161c19169055388080612e9b565b80600185968294968601518155019501930190612e87565b6106df9291612f9b91600060ff815460081c16612ef381612ffc565b612efc81612ffc565b612f1060ff19918260335416603355612ffc565b8180526097602090815260408084206001600160a01b0386166000908152925290205460ff1615612fa0575b5050612f47816127d7565b612f508161288d565b612f59816128ee565b60018060a01b03166bffffffffffffffffffffffff60a01b60cc54161760cc5560018060a01b03166bffffffffffffffffffffffff60a01b60cd54161760cd55565b612e05565b8180526097602090815260408084206001600160a01b0386166000818152919093522080549290921660011790915533917f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d8180a43880612f3c565b1561300357565b60405162461bcd60e51b815260206004820152602b60248201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960448201526a6e697469616c697a696e6760a81b6064820152608490fd5b1561306357565b60405162461bcd60e51b815260206004820152602b60248201527f4d756c74694163636f756e743a2053656e6465722069736e2774206f776e657260448201526a081bd9881858d8dbdd5b9d60aa1b6064820152608490fd5b156130c357565b60405162461bcd60e51b815260206004820152601c60248201527f4d756c74694163636f756e743a20496e76616c696420746172676574000000006044820152606490fd5b1561310f57565b60405162461bcd60e51b815260206004820152601b60248201527f4d756c74694163636f756e743a20496e76616c696420737461746500000000006044820152606490fd5b600019810191908211611b7257565b91908203918211611b7257565b80518210156116bc5760209160051b010190565b90815180825260208080930193019160005b8281106131a4575050505090565b83516001600160e01b03191685529381019392810192600101613196565b6001600160a01b039182168152911660208201526080604082018190529092916000916060916131f491860190613184565b930152565b926132279160609396959660018060a01b038092168652166020850152608060408501526080840190613184565b931515910152565b6001600160a01b0391821681529116602082015260606040820181905261055292910190613184565b1561325f57565b60405162461bcd60e51b815260206004820152602860248201527f4d756c74694163636f756e743a205265766f6b6520616363657373206e6f74206044820152671c1c9bdc1bdcd95960c21b6064820152608490fd5b156132bc57565b60405162461bcd60e51b815260206004820152602260248201527f4d756c74694163636f756e743a20436f6f6c646f776e206e6f74207265616368604482015261195960f21b6064820152608490fd5b60ff6033541661331857565b60405162461bcd60e51b815260206004820152601060248201526f14185d5cd8589b194e881c185d5cd95960821b6044820152606490fd5b80546801000000000000000081101561049d576133749060019283820181556116a0565b61346757825181546001600160a01b0319166001600160a01b0391909116178155810191602080910151908151916001600160401b03831161049d576133c4836133be875461043a565b87612dcb565b81601f84116001146133fd57509282939183926000946133f2575b50501b916000199060031b1c1916179055565b0151925038806133df565b919083601f19811661341488600052602060002090565b946000905b8883831061344d5750505010613434575b505050811b019055565b015160001960f88460031b161c1916905538808061342a565b858701518855909601959485019487935090810190613419565b610424565b6001600160a01b039182168152911660208201526060604082018190526105529291019061051c565b60cf54600092916134a58261043a565b916001908181169081156134ff57506001146134c057505050565b909192935060cf600052600080516020613d8c833981519152906000915b8483106134ec575050500190565b81816020925485870152019201916134de565b60ff191683525050811515909102019150565b6020815191016000f56001600160a01b0381161561356757604080513381526001600160a01b03831660208201527f6cbd957809e2aaf4d5e36136d06e71215f53a984b218c6d501e22f91d348d9ce9190a190565b60405162461bcd60e51b815260206004820152601c60248201527f4d756c74694163636f756e743a2063726561746532206661696c6564000000006044820152606490fd5b908160209103126102ed5751610552816102dc565b6040513d6000823e3d90fd5b6040516323b872dd60e01b60208201526001600160a01b03928316602482015292909116604483015260648201929092526106df9161361982608481015b03601f1981018452836104d8565b613774565b908160209103126102ed575190565b1561363457565b60405162461bcd60e51b815260206004820152603660248201527f5361666545524332303a20617070726f76652066726f6d206e6f6e2d7a65726f60448201527520746f206e6f6e2d7a65726f20616c6c6f77616e636560501b6064820152608490fd5b919091811580156136e6575b6106df936136b46136199261362d565b60405163095ea7b360e01b60208201526001600160a01b0390911660248201526044810193909352826064810161360b565b50604051636eb1769f60e11b81523060048201526001600160a01b038416602482015292602084806044810103816001600160a01b0386165afa908115610c33576136b4613619926106df96600091613746575b501592505093506136a4565b613767915060203d811161376d575b61375f81836104d8565b81019061361e565b3861373a565b503d613755565b60018060a01b0316906137f160405161378c816104a2565b6020938482527f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564858301526000808587829751910182855af13d15613887573d916137d6836106e1565b926137e460405194856104d8565b83523d868885013e61388b565b90815190838215928315613864575b50505090501561380d5750565b6084906040519062461bcd60e51b82526004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b6064820152fd5b848092939450010312610625575081015161387e81610ff0565b80388381613800565b6060915b919290156138ed575081511561389f575090565b3b156138a85790565b60405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000006044820152606490fd5b8251909150156139005750805190602001fd5b60405162461bcd60e51b81529081906116869060048301610541565b908160209103126102ed575160ff811681036102ed5790565b60ff16604d8111611b7257600a0a90565b8115613950570490565b634e487b7160e01b600052601260045260246000fd5b6001600160a01b0391821681529116602082015260a06040820181905261055294926139949183019061051c565b9215156060820152608081840391015261051c565b60405163316fdd9760e11b815260009290918383806139cb8560048301610541565b0381836001600160a01b0386165af1938415610c335780938195613a34575b5050907f268e99f0b37c8146a6aea7c6af329e3924d9c92c4386be924c2990926d99b66191613a2185856040519485943386613966565b0390a115613a2c5750565b602081519101fd5b91945092503d8084833e613a4881836104d8565b81019260408285031261062557815191613a6183610ff0565b6020810151906001600160401b038211613aec570184601f82011215613ae857805191613a8d836106e1565b95613a9b60405197886104d8565b8387526020848401011161062557507f268e99f0b37c8146a6aea7c6af329e3924d9c92c4386be924c2990926d99b661939291613ade91602080880191016104f9565b92939091386139ea565b5080fd5b8280fd5b613af861330c565b60018060a01b039081811660005260209160cb83526040600020541691600092331415925b845160ff821690811015613ba65784613b39613b469288613170565b5190613b5a575b846139a9565b60ff809116908114611b7257600101613b1d565b613b68600482511015613bae565b613ba1613b9c613b9586840151611bf733611dbc8b60018060a01b031660005260d0602052604060002090565b5460ff1690565b613bfa565b613b40565b505050505050565b15613bb557565b60405162461bcd60e51b815260206004820152601f60248201527f4d756c74694163636f756e743a20496e76616c69642063616c6c2064617461006044820152606490fd5b15613c0157565b60405162461bcd60e51b815260206004820152602160248201527f4d756c74694163636f756e743a20556e617574686f72697a65642061636365736044820152607360f81b6064820152608490fd5b90613c5a82610f6a565b6040613c68815192836104d8565b8382528193613c79601f1991610f6a565b0191600091825b848110613c8e575050505050565b6020908251613c9c816104a2565b85815282606081830152828601015201613c80565b6000198114611b725760010190565b9060016020604051613cd1816104a2565b613cf88195848060a01b038154168352613cf16040518096819301611753565b03846104d8565b0152565b91908110156116bc5760061b0190565b15613d1357565b60405162461bcd60e51b815260206004820152602260248201527f4d756c74694163636f756e743a20526566657272616c20616c72656164792073604482015261195d60f21b6064820152608490fd5b90613d7b60209194939460408452604084019061051c565b6001600160a01b0390941691015256feacb8d954e2cfef495862221e91bd7523613cf8808827cb33edfe4904cc51bf2965d7a28e3265b37a6474929f336521b332c1681b933f6cb9f3376673440d862aa164736f6c6343000812000a
Loading...
Loading
Loading...
Loading
Loading...
Loading
Net Worth in USD
$0.00
Net Worth in MON
Multichain Portfolio | 35 Chains
| Chain | Token | Portfolio % | Price | Amount | Value |
|---|
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.