Overview
ETH Balance
0 ETH
Eth Value
$0.00More Info
Private Name Tags
ContractCreator
View more zero value Internal Transactions in Advanced View mode
Advanced mode:
Loading...
Loading
This contract contains unverified libraries: ERC20FactoryLib
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:
MasterPenpie
Compiler Version
v0.8.19+commit.7dd6d404
Optimization Enabled:
Yes with 100 runs
Other Settings:
default evmVersion
Contract Source Code (Solidity Standard Json-Input format)
// SPDX-License-Identifier: MIT pragma solidity ^0.8.19; import { Initializable } from "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol"; import { OwnableUpgradeable } from "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol"; import { SafeERC20 } from "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol"; import { IERC20Metadata } from "@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol"; import { Address } from "@openzeppelin/contracts/utils/Address.sol"; import { ReentrancyGuardUpgradeable } from "@openzeppelin/contracts-upgradeable/security/ReentrancyGuardUpgradeable.sol"; import { PausableUpgradeable } from "@openzeppelin/contracts-upgradeable/security/PausableUpgradeable.sol"; import "../PenpieOFT.sol"; import "../rewards/BaseRewardPoolV2.sol"; import "../interfaces/IBaseRewardPool.sol"; import "../interfaces/IARBRewarder.sol"; import "../interfaces/IVLPenpieBaseRewarder.sol"; import "../interfaces/IVLPenpie.sol"; import "../libraries/ERC20FactoryLib.sol"; import "../interfaces/IMintableERC20.sol"; /// @title A contract for managing all reward pools /// @author Magpie Team /// @notice Mater penpie emit `PNP` reward token based on Time. For a pool, contract MasterPenpie is Initializable, OwnableUpgradeable, ReentrancyGuardUpgradeable, PausableUpgradeable { using SafeERC20 for IERC20; /* ============ Structs ============ */ // Info of each user. struct UserInfo { uint256 amount; // How many staking tokens the user has provided. uint256 rewardDebt; // Reward debt. See explanation below. uint256 available; // in case of locking uint256 unClaimedPenpie; // // We do some fancy math here. Basically, any point in time, the amount of Penpies // entitled to a user but is pending to be distributed is: // // pending reward = (user.amount * pool.accPenpiePerShare) - user.rewardDebt // // Whenever a user deposits or withdraws staking tokens to a pool. Here's what happens: // 1. The pool's `accPenpiePerShare` (and `lastRewardTimestamp`) gets updated. // 2. User receives the pending reward sent to his/her address. // 3. User's `amount` gets updated. // 4. User's `rewardDebt` gets updated. } // Info of each pool. struct PoolInfo { address stakingToken; // Address of staking token contract to be staked. address receiptToken; // Address of receipt token contract represent a staking position uint256 allocPoint; // How many allocation points assigned to this pool. Penpies to distribute per second. uint256 lastRewardTimestamp; // Last timestamp that Penpies distribution occurs. uint256 accPenpiePerShare; // Accumulated Penpies per share, times 1e12. See below. uint256 totalStaked; address rewarder; bool isActive; // if the pool is active } /* ============ State Variables ============ */ // The Penpie TOKEN! IERC20 public penpieOFT; IVLPenpie public vlPenpie; // penpie tokens created per second. uint256 public penpiePerSec; // Registered staking tokens address[] public registeredToken; // Info of each pool. mapping(address => PoolInfo) public tokenToPoolInfo; // mapping of staking -> receipt Token mapping(address => address) public receiptToStakeToken; // Info of each user that stakes staking tokens [_staking][_account] mapping(address => mapping(address => UserInfo)) public userInfo; // Total allocation points. Must be the sum of all allocation points in all pools. uint256 public totalAllocPoint; // The timestamp when Penpie mining starts. uint256 public startTimestamp; mapping(address => bool) public PoolManagers; mapping(address => bool) public AllocationManagers; /* ==== variable added for mPendleSV contract === */ address public mPendleSV; address public compounder; /* variable added for 1st upgrade */ address public ARBRewarder; /* ============ Events ============ */ event Add( uint256 _allocPoint, address indexed _stakingToken, address indexed _receiptToken, IBaseRewardPool indexed _rewarder ); event Set( address indexed _stakingToken, uint256 _allocPoint, IBaseRewardPool indexed _rewarder ); event Deposit( address indexed _user, address indexed _stakingToken, address indexed _receiptToken, uint256 _amount ); event Withdraw( address indexed _user, address indexed _stakingToken, address indexed _receiptToken, uint256 _amount ); event UpdatePool( address indexed _stakingToken, uint256 _lastRewardTimestamp, uint256 _lpSupply, uint256 _accPenpiePerShare ); event HarvestPenpie( address indexed _account, address indexed _receiver, uint256 _amount, bool isLock ); event UpdateEmissionRate( address indexed _user, uint256 _oldPenpiePerSec, uint256 _newPenpiePerSec ); event UpdatePoolAlloc( address _stakingToken, uint256 _oldAllocPoint, uint256 _newAllocPoint ); event PoolManagerStatus(address _account, bool _status); event VlPenpieUpdated(address _newvlPenpie, address _oldvlPenpie); event CompounderUpdated(address _newCompounder, address _oldCompounder); event mPendleSVUpdated(address _newMPendleSV, address _oldMPendleSV); event DepositNotAvailable( address indexed _user, address indexed _stakingToken, uint256 _amount ); event PenpieOFTSet(address _penpie); event ARBRewarderSet(address _oldARBRewarder, address _newARBRewarder); event ARBRewarderSetAsQueuer(address rewarder); /* ============ Errors ============ */ error OnlyPoolManager(); error OnlyReceiptToken(); error OnlyStakingToken(); error OnlyActivePool(); error PoolExisted(); error InvalidStakingToken(); error WithdrawAmountExceedsStaked(); error UnlockAmountExceedsLocked(); error MustBeContractOrZero(); error OnlyVlPenpie(); error OnlyMPendleSV(); error PenpieOFTSetAlready(); error MustBeContract(); error LengthMismatch(); error OnlyWhiteListedAllocaUpdator(); error OnlyCompounder(); error onlyARBRewarder(); /* ============ Constructor ============ */ constructor() { _disableInitializers(); } function __MasterPenpie_init( address _penpieOFT, uint256 _penpiePerSec, uint256 _startTimestamp ) public initializer { __Ownable_init(); __ReentrancyGuard_init(); __Pausable_init(); penpieOFT = IERC20(_penpieOFT); penpiePerSec = _penpiePerSec; startTimestamp = _startTimestamp; totalAllocPoint = 0; PoolManagers[owner()] = true; } /* ============ Modifiers ============ */ modifier _onlyPoolManager() { if (!PoolManagers[msg.sender] && msg.sender != address(this)) revert OnlyPoolManager(); _; } modifier _onlyWhiteListed() { if ( AllocationManagers[msg.sender] || PoolManagers[msg.sender] || msg.sender == owner() ) { _; } else { revert OnlyWhiteListedAllocaUpdator(); } } modifier _onlyReceiptToken() { address stakingToken = receiptToStakeToken[msg.sender]; if (msg.sender != address(tokenToPoolInfo[stakingToken].receiptToken)) revert OnlyReceiptToken(); _; } modifier _onlyVlPenpie() { if (msg.sender != address(vlPenpie)) revert OnlyVlPenpie(); _; } modifier _onlyCompounder() { if (msg.sender != compounder) revert OnlyCompounder(); _; } modifier _onlyMPendleSV() { if (msg.sender != address(mPendleSV)) revert OnlyMPendleSV(); _; } /* ============ External Getters ============ */ /// @notice Returns number of registered tokens, tokens having a registered pool. /// @return Returns number of registered tokens function poolLength() external view returns (uint256) { return registeredToken.length; } /// @notice Gives information about a Pool. Used for APR calculation and Front-End /// @param _stakingToken Staking token of the pool we want to get information from /// @return emission - Emissions of Penpie from the contract, allocpoint - Allocated emissions of Penpie to the pool,sizeOfPool - size of Pool, totalPoint total allocation points function getPoolInfo( address _stakingToken ) external view returns ( uint256 emission, uint256 allocpoint, uint256 sizeOfPool, uint256 totalPoint ) { PoolInfo memory pool = tokenToPoolInfo[_stakingToken]; return ( ((penpiePerSec * pool.allocPoint) / totalAllocPoint), pool.allocPoint, pool.totalStaked, totalAllocPoint ); } /** * @dev Get staking information for a user. * @param _stakingToken The address of the staking token. * @param _user The address of the user. * @return stakedAmount The amount of tokens staked by the user. * @return availableAmount The available amount of tokens for the user to withdraw. */ function stakingInfo( address _stakingToken, address _user ) public view returns (uint256 stakedAmount, uint256 availableAmount) { return ( userInfo[_stakingToken][_user].amount, userInfo[_stakingToken][_user].available ); } /// @notice View function to see pending reward tokens on frontend. /// @param _stakingToken Staking token of the pool /// @param _user Address of the user /// @param _rewardToken Specific pending reward token, apart from Penpie /// @return pendingPenpie - Expected amount of Penpie the user can claim, bonusTokenAddress - token, bonusTokenSymbol - token Symbol, pendingBonusToken - Expected amount of token the user can claim function pendingTokens( address _stakingToken, address _user, address _rewardToken ) external view returns ( uint256 pendingPenpie, address bonusTokenAddress, string memory bonusTokenSymbol, uint256 pendingBonusToken ) { PoolInfo storage pool = tokenToPoolInfo[_stakingToken]; pendingPenpie = _calPenpieReward(_stakingToken, _user); // If it's a multiple reward farm, we return info about the specific bonus token if ( address(pool.rewarder) != address(0) && _rewardToken != address(0) ) { (bonusTokenAddress, bonusTokenSymbol) = ( _rewardToken, IERC20Metadata(_rewardToken).symbol() ); pendingBonusToken = IBaseRewardPool(pool.rewarder).earned( _user, _rewardToken ); } } function allPendingTokens( address _stakingToken, address _user ) external view returns ( uint256 pendingPenpie, address[] memory bonusTokenAddresses, string[] memory bonusTokenSymbols, uint256[] memory pendingBonusRewards ) { PoolInfo storage pool = tokenToPoolInfo[_stakingToken]; pendingPenpie = _calPenpieReward(_stakingToken, _user); // If it's a multiple reward farm, we return all info about the bonus tokens if (address(pool.rewarder) != address(0)) { (bonusTokenAddresses, bonusTokenSymbols) = IBaseRewardPool( pool.rewarder ).rewardTokenInfos(); pendingBonusRewards = IBaseRewardPool(pool.rewarder).allEarned( _user ); } } function getRewarder(address stakingToken) external view returns(address){ return tokenToPoolInfo[stakingToken].rewarder; } /* ============ External Functions ============ */ /// @notice Deposits staking token to the pool, updates pool and distributes rewards /// @param _stakingToken Staking token of the pool /// @param _amount Amount to deposit to the pool function deposit( address _stakingToken, uint256 _amount ) external whenNotPaused nonReentrant { PoolInfo storage pool = tokenToPoolInfo[_stakingToken]; IMintableERC20(pool.receiptToken).mint(msg.sender, _amount); IERC20(pool.stakingToken).safeTransferFrom( address(msg.sender), address(this), _amount ); emit Deposit(msg.sender, _stakingToken, pool.receiptToken, _amount); } function depositFor( address _stakingToken, address _for, uint256 _amount ) external whenNotPaused nonReentrant { PoolInfo storage pool = tokenToPoolInfo[_stakingToken]; IMintableERC20(pool.receiptToken).mint(_for, _amount); IERC20(pool.stakingToken).safeTransferFrom( address(msg.sender), address(this), _amount ); emit Deposit(_for, _stakingToken, pool.receiptToken, _amount); } /// @notice Withdraw staking tokens from Master Penpie. /// @param _stakingToken Staking token of the pool /// @param _amount amount to withdraw function withdraw( address _stakingToken, uint256 _amount ) external whenNotPaused nonReentrant { PoolInfo storage pool = tokenToPoolInfo[_stakingToken]; IMintableERC20(pool.receiptToken).burn(msg.sender, _amount); IERC20(pool.stakingToken).safeTransfer(msg.sender, _amount); emit Withdraw(msg.sender, _stakingToken, pool.receiptToken, _amount); } /// @notice Update reward variables of the given pool to be up-to-date. /// @param _stakingToken Staking token of the pool function updatePool(address _stakingToken) public whenNotPaused { PoolInfo storage pool = tokenToPoolInfo[_stakingToken]; if ( block.timestamp <= pool.lastRewardTimestamp || totalAllocPoint == 0 ) { return; } uint256 lpSupply = pool.totalStaked; if (lpSupply == 0) { pool.lastRewardTimestamp = block.timestamp; return; } uint256 multiplier = block.timestamp - pool.lastRewardTimestamp; uint256 penpieReward = (multiplier * penpiePerSec * pool.allocPoint) / totalAllocPoint; pool.accPenpiePerShare = pool.accPenpiePerShare + ((penpieReward * 1e12) / lpSupply); pool.lastRewardTimestamp = block.timestamp; emit UpdatePool( _stakingToken, pool.lastRewardTimestamp, lpSupply, pool.accPenpiePerShare ); } /// @notice Update reward variables for all pools. Be mindful of gas costs! function massUpdatePools() public whenNotPaused { for (uint256 pid = 0; pid < registeredToken.length; ++pid) { updatePool(registeredToken[pid]); } } /// @notice Claims for each of the pools with specified rewards to claim for each pool function multiclaimSpecPNP( address[] calldata _stakingTokens, address[][] memory _rewardTokens, bool _withPNP ) external whenNotPaused { _multiClaim(_stakingTokens, msg.sender, msg.sender, _rewardTokens, _withPNP); } /// @notice Claims for each of the pools with specified rewards to claim for each pool function multiclaimSpec( address[] calldata _stakingTokens, address[][] memory _rewardTokens ) external whenNotPaused { _multiClaim(_stakingTokens, msg.sender, msg.sender, _rewardTokens, true); } function multiclaimOnBehalf(address[] calldata _stakingTokens, address[][] memory _rewardTokens, address _account, bool _isClaimPNP) external whenNotPaused _onlyCompounder { _multiClaim(_stakingTokens, _account, msg.sender, _rewardTokens, _isClaimPNP); } /// @notice Claims for each of the pools with specified rewards to claim for each pool function multiclaimFor( address[] calldata _stakingTokens, address[][] memory _rewardTokens, address _account ) external whenNotPaused { _multiClaim(_stakingTokens, _account, _account, _rewardTokens, true); } /// @notice Claim for all rewards for the pools function multiclaim( address[] calldata _stakingTokens ) external whenNotPaused { address[][] memory rewardTokens = new address[][]( _stakingTokens.length ); _multiClaim(_stakingTokens, msg.sender, msg.sender, rewardTokens, true); } /* ============ penpie receipToken interaction Functions ============ */ function beforeReceiptTokenTransfer( address _from, address _to, uint256 _amount ) external _onlyReceiptToken { address _stakingToken = receiptToStakeToken[msg.sender]; updatePool(_stakingToken); if (_from != address(0)) _harvestRewards(_stakingToken, _from); if (_from != _to) _harvestRewards(_stakingToken, _to); } function afterReceiptTokenTransfer( address _from, address _to, uint256 _amount ) external _onlyReceiptToken { address _stakingToken = receiptToStakeToken[msg.sender]; PoolInfo storage pool = tokenToPoolInfo[_stakingToken]; if (_from != address(0)) { UserInfo storage from = userInfo[_stakingToken][_from]; from.amount = from.amount - _amount; from.available = from.available - _amount; from.rewardDebt = (from.amount * pool.accPenpiePerShare) / 1e12; } else { // mint tokenToPoolInfo[_stakingToken].totalStaked += _amount; } if (_to != address(0)) { UserInfo storage to = userInfo[_stakingToken][_to]; to.amount = to.amount + _amount; to.available = to.available + _amount; to.rewardDebt = (to.amount * pool.accPenpiePerShare) / 1e12; } else { // brun tokenToPoolInfo[_stakingToken].totalStaked -= _amount; } } /* ============ vlPenpie interaction Functions ============ */ function depositVlPenpieFor( uint256 _amount, address _for ) external whenNotPaused nonReentrant _onlyVlPenpie { _deposit(address(vlPenpie), msg.sender, _for, _amount, true); } function withdrawVlPenpieFor( uint256 _amount, address _for ) external whenNotPaused nonReentrant _onlyVlPenpie { _withdraw(address(vlPenpie), _for, _amount, true); } function depositMPendleSVFor( uint256 _amount, address _for ) external whenNotPaused _onlyMPendleSV() { _deposit(address(mPendleSV), msg.sender,_for, _amount, true); } function withdrawMPendleSVFor( uint256 _amount, address _for ) external whenNotPaused _onlyMPendleSV() { _withdraw(address(mPendleSV), _for, _amount, true); } /* ============ Internal Functions ============ */ /// @notice internal function to deal with deposit staking token function _deposit( address _stakingToken, address _from, address _for, uint256 _amount, bool _isLock ) internal { PoolInfo storage pool = tokenToPoolInfo[_stakingToken]; UserInfo storage user = userInfo[_stakingToken][_for]; updatePool(_stakingToken); _harvestRewards(_stakingToken, _for); user.amount = user.amount + _amount; if (!_isLock) { user.available = user.available + _amount; IERC20(pool.stakingToken).safeTransferFrom( address(_from), address(this), _amount ); } user.rewardDebt = (user.amount * pool.accPenpiePerShare) / 1e12; if (_amount > 0) { pool.totalStaked += _amount; if (!_isLock) emit Deposit(_for, _stakingToken, pool.receiptToken, _amount); else emit DepositNotAvailable(_for, _stakingToken, _amount); } } /// @notice internal function to deal with withdraw staking token function _withdraw( address _stakingToken, address _account, uint256 _amount, bool _isLock ) internal { PoolInfo storage pool = tokenToPoolInfo[_stakingToken]; UserInfo storage user = userInfo[_stakingToken][_account]; if (!_isLock && user.available < _amount) revert WithdrawAmountExceedsStaked(); else if (user.amount < _amount && _isLock) revert UnlockAmountExceedsLocked(); updatePool(_stakingToken); _harvestPenpie(_stakingToken, _account); _harvestBaseRewarder(_stakingToken, _account); user.amount = user.amount - _amount; if (!_isLock) { user.available = user.available - _amount; IERC20(tokenToPoolInfo[_stakingToken].stakingToken).safeTransfer( address(msg.sender), _amount ); } user.rewardDebt = (user.amount * pool.accPenpiePerShare) / 1e12; pool.totalStaked -= _amount; emit Withdraw(_account, _stakingToken, pool.receiptToken, _amount); } function _multiClaim( address[] calldata _stakingTokens, address _user, address _receiver, address[][] memory _rewardTokens, bool _withPnp ) internal nonReentrant { uint256 length = _stakingTokens.length; if (length != _rewardTokens.length) revert LengthMismatch(); uint256 vlPenpiePoolAmount; uint256 defaultPoolAmount; for (uint256 i = 0; i < length; ++i) { address _stakingToken = _stakingTokens[i]; UserInfo storage user = userInfo[_stakingToken][_user]; updatePool(_stakingToken); uint256 claimablePenpie = _calNewPenpie(_stakingToken, _user) + user.unClaimedPenpie; // if claim with PNP, then unclamed is 0 if (_withPnp) { if (_stakingToken == address(vlPenpie)) { vlPenpiePoolAmount += claimablePenpie; } else { defaultPoolAmount += claimablePenpie; } user.unClaimedPenpie = 0; } else { user.unClaimedPenpie = claimablePenpie; } user.rewardDebt = (user.amount * tokenToPoolInfo[_stakingToken].accPenpiePerShare) / 1e12; _claimBaseRewarder( _stakingToken, _user, _receiver, _rewardTokens[i] ); } // if not claiming PNP, early return if (!_withPnp) return; if (vlPenpiePoolAmount > 0) { _sendPenpieForVlPenpiePool(_user, _receiver, vlPenpiePoolAmount); } if (defaultPoolAmount > 0) { _sendPenpie(_user, _receiver, defaultPoolAmount); } } /// @notice calculate Penpie reward based at current timestamp, for frontend only function _calPenpieReward( address _stakingToken, address _user ) internal view returns (uint256 pendingPenpie) { PoolInfo storage pool = tokenToPoolInfo[_stakingToken]; UserInfo storage user = userInfo[_stakingToken][_user]; uint256 accPenpiePerShare = pool.accPenpiePerShare; if ( block.timestamp > pool.lastRewardTimestamp && pool.totalStaked != 0 ) { uint256 multiplier = block.timestamp - pool.lastRewardTimestamp; uint256 penpieReward = (multiplier * penpiePerSec * pool.allocPoint) / totalAllocPoint; accPenpiePerShare = accPenpiePerShare + (penpieReward * 1e12) / pool.totalStaked; } pendingPenpie = (user.amount * accPenpiePerShare) / 1e12 - user.rewardDebt; pendingPenpie += user.unClaimedPenpie; } function _harvestRewards(address _stakingToken, address _account) internal { if (userInfo[_stakingToken][_account].amount > 0) { _harvestPenpie(_stakingToken, _account); } _harvestBaseRewarder(_stakingToken, _account); } /// @notice Harvest Penpie for an account /// only update the reward counting but not sending them to user function _harvestPenpie(address _stakingToken, address _account) internal { // Harvest Penpie uint256 pending = _calNewPenpie(_stakingToken, _account); userInfo[_stakingToken][_account].unClaimedPenpie += pending; } /// @notice calculate Penpie reward based on current accPenpiePerShare function _calNewPenpie( address _stakingToken, address _account ) internal view returns (uint256) { UserInfo storage user = userInfo[_stakingToken][_account]; uint256 pending = (user.amount * tokenToPoolInfo[_stakingToken].accPenpiePerShare) / 1e12 - user.rewardDebt; return pending; } /// @notice Harvest reward token in BaseRewarder for an account. NOTE: Baserewarder use user staking token balance as source to /// calculate reward token amount function _claimBaseRewarder( address _stakingToken, address _account, address _receiver, address[] memory _rewardTokens ) internal { IBaseRewardPool rewarder = IBaseRewardPool( tokenToPoolInfo[_stakingToken].rewarder ); if (address(rewarder) != address(0)) { if (_rewardTokens.length > 0) { rewarder.getRewards(_account, _receiver, _rewardTokens); // if not specifiying any reward token, just claim them all } else { rewarder.getReward(_account, _receiver); } } } /// only update the reward counting on in base rewarder but not sending them to user function _harvestBaseRewarder( address _stakingToken, address _account ) internal { IBaseRewardPool rewarder = IBaseRewardPool( tokenToPoolInfo[_stakingToken].rewarder ); if(address(ARBRewarder) != address(0) && address(rewarder) != address(0)) IARBRewarder(ARBRewarder).harvestARB(_stakingToken, address(rewarder)); if (address(rewarder) != address(0)) rewarder.updateFor(_account); } function _sendPenpieForVlPenpiePool( address _account, address _receiver, uint256 _amount ) internal { address vlPenpieRewarder = tokenToPoolInfo[address(vlPenpie)].rewarder; penpieOFT.safeApprove(vlPenpieRewarder, _amount); IVLPenpieBaseRewarder(vlPenpieRewarder).queuePenpie( _amount, _account, _receiver ); emit HarvestPenpie(_account, _receiver, _amount, false); } function _sendPenpie( address _account, address _receiver, uint256 _amount ) internal { penpieOFT.safeTransfer(_receiver, _amount); emit HarvestPenpie(_account, _receiver, _amount, false); } function _addPool( uint256 _allocPoint, address _stakingToken, address _receiptToken, address _rewarder ) internal { if ( !Address.isContract(address(_stakingToken)) || !Address.isContract(address(_receiptToken)) ) revert InvalidStakingToken(); if ( !Address.isContract(address(_rewarder)) && address(_rewarder) != address(0) ) revert MustBeContractOrZero(); if (tokenToPoolInfo[_stakingToken].isActive) revert PoolExisted(); // massUpdatePools(); uint256 lastRewardTimestamp = block.timestamp > startTimestamp ? block.timestamp : startTimestamp; totalAllocPoint = totalAllocPoint + _allocPoint; registeredToken.push(_stakingToken); // it's receipt token as the registered token tokenToPoolInfo[_stakingToken] = PoolInfo({ receiptToken: _receiptToken, stakingToken: _stakingToken, allocPoint: _allocPoint, lastRewardTimestamp: lastRewardTimestamp, accPenpiePerShare: 0, totalStaked: 0, rewarder: _rewarder, isActive: true }); receiptToStakeToken[_receiptToken] = _stakingToken; emit Add( _allocPoint, _stakingToken, _receiptToken, IBaseRewardPool(_rewarder) ); } /* ============ Admin Functions ============ */ /// @notice Used to give edit rights to the pools in this contract to a Pool Manager /// @param _account Pool Manager Adress /// @param _allowedManager True gives rights, False revokes them function setPoolManagerStatus( address _account, bool _allowedManager ) external onlyOwner { PoolManagers[_account] = _allowedManager; emit PoolManagerStatus(_account, PoolManagers[_account]); } function setPenpie(address _penpieOFT) external onlyOwner { if (address(penpieOFT) != address(0)) revert PenpieOFTSetAlready(); if (!Address.isContract(_penpieOFT)) revert MustBeContract(); penpieOFT = IERC20(_penpieOFT); emit PenpieOFTSet(_penpieOFT); } function setCompounder(address _compounder) external onlyOwner { address oldCompounder = compounder; compounder = _compounder; emit CompounderUpdated(compounder, oldCompounder); } function setVlPenpie(address _vlPenpie) external onlyOwner { address oldvlPenpie = address(vlPenpie); vlPenpie = IVLPenpie(_vlPenpie); emit VlPenpieUpdated(address(vlPenpie), oldvlPenpie); } function setMPendleSV(address _mPendleSV) external onlyOwner { address oldMPendleSV = mPendleSV; mPendleSV = _mPendleSV; emit mPendleSVUpdated(_mPendleSV, oldMPendleSV); } /** * @dev pause pool, restricting certain operations */ function pause() external onlyOwner { _pause(); } /** * @dev unpause pool, enabling certain operations */ function unpause() external onlyOwner { _unpause(); } /// @notice Add a new rewarder to the pool. Can only be called by a PoolManager. /// @param _receiptToken receipt token of the pool /// @param mainRewardToken Token that will be rewarded for staking in the pool /// @return address of the rewarder created function createRewarder( address _receiptToken, address mainRewardToken ) external _onlyPoolManager returns (address) { address rewarder = ERC20FactoryLib.createRewarder( _receiptToken, mainRewardToken, address(this), msg.sender ); return rewarder; } /// @notice Add a new penlde marekt pool. Explicitly for Pendle Market pools and should be called from Pendle Staking. function add( uint256 _allocPoint, address _stakingToken, address _receiptToken, address _rewarder ) external _onlyPoolManager { _addPool(_allocPoint, _stakingToken, _receiptToken, _rewarder); } /// @notice Add a new pool that does not mint receipt token. Mainly for locker pool such as vlPNP, mPendleSV function createNoReceiptPool( uint256 _allocPoint, address _stakingToken, address _rewarder ) external onlyOwner { _addPool(_allocPoint, _stakingToken, _stakingToken, _rewarder); } function createPool( uint256 _allocPoint, address _stakingToken, string memory _receiptName, string memory _receiptSymbol ) external onlyOwner { IERC20 newToken = IERC20( ERC20FactoryLib.createReceipt( address(_stakingToken), address(this), _receiptName, _receiptSymbol ) ); address rewarder = this.createRewarder(address(newToken), address(0)); _addPool(_allocPoint, _stakingToken, address(newToken), rewarder); } /// @notice Updates the given pool's Penpie allocation point, rewarder address and locker address if overwritten. Can only be called by a Pool Manager. /// @param _stakingToken Staking token of the pool /// @param _allocPoint Allocation points of Penpie to the pool /// @param _rewarder Address of the rewarder for the pool function set( address _stakingToken, uint256 _allocPoint, address _rewarder ) external _onlyPoolManager { if ( !Address.isContract(address(_rewarder)) && address(_rewarder) != address(0) ) revert MustBeContractOrZero(); if (!tokenToPoolInfo[_stakingToken].isActive) revert OnlyActivePool(); // massUpdatePools(); totalAllocPoint = totalAllocPoint - tokenToPoolInfo[_stakingToken].allocPoint + _allocPoint; tokenToPoolInfo[_stakingToken].allocPoint = _allocPoint; tokenToPoolInfo[_stakingToken].rewarder = _rewarder; emit Set( _stakingToken, _allocPoint, IBaseRewardPool(tokenToPoolInfo[_stakingToken].rewarder) ); } /// @notice Update the emission rate of Penpie for MasterMagpie /// @param _penpiePerSec new emission per second function updateEmissionRate(uint256 _penpiePerSec) public onlyOwner { massUpdatePools(); uint256 oldEmissionRate = penpiePerSec; penpiePerSec = _penpiePerSec; emit UpdateEmissionRate(msg.sender, oldEmissionRate, penpiePerSec); } function updatePoolsAlloc( address[] calldata _stakingTokens, uint256[] calldata _allocPoints ) external _onlyWhiteListed { // massUpdatePools(); if (_stakingTokens.length != _allocPoints.length) revert LengthMismatch(); for (uint256 i = 0; i < _stakingTokens.length; i++) { uint256 oldAllocPoint = tokenToPoolInfo[_stakingTokens[i]] .allocPoint; totalAllocPoint = totalAllocPoint - oldAllocPoint + _allocPoints[i]; tokenToPoolInfo[_stakingTokens[i]].allocPoint = _allocPoints[i]; emit UpdatePoolAlloc( _stakingTokens[i], oldAllocPoint, _allocPoints[i] ); } } function updateWhitelistedAllocManager( address _account, bool _allowed ) external onlyOwner { AllocationManagers[_account] = _allowed; } function updateRewarderQueuer( address _rewarder, address _manager, bool _allowed ) external onlyOwner { IBaseRewardPool rewarder = IBaseRewardPool(_rewarder); rewarder.updateRewardQueuer(_manager, _allowed); } function setARBRewarder(address _ARBRewarder) external onlyOwner{ address oldARBRewarder = ARBRewarder; ARBRewarder = _ARBRewarder; emit ARBRewarderSet(oldARBRewarder, ARBRewarder); } function setARBRewarderAsQueuer(address[] calldata _pools) external onlyOwner { for(uint256 index = 0; index < _pools.length; index++){ address _stakingToken = _pools[index]; address rewarder = tokenToPoolInfo[_stakingToken].rewarder; if(rewarder != address(0)){ IBaseRewardPool(rewarder).updateRewardQueuer(ARBRewarder, true); emit ARBRewarderSetAsQueuer(rewarder); } } } }
// SPDX-License-Identifier: MIT 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 lzApp 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: MIT pragma solidity >=0.5.0; interface ILayerZeroReceiver { // @notice LayerZero endpoint will invoke this function to deliver the message on the destination // @param _srcChainId - the source endpoint identifier // @param _srcAddress - the source sending contract address from the source chain // @param _nonce - the ordered message nonce // @param _payload - the signed payload is the UA bytes has encoded to be sent function lzReceive(uint16 _srcChainId, bytes calldata _srcAddress, uint64 _nonce, bytes calldata _payload) external; }
// SPDX-License-Identifier: MIT 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 pragma solidity ^0.8.0; import "@openzeppelin/contracts/access/Ownable.sol"; import "../interfaces/ILayerZeroReceiver.sol"; import "../interfaces/ILayerZeroUserApplicationConfig.sol"; import "../interfaces/ILayerZeroEndpoint.sol"; import "../util/BytesLib.sol"; /* * a generic LzReceiver implementation */ abstract contract LzApp is Ownable, ILayerZeroReceiver, ILayerZeroUserApplicationConfig { using BytesLib for bytes; // ua can not send payload larger than this by default, but it can be changed by the ua owner uint constant public DEFAULT_PAYLOAD_SIZE_LIMIT = 10000; ILayerZeroEndpoint public immutable lzEndpoint; mapping(uint16 => bytes) public trustedRemoteLookup; mapping(uint16 => mapping(uint16 => uint)) public minDstGasLookup; mapping(uint16 => uint) public payloadSizeLimitLookup; address public precrime; event SetPrecrime(address precrime); event SetTrustedRemote(uint16 _remoteChainId, bytes _path); event SetTrustedRemoteAddress(uint16 _remoteChainId, bytes _remoteAddress); event SetMinDstGas(uint16 _dstChainId, uint16 _type, uint _minDstGas); constructor(address _endpoint) { lzEndpoint = ILayerZeroEndpoint(_endpoint); } function lzReceive(uint16 _srcChainId, bytes calldata _srcAddress, uint64 _nonce, bytes calldata _payload) public virtual override { // lzReceive must be called by the endpoint for security require(_msgSender() == address(lzEndpoint), "LzApp: invalid endpoint caller"); bytes memory trustedRemote = trustedRemoteLookup[_srcChainId]; // if will still block the message pathway from (srcChainId, srcAddress). should not receive message from untrusted remote. require(_srcAddress.length == trustedRemote.length && trustedRemote.length > 0 && keccak256(_srcAddress) == keccak256(trustedRemote), "LzApp: invalid source sending contract"); _blockingLzReceive(_srcChainId, _srcAddress, _nonce, _payload); } // abstract function - the default behaviour of LayerZero is blocking. See: NonblockingLzApp if you dont need to enforce ordered messaging function _blockingLzReceive(uint16 _srcChainId, bytes memory _srcAddress, uint64 _nonce, bytes memory _payload) internal virtual; function _lzSend(uint16 _dstChainId, bytes memory _payload, address payable _refundAddress, address _zroPaymentAddress, bytes memory _adapterParams, uint _nativeFee) internal virtual { bytes memory trustedRemote = trustedRemoteLookup[_dstChainId]; require(trustedRemote.length != 0, "LzApp: destination chain is not a trusted source"); _checkPayloadSize(_dstChainId, _payload.length); lzEndpoint.send{value: _nativeFee}(_dstChainId, trustedRemote, _payload, _refundAddress, _zroPaymentAddress, _adapterParams); } function _checkGasLimit(uint16 _dstChainId, uint16 _type, bytes memory _adapterParams, uint _extraGas) internal view virtual { uint providedGasLimit = _getGasLimit(_adapterParams); uint minGasLimit = minDstGasLookup[_dstChainId][_type] + _extraGas; require(minGasLimit > 0, "LzApp: minGasLimit not set"); require(providedGasLimit >= minGasLimit, "LzApp: gas limit is too low"); } function _getGasLimit(bytes memory _adapterParams) internal pure virtual returns (uint gasLimit) { require(_adapterParams.length >= 34, "LzApp: invalid adapterParams"); assembly { gasLimit := mload(add(_adapterParams, 34)) } } function _checkPayloadSize(uint16 _dstChainId, uint _payloadSize) internal view virtual { uint payloadSizeLimit = payloadSizeLimitLookup[_dstChainId]; if (payloadSizeLimit == 0) { // use default if not set payloadSizeLimit = DEFAULT_PAYLOAD_SIZE_LIMIT; } require(_payloadSize <= payloadSizeLimit, "LzApp: payload size is too large"); } //---------------------------UserApplication config---------------------------------------- function getConfig(uint16 _version, uint16 _chainId, address, uint _configType) external view returns (bytes memory) { return lzEndpoint.getConfig(_version, _chainId, address(this), _configType); } // generic config for LayerZero user Application function setConfig(uint16 _version, uint16 _chainId, uint _configType, bytes calldata _config) external override onlyOwner { lzEndpoint.setConfig(_version, _chainId, _configType, _config); } function setSendVersion(uint16 _version) external override onlyOwner { lzEndpoint.setSendVersion(_version); } function setReceiveVersion(uint16 _version) external override onlyOwner { lzEndpoint.setReceiveVersion(_version); } function forceResumeReceive(uint16 _srcChainId, bytes calldata _srcAddress) external override onlyOwner { lzEndpoint.forceResumeReceive(_srcChainId, _srcAddress); } // _path = abi.encodePacked(remoteAddress, localAddress) // this function set the trusted path for the cross-chain communication function setTrustedRemote(uint16 _srcChainId, bytes calldata _path) external onlyOwner { trustedRemoteLookup[_srcChainId] = _path; emit SetTrustedRemote(_srcChainId, _path); } function setTrustedRemoteAddress(uint16 _remoteChainId, bytes calldata _remoteAddress) external onlyOwner { trustedRemoteLookup[_remoteChainId] = abi.encodePacked(_remoteAddress, address(this)); emit SetTrustedRemoteAddress(_remoteChainId, _remoteAddress); } function getTrustedRemoteAddress(uint16 _remoteChainId) external view returns (bytes memory) { bytes memory path = trustedRemoteLookup[_remoteChainId]; require(path.length != 0, "LzApp: no trusted path record"); return path.slice(0, path.length - 20); // the last 20 bytes should be address(this) } function setPrecrime(address _precrime) external onlyOwner { precrime = _precrime; emit SetPrecrime(_precrime); } function setMinDstGas(uint16 _dstChainId, uint16 _packetType, uint _minGas) external onlyOwner { require(_minGas > 0, "LzApp: invalid minGas"); minDstGasLookup[_dstChainId][_packetType] = _minGas; emit SetMinDstGas(_dstChainId, _packetType, _minGas); } // if the size is 0, it means default size limit function setPayloadSizeLimit(uint16 _dstChainId, uint _size) external onlyOwner { payloadSizeLimitLookup[_dstChainId] = _size; } //--------------------------- VIEW FUNCTION ---------------------------------------- function isTrustedRemote(uint16 _srcChainId, bytes calldata _srcAddress) external view returns (bool) { bytes memory trustedSource = trustedRemoteLookup[_srcChainId]; return keccak256(trustedSource) == keccak256(_srcAddress); } }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "./LzApp.sol"; import "../util/ExcessivelySafeCall.sol"; /* * the default LayerZero messaging behaviour is blocking, i.e. any failed message will block the channel * this abstract class try-catch all fail messages and store locally for future retry. hence, non-blocking * NOTE: if the srcAddress is not configured properly, it will still block the message pathway from (srcChainId, srcAddress) */ abstract contract NonblockingLzApp is LzApp { using ExcessivelySafeCall for address; constructor(address _endpoint) LzApp(_endpoint) {} mapping(uint16 => mapping(bytes => mapping(uint64 => bytes32))) public failedMessages; event MessageFailed(uint16 _srcChainId, bytes _srcAddress, uint64 _nonce, bytes _payload, bytes _reason); event RetryMessageSuccess(uint16 _srcChainId, bytes _srcAddress, uint64 _nonce, bytes32 _payloadHash); // overriding the virtual function in LzReceiver function _blockingLzReceive(uint16 _srcChainId, bytes memory _srcAddress, uint64 _nonce, bytes memory _payload) internal virtual override { (bool success, bytes memory reason) = address(this).excessivelySafeCall(gasleft(), 150, abi.encodeWithSelector(this.nonblockingLzReceive.selector, _srcChainId, _srcAddress, _nonce, _payload)); // try-catch all errors/exceptions if (!success) { _storeFailedMessage(_srcChainId, _srcAddress, _nonce, _payload, reason); } } function _storeFailedMessage(uint16 _srcChainId, bytes memory _srcAddress, uint64 _nonce, bytes memory _payload, bytes memory _reason) internal virtual { failedMessages[_srcChainId][_srcAddress][_nonce] = keccak256(_payload); emit MessageFailed(_srcChainId, _srcAddress, _nonce, _payload, _reason); } function nonblockingLzReceive(uint16 _srcChainId, bytes calldata _srcAddress, uint64 _nonce, bytes calldata _payload) public virtual { // only internal transaction require(_msgSender() == address(this), "NonblockingLzApp: caller must be LzApp"); _nonblockingLzReceive(_srcChainId, _srcAddress, _nonce, _payload); } //@notice override this function function _nonblockingLzReceive(uint16 _srcChainId, bytes memory _srcAddress, uint64 _nonce, bytes memory _payload) internal virtual; function retryMessage(uint16 _srcChainId, bytes calldata _srcAddress, uint64 _nonce, bytes calldata _payload) public payable virtual { // assert there is message to retry bytes32 payloadHash = failedMessages[_srcChainId][_srcAddress][_nonce]; require(payloadHash != bytes32(0), "NonblockingLzApp: no stored message"); require(keccak256(_payload) == payloadHash, "NonblockingLzApp: invalid payload"); // clear the stored message failedMessages[_srcChainId][_srcAddress][_nonce] = bytes32(0); // execute the message. revert if it fails again _nonblockingLzReceive(_srcChainId, _srcAddress, _nonce, _payload); emit RetryMessageSuccess(_srcChainId, _srcAddress, _nonce, payloadHash); } }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "./OFTCoreV2.sol"; import "./IOFTV2.sol"; import "@openzeppelin/contracts/utils/introspection/ERC165.sol"; abstract contract BaseOFTV2 is OFTCoreV2, ERC165, IOFTV2 { constructor(uint8 _sharedDecimals, address _lzEndpoint) OFTCoreV2(_sharedDecimals, _lzEndpoint) { } /************************************************************************ * public functions ************************************************************************/ function sendFrom(address _from, uint16 _dstChainId, bytes32 _toAddress, uint _amount, LzCallParams calldata _callParams) public payable virtual override { _send(_from, _dstChainId, _toAddress, _amount, _callParams.refundAddress, _callParams.zroPaymentAddress, _callParams.adapterParams); } function sendAndCall(address _from, uint16 _dstChainId, bytes32 _toAddress, uint _amount, bytes calldata _payload, uint64 _dstGasForCall, LzCallParams calldata _callParams) public payable virtual override { _sendAndCall(_from, _dstChainId, _toAddress, _amount, _payload, _dstGasForCall, _callParams.refundAddress, _callParams.zroPaymentAddress, _callParams.adapterParams); } /************************************************************************ * public view functions ************************************************************************/ function supportsInterface(bytes4 interfaceId) public view virtual override(ERC165, IERC165) returns (bool) { return interfaceId == type(IOFTV2).interfaceId || super.supportsInterface(interfaceId); } function estimateSendFee(uint16 _dstChainId, bytes32 _toAddress, uint _amount, bool _useZro, bytes calldata _adapterParams) public view virtual override returns (uint nativeFee, uint zroFee) { return _estimateSendFee(_dstChainId, _toAddress, _amount, _useZro, _adapterParams); } function estimateSendAndCallFee(uint16 _dstChainId, bytes32 _toAddress, uint _amount, bytes calldata _payload, uint64 _dstGasForCall, bool _useZro, bytes calldata _adapterParams) public view virtual override returns (uint nativeFee, uint zroFee) { return _estimateSendAndCallFee(_dstChainId, _toAddress, _amount, _payload, _dstGasForCall, _useZro, _adapterParams); } function circulatingSupply() public view virtual override returns (uint); function token() public view virtual override returns (address); }
// SPDX-License-Identifier: MIT pragma solidity >=0.5.0; import "@openzeppelin/contracts/utils/introspection/IERC165.sol"; /** * @dev Interface of the IOFT core standard */ interface ICommonOFT is IERC165 { struct LzCallParams { address payable refundAddress; address zroPaymentAddress; bytes adapterParams; } /** * @dev estimate send token `_tokenId` to (`_dstChainId`, `_toAddress`) * _dstChainId - L0 defined chain id to send tokens too * _toAddress - dynamic bytes array which contains the address to whom you are sending tokens to on the dstChain * _amount - amount of the tokens to transfer * _useZro - indicates to use zro to pay L0 fees * _adapterParam - flexible bytes array to indicate messaging adapter services in L0 */ function estimateSendFee(uint16 _dstChainId, bytes32 _toAddress, uint _amount, bool _useZro, bytes calldata _adapterParams) external view returns (uint nativeFee, uint zroFee); function estimateSendAndCallFee(uint16 _dstChainId, bytes32 _toAddress, uint _amount, bytes calldata _payload, uint64 _dstGasForCall, bool _useZro, bytes calldata _adapterParams) external view returns (uint nativeFee, uint zroFee); /** * @dev returns the circulating amount of tokens on current chain */ function circulatingSupply() external view returns (uint); /** * @dev returns the address of the ERC20 token */ function token() external view returns (address); }
// SPDX-License-Identifier: BUSL-1.1 pragma solidity >=0.5.0; interface IOFTReceiverV2 { /** * @dev Called by the OFT contract when tokens are received from source chain. * @param _srcChainId The chain id of the source chain. * @param _srcAddress The address of the OFT token contract on the source chain. * @param _nonce The nonce of the transaction on the source chain. * @param _from The address of the account who calls the sendAndCall() on the source chain. * @param _amount The amount of tokens to transfer. * @param _payload Additional data with no specified format. */ function onOFTReceived(uint16 _srcChainId, bytes calldata _srcAddress, uint64 _nonce, bytes32 _from, uint _amount, bytes calldata _payload) external; }
// SPDX-License-Identifier: MIT pragma solidity >=0.5.0; import "./ICommonOFT.sol"; /** * @dev Interface of the IOFT core standard */ interface IOFTV2 is ICommonOFT { /** * @dev send `_amount` amount of token to (`_dstChainId`, `_toAddress`) from `_from` * `_from` the owner of token * `_dstChainId` the destination chain identifier * `_toAddress` can be any size depending on the `dstChainId`. * `_amount` the quantity of tokens in wei * `_refundAddress` the address LayerZero refunds if too much message fee is sent * `_zroPaymentAddress` set to address(0x0) if not paying in ZRO (LayerZero Token) * `_adapterParams` is a flexible bytes array to indicate messaging adapter services */ function sendFrom(address _from, uint16 _dstChainId, bytes32 _toAddress, uint _amount, LzCallParams calldata _callParams) external payable; function sendAndCall(address _from, uint16 _dstChainId, bytes32 _toAddress, uint _amount, bytes calldata _payload, uint64 _dstGasForCall, LzCallParams calldata _callParams) external payable; }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "../../../lzApp/NonblockingLzApp.sol"; import "../../../util/ExcessivelySafeCall.sol"; import "./ICommonOFT.sol"; import "./IOFTReceiverV2.sol"; abstract contract OFTCoreV2 is NonblockingLzApp { using BytesLib for bytes; using ExcessivelySafeCall for address; uint public constant NO_EXTRA_GAS = 0; // packet type uint8 public constant PT_SEND = 0; uint8 public constant PT_SEND_AND_CALL = 1; uint8 public immutable sharedDecimals; bool public useCustomAdapterParams; mapping(uint16 => mapping(bytes => mapping(uint64 => bool))) public creditedPackets; /** * @dev Emitted when `_amount` tokens are moved from the `_sender` to (`_dstChainId`, `_toAddress`) * `_nonce` is the outbound nonce */ event SendToChain(uint16 indexed _dstChainId, address indexed _from, bytes32 indexed _toAddress, uint _amount); /** * @dev Emitted when `_amount` tokens are received from `_srcChainId` into the `_toAddress` on the local chain. * `_nonce` is the inbound nonce. */ event ReceiveFromChain(uint16 indexed _srcChainId, address indexed _to, uint _amount); event SetUseCustomAdapterParams(bool _useCustomAdapterParams); event CallOFTReceivedSuccess(uint16 indexed _srcChainId, bytes _srcAddress, uint64 _nonce, bytes32 _hash); event NonContractAddress(address _address); // _sharedDecimals should be the minimum decimals on all chains constructor(uint8 _sharedDecimals, address _lzEndpoint) NonblockingLzApp(_lzEndpoint) { sharedDecimals = _sharedDecimals; } /************************************************************************ * public functions ************************************************************************/ function callOnOFTReceived(uint16 _srcChainId, bytes calldata _srcAddress, uint64 _nonce, bytes32 _from, address _to, uint _amount, bytes calldata _payload, uint _gasForCall) public virtual { require(_msgSender() == address(this), "OFTCore: caller must be OFTCore"); // send _amount = _transferFrom(address(this), _to, _amount); emit ReceiveFromChain(_srcChainId, _to, _amount); // call IOFTReceiverV2(_to).onOFTReceived{gas: _gasForCall}(_srcChainId, _srcAddress, _nonce, _from, _amount, _payload); } function setUseCustomAdapterParams(bool _useCustomAdapterParams) public virtual onlyOwner { useCustomAdapterParams = _useCustomAdapterParams; emit SetUseCustomAdapterParams(_useCustomAdapterParams); } /************************************************************************ * internal functions ************************************************************************/ function _estimateSendFee(uint16 _dstChainId, bytes32 _toAddress, uint _amount, bool _useZro, bytes memory _adapterParams) internal view virtual returns (uint nativeFee, uint zroFee) { // mock the payload for sendFrom() bytes memory payload = _encodeSendPayload(_toAddress, _ld2sd(_amount)); return lzEndpoint.estimateFees(_dstChainId, address(this), payload, _useZro, _adapterParams); } function _estimateSendAndCallFee(uint16 _dstChainId, bytes32 _toAddress, uint _amount, bytes memory _payload, uint64 _dstGasForCall, bool _useZro, bytes memory _adapterParams) internal view virtual returns (uint nativeFee, uint zroFee) { // mock the payload for sendAndCall() bytes memory payload = _encodeSendAndCallPayload(msg.sender, _toAddress, _ld2sd(_amount), _payload, _dstGasForCall); return lzEndpoint.estimateFees(_dstChainId, address(this), payload, _useZro, _adapterParams); } function _nonblockingLzReceive(uint16 _srcChainId, bytes memory _srcAddress, uint64 _nonce, bytes memory _payload) internal virtual override { uint8 packetType = _payload.toUint8(0); if (packetType == PT_SEND) { _sendAck(_srcChainId, _srcAddress, _nonce, _payload); } else if (packetType == PT_SEND_AND_CALL) { _sendAndCallAck(_srcChainId, _srcAddress, _nonce, _payload); } else { revert("OFTCore: unknown packet type"); } } function _send(address _from, uint16 _dstChainId, bytes32 _toAddress, uint _amount, address payable _refundAddress, address _zroPaymentAddress, bytes memory _adapterParams) internal virtual returns (uint amount) { _checkAdapterParams(_dstChainId, PT_SEND, _adapterParams, NO_EXTRA_GAS); (amount,) = _removeDust(_amount); amount = _debitFrom(_from, _dstChainId, _toAddress, amount); // amount returned should not have dust require(amount > 0, "OFTCore: amount too small"); bytes memory lzPayload = _encodeSendPayload(_toAddress, _ld2sd(amount)); _lzSend(_dstChainId, lzPayload, _refundAddress, _zroPaymentAddress, _adapterParams, msg.value); emit SendToChain(_dstChainId, _from, _toAddress, amount); } function _sendAck(uint16 _srcChainId, bytes memory, uint64, bytes memory _payload) internal virtual { (address to, uint64 amountSD) = _decodeSendPayload(_payload); if (to == address(0)) { to = address(0xdead); } uint amount = _sd2ld(amountSD); amount = _creditTo(_srcChainId, to, amount); emit ReceiveFromChain(_srcChainId, to, amount); } function _sendAndCall(address _from, uint16 _dstChainId, bytes32 _toAddress, uint _amount, bytes memory _payload, uint64 _dstGasForCall, address payable _refundAddress, address _zroPaymentAddress, bytes memory _adapterParams) internal virtual returns (uint amount) { _checkAdapterParams(_dstChainId, PT_SEND_AND_CALL, _adapterParams, _dstGasForCall); (amount,) = _removeDust(_amount); amount = _debitFrom(_from, _dstChainId, _toAddress, amount); require(amount > 0, "OFTCore: amount too small"); // encode the msg.sender into the payload instead of _from bytes memory lzPayload = _encodeSendAndCallPayload(msg.sender, _toAddress, _ld2sd(amount), _payload, _dstGasForCall); _lzSend(_dstChainId, lzPayload, _refundAddress, _zroPaymentAddress, _adapterParams, msg.value); emit SendToChain(_dstChainId, _from, _toAddress, amount); } function _sendAndCallAck(uint16 _srcChainId, bytes memory _srcAddress, uint64 _nonce, bytes memory _payload) internal virtual { (bytes32 from, address to, uint64 amountSD, bytes memory payloadForCall, uint64 gasForCall) = _decodeSendAndCallPayload(_payload); bool credited = creditedPackets[_srcChainId][_srcAddress][_nonce]; uint amount = _sd2ld(amountSD); // credit to this contract first, and then transfer to receiver only if callOnOFTReceived() succeeds if (!credited) { amount = _creditTo(_srcChainId, address(this), amount); creditedPackets[_srcChainId][_srcAddress][_nonce] = true; } if (!_isContract(to)) { emit NonContractAddress(to); return; } // workaround for stack too deep uint16 srcChainId = _srcChainId; bytes memory srcAddress = _srcAddress; uint64 nonce = _nonce; bytes memory payload = _payload; bytes32 from_ = from; address to_ = to; uint amount_ = amount; bytes memory payloadForCall_ = payloadForCall; // no gas limit for the call if retry uint gas = credited ? gasleft() : gasForCall; (bool success, bytes memory reason) = address(this).excessivelySafeCall(gasleft(), 150, abi.encodeWithSelector(this.callOnOFTReceived.selector, srcChainId, srcAddress, nonce, from_, to_, amount_, payloadForCall_, gas)); if (success) { bytes32 hash = keccak256(payload); emit CallOFTReceivedSuccess(srcChainId, srcAddress, nonce, hash); } else { // store the failed message into the nonblockingLzApp _storeFailedMessage(srcChainId, srcAddress, nonce, payload, reason); } } function _isContract(address _account) internal view returns (bool) { return _account.code.length > 0; } function _checkAdapterParams(uint16 _dstChainId, uint16 _pkType, bytes memory _adapterParams, uint _extraGas) internal virtual { if (useCustomAdapterParams) { _checkGasLimit(_dstChainId, _pkType, _adapterParams, _extraGas); } else { require(_adapterParams.length == 0, "OFTCore: _adapterParams must be empty."); } } function _ld2sd(uint _amount) internal virtual view returns (uint64) { uint amountSD = _amount / _ld2sdRate(); require(amountSD <= type(uint64).max, "OFTCore: amountSD overflow"); return uint64(amountSD); } function _sd2ld(uint64 _amountSD) internal virtual view returns (uint) { return _amountSD * _ld2sdRate(); } function _removeDust(uint _amount) internal virtual view returns (uint amountAfter, uint dust) { dust = _amount % _ld2sdRate(); amountAfter = _amount - dust; } function _encodeSendPayload(bytes32 _toAddress, uint64 _amountSD) internal virtual view returns (bytes memory) { return abi.encodePacked(PT_SEND, _toAddress, _amountSD); } function _decodeSendPayload(bytes memory _payload) internal virtual view returns (address to, uint64 amountSD) { require(_payload.toUint8(0) == PT_SEND && _payload.length == 41, "OFTCore: invalid payload"); to = _payload.toAddress(13); // drop the first 12 bytes of bytes32 amountSD = _payload.toUint64(33); } function _encodeSendAndCallPayload(address _from, bytes32 _toAddress, uint64 _amountSD, bytes memory _payload, uint64 _dstGasForCall) internal virtual view returns (bytes memory) { return abi.encodePacked( PT_SEND_AND_CALL, _toAddress, _amountSD, _addressToBytes32(_from), _dstGasForCall, _payload ); } function _decodeSendAndCallPayload(bytes memory _payload) internal virtual view returns (bytes32 from, address to, uint64 amountSD, bytes memory payload, uint64 dstGasForCall) { require(_payload.toUint8(0) == PT_SEND_AND_CALL, "OFTCore: invalid payload"); to = _payload.toAddress(13); // drop the first 12 bytes of bytes32 amountSD = _payload.toUint64(33); from = _payload.toBytes32(41); dstGasForCall = _payload.toUint64(73); payload = _payload.slice(81, _payload.length - 81); } function _addressToBytes32(address _address) internal pure virtual returns (bytes32) { return bytes32(uint(uint160(_address))); } function _debitFrom(address _from, uint16 _dstChainId, bytes32 _toAddress, uint _amount) internal virtual returns (uint); function _creditTo(uint16 _srcChainId, address _toAddress, uint _amount) internal virtual returns (uint); function _transferFrom(address _from, address _to, uint _amount) internal virtual returns (uint); function _ld2sdRate() internal view virtual returns (uint); }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "@openzeppelin/contracts/token/ERC20/ERC20.sol"; import "./BaseOFTV2.sol"; contract OFTV2 is BaseOFTV2, ERC20 { uint internal immutable ld2sdRate; constructor(string memory _name, string memory _symbol, uint8 _sharedDecimals, address _lzEndpoint) ERC20(_name, _symbol) BaseOFTV2(_sharedDecimals, _lzEndpoint) { uint8 decimals = decimals(); require(_sharedDecimals <= decimals, "OFT: sharedDecimals must be <= decimals"); ld2sdRate = 10 ** (decimals - _sharedDecimals); } /************************************************************************ * public functions ************************************************************************/ function circulatingSupply() public view virtual override returns (uint) { return totalSupply(); } function token() public view virtual override returns (address) { return address(this); } /************************************************************************ * internal functions ************************************************************************/ function _debitFrom(address _from, uint16, bytes32, uint _amount) internal virtual override returns (uint) { address spender = _msgSender(); if (_from != spender) _spendAllowance(_from, spender, _amount); _burn(_from, _amount); return _amount; } function _creditTo(uint16, address _toAddress, uint _amount) internal virtual override returns (uint) { _mint(_toAddress, _amount); return _amount; } function _transferFrom(address _from, address _to, uint _amount) internal virtual override returns (uint) { address spender = _msgSender(); // if transfer from this contract, no need to check allowance if (_from != address(this) && _from != spender) _spendAllowance(_from, spender, _amount); _transfer(_from, _to, _amount); return _amount; } function _ld2sdRate() internal view virtual override returns (uint) { return ld2sdRate; } }
// SPDX-License-Identifier: Unlicense /* * @title Solidity Bytes Arrays Utils * @author Gonçalo Sá <[email protected]> * * @dev Bytes tightly packed arrays utility library for ethereum contracts written in Solidity. * The library lets you concatenate, slice and type cast bytes arrays both in memory and storage. */ pragma solidity >=0.8.0 <0.9.0; library BytesLib { function concat( bytes memory _preBytes, bytes memory _postBytes ) internal pure returns (bytes memory) { bytes memory tempBytes; assembly { // Get a location of some free memory and store it in tempBytes as // Solidity does for memory variables. tempBytes := mload(0x40) // Store the length of the first bytes array at the beginning of // the memory for tempBytes. let length := mload(_preBytes) mstore(tempBytes, length) // Maintain a memory counter for the current write location in the // temp bytes array by adding the 32 bytes for the array length to // the starting location. let mc := add(tempBytes, 0x20) // Stop copying when the memory counter reaches the length of the // first bytes array. let end := add(mc, length) for { // Initialize a copy counter to the start of the _preBytes data, // 32 bytes into its memory. let cc := add(_preBytes, 0x20) } lt(mc, end) { // Increase both counters by 32 bytes each iteration. mc := add(mc, 0x20) cc := add(cc, 0x20) } { // Write the _preBytes data into the tempBytes memory 32 bytes // at a time. mstore(mc, mload(cc)) } // Add the length of _postBytes to the current length of tempBytes // and store it as the new length in the first 32 bytes of the // tempBytes memory. length := mload(_postBytes) mstore(tempBytes, add(length, mload(tempBytes))) // Move the memory counter back from a multiple of 0x20 to the // actual end of the _preBytes data. mc := end // Stop copying when the memory counter reaches the new combined // length of the arrays. end := add(mc, length) for { let cc := add(_postBytes, 0x20) } lt(mc, end) { mc := add(mc, 0x20) cc := add(cc, 0x20) } { mstore(mc, mload(cc)) } // Update the free-memory pointer by padding our last write location // to 32 bytes: add 31 bytes to the end of tempBytes to move to the // next 32 byte block, then round down to the nearest multiple of // 32. If the sum of the length of the two arrays is zero then add // one before rounding down to leave a blank 32 bytes (the length block with 0). mstore(0x40, and( add(add(end, iszero(add(length, mload(_preBytes)))), 31), not(31) // Round down to the nearest 32 bytes. )) } return tempBytes; } function concatStorage(bytes storage _preBytes, bytes memory _postBytes) internal { assembly { // Read the first 32 bytes of _preBytes storage, which is the length // of the array. (We don't need to use the offset into the slot // because arrays use the entire slot.) let fslot := sload(_preBytes.slot) // Arrays of 31 bytes or less have an even value in their slot, // while longer arrays have an odd value. The actual length is // the slot divided by two for odd values, and the lowest order // byte divided by two for even values. // If the slot is even, bitwise and the slot with 255 and divide by // two to get the length. If the slot is odd, bitwise and the slot // with -1 and divide by two. let slength := div(and(fslot, sub(mul(0x100, iszero(and(fslot, 1))), 1)), 2) let mlength := mload(_postBytes) let newlength := add(slength, mlength) // slength can contain both the length and contents of the array // if length < 32 bytes so let's prepare for that // v. http://solidity.readthedocs.io/en/latest/miscellaneous.html#layout-of-state-variables-in-storage switch add(lt(slength, 32), lt(newlength, 32)) case 2 { // Since the new array still fits in the slot, we just need to // update the contents of the slot. // uint256(bytes_storage) = uint256(bytes_storage) + uint256(bytes_memory) + new_length sstore( _preBytes.slot, // all the modifications to the slot are inside this // next block add( // we can just add to the slot contents because the // bytes we want to change are the LSBs fslot, add( mul( div( // load the bytes from memory mload(add(_postBytes, 0x20)), // zero all bytes to the right exp(0x100, sub(32, mlength)) ), // and now shift left the number of bytes to // leave space for the length in the slot exp(0x100, sub(32, newlength)) ), // increase length by the double of the memory // bytes length mul(mlength, 2) ) ) ) } case 1 { // The stored value fits in the slot, but the combined value // will exceed it. // get the keccak hash to get the contents of the array mstore(0x0, _preBytes.slot) let sc := add(keccak256(0x0, 0x20), div(slength, 32)) // save new length sstore(_preBytes.slot, add(mul(newlength, 2), 1)) // The contents of the _postBytes array start 32 bytes into // the structure. Our first read should obtain the `submod` // bytes that can fit into the unused space in the last word // of the stored array. To get this, we read 32 bytes starting // from `submod`, so the data we read overlaps with the array // contents by `submod` bytes. Masking the lowest-order // `submod` bytes allows us to add that value directly to the // stored value. let submod := sub(32, slength) let mc := add(_postBytes, submod) let end := add(_postBytes, mlength) let mask := sub(exp(0x100, submod), 1) sstore( sc, add( and( fslot, 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00 ), and(mload(mc), mask) ) ) for { mc := add(mc, 0x20) sc := add(sc, 1) } lt(mc, end) { sc := add(sc, 1) mc := add(mc, 0x20) } { sstore(sc, mload(mc)) } mask := exp(0x100, sub(mc, end)) sstore(sc, mul(div(mload(mc), mask), mask)) } default { // get the keccak hash to get the contents of the array mstore(0x0, _preBytes.slot) // Start copying to the last used word of the stored array. let sc := add(keccak256(0x0, 0x20), div(slength, 32)) // save new length sstore(_preBytes.slot, add(mul(newlength, 2), 1)) // Copy over the first `submod` bytes of the new data as in // case 1 above. let slengthmod := mod(slength, 32) let mlengthmod := mod(mlength, 32) let submod := sub(32, slengthmod) let mc := add(_postBytes, submod) let end := add(_postBytes, mlength) let mask := sub(exp(0x100, submod), 1) sstore(sc, add(sload(sc), and(mload(mc), mask))) for { sc := add(sc, 1) mc := add(mc, 0x20) } lt(mc, end) { sc := add(sc, 1) mc := add(mc, 0x20) } { sstore(sc, mload(mc)) } mask := exp(0x100, sub(mc, end)) sstore(sc, mul(div(mload(mc), mask), mask)) } } } function slice( bytes memory _bytes, uint256 _start, uint256 _length ) internal pure returns (bytes memory) { require(_length + 31 >= _length, "slice_overflow"); require(_bytes.length >= _start + _length, "slice_outOfBounds"); bytes memory tempBytes; assembly { switch iszero(_length) case 0 { // Get a location of some free memory and store it in tempBytes as // Solidity does for memory variables. tempBytes := mload(0x40) // The first word of the slice result is potentially a partial // word read from the original array. To read it, we calculate // the length of that partial word and start copying that many // bytes into the array. The first word we copy will start with // data we don't care about, but the last `lengthmod` bytes will // land at the beginning of the contents of the new array. When // we're done copying, we overwrite the full first word with // the actual length of the slice. let lengthmod := and(_length, 31) // The multiplication in the next line is necessary // because when slicing multiples of 32 bytes (lengthmod == 0) // the following copy loop was copying the origin's length // and then ending prematurely not copying everything it should. let mc := add(add(tempBytes, lengthmod), mul(0x20, iszero(lengthmod))) let end := add(mc, _length) for { // The multiplication in the next line has the same exact purpose // as the one above. let cc := add(add(add(_bytes, lengthmod), mul(0x20, iszero(lengthmod))), _start) } lt(mc, end) { mc := add(mc, 0x20) cc := add(cc, 0x20) } { mstore(mc, mload(cc)) } mstore(tempBytes, _length) //update free-memory pointer //allocating the array padded to 32 bytes like the compiler does now mstore(0x40, and(add(mc, 31), not(31))) } //if we want a zero-length slice let's just return a zero-length array default { tempBytes := mload(0x40) //zero out the 32 bytes slice we are about to return //we need to do it because Solidity does not garbage collect mstore(tempBytes, 0) mstore(0x40, add(tempBytes, 0x20)) } } return tempBytes; } function toAddress(bytes memory _bytes, uint256 _start) internal pure returns (address) { require(_bytes.length >= _start + 20, "toAddress_outOfBounds"); address tempAddress; assembly { tempAddress := div(mload(add(add(_bytes, 0x20), _start)), 0x1000000000000000000000000) } return tempAddress; } function toUint8(bytes memory _bytes, uint256 _start) internal pure returns (uint8) { require(_bytes.length >= _start + 1 , "toUint8_outOfBounds"); uint8 tempUint; assembly { tempUint := mload(add(add(_bytes, 0x1), _start)) } return tempUint; } function toUint16(bytes memory _bytes, uint256 _start) internal pure returns (uint16) { require(_bytes.length >= _start + 2, "toUint16_outOfBounds"); uint16 tempUint; assembly { tempUint := mload(add(add(_bytes, 0x2), _start)) } return tempUint; } function toUint32(bytes memory _bytes, uint256 _start) internal pure returns (uint32) { require(_bytes.length >= _start + 4, "toUint32_outOfBounds"); uint32 tempUint; assembly { tempUint := mload(add(add(_bytes, 0x4), _start)) } return tempUint; } function toUint64(bytes memory _bytes, uint256 _start) internal pure returns (uint64) { require(_bytes.length >= _start + 8, "toUint64_outOfBounds"); uint64 tempUint; assembly { tempUint := mload(add(add(_bytes, 0x8), _start)) } return tempUint; } function toUint96(bytes memory _bytes, uint256 _start) internal pure returns (uint96) { require(_bytes.length >= _start + 12, "toUint96_outOfBounds"); uint96 tempUint; assembly { tempUint := mload(add(add(_bytes, 0xc), _start)) } return tempUint; } function toUint128(bytes memory _bytes, uint256 _start) internal pure returns (uint128) { require(_bytes.length >= _start + 16, "toUint128_outOfBounds"); uint128 tempUint; assembly { tempUint := mload(add(add(_bytes, 0x10), _start)) } return tempUint; } function toUint256(bytes memory _bytes, uint256 _start) internal pure returns (uint256) { require(_bytes.length >= _start + 32, "toUint256_outOfBounds"); uint256 tempUint; assembly { tempUint := mload(add(add(_bytes, 0x20), _start)) } return tempUint; } function toBytes32(bytes memory _bytes, uint256 _start) internal pure returns (bytes32) { require(_bytes.length >= _start + 32, "toBytes32_outOfBounds"); bytes32 tempBytes32; assembly { tempBytes32 := mload(add(add(_bytes, 0x20), _start)) } return tempBytes32; } function equal(bytes memory _preBytes, bytes memory _postBytes) internal pure returns (bool) { bool success = true; assembly { let length := mload(_preBytes) // if lengths don't match the arrays are not equal switch eq(length, mload(_postBytes)) case 1 { // cb is a circuit breaker in the for loop since there's // no said feature for inline assembly loops // cb = 1 - don't breaker // cb = 0 - break let cb := 1 let mc := add(_preBytes, 0x20) let end := add(mc, length) for { let cc := add(_postBytes, 0x20) // the next line is the loop condition: // while(uint256(mc < end) + cb == 2) } eq(add(lt(mc, end), cb), 2) { mc := add(mc, 0x20) cc := add(cc, 0x20) } { // if any of these checks fails then arrays are not equal if iszero(eq(mload(mc), mload(cc))) { // unsuccess: success := 0 cb := 0 } } } default { // unsuccess: success := 0 } } return success; } function equalStorage( bytes storage _preBytes, bytes memory _postBytes ) internal view returns (bool) { bool success = true; assembly { // we know _preBytes_offset is 0 let fslot := sload(_preBytes.slot) // Decode the length of the stored array like in concatStorage(). let slength := div(and(fslot, sub(mul(0x100, iszero(and(fslot, 1))), 1)), 2) let mlength := mload(_postBytes) // if lengths don't match the arrays are not equal switch eq(slength, mlength) case 1 { // slength can contain both the length and contents of the array // if length < 32 bytes so let's prepare for that // v. http://solidity.readthedocs.io/en/latest/miscellaneous.html#layout-of-state-variables-in-storage if iszero(iszero(slength)) { switch lt(slength, 32) case 1 { // blank the last byte which is the length fslot := mul(div(fslot, 0x100), 0x100) if iszero(eq(fslot, mload(add(_postBytes, 0x20)))) { // unsuccess: success := 0 } } default { // cb is a circuit breaker in the for loop since there's // no said feature for inline assembly loops // cb = 1 - don't breaker // cb = 0 - break let cb := 1 // get the keccak hash to get the contents of the array mstore(0x0, _preBytes.slot) let sc := keccak256(0x0, 0x20) let mc := add(_postBytes, 0x20) let end := add(mc, mlength) // the next line is the loop condition: // while(uint256(mc < end) + cb == 2) for {} eq(add(lt(mc, end), cb), 2) { sc := add(sc, 1) mc := add(mc, 0x20) } { if iszero(eq(sload(sc), mload(mc))) { // unsuccess: success := 0 cb := 0 } } } } } default { // unsuccess: success := 0 } } return success; } }
// SPDX-License-Identifier: MIT OR Apache-2.0 pragma solidity >=0.7.6; library ExcessivelySafeCall { uint256 constant LOW_28_MASK = 0x00000000ffffffffffffffffffffffffffffffffffffffffffffffffffffffff; /// @notice Use when you _really_ really _really_ don't trust the called /// contract. This prevents the called contract from causing reversion of /// the caller in as many ways as we can. /// @dev The main difference between this and a solidity low-level call is /// that we limit the number of bytes that the callee can cause to be /// copied to caller memory. This prevents stupid things like malicious /// contracts returning 10,000,000 bytes causing a local OOG when copying /// to memory. /// @param _target The address to call /// @param _gas The amount of gas to forward to the remote contract /// @param _maxCopy The maximum number of bytes of returndata to copy /// to memory. /// @param _calldata The data to send to the remote contract /// @return success and returndata, as `.call()`. Returndata is capped to /// `_maxCopy` bytes. function excessivelySafeCall( address _target, uint256 _gas, uint16 _maxCopy, bytes memory _calldata ) internal returns (bool, bytes memory) { // set up for assembly call uint256 _toCopy; bool _success; bytes memory _returnData = new bytes(_maxCopy); // dispatch message to recipient // by assembly calling "handle" function // we call via assembly to avoid memcopying a very large returndata // returned by a malicious contract assembly { _success := call( _gas, // gas _target, // recipient 0, // ether value add(_calldata, 0x20), // inloc mload(_calldata), // inlen 0, // outloc 0 // outlen ) // limit our copy to 256 bytes _toCopy := returndatasize() if gt(_toCopy, _maxCopy) { _toCopy := _maxCopy } // Store the length of the copied bytes mstore(_returnData, _toCopy) // copy the bytes from returndata[0:_toCopy] returndatacopy(add(_returnData, 0x20), 0, _toCopy) } return (_success, _returnData); } /// @notice Use when you _really_ really _really_ don't trust the called /// contract. This prevents the called contract from causing reversion of /// the caller in as many ways as we can. /// @dev The main difference between this and a solidity low-level call is /// that we limit the number of bytes that the callee can cause to be /// copied to caller memory. This prevents stupid things like malicious /// contracts returning 10,000,000 bytes causing a local OOG when copying /// to memory. /// @param _target The address to call /// @param _gas The amount of gas to forward to the remote contract /// @param _maxCopy The maximum number of bytes of returndata to copy /// to memory. /// @param _calldata The data to send to the remote contract /// @return success and returndata, as `.call()`. Returndata is capped to /// `_maxCopy` bytes. function excessivelySafeStaticCall( address _target, uint256 _gas, uint16 _maxCopy, bytes memory _calldata ) internal view returns (bool, bytes memory) { // set up for assembly call uint256 _toCopy; bool _success; bytes memory _returnData = new bytes(_maxCopy); // dispatch message to recipient // by assembly calling "handle" function // we call via assembly to avoid memcopying a very large returndata // returned by a malicious contract assembly { _success := staticcall( _gas, // gas _target, // recipient add(_calldata, 0x20), // inloc mload(_calldata), // inlen 0, // outloc 0 // outlen ) // limit our copy to 256 bytes _toCopy := returndatasize() if gt(_toCopy, _maxCopy) { _toCopy := _maxCopy } // Store the length of the copied bytes mstore(_returnData, _toCopy) // copy the bytes from returndata[0:_toCopy] returndatacopy(add(_returnData, 0x20), 0, _toCopy) } return (_success, _returnData); } /** * @notice Swaps function selectors in encoded contract calls * @dev Allows reuse of encoded calldata for functions with identical * argument types but different names. It simply swaps out the first 4 bytes * for the new selector. This function modifies memory in place, and should * only be used with caution. * @param _newSelector The new 4-byte selector * @param _buf The encoded contract args */ function swapSelector(bytes4 _newSelector, bytes memory _buf) internal pure { require(_buf.length >= 4); uint256 _mask = LOW_28_MASK; assembly { // load the first word of let _word := mload(add(_buf, 0x20)) // mask out the top 4 bytes // /x _word := and(_word, _mask) _word := or(_newSelector, _word) mstore(add(_buf, 0x20), _word) } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.7.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 anymore. Can only be called by the current owner. * * NOTE: Renouncing ownership will leave the contract without an owner, * thereby removing 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.7.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] * ``` * 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. Equivalent to `reinitializer(1)`. */ 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. * * `initializer` is equivalent to `reinitializer(1)`, so 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. * * 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. */ 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. */ function _disableInitializers() internal virtual { require(!_initializing, "Initializable: contract is initializing"); if (_initialized < type(uint8).max) { _initialized = type(uint8).max; emit Initialized(type(uint8).max); } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.7.0) (security/Pausable.sol) pragma solidity ^0.8.0; import "../utils/ContextUpgradeable.sol"; import "../proxy/utils/Initializable.sol"; /** * @dev Contract module which allows children to implement an emergency stop * mechanism that can be triggered by an authorized account. * * This module is used through inheritance. It will make available the * modifiers `whenNotPaused` and `whenPaused`, which can be applied to * the functions of your contract. Note that they will not be pausable by * simply including this module, only once the modifiers are put in place. */ abstract contract PausableUpgradeable is Initializable, ContextUpgradeable { /** * @dev Emitted when the pause is triggered by `account`. */ event Paused(address account); /** * @dev Emitted when the pause is lifted by `account`. */ event Unpaused(address account); bool private _paused; /** * @dev Initializes the contract in unpaused state. */ function __Pausable_init() internal onlyInitializing { __Pausable_init_unchained(); } function __Pausable_init_unchained() internal onlyInitializing { _paused = false; } /** * @dev Modifier to make a function callable only when the contract is not paused. * * Requirements: * * - The contract must not be paused. */ modifier whenNotPaused() { _requireNotPaused(); _; } /** * @dev Modifier to make a function callable only when the contract is paused. * * Requirements: * * - The contract must be paused. */ modifier whenPaused() { _requirePaused(); _; } /** * @dev Returns true if the contract is paused, and false otherwise. */ function paused() public view virtual returns (bool) { return _paused; } /** * @dev Throws if the contract is paused. */ function _requireNotPaused() internal view virtual { require(!paused(), "Pausable: paused"); } /** * @dev Throws if the contract is not paused. */ function _requirePaused() internal view virtual { require(paused(), "Pausable: not paused"); } /** * @dev Triggers stopped state. * * Requirements: * * - The contract must not be paused. */ function _pause() internal virtual whenNotPaused { _paused = true; emit Paused(_msgSender()); } /** * @dev Returns to normal state. * * Requirements: * * - The contract must be paused. */ function _unpause() internal virtual whenPaused { _paused = false; emit Unpaused(_msgSender()); } /** * @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 v4.4.1 (security/ReentrancyGuard.sol) pragma solidity ^0.8.0; import "../proxy/utils/Initializable.sol"; /** * @dev Contract module that helps prevent reentrant calls to a function. * * Inheriting from `ReentrancyGuard` will make the {nonReentrant} modifier * available, which can be applied to functions to make sure there are no nested * (reentrant) calls to them. * * Note that because there is a single `nonReentrant` guard, functions marked as * `nonReentrant` may not call one another. This can be worked around by making * those functions `private`, and then adding `external` `nonReentrant` entry * points to them. * * TIP: If you would like to learn more about reentrancy and alternative ways * to protect against it, check out our blog post * https://blog.openzeppelin.com/reentrancy-after-istanbul/[Reentrancy After Istanbul]. */ abstract contract ReentrancyGuardUpgradeable is Initializable { // Booleans are more expensive than uint256 or any type that takes up a full // word because each write operation emits an extra SLOAD to first read the // slot's contents, replace the bits taken up by the boolean, and then write // back. This is the compiler's defense against contract upgrades and // pointer aliasing, and it cannot be disabled. // The values being non-zero value makes deployment a bit more expensive, // but in exchange the refund on every call to nonReentrant will be lower in // amount. Since refunds are capped to a percentage of the total // transaction's gas, it is best to keep them low in cases like this one, to // increase the likelihood of the full refund coming into effect. uint256 private constant _NOT_ENTERED = 1; uint256 private constant _ENTERED = 2; uint256 private _status; function __ReentrancyGuard_init() internal onlyInitializing { __ReentrancyGuard_init_unchained(); } function __ReentrancyGuard_init_unchained() internal onlyInitializing { _status = _NOT_ENTERED; } /** * @dev Prevents a contract from calling itself, directly or indirectly. * Calling a `nonReentrant` function from another `nonReentrant` * function is not supported. It is possible to prevent this from happening * by making the `nonReentrant` function external, and making it call a * `private` function that does the actual work. */ modifier nonReentrant() { // On the first call to nonReentrant, _notEntered will be true require(_status != _ENTERED, "ReentrancyGuard: reentrant call"); // Any calls to nonReentrant after this point will fail _status = _ENTERED; _; // By storing the original value once again, a refund is triggered (see // https://eips.ethereum.org/EIPS/eip-2200) _status = _NOT_ENTERED; } /** * @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.7.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 * ==== * * [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://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more]. * * IMPORTANT: because control is transferred to `recipient`, care must be * taken to not create reentrancy vulnerabilities. Consider using * {ReentrancyGuard} or the * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. */ function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, "Address: insufficient balance"); (bool success, ) = recipient.call{value: amount}(""); require(success, "Address: unable to send value, recipient may have reverted"); } /** * @dev Performs a Solidity function call using a low level `call`. A * plain `call` is an unsafe replacement for a function call: use this * function instead. * * If `target` reverts with a revert reason, it is bubbled up by this * function (like regular Solidity function calls). * * Returns the raw returned data. To convert to the expected return value, * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`]. * * Requirements: * * - `target` must be a contract. * - calling `target` with `data` must not revert. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCall(target, data, "Address: low-level call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with * `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { return functionCallWithValue(target, data, 0, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but also transferring `value` wei to `target`. * * Requirements: * * - the calling contract must have an ETH balance of at least `value`. * - the called Solidity function must be `payable`. * * _Available since v3.1._ */ function functionCallWithValue( address target, bytes memory data, uint256 value ) internal returns (bytes memory) { return functionCallWithValue(target, data, value, "Address: low-level call with value failed"); } /** * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but * with `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCallWithValue( address target, bytes memory data, uint256 value, string memory errorMessage ) internal returns (bytes memory) { require(address(this).balance >= value, "Address: insufficient balance for call"); require(isContract(target), "Address: call to non-contract"); (bool success, bytes memory returndata) = target.call{value: value}(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) { return functionStaticCall(target, data, "Address: low-level static call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall( address target, bytes memory data, string memory errorMessage ) internal view returns (bytes memory) { require(isContract(target), "Address: static call to non-contract"); (bool success, bytes memory returndata) = target.staticcall(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the * revert reason using the provided one. * * _Available since v4.3._ */ function verifyCallResult( bool success, bytes memory returndata, string memory errorMessage ) internal pure returns (bytes memory) { if (success) { return returndata; } else { // Look for revert reason and bubble it up if present if (returndata.length > 0) { // The easiest way to bubble the revert reason is using memory via assembly /// @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.7.0) (access/Ownable.sol) pragma solidity ^0.8.0; import "../utils/Context.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 Ownable is Context { address private _owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); /** * @dev Initializes the contract setting the deployer as the initial owner. */ constructor() { _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 anymore. Can only be called by the current owner. * * NOTE: Renouncing ownership will leave the contract without an owner, * thereby removing 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); } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.7.0) (security/Pausable.sol) pragma solidity ^0.8.0; import "../utils/Context.sol"; /** * @dev Contract module which allows children to implement an emergency stop * mechanism that can be triggered by an authorized account. * * This module is used through inheritance. It will make available the * modifiers `whenNotPaused` and `whenPaused`, which can be applied to * the functions of your contract. Note that they will not be pausable by * simply including this module, only once the modifiers are put in place. */ abstract contract Pausable is Context { /** * @dev Emitted when the pause is triggered by `account`. */ event Paused(address account); /** * @dev Emitted when the pause is lifted by `account`. */ event Unpaused(address account); bool private _paused; /** * @dev Initializes the contract in unpaused state. */ constructor() { _paused = false; } /** * @dev Modifier to make a function callable only when the contract is not paused. * * Requirements: * * - The contract must not be paused. */ modifier whenNotPaused() { _requireNotPaused(); _; } /** * @dev Modifier to make a function callable only when the contract is paused. * * Requirements: * * - The contract must be paused. */ modifier whenPaused() { _requirePaused(); _; } /** * @dev Returns true if the contract is paused, and false otherwise. */ function paused() public view virtual returns (bool) { return _paused; } /** * @dev Throws if the contract is paused. */ function _requireNotPaused() internal view virtual { require(!paused(), "Pausable: paused"); } /** * @dev Throws if the contract is not paused. */ function _requirePaused() internal view virtual { require(paused(), "Pausable: not paused"); } /** * @dev Triggers stopped state. * * Requirements: * * - The contract must not be paused. */ function _pause() internal virtual whenNotPaused { _paused = true; emit Paused(_msgSender()); } /** * @dev Returns to normal state. * * Requirements: * * - The contract must be paused. */ function _unpause() internal virtual whenPaused { _paused = false; emit Unpaused(_msgSender()); } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.7.0) (token/ERC20/ERC20.sol) pragma solidity ^0.8.0; import "./IERC20.sol"; import "./extensions/IERC20Metadata.sol"; import "../../utils/Context.sol"; /** * @dev Implementation of the {IERC20} interface. * * This implementation is agnostic to the way tokens are created. This means * that a supply mechanism has to be added in a derived contract using {_mint}. * For a generic mechanism see {ERC20PresetMinterPauser}. * * TIP: For a detailed writeup see our guide * https://forum.zeppelin.solutions/t/how-to-implement-erc20-supply-mechanisms/226[How * to implement supply mechanisms]. * * We have followed general OpenZeppelin Contracts guidelines: functions revert * instead returning `false` on failure. This behavior is nonetheless * conventional and does not conflict with the expectations of ERC20 * applications. * * Additionally, an {Approval} event is emitted on calls to {transferFrom}. * This allows applications to reconstruct the allowance for all accounts just * by listening to said events. Other implementations of the EIP may not emit * these events, as it isn't required by the specification. * * Finally, the non-standard {decreaseAllowance} and {increaseAllowance} * functions have been added to mitigate the well-known issues around setting * allowances. See {IERC20-approve}. */ contract ERC20 is Context, IERC20, IERC20Metadata { mapping(address => uint256) private _balances; mapping(address => mapping(address => uint256)) private _allowances; uint256 private _totalSupply; string private _name; string private _symbol; /** * @dev Sets the values for {name} and {symbol}. * * The default value of {decimals} is 18. To select a different value for * {decimals} you should overload it. * * All two of these values are immutable: they can only be set once during * construction. */ constructor(string memory name_, string memory symbol_) { _name = name_; _symbol = symbol_; } /** * @dev Returns the name of the token. */ function name() public view virtual override returns (string memory) { return _name; } /** * @dev Returns the symbol of the token, usually a shorter version of the * name. */ function symbol() public view virtual override returns (string memory) { return _symbol; } /** * @dev Returns the number of decimals used to get its user representation. * For example, if `decimals` equals `2`, a balance of `505` tokens should * be displayed to a user as `5.05` (`505 / 10 ** 2`). * * Tokens usually opt for a value of 18, imitating the relationship between * Ether and Wei. This is the value {ERC20} uses, unless this function is * overridden; * * NOTE: This information is only used for _display_ purposes: it in * no way affects any of the arithmetic of the contract, including * {IERC20-balanceOf} and {IERC20-transfer}. */ function decimals() public view virtual override returns (uint8) { return 18; } /** * @dev See {IERC20-totalSupply}. */ function totalSupply() public view virtual override returns (uint256) { return _totalSupply; } /** * @dev See {IERC20-balanceOf}. */ function balanceOf(address account) public view virtual override returns (uint256) { return _balances[account]; } /** * @dev See {IERC20-transfer}. * * Requirements: * * - `to` cannot be the zero address. * - the caller must have a balance of at least `amount`. */ function transfer(address to, uint256 amount) public virtual override returns (bool) { address owner = _msgSender(); _transfer(owner, to, amount); return true; } /** * @dev See {IERC20-allowance}. */ function allowance(address owner, address spender) public view virtual override returns (uint256) { return _allowances[owner][spender]; } /** * @dev See {IERC20-approve}. * * NOTE: If `amount` is the maximum `uint256`, the allowance is not updated on * `transferFrom`. This is semantically equivalent to an infinite approval. * * Requirements: * * - `spender` cannot be the zero address. */ function approve(address spender, uint256 amount) public virtual override returns (bool) { address owner = _msgSender(); _approve(owner, spender, amount); return true; } /** * @dev See {IERC20-transferFrom}. * * Emits an {Approval} event indicating the updated allowance. This is not * required by the EIP. See the note at the beginning of {ERC20}. * * NOTE: Does not update the allowance if the current allowance * is the maximum `uint256`. * * Requirements: * * - `from` and `to` cannot be the zero address. * - `from` must have a balance of at least `amount`. * - the caller must have allowance for ``from``'s tokens of at least * `amount`. */ function transferFrom( address from, address to, uint256 amount ) public virtual override returns (bool) { address spender = _msgSender(); _spendAllowance(from, spender, amount); _transfer(from, to, amount); return true; } /** * @dev Atomically increases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. */ function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) { address owner = _msgSender(); _approve(owner, spender, allowance(owner, spender) + addedValue); return true; } /** * @dev Atomically decreases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. * - `spender` must have allowance for the caller of at least * `subtractedValue`. */ function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) { address owner = _msgSender(); uint256 currentAllowance = allowance(owner, spender); require(currentAllowance >= subtractedValue, "ERC20: decreased allowance below zero"); unchecked { _approve(owner, spender, currentAllowance - subtractedValue); } return true; } /** * @dev Moves `amount` of tokens from `from` to `to`. * * This internal function is equivalent to {transfer}, and can be used to * e.g. implement automatic token fees, slashing mechanisms, etc. * * Emits a {Transfer} event. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `from` must have a balance of at least `amount`. */ function _transfer( address from, address to, uint256 amount ) internal virtual { require(from != address(0), "ERC20: transfer from the zero address"); require(to != address(0), "ERC20: transfer to the zero address"); _beforeTokenTransfer(from, to, amount); uint256 fromBalance = _balances[from]; require(fromBalance >= amount, "ERC20: transfer amount exceeds balance"); unchecked { _balances[from] = fromBalance - amount; } _balances[to] += amount; emit Transfer(from, to, amount); _afterTokenTransfer(from, to, amount); } /** @dev Creates `amount` tokens and assigns them to `account`, increasing * the total supply. * * Emits a {Transfer} event with `from` set to the zero address. * * Requirements: * * - `account` cannot be the zero address. */ function _mint(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: mint to the zero address"); _beforeTokenTransfer(address(0), account, amount); _totalSupply += amount; _balances[account] += amount; emit Transfer(address(0), account, amount); _afterTokenTransfer(address(0), account, amount); } /** * @dev Destroys `amount` tokens from `account`, reducing the * total supply. * * Emits a {Transfer} event with `to` set to the zero address. * * Requirements: * * - `account` cannot be the zero address. * - `account` must have at least `amount` tokens. */ function _burn(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: burn from the zero address"); _beforeTokenTransfer(account, address(0), amount); uint256 accountBalance = _balances[account]; require(accountBalance >= amount, "ERC20: burn amount exceeds balance"); unchecked { _balances[account] = accountBalance - amount; } _totalSupply -= amount; emit Transfer(account, address(0), amount); _afterTokenTransfer(account, address(0), amount); } /** * @dev Sets `amount` as the allowance of `spender` over the `owner` s tokens. * * This internal function is equivalent to `approve`, and can be used to * e.g. set automatic allowances for certain subsystems, etc. * * Emits an {Approval} event. * * Requirements: * * - `owner` cannot be the zero address. * - `spender` cannot be the zero address. */ function _approve( address owner, address spender, uint256 amount ) internal virtual { require(owner != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); _allowances[owner][spender] = amount; emit Approval(owner, spender, amount); } /** * @dev Updates `owner` s allowance for `spender` based on spent `amount`. * * Does not update the allowance amount in case of infinite allowance. * Revert if not enough allowance is available. * * Might emit an {Approval} event. */ function _spendAllowance( address owner, address spender, uint256 amount ) internal virtual { uint256 currentAllowance = allowance(owner, spender); if (currentAllowance != type(uint256).max) { require(currentAllowance >= amount, "ERC20: insufficient allowance"); unchecked { _approve(owner, spender, currentAllowance - amount); } } } /** * @dev Hook that is called before any transfer of tokens. This includes * minting and burning. * * Calling conditions: * * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens * will be transferred to `to`. * - when `from` is zero, `amount` tokens will be minted for `to`. * - when `to` is zero, `amount` of ``from``'s tokens will be burned. * - `from` and `to` are never both zero. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _beforeTokenTransfer( address from, address to, uint256 amount ) internal virtual {} /** * @dev Hook that is called after any transfer of tokens. This includes * minting and burning. * * Calling conditions: * * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens * has been transferred to `to`. * - when `from` is zero, `amount` tokens have been minted for `to`. * - when `to` is zero, `amount` of ``from``'s tokens have been burned. * - `from` and `to` are never both zero. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _afterTokenTransfer( address from, address to, uint256 amount ) internal virtual {} }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/draft-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 v4.4.1 (token/ERC20/extensions/IERC20Metadata.sol) pragma solidity ^0.8.0; import "../IERC20.sol"; /** * @dev Interface for the optional metadata functions from the ERC20 standard. * * _Available since v4.1._ */ interface IERC20Metadata is IERC20 { /** * @dev Returns the name of the token. */ function name() external view returns (string memory); /** * @dev Returns the symbol of the token. */ function symbol() external view returns (string memory); /** * @dev Returns the decimals places of the token. */ function decimals() external view returns (uint8); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.6.0) (token/ERC20/IERC20.sol) pragma solidity ^0.8.0; /** * @dev Interface of the ERC20 standard as defined in the EIP. */ interface IERC20 { /** * @dev Emitted when `value` tokens are moved from one account (`from`) to * another (`to`). * * Note that `value` may be zero. */ event Transfer(address indexed from, address indexed to, uint256 value); /** * @dev Emitted when the allowance of a `spender` for an `owner` is set by * a call to {approve}. `value` is the new allowance. */ event Approval(address indexed owner, address indexed spender, uint256 value); /** * @dev Returns the amount of tokens in existence. */ function totalSupply() external view returns (uint256); /** * @dev Returns the amount of tokens owned by `account`. */ function balanceOf(address account) external view returns (uint256); /** * @dev Moves `amount` tokens from the caller's account to `to`. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transfer(address to, uint256 amount) external returns (bool); /** * @dev Returns the remaining number of tokens that `spender` will be * allowed to spend on behalf of `owner` through {transferFrom}. This is * zero by default. * * This value changes when {approve} or {transferFrom} are called. */ function allowance(address owner, address spender) external view returns (uint256); /** * @dev Sets `amount` as the allowance of `spender` over the caller's tokens. * * Returns a boolean value indicating whether the operation succeeded. * * IMPORTANT: Beware that changing an allowance with this method brings the risk * that someone may use both the old and the new allowance by unfortunate * transaction ordering. One possible solution to mitigate this race * condition is to first reduce the spender's allowance to 0 and set the * desired value afterwards: * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 * * Emits an {Approval} event. */ function approve(address spender, uint256 amount) external returns (bool); /** * @dev Moves `amount` tokens from `from` to `to` using the * allowance mechanism. `amount` is then deducted from the caller's * allowance. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transferFrom( address from, address to, uint256 amount ) external returns (bool); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.7.0) (token/ERC20/utils/SafeERC20.sol) pragma solidity ^0.8.0; import "../IERC20.sol"; import "../extensions/draft-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; function safeTransfer( IERC20 token, address to, uint256 value ) internal { _callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value)); } function safeTransferFrom( IERC20 token, address from, address to, uint256 value ) internal { _callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value)); } /** * @dev Deprecated. This function has issues similar to the ones found in * {IERC20-approve}, and its usage is discouraged. * * Whenever possible, use {safeIncreaseAllowance} and * {safeDecreaseAllowance} instead. */ function safeApprove( IERC20 token, address spender, uint256 value ) internal { // safeApprove should only be called when setting an initial allowance, // or when resetting it to zero. To increase and decrease it, use // 'safeIncreaseAllowance' and 'safeDecreaseAllowance' require( (value == 0) || (token.allowance(address(this), spender) == 0), "SafeERC20: approve from non-zero to non-zero allowance" ); _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value)); } function safeIncreaseAllowance( IERC20 token, address spender, uint256 value ) internal { uint256 newAllowance = token.allowance(address(this), spender) + value; _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance)); } function safeDecreaseAllowance( IERC20 token, address spender, uint256 value ) internal { unchecked { uint256 oldAllowance = token.allowance(address(this), spender); require(oldAllowance >= value, "SafeERC20: decreased allowance below zero"); uint256 newAllowance = oldAllowance - value; _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance)); } } 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"); if (returndata.length > 0) { // Return data is optional require(abi.decode(returndata, (bool)), "SafeERC20: ERC20 operation did not succeed"); } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.7.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 * ==== * * [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://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more]. * * IMPORTANT: because control is transferred to `recipient`, care must be * taken to not create reentrancy vulnerabilities. Consider using * {ReentrancyGuard} or the * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. */ function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, "Address: insufficient balance"); (bool success, ) = recipient.call{value: amount}(""); require(success, "Address: unable to send value, recipient may have reverted"); } /** * @dev Performs a Solidity function call using a low level `call`. A * plain `call` is an unsafe replacement for a function call: use this * function instead. * * If `target` reverts with a revert reason, it is bubbled up by this * function (like regular Solidity function calls). * * Returns the raw returned data. To convert to the expected return value, * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`]. * * Requirements: * * - `target` must be a contract. * - calling `target` with `data` must not revert. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCall(target, data, "Address: low-level call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with * `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { return functionCallWithValue(target, data, 0, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but also transferring `value` wei to `target`. * * Requirements: * * - the calling contract must have an ETH balance of at least `value`. * - the called Solidity function must be `payable`. * * _Available since v3.1._ */ function functionCallWithValue( address target, bytes memory data, uint256 value ) internal returns (bytes memory) { return functionCallWithValue(target, data, value, "Address: low-level call with value failed"); } /** * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but * with `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCallWithValue( address target, bytes memory data, uint256 value, string memory errorMessage ) internal returns (bytes memory) { require(address(this).balance >= value, "Address: insufficient balance for call"); require(isContract(target), "Address: call to non-contract"); (bool success, bytes memory returndata) = target.call{value: value}(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) { return functionStaticCall(target, data, "Address: low-level static call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall( address target, bytes memory data, string memory errorMessage ) internal view returns (bytes memory) { require(isContract(target), "Address: static call to non-contract"); (bool success, bytes memory returndata) = target.staticcall(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) { return functionDelegateCall(target, data, "Address: low-level delegate call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { require(isContract(target), "Address: delegate call to non-contract"); (bool success, bytes memory returndata) = target.delegatecall(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the * revert reason using the provided one. * * _Available since v4.3._ */ function verifyCallResult( bool success, bytes memory returndata, string memory errorMessage ) internal pure returns (bytes memory) { if (success) { return returndata; } else { // Look for revert reason and bubble it up if present if (returndata.length > 0) { // The easiest way to bubble the revert reason is using memory via assembly /// @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; /** * @dev Provides information about the current execution context, including the * sender of the transaction and its data. While these are generally available * via msg.sender and msg.data, they should not be accessed in such a direct * manner, since when dealing with meta-transactions the account sending and * paying for execution may not be the actual sender (as far as an application * is concerned). * * This contract is only required for intermediate, library-like contracts. */ abstract contract Context { function _msgSender() internal view virtual returns (address) { return msg.sender; } function _msgData() internal view virtual returns (bytes calldata) { return msg.data; } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts 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.19; import "@openzeppelin/contracts/token/ERC20/ERC20.sol"; interface IARBRewarder { function harvestARB(address _stakingToken, address _user) external; function ARB() external view returns(IERC20 ARB); function massUpdatePools() external; }
// SPDX-License-Identifier: MIT pragma solidity =0.8.19; interface IBaseRewardPool { function stakingDecimals() external view returns (uint256); function totalStaked() external view returns (uint256); function balanceOf(address account) external view returns (uint256); function rewardPerToken(address token) external view returns (uint256); function rewardTokenInfos() external view returns ( address[] memory bonusTokenAddresses, string[] memory bonusTokenSymbols ); function earned(address account, address token) external view returns (uint256); function allEarned(address account) external view returns (uint256[] memory pendingBonusRewards); function queueNewRewards(uint256 _rewards, address token) external returns (bool); function getReward(address _account, address _receiver) external returns (bool); function getRewards(address _account, address _receiver, address[] memory _rewardTokens) external; function updateFor(address account) external; function updateRewardQueuer(address _rewardManager, bool _allowed) external; }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.19; interface IBribeRewardDistributor { struct Claimable { address token; uint256 amount; } struct Claim { address token; address account; uint256 amount; bytes32[] merkleProof; } function getClaimable(Claim[] calldata _claims) external view returns(Claimable[] memory); function claim(Claim[] calldata _claims) external; }
// SPDX-License-Identifier: MIT pragma solidity =0.8.19; interface ILocker { struct UserUnlocking { uint256 startTime; uint256 endTime; uint256 amountInCoolDown; // total amount comitted to the unlock slot, never changes except when reseting slot } function getUserUnlockingSchedule(address _user) external view returns (UserUnlocking[] memory slots); function getUserAmountInCoolDown(address _user) external view returns (uint256); function totalLocked() external view returns (uint256); function getFullyUnlock(address _user) external view returns(uint256 unlockedAmount); function getRewardablePercentWAD(address _user) external view returns(uint256 percent); function totalAmountInCoolDown() external view returns (uint256); function getUserNthUnlockSlot(address _user, uint256 n) external view returns ( uint256 startTime, uint256 endTime, uint256 amountInCoolDown ); function getUserUnlockSlotLength(address _user) external view returns (uint256); function getNextAvailableUnlockSlot(address _user) external view returns (uint256); function getUserTotalLocked(address _user) external view returns (uint256); function lock(uint256 _amount) external; function lockFor(uint256 _amount, address _for) external; function startUnlock(uint256 _amountToCoolDown) external; function cancelUnlock(uint256 _slotIndex) external; function unlock(uint256 slotIndex) external; }
// SPDX-License-Identifier: MIT pragma solidity =0.8.19; import { IERC20 } from "@openzeppelin/contracts/token/ERC20/ERC20.sol"; import "./IBribeRewardDistributor.sol"; interface IMasterPenpie { function poolLength() external view returns (uint256); function setPoolManagerStatus(address _address, bool _bool) external; function add(uint256 _allocPoint, address _stakingTokenToken, address _receiptToken, address _rewarder) external; function set(address _stakingToken, uint256 _allocPoint, address _helper, address _rewarder, bool _helperNeedsHarvest) external; function createRewarder(address _stakingTokenToken, address mainRewardToken) external returns (address); // View function to see pending GMPs on frontend. function getPoolInfo(address token) external view returns ( uint256 emission, uint256 allocpoint, uint256 sizeOfPool, uint256 totalPoint ); function pendingTokens(address _stakingToken, address _user, address token) external view returns ( uint256 _pendingGMP, address _bonusTokenAddress, string memory _bonusTokenSymbol, uint256 _pendingBonusToken ); function allPendingTokensWithBribe( address _stakingToken, address _user, IBribeRewardDistributor.Claim[] calldata _proof ) external view returns ( uint256 pendingPenpie, address[] memory bonusTokenAddresses, string[] memory bonusTokenSymbols, uint256[] memory pendingBonusRewards ); function allPendingTokens(address _stakingToken, address _user) external view returns ( uint256 pendingPenpie, address[] memory bonusTokenAddresses, string[] memory bonusTokenSymbols, uint256[] memory pendingBonusRewards ); function massUpdatePools() external; function updatePool(address _stakingToken) external; function deposit(address _stakingToken, uint256 _amount) external; function depositFor(address _stakingToken, address _for, uint256 _amount) external; function withdraw(address _stakingToken, uint256 _amount) external; function beforeReceiptTokenTransfer(address _from, address _to, uint256 _amount) external; function afterReceiptTokenTransfer(address _from, address _to, uint256 _amount) external; function depositVlPenpieFor(uint256 _amount, address sender) external; function withdrawVlPenpieFor(uint256 _amount, address sender) external; function depositMPendleSVFor(uint256 _amount, address sender) external; function withdrawMPendleSVFor(uint256 _amount, address sender) external; function multiclaimFor(address[] calldata _stakingTokens, address[][] calldata _rewardTokens, address user_address) external; function multiclaimOnBehalf(address[] memory _stakingTokens, address[][] calldata _rewardTokens, address user_address, bool _isClaimPNP) external; function multiclaim(address[] calldata _stakingTokens) external; function emergencyWithdraw(address _stakingToken, address sender) external; function updateEmissionRate(uint256 _gmpPerSec) external; function stakingInfo(address _stakingToken, address _user) external view returns (uint256 depositAmount, uint256 availableAmount); function totalTokenStaked(address _stakingToken) external view returns (uint256); function getRewarder(address _stakingToken) external view returns (address rewarder); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (token/ERC20/IERC20.sol) pragma solidity =0.8.19; /** * @dev Interface of the ERC20 standard as defined in the EIP. */ interface IMintableERC20 { /** * @dev Returns the amount of tokens in existence. */ function totalSupply() external view returns (uint256); /** * @dev Returns the amount of tokens owned by `account`. */ function balanceOf(address account) external view returns (uint256); /** * @dev Moves `amount` tokens from the caller's account to `recipient`. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transfer(address recipient, uint256 amount) external returns (bool); function symbol() external view returns (string memory); function decimals() external view returns (uint8); /** * @dev Returns the remaining number of tokens that `spender` will be * allowed to spend on behalf of `owner` through {transferFrom}. This is * zero by default. * * This value changes when {approve} or {transferFrom} are called. */ function allowance(address owner, address spender) external view returns (uint256); /** * @dev Sets `amount` as the allowance of `spender` over the caller's tokens. * * Returns a boolean value indicating whether the operation succeeded. * * IMPORTANT: Beware that changing an allowance with this method brings the risk * that someone may use both the old and the new allowance by unfortunate * transaction ordering. One possible solution to mitigate this race * condition is to first reduce the spender's allowance to 0 and set the * desired value afterwards: * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 * * Emits an {Approval} event. */ function approve(address spender, uint256 amount) external returns (bool); /** * @dev Moves `amount` tokens from `sender` to `recipient` using the * allowance mechanism. `amount` is then deducted from the caller's * allowance. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transferFrom( address sender, address recipient, uint256 amount ) external returns (bool); function mint(address, uint256) external; function faucet(uint256) external; function burn(address, uint256) external; /** * @dev Emitted when `value` tokens are moved from one account (`from`) to * another (`to`). * * Note that `value` may be zero. */ event Transfer(address indexed from, address indexed to, uint256 value); /** * @dev Emitted when the allowance of a `spender` for an `owner` is set by * a call to {approve}. `value` is the new allowance. */ event Approval( address indexed owner, address indexed spender, uint256 value ); }
// SPDX-License-Identifier: MIT pragma solidity =0.8.19; import { IERC20, ERC20 } from "@openzeppelin/contracts/token/ERC20/ERC20.sol"; import "./ILocker.sol"; interface IVLPenpie is ILocker { function penpie() external view returns(IERC20); }
// SPDX-License-Identifier: MIT pragma solidity =0.8.19; import "./IBaseRewardPool.sol"; import "./IBribeRewardDistributor.sol"; interface IVLPenpieBaseRewarder is IBaseRewardPool { function rewardTokenInfosWithBribe(IBribeRewardDistributor.Claim[] calldata _proof) external view returns ( address[] memory bonusTokenAddresses, string[] memory bonusTokenSymbols ); function rewardTokenInfos() external view returns ( address[] memory bonusTokenAddresses, string[] memory bonusTokenSymbols ); function allEarnedWithBribe(address _account, IBribeRewardDistributor.Claim[] calldata _proof) external view returns (uint256[] memory pendingBonusRewards); function allEarned(address _account) external view returns (uint256[] memory pendingBonusRewards); function getRewardWithBribe( address _account, address _receiver, IBribeRewardDistributor.Claim[] calldata _proof ) external returns (bool); function getReward( address _account, address _receiver ) external returns (bool); function getRewardsWithBribe( address _account, address _receiver, address[] memory _rewardTokens, IBribeRewardDistributor.Claim[] calldata _proof ) external; function queuePenpie(uint256 _amount, address _user, address _receiver) external returns(bool); }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; pragma experimental ABIEncoderV2; import { ERC20 } from "@openzeppelin/contracts/token/ERC20/ERC20.sol"; import { MintableERC20 } from "./MintableERC20.sol"; import { PenpieReceiptToken } from "../rewards/PenpieReceiptToken.sol"; import { BaseRewardPoolV2 } from "../rewards/BaseRewardPoolV2.sol"; library ERC20FactoryLib { function createERC20(string memory name_, string memory symbol_) public returns(address) { ERC20 token = new MintableERC20(name_, symbol_); return address(token); } function createReceipt(address _stakeToken, address _masterPenpie, string memory _name, string memory _symbol) public returns(address) { ERC20 token = new PenpieReceiptToken(_stakeToken, _masterPenpie, _name, _symbol); return address(token); } function createRewarder( address _receiptToken, address mainRewardToken, address _masterRadpie, address _rewardQueuer ) external returns (address) { BaseRewardPoolV2 _rewarder = new BaseRewardPoolV2( _receiptToken, mainRewardToken, _masterRadpie, _rewardQueuer ); return address(_rewarder); } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (token/ERC20/ERC20.sol) pragma solidity ^0.8.0; import { ERC20 } from "@openzeppelin/contracts/token/ERC20/ERC20.sol"; import { Ownable } from "@openzeppelin/contracts/access/Ownable.sol"; contract MintableERC20 is ERC20, Ownable { /* The ERC20 deployed will be owned by the others contracts of the protocol, specifically by MasterMagpie and WombatStaking, forbidding the misuse of these functions for nefarious purposes */ constructor(string memory name_, string memory symbol_) ERC20(name_, symbol_) {} function mint(address account, uint256 amount) external virtual onlyOwner { _mint(account, amount); } function burn(address account, uint256 amount) external virtual onlyOwner { _burn(account, amount); } }
// SPDX-License-Identifier: MIT pragma solidity =0.8.19; import "@layerzerolabs/solidity-examples/contracts/token/oft/v2/OFTV2.sol"; import "@openzeppelin/contracts/security/Pausable.sol"; contract PenpieOFT is OFTV2, Pausable { /* ============ State Variables ============ */ /* ============ Constructor ============ */ constructor( address _endpoint, uint256 _mintAmt ) OFTV2("Penpie Token", "PNP", 8, _endpoint) { if (_mintAmt > 0) { _mint(msg.sender, _mintAmt); } } /* ============ External Functions ============ */ /* ============ Internal Functions ============ */ function _debitFrom( address _from, uint16 _dstChainId, bytes32 _toAddress, uint _amount ) internal override whenNotPaused returns (uint) { return super._debitFrom(_from, _dstChainId, _toAddress, _amount); } function _creditTo(uint16 _srcChainId, address _toAddress, uint _amount) internal override whenNotPaused returns (uint) { return super._creditTo(_srcChainId, _toAddress, _amount); } /* ============ Admin Functions ============ */ function pause() public onlyOwner { _pause(); } function unpause() public onlyOwner { _unpause(); } }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.19; import { SafeERC20 } from "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol"; import { Ownable } from "@openzeppelin/contracts/access/Ownable.sol"; import { IERC20Metadata } from "@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol"; import { IERC20 } from "@openzeppelin/contracts/token/ERC20/IERC20.sol"; import { IMasterPenpie } from "../interfaces/IMasterPenpie.sol"; import "../interfaces/IBaseRewardPool.sol"; /// @title A contract for managing rewards for a pool /// @author Magpie Team /// @notice You can use this contract for getting informations about rewards for a specific pools contract BaseRewardPoolV2 is Ownable, IBaseRewardPool { using SafeERC20 for IERC20Metadata; using SafeERC20 for IERC20; /* ============ State Variables ============ */ address public immutable receiptToken; address public immutable operator; // master Penpie uint256 public immutable receiptTokenDecimals; address[] public rewardTokens; struct Reward { address rewardToken; uint256 rewardPerTokenStored; uint256 queuedRewards; } struct UserInfo { uint256 userRewardPerTokenPaid; uint256 userRewards; } mapping(address => Reward) public rewards; // [rewardToken] // amount by [rewardToken][account], mapping(address => mapping(address => UserInfo)) public userInfos; mapping(address => bool) public isRewardToken; mapping(address => bool) public rewardQueuers; /* ============ Events ============ */ event RewardAdded(uint256 _reward, address indexed _token); event Staked(address indexed _user, uint256 _amount); event Withdrawn(address indexed _user, uint256 _amount); event RewardPaid(address indexed _user, address indexed _receiver, uint256 _reward, address indexed _token); event RewardQueuerUpdated(address indexed _manager, bool _allowed); /* ============ Errors ============ */ error OnlyRewardQueuer(); error OnlyMasterPenpie(); error NotAllowZeroAddress(); error MustBeRewardToken(); /* ============ Constructor ============ */ constructor( address _receiptToken, address _rewardToken, address _masterPenpie, address _rewardQueuer ) { if( _receiptToken == address(0) || _masterPenpie == address(0) || _rewardQueuer == address(0) ) revert NotAllowZeroAddress(); receiptToken = _receiptToken; receiptTokenDecimals = IERC20Metadata(receiptToken).decimals(); operator = _masterPenpie; if (_rewardToken != address(0)) { rewards[_rewardToken] = Reward({ rewardToken: _rewardToken, rewardPerTokenStored: 0, queuedRewards: 0 }); rewardTokens.push(_rewardToken); } isRewardToken[_rewardToken] = true; rewardQueuers[_rewardQueuer] = true; } /* ============ Modifiers ============ */ modifier onlyRewardQueuer() { if (!rewardQueuers[msg.sender]) revert OnlyRewardQueuer(); _; } modifier onlyMasterPenpie() { if (msg.sender != operator) revert OnlyMasterPenpie(); _; } modifier updateReward(address _account) { _updateFor(_account); _; } modifier updateRewards(address _account, address[] memory _rewards) { uint256 length = _rewards.length; uint256 userShare = balanceOf(_account); for (uint256 index = 0; index < length; ++index) { address rewardToken = _rewards[index]; UserInfo storage userInfo = userInfos[rewardToken][_account]; // if a reward stopped queuing, no need to recalculate to save gas fee if (userInfo.userRewardPerTokenPaid == rewardPerToken(rewardToken)) continue; userInfo.userRewards = _earned(_account, rewardToken, userShare); userInfo.userRewardPerTokenPaid = rewardPerToken(rewardToken); } _; } /* ============ External Getters ============ */ /// @notice Returns current amount of staked tokens /// @return Returns current amount of staked tokens function totalStaked() public override virtual view returns (uint256) { return IERC20(receiptToken).totalSupply(); } /// @notice Returns amount of staked tokens in master Penpie by account /// @param _account Address account /// @return Returns amount of staked tokens by account function balanceOf(address _account) public override virtual view returns (uint256) { return IERC20(receiptToken).balanceOf(_account); } function stakingDecimals() external override virtual view returns (uint256) { return receiptTokenDecimals; } /// @notice Returns amount of reward token per staking tokens in pool /// @param _rewardToken Address reward token /// @return Returns amount of reward token per staking tokens in pool function rewardPerToken(address _rewardToken) public override view returns (uint256) { return rewards[_rewardToken].rewardPerTokenStored; } function rewardTokenInfos() override external view returns ( address[] memory bonusTokenAddresses, string[] memory bonusTokenSymbols ) { uint256 rewardTokensLength = rewardTokens.length; bonusTokenAddresses = new address[](rewardTokensLength); bonusTokenSymbols = new string[](rewardTokensLength); for (uint256 i; i < rewardTokensLength; i++) { bonusTokenAddresses[i] = rewardTokens[i]; bonusTokenSymbols[i] = IERC20Metadata(address(bonusTokenAddresses[i])).symbol(); } } /// @notice Returns amount of reward token earned by a user /// @param _account Address account /// @param _rewardToken Address reward token /// @return Returns amount of reward token earned by a user function earned(address _account, address _rewardToken) public override view returns (uint256) { return _earned(_account, _rewardToken, balanceOf(_account)); } /// @notice Returns amount of all reward tokens /// @param _account Address account /// @return pendingBonusRewards as amounts of all rewards. function allEarned(address _account) external override view returns ( uint256[] memory pendingBonusRewards ) { uint256 length = rewardTokens.length; pendingBonusRewards = new uint256[](length); for (uint256 i = 0; i < length; i++) { pendingBonusRewards[i] = earned(_account, rewardTokens[i]); } return pendingBonusRewards; } function getRewardLength() external view returns(uint256) { return rewardTokens.length; } /* ============ External Functions ============ */ /// @notice Updates the reward information for one account /// @param _account Address account function updateFor(address _account) override external { _updateFor(_account); } function getReward(address _account, address _receiver) public onlyMasterPenpie updateReward(_account) returns (bool) { uint256 length = rewardTokens.length; for (uint256 index = 0; index < length; ++index) { address rewardToken = rewardTokens[index]; _sendReward(rewardToken, _account, _receiver); } return true; } function getRewards(address _account, address _receiver, address[] memory _rewardTokens) override external onlyMasterPenpie updateRewards(_account, _rewardTokens) { uint256 length = _rewardTokens.length; for (uint256 index = 0; index < length; ++index) { address rewardToken = _rewardTokens[index]; _sendReward(rewardToken, _account, _receiver); } } /// @notice Sends new rewards to be distributed to the users staking. Only possible to donate already registered token /// @param _amountReward Amount of reward token to be distributed /// @param _rewardToken Address reward token function donateRewards(uint256 _amountReward, address _rewardToken) external { if (!isRewardToken[_rewardToken]) revert MustBeRewardToken(); _provisionReward(_amountReward, _rewardToken); } /* ============ Admin Functions ============ */ function updateRewardQueuer(address _rewardManager, bool _allowed) external onlyOwner { rewardQueuers[_rewardManager] = _allowed; emit RewardQueuerUpdated(_rewardManager, rewardQueuers[_rewardManager]); } /// @notice Sends new rewards to be distributed to the users staking. Only callable by manager /// @param _amountReward Amount of reward token to be distributed /// @param _rewardToken Address reward token function queueNewRewards(uint256 _amountReward, address _rewardToken) override external onlyRewardQueuer returns (bool) { if (!isRewardToken[_rewardToken]) { rewardTokens.push(_rewardToken); isRewardToken[_rewardToken] = true; } _provisionReward(_amountReward, _rewardToken); return true; } /* ============ Internal Functions ============ */ function _provisionReward(uint256 _amountReward, address _rewardToken) internal { IERC20(_rewardToken).safeTransferFrom( msg.sender, address(this), _amountReward ); Reward storage rewardInfo = rewards[_rewardToken]; uint256 totalStake = totalStaked(); if (totalStake == 0) { rewardInfo.queuedRewards += _amountReward; } else { if (rewardInfo.queuedRewards > 0) { _amountReward += rewardInfo.queuedRewards; rewardInfo.queuedRewards = 0; } rewardInfo.rewardPerTokenStored = rewardInfo.rewardPerTokenStored + (_amountReward * 10**receiptTokenDecimals) / totalStake; } emit RewardAdded(_amountReward, _rewardToken); } function _earned(address _account, address _rewardToken, uint256 _userShare) internal view returns (uint256) { UserInfo storage userInfo = userInfos[_rewardToken][_account]; return ((_userShare * (rewardPerToken(_rewardToken) - userInfo.userRewardPerTokenPaid)) / 10**receiptTokenDecimals) + userInfo.userRewards; } function _sendReward(address _rewardToken, address _account, address _receiver) internal { uint256 _amount = userInfos[_rewardToken][_account].userRewards; if (_amount != 0) { userInfos[_rewardToken][_account].userRewards = 0; IERC20(_rewardToken).safeTransfer(_receiver, _amount); emit RewardPaid(_account, _receiver, _amount, _rewardToken); } } function _updateFor(address _account) internal { uint256 length = rewardTokens.length; for (uint256 index = 0; index < length; ++index) { address rewardToken = rewardTokens[index]; UserInfo storage userInfo = userInfos[rewardToken][_account]; // if a reward stopped queuing, no need to recalculate to save gas fee if (userInfo.userRewardPerTokenPaid == rewardPerToken(rewardToken)) continue; userInfo.userRewards = earned(_account, rewardToken); userInfo.userRewardPerTokenPaid = rewardPerToken(rewardToken); } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (token/ERC20/ERC20.sol) pragma solidity ^0.8.19; import { ERC20, IERC20 } from "@openzeppelin/contracts/token/ERC20/ERC20.sol"; import { SafeERC20 } from "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol"; import { IERC20Metadata } from "@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol"; import { Ownable } from "@openzeppelin/contracts/access/Ownable.sol"; import { IMasterPenpie } from "../interfaces/IMasterPenpie.sol"; /// @title PenpieReceiptToken is to represent a Pendle Market deposited to penpie posistion. PenpieReceiptToken is minted to user who deposited Market token /// on pendle staking to increase defi lego /// /// Reward from Magpie and on BaseReward should be updated upon every transfer. /// /// @author Magpie Team /// @notice Mater penpie emit `PNP` reward token based on Time. For a pool, contract PenpieReceiptToken is ERC20, Ownable { using SafeERC20 for IERC20Metadata; using SafeERC20 for IERC20; address public underlying; address public immutable masterPenpie; /* ============ Errors ============ */ /* ============ Events ============ */ constructor(address _underlying, address _masterPenpie, string memory name, string memory symbol) ERC20(name, symbol) { underlying = _underlying; masterPenpie = _masterPenpie; } // should only be called by 1. pendleStaking for Pendle Market deposits 2. masterPenpie for other general staking token such as mPendleOFT or PNP-ETH Lp tokens function mint(address account, uint256 amount) external virtual onlyOwner { _mint(account, amount); } // should only be called by 1. pendleStaking for Pendle Market deposits 2. masterPenpie for other general staking token such as mPendleOFT or PNP-ETH Lp tokens function burn(address account, uint256 amount) external virtual onlyOwner { _burn(account, amount); } // rewards are calculated based on user's receipt token balance, so reward should be updated on master penpie before transfer function _beforeTokenTransfer( address from, address to, uint256 amount ) internal override { IMasterPenpie(masterPenpie).beforeReceiptTokenTransfer(from, to, amount); } // rewards are calculated based on user's receipt token balance, so balance should be updated on master penpie before transfer function _afterTokenTransfer( address from, address to, uint256 amount ) internal override { IMasterPenpie(masterPenpie).afterReceiptTokenTransfer(from, to, amount); } }
{ "optimizer": { "enabled": true, "runs": 100 }, "outputSelection": { "*": { "*": [ "evm.bytecode", "evm.deployedBytecode", "devdoc", "userdoc", "metadata", "abi" ] } }, "libraries": { "contracts/libraries/ERC20FactoryLib.sol": { "ERC20FactoryLib": "0xae8e4bc88f792297a808cb5f32d4950fbbd8aeba" } } }
Contract Security Audit
- No Contract Security Audit Submitted- Submit Audit Here
[{"inputs":[],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[],"name":"InvalidStakingToken","type":"error"},{"inputs":[],"name":"LengthMismatch","type":"error"},{"inputs":[],"name":"MustBeContract","type":"error"},{"inputs":[],"name":"MustBeContractOrZero","type":"error"},{"inputs":[],"name":"OnlyActivePool","type":"error"},{"inputs":[],"name":"OnlyCompounder","type":"error"},{"inputs":[],"name":"OnlyMPendleSV","type":"error"},{"inputs":[],"name":"OnlyPoolManager","type":"error"},{"inputs":[],"name":"OnlyReceiptToken","type":"error"},{"inputs":[],"name":"OnlyStakingToken","type":"error"},{"inputs":[],"name":"OnlyVlPenpie","type":"error"},{"inputs":[],"name":"OnlyWhiteListedAllocaUpdator","type":"error"},{"inputs":[],"name":"PenpieOFTSetAlready","type":"error"},{"inputs":[],"name":"PoolExisted","type":"error"},{"inputs":[],"name":"UnlockAmountExceedsLocked","type":"error"},{"inputs":[],"name":"WithdrawAmountExceedsStaked","type":"error"},{"inputs":[],"name":"onlyARBRewarder","type":"error"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"_oldARBRewarder","type":"address"},{"indexed":false,"internalType":"address","name":"_newARBRewarder","type":"address"}],"name":"ARBRewarderSet","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"rewarder","type":"address"}],"name":"ARBRewarderSetAsQueuer","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"_allocPoint","type":"uint256"},{"indexed":true,"internalType":"address","name":"_stakingToken","type":"address"},{"indexed":true,"internalType":"address","name":"_receiptToken","type":"address"},{"indexed":true,"internalType":"contract IBaseRewardPool","name":"_rewarder","type":"address"}],"name":"Add","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"_newCompounder","type":"address"},{"indexed":false,"internalType":"address","name":"_oldCompounder","type":"address"}],"name":"CompounderUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"_user","type":"address"},{"indexed":true,"internalType":"address","name":"_stakingToken","type":"address"},{"indexed":true,"internalType":"address","name":"_receiptToken","type":"address"},{"indexed":false,"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"Deposit","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"_user","type":"address"},{"indexed":true,"internalType":"address","name":"_stakingToken","type":"address"},{"indexed":false,"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"DepositNotAvailable","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"_account","type":"address"},{"indexed":true,"internalType":"address","name":"_receiver","type":"address"},{"indexed":false,"internalType":"uint256","name":"_amount","type":"uint256"},{"indexed":false,"internalType":"bool","name":"isLock","type":"bool"}],"name":"HarvestPenpie","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint8","name":"version","type":"uint8"}],"name":"Initialized","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"previousOwner","type":"address"},{"indexed":true,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnershipTransferred","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"account","type":"address"}],"name":"Paused","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"_penpie","type":"address"}],"name":"PenpieOFTSet","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"_account","type":"address"},{"indexed":false,"internalType":"bool","name":"_status","type":"bool"}],"name":"PoolManagerStatus","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"_stakingToken","type":"address"},{"indexed":false,"internalType":"uint256","name":"_allocPoint","type":"uint256"},{"indexed":true,"internalType":"contract IBaseRewardPool","name":"_rewarder","type":"address"}],"name":"Set","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"account","type":"address"}],"name":"Unpaused","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"_user","type":"address"},{"indexed":false,"internalType":"uint256","name":"_oldPenpiePerSec","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"_newPenpiePerSec","type":"uint256"}],"name":"UpdateEmissionRate","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"_stakingToken","type":"address"},{"indexed":false,"internalType":"uint256","name":"_lastRewardTimestamp","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"_lpSupply","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"_accPenpiePerShare","type":"uint256"}],"name":"UpdatePool","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"_stakingToken","type":"address"},{"indexed":false,"internalType":"uint256","name":"_oldAllocPoint","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"_newAllocPoint","type":"uint256"}],"name":"UpdatePoolAlloc","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"_newvlPenpie","type":"address"},{"indexed":false,"internalType":"address","name":"_oldvlPenpie","type":"address"}],"name":"VlPenpieUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"_user","type":"address"},{"indexed":true,"internalType":"address","name":"_stakingToken","type":"address"},{"indexed":true,"internalType":"address","name":"_receiptToken","type":"address"},{"indexed":false,"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"Withdraw","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"_newMPendleSV","type":"address"},{"indexed":false,"internalType":"address","name":"_oldMPendleSV","type":"address"}],"name":"mPendleSVUpdated","type":"event"},{"inputs":[],"name":"ARBRewarder","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"AllocationManagers","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"PoolManagers","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_penpieOFT","type":"address"},{"internalType":"uint256","name":"_penpiePerSec","type":"uint256"},{"internalType":"uint256","name":"_startTimestamp","type":"uint256"}],"name":"__MasterPenpie_init","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_allocPoint","type":"uint256"},{"internalType":"address","name":"_stakingToken","type":"address"},{"internalType":"address","name":"_receiptToken","type":"address"},{"internalType":"address","name":"_rewarder","type":"address"}],"name":"add","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_from","type":"address"},{"internalType":"address","name":"_to","type":"address"},{"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"afterReceiptTokenTransfer","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_stakingToken","type":"address"},{"internalType":"address","name":"_user","type":"address"}],"name":"allPendingTokens","outputs":[{"internalType":"uint256","name":"pendingPenpie","type":"uint256"},{"internalType":"address[]","name":"bonusTokenAddresses","type":"address[]"},{"internalType":"string[]","name":"bonusTokenSymbols","type":"string[]"},{"internalType":"uint256[]","name":"pendingBonusRewards","type":"uint256[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_from","type":"address"},{"internalType":"address","name":"_to","type":"address"},{"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"beforeReceiptTokenTransfer","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"compounder","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_allocPoint","type":"uint256"},{"internalType":"address","name":"_stakingToken","type":"address"},{"internalType":"address","name":"_rewarder","type":"address"}],"name":"createNoReceiptPool","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_allocPoint","type":"uint256"},{"internalType":"address","name":"_stakingToken","type":"address"},{"internalType":"string","name":"_receiptName","type":"string"},{"internalType":"string","name":"_receiptSymbol","type":"string"}],"name":"createPool","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_receiptToken","type":"address"},{"internalType":"address","name":"mainRewardToken","type":"address"}],"name":"createRewarder","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_stakingToken","type":"address"},{"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"deposit","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_stakingToken","type":"address"},{"internalType":"address","name":"_for","type":"address"},{"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"depositFor","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_amount","type":"uint256"},{"internalType":"address","name":"_for","type":"address"}],"name":"depositMPendleSVFor","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_amount","type":"uint256"},{"internalType":"address","name":"_for","type":"address"}],"name":"depositVlPenpieFor","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_stakingToken","type":"address"}],"name":"getPoolInfo","outputs":[{"internalType":"uint256","name":"emission","type":"uint256"},{"internalType":"uint256","name":"allocpoint","type":"uint256"},{"internalType":"uint256","name":"sizeOfPool","type":"uint256"},{"internalType":"uint256","name":"totalPoint","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"stakingToken","type":"address"}],"name":"getRewarder","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"mPendleSV","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"massUpdatePools","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address[]","name":"_stakingTokens","type":"address[]"}],"name":"multiclaim","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address[]","name":"_stakingTokens","type":"address[]"},{"internalType":"address[][]","name":"_rewardTokens","type":"address[][]"},{"internalType":"address","name":"_account","type":"address"}],"name":"multiclaimFor","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address[]","name":"_stakingTokens","type":"address[]"},{"internalType":"address[][]","name":"_rewardTokens","type":"address[][]"},{"internalType":"address","name":"_account","type":"address"},{"internalType":"bool","name":"_isClaimPNP","type":"bool"}],"name":"multiclaimOnBehalf","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address[]","name":"_stakingTokens","type":"address[]"},{"internalType":"address[][]","name":"_rewardTokens","type":"address[][]"}],"name":"multiclaimSpec","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address[]","name":"_stakingTokens","type":"address[]"},{"internalType":"address[][]","name":"_rewardTokens","type":"address[][]"},{"internalType":"bool","name":"_withPNP","type":"bool"}],"name":"multiclaimSpecPNP","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"pause","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"paused","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_stakingToken","type":"address"},{"internalType":"address","name":"_user","type":"address"},{"internalType":"address","name":"_rewardToken","type":"address"}],"name":"pendingTokens","outputs":[{"internalType":"uint256","name":"pendingPenpie","type":"uint256"},{"internalType":"address","name":"bonusTokenAddress","type":"address"},{"internalType":"string","name":"bonusTokenSymbol","type":"string"},{"internalType":"uint256","name":"pendingBonusToken","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"penpieOFT","outputs":[{"internalType":"contract IERC20","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"penpiePerSec","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"poolLength","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"receiptToStakeToken","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"registeredToken","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_stakingToken","type":"address"},{"internalType":"uint256","name":"_allocPoint","type":"uint256"},{"internalType":"address","name":"_rewarder","type":"address"}],"name":"set","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_ARBRewarder","type":"address"}],"name":"setARBRewarder","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address[]","name":"_pools","type":"address[]"}],"name":"setARBRewarderAsQueuer","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_compounder","type":"address"}],"name":"setCompounder","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_mPendleSV","type":"address"}],"name":"setMPendleSV","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_penpieOFT","type":"address"}],"name":"setPenpie","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_account","type":"address"},{"internalType":"bool","name":"_allowedManager","type":"bool"}],"name":"setPoolManagerStatus","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_vlPenpie","type":"address"}],"name":"setVlPenpie","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_stakingToken","type":"address"},{"internalType":"address","name":"_user","type":"address"}],"name":"stakingInfo","outputs":[{"internalType":"uint256","name":"stakedAmount","type":"uint256"},{"internalType":"uint256","name":"availableAmount","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"startTimestamp","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"tokenToPoolInfo","outputs":[{"internalType":"address","name":"stakingToken","type":"address"},{"internalType":"address","name":"receiptToken","type":"address"},{"internalType":"uint256","name":"allocPoint","type":"uint256"},{"internalType":"uint256","name":"lastRewardTimestamp","type":"uint256"},{"internalType":"uint256","name":"accPenpiePerShare","type":"uint256"},{"internalType":"uint256","name":"totalStaked","type":"uint256"},{"internalType":"address","name":"rewarder","type":"address"},{"internalType":"bool","name":"isActive","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"totalAllocPoint","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":[],"name":"unpause","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_penpiePerSec","type":"uint256"}],"name":"updateEmissionRate","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_stakingToken","type":"address"}],"name":"updatePool","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address[]","name":"_stakingTokens","type":"address[]"},{"internalType":"uint256[]","name":"_allocPoints","type":"uint256[]"}],"name":"updatePoolsAlloc","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_rewarder","type":"address"},{"internalType":"address","name":"_manager","type":"address"},{"internalType":"bool","name":"_allowed","type":"bool"}],"name":"updateRewarderQueuer","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_account","type":"address"},{"internalType":"bool","name":"_allowed","type":"bool"}],"name":"updateWhitelistedAllocManager","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"address","name":"","type":"address"}],"name":"userInfo","outputs":[{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"uint256","name":"rewardDebt","type":"uint256"},{"internalType":"uint256","name":"available","type":"uint256"},{"internalType":"uint256","name":"unClaimedPenpie","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"vlPenpie","outputs":[{"internalType":"contract IVLPenpie","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_stakingToken","type":"address"},{"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"withdraw","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_amount","type":"uint256"},{"internalType":"address","name":"_for","type":"address"}],"name":"withdrawMPendleSVFor","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_amount","type":"uint256"},{"internalType":"address","name":"_for","type":"address"}],"name":"withdrawVlPenpieFor","outputs":[],"stateMutability":"nonpayable","type":"function"}]
Contract Creation Code
60806040523480156200001157600080fd5b506200001c62000022565b620000e4565b600054610100900460ff16156200008f5760405162461bcd60e51b815260206004820152602760248201527f496e697469616c697a61626c653a20636f6e747261637420697320696e697469604482015266616c697a696e6760c81b606482015260840160405180910390fd5b60005460ff9081161015620000e2576000805460ff191660ff9081179091556040519081527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb38474024989060200160405180910390a15b565b61455d80620000f46000396000f3fe608060405234801561001057600080fd5b50600436106103195760003560e01c80636ca8365b116101a9578063b3db428b116100ef578063e6fd48bc1161009d578063e6fd48bc14610832578063e74fac201461083b578063efe33cfa1461084e578063f2fde38b14610861578063f3fef3a314610874578063fa2cc3c014610887578063fa454aae1461089a578063fe0079aa146108ad57600080fd5b8063b3db428b1461070f578063b790161914610722578063c22d145314610735578063c78f742014610748578063c9365cd5146107f9578063cf94fdf51461080c578063e00e07321461081f57600080fd5b806380f84f011161015757806380f84f011461065857806382dad4341461066b5780638456cb591461067e5780638da5cb5b146106865780639a47ce13146106975780639c7e2655146106aa578063ad05e627146106bd578063afe300a4146106e057600080fd5b80636ca8365b146105d85780636d687fed146105eb57806370a1198e1461060e578063715018a6146106215780637881946a146106295780637b46c54f1461063c578063804994b71461064f57600080fd5b80633a274c061161026e57806359e66af31161021c57806359e66af3146105535780635c85503c146105665780635c975abb146105795780636030a73614610584578063630b5ba1146105975780636669a9301461059f57806368ab633c146105b257806368e1add1146105c557600080fd5b80633a274c06146104c45780633b3f0ee6146104d75780633f4ba83a146104ea5780633fb056c2146104f2578063453114631461050557806347e7ef24146105185780635750ec531461052b57600080fd5b806311b4919f116102cb57806311b4919f1461041657806317caf6f1146104365780631d53d3e61461043f578063266f24b7146104625780632b32ced61461047557806330f668361461048857806337e51e8e146104b157600080fd5b8063011684371461031e57806306bfa9381461033357806306f821ee1461036b57806307337f2b1461037e578063081e3eda146103b15780630ba84cd2146103c35780630f208beb146103d6575b600080fd5b61033161032c366004613705565b6108c0565b005b610346610341366004613735565b610946565b6040805194855260208501939093529183015260608201526080015b60405180910390f35b610331610379366004613760565b610a08565b6103a161038c366004613735565b60d26020526000908152604090205460ff1681565b6040519015158152602001610362565b60cc545b604051908152602001610362565b6103316103d13660046137ab565b610a78565b6103466103e43660046137c4565b60cf60209081526000928352604080842090915290825290208054600182015460028301546003909301549192909184565b60ca54610429906001600160a01b031681565b60405161036291906137f2565b6103b560d05481565b6103a161044d366004613735565b60d36020526000908152604090205460ff1681565b610331610470366004613806565b610acf565b60c954610429906001600160a01b031681565b610429610496366004613735565b60ce602052600090815260409020546001600160a01b031681565b6103316104bf366004613859565b610b1f565b6103316104d2366004613a38565b610d01565b6104296104e53660046137c4565b610d49565b610331610e24565b610331610500366004613705565b610e36565b610331610513366004613ac8565b610e86565b610331610526366004613b30565b610ea2565b61053e6105393660046137c4565b610fa6565b60408051928352602083019190915201610362565b610331610561366004613735565b610fdb565b60d454610429906001600160a01b031681565b60975460ff166103a1565b610331610592366004613705565b611042565b61033161108f565b6103316105ad366004613705565b6110e7565b6103316105c0366004613b5c565b61115a565b6103316105d3366004613859565b611271565b60d654610429906001600160a01b031681565b6105fe6105f93660046137c4565b61131d565b6040516103629493929190613c31565b61033161061c366004613ce1565b611461565b610331611478565b610331610637366004613735565b61148a565b61033161064a366004613735565b611538565b6103b560cb5481565b610331610666366004613d51565b61165a565b610331610679366004613d86565b6117f2565b610331611806565b6033546001600160a01b0316610429565b6103316106a5366004613dbd565b611816565b6104296106b83660046137ab565b611a3a565b6106d06106cb366004613e28565b611a64565b6040516103629493929190613e58565b6104296106ee366004613735565b6001600160a01b03908116600090815260cd60205260409020600601541690565b61033161071d366004613859565b611ba6565b610331610730366004613e93565b611cad565b610331610743366004613735565b611ce0565b6107ac610756366004613735565b60cd6020526000908152604090208054600182015460028301546003840154600485015460058601546006909601546001600160a01b03958616969486169593949293919291811690600160a01b900460ff1688565b604080516001600160a01b03998a16815297891660208901528701959095526060860193909352608085019190915260a084015290921660c082015290151560e082015261010001610362565b610331610807366004613ec1565b611d3a565b61033161081a366004613b5c565b611e9f565b61033161082d366004613735565b611f06565b6103b560d15481565b610331610849366004613ef8565b611f61565b61033161085c366004613e93565b611f77565b61033161086f366004613735565b611fdb565b610331610882366004613b30565b612051565b60d554610429906001600160a01b031681565b6103316108a8366004613735565b612158565b6103316108bb366004613fe0565b6121b3565b6108c86122b8565b6002606554036108f35760405162461bcd60e51b81526004016108ea90614053565b60405180910390fd5b600260655560ca546001600160a01b031633146109235760405163d52ea75b60e01b815260040160405180910390fd5b60ca5461093d906001600160a01b031633838560016122fe565b50506001606555565b6001600160a01b03818116600090815260cd60209081526040808320815161010081018352815486168152600182015486169381019390935260028101549183018290526003810154606084015260048101546080840152600581015460a08401526006015493841660c0830152600160a01b90930460ff16151560e082015260d05460cb549293849384938493909290916109e291906140a0565b6109ec91906140b7565b604082015160a09092015160d054919892975095509350915050565b610a10612460565b6040516371daff7560e01b815283906001600160a01b038216906371daff7590610a4090869086906004016140d9565b600060405180830381600087803b158015610a5a57600080fd5b505af1158015610a6e573d6000803e3d6000fd5b5050505050505050565b610a80612460565b610a8861108f565b60cb805490829055604080518281526020810184905233917f1d75b4af369dd9c67d43994eea5f98a89dcaa2d64156061ae12a4eaaeb43ff08910160405180910390a25050565b33600090815260d2602052604090205460ff16158015610aef5750333014155b15610b0d5760405163f655705d60e01b815260040160405180910390fd5b610b19848484846124ba565b50505050565b33600081815260ce60209081526040808320546001600160a01b0390811680855260cd9093529220600101549092911614610b6d57604051639ed2ad3b60e01b815260040160405180910390fd5b33600090815260ce60209081526040808320546001600160a01b0390811680855260cd90935292209091861615610c13576001600160a01b03808316600090815260cf60209081526040808320938a168352929052208054610bd09086906140f4565b81556002810154610be29086906140f4565b60028201556004820154815464e8d4a5100091610bfe916140a0565b610c0891906140b7565b600190910155610c44565b6001600160a01b038216600090815260cd602052604081206005018054869290610c3e908490614107565b90915550505b6001600160a01b03851615610cc8576001600160a01b03808316600090815260cf602090815260408083209389168352929052208054610c85908690614107565b81556002810154610c97908690614107565b60028201556004820154815464e8d4a5100091610cb3916140a0565b610cbd91906140b7565b600190910155610cf9565b6001600160a01b038216600090815260cd602052604081206005018054869290610cf39084906140f4565b90915550505b505050505050565b610d096122b8565b60d5546001600160a01b03163314610d3457604051630c240a0760e11b815260040160405180910390fd5b610d428585843387866127e0565b5050505050565b33600090815260d2602052604081205460ff16158015610d695750333014155b15610d875760405163f655705d60e01b815260040160405180910390fd5b604051632d096c4f60e21b81526001600160a01b0380851660048301528316602482015230604482015233606482015260009073ae8e4bc88f792297a808cb5f32d4950fbbd8aeba9063b425b13c90608401602060405180830381865af4158015610df6573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610e1a919061411a565b9150505b92915050565b610e2c612460565b610e346129ba565b565b610e3e6122b8565b60d4546001600160a01b03163314610e695760405163806763cd60e01b815260040160405180910390fd5b60d454610e82906001600160a01b031682846001612a06565b5050565b610e8e6122b8565b610e9d838333338560016127e0565b505050565b610eaa6122b8565b600260655403610ecc5760405162461bcd60e51b81526004016108ea90614053565b60026065556001600160a01b03808316600090815260cd602052604090819020600181015491516340c10f1960e01b8152909291909116906340c10f1990610f1a9033908690600401614137565b600060405180830381600087803b158015610f3457600080fd5b505af1158015610f48573d6000803e3d6000fd5b50508254610f6492506001600160a01b03169050333085612b90565b60018101546040518381526001600160a01b03918216918516903390600080516020614508833981519152906020015b60405180910390a45050600160655550565b6001600160a01b03828116600090815260cf6020908152604080832093851683529290522080546002909101545b9250929050565b610fe3612460565b60ca80546001600160a01b038381166001600160a01b0319831681179093556040519116917f9067c50c8e02c1a44b029fbb43b4c2fdc9ffb0495c4795cd2dc144a2e3040c569161103691908490614150565b60405180910390a15050565b61104a6122b8565b60d4546001600160a01b031633146110755760405163806763cd60e01b815260040160405180910390fd5b60d454610e82906001600160a01b031633838560016122fe565b6110976122b8565b60005b60cc548110156110e4576110d460cc82815481106110ba576110ba61416a565b6000918252602090912001546001600160a01b0316611538565b6110dd81614180565b905061109a565b50565b6110ef6122b8565b6002606554036111115760405162461bcd60e51b81526004016108ea90614053565b600260655560ca546001600160a01b031633146111415760405163d52ea75b60e01b815260040160405180910390fd5b60ca5461093d906001600160a01b031682846001612a06565b611162612460565b60005b81811015610e9d5760008383838181106111815761118161416a565b90506020020160208101906111969190613735565b6001600160a01b03808216600090815260cd602052604090206006015491925016801561125c5760d6546040516371daff7560e01b81526001600160a01b03838116926371daff75926111f292909116906001906004016140d9565b600060405180830381600087803b15801561120c57600080fd5b505af1158015611220573d6000803e3d6000fd5b505050507feb634d56c1728cfbabdc5c85f7057217c21a80b7a2d3191b57c8e82176839ae48160405161125391906137f2565b60405180910390a15b5050808061126990614180565b915050611165565b33600081815260ce60209081526040808320546001600160a01b0390811680855260cd90935292206001015490929116146112bf57604051639ed2ad3b60e01b815260040160405180910390fd5b33600090815260ce60205260409020546001600160a01b03166112e181611538565b6001600160a01b038516156112fa576112fa8186612bfb565b836001600160a01b0316856001600160a01b031614610d4257610d428185612bfb565b6001600160a01b038216600090815260cd60205260408120606090819081906113468787612c3a565b60068201549095506001600160a01b031615611457578060060160009054906101000a90046001600160a01b03166001600160a01b03166345b507e36040518163ffffffff1660e01b8152600401600060405180830381865afa1580156113b1573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526113d99190810190614270565b60068301546040516352146cdb60e01b81529296509094506001600160a01b0316906352146cdb9061140f9089906004016137f2565b600060405180830381865afa15801561142c573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526114549190810190614334565b91505b5092959194509250565b6114696122b8565b610b19848483848660016127e0565b611480612460565b610e346000612d44565b611492612460565b60c9546001600160a01b0316156114bc576040516336d1e00560e11b815260040160405180910390fd5b6114c581612d96565b6114e25760405163cc8ea4f560e01b815260040160405180910390fd5b60c980546001600160a01b0319166001600160a01b0383161790556040517f28bd60b0cfa9ed243cddcb0a06776639d31979cb7acff48946c6806bd3be61049061152d9083906137f2565b60405180910390a150565b6115406122b8565b6001600160a01b038116600090815260cd6020526040902060038101544211158061156b575060d054155b15611574575050565b6005810154600081900361158d57504260039091015550565b600082600301544261159f91906140f4565b9050600060d054846002015460cb54846115b991906140a0565b6115c391906140a0565b6115cd91906140b7565b9050826115df8264e8d4a510006140a0565b6115e991906140b7565b84600401546115f89190614107565b60048501819055426003860181905560408051918252602082018690528101919091526001600160a01b038616907f50a1a2d4fcb1c08863a0b14fcc7d9d728e2b21d8d7588b9cfa3991efe8112ee79060600160405180910390a25050505050565b600054610100900460ff161580801561167a5750600054600160ff909116105b8061169b575061168930612d96565b15801561169b575060005460ff166001145b6116fe5760405162461bcd60e51b815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201526d191e481a5b9a5d1a585b1a5e995960921b60648201526084016108ea565b6000805460ff191660011790558015611721576000805461ff0019166101001790555b611729612da5565b611731612dd4565b611739612e03565b60c980546001600160a01b0386166001600160a01b031990911617905560cb83905560d1829055600060d081905560019060d29061177f6033546001600160a01b031690565b6001600160a01b031681526020810191909152604001600020805460ff19169115159190911790558015610b19576000805461ff0019169055604051600181527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb38474024989060200160405180910390a150505050565b6117fa612460565b610e9d838384846124ba565b61180e612460565b610e34612e32565b33600090815260d3602052604090205460ff1680611843575033600090815260d2602052604090205460ff165b8061185857506033546001600160a01b031633145b15611a2157828114611880576040516001621398b960e31b0319815260040160405180910390fd5b60005b83811015611a1b57600060cd60008787858181106118a3576118a361416a565b90506020020160208101906118b89190613735565b6001600160a01b03166001600160a01b031681526020019081526020016000206002015490508383838181106118f0576118f061416a565b905060200201358160d05461190591906140f4565b61190f9190614107565b60d0558383838181106119245761192461416a565b9050602002013560cd60008888868181106119415761194161416a565b90506020020160208101906119569190613735565b6001600160a01b031681526020810191909152604001600020600201557f9d1e399e9f825d6a92c706d1784017e4e9e8c44116b04bf9d7b3dcffa37eddc88686848181106119a6576119a661416a565b90506020020160208101906119bb9190613735565b828686868181106119ce576119ce61416a565b90506020020135604051611a00939291906001600160a01b039390931683526020830191909152604082015260600190565b60405180910390a15080611a1381614180565b915050611883565b50610b19565b604051633a6294b560e11b815260040160405180910390fd5b60cc8181548110611a4a57600080fd5b6000918252602090912001546001600160a01b0316905081565b6001600160a01b038316600090815260cd6020526040812081906060908290611a8d8888612c3a565b60068201549095506001600160a01b031615801590611ab457506001600160a01b03861615155b15611b9c5785866001600160a01b03166395d89b416040518163ffffffff1660e01b8152600401600060405180830381865afa158015611af8573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052611b2091908101906143b9565b600683015460405163211dc32d60e01b81529296509094506001600160a01b03169063211dc32d90611b58908a908a90600401614150565b602060405180830381865afa158015611b75573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611b9991906143ed565b91505b5093509350935093565b611bae6122b8565b600260655403611bd05760405162461bcd60e51b81526004016108ea90614053565b60026065556001600160a01b03808416600090815260cd602052604090819020600181015491516340c10f1960e01b8152909291909116906340c10f1990611c1e9086908690600401614137565b600060405180830381600087803b158015611c3857600080fd5b505af1158015611c4c573d6000803e3d6000fd5b50508254611c6892506001600160a01b03169050333085612b90565b60018101546040518381526001600160a01b039182169186811691908616906000805160206145088339815191529060200160405180910390a4505060016065555050565b611cb5612460565b6001600160a01b0391909116600090815260d360205260409020805460ff1916911515919091179055565b611ce8612460565b60d680546001600160a01b038381166001600160a01b0319831681179093556040519116917fb12eee8c2e1b5fc0a75061f2f305355fe9479f86daee2606a0162c2c09e39b1b91611036918491614150565b33600090815260d2602052604090205460ff16158015611d5a5750333014155b15611d785760405163f655705d60e01b815260040160405180910390fd5b611d8181612d96565b158015611d9657506001600160a01b03811615155b15611db45760405163b66f944760e01b815260040160405180910390fd5b6001600160a01b038316600090815260cd6020526040902060060154600160a01b900460ff16611df757604051636a325bd960e11b815260040160405180910390fd5b6001600160a01b038316600090815260cd602052604090206002015460d0548391611e21916140f4565b611e2b9190614107565b60d0556001600160a01b03838116600081815260cd60209081526040918290206002810187905560060180546001600160a01b031916948616948517905590518581527fdb56252d0d52575e1a437302556b299c2a995c7fd5c619b8efda785dcf597d2891015b60405180910390a3505050565b611ea76122b8565b6000816001600160401b03811115611ec157611ec16138de565b604051908082528060200260200182016040528015611ef457816020015b6060815260200190600190039081611edf5790505b509050610e9d838333338560016127e0565b611f0e612460565b60d580546001600160a01b038381166001600160a01b0319831681179093556040519116917f54894eb11869f8993d34c2e84d51ff771a5e43d1928cf8996a359f97155d8cb69161103691908490614150565b611f696122b8565b610b198484333386866127e0565b611f7f612460565b6001600160a01b038216600090815260d2602052604090819020805460ff191683151590811790915590517f26b10598e51169a6f63965086cafd8665e54b0ff538233804909efe8d5c5810d9161103691859160ff16906140d9565b611fe3612460565b6001600160a01b0381166120485760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b60648201526084016108ea565b6110e481612d44565b6120596122b8565b60026065540361207b5760405162461bcd60e51b81526004016108ea90614053565b60026065556001600160a01b03808316600090815260cd60205260409081902060018101549151632770a7eb60e21b815290929190911690639dc29fac906120c99033908690600401614137565b600060405180830381600087803b1580156120e357600080fd5b505af11580156120f7573d6000803e3d6000fd5b5050825461211292506001600160a01b031690503384612e6f565b60018101546040518381526001600160a01b039182169185169033907f3115d1449a7b732c986cba18244e897a450f61e1bb8d589cd2e69e6c8924f9f790602001610f94565b612160612460565b60d480546001600160a01b038381166001600160a01b03198316179092556040519116907fa36fc62da97ee1df24a48660c231c7e6d8a6b1821b2e53344d053b90701a89de906110369084908490614150565b6121bb612460565b604051630639860b60e51b815260009073ae8e4bc88f792297a808cb5f32d4950fbbd8aeba9063c730c160906121fb908790309088908890600401614406565b602060405180830381865af4158015612218573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061223c919061411a565b604051631d9f877360e11b81529091506000903090633b3f0ee6906122679085908590600401614150565b6020604051808303816000875af1158015612286573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906122aa919061411a565b9050610cf9868684846124ba565b60975460ff1615610e345760405162461bcd60e51b815260206004820152601060248201526f14185d5cd8589b194e881c185d5cd95960821b60448201526064016108ea565b6001600160a01b03808616600090815260cd6020908152604080832060cf8352818420948816845293909152902061233587611538565b61233f8786612bfb565b805461234c908590614107565b81558261237f578381600201546123639190614107565b6002820155815461237f906001600160a01b0316873087612b90565b6004820154815464e8d4a5100091612396916140a0565b6123a091906140b7565b6001820155831561245757838260050160008282546123bf9190614107565b909155508390506124095760018201546040518581526001600160a01b039182169189811691908816906000805160206145088339815191529060200160405180910390a4612457565b866001600160a01b0316856001600160a01b03167f6d0456143026caba846332ec09535fc3171dcd0c340cf99ad1668e75bfc1c7c88660405161244e91815260200190565b60405180910390a35b50505050505050565b6033546001600160a01b03163314610e345760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657260448201526064016108ea565b6124c383612d96565b15806124d557506124d382612d96565b155b156124f3576040516330704cfd60e11b815260040160405180910390fd5b6124fc81612d96565b15801561251157506001600160a01b03811615155b1561252f5760405163b66f944760e01b815260040160405180910390fd5b6001600160a01b038316600090815260cd6020526040902060060154600160a01b900460ff161561257357604051636d3acfdd60e01b815260040160405180910390fd5b600060d15442116125865760d154612588565b425b90508460d0546125989190614107565b60d08190555060cc849080600181540180825580915050600190039060005260206000200160009091909190916101000a8154816001600160a01b0302191690836001600160a01b03160217905550604051806101000160405280856001600160a01b03168152602001846001600160a01b031681526020018681526020018281526020016000815260200160008152602001836001600160a01b031681526020016001151581525060cd6000866001600160a01b03166001600160a01b0316815260200190815260200160002060008201518160000160006101000a8154816001600160a01b0302191690836001600160a01b0316021790555060208201518160010160006101000a8154816001600160a01b0302191690836001600160a01b0316021790555060408201518160020155606082015181600301556080820151816004015560a0820151816005015560c08201518160060160006101000a8154816001600160a01b0302191690836001600160a01b0316021790555060e08201518160060160146101000a81548160ff0219169083151502179055509050508360ce6000856001600160a01b03166001600160a01b0316815260200190815260200160002060006101000a8154816001600160a01b0302191690836001600160a01b03160217905550816001600160a01b0316836001600160a01b0316856001600160a01b03167f224e1c56d5a095bbae2a37104ca3c43212f7580c6ebb1b6b9ea1fb3eebb42e7c886040516127d191815260200190565b60405180910390a45050505050565b6002606554036128025760405162461bcd60e51b81526004016108ea90614053565b600260655581518590811461282d576040516001621398b960e31b0319815260040160405180910390fd5b60008060005b838110156129795760008a8a8381811061284f5761284f61416a565b90506020020160208101906128649190613735565b6001600160a01b03808216600090815260cf60209081526040808320938e1683529290522090915061289582611538565b600081600301546128a6848d612e8e565b6128b09190614107565b905087156128f85760ca546001600160a01b03908116908416036128df576128d88187614107565b95506128ec565b6128e98186614107565b94505b60006003830155612900565b600382018190555b6001600160a01b038316600090815260cd6020526040902060040154825464e8d4a510009161292e916140a0565b61293891906140b7565b8260010181905550612965838c8c8c88815181106129585761295861416a565b6020026020010151612f00565b5050508061297290614180565b9050612833565b5083612987575050506129ad565b811561299857612998878784613003565b80156129a9576129a9878783613100565b5050505b5050600160655550505050565b6129c261315d565b6097805460ff191690557f5db9ee0a495bf2e6ff9c91a7834c1ba4fdd244a5e8aa4e537bd38aeae4b073aa335b6040516129fc91906137f2565b60405180910390a1565b6001600160a01b03808516600090815260cd6020908152604080832060cf8352818420948816845293909152902082158015612a455750838160020154105b15612a635760405163e997875560e01b815260040160405180910390fd5b805484118015612a705750825b15612a8e57604051633bd20ca960e21b815260040160405180910390fd5b612a9786611538565b612aa186866131a6565b612aab86866131fb565b8054612ab89085906140f4565b815582612afa57838160020154612acf91906140f4565b60028201556001600160a01b03808716600090815260cd6020526040902054612afa91163386612e6f565b6004820154815464e8d4a5100091612b11916140a0565b612b1b91906140b7565b816001018190555083826005016000828254612b3791906140f4565b909155505060018201546040518581526001600160a01b039182169188811691908816907f3115d1449a7b732c986cba18244e897a450f61e1bb8d589cd2e69e6c8924f9f79060200160405180910390a4505050505050565b6040516001600160a01b0380851660248301528316604482015260648101829052610b199085906323b872dd60e01b906084015b60408051601f198184030181529190526020810180516001600160e01b03166001600160e01b031990931692909217909152613309565b6001600160a01b03808316600090815260cf602090815260408083209385168352929052205415612c3057612c3082826131a6565b610e8282826131fb565b6001600160a01b03808316600090815260cd6020908152604080832060cf835281842094861684529390915281206004830154600384015492939242118015612c865750600583015415155b15612cfb576000836003015442612c9d91906140f4565b9050600060d054856002015460cb5484612cb791906140a0565b612cc191906140a0565b612ccb91906140b7565b6005860154909150612ce28264e8d4a510006140a0565b612cec91906140b7565b612cf69084614107565b925050505b6001820154825464e8d4a5100090612d149084906140a0565b612d1e91906140b7565b612d2891906140f4565b9350816003015484612d3a9190614107565b9695505050505050565b603380546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b6001600160a01b03163b151590565b600054610100900460ff16612dcc5760405162461bcd60e51b81526004016108ea90614444565b610e346133db565b600054610100900460ff16612dfb5760405162461bcd60e51b81526004016108ea90614444565b610e3461340b565b600054610100900460ff16612e2a5760405162461bcd60e51b81526004016108ea90614444565b610e34613439565b612e3a6122b8565b6097805460ff191660011790557f62e78cea01bee320cd4e420270b5ea74000d11b0c9f74754ebdbfc544b05a2586129ef3390565b610e9d8363a9059cbb60e01b8484604051602401612bc4929190614137565b6001600160a01b03808316600081815260cf602090815260408083209486168352938152838220600181015493835260cd9091529281206004015483549193928492909164e8d4a5100091612ee391906140a0565b612eed91906140b7565b612ef791906140f4565b95945050505050565b6001600160a01b03808516600090815260cd6020526040902060060154168015610d4257815115612f92576040516369795e9360e01b81526001600160a01b038216906369795e9390612f5b9087908790879060040161448f565b600060405180830381600087803b158015612f7557600080fd5b505af1158015612f89573d6000803e3d6000fd5b50505050610d42565b604051636b09169560e01b81526001600160a01b03821690636b09169590612fc09087908790600401614150565b6020604051808303816000875af1158015612fdf573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610cf991906144bb565b60ca546001600160a01b03908116600090815260cd602052604090206006015460c954908216916130369116828461346c565b60405162e280a560e31b8152600481018390526001600160a01b03858116602483015284811660448301528216906307140528906064016020604051808303816000875af115801561308c573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906130b091906144bb565b5060408051838152600060208201526001600160a01b0380861692908716917f65f4901aaf030c6a056bf3ed5e6f41707bee06b5534c53867f2b83492dc2d748910160405180910390a350505050565b60c954613117906001600160a01b03168383612e6f565b60408051828152600060208201526001600160a01b0380851692908616917f65f4901aaf030c6a056bf3ed5e6f41707bee06b5534c53867f2b83492dc2d7489101611e92565b60975460ff16610e345760405162461bcd60e51b815260206004820152601460248201527314185d5cd8589b194e881b9bdd081c185d5cd95960621b60448201526064016108ea565b60006131b28383612e8e565b6001600160a01b03808516600090815260cf602090815260408083209387168352929052908120600301805492935083929091906131f1908490614107565b9091555050505050565b6001600160a01b03808316600090815260cd602052604090206006015460d65490821691161580159061323657506001600160a01b03811615155b156132a05760d65460405163ee96202f60e01b81526001600160a01b039091169063ee96202f9061326d9086908590600401614150565b600060405180830381600087803b15801561328757600080fd5b505af115801561329b573d6000803e3d6000fd5b505050505b6001600160a01b03811615610e9d576040516301c14b2d60e31b81526001600160a01b03821690630e0a5968906132db9085906004016137f2565b600060405180830381600087803b1580156132f557600080fd5b505af1158015612457573d6000803e3d6000fd5b600061335e826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b031661356f9092919063ffffffff16565b805190915015610e9d578080602001905181019061337c91906144bb565b610e9d5760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b60648201526084016108ea565b600054610100900460ff166134025760405162461bcd60e51b81526004016108ea90614444565b610e3433612d44565b600054610100900460ff166134325760405162461bcd60e51b81526004016108ea90614444565b6001606555565b600054610100900460ff166134605760405162461bcd60e51b81526004016108ea90614444565b6097805460ff19169055565b8015806134e55750604051636eb1769f60e11b81526001600160a01b0384169063dd62ed3e906134a29030908690600401614150565b602060405180830381865afa1580156134bf573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906134e391906143ed565b155b6135505760405162461bcd60e51b815260206004820152603660248201527f5361666545524332303a20617070726f76652066726f6d206e6f6e2d7a65726f60448201527520746f206e6f6e2d7a65726f20616c6c6f77616e636560501b60648201526084016108ea565b610e9d8363095ea7b360e01b8484604051602401612bc4929190614137565b606061357e8484600085613588565b90505b9392505050565b6060824710156135e95760405162461bcd60e51b815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f6044820152651c8818d85b1b60d21b60648201526084016108ea565b6135f285612d96565b61363e5760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e747261637400000060448201526064016108ea565b600080866001600160a01b0316858760405161365a91906144d8565b60006040518083038185875af1925050503d8060008114613697576040519150601f19603f3d011682016040523d82523d6000602084013e61369c565b606091505b50915091506136ac8282866136b7565b979650505050505050565b606083156136c6575081613581565b8251156136d65782518084602001fd5b8160405162461bcd60e51b81526004016108ea91906144f4565b6001600160a01b03811681146110e457600080fd5b6000806040838503121561371857600080fd5b82359150602083013561372a816136f0565b809150509250929050565b60006020828403121561374757600080fd5b8135613581816136f0565b80151581146110e457600080fd5b60008060006060848603121561377557600080fd5b8335613780816136f0565b92506020840135613790816136f0565b915060408401356137a081613752565b809150509250925092565b6000602082840312156137bd57600080fd5b5035919050565b600080604083850312156137d757600080fd5b82356137e2816136f0565b9150602083013561372a816136f0565b6001600160a01b0391909116815260200190565b6000806000806080858703121561381c57600080fd5b84359350602085013561382e816136f0565b9250604085013561383e816136f0565b9150606085013561384e816136f0565b939692955090935050565b60008060006060848603121561386e57600080fd5b8335613879816136f0565b92506020840135613889816136f0565b929592945050506040919091013590565b60008083601f8401126138ac57600080fd5b5081356001600160401b038111156138c357600080fd5b6020830191508360208260051b8501011115610fd457600080fd5b634e487b7160e01b600052604160045260246000fd5b604051601f8201601f191681016001600160401b038111828210171561391c5761391c6138de565b604052919050565b60006001600160401b0382111561393d5761393d6138de565b5060051b60200190565b600082601f83011261395857600080fd5b8135602061396d61396883613924565b6138f4565b828152600592831b850182019282820191908785111561398c57600080fd5b8387015b85811015613a2b5780356001600160401b038111156139af5760008081fd5b8801603f81018a136139c15760008081fd5b8581013560406139d361396883613924565b82815291851b8301810191888101908d8411156139f05760008081fd5b938201935b83851015613a1a5784359250613a0a836136f0565b82825293890193908901906139f5565b885250505093850193508401613990565b5090979650505050505050565b600080600080600060808688031215613a5057600080fd5b85356001600160401b0380821115613a6757600080fd5b613a7389838a0161389a565b90975095506020880135915080821115613a8c57600080fd5b50613a9988828901613947565b9350506040860135613aaa816136f0565b91506060860135613aba81613752565b809150509295509295909350565b600080600060408486031215613add57600080fd5b83356001600160401b0380821115613af457600080fd5b613b008783880161389a565b90955093506020860135915080821115613b1957600080fd5b50613b2686828701613947565b9150509250925092565b60008060408385031215613b4357600080fd5b8235613b4e816136f0565b946020939093013593505050565b60008060208385031215613b6f57600080fd5b82356001600160401b03811115613b8557600080fd5b613b918582860161389a565b90969095509350505050565b600081518084526020808501945080840160005b83811015613bd65781516001600160a01b031687529582019590820190600101613bb1565b509495945050505050565b60005b83811015613bfc578181015183820152602001613be4565b50506000910152565b60008151808452613c1d816020860160208601613be1565b601f01601f19169290920160200192915050565b84815260006020608081840152613c4b6080840187613b9d565b8381036040850152855180825282820190600581901b8301840184890160005b83811015613c9957601f19868403018552613c87838351613c05565b94870194925090860190600101613c6b565b505086810360608801528751808252908501935091505082860160005b82811015613cd257815184529284019290840190600101613cb6565b50919998505050505050505050565b60008060008060608587031215613cf757600080fd5b84356001600160401b0380821115613d0e57600080fd5b613d1a8883890161389a565b90965094506020870135915080821115613d3357600080fd5b50613d4087828801613947565b925050604085013561384e816136f0565b600080600060608486031215613d6657600080fd5b8335613d71816136f0565b95602085013595506040909401359392505050565b600080600060608486031215613d9b57600080fd5b833592506020840135613dad816136f0565b915060408401356137a0816136f0565b60008060008060408587031215613dd357600080fd5b84356001600160401b0380821115613dea57600080fd5b613df68883890161389a565b90965094506020870135915080821115613e0f57600080fd5b50613e1c8782880161389a565b95989497509550505050565b600080600060608486031215613e3d57600080fd5b8335613e48816136f0565b92506020840135613dad816136f0565b8481526001600160a01b0384166020820152608060408201819052600090613e8290830185613c05565b905082606083015295945050505050565b60008060408385031215613ea657600080fd5b8235613eb1816136f0565b9150602083013561372a81613752565b600080600060608486031215613ed657600080fd5b8335613ee1816136f0565b92506020840135915060408401356137a0816136f0565b60008060008060608587031215613f0e57600080fd5b84356001600160401b0380821115613f2557600080fd5b613f318883890161389a565b90965094506020870135915080821115613f4a57600080fd5b50613f5787828801613947565b925050604085013561384e81613752565b60006001600160401b03821115613f8157613f816138de565b50601f01601f191660200190565b600082601f830112613fa057600080fd5b8135613fae61396882613f68565b818152846020838601011115613fc357600080fd5b816020850160208301376000918101602001919091529392505050565b60008060008060808587031215613ff657600080fd5b843593506020850135614008816136f0565b925060408501356001600160401b038082111561402457600080fd5b61403088838901613f8f565b9350606087013591508082111561404657600080fd5b5061145487828801613f8f565b6020808252601f908201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c00604082015260600190565b634e487b7160e01b600052601160045260246000fd5b8082028115828204841417610e1e57610e1e61408a565b6000826140d457634e487b7160e01b600052601260045260246000fd5b500490565b6001600160a01b039290921682521515602082015260400190565b81810381811115610e1e57610e1e61408a565b80820180821115610e1e57610e1e61408a565b60006020828403121561412c57600080fd5b8151613581816136f0565b6001600160a01b03929092168252602082015260400190565b6001600160a01b0392831681529116602082015260400190565b634e487b7160e01b600052603260045260246000fd5b6000600182016141925761419261408a565b5060010190565b600082601f8301126141aa57600080fd5b81516141b861396882613f68565b8181528460208386010111156141cd57600080fd5b6141de826020830160208701613be1565b949350505050565b600082601f8301126141f757600080fd5b8151602061420761396883613924565b82815260059290921b8401810191818101908684111561422657600080fd5b8286015b848110156142655780516001600160401b038111156142495760008081fd5b6142578986838b0101614199565b84525091830191830161422a565b509695505050505050565b6000806040838503121561428357600080fd5b82516001600160401b038082111561429a57600080fd5b818501915085601f8301126142ae57600080fd5b815160206142be61396883613924565b82815260059290921b840181019181810190898411156142dd57600080fd5b948201945b838610156143045785516142f5816136f0565b825294820194908201906142e2565b9188015191965090935050508082111561431d57600080fd5b5061432a858286016141e6565b9150509250929050565b6000602080838503121561434757600080fd5b82516001600160401b0381111561435d57600080fd5b8301601f8101851361436e57600080fd5b805161437c61396882613924565b81815260059190911b8201830190838101908783111561439b57600080fd5b928401925b828410156136ac578351825292840192908401906143a0565b6000602082840312156143cb57600080fd5b81516001600160401b038111156143e157600080fd5b6141de84828501614199565b6000602082840312156143ff57600080fd5b5051919050565b6001600160a01b0385811682528416602082015260806040820181905260009061443290830185613c05565b82810360608401526136ac8185613c05565b6020808252602b908201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960408201526a6e697469616c697a696e6760a81b606082015260800190565b6001600160a01b03848116825283166020820152606060408201819052600090612ef790830184613b9d565b6000602082840312156144cd57600080fd5b815161358181613752565b600082516144ea818460208701613be1565b9190910192915050565b6020815260006135816020830184613c0556fe7cfff908a4b583f36430b25d75964c458d8ede8a99bd61be750e97ee1b2f3a96a26469706673582212207de0adbe72befa05ce3a3208de1b404f92c954fa41fc833dca52675b65d8e18664736f6c63430008130033
Deployed Bytecode
0x608060405234801561001057600080fd5b50600436106103195760003560e01c80636ca8365b116101a9578063b3db428b116100ef578063e6fd48bc1161009d578063e6fd48bc14610832578063e74fac201461083b578063efe33cfa1461084e578063f2fde38b14610861578063f3fef3a314610874578063fa2cc3c014610887578063fa454aae1461089a578063fe0079aa146108ad57600080fd5b8063b3db428b1461070f578063b790161914610722578063c22d145314610735578063c78f742014610748578063c9365cd5146107f9578063cf94fdf51461080c578063e00e07321461081f57600080fd5b806380f84f011161015757806380f84f011461065857806382dad4341461066b5780638456cb591461067e5780638da5cb5b146106865780639a47ce13146106975780639c7e2655146106aa578063ad05e627146106bd578063afe300a4146106e057600080fd5b80636ca8365b146105d85780636d687fed146105eb57806370a1198e1461060e578063715018a6146106215780637881946a146106295780637b46c54f1461063c578063804994b71461064f57600080fd5b80633a274c061161026e57806359e66af31161021c57806359e66af3146105535780635c85503c146105665780635c975abb146105795780636030a73614610584578063630b5ba1146105975780636669a9301461059f57806368ab633c146105b257806368e1add1146105c557600080fd5b80633a274c06146104c45780633b3f0ee6146104d75780633f4ba83a146104ea5780633fb056c2146104f2578063453114631461050557806347e7ef24146105185780635750ec531461052b57600080fd5b806311b4919f116102cb57806311b4919f1461041657806317caf6f1146104365780631d53d3e61461043f578063266f24b7146104625780632b32ced61461047557806330f668361461048857806337e51e8e146104b157600080fd5b8063011684371461031e57806306bfa9381461033357806306f821ee1461036b57806307337f2b1461037e578063081e3eda146103b15780630ba84cd2146103c35780630f208beb146103d6575b600080fd5b61033161032c366004613705565b6108c0565b005b610346610341366004613735565b610946565b6040805194855260208501939093529183015260608201526080015b60405180910390f35b610331610379366004613760565b610a08565b6103a161038c366004613735565b60d26020526000908152604090205460ff1681565b6040519015158152602001610362565b60cc545b604051908152602001610362565b6103316103d13660046137ab565b610a78565b6103466103e43660046137c4565b60cf60209081526000928352604080842090915290825290208054600182015460028301546003909301549192909184565b60ca54610429906001600160a01b031681565b60405161036291906137f2565b6103b560d05481565b6103a161044d366004613735565b60d36020526000908152604090205460ff1681565b610331610470366004613806565b610acf565b60c954610429906001600160a01b031681565b610429610496366004613735565b60ce602052600090815260409020546001600160a01b031681565b6103316104bf366004613859565b610b1f565b6103316104d2366004613a38565b610d01565b6104296104e53660046137c4565b610d49565b610331610e24565b610331610500366004613705565b610e36565b610331610513366004613ac8565b610e86565b610331610526366004613b30565b610ea2565b61053e6105393660046137c4565b610fa6565b60408051928352602083019190915201610362565b610331610561366004613735565b610fdb565b60d454610429906001600160a01b031681565b60975460ff166103a1565b610331610592366004613705565b611042565b61033161108f565b6103316105ad366004613705565b6110e7565b6103316105c0366004613b5c565b61115a565b6103316105d3366004613859565b611271565b60d654610429906001600160a01b031681565b6105fe6105f93660046137c4565b61131d565b6040516103629493929190613c31565b61033161061c366004613ce1565b611461565b610331611478565b610331610637366004613735565b61148a565b61033161064a366004613735565b611538565b6103b560cb5481565b610331610666366004613d51565b61165a565b610331610679366004613d86565b6117f2565b610331611806565b6033546001600160a01b0316610429565b6103316106a5366004613dbd565b611816565b6104296106b83660046137ab565b611a3a565b6106d06106cb366004613e28565b611a64565b6040516103629493929190613e58565b6104296106ee366004613735565b6001600160a01b03908116600090815260cd60205260409020600601541690565b61033161071d366004613859565b611ba6565b610331610730366004613e93565b611cad565b610331610743366004613735565b611ce0565b6107ac610756366004613735565b60cd6020526000908152604090208054600182015460028301546003840154600485015460058601546006909601546001600160a01b03958616969486169593949293919291811690600160a01b900460ff1688565b604080516001600160a01b03998a16815297891660208901528701959095526060860193909352608085019190915260a084015290921660c082015290151560e082015261010001610362565b610331610807366004613ec1565b611d3a565b61033161081a366004613b5c565b611e9f565b61033161082d366004613735565b611f06565b6103b560d15481565b610331610849366004613ef8565b611f61565b61033161085c366004613e93565b611f77565b61033161086f366004613735565b611fdb565b610331610882366004613b30565b612051565b60d554610429906001600160a01b031681565b6103316108a8366004613735565b612158565b6103316108bb366004613fe0565b6121b3565b6108c86122b8565b6002606554036108f35760405162461bcd60e51b81526004016108ea90614053565b60405180910390fd5b600260655560ca546001600160a01b031633146109235760405163d52ea75b60e01b815260040160405180910390fd5b60ca5461093d906001600160a01b031633838560016122fe565b50506001606555565b6001600160a01b03818116600090815260cd60209081526040808320815161010081018352815486168152600182015486169381019390935260028101549183018290526003810154606084015260048101546080840152600581015460a08401526006015493841660c0830152600160a01b90930460ff16151560e082015260d05460cb549293849384938493909290916109e291906140a0565b6109ec91906140b7565b604082015160a09092015160d054919892975095509350915050565b610a10612460565b6040516371daff7560e01b815283906001600160a01b038216906371daff7590610a4090869086906004016140d9565b600060405180830381600087803b158015610a5a57600080fd5b505af1158015610a6e573d6000803e3d6000fd5b5050505050505050565b610a80612460565b610a8861108f565b60cb805490829055604080518281526020810184905233917f1d75b4af369dd9c67d43994eea5f98a89dcaa2d64156061ae12a4eaaeb43ff08910160405180910390a25050565b33600090815260d2602052604090205460ff16158015610aef5750333014155b15610b0d5760405163f655705d60e01b815260040160405180910390fd5b610b19848484846124ba565b50505050565b33600081815260ce60209081526040808320546001600160a01b0390811680855260cd9093529220600101549092911614610b6d57604051639ed2ad3b60e01b815260040160405180910390fd5b33600090815260ce60209081526040808320546001600160a01b0390811680855260cd90935292209091861615610c13576001600160a01b03808316600090815260cf60209081526040808320938a168352929052208054610bd09086906140f4565b81556002810154610be29086906140f4565b60028201556004820154815464e8d4a5100091610bfe916140a0565b610c0891906140b7565b600190910155610c44565b6001600160a01b038216600090815260cd602052604081206005018054869290610c3e908490614107565b90915550505b6001600160a01b03851615610cc8576001600160a01b03808316600090815260cf602090815260408083209389168352929052208054610c85908690614107565b81556002810154610c97908690614107565b60028201556004820154815464e8d4a5100091610cb3916140a0565b610cbd91906140b7565b600190910155610cf9565b6001600160a01b038216600090815260cd602052604081206005018054869290610cf39084906140f4565b90915550505b505050505050565b610d096122b8565b60d5546001600160a01b03163314610d3457604051630c240a0760e11b815260040160405180910390fd5b610d428585843387866127e0565b5050505050565b33600090815260d2602052604081205460ff16158015610d695750333014155b15610d875760405163f655705d60e01b815260040160405180910390fd5b604051632d096c4f60e21b81526001600160a01b0380851660048301528316602482015230604482015233606482015260009073ae8e4bc88f792297a808cb5f32d4950fbbd8aeba9063b425b13c90608401602060405180830381865af4158015610df6573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610e1a919061411a565b9150505b92915050565b610e2c612460565b610e346129ba565b565b610e3e6122b8565b60d4546001600160a01b03163314610e695760405163806763cd60e01b815260040160405180910390fd5b60d454610e82906001600160a01b031682846001612a06565b5050565b610e8e6122b8565b610e9d838333338560016127e0565b505050565b610eaa6122b8565b600260655403610ecc5760405162461bcd60e51b81526004016108ea90614053565b60026065556001600160a01b03808316600090815260cd602052604090819020600181015491516340c10f1960e01b8152909291909116906340c10f1990610f1a9033908690600401614137565b600060405180830381600087803b158015610f3457600080fd5b505af1158015610f48573d6000803e3d6000fd5b50508254610f6492506001600160a01b03169050333085612b90565b60018101546040518381526001600160a01b03918216918516903390600080516020614508833981519152906020015b60405180910390a45050600160655550565b6001600160a01b03828116600090815260cf6020908152604080832093851683529290522080546002909101545b9250929050565b610fe3612460565b60ca80546001600160a01b038381166001600160a01b0319831681179093556040519116917f9067c50c8e02c1a44b029fbb43b4c2fdc9ffb0495c4795cd2dc144a2e3040c569161103691908490614150565b60405180910390a15050565b61104a6122b8565b60d4546001600160a01b031633146110755760405163806763cd60e01b815260040160405180910390fd5b60d454610e82906001600160a01b031633838560016122fe565b6110976122b8565b60005b60cc548110156110e4576110d460cc82815481106110ba576110ba61416a565b6000918252602090912001546001600160a01b0316611538565b6110dd81614180565b905061109a565b50565b6110ef6122b8565b6002606554036111115760405162461bcd60e51b81526004016108ea90614053565b600260655560ca546001600160a01b031633146111415760405163d52ea75b60e01b815260040160405180910390fd5b60ca5461093d906001600160a01b031682846001612a06565b611162612460565b60005b81811015610e9d5760008383838181106111815761118161416a565b90506020020160208101906111969190613735565b6001600160a01b03808216600090815260cd602052604090206006015491925016801561125c5760d6546040516371daff7560e01b81526001600160a01b03838116926371daff75926111f292909116906001906004016140d9565b600060405180830381600087803b15801561120c57600080fd5b505af1158015611220573d6000803e3d6000fd5b505050507feb634d56c1728cfbabdc5c85f7057217c21a80b7a2d3191b57c8e82176839ae48160405161125391906137f2565b60405180910390a15b5050808061126990614180565b915050611165565b33600081815260ce60209081526040808320546001600160a01b0390811680855260cd90935292206001015490929116146112bf57604051639ed2ad3b60e01b815260040160405180910390fd5b33600090815260ce60205260409020546001600160a01b03166112e181611538565b6001600160a01b038516156112fa576112fa8186612bfb565b836001600160a01b0316856001600160a01b031614610d4257610d428185612bfb565b6001600160a01b038216600090815260cd60205260408120606090819081906113468787612c3a565b60068201549095506001600160a01b031615611457578060060160009054906101000a90046001600160a01b03166001600160a01b03166345b507e36040518163ffffffff1660e01b8152600401600060405180830381865afa1580156113b1573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526113d99190810190614270565b60068301546040516352146cdb60e01b81529296509094506001600160a01b0316906352146cdb9061140f9089906004016137f2565b600060405180830381865afa15801561142c573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526114549190810190614334565b91505b5092959194509250565b6114696122b8565b610b19848483848660016127e0565b611480612460565b610e346000612d44565b611492612460565b60c9546001600160a01b0316156114bc576040516336d1e00560e11b815260040160405180910390fd5b6114c581612d96565b6114e25760405163cc8ea4f560e01b815260040160405180910390fd5b60c980546001600160a01b0319166001600160a01b0383161790556040517f28bd60b0cfa9ed243cddcb0a06776639d31979cb7acff48946c6806bd3be61049061152d9083906137f2565b60405180910390a150565b6115406122b8565b6001600160a01b038116600090815260cd6020526040902060038101544211158061156b575060d054155b15611574575050565b6005810154600081900361158d57504260039091015550565b600082600301544261159f91906140f4565b9050600060d054846002015460cb54846115b991906140a0565b6115c391906140a0565b6115cd91906140b7565b9050826115df8264e8d4a510006140a0565b6115e991906140b7565b84600401546115f89190614107565b60048501819055426003860181905560408051918252602082018690528101919091526001600160a01b038616907f50a1a2d4fcb1c08863a0b14fcc7d9d728e2b21d8d7588b9cfa3991efe8112ee79060600160405180910390a25050505050565b600054610100900460ff161580801561167a5750600054600160ff909116105b8061169b575061168930612d96565b15801561169b575060005460ff166001145b6116fe5760405162461bcd60e51b815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201526d191e481a5b9a5d1a585b1a5e995960921b60648201526084016108ea565b6000805460ff191660011790558015611721576000805461ff0019166101001790555b611729612da5565b611731612dd4565b611739612e03565b60c980546001600160a01b0386166001600160a01b031990911617905560cb83905560d1829055600060d081905560019060d29061177f6033546001600160a01b031690565b6001600160a01b031681526020810191909152604001600020805460ff19169115159190911790558015610b19576000805461ff0019169055604051600181527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb38474024989060200160405180910390a150505050565b6117fa612460565b610e9d838384846124ba565b61180e612460565b610e34612e32565b33600090815260d3602052604090205460ff1680611843575033600090815260d2602052604090205460ff165b8061185857506033546001600160a01b031633145b15611a2157828114611880576040516001621398b960e31b0319815260040160405180910390fd5b60005b83811015611a1b57600060cd60008787858181106118a3576118a361416a565b90506020020160208101906118b89190613735565b6001600160a01b03166001600160a01b031681526020019081526020016000206002015490508383838181106118f0576118f061416a565b905060200201358160d05461190591906140f4565b61190f9190614107565b60d0558383838181106119245761192461416a565b9050602002013560cd60008888868181106119415761194161416a565b90506020020160208101906119569190613735565b6001600160a01b031681526020810191909152604001600020600201557f9d1e399e9f825d6a92c706d1784017e4e9e8c44116b04bf9d7b3dcffa37eddc88686848181106119a6576119a661416a565b90506020020160208101906119bb9190613735565b828686868181106119ce576119ce61416a565b90506020020135604051611a00939291906001600160a01b039390931683526020830191909152604082015260600190565b60405180910390a15080611a1381614180565b915050611883565b50610b19565b604051633a6294b560e11b815260040160405180910390fd5b60cc8181548110611a4a57600080fd5b6000918252602090912001546001600160a01b0316905081565b6001600160a01b038316600090815260cd6020526040812081906060908290611a8d8888612c3a565b60068201549095506001600160a01b031615801590611ab457506001600160a01b03861615155b15611b9c5785866001600160a01b03166395d89b416040518163ffffffff1660e01b8152600401600060405180830381865afa158015611af8573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052611b2091908101906143b9565b600683015460405163211dc32d60e01b81529296509094506001600160a01b03169063211dc32d90611b58908a908a90600401614150565b602060405180830381865afa158015611b75573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611b9991906143ed565b91505b5093509350935093565b611bae6122b8565b600260655403611bd05760405162461bcd60e51b81526004016108ea90614053565b60026065556001600160a01b03808416600090815260cd602052604090819020600181015491516340c10f1960e01b8152909291909116906340c10f1990611c1e9086908690600401614137565b600060405180830381600087803b158015611c3857600080fd5b505af1158015611c4c573d6000803e3d6000fd5b50508254611c6892506001600160a01b03169050333085612b90565b60018101546040518381526001600160a01b039182169186811691908616906000805160206145088339815191529060200160405180910390a4505060016065555050565b611cb5612460565b6001600160a01b0391909116600090815260d360205260409020805460ff1916911515919091179055565b611ce8612460565b60d680546001600160a01b038381166001600160a01b0319831681179093556040519116917fb12eee8c2e1b5fc0a75061f2f305355fe9479f86daee2606a0162c2c09e39b1b91611036918491614150565b33600090815260d2602052604090205460ff16158015611d5a5750333014155b15611d785760405163f655705d60e01b815260040160405180910390fd5b611d8181612d96565b158015611d9657506001600160a01b03811615155b15611db45760405163b66f944760e01b815260040160405180910390fd5b6001600160a01b038316600090815260cd6020526040902060060154600160a01b900460ff16611df757604051636a325bd960e11b815260040160405180910390fd5b6001600160a01b038316600090815260cd602052604090206002015460d0548391611e21916140f4565b611e2b9190614107565b60d0556001600160a01b03838116600081815260cd60209081526040918290206002810187905560060180546001600160a01b031916948616948517905590518581527fdb56252d0d52575e1a437302556b299c2a995c7fd5c619b8efda785dcf597d2891015b60405180910390a3505050565b611ea76122b8565b6000816001600160401b03811115611ec157611ec16138de565b604051908082528060200260200182016040528015611ef457816020015b6060815260200190600190039081611edf5790505b509050610e9d838333338560016127e0565b611f0e612460565b60d580546001600160a01b038381166001600160a01b0319831681179093556040519116917f54894eb11869f8993d34c2e84d51ff771a5e43d1928cf8996a359f97155d8cb69161103691908490614150565b611f696122b8565b610b198484333386866127e0565b611f7f612460565b6001600160a01b038216600090815260d2602052604090819020805460ff191683151590811790915590517f26b10598e51169a6f63965086cafd8665e54b0ff538233804909efe8d5c5810d9161103691859160ff16906140d9565b611fe3612460565b6001600160a01b0381166120485760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b60648201526084016108ea565b6110e481612d44565b6120596122b8565b60026065540361207b5760405162461bcd60e51b81526004016108ea90614053565b60026065556001600160a01b03808316600090815260cd60205260409081902060018101549151632770a7eb60e21b815290929190911690639dc29fac906120c99033908690600401614137565b600060405180830381600087803b1580156120e357600080fd5b505af11580156120f7573d6000803e3d6000fd5b5050825461211292506001600160a01b031690503384612e6f565b60018101546040518381526001600160a01b039182169185169033907f3115d1449a7b732c986cba18244e897a450f61e1bb8d589cd2e69e6c8924f9f790602001610f94565b612160612460565b60d480546001600160a01b038381166001600160a01b03198316179092556040519116907fa36fc62da97ee1df24a48660c231c7e6d8a6b1821b2e53344d053b90701a89de906110369084908490614150565b6121bb612460565b604051630639860b60e51b815260009073ae8e4bc88f792297a808cb5f32d4950fbbd8aeba9063c730c160906121fb908790309088908890600401614406565b602060405180830381865af4158015612218573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061223c919061411a565b604051631d9f877360e11b81529091506000903090633b3f0ee6906122679085908590600401614150565b6020604051808303816000875af1158015612286573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906122aa919061411a565b9050610cf9868684846124ba565b60975460ff1615610e345760405162461bcd60e51b815260206004820152601060248201526f14185d5cd8589b194e881c185d5cd95960821b60448201526064016108ea565b6001600160a01b03808616600090815260cd6020908152604080832060cf8352818420948816845293909152902061233587611538565b61233f8786612bfb565b805461234c908590614107565b81558261237f578381600201546123639190614107565b6002820155815461237f906001600160a01b0316873087612b90565b6004820154815464e8d4a5100091612396916140a0565b6123a091906140b7565b6001820155831561245757838260050160008282546123bf9190614107565b909155508390506124095760018201546040518581526001600160a01b039182169189811691908816906000805160206145088339815191529060200160405180910390a4612457565b866001600160a01b0316856001600160a01b03167f6d0456143026caba846332ec09535fc3171dcd0c340cf99ad1668e75bfc1c7c88660405161244e91815260200190565b60405180910390a35b50505050505050565b6033546001600160a01b03163314610e345760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657260448201526064016108ea565b6124c383612d96565b15806124d557506124d382612d96565b155b156124f3576040516330704cfd60e11b815260040160405180910390fd5b6124fc81612d96565b15801561251157506001600160a01b03811615155b1561252f5760405163b66f944760e01b815260040160405180910390fd5b6001600160a01b038316600090815260cd6020526040902060060154600160a01b900460ff161561257357604051636d3acfdd60e01b815260040160405180910390fd5b600060d15442116125865760d154612588565b425b90508460d0546125989190614107565b60d08190555060cc849080600181540180825580915050600190039060005260206000200160009091909190916101000a8154816001600160a01b0302191690836001600160a01b03160217905550604051806101000160405280856001600160a01b03168152602001846001600160a01b031681526020018681526020018281526020016000815260200160008152602001836001600160a01b031681526020016001151581525060cd6000866001600160a01b03166001600160a01b0316815260200190815260200160002060008201518160000160006101000a8154816001600160a01b0302191690836001600160a01b0316021790555060208201518160010160006101000a8154816001600160a01b0302191690836001600160a01b0316021790555060408201518160020155606082015181600301556080820151816004015560a0820151816005015560c08201518160060160006101000a8154816001600160a01b0302191690836001600160a01b0316021790555060e08201518160060160146101000a81548160ff0219169083151502179055509050508360ce6000856001600160a01b03166001600160a01b0316815260200190815260200160002060006101000a8154816001600160a01b0302191690836001600160a01b03160217905550816001600160a01b0316836001600160a01b0316856001600160a01b03167f224e1c56d5a095bbae2a37104ca3c43212f7580c6ebb1b6b9ea1fb3eebb42e7c886040516127d191815260200190565b60405180910390a45050505050565b6002606554036128025760405162461bcd60e51b81526004016108ea90614053565b600260655581518590811461282d576040516001621398b960e31b0319815260040160405180910390fd5b60008060005b838110156129795760008a8a8381811061284f5761284f61416a565b90506020020160208101906128649190613735565b6001600160a01b03808216600090815260cf60209081526040808320938e1683529290522090915061289582611538565b600081600301546128a6848d612e8e565b6128b09190614107565b905087156128f85760ca546001600160a01b03908116908416036128df576128d88187614107565b95506128ec565b6128e98186614107565b94505b60006003830155612900565b600382018190555b6001600160a01b038316600090815260cd6020526040902060040154825464e8d4a510009161292e916140a0565b61293891906140b7565b8260010181905550612965838c8c8c88815181106129585761295861416a565b6020026020010151612f00565b5050508061297290614180565b9050612833565b5083612987575050506129ad565b811561299857612998878784613003565b80156129a9576129a9878783613100565b5050505b5050600160655550505050565b6129c261315d565b6097805460ff191690557f5db9ee0a495bf2e6ff9c91a7834c1ba4fdd244a5e8aa4e537bd38aeae4b073aa335b6040516129fc91906137f2565b60405180910390a1565b6001600160a01b03808516600090815260cd6020908152604080832060cf8352818420948816845293909152902082158015612a455750838160020154105b15612a635760405163e997875560e01b815260040160405180910390fd5b805484118015612a705750825b15612a8e57604051633bd20ca960e21b815260040160405180910390fd5b612a9786611538565b612aa186866131a6565b612aab86866131fb565b8054612ab89085906140f4565b815582612afa57838160020154612acf91906140f4565b60028201556001600160a01b03808716600090815260cd6020526040902054612afa91163386612e6f565b6004820154815464e8d4a5100091612b11916140a0565b612b1b91906140b7565b816001018190555083826005016000828254612b3791906140f4565b909155505060018201546040518581526001600160a01b039182169188811691908816907f3115d1449a7b732c986cba18244e897a450f61e1bb8d589cd2e69e6c8924f9f79060200160405180910390a4505050505050565b6040516001600160a01b0380851660248301528316604482015260648101829052610b199085906323b872dd60e01b906084015b60408051601f198184030181529190526020810180516001600160e01b03166001600160e01b031990931692909217909152613309565b6001600160a01b03808316600090815260cf602090815260408083209385168352929052205415612c3057612c3082826131a6565b610e8282826131fb565b6001600160a01b03808316600090815260cd6020908152604080832060cf835281842094861684529390915281206004830154600384015492939242118015612c865750600583015415155b15612cfb576000836003015442612c9d91906140f4565b9050600060d054856002015460cb5484612cb791906140a0565b612cc191906140a0565b612ccb91906140b7565b6005860154909150612ce28264e8d4a510006140a0565b612cec91906140b7565b612cf69084614107565b925050505b6001820154825464e8d4a5100090612d149084906140a0565b612d1e91906140b7565b612d2891906140f4565b9350816003015484612d3a9190614107565b9695505050505050565b603380546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b6001600160a01b03163b151590565b600054610100900460ff16612dcc5760405162461bcd60e51b81526004016108ea90614444565b610e346133db565b600054610100900460ff16612dfb5760405162461bcd60e51b81526004016108ea90614444565b610e3461340b565b600054610100900460ff16612e2a5760405162461bcd60e51b81526004016108ea90614444565b610e34613439565b612e3a6122b8565b6097805460ff191660011790557f62e78cea01bee320cd4e420270b5ea74000d11b0c9f74754ebdbfc544b05a2586129ef3390565b610e9d8363a9059cbb60e01b8484604051602401612bc4929190614137565b6001600160a01b03808316600081815260cf602090815260408083209486168352938152838220600181015493835260cd9091529281206004015483549193928492909164e8d4a5100091612ee391906140a0565b612eed91906140b7565b612ef791906140f4565b95945050505050565b6001600160a01b03808516600090815260cd6020526040902060060154168015610d4257815115612f92576040516369795e9360e01b81526001600160a01b038216906369795e9390612f5b9087908790879060040161448f565b600060405180830381600087803b158015612f7557600080fd5b505af1158015612f89573d6000803e3d6000fd5b50505050610d42565b604051636b09169560e01b81526001600160a01b03821690636b09169590612fc09087908790600401614150565b6020604051808303816000875af1158015612fdf573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610cf991906144bb565b60ca546001600160a01b03908116600090815260cd602052604090206006015460c954908216916130369116828461346c565b60405162e280a560e31b8152600481018390526001600160a01b03858116602483015284811660448301528216906307140528906064016020604051808303816000875af115801561308c573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906130b091906144bb565b5060408051838152600060208201526001600160a01b0380861692908716917f65f4901aaf030c6a056bf3ed5e6f41707bee06b5534c53867f2b83492dc2d748910160405180910390a350505050565b60c954613117906001600160a01b03168383612e6f565b60408051828152600060208201526001600160a01b0380851692908616917f65f4901aaf030c6a056bf3ed5e6f41707bee06b5534c53867f2b83492dc2d7489101611e92565b60975460ff16610e345760405162461bcd60e51b815260206004820152601460248201527314185d5cd8589b194e881b9bdd081c185d5cd95960621b60448201526064016108ea565b60006131b28383612e8e565b6001600160a01b03808516600090815260cf602090815260408083209387168352929052908120600301805492935083929091906131f1908490614107565b9091555050505050565b6001600160a01b03808316600090815260cd602052604090206006015460d65490821691161580159061323657506001600160a01b03811615155b156132a05760d65460405163ee96202f60e01b81526001600160a01b039091169063ee96202f9061326d9086908590600401614150565b600060405180830381600087803b15801561328757600080fd5b505af115801561329b573d6000803e3d6000fd5b505050505b6001600160a01b03811615610e9d576040516301c14b2d60e31b81526001600160a01b03821690630e0a5968906132db9085906004016137f2565b600060405180830381600087803b1580156132f557600080fd5b505af1158015612457573d6000803e3d6000fd5b600061335e826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b031661356f9092919063ffffffff16565b805190915015610e9d578080602001905181019061337c91906144bb565b610e9d5760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b60648201526084016108ea565b600054610100900460ff166134025760405162461bcd60e51b81526004016108ea90614444565b610e3433612d44565b600054610100900460ff166134325760405162461bcd60e51b81526004016108ea90614444565b6001606555565b600054610100900460ff166134605760405162461bcd60e51b81526004016108ea90614444565b6097805460ff19169055565b8015806134e55750604051636eb1769f60e11b81526001600160a01b0384169063dd62ed3e906134a29030908690600401614150565b602060405180830381865afa1580156134bf573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906134e391906143ed565b155b6135505760405162461bcd60e51b815260206004820152603660248201527f5361666545524332303a20617070726f76652066726f6d206e6f6e2d7a65726f60448201527520746f206e6f6e2d7a65726f20616c6c6f77616e636560501b60648201526084016108ea565b610e9d8363095ea7b360e01b8484604051602401612bc4929190614137565b606061357e8484600085613588565b90505b9392505050565b6060824710156135e95760405162461bcd60e51b815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f6044820152651c8818d85b1b60d21b60648201526084016108ea565b6135f285612d96565b61363e5760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e747261637400000060448201526064016108ea565b600080866001600160a01b0316858760405161365a91906144d8565b60006040518083038185875af1925050503d8060008114613697576040519150601f19603f3d011682016040523d82523d6000602084013e61369c565b606091505b50915091506136ac8282866136b7565b979650505050505050565b606083156136c6575081613581565b8251156136d65782518084602001fd5b8160405162461bcd60e51b81526004016108ea91906144f4565b6001600160a01b03811681146110e457600080fd5b6000806040838503121561371857600080fd5b82359150602083013561372a816136f0565b809150509250929050565b60006020828403121561374757600080fd5b8135613581816136f0565b80151581146110e457600080fd5b60008060006060848603121561377557600080fd5b8335613780816136f0565b92506020840135613790816136f0565b915060408401356137a081613752565b809150509250925092565b6000602082840312156137bd57600080fd5b5035919050565b600080604083850312156137d757600080fd5b82356137e2816136f0565b9150602083013561372a816136f0565b6001600160a01b0391909116815260200190565b6000806000806080858703121561381c57600080fd5b84359350602085013561382e816136f0565b9250604085013561383e816136f0565b9150606085013561384e816136f0565b939692955090935050565b60008060006060848603121561386e57600080fd5b8335613879816136f0565b92506020840135613889816136f0565b929592945050506040919091013590565b60008083601f8401126138ac57600080fd5b5081356001600160401b038111156138c357600080fd5b6020830191508360208260051b8501011115610fd457600080fd5b634e487b7160e01b600052604160045260246000fd5b604051601f8201601f191681016001600160401b038111828210171561391c5761391c6138de565b604052919050565b60006001600160401b0382111561393d5761393d6138de565b5060051b60200190565b600082601f83011261395857600080fd5b8135602061396d61396883613924565b6138f4565b828152600592831b850182019282820191908785111561398c57600080fd5b8387015b85811015613a2b5780356001600160401b038111156139af5760008081fd5b8801603f81018a136139c15760008081fd5b8581013560406139d361396883613924565b82815291851b8301810191888101908d8411156139f05760008081fd5b938201935b83851015613a1a5784359250613a0a836136f0565b82825293890193908901906139f5565b885250505093850193508401613990565b5090979650505050505050565b600080600080600060808688031215613a5057600080fd5b85356001600160401b0380821115613a6757600080fd5b613a7389838a0161389a565b90975095506020880135915080821115613a8c57600080fd5b50613a9988828901613947565b9350506040860135613aaa816136f0565b91506060860135613aba81613752565b809150509295509295909350565b600080600060408486031215613add57600080fd5b83356001600160401b0380821115613af457600080fd5b613b008783880161389a565b90955093506020860135915080821115613b1957600080fd5b50613b2686828701613947565b9150509250925092565b60008060408385031215613b4357600080fd5b8235613b4e816136f0565b946020939093013593505050565b60008060208385031215613b6f57600080fd5b82356001600160401b03811115613b8557600080fd5b613b918582860161389a565b90969095509350505050565b600081518084526020808501945080840160005b83811015613bd65781516001600160a01b031687529582019590820190600101613bb1565b509495945050505050565b60005b83811015613bfc578181015183820152602001613be4565b50506000910152565b60008151808452613c1d816020860160208601613be1565b601f01601f19169290920160200192915050565b84815260006020608081840152613c4b6080840187613b9d565b8381036040850152855180825282820190600581901b8301840184890160005b83811015613c9957601f19868403018552613c87838351613c05565b94870194925090860190600101613c6b565b505086810360608801528751808252908501935091505082860160005b82811015613cd257815184529284019290840190600101613cb6565b50919998505050505050505050565b60008060008060608587031215613cf757600080fd5b84356001600160401b0380821115613d0e57600080fd5b613d1a8883890161389a565b90965094506020870135915080821115613d3357600080fd5b50613d4087828801613947565b925050604085013561384e816136f0565b600080600060608486031215613d6657600080fd5b8335613d71816136f0565b95602085013595506040909401359392505050565b600080600060608486031215613d9b57600080fd5b833592506020840135613dad816136f0565b915060408401356137a0816136f0565b60008060008060408587031215613dd357600080fd5b84356001600160401b0380821115613dea57600080fd5b613df68883890161389a565b90965094506020870135915080821115613e0f57600080fd5b50613e1c8782880161389a565b95989497509550505050565b600080600060608486031215613e3d57600080fd5b8335613e48816136f0565b92506020840135613dad816136f0565b8481526001600160a01b0384166020820152608060408201819052600090613e8290830185613c05565b905082606083015295945050505050565b60008060408385031215613ea657600080fd5b8235613eb1816136f0565b9150602083013561372a81613752565b600080600060608486031215613ed657600080fd5b8335613ee1816136f0565b92506020840135915060408401356137a0816136f0565b60008060008060608587031215613f0e57600080fd5b84356001600160401b0380821115613f2557600080fd5b613f318883890161389a565b90965094506020870135915080821115613f4a57600080fd5b50613f5787828801613947565b925050604085013561384e81613752565b60006001600160401b03821115613f8157613f816138de565b50601f01601f191660200190565b600082601f830112613fa057600080fd5b8135613fae61396882613f68565b818152846020838601011115613fc357600080fd5b816020850160208301376000918101602001919091529392505050565b60008060008060808587031215613ff657600080fd5b843593506020850135614008816136f0565b925060408501356001600160401b038082111561402457600080fd5b61403088838901613f8f565b9350606087013591508082111561404657600080fd5b5061145487828801613f8f565b6020808252601f908201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c00604082015260600190565b634e487b7160e01b600052601160045260246000fd5b8082028115828204841417610e1e57610e1e61408a565b6000826140d457634e487b7160e01b600052601260045260246000fd5b500490565b6001600160a01b039290921682521515602082015260400190565b81810381811115610e1e57610e1e61408a565b80820180821115610e1e57610e1e61408a565b60006020828403121561412c57600080fd5b8151613581816136f0565b6001600160a01b03929092168252602082015260400190565b6001600160a01b0392831681529116602082015260400190565b634e487b7160e01b600052603260045260246000fd5b6000600182016141925761419261408a565b5060010190565b600082601f8301126141aa57600080fd5b81516141b861396882613f68565b8181528460208386010111156141cd57600080fd5b6141de826020830160208701613be1565b949350505050565b600082601f8301126141f757600080fd5b8151602061420761396883613924565b82815260059290921b8401810191818101908684111561422657600080fd5b8286015b848110156142655780516001600160401b038111156142495760008081fd5b6142578986838b0101614199565b84525091830191830161422a565b509695505050505050565b6000806040838503121561428357600080fd5b82516001600160401b038082111561429a57600080fd5b818501915085601f8301126142ae57600080fd5b815160206142be61396883613924565b82815260059290921b840181019181810190898411156142dd57600080fd5b948201945b838610156143045785516142f5816136f0565b825294820194908201906142e2565b9188015191965090935050508082111561431d57600080fd5b5061432a858286016141e6565b9150509250929050565b6000602080838503121561434757600080fd5b82516001600160401b0381111561435d57600080fd5b8301601f8101851361436e57600080fd5b805161437c61396882613924565b81815260059190911b8201830190838101908783111561439b57600080fd5b928401925b828410156136ac578351825292840192908401906143a0565b6000602082840312156143cb57600080fd5b81516001600160401b038111156143e157600080fd5b6141de84828501614199565b6000602082840312156143ff57600080fd5b5051919050565b6001600160a01b0385811682528416602082015260806040820181905260009061443290830185613c05565b82810360608401526136ac8185613c05565b6020808252602b908201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960408201526a6e697469616c697a696e6760a81b606082015260800190565b6001600160a01b03848116825283166020820152606060408201819052600090612ef790830184613b9d565b6000602082840312156144cd57600080fd5b815161358181613752565b600082516144ea818460208701613be1565b9190910192915050565b6020815260006135816020830184613c0556fe7cfff908a4b583f36430b25d75964c458d8ede8a99bd61be750e97ee1b2f3a96a26469706673582212207de0adbe72befa05ce3a3208de1b404f92c954fa41fc833dca52675b65d8e18664736f6c63430008130033
Loading...
Loading
Loading...
Loading
Multichain Portfolio | 30 Chains
Chain | Token | Portfolio % | Price | Amount | Value |
---|
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.