BscScan - Sponsored slots available. Book your slot here!
Overview
BNB Balance
0 BNB
BNB Value
$0.00Token Holdings
Latest 25 from a total of 100,194 transactions
Transaction Hash |
Method
|
Block
|
From
|
To
|
|||||
---|---|---|---|---|---|---|---|---|---|
Deposit | 44920316 | 34 secs ago | IN | 0 BNB | 0 | ||||
Deposit | 44920294 | 1 min ago | IN | 0 BNB | 0 | ||||
Deposit | 44920246 | 4 mins ago | IN | 0 BNB | 0 | ||||
Deposit | 44920220 | 5 mins ago | IN | 0 BNB | 0 | ||||
Execute Withdraw... | 44920193 | 6 mins ago | IN | 0 BNB | 0.00023977 | ||||
Deposit | 44920171 | 7 mins ago | IN | 0 BNB | 0 | ||||
Deposit | 44920137 | 9 mins ago | IN | 0 BNB | 0 | ||||
Deposit | 44919973 | 17 mins ago | IN | 0 BNB | 0 | ||||
Deposit | 44919972 | 17 mins ago | IN | 0 BNB | 0 | ||||
Deposit | 44919751 | 28 mins ago | IN | 0 BNB | 0 | ||||
Deposit | 44919750 | 28 mins ago | IN | 0 BNB | 0 | ||||
Deposit | 44919748 | 28 mins ago | IN | 0 BNB | 0 | ||||
Deposit | 44919743 | 29 mins ago | IN | 0 BNB | 0 | ||||
Deposit | 44919742 | 29 mins ago | IN | 0 BNB | 0 | ||||
Deposit | 44919740 | 29 mins ago | IN | 0 BNB | 0 | ||||
Execute Withdraw... | 44919612 | 35 mins ago | IN | 0 BNB | 0.00023977 | ||||
Deposit | 44919544 | 39 mins ago | IN | 0 BNB | 0 | ||||
Deposit | 44919412 | 45 mins ago | IN | 0 BNB | 0 | ||||
Deposit | 44919389 | 46 mins ago | IN | 0 BNB | 0 | ||||
Deposit | 44919348 | 48 mins ago | IN | 0 BNB | 0 | ||||
Deposit | 44919341 | 49 mins ago | IN | 0 BNB | 0.00017511 | ||||
Deposit | 44919329 | 49 mins ago | IN | 0 BNB | 0 | ||||
Deposit | 44919306 | 51 mins ago | IN | 0 BNB | 0 | ||||
Deposit | 44919148 | 58 mins ago | IN | 0 BNB | 0 | ||||
Deposit | 44919124 | 1 hr ago | IN | 0 BNB | 0 |
Loading...
Loading
Contract Name:
XVSVaultProxy
Compiler Version
v0.5.17+commit.d19bba13
Optimization Enabled:
Yes with 200 runs
Other Settings:
default evmVersion
Contract Source Code (Solidity Standard Json-Input format)
pragma solidity ^0.5.16; import "./XVSVaultStorage.sol"; import "./XVSVaultErrorReporter.sol"; contract XVSVaultProxy is XVSVaultAdminStorage, XVSVaultErrorReporter { /** * @notice Emitted when pendingXVSVaultImplementation is changed */ event NewPendingImplementation(address oldPendingImplementation, address newPendingImplementation); /** * @notice Emitted when pendingXVSVaultImplementation is accepted, which means XVS Vault implementation is updated */ event NewImplementation(address oldImplementation, address newImplementation); /** * @notice Emitted when pendingAdmin is changed */ event NewPendingAdmin(address oldPendingAdmin, address newPendingAdmin); /** * @notice Emitted when pendingAdmin is accepted, which means admin is updated */ event NewAdmin(address oldAdmin, address newAdmin); constructor() public { // Set admin to caller admin = msg.sender; } /*** Admin Functions ***/ function _setPendingImplementation(address newPendingImplementation) public returns (uint) { if (msg.sender != admin) { return fail(Error.UNAUTHORIZED, FailureInfo.SET_PENDING_IMPLEMENTATION_OWNER_CHECK); } address oldPendingImplementation = pendingXVSVaultImplementation; pendingXVSVaultImplementation = newPendingImplementation; emit NewPendingImplementation(oldPendingImplementation, pendingXVSVaultImplementation); return uint(Error.NO_ERROR); } /** * @notice Accepts new implementation of XVS Vault. msg.sender must be pendingImplementation * @dev Admin function for new implementation to accept it's role as implementation * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details) */ function _acceptImplementation() public returns (uint) { // Check caller is pendingImplementation if (msg.sender != pendingXVSVaultImplementation) { return fail(Error.UNAUTHORIZED, FailureInfo.ACCEPT_PENDING_IMPLEMENTATION_ADDRESS_CHECK); } // Save current values for inclusion in log address oldImplementation = implementation; address oldPendingImplementation = pendingXVSVaultImplementation; implementation = pendingXVSVaultImplementation; pendingXVSVaultImplementation = address(0); emit NewImplementation(oldImplementation, implementation); emit NewPendingImplementation(oldPendingImplementation, pendingXVSVaultImplementation); return uint(Error.NO_ERROR); } /** * @notice Begins transfer of admin rights. The newPendingAdmin must call `_acceptAdmin` to finalize the transfer. * @dev Admin function to begin change of admin. The newPendingAdmin must call `_acceptAdmin` to finalize the transfer. * @param newPendingAdmin New pending admin. * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details) */ function _setPendingAdmin(address newPendingAdmin) public returns (uint) { // Check caller = admin if (msg.sender != admin) { return fail(Error.UNAUTHORIZED, FailureInfo.SET_PENDING_ADMIN_OWNER_CHECK); } // Save current value, if any, for inclusion in log address oldPendingAdmin = pendingAdmin; // Store pendingAdmin with value newPendingAdmin pendingAdmin = newPendingAdmin; // Emit NewPendingAdmin(oldPendingAdmin, newPendingAdmin) emit NewPendingAdmin(oldPendingAdmin, newPendingAdmin); return uint(Error.NO_ERROR); } /** * @notice Accepts transfer of admin rights. msg.sender must be pendingAdmin * @dev Admin function for pending admin to accept role and update admin * @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details) */ function _acceptAdmin() public returns (uint) { // Check caller is pendingAdmin if (msg.sender != pendingAdmin) { return fail(Error.UNAUTHORIZED, FailureInfo.ACCEPT_ADMIN_PENDING_ADMIN_CHECK); } // Save current values for inclusion in log address oldAdmin = admin; address oldPendingAdmin = pendingAdmin; // Store admin with value pendingAdmin admin = pendingAdmin; // Clear the pending value pendingAdmin = address(0); emit NewAdmin(oldAdmin, admin); emit NewPendingAdmin(oldPendingAdmin, pendingAdmin); return uint(Error.NO_ERROR); } /** * @dev Delegates execution to an implementation contract. * It returns to the external caller whatever the implementation returns * or forwards reverts. */ function () external payable { // delegate all other functions to current implementation (bool success, ) = implementation.delegatecall(msg.data); assembly { let free_mem_ptr := mload(0x40) returndatacopy(free_mem_ptr, 0, returndatasize) switch success case 0 { revert(free_mem_ptr, returndatasize) } default { return(free_mem_ptr, returndatasize) } } } }
pragma solidity ^0.5.16; pragma experimental ABIEncoderV2; import "../Utils/ECDSA.sol"; import "../Utils/SafeBEP20.sol"; import "../Utils/IBEP20.sol"; import "./XVSVaultProxy.sol"; import "./XVSVaultStorage.sol"; import "./XVSVaultErrorReporter.sol"; interface IXVSStore { function safeRewardTransfer(address _token, address _to, uint256 _amount) external; function setRewardToken(address _tokenAddress, bool status) external; } contract XVSVault is XVSVaultStorage, ECDSA { using SafeMath for uint256; using SafeBEP20 for IBEP20; /// @notice Event emitted when deposit event Deposit(address indexed user, address indexed rewardToken, uint256 indexed pid, uint256 amount); /// @notice Event emitted when execute withrawal event ExecutedWithdrawal(address indexed user, address indexed rewardToken, uint256 indexed pid, uint256 amount); /// @notice Event emitted when request withrawal event ReqestedWithdrawal(address indexed user, address indexed rewardToken, uint256 indexed pid, uint256 amount); /// @notice Event emitted when admin changed event AdminTransferred(address indexed oldAdmin, address indexed newAdmin); /// @notice An event thats emitted when an account changes its delegate event DelegateChanged(address indexed delegator, address indexed fromDelegate, address indexed toDelegate); /// @notice An event thats emitted when a delegate account's vote balance changes event DelegateVotesChanged(address indexed delegate, uint previousBalance, uint newBalance); /// @notice An event emitted when the reward store address is updated event StoreUpdated(address oldXvs, address oldStore, address newXvs, address newStore); /// @notice An event emitted when the withdrawal locking period is updated for a pool event WithdrawalLockingPeriodUpdated( address indexed rewardToken, uint indexed pid, uint oldPeriod, uint newPeriod ); /// @notice An event emitted when the reward amount per block is modified for a pool event RewardAmountUpdated(address indexed rewardToken, uint oldReward, uint newReward); /// @notice An event emitted when a new pool is added event PoolAdded( address indexed rewardToken, uint indexed pid, address indexed token, uint allocPoints, uint rewardPerBlock, uint lockPeriod ); /// @notice An event emitted when a pool allocation points are updated event PoolUpdated( address indexed rewardToken, uint indexed pid, uint oldAllocPoints, uint newAllocPoints ); constructor() public { admin = msg.sender; } modifier onlyAdmin() { require(msg.sender == admin, "only admin can"); _; } /** * @dev Prevents a contract from calling itself, directly or indirectly. */ modifier nonReentrant() { require(_notEntered, "re-entered"); _notEntered = false; _; _notEntered = true; // get a gas-refund post-Istanbul } function poolLength(address rewardToken) external view returns (uint256) { return poolInfos[rewardToken].length; } /** * @notice Add a new token pool. Can only be called by the admin. * @dev This vault DOES NOT support deflationary tokens — it expects that * the amount of transferred tokens would equal the actually deposited * amount. In practice this means that this vault DOES NOT support USDT * and similar tokens (that do not provide these guarantees). */ function add( address _rewardToken, uint256 _allocPoint, IBEP20 _token, uint256 _rewardPerBlock, uint256 _lockPeriod ) external onlyAdmin { require(address(xvsStore) != address(0), "Store contract addres is empty"); massUpdatePools(_rewardToken); PoolInfo[] storage poolInfo = poolInfos[_rewardToken]; uint256 length = poolInfo.length; for (uint256 pid = 0; pid < length; ++pid) { require(poolInfo[pid].token != _token, "Error pool already added"); } totalAllocPoints[_rewardToken] = totalAllocPoints[_rewardToken].add(_allocPoint); rewardTokenAmountsPerBlock[_rewardToken] = _rewardPerBlock; poolInfo.push( PoolInfo({ token: _token, allocPoint: _allocPoint, lastRewardBlock: block.number, accRewardPerShare: 0, lockPeriod: _lockPeriod }) ); IXVSStore(xvsStore).setRewardToken(_rewardToken, true); emit PoolAdded( _rewardToken, poolInfo.length - 1, address(_token), _allocPoint, _rewardPerBlock, _lockPeriod ); } // Update the given pool's reward allocation point. Can only be called by the admin. function set( address _rewardToken, uint256 _pid, uint256 _allocPoint ) external onlyAdmin { _ensureValidPool(_rewardToken, _pid); massUpdatePools(_rewardToken); PoolInfo[] storage poolInfo = poolInfos[_rewardToken]; totalAllocPoints[_rewardToken] = totalAllocPoints[_rewardToken].sub(poolInfo[_pid].allocPoint).add( _allocPoint ); uint256 oldAllocPoints = poolInfo[_pid].allocPoint; poolInfo[_pid].allocPoint = _allocPoint; emit PoolUpdated(_rewardToken, _pid, oldAllocPoints, _allocPoint); } // Update the given reward token's amount per block function setRewardAmountPerBlock( address _rewardToken, uint256 _rewardAmount ) external onlyAdmin { massUpdatePools(_rewardToken); uint256 oldReward = rewardTokenAmountsPerBlock[_rewardToken]; rewardTokenAmountsPerBlock[_rewardToken] = _rewardAmount; emit RewardAmountUpdated(_rewardToken, oldReward, _rewardAmount); } // Update the given reward token's amount per block function setWithdrawalLockingPeriod( address _rewardToken, uint256 _pid, uint256 _newPeriod ) external onlyAdmin { _ensureValidPool(_rewardToken, _pid); require(_newPeriod > 0, "Invalid new locking period"); PoolInfo storage pool = poolInfos[_rewardToken][_pid]; uint256 oldPeriod = pool.lockPeriod; pool.lockPeriod = _newPeriod; emit WithdrawalLockingPeriodUpdated(_rewardToken, _pid, oldPeriod, _newPeriod); } /** * @notice Deposit XVSVault for XVS allocation * @param _rewardToken The Reward Token Address * @param _pid The Pool Index * @param _amount The amount to deposit to vault */ function deposit(address _rewardToken, uint256 _pid, uint256 _amount) external nonReentrant { _ensureValidPool(_rewardToken, _pid); PoolInfo storage pool = poolInfos[_rewardToken][_pid]; UserInfo storage user = userInfos[_rewardToken][_pid][msg.sender]; _updatePool(_rewardToken, _pid); if (user.amount > 0) { uint256 pending = user.amount.mul(pool.accRewardPerShare).div(1e12).sub( user.rewardDebt ); IXVSStore(xvsStore).safeRewardTransfer(_rewardToken, msg.sender, pending); } pool.token.safeTransferFrom( address(msg.sender), address(this), _amount ); user.amount = user.amount.add(_amount); user.rewardDebt = user.amount.mul(pool.accRewardPerShare).div(1e12); // Update Delegate Amount if (address(pool.token) == address(xvsAddress)) { uint256 updatedAmount = user.amount.sub(user.pendingWithdrawals); _updateDelegate(address(msg.sender), uint96(updatedAmount)); } emit Deposit(msg.sender, _rewardToken, _pid, _amount); } /** * @notice Pushes withdrawal request to the requests array and updates * the pending withdrawals amount. The requests are always sorted * by unlock time (descending) so that the earliest to execute requests * are always at the end of the array. * @param _user The user struct storage pointer * @param _requests The user's requests array storage pointer * @param _amount The amount being requested */ function pushWithdrawalRequest( UserInfo storage _user, WithdrawalRequest[] storage _requests, uint _amount, uint _lockedUntil ) internal { uint i = _requests.length; _requests.push(WithdrawalRequest(0, 0)); // Keep it sorted so that the first to get unlocked request is always at the end for (; i > 0 && _requests[i - 1].lockedUntil <= _lockedUntil; --i) { _requests[i] = _requests[i - 1]; } _requests[i] = WithdrawalRequest(_amount, _lockedUntil); _user.pendingWithdrawals = _user.pendingWithdrawals.add(_amount); } /** * @notice Pops the requests with unlock time < now from the requests * array and deducts the computed amount from the user's pending * withdrawals counter. Assumes that the requests array is sorted * by unclock time (descending). * @dev This function **removes** the eligible requests from the requests * array. If this function is called, the withdrawal should actually * happen (or the transaction should be reverted). * @param _user The user struct storage pointer * @param _requests The user's requests array storage pointer * @return The amount eligible for withdrawal (this amount should be * sent to the user, otherwise the state would be inconsistent). */ function popEligibleWithdrawalRequests( UserInfo storage _user, WithdrawalRequest[] storage _requests ) internal returns (uint withdrawalAmount) { // Since the requests are sorted by their unlock time, we can just // pop them from the array and stop at the first not-yet-eligible one for (uint i = _requests.length; i > 0 && isUnlocked(_requests[i - 1]); --i) { withdrawalAmount = withdrawalAmount.add(_requests[i - 1].amount); _requests.pop(); } _user.pendingWithdrawals = _user.pendingWithdrawals.sub(withdrawalAmount); return withdrawalAmount; } /** * @notice Checks if the request is eligible for withdrawal. * @param _request The request struct storage pointer * @return True if the request is eligible for withdrawal, false otherwise */ function isUnlocked(WithdrawalRequest storage _request) private view returns (bool) { return _request.lockedUntil <= block.timestamp; } /** * @notice Execute withdrawal to XVSVault for XVS allocation * @param _rewardToken The Reward Token Address * @param _pid The Pool Index */ function executeWithdrawal(address _rewardToken, uint256 _pid) external nonReentrant { _ensureValidPool(_rewardToken, _pid); PoolInfo storage pool = poolInfos[_rewardToken][_pid]; UserInfo storage user = userInfos[_rewardToken][_pid][msg.sender]; WithdrawalRequest[] storage requests = withdrawalRequests[_rewardToken][_pid][msg.sender]; uint256 _amount = popEligibleWithdrawalRequests(user, requests); require(_amount > 0, "nothing to withdraw"); _updatePool(_rewardToken, _pid); uint256 pending = user.amount.mul(pool.accRewardPerShare).div(1e12).sub( user.rewardDebt ); IXVSStore(xvsStore).safeRewardTransfer(_rewardToken, msg.sender, pending); user.amount = user.amount.sub(_amount); user.rewardDebt = user.amount.mul(pool.accRewardPerShare).div(1e12); pool.token.safeTransfer(address(msg.sender), _amount); emit ExecutedWithdrawal(msg.sender, _rewardToken, _pid, _amount); } /** * @notice Request withdrawal to XVSVault for XVS allocation * @param _rewardToken The Reward Token Address * @param _pid The Pool Index * @param _amount The amount to withdraw to vault */ function requestWithdrawal(address _rewardToken, uint256 _pid, uint256 _amount) external nonReentrant { _ensureValidPool(_rewardToken, _pid); require(_amount > 0, "requested amount cannot be zero"); UserInfo storage user = userInfos[_rewardToken][_pid][msg.sender]; require(user.amount >= user.pendingWithdrawals.add(_amount), "requested amount is invalid"); PoolInfo storage pool = poolInfos[_rewardToken][_pid]; WithdrawalRequest[] storage requests = withdrawalRequests[_rewardToken][_pid][msg.sender]; uint lockedUntil = pool.lockPeriod.add(block.timestamp); pushWithdrawalRequest(user, requests, _amount, lockedUntil); // Update Delegate Amount if (_rewardToken == address(xvsAddress)) { uint256 updatedAmount = user.amount.sub(user.pendingWithdrawals); _updateDelegate(address(msg.sender), uint96(updatedAmount)); } emit ReqestedWithdrawal(msg.sender, _rewardToken, _pid, _amount); } /** * @notice Get unlocked withdrawal amount * @param _rewardToken The Reward Token Address * @param _pid The Pool Index * @param _user The User Address */ function getEligibleWithdrawalAmount(address _rewardToken, uint256 _pid, address _user) external view returns (uint withdrawalAmount) { _ensureValidPool(_rewardToken, _pid); WithdrawalRequest[] storage requests = withdrawalRequests[_rewardToken][_pid][_user]; // Since the requests are sorted by their unlock time, we can take // the entries from the end of the array and stop at the first // not-yet-eligible one for (uint i = requests.length; i > 0 && isUnlocked(requests[i - 1]); --i) { withdrawalAmount = withdrawalAmount.add(requests[i - 1].amount); } return withdrawalAmount; } /** * @notice Get requested amount * @param _rewardToken The Reward Token Address * @param _pid The Pool Index * @param _user The User Address */ function getRequestedAmount(address _rewardToken, uint256 _pid, address _user) external view returns (uint256) { _ensureValidPool(_rewardToken, _pid); UserInfo storage user = userInfos[_rewardToken][_pid][_user]; return user.pendingWithdrawals; } /** * @notice Returns the array of withdrawal requests that have not been executed yet * @param _rewardToken The Reward Token Address * @param _pid The Pool Index * @param _user The User Address */ function getWithdrawalRequests(address _rewardToken, uint256 _pid, address _user) external view returns (WithdrawalRequest[] memory) { _ensureValidPool(_rewardToken, _pid); return withdrawalRequests[_rewardToken][_pid][_user]; } // View function to see pending XVSs on frontend. function pendingReward(address _rewardToken, uint256 _pid, address _user) external view returns (uint256) { _ensureValidPool(_rewardToken, _pid); PoolInfo storage pool = poolInfos[_rewardToken][_pid]; UserInfo storage user = userInfos[_rewardToken][_pid][_user]; uint256 accRewardPerShare = pool.accRewardPerShare; uint256 supply = pool.token.balanceOf(address(this)); uint256 curBlockNumber = block.number; uint256 rewardTokenPerBlock = rewardTokenAmountsPerBlock[_rewardToken]; if (curBlockNumber > pool.lastRewardBlock && supply != 0) { uint256 multiplier = curBlockNumber.sub(pool.lastRewardBlock); uint256 reward = multiplier.mul(rewardTokenPerBlock).mul(pool.allocPoint).div( totalAllocPoints[_rewardToken] ); accRewardPerShare = accRewardPerShare.add( reward.mul(1e12).div(supply) ); } return user.amount.mul(accRewardPerShare).div(1e12).sub(user.rewardDebt); } // Update reward vairables for all pools. Be careful of gas spending! function massUpdatePools(address _rewardToken) public { uint256 length = poolInfos[_rewardToken].length; for (uint256 pid = 0; pid < length; ++pid) { _updatePool(_rewardToken, pid); } } function updatePool(address _rewardToken, uint256 _pid) external { _ensureValidPool(_rewardToken, _pid); _updatePool(_rewardToken, _pid); } // Update reward variables of the given pool to be up-to-date. function _updatePool(address _rewardToken, uint256 _pid) internal { PoolInfo storage pool = poolInfos[_rewardToken][_pid]; if (block.number <= pool.lastRewardBlock) { return; } uint256 supply = pool.token.balanceOf(address(this)); if (supply == 0) { pool.lastRewardBlock = block.number; return; } uint256 curBlockNumber = block.number; uint256 multiplier = curBlockNumber.sub(pool.lastRewardBlock); uint256 reward = multiplier.mul(rewardTokenAmountsPerBlock[_rewardToken]).mul(pool.allocPoint).div( totalAllocPoints[_rewardToken] ); pool.accRewardPerShare = pool.accRewardPerShare.add( reward.mul(1e12).div(supply) ); pool.lastRewardBlock = block.number; } function _ensureValidPool(address rewardToken, uint256 pid) internal view { require(pid < poolInfos[rewardToken].length , "vault: pool exists?"); } // Get user info with reward token address and pid function getUserInfo( address _rewardToken, uint256 _pid, address _user ) external view returns (uint256 amount, uint256 rewardDebt, uint256 pendingWithdrawals) { _ensureValidPool(_rewardToken, _pid); UserInfo storage user = userInfos[_rewardToken][_pid][_user]; amount = user.amount; rewardDebt = user.rewardDebt; pendingWithdrawals = user.pendingWithdrawals; } /** * @notice Get the XVS stake balance of an account (excluding the pending withdrawals) * @param account The address of the account to check * @return The balance that user staked */ function getStakeAmount(address account) internal view returns (uint96) { require(xvsAddress != address(0), "XVSVault::getStakeAmount: xvs address is not set"); PoolInfo[] storage poolInfo = poolInfos[xvsAddress]; uint256 length = poolInfo.length; for (uint256 pid = 0; pid < length; ++pid) { if (address(poolInfo[pid].token) == address(xvsAddress)) { UserInfo storage user = userInfos[xvsAddress][pid][account]; return uint96(user.amount.sub(user.pendingWithdrawals)); } } return uint96(0); } /** * @notice Update Delegates - voting power * @param delegator The address of Delegator * @param amount Updated delegate amount */ function _updateDelegate(address delegator, uint96 amount) internal { address currentDelegate = delegates[delegator]; if (currentDelegate != address(0)) { uint32 delegateRepNum = numCheckpoints[currentDelegate]; uint96 delegateRepOld = delegateRepNum > 0 ? checkpoints[currentDelegate][delegateRepNum - 1].votes : 0; _writeCheckpoint(currentDelegate, delegateRepNum, delegateRepOld, amount); } } /** * @notice Delegate votes from `msg.sender` to `delegatee` * @param delegatee The address to delegate votes to */ function delegate(address delegatee) external { return _delegate(msg.sender, delegatee); } /** * @notice Delegates votes from signatory to `delegatee` * @param delegatee The address to delegate votes to * @param nonce The contract state required to match the signature * @param expiry The time at which to expire the signature * @param v The recovery byte of the signature * @param r Half of the ECDSA signature pair * @param s Half of the ECDSA signature pair */ function delegateBySig(address delegatee, uint nonce, uint expiry, uint8 v, bytes32 r, bytes32 s) external { bytes32 domainSeparator = keccak256(abi.encode(DOMAIN_TYPEHASH, keccak256(bytes("XVSVault")), getChainId(), address(this))); bytes32 structHash = keccak256(abi.encode(DELEGATION_TYPEHASH, delegatee, nonce, expiry)); bytes32 digest = keccak256(abi.encodePacked("\x19\x01", domainSeparator, structHash)); address signatory = ECDSA.recover(digest, v, r, s); require(nonce == nonces[signatory]++, "XVSVault::delegateBySig: invalid nonce"); require(block.timestamp <= expiry, "XVSVault::delegateBySig: signature expired"); return _delegate(signatory, delegatee); } /** * @notice Gets the current votes balance for `account` * @param account The address to get votes balance * @return The number of current votes for `account` */ function getCurrentVotes(address account) external view returns (uint96) { uint32 nCheckpoints = numCheckpoints[account]; return nCheckpoints > 0 ? checkpoints[account][nCheckpoints - 1].votes : 0; } function _delegate(address delegator, address delegatee) internal { address currentDelegate = delegates[delegator]; uint96 delegatorBalance = getStakeAmount(delegator); delegates[delegator] = delegatee; emit DelegateChanged(delegator, currentDelegate, delegatee); _moveDelegates(currentDelegate, delegatee, delegatorBalance); } function _moveDelegates(address srcRep, address dstRep, uint96 amount) internal { if (srcRep != dstRep && amount > 0) { if (srcRep != address(0)) { uint32 srcRepNum = numCheckpoints[srcRep]; uint96 srcRepOld = srcRepNum > 0 ? checkpoints[srcRep][srcRepNum - 1].votes : 0; uint96 srcRepNew = sub96(srcRepOld, amount, "XVSVault::_moveVotes: vote amount underflows"); _writeCheckpoint(srcRep, srcRepNum, srcRepOld, srcRepNew); } if (dstRep != address(0)) { uint32 dstRepNum = numCheckpoints[dstRep]; uint96 dstRepOld = dstRepNum > 0 ? checkpoints[dstRep][dstRepNum - 1].votes : 0; uint96 dstRepNew = add96(dstRepOld, amount, "XVSVault::_moveVotes: vote amount overflows"); _writeCheckpoint(dstRep, dstRepNum, dstRepOld, dstRepNew); } } } function _writeCheckpoint(address delegatee, uint32 nCheckpoints, uint96 oldVotes, uint96 newVotes) internal { uint32 blockNumber = safe32(block.number, "XVSVault::_writeCheckpoint: block number exceeds 32 bits"); if (nCheckpoints > 0 && checkpoints[delegatee][nCheckpoints - 1].fromBlock == blockNumber) { checkpoints[delegatee][nCheckpoints - 1].votes = newVotes; } else { checkpoints[delegatee][nCheckpoints] = Checkpoint(blockNumber, newVotes); numCheckpoints[delegatee] = nCheckpoints + 1; } emit DelegateVotesChanged(delegatee, oldVotes, newVotes); } function safe32(uint n, string memory errorMessage) internal pure returns (uint32) { require(n < 2**32, errorMessage); return uint32(n); } function safe96(uint n, string memory errorMessage) internal pure returns (uint96) { require(n < 2**96, errorMessage); return uint96(n); } function add96(uint96 a, uint96 b, string memory errorMessage) internal pure returns (uint96) { uint96 c = a + b; require(c >= a, errorMessage); return c; } function sub96(uint96 a, uint96 b, string memory errorMessage) internal pure returns (uint96) { require(b <= a, errorMessage); return a - b; } function getChainId() internal pure returns (uint) { uint256 chainId; assembly { chainId := chainid() } return chainId; } /** * @notice Determine the xvs stake balance for an account * @param account The address of the account to check * @param blockNumber The block number to get the vote balance at * @return The balance that user staked */ function getPriorVotes(address account, uint256 blockNumber) external view returns (uint96) { require(blockNumber < block.number, "XVSVault::getPriorVotes: not yet determined"); uint32 nCheckpoints = numCheckpoints[account]; if (nCheckpoints == 0) { return 0; } // First check most recent balance if (checkpoints[account][nCheckpoints - 1].fromBlock <= blockNumber) { return checkpoints[account][nCheckpoints - 1].votes; } // Next check implicit zero balance if (checkpoints[account][0].fromBlock > blockNumber) { return 0; } uint32 lower = 0; uint32 upper = nCheckpoints - 1; while (upper > lower) { uint32 center = upper - (upper - lower) / 2; // ceil, avoiding overflow Checkpoint memory cp = checkpoints[account][center]; if (cp.fromBlock == blockNumber) { return cp.votes; } else if (cp.fromBlock < blockNumber) { lower = center; } else { upper = center - 1; } } return checkpoints[account][lower].votes; } /** * @dev Returns the address of the current admin */ function getAdmin() external view returns (address) { return admin; } /** * @dev Burn the current admin */ function burnAdmin() external onlyAdmin { emit AdminTransferred(admin, address(0)); admin = address(0); } /*** Admin Functions ***/ function _become(XVSVaultProxy xvsVaultProxy) external { require(msg.sender == xvsVaultProxy.admin(), "only proxy admin can change brains"); require(xvsVaultProxy._acceptImplementation() == 0, "change not authorized"); } function setXvsStore(address _xvs, address _xvsStore) external onlyAdmin { address oldXvsContract = xvsAddress; address oldStore = xvsStore; xvsAddress = _xvs; xvsStore = _xvsStore; _notEntered = true; emit StoreUpdated(oldXvsContract, oldStore, _xvs, _xvsStore); } }
pragma solidity ^0.5.16; contract XVSVaultErrorReporter { enum Error { NO_ERROR, UNAUTHORIZED } enum FailureInfo { ACCEPT_ADMIN_PENDING_ADMIN_CHECK, ACCEPT_PENDING_IMPLEMENTATION_ADDRESS_CHECK, SET_PENDING_ADMIN_OWNER_CHECK, SET_PENDING_IMPLEMENTATION_OWNER_CHECK } /** * @dev `error` corresponds to enum Error; `info` corresponds to enum FailureInfo, and `detail` is an arbitrary * contract-specific code that enables us to report opaque error codes from upgradeable contracts. **/ event Failure(uint error, uint info, uint detail); /** * @dev use this when reporting a known error from the money market or a non-upgradeable collaborator */ function fail(Error err, FailureInfo info) internal returns (uint) { emit Failure(uint(err), uint(info), 0); return uint(err); } /** * @dev use this when reporting an opaque error from an upgradeable collaborator contract */ function failOpaque(Error err, FailureInfo info, uint opaqueError) internal returns (uint) { emit Failure(uint(err), uint(info), opaqueError); return uint(err); } }
pragma solidity ^0.5.16; import "../Utils/SafeMath.sol"; import "../Utils/IBEP20.sol"; contract XVSVaultAdminStorage { /** * @notice Administrator for this contract */ address public admin; /** * @notice Pending administrator for this contract */ address public pendingAdmin; /** * @notice Active brains of XVS Vault */ address public implementation; /** * @notice Pending brains of XVS Vault */ address public pendingXVSVaultImplementation; } contract XVSVaultStorage is XVSVaultAdminStorage { /// @notice Guard variable for re-entrancy checks bool internal _notEntered; /// @notice The reward token store address public xvsStore; /// @notice The xvs token address address public xvsAddress; // Reward tokens created per block indentified by reward token address. mapping(address => uint256) public rewardTokenAmountsPerBlock; /// @notice Info of each user. struct UserInfo { uint256 amount; uint256 rewardDebt; uint256 pendingWithdrawals; } // Info of each pool. struct PoolInfo { IBEP20 token; // Address of token contract to stake. uint256 allocPoint; // How many allocation points assigned to this pool. uint256 lastRewardBlock; // Last block number that reward tokens distribution occurs. uint256 accRewardPerShare; // Accumulated per share, times 1e12. See below. uint256 lockPeriod; // Min time between withdrawal request and its execution. } // Infomation about a withdrawal request struct WithdrawalRequest { uint256 amount; uint256 lockedUntil; } // Info of each user that stakes tokens. mapping(address => mapping(uint256 => mapping(address => UserInfo))) userInfos; // Info of each pool. mapping(address => PoolInfo[]) public poolInfos; // Total allocation points. Must be the sum of all allocation points in all pools. mapping(address => uint256) public totalAllocPoints; // Info of requested but not yet executed withdrawals mapping(address => mapping(uint256 => mapping(address => WithdrawalRequest[]))) withdrawalRequests; /// @notice A record of each accounts delegate mapping (address => address) public delegates; /// @notice A checkpoint for marking number of votes from a given block struct Checkpoint { uint32 fromBlock; uint96 votes; } /// @notice A record of votes checkpoints for each account, by index mapping (address => mapping (uint32 => Checkpoint)) public checkpoints; /// @notice The number of checkpoints for each account mapping (address => uint32) public numCheckpoints; /// @notice A record of states for signing / validating signatures mapping (address => uint) public nonces; /// @notice The EIP-712 typehash for the contract's domain bytes32 public constant DOMAIN_TYPEHASH = keccak256("EIP712Domain(string name,uint256 chainId,address verifyingContract)"); /// @notice The EIP-712 typehash for the delegation struct used by the contract bytes32 public constant DELEGATION_TYPEHASH = keccak256("Delegation(address delegatee,uint256 nonce,uint256 expiry)"); }
pragma solidity ^0.5.0; /** * @dev Interface of the BEP20 standard as defined in the EIP. Does not include * the optional functions; to access them see {BEP20Detailed}. */ interface IBEP20 { /** * @dev Returns the amount of tokens in existence. */ function totalSupply() external view returns (uint256); /** * @dev Returns the amount of tokens owned by `account`. */ function balanceOf(address account) external view returns (uint256); /** * @dev Moves `amount` tokens from the caller's account to `recipient`. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transfer(address recipient, uint256 amount) external returns (bool); /** * @dev Returns the remaining number of tokens that `spender` will be * allowed to spend on behalf of `owner` through {transferFrom}. This is * zero by default. * * This value changes when {approve} or {transferFrom} are called. */ function allowance(address owner, address spender) external view returns (uint256); /** * @dev Sets `amount` as the allowance of `spender` over the caller's tokens. * * Returns a boolean value indicating whether the operation succeeded. * * IMPORTANT: Beware that changing an allowance with this method brings the risk * that someone may use both the old and the new allowance by unfortunate * transaction ordering. One possible solution to mitigate this race * condition is to first reduce the spender's allowance to 0 and set the * desired value afterwards: * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 * * Emits an {Approval} event. */ function approve(address spender, uint256 amount) external returns (bool); /** * @dev Moves `amount` tokens from `sender` to `recipient` using the * allowance mechanism. `amount` is then deducted from the caller's * allowance. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transferFrom(address sender, address recipient, uint256 amount) external returns (bool); /** * @dev Emitted when `value` tokens are moved from one account (`from`) to * another (`to`). * * Note that `value` may be zero. */ event Transfer(address indexed from, address indexed to, uint256 value); /** * @dev Emitted when the allowance of a `spender` for an `owner` is set by * a call to {approve}. `value` is the new allowance. */ event Approval(address indexed owner, address indexed spender, uint256 value); }
pragma solidity ^0.5.0; import "./IBEP20.sol"; import "./SafeMath.sol"; import "./Address.sol"; /** * @title SafeBEP20 * @dev Wrappers around BEP20 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 SafeBEP20 for BEP20;` statement to your contract, * which allows you to call the safe operations as `token.safeTransfer(...)`, etc. */ library SafeBEP20 { using SafeMath for uint256; using Address for address; function safeTransfer(IBEP20 token, address to, uint256 value) internal { callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value)); } function safeTransferFrom(IBEP20 token, address from, address to, uint256 value) internal { callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value)); } function safeApprove(IBEP20 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' // solhint-disable-next-line max-line-length require((value == 0) || (token.allowance(address(this), spender) == 0), "SafeBEP20: approve from non-zero to non-zero allowance" ); callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value)); } function safeIncreaseAllowance(IBEP20 token, address spender, uint256 value) internal { uint256 newAllowance = token.allowance(address(this), spender).add(value); callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance)); } function safeDecreaseAllowance(IBEP20 token, address spender, uint256 value) internal { uint256 newAllowance = token.allowance(address(this), spender).sub(value, "SafeBEP20: decreased allowance below zero"); callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance)); } /** * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement * on the return value: the return value is optional (but if data is returned, it must not be false). * @param token The token targeted by the call. * @param data The call data (encoded using abi.encode or one of its variants). */ function callOptionalReturn(IBEP20 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. // A Solidity high level call has three parts: // 1. The target address is checked to verify it contains contract code // 2. The call itself is made, and success asserted // 3. The return value is decoded, which in turn checks the size of the returned data. // solhint-disable-next-line max-line-length require(address(token).isContract(), "SafeBEP20: call to non-contract"); // solhint-disable-next-line avoid-low-level-calls (bool success, bytes memory returndata) = address(token).call(data); require(success, "SafeBEP20: low-level call failed"); if (returndata.length > 0) { // Return data is optional // solhint-disable-next-line max-line-length require(abi.decode(returndata, (bool)), "SafeBEP20: BEP20 operation did not succeed"); } } }
// SPDX-License-Identifier: MIT // Adapted from OpenZeppelin Contracts v4.3.2 (utils/cryptography/ECDSA.sol) // SPDX-Copyright-Text: OpenZeppelin, 2021 // SPDX-Copyright-Text: Venus, 2021 pragma solidity ^0.5.16; /** * @dev Elliptic Curve Digital Signature Algorithm (ECDSA) operations. * * These functions can be used to verify that a message was signed by the holder * of the private keys of a given address. */ contract ECDSA { enum RecoverError { NoError, InvalidSignature, InvalidSignatureLength, InvalidSignatureS, InvalidSignatureV } function _throwError(RecoverError error) private pure { if (error == RecoverError.NoError) { return; // no error: do nothing } else if (error == RecoverError.InvalidSignature) { revert("ECDSA: invalid signature"); } else if (error == RecoverError.InvalidSignatureLength) { revert("ECDSA: invalid signature length"); } else if (error == RecoverError.InvalidSignatureS) { revert("ECDSA: invalid signature 's' value"); } else if (error == RecoverError.InvalidSignatureV) { revert("ECDSA: invalid signature 'v' value"); } } /** * @dev Returns the address that signed a hashed message (`hash`) with * `signature`. This address can then be used for verification purposes. * * The `ecrecover` EVM opcode allows for malleable (non-unique) signatures: * this function rejects them by requiring the `s` value to be in the lower * half order, and the `v` value to be either 27 or 28. * * IMPORTANT: `hash` _must_ be the result of a hash operation for the * verification to be secure: it is possible to craft signatures that * recover to arbitrary addresses for non-hashed data. A safe way to ensure * this is by receiving a hash of the original message (which may otherwise * be too long), and then calling {toEthSignedMessageHash} on it. */ function recover( bytes32 hash, uint8 v, bytes32 r, bytes32 s ) internal pure returns (address) { (address recovered, RecoverError error) = tryRecover(hash, v, r, s); _throwError(error); return recovered; } /** * @dev Returns the address that signed a hashed message (`hash`) with * `signature` or error string. This address can then be used for verification purposes. * * The `ecrecover` EVM opcode allows for malleable (non-unique) signatures: * this function rejects them by requiring the `s` value to be in the lower * half order, and the `v` value to be either 27 or 28. * * IMPORTANT: `hash` _must_ be the result of a hash operation for the * verification to be secure: it is possible to craft signatures that * recover to arbitrary addresses for non-hashed data. A safe way to ensure * this is by receiving a hash of the original message (which may otherwise * be too long), and then calling {toEthSignedMessageHash} on it. * * Documentation for signature generation: * - with https://web3js.readthedocs.io/en/v1.3.4/web3-eth-accounts.html#sign[Web3.js] * - with https://docs.ethers.io/v5/api/signer/#Signer-signMessage[ethers] * * _Available since v4.3._ */ function tryRecover( bytes32 hash, uint8 v, bytes32 r, bytes32 s ) internal pure returns (address, RecoverError) { // EIP-2 still allows signature malleability for ecrecover(). Remove this possibility and make the signature // unique. Appendix F in the Ethereum Yellow paper (https://ethereum.github.io/yellowpaper/paper.pdf), defines // the valid range for s in (301): 0 < s < secp256k1n ÷ 2 + 1, and for v in (302): v ∈ {27, 28}. Most // signatures from current libraries generate a unique signature with an s-value in the lower half order. // // If your library generates malleable signatures, such as s-values in the upper range, calculate a new s-value // with 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEBAAEDCE6AF48A03BBFD25E8CD0364141 - s1 and flip v from 27 to 28 or // vice versa. If your library also generates signatures with 0/1 for v instead 27/28, add 27 to v to accept // these malleable signatures as well. if (uint256(s) > 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF5D576E7357A4501DDFE92F46681B20A0) { return (address(0), RecoverError.InvalidSignatureS); } if (v != 27 && v != 28) { return (address(0), RecoverError.InvalidSignatureV); } // If the signature is valid (and not malleable), return the signer address address signer = ecrecover(hash, v, r, s); if (signer == address(0)) { return (address(0), RecoverError.InvalidSignature); } return (signer, RecoverError.NoError); } }
pragma solidity ^0.5.0; /** * @dev Wrappers over Solidity's arithmetic operations with added overflow * checks. * * Arithmetic operations in Solidity wrap on overflow. This can easily result * in bugs, because programmers usually assume that an overflow raises an * error, which is the standard behavior in high level programming languages. * `SafeMath` restores this intuition by reverting the transaction when an * operation overflows. * * Using this library instead of the unchecked operations eliminates an entire * class of bugs, so it's recommended to use it always. */ library SafeMath { /** * @dev Returns the addition of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `+` operator. * * Requirements: * - Addition cannot overflow. */ function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; require(c >= a, "SafeMath: addition overflow"); return c; } /** * @dev Returns the subtraction of two unsigned integers, reverting on * overflow (when the result is negative). * * Counterpart to Solidity's `-` operator. * * Requirements: * - Subtraction cannot overflow. */ function sub(uint256 a, uint256 b) internal pure returns (uint256) { return sub(a, b, "SafeMath: subtraction overflow"); } /** * @dev Returns the subtraction of two unsigned integers, reverting with custom message on * overflow (when the result is negative). * * Counterpart to Solidity's `-` operator. * * Requirements: * - Subtraction cannot overflow. * * _Available since v2.4.0._ */ function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b <= a, errorMessage); uint256 c = a - b; return c; } /** * @dev Returns the multiplication of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `*` operator. * * Requirements: * - Multiplication cannot overflow. */ function mul(uint256 a, uint256 b) internal pure returns (uint256) { // Gas optimization: this is cheaper than requiring 'a' not being zero, but the // benefit is lost if 'b' is also tested. // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522 if (a == 0) { return 0; } uint256 c = a * b; require(c / a == b, "SafeMath: multiplication overflow"); return c; } /** * @dev Returns the integer division of two unsigned integers. Reverts on * division by zero. The result is rounded towards zero. * * Counterpart to Solidity's `/` operator. Note: this function uses a * `revert` opcode (which leaves remaining gas untouched) while Solidity * uses an invalid opcode to revert (consuming all remaining gas). * * Requirements: * - The divisor cannot be zero. */ function div(uint256 a, uint256 b) internal pure returns (uint256) { return div(a, b, "SafeMath: division by zero"); } /** * @dev Returns the integer division of two unsigned integers. Reverts with custom message on * division by zero. The result is rounded towards zero. * * Counterpart to Solidity's `/` operator. Note: this function uses a * `revert` opcode (which leaves remaining gas untouched) while Solidity * uses an invalid opcode to revert (consuming all remaining gas). * * Requirements: * - The divisor cannot be zero. * * _Available since v2.4.0._ */ function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { // Solidity only automatically asserts when dividing by 0 require(b > 0, errorMessage); uint256 c = a / b; // assert(a == b * c + a % b); // There is no case in which this doesn't hold return c; } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * Reverts when dividing by zero. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * - The divisor cannot be zero. */ function mod(uint256 a, uint256 b) internal pure returns (uint256) { return mod(a, b, "SafeMath: modulo by zero"); } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * Reverts with custom message when dividing by zero. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * - The divisor cannot be zero. * * _Available since v2.4.0._ */ function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b != 0, errorMessage); return a % b; } }
pragma solidity ^0.5.5; /** * @dev Collection of functions related to the address type */ library Address { /** * @dev Returns true if `account` is a contract. * * [IMPORTANT] * ==== * It is unsafe to assume that an address for which this function returns * false is an externally-owned account (EOA) and not a contract. * * Among others, `isContract` will return false for the following * types of addresses: * * - an externally-owned account * - a contract in construction * - an address where a contract will be created * - an address where a contract lived, but was destroyed * ==== */ function isContract(address account) internal view returns (bool) { // According to EIP-1052, 0x0 is the value returned for not-yet created accounts // and 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470 is returned // for accounts without code, i.e. `keccak256('')` bytes32 codehash; bytes32 accountHash = 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470; // solhint-disable-next-line no-inline-assembly assembly { codehash := extcodehash(account) } return (codehash != accountHash && codehash != 0x0); } /** * @dev Converts an `address` into `address payable`. Note that this is * simply a type cast: the actual underlying value is not changed. * * _Available since v2.4.0._ */ function toPayable(address account) internal pure returns (address payable) { return address(uint160(account)); } /** * @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]. * * _Available since v2.4.0._ */ function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, "Address: insufficient balance"); // solhint-disable-next-line avoid-call-value // solium-disable-next-line security/no-call-value (bool success, ) = recipient.call.value(amount)(""); require(success, "Address: unable to send value, recipient may have reverted"); } }
{ "optimizer": { "enabled": true, "runs": 200 }, "outputSelection": { "*": { "*": [ "evm.bytecode", "evm.deployedBytecode", "devdoc", "userdoc", "metadata", "abi" ] } } }
Contract Security Audit
- No Contract Security Audit Submitted- Submit Audit Here
[{"inputs":[],"payable":false,"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"error","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"info","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"detail","type":"uint256"}],"name":"Failure","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"oldAdmin","type":"address"},{"indexed":false,"internalType":"address","name":"newAdmin","type":"address"}],"name":"NewAdmin","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"oldImplementation","type":"address"},{"indexed":false,"internalType":"address","name":"newImplementation","type":"address"}],"name":"NewImplementation","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"oldPendingAdmin","type":"address"},{"indexed":false,"internalType":"address","name":"newPendingAdmin","type":"address"}],"name":"NewPendingAdmin","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"oldPendingImplementation","type":"address"},{"indexed":false,"internalType":"address","name":"newPendingImplementation","type":"address"}],"name":"NewPendingImplementation","type":"event"},{"payable":true,"stateMutability":"payable","type":"fallback"},{"constant":false,"inputs":[],"name":"_acceptAdmin","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[],"name":"_acceptImplementation","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"newPendingAdmin","type":"address"}],"name":"_setPendingAdmin","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"newPendingImplementation","type":"address"}],"name":"_setPendingImplementation","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"admin","outputs":[{"internalType":"address","name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"implementation","outputs":[{"internalType":"address","name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"pendingAdmin","outputs":[{"internalType":"address","name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"pendingXVSVaultImplementation","outputs":[{"internalType":"address","name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"}]
Contract Creation Code
608060405234801561001057600080fd5b50600080546001600160a01b031916331790556105c3806100326000396000f3fe60806040526004361061007b5760003560e01c8063de0368b21161004e578063de0368b21461019e578063e992a041146101b3578063e9c714f2146101e6578063f851a440146101fb5761007b565b806326782247146100fe5780635c60da1b1461012f578063b71d1a0c14610144578063c1e8033414610189575b6002546040516000916001600160a01b031690829036908083838082843760405192019450600093509091505080830381855af49150503d80600081146100de576040519150601f19603f3d011682016040523d82523d6000602084013e6100e3565b606091505b505090506040513d6000823e8180156100fa573d82f35b3d82fd5b34801561010a57600080fd5b50610113610210565b604080516001600160a01b039092168252519081900360200190f35b34801561013b57600080fd5b5061011361021f565b34801561015057600080fd5b506101776004803603602081101561016757600080fd5b50356001600160a01b031661022e565b60408051918252519081900360200190f35b34801561019557600080fd5b506101776102bf565b3480156101aa57600080fd5b506101136103a4565b3480156101bf57600080fd5b50610177600480360360208110156101d657600080fd5b50356001600160a01b03166103b3565b3480156101f257600080fd5b50610177610437565b34801561020757600080fd5b50610113610512565b6001546001600160a01b031681565b6002546001600160a01b031681565b600080546001600160a01b031633146102545761024d60016002610521565b90506102ba565b600180546001600160a01b038481166001600160a01b0319831681179093556040805191909216808252602082019390935281517fca4f2f25d0898edd99413412fb94012f9e54ec8142f9b093e7720646a95b16a9929181900390910190a160005b9150505b919050565b6003546000906001600160a01b031633146102e6576102df600180610521565b90506103a1565b60028054600380546001600160a01b038082166001600160a01b031980861682179687905590921690925560408051938316808552949092166020840152815190927fd604de94d45953f9138079ec1b82d533cb2160c906d1076d1f7ed54befbca97a92908290030190a1600354604080516001600160a01b038085168252909216602083015280517fe945ccee5d701fc83f9b8aa8ca94ea4219ec1fcbd4f4cab4f0ea57c5c3e1d8159281900390910190a160005b925050505b90565b6003546001600160a01b031681565b600080546001600160a01b031633146103d25761024d60016003610521565b600380546001600160a01b038481166001600160a01b0319831617928390556040805192821680845293909116602083015280517fe945ccee5d701fc83f9b8aa8ca94ea4219ec1fcbd4f4cab4f0ea57c5c3e1d8159281900390910190a160006102b6565b6001546000906001600160a01b03163314610458576102df60016000610521565b60008054600180546001600160a01b038082166001600160a01b031980861682179687905590921690925560408051938316808552949092166020840152815190927ff9ffabca9c8276e99321725bcb43fb076a6c66a54b7f21c4e8146d8519b417dc92908290030190a1600154604080516001600160a01b038085168252909216602083015280517fca4f2f25d0898edd99413412fb94012f9e54ec8142f9b093e7720646a95b16a99281900390910190a1600061039c565b6000546001600160a01b031681565b60007f45b96fe442630264581b197e84bbada861235052c5a1aadfff9ea4e40a969aa083600181111561055057fe5b83600381111561055c57fe5b604080519283526020830191909152600082820152519081900360600190a182600181111561058757fe5b939250505056fea265627a7a72315820b8643106c8de1745345ceb68ac33793184125c35ac2d92a457d639298d519b9e64736f6c63430005110032
Deployed Bytecode
0x60806040526004361061007b5760003560e01c8063de0368b21161004e578063de0368b21461019e578063e992a041146101b3578063e9c714f2146101e6578063f851a440146101fb5761007b565b806326782247146100fe5780635c60da1b1461012f578063b71d1a0c14610144578063c1e8033414610189575b6002546040516000916001600160a01b031690829036908083838082843760405192019450600093509091505080830381855af49150503d80600081146100de576040519150601f19603f3d011682016040523d82523d6000602084013e6100e3565b606091505b505090506040513d6000823e8180156100fa573d82f35b3d82fd5b34801561010a57600080fd5b50610113610210565b604080516001600160a01b039092168252519081900360200190f35b34801561013b57600080fd5b5061011361021f565b34801561015057600080fd5b506101776004803603602081101561016757600080fd5b50356001600160a01b031661022e565b60408051918252519081900360200190f35b34801561019557600080fd5b506101776102bf565b3480156101aa57600080fd5b506101136103a4565b3480156101bf57600080fd5b50610177600480360360208110156101d657600080fd5b50356001600160a01b03166103b3565b3480156101f257600080fd5b50610177610437565b34801561020757600080fd5b50610113610512565b6001546001600160a01b031681565b6002546001600160a01b031681565b600080546001600160a01b031633146102545761024d60016002610521565b90506102ba565b600180546001600160a01b038481166001600160a01b0319831681179093556040805191909216808252602082019390935281517fca4f2f25d0898edd99413412fb94012f9e54ec8142f9b093e7720646a95b16a9929181900390910190a160005b9150505b919050565b6003546000906001600160a01b031633146102e6576102df600180610521565b90506103a1565b60028054600380546001600160a01b038082166001600160a01b031980861682179687905590921690925560408051938316808552949092166020840152815190927fd604de94d45953f9138079ec1b82d533cb2160c906d1076d1f7ed54befbca97a92908290030190a1600354604080516001600160a01b038085168252909216602083015280517fe945ccee5d701fc83f9b8aa8ca94ea4219ec1fcbd4f4cab4f0ea57c5c3e1d8159281900390910190a160005b925050505b90565b6003546001600160a01b031681565b600080546001600160a01b031633146103d25761024d60016003610521565b600380546001600160a01b038481166001600160a01b0319831617928390556040805192821680845293909116602083015280517fe945ccee5d701fc83f9b8aa8ca94ea4219ec1fcbd4f4cab4f0ea57c5c3e1d8159281900390910190a160006102b6565b6001546000906001600160a01b03163314610458576102df60016000610521565b60008054600180546001600160a01b038082166001600160a01b031980861682179687905590921690925560408051938316808552949092166020840152815190927ff9ffabca9c8276e99321725bcb43fb076a6c66a54b7f21c4e8146d8519b417dc92908290030190a1600154604080516001600160a01b038085168252909216602083015280517fca4f2f25d0898edd99413412fb94012f9e54ec8142f9b093e7720646a95b16a99281900390910190a1600061039c565b6000546001600160a01b031681565b60007f45b96fe442630264581b197e84bbada861235052c5a1aadfff9ea4e40a969aa083600181111561055057fe5b83600381111561055c57fe5b604080519283526020830191909152600082820152519081900360600190a182600181111561058757fe5b939250505056fea265627a7a72315820b8643106c8de1745345ceb68ac33793184125c35ac2d92a457d639298d519b9e64736f6c63430005110032
Loading...
Loading
Loading...
Loading
Loading...
Loading
[ Download: CSV Export ]
A contract address hosts a smart contract, which is a set of code stored on the blockchain that runs when predetermined conditions are met. Learn more about addresses in our Knowledge Base.