Source Code
Overview
ETH Balance
0 ETH
Eth Value
$0.00View more zero value Internal Transactions in Advanced View mode
Advanced mode:
Loading...
Loading
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:
Distribution
Compiler Version
v0.8.20+commit.a1b79de6
Optimization Enabled:
Yes with 200 runs
Other Settings:
paris EvmVersion
Contract Source Code (Solidity Standard Json-Input format)
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;
import {SafeERC20, IERC20} from "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
import {UUPSUpgradeable} from "@openzeppelin/contracts-upgradeable/proxy/utils/UUPSUpgradeable.sol";
import {OwnableUpgradeable} from "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol";
import {PRECISION} from "@solarity/solidity-lib/utils/Globals.sol";
import {LinearDistributionIntervalDecrease} from "./libs/LinearDistributionIntervalDecrease.sol";
import {L1Sender} from "./L1Sender.sol";
import {IDistribution} from "./interfaces/IDistribution.sol";
contract Distribution is IDistribution, OwnableUpgradeable, UUPSUpgradeable {
using SafeERC20 for IERC20;
bool public isNotUpgradeable;
address public depositToken;
address public l1Sender;
// Pool storage
Pool[] public pools;
mapping(uint256 => PoolData) public poolsData;
// User storage
mapping(address => mapping(uint256 => UserData)) public usersData;
// Total deposited storage
uint256 public totalDepositedInPublicPools;
/**********************************************************************************************/
/*** Modifiers ***/
/**********************************************************************************************/
modifier poolExists(uint256 poolId_) {
require(_poolExists(poolId_), "DS: pool doesn't exist");
_;
}
modifier poolPublic(uint256 poolId_) {
require(pools[poolId_].isPublic, "DS: pool isn't public");
_;
}
/**********************************************************************************************/
/*** Init ***/
/**********************************************************************************************/
constructor() {
_disableInitializers();
}
function Distribution_init(
address depositToken_,
address l1Sender_,
Pool[] calldata poolsInfo_
) external initializer {
__Ownable_init();
__UUPSUpgradeable_init();
for (uint256 i; i < poolsInfo_.length; ++i) {
createPool(poolsInfo_[i]);
}
depositToken = depositToken_;
l1Sender = l1Sender_;
}
/**********************************************************************************************/
/*** Pool managment and data retrieval ***/
/**********************************************************************************************/
function createPool(Pool calldata pool_) public onlyOwner {
require(pool_.payoutStart > block.timestamp, "DS: invalid payout start value");
_validatePool(pool_);
pools.push(pool_);
emit PoolCreated(pools.length - 1, pool_);
}
function editPool(uint256 poolId_, Pool calldata pool_) external onlyOwner poolExists(poolId_) {
_validatePool(pool_);
require(pools[poolId_].isPublic == pool_.isPublic, "DS: invalid pool type");
PoolData storage poolData = poolsData[poolId_];
uint256 currentPoolRate_ = _getCurrentPoolRate(poolId_);
// Update pool data
poolData.rate = currentPoolRate_;
poolData.lastUpdate = uint128(block.timestamp);
pools[poolId_] = pool_;
emit PoolEdited(poolId_, pool_);
}
function getPeriodReward(uint256 poolId_, uint128 startTime_, uint128 endTime_) public view returns (uint256) {
if (!_poolExists(poolId_)) {
return 0;
}
Pool storage pool = pools[poolId_];
return
LinearDistributionIntervalDecrease.getPeriodReward(
pool.initialReward,
pool.rewardDecrease,
pool.payoutStart,
pool.decreaseInterval,
startTime_,
endTime_
);
}
function _validatePool(Pool calldata pool_) private pure {
require(pool_.decreaseInterval > 0, "DS: invalid decrease interval");
}
/**********************************************************************************************/
/*** User management in private pools ***/
/**********************************************************************************************/
function manageUsersInPrivatePool(
uint256 poolId_,
address[] calldata users_,
uint256[] calldata amounts_
) external onlyOwner poolExists(poolId_) {
require(!pools[poolId_].isPublic, "DS: pool is public");
require(users_.length == amounts_.length, "DS: invalid length");
uint256 currentPoolRate_ = _getCurrentPoolRate(poolId_);
for (uint256 i; i < users_.length; ++i) {
address user_ = users_[i];
uint256 amount_ = amounts_[i];
uint256 deposited_ = usersData[user_][poolId_].deposited;
if (deposited_ < amount_) {
_stake(user_, poolId_, amount_ - deposited_, currentPoolRate_);
} else if (deposited_ > amount_) {
_withdraw(user_, poolId_, deposited_ - amount_, currentPoolRate_);
}
}
}
/**********************************************************************************************/
/*** Stake, claim, withdraw ***/
/**********************************************************************************************/
function stake(uint256 poolId_, uint256 amount_) external poolExists(poolId_) poolPublic(poolId_) {
_stake(_msgSender(), poolId_, amount_, _getCurrentPoolRate(poolId_));
}
function claim(uint256 poolId_, address receiver_) external payable poolExists(poolId_) {
address user_ = _msgSender();
Pool storage pool = pools[poolId_];
PoolData storage poolData = poolsData[poolId_];
UserData storage userData = usersData[user_][poolId_];
require(block.timestamp > pool.payoutStart + pool.claimLockPeriod, "DS: pool claim is locked");
uint256 currentPoolRate_ = _getCurrentPoolRate(poolId_);
uint256 pendingRewards_ = _getCurrentUserReward(currentPoolRate_, userData);
require(pendingRewards_ > 0, "DS: nothing to claim");
// Update pool data
poolData.lastUpdate = uint128(block.timestamp);
poolData.rate = currentPoolRate_;
// Update user data
userData.rate = currentPoolRate_;
userData.pendingRewards = 0;
// Transfer rewards
L1Sender(l1Sender).sendMintMessage{value: msg.value}(receiver_, pendingRewards_, user_);
emit UserClaimed(poolId_, user_, receiver_, pendingRewards_);
}
function withdraw(uint256 poolId_, uint256 amount_) external poolExists(poolId_) poolPublic(poolId_) {
_withdraw(_msgSender(), poolId_, amount_, _getCurrentPoolRate(poolId_));
}
function getCurrentUserReward(uint256 poolId_, address user_) external view returns (uint256) {
if (!_poolExists(poolId_)) {
return 0;
}
UserData storage userData = usersData[user_][poolId_];
uint256 currentPoolRate_ = _getCurrentPoolRate(poolId_);
return _getCurrentUserReward(currentPoolRate_, userData);
}
function _stake(address user_, uint256 poolId_, uint256 amount_, uint256 currentPoolRate_) private {
require(amount_ > 0, "DS: nothing to stake");
Pool storage pool = pools[poolId_];
PoolData storage poolData = poolsData[poolId_];
UserData storage userData = usersData[user_][poolId_];
if (pool.isPublic) {
// https://docs.lido.fi/guides/lido-tokens-integration-guide/#steth-internals-share-mechanics
uint256 balanceBefore_ = IERC20(depositToken).balanceOf(address(this));
IERC20(depositToken).safeTransferFrom(_msgSender(), address(this), amount_);
uint256 balanceAfter_ = IERC20(depositToken).balanceOf(address(this));
amount_ = balanceAfter_ - balanceBefore_;
require(userData.deposited + amount_ >= pool.minimalStake, "DS: amount too low");
totalDepositedInPublicPools += amount_;
}
userData.pendingRewards = _getCurrentUserReward(currentPoolRate_, userData);
// Update pool data
poolData.lastUpdate = uint128(block.timestamp);
poolData.rate = currentPoolRate_;
poolData.totalDeposited += amount_;
// Update user data
userData.lastStake = uint128(block.timestamp);
userData.rate = currentPoolRate_;
userData.deposited += amount_;
emit UserStaked(poolId_, user_, amount_);
}
function _withdraw(address user_, uint256 poolId_, uint256 amount_, uint256 currentPoolRate_) private {
Pool storage pool = pools[poolId_];
PoolData storage poolData = poolsData[poolId_];
UserData storage userData = usersData[user_][poolId_];
uint256 deposited_ = userData.deposited;
require(deposited_ > 0, "DS: user isn't staked");
if (amount_ > deposited_) {
amount_ = deposited_;
}
uint256 newDeposited_;
if (pool.isPublic) {
require(
block.timestamp < pool.payoutStart ||
(block.timestamp > pool.payoutStart + pool.withdrawLockPeriod &&
block.timestamp > userData.lastStake + pool.withdrawLockPeriodAfterStake),
"DS: pool withdraw is locked"
);
uint256 depositTokenContractBalance_ = IERC20(depositToken).balanceOf(address(this));
if (amount_ > depositTokenContractBalance_) {
amount_ = depositTokenContractBalance_;
}
newDeposited_ = deposited_ - amount_;
require(amount_ > 0, "DS: nothing to withdraw");
require(newDeposited_ >= pool.minimalStake || newDeposited_ == 0, "DS: invalid withdraw amount");
} else {
newDeposited_ = deposited_ - amount_;
}
uint256 pendingRewards_ = _getCurrentUserReward(currentPoolRate_, userData);
// Update pool data
poolData.lastUpdate = uint128(block.timestamp);
poolData.rate = currentPoolRate_;
poolData.totalDeposited -= amount_;
// Update user data
userData.rate = currentPoolRate_;
userData.deposited = newDeposited_;
userData.pendingRewards = pendingRewards_;
if (pool.isPublic) {
totalDepositedInPublicPools -= amount_;
IERC20(depositToken).safeTransfer(user_, amount_);
}
emit UserWithdrawn(poolId_, user_, amount_);
}
function _getCurrentUserReward(uint256 currentPoolRate_, UserData memory userData_) private pure returns (uint256) {
uint256 newRewards_ = ((currentPoolRate_ - userData_.rate) * userData_.deposited) / PRECISION;
return userData_.pendingRewards + newRewards_;
}
function _getCurrentPoolRate(uint256 poolId_) private view returns (uint256) {
PoolData storage poolData = poolsData[poolId_];
if (poolData.totalDeposited == 0) {
return poolData.rate;
}
uint256 rewards_ = getPeriodReward(poolId_, poolData.lastUpdate, uint128(block.timestamp));
return poolData.rate + (rewards_ * PRECISION) / poolData.totalDeposited;
}
function _poolExists(uint256 poolId_) private view returns (bool) {
return poolId_ < pools.length;
}
/**********************************************************************************************/
/*** Bridge ***/
/**********************************************************************************************/
function overplus() public view returns (uint256) {
uint256 depositTokenContractBalance_ = IERC20(depositToken).balanceOf(address(this));
if (depositTokenContractBalance_ <= totalDepositedInPublicPools) {
return 0;
}
return depositTokenContractBalance_ - totalDepositedInPublicPools;
}
function bridgeOverplus(
uint256 gasLimit_,
uint256 maxFeePerGas_,
uint256 maxSubmissionCost_
) external payable onlyOwner returns (bytes memory) {
uint256 overplus_ = overplus();
require(overplus_ > 0, "DS: overplus is zero");
IERC20(depositToken).safeTransfer(l1Sender, overplus_);
bytes memory bridgeMessageId_ = L1Sender(l1Sender).sendDepositToken{value: msg.value}(
gasLimit_,
maxFeePerGas_,
maxSubmissionCost_
);
emit OverplusBridged(overplus_, bridgeMessageId_);
return bridgeMessageId_;
}
/**********************************************************************************************/
/*** UUPS ***/
/**********************************************************************************************/
function removeUpgradeability() external onlyOwner {
isNotUpgradeable = true;
}
function _authorizeUpgrade(address) internal view override onlyOwner {
require(!isNotUpgradeable, "DS: upgrade isn't available");
}
}// SPDX-License-Identifier: Apache-2.0
/*
* Copyright 2021, Offchain Labs, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
pragma solidity ^0.8.0;
/// @notice this library manages encoding and decoding of gateway communication
library GatewayMessageHandler {
// these are for communication from L1 to L2 gateway
function encodeToL2GatewayMsg(bytes memory gatewayData, bytes memory callHookData)
internal
pure
returns (bytes memory res)
{
res = abi.encode(gatewayData, callHookData);
}
function parseFromL1GatewayMsg(bytes calldata _data)
internal
pure
returns (bytes memory gatewayData, bytes memory callHookData)
{
// abi decode may revert, but the encoding is done by L1 gateway, so we trust it
(gatewayData, callHookData) = abi.decode(_data, (bytes, bytes));
}
// these are for communication from L2 to L1 gateway
function encodeFromL2GatewayMsg(uint256 exitNum, bytes memory callHookData)
internal
pure
returns (bytes memory res)
{
res = abi.encode(exitNum, callHookData);
}
function parseToL1GatewayMsg(bytes calldata _data)
internal
pure
returns (uint256 exitNum, bytes memory callHookData)
{
// abi decode may revert, but the encoding is done by L1 gateway, so we trust it
(exitNum, callHookData) = abi.decode(_data, (uint256, bytes));
}
// these are for communication from router to gateway
function encodeFromRouterToGateway(address _from, bytes calldata _data)
internal
pure
returns (bytes memory res)
{
// abi decode may revert, but the encoding is done by L1 gateway, so we trust it
return abi.encode(_from, _data);
}
function parseFromRouterToGateway(bytes calldata _data)
internal
pure
returns (address, bytes memory res)
{
// abi decode may revert, but the encoding is done by L1 gateway, so we trust it
return abi.decode(_data, (address, bytes));
}
}// SPDX-License-Identifier: Apache-2.0
/*
* Copyright 2020, Offchain Labs, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
pragma solidity ^0.8.0;
import "../ProxyUtil.sol";
import "@openzeppelin/contracts/utils/Address.sol";
import "./TokenGateway.sol";
import "./GatewayMessageHandler.sol";
/**
* @title Common interface for L1 and L2 Gateway Routers
*/
interface IGatewayRouter is ITokenGateway {
function defaultGateway() external view returns (address gateway);
event TransferRouted(
address indexed token,
address indexed _userFrom,
address indexed _userTo,
address gateway
);
event GatewaySet(address indexed l1Token, address indexed gateway);
event DefaultGatewayUpdated(address newDefaultGateway);
function getGateway(address _token) external view returns (address gateway);
}// SPDX-License-Identifier: Apache-2.0
/*
* Copyright 2020, Offchain Labs, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
// solhint-disable-next-line compiler-version
pragma solidity >=0.6.9 <0.9.0;
interface ITokenGateway {
/// @notice event deprecated in favor of DepositInitiated and WithdrawalInitiated
// event OutboundTransferInitiated(
// address token,
// address indexed _from,
// address indexed _to,
// uint256 indexed _transferId,
// uint256 _amount,
// bytes _data
// );
/// @notice event deprecated in favor of DepositFinalized and WithdrawalFinalized
// event InboundTransferFinalized(
// address token,
// address indexed _from,
// address indexed _to,
// uint256 indexed _transferId,
// uint256 _amount,
// bytes _data
// );
function outboundTransfer(
address _token,
address _to,
uint256 _amount,
uint256 _maxGas,
uint256 _gasPriceBid,
bytes calldata _data
) external payable returns (bytes memory);
function finalizeInboundTransfer(
address _token,
address _from,
address _to,
uint256 _amount,
bytes calldata _data
) external payable;
/**
* @notice Calculate the address used when bridging an ERC20 token
* @dev the L1 and L2 address oracles may not always be in sync.
* For example, a custom token may have been registered but not deploy or the contract self destructed.
* @param l1ERC20 address of L1 token
* @return L2 address of a bridged ERC20 token
*/
function calculateL2TokenAddress(address l1ERC20) external view returns (address);
function getOutboundCalldata(
address _token,
address _from,
address _to,
uint256 _amount,
bytes memory _data
) external view returns (bytes memory);
}// SPDX-License-Identifier: Apache-2.0
/*
* Copyright 2020, Offchain Labs, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
pragma solidity ^0.8.0;
import "./ITokenGateway.sol";
import "@openzeppelin/contracts/utils/Address.sol";
abstract contract TokenGateway is ITokenGateway {
using Address for address;
address public counterpartGateway;
address public router;
// This modifier is overriden in gateways to validate the message sender
// For L1 to L2 messages need to be validated against the aliased counterpartGateway
// For L2 to L1 messages need to be validated against the bridge and L2ToL1Sender
// prettier-ignore
modifier onlyCounterpartGateway() virtual;
function _initialize(address _counterpartGateway, address _router) internal virtual {
// This initializes internal variables of the abstract contract it can be chained together with other functions.
// It is virtual so subclasses can override or wrap around this logic.
// An example where this is useful is different subclasses that validate the router address differently
require(_counterpartGateway != address(0), "INVALID_COUNTERPART");
require(counterpartGateway == address(0), "ALREADY_INIT");
counterpartGateway = _counterpartGateway;
router = _router;
}
function isRouter(address _target) internal view returns (bool isTargetRouter) {
return _target == router;
}
/**
* @notice Calculate the address used when bridging an ERC20 token
* @dev the L1 and L2 address oracles may not always be in sync.
* For example, a custom token may have been registered but not deploy or the contract self destructed.
* @param l1ERC20 address of L1 token
* @return L2 address of a bridged ERC20 token
*/
function calculateL2TokenAddress(address l1ERC20)
public
view
virtual
override
returns (address);
}// SPDX-License-Identifier: Apache-2.0
/*
* Copyright 2021, Offchain Labs, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
pragma solidity ^0.8.0;
library ProxyUtil {
function getProxyAdmin() internal view returns (address admin) {
// https://github.com/OpenZeppelin/openzeppelin-contracts/blob/v3.4.0/contracts/proxy/TransparentUpgradeableProxy.sol#L48
// Storage slot with the admin of the proxy contract.
// This is the keccak-256 hash of "eip1967.proxy.admin" subtracted by 1, and is
bytes32 slot = 0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103;
assembly {
admin := sload(slot)
}
}
}// SPDX-License-Identifier: BUSL-1.1
pragma solidity >=0.5.0;
import "./ILayerZeroUserApplicationConfig.sol";
interface ILayerZeroEndpoint is ILayerZeroUserApplicationConfig {
// @notice send a LayerZero message to the specified address at a LayerZero endpoint.
// @param _dstChainId - the destination chain identifier
// @param _destination - the address on destination chain (in bytes). address length/format may vary by chains
// @param _payload - a custom bytes payload to send to the destination contract
// @param _refundAddress - if the source transaction is cheaper than the amount of value passed, refund the additional amount to this address
// @param _zroPaymentAddress - the address of the ZRO token holder who would pay for the transaction
// @param _adapterParams - parameters for custom functionality. e.g. receive airdropped native gas from the relayer on destination
function send(
uint16 _dstChainId,
bytes calldata _destination,
bytes calldata _payload,
address payable _refundAddress,
address _zroPaymentAddress,
bytes calldata _adapterParams
) external payable;
// @notice used by the messaging library to publish verified payload
// @param _srcChainId - the source chain identifier
// @param _srcAddress - the source contract (as bytes) at the source chain
// @param _dstAddress - the address on destination chain
// @param _nonce - the unbound message ordering nonce
// @param _gasLimit - the gas limit for external contract execution
// @param _payload - verified payload to send to the destination contract
function receivePayload(
uint16 _srcChainId,
bytes calldata _srcAddress,
address _dstAddress,
uint64 _nonce,
uint _gasLimit,
bytes calldata _payload
) external;
// @notice get the inboundNonce of a receiver from a source chain which could be EVM or non-EVM chain
// @param _srcChainId - the source chain identifier
// @param _srcAddress - the source chain contract address
function getInboundNonce(uint16 _srcChainId, bytes calldata _srcAddress) external view returns (uint64);
// @notice get the outboundNonce from this source chain which, consequently, is always an EVM
// @param _srcAddress - the source chain contract address
function getOutboundNonce(uint16 _dstChainId, address _srcAddress) external view returns (uint64);
// @notice gets a quote in source native gas, for the amount that send() requires to pay for message delivery
// @param _dstChainId - the destination chain identifier
// @param _userApplication - the user app address on this EVM chain
// @param _payload - the custom message to send over LayerZero
// @param _payInZRO - if false, user app pays the protocol fee in native token
// @param _adapterParam - parameters for the adapter service, e.g. send some dust native token to dstChain
function estimateFees(
uint16 _dstChainId,
address _userApplication,
bytes calldata _payload,
bool _payInZRO,
bytes calldata _adapterParam
) external view returns (uint nativeFee, uint zroFee);
// @notice get this Endpoint's immutable source identifier
function getChainId() external view returns (uint16);
// @notice the interface to retry failed message on this Endpoint destination
// @param _srcChainId - the source chain identifier
// @param _srcAddress - the source chain contract address
// @param _payload - the payload to be retried
function retryPayload(uint16 _srcChainId, bytes calldata _srcAddress, bytes calldata _payload) external;
// @notice query if any STORED payload (message blocking) at the endpoint.
// @param _srcChainId - the source chain identifier
// @param _srcAddress - the source chain contract address
function hasStoredPayload(uint16 _srcChainId, bytes calldata _srcAddress) external view returns (bool);
// @notice query if the _libraryAddress is valid for sending msgs.
// @param _userApplication - the user app address on this EVM chain
function getSendLibraryAddress(address _userApplication) external view returns (address);
// @notice query if the _libraryAddress is valid for receiving msgs.
// @param _userApplication - the user app address on this EVM chain
function getReceiveLibraryAddress(address _userApplication) external view returns (address);
// @notice query if the non-reentrancy guard for send() is on
// @return true if the guard is on. false otherwise
function isSendingPayload() external view returns (bool);
// @notice query if the non-reentrancy guard for receive() is on
// @return true if the guard is on. false otherwise
function isReceivingPayload() external view returns (bool);
// @notice get the configuration of the LayerZero messaging library of the specified version
// @param _version - messaging library version
// @param _chainId - the chainId for the pending config change
// @param _userApplication - the contract address of the user application
// @param _configType - type of configuration. every messaging library has its own convention.
function getConfig(
uint16 _version,
uint16 _chainId,
address _userApplication,
uint _configType
) external view returns (bytes memory);
// @notice get the send() LayerZero messaging library version
// @param _userApplication - the contract address of the user application
function getSendVersion(address _userApplication) external view returns (uint16);
// @notice get the lzReceive() LayerZero messaging library version
// @param _userApplication - the contract address of the user application
function getReceiveVersion(address _userApplication) external view returns (uint16);
}// SPDX-License-Identifier: BUSL-1.1
pragma solidity >=0.5.0;
interface ILayerZeroUserApplicationConfig {
// @notice set the configuration of the LayerZero messaging library of the specified version
// @param _version - messaging library version
// @param _chainId - the chainId for the pending config change
// @param _configType - type of configuration. every messaging library has its own convention.
// @param _config - configuration in the bytes. can encode arbitrary content.
function setConfig(uint16 _version, uint16 _chainId, uint _configType, bytes calldata _config) external;
// @notice set the send() LayerZero messaging library version to _version
// @param _version - new messaging library version
function setSendVersion(uint16 _version) external;
// @notice set the lzReceive() LayerZero messaging library version to _version
// @param _version - new messaging library version
function setReceiveVersion(uint16 _version) external;
// @notice Only when the UA needs to resume the message flow in blocking mode and clear the stored payload
// @param _srcChainId - the chainId of the source chain
// @param _srcAddress - the contract address of the source contract at the source chain
function forceResumeReceive(uint16 _srcChainId, bytes calldata _srcAddress) external;
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (access/Ownable.sol)
pragma solidity ^0.8.0;
import "../utils/ContextUpgradeable.sol";
import "../proxy/utils/Initializable.sol";
/**
* @dev Contract module which provides a basic access control mechanism, where
* there is an account (an owner) that can be granted exclusive access to
* specific functions.
*
* By default, the owner account will be the one that deploys the contract. This
* can later be changed with {transferOwnership}.
*
* This module is used through inheritance. It will make available the modifier
* `onlyOwner`, which can be applied to your functions to restrict their use to
* the owner.
*/
abstract contract OwnableUpgradeable is Initializable, ContextUpgradeable {
address private _owner;
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
/**
* @dev Initializes the contract setting the deployer as the initial owner.
*/
function __Ownable_init() internal onlyInitializing {
__Ownable_init_unchained();
}
function __Ownable_init_unchained() internal onlyInitializing {
_transferOwnership(_msgSender());
}
/**
* @dev Throws if called by any account other than the owner.
*/
modifier onlyOwner() {
_checkOwner();
_;
}
/**
* @dev Returns the address of the current owner.
*/
function owner() public view virtual returns (address) {
return _owner;
}
/**
* @dev Throws if the sender is not the owner.
*/
function _checkOwner() internal view virtual {
require(owner() == _msgSender(), "Ownable: caller is not the owner");
}
/**
* @dev Leaves the contract without owner. It will not be possible to call
* `onlyOwner` functions. Can only be called by the current owner.
*
* NOTE: Renouncing ownership will leave the contract without an owner,
* thereby disabling any functionality that is only available to the owner.
*/
function renounceOwnership() public virtual onlyOwner {
_transferOwnership(address(0));
}
/**
* @dev Transfers ownership of the contract to a new account (`newOwner`).
* Can only be called by the current owner.
*/
function transferOwnership(address newOwner) public virtual onlyOwner {
require(newOwner != address(0), "Ownable: new owner is the zero address");
_transferOwnership(newOwner);
}
/**
* @dev Transfers ownership of the contract to a new account (`newOwner`).
* Internal function without access restriction.
*/
function _transferOwnership(address newOwner) internal virtual {
address oldOwner = _owner;
_owner = newOwner;
emit OwnershipTransferred(oldOwner, newOwner);
}
/**
* @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[49] private __gap;
}// 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 v4.4.1 (utils/Context.sol)
pragma solidity ^0.8.0;
import "../proxy/utils/Initializable.sol";
/**
* @dev Provides information about the current execution context, including the
* sender of the transaction and its data. While these are generally available
* via msg.sender and msg.data, they should not be accessed in such a direct
* manner, since when dealing with meta-transactions the account sending and
* paying for execution may not be the actual sender (as far as an application
* is concerned).
*
* This contract is only required for intermediate, library-like contracts.
*/
abstract contract ContextUpgradeable is Initializable {
function __Context_init() internal onlyInitializing {
}
function __Context_init_unchained() internal onlyInitializing {
}
function _msgSender() internal view virtual returns (address) {
return msg.sender;
}
function _msgData() internal view virtual returns (bytes calldata) {
return msg.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) (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) (token/ERC20/extensions/IERC20Permit.sol)
pragma solidity ^0.8.0;
/**
* @dev Interface of the ERC20 Permit extension allowing approvals to be made via signatures, as defined in
* https://eips.ethereum.org/EIPS/eip-2612[EIP-2612].
*
* Adds the {permit} method, which can be used to change an account's ERC20 allowance (see {IERC20-allowance}) by
* presenting a message signed by the account. By not relying on {IERC20-approve}, the token holder account doesn't
* need to send a transaction, and thus is not required to hold Ether at all.
*/
interface IERC20Permit {
/**
* @dev Sets `value` as the allowance of `spender` over ``owner``'s tokens,
* given ``owner``'s signed approval.
*
* IMPORTANT: The same issues {IERC20-approve} has related to transaction
* ordering also apply here.
*
* Emits an {Approval} event.
*
* Requirements:
*
* - `spender` cannot be the zero address.
* - `deadline` must be a timestamp in the future.
* - `v`, `r` and `s` must be a valid `secp256k1` signature from `owner`
* over the EIP712-formatted function arguments.
* - the signature must use ``owner``'s current nonce (see {nonces}).
*
* For more information on the signature format, see the
* https://eips.ethereum.org/EIPS/eip-2612#specification[relevant EIP
* section].
*/
function permit(
address owner,
address spender,
uint256 value,
uint256 deadline,
uint8 v,
bytes32 r,
bytes32 s
) external;
/**
* @dev Returns the current nonce for `owner`. This value must be
* included whenever a signature is generated for {permit}.
*
* Every successful call to {permit} increases ``owner``'s nonce by one. This
* prevents a signature from being used multiple times.
*/
function nonces(address owner) external view returns (uint256);
/**
* @dev Returns the domain separator used in the encoding of the signature for {permit}, as defined by {EIP712}.
*/
// solhint-disable-next-line func-name-mixedcase
function DOMAIN_SEPARATOR() external view returns (bytes32);
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (token/ERC20/IERC20.sol)
pragma solidity ^0.8.0;
/**
* @dev Interface of the ERC20 standard as defined in the EIP.
*/
interface IERC20 {
/**
* @dev Emitted when `value` tokens are moved from one account (`from`) to
* another (`to`).
*
* Note that `value` may be zero.
*/
event Transfer(address indexed from, address indexed to, uint256 value);
/**
* @dev Emitted when the allowance of a `spender` for an `owner` is set by
* a call to {approve}. `value` is the new allowance.
*/
event Approval(address indexed owner, address indexed spender, uint256 value);
/**
* @dev Returns the amount of tokens in existence.
*/
function totalSupply() external view returns (uint256);
/**
* @dev Returns the amount of tokens owned by `account`.
*/
function balanceOf(address account) external view returns (uint256);
/**
* @dev Moves `amount` tokens from the caller's account to `to`.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transfer(address to, uint256 amount) external returns (bool);
/**
* @dev Returns the remaining number of tokens that `spender` will be
* allowed to spend on behalf of `owner` through {transferFrom}. This is
* zero by default.
*
* This value changes when {approve} or {transferFrom} are called.
*/
function allowance(address owner, address spender) external view returns (uint256);
/**
* @dev Sets `amount` as the allowance of `spender` over the caller's tokens.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* IMPORTANT: Beware that changing an allowance with this method brings the risk
* that someone may use both the old and the new allowance by unfortunate
* transaction ordering. One possible solution to mitigate this race
* condition is to first reduce the spender's allowance to 0 and set the
* desired value afterwards:
* https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
*
* Emits an {Approval} event.
*/
function approve(address spender, uint256 amount) external returns (bool);
/**
* @dev Moves `amount` tokens from `from` to `to` using the
* allowance mechanism. `amount` is then deducted from the caller's
* allowance.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transferFrom(address from, address to, uint256 amount) external returns (bool);
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (token/ERC20/utils/SafeERC20.sol)
pragma solidity ^0.8.0;
import "../IERC20.sol";
import "../extensions/IERC20Permit.sol";
import "../../../utils/Address.sol";
/**
* @title SafeERC20
* @dev Wrappers around ERC20 operations that throw on failure (when the token
* contract returns false). Tokens that return no value (and instead revert or
* throw on failure) are also supported, non-reverting calls are assumed to be
* successful.
* To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract,
* which allows you to call the safe operations as `token.safeTransfer(...)`, etc.
*/
library SafeERC20 {
using Address for address;
/**
* @dev Transfer `value` amount of `token` from the calling contract to `to`. If `token` returns no value,
* non-reverting calls are assumed to be successful.
*/
function safeTransfer(IERC20 token, address to, uint256 value) internal {
_callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value));
}
/**
* @dev Transfer `value` amount of `token` from `from` to `to`, spending the approval given by `from` to the
* calling contract. If `token` returns no value, non-reverting calls are assumed to be successful.
*/
function safeTransferFrom(IERC20 token, address from, address to, uint256 value) internal {
_callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value));
}
/**
* @dev Deprecated. This function has issues similar to the ones found in
* {IERC20-approve}, and its usage is discouraged.
*
* Whenever possible, use {safeIncreaseAllowance} and
* {safeDecreaseAllowance} instead.
*/
function safeApprove(IERC20 token, address spender, uint256 value) internal {
// safeApprove should only be called when setting an initial allowance,
// or when resetting it to zero. To increase and decrease it, use
// 'safeIncreaseAllowance' and 'safeDecreaseAllowance'
require(
(value == 0) || (token.allowance(address(this), spender) == 0),
"SafeERC20: approve from non-zero to non-zero allowance"
);
_callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value));
}
/**
* @dev Increase the calling contract's allowance toward `spender` by `value`. If `token` returns no value,
* non-reverting calls are assumed to be successful.
*/
function safeIncreaseAllowance(IERC20 token, address spender, uint256 value) internal {
uint256 oldAllowance = token.allowance(address(this), spender);
_callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, oldAllowance + value));
}
/**
* @dev Decrease the calling contract's allowance toward `spender` by `value`. If `token` returns no value,
* non-reverting calls are assumed to be successful.
*/
function safeDecreaseAllowance(IERC20 token, address spender, uint256 value) internal {
unchecked {
uint256 oldAllowance = token.allowance(address(this), spender);
require(oldAllowance >= value, "SafeERC20: decreased allowance below zero");
_callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, oldAllowance - value));
}
}
/**
* @dev Set the calling contract's allowance toward `spender` to `value`. If `token` returns no value,
* non-reverting calls are assumed to be successful. Compatible with tokens that require the approval to be set to
* 0 before setting it to a non-zero value.
*/
function forceApprove(IERC20 token, address spender, uint256 value) internal {
bytes memory approvalCall = abi.encodeWithSelector(token.approve.selector, spender, value);
if (!_callOptionalReturnBool(token, approvalCall)) {
_callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, 0));
_callOptionalReturn(token, approvalCall);
}
}
/**
* @dev Use a ERC-2612 signature to set the `owner` approval toward `spender` on `token`.
* Revert on invalid signature.
*/
function safePermit(
IERC20Permit token,
address owner,
address spender,
uint256 value,
uint256 deadline,
uint8 v,
bytes32 r,
bytes32 s
) internal {
uint256 nonceBefore = token.nonces(owner);
token.permit(owner, spender, value, deadline, v, r, s);
uint256 nonceAfter = token.nonces(owner);
require(nonceAfter == nonceBefore + 1, "SafeERC20: permit did not succeed");
}
/**
* @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement
* on the return value: the return value is optional (but if data is returned, it must not be false).
* @param token The token targeted by the call.
* @param data The call data (encoded using abi.encode or one of its variants).
*/
function _callOptionalReturn(IERC20 token, bytes memory data) private {
// We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since
// we're implementing it ourselves. We use {Address-functionCall} to perform this call, which verifies that
// the target address contains contract code and also asserts for success in the low-level call.
bytes memory returndata = address(token).functionCall(data, "SafeERC20: low-level call failed");
require(returndata.length == 0 || abi.decode(returndata, (bool)), "SafeERC20: ERC20 operation did not succeed");
}
/**
* @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement
* on the return value: the return value is optional (but if data is returned, it must not be false).
* @param token The token targeted by the call.
* @param data The call data (encoded using abi.encode or one of its variants).
*
* This is a variant of {_callOptionalReturn} that silents catches all reverts and returns a bool instead.
*/
function _callOptionalReturnBool(IERC20 token, bytes memory data) private returns (bool) {
// We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since
// we're implementing it ourselves. We cannot use {Address-functionCall} here since this should return false
// and not revert is the subcall reverts.
(bool success, bytes memory returndata) = address(token).call(data);
return
success && (returndata.length == 0 || abi.decode(returndata, (bool))) && Address.isContract(address(token));
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (utils/Address.sol)
pragma solidity ^0.8.1;
/**
* @dev Collection of functions related to the address type
*/
library Address {
/**
* @dev Returns true if `account` is a contract.
*
* [IMPORTANT]
* ====
* It is unsafe to assume that an address for which this function returns
* false is an externally-owned account (EOA) and not a contract.
*
* Among others, `isContract` will return false for the following
* types of addresses:
*
* - an externally-owned account
* - a contract in construction
* - an address where a contract will be created
* - an address where a contract lived, but was destroyed
*
* Furthermore, `isContract` will also return true if the target contract within
* the same transaction is already scheduled for destruction by `SELFDESTRUCT`,
* which only has an effect at the end of a transaction.
* ====
*
* [IMPORTANT]
* ====
* You shouldn't rely on `isContract` to protect against flash loan attacks!
*
* Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets
* like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract
* constructor.
* ====
*/
function isContract(address account) internal view returns (bool) {
// This method relies on extcodesize/address.code.length, which returns 0
// for contracts in construction, since the code is only stored at the end
// of the constructor execution.
return account.code.length > 0;
}
/**
* @dev Replacement for Solidity's `transfer`: sends `amount` wei to
* `recipient`, forwarding all available gas and reverting on errors.
*
* https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost
* of certain opcodes, possibly making contracts go over the 2300 gas limit
* imposed by `transfer`, making them unable to receive funds via
* `transfer`. {sendValue} removes this limitation.
*
* https://consensys.net/diligence/blog/2019/09/stop-using-soliditys-transfer-now/[Learn more].
*
* IMPORTANT: because control is transferred to `recipient`, care must be
* taken to not create reentrancy vulnerabilities. Consider using
* {ReentrancyGuard} or the
* https://solidity.readthedocs.io/en/v0.8.0/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].
*/
function sendValue(address payable recipient, uint256 amount) internal {
require(address(this).balance >= amount, "Address: insufficient balance");
(bool success, ) = recipient.call{value: amount}("");
require(success, "Address: unable to send value, recipient may have reverted");
}
/**
* @dev Performs a Solidity function call using a low level `call`. A
* plain `call` is an unsafe replacement for a function call: use this
* function instead.
*
* If `target` reverts with a revert reason, it is bubbled up by this
* function (like regular Solidity function calls).
*
* Returns the raw returned data. To convert to the expected return value,
* use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].
*
* Requirements:
*
* - `target` must be a contract.
* - calling `target` with `data` must not revert.
*
* _Available since v3.1._
*/
function functionCall(address target, bytes memory data) internal returns (bytes memory) {
return functionCallWithValue(target, data, 0, "Address: low-level call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with
* `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCall(
address target,
bytes memory data,
string memory errorMessage
) internal returns (bytes memory) {
return functionCallWithValue(target, data, 0, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but also transferring `value` wei to `target`.
*
* Requirements:
*
* - the calling contract must have an ETH balance of at least `value`.
* - the called Solidity function must be `payable`.
*
* _Available since v3.1._
*/
function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) {
return functionCallWithValue(target, data, value, "Address: low-level call with value failed");
}
/**
* @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but
* with `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCallWithValue(
address target,
bytes memory data,
uint256 value,
string memory errorMessage
) internal returns (bytes memory) {
require(address(this).balance >= value, "Address: insufficient balance for call");
(bool success, bytes memory returndata) = target.call{value: value}(data);
return verifyCallResultFromTarget(target, success, returndata, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but performing a static call.
*
* _Available since v3.3._
*/
function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {
return functionStaticCall(target, data, "Address: low-level static call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
* but performing a static call.
*
* _Available since v3.3._
*/
function functionStaticCall(
address target,
bytes memory data,
string memory errorMessage
) internal view returns (bytes memory) {
(bool success, bytes memory returndata) = target.staticcall(data);
return verifyCallResultFromTarget(target, success, returndata, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but performing a delegate call.
*
* _Available since v3.4._
*/
function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {
return functionDelegateCall(target, data, "Address: low-level delegate call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
* but performing a delegate call.
*
* _Available since v3.4._
*/
function functionDelegateCall(
address target,
bytes memory data,
string memory errorMessage
) internal returns (bytes memory) {
(bool success, bytes memory returndata) = target.delegatecall(data);
return verifyCallResultFromTarget(target, success, returndata, errorMessage);
}
/**
* @dev Tool to verify that a low level call to smart-contract was successful, and revert (either by bubbling
* the revert reason or using the provided one) in case of unsuccessful call or if target was not a contract.
*
* _Available since v4.8._
*/
function verifyCallResultFromTarget(
address target,
bool success,
bytes memory returndata,
string memory errorMessage
) internal view returns (bytes memory) {
if (success) {
if (returndata.length == 0) {
// only check isContract if the call was successful and the return data is empty
// otherwise we already know that it was a contract
require(isContract(target), "Address: call to non-contract");
}
return returndata;
} else {
_revert(returndata, errorMessage);
}
}
/**
* @dev Tool to verify that a low level call was successful, and revert if it wasn't, either by bubbling the
* revert reason or using the provided one.
*
* _Available since v4.3._
*/
function verifyCallResult(
bool success,
bytes memory returndata,
string memory errorMessage
) internal pure returns (bytes memory) {
if (success) {
return returndata;
} else {
_revert(returndata, errorMessage);
}
}
function _revert(bytes memory returndata, string memory errorMessage) private pure {
// Look for revert reason and bubble it up if present
if (returndata.length > 0) {
// The easiest way to bubble the revert reason is using memory via assembly
/// @solidity memory-safe-assembly
assembly {
let returndata_size := mload(returndata)
revert(add(32, returndata), returndata_size)
}
} else {
revert(errorMessage);
}
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/introspection/ERC165.sol)
pragma solidity ^0.8.0;
import "./IERC165.sol";
/**
* @dev Implementation of the {IERC165} interface.
*
* Contracts that want to implement ERC165 should inherit from this contract and override {supportsInterface} to check
* for the additional interface id that will be supported. For example:
*
* ```solidity
* function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
* return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId);
* }
* ```
*
* Alternatively, {ERC165Storage} provides an easier to use but more expensive implementation.
*/
abstract contract ERC165 is IERC165 {
/**
* @dev See {IERC165-supportsInterface}.
*/
function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
return interfaceId == type(IERC165).interfaceId;
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/introspection/IERC165.sol)
pragma solidity ^0.8.0;
/**
* @dev Interface of the ERC165 standard, as defined in the
* https://eips.ethereum.org/EIPS/eip-165[EIP].
*
* Implementers can declare support of contract interfaces, which can then be
* queried by others ({ERC165Checker}).
*
* For an implementation, see {ERC165}.
*/
interface IERC165 {
/**
* @dev Returns true if this contract implements the interface defined by
* `interfaceId`. See the corresponding
* https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section]
* to learn more about how these ids are created.
*
* This function call must use less than 30 000 gas.
*/
function supportsInterface(bytes4 interfaceId) external view returns (bool);
}// SPDX-License-Identifier: MIT pragma solidity ^0.8.4; uint256 constant PRECISION = 10 ** 25; uint256 constant DECIMAL = 10 ** 18; uint256 constant PERCENTAGE_100 = 10 ** 27;
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;
/**
* This is Distribution contract that stores all the pools and users data.
* It is used to calculate the user's rewards and operate with overpluses.
*/
interface IDistribution {
/**
* The structure that stores the core pool's data.
* @param payoutStart The timestamp when the pool starts to pay out rewards.
* @param decreaseInterval The interval in seconds between reward decreases.
* @param withdrawLockPeriod The period in seconds when the user can't withdraw his stake.
* @param withdrawLockPeriodAfterStake The period in seconds when the user can't withdraw his stake after staking.
* @param claimLockPeriod The period in seconds when the user can't claim his rewards.
* @param initialReward The initial reward per interval.
* @param rewardDecrease The reward decrease per interval.
* @param minimalStake The minimal stake amount.
* @param isPublic The flag that indicates if the pool is public.
*/
struct Pool {
uint128 payoutStart;
uint128 decreaseInterval;
uint128 withdrawLockPeriod;
uint128 claimLockPeriod;
uint128 withdrawLockPeriodAfterStake;
uint256 initialReward;
uint256 rewardDecrease;
uint256 minimalStake;
bool isPublic;
}
/**
* The structure that stores the pool's rate data.
* @param lastUpdate The timestamp when the pool was updated.
* @param rate The current reward rate.
* @param totalDeposited The total amount of tokens deposited in the pool.
*/
struct PoolData {
uint128 lastUpdate;
uint256 rate;
uint256 totalDeposited;
}
/**
* The structure that stores the user's rate data of pool.
* @param lastStake The timestamp when the user last staked tokens.
* @param deposited The amount of tokens deposited in the pool.
* @param rate The current reward rate.
* @param pendingRewards The amount of pending rewards.
*/
struct UserData {
uint128 lastStake;
uint256 deposited;
uint256 rate;
uint256 pendingRewards;
}
/**
* The event that is emitted when the pool is created.
* @param poolId The pool's id.
* @param pool The pool's data.
*/
event PoolCreated(uint256 indexed poolId, Pool pool);
/**
* The event that is emitted when the pool is edited.
* @param poolId The pool's id.
* @param pool The pool's data.
*/
event PoolEdited(uint256 indexed poolId, Pool pool);
/**
* The event that is emitted when the user stakes tokens in the pool.
* @param poolId The pool's id.
* @param user The user's address.
* @param amount The amount of tokens.
*/
event UserStaked(uint256 indexed poolId, address indexed user, uint256 amount);
/**
* The event that is emitted when the user claims rewards from the pool.
* @param poolId The pool's id.
* @param user The user's address.
* @param receiver The receiver's address.
* @param amount The amount of tokens.
*/
event UserClaimed(uint256 indexed poolId, address indexed user, address receiver, uint256 amount);
/**
* The event that is emitted when the user withdraws tokens from the pool.
* @param poolId The pool's id.
* @param user The user's address.
* @param amount The amount of tokens.
*/
event UserWithdrawn(uint256 indexed poolId, address indexed user, uint256 amount);
/**
* The event that is emitted when the overplus of the deposit tokens is bridged.
*/
event OverplusBridged(uint256 amount, bytes uniqueId);
/**
* The function to initialize the contract.
* @param depositToken_ The address of deposit token.
* @param l1Sender_ The address of bridge contract.
* @param poolsInfo_ The array of initial pools.
*/
function Distribution_init(address depositToken_, address l1Sender_, Pool[] calldata poolsInfo_) external;
/**
* The function to create a new pool.
* @param pool_ The pool's data.
*/
function createPool(Pool calldata pool_) external;
/**
* The function to edit the pool's data.
* @param poolId The pool's id.
* @param pool_ The new pool's data.
*/
function editPool(uint256 poolId, Pool calldata pool_) external;
/**
* The function to calculate the total pool's reward for the specified period.
* @param poolId_ The pool's id.
* @param startTime_ The start timestamp.
* @param endTime_ The end timestamp.
* @return The total reward amount.
*/
function getPeriodReward(uint256 poolId_, uint128 startTime_, uint128 endTime_) external view returns (uint256);
/**
* The function to manage users and their rate in the private pool.
* @param poolId_ The pool's id.
* @param users_ The array of users.
* @param amounts_ The array of amounts.
*/
function manageUsersInPrivatePool(uint256 poolId_, address[] calldata users_, uint256[] calldata amounts_) external;
/**
* The function to stake tokens in the public pool.
* @param poolId_ The pool's id.
* @param amount_ The amount of tokens to stake.
*/
function stake(uint256 poolId_, uint256 amount_) external;
/**
* The function to claim rewards from the pool.
* @param poolId_ The pool's id.
* @param receiver_ The receiver's address.
*/
function claim(uint256 poolId_, address receiver_) external payable;
/**
* The function to withdraw tokens from the pool.
* @param poolId_ The pool's id.
* @param amount_ The amount of tokens to withdraw.
*/
function withdraw(uint256 poolId_, uint256 amount_) external;
/**
* The function to get the user's reward for the specified pool.
* @param poolId_ The pool's id.
* @param user_ The user's address.
* @return The user's reward amount.
*/
function getCurrentUserReward(uint256 poolId_, address user_) external view returns (uint256);
/**
* The function to calculate the total overplus of the staked deposit tokens.
* @return The total overplus amount.
*/
function overplus() external view returns (uint256);
/**
* The function to bridge the overplus of the staked deposit tokens.
* @param gasLimit_ The gas limit.
* @param maxFeePerGas_ The max fee per gas.
* @param maxSubmissionCost_ The max submission cost.
* @return The unique identifier for withdrawal.
*/
function bridgeOverplus(
uint256 gasLimit_,
uint256 maxFeePerGas_,
uint256 maxSubmissionCost_
) external payable returns (bytes memory);
/**
* The function to remove upgradeability.
*/
function removeUpgradeability() external;
/**
* The function to check if the contract is upgradeable.
* @return The flag that indicates if the contract is upgradeable.
*/
function isNotUpgradeable() external view returns (bool);
/**
* The function to get the address of deposit token.
* @return The address of deposit token.
*/
function depositToken() external view returns (address);
/**
* The function to get the address of bridge contract.
* @return The address of bridge contract.
*/
function l1Sender() external view returns (address);
/**
* The function to get the amount of deposit tokens that are staked in all of the public pools.
* @dev The value accumulates the amount amount despite the rate differences.
* @return The amount of deposit tokens.
*/
function totalDepositedInPublicPools() external view returns (uint256);
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;
import {IERC165} from "@openzeppelin/contracts/utils/introspection/ERC165.sol";
interface IL1Sender is IERC165 {
/**
* The structure that stores the deposit token's data.
* @param token The address of wrapped deposit token.
* @param gateway The address of token's gateway.
* @param receiver The address of wrapped token's receiver on L2.
*/
struct DepositTokenConfig {
address token;
address gateway;
address receiver;
}
/**
* The structure that stores the reward token's data.
* @param gateway The address of token's gateway.
* @param receiver The address of token's receiver on L2.
* @param receiverChainId The chain id of receiver.
* @param zroPaymentAddress The address of ZKSync payment contract.
* @param adapterParams The parameters for the adapter.
*/
struct RewardTokenConfig {
address gateway;
address receiver;
uint16 receiverChainId;
address zroPaymentAddress;
bytes adapterParams;
}
/**
* The function to get the deposit token's address.
*/
function unwrappedDepositToken() external view returns (address);
/**
* The function to set the reward token's config.
* @param newConfig_ The new reward token's config.
*/
function setRewardTokenConfig(RewardTokenConfig calldata newConfig_) external;
/**
* The function to set the deposit token's config.
* @param newConfig_ The new deposit token's config.
*/
function setDepositTokenConfig(DepositTokenConfig calldata newConfig_) external;
/**
* The function to send all current balance of the deposit token to the L2.
* @param gasLimit_ The gas limit for the L2 transaction.
* @param maxFeePerGas_ The max fee per gas for the L2 transaction.
* @param maxSubmissionCost_ The max submission cost for the L2 transaction.
* @return The unique identifier for withdrawal.
*/
function sendDepositToken(
uint256 gasLimit_,
uint256 maxFeePerGas_,
uint256 maxSubmissionCost_
) external payable returns (bytes memory);
/**
* The function to send the message of mint of reward token to the L2.
* @param user_ The user's address to mint reward tokens.
* @param amount_ The amount of reward tokens to mint.
* @param refundTo_ The address to refund the overpaid gas.
*/
function sendMintMessage(address user_, uint256 amount_, address refundTo_) external payable;
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;
import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol";
interface IWStETH is IERC20 {
function stETH() external returns (address);
function wrap(uint256 _stETHAmount) external returns (uint256);
function unwrap(uint256 _wstETHAmount) external returns (uint256);
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;
import {ILayerZeroEndpoint} from "@layerzerolabs/lz-evm-sdk-v1-0.7/contracts/interfaces/ILayerZeroEndpoint.sol";
import {IGatewayRouter} from "@arbitrum/token-bridge-contracts/contracts/tokenbridge/libraries/gateway/IGatewayRouter.sol";
import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import {UUPSUpgradeable} from "@openzeppelin/contracts-upgradeable/proxy/utils/UUPSUpgradeable.sol";
import {OwnableUpgradeable} from "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol";
import {IL1Sender, IERC165} from "./interfaces/IL1Sender.sol";
import {IWStETH} from "./interfaces/tokens/IWStETH.sol";
contract L1Sender is IL1Sender, OwnableUpgradeable, UUPSUpgradeable {
address public unwrappedDepositToken;
address public distribution;
DepositTokenConfig public depositTokenConfig;
RewardTokenConfig public rewardTokenConfig;
modifier onlyDistribution() {
require(_msgSender() == distribution, "L1S: invalid sender");
_;
}
constructor() {
_disableInitializers();
}
function L1Sender__init(
address distribution_,
RewardTokenConfig calldata rewardTokenConfig_,
DepositTokenConfig calldata depositTokenConfig_
) external initializer {
__Ownable_init();
__UUPSUpgradeable_init();
setDistribution(distribution_);
setRewardTokenConfig(rewardTokenConfig_);
setDepositTokenConfig(depositTokenConfig_);
}
function supportsInterface(bytes4 interfaceId_) external pure returns (bool) {
return interfaceId_ == type(IL1Sender).interfaceId || interfaceId_ == type(IERC165).interfaceId;
}
function setDistribution(address distribution_) public onlyOwner {
distribution = distribution_;
}
function setRewardTokenConfig(RewardTokenConfig calldata newConfig_) public onlyOwner {
rewardTokenConfig = newConfig_;
}
function setDepositTokenConfig(DepositTokenConfig calldata newConfig_) public onlyOwner {
require(newConfig_.receiver != address(0), "L1S: invalid receiver");
DepositTokenConfig storage oldConfig = depositTokenConfig;
_replaceDepositToken(oldConfig.token, newConfig_.token);
_replaceDepositTokenGateway(oldConfig.gateway, newConfig_.gateway, oldConfig.token, newConfig_.token);
depositTokenConfig = newConfig_;
}
function _replaceDepositToken(address oldToken_, address newToken_) private {
bool isTokenChanged_ = oldToken_ != newToken_;
if (oldToken_ != address(0) && isTokenChanged_) {
// Remove allowance from stETH to wstETH
IERC20(unwrappedDepositToken).approve(oldToken_, 0);
}
if (isTokenChanged_) {
// Get stETH from wstETH
address unwrappedToken_ = IWStETH(newToken_).stETH();
// Increase allowance from stETH to wstETH. To exchange stETH for wstETH
IERC20(unwrappedToken_).approve(newToken_, type(uint256).max);
unwrappedDepositToken = unwrappedToken_;
}
}
function _replaceDepositTokenGateway(
address oldGateway_,
address newGateway_,
address oldToken_,
address newToken_
) private {
bool isAllowedChanged_ = (oldToken_ != newToken_) || (oldGateway_ != newGateway_);
if (oldGateway_ != address(0) && isAllowedChanged_) {
IERC20(oldToken_).approve(IGatewayRouter(oldGateway_).getGateway(oldToken_), 0);
}
if (isAllowedChanged_) {
IERC20(newToken_).approve(IGatewayRouter(newGateway_).getGateway(newToken_), type(uint256).max);
}
}
function sendDepositToken(
uint256 gasLimit_,
uint256 maxFeePerGas_,
uint256 maxSubmissionCost_
) external payable onlyDistribution returns (bytes memory) {
DepositTokenConfig storage config = depositTokenConfig;
// Get current stETH balance
uint256 amountUnwrappedToken_ = IERC20(unwrappedDepositToken).balanceOf(address(this));
// Wrap all stETH to wstETH
uint256 amount_ = IWStETH(config.token).wrap(amountUnwrappedToken_);
bytes memory data_ = abi.encode(maxSubmissionCost_, "");
return
IGatewayRouter(config.gateway).outboundTransfer{value: msg.value}(
config.token,
config.receiver,
amount_,
gasLimit_,
maxFeePerGas_,
data_
);
}
function sendMintMessage(address user_, uint256 amount_, address refundTo_) external payable onlyDistribution {
RewardTokenConfig storage config = rewardTokenConfig;
bytes memory receiverAndSenderAddresses_ = abi.encodePacked(config.receiver, address(this));
bytes memory payload_ = abi.encode(user_, amount_);
ILayerZeroEndpoint(config.gateway).send{value: msg.value}(
config.receiverChainId, // communicator LayerZero chainId
receiverAndSenderAddresses_, // send to this address to the communicator
payload_, // bytes payload
payable(refundTo_), // refund address
config.zroPaymentAddress, // future parameter
config.adapterParams // adapterParams (see "Advanced Features")
);
}
function _authorizeUpgrade(address) internal view override onlyOwner {}
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;
/**
* This is the library that calculates the reward for the period with linear distribution and interval decrease.
* Supports the constant reward amount (decreaseAmount_ = 0)
*/
library LinearDistributionIntervalDecrease {
/**
* The function to calculate the reward for the period.
* @param initialAmount_ The initial reward amount.
* @param decreaseAmount_ The reward decrease amount.
* @param payoutStart_ The timestamp when the period starts to pay out rewards.
* @param interval_ The interval in seconds between reward decreases.
* @param startTime_ The timestamp when the period starts.
* @param endTime_ The timestamp when the period ends.
* @return The reward amount.
*/
function getPeriodReward(
uint256 initialAmount_,
uint256 decreaseAmount_,
uint128 payoutStart_,
uint128 interval_,
uint128 startTime_,
uint128 endTime_
) external pure returns (uint256) {
if (interval_ == 0) {
return 0;
}
// 'startTime_' can't be less than 'payoutStart_'
if (startTime_ < payoutStart_) {
startTime_ = payoutStart_;
}
uint128 maxEndTime_ = _calculateMaxEndTime(payoutStart_, interval_, initialAmount_, decreaseAmount_);
if (endTime_ > maxEndTime_) {
endTime_ = maxEndTime_;
}
// Return 0 when calculation 'startTime_' is bigger then 'endTime_'...
if (startTime_ >= endTime_) {
return 0;
}
// Calculate interval that less then 'interval_' range
uint256 timePassedBefore_ = startTime_ - payoutStart_;
if ((timePassedBefore_ / interval_) == ((endTime_ - payoutStart_) / interval_)) {
uint256 intervalsPassed_ = timePassedBefore_ / interval_;
uint256 intervalFullReward_ = initialAmount_ - intervalsPassed_ * decreaseAmount_;
return (intervalFullReward_ * (endTime_ - startTime_)) / interval_;
}
// Calculate interval that more then 'interval_' range
uint256 firstPeriodReward_ = _calculatePartPeriodReward(
payoutStart_,
startTime_,
interval_,
initialAmount_,
decreaseAmount_,
true
);
uint256 secondPeriodReward_ = _calculateFullPeriodReward(
payoutStart_,
startTime_,
endTime_,
interval_,
initialAmount_,
decreaseAmount_
);
uint256 thirdPeriodReward_ = _calculatePartPeriodReward(
payoutStart_,
endTime_,
interval_,
initialAmount_,
decreaseAmount_,
false
);
return firstPeriodReward_ + secondPeriodReward_ + thirdPeriodReward_;
}
function _calculateMaxEndTime(
uint128 payoutStart_,
uint128 interval_,
uint256 initialAmount_,
uint256 decreaseAmount_
) private pure returns (uint128) {
if (decreaseAmount_ == 0) {
return type(uint128).max;
}
uint256 maxIntervals_ = _divideCeil(initialAmount_, decreaseAmount_);
return uint128(payoutStart_ + maxIntervals_ * interval_);
}
function _calculatePartPeriodReward(
uint128 payoutStart_,
uint128 startTime_,
uint128 interval_,
uint256 initialAmount_,
uint256 decreaseAmount_,
bool toEnd_
) private pure returns (uint256) {
uint256 intervalsPassed_ = (startTime_ - payoutStart_) / interval_;
uint256 decreaseRewardAmount_ = intervalsPassed_ * decreaseAmount_;
if (decreaseRewardAmount_ >= initialAmount_) {
return 0;
}
uint256 intervalFullReward_ = initialAmount_ - decreaseRewardAmount_;
uint256 intervalPart_;
if (toEnd_) {
intervalPart_ = interval_ * (intervalsPassed_ + 1) + payoutStart_ - startTime_;
} else {
intervalPart_ = startTime_ - interval_ * intervalsPassed_ - payoutStart_;
}
if (intervalPart_ == interval_) {
return 0;
}
return (intervalFullReward_ * intervalPart_) / interval_;
}
function _calculateFullPeriodReward(
uint128 payoutStart_,
uint128 startTime_,
uint128 endTime_,
uint128 interval_,
uint256 initialAmount_,
uint256 decreaseAmount_
) private pure returns (uint256) {
// START calculate initial reward when period start
uint256 timePassedBefore_ = startTime_ - payoutStart_;
uint256 intervalsPassedBefore_ = _divideCeil(timePassedBefore_, interval_);
uint256 decreaseRewardAmount_ = intervalsPassedBefore_ * decreaseAmount_;
if (decreaseRewardAmount_ >= initialAmount_) {
return 0;
}
uint256 initialReward_ = initialAmount_ - decreaseRewardAmount_;
// END
// Intervals passed
uint256 ip_ = ((endTime_ - payoutStart_ - intervalsPassedBefore_ * interval_) / interval_);
if (ip_ == 0) {
return 0;
}
return initialReward_ * ip_ - (decreaseAmount_ * (ip_ * (ip_ - 1))) / 2;
}
function _divideCeil(uint256 a_, uint256 b_) private pure returns (uint256) {
return (a_ + b_ - 1) / b_;
}
}{
"optimizer": {
"enabled": true,
"runs": 200
},
"evmVersion": "paris",
"outputSelection": {
"*": {
"*": [
"evm.bytecode",
"evm.deployedBytecode",
"devdoc",
"userdoc",
"metadata",
"abi"
]
}
},
"libraries": {
"contracts/libs/LinearDistributionIntervalDecrease.sol": {
"LinearDistributionIntervalDecrease": "0x7431ada8a591c955a994a21710752ef9b882b8e3"
}
}
}Contract Security Audit
- No Contract Security Audit Submitted- Submit Audit Here
Contract ABI
API[{"inputs":[],"stateMutability":"nonpayable","type":"constructor"},{"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":false,"internalType":"uint8","name":"version","type":"uint8"}],"name":"Initialized","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"},{"indexed":false,"internalType":"bytes","name":"uniqueId","type":"bytes"}],"name":"OverplusBridged","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"previousOwner","type":"address"},{"indexed":true,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnershipTransferred","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"poolId","type":"uint256"},{"components":[{"internalType":"uint128","name":"payoutStart","type":"uint128"},{"internalType":"uint128","name":"decreaseInterval","type":"uint128"},{"internalType":"uint128","name":"withdrawLockPeriod","type":"uint128"},{"internalType":"uint128","name":"claimLockPeriod","type":"uint128"},{"internalType":"uint128","name":"withdrawLockPeriodAfterStake","type":"uint128"},{"internalType":"uint256","name":"initialReward","type":"uint256"},{"internalType":"uint256","name":"rewardDecrease","type":"uint256"},{"internalType":"uint256","name":"minimalStake","type":"uint256"},{"internalType":"bool","name":"isPublic","type":"bool"}],"indexed":false,"internalType":"struct IDistribution.Pool","name":"pool","type":"tuple"}],"name":"PoolCreated","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"poolId","type":"uint256"},{"components":[{"internalType":"uint128","name":"payoutStart","type":"uint128"},{"internalType":"uint128","name":"decreaseInterval","type":"uint128"},{"internalType":"uint128","name":"withdrawLockPeriod","type":"uint128"},{"internalType":"uint128","name":"claimLockPeriod","type":"uint128"},{"internalType":"uint128","name":"withdrawLockPeriodAfterStake","type":"uint128"},{"internalType":"uint256","name":"initialReward","type":"uint256"},{"internalType":"uint256","name":"rewardDecrease","type":"uint256"},{"internalType":"uint256","name":"minimalStake","type":"uint256"},{"internalType":"bool","name":"isPublic","type":"bool"}],"indexed":false,"internalType":"struct IDistribution.Pool","name":"pool","type":"tuple"}],"name":"PoolEdited","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"implementation","type":"address"}],"name":"Upgraded","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"poolId","type":"uint256"},{"indexed":true,"internalType":"address","name":"user","type":"address"},{"indexed":false,"internalType":"address","name":"receiver","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"UserClaimed","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"poolId","type":"uint256"},{"indexed":true,"internalType":"address","name":"user","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"UserStaked","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"poolId","type":"uint256"},{"indexed":true,"internalType":"address","name":"user","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"UserWithdrawn","type":"event"},{"inputs":[{"internalType":"address","name":"depositToken_","type":"address"},{"internalType":"address","name":"l1Sender_","type":"address"},{"components":[{"internalType":"uint128","name":"payoutStart","type":"uint128"},{"internalType":"uint128","name":"decreaseInterval","type":"uint128"},{"internalType":"uint128","name":"withdrawLockPeriod","type":"uint128"},{"internalType":"uint128","name":"claimLockPeriod","type":"uint128"},{"internalType":"uint128","name":"withdrawLockPeriodAfterStake","type":"uint128"},{"internalType":"uint256","name":"initialReward","type":"uint256"},{"internalType":"uint256","name":"rewardDecrease","type":"uint256"},{"internalType":"uint256","name":"minimalStake","type":"uint256"},{"internalType":"bool","name":"isPublic","type":"bool"}],"internalType":"struct IDistribution.Pool[]","name":"poolsInfo_","type":"tuple[]"}],"name":"Distribution_init","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"gasLimit_","type":"uint256"},{"internalType":"uint256","name":"maxFeePerGas_","type":"uint256"},{"internalType":"uint256","name":"maxSubmissionCost_","type":"uint256"}],"name":"bridgeOverplus","outputs":[{"internalType":"bytes","name":"","type":"bytes"}],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"uint256","name":"poolId_","type":"uint256"},{"internalType":"address","name":"receiver_","type":"address"}],"name":"claim","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"components":[{"internalType":"uint128","name":"payoutStart","type":"uint128"},{"internalType":"uint128","name":"decreaseInterval","type":"uint128"},{"internalType":"uint128","name":"withdrawLockPeriod","type":"uint128"},{"internalType":"uint128","name":"claimLockPeriod","type":"uint128"},{"internalType":"uint128","name":"withdrawLockPeriodAfterStake","type":"uint128"},{"internalType":"uint256","name":"initialReward","type":"uint256"},{"internalType":"uint256","name":"rewardDecrease","type":"uint256"},{"internalType":"uint256","name":"minimalStake","type":"uint256"},{"internalType":"bool","name":"isPublic","type":"bool"}],"internalType":"struct IDistribution.Pool","name":"pool_","type":"tuple"}],"name":"createPool","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"depositToken","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"poolId_","type":"uint256"},{"components":[{"internalType":"uint128","name":"payoutStart","type":"uint128"},{"internalType":"uint128","name":"decreaseInterval","type":"uint128"},{"internalType":"uint128","name":"withdrawLockPeriod","type":"uint128"},{"internalType":"uint128","name":"claimLockPeriod","type":"uint128"},{"internalType":"uint128","name":"withdrawLockPeriodAfterStake","type":"uint128"},{"internalType":"uint256","name":"initialReward","type":"uint256"},{"internalType":"uint256","name":"rewardDecrease","type":"uint256"},{"internalType":"uint256","name":"minimalStake","type":"uint256"},{"internalType":"bool","name":"isPublic","type":"bool"}],"internalType":"struct IDistribution.Pool","name":"pool_","type":"tuple"}],"name":"editPool","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"poolId_","type":"uint256"},{"internalType":"address","name":"user_","type":"address"}],"name":"getCurrentUserReward","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"poolId_","type":"uint256"},{"internalType":"uint128","name":"startTime_","type":"uint128"},{"internalType":"uint128","name":"endTime_","type":"uint128"}],"name":"getPeriodReward","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"isNotUpgradeable","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"l1Sender","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"poolId_","type":"uint256"},{"internalType":"address[]","name":"users_","type":"address[]"},{"internalType":"uint256[]","name":"amounts_","type":"uint256[]"}],"name":"manageUsersInPrivatePool","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"overplus","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"pools","outputs":[{"internalType":"uint128","name":"payoutStart","type":"uint128"},{"internalType":"uint128","name":"decreaseInterval","type":"uint128"},{"internalType":"uint128","name":"withdrawLockPeriod","type":"uint128"},{"internalType":"uint128","name":"claimLockPeriod","type":"uint128"},{"internalType":"uint128","name":"withdrawLockPeriodAfterStake","type":"uint128"},{"internalType":"uint256","name":"initialReward","type":"uint256"},{"internalType":"uint256","name":"rewardDecrease","type":"uint256"},{"internalType":"uint256","name":"minimalStake","type":"uint256"},{"internalType":"bool","name":"isPublic","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"poolsData","outputs":[{"internalType":"uint128","name":"lastUpdate","type":"uint128"},{"internalType":"uint256","name":"rate","type":"uint256"},{"internalType":"uint256","name":"totalDeposited","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"proxiableUUID","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"removeUpgradeability","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"poolId_","type":"uint256"},{"internalType":"uint256","name":"amount_","type":"uint256"}],"name":"stake","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"totalDepositedInPublicPools","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"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"},{"inputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"uint256","name":"","type":"uint256"}],"name":"usersData","outputs":[{"internalType":"uint128","name":"lastStake","type":"uint128"},{"internalType":"uint256","name":"deposited","type":"uint256"},{"internalType":"uint256","name":"rate","type":"uint256"},{"internalType":"uint256","name":"pendingRewards","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"poolId_","type":"uint256"},{"internalType":"uint256","name":"amount_","type":"uint256"}],"name":"withdraw","outputs":[],"stateMutability":"nonpayable","type":"function"}]Contract Creation Code
60a0604052306080523480156200001557600080fd5b506200002062000026565b620000e7565b600054610100900460ff1615620000935760405162461bcd60e51b815260206004820152602760248201527f496e697469616c697a61626c653a20636f6e747261637420697320696e697469604482015266616c697a696e6760c81b606482015260840160405180910390fd5b60005460ff90811614620000e5576000805460ff191660ff9081179091556040519081527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb38474024989060200160405180910390a15b565b608051612fbf6200011f600039600081816107200152818161076001528181610bd401528181610c140152610ca70152612fbf6000f3fe6080604052600436106101665760003560e01c80637b0472f0116100d1578063c89039c51161008a578063ddd5e1b211610064578063ddd5e1b2146104b0578063e0b4b386146104c3578063f2fde38b146104ed578063f343e8581461050d57600080fd5b8063c89039c514610455578063d2ba5e3a1461047a578063d63bb92c1461049057600080fd5b80637b0472f0146103335780638468a4c4146103535780638da5cb5b14610373578063ac4afa38146103a5578063b7558b7a14610420578063beee9fa91461044057600080fd5b80634f1ef286116101235780634f1ef2861461029357806352d1902d146102a6578063535f583f146102c95780635bd2e387146102e9578063715018a61461030957806378df87b21461031e57600080fd5b80632a1f34f41461016b57806330dc63081461018d5780633659cfe6146102135780633a4f1431146102335780633fde343514610253578063441a3e7014610273575b600080fd5b34801561017757600080fd5b5061018b61018636600461261e565b610578565b005b34801561019957600080fd5b506101e46101a83660046126b0565b60cd60209081526000928352604080842090915290825290208054600182015460028301546003909301546001600160801b0390921692909184565b604080516001600160801b03909516855260208501939093529183015260608201526080015b60405180910390f35b34801561021f57600080fd5b5061018b61022e3660046126da565b610716565b6102466102413660046126f5565b6107f5565b60405161020a9190612771565b34801561025f57600080fd5b5061018b61026e3660046127d0565b61093e565b34801561027f57600080fd5b5061018b61028e36600461284a565b610b19565b61018b6102a13660046128db565b610bca565b3480156102b257600080fd5b506102bb610c9a565b60405190815260200161020a565b3480156102d557600080fd5b506102bb6102e436600461298c565b610d4d565b3480156102f557600080fd5b5061018b6103043660046129e7565b610e4c565b34801561031557600080fd5b5061018b610f4d565b34801561032a57600080fd5b506102bb610f61565b34801561033f57600080fd5b5061018b61034e36600461284a565b610ffc565b34801561035f57600080fd5b506102bb61036e366004612a04565b6110a7565b34801561037f57600080fd5b506033546001600160a01b03165b6040516001600160a01b03909116815260200161020a565b3480156103b157600080fd5b506103c56103c0366004612a30565b61113d565b604080516001600160801b039a8b168152988a1660208a015296891696880196909652938716606087015295909116608085015260a084015260c083019390935260e08201929092529015156101008201526101200161020a565b34801561042c57600080fd5b5060ca5461038d906001600160a01b031681565b34801561044c57600080fd5b5061018b6111ab565b34801561046157600080fd5b5060c95461038d9061010090046001600160a01b031681565b34801561048657600080fd5b506102bb60ce5481565b34801561049c57600080fd5b5061018b6104ab366004612a49565b6111c2565b61018b6104be366004612a04565b61132d565b3480156104cf57600080fd5b5060c9546104dd9060ff1681565b604051901515815260200161020a565b3480156104f957600080fd5b5061018b6105083660046126da565b6115b6565b34801561051957600080fd5b50610553610528366004612a30565b60cc602052600090815260409020805460018201546002909201546001600160801b03909116919083565b604080516001600160801b03909416845260208401929092529082015260600161020a565b600054610100900460ff16158080156105985750600054600160ff909116105b806105b25750303b1580156105b2575060005460ff166001145b61061a5760405162461bcd60e51b815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201526d191e481a5b9a5d1a585b1a5e995960921b60648201526084015b60405180910390fd5b6000805460ff19166001179055801561063d576000805461ff0019166101001790555b61064561162c565b61064d61165b565b60005b828110156106895761067984848381811061066d5761066d612a6e565b90506101200201610e4c565b61068281612a9a565b9050610650565b5060c98054610100600160a81b0319166101006001600160a01b03888116919091029190911790915560ca80546001600160a01b031916918616919091179055801561070f576000805461ff0019169055604051600181527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb38474024989060200160405180910390a15b5050505050565b6001600160a01b037f000000000000000000000000000000000000000000000000000000000000000016300361075e5760405162461bcd60e51b815260040161061190612ab3565b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03166107a7600080516020612f43833981519152546001600160a01b031690565b6001600160a01b0316146107cd5760405162461bcd60e51b815260040161061190612aff565b6107d681611682565b604080516000808252602082019092526107f2918391906116dd565b50565b60606107ff61184d565b6000610809610f61565b9050600081116108525760405162461bcd60e51b815260206004820152601460248201527344533a206f766572706c7573206973207a65726f60601b6044820152606401610611565b60ca5460c954610874916001600160a01b0361010090920482169116836118a7565b60ca5460405163fa69dce560e01b81526004810187905260248101869052604481018590526000916001600160a01b03169063fa69dce590349060640160006040518083038185885af11580156108cf573d6000803e3d6000fd5b50505050506040513d6000823e601f3d908101601f191682016040526108f89190810190612b4b565b90507fba6b0fa6fe85fc22ff5fb621db882cf2810a52956ae27fc4609bddc39b6ab7cf828260405161092b929190612bb9565b60405180910390a19150505b9392505050565b61094661184d565b846109528160cb541190565b61096e5760405162461bcd60e51b815260040161061190612bd2565b60cb868154811061098157610981612a6e565b600091825260209091206006600790920201015460ff16156109da5760405162461bcd60e51b815260206004820152601260248201527144533a20706f6f6c206973207075626c696360701b6044820152606401610611565b838214610a1e5760405162461bcd60e51b8152602060048201526012602482015271088a67440d2dcecc2d8d2c840d8cadccee8d60731b6044820152606401610611565b6000610a298761190a565b905060005b85811015610b0f576000878783818110610a4a57610a4a612a6e565b9050602002016020810190610a5f91906126da565b90506000868684818110610a7557610a75612a6e565b905060200201359050600060cd6000846001600160a01b03166001600160a01b0316815260200190815260200160002060008c815260200190815260200160002060010154905081811015610ade57610ad9838c610ad38486612c02565b88611985565b610afb565b81811115610afb57610afb838c610af58585612c02565b88611cb7565b50505080610b0890612a9a565b9050610a2e565b5050505050505050565b81610b258160cb541190565b610b415760405162461bcd60e51b815260040161061190612bd2565b8260cb8181548110610b5557610b55612a6e565b600091825260209091206006600790920201015460ff16610bb05760405162461bcd60e51b815260206004820152601560248201527444533a20706f6f6c2069736e2774207075626c696360581b6044820152606401610611565b610bc4338585610bbf8861190a565b611cb7565b50505050565b6001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000163003610c125760405162461bcd60e51b815260040161061190612ab3565b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316610c5b600080516020612f43833981519152546001600160a01b031690565b6001600160a01b031614610c815760405162461bcd60e51b815260040161061190612aff565b610c8a82611682565b610c96828260016116dd565b5050565b6000306001600160a01b037f00000000000000000000000000000000000000000000000000000000000000001614610d3a5760405162461bcd60e51b815260206004820152603860248201527f555550535570677261646561626c653a206d757374206e6f742062652063616c60448201527f6c6564207468726f7567682064656c656761746563616c6c00000000000000006064820152608401610611565b50600080516020612f4383398151915290565b6000610d5a8460cb541190565b610d6657506000610937565b600060cb8581548110610d7b57610d7b612a6e565b6000918252602090912060079091020160038101546004808301548354604051638ef1035b60e01b81529283019390935260248201526001600160801b038083166044830152600160801b90920482166064820152868216608482015290851660a4820152909150737431ada8a591c955a994a21710752ef9b882b8e390638ef1035b9060c401602060405180830381865af4158015610e1f573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610e439190612c15565b95945050505050565b610e5461184d565b42610e626020830183612c2e565b6001600160801b031611610eb85760405162461bcd60e51b815260206004820152601e60248201527f44533a20696e76616c6964207061796f75742073746172742076616c756500006044820152606401610611565b610ec18161209b565b60cb805460018101825560009190915281906007027fa7ce836d032b2bf62b7e2097a8e0a6d8aeb35405ad15271e96d3b0188a1d06fb01610f028282612c73565b505060cb54610f1390600190612c02565b7f9b9b09f76d4db7c7b0d783b9ba64d003e95462ef13cbb7cb782d74b085548cac82604051610f429190612d70565b60405180910390a250565b610f5561184d565b610f5f6000612103565b565b60c9546040516370a0823160e01b815230600482015260009182916101009091046001600160a01b0316906370a0823190602401602060405180830381865afa158015610fb2573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610fd69190612c15565b905060ce548111610fe957600091505090565b60ce54610ff69082612c02565b91505090565b816110088160cb541190565b6110245760405162461bcd60e51b815260040161061190612bd2565b8260cb818154811061103857611038612a6e565b600091825260209091206006600790920201015460ff166110935760405162461bcd60e51b815260206004820152601560248201527444533a20706f6f6c2069736e2774207075626c696360581b6044820152606401610611565b610bc43385856110a28861190a565b611985565b60006110b48360cb541190565b6110c057506000611137565b6001600160a01b038216600090815260cd602090815260408083208684529091528120906110ed8561190a565b6040805160808101825284546001600160801b031681526001850154602082015260028501549181019190915260038401546060820152909150611132908290612155565b925050505b92915050565b60cb818154811061114d57600080fd5b600091825260209091206007909102018054600182015460028301546003840154600485015460058601546006909601546001600160801b038087169850600160801b96879004811697868216979096048116959416939060ff1689565b6111b361184d565b60c9805460ff19166001179055565b6111ca61184d565b816111d68160cb541190565b6111f25760405162461bcd60e51b815260040161061190612bd2565b6111fb8261209b565b61120d61012083016101008401612e2e565b151560cb848154811061122257611222612a6e565b600091825260209091206006600790920201015460ff161515146112805760405162461bcd60e51b815260206004820152601560248201527444533a20696e76616c696420706f6f6c207479706560581b6044820152606401610611565b600083815260cc60205260408120906112988561190a565b6001830181905582546001600160801b031916426001600160801b031617835560cb80549192508591879081106112d1576112d1612a6e565b906000526020600020906007020181816112eb9190612c73565b905050847f3a267bddb165bbfddc7b47b4a65707d7b637e98f445a07ba27ba471b9e0bea548560405161131e9190612d70565b60405180910390a25050505050565b816113398160cb541190565b6113555760405162461bcd60e51b815260040161061190612bd2565b6000339050600060cb858154811061136f5761136f612a6e565b6000918252602080832088845260cc825260408085206001600160a01b038816865260cd84528186208b8752909352909320600792909202909201600181015481549194506113d291600160801b9091046001600160801b039081169116612e4b565b6001600160801b031642116114295760405162461bcd60e51b815260206004820152601860248201527f44533a20706f6f6c20636c61696d206973206c6f636b656400000000000000006044820152606401610611565b60006114348861190a565b6040805160808101825284546001600160801b03168152600185015460208201526002850154918101919091526003840154606082015290915060009061147c908390612155565b9050600081116114c55760405162461bcd60e51b815260206004820152601460248201527344533a206e6f7468696e6720746f20636c61696d60601b6044820152606401610611565b83546001600160801b031916426001600160801b031617845560018401829055600283018290556000600384015560ca5460405163204209a560e11b81526001600160a01b038a8116600483015260248201849052888116604483015290911690634084134a9034906064016000604051808303818588803b15801561154a57600080fd5b505af115801561155e573d6000803e3d6000fd5b5050604080516001600160a01b038d81168252602082018790528b1694508d93507face6f3f8956413e2875b9070e2616d13687dfb251cf63b343028c32822dfa26392500160405180910390a3505050505050505050565b6115be61184d565b6001600160a01b0381166116235760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b6064820152608401610611565b6107f281612103565b600054610100900460ff166116535760405162461bcd60e51b815260040161061190612e72565b610f5f61219f565b600054610100900460ff16610f5f5760405162461bcd60e51b815260040161061190612e72565b61168a61184d565b60c95460ff16156107f25760405162461bcd60e51b815260206004820152601b60248201527f44533a20757067726164652069736e277420617661696c61626c6500000000006044820152606401610611565b7f4910fdfa16fed3260ed0e7147f7cc6da11a60208b5b9406d12a635614ffd91435460ff161561171557611710836121cf565b505050565b826001600160a01b03166352d1902d6040518163ffffffff1660e01b8152600401602060405180830381865afa92505050801561176f575060408051601f3d908101601f1916820190925261176c91810190612c15565b60015b6117d25760405162461bcd60e51b815260206004820152602e60248201527f45524331393637557067726164653a206e657720696d706c656d656e7461746960448201526d6f6e206973206e6f74205555505360901b6064820152608401610611565b600080516020612f4383398151915281146118415760405162461bcd60e51b815260206004820152602960248201527f45524331393637557067726164653a20756e737570706f727465642070726f786044820152681a58589b195555525160ba1b6064820152608401610611565b5061171083838361226b565b6033546001600160a01b03163314610f5f5760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152606401610611565b6040516001600160a01b03831660248201526044810182905261171090849063a9059cbb60e01b906064015b60408051601f198184030181529190526020810180516001600160e01b03166001600160e01b031990931692909217909152612290565b600081815260cc602052604081206002810154820361192d576001015492915050565b80546000906119479085906001600160801b031642610d4d565b60028301549091506119646a084595161401484a00000083612ebd565b61196e9190612ed4565b826001015461197d9190612ef6565b949350505050565b600082116119cc5760405162461bcd60e51b815260206004820152601460248201527344533a206e6f7468696e6720746f207374616b6560601b6044820152606401610611565b600060cb84815481106119e1576119e1612a6e565b6000918252602080832087845260cc825260408085206001600160a01b038b16865260cd84528186208a8752909352909320600792909202909201600681015490935060ff1615611baf5760c9546040516370a0823160e01b815230600482015260009161010090046001600160a01b0316906370a0823190602401602060405180830381865afa158015611a7a573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611a9e9190612c15565b9050611abd3360c95461010090046001600160a01b0316903089612365565b60c9546040516370a0823160e01b815230600482015260009161010090046001600160a01b0316906370a0823190602401602060405180830381865afa158015611b0b573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611b2f9190612c15565b9050611b3b8282612c02565b96508460050154878460010154611b529190612ef6565b1015611b955760405162461bcd60e51b815260206004820152601260248201527144533a20616d6f756e7420746f6f206c6f7760701b6044820152606401610611565b8660ce6000828254611ba79190612ef6565b909155505050505b6040805160808101825282546001600160801b031681526001830154602082015260028301549181019190915260038201546060820152611bf1908590612155565b600382015581546001600160801b031916426001600160801b031617825560018201849055600282018054869190600090611c2d908490612ef6565b909155505080546001600160801b031916426001600160801b031617815560028101849055600181018054869190600090611c69908490612ef6565b90915550506040518581526001600160a01b0388169087907fe2f02dc2168917563b46b1f788ea74861c381103710158efe9976c0bb33336779060200160405180910390a350505050505050565b600060cb8481548110611ccc57611ccc612a6e565b6000918252602080832087845260cc825260408085206001600160a01b038b16865260cd84528186208a8752909352909320600181015460079093029093019350919080611d545760405162461bcd60e51b81526020600482015260156024820152741114ce881d5cd95c881a5cdb89dd081cdd185ad959605a1b6044820152606401610611565b80861115611d60578095505b600684015460009060ff1615611f665784546001600160801b0316421080611ddb575060018501548554611da0916001600160801b039081169116612e4b565b6001600160801b031642118015611ddb575060028501548354611dcf916001600160801b039081169116612e4b565b6001600160801b031642115b611e275760405162461bcd60e51b815260206004820152601b60248201527f44533a20706f6f6c207769746864726177206973206c6f636b656400000000006044820152606401610611565b60c9546040516370a0823160e01b815230600482015260009161010090046001600160a01b0316906370a0823190602401602060405180830381865afa158015611e75573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611e999190612c15565b905080881115611ea7578097505b611eb18884612c02565b915060008811611f035760405162461bcd60e51b815260206004820152601760248201527f44533a206e6f7468696e6720746f2077697468647261770000000000000000006044820152606401610611565b856005015482101580611f14575081155b611f605760405162461bcd60e51b815260206004820152601b60248201527f44533a20696e76616c696420776974686472617720616d6f756e7400000000006044820152606401610611565b50611f73565b611f708783612c02565b90505b6040805160808101825284546001600160801b031681526001850154602082015260028501549181019190915260038401546060820152600090611fb8908890612155565b85546001600160801b031916426001600160801b0316178655600186018890556002860180549192508991600090611ff1908490612c02565b9091555050600284018790556001840182905560038401819055600686015460ff161561204b578760ce600082825461202a9190612c02565b909155505060c95461204b9061010090046001600160a01b03168b8a6118a7565b896001600160a01b0316897fc58ee088a46c9f0489c976c90d228e4c3878985b4bddcc82ee960e0110d94e5a8a60405161208791815260200190565b60405180910390a350505050505050505050565b60006120ad6040830160208401612c2e565b6001600160801b0316116107f25760405162461bcd60e51b815260206004820152601d60248201527f44533a20696e76616c696420646563726561736520696e74657276616c0000006044820152606401610611565b603380546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b6000806a084595161401484a00000083602001518460400151866121799190612c02565b6121839190612ebd565b61218d9190612ed4565b905080836060015161197d9190612ef6565b600054610100900460ff166121c65760405162461bcd60e51b815260040161061190612e72565b610f5f33612103565b6001600160a01b0381163b61223c5760405162461bcd60e51b815260206004820152602d60248201527f455243313936373a206e657720696d706c656d656e746174696f6e206973206e60448201526c1bdd08184818dbdb9d1c9858dd609a1b6064820152608401610611565b600080516020612f4383398151915280546001600160a01b0319166001600160a01b0392909216919091179055565b6122748361239d565b6000825111806122815750805b1561171057610bc483836123dd565b60006122e5826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b03166124029092919063ffffffff16565b90508051600014806123065750808060200190518101906123069190612f09565b6117105760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b6064820152608401610611565b6040516001600160a01b0380851660248301528316604482015260648101829052610bc49085906323b872dd60e01b906084016118d3565b6123a6816121cf565b6040516001600160a01b038216907fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b90600090a250565b60606109378383604051806060016040528060278152602001612f6360279139612411565b606061197d8484600085612489565b6060600080856001600160a01b03168560405161242e9190612f26565b600060405180830381855af49150503d8060008114612469576040519150601f19603f3d011682016040523d82523d6000602084013e61246e565b606091505b509150915061247f86838387612564565b9695505050505050565b6060824710156124ea5760405162461bcd60e51b815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f6044820152651c8818d85b1b60d21b6064820152608401610611565b600080866001600160a01b031685876040516125069190612f26565b60006040518083038185875af1925050503d8060008114612543576040519150601f19603f3d011682016040523d82523d6000602084013e612548565b606091505b509150915061255987838387612564565b979650505050505050565b606083156125d35782516000036125cc576001600160a01b0385163b6125cc5760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000006044820152606401610611565b508161197d565b61197d83838151156125e85781518083602001fd5b8060405162461bcd60e51b81526004016106119190612771565b80356001600160a01b038116811461261957600080fd5b919050565b6000806000806060858703121561263457600080fd5b61263d85612602565b935061264b60208601612602565b9250604085013567ffffffffffffffff8082111561266857600080fd5b818701915087601f83011261267c57600080fd5b81358181111561268b57600080fd5b886020610120830285010111156126a157600080fd5b95989497505060200194505050565b600080604083850312156126c357600080fd5b6126cc83612602565b946020939093013593505050565b6000602082840312156126ec57600080fd5b61093782612602565b60008060006060848603121561270a57600080fd5b505081359360208301359350604090920135919050565b60005b8381101561273c578181015183820152602001612724565b50506000910152565b6000815180845261275d816020860160208601612721565b601f01601f19169290920160200192915050565b6020815260006109376020830184612745565b60008083601f84011261279657600080fd5b50813567ffffffffffffffff8111156127ae57600080fd5b6020830191508360208260051b85010111156127c957600080fd5b9250929050565b6000806000806000606086880312156127e857600080fd5b85359450602086013567ffffffffffffffff8082111561280757600080fd5b61281389838a01612784565b9096509450604088013591508082111561282c57600080fd5b5061283988828901612784565b969995985093965092949392505050565b6000806040838503121561285d57600080fd5b50508035926020909101359150565b634e487b7160e01b600052604160045260246000fd5b604051601f8201601f1916810167ffffffffffffffff811182821017156128ab576128ab61286c565b604052919050565b600067ffffffffffffffff8211156128cd576128cd61286c565b50601f01601f191660200190565b600080604083850312156128ee57600080fd5b6128f783612602565b9150602083013567ffffffffffffffff81111561291357600080fd5b8301601f8101851361292457600080fd5b8035612937612932826128b3565b612882565b81815286602083850101111561294c57600080fd5b816020840160208301376000602083830101528093505050509250929050565b6001600160801b03811681146107f257600080fd5b80356126198161296c565b6000806000606084860312156129a157600080fd5b8335925060208401356129b38161296c565b915060408401356129c38161296c565b809150509250925092565b600061012082840312156129e157600080fd5b50919050565b600061012082840312156129fa57600080fd5b61093783836129ce565b60008060408385031215612a1757600080fd5b82359150612a2760208401612602565b90509250929050565b600060208284031215612a4257600080fd5b5035919050565b6000806101408385031215612a5d57600080fd5b82359150612a2784602085016129ce565b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052601160045260246000fd5b600060018201612aac57612aac612a84565b5060010190565b6020808252602c908201527f46756e6374696f6e206d7573742062652063616c6c6564207468726f7567682060408201526b19195b1959d85d1958d85b1b60a21b606082015260800190565b6020808252602c908201527f46756e6374696f6e206d7573742062652063616c6c6564207468726f7567682060408201526b6163746976652070726f787960a01b606082015260800190565b600060208284031215612b5d57600080fd5b815167ffffffffffffffff811115612b7457600080fd5b8201601f81018413612b8557600080fd5b8051612b93612932826128b3565b818152856020838501011115612ba857600080fd5b610e43826020830160208601612721565b82815260406020820152600061197d6040830184612745565b6020808252601690820152751114ce881c1bdbdb08191bd95cdb89dd08195e1a5cdd60521b604082015260600190565b8181038181111561113757611137612a84565b600060208284031215612c2757600080fd5b5051919050565b600060208284031215612c4057600080fd5b81356109378161296c565b600081356111378161296c565b80151581146107f257600080fd5b6000813561113781612c58565b612c9c612c7f83612c4b565b82546001600160801b0319166001600160801b0391909116178255565b612ccb612cab60208401612c4b565b82546001600160801b031660809190911b6001600160801b031916178255565b60018101612cde612c7f60408501612c4b565b612ced612cab60608501612c4b565b50612d1e612cfd60808401612c4b565b600283016001600160801b0382166001600160801b03198254161781555050565b60a0820135600382015560c0820135600482015560e08201356005820155610c96612d4c6101008401612c66565b6006830160ff1981541660ff8315151681178255505050565b803561261981612c58565b61012081018235612d808161296c565b6001600160801b03168252612d9760208401612981565b6001600160801b03166020830152612db160408401612981565b6001600160801b03166040830152612dcb60608401612981565b6001600160801b03166060830152612de560808401612981565b6001600160801b03811660808401525060a083013560a083015260c083013560c083015260e083013560e0830152610100612e21818501612d65565b1515920191909152919050565b600060208284031215612e4057600080fd5b813561093781612c58565b6001600160801b03818116838216019080821115612e6b57612e6b612a84565b5092915050565b6020808252602b908201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960408201526a6e697469616c697a696e6760a81b606082015260800190565b808202811582820484141761113757611137612a84565b600082612ef157634e487b7160e01b600052601260045260246000fd5b500490565b8082018082111561113757611137612a84565b600060208284031215612f1b57600080fd5b815161093781612c58565b60008251612f38818460208701612721565b919091019291505056fe360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c206661696c6564a2646970667358221220ec6c3734261cc4f9912009717a946899b5422ccfd35cdbabeeb7f57804b0a69364736f6c63430008140033
Deployed Bytecode
0x6080604052600436106101665760003560e01c80637b0472f0116100d1578063c89039c51161008a578063ddd5e1b211610064578063ddd5e1b2146104b0578063e0b4b386146104c3578063f2fde38b146104ed578063f343e8581461050d57600080fd5b8063c89039c514610455578063d2ba5e3a1461047a578063d63bb92c1461049057600080fd5b80637b0472f0146103335780638468a4c4146103535780638da5cb5b14610373578063ac4afa38146103a5578063b7558b7a14610420578063beee9fa91461044057600080fd5b80634f1ef286116101235780634f1ef2861461029357806352d1902d146102a6578063535f583f146102c95780635bd2e387146102e9578063715018a61461030957806378df87b21461031e57600080fd5b80632a1f34f41461016b57806330dc63081461018d5780633659cfe6146102135780633a4f1431146102335780633fde343514610253578063441a3e7014610273575b600080fd5b34801561017757600080fd5b5061018b61018636600461261e565b610578565b005b34801561019957600080fd5b506101e46101a83660046126b0565b60cd60209081526000928352604080842090915290825290208054600182015460028301546003909301546001600160801b0390921692909184565b604080516001600160801b03909516855260208501939093529183015260608201526080015b60405180910390f35b34801561021f57600080fd5b5061018b61022e3660046126da565b610716565b6102466102413660046126f5565b6107f5565b60405161020a9190612771565b34801561025f57600080fd5b5061018b61026e3660046127d0565b61093e565b34801561027f57600080fd5b5061018b61028e36600461284a565b610b19565b61018b6102a13660046128db565b610bca565b3480156102b257600080fd5b506102bb610c9a565b60405190815260200161020a565b3480156102d557600080fd5b506102bb6102e436600461298c565b610d4d565b3480156102f557600080fd5b5061018b6103043660046129e7565b610e4c565b34801561031557600080fd5b5061018b610f4d565b34801561032a57600080fd5b506102bb610f61565b34801561033f57600080fd5b5061018b61034e36600461284a565b610ffc565b34801561035f57600080fd5b506102bb61036e366004612a04565b6110a7565b34801561037f57600080fd5b506033546001600160a01b03165b6040516001600160a01b03909116815260200161020a565b3480156103b157600080fd5b506103c56103c0366004612a30565b61113d565b604080516001600160801b039a8b168152988a1660208a015296891696880196909652938716606087015295909116608085015260a084015260c083019390935260e08201929092529015156101008201526101200161020a565b34801561042c57600080fd5b5060ca5461038d906001600160a01b031681565b34801561044c57600080fd5b5061018b6111ab565b34801561046157600080fd5b5060c95461038d9061010090046001600160a01b031681565b34801561048657600080fd5b506102bb60ce5481565b34801561049c57600080fd5b5061018b6104ab366004612a49565b6111c2565b61018b6104be366004612a04565b61132d565b3480156104cf57600080fd5b5060c9546104dd9060ff1681565b604051901515815260200161020a565b3480156104f957600080fd5b5061018b6105083660046126da565b6115b6565b34801561051957600080fd5b50610553610528366004612a30565b60cc602052600090815260409020805460018201546002909201546001600160801b03909116919083565b604080516001600160801b03909416845260208401929092529082015260600161020a565b600054610100900460ff16158080156105985750600054600160ff909116105b806105b25750303b1580156105b2575060005460ff166001145b61061a5760405162461bcd60e51b815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201526d191e481a5b9a5d1a585b1a5e995960921b60648201526084015b60405180910390fd5b6000805460ff19166001179055801561063d576000805461ff0019166101001790555b61064561162c565b61064d61165b565b60005b828110156106895761067984848381811061066d5761066d612a6e565b90506101200201610e4c565b61068281612a9a565b9050610650565b5060c98054610100600160a81b0319166101006001600160a01b03888116919091029190911790915560ca80546001600160a01b031916918616919091179055801561070f576000805461ff0019169055604051600181527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb38474024989060200160405180910390a15b5050505050565b6001600160a01b037f00000000000000000000000024c09a0c047e8a439f26682ea51c7157b3ccc20b16300361075e5760405162461bcd60e51b815260040161061190612ab3565b7f00000000000000000000000024c09a0c047e8a439f26682ea51c7157b3ccc20b6001600160a01b03166107a7600080516020612f43833981519152546001600160a01b031690565b6001600160a01b0316146107cd5760405162461bcd60e51b815260040161061190612aff565b6107d681611682565b604080516000808252602082019092526107f2918391906116dd565b50565b60606107ff61184d565b6000610809610f61565b9050600081116108525760405162461bcd60e51b815260206004820152601460248201527344533a206f766572706c7573206973207a65726f60601b6044820152606401610611565b60ca5460c954610874916001600160a01b0361010090920482169116836118a7565b60ca5460405163fa69dce560e01b81526004810187905260248101869052604481018590526000916001600160a01b03169063fa69dce590349060640160006040518083038185885af11580156108cf573d6000803e3d6000fd5b50505050506040513d6000823e601f3d908101601f191682016040526108f89190810190612b4b565b90507fba6b0fa6fe85fc22ff5fb621db882cf2810a52956ae27fc4609bddc39b6ab7cf828260405161092b929190612bb9565b60405180910390a19150505b9392505050565b61094661184d565b846109528160cb541190565b61096e5760405162461bcd60e51b815260040161061190612bd2565b60cb868154811061098157610981612a6e565b600091825260209091206006600790920201015460ff16156109da5760405162461bcd60e51b815260206004820152601260248201527144533a20706f6f6c206973207075626c696360701b6044820152606401610611565b838214610a1e5760405162461bcd60e51b8152602060048201526012602482015271088a67440d2dcecc2d8d2c840d8cadccee8d60731b6044820152606401610611565b6000610a298761190a565b905060005b85811015610b0f576000878783818110610a4a57610a4a612a6e565b9050602002016020810190610a5f91906126da565b90506000868684818110610a7557610a75612a6e565b905060200201359050600060cd6000846001600160a01b03166001600160a01b0316815260200190815260200160002060008c815260200190815260200160002060010154905081811015610ade57610ad9838c610ad38486612c02565b88611985565b610afb565b81811115610afb57610afb838c610af58585612c02565b88611cb7565b50505080610b0890612a9a565b9050610a2e565b5050505050505050565b81610b258160cb541190565b610b415760405162461bcd60e51b815260040161061190612bd2565b8260cb8181548110610b5557610b55612a6e565b600091825260209091206006600790920201015460ff16610bb05760405162461bcd60e51b815260206004820152601560248201527444533a20706f6f6c2069736e2774207075626c696360581b6044820152606401610611565b610bc4338585610bbf8861190a565b611cb7565b50505050565b6001600160a01b037f00000000000000000000000024c09a0c047e8a439f26682ea51c7157b3ccc20b163003610c125760405162461bcd60e51b815260040161061190612ab3565b7f00000000000000000000000024c09a0c047e8a439f26682ea51c7157b3ccc20b6001600160a01b0316610c5b600080516020612f43833981519152546001600160a01b031690565b6001600160a01b031614610c815760405162461bcd60e51b815260040161061190612aff565b610c8a82611682565b610c96828260016116dd565b5050565b6000306001600160a01b037f00000000000000000000000024c09a0c047e8a439f26682ea51c7157b3ccc20b1614610d3a5760405162461bcd60e51b815260206004820152603860248201527f555550535570677261646561626c653a206d757374206e6f742062652063616c60448201527f6c6564207468726f7567682064656c656761746563616c6c00000000000000006064820152608401610611565b50600080516020612f4383398151915290565b6000610d5a8460cb541190565b610d6657506000610937565b600060cb8581548110610d7b57610d7b612a6e565b6000918252602090912060079091020160038101546004808301548354604051638ef1035b60e01b81529283019390935260248201526001600160801b038083166044830152600160801b90920482166064820152868216608482015290851660a4820152909150737431ada8a591c955a994a21710752ef9b882b8e390638ef1035b9060c401602060405180830381865af4158015610e1f573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610e439190612c15565b95945050505050565b610e5461184d565b42610e626020830183612c2e565b6001600160801b031611610eb85760405162461bcd60e51b815260206004820152601e60248201527f44533a20696e76616c6964207061796f75742073746172742076616c756500006044820152606401610611565b610ec18161209b565b60cb805460018101825560009190915281906007027fa7ce836d032b2bf62b7e2097a8e0a6d8aeb35405ad15271e96d3b0188a1d06fb01610f028282612c73565b505060cb54610f1390600190612c02565b7f9b9b09f76d4db7c7b0d783b9ba64d003e95462ef13cbb7cb782d74b085548cac82604051610f429190612d70565b60405180910390a250565b610f5561184d565b610f5f6000612103565b565b60c9546040516370a0823160e01b815230600482015260009182916101009091046001600160a01b0316906370a0823190602401602060405180830381865afa158015610fb2573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610fd69190612c15565b905060ce548111610fe957600091505090565b60ce54610ff69082612c02565b91505090565b816110088160cb541190565b6110245760405162461bcd60e51b815260040161061190612bd2565b8260cb818154811061103857611038612a6e565b600091825260209091206006600790920201015460ff166110935760405162461bcd60e51b815260206004820152601560248201527444533a20706f6f6c2069736e2774207075626c696360581b6044820152606401610611565b610bc43385856110a28861190a565b611985565b60006110b48360cb541190565b6110c057506000611137565b6001600160a01b038216600090815260cd602090815260408083208684529091528120906110ed8561190a565b6040805160808101825284546001600160801b031681526001850154602082015260028501549181019190915260038401546060820152909150611132908290612155565b925050505b92915050565b60cb818154811061114d57600080fd5b600091825260209091206007909102018054600182015460028301546003840154600485015460058601546006909601546001600160801b038087169850600160801b96879004811697868216979096048116959416939060ff1689565b6111b361184d565b60c9805460ff19166001179055565b6111ca61184d565b816111d68160cb541190565b6111f25760405162461bcd60e51b815260040161061190612bd2565b6111fb8261209b565b61120d61012083016101008401612e2e565b151560cb848154811061122257611222612a6e565b600091825260209091206006600790920201015460ff161515146112805760405162461bcd60e51b815260206004820152601560248201527444533a20696e76616c696420706f6f6c207479706560581b6044820152606401610611565b600083815260cc60205260408120906112988561190a565b6001830181905582546001600160801b031916426001600160801b031617835560cb80549192508591879081106112d1576112d1612a6e565b906000526020600020906007020181816112eb9190612c73565b905050847f3a267bddb165bbfddc7b47b4a65707d7b637e98f445a07ba27ba471b9e0bea548560405161131e9190612d70565b60405180910390a25050505050565b816113398160cb541190565b6113555760405162461bcd60e51b815260040161061190612bd2565b6000339050600060cb858154811061136f5761136f612a6e565b6000918252602080832088845260cc825260408085206001600160a01b038816865260cd84528186208b8752909352909320600792909202909201600181015481549194506113d291600160801b9091046001600160801b039081169116612e4b565b6001600160801b031642116114295760405162461bcd60e51b815260206004820152601860248201527f44533a20706f6f6c20636c61696d206973206c6f636b656400000000000000006044820152606401610611565b60006114348861190a565b6040805160808101825284546001600160801b03168152600185015460208201526002850154918101919091526003840154606082015290915060009061147c908390612155565b9050600081116114c55760405162461bcd60e51b815260206004820152601460248201527344533a206e6f7468696e6720746f20636c61696d60601b6044820152606401610611565b83546001600160801b031916426001600160801b031617845560018401829055600283018290556000600384015560ca5460405163204209a560e11b81526001600160a01b038a8116600483015260248201849052888116604483015290911690634084134a9034906064016000604051808303818588803b15801561154a57600080fd5b505af115801561155e573d6000803e3d6000fd5b5050604080516001600160a01b038d81168252602082018790528b1694508d93507face6f3f8956413e2875b9070e2616d13687dfb251cf63b343028c32822dfa26392500160405180910390a3505050505050505050565b6115be61184d565b6001600160a01b0381166116235760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b6064820152608401610611565b6107f281612103565b600054610100900460ff166116535760405162461bcd60e51b815260040161061190612e72565b610f5f61219f565b600054610100900460ff16610f5f5760405162461bcd60e51b815260040161061190612e72565b61168a61184d565b60c95460ff16156107f25760405162461bcd60e51b815260206004820152601b60248201527f44533a20757067726164652069736e277420617661696c61626c6500000000006044820152606401610611565b7f4910fdfa16fed3260ed0e7147f7cc6da11a60208b5b9406d12a635614ffd91435460ff161561171557611710836121cf565b505050565b826001600160a01b03166352d1902d6040518163ffffffff1660e01b8152600401602060405180830381865afa92505050801561176f575060408051601f3d908101601f1916820190925261176c91810190612c15565b60015b6117d25760405162461bcd60e51b815260206004820152602e60248201527f45524331393637557067726164653a206e657720696d706c656d656e7461746960448201526d6f6e206973206e6f74205555505360901b6064820152608401610611565b600080516020612f4383398151915281146118415760405162461bcd60e51b815260206004820152602960248201527f45524331393637557067726164653a20756e737570706f727465642070726f786044820152681a58589b195555525160ba1b6064820152608401610611565b5061171083838361226b565b6033546001600160a01b03163314610f5f5760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152606401610611565b6040516001600160a01b03831660248201526044810182905261171090849063a9059cbb60e01b906064015b60408051601f198184030181529190526020810180516001600160e01b03166001600160e01b031990931692909217909152612290565b600081815260cc602052604081206002810154820361192d576001015492915050565b80546000906119479085906001600160801b031642610d4d565b60028301549091506119646a084595161401484a00000083612ebd565b61196e9190612ed4565b826001015461197d9190612ef6565b949350505050565b600082116119cc5760405162461bcd60e51b815260206004820152601460248201527344533a206e6f7468696e6720746f207374616b6560601b6044820152606401610611565b600060cb84815481106119e1576119e1612a6e565b6000918252602080832087845260cc825260408085206001600160a01b038b16865260cd84528186208a8752909352909320600792909202909201600681015490935060ff1615611baf5760c9546040516370a0823160e01b815230600482015260009161010090046001600160a01b0316906370a0823190602401602060405180830381865afa158015611a7a573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611a9e9190612c15565b9050611abd3360c95461010090046001600160a01b0316903089612365565b60c9546040516370a0823160e01b815230600482015260009161010090046001600160a01b0316906370a0823190602401602060405180830381865afa158015611b0b573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611b2f9190612c15565b9050611b3b8282612c02565b96508460050154878460010154611b529190612ef6565b1015611b955760405162461bcd60e51b815260206004820152601260248201527144533a20616d6f756e7420746f6f206c6f7760701b6044820152606401610611565b8660ce6000828254611ba79190612ef6565b909155505050505b6040805160808101825282546001600160801b031681526001830154602082015260028301549181019190915260038201546060820152611bf1908590612155565b600382015581546001600160801b031916426001600160801b031617825560018201849055600282018054869190600090611c2d908490612ef6565b909155505080546001600160801b031916426001600160801b031617815560028101849055600181018054869190600090611c69908490612ef6565b90915550506040518581526001600160a01b0388169087907fe2f02dc2168917563b46b1f788ea74861c381103710158efe9976c0bb33336779060200160405180910390a350505050505050565b600060cb8481548110611ccc57611ccc612a6e565b6000918252602080832087845260cc825260408085206001600160a01b038b16865260cd84528186208a8752909352909320600181015460079093029093019350919080611d545760405162461bcd60e51b81526020600482015260156024820152741114ce881d5cd95c881a5cdb89dd081cdd185ad959605a1b6044820152606401610611565b80861115611d60578095505b600684015460009060ff1615611f665784546001600160801b0316421080611ddb575060018501548554611da0916001600160801b039081169116612e4b565b6001600160801b031642118015611ddb575060028501548354611dcf916001600160801b039081169116612e4b565b6001600160801b031642115b611e275760405162461bcd60e51b815260206004820152601b60248201527f44533a20706f6f6c207769746864726177206973206c6f636b656400000000006044820152606401610611565b60c9546040516370a0823160e01b815230600482015260009161010090046001600160a01b0316906370a0823190602401602060405180830381865afa158015611e75573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611e999190612c15565b905080881115611ea7578097505b611eb18884612c02565b915060008811611f035760405162461bcd60e51b815260206004820152601760248201527f44533a206e6f7468696e6720746f2077697468647261770000000000000000006044820152606401610611565b856005015482101580611f14575081155b611f605760405162461bcd60e51b815260206004820152601b60248201527f44533a20696e76616c696420776974686472617720616d6f756e7400000000006044820152606401610611565b50611f73565b611f708783612c02565b90505b6040805160808101825284546001600160801b031681526001850154602082015260028501549181019190915260038401546060820152600090611fb8908890612155565b85546001600160801b031916426001600160801b0316178655600186018890556002860180549192508991600090611ff1908490612c02565b9091555050600284018790556001840182905560038401819055600686015460ff161561204b578760ce600082825461202a9190612c02565b909155505060c95461204b9061010090046001600160a01b03168b8a6118a7565b896001600160a01b0316897fc58ee088a46c9f0489c976c90d228e4c3878985b4bddcc82ee960e0110d94e5a8a60405161208791815260200190565b60405180910390a350505050505050505050565b60006120ad6040830160208401612c2e565b6001600160801b0316116107f25760405162461bcd60e51b815260206004820152601d60248201527f44533a20696e76616c696420646563726561736520696e74657276616c0000006044820152606401610611565b603380546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b6000806a084595161401484a00000083602001518460400151866121799190612c02565b6121839190612ebd565b61218d9190612ed4565b905080836060015161197d9190612ef6565b600054610100900460ff166121c65760405162461bcd60e51b815260040161061190612e72565b610f5f33612103565b6001600160a01b0381163b61223c5760405162461bcd60e51b815260206004820152602d60248201527f455243313936373a206e657720696d706c656d656e746174696f6e206973206e60448201526c1bdd08184818dbdb9d1c9858dd609a1b6064820152608401610611565b600080516020612f4383398151915280546001600160a01b0319166001600160a01b0392909216919091179055565b6122748361239d565b6000825111806122815750805b1561171057610bc483836123dd565b60006122e5826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b03166124029092919063ffffffff16565b90508051600014806123065750808060200190518101906123069190612f09565b6117105760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b6064820152608401610611565b6040516001600160a01b0380851660248301528316604482015260648101829052610bc49085906323b872dd60e01b906084016118d3565b6123a6816121cf565b6040516001600160a01b038216907fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b90600090a250565b60606109378383604051806060016040528060278152602001612f6360279139612411565b606061197d8484600085612489565b6060600080856001600160a01b03168560405161242e9190612f26565b600060405180830381855af49150503d8060008114612469576040519150601f19603f3d011682016040523d82523d6000602084013e61246e565b606091505b509150915061247f86838387612564565b9695505050505050565b6060824710156124ea5760405162461bcd60e51b815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f6044820152651c8818d85b1b60d21b6064820152608401610611565b600080866001600160a01b031685876040516125069190612f26565b60006040518083038185875af1925050503d8060008114612543576040519150601f19603f3d011682016040523d82523d6000602084013e612548565b606091505b509150915061255987838387612564565b979650505050505050565b606083156125d35782516000036125cc576001600160a01b0385163b6125cc5760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000006044820152606401610611565b508161197d565b61197d83838151156125e85781518083602001fd5b8060405162461bcd60e51b81526004016106119190612771565b80356001600160a01b038116811461261957600080fd5b919050565b6000806000806060858703121561263457600080fd5b61263d85612602565b935061264b60208601612602565b9250604085013567ffffffffffffffff8082111561266857600080fd5b818701915087601f83011261267c57600080fd5b81358181111561268b57600080fd5b886020610120830285010111156126a157600080fd5b95989497505060200194505050565b600080604083850312156126c357600080fd5b6126cc83612602565b946020939093013593505050565b6000602082840312156126ec57600080fd5b61093782612602565b60008060006060848603121561270a57600080fd5b505081359360208301359350604090920135919050565b60005b8381101561273c578181015183820152602001612724565b50506000910152565b6000815180845261275d816020860160208601612721565b601f01601f19169290920160200192915050565b6020815260006109376020830184612745565b60008083601f84011261279657600080fd5b50813567ffffffffffffffff8111156127ae57600080fd5b6020830191508360208260051b85010111156127c957600080fd5b9250929050565b6000806000806000606086880312156127e857600080fd5b85359450602086013567ffffffffffffffff8082111561280757600080fd5b61281389838a01612784565b9096509450604088013591508082111561282c57600080fd5b5061283988828901612784565b969995985093965092949392505050565b6000806040838503121561285d57600080fd5b50508035926020909101359150565b634e487b7160e01b600052604160045260246000fd5b604051601f8201601f1916810167ffffffffffffffff811182821017156128ab576128ab61286c565b604052919050565b600067ffffffffffffffff8211156128cd576128cd61286c565b50601f01601f191660200190565b600080604083850312156128ee57600080fd5b6128f783612602565b9150602083013567ffffffffffffffff81111561291357600080fd5b8301601f8101851361292457600080fd5b8035612937612932826128b3565b612882565b81815286602083850101111561294c57600080fd5b816020840160208301376000602083830101528093505050509250929050565b6001600160801b03811681146107f257600080fd5b80356126198161296c565b6000806000606084860312156129a157600080fd5b8335925060208401356129b38161296c565b915060408401356129c38161296c565b809150509250925092565b600061012082840312156129e157600080fd5b50919050565b600061012082840312156129fa57600080fd5b61093783836129ce565b60008060408385031215612a1757600080fd5b82359150612a2760208401612602565b90509250929050565b600060208284031215612a4257600080fd5b5035919050565b6000806101408385031215612a5d57600080fd5b82359150612a2784602085016129ce565b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052601160045260246000fd5b600060018201612aac57612aac612a84565b5060010190565b6020808252602c908201527f46756e6374696f6e206d7573742062652063616c6c6564207468726f7567682060408201526b19195b1959d85d1958d85b1b60a21b606082015260800190565b6020808252602c908201527f46756e6374696f6e206d7573742062652063616c6c6564207468726f7567682060408201526b6163746976652070726f787960a01b606082015260800190565b600060208284031215612b5d57600080fd5b815167ffffffffffffffff811115612b7457600080fd5b8201601f81018413612b8557600080fd5b8051612b93612932826128b3565b818152856020838501011115612ba857600080fd5b610e43826020830160208601612721565b82815260406020820152600061197d6040830184612745565b6020808252601690820152751114ce881c1bdbdb08191bd95cdb89dd08195e1a5cdd60521b604082015260600190565b8181038181111561113757611137612a84565b600060208284031215612c2757600080fd5b5051919050565b600060208284031215612c4057600080fd5b81356109378161296c565b600081356111378161296c565b80151581146107f257600080fd5b6000813561113781612c58565b612c9c612c7f83612c4b565b82546001600160801b0319166001600160801b0391909116178255565b612ccb612cab60208401612c4b565b82546001600160801b031660809190911b6001600160801b031916178255565b60018101612cde612c7f60408501612c4b565b612ced612cab60608501612c4b565b50612d1e612cfd60808401612c4b565b600283016001600160801b0382166001600160801b03198254161781555050565b60a0820135600382015560c0820135600482015560e08201356005820155610c96612d4c6101008401612c66565b6006830160ff1981541660ff8315151681178255505050565b803561261981612c58565b61012081018235612d808161296c565b6001600160801b03168252612d9760208401612981565b6001600160801b03166020830152612db160408401612981565b6001600160801b03166040830152612dcb60608401612981565b6001600160801b03166060830152612de560808401612981565b6001600160801b03811660808401525060a083013560a083015260c083013560c083015260e083013560e0830152610100612e21818501612d65565b1515920191909152919050565b600060208284031215612e4057600080fd5b813561093781612c58565b6001600160801b03818116838216019080821115612e6b57612e6b612a84565b5092915050565b6020808252602b908201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960408201526a6e697469616c697a696e6760a81b606082015260800190565b808202811582820484141761113757611137612a84565b600082612ef157634e487b7160e01b600052601260045260246000fd5b500490565b8082018082111561113757611137612a84565b600060208284031215612f1b57600080fd5b815161093781612c58565b60008251612f38818460208701612721565b919091019291505056fe360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c206661696c6564a2646970667358221220ec6c3734261cc4f9912009717a946899b5422ccfd35cdbabeeb7f57804b0a69364736f6c63430008140033
Loading...
Loading
Loading...
Loading
Multichain Portfolio | 34 Chains
| Chain | Token | Portfolio % | Price | Amount | Value |
|---|
Loading...
Loading
Loading...
Loading
Loading...
Loading
A contract address hosts a smart contract, which is a set of code stored on the blockchain that runs when predetermined conditions are met. Learn more about addresses in our Knowledge Base.