Source Code
Overview
POL Balance
Token Holdings
More Info
ContractCreator
Multichain Info
N/A
Latest 25 from a total of 118 transactions
| Transaction Hash |
Method
|
Block
|
From
|
To
|
Amount
|
||||
|---|---|---|---|---|---|---|---|---|---|
| Create Certifica... | 16022976 | 481 days ago | IN | 0 POL | 0.00967953 | ||||
| Finish Certifica... | 15994094 | 482 days ago | IN | 0 POL | 0.00221852 | ||||
| Terminate Certif... | 15992405 | 482 days ago | IN | 0 POL | 0.00288765 | ||||
| Create Certifica... | 15991761 | 482 days ago | IN | 0 POL | 0.00978671 | ||||
| Authenticate Gua... | 15982049 | 482 days ago | IN | 0 POL | 0.00404265 | ||||
| Demander Paid | 15953554 | 483 days ago | IN | 0 POL | 0.00252963 | ||||
| Create Certifica... | 15953358 | 483 days ago | IN | 0 POL | 0.01019181 | ||||
| Authenticate Gua... | 15952746 | 483 days ago | IN | 0 POL | 0.0036938 | ||||
| Authenticate Gua... | 15951832 | 483 days ago | IN | 0 POL | 0.00427666 | ||||
| Authenticate Gua... | 15949729 | 483 days ago | IN | 0 POL | 0.0038844 | ||||
| Finish Certifica... | 15905446 | 484 days ago | IN | 0 POL | 0.00201684 | ||||
| Finish Certifica... | 15877796 | 485 days ago | IN | 0 POL | 0.0018007 | ||||
| Finish Certifica... | 15867649 | 485 days ago | IN | 0 POL | 0.0018007 | ||||
| Demander Paid | 15864618 | 485 days ago | IN | 0 POL | 0.00168082 | ||||
| Create Certifica... | 15864554 | 485 days ago | IN | 0 POL | 0.00806597 | ||||
| Terminate Certif... | 15864421 | 485 days ago | IN | 0 POL | 0.0021338 | ||||
| Demander Paid | 15864257 | 485 days ago | IN | 0 POL | 0.00168082 | ||||
| Create Certifica... | 15864144 | 485 days ago | IN | 0 POL | 0.00806597 | ||||
| Finish Certifica... | 15843371 | 486 days ago | IN | 0 POL | 0.00202983 | ||||
| Finish Certifica... | 15837724 | 486 days ago | IN | 0 POL | 0.00192134 | ||||
| Terminate Certif... | 15837713 | 486 days ago | IN | 0 POL | 0.00240448 | ||||
| Demander Paid | 15837670 | 486 days ago | IN | 0 POL | 0.00179344 | ||||
| Create Certifica... | 15837623 | 486 days ago | IN | 0 POL | 0.00815025 | ||||
| Demander Paid | 15837139 | 486 days ago | IN | 0 POL | 0.00189814 | ||||
| Create Certifica... | 15837087 | 486 days ago | IN | 0 POL | 0.00836831 |
Loading...
Loading
Contract Name:
Guaranty
Compiler Version
v0.8.20+commit.a1b79de6
Optimization Enabled:
Yes with 200 runs
Other Settings:
paris EvmVersion
Contract Source Code (Solidity Standard Json-Input format)
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;
// lib/openzeppelin-contracts/contracts/token/ERC20/IERC20.sol
// OpenZeppelin Contracts (last updated v5.0.0) (token/ERC20/IERC20.sol)
/**
* @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 value of tokens in existence.
*/
function totalSupply() external view returns (uint256);
/**
* @dev Returns the value of tokens owned by `account`.
*/
function balanceOf(address account) external view returns (uint256);
/**
* @dev Moves a `value` amount of 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 value) 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 a `value` amount of tokens 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 value) external returns (bool);
/**
* @dev Moves a `value` amount of tokens from `from` to `to` using the
* allowance mechanism. `value` 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 value) external returns (bool);
}
// lib/openzeppelin-contracts/contracts/token/ERC20/extensions/IERC20Permit.sol
// OpenZeppelin Contracts (last updated v5.0.0) (token/ERC20/extensions/IERC20Permit.sol)
/**
* @dev Interface of the ERC20 Permit extension allowing approvals to be made via signatures, as defined in
* https://eips.ethereum.org/EIPS/eip-2612[EIP-2612].
*
* Adds the {permit} method, which can be used to change an account's ERC20 allowance (see {IERC20-allowance}) by
* presenting a message signed by the account. By not relying on {IERC20-approve}, the token holder account doesn't
* need to send a transaction, and thus is not required to hold Ether at all.
*
* ==== Security Considerations
*
* There are two important considerations concerning the use of `permit`. The first is that a valid permit signature
* expresses an allowance, and it should not be assumed to convey additional meaning. In particular, it should not be
* considered as an intention to spend the allowance in any specific way. The second is that because permits have
* built-in replay protection and can be submitted by anyone, they can be frontrun. A protocol that uses permits should
* take this into consideration and allow a `permit` call to fail. Combining these two aspects, a pattern that may be
* generally recommended is:
*
* ```solidity
* function doThingWithPermit(..., uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s) public {
* try token.permit(msg.sender, address(this), value, deadline, v, r, s) {} catch {}
* doThing(..., value);
* }
*
* function doThing(..., uint256 value) public {
* token.safeTransferFrom(msg.sender, address(this), value);
* ...
* }
* ```
*
* Observe that: 1) `msg.sender` is used as the owner, leaving no ambiguity as to the signer intent, and 2) the use of
* `try/catch` allows the permit to fail and makes the code tolerant to frontrunning. (See also
* {SafeERC20-safeTransferFrom}).
*
* Additionally, note that smart contract wallets (such as Argent or Safe) are not able to produce permit signatures, so
* contracts should have entry points that don't rely on permit.
*/
interface 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].
*
* CAUTION: See Security Considerations above.
*/
function permit(
address owner,
address spender,
uint256 value,
uint256 deadline,
uint8 v,
bytes32 r,
bytes32 s
) external;
/**
* @dev Returns the current nonce for `owner`. This value must be
* included whenever a signature is generated for {permit}.
*
* Every successful call to {permit} increases ``owner``'s nonce by one. This
* prevents a signature from being used multiple times.
*/
function nonces(address owner) external view returns (uint256);
/**
* @dev Returns the domain separator used in the encoding of the signature for {permit}, as defined by {EIP712}.
*/
// solhint-disable-next-line func-name-mixedcase
function DOMAIN_SEPARATOR() external view returns (bytes32);
}
// lib/openzeppelin-contracts/contracts/utils/Address.sol
// OpenZeppelin Contracts (last updated v5.0.0) (utils/Address.sol)
/**
* @dev Collection of functions related to the address type
*/
library Address {
/**
* @dev The ETH balance of the account is not enough to perform the operation.
*/
error AddressInsufficientBalance(address account);
/**
* @dev There's no code at `target` (it is not a contract).
*/
error AddressEmptyCode(address target);
/**
* @dev A call to an address target failed. The target may have reverted.
*/
error FailedInnerCall();
/**
* @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.20/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].
*/
function sendValue(address payable recipient, uint256 amount) internal {
if (address(this).balance < amount) {
revert AddressInsufficientBalance(address(this));
}
(bool success, ) = recipient.call{value: amount}("");
if (!success) {
revert FailedInnerCall();
}
}
/**
* @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 or custom error, it is bubbled
* up by this function (like regular Solidity function calls). However, if
* the call reverted with no returned reason, this function reverts with a
* {FailedInnerCall} error.
*
* 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.
*/
function functionCall(address target, bytes memory data) internal returns (bytes memory) {
return functionCallWithValue(target, data, 0);
}
/**
* @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`.
*/
function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) {
if (address(this).balance < value) {
revert AddressInsufficientBalance(address(this));
}
(bool success, bytes memory returndata) = target.call{value: value}(data);
return verifyCallResultFromTarget(target, success, returndata);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but performing a static call.
*/
function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {
(bool success, bytes memory returndata) = target.staticcall(data);
return verifyCallResultFromTarget(target, success, returndata);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but performing a delegate call.
*/
function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {
(bool success, bytes memory returndata) = target.delegatecall(data);
return verifyCallResultFromTarget(target, success, returndata);
}
/**
* @dev Tool to verify that a low level call to smart-contract was successful, and reverts if the target
* was not a contract or bubbling up the revert reason (falling back to {FailedInnerCall}) in case of an
* unsuccessful call.
*/
function verifyCallResultFromTarget(
address target,
bool success,
bytes memory returndata
) internal view returns (bytes memory) {
if (!success) {
_revert(returndata);
} else {
// only check if target is a contract if the call was successful and the return data is empty
// otherwise we already know that it was a contract
if (returndata.length == 0 && target.code.length == 0) {
revert AddressEmptyCode(target);
}
return returndata;
}
}
/**
* @dev Tool to verify that a low level call was successful, and reverts if it wasn't, either by bubbling the
* revert reason or with a default {FailedInnerCall} error.
*/
function verifyCallResult(bool success, bytes memory returndata) internal pure returns (bytes memory) {
if (!success) {
_revert(returndata);
} else {
return returndata;
}
}
/**
* @dev Reverts with returndata if present. Otherwise reverts with {FailedInnerCall}.
*/
function _revert(bytes memory returndata) 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 FailedInnerCall();
}
}
}
// lib/openzeppelin-contracts/contracts/utils/Context.sol
// OpenZeppelin Contracts (last updated v5.0.1) (utils/Context.sol)
/**
* @dev Provides information about the current execution context, including the
* sender of the transaction and its data. While these are generally available
* via msg.sender and msg.data, they should not be accessed in such a direct
* manner, since when dealing with meta-transactions the account sending and
* paying for execution may not be the actual sender (as far as an application
* is concerned).
*
* This contract is only required for intermediate, library-like contracts.
*/
abstract contract Context {
function _msgSender() internal view virtual returns (address) {
return msg.sender;
}
function _msgData() internal view virtual returns (bytes calldata) {
return msg.data;
}
function _contextSuffixLength() internal view virtual returns (uint256) {
return 0;
}
}
// lib/openzeppelin-contracts/contracts/utils/ReentrancyGuard.sol
// OpenZeppelin Contracts (last updated v5.0.0) (utils/ReentrancyGuard.sol)
/**
* @dev Contract module that helps prevent reentrant calls to a function.
*
* Inheriting from `ReentrancyGuard` will make the {nonReentrant} modifier
* available, which can be applied to functions to make sure there are no nested
* (reentrant) calls to them.
*
* Note that because there is a single `nonReentrant` guard, functions marked as
* `nonReentrant` may not call one another. This can be worked around by making
* those functions `private`, and then adding `external` `nonReentrant` entry
* points to them.
*
* TIP: If you would like to learn more about reentrancy and alternative ways
* to protect against it, check out our blog post
* https://blog.openzeppelin.com/reentrancy-after-istanbul/[Reentrancy After Istanbul].
*/
abstract contract ReentrancyGuard {
// Booleans are more expensive than uint256 or any type that takes up a full
// word because each write operation emits an extra SLOAD to first read the
// slot's contents, replace the bits taken up by the boolean, and then write
// back. This is the compiler's defense against contract upgrades and
// pointer aliasing, and it cannot be disabled.
// The values being non-zero value makes deployment a bit more expensive,
// but in exchange the refund on every call to nonReentrant will be lower in
// amount. Since refunds are capped to a percentage of the total
// transaction's gas, it is best to keep them low in cases like this one, to
// increase the likelihood of the full refund coming into effect.
uint256 private constant NOT_ENTERED = 1;
uint256 private constant ENTERED = 2;
uint256 private _status;
/**
* @dev Unauthorized reentrant call.
*/
error ReentrancyGuardReentrantCall();
constructor() {
_status = NOT_ENTERED;
}
/**
* @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() {
_nonReentrantBefore();
_;
_nonReentrantAfter();
}
function _nonReentrantBefore() private {
// On the first call to nonReentrant, _status will be NOT_ENTERED
if (_status == ENTERED) {
revert ReentrancyGuardReentrantCall();
}
// Any calls to nonReentrant after this point will fail
_status = ENTERED;
}
function _nonReentrantAfter() private {
// By storing the original value once again, a refund is triggered (see
// https://eips.ethereum.org/EIPS/eip-2200)
_status = NOT_ENTERED;
}
/**
* @dev Returns true if the reentrancy guard is currently set to "entered", which indicates there is a
* `nonReentrant` function in the call stack.
*/
function _reentrancyGuardEntered() internal view returns (bool) {
return _status == ENTERED;
}
}
// lib/openzeppelin-contracts/contracts/utils/cryptography/ECDSA.sol
// OpenZeppelin Contracts (last updated v5.0.0) (utils/cryptography/ECDSA.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
}
/**
* @dev The signature derives the `address(0)`.
*/
error ECDSAInvalidSignature();
/**
* @dev The signature has an invalid length.
*/
error ECDSAInvalidSignatureLength(uint256 length);
/**
* @dev The signature has an S value that is in the upper half order.
*/
error ECDSAInvalidSignatureS(bytes32 s);
/**
* @dev Returns the address that signed a hashed message (`hash`) with `signature` or an error. This will not
* return address(0) without also returning an error description. Errors are documented using an enum (error type)
* and a bytes32 providing additional information about the error.
*
* If no error is returned, then the address can be used for verification purposes.
*
* The `ecrecover` EVM precompile 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 {MessageHashUtils-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]
*/
function tryRecover(bytes32 hash, bytes memory signature) internal pure returns (address, RecoverError, bytes32) {
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, bytes32(signature.length));
}
}
/**
* @dev Returns the address that signed a hashed message (`hash`) with
* `signature`. This address can then be used for verification purposes.
*
* The `ecrecover` EVM precompile 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 {MessageHashUtils-toEthSignedMessageHash} on it.
*/
function recover(bytes32 hash, bytes memory signature) internal pure returns (address) {
(address recovered, RecoverError error, bytes32 errorArg) = tryRecover(hash, signature);
_throwError(error, errorArg);
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]
*/
function tryRecover(bytes32 hash, bytes32 r, bytes32 vs) internal pure returns (address, RecoverError, bytes32) {
unchecked {
bytes32 s = vs & bytes32(0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff);
// We do not check for an overflow here since the shift operation results in 0 or 1.
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.
*/
function recover(bytes32 hash, bytes32 r, bytes32 vs) internal pure returns (address) {
(address recovered, RecoverError error, bytes32 errorArg) = tryRecover(hash, r, vs);
_throwError(error, errorArg);
return recovered;
}
/**
* @dev Overload of {ECDSA-tryRecover} that receives the `v`,
* `r` and `s` signature fields separately.
*/
function tryRecover(
bytes32 hash,
uint8 v,
bytes32 r,
bytes32 s
) internal pure returns (address, RecoverError, bytes32) {
// 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, s);
}
// 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, bytes32(0));
}
return (signer, RecoverError.NoError, bytes32(0));
}
/**
* @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, bytes32 errorArg) = tryRecover(hash, v, r, s);
_throwError(error, errorArg);
return recovered;
}
/**
* @dev Optionally reverts with the corresponding custom error according to the `error` argument provided.
*/
function _throwError(RecoverError error, bytes32 errorArg) private pure {
if (error == RecoverError.NoError) {
return; // no error: do nothing
} else if (error == RecoverError.InvalidSignature) {
revert ECDSAInvalidSignature();
} else if (error == RecoverError.InvalidSignatureLength) {
revert ECDSAInvalidSignatureLength(uint256(errorArg));
} else if (error == RecoverError.InvalidSignatureS) {
revert ECDSAInvalidSignatureS(errorArg);
}
}
}
// lib/openzeppelin-contracts/contracts/utils/math/Math.sol
// OpenZeppelin Contracts (last updated v5.0.0) (utils/math/Math.sol)
/**
* @dev Standard math utilities missing in the Solidity language.
*/
library Math {
/**
* @dev Muldiv operation overflow.
*/
error MathOverflowedMulDiv();
enum Rounding {
Floor, // Toward negative infinity
Ceil, // Toward positive infinity
Trunc, // Toward zero
Expand // Away from zero
}
/**
* @dev Returns the addition of two unsigned integers, with an overflow flag.
*/
function tryAdd(uint256 a, uint256 b) internal pure returns (bool, uint256) {
unchecked {
uint256 c = a + b;
if (c < a) return (false, 0);
return (true, c);
}
}
/**
* @dev Returns the subtraction of two unsigned integers, with an overflow flag.
*/
function trySub(uint256 a, uint256 b) internal pure returns (bool, uint256) {
unchecked {
if (b > a) return (false, 0);
return (true, a - b);
}
}
/**
* @dev Returns the multiplication of two unsigned integers, with an overflow flag.
*/
function tryMul(uint256 a, uint256 b) internal pure returns (bool, uint256) {
unchecked {
// Gas optimization: this is cheaper than requiring 'a' not being zero, but the
// benefit is lost if 'b' is also tested.
// See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522
if (a == 0) return (true, 0);
uint256 c = a * b;
if (c / a != b) return (false, 0);
return (true, c);
}
}
/**
* @dev Returns the division of two unsigned integers, with a division by zero flag.
*/
function tryDiv(uint256 a, uint256 b) internal pure returns (bool, uint256) {
unchecked {
if (b == 0) return (false, 0);
return (true, a / b);
}
}
/**
* @dev Returns the remainder of dividing two unsigned integers, with a division by zero flag.
*/
function tryMod(uint256 a, uint256 b) internal pure returns (bool, uint256) {
unchecked {
if (b == 0) return (false, 0);
return (true, a % b);
}
}
/**
* @dev Returns the 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 towards infinity instead
* of rounding towards zero.
*/
function ceilDiv(uint256 a, uint256 b) internal pure returns (uint256) {
if (b == 0) {
// Guarantee the same behavior as in a regular Solidity division.
return a / b;
}
// (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 = x * y; // Least significant 256 bits of the product
uint256 prod1; // Most significant 256 bits of the product
assembly {
let mm := mulmod(x, y, not(0))
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.
if (denominator <= prod1) {
revert MathOverflowedMulDiv();
}
///////////////////////////////////////////////
// 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.
uint256 twos = denominator & (0 - denominator);
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 (unsignedRoundsUp(rounding) && 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
* towards zero.
*
* 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 + (unsignedRoundsUp(rounding) && result * result < a ? 1 : 0);
}
}
/**
* @dev Return the log in base 2 of a positive value rounded towards zero.
* 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 + (unsignedRoundsUp(rounding) && 1 << result < value ? 1 : 0);
}
}
/**
* @dev Return the log in base 10 of a positive value rounded towards zero.
* 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 + (unsignedRoundsUp(rounding) && 10 ** result < value ? 1 : 0);
}
}
/**
* @dev Return the log in base 256 of a positive value rounded towards zero.
* 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 + (unsignedRoundsUp(rounding) && 1 << (result << 3) < value ? 1 : 0);
}
}
/**
* @dev Returns whether a provided rounding mode is considered rounding up for unsigned integers.
*/
function unsignedRoundsUp(Rounding rounding) internal pure returns (bool) {
return uint8(rounding) % 2 == 1;
}
}
// lib/openzeppelin-contracts/contracts/utils/math/SignedMath.sol
// OpenZeppelin Contracts (last updated v5.0.0) (utils/math/SignedMath.sol)
/**
* @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);
}
}
}
// lib/openzeppelin-contracts/contracts/access/Ownable.sol
// OpenZeppelin Contracts (last updated v5.0.0) (access/Ownable.sol)
/**
* @dev Contract module which provides a basic access control mechanism, where
* there is an account (an owner) that can be granted exclusive access to
* specific functions.
*
* The initial owner is set to the address provided by the deployer. This can
* later be changed with {transferOwnership}.
*
* This module is used through inheritance. It will make available the modifier
* `onlyOwner`, which can be applied to your functions to restrict their use to
* the owner.
*/
abstract contract Ownable is Context {
address private _owner;
/**
* @dev The caller account is not authorized to perform an operation.
*/
error OwnableUnauthorizedAccount(address account);
/**
* @dev The owner is not a valid owner account. (eg. `address(0)`)
*/
error OwnableInvalidOwner(address owner);
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
/**
* @dev Initializes the contract setting the address provided by the deployer as the initial owner.
*/
constructor(address initialOwner) {
if (initialOwner == address(0)) {
revert OwnableInvalidOwner(address(0));
}
_transferOwnership(initialOwner);
}
/**
* @dev Throws if called by any account other than the owner.
*/
modifier onlyOwner() {
_checkOwner();
_;
}
/**
* @dev Returns the address of the current owner.
*/
function owner() public view virtual returns (address) {
return _owner;
}
/**
* @dev Throws if the sender is not the owner.
*/
function _checkOwner() internal view virtual {
if (owner() != _msgSender()) {
revert OwnableUnauthorizedAccount(_msgSender());
}
}
/**
* @dev Leaves the contract without owner. It will not be possible to call
* `onlyOwner` functions. Can only be called by the current owner.
*
* NOTE: Renouncing ownership will leave the contract without an owner,
* thereby disabling any functionality that is only available to the owner.
*/
function renounceOwnership() public virtual onlyOwner {
_transferOwnership(address(0));
}
/**
* @dev Transfers ownership of the contract to a new account (`newOwner`).
* Can only be called by the current owner.
*/
function transferOwnership(address newOwner) public virtual onlyOwner {
if (newOwner == address(0)) {
revert OwnableInvalidOwner(address(0));
}
_transferOwnership(newOwner);
}
/**
* @dev Transfers ownership of the contract to a new account (`newOwner`).
* Internal function without access restriction.
*/
function _transferOwnership(address newOwner) internal virtual {
address oldOwner = _owner;
_owner = newOwner;
emit OwnershipTransferred(oldOwner, newOwner);
}
}
// lib/openzeppelin-contracts/contracts/utils/Strings.sol
// OpenZeppelin Contracts (last updated v5.0.0) (utils/Strings.sol)
/**
* @dev String operations.
*/
library Strings {
bytes16 private constant HEX_DIGITS = "0123456789abcdef";
uint8 private constant ADDRESS_LENGTH = 20;
/**
* @dev The `value` string doesn't fit in the specified `length`.
*/
error StringsInsufficientHexLength(uint256 value, uint256 length);
/**
* @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), HEX_DIGITS))
}
value /= 10;
if (value == 0) break;
}
return buffer;
}
}
/**
* @dev Converts a `int256` to its ASCII `string` decimal representation.
*/
function toStringSigned(int256 value) internal pure returns (string memory) {
return string.concat(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) {
uint256 localValue = value;
bytes memory buffer = new bytes(2 * length + 2);
buffer[0] = "0";
buffer[1] = "x";
for (uint256 i = 2 * length + 1; i > 1; --i) {
buffer[i] = HEX_DIGITS[localValue & 0xf];
localValue >>= 4;
}
if (localValue != 0) {
revert StringsInsufficientHexLength(value, length);
}
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 bytes(a).length == bytes(b).length && keccak256(bytes(a)) == keccak256(bytes(b));
}
}
// lib/openzeppelin-contracts/contracts/token/ERC20/utils/SafeERC20.sol
// OpenZeppelin Contracts (last updated v5.0.0) (token/ERC20/utils/SafeERC20.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 An operation with an ERC20 token failed.
*/
error SafeERC20FailedOperation(address token);
/**
* @dev Indicates a failed `decreaseAllowance` request.
*/
error SafeERC20FailedDecreaseAllowance(address spender, uint256 currentAllowance, uint256 requestedDecrease);
/**
* @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.encodeCall(token.transfer, (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.encodeCall(token.transferFrom, (from, to, 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);
forceApprove(token, spender, oldAllowance + value);
}
/**
* @dev Decrease the calling contract's allowance toward `spender` by `requestedDecrease`. If `token` returns no
* value, non-reverting calls are assumed to be successful.
*/
function safeDecreaseAllowance(IERC20 token, address spender, uint256 requestedDecrease) internal {
unchecked {
uint256 currentAllowance = token.allowance(address(this), spender);
if (currentAllowance < requestedDecrease) {
revert SafeERC20FailedDecreaseAllowance(spender, currentAllowance, requestedDecrease);
}
forceApprove(token, spender, currentAllowance - requestedDecrease);
}
}
/**
* @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.encodeCall(token.approve, (spender, value));
if (!_callOptionalReturnBool(token, approvalCall)) {
_callOptionalReturn(token, abi.encodeCall(token.approve, (spender, 0)));
_callOptionalReturn(token, approvalCall);
}
}
/**
* @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);
if (returndata.length != 0 && !abi.decode(returndata, (bool))) {
revert SafeERC20FailedOperation(address(token));
}
}
/**
* @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(token).code.length > 0;
}
}
// lib/openzeppelin-contracts/contracts/utils/cryptography/MessageHashUtils.sol
// OpenZeppelin Contracts (last updated v5.0.0) (utils/cryptography/MessageHashUtils.sol)
/**
* @dev Signature message hash utilities for producing digests to be consumed by {ECDSA} recovery or signing.
*
* The library provides methods for generating a hash of a message that conforms to the
* https://eips.ethereum.org/EIPS/eip-191[EIP 191] and https://eips.ethereum.org/EIPS/eip-712[EIP 712]
* specifications.
*/
library MessageHashUtils {
/**
* @dev Returns the keccak256 digest of an EIP-191 signed data with version
* `0x45` (`personal_sign` messages).
*
* The digest is calculated by prefixing a bytes32 `messageHash` with
* `"\x19Ethereum Signed Message:\n32"` and hashing the result. It corresponds with the
* hash signed when using the https://eth.wiki/json-rpc/API#eth_sign[`eth_sign`] JSON-RPC method.
*
* NOTE: The `messageHash` parameter is intended to be the result of hashing a raw message with
* keccak256, although any bytes32 value can be safely used because the final digest will
* be re-hashed.
*
* See {ECDSA-recover}.
*/
function toEthSignedMessageHash(bytes32 messageHash) internal pure returns (bytes32 digest) {
/// @solidity memory-safe-assembly
assembly {
mstore(0x00, "\x19Ethereum Signed Message:\n32") // 32 is the bytes-length of messageHash
mstore(0x1c, messageHash) // 0x1c (28) is the length of the prefix
digest := keccak256(0x00, 0x3c) // 0x3c is the length of the prefix (0x1c) + messageHash (0x20)
}
}
/**
* @dev Returns the keccak256 digest of an EIP-191 signed data with version
* `0x45` (`personal_sign` messages).
*
* The digest is calculated by prefixing an arbitrary `message` with
* `"\x19Ethereum Signed Message:\n" + len(message)` and hashing the result. It corresponds with the
* hash signed when using the https://eth.wiki/json-rpc/API#eth_sign[`eth_sign`] JSON-RPC method.
*
* See {ECDSA-recover}.
*/
function toEthSignedMessageHash(bytes memory message) internal pure returns (bytes32) {
return
keccak256(bytes.concat("\x19Ethereum Signed Message:\n", bytes(Strings.toString(message.length)), message));
}
/**
* @dev Returns the keccak256 digest of an EIP-191 signed data with version
* `0x00` (data with intended validator).
*
* The digest is calculated by prefixing an arbitrary `data` with `"\x19\x00"` and the intended
* `validator` address. Then hashing the result.
*
* See {ECDSA-recover}.
*/
function toDataWithIntendedValidatorHash(address validator, bytes memory data) internal pure returns (bytes32) {
return keccak256(abi.encodePacked(hex"19_00", validator, data));
}
/**
* @dev Returns the keccak256 digest of an EIP-712 typed data (EIP-191 version `0x01`).
*
* The digest is calculated from a `domainSeparator` and a `structHash`, by prefixing them with
* `\x19\x01` and hashing the result. It corresponds to the hash signed by the
* https://eips.ethereum.org/EIPS/eip-712[`eth_signTypedData`] JSON-RPC method as part of EIP-712.
*
* See {ECDSA-recover}.
*/
function toTypedDataHash(bytes32 domainSeparator, bytes32 structHash) internal pure returns (bytes32 digest) {
/// @solidity memory-safe-assembly
assembly {
let ptr := mload(0x40)
mstore(ptr, hex"19_01")
mstore(add(ptr, 0x02), domainSeparator)
mstore(add(ptr, 0x22), structHash)
digest := keccak256(ptr, 0x42)
}
}
}
// src/libs/IERC20Token.sol
library IERC20Token {
using Address for address payable;
using SafeERC20 for IERC20;
function sendTo(IERC20 token, address to, uint256 amount) internal {
require(to != address(0), "Invalid recipient");
if (address(token) == address(0)) {
require(address(this).balance >= amount, "Insufficient ETH");
payable(to).sendValue(amount);
} else {
uint256 balanceFrom = token.balanceOf(address(this));
require(balanceFrom >= amount, "Insufficient balance");
uint256 balanceTo = token.balanceOf(to);
(bool success,) = address(token).call(abi.encodeCall(IERC20.transfer, (to, amount)));
require(success, "ERC20 token transfer call failed");
require(token.balanceOf(to) == balanceTo + amount, "ERC20 token transfer to failed");
require(token.balanceOf(address(this)) == balanceFrom - amount, "ERC20 token transfer from failed");
}
}
function receiveFromSender(IERC20 token, uint256 amount) internal {
if (address(token) == address(0)) {
require(msg.value >= amount, "Insufficient value");
} else {
require(amount > 0, "Invalid amount");
uint256 allowance = token.allowance(msg.sender, address(this));
require(allowance >= amount, "Insufficient allowance");
token.safeTransferFrom(msg.sender, address(this), amount);
}
}
}
// src/Guaranty.sol
contract Guaranty is Ownable, ReentrancyGuard {
using IERC20Token for IERC20;
enum CertificationStatus { INACTIVE, ACTIVE, TERMINATED }
enum GuarantorIncomeType { CreateCert, TerminateCert }
struct Guarantor {
bool isAuthenticated;
address tokenAddr;
uint256 depositAmount;
uint256 availableAmount;
mapping(address => uint256) feePool;
}
struct Certification {
string certId;
address guarantor;
address demander;
address tokenAddr;
uint256 startTime;
uint256 endTime;
uint256 guaranteeAmount;
uint256 availableAmount;
uint256 penaltyRate;
CertificationStatus status;
}
struct TokenInfo{
address tokenAddr;
uint256 amount;
}
address[] private _certTokens;
mapping(address => bool) public supportedTokens;
mapping(address => Guarantor) public guarantors;
mapping(string => Certification) public certifications;
mapping(address => uint256) public guarantorCertNum;
mapping(address => bool) private executorList;
mapping(address => uint256) public feePool;
event GuarantorAuthenticated(address guarantorAddr, address tokenAddr, uint256 amount);
event GuarantorDeregistered(address guarantorAddr, uint256 amount);
event CertCreated(string certId, address demanderAddr, address guarantorAddr, address tokenAddr, uint256 amount, uint256 serviceFee, uint256 platformFee, uint256 penaltyRate, uint256 startTime, uint256 endTime);
event CertFunded(string certId, address demanderAddr, address tokenAddr, uint256 amount);
event CertFinished(string certId, address demanderAddr, address tokenAddr, uint256 amount);
event CertTerminated(string certId, address demanderAddr, address tokenAddr, uint256 amount, uint256 fee, uint256 rate);
event GuarantorPaid(string paidNo, string certId, address guarantorAddr, address targetAddr, address tokenAddr, uint256 amount);
event DemanderPaid(string paidNo, string certId, address demanderAddr, address targetAddr, address tokenAddr, uint256 amount);
event AddExecutor(address _newExecutor);
event DelExecutor(address _oldExecutor);
event WithdrawPFee(address tokenAddr, address targetAddr, uint256 amount);
event WithdrawGFee(address tokenAddr, address guarantorAddr, uint256 amount);
event GuarantorIncome(string certId, address tokenAddr, uint256 amount, GuarantorIncomeType incomeType);
event PlatformIncome(string certId, address tokenAddr, uint256 amount);
event UnclaimedIncome(address guarantorAddr, address tokenAddr, uint256 amount);
error NotAuthorizedExecutor();
error NotAuthenticatedGuarantor();
error GuarantorNotFound();
error HasActiveCertifications();
error CertificationNotActive();
error NotCertificationGuarantor();
error InsufficientAvailableAmount();
error InvalidExecutorSignature();
error InvalidGuarantorSignature();
error GuarantorNotAuthenticated();
error NotCertificationOwner();
error CertificationNotExpired();
error CertificationNeedFinished();
modifier onlyExecutor() {
if (!executorList[msg.sender] && owner() != msg.sender) {
revert NotAuthorizedExecutor();
}
_;
}
modifier onlyGuarantor() {
if (!guarantors[msg.sender].isAuthenticated) {
revert NotAuthenticatedGuarantor();
}
_;
}
constructor() Ownable(msg.sender) {
executorList[msg.sender] = true;
}
function authenticateGuarantor(address tokenAddr, uint256 amount, uint256 timestamp, bytes memory signature) external nonReentrant {
_checkSigTimestamp(timestamp);
_verifyExecutorSignature(keccak256(abi.encode(msg.sender, tokenAddr, amount, timestamp)), signature);
require(!guarantors[msg.sender].isAuthenticated, "Duplicate authentication");
_receiveToken(tokenAddr, amount);
_addSupportedToken(tokenAddr);
guarantors[msg.sender].isAuthenticated = true;
guarantors[msg.sender].tokenAddr = tokenAddr;
guarantors[msg.sender].depositAmount = amount;
guarantors[msg.sender].availableAmount = amount;
emit GuarantorAuthenticated(msg.sender, tokenAddr, amount);
}
function deregisterGuarantor(address guarantorAddr) external onlyExecutor nonReentrant {
Guarantor storage guarantor = guarantors[guarantorAddr];
if (!guarantor.isAuthenticated) {
revert GuarantorNotFound();
}
if (guarantorCertNum[guarantorAddr] > 0) {
revert HasActiveCertifications();
}
guarantor.isAuthenticated = false;
guarantor.depositAmount = 0;
uint256 amount = 0;
if(guarantor.availableAmount > 0) {
amount = guarantor.availableAmount;
guarantor.availableAmount = 0;
_transferToken(guarantor.tokenAddr, guarantorAddr, amount);
}
emit GuarantorDeregistered(guarantorAddr, amount);
uint256 cnt = _certTokens.length;
if (cnt > 0) {
amount = 0;
for (uint256 i = 0; i < cnt; i++) {
address tokenAddr = _certTokens[i];
amount = guarantor.feePool[tokenAddr];
if (amount > 0) {
guarantor.feePool[tokenAddr] -= amount;
feePool[tokenAddr] += amount;
emit UnclaimedIncome(guarantorAddr, tokenAddr, amount);
}
}
}
}
function guarantorPaid(string memory paidNo, string memory certId, address targetAddr, uint256 amount) external onlyExecutor nonReentrant {
Certification storage cert = certifications[certId];
if (cert.status != CertificationStatus.ACTIVE || block.timestamp < cert.startTime ||block.timestamp > cert.endTime) {
revert CertificationNotActive();
}
Guarantor storage guarantor = guarantors[cert.guarantor];
if (guarantor.availableAmount < amount) {
revert InsufficientAvailableAmount();
}
guarantor.availableAmount -= amount;
_transferToken(guarantor.tokenAddr, targetAddr, amount);
emit GuarantorPaid(paidNo, certId, cert.guarantor, targetAddr, guarantor.tokenAddr, amount);
}
function getGuarantorInfo(address guarantorAddr) external view returns (bool isAuthenticated, address tokenAddr, uint256 depositAmount, uint256 availableAmount) {
Guarantor storage guarantor = guarantors[guarantorAddr];
return (
guarantor.isAuthenticated,
guarantor.tokenAddr,
guarantor.depositAmount,
guarantor.availableAmount
);
}
function withdrawGuarantorFee(address guarantorAddr, address[] memory tokenAddr, uint256[] memory amount) external nonReentrant {
if(guarantorAddr == address(0)){
guarantorAddr = msg.sender;
}
Guarantor storage guarantor = guarantors[guarantorAddr];
if (!guarantor.isAuthenticated) {
revert GuarantorNotFound();
}
for(uint256 i = 0; i < tokenAddr.length; i++){
uint256 fee = guarantor.feePool[tokenAddr[i]];
if(amount[i] == 0){
amount[i] = fee;
}
if(amount[i] == 0) continue;
require(amount[i] <= fee, "Insufficient fee");
guarantor.feePool[tokenAddr[i]] -= amount[i];
_transferToken(tokenAddr[i], guarantorAddr, amount[i]);
emit WithdrawGFee(tokenAddr[i], guarantorAddr, amount[i]);
}
}
function getGuarantorFee(address guarantorAddr) external view returns (TokenInfo[] memory fees) {
uint256 cnt = _certTokens.length;
if(cnt > 0){
fees = new TokenInfo[](cnt);
for(uint256 i = 0;i < cnt; i++){
fees[i].tokenAddr = _certTokens[i];
fees[i].amount = guarantors[guarantorAddr].feePool[_certTokens[i]];
}
}
}
function createCertification(
string memory certId,
address guarantorAddr,
address tokenAddr,
uint256 amount,
uint256 serviceFee,
uint256 platformFee,
uint256 penaltyRate,
uint256 period,
uint256 timestamp,
bytes memory signature
) external nonReentrant {
_checkGuarantorSigTimestamp(timestamp);
_verifyGuarantorSignature(keccak256(abi.encode(certId, msg.sender, guarantorAddr, tokenAddr, amount, serviceFee, platformFee, penaltyRate, period, timestamp)), signature);
Guarantor storage guarantor = guarantors[guarantorAddr];
if (!guarantor.isAuthenticated) {
revert GuarantorNotAuthenticated();
}
uint256 available = amount - serviceFee - platformFee;
require(available > 0, "Insufficient amount");
_receiveToken(tokenAddr, amount);
_addSupportedToken(tokenAddr);
uint256 startTime = block.timestamp - (block.timestamp % 86400);
uint256 endTime = startTime + period * 86400;
certifications[certId] = Certification({
certId: certId,
guarantor: guarantorAddr,
demander: msg.sender,
tokenAddr: tokenAddr,
startTime: startTime,
endTime: endTime,
guaranteeAmount: amount,
availableAmount: available,
penaltyRate: penaltyRate,
status: CertificationStatus.ACTIVE
});
guarantorCertNum[guarantorAddr] += 1;
feePool[tokenAddr] += platformFee;
emit PlatformIncome(certId, tokenAddr, platformFee);
guarantor.feePool[tokenAddr] += serviceFee;
emit GuarantorIncome(certId, tokenAddr, serviceFee, GuarantorIncomeType.CreateCert);
emit CertCreated(certId, msg.sender, guarantorAddr, tokenAddr, amount, serviceFee, platformFee, penaltyRate, startTime, endTime);
}
function fundCertification(string memory certId, uint256 amount, uint256 timestamp, bytes memory signature) external nonReentrant {
_checkGuarantorSigTimestamp(timestamp);
_verifyGuarantorSignature(keccak256(abi.encode(certId, msg.sender, amount, timestamp)), signature);
Certification storage cert = certifications[certId];
if (cert.status != CertificationStatus.ACTIVE || block.timestamp >= cert.endTime) {
revert CertificationNotActive();
}
if (msg.sender != cert.demander) {
revert NotCertificationOwner();
}
_receiveToken(cert.tokenAddr, amount);
cert.guaranteeAmount += amount;
cert.availableAmount += amount;
emit CertFunded(certId, msg.sender, cert.tokenAddr, amount);
}
function finishCertification(string memory certId) external onlyExecutor nonReentrant {
Certification storage cert = certifications[certId];
if (cert.status != CertificationStatus.ACTIVE) {
revert CertificationNotActive();
}
if (block.timestamp > cert.startTime && block.timestamp < cert.endTime) {
revert CertificationNotExpired();
}
cert.status = CertificationStatus.TERMINATED;
guarantorCertNum[cert.guarantor] -= 1;
uint256 amount = 0;
if(cert.availableAmount > 0){
amount = cert.availableAmount;
cert.availableAmount = 0;
_transferToken(cert.tokenAddr, cert.demander, amount);
}
emit CertFinished(certId, cert.demander, cert.tokenAddr, amount);
}
function terminateCertification(string memory certId, uint256 timestamp, bytes memory signature) external nonReentrant {
_checkGuarantorSigTimestamp(timestamp);
_verifyGuarantorSignature(keccak256(abi.encode(certId, msg.sender, timestamp)), signature);
Certification storage cert = certifications[certId];
if (cert.status != CertificationStatus.ACTIVE) {
revert CertificationNotActive();
}
if (block.timestamp < cert.startTime || block.timestamp > cert.endTime) {
revert CertificationNeedFinished();
}
if (msg.sender != cert.demander) {
revert NotCertificationOwner();
}
cert.status = CertificationStatus.TERMINATED;
guarantorCertNum[cert.guarantor] -= 1;
uint256 amount = 0;
uint256 fee = 0;
if(cert.availableAmount > 0){
amount = cert.availableAmount;
fee = amount * cert.penaltyRate / 10000;
guarantors[cert.guarantor].feePool[cert.tokenAddr] += fee;
emit GuarantorIncome(certId, cert.tokenAddr, fee, GuarantorIncomeType.TerminateCert);
cert.availableAmount = 0;
_transferToken(cert.tokenAddr, cert.demander, amount - fee);
}
emit CertTerminated(certId, cert.demander, cert.tokenAddr, amount, fee, cert.penaltyRate);
}
function demanderPaid(string memory paidNo, string memory certId, address targetAddr, uint256 amount) external nonReentrant {
Certification storage cert = certifications[certId];
if (cert.status != CertificationStatus.ACTIVE || block.timestamp >= cert.endTime) {
revert CertificationNotActive();
}
if (msg.sender != cert.guarantor) {
revert NotCertificationGuarantor();
}
if (cert.availableAmount < amount) {
revert InsufficientAvailableAmount();
}
cert.availableAmount -= amount;
_transferToken(cert.tokenAddr, targetAddr, amount);
emit DemanderPaid(paidNo, certId, cert.demander, targetAddr, cert.tokenAddr, amount);
}
function getCertificationInfo(string memory certId) external view returns (
uint256 startTime,
uint256 endTime,
uint256 guaranteeAmount,
address tokenAddr,
address guarantorAddr,
address demanderAddr,
uint256 availableAmount,
uint256 penaltyRate,
CertificationStatus status
) {
Certification memory cert = certifications[certId];
return (
cert.startTime,
cert.endTime,
cert.guaranteeAmount,
cert.tokenAddr,
cert.guarantor,
cert.demander,
cert.availableAmount,
cert.penaltyRate,
cert.status
);
}
function withdrawPlatformFee(address targetAddr, address[] memory tokenAddr, uint256[] memory amount) external onlyExecutor nonReentrant {
for(uint256 i = 0; i < tokenAddr.length; i++){
uint256 fee = feePool[tokenAddr[i]];
if(amount[i] == 0){
amount[i] = fee;
}
if(amount[i] == 0) continue;
require(amount[i] <= fee, "Insufficient fee");
feePool[tokenAddr[i]] -= amount[i];
_transferToken(tokenAddr[i], targetAddr, amount[i]);
emit WithdrawPFee(tokenAddr[i], targetAddr, amount[i]);
}
}
function getPlatformFee() external view returns (TokenInfo[] memory fees) {
uint256 cnt = _certTokens.length;
if(cnt > 0){
fees = new TokenInfo[](cnt);
for(uint256 i = 0;i < cnt; i++){
fees[i].tokenAddr = _certTokens[i];
fees[i].amount = feePool[_certTokens[i]];
}
}
}
function addExecutor(address _newExecutor) external onlyOwner {
executorList[_newExecutor] = true;
emit AddExecutor(_newExecutor);
}
function delExecutor(address _oldExecutor) external onlyOwner {
executorList[_oldExecutor] = false;
emit DelExecutor(_oldExecutor);
}
function _receiveToken(address token, uint256 amount) private {
IERC20(token).receiveFromSender(amount);
}
function _transferToken(address token, address to, uint256 amount) private {
IERC20(token).sendTo(to, amount);
}
function _checkSigTimestamp(uint256 sigTimestamp) private view {
require(block.timestamp > sigTimestamp, "Invalid sig timestamp!");
require(block.timestamp - sigTimestamp <= 1 hours, "Sig timestamp expire!");
}
function _checkGuarantorSigTimestamp(uint256 sigTimestamp) private view {
require(block.timestamp > sigTimestamp, "Invalid sig timestamp!");
require(block.timestamp - sigTimestamp <= 1 days, "Sig timestamp expire!");
}
function _verifyExecutorSignature(bytes32 hash, bytes memory signature) private view {
if (!executorList[ECDSA.recover(MessageHashUtils.toEthSignedMessageHash(hash), signature)]) {
revert InvalidExecutorSignature();
}
}
function _verifyGuarantorSignature(bytes32 hash, bytes memory signature) private view {
if (!guarantors[ECDSA.recover(MessageHashUtils.toEthSignedMessageHash(hash), signature)].isAuthenticated) {
revert InvalidGuarantorSignature();
}
}
function _addSupportedToken(address token) private {
if (!supportedTokens[token]) {
supportedTokens[token] = true;
_certTokens.push(token);
}
}
}{
"remappings": [
"@openzeppelin/contracts/=lib/openzeppelin-contracts/contracts/",
"ds-test/=lib/openzeppelin-contracts/lib/forge-std/lib/ds-test/src/",
"erc4626-tests/=lib/openzeppelin-contracts/lib/erc4626-tests/",
"forge-std/=lib/forge-std/src/",
"openzeppelin-contracts/=lib/openzeppelin-contracts/"
],
"optimizer": {
"enabled": true,
"runs": 200
},
"metadata": {
"useLiteralContent": false,
"bytecodeHash": "ipfs",
"appendCBOR": true
},
"outputSelection": {
"*": {
"*": [
"evm.bytecode",
"evm.deployedBytecode",
"devdoc",
"userdoc",
"metadata",
"abi"
]
}
},
"evmVersion": "paris",
"viaIR": false,
"libraries": {}
}Contract ABI
API[{"inputs":[],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[{"internalType":"address","name":"target","type":"address"}],"name":"AddressEmptyCode","type":"error"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"AddressInsufficientBalance","type":"error"},{"inputs":[],"name":"CertificationNeedFinished","type":"error"},{"inputs":[],"name":"CertificationNotActive","type":"error"},{"inputs":[],"name":"CertificationNotExpired","type":"error"},{"inputs":[],"name":"ECDSAInvalidSignature","type":"error"},{"inputs":[{"internalType":"uint256","name":"length","type":"uint256"}],"name":"ECDSAInvalidSignatureLength","type":"error"},{"inputs":[{"internalType":"bytes32","name":"s","type":"bytes32"}],"name":"ECDSAInvalidSignatureS","type":"error"},{"inputs":[],"name":"FailedInnerCall","type":"error"},{"inputs":[],"name":"GuarantorNotAuthenticated","type":"error"},{"inputs":[],"name":"GuarantorNotFound","type":"error"},{"inputs":[],"name":"HasActiveCertifications","type":"error"},{"inputs":[],"name":"InsufficientAvailableAmount","type":"error"},{"inputs":[],"name":"InvalidExecutorSignature","type":"error"},{"inputs":[],"name":"InvalidGuarantorSignature","type":"error"},{"inputs":[],"name":"NotAuthenticatedGuarantor","type":"error"},{"inputs":[],"name":"NotAuthorizedExecutor","type":"error"},{"inputs":[],"name":"NotCertificationGuarantor","type":"error"},{"inputs":[],"name":"NotCertificationOwner","type":"error"},{"inputs":[{"internalType":"address","name":"owner","type":"address"}],"name":"OwnableInvalidOwner","type":"error"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"OwnableUnauthorizedAccount","type":"error"},{"inputs":[],"name":"ReentrancyGuardReentrantCall","type":"error"},{"inputs":[{"internalType":"address","name":"token","type":"address"}],"name":"SafeERC20FailedOperation","type":"error"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"_newExecutor","type":"address"}],"name":"AddExecutor","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"string","name":"certId","type":"string"},{"indexed":false,"internalType":"address","name":"demanderAddr","type":"address"},{"indexed":false,"internalType":"address","name":"guarantorAddr","type":"address"},{"indexed":false,"internalType":"address","name":"tokenAddr","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"serviceFee","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"platformFee","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"penaltyRate","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"startTime","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"endTime","type":"uint256"}],"name":"CertCreated","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"string","name":"certId","type":"string"},{"indexed":false,"internalType":"address","name":"demanderAddr","type":"address"},{"indexed":false,"internalType":"address","name":"tokenAddr","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"CertFinished","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"string","name":"certId","type":"string"},{"indexed":false,"internalType":"address","name":"demanderAddr","type":"address"},{"indexed":false,"internalType":"address","name":"tokenAddr","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"CertFunded","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"string","name":"certId","type":"string"},{"indexed":false,"internalType":"address","name":"demanderAddr","type":"address"},{"indexed":false,"internalType":"address","name":"tokenAddr","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"fee","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"rate","type":"uint256"}],"name":"CertTerminated","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"_oldExecutor","type":"address"}],"name":"DelExecutor","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"string","name":"paidNo","type":"string"},{"indexed":false,"internalType":"string","name":"certId","type":"string"},{"indexed":false,"internalType":"address","name":"demanderAddr","type":"address"},{"indexed":false,"internalType":"address","name":"targetAddr","type":"address"},{"indexed":false,"internalType":"address","name":"tokenAddr","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"DemanderPaid","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"guarantorAddr","type":"address"},{"indexed":false,"internalType":"address","name":"tokenAddr","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"GuarantorAuthenticated","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"guarantorAddr","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"GuarantorDeregistered","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"string","name":"certId","type":"string"},{"indexed":false,"internalType":"address","name":"tokenAddr","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"},{"indexed":false,"internalType":"enum Guaranty.GuarantorIncomeType","name":"incomeType","type":"uint8"}],"name":"GuarantorIncome","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"string","name":"paidNo","type":"string"},{"indexed":false,"internalType":"string","name":"certId","type":"string"},{"indexed":false,"internalType":"address","name":"guarantorAddr","type":"address"},{"indexed":false,"internalType":"address","name":"targetAddr","type":"address"},{"indexed":false,"internalType":"address","name":"tokenAddr","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"GuarantorPaid","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":"string","name":"certId","type":"string"},{"indexed":false,"internalType":"address","name":"tokenAddr","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"PlatformIncome","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"guarantorAddr","type":"address"},{"indexed":false,"internalType":"address","name":"tokenAddr","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"UnclaimedIncome","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"tokenAddr","type":"address"},{"indexed":false,"internalType":"address","name":"guarantorAddr","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"WithdrawGFee","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"tokenAddr","type":"address"},{"indexed":false,"internalType":"address","name":"targetAddr","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"WithdrawPFee","type":"event"},{"inputs":[{"internalType":"address","name":"_newExecutor","type":"address"}],"name":"addExecutor","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"tokenAddr","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"uint256","name":"timestamp","type":"uint256"},{"internalType":"bytes","name":"signature","type":"bytes"}],"name":"authenticateGuarantor","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"string","name":"","type":"string"}],"name":"certifications","outputs":[{"internalType":"string","name":"certId","type":"string"},{"internalType":"address","name":"guarantor","type":"address"},{"internalType":"address","name":"demander","type":"address"},{"internalType":"address","name":"tokenAddr","type":"address"},{"internalType":"uint256","name":"startTime","type":"uint256"},{"internalType":"uint256","name":"endTime","type":"uint256"},{"internalType":"uint256","name":"guaranteeAmount","type":"uint256"},{"internalType":"uint256","name":"availableAmount","type":"uint256"},{"internalType":"uint256","name":"penaltyRate","type":"uint256"},{"internalType":"enum Guaranty.CertificationStatus","name":"status","type":"uint8"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"string","name":"certId","type":"string"},{"internalType":"address","name":"guarantorAddr","type":"address"},{"internalType":"address","name":"tokenAddr","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"uint256","name":"serviceFee","type":"uint256"},{"internalType":"uint256","name":"platformFee","type":"uint256"},{"internalType":"uint256","name":"penaltyRate","type":"uint256"},{"internalType":"uint256","name":"period","type":"uint256"},{"internalType":"uint256","name":"timestamp","type":"uint256"},{"internalType":"bytes","name":"signature","type":"bytes"}],"name":"createCertification","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_oldExecutor","type":"address"}],"name":"delExecutor","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"string","name":"paidNo","type":"string"},{"internalType":"string","name":"certId","type":"string"},{"internalType":"address","name":"targetAddr","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"demanderPaid","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"guarantorAddr","type":"address"}],"name":"deregisterGuarantor","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"feePool","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"string","name":"certId","type":"string"}],"name":"finishCertification","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"string","name":"certId","type":"string"},{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"uint256","name":"timestamp","type":"uint256"},{"internalType":"bytes","name":"signature","type":"bytes"}],"name":"fundCertification","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"string","name":"certId","type":"string"}],"name":"getCertificationInfo","outputs":[{"internalType":"uint256","name":"startTime","type":"uint256"},{"internalType":"uint256","name":"endTime","type":"uint256"},{"internalType":"uint256","name":"guaranteeAmount","type":"uint256"},{"internalType":"address","name":"tokenAddr","type":"address"},{"internalType":"address","name":"guarantorAddr","type":"address"},{"internalType":"address","name":"demanderAddr","type":"address"},{"internalType":"uint256","name":"availableAmount","type":"uint256"},{"internalType":"uint256","name":"penaltyRate","type":"uint256"},{"internalType":"enum Guaranty.CertificationStatus","name":"status","type":"uint8"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"guarantorAddr","type":"address"}],"name":"getGuarantorFee","outputs":[{"components":[{"internalType":"address","name":"tokenAddr","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"internalType":"struct Guaranty.TokenInfo[]","name":"fees","type":"tuple[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"guarantorAddr","type":"address"}],"name":"getGuarantorInfo","outputs":[{"internalType":"bool","name":"isAuthenticated","type":"bool"},{"internalType":"address","name":"tokenAddr","type":"address"},{"internalType":"uint256","name":"depositAmount","type":"uint256"},{"internalType":"uint256","name":"availableAmount","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getPlatformFee","outputs":[{"components":[{"internalType":"address","name":"tokenAddr","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"internalType":"struct Guaranty.TokenInfo[]","name":"fees","type":"tuple[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"guarantorCertNum","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"string","name":"paidNo","type":"string"},{"internalType":"string","name":"certId","type":"string"},{"internalType":"address","name":"targetAddr","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"guarantorPaid","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"guarantors","outputs":[{"internalType":"bool","name":"isAuthenticated","type":"bool"},{"internalType":"address","name":"tokenAddr","type":"address"},{"internalType":"uint256","name":"depositAmount","type":"uint256"},{"internalType":"uint256","name":"availableAmount","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"supportedTokens","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"string","name":"certId","type":"string"},{"internalType":"uint256","name":"timestamp","type":"uint256"},{"internalType":"bytes","name":"signature","type":"bytes"}],"name":"terminateCertification","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"guarantorAddr","type":"address"},{"internalType":"address[]","name":"tokenAddr","type":"address[]"},{"internalType":"uint256[]","name":"amount","type":"uint256[]"}],"name":"withdrawGuarantorFee","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"targetAddr","type":"address"},{"internalType":"address[]","name":"tokenAddr","type":"address[]"},{"internalType":"uint256[]","name":"amount","type":"uint256[]"}],"name":"withdrawPlatformFee","outputs":[],"stateMutability":"nonpayable","type":"function"}]Contract Creation Code
60806040523480156200001157600080fd5b5033806200003957604051631e4fbdf760e01b81526000600482015260240160405180910390fd5b62000044816200006a565b506001808055336000908152600760205260409020805460ff19169091179055620000ba565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b6138e380620000ca6000396000f3fe608060405234801561001057600080fd5b50600436106101585760003560e01c80636ea8bc10116100c3578063df0c03971161007c578063df0c039714610395578063f0d6e739146103a8578063f2fde38b146103bb578063fc6b38ad146103ce578063fd26fef1146103f7578063fefeb9421461041757600080fd5b80636ea8bc10146102fe578063715018a6146103065780638da5cb5b1461030e57806393b1c0be14610329578063978baed61461036f578063abbffd7f1461038257600080fd5b80634161a89f116101155780634161a89f1461025f578063479feffb1461027257806351263f3e1461028557806362f0e1bf146102a557806368c4ac26146102b85780636a12d691146102eb57600080fd5b806308cfddaa1461015d5780631f5a0bbe146101ce5780632f8dc0b1146101e3578063323c8fd7146101f6578063373a82291461021e5780633e99953014610231575b600080fd5b61019f61016b366004612ddc565b60046020526000908152604090208054600182015460029092015460ff8216926101009092046001600160a01b0316919084565b6040805194151585526001600160a01b0390931660208501529183015260608201526080015b60405180910390f35b6101e16101dc366004612ddc565b61042a565b005b6101e16101f1366004612ecb565b61048d565b61020961020436600461300b565b610739565b6040516101c599989796959493929190613071565b6101e161022c366004612ddc565b6108ea565b61025161023f366004612ddc565b60066020526000908152604090205481565b6040519081526020016101c5565b6101e161026d3660046130d0565b610b5a565b6101e1610280366004613146565b610ce4565b610298610293366004612ddc565b610f71565b6040516101c591906131a8565b6101e16102b3366004613200565b6110d1565b6102db6102c6366004612ddc565b60036020526000908152604090205460ff1681565b60405190151581526020016101c5565b6101e16102f936600461300b565b6114ac565b610298611676565b6101e16117ca565b6000546040516001600160a01b0390911681526020016101c5565b61019f610337366004612ddc565b6001600160a01b0390811660009081526004602052604090208054600182015460029092015460ff8216946101009092049093169290565b6101e161037d3660046132c0565b6117de565b6101e1610390366004612ecb565b61192e565b6101e16103a3366004613314565b611bca565b6101e16103b6366004613314565b611d7f565b6101e16103c9366004612ddc565b611ec7565b6103e16103dc36600461300b565b611f02565b6040516101c59a999897969594939291906133df565b610251610405366004612ddc565b60086020526000908152604090205481565b6101e1610425366004612ddc565b611ff9565b610432612052565b6001600160a01b038116600081815260076020908152604091829020805460ff1916600117905590519182527f93c7cc308c27512f308819cbaa4c96440f4f9d65281fad8e5ef00e47040f8b5d91015b60405180910390a150565b61049561207f565b6001600160a01b0383166104a7573392505b6001600160a01b0383166000908152600460205260409020805460ff166104e157604051638a0485f960e01b815260040160405180910390fd5b60005b835181101561072957600082600301600086848151811061050757610507613452565b60200260200101516001600160a01b03166001600160a01b0316815260200190815260200160002054905083828151811061054457610544613452565b6020026020010151600003610573578084838151811061056657610566613452565b6020026020010181815250505b83828151811061058557610585613452565b602002602001015160000361059a5750610717565b808483815181106105ad576105ad613452565b602002602001015111156105fb5760405162461bcd60e51b815260206004820152601060248201526f496e73756666696369656e742066656560801b60448201526064015b60405180910390fd5b83828151811061060d5761060d613452565b602002602001015183600301600087858151811061062d5761062d613452565b60200260200101516001600160a01b03166001600160a01b031681526020019081526020016000206000828254610664919061347e565b925050819055506106a885838151811061068057610680613452565b60200260200101518786858151811061069b5761069b613452565b60200260200101516120a9565b7f64c2af7a694cf88cf9a458a6e1dd6cea545679194c344bcf8a88f0862b1d69618583815181106106db576106db613452565b6020026020010151878685815181106106f6576106f6613452565b602002602001015160405161070d93929190613491565b60405180910390a1505b80610721816134b5565b9150506104e4565b505061073460018055565b505050565b60008060008060008060008060008060058b60405161075891906134ce565b908152602001604051809103902060405180610140016040529081600082018054610782906134ea565b80601f01602080910402602001604051908101604052809291908181526020018280546107ae906134ea565b80156107fb5780601f106107d0576101008083540402835291602001916107fb565b820191906000526020600020905b8154815290600101906020018083116107de57829003601f168201915b505050918352505060018201546001600160a01b039081166020830152600280840154821660408401526003840154909116606083015260048301546080830152600583015460a0830152600683015460c0830152600783015460e0830152600883015461010083015260098301546101209092019160ff169081111561088457610884613047565b600281111561089557610895613047565b81525050905080608001518160a001518260c001518360600151846020015185604001518660e00151876101000151886101200151995099509950995099509950995099509950509193959799909294969850565b3360009081526007602052604090205460ff161580156109245750336109186000546001600160a01b031690565b6001600160a01b031614155b1561094257604051631a75945360e21b815260040160405180910390fd5b61094a61207f565b6001600160a01b0381166000908152600460205260409020805460ff1661098457604051638a0485f960e01b815260040160405180910390fd5b6001600160a01b038216600090815260066020526040902054156109bb57604051639fbc65df60e01b815260040160405180910390fd5b805460ff191681556000600182018190556002820154156109fd5750600281018054600090915581546109fd9061010090046001600160a01b031684836120a9565b604080516001600160a01b0385168152602081018390527ff45125f67e34d1fd0b4e22eb323de75a5895ff2aaa3a14e4587e90a20338702b910160405180910390a16002548015610b4b576000915060005b81811015610b4957600060028281548110610a6c57610a6c613452565b60009182526020808320909101546001600160a01b031680835260038801909152604090912054945090508315610b36576001600160a01b038116600090815260038601602052604081208054869290610ac790849061347e565b90915550506001600160a01b03811660009081526008602052604081208054869290610af490849061351e565b90915550506040517ff6c9190ab9e587d44203b4057d1e911a8c6b0f5afbb5c00fe07a438b2adb662b90610b2d90889084908890613491565b60405180910390a15b5080610b41816134b5565b915050610a4f565b505b505050610b5760018055565b50565b610b6261207f565b610b6b826120bd565b610ba184338585604051602001610b859493929190613531565b6040516020818303038152906040528051906020012082612159565b6000600585604051610bb391906134ce565b90815260405190819003602001902090506001600982015460ff166002811115610bdf57610bdf613047565b141580610bf0575080600501544210155b15610c0e5760405163caa1497160e01b815260040160405180910390fd5b60028101546001600160a01b03163314610c3b57604051635108225f60e01b815260040160405180910390fd5b6003810154610c53906001600160a01b0316856121d5565b83816006016000828254610c67919061351e565b9250508190555083816007016000828254610c82919061351e565b909155505060038101546040517fe4beadee588b5258b127bbd695bdb882f13feb7d04941947a42e4edafdd42e8091610ccc91889133916001600160a01b03909116908990613569565b60405180910390a150610cde60018055565b50505050565b610cec61207f565b610cf5826120bd565b610d0d833384604051602001610b859392919061359f565b6000600584604051610d1f91906134ce565b90815260405190819003602001902090506001600982015460ff166002811115610d4b57610d4b613047565b14610d695760405163caa1497160e01b815260040160405180910390fd5b8060040154421080610d7e5750806005015442115b15610d9c57604051633d991c7760e01b815260040160405180910390fd5b60028101546001600160a01b03163314610dc957604051635108225f60e01b815260040160405180910390fd5b60098101805460ff191660021790556001808201546001600160a01b031660009081526006602052604081208054909190610e0590849061347e565b90915550506007810154600090819015610f095782600701549150612710836008015483610e3391906135cd565b610e3d91906135fa565b60018401546001600160a01b0390811660009081526004602090815260408083206003808a0154909516845293909301905290812080549293508392909190610e8790849061351e565b909155505060038301546040517f6dd04698d6369e1fc7f26b7de3cc578d1f8de62e7566a604446f1e745f1c243391610ed09189916001600160a01b031690859060019061360e565b60405180910390a16000600784015560038301546002840154610f09916001600160a01b039081169116610f04848661347e565b6120a9565b6002830154600384015460088501546040517fe2bf30fb6079aea4f533e84b8d79bb8e2be03d5fcd44a72792812674d0688b0b93610f5d938b936001600160a01b0392831693929091169188918891613658565b60405180910390a150505061073460018055565b60025460609080156110cb57806001600160401b03811115610f9557610f95612df7565b604051908082528060200260200182016040528015610fda57816020015b6040805180820190915260008082526020820152815260200190600190039081610fb35790505b50915060005b818110156110c95760028181548110610ffb57610ffb613452565b9060005260206000200160009054906101000a90046001600160a01b031683828151811061102b5761102b613452565b6020908102919091018101516001600160a01b039283169052908516600090815260049091526040812060028054600390920192918490811061107057611070613452565b60009182526020808320909101546001600160a01b0316835282019290925260400190205483518490839081106110a9576110a9613452565b6020908102919091018101510152806110c1816134b5565b915050610fe0565b505b50919050565b6110d961207f565b6110e2826120bd565b6111088a338b8b8b8b8b8b8b8b604051602001610b859a999897969594939291906136a0565b6001600160a01b0389166000908152600460205260409020805460ff166111425760405163dd4379a760e01b815260040160405180910390fd5b60008661114f898b61347e565b611159919061347e565b9050600081116111a15760405162461bcd60e51b8152602060048201526013602482015272125b9cdd59999a58da595b9d08185b5bdd5b9d606a1b60448201526064016105f2565b6111ab8a8a6121d5565b6111b48a6121e8565b60006111c36201518042613704565b6111cd904261347e565b905060006111de87620151806135cd565b6111e8908361351e565b90506040518061014001604052808f81526020018e6001600160a01b03168152602001336001600160a01b031681526020018d6001600160a01b031681526020018381526020018281526020018c81526020018481526020018981526020016001600281111561125a5761125a613047565b81525060058f60405161126d91906134ce565b9081526040519081900360200190208151819061128a908261375e565b506020820151600182810180546001600160a01b03199081166001600160a01b0394851617909155604085015160028086018054841692861692909217909155606086015160038601805490931694169390931790556080840151600484015560a0840151600584015560c0840151600684015560e0840151600784015561010084015160088401556101208401516009840180549193909260ff199092169190849081111561133c5761133c613047565b021790555050506001600160a01b038d16600090815260066020526040812080546001929061136c90849061351e565b90915550506001600160a01b038c16600090815260086020526040812080548b929061139990849061351e565b925050819055507f819255859451cb1d22ee7b16632a5dff1e1aae811a50bb210aa18a391f3e83ea8e8d8b6040516113d39392919061359f565b60405180910390a16001600160a01b038c166000908152600385016020526040812080548c929061140590849061351e565b925050819055507f6dd04698d6369e1fc7f26b7de3cc578d1f8de62e7566a604446f1e745f1c24338e8d8c6000604051611442949392919061360e565b60405180910390a17f4fbce2f54c601d1611f9f579b68be00e5ccca68ecd633e14ec9e555c132799028e338f8f8f8f8f8f8a8a60405161148b9a999897969594939291906136a0565b60405180910390a1505050506114a060018055565b50505050505050505050565b3360009081526007602052604090205460ff161580156114e65750336114da6000546001600160a01b031690565b6001600160a01b031614155b1561150457604051631a75945360e21b815260040160405180910390fd5b61150c61207f565b600060058260405161151e91906134ce565b90815260405190819003602001902090506001600982015460ff16600281111561154a5761154a613047565b146115685760405163caa1497160e01b815260040160405180910390fd5b80600401544211801561157e5750806005015442105b1561159c5760405163f4ccb25d60e01b815260040160405180910390fd5b60098101805460ff191660021790556001808201546001600160a01b0316600090815260066020526040812080549091906115d890849061347e565b90915550506007810154600090156116175750600781018054600090915560038201546002830154611617916001600160a01b039081169116836120a9565b600282015460038301546040517fdb46044070e997437f48c54bc1f631d4b764f9b2db668dd08c2b75cd2f3b14db926116639287926001600160a01b0392831692909116908690613569565b60405180910390a15050610b5760018055565b60025460609080156117c657806001600160401b0381111561169a5761169a612df7565b6040519080825280602002602001820160405280156116df57816020015b60408051808201909152600080825260208201528152602001906001900390816116b85790505b50915060005b818110156117c4576002818154811061170057611700613452565b9060005260206000200160009054906101000a90046001600160a01b031683828151811061173057611730613452565b6020026020010151600001906001600160a01b031690816001600160a01b031681525050600860006002838154811061176b5761176b613452565b60009182526020808320909101546001600160a01b0316835282019290925260400190205483518490839081106117a4576117a4613452565b6020908102919091018101510152806117bc816134b5565b9150506116e5565b505b5090565b6117d2612052565b6117dc600061226e565b565b6117e661207f565b6117ef826122be565b604080513360208201526001600160a01b03861691810191909152606081018490526080810183905261183b9060a0016040516020818303038152906040528051906020012082612313565b3360009081526004602052604090205460ff161561189b5760405162461bcd60e51b815260206004820152601860248201527f4475706c69636174652061757468656e7469636174696f6e000000000000000060448201526064016105f2565b6118a584846121d5565b6118ae846121e8565b3360008181526004602052604090819020805460016001600160a81b03199091166101006001600160a01b038a160217811782558101869055600201859055517f031d04f6a40e144a113c642f1005ad66a38fae6b723e0b4e055169e727b197939161191d9187908790613491565b60405180910390a1610cde60018055565b3360009081526007602052604090205460ff1615801561196857503361195c6000546001600160a01b031690565b6001600160a01b031614155b1561198657604051631a75945360e21b815260040160405180910390fd5b61198e61207f565b60005b8251811015611bc0576000600860008584815181106119b2576119b2613452565b60200260200101516001600160a01b03166001600160a01b031681526020019081526020016000205490508282815181106119ef576119ef613452565b6020026020010151600003611a1e5780838381518110611a1157611a11613452565b6020026020010181815250505b828281518110611a3057611a30613452565b6020026020010151600003611a455750611bae565b80838381518110611a5857611a58613452565b60200260200101511115611aa15760405162461bcd60e51b815260206004820152601060248201526f496e73756666696369656e742066656560801b60448201526064016105f2565b828281518110611ab357611ab3613452565b602002602001015160086000868581518110611ad157611ad1613452565b60200260200101516001600160a01b03166001600160a01b031681526020019081526020016000206000828254611b08919061347e565b92505081905550611b3f848381518110611b2457611b24613452565b60200260200101518685858151811061069b5761069b613452565b7ff8f5bbf0838cacfc546b920891c79cce3359e0e41c9d3462c23416a0488ab37b848381518110611b7257611b72613452565b602002602001015186858581518110611b8d57611b8d613452565b6020026020010151604051611ba493929190613491565b60405180910390a1505b80611bb8816134b5565b915050611991565b5061073460018055565b3360009081526007602052604090205460ff16158015611c04575033611bf86000546001600160a01b031690565b6001600160a01b031614155b15611c2257604051631a75945360e21b815260040160405180910390fd5b611c2a61207f565b6000600584604051611c3c91906134ce565b90815260405190819003602001902090506001600982015460ff166002811115611c6857611c68613047565b141580611c785750806004015442105b80611c865750806005015442115b15611ca45760405163caa1497160e01b815260040160405180910390fd5b60018101546001600160a01b031660009081526004602052604090206002810154831115611ce55760405163b35f6c3760e01b815260040160405180910390fd5b82816002016000828254611cf9919061347e565b90915550508054611d199061010090046001600160a01b031685856120a9565b600182015481546040517f6619f0dd4f318c9c029f8dc03a5333640d21c55b5c58590578f115400941769892611d6c928a928a926001600160a01b03908116928b92610100909104909116908a9061381d565b60405180910390a15050610cde60018055565b611d8761207f565b6000600584604051611d9991906134ce565b90815260405190819003602001902090506001600982015460ff166002811115611dc557611dc5613047565b141580611dd6575080600501544210155b15611df45760405163caa1497160e01b815260040160405180910390fd5b60018101546001600160a01b03163314611e2157604051632fc7075d60e11b815260040160405180910390fd5b8181600701541015611e465760405163b35f6c3760e01b815260040160405180910390fd5b81816007016000828254611e5a919061347e565b90915550506003810154611e78906001600160a01b031684846120a9565b600281015460038201546040517f9be6dbcaf4b06f543edce6f4d3f6652632b061bff8d611ca4c15fc19f982d05992610ccc92899289926001600160a01b03908116928a92911690899061381d565b611ecf612052565b6001600160a01b038116611ef957604051631e4fbdf760e01b8152600060048201526024016105f2565b610b578161226e565b8051602081830181018051600582529282019190930120915280548190611f28906134ea565b80601f0160208091040260200160405190810160405280929190818152602001828054611f54906134ea565b8015611fa15780601f10611f7657610100808354040283529160200191611fa1565b820191906000526020600020905b815481529060010190602001808311611f8457829003601f168201915b50505060018401546002850154600386015460048701546005880154600689015460078a015460088b01546009909b0154999a6001600160a01b039788169a9688169950949096169650919490939192909160ff168a565b612001612052565b6001600160a01b038116600081815260076020908152604091829020805460ff1916905590519182527fd96f2ee6fc90ccdacdc133ce2a13d876eae3a1d62033c54b39687920f85b11599101610482565b6000546001600160a01b031633146117dc5760405163118cdaa760e01b81523360048201526024016105f2565b6002600154036120a257604051633ee5aeb560e01b815260040160405180910390fd5b6002600155565b6107346001600160a01b0384168383612389565b8042116121055760405162461bcd60e51b8152602060048201526016602482015275496e76616c6964207369672074696d657374616d702160501b60448201526064016105f2565b62015180612113824261347e565b1115610b575760405162461bcd60e51b81526020600482015260156024820152745369672074696d657374616d70206578706972652160581b60448201526064016105f2565b7f19457468657265756d205369676e6564204d6573736167653a0a3332000000006000908152601c839052603c812060049190612197905b846127cf565b6001600160a01b0316815260208101919091526040016000205460ff166121d1576040516369790f8760e11b815260040160405180910390fd5b5050565b6121d16001600160a01b038316826127fb565b6001600160a01b03811660009081526003602052604090205460ff16610b57576001600160a01b03166000818152600360205260408120805460ff191660019081179091556002805491820181559091527f405787fa12a823e0f2b7631cc41b3ba8828b3321ca811111fa75cd3aa3bb5ace0180546001600160a01b0319169091179055565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b8042116123065760405162461bcd60e51b8152602060048201526016602482015275496e76616c6964207369672074696d657374616d702160501b60448201526064016105f2565b610e10612113824261347e565b7f19457468657265756d205369676e6564204d6573736167653a0a3332000000006000908152601c839052603c81206007919061234f90612191565b6001600160a01b0316815260208101919091526040016000205460ff166121d157604051638f4450b560e01b815260040160405180910390fd5b6001600160a01b0382166123d35760405162461bcd60e51b8152602060048201526011602482015270125b9d985b1a59081c9958da5c1a595b9d607a1b60448201526064016105f2565b6001600160a01b03831661243757804710156124245760405162461bcd60e51b815260206004820152601060248201526f092dce6eaccccd2c6d2cadce8408aa8960831b60448201526064016105f2565b6107346001600160a01b03831682612960565b6040516370a0823160e01b81523060048201526000906001600160a01b038516906370a0823190602401602060405180830381865afa15801561247e573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906124a29190613872565b9050818110156124eb5760405162461bcd60e51b8152602060048201526014602482015273496e73756666696369656e742062616c616e636560601b60448201526064016105f2565b6040516370a0823160e01b81526001600160a01b038481166004830152600091908616906370a0823190602401602060405180830381865afa158015612535573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906125599190613872565b6040516001600160a01b0386811660248301526044820186905291925060009187169060640160408051601f198184030181529181526020820180516001600160e01b031663a9059cbb60e01b179052516125b491906134ce565b6000604051808303816000865af19150503d80600081146125f1576040519150601f19603f3d011682016040523d82523d6000602084013e6125f6565b606091505b50509050806126475760405162461bcd60e51b815260206004820181905260248201527f455243323020746f6b656e207472616e736665722063616c6c206661696c656460448201526064016105f2565b612651848361351e565b6040516370a0823160e01b81526001600160a01b0387811660048301528816906370a0823190602401602060405180830381865afa158015612697573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906126bb9190613872565b146127085760405162461bcd60e51b815260206004820152601e60248201527f455243323020746f6b656e207472616e7366657220746f206661696c6564000060448201526064016105f2565b612712848461347e565b6040516370a0823160e01b81523060048201526001600160a01b038816906370a0823190602401602060405180830381865afa158015612756573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061277a9190613872565b146127c75760405162461bcd60e51b815260206004820181905260248201527f455243323020746f6b656e207472616e736665722066726f6d206661696c656460448201526064016105f2565b505050505050565b6000806000806127df86866129f7565b9250925092506127ef8282612a44565b50909150505b92915050565b6001600160a01b03821661284e57803410156121d15760405162461bcd60e51b8152602060048201526012602482015271496e73756666696369656e742076616c756560701b60448201526064016105f2565b6000811161288f5760405162461bcd60e51b815260206004820152600e60248201526d125b9d985b1a5908185b5bdd5b9d60921b60448201526064016105f2565b604051636eb1769f60e11b81523360048201523060248201526000906001600160a01b0384169063dd62ed3e90604401602060405180830381865afa1580156128dc573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906129009190613872565b90508181101561294b5760405162461bcd60e51b8152602060048201526016602482015275496e73756666696369656e7420616c6c6f77616e636560501b60448201526064016105f2565b6107346001600160a01b038416333085612afd565b804710156129835760405163cd78605960e01b81523060048201526024016105f2565b6000826001600160a01b03168260405160006040518083038185875af1925050503d80600081146129d0576040519150601f19603f3d011682016040523d82523d6000602084013e6129d5565b606091505b505090508061073457604051630a12f52160e11b815260040160405180910390fd5b60008060008351604103612a315760208401516040850151606086015160001a612a2388828585612b57565b955095509550505050612a3d565b50508151600091506002905b9250925092565b6000826003811115612a5857612a58613047565b03612a61575050565b6001826003811115612a7557612a75613047565b03612a935760405163f645eedf60e01b815260040160405180910390fd5b6002826003811115612aa757612aa7613047565b03612ac85760405163fce698f760e01b8152600481018290526024016105f2565b6003826003811115612adc57612adc613047565b036121d1576040516335e2f38360e21b8152600481018290526024016105f2565b610cde84856001600160a01b03166323b872dd868686604051602401612b2593929190613491565b604051602081830303815290604052915060e01b6020820180516001600160e01b038381831617835250505050612c26565b600080807f7fffffffffffffffffffffffffffffff5d576e7357a4501ddfe92f46681b20a0841115612b925750600091506003905082612c1c565b604080516000808252602082018084528a905260ff891692820192909252606081018790526080810186905260019060a0016020604051602081039080840390855afa158015612be6573d6000803e3d6000fd5b5050604051601f1901519150506001600160a01b038116612c1257506000925060019150829050612c1c565b9250600091508190505b9450945094915050565b6000612c3b6001600160a01b03841683612c89565b90508051600014158015612c60575080806020019051810190612c5e919061388b565b155b1561073457604051635274afe760e01b81526001600160a01b03841660048201526024016105f2565b6060612c9783836000612c9e565b9392505050565b606081471015612cc35760405163cd78605960e01b81523060048201526024016105f2565b600080856001600160a01b03168486604051612cdf91906134ce565b60006040518083038185875af1925050503d8060008114612d1c576040519150601f19603f3d011682016040523d82523d6000602084013e612d21565b606091505b5091509150612d31868383612d3b565b9695505050505050565b606082612d5057612d4b82612d97565b612c97565b8151158015612d6757506001600160a01b0384163b155b15612d9057604051639996b31560e01b81526001600160a01b03851660048201526024016105f2565b5080612c97565b805115612da75780518082602001fd5b604051630a12f52160e11b815260040160405180910390fd5b80356001600160a01b0381168114612dd757600080fd5b919050565b600060208284031215612dee57600080fd5b612c9782612dc0565b634e487b7160e01b600052604160045260246000fd5b604051601f8201601f191681016001600160401b0381118282101715612e3557612e35612df7565b604052919050565b60006001600160401b03821115612e5657612e56612df7565b5060051b60200190565b600082601f830112612e7157600080fd5b81356020612e86612e8183612e3d565b612e0d565b82815260059290921b84018101918181019086841115612ea557600080fd5b8286015b84811015612ec05780358352918301918301612ea9565b509695505050505050565b600080600060608486031215612ee057600080fd5b612ee984612dc0565b92506020808501356001600160401b0380821115612f0657600080fd5b818701915087601f830112612f1a57600080fd5b8135612f28612e8182612e3d565b81815260059190911b8301840190848101908a831115612f4757600080fd5b938501935b82851015612f6c57612f5d85612dc0565b82529385019390850190612f4c565b965050506040870135925080831115612f8457600080fd5b5050612f9286828701612e60565b9150509250925092565b600082601f830112612fad57600080fd5b81356001600160401b03811115612fc657612fc6612df7565b612fd9601f8201601f1916602001612e0d565b818152846020838601011115612fee57600080fd5b816020850160208301376000918101602001919091529392505050565b60006020828403121561301d57600080fd5b81356001600160401b0381111561303357600080fd5b61303f84828501612f9c565b949350505050565b634e487b7160e01b600052602160045260246000fd5b6003811061306d5761306d613047565b9052565b89815260208101899052604081018890526001600160a01b0387811660608301528681166080830152851660a082015260c0810184905260e0810183905261012081016130c261010083018461305d565b9a9950505050505050505050565b600080600080608085870312156130e657600080fd5b84356001600160401b03808211156130fd57600080fd5b61310988838901612f9c565b95506020870135945060408701359350606087013591508082111561312d57600080fd5b5061313a87828801612f9c565b91505092959194509250565b60008060006060848603121561315b57600080fd5b83356001600160401b038082111561317257600080fd5b61317e87838801612f9c565b945060208601359350604086013591508082111561319b57600080fd5b50612f9286828701612f9c565b602080825282518282018190526000919060409081850190868401855b828110156131f357815180516001600160a01b031685528601518685015292840192908501906001016131c5565b5091979650505050505050565b6000806000806000806000806000806101408b8d03121561322057600080fd5b8a356001600160401b038082111561323757600080fd5b6132438e838f01612f9c565b9b5061325160208e01612dc0565b9a5061325f60408e01612dc0565b995060608d0135985060808d0135975060a08d0135965060c08d0135955060e08d013594506101008d013593506101208d01359150808211156132a157600080fd5b506132ae8d828e01612f9c565b9150509295989b9194979a5092959850565b600080600080608085870312156132d657600080fd5b6132df85612dc0565b9350602085013592506040850135915060608501356001600160401b0381111561330857600080fd5b61313a87828801612f9c565b6000806000806080858703121561332a57600080fd5b84356001600160401b038082111561334157600080fd5b61334d88838901612f9c565b9550602087013591508082111561336357600080fd5b5061337087828801612f9c565b93505061337f60408601612dc0565b9396929550929360600135925050565b60005b838110156133aa578181015183820152602001613392565b50506000910152565b600081518084526133cb81602086016020860161338f565b601f01601f19169290920160200192915050565b60006101408083526133f38184018e6133b3565b91505060018060a01b03808c166020840152808b166040840152808a166060840152508760808301528660a08301528560c08301528460e08301528361010083015261344361012083018461305d565b9b9a5050505050505050505050565b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052601160045260246000fd5b818103818111156127f5576127f5613468565b6001600160a01b039384168152919092166020820152604081019190915260600190565b6000600182016134c7576134c7613468565b5060010190565b600082516134e081846020870161338f565b9190910192915050565b600181811c908216806134fe57607f821691505b6020821081036110cb57634e487b7160e01b600052602260045260246000fd5b808201808211156127f5576127f5613468565b60808152600061354460808301876133b3565b6001600160a01b03959095166020830152506040810192909252606090910152919050565b60808152600061357c60808301876133b3565b6001600160a01b0395861660208401529390941660408201526060015292915050565b6060815260006135b260608301866133b3565b6001600160a01b039490941660208301525060400152919050565b80820281158282048414176127f5576127f5613468565b634e487b7160e01b600052601260045260246000fd5b600082613609576136096135e4565b500490565b60808152600061362160808301876133b3565b6001600160a01b03861660208401526040830185905290506002831061364957613649613047565b82606083015295945050505050565b60c08152600061366b60c08301896133b3565b6001600160a01b0397881660208401529590961660408201526060810193909352608083019190915260a09091015292915050565b60006101408083526136b48184018e6133b3565b6001600160a01b039c8d1660208501529a8c1660408401525050969098166060870152608086019490945260a085019290925260c084015260e08301526101008201526101200191909152919050565b600082613713576137136135e4565b500690565b601f82111561073457600081815260208120601f850160051c8101602086101561373f5750805b601f850160051c820191505b818110156127c75782815560010161374b565b81516001600160401b0381111561377757613777612df7565b61378b8161378584546134ea565b84613718565b602080601f8311600181146137c057600084156137a85750858301515b600019600386901b1c1916600185901b1785556127c7565b600085815260208120601f198616915b828110156137ef578886015182559484019460019091019084016137d0565b508582101561380d5787850151600019600388901b60f8161c191681555b5050505050600190811b01905550565b60c08152600061383060c08301896133b3565b828103602084015261384281896133b3565b6001600160a01b0397881660408501529587166060840152505091909316608082015260a0019190915292915050565b60006020828403121561388457600080fd5b5051919050565b60006020828403121561389d57600080fd5b81518015158114612c9757600080fdfea26469706673582212200aefe90cebfc7e816985a9bcda7657980781b3ed301eb865f948638c8e9f224764736f6c63430008140033
Deployed Bytecode
0x608060405234801561001057600080fd5b50600436106101585760003560e01c80636ea8bc10116100c3578063df0c03971161007c578063df0c039714610395578063f0d6e739146103a8578063f2fde38b146103bb578063fc6b38ad146103ce578063fd26fef1146103f7578063fefeb9421461041757600080fd5b80636ea8bc10146102fe578063715018a6146103065780638da5cb5b1461030e57806393b1c0be14610329578063978baed61461036f578063abbffd7f1461038257600080fd5b80634161a89f116101155780634161a89f1461025f578063479feffb1461027257806351263f3e1461028557806362f0e1bf146102a557806368c4ac26146102b85780636a12d691146102eb57600080fd5b806308cfddaa1461015d5780631f5a0bbe146101ce5780632f8dc0b1146101e3578063323c8fd7146101f6578063373a82291461021e5780633e99953014610231575b600080fd5b61019f61016b366004612ddc565b60046020526000908152604090208054600182015460029092015460ff8216926101009092046001600160a01b0316919084565b6040805194151585526001600160a01b0390931660208501529183015260608201526080015b60405180910390f35b6101e16101dc366004612ddc565b61042a565b005b6101e16101f1366004612ecb565b61048d565b61020961020436600461300b565b610739565b6040516101c599989796959493929190613071565b6101e161022c366004612ddc565b6108ea565b61025161023f366004612ddc565b60066020526000908152604090205481565b6040519081526020016101c5565b6101e161026d3660046130d0565b610b5a565b6101e1610280366004613146565b610ce4565b610298610293366004612ddc565b610f71565b6040516101c591906131a8565b6101e16102b3366004613200565b6110d1565b6102db6102c6366004612ddc565b60036020526000908152604090205460ff1681565b60405190151581526020016101c5565b6101e16102f936600461300b565b6114ac565b610298611676565b6101e16117ca565b6000546040516001600160a01b0390911681526020016101c5565b61019f610337366004612ddc565b6001600160a01b0390811660009081526004602052604090208054600182015460029092015460ff8216946101009092049093169290565b6101e161037d3660046132c0565b6117de565b6101e1610390366004612ecb565b61192e565b6101e16103a3366004613314565b611bca565b6101e16103b6366004613314565b611d7f565b6101e16103c9366004612ddc565b611ec7565b6103e16103dc36600461300b565b611f02565b6040516101c59a999897969594939291906133df565b610251610405366004612ddc565b60086020526000908152604090205481565b6101e1610425366004612ddc565b611ff9565b610432612052565b6001600160a01b038116600081815260076020908152604091829020805460ff1916600117905590519182527f93c7cc308c27512f308819cbaa4c96440f4f9d65281fad8e5ef00e47040f8b5d91015b60405180910390a150565b61049561207f565b6001600160a01b0383166104a7573392505b6001600160a01b0383166000908152600460205260409020805460ff166104e157604051638a0485f960e01b815260040160405180910390fd5b60005b835181101561072957600082600301600086848151811061050757610507613452565b60200260200101516001600160a01b03166001600160a01b0316815260200190815260200160002054905083828151811061054457610544613452565b6020026020010151600003610573578084838151811061056657610566613452565b6020026020010181815250505b83828151811061058557610585613452565b602002602001015160000361059a5750610717565b808483815181106105ad576105ad613452565b602002602001015111156105fb5760405162461bcd60e51b815260206004820152601060248201526f496e73756666696369656e742066656560801b60448201526064015b60405180910390fd5b83828151811061060d5761060d613452565b602002602001015183600301600087858151811061062d5761062d613452565b60200260200101516001600160a01b03166001600160a01b031681526020019081526020016000206000828254610664919061347e565b925050819055506106a885838151811061068057610680613452565b60200260200101518786858151811061069b5761069b613452565b60200260200101516120a9565b7f64c2af7a694cf88cf9a458a6e1dd6cea545679194c344bcf8a88f0862b1d69618583815181106106db576106db613452565b6020026020010151878685815181106106f6576106f6613452565b602002602001015160405161070d93929190613491565b60405180910390a1505b80610721816134b5565b9150506104e4565b505061073460018055565b505050565b60008060008060008060008060008060058b60405161075891906134ce565b908152602001604051809103902060405180610140016040529081600082018054610782906134ea565b80601f01602080910402602001604051908101604052809291908181526020018280546107ae906134ea565b80156107fb5780601f106107d0576101008083540402835291602001916107fb565b820191906000526020600020905b8154815290600101906020018083116107de57829003601f168201915b505050918352505060018201546001600160a01b039081166020830152600280840154821660408401526003840154909116606083015260048301546080830152600583015460a0830152600683015460c0830152600783015460e0830152600883015461010083015260098301546101209092019160ff169081111561088457610884613047565b600281111561089557610895613047565b81525050905080608001518160a001518260c001518360600151846020015185604001518660e00151876101000151886101200151995099509950995099509950995099509950509193959799909294969850565b3360009081526007602052604090205460ff161580156109245750336109186000546001600160a01b031690565b6001600160a01b031614155b1561094257604051631a75945360e21b815260040160405180910390fd5b61094a61207f565b6001600160a01b0381166000908152600460205260409020805460ff1661098457604051638a0485f960e01b815260040160405180910390fd5b6001600160a01b038216600090815260066020526040902054156109bb57604051639fbc65df60e01b815260040160405180910390fd5b805460ff191681556000600182018190556002820154156109fd5750600281018054600090915581546109fd9061010090046001600160a01b031684836120a9565b604080516001600160a01b0385168152602081018390527ff45125f67e34d1fd0b4e22eb323de75a5895ff2aaa3a14e4587e90a20338702b910160405180910390a16002548015610b4b576000915060005b81811015610b4957600060028281548110610a6c57610a6c613452565b60009182526020808320909101546001600160a01b031680835260038801909152604090912054945090508315610b36576001600160a01b038116600090815260038601602052604081208054869290610ac790849061347e565b90915550506001600160a01b03811660009081526008602052604081208054869290610af490849061351e565b90915550506040517ff6c9190ab9e587d44203b4057d1e911a8c6b0f5afbb5c00fe07a438b2adb662b90610b2d90889084908890613491565b60405180910390a15b5080610b41816134b5565b915050610a4f565b505b505050610b5760018055565b50565b610b6261207f565b610b6b826120bd565b610ba184338585604051602001610b859493929190613531565b6040516020818303038152906040528051906020012082612159565b6000600585604051610bb391906134ce565b90815260405190819003602001902090506001600982015460ff166002811115610bdf57610bdf613047565b141580610bf0575080600501544210155b15610c0e5760405163caa1497160e01b815260040160405180910390fd5b60028101546001600160a01b03163314610c3b57604051635108225f60e01b815260040160405180910390fd5b6003810154610c53906001600160a01b0316856121d5565b83816006016000828254610c67919061351e565b9250508190555083816007016000828254610c82919061351e565b909155505060038101546040517fe4beadee588b5258b127bbd695bdb882f13feb7d04941947a42e4edafdd42e8091610ccc91889133916001600160a01b03909116908990613569565b60405180910390a150610cde60018055565b50505050565b610cec61207f565b610cf5826120bd565b610d0d833384604051602001610b859392919061359f565b6000600584604051610d1f91906134ce565b90815260405190819003602001902090506001600982015460ff166002811115610d4b57610d4b613047565b14610d695760405163caa1497160e01b815260040160405180910390fd5b8060040154421080610d7e5750806005015442115b15610d9c57604051633d991c7760e01b815260040160405180910390fd5b60028101546001600160a01b03163314610dc957604051635108225f60e01b815260040160405180910390fd5b60098101805460ff191660021790556001808201546001600160a01b031660009081526006602052604081208054909190610e0590849061347e565b90915550506007810154600090819015610f095782600701549150612710836008015483610e3391906135cd565b610e3d91906135fa565b60018401546001600160a01b0390811660009081526004602090815260408083206003808a0154909516845293909301905290812080549293508392909190610e8790849061351e565b909155505060038301546040517f6dd04698d6369e1fc7f26b7de3cc578d1f8de62e7566a604446f1e745f1c243391610ed09189916001600160a01b031690859060019061360e565b60405180910390a16000600784015560038301546002840154610f09916001600160a01b039081169116610f04848661347e565b6120a9565b6002830154600384015460088501546040517fe2bf30fb6079aea4f533e84b8d79bb8e2be03d5fcd44a72792812674d0688b0b93610f5d938b936001600160a01b0392831693929091169188918891613658565b60405180910390a150505061073460018055565b60025460609080156110cb57806001600160401b03811115610f9557610f95612df7565b604051908082528060200260200182016040528015610fda57816020015b6040805180820190915260008082526020820152815260200190600190039081610fb35790505b50915060005b818110156110c95760028181548110610ffb57610ffb613452565b9060005260206000200160009054906101000a90046001600160a01b031683828151811061102b5761102b613452565b6020908102919091018101516001600160a01b039283169052908516600090815260049091526040812060028054600390920192918490811061107057611070613452565b60009182526020808320909101546001600160a01b0316835282019290925260400190205483518490839081106110a9576110a9613452565b6020908102919091018101510152806110c1816134b5565b915050610fe0565b505b50919050565b6110d961207f565b6110e2826120bd565b6111088a338b8b8b8b8b8b8b8b604051602001610b859a999897969594939291906136a0565b6001600160a01b0389166000908152600460205260409020805460ff166111425760405163dd4379a760e01b815260040160405180910390fd5b60008661114f898b61347e565b611159919061347e565b9050600081116111a15760405162461bcd60e51b8152602060048201526013602482015272125b9cdd59999a58da595b9d08185b5bdd5b9d606a1b60448201526064016105f2565b6111ab8a8a6121d5565b6111b48a6121e8565b60006111c36201518042613704565b6111cd904261347e565b905060006111de87620151806135cd565b6111e8908361351e565b90506040518061014001604052808f81526020018e6001600160a01b03168152602001336001600160a01b031681526020018d6001600160a01b031681526020018381526020018281526020018c81526020018481526020018981526020016001600281111561125a5761125a613047565b81525060058f60405161126d91906134ce565b9081526040519081900360200190208151819061128a908261375e565b506020820151600182810180546001600160a01b03199081166001600160a01b0394851617909155604085015160028086018054841692861692909217909155606086015160038601805490931694169390931790556080840151600484015560a0840151600584015560c0840151600684015560e0840151600784015561010084015160088401556101208401516009840180549193909260ff199092169190849081111561133c5761133c613047565b021790555050506001600160a01b038d16600090815260066020526040812080546001929061136c90849061351e565b90915550506001600160a01b038c16600090815260086020526040812080548b929061139990849061351e565b925050819055507f819255859451cb1d22ee7b16632a5dff1e1aae811a50bb210aa18a391f3e83ea8e8d8b6040516113d39392919061359f565b60405180910390a16001600160a01b038c166000908152600385016020526040812080548c929061140590849061351e565b925050819055507f6dd04698d6369e1fc7f26b7de3cc578d1f8de62e7566a604446f1e745f1c24338e8d8c6000604051611442949392919061360e565b60405180910390a17f4fbce2f54c601d1611f9f579b68be00e5ccca68ecd633e14ec9e555c132799028e338f8f8f8f8f8f8a8a60405161148b9a999897969594939291906136a0565b60405180910390a1505050506114a060018055565b50505050505050505050565b3360009081526007602052604090205460ff161580156114e65750336114da6000546001600160a01b031690565b6001600160a01b031614155b1561150457604051631a75945360e21b815260040160405180910390fd5b61150c61207f565b600060058260405161151e91906134ce565b90815260405190819003602001902090506001600982015460ff16600281111561154a5761154a613047565b146115685760405163caa1497160e01b815260040160405180910390fd5b80600401544211801561157e5750806005015442105b1561159c5760405163f4ccb25d60e01b815260040160405180910390fd5b60098101805460ff191660021790556001808201546001600160a01b0316600090815260066020526040812080549091906115d890849061347e565b90915550506007810154600090156116175750600781018054600090915560038201546002830154611617916001600160a01b039081169116836120a9565b600282015460038301546040517fdb46044070e997437f48c54bc1f631d4b764f9b2db668dd08c2b75cd2f3b14db926116639287926001600160a01b0392831692909116908690613569565b60405180910390a15050610b5760018055565b60025460609080156117c657806001600160401b0381111561169a5761169a612df7565b6040519080825280602002602001820160405280156116df57816020015b60408051808201909152600080825260208201528152602001906001900390816116b85790505b50915060005b818110156117c4576002818154811061170057611700613452565b9060005260206000200160009054906101000a90046001600160a01b031683828151811061173057611730613452565b6020026020010151600001906001600160a01b031690816001600160a01b031681525050600860006002838154811061176b5761176b613452565b60009182526020808320909101546001600160a01b0316835282019290925260400190205483518490839081106117a4576117a4613452565b6020908102919091018101510152806117bc816134b5565b9150506116e5565b505b5090565b6117d2612052565b6117dc600061226e565b565b6117e661207f565b6117ef826122be565b604080513360208201526001600160a01b03861691810191909152606081018490526080810183905261183b9060a0016040516020818303038152906040528051906020012082612313565b3360009081526004602052604090205460ff161561189b5760405162461bcd60e51b815260206004820152601860248201527f4475706c69636174652061757468656e7469636174696f6e000000000000000060448201526064016105f2565b6118a584846121d5565b6118ae846121e8565b3360008181526004602052604090819020805460016001600160a81b03199091166101006001600160a01b038a160217811782558101869055600201859055517f031d04f6a40e144a113c642f1005ad66a38fae6b723e0b4e055169e727b197939161191d9187908790613491565b60405180910390a1610cde60018055565b3360009081526007602052604090205460ff1615801561196857503361195c6000546001600160a01b031690565b6001600160a01b031614155b1561198657604051631a75945360e21b815260040160405180910390fd5b61198e61207f565b60005b8251811015611bc0576000600860008584815181106119b2576119b2613452565b60200260200101516001600160a01b03166001600160a01b031681526020019081526020016000205490508282815181106119ef576119ef613452565b6020026020010151600003611a1e5780838381518110611a1157611a11613452565b6020026020010181815250505b828281518110611a3057611a30613452565b6020026020010151600003611a455750611bae565b80838381518110611a5857611a58613452565b60200260200101511115611aa15760405162461bcd60e51b815260206004820152601060248201526f496e73756666696369656e742066656560801b60448201526064016105f2565b828281518110611ab357611ab3613452565b602002602001015160086000868581518110611ad157611ad1613452565b60200260200101516001600160a01b03166001600160a01b031681526020019081526020016000206000828254611b08919061347e565b92505081905550611b3f848381518110611b2457611b24613452565b60200260200101518685858151811061069b5761069b613452565b7ff8f5bbf0838cacfc546b920891c79cce3359e0e41c9d3462c23416a0488ab37b848381518110611b7257611b72613452565b602002602001015186858581518110611b8d57611b8d613452565b6020026020010151604051611ba493929190613491565b60405180910390a1505b80611bb8816134b5565b915050611991565b5061073460018055565b3360009081526007602052604090205460ff16158015611c04575033611bf86000546001600160a01b031690565b6001600160a01b031614155b15611c2257604051631a75945360e21b815260040160405180910390fd5b611c2a61207f565b6000600584604051611c3c91906134ce565b90815260405190819003602001902090506001600982015460ff166002811115611c6857611c68613047565b141580611c785750806004015442105b80611c865750806005015442115b15611ca45760405163caa1497160e01b815260040160405180910390fd5b60018101546001600160a01b031660009081526004602052604090206002810154831115611ce55760405163b35f6c3760e01b815260040160405180910390fd5b82816002016000828254611cf9919061347e565b90915550508054611d199061010090046001600160a01b031685856120a9565b600182015481546040517f6619f0dd4f318c9c029f8dc03a5333640d21c55b5c58590578f115400941769892611d6c928a928a926001600160a01b03908116928b92610100909104909116908a9061381d565b60405180910390a15050610cde60018055565b611d8761207f565b6000600584604051611d9991906134ce565b90815260405190819003602001902090506001600982015460ff166002811115611dc557611dc5613047565b141580611dd6575080600501544210155b15611df45760405163caa1497160e01b815260040160405180910390fd5b60018101546001600160a01b03163314611e2157604051632fc7075d60e11b815260040160405180910390fd5b8181600701541015611e465760405163b35f6c3760e01b815260040160405180910390fd5b81816007016000828254611e5a919061347e565b90915550506003810154611e78906001600160a01b031684846120a9565b600281015460038201546040517f9be6dbcaf4b06f543edce6f4d3f6652632b061bff8d611ca4c15fc19f982d05992610ccc92899289926001600160a01b03908116928a92911690899061381d565b611ecf612052565b6001600160a01b038116611ef957604051631e4fbdf760e01b8152600060048201526024016105f2565b610b578161226e565b8051602081830181018051600582529282019190930120915280548190611f28906134ea565b80601f0160208091040260200160405190810160405280929190818152602001828054611f54906134ea565b8015611fa15780601f10611f7657610100808354040283529160200191611fa1565b820191906000526020600020905b815481529060010190602001808311611f8457829003601f168201915b50505060018401546002850154600386015460048701546005880154600689015460078a015460088b01546009909b0154999a6001600160a01b039788169a9688169950949096169650919490939192909160ff168a565b612001612052565b6001600160a01b038116600081815260076020908152604091829020805460ff1916905590519182527fd96f2ee6fc90ccdacdc133ce2a13d876eae3a1d62033c54b39687920f85b11599101610482565b6000546001600160a01b031633146117dc5760405163118cdaa760e01b81523360048201526024016105f2565b6002600154036120a257604051633ee5aeb560e01b815260040160405180910390fd5b6002600155565b6107346001600160a01b0384168383612389565b8042116121055760405162461bcd60e51b8152602060048201526016602482015275496e76616c6964207369672074696d657374616d702160501b60448201526064016105f2565b62015180612113824261347e565b1115610b575760405162461bcd60e51b81526020600482015260156024820152745369672074696d657374616d70206578706972652160581b60448201526064016105f2565b7f19457468657265756d205369676e6564204d6573736167653a0a3332000000006000908152601c839052603c812060049190612197905b846127cf565b6001600160a01b0316815260208101919091526040016000205460ff166121d1576040516369790f8760e11b815260040160405180910390fd5b5050565b6121d16001600160a01b038316826127fb565b6001600160a01b03811660009081526003602052604090205460ff16610b57576001600160a01b03166000818152600360205260408120805460ff191660019081179091556002805491820181559091527f405787fa12a823e0f2b7631cc41b3ba8828b3321ca811111fa75cd3aa3bb5ace0180546001600160a01b0319169091179055565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b8042116123065760405162461bcd60e51b8152602060048201526016602482015275496e76616c6964207369672074696d657374616d702160501b60448201526064016105f2565b610e10612113824261347e565b7f19457468657265756d205369676e6564204d6573736167653a0a3332000000006000908152601c839052603c81206007919061234f90612191565b6001600160a01b0316815260208101919091526040016000205460ff166121d157604051638f4450b560e01b815260040160405180910390fd5b6001600160a01b0382166123d35760405162461bcd60e51b8152602060048201526011602482015270125b9d985b1a59081c9958da5c1a595b9d607a1b60448201526064016105f2565b6001600160a01b03831661243757804710156124245760405162461bcd60e51b815260206004820152601060248201526f092dce6eaccccd2c6d2cadce8408aa8960831b60448201526064016105f2565b6107346001600160a01b03831682612960565b6040516370a0823160e01b81523060048201526000906001600160a01b038516906370a0823190602401602060405180830381865afa15801561247e573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906124a29190613872565b9050818110156124eb5760405162461bcd60e51b8152602060048201526014602482015273496e73756666696369656e742062616c616e636560601b60448201526064016105f2565b6040516370a0823160e01b81526001600160a01b038481166004830152600091908616906370a0823190602401602060405180830381865afa158015612535573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906125599190613872565b6040516001600160a01b0386811660248301526044820186905291925060009187169060640160408051601f198184030181529181526020820180516001600160e01b031663a9059cbb60e01b179052516125b491906134ce565b6000604051808303816000865af19150503d80600081146125f1576040519150601f19603f3d011682016040523d82523d6000602084013e6125f6565b606091505b50509050806126475760405162461bcd60e51b815260206004820181905260248201527f455243323020746f6b656e207472616e736665722063616c6c206661696c656460448201526064016105f2565b612651848361351e565b6040516370a0823160e01b81526001600160a01b0387811660048301528816906370a0823190602401602060405180830381865afa158015612697573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906126bb9190613872565b146127085760405162461bcd60e51b815260206004820152601e60248201527f455243323020746f6b656e207472616e7366657220746f206661696c6564000060448201526064016105f2565b612712848461347e565b6040516370a0823160e01b81523060048201526001600160a01b038816906370a0823190602401602060405180830381865afa158015612756573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061277a9190613872565b146127c75760405162461bcd60e51b815260206004820181905260248201527f455243323020746f6b656e207472616e736665722066726f6d206661696c656460448201526064016105f2565b505050505050565b6000806000806127df86866129f7565b9250925092506127ef8282612a44565b50909150505b92915050565b6001600160a01b03821661284e57803410156121d15760405162461bcd60e51b8152602060048201526012602482015271496e73756666696369656e742076616c756560701b60448201526064016105f2565b6000811161288f5760405162461bcd60e51b815260206004820152600e60248201526d125b9d985b1a5908185b5bdd5b9d60921b60448201526064016105f2565b604051636eb1769f60e11b81523360048201523060248201526000906001600160a01b0384169063dd62ed3e90604401602060405180830381865afa1580156128dc573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906129009190613872565b90508181101561294b5760405162461bcd60e51b8152602060048201526016602482015275496e73756666696369656e7420616c6c6f77616e636560501b60448201526064016105f2565b6107346001600160a01b038416333085612afd565b804710156129835760405163cd78605960e01b81523060048201526024016105f2565b6000826001600160a01b03168260405160006040518083038185875af1925050503d80600081146129d0576040519150601f19603f3d011682016040523d82523d6000602084013e6129d5565b606091505b505090508061073457604051630a12f52160e11b815260040160405180910390fd5b60008060008351604103612a315760208401516040850151606086015160001a612a2388828585612b57565b955095509550505050612a3d565b50508151600091506002905b9250925092565b6000826003811115612a5857612a58613047565b03612a61575050565b6001826003811115612a7557612a75613047565b03612a935760405163f645eedf60e01b815260040160405180910390fd5b6002826003811115612aa757612aa7613047565b03612ac85760405163fce698f760e01b8152600481018290526024016105f2565b6003826003811115612adc57612adc613047565b036121d1576040516335e2f38360e21b8152600481018290526024016105f2565b610cde84856001600160a01b03166323b872dd868686604051602401612b2593929190613491565b604051602081830303815290604052915060e01b6020820180516001600160e01b038381831617835250505050612c26565b600080807f7fffffffffffffffffffffffffffffff5d576e7357a4501ddfe92f46681b20a0841115612b925750600091506003905082612c1c565b604080516000808252602082018084528a905260ff891692820192909252606081018790526080810186905260019060a0016020604051602081039080840390855afa158015612be6573d6000803e3d6000fd5b5050604051601f1901519150506001600160a01b038116612c1257506000925060019150829050612c1c565b9250600091508190505b9450945094915050565b6000612c3b6001600160a01b03841683612c89565b90508051600014158015612c60575080806020019051810190612c5e919061388b565b155b1561073457604051635274afe760e01b81526001600160a01b03841660048201526024016105f2565b6060612c9783836000612c9e565b9392505050565b606081471015612cc35760405163cd78605960e01b81523060048201526024016105f2565b600080856001600160a01b03168486604051612cdf91906134ce565b60006040518083038185875af1925050503d8060008114612d1c576040519150601f19603f3d011682016040523d82523d6000602084013e612d21565b606091505b5091509150612d31868383612d3b565b9695505050505050565b606082612d5057612d4b82612d97565b612c97565b8151158015612d6757506001600160a01b0384163b155b15612d9057604051639996b31560e01b81526001600160a01b03851660048201526024016105f2565b5080612c97565b805115612da75780518082602001fd5b604051630a12f52160e11b815260040160405180910390fd5b80356001600160a01b0381168114612dd757600080fd5b919050565b600060208284031215612dee57600080fd5b612c9782612dc0565b634e487b7160e01b600052604160045260246000fd5b604051601f8201601f191681016001600160401b0381118282101715612e3557612e35612df7565b604052919050565b60006001600160401b03821115612e5657612e56612df7565b5060051b60200190565b600082601f830112612e7157600080fd5b81356020612e86612e8183612e3d565b612e0d565b82815260059290921b84018101918181019086841115612ea557600080fd5b8286015b84811015612ec05780358352918301918301612ea9565b509695505050505050565b600080600060608486031215612ee057600080fd5b612ee984612dc0565b92506020808501356001600160401b0380821115612f0657600080fd5b818701915087601f830112612f1a57600080fd5b8135612f28612e8182612e3d565b81815260059190911b8301840190848101908a831115612f4757600080fd5b938501935b82851015612f6c57612f5d85612dc0565b82529385019390850190612f4c565b965050506040870135925080831115612f8457600080fd5b5050612f9286828701612e60565b9150509250925092565b600082601f830112612fad57600080fd5b81356001600160401b03811115612fc657612fc6612df7565b612fd9601f8201601f1916602001612e0d565b818152846020838601011115612fee57600080fd5b816020850160208301376000918101602001919091529392505050565b60006020828403121561301d57600080fd5b81356001600160401b0381111561303357600080fd5b61303f84828501612f9c565b949350505050565b634e487b7160e01b600052602160045260246000fd5b6003811061306d5761306d613047565b9052565b89815260208101899052604081018890526001600160a01b0387811660608301528681166080830152851660a082015260c0810184905260e0810183905261012081016130c261010083018461305d565b9a9950505050505050505050565b600080600080608085870312156130e657600080fd5b84356001600160401b03808211156130fd57600080fd5b61310988838901612f9c565b95506020870135945060408701359350606087013591508082111561312d57600080fd5b5061313a87828801612f9c565b91505092959194509250565b60008060006060848603121561315b57600080fd5b83356001600160401b038082111561317257600080fd5b61317e87838801612f9c565b945060208601359350604086013591508082111561319b57600080fd5b50612f9286828701612f9c565b602080825282518282018190526000919060409081850190868401855b828110156131f357815180516001600160a01b031685528601518685015292840192908501906001016131c5565b5091979650505050505050565b6000806000806000806000806000806101408b8d03121561322057600080fd5b8a356001600160401b038082111561323757600080fd5b6132438e838f01612f9c565b9b5061325160208e01612dc0565b9a5061325f60408e01612dc0565b995060608d0135985060808d0135975060a08d0135965060c08d0135955060e08d013594506101008d013593506101208d01359150808211156132a157600080fd5b506132ae8d828e01612f9c565b9150509295989b9194979a5092959850565b600080600080608085870312156132d657600080fd5b6132df85612dc0565b9350602085013592506040850135915060608501356001600160401b0381111561330857600080fd5b61313a87828801612f9c565b6000806000806080858703121561332a57600080fd5b84356001600160401b038082111561334157600080fd5b61334d88838901612f9c565b9550602087013591508082111561336357600080fd5b5061337087828801612f9c565b93505061337f60408601612dc0565b9396929550929360600135925050565b60005b838110156133aa578181015183820152602001613392565b50506000910152565b600081518084526133cb81602086016020860161338f565b601f01601f19169290920160200192915050565b60006101408083526133f38184018e6133b3565b91505060018060a01b03808c166020840152808b166040840152808a166060840152508760808301528660a08301528560c08301528460e08301528361010083015261344361012083018461305d565b9b9a5050505050505050505050565b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052601160045260246000fd5b818103818111156127f5576127f5613468565b6001600160a01b039384168152919092166020820152604081019190915260600190565b6000600182016134c7576134c7613468565b5060010190565b600082516134e081846020870161338f565b9190910192915050565b600181811c908216806134fe57607f821691505b6020821081036110cb57634e487b7160e01b600052602260045260246000fd5b808201808211156127f5576127f5613468565b60808152600061354460808301876133b3565b6001600160a01b03959095166020830152506040810192909252606090910152919050565b60808152600061357c60808301876133b3565b6001600160a01b0395861660208401529390941660408201526060015292915050565b6060815260006135b260608301866133b3565b6001600160a01b039490941660208301525060400152919050565b80820281158282048414176127f5576127f5613468565b634e487b7160e01b600052601260045260246000fd5b600082613609576136096135e4565b500490565b60808152600061362160808301876133b3565b6001600160a01b03861660208401526040830185905290506002831061364957613649613047565b82606083015295945050505050565b60c08152600061366b60c08301896133b3565b6001600160a01b0397881660208401529590961660408201526060810193909352608083019190915260a09091015292915050565b60006101408083526136b48184018e6133b3565b6001600160a01b039c8d1660208501529a8c1660408401525050969098166060870152608086019490945260a085019290925260c084015260e08301526101008201526101200191909152919050565b600082613713576137136135e4565b500690565b601f82111561073457600081815260208120601f850160051c8101602086101561373f5750805b601f850160051c820191505b818110156127c75782815560010161374b565b81516001600160401b0381111561377757613777612df7565b61378b8161378584546134ea565b84613718565b602080601f8311600181146137c057600084156137a85750858301515b600019600386901b1c1916600185901b1785556127c7565b600085815260208120601f198616915b828110156137ef578886015182559484019460019091019084016137d0565b508582101561380d5787850151600019600388901b60f8161c191681555b5050505050600190811b01905550565b60c08152600061383060c08301896133b3565b828103602084015261384281896133b3565b6001600160a01b0397881660408501529587166060840152505091909316608082015260a0019190915292915050565b60006020828403121561388457600080fd5b5051919050565b60006020828403121561389d57600080fd5b81518015158114612c9757600080fdfea26469706673582212200aefe90cebfc7e816985a9bcda7657980781b3ed301eb865f948638c8e9f224764736f6c63430008140033
Loading...
Loading
Loading...
Loading
Loading...
Loading
Loading...
Loading
[ Download: CSV Export ]
A contract address hosts a smart contract, which is a set of code stored on the blockchain that runs when predetermined conditions are met. Learn more about addresses in our Knowledge Base.