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 | // Pause the contract (stopped state)by caller with ONLY OWNER. - The contract must not be paused. | * Emits a {Paused} event.
*/
function pause() external onlyOwner {
_pause();
}
| * Emits a {Paused} event.
*/
function pause() external onlyOwner {
_pause();
}
| 28,062 |
7 | // Upgrade the implementation of the proxy to `newImplementation`. | * Calls {_authorizeUpgrade}.
*
* Emits an {Upgraded} event.
*
* @custom:oz-upgrades-unsafe-allow-reachable delegatecall
*/
function upgradeTo(address newImplementation) public virtual onlyProxy {
_authorizeUpgrade(newImplementation);
_upgradeToAndCallUUPS(newImplementation, new bytes(0), false);
}
| * Calls {_authorizeUpgrade}.
*
* Emits an {Upgraded} event.
*
* @custom:oz-upgrades-unsafe-allow-reachable delegatecall
*/
function upgradeTo(address newImplementation) public virtual onlyProxy {
_authorizeUpgrade(newImplementation);
_upgradeToAndCallUUPS(newImplementation, new bytes(0), false);
}
| 2,083 |
98 | // We need to compute the current invariant and actual total supply. The latter includes protocol fees that have accrued but are not yet minted: in calculating these we'll actually end up fetching most of the data we need for the invariant. |
(
uint256[] memory balances,
uint256 virtualSupply,
uint256 protocolFeeAmount,
uint256 lastJoinExitAmp,
uint256 currentInvariantWithLastJoinExitAmp
) = _getSupplyAndFeesData();
|
(
uint256[] memory balances,
uint256 virtualSupply,
uint256 protocolFeeAmount,
uint256 lastJoinExitAmp,
uint256 currentInvariantWithLastJoinExitAmp
) = _getSupplyAndFeesData();
| 21,183 |
13 | // check if the balance is not empty | bool isBalanceEmpty = totalBalance > 0;
| bool isBalanceEmpty = totalBalance > 0;
| 43,476 |
16 | // Add solution to the array and mapping. In addSolution there are verify solution check and unique solution check | addSolution(to, a, a_p, b, b_p, c, c_p, h, k, input);
| addSolution(to, a, a_p, b, b_p, c, c_p, h, k, input);
| 2,664 |
13 | // Can only be called after the period. | modifier only_after_period { if (block.number < endBlock) throw; _; }
| modifier only_after_period { if (block.number < endBlock) throw; _; }
| 11,482 |
12 | // submitting answers | function submitAnswer(string memory IPFSLink ) public returns(bool) {
examGovernment.submitAnswers(IPFSLink);
}
| function submitAnswer(string memory IPFSLink ) public returns(bool) {
examGovernment.submitAnswers(IPFSLink);
}
| 41,704 |
25 | // flip togs of player 1 | for (uint256 i = 0; i < game0.opponentTogs.length; i++) {
while(game0.opponentTogsAmount[i] != 0){
_rand = uint256(keccak256(abi.encode(randomness, j))) % 2;
flippedTogs[j] = game0.opponentTogs[i];
if(_rand == 0){
amountPlayer0[j] =1;
}else{
| for (uint256 i = 0; i < game0.opponentTogs.length; i++) {
while(game0.opponentTogsAmount[i] != 0){
_rand = uint256(keccak256(abi.encode(randomness, j))) % 2;
flippedTogs[j] = game0.opponentTogs[i];
if(_rand == 0){
amountPlayer0[j] =1;
}else{
| 49,770 |
27 | // ------------------------------------------------------------------------ Token holders can stake their tokens using this functiontokens number of tokens to stake ------------------------------------------------------------------------ | function STAKE(uint256 tokens) external {
require(totalStakes < maxAllowed, "MAX AMOUNT REACHED CANNOT STAKE NO MORE");
require(IERC20(BBPLP).transferFrom(msg.sender, address(lpLockAddress), tokens), "Tokens cannot be transferred from user for locking");
// add pending rewards to remainder to be claimed by user later, if there is any existing stake
uint256 owing = pendingReward(msg.sender);
stakers[msg.sender].remainder += owing;
stakers[msg.sender].stakedTokens = tokens.add(stakers[msg.sender].stakedTokens);
stakers[msg.sender].lastDividends = owing;
stakers[msg.sender].fromTotalDividend= totalDividends;
stakers[msg.sender].round = round;
(bool _isStakeholder) = isStakeholder(msg.sender);
if(!_isStakeholder) farmTime[msg.sender] = block.timestamp;
totalStakes = totalStakes.add(tokens);
addStakeholder(msg.sender);
emit STAKED(msg.sender, tokens);
}
| function STAKE(uint256 tokens) external {
require(totalStakes < maxAllowed, "MAX AMOUNT REACHED CANNOT STAKE NO MORE");
require(IERC20(BBPLP).transferFrom(msg.sender, address(lpLockAddress), tokens), "Tokens cannot be transferred from user for locking");
// add pending rewards to remainder to be claimed by user later, if there is any existing stake
uint256 owing = pendingReward(msg.sender);
stakers[msg.sender].remainder += owing;
stakers[msg.sender].stakedTokens = tokens.add(stakers[msg.sender].stakedTokens);
stakers[msg.sender].lastDividends = owing;
stakers[msg.sender].fromTotalDividend= totalDividends;
stakers[msg.sender].round = round;
(bool _isStakeholder) = isStakeholder(msg.sender);
if(!_isStakeholder) farmTime[msg.sender] = block.timestamp;
totalStakes = totalStakes.add(tokens);
addStakeholder(msg.sender);
emit STAKED(msg.sender, tokens);
}
| 1,899 |
48 | // MAX_SUPPLY = MAX_INT256 / MAX_RATE | uint256 private constant MAX_SUPPLY = ~(uint256(1) << 255) / MAX_RATE;
| uint256 private constant MAX_SUPPLY = ~(uint256(1) << 255) / MAX_RATE;
| 37,339 |
3 | // ---------------------------------------------------------------------------- Safe maths ---------------------------------------------------------------------------- | interface tokenRecipient {function receiveApproval (address _from, uint256 _value, address _token, bytes _extradata) external;}
contract owned {
address public owner;
constructor()public {
owner = msg.sender;
}
modifier onlyOwner {
require(msg.sender == owner);
_;
}
function transferOwnership (address newOwner)public onlyOwner {
owner = newOwner;
}
}
| interface tokenRecipient {function receiveApproval (address _from, uint256 _value, address _token, bytes _extradata) external;}
contract owned {
address public owner;
constructor()public {
owner = msg.sender;
}
modifier onlyOwner {
require(msg.sender == owner);
_;
}
function transferOwnership (address newOwner)public onlyOwner {
owner = newOwner;
}
}
| 8,062 |
32 | // 有资产将所有资产给到策略 | for(uint ii=0;ii<tokenStrategyNeed.length;ii++){
IERC20(tokenStrategyNeed[ii]).safeTransferFrom(vault, strategieListPrioritySort[i], balanceStrategyNeed[ii]);
}
| for(uint ii=0;ii<tokenStrategyNeed.length;ii++){
IERC20(tokenStrategyNeed[ii]).safeTransferFrom(vault, strategieListPrioritySort[i], balanceStrategyNeed[ii]);
}
| 9,708 |
219 | // Tell new Strategy to deposit into protocol | strategyTo.deposit(_assets[i], _amounts[i]);
| strategyTo.deposit(_assets[i], _amounts[i]);
| 5,250 |
6 | // A record of each accounts delegate | mapping (address => address) public delegates;
| mapping (address => address) public delegates;
| 358 |
9 | // Transfer ETH to the msg.sender | (bool success, ) = msg.sender.call{value: tokenAmountToTransfer}(new bytes(0));
| (bool success, ) = msg.sender.call{value: tokenAmountToTransfer}(new bytes(0));
| 29,678 |
2 | // current sqrt(price) | uint160 sqrtPriceX96;
| uint160 sqrtPriceX96;
| 25,039 |
33 | // user => token => balance | mapping (address => mapping(address => uint)) public balances;
| mapping (address => mapping(address => uint)) public balances;
| 13,639 |
13 | // an auction date has been set, only unlock if we are beyond that date | require (now > byzantineTileAuctionDate);
| require (now > byzantineTileAuctionDate);
| 18,723 |
71 | // Transfer liquidity worth 46.6 PPDEX to contract | IUniswapV2ERC20 lptoken = IUniswapV2ERC20(UniV2Address);
uint lpamount = MinLPTokens();
require (lptoken.transferFrom(msg.sender, address(this), lpamount), "Token Transfer failed");
| IUniswapV2ERC20 lptoken = IUniswapV2ERC20(UniV2Address);
uint lpamount = MinLPTokens();
require (lptoken.transferFrom(msg.sender, address(this), lpamount), "Token Transfer failed");
| 5,237 |
20 | // ============ Mutable Internal NFT Storage ============ |
mapping(uint256 => address) internal _owners;
mapping(address => uint256) internal _balances;
mapping(uint256 => address) internal _tokenApprovals;
mapping(address => mapping(address => bool)) internal _operatorApprovals;
|
mapping(uint256 => address) internal _owners;
mapping(address => uint256) internal _balances;
mapping(uint256 => address) internal _tokenApprovals;
mapping(address => mapping(address => bool)) internal _operatorApprovals;
| 26,087 |
7 | // Events | event TokenAdded(address _tokenAddress, uint _tokenIndex);
event Invested(address _user, uint _tokenIndex, uint _value);
event Reinvested(address _user, uint _tokenIndex, uint _value);
event Withdrew(address _user, uint _tokenIndex, uint _value);
| event TokenAdded(address _tokenAddress, uint _tokenIndex);
event Invested(address _user, uint _tokenIndex, uint _value);
event Reinvested(address _user, uint _tokenIndex, uint _value);
event Withdrew(address _user, uint _tokenIndex, uint _value);
| 40,838 |
142 | // return { "frozenBalance" : "Return the frozen balance of a given account for a specified currency"} / | function getTokenFrozenBalance(Data storage self, string currency, address account) internal view returns (uint frozenBalance) {
bytes32 id = keccak256(abi.encodePacked('token.frozen', currency, getForwardedAccount(self, account)));
return self.Storage.getUint(id);
}
| function getTokenFrozenBalance(Data storage self, string currency, address account) internal view returns (uint frozenBalance) {
bytes32 id = keccak256(abi.encodePacked('token.frozen', currency, getForwardedAccount(self, account)));
return self.Storage.getUint(id);
}
| 12,424 |
329 | // player burn their nft | function burnAndEarn(uint256 tokenId) external {
uint256 _remainOwners = remainOwners;
require(_remainOwners > 0, "ALL_BURNED");
require(ownerOf(tokenId) == msg.sender, "NO_AUTHORITY");
require(squidStartTime != 0 && block.timestamp >= squidStartTime, "GAME_IS_NOT_BEGIN");
_burn(tokenId);
(uint256 withdrawAmount, uint256 bonus) = _calWithdrawAmountAndBonus();
if (_remainOwners > 1) {
vaultAmount = vaultAmount + BONUS_PERPAX - bonus;
}
remainOwners = _remainOwners - 1;
emit Burn(tokenId, withdrawAmount, msg.sender);
require(IERC20(token).transfer(msg.sender, withdrawAmount));
}
| function burnAndEarn(uint256 tokenId) external {
uint256 _remainOwners = remainOwners;
require(_remainOwners > 0, "ALL_BURNED");
require(ownerOf(tokenId) == msg.sender, "NO_AUTHORITY");
require(squidStartTime != 0 && block.timestamp >= squidStartTime, "GAME_IS_NOT_BEGIN");
_burn(tokenId);
(uint256 withdrawAmount, uint256 bonus) = _calWithdrawAmountAndBonus();
if (_remainOwners > 1) {
vaultAmount = vaultAmount + BONUS_PERPAX - bonus;
}
remainOwners = _remainOwners - 1;
emit Burn(tokenId, withdrawAmount, msg.sender);
require(IERC20(token).transfer(msg.sender, withdrawAmount));
}
| 32,460 |
26 | // Returns the string of the current version. / | function version() public pure returns (string memory) {
| function version() public pure returns (string memory) {
| 35,227 |
259 | // Modifier to make a function callable only when the contract is paused. Requirements: - The contract must be paused. / | modifier whenPaused() {
require(paused(), "Pausable: not paused");
_;
}
| modifier whenPaused() {
require(paused(), "Pausable: not paused");
_;
}
| 1,886 |
46 | // return Available routers / | function getAvailableRouters() external view returns (address[] memory) {
return availableRouters.values();
}
| function getAvailableRouters() external view returns (address[] memory) {
return availableRouters.values();
}
| 26,920 |
4 | // Integer division of two unsigned integers truncating the quotient, reverts on division by zero./ | function div(uint256 a, uint256 b) internal pure returns (uint256) {
// Solidity only automatically asserts when dividing by 0
require(b > 0);
uint256 c = a / b;
// assert(a == b * c + a % b); // There is no case in which this doesn't hold
return c;
}
| function div(uint256 a, uint256 b) internal pure returns (uint256) {
// Solidity only automatically asserts when dividing by 0
require(b > 0);
uint256 c = a / b;
// assert(a == b * c + a % b); // There is no case in which this doesn't hold
return c;
}
| 190 |
200 | // These cases ensures that if a price has been frozen, it stays frozen even if it returns to the bounds | if (inverse.frozenAtUpperLimit) {
newRate = inverse.upperLimit;
} else if (inverse.frozenAtLowerLimit) {
| if (inverse.frozenAtUpperLimit) {
newRate = inverse.upperLimit;
} else if (inverse.frozenAtLowerLimit) {
| 43,073 |
41 | // Accounting - so we can pull the fees out without changing the balance | collectedFees += (msg.value * fee) / 1000000;
emit Buy(msg.sender, msg.value, amount);
tokenContract.transfer(msg.sender, amount);
| collectedFees += (msg.value * fee) / 1000000;
emit Buy(msg.sender, msg.value, amount);
tokenContract.transfer(msg.sender, amount);
| 37,157 |
1 | // Mints tokens to a specific address with a particular "option".This should be callable only by the account who has the minter role. optionId the option id (default: 0) toAddress address of the future owner of the tokens amount amount of the option to mint / | function mint(uint256 optionId, address toAddress, uint256 amount) external;
| function mint(uint256 optionId, address toAddress, uint256 amount) external;
| 21,095 |
11 | // Marks an index as overwritable, meaing the underlying buffer can start to write values overany objects before and including the given index. / | function setNextOverwritableIndex(
| function setNextOverwritableIndex(
| 3,735 |
7 | // Increase the calling contract's allowance toward `spender` by `value`. If `token` returns no value,non-reverting calls are assumed to be successful. / | function safeIncreaseAllowance(
IERC20Upgradeable token,
address spender,
uint256 value
| function safeIncreaseAllowance(
IERC20Upgradeable token,
address spender,
uint256 value
| 2,070 |
3 | // contract that sushi swaps ETH into SUSHI for sender. | contract ShwapETH {
address constant sushiToken = 0x6B3595068778DD592e39A122f4f5a5cF09C90fE2; // SUSHI token contract
address constant wETH = 0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2; // Wrapped ETH token contract
ISushiSwapETH constant sushiETHpair = ISushiSwapETH(0x795065dCc9f64b5614C407a6EFDC400DA6221FB0); // SUSHI/ETH pair for SushiSwap
ISushiSwapETH constant sushiSwapRouter = ISushiSwapETH(0xd9e1cE17f2641f24aE83637ab66a2cca9C378B9F); // SushiSwap router contract
/// @dev sushi swap ETH into SUSHI for sender.
receive() external payable {
(uint256 reserve0, uint256 reserve1, ) = sushiETHpair.getReserves(); // get `sushiETHpair` reserve balances for rate calculation
uint256 sushiOutMin = msg.value * (reserve0 / reserve1)
- msg.value * ((reserve0 / reserve1) / 200); // calculate minimum SUSHI return with 0.5% slippage threshold based on `msg.value` ETH
address[] memory path = new address[](2); // load SUSHI/ETH `path` for router
path[0] = address(wETH);
path[1] = address(sushiToken);
sushiSwapRouter.swapExactETHForTokens{value: msg.value}
(sushiOutMin, path, msg.sender, block.timestamp + 1200); // stage swap tx in router with 20 minute deadline
}
} | contract ShwapETH {
address constant sushiToken = 0x6B3595068778DD592e39A122f4f5a5cF09C90fE2; // SUSHI token contract
address constant wETH = 0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2; // Wrapped ETH token contract
ISushiSwapETH constant sushiETHpair = ISushiSwapETH(0x795065dCc9f64b5614C407a6EFDC400DA6221FB0); // SUSHI/ETH pair for SushiSwap
ISushiSwapETH constant sushiSwapRouter = ISushiSwapETH(0xd9e1cE17f2641f24aE83637ab66a2cca9C378B9F); // SushiSwap router contract
/// @dev sushi swap ETH into SUSHI for sender.
receive() external payable {
(uint256 reserve0, uint256 reserve1, ) = sushiETHpair.getReserves(); // get `sushiETHpair` reserve balances for rate calculation
uint256 sushiOutMin = msg.value * (reserve0 / reserve1)
- msg.value * ((reserve0 / reserve1) / 200); // calculate minimum SUSHI return with 0.5% slippage threshold based on `msg.value` ETH
address[] memory path = new address[](2); // load SUSHI/ETH `path` for router
path[0] = address(wETH);
path[1] = address(sushiToken);
sushiSwapRouter.swapExactETHForTokens{value: msg.value}
(sushiOutMin, path, msg.sender, block.timestamp + 1200); // stage swap tx in router with 20 minute deadline
}
} | 45,601 |
45 | // transfer contributed ETH back to the participant |
address(msg.sender).transfer(participantValues[msg.sender]);
|
address(msg.sender).transfer(participantValues[msg.sender]);
| 30,522 |
7,318 | // 3661 | entry "haecceitistically" : ENG_ADVERB
| entry "haecceitistically" : ENG_ADVERB
| 24,497 |
0 | // sets values for _bPool address of the balancer pool _deus address of DEUS token _dea address of DEA token _sdea address of SDEA token _suni_dd address of SUNI_DD token _suni_de address of SUNI_DE token _suni_du address of SUNI_DU token _sdeus address of SDEUS token / | constructor(
address _bPool,
address _deus,
address _dea,
address _sdea,
address _suni_dd,
address _suni_de,
address _suni_du,
address _sdeus
| constructor(
address _bPool,
address _deus,
address _dea,
address _sdea,
address _suni_dd,
address _suni_de,
address _suni_du,
address _sdeus
| 85,261 |
148 | // The same as replaceTokenWithNew, but sets fromTimestamp with block.timestampand uses durationFromNow to set targetTimestamp. oldToken Token to replace newToken New token balance Initial new token balance durationFromNow Duration to set targetTimestamp. / | function replaceTokenWithNewFromNow(
address oldToken,
address newToken,
uint256 balance,
uint256 durationFromNow
| function replaceTokenWithNewFromNow(
address oldToken,
address newToken,
uint256 balance,
uint256 durationFromNow
| 18,094 |
26 | // This function is used to return participantList | function getParticipants() public view returns (address[]) {
return participantList;
}
| function getParticipants() public view returns (address[]) {
return participantList;
}
| 15,666 |
131 | // Checks that the address is not already in the list, to avoid redundant events | if (!statusCurrent) {
creditManager.addEmergencyLiquidator(liquidator); // F: [CC-38]
emit EmergencyLiquidatorAdded(liquidator); // F: [CC-38]
}
| if (!statusCurrent) {
creditManager.addEmergencyLiquidator(liquidator); // F: [CC-38]
emit EmergencyLiquidatorAdded(liquidator); // F: [CC-38]
}
| 28,840 |
201 | // Total value of the assets managed by the vault Denominated in USDCreturn Total value of the vault / | function _balanceOfVault() internal view returns (uint256) {
ICErc20 cUsdc = ICErc20(registry().cUsdc());
Decimal.D256 memory exchangeRate = Decimal.D256({value: cUsdc.exchangeRateStored()});
return exchangeRate.mul(cUsdc.balanceOf(address(this))).asUint256();
}
| function _balanceOfVault() internal view returns (uint256) {
ICErc20 cUsdc = ICErc20(registry().cUsdc());
Decimal.D256 memory exchangeRate = Decimal.D256({value: cUsdc.exchangeRateStored()});
return exchangeRate.mul(cUsdc.balanceOf(address(this))).asUint256();
}
| 63,138 |
3 | // This creates a dictionary with allowances | mapping (address => mapping (address => uint256)) internal allowed;
| mapping (address => mapping (address => uint256)) internal allowed;
| 50,268 |
572 | // Calculates the ETH gain earned by the deposit since its last snapshots were taken. Given by the formula:E = d0(S - S(0))/P(0) where S(0) and P(0) are the depositor's snapshots of the sum S and product P, respectively. d0 is the last recorded deposit value./ | function getDepositorETHGain(address _depositor) public view override returns (uint) {
uint initialDeposit = deposits[_depositor].initialValue;
if (initialDeposit == 0) { return 0; }
Snapshots memory snapshots = depositSnapshots[_depositor];
uint ETHGain = _getETHGainFromSnapshots(initialDeposit, snapshots);
return ETHGain;
}
| function getDepositorETHGain(address _depositor) public view override returns (uint) {
uint initialDeposit = deposits[_depositor].initialValue;
if (initialDeposit == 0) { return 0; }
Snapshots memory snapshots = depositSnapshots[_depositor];
uint ETHGain = _getETHGainFromSnapshots(initialDeposit, snapshots);
return ETHGain;
}
| 10,421 |
6 | // Emits when found an error decoding request result | event ResultError(string);
| event ResultError(string);
| 38,686 |
3 | // Replacement for Solidity's transfer: sends amount wei torecipient, forwarding all available gas and reverting on errors. of certain opcodes, possibly making contracts go over the 2300 gas limitimposed by transfer, making them unable to receive funds via | * transfer. {sendValue} removes this limitation.
*
* https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].
*
* IMPORTANT: because control is transferred to recipient, care must be
* taken to not create reentrancy vulnerabilities. Consider using
* {ReentrancyGuard} or the
* https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].
*/
function sendValue(address payable recipient, uint256 amount) internal {
require(address(this).balance >= amount, "Address: insufficient balance");
(bool success, ) = recipient.call{value: amount}("");
require(success, "Address: unable to send value, recipient may have reverted");
}
| * transfer. {sendValue} removes this limitation.
*
* https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].
*
* IMPORTANT: because control is transferred to recipient, care must be
* taken to not create reentrancy vulnerabilities. Consider using
* {ReentrancyGuard} or the
* https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].
*/
function sendValue(address payable recipient, uint256 amount) internal {
require(address(this).balance >= amount, "Address: insufficient balance");
(bool success, ) = recipient.call{value: amount}("");
require(success, "Address: unable to send value, recipient may have reverted");
}
| 11,075 |
74 | // use the internal transfer function as the external has a guard to prevent transfers to 0x0 | _transfer(msg.sender, address(0), id);
| _transfer(msg.sender, address(0), id);
| 57,437 |
1,124 | // log the event | logger.Log(address(this), msg.sender, "ExchangeSell", abi.encode(wrapper, exData.srcAddr, exData.destAddr, exData.srcAmount, destAmount));
| logger.Log(address(this), msg.sender, "ExchangeSell", abi.encode(wrapper, exData.srcAddr, exData.destAddr, exData.srcAmount, destAmount));
| 31,486 |
179 | // retrieve the input | OrderQueryInput memory order = orders[i];
| OrderQueryInput memory order = orders[i];
| 10,408 |
110 | // Clean up the existing top bid | delete highestBids[_tokenId];
| delete highestBids[_tokenId];
| 41,704 |
96 | // subtract goodwill | totalGoodwillPortion = _subtractGoodwill(
token,
amount,
affiliate,
enableGoodwill
);
return amount - totalGoodwillPortion;
| totalGoodwillPortion = _subtractGoodwill(
token,
amount,
affiliate,
enableGoodwill
);
return amount - totalGoodwillPortion;
| 8,823 |
138 | // this is uniswap | IUniswapV2Pair lpToken = IUniswapV2Pair(lpTokensInfo[_pid].lpToken);
return (lpToken.token0(), lpToken.token1());
| IUniswapV2Pair lpToken = IUniswapV2Pair(lpTokensInfo[_pid].lpToken);
return (lpToken.token0(), lpToken.token1());
| 9,319 |
21 | // Instanciate the contract/_maxSupply how many tokens this collection should hold/_startFrom the tokenID with which to start counting | constructor (uint256 _maxSupply, uint256 _startFrom)
WithLimitedSupply(_maxSupply)
| constructor (uint256 _maxSupply, uint256 _startFrom)
WithLimitedSupply(_maxSupply)
| 7,369 |
85 | // Return Manager Module address from the Nexusreturn Address of the Manager Module contract / | function _manager() internal view returns (address) {
return nexus.getModule(KEY_MANAGER);
}
| function _manager() internal view returns (address) {
return nexus.getModule(KEY_MANAGER);
}
| 9,952 |
151 | // Add new signer `signer` must not be zero address/ | function addSigner(
address signer,
bytes[] calldata signatures
| function addSigner(
address signer,
bytes[] calldata signatures
| 44,494 |
17 | // Multiplies two numbers, throws on overflow. _a Factor number. _b Factor number. / | function mul(
uint256 _a,
uint256 _b
)
internal
pure
returns (uint256)
| function mul(
uint256 _a,
uint256 _b
)
internal
pure
returns (uint256)
| 42,591 |
1 | // The ProjectData event is emitted from writeProjectData function. indexed keyword is added to scriptIndex for searchability. scriptIndex is index in the mapping that is being updated. oldScript is the data being replaced, potentially "". newScript is the new data stored to chain. / | event ProjectData(
uint256 indexed scriptIndex,
string oldScript,
string newScript
);
| event ProjectData(
uint256 indexed scriptIndex,
string oldScript,
string newScript
);
| 25,224 |
7 | // Adds or removes members, or changes their allocations accounts An array of member addresses allocations The amount of tokens to allocate to the correspondingmember, overriding the previous allocation vestFor The duration the corresponding allocation will last for / | function setAllocations(
address[] memory accounts,
uint[] memory allocations,
uint[] memory vestFor
| function setAllocations(
address[] memory accounts,
uint[] memory allocations,
uint[] memory vestFor
| 5,636 |
1,043 | // Percentage of local liquidity token cash claim delivered to the liquidator for liquidating liquidity tokens | int256 internal constant TOKEN_REPO_INCENTIVE_PERCENT = 30;
| int256 internal constant TOKEN_REPO_INCENTIVE_PERCENT = 30;
| 4,064 |
1 | // updates the total that the capital raise has sold and the relevant user shares balance. _receiver address Receiving address. _shares uint256 Amount of shares. / | function _updateSold(address _receiver, uint256 _shares) internal {
shares[_receiver] = shares[_receiver].add(_shares);
sold = sold.add(_shares);
receivers.push(_receiver);
}
| function _updateSold(address _receiver, uint256 _shares) internal {
shares[_receiver] = shares[_receiver].add(_shares);
sold = sold.add(_shares);
receivers.push(_receiver);
}
| 51,181 |
10 | // ADMIN / | modifier onlyOwner() {
require(msg.sender == auth);
_;
}
| modifier onlyOwner() {
require(msg.sender == auth);
_;
}
| 33,807 |
92 | // Sets the address of the Consensus Contract_consensusAddress the address of the consensus contract/ | function _setConsensus(address _consensusAddress) internal {
_consensus = _consensusAddress;
}
| function _setConsensus(address _consensusAddress) internal {
_consensus = _consensusAddress;
}
| 31,652 |
323 | // A record of all the token balances This mapping keeps record of all token owners: owner => balance / | mapping(address => uint256) public tokenBalances;
| mapping(address => uint256) public tokenBalances;
| 7,037 |
78 | // These next few lines are used when the totalSupply of the token isrequested before a check point was ever created for this token, itrequires that the `parentToken.totalSupplyAt` be queried at thegenesis block for this token as that contains totalSupply of thistoken at this block number. | if ((totalSupplyHistory.length == 0)
|| (totalSupplyHistory[0].fromBlock > _blockNumber)) {
if (address(parentToken) != 0) {
return parentToken.totalSupplyAt(min(_blockNumber, parentSnapShotBlock));
} else {
| if ((totalSupplyHistory.length == 0)
|| (totalSupplyHistory[0].fromBlock > _blockNumber)) {
if (address(parentToken) != 0) {
return parentToken.totalSupplyAt(min(_blockNumber, parentSnapShotBlock));
} else {
| 15,683 |
160 | // How many HEAL tokens do this contract have | function getHealBalance() view public returns (uint256) {
return ethealController.ethealToken().balanceOf(address(this));
}
| function getHealBalance() view public returns (uint256) {
return ethealController.ethealToken().balanceOf(address(this));
}
| 14,489 |
892 | // Unpacks a sample into its components. / | function unpack(bytes32 sample)
internal
pure
returns (
int256 logPairPrice,
int256 accLogPairPrice,
int256 logBptPrice,
int256 accLogBptPrice,
int256 logInvariant,
int256 accLogInvariant,
| function unpack(bytes32 sample)
internal
pure
returns (
int256 logPairPrice,
int256 accLogPairPrice,
int256 logBptPrice,
int256 accLogBptPrice,
int256 logInvariant,
int256 accLogInvariant,
| 5,238 |
109 | // Umbrella Airdrop contract/ umb.network/ This contract provides Airdrop capability. | abstract contract Airdrop is ERC20 {
function airdropTokens(
address[] calldata _addresses,
uint256[] calldata _amounts
) external {
require(_addresses.length != 0, "there are no _addresses");
require(_addresses.length == _amounts.length, "the number of _addresses should match _amounts");
for(uint i = 0; i < _addresses.length; i++) {
transfer(_addresses[i], _amounts[i]);
}
}
}
| abstract contract Airdrop is ERC20 {
function airdropTokens(
address[] calldata _addresses,
uint256[] calldata _amounts
) external {
require(_addresses.length != 0, "there are no _addresses");
require(_addresses.length == _amounts.length, "the number of _addresses should match _amounts");
for(uint i = 0; i < _addresses.length; i++) {
transfer(_addresses[i], _amounts[i]);
}
}
}
| 32,780 |
10 | // function cancelled(bytes32) | bytes4 constant internal CANCELLED_SELECTOR = 0x2ac12622;
| bytes4 constant internal CANCELLED_SELECTOR = 0x2ac12622;
| 34,222 |
4 | // employee must not exist | require(!employees[_addr].isExists, "Employee already exists");
| require(!employees[_addr].isExists, "Employee already exists");
| 4,859 |
4 | // Emitted when the contract image is updated | event ContractImageUpdated(string prevImage, string newImage);
| event ContractImageUpdated(string prevImage, string newImage);
| 17,026 |
33 | // vote with enocded vote id."supported" needs to be false if doing this type | return IBooster(booster).vote(data, _isOwnership ? voteOwnership : voteParameter, false);
| return IBooster(booster).vote(data, _isOwnership ? voteOwnership : voteParameter, false);
| 5,867 |
76 | // eth 2 token | function swapExactETHForTokens(
uint256 amountOutMin,
address[] calldata path,
address to,
uint256 deadline
) external payable returns (uint256[] memory amounts);
function swapETHForExactTokens(
uint256 amountOut,
address[] calldata path,
| function swapExactETHForTokens(
uint256 amountOutMin,
address[] calldata path,
address to,
uint256 deadline
) external payable returns (uint256[] memory amounts);
function swapETHForExactTokens(
uint256 amountOut,
address[] calldata path,
| 12,830 |
125 | // Reward per second given to the staking contract, split among the staked tokens | uint256 public rewardRate;
| uint256 public rewardRate;
| 55,128 |
30 | // solhint-disable-next-line avoid-low-level-calls, avoid-call-value | (bool success, ) = recipient.call{ value: amount }("");
| (bool success, ) = recipient.call{ value: amount }("");
| 1,348 |
86 | // Reclaims free slots between valid owners in m_owners. TODO given that its called after each removal, it could be simplified. | function reorganizeOwners() private {
uint free = 1;
while (free < m_numOwners)
{
// iterating to the first free slot from the beginning
while (free < m_numOwners && m_owners[free] != 0) free++;
// iterating to the first occupied slot from the end
while (m_numOwners > 1 && m_owners[m_numOwners] == 0) m_numOwners--;
// swap, if possible, so free slot is located at the end after the swap
if (free < m_numOwners && m_owners[m_numOwners] != 0 && m_owners[free] == 0)
{
// owners between swapped slots should't be renumbered - that saves a lot of gas
m_owners[free] = m_owners[m_numOwners];
m_ownerIndex[m_owners[free]] = free;
m_owners[m_numOwners] = 0;
}
}
}
| function reorganizeOwners() private {
uint free = 1;
while (free < m_numOwners)
{
// iterating to the first free slot from the beginning
while (free < m_numOwners && m_owners[free] != 0) free++;
// iterating to the first occupied slot from the end
while (m_numOwners > 1 && m_owners[m_numOwners] == 0) m_numOwners--;
// swap, if possible, so free slot is located at the end after the swap
if (free < m_numOwners && m_owners[m_numOwners] != 0 && m_owners[free] == 0)
{
// owners between swapped slots should't be renumbered - that saves a lot of gas
m_owners[free] = m_owners[m_numOwners];
m_ownerIndex[m_owners[free]] = free;
m_owners[m_numOwners] = 0;
}
}
}
| 2,672 |
449 | // ISavingsContract / | contract ISavingsContract {
uint256 public exchangeRate;
mapping(address => uint256) public creditBalances;
function depositSavings(uint256 _amount) external returns (uint256 creditsIssued);
function redeem(uint256 _amount) external returns (uint256 massetReturned);
}
| contract ISavingsContract {
uint256 public exchangeRate;
mapping(address => uint256) public creditBalances;
function depositSavings(uint256 _amount) external returns (uint256 creditsIssued);
function redeem(uint256 _amount) external returns (uint256 massetReturned);
}
| 11,022 |
133 | // Finally, search trough all checkpoints | ( , uint192 data) = _findCheckpoint(record, _record.numCheckpoints, blockNum);
return data;
| ( , uint192 data) = _findCheckpoint(record, _record.numCheckpoints, blockNum);
return data;
| 20,303 |
105 | // keccak256("ERC777TokensRecipient") | bytes32 constant private _TOKENS_RECIPIENT_INTERFACE_HASH =
0xb281fc8c12954d22544db45de3159a39272895b169a852b314f9cc762e44c53b;
| bytes32 constant private _TOKENS_RECIPIENT_INTERFACE_HASH =
0xb281fc8c12954d22544db45de3159a39272895b169a852b314f9cc762e44c53b;
| 13,745 |
306 | // check if pptbalance minus collateral held is more than pptFee then transfer pptFee from users ppt deposit to adminWallet | require(SafeMath.safeSub(o.balanceOf(tokenDetails[0x505054]._token), inCollateral) >= pptFee);
require(o.transfer(tokenDetails[0x505054]._token, adminExternalWallet, pptFee) == true);
| require(SafeMath.safeSub(o.balanceOf(tokenDetails[0x505054]._token), inCollateral) >= pptFee);
require(o.transfer(tokenDetails[0x505054]._token, adminExternalWallet, pptFee) == true);
| 22,267 |
8 | // Decodes a bytes32 into a uint128 as the first or second uint128 z The encoded bytes32 as follows:if first:[0 - 128[: x1[128 - 256[: emptyelse:[0 - 128[: empty[128 - 256[: x2 first Whether to decode as the first or second uint128return x The decoded uint128 / | function decode(bytes32 z, bool first) internal pure returns (uint128 x) {
return first ? decodeX(z) : decodeY(z);
}
| function decode(bytes32 z, bool first) internal pure returns (uint128 x) {
return first ? decodeX(z) : decodeY(z);
}
| 30,733 |
17 | // If the solid account has held wei, add the amount the solid account will receive from liquidation to its total held wei We do this so we can accurately track how much the solid account has, in case we need to input it exactly to RoutergetParamsForSwapExactTokensForTokens | totalSolidHeldWei = totalSolidHeldWei.add(cache.solidHeldWei.value);
| totalSolidHeldWei = totalSolidHeldWei.add(cache.solidHeldWei.value);
| 36,283 |
36 | // Make sure passed value is greater than 0 | require (
_value > 0,
"CommonMath.ceilLog10: Value must be greater than zero."
);
| require (
_value > 0,
"CommonMath.ceilLog10: Value must be greater than zero."
);
| 44,115 |
18 | // 当前收益:直推总量 / 投入本金 是否大于等于3,小于3 当前收益为0 大于3:本金3 - 已提取数 | function getIncome(address addr) view public isAddress(addr) returns(uint256){
uint256 multiple = directPushMultiple(addr);
if (multiple < 3){
return 0;
}
return (balance[addr].mul(3).sub(user[addr].amountWithdrawn));
}
| function getIncome(address addr) view public isAddress(addr) returns(uint256){
uint256 multiple = directPushMultiple(addr);
if (multiple < 3){
return 0;
}
return (balance[addr].mul(3).sub(user[addr].amountWithdrawn));
}
| 3,325 |
56 | // require(owner != address(0)); | require(spender != address(0), "ERC20: approve to zero address");
_allowances[owner][spender] = amount;
emit Approval(owner, spender, amount);
| require(spender != address(0), "ERC20: approve to zero address");
_allowances[owner][spender] = amount;
emit Approval(owner, spender, amount);
| 29,694 |
4 | // TaxDeposit 0x2ab3b3b53aa29a0599c58f343221e29a032103d015c988fae9a5cdfa5c005d9d | event TaxDeposit(address indexed user, uint256 amount); // when tax is deposited
| event TaxDeposit(address indexed user, uint256 amount); // when tax is deposited
| 48,550 |
194 | // get Bancor Converter address | address converterAddress = getBacorConverterAddressByRelay(address(_poolToken), 1);
| address converterAddress = getBacorConverterAddressByRelay(address(_poolToken), 1);
| 5,678 |
240 | // check if caller has sufficient permissions to mint a token | require(__isSenderInRole(ROLE_TOKEN_CREATOR));
| require(__isSenderInRole(ROLE_TOKEN_CREATOR));
| 32,413 |
162 | // buyback token configuration | address public immutable rewardToken;
address public immutable buybackToken1;
address public immutable buybackToken2;
| address public immutable rewardToken;
address public immutable buybackToken1;
address public immutable buybackToken2;
| 9,314 |
16 | // Calculate a new reward lane value with the given parameters _rewardLane The previous reward lane value _totalDeposit Thte total deposit amount of the Contribution Tokens _rewardPerBlock The reward token amount per a block _decrementUnitPerBlock The decerement amount of the reward token per a block / | function _calcNewRewardLane(
uint256 _rewardLane,
uint256 _totalDeposit,
uint256 _rewardPerBlock,
uint256 _decrementUnitPerBlock,
| function _calcNewRewardLane(
uint256 _rewardLane,
uint256 _totalDeposit,
uint256 _rewardPerBlock,
uint256 _decrementUnitPerBlock,
| 11,194 |
323 | // 0.1% fee after 14 days | pool.lpToken.safeTransfer(
address(msg.sender),
_amount.mul(userFeeStage[6]).div(1000)
);
pool.lpToken.safeTransfer(
address(devaddr),
_amount.mul(devFeeStage[6]).div(1000)
);
| pool.lpToken.safeTransfer(
address(msg.sender),
_amount.mul(userFeeStage[6]).div(1000)
);
pool.lpToken.safeTransfer(
address(devaddr),
_amount.mul(devFeeStage[6]).div(1000)
);
| 9,225 |
151 | // Swapper strategy IDs. | EnumerableSetUpgradeable.AddressSet private strategies;
| EnumerableSetUpgradeable.AddressSet private strategies;
| 37,299 |
48 | // Cap amount if the remaining PRPS on hodl is less than what still needs to be marked pending | if (remainingPendingPrps > remainingLockedPrps) {
remainingPendingPrps = remainingLockedPrps;
}
| if (remainingPendingPrps > remainingLockedPrps) {
remainingPendingPrps = remainingLockedPrps;
}
| 29,219 |
177 | // Deposit LP tokens to VegionFarm for vt allocation. | function deposit(
uint256 _pid,
uint256 _amount,
string memory _pname
| function deposit(
uint256 _pid,
uint256 _amount,
string memory _pname
| 80,341 |
79 | // AGENT ROLE / | function addAgent(address _agent) public onlyAdmin {
agents[_agent] = true;
}
| function addAgent(address _agent) public onlyAdmin {
agents[_agent] = true;
}
| 32,028 |
70 | // Return the status of the presale (is it open) The sale is open when the current time is larger than the sale start time and not all packs are minted./ | function isSaleOpen() external view returns (bool) {
return block.timestamp >= SALE_START_TIMESTAMP && totalPackSupply() < MAX_PACK_SUPPLY;
}
| function isSaleOpen() external view returns (bool) {
return block.timestamp >= SALE_START_TIMESTAMP && totalPackSupply() < MAX_PACK_SUPPLY;
}
| 18,742 |
161 | // Called through the Strategy contract to execute a task/Doesn't burn gst2/chi as it's handled in the StrategyExecutor/_strategyId Id of the strategy we want to execute/_actionCallData All the data related to the strategies Task | function executeStrategyTask(uint256 _strategyId, bytes[][] memory _actionCallData)
public
payable
| function executeStrategyTask(uint256 _strategyId, bytes[][] memory _actionCallData)
public
payable
| 48,010 |
7 | // Reverts if the caller is not the contract owner. | function _onlyAdmin() internal view {
if (msg.sender != owner()) {
revert Unauthorized();
}
}
| function _onlyAdmin() internal view {
if (msg.sender != owner()) {
revert Unauthorized();
}
}
| 64,008 |
16 | // work on right child | (resParent, resBegin, resEnd) = getUpdatedNode(
node,
parentUpdate,
begin,
end,
node * 2 + 1,
mid + 1,
end,
leaf
);
| (resParent, resBegin, resEnd) = getUpdatedNode(
node,
parentUpdate,
begin,
end,
node * 2 + 1,
mid + 1,
end,
leaf
);
| 8,558 |
41 | // Join Hook |
function onJoinPool(
bytes32 poolId,
address sender,
address recipient,
uint256[] memory balances,
uint256 lastChangeBlock,
uint256 protocolSwapFeePercentage,
bytes memory userData
)
|
function onJoinPool(
bytes32 poolId,
address sender,
address recipient,
uint256[] memory balances,
uint256 lastChangeBlock,
uint256 protocolSwapFeePercentage,
bytes memory userData
)
| 14,841 |
2 | // let user unlcok NFT if enabled, access: ANY/_nftId is the NFT id which unlocked | function unlockNFT(uint256 _nftId) external;
| function unlockNFT(uint256 _nftId) external;
| 35,620 |
96 | // called by the owner to unpause, returns to normal state/ | function _unpause() internal {
require(paused);
paused = false;
emit Unpause(now);
}
| function _unpause() internal {
require(paused);
paused = false;
emit Unpause(now);
}
| 49,601 |
263 | // SWAP HELPERS / | function _getMinMaxReportInterval() internal view returns (uint256 min, uint256 max) {
return powerPoke.getMinMaxReportIntervals(address(this));
}
| function _getMinMaxReportInterval() internal view returns (uint256 min, uint256 max) {
return powerPoke.getMinMaxReportIntervals(address(this));
}
| 57,403 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.