Overview
ETH Balance
0 ETH
Eth Value
$0.00More Info
Private Name Tags
ContractCreator
View more zero value Internal Transactions in Advanced View mode
Advanced mode:
Loading...
Loading
Contract Source Code Verified (Exact Match)
Contract Name:
UserData
Compiler Version
v0.8.9+commit.e5eed63a
Optimization Enabled:
Yes with 100 runs
Other Settings:
default evmVersion
Contract Source Code (Solidity Standard Json-Input format)
// SPDX-License-Identifier: MIT pragma solidity 0.8.9; import "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol"; import "@openzeppelin/contracts-upgradeable/access/AccessControlUpgradeable.sol"; import "./configuration/UserConfiguration.sol"; import "./interfaces/ILedger.sol"; import "./interfaces/IUserData.sol"; import "./libraries/math/MathUtils.sol"; import "./libraries/helpers/Errors.sol"; import "./types/DataTypes.sol"; contract UserData is IUserData, Initializable, AccessControlUpgradeable { using MathUtils for uint256; using MathUtils for int256; using UserConfiguration for DataTypes.UserConfiguration; uint256 public constant VERSION = 3; bytes32 public constant OPERATOR_ROLE = keccak256("OPERATOR_ROLE"); /// @dev Total reserve share supply, expressed in ray // pid => share supply mapping(uint256 => uint256) public totalReserveShareSupply; /// @dev Total collateral share supply, expressed in ray // pid => share supply mapping(uint256 => uint256) public totalCollateralShareSupply; // user => amount mapping(address => DataTypes.UserData) public userData; /// @dev Ledger ILedger public ledger; event SetLedger(address ledger); function initialize() external initializer onlyInitializing { _grantRole(DEFAULT_ADMIN_ROLE, msg.sender); } modifier onlyOperator() { require(hasRole(OPERATOR_ROLE, msg.sender), Errors.CALLER_NOT_OPERATOR); _; } function setLedger(address ledger_) external onlyOperator { require(address(ledger) == address(0), Errors.LEDGER_INITIALIZED); ledger = ILedger(ledger_); emit SetLedger(ledger_); } function depositReserve(address user, uint256 pid, uint256 amount, uint256 unit, uint256 currPoolSupply) external override onlyLedger { uint256 currTotalReserveShareSupply = totalReserveShareSupply[pid]; if (userData[user].reserveShares[pid] == 0) { userData[user].configuration.setUsingReserve(pid, true); } uint256 shares = _toShare( amount.unitToRay(unit), currTotalReserveShareSupply, currPoolSupply.unitToRay(unit) ); userData[user].reserveShares[pid] += shares; totalReserveShareSupply[pid] += shares; } function withdrawReserve(address user, uint256 pid, uint256 amount, uint256 unit, uint256 currPoolSupply) external override onlyLedger { uint256 currTotalReserveShareSupply = totalReserveShareSupply[pid]; uint256 shares = _toShare( amount.unitToRay(unit), currTotalReserveShareSupply, currPoolSupply.unitToRay(unit) ); require(shares <= userData[user].reserveShares[pid], Errors.NOT_ENOUGH_BALANCE); userData[user].reserveShares[pid] -= shares; totalReserveShareSupply[pid] -= shares; if (userData[user].reserveShares[pid] == 0) { userData[user].configuration.setUsingReserve(pid, false); } } function depositCollateral(address user, uint256 pid, uint256 amount, uint256 unit, uint256 currPoolSupply) external override onlyLedger { uint256 currTotalCollateralShareSupply = totalCollateralShareSupply[pid]; if (userData[user].collateralShares[pid] == 0) { userData[user].configuration.setUsingCollateral(pid, true); } uint256 shares = _toShare( amount.unitToRay(unit), currTotalCollateralShareSupply, currPoolSupply.unitToRay(unit) ); userData[user].collateralShares[pid] += shares; totalCollateralShareSupply[pid] += shares; } function withdrawCollateral(address user, uint256 pid, uint256 amount, uint256 currPoolSupply, uint256 unit) external override onlyLedger { uint256 currTotalCollateralShareSupply = totalCollateralShareSupply[pid]; uint256 shares = _toShare( amount.unitToRay(unit), currTotalCollateralShareSupply, currPoolSupply.unitToRay(unit) ); userData[user].collateralShares[pid] -= shares; totalCollateralShareSupply[pid] -= shares; if (userData[user].collateralShares[pid] == 0) { userData[user].configuration.setUsingCollateral(pid, false); } } // TODO: requires review function changePosition(address user, uint256 pid, int256 incomingPosition, uint256 borrowIndex, uint256 decimals) external override onlyLedger { int256 currNormalizedPositionRay = _normalizedPositionRay(userData[user].positions[pid], borrowIndex); int256 nextPositionRay = currNormalizedPositionRay + incomingPosition.unitToRay(decimals); userData[user].positions[pid] = _scaledPositionRay(nextPositionRay, borrowIndex); userData[user].configuration.setUsingPosition(pid, nextPositionRay != 0); } function getUserCollateralInternal(address user, uint256 pid, uint256 currPoolSupply, uint256 decimals) external view onlyLedger returns (uint256) { uint256 currUserCollateralShare = userData[user].collateralShares[pid]; if (currUserCollateralShare == 0) { return 0; } uint256 currTotalShareSupply = totalCollateralShareSupply[pid]; return _toAmount( currUserCollateralShare, currTotalShareSupply, currPoolSupply.unitToRay(decimals) ).rayToUnit(decimals); } function getUserPositionInternal(address user, uint256 pid, uint256 borrowIndex, uint256 decimals) external view override onlyLedger returns (int256) { return _normalizedPositionRay(userData[user].positions[pid], borrowIndex).rayToUnit(decimals); } function getUserConfiguration(address user) external view returns (DataTypes.UserConfiguration memory) { return userData[user].configuration; } function getUserReserve(address user, address asset, bool claimable) external view returns (uint256) { DataTypes.ReserveData memory reserve = ledger.getReserveData(asset); uint256 currUserReserveShare = userData[user].reserveShares[reserve.poolId]; if (currUserReserveShare == 0) { return 0; } DataTypes.AssetConfig memory assetConfig = ledger.getAssetConfiguration(asset); uint256 decimals = assetConfig.decimals; (uint256 currAvailableSupply,uint256 currPoolSupply,,,) = ledger.reserveSupplies(asset); uint256 currTotalShareSupply = totalReserveShareSupply[reserve.poolId]; uint256 balance = _toAmount( currUserReserveShare, currTotalShareSupply, currPoolSupply.unitToRay(decimals) ).rayToUnit(decimals); if (claimable) { if (balance > currAvailableSupply) { balance = currAvailableSupply; } } return balance; } function getUserCollateral(address user, address asset_, address reinvestment, bool claimable) external override view returns (uint256) { // resolve stack too deep; address asset = asset_; DataTypes.CollateralData memory collateral = ledger.getCollateralData(asset, reinvestment); uint256 currUserCollateralShare = userData[user].collateralShares[collateral.poolId]; if (currUserCollateralShare == 0) { return 0; } DataTypes.AssetConfig memory assetConfig = ledger.getAssetConfiguration(asset); uint256 decimals = assetConfig.decimals; uint256 currPoolSupply = ledger.collateralTotalSupply(asset, reinvestment); uint256 currTotalShareSupply = totalCollateralShareSupply[collateral.poolId]; uint256 balance = _toAmount( currUserCollateralShare, currTotalShareSupply, currPoolSupply.unitToRay(decimals) ).rayToUnit(decimals); if (claimable) { DataTypes.UserLiquidity memory currUserLiquidity = ledger.getUserLiquidity(user); if (currUserLiquidity.availableLeverageUsd <= 0) { return 0; } uint256 leverageFactor = ledger.getProtocolConfig().leverageFactor; (uint256 assetPrice, uint256 assetPriceUnit) = assetConfig.oracle.getAssetPrice(asset); uint256 ltvGwei = uint256(collateral.configuration.ltvGwei); uint256 maxAmount = uint256(currUserLiquidity.availableLeverageUsd) .wadDiv(leverageFactor) .wadDiv(ltvGwei.unitToWad(9)) .wadDiv(assetPrice.unitToWad(assetPriceUnit)) .wadToUnit(decimals); if (maxAmount < balance) { balance = maxAmount; } } return balance; } function getUserPosition(address user, address asset) external override view returns (int256) { DataTypes.ReserveData memory reserve = ledger.getReserveData(asset); DataTypes.AssetConfig memory assetConfig = ledger.getAssetConfiguration(asset); (,,uint256 borrowIndex) = ledger.getReserveIndexes(asset); return _normalizedPositionRay( userData[user].positions[reserve.poolId], borrowIndex ).rayToUnit(assetConfig.decimals); } function _normalizedPositionRay(int256 scaledPosition, uint256 borrowIndex) internal pure returns (int256) { if (scaledPosition < 0) { uint256 absNormalizedPosition = scaledPosition.abs().rayMul(borrowIndex); return int256(absNormalizedPosition) * (- 1); } else { return scaledPosition; } } function _scaledPositionRay(int256 normalizedPosition, uint256 borrowIndex) internal pure returns (int256) { if (normalizedPosition < 0) { uint256 absScaledPosition = normalizedPosition.abs().rayDiv(borrowIndex); return int256(absScaledPosition) * (-1); } else { return normalizedPosition; } } function _toShare(uint256 amount, uint256 shareSupply, uint256 poolSupply) internal pure returns (uint256) { if (poolSupply == 0) { return amount; } return amount * shareSupply / poolSupply; } function _toAmount(uint256 share, uint256 shareSupply, uint256 poolSupply) internal pure returns (uint256) { if (shareSupply == 0) { return share; } return share * poolSupply / shareSupply; } modifier onlyLedger() { require(address(ledger) == msg.sender, Errors.CALLER_NOT_LEDGER); _; } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.6.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] * ``` * 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. Equivalent to `reinitializer(1)`. */ modifier initializer() { bool isTopLevelCall = _setInitializedVersion(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. * * `initializer` is equivalent to `reinitializer(1)`, so 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. * * 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. */ modifier reinitializer(uint8 version) { bool isTopLevelCall = _setInitializedVersion(version); if (isTopLevelCall) { _initializing = true; } _; if (isTopLevelCall) { _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. */ function _disableInitializers() internal virtual { _setInitializedVersion(type(uint8).max); } function _setInitializedVersion(uint8 version) private returns (bool) { // If the contract is initializing we ignore whether _initialized is set in order to support multiple // inheritance patterns, but we only do this in the context of a constructor, and for the lowest level // of initializers, because in other contexts the contract may have been reentered. if (_initializing) { require( version == 1 && !AddressUpgradeable.isContract(address(this)), "Initializable: contract is already initialized" ); return false; } else { require(_initialized < version, "Initializable: contract is already initialized"); _initialized = version; return true; } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.6.0) (access/AccessControl.sol) pragma solidity ^0.8.0; import "./IAccessControlUpgradeable.sol"; import "../utils/ContextUpgradeable.sol"; import "../utils/StringsUpgradeable.sol"; import "../utils/introspection/ERC165Upgradeable.sol"; import "../proxy/utils/Initializable.sol"; /** * @dev Contract module that allows children to implement role-based access * control mechanisms. This is a lightweight version that doesn't allow enumerating role * members except through off-chain means by accessing the contract event logs. Some * applications may benefit from on-chain enumerability, for those cases see * {AccessControlEnumerable}. * * Roles are referred to by their `bytes32` identifier. These should be exposed * in the external API and be unique. The best way to achieve this is by * using `public constant` hash digests: * * ``` * 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}: * * ``` * 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. */ abstract contract AccessControlUpgradeable is Initializable, ContextUpgradeable, IAccessControlUpgradeable, ERC165Upgradeable { function __AccessControl_init() internal onlyInitializing { } function __AccessControl_init_unchained() internal onlyInitializing { } struct RoleData { mapping(address => bool) members; bytes32 adminRole; } mapping(bytes32 => RoleData) private _roles; bytes32 public constant DEFAULT_ADMIN_ROLE = 0x00; /** * @dev Modifier that checks that an account has a specific role. Reverts * with a standardized message including the required role. * * The format of the revert reason is given by the following regular expression: * * /^AccessControl: account (0x[0-9a-f]{40}) is missing role (0x[0-9a-f]{64})$/ * * _Available since v4.1._ */ modifier onlyRole(bytes32 role) { _checkRole(role); _; } /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { return interfaceId == type(IAccessControlUpgradeable).interfaceId || super.supportsInterface(interfaceId); } /** * @dev Returns `true` if `account` has been granted `role`. */ function hasRole(bytes32 role, address account) public view virtual override returns (bool) { return _roles[role].members[account]; } /** * @dev Revert with a standard message if `_msgSender()` is missing `role`. * Overriding this function changes the behavior of the {onlyRole} modifier. * * Format of the revert message is described in {_checkRole}. * * _Available since v4.6._ */ function _checkRole(bytes32 role) internal view virtual { _checkRole(role, _msgSender()); } /** * @dev Revert with a standard message if `account` is missing `role`. * * The format of the revert reason is given by the following regular expression: * * /^AccessControl: account (0x[0-9a-f]{40}) is missing role (0x[0-9a-f]{64})$/ */ function _checkRole(bytes32 role, address account) internal view virtual { if (!hasRole(role, account)) { revert( string( abi.encodePacked( "AccessControl: account ", StringsUpgradeable.toHexString(uint160(account), 20), " 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. */ 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. */ 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`. */ 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. * * [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. */ 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. */ 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 pragma solidity 0.8.9; import "../types/DataTypes.sol"; library UserConfiguration { function setUsingReserve( DataTypes.UserConfiguration storage self, uint256 bitIndex, bool usingReserve ) internal { self.reserve = (self.reserve & ~(1 << bitIndex)) | (uint256(usingReserve ? 1 : 0) << bitIndex); } function setUsingCollateral( DataTypes.UserConfiguration storage self, uint256 bitIndex, bool usingCollateral ) internal { self.collateral = (self.collateral & ~(1 << bitIndex)) | (uint256(usingCollateral ? 1 : 0) << bitIndex); } function setUsingPosition( DataTypes.UserConfiguration storage self, uint256 bitIndex, bool usingPosition ) internal { self.position = (self.position & ~(1 << bitIndex)) | (uint256(usingPosition ? 1 : 0) << bitIndex); } function isUsingReserve( DataTypes.UserConfiguration memory self, uint256 bitIndex ) internal pure returns (bool) { return (self.reserve >> bitIndex) & 1 != 0; } function isUsingCollateral( DataTypes.UserConfiguration memory self, uint256 bitIndex ) internal pure returns (bool) { return (self.collateral >> bitIndex) & 1 != 0; } function isUsingPosition( DataTypes.UserConfiguration memory self, uint256 bitIndex ) internal pure returns (bool) { return (self.position >> bitIndex) & 1 != 0; } function hasReserve( DataTypes.UserConfiguration memory self, uint256 offSetIndex ) internal pure returns (bool) { return (self.reserve >> offSetIndex) > 0; } function hasCollateral( DataTypes.UserConfiguration memory self, uint256 offSetIndex ) internal pure returns (bool) { return (self.collateral >> offSetIndex) > 0; } function hasPosition( DataTypes.UserConfiguration memory self, uint256 offSetIndex ) internal pure returns (bool) { return (self.position >> offSetIndex) > 0; } function isEmpty(DataTypes.UserConfiguration memory self) internal pure returns (bool) { return self.reserve == 0 && self.collateral == 0 && self.position == 0; } }
// SPDX-License-Identifier: MIT pragma solidity 0.8.9; import "../types/DataTypes.sol"; interface ILedger { function getProtocolConfig() external view returns (DataTypes.ProtocolConfig memory); function setProtocolConfig(DataTypes.ProtocolConfig memory config) external; function initAssetConfiguration(address asset) external returns (uint256 assetId); function setAssetConfiguration(address asset, DataTypes.AssetConfig memory configuration) external; function initReserve(address asset) external returns (uint256 poolId); function initCollateral(address asset, address reinvestment) external returns (uint256 poolId); function setReserveBonusPool(uint256 poolId, address newBonusPool) external; function setReserveReinvestment(uint256 poolId, address newReinvestment) external; function setReserveLongReinvestment(uint256 poolId, address newReinvestment) external; function setCollateralReinvestment(uint256 poolId, address newReinvestment) external; function setReserveConfiguration(uint256 poolId, DataTypes.ReserveConfiguration memory configuration) external; function setCollateralConfiguration(uint256 poolId, DataTypes.CollateralConfiguration memory configuration) external; function managePoolReinvestment(uint256 actionId, uint256 poolId) external; function getAssetConfiguration(address asset) external view returns (DataTypes.AssetConfig memory); function getReserveData(address asset) external view returns (DataTypes.ReserveData memory); function getCollateralData(address asset, address reinvestment) external view returns (DataTypes.CollateralData memory); function getReserveIndexes(address asset) external view returns (uint256, uint256, uint256); function reserveSupplies(address asset) external view returns (uint256, uint256, uint256, uint256, uint256); function collateralTotalSupply(address asset, address reinvestment) external view returns (uint256); function getUserLiquidity(address user) external view returns (DataTypes.UserLiquidity memory); function depositReserve(address asset, uint256 amount) external; }
// SPDX-License-Identifier: MIT pragma solidity 0.8.9; import "../types/DataTypes.sol"; interface IUserData { function depositReserve( address user, uint256 pid, uint256 amount, uint256 decimals, uint256 currReserveSupply ) external; function withdrawReserve( address user, uint256 pid, uint256 amount, uint256 decimals, uint256 currReserveSupply ) external; function depositCollateral( address user, uint256 pid, uint256 amount, uint256 decimals, uint256 currReserveSupply ) external; function withdrawCollateral( address user, uint256 pid, uint256 amount, uint256 currReserveSupply, uint256 decimals ) external; function changePosition( address user, uint256 pid, int256 incomingPosition, uint256 borrowIndex, uint256 decimals ) external; function getUserConfiguration(address user) external view returns (DataTypes.UserConfiguration memory); function getUserReserve(address user, address asset, bool claimable) external view returns (uint256); function getUserCollateral(address user, address asset, address reinvestment, bool claimable) external view returns (uint256); function getUserCollateralInternal(address user, uint256 pid, uint256 currPoolSupply, uint256 decimals) external view returns (uint256); function getUserPosition(address user, address asset) external view returns (int256); function getUserPositionInternal(address user, uint256 pid, uint256 borrowIndex, uint256 decimals) external view returns (int256); }
// SPDX-License-Identifier: MIT pragma solidity 0.8.9; /** * @dev Provides mul and div function for wads (decimal numbers with 18 digits precision) and rays (decimals with 27 digits) **/ library MathUtils { uint256 public constant VERSION = 1; uint256 internal constant WAD_UNIT = 18; uint256 internal constant RAY_UNIT = 27; uint256 internal constant WAD_RAY_RATIO = 1e9; uint256 public constant WAD = 1e18; uint256 public constant RAY = 1e27; uint256 public constant HALF_WAD = WAD / 2; uint256 public constant HALF_RAY = RAY / 2; /** * @notice Multiplies two wad, rounding half up to the nearest wad * @param a Wad * @param b Wad * @return The result of a*b, in wad **/ function wadMul(uint256 a, uint256 b) internal pure returns (uint256) { if (a == 0 || b == 0) { return 0; } require(a <= (type(uint256).max - HALF_WAD) / b, "MathUtils: overflow"); return (a * b + HALF_WAD) / WAD; } /** * @notice Divides two wad, rounding half up to the nearest wad * @param a Wad * @param b Wad * @return The result of a/b, in wad **/ function wadDiv(uint256 a, uint256 b) internal pure returns (uint256) { require(b != 0, "MathUtils: division by zero"); uint256 halfB = b / 2; require(a <= (type(uint256).max - halfB) / WAD, "MathUtils: overflow"); return (a * WAD + halfB) / b; } /** * @notice Multiplies two ray, rounding half up to the nearest ray * @param a Ray * @param b Ray * @return The result of a*b, in ray **/ function rayMul(uint256 a, uint256 b) internal pure returns (uint256) { if (a == 0 || b == 0) { return 0; } require(a <= (type(uint256).max - HALF_RAY) / b, "MathUtils: overflow"); return (a * b + HALF_RAY) / RAY; } /** * @notice Divides two ray, rounding half up to the nearest ray * @param a Ray * @param b Ray * @return The result of a/b, in ray **/ function rayDiv(uint256 a, uint256 b) internal pure returns (uint256) { require(b != 0, "MathUtils: division by zero"); uint256 halfB = b / 2; require(a <= (type(uint256).max - halfB) / RAY, "MathUtils: overflow"); return (a * RAY + halfB) / b; } /** * @notice Casts ray down to wad * @param a Ray * @return a casted to wad, rounded half up to the nearest wad **/ function rayToWad(uint256 a) internal pure returns (uint256) { uint256 halfRatio = WAD_RAY_RATIO / 2; uint256 result = halfRatio + a; require(result >= halfRatio, "MathUtils: overflow"); return result / WAD_RAY_RATIO; } /** * @notice Converts wad up to ray * @param a Wad * @return a converted in ray **/ function wadToRay(uint256 a) internal pure returns (uint256) { uint256 result = a * WAD_RAY_RATIO; require(result / WAD_RAY_RATIO == a, "MathUtils: overflow"); return result; } /** * @notice Converts unit to wad * @param self Value * @param unit Value's unit * @return value converted in wad **/ function unitToWad(uint256 self, uint256 unit) internal pure returns (uint256) { if (self == 0 || unit == WAD_UNIT) return self; if (unit < WAD_UNIT) { return self * 10**(WAD_UNIT - unit); } else { return self / 10**(unit - WAD_UNIT); } } /** * @notice Converts unit to ray * @param self Value * @param unit Value's unit * @return value converted in ray **/ function unitToRay(uint256 self, uint256 unit) internal pure returns (uint256) { if (self == 0 || unit == RAY_UNIT) return self; if (unit < RAY_UNIT) { return self * 10**(RAY_UNIT -unit); } else { return self / 10**(unit - RAY_UNIT); } } /** * @notice Converts unit to ray * @param self Value * @param unit Value's unit * @return value converted in ray **/ function unitToRay(int256 self, uint256 unit) internal pure returns (int256) { if (self == 0 || unit == RAY_UNIT) return self; if (unit < RAY_UNIT) { return self * int256(10**(RAY_UNIT -unit)); } else { return self / int256(10**(unit - RAY_UNIT)); } } /** * @notice Converts wad to unit * @param self Value * @param unit Value's unit * @return value converted in unit **/ function wadToUnit(uint256 self, uint256 unit) internal pure returns (uint256) { if (self == 0 || unit == WAD) return self; if (unit < WAD_UNIT) { return self / 10**(WAD_UNIT - unit); } else { return self * 10**(unit - WAD_UNIT); } } /** * @notice Converts ray to unit * @param self Value * @param unit Value's unit * @return value converted in unit **/ function rayToUnit(uint256 self, uint256 unit) internal pure returns (uint256) { if (self == 0 || unit == RAY_UNIT) return self; if (unit < RAY_UNIT) { return self / 10**(RAY_UNIT - unit); } else { return self * 10**(unit - RAY_UNIT); } } /** * @notice Converts ray to unit * @param self Value * @param unit Value's unit * @return value converted in unit **/ function rayToUnit(int256 self, uint256 unit) internal pure returns (int256) { if (self == 0 || unit == RAY_UNIT) return self; if (unit < RAY_UNIT) { return self / int256(10**(RAY_UNIT - unit)); } else { return self * int256(10**(unit - RAY_UNIT)); } } function abs(int256 a) internal pure returns (uint256) { if (a < 0) { return uint256(a * (-1)); } else { return uint256(a); } } }
// SPDX-License-Identifier: MIT pragma solidity 0.8.9; library Errors { string public constant LEDGER_INITIALIZED = 'LEDGER_INITIALIZED'; string public constant CALLER_NOT_OPERATOR = 'CALLER_NOT_OPERATOR'; string public constant CALLER_NOT_LIQUIDATE_EXECUTOR = 'CALLER_NOT_LIQUIDATE_EXECUTOR'; string public constant CALLER_NOT_CONFIGURATOR = 'CALLER_NOT_CONFIGURATOR'; string public constant CALLER_NOT_WHITELISTED = 'CALLER_NOT_WHITELISTED'; string public constant CALLER_NOT_LEDGER = 'ONLY_LEDGER'; string public constant INVALID_LEVERAGE_FACTOR = 'INVALID_LEVERAGE_FACTOR'; string public constant INVALID_LIQUIDATION_RATIO = 'INVALID_LIQUIDATION_RATIO'; string public constant INVALID_TRADE_FEE = 'INVALID_TRADE_FEE'; string public constant INVALID_ZERO_ADDRESS = 'INVALID_ZERO_ADDRESS'; string public constant INVALID_ASSET_CONFIGURATION = 'INVALID_ASSET_CONFIGURATION'; string public constant ASSET_INACTIVE = 'ASSET_INACTIVE'; string public constant ASSET_ACTIVE = 'ASSET_ACTIVE'; string public constant POOL_INACTIVE = 'POOL_INACTIVE'; string public constant POOL_ACTIVE = 'POOL_ACTIVE'; string public constant POOL_EXIST = 'POOL_EXIST'; string public constant INVALID_POOL_REINVESTMENT = 'INVALID_POOL_REINVESTMENT'; string public constant ASSET_INITIALIZED = 'ASSET_INITIALIZED'; string public constant ASSET_NOT_INITIALIZED = 'ASSET_NOT_INITIALIZED'; string public constant POOL_INITIALIZED = 'POOL_INITIALIZED'; string public constant POOL_NOT_INITIALIZED = 'POOL_NOT_INITIALIZED'; string public constant INVALID_ZERO_AMOUNT = 'INVALID_ZERO_AMOUNT'; string public constant CANNOT_SWEEP_REGISTERED_ASSET = 'CANNOT_SWEEP_REGISTERED_ASSET'; string public constant INVALID_ACTION_ID = 'INVALID_ACTION_ID'; string public constant INVALID_POSITION_TYPE = 'INVALID_POSITION_TYPE'; string public constant INVALID_AMOUNT_INPUT = 'INVALID_AMOUNT_INPUT'; string public constant INVALID_ASSET_INPUT = 'INVALID_ASSET_INPUT'; string public constant INVALID_SWAP_BUFFER_LIMIT = 'INVALID_SWAP_BUFFER_LIMIT'; string public constant NOT_ENOUGH_BALANCE = 'NOT_ENOUGH_BALANCE'; string public constant NOT_ENOUGH_LONG_BALANCE = 'NOT_ENOUGH_LONG_BALANCE'; string public constant NOT_ENOUGH_POOL_BALANCE = 'NOT_ENOUGH_POOL_BALANCE'; string public constant NOT_ENOUGH_USER_LEVERAGE = 'NOT_ENOUGH_USER_LEVERAGE'; string public constant MISSING_UNDERLYING_ASSET = 'MISSING_UNDERLYING_ASSET'; string public constant NEGATIVE_PNL = 'NEGATIVE_PNL'; string public constant NEGATIVE_AVAILABLE_LEVERAGE = 'NEGATIVE_AVAILABLE_LEVERAGE'; string public constant BAD_TRADE = 'BAD_TRADE'; string public constant USER_TRADE_BLOCK = 'USER_TRADE_BLOCK'; string public constant ERROR_EMERGENCY_WITHDRAW = 'ERROR_EMERGENCY_WITHDRAW'; string public constant ERROR_UNWRAP_LP = 'ERROR_UNWRAP_LP'; string public constant CANNOT_TRADE_SAME_ASSET = 'CANNOT_TRADE_SAME_ASSET'; }
// SPDX-License-Identifier: MIT pragma solidity 0.8.9; import "../interfaces/ISwapAdapter.sol"; import "../interfaces/IPriceOracleGetter.sol"; import "../interfaces/IReinvestment.sol"; import "../interfaces/IBonusPool.sol"; import "../interfaces/IUserData.sol"; /// @dev This help resolves cyclic dependencies library DataTypes { uint256 public constant VERSION = 1; address public constant LIQUIDATION_WALLET = 0x0000000000000000000000000000000000000001; enum AssetState {Disabled, Active, Withdrawing} enum PositionType {Long, Short} enum AssetMode {Disabled, OnlyReserve, OnlyLong, ReserveAndLong} enum AssetKind {SingleStable, SingleVolatile, LP} struct AssetStorage { uint256 assetsCount; mapping(uint256 => address) assetsList; mapping(address => DataTypes.AssetConfig) assetConfigs; } struct ReserveStorage { uint256 reservesCount; mapping(address => uint256) reservesList; mapping(uint256 => DataTypes.ReserveData) reserves; } struct CollateralStorage { uint256 collateralsCount; mapping(address => mapping(address => uint256)) collateralsList; mapping(uint256 => DataTypes.CollateralData) collaterals; } struct ProtocolConfig { address treasury; address configuratorAddress; address userData; uint256 leverageFactor; uint256 tradeFeeMantissa; uint256 liquidationRatioMantissa; uint256 swapBufferLimitPercentage; } struct MappingStorage { mapping(address => bool) whitelistedCallers; mapping(address => uint256) userLastTradeBlock; mapping(address => uint256) liquidatedCollaterals; } // Shared property of reserve, collateral and portfolio struct AssetConfig { uint256 assetId; uint8 decimals; AssetKind kind; ISwapAdapter swapAdapter; IPriceOracleGetter oracle; } struct ReserveConfiguration { uint32 depositFeeMantissaGwei; uint32 protocolRateMantissaGwei; uint32 utilizationBaseRateMantissaGwei; uint32 kinkMantissaGwei; uint32 multiplierAnnualGwei; uint32 jumpMultiplierAnnualGwei; // --- 208 bits used --- AssetState state; AssetMode mode; } struct ReserveDataExtension { address reinvestment; address longReinvestment; address bonusPool; } struct ReserveData { ReserveConfiguration configuration; ReserveDataExtension ext; address asset; uint256 poolId; uint256 liquidSupply; // scaled utilized supply on reserve, changes whenever a deposit, withdraw, borrow and repay is executed uint256 scaledUtilizedSupplyRay; uint256 longSupply; uint256 reserveIndexRay; uint256 utilizationPercentageRay; uint256 protocolIndexRay; uint256 lastUpdatedTimestamp; } struct ReserveDataCache { address asset; address reinvestment; address longReinvestment; uint256 currReserveIndexRay; uint256 currProtocolIndexRay; uint256 currBorrowIndexRay; } struct CollateralConfiguration { uint32 depositFeeMantissaGwei; uint32 ltvGwei; uint128 minBalance; // --- 192 bits used --- AssetState state; } struct CollateralData { CollateralConfiguration configuration; address asset; address reinvestment; uint256 poolId; uint256 liquidSupply; uint256 totalShareSupplyRay; } struct UserConfiguration { uint256 reserve; uint256 collateral; uint256 position; } struct UserData { UserConfiguration configuration; mapping(uint256 => uint256) reserveShares; // in ray mapping(uint256 => uint256) collateralShares; // in ray mapping(uint256 => int256) positions; // in ray } struct InitReserveData { address reinvestment; address bonusPool; address longReinvestment; uint32 depositFeeMantissa; uint32 protocolRateMantissaRay; uint32 utilizationBaseRateMantissaRay; uint32 kinkMantissaRay; uint32 multiplierAnnualRay; uint32 jumpMultiplierAnnualRay; AssetState state; AssetMode mode; } struct ValidateTradeParams { address user; uint256 amountToTrade; uint256 currShortReserveAvailableSupply; uint256 maxAmountToTrade; uint256 userLastTradeBlock; } struct UserLiquidity { uint256 totalCollateralUsdPreLtv; uint256 totalCollateralUsdPostLtv; uint256 totalLongUsd; uint256 totalShortUsd; int256 pnlUsd; int256 totalLeverageUsd; int256 availableLeverageUsd; bool isLiquidatable; } struct UserLiquidityCachedData { int256 currShortingPosition; int256 currLongingPosition; uint256 shortingPrice; uint256 shortingPriceDecimals; uint256 longingPrice; uint256 longingPriceDecimals; } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.5.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 * ==== * * [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://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more]. * * IMPORTANT: because control is transferred to `recipient`, care must be * taken to not create reentrancy vulnerabilities. Consider using * {ReentrancyGuard} or the * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. */ function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, "Address: insufficient balance"); (bool success, ) = recipient.call{value: amount}(""); require(success, "Address: unable to send value, recipient may have reverted"); } /** * @dev Performs a Solidity function call using a low level `call`. A * plain `call` is an unsafe replacement for a function call: use this * function instead. * * If `target` reverts with a revert reason, it is bubbled up by this * function (like regular Solidity function calls). * * Returns the raw returned data. To convert to the expected return value, * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`]. * * Requirements: * * - `target` must be a contract. * - calling `target` with `data` must not revert. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCall(target, data, "Address: low-level call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with * `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { return functionCallWithValue(target, data, 0, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but also transferring `value` wei to `target`. * * Requirements: * * - the calling contract must have an ETH balance of at least `value`. * - the called Solidity function must be `payable`. * * _Available since v3.1._ */ function functionCallWithValue( address target, bytes memory data, uint256 value ) internal returns (bytes memory) { return functionCallWithValue(target, data, value, "Address: low-level call with value failed"); } /** * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but * with `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCallWithValue( address target, bytes memory data, uint256 value, string memory errorMessage ) internal returns (bytes memory) { require(address(this).balance >= value, "Address: insufficient balance for call"); require(isContract(target), "Address: call to non-contract"); (bool success, bytes memory returndata) = target.call{value: value}(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) { return functionStaticCall(target, data, "Address: low-level static call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall( address target, bytes memory data, string memory errorMessage ) internal view returns (bytes memory) { require(isContract(target), "Address: static call to non-contract"); (bool success, bytes memory returndata) = target.staticcall(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the * revert reason 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 { // Look for revert reason and bubble it up if present if (returndata.length > 0) { // The easiest way to bubble the revert reason is using memory via assembly assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } } }
// SPDX-License-Identifier: 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 (utils/Context.sol) pragma solidity ^0.8.0; import "../proxy/utils/Initializable.sol"; /** * @dev Provides information about the current execution context, including the * sender of the transaction and its data. While these are generally available * via msg.sender and msg.data, they should not be accessed in such a direct * manner, since when dealing with meta-transactions the account sending and * paying for execution may not be the actual sender (as far as an application * is concerned). * * This contract is only required for intermediate, library-like contracts. */ abstract contract ContextUpgradeable is Initializable { function __Context_init() internal onlyInitializing { } function __Context_init_unchained() internal onlyInitializing { } function _msgSender() internal view virtual returns (address) { return msg.sender; } function _msgData() internal view virtual returns (bytes calldata) { return msg.data; } /** * @dev This empty reserved space is put in place to allow future versions to add new * variables without shifting down storage in the inheritance chain. * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps */ uint256[50] private __gap; }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/Strings.sol) pragma solidity ^0.8.0; /** * @dev String operations. */ library StringsUpgradeable { bytes16 private constant _HEX_SYMBOLS = "0123456789abcdef"; /** * @dev Converts a `uint256` to its ASCII `string` decimal representation. */ function toString(uint256 value) internal pure returns (string memory) { // Inspired by OraclizeAPI's implementation - MIT licence // https://github.com/oraclize/ethereum-api/blob/b42146b063c7d6ee1358846c198246239e9360e8/oraclizeAPI_0.4.25.sol if (value == 0) { return "0"; } uint256 temp = value; uint256 digits; while (temp != 0) { digits++; temp /= 10; } bytes memory buffer = new bytes(digits); while (value != 0) { digits -= 1; buffer[digits] = bytes1(uint8(48 + uint256(value % 10))); value /= 10; } return string(buffer); } /** * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation. */ function toHexString(uint256 value) internal pure returns (string memory) { if (value == 0) { return "0x00"; } uint256 temp = value; uint256 length = 0; while (temp != 0) { length++; temp >>= 8; } return toHexString(value, length); } /** * @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] = _HEX_SYMBOLS[value & 0xf]; value >>= 4; } require(value == 0, "Strings: hex length insufficient"); return string(buffer); } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/introspection/ERC165.sol) pragma solidity ^0.8.0; import "./IERC165Upgradeable.sol"; import "../../proxy/utils/Initializable.sol"; /** * @dev Implementation of the {IERC165} interface. * * Contracts that want to implement ERC165 should inherit from this contract and override {supportsInterface} to check * for the additional interface id that will be supported. For example: * * ```solidity * function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { * return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId); * } * ``` * * Alternatively, {ERC165Storage} provides an easier to use but more expensive implementation. */ abstract contract ERC165Upgradeable is Initializable, IERC165Upgradeable { function __ERC165_init() internal onlyInitializing { } function __ERC165_init_unchained() internal onlyInitializing { } /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { return interfaceId == type(IERC165Upgradeable).interfaceId; } /** * @dev This empty reserved space is put in place to allow future versions to add new * variables without shifting down storage in the inheritance chain. * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps */ uint256[50] private __gap; }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/introspection/IERC165.sol) pragma solidity ^0.8.0; /** * @dev Interface of the ERC165 standard, as defined in the * https://eips.ethereum.org/EIPS/eip-165[EIP]. * * Implementers can declare support of contract interfaces, which can then be * queried by others ({ERC165Checker}). * * For an implementation, see {ERC165}. */ interface IERC165Upgradeable { /** * @dev Returns true if this contract implements the interface defined by * `interfaceId`. See the corresponding * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section] * to learn more about how these ids are created. * * This function call must use less than 30 000 gas. */ function supportsInterface(bytes4 interfaceId) external view returns (bool); }
// SPDX-License-Identifier: MIT pragma solidity 0.8.9; interface ISwapAdapter { function swap( address selling, address buying, uint256 amount, bytes memory data ) external returns (uint256); }
// SPDX-License-Identifier: MIT pragma solidity 0.8.9; interface IPriceOracleGetter { function getAssetPrice(address asset) external view returns (uint256, uint256); }
// SPDX-License-Identifier: MIT pragma solidity 0.8.9; interface IReinvestmentProxy { function owner() external view returns (address); function logic() external view returns (address); function setLogic() external view returns (address); function supportedInterfaceId() external view returns (bytes4); } interface IReinvestmentLogic { event UpdatedTreasury(address oldAddress, address newAddress); event UpdatedFeeMantissa(uint256 oldFee, uint256 newFee); struct Reward { address asset; uint256 claimable; } function setTreasury(address treasury_) external; function setFeeMantissa(uint256 feeMantissa_) external; function asset() external view returns (address); function treasury() external view returns (address); function ledger() external view returns (address); function feeMantissa() external view returns (uint256); function receipt() external view returns (address); function platform() external view returns (address); function rewardOf(address, uint256) external view returns (Reward[] memory); function rewardLength() external view returns (uint256); function totalSupply() external view returns (uint256); function claim(address, uint256) external; function checkpoint(address, uint256) external; function invest(uint256) external; function divest(uint256) external; function emergencyWithdraw() external returns (uint256); function sweep(address) external; } interface IReinvestment is IReinvestmentProxy, IReinvestmentLogic {}
// SPDX-License-Identifier: MIT pragma solidity 0.8.9; interface IBonusPool { function updatePoolUser(address _token, address _account, uint256 _amount) external; }
{ "optimizer": { "enabled": true, "runs": 100 }, "outputSelection": { "*": { "*": [ "evm.bytecode", "evm.deployedBytecode", "devdoc", "userdoc", "metadata", "abi" ] } }, "libraries": {} }
Contract Security Audit
- No Contract Security Audit Submitted- Submit Audit Here
Contract ABI
API[{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint8","name":"version","type":"uint8"}],"name":"Initialized","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"bytes32","name":"previousAdminRole","type":"bytes32"},{"indexed":true,"internalType":"bytes32","name":"newAdminRole","type":"bytes32"}],"name":"RoleAdminChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":true,"internalType":"address","name":"sender","type":"address"}],"name":"RoleGranted","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":true,"internalType":"address","name":"sender","type":"address"}],"name":"RoleRevoked","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"ledger","type":"address"}],"name":"SetLedger","type":"event"},{"inputs":[],"name":"DEFAULT_ADMIN_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"OPERATOR_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"VERSION","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"user","type":"address"},{"internalType":"uint256","name":"pid","type":"uint256"},{"internalType":"int256","name":"incomingPosition","type":"int256"},{"internalType":"uint256","name":"borrowIndex","type":"uint256"},{"internalType":"uint256","name":"decimals","type":"uint256"}],"name":"changePosition","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"user","type":"address"},{"internalType":"uint256","name":"pid","type":"uint256"},{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"uint256","name":"unit","type":"uint256"},{"internalType":"uint256","name":"currPoolSupply","type":"uint256"}],"name":"depositCollateral","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"user","type":"address"},{"internalType":"uint256","name":"pid","type":"uint256"},{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"uint256","name":"unit","type":"uint256"},{"internalType":"uint256","name":"currPoolSupply","type":"uint256"}],"name":"depositReserve","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"}],"name":"getRoleAdmin","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"user","type":"address"},{"internalType":"address","name":"asset_","type":"address"},{"internalType":"address","name":"reinvestment","type":"address"},{"internalType":"bool","name":"claimable","type":"bool"}],"name":"getUserCollateral","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"user","type":"address"},{"internalType":"uint256","name":"pid","type":"uint256"},{"internalType":"uint256","name":"currPoolSupply","type":"uint256"},{"internalType":"uint256","name":"decimals","type":"uint256"}],"name":"getUserCollateralInternal","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"user","type":"address"}],"name":"getUserConfiguration","outputs":[{"components":[{"internalType":"uint256","name":"reserve","type":"uint256"},{"internalType":"uint256","name":"collateral","type":"uint256"},{"internalType":"uint256","name":"position","type":"uint256"}],"internalType":"struct DataTypes.UserConfiguration","name":"","type":"tuple"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"user","type":"address"},{"internalType":"address","name":"asset","type":"address"}],"name":"getUserPosition","outputs":[{"internalType":"int256","name":"","type":"int256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"user","type":"address"},{"internalType":"uint256","name":"pid","type":"uint256"},{"internalType":"uint256","name":"borrowIndex","type":"uint256"},{"internalType":"uint256","name":"decimals","type":"uint256"}],"name":"getUserPositionInternal","outputs":[{"internalType":"int256","name":"","type":"int256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"user","type":"address"},{"internalType":"address","name":"asset","type":"address"},{"internalType":"bool","name":"claimable","type":"bool"}],"name":"getUserReserve","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"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":[],"name":"initialize","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"ledger","outputs":[{"internalType":"contract ILedger","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":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"revokeRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"ledger_","type":"address"}],"name":"setLedger","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes4","name":"interfaceId","type":"bytes4"}],"name":"supportsInterface","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"totalCollateralShareSupply","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"totalReserveShareSupply","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"userData","outputs":[{"components":[{"internalType":"uint256","name":"reserve","type":"uint256"},{"internalType":"uint256","name":"collateral","type":"uint256"},{"internalType":"uint256","name":"position","type":"uint256"}],"internalType":"struct DataTypes.UserConfiguration","name":"configuration","type":"tuple"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"user","type":"address"},{"internalType":"uint256","name":"pid","type":"uint256"},{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"uint256","name":"currPoolSupply","type":"uint256"},{"internalType":"uint256","name":"unit","type":"uint256"}],"name":"withdrawCollateral","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"user","type":"address"},{"internalType":"uint256","name":"pid","type":"uint256"},{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"uint256","name":"unit","type":"uint256"},{"internalType":"uint256","name":"currPoolSupply","type":"uint256"}],"name":"withdrawReserve","outputs":[],"stateMutability":"nonpayable","type":"function"}]
Contract Creation Code
608060405234801561001057600080fd5b50612c3e806100206000396000f3fe608060405234801561001057600080fd5b506004361061016d5760003560e01c80639f50de30116100ce578063d547741f11610087578063d547741f14610369578063d67622ff1461037c578063dc2673841461038f578063dcaa1f12146103a2578063e7d7bf07146103c2578063f5b541a6146103d5578063ffa1ad74146103fc57600080fd5b80639f50de30146102cf578063a217fddf146102e2578063a68bce57146102ea578063be55e0fd146102fd578063c891091314610310578063d482f9301461035657600080fd5b806336568abe1161012b57806336568abe146102265780634417a5831461023957806356397c351461026e578063629a839d1461028e5780638129fc1c146102a157806391d14854146102a957806392a576e6146102bc57600080fd5b806209acc31461017257806301ffc9a7146101a5578063248a9ca3146101c85780632a4f2cde146101eb5780632f2ff15d146102005780633246887d14610213575b600080fd5b610192610180366004611f67565b60976020526000908152604090205481565b6040519081526020015b60405180910390f35b6101b86101b3366004611f80565b610404565b604051901515815260200161019c565b6101926101d6366004611f67565b60009081526065602052604090206001015490565b6101fe6101f9366004611fbf565b61043b565b005b6101fe61020e366004612003565b610578565b6101fe610221366004612033565b6105a2565b6101fe610234366004612003565b6106c2565b61024c610247366004612033565b610740565b604080518251815260208084015190820152918101519082015260600161019c565b609a54610281906001600160a01b031681565b60405161019c9190612050565b61019261029c366004612064565b6107a6565b6101fe610867565b6101b86102b7366004612003565b610946565b6101926102ca36600461209f565b610971565b6101fe6102dd366004611fbf565b610b5a565b610192600081565b6101926102f83660046120db565b610c70565b61019261030b366004612126565b610e9c565b61024c61031e366004612033565b609960209081526000918252604091829020825160608101845281548152600182015492810192909252600201549181019190915281565b610192610364366004612064565b6112ea565b6101fe610377366004612003565b61137b565b6101fe61038a366004611fbf565b6113a0565b6101fe61039d366004611fbf565b61148b565b6101926103b0366004611f67565b60986020526000908152604090205481565b6101fe6103d0366004611fbf565b611619565b6101927f97667070c54ef182b0f5858b034beac1b6f3089aa2d3188bb1e8929f4fa9b92981565b610192600381565b60006001600160e01b03198216637965db0b60e01b148061043557506301ffc9a760e01b6001600160e01b03198316145b92915050565b609a5460408051808201909152600b81526a27a7262cafa622a223a2a960a91b6020820152906001600160a01b031633146104925760405162461bcd60e51b815260040161048991906121b2565b60405180910390fd5b506000848152609860209081526040808320546001600160a01b038916845260998352818420888552600401909252909120546104ed576001600160a01b03861660009081526099602052604090206104ed9086600161173d565b600061050c6104fc868661176c565b83610507868861176c565b6117d7565b6001600160a01b03881660009081526099602090815260408083208a84526004019091528120805492935083929091906105479084906121fb565b90915550506000868152609860205260408120805483929061056a9084906121fb565b909155505050505050505050565b600082815260656020526040902060010154610593816117fa565b61059d8383611804565b505050565b6105cc7f97667070c54ef182b0f5858b034beac1b6f3089aa2d3188bb1e8929f4fa9b92933610946565b6040518060400160405280601381526020017221a0a62622a92fa727aa2fa7a822a920aa27a960691b815250906106165760405162461bcd60e51b815260040161048991906121b2565b50609a5460408051808201909152601281527113115111d15497d25392551250531256915160721b6020820152906001600160a01b03161561066b5760405162461bcd60e51b815260040161048991906121b2565b50609a80546001600160a01b0319166001600160a01b0383161790556040517f90b03a813aad27839e6166b75a4afe364137df14d9c35f60b3fc58b278c0aae6906106b7908390612050565b60405180910390a150565b6001600160a01b03811633146107325760405162461bcd60e51b815260206004820152602f60248201527f416363657373436f6e74726f6c3a2063616e206f6e6c792072656e6f756e636560448201526e103937b632b9903337b91039b2b63360891b6064820152608401610489565b61073c828261188a565b5050565b61076460405180606001604052806000815260200160008152602001600081525090565b506001600160a01b0316600090815260996020908152604091829020825160608101845281548152600182015492810192909252600201549181019190915290565b609a5460408051808201909152600b81526a27a7262cafa622a223a2a960a91b60208201526000916001600160a01b031633146107f65760405162461bcd60e51b815260040161048991906121b2565b506001600160a01b03851660009081526099602090815260408083208784526004019091529020548061082d57600091505061085f565b60008581526098602052604090205461085a84610854848461084f8a8561176c565b6118f1565b9061190a565b925050505b949350505050565b60006108736001611944565b9050801561088b576000805461ff0019166101001790555b600054610100900460ff166108f65760405162461bcd60e51b815260206004820152602b60248201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960448201526a6e697469616c697a696e6760a81b6064820152608401610489565b610901600033611804565b8015610943576000805461ff0019169055604051600181527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb3847402498906020016106b7565b50565b60009182526065602090815260408084206001600160a01b0393909316845291905290205460ff1690565b609a546040516335ea6a7560e01b815260009182916001600160a01b03909116906335ea6a75906109a6908690600401612050565b6102806040518083038186803b1580156109bf57600080fd5b505afa1580156109d3573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906109f7919061245a565b609a5460405163032b467760e31b81529192506000916001600160a01b039091169063195a33b890610a2d908790600401612050565b60a06040518083038186803b158015610a4557600080fd5b505afa158015610a59573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610a7d9190612507565b609a5460405163c9ffb40960e01b81529192506000916001600160a01b039091169063c9ffb40990610ab3908890600401612050565b60606040518083038186803b158015610acb57600080fd5b505afa158015610adf573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610b0391906125a9565b6020808601516001600160a01b038b16600090815260998352604080822060608b015183526005019093529190912054919450610b50935060ff169150610b4a90846119d1565b90611a0d565b9695505050505050565b609a5460408051808201909152600b81526a27a7262cafa622a223a2a960a91b6020820152906001600160a01b03163314610ba85760405162461bcd60e51b815260040161048991906121b2565b506000848152609760209081526040808320546001600160a01b03891684526099835281842088855260030190925290912054610c03576001600160a01b0386166000908152609960205260409020610c0390866001611a71565b6000610c126104fc868661176c565b6001600160a01b03881660009081526099602090815260408083208a8452600301909152812080549293508392909190610c4d9084906121fb565b90915550506000868152609760205260408120805483929061056a9084906121fb565b609a546040516335ea6a7560e01b815260009182916001600160a01b03909116906335ea6a7590610ca5908790600401612050565b6102806040518083038186803b158015610cbe57600080fd5b505afa158015610cd2573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610cf6919061245a565b6001600160a01b03861660009081526099602090815260408083206060850151845260030190915290205490915080610d3457600092505050610e95565b609a5460405163032b467760e31b81526000916001600160a01b03169063195a33b890610d65908990600401612050565b60a06040518083038186803b158015610d7d57600080fd5b505afa158015610d91573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610db59190612507565b6020810151609a54604051631515813960e11b815292935060ff9091169160009182916001600160a01b0390911690632a2b027290610df8908c90600401612050565b60a06040518083038186803b158015610e1057600080fd5b505afa158015610e24573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610e4891906125d7565b5050506060880151600090815260976020526040812054929450909250610e7885610854898561084f888561176c565b90508915610e8b5783811115610e8b5750825b9750505050505050505b9392505050565b609a546040516327c72ebf60e01b81526001600160a01b038086166004830152848116602483015260009286928492909116906327c72ebf906044016101206040518083038186803b158015610ef157600080fd5b505afa158015610f05573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610f299190612617565b6001600160a01b03881660009081526099602090815260408083206060850151845260040190915290205490915080610f68576000935050505061085f565b609a5460405163032b467760e31b81526000916001600160a01b03169063195a33b890610f99908790600401612050565b60a06040518083038186803b158015610fb157600080fd5b505afa158015610fc5573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610fe99190612507565b6020810151609a54604051631408e8a360e31b81526001600160a01b0388811660048301528b8116602483015293945060ff9092169260009291169063a04745189060440160206040518083038186803b15801561104657600080fd5b505afa15801561105a573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061107e91906126e6565b60608601516000908152609860205260408120549192506110a884610854888561084f888561176c565b905089156112da576000609a60009054906101000a90046001600160a01b03166001600160a01b031663dbbdd9358f6040518263ffffffff1660e01b81526004016110f39190612050565b6101006040518083038186803b15801561110c57600080fd5b505afa158015611120573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061114491906126ff565b905060008160c0015113611164576000995050505050505050505061085f565b609a54604080516376b8059f60e11b815290516000926001600160a01b03169163ed700b3e9160048083019260e0929190829003018186803b1580156111a957600080fd5b505afa1580156111bd573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906111e191906127a6565b60600151905060008088608001516001600160a01b031663b3596f078d6040518263ffffffff1660e01b815260040161121a9190612050565b604080518083038186803b15801561123157600080fd5b505afa158015611245573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906112699190612852565b9150915060008b600001516020015163ffffffff16905060006112c58a6112bf61129c8688611aa090919063ffffffff16565b6112b96112aa876009611aa0565b60c08c01516112b9908c611ada565b90611ada565b90611b64565b9050868110156112d3578096505b5050505050505b9c9b505050505050505050505050565b609a5460408051808201909152600b81526a27a7262cafa622a223a2a960a91b60208201526000916001600160a01b0316331461133a5760405162461bcd60e51b815260040161048991906121b2565b506001600160a01b0385166000908152609960209081526040808320878452600501909152902054611372908390610b4a90866119d1565b95945050505050565b600082815260656020526040902060010154611396816117fa565b61059d838361188a565b609a5460408051808201909152600b81526a27a7262cafa622a223a2a960a91b6020820152906001600160a01b031633146113ee5760405162461bcd60e51b815260040161048991906121b2565b506001600160a01b038516600090815260996020908152604080832087845260050190915281205461142090846119d1565b9050600061142e8584611ba5565b6114389083612876565b90506114448185611bdf565b6001600160a01b03881660008181526099602081815260408084208c8552600581018352908420959095559290915290526114829087831515611bfe565b50505050505050565b609a5460408051808201909152600b81526a27a7262cafa622a223a2a960a91b6020820152906001600160a01b031633146114d95760405162461bcd60e51b815260040161048991906121b2565b50600084815260976020526040812054906114f76104fc868661176c565b6001600160a01b03881660009081526099602090815260408083208a845260030182529182902054825180840190935260128352714e4f545f454e4f5547485f42414c414e434560701b918301919091529192509082111561156c5760405162461bcd60e51b815260040161048991906121b2565b506001600160a01b0387166000908152609960209081526040808320898452600301909152812080548392906115a39084906128b7565b9091555050600086815260976020526040812080548392906115c69084906128b7565b90915550506001600160a01b0387166000908152609960209081526040808320898452600301909152902054611482576001600160a01b0387166000908152609960205260408120611482918890611a71565b609a5460408051808201909152600b81526a27a7262cafa622a223a2a960a91b6020820152906001600160a01b031633146116675760405162461bcd60e51b815260040161048991906121b2565b5060008481526098602052604081205490611690611685868561176c565b83610507878761176c565b6001600160a01b03881660009081526099602090815260408083208a84526004019091528120805492935083929091906116cb9084906128b7565b9091555050600086815260986020526040812080548392906116ee9084906128b7565b90915550506001600160a01b0387166000908152609960209081526040808320898452600401909152902054611482576001600160a01b03871660009081526099602052604081206114829188905b818161174a57600061174d565b60015b60ff16901b826001901b19846001015416178360010181905550505050565b600082158061177b5750601b82145b15611787575081610435565b601b8210156117b75761179b82601b6128b7565b6117a690600a6129b2565b6117b090846129be565b9050610435565b6117c2601b836128b7565b6117cd90600a6129b2565b6117b090846129f3565b6000816117e5575082610e95565b816117f084866129be565b61085f91906129f3565b6109438133611c2d565b61180e8282610946565b61073c5760008281526065602090815260408083206001600160a01b03851684529091529020805460ff191660011790556118463390565b6001600160a01b0316816001600160a01b0316837f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a45050565b6118948282610946565b1561073c5760008281526065602090815260408083206001600160a01b0385168085529252808320805460ff1916905551339285917ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b9190a45050565b6000826118ff575082610e95565b826117f083866129be565b60008215806119195750601b82145b15611925575081610435565b601b821015611939576117c282601b6128b7565b61179b601b836128b7565b60008054610100900460ff161561198b578160ff1660011480156119675750303b155b6119835760405162461bcd60e51b815260040161048990612a07565b506000919050565b60005460ff8084169116106119b25760405162461bcd60e51b815260040161048990612a07565b506000805460ff191660ff92909216919091179055600190565b919050565b600080831215611a065760006119f0836119ea86611c91565b90611cab565b90506119fe81600019612a55565b915050610435565b5081610435565b6000821580611a1c5750601b82145b15611a28575081610435565b601b821015611a5157611a3c82601b6128b7565b611a4790600a6129b2565b6117b09084612ada565b611a5c601b836128b7565b611a6790600a6129b2565b6117b09084612a55565b8181611a7e576000611a81565b60015b60ff16901b826001901b19846000015416178360000181905550505050565b6000821580611aaf5750601282145b15611abb575081610435565b6012821015611acf5761179b8260126128b7565b6117c26012836128b7565b600081611af95760405162461bcd60e51b815260040161048990612b08565b6000611b066002846129f3565b9050670de0b6b3a7640000611b1d826000196128b7565b611b2791906129f3565b841115611b465760405162461bcd60e51b815260040161048990612b3f565b8281611b5a670de0b6b3a7640000876129be565b6117f091906121fb565b6000821580611b7a5750670de0b6b3a764000082145b15611b86575081610435565b6012821015611b9a576117c28260126128b7565b61179b6012836128b7565b6000821580611bb45750601b82145b15611bc0575081610435565b601b821015611bd457611a5c82601b6128b7565b611a3c601b836128b7565b600080831215611a065760006119f083611bf886611c91565b90611d46565b8181611c0b576000611c0e565b60015b60ff16901b826001901b19846002015416178360020181905550505050565b611c378282610946565b61073c57611c4f816001600160a01b03166014611dcc565b611c5a836020611dcc565b604051602001611c6b929190612b6c565b60408051601f198184030181529082905262461bcd60e51b8252610489916004016121b2565b600080821215611ca75761043582600019612a55565b5090565b6000821580611cb8575081155b15611cc557506000610435565b81611cdc6002676765c793fa10079d601b1b6129f3565b611ce8906000196128b7565b611cf291906129f3565b831115611d115760405162461bcd60e51b815260040161048990612b3f565b676765c793fa10079d601b1b611d286002826129f3565b611d3284866129be565b611d3c91906121fb565b610e9591906129f3565b600081611d655760405162461bcd60e51b815260040161048990612b08565b6000611d726002846129f3565b9050676765c793fa10079d601b1b611d8c826000196128b7565b611d9691906129f3565b841115611db55760405162461bcd60e51b815260040161048990612b3f565b8281611b5a676765c793fa10079d601b1b876129be565b60606000611ddb8360026129be565b611de69060026121fb565b6001600160401b03811115611dfd57611dfd612213565b6040519080825280601f01601f191660200182016040528015611e27576020820181803683370190505b509050600360fc1b81600081518110611e4257611e42612bdb565b60200101906001600160f81b031916908160001a905350600f60fb1b81600181518110611e7157611e71612bdb565b60200101906001600160f81b031916908160001a9053506000611e958460026129be565b611ea09060016121fb565b90505b6001811115611f18576f181899199a1a9b1b9c1cb0b131b232b360811b85600f1660108110611ed457611ed4612bdb565b1a60f81b828281518110611eea57611eea612bdb565b60200101906001600160f81b031916908160001a90535060049490941c93611f1181612bf1565b9050611ea3565b508315610e955760405162461bcd60e51b815260206004820181905260248201527f537472696e67733a20686578206c656e67746820696e73756666696369656e746044820152606401610489565b600060208284031215611f7957600080fd5b5035919050565b600060208284031215611f9257600080fd5b81356001600160e01b031981168114610e9557600080fd5b6001600160a01b038116811461094357600080fd5b600080600080600060a08688031215611fd757600080fd5b8535611fe281611faa565b97602087013597506040870135966060810135965060800135945092505050565b6000806040838503121561201657600080fd5b82359150602083013561202881611faa565b809150509250929050565b60006020828403121561204557600080fd5b8135610e9581611faa565b6001600160a01b0391909116815260200190565b6000806000806080858703121561207a57600080fd5b843561208581611faa565b966020860135965060408601359560600135945092505050565b600080604083850312156120b257600080fd5b82356120bd81611faa565b9150602083013561202881611faa565b801515811461094357600080fd5b6000806000606084860312156120f057600080fd5b83356120fb81611faa565b9250602084013561210b81611faa565b9150604084013561211b816120cd565b809150509250925092565b6000806000806080858703121561213c57600080fd5b843561214781611faa565b9350602085013561215781611faa565b9250604085013561216781611faa565b91506060850135612177816120cd565b939692955090935050565b60005b8381101561219d578181015183820152602001612185565b838111156121ac576000848401525b50505050565b60208152600082518060208401526121d1816040850160208701612182565b601f01601f19169190910160400192915050565b634e487b7160e01b600052601160045260246000fd5b6000821982111561220e5761220e6121e5565b500190565b634e487b7160e01b600052604160045260246000fd5b60405161016081016001600160401b038111828210171561225a57634e487b7160e01b600052604160045260246000fd5b60405290565b60405160c081016001600160401b038111828210171561225a57634e487b7160e01b600052604160045260246000fd5b604051608081016001600160401b038111828210171561225a57634e487b7160e01b600052604160045260246000fd5b805163ffffffff811681146119cc57600080fd5b6003811061094357600080fd5b8051600481106119cc57600080fd5b600061010080838503121561230457600080fd5b604051908101906001600160401b038211818310171561233457634e487b7160e01b600052604160045260246000fd5b81604052809250612344846122c0565b8152612352602085016122c0565b6020820152612363604085016122c0565b6040820152612374606085016122c0565b6060820152612385608085016122c0565b608082015261239660a085016122c0565b60a082015260c084015191506123ab826122d4565b8160c08201526123bd60e085016122e1565b60e0820152505092915050565b80516119cc81611faa565b6000606082840312156123e757600080fd5b604051606081018181106001600160401b038211171561241757634e487b7160e01b600052604160045260246000fd5b8060405250809150825161242a81611faa565b8152602083015161243a81611faa565b6020820152604083015161244d81611faa565b6040919091015292915050565b6000610280828403121561246d57600080fd5b612475612229565b61247f84846122f0565b8152610100612490858286016123d5565b60208301526124a261016085016123ca565b604083015261018084015160608301526101a084015160808301526101c084015160a08301526101e084015160c083015261020084015160e0830152610220840151908201526102408301516101208201526102609092015161014083015250919050565b600060a0828403121561251957600080fd5b60405160a081018181106001600160401b038211171561254957634e487b7160e01b600052604160045260246000fd5b60405282518152602083015160ff8116811461256457600080fd5b60208201526040830151612577816122d4565b6040820152606083015161258a81611faa565b6060820152608083015161259d81611faa565b60808201529392505050565b6000806000606084860312156125be57600080fd5b8351925060208401519150604084015190509250925092565b600080600080600060a086880312156125ef57600080fd5b5050835160208501516040860151606087015160809097015192989197509594509092509050565b600081830361012081121561262b57600080fd5b612633612260565b608082121561264157600080fd5b612649612290565b9150612654846122c0565b8252612662602085016122c0565b602083015260408401516001600160801b038116811461268157600080fd5b60408301526060840151612694816122d4565b60608301528181526126a8608085016123ca565b60208201526126b960a085016123ca565b604082015260c0840151606082015260e084015160808201526101009093015160a0840152509092915050565b6000602082840312156126f857600080fd5b5051919050565b600061010080838503121561271357600080fd5b604051908101906001600160401b038211818310171561274357634e487b7160e01b600052604160045260246000fd5b81604052835181526020840151602082015260408401516040820152606084015160608201526080840151608082015260a084015160a082015260c084015160c082015260e08401519150612797826120cd565b60e08101919091529392505050565b600060e082840312156127b857600080fd5b60405160e081018181106001600160401b03821117156127e857634e487b7160e01b600052604160045260246000fd5b60405282516127f681611faa565b8152602083015161280681611faa565b6020820152604083015161281981611faa565b80604083015250606083015160608201526080830151608082015260a083015160a082015260c083015160c08201528091505092915050565b6000806040838503121561286557600080fd5b505080516020909101519092909150565b600080821280156001600160ff1b0384900385131615612898576128986121e5565b600160ff1b83900384128116156128b1576128b16121e5565b50500190565b6000828210156128c9576128c96121e5565b500390565b600181815b808511156129095781600019048211156128ef576128ef6121e5565b808516156128fc57918102915b93841c93908002906128d3565b509250929050565b60008261292057506001610435565b8161292d57506000610435565b8160018114612943576002811461294d57612969565b6001915050610435565b60ff84111561295e5761295e6121e5565b50506001821b610435565b5060208310610133831016604e8410600b841016171561298c575081810a610435565b61299683836128ce565b80600019048211156129aa576129aa6121e5565b029392505050565b6000610e958383612911565b60008160001904831182151516156129d8576129d86121e5565b500290565b634e487b7160e01b600052601260045260246000fd5b600082612a0257612a026129dd565b500490565b6020808252602e908201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160408201526d191e481a5b9a5d1a585b1a5e995960921b606082015260800190565b60006001600160ff1b0381841382841380821686840486111615612a7b57612a7b6121e5565b600160ff1b6000871282811687830589121615612a9a57612a9a6121e5565b60008712925087820587128484161615612ab657612ab66121e5565b87850587128184161615612acc57612acc6121e5565b505050929093029392505050565b600082612ae957612ae96129dd565b600160ff1b821460001984141615612b0357612b036121e5565b500590565b6020808252601b908201527f4d6174685574696c733a206469766973696f6e206279207a65726f0000000000604082015260600190565b6020808252601390820152724d6174685574696c733a206f766572666c6f7760681b604082015260600190565b76020b1b1b2b9b9a1b7b73a3937b61d1030b1b1b7bab73a1604d1b815260008351612b9e816017850160208801612182565b7001034b99036b4b9b9b4b733903937b6329607d1b6017918401918201528351612bcf816028840160208801612182565b01602801949350505050565b634e487b7160e01b600052603260045260246000fd5b600081612c0057612c006121e5565b50600019019056fea2646970667358221220a9beec8926224a3e0a3fade9cbda3abb4e0d22473f506d2be26c9e8cc7763a5064736f6c63430008090033
Deployed Bytecode
0x608060405234801561001057600080fd5b506004361061016d5760003560e01c80639f50de30116100ce578063d547741f11610087578063d547741f14610369578063d67622ff1461037c578063dc2673841461038f578063dcaa1f12146103a2578063e7d7bf07146103c2578063f5b541a6146103d5578063ffa1ad74146103fc57600080fd5b80639f50de30146102cf578063a217fddf146102e2578063a68bce57146102ea578063be55e0fd146102fd578063c891091314610310578063d482f9301461035657600080fd5b806336568abe1161012b57806336568abe146102265780634417a5831461023957806356397c351461026e578063629a839d1461028e5780638129fc1c146102a157806391d14854146102a957806392a576e6146102bc57600080fd5b806209acc31461017257806301ffc9a7146101a5578063248a9ca3146101c85780632a4f2cde146101eb5780632f2ff15d146102005780633246887d14610213575b600080fd5b610192610180366004611f67565b60976020526000908152604090205481565b6040519081526020015b60405180910390f35b6101b86101b3366004611f80565b610404565b604051901515815260200161019c565b6101926101d6366004611f67565b60009081526065602052604090206001015490565b6101fe6101f9366004611fbf565b61043b565b005b6101fe61020e366004612003565b610578565b6101fe610221366004612033565b6105a2565b6101fe610234366004612003565b6106c2565b61024c610247366004612033565b610740565b604080518251815260208084015190820152918101519082015260600161019c565b609a54610281906001600160a01b031681565b60405161019c9190612050565b61019261029c366004612064565b6107a6565b6101fe610867565b6101b86102b7366004612003565b610946565b6101926102ca36600461209f565b610971565b6101fe6102dd366004611fbf565b610b5a565b610192600081565b6101926102f83660046120db565b610c70565b61019261030b366004612126565b610e9c565b61024c61031e366004612033565b609960209081526000918252604091829020825160608101845281548152600182015492810192909252600201549181019190915281565b610192610364366004612064565b6112ea565b6101fe610377366004612003565b61137b565b6101fe61038a366004611fbf565b6113a0565b6101fe61039d366004611fbf565b61148b565b6101926103b0366004611f67565b60986020526000908152604090205481565b6101fe6103d0366004611fbf565b611619565b6101927f97667070c54ef182b0f5858b034beac1b6f3089aa2d3188bb1e8929f4fa9b92981565b610192600381565b60006001600160e01b03198216637965db0b60e01b148061043557506301ffc9a760e01b6001600160e01b03198316145b92915050565b609a5460408051808201909152600b81526a27a7262cafa622a223a2a960a91b6020820152906001600160a01b031633146104925760405162461bcd60e51b815260040161048991906121b2565b60405180910390fd5b506000848152609860209081526040808320546001600160a01b038916845260998352818420888552600401909252909120546104ed576001600160a01b03861660009081526099602052604090206104ed9086600161173d565b600061050c6104fc868661176c565b83610507868861176c565b6117d7565b6001600160a01b03881660009081526099602090815260408083208a84526004019091528120805492935083929091906105479084906121fb565b90915550506000868152609860205260408120805483929061056a9084906121fb565b909155505050505050505050565b600082815260656020526040902060010154610593816117fa565b61059d8383611804565b505050565b6105cc7f97667070c54ef182b0f5858b034beac1b6f3089aa2d3188bb1e8929f4fa9b92933610946565b6040518060400160405280601381526020017221a0a62622a92fa727aa2fa7a822a920aa27a960691b815250906106165760405162461bcd60e51b815260040161048991906121b2565b50609a5460408051808201909152601281527113115111d15497d25392551250531256915160721b6020820152906001600160a01b03161561066b5760405162461bcd60e51b815260040161048991906121b2565b50609a80546001600160a01b0319166001600160a01b0383161790556040517f90b03a813aad27839e6166b75a4afe364137df14d9c35f60b3fc58b278c0aae6906106b7908390612050565b60405180910390a150565b6001600160a01b03811633146107325760405162461bcd60e51b815260206004820152602f60248201527f416363657373436f6e74726f6c3a2063616e206f6e6c792072656e6f756e636560448201526e103937b632b9903337b91039b2b63360891b6064820152608401610489565b61073c828261188a565b5050565b61076460405180606001604052806000815260200160008152602001600081525090565b506001600160a01b0316600090815260996020908152604091829020825160608101845281548152600182015492810192909252600201549181019190915290565b609a5460408051808201909152600b81526a27a7262cafa622a223a2a960a91b60208201526000916001600160a01b031633146107f65760405162461bcd60e51b815260040161048991906121b2565b506001600160a01b03851660009081526099602090815260408083208784526004019091529020548061082d57600091505061085f565b60008581526098602052604090205461085a84610854848461084f8a8561176c565b6118f1565b9061190a565b925050505b949350505050565b60006108736001611944565b9050801561088b576000805461ff0019166101001790555b600054610100900460ff166108f65760405162461bcd60e51b815260206004820152602b60248201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960448201526a6e697469616c697a696e6760a81b6064820152608401610489565b610901600033611804565b8015610943576000805461ff0019169055604051600181527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb3847402498906020016106b7565b50565b60009182526065602090815260408084206001600160a01b0393909316845291905290205460ff1690565b609a546040516335ea6a7560e01b815260009182916001600160a01b03909116906335ea6a75906109a6908690600401612050565b6102806040518083038186803b1580156109bf57600080fd5b505afa1580156109d3573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906109f7919061245a565b609a5460405163032b467760e31b81529192506000916001600160a01b039091169063195a33b890610a2d908790600401612050565b60a06040518083038186803b158015610a4557600080fd5b505afa158015610a59573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610a7d9190612507565b609a5460405163c9ffb40960e01b81529192506000916001600160a01b039091169063c9ffb40990610ab3908890600401612050565b60606040518083038186803b158015610acb57600080fd5b505afa158015610adf573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610b0391906125a9565b6020808601516001600160a01b038b16600090815260998352604080822060608b015183526005019093529190912054919450610b50935060ff169150610b4a90846119d1565b90611a0d565b9695505050505050565b609a5460408051808201909152600b81526a27a7262cafa622a223a2a960a91b6020820152906001600160a01b03163314610ba85760405162461bcd60e51b815260040161048991906121b2565b506000848152609760209081526040808320546001600160a01b03891684526099835281842088855260030190925290912054610c03576001600160a01b0386166000908152609960205260409020610c0390866001611a71565b6000610c126104fc868661176c565b6001600160a01b03881660009081526099602090815260408083208a8452600301909152812080549293508392909190610c4d9084906121fb565b90915550506000868152609760205260408120805483929061056a9084906121fb565b609a546040516335ea6a7560e01b815260009182916001600160a01b03909116906335ea6a7590610ca5908790600401612050565b6102806040518083038186803b158015610cbe57600080fd5b505afa158015610cd2573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610cf6919061245a565b6001600160a01b03861660009081526099602090815260408083206060850151845260030190915290205490915080610d3457600092505050610e95565b609a5460405163032b467760e31b81526000916001600160a01b03169063195a33b890610d65908990600401612050565b60a06040518083038186803b158015610d7d57600080fd5b505afa158015610d91573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610db59190612507565b6020810151609a54604051631515813960e11b815292935060ff9091169160009182916001600160a01b0390911690632a2b027290610df8908c90600401612050565b60a06040518083038186803b158015610e1057600080fd5b505afa158015610e24573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610e4891906125d7565b5050506060880151600090815260976020526040812054929450909250610e7885610854898561084f888561176c565b90508915610e8b5783811115610e8b5750825b9750505050505050505b9392505050565b609a546040516327c72ebf60e01b81526001600160a01b038086166004830152848116602483015260009286928492909116906327c72ebf906044016101206040518083038186803b158015610ef157600080fd5b505afa158015610f05573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610f299190612617565b6001600160a01b03881660009081526099602090815260408083206060850151845260040190915290205490915080610f68576000935050505061085f565b609a5460405163032b467760e31b81526000916001600160a01b03169063195a33b890610f99908790600401612050565b60a06040518083038186803b158015610fb157600080fd5b505afa158015610fc5573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610fe99190612507565b6020810151609a54604051631408e8a360e31b81526001600160a01b0388811660048301528b8116602483015293945060ff9092169260009291169063a04745189060440160206040518083038186803b15801561104657600080fd5b505afa15801561105a573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061107e91906126e6565b60608601516000908152609860205260408120549192506110a884610854888561084f888561176c565b905089156112da576000609a60009054906101000a90046001600160a01b03166001600160a01b031663dbbdd9358f6040518263ffffffff1660e01b81526004016110f39190612050565b6101006040518083038186803b15801561110c57600080fd5b505afa158015611120573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061114491906126ff565b905060008160c0015113611164576000995050505050505050505061085f565b609a54604080516376b8059f60e11b815290516000926001600160a01b03169163ed700b3e9160048083019260e0929190829003018186803b1580156111a957600080fd5b505afa1580156111bd573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906111e191906127a6565b60600151905060008088608001516001600160a01b031663b3596f078d6040518263ffffffff1660e01b815260040161121a9190612050565b604080518083038186803b15801561123157600080fd5b505afa158015611245573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906112699190612852565b9150915060008b600001516020015163ffffffff16905060006112c58a6112bf61129c8688611aa090919063ffffffff16565b6112b96112aa876009611aa0565b60c08c01516112b9908c611ada565b90611ada565b90611b64565b9050868110156112d3578096505b5050505050505b9c9b505050505050505050505050565b609a5460408051808201909152600b81526a27a7262cafa622a223a2a960a91b60208201526000916001600160a01b0316331461133a5760405162461bcd60e51b815260040161048991906121b2565b506001600160a01b0385166000908152609960209081526040808320878452600501909152902054611372908390610b4a90866119d1565b95945050505050565b600082815260656020526040902060010154611396816117fa565b61059d838361188a565b609a5460408051808201909152600b81526a27a7262cafa622a223a2a960a91b6020820152906001600160a01b031633146113ee5760405162461bcd60e51b815260040161048991906121b2565b506001600160a01b038516600090815260996020908152604080832087845260050190915281205461142090846119d1565b9050600061142e8584611ba5565b6114389083612876565b90506114448185611bdf565b6001600160a01b03881660008181526099602081815260408084208c8552600581018352908420959095559290915290526114829087831515611bfe565b50505050505050565b609a5460408051808201909152600b81526a27a7262cafa622a223a2a960a91b6020820152906001600160a01b031633146114d95760405162461bcd60e51b815260040161048991906121b2565b50600084815260976020526040812054906114f76104fc868661176c565b6001600160a01b03881660009081526099602090815260408083208a845260030182529182902054825180840190935260128352714e4f545f454e4f5547485f42414c414e434560701b918301919091529192509082111561156c5760405162461bcd60e51b815260040161048991906121b2565b506001600160a01b0387166000908152609960209081526040808320898452600301909152812080548392906115a39084906128b7565b9091555050600086815260976020526040812080548392906115c69084906128b7565b90915550506001600160a01b0387166000908152609960209081526040808320898452600301909152902054611482576001600160a01b0387166000908152609960205260408120611482918890611a71565b609a5460408051808201909152600b81526a27a7262cafa622a223a2a960a91b6020820152906001600160a01b031633146116675760405162461bcd60e51b815260040161048991906121b2565b5060008481526098602052604081205490611690611685868561176c565b83610507878761176c565b6001600160a01b03881660009081526099602090815260408083208a84526004019091528120805492935083929091906116cb9084906128b7565b9091555050600086815260986020526040812080548392906116ee9084906128b7565b90915550506001600160a01b0387166000908152609960209081526040808320898452600401909152902054611482576001600160a01b03871660009081526099602052604081206114829188905b818161174a57600061174d565b60015b60ff16901b826001901b19846001015416178360010181905550505050565b600082158061177b5750601b82145b15611787575081610435565b601b8210156117b75761179b82601b6128b7565b6117a690600a6129b2565b6117b090846129be565b9050610435565b6117c2601b836128b7565b6117cd90600a6129b2565b6117b090846129f3565b6000816117e5575082610e95565b816117f084866129be565b61085f91906129f3565b6109438133611c2d565b61180e8282610946565b61073c5760008281526065602090815260408083206001600160a01b03851684529091529020805460ff191660011790556118463390565b6001600160a01b0316816001600160a01b0316837f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a45050565b6118948282610946565b1561073c5760008281526065602090815260408083206001600160a01b0385168085529252808320805460ff1916905551339285917ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b9190a45050565b6000826118ff575082610e95565b826117f083866129be565b60008215806119195750601b82145b15611925575081610435565b601b821015611939576117c282601b6128b7565b61179b601b836128b7565b60008054610100900460ff161561198b578160ff1660011480156119675750303b155b6119835760405162461bcd60e51b815260040161048990612a07565b506000919050565b60005460ff8084169116106119b25760405162461bcd60e51b815260040161048990612a07565b506000805460ff191660ff92909216919091179055600190565b919050565b600080831215611a065760006119f0836119ea86611c91565b90611cab565b90506119fe81600019612a55565b915050610435565b5081610435565b6000821580611a1c5750601b82145b15611a28575081610435565b601b821015611a5157611a3c82601b6128b7565b611a4790600a6129b2565b6117b09084612ada565b611a5c601b836128b7565b611a6790600a6129b2565b6117b09084612a55565b8181611a7e576000611a81565b60015b60ff16901b826001901b19846000015416178360000181905550505050565b6000821580611aaf5750601282145b15611abb575081610435565b6012821015611acf5761179b8260126128b7565b6117c26012836128b7565b600081611af95760405162461bcd60e51b815260040161048990612b08565b6000611b066002846129f3565b9050670de0b6b3a7640000611b1d826000196128b7565b611b2791906129f3565b841115611b465760405162461bcd60e51b815260040161048990612b3f565b8281611b5a670de0b6b3a7640000876129be565b6117f091906121fb565b6000821580611b7a5750670de0b6b3a764000082145b15611b86575081610435565b6012821015611b9a576117c28260126128b7565b61179b6012836128b7565b6000821580611bb45750601b82145b15611bc0575081610435565b601b821015611bd457611a5c82601b6128b7565b611a3c601b836128b7565b600080831215611a065760006119f083611bf886611c91565b90611d46565b8181611c0b576000611c0e565b60015b60ff16901b826001901b19846002015416178360020181905550505050565b611c378282610946565b61073c57611c4f816001600160a01b03166014611dcc565b611c5a836020611dcc565b604051602001611c6b929190612b6c565b60408051601f198184030181529082905262461bcd60e51b8252610489916004016121b2565b600080821215611ca75761043582600019612a55565b5090565b6000821580611cb8575081155b15611cc557506000610435565b81611cdc6002676765c793fa10079d601b1b6129f3565b611ce8906000196128b7565b611cf291906129f3565b831115611d115760405162461bcd60e51b815260040161048990612b3f565b676765c793fa10079d601b1b611d286002826129f3565b611d3284866129be565b611d3c91906121fb565b610e9591906129f3565b600081611d655760405162461bcd60e51b815260040161048990612b08565b6000611d726002846129f3565b9050676765c793fa10079d601b1b611d8c826000196128b7565b611d9691906129f3565b841115611db55760405162461bcd60e51b815260040161048990612b3f565b8281611b5a676765c793fa10079d601b1b876129be565b60606000611ddb8360026129be565b611de69060026121fb565b6001600160401b03811115611dfd57611dfd612213565b6040519080825280601f01601f191660200182016040528015611e27576020820181803683370190505b509050600360fc1b81600081518110611e4257611e42612bdb565b60200101906001600160f81b031916908160001a905350600f60fb1b81600181518110611e7157611e71612bdb565b60200101906001600160f81b031916908160001a9053506000611e958460026129be565b611ea09060016121fb565b90505b6001811115611f18576f181899199a1a9b1b9c1cb0b131b232b360811b85600f1660108110611ed457611ed4612bdb565b1a60f81b828281518110611eea57611eea612bdb565b60200101906001600160f81b031916908160001a90535060049490941c93611f1181612bf1565b9050611ea3565b508315610e955760405162461bcd60e51b815260206004820181905260248201527f537472696e67733a20686578206c656e67746820696e73756666696369656e746044820152606401610489565b600060208284031215611f7957600080fd5b5035919050565b600060208284031215611f9257600080fd5b81356001600160e01b031981168114610e9557600080fd5b6001600160a01b038116811461094357600080fd5b600080600080600060a08688031215611fd757600080fd5b8535611fe281611faa565b97602087013597506040870135966060810135965060800135945092505050565b6000806040838503121561201657600080fd5b82359150602083013561202881611faa565b809150509250929050565b60006020828403121561204557600080fd5b8135610e9581611faa565b6001600160a01b0391909116815260200190565b6000806000806080858703121561207a57600080fd5b843561208581611faa565b966020860135965060408601359560600135945092505050565b600080604083850312156120b257600080fd5b82356120bd81611faa565b9150602083013561202881611faa565b801515811461094357600080fd5b6000806000606084860312156120f057600080fd5b83356120fb81611faa565b9250602084013561210b81611faa565b9150604084013561211b816120cd565b809150509250925092565b6000806000806080858703121561213c57600080fd5b843561214781611faa565b9350602085013561215781611faa565b9250604085013561216781611faa565b91506060850135612177816120cd565b939692955090935050565b60005b8381101561219d578181015183820152602001612185565b838111156121ac576000848401525b50505050565b60208152600082518060208401526121d1816040850160208701612182565b601f01601f19169190910160400192915050565b634e487b7160e01b600052601160045260246000fd5b6000821982111561220e5761220e6121e5565b500190565b634e487b7160e01b600052604160045260246000fd5b60405161016081016001600160401b038111828210171561225a57634e487b7160e01b600052604160045260246000fd5b60405290565b60405160c081016001600160401b038111828210171561225a57634e487b7160e01b600052604160045260246000fd5b604051608081016001600160401b038111828210171561225a57634e487b7160e01b600052604160045260246000fd5b805163ffffffff811681146119cc57600080fd5b6003811061094357600080fd5b8051600481106119cc57600080fd5b600061010080838503121561230457600080fd5b604051908101906001600160401b038211818310171561233457634e487b7160e01b600052604160045260246000fd5b81604052809250612344846122c0565b8152612352602085016122c0565b6020820152612363604085016122c0565b6040820152612374606085016122c0565b6060820152612385608085016122c0565b608082015261239660a085016122c0565b60a082015260c084015191506123ab826122d4565b8160c08201526123bd60e085016122e1565b60e0820152505092915050565b80516119cc81611faa565b6000606082840312156123e757600080fd5b604051606081018181106001600160401b038211171561241757634e487b7160e01b600052604160045260246000fd5b8060405250809150825161242a81611faa565b8152602083015161243a81611faa565b6020820152604083015161244d81611faa565b6040919091015292915050565b6000610280828403121561246d57600080fd5b612475612229565b61247f84846122f0565b8152610100612490858286016123d5565b60208301526124a261016085016123ca565b604083015261018084015160608301526101a084015160808301526101c084015160a08301526101e084015160c083015261020084015160e0830152610220840151908201526102408301516101208201526102609092015161014083015250919050565b600060a0828403121561251957600080fd5b60405160a081018181106001600160401b038211171561254957634e487b7160e01b600052604160045260246000fd5b60405282518152602083015160ff8116811461256457600080fd5b60208201526040830151612577816122d4565b6040820152606083015161258a81611faa565b6060820152608083015161259d81611faa565b60808201529392505050565b6000806000606084860312156125be57600080fd5b8351925060208401519150604084015190509250925092565b600080600080600060a086880312156125ef57600080fd5b5050835160208501516040860151606087015160809097015192989197509594509092509050565b600081830361012081121561262b57600080fd5b612633612260565b608082121561264157600080fd5b612649612290565b9150612654846122c0565b8252612662602085016122c0565b602083015260408401516001600160801b038116811461268157600080fd5b60408301526060840151612694816122d4565b60608301528181526126a8608085016123ca565b60208201526126b960a085016123ca565b604082015260c0840151606082015260e084015160808201526101009093015160a0840152509092915050565b6000602082840312156126f857600080fd5b5051919050565b600061010080838503121561271357600080fd5b604051908101906001600160401b038211818310171561274357634e487b7160e01b600052604160045260246000fd5b81604052835181526020840151602082015260408401516040820152606084015160608201526080840151608082015260a084015160a082015260c084015160c082015260e08401519150612797826120cd565b60e08101919091529392505050565b600060e082840312156127b857600080fd5b60405160e081018181106001600160401b03821117156127e857634e487b7160e01b600052604160045260246000fd5b60405282516127f681611faa565b8152602083015161280681611faa565b6020820152604083015161281981611faa565b80604083015250606083015160608201526080830151608082015260a083015160a082015260c083015160c08201528091505092915050565b6000806040838503121561286557600080fd5b505080516020909101519092909150565b600080821280156001600160ff1b0384900385131615612898576128986121e5565b600160ff1b83900384128116156128b1576128b16121e5565b50500190565b6000828210156128c9576128c96121e5565b500390565b600181815b808511156129095781600019048211156128ef576128ef6121e5565b808516156128fc57918102915b93841c93908002906128d3565b509250929050565b60008261292057506001610435565b8161292d57506000610435565b8160018114612943576002811461294d57612969565b6001915050610435565b60ff84111561295e5761295e6121e5565b50506001821b610435565b5060208310610133831016604e8410600b841016171561298c575081810a610435565b61299683836128ce565b80600019048211156129aa576129aa6121e5565b029392505050565b6000610e958383612911565b60008160001904831182151516156129d8576129d86121e5565b500290565b634e487b7160e01b600052601260045260246000fd5b600082612a0257612a026129dd565b500490565b6020808252602e908201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160408201526d191e481a5b9a5d1a585b1a5e995960921b606082015260800190565b60006001600160ff1b0381841382841380821686840486111615612a7b57612a7b6121e5565b600160ff1b6000871282811687830589121615612a9a57612a9a6121e5565b60008712925087820587128484161615612ab657612ab66121e5565b87850587128184161615612acc57612acc6121e5565b505050929093029392505050565b600082612ae957612ae96129dd565b600160ff1b821460001984141615612b0357612b036121e5565b500590565b6020808252601b908201527f4d6174685574696c733a206469766973696f6e206279207a65726f0000000000604082015260600190565b6020808252601390820152724d6174685574696c733a206f766572666c6f7760681b604082015260600190565b76020b1b1b2b9b9a1b7b73a3937b61d1030b1b1b7bab73a1604d1b815260008351612b9e816017850160208801612182565b7001034b99036b4b9b9b4b733903937b6329607d1b6017918401918201528351612bcf816028840160208801612182565b01602801949350505050565b634e487b7160e01b600052603260045260246000fd5b600081612c0057612c006121e5565b50600019019056fea2646970667358221220a9beec8926224a3e0a3fade9cbda3abb4e0d22473f506d2be26c9e8cc7763a5064736f6c63430008090033
Loading...
Loading
Loading...
Loading
Multichain Portfolio | 31 Chains
Chain | Token | Portfolio % | Price | Amount | Value |
---|
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.