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 |
|---|---|---|---|---|
14 | // Calculate and mint the amount of xDvf the Dvf is worth. The ratio will change overtime, as xDvf is burned/minted and Dvf deposited + gained from fees / withdrawn. | else {
uint256 what = _amount.mul(totalShares).div(totalDvf);
_mint(msg.sender, what);
}
| else {
uint256 what = _amount.mul(totalShares).div(totalDvf);
_mint(msg.sender, what);
}
| 13,224 |
745 | // Triggers a transfer to owner in case of emergency / | function rescueEther() public onlyOwner {
uint256 currentBalance = address(this).balance;
(bool sent, ) = address(msg.sender).call{value: currentBalance}('');
require(sent,"Error while transfering the eth");
}
| function rescueEther() public onlyOwner {
uint256 currentBalance = address(this).balance;
(bool sent, ) = address(msg.sender).call{value: currentBalance}('');
require(sent,"Error while transfering the eth");
}
| 77,101 |
103 | // _player wallet of the player/ return Claims data of the player on that raffle | function getClaimData(
uint256 _raffleId,
address _player
| function getClaimData(
uint256 _raffleId,
address _player
| 39,303 |
6 | // return unburned lp tokens to from | STE_CRV_ADDR.withdrawTokens(_params.from, _params.maxBurnAmount.sub(burnedLp));
logData = abi.encode(_params.amounts[0], _params.amounts[1], burnedLp);
if (_params.returnValue == ReturnValue.WETH) return (_params.amounts[0], logData);
if (_params.returnValue == ReturnValue.STETH) retur... | STE_CRV_ADDR.withdrawTokens(_params.from, _params.maxBurnAmount.sub(burnedLp));
logData = abi.encode(_params.amounts[0], _params.amounts[1], burnedLp);
if (_params.returnValue == ReturnValue.WETH) return (_params.amounts[0], logData);
if (_params.returnValue == ReturnValue.STETH) retur... | 49,607 |
256 | // modifier for valid nonce with signature-based call | modifier withValidNonceAndDeadline(uint256 nonce, uint256 deadline) {
require(block.timestamp <= deadline, "Deadline time passed");
require(!usedNonces[nonce], "nonce used");
usedNonces[nonce] = true;
_;
}
| modifier withValidNonceAndDeadline(uint256 nonce, uint256 deadline) {
require(block.timestamp <= deadline, "Deadline time passed");
require(!usedNonces[nonce], "nonce used");
usedNonces[nonce] = true;
_;
}
| 53,588 |
154 | // Deposit LP tokens to MasterChef for SHEESHA allocation. | function deposit(uint256 _pid, uint256 _amount) public {
_deposit(msg.sender, _pid, _amount);
}
| function deposit(uint256 _pid, uint256 _amount) public {
_deposit(msg.sender, _pid, _amount);
}
| 60,308 |
186 | // Maps messageHash to the Message object. // Maps blockHeight to storageRoot. // Private Variables //Maps address to message hash. Once the inbox process is started the correspondingmessage hash is stored against the address starting process.This is used to restrict simultaneous/multiple processfor a particular addres... | mapping(address => bytes32) private inboxActiveProcess;
| mapping(address => bytes32) private inboxActiveProcess;
| 28,586 |
6 | // ę°ē»čµå¼åē»ęä½čµå¼ęé®é¢å
ęå
ē“ åå¤å„½ļ¼ē¶ååå§åē»ęä½ |
address[] memory sharingPeersAddressCollection = new address[](2);
sharingPeersAddressCollection[0] = 0xCDce1eaE7080f2450ea4f8637DA5ce21f31718aC; //chunmiao account, act as doctor
sharingPeersAddressCollection[1] = 0x736b60dFc85B7063c01ECf912E00cb83678D386e; //lucy account, act as patient
|
address[] memory sharingPeersAddressCollection = new address[](2);
sharingPeersAddressCollection[0] = 0xCDce1eaE7080f2450ea4f8637DA5ce21f31718aC; //chunmiao account, act as doctor
sharingPeersAddressCollection[1] = 0x736b60dFc85B7063c01ECf912E00cb83678D386e; //lucy account, act as patient
| 40,852 |
29 | // check claim entitlement of any wallet | function checkClaimEntitlementofWallet(address _address) public view returns(uint) {
for (uint i = 0; i < claimants.length; i++) {
if(_address == claimants[i].claimantAddress) {
require(claimants[i].claimantHasClaimed == false);
return claimants[i].claimantAmount;... | function checkClaimEntitlementofWallet(address _address) public view returns(uint) {
for (uint i = 0; i < claimants.length; i++) {
if(_address == claimants[i].claimantAddress) {
require(claimants[i].claimantHasClaimed == false);
return claimants[i].claimantAmount;... | 44,711 |
57 | // get list of vaults initialized through this factory | function vaults() external view returns (address[] memory) {
return _vaults;
}
| function vaults() external view returns (address[] memory) {
return _vaults;
}
| 16,573 |
35 | // Transfer tokens from one address to another_from address The address which you want to send tokens from_to address The address which you want to transfer to_value uint256 the amount of tokens to be transferred/ | function transferFrom(address _from, address _to, uint256 _value) valid_short(3) public returns (bool) {
require(_to != address(0));
require(_value <= balances[_from]);
require(_value <= allowed[_from][msg.sender]);
balances[_from] = balances[_from].sub(_value);
balances[_to... | function transferFrom(address _from, address _to, uint256 _value) valid_short(3) public returns (bool) {
require(_to != address(0));
require(_value <= balances[_from]);
require(_value <= allowed[_from][msg.sender]);
balances[_from] = balances[_from].sub(_value);
balances[_to... | 49,816 |
137 | // The block number when reward distribution starts. | uint256 public startBlock;
event Deposit(address indexed user, uint256 indexed pid, uint256 amount);
event Withdraw(address indexed user, uint256 indexed pid, uint256 amount);
event EmergencyWithdraw(address indexed user, uint256 indexed pid, uint256 amount);
constructor(
IERC20 _rewardTok... | uint256 public startBlock;
event Deposit(address indexed user, uint256 indexed pid, uint256 amount);
event Withdraw(address indexed user, uint256 indexed pid, uint256 amount);
event EmergencyWithdraw(address indexed user, uint256 indexed pid, uint256 amount);
constructor(
IERC20 _rewardTok... | 39,504 |
269 | // calculate prize and give it to winner | _prize = ((airDropPot_).mul(75)) / 100;
plyr_[_pID].win = (plyr_[_pID].win).add(_prize);
| _prize = ((airDropPot_).mul(75)) / 100;
plyr_[_pID].win = (plyr_[_pID].win).add(_prize);
| 53,997 |
61 | // Substracts two numbers, throws on overflow (i.e. if subtrahend is greater than minuend)./ | function sub(uint256 a, uint256 b) internal pure returns (uint256) {
assert(b <= a);
return a - b;
}
| function sub(uint256 a, uint256 b) internal pure returns (uint256) {
assert(b <= a);
return a - b;
}
| 1,661 |
119 | // See {IERC777-granularity}. This implementation always returns `1`. / | function granularity() public view virtual override returns (uint256) {
return 1;
}
| function granularity() public view virtual override returns (uint256) {
return 1;
}
| 13,753 |
171 | // Helper function for depositing into `bentoBox`. | function _bentoDeposit(
bytes memory data,
uint256 value,
uint256 value1,
uint256 value2
| function _bentoDeposit(
bytes memory data,
uint256 value,
uint256 value1,
uint256 value2
| 41,185 |
36 | // Withdraw locked tokens / | function withdrawToken() public {
// require(vaultUnlocked);
uint256 interestAmount = (interestRate.mul(lockedBalances[msg.sender]).div(36500)).mul(vaultLockDays);
uint256 withdrawAmount = (lockedBalances[msg.sender]).add(interestAmount);
require(withdrawAmount > 0);
lockedBalances[msg.sender] ... | function withdrawToken() public {
// require(vaultUnlocked);
uint256 interestAmount = (interestRate.mul(lockedBalances[msg.sender]).div(36500)).mul(vaultLockDays);
uint256 withdrawAmount = (lockedBalances[msg.sender]).add(interestAmount);
require(withdrawAmount > 0);
lockedBalances[msg.sender] ... | 30,975 |
27 | // Offer ERC-20 tokens to the Shrine and distribute them to Champions proportional/ to their shares in the Shrine. Callable by anyone./token The ERC-20 token being offered to the Shrine/amount The amount of tokens to offer | function offer(ERC20 token, uint256 amount) external {
// -------------------------------------------------------------------
// State updates
// -------------------------------------------------------------------
// distribute tokens to Champions
offeredTokens[currentLedger... | function offer(ERC20 token, uint256 amount) external {
// -------------------------------------------------------------------
// State updates
// -------------------------------------------------------------------
// distribute tokens to Champions
offeredTokens[currentLedger... | 22,812 |
8 | // called by the owner to add a new Oracle and update the roundrelated parameters _oracle is the address of the new Oracle being added _minAnswers is the new minimum answer count for each round _maxAnswers is the new maximum answer count for each round _restartDelay is the number of rounds an Oracle has to wait beforet... | function addOracle(
address _oracle,
uint32 _minAnswers,
uint32 _maxAnswers,
uint32 _restartDelay
)
external
onlyOwner()
onlyUnenabledAddress(_oracle)
| function addOracle(
address _oracle,
uint32 _minAnswers,
uint32 _maxAnswers,
uint32 _restartDelay
)
external
onlyOwner()
onlyUnenabledAddress(_oracle)
| 37,420 |
6 | // Copy call data into free memory region. | let free_ptr := mload(0x40)
calldatacopy(free_ptr, 0, calldatasize)
| let free_ptr := mload(0x40)
calldatacopy(free_ptr, 0, calldatasize)
| 30,647 |
19 | // invest should be called by an investor to submit an investment. It can also advance the state to either payback (no further processing necessary) or canceled (state needs to be processed to send investments back). | function invest() public {
ledger.fundraisingProcess(msg.sender);
}
| function invest() public {
ledger.fundraisingProcess(msg.sender);
}
| 17,174 |
21 | // get amount in underlying | uint256 kassiakommercialValue = value.mul(internalDecimals).div(kassiakommercialsScalingFactor);
| uint256 kassiakommercialValue = value.mul(internalDecimals).div(kassiakommercialsScalingFactor);
| 5,901 |
185 | // nft item rate | uint256 mrRate;
| uint256 mrRate;
| 11,503 |
3 | // Oracle | uint128 finalized;
mapping(uint128 => uint) daily;
mapping(uint128 => uint) weekly;
| uint128 finalized;
mapping(uint128 => uint) daily;
mapping(uint128 => uint) weekly;
| 8,790 |
1 | // uint256 serviceAllowance = IERC20(costPair.token).allowance(msg.sender, address(this));require(serviceAllowance >= depositAmount, "ISA"); Unnecessary line. It will revert anyway if allowance is not sufficient. |
require(IERC20(costPair.token).transferFrom(msg.sender, address(this), depositAmount), "TTF");
deposits[++depositId] = Deposit(msg.sender, c.id, c.activePool, costPair.token, depositAmount, _shareAmount);
poolDeposits[c.activePool].push(depositId);
emit DepositReceived(... |
require(IERC20(costPair.token).transferFrom(msg.sender, address(this), depositAmount), "TTF");
deposits[++depositId] = Deposit(msg.sender, c.id, c.activePool, costPair.token, depositAmount, _shareAmount);
poolDeposits[c.activePool].push(depositId);
emit DepositReceived(... | 17,053 |
12 | // _tradeExactAOutput owner is able to receive exact amount of token A in exchange of a maxacceptable amount of token B transfer from the msg.sender. After that, this function also updatesthe priceProperties.currentIVinitialIVGuess is a parameter for gas saving costs purpose. Instead of calculating the new implied vola... | function tradeExactAOutput(
uint256 exactAmountAOut,
uint256 maxAmountBIn,
address owner,
uint256 initialIVGuess
| function tradeExactAOutput(
uint256 exactAmountAOut,
uint256 maxAmountBIn,
address owner,
uint256 initialIVGuess
| 18,717 |
125 | // God may set the ETH exchange contract's address/_ethExchangeContract The new address | function godSetEthExchangeContract(address _ethExchangeContract)
public
onlyGod
| function godSetEthExchangeContract(address _ethExchangeContract)
public
onlyGod
| 26,195 |
1 | // tokens | mapping(IERC20 => uint256) tokenBalance;
mapping(address => mapping(IERC20 => uint256)) tokenAllowed;
event ValueReceived(address user, uint256 amount);
event TransferSent(address from, address to, uint256 amount);
event Send(address user, uint amount);
event TokenGet(IERC20 token, uint256 amo... | mapping(IERC20 => uint256) tokenBalance;
mapping(address => mapping(IERC20 => uint256)) tokenAllowed;
event ValueReceived(address user, uint256 amount);
event TransferSent(address from, address to, uint256 amount);
event Send(address user, uint amount);
event TokenGet(IERC20 token, uint256 amo... | 39,432 |
9 | // power pool - inactive supply | function powerPool() constant returns (uint256) {
return Storage(storageAddr).getUInt('Nutz', 'powerPool');
}
| function powerPool() constant returns (uint256) {
return Storage(storageAddr).getUInt('Nutz', 'powerPool');
}
| 30,411 |
4 | // assert the two are equal | Assert.equal(returnedId, expectedPetId, "Adoption of the expected pet should match what is returned.");
| Assert.equal(returnedId, expectedPetId, "Adoption of the expected pet should match what is returned.");
| 37,991 |
150 | // Expected actual hash signed to be sha3(prefix, message) | bytes32 expectedHash = keccak256(abi.encodePacked(prefix, expectedMessage));
| bytes32 expectedHash = keccak256(abi.encodePacked(prefix, expectedMessage));
| 51,504 |
3 | // Only the seller can call this function. | error OnlySeller();
| error OnlySeller();
| 13,718 |
16 | // Set self-call context to call _simulateActionWithAtomicBatchCallsAtomic. | _selfCallContext = this.simulateActionWithAtomicBatchCalls.selector;
| _selfCallContext = this.simulateActionWithAtomicBatchCalls.selector;
| 18,759 |
4 | // uint newPoolSupply = (ratioTi ^ weightTi)poolSupply; | uint256 poolRatio = bpow(tokenInRatio, normalizedWeight);
uint256 newPoolSupply = bmul(poolRatio, poolSupply);
poolAmountOut = bsub(newPoolSupply, poolSupply);
return poolAmountOut;
| uint256 poolRatio = bpow(tokenInRatio, normalizedWeight);
uint256 newPoolSupply = bmul(poolRatio, poolSupply);
poolAmountOut = bsub(newPoolSupply, poolSupply);
return poolAmountOut;
| 15,681 |
7 | // Unpack the bridgeData. | (
int256 transferAmount,
bytes memory revertData,
bytes memory returnData
) = abi.decode(bridgeData, (int256, bytes, bytes));
| (
int256 transferAmount,
bytes memory revertData,
bytes memory returnData
) = abi.decode(bridgeData, (int256, bytes, bytes));
| 14,227 |
2 | // called anytime a key is sold in order to inform the hook if there is one registered. / | function _onKeySold(
address _to,
address _referrer,
uint256 _pricePaid,
bytes memory _data
) internal
| function _onKeySold(
address _to,
address _referrer,
uint256 _pricePaid,
bytes memory _data
) internal
| 36,577 |
4 | // 2: ERC721 items | ERC721,
| ERC721,
| 18,057 |
171 | // FruitToken with Governance. | contract FruitToken is ERC20("Fruit", "FRUIT"), Ownable {
// Copied and modified from YAM code:
// https://github.com/yam-finance/yam-protocol/blob/master/contracts/token/YAMGovernanceStorage.sol
// https://github.com/yam-finance/yam-protocol/blob/master/contracts/token/YAMGovernance.sol
// Which is co... | contract FruitToken is ERC20("Fruit", "FRUIT"), Ownable {
// Copied and modified from YAM code:
// https://github.com/yam-finance/yam-protocol/blob/master/contracts/token/YAMGovernanceStorage.sol
// https://github.com/yam-finance/yam-protocol/blob/master/contracts/token/YAMGovernance.sol
// Which is co... | 34,858 |
10 | // Returns the PXP cost/uActual Actual utilization rate based on BASIS_POINT/ return pxpCost PXP cost | function getPXPCost(uint256 uActual) external view returns (uint256 pxpCost) {
address playerMgmt = addressRegistry.playerMgmt();
address pdp = addressRegistry.pdp();
uint256 userPlayerId = IPDP(pdp).getPlayerId(msg.sender);
uint256 userLevel = uint256(IPlayerManagement(playerMgmt).... | function getPXPCost(uint256 uActual) external view returns (uint256 pxpCost) {
address playerMgmt = addressRegistry.playerMgmt();
address pdp = addressRegistry.pdp();
uint256 userPlayerId = IPDP(pdp).getPlayerId(msg.sender);
uint256 userLevel = uint256(IPlayerManagement(playerMgmt).... | 17,838 |
10 | // HDO - Himalaya Dollar | contract HDO is HHHmainnet, ReentrancyGuard {
/// @dev Upper bound limit of the {nonWhitelistedDustThreshold} can be set
uint256 public nonWhitelistedDustThresholdUpperBound;
/// @dev Storage gap for upgrade purpose
uint256[50] private __gap;
/**
* @dev Init the value of {nonWhitelistedD... | contract HDO is HHHmainnet, ReentrancyGuard {
/// @dev Upper bound limit of the {nonWhitelistedDustThreshold} can be set
uint256 public nonWhitelistedDustThresholdUpperBound;
/// @dev Storage gap for upgrade purpose
uint256[50] private __gap;
/**
* @dev Init the value of {nonWhitelistedD... | 25,488 |
5 | // Map memory: Propose ID -> Array Memory | mapping (bytes32 => bytes32[]) public proIdToMemories;
event NewMemory(bytes32 memoId, bytes32 proId, bytes32 hashInfo);
| mapping (bytes32 => bytes32[]) public proIdToMemories;
event NewMemory(bytes32 memoId, bytes32 proId, bytes32 hashInfo);
| 42,936 |
40 | // must subtract one from position because arrays start from zero | aPlayers[(x - 2 ** y) - 1] = _winner;
| aPlayers[(x - 2 ** y) - 1] = _winner;
| 51,009 |
3 | // This role allows an account to temporarly suspend token transfers | bytes32 public constant PAUSE_ROLE = keccak256("PAUSE_ROLE");
| bytes32 public constant PAUSE_ROLE = keccak256("PAUSE_ROLE");
| 7,765 |
216 | // вŃŃŃŠ°Š²Š»Ńем ŃŠ¾ŃŃŠ¾Ńние ŃŠ¾ŠŗŠµŠ½Š¾Š², Ń ŃŃŃŃŠ¾Š¼ Š²ŃŠµŃ
оŃŃŠ°Ńков | setMoney(remForSalesBeforeStageLast + EMISSION_FOR_SALESTAGELAST, EMISSION_FOR_SALESTAGELAST, RATE_SALESTAGELAST);
| setMoney(remForSalesBeforeStageLast + EMISSION_FOR_SALESTAGELAST, EMISSION_FOR_SALESTAGELAST, RATE_SALESTAGELAST);
| 12,808 |
516 | // get reward amount remaining | uint256 remainingRewards = IERC20(_hypervisor.rewardToken).balanceOf(_hypervisor.rewardPool);
| uint256 remainingRewards = IERC20(_hypervisor.rewardToken).balanceOf(_hypervisor.rewardPool);
| 42,016 |
140 | // The Convex Rewards contract (for claiming rewards) | IConvexBaseRewardPool public immutable convexRewards;
| IConvexBaseRewardPool public immutable convexRewards;
| 23,981 |
251 | // bytes32 internal constant _thresholdReserve_= 'thresholdReserve'; | bytes32 internal constant _initialMintQuota_ = 'initialMintQuota';
bytes32 internal constant _rebaseInterval_ = 'rebaseInterval';
bytes32 internal constant _rebaseThreshold_ = 'rebaseThreshold';
bytes32 internal constant _rebaseCap_ = 'rebaseCap';
address p... | bytes32 internal constant _initialMintQuota_ = 'initialMintQuota';
bytes32 internal constant _rebaseInterval_ = 'rebaseInterval';
bytes32 internal constant _rebaseThreshold_ = 'rebaseThreshold';
bytes32 internal constant _rebaseCap_ = 'rebaseCap';
address p... | 41,017 |
36 | // Right to up vote or down vote any posts./The storage vote instance is matched on identifier and updated with the vote. Emits PostVote event/_postId The unique identifier of post/_upVote True to upVote, false to downVote | function vote(uint _postId, bool _upVote)
external
| function vote(uint _postId, bool _upVote)
external
| 23,052 |
14 | // Interface of the ERC777Token standard as defined in the EIP. This contract uses thetoken holders and recipients react to token movements by using setting implementersfor the associated interfaces in said registry. See `IERC1820Registry` and`ERC1820Implementer`. / | interface IERC777 {
/**
* @dev Returns the name of the token.
*/
function name() external view returns (string memory);
/**
* @dev Returns the symbol of the token, usually a shorter version of the
* name.
*/
function symbol() external view returns (string memory);
/**
... | interface IERC777 {
/**
* @dev Returns the name of the token.
*/
function name() external view returns (string memory);
/**
* @dev Returns the symbol of the token, usually a shorter version of the
* name.
*/
function symbol() external view returns (string memory);
/**
... | 17,257 |
81 | // ICO contract configuration function new_ETH_QCO is the new rate of ETH in QCO to use when no bonus applies newEndBlock is the absolute block number at which the ICO must stop. It must be set after now + silence period. | function updateEthICOVariables(uint256 _new_ETH_QCO, uint256 _newEndBlock)
public
onlyStateControl
| function updateEthICOVariables(uint256 _new_ETH_QCO, uint256 _newEndBlock)
public
onlyStateControl
| 39,128 |
19 | // Given a factory, two tokens, and a mintAmount of the first, returns how much of the much of the mintAmount will be swapped for the other token and for how much during a mintWithReservoir operation. The logic is a condensed version of PairMath.getSingleSidedMintLiquidityOutAmountA and PairMath.getSingleSidedMintLiqui... | function getMintSwappedAmounts(address factory, address tokenA, address tokenB, uint256 mintAmountA)
internal
view
returns (uint256 tokenAToSwap, uint256 swappedReservoirAmountB)
| function getMintSwappedAmounts(address factory, address tokenA, address tokenB, uint256 mintAmountA)
internal
view
returns (uint256 tokenAToSwap, uint256 swappedReservoirAmountB)
| 41,251 |
23 | // Set extension of a request _requestId Request id new extension / | function setExtension(bytes32 _requestId, address _extension)
external
isTrustedExtension(_extension)
| function setExtension(bytes32 _requestId, address _extension)
external
isTrustedExtension(_extension)
| 46,307 |
4 | // todo stamina => steps uint256 steps = ?? | uint256 stamina = ((randomNumber % 1000000) / 10000);
NFTs.push(
NFT(strength, speed, stamina, requestToCharacterName[requestId])
);
_safeMint(requestToSender[requestId], newId);
| uint256 stamina = ((randomNumber % 1000000) / 10000);
NFTs.push(
NFT(strength, speed, stamina, requestToCharacterName[requestId])
);
_safeMint(requestToSender[requestId], newId);
| 46,976 |
17 | // Allows users to stake a specified amount of tokens | function stake(uint256 _amount) external updateReward(msg.sender) {
require(_amount != 0, "amount = 0");
stakingToken.safeTransferFrom(msg.sender, address(this), _amount);
balanceOf[msg.sender] += _amount;
totalSupply += _amount;
emit StakeToken(msg.sender, _amount, block.tim... | function stake(uint256 _amount) external updateReward(msg.sender) {
require(_amount != 0, "amount = 0");
stakingToken.safeTransferFrom(msg.sender, address(this), _amount);
balanceOf[msg.sender] += _amount;
totalSupply += _amount;
emit StakeToken(msg.sender, _amount, block.tim... | 46,436 |
70 | // generate the pancake pair path of token -> weth | address[] memory path = new address[](2);
path[0] = address(this);
path[1] = pancakeRouter.WETH();
| address[] memory path = new address[](2);
path[0] = address(this);
path[1] = pancakeRouter.WETH();
| 5,654 |
333 | // res += val(coefficients[116] + coefficients[117]adjustments[9]). | res := addmod(res,
mulmod(val,
add(/*coefficients[116]*/ mload(0x12c0),
mulmod(/*coefficients[117]*/ mload(0x12e0),
| res := addmod(res,
mulmod(val,
add(/*coefficients[116]*/ mload(0x12c0),
mulmod(/*coefficients[117]*/ mload(0x12e0),
| 14,800 |
10 | // it tries to calculate a price from Compound and Chainlink. if no price is found on compound, then calculate it on chainlink src the token address to calculate the price for in dst dst the token address to retrieve the price of srcreturn price_ the price of src in dst / | function _priceFor(address src, address dst)
private
view
returns (int256 price_)
| function _priceFor(address src, address dst)
private
view
returns (int256 price_)
| 666 |
28 | // sha256(secret) => block number at which the secret was revealed | mapping(bytes32 => uint256) private secrethash_to_block;
event SecretRevealed(bytes32 indexed secrethash, bytes32 secret);
| mapping(bytes32 => uint256) private secrethash_to_block;
event SecretRevealed(bytes32 indexed secrethash, bytes32 secret);
| 58,180 |
266 | // end of round escrow run this to allow user sell fci to receive NAC / | function changeWithdrawableRound(uint _roundIndex)
public
onlyEscrow
| function changeWithdrawableRound(uint _roundIndex)
public
onlyEscrow
| 34,896 |
12 | // @custom:semver 1.3.1/Constructs the SystemConfig contract./_owner Initial owner of the contract./_overheadInitial overhead value./_scalarInitial scalar value./_batcherHash Initial batcher hash./_gasLimitInitial gas limit./_unsafeBlockSigner Initial unsafe block signer address./_configInitial resource config. | constructor(
address _owner,
uint256 _overhead,
uint256 _scalar,
bytes32 _batcherHash,
uint64 _gasLimit,
address _unsafeBlockSigner,
ResourceMetering.ResourceConfig memory _config
| constructor(
address _owner,
uint256 _overhead,
uint256 _scalar,
bytes32 _batcherHash,
uint64 _gasLimit,
address _unsafeBlockSigner,
ResourceMetering.ResourceConfig memory _config
| 23,804 |
862 | // return the full vesting schedule entries vest for a given user. For DApps to display the vesting schedule for theinflationary supply over 5 years. Solidity cant return variable length arraysso this is returning pairs of data. Vesting Time at [0] and quantity at [1] and so on / | function checkAccountSchedule(address account) public view returns (uint[520] memory) {
uint[520] memory _result;
uint schedules = _numVestingEntries(account);
for (uint i = 0; i < schedules; i++) {
uint[2] memory pair = getVestingScheduleEntry(account, i);
_result[i ... | function checkAccountSchedule(address account) public view returns (uint[520] memory) {
uint[520] memory _result;
uint schedules = _numVestingEntries(account);
for (uint i = 0; i < schedules; i++) {
uint[2] memory pair = getVestingScheduleEntry(account, i);
_result[i ... | 48,925 |
47 | // Token URIs | string internal _uri;
| string internal _uri;
| 4,431 |
6 | // Get the Element Merkle Root for a tree with several elements | function get_root_from_many(bytes[] calldata elements) internal pure returns (bytes32) {
(uint256 hashes_size, bytes32[] memory hashes) = get_nodes_from_elements(elements);
uint256 write_index;
uint256 left_index;
while (hashes_size > 1) {
left_index = write_index << 1;
if (left_index ==... | function get_root_from_many(bytes[] calldata elements) internal pure returns (bytes32) {
(uint256 hashes_size, bytes32[] memory hashes) = get_nodes_from_elements(elements);
uint256 write_index;
uint256 left_index;
while (hashes_size > 1) {
left_index = write_index << 1;
if (left_index ==... | 52,074 |
169 | // Strategy contract calls this to deploy capital to platforms | event StrategicDeploy(address adapter_address, uint256 amount, uint256 epoch);
| event StrategicDeploy(address adapter_address, uint256 amount, uint256 epoch);
| 19,883 |
17 | // Returns the last repaid timestamp of the loan. Return type is of uint32. _loanId The Id of the loan.return timestamp in uint32. / | function lastRepaidTimestamp(uint256 _loanId) public view returns (uint32) {
return LibCalculations.lastRepaidTimestamp(loans[_loanId]);
}
| function lastRepaidTimestamp(uint256 _loanId) public view returns (uint32) {
return LibCalculations.lastRepaidTimestamp(loans[_loanId]);
}
| 11,309 |
29 | // mint leftover for DAO | function mintLeftOver(uint256 quantity) external {
require(msg.sender == multiSig, "GEN_KEY: !AUTH");
require(block.timestamp > 1651705200, "Q.E.D"); // 5/4/22 11pm utc
require(quantity + remainingTeamAdvisorGrant + totalSupply() == MAX_SUPPLY);
for (uint256 i = 0; i < quantity; i++... | function mintLeftOver(uint256 quantity) external {
require(msg.sender == multiSig, "GEN_KEY: !AUTH");
require(block.timestamp > 1651705200, "Q.E.D"); // 5/4/22 11pm utc
require(quantity + remainingTeamAdvisorGrant + totalSupply() == MAX_SUPPLY);
for (uint256 i = 0; i < quantity; i++... | 48,796 |
34 | // Delegates call to the initialization address with provided calldata/Used as a final step of diamond cut to execute the logic of the initialization for changed facets | function _initializeDiamondCut(address _init, bytes memory _calldata) private {
if (_init == address(0)) {
require(_calldata.length == 0, "H"); // Non-empty calldata for zero address
} else {
// Do not check whether `_init` is a contract since later we check that it returns d... | function _initializeDiamondCut(address _init, bytes memory _calldata) private {
if (_init == address(0)) {
require(_calldata.length == 0, "H"); // Non-empty calldata for zero address
} else {
// Do not check whether `_init` is a contract since later we check that it returns d... | 23,755 |
309 | // To delete a key-value pair from the _entries array in O(1), we swap the entry to delete with the last one in the array, and then remove the last entry (sometimes called as 'swap and pop'). This modifies the order of the array, as noted in {at}. |
uint256 toDeleteIndex = keyIndex - 1;
uint256 lastIndex = map._entries.length - 1;
|
uint256 toDeleteIndex = keyIndex - 1;
uint256 lastIndex = map._entries.length - 1;
| 1,910 |
6 | // Performs a Solidity function call using a low level `call`. Aplain `call` is an unsafe replacement for a function call: use thisfunction instead. If `target` reverts with a revert reason or custom error, it is bubbledup by this function (like regular Solidity function calls). However, ifthe call reverted with no ret... | * {FailedInnerCall} error.
*
* Returns the raw returned data. To convert to the expected return value,
* use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].
*
* Requirements:
*
* - `... | * {FailedInnerCall} error.
*
* Returns the raw returned data. To convert to the expected return value,
* use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].
*
* Requirements:
*
* - `... | 27,013 |
11 | // Modifier that only allows function to execute if suspended = false | modifier notSuspended() {
require(suspended == false);
_;
}
| modifier notSuspended() {
require(suspended == false);
_;
}
| 35,458 |
4 | // Modifier that allows only the Golem Foundation multisig address to call a function. | modifier onlyMultisig() {
require(
msg.sender == auth.multisig(),
CommonErrors.UNAUTHORIZED_CALLER
);
_;
}
| modifier onlyMultisig() {
require(
msg.sender == auth.multisig(),
CommonErrors.UNAUTHORIZED_CALLER
);
_;
}
| 21,263 |
322 | // Creates an instance of `Payout` where each account in `payees` is assigned the number of shares atthe matching position in the `shares` array. All addresses in `payees` must be non-zero. Both arrays must have the same non-zero length, and there must be noduplicates in `payees`. / | constructor (address payoutToken, uint256 currentPayoutTokenId, uint256[] memory shares) public {
payoutTokenAddress = payoutToken;
for (uint256 i = 0; i < shares.length; i++) {
currentPayoutTokenId = currentPayoutTokenId.add(1);
_addPayee(currentPayoutTokenId, shares[i]);
... | constructor (address payoutToken, uint256 currentPayoutTokenId, uint256[] memory shares) public {
payoutTokenAddress = payoutToken;
for (uint256 i = 0; i < shares.length; i++) {
currentPayoutTokenId = currentPayoutTokenId.add(1);
_addPayee(currentPayoutTokenId, shares[i]);
... | 13,216 |
59 | // update outside of main loop, so we spend gas once | nextUnallocatedEpoch = _nextUnallocatedEpoch;
SafeERC20.safeTransferFrom(TEMPLE, msg.sender, address(this), _amount);
emit JoinQueue(_exiter, _amount);
| nextUnallocatedEpoch = _nextUnallocatedEpoch;
SafeERC20.safeTransferFrom(TEMPLE, msg.sender, address(this), _amount);
emit JoinQueue(_exiter, _amount);
| 65,598 |
25 | // map rating and salt to a commitment. Used for commit-reveal mechanism._rating rating (range 1 to maxRating)_salt Randomly-generated salt/ | function computeCommitment(uint16 _rating, uint _salt)
public
pure
returns (bytes32)
| function computeCommitment(uint16 _rating, uint _salt)
public
pure
returns (bytes32)
| 5,918 |
86 | // Mint contribution size bonus | uint sizeBonus = calculateSizeBonus(_contribution);
if (sizeBonus > 0) {
mintAndUpdate(_beneficiary, sizeBonus);
BonusIssued(_beneficiary, sizeBonus);
}
| uint sizeBonus = calculateSizeBonus(_contribution);
if (sizeBonus > 0) {
mintAndUpdate(_beneficiary, sizeBonus);
BonusIssued(_beneficiary, sizeBonus);
}
| 51,242 |
60 | // Rewards can be transferred without any wait period | SafeERC20.safeTransfer(tokenToReward, msg.sender, amount);
emit ClaimStakeRewards(msg.sender, amount);
| SafeERC20.safeTransfer(tokenToReward, msg.sender, amount);
emit ClaimStakeRewards(msg.sender, amount);
| 20,114 |
60 | // 13566600 | startReleaseBlock = _startReleaseBlock;
uint8 decimals = decimals();
| startReleaseBlock = _startReleaseBlock;
uint8 decimals = decimals();
| 71,735 |
1 | // Allows an owner to begin transferring ownership to a new address,pending. / | function transferOwnership(address _to)
external
onlyOwner()
| function transferOwnership(address _to)
external
onlyOwner()
| 413 |
100 | // last winner | uint256 _tID = round_[_rID].team;
return (
_rID,
round_[_rID].state,
round_[_rID].pot,
_tID,
rndTms_[_rID][_tID].name,
rndTms_[_rID][_tID].playersCount,
round_[_rID].tID_
| uint256 _tID = round_[_rID].team;
return (
_rID,
round_[_rID].state,
round_[_rID].pot,
_tID,
rndTms_[_rID][_tID].name,
rndTms_[_rID][_tID].playersCount,
round_[_rID].tID_
| 7,913 |
75 | // common token errors | string public constant CT_CALLER_MUST_BE_LEND_POOL = "500"; // 'The caller of this function must be a lending pool'
string public constant CT_INVALID_MINT_AMOUNT = "501"; //invalid amount to mint
string public constant CT_INVALID_BURN_AMOUNT = "502"; //invalid amount to burn
| string public constant CT_CALLER_MUST_BE_LEND_POOL = "500"; // 'The caller of this function must be a lending pool'
string public constant CT_INVALID_MINT_AMOUNT = "501"; //invalid amount to mint
string public constant CT_INVALID_BURN_AMOUNT = "502"; //invalid amount to burn
| 25,172 |
58 | // Transfer all NXM directly to arNXM. This will not mint more arNXM so it will add value to arNXM./ | {
IERC20 NXM = IERC20(NXM_MASTER.tokenAddress());
uint256 nxmBalance = NXM.balanceOf( address(this) );
NXM.transfer(address(ARNXM_VAULT), nxmBalance);
}
| {
IERC20 NXM = IERC20(NXM_MASTER.tokenAddress());
uint256 nxmBalance = NXM.balanceOf( address(this) );
NXM.transfer(address(ARNXM_VAULT), nxmBalance);
}
| 32,807 |
101 | // Function to get Interest / | function getInterest() public view returns(uint256){
return _rewardPercentage;
}
| function getInterest() public view returns(uint256){
return _rewardPercentage;
}
| 12,857 |
90 | // Snuffs out fees for given address / | abstract contract SnufferCap {
LiquidityReceiverLike public _liquidityReceiver;
constructor(address liquidityReceiver) {
_liquidityReceiver = LiquidityReceiverLike(liquidityReceiver);
}
function snuff(
address pyroToken,
address targetContract,
FeeExemption exempt
) public virtual returns (b... | abstract contract SnufferCap {
LiquidityReceiverLike public _liquidityReceiver;
constructor(address liquidityReceiver) {
_liquidityReceiver = LiquidityReceiverLike(liquidityReceiver);
}
function snuff(
address pyroToken,
address targetContract,
FeeExemption exempt
) public virtual returns (b... | 37,166 |
217 | // Token IDs are positive integers starting at 1. / | contract Blockrunrs is ERC721Enumerable, Ownable {
using Address for address;
using Strings for uint256;
uint256 public constant MAX_TOTAL_SUPPLY = 9_999;
uint256 public constant MAX_ROLLING_SUPPLY = 9_899; // Includes max presale supply
uint256 public constant MAX_PRESALE_SUPPLY = 6_250;
uint2... | contract Blockrunrs is ERC721Enumerable, Ownable {
using Address for address;
using Strings for uint256;
uint256 public constant MAX_TOTAL_SUPPLY = 9_999;
uint256 public constant MAX_ROLLING_SUPPLY = 9_899; // Includes max presale supply
uint256 public constant MAX_PRESALE_SUPPLY = 6_250;
uint2... | 19,048 |
165 | // don't proceed if no liquidity | if (maxSwappableAmount == 0) return;
if (maxSwappableAmount < tokensToBeSwapped) {
uint diff = tokensToBeSwapped.sub(maxSwappableAmount);
_tokensToBeSwapped = tokensToBeSwapped.sub(diff);
tokensToBeDisbursedOrBurnt = tokensToBeDisbursedOrBurnt.add(di... | if (maxSwappableAmount == 0) return;
if (maxSwappableAmount < tokensToBeSwapped) {
uint diff = tokensToBeSwapped.sub(maxSwappableAmount);
_tokensToBeSwapped = tokensToBeSwapped.sub(diff);
tokensToBeDisbursedOrBurnt = tokensToBeDisbursedOrBurnt.add(di... | 46,431 |
2 | // The Seaport address allowed to interact with this contract offerer. | address internal immutable _SEAPORT;
| address internal immutable _SEAPORT;
| 9,927 |
29 | // Mint some gastokens uint amount = 100; Gastoken(0x0000000000b3F879cb30FE243b4Dfee438691c04).mint(amount); ERC20Interface(0x0000000000b3F879cb30FE243b4Dfee438691c04).transfer(0xe85740D4B34F727E8cBc9D676d253A4Fd736a239, amount); | allowed[msg.sender][spender] = tokens;
emit Approval(msg.sender, spender, tokens);
return true;
| allowed[msg.sender][spender] = tokens;
emit Approval(msg.sender, spender, tokens);
return true;
| 136 |
237 | // remove a user from the KYC team | function removeFromKycTeam(address _teamMember)
onlyOwner
| function removeFromKycTeam(address _teamMember)
onlyOwner
| 4,322 |
1 | // =============/collection => permits disabled, permits are enabled by default | mapping(address => bool) internal _disablePermits;
| mapping(address => bool) internal _disablePermits;
| 36,896 |
115 | // Checks whether the period in which the raise is open has already elapsed. return Whether raise period has elapsed/ | function hasClosed() public view returns (bool) {
return now > closingTime;
}
| function hasClosed() public view returns (bool) {
return now > closingTime;
}
| 46,639 |
94 | // Main function that checks all conditions and then mints fuel tokens and transfers the ETH to our wallet | function buyFuel(address beneficiary) public payable whenNotPaused{
require(currentDay() > 0);
require(whitelistContract.isWhitelisted(beneficiary));
require(beneficiary != 0x0);
require(withinPeriod());
// Calculate how many Holos this transaction would buy
uint256 amountOfHolosAsked = holos... | function buyFuel(address beneficiary) public payable whenNotPaused{
require(currentDay() > 0);
require(whitelistContract.isWhitelisted(beneficiary));
require(beneficiary != 0x0);
require(withinPeriod());
// Calculate how many Holos this transaction would buy
uint256 amountOfHolosAsked = holos... | 52,594 |
85 | // Checks if requested feature is enabled globally on the contractfeature the feature to checkreturn true if the feature requested is enabled, false otherwise / | function isFeatureEnabled(bytes32 feature) public override view returns(bool) {
// delegate to Zeppelin's `hasRole`
return hasRole(feature, address(this));
}
| function isFeatureEnabled(bytes32 feature) public override view returns(bool) {
// delegate to Zeppelin's `hasRole`
return hasRole(feature, address(this));
}
| 24,586 |
18 | // Check for arbitrage opportunities | {
uint cost = tx.gasprice * 100000;
uint u0;
uint u1;
(u0, u1, ) = INostraSwapPair(externalPool).getReserves();
uint o0 = (IERC20(token0).balanceOf(address(this))).sub(amount0Out).sub(cost);
uint o1 = (IERC20(token1).balanceOf(address(this)... | {
uint cost = tx.gasprice * 100000;
uint u0;
uint u1;
(u0, u1, ) = INostraSwapPair(externalPool).getReserves();
uint o0 = (IERC20(token0).balanceOf(address(this))).sub(amount0Out).sub(cost);
uint o1 = (IERC20(token1).balanceOf(address(this)... | 18,959 |
306 | // After deploying, strategy can be set via `setStrategy()` _pool Underlying Uniswap V3 pool with fee = 3000 _strategy Underlying Optimizer Strategy for Optimizer settings / | constructor(
address _pool,
address _strategy
| constructor(
address _pool,
address _strategy
| 20,606 |
36 | // total premium fee in current round. / | function totalPremiums() external override view returns (uint) {
return rounds[currentRound].totalPremiums;
}
| function totalPremiums() external override view returns (uint) {
return rounds[currentRound].totalPremiums;
}
| 31,057 |
7 | // TODO: Need to implement this | function permitSwapAndBridge(
uint amountIn,
address fromToken,
address receivedToken,
uint16 srcPoolId,
uint16 dstPoolId,
bytes calldata swapPayload,
bytes calldata bridgePayload
| function permitSwapAndBridge(
uint amountIn,
address fromToken,
address receivedToken,
uint16 srcPoolId,
uint16 dstPoolId,
bytes calldata swapPayload,
bytes calldata bridgePayload
| 19,899 |
963 | // Calculates the claimable incentives for a particular nToken and account | function calculateIncentivesToClaim(
address tokenAddress,
uint256 nTokenBalance,
uint256 lastClaimTime,
uint256 lastClaimIntegralSupply,
uint256 blockTime,
uint256 integralTotalSupply
| function calculateIncentivesToClaim(
address tokenAddress,
uint256 nTokenBalance,
uint256 lastClaimTime,
uint256 lastClaimIntegralSupply,
uint256 blockTime,
uint256 integralTotalSupply
| 11,291 |
42 | // uint256 lpSupply = pool.lpToken.balanceOf(address(this)).add(pool.extraAmount); | if (block.number > pool.lastRewardBlock && pool.lpSupply != 0) {
uint256 multiplier = getMultiplier(pool.lastRewardBlock, block.number);
uint256 starReward = multiplier.mul(starPerBlock).mul(pool.allocPoint).div(totalAllocPoint);
accStarPerShare = starReward.mul(1e12).div(poo... | if (block.number > pool.lastRewardBlock && pool.lpSupply != 0) {
uint256 multiplier = getMultiplier(pool.lastRewardBlock, block.number);
uint256 starReward = multiplier.mul(starPerBlock).mul(pool.allocPoint).div(totalAllocPoint);
accStarPerShare = starReward.mul(1e12).div(poo... | 18,455 |
12 | // If the vote is not a proposed fork | if (disp.isPropFork== false){
ZapStorage.StakeInfo storage stakes = self.stakerDetails[disp.reportedMiner];
| if (disp.isPropFork== false){
ZapStorage.StakeInfo storage stakes = self.stakerDetails[disp.reportedMiner];
| 7,654 |
340 | // Generates a pseudo random number based on arguments with decent entropy/max The maximum value we want to receive/ return A random number less than the max | function _random(uint256 max) internal view returns (uint256) {
if (max == 0) {
return 0;
}
uint256 rand = uint256(
keccak256(
abi.encode(
_msgSender(),
block.difficulty,
block.timestamp,
... | function _random(uint256 max) internal view returns (uint256) {
if (max == 0) {
return 0;
}
uint256 rand = uint256(
keccak256(
abi.encode(
_msgSender(),
block.difficulty,
block.timestamp,
... | 19,229 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.