Overview
ETH Balance
0 ETH
Eth Value
$0.00More Info
Private Name Tags
ContractCreator
Latest 25 from a total of 193 transactions
Transaction Hash |
Method
|
Block
|
From
|
To
|
|||||
---|---|---|---|---|---|---|---|---|---|
Delegate | 17500359 | 558 days ago | IN | 0 ETH | 0.00198395 | ||||
Delegate | 17496495 | 559 days ago | IN | 0 ETH | 0.00191447 | ||||
Delegate | 17495994 | 559 days ago | IN | 0 ETH | 0.00211629 | ||||
Delegate | 17494904 | 559 days ago | IN | 0 ETH | 0.00207952 | ||||
Delegate | 17492857 | 559 days ago | IN | 0 ETH | 0.00223316 | ||||
Delegate | 17491131 | 560 days ago | IN | 0 ETH | 0.00201364 | ||||
Delegate | 17490655 | 560 days ago | IN | 0 ETH | 0.00196662 | ||||
Delegate | 17488147 | 560 days ago | IN | 0 ETH | 0.00116934 | ||||
Delegate | 17487501 | 560 days ago | IN | 0 ETH | 0.00217535 | ||||
Delegate | 17485926 | 560 days ago | IN | 0 ETH | 0.00203248 | ||||
Delegate | 17485554 | 560 days ago | IN | 0 ETH | 0.00337736 | ||||
Delegate | 17483741 | 561 days ago | IN | 0 ETH | 0.00264632 | ||||
Delegate | 17480491 | 561 days ago | IN | 0 ETH | 0.00400929 | ||||
Delegate | 17479765 | 561 days ago | IN | 0 ETH | 0.00321272 | ||||
Delegate | 17474681 | 562 days ago | IN | 0 ETH | 0.00188098 | ||||
Delegate | 17474046 | 562 days ago | IN | 0 ETH | 0.00104499 | ||||
Delegate | 17472031 | 562 days ago | IN | 0 ETH | 0.00291036 | ||||
Delegate | 17470943 | 562 days ago | IN | 0 ETH | 0.0020367 | ||||
Delegate | 17469537 | 563 days ago | IN | 0 ETH | 0.00188524 | ||||
Delegate | 17469532 | 563 days ago | IN | 0 ETH | 0.00190921 | ||||
Delegate | 17469489 | 563 days ago | IN | 0 ETH | 0.00189975 | ||||
Delegate | 17468036 | 563 days ago | IN | 0 ETH | 0.0114341 | ||||
Delegate | 17465980 | 563 days ago | IN | 0 ETH | 0.00205897 | ||||
Delegate | 17465930 | 563 days ago | IN | 0 ETH | 0.0032584 | ||||
Delegate | 17465832 | 563 days ago | IN | 0 ETH | 0.00098461 |
View more zero value Internal Transactions in Advanced View mode
Advanced mode:
Loading...
Loading
Similar Match Source Code This contract matches the deployed Bytecode of the Source Code for Contract 0x7577EbFB...da3ae509C The constructor portion of the code might be different and could alter the actual behaviour of the contract
Contract Name:
ChromiaDelegation
Compiler Version
v0.8.17+commit.8df45f5f
Optimization Enabled:
Yes with 2000 runs
Other Settings:
default evmVersion
Contract Source Code (Solidity Standard Json-Input format)
// SPDX-License-Identifier: MIT /* This contract has three parts: Delegation, Yield and ProviderStaking. IMPORTANT: User can only make 1 change at a time, meaning e.g. if they increase stake, they must delegate, before increasing stake again. User MUST `undelegate(..)` AFTER reqesting a withdrawal, but BEFORE actually withdrawing their stake from TWN, otherwise their records in TWN will gone and cannot be synced. */ pragma solidity ^0.8.17; import {IERC20Metadata} from "@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol"; import {SafeERC20} from "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol"; import {AccessControl} from "@openzeppelin/contracts/access/AccessControl.sol"; import {ReentrancyGuard} from "@openzeppelin/contracts/security/ReentrancyGuard.sol"; import {ITwoWeeksNotice} from "contracts/interfaces/ITwoWeeksNotice.sol"; struct DelegationChange { address delegatedTo; uint72 balance; uint16 nextChange; } struct DelegationState { uint16 claimedEpoch; uint16 latestChangeEpoch; uint96 processed; uint32 processedDate; // By day. Multiple by 1 day for *time*. uint96 balanceAtProcessed; mapping(uint16 => DelegationChange) delegationTimeline; // each uint key is a week starting from "startTime" } struct RateTimeline { uint16 latestChangeEpoch; mapping(uint16 => uint16) timeline; mapping(uint16 => uint16) nextChange; } struct ProviderStateChange { bool lostWhitelist; // provider got removed from whitelist this epoch bool gainedWhitelist; // provider got added to whitelist this epoch uint96 delegationsIncrease; uint96 delegationsDecrease; uint16 nextChangeDelegations; uint16 nextChangeWhitelist; } struct AdditionalReward { uint16 additionalRewardPerYieldPeriodPerToken; uint16 epoch; } struct ProviderState { bool whitelisted; uint16 claimedEpochReward; uint16 latestDelegationsChange; uint16 latestWhitelistChange; uint128 latestTotalDelegation; uint16 latestTotalDelegationEpoch; AdditionalReward[] additionalRewards; mapping(uint16 => ProviderStateChange) providerStateTimeline; } /// @title ChromiaProvider Delegation /// @author Mustafa Koray Kaya /// @notice TwoWeekNoticeProvider extension that allows delegation rewards for an existing TwoWeekNotice contract. /// @dev Syncronizes state with the TWN contract when delegation is altered. /// @dev Syncronization must also be performed before a TWN withdrawal contract ChromiaDelegation is AccessControl, ReentrancyGuard { using SafeERC20 for IERC20Metadata; bytes32 public constant WHITELIST_ADMIN = keccak256("WHITELIST_ADMIN"); bytes32 public constant RATE_ADMIN = keccak256("RATE_ADMIN"); bytes32 public constant ADDITIONAL_REWARD_ADMIN = keccak256("ADDITIONAL_REWARD_ADMIN"); uint32 public immutable yieldPeriod; uint32 public immutable epochLength; uint32 public immutable startTime; ITwoWeeksNotice public immutable twn; IERC20Metadata public immutable token; address public bank; uint128 private immutable minorTokenUnitsInMajor; mapping(address => DelegationState) public delegatorStates; mapping(address => ProviderState) public providerStates; RateTimeline private delegatorYieldTimeline; // The yield delegators get for delegating RateTimeline private providerRewardRateTimeline; // The reward the provider gets from the delegations that are delegated to them event Delegated(address indexed delegator, address indexed provider, uint128 amount); event Undelegated(address indexed delegator, address indexed provider, uint128 amount); event DelegatorYieldRateChanged(uint16 newRate); event ProviderTotalDelegationRateChanged(uint16 newRate); event AddedWhitelist(address provider); event RemovedWhitelist(address provider); event RevisedDelegation(address delegator); event ResetAccount(address delegator); event GrantedAdditionalReward(address provider, uint16 rate); event ClaimedYield(address delegator, uint128 amount); event ProviderClaimedTotalDelegationYield(address provider, uint128 amount); string private constant INVALID_WITHDRAW_ERROR = "Withdrawn without undelegating"; string private constant TIMELINE_MISMATCH_ERROR = "Timeline does not match with TWN."; string private constant UNAUTHORISED_ERROR = "Unauthorized"; string private constant CANNOT_CHANGE_WITHDRAWAL_ERROR = "Cannot change delegation while withdrawing"; string private constant WITHDRAWAL_NOT_REQUESTED_ERROR = "Withdraw has not been requested"; string private constant MUST_HAVE_STAKE_ERROR = "Must have a stake to delegate"; string private constant MUST_WHITELISTED_ERROR = "Provider must be whitelisted"; string private constant MUST_AFTER_START_ERROR = "Time must be after start time"; string private constant CHANGE_TOO_RECENT_ERROR = "Change is too recent"; string private constant ZERO_REWARD_ERROR = "Reward is 0"; string private constant FIRST_DELEGATION_NEEDED_ERROR = "Address must make a first delegation."; string private constant ALREADY_SYNCRONISED_ERROR = "Stake is synced"; constructor( IERC20Metadata _token, ITwoWeeksNotice _twn, address _owner, uint16 _delegatorYield, // Yield delegators get for delegating uint16 _totalDelegationYield, // Yield providers get on the total amount delegated to them address _bank, uint32 _yieldPeriodInSecs, uint32 _epochLengthInYieldPeriods ) { yieldPeriod = _yieldPeriodInSecs; epochLength = _epochLengthInYieldPeriods * yieldPeriod; startTime = uint32(block.timestamp) - epochLength; _setupRole(DEFAULT_ADMIN_ROLE, _owner); _setupRole(WHITELIST_ADMIN, _owner); _setupRole(RATE_ADMIN, _owner); _setupRole(ADDITIONAL_REWARD_ADMIN, _owner); twn = _twn; token = _token; bank = _bank; minorTokenUnitsInMajor = uint128(10 ** token.decimals()); delegatorYieldTimeline.timeline[1] = _delegatorYield; delegatorYieldTimeline.nextChange[0] = 1; delegatorYieldTimeline.latestChangeEpoch = 1; providerRewardRateTimeline.timeline[1] = _totalDelegationYield; providerRewardRateTimeline.nextChange[0] = 1; providerRewardRateTimeline.latestChangeEpoch = 1; } /// @dev Has the delegator's stake on the TWN contract not been released or modified. function isStakeValid(address account) public view returns (bool) { (, uint128 remoteAccumulated) = twn.getAccumulated(account); return remoteAccumulated == delegatorStates[account].processed; } /** * * SETTERS AND GETTERS * */ /// @notice Set the reward rate to `rewardRate` for the *next* epoch function setRewardRate(uint16 newRate) external { setNewRate(newRate, delegatorYieldTimeline); emit DelegatorYieldRateChanged(newRate); } /// @notice Set the provider reward rate to `newRate` at the new epoch function setProviderRewardRate(uint16 newRate) external { setNewRate(newRate, providerRewardRateTimeline); emit ProviderTotalDelegationRateChanged(newRate); } function setNewRate(uint16 newRate, RateTimeline storage rateTimeline) private { require(hasRole(DEFAULT_ADMIN_ROLE, msg.sender) || hasRole(RATE_ADMIN, msg.sender), UNAUTHORISED_ERROR); uint16 nextEpoch = getCurrentEpoch() + 1; rateTimeline.timeline[nextEpoch] = newRate; if (rateTimeline.latestChangeEpoch != nextEpoch) { rateTimeline.nextChange[rateTimeline.latestChangeEpoch] = nextEpoch; rateTimeline.latestChangeEpoch = nextEpoch; } } function journalProviderWhitelistChange(ProviderState storage providerState) private returns (uint16 newLatestChange) { ProviderStateChange storage nextChangeMapping = providerState.providerStateTimeline[providerState.latestWhitelistChange]; if (providerState.latestWhitelistChange != getCurrentEpoch()) { nextChangeMapping.nextChangeWhitelist = getCurrentEpoch(); return getCurrentEpoch(); } return providerState.latestWhitelistChange; } function journalProviderDelegationChange(ProviderState storage ps) private returns (uint16 newLatestChange) { uint16 changeEpoch = getCurrentEpoch() + 1; ProviderStateChange storage nextChangeMapping = ps.providerStateTimeline[ps.latestDelegationsChange]; if (ps.latestDelegationsChange != changeEpoch) { nextChangeMapping.nextChangeDelegations = changeEpoch; return changeEpoch; } return ps.latestDelegationsChange; } function journalDelegationChange(uint16 epoch, DelegationState storage userState) private returns (uint16 newLatestChange) { DelegationChange storage nextChangeMapping = userState.delegationTimeline[userState.latestChangeEpoch]; if (userState.latestChangeEpoch != epoch) { nextChangeMapping.nextChange = epoch; return epoch; } return userState.latestChangeEpoch; } /// @notice Gets the current active reward rate in the present epoch function getActiveProviderRewardRate(uint16 epoch) public view returns (uint128 activeRate, uint16 latestEpoch) { return getActiveRate(epoch, providerRewardRateTimeline); } /// @notice Get the reward rate active at epoch `epoch` function getActiveYieldRate(uint16 epoch) public view returns (uint128 activeRate, uint16 latestEpoch) { return getActiveRate(epoch, delegatorYieldTimeline); } function getActiveRate(uint16 epoch, RateTimeline storage rateTimeline) private view returns (uint128 activeRate, uint16 latestEpoch) { if (epoch >= rateTimeline.latestChangeEpoch) { return (rateTimeline.timeline[rateTimeline.latestChangeEpoch], rateTimeline.latestChangeEpoch); } uint16 nextChange = 0; while (true) { if (rateTimeline.nextChange[nextChange] > epoch) { return (rateTimeline.timeline[nextChange], nextChange); } nextChange = rateTimeline.nextChange[nextChange]; } } /// @notice Get the active delegates state for `account` at epoch `epoch` function getActiveDelegation(address account, uint16 epoch) public view returns (DelegationChange memory activeDelegation, uint16 latestEpoch) { DelegationState storage userState = delegatorStates[account]; if (userState.latestChangeEpoch == 0) { return (activeDelegation, 0); } if (epoch >= userState.latestChangeEpoch) { return (userState.delegationTimeline[userState.latestChangeEpoch], userState.latestChangeEpoch); } uint16 nextChange = 0; while (true) { if (userState.delegationTimeline[nextChange].nextChange > epoch) { return (userState.delegationTimeline[nextChange], nextChange); } nextChange = userState.delegationTimeline[nextChange].nextChange; } } /// @notice Get if the account has whitelist at certain epoch function getWhitelisted(address account, uint16 epoch) public view returns (bool whitelisted, uint16 latestEpoch) { ProviderState storage providerState = providerStates[account]; if (providerState.latestWhitelistChange == 0) { return (false, 0); } ProviderStateChange storage psc; if (epoch >= providerState.latestWhitelistChange) { psc = providerState.providerStateTimeline[providerState.latestWhitelistChange]; if (psc.lostWhitelist) { return (false, providerState.latestWhitelistChange); } else if (psc.gainedWhitelist) { return (true, providerState.latestWhitelistChange); } } uint16 nextChange = 0; while (true) { if (providerState.providerStateTimeline[nextChange].nextChangeWhitelist > epoch) { psc = providerState.providerStateTimeline[nextChange]; if (psc.lostWhitelist) { return (false, nextChange); } else if (psc.gainedWhitelist) { return (true, nextChange); } } nextChange = providerState.providerStateTimeline[nextChange].nextChangeWhitelist; } } function getTotalDelegations(address provider) external view returns (uint128 totalDelegations) { ProviderState storage providerState = providerStates[provider]; totalDelegations = providerState.latestTotalDelegation; uint16 next = providerState.providerStateTimeline[providerState.latestTotalDelegationEpoch].nextChangeDelegations; ProviderStateChange storage psc; while (true) { if (next == 0 || next > getCurrentEpoch() - 1) { break; } psc = providerState.providerStateTimeline[next]; if (psc.delegationsIncrease != 0) { totalDelegations += psc.delegationsIncrease; } if (psc.delegationsDecrease != 0) { if (totalDelegations > psc.delegationsDecrease) { totalDelegations -= psc.delegationsDecrease; } else totalDelegations = 0; } next = providerState.providerStateTimeline[next].nextChangeDelegations; } } /** * * DELEGATION MANAGEMENT * */ function removeCurrentDelegationFromProvider(DelegationChange memory currentDelegation, uint16 currDelEpoch) private { uint16 nextEpoch = getCurrentEpoch() + 1; ProviderState storage ps = providerStates[currentDelegation.delegatedTo]; // If provider has lost whitelist since delegation, dont bother to decreae since their total is already set to 0 on // removeWhitelist() if (currDelEpoch >= ps.latestWhitelistChange) { // Remove previous delegation from providers pool ps.providerStateTimeline[nextEpoch].delegationsDecrease += currentDelegation.balance; ps.latestDelegationsChange = journalProviderDelegationChange(ps); } } function addDelegation(DelegationState storage userState, uint16 epoch, address to, uint128 acc, uint64 since, uint64 delegateAmount) private { userState.delegationTimeline[epoch] = DelegationChange(to, delegateAmount, 0); userState.latestChangeEpoch = journalDelegationChange(epoch, userState); userState.balanceAtProcessed = delegateAmount; userState.processed = uint96(acc); userState.processedDate = uint32(since / yieldPeriod); } /// @notice Removes delegation after a withdrawal is requested. Failure to do so prior to withdrawal may result in lost. function undelegate(address account) external nonReentrant { (, , uint64 lockedUntil, uint64 since) = twn.getStakeState(account); require(lockedUntil > 0, WITHDRAWAL_NOT_REQUESTED_ERROR); DelegationState storage userState = delegatorStates[account]; (, uint128 acc) = twn.getAccumulated(msg.sender); ensureSyncronisedDelegationState(userState, acc, since); uint16 nextEpoch = getCurrentEpoch() + 1; // Remove previous delegation from providers pool (DelegationChange memory currentDelegation, uint16 currDelEpoch) = getActiveDelegation(msg.sender, nextEpoch); removeCurrentDelegationFromProvider(currentDelegation, currDelEpoch); addDelegation(userState, getEpoch(since), address(0), acc, since, 0); emit Undelegated(account, currentDelegation.delegatedTo, currentDelegation.balance); } /// @notice Set the delegation of the caller for the *next* epoch function delegate(address to) external nonReentrant { DelegationState storage userState = delegatorStates[msg.sender]; ProviderState storage ps = providerStates[to]; (, uint128 acc) = twn.getAccumulated(msg.sender); (uint64 delegateAmount, , uint64 lockedUntil, uint64 since) = twn.getStakeState(msg.sender); require(delegateAmount > 0, MUST_HAVE_STAKE_ERROR); require(lockedUntil == 0, CANNOT_CHANGE_WITHDRAWAL_ERROR); require(ps.whitelisted, MUST_WHITELISTED_ERROR); uint16 nextEpoch = getCurrentEpoch() + 1; // Remove previous delegation from providers pool so that they cannot claim rewards from it if we have a new provider (DelegationChange memory currentDelegation, uint16 currDelEpoch) = getActiveDelegation(msg.sender, nextEpoch); if (currentDelegation.delegatedTo != address(0) && (currentDelegation.delegatedTo != to || currDelEpoch < ps.latestWhitelistChange)) { removeCurrentDelegationFromProvider(currentDelegation, currDelEpoch); // 40k gas } if (userState.latestChangeEpoch == 0) { userState.claimedEpoch = nextEpoch - 1; // If user has never delegated before, set claimedEpoch to current epoch } else { ensureSyncronisedDelegationState(userState, acc, since); // Make sure that the user hasnt decreased stake since last delegation } addDelegation(userState, nextEpoch, to, acc, since, delegateAmount); // 80k gas. Add delegation to users state // Add to new providers "totalDelegations" pool so they can claim rewards // 40k gas if (currentDelegation.delegatedTo != to || currDelEpoch < ps.latestWhitelistChange) { ps.providerStateTimeline[nextEpoch].delegationsIncrease += delegateAmount; } else { ps.providerStateTimeline[nextEpoch].delegationsIncrease += delegateAmount - currentDelegation.balance; } ps.latestDelegationsChange = journalProviderDelegationChange(ps); emit Delegated(msg.sender, to, delegateAmount); } /// @notice Remove the calling account's delegation status. Call only if state is "broken". function resetAccount() external { DelegationState storage userState = delegatorStates[msg.sender]; require(userState.latestChangeEpoch > 0, FIRST_DELEGATION_NEEDED_ERROR); (DelegationChange memory currentDelegation, uint16 currDelEpoch) = getActiveDelegation(msg.sender, getCurrentEpoch() + 1); removeCurrentDelegationFromProvider(currentDelegation, currDelEpoch); delete delegatorStates[msg.sender]; emit ResetAccount(msg.sender); } /// @notice Matches `account`'s delegation to the underlying stake. `isStakeValid(account)` must be false before call. function reviseDelegation(address account) external nonReentrant { require(!isStakeValid(account), ALREADY_SYNCRONISED_ERROR); (, , , uint64 since) = twn.getStakeState(account); require(block.timestamp - since > epochLength, CHANGE_TOO_RECENT_ERROR); DelegationState storage userState = delegatorStates[account]; require(userState.latestChangeEpoch > 0, FIRST_DELEGATION_NEEDED_ERROR); uint16 currentEpoch = getCurrentEpoch(); (DelegationChange memory currentDelegation, uint16 currDelEpoch) = getActiveDelegation(account, currentEpoch + 1); removeCurrentDelegationFromProvider(currentDelegation, currDelEpoch); userState.delegationTimeline[currentEpoch] = DelegationChange(address(0), 0, 0); userState.latestChangeEpoch = journalDelegationChange(currentEpoch, userState); emit RevisedDelegation(account); } /** * * REWARD FUNCTIONS * */ /// @notice Estimates the additional reward providers get for the total amount delegated to them per epoch function updateProviderDelegationRewardEstimate(address account) external nonReentrant returns (uint128 reward) { return _updateProviderDelegationRewardEstimate(account); } function _updateProviderDelegationRewardEstimate(address account) internal returns (uint128 reward) { ProviderState storage providerState = providerStates[account]; uint16 currentEpoch = getCurrentEpoch(); if (currentEpoch - 1 <= providerState.claimedEpochReward) { return 0; } uint128 totalDelegations = providerState.latestTotalDelegation; uint16 nextDC = providerState.latestTotalDelegationEpoch; (uint128 activeRate, uint16 nextAR) = getActiveProviderRewardRate(providerState.claimedEpochReward + 1); uint16 latestTotalDelegationEpoch = nextDC; nextAR = providerRewardRateTimeline.nextChange[nextAR]; nextDC = providerState.providerStateTimeline[nextDC].nextChangeDelegations; uint16 prev = providerState.claimedEpochReward + 1; uint16 next = findSmallestNonZero(nextAR, nextDC); if (next == 0 || next >= currentEpoch) { next = currentEpoch; } ProviderStateChange storage psc; while (true) { reward += uint128((activeRate) * totalDelegations * epochLength) * (next - prev); if (next == currentEpoch) break; if (next == nextAR) { activeRate = providerRewardRateTimeline.timeline[next]; nextAR = providerRewardRateTimeline.nextChange[next]; } if (next == nextDC) { psc = providerStates[account].providerStateTimeline[next]; if (psc.delegationsIncrease != 0) { totalDelegations += psc.delegationsIncrease; } if (psc.delegationsDecrease != 0) { if (totalDelegations > psc.delegationsDecrease) { totalDelegations -= psc.delegationsDecrease; } else totalDelegations = 0; } latestTotalDelegationEpoch = nextDC; nextDC = providerState.providerStateTimeline[next].nextChangeDelegations; } prev = next; next = findSmallestNonZero(nextAR, nextDC); if (next == 0 || next >= currentEpoch) { next = currentEpoch; } } reward /= minorTokenUnitsInMajor * yieldPeriod; providerState.latestTotalDelegation = totalDelegations; providerState.latestTotalDelegationEpoch = latestTotalDelegationEpoch; } /// @notice Calculate the total accumulated reward available to `account` function estimateYield(address account) public view returns (uint128 reward) { DelegationState storage userState = delegatorStates[account]; uint16 processedEpoch = userState.claimedEpoch; uint16 currentEpoch = getCurrentEpoch(); if (currentEpoch - 1 <= processedEpoch) { return 0; } (uint128 activeRate, uint16 nextAR) = getActiveYieldRate(processedEpoch + 1); (DelegationChange memory activeDelegation, uint16 nextAD) = getActiveDelegation(account, processedEpoch + 1); (bool whitelisted, uint16 nextWL) = getWhitelisted(activeDelegation.delegatedTo, processedEpoch + 1); ProviderState storage providerState = providerStates[activeDelegation.delegatedTo]; nextAR = delegatorYieldTimeline.nextChange[nextAR]; nextAD = userState.delegationTimeline[nextAD].nextChange; nextWL = providerState.providerStateTimeline[nextWL].nextChangeWhitelist; uint16 prev = processedEpoch + 1; uint16 next = findSmallestNonZero(nextAR, nextAD, nextWL); if (next == 0 || next >= currentEpoch) { next = currentEpoch; } while (true) { if (whitelisted) { reward += uint128((activeRate) * activeDelegation.balance * epochLength) * (next - prev); if (providerState.additionalRewards.length > 0) { for (uint i = providerState.additionalRewards.length - 1; i >= 0; i--) { if (providerState.additionalRewards[i].epoch < prev) break; if ( providerState.additionalRewards[i].epoch < next && providerState.additionalRewards[i].additionalRewardPerYieldPeriodPerToken > 0 ) { reward += uint128( (providerState.additionalRewards[i].additionalRewardPerYieldPeriodPerToken) * activeDelegation.balance * epochLength ); } if (i == 0) break; } } } if (next == currentEpoch) break; if (next == nextAR) { activeRate = delegatorYieldTimeline.timeline[next]; nextAR = delegatorYieldTimeline.nextChange[next]; } if (next == nextAD) { DelegationChange memory oldDelegation = activeDelegation; activeDelegation = userState.delegationTimeline[next]; if (oldDelegation.delegatedTo != activeDelegation.delegatedTo) { providerState = providerStates[activeDelegation.delegatedTo]; (whitelisted, nextWL) = getWhitelisted(activeDelegation.delegatedTo, next); nextWL = providerState.providerStateTimeline[nextWL].nextChangeWhitelist; } nextAD = userState.delegationTimeline[next].nextChange; } if (next == nextWL) { ProviderStateChange storage psc = providerState.providerStateTimeline[next]; if (psc.lostWhitelist) { whitelisted = false; } else if (psc.gainedWhitelist) { whitelisted = true; } nextWL = providerState.providerStateTimeline[next].nextChangeWhitelist; } prev = next; next = findSmallestNonZero(nextAR, nextAD, nextWL); if (next == 0 || next >= currentEpoch) { next = currentEpoch; } } reward /= (minorTokenUnitsInMajor * yieldPeriod); } /// @notice Claims the rewards (which should be per `estimateYield(account)`) for `account` function claimYield(address account) external nonReentrant { require(delegatorStates[account].latestChangeEpoch > 0, FIRST_DELEGATION_NEEDED_ERROR); require(isStakeValid(account), TIMELINE_MISMATCH_ERROR); uint128 reward = estimateYield(account); require(reward > 0, ZERO_REWARD_ERROR); delegatorStates[account].claimedEpoch = getCurrentEpoch() - 1; token.safeTransferFrom(bank, account, reward); emit ClaimedYield(account, reward); } /// @notice Claims additional token rewards for the calling provider function claimProviderDelegationReward(address account) external nonReentrant { _claimProviderDelegationReward(account); } function _claimProviderDelegationReward(address account) internal { uint128 reward = _updateProviderDelegationRewardEstimate(account); providerStates[account].claimedEpochReward = getCurrentEpoch() - 1; token.safeTransferFrom(bank, account, reward); emit ProviderClaimedTotalDelegationYield(account, reward); } /** * * HELPERS * */ function getCurrentEpoch() public view returns (uint16) { return getEpoch(block.timestamp); } function getEpoch(uint time) public view returns (uint16) { require(time > startTime, MUST_AFTER_START_ERROR); return uint16((time - startTime) / epochLength); } function ensureSyncronisedDelegationState(DelegationState storage userState, uint128 acc, uint64 since) private view { uint32 sinceYieldPeriods = uint32(since / yieldPeriod); require((userState.balanceAtProcessed * (sinceYieldPeriods - userState.processedDate)) + userState.processed <= acc, INVALID_WITHDRAW_ERROR); } function findSmallestNonZero(uint16 a, uint16 b, uint16 c) private pure returns (uint16 smallestNonZero) { if (a == 0 && b == 0 && c == 0) { return 0; } smallestNonZero = type(uint16).max; if (a != 0 && a < smallestNonZero) { smallestNonZero = a; } if (b != 0 && b < smallestNonZero) { smallestNonZero = b; } if (c != 0 && c < smallestNonZero) { smallestNonZero = c; } } function findSmallestNonZero(uint16 a, uint16 b) private pure returns (uint16 smallestNonZero) { if (a == 0 && b == 0) { return 0; } smallestNonZero = type(uint16).max; if (a != 0 && a < smallestNonZero) { smallestNonZero = a; } if (b != 0 && b < smallestNonZero) { smallestNonZero = b; } } /** * * ADMIN * */ /// @notice Adds `account` as a valid provider on the whitelist function addToWhitelist(address account) external { require(hasRole(DEFAULT_ADMIN_ROLE, msg.sender) || hasRole(WHITELIST_ADMIN, msg.sender), UNAUTHORISED_ERROR); uint16 currentEpoch = getCurrentEpoch(); ProviderState storage providerState = providerStates[account]; providerState.whitelisted = true; providerState.providerStateTimeline[currentEpoch].gainedWhitelist = true; providerState.latestWhitelistChange = journalProviderWhitelistChange(providerState); emit AddedWhitelist(account); } /// @notice Removes `account` from the provider whitelist, and process an immediate withdrawal if successful function removeFromWhitelist(address account) external nonReentrant { require(hasRole(DEFAULT_ADMIN_ROLE, msg.sender) || hasRole(WHITELIST_ADMIN, msg.sender), UNAUTHORISED_ERROR); ProviderState storage providerState = providerStates[account]; uint16 currentEpoch = getCurrentEpoch(); _claimProviderDelegationReward(account); providerState.latestTotalDelegation = 0; // remove from whitelist providerState.whitelisted = false; providerState.providerStateTimeline[currentEpoch].lostWhitelist = true; // Record change providerState.latestWhitelistChange = journalProviderWhitelistChange(providerState); emit RemovedWhitelist(account); } /// @notice Grants a lump `amount` award to a provider `account` at epoch `epoch`. Admin only. function grantAdditionalReward(address account, uint16 epoch, uint16 amount) external onlyRole(ADDITIONAL_REWARD_ADMIN) { require(epoch >= getCurrentEpoch(), "Cannot grant additional rewards retroactively"); providerStates[account].additionalRewards.push(AdditionalReward(amount, epoch)); emit GrantedAdditionalReward(account, amount); } /// @notice Changes the bank address from which rewards are drawn to `newBank`. Admin only. function changeBank(address newBank) external onlyRole(DEFAULT_ADMIN_ROLE) { bank = newBank; } /// @notice Sends all CHR tokens to the contract owner. Only admin can call. function drain() external onlyRole(DEFAULT_ADMIN_ROLE) { token.safeTransfer(msg.sender, token.balanceOf(address(this))); } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.8.0) (access/AccessControl.sol) pragma solidity ^0.8.0; import "./IAccessControl.sol"; import "../utils/Context.sol"; import "../utils/Strings.sol"; import "../utils/introspection/ERC165.sol"; /** * @dev Contract module that allows children to implement role-based access * control mechanisms. This is a lightweight version that doesn't allow enumerating role * members except through off-chain means by accessing the contract event logs. Some * applications may benefit from on-chain enumerability, for those cases see * {AccessControlEnumerable}. * * Roles are referred to by their `bytes32` identifier. These should be exposed * in the external API and be unique. The best way to achieve this is by * using `public constant` hash digests: * * ``` * bytes32 public constant MY_ROLE = keccak256("MY_ROLE"); * ``` * * Roles can be used to represent a set of permissions. To restrict access to a * function call, use {hasRole}: * * ``` * function foo() public { * require(hasRole(MY_ROLE, msg.sender)); * ... * } * ``` * * Roles can be granted and revoked dynamically via the {grantRole} and * {revokeRole} functions. Each role has an associated admin role, and only * accounts that have a role's admin role can call {grantRole} and {revokeRole}. * * By default, the admin role for all roles is `DEFAULT_ADMIN_ROLE`, which means * that only accounts with this role will be able to grant or revoke other * roles. More complex role relationships can be created by using * {_setRoleAdmin}. * * WARNING: The `DEFAULT_ADMIN_ROLE` is also its own admin: it has permission to * grant and revoke this role. Extra precautions should be taken to secure * accounts that have been granted it. */ abstract contract AccessControl is Context, IAccessControl, ERC165 { struct RoleData { mapping(address => bool) members; bytes32 adminRole; } mapping(bytes32 => RoleData) private _roles; bytes32 public constant DEFAULT_ADMIN_ROLE = 0x00; /** * @dev Modifier that checks that an account has a specific role. Reverts * with a standardized message including the required role. * * The format of the revert reason is given by the following regular expression: * * /^AccessControl: account (0x[0-9a-f]{40}) is missing role (0x[0-9a-f]{64})$/ * * _Available since v4.1._ */ modifier onlyRole(bytes32 role) { _checkRole(role); _; } /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { return interfaceId == type(IAccessControl).interfaceId || super.supportsInterface(interfaceId); } /** * @dev Returns `true` if `account` has been granted `role`. */ function hasRole(bytes32 role, address account) public view virtual override returns (bool) { return _roles[role].members[account]; } /** * @dev Revert with a standard message if `_msgSender()` is missing `role`. * Overriding this function changes the behavior of the {onlyRole} modifier. * * Format of the revert message is described in {_checkRole}. * * _Available since v4.6._ */ function _checkRole(bytes32 role) internal view virtual { _checkRole(role, _msgSender()); } /** * @dev Revert with a standard message if `account` is missing `role`. * * The format of the revert reason is given by the following regular expression: * * /^AccessControl: account (0x[0-9a-f]{40}) is missing role (0x[0-9a-f]{64})$/ */ function _checkRole(bytes32 role, address account) internal view virtual { if (!hasRole(role, account)) { revert( string( abi.encodePacked( "AccessControl: account ", Strings.toHexString(account), " is missing role ", Strings.toHexString(uint256(role), 32) ) ) ); } } /** * @dev Returns the admin role that controls `role`. See {grantRole} and * {revokeRole}. * * To change a role's admin, use {_setRoleAdmin}. */ function getRoleAdmin(bytes32 role) public view virtual override returns (bytes32) { return _roles[role].adminRole; } /** * @dev Grants `role` to `account`. * * If `account` had not been already granted `role`, emits a {RoleGranted} * event. * * Requirements: * * - the caller must have ``role``'s admin role. * * May emit a {RoleGranted} event. */ function grantRole(bytes32 role, address account) public virtual override onlyRole(getRoleAdmin(role)) { _grantRole(role, account); } /** * @dev Revokes `role` from `account`. * * If `account` had been granted `role`, emits a {RoleRevoked} event. * * Requirements: * * - the caller must have ``role``'s admin role. * * May emit a {RoleRevoked} event. */ function revokeRole(bytes32 role, address account) public virtual override onlyRole(getRoleAdmin(role)) { _revokeRole(role, account); } /** * @dev Revokes `role` from the calling account. * * Roles are often managed via {grantRole} and {revokeRole}: this function's * purpose is to provide a mechanism for accounts to lose their privileges * if they are compromised (such as when a trusted device is misplaced). * * If the calling account had been revoked `role`, emits a {RoleRevoked} * event. * * Requirements: * * - the caller must be `account`. * * May emit a {RoleRevoked} event. */ function renounceRole(bytes32 role, address account) public virtual override { require(account == _msgSender(), "AccessControl: can only renounce roles for self"); _revokeRole(role, account); } /** * @dev Grants `role` to `account`. * * If `account` had not been already granted `role`, emits a {RoleGranted} * event. Note that unlike {grantRole}, this function doesn't perform any * checks on the calling account. * * May emit a {RoleGranted} event. * * [WARNING] * ==== * This function should only be called from the constructor when setting * up the initial roles for the system. * * Using this function in any other way is effectively circumventing the admin * system imposed by {AccessControl}. * ==== * * NOTE: This function is deprecated in favor of {_grantRole}. */ function _setupRole(bytes32 role, address account) internal virtual { _grantRole(role, account); } /** * @dev Sets `adminRole` as ``role``'s admin role. * * Emits a {RoleAdminChanged} event. */ function _setRoleAdmin(bytes32 role, bytes32 adminRole) internal virtual { bytes32 previousAdminRole = getRoleAdmin(role); _roles[role].adminRole = adminRole; emit RoleAdminChanged(role, previousAdminRole, adminRole); } /** * @dev Grants `role` to `account`. * * Internal function without access restriction. * * May emit a {RoleGranted} event. */ function _grantRole(bytes32 role, address account) internal virtual { if (!hasRole(role, account)) { _roles[role].members[account] = true; emit RoleGranted(role, account, _msgSender()); } } /** * @dev Revokes `role` from `account`. * * Internal function without access restriction. * * May emit a {RoleRevoked} event. */ function _revokeRole(bytes32 role, address account) internal virtual { if (hasRole(role, account)) { _roles[role].members[account] = false; emit RoleRevoked(role, account, _msgSender()); } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (access/IAccessControl.sol) pragma solidity ^0.8.0; /** * @dev External interface of AccessControl declared to support ERC165 detection. */ interface IAccessControl { /** * @dev Emitted when `newAdminRole` is set as ``role``'s admin role, replacing `previousAdminRole` * * `DEFAULT_ADMIN_ROLE` is the starting admin for all roles, despite * {RoleAdminChanged} not being emitted signaling this. * * _Available since v3.1._ */ event RoleAdminChanged(bytes32 indexed role, bytes32 indexed previousAdminRole, bytes32 indexed newAdminRole); /** * @dev Emitted when `account` is granted `role`. * * `sender` is the account that originated the contract call, an admin role * bearer except when using {AccessControl-_setupRole}. */ event RoleGranted(bytes32 indexed role, address indexed account, address indexed sender); /** * @dev Emitted when `account` is revoked `role`. * * `sender` is the account that originated the contract call: * - if using `revokeRole`, it is the admin role bearer * - if using `renounceRole`, it is the role bearer (i.e. `account`) */ event RoleRevoked(bytes32 indexed role, address indexed account, address indexed sender); /** * @dev Returns `true` if `account` has been granted `role`. */ function hasRole(bytes32 role, address account) external view returns (bool); /** * @dev Returns the admin role that controls `role`. See {grantRole} and * {revokeRole}. * * To change a role's admin, use {AccessControl-_setRoleAdmin}. */ function getRoleAdmin(bytes32 role) external view returns (bytes32); /** * @dev Grants `role` to `account`. * * If `account` had not been already granted `role`, emits a {RoleGranted} * event. * * Requirements: * * - the caller must have ``role``'s admin role. */ function grantRole(bytes32 role, address account) external; /** * @dev Revokes `role` from `account`. * * If `account` had been granted `role`, emits a {RoleRevoked} event. * * Requirements: * * - the caller must have ``role``'s admin role. */ function revokeRole(bytes32 role, address account) external; /** * @dev Revokes `role` from the calling account. * * Roles are often managed via {grantRole} and {revokeRole}: this function's * purpose is to provide a mechanism for accounts to lose their privileges * if they are compromised (such as when a trusted device is misplaced). * * If the calling account had been granted `role`, emits a {RoleRevoked} * event. * * Requirements: * * - the caller must be `account`. */ function renounceRole(bytes32 role, address account) external; }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.8.0) (security/ReentrancyGuard.sol) pragma solidity ^0.8.0; /** * @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 ReentrancyGuard { // 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; constructor() { _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() { _nonReentrantBefore(); _; _nonReentrantAfter(); } function _nonReentrantBefore() private { // On the first call to nonReentrant, _status will be _NOT_ENTERED require(_status != _ENTERED, "ReentrancyGuard: reentrant call"); // Any calls to nonReentrant after this point will fail _status = _ENTERED; } function _nonReentrantAfter() private { // By storing the original value once again, a refund is triggered (see // https://eips.ethereum.org/EIPS/eip-2200) _status = _NOT_ENTERED; } }
// 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.8.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.8.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 functionCallWithValue(target, data, 0, "Address: low-level call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with * `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { return functionCallWithValue(target, data, 0, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but also transferring `value` wei to `target`. * * Requirements: * * - the calling contract must have an ETH balance of at least `value`. * - the called Solidity function must be `payable`. * * _Available since v3.1._ */ function functionCallWithValue( address target, bytes memory data, uint256 value ) internal returns (bytes memory) { return functionCallWithValue(target, data, value, "Address: low-level call with value failed"); } /** * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but * with `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCallWithValue( address target, bytes memory data, uint256 value, string memory errorMessage ) internal returns (bytes memory) { require(address(this).balance >= value, "Address: insufficient balance for call"); (bool success, bytes memory returndata) = target.call{value: value}(data); return verifyCallResultFromTarget(target, success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) { return functionStaticCall(target, data, "Address: low-level static call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall( address target, bytes memory data, string memory errorMessage ) internal view returns (bytes memory) { (bool success, bytes memory returndata) = target.staticcall(data); return verifyCallResultFromTarget(target, success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) { return functionDelegateCall(target, data, "Address: low-level delegate call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { (bool success, bytes memory returndata) = target.delegatecall(data); return verifyCallResultFromTarget(target, success, returndata, errorMessage); } /** * @dev Tool to verify that a low level call to smart-contract was successful, and revert (either by bubbling * the revert reason or using the provided one) in case of unsuccessful call or if target was not a contract. * * _Available since v4.8._ */ function verifyCallResultFromTarget( address target, bool success, bytes memory returndata, string memory errorMessage ) internal view returns (bytes memory) { if (success) { if (returndata.length == 0) { // only check isContract if the call was successful and the return data is empty // otherwise we already know that it was a contract require(isContract(target), "Address: call to non-contract"); } return returndata; } else { _revert(returndata, errorMessage); } } /** * @dev Tool to verify that a low level call was successful, and revert if it wasn't, either by bubbling the * revert reason or using the provided one. * * _Available since v4.3._ */ function verifyCallResult( bool success, bytes memory returndata, string memory errorMessage ) internal pure returns (bytes memory) { if (success) { return returndata; } else { _revert(returndata, errorMessage); } } function _revert(bytes memory returndata, string memory errorMessage) private pure { // Look for revert reason and bubble it up if present if (returndata.length > 0) { // The easiest way to bubble the revert reason is using memory via assembly /// @solidity memory-safe-assembly assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/Context.sol) pragma solidity ^0.8.0; /** * @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 // OpenZeppelin Contracts (last updated v4.8.0) (utils/math/Math.sol) pragma solidity ^0.8.0; /** * @dev Standard math utilities missing in the Solidity language. */ library Math { enum Rounding { Down, // Toward negative infinity Up, // Toward infinity Zero // Toward zero } /** * @dev Returns the largest of two numbers. */ function max(uint256 a, uint256 b) internal pure returns (uint256) { return a > b ? a : b; } /** * @dev Returns the smallest of two numbers. */ function min(uint256 a, uint256 b) internal pure returns (uint256) { return a < b ? a : b; } /** * @dev Returns the average of two numbers. The result is rounded towards * zero. */ function average(uint256 a, uint256 b) internal pure returns (uint256) { // (a + b) / 2 can overflow. return (a & b) + (a ^ b) / 2; } /** * @dev Returns the ceiling of the division of two numbers. * * This differs from standard division with `/` in that it rounds up instead * of rounding down. */ function ceilDiv(uint256 a, uint256 b) internal pure returns (uint256) { // (a + b - 1) / b can overflow on addition, so we distribute. return a == 0 ? 0 : (a - 1) / b + 1; } /** * @notice Calculates floor(x * y / denominator) with full precision. Throws if result overflows a uint256 or denominator == 0 * @dev Original credit to Remco Bloemen under MIT license (https://xn--2-umb.com/21/muldiv) * with further edits by Uniswap Labs also under MIT license. */ function mulDiv( uint256 x, uint256 y, uint256 denominator ) internal pure returns (uint256 result) { unchecked { // 512-bit multiply [prod1 prod0] = x * y. Compute the product mod 2^256 and mod 2^256 - 1, then use // use the Chinese Remainder Theorem to reconstruct the 512 bit result. The result is stored in two 256 // variables such that product = prod1 * 2^256 + prod0. uint256 prod0; // Least significant 256 bits of the product uint256 prod1; // Most significant 256 bits of the product assembly { let mm := mulmod(x, y, not(0)) prod0 := mul(x, y) prod1 := sub(sub(mm, prod0), lt(mm, prod0)) } // Handle non-overflow cases, 256 by 256 division. if (prod1 == 0) { return prod0 / denominator; } // Make sure the result is less than 2^256. Also prevents denominator == 0. require(denominator > prod1); /////////////////////////////////////////////// // 512 by 256 division. /////////////////////////////////////////////// // Make division exact by subtracting the remainder from [prod1 prod0]. uint256 remainder; assembly { // Compute remainder using mulmod. remainder := mulmod(x, y, denominator) // Subtract 256 bit number from 512 bit number. prod1 := sub(prod1, gt(remainder, prod0)) prod0 := sub(prod0, remainder) } // Factor powers of two out of denominator and compute largest power of two divisor of denominator. Always >= 1. // See https://cs.stackexchange.com/q/138556/92363. // Does not overflow because the denominator cannot be zero at this stage in the function. uint256 twos = denominator & (~denominator + 1); assembly { // Divide denominator by twos. denominator := div(denominator, twos) // Divide [prod1 prod0] by twos. prod0 := div(prod0, twos) // Flip twos such that it is 2^256 / twos. If twos is zero, then it becomes one. twos := add(div(sub(0, twos), twos), 1) } // Shift in bits from prod1 into prod0. prod0 |= prod1 * twos; // Invert denominator mod 2^256. Now that denominator is an odd number, it has an inverse modulo 2^256 such // that denominator * inv = 1 mod 2^256. Compute the inverse by starting with a seed that is correct for // four bits. That is, denominator * inv = 1 mod 2^4. uint256 inverse = (3 * denominator) ^ 2; // Use the Newton-Raphson iteration to improve the precision. Thanks to Hensel's lifting lemma, this also works // in modular arithmetic, doubling the correct bits in each step. inverse *= 2 - denominator * inverse; // inverse mod 2^8 inverse *= 2 - denominator * inverse; // inverse mod 2^16 inverse *= 2 - denominator * inverse; // inverse mod 2^32 inverse *= 2 - denominator * inverse; // inverse mod 2^64 inverse *= 2 - denominator * inverse; // inverse mod 2^128 inverse *= 2 - denominator * inverse; // inverse mod 2^256 // Because the division is now exact we can divide by multiplying with the modular inverse of denominator. // This will give us the correct result modulo 2^256. Since the preconditions guarantee that the outcome is // less than 2^256, this is the final result. We don't need to compute the high bits of the result and prod1 // is no longer required. result = prod0 * inverse; return result; } } /** * @notice Calculates x * y / denominator with full precision, following the selected rounding direction. */ function mulDiv( uint256 x, uint256 y, uint256 denominator, Rounding rounding ) internal pure returns (uint256) { uint256 result = mulDiv(x, y, denominator); if (rounding == Rounding.Up && mulmod(x, y, denominator) > 0) { result += 1; } return result; } /** * @dev Returns the square root of a number. If the number is not a perfect square, the value is rounded down. * * Inspired by Henry S. Warren, Jr.'s "Hacker's Delight" (Chapter 11). */ function sqrt(uint256 a) internal pure returns (uint256) { if (a == 0) { return 0; } // For our first guess, we get the biggest power of 2 which is smaller than the square root of the target. // // We know that the "msb" (most significant bit) of our target number `a` is a power of 2 such that we have // `msb(a) <= a < 2*msb(a)`. This value can be written `msb(a)=2**k` with `k=log2(a)`. // // This can be rewritten `2**log2(a) <= a < 2**(log2(a) + 1)` // → `sqrt(2**k) <= sqrt(a) < sqrt(2**(k+1))` // → `2**(k/2) <= sqrt(a) < 2**((k+1)/2) <= 2**(k/2 + 1)` // // Consequently, `2**(log2(a) / 2)` is a good first approximation of `sqrt(a)` with at least 1 correct bit. uint256 result = 1 << (log2(a) >> 1); // At this point `result` is an estimation with one bit of precision. We know the true value is a uint128, // since it is the square root of a uint256. Newton's method converges quadratically (precision doubles at // every iteration). We thus need at most 7 iteration to turn our partial result with one bit of precision // into the expected uint128 result. unchecked { result = (result + a / result) >> 1; result = (result + a / result) >> 1; result = (result + a / result) >> 1; result = (result + a / result) >> 1; result = (result + a / result) >> 1; result = (result + a / result) >> 1; result = (result + a / result) >> 1; return min(result, a / result); } } /** * @notice Calculates sqrt(a), following the selected rounding direction. */ function sqrt(uint256 a, Rounding rounding) internal pure returns (uint256) { unchecked { uint256 result = sqrt(a); return result + (rounding == Rounding.Up && result * result < a ? 1 : 0); } } /** * @dev Return the log in base 2, rounded down, of a positive value. * Returns 0 if given 0. */ function log2(uint256 value) internal pure returns (uint256) { uint256 result = 0; unchecked { if (value >> 128 > 0) { value >>= 128; result += 128; } if (value >> 64 > 0) { value >>= 64; result += 64; } if (value >> 32 > 0) { value >>= 32; result += 32; } if (value >> 16 > 0) { value >>= 16; result += 16; } if (value >> 8 > 0) { value >>= 8; result += 8; } if (value >> 4 > 0) { value >>= 4; result += 4; } if (value >> 2 > 0) { value >>= 2; result += 2; } if (value >> 1 > 0) { result += 1; } } return result; } /** * @dev Return the log in base 2, following the selected rounding direction, of a positive value. * Returns 0 if given 0. */ function log2(uint256 value, Rounding rounding) internal pure returns (uint256) { unchecked { uint256 result = log2(value); return result + (rounding == Rounding.Up && 1 << result < value ? 1 : 0); } } /** * @dev Return the log in base 10, rounded down, of a positive value. * Returns 0 if given 0. */ function log10(uint256 value) internal pure returns (uint256) { uint256 result = 0; unchecked { if (value >= 10**64) { value /= 10**64; result += 64; } if (value >= 10**32) { value /= 10**32; result += 32; } if (value >= 10**16) { value /= 10**16; result += 16; } if (value >= 10**8) { value /= 10**8; result += 8; } if (value >= 10**4) { value /= 10**4; result += 4; } if (value >= 10**2) { value /= 10**2; result += 2; } if (value >= 10**1) { result += 1; } } return result; } /** * @dev Return the log in base 10, following the selected rounding direction, of a positive value. * Returns 0 if given 0. */ function log10(uint256 value, Rounding rounding) internal pure returns (uint256) { unchecked { uint256 result = log10(value); return result + (rounding == Rounding.Up && 10**result < value ? 1 : 0); } } /** * @dev Return the log in base 256, rounded down, of a positive value. * Returns 0 if given 0. * * Adding one to the result gives the number of pairs of hex symbols needed to represent `value` as a hex string. */ function log256(uint256 value) internal pure returns (uint256) { uint256 result = 0; unchecked { if (value >> 128 > 0) { value >>= 128; result += 16; } if (value >> 64 > 0) { value >>= 64; result += 8; } if (value >> 32 > 0) { value >>= 32; result += 4; } if (value >> 16 > 0) { value >>= 16; result += 2; } if (value >> 8 > 0) { result += 1; } } return result; } /** * @dev Return the log in base 10, following the selected rounding direction, of a positive value. * Returns 0 if given 0. */ function log256(uint256 value, Rounding rounding) internal pure returns (uint256) { unchecked { uint256 result = log256(value); return result + (rounding == Rounding.Up && 1 << (result * 8) < value ? 1 : 0); } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.8.0) (utils/Strings.sol) pragma solidity ^0.8.0; import "./math/Math.sol"; /** * @dev String operations. */ library Strings { bytes16 private constant _SYMBOLS = "0123456789abcdef"; uint8 private constant _ADDRESS_LENGTH = 20; /** * @dev Converts a `uint256` to its ASCII `string` decimal representation. */ function toString(uint256 value) internal pure returns (string memory) { unchecked { uint256 length = Math.log10(value) + 1; string memory buffer = new string(length); uint256 ptr; /// @solidity memory-safe-assembly assembly { ptr := add(buffer, add(32, length)) } while (true) { ptr--; /// @solidity memory-safe-assembly assembly { mstore8(ptr, byte(mod(value, 10), _SYMBOLS)) } value /= 10; if (value == 0) break; } return buffer; } } /** * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation. */ function toHexString(uint256 value) internal pure returns (string memory) { unchecked { return toHexString(value, Math.log256(value) + 1); } } /** * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length. */ function toHexString(uint256 value, uint256 length) internal pure returns (string memory) { bytes memory buffer = new bytes(2 * length + 2); buffer[0] = "0"; buffer[1] = "x"; for (uint256 i = 2 * length + 1; i > 1; --i) { buffer[i] = _SYMBOLS[value & 0xf]; value >>= 4; } require(value == 0, "Strings: hex length insufficient"); return string(buffer); } /** * @dev Converts an `address` with fixed length of 20 bytes to its not checksummed ASCII `string` hexadecimal representation. */ function toHexString(address addr) internal pure returns (string memory) { return toHexString(uint256(uint160(addr)), _ADDRESS_LENGTH); } }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.17; interface ITwoWeeksNotice { function getStakeState(address account) external view returns (uint64, uint64, uint64, uint64); function getAccumulated(address account) external view returns (uint128, uint128); }
{ "optimizer": { "enabled": true, "runs": 2000 }, "outputSelection": { "*": { "*": [ "evm.bytecode", "evm.deployedBytecode", "devdoc", "userdoc", "metadata", "abi" ] } }, "metadata": { "useLiteralContent": true }, "libraries": {} }
Contract Security Audit
- No Contract Security Audit Submitted- Submit Audit Here
[{"inputs":[{"internalType":"contract IERC20Metadata","name":"_token","type":"address"},{"internalType":"contract ITwoWeeksNotice","name":"_twn","type":"address"},{"internalType":"address","name":"_owner","type":"address"},{"internalType":"uint16","name":"_delegatorYield","type":"uint16"},{"internalType":"uint16","name":"_totalDelegationYield","type":"uint16"},{"internalType":"address","name":"_bank","type":"address"},{"internalType":"uint32","name":"_yieldPeriodInSecs","type":"uint32"},{"internalType":"uint32","name":"_epochLengthInYieldPeriods","type":"uint32"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"provider","type":"address"}],"name":"AddedWhitelist","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"delegator","type":"address"},{"indexed":false,"internalType":"uint128","name":"amount","type":"uint128"}],"name":"ClaimedYield","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"delegator","type":"address"},{"indexed":true,"internalType":"address","name":"provider","type":"address"},{"indexed":false,"internalType":"uint128","name":"amount","type":"uint128"}],"name":"Delegated","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint16","name":"newRate","type":"uint16"}],"name":"DelegatorYieldRateChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"provider","type":"address"},{"indexed":false,"internalType":"uint16","name":"rate","type":"uint16"}],"name":"GrantedAdditionalReward","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"provider","type":"address"},{"indexed":false,"internalType":"uint128","name":"amount","type":"uint128"}],"name":"ProviderClaimedTotalDelegationYield","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint16","name":"newRate","type":"uint16"}],"name":"ProviderTotalDelegationRateChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"provider","type":"address"}],"name":"RemovedWhitelist","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"delegator","type":"address"}],"name":"ResetAccount","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"delegator","type":"address"}],"name":"RevisedDelegation","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"bytes32","name":"previousAdminRole","type":"bytes32"},{"indexed":true,"internalType":"bytes32","name":"newAdminRole","type":"bytes32"}],"name":"RoleAdminChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":true,"internalType":"address","name":"sender","type":"address"}],"name":"RoleGranted","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":true,"internalType":"address","name":"sender","type":"address"}],"name":"RoleRevoked","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"delegator","type":"address"},{"indexed":true,"internalType":"address","name":"provider","type":"address"},{"indexed":false,"internalType":"uint128","name":"amount","type":"uint128"}],"name":"Undelegated","type":"event"},{"inputs":[],"name":"ADDITIONAL_REWARD_ADMIN","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"DEFAULT_ADMIN_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"RATE_ADMIN","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"WHITELIST_ADMIN","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"addToWhitelist","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"bank","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"newBank","type":"address"}],"name":"changeBank","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"claimProviderDelegationReward","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"claimYield","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"to","type":"address"}],"name":"delegate","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"delegatorStates","outputs":[{"internalType":"uint16","name":"claimedEpoch","type":"uint16"},{"internalType":"uint16","name":"latestChangeEpoch","type":"uint16"},{"internalType":"uint96","name":"processed","type":"uint96"},{"internalType":"uint32","name":"processedDate","type":"uint32"},{"internalType":"uint96","name":"balanceAtProcessed","type":"uint96"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"drain","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"epochLength","outputs":[{"internalType":"uint32","name":"","type":"uint32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"estimateYield","outputs":[{"internalType":"uint128","name":"reward","type":"uint128"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"},{"internalType":"uint16","name":"epoch","type":"uint16"}],"name":"getActiveDelegation","outputs":[{"components":[{"internalType":"address","name":"delegatedTo","type":"address"},{"internalType":"uint72","name":"balance","type":"uint72"},{"internalType":"uint16","name":"nextChange","type":"uint16"}],"internalType":"struct DelegationChange","name":"activeDelegation","type":"tuple"},{"internalType":"uint16","name":"latestEpoch","type":"uint16"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint16","name":"epoch","type":"uint16"}],"name":"getActiveProviderRewardRate","outputs":[{"internalType":"uint128","name":"activeRate","type":"uint128"},{"internalType":"uint16","name":"latestEpoch","type":"uint16"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint16","name":"epoch","type":"uint16"}],"name":"getActiveYieldRate","outputs":[{"internalType":"uint128","name":"activeRate","type":"uint128"},{"internalType":"uint16","name":"latestEpoch","type":"uint16"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getCurrentEpoch","outputs":[{"internalType":"uint16","name":"","type":"uint16"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"time","type":"uint256"}],"name":"getEpoch","outputs":[{"internalType":"uint16","name":"","type":"uint16"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"}],"name":"getRoleAdmin","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"provider","type":"address"}],"name":"getTotalDelegations","outputs":[{"internalType":"uint128","name":"totalDelegations","type":"uint128"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"},{"internalType":"uint16","name":"epoch","type":"uint16"}],"name":"getWhitelisted","outputs":[{"internalType":"bool","name":"whitelisted","type":"bool"},{"internalType":"uint16","name":"latestEpoch","type":"uint16"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"},{"internalType":"uint16","name":"epoch","type":"uint16"},{"internalType":"uint16","name":"amount","type":"uint16"}],"name":"grantAdditionalReward","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"grantRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"hasRole","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"isStakeValid","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"providerStates","outputs":[{"internalType":"bool","name":"whitelisted","type":"bool"},{"internalType":"uint16","name":"claimedEpochReward","type":"uint16"},{"internalType":"uint16","name":"latestDelegationsChange","type":"uint16"},{"internalType":"uint16","name":"latestWhitelistChange","type":"uint16"},{"internalType":"uint128","name":"latestTotalDelegation","type":"uint128"},{"internalType":"uint16","name":"latestTotalDelegationEpoch","type":"uint16"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"removeFromWhitelist","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"renounceRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"resetAccount","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"reviseDelegation","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"revokeRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint16","name":"newRate","type":"uint16"}],"name":"setProviderRewardRate","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint16","name":"newRate","type":"uint16"}],"name":"setRewardRate","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"startTime","outputs":[{"internalType":"uint32","name":"","type":"uint32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes4","name":"interfaceId","type":"bytes4"}],"name":"supportsInterface","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"token","outputs":[{"internalType":"contract IERC20Metadata","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"twn","outputs":[{"internalType":"contract ITwoWeeksNotice","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"undelegate","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"updateProviderDelegationRewardEstimate","outputs":[{"internalType":"uint128","name":"reward","type":"uint128"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"yieldPeriod","outputs":[{"internalType":"uint32","name":"","type":"uint32"}],"stateMutability":"view","type":"function"}]
Deployed Bytecode
0x608060405234801561001057600080fd5b50600436106102d35760003560e01c80638ab1d68111610186578063bc0bc6ba116100e3578063e06fffa411610097578063f58af7db11610071578063f58af7db14610850578063fc0c546a14610877578063ffc192241461089e57600080fd5b8063e06fffa4146107fd578063e43252d714610810578063e4a10abd1461082357600080fd5b8063d547741f116100c8578063d547741f146107b0578063da8be864146107c3578063dedfbbfa146107d657600080fd5b8063bc0bc6ba1461078a578063c2c39b081461079d57600080fd5b80639f25d7221161013a578063a5a9f84a1161011f578063a5a9f84a14610727578063b8addc961461073a578063b97dd9e21461076f57600080fd5b80639f25d72214610679578063a217fddf1461071f57600080fd5b80639890220b1161016b5780639890220b1461064b578063999927df146106535780639a61fd6f1461066657600080fd5b80638ab1d6811461060157806391d148541461061457600080fd5b8063361d004f116102345780636027bfb0116101e857806376cdb03b116101cd57806376cdb03b146105a057806378e97925146105b35780638846da69146105da57600080fd5b80636027bfb01461050957806363052bb21461054857600080fd5b8063559301751161021957806355930175146104a757806357d775f8146104ba5780635c19a95c146104f657600080fd5b8063361d004f1461048157806336568abe1461049457600080fd5b80631dd624671161028b5780632ec027bf116102705780632ec027bf146104345780632f2ff15d1461045b5780633587ec701461046e57600080fd5b80631dd62467146103d8578063248a9ca31461040357600080fd5b806309995d7f116102bc57806309995d7f146103155780631c12c613146103285780631d0c2652146103d057600080fd5b806301ffc9a7146102d857806306a89ca114610300575b600080fd5b6102eb6102e6366004613e27565b6108b1565b60405190151581526020015b60405180910390f35b61031361030e366004613e7b565b61094a565b005b610313610323366004613ead565b610990565b610390610336366004613ead565b60036020526000908152604090205461ffff80821691620100008104909116906001600160601b03640100000000820481169163ffffffff70010000000000000000000000000000000082041691600160a01b9091041685565b6040805161ffff96871681529590941660208601526001600160601b039283169385019390935263ffffffff16606084015216608082015260a0016102f7565b6103136109ad565b6103eb6103e6366004613ead565b610a86565b6040516001600160801b0390911681526020016102f7565b610426610411366004613ec8565b60009081526020819052604090206001015490565b6040519081526020016102f7565b6104267fb54bb84ee3be50e6950d3bc7b4df6132e81f11695d45d3abf42ff629408f253981565b610313610469366004613ee1565b610fcc565b6103eb61047c366004613ead565b610ff6565b61031361048f366004613ead565b611019565b6103136104a2366004613ee1565b61105f565b6103136104b5366004613f0d565b6110eb565b6104e17f0000000000000000000000000000000000000000000000000000000000093a8081565b60405163ffffffff90911681526020016102f7565b610313610504366004613ead565b611261565b6105307f000000000000000000000000c7b0f970c1efbb181194fc15ccd5c4a2c2ab863b81565b6040516001600160a01b0390911681526020016102f7565b61055b610556366004613f50565b611728565b6040805183516001600160a01b0316815260208085015168ffffffffffffffffff16908201529281015161ffff908116918401919091521660608201526080016102f7565b600254610530906001600160a01b031681565b6104e17f00000000000000000000000000000000000000000000000000000000646f895f81565b6104267fc4fb326a0f29357e7e664c75ea916c5b15852bf43b3ef049935b453971100f0a81565b61031361060f366004613ead565b6118bb565b6102eb610622366004613ee1565b6000918252602082815260408084206001600160a01b0393909316845291905290205460ff1690565b610313611a65565b610313610661366004613ead565b611b48565b6102eb610674366004613ead565b611d32565b6106dd610687366004613ead565b60046020526000908152604090205460ff81169061ffff6101008204811691630100000081048216916501000000000082048116916001600160801b0367010000000000000082041691600160b81b9091041686565b60408051961515875261ffff95861660208801529385169386019390935290831660608501526001600160801b031660808401521660a082015260c0016102f7565b610426600081565b610313610735366004613e7b565b611e02565b61074d610748366004613e7b565b611e41565b604080516001600160801b03909316835261ffff9091166020830152016102f7565b610777611e58565b60405161ffff90911681526020016102f7565b610777610798366004613ec8565b611e68565b61074d6107ab366004613e7b565b611f4b565b6103136107be366004613ee1565b611f59565b6103136107d1366004613ead565b611f7e565b6104e17f000000000000000000000000000000000000000000000000000000000001518081565b61031361080b366004613ead565b6121de565b61031361081e366004613ead565b61253c565b610836610831366004613f50565b6126cc565b60408051921515835261ffff9091166020830152016102f7565b6104267f9cc798953f1657230a000cfd0cfb877f321fc37733bbdaba923c800c0f6f63b681565b6105307f0000000000000000000000008a2279d4a90b6fe1c4b30fa660cc9f926797baa281565b6103eb6108ac366004613ead565b612831565b60007fffffffff0000000000000000000000000000000000000000000000000000000082167f7965db0b00000000000000000000000000000000000000000000000000000000148061094457507f01ffc9a7000000000000000000000000000000000000000000000000000000007fffffffff000000000000000000000000000000000000000000000000000000008316145b92915050565b610955816005612996565b60405161ffff821681527fb7c5fd9f6249df36ef72e1a3e3d9820beb9a9a7b38efef6f5ce6c9d6af181d70906020015b60405180910390a150565b610998612acd565b6109a181612b26565b6109aa60018055565b50565b336000908152600360209081526040918290208054835160608101909452602580855291936201000090910461ffff161515929091906143c59083013990610a115760405162461bcd60e51b8152600401610a089190613f9e565b60405180910390fd5b50600080610a2c33610a21611e58565b610556906001613fe7565b91509150610a3a8282612c22565b3360008181526003602090815260408083209290925590519182527ff342139ca4d413a491f1cef1c72371556e3c982936b4e7184b58674e241c492c91015b60405180910390a1505050565b6001600160a01b0381166000908152600360205260408120805461ffff1682610aad611e58565b905061ffff8216610abf600183614009565b61ffff1611610ad357506000949350505050565b600080610ae4610748856001613fe7565b9092509050600080610afb89610556886001613fe7565b91509150600080610b1784600001518960016108319190613fe7565b85516001600160a01b0316600090815260046020908152604080832061ffff9a8b1684526007835281842054988b16845260018f8101845282852054958c1685526002820190935290832054978a1699600160e81b909404841697949650600160e01b909404909216935090610b8e908b90613fe7565b90506000610b9d888786612d07565b905061ffff81161580610bb857508961ffff168161ffff1610155b15610bc05750885b8415610d8857610bd08282614009565b61ffff167f0000000000000000000000000000000000000000000000000000000000093a8063ffffffff16886020015168ffffffffffffffffff168b610c169190614024565b610c209190614024565b610c2a9190614024565b610c34908e61404f565b6001840154909d5015610d8857600183810154600091610c539161406f565b90505b8261ffff16846001018281548110610c7057610c70614082565b60009182526020909120015462010000900461ffff1610610d86578161ffff16846001018281548110610ca557610ca5614082565b60009182526020909120015462010000900461ffff16108015610cec57506000846001018281548110610cda57610cda614082565b60009182526020909120015461ffff16115b15610d6e577f0000000000000000000000000000000000000000000000000000000000093a8063ffffffff168860200151856001018381548110610d3257610d32614082565b600091825260209091200154610d4c919061ffff16614098565b610d569190614098565b610d6b9068ffffffffffffffffff168f61404f565b9d505b8015610d865780610d7e816140bd565b915050610c56565b505b8961ffff168161ffff160315610f60578761ffff168161ffff1603610dd15761ffff8082166000908152600660209081526040808320546007909252909120549082169a501697505b8561ffff168161ffff1603610ebc5761ffff808216600090815260018e016020908152604091829020825160608101845290546001600160a01b0380821680845268ffffffffffffffffff600160a01b84041694840194909452600160e81b9091049094169281019290925289519199929190911614610e995787516001600160a01b031660009081526004602052604090208851909450610e7390836126cc565b61ffff9081166000908152600287016020526040902054919750600160e01b9091041694505b5061ffff808216600090815260018e016020526040902054600160e81b90041695505b8361ffff168161ffff1603610f2a5761ffff811660009081526002840160205260409020805460ff1615610ef35760009550610f07565b8054610100900460ff1615610f0757600195505b5061ffff8082166000908152600285016020526040902054600160e01b90041693505b809150610f38888786612d07565b905061ffff81161580610f5357508961ffff168161ffff1610155b15610f5b5750885b610bc0565b610fb063ffffffff7f0000000000000000000000000000000000000000000000000000000000015180167f00000000000000000000000000000000000000000000000000000000000f4240614024565b610fba908e614108565b9e9d5050505050505050505050505050565b600082815260208190526040902060010154610fe781612da7565b610ff18383612db1565b505050565b6000611000612acd565b61100982612e4f565b905061101460018055565b919050565b600061102481612da7565b50600280547fffffffffffffffffffffffff0000000000000000000000000000000000000000166001600160a01b0392909216919091179055565b6001600160a01b03811633146110dd5760405162461bcd60e51b815260206004820152602f60248201527f416363657373436f6e74726f6c3a2063616e206f6e6c792072656e6f756e636560448201527f20726f6c657320666f722073656c6600000000000000000000000000000000006064820152608401610a08565b6110e7828261320b565b5050565b7fc4fb326a0f29357e7e664c75ea916c5b15852bf43b3ef049935b453971100f0a61111581612da7565b61111d611e58565b61ffff168361ffff16101561119a5760405162461bcd60e51b815260206004820152602d60248201527f43616e6e6f74206772616e74206164646974696f6e616c20726577617264732060448201527f726574726f6163746976656c79000000000000000000000000000000000000006064820152608401610a08565b6001600160a01b03841660008181526004602090815260408083208151808301835261ffff8881168083528a821683870190815260019485018054958601815588529686902092519290930180549651821662010000027fffffffffffffffffffffffffffffffffffffffffffffffffffffffff000000009097169290911691909117949094179093558051938452908301919091527fc96041c5d70aebb7bb795817bab7964a05e1f39a37ee304c6aee0e19a3538f12910160405180910390a150505050565b611269612acd565b3360008181526003602090815260408083206001600160a01b038681168552600493849052828520925163112acded60e21b815293840195909552939092917f000000000000000000000000c7b0f970c1efbb181194fc15ccd5c4a2c2ab863b909116906344ab37b4906024016040805180830381865afa1580156112f2573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906113169190614145565b604051630fd4003760e41b815233600482015290925060009150819081906001600160a01b037f000000000000000000000000c7b0f970c1efbb181194fc15ccd5c4a2c2ab863b169063fd40037090602401608060405180830381865afa158015611385573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906113a99190614187565b9350935050925060008367ffffffffffffffff16116040518060400160405280601d81526020017f4d75737420686176652061207374616b6520746f2064656c6567617465000000815250906114125760405162461bcd60e51b8152600401610a089190613f9e565b508167ffffffffffffffff166000146040518060600160405280602a815260200161440b602a9139906114585760405162461bcd60e51b8152600401610a089190613f9e565b50845460408051808201909152601c81527f50726f7669646572206d7573742062652077686974656c69737465640000000060208201529060ff166114b05760405162461bcd60e51b8152600401610a089190613f9e565b5060006114bb611e58565b6114c6906001613fe7565b90506000806114d53384611728565b815191935091506001600160a01b0316158015906115245750896001600160a01b031682600001516001600160a01b03161415806115245750875461ffff650100000000009091048116908216105b15611533576115338282612c22565b885462010000900461ffff1660000361156757611551600184614009565b895461ffff191661ffff91909116178955611572565b61157289888661328a565b61158089848c8a888b613394565b896001600160a01b031682600001516001600160a01b03161415806115b65750875461ffff650100000000009091048116908216105b156116245761ffff8316600090815260028981016020526040909120805467ffffffffffffffff891692906115fb9084906201000090046001600160601b03166141db565b92506101000a8154816001600160601b0302191690836001600160601b031602179055506116a7565b602082015161163d9067ffffffffffffffff88166141fb565b61ffff8416600090815260028a81016020526040909120805468ffffffffffffffffff93909316929091906116829084906201000090046001600160601b03166141db565b92506101000a8154816001600160601b0302191690836001600160601b031602179055505b6116b088613552565b885461ffff9190911663010000000264ffff0000001990911617885560405167ffffffffffffffff871681526001600160a01b038b169033907f24c73a8cd5729a711d07964c8034bffe7222a8297237b39a5424d499aa97b6f39060200160405180910390a35050505050505050506109aa60018055565b60408051606081018252600080825260208201819052918101919091526001600160a01b0383166000908152600360205260408120805462010000900461ffff1682036117795750600090506118b4565b805461ffff620100009091048116908516106117fc57805461ffff620100009091048116600081815260019093016020908152604093849020845160608101865290546001600160a01b038116825268ffffffffffffffffff600160a01b82041692820192909252600160e81b90910490921692820192909252925090506118b4565b60005b61ffff8181166000908152600184016020526040902054818716600160e81b90910490911611156118905761ffff808216600090815260019093016020908152604093849020845160608101865290546001600160a01b038116825268ffffffffffffffffff600160a01b82041692820192909252600160e81b9091049091169281019290925290925090506118b4565b61ffff9081166000908152600183016020526040902054600160e81b9004166117ff565b9250929050565b6118c3612acd565b3360009081527fad3228b676f7d3cd4284a5443f17f1962b36e491b30a40b2405849e597ba5fb5602052604090205460ff168061192e57503360009081527f2fad6f534c831d814d61bd3f1935c89916c064d457ab36ff588d93f1b344468c602052604090205460ff165b6040518060400160405280600c81526020017f556e617574686f72697a65640000000000000000000000000000000000000000815250906119825760405162461bcd60e51b8152600401610a089190613f9e565b506001600160a01b0381166000908152600460205260408120906119a4611e58565b90506119af83612b26565b81547fffffffffffffffffff00000000000000000000000000000000ffffffffffff0016825561ffff811660009081526002830160205260409020805460ff191660011790556119fe826135de565b825461ffff91909116650100000000000266ffff0000000000199091161782556040516001600160a01b03841681527f441e43beaf2db8af6e1f9f7a6b9f0dcc36fcf83a2904264c9ab624068242efff9060200160405180910390a150506109aa60018055565b6000611a7081612da7565b6040517f70a082310000000000000000000000000000000000000000000000000000000081523060048201526109aa9033906001600160a01b037f0000000000000000000000008a2279d4a90b6fe1c4b30fa660cc9f926797baa216906370a0823190602401602060405180830381865afa158015611af3573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611b17919061421d565b6001600160a01b037f0000000000000000000000008a2279d4a90b6fe1c4b30fa660cc9f926797baa2169190613676565b611b50612acd565b6001600160a01b0381166000908152600360209081526040918290205482516060810190935260258084526201000090910461ffff16151592916143c59083013990611baf5760405162461bcd60e51b8152600401610a089190613f9e565b50611bb981611d32565b6040518060600160405280602181526020016143ea6021913990611bf05760405162461bcd60e51b8152600401610a089190613f9e565b506000611bfc82610a86565b90506000816001600160801b0316116040518060400160405280600b81526020017f526577617264206973203000000000000000000000000000000000000000000081525090611c5f5760405162461bcd60e51b8152600401610a089190613f9e565b506001611c6a611e58565b611c749190614009565b6001600160a01b038381166000908152600360205260409020805461ffff191661ffff9390931692909217909155600254611cde917f0000000000000000000000008a2279d4a90b6fe1c4b30fa660cc9f926797baa281169116846001600160801b03851661371f565b604080516001600160a01b03841681526001600160801b03831660208201527fef43505223391b62c1822fa8cb516c89c1ebe8d6d132bb1d4bb16aa024cf22da910160405180910390a1506109aa60018055565b60405163112acded60e21b81526001600160a01b03828116600483015260009182917f000000000000000000000000c7b0f970c1efbb181194fc15ccd5c4a2c2ab863b16906344ab37b4906024016040805180830381865afa158015611d9c573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611dc09190614145565b6001600160a01b039490941660009081526003602052604090205464010000000090046001600160601b03166001600160801b03909416939093149392505050565b611e0d816008612996565b60405161ffff821681527f4cbb06fa60b98b90df166f921bd5cddfdde3e01f61701e13e7ba250188106f3a90602001610985565b600080611e4f836005613770565b91509150915091565b6000611e6342611e68565b905090565b60007f00000000000000000000000000000000000000000000000000000000646f895f63ffffffff1682116040518060400160405280601d81526020017f54696d65206d7573742062652061667465722073746172742074696d6500000081525090611ee75760405162461bcd60e51b8152600401610a089190613f9e565b507f0000000000000000000000000000000000000000000000000000000000093a8063ffffffff167f00000000000000000000000000000000000000000000000000000000646f895f63ffffffff1683611f41919061406f565b6109449190614236565b600080611e4f836008613770565b600082815260208190526040902060010154611f7481612da7565b610ff1838361320b565b611f86612acd565b604051630fd4003760e41b81526001600160a01b03828116600483015260009182917f000000000000000000000000c7b0f970c1efbb181194fc15ccd5c4a2c2ab863b169063fd40037090602401608060405180830381865afa158015611ff1573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906120159190614187565b93509350505060008267ffffffffffffffff16116040518060400160405280601f81526020017f576974686472617720686173206e6f74206265656e20726571756573746564008152509061207d5760405162461bcd60e51b8152600401610a089190613f9e565b506001600160a01b03838116600090815260036020526040808220905163112acded60e21b815233600482015290927f000000000000000000000000c7b0f970c1efbb181194fc15ccd5c4a2c2ab863b16906344ab37b4906024016040805180830381865afa1580156120f4573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906121189190614145565b91505061212682828561328a565b6000612130611e58565b61213b906001613fe7565b905060008061214a3384611728565b915091506121588282612c22565b61217a8561216f8867ffffffffffffffff16611e68565b6000878a6000613394565b815160208084015160405168ffffffffffffffffff90911681526001600160a01b03928316928b16917fc909aa6ad3220db7f68d6c9419dc76f84c8003fb90e6c6709fe7f01344875462910160405180910390a3505050505050506109aa60018055565b6121e6612acd565b6121ef81611d32565b156040518060400160405280600f81526020017f5374616b652069732073796e6365640000000000000000000000000000000000815250906122445760405162461bcd60e51b8152600401610a089190613f9e565b50604051630fd4003760e41b81526001600160a01b0382811660048301526000917f000000000000000000000000c7b0f970c1efbb181194fc15ccd5c4a2c2ab863b9091169063fd40037090602401608060405180830381865afa1580156122b0573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906122d49190614187565b93505050507f0000000000000000000000000000000000000000000000000000000000093a8063ffffffff168167ffffffffffffffff1642612316919061406f565b116040518060400160405280601481526020017f4368616e676520697320746f6f20726563656e740000000000000000000000008152509061236b5760405162461bcd60e51b8152600401610a089190613f9e565b506001600160a01b0382166000908152600360209081526040918290208054835160608101909452602580855291936201000090910461ffff161515929091906143c590830139906123d05760405162461bcd60e51b8152600401610a089190613f9e565b5060006123db611e58565b90506000806123ef86610556856001613fe7565b915091506123fd8282612c22565b604080516060810182526000808252602080830182815283850183815261ffff898116855260018b01909352949092209251835492519451909116600160e81b027fff0000ffffffffffffffffffffffffffffffffffffffffffffffffffffffffff68ffffffffffffffffff909516600160a01b027fffffff00000000000000000000000000000000000000000000000000000000009093166001600160a01b039092169190911791909117929092169190911790556124bd838561380c565b845461ffff9190911662010000027fffffffffffffffffffffffffffffffffffffffffffffffffffffffff0000ffff9091161784556040516001600160a01b03871681527ff4121035e07e1bf50eab89f52c0a5f0ef9f4a57fc875681e8de25a231f9567759060200160405180910390a150505050506109aa60018055565b3360009081527fad3228b676f7d3cd4284a5443f17f1962b36e491b30a40b2405849e597ba5fb5602052604090205460ff16806125a757503360009081527f2fad6f534c831d814d61bd3f1935c89916c064d457ab36ff588d93f1b344468c602052604090205460ff165b6040518060400160405280600c81526020017f556e617574686f72697a65640000000000000000000000000000000000000000815250906125fb5760405162461bcd60e51b8152600401610a089190613f9e565b506000612606611e58565b6001600160a01b0383166000908152600460209081526040808320805460ff1916600117815561ffff851684526002810190925290912080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00ff16610100179055909150612673816135de565b815461ffff91909116650100000000000266ffff0000000000199091161781556040516001600160a01b03841681527f2373c347d35d91064d64b63157cb8aee2bd652a41983ca2e8a3e7348bfeff92f90602001610a79565b6001600160a01b0382166000908152600460205260408120805482919065010000000000900461ffff1682036127095760008092509250506118b4565b805460009061ffff650100000000009091048116908616106127925750805465010000000000900461ffff1660009081526002820160205260409020805460ff16156127695750546000925065010000000000900461ffff1690506118b4565b8054610100900460ff16156127925750546001925065010000000000900461ffff1690506118b4565b60005b61ffff8181166000908152600285016020526040902054818816600160e01b909104909116111561280d5761ffff811660009081526002840160205260409020805490925060ff16156127f0576000945092506118b4915050565b8154610100900460ff161561280d576001945092506118b4915050565b61ffff9081166000908152600284016020526040902054600160e01b900416612795565b6001600160a01b03811660009081526004602090815260408083208054600160b81b810461ffff908116865260028301909452918420546701000000000000009092046001600160801b0316939092600160d01b909204909116905b61ffff821615806128b8575060016128a3611e58565b6128ad9190614009565b61ffff168261ffff16115b61298e575061ffff81166000908152600283016020526040902080546201000090046001600160601b031615612906578054612903906201000090046001600160601b03168561404f565b93505b8054600160701b90046001600160601b031615612967578054600160701b90046001600160601b03166001600160801b038516111561296257805461295b90600160701b90046001600160601b03168561424a565b9350612967565b600093505b61ffff9182166000908152600284016020526040902054600160d01b90049091169061288d565b505050919050565b3360009081527fad3228b676f7d3cd4284a5443f17f1962b36e491b30a40b2405849e597ba5fb5602052604090205460ff1680612a0157503360009081527fc342493bf0f29bc7b419c89b92007cc16992810c027f6983a264f9a7ce1c9b99602052604090205460ff165b6040518060400160405280600c81526020017f556e617574686f72697a6564000000000000000000000000000000000000000081525090612a555760405162461bcd60e51b8152600401610a089190613f9e565b506000612a60611e58565b612a6b906001613fe7565b61ffff81811660008181526001860160205260409020805461ffff19168784161790558454929350911614610ff157815461ffff90811660009081526002840160205260409020805461ffff1990811693909216928317905582541617905550565b600260015403612b1f5760405162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c006044820152606401610a08565b6002600155565b6000612b3182612e4f565b90506001612b3d611e58565b612b479190614009565b6001600160a01b038084166000908152600460205260409020805461ffff93909316610100027fffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0000ff90931692909217909155600254612bd4917f0000000000000000000000008a2279d4a90b6fe1c4b30fa660cc9f926797baa281169116846001600160801b03851661371f565b604080516001600160a01b03841681526001600160801b03831660208201527f1a37fda35171b6151f4e7ae8aa53df21f025cf0cb96e363cfa48f504ba9456de910160405180910390a15050565b6000612c2c611e58565b612c37906001613fe7565b83516001600160a01b0316600090815260046020526040902080549192509061ffff65010000000000909104811690841610612d015760208481015161ffff84166000908152600284019092526040909120805468ffffffffffffffffff90921691600e90612cb7908490600160701b90046001600160601b03166141db565b92506101000a8154816001600160601b0302191690836001600160601b03160217905550612ce481613552565b815461ffff9190911663010000000264ffff000000199091161781555b50505050565b600061ffff8416158015612d1d575061ffff8316155b8015612d2b575061ffff8216155b15612d3857506000612da0565b5061ffff83811615801590612d5457508061ffff168461ffff16105b15612d5c5750825b61ffff831615801590612d7657508061ffff168361ffff16105b15612d7e5750815b61ffff821615801590612d9857508061ffff168261ffff16105b15612da05750805b9392505050565b6109aa8133613881565b6000828152602081815260408083206001600160a01b038516845290915290205460ff166110e7576000828152602081815260408083206001600160a01b03851684529091529020805460ff19166001179055612e0b3390565b6001600160a01b0316816001600160a01b0316837f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a45050565b6001600160a01b038116600090815260046020526040812081612e70611e58565b8254909150610100900461ffff16612e89600183614009565b61ffff1611612e9c575060009392505050565b81546001600160801b036701000000000000008204169061ffff600160b81b82048116916000918291612eda916107ab916101009004166001613fe7565b61ffff9081166000908152600a6020908152604080832054848916845260028c019092528220548a54600160d01b90910484169794965090831694509091612f29916101009004166001613fe7565b90506000612f3784876138f4565b905061ffff81161580612f5257508761ffff168161ffff1610155b15612f5a5750865b60005b612f678383614009565b61ffff1663ffffffff7f0000000000000000000000000000000000000000000000000000000000093a8016612f9c8a89614024565b612fa69190614024565b612fb09190614024565b612fba908c61404f565b9a508861ffff168261ffff16031561312d578461ffff168261ffff16036130055761ffff808316600090815260096020908152604080832054600a9092529091205490821697501694505b8661ffff168261ffff16036130f757506001600160a01b038b16600090815260046020908152604080832061ffff85168452600201909152902080546201000090046001600160601b031615613073578054613070906201000090046001600160601b03168961404f565b97505b8054600160701b90046001600160601b0316156130d4578054600160701b90046001600160601b03166001600160801b03891611156130cf5780546130c890600160701b90046001600160601b03168961424a565b97506130d4565b600097505b61ffff808316600090815260028c016020526040902054600160d01b9004169693505b81925061310485886138f4565b915061ffff8216158061311f57508861ffff168261ffff1610155b15613128578891505b612f5d565b61317d63ffffffff7f0000000000000000000000000000000000000000000000000000000000015180167f00000000000000000000000000000000000000000000000000000000000f4240614024565b613187908c614108565b8a5461ffff909516600160b81b027fffffffffffffff0000ffffffffffffffffffffffffffffffffffffffffffffff6001600160801b03909a1667010000000000000002999099167fffffffffffffff000000000000000000000000000000000000ffffffffffffff90951694909417979097179098555098975050505050505050565b6000828152602081815260408083206001600160a01b038516845290915290205460ff16156110e7576000828152602081815260408083206001600160a01b0385168085529252808320805460ff1916905551339285917ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b9190a45050565b60006132bc63ffffffff7f0000000000000000000000000000000000000000000000000000000000015180168361426a565b84549091506001600160801b0384169064010000000081046001600160601b03169061330290700100000000000000000000000000000000900463ffffffff1684614285565b86546133249163ffffffff1690600160a01b90046001600160601b03166142a2565b61332e91906141db565b6001600160601b031611156040518060400160405280601e81526020017f57697468647261776e20776974686f757420756e64656c65676174696e6700008152509061338d5760405162461bcd60e51b8152600401610a089190613f9e565b5050505050565b604080516060810182526001600160a01b03808716825267ffffffffffffffff84166020808401918252600084860181815261ffff8c8116835260018e019093529590209351845492519551909116600160e81b027fff0000ffffffffffffffffffffffffffffffffffffffffffffffffffffffffff68ffffffffffffffffff96909616600160a01b027fffffff00000000000000000000000000000000000000000000000000000000009093169190931617179290921691909117905561345c858761380c565b865473ffffffffffffffffffffffffffffffff0000ffff166201000061ffff92909216919091026001600160a01b03161767ffffffffffffffff8216600160a01b02177fffffffffffffffffffffffffffffffff000000000000000000000000ffffffff166401000000006001600160601b038516021786556135057f000000000000000000000000000000000000000000000000000000000001518063ffffffff168361426a565b865463ffffffff91909116700100000000000000000000000000000000027fffffffffffffffffffffffff00000000ffffffffffffffffffffffffffffffff909116179095555050505050565b60008061355d611e58565b613568906001613fe7565b835461ffff6301000000909104811660008181526002870160205260409020929350908316146135ca5780547fffffffff0000ffffffffffffffffffffffffffffffffffffffffffffffffffff16600160d01b61ffff84160217905592915050565b505090546301000000900461ffff16919050565b805465010000000000900461ffff1660009081526002820160205260408120613605611e58565b835465010000000000900461ffff90811691161461366357613625611e58565b815461ffff91909116600160e01b027fffff0000ffffffffffffffffffffffffffffffffffffffffffffffffffffffff909116178155612da0611e58565b50505465010000000000900461ffff1690565b6040516001600160a01b038316602482015260448101829052610ff19084907fa9059cbb00000000000000000000000000000000000000000000000000000000906064015b60408051601f198184030181529190526020810180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167fffffffff0000000000000000000000000000000000000000000000000000000090931692909217909152613960565b6040516001600160a01b0380851660248301528316604482015260648101829052612d019085907f23b872dd00000000000000000000000000000000000000000000000000000000906084016136bb565b8054600090819061ffff908116908516106137a9575050805461ffff9081166000818152600184016020526040902054909116906118b4565b60005b61ffff8181166000908152600286016020526040902054818716911611156137ef5761ffff808216600090815260018601602052604090205416925090506118b4565b61ffff9081166000908152600285016020526040902054166137ac565b805461ffff62010000909104811660008181526001840160205260408120909290919085161461386f5780547fff0000ffffffffffffffffffffffffffffffffffffffffffffffffffffffffff16600160e81b61ffff8616021790555081610944565b50505462010000900461ffff16919050565b6000828152602081815260408083206001600160a01b038516845290915290205460ff166110e7576138b281613a45565b6138bd836020613a57565b6040516020016138ce9291906142c5565b60408051601f198184030181529082905262461bcd60e51b8252610a0891600401613f9e565b600061ffff831615801561390a575061ffff8216155b1561391757506000610944565b5061ffff8281161580159061393357508061ffff168361ffff16105b1561393b5750815b61ffff82161580159061395557508061ffff168261ffff16105b156109445750919050565b60006139b5826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b0316613c809092919063ffffffff16565b805190915015610ff157808060200190518101906139d39190614346565b610ff15760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e60448201527f6f742073756363656564000000000000000000000000000000000000000000006064820152608401610a08565b60606109446001600160a01b03831660145b60606000613a66836002614368565b613a7190600261437f565b67ffffffffffffffff811115613a8957613a89614392565b6040519080825280601f01601f191660200182016040528015613ab3576020820181803683370190505b5090507f300000000000000000000000000000000000000000000000000000000000000081600081518110613aea57613aea614082565b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a9053507f780000000000000000000000000000000000000000000000000000000000000081600181518110613b4d57613b4d614082565b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a9053506000613b89846002614368565b613b9490600161437f565b90505b6001811115613c31577f303132333435363738396162636465660000000000000000000000000000000085600f1660108110613bd557613bd5614082565b1a60f81b828281518110613beb57613beb614082565b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a90535060049490941c93613c2a816140bd565b9050613b97565b508315612da05760405162461bcd60e51b815260206004820181905260248201527f537472696e67733a20686578206c656e67746820696e73756666696369656e746044820152606401610a08565b6060613c8f8484600085613c97565b949350505050565b606082471015613d0f5760405162461bcd60e51b815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f60448201527f722063616c6c00000000000000000000000000000000000000000000000000006064820152608401610a08565b600080866001600160a01b03168587604051613d2b91906143a8565b60006040518083038185875af1925050503d8060008114613d68576040519150601f19603f3d011682016040523d82523d6000602084013e613d6d565b606091505b5091509150613d7e87838387613d89565b979650505050505050565b60608315613df8578251600003613df1576001600160a01b0385163b613df15760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000006044820152606401610a08565b5081613c8f565b613c8f8383815115613e0d5781518083602001fd5b8060405162461bcd60e51b8152600401610a089190613f9e565b600060208284031215613e3957600080fd5b81357fffffffff0000000000000000000000000000000000000000000000000000000081168114612da057600080fd5b803561ffff8116811461101457600080fd5b600060208284031215613e8d57600080fd5b612da082613e69565b80356001600160a01b038116811461101457600080fd5b600060208284031215613ebf57600080fd5b612da082613e96565b600060208284031215613eda57600080fd5b5035919050565b60008060408385031215613ef457600080fd5b82359150613f0460208401613e96565b90509250929050565b600080600060608486031215613f2257600080fd5b613f2b84613e96565b9250613f3960208501613e69565b9150613f4760408501613e69565b90509250925092565b60008060408385031215613f6357600080fd5b613f6c83613e96565b9150613f0460208401613e69565b60005b83811015613f95578181015183820152602001613f7d565b50506000910152565b6020815260008251806020840152613fbd816040850160208701613f7a565b601f01601f19169190910160400192915050565b634e487b7160e01b600052601160045260246000fd5b61ffff81811683821601908082111561400257614002613fd1565b5092915050565b61ffff82811682821603908082111561400257614002613fd1565b6001600160801b0381811683821602808216919082811461404757614047613fd1565b505092915050565b6001600160801b0381811683821601908082111561400257614002613fd1565b8181038181111561094457610944613fd1565b634e487b7160e01b600052603260045260246000fd5b68ffffffffffffffffff81811683821602808216919082811461404757614047613fd1565b6000816140cc576140cc613fd1565b507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0190565b634e487b7160e01b600052601260045260246000fd5b60006001600160801b0380841680614122576141226140f2565b92169190910492915050565b80516001600160801b038116811461101457600080fd5b6000806040838503121561415857600080fd5b6141618361412e565b9150613f046020840161412e565b805167ffffffffffffffff8116811461101457600080fd5b6000806000806080858703121561419d57600080fd5b6141a68561416f565b93506141b46020860161416f565b92506141c26040860161416f565b91506141d06060860161416f565b905092959194509250565b6001600160601b0381811683821601908082111561400257614002613fd1565b68ffffffffffffffffff82811682821603908082111561400257614002613fd1565b60006020828403121561422f57600080fd5b5051919050565b600082614245576142456140f2565b500490565b6001600160801b0382811682821603908082111561400257614002613fd1565b600067ffffffffffffffff80841680614122576141226140f2565b63ffffffff82811682821603908082111561400257614002613fd1565b6001600160601b0381811683821602808216919082811461404757614047613fd1565b7f416363657373436f6e74726f6c3a206163636f756e74200000000000000000008152600083516142fd816017850160208801613f7a565b7f206973206d697373696e6720726f6c6520000000000000000000000000000000601791840191820152835161433a816028840160208801613f7a565b01602801949350505050565b60006020828403121561435857600080fd5b81518015158114612da057600080fd5b808202811582820484141761094457610944613fd1565b8082018082111561094457610944613fd1565b634e487b7160e01b600052604160045260246000fd5b600082516143ba818460208701613f7a565b919091019291505056fe41646472657373206d757374206d616b6520612066697273742064656c65676174696f6e2e54696d656c696e6520646f6573206e6f74206d6174636820776974682054574e2e43616e6e6f74206368616e67652064656c65676174696f6e207768696c65207769746864726177696e67a26469706673582212200d944885014f9ea166ceebfe7b009c33575dd763d1606812927051a367cdc45164736f6c63430008110033
Loading...
Loading
Loading...
Loading
Multichain Portfolio | 30 Chains
Chain | Token | Portfolio % | Price | Amount | Value |
---|
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.