Source Code
Overview
HYPE Balance
HYPE Value
$0.00| Transaction Hash |
|
Block
|
From
|
To
|
|||||
|---|---|---|---|---|---|---|---|---|---|
Advanced mode: Intended for advanced users or developers and will display all Internal Transactions including zero value transfers.
Latest 25 internal transactions (View All)
Advanced mode:
| Parent Transaction Hash | Block | From | To | ||||
|---|---|---|---|---|---|---|---|
| 25492722 | 28 hrs ago | 0 HYPE | |||||
| 25492722 | 28 hrs ago | 0 HYPE | |||||
| 25492722 | 28 hrs ago | 0 HYPE | |||||
| 25492722 | 28 hrs ago | 0 HYPE | |||||
| 25492722 | 28 hrs ago | 0 HYPE | |||||
| 25492722 | 28 hrs ago | 0 HYPE | |||||
| 25492722 | 28 hrs ago | 0 HYPE | |||||
| 25337483 | 2 days ago | 0 HYPE | |||||
| 25337483 | 2 days ago | 0 HYPE | |||||
| 25337483 | 2 days ago | 0 HYPE | |||||
| 25337483 | 2 days ago | 0 HYPE | |||||
| 25337483 | 2 days ago | 0 HYPE | |||||
| 25337483 | 2 days ago | 0 HYPE | |||||
| 25337483 | 2 days ago | 0 HYPE | |||||
| 25337459 | 2 days ago | 0 HYPE | |||||
| 25263788 | 3 days ago | 0 HYPE | |||||
| 25263788 | 3 days ago | 0 HYPE | |||||
| 25263788 | 3 days ago | 0 HYPE | |||||
| 25263788 | 3 days ago | 0 HYPE | |||||
| 25263788 | 3 days ago | 0 HYPE | |||||
| 25263788 | 3 days ago | 0 HYPE | |||||
| 25263788 | 3 days ago | 0 HYPE | |||||
| 25201322 | 4 days ago | 0 HYPE | |||||
| 25201322 | 4 days ago | 0 HYPE | |||||
| 25201322 | 4 days ago | 0 HYPE |
Cross-Chain Transactions
Loading...
Loading
Contract Name:
PendleAaveV3OffchainRewardsSYUpg
Compiler Version
v0.8.24+commit.e11b9ed9
Optimization Enabled:
Yes with 1000000 runs
Other Settings:
shanghai EvmVersion
Contract Source Code (Solidity Standard Json-Input format)
// SPDX-License-Identifier: GPL-3.0-or-later
pragma solidity ^0.8.23;
import "./PendleAaveV3WithRewardsSYUpg.sol";
import "./PendleAaveMerit.sol";
contract PendleAaveV3OffchainRewardsSYUpg is PendleAaveV3WithRewardsSYUpg, PendleAaveMerit {
constructor(
address _aavePool,
address _aToken,
address _initialIncentiveController,
address _defaultRewardToken,
address _offchainReceiver
)
PendleAaveV3WithRewardsSYUpg(_aavePool, _aToken, _initialIncentiveController, _defaultRewardToken)
PendleAaveMerit(_offchainReceiver)
{}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (interfaces/IERC5267.sol)
pragma solidity ^0.8.0;
interface IERC5267Upgradeable {
/**
* @dev MAY be emitted to signal that the domain could have changed.
*/
event EIP712DomainChanged();
/**
* @dev returns the fields and values that describe the domain separator used by this contract for EIP-712
* signature.
*/
function eip712Domain()
external
view
returns (
bytes1 fields,
string memory name,
string memory version,
uint256 chainId,
address verifyingContract,
bytes32 salt,
uint256[] memory extensions
);
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (proxy/utils/Initializable.sol)
pragma solidity ^0.8.2;
import "../../utils/AddressUpgradeable.sol";
/**
* @dev This is a base contract to aid in writing upgradeable contracts, or any kind of contract that will be deployed
* behind a proxy. Since proxied contracts do not make use of a constructor, it's common to move constructor logic to an
* external initializer function, usually called `initialize`. It then becomes necessary to protect this initializer
* function so it can only be called once. The {initializer} modifier provided by this contract will have this effect.
*
* The initialization functions use a version number. Once a version number is used, it is consumed and cannot be
* reused. This mechanism prevents re-execution of each "step" but allows the creation of new initialization steps in
* case an upgrade adds a module that needs to be initialized.
*
* For example:
*
* [.hljs-theme-light.nopadding]
* ```solidity
* contract MyToken is ERC20Upgradeable {
* function initialize() initializer public {
* __ERC20_init("MyToken", "MTK");
* }
* }
*
* contract MyTokenV2 is MyToken, ERC20PermitUpgradeable {
* function initializeV2() reinitializer(2) public {
* __ERC20Permit_init("MyToken");
* }
* }
* ```
*
* TIP: To avoid leaving the proxy in an uninitialized state, the initializer function should be called as early as
* possible by providing the encoded function call as the `_data` argument to {ERC1967Proxy-constructor}.
*
* CAUTION: When used with inheritance, manual care must be taken to not invoke a parent initializer twice, or to ensure
* that all initializers are idempotent. This is not verified automatically as constructors are by Solidity.
*
* [CAUTION]
* ====
* Avoid leaving a contract uninitialized.
*
* An uninitialized contract can be taken over by an attacker. This applies to both a proxy and its implementation
* contract, which may impact the proxy. To prevent the implementation contract from being used, you should invoke
* the {_disableInitializers} function in the constructor to automatically lock it when it is deployed:
*
* [.hljs-theme-light.nopadding]
* ```
* /// @custom:oz-upgrades-unsafe-allow constructor
* constructor() {
* _disableInitializers();
* }
* ```
* ====
*/
abstract contract Initializable {
/**
* @dev Indicates that the contract has been initialized.
* @custom:oz-retyped-from bool
*/
uint8 private _initialized;
/**
* @dev Indicates that the contract is in the process of being initialized.
*/
bool private _initializing;
/**
* @dev Triggered when the contract has been initialized or reinitialized.
*/
event Initialized(uint8 version);
/**
* @dev A modifier that defines a protected initializer function that can be invoked at most once. In its scope,
* `onlyInitializing` functions can be used to initialize parent contracts.
*
* Similar to `reinitializer(1)`, except that functions marked with `initializer` can be nested in the context of a
* constructor.
*
* Emits an {Initialized} event.
*/
modifier initializer() {
bool isTopLevelCall = !_initializing;
require(
(isTopLevelCall && _initialized < 1) || (!AddressUpgradeable.isContract(address(this)) && _initialized == 1),
"Initializable: contract is already initialized"
);
_initialized = 1;
if (isTopLevelCall) {
_initializing = true;
}
_;
if (isTopLevelCall) {
_initializing = false;
emit Initialized(1);
}
}
/**
* @dev A modifier that defines a protected reinitializer function that can be invoked at most once, and only if the
* contract hasn't been initialized to a greater version before. In its scope, `onlyInitializing` functions can be
* used to initialize parent contracts.
*
* A reinitializer may be used after the original initialization step. This is essential to configure modules that
* are added through upgrades and that require initialization.
*
* When `version` is 1, this modifier is similar to `initializer`, except that functions marked with `reinitializer`
* cannot be nested. If one is invoked in the context of another, execution will revert.
*
* Note that versions can jump in increments greater than 1; this implies that if multiple reinitializers coexist in
* a contract, executing them in the right order is up to the developer or operator.
*
* WARNING: setting the version to 255 will prevent any future reinitialization.
*
* Emits an {Initialized} event.
*/
modifier reinitializer(uint8 version) {
require(!_initializing && _initialized < version, "Initializable: contract is already initialized");
_initialized = version;
_initializing = true;
_;
_initializing = false;
emit Initialized(version);
}
/**
* @dev Modifier to protect an initialization function so that it can only be invoked by functions with the
* {initializer} and {reinitializer} modifiers, directly or indirectly.
*/
modifier onlyInitializing() {
require(_initializing, "Initializable: contract is not initializing");
_;
}
/**
* @dev Locks the contract, preventing any future reinitialization. This cannot be part of an initializer call.
* Calling this in the constructor of a contract will prevent that contract from being initialized or reinitialized
* to any version. It is recommended to use this to lock implementation contracts that are designed to be called
* through proxies.
*
* Emits an {Initialized} event the first time it is successfully executed.
*/
function _disableInitializers() internal virtual {
require(!_initializing, "Initializable: contract is initializing");
if (_initialized != type(uint8).max) {
_initialized = type(uint8).max;
emit Initialized(type(uint8).max);
}
}
/**
* @dev Returns the highest version that has been initialized. See {reinitializer}.
*/
function _getInitializedVersion() internal view returns (uint8) {
return _initialized;
}
/**
* @dev Returns `true` if the contract is currently initializing. See {onlyInitializing}.
*/
function _isInitializing() internal view returns (bool) {
return _initializing;
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (utils/Address.sol)
pragma solidity ^0.8.1;
/**
* @dev Collection of functions related to the address type
*/
library AddressUpgradeable {
/**
* @dev Returns true if `account` is a contract.
*
* [IMPORTANT]
* ====
* It is unsafe to assume that an address for which this function returns
* false is an externally-owned account (EOA) and not a contract.
*
* Among others, `isContract` will return false for the following
* types of addresses:
*
* - an externally-owned account
* - a contract in construction
* - an address where a contract will be created
* - an address where a contract lived, but was destroyed
*
* Furthermore, `isContract` will also return true if the target contract within
* the same transaction is already scheduled for destruction by `SELFDESTRUCT`,
* which only has an effect at the end of a transaction.
* ====
*
* [IMPORTANT]
* ====
* You shouldn't rely on `isContract` to protect against flash loan attacks!
*
* Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets
* like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract
* constructor.
* ====
*/
function isContract(address account) internal view returns (bool) {
// This method relies on extcodesize/address.code.length, which returns 0
// for contracts in construction, since the code is only stored at the end
// of the constructor execution.
return account.code.length > 0;
}
/**
* @dev Replacement for Solidity's `transfer`: sends `amount` wei to
* `recipient`, forwarding all available gas and reverting on errors.
*
* https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost
* of certain opcodes, possibly making contracts go over the 2300 gas limit
* imposed by `transfer`, making them unable to receive funds via
* `transfer`. {sendValue} removes this limitation.
*
* https://consensys.net/diligence/blog/2019/09/stop-using-soliditys-transfer-now/[Learn more].
*
* IMPORTANT: because control is transferred to `recipient`, care must be
* taken to not create reentrancy vulnerabilities. Consider using
* {ReentrancyGuard} or the
* https://solidity.readthedocs.io/en/v0.8.0/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].
*/
function sendValue(address payable recipient, uint256 amount) internal {
require(address(this).balance >= amount, "Address: insufficient balance");
(bool success, ) = recipient.call{value: amount}("");
require(success, "Address: unable to send value, recipient may have reverted");
}
/**
* @dev Performs a Solidity function call using a low level `call`. A
* plain `call` is an unsafe replacement for a function call: use this
* function instead.
*
* If `target` reverts with a revert reason, it is bubbled up by this
* function (like regular Solidity function calls).
*
* Returns the raw returned data. To convert to the expected return value,
* use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].
*
* Requirements:
*
* - `target` must be a contract.
* - calling `target` with `data` must not revert.
*
* _Available since v3.1._
*/
function functionCall(address target, bytes memory data) internal returns (bytes memory) {
return functionCallWithValue(target, data, 0, "Address: low-level call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with
* `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCall(
address target,
bytes memory data,
string memory errorMessage
) internal returns (bytes memory) {
return functionCallWithValue(target, data, 0, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but also transferring `value` wei to `target`.
*
* Requirements:
*
* - the calling contract must have an ETH balance of at least `value`.
* - the called Solidity function must be `payable`.
*
* _Available since v3.1._
*/
function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) {
return functionCallWithValue(target, data, value, "Address: low-level call with value failed");
}
/**
* @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but
* with `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCallWithValue(
address target,
bytes memory data,
uint256 value,
string memory errorMessage
) internal returns (bytes memory) {
require(address(this).balance >= value, "Address: insufficient balance for call");
(bool success, bytes memory returndata) = target.call{value: value}(data);
return verifyCallResultFromTarget(target, success, returndata, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but performing a static call.
*
* _Available since v3.3._
*/
function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {
return functionStaticCall(target, data, "Address: low-level static call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
* but performing a static call.
*
* _Available since v3.3._
*/
function functionStaticCall(
address target,
bytes memory data,
string memory errorMessage
) internal view returns (bytes memory) {
(bool success, bytes memory returndata) = target.staticcall(data);
return verifyCallResultFromTarget(target, success, returndata, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but performing a delegate call.
*
* _Available since v3.4._
*/
function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {
return functionDelegateCall(target, data, "Address: low-level delegate call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
* but performing a delegate call.
*
* _Available since v3.4._
*/
function functionDelegateCall(
address target,
bytes memory data,
string memory errorMessage
) internal returns (bytes memory) {
(bool success, bytes memory returndata) = target.delegatecall(data);
return verifyCallResultFromTarget(target, success, returndata, errorMessage);
}
/**
* @dev Tool to verify that a low level call to smart-contract was successful, and revert (either by bubbling
* the revert reason or using the provided one) in case of unsuccessful call or if target was not a contract.
*
* _Available since v4.8._
*/
function verifyCallResultFromTarget(
address target,
bool success,
bytes memory returndata,
string memory errorMessage
) internal view returns (bytes memory) {
if (success) {
if (returndata.length == 0) {
// only check isContract if the call was successful and the return data is empty
// otherwise we already know that it was a contract
require(isContract(target), "Address: call to non-contract");
}
return returndata;
} else {
_revert(returndata, errorMessage);
}
}
/**
* @dev Tool to verify that a low level call was successful, and revert if it wasn't, either by bubbling the
* revert reason or using the provided one.
*
* _Available since v4.3._
*/
function verifyCallResult(
bool success,
bytes memory returndata,
string memory errorMessage
) internal pure returns (bytes memory) {
if (success) {
return returndata;
} else {
_revert(returndata, errorMessage);
}
}
function _revert(bytes memory returndata, string memory errorMessage) private pure {
// Look for revert reason and bubble it up if present
if (returndata.length > 0) {
// The easiest way to bubble the revert reason is using memory via assembly
/// @solidity memory-safe-assembly
assembly {
let returndata_size := mload(returndata)
revert(add(32, returndata), returndata_size)
}
} else {
revert(errorMessage);
}
}
}// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.8.0) (utils/cryptography/draft-EIP712.sol) pragma solidity ^0.8.0; // EIP-712 is Final as of 2022-08-11. This file is deprecated. import "./EIP712Upgradeable.sol";
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (utils/cryptography/ECDSA.sol)
pragma solidity ^0.8.0;
import "../StringsUpgradeable.sol";
/**
* @dev Elliptic Curve Digital Signature Algorithm (ECDSA) operations.
*
* These functions can be used to verify that a message was signed by the holder
* of the private keys of a given address.
*/
library ECDSAUpgradeable {
enum RecoverError {
NoError,
InvalidSignature,
InvalidSignatureLength,
InvalidSignatureS,
InvalidSignatureV // Deprecated in v4.8
}
function _throwError(RecoverError error) private pure {
if (error == RecoverError.NoError) {
return; // no error: do nothing
} else if (error == RecoverError.InvalidSignature) {
revert("ECDSA: invalid signature");
} else if (error == RecoverError.InvalidSignatureLength) {
revert("ECDSA: invalid signature length");
} else if (error == RecoverError.InvalidSignatureS) {
revert("ECDSA: invalid signature 's' value");
}
}
/**
* @dev Returns the address that signed a hashed message (`hash`) with
* `signature` or error string. This address can then be used for verification purposes.
*
* The `ecrecover` EVM opcode allows for malleable (non-unique) signatures:
* this function rejects them by requiring the `s` value to be in the lower
* half order, and the `v` value to be either 27 or 28.
*
* IMPORTANT: `hash` _must_ be the result of a hash operation for the
* verification to be secure: it is possible to craft signatures that
* recover to arbitrary addresses for non-hashed data. A safe way to ensure
* this is by receiving a hash of the original message (which may otherwise
* be too long), and then calling {toEthSignedMessageHash} on it.
*
* Documentation for signature generation:
* - with https://web3js.readthedocs.io/en/v1.3.4/web3-eth-accounts.html#sign[Web3.js]
* - with https://docs.ethers.io/v5/api/signer/#Signer-signMessage[ethers]
*
* _Available since v4.3._
*/
function tryRecover(bytes32 hash, bytes memory signature) internal pure returns (address, RecoverError) {
if (signature.length == 65) {
bytes32 r;
bytes32 s;
uint8 v;
// ecrecover takes the signature parameters, and the only way to get them
// currently is to use assembly.
/// @solidity memory-safe-assembly
assembly {
r := mload(add(signature, 0x20))
s := mload(add(signature, 0x40))
v := byte(0, mload(add(signature, 0x60)))
}
return tryRecover(hash, v, r, s);
} else {
return (address(0), RecoverError.InvalidSignatureLength);
}
}
/**
* @dev Returns the address that signed a hashed message (`hash`) with
* `signature`. This address can then be used for verification purposes.
*
* The `ecrecover` EVM opcode allows for malleable (non-unique) signatures:
* this function rejects them by requiring the `s` value to be in the lower
* half order, and the `v` value to be either 27 or 28.
*
* IMPORTANT: `hash` _must_ be the result of a hash operation for the
* verification to be secure: it is possible to craft signatures that
* recover to arbitrary addresses for non-hashed data. A safe way to ensure
* this is by receiving a hash of the original message (which may otherwise
* be too long), and then calling {toEthSignedMessageHash} on it.
*/
function recover(bytes32 hash, bytes memory signature) internal pure returns (address) {
(address recovered, RecoverError error) = tryRecover(hash, signature);
_throwError(error);
return recovered;
}
/**
* @dev Overload of {ECDSA-tryRecover} that receives the `r` and `vs` short-signature fields separately.
*
* See https://eips.ethereum.org/EIPS/eip-2098[EIP-2098 short signatures]
*
* _Available since v4.3._
*/
function tryRecover(bytes32 hash, bytes32 r, bytes32 vs) internal pure returns (address, RecoverError) {
bytes32 s = vs & bytes32(0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff);
uint8 v = uint8((uint256(vs) >> 255) + 27);
return tryRecover(hash, v, r, s);
}
/**
* @dev Overload of {ECDSA-recover} that receives the `r and `vs` short-signature fields separately.
*
* _Available since v4.2._
*/
function recover(bytes32 hash, bytes32 r, bytes32 vs) internal pure returns (address) {
(address recovered, RecoverError error) = tryRecover(hash, r, vs);
_throwError(error);
return recovered;
}
/**
* @dev Overload of {ECDSA-tryRecover} that receives the `v`,
* `r` and `s` signature fields separately.
*
* _Available since v4.3._
*/
function tryRecover(bytes32 hash, uint8 v, bytes32 r, bytes32 s) internal pure returns (address, RecoverError) {
// EIP-2 still allows signature malleability for ecrecover(). Remove this possibility and make the signature
// unique. Appendix F in the Ethereum Yellow paper (https://ethereum.github.io/yellowpaper/paper.pdf), defines
// the valid range for s in (301): 0 < s < secp256k1n ÷ 2 + 1, and for v in (302): v ∈ {27, 28}. Most
// signatures from current libraries generate a unique signature with an s-value in the lower half order.
//
// If your library generates malleable signatures, such as s-values in the upper range, calculate a new s-value
// with 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEBAAEDCE6AF48A03BBFD25E8CD0364141 - s1 and flip v from 27 to 28 or
// vice versa. If your library also generates signatures with 0/1 for v instead 27/28, add 27 to v to accept
// these malleable signatures as well.
if (uint256(s) > 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF5D576E7357A4501DDFE92F46681B20A0) {
return (address(0), RecoverError.InvalidSignatureS);
}
// If the signature is valid (and not malleable), return the signer address
address signer = ecrecover(hash, v, r, s);
if (signer == address(0)) {
return (address(0), RecoverError.InvalidSignature);
}
return (signer, RecoverError.NoError);
}
/**
* @dev Overload of {ECDSA-recover} that receives the `v`,
* `r` and `s` signature fields separately.
*/
function recover(bytes32 hash, uint8 v, bytes32 r, bytes32 s) internal pure returns (address) {
(address recovered, RecoverError error) = tryRecover(hash, v, r, s);
_throwError(error);
return recovered;
}
/**
* @dev Returns an Ethereum Signed Message, created from a `hash`. This
* produces hash corresponding to the one signed with the
* https://eth.wiki/json-rpc/API#eth_sign[`eth_sign`]
* JSON-RPC method as part of EIP-191.
*
* See {recover}.
*/
function toEthSignedMessageHash(bytes32 hash) internal pure returns (bytes32 message) {
// 32 is the length in bytes of hash,
// enforced by the type signature above
/// @solidity memory-safe-assembly
assembly {
mstore(0x00, "\x19Ethereum Signed Message:\n32")
mstore(0x1c, hash)
message := keccak256(0x00, 0x3c)
}
}
/**
* @dev Returns an Ethereum Signed Message, created from `s`. This
* produces hash corresponding to the one signed with the
* https://eth.wiki/json-rpc/API#eth_sign[`eth_sign`]
* JSON-RPC method as part of EIP-191.
*
* See {recover}.
*/
function toEthSignedMessageHash(bytes memory s) internal pure returns (bytes32) {
return keccak256(abi.encodePacked("\x19Ethereum Signed Message:\n", StringsUpgradeable.toString(s.length), s));
}
/**
* @dev Returns an Ethereum Signed Typed Data, created from a
* `domainSeparator` and a `structHash`. This produces hash corresponding
* to the one signed with the
* https://eips.ethereum.org/EIPS/eip-712[`eth_signTypedData`]
* JSON-RPC method as part of EIP-712.
*
* See {recover}.
*/
function toTypedDataHash(bytes32 domainSeparator, bytes32 structHash) internal pure returns (bytes32 data) {
/// @solidity memory-safe-assembly
assembly {
let ptr := mload(0x40)
mstore(ptr, "\x19\x01")
mstore(add(ptr, 0x02), domainSeparator)
mstore(add(ptr, 0x22), structHash)
data := keccak256(ptr, 0x42)
}
}
/**
* @dev Returns an Ethereum Signed Data with intended validator, created from a
* `validator` and `data` according to the version 0 of EIP-191.
*
* See {recover}.
*/
function toDataWithIntendedValidatorHash(address validator, bytes memory data) internal pure returns (bytes32) {
return keccak256(abi.encodePacked("\x19\x00", validator, data));
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (utils/cryptography/EIP712.sol)
pragma solidity ^0.8.8;
import "./ECDSAUpgradeable.sol";
import "../../interfaces/IERC5267Upgradeable.sol";
import "../../proxy/utils/Initializable.sol";
/**
* @dev https://eips.ethereum.org/EIPS/eip-712[EIP 712] is a standard for hashing and signing of typed structured data.
*
* The encoding specified in the EIP is very generic, and such a generic implementation in Solidity is not feasible,
* thus this contract does not implement the encoding itself. Protocols need to implement the type-specific encoding
* they need in their contracts using a combination of `abi.encode` and `keccak256`.
*
* This contract implements the EIP 712 domain separator ({_domainSeparatorV4}) that is used as part of the encoding
* scheme, and the final step of the encoding to obtain the message digest that is then signed via ECDSA
* ({_hashTypedDataV4}).
*
* The implementation of the domain separator was designed to be as efficient as possible while still properly updating
* the chain id to protect against replay attacks on an eventual fork of the chain.
*
* NOTE: This contract implements the version of the encoding known as "v4", as implemented by the JSON RPC method
* https://docs.metamask.io/guide/signing-data.html[`eth_signTypedDataV4` in MetaMask].
*
* NOTE: In the upgradeable version of this contract, the cached values will correspond to the address, and the domain
* separator of the implementation contract. This will cause the `_domainSeparatorV4` function to always rebuild the
* separator from the immutable values, which is cheaper than accessing a cached version in cold storage.
*
* _Available since v3.4._
*
* @custom:storage-size 52
*/
abstract contract EIP712Upgradeable is Initializable, IERC5267Upgradeable {
bytes32 private constant _TYPE_HASH =
keccak256("EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)");
/// @custom:oz-renamed-from _HASHED_NAME
bytes32 private _hashedName;
/// @custom:oz-renamed-from _HASHED_VERSION
bytes32 private _hashedVersion;
string private _name;
string private _version;
/**
* @dev Initializes the domain separator and parameter caches.
*
* The meaning of `name` and `version` is specified in
* https://eips.ethereum.org/EIPS/eip-712#definition-of-domainseparator[EIP 712]:
*
* - `name`: the user readable name of the signing domain, i.e. the name of the DApp or the protocol.
* - `version`: the current major version of the signing domain.
*
* NOTE: These parameters cannot be changed except through a xref:learn::upgrading-smart-contracts.adoc[smart
* contract upgrade].
*/
function __EIP712_init(string memory name, string memory version) internal onlyInitializing {
__EIP712_init_unchained(name, version);
}
function __EIP712_init_unchained(string memory name, string memory version) internal onlyInitializing {
_name = name;
_version = version;
// Reset prior values in storage if upgrading
_hashedName = 0;
_hashedVersion = 0;
}
/**
* @dev Returns the domain separator for the current chain.
*/
function _domainSeparatorV4() internal view returns (bytes32) {
return _buildDomainSeparator();
}
function _buildDomainSeparator() private view returns (bytes32) {
return keccak256(abi.encode(_TYPE_HASH, _EIP712NameHash(), _EIP712VersionHash(), block.chainid, address(this)));
}
/**
* @dev Given an already https://eips.ethereum.org/EIPS/eip-712#definition-of-hashstruct[hashed struct], this
* function returns the hash of the fully encoded EIP712 message for this domain.
*
* This hash can be used together with {ECDSA-recover} to obtain the signer of a message. For example:
*
* ```solidity
* bytes32 digest = _hashTypedDataV4(keccak256(abi.encode(
* keccak256("Mail(address to,string contents)"),
* mailTo,
* keccak256(bytes(mailContents))
* )));
* address signer = ECDSA.recover(digest, signature);
* ```
*/
function _hashTypedDataV4(bytes32 structHash) internal view virtual returns (bytes32) {
return ECDSAUpgradeable.toTypedDataHash(_domainSeparatorV4(), structHash);
}
/**
* @dev See {EIP-5267}.
*
* _Available since v4.9._
*/
function eip712Domain()
public
view
virtual
override
returns (
bytes1 fields,
string memory name,
string memory version,
uint256 chainId,
address verifyingContract,
bytes32 salt,
uint256[] memory extensions
)
{
// If the hashed name and version in storage are non-zero, the contract hasn't been properly initialized
// and the EIP712 domain is not reliable, as it will be missing name and version.
require(_hashedName == 0 && _hashedVersion == 0, "EIP712: Uninitialized");
return (
hex"0f", // 01111
_EIP712Name(),
_EIP712Version(),
block.chainid,
address(this),
bytes32(0),
new uint256[](0)
);
}
/**
* @dev The name parameter for the EIP712 domain.
*
* NOTE: This function reads from storage by default, but can be redefined to return a constant value if gas costs
* are a concern.
*/
function _EIP712Name() internal virtual view returns (string memory) {
return _name;
}
/**
* @dev The version parameter for the EIP712 domain.
*
* NOTE: This function reads from storage by default, but can be redefined to return a constant value if gas costs
* are a concern.
*/
function _EIP712Version() internal virtual view returns (string memory) {
return _version;
}
/**
* @dev The hash of the name parameter for the EIP712 domain.
*
* NOTE: In previous versions this function was virtual. In this version you should override `_EIP712Name` instead.
*/
function _EIP712NameHash() internal view returns (bytes32) {
string memory name = _EIP712Name();
if (bytes(name).length > 0) {
return keccak256(bytes(name));
} else {
// If the name is empty, the contract may have been upgraded without initializing the new storage.
// We return the name hash in storage if non-zero, otherwise we assume the name is empty by design.
bytes32 hashedName = _hashedName;
if (hashedName != 0) {
return hashedName;
} else {
return keccak256("");
}
}
}
/**
* @dev The hash of the version parameter for the EIP712 domain.
*
* NOTE: In previous versions this function was virtual. In this version you should override `_EIP712Version` instead.
*/
function _EIP712VersionHash() internal view returns (bytes32) {
string memory version = _EIP712Version();
if (bytes(version).length > 0) {
return keccak256(bytes(version));
} else {
// If the version is empty, the contract may have been upgraded without initializing the new storage.
// We return the version hash in storage if non-zero, otherwise we assume the version is empty by design.
bytes32 hashedVersion = _hashedVersion;
if (hashedVersion != 0) {
return hashedVersion;
} else {
return keccak256("");
}
}
}
/**
* @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[48] private __gap;
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (utils/math/Math.sol)
pragma solidity ^0.8.0;
/**
* @dev Standard math utilities missing in the Solidity language.
*/
library MathUpgradeable {
enum Rounding {
Down, // Toward negative infinity
Up, // Toward infinity
Zero // Toward zero
}
/**
* @dev Returns the largest of two numbers.
*/
function max(uint256 a, uint256 b) internal pure returns (uint256) {
return a > b ? a : b;
}
/**
* @dev Returns the smallest of two numbers.
*/
function min(uint256 a, uint256 b) internal pure returns (uint256) {
return a < b ? a : b;
}
/**
* @dev Returns the average of two numbers. The result is rounded towards
* zero.
*/
function average(uint256 a, uint256 b) internal pure returns (uint256) {
// (a + b) / 2 can overflow.
return (a & b) + (a ^ b) / 2;
}
/**
* @dev Returns the ceiling of the division of two numbers.
*
* This differs from standard division with `/` in that it rounds up instead
* of rounding down.
*/
function ceilDiv(uint256 a, uint256 b) internal pure returns (uint256) {
// (a + b - 1) / b can overflow on addition, so we distribute.
return a == 0 ? 0 : (a - 1) / b + 1;
}
/**
* @notice Calculates floor(x * y / denominator) with full precision. Throws if result overflows a uint256 or denominator == 0
* @dev Original credit to Remco Bloemen under MIT license (https://xn--2-umb.com/21/muldiv)
* with further edits by Uniswap Labs also under MIT license.
*/
function mulDiv(uint256 x, uint256 y, uint256 denominator) internal pure returns (uint256 result) {
unchecked {
// 512-bit multiply [prod1 prod0] = x * y. Compute the product mod 2^256 and mod 2^256 - 1, then use
// use the Chinese Remainder Theorem to reconstruct the 512 bit result. The result is stored in two 256
// variables such that product = prod1 * 2^256 + prod0.
uint256 prod0; // Least significant 256 bits of the product
uint256 prod1; // Most significant 256 bits of the product
assembly {
let mm := mulmod(x, y, not(0))
prod0 := mul(x, y)
prod1 := sub(sub(mm, prod0), lt(mm, prod0))
}
// Handle non-overflow cases, 256 by 256 division.
if (prod1 == 0) {
// Solidity will revert if denominator == 0, unlike the div opcode on its own.
// The surrounding unchecked block does not change this fact.
// See https://docs.soliditylang.org/en/latest/control-structures.html#checked-or-unchecked-arithmetic.
return prod0 / denominator;
}
// Make sure the result is less than 2^256. Also prevents denominator == 0.
require(denominator > prod1, "Math: mulDiv overflow");
///////////////////////////////////////////////
// 512 by 256 division.
///////////////////////////////////////////////
// Make division exact by subtracting the remainder from [prod1 prod0].
uint256 remainder;
assembly {
// Compute remainder using mulmod.
remainder := mulmod(x, y, denominator)
// Subtract 256 bit number from 512 bit number.
prod1 := sub(prod1, gt(remainder, prod0))
prod0 := sub(prod0, remainder)
}
// Factor powers of two out of denominator and compute largest power of two divisor of denominator. Always >= 1.
// See https://cs.stackexchange.com/q/138556/92363.
// Does not overflow because the denominator cannot be zero at this stage in the function.
uint256 twos = denominator & (~denominator + 1);
assembly {
// Divide denominator by twos.
denominator := div(denominator, twos)
// Divide [prod1 prod0] by twos.
prod0 := div(prod0, twos)
// Flip twos such that it is 2^256 / twos. If twos is zero, then it becomes one.
twos := add(div(sub(0, twos), twos), 1)
}
// Shift in bits from prod1 into prod0.
prod0 |= prod1 * twos;
// Invert denominator mod 2^256. Now that denominator is an odd number, it has an inverse modulo 2^256 such
// that denominator * inv = 1 mod 2^256. Compute the inverse by starting with a seed that is correct for
// four bits. That is, denominator * inv = 1 mod 2^4.
uint256 inverse = (3 * denominator) ^ 2;
// Use the Newton-Raphson iteration to improve the precision. Thanks to Hensel's lifting lemma, this also works
// in modular arithmetic, doubling the correct bits in each step.
inverse *= 2 - denominator * inverse; // inverse mod 2^8
inverse *= 2 - denominator * inverse; // inverse mod 2^16
inverse *= 2 - denominator * inverse; // inverse mod 2^32
inverse *= 2 - denominator * inverse; // inverse mod 2^64
inverse *= 2 - denominator * inverse; // inverse mod 2^128
inverse *= 2 - denominator * inverse; // inverse mod 2^256
// Because the division is now exact we can divide by multiplying with the modular inverse of denominator.
// This will give us the correct result modulo 2^256. Since the preconditions guarantee that the outcome is
// less than 2^256, this is the final result. We don't need to compute the high bits of the result and prod1
// is no longer required.
result = prod0 * inverse;
return result;
}
}
/**
* @notice Calculates x * y / denominator with full precision, following the selected rounding direction.
*/
function mulDiv(uint256 x, uint256 y, uint256 denominator, Rounding rounding) internal pure returns (uint256) {
uint256 result = mulDiv(x, y, denominator);
if (rounding == Rounding.Up && mulmod(x, y, denominator) > 0) {
result += 1;
}
return result;
}
/**
* @dev Returns the square root of a number. If the number is not a perfect square, the value is rounded down.
*
* Inspired by Henry S. Warren, Jr.'s "Hacker's Delight" (Chapter 11).
*/
function sqrt(uint256 a) internal pure returns (uint256) {
if (a == 0) {
return 0;
}
// For our first guess, we get the biggest power of 2 which is smaller than the square root of the target.
//
// We know that the "msb" (most significant bit) of our target number `a` is a power of 2 such that we have
// `msb(a) <= a < 2*msb(a)`. This value can be written `msb(a)=2**k` with `k=log2(a)`.
//
// This can be rewritten `2**log2(a) <= a < 2**(log2(a) + 1)`
// → `sqrt(2**k) <= sqrt(a) < sqrt(2**(k+1))`
// → `2**(k/2) <= sqrt(a) < 2**((k+1)/2) <= 2**(k/2 + 1)`
//
// Consequently, `2**(log2(a) / 2)` is a good first approximation of `sqrt(a)` with at least 1 correct bit.
uint256 result = 1 << (log2(a) >> 1);
// At this point `result` is an estimation with one bit of precision. We know the true value is a uint128,
// since it is the square root of a uint256. Newton's method converges quadratically (precision doubles at
// every iteration). We thus need at most 7 iteration to turn our partial result with one bit of precision
// into the expected uint128 result.
unchecked {
result = (result + a / result) >> 1;
result = (result + a / result) >> 1;
result = (result + a / result) >> 1;
result = (result + a / result) >> 1;
result = (result + a / result) >> 1;
result = (result + a / result) >> 1;
result = (result + a / result) >> 1;
return min(result, a / result);
}
}
/**
* @notice Calculates sqrt(a), following the selected rounding direction.
*/
function sqrt(uint256 a, Rounding rounding) internal pure returns (uint256) {
unchecked {
uint256 result = sqrt(a);
return result + (rounding == Rounding.Up && result * result < a ? 1 : 0);
}
}
/**
* @dev Return the log in base 2, rounded down, of a positive value.
* Returns 0 if given 0.
*/
function log2(uint256 value) internal pure returns (uint256) {
uint256 result = 0;
unchecked {
if (value >> 128 > 0) {
value >>= 128;
result += 128;
}
if (value >> 64 > 0) {
value >>= 64;
result += 64;
}
if (value >> 32 > 0) {
value >>= 32;
result += 32;
}
if (value >> 16 > 0) {
value >>= 16;
result += 16;
}
if (value >> 8 > 0) {
value >>= 8;
result += 8;
}
if (value >> 4 > 0) {
value >>= 4;
result += 4;
}
if (value >> 2 > 0) {
value >>= 2;
result += 2;
}
if (value >> 1 > 0) {
result += 1;
}
}
return result;
}
/**
* @dev Return the log in base 2, following the selected rounding direction, of a positive value.
* Returns 0 if given 0.
*/
function log2(uint256 value, Rounding rounding) internal pure returns (uint256) {
unchecked {
uint256 result = log2(value);
return result + (rounding == Rounding.Up && 1 << result < value ? 1 : 0);
}
}
/**
* @dev Return the log in base 10, rounded down, of a positive value.
* Returns 0 if given 0.
*/
function log10(uint256 value) internal pure returns (uint256) {
uint256 result = 0;
unchecked {
if (value >= 10 ** 64) {
value /= 10 ** 64;
result += 64;
}
if (value >= 10 ** 32) {
value /= 10 ** 32;
result += 32;
}
if (value >= 10 ** 16) {
value /= 10 ** 16;
result += 16;
}
if (value >= 10 ** 8) {
value /= 10 ** 8;
result += 8;
}
if (value >= 10 ** 4) {
value /= 10 ** 4;
result += 4;
}
if (value >= 10 ** 2) {
value /= 10 ** 2;
result += 2;
}
if (value >= 10 ** 1) {
result += 1;
}
}
return result;
}
/**
* @dev Return the log in base 10, following the selected rounding direction, of a positive value.
* Returns 0 if given 0.
*/
function log10(uint256 value, Rounding rounding) internal pure returns (uint256) {
unchecked {
uint256 result = log10(value);
return result + (rounding == Rounding.Up && 10 ** result < value ? 1 : 0);
}
}
/**
* @dev Return the log in base 256, rounded down, of a positive value.
* Returns 0 if given 0.
*
* Adding one to the result gives the number of pairs of hex symbols needed to represent `value` as a hex string.
*/
function log256(uint256 value) internal pure returns (uint256) {
uint256 result = 0;
unchecked {
if (value >> 128 > 0) {
value >>= 128;
result += 16;
}
if (value >> 64 > 0) {
value >>= 64;
result += 8;
}
if (value >> 32 > 0) {
value >>= 32;
result += 4;
}
if (value >> 16 > 0) {
value >>= 16;
result += 2;
}
if (value >> 8 > 0) {
result += 1;
}
}
return result;
}
/**
* @dev Return the log in base 256, following the selected rounding direction, of a positive value.
* Returns 0 if given 0.
*/
function log256(uint256 value, Rounding rounding) internal pure returns (uint256) {
unchecked {
uint256 result = log256(value);
return result + (rounding == Rounding.Up && 1 << (result << 3) < value ? 1 : 0);
}
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.8.0) (utils/math/SignedMath.sol)
pragma solidity ^0.8.0;
/**
* @dev Standard signed math utilities missing in the Solidity language.
*/
library SignedMathUpgradeable {
/**
* @dev Returns the largest of two signed numbers.
*/
function max(int256 a, int256 b) internal pure returns (int256) {
return a > b ? a : b;
}
/**
* @dev Returns the smallest of two signed numbers.
*/
function min(int256 a, int256 b) internal pure returns (int256) {
return a < b ? a : b;
}
/**
* @dev Returns the average of two signed numbers without overflow.
* The result is rounded towards zero.
*/
function average(int256 a, int256 b) internal pure returns (int256) {
// Formula from the book "Hacker's Delight"
int256 x = (a & b) + ((a ^ b) >> 1);
return x + (int256(uint256(x) >> 255) & (a ^ b));
}
/**
* @dev Returns the absolute unsigned value of a signed value.
*/
function abs(int256 n) internal pure returns (uint256) {
unchecked {
// must be unchecked in order to support `n = type(int256).min`
return uint256(n >= 0 ? n : -n);
}
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (utils/Strings.sol)
pragma solidity ^0.8.0;
import "./math/MathUpgradeable.sol";
import "./math/SignedMathUpgradeable.sol";
/**
* @dev String operations.
*/
library StringsUpgradeable {
bytes16 private constant _SYMBOLS = "0123456789abcdef";
uint8 private constant _ADDRESS_LENGTH = 20;
/**
* @dev Converts a `uint256` to its ASCII `string` decimal representation.
*/
function toString(uint256 value) internal pure returns (string memory) {
unchecked {
uint256 length = MathUpgradeable.log10(value) + 1;
string memory buffer = new string(length);
uint256 ptr;
/// @solidity memory-safe-assembly
assembly {
ptr := add(buffer, add(32, length))
}
while (true) {
ptr--;
/// @solidity memory-safe-assembly
assembly {
mstore8(ptr, byte(mod(value, 10), _SYMBOLS))
}
value /= 10;
if (value == 0) break;
}
return buffer;
}
}
/**
* @dev Converts a `int256` to its ASCII `string` decimal representation.
*/
function toString(int256 value) internal pure returns (string memory) {
return string(abi.encodePacked(value < 0 ? "-" : "", toString(SignedMathUpgradeable.abs(value))));
}
/**
* @dev Converts a `uint256` to its ASCII `string` hexadecimal representation.
*/
function toHexString(uint256 value) internal pure returns (string memory) {
unchecked {
return toHexString(value, MathUpgradeable.log256(value) + 1);
}
}
/**
* @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length.
*/
function toHexString(uint256 value, uint256 length) internal pure returns (string memory) {
bytes memory buffer = new bytes(2 * length + 2);
buffer[0] = "0";
buffer[1] = "x";
for (uint256 i = 2 * length + 1; i > 1; --i) {
buffer[i] = _SYMBOLS[value & 0xf];
value >>= 4;
}
require(value == 0, "Strings: hex length insufficient");
return string(buffer);
}
/**
* @dev Converts an `address` with fixed length of 20 bytes to its not checksummed ASCII `string` hexadecimal representation.
*/
function toHexString(address addr) internal pure returns (string memory) {
return toHexString(uint256(uint160(addr)), _ADDRESS_LENGTH);
}
/**
* @dev Returns true if the two strings are equal.
*/
function equal(string memory a, string memory b) internal pure returns (bool) {
return keccak256(bytes(a)) == keccak256(bytes(b));
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (interfaces/IERC5267.sol)
pragma solidity ^0.8.0;
interface IERC5267 {
/**
* @dev MAY be emitted to signal that the domain could have changed.
*/
event EIP712DomainChanged();
/**
* @dev returns the fields and values that describe the domain separator used by this contract for EIP-712
* signature.
*/
function eip712Domain()
external
view
returns (
bytes1 fields,
string memory name,
string memory version,
uint256 chainId,
address verifyingContract,
bytes32 salt,
uint256[] memory extensions
);
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.0) (security/Pausable.sol)
pragma solidity ^0.8.0;
import "../utils/Context.sol";
/**
* @dev Contract module which allows children to implement an emergency stop
* mechanism that can be triggered by an authorized account.
*
* This module is used through inheritance. It will make available the
* modifiers `whenNotPaused` and `whenPaused`, which can be applied to
* the functions of your contract. Note that they will not be pausable by
* simply including this module, only once the modifiers are put in place.
*/
abstract contract Pausable is Context {
/**
* @dev Emitted when the pause is triggered by `account`.
*/
event Paused(address account);
/**
* @dev Emitted when the pause is lifted by `account`.
*/
event Unpaused(address account);
bool private _paused;
/**
* @dev Initializes the contract in unpaused state.
*/
constructor() {
_paused = false;
}
/**
* @dev Modifier to make a function callable only when the contract is not paused.
*
* Requirements:
*
* - The contract must not be paused.
*/
modifier whenNotPaused() {
_requireNotPaused();
_;
}
/**
* @dev Modifier to make a function callable only when the contract is paused.
*
* Requirements:
*
* - The contract must be paused.
*/
modifier whenPaused() {
_requirePaused();
_;
}
/**
* @dev Returns true if the contract is paused, and false otherwise.
*/
function paused() public view virtual returns (bool) {
return _paused;
}
/**
* @dev Throws if the contract is paused.
*/
function _requireNotPaused() internal view virtual {
require(!paused(), "Pausable: paused");
}
/**
* @dev Throws if the contract is not paused.
*/
function _requirePaused() internal view virtual {
require(paused(), "Pausable: not paused");
}
/**
* @dev Triggers stopped state.
*
* Requirements:
*
* - The contract must not be paused.
*/
function _pause() internal virtual whenNotPaused {
_paused = true;
emit Paused(_msgSender());
}
/**
* @dev Returns to normal state.
*
* Requirements:
*
* - The contract must be paused.
*/
function _unpause() internal virtual whenPaused {
_paused = false;
emit Unpaused(_msgSender());
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (token/ERC20/ERC20.sol)
pragma solidity ^0.8.0;
import "./IERC20.sol";
import "./extensions/IERC20Metadata.sol";
import "../../utils/Context.sol";
/**
* @dev Implementation of the {IERC20} interface.
*
* This implementation is agnostic to the way tokens are created. This means
* that a supply mechanism has to be added in a derived contract using {_mint}.
* For a generic mechanism see {ERC20PresetMinterPauser}.
*
* TIP: For a detailed writeup see our guide
* https://forum.openzeppelin.com/t/how-to-implement-erc20-supply-mechanisms/226[How
* to implement supply mechanisms].
*
* The default value of {decimals} is 18. To change this, you should override
* this function so it returns a different value.
*
* We have followed general OpenZeppelin Contracts guidelines: functions revert
* instead returning `false` on failure. This behavior is nonetheless
* conventional and does not conflict with the expectations of ERC20
* applications.
*
* Additionally, an {Approval} event is emitted on calls to {transferFrom}.
* This allows applications to reconstruct the allowance for all accounts just
* by listening to said events. Other implementations of the EIP may not emit
* these events, as it isn't required by the specification.
*
* Finally, the non-standard {decreaseAllowance} and {increaseAllowance}
* functions have been added to mitigate the well-known issues around setting
* allowances. See {IERC20-approve}.
*/
contract ERC20 is Context, IERC20, IERC20Metadata {
mapping(address => uint256) private _balances;
mapping(address => mapping(address => uint256)) private _allowances;
uint256 private _totalSupply;
string private _name;
string private _symbol;
/**
* @dev Sets the values for {name} and {symbol}.
*
* All two of these values are immutable: they can only be set once during
* construction.
*/
constructor(string memory name_, string memory symbol_) {
_name = name_;
_symbol = symbol_;
}
/**
* @dev Returns the name of the token.
*/
function name() public view virtual override returns (string memory) {
return _name;
}
/**
* @dev Returns the symbol of the token, usually a shorter version of the
* name.
*/
function symbol() public view virtual override returns (string memory) {
return _symbol;
}
/**
* @dev Returns the number of decimals used to get its user representation.
* For example, if `decimals` equals `2`, a balance of `505` tokens should
* be displayed to a user as `5.05` (`505 / 10 ** 2`).
*
* Tokens usually opt for a value of 18, imitating the relationship between
* Ether and Wei. This is the default value returned by this function, unless
* it's overridden.
*
* NOTE: This information is only used for _display_ purposes: it in
* no way affects any of the arithmetic of the contract, including
* {IERC20-balanceOf} and {IERC20-transfer}.
*/
function decimals() public view virtual override returns (uint8) {
return 18;
}
/**
* @dev See {IERC20-totalSupply}.
*/
function totalSupply() public view virtual override returns (uint256) {
return _totalSupply;
}
/**
* @dev See {IERC20-balanceOf}.
*/
function balanceOf(address account) public view virtual override returns (uint256) {
return _balances[account];
}
/**
* @dev See {IERC20-transfer}.
*
* Requirements:
*
* - `to` cannot be the zero address.
* - the caller must have a balance of at least `amount`.
*/
function transfer(address to, uint256 amount) public virtual override returns (bool) {
address owner = _msgSender();
_transfer(owner, to, amount);
return true;
}
/**
* @dev See {IERC20-allowance}.
*/
function allowance(address owner, address spender) public view virtual override returns (uint256) {
return _allowances[owner][spender];
}
/**
* @dev See {IERC20-approve}.
*
* NOTE: If `amount` is the maximum `uint256`, the allowance is not updated on
* `transferFrom`. This is semantically equivalent to an infinite approval.
*
* Requirements:
*
* - `spender` cannot be the zero address.
*/
function approve(address spender, uint256 amount) public virtual override returns (bool) {
address owner = _msgSender();
_approve(owner, spender, amount);
return true;
}
/**
* @dev See {IERC20-transferFrom}.
*
* Emits an {Approval} event indicating the updated allowance. This is not
* required by the EIP. See the note at the beginning of {ERC20}.
*
* NOTE: Does not update the allowance if the current allowance
* is the maximum `uint256`.
*
* Requirements:
*
* - `from` and `to` cannot be the zero address.
* - `from` must have a balance of at least `amount`.
* - the caller must have allowance for ``from``'s tokens of at least
* `amount`.
*/
function transferFrom(address from, address to, uint256 amount) public virtual override returns (bool) {
address spender = _msgSender();
_spendAllowance(from, spender, amount);
_transfer(from, to, amount);
return true;
}
/**
* @dev Atomically increases the allowance granted to `spender` by the caller.
*
* This is an alternative to {approve} that can be used as a mitigation for
* problems described in {IERC20-approve}.
*
* Emits an {Approval} event indicating the updated allowance.
*
* Requirements:
*
* - `spender` cannot be the zero address.
*/
function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) {
address owner = _msgSender();
_approve(owner, spender, allowance(owner, spender) + addedValue);
return true;
}
/**
* @dev Atomically decreases the allowance granted to `spender` by the caller.
*
* This is an alternative to {approve} that can be used as a mitigation for
* problems described in {IERC20-approve}.
*
* Emits an {Approval} event indicating the updated allowance.
*
* Requirements:
*
* - `spender` cannot be the zero address.
* - `spender` must have allowance for the caller of at least
* `subtractedValue`.
*/
function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) {
address owner = _msgSender();
uint256 currentAllowance = allowance(owner, spender);
require(currentAllowance >= subtractedValue, "ERC20: decreased allowance below zero");
unchecked {
_approve(owner, spender, currentAllowance - subtractedValue);
}
return true;
}
/**
* @dev Moves `amount` of tokens from `from` to `to`.
*
* This internal function is equivalent to {transfer}, and can be used to
* e.g. implement automatic token fees, slashing mechanisms, etc.
*
* Emits a {Transfer} event.
*
* Requirements:
*
* - `from` cannot be the zero address.
* - `to` cannot be the zero address.
* - `from` must have a balance of at least `amount`.
*/
function _transfer(address from, address to, uint256 amount) internal virtual {
require(from != address(0), "ERC20: transfer from the zero address");
require(to != address(0), "ERC20: transfer to the zero address");
_beforeTokenTransfer(from, to, amount);
uint256 fromBalance = _balances[from];
require(fromBalance >= amount, "ERC20: transfer amount exceeds balance");
unchecked {
_balances[from] = fromBalance - amount;
// Overflow not possible: the sum of all balances is capped by totalSupply, and the sum is preserved by
// decrementing then incrementing.
_balances[to] += amount;
}
emit Transfer(from, to, amount);
_afterTokenTransfer(from, to, amount);
}
/** @dev Creates `amount` tokens and assigns them to `account`, increasing
* the total supply.
*
* Emits a {Transfer} event with `from` set to the zero address.
*
* Requirements:
*
* - `account` cannot be the zero address.
*/
function _mint(address account, uint256 amount) internal virtual {
require(account != address(0), "ERC20: mint to the zero address");
_beforeTokenTransfer(address(0), account, amount);
_totalSupply += amount;
unchecked {
// Overflow not possible: balance + amount is at most totalSupply + amount, which is checked above.
_balances[account] += amount;
}
emit Transfer(address(0), account, amount);
_afterTokenTransfer(address(0), account, amount);
}
/**
* @dev Destroys `amount` tokens from `account`, reducing the
* total supply.
*
* Emits a {Transfer} event with `to` set to the zero address.
*
* Requirements:
*
* - `account` cannot be the zero address.
* - `account` must have at least `amount` tokens.
*/
function _burn(address account, uint256 amount) internal virtual {
require(account != address(0), "ERC20: burn from the zero address");
_beforeTokenTransfer(account, address(0), amount);
uint256 accountBalance = _balances[account];
require(accountBalance >= amount, "ERC20: burn amount exceeds balance");
unchecked {
_balances[account] = accountBalance - amount;
// Overflow not possible: amount <= accountBalance <= totalSupply.
_totalSupply -= amount;
}
emit Transfer(account, address(0), amount);
_afterTokenTransfer(account, address(0), amount);
}
/**
* @dev Sets `amount` as the allowance of `spender` over the `owner` s tokens.
*
* This internal function is equivalent to `approve`, and can be used to
* e.g. set automatic allowances for certain subsystems, etc.
*
* Emits an {Approval} event.
*
* Requirements:
*
* - `owner` cannot be the zero address.
* - `spender` cannot be the zero address.
*/
function _approve(address owner, address spender, uint256 amount) internal virtual {
require(owner != address(0), "ERC20: approve from the zero address");
require(spender != address(0), "ERC20: approve to the zero address");
_allowances[owner][spender] = amount;
emit Approval(owner, spender, amount);
}
/**
* @dev Updates `owner` s allowance for `spender` based on spent `amount`.
*
* Does not update the allowance amount in case of infinite allowance.
* Revert if not enough allowance is available.
*
* Might emit an {Approval} event.
*/
function _spendAllowance(address owner, address spender, uint256 amount) internal virtual {
uint256 currentAllowance = allowance(owner, spender);
if (currentAllowance != type(uint256).max) {
require(currentAllowance >= amount, "ERC20: insufficient allowance");
unchecked {
_approve(owner, spender, currentAllowance - amount);
}
}
}
/**
* @dev Hook that is called before any transfer of tokens. This includes
* minting and burning.
*
* Calling conditions:
*
* - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens
* will be transferred to `to`.
* - when `from` is zero, `amount` tokens will be minted for `to`.
* - when `to` is zero, `amount` of ``from``'s tokens will be burned.
* - `from` and `to` are never both zero.
*
* To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].
*/
function _beforeTokenTransfer(address from, address to, uint256 amount) internal virtual {}
/**
* @dev Hook that is called after any transfer of tokens. This includes
* minting and burning.
*
* Calling conditions:
*
* - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens
* has been transferred to `to`.
* - when `from` is zero, `amount` tokens have been minted for `to`.
* - when `to` is zero, `amount` of ``from``'s tokens have been burned.
* - `from` and `to` are never both zero.
*
* To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].
*/
function _afterTokenTransfer(address from, address to, uint256 amount) internal virtual {}
}// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.9.0) (token/ERC20/extensions/draft-ERC20Permit.sol) pragma solidity ^0.8.0; // EIP-2612 is Final as of 2022-11-01. This file is deprecated. import "./ERC20Permit.sol";
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (token/ERC20/extensions/ERC20Permit.sol)
pragma solidity ^0.8.0;
import "./IERC20Permit.sol";
import "../ERC20.sol";
import "../../../utils/cryptography/ECDSA.sol";
import "../../../utils/cryptography/EIP712.sol";
import "../../../utils/Counters.sol";
/**
* @dev Implementation of the ERC20 Permit extension allowing approvals to be made via signatures, as defined in
* https://eips.ethereum.org/EIPS/eip-2612[EIP-2612].
*
* Adds the {permit} method, which can be used to change an account's ERC20 allowance (see {IERC20-allowance}) by
* presenting a message signed by the account. By not relying on `{IERC20-approve}`, the token holder account doesn't
* need to send a transaction, and thus is not required to hold Ether at all.
*
* _Available since v3.4._
*/
abstract contract ERC20Permit is ERC20, IERC20Permit, EIP712 {
using Counters for Counters.Counter;
mapping(address => Counters.Counter) private _nonces;
// solhint-disable-next-line var-name-mixedcase
bytes32 private constant _PERMIT_TYPEHASH =
keccak256("Permit(address owner,address spender,uint256 value,uint256 nonce,uint256 deadline)");
/**
* @dev In previous versions `_PERMIT_TYPEHASH` was declared as `immutable`.
* However, to ensure consistency with the upgradeable transpiler, we will continue
* to reserve a slot.
* @custom:oz-renamed-from _PERMIT_TYPEHASH
*/
// solhint-disable-next-line var-name-mixedcase
bytes32 private _PERMIT_TYPEHASH_DEPRECATED_SLOT;
/**
* @dev Initializes the {EIP712} domain separator using the `name` parameter, and setting `version` to `"1"`.
*
* It's a good idea to use the same `name` that is defined as the ERC20 token name.
*/
constructor(string memory name) EIP712(name, "1") {}
/**
* @dev See {IERC20Permit-permit}.
*/
function permit(
address owner,
address spender,
uint256 value,
uint256 deadline,
uint8 v,
bytes32 r,
bytes32 s
) public virtual override {
require(block.timestamp <= deadline, "ERC20Permit: expired deadline");
bytes32 structHash = keccak256(abi.encode(_PERMIT_TYPEHASH, owner, spender, value, _useNonce(owner), deadline));
bytes32 hash = _hashTypedDataV4(structHash);
address signer = ECDSA.recover(hash, v, r, s);
require(signer == owner, "ERC20Permit: invalid signature");
_approve(owner, spender, value);
}
/**
* @dev See {IERC20Permit-nonces}.
*/
function nonces(address owner) public view virtual override returns (uint256) {
return _nonces[owner].current();
}
/**
* @dev See {IERC20Permit-DOMAIN_SEPARATOR}.
*/
// solhint-disable-next-line func-name-mixedcase
function DOMAIN_SEPARATOR() external view override returns (bytes32) {
return _domainSeparatorV4();
}
/**
* @dev "Consume a nonce": return the current value and increment.
*
* _Available since v4.1._
*/
function _useNonce(address owner) internal virtual returns (uint256 current) {
Counters.Counter storage nonce = _nonces[owner];
current = nonce.current();
nonce.increment();
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/IERC20Metadata.sol)
pragma solidity ^0.8.0;
import "../IERC20.sol";
/**
* @dev Interface for the optional metadata functions from the ERC20 standard.
*
* _Available since v4.1._
*/
interface IERC20Metadata is IERC20 {
/**
* @dev Returns the name of the token.
*/
function name() external view returns (string memory);
/**
* @dev Returns the symbol of the token.
*/
function symbol() external view returns (string memory);
/**
* @dev Returns the decimals places of the token.
*/
function decimals() external view returns (uint8);
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (token/ERC20/extensions/IERC20Permit.sol)
pragma solidity ^0.8.0;
/**
* @dev Interface of the ERC20 Permit extension allowing approvals to be made via signatures, as defined in
* https://eips.ethereum.org/EIPS/eip-2612[EIP-2612].
*
* Adds the {permit} method, which can be used to change an account's ERC20 allowance (see {IERC20-allowance}) by
* presenting a message signed by the account. By not relying on {IERC20-approve}, the token holder account doesn't
* need to send a transaction, and thus is not required to hold Ether at all.
*/
interface IERC20Permit {
/**
* @dev Sets `value` as the allowance of `spender` over ``owner``'s tokens,
* given ``owner``'s signed approval.
*
* IMPORTANT: The same issues {IERC20-approve} has related to transaction
* ordering also apply here.
*
* Emits an {Approval} event.
*
* Requirements:
*
* - `spender` cannot be the zero address.
* - `deadline` must be a timestamp in the future.
* - `v`, `r` and `s` must be a valid `secp256k1` signature from `owner`
* over the EIP712-formatted function arguments.
* - the signature must use ``owner``'s current nonce (see {nonces}).
*
* For more information on the signature format, see the
* https://eips.ethereum.org/EIPS/eip-2612#specification[relevant EIP
* section].
*/
function permit(
address owner,
address spender,
uint256 value,
uint256 deadline,
uint8 v,
bytes32 r,
bytes32 s
) external;
/**
* @dev Returns the current nonce for `owner`. This value must be
* included whenever a signature is generated for {permit}.
*
* Every successful call to {permit} increases ``owner``'s nonce by one. This
* prevents a signature from being used multiple times.
*/
function nonces(address owner) external view returns (uint256);
/**
* @dev Returns the domain separator used in the encoding of the signature for {permit}, as defined by {EIP712}.
*/
// solhint-disable-next-line func-name-mixedcase
function DOMAIN_SEPARATOR() external view returns (bytes32);
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (token/ERC20/IERC20.sol)
pragma solidity ^0.8.0;
/**
* @dev Interface of the ERC20 standard as defined in the EIP.
*/
interface IERC20 {
/**
* @dev Emitted when `value` tokens are moved from one account (`from`) to
* another (`to`).
*
* Note that `value` may be zero.
*/
event Transfer(address indexed from, address indexed to, uint256 value);
/**
* @dev Emitted when the allowance of a `spender` for an `owner` is set by
* a call to {approve}. `value` is the new allowance.
*/
event Approval(address indexed owner, address indexed spender, uint256 value);
/**
* @dev Returns the amount of tokens in existence.
*/
function totalSupply() external view returns (uint256);
/**
* @dev Returns the amount of tokens owned by `account`.
*/
function balanceOf(address account) external view returns (uint256);
/**
* @dev Moves `amount` tokens from the caller's account to `to`.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transfer(address to, uint256 amount) external returns (bool);
/**
* @dev Returns the remaining number of tokens that `spender` will be
* allowed to spend on behalf of `owner` through {transferFrom}. This is
* zero by default.
*
* This value changes when {approve} or {transferFrom} are called.
*/
function allowance(address owner, address spender) external view returns (uint256);
/**
* @dev Sets `amount` as the allowance of `spender` over the caller's tokens.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* IMPORTANT: Beware that changing an allowance with this method brings the risk
* that someone may use both the old and the new allowance by unfortunate
* transaction ordering. One possible solution to mitigate this race
* condition is to first reduce the spender's allowance to 0 and set the
* desired value afterwards:
* https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
*
* Emits an {Approval} event.
*/
function approve(address spender, uint256 amount) external returns (bool);
/**
* @dev Moves `amount` tokens from `from` to `to` using the
* allowance mechanism. `amount` is then deducted from the caller's
* allowance.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transferFrom(address from, address to, uint256 amount) external returns (bool);
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.3) (token/ERC20/utils/SafeERC20.sol)
pragma solidity ^0.8.0;
import "../IERC20.sol";
import "../extensions/IERC20Permit.sol";
import "../../../utils/Address.sol";
/**
* @title SafeERC20
* @dev Wrappers around ERC20 operations that throw on failure (when the token
* contract returns false). Tokens that return no value (and instead revert or
* throw on failure) are also supported, non-reverting calls are assumed to be
* successful.
* To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract,
* which allows you to call the safe operations as `token.safeTransfer(...)`, etc.
*/
library SafeERC20 {
using Address for address;
/**
* @dev Transfer `value` amount of `token` from the calling contract to `to`. If `token` returns no value,
* non-reverting calls are assumed to be successful.
*/
function safeTransfer(IERC20 token, address to, uint256 value) internal {
_callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value));
}
/**
* @dev Transfer `value` amount of `token` from `from` to `to`, spending the approval given by `from` to the
* calling contract. If `token` returns no value, non-reverting calls are assumed to be successful.
*/
function safeTransferFrom(IERC20 token, address from, address to, uint256 value) internal {
_callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value));
}
/**
* @dev Deprecated. This function has issues similar to the ones found in
* {IERC20-approve}, and its usage is discouraged.
*
* Whenever possible, use {safeIncreaseAllowance} and
* {safeDecreaseAllowance} instead.
*/
function safeApprove(IERC20 token, address spender, uint256 value) internal {
// safeApprove should only be called when setting an initial allowance,
// or when resetting it to zero. To increase and decrease it, use
// 'safeIncreaseAllowance' and 'safeDecreaseAllowance'
require(
(value == 0) || (token.allowance(address(this), spender) == 0),
"SafeERC20: approve from non-zero to non-zero allowance"
);
_callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value));
}
/**
* @dev Increase the calling contract's allowance toward `spender` by `value`. If `token` returns no value,
* non-reverting calls are assumed to be successful.
*/
function safeIncreaseAllowance(IERC20 token, address spender, uint256 value) internal {
uint256 oldAllowance = token.allowance(address(this), spender);
_callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, oldAllowance + value));
}
/**
* @dev Decrease the calling contract's allowance toward `spender` by `value`. If `token` returns no value,
* non-reverting calls are assumed to be successful.
*/
function safeDecreaseAllowance(IERC20 token, address spender, uint256 value) internal {
unchecked {
uint256 oldAllowance = token.allowance(address(this), spender);
require(oldAllowance >= value, "SafeERC20: decreased allowance below zero");
_callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, oldAllowance - value));
}
}
/**
* @dev Set the calling contract's allowance toward `spender` to `value`. If `token` returns no value,
* non-reverting calls are assumed to be successful. Meant to be used with tokens that require the approval
* to be set to zero before setting it to a non-zero value, such as USDT.
*/
function forceApprove(IERC20 token, address spender, uint256 value) internal {
bytes memory approvalCall = abi.encodeWithSelector(token.approve.selector, spender, value);
if (!_callOptionalReturnBool(token, approvalCall)) {
_callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, 0));
_callOptionalReturn(token, approvalCall);
}
}
/**
* @dev Use a ERC-2612 signature to set the `owner` approval toward `spender` on `token`.
* Revert on invalid signature.
*/
function safePermit(
IERC20Permit token,
address owner,
address spender,
uint256 value,
uint256 deadline,
uint8 v,
bytes32 r,
bytes32 s
) internal {
uint256 nonceBefore = token.nonces(owner);
token.permit(owner, spender, value, deadline, v, r, s);
uint256 nonceAfter = token.nonces(owner);
require(nonceAfter == nonceBefore + 1, "SafeERC20: permit did not succeed");
}
/**
* @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement
* on the return value: the return value is optional (but if data is returned, it must not be false).
* @param token The token targeted by the call.
* @param data The call data (encoded using abi.encode or one of its variants).
*/
function _callOptionalReturn(IERC20 token, bytes memory data) private {
// We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since
// we're implementing it ourselves. We use {Address-functionCall} to perform this call, which verifies that
// the target address contains contract code and also asserts for success in the low-level call.
bytes memory returndata = address(token).functionCall(data, "SafeERC20: low-level call failed");
require(returndata.length == 0 || abi.decode(returndata, (bool)), "SafeERC20: ERC20 operation did not succeed");
}
/**
* @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement
* on the return value: the return value is optional (but if data is returned, it must not be false).
* @param token The token targeted by the call.
* @param data The call data (encoded using abi.encode or one of its variants).
*
* This is a variant of {_callOptionalReturn} that silents catches all reverts and returns a bool instead.
*/
function _callOptionalReturnBool(IERC20 token, bytes memory data) private returns (bool) {
// We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since
// we're implementing it ourselves. We cannot use {Address-functionCall} here since this should return false
// and not revert is the subcall reverts.
(bool success, bytes memory returndata) = address(token).call(data);
return
success && (returndata.length == 0 || abi.decode(returndata, (bool))) && Address.isContract(address(token));
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (utils/Address.sol)
pragma solidity ^0.8.1;
/**
* @dev Collection of functions related to the address type
*/
library Address {
/**
* @dev Returns true if `account` is a contract.
*
* [IMPORTANT]
* ====
* It is unsafe to assume that an address for which this function returns
* false is an externally-owned account (EOA) and not a contract.
*
* Among others, `isContract` will return false for the following
* types of addresses:
*
* - an externally-owned account
* - a contract in construction
* - an address where a contract will be created
* - an address where a contract lived, but was destroyed
*
* Furthermore, `isContract` will also return true if the target contract within
* the same transaction is already scheduled for destruction by `SELFDESTRUCT`,
* which only has an effect at the end of a transaction.
* ====
*
* [IMPORTANT]
* ====
* You shouldn't rely on `isContract` to protect against flash loan attacks!
*
* Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets
* like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract
* constructor.
* ====
*/
function isContract(address account) internal view returns (bool) {
// This method relies on extcodesize/address.code.length, which returns 0
// for contracts in construction, since the code is only stored at the end
// of the constructor execution.
return account.code.length > 0;
}
/**
* @dev Replacement for Solidity's `transfer`: sends `amount` wei to
* `recipient`, forwarding all available gas and reverting on errors.
*
* https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost
* of certain opcodes, possibly making contracts go over the 2300 gas limit
* imposed by `transfer`, making them unable to receive funds via
* `transfer`. {sendValue} removes this limitation.
*
* https://consensys.net/diligence/blog/2019/09/stop-using-soliditys-transfer-now/[Learn more].
*
* IMPORTANT: because control is transferred to `recipient`, care must be
* taken to not create reentrancy vulnerabilities. Consider using
* {ReentrancyGuard} or the
* https://solidity.readthedocs.io/en/v0.8.0/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].
*/
function sendValue(address payable recipient, uint256 amount) internal {
require(address(this).balance >= amount, "Address: insufficient balance");
(bool success, ) = recipient.call{value: amount}("");
require(success, "Address: unable to send value, recipient may have reverted");
}
/**
* @dev Performs a Solidity function call using a low level `call`. A
* plain `call` is an unsafe replacement for a function call: use this
* function instead.
*
* If `target` reverts with a revert reason, it is bubbled up by this
* function (like regular Solidity function calls).
*
* Returns the raw returned data. To convert to the expected return value,
* use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].
*
* Requirements:
*
* - `target` must be a contract.
* - calling `target` with `data` must not revert.
*
* _Available since v3.1._
*/
function functionCall(address target, bytes memory data) internal returns (bytes memory) {
return functionCallWithValue(target, data, 0, "Address: low-level call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with
* `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCall(
address target,
bytes memory data,
string memory errorMessage
) internal returns (bytes memory) {
return functionCallWithValue(target, data, 0, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but also transferring `value` wei to `target`.
*
* Requirements:
*
* - the calling contract must have an ETH balance of at least `value`.
* - the called Solidity function must be `payable`.
*
* _Available since v3.1._
*/
function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) {
return functionCallWithValue(target, data, value, "Address: low-level call with value failed");
}
/**
* @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but
* with `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCallWithValue(
address target,
bytes memory data,
uint256 value,
string memory errorMessage
) internal returns (bytes memory) {
require(address(this).balance >= value, "Address: insufficient balance for call");
(bool success, bytes memory returndata) = target.call{value: value}(data);
return verifyCallResultFromTarget(target, success, returndata, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but performing a static call.
*
* _Available since v3.3._
*/
function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {
return functionStaticCall(target, data, "Address: low-level static call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
* but performing a static call.
*
* _Available since v3.3._
*/
function functionStaticCall(
address target,
bytes memory data,
string memory errorMessage
) internal view returns (bytes memory) {
(bool success, bytes memory returndata) = target.staticcall(data);
return verifyCallResultFromTarget(target, success, returndata, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but performing a delegate call.
*
* _Available since v3.4._
*/
function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {
return functionDelegateCall(target, data, "Address: low-level delegate call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
* but performing a delegate call.
*
* _Available since v3.4._
*/
function functionDelegateCall(
address target,
bytes memory data,
string memory errorMessage
) internal returns (bytes memory) {
(bool success, bytes memory returndata) = target.delegatecall(data);
return verifyCallResultFromTarget(target, success, returndata, errorMessage);
}
/**
* @dev Tool to verify that a low level call to smart-contract was successful, and revert (either by bubbling
* the revert reason or using the provided one) in case of unsuccessful call or if target was not a contract.
*
* _Available since v4.8._
*/
function verifyCallResultFromTarget(
address target,
bool success,
bytes memory returndata,
string memory errorMessage
) internal view returns (bytes memory) {
if (success) {
if (returndata.length == 0) {
// only check isContract if the call was successful and the return data is empty
// otherwise we already know that it was a contract
require(isContract(target), "Address: call to non-contract");
}
return returndata;
} else {
_revert(returndata, errorMessage);
}
}
/**
* @dev Tool to verify that a low level call was successful, and revert if it wasn't, either by bubbling the
* revert reason or using the provided one.
*
* _Available since v4.3._
*/
function verifyCallResult(
bool success,
bytes memory returndata,
string memory errorMessage
) internal pure returns (bytes memory) {
if (success) {
return returndata;
} else {
_revert(returndata, errorMessage);
}
}
function _revert(bytes memory returndata, string memory errorMessage) private pure {
// Look for revert reason and bubble it up if present
if (returndata.length > 0) {
// The easiest way to bubble the revert reason is using memory via assembly
/// @solidity memory-safe-assembly
assembly {
let returndata_size := mload(returndata)
revert(add(32, returndata), returndata_size)
}
} else {
revert(errorMessage);
}
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/Context.sol)
pragma solidity ^0.8.0;
/**
* @dev Provides information about the current execution context, including the
* sender of the transaction and its data. While these are generally available
* via msg.sender and msg.data, they should not be accessed in such a direct
* manner, since when dealing with meta-transactions the account sending and
* paying for execution may not be the actual sender (as far as an application
* is concerned).
*
* This contract is only required for intermediate, library-like contracts.
*/
abstract contract Context {
function _msgSender() internal view virtual returns (address) {
return msg.sender;
}
function _msgData() internal view virtual returns (bytes calldata) {
return msg.data;
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/Counters.sol)
pragma solidity ^0.8.0;
/**
* @title Counters
* @author Matt Condon (@shrugs)
* @dev Provides counters that can only be incremented, decremented or reset. This can be used e.g. to track the number
* of elements in a mapping, issuing ERC721 ids, or counting request ids.
*
* Include with `using Counters for Counters.Counter;`
*/
library Counters {
struct Counter {
// This variable should never be directly accessed by users of the library: interactions must be restricted to
// the library's function. As of Solidity v0.5.2, this cannot be enforced, though there is a proposal to add
// this feature: see https://github.com/ethereum/solidity/issues/4637
uint256 _value; // default: 0
}
function current(Counter storage counter) internal view returns (uint256) {
return counter._value;
}
function increment(Counter storage counter) internal {
unchecked {
counter._value += 1;
}
}
function decrement(Counter storage counter) internal {
uint256 value = counter._value;
require(value > 0, "Counter: decrement overflow");
unchecked {
counter._value = value - 1;
}
}
function reset(Counter storage counter) internal {
counter._value = 0;
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (utils/cryptography/ECDSA.sol)
pragma solidity ^0.8.0;
import "../Strings.sol";
/**
* @dev Elliptic Curve Digital Signature Algorithm (ECDSA) operations.
*
* These functions can be used to verify that a message was signed by the holder
* of the private keys of a given address.
*/
library ECDSA {
enum RecoverError {
NoError,
InvalidSignature,
InvalidSignatureLength,
InvalidSignatureS,
InvalidSignatureV // Deprecated in v4.8
}
function _throwError(RecoverError error) private pure {
if (error == RecoverError.NoError) {
return; // no error: do nothing
} else if (error == RecoverError.InvalidSignature) {
revert("ECDSA: invalid signature");
} else if (error == RecoverError.InvalidSignatureLength) {
revert("ECDSA: invalid signature length");
} else if (error == RecoverError.InvalidSignatureS) {
revert("ECDSA: invalid signature 's' value");
}
}
/**
* @dev Returns the address that signed a hashed message (`hash`) with
* `signature` or error string. This address can then be used for verification purposes.
*
* The `ecrecover` EVM opcode allows for malleable (non-unique) signatures:
* this function rejects them by requiring the `s` value to be in the lower
* half order, and the `v` value to be either 27 or 28.
*
* IMPORTANT: `hash` _must_ be the result of a hash operation for the
* verification to be secure: it is possible to craft signatures that
* recover to arbitrary addresses for non-hashed data. A safe way to ensure
* this is by receiving a hash of the original message (which may otherwise
* be too long), and then calling {toEthSignedMessageHash} on it.
*
* Documentation for signature generation:
* - with https://web3js.readthedocs.io/en/v1.3.4/web3-eth-accounts.html#sign[Web3.js]
* - with https://docs.ethers.io/v5/api/signer/#Signer-signMessage[ethers]
*
* _Available since v4.3._
*/
function tryRecover(bytes32 hash, bytes memory signature) internal pure returns (address, RecoverError) {
if (signature.length == 65) {
bytes32 r;
bytes32 s;
uint8 v;
// ecrecover takes the signature parameters, and the only way to get them
// currently is to use assembly.
/// @solidity memory-safe-assembly
assembly {
r := mload(add(signature, 0x20))
s := mload(add(signature, 0x40))
v := byte(0, mload(add(signature, 0x60)))
}
return tryRecover(hash, v, r, s);
} else {
return (address(0), RecoverError.InvalidSignatureLength);
}
}
/**
* @dev Returns the address that signed a hashed message (`hash`) with
* `signature`. This address can then be used for verification purposes.
*
* The `ecrecover` EVM opcode allows for malleable (non-unique) signatures:
* this function rejects them by requiring the `s` value to be in the lower
* half order, and the `v` value to be either 27 or 28.
*
* IMPORTANT: `hash` _must_ be the result of a hash operation for the
* verification to be secure: it is possible to craft signatures that
* recover to arbitrary addresses for non-hashed data. A safe way to ensure
* this is by receiving a hash of the original message (which may otherwise
* be too long), and then calling {toEthSignedMessageHash} on it.
*/
function recover(bytes32 hash, bytes memory signature) internal pure returns (address) {
(address recovered, RecoverError error) = tryRecover(hash, signature);
_throwError(error);
return recovered;
}
/**
* @dev Overload of {ECDSA-tryRecover} that receives the `r` and `vs` short-signature fields separately.
*
* See https://eips.ethereum.org/EIPS/eip-2098[EIP-2098 short signatures]
*
* _Available since v4.3._
*/
function tryRecover(bytes32 hash, bytes32 r, bytes32 vs) internal pure returns (address, RecoverError) {
bytes32 s = vs & bytes32(0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff);
uint8 v = uint8((uint256(vs) >> 255) + 27);
return tryRecover(hash, v, r, s);
}
/**
* @dev Overload of {ECDSA-recover} that receives the `r and `vs` short-signature fields separately.
*
* _Available since v4.2._
*/
function recover(bytes32 hash, bytes32 r, bytes32 vs) internal pure returns (address) {
(address recovered, RecoverError error) = tryRecover(hash, r, vs);
_throwError(error);
return recovered;
}
/**
* @dev Overload of {ECDSA-tryRecover} that receives the `v`,
* `r` and `s` signature fields separately.
*
* _Available since v4.3._
*/
function tryRecover(bytes32 hash, uint8 v, bytes32 r, bytes32 s) internal pure returns (address, RecoverError) {
// EIP-2 still allows signature malleability for ecrecover(). Remove this possibility and make the signature
// unique. Appendix F in the Ethereum Yellow paper (https://ethereum.github.io/yellowpaper/paper.pdf), defines
// the valid range for s in (301): 0 < s < secp256k1n ÷ 2 + 1, and for v in (302): v ∈ {27, 28}. Most
// signatures from current libraries generate a unique signature with an s-value in the lower half order.
//
// If your library generates malleable signatures, such as s-values in the upper range, calculate a new s-value
// with 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEBAAEDCE6AF48A03BBFD25E8CD0364141 - s1 and flip v from 27 to 28 or
// vice versa. If your library also generates signatures with 0/1 for v instead 27/28, add 27 to v to accept
// these malleable signatures as well.
if (uint256(s) > 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF5D576E7357A4501DDFE92F46681B20A0) {
return (address(0), RecoverError.InvalidSignatureS);
}
// If the signature is valid (and not malleable), return the signer address
address signer = ecrecover(hash, v, r, s);
if (signer == address(0)) {
return (address(0), RecoverError.InvalidSignature);
}
return (signer, RecoverError.NoError);
}
/**
* @dev Overload of {ECDSA-recover} that receives the `v`,
* `r` and `s` signature fields separately.
*/
function recover(bytes32 hash, uint8 v, bytes32 r, bytes32 s) internal pure returns (address) {
(address recovered, RecoverError error) = tryRecover(hash, v, r, s);
_throwError(error);
return recovered;
}
/**
* @dev Returns an Ethereum Signed Message, created from a `hash`. This
* produces hash corresponding to the one signed with the
* https://eth.wiki/json-rpc/API#eth_sign[`eth_sign`]
* JSON-RPC method as part of EIP-191.
*
* See {recover}.
*/
function toEthSignedMessageHash(bytes32 hash) internal pure returns (bytes32 message) {
// 32 is the length in bytes of hash,
// enforced by the type signature above
/// @solidity memory-safe-assembly
assembly {
mstore(0x00, "\x19Ethereum Signed Message:\n32")
mstore(0x1c, hash)
message := keccak256(0x00, 0x3c)
}
}
/**
* @dev Returns an Ethereum Signed Message, created from `s`. This
* produces hash corresponding to the one signed with the
* https://eth.wiki/json-rpc/API#eth_sign[`eth_sign`]
* JSON-RPC method as part of EIP-191.
*
* See {recover}.
*/
function toEthSignedMessageHash(bytes memory s) internal pure returns (bytes32) {
return keccak256(abi.encodePacked("\x19Ethereum Signed Message:\n", Strings.toString(s.length), s));
}
/**
* @dev Returns an Ethereum Signed Typed Data, created from a
* `domainSeparator` and a `structHash`. This produces hash corresponding
* to the one signed with the
* https://eips.ethereum.org/EIPS/eip-712[`eth_signTypedData`]
* JSON-RPC method as part of EIP-712.
*
* See {recover}.
*/
function toTypedDataHash(bytes32 domainSeparator, bytes32 structHash) internal pure returns (bytes32 data) {
/// @solidity memory-safe-assembly
assembly {
let ptr := mload(0x40)
mstore(ptr, "\x19\x01")
mstore(add(ptr, 0x02), domainSeparator)
mstore(add(ptr, 0x22), structHash)
data := keccak256(ptr, 0x42)
}
}
/**
* @dev Returns an Ethereum Signed Data with intended validator, created from a
* `validator` and `data` according to the version 0 of EIP-191.
*
* See {recover}.
*/
function toDataWithIntendedValidatorHash(address validator, bytes memory data) internal pure returns (bytes32) {
return keccak256(abi.encodePacked("\x19\x00", validator, data));
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (utils/cryptography/EIP712.sol)
pragma solidity ^0.8.8;
import "./ECDSA.sol";
import "../ShortStrings.sol";
import "../../interfaces/IERC5267.sol";
/**
* @dev https://eips.ethereum.org/EIPS/eip-712[EIP 712] is a standard for hashing and signing of typed structured data.
*
* The encoding specified in the EIP is very generic, and such a generic implementation in Solidity is not feasible,
* thus this contract does not implement the encoding itself. Protocols need to implement the type-specific encoding
* they need in their contracts using a combination of `abi.encode` and `keccak256`.
*
* This contract implements the EIP 712 domain separator ({_domainSeparatorV4}) that is used as part of the encoding
* scheme, and the final step of the encoding to obtain the message digest that is then signed via ECDSA
* ({_hashTypedDataV4}).
*
* The implementation of the domain separator was designed to be as efficient as possible while still properly updating
* the chain id to protect against replay attacks on an eventual fork of the chain.
*
* NOTE: This contract implements the version of the encoding known as "v4", as implemented by the JSON RPC method
* https://docs.metamask.io/guide/signing-data.html[`eth_signTypedDataV4` in MetaMask].
*
* NOTE: In the upgradeable version of this contract, the cached values will correspond to the address, and the domain
* separator of the implementation contract. This will cause the `_domainSeparatorV4` function to always rebuild the
* separator from the immutable values, which is cheaper than accessing a cached version in cold storage.
*
* _Available since v3.4._
*
* @custom:oz-upgrades-unsafe-allow state-variable-immutable state-variable-assignment
*/
abstract contract EIP712 is IERC5267 {
using ShortStrings for *;
bytes32 private constant _TYPE_HASH =
keccak256("EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)");
// Cache the domain separator as an immutable value, but also store the chain id that it corresponds to, in order to
// invalidate the cached domain separator if the chain id changes.
bytes32 private immutable _cachedDomainSeparator;
uint256 private immutable _cachedChainId;
address private immutable _cachedThis;
bytes32 private immutable _hashedName;
bytes32 private immutable _hashedVersion;
ShortString private immutable _name;
ShortString private immutable _version;
string private _nameFallback;
string private _versionFallback;
/**
* @dev Initializes the domain separator and parameter caches.
*
* The meaning of `name` and `version` is specified in
* https://eips.ethereum.org/EIPS/eip-712#definition-of-domainseparator[EIP 712]:
*
* - `name`: the user readable name of the signing domain, i.e. the name of the DApp or the protocol.
* - `version`: the current major version of the signing domain.
*
* NOTE: These parameters cannot be changed except through a xref:learn::upgrading-smart-contracts.adoc[smart
* contract upgrade].
*/
constructor(string memory name, string memory version) {
_name = name.toShortStringWithFallback(_nameFallback);
_version = version.toShortStringWithFallback(_versionFallback);
_hashedName = keccak256(bytes(name));
_hashedVersion = keccak256(bytes(version));
_cachedChainId = block.chainid;
_cachedDomainSeparator = _buildDomainSeparator();
_cachedThis = address(this);
}
/**
* @dev Returns the domain separator for the current chain.
*/
function _domainSeparatorV4() internal view returns (bytes32) {
if (address(this) == _cachedThis && block.chainid == _cachedChainId) {
return _cachedDomainSeparator;
} else {
return _buildDomainSeparator();
}
}
function _buildDomainSeparator() private view returns (bytes32) {
return keccak256(abi.encode(_TYPE_HASH, _hashedName, _hashedVersion, block.chainid, address(this)));
}
/**
* @dev Given an already https://eips.ethereum.org/EIPS/eip-712#definition-of-hashstruct[hashed struct], this
* function returns the hash of the fully encoded EIP712 message for this domain.
*
* This hash can be used together with {ECDSA-recover} to obtain the signer of a message. For example:
*
* ```solidity
* bytes32 digest = _hashTypedDataV4(keccak256(abi.encode(
* keccak256("Mail(address to,string contents)"),
* mailTo,
* keccak256(bytes(mailContents))
* )));
* address signer = ECDSA.recover(digest, signature);
* ```
*/
function _hashTypedDataV4(bytes32 structHash) internal view virtual returns (bytes32) {
return ECDSA.toTypedDataHash(_domainSeparatorV4(), structHash);
}
/**
* @dev See {EIP-5267}.
*
* _Available since v4.9._
*/
function eip712Domain()
public
view
virtual
override
returns (
bytes1 fields,
string memory name,
string memory version,
uint256 chainId,
address verifyingContract,
bytes32 salt,
uint256[] memory extensions
)
{
return (
hex"0f", // 01111
_name.toStringWithFallback(_nameFallback),
_version.toStringWithFallback(_versionFallback),
block.chainid,
address(this),
bytes32(0),
new uint256[](0)
);
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (utils/math/Math.sol)
pragma solidity ^0.8.0;
/**
* @dev Standard math utilities missing in the Solidity language.
*/
library Math {
enum Rounding {
Down, // Toward negative infinity
Up, // Toward infinity
Zero // Toward zero
}
/**
* @dev Returns the largest of two numbers.
*/
function max(uint256 a, uint256 b) internal pure returns (uint256) {
return a > b ? a : b;
}
/**
* @dev Returns the smallest of two numbers.
*/
function min(uint256 a, uint256 b) internal pure returns (uint256) {
return a < b ? a : b;
}
/**
* @dev Returns the average of two numbers. The result is rounded towards
* zero.
*/
function average(uint256 a, uint256 b) internal pure returns (uint256) {
// (a + b) / 2 can overflow.
return (a & b) + (a ^ b) / 2;
}
/**
* @dev Returns the ceiling of the division of two numbers.
*
* This differs from standard division with `/` in that it rounds up instead
* of rounding down.
*/
function ceilDiv(uint256 a, uint256 b) internal pure returns (uint256) {
// (a + b - 1) / b can overflow on addition, so we distribute.
return a == 0 ? 0 : (a - 1) / b + 1;
}
/**
* @notice Calculates floor(x * y / denominator) with full precision. Throws if result overflows a uint256 or denominator == 0
* @dev Original credit to Remco Bloemen under MIT license (https://xn--2-umb.com/21/muldiv)
* with further edits by Uniswap Labs also under MIT license.
*/
function mulDiv(uint256 x, uint256 y, uint256 denominator) internal pure returns (uint256 result) {
unchecked {
// 512-bit multiply [prod1 prod0] = x * y. Compute the product mod 2^256 and mod 2^256 - 1, then use
// use the Chinese Remainder Theorem to reconstruct the 512 bit result. The result is stored in two 256
// variables such that product = prod1 * 2^256 + prod0.
uint256 prod0; // Least significant 256 bits of the product
uint256 prod1; // Most significant 256 bits of the product
assembly {
let mm := mulmod(x, y, not(0))
prod0 := mul(x, y)
prod1 := sub(sub(mm, prod0), lt(mm, prod0))
}
// Handle non-overflow cases, 256 by 256 division.
if (prod1 == 0) {
// Solidity will revert if denominator == 0, unlike the div opcode on its own.
// The surrounding unchecked block does not change this fact.
// See https://docs.soliditylang.org/en/latest/control-structures.html#checked-or-unchecked-arithmetic.
return prod0 / denominator;
}
// Make sure the result is less than 2^256. Also prevents denominator == 0.
require(denominator > prod1, "Math: mulDiv overflow");
///////////////////////////////////////////////
// 512 by 256 division.
///////////////////////////////////////////////
// Make division exact by subtracting the remainder from [prod1 prod0].
uint256 remainder;
assembly {
// Compute remainder using mulmod.
remainder := mulmod(x, y, denominator)
// Subtract 256 bit number from 512 bit number.
prod1 := sub(prod1, gt(remainder, prod0))
prod0 := sub(prod0, remainder)
}
// Factor powers of two out of denominator and compute largest power of two divisor of denominator. Always >= 1.
// See https://cs.stackexchange.com/q/138556/92363.
// Does not overflow because the denominator cannot be zero at this stage in the function.
uint256 twos = denominator & (~denominator + 1);
assembly {
// Divide denominator by twos.
denominator := div(denominator, twos)
// Divide [prod1 prod0] by twos.
prod0 := div(prod0, twos)
// Flip twos such that it is 2^256 / twos. If twos is zero, then it becomes one.
twos := add(div(sub(0, twos), twos), 1)
}
// Shift in bits from prod1 into prod0.
prod0 |= prod1 * twos;
// Invert denominator mod 2^256. Now that denominator is an odd number, it has an inverse modulo 2^256 such
// that denominator * inv = 1 mod 2^256. Compute the inverse by starting with a seed that is correct for
// four bits. That is, denominator * inv = 1 mod 2^4.
uint256 inverse = (3 * denominator) ^ 2;
// Use the Newton-Raphson iteration to improve the precision. Thanks to Hensel's lifting lemma, this also works
// in modular arithmetic, doubling the correct bits in each step.
inverse *= 2 - denominator * inverse; // inverse mod 2^8
inverse *= 2 - denominator * inverse; // inverse mod 2^16
inverse *= 2 - denominator * inverse; // inverse mod 2^32
inverse *= 2 - denominator * inverse; // inverse mod 2^64
inverse *= 2 - denominator * inverse; // inverse mod 2^128
inverse *= 2 - denominator * inverse; // inverse mod 2^256
// Because the division is now exact we can divide by multiplying with the modular inverse of denominator.
// This will give us the correct result modulo 2^256. Since the preconditions guarantee that the outcome is
// less than 2^256, this is the final result. We don't need to compute the high bits of the result and prod1
// is no longer required.
result = prod0 * inverse;
return result;
}
}
/**
* @notice Calculates x * y / denominator with full precision, following the selected rounding direction.
*/
function mulDiv(uint256 x, uint256 y, uint256 denominator, Rounding rounding) internal pure returns (uint256) {
uint256 result = mulDiv(x, y, denominator);
if (rounding == Rounding.Up && mulmod(x, y, denominator) > 0) {
result += 1;
}
return result;
}
/**
* @dev Returns the square root of a number. If the number is not a perfect square, the value is rounded down.
*
* Inspired by Henry S. Warren, Jr.'s "Hacker's Delight" (Chapter 11).
*/
function sqrt(uint256 a) internal pure returns (uint256) {
if (a == 0) {
return 0;
}
// For our first guess, we get the biggest power of 2 which is smaller than the square root of the target.
//
// We know that the "msb" (most significant bit) of our target number `a` is a power of 2 such that we have
// `msb(a) <= a < 2*msb(a)`. This value can be written `msb(a)=2**k` with `k=log2(a)`.
//
// This can be rewritten `2**log2(a) <= a < 2**(log2(a) + 1)`
// → `sqrt(2**k) <= sqrt(a) < sqrt(2**(k+1))`
// → `2**(k/2) <= sqrt(a) < 2**((k+1)/2) <= 2**(k/2 + 1)`
//
// Consequently, `2**(log2(a) / 2)` is a good first approximation of `sqrt(a)` with at least 1 correct bit.
uint256 result = 1 << (log2(a) >> 1);
// At this point `result` is an estimation with one bit of precision. We know the true value is a uint128,
// since it is the square root of a uint256. Newton's method converges quadratically (precision doubles at
// every iteration). We thus need at most 7 iteration to turn our partial result with one bit of precision
// into the expected uint128 result.
unchecked {
result = (result + a / result) >> 1;
result = (result + a / result) >> 1;
result = (result + a / result) >> 1;
result = (result + a / result) >> 1;
result = (result + a / result) >> 1;
result = (result + a / result) >> 1;
result = (result + a / result) >> 1;
return min(result, a / result);
}
}
/**
* @notice Calculates sqrt(a), following the selected rounding direction.
*/
function sqrt(uint256 a, Rounding rounding) internal pure returns (uint256) {
unchecked {
uint256 result = sqrt(a);
return result + (rounding == Rounding.Up && result * result < a ? 1 : 0);
}
}
/**
* @dev Return the log in base 2, rounded down, of a positive value.
* Returns 0 if given 0.
*/
function log2(uint256 value) internal pure returns (uint256) {
uint256 result = 0;
unchecked {
if (value >> 128 > 0) {
value >>= 128;
result += 128;
}
if (value >> 64 > 0) {
value >>= 64;
result += 64;
}
if (value >> 32 > 0) {
value >>= 32;
result += 32;
}
if (value >> 16 > 0) {
value >>= 16;
result += 16;
}
if (value >> 8 > 0) {
value >>= 8;
result += 8;
}
if (value >> 4 > 0) {
value >>= 4;
result += 4;
}
if (value >> 2 > 0) {
value >>= 2;
result += 2;
}
if (value >> 1 > 0) {
result += 1;
}
}
return result;
}
/**
* @dev Return the log in base 2, following the selected rounding direction, of a positive value.
* Returns 0 if given 0.
*/
function log2(uint256 value, Rounding rounding) internal pure returns (uint256) {
unchecked {
uint256 result = log2(value);
return result + (rounding == Rounding.Up && 1 << result < value ? 1 : 0);
}
}
/**
* @dev Return the log in base 10, rounded down, of a positive value.
* Returns 0 if given 0.
*/
function log10(uint256 value) internal pure returns (uint256) {
uint256 result = 0;
unchecked {
if (value >= 10 ** 64) {
value /= 10 ** 64;
result += 64;
}
if (value >= 10 ** 32) {
value /= 10 ** 32;
result += 32;
}
if (value >= 10 ** 16) {
value /= 10 ** 16;
result += 16;
}
if (value >= 10 ** 8) {
value /= 10 ** 8;
result += 8;
}
if (value >= 10 ** 4) {
value /= 10 ** 4;
result += 4;
}
if (value >= 10 ** 2) {
value /= 10 ** 2;
result += 2;
}
if (value >= 10 ** 1) {
result += 1;
}
}
return result;
}
/**
* @dev Return the log in base 10, following the selected rounding direction, of a positive value.
* Returns 0 if given 0.
*/
function log10(uint256 value, Rounding rounding) internal pure returns (uint256) {
unchecked {
uint256 result = log10(value);
return result + (rounding == Rounding.Up && 10 ** result < value ? 1 : 0);
}
}
/**
* @dev Return the log in base 256, rounded down, of a positive value.
* Returns 0 if given 0.
*
* Adding one to the result gives the number of pairs of hex symbols needed to represent `value` as a hex string.
*/
function log256(uint256 value) internal pure returns (uint256) {
uint256 result = 0;
unchecked {
if (value >> 128 > 0) {
value >>= 128;
result += 16;
}
if (value >> 64 > 0) {
value >>= 64;
result += 8;
}
if (value >> 32 > 0) {
value >>= 32;
result += 4;
}
if (value >> 16 > 0) {
value >>= 16;
result += 2;
}
if (value >> 8 > 0) {
result += 1;
}
}
return result;
}
/**
* @dev Return the log in base 256, following the selected rounding direction, of a positive value.
* Returns 0 if given 0.
*/
function log256(uint256 value, Rounding rounding) internal pure returns (uint256) {
unchecked {
uint256 result = log256(value);
return result + (rounding == Rounding.Up && 1 << (result << 3) < value ? 1 : 0);
}
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.8.0) (utils/math/SignedMath.sol)
pragma solidity ^0.8.0;
/**
* @dev Standard signed math utilities missing in the Solidity language.
*/
library SignedMath {
/**
* @dev Returns the largest of two signed numbers.
*/
function max(int256 a, int256 b) internal pure returns (int256) {
return a > b ? a : b;
}
/**
* @dev Returns the smallest of two signed numbers.
*/
function min(int256 a, int256 b) internal pure returns (int256) {
return a < b ? a : b;
}
/**
* @dev Returns the average of two signed numbers without overflow.
* The result is rounded towards zero.
*/
function average(int256 a, int256 b) internal pure returns (int256) {
// Formula from the book "Hacker's Delight"
int256 x = (a & b) + ((a ^ b) >> 1);
return x + (int256(uint256(x) >> 255) & (a ^ b));
}
/**
* @dev Returns the absolute unsigned value of a signed value.
*/
function abs(int256 n) internal pure returns (uint256) {
unchecked {
// must be unchecked in order to support `n = type(int256).min`
return uint256(n >= 0 ? n : -n);
}
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (utils/ShortStrings.sol)
pragma solidity ^0.8.8;
import "./StorageSlot.sol";
// | string | 0xAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA |
// | length | 0x BB |
type ShortString is bytes32;
/**
* @dev This library provides functions to convert short memory strings
* into a `ShortString` type that can be used as an immutable variable.
*
* Strings of arbitrary length can be optimized using this library if
* they are short enough (up to 31 bytes) by packing them with their
* length (1 byte) in a single EVM word (32 bytes). Additionally, a
* fallback mechanism can be used for every other case.
*
* Usage example:
*
* ```solidity
* contract Named {
* using ShortStrings for *;
*
* ShortString private immutable _name;
* string private _nameFallback;
*
* constructor(string memory contractName) {
* _name = contractName.toShortStringWithFallback(_nameFallback);
* }
*
* function name() external view returns (string memory) {
* return _name.toStringWithFallback(_nameFallback);
* }
* }
* ```
*/
library ShortStrings {
// Used as an identifier for strings longer than 31 bytes.
bytes32 private constant _FALLBACK_SENTINEL = 0x00000000000000000000000000000000000000000000000000000000000000FF;
error StringTooLong(string str);
error InvalidShortString();
/**
* @dev Encode a string of at most 31 chars into a `ShortString`.
*
* This will trigger a `StringTooLong` error is the input string is too long.
*/
function toShortString(string memory str) internal pure returns (ShortString) {
bytes memory bstr = bytes(str);
if (bstr.length > 31) {
revert StringTooLong(str);
}
return ShortString.wrap(bytes32(uint256(bytes32(bstr)) | bstr.length));
}
/**
* @dev Decode a `ShortString` back to a "normal" string.
*/
function toString(ShortString sstr) internal pure returns (string memory) {
uint256 len = byteLength(sstr);
// using `new string(len)` would work locally but is not memory safe.
string memory str = new string(32);
/// @solidity memory-safe-assembly
assembly {
mstore(str, len)
mstore(add(str, 0x20), sstr)
}
return str;
}
/**
* @dev Return the length of a `ShortString`.
*/
function byteLength(ShortString sstr) internal pure returns (uint256) {
uint256 result = uint256(ShortString.unwrap(sstr)) & 0xFF;
if (result > 31) {
revert InvalidShortString();
}
return result;
}
/**
* @dev Encode a string into a `ShortString`, or write it to storage if it is too long.
*/
function toShortStringWithFallback(string memory value, string storage store) internal returns (ShortString) {
if (bytes(value).length < 32) {
return toShortString(value);
} else {
StorageSlot.getStringSlot(store).value = value;
return ShortString.wrap(_FALLBACK_SENTINEL);
}
}
/**
* @dev Decode a string that was encoded to `ShortString` or written to storage using {setWithFallback}.
*/
function toStringWithFallback(ShortString value, string storage store) internal pure returns (string memory) {
if (ShortString.unwrap(value) != _FALLBACK_SENTINEL) {
return toString(value);
} else {
return store;
}
}
/**
* @dev Return the length of a string that was encoded to `ShortString` or written to storage using {setWithFallback}.
*
* WARNING: This will return the "byte length" of the string. This may not reflect the actual length in terms of
* actual characters as the UTF-8 encoding of a single character can span over multiple bytes.
*/
function byteLengthWithFallback(ShortString value, string storage store) internal view returns (uint256) {
if (ShortString.unwrap(value) != _FALLBACK_SENTINEL) {
return byteLength(value);
} else {
return bytes(store).length;
}
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (utils/StorageSlot.sol)
// This file was procedurally generated from scripts/generate/templates/StorageSlot.js.
pragma solidity ^0.8.0;
/**
* @dev Library for reading and writing primitive types to specific storage slots.
*
* Storage slots are often used to avoid storage conflict when dealing with upgradeable contracts.
* This library helps with reading and writing to such slots without the need for inline assembly.
*
* The functions in this library return Slot structs that contain a `value` member that can be used to read or write.
*
* Example usage to set ERC1967 implementation slot:
* ```solidity
* contract ERC1967 {
* bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;
*
* function _getImplementation() internal view returns (address) {
* return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value;
* }
*
* function _setImplementation(address newImplementation) internal {
* require(Address.isContract(newImplementation), "ERC1967: new implementation is not a contract");
* StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation;
* }
* }
* ```
*
* _Available since v4.1 for `address`, `bool`, `bytes32`, `uint256`._
* _Available since v4.9 for `string`, `bytes`._
*/
library StorageSlot {
struct AddressSlot {
address value;
}
struct BooleanSlot {
bool value;
}
struct Bytes32Slot {
bytes32 value;
}
struct Uint256Slot {
uint256 value;
}
struct StringSlot {
string value;
}
struct BytesSlot {
bytes value;
}
/**
* @dev Returns an `AddressSlot` with member `value` located at `slot`.
*/
function getAddressSlot(bytes32 slot) internal pure returns (AddressSlot storage r) {
/// @solidity memory-safe-assembly
assembly {
r.slot := slot
}
}
/**
* @dev Returns an `BooleanSlot` with member `value` located at `slot`.
*/
function getBooleanSlot(bytes32 slot) internal pure returns (BooleanSlot storage r) {
/// @solidity memory-safe-assembly
assembly {
r.slot := slot
}
}
/**
* @dev Returns an `Bytes32Slot` with member `value` located at `slot`.
*/
function getBytes32Slot(bytes32 slot) internal pure returns (Bytes32Slot storage r) {
/// @solidity memory-safe-assembly
assembly {
r.slot := slot
}
}
/**
* @dev Returns an `Uint256Slot` with member `value` located at `slot`.
*/
function getUint256Slot(bytes32 slot) internal pure returns (Uint256Slot storage r) {
/// @solidity memory-safe-assembly
assembly {
r.slot := slot
}
}
/**
* @dev Returns an `StringSlot` with member `value` located at `slot`.
*/
function getStringSlot(bytes32 slot) internal pure returns (StringSlot storage r) {
/// @solidity memory-safe-assembly
assembly {
r.slot := slot
}
}
/**
* @dev Returns an `StringSlot` representation of the string storage pointer `store`.
*/
function getStringSlot(string storage store) internal pure returns (StringSlot storage r) {
/// @solidity memory-safe-assembly
assembly {
r.slot := store.slot
}
}
/**
* @dev Returns an `BytesSlot` with member `value` located at `slot`.
*/
function getBytesSlot(bytes32 slot) internal pure returns (BytesSlot storage r) {
/// @solidity memory-safe-assembly
assembly {
r.slot := slot
}
}
/**
* @dev Returns an `BytesSlot` representation of the bytes storage pointer `store`.
*/
function getBytesSlot(bytes storage store) internal pure returns (BytesSlot storage r) {
/// @solidity memory-safe-assembly
assembly {
r.slot := store.slot
}
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (utils/Strings.sol)
pragma solidity ^0.8.0;
import "./math/Math.sol";
import "./math/SignedMath.sol";
/**
* @dev String operations.
*/
library Strings {
bytes16 private constant _SYMBOLS = "0123456789abcdef";
uint8 private constant _ADDRESS_LENGTH = 20;
/**
* @dev Converts a `uint256` to its ASCII `string` decimal representation.
*/
function toString(uint256 value) internal pure returns (string memory) {
unchecked {
uint256 length = Math.log10(value) + 1;
string memory buffer = new string(length);
uint256 ptr;
/// @solidity memory-safe-assembly
assembly {
ptr := add(buffer, add(32, length))
}
while (true) {
ptr--;
/// @solidity memory-safe-assembly
assembly {
mstore8(ptr, byte(mod(value, 10), _SYMBOLS))
}
value /= 10;
if (value == 0) break;
}
return buffer;
}
}
/**
* @dev Converts a `int256` to its ASCII `string` decimal representation.
*/
function toString(int256 value) internal pure returns (string memory) {
return string(abi.encodePacked(value < 0 ? "-" : "", toString(SignedMath.abs(value))));
}
/**
* @dev Converts a `uint256` to its ASCII `string` hexadecimal representation.
*/
function toHexString(uint256 value) internal pure returns (string memory) {
unchecked {
return toHexString(value, Math.log256(value) + 1);
}
}
/**
* @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length.
*/
function toHexString(uint256 value, uint256 length) internal pure returns (string memory) {
bytes memory buffer = new bytes(2 * length + 2);
buffer[0] = "0";
buffer[1] = "x";
for (uint256 i = 2 * length + 1; i > 1; --i) {
buffer[i] = _SYMBOLS[value & 0xf];
value >>= 4;
}
require(value == 0, "Strings: hex length insufficient");
return string(buffer);
}
/**
* @dev Converts an `address` with fixed length of 20 bytes to its not checksummed ASCII `string` hexadecimal representation.
*/
function toHexString(address addr) internal pure returns (string memory) {
return toHexString(uint256(uint160(addr)), _ADDRESS_LENGTH);
}
/**
* @dev Returns true if the two strings are equal.
*/
function equal(string memory a, string memory b) internal pure returns (bool) {
return keccak256(bytes(a)) == keccak256(bytes(b));
}
}// SPDX-License-Identifier: GPL-3.0-or-later
// OpenZeppelin Contracts (last updated v4.6.0) (token/ERC20/ERC20.sol)
pragma solidity ^0.8.0;
import "./PendleERC20Upg.sol";
import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import "@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol";
import "@openzeppelin/contracts/utils/Context.sol";
import "@openzeppelin/contracts/token/ERC20/extensions/draft-ERC20Permit.sol";
import "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol";
import "@openzeppelin/contracts-upgradeable/utils/cryptography/draft-EIP712Upgradeable.sol";
import "@openzeppelin/contracts/utils/cryptography/ECDSA.sol";
import "@openzeppelin/contracts/utils/Counters.sol";
/// @dev forked from OZ's ERC20Permit
abstract contract PendleERC20PermitUpg is PendleERC20Upg, IERC20Permit, EIP712Upgradeable {
using Counters for Counters.Counter;
mapping(address => Counters.Counter) private _nonces;
uint256[100] private __gap;
// solhint-disable-next-line var-name-mixedcase
bytes32 private constant _PERMIT_TYPEHASH =
keccak256("Permit(address owner,address spender,uint256 value,uint256 nonce,uint256 deadline)");
function __ERC20PermitUpg_init(string memory name_, string memory symbol_) internal onlyInitializing {
__ERC20Upg_init(name_, symbol_);
__EIP712_init(name_, "1");
}
/**
* @dev See {IERC20Permit-permit}.
*/
function permit(
address owner,
address spender,
uint256 value,
uint256 deadline,
uint8 v,
bytes32 r,
bytes32 s
) public virtual override {
require(block.timestamp <= deadline, "ERC20Permit: expired deadline");
bytes32 structHash = keccak256(abi.encode(_PERMIT_TYPEHASH, owner, spender, value, _useNonce(owner), deadline));
bytes32 hash = _hashTypedDataV4(structHash);
address signer = ECDSA.recover(hash, v, r, s);
require(signer == owner, "ERC20Permit: invalid signature");
_approve(owner, spender, value);
}
/**
* @dev See {IERC20Permit-nonces}.
*/
function nonces(address owner) public view virtual override returns (uint256) {
return _nonces[owner].current();
}
/**
* @dev See {IERC20Permit-DOMAIN_SEPARATOR}.
*/
// solhint-disable-next-line func-name-mixedcase
function DOMAIN_SEPARATOR() external view override returns (bytes32) {
return _domainSeparatorV4();
}
/**
* @dev "Consume a nonce": return the current value and increment.
*
* _Available since v4.1._
*/
function _useNonce(address owner) internal virtual returns (uint256 current) {
Counters.Counter storage nonce = _nonces[owner];
current = nonce.current();
nonce.increment();
}
}// SPDX-License-Identifier: GPL-3.0-or-later
// OpenZeppelin Contracts (last updated v4.6.0) (token/ERC20/ERC20.sol)
pragma solidity ^0.8.0;
import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import "@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol";
import "@openzeppelin/contracts/utils/Context.sol";
import "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol";
/**
* @dev Pendle's ERC20 implementation, modified from @openzeppelin implementation
* Changes are:
* - comes with built-in reentrancy protection, storage-packed with totalSupply variable
* - delete increaseAllowance / decreaseAllowance
* - add nonReentrancy protection to transfer / transferFrom functions
* - allow decimals to be passed in
* - block self-transfer by default
*/
// solhint-disable
abstract contract PendleERC20Upg is Context, Initializable, IERC20, IERC20Metadata {
uint8 private constant _NOT_ENTERED = 1;
uint8 private constant _ENTERED = 2;
mapping(address => uint256) private _balances;
mapping(address => mapping(address => uint256)) private _allowances;
uint248 private _totalSupply;
uint8 private _status;
string private _name;
string private _symbol;
uint8 public immutable decimals;
uint256[100] private __gap;
/**
* @dev Prevents a contract from calling itself, directly or indirectly.
* Calling a `nonReentrant` function from another `nonReentrant`
* function is not supported. It is possible to prevent this from happening
* by making the `nonReentrant` function external, and making it call a
* `private` function that does the actual work.
*/
modifier nonReentrant() {
// On the first call to nonReentrant, _notEntered will be true
require(_status != _ENTERED, "ReentrancyGuard: reentrant call");
// Any calls to nonReentrant after this point will fail
_status = _ENTERED;
_;
// By storing the original value once again, a refund is triggered (see
// https://eips.ethereum.org/EIPS/eip-2200)
_status = _NOT_ENTERED;
}
/**
* @dev Sets the values for {name}, {symbol} and {decimals}.
*
* All three of these values are immutable: they can only be set once during
* construction.
*/
constructor(uint8 decimals_) {
decimals = decimals_;
}
/**
* @dev Sets the values for {name} and {symbol}.
*
* The default value of {decimals} is 18. To select a different value for
* {decimals} you should overload it.
*
* All two of these values are immutable: they can only be set once during
* construction.
*/
function __ERC20Upg_init(string memory name_, string memory symbol_) internal onlyInitializing {
_name = name_;
_symbol = symbol_;
_status = _NOT_ENTERED;
}
/**
* @dev Returns the name of the token.
*/
function name() public view virtual override returns (string memory) {
return _name;
}
/**
* @dev Returns the symbol of the token, usually a shorter version of the
* name.
*/
function symbol() public view virtual override returns (string memory) {
return _symbol;
}
/**
* @dev See {IERC20-totalSupply}.
*/
function totalSupply() public view virtual override returns (uint256) {
return _totalSupply;
}
/**
* @dev See {IERC20-balanceOf}.
*/
function balanceOf(address account) public view virtual override returns (uint256) {
return _balances[account];
}
/**
* @dev See {IERC20-transfer}.
*
* Requirements:
*
* - `to` cannot be the zero address.
* - the caller must have a balance of at least `amount`.
*/
function transfer(address to, uint256 amount) external virtual override nonReentrant returns (bool) {
address owner = _msgSender();
_transfer(owner, to, amount);
return true;
}
/**
* @dev See {IERC20-allowance}.
*/
function allowance(address owner, address spender) public view virtual override returns (uint256) {
return _allowances[owner][spender];
}
/**
* @dev See {IERC20-approve}.
*
* NOTE: If `amount` is the maximum `uint256`, the allowance is not updated on
* `transferFrom`. This is semantically equivalent to an infinite approval.
*
* Requirements:
*
* - `spender` cannot be the zero address.
*/
function approve(address spender, uint256 amount) external virtual override returns (bool) {
address owner = _msgSender();
_approve(owner, spender, amount);
return true;
}
/**
* @dev See {IERC20-transferFrom}.
*
* Emits an {Approval} event indicating the updated allowance. This is not
* required by the EIP. See the note at the beginning of {ERC20}.
*
* NOTE: Does not update the allowance if the current allowance
* is the maximum `uint256`.
*
* Requirements:
*
* - `from` and `to` cannot be the zero address.
* - `from` must have a balance of at least `amount`.
* - the caller must have allowance for ``from``'s tokens of at least
* `amount`.
*/
function transferFrom(
address from,
address to,
uint256 amount
) external virtual override nonReentrant returns (bool) {
address spender = _msgSender();
_spendAllowance(from, spender, amount);
_transfer(from, to, amount);
return true;
}
/**
* @dev Moves `amount` of tokens from `sender` to `recipient`.
*
* This internal function is equivalent to {transfer}, and can be used to
* e.g. implement automatic token fees, slashing mechanisms, etc.
*
* Emits a {Transfer} event.
*
* Requirements:
*
* - `from` cannot be the zero address.
* - `to` cannot be the zero address.
* - `from` must have a balance of at least `amount`.
*/
function _transfer(address from, address to, uint256 amount) internal virtual {
require(from != address(0), "ERC20: transfer from the zero address");
require(to != address(0), "ERC20: transfer to the zero address");
require(from != to, "ERC20: transfer to self");
_beforeTokenTransfer(from, to, amount);
uint256 fromBalance = _balances[from];
require(fromBalance >= amount, "ERC20: transfer amount exceeds balance");
unchecked {
_balances[from] = fromBalance - amount;
}
_balances[to] += amount;
emit Transfer(from, to, amount);
_afterTokenTransfer(from, to, amount);
}
/** @dev Creates `amount` tokens and assigns them to `account`, increasing
* the total supply.
*
* Emits a {Transfer} event with `from` set to the zero address.
*
* Requirements:
*
* - `account` cannot be the zero address.
*/
function _mint(address account, uint256 amount) internal virtual {
require(account != address(0), "ERC20: mint to the zero address");
_beforeTokenTransfer(address(0), account, amount);
_totalSupply += toUint248(amount);
_balances[account] += amount;
emit Transfer(address(0), account, amount);
_afterTokenTransfer(address(0), account, amount);
}
/**
* @dev Destroys `amount` tokens from `account`, reducing the
* total supply.
*
* Emits a {Transfer} event with `to` set to the zero address.
*
* Requirements:
*
* - `account` cannot be the zero address.
* - `account` must have at least `amount` tokens.
*/
function _burn(address account, uint256 amount) internal virtual {
require(account != address(0), "ERC20: burn from the zero address");
_beforeTokenTransfer(account, address(0), amount);
uint256 accountBalance = _balances[account];
require(accountBalance >= amount, "ERC20: burn amount exceeds balance");
unchecked {
_balances[account] = accountBalance - amount;
}
_totalSupply -= toUint248(amount);
emit Transfer(account, address(0), amount);
_afterTokenTransfer(account, address(0), amount);
}
/**
* @dev Sets `amount` as the allowance of `spender` over the `owner` s tokens.
*
* This internal function is equivalent to `approve`, and can be used to
* e.g. set automatic allowances for certain subsystems, etc.
*
* Emits an {Approval} event.
*
* Requirements:
*
* - `owner` cannot be the zero address.
* - `spender` cannot be the zero address.
*/
function _approve(address owner, address spender, uint256 amount) internal virtual {
require(owner != address(0), "ERC20: approve from the zero address");
require(spender != address(0), "ERC20: approve to the zero address");
_allowances[owner][spender] = amount;
emit Approval(owner, spender, amount);
}
/**
* @dev Updates `owner` s allowance for `spender` based on spent `amount`.
*
* Does not update the allowance amount in case of infinite allowance.
* Revert if not enough allowance is available.
*
* Might emit an {Approval} event.
*/
function _spendAllowance(address owner, address spender, uint256 amount) internal virtual {
uint256 currentAllowance = allowance(owner, spender);
if (currentAllowance != type(uint256).max) {
require(currentAllowance >= amount, "ERC20: insufficient allowance");
unchecked {
_approve(owner, spender, currentAllowance - amount);
}
}
}
/**
* @dev Hook that is called before any transfer of tokens. This includes
* minting and burning.
*
* Calling conditions:
*
* - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens
* will be transferred to `to`.
* - when `from` is zero, `amount` tokens will be minted for `to`.
* - when `to` is zero, `amount` of ``from``'s tokens will be burned.
* - `from` and `to` are never both zero.
*
* To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].
*/
function _beforeTokenTransfer(address from, address to, uint256 amount) internal virtual {}
/**
* @dev Hook that is called after any transfer of tokens. This includes
* minting and burning.
*
* Calling conditions:
*
* - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens
* has been transferred to `to`.
* - when `from` is zero, `amount` tokens have been minted for `to`.
* - when `to` is zero, `amount` of ``from``'s tokens have been burned.
* - `from` and `to` are never both zero.
*
* To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].
*/
function _afterTokenTransfer(address from, address to, uint256 amount) internal virtual {}
function toUint248(uint256 x) internal virtual returns (uint248) {
require(x <= type(uint248).max); // signed, lim = bit-1
return uint248(x);
}
}// SPDX-License-Identifier: GPL-3.0-or-later
pragma solidity ^0.8.0;
library ArrayLib {
function sum(uint256[] memory input) internal pure returns (uint256) {
uint256 value = 0;
for (uint256 i = 0; i < input.length; ) {
value += input[i];
unchecked {
i++;
}
}
return value;
}
/// @notice return index of the element if found, else return uint256.max
function find(address[] memory array, address element) internal pure returns (uint256 index) {
uint256 length = array.length;
for (uint256 i = 0; i < length; ) {
if (array[i] == element) return i;
unchecked {
i++;
}
}
return type(uint256).max;
}
function append(address[] memory inp, address element) internal pure returns (address[] memory out) {
uint256 length = inp.length;
out = new address[](length + 1);
for (uint256 i = 0; i < length; ) {
out[i] = inp[i];
unchecked {
i++;
}
}
out[length] = element;
}
function append(
address[] memory inp,
address element0,
address element1
) internal pure returns (address[] memory out) {
uint256 length = inp.length;
out = new address[](length + 2);
for (uint256 i = 0; i < length; ) {
out[i] = inp[i];
unchecked {
i++;
}
}
out[length] = element0;
out[length + 1] = element1;
}
function appendHead(address[] memory inp, address element) internal pure returns (address[] memory out) {
uint256 length = inp.length;
out = new address[](length + 1);
out[0] = element;
for (uint256 i = 1; i <= length; ) {
out[i] = inp[i - 1];
unchecked {
i++;
}
}
}
/**
* @dev This function assumes a and b each contains unidentical elements
* @param a array of addresses a
* @param b array of addresses b
* @return out Concatenation of a and b containing unidentical elements
*/
function merge(address[] memory a, address[] memory b) internal pure returns (address[] memory out) {
unchecked {
uint256 countUnidenticalB = 0;
bool[] memory isUnidentical = new bool[](b.length);
for (uint256 i = 0; i < b.length; ++i) {
if (!contains(a, b[i])) {
countUnidenticalB++;
isUnidentical[i] = true;
}
}
out = new address[](a.length + countUnidenticalB);
for (uint256 i = 0; i < a.length; ++i) {
out[i] = a[i];
}
uint256 id = a.length;
for (uint256 i = 0; i < b.length; ++i) {
if (isUnidentical[i]) {
out[id++] = b[i];
}
}
}
}
// various version of contains
function contains(address[] memory array, address element) internal pure returns (bool) {
uint256 length = array.length;
for (uint256 i = 0; i < length; ) {
if (array[i] == element) return true;
unchecked {
i++;
}
}
return false;
}
function contains(bytes4[] memory array, bytes4 element) internal pure returns (bool) {
uint256 length = array.length;
for (uint256 i = 0; i < length; ) {
if (array[i] == element) return true;
unchecked {
i++;
}
}
return false;
}
function create(address a) internal pure returns (address[] memory res) {
res = new address[](1);
res[0] = a;
}
function create(address a, address b) internal pure returns (address[] memory res) {
res = new address[](2);
res[0] = a;
res[1] = b;
}
function create(address a, address b, address c) internal pure returns (address[] memory res) {
res = new address[](3);
res[0] = a;
res[1] = b;
res[2] = c;
}
function create(address a, address b, address c, address d) internal pure returns (address[] memory res) {
res = new address[](4);
res[0] = a;
res[1] = b;
res[2] = c;
res[3] = d;
}
function create(
address a,
address b,
address c,
address d,
address e
) internal pure returns (address[] memory res) {
res = new address[](5);
res[0] = a;
res[1] = b;
res[2] = c;
res[3] = d;
res[4] = e;
}
function create(uint256 a) internal pure returns (uint256[] memory res) {
res = new uint256[](1);
res[0] = a;
}
function create(uint256 a, uint256 b) internal pure returns (uint256[] memory res) {
res = new uint256[](2);
res[0] = a;
res[1] = b;
}
}// SPDX-License-Identifier: GPL-3.0-or-later
pragma solidity ^0.8.0;
import "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol";
contract BoringOwnableUpgradeableData {
address public owner;
address public pendingOwner;
}
abstract contract BoringOwnableUpgradeable__deprecated is BoringOwnableUpgradeableData, Initializable {
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
function __BoringOwnable__deprecated_init() internal onlyInitializing {
owner = msg.sender;
}
/// @notice Transfers ownership to `newOwner`. Either directly or claimable by the new pending owner.
/// Can only be invoked by the current `owner`.
/// @param newOwner Address of the new owner.
/// @param direct True if `newOwner` should be set immediately. False if `newOwner` needs to use `claimOwnership`.
/// @param renounce Allows the `newOwner` to be `address(0)` if `direct` and `renounce` is True. Has no effect otherwise.
function transferOwnership(address newOwner, bool direct, bool renounce) public onlyOwner {
if (direct) {
// Checks
require(newOwner != address(0) || renounce, "Ownable: zero address");
// Effects
emit OwnershipTransferred(owner, newOwner);
owner = newOwner;
pendingOwner = address(0);
} else {
// Effects
pendingOwner = newOwner;
}
}
/// @notice Needs to be called by `pendingOwner` to claim ownership.
function claimOwnership() public {
address _pendingOwner = pendingOwner;
// Checks
require(msg.sender == _pendingOwner, "Ownable: caller != pending owner");
// Effects
emit OwnershipTransferred(owner, _pendingOwner);
owner = _pendingOwner;
pendingOwner = address(0);
}
/// @notice Only allows the `owner` to execute the function.
modifier onlyOwner() {
require(msg.sender == owner, "Ownable: caller is not the owner");
_;
}
uint256[48] private __gap;
}// SPDX-License-Identifier: GPL-3.0-or-later
pragma solidity ^0.8.0;
library Errors {
// BulkSeller
error BulkInsufficientSyForTrade(uint256 currentAmount, uint256 requiredAmount);
error BulkInsufficientTokenForTrade(uint256 currentAmount, uint256 requiredAmount);
error BulkInSufficientSyOut(uint256 actualSyOut, uint256 requiredSyOut);
error BulkInSufficientTokenOut(uint256 actualTokenOut, uint256 requiredTokenOut);
error BulkInsufficientSyReceived(uint256 actualBalance, uint256 requiredBalance);
error BulkNotMaintainer();
error BulkNotAdmin();
error BulkSellerAlreadyExisted(address token, address SY, address bulk);
error BulkSellerInvalidToken(address token, address SY);
error BulkBadRateTokenToSy(uint256 actualRate, uint256 currentRate, uint256 eps);
error BulkBadRateSyToToken(uint256 actualRate, uint256 currentRate, uint256 eps);
// APPROX
error ApproxFail();
error ApproxParamsInvalid(uint256 guessMin, uint256 guessMax, uint256 eps);
error ApproxBinarySearchInputInvalid(
uint256 approxGuessMin,
uint256 approxGuessMax,
uint256 minGuessMin,
uint256 maxGuessMax
);
// MARKET + MARKET MATH CORE
error MarketExpired();
error MarketZeroAmountsInput();
error MarketZeroAmountsOutput();
error MarketZeroLnImpliedRate();
error MarketInsufficientPtForTrade(int256 currentAmount, int256 requiredAmount);
error MarketInsufficientPtReceived(uint256 actualBalance, uint256 requiredBalance);
error MarketInsufficientSyReceived(uint256 actualBalance, uint256 requiredBalance);
error MarketZeroTotalPtOrTotalAsset(int256 totalPt, int256 totalAsset);
error MarketExchangeRateBelowOne(int256 exchangeRate);
error MarketProportionMustNotEqualOne();
error MarketRateScalarBelowZero(int256 rateScalar);
error MarketScalarRootBelowZero(int256 scalarRoot);
error MarketProportionTooHigh(int256 proportion, int256 maxProportion);
error OracleUninitialized();
error OracleTargetTooOld(uint32 target, uint32 oldest);
error OracleZeroCardinality();
error MarketFactoryExpiredPt();
error MarketFactoryInvalidPt();
error MarketFactoryMarketExists();
error MarketFactoryLnFeeRateRootTooHigh(uint80 lnFeeRateRoot, uint256 maxLnFeeRateRoot);
error MarketFactoryOverriddenFeeTooHigh(uint80 overriddenFee, uint256 marketLnFeeRateRoot);
error MarketFactoryReserveFeePercentTooHigh(uint8 reserveFeePercent, uint8 maxReserveFeePercent);
error MarketFactoryZeroTreasury();
error MarketFactoryInitialAnchorTooLow(int256 initialAnchor, int256 minInitialAnchor);
error MFNotPendleMarket(address addr);
// ROUTER
error RouterInsufficientLpOut(uint256 actualLpOut, uint256 requiredLpOut);
error RouterInsufficientSyOut(uint256 actualSyOut, uint256 requiredSyOut);
error RouterInsufficientPtOut(uint256 actualPtOut, uint256 requiredPtOut);
error RouterInsufficientYtOut(uint256 actualYtOut, uint256 requiredYtOut);
error RouterInsufficientPYOut(uint256 actualPYOut, uint256 requiredPYOut);
error RouterInsufficientTokenOut(uint256 actualTokenOut, uint256 requiredTokenOut);
error RouterInsufficientSyRepay(uint256 actualSyRepay, uint256 requiredSyRepay);
error RouterInsufficientPtRepay(uint256 actualPtRepay, uint256 requiredPtRepay);
error RouterNotAllSyUsed(uint256 netSyDesired, uint256 netSyUsed);
error RouterTimeRangeZero();
error RouterCallbackNotPendleMarket(address caller);
error RouterInvalidAction(bytes4 selector);
error RouterInvalidFacet(address facet);
error RouterKyberSwapDataZero();
error SimulationResults(bool success, bytes res);
// YIELD CONTRACT
error YCExpired();
error YCNotExpired();
error YieldContractInsufficientSy(uint256 actualSy, uint256 requiredSy);
error YCNothingToRedeem();
error YCPostExpiryDataNotSet();
error YCNoFloatingSy();
// YieldFactory
error YCFactoryInvalidExpiry();
error YCFactoryYieldContractExisted();
error YCFactoryZeroExpiryDivisor();
error YCFactoryZeroTreasury();
error YCFactoryInterestFeeRateTooHigh(uint256 interestFeeRate, uint256 maxInterestFeeRate);
error YCFactoryRewardFeeRateTooHigh(uint256 newRewardFeeRate, uint256 maxRewardFeeRate);
// SY
error SYInvalidTokenIn(address token);
error SYInvalidTokenOut(address token);
error SYZeroDeposit();
error SYZeroRedeem();
error SYInsufficientSharesOut(uint256 actualSharesOut, uint256 requiredSharesOut);
error SYInsufficientTokenOut(uint256 actualTokenOut, uint256 requiredTokenOut);
// SY-specific
error SYQiTokenMintFailed(uint256 errCode);
error SYQiTokenRedeemFailed(uint256 errCode);
error SYQiTokenRedeemRewardsFailed(uint256 rewardAccruedType0, uint256 rewardAccruedType1);
error SYQiTokenBorrowRateTooHigh(uint256 borrowRate, uint256 borrowRateMax);
error SYCurveInvalidPid();
error SYCurve3crvPoolNotFound();
error SYApeDepositAmountTooSmall(uint256 amountDeposited);
error SYBalancerInvalidPid();
error SYInvalidRewardToken(address token);
error SYStargateRedeemCapExceeded(uint256 amountLpDesired, uint256 amountLpRedeemable);
error SYBalancerReentrancy();
error NotFromTrustedRemote(uint16 srcChainId, bytes path);
error ApxETHNotEnoughBuffer();
// Liquidity Mining
error VCInactivePool(address pool);
error VCPoolAlreadyActive(address pool);
error VCZeroVePendle(address user);
error VCExceededMaxWeight(uint256 totalWeight, uint256 maxWeight);
error VCEpochNotFinalized(uint256 wTime);
error VCPoolAlreadyAddAndRemoved(address pool);
error VEInvalidNewExpiry(uint256 newExpiry);
error VEExceededMaxLockTime();
error VEInsufficientLockTime();
error VENotAllowedReduceExpiry();
error VEZeroAmountLocked();
error VEPositionNotExpired();
error VEZeroPosition();
error VEZeroSlope(uint128 bias, uint128 slope);
error VEReceiveOldSupply(uint256 msgTime);
error GCNotPendleMarket(address caller);
error GCNotVotingController(address caller);
error InvalidWTime(uint256 wTime);
error ExpiryInThePast(uint256 expiry);
error ChainNotSupported(uint256 chainId);
error FDTotalAmountFundedNotMatch(uint256 actualTotalAmount, uint256 expectedTotalAmount);
error FDEpochLengthMismatch();
error FDInvalidPool(address pool);
error FDPoolAlreadyExists(address pool);
error FDInvalidNewFinishedEpoch(uint256 oldFinishedEpoch, uint256 newFinishedEpoch);
error FDInvalidStartEpoch(uint256 startEpoch);
error FDInvalidWTimeFund(uint256 lastFunded, uint256 wTime);
error FDFutureFunding(uint256 lastFunded, uint256 currentWTime);
error BDInvalidEpoch(uint256 epoch, uint256 startTime);
// Cross-Chain
error MsgNotFromSendEndpoint(uint16 srcChainId, bytes path);
error MsgNotFromReceiveEndpoint(address sender);
error InsufficientFeeToSendMsg(uint256 currentFee, uint256 requiredFee);
error ApproxDstExecutionGasNotSet();
error InvalidRetryData();
// GENERIC MSG
error ArrayLengthMismatch();
error ArrayEmpty();
error ArrayOutOfBounds();
error ZeroAddress();
error FailedToSendEther();
error InvalidMerkleProof();
error OnlyLayerZeroEndpoint();
error OnlyYT();
error OnlyYCFactory();
error OnlyWhitelisted();
// Swap Aggregator
error SAInsufficientTokenIn(address tokenIn, uint256 amountExpected, uint256 amountActual);
error UnsupportedSelector(uint256 aggregatorType, bytes4 selector);
}// SPDX-License-Identifier: GPL-3.0-or-later
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
pragma solidity ^0.8.0;
/* solhint-disable private-vars-leading-underscore, reason-string */
library PMath {
uint256 internal constant ONE = 1e18; // 18 decimal places
int256 internal constant IONE = 1e18; // 18 decimal places
function subMax0(uint256 a, uint256 b) internal pure returns (uint256) {
unchecked {
return (a >= b ? a - b : 0);
}
}
function subNoNeg(int256 a, int256 b) internal pure returns (int256) {
require(a >= b, "negative");
return a - b; // no unchecked since if b is very negative, a - b might overflow
}
function mulDown(uint256 a, uint256 b) internal pure returns (uint256) {
uint256 product = a * b;
unchecked {
return product / ONE;
}
}
function mulDown(int256 a, int256 b) internal pure returns (int256) {
int256 product = a * b;
unchecked {
return product / IONE;
}
}
function divDown(uint256 a, uint256 b) internal pure returns (uint256) {
uint256 aInflated = a * ONE;
unchecked {
return aInflated / b;
}
}
function divDown(int256 a, int256 b) internal pure returns (int256) {
int256 aInflated = a * IONE;
unchecked {
return aInflated / b;
}
}
function rawDivUp(uint256 a, uint256 b) internal pure returns (uint256) {
return (a + b - 1) / b;
}
function rawDivUp(int256 a, int256 b) internal pure returns (int256) {
return (a + b - 1) / b;
}
function tweakUp(uint256 a, uint256 factor) internal pure returns (uint256) {
return mulDown(a, ONE + factor);
}
function tweakDown(uint256 a, uint256 factor) internal pure returns (uint256) {
return mulDown(a, ONE - factor);
}
/// @return res = min(a + b, bound)
/// @dev This function should handle arithmetic operation and bound check without overflow/underflow
function addWithUpperBound(uint256 a, uint256 b, uint256 bound) internal pure returns (uint256 res) {
unchecked {
if (type(uint256).max - b < a) res = bound;
else res = min(bound, a + b);
}
}
/// @return res = max(a - b, bound)
/// @dev This function should handle arithmetic operation and bound check without overflow/underflow
function subWithLowerBound(uint256 a, uint256 b, uint256 bound) internal pure returns (uint256 res) {
unchecked {
if (b > a) res = bound;
else res = max(a - b, bound);
}
}
function clamp(uint256 x, uint256 lower, uint256 upper) internal pure returns (uint256 res) {
res = x;
if (x < lower) res = lower;
else if (x > upper) res = upper;
}
// @author Uniswap
function sqrt(uint256 y) internal pure returns (uint256 z) {
if (y > 3) {
z = y;
uint256 x = y / 2 + 1;
while (x < z) {
z = x;
x = (y / x + x) / 2;
}
} else if (y != 0) {
z = 1;
}
}
function square(uint256 x) internal pure returns (uint256) {
return x * x;
}
function squareDown(uint256 x) internal pure returns (uint256) {
return mulDown(x, x);
}
function abs(int256 x) internal pure returns (uint256) {
return uint256(x > 0 ? x : -x);
}
function neg(int256 x) internal pure returns (int256) {
return x * (-1);
}
function neg(uint256 x) internal pure returns (int256) {
return Int(x) * (-1);
}
function max(uint256 x, uint256 y) internal pure returns (uint256) {
return (x > y ? x : y);
}
function max(int256 x, int256 y) internal pure returns (int256) {
return (x > y ? x : y);
}
function min(uint256 x, uint256 y) internal pure returns (uint256) {
return (x < y ? x : y);
}
function min(int256 x, int256 y) internal pure returns (int256) {
return (x < y ? x : y);
}
/*///////////////////////////////////////////////////////////////
SIGNED CASTS
//////////////////////////////////////////////////////////////*/
function Int(uint256 x) internal pure returns (int256) {
require(x <= uint256(type(int256).max));
return int256(x);
}
function Int128(int256 x) internal pure returns (int128) {
require(type(int128).min <= x && x <= type(int128).max);
return int128(x);
}
function Int128(uint256 x) internal pure returns (int128) {
return Int128(Int(x));
}
/*///////////////////////////////////////////////////////////////
UNSIGNED CASTS
//////////////////////////////////////////////////////////////*/
function Uint(int256 x) internal pure returns (uint256) {
require(x >= 0);
return uint256(x);
}
function Uint32(uint256 x) internal pure returns (uint32) {
require(x <= type(uint32).max);
return uint32(x);
}
function Uint64(uint256 x) internal pure returns (uint64) {
require(x <= type(uint64).max);
return uint64(x);
}
function Uint112(uint256 x) internal pure returns (uint112) {
require(x <= type(uint112).max);
return uint112(x);
}
function Uint96(uint256 x) internal pure returns (uint96) {
require(x <= type(uint96).max);
return uint96(x);
}
function Uint128(uint256 x) internal pure returns (uint128) {
require(x <= type(uint128).max);
return uint128(x);
}
function Uint192(uint256 x) internal pure returns (uint192) {
require(x <= type(uint192).max);
return uint192(x);
}
function isAApproxB(uint256 a, uint256 b, uint256 eps) internal pure returns (bool) {
return mulDown(b, ONE - eps) <= a && a <= mulDown(b, ONE + eps);
}
function isAGreaterApproxB(uint256 a, uint256 b, uint256 eps) internal pure returns (bool) {
return a >= b && a <= mulDown(b, ONE + eps);
}
function isASmallerApproxB(uint256 a, uint256 b, uint256 eps) internal pure returns (bool) {
return a <= b && a >= mulDown(b, ONE - eps);
}
}// SPDX-License-Identifier: GPL-3.0-or-later
pragma solidity ^0.8.0;
import "@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol";
import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
import "../../interfaces/IWETH.sol";
abstract contract TokenHelper {
using SafeERC20 for IERC20;
address internal constant NATIVE = address(0);
uint256 internal constant LOWER_BOUND_APPROVAL = type(uint96).max / 2; // some tokens use 96 bits for approval
function _transferIn(address token, address from, uint256 amount) internal {
if (token == NATIVE) require(msg.value == amount, "eth mismatch");
else if (amount != 0) IERC20(token).safeTransferFrom(from, address(this), amount);
}
function _transferFrom(IERC20 token, address from, address to, uint256 amount) internal {
if (amount != 0) token.safeTransferFrom(from, to, amount);
}
function _transferOut(address token, address to, uint256 amount) internal {
if (amount == 0) return;
if (token == NATIVE) {
(bool success, ) = to.call{value: amount}("");
require(success, "eth send failed");
} else {
IERC20(token).safeTransfer(to, amount);
}
}
function _transferOut(address[] memory tokens, address to, uint256[] memory amounts) internal {
uint256 numTokens = tokens.length;
require(numTokens == amounts.length, "length mismatch");
for (uint256 i = 0; i < numTokens; ) {
_transferOut(tokens[i], to, amounts[i]);
unchecked {
i++;
}
}
}
function _selfBalance(address token) internal view returns (uint256) {
return (token == NATIVE) ? address(this).balance : IERC20(token).balanceOf(address(this));
}
function _selfBalance(IERC20 token) internal view returns (uint256) {
return token.balanceOf(address(this));
}
/// @notice Approves the stipulated contract to spend the given allowance in the given token
/// @dev PLS PAY ATTENTION to tokens that requires the approval to be set to 0 before changing it
function _safeApprove(address token, address to, uint256 value) internal {
(bool success, bytes memory data) = token.call(abi.encodeWithSelector(IERC20.approve.selector, to, value));
require(success && (data.length == 0 || abi.decode(data, (bool))), "Safe Approve");
}
function _safeApproveInf(address token, address to) internal {
if (token == NATIVE) return;
if (IERC20(token).allowance(address(this), to) < LOWER_BOUND_APPROVAL) {
_safeApprove(token, to, 0);
_safeApprove(token, to, type(uint256).max);
}
}
function _wrap_unwrap_ETH(address tokenIn, address tokenOut, uint256 netTokenIn) internal {
if (tokenIn == NATIVE) IWETH(tokenOut).deposit{value: netTokenIn}();
else IWETH(tokenIn).withdraw(netTokenIn);
}
}// SPDX-License-Identifier: GPL-3.0-or-later
pragma solidity ^0.8.0;
import "./RewardManagerAbstract.sol";
/// NOTE: This RewardManager is used with SY & YTv2 & PendleMarket. For YTv1, it will use RewardManagerAbstract
/// NOTE: RewardManager must not have duplicated rewardTokens
abstract contract RewardManager is RewardManagerAbstract {
using PMath for uint256;
using ArrayLib for uint256[];
uint256 public lastRewardBlock;
mapping(address => RewardState) public rewardState;
function _updateRewardIndex()
internal
virtual
override
returns (address[] memory tokens, uint256[] memory indexes)
{
tokens = _getRewardTokens();
indexes = new uint256[](tokens.length);
if (tokens.length == 0) return (tokens, indexes);
if (lastRewardBlock != block.number) {
// if we have not yet update the index for this block
lastRewardBlock = block.number;
uint256 totalShares = _rewardSharesTotal();
_redeemExternalReward();
for (uint256 i = 0; i < tokens.length; ++i) {
address token = tokens[i];
// the entire token balance of the contract must be the rewards of the contract
RewardState memory _state = rewardState[token];
(uint256 lastBalance, uint256 index) = (_state.lastBalance, _state.index);
uint256 accrued = _selfBalance(tokens[i]) - lastBalance;
if (index == 0) index = INITIAL_REWARD_INDEX;
if (totalShares != 0) index += accrued.divDown(totalShares);
rewardState[token] = RewardState({
index: index.Uint128(),
lastBalance: (lastBalance + accrued).Uint128()
});
indexes[i] = index;
}
} else {
for (uint256 i = 0; i < tokens.length; i++) {
indexes[i] = rewardState[tokens[i]].index;
}
}
}
/// @dev this function doesn't need redeemExternal since redeemExternal is bundled in updateRewardIndex
/// @dev this function also has to update rewardState.lastBalance
function _doTransferOutRewards(
address user,
address receiver
) internal virtual override returns (uint256[] memory rewardAmounts) {
address[] memory tokens = _getRewardTokens();
rewardAmounts = new uint256[](tokens.length);
for (uint256 i = 0; i < tokens.length; i++) {
rewardAmounts[i] = userReward[tokens[i]][user].accrued;
if (rewardAmounts[i] != 0) {
userReward[tokens[i]][user].accrued = 0;
rewardState[tokens[i]].lastBalance -= rewardAmounts[i].Uint128();
_transferOut(tokens[i], receiver, rewardAmounts[i]);
}
}
}
function _getRewardTokens() internal view virtual returns (address[] memory);
function _rewardSharesTotal() internal view virtual returns (uint256);
}// SPDX-License-Identifier: GPL-3.0-or-later
pragma solidity ^0.8.0;
import "../../interfaces/IRewardManager.sol";
import "../libraries/ArrayLib.sol";
import "../libraries/TokenHelper.sol";
import "../libraries/math/PMath.sol";
import "./RewardManagerAbstract.sol";
/// NOTE: RewardManager must not have duplicated rewardTokens
abstract contract RewardManagerAbstract is IRewardManager, TokenHelper {
using PMath for uint256;
uint256 internal constant INITIAL_REWARD_INDEX = 1;
struct RewardState {
uint128 index;
uint128 lastBalance;
}
struct UserReward {
uint128 index;
uint128 accrued;
}
// [token] => [user] => (index,accrued)
mapping(address => mapping(address => UserReward)) public userReward;
function _updateAndDistributeRewards(address user) internal virtual {
_updateAndDistributeRewardsForTwo(user, address(0));
}
function _updateAndDistributeRewardsForTwo(address user1, address user2) internal virtual {
(address[] memory tokens, uint256[] memory indexes) = _updateRewardIndex();
if (tokens.length == 0) return;
if (user1 != address(0) && user1 != address(this)) _distributeRewardsPrivate(user1, tokens, indexes);
if (user2 != address(0) && user2 != address(this)) _distributeRewardsPrivate(user2, tokens, indexes);
}
// should only be callable from `_updateAndDistributeRewardsForTwo` to guarantee user != address(0) && user != address(this)
function _distributeRewardsPrivate(address user, address[] memory tokens, uint256[] memory indexes) private {
assert(user != address(0) && user != address(this));
uint256 userShares = _rewardSharesUser(user);
for (uint256 i = 0; i < tokens.length; ++i) {
address token = tokens[i];
uint256 index = indexes[i];
uint256 userIndex = userReward[token][user].index;
if (userIndex == 0) {
userIndex = INITIAL_REWARD_INDEX.Uint128();
}
if (userIndex == index || index == 0) continue;
uint256 deltaIndex = index - userIndex;
uint256 rewardDelta = userShares.mulDown(deltaIndex);
uint256 rewardAccrued = userReward[token][user].accrued + rewardDelta;
userReward[token][user] = UserReward({index: index.Uint128(), accrued: rewardAccrued.Uint128()});
}
}
function _updateRewardIndex() internal virtual returns (address[] memory tokens, uint256[] memory indexes);
function _redeemExternalReward() internal virtual;
function _doTransferOutRewards(
address user,
address receiver
) internal virtual returns (uint256[] memory rewardAmounts);
function _rewardSharesUser(address user) internal view virtual returns (uint256);
}// SPDX-License-Identifier: BUSL-1.1
pragma solidity ^0.8.0;
import "./WadRayMath.sol";
library AaveAdapterLib {
// Also denote this function as f(share) for a given (constant) index
function calcSharesToAssetDown(uint256 amountShares, uint256 index) internal pure returns (uint256) {
return (amountShares * index) / WadRayMath.RAY;
}
function calcSharesFromAssetDown(uint256 amountAssets, uint256 index) internal pure returns (uint256) {
return (amountAssets * WadRayMath.RAY) / index;
}
function calcSharesFromAssetUp(uint256 amountAssets, uint256 index) internal pure returns (uint256) {
return WadRayMath.rayDiv(amountAssets, index);
}
}// SPDX-License-Identifier: BUSL-1.1
pragma solidity ^0.8.0;
/**
* @title WadRayMath library
* @author Aave
* @notice Provides functions to perform calculations with Wad and Ray units
* @dev Provides mul and div function for wads (decimal numbers with 18 digits of precision) and rays (decimal numbers
* with 27 digits of precision)
* @dev Operations are rounded. If a value is >=.5, will be rounded up, otherwise rounded down.
*/
library WadRayMath {
// HALF_WAD and HALF_RAY expressed with extended notation as constant with operations are not supported in Yul assembly
uint256 internal constant WAD = 1e18;
uint256 internal constant HALF_WAD = 0.5e18;
uint256 internal constant RAY = 1e27;
uint256 internal constant HALF_RAY = 0.5e27;
uint256 internal constant WAD_RAY_RATIO = 1e9;
/**
* @dev Multiplies two wad, rounding half up to the nearest wad
* @dev assembly optimized for improved gas savings, see https://twitter.com/transmissions11/status/1451131036377571328
* @param a Wad
* @param b Wad
* @return c = a*b, in wad
*/
function wadMul(uint256 a, uint256 b) internal pure returns (uint256 c) {
// to avoid overflow, a <= (type(uint256).max - HALF_WAD) / b
assembly {
if iszero(or(iszero(b), iszero(gt(a, div(sub(not(0), HALF_WAD), b))))) {
revert(0, 0)
}
c := div(add(mul(a, b), HALF_WAD), WAD)
}
}
/**
* @dev Divides two wad, rounding half up to the nearest wad
* @dev assembly optimized for improved gas savings, see https://twitter.com/transmissions11/status/1451131036377571328
* @param a Wad
* @param b Wad
* @return c = a/b, in wad
*/
function wadDiv(uint256 a, uint256 b) internal pure returns (uint256 c) {
// to avoid overflow, a <= (type(uint256).max - halfB) / WAD
assembly {
if or(iszero(b), iszero(iszero(gt(a, div(sub(not(0), div(b, 2)), WAD))))) {
revert(0, 0)
}
c := div(add(mul(a, WAD), div(b, 2)), b)
}
}
/**
* @notice Multiplies two ray, rounding half up to the nearest ray
* @dev assembly optimized for improved gas savings, see https://twitter.com/transmissions11/status/1451131036377571328
* @param a Ray
* @param b Ray
* @return c = a raymul b
*/
function rayMul(uint256 a, uint256 b) internal pure returns (uint256 c) {
// to avoid overflow, a <= (type(uint256).max - HALF_RAY) / b
assembly {
if iszero(or(iszero(b), iszero(gt(a, div(sub(not(0), HALF_RAY), b))))) {
revert(0, 0)
}
c := div(add(mul(a, b), HALF_RAY), RAY)
}
}
/**
* @notice Divides two ray, rounding half up to the nearest ray
* @dev assembly optimized for improved gas savings, see https://twitter.com/transmissions11/status/1451131036377571328
* @param a Ray
* @param b Ray
* @return c = a raydiv b
*/
function rayDiv(uint256 a, uint256 b) internal pure returns (uint256 c) {
// to avoid overflow, a <= (type(uint256).max - halfB) / RAY
assembly {
if or(iszero(b), iszero(iszero(gt(a, div(sub(not(0), div(b, 2)), RAY))))) {
revert(0, 0)
}
c := div(add(mul(a, RAY), div(b, 2)), b)
}
}
/**
* @dev Casts ray down to wad
* @dev assembly optimized for improved gas savings, see https://twitter.com/transmissions11/status/1451131036377571328
* @param a Ray
* @return b = a converted to wad, rounded half up to the nearest wad
*/
function rayToWad(uint256 a) internal pure returns (uint256 b) {
assembly {
b := div(a, WAD_RAY_RATIO)
let remainder := mod(a, WAD_RAY_RATIO)
if iszero(lt(remainder, div(WAD_RAY_RATIO, 2))) {
b := add(b, 1)
}
}
}
/**
* @dev Converts wad up to ray
* @dev assembly optimized for improved gas savings, see https://twitter.com/transmissions11/status/1451131036377571328
* @param a Wad
* @return b = a converted in ray
*/
function wadToRay(uint256 a) internal pure returns (uint256 b) {
// to avoid overflow, b/WAD_RAY_RATIO == a
assembly {
b := mul(a, WAD_RAY_RATIO)
if iszero(eq(div(b, WAD_RAY_RATIO), a)) {
revert(0, 0)
}
}
}
}// SPDX-License-Identifier: GPL-3.0-or-later
pragma solidity ^0.8.23;
import "../../../libraries/TokenHelper.sol";
import "../../../../interfaces/Angle/IAngleDistributor.sol";
abstract contract PendleAaveMerit is TokenHelper {
// solhint-disable immutable-vars-naming
address public immutable offchainReceiver;
address public constant ANGLE_DISTRIBUTOR = 0x3Ef3D8bA38EBe18DB133cEc108f4D14CE00Dd9Ae; // same on every chain
constructor(address _offchainReceiver) {
offchainReceiver = _offchainReceiver;
}
function claimOffchainRewards(
address[] calldata users,
address[] calldata tokens,
uint256[] calldata amounts,
bytes32[][] calldata proofs
) external {
require(msg.sender == offchainReceiver, "PendleAaveMerit: unauthorized");
require(users.length == 1 && users[0] == address(this), "PendleAaveMerit: invalid users");
uint256[] memory preBalance = new uint256[](tokens.length);
for (uint256 i = 0; i < tokens.length; ++i) {
preBalance[i] = _selfBalance(tokens[i]);
}
IAngleDistributor(ANGLE_DISTRIBUTOR).claim(users, tokens, amounts, proofs);
for (uint256 i = 0; i < tokens.length; ++i) {
uint256 amountClaimed = _selfBalance(tokens[i]) - preBalance[i];
if (amountClaimed > 0) {
_transferOut(tokens[i], offchainReceiver, amountClaimed);
}
}
}
}// SPDX-License-Identifier: GPL-3.0-or-later
pragma solidity ^0.8.23;
import "../../SYBaseWithRewardsUpg.sol";
import "./libraries/AaveAdapterLib.sol";
import "../../../../interfaces/AaveV3/IAaveV3AToken.sol";
import "../../../../interfaces/AaveV3/IAaveV3Pool.sol";
import "../../../../interfaces/AaveV3/IAaveV3IncentiveController.sol";
// @NOTE: In this contract, we denote the "scaled balance" term as "share"
// [NEW] @NOTE: As for the getRewardTokens function, it will check for different incentive controller
// so this implementation should only be used in L2s. L1 would require more gas optimization
contract PendleAaveV3WithRewardsSYUpg is SYBaseWithRewardsUpg {
using PMath for uint256;
event NewIncentiveController(address incentiveController);
error SameIncentiveController();
// solhint-disable immutable-vars-naming
address public immutable aToken;
address public immutable aavePool;
address public immutable underlying;
address public immutable incentiveController;
address public immutable defaultRewardToken;
uint256[100] private __gap;
constructor(
address _aavePool,
address _aToken,
address _initialIncentiveController,
address _defaultRewardToken
) SYBaseUpg(_aToken) {
aToken = _aToken;
aavePool = _aavePool;
underlying = IAaveV3AToken(aToken).UNDERLYING_ASSET_ADDRESS();
incentiveController = _initialIncentiveController;
defaultRewardToken = _defaultRewardToken;
}
function initialize(string memory _name, string memory _symbol) external initializer {
__SYBaseUpg_init(_name, _symbol);
_safeApproveInf(underlying, aavePool);
}
function _deposit(
address tokenIn,
uint256 amountDeposited
) internal virtual override returns (uint256 amountSharesOut) {
if (tokenIn == underlying) {
IAaveV3Pool(aavePool).supply(underlying, amountDeposited, address(this), 0);
}
amountSharesOut = AaveAdapterLib.calcSharesFromAssetUp(amountDeposited, _getNormalizedIncome());
}
function _redeem(
address receiver,
address tokenOut,
uint256 amountSharesToRedeem
) internal override returns (uint256 amountTokenOut) {
amountTokenOut = AaveAdapterLib.calcSharesToAssetDown(amountSharesToRedeem, _getNormalizedIncome());
if (tokenOut == underlying) {
IAaveV3Pool(aavePool).withdraw(underlying, amountTokenOut, receiver);
} else {
_transferOut(aToken, receiver, amountTokenOut);
}
}
function exchangeRate() public view virtual override returns (uint256) {
return _getNormalizedIncome() / 1e9;
}
function _previewDeposit(
address,
uint256 amountTokenToDeposit
) internal view virtual override returns (uint256 /*amountSharesOut*/) {
return AaveAdapterLib.calcSharesFromAssetUp(amountTokenToDeposit, _getNormalizedIncome());
}
function _previewRedeem(
address,
uint256 amountSharesToRedeem
) internal view virtual override returns (uint256 /*amountTokenOut*/) {
return AaveAdapterLib.calcSharesToAssetDown(amountSharesToRedeem, _getNormalizedIncome());
}
function _getNormalizedIncome() internal view returns (uint256) {
return IAaveV3Pool(aavePool).getReserveNormalizedIncome(underlying);
}
function getTokensIn() public view virtual override returns (address[] memory res) {
return ArrayLib.create(underlying, aToken);
}
function getTokensOut() public view virtual override returns (address[] memory res) {
return ArrayLib.create(underlying, aToken);
}
function isValidTokenIn(address token) public view virtual override returns (bool) {
return token == aToken || token == underlying;
}
function isValidTokenOut(address token) public view virtual override returns (bool) {
return token == aToken || token == underlying;
}
function assetInfo()
external
view
virtual
returns (AssetType assetType, address assetAddress, uint8 assetDecimals)
{
return (AssetType.TOKEN, underlying, IERC20Metadata(underlying).decimals());
}
/*///////////////////////////////////////////////////////////////
REWARDS-RELATED
//////////////////////////////////////////////////////////////*/
/**
* @dev See {IStandardizedYield-getRewardTokens}
*/
function _getRewardTokens() internal view override returns (address[] memory res) {
return ArrayLib.create(defaultRewardToken);
}
function _redeemExternalReward() internal virtual override {
if (incentiveController != address(0)) {
IAaveV3IncentiveController(incentiveController).claimAllRewardsToSelf(ArrayLib.create(aToken));
}
}
}// SPDX-License-Identifier: GPL-3.0-or-later
pragma solidity ^0.8.17;
import "../../interfaces/IStandardizedYield.sol";
import "../erc20/PendleERC20PermitUpg.sol";
import "../libraries/math/PMath.sol";
import "../libraries/ArrayLib.sol";
import "../libraries/TokenHelper.sol";
import "../libraries/Errors.sol";
import "../libraries/BoringOwnableUpgradeable__deprecated.sol";
import "@openzeppelin/contracts/security/Pausable.sol";
abstract contract SYBaseUpg is
IStandardizedYield,
PendleERC20PermitUpg,
TokenHelper,
BoringOwnableUpgradeable__deprecated,
Pausable
{
using PMath for uint256;
address public immutable yieldToken;
uint256[100] private __gap;
constructor(address _yieldToken) PendleERC20Upg(IERC20Metadata(_yieldToken).decimals()) {
yieldToken = _yieldToken;
_disableInitializers();
}
function __SYBaseUpg_init(string memory name_, string memory symbol_) internal onlyInitializing {
__ERC20PermitUpg_init(name_, symbol_);
__BoringOwnable__deprecated_init();
}
// solhint-disable no-empty-blocks
receive() external payable {}
/*///////////////////////////////////////////////////////////////
DEPOSIT/REDEEM USING BASE TOKENS
//////////////////////////////////////////////////////////////*/
/**
* @dev See {IStandardizedYield-deposit}
*/
function deposit(
address receiver,
address tokenIn,
uint256 amountTokenToDeposit,
uint256 minSharesOut
) external payable nonReentrant returns (uint256 amountSharesOut) {
if (!isValidTokenIn(tokenIn)) revert Errors.SYInvalidTokenIn(tokenIn);
if (amountTokenToDeposit == 0) revert Errors.SYZeroDeposit();
_transferIn(tokenIn, msg.sender, amountTokenToDeposit);
amountSharesOut = _deposit(tokenIn, amountTokenToDeposit);
if (amountSharesOut < minSharesOut) revert Errors.SYInsufficientSharesOut(amountSharesOut, minSharesOut);
_mint(receiver, amountSharesOut);
emit Deposit(msg.sender, receiver, tokenIn, amountTokenToDeposit, amountSharesOut);
}
/**
* @dev See {IStandardizedYield-redeem}
*/
function redeem(
address receiver,
uint256 amountSharesToRedeem,
address tokenOut,
uint256 minTokenOut,
bool burnFromInternalBalance
) external nonReentrant returns (uint256 amountTokenOut) {
if (!isValidTokenOut(tokenOut)) revert Errors.SYInvalidTokenOut(tokenOut);
if (amountSharesToRedeem == 0) revert Errors.SYZeroRedeem();
if (burnFromInternalBalance) {
_burn(address(this), amountSharesToRedeem);
} else {
_burn(msg.sender, amountSharesToRedeem);
}
amountTokenOut = _redeem(receiver, tokenOut, amountSharesToRedeem);
if (amountTokenOut < minTokenOut) revert Errors.SYInsufficientTokenOut(amountTokenOut, minTokenOut);
emit Redeem(msg.sender, receiver, tokenOut, amountSharesToRedeem, amountTokenOut);
}
/**
* @notice mint shares based on the deposited base tokens
* @param tokenIn base token address used to mint shares
* @param amountDeposited amount of base tokens deposited
* @return amountSharesOut amount of shares minted
*/
function _deposit(address tokenIn, uint256 amountDeposited) internal virtual returns (uint256 amountSharesOut);
/**
* @notice redeems base tokens based on amount of shares to be burned
* @param tokenOut address of the base token to be redeemed
* @param amountSharesToRedeem amount of shares to be burned
* @return amountTokenOut amount of base tokens redeemed
*/
function _redeem(
address receiver,
address tokenOut,
uint256 amountSharesToRedeem
) internal virtual returns (uint256 amountTokenOut);
/*///////////////////////////////////////////////////////////////
EXCHANGE-RATE
//////////////////////////////////////////////////////////////*/
/**
* @dev See {IStandardizedYield-exchangeRate}
*/
function exchangeRate() external view virtual override returns (uint256 res);
/*///////////////////////////////////////////////////////////////
REWARDS-RELATED
//////////////////////////////////////////////////////////////*/
/**
* @dev See {IStandardizedYield-claimRewards}
*/
function claimRewards(address /*user*/) external virtual override returns (uint256[] memory rewardAmounts) {
rewardAmounts = new uint256[](0);
}
/**
* @dev See {IStandardizedYield-getRewardTokens}
*/
function getRewardTokens() external view virtual override returns (address[] memory rewardTokens) {
rewardTokens = new address[](0);
}
/**
* @dev See {IStandardizedYield-accruedRewards}
*/
function accruedRewards(address /*user*/) external view virtual override returns (uint256[] memory rewardAmounts) {
rewardAmounts = new uint256[](0);
}
function rewardIndexesCurrent() external virtual override returns (uint256[] memory indexes) {
indexes = new uint256[](0);
}
function rewardIndexesStored() external view virtual override returns (uint256[] memory indexes) {
indexes = new uint256[](0);
}
/*///////////////////////////////////////////////////////////////
MISC METADATA FUNCTIONS
//////////////////////////////////////////////////////////////*/
function previewDeposit(
address tokenIn,
uint256 amountTokenToDeposit
) external view virtual returns (uint256 amountSharesOut) {
if (!isValidTokenIn(tokenIn)) revert Errors.SYInvalidTokenIn(tokenIn);
return _previewDeposit(tokenIn, amountTokenToDeposit);
}
function previewRedeem(
address tokenOut,
uint256 amountSharesToRedeem
) external view virtual returns (uint256 amountTokenOut) {
if (!isValidTokenOut(tokenOut)) revert Errors.SYInvalidTokenOut(tokenOut);
return _previewRedeem(tokenOut, amountSharesToRedeem);
}
function pause() external onlyOwner {
_pause();
}
function unpause() external onlyOwner {
_unpause();
}
function _beforeTokenTransfer(address, address, uint256) internal virtual override whenNotPaused {}
function _previewDeposit(
address tokenIn,
uint256 amountTokenToDeposit
) internal view virtual returns (uint256 amountSharesOut);
function _previewRedeem(
address tokenOut,
uint256 amountSharesToRedeem
) internal view virtual returns (uint256 amountTokenOut);
function getTokensIn() public view virtual returns (address[] memory res);
function getTokensOut() public view virtual returns (address[] memory res);
function isValidTokenIn(address token) public view virtual returns (bool);
function isValidTokenOut(address token) public view virtual returns (bool);
}// SPDX-License-Identifier: GPL-3.0-or-later
pragma solidity ^0.8.17;
import "../RewardManager/RewardManager.sol";
import "./SYBaseUpg.sol";
/// NOTE: yieldToken MUST NEVER BE a rewardToken, else the rewardManager will behave erroneously
abstract contract SYBaseWithRewardsUpg is SYBaseUpg, RewardManager {
using PMath for uint256;
using ArrayLib for address[];
uint256[100] private __gap;
/*///////////////////////////////////////////////////////////////
REWARDS-RELATED
//////////////////////////////////////////////////////////////*/
/**
* @dev See {IStandardizedYield-claimRewards}
*/
function claimRewards(
address user
) external virtual override nonReentrant whenNotPaused returns (uint256[] memory rewardAmounts) {
_updateAndDistributeRewards(user);
rewardAmounts = _doTransferOutRewards(user, user);
emit ClaimRewards(user, _getRewardTokens(), rewardAmounts);
}
/**
* @dev See {IStandardizedYield-getRewardTokens}
*/
function getRewardTokens() external view virtual override returns (address[] memory rewardTokens) {
rewardTokens = _getRewardTokens();
}
/**
* @dev See {IStandardizedYield-accruedRewards}
*/
function accruedRewards(address user) external view virtual override returns (uint256[] memory rewardAmounts) {
address[] memory rewardTokens = _getRewardTokens();
rewardAmounts = new uint256[](rewardTokens.length);
for (uint256 i = 0; i < rewardTokens.length; ) {
rewardAmounts[i] = userReward[rewardTokens[i]][user].accrued;
unchecked {
i++;
}
}
}
function rewardIndexesCurrent() external override nonReentrant whenNotPaused returns (uint256[] memory indexes) {
(, indexes) = _updateRewardIndex();
}
function rewardIndexesStored() public view virtual override returns (uint256[] memory indexes) {
address[] memory rewardTokens = _getRewardTokens();
indexes = new uint256[](rewardTokens.length);
for (uint256 i = 0; i < rewardTokens.length; ) {
indexes[i] = rewardState[rewardTokens[i]].index;
unchecked {
i++;
}
}
}
/**
* @notice returns the total number of reward shares
* @dev this is simply the total supply of shares, as rewards shares are equivalent to SY shares
*/
function _rewardSharesTotal() internal view virtual override returns (uint256) {
return totalSupply();
}
/**
* @notice returns the reward shares of (`user`)
* @dev this is simply the SY balance of (`user`), as rewards shares are equivalent to SY shares
*/
function _rewardSharesUser(address user) internal view virtual override returns (uint256) {
return balanceOf(user);
}
/*///////////////////////////////////////////////////////////////
TRANSFER HOOKS
//////////////////////////////////////////////////////////////*/
function _beforeTokenTransfer(address from, address to, uint256) internal virtual override whenNotPaused {
_updateAndDistributeRewardsForTwo(from, to);
}
}// SPDX-License-Identifier: GPL-3.0-or-later
pragma solidity ^0.8.0;
interface IAaveV3AToken {
function UNDERLYING_ASSET_ADDRESS() external view returns (address);
function scaledBalanceOf(address user) external view returns (uint256);
function getScaledUserBalanceAndSupply(address user) external view returns (uint256, uint256);
function scaledTotalSupply() external view returns (uint256);
function getPreviousIndex(address user) external view returns (uint256);
function getIncentivesController() external view returns (address);
}// SPDX-License-Identifier: GPL-3.0-or-later
pragma solidity ^0.8.0;
interface IAaveV3IncentiveController {
function getRewardsList() external view returns (address[] memory);
function claimAllRewardsToSelf(
address[] calldata assets
) external returns (address[] memory rewardsList, uint256[] memory claimedAmounts);
}// SPDX-License-Identifier: GPL-3.0-or-later
pragma solidity ^0.8.0;
interface IAaveV3Pool {
function supply(address asset, uint256 amount, address onBehalfOf, uint16 referralCode) external;
function withdraw(address asset, uint256 amount, address to) external returns (uint256);
function getReserveNormalizedIncome(address asset) external view returns (uint256);
}// SPDX-License-Identifier: GPL-3.0-or-later
pragma solidity ^0.8.0;
interface IAngleDistributor {
function claim(
address[] calldata users,
address[] calldata tokens,
uint256[] calldata amounts,
bytes32[][] calldata proofs
) external;
}// SPDX-License-Identifier: GPL-3.0-or-later
pragma solidity ^0.8.0;
interface IRewardManager {
function userReward(address token, address user) external view returns (uint128 index, uint128 accrued);
}// SPDX-License-Identifier: GPL-3.0-or-later
/*
* MIT License
* ===========
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
*/
pragma solidity ^0.8.0;
import "@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol";
interface IStandardizedYield is IERC20Metadata {
/// @dev Emitted when any base tokens is deposited to mint shares
event Deposit(
address indexed caller,
address indexed receiver,
address indexed tokenIn,
uint256 amountDeposited,
uint256 amountSyOut
);
/// @dev Emitted when any shares are redeemed for base tokens
event Redeem(
address indexed caller,
address indexed receiver,
address indexed tokenOut,
uint256 amountSyToRedeem,
uint256 amountTokenOut
);
/// @dev check `assetInfo()` for more information
enum AssetType {
TOKEN,
LIQUIDITY
}
/// @dev Emitted when (`user`) claims their rewards
event ClaimRewards(address indexed user, address[] rewardTokens, uint256[] rewardAmounts);
/**
* @notice mints an amount of shares by depositing a base token.
* @param receiver shares recipient address
* @param tokenIn address of the base tokens to mint shares
* @param amountTokenToDeposit amount of base tokens to be transferred from (`msg.sender`)
* @param minSharesOut reverts if amount of shares minted is lower than this
* @return amountSharesOut amount of shares minted
* @dev Emits a {Deposit} event
*
* Requirements:
* - (`tokenIn`) must be a valid base token.
*/
function deposit(
address receiver,
address tokenIn,
uint256 amountTokenToDeposit,
uint256 minSharesOut
) external payable returns (uint256 amountSharesOut);
/**
* @notice redeems an amount of base tokens by burning some shares
* @param receiver recipient address
* @param amountSharesToRedeem amount of shares to be burned
* @param tokenOut address of the base token to be redeemed
* @param minTokenOut reverts if amount of base token redeemed is lower than this
* @param burnFromInternalBalance if true, burns from balance of `address(this)`, otherwise burns from `msg.sender`
* @return amountTokenOut amount of base tokens redeemed
* @dev Emits a {Redeem} event
*
* Requirements:
* - (`tokenOut`) must be a valid base token.
*/
function redeem(
address receiver,
uint256 amountSharesToRedeem,
address tokenOut,
uint256 minTokenOut,
bool burnFromInternalBalance
) external returns (uint256 amountTokenOut);
/**
* @notice exchangeRate * syBalance / 1e18 must return the asset balance of the account
* @notice vice-versa, if a user uses some amount of tokens equivalent to X asset, the amount of sy
he can mint must be X * exchangeRate / 1e18
* @dev SYUtils's assetToSy & syToAsset should be used instead of raw multiplication
& division
*/
function exchangeRate() external view returns (uint256 res);
/**
* @notice claims reward for (`user`)
* @param user the user receiving their rewards
* @return rewardAmounts an array of reward amounts in the same order as `getRewardTokens`
* @dev
* Emits a `ClaimRewards` event
* See {getRewardTokens} for list of reward tokens
*/
function claimRewards(address user) external returns (uint256[] memory rewardAmounts);
/**
* @notice get the amount of unclaimed rewards for (`user`)
* @param user the user to check for
* @return rewardAmounts an array of reward amounts in the same order as `getRewardTokens`
*/
function accruedRewards(address user) external view returns (uint256[] memory rewardAmounts);
function rewardIndexesCurrent() external returns (uint256[] memory indexes);
function rewardIndexesStored() external view returns (uint256[] memory indexes);
/**
* @notice returns the list of reward token addresses
*/
function getRewardTokens() external view returns (address[] memory);
/**
* @notice returns the address of the underlying yield token
*/
function yieldToken() external view returns (address);
/**
* @notice returns all tokens that can mint this SY
*/
function getTokensIn() external view returns (address[] memory res);
/**
* @notice returns all tokens that can be redeemed by this SY
*/
function getTokensOut() external view returns (address[] memory res);
function isValidTokenIn(address token) external view returns (bool);
function isValidTokenOut(address token) external view returns (bool);
function previewDeposit(
address tokenIn,
uint256 amountTokenToDeposit
) external view returns (uint256 amountSharesOut);
function previewRedeem(
address tokenOut,
uint256 amountSharesToRedeem
) external view returns (uint256 amountTokenOut);
/**
* @notice This function contains information to interpret what the asset is
* @return assetType the type of the asset (0 for ERC20 tokens, 1 for AMM liquidity tokens,
2 for bridged yield bearing tokens like wstETH, rETH on Arbi whose the underlying asset doesn't exist on the chain)
* @return assetAddress the address of the asset
* @return assetDecimals the decimals of the asset
*/
function assetInfo() external view returns (AssetType assetType, address assetAddress, uint8 assetDecimals);
}// SPDX-License-Identifier: GPL-3.0-or-later
/*
* MIT License
* ===========
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
*/
pragma solidity ^0.8.0;
import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
interface IWETH is IERC20 {
event Deposit(address indexed dst, uint256 wad);
event Withdrawal(address indexed src, uint256 wad);
function deposit() external payable;
function withdraw(uint256 wad) external;
}{
"optimizer": {
"enabled": true,
"runs": 1000000
},
"viaIR": true,
"evmVersion": "shanghai",
"outputSelection": {
"*": {
"*": [
"evm.bytecode",
"evm.deployedBytecode",
"devdoc",
"userdoc",
"metadata",
"abi"
]
}
}
}Contract Security Audit
- No Contract Security Audit Submitted- Submit Audit Here
Contract ABI
API[{"inputs":[{"internalType":"address","name":"_aavePool","type":"address"},{"internalType":"address","name":"_aToken","type":"address"},{"internalType":"address","name":"_initialIncentiveController","type":"address"},{"internalType":"address","name":"_defaultRewardToken","type":"address"},{"internalType":"address","name":"_offchainReceiver","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[{"internalType":"uint256","name":"actualSharesOut","type":"uint256"},{"internalType":"uint256","name":"requiredSharesOut","type":"uint256"}],"name":"SYInsufficientSharesOut","type":"error"},{"inputs":[{"internalType":"uint256","name":"actualTokenOut","type":"uint256"},{"internalType":"uint256","name":"requiredTokenOut","type":"uint256"}],"name":"SYInsufficientTokenOut","type":"error"},{"inputs":[{"internalType":"address","name":"token","type":"address"}],"name":"SYInvalidTokenIn","type":"error"},{"inputs":[{"internalType":"address","name":"token","type":"address"}],"name":"SYInvalidTokenOut","type":"error"},{"inputs":[],"name":"SYZeroDeposit","type":"error"},{"inputs":[],"name":"SYZeroRedeem","type":"error"},{"inputs":[],"name":"SameIncentiveController","type":"error"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"owner","type":"address"},{"indexed":true,"internalType":"address","name":"spender","type":"address"},{"indexed":false,"internalType":"uint256","name":"value","type":"uint256"}],"name":"Approval","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"user","type":"address"},{"indexed":false,"internalType":"address[]","name":"rewardTokens","type":"address[]"},{"indexed":false,"internalType":"uint256[]","name":"rewardAmounts","type":"uint256[]"}],"name":"ClaimRewards","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"caller","type":"address"},{"indexed":true,"internalType":"address","name":"receiver","type":"address"},{"indexed":true,"internalType":"address","name":"tokenIn","type":"address"},{"indexed":false,"internalType":"uint256","name":"amountDeposited","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"amountSyOut","type":"uint256"}],"name":"Deposit","type":"event"},{"anonymous":false,"inputs":[],"name":"EIP712DomainChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint8","name":"version","type":"uint8"}],"name":"Initialized","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"incentiveController","type":"address"}],"name":"NewIncentiveController","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"previousOwner","type":"address"},{"indexed":true,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnershipTransferred","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"account","type":"address"}],"name":"Paused","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"caller","type":"address"},{"indexed":true,"internalType":"address","name":"receiver","type":"address"},{"indexed":true,"internalType":"address","name":"tokenOut","type":"address"},{"indexed":false,"internalType":"uint256","name":"amountSyToRedeem","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"amountTokenOut","type":"uint256"}],"name":"Redeem","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"from","type":"address"},{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":false,"internalType":"uint256","name":"value","type":"uint256"}],"name":"Transfer","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"account","type":"address"}],"name":"Unpaused","type":"event"},{"inputs":[],"name":"ANGLE_DISTRIBUTOR","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"DOMAIN_SEPARATOR","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"aToken","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"aavePool","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"user","type":"address"}],"name":"accruedRewards","outputs":[{"internalType":"uint256[]","name":"rewardAmounts","type":"uint256[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"},{"internalType":"address","name":"spender","type":"address"}],"name":"allowance","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"approve","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"assetInfo","outputs":[{"internalType":"enum IStandardizedYield.AssetType","name":"assetType","type":"uint8"},{"internalType":"address","name":"assetAddress","type":"address"},{"internalType":"uint8","name":"assetDecimals","type":"uint8"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"balanceOf","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address[]","name":"users","type":"address[]"},{"internalType":"address[]","name":"tokens","type":"address[]"},{"internalType":"uint256[]","name":"amounts","type":"uint256[]"},{"internalType":"bytes32[][]","name":"proofs","type":"bytes32[][]"}],"name":"claimOffchainRewards","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"claimOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"user","type":"address"}],"name":"claimRewards","outputs":[{"internalType":"uint256[]","name":"rewardAmounts","type":"uint256[]"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"decimals","outputs":[{"internalType":"uint8","name":"","type":"uint8"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"defaultRewardToken","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"receiver","type":"address"},{"internalType":"address","name":"tokenIn","type":"address"},{"internalType":"uint256","name":"amountTokenToDeposit","type":"uint256"},{"internalType":"uint256","name":"minSharesOut","type":"uint256"}],"name":"deposit","outputs":[{"internalType":"uint256","name":"amountSharesOut","type":"uint256"}],"stateMutability":"payable","type":"function"},{"inputs":[],"name":"eip712Domain","outputs":[{"internalType":"bytes1","name":"fields","type":"bytes1"},{"internalType":"string","name":"name","type":"string"},{"internalType":"string","name":"version","type":"string"},{"internalType":"uint256","name":"chainId","type":"uint256"},{"internalType":"address","name":"verifyingContract","type":"address"},{"internalType":"bytes32","name":"salt","type":"bytes32"},{"internalType":"uint256[]","name":"extensions","type":"uint256[]"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"exchangeRate","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getRewardTokens","outputs":[{"internalType":"address[]","name":"rewardTokens","type":"address[]"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getTokensIn","outputs":[{"internalType":"address[]","name":"res","type":"address[]"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getTokensOut","outputs":[{"internalType":"address[]","name":"res","type":"address[]"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"incentiveController","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"string","name":"_name","type":"string"},{"internalType":"string","name":"_symbol","type":"string"}],"name":"initialize","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"token","type":"address"}],"name":"isValidTokenIn","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"token","type":"address"}],"name":"isValidTokenOut","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"lastRewardBlock","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"name","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"}],"name":"nonces","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"offchainReceiver","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"pause","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"paused","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"pendingOwner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"},{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"value","type":"uint256"},{"internalType":"uint256","name":"deadline","type":"uint256"},{"internalType":"uint8","name":"v","type":"uint8"},{"internalType":"bytes32","name":"r","type":"bytes32"},{"internalType":"bytes32","name":"s","type":"bytes32"}],"name":"permit","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"tokenIn","type":"address"},{"internalType":"uint256","name":"amountTokenToDeposit","type":"uint256"}],"name":"previewDeposit","outputs":[{"internalType":"uint256","name":"amountSharesOut","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"tokenOut","type":"address"},{"internalType":"uint256","name":"amountSharesToRedeem","type":"uint256"}],"name":"previewRedeem","outputs":[{"internalType":"uint256","name":"amountTokenOut","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"receiver","type":"address"},{"internalType":"uint256","name":"amountSharesToRedeem","type":"uint256"},{"internalType":"address","name":"tokenOut","type":"address"},{"internalType":"uint256","name":"minTokenOut","type":"uint256"},{"internalType":"bool","name":"burnFromInternalBalance","type":"bool"}],"name":"redeem","outputs":[{"internalType":"uint256","name":"amountTokenOut","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"rewardIndexesCurrent","outputs":[{"internalType":"uint256[]","name":"indexes","type":"uint256[]"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"rewardIndexesStored","outputs":[{"internalType":"uint256[]","name":"indexes","type":"uint256[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"rewardState","outputs":[{"internalType":"uint128","name":"index","type":"uint128"},{"internalType":"uint128","name":"lastBalance","type":"uint128"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"symbol","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"totalSupply","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"transfer","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"from","type":"address"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"transferFrom","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newOwner","type":"address"},{"internalType":"bool","name":"direct","type":"bool"},{"internalType":"bool","name":"renounce","type":"bool"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"underlying","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"unpause","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"address","name":"","type":"address"}],"name":"userReward","outputs":[{"internalType":"uint128","name":"index","type":"uint128"},{"internalType":"uint128","name":"accrued","type":"uint128"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"yieldToken","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"stateMutability":"payable","type":"receive"}]Contract Creation Code
610180604081815234620002465760a0826200623080380380916200002582856200033a565b83398101031262000246576200003b8262000372565b6020926200004b84820162000372565b926200005981830162000372565b936200007660806200006e6060860162000372565b940162000372565b825163313ce56760e01b815290946001600160a01b0383169290918881600481875afa90811562000330575f91620002f2575b5060805261013460ff1981541690558060a05260015460ff8160a81c166200029e5791600493918360ff808c9660a01c16036200025c575b5060c05260e05283516358b50cef60e11b815292839182905afa95861562000252575f966200020e575b50506101009485526101209384526101409182526101609283525192615ea8948562000388863960805185610e87015260a0518561192e015260c0518581816105b301528181611e470152818161332e0152818161471e0152615349015260e051858181611dd9015281816131fa01528181613b48015281816140dc01526146cb0152518481816105810152818161164c01528181611ec10152818161321b0152818161335e01528181613b06015281816140b501526146270152518381816114d201526153160152518281816108e4015281816121c8015281816125f30152818161287801528181612c6b01526149ff015251818181611c5801526136370152f35b9080929650813d83116200024a575b6200022981836200033a565b8101031262000246576200023d9062000372565b935f806200010b565b5f80fd5b503d6200021d565b82513d5f823e3d90fd5b60ff60a01b191660ff60a01b17600155855160ff81527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb3847402498908590a15f620000e1565b845162461bcd60e51b8152600481018a9052602760248201527f496e697469616c697a61626c653a20636f6e747261637420697320696e697469604482015266616c697a696e6760c81b6064820152608490fd5b90508881813d831162000328575b6200030c81836200033a565b8101031262000246575160ff8116810362000246575f620000a9565b503d62000300565b85513d5f823e3d90fd5b601f909101601f19168101906001600160401b038211908210176200035e57604052565b634e487b7160e01b5f52604160045260245ffd5b51906001600160a01b0382168203620002465756fe6080604052600436101561001a575b3615610018575f80fd5b005b5f3560e01c806306fdde031461030f578063071bc3c9146102f1578063078dfbe71461030a578063095ea7b314610305578063128fced11461030057806318160ddd146102fb57806320e8c565146102f6578063213cae63146102f157806323b872dd146102ec578063313ce567146102e75780633644e515146102e25780633ba0b9a9146102dd5780633f4ba83a146102d85780634cd88b76146102d35780634e71e0c8146102ce5780635b9fe37f146102c95780635c975abb146102c45780635cbadbe4146102bf5780636f307dc3146102ba57806370a08231146102b5578063769f8e5d146102b057806376d5de85146102ab578063784367d6146102335780637ecebe00146102a65780638456cb59146102a157806384b0196e1461029c5780638b8fa807146102975780638da5cb5b1461029257806395d89b411461028d578063a03e4bc314610288578063a0c1f15e14610283578063a40bee501461027e578063a9059cbb14610279578063a9f8d18114610274578063b8f82b261461026f578063c4f59f9b1461026a578063c8b5a95714610265578063cbe52ae314610260578063cf2fa5761461025b578063d505accf14610256578063da88ecb414610251578063dd62ed3e1461024c578063e30c397814610247578063ea64a82014610242578063ef5cfb8c1461023d578063f8b2f99114610238578063fa5a4f06146102335763ff3a4ac00361000e57612c21565b611952565b612b1c565b6127ca565b612740565b6126ef565b61268f565b6125c0565b6123e2565b61238b565b6122d9565b612231565b612192565b6120bd565b612081565b611f8b565b611e6b565b611dfd565b611d8f565b611ccc565b611c7c565b611c0e565b611b3d565b611a08565b6119a1565b6118e4565b6116d5565b611670565b611602565b61157a565b6114f6565b611488565b611346565b611186565b610f31565b610eeb565b610eab565b610e50565b610c54565b610508565b6109f4565b610998565b6108a3565b61080c565b610616565b610392565b5f91031261031e57565b5f80fd5b91908251928382525f5b84811061036a5750507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0601f845f6020809697860101520116010190565b60208183018101518483018201520161032c565b90602061038f928181520190610322565b90565b3461031e575f7ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc36011261031e576040515f6005546103d081612c8f565b80845290602090600190818116908115610466575060011461040d575b610409856103fd818703826110b6565b6040519182918261037e565b0390f35b60055f90815293507f036b6384b5eca791c62761152d0c79bb0604c104a5fb6f4eb0703f3154bb3db05b838510610453575050505081016020016103fd826104096103ed565b8054868601840152938201938101610437565b869550610409969350602092506103fd9491507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff001682840152151560051b82010192936103ed565b9081518082526020808093019301915f5b8281106104cd575050505090565b835173ffffffffffffffffffffffffffffffffffffffff16855293810193928101926001016104bf565b90602061038f9281815201906104ae565b3461031e575f7ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc36011261031e576040516060810181811067ffffffffffffffff8211176105e95760405260028152602081019060403683378051156105e45773ffffffffffffffffffffffffffffffffffffffff91827f00000000000000000000000000000000000000000000000000000000000000001690528051600110156105e457610409917f0000000000000000000000000000000000000000000000000000000000000000166040820152604051918291826104f7565b612f4f565b61103d565b73ffffffffffffffffffffffffffffffffffffffff81160361031e57565b8015150361031e57565b3461031e5760607ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc36011261031e57600435610651816105ee565b6024359061065e8261060c565b6044359161066b8361060c565b73ffffffffffffffffffffffffffffffffffffffff9061068f825f54163314612e5c565b156107dc578116918215908115916107d4575b501561077657610749916106e66106cd5f5473ffffffffffffffffffffffffffffffffffffffff1690565b73ffffffffffffffffffffffffffffffffffffffff1690565b7f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e05f80a373ffffffffffffffffffffffffffffffffffffffff167fffffffffffffffffffffffff00000000000000000000000000000000000000005f5416175f55565b6100187fffffffffffffffffffffffff000000000000000000000000000000000000000060015416600155565b60646040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601560248201527f4f776e61626c653a207a65726f206164647265737300000000000000000000006044820152fd5b90505f6106a2565b9150167fffffffffffffffffffffffff000000000000000000000000000000000000000060015416176001555f80f35b3461031e5760407ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc36011261031e5761085460043561084a816105ee565b6024359033613867565b602060405160018152f35b9081518082526020808093019301915f5b82811061087e575050505090565b835185529381019392810192600101610870565b90602061038f92818152019061085f565b3461031e576020807ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc36011261031e576004356108df816105ee565b6109087f0000000000000000000000000000000000000000000000000000000000000000614c97565b906109138251612f00565b925f5b835181101561098a578073ffffffffffffffffffffffffffffffffffffffff61094160019387612f7c565b51165f5261019983526109758460405f209073ffffffffffffffffffffffffffffffffffffffff165f5260205260405f2090565b5460801c6109838288612f7c565b5201610916565b604051806104098782610892565b3461031e575f7ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc36011261031e5760207effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff60045416604051908152f35b60807ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc36011261031e57600435610a2a816105ee565b60243590610a37826105ee565b6044359060643592610a51600260045460f81c1415612f90565b610a9f7f02000000000000000000000000000000000000000000000000000000000000007effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff6004541617600455565b610aaf610aab82613313565b1590565b610c0b578215610be157610ac48333836139ff565b610ace8382613aef565b92848410610b9f576104099450610ae58484613bea565b7f5fe47ed6d4225326d3303476197d782ded5a4e9c14f479dc9ec4992af4e85d5973ffffffffffffffffffffffffffffffffffffffff80604051941694169280610b3e8733958360209093929193604081019481520152565b0390a4610b8f7f01000000000000000000000000000000000000000000000000000000000000007effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff6004541617600455565b6040519081529081906020820190565b50506040517fbc71f2ba0000000000000000000000000000000000000000000000000000000081526004810192909252506024810191909152604490fd5b0390fd5b60046040517fa907f2f0000000000000000000000000000000000000000000000000000000008152fd5b6040517faeabe71800000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff919091166004820152602490fd5b3461031e5760607ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc36011261031e57600435610c8f816105ee565b602435610c9b816105ee565b60443590610cb1600260045460f81c1415612f90565b610cff7f02000000000000000000000000000000000000000000000000000000000000007effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff6004541617600455565b73ffffffffffffffffffffffffffffffffffffffff83165f526003602052610d483360405f209073ffffffffffffffffffffffffffffffffffffffff165f5260205260405f2090565b54927fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8403610dd6575b610d7c9350613ee9565b610dca7f01000000000000000000000000000000000000000000000000000000000000007effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff6004541617600455565b60405160018152602090f35b828410610df257610ded83610d7c95033383613867565b610d72565b60646040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601d60248201527f45524332303a20696e73756666696369656e7420616c6c6f77616e63650000006044820152fd5b3461031e575f7ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc36011261031e57602060405160ff7f0000000000000000000000000000000000000000000000000000000000000000168152f35b3461031e575f7ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc36011261031e576020610ee3614d23565b604051908152f35b3461031e575f7ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc36011261031e576020633b9aca00610f2861406f565b04604051908152f35b3461031e575f7ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc36011261031e57610f8173ffffffffffffffffffffffffffffffffffffffff5f54163314612e5c565b610134805460ff811615610fdf577fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff001690557f5db9ee0a495bf2e6ff9c91a7834c1ba4fdd244a5e8aa4e537bd38aeae4b073aa6020604051338152a1005b60646040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601460248201527f5061757361626c653a206e6f74207061757365640000000000000000000000006044820152fd5b7f4e487b71000000000000000000000000000000000000000000000000000000005f52604160045260245ffd5b67ffffffffffffffff81116105e957604052565b6040810190811067ffffffffffffffff8211176105e957604052565b60a0810190811067ffffffffffffffff8211176105e957604052565b90601f7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0910116810190811067ffffffffffffffff8211176105e957604052565b604051906111048261107e565b565b67ffffffffffffffff81116105e957601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe01660200190565b81601f8201121561031e5780359061115782611106565b9261116560405194856110b6565b8284526020838301011161031e57815f926020809301838601378301015290565b3461031e5760407ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc36011261031e5767ffffffffffffffff60043581811161031e576111d6903690600401611140565b9060243590811161031e576111f2611265913690600401611140565b6001549261121760ff8560a81c161580958196611334575b8115611311575b50613059565b8361125c740100000000000000000000000000000000000000007fffffffffffffffffffffff00ffffffffffffffffffffffffffffffffffffffff6001541617600155565b6112c7576130e4565b61126b57005b6112987fffffffffffffffffffff00ffffffffffffffffffffffffffffffffffffffffff60015416600155565b604051600181527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb384740249890602090a1005b61130c75010000000000000000000000000000000000000000007fffffffffffffffffffff00ffffffffffffffffffffffffffffffffffffffffff6001541617600155565b6130e4565b303b15915081611323575b505f611211565b60a01c60ff1660011490505f61131c565b9050600160ff8260a01c16109061120a565b3461031e575f7ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc36011261031e5773ffffffffffffffffffffffffffffffffffffffff806001541680330361142a5780611400925f54167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e05f80a373ffffffffffffffffffffffffffffffffffffffff167fffffffffffffffffffffffff00000000000000000000000000000000000000005f5416175f55565b600180547fffffffffffffffffffffffff0000000000000000000000000000000000000000169055005b60646040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602060248201527f4f776e61626c653a2063616c6c657220213d2070656e64696e67206f776e65726044820152fd5b3461031e575f7ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc36011261031e57602060405173ffffffffffffffffffffffffffffffffffffffff7f0000000000000000000000000000000000000000000000000000000000000000168152f35b3461031e575f7ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc36011261031e57602060ff61013454166040519015158152f35b7ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc604091011261031e5760043561156d816105ee565b9060243561038f816105ee565b3461031e576104096115d473ffffffffffffffffffffffffffffffffffffffff6115a336611537565b91165f5261019960205260405f209073ffffffffffffffffffffffffffffffffffffffff165f5260205260405f2090565b54604080516fffffffffffffffffffffffffffffffff8316815260809290921c602083015290918291820190565b3461031e575f7ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc36011261031e57602060405173ffffffffffffffffffffffffffffffffffffffff7f0000000000000000000000000000000000000000000000000000000000000000168152f35b3461031e5760207ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc36011261031e576020610ee36004356116b0816105ee565b73ffffffffffffffffffffffffffffffffffffffff165f52600260205260405f205490565b3461031e5760a07ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc36011261031e57600435611710816105ee565b60243560443591611720836105ee565b606435926084356117308161060c565b611742600260045460f81c1415612f90565b6117907f02000000000000000000000000000000000000000000000000000000000000007effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff6004541617600455565b61179c610aab83613313565b61189d5783156118735715611864576117b5833061446f565b6117c0838284614600565b928484106118265761040994507faee47cdf925cf525fdae94f9777ee5a06cac37e1c41220d0a8a89ed154f62d1c73ffffffffffffffffffffffffffffffffffffffff80604051941694169280610b3e8733958360209093929193604081019481520152565b50506040517fbfee4ca00000000000000000000000000000000000000000000000000000000081526004810192909252506024810191909152604490fd5b61186e833361446f565b6117b5565b60046040517fc3d83b07000000000000000000000000000000000000000000000000000000008152fd5b6040517f88a5056100000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff83166004820152602490fd5b3461031e575f7ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc36011261031e57602060405173ffffffffffffffffffffffffffffffffffffffff7f0000000000000000000000000000000000000000000000000000000000000000168152f35b3461031e5760207ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc36011261031e576020611997600435611992816105ee565b613313565b6040519015158152f35b3461031e5760207ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc36011261031e5773ffffffffffffffffffffffffffffffffffffffff6004356119f1816105ee565b165f52609f602052602060405f2054604051908152f35b3461031e575f7ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc36011261031e57611a5873ffffffffffffffffffffffffffffffffffffffff5f54163314612e5c565b611a6061492e565b61013460017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff008254161790557f62e78cea01bee320cd4e420270b5ea74000d11b0c9f74754ebdbfc544b05a2586020604051338152a1005b9193611b1e61038f969495611b1073ffffffffffffffffffffffffffffffffffffffff947f0f00000000000000000000000000000000000000000000000000000000000000875260e0602088015260e0870190610322565b908582036040870152610322565b9460608401521660808201525f60a082015260c081840391015261085f565b3461031e575f7ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc36011261031e57606b541580611c04575b15611ba657611b82612ce0565b611b8a612dc0565b90610409611b96612ed9565b6040519384933091469186611ab8565b60646040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601560248201527f4549503731323a20556e696e697469616c697a656400000000000000000000006044820152fd5b50606c5415611b75565b3461031e575f7ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc36011261031e57602060405173ffffffffffffffffffffffffffffffffffffffff7f0000000000000000000000000000000000000000000000000000000000000000168152f35b3461031e575f7ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc36011261031e57602073ffffffffffffffffffffffffffffffffffffffff5f5416604051908152f35b3461031e575f7ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc36011261031e576040515f600654611d0a81612c8f565b808452906020906001908181169081156104665750600114611d3657610409856103fd818703826110b6565b60065f90815293507ff652222313e28459528d920b65115c16c04f3efc82aaedc97be59f3f377c0d3f5b838510611d7c575050505081016020016103fd826104096103ed565b8054868601840152938201938101611d60565b3461031e575f7ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc36011261031e57602060405173ffffffffffffffffffffffffffffffffffffffff7f0000000000000000000000000000000000000000000000000000000000000000168152f35b3461031e575f7ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc36011261031e57602060405173ffffffffffffffffffffffffffffffffffffffff7f0000000000000000000000000000000000000000000000000000000000000000168152f35b3461031e575f7ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc36011261031e576040517f313ce5670000000000000000000000000000000000000000000000000000000081527f000000000000000000000000000000000000000000000000000000000000000060208260048173ffffffffffffffffffffffffffffffffffffffff85165afa918215611f86575f92611f49575b506104096040519283928390929160ff60409173ffffffffffffffffffffffffffffffffffffffff60608501965f865216602085015216910152565b9091506020813d602011611f7e575b81611f65602093836110b6565b8101031261031e5751611f77816123d7565b905f611f0d565b3d9150611f58565b613384565b3461031e5760407ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc36011261031e57612033600435611fc9816105ee565b611fdb600260045460f81c1415612f90565b6120297f02000000000000000000000000000000000000000000000000000000000000007effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff6004541617600455565b6024359033613ee9565b6108547f01000000000000000000000000000000000000000000000000000000000000007effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff6004541617600455565b3461031e575f7ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc36011261031e57602061019a54604051908152f35b3461031e5760407ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc36011261031e576004356120f8816105ee565b6024359061210581613313565b1561214b575061211361406f565b908160011c6b033b2e3c9fd0803ce80000009283821904831181151761031e5761040991604051948594020104829190602083019252565b60249073ffffffffffffffffffffffffffffffffffffffff604051917faeabe718000000000000000000000000000000000000000000000000000000008352166004820152fd5b3461031e575f7ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc36011261031e576104096121ec7f0000000000000000000000000000000000000000000000000000000000000000614c97565b6040519182916020835260208301906104ae565b9181601f8401121561031e5782359167ffffffffffffffff831161031e576020808501948460051b01011161031e57565b3461031e5760807ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc36011261031e5767ffffffffffffffff60043581811161031e57612281903690600401612200565b9060243583811161031e5761229a903690600401612200565b9060443585811161031e576122b3903690600401612200565b92909160643596871161031e576122d1610018973690600401612200565b96909561362e565b3461031e5760407ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc36011261031e57600435612314816105ee565b61231d81613313565b156123445760206b033b2e3c9fd0803ce8000000610f2861233c61406f565b602435614f68565b60249073ffffffffffffffffffffffffffffffffffffffff604051917f88a50561000000000000000000000000000000000000000000000000000000008352166004820152fd5b3461031e575f7ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc36011261031e576020604051733ef3d8ba38ebe18db133cec108f4d14ce00dd9ae8152f35b60ff81160361031e57565b3461031e5760e07ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc36011261031e5760043561241d816105ee565b602435612429816105ee565b60443590606435926084359361243e856123d7565b8042116125625761253d61255d916124f9610018976125256124878773ffffffffffffffffffffffffffffffffffffffff165f52609f60205260405f2090815491600183019055565b9360405193849160208301968c8c8c8a91959493909260a09360c08401977f6e71edae12b1b97f4d1f60370fef10105fa2faae0126114a169c64845d6126c9855273ffffffffffffffffffffffffffffffffffffffff8092166020860152166040840152606083015260808201520152565b037fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe081018452836110b6565b61253860c4359360a435935190206148d6565b614917565b73ffffffffffffffffffffffffffffffffffffffff8084169116146137dd565b613867565b60646040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601d60248201527f45524332305065726d69743a206578706972656420646561646c696e650000006044820152fd5b3461031e575f7ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc36011261031e576126177f0000000000000000000000000000000000000000000000000000000000000000614c97565b6126218151612f00565b905f5b8151811015612681578073ffffffffffffffffffffffffffffffffffffffff61264f60019385612f7c565b51165f5261019b6020526fffffffffffffffffffffffffffffffff60405f20541661267a8286612f7c565b5201612624565b604051806104098582610892565b3461031e5760206126e673ffffffffffffffffffffffffffffffffffffffff6126b736611537565b91165f526003835260405f209073ffffffffffffffffffffffffffffffffffffffff165f5260205260405f2090565b54604051908152f35b3461031e575f7ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc36011261031e57602073ffffffffffffffffffffffffffffffffffffffff60015416604051908152f35b3461031e5760207ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc36011261031e5773ffffffffffffffffffffffffffffffffffffffff600435612790816105ee565b165f90815261019b60209081526040918290205482516fffffffffffffffffffffffffffffffff8216815260809190911c91810191909152f35b3461031e5760207ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc36011261031e57600435612805816105ee565b612817600260045460f81c1415612f90565b6128657f02000000000000000000000000000000000000000000000000000000000000007effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff6004541617600455565b61286d61492e565b612876816151c3565b7f00000000000000000000000000000000000000000000000000000000000000006128a081614c97565b916128ab8351612f00565b925f5b8151811015612a68578061295261293d612936866129136128ee6128d46001988a612f7c565b5173ffffffffffffffffffffffffffffffffffffffff1690565b73ffffffffffffffffffffffffffffffffffffffff165f5261019960205260405f2090565b9073ffffffffffffffffffffffffffffffffffffffff165f5260205260405f2090565b5460801c90565b6fffffffffffffffffffffffffffffffff1690565b61295c8288612f7c565b526129678187612f7c565b51612973575b016128ae565b6129a261298a856129136128ee6128d48689612f7c565b6fffffffffffffffffffffffffffffffff8154169055565b612a416129b86129b28389612f7c565b51615281565b612a016129f06129cb6128d48689612f7c565b73ffffffffffffffffffffffffffffffffffffffff165f5261019b60205260405f2090565b916129fc835460801c90565b614999565b6fffffffffffffffffffffffffffffffff7fffffffffffffffffffffffffffffffff0000000000000000000000000000000083549260801b169116179055565b612a63612a516128d48386612f7c565b85612a5c848a612f7c565b51916147da565b61296d565b61040985847f2193aa20a3717f5f4ac79482f4f553e5f0afe8f4e6ec3e3d1aa2e138adc4763f73ffffffffffffffffffffffffffffffffffffffff612aac89614c97565b92612abf85604051938493169583613842565b0390a2612b107f01000000000000000000000000000000000000000000000000000000000000007effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff6004541617600455565b60405191829182610892565b3461031e575f7ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc36011261031e57612b5c600260045460f81c1415612f90565b612baa7f02000000000000000000000000000000000000000000000000000000000000007effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff6004541617600455565b612bb261492e565b610409612bbd6149fa565b9050612c0d7f01000000000000000000000000000000000000000000000000000000000000007effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff6004541617600455565b60405191829160208352602083019061085f565b3461031e575f7ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc36011261031e57602060405173ffffffffffffffffffffffffffffffffffffffff7f0000000000000000000000000000000000000000000000000000000000000000168152f35b90600182811c92168015612cd6575b6020831014612ca957565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52602260045260245ffd5b91607f1691612c9e565b604051905f82606d5491612cf383612c8f565b80835292602090600190818116908115612d7d5750600114612d1e575b5050611104925003836110b6565b915092606d5f527f5006b838207c6a9ae9b84d68f467dd4bb5c305fbfb6b04eab8faaabeec1e18d8935f925b828410612d6557506111049450505081016020015f80612d10565b85548885018301529485019487945092810192612d4a565b9050602093506111049592507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0091501682840152151560051b8201015f80612d10565b604051905f82606e5491612dd383612c8f565b80835292602090600190818116908115612d7d5750600114612dfd575050611104925003836110b6565b915092606e5f527f9930d9ff0dee0ef5ca2f7710ea66b8f84dd0f5f5351ecffe72b952cd9db7142a935f925b828410612e4457506111049450505081016020015f80612d10565b85548885018301529485019487945092810192612e29565b15612e6357565b60646040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602060248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152fd5b67ffffffffffffffff81116105e95760051b60200190565b6040516020810181811067ffffffffffffffff8211176105e9576040525f8152905f368137565b90612f0a82612ec1565b612f1760405191826110b6565b8281527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0612f458294612ec1565b0190602036910137565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52603260045260245ffd5b80518210156105e45760209160051b010190565b15612f9757565b60646040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c006044820152fd5b7f4e487b71000000000000000000000000000000000000000000000000000000005f52601160045260245ffd5b811561302c570490565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52601260045260245ffd5b1561306057565b60846040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201527f647920696e697469616c697a65640000000000000000000000000000000000006064820152fd5b91909160019261310d60ff60015460a81c166130ff81614138565b61310881614138565b614138565b815167ffffffffffffffff81116105e9576131328161312d600554612c8f565b615614565b602094856001601f84111461324a5750509061318982613191936131ed96975f9161323f575b507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8260011b9260031b1c19161790565b6005556157c8565b6131df7f01000000000000000000000000000000000000000000000000000000000000007effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff6004541617600455565b6131e7614d99565b90615a4a565b6131f5614dd2565b6111047f00000000000000000000000000000000000000000000000000000000000000007f00000000000000000000000000000000000000000000000000000000000000006141c3565b90508501515f613158565b60055f5295907fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe08316907f036b6384b5eca791c62761152d0c79bb0604c104a5fb6f4eb0703f3154bb3db0975f915b8383106132fc57505050916131ed9596600192826131919695106132c5575b5050811b016005556157c8565b8601517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff60f88460031b161c191690555f806132b8565b878501518a55988901989381019391810191613299565b73ffffffffffffffffffffffffffffffffffffffff809116817f000000000000000000000000000000000000000000000000000000000000000016811491821561335c57505090565b7f00000000000000000000000000000000000000000000000000000000000000001614919050565b6040513d5f823e3d90fd5b1561339657565b60646040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601d60248201527f50656e646c65416176654d657269743a20756e617574686f72697a65640000006044820152fd5b90156105e45790565b91908110156105e45760051b0190565b3561038f816105ee565b1561341e57565b60646040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601e60248201527f50656e646c65416176654d657269743a20696e76616c696420757365727300006044820152fd5b9190808252602080920192915f5b828110613498575050505090565b90919293828060019273ffffffffffffffffffffffffffffffffffffffff88356134c1816105ee565b1681520195019392910161348a565b90918281527f07ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff831161031e5760209260051b809284830137010190565b9795919361352d61353d9261354b9697959760808c5260808c019161347c565b906020968a8303888c015261347c565b9187830360408901526134d0565b936060818603910152818452808401936005828460051b83010195855f935b86851061357c57505050505050505090565b90919293949596977fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe082820301845288357fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe18436030181121561031e57830187810191903567ffffffffffffffff811161031e5780871b3603831361031e5761360a899283926001956134d0565b9a01940195019392969594919061356a565b9190820391821161362957565b612ff5565b939194959690967f00000000000000000000000000000000000000000000000000000000000000009473ffffffffffffffffffffffffffffffffffffffff9861367a8a8816331461338f565b61369160019a6001831490816137c5575b50613417565b61369a86612f00565b988a5f5b8b898c8184106137a1575050505050733ef3d8ba38ebe18db133cec108f4d14ce00dd9ae92833b1561031e5761370b5f968b9688948b9a6040519b8c9a8b998a987f71ee95c0000000000000000000000000000000000000000000000000000000008a5260048a0161350d565b03925af18015611f8657613788575b505f5b81811061372c57505050505050565b8061375d61374c6137476137428a95878a6133fd565b61340d565b614742565b6137568389612f7c565b519061361c565b8061376a575b500161371d565b613782908561377d61374285888b6133fd565b6147da565b5f613763565b8061379561379b9261106a565b80610314565b5f61371a565b6137b6613747613742866137bc9581956133fd565b92612f7c565b52018b9061369e565b90506137d461374284866133f4565b1630145f61368b565b156137e457565b60646040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601e60248201527f45524332305065726d69743a20696e76616c6964207369676e617475726500006044820152fd5b909161385961038f936040845260408401906104ae565b91602081840391015261085f565b9073ffffffffffffffffffffffffffffffffffffffff9182811692831561397c5782169384156138f857806138e27f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925946129136138f39573ffffffffffffffffffffffffffffffffffffffff165f52600360205260405f2090565b556040519081529081906020820190565b0390a3565b60846040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602260248201527f45524332303a20617070726f766520746f20746865207a65726f20616464726560448201527f73730000000000000000000000000000000000000000000000000000000000006064820152fd5b60846040517f08c379a0000000000000000000000000000000000000000000000000000000008152602060048201526024808201527f45524332303a20617070726f76652066726f6d20746865207a65726f2061646460448201527f72657373000000000000000000000000000000000000000000000000000000006064820152fd5b73ffffffffffffffffffffffffffffffffffffffff9190821680613a86575050503403613a2857565b60646040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152600c60248201527f657468206d69736d6174636800000000000000000000000000000000000000006044820152fd5b90919280613a95575b50505050565b613ae693604051937f23b872dd000000000000000000000000000000000000000000000000000000006020860152166024840152306044840152606483015260648252613ae18261109a565b61545e565b5f808080613a8f565b73ffffffffffffffffffffffffffffffffffffffff7f00000000000000000000000000000000000000000000000000000000000000008116929181168314613b46575b5061038f9150613b4061406f565b9061557d565b7f00000000000000000000000000000000000000000000000000000000000000001691823b1561031e575f926084849260405195869384927f617ba03700000000000000000000000000000000000000000000000000000000845260048401528660248401523060448401528160648401525af1918215611f865761038f9215613b325780613795613bd79261106a565b5f613b32565b9190820180921161362957565b9073ffffffffffffffffffffffffffffffffffffffff8216918215613d1057613c1161492e565b613c1a816151c3565b613c2382614cf7565b907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff91828060045416911601918211613629575f92613cf36138f392613ccf7fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef957effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff167fff000000000000000000000000000000000000000000000000000000000000006004541617600455565b73ffffffffffffffffffffffffffffffffffffffff165f52600260205260405f2090565b613cfe828254613bdd565b90556040519081529081906020820190565b60646040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601f60248201527f45524332303a206d696e7420746f20746865207a65726f2061646472657373006044820152fd5b15613d7557565b60846040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602360248201527f45524332303a207472616e7366657220746f20746865207a65726f206164647260448201527f65737300000000000000000000000000000000000000000000000000000000006064820152fd5b15613e0057565b60646040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601760248201527f45524332303a207472616e7366657220746f2073656c660000000000000000006044820152fd5b15613e6557565b60846040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602660248201527f45524332303a207472616e7366657220616d6f756e742065786365656473206260448201527f616c616e636500000000000000000000000000000000000000000000000000006064820152fd5b919073ffffffffffffffffffffffffffffffffffffffff90818416928315613fdc57613cf3827fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef946138f3941696613f42881515613d6e565b613f4e88881415613df9565b613f588282614ce5565b613fb784613f848373ffffffffffffffffffffffffffffffffffffffff165f52600260205260405f2090565b54613f9182821015613e5e565b039173ffffffffffffffffffffffffffffffffffffffff165f52600260205260405f2090565b5573ffffffffffffffffffffffffffffffffffffffff165f52600260205260405f2090565b60846040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602560248201527f45524332303a207472616e736665722066726f6d20746865207a65726f20616460448201527f64726573730000000000000000000000000000000000000000000000000000006064820152fd5b9081602091031261031e575190565b6024602073ffffffffffffffffffffffffffffffffffffffff604051928380927fd15e0053000000000000000000000000000000000000000000000000000000008252807f00000000000000000000000000000000000000000000000000000000000000001660048301527f0000000000000000000000000000000000000000000000000000000000000000165afa908115611f86575f9161410f575090565b61038f915060203d602011614131575b61412981836110b6565b810190614060565b503d61411f565b1561413f57565b60846040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602b60248201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960448201527f6e697469616c697a696e670000000000000000000000000000000000000000006064820152fd5b919073ffffffffffffffffffffffffffffffffffffffff928381169384156143ac576040519485917fdd62ed3e0000000000000000000000000000000000000000000000000000000083523060048401528416602483015281604460209788935afa8015611f86576b7fffffffffffffffffffffff915f9161438f575b501061424d575b50509050565b6040517f095ea7b30000000000000000000000000000000000000000000000000000000085820190815273ffffffffffffffffffffffffffffffffffffffff841660248301525f60448301819052918291906142d481606481015b037fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe081018352826110b6565b519082855af16142e26147ab565b8161435f575b5015614301576142f9929350614e22565b805f80614247565b606484604051907f08c379a00000000000000000000000000000000000000000000000000000000082526004820152600c60248201527f5361666520417070726f766500000000000000000000000000000000000000006044820152fd5b80518015925086908315614377575b5050505f6142e8565b6143879350820181019101614e0d565b5f858161436e565b6143a69150863d88116141315761412981836110b6565b5f614240565b5050509050565b156143ba57565b60846040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602260248201527f45524332303a206275726e20616d6f756e7420657863656564732062616c616e60448201527f63650000000000000000000000000000000000000000000000000000000000006064820152fd5b7effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff918216908216039190821161362957565b9073ffffffffffffffffffffffffffffffffffffffff821690811561457c576138f37fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef91846144be5f96614cd4565b6144f7826144ea8373ffffffffffffffffffffffffffffffffffffffff165f52600260205260405f2090565b54613f91828210156143b3565b55610b8f61453061450783614cf7565b6004547effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1661443e565b7effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff167fff000000000000000000000000000000000000000000000000000000000000006004541617600455565b60846040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602160248201527f45524332303a206275726e2066726f6d20746865207a65726f2061646472657360448201527f73000000000000000000000000000000000000000000000000000000000000006064820152fd5b9092916146226b033b2e3c9fd0803ce80000009161461c61406f565b90614f68565b0492837f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff92838083169116145f14614715576040517f69328dec00000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff91821660048201526024810192909252929092166044830152602090829060649082905f907f0000000000000000000000000000000000000000000000000000000000000000165af18015611f86576146fa5750565b6147129060203d6020116141315761412981836110b6565b50565b509050611104917f00000000000000000000000000000000000000000000000000000000000000006147da565b73ffffffffffffffffffffffffffffffffffffffff168061476257504790565b6020602491604051928380927f70a082310000000000000000000000000000000000000000000000000000000082523060048301525afa908115611f86575f9161410f575b5090565b3d156147d5573d906147bc82611106565b916147ca60405193846110b6565b82523d5f602084013e565b606090565b82156148d15773ffffffffffffffffffffffffffffffffffffffff168061487257505f80809381935af161480c6147ab565b501561481457565b60646040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152600f60248201527f6574682073656e64206661696c656400000000000000000000000000000000006044820152fd5b6040517fa9059cbb00000000000000000000000000000000000000000000000000000000602082015273ffffffffffffffffffffffffffffffffffffffff9092166024830152604482019290925261110491613ae182606481016124f9565b505050565b6042906148e1614d23565b90604051917f19010000000000000000000000000000000000000000000000000000000000008352600283015260228201522090565b9161038f939161492693614f7b565b91909161503a565b60ff610134541661493b57565b60646040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601060248201527f5061757361626c653a20706175736564000000000000000000000000000000006044820152fd5b6fffffffffffffffffffffffffffffffff918216908216039190821161362957565b906040516040810181811067ffffffffffffffff8211176105e95760405291546fffffffffffffffffffffffffffffffff8116835260801c6020830152565b614a237f0000000000000000000000000000000000000000000000000000000000000000614c97565b90614a2e8251612f00565b908251156111045761019a544314614c4b5790614a4b4361019a55565b7effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff6004541690614a786152ff565b811515915f5b8551811015614c445780614a976128d460019389612f7c565b87614ac9614ac48373ffffffffffffffffffffffffffffffffffffffff165f5261019b60205260405f2090565b6149bb565b602092614b32614b05614aee868501516fffffffffffffffffffffffffffffffff1690565b93516fffffffffffffffffffffffffffffffff1690565b614b2d6137476128d4896fffffffffffffffffffffffffffffffff8098169788951698612f7c565b61361c565b93878a8515614c3c575b614c01575b50906129cb614ba692614b69614b648798614b5e614bf099615281565b97613bdd565b615281565b90614b8d614b756110f7565b6fffffffffffffffffffffffffffffffff9097168752565b8501906fffffffffffffffffffffffffffffffff169052565b815160209092015160801b7fffffffffffffffffffffffffffffffff00000000000000000000000000000000166fffffffffffffffffffffffffffffffff92909216919091179055565b614bfa8286612f7c565b5201614a7e565b614ba69291614b69614b64614c2e614bf098614c286129cb96614c238d614f4b565b613022565b90613bdd565b975050509192505087614b41565b889550614b3c565b5050919050565b905f5b83518110156147a75780614c8661293d614c706129cb6128d46001968a612f7c565b546fffffffffffffffffffffffffffffffff1690565b614c908285612f7c565b5201614c4e565b9060405191614ca58361107e565b60018352602083019060203683378351156105e45773ffffffffffffffffffffffffffffffffffffffff169052565b61110490614ce061492e565b6151c3565b9061110491614cf261492e565b615212565b7effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff9081811161031e571690565b614d2b6155a3565b614d336155ee565b6040519060208201927f8b73c3c69bb8fe3d512ecc4cf759cc79239f7b179b0ffacaa9a75d522b39400f8452604083015260608201524660808201523060a082015260a0815260c0810181811067ffffffffffffffff8211176105e95760405251902090565b60405190614da68261107e565b600182527f31000000000000000000000000000000000000000000000000000000000000006020830152565b614de360ff60015460a81c16614138565b337fffffffffffffffffffffffff00000000000000000000000000000000000000005f5416175f55565b9081602091031261031e575161038f8161060c565b6040517f095ea7b3000000000000000000000000000000000000000000000000000000006020820190815273ffffffffffffffffffffffffffffffffffffffff90931660248201527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff60448201525f928392918390614ea481606481016142a8565b51925af1614eb06147ab565b81614f1c575b5015614ebe57565b60646040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152600c60248201527f5361666520417070726f766500000000000000000000000000000000000000006044820152fd5b8051801592508215614f31575b50505f614eb6565b614f449250602080918301019101614e0d565b5f80614f29565b90670de0b6b3a76400009182810292818404149015171561362957565b8181029291811591840414171561362957565b7f7fffffffffffffffffffffffffffffff5d576e7357a4501ddfe92f46681b20a08411614ff8576020935f9360ff60809460405194855216868401526040830152606082015282805260015afa15611f86575f5173ffffffffffffffffffffffffffffffffffffffff811615614ff057905f90565b505f90600190565b505050505f90600390565b6005111561500d57565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52602160045260245ffd5b61504381615003565b8061504b5750565b61505481615003565b600181036150bb576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601860248201527f45434453413a20696e76616c6964207369676e617475726500000000000000006044820152606490fd5b6150c481615003565b6002810361512b576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601f60248201527f45434453413a20696e76616c6964207369676e6174757265206c656e677468006044820152606490fd5b80615137600392615003565b1461513e57565b6040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602260248201527f45434453413a20696e76616c6964207369676e6174757265202773272076616c60448201527f75650000000000000000000000000000000000000000000000000000000000006064820152608490fd5b6151cb6149fa565b908051156148d15773ffffffffffffffffffffffffffffffffffffffff83168015159081615207575b506151fe57505050565b61110492615bf4565b90503014155f6151f4565b61521a6149fa565b91815115613a8f5773ffffffffffffffffffffffffffffffffffffffff9083838383168015159081615276575b50615265575b5050508316801515908161520757506151fe57505050565b61526e92615bf4565b5f838361524d565b90503014155f615247565b6fffffffffffffffffffffffffffffffff9081811161031e571690565b9080601f8301121561031e578151906020916152b981612ec1565b936152c760405195866110b6565b81855260208086019260051b82010192831161031e57602001905b8282106152f0575050505090565b815181529083019083016152e2565b73ffffffffffffffffffffffffffffffffffffffff7f0000000000000000000000000000000000000000000000000000000000000000168061533e5750565b5f6153a2819261536d7f0000000000000000000000000000000000000000000000000000000000000000614c97565b6040519485809481937fbf90f63a000000000000000000000000000000000000000000000000000000008352600483016104f7565b03925af18015611f86576153b35750565b3d805f833e6153c281836110b6565b810160408282031261031e57815167ffffffffffffffff9081811161031e57830182601f8201121561031e5780519060209182806153ff83612ec1565b61540c60405191826110b6565b838152019160051b8301019185831161031e5783809101915b838310615444575050505083015190811161031e57614712920161529e565b81908351615451816105ee565b8152019101908390615425565b6040516154c89173ffffffffffffffffffffffffffffffffffffffff166154848261107e565b5f806020958685527f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c656487860152868151910182855af16154c26147ab565b91615dae565b805190828215928315615565575b505050156154e15750565b608490604051907f08c379a00000000000000000000000000000000000000000000000000000000082526004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e60448201527f6f742073756363656564000000000000000000000000000000000000000000006064820152fd5b6155759350820181019101614e0d565b5f82816154d6565b8160011c906b033b2e3c9fd0803ce80000009081831904811184151761031e5702010490565b6155ab612ce0565b80519081156155bb576020012090565b5050606b5480156155c95790565b507fc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a47090565b6155f6612dc0565b8051908115615606576020012090565b5050606c5480156155c95790565b601f8111615620575050565b60055f527f036b6384b5eca791c62761152d0c79bb0604c104a5fb6f4eb0703f3154bb3db0906020601f840160051c83019310615677575b601f0160051c01905b81811061566c575050565b5f8155600101615661565b9091508190615658565b601f811161568d575050565b606d5f527f5006b838207c6a9ae9b84d68f467dd4bb5c305fbfb6b04eab8faaabeec1e18d8906020601f840160051c830193106156e4575b601f0160051c01905b8181106156d9575050565b5f81556001016156ce565b90915081906156c5565b601f81116156fa575050565b60065f527ff652222313e28459528d920b65115c16c04f3efc82aaedc97be59f3f377c0d3f906020601f840160051c83019310615751575b601f0160051c01905b818110615746575050565b5f815560010161573b565b9091508190615732565b601f8111615767575050565b606e5f527f9930d9ff0dee0ef5ca2f7710ea66b8f84dd0f5f5351ecffe72b952cd9db7142a906020601f840160051c830193106157be575b601f0160051c01905b8181106157b3575050565b5f81556001016157a8565b909150819061579f565b90815167ffffffffffffffff81116105e9576157ee816157e9600654612c8f565b6156ee565b602080601f831160011461584d5750819061583d93945f92615842575b50507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8260011b9260031b1c19161790565b600655565b015190505f8061580b565b907fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe083169461589d60065f527ff652222313e28459528d920b65115c16c04f3efc82aaedc97be59f3f377c0d3f90565b925f905b8782106158f75750508360019596106158c0575b505050811b01600655565b01517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff60f88460031b161c191690555f80806158b5565b806001859682949686015181550195019301906158a1565b90815167ffffffffffffffff81116105e95761593581615930606e54612c8f565b61575b565b602080601f83116001146159885750819061598393945f926158425750507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8260011b9260031b1c19161790565b606e55565b907fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe08316946159d8606e5f527f9930d9ff0dee0ef5ca2f7710ea66b8f84dd0f5f5351ecffe72b952cd9db7142a90565b925f905b878210615a325750508360019596106159fb575b505050811b01606e55565b01517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff60f88460031b161c191690555f80806159f0565b806001859682949686015181550195019301906159dc565b9190600192615a6460ff60015460a81c1661310881614138565b80519067ffffffffffffffff82116105e957615a8a82615a85606d54612c8f565b615681565b602090816001601f851114615af95750615ae7949550918091615adf935f926158425750507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8260011b9260031b1c19161790565b606d5561590f565b615af05f606b55565b6111045f606c55565b606d5f5291957fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe08416907f5006b838207c6a9ae9b84d68f467dd4bb5c305fbfb6b04eab8faaabeec1e18d8935f915b838310615ba95750505095839291600194615ae7979810615b72575b505050811b01606d5561590f565b01517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff60f88460031b161c191690555f8080615b64565b848a01518655988101989485019491810191615b48565b15615bc757565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52600160045260245ffd5b92919092615c2273ffffffffffffffffffffffffffffffffffffffff82168015159081615d8c575b50615bc0565b615c4b8173ffffffffffffffffffffffffffffffffffffffff165f52600260205260405f205490565b5f5b8551811015615d845780615c666128d460019389612f7c565b615c708287612f7c565b51615ca461293d614c70886129138673ffffffffffffffffffffffffffffffffffffffff165f5261019960205260405f2090565b8015615d7d575b86868383148015615d75575b615d6b57615d65946128ee615d29615d23615d1d615ce561291396615cdf614ba69a8c61361c565b90615d97565b615d1861293d6129368a6129138a73ffffffffffffffffffffffffffffffffffffffff165f5261019960205260405f2090565b613bdd565b97615281565b96615281565b615d4c615d346110f7565b6fffffffffffffffffffffffffffffffff9098168852565b6fffffffffffffffffffffffffffffffff166020870152565b01615c4d565b5050505050615d65565b508315615cb7565b5083615cab565b505050509050565b90503014155f615c1c565b670de0b6b3a764000091615daa91614f68565b0490565b91929015615e295750815115615dc2575090565b3b15615dcb5790565b60646040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000006044820152fd5b825190915015615e3c5750805190602001fd5b610bdd906040519182917f08c379a00000000000000000000000000000000000000000000000000000000083526004830161037e56fea2646970667358221220f0d335b4654b144b7ec7bd281fd9c29788052bc1b59cd60ba5513d7f2f50e6df64736f6c6343000818003300000000000000000000000000a89d7a5a02160f20150ebea7a2b5e4879a1a8b0000000000000000000000000d745eaa9e70bb8b6e2a0317f85f1d536616bd3400000000000000000000000000000000000000000000000000000000000000000000000000000000000000005555555555555555555555555555555555555555000000000000000000000000eea6f790f18563e91b18df00b89d9f79b2e6761f
Deployed Bytecode
0x6080604052600436101561001a575b3615610018575f80fd5b005b5f3560e01c806306fdde031461030f578063071bc3c9146102f1578063078dfbe71461030a578063095ea7b314610305578063128fced11461030057806318160ddd146102fb57806320e8c565146102f6578063213cae63146102f157806323b872dd146102ec578063313ce567146102e75780633644e515146102e25780633ba0b9a9146102dd5780633f4ba83a146102d85780634cd88b76146102d35780634e71e0c8146102ce5780635b9fe37f146102c95780635c975abb146102c45780635cbadbe4146102bf5780636f307dc3146102ba57806370a08231146102b5578063769f8e5d146102b057806376d5de85146102ab578063784367d6146102335780637ecebe00146102a65780638456cb59146102a157806384b0196e1461029c5780638b8fa807146102975780638da5cb5b1461029257806395d89b411461028d578063a03e4bc314610288578063a0c1f15e14610283578063a40bee501461027e578063a9059cbb14610279578063a9f8d18114610274578063b8f82b261461026f578063c4f59f9b1461026a578063c8b5a95714610265578063cbe52ae314610260578063cf2fa5761461025b578063d505accf14610256578063da88ecb414610251578063dd62ed3e1461024c578063e30c397814610247578063ea64a82014610242578063ef5cfb8c1461023d578063f8b2f99114610238578063fa5a4f06146102335763ff3a4ac00361000e57612c21565b611952565b612b1c565b6127ca565b612740565b6126ef565b61268f565b6125c0565b6123e2565b61238b565b6122d9565b612231565b612192565b6120bd565b612081565b611f8b565b611e6b565b611dfd565b611d8f565b611ccc565b611c7c565b611c0e565b611b3d565b611a08565b6119a1565b6118e4565b6116d5565b611670565b611602565b61157a565b6114f6565b611488565b611346565b611186565b610f31565b610eeb565b610eab565b610e50565b610c54565b610508565b6109f4565b610998565b6108a3565b61080c565b610616565b610392565b5f91031261031e57565b5f80fd5b91908251928382525f5b84811061036a5750507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0601f845f6020809697860101520116010190565b60208183018101518483018201520161032c565b90602061038f928181520190610322565b90565b3461031e575f7ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc36011261031e576040515f6005546103d081612c8f565b80845290602090600190818116908115610466575060011461040d575b610409856103fd818703826110b6565b6040519182918261037e565b0390f35b60055f90815293507f036b6384b5eca791c62761152d0c79bb0604c104a5fb6f4eb0703f3154bb3db05b838510610453575050505081016020016103fd826104096103ed565b8054868601840152938201938101610437565b869550610409969350602092506103fd9491507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff001682840152151560051b82010192936103ed565b9081518082526020808093019301915f5b8281106104cd575050505090565b835173ffffffffffffffffffffffffffffffffffffffff16855293810193928101926001016104bf565b90602061038f9281815201906104ae565b3461031e575f7ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc36011261031e576040516060810181811067ffffffffffffffff8211176105e95760405260028152602081019060403683378051156105e45773ffffffffffffffffffffffffffffffffffffffff91827f00000000000000000000000055555555555555555555555555555555555555551690528051600110156105e457610409917f0000000000000000000000000d745eaa9e70bb8b6e2a0317f85f1d536616bd34166040820152604051918291826104f7565b612f4f565b61103d565b73ffffffffffffffffffffffffffffffffffffffff81160361031e57565b8015150361031e57565b3461031e5760607ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc36011261031e57600435610651816105ee565b6024359061065e8261060c565b6044359161066b8361060c565b73ffffffffffffffffffffffffffffffffffffffff9061068f825f54163314612e5c565b156107dc578116918215908115916107d4575b501561077657610749916106e66106cd5f5473ffffffffffffffffffffffffffffffffffffffff1690565b73ffffffffffffffffffffffffffffffffffffffff1690565b7f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e05f80a373ffffffffffffffffffffffffffffffffffffffff167fffffffffffffffffffffffff00000000000000000000000000000000000000005f5416175f55565b6100187fffffffffffffffffffffffff000000000000000000000000000000000000000060015416600155565b60646040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601560248201527f4f776e61626c653a207a65726f206164647265737300000000000000000000006044820152fd5b90505f6106a2565b9150167fffffffffffffffffffffffff000000000000000000000000000000000000000060015416176001555f80f35b3461031e5760407ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc36011261031e5761085460043561084a816105ee565b6024359033613867565b602060405160018152f35b9081518082526020808093019301915f5b82811061087e575050505090565b835185529381019392810192600101610870565b90602061038f92818152019061085f565b3461031e576020807ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc36011261031e576004356108df816105ee565b6109087f0000000000000000000000005555555555555555555555555555555555555555614c97565b906109138251612f00565b925f5b835181101561098a578073ffffffffffffffffffffffffffffffffffffffff61094160019387612f7c565b51165f5261019983526109758460405f209073ffffffffffffffffffffffffffffffffffffffff165f5260205260405f2090565b5460801c6109838288612f7c565b5201610916565b604051806104098782610892565b3461031e575f7ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc36011261031e5760207effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff60045416604051908152f35b60807ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc36011261031e57600435610a2a816105ee565b60243590610a37826105ee565b6044359060643592610a51600260045460f81c1415612f90565b610a9f7f02000000000000000000000000000000000000000000000000000000000000007effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff6004541617600455565b610aaf610aab82613313565b1590565b610c0b578215610be157610ac48333836139ff565b610ace8382613aef565b92848410610b9f576104099450610ae58484613bea565b7f5fe47ed6d4225326d3303476197d782ded5a4e9c14f479dc9ec4992af4e85d5973ffffffffffffffffffffffffffffffffffffffff80604051941694169280610b3e8733958360209093929193604081019481520152565b0390a4610b8f7f01000000000000000000000000000000000000000000000000000000000000007effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff6004541617600455565b6040519081529081906020820190565b50506040517fbc71f2ba0000000000000000000000000000000000000000000000000000000081526004810192909252506024810191909152604490fd5b0390fd5b60046040517fa907f2f0000000000000000000000000000000000000000000000000000000008152fd5b6040517faeabe71800000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff919091166004820152602490fd5b3461031e5760607ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc36011261031e57600435610c8f816105ee565b602435610c9b816105ee565b60443590610cb1600260045460f81c1415612f90565b610cff7f02000000000000000000000000000000000000000000000000000000000000007effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff6004541617600455565b73ffffffffffffffffffffffffffffffffffffffff83165f526003602052610d483360405f209073ffffffffffffffffffffffffffffffffffffffff165f5260205260405f2090565b54927fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8403610dd6575b610d7c9350613ee9565b610dca7f01000000000000000000000000000000000000000000000000000000000000007effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff6004541617600455565b60405160018152602090f35b828410610df257610ded83610d7c95033383613867565b610d72565b60646040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601d60248201527f45524332303a20696e73756666696369656e7420616c6c6f77616e63650000006044820152fd5b3461031e575f7ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc36011261031e57602060405160ff7f0000000000000000000000000000000000000000000000000000000000000012168152f35b3461031e575f7ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc36011261031e576020610ee3614d23565b604051908152f35b3461031e575f7ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc36011261031e576020633b9aca00610f2861406f565b04604051908152f35b3461031e575f7ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc36011261031e57610f8173ffffffffffffffffffffffffffffffffffffffff5f54163314612e5c565b610134805460ff811615610fdf577fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff001690557f5db9ee0a495bf2e6ff9c91a7834c1ba4fdd244a5e8aa4e537bd38aeae4b073aa6020604051338152a1005b60646040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601460248201527f5061757361626c653a206e6f74207061757365640000000000000000000000006044820152fd5b7f4e487b71000000000000000000000000000000000000000000000000000000005f52604160045260245ffd5b67ffffffffffffffff81116105e957604052565b6040810190811067ffffffffffffffff8211176105e957604052565b60a0810190811067ffffffffffffffff8211176105e957604052565b90601f7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0910116810190811067ffffffffffffffff8211176105e957604052565b604051906111048261107e565b565b67ffffffffffffffff81116105e957601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe01660200190565b81601f8201121561031e5780359061115782611106565b9261116560405194856110b6565b8284526020838301011161031e57815f926020809301838601378301015290565b3461031e5760407ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc36011261031e5767ffffffffffffffff60043581811161031e576111d6903690600401611140565b9060243590811161031e576111f2611265913690600401611140565b6001549261121760ff8560a81c161580958196611334575b8115611311575b50613059565b8361125c740100000000000000000000000000000000000000007fffffffffffffffffffffff00ffffffffffffffffffffffffffffffffffffffff6001541617600155565b6112c7576130e4565b61126b57005b6112987fffffffffffffffffffff00ffffffffffffffffffffffffffffffffffffffffff60015416600155565b604051600181527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb384740249890602090a1005b61130c75010000000000000000000000000000000000000000007fffffffffffffffffffff00ffffffffffffffffffffffffffffffffffffffffff6001541617600155565b6130e4565b303b15915081611323575b505f611211565b60a01c60ff1660011490505f61131c565b9050600160ff8260a01c16109061120a565b3461031e575f7ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc36011261031e5773ffffffffffffffffffffffffffffffffffffffff806001541680330361142a5780611400925f54167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e05f80a373ffffffffffffffffffffffffffffffffffffffff167fffffffffffffffffffffffff00000000000000000000000000000000000000005f5416175f55565b600180547fffffffffffffffffffffffff0000000000000000000000000000000000000000169055005b60646040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602060248201527f4f776e61626c653a2063616c6c657220213d2070656e64696e67206f776e65726044820152fd5b3461031e575f7ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc36011261031e57602060405173ffffffffffffffffffffffffffffffffffffffff7f0000000000000000000000000000000000000000000000000000000000000000168152f35b3461031e575f7ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc36011261031e57602060ff61013454166040519015158152f35b7ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc604091011261031e5760043561156d816105ee565b9060243561038f816105ee565b3461031e576104096115d473ffffffffffffffffffffffffffffffffffffffff6115a336611537565b91165f5261019960205260405f209073ffffffffffffffffffffffffffffffffffffffff165f5260205260405f2090565b54604080516fffffffffffffffffffffffffffffffff8316815260809290921c602083015290918291820190565b3461031e575f7ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc36011261031e57602060405173ffffffffffffffffffffffffffffffffffffffff7f0000000000000000000000005555555555555555555555555555555555555555168152f35b3461031e5760207ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc36011261031e576020610ee36004356116b0816105ee565b73ffffffffffffffffffffffffffffffffffffffff165f52600260205260405f205490565b3461031e5760a07ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc36011261031e57600435611710816105ee565b60243560443591611720836105ee565b606435926084356117308161060c565b611742600260045460f81c1415612f90565b6117907f02000000000000000000000000000000000000000000000000000000000000007effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff6004541617600455565b61179c610aab83613313565b61189d5783156118735715611864576117b5833061446f565b6117c0838284614600565b928484106118265761040994507faee47cdf925cf525fdae94f9777ee5a06cac37e1c41220d0a8a89ed154f62d1c73ffffffffffffffffffffffffffffffffffffffff80604051941694169280610b3e8733958360209093929193604081019481520152565b50506040517fbfee4ca00000000000000000000000000000000000000000000000000000000081526004810192909252506024810191909152604490fd5b61186e833361446f565b6117b5565b60046040517fc3d83b07000000000000000000000000000000000000000000000000000000008152fd5b6040517f88a5056100000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff83166004820152602490fd5b3461031e575f7ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc36011261031e57602060405173ffffffffffffffffffffffffffffffffffffffff7f0000000000000000000000000d745eaa9e70bb8b6e2a0317f85f1d536616bd34168152f35b3461031e5760207ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc36011261031e576020611997600435611992816105ee565b613313565b6040519015158152f35b3461031e5760207ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc36011261031e5773ffffffffffffffffffffffffffffffffffffffff6004356119f1816105ee565b165f52609f602052602060405f2054604051908152f35b3461031e575f7ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc36011261031e57611a5873ffffffffffffffffffffffffffffffffffffffff5f54163314612e5c565b611a6061492e565b61013460017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff008254161790557f62e78cea01bee320cd4e420270b5ea74000d11b0c9f74754ebdbfc544b05a2586020604051338152a1005b9193611b1e61038f969495611b1073ffffffffffffffffffffffffffffffffffffffff947f0f00000000000000000000000000000000000000000000000000000000000000875260e0602088015260e0870190610322565b908582036040870152610322565b9460608401521660808201525f60a082015260c081840391015261085f565b3461031e575f7ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc36011261031e57606b541580611c04575b15611ba657611b82612ce0565b611b8a612dc0565b90610409611b96612ed9565b6040519384933091469186611ab8565b60646040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601560248201527f4549503731323a20556e696e697469616c697a656400000000000000000000006044820152fd5b50606c5415611b75565b3461031e575f7ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc36011261031e57602060405173ffffffffffffffffffffffffffffffffffffffff7f000000000000000000000000eea6f790f18563e91b18df00b89d9f79b2e6761f168152f35b3461031e575f7ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc36011261031e57602073ffffffffffffffffffffffffffffffffffffffff5f5416604051908152f35b3461031e575f7ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc36011261031e576040515f600654611d0a81612c8f565b808452906020906001908181169081156104665750600114611d3657610409856103fd818703826110b6565b60065f90815293507ff652222313e28459528d920b65115c16c04f3efc82aaedc97be59f3f377c0d3f5b838510611d7c575050505081016020016103fd826104096103ed565b8054868601840152938201938101611d60565b3461031e575f7ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc36011261031e57602060405173ffffffffffffffffffffffffffffffffffffffff7f00000000000000000000000000a89d7a5a02160f20150ebea7a2b5e4879a1a8b168152f35b3461031e575f7ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc36011261031e57602060405173ffffffffffffffffffffffffffffffffffffffff7f0000000000000000000000000d745eaa9e70bb8b6e2a0317f85f1d536616bd34168152f35b3461031e575f7ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc36011261031e576040517f313ce5670000000000000000000000000000000000000000000000000000000081527f000000000000000000000000555555555555555555555555555555555555555560208260048173ffffffffffffffffffffffffffffffffffffffff85165afa918215611f86575f92611f49575b506104096040519283928390929160ff60409173ffffffffffffffffffffffffffffffffffffffff60608501965f865216602085015216910152565b9091506020813d602011611f7e575b81611f65602093836110b6565b8101031261031e5751611f77816123d7565b905f611f0d565b3d9150611f58565b613384565b3461031e5760407ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc36011261031e57612033600435611fc9816105ee565b611fdb600260045460f81c1415612f90565b6120297f02000000000000000000000000000000000000000000000000000000000000007effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff6004541617600455565b6024359033613ee9565b6108547f01000000000000000000000000000000000000000000000000000000000000007effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff6004541617600455565b3461031e575f7ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc36011261031e57602061019a54604051908152f35b3461031e5760407ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc36011261031e576004356120f8816105ee565b6024359061210581613313565b1561214b575061211361406f565b908160011c6b033b2e3c9fd0803ce80000009283821904831181151761031e5761040991604051948594020104829190602083019252565b60249073ffffffffffffffffffffffffffffffffffffffff604051917faeabe718000000000000000000000000000000000000000000000000000000008352166004820152fd5b3461031e575f7ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc36011261031e576104096121ec7f0000000000000000000000005555555555555555555555555555555555555555614c97565b6040519182916020835260208301906104ae565b9181601f8401121561031e5782359167ffffffffffffffff831161031e576020808501948460051b01011161031e57565b3461031e5760807ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc36011261031e5767ffffffffffffffff60043581811161031e57612281903690600401612200565b9060243583811161031e5761229a903690600401612200565b9060443585811161031e576122b3903690600401612200565b92909160643596871161031e576122d1610018973690600401612200565b96909561362e565b3461031e5760407ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc36011261031e57600435612314816105ee565b61231d81613313565b156123445760206b033b2e3c9fd0803ce8000000610f2861233c61406f565b602435614f68565b60249073ffffffffffffffffffffffffffffffffffffffff604051917f88a50561000000000000000000000000000000000000000000000000000000008352166004820152fd5b3461031e575f7ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc36011261031e576020604051733ef3d8ba38ebe18db133cec108f4d14ce00dd9ae8152f35b60ff81160361031e57565b3461031e5760e07ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc36011261031e5760043561241d816105ee565b602435612429816105ee565b60443590606435926084359361243e856123d7565b8042116125625761253d61255d916124f9610018976125256124878773ffffffffffffffffffffffffffffffffffffffff165f52609f60205260405f2090815491600183019055565b9360405193849160208301968c8c8c8a91959493909260a09360c08401977f6e71edae12b1b97f4d1f60370fef10105fa2faae0126114a169c64845d6126c9855273ffffffffffffffffffffffffffffffffffffffff8092166020860152166040840152606083015260808201520152565b037fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe081018452836110b6565b61253860c4359360a435935190206148d6565b614917565b73ffffffffffffffffffffffffffffffffffffffff8084169116146137dd565b613867565b60646040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601d60248201527f45524332305065726d69743a206578706972656420646561646c696e650000006044820152fd5b3461031e575f7ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc36011261031e576126177f0000000000000000000000005555555555555555555555555555555555555555614c97565b6126218151612f00565b905f5b8151811015612681578073ffffffffffffffffffffffffffffffffffffffff61264f60019385612f7c565b51165f5261019b6020526fffffffffffffffffffffffffffffffff60405f20541661267a8286612f7c565b5201612624565b604051806104098582610892565b3461031e5760206126e673ffffffffffffffffffffffffffffffffffffffff6126b736611537565b91165f526003835260405f209073ffffffffffffffffffffffffffffffffffffffff165f5260205260405f2090565b54604051908152f35b3461031e575f7ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc36011261031e57602073ffffffffffffffffffffffffffffffffffffffff60015416604051908152f35b3461031e5760207ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc36011261031e5773ffffffffffffffffffffffffffffffffffffffff600435612790816105ee565b165f90815261019b60209081526040918290205482516fffffffffffffffffffffffffffffffff8216815260809190911c91810191909152f35b3461031e5760207ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc36011261031e57600435612805816105ee565b612817600260045460f81c1415612f90565b6128657f02000000000000000000000000000000000000000000000000000000000000007effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff6004541617600455565b61286d61492e565b612876816151c3565b7f00000000000000000000000055555555555555555555555555555555555555556128a081614c97565b916128ab8351612f00565b925f5b8151811015612a68578061295261293d612936866129136128ee6128d46001988a612f7c565b5173ffffffffffffffffffffffffffffffffffffffff1690565b73ffffffffffffffffffffffffffffffffffffffff165f5261019960205260405f2090565b9073ffffffffffffffffffffffffffffffffffffffff165f5260205260405f2090565b5460801c90565b6fffffffffffffffffffffffffffffffff1690565b61295c8288612f7c565b526129678187612f7c565b51612973575b016128ae565b6129a261298a856129136128ee6128d48689612f7c565b6fffffffffffffffffffffffffffffffff8154169055565b612a416129b86129b28389612f7c565b51615281565b612a016129f06129cb6128d48689612f7c565b73ffffffffffffffffffffffffffffffffffffffff165f5261019b60205260405f2090565b916129fc835460801c90565b614999565b6fffffffffffffffffffffffffffffffff7fffffffffffffffffffffffffffffffff0000000000000000000000000000000083549260801b169116179055565b612a63612a516128d48386612f7c565b85612a5c848a612f7c565b51916147da565b61296d565b61040985847f2193aa20a3717f5f4ac79482f4f553e5f0afe8f4e6ec3e3d1aa2e138adc4763f73ffffffffffffffffffffffffffffffffffffffff612aac89614c97565b92612abf85604051938493169583613842565b0390a2612b107f01000000000000000000000000000000000000000000000000000000000000007effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff6004541617600455565b60405191829182610892565b3461031e575f7ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc36011261031e57612b5c600260045460f81c1415612f90565b612baa7f02000000000000000000000000000000000000000000000000000000000000007effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff6004541617600455565b612bb261492e565b610409612bbd6149fa565b9050612c0d7f01000000000000000000000000000000000000000000000000000000000000007effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff6004541617600455565b60405191829160208352602083019061085f565b3461031e575f7ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc36011261031e57602060405173ffffffffffffffffffffffffffffffffffffffff7f0000000000000000000000005555555555555555555555555555555555555555168152f35b90600182811c92168015612cd6575b6020831014612ca957565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52602260045260245ffd5b91607f1691612c9e565b604051905f82606d5491612cf383612c8f565b80835292602090600190818116908115612d7d5750600114612d1e575b5050611104925003836110b6565b915092606d5f527f5006b838207c6a9ae9b84d68f467dd4bb5c305fbfb6b04eab8faaabeec1e18d8935f925b828410612d6557506111049450505081016020015f80612d10565b85548885018301529485019487945092810192612d4a565b9050602093506111049592507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0091501682840152151560051b8201015f80612d10565b604051905f82606e5491612dd383612c8f565b80835292602090600190818116908115612d7d5750600114612dfd575050611104925003836110b6565b915092606e5f527f9930d9ff0dee0ef5ca2f7710ea66b8f84dd0f5f5351ecffe72b952cd9db7142a935f925b828410612e4457506111049450505081016020015f80612d10565b85548885018301529485019487945092810192612e29565b15612e6357565b60646040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602060248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152fd5b67ffffffffffffffff81116105e95760051b60200190565b6040516020810181811067ffffffffffffffff8211176105e9576040525f8152905f368137565b90612f0a82612ec1565b612f1760405191826110b6565b8281527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0612f458294612ec1565b0190602036910137565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52603260045260245ffd5b80518210156105e45760209160051b010190565b15612f9757565b60646040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c006044820152fd5b7f4e487b71000000000000000000000000000000000000000000000000000000005f52601160045260245ffd5b811561302c570490565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52601260045260245ffd5b1561306057565b60846040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201527f647920696e697469616c697a65640000000000000000000000000000000000006064820152fd5b91909160019261310d60ff60015460a81c166130ff81614138565b61310881614138565b614138565b815167ffffffffffffffff81116105e9576131328161312d600554612c8f565b615614565b602094856001601f84111461324a5750509061318982613191936131ed96975f9161323f575b507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8260011b9260031b1c19161790565b6005556157c8565b6131df7f01000000000000000000000000000000000000000000000000000000000000007effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff6004541617600455565b6131e7614d99565b90615a4a565b6131f5614dd2565b6111047f00000000000000000000000000a89d7a5a02160f20150ebea7a2b5e4879a1a8b7f00000000000000000000000055555555555555555555555555555555555555556141c3565b90508501515f613158565b60055f5295907fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe08316907f036b6384b5eca791c62761152d0c79bb0604c104a5fb6f4eb0703f3154bb3db0975f915b8383106132fc57505050916131ed9596600192826131919695106132c5575b5050811b016005556157c8565b8601517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff60f88460031b161c191690555f806132b8565b878501518a55988901989381019391810191613299565b73ffffffffffffffffffffffffffffffffffffffff809116817f0000000000000000000000000d745eaa9e70bb8b6e2a0317f85f1d536616bd3416811491821561335c57505090565b7f00000000000000000000000055555555555555555555555555555555555555551614919050565b6040513d5f823e3d90fd5b1561339657565b60646040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601d60248201527f50656e646c65416176654d657269743a20756e617574686f72697a65640000006044820152fd5b90156105e45790565b91908110156105e45760051b0190565b3561038f816105ee565b1561341e57565b60646040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601e60248201527f50656e646c65416176654d657269743a20696e76616c696420757365727300006044820152fd5b9190808252602080920192915f5b828110613498575050505090565b90919293828060019273ffffffffffffffffffffffffffffffffffffffff88356134c1816105ee565b1681520195019392910161348a565b90918281527f07ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff831161031e5760209260051b809284830137010190565b9795919361352d61353d9261354b9697959760808c5260808c019161347c565b906020968a8303888c015261347c565b9187830360408901526134d0565b936060818603910152818452808401936005828460051b83010195855f935b86851061357c57505050505050505090565b90919293949596977fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe082820301845288357fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe18436030181121561031e57830187810191903567ffffffffffffffff811161031e5780871b3603831361031e5761360a899283926001956134d0565b9a01940195019392969594919061356a565b9190820391821161362957565b612ff5565b939194959690967f000000000000000000000000eea6f790f18563e91b18df00b89d9f79b2e6761f9473ffffffffffffffffffffffffffffffffffffffff9861367a8a8816331461338f565b61369160019a6001831490816137c5575b50613417565b61369a86612f00565b988a5f5b8b898c8184106137a1575050505050733ef3d8ba38ebe18db133cec108f4d14ce00dd9ae92833b1561031e5761370b5f968b9688948b9a6040519b8c9a8b998a987f71ee95c0000000000000000000000000000000000000000000000000000000008a5260048a0161350d565b03925af18015611f8657613788575b505f5b81811061372c57505050505050565b8061375d61374c6137476137428a95878a6133fd565b61340d565b614742565b6137568389612f7c565b519061361c565b8061376a575b500161371d565b613782908561377d61374285888b6133fd565b6147da565b5f613763565b8061379561379b9261106a565b80610314565b5f61371a565b6137b6613747613742866137bc9581956133fd565b92612f7c565b52018b9061369e565b90506137d461374284866133f4565b1630145f61368b565b156137e457565b60646040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601e60248201527f45524332305065726d69743a20696e76616c6964207369676e617475726500006044820152fd5b909161385961038f936040845260408401906104ae565b91602081840391015261085f565b9073ffffffffffffffffffffffffffffffffffffffff9182811692831561397c5782169384156138f857806138e27f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925946129136138f39573ffffffffffffffffffffffffffffffffffffffff165f52600360205260405f2090565b556040519081529081906020820190565b0390a3565b60846040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602260248201527f45524332303a20617070726f766520746f20746865207a65726f20616464726560448201527f73730000000000000000000000000000000000000000000000000000000000006064820152fd5b60846040517f08c379a0000000000000000000000000000000000000000000000000000000008152602060048201526024808201527f45524332303a20617070726f76652066726f6d20746865207a65726f2061646460448201527f72657373000000000000000000000000000000000000000000000000000000006064820152fd5b73ffffffffffffffffffffffffffffffffffffffff9190821680613a86575050503403613a2857565b60646040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152600c60248201527f657468206d69736d6174636800000000000000000000000000000000000000006044820152fd5b90919280613a95575b50505050565b613ae693604051937f23b872dd000000000000000000000000000000000000000000000000000000006020860152166024840152306044840152606483015260648252613ae18261109a565b61545e565b5f808080613a8f565b73ffffffffffffffffffffffffffffffffffffffff7f00000000000000000000000055555555555555555555555555555555555555558116929181168314613b46575b5061038f9150613b4061406f565b9061557d565b7f00000000000000000000000000a89d7a5a02160f20150ebea7a2b5e4879a1a8b1691823b1561031e575f926084849260405195869384927f617ba03700000000000000000000000000000000000000000000000000000000845260048401528660248401523060448401528160648401525af1918215611f865761038f9215613b325780613795613bd79261106a565b5f613b32565b9190820180921161362957565b9073ffffffffffffffffffffffffffffffffffffffff8216918215613d1057613c1161492e565b613c1a816151c3565b613c2382614cf7565b907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff91828060045416911601918211613629575f92613cf36138f392613ccf7fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef957effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff167fff000000000000000000000000000000000000000000000000000000000000006004541617600455565b73ffffffffffffffffffffffffffffffffffffffff165f52600260205260405f2090565b613cfe828254613bdd565b90556040519081529081906020820190565b60646040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601f60248201527f45524332303a206d696e7420746f20746865207a65726f2061646472657373006044820152fd5b15613d7557565b60846040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602360248201527f45524332303a207472616e7366657220746f20746865207a65726f206164647260448201527f65737300000000000000000000000000000000000000000000000000000000006064820152fd5b15613e0057565b60646040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601760248201527f45524332303a207472616e7366657220746f2073656c660000000000000000006044820152fd5b15613e6557565b60846040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602660248201527f45524332303a207472616e7366657220616d6f756e742065786365656473206260448201527f616c616e636500000000000000000000000000000000000000000000000000006064820152fd5b919073ffffffffffffffffffffffffffffffffffffffff90818416928315613fdc57613cf3827fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef946138f3941696613f42881515613d6e565b613f4e88881415613df9565b613f588282614ce5565b613fb784613f848373ffffffffffffffffffffffffffffffffffffffff165f52600260205260405f2090565b54613f9182821015613e5e565b039173ffffffffffffffffffffffffffffffffffffffff165f52600260205260405f2090565b5573ffffffffffffffffffffffffffffffffffffffff165f52600260205260405f2090565b60846040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602560248201527f45524332303a207472616e736665722066726f6d20746865207a65726f20616460448201527f64726573730000000000000000000000000000000000000000000000000000006064820152fd5b9081602091031261031e575190565b6024602073ffffffffffffffffffffffffffffffffffffffff604051928380927fd15e0053000000000000000000000000000000000000000000000000000000008252807f00000000000000000000000055555555555555555555555555555555555555551660048301527f00000000000000000000000000a89d7a5a02160f20150ebea7a2b5e4879a1a8b165afa908115611f86575f9161410f575090565b61038f915060203d602011614131575b61412981836110b6565b810190614060565b503d61411f565b1561413f57565b60846040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602b60248201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960448201527f6e697469616c697a696e670000000000000000000000000000000000000000006064820152fd5b919073ffffffffffffffffffffffffffffffffffffffff928381169384156143ac576040519485917fdd62ed3e0000000000000000000000000000000000000000000000000000000083523060048401528416602483015281604460209788935afa8015611f86576b7fffffffffffffffffffffff915f9161438f575b501061424d575b50509050565b6040517f095ea7b30000000000000000000000000000000000000000000000000000000085820190815273ffffffffffffffffffffffffffffffffffffffff841660248301525f60448301819052918291906142d481606481015b037fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe081018352826110b6565b519082855af16142e26147ab565b8161435f575b5015614301576142f9929350614e22565b805f80614247565b606484604051907f08c379a00000000000000000000000000000000000000000000000000000000082526004820152600c60248201527f5361666520417070726f766500000000000000000000000000000000000000006044820152fd5b80518015925086908315614377575b5050505f6142e8565b6143879350820181019101614e0d565b5f858161436e565b6143a69150863d88116141315761412981836110b6565b5f614240565b5050509050565b156143ba57565b60846040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602260248201527f45524332303a206275726e20616d6f756e7420657863656564732062616c616e60448201527f63650000000000000000000000000000000000000000000000000000000000006064820152fd5b7effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff918216908216039190821161362957565b9073ffffffffffffffffffffffffffffffffffffffff821690811561457c576138f37fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef91846144be5f96614cd4565b6144f7826144ea8373ffffffffffffffffffffffffffffffffffffffff165f52600260205260405f2090565b54613f91828210156143b3565b55610b8f61453061450783614cf7565b6004547effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1661443e565b7effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff167fff000000000000000000000000000000000000000000000000000000000000006004541617600455565b60846040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602160248201527f45524332303a206275726e2066726f6d20746865207a65726f2061646472657360448201527f73000000000000000000000000000000000000000000000000000000000000006064820152fd5b9092916146226b033b2e3c9fd0803ce80000009161461c61406f565b90614f68565b0492837f000000000000000000000000555555555555555555555555555555555555555573ffffffffffffffffffffffffffffffffffffffff92838083169116145f14614715576040517f69328dec00000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff91821660048201526024810192909252929092166044830152602090829060649082905f907f00000000000000000000000000a89d7a5a02160f20150ebea7a2b5e4879a1a8b165af18015611f86576146fa5750565b6147129060203d6020116141315761412981836110b6565b50565b509050611104917f0000000000000000000000000d745eaa9e70bb8b6e2a0317f85f1d536616bd346147da565b73ffffffffffffffffffffffffffffffffffffffff168061476257504790565b6020602491604051928380927f70a082310000000000000000000000000000000000000000000000000000000082523060048301525afa908115611f86575f9161410f575b5090565b3d156147d5573d906147bc82611106565b916147ca60405193846110b6565b82523d5f602084013e565b606090565b82156148d15773ffffffffffffffffffffffffffffffffffffffff168061487257505f80809381935af161480c6147ab565b501561481457565b60646040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152600f60248201527f6574682073656e64206661696c656400000000000000000000000000000000006044820152fd5b6040517fa9059cbb00000000000000000000000000000000000000000000000000000000602082015273ffffffffffffffffffffffffffffffffffffffff9092166024830152604482019290925261110491613ae182606481016124f9565b505050565b6042906148e1614d23565b90604051917f19010000000000000000000000000000000000000000000000000000000000008352600283015260228201522090565b9161038f939161492693614f7b565b91909161503a565b60ff610134541661493b57565b60646040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601060248201527f5061757361626c653a20706175736564000000000000000000000000000000006044820152fd5b6fffffffffffffffffffffffffffffffff918216908216039190821161362957565b906040516040810181811067ffffffffffffffff8211176105e95760405291546fffffffffffffffffffffffffffffffff8116835260801c6020830152565b614a237f0000000000000000000000005555555555555555555555555555555555555555614c97565b90614a2e8251612f00565b908251156111045761019a544314614c4b5790614a4b4361019a55565b7effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff6004541690614a786152ff565b811515915f5b8551811015614c445780614a976128d460019389612f7c565b87614ac9614ac48373ffffffffffffffffffffffffffffffffffffffff165f5261019b60205260405f2090565b6149bb565b602092614b32614b05614aee868501516fffffffffffffffffffffffffffffffff1690565b93516fffffffffffffffffffffffffffffffff1690565b614b2d6137476128d4896fffffffffffffffffffffffffffffffff8098169788951698612f7c565b61361c565b93878a8515614c3c575b614c01575b50906129cb614ba692614b69614b648798614b5e614bf099615281565b97613bdd565b615281565b90614b8d614b756110f7565b6fffffffffffffffffffffffffffffffff9097168752565b8501906fffffffffffffffffffffffffffffffff169052565b815160209092015160801b7fffffffffffffffffffffffffffffffff00000000000000000000000000000000166fffffffffffffffffffffffffffffffff92909216919091179055565b614bfa8286612f7c565b5201614a7e565b614ba69291614b69614b64614c2e614bf098614c286129cb96614c238d614f4b565b613022565b90613bdd565b975050509192505087614b41565b889550614b3c565b5050919050565b905f5b83518110156147a75780614c8661293d614c706129cb6128d46001968a612f7c565b546fffffffffffffffffffffffffffffffff1690565b614c908285612f7c565b5201614c4e565b9060405191614ca58361107e565b60018352602083019060203683378351156105e45773ffffffffffffffffffffffffffffffffffffffff169052565b61110490614ce061492e565b6151c3565b9061110491614cf261492e565b615212565b7effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff9081811161031e571690565b614d2b6155a3565b614d336155ee565b6040519060208201927f8b73c3c69bb8fe3d512ecc4cf759cc79239f7b179b0ffacaa9a75d522b39400f8452604083015260608201524660808201523060a082015260a0815260c0810181811067ffffffffffffffff8211176105e95760405251902090565b60405190614da68261107e565b600182527f31000000000000000000000000000000000000000000000000000000000000006020830152565b614de360ff60015460a81c16614138565b337fffffffffffffffffffffffff00000000000000000000000000000000000000005f5416175f55565b9081602091031261031e575161038f8161060c565b6040517f095ea7b3000000000000000000000000000000000000000000000000000000006020820190815273ffffffffffffffffffffffffffffffffffffffff90931660248201527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff60448201525f928392918390614ea481606481016142a8565b51925af1614eb06147ab565b81614f1c575b5015614ebe57565b60646040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152600c60248201527f5361666520417070726f766500000000000000000000000000000000000000006044820152fd5b8051801592508215614f31575b50505f614eb6565b614f449250602080918301019101614e0d565b5f80614f29565b90670de0b6b3a76400009182810292818404149015171561362957565b8181029291811591840414171561362957565b7f7fffffffffffffffffffffffffffffff5d576e7357a4501ddfe92f46681b20a08411614ff8576020935f9360ff60809460405194855216868401526040830152606082015282805260015afa15611f86575f5173ffffffffffffffffffffffffffffffffffffffff811615614ff057905f90565b505f90600190565b505050505f90600390565b6005111561500d57565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52602160045260245ffd5b61504381615003565b8061504b5750565b61505481615003565b600181036150bb576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601860248201527f45434453413a20696e76616c6964207369676e617475726500000000000000006044820152606490fd5b6150c481615003565b6002810361512b576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601f60248201527f45434453413a20696e76616c6964207369676e6174757265206c656e677468006044820152606490fd5b80615137600392615003565b1461513e57565b6040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602260248201527f45434453413a20696e76616c6964207369676e6174757265202773272076616c60448201527f75650000000000000000000000000000000000000000000000000000000000006064820152608490fd5b6151cb6149fa565b908051156148d15773ffffffffffffffffffffffffffffffffffffffff83168015159081615207575b506151fe57505050565b61110492615bf4565b90503014155f6151f4565b61521a6149fa565b91815115613a8f5773ffffffffffffffffffffffffffffffffffffffff9083838383168015159081615276575b50615265575b5050508316801515908161520757506151fe57505050565b61526e92615bf4565b5f838361524d565b90503014155f615247565b6fffffffffffffffffffffffffffffffff9081811161031e571690565b9080601f8301121561031e578151906020916152b981612ec1565b936152c760405195866110b6565b81855260208086019260051b82010192831161031e57602001905b8282106152f0575050505090565b815181529083019083016152e2565b73ffffffffffffffffffffffffffffffffffffffff7f0000000000000000000000000000000000000000000000000000000000000000168061533e5750565b5f6153a2819261536d7f0000000000000000000000000d745eaa9e70bb8b6e2a0317f85f1d536616bd34614c97565b6040519485809481937fbf90f63a000000000000000000000000000000000000000000000000000000008352600483016104f7565b03925af18015611f86576153b35750565b3d805f833e6153c281836110b6565b810160408282031261031e57815167ffffffffffffffff9081811161031e57830182601f8201121561031e5780519060209182806153ff83612ec1565b61540c60405191826110b6565b838152019160051b8301019185831161031e5783809101915b838310615444575050505083015190811161031e57614712920161529e565b81908351615451816105ee565b8152019101908390615425565b6040516154c89173ffffffffffffffffffffffffffffffffffffffff166154848261107e565b5f806020958685527f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c656487860152868151910182855af16154c26147ab565b91615dae565b805190828215928315615565575b505050156154e15750565b608490604051907f08c379a00000000000000000000000000000000000000000000000000000000082526004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e60448201527f6f742073756363656564000000000000000000000000000000000000000000006064820152fd5b6155759350820181019101614e0d565b5f82816154d6565b8160011c906b033b2e3c9fd0803ce80000009081831904811184151761031e5702010490565b6155ab612ce0565b80519081156155bb576020012090565b5050606b5480156155c95790565b507fc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a47090565b6155f6612dc0565b8051908115615606576020012090565b5050606c5480156155c95790565b601f8111615620575050565b60055f527f036b6384b5eca791c62761152d0c79bb0604c104a5fb6f4eb0703f3154bb3db0906020601f840160051c83019310615677575b601f0160051c01905b81811061566c575050565b5f8155600101615661565b9091508190615658565b601f811161568d575050565b606d5f527f5006b838207c6a9ae9b84d68f467dd4bb5c305fbfb6b04eab8faaabeec1e18d8906020601f840160051c830193106156e4575b601f0160051c01905b8181106156d9575050565b5f81556001016156ce565b90915081906156c5565b601f81116156fa575050565b60065f527ff652222313e28459528d920b65115c16c04f3efc82aaedc97be59f3f377c0d3f906020601f840160051c83019310615751575b601f0160051c01905b818110615746575050565b5f815560010161573b565b9091508190615732565b601f8111615767575050565b606e5f527f9930d9ff0dee0ef5ca2f7710ea66b8f84dd0f5f5351ecffe72b952cd9db7142a906020601f840160051c830193106157be575b601f0160051c01905b8181106157b3575050565b5f81556001016157a8565b909150819061579f565b90815167ffffffffffffffff81116105e9576157ee816157e9600654612c8f565b6156ee565b602080601f831160011461584d5750819061583d93945f92615842575b50507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8260011b9260031b1c19161790565b600655565b015190505f8061580b565b907fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe083169461589d60065f527ff652222313e28459528d920b65115c16c04f3efc82aaedc97be59f3f377c0d3f90565b925f905b8782106158f75750508360019596106158c0575b505050811b01600655565b01517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff60f88460031b161c191690555f80806158b5565b806001859682949686015181550195019301906158a1565b90815167ffffffffffffffff81116105e95761593581615930606e54612c8f565b61575b565b602080601f83116001146159885750819061598393945f926158425750507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8260011b9260031b1c19161790565b606e55565b907fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe08316946159d8606e5f527f9930d9ff0dee0ef5ca2f7710ea66b8f84dd0f5f5351ecffe72b952cd9db7142a90565b925f905b878210615a325750508360019596106159fb575b505050811b01606e55565b01517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff60f88460031b161c191690555f80806159f0565b806001859682949686015181550195019301906159dc565b9190600192615a6460ff60015460a81c1661310881614138565b80519067ffffffffffffffff82116105e957615a8a82615a85606d54612c8f565b615681565b602090816001601f851114615af95750615ae7949550918091615adf935f926158425750507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8260011b9260031b1c19161790565b606d5561590f565b615af05f606b55565b6111045f606c55565b606d5f5291957fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe08416907f5006b838207c6a9ae9b84d68f467dd4bb5c305fbfb6b04eab8faaabeec1e18d8935f915b838310615ba95750505095839291600194615ae7979810615b72575b505050811b01606d5561590f565b01517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff60f88460031b161c191690555f8080615b64565b848a01518655988101989485019491810191615b48565b15615bc757565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52600160045260245ffd5b92919092615c2273ffffffffffffffffffffffffffffffffffffffff82168015159081615d8c575b50615bc0565b615c4b8173ffffffffffffffffffffffffffffffffffffffff165f52600260205260405f205490565b5f5b8551811015615d845780615c666128d460019389612f7c565b615c708287612f7c565b51615ca461293d614c70886129138673ffffffffffffffffffffffffffffffffffffffff165f5261019960205260405f2090565b8015615d7d575b86868383148015615d75575b615d6b57615d65946128ee615d29615d23615d1d615ce561291396615cdf614ba69a8c61361c565b90615d97565b615d1861293d6129368a6129138a73ffffffffffffffffffffffffffffffffffffffff165f5261019960205260405f2090565b613bdd565b97615281565b96615281565b615d4c615d346110f7565b6fffffffffffffffffffffffffffffffff9098168852565b6fffffffffffffffffffffffffffffffff166020870152565b01615c4d565b5050505050615d65565b508315615cb7565b5083615cab565b505050509050565b90503014155f615c1c565b670de0b6b3a764000091615daa91614f68565b0490565b91929015615e295750815115615dc2575090565b3b15615dcb5790565b60646040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000006044820152fd5b825190915015615e3c5750805190602001fd5b610bdd906040519182917f08c379a00000000000000000000000000000000000000000000000000000000083526004830161037e56fea2646970667358221220f0d335b4654b144b7ec7bd281fd9c29788052bc1b59cd60ba5513d7f2f50e6df64736f6c63430008180033
Constructor Arguments (ABI-Encoded and is the last bytes of the Contract Creation Code above)
00000000000000000000000000a89d7a5a02160f20150ebea7a2b5e4879a1a8b0000000000000000000000000d745eaa9e70bb8b6e2a0317f85f1d536616bd3400000000000000000000000000000000000000000000000000000000000000000000000000000000000000005555555555555555555555555555555555555555000000000000000000000000eea6f790f18563e91b18df00b89d9f79b2e6761f
-----Decoded View---------------
Arg [0] : _aavePool (address): 0x00A89d7a5A02160f20150EbEA7a2b5E4879A1A8b
Arg [1] : _aToken (address): 0x0D745EAA9E70bb8B6e2a0317f85F1d536616bD34
Arg [2] : _initialIncentiveController (address): 0x0000000000000000000000000000000000000000
Arg [3] : _defaultRewardToken (address): 0x5555555555555555555555555555555555555555
Arg [4] : _offchainReceiver (address): 0xeea6F790F18563E91b18DF00B89d9f79b2E6761F
-----Encoded View---------------
5 Constructor Arguments found :
Arg [0] : 00000000000000000000000000a89d7a5a02160f20150ebea7a2b5e4879a1a8b
Arg [1] : 0000000000000000000000000d745eaa9e70bb8b6e2a0317f85f1d536616bd34
Arg [2] : 0000000000000000000000000000000000000000000000000000000000000000
Arg [3] : 0000000000000000000000005555555555555555555555555555555555555555
Arg [4] : 000000000000000000000000eea6f790f18563e91b18df00b89d9f79b2e6761f
Loading...
Loading
Loading...
Loading
Loading...
Loading
Net Worth in USD
$0.00
Net Worth in HYPE
Multichain Portfolio | 35 Chains
| Chain | Token | Portfolio % | Price | Amount | Value |
|---|
Loading...
Loading
Loading...
Loading
Loading...
Loading
A contract address hosts a smart contract, which is a set of code stored on the blockchain that runs when predetermined conditions are met. Learn more about addresses in our Knowledge Base.