Source Code
Overview
ETH Balance
ETH Value
$0.00| Transaction Hash |
|
Block
|
From
|
To
|
|||||
|---|---|---|---|---|---|---|---|---|---|
Latest 25 internal transactions (View All)
Advanced mode:
| Parent Transaction Hash | Block | From | To | |||
|---|---|---|---|---|---|---|
| 23031693 | 149 days ago | 0 ETH | ||||
| 16017127 | 348 days ago | 0 ETH | ||||
| 16017124 | 348 days ago | 0 ETH | ||||
| 16017122 | 348 days ago | 0 ETH | ||||
| 16017119 | 348 days ago | 0 ETH | ||||
| 16017117 | 348 days ago | 0 ETH | ||||
| 16013743 | 349 days ago | 0.00027648 ETH | ||||
| 16013563 | 349 days ago | 0.00027648 ETH | ||||
| 16013382 | 349 days ago | 0.00027648 ETH | ||||
| 16003651 | 349 days ago | 0.00027652 ETH | ||||
| 16001874 | 349 days ago | 0.00027958 ETH | ||||
| 15980896 | 349 days ago | 0.00028648 ETH | ||||
| 15959884 | 350 days ago | 0.0002819 ETH | ||||
| 15904630 | 351 days ago | 0.00028032 ETH | ||||
| 15893533 | 351 days ago | 0.00027845 ETH | ||||
| 15887172 | 352 days ago | 0.00027705 ETH | ||||
| 15876789 | 352 days ago | 0.00027854 ETH | ||||
| 15876305 | 352 days ago | 0.00027854 ETH | ||||
| 15876167 | 352 days ago | 0.00027854 ETH | ||||
| 15876022 | 352 days ago | 0.00027854 ETH | ||||
| 15875883 | 352 days ago | 0.00027854 ETH | ||||
| 15875762 | 352 days ago | 0.00027854 ETH | ||||
| 15847152 | 353 days ago | 0.00027774 ETH | ||||
| 15841817 | 353 days ago | 0.00027482 ETH | ||||
| 15825253 | 353 days ago | 0.00027087 ETH |
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:
SharesCollateral
Compiler Version
v0.8.20+commit.a1b79de6
Optimization Enabled:
Yes with 1 runs
Other Settings:
paris EvmVersion
Contract Source Code (Solidity Standard Json-Input format)
pragma solidity ^0.8.4;
import "@openzeppelin/contracts-upgradeable/proxy/utils/UUPSUpgradeable.sol";
import "@openzeppelin/contracts-upgradeable/utils/cryptography/ECDSAUpgradeable.sol";
import {IERC20Metadata} from "./deps/OpenZeppelinV5/IERC20Metadata.sol";
import {SafeERC20} from "./deps/OpenZeppelinV5/SafeERC20.sol";
import "./interfaces/IReceiptNFT.sol";
import "./interfaces/IRegistry.sol";
import "./interfaces/IRouterAdmin.sol";
import "./interfaces/ISharesToken.sol";
import "./interfaces/IStrategyRouter.sol";
import "./interfaces/IExchange.sol";
import "./interfaces/IUsdOracle.sol";
import {toUniform, fromUniform, MAX_BPS} from "./lib/Math.sol";
import {TokenPrice} from "./lib/Structs.sol";
contract SharesCollateral is UUPSUpgradeable {
using ECDSAUpgradeable for bytes32;
using SafeERC20 for IERC20Metadata;
address internal immutable signer;
IRouterAdmin internal immutable admin;
IReceiptNFT internal immutable receiptContract;
ISharesToken internal immutable sharesToken;
IStrategyRouter internal immutable strategyRouter;
IExchange internal immutable exchange;
IUsdOracle internal immutable oracle;
uint256 public maxSlippageToWithdrawInBps;
struct SwapData {
address token; // token address
bool isDeposit; // true for deposit, false for withdraw
uint256 amountIn; // amount of tokens or shares to swap
uint256 amountOut; // amount of shares or tokens to receive
uint256 deadline; // deadline for swap
uint256 fee; // deadline for swap
bytes signature; // signature of swap data
}
constructor(
address _signer,
ISharesToken _sharesToken,
IReceiptNFT _receiptContract,
IRouterAdmin _admin,
IStrategyRouter _strategyRouter,
IExchange _exchange,
IUsdOracle _oracle
) {
signer = _signer;
sharesToken = _sharesToken;
receiptContract = _receiptContract;
admin = _admin;
strategyRouter = _strategyRouter;
exchange = _exchange;
oracle = _oracle;
// lock implementation
_disableInitializers();
}
modifier onlyAdmin() {
if (address(admin) != msg.sender) revert Unauthorized();
_;
}
modifier onlySignerOrAdmin() {
if (signer != msg.sender && address(admin) != msg.sender) revert Unauthorized();
_;
}
function initialize(bytes memory initializeData) external initializer {
__UUPSUpgradeable_init();
}
function _authorizeUpgrade(address newImplementation) internal override onlyAdmin {}
function swapShares(SwapData calldata swapData, bytes32 referral) external payable {
_swapShares(swapData);
emit SwapShares(
msg.sender,
swapData.token,
swapData.isDeposit,
swapData.amountIn,
swapData.amountOut,
swapData.fee,
referral
);
}
function convertNFTAndSwapShares(SwapData calldata swapData, uint256[] calldata receiptIds) external payable {
for (uint256 i = 0; i < receiptIds.length; i++) {
if (receiptContract.ownerOf(receiptIds[i]) != msg.sender) revert NotReceiptOwner();
}
// If receiptIds is not empty, redeem them to shares
if (receiptIds.length > 0) admin.redeemReceiptsToSharesByModerators(receiptIds);
_swapShares(swapData);
emit ConvertNFTAndSwapShares(
msg.sender,
receiptIds,
swapData.token,
swapData.isDeposit,
swapData.amountIn,
swapData.amountOut,
swapData.fee
);
}
function _swapShares(SwapData calldata swapData) internal {
// check that deadline is not passed
if (swapData.deadline < block.timestamp) revert Stale();
if (swapData.fee > msg.value) revert NotEnoughFee();
// prepare message to check signature
bytes32 message = keccak256(
abi.encodePacked(
swapData.token,
swapData.isDeposit,
swapData.amountIn,
swapData.amountOut,
swapData.deadline,
swapData.fee
)
).toEthSignedMessageHash();
address signer_ = message.recover(swapData.signature);
if (signer_ != signer) revert BadSignature();
if (swapData.isDeposit) {
IERC20Metadata(swapData.token).safeTransferFrom(msg.sender, address(this), swapData.amountIn);
if (sharesToken.balanceOf(address(this)) < swapData.amountOut) revert NotEnoughShares();
sharesToken.transfer(msg.sender, swapData.amountOut);
} else {
sharesToken.transferFromAutoApproved(msg.sender, address(this), swapData.amountIn);
if (IERC20Metadata(swapData.token).balanceOf(address(this)) < swapData.amountOut) revert NotEnoughTokens();
IERC20Metadata(swapData.token).safeTransfer(msg.sender, swapData.amountOut);
}
}
function swapTokens(
uint256 amountIn,
address tokenIn,
address tokenOut
) external onlySignerOrAdmin returns (uint256 amountOut) {
if (amountIn == 0) return 0;
IERC20Metadata token = IERC20Metadata(tokenIn);
if (amountIn > token.balanceOf(address(this))) revert NotEnoughTokens();
// transfer tokens to exchange
token.safeTransfer(address(exchange), amountIn);
// swap tokens
amountOut = exchange.stablecoinSwap(
amountIn,
tokenIn,
tokenOut,
address(this), // receiver
getOraclePrice(tokenIn),
getOraclePrice(tokenOut)
);
}
function depositStablesAndConvertShares(
address depositToken,
uint256 depositAmount
) external payable onlySignerOrAdmin returns (uint256 shares) {
if (depositAmount == 0) return 0;
IERC20Metadata token = IERC20Metadata(depositToken);
if (depositAmount > token.balanceOf(address(this))) revert NotEnoughTokens();
// deposit tokens to batch via strategy router
strategyRouter.depositToBatch{value: msg.value}(depositToken, depositAmount, "");
// allocate tokens to strategies to close the cycle
strategyRouter.allocateToStrategies();
// prepare array with last minted (during depositToBatch) receipt id
uint256[] memory arrayWithLastReceipt = new uint256[](1);
// get last minted receipt
arrayWithLastReceipt[0] = receiptContract.getReceiptsCounter() - 1;
shares = strategyRouter.redeemReceiptsToShares(arrayWithLastReceipt);
}
function convertSharesToStablesWithWithdrawFromStrategies(
uint256 shares,
address withdrawToken
) external onlySignerOrAdmin returns (uint256 withdrawnAmount) {
if (shares == 0) return 0;
if (shares > sharesToken.balanceOf(address(this))) revert NotEnoughShares();
// calculate min token amount to withdraw
uint256 minTokenAmountToWithdraw = strategyRouter.calculateSharesUsdValue(shares);
TokenPrice memory tokenPrice = getOraclePrice(withdrawToken);
minTokenAmountToWithdraw = (minTokenAmountToWithdraw * 10 ** tokenPrice.priceDecimals) / tokenPrice.price;
minTokenAmountToWithdraw = (minTokenAmountToWithdraw * (MAX_BPS - maxSlippageToWithdrawInBps)) / MAX_BPS;
// adjust decimals of the token amount
minTokenAmountToWithdraw = fromUniform(minTokenAmountToWithdraw, withdrawToken);
uint256 prevBalance = IERC20Metadata(withdrawToken).balanceOf(address(this));
strategyRouter.withdrawFromStrategies(new uint256[](0), withdrawToken, shares, minTokenAmountToWithdraw, true);
withdrawnAmount = IERC20Metadata(withdrawToken).balanceOf(address(this)) - prevBalance;
}
function callTarget(
address _target,
bytes memory _data,
uint256 value
) public payable onlyAdmin returns (bool, bytes memory) {
(bool success, bytes memory result) = _target.call{value: value}(_data);
return (success, result);
}
receive() external payable {}
function collectFee(address _receiver) external onlyAdmin {
(bool success, ) = _receiver.call{value: address(this).balance}("");
require(success, "Transfer failed");
}
function collectERC20(address _receiver, address _erc20Address, uint256 _amount) external onlyAdmin {
IERC20Metadata(_erc20Address).safeTransfer(_receiver, _amount);
}
function setMaxSlippageToWithdrawInBps(uint256 newMaxSlippageInBps) external onlyAdmin {
if (
newMaxSlippageInBps > 1000 // max is 10%
) revert InvalidInput();
maxSlippageToWithdrawInBps = newMaxSlippageInBps;
}
function getOraclePrice(address tokenAddress) internal view returns (TokenPrice memory priceData) {
(uint256 price, uint8 decimals) = oracle.getTokenUsdPrice(tokenAddress);
priceData = TokenPrice({price: price, priceDecimals: decimals, token: tokenAddress});
}
/* ERRORS */
error Unauthorized();
error Stale();
error BadSignature();
error NotEnoughShares();
error NotEnoughTokens();
error NotEnoughFee();
error NotReceiptOwner();
error InvalidInput();
/* EVENTS */
event SwapShares(
address indexed sender,
address token,
bool isDeposit,
uint256 amountIn,
uint256 amountOut,
uint256 fee,
bytes32 referral
);
event ConvertNFTAndSwapShares(
address indexed sender,
uint256[] receiptIds,
address token,
bool isDeposit,
uint256 amountIn,
uint256 amountOut,
uint256 fee
);
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.5.0) (interfaces/draft-IERC1822.sol)
pragma solidity ^0.8.0;
/**
* @dev ERC1822: Universal Upgradeable Proxy Standard (UUPS) documents a method for upgradeability through a simplified
* proxy whose upgrades are fully controlled by the current implementation.
*/
interface IERC1822ProxiableUpgradeable {
/**
* @dev Returns the storage slot that the proxiable contract assumes is being used to store the implementation
* address.
*
* IMPORTANT: A proxy pointing at a proxiable contract should not be considered proxiable itself, because this risks
* bricking a proxy that upgrades to it, by delegating to itself until out of gas. Thus it is critical that this
* function revert if invoked through a proxy.
*/
function proxiableUUID() external view returns (bytes32);
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (interfaces/IERC1967.sol)
pragma solidity ^0.8.0;
/**
* @dev ERC-1967: Proxy Storage Slots. This interface contains the events defined in the ERC.
*
* _Available since v4.8.3._
*/
interface IERC1967Upgradeable {
/**
* @dev Emitted when the implementation is upgraded.
*/
event Upgraded(address indexed implementation);
/**
* @dev Emitted when the admin account has changed.
*/
event AdminChanged(address previousAdmin, address newAdmin);
/**
* @dev Emitted when the beacon is changed.
*/
event BeaconUpgraded(address indexed beacon);
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (proxy/beacon/IBeacon.sol)
pragma solidity ^0.8.0;
/**
* @dev This is the interface that {BeaconProxy} expects of its beacon.
*/
interface IBeaconUpgradeable {
/**
* @dev Must return an address that can be used as a delegate call target.
*
* {BeaconProxy} will check that this address is a contract.
*/
function implementation() external view returns (address);
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (proxy/ERC1967/ERC1967Upgrade.sol)
pragma solidity ^0.8.2;
import "../beacon/IBeaconUpgradeable.sol";
import "../../interfaces/IERC1967Upgradeable.sol";
import "../../interfaces/draft-IERC1822Upgradeable.sol";
import "../../utils/AddressUpgradeable.sol";
import "../../utils/StorageSlotUpgradeable.sol";
import "../utils/Initializable.sol";
/**
* @dev This abstract contract provides getters and event emitting update functions for
* https://eips.ethereum.org/EIPS/eip-1967[EIP1967] slots.
*
* _Available since v4.1._
*/
abstract contract ERC1967UpgradeUpgradeable is Initializable, IERC1967Upgradeable {
function __ERC1967Upgrade_init() internal onlyInitializing {
}
function __ERC1967Upgrade_init_unchained() internal onlyInitializing {
}
// This is the keccak-256 hash of "eip1967.proxy.rollback" subtracted by 1
bytes32 private constant _ROLLBACK_SLOT = 0x4910fdfa16fed3260ed0e7147f7cc6da11a60208b5b9406d12a635614ffd9143;
/**
* @dev Storage slot with the address of the current implementation.
* This is the keccak-256 hash of "eip1967.proxy.implementation" subtracted by 1, and is
* validated in the constructor.
*/
bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;
/**
* @dev Returns the current implementation address.
*/
function _getImplementation() internal view returns (address) {
return StorageSlotUpgradeable.getAddressSlot(_IMPLEMENTATION_SLOT).value;
}
/**
* @dev Stores a new address in the EIP1967 implementation slot.
*/
function _setImplementation(address newImplementation) private {
require(AddressUpgradeable.isContract(newImplementation), "ERC1967: new implementation is not a contract");
StorageSlotUpgradeable.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation;
}
/**
* @dev Perform implementation upgrade
*
* Emits an {Upgraded} event.
*/
function _upgradeTo(address newImplementation) internal {
_setImplementation(newImplementation);
emit Upgraded(newImplementation);
}
/**
* @dev Perform implementation upgrade with additional setup call.
*
* Emits an {Upgraded} event.
*/
function _upgradeToAndCall(address newImplementation, bytes memory data, bool forceCall) internal {
_upgradeTo(newImplementation);
if (data.length > 0 || forceCall) {
AddressUpgradeable.functionDelegateCall(newImplementation, data);
}
}
/**
* @dev Perform implementation upgrade with security checks for UUPS proxies, and additional setup call.
*
* Emits an {Upgraded} event.
*/
function _upgradeToAndCallUUPS(address newImplementation, bytes memory data, bool forceCall) internal {
// Upgrades from old implementations will perform a rollback test. This test requires the new
// implementation to upgrade back to the old, non-ERC1822 compliant, implementation. Removing
// this special case will break upgrade paths from old UUPS implementation to new ones.
if (StorageSlotUpgradeable.getBooleanSlot(_ROLLBACK_SLOT).value) {
_setImplementation(newImplementation);
} else {
try IERC1822ProxiableUpgradeable(newImplementation).proxiableUUID() returns (bytes32 slot) {
require(slot == _IMPLEMENTATION_SLOT, "ERC1967Upgrade: unsupported proxiableUUID");
} catch {
revert("ERC1967Upgrade: new implementation is not UUPS");
}
_upgradeToAndCall(newImplementation, data, forceCall);
}
}
/**
* @dev Storage slot with the admin of the contract.
* This is the keccak-256 hash of "eip1967.proxy.admin" subtracted by 1, and is
* validated in the constructor.
*/
bytes32 internal constant _ADMIN_SLOT = 0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103;
/**
* @dev Returns the current admin.
*/
function _getAdmin() internal view returns (address) {
return StorageSlotUpgradeable.getAddressSlot(_ADMIN_SLOT).value;
}
/**
* @dev Stores a new address in the EIP1967 admin slot.
*/
function _setAdmin(address newAdmin) private {
require(newAdmin != address(0), "ERC1967: new admin is the zero address");
StorageSlotUpgradeable.getAddressSlot(_ADMIN_SLOT).value = newAdmin;
}
/**
* @dev Changes the admin of the proxy.
*
* Emits an {AdminChanged} event.
*/
function _changeAdmin(address newAdmin) internal {
emit AdminChanged(_getAdmin(), newAdmin);
_setAdmin(newAdmin);
}
/**
* @dev The storage slot of the UpgradeableBeacon contract which defines the implementation for this proxy.
* This is bytes32(uint256(keccak256('eip1967.proxy.beacon')) - 1)) and is validated in the constructor.
*/
bytes32 internal constant _BEACON_SLOT = 0xa3f0ad74e5423aebfd80d3ef4346578335a9a72aeaee59ff6cb3582b35133d50;
/**
* @dev Returns the current beacon.
*/
function _getBeacon() internal view returns (address) {
return StorageSlotUpgradeable.getAddressSlot(_BEACON_SLOT).value;
}
/**
* @dev Stores a new beacon in the EIP1967 beacon slot.
*/
function _setBeacon(address newBeacon) private {
require(AddressUpgradeable.isContract(newBeacon), "ERC1967: new beacon is not a contract");
require(
AddressUpgradeable.isContract(IBeaconUpgradeable(newBeacon).implementation()),
"ERC1967: beacon implementation is not a contract"
);
StorageSlotUpgradeable.getAddressSlot(_BEACON_SLOT).value = newBeacon;
}
/**
* @dev Perform beacon upgrade with additional setup call. Note: This upgrades the address of the beacon, it does
* not upgrade the implementation contained in the beacon (see {UpgradeableBeacon-_setImplementation} for that).
*
* Emits a {BeaconUpgraded} event.
*/
function _upgradeBeaconToAndCall(address newBeacon, bytes memory data, bool forceCall) internal {
_setBeacon(newBeacon);
emit BeaconUpgraded(newBeacon);
if (data.length > 0 || forceCall) {
AddressUpgradeable.functionDelegateCall(IBeaconUpgradeable(newBeacon).implementation(), data);
}
}
/**
* @dev This empty reserved space is put in place to allow future versions to add new
* variables without shifting down storage in the inheritance chain.
* See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps
*/
uint256[50] private __gap;
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (proxy/utils/Initializable.sol)
pragma solidity ^0.8.2;
import "../../utils/AddressUpgradeable.sol";
/**
* @dev This is a base contract to aid in writing upgradeable contracts, or any kind of contract that will be deployed
* behind a proxy. Since proxied contracts do not make use of a constructor, it's common to move constructor logic to an
* external initializer function, usually called `initialize`. It then becomes necessary to protect this initializer
* function so it can only be called once. The {initializer} modifier provided by this contract will have this effect.
*
* The initialization functions use a version number. Once a version number is used, it is consumed and cannot be
* reused. This mechanism prevents re-execution of each "step" but allows the creation of new initialization steps in
* case an upgrade adds a module that needs to be initialized.
*
* For example:
*
* [.hljs-theme-light.nopadding]
* ```solidity
* contract MyToken is ERC20Upgradeable {
* function initialize() initializer public {
* __ERC20_init("MyToken", "MTK");
* }
* }
*
* contract MyTokenV2 is MyToken, ERC20PermitUpgradeable {
* function initializeV2() reinitializer(2) public {
* __ERC20Permit_init("MyToken");
* }
* }
* ```
*
* TIP: To avoid leaving the proxy in an uninitialized state, the initializer function should be called as early as
* possible by providing the encoded function call as the `_data` argument to {ERC1967Proxy-constructor}.
*
* CAUTION: When used with inheritance, manual care must be taken to not invoke a parent initializer twice, or to ensure
* that all initializers are idempotent. This is not verified automatically as constructors are by Solidity.
*
* [CAUTION]
* ====
* Avoid leaving a contract uninitialized.
*
* An uninitialized contract can be taken over by an attacker. This applies to both a proxy and its implementation
* contract, which may impact the proxy. To prevent the implementation contract from being used, you should invoke
* the {_disableInitializers} function in the constructor to automatically lock it when it is deployed:
*
* [.hljs-theme-light.nopadding]
* ```
* /// @custom:oz-upgrades-unsafe-allow constructor
* constructor() {
* _disableInitializers();
* }
* ```
* ====
*/
abstract contract Initializable {
/**
* @dev Indicates that the contract has been initialized.
* @custom:oz-retyped-from bool
*/
uint8 private _initialized;
/**
* @dev Indicates that the contract is in the process of being initialized.
*/
bool private _initializing;
/**
* @dev Triggered when the contract has been initialized or reinitialized.
*/
event Initialized(uint8 version);
/**
* @dev A modifier that defines a protected initializer function that can be invoked at most once. In its scope,
* `onlyInitializing` functions can be used to initialize parent contracts.
*
* Similar to `reinitializer(1)`, except that functions marked with `initializer` can be nested in the context of a
* constructor.
*
* Emits an {Initialized} event.
*/
modifier initializer() {
bool isTopLevelCall = !_initializing;
require(
(isTopLevelCall && _initialized < 1) || (!AddressUpgradeable.isContract(address(this)) && _initialized == 1),
"Initializable: contract is already initialized"
);
_initialized = 1;
if (isTopLevelCall) {
_initializing = true;
}
_;
if (isTopLevelCall) {
_initializing = false;
emit Initialized(1);
}
}
/**
* @dev A modifier that defines a protected reinitializer function that can be invoked at most once, and only if the
* contract hasn't been initialized to a greater version before. In its scope, `onlyInitializing` functions can be
* used to initialize parent contracts.
*
* A reinitializer may be used after the original initialization step. This is essential to configure modules that
* are added through upgrades and that require initialization.
*
* When `version` is 1, this modifier is similar to `initializer`, except that functions marked with `reinitializer`
* cannot be nested. If one is invoked in the context of another, execution will revert.
*
* Note that versions can jump in increments greater than 1; this implies that if multiple reinitializers coexist in
* a contract, executing them in the right order is up to the developer or operator.
*
* WARNING: setting the version to 255 will prevent any future reinitialization.
*
* Emits an {Initialized} event.
*/
modifier reinitializer(uint8 version) {
require(!_initializing && _initialized < version, "Initializable: contract is already initialized");
_initialized = version;
_initializing = true;
_;
_initializing = false;
emit Initialized(version);
}
/**
* @dev Modifier to protect an initialization function so that it can only be invoked by functions with the
* {initializer} and {reinitializer} modifiers, directly or indirectly.
*/
modifier onlyInitializing() {
require(_initializing, "Initializable: contract is not initializing");
_;
}
/**
* @dev Locks the contract, preventing any future reinitialization. This cannot be part of an initializer call.
* Calling this in the constructor of a contract will prevent that contract from being initialized or reinitialized
* to any version. It is recommended to use this to lock implementation contracts that are designed to be called
* through proxies.
*
* Emits an {Initialized} event the first time it is successfully executed.
*/
function _disableInitializers() internal virtual {
require(!_initializing, "Initializable: contract is initializing");
if (_initialized != type(uint8).max) {
_initialized = type(uint8).max;
emit Initialized(type(uint8).max);
}
}
/**
* @dev Returns the highest version that has been initialized. See {reinitializer}.
*/
function _getInitializedVersion() internal view returns (uint8) {
return _initialized;
}
/**
* @dev Returns `true` if the contract is currently initializing. See {onlyInitializing}.
*/
function _isInitializing() internal view returns (bool) {
return _initializing;
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (proxy/utils/UUPSUpgradeable.sol)
pragma solidity ^0.8.0;
import "../../interfaces/draft-IERC1822Upgradeable.sol";
import "../ERC1967/ERC1967UpgradeUpgradeable.sol";
import "./Initializable.sol";
/**
* @dev An upgradeability mechanism designed for UUPS proxies. The functions included here can perform an upgrade of an
* {ERC1967Proxy}, when this contract is set as the implementation behind such a proxy.
*
* A security mechanism ensures that an upgrade does not turn off upgradeability accidentally, although this risk is
* reinstated if the upgrade retains upgradeability but removes the security mechanism, e.g. by replacing
* `UUPSUpgradeable` with a custom implementation of upgrades.
*
* The {_authorizeUpgrade} function must be overridden to include access restriction to the upgrade mechanism.
*
* _Available since v4.1._
*/
abstract contract UUPSUpgradeable is Initializable, IERC1822ProxiableUpgradeable, ERC1967UpgradeUpgradeable {
function __UUPSUpgradeable_init() internal onlyInitializing {
}
function __UUPSUpgradeable_init_unchained() internal onlyInitializing {
}
/// @custom:oz-upgrades-unsafe-allow state-variable-immutable state-variable-assignment
address private immutable __self = address(this);
/**
* @dev Check that the execution is being performed through a delegatecall call and that the execution context is
* a proxy contract with an implementation (as defined in ERC1967) pointing to self. This should only be the case
* for UUPS and transparent proxies that are using the current contract as their implementation. Execution of a
* function through ERC1167 minimal proxies (clones) would not normally pass this test, but is not guaranteed to
* fail.
*/
modifier onlyProxy() {
require(address(this) != __self, "Function must be called through delegatecall");
require(_getImplementation() == __self, "Function must be called through active proxy");
_;
}
/**
* @dev Check that the execution is not being performed through a delegate call. This allows a function to be
* callable on the implementing contract but not through proxies.
*/
modifier notDelegated() {
require(address(this) == __self, "UUPSUpgradeable: must not be called through delegatecall");
_;
}
/**
* @dev Implementation of the ERC1822 {proxiableUUID} function. This returns the storage slot used by the
* implementation. It is used to validate the implementation's compatibility when performing an upgrade.
*
* IMPORTANT: A proxy pointing at a proxiable contract should not be considered proxiable itself, because this risks
* bricking a proxy that upgrades to it, by delegating to itself until out of gas. Thus it is critical that this
* function revert if invoked through a proxy. This is guaranteed by the `notDelegated` modifier.
*/
function proxiableUUID() external view virtual override notDelegated returns (bytes32) {
return _IMPLEMENTATION_SLOT;
}
/**
* @dev Upgrade the implementation of the proxy to `newImplementation`.
*
* Calls {_authorizeUpgrade}.
*
* Emits an {Upgraded} event.
*
* @custom:oz-upgrades-unsafe-allow-reachable delegatecall
*/
function upgradeTo(address newImplementation) public virtual onlyProxy {
_authorizeUpgrade(newImplementation);
_upgradeToAndCallUUPS(newImplementation, new bytes(0), false);
}
/**
* @dev Upgrade the implementation of the proxy to `newImplementation`, and subsequently execute the function call
* encoded in `data`.
*
* Calls {_authorizeUpgrade}.
*
* Emits an {Upgraded} event.
*
* @custom:oz-upgrades-unsafe-allow-reachable delegatecall
*/
function upgradeToAndCall(address newImplementation, bytes memory data) public payable virtual onlyProxy {
_authorizeUpgrade(newImplementation);
_upgradeToAndCallUUPS(newImplementation, data, true);
}
/**
* @dev Function that should revert when `msg.sender` is not authorized to upgrade the contract. Called by
* {upgradeTo} and {upgradeToAndCall}.
*
* Normally, this function will use an xref:access.adoc[access control] modifier such as {Ownable-onlyOwner}.
*
* ```solidity
* function _authorizeUpgrade(address) internal override onlyOwner {}
* ```
*/
function _authorizeUpgrade(address newImplementation) internal virtual;
/**
* @dev This empty reserved space is put in place to allow future versions to add new
* variables without shifting down storage in the inheritance chain.
* See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps
*/
uint256[50] private __gap;
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (utils/Address.sol)
pragma solidity ^0.8.1;
/**
* @dev Collection of functions related to the address type
*/
library AddressUpgradeable {
/**
* @dev Returns true if `account` is a contract.
*
* [IMPORTANT]
* ====
* It is unsafe to assume that an address for which this function returns
* false is an externally-owned account (EOA) and not a contract.
*
* Among others, `isContract` will return false for the following
* types of addresses:
*
* - an externally-owned account
* - a contract in construction
* - an address where a contract will be created
* - an address where a contract lived, but was destroyed
*
* Furthermore, `isContract` will also return true if the target contract within
* the same transaction is already scheduled for destruction by `SELFDESTRUCT`,
* which only has an effect at the end of a transaction.
* ====
*
* [IMPORTANT]
* ====
* You shouldn't rely on `isContract` to protect against flash loan attacks!
*
* Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets
* like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract
* constructor.
* ====
*/
function isContract(address account) internal view returns (bool) {
// This method relies on extcodesize/address.code.length, which returns 0
// for contracts in construction, since the code is only stored at the end
// of the constructor execution.
return account.code.length > 0;
}
/**
* @dev Replacement for Solidity's `transfer`: sends `amount` wei to
* `recipient`, forwarding all available gas and reverting on errors.
*
* https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost
* of certain opcodes, possibly making contracts go over the 2300 gas limit
* imposed by `transfer`, making them unable to receive funds via
* `transfer`. {sendValue} removes this limitation.
*
* https://consensys.net/diligence/blog/2019/09/stop-using-soliditys-transfer-now/[Learn more].
*
* IMPORTANT: because control is transferred to `recipient`, care must be
* taken to not create reentrancy vulnerabilities. Consider using
* {ReentrancyGuard} or the
* https://solidity.readthedocs.io/en/v0.8.0/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].
*/
function sendValue(address payable recipient, uint256 amount) internal {
require(address(this).balance >= amount, "Address: insufficient balance");
(bool success, ) = recipient.call{value: amount}("");
require(success, "Address: unable to send value, recipient may have reverted");
}
/**
* @dev Performs a Solidity function call using a low level `call`. A
* plain `call` is an unsafe replacement for a function call: use this
* function instead.
*
* If `target` reverts with a revert reason, it is bubbled up by this
* function (like regular Solidity function calls).
*
* Returns the raw returned data. To convert to the expected return value,
* use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].
*
* Requirements:
*
* - `target` must be a contract.
* - calling `target` with `data` must not revert.
*
* _Available since v3.1._
*/
function functionCall(address target, bytes memory data) internal returns (bytes memory) {
return functionCallWithValue(target, data, 0, "Address: low-level call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with
* `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCall(
address target,
bytes memory data,
string memory errorMessage
) internal returns (bytes memory) {
return functionCallWithValue(target, data, 0, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but also transferring `value` wei to `target`.
*
* Requirements:
*
* - the calling contract must have an ETH balance of at least `value`.
* - the called Solidity function must be `payable`.
*
* _Available since v3.1._
*/
function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) {
return functionCallWithValue(target, data, value, "Address: low-level call with value failed");
}
/**
* @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but
* with `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCallWithValue(
address target,
bytes memory data,
uint256 value,
string memory errorMessage
) internal returns (bytes memory) {
require(address(this).balance >= value, "Address: insufficient balance for call");
(bool success, bytes memory returndata) = target.call{value: value}(data);
return verifyCallResultFromTarget(target, success, returndata, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but performing a static call.
*
* _Available since v3.3._
*/
function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {
return functionStaticCall(target, data, "Address: low-level static call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
* but performing a static call.
*
* _Available since v3.3._
*/
function functionStaticCall(
address target,
bytes memory data,
string memory errorMessage
) internal view returns (bytes memory) {
(bool success, bytes memory returndata) = target.staticcall(data);
return verifyCallResultFromTarget(target, success, returndata, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but performing a delegate call.
*
* _Available since v3.4._
*/
function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {
return functionDelegateCall(target, data, "Address: low-level delegate call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
* but performing a delegate call.
*
* _Available since v3.4._
*/
function functionDelegateCall(
address target,
bytes memory data,
string memory errorMessage
) internal returns (bytes memory) {
(bool success, bytes memory returndata) = target.delegatecall(data);
return verifyCallResultFromTarget(target, success, returndata, errorMessage);
}
/**
* @dev Tool to verify that a low level call to smart-contract was successful, and revert (either by bubbling
* the revert reason or using the provided one) in case of unsuccessful call or if target was not a contract.
*
* _Available since v4.8._
*/
function verifyCallResultFromTarget(
address target,
bool success,
bytes memory returndata,
string memory errorMessage
) internal view returns (bytes memory) {
if (success) {
if (returndata.length == 0) {
// only check isContract if the call was successful and the return data is empty
// otherwise we already know that it was a contract
require(isContract(target), "Address: call to non-contract");
}
return returndata;
} else {
_revert(returndata, errorMessage);
}
}
/**
* @dev Tool to verify that a low level call was successful, and revert if it wasn't, either by bubbling the
* revert reason or using the provided one.
*
* _Available since v4.3._
*/
function verifyCallResult(
bool success,
bytes memory returndata,
string memory errorMessage
) internal pure returns (bytes memory) {
if (success) {
return returndata;
} else {
_revert(returndata, errorMessage);
}
}
function _revert(bytes memory returndata, string memory errorMessage) private pure {
// Look for revert reason and bubble it up if present
if (returndata.length > 0) {
// The easiest way to bubble the revert reason is using memory via assembly
/// @solidity memory-safe-assembly
assembly {
let returndata_size := mload(returndata)
revert(add(32, returndata), returndata_size)
}
} else {
revert(errorMessage);
}
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (utils/cryptography/ECDSA.sol)
pragma solidity ^0.8.0;
import "../StringsUpgradeable.sol";
/**
* @dev Elliptic Curve Digital Signature Algorithm (ECDSA) operations.
*
* These functions can be used to verify that a message was signed by the holder
* of the private keys of a given address.
*/
library ECDSAUpgradeable {
enum RecoverError {
NoError,
InvalidSignature,
InvalidSignatureLength,
InvalidSignatureS,
InvalidSignatureV // Deprecated in v4.8
}
function _throwError(RecoverError error) private pure {
if (error == RecoverError.NoError) {
return; // no error: do nothing
} else if (error == RecoverError.InvalidSignature) {
revert("ECDSA: invalid signature");
} else if (error == RecoverError.InvalidSignatureLength) {
revert("ECDSA: invalid signature length");
} else if (error == RecoverError.InvalidSignatureS) {
revert("ECDSA: invalid signature 's' value");
}
}
/**
* @dev Returns the address that signed a hashed message (`hash`) with
* `signature` or error string. This address can then be used for verification purposes.
*
* The `ecrecover` EVM opcode allows for malleable (non-unique) signatures:
* this function rejects them by requiring the `s` value to be in the lower
* half order, and the `v` value to be either 27 or 28.
*
* IMPORTANT: `hash` _must_ be the result of a hash operation for the
* verification to be secure: it is possible to craft signatures that
* recover to arbitrary addresses for non-hashed data. A safe way to ensure
* this is by receiving a hash of the original message (which may otherwise
* be too long), and then calling {toEthSignedMessageHash} on it.
*
* Documentation for signature generation:
* - with https://web3js.readthedocs.io/en/v1.3.4/web3-eth-accounts.html#sign[Web3.js]
* - with https://docs.ethers.io/v5/api/signer/#Signer-signMessage[ethers]
*
* _Available since v4.3._
*/
function tryRecover(bytes32 hash, bytes memory signature) internal pure returns (address, RecoverError) {
if (signature.length == 65) {
bytes32 r;
bytes32 s;
uint8 v;
// ecrecover takes the signature parameters, and the only way to get them
// currently is to use assembly.
/// @solidity memory-safe-assembly
assembly {
r := mload(add(signature, 0x20))
s := mload(add(signature, 0x40))
v := byte(0, mload(add(signature, 0x60)))
}
return tryRecover(hash, v, r, s);
} else {
return (address(0), RecoverError.InvalidSignatureLength);
}
}
/**
* @dev Returns the address that signed a hashed message (`hash`) with
* `signature`. This address can then be used for verification purposes.
*
* The `ecrecover` EVM opcode allows for malleable (non-unique) signatures:
* this function rejects them by requiring the `s` value to be in the lower
* half order, and the `v` value to be either 27 or 28.
*
* IMPORTANT: `hash` _must_ be the result of a hash operation for the
* verification to be secure: it is possible to craft signatures that
* recover to arbitrary addresses for non-hashed data. A safe way to ensure
* this is by receiving a hash of the original message (which may otherwise
* be too long), and then calling {toEthSignedMessageHash} on it.
*/
function recover(bytes32 hash, bytes memory signature) internal pure returns (address) {
(address recovered, RecoverError error) = tryRecover(hash, signature);
_throwError(error);
return recovered;
}
/**
* @dev Overload of {ECDSA-tryRecover} that receives the `r` and `vs` short-signature fields separately.
*
* See https://eips.ethereum.org/EIPS/eip-2098[EIP-2098 short signatures]
*
* _Available since v4.3._
*/
function tryRecover(bytes32 hash, bytes32 r, bytes32 vs) internal pure returns (address, RecoverError) {
bytes32 s = vs & bytes32(0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff);
uint8 v = uint8((uint256(vs) >> 255) + 27);
return tryRecover(hash, v, r, s);
}
/**
* @dev Overload of {ECDSA-recover} that receives the `r and `vs` short-signature fields separately.
*
* _Available since v4.2._
*/
function recover(bytes32 hash, bytes32 r, bytes32 vs) internal pure returns (address) {
(address recovered, RecoverError error) = tryRecover(hash, r, vs);
_throwError(error);
return recovered;
}
/**
* @dev Overload of {ECDSA-tryRecover} that receives the `v`,
* `r` and `s` signature fields separately.
*
* _Available since v4.3._
*/
function tryRecover(bytes32 hash, uint8 v, bytes32 r, bytes32 s) internal pure returns (address, RecoverError) {
// EIP-2 still allows signature malleability for ecrecover(). Remove this possibility and make the signature
// unique. Appendix F in the Ethereum Yellow paper (https://ethereum.github.io/yellowpaper/paper.pdf), defines
// the valid range for s in (301): 0 < s < secp256k1n ÷ 2 + 1, and for v in (302): v ∈ {27, 28}. Most
// signatures from current libraries generate a unique signature with an s-value in the lower half order.
//
// If your library generates malleable signatures, such as s-values in the upper range, calculate a new s-value
// with 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEBAAEDCE6AF48A03BBFD25E8CD0364141 - s1 and flip v from 27 to 28 or
// vice versa. If your library also generates signatures with 0/1 for v instead 27/28, add 27 to v to accept
// these malleable signatures as well.
if (uint256(s) > 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF5D576E7357A4501DDFE92F46681B20A0) {
return (address(0), RecoverError.InvalidSignatureS);
}
// If the signature is valid (and not malleable), return the signer address
address signer = ecrecover(hash, v, r, s);
if (signer == address(0)) {
return (address(0), RecoverError.InvalidSignature);
}
return (signer, RecoverError.NoError);
}
/**
* @dev Overload of {ECDSA-recover} that receives the `v`,
* `r` and `s` signature fields separately.
*/
function recover(bytes32 hash, uint8 v, bytes32 r, bytes32 s) internal pure returns (address) {
(address recovered, RecoverError error) = tryRecover(hash, v, r, s);
_throwError(error);
return recovered;
}
/**
* @dev Returns an Ethereum Signed Message, created from a `hash`. This
* produces hash corresponding to the one signed with the
* https://eth.wiki/json-rpc/API#eth_sign[`eth_sign`]
* JSON-RPC method as part of EIP-191.
*
* See {recover}.
*/
function toEthSignedMessageHash(bytes32 hash) internal pure returns (bytes32 message) {
// 32 is the length in bytes of hash,
// enforced by the type signature above
/// @solidity memory-safe-assembly
assembly {
mstore(0x00, "\x19Ethereum Signed Message:\n32")
mstore(0x1c, hash)
message := keccak256(0x00, 0x3c)
}
}
/**
* @dev Returns an Ethereum Signed Message, created from `s`. This
* produces hash corresponding to the one signed with the
* https://eth.wiki/json-rpc/API#eth_sign[`eth_sign`]
* JSON-RPC method as part of EIP-191.
*
* See {recover}.
*/
function toEthSignedMessageHash(bytes memory s) internal pure returns (bytes32) {
return keccak256(abi.encodePacked("\x19Ethereum Signed Message:\n", StringsUpgradeable.toString(s.length), s));
}
/**
* @dev Returns an Ethereum Signed Typed Data, created from a
* `domainSeparator` and a `structHash`. This produces hash corresponding
* to the one signed with the
* https://eips.ethereum.org/EIPS/eip-712[`eth_signTypedData`]
* JSON-RPC method as part of EIP-712.
*
* See {recover}.
*/
function toTypedDataHash(bytes32 domainSeparator, bytes32 structHash) internal pure returns (bytes32 data) {
/// @solidity memory-safe-assembly
assembly {
let ptr := mload(0x40)
mstore(ptr, "\x19\x01")
mstore(add(ptr, 0x02), domainSeparator)
mstore(add(ptr, 0x22), structHash)
data := keccak256(ptr, 0x42)
}
}
/**
* @dev Returns an Ethereum Signed Data with intended validator, created from a
* `validator` and `data` according to the version 0 of EIP-191.
*
* See {recover}.
*/
function toDataWithIntendedValidatorHash(address validator, bytes memory data) internal pure returns (bytes32) {
return keccak256(abi.encodePacked("\x19\x00", validator, data));
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (utils/math/Math.sol)
pragma solidity ^0.8.0;
/**
* @dev Standard math utilities missing in the Solidity language.
*/
library MathUpgradeable {
enum Rounding {
Down, // Toward negative infinity
Up, // Toward infinity
Zero // Toward zero
}
/**
* @dev Returns the largest of two numbers.
*/
function max(uint256 a, uint256 b) internal pure returns (uint256) {
return a > b ? a : b;
}
/**
* @dev Returns the smallest of two numbers.
*/
function min(uint256 a, uint256 b) internal pure returns (uint256) {
return a < b ? a : b;
}
/**
* @dev Returns the average of two numbers. The result is rounded towards
* zero.
*/
function average(uint256 a, uint256 b) internal pure returns (uint256) {
// (a + b) / 2 can overflow.
return (a & b) + (a ^ b) / 2;
}
/**
* @dev Returns the ceiling of the division of two numbers.
*
* This differs from standard division with `/` in that it rounds up instead
* of rounding down.
*/
function ceilDiv(uint256 a, uint256 b) internal pure returns (uint256) {
// (a + b - 1) / b can overflow on addition, so we distribute.
return a == 0 ? 0 : (a - 1) / b + 1;
}
/**
* @notice Calculates floor(x * y / denominator) with full precision. Throws if result overflows a uint256 or denominator == 0
* @dev Original credit to Remco Bloemen under MIT license (https://xn--2-umb.com/21/muldiv)
* with further edits by Uniswap Labs also under MIT license.
*/
function mulDiv(uint256 x, uint256 y, uint256 denominator) internal pure returns (uint256 result) {
unchecked {
// 512-bit multiply [prod1 prod0] = x * y. Compute the product mod 2^256 and mod 2^256 - 1, then use
// use the Chinese Remainder Theorem to reconstruct the 512 bit result. The result is stored in two 256
// variables such that product = prod1 * 2^256 + prod0.
uint256 prod0; // Least significant 256 bits of the product
uint256 prod1; // Most significant 256 bits of the product
assembly {
let mm := mulmod(x, y, not(0))
prod0 := mul(x, y)
prod1 := sub(sub(mm, prod0), lt(mm, prod0))
}
// Handle non-overflow cases, 256 by 256 division.
if (prod1 == 0) {
// Solidity will revert if denominator == 0, unlike the div opcode on its own.
// The surrounding unchecked block does not change this fact.
// See https://docs.soliditylang.org/en/latest/control-structures.html#checked-or-unchecked-arithmetic.
return prod0 / denominator;
}
// Make sure the result is less than 2^256. Also prevents denominator == 0.
require(denominator > prod1, "Math: mulDiv overflow");
///////////////////////////////////////////////
// 512 by 256 division.
///////////////////////////////////////////////
// Make division exact by subtracting the remainder from [prod1 prod0].
uint256 remainder;
assembly {
// Compute remainder using mulmod.
remainder := mulmod(x, y, denominator)
// Subtract 256 bit number from 512 bit number.
prod1 := sub(prod1, gt(remainder, prod0))
prod0 := sub(prod0, remainder)
}
// Factor powers of two out of denominator and compute largest power of two divisor of denominator. Always >= 1.
// See https://cs.stackexchange.com/q/138556/92363.
// Does not overflow because the denominator cannot be zero at this stage in the function.
uint256 twos = denominator & (~denominator + 1);
assembly {
// Divide denominator by twos.
denominator := div(denominator, twos)
// Divide [prod1 prod0] by twos.
prod0 := div(prod0, twos)
// Flip twos such that it is 2^256 / twos. If twos is zero, then it becomes one.
twos := add(div(sub(0, twos), twos), 1)
}
// Shift in bits from prod1 into prod0.
prod0 |= prod1 * twos;
// Invert denominator mod 2^256. Now that denominator is an odd number, it has an inverse modulo 2^256 such
// that denominator * inv = 1 mod 2^256. Compute the inverse by starting with a seed that is correct for
// four bits. That is, denominator * inv = 1 mod 2^4.
uint256 inverse = (3 * denominator) ^ 2;
// Use the Newton-Raphson iteration to improve the precision. Thanks to Hensel's lifting lemma, this also works
// in modular arithmetic, doubling the correct bits in each step.
inverse *= 2 - denominator * inverse; // inverse mod 2^8
inverse *= 2 - denominator * inverse; // inverse mod 2^16
inverse *= 2 - denominator * inverse; // inverse mod 2^32
inverse *= 2 - denominator * inverse; // inverse mod 2^64
inverse *= 2 - denominator * inverse; // inverse mod 2^128
inverse *= 2 - denominator * inverse; // inverse mod 2^256
// Because the division is now exact we can divide by multiplying with the modular inverse of denominator.
// This will give us the correct result modulo 2^256. Since the preconditions guarantee that the outcome is
// less than 2^256, this is the final result. We don't need to compute the high bits of the result and prod1
// is no longer required.
result = prod0 * inverse;
return result;
}
}
/**
* @notice Calculates x * y / denominator with full precision, following the selected rounding direction.
*/
function mulDiv(uint256 x, uint256 y, uint256 denominator, Rounding rounding) internal pure returns (uint256) {
uint256 result = mulDiv(x, y, denominator);
if (rounding == Rounding.Up && mulmod(x, y, denominator) > 0) {
result += 1;
}
return result;
}
/**
* @dev Returns the square root of a number. If the number is not a perfect square, the value is rounded down.
*
* Inspired by Henry S. Warren, Jr.'s "Hacker's Delight" (Chapter 11).
*/
function sqrt(uint256 a) internal pure returns (uint256) {
if (a == 0) {
return 0;
}
// For our first guess, we get the biggest power of 2 which is smaller than the square root of the target.
//
// We know that the "msb" (most significant bit) of our target number `a` is a power of 2 such that we have
// `msb(a) <= a < 2*msb(a)`. This value can be written `msb(a)=2**k` with `k=log2(a)`.
//
// This can be rewritten `2**log2(a) <= a < 2**(log2(a) + 1)`
// → `sqrt(2**k) <= sqrt(a) < sqrt(2**(k+1))`
// → `2**(k/2) <= sqrt(a) < 2**((k+1)/2) <= 2**(k/2 + 1)`
//
// Consequently, `2**(log2(a) / 2)` is a good first approximation of `sqrt(a)` with at least 1 correct bit.
uint256 result = 1 << (log2(a) >> 1);
// At this point `result` is an estimation with one bit of precision. We know the true value is a uint128,
// since it is the square root of a uint256. Newton's method converges quadratically (precision doubles at
// every iteration). We thus need at most 7 iteration to turn our partial result with one bit of precision
// into the expected uint128 result.
unchecked {
result = (result + a / result) >> 1;
result = (result + a / result) >> 1;
result = (result + a / result) >> 1;
result = (result + a / result) >> 1;
result = (result + a / result) >> 1;
result = (result + a / result) >> 1;
result = (result + a / result) >> 1;
return min(result, a / result);
}
}
/**
* @notice Calculates sqrt(a), following the selected rounding direction.
*/
function sqrt(uint256 a, Rounding rounding) internal pure returns (uint256) {
unchecked {
uint256 result = sqrt(a);
return result + (rounding == Rounding.Up && result * result < a ? 1 : 0);
}
}
/**
* @dev Return the log in base 2, rounded down, of a positive value.
* Returns 0 if given 0.
*/
function log2(uint256 value) internal pure returns (uint256) {
uint256 result = 0;
unchecked {
if (value >> 128 > 0) {
value >>= 128;
result += 128;
}
if (value >> 64 > 0) {
value >>= 64;
result += 64;
}
if (value >> 32 > 0) {
value >>= 32;
result += 32;
}
if (value >> 16 > 0) {
value >>= 16;
result += 16;
}
if (value >> 8 > 0) {
value >>= 8;
result += 8;
}
if (value >> 4 > 0) {
value >>= 4;
result += 4;
}
if (value >> 2 > 0) {
value >>= 2;
result += 2;
}
if (value >> 1 > 0) {
result += 1;
}
}
return result;
}
/**
* @dev Return the log in base 2, following the selected rounding direction, of a positive value.
* Returns 0 if given 0.
*/
function log2(uint256 value, Rounding rounding) internal pure returns (uint256) {
unchecked {
uint256 result = log2(value);
return result + (rounding == Rounding.Up && 1 << result < value ? 1 : 0);
}
}
/**
* @dev Return the log in base 10, rounded down, of a positive value.
* Returns 0 if given 0.
*/
function log10(uint256 value) internal pure returns (uint256) {
uint256 result = 0;
unchecked {
if (value >= 10 ** 64) {
value /= 10 ** 64;
result += 64;
}
if (value >= 10 ** 32) {
value /= 10 ** 32;
result += 32;
}
if (value >= 10 ** 16) {
value /= 10 ** 16;
result += 16;
}
if (value >= 10 ** 8) {
value /= 10 ** 8;
result += 8;
}
if (value >= 10 ** 4) {
value /= 10 ** 4;
result += 4;
}
if (value >= 10 ** 2) {
value /= 10 ** 2;
result += 2;
}
if (value >= 10 ** 1) {
result += 1;
}
}
return result;
}
/**
* @dev Return the log in base 10, following the selected rounding direction, of a positive value.
* Returns 0 if given 0.
*/
function log10(uint256 value, Rounding rounding) internal pure returns (uint256) {
unchecked {
uint256 result = log10(value);
return result + (rounding == Rounding.Up && 10 ** result < value ? 1 : 0);
}
}
/**
* @dev Return the log in base 256, rounded down, of a positive value.
* Returns 0 if given 0.
*
* Adding one to the result gives the number of pairs of hex symbols needed to represent `value` as a hex string.
*/
function log256(uint256 value) internal pure returns (uint256) {
uint256 result = 0;
unchecked {
if (value >> 128 > 0) {
value >>= 128;
result += 16;
}
if (value >> 64 > 0) {
value >>= 64;
result += 8;
}
if (value >> 32 > 0) {
value >>= 32;
result += 4;
}
if (value >> 16 > 0) {
value >>= 16;
result += 2;
}
if (value >> 8 > 0) {
result += 1;
}
}
return result;
}
/**
* @dev Return the log in base 256, following the selected rounding direction, of a positive value.
* Returns 0 if given 0.
*/
function log256(uint256 value, Rounding rounding) internal pure returns (uint256) {
unchecked {
uint256 result = log256(value);
return result + (rounding == Rounding.Up && 1 << (result << 3) < value ? 1 : 0);
}
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.8.0) (utils/math/SignedMath.sol)
pragma solidity ^0.8.0;
/**
* @dev Standard signed math utilities missing in the Solidity language.
*/
library SignedMathUpgradeable {
/**
* @dev Returns the largest of two signed numbers.
*/
function max(int256 a, int256 b) internal pure returns (int256) {
return a > b ? a : b;
}
/**
* @dev Returns the smallest of two signed numbers.
*/
function min(int256 a, int256 b) internal pure returns (int256) {
return a < b ? a : b;
}
/**
* @dev Returns the average of two signed numbers without overflow.
* The result is rounded towards zero.
*/
function average(int256 a, int256 b) internal pure returns (int256) {
// Formula from the book "Hacker's Delight"
int256 x = (a & b) + ((a ^ b) >> 1);
return x + (int256(uint256(x) >> 255) & (a ^ b));
}
/**
* @dev Returns the absolute unsigned value of a signed value.
*/
function abs(int256 n) internal pure returns (uint256) {
unchecked {
// must be unchecked in order to support `n = type(int256).min`
return uint256(n >= 0 ? n : -n);
}
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (utils/StorageSlot.sol)
// This file was procedurally generated from scripts/generate/templates/StorageSlot.js.
pragma solidity ^0.8.0;
/**
* @dev Library for reading and writing primitive types to specific storage slots.
*
* Storage slots are often used to avoid storage conflict when dealing with upgradeable contracts.
* This library helps with reading and writing to such slots without the need for inline assembly.
*
* The functions in this library return Slot structs that contain a `value` member that can be used to read or write.
*
* Example usage to set ERC1967 implementation slot:
* ```solidity
* contract ERC1967 {
* bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;
*
* function _getImplementation() internal view returns (address) {
* return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value;
* }
*
* function _setImplementation(address newImplementation) internal {
* require(Address.isContract(newImplementation), "ERC1967: new implementation is not a contract");
* StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation;
* }
* }
* ```
*
* _Available since v4.1 for `address`, `bool`, `bytes32`, `uint256`._
* _Available since v4.9 for `string`, `bytes`._
*/
library StorageSlotUpgradeable {
struct AddressSlot {
address value;
}
struct BooleanSlot {
bool value;
}
struct Bytes32Slot {
bytes32 value;
}
struct Uint256Slot {
uint256 value;
}
struct StringSlot {
string value;
}
struct BytesSlot {
bytes value;
}
/**
* @dev Returns an `AddressSlot` with member `value` located at `slot`.
*/
function getAddressSlot(bytes32 slot) internal pure returns (AddressSlot storage r) {
/// @solidity memory-safe-assembly
assembly {
r.slot := slot
}
}
/**
* @dev Returns an `BooleanSlot` with member `value` located at `slot`.
*/
function getBooleanSlot(bytes32 slot) internal pure returns (BooleanSlot storage r) {
/// @solidity memory-safe-assembly
assembly {
r.slot := slot
}
}
/**
* @dev Returns an `Bytes32Slot` with member `value` located at `slot`.
*/
function getBytes32Slot(bytes32 slot) internal pure returns (Bytes32Slot storage r) {
/// @solidity memory-safe-assembly
assembly {
r.slot := slot
}
}
/**
* @dev Returns an `Uint256Slot` with member `value` located at `slot`.
*/
function getUint256Slot(bytes32 slot) internal pure returns (Uint256Slot storage r) {
/// @solidity memory-safe-assembly
assembly {
r.slot := slot
}
}
/**
* @dev Returns an `StringSlot` with member `value` located at `slot`.
*/
function getStringSlot(bytes32 slot) internal pure returns (StringSlot storage r) {
/// @solidity memory-safe-assembly
assembly {
r.slot := slot
}
}
/**
* @dev Returns an `StringSlot` representation of the string storage pointer `store`.
*/
function getStringSlot(string storage store) internal pure returns (StringSlot storage r) {
/// @solidity memory-safe-assembly
assembly {
r.slot := store.slot
}
}
/**
* @dev Returns an `BytesSlot` with member `value` located at `slot`.
*/
function getBytesSlot(bytes32 slot) internal pure returns (BytesSlot storage r) {
/// @solidity memory-safe-assembly
assembly {
r.slot := slot
}
}
/**
* @dev Returns an `BytesSlot` representation of the bytes storage pointer `store`.
*/
function getBytesSlot(bytes storage store) internal pure returns (BytesSlot storage r) {
/// @solidity memory-safe-assembly
assembly {
r.slot := store.slot
}
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (utils/Strings.sol)
pragma solidity ^0.8.0;
import "./math/MathUpgradeable.sol";
import "./math/SignedMathUpgradeable.sol";
/**
* @dev String operations.
*/
library StringsUpgradeable {
bytes16 private constant _SYMBOLS = "0123456789abcdef";
uint8 private constant _ADDRESS_LENGTH = 20;
/**
* @dev Converts a `uint256` to its ASCII `string` decimal representation.
*/
function toString(uint256 value) internal pure returns (string memory) {
unchecked {
uint256 length = MathUpgradeable.log10(value) + 1;
string memory buffer = new string(length);
uint256 ptr;
/// @solidity memory-safe-assembly
assembly {
ptr := add(buffer, add(32, length))
}
while (true) {
ptr--;
/// @solidity memory-safe-assembly
assembly {
mstore8(ptr, byte(mod(value, 10), _SYMBOLS))
}
value /= 10;
if (value == 0) break;
}
return buffer;
}
}
/**
* @dev Converts a `int256` to its ASCII `string` decimal representation.
*/
function toString(int256 value) internal pure returns (string memory) {
return string(abi.encodePacked(value < 0 ? "-" : "", toString(SignedMathUpgradeable.abs(value))));
}
/**
* @dev Converts a `uint256` to its ASCII `string` hexadecimal representation.
*/
function toHexString(uint256 value) internal pure returns (string memory) {
unchecked {
return toHexString(value, MathUpgradeable.log256(value) + 1);
}
}
/**
* @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length.
*/
function toHexString(uint256 value, uint256 length) internal pure returns (string memory) {
bytes memory buffer = new bytes(2 * length + 2);
buffer[0] = "0";
buffer[1] = "x";
for (uint256 i = 2 * length + 1; i > 1; --i) {
buffer[i] = _SYMBOLS[value & 0xf];
value >>= 4;
}
require(value == 0, "Strings: hex length insufficient");
return string(buffer);
}
/**
* @dev Converts an `address` with fixed length of 20 bytes to its not checksummed ASCII `string` hexadecimal representation.
*/
function toHexString(address addr) internal pure returns (string memory) {
return toHexString(uint256(uint160(addr)), _ADDRESS_LENGTH);
}
/**
* @dev Returns true if the two strings are equal.
*/
function equal(string memory a, string memory b) internal pure returns (bool) {
return keccak256(bytes(a)) == keccak256(bytes(b));
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.8.0) (token/ERC20/ERC20.sol)
pragma solidity ^0.8.0;
import "./IERC20.sol";
import "./extensions/IERC20Metadata.sol";
import "../../utils/Context.sol";
/**
* @dev Implementation of the {IERC20} interface.
*
* This implementation is agnostic to the way tokens are created. This means
* that a supply mechanism has to be added in a derived contract using {_mint}.
* For a generic mechanism see {ERC20PresetMinterPauser}.
*
* TIP: For a detailed writeup see our guide
* https://forum.openzeppelin.com/t/how-to-implement-erc20-supply-mechanisms/226[How
* to implement supply mechanisms].
*
* We have followed general OpenZeppelin Contracts guidelines: functions revert
* instead returning `false` on failure. This behavior is nonetheless
* conventional and does not conflict with the expectations of ERC20
* applications.
*
* Additionally, an {Approval} event is emitted on calls to {transferFrom}.
* This allows applications to reconstruct the allowance for all accounts just
* by listening to said events. Other implementations of the EIP may not emit
* these events, as it isn't required by the specification.
*
* Finally, the non-standard {decreaseAllowance} and {increaseAllowance}
* functions have been added to mitigate the well-known issues around setting
* allowances. See {IERC20-approve}.
*/
contract ERC20 is Context, IERC20, IERC20Metadata {
mapping(address => uint256) private _balances;
mapping(address => mapping(address => uint256)) private _allowances;
uint256 private _totalSupply;
string private _name;
string private _symbol;
/**
* @dev Sets the values for {name} and {symbol}.
*
* The default value of {decimals} is 18. To select a different value for
* {decimals} you should overload it.
*
* All two of these values are immutable: they can only be set once during
* construction.
*/
constructor(string memory name_, string memory symbol_) {
_name = name_;
_symbol = symbol_;
}
/**
* @dev Returns the name of the token.
*/
function name() public view virtual override returns (string memory) {
return _name;
}
/**
* @dev Returns the symbol of the token, usually a shorter version of the
* name.
*/
function symbol() public view virtual override returns (string memory) {
return _symbol;
}
/**
* @dev Returns the number of decimals used to get its user representation.
* For example, if `decimals` equals `2`, a balance of `505` tokens should
* be displayed to a user as `5.05` (`505 / 10 ** 2`).
*
* Tokens usually opt for a value of 18, imitating the relationship between
* Ether and Wei. This is the value {ERC20} uses, unless this function is
* overridden;
*
* NOTE: This information is only used for _display_ purposes: it in
* no way affects any of the arithmetic of the contract, including
* {IERC20-balanceOf} and {IERC20-transfer}.
*/
function decimals() public view virtual override returns (uint8) {
return 18;
}
/**
* @dev See {IERC20-totalSupply}.
*/
function totalSupply() public view virtual override returns (uint256) {
return _totalSupply;
}
/**
* @dev See {IERC20-balanceOf}.
*/
function balanceOf(address account) public view virtual override returns (uint256) {
return _balances[account];
}
/**
* @dev See {IERC20-transfer}.
*
* Requirements:
*
* - `to` cannot be the zero address.
* - the caller must have a balance of at least `amount`.
*/
function transfer(address to, uint256 amount) public virtual override returns (bool) {
address owner = _msgSender();
_transfer(owner, to, amount);
return true;
}
/**
* @dev See {IERC20-allowance}.
*/
function allowance(address owner, address spender) public view virtual override returns (uint256) {
return _allowances[owner][spender];
}
/**
* @dev See {IERC20-approve}.
*
* NOTE: If `amount` is the maximum `uint256`, the allowance is not updated on
* `transferFrom`. This is semantically equivalent to an infinite approval.
*
* Requirements:
*
* - `spender` cannot be the zero address.
*/
function approve(address spender, uint256 amount) public virtual override returns (bool) {
address owner = _msgSender();
_approve(owner, spender, amount);
return true;
}
/**
* @dev See {IERC20-transferFrom}.
*
* Emits an {Approval} event indicating the updated allowance. This is not
* required by the EIP. See the note at the beginning of {ERC20}.
*
* NOTE: Does not update the allowance if the current allowance
* is the maximum `uint256`.
*
* Requirements:
*
* - `from` and `to` cannot be the zero address.
* - `from` must have a balance of at least `amount`.
* - the caller must have allowance for ``from``'s tokens of at least
* `amount`.
*/
function transferFrom(
address from,
address to,
uint256 amount
) public virtual override returns (bool) {
address spender = _msgSender();
_spendAllowance(from, spender, amount);
_transfer(from, to, amount);
return true;
}
/**
* @dev Atomically increases the allowance granted to `spender` by the caller.
*
* This is an alternative to {approve} that can be used as a mitigation for
* problems described in {IERC20-approve}.
*
* Emits an {Approval} event indicating the updated allowance.
*
* Requirements:
*
* - `spender` cannot be the zero address.
*/
function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) {
address owner = _msgSender();
_approve(owner, spender, allowance(owner, spender) + addedValue);
return true;
}
/**
* @dev Atomically decreases the allowance granted to `spender` by the caller.
*
* This is an alternative to {approve} that can be used as a mitigation for
* problems described in {IERC20-approve}.
*
* Emits an {Approval} event indicating the updated allowance.
*
* Requirements:
*
* - `spender` cannot be the zero address.
* - `spender` must have allowance for the caller of at least
* `subtractedValue`.
*/
function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) {
address owner = _msgSender();
uint256 currentAllowance = allowance(owner, spender);
require(currentAllowance >= subtractedValue, "ERC20: decreased allowance below zero");
unchecked {
_approve(owner, spender, currentAllowance - subtractedValue);
}
return true;
}
/**
* @dev Moves `amount` of tokens from `from` to `to`.
*
* This internal function is equivalent to {transfer}, and can be used to
* e.g. implement automatic token fees, slashing mechanisms, etc.
*
* Emits a {Transfer} event.
*
* Requirements:
*
* - `from` cannot be the zero address.
* - `to` cannot be the zero address.
* - `from` must have a balance of at least `amount`.
*/
function _transfer(
address from,
address to,
uint256 amount
) internal virtual {
require(from != address(0), "ERC20: transfer from the zero address");
require(to != address(0), "ERC20: transfer to the zero address");
_beforeTokenTransfer(from, to, amount);
uint256 fromBalance = _balances[from];
require(fromBalance >= amount, "ERC20: transfer amount exceeds balance");
unchecked {
_balances[from] = fromBalance - amount;
// Overflow not possible: the sum of all balances is capped by totalSupply, and the sum is preserved by
// decrementing then incrementing.
_balances[to] += amount;
}
emit Transfer(from, to, amount);
_afterTokenTransfer(from, to, amount);
}
/** @dev Creates `amount` tokens and assigns them to `account`, increasing
* the total supply.
*
* Emits a {Transfer} event with `from` set to the zero address.
*
* Requirements:
*
* - `account` cannot be the zero address.
*/
function _mint(address account, uint256 amount) internal virtual {
require(account != address(0), "ERC20: mint to the zero address");
_beforeTokenTransfer(address(0), account, amount);
_totalSupply += amount;
unchecked {
// Overflow not possible: balance + amount is at most totalSupply + amount, which is checked above.
_balances[account] += amount;
}
emit Transfer(address(0), account, amount);
_afterTokenTransfer(address(0), account, amount);
}
/**
* @dev Destroys `amount` tokens from `account`, reducing the
* total supply.
*
* Emits a {Transfer} event with `to` set to the zero address.
*
* Requirements:
*
* - `account` cannot be the zero address.
* - `account` must have at least `amount` tokens.
*/
function _burn(address account, uint256 amount) internal virtual {
require(account != address(0), "ERC20: burn from the zero address");
_beforeTokenTransfer(account, address(0), amount);
uint256 accountBalance = _balances[account];
require(accountBalance >= amount, "ERC20: burn amount exceeds balance");
unchecked {
_balances[account] = accountBalance - amount;
// Overflow not possible: amount <= accountBalance <= totalSupply.
_totalSupply -= amount;
}
emit Transfer(account, address(0), amount);
_afterTokenTransfer(account, address(0), amount);
}
/**
* @dev Sets `amount` as the allowance of `spender` over the `owner` s tokens.
*
* This internal function is equivalent to `approve`, and can be used to
* e.g. set automatic allowances for certain subsystems, etc.
*
* Emits an {Approval} event.
*
* Requirements:
*
* - `owner` cannot be the zero address.
* - `spender` cannot be the zero address.
*/
function _approve(
address owner,
address spender,
uint256 amount
) internal virtual {
require(owner != address(0), "ERC20: approve from the zero address");
require(spender != address(0), "ERC20: approve to the zero address");
_allowances[owner][spender] = amount;
emit Approval(owner, spender, amount);
}
/**
* @dev Updates `owner` s allowance for `spender` based on spent `amount`.
*
* Does not update the allowance amount in case of infinite allowance.
* Revert if not enough allowance is available.
*
* Might emit an {Approval} event.
*/
function _spendAllowance(
address owner,
address spender,
uint256 amount
) internal virtual {
uint256 currentAllowance = allowance(owner, spender);
if (currentAllowance != type(uint256).max) {
require(currentAllowance >= amount, "ERC20: insufficient allowance");
unchecked {
_approve(owner, spender, currentAllowance - amount);
}
}
}
/**
* @dev Hook that is called before any transfer of tokens. This includes
* minting and burning.
*
* Calling conditions:
*
* - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens
* will be transferred to `to`.
* - when `from` is zero, `amount` tokens will be minted for `to`.
* - when `to` is zero, `amount` of ``from``'s tokens will be burned.
* - `from` and `to` are never both zero.
*
* To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].
*/
function _beforeTokenTransfer(
address from,
address to,
uint256 amount
) internal virtual {}
/**
* @dev Hook that is called after any transfer of tokens. This includes
* minting and burning.
*
* Calling conditions:
*
* - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens
* has been transferred to `to`.
* - when `from` is zero, `amount` tokens have been minted for `to`.
* - when `to` is zero, `amount` of ``from``'s tokens have been burned.
* - `from` and `to` are never both zero.
*
* To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].
*/
function _afterTokenTransfer(
address from,
address to,
uint256 amount
) internal virtual {}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/IERC20Metadata.sol)
pragma solidity ^0.8.0;
import "../IERC20.sol";
/**
* @dev Interface for the optional metadata functions from the ERC20 standard.
*
* _Available since v4.1._
*/
interface IERC20Metadata is IERC20 {
/**
* @dev Returns the name of the token.
*/
function name() external view returns (string memory);
/**
* @dev Returns the symbol of the token.
*/
function symbol() external view returns (string memory);
/**
* @dev Returns the decimals places of the token.
*/
function decimals() external view returns (uint8);
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.6.0) (token/ERC20/IERC20.sol)
pragma solidity ^0.8.0;
/**
* @dev Interface of the ERC20 standard as defined in the EIP.
*/
interface IERC20 {
/**
* @dev Emitted when `value` tokens are moved from one account (`from`) to
* another (`to`).
*
* Note that `value` may be zero.
*/
event Transfer(address indexed from, address indexed to, uint256 value);
/**
* @dev Emitted when the allowance of a `spender` for an `owner` is set by
* a call to {approve}. `value` is the new allowance.
*/
event Approval(address indexed owner, address indexed spender, uint256 value);
/**
* @dev Returns the amount of tokens in existence.
*/
function totalSupply() external view returns (uint256);
/**
* @dev Returns the amount of tokens owned by `account`.
*/
function balanceOf(address account) external view returns (uint256);
/**
* @dev Moves `amount` tokens from the caller's account to `to`.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transfer(address to, uint256 amount) external returns (bool);
/**
* @dev Returns the remaining number of tokens that `spender` will be
* allowed to spend on behalf of `owner` through {transferFrom}. This is
* zero by default.
*
* This value changes when {approve} or {transferFrom} are called.
*/
function allowance(address owner, address spender) external view returns (uint256);
/**
* @dev Sets `amount` as the allowance of `spender` over the caller's tokens.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* IMPORTANT: Beware that changing an allowance with this method brings the risk
* that someone may use both the old and the new allowance by unfortunate
* transaction ordering. One possible solution to mitigate this race
* condition is to first reduce the spender's allowance to 0 and set the
* desired value afterwards:
* https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
*
* Emits an {Approval} event.
*/
function approve(address spender, uint256 amount) external returns (bool);
/**
* @dev Moves `amount` tokens from `from` to `to` using the
* allowance mechanism. `amount` is then deducted from the caller's
* allowance.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transferFrom(
address from,
address to,
uint256 amount
) external returns (bool);
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/Context.sol)
pragma solidity ^0.8.0;
/**
* @dev Provides information about the current execution context, including the
* sender of the transaction and its data. While these are generally available
* via msg.sender and msg.data, they should not be accessed in such a direct
* manner, since when dealing with meta-transactions the account sending and
* paying for execution may not be the actual sender (as far as an application
* is concerned).
*
* This contract is only required for intermediate, library-like contracts.
*/
abstract contract Context {
function _msgSender() internal view virtual returns (address) {
return msg.sender;
}
function _msgData() internal view virtual returns (bytes calldata) {
return msg.data;
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (utils/Address.sol)
pragma solidity ^0.8.20;
/**
* @dev Collection of functions related to the address type
*/
library Address {
/**
* @dev The ETH balance of the account is not enough to perform the operation.
*/
error AddressInsufficientBalance(address account);
/**
* @dev There's no code at `target` (it is not a contract).
*/
error AddressEmptyCode(address target);
/**
* @dev A call to an address target failed. The target may have reverted.
*/
error FailedInnerCall();
/**
* @dev Replacement for Solidity's `transfer`: sends `amount` wei to
* `recipient`, forwarding all available gas and reverting on errors.
*
* https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost
* of certain opcodes, possibly making contracts go over the 2300 gas limit
* imposed by `transfer`, making them unable to receive funds via
* `transfer`. {sendValue} removes this limitation.
*
* https://consensys.net/diligence/blog/2019/09/stop-using-soliditys-transfer-now/[Learn more].
*
* IMPORTANT: because control is transferred to `recipient`, care must be
* taken to not create reentrancy vulnerabilities. Consider using
* {ReentrancyGuard} or the
* https://solidity.readthedocs.io/en/v0.8.20/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].
*/
function sendValue(address payable recipient, uint256 amount) internal {
if (address(this).balance < amount) {
revert AddressInsufficientBalance(address(this));
}
(bool success, ) = recipient.call{value: amount}("");
if (!success) {
revert FailedInnerCall();
}
}
/**
* @dev Performs a Solidity function call using a low level `call`. A
* plain `call` is an unsafe replacement for a function call: use this
* function instead.
*
* If `target` reverts with a revert reason or custom error, it is bubbled
* up by this function (like regular Solidity function calls). However, if
* the call reverted with no returned reason, this function reverts with a
* {FailedInnerCall} error.
*
* Returns the raw returned data. To convert to the expected return value,
* use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].
*
* Requirements:
*
* - `target` must be a contract.
* - calling `target` with `data` must not revert.
*/
function functionCall(address target, bytes memory data) internal returns (bytes memory) {
return functionCallWithValue(target, data, 0);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but also transferring `value` wei to `target`.
*
* Requirements:
*
* - the calling contract must have an ETH balance of at least `value`.
* - the called Solidity function must be `payable`.
*/
function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) {
if (address(this).balance < value) {
revert AddressInsufficientBalance(address(this));
}
(bool success, bytes memory returndata) = target.call{value: value}(data);
return verifyCallResultFromTarget(target, success, returndata);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but performing a static call.
*/
function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {
(bool success, bytes memory returndata) = target.staticcall(data);
return verifyCallResultFromTarget(target, success, returndata);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but performing a delegate call.
*/
function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {
(bool success, bytes memory returndata) = target.delegatecall(data);
return verifyCallResultFromTarget(target, success, returndata);
}
/**
* @dev Tool to verify that a low level call to smart-contract was successful, and reverts if the target
* was not a contract or bubbling up the revert reason (falling back to {FailedInnerCall}) in case of an
* unsuccessful call.
*/
function verifyCallResultFromTarget(
address target,
bool success,
bytes memory returndata
) internal view returns (bytes memory) {
if (!success) {
_revert(returndata);
} else {
// only check if target is a contract if the call was successful and the return data is empty
// otherwise we already know that it was a contract
if (returndata.length == 0 && target.code.length == 0) {
revert AddressEmptyCode(target);
}
return returndata;
}
}
/**
* @dev Tool to verify that a low level call was successful, and reverts if it wasn't, either by bubbling the
* revert reason or with a default {FailedInnerCall} error.
*/
function verifyCallResult(bool success, bytes memory returndata) internal pure returns (bytes memory) {
if (!success) {
_revert(returndata);
} else {
return returndata;
}
}
/**
* @dev Reverts with returndata if present. Otherwise reverts with {FailedInnerCall}.
*/
function _revert(bytes memory returndata) private pure {
// Look for revert reason and bubble it up if present
if (returndata.length > 0) {
// The easiest way to bubble the revert reason is using memory via assembly
/// @solidity memory-safe-assembly
assembly {
let returndata_size := mload(returndata)
revert(add(32, returndata), returndata_size)
}
} else {
revert FailedInnerCall();
}
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (token/ERC20/IERC20.sol)
pragma solidity ^0.8.20;
/**
* @dev Interface of the ERC-20 standard as defined in the ERC.
*/
interface IERC20 {
/**
* @dev Emitted when `value` tokens are moved from one account (`from`) to
* another (`to`).
*
* Note that `value` may be zero.
*/
event Transfer(address indexed from, address indexed to, uint256 value);
/**
* @dev Emitted when the allowance of a `spender` for an `owner` is set by
* a call to {approve}. `value` is the new allowance.
*/
event Approval(address indexed owner, address indexed spender, uint256 value);
/**
* @dev Returns the value of tokens in existence.
*/
function totalSupply() external view returns (uint256);
/**
* @dev Returns the value of tokens owned by `account`.
*/
function balanceOf(address account) external view returns (uint256);
/**
* @dev Moves a `value` amount of tokens from the caller's account to `to`.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transfer(address to, uint256 value) external returns (bool);
/**
* @dev Returns the remaining number of tokens that `spender` will be
* allowed to spend on behalf of `owner` through {transferFrom}. This is
* zero by default.
*
* This value changes when {approve} or {transferFrom} are called.
*/
function allowance(address owner, address spender) external view returns (uint256);
/**
* @dev Sets a `value` amount of tokens as the allowance of `spender` over the
* caller's tokens.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* IMPORTANT: Beware that changing an allowance with this method brings the risk
* that someone may use both the old and the new allowance by unfortunate
* transaction ordering. One possible solution to mitigate this race
* condition is to first reduce the spender's allowance to 0 and set the
* desired value afterwards:
* https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
*
* Emits an {Approval} event.
*/
function approve(address spender, uint256 value) external returns (bool);
/**
* @dev Moves a `value` amount of tokens from `from` to `to` using the
* allowance mechanism. `value` is then deducted from the caller's
* allowance.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transferFrom(address from, address to, uint256 value) external returns (bool);
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (token/ERC20/extensions/IERC20Metadata.sol)
pragma solidity ^0.8.20;
import {IERC20} from "./IERC20.sol";
/**
* @dev Interface for the optional metadata functions from the ERC-20 standard.
*/
interface IERC20Metadata is IERC20 {
/**
* @dev Returns the name of the token.
*/
function name() external view returns (string memory);
/**
* @dev Returns the symbol of the token.
*/
function symbol() external view returns (string memory);
/**
* @dev Returns the decimals places of the token.
*/
function decimals() external view returns (uint8);
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (token/ERC20/extensions/IERC20Permit.sol)
pragma solidity ^0.8.20;
/**
* @dev Interface of the ERC-20 Permit extension allowing approvals to be made via signatures, as defined in
* https://eips.ethereum.org/EIPS/eip-2612[ERC-2612].
*
* Adds the {permit} method, which can be used to change an account's ERC-20 allowance (see {IERC20-allowance}) by
* presenting a message signed by the account. By not relying on {IERC20-approve}, the token holder account doesn't
* need to send a transaction, and thus is not required to hold Ether at all.
*
* ==== Security Considerations
*
* There are two important considerations concerning the use of `permit`. The first is that a valid permit signature
* expresses an allowance, and it should not be assumed to convey additional meaning. In particular, it should not be
* considered as an intention to spend the allowance in any specific way. The second is that because permits have
* built-in replay protection and can be submitted by anyone, they can be frontrun. A protocol that uses permits should
* take this into consideration and allow a `permit` call to fail. Combining these two aspects, a pattern that may be
* generally recommended is:
*
* ```solidity
* function doThingWithPermit(..., uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s) public {
* try token.permit(msg.sender, address(this), value, deadline, v, r, s) {} catch {}
* doThing(..., value);
* }
*
* function doThing(..., uint256 value) public {
* token.safeTransferFrom(msg.sender, address(this), value);
* ...
* }
* ```
*
* Observe that: 1) `msg.sender` is used as the owner, leaving no ambiguity as to the signer intent, and 2) the use of
* `try/catch` allows the permit to fail and makes the code tolerant to frontrunning. (See also
* {SafeERC20-safeTransferFrom}).
*
* Additionally, note that smart contract wallets (such as Argent or Safe) are not able to produce permit signatures, so
* contracts should have entry points that don't rely on permit.
*/
interface IERC20Permit {
/**
* @dev Sets `value` as the allowance of `spender` over ``owner``'s tokens,
* given ``owner``'s signed approval.
*
* IMPORTANT: The same issues {IERC20-approve} has related to transaction
* ordering also apply here.
*
* Emits an {Approval} event.
*
* Requirements:
*
* - `spender` cannot be the zero address.
* - `deadline` must be a timestamp in the future.
* - `v`, `r` and `s` must be a valid `secp256k1` signature from `owner`
* over the EIP712-formatted function arguments.
* - the signature must use ``owner``'s current nonce (see {nonces}).
*
* For more information on the signature format, see the
* https://eips.ethereum.org/EIPS/eip-2612#specification[relevant EIP
* section].
*
* CAUTION: See Security Considerations above.
*/
function permit(
address owner,
address spender,
uint256 value,
uint256 deadline,
uint8 v,
bytes32 r,
bytes32 s
) external;
/**
* @dev Returns the current nonce for `owner`. This value must be
* included whenever a signature is generated for {permit}.
*
* Every successful call to {permit} increases ``owner``'s nonce by one. This
* prevents a signature from being used multiple times.
*/
function nonces(address owner) external view returns (uint256);
/**
* @dev Returns the domain separator used in the encoding of the signature for {permit}, as defined by {EIP712}.
*/
// solhint-disable-next-line func-name-mixedcase
function DOMAIN_SEPARATOR() external view returns (bytes32);
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (token/ERC20/utils/SafeERC20.sol)
pragma solidity ^0.8.20;
import {IERC20} from "./IERC20.sol";
import {IERC20Permit} from "./IERC20Permit.sol";
import {Address} from "./Address.sol";
/**
* @title SafeERC20
* @dev Wrappers around ERC-20 operations that throw on failure (when the token
* contract returns false). Tokens that return no value (and instead revert or
* throw on failure) are also supported, non-reverting calls are assumed to be
* successful.
* To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract,
* which allows you to call the safe operations as `token.safeTransfer(...)`, etc.
*/
library SafeERC20 {
using Address for address;
/**
* @dev An operation with an ERC-20 token failed.
*/
error SafeERC20FailedOperation(address token);
/**
* @dev Indicates a failed `decreaseAllowance` request.
*/
error SafeERC20FailedDecreaseAllowance(address spender, uint256 currentAllowance, uint256 requestedDecrease);
/**
* @dev Transfer `value` amount of `token` from the calling contract to `to`. If `token` returns no value,
* non-reverting calls are assumed to be successful.
*/
function safeTransfer(IERC20 token, address to, uint256 value) internal {
_callOptionalReturn(token, abi.encodeCall(token.transfer, (to, value)));
}
/**
* @dev Transfer `value` amount of `token` from `from` to `to`, spending the approval given by `from` to the
* calling contract. If `token` returns no value, non-reverting calls are assumed to be successful.
*/
function safeTransferFrom(IERC20 token, address from, address to, uint256 value) internal {
_callOptionalReturn(token, abi.encodeCall(token.transferFrom, (from, to, value)));
}
/**
* @dev Increase the calling contract's allowance toward `spender` by `value`. If `token` returns no value,
* non-reverting calls are assumed to be successful.
*/
function safeIncreaseAllowance(IERC20 token, address spender, uint256 value) internal {
uint256 oldAllowance = token.allowance(address(this), spender);
forceApprove(token, spender, oldAllowance + value);
}
/**
* @dev Decrease the calling contract's allowance toward `spender` by `requestedDecrease`. If `token` returns no
* value, non-reverting calls are assumed to be successful.
*/
function safeDecreaseAllowance(IERC20 token, address spender, uint256 requestedDecrease) internal {
unchecked {
uint256 currentAllowance = token.allowance(address(this), spender);
if (currentAllowance < requestedDecrease) {
revert SafeERC20FailedDecreaseAllowance(spender, currentAllowance, requestedDecrease);
}
forceApprove(token, spender, currentAllowance - requestedDecrease);
}
}
/**
* @dev Set the calling contract's allowance toward `spender` to `value`. If `token` returns no value,
* non-reverting calls are assumed to be successful. Meant to be used with tokens that require the approval
* to be set to zero before setting it to a non-zero value, such as USDT.
*/
function forceApprove(IERC20 token, address spender, uint256 value) internal {
bytes memory approvalCall = abi.encodeCall(token.approve, (spender, value));
if (!_callOptionalReturnBool(token, approvalCall)) {
_callOptionalReturn(token, abi.encodeCall(token.approve, (spender, 0)));
_callOptionalReturn(token, approvalCall);
}
}
/**
* @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement
* on the return value: the return value is optional (but if data is returned, it must not be false).
* @param token The token targeted by the call.
* @param data The call data (encoded using abi.encode or one of its variants).
*/
function _callOptionalReturn(IERC20 token, bytes memory data) private {
// We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since
// we're implementing it ourselves. We use {Address-functionCall} to perform this call, which verifies that
// the target address contains contract code and also asserts for success in the low-level call.
bytes memory returndata = address(token).functionCall(data);
if (returndata.length != 0 && !abi.decode(returndata, (bool))) {
revert SafeERC20FailedOperation(address(token));
}
}
/**
* @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement
* on the return value: the return value is optional (but if data is returned, it must not be false).
* @param token The token targeted by the call.
* @param data The call data (encoded using abi.encode or one of its variants).
*
* This is a variant of {_callOptionalReturn} that silents catches all reverts and returns a bool instead.
*/
function _callOptionalReturnBool(IERC20 token, bytes memory data) private returns (bool) {
// We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since
// we're implementing it ourselves. We cannot use {Address-functionCall} here since this should return false
// and not revert is the subcall reverts.
(bool success, bytes memory returndata) = address(token).call(data);
return success && (returndata.length == 0 || abi.decode(returndata, (bool))) && address(token).code.length > 0;
}
}//SPDX-License-Identifier: Unlicense
pragma solidity ^0.8.0;
import {TokenPrice, StrategyInfo, IdleStrategyInfo} from "../lib/Structs.sol";
interface IBatch {
function getSupportedTokensWithPriceInUsd() external view returns (TokenPrice[] memory supportedTokenPrices);
function getBatchValueUsdWithoutOracleCalls(
TokenPrice[] calldata supportedTokenPrices
) external view returns (uint256 totalBalanceUsd, uint256[] memory supportedTokenBalancesUsd);
function getSupportedTokens() external view returns (address[] memory);
function getBatchValueUsd() external view returns (uint256 totalBalance, uint256[] memory balances);
function getDepositFeeInNative(uint256 amountInStableUniform) external view returns (uint256 feeAmountInNative);
function supportsToken(address tokenAddress) external view returns (bool isSupported);
function rebalance(
TokenPrice[] calldata supportedTokenPrices,
StrategyInfo[] calldata strategies,
uint256 remainingToAllocateStrategiesWeightSum,
IdleStrategyInfo[] calldata idleStrategies
) external;
function withdraw(
address receiptOwner,
uint256[] calldata receiptIds,
uint256 _currentCycleId
)
external
returns (uint256[] memory _receiptIds, address[] memory _tokens, uint256[] memory _withdrawnTokenAmounts);
function deposit(
address depositor,
address depositToken,
uint256 depositAmount,
uint256 _currentCycleId
) external payable returns (uint256 depositFeeAmount);
function addSupportedToken(address tokenAddress) external;
function removeSupportedToken(
address tokenAddress
) external returns (bool wasRemovedFromTail, address formerTailTokenAddress, uint256 newIndexOfFormerTailToken);
}//SPDX-License-Identifier: Unlicense
pragma solidity ^0.8.0;
import {TokenPrice} from "../lib/Structs.sol";
interface IExchange {
function stablecoinSwap(
uint256 amountA,
address tokenA,
address tokenB,
address to,
TokenPrice calldata usdPriceTokenA,
TokenPrice calldata usdPriceTokenB
) external returns (uint256 amountReceived);
function swap(
uint256 amountA,
address tokenA,
address tokenB,
address to
) external returns (uint256 amountReceived);
function getExchangeProtocolFee(
uint256 amountA,
address tokenA,
address tokenB
) external view returns (uint256 feePercent);
function protectedSwap(
uint256 amountA,
address tokenA,
address tokenB,
address to,
TokenPrice calldata usdPriceTokenA,
TokenPrice calldata usdPriceTokenB
) external returns (uint256 amountReceived);
function getRoutePrice(address tokenA, address tokenB) external view returns (uint256 price);
}//SPDX-License-Identifier: Unlicense
pragma solidity ^0.8.0;
import {ReceiptData} from "../lib/Structs.sol";
interface IReceiptNFT {
function ownerOf(uint256 receiptId) external view returns (address owner);
function getReceipt(uint256 receiptId) external view returns (ReceiptData memory);
function mint(uint256 cycleId, uint256 amount, address token, address wallet) external;
function burn(uint256 receiptId) external;
function setAmount(uint256 receiptId, uint256 amount) external;
function getTokensOfOwner(address owner) external view returns (uint256[] memory receiptIds);
function getReceiptsCounter() external view returns (uint256);
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
interface IRegistry {
function getBytes32Identifier(string calldata identifierString) external pure returns (bytes32);
function registerAddress(bytes32 bytes32Identifier, address contractAddress) external;
function getAddressByIdentifier(bytes32 bytes32Identifier) external view returns (address identifierAddress);
function getAllRegisteredIdentifiers() external view returns (bytes32[] memory);
function getRegisteredIdentifierById(uint256 id) external view returns (bytes32 registeredIdentifier);
function getRegisteredIdentifierCount() external view returns (uint256);
}//SPDX-License-Identifier: Unlicense
pragma solidity ^0.8.0;
interface IRouterAdmin {
function redeemReceiptsToSharesByModerators(uint256[] calldata receiptIds) external;
}//SPDX-License-Identifier: Unlicense
pragma solidity ^0.8.0;
interface ISharesToken {
function balanceOf(address account) external view returns (uint256);
function totalSupply() external view returns (uint256);
function transfer(address to, uint256 amount) external;
function transferFromAutoApproved(address from, address to, uint256 amount) external;
function mint(address to, uint256 amount) external;
function burn(address from, uint256 amount) external;
}//SPDX-License-Identifier: Unlicense
pragma solidity ^0.8.0;
import "./IUsdOracle.sol";
import "./IExchange.sol";
import "./IReceiptNFT.sol";
import "./ISharesToken.sol";
import "./IBatch.sol";
interface IStrategyRouter {
function getStrategiesCount() external view returns (uint256);
function getStrategyDepositToken(uint256 i) external view returns (address);
function supportsToken(address tokenAddress) external view returns (bool isSupported);
function calculateSharesUsdValue(uint256 amountShares) external view returns (uint256 amountUsd);
function withdrawFromStrategies(
uint256[] calldata receiptIds,
address withdrawToken,
uint256 shares,
uint256 minTokenAmountToWithdraw,
bool performCompound
) external returns (uint256 withdrawnAmount);
function setAddresses(
IExchange _exchange,
IUsdOracle _oracle,
ISharesToken _sharesToken,
IBatch _batch,
IReceiptNFT _receiptNft
) external;
function redeemReceiptsToSharesByModerators(uint256[] calldata receiptIds) external;
function setSupportedToken(address tokenAddress, bool supported, address idleStrategy) external;
function setFeesCollectionAddress(address moderator) external;
function setAllocationWindowTime(uint256 timeInSeconds) external;
function setIdleStrategy(uint256 i, address idleStrategy) external;
function addStrategy(address strategyAddress, uint256 weight) external;
function removeStrategy(uint256 strategyId) external;
function rebalanceStrategies() external returns (uint256[] memory balances);
function updateStrategy(uint256 strategyId, uint256 weight) external;
function getExchange() external view returns (IExchange);
function getStrategies() external view returns (StrategyInfo[] memory, uint256);
function getSupportedTokens() external view returns (address[] memory);
/// @notice Send pending money collected in the batch into the strategies.
function allocateToStrategies() external;
function depositToBatch(address depositToken, uint256 depositAmount, string calldata referral) external payable;
function redeemReceiptsToShares(uint256[] calldata receiptIds) external returns (uint256 shares);
}//SPDX-License-Identifier: Unlicense
pragma solidity ^0.8.0;
interface IUsdOracle {
function isTokenSupported(address base)
external
view
returns (bool isTokenSupported);
/// @notice Get usd value of token `base`.
function getTokenUsdPrice(address base)
external
view
returns (uint256 price, uint8 decimals);
}pragma solidity ^0.8.0;
import "@openzeppelin/contracts/token/ERC20/ERC20.sol";
uint8 constant UNIFORM_DECIMALS = 18;
uint256 constant UNIFROM_PRECISION = 10 ** UNIFORM_DECIMALS;
uint256 constant MAX_BPS = 10000;
library ClipMath {
error DivByZero();
function divCeil(uint256 _a, uint256 _b) internal pure returns (uint256 c) {
if (_b == 0) revert DivByZero();
c = _a / _b;
if (_a % _b != 0) {
c = c + 1;
}
}
}
/// @dev Change decimal places to `UNIFORM_DECIMALS`.
function toUniform(uint256 amount, address token) view returns (uint256) {
return changeDecimals(amount, ERC20(token).decimals(), UNIFORM_DECIMALS);
}
/// @dev Convert decimal places from `UNIFORM_DECIMALS` to token decimals.
function fromUniform(uint256 amount, address token) view returns (uint256) {
return changeDecimals(amount, UNIFORM_DECIMALS, ERC20(token).decimals());
}
/// @dev Change decimal places of number from `oldDecimals` to `newDecimals`.
function changeDecimals(uint256 amount, uint8 oldDecimals, uint8 newDecimals) pure returns (uint256) {
if (oldDecimals < newDecimals) {
return amount * (10 ** (newDecimals - oldDecimals));
} else if (oldDecimals > newDecimals) {
return amount / (10 ** (oldDecimals - newDecimals));
}
return amount;
}//SPDX-License-Identifier: Unlicense
pragma solidity ^0.8.0;
struct TokenPrice {
uint256 price;
uint8 priceDecimals;
address token;
}
struct StrategyInfo {
address strategyAddress;
address depositToken;
uint256 depositTokenInSupportedTokensIndex;
uint256 weight;
}
struct IdleStrategyInfo {
address strategyAddress;
address depositToken;
}
struct ReceiptData {
uint256 cycleId;
uint256 tokenAmountUniform; // in token
address token;
}
struct Cycle {
// block.timestamp at which cycle started
uint256 startAt;
// batch USD value before deposited into strategies
uint256 totalDepositedInUsd;
// USD value received by strategies after all swaps necessary to ape into strategies
uint256 receivedByStrategiesInUsd;
// Protocol TVL after compound idle strategy and actual deposit to strategies
uint256 strategiesBalanceWithCompoundAndBatchDepositsInUsd;
// price per share in USD
uint256 pricePerShare;
// tokens price at time of the deposit to strategies
mapping(address => uint256) prices;
}{
"viaIR": true,
"optimizer": {
"enabled": true,
"runs": 1,
"details": {
"peephole": true,
"yulDetails": {
"stackAllocation": true,
"optimizerSteps": "dhfoD[xarrscLMcCTU]uljmul"
}
}
},
"evmVersion": "paris",
"outputSelection": {
"*": {
"*": [
"evm.bytecode",
"evm.deployedBytecode",
"devdoc",
"userdoc",
"metadata",
"abi"
]
}
},
"libraries": {}
}Contract Security Audit
- No Contract Security Audit Submitted- Submit Audit Here
Contract ABI
API[{"inputs":[{"internalType":"address","name":"_signer","type":"address"},{"internalType":"contract ISharesToken","name":"_sharesToken","type":"address"},{"internalType":"contract IReceiptNFT","name":"_receiptContract","type":"address"},{"internalType":"contract IRouterAdmin","name":"_admin","type":"address"},{"internalType":"contract IStrategyRouter","name":"_strategyRouter","type":"address"},{"internalType":"contract IExchange","name":"_exchange","type":"address"},{"internalType":"contract IUsdOracle","name":"_oracle","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[{"internalType":"address","name":"target","type":"address"}],"name":"AddressEmptyCode","type":"error"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"AddressInsufficientBalance","type":"error"},{"inputs":[],"name":"BadSignature","type":"error"},{"inputs":[],"name":"FailedInnerCall","type":"error"},{"inputs":[],"name":"InvalidInput","type":"error"},{"inputs":[],"name":"NotEnoughFee","type":"error"},{"inputs":[],"name":"NotEnoughShares","type":"error"},{"inputs":[],"name":"NotEnoughTokens","type":"error"},{"inputs":[],"name":"NotReceiptOwner","type":"error"},{"inputs":[{"internalType":"address","name":"token","type":"address"}],"name":"SafeERC20FailedOperation","type":"error"},{"inputs":[],"name":"Stale","type":"error"},{"inputs":[],"name":"Unauthorized","type":"error"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"previousAdmin","type":"address"},{"indexed":false,"internalType":"address","name":"newAdmin","type":"address"}],"name":"AdminChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"beacon","type":"address"}],"name":"BeaconUpgraded","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"sender","type":"address"},{"indexed":false,"internalType":"uint256[]","name":"receiptIds","type":"uint256[]"},{"indexed":false,"internalType":"address","name":"token","type":"address"},{"indexed":false,"internalType":"bool","name":"isDeposit","type":"bool"},{"indexed":false,"internalType":"uint256","name":"amountIn","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"amountOut","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"fee","type":"uint256"}],"name":"ConvertNFTAndSwapShares","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint8","name":"version","type":"uint8"}],"name":"Initialized","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"sender","type":"address"},{"indexed":false,"internalType":"address","name":"token","type":"address"},{"indexed":false,"internalType":"bool","name":"isDeposit","type":"bool"},{"indexed":false,"internalType":"uint256","name":"amountIn","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"amountOut","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"fee","type":"uint256"},{"indexed":false,"internalType":"bytes32","name":"referral","type":"bytes32"}],"name":"SwapShares","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"implementation","type":"address"}],"name":"Upgraded","type":"event"},{"inputs":[{"internalType":"address","name":"_target","type":"address"},{"internalType":"bytes","name":"_data","type":"bytes"},{"internalType":"uint256","name":"value","type":"uint256"}],"name":"callTarget","outputs":[{"internalType":"bool","name":"","type":"bool"},{"internalType":"bytes","name":"","type":"bytes"}],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"address","name":"_receiver","type":"address"},{"internalType":"address","name":"_erc20Address","type":"address"},{"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"collectERC20","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_receiver","type":"address"}],"name":"collectFee","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"components":[{"internalType":"address","name":"token","type":"address"},{"internalType":"bool","name":"isDeposit","type":"bool"},{"internalType":"uint256","name":"amountIn","type":"uint256"},{"internalType":"uint256","name":"amountOut","type":"uint256"},{"internalType":"uint256","name":"deadline","type":"uint256"},{"internalType":"uint256","name":"fee","type":"uint256"},{"internalType":"bytes","name":"signature","type":"bytes"}],"internalType":"struct SharesCollateral.SwapData","name":"swapData","type":"tuple"},{"internalType":"uint256[]","name":"receiptIds","type":"uint256[]"}],"name":"convertNFTAndSwapShares","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"uint256","name":"shares","type":"uint256"},{"internalType":"address","name":"withdrawToken","type":"address"}],"name":"convertSharesToStablesWithWithdrawFromStrategies","outputs":[{"internalType":"uint256","name":"withdrawnAmount","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"depositToken","type":"address"},{"internalType":"uint256","name":"depositAmount","type":"uint256"}],"name":"depositStablesAndConvertShares","outputs":[{"internalType":"uint256","name":"shares","type":"uint256"}],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"bytes","name":"initializeData","type":"bytes"}],"name":"initialize","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"maxSlippageToWithdrawInBps","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"proxiableUUID","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"newMaxSlippageInBps","type":"uint256"}],"name":"setMaxSlippageToWithdrawInBps","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"components":[{"internalType":"address","name":"token","type":"address"},{"internalType":"bool","name":"isDeposit","type":"bool"},{"internalType":"uint256","name":"amountIn","type":"uint256"},{"internalType":"uint256","name":"amountOut","type":"uint256"},{"internalType":"uint256","name":"deadline","type":"uint256"},{"internalType":"uint256","name":"fee","type":"uint256"},{"internalType":"bytes","name":"signature","type":"bytes"}],"internalType":"struct SharesCollateral.SwapData","name":"swapData","type":"tuple"},{"internalType":"bytes32","name":"referral","type":"bytes32"}],"name":"swapShares","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"uint256","name":"amountIn","type":"uint256"},{"internalType":"address","name":"tokenIn","type":"address"},{"internalType":"address","name":"tokenOut","type":"address"}],"name":"swapTokens","outputs":[{"internalType":"uint256","name":"amountOut","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newImplementation","type":"address"}],"name":"upgradeTo","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newImplementation","type":"address"},{"internalType":"bytes","name":"data","type":"bytes"}],"name":"upgradeToAndCall","outputs":[],"stateMutability":"payable","type":"function"},{"stateMutability":"payable","type":"receive"}]Contract Creation Code
61018060405234620000f257620000266200001962000219565b959490949391936200024b565b604051612cb29081620003f882396080518181816106f00152610827015260a0518181816116b801528181611c5f01528181611e980152612202015260c0518181816110670152818161143801528181611ca401528181611edd01528181612247015281816125d20152818161263a015281816126f50152612753015260e0518181816112be01526121020152610100518181816117290152818161182f015261233901526101205181818161205801526123b201526101405181611de0015261016051816128600152f35b600080fd5b634e487b7160e01b600052604160045260246000fd5b90601f01601f191681019081106001600160401b038211176200012f57604052565b620000f7565b906200014c6200014460405190565b92836200010d565b565b6001600160a01b031690565b90565b62000168816200014e565b03620000f257565b905051906200014c826200015d565b6200015a906200014e565b62000168816200017f565b905051906200014c826200018a565b60e081830312620000f257620001bb828262000170565b92620001cb836020840162000195565b92620001db816040850162000195565b92620001eb826060830162000195565b926200015a620001ff846080850162000195565b9360c0620002118260a0870162000195565b940162000195565b6200023c620030aa80380380620002308162000135565b928339810190620001a4565b91939596909294959493929190565b62000255620002a4565b60a0526101005260e05260c0526101205261014052610160526200014c6200037d565b6200015a906200014e906001600160a01b031682565b6200015a9062000278565b6200015a906200028e565b620002af3062000299565b608052565b6200015a9060081c5b60ff1690565b6200015a9054620002b4565b15620002d757565b60405162461bcd60e51b815260206004820152602760248201527f496e697469616c697a61626c653a20636f6e747261637420697320696e697469604482015266616c697a696e6760c81b6064820152608490fd5b6200015a90620002bd565b6200015a90546200032c565b620002bd6200015a6200015a9260ff1690565b906200036a6200015a620003799262000343565b825460ff191660ff9091161790565b9055565b6200039b62000395620003916000620002c3565b1590565b620002cf565b620003a7600062000337565b60ff90811603620003b457565b620003c260ff600062000356565b7f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb3847402498620003ed60405190565b60ff8152602090a156fe6080604052600436101561001b575b361561001957600080fd5b005b60003560e01c806309b96068146100fb57806312617ea5146100f6578063235c9238146100f15780633659cfe6146100ec578063439fab91146100e75780634f1ef286146100e257806352d1902d146100dd57806369b59e75146100d857806374f0ff82146100d357806378040411146100ce5780638917d59c146100c9578063c3bda152146100c4578063ee91a966146100bf5763f70d1d980361000e57610625565b6105d2565b610505565b6104cb565b6104a0565b610468565b61042d565b610402565b6103df565b610392565b61028e565b610266565b610224565b610176565b6001600160a01b031690565b90565b61011881610100565b0361011f57565b600080fd5b905035906101318261010f565b565b80610118565b9050359061013182610133565b909160608284031261011f5761010c61015f8484610124565b93604061016f8260208701610124565b9401610139565b3461011f5761018f610189366004610146565b91612743565b604051005b0390f35b908160e091031261011f5790565b909182601f8301121561011f5781359283926001600160401b03841161011f578060208092019560051b01011161011f57565b91909160408184031261011f5780356001600160401b03811161011f5783610202918301610198565b9260208201356001600160401b03811161011f5761022092016101a6565b9091565b61018f6102323660046101d9565b916112a9565b919060408382031261011f578235906001600160401b03821161011f57602061016f8261010c948701610198565b61018f610274366004610238565b90611130565b9060208282031261011f5761010c91610124565b3461011f5761018f6102a136600461027a565b6108d7565b634e487b7160e01b600052604160045260246000fd5b90601f01601f191681019081106001600160401b038211176102dd57604052565b6102a6565b906101316102ef60405190565b92836102bc565b6001600160401b0381116102dd57602090601f01601f19160190565b0190565b90826000939282370152565b90929192610337610332826102f6565b6102e2565b9182948284528282011161011f576020610131930190610316565b9080601f8301121561011f5781602061010c93359101610322565b9060208282031261011f5781356001600160401b03811161011f5761010c9201610352565b3461011f5761018f6103a536600461036d565b610fde565b91909160408184031261011f576103c18382610124565b9260208201356001600160401b03811161011f5761010c9201610352565b61018f6103ed3660046103aa565b90610c45565b600091031261011f57565b9052565b3461011f576104123660046103f3565b61019461041d610764565b6040519182918290815260200190565b3461011f5761018f61044036600461027a565b6126e5565b919060408382031261011f5780602061046161010c9386610139565b9401610124565b3461011f5761019461041d61047e366004610445565b906125bd565b919060408382031261011f5780602061016f61010c9386610124565b61019461041d6104b1366004610484565b906121e5565b9060208282031261011f5761010c91610139565b3461011f5761018f6104de3660046104b7565b6127d6565b61010c9160031b1c81565b9061010c91546104e3565b61010c600060656104ee565b3461011f576105153660046103f3565b61019461041d6104f9565b909160608284031261011f576105368383610124565b926020830135906001600160401b03821161011f57604061016f8261010c948701610352565b60005b83811061056f5750506000910152565b818101518382015260200161055f565b6105a06105a960209361031293610594815190565b80835293849260200190565b9586910161055c565b601f01601f191690565b806105c560409261010c959415159052565b816020820152019061057f565b6105e66105e0366004610520565b91612626565b906101946105f360405190565b928392836105b3565b909160608284031261011f5761010c6106158484610139565b9360406104618260208701610124565b3461011f5761019461041d61063b3660046105fc565b91611e7a565b61010c90610100906001600160a01b031682565b61010c90610641565b61010c90610655565b1561066e57565b60405162461bcd60e51b815260206004820152603860248201527f555550535570677261646561626c653a206d757374206e6f742062652063616c6044820152771b1959081d1a1c9bdd59da0819195b1959d85d1958d85b1b60421b6064820152608490fd5b0390fd5b61010c906107206106e83061065e565b61071a6107147f0000000000000000000000000000000000000000000000000000000000000000610100565b91610100565b14610667565b61075b565b61010c61010c61010c9290565b61010c7f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc610725565b5061010c610732565b61010c60006106d8565b1561077557565b60405162461bcd60e51b815260206004820152602c6024820152600080516020612c3d83398151915260448201526b19195b1959d85d1958d85b1b60a21b6064820152608490fd5b156107c457565b60405162461bcd60e51b815260206004820152602c6024820152600080516020612c3d83398151915260448201526b6163746976652070726f787960a01b6064820152608490fd5b6101319061087061085361085a6108223061065e565b61084b7f0000000000000000000000000000000000000000000000000000000000000000610100565b928391610100565b141561076e565b61086a6108656108f3565b610100565b146107bd565b6108b1565b90610882610332836102f6565b918252565b369037565b9061013161089983610875565b602081946108a9601f19916102f6565b019101610887565b6000610131916108c0816110af565b6108d16108cc83610725565b61088c565b906109cf565b6101319061080c565b61010c90610100565b61010c90546108e0565b61010c61090161010c610732565b6108e9565b61010c7f4910fdfa16fed3260ed0e7147f7cc6da11a60208b5b9406d12a635614ffd9143610725565b61010c905b60ff1690565b61010c905461092f565b9050519061013182610133565b9060208282031261011f5761010c91610944565b6040513d6000823e3d90fd5b1561097857565b60405162461bcd60e51b815260206004820152602960248201527f45524331393637557067726164653a20756e737570706f727465642070726f786044820152681a58589b195555525160ba1b6064820152608490fd5b91906109e46109df61010c610906565b61093a565b156109f457505061013190610b76565b610a05610a008461065e565b61065e565b6020610a1060405190565b6352d1902d60e01b815291829060049082905afa60009181610ab4575b50610a8f575060405162461bcd60e51b815260206004820152602e60248201527f45524331393637557067726164653a206e657720696d706c656d656e7461746960448201526d6f6e206973206e6f74205555505360901b6064820152608490fd5b92610aaf61013194610aa9610aa561010c610732565b9190565b14610971565b610b9b565b610ad691925060203d8111610add575b610ace81836102bc565b810190610951565b9038610a2d565b503d610ac4565b15610aeb57565b60405162461bcd60e51b815260206004820152602d60248201527f455243313936373a206e657720696d706c656d656e746174696f6e206973206e60448201526c1bdd08184818dbdb9d1c9858dd609a1b6064820152608490fd5b90610b5661010c610b729261065e565b82546001600160a01b0319166001600160a01b03919091161790565b9055565b61013190610b8b610b8682610c4f565b610ae4565b610b9661010c610732565b610b46565b91610ba583610bda565b8151610bb4610aa56000610725565b11908115610bd2575b50610bc6575050565b610bcf91610cac565b50565b905038610bbd565b610be790610a0081610b76565b7fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b610c1160405190565b80805b0390a2565b9061013191610c3061085361085a6108223061065e565b61013191600191610c40816110af565b6109cf565b9061013191610c19565b3b610c5d610aa56000610725565b1190565b610c6b6027610875565b7f416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c6020820152660819985a5b195960ca1b604082015290565b61010c610c61565b61010c91610cb8610ca4565b91610cdd565b3d15610cd857610ccd3d610875565b903d6000602084013e565b606090565b60008061010c9493602081519101845af4610cf6610cbe565b91610d48565b15610d0357565b60405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000006044820152606490fd5b91929015610d7a57508151610d60610aa56000610725565b14610d69575090565b610d7561010c91610c4f565b610cfc565b82610d91565b90602061010c92818152019061057f565b90610d9a825190565b610da7610aa56000610725565b1115610db65750805190602001fd5b6106d490610dc360405190565b62461bcd60e51b815291829160048301610d80565b61010c9060081c610934565b61010c9054610dd8565b61093461010c61010c9290565b15610e0257565b60405162461bcd60e51b815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201526d191e481a5b9a5d1a585b1a5e995960921b6064820152608490fd5b61093461010c61010c9260ff1690565b90610e7e61010c610b7292610e5e565b825460ff191660ff9091161790565b90610e9d61010c610b7292151590565b825461ff00191660089190911b61ff00161790565b6103fe90610dee565b6020810192916101319190610eb2565b610f15610edf610edb6000610de4565b1590565b918280610fb7575b8015610f72575b610ef790610dfb565b82610f0c610f056001610dee565b6000610e6e565b610f6157610fd5565b610f1b57565b610f26600080610e8d565b7f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb3847402498610f5060405190565b80610f5c600182610ebb565b0390a1565b610f6d60016000610e8d565b610fd5565b50610f87610edb610f823061065e565b610c4f565b8015610eee5750610ef7610f9b600061093a565b610faf610fa86001610dee565b9160ff1690565b149050610eee565b50610fc2600061093a565b610fcf610fa86001610dee565b10610ee7565b50610131611059565b61013190610ecb565b15610fee57565b60405162461bcd60e51b815260206004820152602b60248201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960448201526a6e697469616c697a696e6760a81b6064820152608490fd5b6101316110546000610de4565b610fe7565b610131611047565b5061108b7f000000000000000000000000000000000000000000000000000000000000000061065e565b61109761071433610100565b0361109e57565b6040516282b42960e81b8152600490fd5b61013190611061565b3561010c8161010f565b801515610118565b3561010c816110c2565b3561010c81610133565b6103fe90610100565b919461112561112c9298979561111e60a0966111176101319a61110e8960c081019f6110de565b15156020890152565b6040870152565b6060850152565b6080830152565b0152565b907f888dcbd019af251153dcb996aa5493b904206a294138c315a818b4e47f01cee09061115c836115b9565b611165836110b8565b610c14611174602086016110ca565b92611181604087016110d4565b9561119a60a0611193606084016110d4565b92016110d4565b906111a43361065e565b976111ae60405190565b968796876110e7565b634e487b7160e01b600052601160045260246000fd5b60001981146111dc5760010190565b6111b7565b634e487b7160e01b600052603260045260246000fd5b91908110156112075760051b0190565b6111e1565b905051906101318261010f565b9060208282031261011f5761010c9161120c565b9037565b8183529091602001916001600160fb1b03811161011f5782916103129160051b93849161122d565b91602061010c938181520191611231565b929796946111259061111e60a0966112a06112956101319b9661112c9860c08b5260c08b0191611231565b9c60208901906110de565b15156040870152565b9091926112b66000610725565b9384936112e27f000000000000000000000000000000000000000000000000000000000000000061065e565b926331a9108f60e11b946112f533610100565b965b848110156113a65761132e60206113176113128489896111f7565b6110d4565b604051809381928c83526004830190815260200190565b03818a5afa9081156113a157899161134e91600091611373575b50610100565b036113615761135c906111cd565b6112f7565b6040516357794b2f60e11b8152600490fd5b611394915060203d811161139a575b61138c81836102bc565b810190611219565b38611348565b503d611382565b610965565b5095509591925092506113b961010c8390565b11611433575b600080516020612c5d833981519152916113d8846115b9565b610c146113e4856110b8565b946113f1602082016110ca565b906113fe604082016110d4565b61141660a061140f606085016110d4565b93016110d4565b926114203361065e565b9861142a60405190565b9788978861126a565b61145c7f000000000000000000000000000000000000000000000000000000000000000061065e565b91823b1561011f57600061146f60405190565b938490637b3d246960e11b825281838161148d888860048401611259565b03925af19283156113a157600080516020612c5d833981519152936114b5575b5091506113bf565b6114cd9060006114c581836102bc565b8101906103f3565b386114ad565b6114df6103fe91610100565b60601b90565b94906103129461151960959895611512611527966115068b611520976114d3565b151560f81b60148b0152565b6015890152565b6035870152565b6055850152565b6075830152565b903590601e198136030182121561011f570180359182916001600160401b03831161011f57602001809336031261011f57565b61010c913691610322565b60409061112c61013194969593966115888360608101996110de565b60208301906110de565b60208101929161013191906110de565b91602061013192949361112c8160408101976110de565b608081016115c6816110d4565b421161198b5760a08201906115da826110d4565b341061197957611629916116b0611694611620936116536115fa886110b8565b61164589602081019761160c896110ca565b9561162f6116296060604086019d8e6110d4565b95019d8e6110d4565b926110d4565b9261163960405190565b978896602088016114e5565b03601f1981018352826102bc565b61166561165e825190565b9160200190565b207b0ca2ba3432b932bab69029b4b3b732b21026b2b9b9b0b3b29d05199960211b600052601c52603c60002090565b6116aa6116a460c088018861152e565b90611561565b9061199c565b6116dc6107147f0000000000000000000000000000000000000000000000000000000000000000610100565b03611967576116ea906110ca565b1561182a5761171f90611705610a00610a00611717966110b8565b9061170f3061065e565b9485916110d4565b91339061297f565b611771602061174d7f000000000000000000000000000000000000000000000000000000000000000061065e565b9361175760405190565b9283918291906370a0823160e01b5b835260048301611592565b0381865afa9081156113a15760009161180c575b50611795610aa561010c846110d4565b106117fa576117a3906110d4565b90803b1561011f576117d96000929183926117bd60405190565b948593849283919063a9059cbb60e01b835233600484016115a2565b03925af180156113a1576117ea5750565b6101319060006114c581836102bc565b604051633c57b48560e21b8152600490fd5b611824915060203d8111610add57610ace81836102bc565b38611785565b6118537f000000000000000000000000000000000000000000000000000000000000000061065e565b906118666118603061065e565b916110d4565b91803b1561011f5761189d60009391849261188060405190565b9586938492839190633e4b96f760e01b835288336004850161156c565b03925af19081156113a1576118dc92602092611951575b506118c4610a00610a00876110b8565b6040515b938492839182916370a0823160e01b611766565b03915afa9081156113a157600091611933575b506118ff610aa561010c846110d4565b1061192157611919611860610a00610a00610131956110b8565b90339061293a565b6040516308aeed0f60e21b8152600490fd5b61194b915060203d8111610add57610ace81836102bc565b386118ef565b6119619060006114c581836102bc565b386118b4565b604051635cd5d23360e01b8152600490fd5b6040516334472ad760e11b8152600490fd5b604051621af02b60eb1b8152600490fd5b61010c916119a991611b30565b9190916119e0565b634e487b7160e01b600052602160045260246000fd5b600511156119d157565b6119b1565b90610131826119c7565b6119ea60006119d6565b6119f3826119d6565b036119fb5750565b611a0560016119d6565b611a0e826119d6565b03611a535760405162461bcd60e51b815260206004820152601860248201527745434453413a20696e76616c6964207369676e617475726560401b6044820152606490fd5b611a5d60026119d6565b611a66826119d6565b03611ab05760405162461bcd60e51b815260206004820152601f60248201527f45434453413a20696e76616c6964207369676e6174757265206c656e677468006044820152606490fd5b611ac3611abd60036119d6565b916119d6565b14611aca57565b60405162461bcd60e51b815260206004820152602260248201527f45434453413a20696e76616c6964207369676e6174757265202773272076616c604482015261756560f01b6064820152608490fd5b61010061010c61010c9290565b61010c90611b1a565b908051611b40610aa56041610725565b03611b6257610220916020820151906060604084015193015160001a90611bab565b5050611b6e6000611b27565b90600290565b61010c90610725565b61112c61013194611ba4606094989795611b9a85608081019b9052565b60ff166020850152565b6040830152565b919291611bb783611b74565b611bd9610aa56fa2a8918ca85bafe22016d0b997e4df60600160ff1b03610725565b11611c3957611bf9600093602095611bf060405190565b94859485611b7d565b838052039060015afa156113a157600051611c146000611b27565b611c1d81610100565b611c2683610100565b14611c32575090600090565b9160019150565b50505050611c476000611b27565b90600390565b929190611c5933610100565b80611c837f0000000000000000000000000000000000000000000000000000000000000000610100565b14159081611c9a575b5061109e5761010c93611d4f565b9050611cc86108657f000000000000000000000000000000000000000000000000000000000000000061065e565b141538611c8c565b9060408061013193611ce28482519052565b60208181015160ff169085015201519101906110de565b9194611d3e611d4892989795611d3460e096611d2a6101319a611d208961014081019f9052565b60208901906110de565b60408701906110de565b60608501906110de565b6080830190611cd0565b0190611cd0565b5091611d5b6000610725565b8390818114611e725750611d6e8361065e565b92611d788461065e565b94611d823061065e565b956020611d8e60405190565b9182906370a0823160e01b82528180611daa8c60048301611592565b03915afa80156113a157611dc491600091611e5a575b5090565b10611921576000611dd660209561065e565b92611e0b81611e047f000000000000000000000000000000000000000000000000000000000000000061065e565b809661293a565b611e44611e1784612852565b611e2087612852565b90611e2a60405190565b998a988997889663cf11eaad60e01b885260048801611cf9565b03925af19081156113a157600091611e5a575090565b61010c915060203d8111610add57610ace81836102bc565b935050505090565b61010c9291906000611c4d565b9190611e9233610100565b80611ebc7f0000000000000000000000000000000000000000000000000000000000000000610100565b14159081611ed3575b5061109e5761010c92611ffd565b9050611f016108657f000000000000000000000000000000000000000000000000000000000000000061065e565b141538611ec5565b611f2361010c93611f1c836060956110de565b6020830152565b816040820152016000815260200190565b6001600160401b0381116102dd5760051b60200190565b9061088261033283611f34565b90610131611f6583611f4b565b602081946108a9601f1991611f34565b919082039182116111dc57565b80518210156112075760209160051b010190565b90611fb6611faf611fa5845190565b8084529260200190565b9260200190565b9060005b818110611fc75750505090565b909192611fe4611fdd6001928651815260200190565b9460200190565b929101611fba565b90602061010c928181520190611f96565b506120086000610725565b91808381146121df576120356020612022610a008661065e565b61202b3061065e565b906118c860405190565b03915afa80156113a15761204e91600091611e5a575090565b106119215761207c7f000000000000000000000000000000000000000000000000000000000000000061065e565b91823b1561011f576120ac9160009161209460405190565b9384928392630e79698760e01b845260048401611f09565b038134865af180156113a1576121c9575b50803b1561011f57604051631941278960e01b815260008160048183865af180156113a1576121b3575b506120f26001610725565b906120fc82611f58565b906121267f000000000000000000000000000000000000000000000000000000000000000061065e565b91602061213260405190565b633af7918f60e21b815293849060049082905afa9384156113a15760009561217561216e61217893602098611e44988b91612196575b50611f75565b9184611f82565b52565b6040519485938492839190630ad8132f60e31b835260048301611fec565b6121ad91508a3d8111610add57610ace81836102bc565b38612168565b6121c39060006114c581836102bc565b386120e7565b6121d99060006114c581836102bc565b386120bd565b50505090565b61010c91906000611e87565b91906121fc33610100565b806122267f0000000000000000000000000000000000000000000000000000000000000000610100565b1415908161223d575b5061109e5761010c9261231f565b905061226b6108657f000000000000000000000000000000000000000000000000000000000000000061065e565b14153861222f565b60ff16604d81116111dc57600a0a90565b818102929181159184041417156111dc57565b634e487b7160e01b600052601260045260246000fd5b81156122b7570490565b612297565b61010c612710610725565b61010c9081565b61010c90546122c7565b90610131946123106080949897956123096122fe6123179560a0885260a0880190611f96565b9a60208701906110de565b6040850152565b6060830152565b019015159052565b509061232b6000610725565b90828281146125b65761235d7f000000000000000000000000000000000000000000000000000000000000000061065e565b916123673061065e565b9161237160405190565b6020816370a0823160e01b96878252818061238f8960048301611592565b03915afa80156113a1576123a891600091611e5a575090565b106117fa576123d67f000000000000000000000000000000000000000000000000000000000000000061065e565b946123e060405190565b636863a89560e01b8152600481018290526020816024818a5afa9081156113a15761247161244d612476938693600091612598575b5061244761244261242586612852565b9261243c612437602086015160ff1690565b612273565b90612284565b915190565b906122ad565b61246c6124586122bc565b9161243c61246660656122ce565b84611f75565b6122ad565b612b65565b95612483610a008461065e565b9261248d60405190565b96868852602088806124a28960048301611592565b0381885afa9788156113a157600098612569575b509060006124c76020959493611f58565b6124ef60016124d560405190565b9c8d978896879563026db39b60e01b8752600487016122d8565b03925af19283156113a15761251b9560209461254e575b50604051809681948293835260048301611592565b03915afa80156113a15761010c926000916125365750611f75565b6121ad915060203d8111610add57610ace81836102bc565b61256490853d8111610add57610ace81836102bc565b612506565b60209493929198506124c761258c600092873d8111610add57610ace81836102bc565b999293949550506124b6565b6125b0915060203d8111610add57610ace81836102bc565b38612415565b5050905090565b61010c919060006121f1565b939291906125f67f000000000000000000000000000000000000000000000000000000000000000061065e565b61260261071433610100565b0361109e5761022094505090600092918392602083519301915af19061010c610cbe565b610220929190606060006125c9565b61265e7f000000000000000000000000000000000000000000000000000000000000000061065e565b61266a61071433610100565b0361109e57610131906126b6565b1561267f57565b60405162461bcd60e51b815260206004820152600f60248201526e151c985b9cd9995c8819985a5b1959608a1b6044820152606490fd5b600080610131926126c63061065e565b316126d060405190565b90818003925af16126df610cbe565b50612678565b61013190612635565b91906127197f000000000000000000000000000000000000000000000000000000000000000061065e565b61272561071433610100565b0361109e576101319261273e610a00610131949361065e565b61293a565b9061013192916126ee565b6127777f000000000000000000000000000000000000000000000000000000000000000061065e565b61278361071433610100565b0361109e57610131906127a8565b906127a161010c610b7292610725565b8254611dc0565b6127b36103e8610725565b81116127c457610131906065612791565b60405163b4fa3fb360e01b8152600490fd5b6101319061274e565b61010c60606102e2565b6127f16127df565b9081600081526000602082015260406000910152565b61010c6127e9565b60ff8116610118565b905051906101318261280f565b919060408382031261011f5780602061284161010c9386610944565b9401612818565b906103fe90610100565b61285a612807565b506128847f000000000000000000000000000000000000000000000000000000000000000061065e565b6040805191829062593bcf60e01b825281806128a38760048301611592565b03915afa9182156113a15760009182936128da575b506128d161010c9293611b9a6128cc6127df565b958652565b60408301612848565b6128d1935061010c92506129049060403d811161290d575b6128fc81836102bc565b810190612825565b939092506128b8565b503d6128f2565b61292d61292761010c9263ffffffff1690565b60e01b90565b6001600160e01b03191690565b61297a6101319361296c61295163a9059cbb612914565b9161295b60405190565b9586936020850152602484016115a2565b03601f1981018452836102bc565b6129d5565b909161297a9061296c610131956129996323b872dd612914565b926129a360405190565b96879460208601526024850161156c565b90505190610131826110c2565b9060208282031261011f5761010c916129b4565b6129e16129e89161065e565b9182612a4f565b80516129f7610aa56000610725565b14159081612a2b575b50612a085750565b6106d490612a1560405190565b635274afe760e01b815291829160048301611592565b612a49915080602080612a3f610edb945190565b83010191016129c1565b38612a00565b61010c91612a5d6000610725565b612a663061065e565b81813110612a9057506000828192602061010c969551920190855af1612a8a610cbe565b91612ab3565b6106d490612a9d60405190565b63cd78605960e01b815291829160048301611592565b90612abe5750612b18565b612ad9612ac9835190565b612ad36000610725565b91829190565b149081612b0d575b50612aea575090565b6106d490612af760405190565b639996b31560e01b815291829160048301611592565b9050813b1438612ae1565b8051612b27610aa56000610725565b1115612b3557805190602001fd5b604051630a12f52160e11b8152600490fd5b61010c6012610dee565b9060208282031261011f5761010c91612818565b612b79610a00612b73612b47565b9361065e565b916020612b8560405190565b63313ce56760e01b815293849060049082905afa9182156113a15761010c93600093612bb2575b50612bfb565b612bd491935060203d8111612bdb575b612bcc81836102bc565b810190612b51565b9138612bac565b503d612bc2565b612bee9060ff16610fa8565b90039060ff82116111dc57565b9060ff831660ff821681811015612c1e57505061243761243c9161010c94612be2565b93929311612c2b57505090565b61243761010c939261244792612be256fe46756e6374696f6e206d7573742062652063616c6c6564207468726f756768203fa83e03852010fdfc42d4660bb125b74c3101b72645002d6773ab2cd8c1d455a2646970667358221220c0395ccbb9292eba91b7882bcd95a87a34af640db95ad8c169add62b81bf63fa64736f6c6343000814003300000000000000000000000020e822d61f2011f21bc851c572b2bc42006fcebd000000000000000000000000dd49bf14caae7a22bb6a58a76c4e998054859d9a0000000000000000000000004661ac8b3dbf8db241cc89a3edead3c8849008390000000000000000000000000d598920fc65439e71d2ce359e4a933d82900a4600000000000000000000000003a074d130144fce6883f7ea3884c0a783d85fb300000000000000000000000010d4df9a82131a2707fe2f529f18177aa5b08fba0000000000000000000000006eb57a62e466c628858092eb8cb281dd6381be42
Deployed Bytecode
0x6080604052600436101561001b575b361561001957600080fd5b005b60003560e01c806309b96068146100fb57806312617ea5146100f6578063235c9238146100f15780633659cfe6146100ec578063439fab91146100e75780634f1ef286146100e257806352d1902d146100dd57806369b59e75146100d857806374f0ff82146100d357806378040411146100ce5780638917d59c146100c9578063c3bda152146100c4578063ee91a966146100bf5763f70d1d980361000e57610625565b6105d2565b610505565b6104cb565b6104a0565b610468565b61042d565b610402565b6103df565b610392565b61028e565b610266565b610224565b610176565b6001600160a01b031690565b90565b61011881610100565b0361011f57565b600080fd5b905035906101318261010f565b565b80610118565b9050359061013182610133565b909160608284031261011f5761010c61015f8484610124565b93604061016f8260208701610124565b9401610139565b3461011f5761018f610189366004610146565b91612743565b604051005b0390f35b908160e091031261011f5790565b909182601f8301121561011f5781359283926001600160401b03841161011f578060208092019560051b01011161011f57565b91909160408184031261011f5780356001600160401b03811161011f5783610202918301610198565b9260208201356001600160401b03811161011f5761022092016101a6565b9091565b61018f6102323660046101d9565b916112a9565b919060408382031261011f578235906001600160401b03821161011f57602061016f8261010c948701610198565b61018f610274366004610238565b90611130565b9060208282031261011f5761010c91610124565b3461011f5761018f6102a136600461027a565b6108d7565b634e487b7160e01b600052604160045260246000fd5b90601f01601f191681019081106001600160401b038211176102dd57604052565b6102a6565b906101316102ef60405190565b92836102bc565b6001600160401b0381116102dd57602090601f01601f19160190565b0190565b90826000939282370152565b90929192610337610332826102f6565b6102e2565b9182948284528282011161011f576020610131930190610316565b9080601f8301121561011f5781602061010c93359101610322565b9060208282031261011f5781356001600160401b03811161011f5761010c9201610352565b3461011f5761018f6103a536600461036d565b610fde565b91909160408184031261011f576103c18382610124565b9260208201356001600160401b03811161011f5761010c9201610352565b61018f6103ed3660046103aa565b90610c45565b600091031261011f57565b9052565b3461011f576104123660046103f3565b61019461041d610764565b6040519182918290815260200190565b3461011f5761018f61044036600461027a565b6126e5565b919060408382031261011f5780602061046161010c9386610139565b9401610124565b3461011f5761019461041d61047e366004610445565b906125bd565b919060408382031261011f5780602061016f61010c9386610124565b61019461041d6104b1366004610484565b906121e5565b9060208282031261011f5761010c91610139565b3461011f5761018f6104de3660046104b7565b6127d6565b61010c9160031b1c81565b9061010c91546104e3565b61010c600060656104ee565b3461011f576105153660046103f3565b61019461041d6104f9565b909160608284031261011f576105368383610124565b926020830135906001600160401b03821161011f57604061016f8261010c948701610352565b60005b83811061056f5750506000910152565b818101518382015260200161055f565b6105a06105a960209361031293610594815190565b80835293849260200190565b9586910161055c565b601f01601f191690565b806105c560409261010c959415159052565b816020820152019061057f565b6105e66105e0366004610520565b91612626565b906101946105f360405190565b928392836105b3565b909160608284031261011f5761010c6106158484610139565b9360406104618260208701610124565b3461011f5761019461041d61063b3660046105fc565b91611e7a565b61010c90610100906001600160a01b031682565b61010c90610641565b61010c90610655565b1561066e57565b60405162461bcd60e51b815260206004820152603860248201527f555550535570677261646561626c653a206d757374206e6f742062652063616c6044820152771b1959081d1a1c9bdd59da0819195b1959d85d1958d85b1b60421b6064820152608490fd5b0390fd5b61010c906107206106e83061065e565b61071a6107147f00000000000000000000000007ca7858a2522c37412a474818c61c957530c3e8610100565b91610100565b14610667565b61075b565b61010c61010c61010c9290565b61010c7f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc610725565b5061010c610732565b61010c60006106d8565b1561077557565b60405162461bcd60e51b815260206004820152602c6024820152600080516020612c3d83398151915260448201526b19195b1959d85d1958d85b1b60a21b6064820152608490fd5b156107c457565b60405162461bcd60e51b815260206004820152602c6024820152600080516020612c3d83398151915260448201526b6163746976652070726f787960a01b6064820152608490fd5b6101319061087061085361085a6108223061065e565b61084b7f00000000000000000000000007ca7858a2522c37412a474818c61c957530c3e8610100565b928391610100565b141561076e565b61086a6108656108f3565b610100565b146107bd565b6108b1565b90610882610332836102f6565b918252565b369037565b9061013161089983610875565b602081946108a9601f19916102f6565b019101610887565b6000610131916108c0816110af565b6108d16108cc83610725565b61088c565b906109cf565b6101319061080c565b61010c90610100565b61010c90546108e0565b61010c61090161010c610732565b6108e9565b61010c7f4910fdfa16fed3260ed0e7147f7cc6da11a60208b5b9406d12a635614ffd9143610725565b61010c905b60ff1690565b61010c905461092f565b9050519061013182610133565b9060208282031261011f5761010c91610944565b6040513d6000823e3d90fd5b1561097857565b60405162461bcd60e51b815260206004820152602960248201527f45524331393637557067726164653a20756e737570706f727465642070726f786044820152681a58589b195555525160ba1b6064820152608490fd5b91906109e46109df61010c610906565b61093a565b156109f457505061013190610b76565b610a05610a008461065e565b61065e565b6020610a1060405190565b6352d1902d60e01b815291829060049082905afa60009181610ab4575b50610a8f575060405162461bcd60e51b815260206004820152602e60248201527f45524331393637557067726164653a206e657720696d706c656d656e7461746960448201526d6f6e206973206e6f74205555505360901b6064820152608490fd5b92610aaf61013194610aa9610aa561010c610732565b9190565b14610971565b610b9b565b610ad691925060203d8111610add575b610ace81836102bc565b810190610951565b9038610a2d565b503d610ac4565b15610aeb57565b60405162461bcd60e51b815260206004820152602d60248201527f455243313936373a206e657720696d706c656d656e746174696f6e206973206e60448201526c1bdd08184818dbdb9d1c9858dd609a1b6064820152608490fd5b90610b5661010c610b729261065e565b82546001600160a01b0319166001600160a01b03919091161790565b9055565b61013190610b8b610b8682610c4f565b610ae4565b610b9661010c610732565b610b46565b91610ba583610bda565b8151610bb4610aa56000610725565b11908115610bd2575b50610bc6575050565b610bcf91610cac565b50565b905038610bbd565b610be790610a0081610b76565b7fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b610c1160405190565b80805b0390a2565b9061013191610c3061085361085a6108223061065e565b61013191600191610c40816110af565b6109cf565b9061013191610c19565b3b610c5d610aa56000610725565b1190565b610c6b6027610875565b7f416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c6020820152660819985a5b195960ca1b604082015290565b61010c610c61565b61010c91610cb8610ca4565b91610cdd565b3d15610cd857610ccd3d610875565b903d6000602084013e565b606090565b60008061010c9493602081519101845af4610cf6610cbe565b91610d48565b15610d0357565b60405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000006044820152606490fd5b91929015610d7a57508151610d60610aa56000610725565b14610d69575090565b610d7561010c91610c4f565b610cfc565b82610d91565b90602061010c92818152019061057f565b90610d9a825190565b610da7610aa56000610725565b1115610db65750805190602001fd5b6106d490610dc360405190565b62461bcd60e51b815291829160048301610d80565b61010c9060081c610934565b61010c9054610dd8565b61093461010c61010c9290565b15610e0257565b60405162461bcd60e51b815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201526d191e481a5b9a5d1a585b1a5e995960921b6064820152608490fd5b61093461010c61010c9260ff1690565b90610e7e61010c610b7292610e5e565b825460ff191660ff9091161790565b90610e9d61010c610b7292151590565b825461ff00191660089190911b61ff00161790565b6103fe90610dee565b6020810192916101319190610eb2565b610f15610edf610edb6000610de4565b1590565b918280610fb7575b8015610f72575b610ef790610dfb565b82610f0c610f056001610dee565b6000610e6e565b610f6157610fd5565b610f1b57565b610f26600080610e8d565b7f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb3847402498610f5060405190565b80610f5c600182610ebb565b0390a1565b610f6d60016000610e8d565b610fd5565b50610f87610edb610f823061065e565b610c4f565b8015610eee5750610ef7610f9b600061093a565b610faf610fa86001610dee565b9160ff1690565b149050610eee565b50610fc2600061093a565b610fcf610fa86001610dee565b10610ee7565b50610131611059565b61013190610ecb565b15610fee57565b60405162461bcd60e51b815260206004820152602b60248201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960448201526a6e697469616c697a696e6760a81b6064820152608490fd5b6101316110546000610de4565b610fe7565b610131611047565b5061108b7f0000000000000000000000000d598920fc65439e71d2ce359e4a933d82900a4661065e565b61109761071433610100565b0361109e57565b6040516282b42960e81b8152600490fd5b61013190611061565b3561010c8161010f565b801515610118565b3561010c816110c2565b3561010c81610133565b6103fe90610100565b919461112561112c9298979561111e60a0966111176101319a61110e8960c081019f6110de565b15156020890152565b6040870152565b6060850152565b6080830152565b0152565b907f888dcbd019af251153dcb996aa5493b904206a294138c315a818b4e47f01cee09061115c836115b9565b611165836110b8565b610c14611174602086016110ca565b92611181604087016110d4565b9561119a60a0611193606084016110d4565b92016110d4565b906111a43361065e565b976111ae60405190565b968796876110e7565b634e487b7160e01b600052601160045260246000fd5b60001981146111dc5760010190565b6111b7565b634e487b7160e01b600052603260045260246000fd5b91908110156112075760051b0190565b6111e1565b905051906101318261010f565b9060208282031261011f5761010c9161120c565b9037565b8183529091602001916001600160fb1b03811161011f5782916103129160051b93849161122d565b91602061010c938181520191611231565b929796946111259061111e60a0966112a06112956101319b9661112c9860c08b5260c08b0191611231565b9c60208901906110de565b15156040870152565b9091926112b66000610725565b9384936112e27f0000000000000000000000004661ac8b3dbf8db241cc89a3edead3c88490083961065e565b926331a9108f60e11b946112f533610100565b965b848110156113a65761132e60206113176113128489896111f7565b6110d4565b604051809381928c83526004830190815260200190565b03818a5afa9081156113a157899161134e91600091611373575b50610100565b036113615761135c906111cd565b6112f7565b6040516357794b2f60e11b8152600490fd5b611394915060203d811161139a575b61138c81836102bc565b810190611219565b38611348565b503d611382565b610965565b5095509591925092506113b961010c8390565b11611433575b600080516020612c5d833981519152916113d8846115b9565b610c146113e4856110b8565b946113f1602082016110ca565b906113fe604082016110d4565b61141660a061140f606085016110d4565b93016110d4565b926114203361065e565b9861142a60405190565b9788978861126a565b61145c7f0000000000000000000000000d598920fc65439e71d2ce359e4a933d82900a4661065e565b91823b1561011f57600061146f60405190565b938490637b3d246960e11b825281838161148d888860048401611259565b03925af19283156113a157600080516020612c5d833981519152936114b5575b5091506113bf565b6114cd9060006114c581836102bc565b8101906103f3565b386114ad565b6114df6103fe91610100565b60601b90565b94906103129461151960959895611512611527966115068b611520976114d3565b151560f81b60148b0152565b6015890152565b6035870152565b6055850152565b6075830152565b903590601e198136030182121561011f570180359182916001600160401b03831161011f57602001809336031261011f57565b61010c913691610322565b60409061112c61013194969593966115888360608101996110de565b60208301906110de565b60208101929161013191906110de565b91602061013192949361112c8160408101976110de565b608081016115c6816110d4565b421161198b5760a08201906115da826110d4565b341061197957611629916116b0611694611620936116536115fa886110b8565b61164589602081019761160c896110ca565b9561162f6116296060604086019d8e6110d4565b95019d8e6110d4565b926110d4565b9261163960405190565b978896602088016114e5565b03601f1981018352826102bc565b61166561165e825190565b9160200190565b207b0ca2ba3432b932bab69029b4b3b732b21026b2b9b9b0b3b29d05199960211b600052601c52603c60002090565b6116aa6116a460c088018861152e565b90611561565b9061199c565b6116dc6107147f00000000000000000000000020e822d61f2011f21bc851c572b2bc42006fcebd610100565b03611967576116ea906110ca565b1561182a5761171f90611705610a00610a00611717966110b8565b9061170f3061065e565b9485916110d4565b91339061297f565b611771602061174d7f000000000000000000000000dd49bf14caae7a22bb6a58a76c4e998054859d9a61065e565b9361175760405190565b9283918291906370a0823160e01b5b835260048301611592565b0381865afa9081156113a15760009161180c575b50611795610aa561010c846110d4565b106117fa576117a3906110d4565b90803b1561011f576117d96000929183926117bd60405190565b948593849283919063a9059cbb60e01b835233600484016115a2565b03925af180156113a1576117ea5750565b6101319060006114c581836102bc565b604051633c57b48560e21b8152600490fd5b611824915060203d8111610add57610ace81836102bc565b38611785565b6118537f000000000000000000000000dd49bf14caae7a22bb6a58a76c4e998054859d9a61065e565b906118666118603061065e565b916110d4565b91803b1561011f5761189d60009391849261188060405190565b9586938492839190633e4b96f760e01b835288336004850161156c565b03925af19081156113a1576118dc92602092611951575b506118c4610a00610a00876110b8565b6040515b938492839182916370a0823160e01b611766565b03915afa9081156113a157600091611933575b506118ff610aa561010c846110d4565b1061192157611919611860610a00610a00610131956110b8565b90339061293a565b6040516308aeed0f60e21b8152600490fd5b61194b915060203d8111610add57610ace81836102bc565b386118ef565b6119619060006114c581836102bc565b386118b4565b604051635cd5d23360e01b8152600490fd5b6040516334472ad760e11b8152600490fd5b604051621af02b60eb1b8152600490fd5b61010c916119a991611b30565b9190916119e0565b634e487b7160e01b600052602160045260246000fd5b600511156119d157565b6119b1565b90610131826119c7565b6119ea60006119d6565b6119f3826119d6565b036119fb5750565b611a0560016119d6565b611a0e826119d6565b03611a535760405162461bcd60e51b815260206004820152601860248201527745434453413a20696e76616c6964207369676e617475726560401b6044820152606490fd5b611a5d60026119d6565b611a66826119d6565b03611ab05760405162461bcd60e51b815260206004820152601f60248201527f45434453413a20696e76616c6964207369676e6174757265206c656e677468006044820152606490fd5b611ac3611abd60036119d6565b916119d6565b14611aca57565b60405162461bcd60e51b815260206004820152602260248201527f45434453413a20696e76616c6964207369676e6174757265202773272076616c604482015261756560f01b6064820152608490fd5b61010061010c61010c9290565b61010c90611b1a565b908051611b40610aa56041610725565b03611b6257610220916020820151906060604084015193015160001a90611bab565b5050611b6e6000611b27565b90600290565b61010c90610725565b61112c61013194611ba4606094989795611b9a85608081019b9052565b60ff166020850152565b6040830152565b919291611bb783611b74565b611bd9610aa56fa2a8918ca85bafe22016d0b997e4df60600160ff1b03610725565b11611c3957611bf9600093602095611bf060405190565b94859485611b7d565b838052039060015afa156113a157600051611c146000611b27565b611c1d81610100565b611c2683610100565b14611c32575090600090565b9160019150565b50505050611c476000611b27565b90600390565b929190611c5933610100565b80611c837f00000000000000000000000020e822d61f2011f21bc851c572b2bc42006fcebd610100565b14159081611c9a575b5061109e5761010c93611d4f565b9050611cc86108657f0000000000000000000000000d598920fc65439e71d2ce359e4a933d82900a4661065e565b141538611c8c565b9060408061013193611ce28482519052565b60208181015160ff169085015201519101906110de565b9194611d3e611d4892989795611d3460e096611d2a6101319a611d208961014081019f9052565b60208901906110de565b60408701906110de565b60608501906110de565b6080830190611cd0565b0190611cd0565b5091611d5b6000610725565b8390818114611e725750611d6e8361065e565b92611d788461065e565b94611d823061065e565b956020611d8e60405190565b9182906370a0823160e01b82528180611daa8c60048301611592565b03915afa80156113a157611dc491600091611e5a575b5090565b10611921576000611dd660209561065e565b92611e0b81611e047f00000000000000000000000010d4df9a82131a2707fe2f529f18177aa5b08fba61065e565b809661293a565b611e44611e1784612852565b611e2087612852565b90611e2a60405190565b998a988997889663cf11eaad60e01b885260048801611cf9565b03925af19081156113a157600091611e5a575090565b61010c915060203d8111610add57610ace81836102bc565b935050505090565b61010c9291906000611c4d565b9190611e9233610100565b80611ebc7f00000000000000000000000020e822d61f2011f21bc851c572b2bc42006fcebd610100565b14159081611ed3575b5061109e5761010c92611ffd565b9050611f016108657f0000000000000000000000000d598920fc65439e71d2ce359e4a933d82900a4661065e565b141538611ec5565b611f2361010c93611f1c836060956110de565b6020830152565b816040820152016000815260200190565b6001600160401b0381116102dd5760051b60200190565b9061088261033283611f34565b90610131611f6583611f4b565b602081946108a9601f1991611f34565b919082039182116111dc57565b80518210156112075760209160051b010190565b90611fb6611faf611fa5845190565b8084529260200190565b9260200190565b9060005b818110611fc75750505090565b909192611fe4611fdd6001928651815260200190565b9460200190565b929101611fba565b90602061010c928181520190611f96565b506120086000610725565b91808381146121df576120356020612022610a008661065e565b61202b3061065e565b906118c860405190565b03915afa80156113a15761204e91600091611e5a575090565b106119215761207c7f00000000000000000000000003a074d130144fce6883f7ea3884c0a783d85fb361065e565b91823b1561011f576120ac9160009161209460405190565b9384928392630e79698760e01b845260048401611f09565b038134865af180156113a1576121c9575b50803b1561011f57604051631941278960e01b815260008160048183865af180156113a1576121b3575b506120f26001610725565b906120fc82611f58565b906121267f0000000000000000000000004661ac8b3dbf8db241cc89a3edead3c88490083961065e565b91602061213260405190565b633af7918f60e21b815293849060049082905afa9384156113a15760009561217561216e61217893602098611e44988b91612196575b50611f75565b9184611f82565b52565b6040519485938492839190630ad8132f60e31b835260048301611fec565b6121ad91508a3d8111610add57610ace81836102bc565b38612168565b6121c39060006114c581836102bc565b386120e7565b6121d99060006114c581836102bc565b386120bd565b50505090565b61010c91906000611e87565b91906121fc33610100565b806122267f00000000000000000000000020e822d61f2011f21bc851c572b2bc42006fcebd610100565b1415908161223d575b5061109e5761010c9261231f565b905061226b6108657f0000000000000000000000000d598920fc65439e71d2ce359e4a933d82900a4661065e565b14153861222f565b60ff16604d81116111dc57600a0a90565b818102929181159184041417156111dc57565b634e487b7160e01b600052601260045260246000fd5b81156122b7570490565b612297565b61010c612710610725565b61010c9081565b61010c90546122c7565b90610131946123106080949897956123096122fe6123179560a0885260a0880190611f96565b9a60208701906110de565b6040850152565b6060830152565b019015159052565b509061232b6000610725565b90828281146125b65761235d7f000000000000000000000000dd49bf14caae7a22bb6a58a76c4e998054859d9a61065e565b916123673061065e565b9161237160405190565b6020816370a0823160e01b96878252818061238f8960048301611592565b03915afa80156113a1576123a891600091611e5a575090565b106117fa576123d67f00000000000000000000000003a074d130144fce6883f7ea3884c0a783d85fb361065e565b946123e060405190565b636863a89560e01b8152600481018290526020816024818a5afa9081156113a15761247161244d612476938693600091612598575b5061244761244261242586612852565b9261243c612437602086015160ff1690565b612273565b90612284565b915190565b906122ad565b61246c6124586122bc565b9161243c61246660656122ce565b84611f75565b6122ad565b612b65565b95612483610a008461065e565b9261248d60405190565b96868852602088806124a28960048301611592565b0381885afa9788156113a157600098612569575b509060006124c76020959493611f58565b6124ef60016124d560405190565b9c8d978896879563026db39b60e01b8752600487016122d8565b03925af19283156113a15761251b9560209461254e575b50604051809681948293835260048301611592565b03915afa80156113a15761010c926000916125365750611f75565b6121ad915060203d8111610add57610ace81836102bc565b61256490853d8111610add57610ace81836102bc565b612506565b60209493929198506124c761258c600092873d8111610add57610ace81836102bc565b999293949550506124b6565b6125b0915060203d8111610add57610ace81836102bc565b38612415565b5050905090565b61010c919060006121f1565b939291906125f67f0000000000000000000000000d598920fc65439e71d2ce359e4a933d82900a4661065e565b61260261071433610100565b0361109e5761022094505090600092918392602083519301915af19061010c610cbe565b610220929190606060006125c9565b61265e7f0000000000000000000000000d598920fc65439e71d2ce359e4a933d82900a4661065e565b61266a61071433610100565b0361109e57610131906126b6565b1561267f57565b60405162461bcd60e51b815260206004820152600f60248201526e151c985b9cd9995c8819985a5b1959608a1b6044820152606490fd5b600080610131926126c63061065e565b316126d060405190565b90818003925af16126df610cbe565b50612678565b61013190612635565b91906127197f0000000000000000000000000d598920fc65439e71d2ce359e4a933d82900a4661065e565b61272561071433610100565b0361109e576101319261273e610a00610131949361065e565b61293a565b9061013192916126ee565b6127777f0000000000000000000000000d598920fc65439e71d2ce359e4a933d82900a4661065e565b61278361071433610100565b0361109e57610131906127a8565b906127a161010c610b7292610725565b8254611dc0565b6127b36103e8610725565b81116127c457610131906065612791565b60405163b4fa3fb360e01b8152600490fd5b6101319061274e565b61010c60606102e2565b6127f16127df565b9081600081526000602082015260406000910152565b61010c6127e9565b60ff8116610118565b905051906101318261280f565b919060408382031261011f5780602061284161010c9386610944565b9401612818565b906103fe90610100565b61285a612807565b506128847f0000000000000000000000006eb57a62e466c628858092eb8cb281dd6381be4261065e565b6040805191829062593bcf60e01b825281806128a38760048301611592565b03915afa9182156113a15760009182936128da575b506128d161010c9293611b9a6128cc6127df565b958652565b60408301612848565b6128d1935061010c92506129049060403d811161290d575b6128fc81836102bc565b810190612825565b939092506128b8565b503d6128f2565b61292d61292761010c9263ffffffff1690565b60e01b90565b6001600160e01b03191690565b61297a6101319361296c61295163a9059cbb612914565b9161295b60405190565b9586936020850152602484016115a2565b03601f1981018452836102bc565b6129d5565b909161297a9061296c610131956129996323b872dd612914565b926129a360405190565b96879460208601526024850161156c565b90505190610131826110c2565b9060208282031261011f5761010c916129b4565b6129e16129e89161065e565b9182612a4f565b80516129f7610aa56000610725565b14159081612a2b575b50612a085750565b6106d490612a1560405190565b635274afe760e01b815291829160048301611592565b612a49915080602080612a3f610edb945190565b83010191016129c1565b38612a00565b61010c91612a5d6000610725565b612a663061065e565b81813110612a9057506000828192602061010c969551920190855af1612a8a610cbe565b91612ab3565b6106d490612a9d60405190565b63cd78605960e01b815291829160048301611592565b90612abe5750612b18565b612ad9612ac9835190565b612ad36000610725565b91829190565b149081612b0d575b50612aea575090565b6106d490612af760405190565b639996b31560e01b815291829160048301611592565b9050813b1438612ae1565b8051612b27610aa56000610725565b1115612b3557805190602001fd5b604051630a12f52160e11b8152600490fd5b61010c6012610dee565b9060208282031261011f5761010c91612818565b612b79610a00612b73612b47565b9361065e565b916020612b8560405190565b63313ce56760e01b815293849060049082905afa9182156113a15761010c93600093612bb2575b50612bfb565b612bd491935060203d8111612bdb575b612bcc81836102bc565b810190612b51565b9138612bac565b503d612bc2565b612bee9060ff16610fa8565b90039060ff82116111dc57565b9060ff831660ff821681811015612c1e57505061243761243c9161010c94612be2565b93929311612c2b57505090565b61243761010c939261244792612be256fe46756e6374696f6e206d7573742062652063616c6c6564207468726f756768203fa83e03852010fdfc42d4660bb125b74c3101b72645002d6773ab2cd8c1d455a2646970667358221220c0395ccbb9292eba91b7882bcd95a87a34af640db95ad8c169add62b81bf63fa64736f6c63430008140033
Constructor Arguments (ABI-Encoded and is the last bytes of the Contract Creation Code above)
00000000000000000000000020e822d61f2011f21bc851c572b2bc42006fcebd000000000000000000000000dd49bf14caae7a22bb6a58a76c4e998054859d9a0000000000000000000000004661ac8b3dbf8db241cc89a3edead3c8849008390000000000000000000000000d598920fc65439e71d2ce359e4a933d82900a4600000000000000000000000003a074d130144fce6883f7ea3884c0a783d85fb300000000000000000000000010d4df9a82131a2707fe2f529f18177aa5b08fba0000000000000000000000006eb57a62e466c628858092eb8cb281dd6381be42
-----Decoded View---------------
Arg [0] : _signer (address): 0x20E822D61f2011F21bc851c572b2BC42006FCEbD
Arg [1] : _sharesToken (address): 0xDD49bF14cAAE7a22bb6a58A76C4E998054859D9a
Arg [2] : _receiptContract (address): 0x4661Ac8b3Dbf8Db241Cc89a3EdeAD3c884900839
Arg [3] : _admin (address): 0x0d598920fc65439e71D2CE359E4A933d82900A46
Arg [4] : _strategyRouter (address): 0x03A074D130144FcE6883F7EA3884C0a783d85Fb3
Arg [5] : _exchange (address): 0x10D4Df9A82131a2707fE2F529F18177Aa5B08FbA
Arg [6] : _oracle (address): 0x6Eb57a62e466c628858092Eb8cB281dD6381BE42
-----Encoded View---------------
7 Constructor Arguments found :
Arg [0] : 00000000000000000000000020e822d61f2011f21bc851c572b2bc42006fcebd
Arg [1] : 000000000000000000000000dd49bf14caae7a22bb6a58a76c4e998054859d9a
Arg [2] : 0000000000000000000000004661ac8b3dbf8db241cc89a3edead3c884900839
Arg [3] : 0000000000000000000000000d598920fc65439e71d2ce359e4a933d82900a46
Arg [4] : 00000000000000000000000003a074d130144fce6883f7ea3884c0a783d85fb3
Arg [5] : 00000000000000000000000010d4df9a82131a2707fe2f529f18177aa5b08fba
Arg [6] : 0000000000000000000000006eb57a62e466c628858092eb8cb281dd6381be42
Loading...
Loading
Loading...
Loading
Loading...
Loading
Net Worth in USD
$0.00
Net Worth in ETH
Multichain Portfolio | 34 Chains
| Chain | Token | Portfolio % | Price | Amount | Value |
|---|
Loading...
Loading
Loading...
Loading
Loading...
Loading
[ Download: CSV Export ]
A contract address hosts a smart contract, which is a set of code stored on the blockchain that runs when predetermined conditions are met. Learn more about addresses in our Knowledge Base.