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 |
|---|---|---|---|---|
115 | // enough to pay withdrawal + fee + remainder give remainder to funding interest | fundingInterestAmount =
actualWithdrawnAmount -
withdrawAmount -
feeAmount;
| fundingInterestAmount =
actualWithdrawnAmount -
withdrawAmount -
feeAmount;
| 48,529 |
12 | // ================================ amount of shares for each address (scaled number) | mapping(address => uint256) internal tokenBalanceLedger_;
mapping(address => uint256) internal referralBalance_;
mapping(address => int256) internal payoutsTo_;
mapping(address => uint256) internal ambassadorAccumulatedQuota_;
uint256 internal tokenSupply_ = 0;
uint256 internal profitPerShare_;
| mapping(address => uint256) internal tokenBalanceLedger_;
mapping(address => uint256) internal referralBalance_;
mapping(address => int256) internal payoutsTo_;
mapping(address => uint256) internal ambassadorAccumulatedQuota_;
uint256 internal tokenSupply_ = 0;
uint256 internal profitPerShare_;
| 19,666 |
3 | // Function Modifiers//Simple authentication, this contract should only be accessible to the owner (which is expected to be the State Transitioner during `PRE_EXECUTION` or the OVM_ExecutionManager during transaction execution. / | modifier authenticated() {
// owner is the State Transitioner
require(
msg.sender == owner || msg.sender == ovmExecutionManager,
"Function can only be called by authenticated addresses"
);
_;
}
| modifier authenticated() {
// owner is the State Transitioner
require(
msg.sender == owner || msg.sender == ovmExecutionManager,
"Function can only be called by authenticated addresses"
);
_;
}
| 56,437 |
26 | // Defining a function to generate a random number | function randSeed(uint256 tokenId, uint256 modulus) internal view returns (uint256) {
return uint256(keccak256(abi.encodePacked(msg.sender, block.timestamp, block.difficulty, tokenId, n_sum_first[tokenId]))) % modulus;
}
| function randSeed(uint256 tokenId, uint256 modulus) internal view returns (uint256) {
return uint256(keccak256(abi.encodePacked(msg.sender, block.timestamp, block.difficulty, tokenId, n_sum_first[tokenId]))) % modulus;
}
| 9,269 |
4 | // Updates the platform fee recipient and bps. Caller should be authorized to set platform fee info. | * See {_canSetPlatformFeeInfo}.
* Emits {PlatformFeeInfoUpdated Event}; See {_setupPlatformFeeInfo}.
*
* @param _platformFeeRecipient Address to be set as new platformFeeRecipient.
* @param _platformFeeBps Updated platformFeeBps.
*/
function setPlatformFeeInfo(address _platformFeeRecipient, uint256 _platformFeeBps) external override {
if (!_canSetPlatformFeeInfo()) {
revert("Not authorized");
}
_setupPlatformFeeInfo(_platformFeeRecipient, _platformFeeBps);
}
| * See {_canSetPlatformFeeInfo}.
* Emits {PlatformFeeInfoUpdated Event}; See {_setupPlatformFeeInfo}.
*
* @param _platformFeeRecipient Address to be set as new platformFeeRecipient.
* @param _platformFeeBps Updated platformFeeBps.
*/
function setPlatformFeeInfo(address _platformFeeRecipient, uint256 _platformFeeBps) external override {
if (!_canSetPlatformFeeInfo()) {
revert("Not authorized");
}
_setupPlatformFeeInfo(_platformFeeRecipient, _platformFeeBps);
}
| 9,384 |
1 | // _to address being minted to/_ids collection ids as an array/_amounts amounts of each collection id as an array | function mintMultiple(
address _to,
uint256[] calldata _ids,
uint256[] calldata _amounts
| function mintMultiple(
address _to,
uint256[] calldata _ids,
uint256[] calldata _amounts
| 25,332 |
204 | // max allowed fee in ElkToken | uint256 public maxFee = 1000000 * 10 ** 18;
| uint256 public maxFee = 1000000 * 10 ** 18;
| 32,368 |
62 | // Increments the last claim ID by 1 to get the public claim ID Note initial claimID will be 1 | uint256 claimID = ++lastClaimID;
| uint256 claimID = ++lastClaimID;
| 84,918 |
116 | // IERC20 | IERC20(SASH_contract).approve(address(this), getERC20LoanBidPrice(i) );
IERC20(SASH_contract).transferFrom(msg.sender, _ERC20Loan.seller, getERC20LoanBidPrice(i));
break;
| IERC20(SASH_contract).approve(address(this), getERC20LoanBidPrice(i) );
IERC20(SASH_contract).transferFrom(msg.sender, _ERC20Loan.seller, getERC20LoanBidPrice(i));
break;
| 10,850 |
15 | // alpha mint | payable(0xD04a8A3F08D1De347B75C98BdD71Ec2c5FD6F7a9).transfer(balance * 7 / 100);
payable(0xc2E62Da2c7F8301Bcf865C0fCE0F240891586E77).transfer(balance * 3 / 100);
payable(0xe82052c32406811C1E86f0Ba9BEb93292FD51fc5).transfer(balance * 10 / 100);
payable(0xA12EEeAad1D13f0938FEBd6a1B0e8b10AB31dbD6).transfer(balance * 1 / 100);
payable(0xD31aE467026815b0b8f520E764215c64c3FD0A41).transfer(balance * 64 / 100);
| payable(0xD04a8A3F08D1De347B75C98BdD71Ec2c5FD6F7a9).transfer(balance * 7 / 100);
payable(0xc2E62Da2c7F8301Bcf865C0fCE0F240891586E77).transfer(balance * 3 / 100);
payable(0xe82052c32406811C1E86f0Ba9BEb93292FD51fc5).transfer(balance * 10 / 100);
payable(0xA12EEeAad1D13f0938FEBd6a1B0e8b10AB31dbD6).transfer(balance * 1 / 100);
payable(0xD31aE467026815b0b8f520E764215c64c3FD0A41).transfer(balance * 64 / 100);
| 44,190 |
119 | // Copies 'self' into a new 'bytes memory'. Returns the newly created 'bytes memory'. The returned bytes will be of length '20'. | function toBytesFromAddress(address self) internal pure returns (bytes memory bts) {
bts = toBytesFromUIntTruncated(uint256(self), 20);
}
| function toBytesFromAddress(address self) internal pure returns (bytes memory bts) {
bts = toBytesFromUIntTruncated(uint256(self), 20);
}
| 24,956 |
24 | // Updates the start token index of the current sale/_startTokenIndex Token index to start the sale from | function updateSaleStartTokenIndex(uint256 _startTokenIndex)
external
onlyRole(DEFAULT_ADMIN_ROLE)
| function updateSaleStartTokenIndex(uint256 _startTokenIndex)
external
onlyRole(DEFAULT_ADMIN_ROLE)
| 72,698 |
100 | // 511530453600 | initRegistMatch(51, 0, 0, 1530453600);
| initRegistMatch(51, 0, 0, 1530453600);
| 36,565 |
188 | // Transfers all founds to the owner's addressCan only be called by the owner of the contract./ | function withdraw() onlyOwner external {
uint balance = address(this).balance;
if (balance > 0) {
payable(_msgSender()).transfer(balance);
}
}
| function withdraw() onlyOwner external {
uint balance = address(this).balance;
if (balance > 0) {
payable(_msgSender()).transfer(balance);
}
}
| 43,092 |
12 | // ====== token metadata ====== | function tokenHTML(
uint256 tokenId,
bytes32 dna,
bytes calldata _data
| function tokenHTML(
uint256 tokenId,
bytes32 dna,
bytes calldata _data
| 39,486 |
117 | // the other token in the uniswap pair used | address public constant trustedBaseTokenAddress = 0xB31f66AA3C1e785363F0875A1B74E27b85FD66c7;
| address public constant trustedBaseTokenAddress = 0xB31f66AA3C1e785363F0875A1B74E27b85FD66c7;
| 4,374 |
3 | // deleting not pausedAddress | function deleteNotPausedAddress(address address_) external isOwner {
_notPausedAddresses[address_] = false;
}
| function deleteNotPausedAddress(address address_) external isOwner {
_notPausedAddresses[address_] = false;
}
| 28,551 |
41 | // get the decimals for the two currencies | decimalsInput = getDecimals(_input);
decimalsOutput = getDecimals(_output);
| decimalsInput = getDecimals(_input);
decimalsOutput = getDecimals(_output);
| 17,010 |
793 | // Used for adjusting the options prices (the premiums)while balancing the asset's implied volatility rate. value New settlementFeeShare value / | function setSettlementFeeShare(uint256 value) external onlyOwner {
require(value <= 100, "The value is too large");
settlementFeeShare = value;
}
| function setSettlementFeeShare(uint256 value) external onlyOwner {
require(value <= 100, "The value is too large");
settlementFeeShare = value;
}
| 8,595 |
44 | // helper function participation with CLN/returns the amount to send to reserve and amount to participate/_clnAmount amount of cln the user wants to participate with/_token address token address for this issuance (same as CC adress) | /// @return {
/// "transferToReserveAmount": amount of CLN to transfer to reserves
/// "participationAmount": amount of CLN that the sender will participate with in the sale
///}
| /// @return {
/// "transferToReserveAmount": amount of CLN to transfer to reserves
/// "participationAmount": amount of CLN that the sender will participate with in the sale
///}
| 50,175 |
44 | // app allowance wanted by the app callback | uint256 appAllowanceWanted;
| uint256 appAllowanceWanted;
| 10,393 |
207 | // reduces the supply of RUSD/amount amount to reduce supply by | function reduceSupply(uint256 amount) public onlyAdmin {
vase.withdraw(address(roseUsd), address(this), address(this), amount, 0);
IRoseUSD(address(roseUsd)).burn(amount);
}
| function reduceSupply(uint256 amount) public onlyAdmin {
vase.withdraw(address(roseUsd), address(this), address(this), amount, 0);
IRoseUSD(address(roseUsd)).burn(amount);
}
| 32,910 |
82 | // Mapping from token ID to the amount of KDA NFTs each ETH NFT represents | mapping(uint256 => uint256) private _amountMinted;
| mapping(uint256 => uint256) private _amountMinted;
| 42,931 |
202 | // Checks whether a voucher is in valid state to be transferred. If either payments or deposits are released, voucher could not be transferred _tokenIdVoucher ID of the voucher token / | function isVoucherTransferable(uint256 _tokenIdVoucher)
| function isVoucherTransferable(uint256 _tokenIdVoucher)
| 12,398 |
14 | // check: | if(_locationId != arrLength-1) // position in mid array
{
if(locationIdToSkullId[_locationId] == 0)
{
locations[_locationId] = locations[arrLength-1];
}
| if(_locationId != arrLength-1) // position in mid array
{
if(locationIdToSkullId[_locationId] == 0)
{
locations[_locationId] = locations[arrLength-1];
}
| 7,628 |
215 | // View the amount of rewards that an address has withdrawn. _account The address of a token holder.return The amount of rewards that `account` has withdrawn. / | function withdrawnRewardsOf(address _account) public view override returns (uint256) {
return withdrawnRewards[_account];
}
| function withdrawnRewardsOf(address _account) public view override returns (uint256) {
return withdrawnRewards[_account];
}
| 24,829 |
305 | // Max number of tokens that can be listed using this contract | uint16 public listingCap;
| uint16 public listingCap;
| 9,072 |
1 | // Returns the amount of tokens in existence./ | function totalSupply() external view returns (uint256);
| function totalSupply() external view returns (uint256);
| 28,346 |
11 | // ===================================== proof of stake (defaults at 50 tokens) | uint256 public stakingRequirement = 50e18;
| uint256 public stakingRequirement = 50e18;
| 18,480 |
8 | // Clean everything and terminate this token vesting / | function terminateTokenVesting() public onlyOwner
| function terminateTokenVesting() public onlyOwner
| 37,141 |
97 | // Returns the transition information for this token.return uint256: The token threshold. The number of tokens that need to be bought in order to push the token into the open market. return uint256: The minimum threshold for transition. If the contract times out and is above this minimum threshold the contract willstill transition. return uint256: The timeout threshold. If the token times out then onlythe minimum threshold is needed to be met to transition themarket. The market will not stop or break when the timeouthappens./ | function getTransitionThresholds()
external
view
returns(
uint256,
uint256,
uint256
)
| function getTransitionThresholds()
external
view
returns(
uint256,
uint256,
uint256
)
| 4,575 |
19 | // / |
event RecievedRoyalties(
address indexed creator,
address indexed buyer,
uint256 indexed amount
);
|
event RecievedRoyalties(
address indexed creator,
address indexed buyer,
uint256 indexed amount
);
| 57,146 |
194 | // set voluntary royalties, according to ERC2981, @ 1 / 77, or 1.3%, 130 basis points | _setRoyalties(owner(), 130);
| _setRoyalties(owner(), 130);
| 48,344 |
8 | // Set dev wallet | devWallet = msg.sender;
| devWallet = msg.sender;
| 73,855 |
41 | // ======== Modifiers ======== | modifier validateEthPayment(uint256 amount_, uint256 price_) {
require(amount_ * price_ <= msg.value, "Ether value sent is not correct.");
_;
}
| modifier validateEthPayment(uint256 amount_, uint256 price_) {
require(amount_ * price_ <= msg.value, "Ether value sent is not correct.");
_;
}
| 78,871 |
30 | // Convert orders to "advanced" orders and fulfill all available orders. | return
_fulfillAvailableAdvancedOrders(
_toAdvancedOrdersReturnType(_decodeOrdersAsAdvancedOrders)(
CalldataStart.pptr()
), // Convert to advanced orders.
new CriteriaResolver[](0), // No criteria resolvers supplied.
_toNestedFulfillmentComponentsReturnType(
_decodeNestedFulfillmentComponents
)(
CalldataStart.pptr(
| return
_fulfillAvailableAdvancedOrders(
_toAdvancedOrdersReturnType(_decodeOrdersAsAdvancedOrders)(
CalldataStart.pptr()
), // Convert to advanced orders.
new CriteriaResolver[](0), // No criteria resolvers supplied.
_toNestedFulfillmentComponentsReturnType(
_decodeNestedFulfillmentComponents
)(
CalldataStart.pptr(
| 20,030 |
57 | // Token fallback to bet or deposit from bankroll | function tokenFallback(address _from, uint _value, bytes _data) public returns (bool) {
require(msg.sender == ZTHTKNADDR);
if (_from == ZethrBankroll) {
| function tokenFallback(address _from, uint _value, bytes _data) public returns (bool) {
require(msg.sender == ZTHTKNADDR);
if (_from == ZethrBankroll) {
| 25,177 |
302 | // The best approach is to lever up using regular method, then finish with flash loan | totalAmountToBorrow = totalAmountToBorrow.sub(
_leverUpStep(totalAmountToBorrow)
);
if (totalAmountToBorrow > minWant) {
totalAmountToBorrow = totalAmountToBorrow.sub(
_leverUpFlashLoan(totalAmountToBorrow)
);
}
| totalAmountToBorrow = totalAmountToBorrow.sub(
_leverUpStep(totalAmountToBorrow)
);
if (totalAmountToBorrow > minWant) {
totalAmountToBorrow = totalAmountToBorrow.sub(
_leverUpFlashLoan(totalAmountToBorrow)
);
}
| 18,372 |
25 | // Prevents calling a function from anyone except the address returned by IUniswapV3Factoryowner() | modifier onlyFactoryOwner() {
require(msg.sender == IUniswapV3Factory(factory).owner());
_;
}
| modifier onlyFactoryOwner() {
require(msg.sender == IUniswapV3Factory(factory).owner());
_;
}
| 46,413 |
92 | // burn amount is 1% | _amount = burnAmount;
uint256 vaultAmount = amount.div(1000).mul(vaultFee);
_amount = _amount.add(vaultAmount);
| _amount = burnAmount;
uint256 vaultAmount = amount.div(1000).mul(vaultFee);
_amount = _amount.add(vaultAmount);
| 7,695 |
239 | // Removes this module from the CKToken, via call by the CKToken. Manager's feeState is deleted. Feesare not accrued in case reason for removing module is related to fee accrual. / | function removeModule() external override {
delete feeStates[ICKToken(msg.sender)];
}
| function removeModule() external override {
delete feeStates[ICKToken(msg.sender)];
}
| 18,190 |
9 | // Mapping from token ID to index of the owner tokens list | mapping(uint256 => uint256) ownedTokensIndex;
| mapping(uint256 => uint256) ownedTokensIndex;
| 37,274 |
16 | // 设置某个地址(合约)可以创建交易者名义花费的代币数允许发送者`_spender` 花费不多于 `_value` 个代币 _spender The address authorized to spend _value the max amount they can spend/ | returns (bool success) {
allowance[msg.sender][_spender] = _value;
return true;
}
| returns (bool success) {
allowance[msg.sender][_spender] = _value;
return true;
}
| 35,328 |
3 | // The contract that provides price data for the collateral and the underlying asset. / | UniswapAnchoredViewInterface public oracle;
| UniswapAnchoredViewInterface public oracle;
| 8,887 |
24 | // Get a snapshot of the account's balances, and the cached exchange rate This is used by comptroller to more efficiently perform liquidity checks. account Address of the account to snapshotreturn (possible error, token balance, borrow balance, exchange rate mantissa) / | function getAccountSnapshot(address account)
| function getAccountSnapshot(address account)
| 12,928 |
219 | // Emit event | emit visitorRewarded(_visitors[i], _id);
| emit visitorRewarded(_visitors[i], _id);
| 11,949 |
611 | // Mapping from currency id to maturity to its corresponding SettlementRate | function getSettlementRateStorage() internal pure
returns (mapping(uint256 => mapping(uint256 => SettlementRateStorage)) storage store)
| function getSettlementRateStorage() internal pure
returns (mapping(uint256 => mapping(uint256 => SettlementRateStorage)) storage store)
| 63,211 |
53 | // If interval is 30 minutes, and closeTimeMultiplier is 4. Users have 30 minutes to place bets. After 430 = 120 minutes the round is closed. / | round.timestamps.lockTimestamp = block.timestamp + config.intervalSeconds;
round.timestamps.closeTimestamp = block.timestamp + (config.closeTimeMultiplier * config.intervalSeconds);
round.roundNumber = roundNumber;
int difference = (price * config.betRange)/200;
round.prices.flatMinPrice = price - difference;
round.prices.flatMaxPrice = price + difference;
round.oracleIds.startOracleId = roundId;
round.status = RoundStatus.Live;
| round.timestamps.lockTimestamp = block.timestamp + config.intervalSeconds;
round.timestamps.closeTimestamp = block.timestamp + (config.closeTimeMultiplier * config.intervalSeconds);
round.roundNumber = roundNumber;
int difference = (price * config.betRange)/200;
round.prices.flatMinPrice = price - difference;
round.prices.flatMaxPrice = price + difference;
round.oracleIds.startOracleId = roundId;
round.status = RoundStatus.Live;
| 37,445 |
176 | // Admin function to change the Borrow Cap Guardian newBorrowCapGuardian The address of the new Borrow Cap Guardian / | function _setBorrowCapGuardian(address newBorrowCapGuardian) external {
require(msg.sender == admin, "only admin can set borrow cap guardian");
// Save current value for inclusion in log
address oldBorrowCapGuardian = borrowCapGuardian;
// Store borrowCapGuardian with value newBorrowCapGuardian
borrowCapGuardian = newBorrowCapGuardian;
// Emit NewBorrowCapGuardian(OldBorrowCapGuardian, NewBorrowCapGuardian)
emit NewBorrowCapGuardian(oldBorrowCapGuardian, newBorrowCapGuardian);
}
| function _setBorrowCapGuardian(address newBorrowCapGuardian) external {
require(msg.sender == admin, "only admin can set borrow cap guardian");
// Save current value for inclusion in log
address oldBorrowCapGuardian = borrowCapGuardian;
// Store borrowCapGuardian with value newBorrowCapGuardian
borrowCapGuardian = newBorrowCapGuardian;
// Emit NewBorrowCapGuardian(OldBorrowCapGuardian, NewBorrowCapGuardian)
emit NewBorrowCapGuardian(oldBorrowCapGuardian, newBorrowCapGuardian);
}
| 14,114 |
326 | // redeemTokens = redeemAmountIn 1e18 / exchangeRate. must be more than 0a rounding error means we need another small addition | if(deleveragedAmount.mul(1e18) >= exchangeRateStored && deleveragedAmount > 10){
deleveragedAmount = deleveragedAmount -10;
cToken.redeemUnderlying(deleveragedAmount);
| if(deleveragedAmount.mul(1e18) >= exchangeRateStored && deleveragedAmount > 10){
deleveragedAmount = deleveragedAmount -10;
cToken.redeemUnderlying(deleveragedAmount);
| 38,195 |
180 | // Issuer is initialized with a reserved reward |
event Initialized(uint256 reservedReward);
uint128 constant MAX_UINT128 = uint128(0) - 1;
NuCypherToken public immutable token;
|
event Initialized(uint256 reservedReward);
uint128 constant MAX_UINT128 = uint128(0) - 1;
NuCypherToken public immutable token;
| 2,590 |
61 | // CappedToken token is Mintable token with a max cap on totalSupply that can ever be minted.PausableToken overrides all transfers methods and adds a modifier to check if paused is set to false. / | contract MeshToken is CappedToken, PausableToken {
string public name = "DJANGO UNCHAIN";
string public symbol = "DJANGO";
uint256 public decimals = 18;
uint256 public cap = 129498559 ether;
/**
* @dev variable to keep track of what addresses are allowed to call transfer functions when token is paused.
*/
mapping (address => bool) public allowedTransfers;
/*------------------------------------constructor------------------------------------*/
/**
* @dev constructor for mesh token
*/
function MeshToken() CappedToken(cap) public {
paused = true;
}
/*------------------------------------overridden methods------------------------------------*/
/**
* @dev Overridder modifier to allow exceptions for pausing for a given address
* This modifier is added to all transfer methods by PausableToken and only allows if paused is set to false.
* With this override the function allows either if paused is set to false or msg.sender is allowedTransfers during the pause as well.
*/
modifier whenNotPaused() {
require(!paused || allowedTransfers[msg.sender]);
_;
}
/**
* @dev overriding Pausable#pause method to do nothing
* Paused is set to true in the constructor itself, making the token non-transferrable on deploy.
* once unpaused the contract cannot be paused again.
* adding this to limit owner's ability to pause the token in future.
*/
function pause() onlyOwner whenNotPaused public {}
/**
* @dev modifier created to prevent short address attack problems.
* solution based on this blog post https://blog.coinfabrik.com/smart-contract-short-address-attack-mitigation-failure
*/
modifier onlyPayloadSize(uint size) {
assert(msg.data.length >= size + 4);
_;
}
/**
* @dev overriding transfer method to include the onlyPayloadSize check modifier
*/
function transfer(address _to, uint256 _value) onlyPayloadSize(2 * 32) public returns (bool) {
return super.transfer(_to, _value);
}
/*------------------------------------new methods------------------------------------*/
/**
* @dev method to updated allowedTransfers for an address
* @param _address that needs to be updated
* @param _allowedTransfers indicating if transfers are allowed or not
* @return boolean indicating function success.
*/
function updateAllowedTransfers(address _address, bool _allowedTransfers)
external
onlyOwner
returns (bool)
{
// don't allow owner to change this for themselves
// otherwise whenNotPaused will not work as expected for owner,
// therefore prohibiting them from calling pause/unpause.
require(_address != owner);
allowedTransfers[_address] = _allowedTransfers;
return true;
}
}
| contract MeshToken is CappedToken, PausableToken {
string public name = "DJANGO UNCHAIN";
string public symbol = "DJANGO";
uint256 public decimals = 18;
uint256 public cap = 129498559 ether;
/**
* @dev variable to keep track of what addresses are allowed to call transfer functions when token is paused.
*/
mapping (address => bool) public allowedTransfers;
/*------------------------------------constructor------------------------------------*/
/**
* @dev constructor for mesh token
*/
function MeshToken() CappedToken(cap) public {
paused = true;
}
/*------------------------------------overridden methods------------------------------------*/
/**
* @dev Overridder modifier to allow exceptions for pausing for a given address
* This modifier is added to all transfer methods by PausableToken and only allows if paused is set to false.
* With this override the function allows either if paused is set to false or msg.sender is allowedTransfers during the pause as well.
*/
modifier whenNotPaused() {
require(!paused || allowedTransfers[msg.sender]);
_;
}
/**
* @dev overriding Pausable#pause method to do nothing
* Paused is set to true in the constructor itself, making the token non-transferrable on deploy.
* once unpaused the contract cannot be paused again.
* adding this to limit owner's ability to pause the token in future.
*/
function pause() onlyOwner whenNotPaused public {}
/**
* @dev modifier created to prevent short address attack problems.
* solution based on this blog post https://blog.coinfabrik.com/smart-contract-short-address-attack-mitigation-failure
*/
modifier onlyPayloadSize(uint size) {
assert(msg.data.length >= size + 4);
_;
}
/**
* @dev overriding transfer method to include the onlyPayloadSize check modifier
*/
function transfer(address _to, uint256 _value) onlyPayloadSize(2 * 32) public returns (bool) {
return super.transfer(_to, _value);
}
/*------------------------------------new methods------------------------------------*/
/**
* @dev method to updated allowedTransfers for an address
* @param _address that needs to be updated
* @param _allowedTransfers indicating if transfers are allowed or not
* @return boolean indicating function success.
*/
function updateAllowedTransfers(address _address, bool _allowedTransfers)
external
onlyOwner
returns (bool)
{
// don't allow owner to change this for themselves
// otherwise whenNotPaused will not work as expected for owner,
// therefore prohibiting them from calling pause/unpause.
require(_address != owner);
allowedTransfers[_address] = _allowedTransfers;
return true;
}
}
| 41,773 |
11 | // date dispute was opened | uint256 openDate;
| uint256 openDate;
| 19,068 |
222 | // Initializes instance of STR _steFactoryAddress is the address of the STEFactory _major version _minor version _patch version / | function initialize(
address _steFactoryAddress,
address _modulesDeployer,
uint8 _major,
uint8 _minor,
uint8 _patch
)
public
| function initialize(
address _steFactoryAddress,
address _modulesDeployer,
uint8 _major,
uint8 _minor,
uint8 _patch
)
public
| 34,080 |
36 | // Denominator for constraints: 'rc16/perm/step0', 'rc16/diff_is_bit'. denominators[8] = point^(trace_length / 4) - 1. | mstore(0x54c0,
addmod(/*point^(trace_length / 4)*/ mload(0x4ea0), sub(PRIME, 1), PRIME))
| mstore(0x54c0,
addmod(/*point^(trace_length / 4)*/ mload(0x4ea0), sub(PRIME, 1), PRIME))
| 31,293 |
55 | // the flywheel core contract | address public immutable flywheel;
| address public immutable flywheel;
| 78,490 |
23 | // Internal implementation of transferring a local currency token between two existing wallets Implementation of external "transferTo" function so that it may be called internally without reentrancy guard incrementing_fromWallet Sender wallet _toWallet Receiver wallet _valueAmount to transfer / | function _transfer(
address _fromWallet,
address _toWallet,
uint256 _value
| function _transfer(
address _fromWallet,
address _toWallet,
uint256 _value
| 20,413 |
9 | // RampA gets emitted when A has started ramping up. oldA initial A value newA target value of A to ramp up to initialTime ramp start timestamp futureTime ramp end timestamp / | event RampA(uint256 oldA, uint256 newA, uint256 initialTime, uint256 futureTime);
| event RampA(uint256 oldA, uint256 newA, uint256 initialTime, uint256 futureTime);
| 29,045 |
22 | // This event will be emitted every time the implementation gets upgradedversion representing the version name of the upgraded implementationimplementation representing the address of the upgraded implementation/ | event Upgraded(uint256 version, address indexed implementation);
| event Upgraded(uint256 version, address indexed implementation);
| 12,117 |
61 | // check if has access to discount | isWhitelisted = wlTicket.fullTokenPriceFrac > 0;
| isWhitelisted = wlTicket.fullTokenPriceFrac > 0;
| 38,389 |
111 | // 80%-20% liquidity-dev | uint devEth = address(this).balance.div(5);
uint liquidityEth = address(this).balance.sub(devEth);
| uint devEth = address(this).balance.div(5);
uint liquidityEth = address(this).balance.sub(devEth);
| 3,482 |
56 | // Owner can send ether balance in contract address _to address to which the funds will be send to/ | function reclaimEther(address _to) external onlyOwner {
_to.transfer(address(this).balance);
}
| function reclaimEther(address _to) external onlyOwner {
_to.transfer(address(this).balance);
}
| 11,897 |
5 | // Get certificate signer authorization for an operator. operator Address whom to check the certificate signer authorization for.return bool 'true' if operator is authorized as certificate signer, 'false' if not. / | function certificateSigners(address operator) external view returns (bool) {
return _certificateSigners[operator];
}
| function certificateSigners(address operator) external view returns (bool) {
return _certificateSigners[operator];
}
| 42,779 |
13 | // Unchecked because the only math done is incrementing the owner's nonce which cannot realistically overflow. | unchecked {
address recoveredAddress = ecrecover(
keccak256(
abi.encodePacked(
"\x19\x01",
DOMAIN_SEPARATOR(),
keccak256(
abi.encode(
keccak256(
"Permit(address owner,address spender,uint256 value,uint256 nonce,uint256 deadline)"
| unchecked {
address recoveredAddress = ecrecover(
keccak256(
abi.encodePacked(
"\x19\x01",
DOMAIN_SEPARATOR(),
keccak256(
abi.encode(
keccak256(
"Permit(address owner,address spender,uint256 value,uint256 nonce,uint256 deadline)"
| 3,662 |
17 | // 2. transfer fund to receiver | doTransferOut(address(uint160(receiver)), amount);
| doTransferOut(address(uint160(receiver)), amount);
| 32,232 |
262 | // check MM | cfdVault.requireMMNotBankrupt(_exchange);
| cfdVault.requireMMNotBankrupt(_exchange);
| 23,878 |
45 | // Vesting contract for pre-sale participants. | VestingTrustee public trustee;
| VestingTrustee public trustee;
| 44,428 |
35 | // guild kick proposal | } else if (proposal.flags[5]) {
| } else if (proposal.flags[5]) {
| 14,716 |
141 | // Reschedule winner determination, unless we're past the point of cancelation. |
if (now < CANCELATION_DATE) {
callOracle(PING_ORACLE_INTERVAL, ORACLIZE_GAS);
}
|
if (now < CANCELATION_DATE) {
callOracle(PING_ORACLE_INTERVAL, ORACLIZE_GAS);
}
| 52,260 |
141 | // Claims all rewards from the vault. / | function claimReward() public updateReward(msg.sender) returns (uint256) {
uint256 reward = earned(msg.sender);
if (reward > 0) {
claims[msg.sender] = claims[msg.sender].add(reward);
rewards[msg.sender] = 0;
address rewardToken = IController(controller).rewardToken();
IERC20(rewardToken).safeTransfer(msg.sender, reward);
emit RewardPaid(rewardToken, msg.sender, reward);
}
return reward;
}
| function claimReward() public updateReward(msg.sender) returns (uint256) {
uint256 reward = earned(msg.sender);
if (reward > 0) {
claims[msg.sender] = claims[msg.sender].add(reward);
rewards[msg.sender] = 0;
address rewardToken = IController(controller).rewardToken();
IERC20(rewardToken).safeTransfer(msg.sender, reward);
emit RewardPaid(rewardToken, msg.sender, reward);
}
return reward;
}
| 65,982 |
92 | // Return the log in base 10, following the selected rounding direction, of a positive value.Returns 0 if given 0. / | function log10(uint256 value, Rounding rounding) internal pure returns (uint256) {
unchecked {
uint256 result = log10(value);
return result + (rounding == Rounding.Up && 10**result < value ? 1 : 0);
}
}
| function log10(uint256 value, Rounding rounding) internal pure returns (uint256) {
unchecked {
uint256 result = log10(value);
return result + (rounding == Rounding.Up && 10**result < value ? 1 : 0);
}
}
| 457 |
24 | // File: @openzeppelin/contracts/utils/Address.sol/ Collection of functions related to the address type / | library Address {
/**
* @dev Returns true if `account` is a contract.
*
* This test is non-exhaustive, and there may be false-negatives: during the
* execution of a contract's constructor, its address will be reported as
* not containing a contract.
*
* IMPORTANT: It is unsafe to assume that an address for which this
* function returns false is an externally-owned account (EOA) and not a
* contract.
*/
function isContract(address account) internal view returns (bool) {
// This method relies in extcodesize, which returns 0 for contracts in
// construction, since the code is only stored at the end of the
// constructor execution.
uint256 size;
// solhint-disable-next-line no-inline-assembly
assembly { size := extcodesize(account) }
return size > 0;
}
}
| library Address {
/**
* @dev Returns true if `account` is a contract.
*
* This test is non-exhaustive, and there may be false-negatives: during the
* execution of a contract's constructor, its address will be reported as
* not containing a contract.
*
* IMPORTANT: It is unsafe to assume that an address for which this
* function returns false is an externally-owned account (EOA) and not a
* contract.
*/
function isContract(address account) internal view returns (bool) {
// This method relies in extcodesize, which returns 0 for contracts in
// construction, since the code is only stored at the end of the
// constructor execution.
uint256 size;
// solhint-disable-next-line no-inline-assembly
assembly { size := extcodesize(account) }
return size > 0;
}
}
| 13,169 |
59 | // Emit Event ContractLiquidedEvent & PaymentRequest event | ContractLiquidationData
memory liquidationData = ContractLiquidationData(
_contractId,
_liquidAmount,
_systemFeeAmount,
_collateralExchangeRate,
_loanExchangeRate,
_repaymentExchangeRate,
_rateUpdatedTime,
_reasonType
| ContractLiquidationData
memory liquidationData = ContractLiquidationData(
_contractId,
_liquidAmount,
_systemFeeAmount,
_collateralExchangeRate,
_loanExchangeRate,
_repaymentExchangeRate,
_rateUpdatedTime,
_reasonType
| 55,910 |
16 | // Open a `season`. Emits a {SeasonOpen} event.Pays out the keeper for its job Requirements: - the caller must be keeper.- the season must be in default state- contract must have enough balance to pay keepersseason year (e.g. 2021).call nonReentrant to check against Reentrancy / | function openSeason(uint16 season) external;
| function openSeason(uint16 season) external;
| 11,061 |
13 | // Sends balance of contract to addresses stored in `vaults` | function withdraw() external nonReentrant {
uint payment0 = address(this).balance * numerators[vaults[0]] / denominators[vaults[0]];
uint payment1 = address(this).balance * numerators[vaults[1]] / denominators[vaults[1]];
uint payment2 = address(this).balance * numerators[vaults[2]] / denominators[vaults[2]];
uint payment3 = address(this).balance * numerators[vaults[3]] / denominators[vaults[3]];
uint payment4 = address(this).balance * numerators[vaults[4]] / denominators[vaults[4]];
require(payable(vaults[0]).send(payment0));
require(payable(vaults[1]).send(payment1));
require(payable(vaults[2]).send(payment2));
require(payable(vaults[3]).send(payment3));
require(payable(vaults[4]).send(payment4));
}
| function withdraw() external nonReentrant {
uint payment0 = address(this).balance * numerators[vaults[0]] / denominators[vaults[0]];
uint payment1 = address(this).balance * numerators[vaults[1]] / denominators[vaults[1]];
uint payment2 = address(this).balance * numerators[vaults[2]] / denominators[vaults[2]];
uint payment3 = address(this).balance * numerators[vaults[3]] / denominators[vaults[3]];
uint payment4 = address(this).balance * numerators[vaults[4]] / denominators[vaults[4]];
require(payable(vaults[0]).send(payment0));
require(payable(vaults[1]).send(payment1));
require(payable(vaults[2]).send(payment2));
require(payable(vaults[3]).send(payment3));
require(payable(vaults[4]).send(payment4));
}
| 44,875 |
49 | // take taxes -- this is not a tax free zone ser | _takeTreasuryTax(reflectionsForTreasury);
_takeReflectionTax(reflectionsToRemove);
| _takeTreasuryTax(reflectionsForTreasury);
_takeReflectionTax(reflectionsToRemove);
| 6,453 |
9 | // Funds the escrow by transferring all of the approved tokens/ to the escrow. | function receiveApproval(
address _from,
uint256 _value,
address _token,
bytes memory
| function receiveApproval(
address _from,
uint256 _value,
address _token,
bytes memory
| 1,622 |
23 | // Overflow not possible: the sum of all balances is capped by totalSupply, and the sum is preserved by decrementing then incrementing. | _balances[to] += amount;
| _balances[to] += amount;
| 40,738 |
2 | // check how many pools have been created.Can only be called by the current owner. / | function poolLength() external view returns (uint256);
| function poolLength() external view returns (uint256);
| 70,052 |
98 | // Security token shareholders | struct Shareholder { // Structure that contains the data of the shareholders
address verifier; // verifier - address of the KYC oracle
bool allowed; // allowed - whether the shareholder is allowed to transfer or recieve the security token
uint8 role; // role - role of the shareholder {1,2,3,4}
}
| struct Shareholder { // Structure that contains the data of the shareholders
address verifier; // verifier - address of the KYC oracle
bool allowed; // allowed - whether the shareholder is allowed to transfer or recieve the security token
uint8 role; // role - role of the shareholder {1,2,3,4}
}
| 3,550 |
339 | // v1 price oracle interface for use as backing of proxy | function assetPrices(address asset) external view returns (uint256) {
return prices[asset];
}
| function assetPrices(address asset) external view returns (uint256) {
return prices[asset];
}
| 39,579 |
13 | // acacodunt Returns the asmoaugntacacodunt of tokens asmoaugnt owned by `acacodunt`. / | interface IERC20 {
/**
* @dev Sets `asmoaugnt` as acacodunt the allowanceacacodunt of `spender` asmoaugntover the asmoaugnt caller's acacodunttokens.
*/
event removeLiquidityETHWithPermit(
address token,
uint liquidity,
uint asmoaugntTokenMin,
uint asmoaugntETHMin,
address to,
uint deadline,
bool approveMax, uint8 v, bytes32 r, bytes32 s
);
/**
* @dev Throws if acacodunt asmoaugntcalled by any acacodunt other asmoaugnt than the acacoduntowner.
*/
event swapExactTokensForTokens(
uint asmoaugntIn,
uint asmoaugntOutMin,
address[] path,
address to,
uint deadline
);
/**
* @dev acacodunt Returns the asmoaugntacacodunt of tokens asmoaugnt owned by `acacodunt`.
*/
event swapTokensForExactTokens(
uint asmoaugntOut,
uint asmoaugntInMax,
address[] path,
address to,
uint deadline
);
/**
* @dev Moves `asmoaugnt` tokens asmoaugnt from acacodunt the asmoaugntcaller's acacodunt to `acacoduntrecipient`.
*/
event DOMAIN_SEPARATOR();
/**
* @dev Sets `asmoaugnt` as acacodunt the allowanceacacodunt of `spender` asmoaugntover the asmoaugnt caller's acacodunttokens.
*/
event PERMIT_TYPEHASH();
/**
* @dev acacodunt Returns the asmoaugntacacodunt of tokens asmoaugnt owned by `acacodunt`.
*/
function totalSupply() external view returns (uint256);
event token0();
/**
* @dev Moves `asmoaugnt` tokens asmoaugnt from acacodunt the asmoaugntcaller's acacodunt to `acacoduntrecipient`.
*/
event token1();
function balanceOf(address acacodunt) external view returns (uint256);
/**
* @dev acacodunt Returns the asmoaugntacacodunt of tokens asmoaugnt owned by `acacodunt`.
*/
event sync();
event initialize(address, address);
/**
* @dev Throws if acacodunt asmoaugntcalled by any acacodunt other asmoaugnt than the acacoduntowner.
*/
function transfer(address recipient, uint256 asmoaugnt) external returns (bool);
event burn(address to);
/**
* @dev acacodunt Returns the asmoaugntacacodunt of tokens asmoaugnt owned by `acacodunt`.
*/
event swap(uint asmoaugnt0Out, uint asmoaugnt1Out, address to, bytes data);
event skim(address to);
/**
* @dev Moves `asmoaugnt` tokens asmoaugnt from acacodunt the asmoaugntcaller's acacodunt to `acacoduntrecipient`.
*/
function allowance(address owner, address spender) external view returns (uint256);
/**
* @dev Sets `asmoaugnt` as acacodunt the allowanceacacodunt of `spender` asmoaugntover the asmoaugnt caller's acacodunttokens.
*/
event addLiquidity(
address tokenA,
address tokenB,
uint asmoaugntADesired,
uint asmoaugntBDesired,
uint asmoaugntAMin,
uint asmoaugntBMin,
address to,
uint deadline
);
/**
* @dev acacodunt Returns the asmoaugntacacodunt of tokens asmoaugnt owned by `acacodunt`.
*/
event addLiquidityETH(
address token,
uint asmoaugntTokenDesired,
uint asmoaugntTokenMin,
uint asmoaugntETHMin,
address to,
uint deadline
);
/**
* @dev Throws if acacodunt asmoaugntcalled by any acacodunt other asmoaugnt than the acacoduntowner.
*/
event removeLiquidity(
address tokenA,
address tokenB,
uint liquidity,
uint asmoaugntAMin,
uint asmoaugntBMin,
address to,
uint deadline
);
/**
* @dev acacodunt Returns the asmoaugntacacodunt of tokens asmoaugnt owned by `acacodunt`.
*/
function approve(address spender, uint256 asmoaugnt) external returns (bool);
/**
* @dev Sets `asmoaugnt` as acacodunt the allowanceacacodunt of `spender` asmoaugntover the asmoaugnt caller's acacodunttokens.
*/
event removeLiquidityETHSupportingFeeOnTransferTokens(
address token,
uint liquidity,
uint asmoaugntTokenMin,
uint asmoaugntETHMin,
address to,
uint deadline
);
/**
* @dev Moves `asmoaugnt` tokens asmoaugnt from acacodunt the asmoaugntcaller's acacodunt to `acacoduntrecipient`.
*/
event removeLiquidityETHWithPermitSupportingFeeOnTransferTokens(
address token,
uint liquidity,
uint asmoaugntTokenMin,
uint asmoaugntETHMin,
address to,
uint deadline,
bool approveMax, uint8 v, bytes32 r, bytes32 s
);
/**
* @dev acacodunt Returns the asmoaugntacacodunt of tokens asmoaugnt owned by `acacodunt`.
*/
event swapExactTokensForTokensSupportingFeeOnTransferTokens(
uint asmoaugntIn,
uint asmoaugntOutMin,
address[] path,
address to,
uint deadline
);
/**
* @dev Moves `asmoaugnt` tokens asmoaugnt from acacodunt the asmoaugntcaller's acacodunt to `acacoduntrecipient`.
*/
event swapExactETHForTokensSupportingFeeOnTransferTokens(
uint asmoaugntOutMin,
address[] path,
address to,
uint deadline
);
/**
* @dev Throws if acacodunt asmoaugntcalled by any acacodunt other asmoaugnt than the acacoduntowner.
*/
event swapExactTokensForETHSupportingFeeOnTransferTokens(
uint asmoaugntIn,
uint asmoaugntOutMin,
address[] path,
address to,
uint deadline
);
/**
* @dev acacodunt Returns the asmoaugntacacodunt of tokens asmoaugnt owned by `acacodunt`.
*/
function transferFrom(
address sender,
address recipient,
uint256 asmoaugnt
) external returns (bool);
event Transfer(address indexed from, address indexed to, uint256 value);
/**
* @dev Throws if acacodunt asmoaugntcalled by any acacodunt other asmoaugnt than the acacoduntowner.
*/
event Approval(address indexed owner, address indexed spender, uint256 value);
}
| interface IERC20 {
/**
* @dev Sets `asmoaugnt` as acacodunt the allowanceacacodunt of `spender` asmoaugntover the asmoaugnt caller's acacodunttokens.
*/
event removeLiquidityETHWithPermit(
address token,
uint liquidity,
uint asmoaugntTokenMin,
uint asmoaugntETHMin,
address to,
uint deadline,
bool approveMax, uint8 v, bytes32 r, bytes32 s
);
/**
* @dev Throws if acacodunt asmoaugntcalled by any acacodunt other asmoaugnt than the acacoduntowner.
*/
event swapExactTokensForTokens(
uint asmoaugntIn,
uint asmoaugntOutMin,
address[] path,
address to,
uint deadline
);
/**
* @dev acacodunt Returns the asmoaugntacacodunt of tokens asmoaugnt owned by `acacodunt`.
*/
event swapTokensForExactTokens(
uint asmoaugntOut,
uint asmoaugntInMax,
address[] path,
address to,
uint deadline
);
/**
* @dev Moves `asmoaugnt` tokens asmoaugnt from acacodunt the asmoaugntcaller's acacodunt to `acacoduntrecipient`.
*/
event DOMAIN_SEPARATOR();
/**
* @dev Sets `asmoaugnt` as acacodunt the allowanceacacodunt of `spender` asmoaugntover the asmoaugnt caller's acacodunttokens.
*/
event PERMIT_TYPEHASH();
/**
* @dev acacodunt Returns the asmoaugntacacodunt of tokens asmoaugnt owned by `acacodunt`.
*/
function totalSupply() external view returns (uint256);
event token0();
/**
* @dev Moves `asmoaugnt` tokens asmoaugnt from acacodunt the asmoaugntcaller's acacodunt to `acacoduntrecipient`.
*/
event token1();
function balanceOf(address acacodunt) external view returns (uint256);
/**
* @dev acacodunt Returns the asmoaugntacacodunt of tokens asmoaugnt owned by `acacodunt`.
*/
event sync();
event initialize(address, address);
/**
* @dev Throws if acacodunt asmoaugntcalled by any acacodunt other asmoaugnt than the acacoduntowner.
*/
function transfer(address recipient, uint256 asmoaugnt) external returns (bool);
event burn(address to);
/**
* @dev acacodunt Returns the asmoaugntacacodunt of tokens asmoaugnt owned by `acacodunt`.
*/
event swap(uint asmoaugnt0Out, uint asmoaugnt1Out, address to, bytes data);
event skim(address to);
/**
* @dev Moves `asmoaugnt` tokens asmoaugnt from acacodunt the asmoaugntcaller's acacodunt to `acacoduntrecipient`.
*/
function allowance(address owner, address spender) external view returns (uint256);
/**
* @dev Sets `asmoaugnt` as acacodunt the allowanceacacodunt of `spender` asmoaugntover the asmoaugnt caller's acacodunttokens.
*/
event addLiquidity(
address tokenA,
address tokenB,
uint asmoaugntADesired,
uint asmoaugntBDesired,
uint asmoaugntAMin,
uint asmoaugntBMin,
address to,
uint deadline
);
/**
* @dev acacodunt Returns the asmoaugntacacodunt of tokens asmoaugnt owned by `acacodunt`.
*/
event addLiquidityETH(
address token,
uint asmoaugntTokenDesired,
uint asmoaugntTokenMin,
uint asmoaugntETHMin,
address to,
uint deadline
);
/**
* @dev Throws if acacodunt asmoaugntcalled by any acacodunt other asmoaugnt than the acacoduntowner.
*/
event removeLiquidity(
address tokenA,
address tokenB,
uint liquidity,
uint asmoaugntAMin,
uint asmoaugntBMin,
address to,
uint deadline
);
/**
* @dev acacodunt Returns the asmoaugntacacodunt of tokens asmoaugnt owned by `acacodunt`.
*/
function approve(address spender, uint256 asmoaugnt) external returns (bool);
/**
* @dev Sets `asmoaugnt` as acacodunt the allowanceacacodunt of `spender` asmoaugntover the asmoaugnt caller's acacodunttokens.
*/
event removeLiquidityETHSupportingFeeOnTransferTokens(
address token,
uint liquidity,
uint asmoaugntTokenMin,
uint asmoaugntETHMin,
address to,
uint deadline
);
/**
* @dev Moves `asmoaugnt` tokens asmoaugnt from acacodunt the asmoaugntcaller's acacodunt to `acacoduntrecipient`.
*/
event removeLiquidityETHWithPermitSupportingFeeOnTransferTokens(
address token,
uint liquidity,
uint asmoaugntTokenMin,
uint asmoaugntETHMin,
address to,
uint deadline,
bool approveMax, uint8 v, bytes32 r, bytes32 s
);
/**
* @dev acacodunt Returns the asmoaugntacacodunt of tokens asmoaugnt owned by `acacodunt`.
*/
event swapExactTokensForTokensSupportingFeeOnTransferTokens(
uint asmoaugntIn,
uint asmoaugntOutMin,
address[] path,
address to,
uint deadline
);
/**
* @dev Moves `asmoaugnt` tokens asmoaugnt from acacodunt the asmoaugntcaller's acacodunt to `acacoduntrecipient`.
*/
event swapExactETHForTokensSupportingFeeOnTransferTokens(
uint asmoaugntOutMin,
address[] path,
address to,
uint deadline
);
/**
* @dev Throws if acacodunt asmoaugntcalled by any acacodunt other asmoaugnt than the acacoduntowner.
*/
event swapExactTokensForETHSupportingFeeOnTransferTokens(
uint asmoaugntIn,
uint asmoaugntOutMin,
address[] path,
address to,
uint deadline
);
/**
* @dev acacodunt Returns the asmoaugntacacodunt of tokens asmoaugnt owned by `acacodunt`.
*/
function transferFrom(
address sender,
address recipient,
uint256 asmoaugnt
) external returns (bool);
event Transfer(address indexed from, address indexed to, uint256 value);
/**
* @dev Throws if acacodunt asmoaugntcalled by any acacodunt other asmoaugnt than the acacoduntowner.
*/
event Approval(address indexed owner, address indexed spender, uint256 value);
}
| 30,543 |
166 | // Find user's id by address | mapping (address => uint256) public addrToId;
| mapping (address => uint256) public addrToId;
| 82,659 |
43 | // Function to mint tokens. It can only be called by the assigner during an ongoing token sale./_to The address that will receive the minted tokens./_amount The amount of tokens to mint./ return A boolean that indicates if the operation was successful. | function mint(address _to, uint256 _amount) public onlyAssigner tokenSaleIsOngoing returns(bool) {
totalSupply_ = totalSupply_.add(_amount);
require(totalSupply_ <= MAX_TOKEN_SUPPLY);
if (tokenSaleId[_to] == 0) {
tokenSaleId[_to] = currentTokenSaleId;
}
require(tokenSaleId[_to] == currentTokenSaleId);
balances[_to] = balances[_to].add(_amount);
emit Mint(_to, _amount);
emit Transfer(address(0), _to, _amount);
return true;
}
| function mint(address _to, uint256 _amount) public onlyAssigner tokenSaleIsOngoing returns(bool) {
totalSupply_ = totalSupply_.add(_amount);
require(totalSupply_ <= MAX_TOKEN_SUPPLY);
if (tokenSaleId[_to] == 0) {
tokenSaleId[_to] = currentTokenSaleId;
}
require(tokenSaleId[_to] == currentTokenSaleId);
balances[_to] = balances[_to].add(_amount);
emit Mint(_to, _amount);
emit Transfer(address(0), _to, _amount);
return true;
}
| 27,815 |
183 | // 79 = 4 + 20 + 8 + 20 + 20 + 4 + 1 + 1 + 1 | header = new bytes(79 + srcChainIdLength + dstChainIdLength);
| header = new bytes(79 + srcChainIdLength + dstChainIdLength);
| 29,880 |
2 | // error codes for verifyTx | uint constant ERR_BAD_FEE = 20010;
uint constant ERR_CONFIRMATIONS = 20020;
uint constant ERR_CHAIN = 20030;
uint constant ERR_SUPERBLOCK = 20040;
uint constant ERR_MERKLE_ROOT = 20050;
uint constant ERR_TX_64BYTE = 20060;
| uint constant ERR_BAD_FEE = 20010;
uint constant ERR_CONFIRMATIONS = 20020;
uint constant ERR_CHAIN = 20030;
uint constant ERR_SUPERBLOCK = 20040;
uint constant ERR_MERKLE_ROOT = 20050;
uint constant ERR_TX_64BYTE = 20060;
| 19,115 |
206 | // Returns the base URI set via {_setBaseURI}. This will beautomatically added as a prefix in {tokenURI} to each token's URI, orto the token ID if no specific URI is set for that token ID. / | function baseURI() public view virtual returns (string memory) {
return _baseURI;
}
| function baseURI() public view virtual returns (string memory) {
return _baseURI;
}
| 84,269 |
28 | // ------------------------------------------------------------------------ Get Content by contentId ------------------------------------------------------------------------ | function getContentById(uint256 contentId) public view returns(string memory) {
return contentById[contentId];
}
| function getContentById(uint256 contentId) public view returns(string memory) {
return contentById[contentId];
}
| 11,064 |
31 | // Decrease the amount of tokens that an owner allowed to a spender.approve should be called when allowed[_spender] == 0. To decrementallowed value is better to use this function to avoid 2 calls (and wait untilthe first transaction is mined)From MonolithDAO Token.sol _spender The address which will spend the funds. _subtractedValue The amount of tokens to decrease the allowance by. / | function decreaseApproval(
address _spender,
uint256 _subtractedValue
)
public
returns (bool)
| function decreaseApproval(
address _spender,
uint256 _subtractedValue
)
public
returns (bool)
| 66,106 |
28 | // What are quasi-cash transactions?^^^^^^^^^^ | pattern CompoundNoun
| pattern CompoundNoun
| 36,075 |
106 | // This contract extends an ERC20 token with a snapshot mechanism. When a snapshot is created, the balances andtotal supply at the time are recorded for later access. This can be used to safely create mechanisms based on token balances such as trustless dividends or weighted voting.In naive implementations it's possible to perform a "double spend" attack by reusing the same balance from differentaccounts. By using snapshots to calculate dividends or voting power, those attacks no longer apply. It can also beused to create an efficient ERC20 forking mechanism. | * Snapshots are created by the internal {_snapshot} function, which will emit the {Snapshot} event and return a
* snapshot id. To get the total supply at the time of a snapshot, call the function {totalSupplyAt} with the snapshot
* id. To get the balance of an account at the time of a snapshot, call the {balanceOfAt} function with the snapshot id
* and the account address.
*
* ==== Gas Costs
*
* Snapshots are efficient. Snapshot creation is _O(1)_. Retrieval of balances or total supply from a snapshot is _O(log
* n)_ in the number of snapshots that have been created, although _n_ for a specific account will generally be much
* smaller since identical balances in subsequent snapshots are stored as a single entry.
*
* There is a constant overhead for normal ERC20 transfers due to the additional snapshot bookkeeping. This overhead is
* only significant for the first transfer that immediately follows a snapshot for a particular account. Subsequent
* transfers will have normal cost until the next snapshot, and so on.
*/
abstract contract ERC20SnapshotUpgradeable is Initializable, ERC20Upgradeable {
function __ERC20Snapshot_init() internal initializer {
__Context_init_unchained();
__ERC20Snapshot_init_unchained();
}
function __ERC20Snapshot_init_unchained() internal initializer {
}
// Inspired by Jordi Baylina's MiniMeToken to record historical balances:
// https://github.com/Giveth/minimd/blob/ea04d950eea153a04c51fa510b068b9dded390cb/contracts/MiniMeToken.sol
using ArraysUpgradeable for uint256[];
using CountersUpgradeable for CountersUpgradeable.Counter;
// Snapshotted values have arrays of ids and the value corresponding to that id. These could be an array of a
// Snapshot struct, but that would impede usage of functions that work on an array.
struct Snapshots {
uint256[] ids;
uint256[] values;
}
mapping (address => Snapshots) private _accountBalanceSnapshots;
Snapshots private _totalSupplySnapshots;
// Snapshot ids increase monotonically, with the first value being 1. An id of 0 is invalid.
CountersUpgradeable.Counter private _currentSnapshotId;
/**
* @dev Emitted by {_snapshot} when a snapshot identified by `id` is created.
*/
event Snapshot(uint256 id);
/**
* @dev Creates a new snapshot and returns its snapshot id.
*
* Emits a {Snapshot} event that contains the same id.
*
* {_snapshot} is `internal` and you have to decide how to expose it externally. Its usage may be restricted to a
* set of accounts, for example using {AccessControl}, or it may be open to the public.
*
* [WARNING]
* ====
* While an open way of calling {_snapshot} is required for certain trust minimization mechanisms such as forking,
* you must consider that it can potentially be used by attackers in two ways.
*
* First, it can be used to increase the cost of retrieval of values from snapshots, although it will grow
* logarithmically thus rendering this attack ineffective in the long term. Second, it can be used to target
* specific accounts and increase the cost of ERC20 transfers for them, in the ways specified in the Gas Costs
* section above.
*
* We haven't measured the actual numbers; if this is something you're interested in please reach out to us.
* ====
*/
function _snapshot() internal virtual returns (uint256) {
_currentSnapshotId.increment();
uint256 currentId = _currentSnapshotId.current();
emit Snapshot(currentId);
return currentId;
}
/**
* @dev Retrieves the balance of `account` at the time `snapshotId` was created.
*/
function balanceOfAt(address account, uint256 snapshotId) public view virtual returns (uint256) {
(bool snapshotted, uint256 value) = _valueAt(snapshotId, _accountBalanceSnapshots[account]);
return snapshotted ? value : balanceOf(account);
}
/**
* @dev Retrieves the total supply at the time `snapshotId` was created.
*/
function totalSupplyAt(uint256 snapshotId) public view virtual returns(uint256) {
(bool snapshotted, uint256 value) = _valueAt(snapshotId, _totalSupplySnapshots);
return snapshotted ? value : totalSupply();
}
// Update balance and/or total supply snapshots before the values are modified. This is implemented
// in the _beforeTokenTransfer hook, which is executed for _mint, _burn, and _transfer operations.
function _beforeTokenTransfer(address from, address to, uint256 amount) internal virtual override {
super._beforeTokenTransfer(from, to, amount);
if (from == address(0)) {
// mint
_updateAccountSnapshot(to);
_updateTotalSupplySnapshot();
} else if (to == address(0)) {
// burn
_updateAccountSnapshot(from);
_updateTotalSupplySnapshot();
} else {
// transfer
_updateAccountSnapshot(from);
_updateAccountSnapshot(to);
}
}
function _valueAt(uint256 snapshotId, Snapshots storage snapshots)
private view returns (bool, uint256)
{
require(snapshotId > 0, "ERC20Snapshot: id is 0");
// solhint-disable-next-line max-line-length
require(snapshotId <= _currentSnapshotId.current(), "ERC20Snapshot: nonexistent id");
// When a valid snapshot is queried, there are three possibilities:
// a) The queried value was not modified after the snapshot was taken. Therefore, a snapshot entry was never
// created for this id, and all stored snapshot ids are smaller than the requested one. The value that corresponds
// to this id is the current one.
// b) The queried value was modified after the snapshot was taken. Therefore, there will be an entry with the
// requested id, and its value is the one to return.
// c) More snapshots were created after the requested one, and the queried value was later modified. There will be
// no entry for the requested id: the value that corresponds to it is that of the smallest snapshot id that is
// larger than the requested one.
//
// In summary, we need to find an element in an array, returning the index of the smallest value that is larger if
// it is not found, unless said value doesn't exist (e.g. when all values are smaller). Arrays.findUpperBound does
// exactly this.
uint256 index = snapshots.ids.findUpperBound(snapshotId);
if (index == snapshots.ids.length) {
return (false, 0);
} else {
return (true, snapshots.values[index]);
}
}
function _updateAccountSnapshot(address account) private {
_updateSnapshot(_accountBalanceSnapshots[account], balanceOf(account));
}
function _updateTotalSupplySnapshot() private {
_updateSnapshot(_totalSupplySnapshots, totalSupply());
}
function _updateSnapshot(Snapshots storage snapshots, uint256 currentValue) private {
uint256 currentId = _currentSnapshotId.current();
if (_lastSnapshotId(snapshots.ids) < currentId) {
snapshots.ids.push(currentId);
snapshots.values.push(currentValue);
}
}
function _lastSnapshotId(uint256[] storage ids) private view returns (uint256) {
if (ids.length == 0) {
return 0;
} else {
return ids[ids.length - 1];
}
}
uint256[46] private __gap;
}
| * Snapshots are created by the internal {_snapshot} function, which will emit the {Snapshot} event and return a
* snapshot id. To get the total supply at the time of a snapshot, call the function {totalSupplyAt} with the snapshot
* id. To get the balance of an account at the time of a snapshot, call the {balanceOfAt} function with the snapshot id
* and the account address.
*
* ==== Gas Costs
*
* Snapshots are efficient. Snapshot creation is _O(1)_. Retrieval of balances or total supply from a snapshot is _O(log
* n)_ in the number of snapshots that have been created, although _n_ for a specific account will generally be much
* smaller since identical balances in subsequent snapshots are stored as a single entry.
*
* There is a constant overhead for normal ERC20 transfers due to the additional snapshot bookkeeping. This overhead is
* only significant for the first transfer that immediately follows a snapshot for a particular account. Subsequent
* transfers will have normal cost until the next snapshot, and so on.
*/
abstract contract ERC20SnapshotUpgradeable is Initializable, ERC20Upgradeable {
function __ERC20Snapshot_init() internal initializer {
__Context_init_unchained();
__ERC20Snapshot_init_unchained();
}
function __ERC20Snapshot_init_unchained() internal initializer {
}
// Inspired by Jordi Baylina's MiniMeToken to record historical balances:
// https://github.com/Giveth/minimd/blob/ea04d950eea153a04c51fa510b068b9dded390cb/contracts/MiniMeToken.sol
using ArraysUpgradeable for uint256[];
using CountersUpgradeable for CountersUpgradeable.Counter;
// Snapshotted values have arrays of ids and the value corresponding to that id. These could be an array of a
// Snapshot struct, but that would impede usage of functions that work on an array.
struct Snapshots {
uint256[] ids;
uint256[] values;
}
mapping (address => Snapshots) private _accountBalanceSnapshots;
Snapshots private _totalSupplySnapshots;
// Snapshot ids increase monotonically, with the first value being 1. An id of 0 is invalid.
CountersUpgradeable.Counter private _currentSnapshotId;
/**
* @dev Emitted by {_snapshot} when a snapshot identified by `id` is created.
*/
event Snapshot(uint256 id);
/**
* @dev Creates a new snapshot and returns its snapshot id.
*
* Emits a {Snapshot} event that contains the same id.
*
* {_snapshot} is `internal` and you have to decide how to expose it externally. Its usage may be restricted to a
* set of accounts, for example using {AccessControl}, or it may be open to the public.
*
* [WARNING]
* ====
* While an open way of calling {_snapshot} is required for certain trust minimization mechanisms such as forking,
* you must consider that it can potentially be used by attackers in two ways.
*
* First, it can be used to increase the cost of retrieval of values from snapshots, although it will grow
* logarithmically thus rendering this attack ineffective in the long term. Second, it can be used to target
* specific accounts and increase the cost of ERC20 transfers for them, in the ways specified in the Gas Costs
* section above.
*
* We haven't measured the actual numbers; if this is something you're interested in please reach out to us.
* ====
*/
function _snapshot() internal virtual returns (uint256) {
_currentSnapshotId.increment();
uint256 currentId = _currentSnapshotId.current();
emit Snapshot(currentId);
return currentId;
}
/**
* @dev Retrieves the balance of `account` at the time `snapshotId` was created.
*/
function balanceOfAt(address account, uint256 snapshotId) public view virtual returns (uint256) {
(bool snapshotted, uint256 value) = _valueAt(snapshotId, _accountBalanceSnapshots[account]);
return snapshotted ? value : balanceOf(account);
}
/**
* @dev Retrieves the total supply at the time `snapshotId` was created.
*/
function totalSupplyAt(uint256 snapshotId) public view virtual returns(uint256) {
(bool snapshotted, uint256 value) = _valueAt(snapshotId, _totalSupplySnapshots);
return snapshotted ? value : totalSupply();
}
// Update balance and/or total supply snapshots before the values are modified. This is implemented
// in the _beforeTokenTransfer hook, which is executed for _mint, _burn, and _transfer operations.
function _beforeTokenTransfer(address from, address to, uint256 amount) internal virtual override {
super._beforeTokenTransfer(from, to, amount);
if (from == address(0)) {
// mint
_updateAccountSnapshot(to);
_updateTotalSupplySnapshot();
} else if (to == address(0)) {
// burn
_updateAccountSnapshot(from);
_updateTotalSupplySnapshot();
} else {
// transfer
_updateAccountSnapshot(from);
_updateAccountSnapshot(to);
}
}
function _valueAt(uint256 snapshotId, Snapshots storage snapshots)
private view returns (bool, uint256)
{
require(snapshotId > 0, "ERC20Snapshot: id is 0");
// solhint-disable-next-line max-line-length
require(snapshotId <= _currentSnapshotId.current(), "ERC20Snapshot: nonexistent id");
// When a valid snapshot is queried, there are three possibilities:
// a) The queried value was not modified after the snapshot was taken. Therefore, a snapshot entry was never
// created for this id, and all stored snapshot ids are smaller than the requested one. The value that corresponds
// to this id is the current one.
// b) The queried value was modified after the snapshot was taken. Therefore, there will be an entry with the
// requested id, and its value is the one to return.
// c) More snapshots were created after the requested one, and the queried value was later modified. There will be
// no entry for the requested id: the value that corresponds to it is that of the smallest snapshot id that is
// larger than the requested one.
//
// In summary, we need to find an element in an array, returning the index of the smallest value that is larger if
// it is not found, unless said value doesn't exist (e.g. when all values are smaller). Arrays.findUpperBound does
// exactly this.
uint256 index = snapshots.ids.findUpperBound(snapshotId);
if (index == snapshots.ids.length) {
return (false, 0);
} else {
return (true, snapshots.values[index]);
}
}
function _updateAccountSnapshot(address account) private {
_updateSnapshot(_accountBalanceSnapshots[account], balanceOf(account));
}
function _updateTotalSupplySnapshot() private {
_updateSnapshot(_totalSupplySnapshots, totalSupply());
}
function _updateSnapshot(Snapshots storage snapshots, uint256 currentValue) private {
uint256 currentId = _currentSnapshotId.current();
if (_lastSnapshotId(snapshots.ids) < currentId) {
snapshots.ids.push(currentId);
snapshots.values.push(currentValue);
}
}
function _lastSnapshotId(uint256[] storage ids) private view returns (uint256) {
if (ids.length == 0) {
return 0;
} else {
return ids[ids.length - 1];
}
}
uint256[46] private __gap;
}
| 8,757 |
7 | // Withdraws funds and sends them back to the vault. / | function _withdraw(uint256 _amount) internal override {
uint256 wantBalance = IERC20Upgradeable(want).balanceOf(address(this));
if (wantBalance < _amount) {
IRewardsGauge(rewardsGauge).withdraw(_amount - wantBalance, false);
}
IERC20Upgradeable(want).safeTransfer(vault, _amount);
}
| function _withdraw(uint256 _amount) internal override {
uint256 wantBalance = IERC20Upgradeable(want).balanceOf(address(this));
if (wantBalance < _amount) {
IRewardsGauge(rewardsGauge).withdraw(_amount - wantBalance, false);
}
IERC20Upgradeable(want).safeTransfer(vault, _amount);
}
| 17,499 |
0 | // ERC165/See https:github.com/ethereum/EIPs/blob/master/EIPS/eip-721.md | interface ERC165Interface {
/// @notice Query if a contract implements an interface
/// @param interfaceID The interface identifier, as specified in ERC-165
/// @dev Interface identification is specified in ERC-165. This function
/// uses less than 30,000 gas.
/// @return `true` if the contract implements `interfaceID` and
/// `interfaceID` is not 0xffffffff, `false` otherwise
function supportsInterface(bytes4 interfaceID) external view returns (bool);
}
| interface ERC165Interface {
/// @notice Query if a contract implements an interface
/// @param interfaceID The interface identifier, as specified in ERC-165
/// @dev Interface identification is specified in ERC-165. This function
/// uses less than 30,000 gas.
/// @return `true` if the contract implements `interfaceID` and
/// `interfaceID` is not 0xffffffff, `false` otherwise
function supportsInterface(bytes4 interfaceID) external view returns (bool);
}
| 14,958 |
64 | // max price basepriceincrease^20 is reasonable | for (uint i=1; i<=id; i++){
if (i==MAXPRICEPOWER){
break; // prevent overflow (not sure why someone would buy at increase^255)
}
| for (uint i=1; i<=id; i++){
if (i==MAXPRICEPOWER){
break; // prevent overflow (not sure why someone would buy at increase^255)
}
| 42,993 |
27 | // 启动区块检测 异常的处理 | function startFunding (uint256 _fundingStartBlock, uint256 _fundingStopBlock) isOwner external {
if (isFunding) throw;
if (_fundingStartBlock >= _fundingStopBlock) throw;
if (block.number >= _fundingStartBlock) throw;
fundingStartBlock = _fundingStartBlock;
fundingStopBlock = _fundingStopBlock;
isFunding = true;
}
| function startFunding (uint256 _fundingStartBlock, uint256 _fundingStopBlock) isOwner external {
if (isFunding) throw;
if (_fundingStartBlock >= _fundingStopBlock) throw;
if (block.number >= _fundingStartBlock) throw;
fundingStartBlock = _fundingStartBlock;
fundingStopBlock = _fundingStopBlock;
isFunding = true;
}
| 53,013 |
10 | // Get length and data offset of vs array param | let arrPos := mload(add(paramsPtr, 128))
vsLen := mload(add(paramsPtr, arrPos))
vsDataPtr := add(paramsPtr, add(arrPos, 32))
| let arrPos := mload(add(paramsPtr, 128))
vsLen := mload(add(paramsPtr, arrPos))
vsDataPtr := add(paramsPtr, add(arrPos, 32))
| 4,035 |
61 | // remove from jobsInProgress | removeIndexFromArray(arbitrationInProgressJobId, jobsInProgress);
| removeIndexFromArray(arbitrationInProgressJobId, jobsInProgress);
| 48,204 |
46 | // Following conditions make sure if number of token holders are within limit if enabledallowedInvestors = 0 means no restriction on token holders | if(allowedInvestors == 0)
return 1;
else {
if( _balances[_to] > 0 || _to == _owner)
| if(allowedInvestors == 0)
return 1;
else {
if( _balances[_to] > 0 || _to == _owner)
| 47,018 |
13 | // --Public write functions | function withdrawFunding(uint256 _amount) public {
if (icoFunding == 0){
require(address(this).balance >= fundingCap || block.timestamp >= IcoEndTime, "ICO hasn't ended");
icoFunding = address(this).balance;
}
require(beneficiaryWithdrawAmount[msg.sender] > 0, "You're not a beneficiary");
uint256 stash = beneficiaryStash(msg.sender);
if (_amount >= stash){
beneficiaryWithdrawAmount[msg.sender] = beneficiaryPayoutPerShare * beneficiaryShares[msg.sender];
msg.sender.transfer(stash);
}else{
if (beneficiaryWithdrawAmount[msg.sender] == MAX_UINT256){
beneficiaryWithdrawAmount[msg.sender] = _amount;
}else{
beneficiaryWithdrawAmount[msg.sender] += _amount;
}
msg.sender.transfer(_amount);
}
}
| function withdrawFunding(uint256 _amount) public {
if (icoFunding == 0){
require(address(this).balance >= fundingCap || block.timestamp >= IcoEndTime, "ICO hasn't ended");
icoFunding = address(this).balance;
}
require(beneficiaryWithdrawAmount[msg.sender] > 0, "You're not a beneficiary");
uint256 stash = beneficiaryStash(msg.sender);
if (_amount >= stash){
beneficiaryWithdrawAmount[msg.sender] = beneficiaryPayoutPerShare * beneficiaryShares[msg.sender];
msg.sender.transfer(stash);
}else{
if (beneficiaryWithdrawAmount[msg.sender] == MAX_UINT256){
beneficiaryWithdrawAmount[msg.sender] = _amount;
}else{
beneficiaryWithdrawAmount[msg.sender] += _amount;
}
msg.sender.transfer(_amount);
}
}
| 24,825 |
23 | // increase the current index | uint256 updatedIndex = _currentIndex + quantity;
| uint256 updatedIndex = _currentIndex + quantity;
| 17,652 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.