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 |
|---|---|---|---|---|
54 | // Withdraw from CA to owner | function withdraw(uint256 _amount) external payable onlyOwner {
require(_amount > 0 && _amount <= address(this).balance );
owner.transfer(_amount);
emit Withdraw(owner, _amount);
}
| function withdraw(uint256 _amount) external payable onlyOwner {
require(_amount > 0 && _amount <= address(this).balance );
owner.transfer(_amount);
emit Withdraw(owner, _amount);
}
| 11,806 |
54 | // TODO - attributes.removeAll(...) TODO - GAS COST IF THERE ARE LOTS OF ATTRIBUTES | _burn(msg.sender, tokenId);
Attributes.Data storage attributes = attributesByTokenIds[tokenId];
if (attributes.initialised) {
attributes.removeAll(tokenId);
delete attributesByTokenIds[tokenId];
}
| _burn(msg.sender, tokenId);
Attributes.Data storage attributes = attributesByTokenIds[tokenId];
if (attributes.initialised) {
attributes.removeAll(tokenId);
delete attributesByTokenIds[tokenId];
}
| 46,852 |
0 | // initiate token | MLVERC20 public _MLVERC20;
| MLVERC20 public _MLVERC20;
| 1,867 |
6 | // 受け取ったIDとハッシュ化したデータが一致しない場合はエラー | require(
signature == ISignature(_signature).hashingId(userId),
"signatures do not match"
);
| require(
signature == ISignature(_signature).hashingId(userId),
"signatures do not match"
);
| 7,503 |
1 | // Emitted when a new NFTDropCollection is created from this factory. collection The address of the new NFT drop collection contract. creator The address of the creator which owns the new collection. approvedMinter An optional address to grant the MINTER_ROLE. name The collection's `name`. symbol The collection's `symbol`. baseURI The base URI for the collection. isRevealed Whether the collection is revealed or not. maxTokenId The max `tokenID` for this collection. paymentAddress The address that will receive royalties and mint payments. version The implementation version used by the new NFTDropCollection collection. nonce The nonce used by the creator to create this collection. | event NFTDropCollectionCreated(
address indexed collection,
address indexed creator,
address indexed approvedMinter,
string name,
string symbol,
string baseURI,
bool isRevealed,
uint256 maxTokenId,
address paymentAddress,
| event NFTDropCollectionCreated(
address indexed collection,
address indexed creator,
address indexed approvedMinter,
string name,
string symbol,
string baseURI,
bool isRevealed,
uint256 maxTokenId,
address paymentAddress,
| 20,114 |
1 | // if user exists, add _val | if (arrayStructs[msg.sender].exists ) {
arrayStructs[msg.sender].value += _val;
}
| if (arrayStructs[msg.sender].exists ) {
arrayStructs[msg.sender].value += _val;
}
| 53,159 |
19 | // Funcion para ver los alumnos que han solicitado revision de examen | function VerRevisiones(string memory _asignatura) public view UnicamenteProfesor(msg.sender) returns (string [] memory){
// Devolver las identidades de los alumnos
return revisiones[_asignatura];
}
| function VerRevisiones(string memory _asignatura) public view UnicamenteProfesor(msg.sender) returns (string [] memory){
// Devolver las identidades de los alumnos
return revisiones[_asignatura];
}
| 22,890 |
22 | // This is the only function that can be called by user's of the system and uses an enum and struct to parse the args. This structure guarantees the state machine will always meet certain propertiesoperation An enum of the operation to execute params Parameters to exceute the operation against / | function operateAction(
Operation operation,
OperationParams memory params
)
public
| function operateAction(
Operation operation,
OperationParams memory params
)
public
| 49,859 |
154 | // conversion between 2 reserves | return getCrossReserveReturn(_fromToken, _toToken, _amount);
| return getCrossReserveReturn(_fromToken, _toToken, _amount);
| 14,694 |
90 | // performs no bounds check, just a raw extcodecopy on the pointer/ return addr the address at the given pointer (may include 0 bytes if reading past the end of the pointer) | function SSTORE2_readRawAddress(address pointer, uint256 start) internal view returns (address addr) {
| function SSTORE2_readRawAddress(address pointer, uint256 start) internal view returns (address addr) {
| 26,322 |
62 | // Gets the list of guaridans for a wallet. _wallet The target wallet.return the list of guardians. / | function getGuardians(BaseWallet _wallet) external view returns (address[] memory) {
GuardianStorageConfig storage config = configs[address(_wallet)];
address[] memory guardians = new address[](config.guardians.length);
for (uint256 i = 0; i < config.guardians.length; i++) {
guardians[i] = config.guardians[i];
}
return guardians;
}
| function getGuardians(BaseWallet _wallet) external view returns (address[] memory) {
GuardianStorageConfig storage config = configs[address(_wallet)];
address[] memory guardians = new address[](config.guardians.length);
for (uint256 i = 0; i < config.guardians.length; i++) {
guardians[i] = config.guardians[i];
}
return guardians;
}
| 27,445 |
46 | // is crowdsale updatable | bool public isUpdatable;
| bool public isUpdatable;
| 45,881 |
4 | // Returns the expiration timestamp of the specified label hash. | function nameExpires(uint256 id) external view returns (uint256);
| function nameExpires(uint256 id) external view returns (uint256);
| 26,960 |
43 | // Allow to reimburse if funding was unsuccessful for this answer option. | sum += round.contributions[_beneficiary][_contributedTo];
| sum += round.contributions[_beneficiary][_contributedTo];
| 13,007 |
8 | // Calculates the premium of the provided option using Black-Scholes in stables st is the strike price of the option expiryTimestamp is the unix timestamp of expiry isPut is whether the option is a put optionreturn premium for 100 contracts with 18 decimals / | function getPremiumInStables(
uint256 st,
uint256 expiryTimestamp,
bool isPut
| function getPremiumInStables(
uint256 st,
uint256 expiryTimestamp,
bool isPut
| 63,111 |
230 | // Emits a {Transfer} event with `to` set to the zero address. Requirements: - `src` must have at least `wad` tokens. // if_succeeds {:msg "Burn - balance underflow"} old(_balanceOf[src]) <= _balanceOf[src];/ if_succeeds {:msg "Burn - supply underflow"} old(_totalSupply) <= _totalSupply; | function _burn(address src, uint wad) internal virtual returns (bool) {
unchecked {
require(_balanceOf[src] >= wad, "ERC20: Insufficient balance");
_balanceOf[src] = _balanceOf[src] - wad;
_totalSupply = _totalSupply - wad;
emit Transfer(src, address(0), wad);
}
| function _burn(address src, uint wad) internal virtual returns (bool) {
unchecked {
require(_balanceOf[src] >= wad, "ERC20: Insufficient balance");
_balanceOf[src] = _balanceOf[src] - wad;
_totalSupply = _totalSupply - wad;
emit Transfer(src, address(0), wad);
}
| 52,203 |
259 | // Get payment minimum relative fee for given currency at given block number/blockNumber The concerned block number/currencyCt The address of the concerned currency contract (address(0) == ETH)/currencyId The ID of the concerned currency (0 for ETH and ERC20) | function currencyPaymentMinimumFee(uint256 blockNumber, address currencyCt, uint256 currencyId)
public
view
returns (int256)
| function currencyPaymentMinimumFee(uint256 blockNumber, address currencyCt, uint256 currencyId)
public
view
returns (int256)
| 21,934 |
1 | // The supply cap is used as a measure to guard deposits/ in the pool. It is meant to minimize the impact a potential/ compromise in the source registry (eg. Verra) can have to the pool. | uint256 public supplyCap;
mapping(address => uint256) private DEPRECATED_tokenBalances;
address public contractRegistry;
| uint256 public supplyCap;
mapping(address => uint256) private DEPRECATED_tokenBalances;
address public contractRegistry;
| 6,644 |
501 | // An event for tracking a lock on alteration of panic details. | event PanicDetailsLocked();
| event PanicDetailsLocked();
| 46,539 |
282 | // Remove an address from blacklist | function removeAddressFromBlacklist(address addr) public {
require(hasRole(MANAGER_ROLE, msg.sender), "Caller is not a manager");
_state.accounts[addr].isBlacklisted = false;
}
| function removeAddressFromBlacklist(address addr) public {
require(hasRole(MANAGER_ROLE, msg.sender), "Caller is not a manager");
_state.accounts[addr].isBlacklisted = false;
}
| 31,761 |
29 | // ------------------------------------------------------------------- Validation ------------------------------------------------------------------- |
if (
versionList.length != tokenList.length ||
versionList.length != amountList.length
) {
revert Shrine_InputArraysLengthMismatch();
}
|
if (
versionList.length != tokenList.length ||
versionList.length != amountList.length
) {
revert Shrine_InputArraysLengthMismatch();
}
| 22,814 |
140 | // upgrades the converter to the latest version can only be called by the owner note that the owner needs to call acceptOwnership/acceptManagement on the new converter after the upgrade/ | function upgrade() public ownerOnly {
IBancorConverterUpgrader converterUpgrader = IBancorConverterUpgrader(addressOf(BANCOR_CONVERTER_UPGRADER));
transferOwnership(converterUpgrader);
converterUpgrader.upgrade(version);
acceptOwnership();
}
| function upgrade() public ownerOnly {
IBancorConverterUpgrader converterUpgrader = IBancorConverterUpgrader(addressOf(BANCOR_CONVERTER_UPGRADER));
transferOwnership(converterUpgrader);
converterUpgrader.upgrade(version);
acceptOwnership();
}
| 14,686 |
87 | // Handle a partial word by reading destination and masking off the bits we are interested in. This correctly handles overlap, zero lengths and source == dest | assembly {
let mask := sub(exp(256, sub(32, length)), 1)
let s := and(mload(source), not(mask))
let d := and(mload(dest), mask)
mstore(dest, or(s, d))
}
| assembly {
let mask := sub(exp(256, sub(32, length)), 1)
let s := and(mload(source), not(mask))
let d := and(mload(dest), mask)
mstore(dest, or(s, d))
}
| 12,183 |
184 | // set interest rate for tokens owed from pools. Scaled to 10 (e.g. 150 is 15%)/ | function setBorrowPercent(uint256 _newPercentScaled) external onlyOwner {
borrowInterestPercentScaled = _newPercentScaled;
}
| function setBorrowPercent(uint256 _newPercentScaled) external onlyOwner {
borrowInterestPercentScaled = _newPercentScaled;
}
| 18,826 |
43 | // Safe ETH and ERC20 transfer library that gracefully handles missing return values./Solmate (https:github.com/Rari-Capital/solmate/blob/main/src/utils/SafeTransferLib.sol)/Use with caution! Some functions in this library knowingly create dirty bits at the destination of the free memory pointer./Note that none of the functions in this library check that a token has code at all! That responsibility is delegated to the caller. | library SafeTransferLib {
event Debug(bool one, bool two, uint256 retsize);
/*//////////////////////////////////////////////////////////////
ETH OPERATIONS
//////////////////////////////////////////////////////////////*/
function safeTransferETH(address to, uint256 amount) internal {
bool success;
assembly {
// Transfer the ETH and store if it succeeded or not.
success := call(gas(), to, amount, 0, 0, 0, 0)
}
require(success, "ETH_TRANSFER_FAILED");
}
/*//////////////////////////////////////////////////////////////
ERC20 OPERATIONS
//////////////////////////////////////////////////////////////*/
function safeTransferFrom(
ERC20 token,
address from,
address to,
uint256 amount
) internal {
bool success;
assembly {
// Get a pointer to some free memory.
let freeMemoryPointer := mload(0x40)
// Write the abi-encoded calldata into memory, beginning with the function selector.
mstore(freeMemoryPointer, 0x23b872dd00000000000000000000000000000000000000000000000000000000)
mstore(add(freeMemoryPointer, 4), from) // Append the "from" argument.
mstore(add(freeMemoryPointer, 36), to) // Append the "to" argument.
mstore(add(freeMemoryPointer, 68), amount) // Append the "amount" argument.
success := and(
// Set success to whether the call reverted, if not we check it either
// returned exactly 1 (can't just be non-zero data), or had no return data.
or(and(eq(mload(0), 1), gt(returndatasize(), 31)), iszero(returndatasize())),
// We use 100 because the length of our calldata totals up like so: 4 + 32 * 3.
// We use 0 and 32 to copy up to 32 bytes of return data into the scratch space.
// Counterintuitively, this call must be positioned second to the or() call in the
// surrounding and() call or else returndatasize() will be zero during the computation.
call(gas(), token, 0, freeMemoryPointer, 100, 0, 32)
)
}
require(success, "TRANSFER_FROM_FAILED");
}
function safeTransfer(
ERC20 token,
address to,
uint256 amount
) internal {
bool success;
assembly {
// Get a pointer to some free memory.
let freeMemoryPointer := mload(0x40)
// Write the abi-encoded calldata into memory, beginning with the function selector.
mstore(freeMemoryPointer, 0xa9059cbb00000000000000000000000000000000000000000000000000000000)
mstore(add(freeMemoryPointer, 4), to) // Append the "to" argument.
mstore(add(freeMemoryPointer, 36), amount) // Append the "amount" argument.
success := and(
// Set success to whether the call reverted, if not we check it either
// returned exactly 1 (can't just be non-zero data), or had no return data.
or(and(eq(mload(0), 1), gt(returndatasize(), 31)), iszero(returndatasize())),
// We use 68 because the length of our calldata totals up like so: 4 + 32 * 2.
// We use 0 and 32 to copy up to 32 bytes of return data into the scratch space.
// Counterintuitively, this call must be positioned second to the or() call in the
// surrounding and() call or else returndatasize() will be zero during the computation.
call(gas(), token, 0, freeMemoryPointer, 68, 0, 32)
)
}
require(success, "TRANSFER_FAILED");
}
function safeApprove(
ERC20 token,
address to,
uint256 amount
) internal {
bool success;
assembly {
// Get a pointer to some free memory.
let freeMemoryPointer := mload(0x40)
// Write the abi-encoded calldata into memory, beginning with the function selector.
mstore(freeMemoryPointer, 0x095ea7b300000000000000000000000000000000000000000000000000000000)
mstore(add(freeMemoryPointer, 4), to) // Append the "to" argument.
mstore(add(freeMemoryPointer, 36), amount) // Append the "amount" argument.
success := and(
// Set success to whether the call reverted, if not we check it either
// returned exactly 1 (can't just be non-zero data), or had no return data.
or(and(eq(mload(0), 1), gt(returndatasize(), 31)), iszero(returndatasize())),
// We use 68 because the length of our calldata totals up like so: 4 + 32 * 2.
// We use 0 and 32 to copy up to 32 bytes of return data into the scratch space.
// Counterintuitively, this call must be positioned second to the or() call in the
// surrounding and() call or else returndatasize() will be zero during the computation.
call(gas(), token, 0, freeMemoryPointer, 68, 0, 32)
)
}
require(success, "APPROVE_FAILED");
}
}
| library SafeTransferLib {
event Debug(bool one, bool two, uint256 retsize);
/*//////////////////////////////////////////////////////////////
ETH OPERATIONS
//////////////////////////////////////////////////////////////*/
function safeTransferETH(address to, uint256 amount) internal {
bool success;
assembly {
// Transfer the ETH and store if it succeeded or not.
success := call(gas(), to, amount, 0, 0, 0, 0)
}
require(success, "ETH_TRANSFER_FAILED");
}
/*//////////////////////////////////////////////////////////////
ERC20 OPERATIONS
//////////////////////////////////////////////////////////////*/
function safeTransferFrom(
ERC20 token,
address from,
address to,
uint256 amount
) internal {
bool success;
assembly {
// Get a pointer to some free memory.
let freeMemoryPointer := mload(0x40)
// Write the abi-encoded calldata into memory, beginning with the function selector.
mstore(freeMemoryPointer, 0x23b872dd00000000000000000000000000000000000000000000000000000000)
mstore(add(freeMemoryPointer, 4), from) // Append the "from" argument.
mstore(add(freeMemoryPointer, 36), to) // Append the "to" argument.
mstore(add(freeMemoryPointer, 68), amount) // Append the "amount" argument.
success := and(
// Set success to whether the call reverted, if not we check it either
// returned exactly 1 (can't just be non-zero data), or had no return data.
or(and(eq(mload(0), 1), gt(returndatasize(), 31)), iszero(returndatasize())),
// We use 100 because the length of our calldata totals up like so: 4 + 32 * 3.
// We use 0 and 32 to copy up to 32 bytes of return data into the scratch space.
// Counterintuitively, this call must be positioned second to the or() call in the
// surrounding and() call or else returndatasize() will be zero during the computation.
call(gas(), token, 0, freeMemoryPointer, 100, 0, 32)
)
}
require(success, "TRANSFER_FROM_FAILED");
}
function safeTransfer(
ERC20 token,
address to,
uint256 amount
) internal {
bool success;
assembly {
// Get a pointer to some free memory.
let freeMemoryPointer := mload(0x40)
// Write the abi-encoded calldata into memory, beginning with the function selector.
mstore(freeMemoryPointer, 0xa9059cbb00000000000000000000000000000000000000000000000000000000)
mstore(add(freeMemoryPointer, 4), to) // Append the "to" argument.
mstore(add(freeMemoryPointer, 36), amount) // Append the "amount" argument.
success := and(
// Set success to whether the call reverted, if not we check it either
// returned exactly 1 (can't just be non-zero data), or had no return data.
or(and(eq(mload(0), 1), gt(returndatasize(), 31)), iszero(returndatasize())),
// We use 68 because the length of our calldata totals up like so: 4 + 32 * 2.
// We use 0 and 32 to copy up to 32 bytes of return data into the scratch space.
// Counterintuitively, this call must be positioned second to the or() call in the
// surrounding and() call or else returndatasize() will be zero during the computation.
call(gas(), token, 0, freeMemoryPointer, 68, 0, 32)
)
}
require(success, "TRANSFER_FAILED");
}
function safeApprove(
ERC20 token,
address to,
uint256 amount
) internal {
bool success;
assembly {
// Get a pointer to some free memory.
let freeMemoryPointer := mload(0x40)
// Write the abi-encoded calldata into memory, beginning with the function selector.
mstore(freeMemoryPointer, 0x095ea7b300000000000000000000000000000000000000000000000000000000)
mstore(add(freeMemoryPointer, 4), to) // Append the "to" argument.
mstore(add(freeMemoryPointer, 36), amount) // Append the "amount" argument.
success := and(
// Set success to whether the call reverted, if not we check it either
// returned exactly 1 (can't just be non-zero data), or had no return data.
or(and(eq(mload(0), 1), gt(returndatasize(), 31)), iszero(returndatasize())),
// We use 68 because the length of our calldata totals up like so: 4 + 32 * 2.
// We use 0 and 32 to copy up to 32 bytes of return data into the scratch space.
// Counterintuitively, this call must be positioned second to the or() call in the
// surrounding and() call or else returndatasize() will be zero during the computation.
call(gas(), token, 0, freeMemoryPointer, 68, 0, 32)
)
}
require(success, "APPROVE_FAILED");
}
}
| 17,259 |
2 | // Prevents non-managers from running some functions | modifier onlyManager {
require(managers_map[msg.sender], "Must be a manager");
_;
}
| modifier onlyManager {
require(managers_map[msg.sender], "Must be a manager");
_;
}
| 33,446 |
247 | // t = function() { return IEVMScriptExecutor.at('0x4bcdd59d6c77774ee7317fc1095f69ec84421e49').contract.execScript.getData(...[].slice.call(arguments)).slice(10).match(/.{1,64}/g) } run = function() { return ScriptHelpers.new().then(sh => { sh.abiEncode.call(...[].slice.call(arguments)).then(a => console.log(a.slice(2).match(/.{1,64}/g)) ) }) } This is truly not beautiful but lets no daydream to the day solidity gets reflection features |
function abiEncode(bytes _a, bytes _b, address[] _c) public pure returns (bytes d) {
return encode(_a, _b, _c);
}
|
function abiEncode(bytes _a, bytes _b, address[] _c) public pure returns (bytes d) {
return encode(_a, _b, _c);
}
| 3,340 |
77 | // Update the index for the moved value | set._indexes[lastvalue] = toDeleteIndex + 1; // All indexes are 1-based
| set._indexes[lastvalue] = toDeleteIndex + 1; // All indexes are 1-based
| 63 |
538 | // Get user EIN | Transferer initiates this | uint transfererEIN = identityRegistry.getEIN(msg.sender);
| uint transfererEIN = identityRegistry.getEIN(msg.sender);
| 24,778 |
101 | // Withdraw the principal & the interest from money market | feeAmount = feeModel.getFee(depositEntry.interestOwed);
withdrawAmount = depositEntry.amount.add(
depositEntry.interestOwed
);
| feeAmount = feeModel.getFee(depositEntry.interestOwed);
withdrawAmount = depositEntry.amount.add(
depositEntry.interestOwed
);
| 55,734 |
138 | // emitted when a flashloan is executed_target the address of the flashLoanReceiver_reserve the address of the reserve_amount the amount requested_totalFee the total fee on the amount_protocolFee the part of the fee for the protocol_timestamp the timestamp of the action//emitted during a redeem action._reserve the address of the reserve_user the address of the user_amount the amount to be deposited_timestamp the timestamp of the action//emitted on deposit_reserve the address of the reserve_user the address of the user_amount the amount to be deposited_timestamp the timestamp of the action//only lending pools configurator can use functions affected by this modifier/ | modifier onlyAdmin {
require(
admin == msg.sender,
"The caller must be a admin"
);
_;
}
| modifier onlyAdmin {
require(
admin == msg.sender,
"The caller must be a admin"
);
_;
}
| 38,708 |
23 | // Mapping from holder address to their (enumerable) set of owned tokens | mapping (address => EnumerableSet.UintSet) private _holderTokens;
| mapping (address => EnumerableSet.UintSet) private _holderTokens;
| 60,087 |
93 | // Token Info | string private constant _name = 'GOJO Inu';
string private constant _symbol = 'GOJO';
uint8 private constant _decimals = 9;
uint256 public constant InitialSupply= 100 * 10**9 * 10**_decimals;//equals 100.000.000 token
uint256 swapLimit = 1 * 10**5 * 10**_decimals;
bool isSwapPegged = true;
| string private constant _name = 'GOJO Inu';
string private constant _symbol = 'GOJO';
uint8 private constant _decimals = 9;
uint256 public constant InitialSupply= 100 * 10**9 * 10**_decimals;//equals 100.000.000 token
uint256 swapLimit = 1 * 10**5 * 10**_decimals;
bool isSwapPegged = true;
| 70,408 |
56 | // Clear approval. Throws if `_from` is not the current owner | _clearApproval(_from, _tokenId);
| _clearApproval(_from, _tokenId);
| 12,112 |
42 | // will there be enough money to pay them to investors at the current multiplier.if no, that the multiplier decreases / | function checkFixMultiplier (uint _multiplier) private returns (uint) {
uint multiplier = _multiplier;
if (filmTotalGets < totalRaised * multiplier) {
multiplier = filmTotalGets / totalRaised;
}
return multiplier;
}
| function checkFixMultiplier (uint _multiplier) private returns (uint) {
uint multiplier = _multiplier;
if (filmTotalGets < totalRaised * multiplier) {
multiplier = filmTotalGets / totalRaised;
}
return multiplier;
}
| 52,899 |
34 | // contracts/token/interfaces/IBasicFDT.sol/ pragma solidity 0.6.11; // import "lib/openzeppelin-contracts/contracts/token/ERC20/IERC20.sol"; // import "./IBaseFDT.sol"; / | interface IBasicFDT is IBaseFDT, IERC20 {
event PointsPerShareUpdated(uint256);
event PointsCorrectionUpdated(address indexed, int256);
function withdrawnFundsOf(address) external view returns (uint256);
function accumulativeFundsOf(address) external view returns (uint256);
function updateFundsReceived() external;
}
| interface IBasicFDT is IBaseFDT, IERC20 {
event PointsPerShareUpdated(uint256);
event PointsCorrectionUpdated(address indexed, int256);
function withdrawnFundsOf(address) external view returns (uint256);
function accumulativeFundsOf(address) external view returns (uint256);
function updateFundsReceived() external;
}
| 4,910 |
13 | // Use the controller to check if the minting was successfull | require(controller.depositVerify(address(this), msg.sender, _toMint), Errors.FAIL_DEPOSIT);
return _toMint;
| require(controller.depositVerify(address(this), msg.sender, _toMint), Errors.FAIL_DEPOSIT);
return _toMint;
| 27,436 |
139 | // Timespan for users to review the new implementation and make decision. | uint constant UPGRADE_FREEZE_TIME = 3 days;
using SafeMath for uint;
| uint constant UPGRADE_FREEZE_TIME = 3 days;
using SafeMath for uint;
| 34,347 |
118 | // swap and send eth to Treasury wallet | swapTokensForEth(tokensForTreasury, treasuryWallet);
emit SwapAndLiquify(half, newBalance, otherHalf);
| swapTokensForEth(tokensForTreasury, treasuryWallet);
emit SwapAndLiquify(half, newBalance, otherHalf);
| 3,729 |
122 | // Vote weight of lock | function balanceOfLock(uint256 _lockId) external view returns (uint256);
| function balanceOfLock(uint256 _lockId) external view returns (uint256);
| 59,901 |
18 | // Perform transformations. | for (uint256 i = 0; i < args.transformations.length; ++i) {
_executeTransformation(
state.wallet,
args.transformations[i],
state.transformerDeployer,
args.recipient
);
}
| for (uint256 i = 0; i < args.transformations.length; ++i) {
_executeTransformation(
state.wallet,
args.transformations[i],
state.transformerDeployer,
args.recipient
);
}
| 18,970 |
189 | // govToken -> user_address -> user_index eg. usersGovTokensIndexes[govTokens[0]][msg.sender] = 1111123; | mapping (address => mapping (address => uint256)) public usersGovTokensIndexes;
| mapping (address => mapping (address => uint256)) public usersGovTokensIndexes;
| 22,469 |
83 | // Add bounty event. | event AddBounty(address indexed bountyHunter, uint amount);
| event AddBounty(address indexed bountyHunter, uint amount);
| 38,792 |
32 | // Generate one token ID inside a drop./ dropIDA identifier, or batch number, for a drop/ tokenIDInDrop An identified token inside the drop, from 0 to MAX_DROP_SIZE, inclusive/ return tokenID The token ID representing the token inside the drop | function _assembleTokenID(uint64 dropID, uint32 tokenIDInDrop) internal pure returns (uint256 tokenID) {
return MAX_DROP_SIZE * dropID + tokenIDInDrop;
}
| function _assembleTokenID(uint64 dropID, uint32 tokenIDInDrop) internal pure returns (uint256 tokenID) {
return MAX_DROP_SIZE * dropID + tokenIDInDrop;
}
| 37,030 |
38 | // the ordered list of target addresses for calls to be made | address[] targets;
| address[] targets;
| 48,912 |
82 | // make invest / | function makeInvest(uint256 _value, bytes5 _interval) internal isMintable {
require(min_invest <= _value && _value <= max_invest); // min max condition
assert(balances[msg.sender] >= _value && balances[this] + _value > balances[this]);
balances[msg.sender] -= _value;
balances[this] += _value;
invest storage inv = investInfo[msg.sender][_interval];
if (inv.exists == false) { // if invest no exists
inv.balance = _value;
inv.created = now;
inv.closed = 0;
emit Transfer(msg.sender, this, _value);
} else
if (inv.exists == true) {
uint256 rew = rewardController(msg.sender, _interval);
inv.balance = _value + rew;
inv.closed = 0;
emit Transfer(0x0, this, rew); // fix rise total supply
}
inv.exists = true;
emit Invested(msg.sender, _value);
if(totalSupply > maxSupply) stopMint(); // stop invest
}
| function makeInvest(uint256 _value, bytes5 _interval) internal isMintable {
require(min_invest <= _value && _value <= max_invest); // min max condition
assert(balances[msg.sender] >= _value && balances[this] + _value > balances[this]);
balances[msg.sender] -= _value;
balances[this] += _value;
invest storage inv = investInfo[msg.sender][_interval];
if (inv.exists == false) { // if invest no exists
inv.balance = _value;
inv.created = now;
inv.closed = 0;
emit Transfer(msg.sender, this, _value);
} else
if (inv.exists == true) {
uint256 rew = rewardController(msg.sender, _interval);
inv.balance = _value + rew;
inv.closed = 0;
emit Transfer(0x0, this, rew); // fix rise total supply
}
inv.exists = true;
emit Invested(msg.sender, _value);
if(totalSupply > maxSupply) stopMint(); // stop invest
}
| 36,258 |
294 | // Activate already-configured fees for use in the calling fund | function activateForFund(bool) external override {
address vaultProxy = __setValidatedVaultProxy(msg.sender);
address[] memory enabledFees = comptrollerProxyToFees[msg.sender];
for (uint256 i; i < enabledFees.length; i++) {
IFee(enabledFees[i]).activateForFund(msg.sender, vaultProxy);
}
| function activateForFund(bool) external override {
address vaultProxy = __setValidatedVaultProxy(msg.sender);
address[] memory enabledFees = comptrollerProxyToFees[msg.sender];
for (uint256 i; i < enabledFees.length; i++) {
IFee(enabledFees[i]).activateForFund(msg.sender, vaultProxy);
}
| 18,609 |
113 | // Executes SafeERC20.safeTransferFrom on a pool tokenReentrancy safety enforced via `ReentrancyGuard.nonReentrant` / | function transferPoolTokenFrom(
address _from,
address _to,
uint256 _value
| function transferPoolTokenFrom(
address _from,
address _to,
uint256 _value
| 48,651 |
65 | // Predict the CREATE2 address. / | function predictCloneAddressCreate2(
address template,
address deployer,
bytes32 salt
| function predictCloneAddressCreate2(
address template,
address deployer,
bytes32 salt
| 68,210 |
51 | // Receive ether and issue tokens to the senderThis function requires that msg.sender is not a contract. This is required because it's not possible for a contract to specify a gas amount when calling the (internal) send() function. Solidity imposes a maximum amount of gas (2300 gas at the time of writing)Contracts can call the contribute() function instead / | function () public payable;
| function () public payable;
| 32,881 |
30 | // transfer the resulting amount to BancorX | IBancorX(registry.addressOf(ContractIds.BANCOR_X)).xTransfer(_toBlockchain, _to, amount, _conversionId);
return amount;
| IBancorX(registry.addressOf(ContractIds.BANCOR_X)).xTransfer(_toBlockchain, _to, amount, _conversionId);
return amount;
| 23,341 |
26 | // 当前已提取数量 | function numberWithdrawn(address addr) view public isAddress(addr) returns(uint256) {
return user[addr].amountWithdrawn;
}
| function numberWithdrawn(address addr) view public isAddress(addr) returns(uint256) {
return user[addr].amountWithdrawn;
}
| 12,092 |
12 | // EVENT DEFINITIONS/ Utility Events | event OperatingStatusUpdated(bool newStatus);
event PayoutUpdated(uint payoutMultiplier);
event AirlineRegistrationUpdated(uint airlineConsensusMultiplier, uint airlineRegFee, uint flightArrLimit);
event FlightArrayLimit (uint flightCount);
event FlightArrayUpdated (uint newFlightCount, uint flightArrayLimit);
| event OperatingStatusUpdated(bool newStatus);
event PayoutUpdated(uint payoutMultiplier);
event AirlineRegistrationUpdated(uint airlineConsensusMultiplier, uint airlineRegFee, uint flightArrLimit);
event FlightArrayLimit (uint flightCount);
event FlightArrayUpdated (uint newFlightCount, uint flightArrayLimit);
| 55,573 |
11 | // defines costs of goods sold (“cogs”) as the value of the last item in the inventory |
inventoryBalance[inventoryHolder] -= 1;
|
inventoryBalance[inventoryHolder] -= 1;
| 38,104 |
39 | // Internal function to handle NFT returns (burning) | function returnTierNFT(uint256 _amount) internal {
if (_amount != 0) {
bool burned = false;
for (uint16 i;i < backerInfoMapping[msg.sender].rewards.length; i++) {
if (burned == true) {
break;
}
if (_amount == backerInfoMapping[msg.sender].rewards[i].tierAmount) {
Tier reward = Tier(fundingAmountToTier[_amount].reward);
if (reward.ownerOf(backerInfoMapping[msg.sender].rewards[i].tokenId) == msg.sender) {
reward.burn(backerInfoMapping[msg.sender].rewards[i].tokenId);
delete backerInfoMapping[msg.sender].rewards[i];
burned = true;
}
}
}
require(burned == true, "!backerNFT");
} else {
for (uint16 i;i < backerInfoMapping[msg.sender].rewards.length; i++) {
BackerNFTReward memory backingReward = backerInfoMapping[msg.sender].rewards[i];
Tier reward = Tier(fundingAmountToTier[backingReward.tierAmount].reward);
require(reward.ownerOf(backerInfoMapping[msg.sender].rewards[i].tokenId) == msg.sender, "!NFT ownership");
reward.burn(backerInfoMapping[msg.sender].rewards[i].tokenId);
delete backerInfoMapping[msg.sender].rewards[i];
}
}
}
| function returnTierNFT(uint256 _amount) internal {
if (_amount != 0) {
bool burned = false;
for (uint16 i;i < backerInfoMapping[msg.sender].rewards.length; i++) {
if (burned == true) {
break;
}
if (_amount == backerInfoMapping[msg.sender].rewards[i].tierAmount) {
Tier reward = Tier(fundingAmountToTier[_amount].reward);
if (reward.ownerOf(backerInfoMapping[msg.sender].rewards[i].tokenId) == msg.sender) {
reward.burn(backerInfoMapping[msg.sender].rewards[i].tokenId);
delete backerInfoMapping[msg.sender].rewards[i];
burned = true;
}
}
}
require(burned == true, "!backerNFT");
} else {
for (uint16 i;i < backerInfoMapping[msg.sender].rewards.length; i++) {
BackerNFTReward memory backingReward = backerInfoMapping[msg.sender].rewards[i];
Tier reward = Tier(fundingAmountToTier[backingReward.tierAmount].reward);
require(reward.ownerOf(backerInfoMapping[msg.sender].rewards[i].tokenId) == msg.sender, "!NFT ownership");
reward.burn(backerInfoMapping[msg.sender].rewards[i].tokenId);
delete backerInfoMapping[msg.sender].rewards[i];
}
}
}
| 18,121 |
22 | // function to calculate transaction fees for given value and token _value is the given trade overall value _feeIndex indicates token pay optionsreturn calculated trade feeCaution: _value is expected to be in wei units and it works for single token payment / | function calcTradeFee(uint256 _value, uint256 _feeIndex) public view returns (uint256) {
require(_feeIndex >= 0 && _feeIndex <= 2);
require(_value > 0 && _value >= 1* 1 ether);
require(exFees.length == 3 && exFees[_feeIndex] > 0 );
//Calculation Formula TotalFees = (_value * exFees[_feeIndex])/ (1 ether)
uint256 _totalFees = (_value.mul(exFees[_feeIndex])).div(1 ether);
// Calculated total fee must be gretae than 0 for a given base fee > 0
require(_totalFees > 0);
return _totalFees;
}
| function calcTradeFee(uint256 _value, uint256 _feeIndex) public view returns (uint256) {
require(_feeIndex >= 0 && _feeIndex <= 2);
require(_value > 0 && _value >= 1* 1 ether);
require(exFees.length == 3 && exFees[_feeIndex] > 0 );
//Calculation Formula TotalFees = (_value * exFees[_feeIndex])/ (1 ether)
uint256 _totalFees = (_value.mul(exFees[_feeIndex])).div(1 ether);
// Calculated total fee must be gretae than 0 for a given base fee > 0
require(_totalFees > 0);
return _totalFees;
}
| 45,053 |
45 | // View Functions // Returns the excess collateral that can be removed. return excessCollateral_ The excess collateral that can be removed, if any. / | function excessCollateral() external view returns (uint256 excessCollateral_);
| function excessCollateral() external view returns (uint256 excessCollateral_);
| 11,794 |
177 | // Wether deposits are paused | bool public paused;
| bool public paused;
| 43,037 |
26 | // swap to UST | swapper.swapToken(
address(inputToken),
address(proxyInputToken),
_amount,
_minAmountOut,
address(this)
);
| swapper.swapToken(
address(inputToken),
address(proxyInputToken),
_amount,
_minAmountOut,
address(this)
);
| 19,910 |
152 | // Revokes `role` from `account`. Internal function without access restriction. / | function _revokeRole(bytes32 role, address account) internal virtual {
if (hasRole(role, account)) {
_roles[role].members[account] = false;
emit RoleRevoked(role, account, _msgSender());
}
}
| function _revokeRole(bytes32 role, address account) internal virtual {
if (hasRole(role, account)) {
_roles[role].members[account] = false;
emit RoleRevoked(role, account, _msgSender());
}
}
| 28,676 |
80 | // This value must be <= the Voting contract's `ancillaryBytesLimit` value otherwise it is possible that a price can be requested to this contract successfully, but cannot be disputed because the DVM refuses to accept a price request made with ancillary data length over a certain size. | uint256 public constant ancillaryBytesLimit = 8192;
| uint256 public constant ancillaryBytesLimit = 8192;
| 58,795 |
170 | // Interface for the optional metadata functions from the ERC20 standard. _Available since v4.1._/ | interface IERC20Metadata is IERC20 {
/**
* @dev Returns the name of the token.
*/
function name() external view returns (string memory);
/**
* @dev Returns the symbol of the token.
*/
function symbol() external view returns (string memory);
/**
* @dev Returns the decimals places of the token.
*/
function decimals() external view returns (uint8);
}
| interface IERC20Metadata is IERC20 {
/**
* @dev Returns the name of the token.
*/
function name() external view returns (string memory);
/**
* @dev Returns the symbol of the token.
*/
function symbol() external view returns (string memory);
/**
* @dev Returns the decimals places of the token.
*/
function decimals() external view returns (uint8);
}
| 36,241 |
90 | // Issue token from 0x address | function _issue(address account, uint256 amount) internal {
require(amount != 0);
_balances[account] = _balances[account].add(amount);
emit Transfer(address(0), account, amount);
}
| function _issue(address account, uint256 amount) internal {
require(amount != 0);
_balances[account] = _balances[account].add(amount);
emit Transfer(address(0), account, amount);
}
| 8,682 |
161 | // Reduce total supply | _totalSupply = _totalSupply.sub(amount);
| _totalSupply = _totalSupply.sub(amount);
| 78,106 |
5 | // v1_address is the address for Vega's v1 ERC20 token that has already been deployed | address public v1_address; // mainnet = 0xD249B16f61cB9489Fe0Bb046119A48025545b58a;
| address public v1_address; // mainnet = 0xD249B16f61cB9489Fe0Bb046119A48025545b58a;
| 30,856 |
168 | // Computes the current phase based only on the current time. / | function computeCurrentPhase(Data storage data, uint currentTime) internal view returns (Phase) {
// This employs some hacky casting. We could make this an if-statement if we're worried about type safety.
return Phase(currentTime.div(data.phaseLength).mod(NUM_PHASES));
}
| function computeCurrentPhase(Data storage data, uint currentTime) internal view returns (Phase) {
// This employs some hacky casting. We could make this an if-statement if we're worried about type safety.
return Phase(currentTime.div(data.phaseLength).mod(NUM_PHASES));
}
| 41,233 |
994 | // _processFirstUnstakeRequest is O(1) so we'll handle the iteration checks here | if (iterationsLeft == 0) {
emit PendingActionsProcessed(false);
return (false, iterationsLeft);
}
| if (iterationsLeft == 0) {
emit PendingActionsProcessed(false);
return (false, iterationsLeft);
}
| 29,466 |
215 | // Update and check the effective price listtokenAddress Token addressnum Number of prices to check return uint256[] price list/ | function updateAndCheckPriceList(address tokenAddress, uint256 num) public payable returns (uint256[] memory) {
require(checkUseNestPrice(address(msg.sender)));
mapping(uint256 => PriceInfo) storage priceInfoList = _tokenInfo[tokenAddress].priceInfoList;
// Extract data
uint256 length = num.mul(3);
uint256 index = 0;
uint256[] memory data = new uint256[](length);
uint256 checkBlock = _tokenInfo[tokenAddress].latestOffer;
while(index < length && checkBlock > 0){
if (checkBlock < block.number && priceInfoList[checkBlock].ethAmount != 0) {
// Add return data
data[index++] = priceInfoList[checkBlock].ethAmount;
data[index++] = priceInfoList[checkBlock].erc20Amount;
data[index++] = checkBlock;
}
checkBlock = priceInfoList[checkBlock].frontBlock;
}
require(length == data.length);
// Allocation
address nToken = _tokenMapping.checkTokenMapping(tokenAddress);
if (nToken == address(0x0)) {
_abonus.switchToEth.value(_priceCost)(address(_nestToken));
} else {
_abonus.switchToEth.value(_priceCost)(address(nToken));
}
if (msg.value > _priceCost) {
repayEth(address(msg.sender), msg.value.sub(_priceCost));
}
return data;
}
| function updateAndCheckPriceList(address tokenAddress, uint256 num) public payable returns (uint256[] memory) {
require(checkUseNestPrice(address(msg.sender)));
mapping(uint256 => PriceInfo) storage priceInfoList = _tokenInfo[tokenAddress].priceInfoList;
// Extract data
uint256 length = num.mul(3);
uint256 index = 0;
uint256[] memory data = new uint256[](length);
uint256 checkBlock = _tokenInfo[tokenAddress].latestOffer;
while(index < length && checkBlock > 0){
if (checkBlock < block.number && priceInfoList[checkBlock].ethAmount != 0) {
// Add return data
data[index++] = priceInfoList[checkBlock].ethAmount;
data[index++] = priceInfoList[checkBlock].erc20Amount;
data[index++] = checkBlock;
}
checkBlock = priceInfoList[checkBlock].frontBlock;
}
require(length == data.length);
// Allocation
address nToken = _tokenMapping.checkTokenMapping(tokenAddress);
if (nToken == address(0x0)) {
_abonus.switchToEth.value(_priceCost)(address(_nestToken));
} else {
_abonus.switchToEth.value(_priceCost)(address(nToken));
}
if (msg.value > _priceCost) {
repayEth(address(msg.sender), msg.value.sub(_priceCost));
}
return data;
}
| 24,922 |
95 | // Calculate x / y rounding towards zero, where x and y are unsigned 256-bitinteger numbers.Revert on overflow or when y is zero.x unsigned 256-bit integer number y unsigned 256-bit integer numberreturn signed 64.64-bit fixed point number / | function divu (uint256 x, uint256 y) internal pure returns (int128) {
require (y != 0);
uint128 result = divuu (x, y);
require (result <= uint128 (MAX_64x64));
return int128 (result);
}
| function divu (uint256 x, uint256 y) internal pure returns (int128) {
require (y != 0);
uint128 result = divuu (x, y);
require (result <= uint128 (MAX_64x64));
return int128 (result);
}
| 12,362 |
15 | // function safeMint(address _to, string memory _uri) public onlyOwner { At: https:www.youtube.com/live/DSKDhBCmHXk?feature=share&t=531 |
function mintRx(
address _to
)
public
|
function mintRx(
address _to
)
public
| 8,116 |
53 | // Don't allow a zero index, start counting at 1 | return value.add(1);
| return value.add(1);
| 30,828 |
19 | // swap function signature | mstore(0x7c, PAIR_SWAP_ID)
| mstore(0x7c, PAIR_SWAP_ID)
| 2,617 |
23 | // ------------------------------------------------------------------------ Token owner can approve for `spender` to transferFrom(...) `tokens` from the token owner&39;s account https:github.com/ethereum/EIPs/blob/master/EIPS/eip-20-token-standard.md recommends that there are no checks for the approval double-spend attack as this should be implemented in user interfaces ------------------------------------------------------------------------ | function approve(address spender, uint256 tokens) public returns (bool success) {
allowed[msg.sender][spender] = tokens;
emit Approval(msg.sender, spender, tokens);
return true;
}
| function approve(address spender, uint256 tokens) public returns (bool success) {
allowed[msg.sender][spender] = tokens;
emit Approval(msg.sender, spender, tokens);
return true;
}
| 26,851 |
7 | // returns if staking contract is shutdown or not / | function isShutdown() public view override returns(bool) {
return shutdown;
}
| function isShutdown() public view override returns(bool) {
return shutdown;
}
| 5,904 |
5 | // you can't pass an enum from outside the smart contractbut solidity can convert int to enum, in the order they were definedif you pass 0, it'll map to INACTIVE | function otherFunction(STATE _state) public {
}
| function otherFunction(STATE _state) public {
}
| 51,497 |
12 | // uint256 value = amounttokenPrice; | uint256 value = ExternalSafeMath.mul(amount, tokenPrice);
require(
msg.value == value,
"Incorrect ETH / token amount"
);
| uint256 value = ExternalSafeMath.mul(amount, tokenPrice);
require(
msg.value == value,
"Incorrect ETH / token amount"
);
| 5,003 |
20 | // Retrieves the address from a signature_hash the message that was signed (any length of bytes) _signature the signature (65 bytes) / | function addr(bytes _hash, bytes _signature) internal pure returns (address) {
bytes memory prefix = "\x19Ethereum Signed Message:\n";
bytes memory encoded = abi.encodePacked(prefix, uintToBytes(_hash.length), _hash);
bytes32 prefixedHash = keccak256(encoded);
return ECRecovery.recover(prefixedHash, _signature);
}
| function addr(bytes _hash, bytes _signature) internal pure returns (address) {
bytes memory prefix = "\x19Ethereum Signed Message:\n";
bytes memory encoded = abi.encodePacked(prefix, uintToBytes(_hash.length), _hash);
bytes32 prefixedHash = keccak256(encoded);
return ECRecovery.recover(prefixedHash, _signature);
}
| 1,743 |
0 | // override the tokenURI function/ | function tokenURI(uint256 tokenId) public view virtual override returns (string memory) {
require (tokenId <= _totalMinted(), "Token ID does not exist");
return ImetadataContract(metadataContract).fetchMetadata();
}
| function tokenURI(uint256 tokenId) public view virtual override returns (string memory) {
require (tokenId <= _totalMinted(), "Token ID does not exist");
return ImetadataContract(metadataContract).fetchMetadata();
}
| 27,515 |
22 | // https:etherscan.io/address/0x02e7B8511831B1b02d9018215a0f8f500Ea5c6B3 | address internal constant REPAY_WITH_COLLATERAL_ADAPTER =
0x02e7B8511831B1b02d9018215a0f8f500Ea5c6B3;
| address internal constant REPAY_WITH_COLLATERAL_ADAPTER =
0x02e7B8511831B1b02d9018215a0f8f500Ea5c6B3;
| 15,721 |
5 | // Minimal bytes library, inspired by https:github.com/GNSPS/solidity-bytes-utils | library Bytes {
function areEqual(bytes memory x, bytes memory y) internal pure returns (bool) {
return (x.length == y.length) && (keccak256(x) == keccak256(y));
}
function areEqualStr(string memory x, string memory y) internal pure returns (bool) {
return areEqual(bytes(x), bytes(y));
}
function asUint256(bytes memory x) internal pure returns (uint256 r) {
require(x.length == 32, "Bytes: not length 32");
assembly {
r := mload(add(x, 0x20))
}
}
function asUint256s(bytes memory x) internal pure returns (uint256[] memory) {
require(x.length % 32 == 0, "Bytes: length not multiple of 32");
uint256[] memory y = new uint256[](x.length/32);
assembly {
let a := add(x, 0x20) // initial bytes pointer
let b := add(y, 0x20) // initial uint[] pointer
for
{
let i := 0 // relative mem pointer
let end := mload(x) // length of x is first word of x
}
lt(i, end)
{ i := add(i, 0x20) }
{
mstore(add(b, i), mload(add(a, i)))
}
}
return y;
}
// Returns a pointer to the same memory array as x and destructively sets
// the first word, which is the length of the array, to the bytes length
// divided by 32, effectively turning the bytes array into an uint256[].
//
// The original reference bytes x must not be used after this destructive
// operation.
function asUint256sInplace(bytes memory x) internal pure returns (uint256[] memory r) {
require(x.length % 32 == 0, "Bytes: length not multiple of 32");
assembly {
mstore(x, div(mload(x), 0x20))
r := x
}
}
}
| library Bytes {
function areEqual(bytes memory x, bytes memory y) internal pure returns (bool) {
return (x.length == y.length) && (keccak256(x) == keccak256(y));
}
function areEqualStr(string memory x, string memory y) internal pure returns (bool) {
return areEqual(bytes(x), bytes(y));
}
function asUint256(bytes memory x) internal pure returns (uint256 r) {
require(x.length == 32, "Bytes: not length 32");
assembly {
r := mload(add(x, 0x20))
}
}
function asUint256s(bytes memory x) internal pure returns (uint256[] memory) {
require(x.length % 32 == 0, "Bytes: length not multiple of 32");
uint256[] memory y = new uint256[](x.length/32);
assembly {
let a := add(x, 0x20) // initial bytes pointer
let b := add(y, 0x20) // initial uint[] pointer
for
{
let i := 0 // relative mem pointer
let end := mload(x) // length of x is first word of x
}
lt(i, end)
{ i := add(i, 0x20) }
{
mstore(add(b, i), mload(add(a, i)))
}
}
return y;
}
// Returns a pointer to the same memory array as x and destructively sets
// the first word, which is the length of the array, to the bytes length
// divided by 32, effectively turning the bytes array into an uint256[].
//
// The original reference bytes x must not be used after this destructive
// operation.
function asUint256sInplace(bytes memory x) internal pure returns (uint256[] memory r) {
require(x.length % 32 == 0, "Bytes: length not multiple of 32");
assembly {
mstore(x, div(mload(x), 0x20))
r := x
}
}
}
| 34,003 |
69 | // Allow Vault to take up to the "harvested" balance of this contract, which is the amount it has earned since the last time it reported to the Vault | uint256 outstanding = vault.report(want.balanceOf(address(this)).sub(reserve));
| uint256 outstanding = vault.report(want.balanceOf(address(this)).sub(reserve));
| 73,614 |
8 | // address of fairLaunch contract | address public override getFairLaunchAddr;
| address public override getFairLaunchAddr;
| 9,070 |
72 | // Add dividend | addDividend(divFee);
| addDividend(divFee);
| 47,678 |
54 | // This is the amount of fCash that the liquidity token has a claim to. | uint128 fCashAmount = SafeCast.toUint128(uint256(market.totalfCash).mul(amount).div(market.totalLiquidity));
market.totalfCash = market.totalfCash.sub(fCashAmount);
| uint128 fCashAmount = SafeCast.toUint128(uint256(market.totalfCash).mul(amount).div(market.totalLiquidity));
market.totalfCash = market.totalfCash.sub(fCashAmount);
| 32,535 |
268 | // Transfer amount that is due after realized losses are accounted for. Recognized losses are absorbed by the LP. | _transferLiquidityLockerFunds(msg.sender, amt.sub(_recognizeLosses()));
_emitBalanceUpdatedEvent();
| _transferLiquidityLockerFunds(msg.sender, amt.sub(_recognizeLosses()));
_emitBalanceUpdatedEvent();
| 6,034 |
34 | // Owner only function to lock certain variables./tokenData Lock token data manipulation./metadata Lock metadata contract change./mergePause Lock merge pause./transferPause Lock transfer pause./vaultChange Lock vault change./operatorFiltering Lock operator filtering toggle. | function lockState(
bool tokenData,
bool metadata,
bool mergePause,
bool transferPause,
bool vaultChange,
bool operatorFiltering
| function lockState(
bool tokenData,
bool metadata,
bool mergePause,
bool transferPause,
bool vaultChange,
bool operatorFiltering
| 14,115 |
5 | // batchFillOrders | bytes4 constant public BATCH_FILL_ORDERS_SELECTOR = 0x297bb70b;
bytes4 constant public BATCH_FILL_ORDERS_SELECTOR_GENERATOR = bytes4(keccak256("batchFillOrders((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes)[],uint256[],bytes[])"));
| bytes4 constant public BATCH_FILL_ORDERS_SELECTOR = 0x297bb70b;
bytes4 constant public BATCH_FILL_ORDERS_SELECTOR_GENERATOR = bytes4(keccak256("batchFillOrders((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes)[],uint256[],bytes[])"));
| 41,964 |
2 | // Mirror contract is a shared contract with arbitrary tokenIds not exclusive to plsr, need to maintain a list of eligible Ids | EnumerableSet.UintSet private _redeemableTokenIdsSet;
| EnumerableSet.UintSet private _redeemableTokenIdsSet;
| 73,681 |
260 | // should never be used inside of transaction because of gas fee | function balanceOf(address account) public view returns (uint256) {
uint256 balance = 0;
uint256 supply = nft.totalSupply();
for (uint i = 1; i <= supply; i++) {
if (vault[i].owner == account) {
balance += 1;
}
}
return balance;
}
| function balanceOf(address account) public view returns (uint256) {
uint256 balance = 0;
uint256 supply = nft.totalSupply();
for (uint i = 1; i <= supply; i++) {
if (vault[i].owner == account) {
balance += 1;
}
}
return balance;
}
| 6,479 |
98 | // Needs vat.hope(exportCdpProxy.address, { from: user });/pool The pool to trade in (and therefore fyDai series to migrate)./cdp CDP Vault to export to./wethAmount weth to move from Yield to MakerDAO. Needs to be high enough to collateralize the dai debt in MakerDAO,/ and low enough to make sure that debt left in Yield is also collateralized./fyDaiAmount fyDai debt to move from Yield to MakerDAO./maxFYDaiPrice Maximum Dai price to pay for fyDai./controllerSig packed signature for delegation of this proxy in the controller. Ignored if '0x'. | function exportCdpPositionWithSignature(IPool pool, uint256 cdp, uint256 wethAmount, uint256 fyDaiAmount, uint256 maxFYDaiPrice, bytes memory controllerSig) public {
if (controllerSig.length > 0) controller.addDelegatePacked(controllerSig);
return exportCdpPosition(pool, cdp, wethAmount, fyDaiAmount, maxFYDaiPrice);
}
| function exportCdpPositionWithSignature(IPool pool, uint256 cdp, uint256 wethAmount, uint256 fyDaiAmount, uint256 maxFYDaiPrice, bytes memory controllerSig) public {
if (controllerSig.length > 0) controller.addDelegatePacked(controllerSig);
return exportCdpPosition(pool, cdp, wethAmount, fyDaiAmount, maxFYDaiPrice);
}
| 39,691 |
33 | // if the sender is not in the list | if (indexes[sender] == 0) {
_totalTokens = _totalTokens.add(contributionsToken[sender]);
_totalWei = _totalWei.add(contributionsEth[sender]);
| if (indexes[sender] == 0) {
_totalTokens = _totalTokens.add(contributionsToken[sender]);
_totalWei = _totalWei.add(contributionsEth[sender]);
| 17,026 |
38 | // 0x4f558e79 ===bytes4(keccak256(&39;exists(uint256)&39;)) / |
using SafeMath for uint256;
using AddressUtils for address;
|
using SafeMath for uint256;
using AddressUtils for address;
| 37,945 |
98 | // Check target address is service//_address target address// return `true` when an address is a service, `false` otherwise | function isService(address _address) public view returns (bool check) {
return _address == profiterole ||
_address == treasury ||
_address == proxy ||
_address == pendingManager ||
emissionProviders[_address] ||
burningMans[_address] ||
sideServices[_address];
}
| function isService(address _address) public view returns (bool check) {
return _address == profiterole ||
_address == treasury ||
_address == proxy ||
_address == pendingManager ||
emissionProviders[_address] ||
burningMans[_address] ||
sideServices[_address];
}
| 20,460 |
26 | // Calculate the stake amount of a user, after applying the bonus from the lockup period chosen/_user The user from which to query the stake amount/ return The user stake amount after applying the bonus | function getStakeAmountWithBonus(address _user) public view returns(uint256) {
UserInfo memory user = userInfo[_user];
return user.balance.mul(stakePeriods[user.stakePeriod]).div(_inverseBasisPoint);
}
| function getStakeAmountWithBonus(address _user) public view returns(uint256) {
UserInfo memory user = userInfo[_user];
return user.balance.mul(stakePeriods[user.stakePeriod]).div(_inverseBasisPoint);
}
| 46,131 |
0 | // require(entries <= MAX_ENTRIES, "ENTRIES_EXCEED_LIMIT");require(!whitelistAddress[_entry], "ADDRESS_EXIST"); | whitelistAddress[_sale_type][_entry] = true;
entries += 1;
emit Entries(entries);
| whitelistAddress[_sale_type][_entry] = true;
entries += 1;
emit Entries(entries);
| 32,812 |
0 | // Initializes the contract setting the deployer as the initialowner./ | constructor() {
_setOwner(msg.sender);
}
| constructor() {
_setOwner(msg.sender);
}
| 54,410 |
139 | // value of bodyColor, eyes, mouth, hair, hairColor, armor, weapon, hat must be < 1000 | require(_paramIndex > HAT_MAX_7 || _value < 1000);
| require(_paramIndex > HAT_MAX_7 || _value < 1000);
| 78,810 |
170 | // swaps tokens on the contract for ETH | function _swapTokenForETH(uint256 amount) private {
_approve(address(this), address(_pancakeRouter), amount);
address[] memory path = new address[](2);
path[0] = address(this);
path[1] = _pancakeRouter.WETH();
_pancakeRouter.swapExactTokensForETHSupportingFeeOnTransferTokens(
amount,
0,
path,
address(this),
block.timestamp
);
}
| function _swapTokenForETH(uint256 amount) private {
_approve(address(this), address(_pancakeRouter), amount);
address[] memory path = new address[](2);
path[0] = address(this);
path[1] = _pancakeRouter.WETH();
_pancakeRouter.swapExactTokensForETHSupportingFeeOnTransferTokens(
amount,
0,
path,
address(this),
block.timestamp
);
}
| 40,321 |
318 | // Voting window is opened | uint256 internal constant VOTING_WINDOW_IS_OPENED = 55;
| uint256 internal constant VOTING_WINDOW_IS_OPENED = 55;
| 34,137 |
16 | // Deletes the payment from its receiver's and sender's lists of payments, and zeroes out all the data in the struct.paymentId The ID of the payment to be deleted./ | function deletePayment(address paymentId) private {
EscrowedPayment storage payment = escrowedPayments[paymentId];
address[] storage received = receivedPaymentIds[payment.recipientIdentifier];
address[] storage sent = sentPaymentIds[payment.sender];
escrowedPayments[received[received.length - 1]].receivedIndex = payment.receivedIndex;
received[payment.receivedIndex] = received[received.length - 1];
received.length = received.length.sub(1);
escrowedPayments[sent[sent.length - 1]].sentIndex = payment.sentIndex;
sent[payment.sentIndex] = sent[sent.length - 1];
sent.length = sent.length.sub(1);
delete escrowedPayments[paymentId];
}
| function deletePayment(address paymentId) private {
EscrowedPayment storage payment = escrowedPayments[paymentId];
address[] storage received = receivedPaymentIds[payment.recipientIdentifier];
address[] storage sent = sentPaymentIds[payment.sender];
escrowedPayments[received[received.length - 1]].receivedIndex = payment.receivedIndex;
received[payment.receivedIndex] = received[received.length - 1];
received.length = received.length.sub(1);
escrowedPayments[sent[sent.length - 1]].sentIndex = payment.sentIndex;
sent[payment.sentIndex] = sent[sent.length - 1];
sent.length = sent.length.sub(1);
delete escrowedPayments[paymentId];
}
| 37,366 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.