Source Code
Overview
S Balance
S Value
$0.00View more zero value Internal Transactions in Advanced View mode
Advanced mode:
Cross-Chain Transactions
Loading...
Loading
This contract may be a proxy contract. Click on More Options and select Is this a proxy? to confirm and enable the "Read as Proxy" & "Write as Proxy" tabs.
Contract Name:
OSonicVaultCore
Compiler Version
v0.8.28+commit.7893614a
Optimization Enabled:
Yes with 200 runs
Other Settings:
paris EvmVersion
Contract Source Code (Solidity Standard Json-Input format)
// SPDX-License-Identifier: BUSL-1.1
pragma solidity ^0.8.0;
import { OETHVaultCore } from "./OETHVaultCore.sol";
/**
* @title Origin Sonic VaultCore contract on Sonic
* @author Origin Protocol Inc
*/
contract OSonicVaultCore is OETHVaultCore {
/// @param _wS Sonic's Wrapped S token
constructor(address _wS) OETHVaultCore(_wS) {}
/**
* @notice Instant redeem is not supported on Sonic.
* Use the asynchronous `requestWithdrawal` a `claimWithdrawal` instead.
*/
function _redeem(uint256, uint256) internal override {
revert("unsupported function");
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (token/ERC20/IERC20.sol)
pragma solidity ^0.8.0;
/**
* @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);
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (token/ERC20/utils/SafeERC20.sol)
pragma solidity ^0.8.0;
import "../IERC20.sol";
import "../../../utils/Address.sol";
/**
* @title SafeERC20
* @dev Wrappers around ERC20 operations that throw on failure (when the token
* contract returns false). Tokens that return no value (and instead revert or
* throw on failure) are also supported, non-reverting calls are assumed to be
* successful.
* To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract,
* which allows you to call the safe operations as `token.safeTransfer(...)`, etc.
*/
library SafeERC20 {
using Address for address;
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");
}
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/Address.sol)
pragma solidity ^0.8.0;
/**
* @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);
}
/**
* @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the
* revert reason using the provided one.
*
* _Available since v4.3._
*/
function verifyCallResult(
bool success,
bytes memory returndata,
string memory errorMessage
) internal pure returns (bytes memory) {
if (success) {
return returndata;
} else {
// Look for revert reason and bubble it up if present
if (returndata.length > 0) {
// The easiest way to bubble the revert reason is using memory via assembly
assembly {
let returndata_size := mload(returndata)
revert(add(32, returndata), returndata_size)
}
} else {
revert(errorMessage);
}
}
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/math/SafeCast.sol)
pragma solidity ^0.8.0;
/**
* @dev Wrappers over Solidity's uintXX/intXX casting operators with added overflow
* checks.
*
* Downcasting from uint256/int256 in Solidity does not revert on overflow. This can
* easily result in undesired exploitation or bugs, since developers usually
* assume that overflows raise errors. `SafeCast` restores this intuition by
* reverting the transaction when such an operation overflows.
*
* Using this library instead of the unchecked operations eliminates an entire
* class of bugs, so it's recommended to use it always.
*
* Can be combined with {SafeMath} and {SignedSafeMath} to extend it to smaller types, by performing
* all math on `uint256` and `int256` and then downcasting.
*/
library SafeCast {
/**
* @dev Returns the downcasted uint224 from uint256, reverting on
* overflow (when the input is greater than largest uint224).
*
* Counterpart to Solidity's `uint224` operator.
*
* Requirements:
*
* - input must fit into 224 bits
*/
function toUint224(uint256 value) internal pure returns (uint224) {
require(value <= type(uint224).max, "SafeCast: value doesn't fit in 224 bits");
return uint224(value);
}
/**
* @dev Returns the downcasted uint128 from uint256, reverting on
* overflow (when the input is greater than largest uint128).
*
* Counterpart to Solidity's `uint128` operator.
*
* Requirements:
*
* - input must fit into 128 bits
*/
function toUint128(uint256 value) internal pure returns (uint128) {
require(value <= type(uint128).max, "SafeCast: value doesn't fit in 128 bits");
return uint128(value);
}
/**
* @dev Returns the downcasted uint96 from uint256, reverting on
* overflow (when the input is greater than largest uint96).
*
* Counterpart to Solidity's `uint96` operator.
*
* Requirements:
*
* - input must fit into 96 bits
*/
function toUint96(uint256 value) internal pure returns (uint96) {
require(value <= type(uint96).max, "SafeCast: value doesn't fit in 96 bits");
return uint96(value);
}
/**
* @dev Returns the downcasted uint64 from uint256, reverting on
* overflow (when the input is greater than largest uint64).
*
* Counterpart to Solidity's `uint64` operator.
*
* Requirements:
*
* - input must fit into 64 bits
*/
function toUint64(uint256 value) internal pure returns (uint64) {
require(value <= type(uint64).max, "SafeCast: value doesn't fit in 64 bits");
return uint64(value);
}
/**
* @dev Returns the downcasted uint32 from uint256, reverting on
* overflow (when the input is greater than largest uint32).
*
* Counterpart to Solidity's `uint32` operator.
*
* Requirements:
*
* - input must fit into 32 bits
*/
function toUint32(uint256 value) internal pure returns (uint32) {
require(value <= type(uint32).max, "SafeCast: value doesn't fit in 32 bits");
return uint32(value);
}
/**
* @dev Returns the downcasted uint16 from uint256, reverting on
* overflow (when the input is greater than largest uint16).
*
* Counterpart to Solidity's `uint16` operator.
*
* Requirements:
*
* - input must fit into 16 bits
*/
function toUint16(uint256 value) internal pure returns (uint16) {
require(value <= type(uint16).max, "SafeCast: value doesn't fit in 16 bits");
return uint16(value);
}
/**
* @dev Returns the downcasted uint8 from uint256, reverting on
* overflow (when the input is greater than largest uint8).
*
* Counterpart to Solidity's `uint8` operator.
*
* Requirements:
*
* - input must fit into 8 bits.
*/
function toUint8(uint256 value) internal pure returns (uint8) {
require(value <= type(uint8).max, "SafeCast: value doesn't fit in 8 bits");
return uint8(value);
}
/**
* @dev Converts a signed int256 into an unsigned uint256.
*
* Requirements:
*
* - input must be greater than or equal to 0.
*/
function toUint256(int256 value) internal pure returns (uint256) {
require(value >= 0, "SafeCast: value must be positive");
return uint256(value);
}
/**
* @dev Returns the downcasted int128 from int256, reverting on
* overflow (when the input is less than smallest int128 or
* greater than largest int128).
*
* Counterpart to Solidity's `int128` operator.
*
* Requirements:
*
* - input must fit into 128 bits
*
* _Available since v3.1._
*/
function toInt128(int256 value) internal pure returns (int128) {
require(value >= type(int128).min && value <= type(int128).max, "SafeCast: value doesn't fit in 128 bits");
return int128(value);
}
/**
* @dev Returns the downcasted int64 from int256, reverting on
* overflow (when the input is less than smallest int64 or
* greater than largest int64).
*
* Counterpart to Solidity's `int64` operator.
*
* Requirements:
*
* - input must fit into 64 bits
*
* _Available since v3.1._
*/
function toInt64(int256 value) internal pure returns (int64) {
require(value >= type(int64).min && value <= type(int64).max, "SafeCast: value doesn't fit in 64 bits");
return int64(value);
}
/**
* @dev Returns the downcasted int32 from int256, reverting on
* overflow (when the input is less than smallest int32 or
* greater than largest int32).
*
* Counterpart to Solidity's `int32` operator.
*
* Requirements:
*
* - input must fit into 32 bits
*
* _Available since v3.1._
*/
function toInt32(int256 value) internal pure returns (int32) {
require(value >= type(int32).min && value <= type(int32).max, "SafeCast: value doesn't fit in 32 bits");
return int32(value);
}
/**
* @dev Returns the downcasted int16 from int256, reverting on
* overflow (when the input is less than smallest int16 or
* greater than largest int16).
*
* Counterpart to Solidity's `int16` operator.
*
* Requirements:
*
* - input must fit into 16 bits
*
* _Available since v3.1._
*/
function toInt16(int256 value) internal pure returns (int16) {
require(value >= type(int16).min && value <= type(int16).max, "SafeCast: value doesn't fit in 16 bits");
return int16(value);
}
/**
* @dev Returns the downcasted int8 from int256, reverting on
* overflow (when the input is less than smallest int8 or
* greater than largest int8).
*
* Counterpart to Solidity's `int8` operator.
*
* Requirements:
*
* - input must fit into 8 bits.
*
* _Available since v3.1._
*/
function toInt8(int256 value) internal pure returns (int8) {
require(value >= type(int8).min && value <= type(int8).max, "SafeCast: value doesn't fit in 8 bits");
return int8(value);
}
/**
* @dev Converts an unsigned uint256 into a signed int256.
*
* Requirements:
*
* - input must be less than or equal to maxInt256.
*/
function toInt256(uint256 value) internal pure returns (int256) {
// Note: Unsafe cast below is okay because `type(int256).max` is guaranteed to be positive
require(value <= uint256(type(int256).max), "SafeCast: value doesn't fit in an int256");
return int256(value);
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/math/SafeMath.sol)
pragma solidity ^0.8.0;
// CAUTION
// This version of SafeMath should only be used with Solidity 0.8 or later,
// because it relies on the compiler's built in overflow checks.
/**
* @dev Wrappers over Solidity's arithmetic operations.
*
* NOTE: `SafeMath` is generally not needed starting with Solidity 0.8, since the compiler
* now has built in overflow checking.
*/
library SafeMath {
/**
* @dev Returns the addition of two unsigned integers, with an overflow flag.
*
* _Available since v3.4._
*/
function tryAdd(uint256 a, uint256 b) internal pure returns (bool, uint256) {
unchecked {
uint256 c = a + b;
if (c < a) return (false, 0);
return (true, c);
}
}
/**
* @dev Returns the substraction of two unsigned integers, with an overflow flag.
*
* _Available since v3.4._
*/
function trySub(uint256 a, uint256 b) internal pure returns (bool, uint256) {
unchecked {
if (b > a) return (false, 0);
return (true, a - b);
}
}
/**
* @dev Returns the multiplication of two unsigned integers, with an overflow flag.
*
* _Available since v3.4._
*/
function tryMul(uint256 a, uint256 b) internal pure returns (bool, uint256) {
unchecked {
// Gas optimization: this is cheaper than requiring 'a' not being zero, but the
// benefit is lost if 'b' is also tested.
// See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522
if (a == 0) return (true, 0);
uint256 c = a * b;
if (c / a != b) return (false, 0);
return (true, c);
}
}
/**
* @dev Returns the division of two unsigned integers, with a division by zero flag.
*
* _Available since v3.4._
*/
function tryDiv(uint256 a, uint256 b) internal pure returns (bool, uint256) {
unchecked {
if (b == 0) return (false, 0);
return (true, a / b);
}
}
/**
* @dev Returns the remainder of dividing two unsigned integers, with a division by zero flag.
*
* _Available since v3.4._
*/
function tryMod(uint256 a, uint256 b) internal pure returns (bool, uint256) {
unchecked {
if (b == 0) return (false, 0);
return (true, a % b);
}
}
/**
* @dev Returns the addition of two unsigned integers, reverting on
* overflow.
*
* Counterpart to Solidity's `+` operator.
*
* Requirements:
*
* - Addition cannot overflow.
*/
function add(uint256 a, uint256 b) internal pure returns (uint256) {
return a + b;
}
/**
* @dev Returns the subtraction of two unsigned integers, reverting on
* overflow (when the result is negative).
*
* Counterpart to Solidity's `-` operator.
*
* Requirements:
*
* - Subtraction cannot overflow.
*/
function sub(uint256 a, uint256 b) internal pure returns (uint256) {
return a - b;
}
/**
* @dev Returns the multiplication of two unsigned integers, reverting on
* overflow.
*
* Counterpart to Solidity's `*` operator.
*
* Requirements:
*
* - Multiplication cannot overflow.
*/
function mul(uint256 a, uint256 b) internal pure returns (uint256) {
return a * b;
}
/**
* @dev Returns the integer division of two unsigned integers, reverting on
* division by zero. The result is rounded towards zero.
*
* Counterpart to Solidity's `/` operator.
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function div(uint256 a, uint256 b) internal pure returns (uint256) {
return a / b;
}
/**
* @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
* reverting when dividing by zero.
*
* Counterpart to Solidity's `%` operator. This function uses a `revert`
* opcode (which leaves remaining gas untouched) while Solidity uses an
* invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function mod(uint256 a, uint256 b) internal pure returns (uint256) {
return a % b;
}
/**
* @dev Returns the subtraction of two unsigned integers, reverting with custom message on
* overflow (when the result is negative).
*
* CAUTION: This function is deprecated because it requires allocating memory for the error
* message unnecessarily. For custom revert reasons use {trySub}.
*
* Counterpart to Solidity's `-` operator.
*
* Requirements:
*
* - Subtraction cannot overflow.
*/
function sub(
uint256 a,
uint256 b,
string memory errorMessage
) internal pure returns (uint256) {
unchecked {
require(b <= a, errorMessage);
return a - b;
}
}
/**
* @dev Returns the integer division of two unsigned integers, reverting with custom message on
* division by zero. The result is rounded towards zero.
*
* Counterpart to Solidity's `/` operator. Note: this function uses a
* `revert` opcode (which leaves remaining gas untouched) while Solidity
* uses an invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function div(
uint256 a,
uint256 b,
string memory errorMessage
) internal pure returns (uint256) {
unchecked {
require(b > 0, errorMessage);
return a / b;
}
}
/**
* @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
* reverting with custom message when dividing by zero.
*
* CAUTION: This function is deprecated because it requires allocating memory for the error
* message unnecessarily. For custom revert reasons use {tryMod}.
*
* Counterpart to Solidity's `%` operator. This function uses a `revert`
* opcode (which leaves remaining gas untouched) while Solidity uses an
* invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function mod(
uint256 a,
uint256 b,
string memory errorMessage
) internal pure returns (uint256) {
unchecked {
require(b > 0, errorMessage);
return a % b;
}
}
}// SPDX-License-Identifier: BUSL-1.1
pragma solidity ^0.8.0;
/**
* @title Base for contracts that are managed by the Origin Protocol's Governor.
* @dev Copy of the openzeppelin Ownable.sol contract with nomenclature change
* from owner to governor and renounce methods removed. Does not use
* Context.sol like Ownable.sol does for simplification.
* @author Origin Protocol Inc
*/
abstract contract Governable {
// Storage position of the owner and pendingOwner of the contract
// keccak256("OUSD.governor");
bytes32 private constant governorPosition =
0x7bea13895fa79d2831e0a9e28edede30099005a50d652d8957cf8a607ee6ca4a;
// keccak256("OUSD.pending.governor");
bytes32 private constant pendingGovernorPosition =
0x44c4d30b2eaad5130ad70c3ba6972730566f3e6359ab83e800d905c61b1c51db;
// keccak256("OUSD.reentry.status");
bytes32 private constant reentryStatusPosition =
0x53bf423e48ed90e97d02ab0ebab13b2a235a6bfbe9c321847d5c175333ac4535;
// See OpenZeppelin ReentrancyGuard implementation
uint256 constant _NOT_ENTERED = 1;
uint256 constant _ENTERED = 2;
event PendingGovernorshipTransfer(
address indexed previousGovernor,
address indexed newGovernor
);
event GovernorshipTransferred(
address indexed previousGovernor,
address indexed newGovernor
);
/**
* @notice Returns the address of the current Governor.
*/
function governor() public view returns (address) {
return _governor();
}
/**
* @dev Returns the address of the current Governor.
*/
function _governor() internal view returns (address governorOut) {
bytes32 position = governorPosition;
// solhint-disable-next-line no-inline-assembly
assembly {
governorOut := sload(position)
}
}
/**
* @dev Returns the address of the pending Governor.
*/
function _pendingGovernor()
internal
view
returns (address pendingGovernor)
{
bytes32 position = pendingGovernorPosition;
// solhint-disable-next-line no-inline-assembly
assembly {
pendingGovernor := sload(position)
}
}
/**
* @dev Throws if called by any account other than the Governor.
*/
modifier onlyGovernor() {
require(isGovernor(), "Caller is not the Governor");
_;
}
/**
* @notice Returns true if the caller is the current Governor.
*/
function isGovernor() public view returns (bool) {
return msg.sender == _governor();
}
function _setGovernor(address newGovernor) internal {
emit GovernorshipTransferred(_governor(), newGovernor);
bytes32 position = governorPosition;
// solhint-disable-next-line no-inline-assembly
assembly {
sstore(position, newGovernor)
}
}
/**
* @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() {
bytes32 position = reentryStatusPosition;
uint256 _reentry_status;
// solhint-disable-next-line no-inline-assembly
assembly {
_reentry_status := sload(position)
}
// On the first call to nonReentrant, _notEntered will be true
require(_reentry_status != _ENTERED, "Reentrant call");
// Any calls to nonReentrant after this point will fail
// solhint-disable-next-line no-inline-assembly
assembly {
sstore(position, _ENTERED)
}
_;
// By storing the original value once again, a refund is triggered (see
// https://eips.ethereum.org/EIPS/eip-2200)
// solhint-disable-next-line no-inline-assembly
assembly {
sstore(position, _NOT_ENTERED)
}
}
function _setPendingGovernor(address newGovernor) internal {
bytes32 position = pendingGovernorPosition;
// solhint-disable-next-line no-inline-assembly
assembly {
sstore(position, newGovernor)
}
}
/**
* @notice Transfers Governance of the contract to a new account (`newGovernor`).
* Can only be called by the current Governor. Must be claimed for this to complete
* @param _newGovernor Address of the new Governor
*/
function transferGovernance(address _newGovernor) external onlyGovernor {
_setPendingGovernor(_newGovernor);
emit PendingGovernorshipTransfer(_governor(), _newGovernor);
}
/**
* @notice Claim Governance of the contract to a new account (`newGovernor`).
* Can only be called by the new Governor.
*/
function claimGovernance() external {
require(
msg.sender == _pendingGovernor(),
"Only the pending Governor can complete the claim"
);
_changeGovernor(msg.sender);
}
/**
* @dev Change Governance of the contract to a new account (`newGovernor`).
* @param _newGovernor Address of the new Governor
*/
function _changeGovernor(address _newGovernor) internal {
require(_newGovernor != address(0), "New Governor is address(0)");
_setGovernor(_newGovernor);
}
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
interface IBasicToken {
function symbol() external view returns (string memory);
function decimals() external view returns (uint8);
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
interface IGetExchangeRateToken {
function getExchangeRate() external view returns (uint256 _exchangeRate);
}// SPDX-License-Identifier: BUSL-1.1
pragma solidity ^0.8.0;
interface IOracle {
/**
* @dev returns the asset price in USD, in 8 decimal digits.
*
* The version of priceProvider deployed for OETH has 18 decimal digits
*/
function price(address asset) external view returns (uint256);
}// SPDX-License-Identifier: BUSL-1.1
pragma solidity ^0.8.0;
/**
* @title Platform interface to integrate with lending platform like Compound, AAVE etc.
*/
interface IStrategy {
/**
* @dev Deposit the given asset to platform
* @param _asset asset address
* @param _amount Amount to deposit
*/
function deposit(address _asset, uint256 _amount) external;
/**
* @dev Deposit the entire balance of all supported assets in the Strategy
* to the platform
*/
function depositAll() external;
/**
* @dev Withdraw given asset from Lending platform
*/
function withdraw(
address _recipient,
address _asset,
uint256 _amount
) external;
/**
* @dev Liquidate all assets in strategy and return them to Vault.
*/
function withdrawAll() external;
/**
* @dev Returns the current balance of the given asset.
*/
function checkBalance(address _asset)
external
view
returns (uint256 balance);
/**
* @dev Returns bool indicating whether strategy supports asset.
*/
function supportsAsset(address _asset) external view returns (bool);
/**
* @dev Collect reward tokens from the Strategy.
*/
function collectRewardTokens() external;
/**
* @dev The address array of the reward tokens for the Strategy.
*/
function getRewardTokenAddresses() external view returns (address[] memory);
function harvesterAddress() external view returns (address);
function transferToken(address token, uint256 amount) external;
function setRewardTokenAddresses(address[] calldata _rewardTokenAddresses)
external;
}// SPDX-License-Identifier: BUSL-1.1
pragma solidity ^0.8.0;
import { VaultStorage } from "../vault/VaultStorage.sol";
interface IVault {
// slither-disable-start constable-states
event AssetSupported(address _asset);
event AssetDefaultStrategyUpdated(address _asset, address _strategy);
event AssetAllocated(address _asset, address _strategy, uint256 _amount);
event StrategyApproved(address _addr);
event StrategyRemoved(address _addr);
event Mint(address _addr, uint256 _value);
event Redeem(address _addr, uint256 _value);
event CapitalPaused();
event CapitalUnpaused();
event RebasePaused();
event RebaseUnpaused();
event VaultBufferUpdated(uint256 _vaultBuffer);
event RedeemFeeUpdated(uint256 _redeemFeeBps);
event PriceProviderUpdated(address _priceProvider);
event AllocateThresholdUpdated(uint256 _threshold);
event RebaseThresholdUpdated(uint256 _threshold);
event StrategistUpdated(address _address);
event MaxSupplyDiffChanged(uint256 maxSupplyDiff);
event YieldDistribution(address _to, uint256 _yield, uint256 _fee);
event TrusteeFeeBpsChanged(uint256 _basis);
event TrusteeAddressChanged(address _address);
event SwapperChanged(address _address);
event SwapAllowedUndervalueChanged(uint256 _basis);
event SwapSlippageChanged(address _asset, uint256 _basis);
event Swapped(
address indexed _fromAsset,
address indexed _toAsset,
uint256 _fromAssetAmount,
uint256 _toAssetAmount
);
event StrategyAddedToMintWhitelist(address indexed strategy);
event StrategyRemovedFromMintWhitelist(address indexed strategy);
event DripperChanged(address indexed _dripper);
event WithdrawalRequested(
address indexed _withdrawer,
uint256 indexed _requestId,
uint256 _amount,
uint256 _queued
);
event WithdrawalClaimed(
address indexed _withdrawer,
uint256 indexed _requestId,
uint256 _amount
);
event WithdrawalClaimable(uint256 _claimable, uint256 _newClaimable);
// Governable.sol
function transferGovernance(address _newGovernor) external;
function claimGovernance() external;
function governor() external view returns (address);
function ADMIN_IMPLEMENTATION() external view returns (address);
// VaultAdmin.sol
function setPriceProvider(address _priceProvider) external;
function priceProvider() external view returns (address);
function setRedeemFeeBps(uint256 _redeemFeeBps) external;
function redeemFeeBps() external view returns (uint256);
function setVaultBuffer(uint256 _vaultBuffer) external;
function vaultBuffer() external view returns (uint256);
function setAutoAllocateThreshold(uint256 _threshold) external;
function autoAllocateThreshold() external view returns (uint256);
function setRebaseThreshold(uint256 _threshold) external;
function rebaseThreshold() external view returns (uint256);
function setStrategistAddr(address _address) external;
function strategistAddr() external view returns (address);
function setMaxSupplyDiff(uint256 _maxSupplyDiff) external;
function maxSupplyDiff() external view returns (uint256);
function setTrusteeAddress(address _address) external;
function trusteeAddress() external view returns (address);
function setTrusteeFeeBps(uint256 _basis) external;
function trusteeFeeBps() external view returns (uint256);
function ousdMetaStrategy() external view returns (address);
function setSwapper(address _swapperAddr) external;
function setSwapAllowedUndervalue(uint16 _percentageBps) external;
function setOracleSlippage(address _asset, uint16 _allowedOracleSlippageBps)
external;
function supportAsset(address _asset, uint8 _unitConversion) external;
function approveStrategy(address _addr) external;
function removeStrategy(address _addr) external;
function setAssetDefaultStrategy(address _asset, address _strategy)
external;
function assetDefaultStrategies(address _asset)
external
view
returns (address);
function pauseRebase() external;
function unpauseRebase() external;
function rebasePaused() external view returns (bool);
function pauseCapital() external;
function unpauseCapital() external;
function capitalPaused() external view returns (bool);
function transferToken(address _asset, uint256 _amount) external;
function priceUnitMint(address asset) external view returns (uint256);
function priceUnitRedeem(address asset) external view returns (uint256);
function withdrawAllFromStrategy(address _strategyAddr) external;
function withdrawAllFromStrategies() external;
function withdrawFromStrategy(
address _strategyFromAddress,
address[] calldata _assets,
uint256[] calldata _amounts
) external;
function depositToStrategy(
address _strategyToAddress,
address[] calldata _assets,
uint256[] calldata _amounts
) external;
// VaultCore.sol
function mint(
address _asset,
uint256 _amount,
uint256 _minimumOusdAmount
) external;
function mintForStrategy(uint256 _amount) external;
function redeem(uint256 _amount, uint256 _minimumUnitAmount) external;
function burnForStrategy(uint256 _amount) external;
function allocate() external;
function rebase() external;
function swapCollateral(
address fromAsset,
address toAsset,
uint256 fromAssetAmount,
uint256 minToAssetAmount,
bytes calldata data
) external returns (uint256 toAssetAmount);
function totalValue() external view returns (uint256 value);
function checkBalance(address _asset) external view returns (uint256);
function calculateRedeemOutputs(uint256 _amount)
external
view
returns (uint256[] memory);
function getAssetCount() external view returns (uint256);
function getAssetConfig(address _asset)
external
view
returns (VaultStorage.Asset memory config);
function getAllAssets() external view returns (address[] memory);
function getStrategyCount() external view returns (uint256);
function swapper() external view returns (address);
function allowedSwapUndervalue() external view returns (uint256);
function getAllStrategies() external view returns (address[] memory);
function isSupportedAsset(address _asset) external view returns (bool);
function netOusdMintForStrategyThreshold() external view returns (uint256);
function setOusdMetaStrategy(address _ousdMetaStrategy) external;
function setNetOusdMintForStrategyThreshold(uint256 _threshold) external;
function netOusdMintedForStrategy() external view returns (int256);
function setDripper(address _dripper) external;
function dripper() external view returns (address);
function weth() external view returns (address);
function cacheWETHAssetIndex() external;
function wethAssetIndex() external view returns (uint256);
function initialize(address, address) external;
function setAdminImpl(address) external;
function removeAsset(address _asset) external;
// These are OETH specific functions
function addWithdrawalQueueLiquidity() external;
function requestWithdrawal(uint256 _amount)
external
returns (uint256 requestId, uint256 queued);
function claimWithdrawal(uint256 requestId)
external
returns (uint256 amount);
function claimWithdrawals(uint256[] memory requestIds)
external
returns (uint256[] memory amounts, uint256 totalAmount);
function withdrawalQueueMetadata()
external
view
returns (VaultStorage.WithdrawalQueueMetadata memory);
function withdrawalRequests(uint256 requestId)
external
view
returns (VaultStorage.WithdrawalRequest memory);
// OETHb specific functions
function addStrategyToMintWhitelist(address strategyAddr) external;
function removeStrategyFromMintWhitelist(address strategyAddr) external;
function isMintWhitelistedStrategy(address strategyAddr)
external
view
returns (bool);
function withdrawalClaimDelay() external view returns (uint256);
function setWithdrawalClaimDelay(uint256 newDelay) external;
function lastRebase() external view returns (uint64);
function dripDuration() external view returns (uint64);
function setDripDuration(uint256 _dripDuration) external;
function rebasePerSecondMax() external view returns (uint64);
function setRebaseRateMax(uint256 yearlyApr) external;
function rebasePerSecondTarget() external view returns (uint64);
function previewYield() external view returns (uint256 yield);
// slither-disable-end constable-states
}// SPDX-License-Identifier: BUSL-1.1
pragma solidity ^0.8.0;
/**
* @title OUSD Token Contract
* @dev ERC20 compatible contract for OUSD
* @dev Implements an elastic supply
* @author Origin Protocol Inc
*/
import { IVault } from "../interfaces/IVault.sol";
import { Governable } from "../governance/Governable.sol";
import { SafeCast } from "@openzeppelin/contracts/utils/math/SafeCast.sol";
contract OUSD is Governable {
using SafeCast for int256;
using SafeCast for uint256;
/// @dev Event triggered when the supply changes
/// @param totalSupply Updated token total supply
/// @param rebasingCredits Updated token rebasing credits
/// @param rebasingCreditsPerToken Updated token rebasing credits per token
event TotalSupplyUpdatedHighres(
uint256 totalSupply,
uint256 rebasingCredits,
uint256 rebasingCreditsPerToken
);
/// @dev Event triggered when an account opts in for rebasing
/// @param account Address of the account
event AccountRebasingEnabled(address account);
/// @dev Event triggered when an account opts out of rebasing
/// @param account Address of the account
event AccountRebasingDisabled(address account);
/// @dev Emitted when `value` tokens are moved from one account `from` to
/// another `to`.
/// @param from Address of the account tokens are moved from
/// @param to Address of the account tokens are moved to
/// @param value Amount of tokens transferred
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.
/// @param owner Address of the owner approving allowance
/// @param spender Address of the spender allowance is granted to
/// @param value Amount of tokens spender can transfer
event Approval(
address indexed owner,
address indexed spender,
uint256 value
);
/// @dev Yield resulting from {changeSupply} that a `source` account would
/// receive is directed to `target` account.
/// @param source Address of the source forwarding the yield
/// @param target Address of the target receiving the yield
event YieldDelegated(address source, address target);
/// @dev Yield delegation from `source` account to the `target` account is
/// suspended.
/// @param source Address of the source suspending yield forwarding
/// @param target Address of the target no longer receiving yield from `source`
/// account
event YieldUndelegated(address source, address target);
enum RebaseOptions {
NotSet,
StdNonRebasing,
StdRebasing,
YieldDelegationSource,
YieldDelegationTarget
}
uint256[154] private _gap; // Slots to align with deployed contract
uint256 private constant MAX_SUPPLY = type(uint128).max;
/// @dev The amount of tokens in existence
uint256 public totalSupply;
mapping(address => mapping(address => uint256)) private allowances;
/// @dev The vault with privileges to execute {mint}, {burn}
/// and {changeSupply}
address public vaultAddress;
mapping(address => uint256) internal creditBalances;
// the 2 storage variables below need trailing underscores to not name collide with public functions
uint256 private rebasingCredits_; // Sum of all rebasing credits (creditBalances for rebasing accounts)
uint256 private rebasingCreditsPerToken_;
/// @dev The amount of tokens that are not rebasing - receiving yield
uint256 public nonRebasingSupply;
mapping(address => uint256) internal alternativeCreditsPerToken;
/// @dev A map of all addresses and their respective RebaseOptions
mapping(address => RebaseOptions) public rebaseState;
mapping(address => uint256) private __deprecated_isUpgraded;
/// @dev A map of addresses that have yields forwarded to. This is an
/// inverse mapping of {yieldFrom}
/// Key Account forwarding yield
/// Value Account receiving yield
mapping(address => address) public yieldTo;
/// @dev A map of addresses that are receiving the yield. This is an
/// inverse mapping of {yieldTo}
/// Key Account receiving yield
/// Value Account forwarding yield
mapping(address => address) public yieldFrom;
uint256 private constant RESOLUTION_INCREASE = 1e9;
uint256[34] private __gap; // including below gap totals up to 200
/// @dev Verifies that the caller is the Governor or Strategist.
modifier onlyGovernorOrStrategist() {
require(
isGovernor() || msg.sender == IVault(vaultAddress).strategistAddr(),
"Caller is not the Strategist or Governor"
);
_;
}
/// @dev Initializes the contract and sets necessary variables.
/// @param _vaultAddress Address of the vault contract
/// @param _initialCreditsPerToken The starting rebasing credits per token.
function initialize(address _vaultAddress, uint256 _initialCreditsPerToken)
external
onlyGovernor
{
require(_vaultAddress != address(0), "Zero vault address");
require(vaultAddress == address(0), "Already initialized");
rebasingCreditsPerToken_ = _initialCreditsPerToken;
vaultAddress = _vaultAddress;
}
/// @dev Returns the symbol of the token, a shorter version
/// of the name.
function symbol() external pure virtual returns (string memory) {
return "OUSD";
}
/// @dev Returns the name of the token.
function name() external pure virtual returns (string memory) {
return "Origin Dollar";
}
/// @dev Returns the number of decimals used to get its user representation.
function decimals() external pure virtual returns (uint8) {
return 18;
}
/**
* @dev Verifies that the caller is the Vault contract
*/
modifier onlyVault() {
require(vaultAddress == msg.sender, "Caller is not the Vault");
_;
}
/**
* @return High resolution rebasingCreditsPerToken
*/
function rebasingCreditsPerTokenHighres() external view returns (uint256) {
return rebasingCreditsPerToken_;
}
/**
* @return Low resolution rebasingCreditsPerToken
*/
function rebasingCreditsPerToken() external view returns (uint256) {
return rebasingCreditsPerToken_ / RESOLUTION_INCREASE;
}
/**
* @return High resolution total number of rebasing credits
*/
function rebasingCreditsHighres() external view returns (uint256) {
return rebasingCredits_;
}
/**
* @return Low resolution total number of rebasing credits
*/
function rebasingCredits() external view returns (uint256) {
return rebasingCredits_ / RESOLUTION_INCREASE;
}
/**
* @notice Gets the balance of the specified address.
* @param _account Address to query the balance of.
* @return A uint256 representing the amount of base units owned by the
* specified address.
*/
function balanceOf(address _account) public view returns (uint256) {
RebaseOptions state = rebaseState[_account];
if (state == RebaseOptions.YieldDelegationSource) {
// Saves a slot read when transferring to or from a yield delegating source
// since we know creditBalances equals the balance.
return creditBalances[_account];
}
uint256 baseBalance = (creditBalances[_account] * 1e18) /
_creditsPerToken(_account);
if (state == RebaseOptions.YieldDelegationTarget) {
// creditBalances of yieldFrom accounts equals token balances
return baseBalance - creditBalances[yieldFrom[_account]];
}
return baseBalance;
}
/**
* @notice Gets the credits balance of the specified address.
* @dev Backwards compatible with old low res credits per token.
* @param _account The address to query the balance of.
* @return (uint256, uint256) Credit balance and credits per token of the
* address
*/
function creditsBalanceOf(address _account)
external
view
returns (uint256, uint256)
{
uint256 cpt = _creditsPerToken(_account);
if (cpt == 1e27) {
// For a period before the resolution upgrade, we created all new
// contract accounts at high resolution. Since they are not changing
// as a result of this upgrade, we will return their true values
return (creditBalances[_account], cpt);
} else {
return (
creditBalances[_account] / RESOLUTION_INCREASE,
cpt / RESOLUTION_INCREASE
);
}
}
/**
* @notice Gets the credits balance of the specified address.
* @param _account The address to query the balance of.
* @return (uint256, uint256, bool) Credit balance, credits per token of the
* address, and isUpgraded
*/
function creditsBalanceOfHighres(address _account)
external
view
returns (
uint256,
uint256,
bool
)
{
return (
creditBalances[_account],
_creditsPerToken(_account),
true // all accounts have their resolution "upgraded"
);
}
// Backwards compatible view
function nonRebasingCreditsPerToken(address _account)
external
view
returns (uint256)
{
return alternativeCreditsPerToken[_account];
}
/**
* @notice Transfer tokens to a specified address.
* @param _to the address to transfer to.
* @param _value the amount to be transferred.
* @return true on success.
*/
function transfer(address _to, uint256 _value) external returns (bool) {
require(_to != address(0), "Transfer to zero address");
_executeTransfer(msg.sender, _to, _value);
emit Transfer(msg.sender, _to, _value);
return true;
}
/**
* @notice Transfer tokens from one address to another.
* @param _from The address you want to send tokens from.
* @param _to The address you want to transfer to.
* @param _value The amount of tokens to be transferred.
* @return true on success.
*/
function transferFrom(
address _from,
address _to,
uint256 _value
) external returns (bool) {
require(_to != address(0), "Transfer to zero address");
uint256 userAllowance = allowances[_from][msg.sender];
require(_value <= userAllowance, "Allowance exceeded");
unchecked {
allowances[_from][msg.sender] = userAllowance - _value;
}
_executeTransfer(_from, _to, _value);
emit Transfer(_from, _to, _value);
return true;
}
function _executeTransfer(
address _from,
address _to,
uint256 _value
) internal {
(
int256 fromRebasingCreditsDiff,
int256 fromNonRebasingSupplyDiff
) = _adjustAccount(_from, -_value.toInt256());
(
int256 toRebasingCreditsDiff,
int256 toNonRebasingSupplyDiff
) = _adjustAccount(_to, _value.toInt256());
_adjustGlobals(
fromRebasingCreditsDiff + toRebasingCreditsDiff,
fromNonRebasingSupplyDiff + toNonRebasingSupplyDiff
);
}
function _adjustAccount(address _account, int256 _balanceChange)
internal
returns (int256 rebasingCreditsDiff, int256 nonRebasingSupplyDiff)
{
RebaseOptions state = rebaseState[_account];
int256 currentBalance = balanceOf(_account).toInt256();
if (currentBalance + _balanceChange < 0) {
revert("Transfer amount exceeds balance");
}
uint256 newBalance = (currentBalance + _balanceChange).toUint256();
if (state == RebaseOptions.YieldDelegationSource) {
address target = yieldTo[_account];
uint256 targetOldBalance = balanceOf(target);
uint256 targetNewCredits = _balanceToRebasingCredits(
targetOldBalance + newBalance
);
rebasingCreditsDiff =
targetNewCredits.toInt256() -
creditBalances[target].toInt256();
creditBalances[_account] = newBalance;
creditBalances[target] = targetNewCredits;
} else if (state == RebaseOptions.YieldDelegationTarget) {
uint256 newCredits = _balanceToRebasingCredits(
newBalance + creditBalances[yieldFrom[_account]]
);
rebasingCreditsDiff =
newCredits.toInt256() -
creditBalances[_account].toInt256();
creditBalances[_account] = newCredits;
} else {
_autoMigrate(_account);
uint256 alternativeCreditsPerTokenMem = alternativeCreditsPerToken[
_account
];
if (alternativeCreditsPerTokenMem > 0) {
nonRebasingSupplyDiff = _balanceChange;
if (alternativeCreditsPerTokenMem != 1e18) {
alternativeCreditsPerToken[_account] = 1e18;
}
creditBalances[_account] = newBalance;
} else {
uint256 newCredits = _balanceToRebasingCredits(newBalance);
rebasingCreditsDiff =
newCredits.toInt256() -
creditBalances[_account].toInt256();
creditBalances[_account] = newCredits;
}
}
}
function _adjustGlobals(
int256 _rebasingCreditsDiff,
int256 _nonRebasingSupplyDiff
) internal {
if (_rebasingCreditsDiff != 0) {
rebasingCredits_ = (rebasingCredits_.toInt256() +
_rebasingCreditsDiff).toUint256();
}
if (_nonRebasingSupplyDiff != 0) {
nonRebasingSupply = (nonRebasingSupply.toInt256() +
_nonRebasingSupplyDiff).toUint256();
}
}
/**
* @notice Function to check the amount of tokens that _owner has allowed
* to `_spender`.
* @param _owner The address which owns the funds.
* @param _spender The address which will spend the funds.
* @return The number of tokens still available for the _spender.
*/
function allowance(address _owner, address _spender)
external
view
returns (uint256)
{
return allowances[_owner][_spender];
}
/**
* @notice Approve the passed address to spend the specified amount of
* tokens on behalf of msg.sender.
* @param _spender The address which will spend the funds.
* @param _value The amount of tokens to be spent.
* @return true on success.
*/
function approve(address _spender, uint256 _value) external returns (bool) {
allowances[msg.sender][_spender] = _value;
emit Approval(msg.sender, _spender, _value);
return true;
}
/**
* @notice Creates `_amount` tokens and assigns them to `_account`,
* increasing the total supply.
*/
function mint(address _account, uint256 _amount) external onlyVault {
require(_account != address(0), "Mint to the zero address");
// Account
(
int256 toRebasingCreditsDiff,
int256 toNonRebasingSupplyDiff
) = _adjustAccount(_account, _amount.toInt256());
// Globals
_adjustGlobals(toRebasingCreditsDiff, toNonRebasingSupplyDiff);
totalSupply = totalSupply + _amount;
require(totalSupply < MAX_SUPPLY, "Max supply");
emit Transfer(address(0), _account, _amount);
}
/**
* @notice Destroys `_amount` tokens from `_account`,
* reducing the total supply.
*/
function burn(address _account, uint256 _amount) external onlyVault {
require(_account != address(0), "Burn from the zero address");
if (_amount == 0) {
return;
}
// Account
(
int256 toRebasingCreditsDiff,
int256 toNonRebasingSupplyDiff
) = _adjustAccount(_account, -_amount.toInt256());
// Globals
_adjustGlobals(toRebasingCreditsDiff, toNonRebasingSupplyDiff);
totalSupply = totalSupply - _amount;
emit Transfer(_account, address(0), _amount);
}
/**
* @dev Get the credits per token for an account. Returns a fixed amount
* if the account is non-rebasing.
* @param _account Address of the account.
*/
function _creditsPerToken(address _account)
internal
view
returns (uint256)
{
uint256 alternativeCreditsPerTokenMem = alternativeCreditsPerToken[
_account
];
if (alternativeCreditsPerTokenMem != 0) {
return alternativeCreditsPerTokenMem;
} else {
return rebasingCreditsPerToken_;
}
}
/**
* @dev Auto migrate contracts to be non rebasing,
* unless they have opted into yield.
* @param _account Address of the account.
*/
function _autoMigrate(address _account) internal {
uint256 codeLen = _account.code.length;
bool isEOA = (codeLen == 0) ||
(codeLen == 23 && bytes3(_account.code) == 0xef0100);
// In previous code versions, contracts would not have had their
// rebaseState[_account] set to RebaseOptions.NonRebasing when migrated
// therefore we check the actual accounting used on the account as well.
if (
(!isEOA) &&
rebaseState[_account] == RebaseOptions.NotSet &&
alternativeCreditsPerToken[_account] == 0
) {
_rebaseOptOut(_account);
}
}
/**
* @dev Calculates credits from contract's global rebasingCreditsPerToken_, and
* also balance that corresponds to those credits. The latter is important
* when adjusting the contract's global nonRebasingSupply to circumvent any
* possible rounding errors.
*
* @param _balance Balance of the account.
*/
function _balanceToRebasingCredits(uint256 _balance)
internal
view
returns (uint256 rebasingCredits)
{
// Rounds up, because we need to ensure that accounts always have
// at least the balance that they should have.
// Note this should always be used on an absolute account value,
// not on a possibly negative diff, because then the rounding would be wrong.
return ((_balance) * rebasingCreditsPerToken_ + 1e18 - 1) / 1e18;
}
/**
* @notice The calling account will start receiving yield after a successful call.
* @param _account Address of the account.
*/
function governanceRebaseOptIn(address _account) external onlyGovernor {
require(_account != address(0), "Zero address not allowed");
_rebaseOptIn(_account);
}
/**
* @notice The calling account will start receiving yield after a successful call.
*/
function rebaseOptIn() external {
_rebaseOptIn(msg.sender);
}
function _rebaseOptIn(address _account) internal {
uint256 balance = balanceOf(_account);
// prettier-ignore
require(
alternativeCreditsPerToken[_account] > 0 ||
// Accounts may explicitly `rebaseOptIn` regardless of
// accounting if they have a 0 balance.
creditBalances[_account] == 0
,
"Account must be non-rebasing"
);
RebaseOptions state = rebaseState[_account];
// prettier-ignore
require(
state == RebaseOptions.StdNonRebasing ||
state == RebaseOptions.NotSet,
"Only standard non-rebasing accounts can opt in"
);
uint256 newCredits = _balanceToRebasingCredits(balance);
// Account
rebaseState[_account] = RebaseOptions.StdRebasing;
alternativeCreditsPerToken[_account] = 0;
creditBalances[_account] = newCredits;
// Globals
_adjustGlobals(newCredits.toInt256(), -balance.toInt256());
emit AccountRebasingEnabled(_account);
}
/**
* @notice The calling account will no longer receive yield
*/
function rebaseOptOut() external {
_rebaseOptOut(msg.sender);
}
function _rebaseOptOut(address _account) internal {
require(
alternativeCreditsPerToken[_account] == 0,
"Account must be rebasing"
);
RebaseOptions state = rebaseState[_account];
require(
state == RebaseOptions.StdRebasing || state == RebaseOptions.NotSet,
"Only standard rebasing accounts can opt out"
);
uint256 oldCredits = creditBalances[_account];
uint256 balance = balanceOf(_account);
// Account
rebaseState[_account] = RebaseOptions.StdNonRebasing;
alternativeCreditsPerToken[_account] = 1e18;
creditBalances[_account] = balance;
// Globals
_adjustGlobals(-oldCredits.toInt256(), balance.toInt256());
emit AccountRebasingDisabled(_account);
}
/**
* @notice Distribute yield to users. This changes the exchange rate
* between "credits" and OUSD tokens to change rebasing user's balances.
* @param _newTotalSupply New total supply of OUSD.
*/
function changeSupply(uint256 _newTotalSupply) external onlyVault {
require(totalSupply > 0, "Cannot increase 0 supply");
if (totalSupply == _newTotalSupply) {
emit TotalSupplyUpdatedHighres(
totalSupply,
rebasingCredits_,
rebasingCreditsPerToken_
);
return;
}
totalSupply = _newTotalSupply > MAX_SUPPLY
? MAX_SUPPLY
: _newTotalSupply;
uint256 rebasingSupply = totalSupply - nonRebasingSupply;
// round up in the favour of the protocol
rebasingCreditsPerToken_ =
(rebasingCredits_ * 1e18 + rebasingSupply - 1) /
rebasingSupply;
require(rebasingCreditsPerToken_ > 0, "Invalid change in supply");
emit TotalSupplyUpdatedHighres(
totalSupply,
rebasingCredits_,
rebasingCreditsPerToken_
);
}
/*
* @notice Send the yield from one account to another account.
* Each account keeps its own balances.
*/
function delegateYield(address _from, address _to)
external
onlyGovernorOrStrategist
{
require(_from != address(0), "Zero from address not allowed");
require(_to != address(0), "Zero to address not allowed");
require(_from != _to, "Cannot delegate to self");
require(
yieldFrom[_to] == address(0) &&
yieldTo[_to] == address(0) &&
yieldFrom[_from] == address(0) &&
yieldTo[_from] == address(0),
"Blocked by existing yield delegation"
);
RebaseOptions stateFrom = rebaseState[_from];
RebaseOptions stateTo = rebaseState[_to];
require(
stateFrom == RebaseOptions.NotSet ||
stateFrom == RebaseOptions.StdNonRebasing ||
stateFrom == RebaseOptions.StdRebasing,
"Invalid rebaseState from"
);
require(
stateTo == RebaseOptions.NotSet ||
stateTo == RebaseOptions.StdNonRebasing ||
stateTo == RebaseOptions.StdRebasing,
"Invalid rebaseState to"
);
if (alternativeCreditsPerToken[_from] == 0) {
_rebaseOptOut(_from);
}
if (alternativeCreditsPerToken[_to] > 0) {
_rebaseOptIn(_to);
}
uint256 fromBalance = balanceOf(_from);
uint256 toBalance = balanceOf(_to);
uint256 oldToCredits = creditBalances[_to];
uint256 newToCredits = _balanceToRebasingCredits(
fromBalance + toBalance
);
// Set up the bidirectional links
yieldTo[_from] = _to;
yieldFrom[_to] = _from;
// Local
rebaseState[_from] = RebaseOptions.YieldDelegationSource;
alternativeCreditsPerToken[_from] = 1e18;
creditBalances[_from] = fromBalance;
rebaseState[_to] = RebaseOptions.YieldDelegationTarget;
creditBalances[_to] = newToCredits;
// Global
int256 creditsChange = newToCredits.toInt256() -
oldToCredits.toInt256();
_adjustGlobals(creditsChange, -(fromBalance).toInt256());
emit YieldDelegated(_from, _to);
}
/*
* @notice Stop sending the yield from one account to another account.
*/
function undelegateYield(address _from) external onlyGovernorOrStrategist {
// Require a delegation, which will also ensure a valid delegation
require(yieldTo[_from] != address(0), "Zero address not allowed");
address to = yieldTo[_from];
uint256 fromBalance = balanceOf(_from);
uint256 toBalance = balanceOf(to);
uint256 oldToCredits = creditBalances[to];
uint256 newToCredits = _balanceToRebasingCredits(toBalance);
// Remove the bidirectional links
yieldFrom[to] = address(0);
yieldTo[_from] = address(0);
// Local
rebaseState[_from] = RebaseOptions.StdNonRebasing;
// alternativeCreditsPerToken[from] already 1e18 from `delegateYield()`
creditBalances[_from] = fromBalance;
rebaseState[to] = RebaseOptions.StdRebasing;
// alternativeCreditsPerToken[to] already 0 from `delegateYield()`
creditBalances[to] = newToCredits;
// Global
int256 creditsChange = newToCredits.toInt256() -
oldToCredits.toInt256();
_adjustGlobals(creditsChange, fromBalance.toInt256());
emit YieldUndelegated(_from, to);
}
}// SPDX-License-Identifier: BUSL-1.1
pragma solidity ^0.8.0;
import { IBasicToken } from "../interfaces/IBasicToken.sol";
library Helpers {
/**
* @notice Fetch the `symbol()` from an ERC20 token
* @dev Grabs the `symbol()` from a contract
* @param _token Address of the ERC20 token
* @return string Symbol of the ERC20 token
*/
function getSymbol(address _token) internal view returns (string memory) {
string memory symbol = IBasicToken(_token).symbol();
return symbol;
}
/**
* @notice Fetch the `decimals()` from an ERC20 token
* @dev Grabs the `decimals()` from a contract and fails if
* the decimal value does not live within a certain range
* @param _token Address of the ERC20 token
* @return uint256 Decimals of the ERC20 token
*/
function getDecimals(address _token) internal view returns (uint256) {
uint256 decimals = IBasicToken(_token).decimals();
require(
decimals >= 4 && decimals <= 18,
"Token must have sufficient decimal places"
);
return decimals;
}
}// SPDX-License-Identifier: BUSL-1.1
pragma solidity ^0.8.0;
/**
* @title Base contract any contracts that need to initialize state after deployment.
* @author Origin Protocol Inc
*/
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;
}
}
uint256[50] private ______gap;
}// SPDX-License-Identifier: BUSL-1.1
pragma solidity ^0.8.0;
import { SafeMath } from "@openzeppelin/contracts/utils/math/SafeMath.sol";
// Based on StableMath from Stability Labs Pty. Ltd.
// https://github.com/mstable/mStable-contracts/blob/master/contracts/shared/StableMath.sol
library StableMath {
using SafeMath for uint256;
/**
* @dev Scaling unit for use in specific calculations,
* where 1 * 10**18, or 1e18 represents a unit '1'
*/
uint256 private constant FULL_SCALE = 1e18;
/***************************************
Helpers
****************************************/
/**
* @dev Adjust the scale of an integer
* @param to Decimals to scale to
* @param from Decimals to scale from
*/
function scaleBy(
uint256 x,
uint256 to,
uint256 from
) internal pure returns (uint256) {
if (to > from) {
x = x.mul(10**(to - from));
} else if (to < from) {
// slither-disable-next-line divide-before-multiply
x = x.div(10**(from - to));
}
return x;
}
/***************************************
Precise Arithmetic
****************************************/
/**
* @dev Multiplies two precise units, and then truncates by the full scale
* @param x Left hand input to multiplication
* @param y Right hand input to multiplication
* @return Result after multiplying the two inputs and then dividing by the shared
* scale unit
*/
function mulTruncate(uint256 x, uint256 y) internal pure returns (uint256) {
return mulTruncateScale(x, y, FULL_SCALE);
}
/**
* @dev Multiplies two precise units, and then truncates by the given scale. For example,
* when calculating 90% of 10e18, (10e18 * 9e17) / 1e18 = (9e36) / 1e18 = 9e18
* @param x Left hand input to multiplication
* @param y Right hand input to multiplication
* @param scale Scale unit
* @return Result after multiplying the two inputs and then dividing by the shared
* scale unit
*/
function mulTruncateScale(
uint256 x,
uint256 y,
uint256 scale
) internal pure returns (uint256) {
// e.g. assume scale = fullScale
// z = 10e18 * 9e17 = 9e36
uint256 z = x.mul(y);
// return 9e36 / 1e18 = 9e18
return z.div(scale);
}
/**
* @dev Multiplies two precise units, and then truncates by the full scale, rounding up the result
* @param x Left hand input to multiplication
* @param y Right hand input to multiplication
* @return Result after multiplying the two inputs and then dividing by the shared
* scale unit, rounded up to the closest base unit.
*/
function mulTruncateCeil(uint256 x, uint256 y)
internal
pure
returns (uint256)
{
// e.g. 8e17 * 17268172638 = 138145381104e17
uint256 scaled = x.mul(y);
// e.g. 138145381104e17 + 9.99...e17 = 138145381113.99...e17
uint256 ceil = scaled.add(FULL_SCALE.sub(1));
// e.g. 13814538111.399...e18 / 1e18 = 13814538111
return ceil.div(FULL_SCALE);
}
/**
* @dev Precisely divides two units, by first scaling the left hand operand. Useful
* for finding percentage weightings, i.e. 8e18/10e18 = 80% (or 8e17)
* @param x Left hand input to division
* @param y Right hand input to division
* @return Result after multiplying the left operand by the scale, and
* executing the division on the right hand input.
*/
function divPrecisely(uint256 x, uint256 y)
internal
pure
returns (uint256)
{
// e.g. 8e18 * 1e18 = 8e36
uint256 z = x.mul(FULL_SCALE);
// e.g. 8e36 / 10e18 = 8e17
return z.div(y);
}
}// SPDX-License-Identifier: BUSL-1.1
pragma solidity ^0.8.0;
import { SafeERC20 } from "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
import { IERC20 } from "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import { SafeCast } from "@openzeppelin/contracts/utils/math/SafeCast.sol";
import { StableMath } from "../utils/StableMath.sol";
import { VaultCore } from "./VaultCore.sol";
import { IStrategy } from "../interfaces/IStrategy.sol";
/**
* @title OETH VaultCore Contract
* @author Origin Protocol Inc
*/
contract OETHVaultCore is VaultCore {
using SafeERC20 for IERC20;
using StableMath for uint256;
address public immutable weth;
uint256 public wethAssetIndex;
// For future use (because OETHBaseVaultCore inherits from this)
uint256[50] private __gap;
constructor(address _weth) {
weth = _weth;
}
/**
* @dev Caches WETH's index in `allAssets` variable.
* Reduces gas usage by redeem by caching that.
*/
function cacheWETHAssetIndex() external onlyGovernor {
uint256 assetCount = allAssets.length;
for (uint256 i; i < assetCount; ++i) {
if (allAssets[i] == weth) {
wethAssetIndex = i;
break;
}
}
require(allAssets[wethAssetIndex] == weth, "Invalid WETH Asset Index");
}
// @inheritdoc VaultCore
function mintForStrategy(uint256 amount)
external
override
whenNotCapitalPaused
{
require(
strategies[msg.sender].isSupported == true,
"Unsupported strategy"
);
require(
isMintWhitelistedStrategy[msg.sender] == true,
"Not whitelisted strategy"
);
emit Mint(msg.sender, amount);
// Mint matching amount of OTokens
oUSD.mint(msg.sender, amount);
}
// @inheritdoc VaultCore
function burnForStrategy(uint256 amount)
external
override
whenNotCapitalPaused
{
require(
strategies[msg.sender].isSupported == true,
"Unsupported strategy"
);
require(
isMintWhitelistedStrategy[msg.sender] == true,
"Not whitelisted strategy"
);
emit Redeem(msg.sender, amount);
// Burn OTokens
oUSD.burn(msg.sender, amount);
}
// @inheritdoc VaultCore
// slither-disable-start reentrancy-no-eth
function _mint(
address _asset,
uint256 _amount,
uint256 _minimumOusdAmount
) internal virtual override {
require(_asset == weth, "Unsupported asset for minting");
require(_amount > 0, "Amount must be greater than 0");
require(
_amount >= _minimumOusdAmount,
"Mint amount lower than minimum"
);
emit Mint(msg.sender, _amount);
// Rebase must happen before any transfers occur.
if (!rebasePaused && _amount >= rebaseThreshold) {
_rebase();
}
// Mint oTokens
oUSD.mint(msg.sender, _amount);
// Transfer the deposited coins to the vault
IERC20(_asset).safeTransferFrom(msg.sender, address(this), _amount);
// Give priority to the withdrawal queue for the new WETH liquidity
_addWithdrawalQueueLiquidity();
// Auto-allocate if necessary
if (_amount >= autoAllocateThreshold) {
_allocate();
}
}
// slither-disable-end reentrancy-no-eth
// @inheritdoc VaultCore
function _calculateRedeemOutputs(uint256 _amount)
internal
view
virtual
override
returns (uint256[] memory outputs)
{
// Overrides `VaultCore._calculateRedeemOutputs` to redeem with only
// WETH instead of LST-mix. Doesn't change the function signature
// for backward compatibility
// Calculate redeem fee
if (redeemFeeBps > 0) {
uint256 redeemFee = _amount.mulTruncateScale(redeemFeeBps, 1e4);
_amount = _amount - redeemFee;
}
// Ensure that the WETH index is cached
uint256 _wethAssetIndex = wethAssetIndex;
require(
allAssets[_wethAssetIndex] == weth,
"WETH Asset index not cached"
);
outputs = new uint256[](allAssets.length);
outputs[_wethAssetIndex] = _amount;
}
// @inheritdoc VaultCore
function _redeem(uint256 _amount, uint256 _minimumUnitAmount)
internal
virtual
override
{
// Override `VaultCore._redeem` to simplify it. Gets rid of oracle
// usage and looping through all assets for LST-mix redeem. Instead
// does a simple WETH-only redeem.
emit Redeem(msg.sender, _amount);
if (_amount == 0) {
return;
}
// Amount excluding fees
// No fee for the strategist or the governor, makes it easier to do operations
uint256 amountMinusFee = (msg.sender == strategistAddr || isGovernor())
? _amount
: _calculateRedeemOutputs(_amount)[wethAssetIndex];
require(
amountMinusFee >= _minimumUnitAmount,
"Redeem amount lower than minimum"
);
// Is there enough WETH in the Vault available after accounting for the withdrawal queue
require(_wethAvailable() >= amountMinusFee, "Liquidity error");
// Transfer WETH minus the fee to the redeemer
IERC20(weth).safeTransfer(msg.sender, amountMinusFee);
// Burn OETH from user (including fees)
oUSD.burn(msg.sender, _amount);
// Prevent insolvency
_postRedeem(_amount);
}
/**
* @notice Request an asynchronous withdrawal of WETH in exchange for OETH.
* The OETH is burned on request and the WETH is transferred to the withdrawer on claim.
* This request can be claimed once the withdrawal queue's `claimable` amount
* is greater than or equal this request's `queued` amount.
* There is a minimum of 10 minutes before a request can be claimed. After that, the request just needs
* enough WETH liquidity in the Vault to satisfy all the outstanding requests to that point in the queue.
* OETH is converted to WETH at 1:1.
* @param _amount Amount of OETH to burn.
* @return requestId Unique ID for the withdrawal request
* @return queued Cumulative total of all WETH queued including already claimed requests.
*/
function requestWithdrawal(uint256 _amount)
external
virtual
whenNotCapitalPaused
nonReentrant
returns (uint256 requestId, uint256 queued)
{
require(withdrawalClaimDelay > 0, "Async withdrawals not enabled");
// The check that the requester has enough OETH is done in to later burn call
requestId = withdrawalQueueMetadata.nextWithdrawalIndex;
queued = withdrawalQueueMetadata.queued + _amount;
// Store the next withdrawal request
withdrawalQueueMetadata.nextWithdrawalIndex = SafeCast.toUint128(
requestId + 1
);
// Store the updated queued amount which reserves WETH in the withdrawal queue
// and reduces the vault's total assets
withdrawalQueueMetadata.queued = SafeCast.toUint128(queued);
// Store the user's withdrawal request
withdrawalRequests[requestId] = WithdrawalRequest({
withdrawer: msg.sender,
claimed: false,
timestamp: uint40(block.timestamp),
amount: SafeCast.toUint128(_amount),
queued: SafeCast.toUint128(queued)
});
// Burn the user's OETH
oUSD.burn(msg.sender, _amount);
// Prevent withdrawal if the vault is solvent by more than the allowed percentage
_postRedeem(_amount);
emit WithdrawalRequested(msg.sender, requestId, _amount, queued);
}
// slither-disable-start reentrancy-no-eth
/**
* @notice Claim a previously requested withdrawal once it is claimable.
* This request can be claimed once the withdrawal queue's `claimable` amount
* is greater than or equal this request's `queued` amount and 10 minutes has passed.
* If the requests is not claimable, the transaction will revert with `Queue pending liquidity`.
* If the request is not older than 10 minutes, the transaction will revert with `Claim delay not met`.
* OETH is converted to WETH at 1:1.
* @param _requestId Unique ID for the withdrawal request
* @return amount Amount of WETH transferred to the withdrawer
*/
function claimWithdrawal(uint256 _requestId)
external
virtual
whenNotCapitalPaused
nonReentrant
returns (uint256 amount)
{
// Try and get more liquidity if there is not enough available
if (
withdrawalRequests[_requestId].queued >
withdrawalQueueMetadata.claimable
) {
// Add any WETH to the withdrawal queue
// this needs to remain here as:
// - Vault can be funded and `addWithdrawalQueueLiquidity` is not externally called
// - funds can be withdrawn from a strategy
//
// Those funds need to be added to withdrawal queue liquidity
_addWithdrawalQueueLiquidity();
}
amount = _claimWithdrawal(_requestId);
// transfer WETH from the vault to the withdrawer
IERC20(weth).safeTransfer(msg.sender, amount);
// Prevent insolvency
_postRedeem(amount);
}
// slither-disable-end reentrancy-no-eth
/**
* @notice Claim a previously requested withdrawals once they are claimable.
* This requests can be claimed once the withdrawal queue's `claimable` amount
* is greater than or equal each request's `queued` amount and 10 minutes has passed.
* If one of the requests is not claimable, the whole transaction will revert with `Queue pending liquidity`.
* If one of the requests is not older than 10 minutes,
* the whole transaction will revert with `Claim delay not met`.
* @param _requestIds Unique ID of each withdrawal request
* @return amounts Amount of WETH received for each request
* @return totalAmount Total amount of WETH transferred to the withdrawer
*/
function claimWithdrawals(uint256[] calldata _requestIds)
external
virtual
whenNotCapitalPaused
nonReentrant
returns (uint256[] memory amounts, uint256 totalAmount)
{
// Add any WETH to the withdrawal queue
// this needs to remain here as:
// - Vault can be funded and `addWithdrawalQueueLiquidity` is not externally called
// - funds can be withdrawn from a strategy
//
// Those funds need to be added to withdrawal queue liquidity
_addWithdrawalQueueLiquidity();
amounts = new uint256[](_requestIds.length);
for (uint256 i; i < _requestIds.length; ++i) {
amounts[i] = _claimWithdrawal(_requestIds[i]);
totalAmount += amounts[i];
}
// transfer all the claimed WETH from the vault to the withdrawer
IERC20(weth).safeTransfer(msg.sender, totalAmount);
// Prevent insolvency
_postRedeem(totalAmount);
}
function _claimWithdrawal(uint256 requestId)
internal
returns (uint256 amount)
{
require(withdrawalClaimDelay > 0, "Async withdrawals not enabled");
// Load the structs from storage into memory
WithdrawalRequest memory request = withdrawalRequests[requestId];
WithdrawalQueueMetadata memory queue = withdrawalQueueMetadata;
require(
request.timestamp + withdrawalClaimDelay <= block.timestamp,
"Claim delay not met"
);
// If there isn't enough reserved liquidity in the queue to claim
require(request.queued <= queue.claimable, "Queue pending liquidity");
require(request.withdrawer == msg.sender, "Not requester");
require(request.claimed == false, "Already claimed");
// Store the request as claimed
withdrawalRequests[requestId].claimed = true;
// Store the updated claimed amount
withdrawalQueueMetadata.claimed = queue.claimed + request.amount;
emit WithdrawalClaimed(msg.sender, requestId, request.amount);
return request.amount;
}
/// @notice Adds WETH to the withdrawal queue if there is a funding shortfall.
/// @dev is called from the Native Staking strategy when validator withdrawals are processed.
/// It also called before any WETH is allocated to a strategy.
function addWithdrawalQueueLiquidity() external {
_addWithdrawalQueueLiquidity();
}
/// @dev Adds WETH to the withdrawal queue if there is a funding shortfall.
/// This assumes 1 WETH equal 1 OETH.
function _addWithdrawalQueueLiquidity()
internal
returns (uint256 addedClaimable)
{
WithdrawalQueueMetadata memory queue = withdrawalQueueMetadata;
// Check if the claimable WETH is less than the queued amount
uint256 queueShortfall = queue.queued - queue.claimable;
// No need to do anything is the withdrawal queue is full funded
if (queueShortfall == 0) {
return 0;
}
uint256 wethBalance = IERC20(weth).balanceOf(address(this));
// Of the claimable withdrawal requests, how much is unclaimed?
// That is, the amount of WETH that is currently allocated for the withdrawal queue
uint256 allocatedWeth = queue.claimable - queue.claimed;
// If there is no unallocated WETH then there is nothing to add to the queue
if (wethBalance <= allocatedWeth) {
return 0;
}
uint256 unallocatedWeth = wethBalance - allocatedWeth;
// the new claimable amount is the smaller of the queue shortfall or unallocated weth
addedClaimable = queueShortfall < unallocatedWeth
? queueShortfall
: unallocatedWeth;
uint256 newClaimable = queue.claimable + addedClaimable;
// Store the new claimable amount back to storage
withdrawalQueueMetadata.claimable = SafeCast.toUint128(newClaimable);
// emit a WithdrawalClaimable event
emit WithdrawalClaimable(newClaimable, addedClaimable);
}
/***************************************
View Functions
****************************************/
/// @dev Calculate how much WETH in the vault is not reserved for the withdrawal queue.
// That is, it is available to be redeemed or deposited into a strategy.
function _wethAvailable() internal view returns (uint256 wethAvailable) {
WithdrawalQueueMetadata memory queue = withdrawalQueueMetadata;
// The amount of WETH that is still to be claimed in the withdrawal queue
uint256 outstandingWithdrawals = queue.queued - queue.claimed;
// The amount of sitting in WETH in the vault
uint256 wethBalance = IERC20(weth).balanceOf(address(this));
// If there is not enough WETH in the vault to cover the outstanding withdrawals
if (wethBalance <= outstandingWithdrawals) {
return 0;
}
return wethBalance - outstandingWithdrawals;
}
/// @dev Get the balance of an asset held in Vault and all strategies
/// less any WETH that is reserved for the withdrawal queue.
/// WETH is the only asset that can return a non-zero balance.
/// All other assets will return 0 even if there is some dust amounts left in the Vault.
/// For example, there is 1 wei left of stETH in the OETH Vault but will return 0 in this function.
///
/// If there is not enough WETH in the vault and all strategies to cover all outstanding
/// withdrawal requests then return a WETH balance of 0
function _checkBalance(address _asset)
internal
view
override
returns (uint256 balance)
{
if (_asset != weth) {
return 0;
}
// Get the WETH in the vault and the strategies
balance = super._checkBalance(_asset);
WithdrawalQueueMetadata memory queue = withdrawalQueueMetadata;
// If the vault becomes insolvent enough that the total value in the vault and all strategies
// is less than the outstanding withdrawals.
// For example, there was a mass slashing event and most users request a withdrawal.
if (balance + queue.claimed < queue.queued) {
return 0;
}
// Need to remove WETH that is reserved for the withdrawal queue
return balance + queue.claimed - queue.queued;
}
/**
* @notice Allocate unallocated funds on Vault to strategies.
**/
function allocate() external override whenNotCapitalPaused nonReentrant {
// Add any unallocated WETH to the withdrawal queue first
_addWithdrawalQueueLiquidity();
_allocate();
}
/// @dev Allocate WETH to the default WETH strategy if there is excess to the Vault buffer.
/// This is called from either `mint` or `allocate` and assumes `_addWithdrawalQueueLiquidity`
/// has been called before this function.
function _allocate() internal override {
// No need to do anything if no default strategy for WETH
address depositStrategyAddr = assetDefaultStrategies[weth];
if (depositStrategyAddr == address(0)) return;
uint256 wethAvailableInVault = _wethAvailable();
// No need to do anything if there isn't any WETH in the vault to allocate
if (wethAvailableInVault == 0) return;
// Calculate the target buffer for the vault using the total supply
uint256 totalSupply = oUSD.totalSupply();
uint256 targetBuffer = totalSupply.mulTruncate(vaultBuffer);
// If available WETH in the Vault is below or equal the target buffer then there's nothing to allocate
if (wethAvailableInVault <= targetBuffer) return;
// The amount of assets to allocate to the default strategy
uint256 allocateAmount = wethAvailableInVault - targetBuffer;
IStrategy strategy = IStrategy(depositStrategyAddr);
// Transfer WETH to the strategy and call the strategy's deposit function
IERC20(weth).safeTransfer(address(strategy), allocateAmount);
strategy.deposit(weth, allocateAmount);
emit AssetAllocated(weth, depositStrategyAddr, allocateAmount);
}
/// @dev The total value of all WETH held by the vault and all its strategies
/// less any WETH that is reserved for the withdrawal queue.
///
// If there is not enough WETH in the vault and all strategies to cover all outstanding
// withdrawal requests then return a total value of 0.
function _totalValue() internal view override returns (uint256 value) {
// As WETH is the only asset, just return the WETH balance
return _checkBalance(weth);
}
/// @dev Only WETH is supported in the OETH Vault so return the WETH balance only
/// Any ETH balances in the Vault will be ignored.
/// Amounts from previously supported vault assets will also be ignored.
/// For example, there is 1 wei left of stETH in the OETH Vault but is will be ignored.
function _totalValueInVault()
internal
view
override
returns (uint256 value)
{
value = IERC20(weth).balanceOf(address(this));
}
}// SPDX-License-Identifier: BUSL-1.1
pragma solidity ^0.8.0;
/**
* @title OToken VaultCore contract
* @notice The Vault contract stores assets. On a deposit, OTokens will be minted
and sent to the depositor. On a withdrawal, OTokens will be burned and
assets will be sent to the withdrawer. The Vault accepts deposits of
interest from yield bearing strategies which will modify the supply
of OTokens.
* @author Origin Protocol Inc
*/
import { SafeERC20 } from "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
import { StableMath } from "../utils/StableMath.sol";
import { IOracle } from "../interfaces/IOracle.sol";
import { IGetExchangeRateToken } from "../interfaces/IGetExchangeRateToken.sol";
import "./VaultInitializer.sol";
contract VaultCore is VaultInitializer {
using SafeERC20 for IERC20;
using StableMath for uint256;
/// @dev max signed int
uint256 internal constant MAX_INT = uint256(type(int256).max);
/**
* @dev Verifies that the rebasing is not paused.
*/
modifier whenNotRebasePaused() {
require(!rebasePaused, "Rebasing paused");
_;
}
/**
* @dev Verifies that the deposits are not paused.
*/
modifier whenNotCapitalPaused() {
require(!capitalPaused, "Capital paused");
_;
}
/**
* @dev Verifies that the caller is the AMO strategy.
*/
modifier onlyOusdMetaStrategy() {
require(
msg.sender == ousdMetaStrategy,
"Caller is not the OUSD meta strategy"
);
_;
}
/**
* @notice Deposit a supported asset and mint OTokens.
* @param _asset Address of the asset being deposited
* @param _amount Amount of the asset being deposited
* @param _minimumOusdAmount Minimum OTokens to mint
*/
function mint(
address _asset,
uint256 _amount,
uint256 _minimumOusdAmount
) external whenNotCapitalPaused nonReentrant {
_mint(_asset, _amount, _minimumOusdAmount);
}
/**
* @dev Deposit a supported asset and mint OTokens.
* @param _asset Address of the asset being deposited
* @param _amount Amount of the asset being deposited
* @param _minimumOusdAmount Minimum OTokens to mint
*/
function _mint(
address _asset,
uint256 _amount,
uint256 _minimumOusdAmount
) internal virtual {
require(assets[_asset].isSupported, "Asset is not supported");
require(_amount > 0, "Amount must be greater than 0");
uint256 units = _toUnits(_amount, _asset);
uint256 unitPrice = _toUnitPrice(_asset, true);
uint256 priceAdjustedDeposit = (units * unitPrice) / 1e18;
if (_minimumOusdAmount > 0) {
require(
priceAdjustedDeposit >= _minimumOusdAmount,
"Mint amount lower than minimum"
);
}
emit Mint(msg.sender, priceAdjustedDeposit);
// Rebase must happen before any transfers occur.
if (priceAdjustedDeposit >= rebaseThreshold && !rebasePaused) {
_rebase();
}
// Mint matching amount of OTokens
oUSD.mint(msg.sender, priceAdjustedDeposit);
// Transfer the deposited coins to the vault
IERC20 asset = IERC20(_asset);
asset.safeTransferFrom(msg.sender, address(this), _amount);
if (priceAdjustedDeposit >= autoAllocateThreshold) {
_allocate();
}
}
/**
* @notice Mint OTokens for a Metapool Strategy
* @param _amount Amount of the asset being deposited
*
* Notice: can't use `nonReentrant` modifier since the `mint` function can
* call `allocate`, and that can trigger `ConvexOUSDMetaStrategy` to call this function
* while the execution of the `mint` has not yet completed -> causing a `nonReentrant` collision.
*
* Also important to understand is that this is a limitation imposed by the test suite.
* Production / mainnet contracts should never be configured in a way where mint/redeem functions
* that are moving funds between the Vault and end user wallets can influence strategies
* utilizing this function.
*/
function mintForStrategy(uint256 _amount)
external
virtual
whenNotCapitalPaused
onlyOusdMetaStrategy
{
require(_amount < MAX_INT, "Amount too high");
emit Mint(msg.sender, _amount);
// safe to cast because of the require check at the beginning of the function
netOusdMintedForStrategy += int256(_amount);
require(
abs(netOusdMintedForStrategy) < netOusdMintForStrategyThreshold,
"Minted ousd surpassed netOusdMintForStrategyThreshold."
);
// Mint matching amount of OTokens
oUSD.mint(msg.sender, _amount);
}
// In memoriam
/**
* @notice Withdraw a supported asset and burn OTokens.
* @param _amount Amount of OTokens to burn
* @param _minimumUnitAmount Minimum stablecoin units to receive in return
*/
function redeem(uint256 _amount, uint256 _minimumUnitAmount)
external
whenNotCapitalPaused
nonReentrant
{
_redeem(_amount, _minimumUnitAmount);
}
/**
* @notice Withdraw a supported asset and burn OTokens.
* @param _amount Amount of OTokens to burn
* @param _minimumUnitAmount Minimum stablecoin units to receive in return
*/
function _redeem(uint256 _amount, uint256 _minimumUnitAmount)
internal
virtual
{
// Calculate redemption outputs
uint256[] memory outputs = _calculateRedeemOutputs(_amount);
emit Redeem(msg.sender, _amount);
// Send outputs
uint256 assetCount = allAssets.length;
for (uint256 i = 0; i < assetCount; ++i) {
if (outputs[i] == 0) continue;
address assetAddr = allAssets[i];
if (IERC20(assetAddr).balanceOf(address(this)) >= outputs[i]) {
// Use Vault funds first if sufficient
IERC20(assetAddr).safeTransfer(msg.sender, outputs[i]);
} else {
address strategyAddr = assetDefaultStrategies[assetAddr];
if (strategyAddr != address(0)) {
// Nothing in Vault, but something in Strategy, send from there
IStrategy strategy = IStrategy(strategyAddr);
strategy.withdraw(msg.sender, assetAddr, outputs[i]);
} else {
// Cant find funds anywhere
revert("Liquidity error");
}
}
}
if (_minimumUnitAmount > 0) {
uint256 unitTotal = 0;
for (uint256 i = 0; i < outputs.length; ++i) {
unitTotal += _toUnits(outputs[i], allAssets[i]);
}
require(
unitTotal >= _minimumUnitAmount,
"Redeem amount lower than minimum"
);
}
oUSD.burn(msg.sender, _amount);
_postRedeem(_amount);
}
function _postRedeem(uint256 _amount) internal {
// Until we can prove that we won't affect the prices of our assets
// by withdrawing them, this should be here.
// It's possible that a strategy was off on its asset total, perhaps
// a reward token sold for more or for less than anticipated.
uint256 totalUnits = 0;
if (_amount >= rebaseThreshold && !rebasePaused) {
totalUnits = _rebase();
} else {
totalUnits = _totalValue();
}
// Check that the OTokens are backed by enough assets
if (maxSupplyDiff > 0) {
// If there are more outstanding withdrawal requests than assets in the vault and strategies
// then the available assets will be negative and totalUnits will be rounded up to zero.
// As we don't know the exact shortfall amount, we will reject all redeem and withdrawals
require(totalUnits > 0, "Too many outstanding requests");
// Allow a max difference of maxSupplyDiff% between
// backing assets value and OUSD total supply
uint256 diff = oUSD.totalSupply().divPrecisely(totalUnits);
require(
(diff > 1e18 ? diff - 1e18 : 1e18 - diff) <= maxSupplyDiff,
"Backing supply liquidity error"
);
}
}
/**
* @notice Burn OTokens for Metapool Strategy
* @param _amount Amount of OUSD to burn
*
* @dev Notice: can't use `nonReentrant` modifier since the `redeem` function could
* require withdrawal on `ConvexOUSDMetaStrategy` and that one can call `burnForStrategy`
* while the execution of the `redeem` has not yet completed -> causing a `nonReentrant` collision.
*
* Also important to understand is that this is a limitation imposed by the test suite.
* Production / mainnet contracts should never be configured in a way where mint/redeem functions
* that are moving funds between the Vault and end user wallets can influence strategies
* utilizing this function.
*/
function burnForStrategy(uint256 _amount)
external
virtual
whenNotCapitalPaused
onlyOusdMetaStrategy
{
require(_amount < MAX_INT, "Amount too high");
emit Redeem(msg.sender, _amount);
// safe to cast because of the require check at the beginning of the function
netOusdMintedForStrategy -= int256(_amount);
require(
abs(netOusdMintedForStrategy) < netOusdMintForStrategyThreshold,
"Attempting to burn too much OUSD."
);
// Burn OTokens
oUSD.burn(msg.sender, _amount);
}
/**
* @notice Allocate unallocated funds on Vault to strategies.
**/
function allocate() external virtual whenNotCapitalPaused nonReentrant {
_allocate();
}
/**
* @dev Allocate unallocated funds on Vault to strategies.
**/
function _allocate() internal virtual {
uint256 vaultValue = _totalValueInVault();
// Nothing in vault to allocate
if (vaultValue == 0) return;
uint256 strategiesValue = _totalValueInStrategies();
// We have a method that does the same as this, gas optimisation
uint256 calculatedTotalValue = vaultValue + strategiesValue;
// We want to maintain a buffer on the Vault so calculate a percentage
// modifier to multiply each amount being allocated by to enforce the
// vault buffer
uint256 vaultBufferModifier;
if (strategiesValue == 0) {
// Nothing in Strategies, allocate 100% minus the vault buffer to
// strategies
vaultBufferModifier = uint256(1e18) - vaultBuffer;
} else {
vaultBufferModifier =
(vaultBuffer * calculatedTotalValue) /
vaultValue;
if (1e18 > vaultBufferModifier) {
// E.g. 1e18 - (1e17 * 10e18)/5e18 = 8e17
// (5e18 * 8e17) / 1e18 = 4e18 allocated from Vault
vaultBufferModifier = uint256(1e18) - vaultBufferModifier;
} else {
// We need to let the buffer fill
return;
}
}
if (vaultBufferModifier == 0) return;
// Iterate over all assets in the Vault and allocate to the appropriate
// strategy
uint256 assetCount = allAssets.length;
for (uint256 i = 0; i < assetCount; ++i) {
IERC20 asset = IERC20(allAssets[i]);
uint256 assetBalance = asset.balanceOf(address(this));
// No balance, nothing to do here
if (assetBalance == 0) continue;
// Multiply the balance by the vault buffer modifier and truncate
// to the scale of the asset decimals
uint256 allocateAmount = assetBalance.mulTruncate(
vaultBufferModifier
);
address depositStrategyAddr = assetDefaultStrategies[
address(asset)
];
if (depositStrategyAddr != address(0) && allocateAmount > 0) {
IStrategy strategy = IStrategy(depositStrategyAddr);
// Transfer asset to Strategy and call deposit method to
// mint or take required action
asset.safeTransfer(address(strategy), allocateAmount);
strategy.deposit(address(asset), allocateAmount);
emit AssetAllocated(
address(asset),
depositStrategyAddr,
allocateAmount
);
}
}
}
/**
* @notice Calculate the total value of assets held by the Vault and all
* strategies and update the supply of OTokens.
*/
function rebase() external virtual nonReentrant {
_rebase();
}
/**
* @dev Calculate the total value of assets held by the Vault and all
* strategies and update the supply of OTokens, optionally sending a
* portion of the yield to the trustee.
* @return totalUnits Total balance of Vault in units
*/
function _rebase() internal whenNotRebasePaused returns (uint256) {
uint256 supply = oUSD.totalSupply();
uint256 vaultValue = _totalValue();
// If no supply yet, do not rebase
if (supply == 0) {
return vaultValue;
}
// Calculate yield and new supply
(uint256 yield, uint256 targetRate) = _nextYield(supply, vaultValue);
uint256 newSupply = supply + yield;
// Only rebase upwards and if we have enough backing funds
if (newSupply <= supply || newSupply > vaultValue) {
return vaultValue;
}
rebasePerSecondTarget = uint64(_min(targetRate, type(uint64).max));
lastRebase = uint64(block.timestamp); // Intentional cast
// Fee collection on yield
address _trusteeAddress = trusteeAddress; // gas savings
uint256 fee = 0;
if (_trusteeAddress != address(0)) {
fee = (yield * trusteeFeeBps) / 1e4;
if (fee > 0) {
require(fee < yield, "Fee must not be greater than yield");
oUSD.mint(_trusteeAddress, fee);
}
}
emit YieldDistribution(_trusteeAddress, yield, fee);
// Only ratchet OToken supply upwards
// Final check uses latest totalSupply
if (newSupply > oUSD.totalSupply()) {
oUSD.changeSupply(newSupply);
}
return vaultValue;
}
/**
* @notice Calculates the amount that would rebase at next rebase.
* This is before any fees.
* @return yield amount of expected yield
*/
function previewYield() external view returns (uint256 yield) {
(yield, ) = _nextYield(oUSD.totalSupply(), _totalValue());
return yield;
}
function _nextYield(uint256 supply, uint256 vaultValue)
internal
view
virtual
returns (uint256 yield, uint256 targetRate)
{
uint256 nonRebasing = oUSD.nonRebasingSupply();
uint256 rebasing = supply - nonRebasing;
uint256 elapsed = block.timestamp - lastRebase;
targetRate = rebasePerSecondTarget;
if (
elapsed == 0 || // Yield only once per block.
rebasing == 0 || // No yield if there are no rebasing tokens to give it to.
supply > vaultValue || // No yield if we do not have yield to give.
block.timestamp >= type(uint64).max // No yield if we are too far in the future to calculate it correctly.
) {
return (0, targetRate);
}
// Start with the full difference available
yield = vaultValue - supply;
// Cap via optional automatic duration smoothing
uint256 _dripDuration = dripDuration;
if (_dripDuration > 1) {
// If we are able to sustain an increased drip rate for
// double the duration, then increase the target drip rate
targetRate = _max(targetRate, yield / (_dripDuration * 2));
// If we cannot sustain the target rate any more,
// then rebase what we can, and reduce the target
targetRate = _min(targetRate, yield / _dripDuration);
// drip at the new target rate
yield = _min(yield, targetRate * elapsed);
}
// Cap per second. elapsed is not 1e18 denominated
yield = _min(yield, (rebasing * elapsed * rebasePerSecondMax) / 1e18);
// Cap at a hard max per rebase, to avoid long durations resulting in huge rebases
yield = _min(yield, (rebasing * MAX_REBASE) / 1e18);
return (yield, targetRate);
}
/**
* @notice Determine the total value of assets held by the vault and its
* strategies.
* @return value Total value in USD/ETH (1e18)
*/
function totalValue() external view virtual returns (uint256 value) {
value = _totalValue();
}
/**
* @dev Internal Calculate the total value of the assets held by the
* vault and its strategies.
* @return value Total value in USD/ETH (1e18)
*/
function _totalValue() internal view virtual returns (uint256 value) {
return _totalValueInVault() + _totalValueInStrategies();
}
/**
* @dev Internal to calculate total value of all assets held in Vault.
* @return value Total value in USD/ETH (1e18)
*/
function _totalValueInVault()
internal
view
virtual
returns (uint256 value)
{
uint256 assetCount = allAssets.length;
for (uint256 y; y < assetCount; ++y) {
address assetAddr = allAssets[y];
uint256 balance = IERC20(assetAddr).balanceOf(address(this));
if (balance > 0) {
value += _toUnits(balance, assetAddr);
}
}
}
/**
* @dev Internal to calculate total value of all assets held in Strategies.
* @return value Total value in USD/ETH (1e18)
*/
function _totalValueInStrategies() internal view returns (uint256 value) {
uint256 stratCount = allStrategies.length;
for (uint256 i = 0; i < stratCount; ++i) {
value = value + _totalValueInStrategy(allStrategies[i]);
}
}
/**
* @dev Internal to calculate total value of all assets held by strategy.
* @param _strategyAddr Address of the strategy
* @return value Total value in USD/ETH (1e18)
*/
function _totalValueInStrategy(address _strategyAddr)
internal
view
returns (uint256 value)
{
IStrategy strategy = IStrategy(_strategyAddr);
uint256 assetCount = allAssets.length;
for (uint256 y; y < assetCount; ++y) {
address assetAddr = allAssets[y];
if (strategy.supportsAsset(assetAddr)) {
uint256 balance = strategy.checkBalance(assetAddr);
if (balance > 0) {
value += _toUnits(balance, assetAddr);
}
}
}
}
/**
* @notice Get the balance of an asset held in Vault and all strategies.
* @param _asset Address of asset
* @return uint256 Balance of asset in decimals of asset
*/
function checkBalance(address _asset) external view returns (uint256) {
return _checkBalance(_asset);
}
/**
* @notice Get the balance of an asset held in Vault and all strategies.
* @param _asset Address of asset
* @return balance Balance of asset in decimals of asset
*/
function _checkBalance(address _asset)
internal
view
virtual
returns (uint256 balance)
{
IERC20 asset = IERC20(_asset);
balance = asset.balanceOf(address(this));
uint256 stratCount = allStrategies.length;
for (uint256 i = 0; i < stratCount; ++i) {
IStrategy strategy = IStrategy(allStrategies[i]);
if (strategy.supportsAsset(_asset)) {
balance = balance + strategy.checkBalance(_asset);
}
}
}
/**
* @notice Calculate the outputs for a redeem function, i.e. the mix of
* coins that will be returned
*/
function calculateRedeemOutputs(uint256 _amount)
external
view
returns (uint256[] memory)
{
return _calculateRedeemOutputs(_amount);
}
/**
* @dev Calculate the outputs for a redeem function, i.e. the mix of
* coins that will be returned.
* @return outputs Array of amounts respective to the supported assets
*/
function _calculateRedeemOutputs(uint256 _amount)
internal
view
virtual
returns (uint256[] memory outputs)
{
// We always give out coins in proportion to how many we have,
// Now if all coins were the same value, this math would easy,
// just take the percentage of each coin, and multiply by the
// value to be given out. But if coins are worth more than $1,
// then we would end up handing out too many coins. We need to
// adjust by the total value of coins.
//
// To do this, we total up the value of our coins, by their
// percentages. Then divide what we would otherwise give out by
// this number.
//
// Let say we have 100 DAI at $1.06 and 200 USDT at $1.00.
// So for every 1 DAI we give out, we'll be handing out 2 USDT
// Our total output ratio is: 33% * 1.06 + 66% * 1.00 = 1.02
//
// So when calculating the output, we take the percentage of
// each coin, times the desired output value, divided by the
// totalOutputRatio.
//
// For example, withdrawing: 30 OUSD:
// DAI 33% * 30 / 1.02 = 9.80 DAI
// USDT = 66 % * 30 / 1.02 = 19.60 USDT
//
// Checking these numbers:
// 9.80 DAI * 1.06 = $10.40
// 19.60 USDT * 1.00 = $19.60
//
// And so the user gets $10.40 + $19.60 = $30 worth of value.
uint256 assetCount = allAssets.length;
uint256[] memory assetUnits = new uint256[](assetCount);
uint256[] memory assetBalances = new uint256[](assetCount);
outputs = new uint256[](assetCount);
// Calculate redeem fee
if (redeemFeeBps > 0) {
uint256 redeemFee = _amount.mulTruncateScale(redeemFeeBps, 1e4);
_amount = _amount - redeemFee;
}
// Calculate assets balances and decimals once,
// for a large gas savings.
uint256 totalUnits = 0;
for (uint256 i = 0; i < assetCount; ++i) {
address assetAddr = allAssets[i];
uint256 balance = _checkBalance(assetAddr);
assetBalances[i] = balance;
assetUnits[i] = _toUnits(balance, assetAddr);
totalUnits = totalUnits + assetUnits[i];
}
// Calculate totalOutputRatio
uint256 totalOutputRatio = 0;
for (uint256 i = 0; i < assetCount; ++i) {
uint256 unitPrice = _toUnitPrice(allAssets[i], false);
uint256 ratio = (assetUnits[i] * unitPrice) / totalUnits;
totalOutputRatio = totalOutputRatio + ratio;
}
// Calculate final outputs
uint256 factor = _amount.divPrecisely(totalOutputRatio);
for (uint256 i = 0; i < assetCount; ++i) {
outputs[i] = (assetBalances[i] * factor) / totalUnits;
}
}
/***************************************
Pricing
****************************************/
/**
* @notice Returns the total price in 18 digit units for a given asset.
* Never goes above 1, since that is how we price mints.
* @param asset address of the asset
* @return price uint256: unit (USD / ETH) price for 1 unit of the asset, in 18 decimal fixed
*/
function priceUnitMint(address asset)
external
view
returns (uint256 price)
{
/* need to supply 1 asset unit in asset's decimals and can not just hard-code
* to 1e18 and ignore calling `_toUnits` since we need to consider assets
* with the exchange rate
*/
uint256 units = _toUnits(
uint256(1e18).scaleBy(_getDecimals(asset), 18),
asset
);
price = (_toUnitPrice(asset, true) * units) / 1e18;
}
/**
* @notice Returns the total price in 18 digit unit for a given asset.
* Never goes below 1, since that is how we price redeems
* @param asset Address of the asset
* @return price uint256: unit (USD / ETH) price for 1 unit of the asset, in 18 decimal fixed
*/
function priceUnitRedeem(address asset)
external
view
returns (uint256 price)
{
/* need to supply 1 asset unit in asset's decimals and can not just hard-code
* to 1e18 and ignore calling `_toUnits` since we need to consider assets
* with the exchange rate
*/
uint256 units = _toUnits(
uint256(1e18).scaleBy(_getDecimals(asset), 18),
asset
);
price = (_toUnitPrice(asset, false) * units) / 1e18;
}
/***************************************
Utils
****************************************/
/**
* @dev Convert a quantity of a token into 1e18 fixed decimal "units"
* in the underlying base (USD/ETH) used by the vault.
* Price is not taken into account, only quantity.
*
* Examples of this conversion:
*
* - 1e18 DAI becomes 1e18 units (same decimals)
* - 1e6 USDC becomes 1e18 units (decimal conversion)
* - 1e18 rETH becomes 1.2e18 units (exchange rate conversion)
*
* @param _raw Quantity of asset
* @param _asset Core Asset address
* @return value 1e18 normalized quantity of units
*/
function _toUnits(uint256 _raw, address _asset)
internal
view
returns (uint256)
{
UnitConversion conversion = assets[_asset].unitConversion;
if (conversion == UnitConversion.DECIMALS) {
return _raw.scaleBy(18, _getDecimals(_asset));
} else if (conversion == UnitConversion.GETEXCHANGERATE) {
uint256 exchangeRate = IGetExchangeRateToken(_asset)
.getExchangeRate();
return (_raw * exchangeRate) / 1e18;
} else {
revert("Unsupported conversion type");
}
}
/**
* @dev Returns asset's unit price accounting for different asset types
* and takes into account the context in which that price exists -
* - mint or redeem.
*
* Note: since we are returning the price of the unit and not the one of the
* asset (see comment above how 1 rETH exchanges for 1.2 units) we need
* to make the Oracle price adjustment as well since we are pricing the
* units and not the assets.
*
* The price also snaps to a "full unit price" in case a mint or redeem
* action would be unfavourable to the protocol.
*
*/
function _toUnitPrice(address _asset, bool isMint)
internal
view
returns (uint256 price)
{
UnitConversion conversion = assets[_asset].unitConversion;
price = IOracle(priceProvider).price(_asset);
if (conversion == UnitConversion.GETEXCHANGERATE) {
uint256 exchangeRate = IGetExchangeRateToken(_asset)
.getExchangeRate();
price = (price * 1e18) / exchangeRate;
} else if (conversion != UnitConversion.DECIMALS) {
revert("Unsupported conversion type");
}
/* At this stage the price is already adjusted to the unit
* so the price checks are agnostic to underlying asset being
* pegged to a USD or to an ETH or having a custom exchange rate.
*/
require(price <= MAX_UNIT_PRICE_DRIFT, "Vault: Price exceeds max");
require(price >= MIN_UNIT_PRICE_DRIFT, "Vault: Price under min");
if (isMint) {
/* Never price a normalized unit price for more than one
* unit of OETH/OUSD when minting.
*/
if (price > 1e18) {
price = 1e18;
}
require(price >= MINT_MINIMUM_UNIT_PRICE, "Asset price below peg");
} else {
/* Never give out more than 1 normalized unit amount of assets
* for one unit of OETH/OUSD when redeeming.
*/
if (price < 1e18) {
price = 1e18;
}
}
}
/**
* @dev Get the number of decimals of a token asset
* @param _asset Address of the asset
* @return decimals number of decimals
*/
function _getDecimals(address _asset)
internal
view
returns (uint256 decimals)
{
decimals = assets[_asset].decimals;
require(decimals > 0, "Decimals not cached");
}
/**
* @notice Return the number of assets supported by the Vault.
*/
function getAssetCount() public view returns (uint256) {
return allAssets.length;
}
/**
* @notice Gets the vault configuration of a supported asset.
* @param _asset Address of the token asset
*/
function getAssetConfig(address _asset)
public
view
returns (Asset memory config)
{
config = assets[_asset];
}
/**
* @notice Return all vault asset addresses in order
*/
function getAllAssets() external view returns (address[] memory) {
return allAssets;
}
/**
* @notice Return the number of strategies active on the Vault.
*/
function getStrategyCount() external view returns (uint256) {
return allStrategies.length;
}
/**
* @notice Return the array of all strategies
*/
function getAllStrategies() external view returns (address[] memory) {
return allStrategies;
}
/**
* @notice Returns whether the vault supports the asset
* @param _asset address of the asset
* @return true if supported
*/
function isSupportedAsset(address _asset) external view returns (bool) {
return assets[_asset].isSupported;
}
function ADMIN_IMPLEMENTATION() external view returns (address adminImpl) {
bytes32 slot = adminImplPosition;
// solhint-disable-next-line no-inline-assembly
assembly {
adminImpl := sload(slot)
}
}
/**
* @dev Falldown to the admin implementation
* @notice This is a catch all for all functions not declared in core
*/
// solhint-disable-next-line no-complex-fallback
fallback() external {
bytes32 slot = adminImplPosition;
// solhint-disable-next-line no-inline-assembly
assembly {
// Copy msg.data. We take full control of memory in this inline assembly
// block because it will not return to Solidity code. We overwrite the
// Solidity scratch pad at memory position 0.
calldatacopy(0, 0, calldatasize())
// Call the implementation.
// out and outsize are 0 because we don't know the size yet.
let result := delegatecall(
gas(),
sload(slot),
0,
calldatasize(),
0,
0
)
// Copy the returned data.
returndatacopy(0, 0, returndatasize())
switch result
// delegatecall returns 0 on error.
case 0 {
revert(0, returndatasize())
}
default {
return(0, returndatasize())
}
}
}
function abs(int256 x) private pure returns (uint256) {
require(x < int256(MAX_INT), "Amount too high");
return x >= 0 ? uint256(x) : uint256(-x);
}
function _min(uint256 a, uint256 b) internal pure returns (uint256) {
return a < b ? a : b;
}
function _max(uint256 a, uint256 b) internal pure returns (uint256) {
return a > b ? a : b;
}
}// SPDX-License-Identifier: BUSL-1.1
pragma solidity ^0.8.0;
/**
* @title OToken VaultInitializer contract
* @notice The Vault contract initializes the vault.
* @author Origin Protocol Inc
*/
import "./VaultStorage.sol";
contract VaultInitializer is VaultStorage {
function initialize(address _priceProvider, address _oToken)
external
onlyGovernor
initializer
{
require(_priceProvider != address(0), "PriceProvider address is zero");
require(_oToken != address(0), "oToken address is zero");
oUSD = OUSD(_oToken);
priceProvider = _priceProvider;
rebasePaused = false;
capitalPaused = true;
// Initial redeem fee of 0 basis points
redeemFeeBps = 0;
// Initial Vault buffer of 0%
vaultBuffer = 0;
// Initial allocate threshold of 25,000 OUSD
autoAllocateThreshold = 25000e18;
// Threshold for rebasing
rebaseThreshold = 1000e18;
// Initialize all strategies
allStrategies = new address[](0);
// Start with drip duration disabled
dripDuration = 1;
}
}// SPDX-License-Identifier: BUSL-1.1
pragma solidity ^0.8.0;
/**
* @title OToken VaultStorage contract
* @notice The VaultStorage contract defines the storage for the Vault contracts
* @author Origin Protocol Inc
*/
import { IERC20 } from "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import { SafeERC20 } from "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
import { Address } from "@openzeppelin/contracts/utils/Address.sol";
import { IStrategy } from "../interfaces/IStrategy.sol";
import { Governable } from "../governance/Governable.sol";
import { OUSD } from "../token/OUSD.sol";
import { Initializable } from "../utils/Initializable.sol";
import "../utils/Helpers.sol";
contract VaultStorage is Initializable, Governable {
using SafeERC20 for IERC20;
event AssetSupported(address _asset);
event AssetRemoved(address _asset);
event AssetDefaultStrategyUpdated(address _asset, address _strategy);
event AssetAllocated(address _asset, address _strategy, uint256 _amount);
event StrategyApproved(address _addr);
event StrategyRemoved(address _addr);
event Mint(address _addr, uint256 _value);
event Redeem(address _addr, uint256 _value);
event CapitalPaused();
event CapitalUnpaused();
event RebasePaused();
event RebaseUnpaused();
event VaultBufferUpdated(uint256 _vaultBuffer);
event OusdMetaStrategyUpdated(address _ousdMetaStrategy);
event RedeemFeeUpdated(uint256 _redeemFeeBps);
event PriceProviderUpdated(address _priceProvider);
event AllocateThresholdUpdated(uint256 _threshold);
event RebaseThresholdUpdated(uint256 _threshold);
event StrategistUpdated(address _address);
event MaxSupplyDiffChanged(uint256 maxSupplyDiff);
event YieldDistribution(address _to, uint256 _yield, uint256 _fee);
event TrusteeFeeBpsChanged(uint256 _basis);
event TrusteeAddressChanged(address _address);
event NetOusdMintForStrategyThresholdChanged(uint256 _threshold);
event SwapperChanged(address _address);
event SwapAllowedUndervalueChanged(uint256 _basis);
event SwapSlippageChanged(address _asset, uint256 _basis);
event Swapped(
address indexed _fromAsset,
address indexed _toAsset,
uint256 _fromAssetAmount,
uint256 _toAssetAmount
);
event StrategyAddedToMintWhitelist(address indexed strategy);
event StrategyRemovedFromMintWhitelist(address indexed strategy);
event RebasePerSecondMaxChanged(uint256 rebaseRatePerSecond);
event DripDurationChanged(uint256 dripDuration);
event WithdrawalRequested(
address indexed _withdrawer,
uint256 indexed _requestId,
uint256 _amount,
uint256 _queued
);
event WithdrawalClaimed(
address indexed _withdrawer,
uint256 indexed _requestId,
uint256 _amount
);
event WithdrawalClaimable(uint256 _claimable, uint256 _newClaimable);
event WithdrawalClaimDelayUpdated(uint256 _newDelay);
// Since we are proxy, all state should be uninitalized.
// Since this storage contract does not have logic directly on it
// we should not be checking for to see if these variables can be constant.
// slither-disable-start uninitialized-state
// slither-disable-start constable-states
// Assets supported by the Vault, i.e. Stablecoins
enum UnitConversion {
DECIMALS,
GETEXCHANGERATE
}
// Changed to fit into a single storage slot so the decimals needs to be recached
struct Asset {
// Note: OETHVaultCore doesn't use `isSupported` when minting,
// redeeming or checking balance of assets.
bool isSupported;
UnitConversion unitConversion;
uint8 decimals;
// Max allowed slippage from the Oracle price when swapping collateral assets in basis points.
// For example 40 == 0.4% slippage
uint16 allowedOracleSlippageBps;
}
/// @dev mapping of supported vault assets to their configuration
mapping(address => Asset) internal assets;
/// @dev list of all assets supported by the vault.
address[] internal allAssets;
// Strategies approved for use by the Vault
struct Strategy {
bool isSupported;
uint256 _deprecated; // Deprecated storage slot
}
/// @dev mapping of strategy contracts to their configuration
mapping(address => Strategy) public strategies;
/// @dev list of all vault strategies
address[] internal allStrategies;
/// @notice Address of the Oracle price provider contract
address public priceProvider;
/// @notice pause rebasing if true
bool public rebasePaused;
/// @notice pause operations that change the OToken supply.
/// eg mint, redeem, allocate, mint/burn for strategy
bool public capitalPaused;
/// @notice Redemption fee in basis points. eg 50 = 0.5%
uint256 public redeemFeeBps;
/// @notice Percentage of assets to keep in Vault to handle (most) withdrawals. 100% = 1e18.
uint256 public vaultBuffer;
/// @notice OToken mints over this amount automatically allocate funds. 18 decimals.
uint256 public autoAllocateThreshold;
/// @notice OToken mints over this amount automatically rebase. 18 decimals.
uint256 public rebaseThreshold;
/// @dev Address of the OToken token. eg OUSD or OETH.
OUSD public oUSD;
/// @dev Storage slot for the address of the VaultAdmin contract that is delegated to
// keccak256("OUSD.vault.governor.admin.impl");
bytes32 public constant adminImplPosition =
0xa2bd3d3cf188a41358c8b401076eb59066b09dec5775650c0de4c55187d17bd9;
/// @dev Address of the contract responsible for post rebase syncs with AMMs
address private _deprecated_rebaseHooksAddr = address(0);
/// @dev Deprecated: Address of Uniswap
address private _deprecated_uniswapAddr = address(0);
/// @notice Address of the Strategist
address public strategistAddr = address(0);
/// @notice Mapping of asset address to the Strategy that they should automatically
// be allocated to
mapping(address => address) public assetDefaultStrategies;
/// @notice Max difference between total supply and total value of assets. 18 decimals.
uint256 public maxSupplyDiff;
/// @notice Trustee contract that can collect a percentage of yield
address public trusteeAddress;
/// @notice Amount of yield collected in basis points. eg 2000 = 20%
uint256 public trusteeFeeBps;
/// @dev Deprecated: Tokens that should be swapped for stablecoins
address[] private _deprecated_swapTokens;
uint256 constant MINT_MINIMUM_UNIT_PRICE = 0.998e18;
/// @notice Metapool strategy that is allowed to mint/burn OTokens without changing collateral
address public ousdMetaStrategy;
/// @notice How much OTokens are currently minted by the strategy
int256 public netOusdMintedForStrategy;
/// @notice How much net total OTokens are allowed to be minted by all strategies
uint256 public netOusdMintForStrategyThreshold;
uint256 constant MIN_UNIT_PRICE_DRIFT = 0.7e18;
uint256 constant MAX_UNIT_PRICE_DRIFT = 1.3e18;
/// @notice Collateral swap configuration.
/// @dev is packed into a single storage slot to save gas.
struct SwapConfig {
// Contract that swaps the vault's collateral assets
address swapper;
// Max allowed percentage the total value can drop below the total supply in basis points.
// For example 100 == 1%
uint16 allowedUndervalueBps;
}
SwapConfig internal swapConfig = SwapConfig(address(0), 0);
// List of strategies that can mint oTokens directly
// Used in OETHBaseVaultCore
mapping(address => bool) public isMintWhitelistedStrategy;
/// @notice Address of the Dripper contract that streams harvested rewards to the Vault
/// @dev The vault is proxied so needs to be set with setDripper against the proxy contract.
address private _deprecated_dripper;
/// Withdrawal Queue Storage /////
struct WithdrawalQueueMetadata {
// cumulative total of all withdrawal requests included the ones that have already been claimed
uint128 queued;
// cumulative total of all the requests that can be claimed including the ones that have already been claimed
uint128 claimable;
// total of all the requests that have been claimed
uint128 claimed;
// index of the next withdrawal request starting at 0
uint128 nextWithdrawalIndex;
}
/// @notice Global metadata for the withdrawal queue including:
/// queued - cumulative total of all withdrawal requests included the ones that have already been claimed
/// claimable - cumulative total of all the requests that can be claimed including the ones already claimed
/// claimed - total of all the requests that have been claimed
/// nextWithdrawalIndex - index of the next withdrawal request starting at 0
WithdrawalQueueMetadata public withdrawalQueueMetadata;
struct WithdrawalRequest {
address withdrawer;
bool claimed;
uint40 timestamp; // timestamp of the withdrawal request
// Amount of oTokens to redeem. eg OETH
uint128 amount;
// cumulative total of all withdrawal requests including this one.
// this request can be claimed when this queued amount is less than or equal to the queue's claimable amount.
uint128 queued;
}
/// @notice Mapping of withdrawal request indices to the user withdrawal request data
mapping(uint256 => WithdrawalRequest) public withdrawalRequests;
/// @notice Sets a minimum delay that is required to elapse between
/// requesting async withdrawals and claiming the request.
/// When set to 0 async withdrawals are disabled.
uint256 public withdrawalClaimDelay;
/// @notice Time in seconds that the vault last rebased yield.
uint64 public lastRebase;
/// @notice Automatic rebase yield calculations. In seconds. Set to 0 or 1 to disable.
uint64 public dripDuration;
/// @notice max rebase percentage per second
/// Can be used to set maximum yield of the protocol,
/// spreading out yield over time
uint64 public rebasePerSecondMax;
/// @notice target rebase rate limit, based on past rates and funds available.
uint64 public rebasePerSecondTarget;
uint256 internal constant MAX_REBASE = 0.02 ether;
uint256 internal constant MAX_REBASE_PER_SECOND =
uint256(0.05 ether) / 1 days;
// For future use
uint256[43] private __gap;
// slither-disable-end constable-states
// slither-disable-end uninitialized-state
/**
* @notice set the implementation for the admin, this needs to be in a base class else we cannot set it
* @param newImpl address of the implementation
*/
function setAdminImpl(address newImpl) external onlyGovernor {
require(
Address.isContract(newImpl),
"new implementation is not a contract"
);
bytes32 position = adminImplPosition;
// solhint-disable-next-line no-inline-assembly
assembly {
sstore(position, newImpl)
}
}
}{
"optimizer": {
"enabled": true,
"runs": 200
},
"evmVersion": "paris",
"outputSelection": {
"*": {
"*": [
"evm.bytecode",
"evm.deployedBytecode",
"devdoc",
"userdoc",
"metadata",
"abi"
]
}
},
"metadata": {
"useLiteralContent": true
}
}Contract Security Audit
- No Contract Security Audit Submitted- Submit Audit Here
Contract ABI
API[{"inputs":[{"internalType":"address","name":"_wS","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"_threshold","type":"uint256"}],"name":"AllocateThresholdUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"_asset","type":"address"},{"indexed":false,"internalType":"address","name":"_strategy","type":"address"},{"indexed":false,"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"AssetAllocated","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"_asset","type":"address"},{"indexed":false,"internalType":"address","name":"_strategy","type":"address"}],"name":"AssetDefaultStrategyUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"_asset","type":"address"}],"name":"AssetRemoved","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"_asset","type":"address"}],"name":"AssetSupported","type":"event"},{"anonymous":false,"inputs":[],"name":"CapitalPaused","type":"event"},{"anonymous":false,"inputs":[],"name":"CapitalUnpaused","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"dripDuration","type":"uint256"}],"name":"DripDurationChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"previousGovernor","type":"address"},{"indexed":true,"internalType":"address","name":"newGovernor","type":"address"}],"name":"GovernorshipTransferred","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"maxSupplyDiff","type":"uint256"}],"name":"MaxSupplyDiffChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"_addr","type":"address"},{"indexed":false,"internalType":"uint256","name":"_value","type":"uint256"}],"name":"Mint","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"_threshold","type":"uint256"}],"name":"NetOusdMintForStrategyThresholdChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"_ousdMetaStrategy","type":"address"}],"name":"OusdMetaStrategyUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"previousGovernor","type":"address"},{"indexed":true,"internalType":"address","name":"newGovernor","type":"address"}],"name":"PendingGovernorshipTransfer","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"_priceProvider","type":"address"}],"name":"PriceProviderUpdated","type":"event"},{"anonymous":false,"inputs":[],"name":"RebasePaused","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"rebaseRatePerSecond","type":"uint256"}],"name":"RebasePerSecondMaxChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"_threshold","type":"uint256"}],"name":"RebaseThresholdUpdated","type":"event"},{"anonymous":false,"inputs":[],"name":"RebaseUnpaused","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"_addr","type":"address"},{"indexed":false,"internalType":"uint256","name":"_value","type":"uint256"}],"name":"Redeem","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"_redeemFeeBps","type":"uint256"}],"name":"RedeemFeeUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"_address","type":"address"}],"name":"StrategistUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"strategy","type":"address"}],"name":"StrategyAddedToMintWhitelist","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"_addr","type":"address"}],"name":"StrategyApproved","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"_addr","type":"address"}],"name":"StrategyRemoved","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"strategy","type":"address"}],"name":"StrategyRemovedFromMintWhitelist","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"_basis","type":"uint256"}],"name":"SwapAllowedUndervalueChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"_asset","type":"address"},{"indexed":false,"internalType":"uint256","name":"_basis","type":"uint256"}],"name":"SwapSlippageChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"_fromAsset","type":"address"},{"indexed":true,"internalType":"address","name":"_toAsset","type":"address"},{"indexed":false,"internalType":"uint256","name":"_fromAssetAmount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"_toAssetAmount","type":"uint256"}],"name":"Swapped","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"_address","type":"address"}],"name":"SwapperChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"_address","type":"address"}],"name":"TrusteeAddressChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"_basis","type":"uint256"}],"name":"TrusteeFeeBpsChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"_vaultBuffer","type":"uint256"}],"name":"VaultBufferUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"_newDelay","type":"uint256"}],"name":"WithdrawalClaimDelayUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"_claimable","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"_newClaimable","type":"uint256"}],"name":"WithdrawalClaimable","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"_withdrawer","type":"address"},{"indexed":true,"internalType":"uint256","name":"_requestId","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"WithdrawalClaimed","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"_withdrawer","type":"address"},{"indexed":true,"internalType":"uint256","name":"_requestId","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"_amount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"_queued","type":"uint256"}],"name":"WithdrawalRequested","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"_to","type":"address"},{"indexed":false,"internalType":"uint256","name":"_yield","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"_fee","type":"uint256"}],"name":"YieldDistribution","type":"event"},{"stateMutability":"nonpayable","type":"fallback"},{"inputs":[],"name":"ADMIN_IMPLEMENTATION","outputs":[{"internalType":"address","name":"adminImpl","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"addWithdrawalQueueLiquidity","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"adminImplPosition","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"allocate","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"assetDefaultStrategies","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"autoAllocateThreshold","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"burnForStrategy","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"cacheWETHAssetIndex","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"calculateRedeemOutputs","outputs":[{"internalType":"uint256[]","name":"","type":"uint256[]"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"capitalPaused","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_asset","type":"address"}],"name":"checkBalance","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"claimGovernance","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_requestId","type":"uint256"}],"name":"claimWithdrawal","outputs":[{"internalType":"uint256","name":"amount","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256[]","name":"_requestIds","type":"uint256[]"}],"name":"claimWithdrawals","outputs":[{"internalType":"uint256[]","name":"amounts","type":"uint256[]"},{"internalType":"uint256","name":"totalAmount","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"dripDuration","outputs":[{"internalType":"uint64","name":"","type":"uint64"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getAllAssets","outputs":[{"internalType":"address[]","name":"","type":"address[]"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getAllStrategies","outputs":[{"internalType":"address[]","name":"","type":"address[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_asset","type":"address"}],"name":"getAssetConfig","outputs":[{"components":[{"internalType":"bool","name":"isSupported","type":"bool"},{"internalType":"enum VaultStorage.UnitConversion","name":"unitConversion","type":"uint8"},{"internalType":"uint8","name":"decimals","type":"uint8"},{"internalType":"uint16","name":"allowedOracleSlippageBps","type":"uint16"}],"internalType":"struct VaultStorage.Asset","name":"config","type":"tuple"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getAssetCount","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getStrategyCount","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"governor","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_priceProvider","type":"address"},{"internalType":"address","name":"_oToken","type":"address"}],"name":"initialize","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"isGovernor","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"isMintWhitelistedStrategy","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_asset","type":"address"}],"name":"isSupportedAsset","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"lastRebase","outputs":[{"internalType":"uint64","name":"","type":"uint64"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"maxSupplyDiff","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_asset","type":"address"},{"internalType":"uint256","name":"_amount","type":"uint256"},{"internalType":"uint256","name":"_minimumOusdAmount","type":"uint256"}],"name":"mint","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"mintForStrategy","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"netOusdMintForStrategyThreshold","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"netOusdMintedForStrategy","outputs":[{"internalType":"int256","name":"","type":"int256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"oUSD","outputs":[{"internalType":"contract OUSD","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"ousdMetaStrategy","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"previewYield","outputs":[{"internalType":"uint256","name":"yield","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"priceProvider","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"asset","type":"address"}],"name":"priceUnitMint","outputs":[{"internalType":"uint256","name":"price","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"asset","type":"address"}],"name":"priceUnitRedeem","outputs":[{"internalType":"uint256","name":"price","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"rebase","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"rebasePaused","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"rebasePerSecondMax","outputs":[{"internalType":"uint64","name":"","type":"uint64"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"rebasePerSecondTarget","outputs":[{"internalType":"uint64","name":"","type":"uint64"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"rebaseThreshold","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_amount","type":"uint256"},{"internalType":"uint256","name":"_minimumUnitAmount","type":"uint256"}],"name":"redeem","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"redeemFeeBps","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"requestWithdrawal","outputs":[{"internalType":"uint256","name":"requestId","type":"uint256"},{"internalType":"uint256","name":"queued","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newImpl","type":"address"}],"name":"setAdminImpl","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"strategies","outputs":[{"internalType":"bool","name":"isSupported","type":"bool"},{"internalType":"uint256","name":"_deprecated","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"strategistAddr","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"totalValue","outputs":[{"internalType":"uint256","name":"value","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_newGovernor","type":"address"}],"name":"transferGovernance","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"trusteeAddress","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"trusteeFeeBps","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"vaultBuffer","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"weth","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"wethAssetIndex","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"withdrawalClaimDelay","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"withdrawalQueueMetadata","outputs":[{"internalType":"uint128","name":"queued","type":"uint128"},{"internalType":"uint128","name":"claimable","type":"uint128"},{"internalType":"uint128","name":"claimed","type":"uint128"},{"internalType":"uint128","name":"nextWithdrawalIndex","type":"uint128"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"withdrawalRequests","outputs":[{"internalType":"address","name":"withdrawer","type":"address"},{"internalType":"bool","name":"claimed","type":"bool"},{"internalType":"uint40","name":"timestamp","type":"uint40"},{"internalType":"uint128","name":"amount","type":"uint128"},{"internalType":"uint128","name":"queued","type":"uint128"}],"stateMutability":"view","type":"function"}]Contract Creation Code
603d80546001600160a01b0319908116909155603e805482169055603f8054909116905560e0604052600060a081905260c052604880546001600160b01b031916905534801561004e57600080fd5b5060405161415038038061415083398101604081905261006d9161007e565b6001600160a01b03166080526100ae565b60006020828403121561009057600080fd5b81516001600160a01b03811681146100a757600080fd5b9392505050565b60805161402561012b6000396000818161051001528181610ac801528181610b3201528181610f2f01528181611a4c01528181611b180152818161229f0152818161294b01528181612a5201528181612c1001528181612d1301528181612d5e01528181612dc6015281816131cf01526137b801526140256000f3fe608060405234801561001057600080fd5b506004361061038e5760003560e01c806367bd7ba3116101de578063af14052c1161010f578063d38bfff4116100ad578063ea33b8e41161007c578063ea33b8e4146108f9578063ef08edc214610901578063f844443614610916578063fc0cfeee146109295761038e565b8063d38bfff4146108c1578063d4c3eea0146108d4578063e45cc9f0146108dc578063e6cc5432146108e55761038e565b8063bb7a632e116100e9578063bb7a632e14610882578063c3b288641461089c578063c7af3352146108a4578063cc2fe94b146108ac5761038e565b8063af14052c1461085f578063b888879e14610867578063b9b17f9f1461087a5761038e565b80639be918e61161017c578063a0aead4d11610156578063a0aead4d14610813578063a403e4d51461081b578063ab80dafb14610844578063abaa9916146108575761038e565b80639be918e6146107b65780639ee679e8146107e25780639fa1826e1461080a5761038e565b80637a2202f3116101b85780637a2202f3146106e95780637cbc2373146106f25780638e510b5214610705578063937b25811461070e5761038e565b806367bd7ba3146106965780636ec3ab67146106b657806378f353a1146106d65761038e565b806345e4213b116102c357806353ca9f24116102615780635b60f9fc116102305780635b60f9fc146106555780635d36b190146106685780635f515226146106705780636217f3ea146106835761038e565b806353ca9f241461061257806354c6d85814610626578063570d8e1d1461062f5780635802a172146106425761038e565b806349c1d54d1161029d57806349c1d54d146105aa5780634d5f4629146105bd578063527e83a8146105ef57806352d38e5d146106095761038e565b806345e4213b1461056d578063485cc9551461057657806348e30f54146105895761038e565b806331e19cfa116103305780633b8fe28d1161030a5780633b8fe28d146104f85780633fc8cef31461050b57806344c54707146105325780634530820a1461053a5761038e565b806331e19cfa1461044d578063362bd1a31461045557806339ebf823146104b45761038e565b806318ce56bd1161036c57806318ce56bd146104135780631edfe3da14610426578063207134b01461042f5780632acada4d146104385761038e565b806309f6442c146103c45780630c340a24146103e0578063156e29f614610400575b600080516020613fb0833981519152366000803760008036600084545af43d6000803e8080156103bd573d6000f35b3d6000fd5b005b6103cd60385481565b6040519081526020015b60405180910390f35b6103e861093c565b6040516001600160a01b0390911681526020016103d7565b6103c261040e366004613a15565b610959565b6045546103e8906001600160a01b031681565b6103cd60395481565b6103cd60435481565b6104406109d7565b6040516103d79190613a48565b6036546103cd565b604b54604c54610481916001600160801b0380821692600160801b928390048216928183169291041684565b604080516001600160801b03958616815293851660208501529184169183019190915290911660608201526080016103d7565b6104e16104c2366004613a94565b6035602052600090815260409020805460019091015460ff9091169082565b6040805192151583526020830191909152016103d7565b6103cd610506366004613a94565b610a39565b6103e87f000000000000000000000000000000000000000000000000000000000000000081565b6103c2610a94565b61055d610548366004613a94565b60496020526000908152604090205460ff1681565b60405190151581526020016103d7565b6103cd604e5481565b6103c2610584366004613aaf565b610bd4565b61059c610597366004613ae2565b610df5565b6040516103d7929190613b93565b6042546103e8906001600160a01b031681565b604f546105d790600160c01b90046001600160401b031681565b6040516001600160401b0390911681526020016103d7565b604f546105d790600160801b90046001600160401b031681565b6103cd603b5481565b60375461055d90600160a01b900460ff1681565b6103cd607b5481565b603f546103e8906001600160a01b031681565b603c546103e8906001600160a01b031681565b6103cd610663366004613a94565b610f6c565b6103c2610f95565b6103cd61067e366004613a94565b61103b565b6103c2610691366004613bb5565b61104c565b6106a96106a4366004613bb5565b6111d0565b6040516103d79190613bce565b6106c96106c4366004613a94565b6111db565b6040516103d79190613bf7565b604f546105d7906001600160401b031681565b6103cd60475481565b6103c2610700366004613c4d565b611281565b6103cd60415481565b61076f61071c366004613bb5565b604d60205260009081526040902080546001909101546001600160a01b03821691600160a01b810460ff1691600160a81b90910464ffffffffff16906001600160801b0380821691600160801b90041685565b604080516001600160a01b039096168652931515602086015264ffffffffff909216928401929092526001600160801b03918216606084015216608082015260a0016103d7565b61055d6107c4366004613a94565b6001600160a01b031660009081526033602052604090205460ff1690565b6107f56107f0366004613bb5565b6112f4565b604080519283526020830191909152016103d7565b6103cd603a5481565b6034546103cd565b6103e8610829366004613a94565b6040602081905260009182529020546001600160a01b031681565b6103c2610852366004613bb5565b6115b1565b6103c2611700565b6103c2611778565b6037546103e8906001600160a01b031681565b6103c26117be565b604f546105d790600160401b90046001600160401b031681565b6104406117c6565b61055d611826565b600080516020613fb0833981519152546103e8565b6103c26108cf366004613a94565b611857565b6103cd6118fb565b6103cd60465481565b60375461055d90600160a81b900460ff1681565b6103cd611905565b6103cd600080516020613fb083398151915281565b6103cd610924366004613bb5565b611994565b6103c2610937366004613a94565b611a86565b6000610954600080516020613fd08339815191525490565b905090565b603754600160a81b900460ff161561098c5760405162461bcd60e51b815260040161098390613c6f565b60405180910390fd5b600080516020613f90833981519152805460011981016109be5760405162461bcd60e51b815260040161098390613c97565b600282556109cd858585611b16565b5060019055505050565b60606034805480602002602001604051908101604052809291908181526020018280548015610a2f57602002820191906000526020600020905b81546001600160a01b03168152600190910190602001808311610a11575b5050505050905090565b600080610a62610a5c610a4b85611d2f565b670de0b6b3a7640000906012611d99565b84611dfb565b9050670de0b6b3a764000081610a79856001611f46565b610a839190613cd5565b610a8d9190613cec565b9392505050565b610a9c611826565b610ab85760405162461bcd60e51b815260040161098390613d0e565b60345460005b81811015610b2f577f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031660348281548110610b0357610b03613d45565b6000918252602090912001546001600160a01b031603610b2757607b819055610b2f565b600101610abe565b507f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03166034607b5481548110610b6f57610b6f613d45565b6000918252602090912001546001600160a01b031614610bd15760405162461bcd60e51b815260206004820152601860248201527f496e76616c6964205745544820417373657420496e64657800000000000000006044820152606401610983565b50565b610bdc611826565b610bf85760405162461bcd60e51b815260040161098390613d0e565b600054610100900460ff1680610c11575060005460ff16155b610c745760405162461bcd60e51b815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201526d191e481a5b9a5d1a585b1a5e995960921b6064820152608401610983565b600054610100900460ff16158015610c96576000805461ffff19166101011790555b6001600160a01b038316610cec5760405162461bcd60e51b815260206004820152601d60248201527f507269636550726f76696465722061646472657373206973207a65726f0000006044820152606401610983565b6001600160a01b038216610d3b5760405162461bcd60e51b81526020600482015260166024820152756f546f6b656e2061646472657373206973207a65726f60501b6044820152606401610983565b603c80546001600160a01b038481166001600160a01b031990921691909117909155603780546001600160b01b03191691851691909117600160a81b17905560006038819055603981905569054b40b1f852bda00000603a55683635c9adc5dea00000603b556040805191825260208201908190529051610dbe9160369161398d565b50604f80546fffffffffffffffff00000000000000001916600160401b1790558015610df0576000805461ff00191690555b505050565b603754606090600090600160a81b900460ff1615610e255760405162461bcd60e51b815260040161098390613c6f565b600080516020613f9083398151915280546001198101610e575760405162461bcd60e51b815260040161098390613c97565b60028255610e63612219565b50846001600160401b03811115610e7c57610e7c613d5b565b604051908082528060200260200182016040528015610ea5578160200160208202803683370190505b50935060005b85811015610f2157610ed4878783818110610ec857610ec8613d45565b905060200201356123f5565b858281518110610ee657610ee6613d45565b602002602001018181525050848181518110610f0457610f04613d45565b602002602001015184610f179190613d71565b9350600101610eab565b50610f566001600160a01b037f00000000000000000000000000000000000000000000000000000000000000001633856126eb565b610f5f83612741565b6001825550509250929050565b600080610f7e610a5c610a4b85611d2f565b9050670de0b6b3a764000081610a79856000611f46565b7f44c4d30b2eaad5130ad70c3ba6972730566f3e6359ab83e800d905c61b1c51db546001600160a01b0316336001600160a01b0316146110305760405162461bcd60e51b815260206004820152603060248201527f4f6e6c79207468652070656e64696e6720476f7665726e6f722063616e20636f60448201526f6d706c6574652074686520636c61696d60801b6064820152608401610983565b611039336128e8565b565b600061104682612947565b92915050565b603754600160a81b900460ff16156110765760405162461bcd60e51b815260040161098390613c6f565b3360009081526035602052604090205460ff1615156001146110d15760405162461bcd60e51b8152602060048201526014602482015273556e737570706f7274656420737472617465677960601b6044820152606401610983565b3360009081526049602052604090205460ff1615156001146111305760405162461bcd60e51b81526020600482015260186024820152774e6f742077686974656c697374656420737472617465677960401b6044820152606401610983565b7f222838db2794d11532d940e8dec38ae307ed0b63cd97c233322e221f998767a63382604051611161929190613d84565b60405180910390a1603c54604051632770a7eb60e21b81526001600160a01b0390911690639dc29fac9061119b9033908590600401613d84565b600060405180830381600087803b1580156111b557600080fd5b505af11580156111c9573d6000803e3d6000fd5b5050505050565b606061104682612a1a565b604080516080808201835260008083526020808401829052838501829052606084018290526001600160a01b038616825260338152908490208451928301909452835460ff80821615158452939492939184019161010090910416600181111561124757611247613be1565b600181111561125857611258613be1565b8152905462010000810460ff1660208301526301000000900461ffff1660409091015292915050565b603754600160a81b900460ff16156112ab5760405162461bcd60e51b815260040161098390613c6f565b600080516020613f90833981519152805460011981016112dd5760405162461bcd60e51b815260040161098390613c97565b600282556112eb8484612b5a565b50600190555050565b6037546000908190600160a81b900460ff16156113235760405162461bcd60e51b815260040161098390613c6f565b600080516020613f90833981519152805460011981016113555760405162461bcd60e51b815260040161098390613c97565b600282556000604e54116113ab5760405162461bcd60e51b815260206004820152601d60248201527f4173796e63207769746864726177616c73206e6f7420656e61626c65640000006044820152606401610983565b604c54604b546001600160801b03600160801b909204821695506113d191879116613d71565b92506113e66113e1856001613d71565b612b99565b604c80546001600160801b03928316600160801b02921691909117905561140c83612b99565b604b80546001600160801b0319166001600160801b03929092169190911790556040805160a081018252338152600060208201524264ffffffffff16918101919091526060810161145c87612b99565b6001600160801b0316815260200161147385612b99565b6001600160801b039081169091526000868152604d602090815260409182902084518154928601518685015164ffffffffff16600160a81b0264ffffffffff60a81b19911515600160a01b026001600160a81b03199095166001600160a01b0393841617949094171692909217815560608501516080909501518416600160801b029490931693909317600190920191909155603c549051632770a7eb60e21b8152911690639dc29fac9061152e9033908990600401613d84565b600060405180830381600087803b15801561154857600080fd5b505af115801561155c573d6000803e3d6000fd5b5050505061156985612741565b6040805186815260208101859052859133917f38e3d972947cfef94205163d483d6287ef27eb312e20cb8e0b13a49989db232e910160405180910390a3600182555050915091565b603754600160a81b900460ff16156115db5760405162461bcd60e51b815260040161098390613c6f565b3360009081526035602052604090205460ff1615156001146116365760405162461bcd60e51b8152602060048201526014602482015273556e737570706f7274656420737472617465677960601b6044820152606401610983565b3360009081526049602052604090205460ff1615156001146116955760405162461bcd60e51b81526020600482015260186024820152774e6f742077686974656c697374656420737472617465677960401b6044820152606401610983565b7f0f6798a560793a54c3bcfe86a93cde1e73087d944c0ea20544137d412139688533826040516116c6929190613d84565b60405180910390a1603c546040516340c10f1960e01b81526001600160a01b03909116906340c10f199061119b9033908590600401613d84565b603754600160a81b900460ff161561172a5760405162461bcd60e51b815260040161098390613c6f565b600080516020613f908339815191528054600119810161175c5760405162461bcd60e51b815260040161098390613c97565b60028255611768612219565b50611771612c06565b5060019055565b600080516020613f90833981519152805460011981016117aa5760405162461bcd60e51b815260040161098390613c97565b600282556117b6612e2e565b505060019055565b610bd1612219565b60606036805480602002602001604051908101604052809291908181526020018280548015610a2f576020028201919060005260206000209081546001600160a01b03168152600190910190602001808311610a11575050505050905090565b600061183e600080516020613fd08339815191525490565b6001600160a01b0316336001600160a01b031614905090565b61185f611826565b61187b5760405162461bcd60e51b815260040161098390613d0e565b6118a3817f44c4d30b2eaad5130ad70c3ba6972730566f3e6359ab83e800d905c61b1c51db55565b806001600160a01b03166118c3600080516020613fd08339815191525490565b6001600160a01b03167fa39cc5eb22d0f34d8beaefee8a3f17cc229c1a1d1ef87a5ad47313487b1c4f0d60405160405180910390a350565b60006109546131c8565b600061198e603c60009054906101000a90046001600160a01b03166001600160a01b03166318160ddd6040518163ffffffff1660e01b8152600401602060405180830381865afa15801561195d573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906119819190613d9d565b6119896131c8565b6131f3565b50919050565b603754600090600160a81b900460ff16156119c15760405162461bcd60e51b815260040161098390613c6f565b600080516020613f90833981519152805460011981016119f35760405162461bcd60e51b815260040161098390613c97565b60028255604b546000858152604d60205260409020600101546001600160801b03600160801b92839004811692909104161115611a3457611a32612219565b505b611a3d846123f5565b9250611a736001600160a01b037f00000000000000000000000000000000000000000000000000000000000000001633856126eb565b611a7c83612741565b5060019055919050565b611a8e611826565b611aaa5760405162461bcd60e51b815260040161098390613d0e565b803b611b045760405162461bcd60e51b8152602060048201526024808201527f6e657720696d706c656d656e746174696f6e206973206e6f74206120636f6e746044820152631c9858dd60e21b6064820152608401610983565b600080516020613fb083398151915255565b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316836001600160a01b031614611b975760405162461bcd60e51b815260206004820152601d60248201527f556e737570706f7274656420617373657420666f72206d696e74696e670000006044820152606401610983565b60008211611be75760405162461bcd60e51b815260206004820152601d60248201527f416d6f756e74206d7573742062652067726561746572207468616e20300000006044820152606401610983565b80821015611c375760405162461bcd60e51b815260206004820152601e60248201527f4d696e7420616d6f756e74206c6f776572207468616e206d696e696d756d00006044820152606401610983565b7f0f6798a560793a54c3bcfe86a93cde1e73087d944c0ea20544137d41213968853383604051611c68929190613d84565b60405180910390a1603754600160a01b900460ff16158015611c8c5750603b548210155b15611c9b57611c99612e2e565b505b603c546040516340c10f1960e01b81526001600160a01b03909116906340c10f1990611ccd9033908690600401613d84565b600060405180830381600087803b158015611ce757600080fd5b505af1158015611cfb573d6000803e3d6000fd5b50611d15925050506001600160a01b0384163330856133c6565b611d1d612219565b50603a548210610df057610df0612c06565b6001600160a01b03811660009081526033602052604090205462010000900460ff1680611d945760405162461bcd60e51b8152602060048201526013602482015272111958da5b585b1cc81b9bdd0818d858da1959606a1b6044820152606401610983565b919050565b600081831115611dc957611dc2611db08385613db6565b611dbb90600a613eb0565b8590613404565b9350611df3565b81831015611df357611df0611dde8484613db6565b611de990600a613eb0565b8590613410565b93505b509192915050565b6001600160a01b038116600090815260336020526040812054610100900460ff1681816001811115611e2f57611e2f613be1565b03611e5257611e4a6012611e4285611d2f565b869190611d99565b915050611046565b6001816001811115611e6657611e66613be1565b03611ef7576000836001600160a01b031663e6aa216c6040518163ffffffff1660e01b8152600401602060405180830381865afa158015611eab573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611ecf9190613d9d565b9050670de0b6b3a7640000611ee48287613cd5565b611eee9190613cec565b92505050611046565b60405162461bcd60e51b815260206004820152601b60248201527f556e737570706f7274656420636f6e76657273696f6e207479706500000000006044820152606401610983565b5092915050565b6001600160a01b038281166000818152603360205260408082205460375491516315d5220f60e31b81526004810194909452919361010090920460ff169291169063aea9107890602401602060405180830381865afa158015611fad573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611fd19190613d9d565b91506001816001811115611fe757611fe7613be1565b03612077576000846001600160a01b031663e6aa216c6040518163ffffffff1660e01b8152600401602060405180830381865afa15801561202c573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906120509190613d9d565b90508061206584670de0b6b3a7640000613cd5565b61206f9190613cec565b9250506120d8565b600081600181111561208b5761208b613be1565b146120d85760405162461bcd60e51b815260206004820152601b60248201527f556e737570706f7274656420636f6e76657273696f6e207479706500000000006044820152606401610983565b67120a871cc00200008211156121305760405162461bcd60e51b815260206004820152601860248201527f5661756c743a2050726963652065786365656473206d617800000000000000006044820152606401610983565b6709b6e64a8ec600008210156121815760405162461bcd60e51b81526020600482015260166024820152752b30bab63a1d10283934b1b2903ab73232b91036b4b760511b6044820152606401610983565b82156121f857670de0b6b3a76400008211156121a357670de0b6b3a764000091505b670dd99bb65dd700008210156121f35760405162461bcd60e51b815260206004820152601560248201527441737365742070726963652062656c6f772070656760581b6044820152606401610983565b611f3f565b670de0b6b3a7640000821015611f3f5750670de0b6b3a76400009392505050565b60408051608081018252604b546001600160801b03808216808452600160801b92839004821660208501819052604c548084169686019690965292909404166060830152600092839161226b91613ebc565b6001600160801b03169050806000036122875760009250505090565b6040516370a0823160e01b81523060048201526000907f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316906370a0823190602401602060405180830381865afa1580156122ee573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906123129190613d9d565b905060008360400151846020015161232a9190613ebc565b6001600160801b0316905080821161234757600094505050505090565b60006123538284613db6565b90508084106123625780612364565b835b955060008686602001516001600160801b03166123819190613d71565b905061238c81612b99565b604b80546001600160801b03928316600160801b0292169190911790556040517fee79a0c43d3993055690b54e074b5153e8bae8d1a872b656dedb64aa8f463333906123e49083908a90918252602082015260400190565b60405180910390a150505050505090565b600080604e54116124485760405162461bcd60e51b815260206004820152601d60248201527f4173796e63207769746864726177616c73206e6f7420656e61626c65640000006044820152606401610983565b6000828152604d6020908152604091829020825160a08101845281546001600160a01b038116825260ff600160a01b82041615158285015264ffffffffff600160a81b90910481168286019081526001909301546001600160801b03808216606080860191909152600160801b92839004821660808087019190915288519081018952604b548084168252849004831697810197909752604c54808316988801989098529190960490951694840194909452604e5491519093429261250f92909116613d71565b11156125535760405162461bcd60e51b815260206004820152601360248201527210db185a5b4819195b185e481b9bdd081b595d606a1b6044820152606401610983565b80602001516001600160801b031682608001516001600160801b031611156125bd5760405162461bcd60e51b815260206004820152601760248201527f51756575652070656e64696e67206c69717569646974790000000000000000006044820152606401610983565b81516001600160a01b031633146126065760405162461bcd60e51b815260206004820152600d60248201526c2737ba103932b8bab2b9ba32b960991b6044820152606401610983565b60208201511561264a5760405162461bcd60e51b815260206004820152600f60248201526e105b1c9958591e4818db185a5b5959608a1b6044820152606401610983565b6000848152604d602052604090819020805460ff60a01b1916600160a01b17905560608301519082015161267e9190613edb565b604c80546001600160801b0319166001600160801b03928316179055606083015160405191168152849033907f2d43eb174787155132b52ddb6b346e2dca99302eac3df4466dbeff953d3c84d19060200160405180910390a350606001516001600160801b031692915050565b610df08363a9059cbb60e01b848460405160240161270a929190613d84565b60408051601f198184030181529190526020810180516001600160e01b03166001600160e01b03199093169290921790915261341c565b6000603b54821015801561275f5750603754600160a01b900460ff16155b156127735761276c612e2e565b905061277e565b61277b6131c8565b90505b604154156128e457600081116127d65760405162461bcd60e51b815260206004820152601d60248201527f546f6f206d616e79206f75747374616e64696e672072657175657374730000006044820152606401610983565b600061285982603c60009054906101000a90046001600160a01b03166001600160a01b03166318160ddd6040518163ffffffff1660e01b8152600401602060405180830381865afa15801561282f573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906128539190613d9d565b906134ee565b9050604154670de0b6b3a764000082116128845761287f82670de0b6b3a7640000613db6565b612896565b612896670de0b6b3a764000083613db6565b1115610df05760405162461bcd60e51b815260206004820152601e60248201527f4261636b696e6720737570706c79206c6971756964697479206572726f7200006044820152606401610983565b5050565b6001600160a01b03811661293e5760405162461bcd60e51b815260206004820152601a60248201527f4e657720476f7665726e6f7220697320616464726573732830290000000000006044820152606401610983565b610bd181613517565b60007f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316826001600160a01b03161461298a57506000919050565b6129938261357e565b60408051608081018252604b546001600160801b03808216808452600160801b9283900482166020850152604c548083169585018690529290920416606083015292935091906129e39084613d71565b10156129f25750600092915050565b805160408201516001600160801b0391821691612a10911684613d71565b610a8d9190613db6565b60385460609015612a4957603854600090612a39908490612710613718565b9050612a458184613db6565b9250505b6000607b5490507f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031660348281548110612a8d57612a8d613d45565b6000918252602090912001546001600160a01b031614612aef5760405162461bcd60e51b815260206004820152601b60248201527f5745544820417373657420696e646578206e6f742063616368656400000000006044820152606401610983565b6034546001600160401b03811115612b0957612b09613d5b565b604051908082528060200260200182016040528015612b32578160200160208202803683370190505b50915082828281518110612b4857612b48613d45565b60200260200101818152505050919050565b60405162461bcd60e51b81526020600482015260146024820152733ab739bab83837b93a32b210333ab731ba34b7b760611b6044820152606401610983565b60006001600160801b03821115612c025760405162461bcd60e51b815260206004820152602760248201527f53616665436173743a2076616c756520646f65736e27742066697420696e20316044820152663238206269747360c81b6064820152608401610983565b5090565b6001600160a01b037f000000000000000000000000000000000000000000000000000000000000000081166000908152604060208190529020541680612c495750565b6000612c5361373a565b905080600003612c61575050565b603c54604080516318160ddd60e01b815290516000926001600160a01b0316916318160ddd9160048083019260209291908290030181865afa158015612cab573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612ccf9190613d9d565b90506000612ce86039548361384890919063ffffffff16565b9050808311612cf75750505050565b6000612d038285613db6565b905084612d3a6001600160a01b037f00000000000000000000000000000000000000000000000000000000000000001682846126eb565b6040516311f9fbc960e21b81526001600160a01b038216906347e7ef2490612d88907f0000000000000000000000000000000000000000000000000000000000000000908690600401613d84565b600060405180830381600087803b158015612da257600080fd5b505af1158015612db6573d6000803e3d6000fd5b5050604080516001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000811682528a1660208201529081018590527f41b99659f6ba0803f444aff29e5bf6e26dd86a3219aff92119d69710a956ba8d9250606001905060405180910390a1505050505050565b603754600090600160a01b900460ff1615612e7d5760405162461bcd60e51b815260206004820152600f60248201526e149958985cda5b99c81c185d5cd959608a1b6044820152606401610983565b603c54604080516318160ddd60e01b815290516000926001600160a01b0316916318160ddd9160048083019260209291908290030181865afa158015612ec7573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612eeb9190613d9d565b90506000612ef76131c8565b905081600003612f0a5791506131c59050565b600080612f1784846131f3565b90925090506000612f288386613d71565b90508481111580612f3857508381115b15612f47575091949350505050565b612f58826001600160401b0361385d565b604f805477ffffffffffffffffffffffffffffffff000000000000000016600160c01b6001600160401b039384160267ffffffffffffffff19161742929092169190911790556042546001600160a01b0316600081156130945761271060435486612fc39190613cd5565b612fcd9190613cec565b905080156130945784811061302f5760405162461bcd60e51b815260206004820152602260248201527f466565206d757374206e6f742062652067726561746572207468616e207969656044820152611b1960f21b6064820152608401610983565b603c546040516340c10f1960e01b81526001600160a01b03909116906340c10f19906130619085908590600401613d84565b600060405180830381600087803b15801561307b57600080fd5b505af115801561308f573d6000803e3d6000fd5b505050505b604080516001600160a01b0384168152602081018790529081018290527f09516ecf4a8a86e59780a9befc6dee948bc9e60a36e3be68d31ea817ee8d2c809060600160405180910390a1603c60009054906101000a90046001600160a01b03166001600160a01b03166318160ddd6040518163ffffffff1660e01b8152600401602060405180830381865afa158015613131573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906131559190613d9d565b8311156131bb57603c546040516339a7919f60e01b8152600481018590526001600160a01b03909116906339a7919f90602401600060405180830381600087803b1580156131a257600080fd5b505af11580156131b6573d6000803e3d6000fd5b505050505b5093955050505050505b90565b60006109547f0000000000000000000000000000000000000000000000000000000000000000612947565b6000806000603c60009054906101000a90046001600160a01b03166001600160a01b031663e696393a6040518163ffffffff1660e01b8152600401602060405180830381865afa15801561324b573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061326f9190613d9d565b9050600061327d8287613db6565b604f54909150600090613299906001600160401b031642613db6565b604f54600160c01b90046001600160401b0316945090508015806132bb575081155b806132c557508587115b806132d757506001600160401b034210155b156132e857600094505050506133bf565b6132f28787613db6565b604f54909550600160401b90046001600160401b031660018111156133575761332f85613320836002613cd5565b61332a9089613cec565b613873565b94506133448561333f8389613cec565b61385d565b94506133548661333f8488613cd5565b95505b604f54613398908790670de0b6b3a764000090600160801b90046001600160401b03166133848688613cd5565b61338e9190613cd5565b61333f9190613cec565b95506133b886670de0b6b3a764000061338e66470de4df82000087613cd5565b9550505050505b9250929050565b6040516001600160a01b03808516602483015283166044820152606481018290526133fe9085906323b872dd60e01b9060840161270a565b50505050565b6000610a8d8284613cd5565b6000610a8d8284613cec565b6000613471826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b03166138829092919063ffffffff16565b805190915015610df0578080602001905181019061348f9190613efa565b610df05760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b6064820152608401610983565b60008061350384670de0b6b3a7640000613404565b905061350f8184613410565b949350505050565b806001600160a01b0316613537600080516020613fd08339815191525490565b6001600160a01b03167fc7c0c772add429241571afb3805861fb3cfa2af374534088b76cdb4325a87e9a60405160405180910390a3600080516020613fd083398151915255565b6040516370a0823160e01b815230600482015260009082906001600160a01b038216906370a0823190602401602060405180830381865afa1580156135c7573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906135eb9190613d9d565b60365490925060005b818110156137105760006036828154811061361157613611613d45565b60009182526020909120015460405163551c457b60e11b81526001600160a01b0388811660048301529091169150819063aa388af690602401602060405180830381865afa158015613667573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061368b9190613efa565b1561370757604051632fa8a91360e11b81526001600160a01b038781166004830152821690635f51522690602401602060405180830381865afa1580156136d6573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906136fa9190613d9d565b6137049086613d71565b94505b506001016135f4565b505050919050565b6000806137258585613404565b90506137318184613410565b95945050505050565b60408051608081018252604b546001600160801b03808216808452600160801b9283900482166020850152604c5480831695850186905292909204166060830152600092839161378a9190613ebc565b6040516370a0823160e01b81523060048201526001600160801b039190911691506000906001600160a01b037f000000000000000000000000000000000000000000000000000000000000000016906370a0823190602401602060405180830381865afa1580156137ff573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906138239190613d9d565b9050818111613836576000935050505090565b6138408282613db6565b935050505090565b6000610a8d8383670de0b6b3a7640000613718565b600081831061386c5781610a8d565b5090919050565b600081831161386c5781610a8d565b606061350f848460008585843b6138db5760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000006044820152606401610983565b600080866001600160a01b031685876040516138f79190613f40565b60006040518083038185875af1925050503d8060008114613934576040519150601f19603f3d011682016040523d82523d6000602084013e613939565b606091505b5091509150613949828286613954565b979650505050505050565b60608315613963575081610a8d565b8251156139735782518084602001fd5b8160405162461bcd60e51b81526004016109839190613f5c565b8280548282559060005260206000209081019282156139e2579160200282015b828111156139e257825182546001600160a01b0319166001600160a01b039091161782556020909201916001909101906139ad565b50612c029291505b80821115612c0257600081556001016139ea565b80356001600160a01b0381168114611d9457600080fd5b600080600060608486031215613a2a57600080fd5b613a33846139fe565b95602085013595506040909401359392505050565b602080825282518282018190526000918401906040840190835b81811015613a895783516001600160a01b0316835260209384019390920191600101613a62565b509095945050505050565b600060208284031215613aa657600080fd5b610a8d826139fe565b60008060408385031215613ac257600080fd5b613acb836139fe565b9150613ad9602084016139fe565b90509250929050565b60008060208385031215613af557600080fd5b82356001600160401b03811115613b0b57600080fd5b8301601f81018513613b1c57600080fd5b80356001600160401b03811115613b3257600080fd5b8560208260051b8401011115613b4757600080fd5b6020919091019590945092505050565b600081518084526020840193506020830160005b82811015613b89578151865260209586019590910190600101613b6b565b5093949350505050565b604081526000613ba66040830185613b57565b90508260208301529392505050565b600060208284031215613bc757600080fd5b5035919050565b602081526000610a8d6020830184613b57565b634e487b7160e01b600052602160045260246000fd5b8151151581526020820151608082019060028110613c2557634e487b7160e01b600052602160045260246000fd5b8060208401525060ff604084015116604083015261ffff606084015116606083015292915050565b60008060408385031215613c6057600080fd5b50508035926020909101359150565b6020808252600e908201526d10d85c1a5d185b081c185d5cd95960921b604082015260600190565b6020808252600e908201526d1499595b9d1c985b9d0818d85b1b60921b604082015260600190565b634e487b7160e01b600052601160045260246000fd5b808202811582820484141761104657611046613cbf565b600082613d0957634e487b7160e01b600052601260045260246000fd5b500490565b6020808252601a908201527f43616c6c6572206973206e6f742074686520476f7665726e6f72000000000000604082015260600190565b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052604160045260246000fd5b8082018082111561104657611046613cbf565b6001600160a01b03929092168252602082015260400190565b600060208284031215613daf57600080fd5b5051919050565b8181038181111561104657611046613cbf565b6001815b6001841115613e0457808504811115613de857613de8613cbf565b6001841615613df657908102905b60019390931c928002613dcd565b935093915050565b600082613e1b57506001611046565b81613e2857506000611046565b8160018114613e3e5760028114613e4857613e64565b6001915050611046565b60ff841115613e5957613e59613cbf565b50506001821b611046565b5060208310610133831016604e8410600b8410161715613e87575081810a611046565b613e946000198484613dc9565b8060001904821115613ea857613ea8613cbf565b029392505050565b6000610a8d8383613e0c565b6001600160801b03828116828216039081111561104657611046613cbf565b6001600160801b03818116838216019081111561104657611046613cbf565b600060208284031215613f0c57600080fd5b81518015158114610a8d57600080fd5b60005b83811015613f37578181015183820152602001613f1f565b50506000910152565b60008251613f52818460208701613f1c565b9190910192915050565b6020815260008251806020840152613f7b816040850160208701613f1c565b601f01601f1916919091016040019291505056fe53bf423e48ed90e97d02ab0ebab13b2a235a6bfbe9c321847d5c175333ac4535a2bd3d3cf188a41358c8b401076eb59066b09dec5775650c0de4c55187d17bd97bea13895fa79d2831e0a9e28edede30099005a50d652d8957cf8a607ee6ca4aa264697066735822122021757e4dbbe98fdb828aa00baa2e77cb03e155b9c7fe812fb48e73f1e3d1728b64736f6c634300081c0033000000000000000000000000039e2fb66102314ce7b64ce5ce3e5183bc94ad38
Deployed Bytecode
0x608060405234801561001057600080fd5b506004361061038e5760003560e01c806367bd7ba3116101de578063af14052c1161010f578063d38bfff4116100ad578063ea33b8e41161007c578063ea33b8e4146108f9578063ef08edc214610901578063f844443614610916578063fc0cfeee146109295761038e565b8063d38bfff4146108c1578063d4c3eea0146108d4578063e45cc9f0146108dc578063e6cc5432146108e55761038e565b8063bb7a632e116100e9578063bb7a632e14610882578063c3b288641461089c578063c7af3352146108a4578063cc2fe94b146108ac5761038e565b8063af14052c1461085f578063b888879e14610867578063b9b17f9f1461087a5761038e565b80639be918e61161017c578063a0aead4d11610156578063a0aead4d14610813578063a403e4d51461081b578063ab80dafb14610844578063abaa9916146108575761038e565b80639be918e6146107b65780639ee679e8146107e25780639fa1826e1461080a5761038e565b80637a2202f3116101b85780637a2202f3146106e95780637cbc2373146106f25780638e510b5214610705578063937b25811461070e5761038e565b806367bd7ba3146106965780636ec3ab67146106b657806378f353a1146106d65761038e565b806345e4213b116102c357806353ca9f24116102615780635b60f9fc116102305780635b60f9fc146106555780635d36b190146106685780635f515226146106705780636217f3ea146106835761038e565b806353ca9f241461061257806354c6d85814610626578063570d8e1d1461062f5780635802a172146106425761038e565b806349c1d54d1161029d57806349c1d54d146105aa5780634d5f4629146105bd578063527e83a8146105ef57806352d38e5d146106095761038e565b806345e4213b1461056d578063485cc9551461057657806348e30f54146105895761038e565b806331e19cfa116103305780633b8fe28d1161030a5780633b8fe28d146104f85780633fc8cef31461050b57806344c54707146105325780634530820a1461053a5761038e565b806331e19cfa1461044d578063362bd1a31461045557806339ebf823146104b45761038e565b806318ce56bd1161036c57806318ce56bd146104135780631edfe3da14610426578063207134b01461042f5780632acada4d146104385761038e565b806309f6442c146103c45780630c340a24146103e0578063156e29f614610400575b600080516020613fb0833981519152366000803760008036600084545af43d6000803e8080156103bd573d6000f35b3d6000fd5b005b6103cd60385481565b6040519081526020015b60405180910390f35b6103e861093c565b6040516001600160a01b0390911681526020016103d7565b6103c261040e366004613a15565b610959565b6045546103e8906001600160a01b031681565b6103cd60395481565b6103cd60435481565b6104406109d7565b6040516103d79190613a48565b6036546103cd565b604b54604c54610481916001600160801b0380821692600160801b928390048216928183169291041684565b604080516001600160801b03958616815293851660208501529184169183019190915290911660608201526080016103d7565b6104e16104c2366004613a94565b6035602052600090815260409020805460019091015460ff9091169082565b6040805192151583526020830191909152016103d7565b6103cd610506366004613a94565b610a39565b6103e87f000000000000000000000000039e2fb66102314ce7b64ce5ce3e5183bc94ad3881565b6103c2610a94565b61055d610548366004613a94565b60496020526000908152604090205460ff1681565b60405190151581526020016103d7565b6103cd604e5481565b6103c2610584366004613aaf565b610bd4565b61059c610597366004613ae2565b610df5565b6040516103d7929190613b93565b6042546103e8906001600160a01b031681565b604f546105d790600160c01b90046001600160401b031681565b6040516001600160401b0390911681526020016103d7565b604f546105d790600160801b90046001600160401b031681565b6103cd603b5481565b60375461055d90600160a01b900460ff1681565b6103cd607b5481565b603f546103e8906001600160a01b031681565b603c546103e8906001600160a01b031681565b6103cd610663366004613a94565b610f6c565b6103c2610f95565b6103cd61067e366004613a94565b61103b565b6103c2610691366004613bb5565b61104c565b6106a96106a4366004613bb5565b6111d0565b6040516103d79190613bce565b6106c96106c4366004613a94565b6111db565b6040516103d79190613bf7565b604f546105d7906001600160401b031681565b6103cd60475481565b6103c2610700366004613c4d565b611281565b6103cd60415481565b61076f61071c366004613bb5565b604d60205260009081526040902080546001909101546001600160a01b03821691600160a01b810460ff1691600160a81b90910464ffffffffff16906001600160801b0380821691600160801b90041685565b604080516001600160a01b039096168652931515602086015264ffffffffff909216928401929092526001600160801b03918216606084015216608082015260a0016103d7565b61055d6107c4366004613a94565b6001600160a01b031660009081526033602052604090205460ff1690565b6107f56107f0366004613bb5565b6112f4565b604080519283526020830191909152016103d7565b6103cd603a5481565b6034546103cd565b6103e8610829366004613a94565b6040602081905260009182529020546001600160a01b031681565b6103c2610852366004613bb5565b6115b1565b6103c2611700565b6103c2611778565b6037546103e8906001600160a01b031681565b6103c26117be565b604f546105d790600160401b90046001600160401b031681565b6104406117c6565b61055d611826565b600080516020613fb0833981519152546103e8565b6103c26108cf366004613a94565b611857565b6103cd6118fb565b6103cd60465481565b60375461055d90600160a81b900460ff1681565b6103cd611905565b6103cd600080516020613fb083398151915281565b6103cd610924366004613bb5565b611994565b6103c2610937366004613a94565b611a86565b6000610954600080516020613fd08339815191525490565b905090565b603754600160a81b900460ff161561098c5760405162461bcd60e51b815260040161098390613c6f565b60405180910390fd5b600080516020613f90833981519152805460011981016109be5760405162461bcd60e51b815260040161098390613c97565b600282556109cd858585611b16565b5060019055505050565b60606034805480602002602001604051908101604052809291908181526020018280548015610a2f57602002820191906000526020600020905b81546001600160a01b03168152600190910190602001808311610a11575b5050505050905090565b600080610a62610a5c610a4b85611d2f565b670de0b6b3a7640000906012611d99565b84611dfb565b9050670de0b6b3a764000081610a79856001611f46565b610a839190613cd5565b610a8d9190613cec565b9392505050565b610a9c611826565b610ab85760405162461bcd60e51b815260040161098390613d0e565b60345460005b81811015610b2f577f000000000000000000000000039e2fb66102314ce7b64ce5ce3e5183bc94ad386001600160a01b031660348281548110610b0357610b03613d45565b6000918252602090912001546001600160a01b031603610b2757607b819055610b2f565b600101610abe565b507f000000000000000000000000039e2fb66102314ce7b64ce5ce3e5183bc94ad386001600160a01b03166034607b5481548110610b6f57610b6f613d45565b6000918252602090912001546001600160a01b031614610bd15760405162461bcd60e51b815260206004820152601860248201527f496e76616c6964205745544820417373657420496e64657800000000000000006044820152606401610983565b50565b610bdc611826565b610bf85760405162461bcd60e51b815260040161098390613d0e565b600054610100900460ff1680610c11575060005460ff16155b610c745760405162461bcd60e51b815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201526d191e481a5b9a5d1a585b1a5e995960921b6064820152608401610983565b600054610100900460ff16158015610c96576000805461ffff19166101011790555b6001600160a01b038316610cec5760405162461bcd60e51b815260206004820152601d60248201527f507269636550726f76696465722061646472657373206973207a65726f0000006044820152606401610983565b6001600160a01b038216610d3b5760405162461bcd60e51b81526020600482015260166024820152756f546f6b656e2061646472657373206973207a65726f60501b6044820152606401610983565b603c80546001600160a01b038481166001600160a01b031990921691909117909155603780546001600160b01b03191691851691909117600160a81b17905560006038819055603981905569054b40b1f852bda00000603a55683635c9adc5dea00000603b556040805191825260208201908190529051610dbe9160369161398d565b50604f80546fffffffffffffffff00000000000000001916600160401b1790558015610df0576000805461ff00191690555b505050565b603754606090600090600160a81b900460ff1615610e255760405162461bcd60e51b815260040161098390613c6f565b600080516020613f9083398151915280546001198101610e575760405162461bcd60e51b815260040161098390613c97565b60028255610e63612219565b50846001600160401b03811115610e7c57610e7c613d5b565b604051908082528060200260200182016040528015610ea5578160200160208202803683370190505b50935060005b85811015610f2157610ed4878783818110610ec857610ec8613d45565b905060200201356123f5565b858281518110610ee657610ee6613d45565b602002602001018181525050848181518110610f0457610f04613d45565b602002602001015184610f179190613d71565b9350600101610eab565b50610f566001600160a01b037f000000000000000000000000039e2fb66102314ce7b64ce5ce3e5183bc94ad381633856126eb565b610f5f83612741565b6001825550509250929050565b600080610f7e610a5c610a4b85611d2f565b9050670de0b6b3a764000081610a79856000611f46565b7f44c4d30b2eaad5130ad70c3ba6972730566f3e6359ab83e800d905c61b1c51db546001600160a01b0316336001600160a01b0316146110305760405162461bcd60e51b815260206004820152603060248201527f4f6e6c79207468652070656e64696e6720476f7665726e6f722063616e20636f60448201526f6d706c6574652074686520636c61696d60801b6064820152608401610983565b611039336128e8565b565b600061104682612947565b92915050565b603754600160a81b900460ff16156110765760405162461bcd60e51b815260040161098390613c6f565b3360009081526035602052604090205460ff1615156001146110d15760405162461bcd60e51b8152602060048201526014602482015273556e737570706f7274656420737472617465677960601b6044820152606401610983565b3360009081526049602052604090205460ff1615156001146111305760405162461bcd60e51b81526020600482015260186024820152774e6f742077686974656c697374656420737472617465677960401b6044820152606401610983565b7f222838db2794d11532d940e8dec38ae307ed0b63cd97c233322e221f998767a63382604051611161929190613d84565b60405180910390a1603c54604051632770a7eb60e21b81526001600160a01b0390911690639dc29fac9061119b9033908590600401613d84565b600060405180830381600087803b1580156111b557600080fd5b505af11580156111c9573d6000803e3d6000fd5b5050505050565b606061104682612a1a565b604080516080808201835260008083526020808401829052838501829052606084018290526001600160a01b038616825260338152908490208451928301909452835460ff80821615158452939492939184019161010090910416600181111561124757611247613be1565b600181111561125857611258613be1565b8152905462010000810460ff1660208301526301000000900461ffff1660409091015292915050565b603754600160a81b900460ff16156112ab5760405162461bcd60e51b815260040161098390613c6f565b600080516020613f90833981519152805460011981016112dd5760405162461bcd60e51b815260040161098390613c97565b600282556112eb8484612b5a565b50600190555050565b6037546000908190600160a81b900460ff16156113235760405162461bcd60e51b815260040161098390613c6f565b600080516020613f90833981519152805460011981016113555760405162461bcd60e51b815260040161098390613c97565b600282556000604e54116113ab5760405162461bcd60e51b815260206004820152601d60248201527f4173796e63207769746864726177616c73206e6f7420656e61626c65640000006044820152606401610983565b604c54604b546001600160801b03600160801b909204821695506113d191879116613d71565b92506113e66113e1856001613d71565b612b99565b604c80546001600160801b03928316600160801b02921691909117905561140c83612b99565b604b80546001600160801b0319166001600160801b03929092169190911790556040805160a081018252338152600060208201524264ffffffffff16918101919091526060810161145c87612b99565b6001600160801b0316815260200161147385612b99565b6001600160801b039081169091526000868152604d602090815260409182902084518154928601518685015164ffffffffff16600160a81b0264ffffffffff60a81b19911515600160a01b026001600160a81b03199095166001600160a01b0393841617949094171692909217815560608501516080909501518416600160801b029490931693909317600190920191909155603c549051632770a7eb60e21b8152911690639dc29fac9061152e9033908990600401613d84565b600060405180830381600087803b15801561154857600080fd5b505af115801561155c573d6000803e3d6000fd5b5050505061156985612741565b6040805186815260208101859052859133917f38e3d972947cfef94205163d483d6287ef27eb312e20cb8e0b13a49989db232e910160405180910390a3600182555050915091565b603754600160a81b900460ff16156115db5760405162461bcd60e51b815260040161098390613c6f565b3360009081526035602052604090205460ff1615156001146116365760405162461bcd60e51b8152602060048201526014602482015273556e737570706f7274656420737472617465677960601b6044820152606401610983565b3360009081526049602052604090205460ff1615156001146116955760405162461bcd60e51b81526020600482015260186024820152774e6f742077686974656c697374656420737472617465677960401b6044820152606401610983565b7f0f6798a560793a54c3bcfe86a93cde1e73087d944c0ea20544137d412139688533826040516116c6929190613d84565b60405180910390a1603c546040516340c10f1960e01b81526001600160a01b03909116906340c10f199061119b9033908590600401613d84565b603754600160a81b900460ff161561172a5760405162461bcd60e51b815260040161098390613c6f565b600080516020613f908339815191528054600119810161175c5760405162461bcd60e51b815260040161098390613c97565b60028255611768612219565b50611771612c06565b5060019055565b600080516020613f90833981519152805460011981016117aa5760405162461bcd60e51b815260040161098390613c97565b600282556117b6612e2e565b505060019055565b610bd1612219565b60606036805480602002602001604051908101604052809291908181526020018280548015610a2f576020028201919060005260206000209081546001600160a01b03168152600190910190602001808311610a11575050505050905090565b600061183e600080516020613fd08339815191525490565b6001600160a01b0316336001600160a01b031614905090565b61185f611826565b61187b5760405162461bcd60e51b815260040161098390613d0e565b6118a3817f44c4d30b2eaad5130ad70c3ba6972730566f3e6359ab83e800d905c61b1c51db55565b806001600160a01b03166118c3600080516020613fd08339815191525490565b6001600160a01b03167fa39cc5eb22d0f34d8beaefee8a3f17cc229c1a1d1ef87a5ad47313487b1c4f0d60405160405180910390a350565b60006109546131c8565b600061198e603c60009054906101000a90046001600160a01b03166001600160a01b03166318160ddd6040518163ffffffff1660e01b8152600401602060405180830381865afa15801561195d573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906119819190613d9d565b6119896131c8565b6131f3565b50919050565b603754600090600160a81b900460ff16156119c15760405162461bcd60e51b815260040161098390613c6f565b600080516020613f90833981519152805460011981016119f35760405162461bcd60e51b815260040161098390613c97565b60028255604b546000858152604d60205260409020600101546001600160801b03600160801b92839004811692909104161115611a3457611a32612219565b505b611a3d846123f5565b9250611a736001600160a01b037f000000000000000000000000039e2fb66102314ce7b64ce5ce3e5183bc94ad381633856126eb565b611a7c83612741565b5060019055919050565b611a8e611826565b611aaa5760405162461bcd60e51b815260040161098390613d0e565b803b611b045760405162461bcd60e51b8152602060048201526024808201527f6e657720696d706c656d656e746174696f6e206973206e6f74206120636f6e746044820152631c9858dd60e21b6064820152608401610983565b600080516020613fb083398151915255565b7f000000000000000000000000039e2fb66102314ce7b64ce5ce3e5183bc94ad386001600160a01b0316836001600160a01b031614611b975760405162461bcd60e51b815260206004820152601d60248201527f556e737570706f7274656420617373657420666f72206d696e74696e670000006044820152606401610983565b60008211611be75760405162461bcd60e51b815260206004820152601d60248201527f416d6f756e74206d7573742062652067726561746572207468616e20300000006044820152606401610983565b80821015611c375760405162461bcd60e51b815260206004820152601e60248201527f4d696e7420616d6f756e74206c6f776572207468616e206d696e696d756d00006044820152606401610983565b7f0f6798a560793a54c3bcfe86a93cde1e73087d944c0ea20544137d41213968853383604051611c68929190613d84565b60405180910390a1603754600160a01b900460ff16158015611c8c5750603b548210155b15611c9b57611c99612e2e565b505b603c546040516340c10f1960e01b81526001600160a01b03909116906340c10f1990611ccd9033908690600401613d84565b600060405180830381600087803b158015611ce757600080fd5b505af1158015611cfb573d6000803e3d6000fd5b50611d15925050506001600160a01b0384163330856133c6565b611d1d612219565b50603a548210610df057610df0612c06565b6001600160a01b03811660009081526033602052604090205462010000900460ff1680611d945760405162461bcd60e51b8152602060048201526013602482015272111958da5b585b1cc81b9bdd0818d858da1959606a1b6044820152606401610983565b919050565b600081831115611dc957611dc2611db08385613db6565b611dbb90600a613eb0565b8590613404565b9350611df3565b81831015611df357611df0611dde8484613db6565b611de990600a613eb0565b8590613410565b93505b509192915050565b6001600160a01b038116600090815260336020526040812054610100900460ff1681816001811115611e2f57611e2f613be1565b03611e5257611e4a6012611e4285611d2f565b869190611d99565b915050611046565b6001816001811115611e6657611e66613be1565b03611ef7576000836001600160a01b031663e6aa216c6040518163ffffffff1660e01b8152600401602060405180830381865afa158015611eab573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611ecf9190613d9d565b9050670de0b6b3a7640000611ee48287613cd5565b611eee9190613cec565b92505050611046565b60405162461bcd60e51b815260206004820152601b60248201527f556e737570706f7274656420636f6e76657273696f6e207479706500000000006044820152606401610983565b5092915050565b6001600160a01b038281166000818152603360205260408082205460375491516315d5220f60e31b81526004810194909452919361010090920460ff169291169063aea9107890602401602060405180830381865afa158015611fad573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611fd19190613d9d565b91506001816001811115611fe757611fe7613be1565b03612077576000846001600160a01b031663e6aa216c6040518163ffffffff1660e01b8152600401602060405180830381865afa15801561202c573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906120509190613d9d565b90508061206584670de0b6b3a7640000613cd5565b61206f9190613cec565b9250506120d8565b600081600181111561208b5761208b613be1565b146120d85760405162461bcd60e51b815260206004820152601b60248201527f556e737570706f7274656420636f6e76657273696f6e207479706500000000006044820152606401610983565b67120a871cc00200008211156121305760405162461bcd60e51b815260206004820152601860248201527f5661756c743a2050726963652065786365656473206d617800000000000000006044820152606401610983565b6709b6e64a8ec600008210156121815760405162461bcd60e51b81526020600482015260166024820152752b30bab63a1d10283934b1b2903ab73232b91036b4b760511b6044820152606401610983565b82156121f857670de0b6b3a76400008211156121a357670de0b6b3a764000091505b670dd99bb65dd700008210156121f35760405162461bcd60e51b815260206004820152601560248201527441737365742070726963652062656c6f772070656760581b6044820152606401610983565b611f3f565b670de0b6b3a7640000821015611f3f5750670de0b6b3a76400009392505050565b60408051608081018252604b546001600160801b03808216808452600160801b92839004821660208501819052604c548084169686019690965292909404166060830152600092839161226b91613ebc565b6001600160801b03169050806000036122875760009250505090565b6040516370a0823160e01b81523060048201526000907f000000000000000000000000039e2fb66102314ce7b64ce5ce3e5183bc94ad386001600160a01b0316906370a0823190602401602060405180830381865afa1580156122ee573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906123129190613d9d565b905060008360400151846020015161232a9190613ebc565b6001600160801b0316905080821161234757600094505050505090565b60006123538284613db6565b90508084106123625780612364565b835b955060008686602001516001600160801b03166123819190613d71565b905061238c81612b99565b604b80546001600160801b03928316600160801b0292169190911790556040517fee79a0c43d3993055690b54e074b5153e8bae8d1a872b656dedb64aa8f463333906123e49083908a90918252602082015260400190565b60405180910390a150505050505090565b600080604e54116124485760405162461bcd60e51b815260206004820152601d60248201527f4173796e63207769746864726177616c73206e6f7420656e61626c65640000006044820152606401610983565b6000828152604d6020908152604091829020825160a08101845281546001600160a01b038116825260ff600160a01b82041615158285015264ffffffffff600160a81b90910481168286019081526001909301546001600160801b03808216606080860191909152600160801b92839004821660808087019190915288519081018952604b548084168252849004831697810197909752604c54808316988801989098529190960490951694840194909452604e5491519093429261250f92909116613d71565b11156125535760405162461bcd60e51b815260206004820152601360248201527210db185a5b4819195b185e481b9bdd081b595d606a1b6044820152606401610983565b80602001516001600160801b031682608001516001600160801b031611156125bd5760405162461bcd60e51b815260206004820152601760248201527f51756575652070656e64696e67206c69717569646974790000000000000000006044820152606401610983565b81516001600160a01b031633146126065760405162461bcd60e51b815260206004820152600d60248201526c2737ba103932b8bab2b9ba32b960991b6044820152606401610983565b60208201511561264a5760405162461bcd60e51b815260206004820152600f60248201526e105b1c9958591e4818db185a5b5959608a1b6044820152606401610983565b6000848152604d602052604090819020805460ff60a01b1916600160a01b17905560608301519082015161267e9190613edb565b604c80546001600160801b0319166001600160801b03928316179055606083015160405191168152849033907f2d43eb174787155132b52ddb6b346e2dca99302eac3df4466dbeff953d3c84d19060200160405180910390a350606001516001600160801b031692915050565b610df08363a9059cbb60e01b848460405160240161270a929190613d84565b60408051601f198184030181529190526020810180516001600160e01b03166001600160e01b03199093169290921790915261341c565b6000603b54821015801561275f5750603754600160a01b900460ff16155b156127735761276c612e2e565b905061277e565b61277b6131c8565b90505b604154156128e457600081116127d65760405162461bcd60e51b815260206004820152601d60248201527f546f6f206d616e79206f75747374616e64696e672072657175657374730000006044820152606401610983565b600061285982603c60009054906101000a90046001600160a01b03166001600160a01b03166318160ddd6040518163ffffffff1660e01b8152600401602060405180830381865afa15801561282f573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906128539190613d9d565b906134ee565b9050604154670de0b6b3a764000082116128845761287f82670de0b6b3a7640000613db6565b612896565b612896670de0b6b3a764000083613db6565b1115610df05760405162461bcd60e51b815260206004820152601e60248201527f4261636b696e6720737570706c79206c6971756964697479206572726f7200006044820152606401610983565b5050565b6001600160a01b03811661293e5760405162461bcd60e51b815260206004820152601a60248201527f4e657720476f7665726e6f7220697320616464726573732830290000000000006044820152606401610983565b610bd181613517565b60007f000000000000000000000000039e2fb66102314ce7b64ce5ce3e5183bc94ad386001600160a01b0316826001600160a01b03161461298a57506000919050565b6129938261357e565b60408051608081018252604b546001600160801b03808216808452600160801b9283900482166020850152604c548083169585018690529290920416606083015292935091906129e39084613d71565b10156129f25750600092915050565b805160408201516001600160801b0391821691612a10911684613d71565b610a8d9190613db6565b60385460609015612a4957603854600090612a39908490612710613718565b9050612a458184613db6565b9250505b6000607b5490507f000000000000000000000000039e2fb66102314ce7b64ce5ce3e5183bc94ad386001600160a01b031660348281548110612a8d57612a8d613d45565b6000918252602090912001546001600160a01b031614612aef5760405162461bcd60e51b815260206004820152601b60248201527f5745544820417373657420696e646578206e6f742063616368656400000000006044820152606401610983565b6034546001600160401b03811115612b0957612b09613d5b565b604051908082528060200260200182016040528015612b32578160200160208202803683370190505b50915082828281518110612b4857612b48613d45565b60200260200101818152505050919050565b60405162461bcd60e51b81526020600482015260146024820152733ab739bab83837b93a32b210333ab731ba34b7b760611b6044820152606401610983565b60006001600160801b03821115612c025760405162461bcd60e51b815260206004820152602760248201527f53616665436173743a2076616c756520646f65736e27742066697420696e20316044820152663238206269747360c81b6064820152608401610983565b5090565b6001600160a01b037f000000000000000000000000039e2fb66102314ce7b64ce5ce3e5183bc94ad3881166000908152604060208190529020541680612c495750565b6000612c5361373a565b905080600003612c61575050565b603c54604080516318160ddd60e01b815290516000926001600160a01b0316916318160ddd9160048083019260209291908290030181865afa158015612cab573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612ccf9190613d9d565b90506000612ce86039548361384890919063ffffffff16565b9050808311612cf75750505050565b6000612d038285613db6565b905084612d3a6001600160a01b037f000000000000000000000000039e2fb66102314ce7b64ce5ce3e5183bc94ad381682846126eb565b6040516311f9fbc960e21b81526001600160a01b038216906347e7ef2490612d88907f000000000000000000000000039e2fb66102314ce7b64ce5ce3e5183bc94ad38908690600401613d84565b600060405180830381600087803b158015612da257600080fd5b505af1158015612db6573d6000803e3d6000fd5b5050604080516001600160a01b037f000000000000000000000000039e2fb66102314ce7b64ce5ce3e5183bc94ad38811682528a1660208201529081018590527f41b99659f6ba0803f444aff29e5bf6e26dd86a3219aff92119d69710a956ba8d9250606001905060405180910390a1505050505050565b603754600090600160a01b900460ff1615612e7d5760405162461bcd60e51b815260206004820152600f60248201526e149958985cda5b99c81c185d5cd959608a1b6044820152606401610983565b603c54604080516318160ddd60e01b815290516000926001600160a01b0316916318160ddd9160048083019260209291908290030181865afa158015612ec7573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612eeb9190613d9d565b90506000612ef76131c8565b905081600003612f0a5791506131c59050565b600080612f1784846131f3565b90925090506000612f288386613d71565b90508481111580612f3857508381115b15612f47575091949350505050565b612f58826001600160401b0361385d565b604f805477ffffffffffffffffffffffffffffffff000000000000000016600160c01b6001600160401b039384160267ffffffffffffffff19161742929092169190911790556042546001600160a01b0316600081156130945761271060435486612fc39190613cd5565b612fcd9190613cec565b905080156130945784811061302f5760405162461bcd60e51b815260206004820152602260248201527f466565206d757374206e6f742062652067726561746572207468616e207969656044820152611b1960f21b6064820152608401610983565b603c546040516340c10f1960e01b81526001600160a01b03909116906340c10f19906130619085908590600401613d84565b600060405180830381600087803b15801561307b57600080fd5b505af115801561308f573d6000803e3d6000fd5b505050505b604080516001600160a01b0384168152602081018790529081018290527f09516ecf4a8a86e59780a9befc6dee948bc9e60a36e3be68d31ea817ee8d2c809060600160405180910390a1603c60009054906101000a90046001600160a01b03166001600160a01b03166318160ddd6040518163ffffffff1660e01b8152600401602060405180830381865afa158015613131573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906131559190613d9d565b8311156131bb57603c546040516339a7919f60e01b8152600481018590526001600160a01b03909116906339a7919f90602401600060405180830381600087803b1580156131a257600080fd5b505af11580156131b6573d6000803e3d6000fd5b505050505b5093955050505050505b90565b60006109547f000000000000000000000000039e2fb66102314ce7b64ce5ce3e5183bc94ad38612947565b6000806000603c60009054906101000a90046001600160a01b03166001600160a01b031663e696393a6040518163ffffffff1660e01b8152600401602060405180830381865afa15801561324b573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061326f9190613d9d565b9050600061327d8287613db6565b604f54909150600090613299906001600160401b031642613db6565b604f54600160c01b90046001600160401b0316945090508015806132bb575081155b806132c557508587115b806132d757506001600160401b034210155b156132e857600094505050506133bf565b6132f28787613db6565b604f54909550600160401b90046001600160401b031660018111156133575761332f85613320836002613cd5565b61332a9089613cec565b613873565b94506133448561333f8389613cec565b61385d565b94506133548661333f8488613cd5565b95505b604f54613398908790670de0b6b3a764000090600160801b90046001600160401b03166133848688613cd5565b61338e9190613cd5565b61333f9190613cec565b95506133b886670de0b6b3a764000061338e66470de4df82000087613cd5565b9550505050505b9250929050565b6040516001600160a01b03808516602483015283166044820152606481018290526133fe9085906323b872dd60e01b9060840161270a565b50505050565b6000610a8d8284613cd5565b6000610a8d8284613cec565b6000613471826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b03166138829092919063ffffffff16565b805190915015610df0578080602001905181019061348f9190613efa565b610df05760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b6064820152608401610983565b60008061350384670de0b6b3a7640000613404565b905061350f8184613410565b949350505050565b806001600160a01b0316613537600080516020613fd08339815191525490565b6001600160a01b03167fc7c0c772add429241571afb3805861fb3cfa2af374534088b76cdb4325a87e9a60405160405180910390a3600080516020613fd083398151915255565b6040516370a0823160e01b815230600482015260009082906001600160a01b038216906370a0823190602401602060405180830381865afa1580156135c7573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906135eb9190613d9d565b60365490925060005b818110156137105760006036828154811061361157613611613d45565b60009182526020909120015460405163551c457b60e11b81526001600160a01b0388811660048301529091169150819063aa388af690602401602060405180830381865afa158015613667573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061368b9190613efa565b1561370757604051632fa8a91360e11b81526001600160a01b038781166004830152821690635f51522690602401602060405180830381865afa1580156136d6573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906136fa9190613d9d565b6137049086613d71565b94505b506001016135f4565b505050919050565b6000806137258585613404565b90506137318184613410565b95945050505050565b60408051608081018252604b546001600160801b03808216808452600160801b9283900482166020850152604c5480831695850186905292909204166060830152600092839161378a9190613ebc565b6040516370a0823160e01b81523060048201526001600160801b039190911691506000906001600160a01b037f000000000000000000000000039e2fb66102314ce7b64ce5ce3e5183bc94ad3816906370a0823190602401602060405180830381865afa1580156137ff573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906138239190613d9d565b9050818111613836576000935050505090565b6138408282613db6565b935050505090565b6000610a8d8383670de0b6b3a7640000613718565b600081831061386c5781610a8d565b5090919050565b600081831161386c5781610a8d565b606061350f848460008585843b6138db5760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000006044820152606401610983565b600080866001600160a01b031685876040516138f79190613f40565b60006040518083038185875af1925050503d8060008114613934576040519150601f19603f3d011682016040523d82523d6000602084013e613939565b606091505b5091509150613949828286613954565b979650505050505050565b60608315613963575081610a8d565b8251156139735782518084602001fd5b8160405162461bcd60e51b81526004016109839190613f5c565b8280548282559060005260206000209081019282156139e2579160200282015b828111156139e257825182546001600160a01b0319166001600160a01b039091161782556020909201916001909101906139ad565b50612c029291505b80821115612c0257600081556001016139ea565b80356001600160a01b0381168114611d9457600080fd5b600080600060608486031215613a2a57600080fd5b613a33846139fe565b95602085013595506040909401359392505050565b602080825282518282018190526000918401906040840190835b81811015613a895783516001600160a01b0316835260209384019390920191600101613a62565b509095945050505050565b600060208284031215613aa657600080fd5b610a8d826139fe565b60008060408385031215613ac257600080fd5b613acb836139fe565b9150613ad9602084016139fe565b90509250929050565b60008060208385031215613af557600080fd5b82356001600160401b03811115613b0b57600080fd5b8301601f81018513613b1c57600080fd5b80356001600160401b03811115613b3257600080fd5b8560208260051b8401011115613b4757600080fd5b6020919091019590945092505050565b600081518084526020840193506020830160005b82811015613b89578151865260209586019590910190600101613b6b565b5093949350505050565b604081526000613ba66040830185613b57565b90508260208301529392505050565b600060208284031215613bc757600080fd5b5035919050565b602081526000610a8d6020830184613b57565b634e487b7160e01b600052602160045260246000fd5b8151151581526020820151608082019060028110613c2557634e487b7160e01b600052602160045260246000fd5b8060208401525060ff604084015116604083015261ffff606084015116606083015292915050565b60008060408385031215613c6057600080fd5b50508035926020909101359150565b6020808252600e908201526d10d85c1a5d185b081c185d5cd95960921b604082015260600190565b6020808252600e908201526d1499595b9d1c985b9d0818d85b1b60921b604082015260600190565b634e487b7160e01b600052601160045260246000fd5b808202811582820484141761104657611046613cbf565b600082613d0957634e487b7160e01b600052601260045260246000fd5b500490565b6020808252601a908201527f43616c6c6572206973206e6f742074686520476f7665726e6f72000000000000604082015260600190565b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052604160045260246000fd5b8082018082111561104657611046613cbf565b6001600160a01b03929092168252602082015260400190565b600060208284031215613daf57600080fd5b5051919050565b8181038181111561104657611046613cbf565b6001815b6001841115613e0457808504811115613de857613de8613cbf565b6001841615613df657908102905b60019390931c928002613dcd565b935093915050565b600082613e1b57506001611046565b81613e2857506000611046565b8160018114613e3e5760028114613e4857613e64565b6001915050611046565b60ff841115613e5957613e59613cbf565b50506001821b611046565b5060208310610133831016604e8410600b8410161715613e87575081810a611046565b613e946000198484613dc9565b8060001904821115613ea857613ea8613cbf565b029392505050565b6000610a8d8383613e0c565b6001600160801b03828116828216039081111561104657611046613cbf565b6001600160801b03818116838216019081111561104657611046613cbf565b600060208284031215613f0c57600080fd5b81518015158114610a8d57600080fd5b60005b83811015613f37578181015183820152602001613f1f565b50506000910152565b60008251613f52818460208701613f1c565b9190910192915050565b6020815260008251806020840152613f7b816040850160208701613f1c565b601f01601f1916919091016040019291505056fe53bf423e48ed90e97d02ab0ebab13b2a235a6bfbe9c321847d5c175333ac4535a2bd3d3cf188a41358c8b401076eb59066b09dec5775650c0de4c55187d17bd97bea13895fa79d2831e0a9e28edede30099005a50d652d8957cf8a607ee6ca4aa264697066735822122021757e4dbbe98fdb828aa00baa2e77cb03e155b9c7fe812fb48e73f1e3d1728b64736f6c634300081c0033
Constructor Arguments (ABI-Encoded and is the last bytes of the Contract Creation Code above)
000000000000000000000000039e2fb66102314ce7b64ce5ce3e5183bc94ad38
-----Decoded View---------------
Arg [0] : _wS (address): 0x039e2fB66102314Ce7b64Ce5Ce3E5183bc94aD38
-----Encoded View---------------
1 Constructor Arguments found :
Arg [0] : 000000000000000000000000039e2fb66102314ce7b64ce5ce3e5183bc94ad38
Loading...
Loading
Loading...
Loading
Loading...
Loading
Net Worth in USD
$0.00
Net Worth in S
Multichain Portfolio | 35 Chains
| Chain | Token | Portfolio % | Price | Amount | Value |
|---|
Loading...
Loading
Loading...
Loading
Loading...
Loading
A contract address hosts a smart contract, which is a set of code stored on the blockchain that runs when predetermined conditions are met. Learn more about addresses in our Knowledge Base.