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 |
|---|---|---|---|---|
163 | // Make sure only oraclize can call this function | require(msg.sender == oraclize_cbAddress());
| require(msg.sender == oraclize_cbAddress());
| 7,168 |
15 | // should be enough | delete _stakersPool[tokenIds[i]].policyBookAddress;
| delete _stakersPool[tokenIds[i]].policyBookAddress;
| 45,208 |
110 | // require(_investAmount <= marketTypes[_minute].minute.mul(singleInvestAmount)); | IERC20(BUSD).safeTransferFrom(msg.sender, BSNData, _investAmount);
uint price = getEthUsd();
uint openBlock = marketTypes[_minute].duration.add(block.number);
bool isSet = IBSNInterface(BSNData).invest(msg.sender, uint(_investType), _minute, _investAmount, block.number, block.timestamp, openBlock ,price, _intro);
emit Invest(msg.sender, block.number, openBlock);
if(isSet) {
changeCycle(block.number);
}
| IERC20(BUSD).safeTransferFrom(msg.sender, BSNData, _investAmount);
uint price = getEthUsd();
uint openBlock = marketTypes[_minute].duration.add(block.number);
bool isSet = IBSNInterface(BSNData).invest(msg.sender, uint(_investType), _minute, _investAmount, block.number, block.timestamp, openBlock ,price, _intro);
emit Invest(msg.sender, block.number, openBlock);
if(isSet) {
changeCycle(block.number);
}
| 15,018 |
10 | // Segment lies in cycle | uint256[MAX_CYCLE_SIZE] memory result_t7; // empty array
uint256[MAX_CYCLE_SIZE] memory dates_t7;
dates_t7 = computeDatesFromCycleSegment(cStart, cEnd, c, addEndTime, sStart, sEnd);
result_t7[0] = uint256(1525132800); // Tuesday, 2018-05-01 00:00:00 UTC
result_t7[1] = uint256(1527811200); // Friday, 2018-06-01 00:00:00 UTC
result_t7[2] = uint256(1530403200); // Sunday, 2018-07-01 00:00:00 UTC
result_t7[3] = uint256(1533081600); // Wednesday, 2018-08-01 00:00:00 UTC
result_t7[4] = uint256(1535760000); // Saturday, 2018-09-01 00:00:00 UTC
| uint256[MAX_CYCLE_SIZE] memory result_t7; // empty array
uint256[MAX_CYCLE_SIZE] memory dates_t7;
dates_t7 = computeDatesFromCycleSegment(cStart, cEnd, c, addEndTime, sStart, sEnd);
result_t7[0] = uint256(1525132800); // Tuesday, 2018-05-01 00:00:00 UTC
result_t7[1] = uint256(1527811200); // Friday, 2018-06-01 00:00:00 UTC
result_t7[2] = uint256(1530403200); // Sunday, 2018-07-01 00:00:00 UTC
result_t7[3] = uint256(1533081600); // Wednesday, 2018-08-01 00:00:00 UTC
result_t7[4] = uint256(1535760000); // Saturday, 2018-09-01 00:00:00 UTC
| 36,785 |
3 | // Integer division of two numbers, truncating the quotient./ | function div(uint256 a, uint256 b) internal pure returns (uint256) {
// assert(b > 0); // Solidity automatically throws when dividing by 0
uint256 c = a / b;
// assert(a == b * c + a % b); // There is no case in which this doesn't hold
return c;
}
| function div(uint256 a, uint256 b) internal pure returns (uint256) {
// assert(b > 0); // Solidity automatically throws when dividing by 0
uint256 c = a / b;
// assert(a == b * c + a % b); // There is no case in which this doesn't hold
return c;
}
| 11,655 |
1 | // @inheritdoc IDackieV3PoolImmutables | address public immutable override token0;
| address public immutable override token0;
| 16,188 |
77 | // calculate fee | else if (recipient == uniswapV2Pair) {
feeswap =
sellTaxes.liquidity +
sellTaxes.marketing;
feesum = feeswap;
feeBurn = sellTaxes.burn;
currentTaxes = sellTaxes;
} else if (sender == uniswapV2Pair) {
| else if (recipient == uniswapV2Pair) {
feeswap =
sellTaxes.liquidity +
sellTaxes.marketing;
feesum = feeswap;
feeBurn = sellTaxes.burn;
currentTaxes = sellTaxes;
} else if (sender == uniswapV2Pair) {
| 13,741 |
136 | // Getter function for next requestIds on queue/request with highest payouts at time the function is called / | function getNewVariablesOnDeck()
external
view
returns (uint256[5] memory idsOnDeck, uint256[5] memory tipsOnDeck)
| function getNewVariablesOnDeck()
external
view
returns (uint256[5] memory idsOnDeck, uint256[5] memory tipsOnDeck)
| 77,120 |
11 | // 4 - the rest is by voting only (requires addNewProposal permission) so accessable by Managers only even with voting | dao.allowActionByVoting("manageGroups", token);
dao.allowActionByVoting("modifyMoneyscheme", token);
| dao.allowActionByVoting("manageGroups", token);
dao.allowActionByVoting("modifyMoneyscheme", token);
| 33,849 |
50 | // Admin functionality / |
event Halted();
event Resumed();
bool public halted = false;
|
event Halted();
event Resumed();
bool public halted = false;
| 51,720 |
11 | // Withdraw all assets in the given bundle, returning them to the msg.sender Requirements: - The bundle with id `bundleId` must have been initialized with {initializeBundle}- The bundle with id `bundleId` must be owned by or approved to msg.sender / | function withdraw(uint256 bundleId) external;
| function withdraw(uint256 bundleId) external;
| 52,906 |
145 | // Sets the address that is authorised to perform identity operations on this identity/ manager instance.//newIdentityOperator The address of the new identity operator.// return _ The address of the old identity operator. | function setIdentityOperator(address newIdentityOperator)
public
virtual
onlyProxy
onlyInitialized
onlyOwner
returns (address)
| function setIdentityOperator(address newIdentityOperator)
public
virtual
onlyProxy
onlyInitialized
onlyOwner
returns (address)
| 31,172 |
26 | // get the number of active votes a user holds after delegation (vs the basic balance of reputation he holds)/_user the user to get active votes for/_global wether to include reputation from other blockchains/_blockNumber get votes state at specific block/ return the number of votes | function getVotesAt(
address _user,
bool _global,
uint256 _blockNumber
| function getVotesAt(
address _user,
bool _global,
uint256 _blockNumber
| 29,521 |
2 | // Minimum tick exponential (0.25) / | uint256 internal constant MIN_TICK_EXPONENTIAL = 0.25 * 1e18;
| uint256 internal constant MIN_TICK_EXPONENTIAL = 0.25 * 1e18;
| 16,517 |
25 | // ================= ERC20 =============== | function name() public pure returns (string memory) {
return _name;
}
| function name() public pure returns (string memory) {
return _name;
}
| 929 |
35 | // double check | uint refund = ringFromETH.sub(priceInRING);
if (refund > 0) {
| uint refund = ringFromETH.sub(priceInRING);
if (refund > 0) {
| 38,827 |
23 | // Reverts if there is currently no active deployment ID. / | error NoActiveDeployment();
| error NoActiveDeployment();
| 34,256 |
14 | // Send the ether to the specified address. | msg.sender.send(account.cash);
| msg.sender.send(account.cash);
| 7,034 |
157 | // withdraw ERC20 in the case a held NFT earned ERC20 | function withdrawERC20(address _token) external {
require(_isApprovedOrOwner(msg.sender, 0), "withdraw:not allowed");
IERC20(_token).transfer(msg.sender, IERC20(_token).balanceOf(address(this)));
emit WithdrawERC20(_token, msg.sender);
}
| function withdrawERC20(address _token) external {
require(_isApprovedOrOwner(msg.sender, 0), "withdraw:not allowed");
IERC20(_token).transfer(msg.sender, IERC20(_token).balanceOf(address(this)));
emit WithdrawERC20(_token, msg.sender);
}
| 29,982 |
87 | // if no reserve or a new pair is created | if (amountToSwap <= 0) amountToSwap = SafeMath.div(token0Bought, 2);
token1Bought = _eth2Token(_ToUnipoolToken1, amountToSwap);
token0Bought = SafeMath.sub(token0Bought, amountToSwap);
| if (amountToSwap <= 0) amountToSwap = SafeMath.div(token0Bought, 2);
token1Bought = _eth2Token(_ToUnipoolToken1, amountToSwap);
token0Bought = SafeMath.sub(token0Bought, amountToSwap);
| 35,350 |
22 | // Constructor is called only once and can not be called again / | function CARXTOKEN() public {
balanceOf[msg.sender] = totalSupply;
}
| function CARXTOKEN() public {
balanceOf[msg.sender] = totalSupply;
}
| 24,348 |
14 | // Returns number of allowed tokens that a spender can transfer on behalf of a token owner./_owner Address of token owner./_who Address of token spender./ return Returns remaining allowance for spender. | function allowance(address _owner, address _who) constant public returns (uint256)
| function allowance(address _owner, address _who) constant public returns (uint256)
| 43,620 |
12 | // Construct the calldata for the transferFrom call. | bytes memory proxyCalldata = abi.encodeWithSelector(
IAssetProxy(address(0)).transferFrom.selector,
assetData,
from,
to,
amount
);
| bytes memory proxyCalldata = abi.encodeWithSelector(
IAssetProxy(address(0)).transferFrom.selector,
assetData,
from,
to,
amount
);
| 8,195 |
0 | // uniswap Factory interface to call createPair in constructor | interface IUniswapV2Factory {
event PairCreated(
address indexed token0,
address indexed token1,
address pair,
uint256
);
function createPair(address tokenA, address tokenB)
external
returns (address pair);
}
| interface IUniswapV2Factory {
event PairCreated(
address indexed token0,
address indexed token1,
address pair,
uint256
);
function createPair(address tokenA, address tokenB)
external
returns (address pair);
}
| 17,882 |
4 | // Receives the answer from the Chainlink node. |
function chainlinkCallback(bytes32 _clRequestId, int256 _response)
external
|
function chainlinkCallback(bytes32 _clRequestId, int256 _response)
external
| 51,918 |
15 | // Has Max | if (typeMaxSupply[_typeId] > 0) {
return tokenMgr.totalMinted(_typeId).add(_amount) <= typeMaxSupply[_typeId];
}
| if (typeMaxSupply[_typeId] > 0) {
return tokenMgr.totalMinted(_typeId).add(_amount) <= typeMaxSupply[_typeId];
}
| 27,105 |
4 | // Convert an amount of input token_ to an equivalent amount of the output tokentoken_ address of token to swap amount amount of token to swap/receive / | function swap(address token_, uint256 amount) external {
IERC20 inputToken = IERC20(token_);
address currentAddress = address(this);
require(inputToken.allowance(msg.sender, currentAddress) >= amount, "Wrapper: Insufficient Allowance.");
// Transfer A || B token from sender to wrapper
inputToken.transferFrom(msg.sender, currentAddress, amount);
// Mint the give amount of C token
outputToken.mintForWrapper(amount);
// Transfer C token to sender
outputToken.transfer(msg.sender, amount);
}
| function swap(address token_, uint256 amount) external {
IERC20 inputToken = IERC20(token_);
address currentAddress = address(this);
require(inputToken.allowance(msg.sender, currentAddress) >= amount, "Wrapper: Insufficient Allowance.");
// Transfer A || B token from sender to wrapper
inputToken.transferFrom(msg.sender, currentAddress, amount);
// Mint the give amount of C token
outputToken.mintForWrapper(amount);
// Transfer C token to sender
outputToken.transfer(msg.sender, amount);
}
| 13,140 |
101 | // return the next worse offer in the sorted listthe worse offer is the higher one if its an ask,a lower one if its a bid offer,and in both cases the newer one if they're equal. | function getWorseOffer(uint256 id) public view returns (uint256) {
return _rank[id].prev;
}
| function getWorseOffer(uint256 id) public view returns (uint256) {
return _rank[id].prev;
}
| 17,024 |
12 | // return The local chain token address of given ethereum chain token address. / | function getLocalTokenOf(address foreignContractAddress) public view returns (address) {
return tokenForeignToLocal[foreignContractAddress];
}
| function getLocalTokenOf(address foreignContractAddress) public view returns (address) {
return tokenForeignToLocal[foreignContractAddress];
}
| 50,402 |
20 | // transfer releasable tokens for beneficiary wrt the release graph / | function release() external onlyState(State.Active) onlyBeneficiary(msg.sender) {
require(!beneficiaries[msg.sender].releaseAllTokens);
uint releasableAmount = getReleasableAmount(msg.sender);
beneficiaries[msg.sender].withdrawAmount = beneficiaries[msg.sender].withdrawAmount.add(releasableAmount);
beneficiaries[msg.sender].releaseAllTokens = beneficiaries[msg.sender].withdrawAmount == getPartialAmount(
beneficiaries[msg.sender].ratio,
coeff,
initialBalance);
withdrawAmount = withdrawAmount.add(releasableAmount);
if (withdrawAmount == initialBalance) {
state = State.Drawn;
}
token.transfer(msg.sender, releasableAmount);
}
| function release() external onlyState(State.Active) onlyBeneficiary(msg.sender) {
require(!beneficiaries[msg.sender].releaseAllTokens);
uint releasableAmount = getReleasableAmount(msg.sender);
beneficiaries[msg.sender].withdrawAmount = beneficiaries[msg.sender].withdrawAmount.add(releasableAmount);
beneficiaries[msg.sender].releaseAllTokens = beneficiaries[msg.sender].withdrawAmount == getPartialAmount(
beneficiaries[msg.sender].ratio,
coeff,
initialBalance);
withdrawAmount = withdrawAmount.add(releasableAmount);
if (withdrawAmount == initialBalance) {
state = State.Drawn;
}
token.transfer(msg.sender, releasableAmount);
}
| 56,083 |
41 | // ICO is suspended, tokens cannot be distributed among investors. ICO can be resumed to `Active state`. ICO parameters (end date, hard/low caps) may changed. | Suspended,
| Suspended,
| 16,959 |
55 | // Returns a list of all tokens assigned to an address. _owner The owner whose tokens we are interested in This method MUST NEVER be called by smart contract code. First, it's fairlyexpensive (it walks the entire token array looking for tokens belonging to owner),but it also returns a dynamic array, which is only supported for web3 calls, andnot contract-to-contract calls. / | function tokensOfOwner(address _owner) external view returns(uint256[] ownerTokens) {
uint256 tokenCount = balanceOf(_owner);
if (tokenCount == 0) {
// Return an empty array
return new uint256[](0);
} else {
uint256[] memory result = new uint256[](tokenCount);
uint256 totalTokens = totalSupply();
uint256 resultIndex = 0;
uint256 tokenId;
for (tokenId = 0; tokenId <= totalTokens; tokenId++) {
if (tokenIndexToOwner[tokenId] == _owner) {
result[resultIndex] = tokenId;
resultIndex++;
}
}
return result;
}
}
| function tokensOfOwner(address _owner) external view returns(uint256[] ownerTokens) {
uint256 tokenCount = balanceOf(_owner);
if (tokenCount == 0) {
// Return an empty array
return new uint256[](0);
} else {
uint256[] memory result = new uint256[](tokenCount);
uint256 totalTokens = totalSupply();
uint256 resultIndex = 0;
uint256 tokenId;
for (tokenId = 0; tokenId <= totalTokens; tokenId++) {
if (tokenIndexToOwner[tokenId] == _owner) {
result[resultIndex] = tokenId;
resultIndex++;
}
}
return result;
}
}
| 15,117 |
341 | // Specifies whether the contract is paused at the moment | bool public paused = false;
| bool public paused = false;
| 26,632 |
221 | // Returns lowest total debt that will be split. | function LOW_TOTAL_DEBT() external view returns (uint256);
| function LOW_TOTAL_DEBT() external view returns (uint256);
| 6,056 |
4 | // redeem, caller handles transfer of created value | function redeem(address account, uint256 amount) public onlyOwner {
require(account != address(0), "zero address");
require(_balances[account] >= amount, "Insufficent balance");
_balances[account] = _balances[account].sub(amount);
_outstandingSupply = _outstandingSupply.sub(amount);
emit Redeemed(account, amount);
}
| function redeem(address account, uint256 amount) public onlyOwner {
require(account != address(0), "zero address");
require(_balances[account] >= amount, "Insufficent balance");
_balances[account] = _balances[account].sub(amount);
_outstandingSupply = _outstandingSupply.sub(amount);
emit Redeemed(account, amount);
}
| 14,859 |
2 | // Emitted when borrowing is enabled or disabled on a reserve. asset The address of the underlying asset of the reserve enabled True if borrowing is enabled, false otherwise / | event ReserveBorrowing(address indexed asset, bool enabled);
| event ReserveBorrowing(address indexed asset, bool enabled);
| 35,396 |
192 | // number of observations oracle is due to be reimbursed for _signerOrTransmitter address used by oracle for signing or transmitting reports / | function oracleObservationCount(address _signerOrTransmitter)
external
view
returns (uint16)
| function oracleObservationCount(address _signerOrTransmitter)
external
view
returns (uint16)
| 15,854 |
177 | // Checks whether an address is a system account. account the address to check.return true if system account. / | function isSystemAccount(address account) public view returns (bool) {
return systemAccounts.has(account);
}
| function isSystemAccount(address account) public view returns (bool) {
return systemAccounts.has(account);
}
| 3,419 |
17 | // This check is neccessary to prevent a situation where all ownersare accidentally removed, because we do not want an ownable contractto become an orphan. | require(ownerCount > 1);
require(isOwner[owner]);
isOwner[owner] = false;
ownerCount--;
OwnerRemovedEvent(owner);
| require(ownerCount > 1);
require(isOwner[owner]);
isOwner[owner] = false;
ownerCount--;
OwnerRemovedEvent(owner);
| 6,835 |
3 | // Add a new product to the supply chain | function addProduct(uint _id, string memory _name, string memory _description, uint _quantity) public {
products.push(Product(_id, _name, _description, _quantity, msg.sender));
productIdToIndex[_id] = products.length - 1;
}
| function addProduct(uint _id, string memory _name, string memory _description, uint _quantity) public {
products.push(Product(_id, _name, _description, _quantity, msg.sender));
productIdToIndex[_id] = products.length - 1;
}
| 12,469 |
34 | // returns an existing locked network token balance details_providerlocked balances provider _index start indexreturn amount of network tokensreturn lock expiration time / | function lockedBalance(address _provider, uint256 _index) external view override returns (uint256, uint256) {
LockedBalance storage balance = lockedBalances[_provider][_index];
return (balance.amount, balance.expirationTime);
}
| function lockedBalance(address _provider, uint256 _index) external view override returns (uint256, uint256) {
LockedBalance storage balance = lockedBalances[_provider][_index];
return (balance.amount, balance.expirationTime);
}
| 3,159 |
138 | // Make division exact by subtracting the remainder from [prod1 prod0] Compute remainder using mulmod | uint256 remainder;
assembly {
remainder := mulmod(a, b, denominator)
}
| uint256 remainder;
assembly {
remainder := mulmod(a, b, denominator)
}
| 8,915 |
64 | // Make sure that advertisers are requesting a refund for how much ever ether they have. | require(amount > 0, "Amount should be greater than 0");
require(advertiserBalances[msg.sender] > 0, "You have no balance");
require(advertiserBalances[msg.sender] >= amount, "Insufficient balance to refund");
| require(amount > 0, "Amount should be greater than 0");
require(advertiserBalances[msg.sender] > 0, "You have no balance");
require(advertiserBalances[msg.sender] >= amount, "Insufficient balance to refund");
| 51,426 |
9 | // transfer the tokens to this contract | uint256 amountReceived = custodyTokens(token, amount);
uint256 targetRelayerFee = relayerFee(targetChain, address(token));
require(
amountReceived > targetRelayerFee + toNativeTokenAmount,
"insufficient amountReceived"
);
| uint256 amountReceived = custodyTokens(token, amount);
uint256 targetRelayerFee = relayerFee(targetChain, address(token));
require(
amountReceived > targetRelayerFee + toNativeTokenAmount,
"insufficient amountReceived"
);
| 8,974 |
34 | // When a monster flees, the hero health is reduced by monster level + monsterStrength. | uint public monsterStrength = 4;
| uint public monsterStrength = 4;
| 71,436 |
68 | // Events contract issues new tokens for address. Returns success/_for Address of receiver/outcomeTokenCount Number of tokens to issue | function issue(address _for, uint outcomeTokenCount)
public
isEventContract
| function issue(address _for, uint outcomeTokenCount)
public
isEventContract
| 16,013 |
355 | // either debt has decreased, or debt ceilings are not exceeded | require(either(dart <= 0, both(mul(ilk.Art, ilk.rate) <= ilk.line, debt <= Line)), "Vat/ceiling-exceeded");
| require(either(dart <= 0, both(mul(ilk.Art, ilk.rate) <= ilk.line, debt <= Line)), "Vat/ceiling-exceeded");
| 47,026 |
11 | // Update Target Admirer's Last Voted Hrs for Current Token | s.admirers[invokerId][targetId] = block.timestamp;
| s.admirers[invokerId][targetId] = block.timestamp;
| 17,236 |
31 | // Performs the initial distribution of tokens. / | function _initialTokenDistribution() private {
uint[8] memory tokenAmounts = [
uint(140_000_000 ether),
uint(95_000_000 ether),
uint(60_000_000 ether),
uint(18_750_000 ether),
uint(8_250_000 ether),
uint(8_750_000 ether),
uint(6_250_000 ether),
uint(15_000_000 ether)
];
address[8] memory wallets = [ecosystemWallet, publicSaleWallet, liquidityMMWallet, teamWallet, privateSaleWallet, developmentWallet, partnersWallet, marketingWallet];
for (uint i = 0; i < wallets.length; i++) {
soulPrimeToken.transfer(wallets[i], tokenAmounts[i]);
}
}
| function _initialTokenDistribution() private {
uint[8] memory tokenAmounts = [
uint(140_000_000 ether),
uint(95_000_000 ether),
uint(60_000_000 ether),
uint(18_750_000 ether),
uint(8_250_000 ether),
uint(8_750_000 ether),
uint(6_250_000 ether),
uint(15_000_000 ether)
];
address[8] memory wallets = [ecosystemWallet, publicSaleWallet, liquidityMMWallet, teamWallet, privateSaleWallet, developmentWallet, partnersWallet, marketingWallet];
for (uint i = 0; i < wallets.length; i++) {
soulPrimeToken.transfer(wallets[i], tokenAmounts[i]);
}
}
| 44,688 |
95 | // UniRef constructor/_core Fei Core to reference/_pair Uniswap pair to reference/_oracle oracle to reference/_backupOracle backup oracle to reference | constructor(
address _core,
address _pair,
address _oracle,
address _backupOracle
| constructor(
address _core,
address _pair,
address _oracle,
address _backupOracle
| 58,363 |
47 | // "only growth" check | assert(_burnPrice >= _burnPriceTmp);
return true;
| assert(_burnPrice >= _burnPriceTmp);
return true;
| 52,059 |
147 | // The name of the token. | string public override name;
| string public override name;
| 22,503 |
23 | // minor performance improvement, caches the value | rate = payment_tier[i].rate;
| rate = payment_tier[i].rate;
| 21,136 |
32 | // Binary search of the value in the array | uint256 min = 0;
uint256 max = checkpoints.length-1;
while (max > min) {
uint256 mid = (max + min + 1) / 2;
if (checkpoints[mid].fromBlock <= _block) {
min = mid;
} else {
| uint256 min = 0;
uint256 max = checkpoints.length-1;
while (max > min) {
uint256 mid = (max + min + 1) / 2;
if (checkpoints[mid].fromBlock <= _block) {
min = mid;
} else {
| 54,366 |
55 | // Copy remaining bytes | let srcPart := and(mload(src), not(mask))
let destPart := and(mload(dest), mask)
mstore(dest, or(destPart, srcPart))
| let srcPart := and(mload(src), not(mask))
let destPart := and(mload(dest), mask)
mstore(dest, or(destPart, srcPart))
| 39,976 |
47 | // Send the remainder to the owner | token.safeTransfer(owner, token.balanceOf(this));
revoked = true;
Revoked();
| token.safeTransfer(owner, token.balanceOf(this));
revoked = true;
Revoked();
| 23,846 |
37 | // all the settings for this farm in one struct | struct FarmInfo {
IERC20 lpToken;
IERC20 rewardToken;
uint256 startBlock;
uint256 blockReward;
uint256 bonusEndBlock;
uint256 bonus;
uint256 endBlock;
uint256 lastRewardBlock; // Last block number that reward distribution occurs.
uint256 accRewardPerShare; // Accumulated Rewards per share, times 1e12
uint256 farmableSupply; // set in init, total amount of tokens farmable
uint256 numFarmers;
}
| struct FarmInfo {
IERC20 lpToken;
IERC20 rewardToken;
uint256 startBlock;
uint256 blockReward;
uint256 bonusEndBlock;
uint256 bonus;
uint256 endBlock;
uint256 lastRewardBlock; // Last block number that reward distribution occurs.
uint256 accRewardPerShare; // Accumulated Rewards per share, times 1e12
uint256 farmableSupply; // set in init, total amount of tokens farmable
uint256 numFarmers;
}
| 19,380 |
63 | // Overrides delivery by minting tokens upon purchase. _beneficiary Token purchaser _tokenAmount Number of tokens to be minted / | function _deliverTokens(address _beneficiary, uint256 _tokenAmount) internal {
require(MintableToken(token).mint(_beneficiary, _tokenAmount));
}
| function _deliverTokens(address _beneficiary, uint256 _tokenAmount) internal {
require(MintableToken(token).mint(_beneficiary, _tokenAmount));
}
| 11,635 |
23 | // for the purpose of protecting user assets, under extreme conditions, the circulation of all tokens in the contract needs to be frozen.This process is under the supervision of the community. / | function emergencyPause() external onlyOwner notSealed {
_pause();
}
| function emergencyPause() external onlyOwner notSealed {
_pause();
}
| 11,957 |
26 | // ownership can be transferred to provided newOwner. Function can only be initiated by contract owner's account | function transferOwnership(address newOwner) public onlyOwner {
require (newOwner != address(0));
owner = newOwner;
}
| function transferOwnership(address newOwner) public onlyOwner {
require (newOwner != address(0));
owner = newOwner;
}
| 42,493 |
36 | // Public Variables | address public multiSigWallet;
uint256 public amountRaised;
uint256 public dividendPayment;
uint256 public numberOfRecordEntries;
uint256 public numberOfTokenHolders;
uint256 public startTime;
uint256 public stopTime;
uint256 public hardcap;
uint256 public price;
| address public multiSigWallet;
uint256 public amountRaised;
uint256 public dividendPayment;
uint256 public numberOfRecordEntries;
uint256 public numberOfTokenHolders;
uint256 public startTime;
uint256 public stopTime;
uint256 public hardcap;
uint256 public price;
| 9,109 |
12 | // Mapping of managed id to deactivated state | function deactivated(uint256 tokenId) external view returns (bool inactive);
| function deactivated(uint256 tokenId) external view returns (bool inactive);
| 24,391 |
182 | // using SafeMath for uint256; | bytes32 private constant META_TRANSACTION_TYPEHASH =
keccak256(
bytes(
"MetaTransaction(uint256 nonce,address from,bytes functionSignature)"
)
);
event MetaTransactionExecuted(
address userAddress,
address payable relayerAddress,
bytes functionSignature
| bytes32 private constant META_TRANSACTION_TYPEHASH =
keccak256(
bytes(
"MetaTransaction(uint256 nonce,address from,bytes functionSignature)"
)
);
event MetaTransactionExecuted(
address userAddress,
address payable relayerAddress,
bytes functionSignature
| 54,887 |
13 | // Lease signed by the tenant / | {
lease.tenant = msg.sender;
securityDeposited = msg.value;
require( securityDeposited >= lease.securityDeposit);
lease.signedTimestamp = block.timestamp;
state = LeaseState.Signed;
emit leaseSigned(lease.tenant, lease.signedTimestamp);
}//cc
| {
lease.tenant = msg.sender;
securityDeposited = msg.value;
require( securityDeposited >= lease.securityDeposit);
lease.signedTimestamp = block.timestamp;
state = LeaseState.Signed;
emit leaseSigned(lease.tenant, lease.signedTimestamp);
}//cc
| 31,798 |
2 | // Auto-generated via 'PrintFunctionOptimalLog.py' and 'PrintFunctionOptimalExp.py' / | uint256 private constant OPT_LOG_MAX_VAL = 0x15bf0a8b1457695355fb8ac404e7a79e3;
uint256 private constant OPT_EXP_MAX_VAL = 0x800000000000000000000000000000000;
| uint256 private constant OPT_LOG_MAX_VAL = 0x15bf0a8b1457695355fb8ac404e7a79e3;
uint256 private constant OPT_EXP_MAX_VAL = 0x800000000000000000000000000000000;
| 1,572 |
4 | // Boolean to prevent using the same signature twice | mapping(bytes => bool) public usedSignatures;
| mapping(bytes => bool) public usedSignatures;
| 41,284 |
36 | // excludes for | excludedFromFees[address(this)] = true;
excludedFromRewards[address(this)] = true;
excludedFromPausable[address(this)] = true;
| excludedFromFees[address(this)] = true;
excludedFromRewards[address(this)] = true;
excludedFromPausable[address(this)] = true;
| 29,690 |
166 | // sets the address to send withdrawable funds to _teamAddress the new destination address / | function setTeamAddress(address payable _teamAddress) public onlyOwner {
teamAddress = _teamAddress;
}
| function setTeamAddress(address payable _teamAddress) public onlyOwner {
teamAddress = _teamAddress;
}
| 50,340 |
30 | // address public uniswapRouterAddress; IUniswapV2Router02 public uniswapRouter; |
address[] public tokenList;
mapping(address => bool) public whitelist;
|
address[] public tokenList;
mapping(address => bool) public whitelist;
| 48,543 |
21 | // Team allocation percentages (F3D, P3D) + (Pot , Referrals, Community) Referrals / Community rewards are mathematically designed to come from the winner's share of the pot. | fees_[0] = F3Ddatasets.TeamFee(56,10); //50% to pot, 10% to aff, 2% to com, 1% to pot swap, 1% to air drop pot
fees_[1] = F3Ddatasets.TeamFee(56,10); //43% to pot, 10% to aff, 2% to com, 1% to pot swap, 1% to air drop pot
fees_[2] = F3Ddatasets.TeamFee(56,10); //20% to pot, 10% to aff, 2% to com, 1% to pot swap, 1% to air drop pot
fees_[3] = F3Ddatasets.TeamFee(56,10); //35% to pot, 10% to aff, 2% to com, 1% to pot swap, 1% to air drop pot
| fees_[0] = F3Ddatasets.TeamFee(56,10); //50% to pot, 10% to aff, 2% to com, 1% to pot swap, 1% to air drop pot
fees_[1] = F3Ddatasets.TeamFee(56,10); //43% to pot, 10% to aff, 2% to com, 1% to pot swap, 1% to air drop pot
fees_[2] = F3Ddatasets.TeamFee(56,10); //20% to pot, 10% to aff, 2% to com, 1% to pot swap, 1% to air drop pot
fees_[3] = F3Ddatasets.TeamFee(56,10); //35% to pot, 10% to aff, 2% to com, 1% to pot swap, 1% to air drop pot
| 32,356 |
3 | // If answers after this, will have punishment for being late | uint constant LATE = 10;
uint constant LATE_FEE = 0.1 ether;
uint constant DEPOSIT = 1 ether;
| uint constant LATE = 10;
uint constant LATE_FEE = 0.1 ether;
uint constant DEPOSIT = 1 ether;
| 39,376 |
175 | // Candidate and reserve transcoders | SortedDoublyLL.Data private transcoderPool;
| SortedDoublyLL.Data private transcoderPool;
| 2,052 |
1 | // Required methods | function approve(address _to, uint256 _tokenId) public;
function balanceOf(address _owner) public view returns (uint256 balance);
function implementsERC721() public pure returns (bool);
function ownerOf(uint256 _tokenId) public view returns (address addr);
function takeOwnership(uint256 _tokenId) public;
function totalSupply() public view returns (uint256 total);
function transferFrom(address _from, address _to, uint256 _tokenId) public;
function transfer(address _to, uint256 _tokenId) public;
event Transfer(address indexed from, address indexed to, uint256 tokenId);
| function approve(address _to, uint256 _tokenId) public;
function balanceOf(address _owner) public view returns (uint256 balance);
function implementsERC721() public pure returns (bool);
function ownerOf(uint256 _tokenId) public view returns (address addr);
function takeOwnership(uint256 _tokenId) public;
function totalSupply() public view returns (uint256 total);
function transferFrom(address _from, address _to, uint256 _tokenId) public;
function transfer(address _to, uint256 _tokenId) public;
event Transfer(address indexed from, address indexed to, uint256 tokenId);
| 26,844 |
115 | // claim function to claim pending rewards | function claim() public noContractsAllowed {
updateAccount(msg.sender);
}
| function claim() public noContractsAllowed {
updateAccount(msg.sender);
}
| 6,361 |
56 | // Lock defines a lock of token/ | struct Lock {
uint256 amount;
uint256 expiresAt;
}
| struct Lock {
uint256 amount;
uint256 expiresAt;
}
| 77,319 |
63 | // See {IEIP2981RoyaltyOverride-setDefaultRoyalty}. / | function setDefaultRoyalty(TokenRoyalty calldata royalty) external override onlyOwner {
_setDefaultRoyalty(royalty);
}
| function setDefaultRoyalty(TokenRoyalty calldata royalty) external override onlyOwner {
_setDefaultRoyalty(royalty);
}
| 39,975 |
40 | // Returns the minimum voting power required to create a proposal stored in the voting settings./ return The minimum voting power required to create a proposal. | function minProposerVotingPower() public view virtual returns (uint256) {
return votingSettings.minProposerVotingPower;
}
| function minProposerVotingPower() public view virtual returns (uint256) {
return votingSettings.minProposerVotingPower;
}
| 10,017 |
27 | // Gets the maximum number of tokens an address is allowed to hold/addr The address to check restrictions for | function getMaxBalance(address addr) external view returns(uint256) {
return _maxBalances[addr];
}
| function getMaxBalance(address addr) external view returns(uint256) {
return _maxBalances[addr];
}
| 39,657 |
7 | // Asset States | EntityStates["__IGNORED__"] = 0;
EntityStates["NEW"] = 1;
| EntityStates["__IGNORED__"] = 0;
EntityStates["NEW"] = 1;
| 42,205 |
43 | // Get the available amount of an EtherDelta order./orderAddresses Array of address arrays containing individual order addresses./orderValues Array of uint arrays containing individual order values./exchangeFee Fee percentage of the exchange./v Array ECDSA signature v parameters./r Array of ECDSA signature r parameters./s Array of ECDSA signature s parameters./ return Available amount of the order. | function getAvailableAmount(
address[5] orderAddresses,
uint[6] orderValues,
uint exchangeFee,
uint8 v,
bytes32 r,
bytes32 s
| function getAvailableAmount(
address[5] orderAddresses,
uint[6] orderValues,
uint exchangeFee,
uint8 v,
bytes32 r,
bytes32 s
| 3,455 |
18 | // Matching Commission | function matchingCarBonus(address _user) internal {
address sponser = userList[users[_user].referrerID];
uint _carBonus;
if(sponser == address(0)) sponser = userList[1];
_teamNetworkEarnWallet[sponser] = new address[](0);
if(((users[sponser].membershipExpired).add(blockTime.add(GRACE_PERIOD)) < now) && (!users[sponser].blocked)){
users[sponser].blocked = true;
}
if(sponser != userList[1])
getAllDirectSponsor( sponser, userList[users[sponser].referrerID], 0);
if((_teamNetworkEarnWallet[sponser].length > 0) && (users[sponser].teamNetworkEarnETH > 0)){
_carBonus = (users[sponser].teamNetworkEarnETH.mul(25 ether).div(100 ether)).div(MatchingBonusUplineLimit);
if(_carBonus > 0){
for(uint j=0; j<_teamNetworkEarnWallet[sponser].length;j++){
require(address(uint160(_teamNetworkEarnWallet[sponser][j])).send(_carBonus),"transfer car bonus failed");
users[_teamNetworkEarnWallet[sponser][j]].totalEarnedETH = users[_teamNetworkEarnWallet[sponser][j]].totalEarnedETH.add(_carBonus);
commissionsReceivedValue[msg.sender] = commissionsReceivedValue[msg.sender].add(_carBonus);
}
if(_teamNetworkEarnWallet[sponser].length != MatchingBonusUplineLimit){
uint breakage = MatchingBonusUplineLimit.sub(_teamNetworkEarnWallet[sponser].length);
if(breakage > 0){
require(address(uint160(admin)).send(_carBonus.mul(breakage)),"transfer car bonus failed");
users[admin].totalEarnedETH = users[admin].totalEarnedETH.add(_carBonus.mul(breakage));
adminBreakageAmount[msg.sender] = adminBreakageAmount[msg.sender].add(_carBonus.mul(breakage));
commissionsReceivedValue[msg.sender] = commissionsReceivedValue[msg.sender].add(_carBonus.mul(breakage));
}
}
emit MatchingCarBonus(
_user,
sponser,
_teamNetworkEarnWallet[sponser],
_carBonus
);
}
}
}
| function matchingCarBonus(address _user) internal {
address sponser = userList[users[_user].referrerID];
uint _carBonus;
if(sponser == address(0)) sponser = userList[1];
_teamNetworkEarnWallet[sponser] = new address[](0);
if(((users[sponser].membershipExpired).add(blockTime.add(GRACE_PERIOD)) < now) && (!users[sponser].blocked)){
users[sponser].blocked = true;
}
if(sponser != userList[1])
getAllDirectSponsor( sponser, userList[users[sponser].referrerID], 0);
if((_teamNetworkEarnWallet[sponser].length > 0) && (users[sponser].teamNetworkEarnETH > 0)){
_carBonus = (users[sponser].teamNetworkEarnETH.mul(25 ether).div(100 ether)).div(MatchingBonusUplineLimit);
if(_carBonus > 0){
for(uint j=0; j<_teamNetworkEarnWallet[sponser].length;j++){
require(address(uint160(_teamNetworkEarnWallet[sponser][j])).send(_carBonus),"transfer car bonus failed");
users[_teamNetworkEarnWallet[sponser][j]].totalEarnedETH = users[_teamNetworkEarnWallet[sponser][j]].totalEarnedETH.add(_carBonus);
commissionsReceivedValue[msg.sender] = commissionsReceivedValue[msg.sender].add(_carBonus);
}
if(_teamNetworkEarnWallet[sponser].length != MatchingBonusUplineLimit){
uint breakage = MatchingBonusUplineLimit.sub(_teamNetworkEarnWallet[sponser].length);
if(breakage > 0){
require(address(uint160(admin)).send(_carBonus.mul(breakage)),"transfer car bonus failed");
users[admin].totalEarnedETH = users[admin].totalEarnedETH.add(_carBonus.mul(breakage));
adminBreakageAmount[msg.sender] = adminBreakageAmount[msg.sender].add(_carBonus.mul(breakage));
commissionsReceivedValue[msg.sender] = commissionsReceivedValue[msg.sender].add(_carBonus.mul(breakage));
}
}
emit MatchingCarBonus(
_user,
sponser,
_teamNetworkEarnWallet[sponser],
_carBonus
);
}
}
}
| 53,792 |
237 | // Uses binarysearch to find the unclaimed lockups for a given account / | function _findFirstUnclaimed(uint64 _lastClaim, address _account)
internal
view
returns(uint256 first)
| function _findFirstUnclaimed(uint64 _lastClaim, address _account)
internal
view
returns(uint256 first)
| 13,491 |
3 | // Function to transfer to another owner for this bike contract / | function transfer(address newOwner) onlyOwner public {
owner = newOwner;
}
| function transfer(address newOwner) onlyOwner public {
owner = newOwner;
}
| 1,288 |
1 | // Returns a boolean value indicating whether `_account` has role `_roleName` or not. | function checkRole(bytes32 _roleName, address _account) external view returns (bool);
| function checkRole(bytes32 _roleName, address _account) external view returns (bool);
| 34,145 |
61 | // Deploy new VestingTrustee contract. | trustee = new VestingTrustee(blok);
fundingRecipient = _fundingRecipient;
startTime = _startTime;
endTime = startTime + SALE_DURATION;
| trustee = new VestingTrustee(blok);
fundingRecipient = _fundingRecipient;
startTime = _startTime;
endTime = startTime + SALE_DURATION;
| 26,844 |
62 | // calculate fee | else{
if(recipient == pair) fee = amount * totSellTax / 100;
else fee = amount * totTax / 100;
}
| else{
if(recipient == pair) fee = amount * totSellTax / 100;
else fee = amount * totTax / 100;
}
| 468 |
14 | // implement signup function | function onSignUp(string hydroId, uint allowance) public senderIsSnowflake() returns (bool) {
require(allowance >= signUpFee, "Must set an allowance of at least 1 HYDRO.");
Snowflake snowflake = Snowflake(snowflakeAddress);
snowflake.withdrawSnowflakeBalanceFrom(hydroId, owner, signUpFee);
statuses[hydroId] = firstStatus;
emit StatusUpdated(hydroId, firstStatus);
return true;
}
| function onSignUp(string hydroId, uint allowance) public senderIsSnowflake() returns (bool) {
require(allowance >= signUpFee, "Must set an allowance of at least 1 HYDRO.");
Snowflake snowflake = Snowflake(snowflakeAddress);
snowflake.withdrawSnowflakeBalanceFrom(hydroId, owner, signUpFee);
statuses[hydroId] = firstStatus;
emit StatusUpdated(hydroId, firstStatus);
return true;
}
| 14,475 |
171 | // fee growth per unit of liquidity as of the last update to liquidity or fees owed | uint256 feeGrowthInside0LastX128;
uint256 feeGrowthInside1LastX128;
| uint256 feeGrowthInside0LastX128;
uint256 feeGrowthInside1LastX128;
| 41,292 |
3 | // Integer division of two unsigned integers truncating the quotient,reverts on division by zero. / | function div(uint256 a, uint256 b) internal pure returns (uint256) {
assert(b > 0);
uint256 c = a / b;
assert(a == b * c + a % b);
return a / b;
}
| function div(uint256 a, uint256 b) internal pure returns (uint256) {
assert(b > 0);
uint256 c = a / b;
assert(a == b * c + a % b);
return a / b;
}
| 17,460 |
126 | // 20% discount bonus amount | uint256 tier1BonusTokens;
| uint256 tier1BonusTokens;
| 19,053 |
17 | // we start with false here to save gas and negate it before returning --> (!invalid) | bool invalid,
string memory reason
)
| bool invalid,
string memory reason
)
| 2,779 |
6 | // Returns the current implementation. | * NOTE: Only the admin can call this function. See {ProxyAdmin-getProxyImplementation}.
*
* TIP: To get this value clients can read directly from the storage slot shown below (specified by EIP1967) using the
* https://eth.wiki/json-rpc/API#eth_getstorageat[`eth_getStorageAt`] RPC call.
* `0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc`
*/
function implementation() external ifAdmin returns (address implementation_) {
implementation_ = _implementation();
}
| * NOTE: Only the admin can call this function. See {ProxyAdmin-getProxyImplementation}.
*
* TIP: To get this value clients can read directly from the storage slot shown below (specified by EIP1967) using the
* https://eth.wiki/json-rpc/API#eth_getstorageat[`eth_getStorageAt`] RPC call.
* `0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc`
*/
function implementation() external ifAdmin returns (address implementation_) {
implementation_ = _implementation();
}
| 1,544 |
223 | // List of Items by Type | mapping (OrderType => uint256[]) public itemsByOrderType;
| mapping (OrderType => uint256[]) public itemsByOrderType;
| 34,360 |
17 | // Convenience contract used to make batch view calls to DAO contracts | contract Convenience is Ownable {
enum VotingAppType { Primary, Secondary }
Api3Pool public api3Pool;
address[] public erc20Addresses;
constructor(address api3PoolAddress)
{
api3Pool = Api3Pool(api3PoolAddress);
}
/// @notice Called by the owner to update the addresses of the contract
/// addresses of the ERC20 tokens that will be displayed in the treasury
/// @dev The owner privileges here do not pose a serious security risk, the
/// worst that can happen is that the treasury display will malfunction
/// @param _erc20Addresses ERC20 addresses
function setErc20Addresses(address[] calldata _erc20Addresses)
external
onlyOwner()
{
erc20Addresses = _erc20Addresses;
}
/// @notice Used by the DAO dashboard client to retrieve user staking data
/// @param userAddress User address
function getUserStakingData(address userAddress)
external
view
returns (
uint256 apr,
uint256 api3Supply,
uint256 totalStake,
uint256 totalShares,
uint256 stakeTarget,
uint256 userStaked,
uint256 userUnstaked,
uint256 userLocked,
uint256 userVesting,
uint256 userUnstakeScheduledFor,
uint256 userUnstakeAmount,
uint256 userUnstakeShares
)
{
apr = api3Pool.currentApr();
api3Supply = IERC20Metadata(address(api3Pool.api3Token())).totalSupply();
totalStake = api3Pool.totalStake();
totalShares = api3Pool.totalSupply();
stakeTarget = api3Pool.stakeTarget();
userStaked = api3Pool.userStake(userAddress);
(
userUnstaked,
userVesting,
userUnstakeShares,
userUnstakeAmount,
userUnstakeScheduledFor,
, // mostRecentProposalTimestamp
, // mostRecentVoteTimestamp
, // mostRecentDelegationTimestamp
// mostRecentUndelegationTimestamp
) = api3Pool.getUser(userAddress);
userLocked = api3Pool.getUserLocked(userAddress);
}
/// @notice Used by the DAO dashboard client to retrieve the treasury and
/// user delegation data
/// @param userAddress User address
function getTreasuryAndUserDelegationData(address userAddress)
external
view
returns (
string[] memory names,
string[] memory symbols,
uint8[] memory decimals,
uint256[] memory balancesOfPrimaryAgent,
uint256[] memory balancesOfSecondaryAgent,
address delegate,
uint256 mostRecentProposalTimestamp,
uint256 mostRecentVoteTimestamp,
uint256 mostRecentDelegationTimestamp,
uint256 mostRecentUndelegationTimestamp
)
{
names = new string[](erc20Addresses.length);
symbols = new string[](erc20Addresses.length);
decimals = new uint8[](erc20Addresses.length);
balancesOfPrimaryAgent = new uint256[](erc20Addresses.length);
balancesOfSecondaryAgent = new uint256[](erc20Addresses.length);
for (uint256 i = 0; i < erc20Addresses.length; i++)
{
IERC20Metadata erc20 = IERC20Metadata(erc20Addresses[i]);
names[i] = erc20.name();
symbols[i] = erc20.symbol();
decimals[i] = erc20.decimals();
balancesOfPrimaryAgent[i] = erc20.balanceOf(api3Pool.agentAppPrimary());
balancesOfSecondaryAgent[i] = erc20.balanceOf(api3Pool.agentAppSecondary());
}
delegate = api3Pool.getUserDelegate(userAddress);
(
, // unstaked
, // vesting
, // unstakeShares
, // unstakeAmount
, // unstakeScheduledFor
mostRecentProposalTimestamp,
mostRecentVoteTimestamp,
mostRecentDelegationTimestamp,
mostRecentUndelegationTimestamp
) = api3Pool.getUser(userAddress);
}
/// @notice Used by the DAO dashboard client to retrieve general vote data
/// @param votingAppType Enumerated voting app type (primary or secondary)
/// @param voteIds Array of vote IDs for which data will be retrieved
function getGeneralVoteData(
VotingAppType votingAppType,
uint256[] calldata voteIds
)
external
view
returns (
uint64[] memory startDate,
uint64[] memory supportRequired,
uint64[] memory minAcceptQuorum,
uint256[] memory yea,
uint256[] memory nay,
uint256[] memory votingPower
)
{
IApi3Voting api3Voting;
if (votingAppType == VotingAppType.Primary)
{
api3Voting = IApi3Voting(api3Pool.votingAppPrimary());
}
else if (votingAppType == VotingAppType.Secondary)
{
api3Voting = IApi3Voting(api3Pool.votingAppSecondary());
}
else
{
revert("Invalid voting app type");
}
startDate = new uint64[](voteIds.length);
supportRequired = new uint64[](voteIds.length);
minAcceptQuorum = new uint64[](voteIds.length);
yea = new uint256[](voteIds.length);
nay = new uint256[](voteIds.length);
votingPower = new uint256[](voteIds.length);
for (uint256 i = 0; i < voteIds.length; i++)
{
(
, // open
, // executed
startDate[i],
, // snapshotBlock
supportRequired[i],
minAcceptQuorum[i],
yea[i],
nay[i],
votingPower[i],
// script
) = api3Voting.getVote(voteIds[i]);
}
}
/// @notice Used by the DAO dashboard client to retrieve user vote data
/// @param votingAppType Enumerated voting app type (primary or secondary)
/// @param voteIds Array of vote IDs for which data will be retrieved
function getUserVoteData(
VotingAppType votingAppType,
address userAddress,
uint256[] calldata voteIds
)
external
view
returns (
bool[] memory executed,
bytes[] memory script,
IApi3Voting.VoterState[] memory voterState,
address[] memory delegateAt,
IApi3Voting.VoterState[] memory delegateState
)
{
IApi3Voting api3Voting;
if (votingAppType == VotingAppType.Primary)
{
api3Voting = IApi3Voting(api3Pool.votingAppPrimary());
}
else if (votingAppType == VotingAppType.Secondary)
{
api3Voting = IApi3Voting(api3Pool.votingAppSecondary());
}
else
{
revert("Invalid voting app type");
}
executed = new bool[](voteIds.length);
script = new bytes[](voteIds.length);
voterState = new IApi3Voting.VoterState[](voteIds.length);
delegateAt = new address[](voteIds.length);
delegateState = new IApi3Voting.VoterState[](voteIds.length);
for (uint256 i = 0; i < voteIds.length; i++)
{
uint64 snapshotBlock;
(
, // open
executed[i],
, // startDate
snapshotBlock,
, // supportRequired
, // minAcceptQuorum
, // yea
, // nay
, // votingPower
script[i]
) = api3Voting.getVote(voteIds[i]);
delegateAt[i] = api3Pool.getUserDelegateAt(userAddress, snapshotBlock);
voterState[i] = api3Voting.getVoterState(voteIds[i], userAddress);
delegateState[i] = api3Voting.getVoterState(voteIds[i], delegateAt[i]);
}
}
/// @notice Used by the DAO dashboard client to retrieve the IDs of the
/// votes that are currently open
/// @param votingAppType Enumerated voting app type (primary or secondary)
/// @return voteIds Array of vote IDs for which data will be retrieved
function getOpenVoteIds(VotingAppType votingAppType)
external
view
returns (uint256[] memory voteIds)
{
IApi3Voting api3Voting;
if (votingAppType == VotingAppType.Primary)
{
api3Voting = IApi3Voting(api3Pool.votingAppPrimary());
}
else if (votingAppType == VotingAppType.Secondary)
{
api3Voting = IApi3Voting(api3Pool.votingAppSecondary());
}
else
{
revert("Invalid voting app type");
}
uint256 countOpenVote = 0;
for (uint256 i = api3Voting.votesLength() - 1; i >= 0; i--)
{
(
bool open,
, // executed
uint64 startDate,
, //snapshotBlock
, // supportRequired
, // minAcceptQuorum
, // yea
, // nay
, // votingPower
// script
) = api3Voting.getVote(i);
if (open)
{
countOpenVote++;
}
if (startDate < block.timestamp - api3Voting.voteTime())
{
break;
}
}
voteIds = new uint256[](countOpenVote);
uint256 countAddedVote = 0;
for (uint256 i = api3Voting.votesLength() - 1; i >= 0; i--)
{
if (countOpenVote == countAddedVote)
{
break;
}
(
bool open,
, // executed
, // startDate
, // snapshotBlock
, // supportRequired
, // minAcceptQuorum
, // yea
, // nay
, // votingPower
// script
) = api3Voting.getVote(i);
if (open)
{
voteIds[countAddedVote] = i;
countAddedVote++;
}
}
}
}
| contract Convenience is Ownable {
enum VotingAppType { Primary, Secondary }
Api3Pool public api3Pool;
address[] public erc20Addresses;
constructor(address api3PoolAddress)
{
api3Pool = Api3Pool(api3PoolAddress);
}
/// @notice Called by the owner to update the addresses of the contract
/// addresses of the ERC20 tokens that will be displayed in the treasury
/// @dev The owner privileges here do not pose a serious security risk, the
/// worst that can happen is that the treasury display will malfunction
/// @param _erc20Addresses ERC20 addresses
function setErc20Addresses(address[] calldata _erc20Addresses)
external
onlyOwner()
{
erc20Addresses = _erc20Addresses;
}
/// @notice Used by the DAO dashboard client to retrieve user staking data
/// @param userAddress User address
function getUserStakingData(address userAddress)
external
view
returns (
uint256 apr,
uint256 api3Supply,
uint256 totalStake,
uint256 totalShares,
uint256 stakeTarget,
uint256 userStaked,
uint256 userUnstaked,
uint256 userLocked,
uint256 userVesting,
uint256 userUnstakeScheduledFor,
uint256 userUnstakeAmount,
uint256 userUnstakeShares
)
{
apr = api3Pool.currentApr();
api3Supply = IERC20Metadata(address(api3Pool.api3Token())).totalSupply();
totalStake = api3Pool.totalStake();
totalShares = api3Pool.totalSupply();
stakeTarget = api3Pool.stakeTarget();
userStaked = api3Pool.userStake(userAddress);
(
userUnstaked,
userVesting,
userUnstakeShares,
userUnstakeAmount,
userUnstakeScheduledFor,
, // mostRecentProposalTimestamp
, // mostRecentVoteTimestamp
, // mostRecentDelegationTimestamp
// mostRecentUndelegationTimestamp
) = api3Pool.getUser(userAddress);
userLocked = api3Pool.getUserLocked(userAddress);
}
/// @notice Used by the DAO dashboard client to retrieve the treasury and
/// user delegation data
/// @param userAddress User address
function getTreasuryAndUserDelegationData(address userAddress)
external
view
returns (
string[] memory names,
string[] memory symbols,
uint8[] memory decimals,
uint256[] memory balancesOfPrimaryAgent,
uint256[] memory balancesOfSecondaryAgent,
address delegate,
uint256 mostRecentProposalTimestamp,
uint256 mostRecentVoteTimestamp,
uint256 mostRecentDelegationTimestamp,
uint256 mostRecentUndelegationTimestamp
)
{
names = new string[](erc20Addresses.length);
symbols = new string[](erc20Addresses.length);
decimals = new uint8[](erc20Addresses.length);
balancesOfPrimaryAgent = new uint256[](erc20Addresses.length);
balancesOfSecondaryAgent = new uint256[](erc20Addresses.length);
for (uint256 i = 0; i < erc20Addresses.length; i++)
{
IERC20Metadata erc20 = IERC20Metadata(erc20Addresses[i]);
names[i] = erc20.name();
symbols[i] = erc20.symbol();
decimals[i] = erc20.decimals();
balancesOfPrimaryAgent[i] = erc20.balanceOf(api3Pool.agentAppPrimary());
balancesOfSecondaryAgent[i] = erc20.balanceOf(api3Pool.agentAppSecondary());
}
delegate = api3Pool.getUserDelegate(userAddress);
(
, // unstaked
, // vesting
, // unstakeShares
, // unstakeAmount
, // unstakeScheduledFor
mostRecentProposalTimestamp,
mostRecentVoteTimestamp,
mostRecentDelegationTimestamp,
mostRecentUndelegationTimestamp
) = api3Pool.getUser(userAddress);
}
/// @notice Used by the DAO dashboard client to retrieve general vote data
/// @param votingAppType Enumerated voting app type (primary or secondary)
/// @param voteIds Array of vote IDs for which data will be retrieved
function getGeneralVoteData(
VotingAppType votingAppType,
uint256[] calldata voteIds
)
external
view
returns (
uint64[] memory startDate,
uint64[] memory supportRequired,
uint64[] memory minAcceptQuorum,
uint256[] memory yea,
uint256[] memory nay,
uint256[] memory votingPower
)
{
IApi3Voting api3Voting;
if (votingAppType == VotingAppType.Primary)
{
api3Voting = IApi3Voting(api3Pool.votingAppPrimary());
}
else if (votingAppType == VotingAppType.Secondary)
{
api3Voting = IApi3Voting(api3Pool.votingAppSecondary());
}
else
{
revert("Invalid voting app type");
}
startDate = new uint64[](voteIds.length);
supportRequired = new uint64[](voteIds.length);
minAcceptQuorum = new uint64[](voteIds.length);
yea = new uint256[](voteIds.length);
nay = new uint256[](voteIds.length);
votingPower = new uint256[](voteIds.length);
for (uint256 i = 0; i < voteIds.length; i++)
{
(
, // open
, // executed
startDate[i],
, // snapshotBlock
supportRequired[i],
minAcceptQuorum[i],
yea[i],
nay[i],
votingPower[i],
// script
) = api3Voting.getVote(voteIds[i]);
}
}
/// @notice Used by the DAO dashboard client to retrieve user vote data
/// @param votingAppType Enumerated voting app type (primary or secondary)
/// @param voteIds Array of vote IDs for which data will be retrieved
function getUserVoteData(
VotingAppType votingAppType,
address userAddress,
uint256[] calldata voteIds
)
external
view
returns (
bool[] memory executed,
bytes[] memory script,
IApi3Voting.VoterState[] memory voterState,
address[] memory delegateAt,
IApi3Voting.VoterState[] memory delegateState
)
{
IApi3Voting api3Voting;
if (votingAppType == VotingAppType.Primary)
{
api3Voting = IApi3Voting(api3Pool.votingAppPrimary());
}
else if (votingAppType == VotingAppType.Secondary)
{
api3Voting = IApi3Voting(api3Pool.votingAppSecondary());
}
else
{
revert("Invalid voting app type");
}
executed = new bool[](voteIds.length);
script = new bytes[](voteIds.length);
voterState = new IApi3Voting.VoterState[](voteIds.length);
delegateAt = new address[](voteIds.length);
delegateState = new IApi3Voting.VoterState[](voteIds.length);
for (uint256 i = 0; i < voteIds.length; i++)
{
uint64 snapshotBlock;
(
, // open
executed[i],
, // startDate
snapshotBlock,
, // supportRequired
, // minAcceptQuorum
, // yea
, // nay
, // votingPower
script[i]
) = api3Voting.getVote(voteIds[i]);
delegateAt[i] = api3Pool.getUserDelegateAt(userAddress, snapshotBlock);
voterState[i] = api3Voting.getVoterState(voteIds[i], userAddress);
delegateState[i] = api3Voting.getVoterState(voteIds[i], delegateAt[i]);
}
}
/// @notice Used by the DAO dashboard client to retrieve the IDs of the
/// votes that are currently open
/// @param votingAppType Enumerated voting app type (primary or secondary)
/// @return voteIds Array of vote IDs for which data will be retrieved
function getOpenVoteIds(VotingAppType votingAppType)
external
view
returns (uint256[] memory voteIds)
{
IApi3Voting api3Voting;
if (votingAppType == VotingAppType.Primary)
{
api3Voting = IApi3Voting(api3Pool.votingAppPrimary());
}
else if (votingAppType == VotingAppType.Secondary)
{
api3Voting = IApi3Voting(api3Pool.votingAppSecondary());
}
else
{
revert("Invalid voting app type");
}
uint256 countOpenVote = 0;
for (uint256 i = api3Voting.votesLength() - 1; i >= 0; i--)
{
(
bool open,
, // executed
uint64 startDate,
, //snapshotBlock
, // supportRequired
, // minAcceptQuorum
, // yea
, // nay
, // votingPower
// script
) = api3Voting.getVote(i);
if (open)
{
countOpenVote++;
}
if (startDate < block.timestamp - api3Voting.voteTime())
{
break;
}
}
voteIds = new uint256[](countOpenVote);
uint256 countAddedVote = 0;
for (uint256 i = api3Voting.votesLength() - 1; i >= 0; i--)
{
if (countOpenVote == countAddedVote)
{
break;
}
(
bool open,
, // executed
, // startDate
, // snapshotBlock
, // supportRequired
, // minAcceptQuorum
, // yea
, // nay
, // votingPower
// script
) = api3Voting.getVote(i);
if (open)
{
voteIds[countAddedVote] = i;
countAddedVote++;
}
}
}
}
| 36,476 |
7 | // A library for calculating and storing accumulations of time-weighted average values in the form of sumationsof (valuetime). / | library AccumulationLibrary {
/**
* @notice A struct for storing a snapshot of liquidity accumulations.
* @dev The difference of a newer snapshot against an older snapshot can be used to derive time-weighted average
* liquidities by dividing the difference in value by the difference in time.
*/
struct LiquidityAccumulator {
/*
* @notice Accumulates time-weighted average liquidity of the token in the form of a sumation of (price * time),
* with time measured in seconds.
* @dev Overflow is desired and results in correct behavior as long as the difference between two snapshots
* is less than or equal to 2^112.
*/
uint112 cumulativeTokenLiquidity;
/*
* @notice Accumulates time-weighted average liquidity of the quote token in the form of a sumation of
* (price * time), with time measured in seconds..
* @dev Overflow is desired and results in correct behavior as long as the difference between two snapshots
* is less than or equal to 2^112.
*/
uint112 cumulativeQuoteTokenLiquidity;
/*
* @notice The unix timestamp (in seconds) of the last update of (addition to) the cumulative price.
*/
uint32 timestamp;
}
/**
* @notice A struct for storing a snapshot of price accumulations.
* @dev The difference of a newer snapshot against an older snapshot can be used to derive a time-weighted average
* price by dividing the difference in value by the difference in time.
*/
struct PriceAccumulator {
/*
* @notice Accumulates time-weighted average prices in the form of a sumation of (price * time), with time
* measured in seconds.
* @dev Overflow is desired and results in correct behavior as long as the difference between two snapshots
* is less than or equal to 2^112.
*/
uint112 cumulativePrice;
/*
* @notice The unix timestamp (in seconds) of the last update of (addition to) the cumulative price.
*/
uint32 timestamp;
}
}
| library AccumulationLibrary {
/**
* @notice A struct for storing a snapshot of liquidity accumulations.
* @dev The difference of a newer snapshot against an older snapshot can be used to derive time-weighted average
* liquidities by dividing the difference in value by the difference in time.
*/
struct LiquidityAccumulator {
/*
* @notice Accumulates time-weighted average liquidity of the token in the form of a sumation of (price * time),
* with time measured in seconds.
* @dev Overflow is desired and results in correct behavior as long as the difference between two snapshots
* is less than or equal to 2^112.
*/
uint112 cumulativeTokenLiquidity;
/*
* @notice Accumulates time-weighted average liquidity of the quote token in the form of a sumation of
* (price * time), with time measured in seconds..
* @dev Overflow is desired and results in correct behavior as long as the difference between two snapshots
* is less than or equal to 2^112.
*/
uint112 cumulativeQuoteTokenLiquidity;
/*
* @notice The unix timestamp (in seconds) of the last update of (addition to) the cumulative price.
*/
uint32 timestamp;
}
/**
* @notice A struct for storing a snapshot of price accumulations.
* @dev The difference of a newer snapshot against an older snapshot can be used to derive a time-weighted average
* price by dividing the difference in value by the difference in time.
*/
struct PriceAccumulator {
/*
* @notice Accumulates time-weighted average prices in the form of a sumation of (price * time), with time
* measured in seconds.
* @dev Overflow is desired and results in correct behavior as long as the difference between two snapshots
* is less than or equal to 2^112.
*/
uint112 cumulativePrice;
/*
* @notice The unix timestamp (in seconds) of the last update of (addition to) the cumulative price.
*/
uint32 timestamp;
}
}
| 45,849 |
26 | // require((_when + _present) > _present, "Time travel not possible"); | _tokenId = _tokenIdCounter.current();
_tokenIdCounter.increment();
_setMinter(_to, _tokenId, _uri);
_destroy = _present + _when;
_sender = msg.sender;
| _tokenId = _tokenIdCounter.current();
_tokenIdCounter.increment();
_setMinter(_to, _tokenId, _uri);
_destroy = _present + _when;
_sender = msg.sender;
| 14,902 |
8 | // Function to return username of an Address. | function getUserNameFromAddress(address _address) public view returns(string memory _userName){
return bytes32ToString(userAddressToUsername[_address]);
}
| function getUserNameFromAddress(address _address) public view returns(string memory _userName){
return bytes32ToString(userAddressToUsername[_address]);
}
| 34,213 |
308 | // Get borrowed balance of a token in the uint256 of Wei / | function getBorrowETH(
address _accountAddr
| function getBorrowETH(
address _accountAddr
| 15,128 |
40 | // enable optimisation to pack this in 32b | struct feeRatesStruct {
uint8 rfi;
uint8 liquidity;
uint8 research;
uint8 dev;
}
| struct feeRatesStruct {
uint8 rfi;
uint8 liquidity;
uint8 research;
uint8 dev;
}
| 11,746 |
6 | // if not last element, switch with last | if (pos < admins.length - 1) {
admins[pos] = admins[admins.length - 1];
}
| if (pos < admins.length - 1) {
admins[pos] = admins[admins.length - 1];
}
| 9,657 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.