Source Code
Overview
ETH Balance
0 ETH
Eth Value
$0.00Latest 1 from a total of 1 transactions
| Transaction Hash |
Method
|
Block
|
From
|
|
To
|
||||
|---|---|---|---|---|---|---|---|---|---|
| Initialize | 13004264 | 1632 days ago | IN | 0 ETH | 0.01152404 |
View more zero value Internal Transactions in Advanced View mode
Advanced mode:
Loading...
Loading
Loading...
Loading
Cross-Chain Transactions
Loading...
Loading
Contract Name:
BetaBank
Compiler Version
v0.8.6+commit.11564f7e
Contract Source Code (Solidity)
/**
*Submitted for verification at Etherscan.io on 2021-08-11
*/
// SPDX-License-Identifier: BUSL-1.1
pragma solidity 0.8.6;
// Part: IBetaBank
interface IBetaBank {
/// @dev Returns the address of BToken of the given underlying token, or 0 if not exists.
function bTokens(address _underlying) external view returns (address);
/// @dev Returns the address of the underlying of the given BToken, or 0 if not exists.
function underlyings(address _bToken) external view returns (address);
/// @dev Returns the address of the oracle contract.
function oracle() external view returns (address);
/// @dev Returns the address of the config contract.
function config() external view returns (address);
/// @dev Returns the interest rate model smart contract.
function interestModel() external view returns (address);
/// @dev Returns the position's collateral token and AmToken.
function getPositionTokens(address _owner, uint _pid)
external
view
returns (address _collateral, address _bToken);
/// @dev Returns the debt of the given position. Can't be view as it needs to call accrue.
function fetchPositionDebt(address _owner, uint _pid) external returns (uint);
/// @dev Returns the LTV of the given position. Can't be view as it needs to call accrue.
function fetchPositionLTV(address _owner, uint _pid) external returns (uint);
/// @dev Opens a new position in the Beta smart contract.
function open(
address _owner,
address _underlying,
address _collateral
) external returns (uint pid);
/// @dev Borrows tokens on the given position.
function borrow(
address _owner,
uint _pid,
uint _amount
) external;
/// @dev Repays tokens on the given position.
function repay(
address _owner,
uint _pid,
uint _amount
) external;
/// @dev Puts more collateral to the given position.
function put(
address _owner,
uint _pid,
uint _amount
) external;
/// @dev Takes some collateral out of the position.
function take(
address _owner,
uint _pid,
uint _amount
) external;
/// @dev Liquidates the given position.
function liquidate(
address _owner,
uint _pid,
uint _amount
) external;
}
// Part: IBetaConfig
interface IBetaConfig {
/// @dev Returns the risk level for the given asset.
function getRiskLevel(address token) external view returns (uint);
/// @dev Returns the rate of interest collected to be distributed to the protocol reserve.
function reserveRate() external view returns (uint);
/// @dev Returns the beneficiary to receive a portion interest rate for the protocol.
function reserveBeneficiary() external view returns (address);
/// @dev Returns the ratio of which the given token consider for collateral value.
function getCollFactor(address token) external view returns (uint);
/// @dev Returns the max amount of collateral to accept globally.
function getCollMaxAmount(address token) external view returns (uint);
/// @dev Returns max ltv of collateral / debt to allow a new position.
function getSafetyLTV(address token) external view returns (uint);
/// @dev Returns max ltv of collateral / debt to liquidate a position of the given token.
function getLiquidationLTV(address token) external view returns (uint);
/// @dev Returns the bonus incentive reward factor for liquidators.
function getKillBountyRate(address token) external view returns (uint);
}
// Part: IBetaInterestModel
interface IBetaInterestModel {
/// @dev Returns the initial interest rate per year (times 1e18).
function initialRate() external view returns (uint);
/// @dev Returns the next interest rate for the market.
/// @param prevRate The current interest rate.
/// @param totalAvailable The current available liquidity.
/// @param totalLoan The current outstanding loan.
/// @param timePast The time past since last interest rate rebase in seconds.
function getNextInterestRate(
uint prevRate,
uint totalAvailable,
uint totalLoan,
uint timePast
) external view returns (uint);
}
// Part: IBetaOracle
interface IBetaOracle {
/// @dev Returns the given asset price in ETH (wei), multiplied by 2**112.
/// @param token The token to query for asset price
function getAssetETHPrice(address token) external returns (uint);
/// @dev Returns the given asset value in ETH (wei)
/// @param token The token to query for asset value
/// @param amount The amount of token to query
function getAssetETHValue(address token, uint amount) external returns (uint);
/// @dev Returns the conversion from amount of from` to `to`.
/// @param from The source token to convert.
/// @param to The destination token to convert.
/// @param amount The amount of token for conversion.
function convert(
address from,
address to,
uint amount
) external returns (uint);
}
// Part: OpenZeppelin/[email protected]/Address
/**
* @dev Collection of functions related to the address type
*/
library Address {
/**
* @dev Returns true if `account` is a contract.
*
* [IMPORTANT]
* ====
* It is unsafe to assume that an address for which this function returns
* false is an externally-owned account (EOA) and not a contract.
*
* Among others, `isContract` will return false for the following
* types of addresses:
*
* - an externally-owned account
* - a contract in construction
* - an address where a contract will be created
* - an address where a contract lived, but was destroyed
* ====
*/
function isContract(address account) internal view returns (bool) {
// This method relies on extcodesize, which returns 0 for contracts in
// construction, since the code is only stored at the end of the
// constructor execution.
uint256 size;
assembly {
size := extcodesize(account)
}
return size > 0;
}
/**
* @dev Replacement for Solidity's `transfer`: sends `amount` wei to
* `recipient`, forwarding all available gas and reverting on errors.
*
* https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost
* of certain opcodes, possibly making contracts go over the 2300 gas limit
* imposed by `transfer`, making them unable to receive funds via
* `transfer`. {sendValue} removes this limitation.
*
* https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].
*
* IMPORTANT: because control is transferred to `recipient`, care must be
* taken to not create reentrancy vulnerabilities. Consider using
* {ReentrancyGuard} or the
* https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].
*/
function sendValue(address payable recipient, uint256 amount) internal {
require(address(this).balance >= amount, "Address: insufficient balance");
(bool success, ) = recipient.call{value: amount}("");
require(success, "Address: unable to send value, recipient may have reverted");
}
/**
* @dev Performs a Solidity function call using a low level `call`. A
* plain `call` is an unsafe replacement for a function call: use this
* function instead.
*
* If `target` reverts with a revert reason, it is bubbled up by this
* function (like regular Solidity function calls).
*
* Returns the raw returned data. To convert to the expected return value,
* use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].
*
* Requirements:
*
* - `target` must be a contract.
* - calling `target` with `data` must not revert.
*
* _Available since v3.1._
*/
function functionCall(address target, bytes memory data) internal returns (bytes memory) {
return functionCall(target, data, "Address: low-level call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with
* `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCall(
address target,
bytes memory data,
string memory errorMessage
) internal returns (bytes memory) {
return functionCallWithValue(target, data, 0, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but also transferring `value` wei to `target`.
*
* Requirements:
*
* - the calling contract must have an ETH balance of at least `value`.
* - the called Solidity function must be `payable`.
*
* _Available since v3.1._
*/
function functionCallWithValue(
address target,
bytes memory data,
uint256 value
) internal returns (bytes memory) {
return functionCallWithValue(target, data, value, "Address: low-level call with value failed");
}
/**
* @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but
* with `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCallWithValue(
address target,
bytes memory data,
uint256 value,
string memory errorMessage
) internal returns (bytes memory) {
require(address(this).balance >= value, "Address: insufficient balance for call");
require(isContract(target), "Address: call to non-contract");
(bool success, bytes memory returndata) = target.call{value: value}(data);
return _verifyCallResult(success, returndata, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but performing a static call.
*
* _Available since v3.3._
*/
function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {
return functionStaticCall(target, data, "Address: low-level static call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
* but performing a static call.
*
* _Available since v3.3._
*/
function functionStaticCall(
address target,
bytes memory data,
string memory errorMessage
) internal view returns (bytes memory) {
require(isContract(target), "Address: static call to non-contract");
(bool success, bytes memory returndata) = target.staticcall(data);
return _verifyCallResult(success, returndata, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but performing a delegate call.
*
* _Available since v3.4._
*/
function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {
return functionDelegateCall(target, data, "Address: low-level delegate call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
* but performing a delegate call.
*
* _Available since v3.4._
*/
function functionDelegateCall(
address target,
bytes memory data,
string memory errorMessage
) internal returns (bytes memory) {
require(isContract(target), "Address: delegate call to non-contract");
(bool success, bytes memory returndata) = target.delegatecall(data);
return _verifyCallResult(success, returndata, errorMessage);
}
function _verifyCallResult(
bool success,
bytes memory returndata,
string memory errorMessage
) private pure returns (bytes memory) {
if (success) {
return returndata;
} else {
// Look for revert reason and bubble it up if present
if (returndata.length > 0) {
// The easiest way to bubble the revert reason is using memory via assembly
assembly {
let returndata_size := mload(returndata)
revert(add(32, returndata), returndata_size)
}
} else {
revert(errorMessage);
}
}
}
}
// Part: OpenZeppelin/[email protected]/Context
/*
* @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;
}
}
// Part: OpenZeppelin/[email protected]/Counters
/**
* @title Counters
* @author Matt Condon (@shrugs)
* @dev Provides counters that can only be incremented, decremented or reset. This can be used e.g. to track the number
* of elements in a mapping, issuing ERC721 ids, or counting request ids.
*
* Include with `using Counters for Counters.Counter;`
*/
library Counters {
struct Counter {
// This variable should never be directly accessed by users of the library: interactions must be restricted to
// the library's function. As of Solidity v0.5.2, this cannot be enforced, though there is a proposal to add
// this feature: see https://github.com/ethereum/solidity/issues/4637
uint256 _value; // default: 0
}
function current(Counter storage counter) internal view returns (uint256) {
return counter._value;
}
function increment(Counter storage counter) internal {
unchecked {
counter._value += 1;
}
}
function decrement(Counter storage counter) internal {
uint256 value = counter._value;
require(value > 0, "Counter: decrement overflow");
unchecked {
counter._value = value - 1;
}
}
function reset(Counter storage counter) internal {
counter._value = 0;
}
}
// Part: OpenZeppelin/[email protected]/ECDSA
/**
* @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 {
/**
* @dev Returns the address that signed a hashed message (`hash`) with
* `signature`. This address can then be used for verification purposes.
*
* The `ecrecover` EVM opcode allows for malleable (non-unique) signatures:
* this function rejects them by requiring the `s` value to be in the lower
* half order, and the `v` value to be either 27 or 28.
*
* IMPORTANT: `hash` _must_ be the result of a hash operation for the
* verification to be secure: it is possible to craft signatures that
* recover to arbitrary addresses for non-hashed data. A safe way to ensure
* this is by receiving a hash of the original message (which may otherwise
* be too long), and then calling {toEthSignedMessageHash} on it.
*
* 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 recover(bytes32 hash, bytes memory signature) internal pure returns (address) {
// Check the signature length
// - case 65: r,s,v signature (standard)
// - case 64: r,vs signature (cf https://eips.ethereum.org/EIPS/eip-2098) _Available since v4.1._
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.
assembly {
r := mload(add(signature, 0x20))
s := mload(add(signature, 0x40))
v := byte(0, mload(add(signature, 0x60)))
}
return recover(hash, v, r, s);
} else if (signature.length == 64) {
bytes32 r;
bytes32 vs;
// ecrecover takes the signature parameters, and the only way to get them
// currently is to use assembly.
assembly {
r := mload(add(signature, 0x20))
vs := mload(add(signature, 0x40))
}
return recover(hash, r, vs);
} else {
revert("ECDSA: invalid signature length");
}
}
/**
* @dev Overload of {ECDSA-recover} that receives the `r` and `vs` short-signature fields separately.
*
* See https://eips.ethereum.org/EIPS/eip-2098[EIP-2098 short signatures]
*
* _Available since v4.2._
*/
function recover(
bytes32 hash,
bytes32 r,
bytes32 vs
) internal pure returns (address) {
bytes32 s;
uint8 v;
assembly {
s := and(vs, 0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff)
v := add(shr(255, vs), 27)
}
return recover(hash, v, r, s);
}
/**
* @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) {
// 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 (281): 0 < s < secp256k1n ÷ 2 + 1, and for v in (282): 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.
require(
uint256(s) <= 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF5D576E7357A4501DDFE92F46681B20A0,
"ECDSA: invalid signature 's' value"
);
require(v == 27 || v == 28, "ECDSA: invalid signature 'v' value");
// If the signature is valid (and not malleable), return the signer address
address signer = ecrecover(hash, v, r, s);
require(signer != address(0), "ECDSA: invalid signature");
return signer;
}
/**
* @dev Returns an Ethereum Signed Message, created from a `hash`. This
* produces hash corresponding to the one signed with the
* https://eth.wiki/json-rpc/API#eth_sign[`eth_sign`]
* JSON-RPC method as part of EIP-191.
*
* See {recover}.
*/
function toEthSignedMessageHash(bytes32 hash) internal pure returns (bytes32) {
// 32 is the length in bytes of hash,
// enforced by the type signature above
return keccak256(abi.encodePacked("\x19Ethereum Signed Message:\n32", hash));
}
/**
* @dev Returns an Ethereum Signed Typed Data, created from a
* `domainSeparator` and a `structHash`. This produces hash corresponding
* to the one signed with the
* https://eips.ethereum.org/EIPS/eip-712[`eth_signTypedData`]
* JSON-RPC method as part of EIP-712.
*
* See {recover}.
*/
function toTypedDataHash(bytes32 domainSeparator, bytes32 structHash) internal pure returns (bytes32) {
return keccak256(abi.encodePacked("\x19\x01", domainSeparator, structHash));
}
}
// Part: OpenZeppelin/[email protected]/IERC20
/**
* @dev Interface of the ERC20 standard as defined in the EIP.
*/
interface IERC20 {
/**
* @dev Returns the amount of tokens in existence.
*/
function totalSupply() external view returns (uint256);
/**
* @dev Returns the amount of tokens owned by `account`.
*/
function balanceOf(address account) external view returns (uint256);
/**
* @dev Moves `amount` tokens from the caller's account to `recipient`.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transfer(address recipient, uint256 amount) external returns (bool);
/**
* @dev Returns the remaining number of tokens that `spender` will be
* allowed to spend on behalf of `owner` through {transferFrom}. This is
* zero by default.
*
* This value changes when {approve} or {transferFrom} are called.
*/
function allowance(address owner, address spender) external view returns (uint256);
/**
* @dev Sets `amount` as the allowance of `spender` over the caller's tokens.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* IMPORTANT: Beware that changing an allowance with this method brings the risk
* that someone may use both the old and the new allowance by unfortunate
* transaction ordering. One possible solution to mitigate this race
* condition is to first reduce the spender's allowance to 0 and set the
* desired value afterwards:
* https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
*
* Emits an {Approval} event.
*/
function approve(address spender, uint256 amount) external returns (bool);
/**
* @dev Moves `amount` tokens from `sender` to `recipient` using the
* allowance mechanism. `amount` is then deducted from the caller's
* allowance.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transferFrom(
address sender,
address recipient,
uint256 amount
) external returns (bool);
/**
* @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);
}
// Part: OpenZeppelin/[email protected]/IERC20Permit
/**
* @dev Interface of the ERC20 Permit extension allowing approvals to be made via signatures, as defined in
* https://eips.ethereum.org/EIPS/eip-2612[EIP-2612].
*
* Adds the {permit} method, which can be used to change an account's ERC20 allowance (see {IERC20-allowance}) by
* presenting a message signed by the account. By not relying on {IERC20-approve}, the token holder account doesn't
* need to send a transaction, and thus is not required to hold Ether at all.
*/
interface IERC20Permit {
/**
* @dev Sets `value` as the allowance of `spender` over ``owner``'s tokens,
* given ``owner``'s signed approval.
*
* IMPORTANT: The same issues {IERC20-approve} has related to transaction
* ordering also apply here.
*
* Emits an {Approval} event.
*
* Requirements:
*
* - `spender` cannot be the zero address.
* - `deadline` must be a timestamp in the future.
* - `v`, `r` and `s` must be a valid `secp256k1` signature from `owner`
* over the EIP712-formatted function arguments.
* - the signature must use ``owner``'s current nonce (see {nonces}).
*
* For more information on the signature format, see the
* https://eips.ethereum.org/EIPS/eip-2612#specification[relevant EIP
* section].
*/
function permit(
address owner,
address spender,
uint256 value,
uint256 deadline,
uint8 v,
bytes32 r,
bytes32 s
) external;
/**
* @dev Returns the current nonce for `owner`. This value must be
* included whenever a signature is generated for {permit}.
*
* Every successful call to {permit} increases ``owner``'s nonce by one. This
* prevents a signature from being used multiple times.
*/
function nonces(address owner) external view returns (uint256);
/**
* @dev Returns the domain separator used in the encoding of the signature for {permit}, as defined by {EIP712}.
*/
// solhint-disable-next-line func-name-mixedcase
function DOMAIN_SEPARATOR() external view returns (bytes32);
}
// Part: OpenZeppelin/[email protected]/Initializable
/**
* @dev This is a base contract to aid in writing upgradeable contracts, or any kind of contract that will be deployed
* behind a proxy. Since a proxied contract can't have a constructor, it's common to move constructor logic to an
* external initializer function, usually called `initialize`. It then becomes necessary to protect this initializer
* function so it can only be called once. The {initializer} modifier provided by this contract will have this effect.
*
* TIP: To avoid leaving the proxy in an uninitialized state, the initializer function should be called as early as
* possible by providing the encoded function call as the `_data` argument to {ERC1967Proxy-constructor}.
*
* CAUTION: When used with inheritance, manual care must be taken to not invoke a parent initializer twice, or to ensure
* that all initializers are idempotent. This is not verified automatically as constructors are by Solidity.
*/
abstract contract Initializable {
/**
* @dev Indicates that the contract has been initialized.
*/
bool private _initialized;
/**
* @dev Indicates that the contract is in the process of being initialized.
*/
bool private _initializing;
/**
* @dev Modifier to protect an initializer function from being invoked twice.
*/
modifier initializer() {
require(_initializing || !_initialized, "Initializable: contract is already initialized");
bool isTopLevelCall = !_initializing;
if (isTopLevelCall) {
_initializing = true;
_initialized = true;
}
_;
if (isTopLevelCall) {
_initializing = false;
}
}
}
// Part: OpenZeppelin/[email protected]/Math
/**
* @dev Standard math utilities missing in the Solidity language.
*/
library Math {
/**
* @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, so we distribute.
return (a / 2) + (b / 2) + (((a % 2) + (b % 2)) / 2);
}
/**
* @dev Returns the ceiling of the division of two numbers.
*
* This differs from standard division with `/` in that it rounds up instead
* of rounding down.
*/
function ceilDiv(uint256 a, uint256 b) internal pure returns (uint256) {
// (a + b - 1) / b can overflow on addition, so we distribute.
return a / b + (a % b == 0 ? 0 : 1);
}
}
// Part: OpenZeppelin/[email protected]/ReentrancyGuard
/**
* @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;
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 make it call a
* `private` function that does the actual work.
*/
modifier nonReentrant() {
// On the first call to nonReentrant, _notEntered will be true
require(_status != _ENTERED, "ReentrancyGuard: reentrant call");
// Any calls to nonReentrant after this point will fail
_status = _ENTERED;
_;
// By storing the original value once again, a refund is triggered (see
// https://eips.ethereum.org/EIPS/eip-2200)
_status = _NOT_ENTERED;
}
}
// Part: OpenZeppelin/[email protected]/EIP712
/**
* @dev https://eips.ethereum.org/EIPS/eip-712[EIP 712] is a standard for hashing and signing of typed structured data.
*
* The encoding specified in the EIP is very generic, and such a generic implementation in Solidity is not feasible,
* thus this contract does not implement the encoding itself. Protocols need to implement the type-specific encoding
* they need in their contracts using a combination of `abi.encode` and `keccak256`.
*
* This contract implements the EIP 712 domain separator ({_domainSeparatorV4}) that is used as part of the encoding
* scheme, and the final step of the encoding to obtain the message digest that is then signed via ECDSA
* ({_hashTypedDataV4}).
*
* The implementation of the domain separator was designed to be as efficient as possible while still properly updating
* the chain id to protect against replay attacks on an eventual fork of the chain.
*
* NOTE: This contract implements the version of the encoding known as "v4", as implemented by the JSON RPC method
* https://docs.metamask.io/guide/signing-data.html[`eth_signTypedDataV4` in MetaMask].
*
* _Available since v3.4._
*/
abstract contract EIP712 {
/* solhint-disable var-name-mixedcase */
// Cache the domain separator as an immutable value, but also store the chain id that it corresponds to, in order to
// invalidate the cached domain separator if the chain id changes.
bytes32 private immutable _CACHED_DOMAIN_SEPARATOR;
uint256 private immutable _CACHED_CHAIN_ID;
bytes32 private immutable _HASHED_NAME;
bytes32 private immutable _HASHED_VERSION;
bytes32 private immutable _TYPE_HASH;
/* solhint-enable var-name-mixedcase */
/**
* @dev Initializes the domain separator and parameter caches.
*
* The meaning of `name` and `version` is specified in
* https://eips.ethereum.org/EIPS/eip-712#definition-of-domainseparator[EIP 712]:
*
* - `name`: the user readable name of the signing domain, i.e. the name of the DApp or the protocol.
* - `version`: the current major version of the signing domain.
*
* NOTE: These parameters cannot be changed except through a xref:learn::upgrading-smart-contracts.adoc[smart
* contract upgrade].
*/
constructor(string memory name, string memory version) {
bytes32 hashedName = keccak256(bytes(name));
bytes32 hashedVersion = keccak256(bytes(version));
bytes32 typeHash = keccak256(
"EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)"
);
_HASHED_NAME = hashedName;
_HASHED_VERSION = hashedVersion;
_CACHED_CHAIN_ID = block.chainid;
_CACHED_DOMAIN_SEPARATOR = _buildDomainSeparator(typeHash, hashedName, hashedVersion);
_TYPE_HASH = typeHash;
}
/**
* @dev Returns the domain separator for the current chain.
*/
function _domainSeparatorV4() internal view returns (bytes32) {
if (block.chainid == _CACHED_CHAIN_ID) {
return _CACHED_DOMAIN_SEPARATOR;
} else {
return _buildDomainSeparator(_TYPE_HASH, _HASHED_NAME, _HASHED_VERSION);
}
}
function _buildDomainSeparator(
bytes32 typeHash,
bytes32 nameHash,
bytes32 versionHash
) private view returns (bytes32) {
return keccak256(abi.encode(typeHash, nameHash, versionHash, block.chainid, address(this)));
}
/**
* @dev Given an already https://eips.ethereum.org/EIPS/eip-712#definition-of-hashstruct[hashed struct], this
* function returns the hash of the fully encoded EIP712 message for this domain.
*
* This hash can be used together with {ECDSA-recover} to obtain the signer of a message. For example:
*
* ```solidity
* bytes32 digest = _hashTypedDataV4(keccak256(abi.encode(
* keccak256("Mail(address to,string contents)"),
* mailTo,
* keccak256(bytes(mailContents))
* )));
* address signer = ECDSA.recover(digest, signature);
* ```
*/
function _hashTypedDataV4(bytes32 structHash) internal view virtual returns (bytes32) {
return ECDSA.toTypedDataHash(_domainSeparatorV4(), structHash);
}
}
// Part: OpenZeppelin/[email protected]/IERC20Metadata
/**
* @dev Interface for the optional metadata functions from the ERC20 standard.
*
* _Available since v4.1._
*/
interface IERC20Metadata is IERC20 {
/**
* @dev Returns the name of the token.
*/
function name() external view returns (string memory);
/**
* @dev Returns the symbol of the token.
*/
function symbol() external view returns (string memory);
/**
* @dev Returns the decimals places of the token.
*/
function decimals() external view returns (uint8);
}
// Part: OpenZeppelin/[email protected]/Pausable
/**
* @dev Contract module which allows children to implement an emergency stop
* mechanism that can be triggered by an authorized account.
*
* This module is used through inheritance. It will make available the
* modifiers `whenNotPaused` and `whenPaused`, which can be applied to
* the functions of your contract. Note that they will not be pausable by
* simply including this module, only once the modifiers are put in place.
*/
abstract contract Pausable is Context {
/**
* @dev Emitted when the pause is triggered by `account`.
*/
event Paused(address account);
/**
* @dev Emitted when the pause is lifted by `account`.
*/
event Unpaused(address account);
bool private _paused;
/**
* @dev Initializes the contract in unpaused state.
*/
constructor() {
_paused = false;
}
/**
* @dev Returns true if the contract is paused, and false otherwise.
*/
function paused() public view virtual returns (bool) {
return _paused;
}
/**
* @dev Modifier to make a function callable only when the contract is not paused.
*
* Requirements:
*
* - The contract must not be paused.
*/
modifier whenNotPaused() {
require(!paused(), "Pausable: paused");
_;
}
/**
* @dev Modifier to make a function callable only when the contract is paused.
*
* Requirements:
*
* - The contract must be paused.
*/
modifier whenPaused() {
require(paused(), "Pausable: not paused");
_;
}
/**
* @dev Triggers stopped state.
*
* Requirements:
*
* - The contract must not be paused.
*/
function _pause() internal virtual whenNotPaused {
_paused = true;
emit Paused(_msgSender());
}
/**
* @dev Returns to normal state.
*
* Requirements:
*
* - The contract must be paused.
*/
function _unpause() internal virtual whenPaused {
_paused = false;
emit Unpaused(_msgSender());
}
}
// Part: OpenZeppelin/[email protected]/SafeERC20
/**
* @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;
function safeTransfer(
IERC20 token,
address to,
uint256 value
) internal {
_callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value));
}
function safeTransferFrom(
IERC20 token,
address from,
address to,
uint256 value
) internal {
_callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value));
}
/**
* @dev Deprecated. This function has issues similar to the ones found in
* {IERC20-approve}, and its usage is discouraged.
*
* Whenever possible, use {safeIncreaseAllowance} and
* {safeDecreaseAllowance} instead.
*/
function safeApprove(
IERC20 token,
address spender,
uint256 value
) internal {
// safeApprove should only be called when setting an initial allowance,
// or when resetting it to zero. To increase and decrease it, use
// 'safeIncreaseAllowance' and 'safeDecreaseAllowance'
require(
(value == 0) || (token.allowance(address(this), spender) == 0),
"SafeERC20: approve from non-zero to non-zero allowance"
);
_callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value));
}
function safeIncreaseAllowance(
IERC20 token,
address spender,
uint256 value
) internal {
uint256 newAllowance = token.allowance(address(this), spender) + value;
_callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));
}
function safeDecreaseAllowance(
IERC20 token,
address spender,
uint256 value
) internal {
unchecked {
uint256 oldAllowance = token.allowance(address(this), spender);
require(oldAllowance >= value, "SafeERC20: decreased allowance below zero");
uint256 newAllowance = oldAllowance - value;
_callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));
}
}
/**
* @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement
* on the return value: the return value is optional (but if data is returned, it must not be false).
* @param token The token targeted by the call.
* @param data The call data (encoded using abi.encode or one of its variants).
*/
function _callOptionalReturn(IERC20 token, bytes memory data) private {
// We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since
// we're implementing it ourselves. We use {Address.functionCall} to perform this call, which verifies that
// the target address contains contract code and also asserts for success in the low-level call.
bytes memory returndata = address(token).functionCall(data, "SafeERC20: low-level call failed");
if (returndata.length > 0) {
// Return data is optional
require(abi.decode(returndata, (bool)), "SafeERC20: ERC20 operation did not succeed");
}
}
}
// Part: OpenZeppelin/[email protected]/ERC20
/**
* @dev Implementation of the {IERC20} interface.
*
* This implementation is agnostic to the way tokens are created. This means
* that a supply mechanism has to be added in a derived contract using {_mint}.
* For a generic mechanism see {ERC20PresetMinterPauser}.
*
* TIP: For a detailed writeup see our guide
* https://forum.zeppelin.solutions/t/how-to-implement-erc20-supply-mechanisms/226[How
* to implement supply mechanisms].
*
* We have followed general OpenZeppelin guidelines: functions revert instead
* of returning `false` on failure. This behavior is nonetheless conventional
* and does not conflict with the expectations of ERC20 applications.
*
* Additionally, an {Approval} event is emitted on calls to {transferFrom}.
* This allows applications to reconstruct the allowance for all accounts just
* by listening to said events. Other implementations of the EIP may not emit
* these events, as it isn't required by the specification.
*
* Finally, the non-standard {decreaseAllowance} and {increaseAllowance}
* functions have been added to mitigate the well-known issues around setting
* allowances. See {IERC20-approve}.
*/
contract ERC20 is Context, IERC20, IERC20Metadata {
mapping(address => uint256) private _balances;
mapping(address => mapping(address => uint256)) private _allowances;
uint256 private _totalSupply;
string private _name;
string private _symbol;
/**
* @dev Sets the values for {name} and {symbol}.
*
* The default value of {decimals} is 18. To select a different value for
* {decimals} you should overload it.
*
* All two of these values are immutable: they can only be set once during
* construction.
*/
constructor(string memory name_, string memory symbol_) {
_name = name_;
_symbol = symbol_;
}
/**
* @dev Returns the name of the token.
*/
function name() public view virtual override returns (string memory) {
return _name;
}
/**
* @dev Returns the symbol of the token, usually a shorter version of the
* name.
*/
function symbol() public view virtual override returns (string memory) {
return _symbol;
}
/**
* @dev Returns the number of decimals used to get its user representation.
* For example, if `decimals` equals `2`, a balance of `505` tokens should
* be displayed to a user as `5,05` (`505 / 10 ** 2`).
*
* Tokens usually opt for a value of 18, imitating the relationship between
* Ether and Wei. This is the value {ERC20} uses, unless this function is
* overridden;
*
* NOTE: This information is only used for _display_ purposes: it in
* no way affects any of the arithmetic of the contract, including
* {IERC20-balanceOf} and {IERC20-transfer}.
*/
function decimals() public view virtual override returns (uint8) {
return 18;
}
/**
* @dev See {IERC20-totalSupply}.
*/
function totalSupply() public view virtual override returns (uint256) {
return _totalSupply;
}
/**
* @dev See {IERC20-balanceOf}.
*/
function balanceOf(address account) public view virtual override returns (uint256) {
return _balances[account];
}
/**
* @dev See {IERC20-transfer}.
*
* Requirements:
*
* - `recipient` cannot be the zero address.
* - the caller must have a balance of at least `amount`.
*/
function transfer(address recipient, uint256 amount) public virtual override returns (bool) {
_transfer(_msgSender(), recipient, amount);
return true;
}
/**
* @dev See {IERC20-allowance}.
*/
function allowance(address owner, address spender) public view virtual override returns (uint256) {
return _allowances[owner][spender];
}
/**
* @dev See {IERC20-approve}.
*
* Requirements:
*
* - `spender` cannot be the zero address.
*/
function approve(address spender, uint256 amount) public virtual override returns (bool) {
_approve(_msgSender(), spender, amount);
return true;
}
/**
* @dev See {IERC20-transferFrom}.
*
* Emits an {Approval} event indicating the updated allowance. This is not
* required by the EIP. See the note at the beginning of {ERC20}.
*
* Requirements:
*
* - `sender` and `recipient` cannot be the zero address.
* - `sender` must have a balance of at least `amount`.
* - the caller must have allowance for ``sender``'s tokens of at least
* `amount`.
*/
function transferFrom(
address sender,
address recipient,
uint256 amount
) public virtual override returns (bool) {
_transfer(sender, recipient, amount);
uint256 currentAllowance = _allowances[sender][_msgSender()];
require(currentAllowance >= amount, "ERC20: transfer amount exceeds allowance");
unchecked {
_approve(sender, _msgSender(), currentAllowance - amount);
}
return true;
}
/**
* @dev Atomically increases the allowance granted to `spender` by the caller.
*
* This is an alternative to {approve} that can be used as a mitigation for
* problems described in {IERC20-approve}.
*
* Emits an {Approval} event indicating the updated allowance.
*
* Requirements:
*
* - `spender` cannot be the zero address.
*/
function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) {
_approve(_msgSender(), spender, _allowances[_msgSender()][spender] + addedValue);
return true;
}
/**
* @dev Atomically decreases the allowance granted to `spender` by the caller.
*
* This is an alternative to {approve} that can be used as a mitigation for
* problems described in {IERC20-approve}.
*
* Emits an {Approval} event indicating the updated allowance.
*
* Requirements:
*
* - `spender` cannot be the zero address.
* - `spender` must have allowance for the caller of at least
* `subtractedValue`.
*/
function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) {
uint256 currentAllowance = _allowances[_msgSender()][spender];
require(currentAllowance >= subtractedValue, "ERC20: decreased allowance below zero");
unchecked {
_approve(_msgSender(), spender, currentAllowance - subtractedValue);
}
return true;
}
/**
* @dev Moves `amount` of tokens from `sender` to `recipient`.
*
* This internal function is equivalent to {transfer}, and can be used to
* e.g. implement automatic token fees, slashing mechanisms, etc.
*
* Emits a {Transfer} event.
*
* Requirements:
*
* - `sender` cannot be the zero address.
* - `recipient` cannot be the zero address.
* - `sender` must have a balance of at least `amount`.
*/
function _transfer(
address sender,
address recipient,
uint256 amount
) internal virtual {
require(sender != address(0), "ERC20: transfer from the zero address");
require(recipient != address(0), "ERC20: transfer to the zero address");
_beforeTokenTransfer(sender, recipient, amount);
uint256 senderBalance = _balances[sender];
require(senderBalance >= amount, "ERC20: transfer amount exceeds balance");
unchecked {
_balances[sender] = senderBalance - amount;
}
_balances[recipient] += amount;
emit Transfer(sender, recipient, amount);
_afterTokenTransfer(sender, recipient, amount);
}
/** @dev Creates `amount` tokens and assigns them to `account`, increasing
* the total supply.
*
* Emits a {Transfer} event with `from` set to the zero address.
*
* Requirements:
*
* - `account` cannot be the zero address.
*/
function _mint(address account, uint256 amount) internal virtual {
require(account != address(0), "ERC20: mint to the zero address");
_beforeTokenTransfer(address(0), account, amount);
_totalSupply += amount;
_balances[account] += amount;
emit Transfer(address(0), account, amount);
_afterTokenTransfer(address(0), account, amount);
}
/**
* @dev Destroys `amount` tokens from `account`, reducing the
* total supply.
*
* Emits a {Transfer} event with `to` set to the zero address.
*
* Requirements:
*
* - `account` cannot be the zero address.
* - `account` must have at least `amount` tokens.
*/
function _burn(address account, uint256 amount) internal virtual {
require(account != address(0), "ERC20: burn from the zero address");
_beforeTokenTransfer(account, address(0), amount);
uint256 accountBalance = _balances[account];
require(accountBalance >= amount, "ERC20: burn amount exceeds balance");
unchecked {
_balances[account] = accountBalance - amount;
}
_totalSupply -= amount;
emit Transfer(account, address(0), amount);
_afterTokenTransfer(account, address(0), amount);
}
/**
* @dev Sets `amount` as the allowance of `spender` over the `owner` s tokens.
*
* This internal function is equivalent to `approve`, and can be used to
* e.g. set automatic allowances for certain subsystems, etc.
*
* Emits an {Approval} event.
*
* Requirements:
*
* - `owner` cannot be the zero address.
* - `spender` cannot be the zero address.
*/
function _approve(
address owner,
address spender,
uint256 amount
) internal virtual {
require(owner != address(0), "ERC20: approve from the zero address");
require(spender != address(0), "ERC20: approve to the zero address");
_allowances[owner][spender] = amount;
emit Approval(owner, spender, amount);
}
/**
* @dev Hook that is called before any transfer of tokens. This includes
* minting and burning.
*
* Calling conditions:
*
* - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens
* will be transferred to `to`.
* - when `from` is zero, `amount` tokens will be minted for `to`.
* - when `to` is zero, `amount` of ``from``'s tokens will be burned.
* - `from` and `to` are never both zero.
*
* To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].
*/
function _beforeTokenTransfer(
address from,
address to,
uint256 amount
) internal virtual {}
/**
* @dev Hook that is called after any transfer of tokens. This includes
* minting and burning.
*
* Calling conditions:
*
* - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens
* has been transferred to `to`.
* - when `from` is zero, `amount` tokens have been minted for `to`.
* - when `to` is zero, `amount` of ``from``'s tokens have been burned.
* - `from` and `to` are never both zero.
*
* To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].
*/
function _afterTokenTransfer(
address from,
address to,
uint256 amount
) internal virtual {}
}
// Part: OpenZeppelin/[email protected]/ERC20Permit
/**
* @dev Implementation of the ERC20 Permit extension allowing approvals to be made via signatures, as defined in
* https://eips.ethereum.org/EIPS/eip-2612[EIP-2612].
*
* Adds the {permit} method, which can be used to change an account's ERC20 allowance (see {IERC20-allowance}) by
* presenting a message signed by the account. By not relying on `{IERC20-approve}`, the token holder account doesn't
* need to send a transaction, and thus is not required to hold Ether at all.
*
* _Available since v3.4._
*/
abstract contract ERC20Permit is ERC20, IERC20Permit, EIP712 {
using Counters for Counters.Counter;
mapping(address => Counters.Counter) private _nonces;
// solhint-disable-next-line var-name-mixedcase
bytes32 private immutable _PERMIT_TYPEHASH =
keccak256("Permit(address owner,address spender,uint256 value,uint256 nonce,uint256 deadline)");
/**
* @dev Initializes the {EIP712} domain separator using the `name` parameter, and setting `version` to `"1"`.
*
* It's a good idea to use the same `name` that is defined as the ERC20 token name.
*/
constructor(string memory name) EIP712(name, "1") {}
/**
* @dev See {IERC20Permit-permit}.
*/
function permit(
address owner,
address spender,
uint256 value,
uint256 deadline,
uint8 v,
bytes32 r,
bytes32 s
) public virtual override {
require(block.timestamp <= deadline, "ERC20Permit: expired deadline");
bytes32 structHash = keccak256(abi.encode(_PERMIT_TYPEHASH, owner, spender, value, _useNonce(owner), deadline));
bytes32 hash = _hashTypedDataV4(structHash);
address signer = ECDSA.recover(hash, v, r, s);
require(signer == owner, "ERC20Permit: invalid signature");
_approve(owner, spender, value);
}
/**
* @dev See {IERC20Permit-nonces}.
*/
function nonces(address owner) public view virtual override returns (uint256) {
return _nonces[owner].current();
}
/**
* @dev See {IERC20Permit-DOMAIN_SEPARATOR}.
*/
// solhint-disable-next-line func-name-mixedcase
function DOMAIN_SEPARATOR() external view override returns (bytes32) {
return _domainSeparatorV4();
}
/**
* @dev "Consume a nonce": return the current value and increment.
*
* _Available since v4.1._
*/
function _useNonce(address owner) internal virtual returns (uint256 current) {
Counters.Counter storage nonce = _nonces[owner];
current = nonce.current();
nonce.increment();
}
}
// Part: BToken
contract BToken is ERC20Permit, ReentrancyGuard {
using SafeERC20 for IERC20;
event Accrue(uint interest);
event Mint(address indexed caller, address indexed to, uint amount, uint credit);
event Burn(address indexed caller, address indexed to, uint amount, uint credit);
uint public constant MINIMUM_LIQUIDITY = 10**6; // minimum liquidity to be locked in the pool when first mint occurs
address public immutable betaBank; // BetaBank address
address public immutable underlying; // the underlying token
uint public interestRate; // current interest rate
uint public lastAccrueTime; // last interest accrual timestamp
uint public totalLoanable; // total asset amount available to be borrowed
uint public totalLoan; // total amount of loan
uint public totalDebtShare; // total amount of debt share
/// @dev Initializes the BToken contract.
/// @param _betaBank BetaBank address.
/// @param _underlying The underlying token address for the bToken.
constructor(address _betaBank, address _underlying)
ERC20Permit('B Token')
ERC20('B Token', 'bTOKEN')
{
require(_betaBank != address(0), 'constructor/betabank-zero-address');
require(_underlying != address(0), 'constructor/underlying-zero-address');
betaBank = _betaBank;
underlying = _underlying;
interestRate = IBetaInterestModel(IBetaBank(_betaBank).interestModel()).initialRate();
lastAccrueTime = block.timestamp;
}
/// @dev Returns the name of the token.
function name() public view override returns (string memory) {
try IERC20Metadata(underlying).name() returns (string memory data) {
return string(abi.encodePacked('B ', data));
} catch (bytes memory) {
return ERC20.name();
}
}
/// @dev Returns the symbol of the token.
function symbol() public view override returns (string memory) {
try IERC20Metadata(underlying).symbol() returns (string memory data) {
return string(abi.encodePacked('b', data));
} catch (bytes memory) {
return ERC20.symbol();
}
}
/// @dev Returns the decimal places of the token.
function decimals() public view override returns (uint8) {
try IERC20Metadata(underlying).decimals() returns (uint8 data) {
return data;
} catch (bytes memory) {
return ERC20.decimals();
}
}
/// @dev Accrues interest rate and adjusts the rate. Can be called by anyone at any time.
function accrue() public {
// 1. Check time past condition
uint timePassed = block.timestamp - lastAccrueTime;
if (timePassed == 0) return;
lastAccrueTime = block.timestamp;
// 2. Check bank pause condition
require(!Pausable(betaBank).paused(), 'BetaBank/paused');
// 3. Compute the accrued interest value over the past time
(uint totalLoan_, uint totalLoanable_, uint interestRate_) = (
totalLoan,
totalLoanable,
interestRate
); // gas saving by avoiding multiple SLOADs
IBetaConfig config = IBetaConfig(IBetaBank(betaBank).config());
IBetaInterestModel model = IBetaInterestModel(IBetaBank(betaBank).interestModel());
uint interest = (interestRate_ * totalLoan_ * timePassed) / (365 days) / 1e18;
// 4. Update total loan and next interest rate
totalLoan_ += interest;
totalLoan = totalLoan_;
interestRate = model.getNextInterestRate(interestRate_, totalLoanable_, totalLoan_, timePassed);
// 5. Send a portion of collected interest to the beneficiary
if (interest > 0) {
uint reserveRate = config.reserveRate();
if (reserveRate > 0) {
uint toReserve = (interest * reserveRate) / 1e18;
_mint(
config.reserveBeneficiary(),
(toReserve * totalSupply()) / (totalLoan_ + totalLoanable_ - toReserve)
);
}
emit Accrue(interest);
}
}
/// @dev Returns the debt value for the given debt share. Automatically calls accrue.
function fetchDebtShareValue(uint _debtShare) external returns (uint) {
accrue();
if (_debtShare == 0) {
return 0;
}
return Math.ceilDiv(_debtShare * totalLoan, totalDebtShare); // round up
}
/// @dev Mints new bToken to the given address.
/// @param _to The address to mint new bToken for.
/// @param _amount The amount of underlying tokens to deposit via `transferFrom`.
/// @return credit The amount of bToken minted.
function mint(address _to, uint _amount) external nonReentrant returns (uint credit) {
accrue();
uint amount;
{
uint balBefore = IERC20(underlying).balanceOf(address(this));
IERC20(underlying).safeTransferFrom(msg.sender, address(this), _amount);
uint balAfter = IERC20(underlying).balanceOf(address(this));
amount = balAfter - balBefore;
}
uint supply = totalSupply();
if (supply == 0) {
credit = amount - MINIMUM_LIQUIDITY;
// Permanently lock the first MINIMUM_LIQUIDITY tokens
totalLoanable += credit;
totalLoan += MINIMUM_LIQUIDITY;
totalDebtShare += MINIMUM_LIQUIDITY;
_mint(address(1), MINIMUM_LIQUIDITY); // OpenZeppelin ERC20 does not allow minting to 0
} else {
credit = (amount * supply) / (totalLoanable + totalLoan);
totalLoanable += amount;
}
require(credit > 0, 'mint/no-credit-minted');
_mint(_to, credit);
emit Mint(msg.sender, _to, _amount, credit);
}
/// @dev Burns the given bToken for the proportional amount of underlying tokens.
/// @param _to The address to send the underlying tokens to.
/// @param _credit The amount of bToken to burn.
/// @return amount The amount of underlying tokens getting transferred out.
function burn(address _to, uint _credit) external nonReentrant returns (uint amount) {
accrue();
uint supply = totalSupply();
amount = (_credit * (totalLoanable + totalLoan)) / supply;
require(amount > 0, 'burn/no-amount-returned');
totalLoanable -= amount;
_burn(msg.sender, _credit);
IERC20(underlying).safeTransfer(_to, amount);
emit Burn(msg.sender, _to, amount, _credit);
}
/// @dev Borrows the funds for the given address. Must only be called by BetaBank.
/// @param _to The address to borrow the funds for.
/// @param _amount The amount to borrow.
/// @return debtShare The amount of new debt share minted.
function borrow(address _to, uint _amount) external nonReentrant returns (uint debtShare) {
require(msg.sender == betaBank, 'borrow/not-BetaBank');
accrue();
IERC20(underlying).safeTransfer(_to, _amount);
debtShare = Math.ceilDiv(_amount * totalDebtShare, totalLoan); // round up
totalLoanable -= _amount;
totalLoan += _amount;
totalDebtShare += debtShare;
}
/// @dev Repays the debt using funds from the given address. Must only be called by BetaBank.
/// @param _from The address to drain the funds to repay.
/// @param _amount The amount of funds to call via `transferFrom`.
/// @return debtShare The amount of debt share repaid.
function repay(address _from, uint _amount) external nonReentrant returns (uint debtShare) {
require(msg.sender == betaBank, 'repay/not-BetaBank');
accrue();
uint amount;
{
uint balBefore = IERC20(underlying).balanceOf(address(this));
IERC20(underlying).safeTransferFrom(_from, address(this), _amount);
uint balAfter = IERC20(underlying).balanceOf(address(this));
amount = balAfter - balBefore;
}
require(amount <= totalLoan, 'repay/amount-too-high');
debtShare = (amount * totalDebtShare) / totalLoan; // round down
totalLoanable += amount;
totalLoan -= amount;
totalDebtShare -= debtShare;
require(totalDebtShare >= MINIMUM_LIQUIDITY, 'repay/too-low-sum-debt-share');
}
/// @dev Recovers tokens in this contract. EMERGENCY ONLY. Full trust in BetaBank.
/// @param _token The token to recover, can even be underlying so please be careful.
/// @param _to The address to recover tokens to.
/// @param _amount The amount of tokens to recover, or MAX_UINT256 if whole balance.
function recover(
address _token,
address _to,
uint _amount
) external nonReentrant {
require(msg.sender == betaBank, 'recover/not-BetaBank');
if (_amount == type(uint).max) {
_amount = IERC20(_token).balanceOf(address(this));
}
IERC20(_token).safeTransfer(_to, _amount);
}
}
// Part: BTokenDeployer
contract BTokenDeployer {
/// @dev Deploys a new BToken contract for the given underlying token.
function deploy(address _underlying) external returns (address) {
bytes32 salt = keccak256(abi.encode(msg.sender, _underlying));
return address(new BToken{salt: salt}(msg.sender, _underlying));
}
/// @dev Returns the deterministic BToken address for the given BetaBank + underlying.
function bTokenFor(address _betaBank, address _underlying) external view returns (address) {
bytes memory args = abi.encode(_betaBank, _underlying);
bytes32 code = keccak256(abi.encodePacked(type(BToken).creationCode, args));
bytes32 salt = keccak256(args);
return address(uint160(uint(keccak256(abi.encodePacked(hex'ff', address(this), salt, code)))));
}
}
// File: BetaBank.sol
contract BetaBank is IBetaBank, Initializable, Pausable {
using Address for address;
using SafeERC20 for IERC20;
event Create(address indexed underlying, address bToken);
event Open(address indexed owner, uint indexed pid, address bToken, address collateral);
event Borrow(address indexed owner, uint indexed pid, uint amount, uint share, address borrower);
event Repay(address indexed owner, uint indexed pid, uint amount, uint share, address payer);
event Put(address indexed owner, uint indexed pid, uint amount, address payer);
event Take(address indexed owner, uint indexed pid, uint amount, address to);
event Liquidate(
address indexed owner,
uint indexed pid,
uint amount,
uint share,
uint reward,
address caller
);
event SelflessLiquidate(
address indexed owner,
uint indexed pid,
uint amount,
uint share,
address caller
);
event SetGovernor(address governor);
event SetPendingGovernor(address pendingGovernor);
event SetOracle(address oracle);
event SetConfig(address config);
event SetInterestModel(address interestModel);
event SetRunnerWhitelist(address indexed runner, bool ok);
event SetOwnerWhitelist(address indexed owner, bool ok);
event SetAllowPublicCreate(bool ok);
struct Position {
uint32 blockBorrowPut; // safety check
uint32 blockRepayTake; // safety check
address bToken;
address collateral;
uint collateralSize;
uint debtShare;
}
uint private unlocked; // reentrancy variable
address public deployer; // deployer address
address public override oracle; // oracle address
address public override config; // config address
address public override interestModel; // interest rate model address
address public governor; // current governor
address public pendingGovernor; // pending governor
bool public allowPublicCreate; // allow public to create pool status
mapping(address => address) public override bTokens; // mapping from underlying to bToken
mapping(address => address) public override underlyings; // mapping from bToken to underlying token
mapping(address => bool) public runnerWhitelists; // whitelist of authorized routers
mapping(address => bool) public ownerWhitelists; // whitelist of authorized owners
mapping(address => mapping(uint => Position)) public positions; // mapping from user to the user's position id to Position info
mapping(address => uint) public nextPositionIds; // mapping from user to next position id (position count)
mapping(address => uint) public totalCollaterals; // mapping from token address to amount of collateral
/// @dev Reentrancy guard modifier
modifier lock() {
require(unlocked == 1, 'BetaBank/locked');
unlocked = 2;
_;
unlocked = 1;
}
/// @dev Only governor is allowed modifier.
modifier onlyGov() {
require(msg.sender == governor, 'BetaBank/onlyGov');
_;
}
/// @dev Check if sender is allowed to perform action on behalf of the owner modifier.
modifier isPermittedByOwner(address _owner) {
require(isPermittedCaller(_owner, msg.sender), 'BetaBank/isPermittedByOwner');
_;
}
/// @dev Check is pool id exist for the owner modifier.
modifier checkPID(address _owner, uint _pid) {
require(_pid < nextPositionIds[_owner], 'BetaBank/checkPID');
_;
}
/// @dev Initializes this smart contract. No constructor to make this upgradable.
function initialize(
address _governor,
address _deployer,
address _oracle,
address _config,
address _interestModel
) external initializer {
require(_governor != address(0), 'initialize/governor-zero-address');
require(_deployer != address(0), 'initialize/deployer-zero-address');
require(_oracle != address(0), 'initialize/oracle-zero-address');
require(_config != address(0), 'initialize/config-zero-address');
require(_interestModel != address(0), 'initialize/interest-model-zero-address');
governor = _governor;
deployer = _deployer;
oracle = _oracle;
config = _config;
interestModel = _interestModel;
unlocked = 1;
emit SetGovernor(_governor);
emit SetOracle(_oracle);
emit SetConfig(_config);
emit SetInterestModel(_interestModel);
}
/// @dev Sets the next governor, which will be in effect when they accept.
/// @param _pendingGovernor The next governor address.
function setPendingGovernor(address _pendingGovernor) external onlyGov {
pendingGovernor = _pendingGovernor;
emit SetPendingGovernor(_pendingGovernor);
}
/// @dev Accepts to become the next governor. Must only be called by the pending governor.
function acceptGovernor() external {
require(msg.sender == pendingGovernor, 'acceptGovernor/not-pending-governor');
pendingGovernor = address(0);
governor = msg.sender;
emit SetGovernor(msg.sender);
}
/// @dev Updates the oracle address. Must only be called by the governor.
function setOracle(address _oracle) external onlyGov {
require(_oracle != address(0), 'setOracle/zero-address');
oracle = _oracle;
emit SetOracle(_oracle);
}
/// @dev Updates the config address. Must only be called by the governor.
function setConfig(address _config) external onlyGov {
require(_config != address(0), 'setConfig/zero-address');
config = _config;
emit SetConfig(_config);
}
/// @dev Updates the interest model address. Must only be called by the governor.
function setInterestModel(address _interestModel) external onlyGov {
require(_interestModel != address(0), 'setInterestModel/zero-address');
interestModel = _interestModel;
emit SetInterestModel(_interestModel);
}
/// @dev Sets the whitelist statuses for the given runners. Must only be called by the governor.
function setRunnerWhitelists(address[] calldata _runners, bool ok) external onlyGov {
for (uint idx = 0; idx < _runners.length; idx++) {
runnerWhitelists[_runners[idx]] = ok;
emit SetRunnerWhitelist(_runners[idx], ok);
}
}
/// @dev Sets the whitelist statuses for the given owners. Must only be called by the governor.
function setOwnerWhitelists(address[] calldata _owners, bool ok) external onlyGov {
for (uint idx = 0; idx < _owners.length; idx++) {
ownerWhitelists[_owners[idx]] = ok;
emit SetOwnerWhitelist(_owners[idx], ok);
}
}
/// @dev Pauses and stops money market-related interactions. Must only be called by the governor.
function pause() external whenNotPaused onlyGov {
_pause();
}
/// @dev Unpauses and allows again money market-related interactions. Must only be called by the governor.
function unpause() external whenPaused onlyGov {
_unpause();
}
/// @dev Sets whether anyone can create btoken of any token. Must only be called by the governor.
function setAllowPublicCreate(bool _ok) external onlyGov {
allowPublicCreate = _ok;
emit SetAllowPublicCreate(_ok);
}
/// @dev Creates a new money market for the given underlying token. Permissionless.
/// @param _underlying The ERC-20 that is borrowable in the newly created market contract.
function create(address _underlying) external lock whenNotPaused returns (address bToken) {
require(allowPublicCreate || msg.sender == governor, 'create/unauthorized');
require(_underlying != address(this), 'create/not-like-this');
require(_underlying.isContract(), 'create/underlying-not-contract');
require(bTokens[_underlying] == address(0), 'create/underlying-already-exists');
require(IBetaOracle(oracle).getAssetETHPrice(_underlying) > 0, 'create/no-price');
bToken = BTokenDeployer(deployer).deploy(_underlying);
bTokens[_underlying] = bToken;
underlyings[bToken] = _underlying;
emit Create(_underlying, bToken);
}
/// @dev Returns whether the given sender is allowed to interact with a position of the owner.
function isPermittedCaller(address _owner, address _sender) public view returns (bool) {
// ONE OF THE TWO CONDITIONS MUST HOLD:
// 1. allow if sender is owner and owner is whitelisted.
// 2. allow if owner is origin tx sender (for extra safety) and sender is globally accepted.
return ((_owner == _sender && ownerWhitelists[_owner]) ||
(_owner == tx.origin && runnerWhitelists[_sender]));
}
/// @dev Returns the position's collateral token and BToken.
function getPositionTokens(address _owner, uint _pid)
external
view
override
checkPID(_owner, _pid)
returns (address _collateral, address _bToken)
{
Position storage pos = positions[_owner][_pid];
_collateral = pos.collateral;
_bToken = pos.bToken;
}
/// @dev Returns the debt of the given position. Can't be view as it needs to call accrue.
function fetchPositionDebt(address _owner, uint _pid)
external
override
checkPID(_owner, _pid)
returns (uint)
{
Position storage pos = positions[_owner][_pid];
return BToken(pos.bToken).fetchDebtShareValue(pos.debtShare);
}
/// @dev Returns the LTV of the given position. Can't be view as it needs to call accrue.
function fetchPositionLTV(address _owner, uint _pid)
external
override
checkPID(_owner, _pid)
returns (uint)
{
return _fetchPositionLTV(positions[_owner][_pid]);
}
/// @dev Opens a new position to borrow a specific token for a specific collateral.
/// @param _owner The owner of the newly created position. Sender must be allowed to act for.
/// @param _underlying The token that is allowed to be borrowed in this position.
/// @param _collateral The token that is used as collateral in this position.
function open(
address _owner,
address _underlying,
address _collateral
) external override whenNotPaused isPermittedByOwner(_owner) returns (uint pid) {
address bToken = bTokens[_underlying];
require(bToken != address(0), 'open/bad-underlying');
require(_underlying != _collateral, 'open/self-collateral');
require(IBetaConfig(config).getCollFactor(_collateral) > 0, 'open/bad-collateral');
require(IBetaOracle(oracle).getAssetETHPrice(_collateral) > 0, 'open/no-price');
pid = nextPositionIds[_owner]++;
Position storage pos = positions[_owner][pid];
pos.bToken = bToken;
pos.collateral = _collateral;
emit Open(_owner, pid, bToken, _collateral);
}
/// @dev Borrows tokens on the given position. Position must still be safe.
/// @param _owner The position owner to borrow underlying tokens.
/// @param _pid The position id to borrow underlying tokens.
/// @param _amount The amount of underlying tokens to borrow.
function borrow(
address _owner,
uint _pid,
uint _amount
) external override lock whenNotPaused isPermittedByOwner(_owner) checkPID(_owner, _pid) {
// 1. pre-conditions
Position memory pos = positions[_owner][_pid];
require(pos.blockRepayTake != uint32(block.number), 'borrow/bad-block');
// 2. perform the borrow and update the position
uint share = BToken(pos.bToken).borrow(msg.sender, _amount);
pos.debtShare += share;
positions[_owner][_pid].debtShare = pos.debtShare;
positions[_owner][_pid].blockBorrowPut = uint32(block.number);
// 3. make sure the position is still safe
uint ltv = _fetchPositionLTV(pos);
require(ltv <= IBetaConfig(config).getSafetyLTV(underlyings[pos.bToken]), 'borrow/not-safe');
emit Borrow(_owner, _pid, _amount, share, msg.sender);
}
/// @dev Repays tokens on the given position. Payer must be position owner or sender.
/// @param _owner The position owner to repay underlying tokens.
/// @param _pid The position id to repay underlying tokens.
/// @param _amount The amount of underlying tokens to repay.
function repay(
address _owner,
uint _pid,
uint _amount
) external override lock whenNotPaused isPermittedByOwner(_owner) checkPID(_owner, _pid) {
// 1. pre-conditions
Position memory pos = positions[_owner][_pid];
require(pos.blockBorrowPut != uint32(block.number), 'repay/bad-block');
// 2. perform the repayment and update the position - no collateral check required
uint share = BToken(pos.bToken).repay(msg.sender, _amount);
pos.debtShare -= share;
positions[_owner][_pid].debtShare = pos.debtShare;
positions[_owner][_pid].blockRepayTake = uint32(block.number);
emit Repay(_owner, _pid, _amount, share, msg.sender);
}
/// @dev Puts more collateral to the given position. Payer must be position owner or sender.
/// @param _owner The position owner to put more collateral.
/// @param _pid The position id to put more collateral.
/// @param _amount The amount of collateral to put via `transferFrom`.
function put(
address _owner,
uint _pid,
uint _amount
) external override lock whenNotPaused isPermittedByOwner(_owner) checkPID(_owner, _pid) {
// 1. pre-conditions
Position memory pos = positions[_owner][_pid];
require(pos.blockRepayTake != uint32(block.number), 'put/bad-block');
// 2. transfer collateral tokens in
uint amount;
{
uint balBefore = IERC20(pos.collateral).balanceOf(address(this));
IERC20(pos.collateral).safeTransferFrom(msg.sender, address(this), _amount);
uint balAfter = IERC20(pos.collateral).balanceOf(address(this));
amount = balAfter - balBefore;
}
// 3. update the position and total collateral + check global collateral cap
pos.collateralSize += amount;
totalCollaterals[pos.collateral] += amount;
require(
totalCollaterals[pos.collateral] <= IBetaConfig(config).getCollMaxAmount(pos.collateral),
'put/too-much-collateral'
);
positions[_owner][_pid].collateralSize = pos.collateralSize;
positions[_owner][_pid].blockBorrowPut = uint32(block.number);
emit Put(_owner, _pid, _amount, msg.sender);
}
/// @dev Takes some collateral out of the position and send it out. Position must still be safe.
/// @param _owner The position owner to take collateral out.
/// @param _pid The position id to take collateral out.
/// @param _amount The amount of collateral to take via `transfer`.
function take(
address _owner,
uint _pid,
uint _amount
) external override lock whenNotPaused isPermittedByOwner(_owner) checkPID(_owner, _pid) {
// 1. pre-conditions
Position memory pos = positions[_owner][_pid];
require(pos.blockBorrowPut != uint32(block.number), 'take/bad-block');
// 2. update position collateral size and total collateral
pos.collateralSize -= _amount;
totalCollaterals[pos.collateral] -= _amount;
positions[_owner][_pid].collateralSize = pos.collateralSize;
positions[_owner][_pid].blockRepayTake = uint32(block.number);
// 3. make sure the position is still safe
uint ltv = _fetchPositionLTV(pos);
require(ltv <= IBetaConfig(config).getSafetyLTV(underlyings[pos.bToken]), 'take/not-safe');
// 4. transfer collateral tokens out
IERC20(pos.collateral).safeTransfer(msg.sender, _amount);
emit Take(_owner, _pid, _amount, msg.sender);
}
/// @dev Liquidates the given position. Can be called by anyone but must be liquidatable.
/// @param _owner The position owner to be liquidated.
/// @param _pid The position id to be liquidated.
/// @param _amount The amount of debt to be repaid by caller. Must not exceed half debt (rounded up).
function liquidate(
address _owner,
uint _pid,
uint _amount
) external override lock whenNotPaused checkPID(_owner, _pid) {
// 1. check liquidation condition
Position memory pos = positions[_owner][_pid];
address underlying = underlyings[pos.bToken];
uint ltv = _fetchPositionLTV(pos);
require(ltv >= IBetaConfig(config).getLiquidationLTV(underlying), 'liquidate/not-liquidatable');
// 2. perform repayment
uint debtShare = BToken(pos.bToken).repay(msg.sender, _amount);
require(debtShare <= (pos.debtShare + 1) / 2, 'liquidate/too-much-liquidation');
// 3. calculate reward and payout
uint debtValue = BToken(pos.bToken).fetchDebtShareValue(debtShare);
uint collValue = IBetaOracle(oracle).convert(underlying, pos.collateral, debtValue);
uint payout = Math.min(
collValue + (collValue * IBetaConfig(config).getKillBountyRate(underlying)) / 1e18,
pos.collateralSize
);
// 4. update the position and total collateral
pos.debtShare -= debtShare;
positions[_owner][_pid].debtShare = pos.debtShare;
pos.collateralSize -= payout;
positions[_owner][_pid].collateralSize = pos.collateralSize;
totalCollaterals[pos.collateral] -= payout;
// 5. transfer the payout out
IERC20(pos.collateral).safeTransfer(msg.sender, payout);
emit Liquidate(_owner, _pid, _amount, debtShare, payout, msg.sender);
}
/// @dev onlyGov selfless liquidation if collateral size = 0
/// @param _owner The position owner to be liquidated.
/// @param _pid The position id to be liquidated.
/// @param _amount The amount of debt to be repaid by caller.
function selflessLiquidate(
address _owner,
uint _pid,
uint _amount
) external onlyGov lock checkPID(_owner, _pid) {
// 1. check positions collateral size
Position memory pos = positions[_owner][_pid];
require(pos.collateralSize == 0, 'selflessLiquidate/positive-collateral');
// 2. perform debt repayment
uint debtValue = BToken(pos.bToken).fetchDebtShareValue(pos.debtShare);
_amount = Math.min(_amount, debtValue);
uint debtShare = BToken(pos.bToken).repay(msg.sender, _amount);
pos.debtShare -= debtShare;
positions[_owner][_pid].debtShare = pos.debtShare;
emit SelflessLiquidate(_owner, _pid, _amount, debtShare, msg.sender);
}
/// @dev Recovers lost tokens by the governor. This function is extremely powerful so be careful.
/// @param _bToken The BToken to propagate this recover call.
/// @param _token The ERC20 token to recover.
/// @param _amount The amount of tokens to recover.
function recover(
address _bToken,
address _token,
uint _amount
) external onlyGov lock {
require(underlyings[_bToken] != address(0), 'recover/not-bToken');
BToken(_bToken).recover(_token, msg.sender, _amount);
}
/// @dev Returns the current LTV of the given position.
function _fetchPositionLTV(Position memory pos) internal returns (uint) {
if (pos.debtShare == 0) {
return 0; // no debt means zero LTV
}
address oracle_ = oracle; // gas saving
uint collFactor = IBetaConfig(config).getCollFactor(pos.collateral);
require(collFactor > 0, 'fetch/bad-collateral');
uint debtSize = BToken(pos.bToken).fetchDebtShareValue(pos.debtShare);
uint debtValue = IBetaOracle(oracle_).getAssetETHValue(underlyings[pos.bToken], debtSize);
uint collCred = (pos.collateralSize * collFactor) / 1e18;
uint collValue = IBetaOracle(oracle_).getAssetETHValue(pos.collateral, collCred);
if (debtValue >= collValue) {
return 1e18; // 100% LTV is very very bad and must always be liquidatable and unsafe
}
return (debtValue * 1e18) / collValue;
}
}Contract Security Audit
- No Contract Security Audit Submitted- Submit Audit Here
Contract ABI
API[{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"owner","type":"address"},{"indexed":true,"internalType":"uint256","name":"pid","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"share","type":"uint256"},{"indexed":false,"internalType":"address","name":"borrower","type":"address"}],"name":"Borrow","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"underlying","type":"address"},{"indexed":false,"internalType":"address","name":"bToken","type":"address"}],"name":"Create","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"owner","type":"address"},{"indexed":true,"internalType":"uint256","name":"pid","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"share","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"reward","type":"uint256"},{"indexed":false,"internalType":"address","name":"caller","type":"address"}],"name":"Liquidate","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"owner","type":"address"},{"indexed":true,"internalType":"uint256","name":"pid","type":"uint256"},{"indexed":false,"internalType":"address","name":"bToken","type":"address"},{"indexed":false,"internalType":"address","name":"collateral","type":"address"}],"name":"Open","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"account","type":"address"}],"name":"Paused","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"owner","type":"address"},{"indexed":true,"internalType":"uint256","name":"pid","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"},{"indexed":false,"internalType":"address","name":"payer","type":"address"}],"name":"Put","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"owner","type":"address"},{"indexed":true,"internalType":"uint256","name":"pid","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"share","type":"uint256"},{"indexed":false,"internalType":"address","name":"payer","type":"address"}],"name":"Repay","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"owner","type":"address"},{"indexed":true,"internalType":"uint256","name":"pid","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"share","type":"uint256"},{"indexed":false,"internalType":"address","name":"caller","type":"address"}],"name":"SelflessLiquidate","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"bool","name":"ok","type":"bool"}],"name":"SetAllowPublicCreate","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"config","type":"address"}],"name":"SetConfig","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"governor","type":"address"}],"name":"SetGovernor","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"interestModel","type":"address"}],"name":"SetInterestModel","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"oracle","type":"address"}],"name":"SetOracle","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"owner","type":"address"},{"indexed":false,"internalType":"bool","name":"ok","type":"bool"}],"name":"SetOwnerWhitelist","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"pendingGovernor","type":"address"}],"name":"SetPendingGovernor","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"runner","type":"address"},{"indexed":false,"internalType":"bool","name":"ok","type":"bool"}],"name":"SetRunnerWhitelist","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"owner","type":"address"},{"indexed":true,"internalType":"uint256","name":"pid","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"},{"indexed":false,"internalType":"address","name":"to","type":"address"}],"name":"Take","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"account","type":"address"}],"name":"Unpaused","type":"event"},{"inputs":[],"name":"acceptGovernor","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"allowPublicCreate","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"bTokens","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_owner","type":"address"},{"internalType":"uint256","name":"_pid","type":"uint256"},{"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"borrow","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"config","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_underlying","type":"address"}],"name":"create","outputs":[{"internalType":"address","name":"bToken","type":"address"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"deployer","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_owner","type":"address"},{"internalType":"uint256","name":"_pid","type":"uint256"}],"name":"fetchPositionDebt","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_owner","type":"address"},{"internalType":"uint256","name":"_pid","type":"uint256"}],"name":"fetchPositionLTV","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_owner","type":"address"},{"internalType":"uint256","name":"_pid","type":"uint256"}],"name":"getPositionTokens","outputs":[{"internalType":"address","name":"_collateral","type":"address"},{"internalType":"address","name":"_bToken","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"governor","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_governor","type":"address"},{"internalType":"address","name":"_deployer","type":"address"},{"internalType":"address","name":"_oracle","type":"address"},{"internalType":"address","name":"_config","type":"address"},{"internalType":"address","name":"_interestModel","type":"address"}],"name":"initialize","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"interestModel","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_owner","type":"address"},{"internalType":"address","name":"_sender","type":"address"}],"name":"isPermittedCaller","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_owner","type":"address"},{"internalType":"uint256","name":"_pid","type":"uint256"},{"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"liquidate","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"nextPositionIds","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_owner","type":"address"},{"internalType":"address","name":"_underlying","type":"address"},{"internalType":"address","name":"_collateral","type":"address"}],"name":"open","outputs":[{"internalType":"uint256","name":"pid","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"oracle","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"ownerWhitelists","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"pause","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"paused","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"pendingGovernor","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"uint256","name":"","type":"uint256"}],"name":"positions","outputs":[{"internalType":"uint32","name":"blockBorrowPut","type":"uint32"},{"internalType":"uint32","name":"blockRepayTake","type":"uint32"},{"internalType":"address","name":"bToken","type":"address"},{"internalType":"address","name":"collateral","type":"address"},{"internalType":"uint256","name":"collateralSize","type":"uint256"},{"internalType":"uint256","name":"debtShare","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_owner","type":"address"},{"internalType":"uint256","name":"_pid","type":"uint256"},{"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"put","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_bToken","type":"address"},{"internalType":"address","name":"_token","type":"address"},{"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"recover","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_owner","type":"address"},{"internalType":"uint256","name":"_pid","type":"uint256"},{"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"repay","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"runnerWhitelists","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_owner","type":"address"},{"internalType":"uint256","name":"_pid","type":"uint256"},{"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"selflessLiquidate","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bool","name":"_ok","type":"bool"}],"name":"setAllowPublicCreate","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_config","type":"address"}],"name":"setConfig","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_interestModel","type":"address"}],"name":"setInterestModel","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_oracle","type":"address"}],"name":"setOracle","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address[]","name":"_owners","type":"address[]"},{"internalType":"bool","name":"ok","type":"bool"}],"name":"setOwnerWhitelists","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_pendingGovernor","type":"address"}],"name":"setPendingGovernor","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address[]","name":"_runners","type":"address[]"},{"internalType":"bool","name":"ok","type":"bool"}],"name":"setRunnerWhitelists","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_owner","type":"address"},{"internalType":"uint256","name":"_pid","type":"uint256"},{"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"take","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"totalCollaterals","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"underlyings","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"unpause","outputs":[],"stateMutability":"nonpayable","type":"function"}]Contract Creation Code
608060405234801561001057600080fd5b506000805462ff000019169055613ea98061002c6000396000f3fe608060405234801561001057600080fd5b506004361061023c5760003560e01c80638456cb591161013b578063c1bce0b7116100b8578063e3056a341161007c578063e3056a34146105e7578063e5074709146105fa578063e58bb6391461062d578063f235757f14610635578063f71fd5961461064857600080fd5b8063c1bce0b7146104f4578063c1be667714610507578063c640e9bf146105ae578063c9c8eb6c146105c1578063d5f39488146105d457600080fd5b8063ab01040e116100ff578063ab01040e1461047a578063ac165d7a1461049a578063b0886fe4146104ad578063b5beb20b146104c1578063bf1f53b6146104d457600080fd5b80638456cb59146104065780638cd2e0c71461040e57806390427116146104215780639413126a146104445780639ed933181461046757600080fd5b80634e16cf42116101c95780636e3f5d521161018d5780636e3f5d52146103a757806379502c55146103ba5780637adbf973146103cd5780637dc0d1d0146103e057806382762062146103f357600080fd5b80634e16cf421461030e57806351a491ad1461032157806351ea519a146103445780635c975abb1461036d578063679a8da81461037e57600080fd5b80631ec82cb8116102105780631ec82cb8146102ba57806320e3dbd4146102cd5780632ba4391a146102e057806333e1cf5d146102f35780633f4ba83a1461030657600080fd5b8062187482146102415780630710285c146102675780630c340a241461027c5780631459457a146102a7575b600080fd5b61025461024f366004613b0d565b61065b565b6040519081526020015b60405180910390f35b61027a610275366004613b39565b610751565b005b60065461028f906001600160a01b031681565b6040516001600160a01b03909116815260200161025e565b61027a6102b5366004613a5b565b610d5d565b61027a6102c8366004613acc565b611112565b61027a6102db36600461399d565b611230565b61027a6102ee366004613b39565b6112fe565b61027a610301366004613be9565b61175a565b61027a6117d1565b61027a61031c366004613b6e565b611854565b61033461032f3660046139d7565b611960565b604051901515815260200161025e565b61028f61035236600461399d565b6008602052600090815260409020546001600160a01b031681565b60005462010000900460ff16610334565b61028f61038c36600461399d565b6009602052600090815260409020546001600160a01b031681565b61027a6103b536600461399d565b6119d8565b60045461028f906001600160a01b031681565b61027a6103db36600461399d565b611aa6565b60035461028f906001600160a01b031681565b610254610401366004613b0d565b611b6d565b61027a611c33565b61027a61041c366004613b39565b611c8e565b61033461042f36600461399d565b600b6020526000908152604090205460ff1681565b61033461045236600461399d565b600a6020526000908152604090205460ff1681565b61028f61047536600461399d565b611f28565b61025461048836600461399d565b600d6020526000908152604090205481565b60055461028f906001600160a01b031681565b60075461033490600160a01b900460ff1681565b61027a6104cf366004613b6e565b6122af565b6102546104e236600461399d565b600e6020526000908152604090205481565b61027a610502366004613b39565b6123b5565b61056c610515366004613b0d565b600c602090815260009283526040808420909152908252902080546001820154600283015460039093015463ffffffff80841694600160201b8504909116936001600160a01b03600160401b909104811693169186565b6040805163ffffffff97881681529690951660208701526001600160a01b039384169486019490945291166060840152608083015260a082015260c00161025e565b61027a6105bc366004613b39565b612743565b61027a6105cf366004613b39565b612a81565b60025461028f906001600160a01b031681565b60075461028f906001600160a01b031681565b61060d610608366004613b0d565b612d8a565b604080516001600160a01b0393841681529290911660208301520161025e565b61027a612e07565b61027a61064336600461399d565b612ec1565b610254610656366004613a10565b612f39565b6001600160a01b0382166000908152600d602052604081205483908390811061069f5760405162461bcd60e51b815260040161069690613d3f565b60405180910390fd5b6001600160a01b038581166000908152600c6020908152604080832088845290915290819020805460038201549251635dd9258560e01b815260048101939093529092600160401b9091041690635dd9258590602401602060405180830381600087803b15801561070f57600080fd5b505af1158015610723573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906107479190613c23565b9695505050505050565b6001546001146107735760405162461bcd60e51b815260040161069690613cb5565b600260015560005462010000900460ff16156107a15760405162461bcd60e51b815260040161069690613d15565b6001600160a01b0383166000908152600d60205260409020548390839081106107dc5760405162461bcd60e51b815260040161069690613d3f565b6001600160a01b038086166000908152600c602090815260408083208884528252808320815160c081018352815463ffffffff8082168352600160201b82041682860152600160401b900486168184018190526001830154871660608301526002830154608083015260039092015460a082015290845260099092528220549092169061086883613296565b60048054604051630eb94ee160e41b81526001600160a01b0386811693820193909352929350169063eb94ee109060240160206040518083038186803b1580156108b157600080fd5b505afa1580156108c5573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906108e99190613c23565b8110156109385760405162461bcd60e51b815260206004820152601a60248201527f6c69717569646174652f6e6f742d6c6971756964617461626c650000000000006044820152606401610696565b6040808401519051630450cfaf60e31b8152336004820152602481018890526000916001600160a01b0316906322867d7890604401602060405180830381600087803b15801561098757600080fd5b505af115801561099b573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906109bf9190613c23565b905060028460a0015160016109d49190613d6a565b6109de9190613d82565b811115610a2d5760405162461bcd60e51b815260206004820152601e60248201527f6c69717569646174652f746f6f2d6d7563682d6c69717569646174696f6e00006044820152606401610696565b6040808501519051635dd9258560e01b8152600481018390526000916001600160a01b031690635dd9258590602401602060405180830381600087803b158015610a7657600080fd5b505af1158015610a8a573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610aae9190613c23565b600354606087015160405163248391ff60e01b81526001600160a01b03888116600483015291821660248201526044810184905292935060009291169063248391ff90606401602060405180830381600087803b158015610b0e57600080fd5b505af1158015610b22573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610b469190613c23565b600480546040516339f041ad60e11b81526001600160a01b0389811693820193909352929350600092610c0092670de0b6b3a76400009216906373e0835a9060240160206040518083038186803b158015610ba057600080fd5b505afa158015610bb4573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610bd89190613c23565b610be29085613da4565b610bec9190613d82565b610bf69084613d6a565b88608001516135a5565b9050838760a001818151610c149190613dc3565b90525060a08701516001600160a01b038d166000908152600c602090815260408083208f8452909152902060030155608087018051829190610c57908390613dc3565b915081815250508660800151600c60008e6001600160a01b03166001600160a01b0316815260200190815260200160002060008d81526020019081526020016000206002018190555080600e600089606001516001600160a01b03166001600160a01b031681526020019081526020016000206000828254610cd99190613dc3565b90915550506060870151610cf7906001600160a01b031633836135bb565b604080518b8152602081018690529081018290523360608201528b906001600160a01b038e16907fdde0adb27be857d0db946bcab48f6a9f4b90b721fa0672622d5ec3de019bee3e9060800160405180910390a350506001805550505050505050505050565b600054610100900460ff1680610d76575060005460ff16155b610dd95760405162461bcd60e51b815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201526d191e481a5b9a5d1a585b1a5e995960921b6064820152608401610696565b600054610100900460ff16158015610dfb576000805461ffff19166101011790555b6001600160a01b038616610e515760405162461bcd60e51b815260206004820181905260248201527f696e697469616c697a652f676f7665726e6f722d7a65726f2d616464726573736044820152606401610696565b6001600160a01b038516610ea75760405162461bcd60e51b815260206004820181905260248201527f696e697469616c697a652f6465706c6f7965722d7a65726f2d616464726573736044820152606401610696565b6001600160a01b038416610efd5760405162461bcd60e51b815260206004820152601e60248201527f696e697469616c697a652f6f7261636c652d7a65726f2d6164647265737300006044820152606401610696565b6001600160a01b038316610f535760405162461bcd60e51b815260206004820152601e60248201527f696e697469616c697a652f636f6e6669672d7a65726f2d6164647265737300006044820152606401610696565b6001600160a01b038216610fb85760405162461bcd60e51b815260206004820152602660248201527f696e697469616c697a652f696e7465726573742d6d6f64656c2d7a65726f2d6160448201526564647265737360d01b6064820152608401610696565b600680546001600160a01b03199081166001600160a01b0389811691821790935560028054831689851617905560038054831688851617905560048054831687851617905560058054909216928516929092179055600180556040519081527fbce074c8369e26e70e1ae2f14fc944da352cfe6f52e2de9572f0c9942a24b7fc9060200160405180910390a16040516001600160a01b03851681527fd3b5d1e0ffaeff528910f3663f0adace7694ab8241d58e17a91351ced2e080319060200160405180910390a16040516001600160a01b03841681527fc5618716db99966ac0bedb011a55472827d54343d73b50c3118c0b03cdf1c75f9060200160405180910390a16040516001600160a01b03831681527f2f39052eae53bd818667d1ebcc2423988c8ef77de1477853c399e84c774d6b0e9060200160405180910390a1801561110a576000805461ff00191690555b505050505050565b6006546001600160a01b0316331461113c5760405162461bcd60e51b815260040161069690613c8b565b60015460011461115e5760405162461bcd60e51b815260040161069690613cb5565b60026001556001600160a01b03838116600090815260096020526040902054166111bf5760405162461bcd60e51b81526020600482015260126024820152713932b1b7bb32b917b737ba16b12a37b5b2b760711b6044820152606401610696565b6040516303d9059760e31b81526001600160a01b03838116600483015233602483015260448201839052841690631ec82cb890606401600060405180830381600087803b15801561120f57600080fd5b505af1158015611223573d6000803e3d6000fd5b5050600180555050505050565b6006546001600160a01b0316331461125a5760405162461bcd60e51b815260040161069690613c8b565b6001600160a01b0381166112a95760405162461bcd60e51b8152602060048201526016602482015275736574436f6e6669672f7a65726f2d6164647265737360501b6044820152606401610696565b600480546001600160a01b0319166001600160a01b0383169081179091556040519081527fc5618716db99966ac0bedb011a55472827d54343d73b50c3118c0b03cdf1c75f906020015b60405180910390a150565b6001546001146113205760405162461bcd60e51b815260040161069690613cb5565b600260015560005462010000900460ff161561134e5760405162461bcd60e51b815260040161069690613d15565b826113598133611960565b6113755760405162461bcd60e51b815260040161069690613cde565b6001600160a01b0384166000908152600d60205260409020548490849081106113b05760405162461bcd60e51b815260040161069690613d3f565b6001600160a01b038087166000908152600c60209081526040808320898452825291829020825160c081018452815463ffffffff8082168352600160201b82048116948301859052600160401b90910486169482019490945260018201549094166060850152600281015460808501526003015460a084015243909116141561146b5760405162461bcd60e51b815260206004820152600d60248201526c7075742f6261642d626c6f636b60981b6044820152606401610696565b60608101516040516370a0823160e01b815230600482015260009182916001600160a01b03909116906370a082319060240160206040518083038186803b1580156114b557600080fd5b505afa1580156114c9573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906114ed9190613c23565b606084015190915061150a906001600160a01b031633308a613623565b60608301516040516370a0823160e01b81523060048201526000916001600160a01b0316906370a082319060240160206040518083038186803b15801561155057600080fd5b505afa158015611564573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906115889190613c23565b90506115948282613dc3565b9250505080826080018181516115aa9190613d6a565b90525060608201516001600160a01b03166000908152600e6020526040812080548392906115d9908490613d6a565b909155505060048054606084015160405163665e2e5360e01b81526001600160a01b0391821693810193909352169063665e2e539060240160206040518083038186803b15801561162957600080fd5b505afa15801561163d573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906116619190613c23565b60608301516001600160a01b03166000908152600e602052604090205411156116cc5760405162461bcd60e51b815260206004820152601760248201527f7075742f746f6f2d6d7563682d636f6c6c61746572616c0000000000000000006044820152606401610696565b60808201516001600160a01b0389166000818152600c602090815260408083208c84528252918290206002810194909455835463ffffffff19164363ffffffff16179093558051898152339381019390935289927fa484f5dd35662c7e9a639bb18fd7c87293c82c2ba06dd2ff77536edf523d99f591015b60405180910390a3505060018055505050505050565b6006546001600160a01b031633146117845760405162461bcd60e51b815260040161069690613c8b565b60078054821515600160a01b0260ff60a01b199091161790556040517f1a993cb3baaaeecd4cf09f369bae7bb6a23acba7fdf4c37432a91bbdb4e3963a906112f390831515815260200190565b60005462010000900460ff166118205760405162461bcd60e51b815260206004820152601460248201527314185d5cd8589b194e881b9bdd081c185d5cd95960621b6044820152606401610696565b6006546001600160a01b0316331461184a5760405162461bcd60e51b815260040161069690613c8b565b61185261365b565b565b6006546001600160a01b0316331461187e5760405162461bcd60e51b815260040161069690613c8b565b60005b8281101561195a5781600a60008686858181106118a0576118a0613e37565b90506020020160208101906118b5919061399d565b6001600160a01b031681526020810191909152604001600020805460ff19169115159190911790558383828181106118ef576118ef613e37565b9050602002016020810190611904919061399d565b6001600160a01b03167f3e3f3513ca57dd2a4694ffe4ff73f0d13635c4793c347f048725832f7974303883604051611940911515815260200190565b60405180910390a28061195281613e06565b915050611881565b50505050565b6000816001600160a01b0316836001600160a01b031614801561199b57506001600160a01b0383166000908152600b602052604090205460ff165b806119d157506001600160a01b038316321480156119d157506001600160a01b0382166000908152600a602052604090205460ff165b9392505050565b6006546001600160a01b03163314611a025760405162461bcd60e51b815260040161069690613c8b565b6001600160a01b038116611a585760405162461bcd60e51b815260206004820152601d60248201527f736574496e7465726573744d6f64656c2f7a65726f2d616464726573730000006044820152606401610696565b600580546001600160a01b0319166001600160a01b0383169081179091556040519081527f2f39052eae53bd818667d1ebcc2423988c8ef77de1477853c399e84c774d6b0e906020016112f3565b6006546001600160a01b03163314611ad05760405162461bcd60e51b815260040161069690613c8b565b6001600160a01b038116611b1f5760405162461bcd60e51b81526020600482015260166024820152757365744f7261636c652f7a65726f2d6164647265737360501b6044820152606401610696565b600380546001600160a01b0319166001600160a01b0383169081179091556040519081527fd3b5d1e0ffaeff528910f3663f0adace7694ab8241d58e17a91351ced2e08031906020016112f3565b6001600160a01b0382166000908152600d6020526040812054839083908110611ba85760405162461bcd60e51b815260040161069690613d3f565b6001600160a01b038086166000908152600c60209081526040808320888452825291829020825160c081018452815463ffffffff8082168352600160201b82041693820193909352600160401b90920484169282019290925260018201549092166060830152600281015460808301526003015460a0820152611c2a90613296565b95945050505050565b60005462010000900460ff1615611c5c5760405162461bcd60e51b815260040161069690613d15565b6006546001600160a01b03163314611c865760405162461bcd60e51b815260040161069690613c8b565b6118526136f1565b600154600114611cb05760405162461bcd60e51b815260040161069690613cb5565b600260015560005462010000900460ff1615611cde5760405162461bcd60e51b815260040161069690613d15565b82611ce98133611960565b611d055760405162461bcd60e51b815260040161069690613cde565b6001600160a01b0384166000908152600d6020526040902054849084908110611d405760405162461bcd60e51b815260040161069690613d3f565b6001600160a01b038087166000908152600c60209081526040808320898452825291829020825160c081018452815463ffffffff808216808452600160201b8304821695840195909552600160401b90910486169482019490945260018201549094166060850152600281015460808501526003015460a0840152439091161415611dff5760405162461bcd60e51b815260206004820152600f60248201526e72657061792f6261642d626c6f636b60881b6044820152606401610696565b6040808201519051630450cfaf60e31b8152336004820152602481018790526000916001600160a01b0316906322867d7890604401602060405180830381600087803b158015611e4e57600080fd5b505af1158015611e62573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611e869190613c23565b9050808260a001818151611e9a9190613dc3565b90525060a08201516001600160a01b0389166000818152600c602090815260408083208c84528252918290206003810194909455835467ffffffff000000001916600160201b4363ffffffff1602179093558051898152928301849052339083015288917f09e02f7977f4cd69fd737ff7ee1a723f810d24bac179c0eaa8e5815a795d3ea490606001611744565b6000600154600114611f4c5760405162461bcd60e51b815260040161069690613cb5565b600260015560005462010000900460ff1615611f7a5760405162461bcd60e51b815260040161069690613d15565b600754600160a01b900460ff1680611f9c57506006546001600160a01b031633145b611fde5760405162461bcd60e51b815260206004820152601360248201527218dc99585d194bdd5b985d5d1a1bdc9a5e9959606a1b6044820152606401610696565b6001600160a01b03821630141561202e5760405162461bcd60e51b81526020600482015260146024820152736372656174652f6e6f742d6c696b652d7468697360601b6044820152606401610696565b6001600160a01b0382163b6120855760405162461bcd60e51b815260206004820152601e60248201527f6372656174652f756e6465726c79696e672d6e6f742d636f6e747261637400006044820152606401610696565b6001600160a01b0382811660009081526008602052604090205416156120ed5760405162461bcd60e51b815260206004820181905260248201527f6372656174652f756e6465726c79696e672d616c72656164792d6578697374736044820152606401610696565b60035460405163353d37f960e21b81526001600160a01b038481166004830152600092169063d4f4dfe490602401602060405180830381600087803b15801561213557600080fd5b505af1158015612149573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061216d9190613c23565b116121ac5760405162461bcd60e51b815260206004820152600f60248201526e6372656174652f6e6f2d707269636560881b6044820152606401610696565b600254604051634c96a38960e01b81526001600160a01b03848116600483015290911690634c96a38990602401602060405180830381600087803b1580156121f357600080fd5b505af1158015612207573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061222b91906139ba565b6001600160a01b03838116600081815260086020908152604080832080549587166001600160a01b031996871681179091558084526009835292819020805490951684179094559251908152929350917f96b5b9b8a7193304150caccf9b80d150675fa3d6af57761d8d8ef1d6f9a1a909910160405180910390a260018055919050565b6006546001600160a01b031633146122d95760405162461bcd60e51b815260040161069690613c8b565b60005b8281101561195a5781600b60008686858181106122fb576122fb613e37565b9050602002016020810190612310919061399d565b6001600160a01b031681526020810191909152604001600020805460ff191691151591909117905583838281811061234a5761234a613e37565b905060200201602081019061235f919061399d565b6001600160a01b03167f31713abf7651a5d93dd9702d3bbfdc9bf477ed7a7d4123d818499e7df9f62cc08360405161239b911515815260200190565b60405180910390a2806123ad81613e06565b9150506122dc565b6001546001146123d75760405162461bcd60e51b815260040161069690613cb5565b600260015560005462010000900460ff16156124055760405162461bcd60e51b815260040161069690613d15565b826124108133611960565b61242c5760405162461bcd60e51b815260040161069690613cde565b6001600160a01b0384166000908152600d60205260409020548490849081106124675760405162461bcd60e51b815260040161069690613d3f565b6001600160a01b038087166000908152600c60209081526040808320898452825291829020825160c081018452815463ffffffff8082168352600160201b82048116948301859052600160401b90910486169482019490945260018201549094166060850152600281015460808501526003015460a08401524390911614156125255760405162461bcd60e51b815260206004820152601060248201526f626f72726f772f6261642d626c6f636b60801b6044820152606401610696565b6040808201519051634b8a352960e01b8152336004820152602481018790526000916001600160a01b031690634b8a352990604401602060405180830381600087803b15801561257457600080fd5b505af1158015612588573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906125ac9190613c23565b9050808260a0018181516125c09190613d6a565b90525060a08201516001600160a01b0389166000908152600c602090815260408083208b845290915281206003810192909255815463ffffffff19164363ffffffff161790915561261083613296565b600480546040868101516001600160a01b03908116600090815260096020528290205491516337ea609360e01b81529181169382019390935292935016906337ea60939060240160206040518083038186803b15801561266f57600080fd5b505afa158015612683573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906126a79190613c23565b8111156126e85760405162461bcd60e51b815260206004820152600f60248201526e626f72726f772f6e6f742d7361666560881b6044820152606401610696565b60408051888152602081018490523381830152905189916001600160a01b038c16917f66213fb9f1fa2b7f0877f6506f7ce239ede54b92e550c29d9937d2808aeaa7229181900360600190a350506001805550505050505050565b6001546001146127655760405162461bcd60e51b815260040161069690613cb5565b600260015560005462010000900460ff16156127935760405162461bcd60e51b815260040161069690613d15565b8261279e8133611960565b6127ba5760405162461bcd60e51b815260040161069690613cde565b6001600160a01b0384166000908152600d60205260409020548490849081106127f55760405162461bcd60e51b815260040161069690613d3f565b6001600160a01b038087166000908152600c60209081526040808320898452825291829020825160c081018452815463ffffffff808216808452600160201b8304821695840195909552600160401b90910486169482019490945260018201549094166060850152600281015460808501526003015460a08401524390911614156128b35760405162461bcd60e51b815260206004820152600e60248201526d74616b652f6261642d626c6f636b60901b6044820152606401610696565b84816080018181516128c59190613dc3565b90525060608101516001600160a01b03166000908152600e6020526040812080548792906128f4908490613dc3565b909155505060808101516001600160a01b0388166000908152600c602090815260408083208a845290915281206002810192909255815467ffffffff000000001916600160201b4363ffffffff16021790915561295082613296565b600480546040858101516001600160a01b03908116600090815260096020528290205491516337ea609360e01b81529181169382019390935292935016906337ea60939060240160206040518083038186803b1580156129af57600080fd5b505afa1580156129c3573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906129e79190613c23565b811115612a265760405162461bcd60e51b815260206004820152600d60248201526c74616b652f6e6f742d7361666560981b6044820152606401610696565b6060820151612a3f906001600160a01b031633886135bb565b6040805187815233602082015288916001600160a01b038b16917f3c494f8e78d173658bbb4fc963723899c35ba01c1c467cfa4123ebec192b8aff9101611744565b6006546001600160a01b03163314612aab5760405162461bcd60e51b815260040161069690613c8b565b600154600114612acd5760405162461bcd60e51b815260040161069690613cb5565b60026001556001600160a01b0383166000908152600d6020526040902054839083908110612b0d5760405162461bcd60e51b815260040161069690613d3f565b6001600160a01b038086166000908152600c60209081526040808320888452825291829020825160c081018452815463ffffffff8082168352600160201b82041693820193909352600160401b9092048416928201929092526001820154909216606083015260028101546080830181905260039091015460a083015215612be55760405162461bcd60e51b815260206004820152602560248201527f73656c666c6573734c69717569646174652f706f7369746976652d636f6c6c616044820152641d195c985b60da1b6064820152608401610696565b600081604001516001600160a01b0316635dd925858360a001516040518263ffffffff1660e01b8152600401612c1d91815260200190565b602060405180830381600087803b158015612c3757600080fd5b505af1158015612c4b573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612c6f9190613c23565b9050612c7b85826135a5565b6040808401519051630450cfaf60e31b8152336004820152602481018390529196506000916001600160a01b03909116906322867d7890604401602060405180830381600087803b158015612ccf57600080fd5b505af1158015612ce3573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612d079190613c23565b9050808360a001818151612d1b9190613dc3565b90525060a08301516001600160a01b0389166000818152600c602090815260408083208c8452825291829020600301939093558051898152928301849052339083015288917fb14890f5eebf05b014f5e9e75f121a47fa260063eb0532e1a38439066bd0c4a190606001611744565b6001600160a01b0382166000908152600d60205260408120548190849084908110612dc75760405162461bcd60e51b815260040161069690613d3f565b505050506001600160a01b039182166000908152600c60209081526040808320938352929052206001810154905490821692600160401b90910490911690565b6007546001600160a01b03163314612e6d5760405162461bcd60e51b815260206004820152602360248201527f616363657074476f7665726e6f722f6e6f742d70656e64696e672d676f7665726044820152623737b960e91b6064820152608401610696565b600780546001600160a01b031990811690915560068054339216821790556040519081527fbce074c8369e26e70e1ae2f14fc944da352cfe6f52e2de9572f0c9942a24b7fc906020015b60405180910390a1565b6006546001600160a01b03163314612eeb5760405162461bcd60e51b815260040161069690613c8b565b600780546001600160a01b0319166001600160a01b0383169081179091556040519081527f964dea888b00b2ab53f13dfe7ca334b46e99338c222ae232d98547a1da019f60906020016112f3565b6000805462010000900460ff1615612f635760405162461bcd60e51b815260040161069690613d15565b83612f6e8133611960565b612f8a5760405162461bcd60e51b815260040161069690613cde565b6001600160a01b038085166000908152600860205260409020541680612fe85760405162461bcd60e51b81526020600482015260136024820152726f70656e2f6261642d756e6465726c79696e6760681b6044820152606401610696565b836001600160a01b0316856001600160a01b031614156130415760405162461bcd60e51b81526020600482015260146024820152731bdc195b8bdcd95b198b58dbdb1b185d195c985b60621b6044820152606401610696565b6004805460405163486ef95960e11b81526001600160a01b0387811693820193909352600092909116906390ddf2b29060240160206040518083038186803b15801561308c57600080fd5b505afa1580156130a0573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906130c49190613c23565b116131075760405162461bcd60e51b81526020600482015260136024820152721bdc195b8bd898590b58dbdb1b185d195c985b606a1b6044820152606401610696565b60035460405163353d37f960e21b81526001600160a01b038681166004830152600092169063d4f4dfe490602401602060405180830381600087803b15801561314f57600080fd5b505af1158015613163573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906131879190613c23565b116131c45760405162461bcd60e51b815260206004820152600d60248201526c6f70656e2f6e6f2d707269636560981b6044820152606401610696565b6001600160a01b0386166000908152600d602052604081208054916131e883613e06565b909155506001600160a01b038781166000818152600c60209081526040808320868452825291829020805468010000000000000000600160e01b031916600160401b8887169081029190911782556001820180546001600160a01b031916968c169687179055835190815291820194909452939650919286927fe7ae4268aa398bfe26749e22bfd7a7d50648062474a0422790079e61868a58f8910160405180910390a35050509392505050565b60008160a00151600014156132ad57506000919050565b60035460048054606085015160405163486ef95960e11b81526001600160a01b0391821693810193909352928316926000929116906390ddf2b29060240160206040518083038186803b15801561330357600080fd5b505afa158015613317573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061333b9190613c23565b9050600081116133845760405162461bcd60e51b815260206004820152601460248201527319995d18da0bd898590b58dbdb1b185d195c985b60621b6044820152606401610696565b600084604001516001600160a01b0316635dd925858660a001516040518263ffffffff1660e01b81526004016133bc91815260200190565b602060405180830381600087803b1580156133d657600080fd5b505af11580156133ea573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061340e9190613c23565b6040868101516001600160a01b0390811660009081526009602052828120549251632f5091a160e21b815292821660048401526024830184905292935085169063bd42468490604401602060405180830381600087803b15801561347157600080fd5b505af1158015613485573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906134a99190613c23565b90506000670de0b6b3a76400008488608001516134c69190613da4565b6134d09190613d82565b6060880151604051632f5091a160e21b81526001600160a01b039182166004820152602481018390529192506000919087169063bd42468490604401602060405180830381600087803b15801561352657600080fd5b505af115801561353a573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061355e9190613c23565b905080831061357c5750670de0b6b3a7640000979650505050505050565b8061358f84670de0b6b3a7640000613da4565b6135999190613d82565b98975050505050505050565b60008183106135b457816119d1565b5090919050565b6040516001600160a01b03831660248201526044810182905261361e90849063a9059cbb60e01b906064015b60408051601f198184030181529190526020810180516001600160e01b03166001600160e01b031990931692909217909152613753565b505050565b6040516001600160a01b038085166024830152831660448201526064810182905261195a9085906323b872dd60e01b906084016135e7565b60005462010000900460ff166136aa5760405162461bcd60e51b815260206004820152601460248201527314185d5cd8589b194e881b9bdd081c185d5cd95960621b6044820152606401610696565b6000805462ff0000191690557f5db9ee0a495bf2e6ff9c91a7834c1ba4fdd244a5e8aa4e537bd38aeae4b073aa335b6040516001600160a01b039091168152602001612eb7565b60005462010000900460ff161561371a5760405162461bcd60e51b815260040161069690613d15565b6000805462ff00001916620100001790557f62e78cea01bee320cd4e420270b5ea74000d11b0c9f74754ebdbfc544b05a2586136d93390565b60006137a8826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b03166138259092919063ffffffff16565b80519091501561361e57808060200190518101906137c69190613c06565b61361e5760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b6064820152608401610696565b6060613834848460008561383c565b949350505050565b60608247101561389d5760405162461bcd60e51b815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f6044820152651c8818d85b1b60d21b6064820152608401610696565b843b6138eb5760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000006044820152606401610696565b600080866001600160a01b031685876040516139079190613c3c565b60006040518083038185875af1925050503d8060008114613944576040519150601f19603f3d011682016040523d82523d6000602084013e613949565b606091505b5091509150613959828286613964565b979650505050505050565b606083156139735750816119d1565b8251156139835782518084602001fd5b8160405162461bcd60e51b81526004016106969190613c58565b6000602082840312156139af57600080fd5b81356119d181613e4d565b6000602082840312156139cc57600080fd5b81516119d181613e4d565b600080604083850312156139ea57600080fd5b82356139f581613e4d565b91506020830135613a0581613e4d565b809150509250929050565b600080600060608486031215613a2557600080fd5b8335613a3081613e4d565b92506020840135613a4081613e4d565b91506040840135613a5081613e4d565b809150509250925092565b600080600080600060a08688031215613a7357600080fd5b8535613a7e81613e4d565b94506020860135613a8e81613e4d565b93506040860135613a9e81613e4d565b92506060860135613aae81613e4d565b91506080860135613abe81613e4d565b809150509295509295909350565b600080600060608486031215613ae157600080fd5b8335613aec81613e4d565b92506020840135613afc81613e4d565b929592945050506040919091013590565b60008060408385031215613b2057600080fd5b8235613b2b81613e4d565b946020939093013593505050565b600080600060608486031215613b4e57600080fd5b8335613b5981613e4d565b95602085013595506040909401359392505050565b600080600060408486031215613b8357600080fd5b833567ffffffffffffffff80821115613b9b57600080fd5b818601915086601f830112613baf57600080fd5b813581811115613bbe57600080fd5b8760208260051b8501011115613bd357600080fd5b60209283019550935050840135613a5081613e65565b600060208284031215613bfb57600080fd5b81356119d181613e65565b600060208284031215613c1857600080fd5b81516119d181613e65565b600060208284031215613c3557600080fd5b5051919050565b60008251613c4e818460208701613dda565b9190910192915050565b6020815260008251806020840152613c77816040850160208701613dda565b601f01601f19169190910160400192915050565b60208082526010908201526f2132ba30a130b73597b7b7363ca3b7bb60811b604082015260600190565b6020808252600f908201526e10995d1850985b9acbdb1bd8dad959608a1b604082015260600190565b6020808252601b908201527f4265746142616e6b2f69735065726d697474656442794f776e65720000000000604082015260600190565b60208082526010908201526f14185d5cd8589b194e881c185d5cd95960821b604082015260600190565b60208082526011908201527010995d1850985b9acbd8da1958dad41251607a1b604082015260600190565b60008219821115613d7d57613d7d613e21565b500190565b600082613d9f57634e487b7160e01b600052601260045260246000fd5b500490565b6000816000190483118215151615613dbe57613dbe613e21565b500290565b600082821015613dd557613dd5613e21565b500390565b60005b83811015613df5578181015183820152602001613ddd565b8381111561195a5750506000910152565b6000600019821415613e1a57613e1a613e21565b5060010190565b634e487b7160e01b600052601160045260246000fd5b634e487b7160e01b600052603260045260246000fd5b6001600160a01b0381168114613e6257600080fd5b50565b8015158114613e6257600080fdfea264697066735822122061be41675e7a5a054423516b72b2ec48c5f7e331b32cbd54752e1fdcee30bee264736f6c63430008060033
Deployed Bytecode
0x608060405234801561001057600080fd5b506004361061023c5760003560e01c80638456cb591161013b578063c1bce0b7116100b8578063e3056a341161007c578063e3056a34146105e7578063e5074709146105fa578063e58bb6391461062d578063f235757f14610635578063f71fd5961461064857600080fd5b8063c1bce0b7146104f4578063c1be667714610507578063c640e9bf146105ae578063c9c8eb6c146105c1578063d5f39488146105d457600080fd5b8063ab01040e116100ff578063ab01040e1461047a578063ac165d7a1461049a578063b0886fe4146104ad578063b5beb20b146104c1578063bf1f53b6146104d457600080fd5b80638456cb59146104065780638cd2e0c71461040e57806390427116146104215780639413126a146104445780639ed933181461046757600080fd5b80634e16cf42116101c95780636e3f5d521161018d5780636e3f5d52146103a757806379502c55146103ba5780637adbf973146103cd5780637dc0d1d0146103e057806382762062146103f357600080fd5b80634e16cf421461030e57806351a491ad1461032157806351ea519a146103445780635c975abb1461036d578063679a8da81461037e57600080fd5b80631ec82cb8116102105780631ec82cb8146102ba57806320e3dbd4146102cd5780632ba4391a146102e057806333e1cf5d146102f35780633f4ba83a1461030657600080fd5b8062187482146102415780630710285c146102675780630c340a241461027c5780631459457a146102a7575b600080fd5b61025461024f366004613b0d565b61065b565b6040519081526020015b60405180910390f35b61027a610275366004613b39565b610751565b005b60065461028f906001600160a01b031681565b6040516001600160a01b03909116815260200161025e565b61027a6102b5366004613a5b565b610d5d565b61027a6102c8366004613acc565b611112565b61027a6102db36600461399d565b611230565b61027a6102ee366004613b39565b6112fe565b61027a610301366004613be9565b61175a565b61027a6117d1565b61027a61031c366004613b6e565b611854565b61033461032f3660046139d7565b611960565b604051901515815260200161025e565b61028f61035236600461399d565b6008602052600090815260409020546001600160a01b031681565b60005462010000900460ff16610334565b61028f61038c36600461399d565b6009602052600090815260409020546001600160a01b031681565b61027a6103b536600461399d565b6119d8565b60045461028f906001600160a01b031681565b61027a6103db36600461399d565b611aa6565b60035461028f906001600160a01b031681565b610254610401366004613b0d565b611b6d565b61027a611c33565b61027a61041c366004613b39565b611c8e565b61033461042f36600461399d565b600b6020526000908152604090205460ff1681565b61033461045236600461399d565b600a6020526000908152604090205460ff1681565b61028f61047536600461399d565b611f28565b61025461048836600461399d565b600d6020526000908152604090205481565b60055461028f906001600160a01b031681565b60075461033490600160a01b900460ff1681565b61027a6104cf366004613b6e565b6122af565b6102546104e236600461399d565b600e6020526000908152604090205481565b61027a610502366004613b39565b6123b5565b61056c610515366004613b0d565b600c602090815260009283526040808420909152908252902080546001820154600283015460039093015463ffffffff80841694600160201b8504909116936001600160a01b03600160401b909104811693169186565b6040805163ffffffff97881681529690951660208701526001600160a01b039384169486019490945291166060840152608083015260a082015260c00161025e565b61027a6105bc366004613b39565b612743565b61027a6105cf366004613b39565b612a81565b60025461028f906001600160a01b031681565b60075461028f906001600160a01b031681565b61060d610608366004613b0d565b612d8a565b604080516001600160a01b0393841681529290911660208301520161025e565b61027a612e07565b61027a61064336600461399d565b612ec1565b610254610656366004613a10565b612f39565b6001600160a01b0382166000908152600d602052604081205483908390811061069f5760405162461bcd60e51b815260040161069690613d3f565b60405180910390fd5b6001600160a01b038581166000908152600c6020908152604080832088845290915290819020805460038201549251635dd9258560e01b815260048101939093529092600160401b9091041690635dd9258590602401602060405180830381600087803b15801561070f57600080fd5b505af1158015610723573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906107479190613c23565b9695505050505050565b6001546001146107735760405162461bcd60e51b815260040161069690613cb5565b600260015560005462010000900460ff16156107a15760405162461bcd60e51b815260040161069690613d15565b6001600160a01b0383166000908152600d60205260409020548390839081106107dc5760405162461bcd60e51b815260040161069690613d3f565b6001600160a01b038086166000908152600c602090815260408083208884528252808320815160c081018352815463ffffffff8082168352600160201b82041682860152600160401b900486168184018190526001830154871660608301526002830154608083015260039092015460a082015290845260099092528220549092169061086883613296565b60048054604051630eb94ee160e41b81526001600160a01b0386811693820193909352929350169063eb94ee109060240160206040518083038186803b1580156108b157600080fd5b505afa1580156108c5573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906108e99190613c23565b8110156109385760405162461bcd60e51b815260206004820152601a60248201527f6c69717569646174652f6e6f742d6c6971756964617461626c650000000000006044820152606401610696565b6040808401519051630450cfaf60e31b8152336004820152602481018890526000916001600160a01b0316906322867d7890604401602060405180830381600087803b15801561098757600080fd5b505af115801561099b573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906109bf9190613c23565b905060028460a0015160016109d49190613d6a565b6109de9190613d82565b811115610a2d5760405162461bcd60e51b815260206004820152601e60248201527f6c69717569646174652f746f6f2d6d7563682d6c69717569646174696f6e00006044820152606401610696565b6040808501519051635dd9258560e01b8152600481018390526000916001600160a01b031690635dd9258590602401602060405180830381600087803b158015610a7657600080fd5b505af1158015610a8a573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610aae9190613c23565b600354606087015160405163248391ff60e01b81526001600160a01b03888116600483015291821660248201526044810184905292935060009291169063248391ff90606401602060405180830381600087803b158015610b0e57600080fd5b505af1158015610b22573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610b469190613c23565b600480546040516339f041ad60e11b81526001600160a01b0389811693820193909352929350600092610c0092670de0b6b3a76400009216906373e0835a9060240160206040518083038186803b158015610ba057600080fd5b505afa158015610bb4573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610bd89190613c23565b610be29085613da4565b610bec9190613d82565b610bf69084613d6a565b88608001516135a5565b9050838760a001818151610c149190613dc3565b90525060a08701516001600160a01b038d166000908152600c602090815260408083208f8452909152902060030155608087018051829190610c57908390613dc3565b915081815250508660800151600c60008e6001600160a01b03166001600160a01b0316815260200190815260200160002060008d81526020019081526020016000206002018190555080600e600089606001516001600160a01b03166001600160a01b031681526020019081526020016000206000828254610cd99190613dc3565b90915550506060870151610cf7906001600160a01b031633836135bb565b604080518b8152602081018690529081018290523360608201528b906001600160a01b038e16907fdde0adb27be857d0db946bcab48f6a9f4b90b721fa0672622d5ec3de019bee3e9060800160405180910390a350506001805550505050505050505050565b600054610100900460ff1680610d76575060005460ff16155b610dd95760405162461bcd60e51b815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201526d191e481a5b9a5d1a585b1a5e995960921b6064820152608401610696565b600054610100900460ff16158015610dfb576000805461ffff19166101011790555b6001600160a01b038616610e515760405162461bcd60e51b815260206004820181905260248201527f696e697469616c697a652f676f7665726e6f722d7a65726f2d616464726573736044820152606401610696565b6001600160a01b038516610ea75760405162461bcd60e51b815260206004820181905260248201527f696e697469616c697a652f6465706c6f7965722d7a65726f2d616464726573736044820152606401610696565b6001600160a01b038416610efd5760405162461bcd60e51b815260206004820152601e60248201527f696e697469616c697a652f6f7261636c652d7a65726f2d6164647265737300006044820152606401610696565b6001600160a01b038316610f535760405162461bcd60e51b815260206004820152601e60248201527f696e697469616c697a652f636f6e6669672d7a65726f2d6164647265737300006044820152606401610696565b6001600160a01b038216610fb85760405162461bcd60e51b815260206004820152602660248201527f696e697469616c697a652f696e7465726573742d6d6f64656c2d7a65726f2d6160448201526564647265737360d01b6064820152608401610696565b600680546001600160a01b03199081166001600160a01b0389811691821790935560028054831689851617905560038054831688851617905560048054831687851617905560058054909216928516929092179055600180556040519081527fbce074c8369e26e70e1ae2f14fc944da352cfe6f52e2de9572f0c9942a24b7fc9060200160405180910390a16040516001600160a01b03851681527fd3b5d1e0ffaeff528910f3663f0adace7694ab8241d58e17a91351ced2e080319060200160405180910390a16040516001600160a01b03841681527fc5618716db99966ac0bedb011a55472827d54343d73b50c3118c0b03cdf1c75f9060200160405180910390a16040516001600160a01b03831681527f2f39052eae53bd818667d1ebcc2423988c8ef77de1477853c399e84c774d6b0e9060200160405180910390a1801561110a576000805461ff00191690555b505050505050565b6006546001600160a01b0316331461113c5760405162461bcd60e51b815260040161069690613c8b565b60015460011461115e5760405162461bcd60e51b815260040161069690613cb5565b60026001556001600160a01b03838116600090815260096020526040902054166111bf5760405162461bcd60e51b81526020600482015260126024820152713932b1b7bb32b917b737ba16b12a37b5b2b760711b6044820152606401610696565b6040516303d9059760e31b81526001600160a01b03838116600483015233602483015260448201839052841690631ec82cb890606401600060405180830381600087803b15801561120f57600080fd5b505af1158015611223573d6000803e3d6000fd5b5050600180555050505050565b6006546001600160a01b0316331461125a5760405162461bcd60e51b815260040161069690613c8b565b6001600160a01b0381166112a95760405162461bcd60e51b8152602060048201526016602482015275736574436f6e6669672f7a65726f2d6164647265737360501b6044820152606401610696565b600480546001600160a01b0319166001600160a01b0383169081179091556040519081527fc5618716db99966ac0bedb011a55472827d54343d73b50c3118c0b03cdf1c75f906020015b60405180910390a150565b6001546001146113205760405162461bcd60e51b815260040161069690613cb5565b600260015560005462010000900460ff161561134e5760405162461bcd60e51b815260040161069690613d15565b826113598133611960565b6113755760405162461bcd60e51b815260040161069690613cde565b6001600160a01b0384166000908152600d60205260409020548490849081106113b05760405162461bcd60e51b815260040161069690613d3f565b6001600160a01b038087166000908152600c60209081526040808320898452825291829020825160c081018452815463ffffffff8082168352600160201b82048116948301859052600160401b90910486169482019490945260018201549094166060850152600281015460808501526003015460a084015243909116141561146b5760405162461bcd60e51b815260206004820152600d60248201526c7075742f6261642d626c6f636b60981b6044820152606401610696565b60608101516040516370a0823160e01b815230600482015260009182916001600160a01b03909116906370a082319060240160206040518083038186803b1580156114b557600080fd5b505afa1580156114c9573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906114ed9190613c23565b606084015190915061150a906001600160a01b031633308a613623565b60608301516040516370a0823160e01b81523060048201526000916001600160a01b0316906370a082319060240160206040518083038186803b15801561155057600080fd5b505afa158015611564573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906115889190613c23565b90506115948282613dc3565b9250505080826080018181516115aa9190613d6a565b90525060608201516001600160a01b03166000908152600e6020526040812080548392906115d9908490613d6a565b909155505060048054606084015160405163665e2e5360e01b81526001600160a01b0391821693810193909352169063665e2e539060240160206040518083038186803b15801561162957600080fd5b505afa15801561163d573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906116619190613c23565b60608301516001600160a01b03166000908152600e602052604090205411156116cc5760405162461bcd60e51b815260206004820152601760248201527f7075742f746f6f2d6d7563682d636f6c6c61746572616c0000000000000000006044820152606401610696565b60808201516001600160a01b0389166000818152600c602090815260408083208c84528252918290206002810194909455835463ffffffff19164363ffffffff16179093558051898152339381019390935289927fa484f5dd35662c7e9a639bb18fd7c87293c82c2ba06dd2ff77536edf523d99f591015b60405180910390a3505060018055505050505050565b6006546001600160a01b031633146117845760405162461bcd60e51b815260040161069690613c8b565b60078054821515600160a01b0260ff60a01b199091161790556040517f1a993cb3baaaeecd4cf09f369bae7bb6a23acba7fdf4c37432a91bbdb4e3963a906112f390831515815260200190565b60005462010000900460ff166118205760405162461bcd60e51b815260206004820152601460248201527314185d5cd8589b194e881b9bdd081c185d5cd95960621b6044820152606401610696565b6006546001600160a01b0316331461184a5760405162461bcd60e51b815260040161069690613c8b565b61185261365b565b565b6006546001600160a01b0316331461187e5760405162461bcd60e51b815260040161069690613c8b565b60005b8281101561195a5781600a60008686858181106118a0576118a0613e37565b90506020020160208101906118b5919061399d565b6001600160a01b031681526020810191909152604001600020805460ff19169115159190911790558383828181106118ef576118ef613e37565b9050602002016020810190611904919061399d565b6001600160a01b03167f3e3f3513ca57dd2a4694ffe4ff73f0d13635c4793c347f048725832f7974303883604051611940911515815260200190565b60405180910390a28061195281613e06565b915050611881565b50505050565b6000816001600160a01b0316836001600160a01b031614801561199b57506001600160a01b0383166000908152600b602052604090205460ff165b806119d157506001600160a01b038316321480156119d157506001600160a01b0382166000908152600a602052604090205460ff165b9392505050565b6006546001600160a01b03163314611a025760405162461bcd60e51b815260040161069690613c8b565b6001600160a01b038116611a585760405162461bcd60e51b815260206004820152601d60248201527f736574496e7465726573744d6f64656c2f7a65726f2d616464726573730000006044820152606401610696565b600580546001600160a01b0319166001600160a01b0383169081179091556040519081527f2f39052eae53bd818667d1ebcc2423988c8ef77de1477853c399e84c774d6b0e906020016112f3565b6006546001600160a01b03163314611ad05760405162461bcd60e51b815260040161069690613c8b565b6001600160a01b038116611b1f5760405162461bcd60e51b81526020600482015260166024820152757365744f7261636c652f7a65726f2d6164647265737360501b6044820152606401610696565b600380546001600160a01b0319166001600160a01b0383169081179091556040519081527fd3b5d1e0ffaeff528910f3663f0adace7694ab8241d58e17a91351ced2e08031906020016112f3565b6001600160a01b0382166000908152600d6020526040812054839083908110611ba85760405162461bcd60e51b815260040161069690613d3f565b6001600160a01b038086166000908152600c60209081526040808320888452825291829020825160c081018452815463ffffffff8082168352600160201b82041693820193909352600160401b90920484169282019290925260018201549092166060830152600281015460808301526003015460a0820152611c2a90613296565b95945050505050565b60005462010000900460ff1615611c5c5760405162461bcd60e51b815260040161069690613d15565b6006546001600160a01b03163314611c865760405162461bcd60e51b815260040161069690613c8b565b6118526136f1565b600154600114611cb05760405162461bcd60e51b815260040161069690613cb5565b600260015560005462010000900460ff1615611cde5760405162461bcd60e51b815260040161069690613d15565b82611ce98133611960565b611d055760405162461bcd60e51b815260040161069690613cde565b6001600160a01b0384166000908152600d6020526040902054849084908110611d405760405162461bcd60e51b815260040161069690613d3f565b6001600160a01b038087166000908152600c60209081526040808320898452825291829020825160c081018452815463ffffffff808216808452600160201b8304821695840195909552600160401b90910486169482019490945260018201549094166060850152600281015460808501526003015460a0840152439091161415611dff5760405162461bcd60e51b815260206004820152600f60248201526e72657061792f6261642d626c6f636b60881b6044820152606401610696565b6040808201519051630450cfaf60e31b8152336004820152602481018790526000916001600160a01b0316906322867d7890604401602060405180830381600087803b158015611e4e57600080fd5b505af1158015611e62573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611e869190613c23565b9050808260a001818151611e9a9190613dc3565b90525060a08201516001600160a01b0389166000818152600c602090815260408083208c84528252918290206003810194909455835467ffffffff000000001916600160201b4363ffffffff1602179093558051898152928301849052339083015288917f09e02f7977f4cd69fd737ff7ee1a723f810d24bac179c0eaa8e5815a795d3ea490606001611744565b6000600154600114611f4c5760405162461bcd60e51b815260040161069690613cb5565b600260015560005462010000900460ff1615611f7a5760405162461bcd60e51b815260040161069690613d15565b600754600160a01b900460ff1680611f9c57506006546001600160a01b031633145b611fde5760405162461bcd60e51b815260206004820152601360248201527218dc99585d194bdd5b985d5d1a1bdc9a5e9959606a1b6044820152606401610696565b6001600160a01b03821630141561202e5760405162461bcd60e51b81526020600482015260146024820152736372656174652f6e6f742d6c696b652d7468697360601b6044820152606401610696565b6001600160a01b0382163b6120855760405162461bcd60e51b815260206004820152601e60248201527f6372656174652f756e6465726c79696e672d6e6f742d636f6e747261637400006044820152606401610696565b6001600160a01b0382811660009081526008602052604090205416156120ed5760405162461bcd60e51b815260206004820181905260248201527f6372656174652f756e6465726c79696e672d616c72656164792d6578697374736044820152606401610696565b60035460405163353d37f960e21b81526001600160a01b038481166004830152600092169063d4f4dfe490602401602060405180830381600087803b15801561213557600080fd5b505af1158015612149573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061216d9190613c23565b116121ac5760405162461bcd60e51b815260206004820152600f60248201526e6372656174652f6e6f2d707269636560881b6044820152606401610696565b600254604051634c96a38960e01b81526001600160a01b03848116600483015290911690634c96a38990602401602060405180830381600087803b1580156121f357600080fd5b505af1158015612207573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061222b91906139ba565b6001600160a01b03838116600081815260086020908152604080832080549587166001600160a01b031996871681179091558084526009835292819020805490951684179094559251908152929350917f96b5b9b8a7193304150caccf9b80d150675fa3d6af57761d8d8ef1d6f9a1a909910160405180910390a260018055919050565b6006546001600160a01b031633146122d95760405162461bcd60e51b815260040161069690613c8b565b60005b8281101561195a5781600b60008686858181106122fb576122fb613e37565b9050602002016020810190612310919061399d565b6001600160a01b031681526020810191909152604001600020805460ff191691151591909117905583838281811061234a5761234a613e37565b905060200201602081019061235f919061399d565b6001600160a01b03167f31713abf7651a5d93dd9702d3bbfdc9bf477ed7a7d4123d818499e7df9f62cc08360405161239b911515815260200190565b60405180910390a2806123ad81613e06565b9150506122dc565b6001546001146123d75760405162461bcd60e51b815260040161069690613cb5565b600260015560005462010000900460ff16156124055760405162461bcd60e51b815260040161069690613d15565b826124108133611960565b61242c5760405162461bcd60e51b815260040161069690613cde565b6001600160a01b0384166000908152600d60205260409020548490849081106124675760405162461bcd60e51b815260040161069690613d3f565b6001600160a01b038087166000908152600c60209081526040808320898452825291829020825160c081018452815463ffffffff8082168352600160201b82048116948301859052600160401b90910486169482019490945260018201549094166060850152600281015460808501526003015460a08401524390911614156125255760405162461bcd60e51b815260206004820152601060248201526f626f72726f772f6261642d626c6f636b60801b6044820152606401610696565b6040808201519051634b8a352960e01b8152336004820152602481018790526000916001600160a01b031690634b8a352990604401602060405180830381600087803b15801561257457600080fd5b505af1158015612588573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906125ac9190613c23565b9050808260a0018181516125c09190613d6a565b90525060a08201516001600160a01b0389166000908152600c602090815260408083208b845290915281206003810192909255815463ffffffff19164363ffffffff161790915561261083613296565b600480546040868101516001600160a01b03908116600090815260096020528290205491516337ea609360e01b81529181169382019390935292935016906337ea60939060240160206040518083038186803b15801561266f57600080fd5b505afa158015612683573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906126a79190613c23565b8111156126e85760405162461bcd60e51b815260206004820152600f60248201526e626f72726f772f6e6f742d7361666560881b6044820152606401610696565b60408051888152602081018490523381830152905189916001600160a01b038c16917f66213fb9f1fa2b7f0877f6506f7ce239ede54b92e550c29d9937d2808aeaa7229181900360600190a350506001805550505050505050565b6001546001146127655760405162461bcd60e51b815260040161069690613cb5565b600260015560005462010000900460ff16156127935760405162461bcd60e51b815260040161069690613d15565b8261279e8133611960565b6127ba5760405162461bcd60e51b815260040161069690613cde565b6001600160a01b0384166000908152600d60205260409020548490849081106127f55760405162461bcd60e51b815260040161069690613d3f565b6001600160a01b038087166000908152600c60209081526040808320898452825291829020825160c081018452815463ffffffff808216808452600160201b8304821695840195909552600160401b90910486169482019490945260018201549094166060850152600281015460808501526003015460a08401524390911614156128b35760405162461bcd60e51b815260206004820152600e60248201526d74616b652f6261642d626c6f636b60901b6044820152606401610696565b84816080018181516128c59190613dc3565b90525060608101516001600160a01b03166000908152600e6020526040812080548792906128f4908490613dc3565b909155505060808101516001600160a01b0388166000908152600c602090815260408083208a845290915281206002810192909255815467ffffffff000000001916600160201b4363ffffffff16021790915561295082613296565b600480546040858101516001600160a01b03908116600090815260096020528290205491516337ea609360e01b81529181169382019390935292935016906337ea60939060240160206040518083038186803b1580156129af57600080fd5b505afa1580156129c3573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906129e79190613c23565b811115612a265760405162461bcd60e51b815260206004820152600d60248201526c74616b652f6e6f742d7361666560981b6044820152606401610696565b6060820151612a3f906001600160a01b031633886135bb565b6040805187815233602082015288916001600160a01b038b16917f3c494f8e78d173658bbb4fc963723899c35ba01c1c467cfa4123ebec192b8aff9101611744565b6006546001600160a01b03163314612aab5760405162461bcd60e51b815260040161069690613c8b565b600154600114612acd5760405162461bcd60e51b815260040161069690613cb5565b60026001556001600160a01b0383166000908152600d6020526040902054839083908110612b0d5760405162461bcd60e51b815260040161069690613d3f565b6001600160a01b038086166000908152600c60209081526040808320888452825291829020825160c081018452815463ffffffff8082168352600160201b82041693820193909352600160401b9092048416928201929092526001820154909216606083015260028101546080830181905260039091015460a083015215612be55760405162461bcd60e51b815260206004820152602560248201527f73656c666c6573734c69717569646174652f706f7369746976652d636f6c6c616044820152641d195c985b60da1b6064820152608401610696565b600081604001516001600160a01b0316635dd925858360a001516040518263ffffffff1660e01b8152600401612c1d91815260200190565b602060405180830381600087803b158015612c3757600080fd5b505af1158015612c4b573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612c6f9190613c23565b9050612c7b85826135a5565b6040808401519051630450cfaf60e31b8152336004820152602481018390529196506000916001600160a01b03909116906322867d7890604401602060405180830381600087803b158015612ccf57600080fd5b505af1158015612ce3573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612d079190613c23565b9050808360a001818151612d1b9190613dc3565b90525060a08301516001600160a01b0389166000818152600c602090815260408083208c8452825291829020600301939093558051898152928301849052339083015288917fb14890f5eebf05b014f5e9e75f121a47fa260063eb0532e1a38439066bd0c4a190606001611744565b6001600160a01b0382166000908152600d60205260408120548190849084908110612dc75760405162461bcd60e51b815260040161069690613d3f565b505050506001600160a01b039182166000908152600c60209081526040808320938352929052206001810154905490821692600160401b90910490911690565b6007546001600160a01b03163314612e6d5760405162461bcd60e51b815260206004820152602360248201527f616363657074476f7665726e6f722f6e6f742d70656e64696e672d676f7665726044820152623737b960e91b6064820152608401610696565b600780546001600160a01b031990811690915560068054339216821790556040519081527fbce074c8369e26e70e1ae2f14fc944da352cfe6f52e2de9572f0c9942a24b7fc906020015b60405180910390a1565b6006546001600160a01b03163314612eeb5760405162461bcd60e51b815260040161069690613c8b565b600780546001600160a01b0319166001600160a01b0383169081179091556040519081527f964dea888b00b2ab53f13dfe7ca334b46e99338c222ae232d98547a1da019f60906020016112f3565b6000805462010000900460ff1615612f635760405162461bcd60e51b815260040161069690613d15565b83612f6e8133611960565b612f8a5760405162461bcd60e51b815260040161069690613cde565b6001600160a01b038085166000908152600860205260409020541680612fe85760405162461bcd60e51b81526020600482015260136024820152726f70656e2f6261642d756e6465726c79696e6760681b6044820152606401610696565b836001600160a01b0316856001600160a01b031614156130415760405162461bcd60e51b81526020600482015260146024820152731bdc195b8bdcd95b198b58dbdb1b185d195c985b60621b6044820152606401610696565b6004805460405163486ef95960e11b81526001600160a01b0387811693820193909352600092909116906390ddf2b29060240160206040518083038186803b15801561308c57600080fd5b505afa1580156130a0573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906130c49190613c23565b116131075760405162461bcd60e51b81526020600482015260136024820152721bdc195b8bd898590b58dbdb1b185d195c985b606a1b6044820152606401610696565b60035460405163353d37f960e21b81526001600160a01b038681166004830152600092169063d4f4dfe490602401602060405180830381600087803b15801561314f57600080fd5b505af1158015613163573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906131879190613c23565b116131c45760405162461bcd60e51b815260206004820152600d60248201526c6f70656e2f6e6f2d707269636560981b6044820152606401610696565b6001600160a01b0386166000908152600d602052604081208054916131e883613e06565b909155506001600160a01b038781166000818152600c60209081526040808320868452825291829020805468010000000000000000600160e01b031916600160401b8887169081029190911782556001820180546001600160a01b031916968c169687179055835190815291820194909452939650919286927fe7ae4268aa398bfe26749e22bfd7a7d50648062474a0422790079e61868a58f8910160405180910390a35050509392505050565b60008160a00151600014156132ad57506000919050565b60035460048054606085015160405163486ef95960e11b81526001600160a01b0391821693810193909352928316926000929116906390ddf2b29060240160206040518083038186803b15801561330357600080fd5b505afa158015613317573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061333b9190613c23565b9050600081116133845760405162461bcd60e51b815260206004820152601460248201527319995d18da0bd898590b58dbdb1b185d195c985b60621b6044820152606401610696565b600084604001516001600160a01b0316635dd925858660a001516040518263ffffffff1660e01b81526004016133bc91815260200190565b602060405180830381600087803b1580156133d657600080fd5b505af11580156133ea573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061340e9190613c23565b6040868101516001600160a01b0390811660009081526009602052828120549251632f5091a160e21b815292821660048401526024830184905292935085169063bd42468490604401602060405180830381600087803b15801561347157600080fd5b505af1158015613485573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906134a99190613c23565b90506000670de0b6b3a76400008488608001516134c69190613da4565b6134d09190613d82565b6060880151604051632f5091a160e21b81526001600160a01b039182166004820152602481018390529192506000919087169063bd42468490604401602060405180830381600087803b15801561352657600080fd5b505af115801561353a573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061355e9190613c23565b905080831061357c5750670de0b6b3a7640000979650505050505050565b8061358f84670de0b6b3a7640000613da4565b6135999190613d82565b98975050505050505050565b60008183106135b457816119d1565b5090919050565b6040516001600160a01b03831660248201526044810182905261361e90849063a9059cbb60e01b906064015b60408051601f198184030181529190526020810180516001600160e01b03166001600160e01b031990931692909217909152613753565b505050565b6040516001600160a01b038085166024830152831660448201526064810182905261195a9085906323b872dd60e01b906084016135e7565b60005462010000900460ff166136aa5760405162461bcd60e51b815260206004820152601460248201527314185d5cd8589b194e881b9bdd081c185d5cd95960621b6044820152606401610696565b6000805462ff0000191690557f5db9ee0a495bf2e6ff9c91a7834c1ba4fdd244a5e8aa4e537bd38aeae4b073aa335b6040516001600160a01b039091168152602001612eb7565b60005462010000900460ff161561371a5760405162461bcd60e51b815260040161069690613d15565b6000805462ff00001916620100001790557f62e78cea01bee320cd4e420270b5ea74000d11b0c9f74754ebdbfc544b05a2586136d93390565b60006137a8826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b03166138259092919063ffffffff16565b80519091501561361e57808060200190518101906137c69190613c06565b61361e5760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b6064820152608401610696565b6060613834848460008561383c565b949350505050565b60608247101561389d5760405162461bcd60e51b815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f6044820152651c8818d85b1b60d21b6064820152608401610696565b843b6138eb5760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000006044820152606401610696565b600080866001600160a01b031685876040516139079190613c3c565b60006040518083038185875af1925050503d8060008114613944576040519150601f19603f3d011682016040523d82523d6000602084013e613949565b606091505b5091509150613959828286613964565b979650505050505050565b606083156139735750816119d1565b8251156139835782518084602001fd5b8160405162461bcd60e51b81526004016106969190613c58565b6000602082840312156139af57600080fd5b81356119d181613e4d565b6000602082840312156139cc57600080fd5b81516119d181613e4d565b600080604083850312156139ea57600080fd5b82356139f581613e4d565b91506020830135613a0581613e4d565b809150509250929050565b600080600060608486031215613a2557600080fd5b8335613a3081613e4d565b92506020840135613a4081613e4d565b91506040840135613a5081613e4d565b809150509250925092565b600080600080600060a08688031215613a7357600080fd5b8535613a7e81613e4d565b94506020860135613a8e81613e4d565b93506040860135613a9e81613e4d565b92506060860135613aae81613e4d565b91506080860135613abe81613e4d565b809150509295509295909350565b600080600060608486031215613ae157600080fd5b8335613aec81613e4d565b92506020840135613afc81613e4d565b929592945050506040919091013590565b60008060408385031215613b2057600080fd5b8235613b2b81613e4d565b946020939093013593505050565b600080600060608486031215613b4e57600080fd5b8335613b5981613e4d565b95602085013595506040909401359392505050565b600080600060408486031215613b8357600080fd5b833567ffffffffffffffff80821115613b9b57600080fd5b818601915086601f830112613baf57600080fd5b813581811115613bbe57600080fd5b8760208260051b8501011115613bd357600080fd5b60209283019550935050840135613a5081613e65565b600060208284031215613bfb57600080fd5b81356119d181613e65565b600060208284031215613c1857600080fd5b81516119d181613e65565b600060208284031215613c3557600080fd5b5051919050565b60008251613c4e818460208701613dda565b9190910192915050565b6020815260008251806020840152613c77816040850160208701613dda565b601f01601f19169190910160400192915050565b60208082526010908201526f2132ba30a130b73597b7b7363ca3b7bb60811b604082015260600190565b6020808252600f908201526e10995d1850985b9acbdb1bd8dad959608a1b604082015260600190565b6020808252601b908201527f4265746142616e6b2f69735065726d697474656442794f776e65720000000000604082015260600190565b60208082526010908201526f14185d5cd8589b194e881c185d5cd95960821b604082015260600190565b60208082526011908201527010995d1850985b9acbd8da1958dad41251607a1b604082015260600190565b60008219821115613d7d57613d7d613e21565b500190565b600082613d9f57634e487b7160e01b600052601260045260246000fd5b500490565b6000816000190483118215151615613dbe57613dbe613e21565b500290565b600082821015613dd557613dd5613e21565b500390565b60005b83811015613df5578181015183820152602001613ddd565b8381111561195a5750506000910152565b6000600019821415613e1a57613e1a613e21565b5060010190565b634e487b7160e01b600052601160045260246000fd5b634e487b7160e01b600052603260045260246000fd5b6001600160a01b0381168114613e6257600080fd5b50565b8015158114613e6257600080fdfea264697066735822122061be41675e7a5a054423516b72b2ec48c5f7e331b32cbd54752e1fdcee30bee264736f6c63430008060033
Loading...
Loading
Loading...
Loading
Net Worth in USD
$0.00
Net Worth in ETH
0
Multichain Portfolio | 35 Chains
| Chain | Token | Portfolio % | Price | Amount | Value |
|---|
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.