Unnamed: 0 int64 0 7.36k | comments stringlengths 3 35.2k | code_string stringlengths 1 527k | code stringlengths 1 527k | __index_level_0__ int64 0 88.6k |
|---|---|---|---|---|
8 | // initiate final payout from PayoutEscrow to payee | ClaimablePayout memory payout = ClaimablePayout(payee, totalUsdcAmount, tokensToExchange);
payoutEscrow.claimPayout(payout);
| ClaimablePayout memory payout = ClaimablePayout(payee, totalUsdcAmount, tokensToExchange);
payoutEscrow.claimPayout(payout);
| 49,596 |
5 | // MintableToken public token; |
function test01CrowdsaleInit(){
uint256 startTime = now + 5 seconds;
uint256 endTime = now + 20 minutes;
|
function test01CrowdsaleInit(){
uint256 startTime = now + 5 seconds;
uint256 endTime = now + 20 minutes;
| 18,708 |
0 | // The basis one which the sold are made.Here everithing is in Ether | uint base = 1 ether;
| uint base = 1 ether;
| 9,333 |
36 | // uint _now = now; interest = maxMintProofOfStake; if ((_now.sub(stakeStartTime)).div(1 years) == 0) { interest = (770maxMintProofOfStake).div(100); } else if ((_now.sub(stakeStartTime)).div(1 years) == 1) { interest = (435maxMintProofOfStake).div(100); } |
return REWARDS_PER_AGE;
|
return REWARDS_PER_AGE;
| 35,950 |
300 | // One possible code of zero length | left = 1;
for (len = 1; len <= MAXBITS; len++) {
| left = 1;
for (len = 1; len <= MAXBITS; len++) {
| 47,305 |
12 | // initialize the maturity with also the 1st bit on the 33th position set | if (encoded == 0) return maturity | (1 << 32);
uint256 baseMaturity = encoded & ((1 << 32) - 1);
if (maturity < baseMaturity) {
| if (encoded == 0) return maturity | (1 << 32);
uint256 baseMaturity = encoded & ((1 << 32) - 1);
if (maturity < baseMaturity) {
| 24,471 |
46 | // Bypass for a `--via-ir` bug (https:github.com/chiru-labs/ERC721A/pull/364). | struct TokenApprovalRef {
address value;
}
| struct TokenApprovalRef {
address value;
}
| 5,137 |
104 | // A mapping from product ids to Products | mapping (uint256 => Product) public products;
| mapping (uint256 => Product) public products;
| 42,756 |
262 | // Storage Properties // Container for salary information@member company The address of the company which funded this salary@member isEntity bool true=object exists, otherwise false@member streamId The id of the stream in the Sablier contract / | struct Salary {
address company;
bool isEntity;
uint256 streamId;
}
| struct Salary {
address company;
bool isEntity;
uint256 streamId;
}
| 8,223 |
357 | // Utility function that converts the address in the L1 that submitted a tx to/ the inbox to the msg.sender viewed in the L2/l1Address the address in the L1 that triggered the tx to L2/ return l2Address L2 address as viewed in msg.sender | function applyL1ToL2Alias(address l1Address) internal pure returns (address l2Address) {
unchecked {
l2Address = address(uint160(l1Address) + offset);
}
}
| function applyL1ToL2Alias(address l1Address) internal pure returns (address l2Address) {
unchecked {
l2Address = address(uint160(l1Address) + offset);
}
}
| 71,702 |
2 | // === Event Setup === // This function transfers source tokens if needed, swaps to the Mosspool token, and then retires via their CarbonChain interface. Needed sourcetoken amount is expected to be held by the caller to use._sourceToken The contract address of the token being supplied. _poolToken The contract address of the pool token being retired. _amount The amount being supplied. Expressed in either the total carbon to offset or the total source to spend. See _amountInCarbon. _amountInCarbon Bool indicating if _amount is in carbon or source. _beneficiaryAddress Address of the beneficiary of the retirement. _beneficiaryString String representing the beneficiary. A | function retireMoss(
address _sourceToken,
address _poolToken,
| function retireMoss(
address _sourceToken,
address _poolToken,
| 48,979 |
178 | // Retreive value from oracle based on timestamp_requestId being requested_timestamp to retreive data/value from return value for timestamp submitted/ | function retrieveData(uint256 _requestId, uint256 _timestamp) external view returns (uint256) {
return berry.retrieveData(_requestId, _timestamp);
}
| function retrieveData(uint256 _requestId, uint256 _timestamp) external view returns (uint256) {
return berry.retrieveData(_requestId, _timestamp);
}
| 11,640 |
47 | // Checks if base can be migrated | require(currentState != State.Migrated);
_;
| require(currentState != State.Migrated);
_;
| 40,153 |
16 | // indicator showing if proposal was cancelled | bool wasCancelled;
| bool wasCancelled;
| 73,644 |
20 | // Client buys insurance for a flight; AppContract should send the ether first before insuring the passenger / | function buyInsurance(bytes32 flightKey, address _insuree, uint256 amount) external isAuthorized isOperational {
bytes32 insuranceKey = generateKey(_insuree, flightKey, 0);
insurances[insuranceKey] = Insurance(_insuree, amount, false);
flightInsurances[flightKey].push(insuranceKey);
airlineBalances[flights[flightKey].airline] = airlineBalances[flights[flightKey].airline].add(amount);
}
| function buyInsurance(bytes32 flightKey, address _insuree, uint256 amount) external isAuthorized isOperational {
bytes32 insuranceKey = generateKey(_insuree, flightKey, 0);
insurances[insuranceKey] = Insurance(_insuree, amount, false);
flightInsurances[flightKey].push(insuranceKey);
airlineBalances[flights[flightKey].airline] = airlineBalances[flights[flightKey].airline].add(amount);
}
| 20,378 |
87 | // Decodes message for transferring ERC20 with token info. Returns structure `TransferErc20AndTokenInfoMessage`. / | function decodeTransferErc20AndTokenInfoMessage(
bytes calldata data
| function decodeTransferErc20AndTokenInfoMessage(
bytes calldata data
| 13,755 |
156 | // Transfer to system fee wallet fee amount | safeTransfer(_contract.terms.collateralAsset, address(this), feeWallet, _systemFeeAmount);
| safeTransfer(_contract.terms.collateralAsset, address(this), feeWallet, _systemFeeAmount);
| 7,789 |
27 | // Base date to calculate team, marketing and platform tokens lock | uint256 lockStartDate = 1613494800;
| uint256 lockStartDate = 1613494800;
| 17,259 |
29 | // Locker contract constructor. It will only be called once when deployingcontract. / | constructor(address _uniswapV3Pool, address _uniswapV3PositionManager) {
// Set the locker contract owner to the creator of the contract (msg.sender)
owner = msg.sender;
// Set Uniswap V3 Pool address
uniswapV3Pool = _uniswapV3Pool;
// Set Uniswap V3: Position NFT contract address
uniswapV3PositionManager = _uniswapV3PositionManager;
}
| constructor(address _uniswapV3Pool, address _uniswapV3PositionManager) {
// Set the locker contract owner to the creator of the contract (msg.sender)
owner = msg.sender;
// Set Uniswap V3 Pool address
uniswapV3Pool = _uniswapV3Pool;
// Set Uniswap V3: Position NFT contract address
uniswapV3PositionManager = _uniswapV3PositionManager;
}
| 9,367 |
36 | // Lock tokens to activate TradeGPTPass | function setTradeGPTPassLockedTokens(address user, uint amount) external onlyTradeGPTPass {
tradeGPTPassLockedTokens[user] = amount;
emit TradeGPTPassLockedTokens(user,amount);
}
| function setTradeGPTPassLockedTokens(address user, uint amount) external onlyTradeGPTPass {
tradeGPTPassLockedTokens[user] = amount;
emit TradeGPTPassLockedTokens(user,amount);
}
| 12,768 |
108 | // Treasury module ID - keccak256(abi.encodePacked("TREASURY")) | bytes32 internal constant MODULE_ID_TREASURY = 0x06aa03964db1f7257357ef09714a5f0ca3633723df419e97015e0c7a3e83edb7;
| bytes32 internal constant MODULE_ID_TREASURY = 0x06aa03964db1f7257357ef09714a5f0ca3633723df419e97015e0c7a3e83edb7;
| 12,764 |
20 | // Settle an auction, finalizing the bid and paying out to the owner. If there are no bids, the Noun is burned. / | function _settleAuction() internal {
INounsAuctionHouse.Auction memory _auction = auction;
require(_auction.startTime != 0, "Auction hasn't begun");
require(!_auction.settled, 'Auction has already been settled');
require(block.timestamp >= _auction.endTime, "Auction hasn't completed");
auction.settled = true;
if (_auction.bidder == address(0)) {
nouns.burn(_auction.nounId);
} else {
nouns.transferFrom(address(this), _auction.bidder, _auction.nounId);
}
if (_auction.amount > 0) {
_safeTransferETHWithFallback(owner(), _auction.amount);
}
emit AuctionSettled(_auction.nounId, _auction.bidder, _auction.amount);
}
| function _settleAuction() internal {
INounsAuctionHouse.Auction memory _auction = auction;
require(_auction.startTime != 0, "Auction hasn't begun");
require(!_auction.settled, 'Auction has already been settled');
require(block.timestamp >= _auction.endTime, "Auction hasn't completed");
auction.settled = true;
if (_auction.bidder == address(0)) {
nouns.burn(_auction.nounId);
} else {
nouns.transferFrom(address(this), _auction.bidder, _auction.nounId);
}
if (_auction.amount > 0) {
_safeTransferETHWithFallback(owner(), _auction.amount);
}
emit AuctionSettled(_auction.nounId, _auction.bidder, _auction.amount);
}
| 14,834 |
17 | // This is a hot address with a current record - include the balance held natively by this address and the cold: | balance_ += queryAddress_.balance;
balance_ += hotToRecord[queryAddress_].cold.balance;
| balance_ += queryAddress_.balance;
balance_ += hotToRecord[queryAddress_].cold.balance;
| 8,128 |
58 | // saving sip details to blockchain storage | sips[msg.sender].push(SIP({
planId: _planId,
stakingTimestamp: now,
monthlyCommitmentAmount: _monthlyCommitmentAmount,
totalDeposited: _monthlyCommitmentAmount,
lastWithdrawlMonthId: 0, /// @dev withdrawl monthId starts from 1
powerBoosterWithdrawls: 0,
numberOfAppointees: 0,
appointeeVotes: 0
}));
| sips[msg.sender].push(SIP({
planId: _planId,
stakingTimestamp: now,
monthlyCommitmentAmount: _monthlyCommitmentAmount,
totalDeposited: _monthlyCommitmentAmount,
lastWithdrawlMonthId: 0, /// @dev withdrawl monthId starts from 1
powerBoosterWithdrawls: 0,
numberOfAppointees: 0,
appointeeVotes: 0
}));
| 24,118 |
723 | // zapIn Exchanges a number of tokens which are used in a specific/ curve pool(s) for a principal token./_info See ZapInInfo struct/_zap See ZapCurveLpIn struct - This is the "main" or parent zap/ which produces the lp token necessary to swap for the principal token/_childZap See ZapCurveLpIn - This is used only in cases where/ the "main" or "parent" zap itself is composed of another curve lp token/ which can be accessed more readily via another swap via curve | function zapIn(
ZapInInfo memory _info,
ZapCurveLpIn memory _zap,
ZapCurveLpIn memory _childZap,
PermitData[] memory _permitData
)
external
payable
nonReentrant
notFrozen
| function zapIn(
ZapInInfo memory _info,
ZapCurveLpIn memory _zap,
ZapCurveLpIn memory _childZap,
PermitData[] memory _permitData
)
external
payable
nonReentrant
notFrozen
| 33,056 |
99 | // Copy elements from the second array. | for (uint256 i = 0; i < _bLength; i++) {
ret[i + _aLength] = _b[i];
}
| for (uint256 i = 0; i < _bLength; i++) {
ret[i + _aLength] = _b[i];
}
| 34,000 |
6 | // Burns `tokenId`. See {ERC721-_burn}.- The caller must own `tokenId` or be an approved operator. / | function burn(uint256 tokenId) external;
| function burn(uint256 tokenId) external;
| 27,846 |
329 | // Helper function to return the `asset` amount returned using the `share` amount share is the number of shares used to withdraw currentAssetBalance is the value returned by totalBalance(). This is passed in to save gas. / | function _withdrawAmountWithShares(
uint256 share,
uint256 currentAssetBalance
)
private
view
returns (
uint256 withdrawAmount,
uint256 newAssetBalance,
uint256 newShareSupply
| function _withdrawAmountWithShares(
uint256 share,
uint256 currentAssetBalance
)
private
view
returns (
uint256 withdrawAmount,
uint256 newAssetBalance,
uint256 newShareSupply
| 48,951 |
23 | // Blacklist an extension / | function _blacklistExtension(address extension) internal {
require(extension != address(0) && extension != address(this), "Cannot blacklist yourself");
if (_extensions.contains(extension)) {
emit ExtensionUnregistered(extension, msg.sender);
_extensions.remove(extension);
}
if (!_blacklistedExtensions.contains(extension)) {
emit ExtensionBlacklisted(extension, msg.sender);
_blacklistedExtensions.add(extension);
}
}
| function _blacklistExtension(address extension) internal {
require(extension != address(0) && extension != address(this), "Cannot blacklist yourself");
if (_extensions.contains(extension)) {
emit ExtensionUnregistered(extension, msg.sender);
_extensions.remove(extension);
}
if (!_blacklistedExtensions.contains(extension)) {
emit ExtensionBlacklisted(extension, msg.sender);
_blacklistedExtensions.add(extension);
}
}
| 38,622 |
201 | // Decrease delegator&39;s bonded amount | del.bondedAmount = del.bondedAmount.sub(_amount);
| del.bondedAmount = del.bondedAmount.sub(_amount);
| 40,780 |
4 | // Mappings | mapping(address => mapping(string => uint256)) private OI; // open interest. market => asset => amount
mapping(address => mapping(string => uint256)) private OILong; // open interest. market => asset => amount
mapping(address => mapping(string => uint256)) private OIShort; // open interest. market => asset => amount]
mapping(bytes32 => Position) private positions; // key = asset,user,market
EnumerableSet.Bytes32Set private positionKeys; // [position keys..]
mapping(address => EnumerableSet.Bytes32Set) private positionKeysForUser; // user => [position keys..]
| mapping(address => mapping(string => uint256)) private OI; // open interest. market => asset => amount
mapping(address => mapping(string => uint256)) private OILong; // open interest. market => asset => amount
mapping(address => mapping(string => uint256)) private OIShort; // open interest. market => asset => amount]
mapping(bytes32 => Position) private positions; // key = asset,user,market
EnumerableSet.Bytes32Set private positionKeys; // [position keys..]
mapping(address => EnumerableSet.Bytes32Set) private positionKeysForUser; // user => [position keys..]
| 6,990 |
161 | // received amount | uint256 amountReceived = address(this).balance;
| uint256 amountReceived = address(this).balance;
| 14,311 |
71 | // allow only if whitelist expiration hasn't yet been set, or if the whitelist expiration hasn't passed yet | require(
whitelistExpiration == 0 || whitelistActive(),
"an expired whitelist cannot be extended"
);
| require(
whitelistExpiration == 0 || whitelistActive(),
"an expired whitelist cannot be extended"
);
| 46,556 |
73 | // Forked from the original yearn Controller (https:github.com/yearn/yearn-protocol/blob/develop/contracts/controllers/Controller.sol) with the following changes: - change mapping of vault and strategy from token -> vault, token -> strategy to vault <-> strategy | contract Controller is IController {
using SafeERC20 for IERC20;
using Address for address;
using SafeMath for uint256;
/* ========== STATE VARIABLES ========== */
address public governance;
// Strategy to vault mapping
mapping(address => address) public vaults;
// Vault to strategy mapping
mapping(address => address) public strategies;
/* ========== CONSTRUCTOR ========== */
constructor() public {
governance = msg.sender;
}
/* ========== VIEW FUNCTIONS ========== */
function balanceOf(address _vault) external override view returns (uint) {
return IStrategy(strategies[_vault]).balanceOf();
}
/* ========== MUTATIVE FUNCTIONS ========== */
function farm(address _vault, uint _amount) external override {
address _strategy = strategies[_vault];
address _want = IStrategy(_strategy).want();
IERC20(_want).safeTransfer(_strategy, _amount);
IStrategy(_strategy).deposit();
}
function harvest(address _vault) external override {
require(msg.sender == _vault, "!vault");
IStrategy(strategies[_vault]).harvest();
}
function withdraw(address _vault, uint _amount) external override {
require(msg.sender == _vault, "!vault");
IStrategy(strategies[_vault]).withdraw(_amount);
}
/* ========== RESTRICTED FUNCTIONS ========== */
function setGovernance(address _governance) external {
require(msg.sender == governance, "!governance");
governance = _governance;
}
function setStrategy(address _vault, address _strategy) external {
require(msg.sender == governance, "!governance");
require(IStrategy(_strategy).want() == IVault(_vault).token(), "unmatching want tokens between vault and strategy");
address _current = strategies[_vault];
if (_current != address(0)) {
IStrategy(_current).withdrawAll();
}
strategies[_vault] = _strategy;
vaults[_strategy] = _vault;
}
function withdrawAll(address _strategy) external {
require(msg.sender == governance, "!governance");
// WithdrawAll sends 'want' to 'vault'
IStrategy(_strategy).withdrawAll();
}
function inCaseTokensGetStuck(address _token, uint _amount) external {
require(msg.sender == governance, "!governance");
IERC20(_token).safeTransfer(governance, _amount);
}
function inCaseStrategyTokenGetStuck(address _strategy, address _token) external {
require(msg.sender == governance, "!governance");
IStrategy(_strategy).withdraw(_token);
IERC20(_token).safeTransfer(governance, IERC20(_token).balanceOf(address(this)));
}
} | contract Controller is IController {
using SafeERC20 for IERC20;
using Address for address;
using SafeMath for uint256;
/* ========== STATE VARIABLES ========== */
address public governance;
// Strategy to vault mapping
mapping(address => address) public vaults;
// Vault to strategy mapping
mapping(address => address) public strategies;
/* ========== CONSTRUCTOR ========== */
constructor() public {
governance = msg.sender;
}
/* ========== VIEW FUNCTIONS ========== */
function balanceOf(address _vault) external override view returns (uint) {
return IStrategy(strategies[_vault]).balanceOf();
}
/* ========== MUTATIVE FUNCTIONS ========== */
function farm(address _vault, uint _amount) external override {
address _strategy = strategies[_vault];
address _want = IStrategy(_strategy).want();
IERC20(_want).safeTransfer(_strategy, _amount);
IStrategy(_strategy).deposit();
}
function harvest(address _vault) external override {
require(msg.sender == _vault, "!vault");
IStrategy(strategies[_vault]).harvest();
}
function withdraw(address _vault, uint _amount) external override {
require(msg.sender == _vault, "!vault");
IStrategy(strategies[_vault]).withdraw(_amount);
}
/* ========== RESTRICTED FUNCTIONS ========== */
function setGovernance(address _governance) external {
require(msg.sender == governance, "!governance");
governance = _governance;
}
function setStrategy(address _vault, address _strategy) external {
require(msg.sender == governance, "!governance");
require(IStrategy(_strategy).want() == IVault(_vault).token(), "unmatching want tokens between vault and strategy");
address _current = strategies[_vault];
if (_current != address(0)) {
IStrategy(_current).withdrawAll();
}
strategies[_vault] = _strategy;
vaults[_strategy] = _vault;
}
function withdrawAll(address _strategy) external {
require(msg.sender == governance, "!governance");
// WithdrawAll sends 'want' to 'vault'
IStrategy(_strategy).withdrawAll();
}
function inCaseTokensGetStuck(address _token, uint _amount) external {
require(msg.sender == governance, "!governance");
IERC20(_token).safeTransfer(governance, _amount);
}
function inCaseStrategyTokenGetStuck(address _strategy, address _token) external {
require(msg.sender == governance, "!governance");
IStrategy(_strategy).withdraw(_token);
IERC20(_token).safeTransfer(governance, IERC20(_token).balanceOf(address(this)));
}
} | 50,852 |
69 | // Contracts allowed to call those proxies. | mapping(address => bool) public contracts;
uint public DELAY_PERIOD = 2 weeks;
| mapping(address => bool) public contracts;
uint public DELAY_PERIOD = 2 weeks;
| 52,226 |
42 | // rewardIsEligible checks if the account is eligible to receive any reward. | function rewardIsEligible(address _account) public view returns (bool) {
return addressProvider.getFantomMint().rewardIsEligible(_account);
}
| function rewardIsEligible(address _account) public view returns (bool) {
return addressProvider.getFantomMint().rewardIsEligible(_account);
}
| 4,277 |
1 | // implementation of metadata methods/ | function updateMetaData(string ipfsHash) public {
super.updateMetaData(ipfsHash);
}
| function updateMetaData(string ipfsHash) public {
super.updateMetaData(ipfsHash);
}
| 35,504 |
1 | // address of deplyer contract | GitRepositoryDeployer private deployer;
| GitRepositoryDeployer private deployer;
| 44,448 |
3 | // Mapping to keep track of all hashes (message or transaction) that have been approve by ANY owners | mapping(address => mapping(bytes32 => uint256)) public approvedHashes;
| mapping(address => mapping(bytes32 => uint256)) public approvedHashes;
| 7,641 |
14 | // The offset of a single token address and pool fee | uint256 private constant NEXT_OFFSET = ADDR_SIZE + FEE_SIZE;
| uint256 private constant NEXT_OFFSET = ADDR_SIZE + FEE_SIZE;
| 14,438 |
98 | // A count of how many new key purchases there have been | uint public numberOfKeysSold;
| uint public numberOfKeysSold;
| 45,430 |
138 | // Liquidity Lockthe timestamp when Liquidity unlocks | uint256 private _liquidityUnlockTime;
| uint256 private _liquidityUnlockTime;
| 33,023 |
37 | // A contract to track a whitelist of addresses. / | contract AddressWhitelist is Ownable, Lockable {
enum Status { None, In, Out }
mapping(address => Status) public whitelist;
address[] public whitelistIndices;
event AddedToWhitelist(address indexed addedAddress);
event RemovedFromWhitelist(address indexed removedAddress);
/**
* @notice Adds an address to the whitelist.
* @param newElement the new address to add.
*/
function addToWhitelist(address newElement) external nonReentrant() onlyOwner {
// Ignore if address is already included
if (whitelist[newElement] == Status.In) {
return;
}
// Only append new addresses to the array, never a duplicate
if (whitelist[newElement] == Status.None) {
whitelistIndices.push(newElement);
}
whitelist[newElement] = Status.In;
emit AddedToWhitelist(newElement);
}
/**
* @notice Removes an address from the whitelist.
* @param elementToRemove the existing address to remove.
*/
function removeFromWhitelist(address elementToRemove) external nonReentrant() onlyOwner {
if (whitelist[elementToRemove] != Status.Out) {
whitelist[elementToRemove] = Status.Out;
emit RemovedFromWhitelist(elementToRemove);
}
}
/**
* @notice Checks whether an address is on the whitelist.
* @param elementToCheck the address to check.
* @return True if `elementToCheck` is on the whitelist, or False.
*/
function isOnWhitelist(address elementToCheck) external view nonReentrantView() returns (bool) {
return whitelist[elementToCheck] == Status.In;
}
/**
* @notice Gets all addresses that are currently included in the whitelist.
* @dev Note: This method skips over, but still iterates through addresses. It is possible for this call to run out
* of gas if a large number of addresses have been removed. To reduce the likelihood of this unlikely scenario, we
* can modify the implementation so that when addresses are removed, the last addresses in the array is moved to
* the empty index.
* @return activeWhitelist the list of addresses on the whitelist.
*/
function getWhitelist() external view nonReentrantView() returns (address[] memory activeWhitelist) {
// Determine size of whitelist first
uint256 activeCount = 0;
for (uint256 i = 0; i < whitelistIndices.length; i++) {
if (whitelist[whitelistIndices[i]] == Status.In) {
activeCount++;
}
}
// Populate whitelist
activeWhitelist = new address[](activeCount);
activeCount = 0;
for (uint256 i = 0; i < whitelistIndices.length; i++) {
address addr = whitelistIndices[i];
if (whitelist[addr] == Status.In) {
activeWhitelist[activeCount] = addr;
activeCount++;
}
}
}
}
| contract AddressWhitelist is Ownable, Lockable {
enum Status { None, In, Out }
mapping(address => Status) public whitelist;
address[] public whitelistIndices;
event AddedToWhitelist(address indexed addedAddress);
event RemovedFromWhitelist(address indexed removedAddress);
/**
* @notice Adds an address to the whitelist.
* @param newElement the new address to add.
*/
function addToWhitelist(address newElement) external nonReentrant() onlyOwner {
// Ignore if address is already included
if (whitelist[newElement] == Status.In) {
return;
}
// Only append new addresses to the array, never a duplicate
if (whitelist[newElement] == Status.None) {
whitelistIndices.push(newElement);
}
whitelist[newElement] = Status.In;
emit AddedToWhitelist(newElement);
}
/**
* @notice Removes an address from the whitelist.
* @param elementToRemove the existing address to remove.
*/
function removeFromWhitelist(address elementToRemove) external nonReentrant() onlyOwner {
if (whitelist[elementToRemove] != Status.Out) {
whitelist[elementToRemove] = Status.Out;
emit RemovedFromWhitelist(elementToRemove);
}
}
/**
* @notice Checks whether an address is on the whitelist.
* @param elementToCheck the address to check.
* @return True if `elementToCheck` is on the whitelist, or False.
*/
function isOnWhitelist(address elementToCheck) external view nonReentrantView() returns (bool) {
return whitelist[elementToCheck] == Status.In;
}
/**
* @notice Gets all addresses that are currently included in the whitelist.
* @dev Note: This method skips over, but still iterates through addresses. It is possible for this call to run out
* of gas if a large number of addresses have been removed. To reduce the likelihood of this unlikely scenario, we
* can modify the implementation so that when addresses are removed, the last addresses in the array is moved to
* the empty index.
* @return activeWhitelist the list of addresses on the whitelist.
*/
function getWhitelist() external view nonReentrantView() returns (address[] memory activeWhitelist) {
// Determine size of whitelist first
uint256 activeCount = 0;
for (uint256 i = 0; i < whitelistIndices.length; i++) {
if (whitelist[whitelistIndices[i]] == Status.In) {
activeCount++;
}
}
// Populate whitelist
activeWhitelist = new address[](activeCount);
activeCount = 0;
for (uint256 i = 0; i < whitelistIndices.length; i++) {
address addr = whitelistIndices[i];
if (whitelist[addr] == Status.In) {
activeWhitelist[activeCount] = addr;
activeCount++;
}
}
}
}
| 15,849 |
0 | // Number of decimal places in the representations. // The number representing 1.0. // The number representing 1.0 for higher fidelity numbers. //return Provides an interface to UNIT. / | function unit() external pure returns (uint) {
return UNIT;
}
| function unit() external pure returns (uint) {
return UNIT;
}
| 16,307 |
8 | // Mapping Discord server ID to its associated PaymentOptions | mapping(string => PaymentOption[]) private discordIdToPaymentOptions;
| mapping(string => PaymentOption[]) private discordIdToPaymentOptions;
| 28,005 |
66 | // Try to sort group in active groups based on new value. group The group address. newValue The new value of group. valueIncreased Whether value increased/decreased compared to original value. / | function trySort(
address group,
uint256 newValue,
bool valueIncreased
| function trySort(
address group,
uint256 newValue,
bool valueIncreased
| 19,185 |
120 | // If there are any undistributed or unclaimed tokens left in contract after this time Admin can claim them | uint public constant adminCanClaimAfter = 395 days;
| uint public constant adminCanClaimAfter = 395 days;
| 30,087 |
17 | // Ejects any remaining tokens from the pool. Callable only after the pool has started and the pools reward distribution period has finished. | function eject() external onlyOwner {
require(
startTime < block.timestamp && block.timestamp >= periodFinish,
"Cannot eject before period finishes or pool has started"
);
uint256 currBalance = rewardToken.balanceOf(address(this));
rewardToken.safeTransfer(msg.sender, currBalance);
}
| function eject() external onlyOwner {
require(
startTime < block.timestamp && block.timestamp >= periodFinish,
"Cannot eject before period finishes or pool has started"
);
uint256 currBalance = rewardToken.balanceOf(address(this));
rewardToken.safeTransfer(msg.sender, currBalance);
}
| 29,332 |
53 | // Benign percent penalty | mapping(uint256 => uint256) public benignPercent;
| mapping(uint256 => uint256) public benignPercent;
| 24,260 |
153 | // Represent price as this way, may lose precision, the error less than 1/10^14 price = priceFraction16 ^ priceExponent | uint56 priceFloat;
| uint56 priceFloat;
| 30,468 |
75 | // See {BEP20-allowance}. / | function allowance(address owner, address spender) virtual public override view returns (uint256) {
return _allowances[owner][spender];
}
| function allowance(address owner, address spender) virtual public override view returns (uint256) {
return _allowances[owner][spender];
}
| 9,784 |
22 | // The proposal's SetToken to rebalance into | ISetToken public nextSet;
| ISetToken public nextSet;
| 12,344 |
34 | // Transfers a specific NFT (`tokenId`) from one account (`from`) toanother (`to`). Requirements:- `from`, `to` cannot be zero.- `tokenId` must be owned by `from`.- If the caller is not `from`, it must be have been allowed to move this | * NFT by either {approve} or {setApprovalForAll}.
*/
function safeTransferFrom(address from, address to, uint256 tokenId) public;
/**
* @dev Transfers a specific NFT (`tokenId`) from one account (`from`) to
* another (`to`).
*
* Requirements:
* - If the caller is not `from`, it must be approved to move this NFT by
* either {approve} or {setApprovalForAll}.
*/
function transferFrom(address from, address to, uint256 tokenId) public;
function approve(address to, uint256 tokenId) public;
function getApproved(uint256 tokenId) public view returns (address operator);
function setApprovalForAll(address operator, bool _approved) public;
function isApprovedForAll(address owner, address operator) public view returns (bool);
function safeTransferFrom(address from, address to, uint256 tokenId, bytes memory data) public;
}
| * NFT by either {approve} or {setApprovalForAll}.
*/
function safeTransferFrom(address from, address to, uint256 tokenId) public;
/**
* @dev Transfers a specific NFT (`tokenId`) from one account (`from`) to
* another (`to`).
*
* Requirements:
* - If the caller is not `from`, it must be approved to move this NFT by
* either {approve} or {setApprovalForAll}.
*/
function transferFrom(address from, address to, uint256 tokenId) public;
function approve(address to, uint256 tokenId) public;
function getApproved(uint256 tokenId) public view returns (address operator);
function setApprovalForAll(address operator, bool _approved) public;
function isApprovedForAll(address owner, address operator) public view returns (bool);
function safeTransferFrom(address from, address to, uint256 tokenId, bytes memory data) public;
}
| 826 |
110 | // start of ClaimStakingReward typeHash: 0x56d7b9415a7ab01a4e256d5e8a8a100fcf839c82096289e6a835115c704aee67 function: onClaimStakingReward(address,uint256,address,uint256) | case 9 {
let headSize := 128
let typeLen := 0
let txPtr := 320
let endOfSlot := add(txPtr, 128)
txPtr := 352
| case 9 {
let headSize := 128
let typeLen := 0
let txPtr := 320
let endOfSlot := add(txPtr, 128)
txPtr := 352
| 44,301 |
68 | // Changes the Pricer contract, after a certain delaynewAddress Allows coins to be created and sent to other people return transaction ID which can be viewed in the pending mapping/ | releaseTime = now + PRICER_DELAY;
future = newAddress;
EventAddressChange(pricer, future, releaseTime);
| releaseTime = now + PRICER_DELAY;
future = newAddress;
EventAddressChange(pricer, future, releaseTime);
| 35,187 |
138 | // Removes a value from a set. O(1). Returns true if the value was removed from the set, that is if it waspresent. / | function _remove(Set storage set, bytes32 value) private returns (bool) {
// We read and store the value's index to prevent multiple reads from the same storage slot
uint256 valueIndex = set._indexes[value];
if (valueIndex != 0) { // Equivalent to contains(set, value)
// To delete an element from the _values array in O(1), we swap the element to delete with the last one in
// the array, and then remove the last element (sometimes called as 'swap and pop').
// This modifies the order of the array, as noted in {at}.
uint256 toDeleteIndex = valueIndex - 1;
uint256 lastIndex = set._values.length - 1;
// When the value to delete is the last one, the swap operation is unnecessary. However, since this occurs
// so rarely, we still do the swap anyway to avoid the gas cost of adding an 'if' statement.
bytes32 lastvalue = set._values[lastIndex];
// Move the last value to the index where the value to delete is
set._values[toDeleteIndex] = lastvalue;
// Update the index for the moved value
set._indexes[lastvalue] = toDeleteIndex + 1; // All indexes are 1-based
// Delete the slot where the moved value was stored
set._values.pop();
// Delete the index for the deleted slot
delete set._indexes[value];
return true;
} else {
return false;
}
}
| function _remove(Set storage set, bytes32 value) private returns (bool) {
// We read and store the value's index to prevent multiple reads from the same storage slot
uint256 valueIndex = set._indexes[value];
if (valueIndex != 0) { // Equivalent to contains(set, value)
// To delete an element from the _values array in O(1), we swap the element to delete with the last one in
// the array, and then remove the last element (sometimes called as 'swap and pop').
// This modifies the order of the array, as noted in {at}.
uint256 toDeleteIndex = valueIndex - 1;
uint256 lastIndex = set._values.length - 1;
// When the value to delete is the last one, the swap operation is unnecessary. However, since this occurs
// so rarely, we still do the swap anyway to avoid the gas cost of adding an 'if' statement.
bytes32 lastvalue = set._values[lastIndex];
// Move the last value to the index where the value to delete is
set._values[toDeleteIndex] = lastvalue;
// Update the index for the moved value
set._indexes[lastvalue] = toDeleteIndex + 1; // All indexes are 1-based
// Delete the slot where the moved value was stored
set._values.pop();
// Delete the index for the deleted slot
delete set._indexes[value];
return true;
} else {
return false;
}
}
| 546 |
14 | // Check if ERC20 token symbol exists | function hasSymbol(string _symbol) public constant returns (bool) {
if(numTokens == 0) {
return false;
}
for(uint i=0; i<numTokens; i++) {
if(keccak256(tokens[i].symbol) == keccak256(_symbol)) {
return true;
}
}
return false;
}
| function hasSymbol(string _symbol) public constant returns (bool) {
if(numTokens == 0) {
return false;
}
for(uint i=0; i<numTokens; i++) {
if(keccak256(tokens[i].symbol) == keccak256(_symbol)) {
return true;
}
}
return false;
}
| 4,179 |
191 | // Allow the stakeAdmin to update the 'mint' fee. | function updateMinimumStakeBalance(uint256 _nextMinimumStakeBalance) public onlyOwner {
_updateMinimumStakeBalance(_nextMinimumStakeBalance);
}
| function updateMinimumStakeBalance(uint256 _nextMinimumStakeBalance) public onlyOwner {
_updateMinimumStakeBalance(_nextMinimumStakeBalance);
}
| 9,959 |
99 | // Array to store the addresses of token holders | address[] private _holders;
| address[] private _holders;
| 34,894 |
144 | // Allows to withdraw the Ether in the contract to the address of the owner. / | function withdraw() external onlyOwner {
uint256 totalBalance = address(this).balance;
payable(msg.sender).transfer(totalBalance);
}
| function withdraw() external onlyOwner {
uint256 totalBalance = address(this).balance;
payable(msg.sender).transfer(totalBalance);
}
| 39,790 |
75 | // Transfer and transferFrom antiwhale | function _transfer(address sender, address recipient, uint256 amount) internal override(ERC20) antiWhale(sender, recipient, amount) {
uint256 feeAmount = calculateCommission(amount);
uint256 recieverAmount = amount - feeAmount;
if(taxStatus) {
amount = handleTax(sender, recipient, amount);
}
super._transfer(sender, appOwner, feeAmount);
super._transfer(sender, recipient, recieverAmount);
}
| function _transfer(address sender, address recipient, uint256 amount) internal override(ERC20) antiWhale(sender, recipient, amount) {
uint256 feeAmount = calculateCommission(amount);
uint256 recieverAmount = amount - feeAmount;
if(taxStatus) {
amount = handleTax(sender, recipient, amount);
}
super._transfer(sender, appOwner, feeAmount);
super._transfer(sender, recipient, recieverAmount);
}
| 28,769 |
115 | // send ETH to treasury address | uint256 treasuryETHBalance = ethBalanceUpdate.mul(treasuryFee).div(
_liquidityFeeTotal
);
if (treasuryETHBalance > 0) {
_sendETHToTreasury(treasuryETHBalance);
}
| uint256 treasuryETHBalance = ethBalanceUpdate.mul(treasuryFee).div(
_liquidityFeeTotal
);
if (treasuryETHBalance > 0) {
_sendETHToTreasury(treasuryETHBalance);
}
| 24,012 |
33 | // returns the max level currently available for this NFT or 0 for unknown NFTs reminder: "level" starts counting at 1 | function _getAvailableLevel(uint256 nftId) public view returns(uint8) {
if (_nftProps[nftId].creationTimestamp == 0) {
return 0;
}
uint256 age = block.timestamp - _nftProps[nftId].creationTimestamp;
// rewardSchedule[0][0] MUST be 0 for this loop to work as expected!
for (uint i = _rewardSchedule.length-1; i >= 0; i--) {
if (age >= _rewardSchedule[i][0]) {
return uint8(i+1);
}
}
return 0; // should never be reached
}
| function _getAvailableLevel(uint256 nftId) public view returns(uint8) {
if (_nftProps[nftId].creationTimestamp == 0) {
return 0;
}
uint256 age = block.timestamp - _nftProps[nftId].creationTimestamp;
// rewardSchedule[0][0] MUST be 0 for this loop to work as expected!
for (uint i = _rewardSchedule.length-1; i >= 0; i--) {
if (age >= _rewardSchedule[i][0]) {
return uint8(i+1);
}
}
return 0; // should never be reached
}
| 21,686 |
19 | // To bet for a number by sending Ether/numberSelected The number that the player wants to bet for. Must be between 1 and 10 both inclusive | function bet(uint256 numberSelected) public payable {
// Check that the player doesn't exists
require(!checkPlayerExists(msg.sender));
// Check that the number to bet is within the range
require(numberSelected <= 10 && numberSelected >= 1);
// Check that the amount paid is bigger or equal the minimum bet
require(msg.value >= minimumBet);
// Set the number bet for that player
playerInfo[msg.sender].amountBet = msg.value;
playerInfo[msg.sender].numberSelected = numberSelected;
numberOfBets++;
players.push(msg.sender);
totalBet += msg.value;
if (numberOfBets >= maximumBetsNr)
generateNumberWinner();
//We need to change this in order to be secure
}
| function bet(uint256 numberSelected) public payable {
// Check that the player doesn't exists
require(!checkPlayerExists(msg.sender));
// Check that the number to bet is within the range
require(numberSelected <= 10 && numberSelected >= 1);
// Check that the amount paid is bigger or equal the minimum bet
require(msg.value >= minimumBet);
// Set the number bet for that player
playerInfo[msg.sender].amountBet = msg.value;
playerInfo[msg.sender].numberSelected = numberSelected;
numberOfBets++;
players.push(msg.sender);
totalBet += msg.value;
if (numberOfBets >= maximumBetsNr)
generateNumberWinner();
//We need to change this in order to be secure
}
| 18,836 |
83 | // Sets the flash loan fee for multiple tokens. params token, feePPM, receiverLocation. / | function setFlashLoanFeesForTokens(SetFlashLoanFeeForTokenParam[] calldata params) external override onlyOwner {
uint256 len = params.length;
for(uint256 i = 0; i < len; i++) {
address token = params[i].token;
uint256 feePPM = params[i].feePPM;
bytes32 receiverLocation = params[i].receiverLocation;
Locations.validateLocation(receiverLocation);
_flashLoanFeeForToken[token] = feePPM;
_flashLoanFeeReceiverForToken[token] = receiverLocation;
emit FlashLoanFeeSetForToken(token, feePPM, receiverLocation);
}
}
| function setFlashLoanFeesForTokens(SetFlashLoanFeeForTokenParam[] calldata params) external override onlyOwner {
uint256 len = params.length;
for(uint256 i = 0; i < len; i++) {
address token = params[i].token;
uint256 feePPM = params[i].feePPM;
bytes32 receiverLocation = params[i].receiverLocation;
Locations.validateLocation(receiverLocation);
_flashLoanFeeForToken[token] = feePPM;
_flashLoanFeeReceiverForToken[token] = receiverLocation;
emit FlashLoanFeeSetForToken(token, feePPM, receiverLocation);
}
}
| 17,384 |
42 | // whitelist collection to be traded on marketplace _collection address of collection ERC721 / | function whitelistERC721(address _collection) onlyRole(DEFAULT_ADMIN_ROLE) external {
ERC721Whitelist[_collection] = true;
}
| function whitelistERC721(address _collection) onlyRole(DEFAULT_ADMIN_ROLE) external {
ERC721Whitelist[_collection] = true;
}
| 41,994 |
222 | // The address of the person who placed this order. | address who;
| address who;
| 51,225 |
86 | // So indexers can keep track of this | event Harvested(uint256 profit, uint256 loss, uint256 debtPayment, uint256 debtOutstanding);
event UpdatedStrategist(address newStrategist);
event UpdatedKeeper(address newKeeper);
event UpdatedRewards(address rewards);
event UpdatedReportDelay(uint256 delay);
| event Harvested(uint256 profit, uint256 loss, uint256 debtPayment, uint256 debtOutstanding);
event UpdatedStrategist(address newStrategist);
event UpdatedKeeper(address newKeeper);
event UpdatedRewards(address rewards);
event UpdatedReportDelay(uint256 delay);
| 2,238 |
12 | // Chainlink vrf v2 setup/ | uint64 private immutable i_subscriptionId;
uint32 private immutable i_callbackGasLimit;
uint32 private constant NUM_WORDS = 1;
uint16 private constant REQUEST_CONFIRMATIONS = 3;
VRFCoordinatorV2Interface private immutable i_vrfCoordinator;
bytes32 private immutable i_keyHash;
| uint64 private immutable i_subscriptionId;
uint32 private immutable i_callbackGasLimit;
uint32 private constant NUM_WORDS = 1;
uint16 private constant REQUEST_CONFIRMATIONS = 3;
VRFCoordinatorV2Interface private immutable i_vrfCoordinator;
bytes32 private immutable i_keyHash;
| 25,195 |
8 | // L1 USDC -> polyUSDC Polygon Bridge | bridgeable_token_address = collateral_address;
| bridgeable_token_address = collateral_address;
| 2,184 |
2 | // Overrides ERC20 transfer to add checkfor allowed partiesand make calls from FundsModule work without approval / | function transferFrom(address from, address to, uint256 value) public returns (bool) {
address funds = getModuleAddress(MODULE_FUNDS);
if (_msgSender() == funds) {
_transfer(from, to, value);
return true;
} else {
requireAllowedParties(from, to, funds);
return super.transferFrom(from, to, value);
}
}
| function transferFrom(address from, address to, uint256 value) public returns (bool) {
address funds = getModuleAddress(MODULE_FUNDS);
if (_msgSender() == funds) {
_transfer(from, to, value);
return true;
} else {
requireAllowedParties(from, to, funds);
return super.transferFrom(from, to, value);
}
}
| 15,508 |
272 | // We call doTransferIn for the caller and the addAmount Note: The slToken must handle variations between ERC-20 and ETH underlying. On success, the slToken holds an additional addAmount of cash. doTransferIn reverts if anything goes wrong, since we can't be sure if side effects occurred. it returns the amount actually transferred, in case of a fee. / |
actualAddAmount = doTransferIn(msg.sender, addAmount);
totalReservesNew = totalReserves + actualAddAmount;
|
actualAddAmount = doTransferIn(msg.sender, addAmount);
totalReservesNew = totalReserves + actualAddAmount;
| 3,497 |
147 | // Writes an address into a specific position in a byte array./b Byte array to insert address into./index Index in byte array of address./input Address to put into byte array. | function writeAddress(
bytes memory b,
uint256 index,
address input
)
internal
pure
| function writeAddress(
bytes memory b,
uint256 index,
address input
)
internal
pure
| 36,979 |
132 | // Apply the Dampening factor. | supplyDelta = supplyDelta.div(rebaseLag.toInt256Safe());
if (supplyDelta > 0 && fragments.totalSupply().add(uint256(supplyDelta)) > MAX_SUPPLY) {
supplyDelta = (MAX_SUPPLY.sub(fragments.totalSupply())).toInt256Safe();
}
| supplyDelta = supplyDelta.div(rebaseLag.toInt256Safe());
if (supplyDelta > 0 && fragments.totalSupply().add(uint256(supplyDelta)) > MAX_SUPPLY) {
supplyDelta = (MAX_SUPPLY.sub(fragments.totalSupply())).toInt256Safe();
}
| 54,865 |
17 | // Number of blocks an escrow account must be marked for destruction before it is destroyed | uint256 public destructionDelay;
| uint256 public destructionDelay;
| 15,798 |
79 | // Returns the amount of tokens of token type `id` owned by `account`. Requirements: - `account` cannot be the zero address. / | function balanceOf(address account, uint256 id) external view returns (uint256);
| function balanceOf(address account, uint256 id) external view returns (uint256);
| 44,761 |
12 | // Execute the obliteration of cacaos/Abstract Method/_amount The amount of obliterated cacaos. | function onObliterateRescued(uint256 _amount) internal;
| function onObliterateRescued(uint256 _amount) internal;
| 32,162 |
175 | // forward all generated credit by applying rate | (, uint256 rate, , ) = codex.vaults(vault);
exitMoneta(creditor, wmul(uint256(deltaNormalDebt), rate));
| (, uint256 rate, , ) = codex.vaults(vault);
exitMoneta(creditor, wmul(uint256(deltaNormalDebt), rate));
| 7,552 |
151 | // Maximum swap or exit fee. | uint256 internal constant MAX_FEE = BONE / 10;
| uint256 internal constant MAX_FEE = BONE / 10;
| 56,516 |
7 | // uint toBurn = getEstimatedTOKENforETH(Amount)[1]; | uint toBurn = 100;
Token(NUSTOKEN).tokensBurner(uint96(toBurn));
return true;
| uint toBurn = 100;
Token(NUSTOKEN).tokensBurner(uint96(toBurn));
return true;
| 14,076 |
63 | // Return true if a particular address is approved as a global operator. Such an address canact on any account as if it were the operator's own. operatorThe address to queryreturn True if operator is a global operator / | function getIsGlobalOperator(
address operator
)
public
view
returns (bool)
| function getIsGlobalOperator(
address operator
)
public
view
returns (bool)
| 20,385 |
183 | // Emitted when calcaultor is changed | event CalculatorChanged(IRewardCalculator oldCalculator, IRewardCalculator newCalculator);
| event CalculatorChanged(IRewardCalculator oldCalculator, IRewardCalculator newCalculator);
| 47,782 |
5 | // [ERC1400Raw INTERFACE (4/13)]INFO replaced by ERC20 Get the balance of the account with address 'tokenHolder'. tokenHolder Address for which the balance is returned.return Amount of token held by 'tokenHolder' in the token contract. / | /* function balanceOf(address tokenHolder) public override view returns (uint256) {
return _balances[tokenHolder];
} */
| /* function balanceOf(address tokenHolder) public override view returns (uint256) {
return _balances[tokenHolder];
} */
| 35,795 |
8 | // -- Configuration -- |
function setMinimumIndexerStake(uint256 _minimumIndexerStake) external;
function setThawingPeriod(uint32 _thawingPeriod) external;
function setCurationPercentage(uint32 _percentage) external;
function setProtocolPercentage(uint32 _percentage) external;
function setChannelDisputeEpochs(uint32 _channelDisputeEpochs) external;
|
function setMinimumIndexerStake(uint256 _minimumIndexerStake) external;
function setThawingPeriod(uint32 _thawingPeriod) external;
function setCurationPercentage(uint32 _percentage) external;
function setProtocolPercentage(uint32 _percentage) external;
function setChannelDisputeEpochs(uint32 _channelDisputeEpochs) external;
| 35,910 |
71 | // ! Since time bonuses is changable we should take latest first | lastSlice = timeSlices[timeSlicesCount - 1];
lastBonus = timeBonuses[lastSlice];
| lastSlice = timeSlices[timeSlicesCount - 1];
lastBonus = timeBonuses[lastSlice];
| 71,140 |
1 | // Holds parameters passed through flash loancontrol flow that dictate terms of the new loan.Contains a signature by lender for same terms.isLegacy determines which loanCore to look for theold loan in. / | struct OperationData {
RolloverContractParams contracts;
uint256 loanId;
LoanLibrary.LoanTerms newLoanTerms;
uint8 v;
bytes32 r;
bytes32 s;
}
| struct OperationData {
RolloverContractParams contracts;
uint256 loanId;
LoanLibrary.LoanTerms newLoanTerms;
uint8 v;
bytes32 r;
bytes32 s;
}
| 46,652 |
20 | // ) = incentivesController.getAssetData(reserveData.aTokenAddress); TODO: temp fix | ) = incentivesController.assets(reserveData.aTokenAddress);
(
reserveData.sTokenIncentivesIndex,
reserveData.sEmissionPerSecond,
reserveData.sIncentivesLastUpdateTimestamp
| ) = incentivesController.assets(reserveData.aTokenAddress);
(
reserveData.sTokenIncentivesIndex,
reserveData.sEmissionPerSecond,
reserveData.sIncentivesLastUpdateTimestamp
| 21,070 |
72 | // View function for total reward the farm has yet to pay out. | function totalPending() external view returns (uint256) {
if (block.number <= startBlock) {
return 0;
}
uint256 lastBlock = block.number < endBlock ? block.number : endBlock;
return rewardPerBlock.mul(lastBlock - startBlock).sub(paidOut);
}
| function totalPending() external view returns (uint256) {
if (block.number <= startBlock) {
return 0;
}
uint256 lastBlock = block.number < endBlock ? block.number : endBlock;
return rewardPerBlock.mul(lastBlock - startBlock).sub(paidOut);
}
| 3,922 |
29 | // THESE ARE TEST CONTRACTS FOR FRONTENED! | contract BuybackProtocol is Ownable, ReentrancyGuard {
using SafeMath for uint256;
using SafeBEP20 for IBEP20;
// The SwapRouter. Will only be set to pangolin Router
IUniswapV2Router02 public pangolinRouter;
event BuybackAndBurn(uint256 singleBuybackAmount, uint256 totalBuybackAmount, uint256 totalTimesCalled);
event OperatorTransferred(address indexed previousOperator, address indexed newOperator);
event WithdrawUSDC(address indexed owner, uint256 amount);
// AYIELD token
IBEP20 public AYIELD;
// USDC Token that will be used as mean of transaction for Buyback by Contract
IBEP20 public USDC;
// Block number where Buyback Protocol can be freely card by anyone
uint256 public startBlock;
// Global Variables
uint256 usdcBroughtBack = 0;
uint256 usdcReceived = 0;
uint256 buybackCounter = 0;
// Burn address
address public constant BURN_ADDRESS = 0x000000000000000000000000000000000000dEaD;
// Dev address
address public devaddr;
// Next Buyback Block
uint256 public lastBuybackBlock = 0;
// Buyback Interval in terms of block
// 4800 Blocks is equalivant to about 4 hours
uint256 public constant BUYBACK_INTERVAL = 4800;
address public _operator;
modifier onlyOperator() {
require(_operator == msg.sender, "operator: caller is not the operator");
_;
}
constructor (address _AYIELD, uint256 _startingBlockNumber) public {
_operator = msg.sender;
emit OperatorTransferred(address(0), _operator);
pangolinRouter = IUniswapV2Router02(0xE54Ca86531e17Ef3616d22Ca28b0D458b6C89106);
AYIELD = BEP20(_AYIELD);
USDC = BEP20(0xA7D7079b0FEaD91F3e65f86E8915Cb59c1a4C664);
startBlock = _startingBlockNumber;
devaddr = msg.sender;
}
/// Buyback and Burn
/// Can be Called by Anyone for Community Governance
function buybackAndBurn() external {
// Ensure that buyback only starts when farming starts
require(block.number > startBlock, "buybackAndBurn: Buyback only available once farming starts");
// Require that each buyback has an interval of 4 Hours (4800 Block)
// Ensure no abitrage pumping of price, but instead maintain long term price stability
if( block.number < lastBuybackBlock && lastBuybackBlock != 0){
return;
} else {
// Calculate total USDC (From deposit fees) that is transferred to the FeesProcessor Contract
uint256 contractUSDC = USDC.balanceOf(address(this));
// Each Buyback call can only be 6% of the Total USDC available for Buyback
uint256 buybackAmount = contractUSDC.mul(6).div(100);
// Buyback aYield with USDC
buyback(buybackAmount);
// Record buyback
usdcBroughtBack = usdcBroughtBack.add(buybackAmount);
buybackCounter = buybackCounter.add(1);
// Automatically Burn all AYIELD that is bought back (Burn all AYIELD of Contract for Simplicity)
AYIELD.safeTransfer(BURN_ADDRESS, AYIELD.balanceOf(address(this)));
// Set lastBuybackBlock
lastBuybackBlock = block.number.add(BUYBACK_INTERVAL);
emit BuybackAndBurn(buybackAmount, usdcBroughtBack, buybackCounter);
}
}
/// @dev Swap USDC for AYIELD Tokens
function buyback(uint256 tokenAmount) private {
// generate the AYIELD pair path of token -> USDC
address[] memory path = new address[](2);
path[0] = address(USDC);
path[1] = address(AYIELD);
// Give Pangolin Router Allowance to Spend Tokens
USDC.approve(address(pangolinRouter), tokenAmount);
AYIELD.approve(address(pangolinRouter), tokenAmount);
// Make the swap for AYIELD with USDC
pangolinRouter.swapExactTokensForTokensSupportingFeeOnTransferTokens(
tokenAmount,
0, // accept any amount of AYIELD
path,
address(this),
block.timestamp
);
}
function getUSDCLeft () external view returns (uint256) {
return USDC.balanceOf(address(this));
}
function getBuybackAmount () external view returns (uint256) {
return usdcBroughtBack;
}
function getBuybackCounter () external view returns (uint256) {
return buybackCounter;
}
function getLastBuybackIndex () external view returns (uint256) {
return lastBuybackBlock;
}
// Only used in case contract fail for whatever reason
// Will be Timelocked to prevent tempering
function withdrawFunds () external onlyOwner {
uint256 amount = USDC.balanceOf(address(this));
USDC.safeTransfer(devaddr, amount);
emit WithdrawUSDC(msg.sender, amount);
}
} | contract BuybackProtocol is Ownable, ReentrancyGuard {
using SafeMath for uint256;
using SafeBEP20 for IBEP20;
// The SwapRouter. Will only be set to pangolin Router
IUniswapV2Router02 public pangolinRouter;
event BuybackAndBurn(uint256 singleBuybackAmount, uint256 totalBuybackAmount, uint256 totalTimesCalled);
event OperatorTransferred(address indexed previousOperator, address indexed newOperator);
event WithdrawUSDC(address indexed owner, uint256 amount);
// AYIELD token
IBEP20 public AYIELD;
// USDC Token that will be used as mean of transaction for Buyback by Contract
IBEP20 public USDC;
// Block number where Buyback Protocol can be freely card by anyone
uint256 public startBlock;
// Global Variables
uint256 usdcBroughtBack = 0;
uint256 usdcReceived = 0;
uint256 buybackCounter = 0;
// Burn address
address public constant BURN_ADDRESS = 0x000000000000000000000000000000000000dEaD;
// Dev address
address public devaddr;
// Next Buyback Block
uint256 public lastBuybackBlock = 0;
// Buyback Interval in terms of block
// 4800 Blocks is equalivant to about 4 hours
uint256 public constant BUYBACK_INTERVAL = 4800;
address public _operator;
modifier onlyOperator() {
require(_operator == msg.sender, "operator: caller is not the operator");
_;
}
constructor (address _AYIELD, uint256 _startingBlockNumber) public {
_operator = msg.sender;
emit OperatorTransferred(address(0), _operator);
pangolinRouter = IUniswapV2Router02(0xE54Ca86531e17Ef3616d22Ca28b0D458b6C89106);
AYIELD = BEP20(_AYIELD);
USDC = BEP20(0xA7D7079b0FEaD91F3e65f86E8915Cb59c1a4C664);
startBlock = _startingBlockNumber;
devaddr = msg.sender;
}
/// Buyback and Burn
/// Can be Called by Anyone for Community Governance
function buybackAndBurn() external {
// Ensure that buyback only starts when farming starts
require(block.number > startBlock, "buybackAndBurn: Buyback only available once farming starts");
// Require that each buyback has an interval of 4 Hours (4800 Block)
// Ensure no abitrage pumping of price, but instead maintain long term price stability
if( block.number < lastBuybackBlock && lastBuybackBlock != 0){
return;
} else {
// Calculate total USDC (From deposit fees) that is transferred to the FeesProcessor Contract
uint256 contractUSDC = USDC.balanceOf(address(this));
// Each Buyback call can only be 6% of the Total USDC available for Buyback
uint256 buybackAmount = contractUSDC.mul(6).div(100);
// Buyback aYield with USDC
buyback(buybackAmount);
// Record buyback
usdcBroughtBack = usdcBroughtBack.add(buybackAmount);
buybackCounter = buybackCounter.add(1);
// Automatically Burn all AYIELD that is bought back (Burn all AYIELD of Contract for Simplicity)
AYIELD.safeTransfer(BURN_ADDRESS, AYIELD.balanceOf(address(this)));
// Set lastBuybackBlock
lastBuybackBlock = block.number.add(BUYBACK_INTERVAL);
emit BuybackAndBurn(buybackAmount, usdcBroughtBack, buybackCounter);
}
}
/// @dev Swap USDC for AYIELD Tokens
function buyback(uint256 tokenAmount) private {
// generate the AYIELD pair path of token -> USDC
address[] memory path = new address[](2);
path[0] = address(USDC);
path[1] = address(AYIELD);
// Give Pangolin Router Allowance to Spend Tokens
USDC.approve(address(pangolinRouter), tokenAmount);
AYIELD.approve(address(pangolinRouter), tokenAmount);
// Make the swap for AYIELD with USDC
pangolinRouter.swapExactTokensForTokensSupportingFeeOnTransferTokens(
tokenAmount,
0, // accept any amount of AYIELD
path,
address(this),
block.timestamp
);
}
function getUSDCLeft () external view returns (uint256) {
return USDC.balanceOf(address(this));
}
function getBuybackAmount () external view returns (uint256) {
return usdcBroughtBack;
}
function getBuybackCounter () external view returns (uint256) {
return buybackCounter;
}
function getLastBuybackIndex () external view returns (uint256) {
return lastBuybackBlock;
}
// Only used in case contract fail for whatever reason
// Will be Timelocked to prevent tempering
function withdrawFunds () external onlyOwner {
uint256 amount = USDC.balanceOf(address(this));
USDC.safeTransfer(devaddr, amount);
emit WithdrawUSDC(msg.sender, amount);
}
} | 9,038 |
221 | // -------------------------------------------------------- [external] 発行者の確認-------------------------------------------------------- | function getMinter( uint256 tokenId ) external view returns (address) {
require( _exists( tokenId ), "token not exist" );
return( _minters[tokenId-TOKEN_ID_OFS] );
}
| function getMinter( uint256 tokenId ) external view returns (address) {
require( _exists( tokenId ), "token not exist" );
return( _minters[tokenId-TOKEN_ID_OFS] );
}
| 20,313 |
68 | // Return amount after calculating slippage | return _amount.sub(rate);
| return _amount.sub(rate);
| 37,613 |
70 | // ========== STATE VARIABLES ========== //Addresses selected by owner which are allowed to call `transferFrom` to manage debt shares / | mapping(address => bool) public authorizedBrokers;
| mapping(address => bool) public authorizedBrokers;
| 24,756 |
44 | // wallet changed | event WalletChange(address _wallet, uint256 _timestamp);
| event WalletChange(address _wallet, uint256 _timestamp);
| 42,432 |
244 | // Calculate the effective value by going from source -> USD -> destination | value = sourceAmount.multiplyDecimalRound(sourceRate).divideDecimalRound(destinationRate);
| value = sourceAmount.multiplyDecimalRound(sourceRate).divideDecimalRound(destinationRate);
| 6,102 |
114 | // Gets whether the contract is still in the intial grace period where we give extra features to color setters | function isInGracePeriod() public view returns(bool) {
return now <= GRACE_PERIOD_END_TIMESTAMP;
}
| function isInGracePeriod() public view returns(bool) {
return now <= GRACE_PERIOD_END_TIMESTAMP;
}
| 17,350 |
303 | // PAYOUT / | function withdraw() public nonReentrant onlyOwner {
uint256 balance = address(this).balance;
Address.sendValue(payable(_owner()), balance);
}
| function withdraw() public nonReentrant onlyOwner {
uint256 balance = address(this).balance;
Address.sendValue(payable(_owner()), balance);
}
| 7,388 |
46 | // Emit the AdminLoanRepaid event | emit AdminLoanRepaid(loanID, msg.value, _adminLoanBalances[loanID]);
| emit AdminLoanRepaid(loanID, msg.value, _adminLoanBalances[loanID]);
| 25,295 |
353 | // Note: If we reach this point, we must update _GLOBAL_INDEX_TIMESTAMP_. |
uint256 emissionPerSecond = _REWARDS_PER_SECOND_;
if (emissionPerSecond == 0 || totalStaked == 0) {
|
uint256 emissionPerSecond = _REWARDS_PER_SECOND_;
if (emissionPerSecond == 0 || totalStaked == 0) {
| 43,936 |
48 | // Atomically increases the allowance granted to 'spender' by the caller. | * This is an alternative to {approve} that can be used as a mitigation for
* problems described in {IERC20-approve}.
*
* Emits an {Approval} event indicating the updated allowance.
*
* Requirements:
*
* - 'spender' cannot be the zero address.
*/
function increaseAllowance(
address spender,
uint256 addedValue
) public virtual returns (bool) {
address owner = _msgSender();
_approve(owner, spender, allowance(owner, spender) + addedValue);
return true;
}
| * This is an alternative to {approve} that can be used as a mitigation for
* problems described in {IERC20-approve}.
*
* Emits an {Approval} event indicating the updated allowance.
*
* Requirements:
*
* - 'spender' cannot be the zero address.
*/
function increaseAllowance(
address spender,
uint256 addedValue
) public virtual returns (bool) {
address owner = _msgSender();
_approve(owner, spender, allowance(owner, spender) + addedValue);
return true;
}
| 29,874 |
6 | // Emitted when the default tickspacing is changed/newDefaultTickspacing The new default tickspacing value | event DefaultTickspacing(int24 newDefaultTickspacing);
| event DefaultTickspacing(int24 newDefaultTickspacing);
| 23,168 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.