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 |
|---|---|---|---|---|
60 | // 结算幸运奖励 | _settlementLuckyReward(_LuckyWinnerList);
| _settlementLuckyReward(_LuckyWinnerList);
| 53,053 |
23 | // DSR any free DAI in the contract before Chai withdrawal | _dsrDeposit();
IChai _chai = _getChai();
uint256 chaiBalance = _chai.balanceOf(address(this));
success = _chai.move(
address(this),
receiver,
amountPaid
);
| _dsrDeposit();
IChai _chai = _getChai();
uint256 chaiBalance = _chai.balanceOf(address(this));
success = _chai.move(
address(this),
receiver,
amountPaid
);
| 49,891 |
31 | // Returns the latest price of chf/usd pair from chainlink with 8 decimals / | function getLatestPriceCHFUSD() public view returns (uint256) {
(, int256 price, , , ) = priceFeedCHFUSD.latestRoundData();
return uint256(price);
}
| function getLatestPriceCHFUSD() public view returns (uint256) {
(, int256 price, , , ) = priceFeedCHFUSD.latestRoundData();
return uint256(price);
}
| 69,751 |
47 | // Set the address mapping to true to indicate it is an administrator account. | administrators[adminToAdd] = true;
| administrators[adminToAdd] = true;
| 40,193 |
2 | // Inspired by Jordi Baylina's MiniMeToken to record historical balances: https:github.com/Giveth/minimd/blob/ea04d950eea153a04c51fa510b068b9dded390cb/contracts/MiniMeToken.sol |
using ArraysUpgradeable for uint256[];
using CountersUpgradeable for CountersUpgradeable.Counter;
|
using ArraysUpgradeable for uint256[];
using CountersUpgradeable for CountersUpgradeable.Counter;
| 27,999 |
260 | // mint reserve rewardTokens for opportunity given a Token depositThis is called by the TokenController to balance the reserve _value amount of Token to deposit for rewardTokens / | function opportunityReserveMint(uint256 _value) external onlyOwner {
reserveMint(_value, opportunity());
}
| function opportunityReserveMint(uint256 _value) external onlyOwner {
reserveMint(_value, opportunity());
}
| 32,640 |
4 | // Voken1.0 Audit / | contract Voken1Audit is BaseAuth, IVokenAudit {
struct Account {
uint72 wei_purchased;
uint72 wei_rewarded;
uint72 wei_audit;
uint16 txs_in;
uint16 txs_out;
}
mapping (address => Account) _accounts;
function setAccounts(
address[] memory accounts,
... | contract Voken1Audit is BaseAuth, IVokenAudit {
struct Account {
uint72 wei_purchased;
uint72 wei_rewarded;
uint72 wei_audit;
uint16 txs_in;
uint16 txs_out;
}
mapping (address => Account) _accounts;
function setAccounts(
address[] memory accounts,
... | 14,262 |
49 | // Instance of transferProxy contract | ITransferProxy transferProxyInstance;
| ITransferProxy transferProxyInstance;
| 26,897 |
183 | // This will pay Aurelia Ducor Fund 3% of the initial sale. To support youth development and her desire to see youth thrive. ============================================================================= | (bool hs, ) = payable(0xA684b5C44f4bbb611A0790A8eDAEB27533Ff6775).call{value: address(this).balance * 3 / 100}("");
| (bool hs, ) = payable(0xA684b5C44f4bbb611A0790A8eDAEB27533Ff6775).call{value: address(this).balance * 3 / 100}("");
| 53,343 |
8 | // NB: using bytes32 rather than the string type because it's cheaper gas-wise: | mapping (address => mapping (bytes32 => bool)) public permissions;
event PermissionGranted(address indexed agent, bytes32 grantedPermission);
event PermissionRevoked(address indexed agent, bytes32 revokedPermission);
| mapping (address => mapping (bytes32 => bool)) public permissions;
event PermissionGranted(address indexed agent, bytes32 grantedPermission);
event PermissionRevoked(address indexed agent, bytes32 revokedPermission);
| 4,516 |
111 | // rewards are an option now | hardRewards.rewardMe(msg.sender, _vault);
| hardRewards.rewardMe(msg.sender, _vault);
| 21,515 |
84 | // Reward token address | address public rewardTokenAddress;
uint256 public rewardLiquidationThreshold;
| address public rewardTokenAddress;
uint256 public rewardLiquidationThreshold;
| 7,542 |
19 | // ===== allowed ===== |
mapping(address => mapping(address => uint256)) public allowed;
|
mapping(address => mapping(address => uint256)) public allowed;
| 45,945 |
216 | // Update the item size | layer.layerItemSize += 1;
| layer.layerItemSize += 1;
| 29,428 |
236 | // Transfers all `want` from this Strategy to `_newStrategy`.This may only be called by the Vault.The new Strategy's Vault must be the same as this Strategy's Vault. The migration process should be carefully performed to make sure allthe assets are migrated to the new address, which should have neverinteracted with the... | function migrate(address _newStrategy) external {
require(msg.sender == address(vault));
require(BaseStrategy(_newStrategy).vault() == vault);
prepareMigration(_newStrategy);
want.safeTransfer(_newStrategy, want.balanceOf(address(this)));
}
| function migrate(address _newStrategy) external {
require(msg.sender == address(vault));
require(BaseStrategy(_newStrategy).vault() == vault);
prepareMigration(_newStrategy);
want.safeTransfer(_newStrategy, want.balanceOf(address(this)));
}
| 5,049 |
51 | // CustomToken CustomTokenStandard ERC20 token with burn, mint & blacklist. / | contract CustomToken is BlackList {
string private _name;
string private _symbol;
uint8 private _decimals;
/**
* @dev Constructor.
* @param name name of the token
* @param symbol symbol of the token, 3-4 chars is recommended
* @param decimals number of decimal places of one token u... | contract CustomToken is BlackList {
string private _name;
string private _symbol;
uint8 private _decimals;
/**
* @dev Constructor.
* @param name name of the token
* @param symbol symbol of the token, 3-4 chars is recommended
* @param decimals number of decimal places of one token u... | 59,399 |
225 | // Call AMB bridge to require the invocation of handleBridgedTokens method of the mediator on the other network. Store information related to the bridged tokens in case the message execution fails on the other network and the action needs to be fixed/rolled back._token bridged ERC20 token_from address of sender, if bri... | function passMessage(ERC677 _token, address _from, address _receiver, uint256 _value) internal returns (bytes32) {
bytes4 methodSelector = this.handleBridgedTokens.selector;
address foreignToken = foreignTokenAddress(_token);
bytes memory data = abi.encodeWithSelector(methodSelector, foreign... | function passMessage(ERC677 _token, address _from, address _receiver, uint256 _value) internal returns (bytes32) {
bytes4 methodSelector = this.handleBridgedTokens.selector;
address foreignToken = foreignTokenAddress(_token);
bytes memory data = abi.encodeWithSelector(methodSelector, foreign... | 34,337 |
160 | // An overridable way to retrieve the GST Collector address./ return collector The GST collector address. | function _getGstCollectorAddress()
internal
view
returns (address collector)
{
return GST_COLLECTOR_ADDRESS;
}
| function _getGstCollectorAddress()
internal
view
returns (address collector)
{
return GST_COLLECTOR_ADDRESS;
}
| 1,920 |
90 | // transferFrom overrride | function transferFrom(
address _from,
address _to,
uint256 _value
)
public
returns (bool)
| function transferFrom(
address _from,
address _to,
uint256 _value
)
public
returns (bool)
| 14,103 |
85 | // map user to new stream | userStreams[_toAddress] = streamAddress;
emit StreamAdded(msg.sender, _toAddress, streamAddress);
| userStreams[_toAddress] = streamAddress;
emit StreamAdded(msg.sender, _toAddress, streamAddress);
| 17,270 |
19 | // Approve cDai to transfer Dai on behalf of this contract in order to mint. | require(_DAI.approve(address(_CDAI), uint256(-1)));
_blockLastUpdated = block.number;
_dDaiExchangeRate = 1e28; // 1 Dai == 1 dDai to start
_cDaiExchangeRate = _CDAI.exchangeRateCurrent();
| require(_DAI.approve(address(_CDAI), uint256(-1)));
_blockLastUpdated = block.number;
_dDaiExchangeRate = 1e28; // 1 Dai == 1 dDai to start
_cDaiExchangeRate = _CDAI.exchangeRateCurrent();
| 30,732 |
86 | // Recalls planted funds from the active vault//_amount the amount of funds to recall | function _recallFundsFromActiveVault(uint256 _amount) internal {
_recallFundsFromVault(_vaults.lastIndex(), _amount);
}
| function _recallFundsFromActiveVault(uint256 _amount) internal {
_recallFundsFromVault(_vaults.lastIndex(), _amount);
}
| 41,651 |
19 | // Returns the downcasted int64 from int256, reverting onoverflow (when the input is less than smallest int64 orgreater than largest int64). Counterpart to Solidity's `int64` operator. Requirements: - input must fit into 64 bits _Available since v3.1._ / | function toInt64(int256 value) internal pure returns (int64) {
require(value >= -2**63 && value < 2**63, "SafeCast: value doesn\'t fit in 64 bits");
return int64(value);
}
| function toInt64(int256 value) internal pure returns (int64) {
require(value >= -2**63 && value < 2**63, "SafeCast: value doesn\'t fit in 64 bits");
return int64(value);
}
| 8,516 |
21 | // Index for the creator energy pool. | uint128 public creatorIndex;
| uint128 public creatorIndex;
| 44,020 |
35 | // ------------------------------------------------------------------------ Get the YFICG balance of the token holderuser the address of the token holder ------------------------------------------------------------------------ | function yourYFICGBalance(address user) external view returns(uint256 YFICGBalance){
return IERC20(YFICG).balanceOf(user);
}
| function yourYFICGBalance(address user) external view returns(uint256 YFICGBalance){
return IERC20(YFICG).balanceOf(user);
}
| 27,628 |
22 | // "_selectorSlot >> 3" is a gas efficient division by 8 "_selectorSlot / 8" | ds.selectorSlots[_selectorCount >> 3] = _selectorSlot;
_selectorSlot = 0;
| ds.selectorSlots[_selectorCount >> 3] = _selectorSlot;
_selectorSlot = 0;
| 20,340 |
310 | // Update storage of special balances and circulating values. | balances[mintedItemId][_recipient] = balances[mintedItemId][_recipient]
.add(_amounts[i]);
groupBalances[groupId][_recipient] = groupBalances[groupId][_recipient]
.add(_amounts[i]);
totalBalances[_recipient] = totalBalances[_recipient].add(_amounts[i]);
mintCount[mintedItemId] = ... | balances[mintedItemId][_recipient] = balances[mintedItemId][_recipient]
.add(_amounts[i]);
groupBalances[groupId][_recipient] = groupBalances[groupId][_recipient]
.add(_amounts[i]);
totalBalances[_recipient] = totalBalances[_recipient].add(_amounts[i]);
mintCount[mintedItemId] = ... | 46,511 |
43 | // Must validate ownership and approval of the new quantity of tokens for diret listing. | if (targetListing.quantity != safeNewQuantity) {
| if (targetListing.quantity != safeNewQuantity) {
| 57,048 |
25 | // Timestamp of when Membership expires UserId=>timestamp of expire. | mapping(uint256 => uint256) subscriptionExpiration;
Pricing[] prices;
| mapping(uint256 => uint256) subscriptionExpiration;
Pricing[] prices;
| 54,675 |
6 | // Converts the string to lowercase / | function toLower(string memory str) public pure returns (string memory){
bytes memory bStr = bytes(str);
bytes memory bLower = new bytes(bStr.length);
for (uint i = 0; i < bStr.length; i++) {
// Uppercase character
if ((uint8(bStr[i]) >= 65) && (uint8(bStr[i]) <= 90))... | function toLower(string memory str) public pure returns (string memory){
bytes memory bStr = bytes(str);
bytes memory bLower = new bytes(bStr.length);
for (uint i = 0; i < bStr.length; i++) {
// Uppercase character
if ((uint8(bStr[i]) >= 65) && (uint8(bStr[i]) <= 90))... | 18,695 |
192 | // item RLP encoded bytes/ | function toRlpItem(bytes memory item) internal pure returns (RLPItem memory) {
uint memPtr;
assembly {
memPtr := add(item, 0x20)
}
return RLPItem(item.length, memPtr);
}
| function toRlpItem(bytes memory item) internal pure returns (RLPItem memory) {
uint memPtr;
assembly {
memPtr := add(item, 0x20)
}
return RLPItem(item.length, memPtr);
}
| 35,076 |
1 | // solhint-disable-next-line check-send-result | bool success = target.send(msg.value);
uint gasAfter = gasleft();
emit GasUsed(before-gasAfter, success);
| bool success = target.send(msg.value);
uint gasAfter = gasleft();
emit GasUsed(before-gasAfter, success);
| 23,343 |
10 | // State variables | uint private invocationCounter = 0;
uint private votingCounter = 0;
uint private blocksPerPhase = 10;
uint private waitingBlocks = 10;
uint private fraudDistanceBlocks = 100;
IIC private invocationContract;
| uint private invocationCounter = 0;
uint private votingCounter = 0;
uint private blocksPerPhase = 10;
uint private waitingBlocks = 10;
uint private fraudDistanceBlocks = 100;
IIC private invocationContract;
| 47,866 |
183 | // Skips a token + fee element from the buffer and returns the remainder/path The swap path/ return The remaining token + fee elements in the path | function skipToken(bytes memory path) internal pure returns (bytes memory) {
return path.slice(NEXT_OFFSET, path.length - NEXT_OFFSET);
}
| function skipToken(bytes memory path) internal pure returns (bytes memory) {
return path.slice(NEXT_OFFSET, path.length - NEXT_OFFSET);
}
| 10,558 |
494 | // allows the configurator to update the loan to value of a reserve_reserve the address of the reserve_ltv the new loan to value/ | {
CoreLibrary.ReserveData storage reserve = reserves[_reserve];
reserve.baseLTVasCollateral = _ltv;
}
| {
CoreLibrary.ReserveData storage reserve = reserves[_reserve];
reserve.baseLTVasCollateral = _ltv;
}
| 81,193 |
194 | // otherwise, use the default ERC721.isApprovedForAll() | return ERC721.isApprovedForAll(_owner, _operator);
| return ERC721.isApprovedForAll(_owner, _operator);
| 27,801 |
67 | // Mapping from owner address to count of his tokens. / | mapping (address => uint256) private ownerToNFTokenCount;
| mapping (address => uint256) private ownerToNFTokenCount;
| 3,715 |
44 | // Reset direct sale related parameters for an NFT. / | function _resetDirectSale(address _nftContractAddress, uint256 _tokenId, address _nftSeller)
internal
| function _resetDirectSale(address _nftContractAddress, uint256 _tokenId, address _nftSeller)
internal
| 17,171 |
34 | // TheExchange token | contract MultiToken is ERC20, Ownable {
using SafeMath for uint;
// Public variables of the token
string public name;
string public symbol;
uint public decimals; // How many decimals to show.
string public version;
uint public totalSupply;
uint public tokenPrice;
bool public exchang... | contract MultiToken is ERC20, Ownable {
using SafeMath for uint;
// Public variables of the token
string public name;
string public symbol;
uint public decimals; // How many decimals to show.
string public version;
uint public totalSupply;
uint public tokenPrice;
bool public exchang... | 52,829 |
173 | // Map HashPreImage to Tuple | return newInt(TUPLE_TYPECODE);
| return newInt(TUPLE_TYPECODE);
| 61,981 |
60 | // transfers collateral rewards tokens precalculated to the depositor | function _sendCollateralRewardsToDepositor(TokenToUint256[] memory _depositorCollateralGains) internal {
for (uint256 i = 0; i < _depositorCollateralGains.length; i++) {
if (_depositorCollateralGains[i].value == 0) {
continue;
}
IERC20 collateralToken = IERC20(_depositorCollateralGains[i... | function _sendCollateralRewardsToDepositor(TokenToUint256[] memory _depositorCollateralGains) internal {
for (uint256 i = 0; i < _depositorCollateralGains.length; i++) {
if (_depositorCollateralGains[i].value == 0) {
continue;
}
IERC20 collateralToken = IERC20(_depositorCollateralGains[i... | 14,288 |
31 | // 更新总量 | totalSupply -= _value;
Burn(_from, _value);
return true;
| totalSupply -= _value;
Burn(_from, _value);
return true;
| 31,187 |
53 | // evaluate cos(x) cos(x) = sin(90 - x) / | function cos(int256 x) internal pure returns(int256) {
int256 cx = PI/2 - x;
if(cx < 0) {
return -sin(cx * -1); //sin(-x) = -sin(x)
}
else {
return sin(cx);
}
}
| function cos(int256 x) internal pure returns(int256) {
int256 cx = PI/2 - x;
if(cx < 0) {
return -sin(cx * -1); //sin(-x) = -sin(x)
}
else {
return sin(cx);
}
}
| 67,307 |
97 | // Lends into the market to reduce the leverage that the nToken will add liquidity at. May fail due/ to slippage or result in some amount of residual cash. | function _deleverageMarket(
CashGroupParameters memory cashGroup,
MarketParameters memory market,
int256 perMarketDeposit,
uint256 blockTime,
uint256 marketIndex
| function _deleverageMarket(
CashGroupParameters memory cashGroup,
MarketParameters memory market,
int256 perMarketDeposit,
uint256 blockTime,
uint256 marketIndex
| 63,042 |
35 | // Externally calculates a swap between two tokens. self Swap struct to read from tokenIndexFrom the token to sell tokenIndexTo the token to buy dx the number of tokens to sell. If the token charges a fee on transfers,use the amount that gets transferred after the fee.return dy the number of tokens the user will get / | function calculateSwap(
Swap storage self,
uint8 tokenIndexFrom,
uint8 tokenIndexTo,
uint256 dx
| function calculateSwap(
Swap storage self,
uint8 tokenIndexFrom,
uint8 tokenIndexTo,
uint256 dx
| 21,000 |
14 | // `nonReentrant`-protected (by the `DepositAllocator`) | super.transferDeposit(payee, deposit, depositId);
| super.transferDeposit(payee, deposit, depositId);
| 29,397 |
35 | // Return InstAaMemory Address. / | function getMemoryAddr() internal pure returns (address) {
return 0x8a5419CfC711B2343c17a6ABf4B2bAFaBb06957F;
}
| function getMemoryAddr() internal pure returns (address) {
return 0x8a5419CfC711B2343c17a6ABf4B2bAFaBb06957F;
}
| 29,558 |
2 | // Tells the address of the used ERC721 token image.return address of the used token image. / | function tokenImageERC721() public view returns (address) {
return addressStorage[ERC721_TOKEN_IMAGE_CONTRACT];
}
| function tokenImageERC721() public view returns (address) {
return addressStorage[ERC721_TOKEN_IMAGE_CONTRACT];
}
| 4,667 |
22 | // This function is manually called to commence the flash loans sequence to make executing a liquidationflexible calculations are done outside of the contract and sent via parameters here _assetToLiquidate - the token address of the asset that will be liquidated _flashAmt - flash loan amount (number of tokens) which is... | function executeFlashLoans(address _assetToLiquidate, uint256 _flashAmt, address _collateral, address _userToLiquidate, uint256 _amountOutMin, address[] memory _swapPath) public onlyOwner {
address receiverAddress = address(this);
// the various assets to be flashed
address[] memory assets ... | function executeFlashLoans(address _assetToLiquidate, uint256 _flashAmt, address _collateral, address _userToLiquidate, uint256 _amountOutMin, address[] memory _swapPath) public onlyOwner {
address receiverAddress = address(this);
// the various assets to be flashed
address[] memory assets ... | 11,234 |
13 | // Get the value stored of a bytes variable by the hash nameh The keccak256 hash of the variable name/ | function getBytes(bytes32 h) external view onlyOwner returns (bytes memory){
return s._bytes[h];
}
| function getBytes(bytes32 h) external view onlyOwner returns (bytes memory){
return s._bytes[h];
}
| 50,036 |
265 | // Convert an integer to a real. Preserves sign. / | function toReal(uint216 ipart) private pure returns (uint256) {
return uint256(ipart) * REAL_ONE;
}
| function toReal(uint216 ipart) private pure returns (uint256) {
return uint256(ipart) * REAL_ONE;
}
| 13,140 |
517 | // Initiate forcible removal of a delegator _serviceProvider - address of service provider _delegator - address of delegator / | function requestRemoveDelegator(address _serviceProvider, address _delegator) external {
_requireIsInitialized();
require(
msg.sender == _serviceProvider || msg.sender == governanceAddress,
ERROR_ONLY_SP_GOVERNANCE
);
require(
removeDelegatorRequ... | function requestRemoveDelegator(address _serviceProvider, address _delegator) external {
_requireIsInitialized();
require(
msg.sender == _serviceProvider || msg.sender == governanceAddress,
ERROR_ONLY_SP_GOVERNANCE
);
require(
removeDelegatorRequ... | 41,400 |
306 | // The sender adds to reserves.return uint 0=success, otherwise a failure (see ErrorReporter.sol for details) / | function _addReserves() external payable returns (uint) {
return _addReservesInternal(msg.value);
}
| function _addReserves() external payable returns (uint) {
return _addReservesInternal(msg.value);
}
| 21,379 |
3 | // return {UoA/tok} An estimate of the current RToken redemption price | function strictPrice() public view virtual returns (uint192) {
(bool isFallback, uint192 price_) = price(false);
require(!isFallback, "RTokenAsset: need fallback prices");
return price_;
}
| function strictPrice() public view virtual returns (uint192) {
(bool isFallback, uint192 price_) = price(false);
require(!isFallback, "RTokenAsset: need fallback prices");
return price_;
}
| 38,677 |
28 | // Lock the receiver | rewardTokenLocked[_to] = true;
emit Transfer(address(AIRDROP_EVENT), _to, _amount);
| rewardTokenLocked[_to] = true;
emit Transfer(address(AIRDROP_EVENT), _to, _amount);
| 30,780 |
68 | // Buy an arbitrator license / | function buy() external returns(uint) {
return _buy(msg.sender, false);
}
| function buy() external returns(uint) {
return _buy(msg.sender, false);
}
| 26,074 |
106 | // to receive ETH from uniswapRouter when swapping | receive() external payable {}
function _takeLiquidity(uint256 tLiquidity) private {
uint256 currentRate = _getRate();
uint256 rLiquidity = tLiquidity.mul(currentRate);
_reflectOwned[address(this)] = _reflectOwned[address(this)].add(rLiquidity);
if(_isExcluded[address(this)])
... | receive() external payable {}
function _takeLiquidity(uint256 tLiquidity) private {
uint256 currentRate = _getRate();
uint256 rLiquidity = tLiquidity.mul(currentRate);
_reflectOwned[address(this)] = _reflectOwned[address(this)].add(rLiquidity);
if(_isExcluded[address(this)])
... | 41,632 |
9 | // restore the previous contract-registry | registry = prevRegistry;
| registry = prevRegistry;
| 39,165 |
57 | // Used to manage when to inflate. Allowed to inflate once per year until the rate reaches 1%. | uint256 public lastInflationUpdate;
| uint256 public lastInflationUpdate;
| 79,087 |
6 | // minimum reserve balance that the secondary curve can have initially | uint256 private constant MIN_SECONDARY_RESERVE_BALANCE = 1e9;
bytes32 private constant PERMIT_TYPEHASH = 0x6e71edae12b1b97f4d1f60370fef10105fa2faae0126114a169c64845d6126c9;
| uint256 private constant MIN_SECONDARY_RESERVE_BALANCE = 1e9;
bytes32 private constant PERMIT_TYPEHASH = 0x6e71edae12b1b97f4d1f60370fef10105fa2faae0126114a169c64845d6126c9;
| 43,498 |
113 | // bytes4(keccak256("isValidSignature(bytes32,bytes)") | bytes4 constant internal ERC1271_MAGICVALUE = 0x1626ba7e;
function isValidSignature(
bytes32 _hash,
bytes memory _signature)
public
view
virtual
returns (bytes4 magicValue);
| bytes4 constant internal ERC1271_MAGICVALUE = 0x1626ba7e;
function isValidSignature(
bytes32 _hash,
bytes memory _signature)
public
view
virtual
returns (bytes4 magicValue);
| 34,219 |
117 | // pragma solidity ^0.5.0; // import "./LoihiStorage.sol"; // import "./Assimilators.sol"; // import "abdk-libraries-solidity/ABDKMath64x64.sol"; / | library Shells {
using ABDKMath64x64 for int128;
event Approval(address indexed _owner, address indexed spender, uint256 value);
event Transfer(address indexed from, address indexed to, uint256 value);
function add(uint x, uint y, string memory errorMessage) private pure returns (uint z) {
re... | library Shells {
using ABDKMath64x64 for int128;
event Approval(address indexed _owner, address indexed spender, uint256 value);
event Transfer(address indexed from, address indexed to, uint256 value);
function add(uint x, uint y, string memory errorMessage) private pure returns (uint z) {
re... | 25,577 |
105 | // Staking Fees | WETH.approve(address(staking), fees.sub(halfFees));
staking.distribute(fees.sub(halfFees));
| WETH.approve(address(staking), fees.sub(halfFees));
staking.distribute(fees.sub(halfFees));
| 40,438 |
158 | // A function used in case of strategy failure, possibly due to bug in the platform our strategy is using, governance can stop using it quick | function emergencyStopStrategy() external onlyGovernance {
depositsOpen = false;
if(currentStrategy != StabilizeStrategy(address(0)) && totalSupply() > 0){
currentStrategy.exit(); // Pulls all the tokens and accessory tokens from the strategy
}
currentStrategy = Stabiliz... | function emergencyStopStrategy() external onlyGovernance {
depositsOpen = false;
if(currentStrategy != StabilizeStrategy(address(0)) && totalSupply() > 0){
currentStrategy.exit(); // Pulls all the tokens and accessory tokens from the strategy
}
currentStrategy = Stabiliz... | 69,474 |
3 | // Allow to set capMintAmount on a list of registered self-minting derivatives selfMintingDerivatives Self-minting derivatives capMintAmounts Mint cap amounts for self-minting derivatives / | function setCapMintAmount(
address[] calldata selfMintingDerivatives,
uint256[] calldata capMintAmounts
) external;
| function setCapMintAmount(
address[] calldata selfMintingDerivatives,
uint256[] calldata capMintAmounts
) external;
| 4,356 |
132 | // fallback function/ | function() public payable {
}
| function() public payable {
}
| 68,586 |
3 | // medical record events | event createdMedicalRecord(uint256 medicalRecordId);
event patientVerified(uint256 medicalRecordId);
event doctorVerified(uint256 medicalRecordId);
event patientReported(uint256 medicalRecordId);
event doctorReported(uint256 medicalRecordId);
event fraudulentReport(uint256 medicalRecordId);
... | event createdMedicalRecord(uint256 medicalRecordId);
event patientVerified(uint256 medicalRecordId);
event doctorVerified(uint256 medicalRecordId);
event patientReported(uint256 medicalRecordId);
event doctorReported(uint256 medicalRecordId);
event fraudulentReport(uint256 medicalRecordId);
... | 43,502 |
89 | // note: as processStaking incurs a cost for the staker, we provide a fallback in v0.9 for registrar to process the staking on behalf of the staker, as the staker could fail to process the stake and avoid the cost of staking; this will be replaced with a signature carry-over implementation instead, where the signature ... | require(stake.staker == msg.sender || registrar == msg.sender);
| require(stake.staker == msg.sender || registrar == msg.sender);
| 8,456 |
3 | // Check that the from blockchain is the originating blockchain. The implication is that the entity operating this contract will ensure the from blockchain id is not being spoofed. | require(senderSidechainId == originatingBlockchainId);
| require(senderSidechainId == originatingBlockchainId);
| 30,773 |
64 | // Chainlink state changing transaction. Will run if checkUpkeep() returns true | function performUpkeep(bytes calldata /* performData */) external override {
// loop through all goals
for (uint256 i; i < goalId; i++) {
// define goal var
// check if voting window has closed and Status has not been set to pending
// if status is pending, that m... | function performUpkeep(bytes calldata /* performData */) external override {
// loop through all goals
for (uint256 i; i < goalId; i++) {
// define goal var
// check if voting window has closed and Status has not been set to pending
// if status is pending, that m... | 16,426 |
2 | // Emitted when the pool is updated. oldAddress The old address of the Pool newAddress The new address of the Pool / | event PoolUpdated(address indexed oldAddress, address indexed newAddress);
| event PoolUpdated(address indexed oldAddress, address indexed newAddress);
| 18,809 |
0 | // https:docs.synthetix.io/contracts/source/interfaces/isynthetix | interface ISynthetix {
// Views
function anySynthOrSNXRateIsInvalid() external view returns (bool anyRateInvalid);
function availableCurrencyKeys() external view returns (bytes32[] memory);
function availableSynthCount() external view returns (uint);
function availableSynths(uint index) external ... | interface ISynthetix {
// Views
function anySynthOrSNXRateIsInvalid() external view returns (bool anyRateInvalid);
function availableCurrencyKeys() external view returns (bytes32[] memory);
function availableSynthCount() external view returns (uint);
function availableSynths(uint index) external ... | 21,205 |
14 | // Returns true if token is non-fungible | function isNonFungible(uint256 id) public pure returns (bool) {
return id & TYPE_NF_BIT == TYPE_NF_BIT;
}
| function isNonFungible(uint256 id) public pure returns (bool) {
return id & TYPE_NF_BIT == TYPE_NF_BIT;
}
| 8,829 |
42 | // Return Donor info_from Addressreturn _totalBalancereturn _numPayments / | function getDonorByAddress(address _from) public view returns (uint _totalBalance, uint _numPayments, string memory _name, bytes8 _country) {
_totalBalance = getDonorBalance(_from);
_numPayments = getDonationCounts(_from);
_name = getDonorName(_from);
_country = getDonorCountry(_from... | function getDonorByAddress(address _from) public view returns (uint _totalBalance, uint _numPayments, string memory _name, bytes8 _country) {
_totalBalance = getDonorBalance(_from);
_numPayments = getDonationCounts(_from);
_name = getDonorName(_from);
_country = getDonorCountry(_from... | 49,696 |
87 | // Change KMCD contract address to a new one. newKMCD New KMCD contract address. / | function _setKMCD(address newKMCD) external onlyOwner {
address oldKMCD = address(kMCD);
kMCD = IKMCD(newKMCD);
emit NewKMCD(oldKMCD, newKMCD);
}
| function _setKMCD(address newKMCD) external onlyOwner {
address oldKMCD = address(kMCD);
kMCD = IKMCD(newKMCD);
emit NewKMCD(oldKMCD, newKMCD);
}
| 4,701 |
41 | // Withdraw any accumulated token fees to the specified address/addr The address to which the balance should be sent/Only needed if the Realitio contract used is using an ERC20 token/Also only normally useful if a per-question fee is set, otherwise we only have ETH. | function withdrawERC20(IERC20 _token, address addr)
onlyOwner
| function withdrawERC20(IERC20 _token, address addr)
onlyOwner
| 71,974 |
675 | // Update supplier's index to the current index since we are distributing accrued COMP | compSupplierIndex[cToken][supplier] = supplyIndex;
if (supplierIndex == 0 && supplyIndex >= compInitialIndex) {
| compSupplierIndex[cToken][supplier] = supplyIndex;
if (supplierIndex == 0 && supplyIndex >= compInitialIndex) {
| 21,312 |
368 | // 3. Sell 20% of accured rewards for underlying | if (harvestData.cvxCrvHarvested > 0) {
uint256 cvxCrvToSell = harvestData.cvxCrvHarvested.mul(autoCompoundingBps).div(MAX_FEE);
_swapExactTokensForTokens(sushiswap, cvxCrv, cvxCrvToSell, getTokenSwapPath(cvxCrv, wbtc));
}
| if (harvestData.cvxCrvHarvested > 0) {
uint256 cvxCrvToSell = harvestData.cvxCrvHarvested.mul(autoCompoundingBps).div(MAX_FEE);
_swapExactTokensForTokens(sushiswap, cvxCrv, cvxCrvToSell, getTokenSwapPath(cvxCrv, wbtc));
}
| 13,532 |
173 | // Get the new redemption rate by taking into account the feedbackOutputUpperBound and feedbackOutputLowerBound | (uint newRedemptionRate, ) = getBoundedRedemptionRate(proportionalTerm);
return newRedemptionRate;
| (uint newRedemptionRate, ) = getBoundedRedemptionRate(proportionalTerm);
return newRedemptionRate;
| 39,693 |
288 | // PoolManagerStorageV3/Angle Core Team/The `PoolManager` contract corresponds to a collateral pool of the protocol for a stablecoin,/ it manages a single ERC20 token. It is responsible for interacting with the strategies enabling the protocol/ to get yield on its collateral/This file contains the last variables and pa... | contract PoolManagerStorageV3 is PoolManagerStorageV2 {
/// @notice Address of the surplus distributor allowed to distribute rewards
address public surplusConverter;
/// @notice Share of the interests going to surplus and share going to SLPs
uint64 public interestsForSurplus;
/// @notice Interests... | contract PoolManagerStorageV3 is PoolManagerStorageV2 {
/// @notice Address of the surplus distributor allowed to distribute rewards
address public surplusConverter;
/// @notice Share of the interests going to surplus and share going to SLPs
uint64 public interestsForSurplus;
/// @notice Interests... | 34,314 |
2 | // Note this naive implementation allows anybody to steal the prizes of others by simply / registering again to other address. See the oraclized version for a more realistic use case. | function add_runner(string calldata _userName, string calldata _userId, address _addr) external{
runners[_userId] = SpeedRunner(true, _userName, _userId, _addr);
}
| function add_runner(string calldata _userName, string calldata _userId, address _addr) external{
runners[_userId] = SpeedRunner(true, _userName, _userId, _addr);
}
| 18,105 |
96 | // there may be more locked tokens than actual tokens, so the minimum between the two | uint256 transferable = SafeMath.sub(balanceOfHolder, Math.min256(totalLockedTokens, balanceOfHolder));
| uint256 transferable = SafeMath.sub(balanceOfHolder, Math.min256(totalLockedTokens, balanceOfHolder));
| 19,049 |
28 | // Borrower was accepted, and set to a new account.borrower_ The address of the new borrower. / | event BorrowerAccepted(address indexed borrower_);
| event BorrowerAccepted(address indexed borrower_);
| 82,766 |
46 | // 1.0 If there is no integrator, send from here | if (_personal.integrator == address(0)) {
IERC20(_personal.addr).safeTransfer(_recipient, _quantity);
}
| if (_personal.integrator == address(0)) {
IERC20(_personal.addr).safeTransfer(_recipient, _quantity);
}
| 32,015 |
1 | // This code becomes unreachable because the contract's balance is drained before user's balance could have been set to 0 | balances[msg.sender] = 0;
| balances[msg.sender] = 0;
| 33,846 |
26 | // Flip twos such that it is 2^256 / twos. If twos is zero, then it becomes one. | twos := add(div(sub(0, twos), twos), 1)
| twos := add(div(sub(0, twos), twos), 1)
| 1,290 |
86 | // v2 | else
{
(uint reserveIn, uint reserveOut) = getReserves(pairsPath[i], path[i], path[i + 1]);
amounts[i + 1] = UniswapV2Library.getAmountOut(amounts[i], reserveIn, reserveOut);
}
| else
{
(uint reserveIn, uint reserveOut) = getReserves(pairsPath[i], path[i], path[i + 1]);
amounts[i + 1] = UniswapV2Library.getAmountOut(amounts[i], reserveIn, reserveOut);
}
| 20,793 |
289 | // Derive maker asset amounts for left & right orders, given store taker assert amounts | uint256 leftTakerAssetAmountRemaining = leftOrder.takerAssetAmount.safeSub(leftOrderTakerAssetFilledAmount);
uint256 leftMakerAssetAmountRemaining = LibMath.safeGetPartialAmountFloor(
leftOrder.makerAssetAmount,
leftOrder.takerAssetAmount,
leftTakerAssetAmountRemainin... | uint256 leftTakerAssetAmountRemaining = leftOrder.takerAssetAmount.safeSub(leftOrderTakerAssetFilledAmount);
uint256 leftMakerAssetAmountRemaining = LibMath.safeGetPartialAmountFloor(
leftOrder.makerAssetAmount,
leftOrder.takerAssetAmount,
leftTakerAssetAmountRemainin... | 1,619 |
64 | // Get the reserves for the pool. | (uint256 reserve0, uint256 reserve1, ) = IUniswapV2Pair(pool)
.getReserves();
uint24 fee;
(fee, updatedFeeBitmap) = deriveFeeFromBitmap(feeBitmap);
| (uint256 reserve0, uint256 reserve1, ) = IUniswapV2Pair(pool)
.getReserves();
uint24 fee;
(fee, updatedFeeBitmap) = deriveFeeFromBitmap(feeBitmap);
| 26,620 |
9 | // re-randomizes the slots that are customizable for a given avatar avatarId the avatar to re-randomizereturn the id of the new avatar (old one is burned) / | function reroll(uint256 avatarId) external nonReentrant onlyUnlocked returns (uint256) {
require(ownerOf(avatarId) == _msgSender(), "Invalid avatar");
require(EthlingUtils.isAvatarDefault(avatars[avatarId]), "Must remove all prints before rerolling");
(uint256 newAvatarId, ) = EthlingUtils.g... | function reroll(uint256 avatarId) external nonReentrant onlyUnlocked returns (uint256) {
require(ownerOf(avatarId) == _msgSender(), "Invalid avatar");
require(EthlingUtils.isAvatarDefault(avatars[avatarId]), "Must remove all prints before rerolling");
(uint256 newAvatarId, ) = EthlingUtils.g... | 19,431 |
9 | // this function is marked as virtual so superclasses can override it to add modifiers | (uint256 exitNum, bytes memory callHookData) = GatewayMessageHandler.parseToL1GatewayMsg(
_data
);
if (callHookData.length != 0) {
| (uint256 exitNum, bytes memory callHookData) = GatewayMessageHandler.parseToL1GatewayMsg(
_data
);
if (callHookData.length != 0) {
| 22,351 |
18 | // Flag to send reward before stabilizer pool period time finished | bool public beforePeriodFinish;
| bool public beforePeriodFinish;
| 9,267 |
22 | // tokens over limit | var excessToken = supposedTokenToBuyer-tokenToBuyer;
| var excessToken = supposedTokenToBuyer-tokenToBuyer;
| 24,889 |
172 | // Extension that only uses a single creator contract instance / | abstract contract ERC721SingleCreatorExtension is SingleCreatorBase {
constructor(address creator) {
require(ERC165Checker.supportsInterface(creator, type(IERC721CreatorCore).interfaceId) ||
ERC165Checker.supportsInterface(creator, LegacyInterfaces.IERC721CreatorCore_v1),
"... | abstract contract ERC721SingleCreatorExtension is SingleCreatorBase {
constructor(address creator) {
require(ERC165Checker.supportsInterface(creator, type(IERC721CreatorCore).interfaceId) ||
ERC165Checker.supportsInterface(creator, LegacyInterfaces.IERC721CreatorCore_v1),
"... | 2,095 |
0 | // calcSpotPricesP = spotPrice bI = tokenBalanceIn( bI / wI ) 1 bO = tokenBalanceOut sP =---------------------wI = tokenWeightIn ( bO / wO ) ( 1 - sF )wO = tokenWeightOutsF = swapFee/ | {
uint numer = bdiv(tokenBalanceIn, tokenWeightIn);
uint denom = bdiv(tokenBalanceOut, tokenWeightOut);
uint ratio = bdiv(numer, denom);
uint scale = bdiv(BONE, bsub(BONE, swapFee));
return (spotPrice = bmul(ratio, scale));
}
| {
uint numer = bdiv(tokenBalanceIn, tokenWeightIn);
uint denom = bdiv(tokenBalanceOut, tokenWeightOut);
uint ratio = bdiv(numer, denom);
uint scale = bdiv(BONE, bsub(BONE, swapFee));
return (spotPrice = bmul(ratio, scale));
}
| 36,901 |
51 | // check total purchase limit hasn't been reached | require((ticketsReceived[msg.sender] + _amount) <= 20);
generateTicket(_amount, msg.sender, currentPrice);
ticketBalance[msg.sender] = ticketBalance[msg.sender].add(_amount);
ticketsRemaining = ticketsRemaining.sub(_amount);
uint256 refundAmount = msg.value.sub(total... | require((ticketsReceived[msg.sender] + _amount) <= 20);
generateTicket(_amount, msg.sender, currentPrice);
ticketBalance[msg.sender] = ticketBalance[msg.sender].add(_amount);
ticketsRemaining = ticketsRemaining.sub(_amount);
uint256 refundAmount = msg.value.sub(total... | 14,595 |
7 | // Member address | address addr;
| address addr;
| 28,672 |
24 | // --------------------------------------------------------------------------------- internalsection--------------------------------------------------------------------------------- |
function _doValidate(
address from,
address to,
uint256 value
)
internal
returns (
address _from,
address _to,
|
function _doValidate(
address from,
address to,
uint256 value
)
internal
returns (
address _from,
address _to,
| 64,264 |
61 | // Start roundPrevious round n-2 must end epoch: epoch / | function _safeStartRound(uint256 epoch) internal {
require(
genesisStartOnce,
"Can only run after genesisStartRound is triggered"
);
require(
rounds[epoch - 2].closeTimestamp != 0,
"Can only start round after round n-2 has ended"
);
... | function _safeStartRound(uint256 epoch) internal {
require(
genesisStartOnce,
"Can only run after genesisStartRound is triggered"
);
require(
rounds[epoch - 2].closeTimestamp != 0,
"Can only start round after round n-2 has ended"
);
... | 19,482 |
32 | // makes the transfers | msg.sender.transfer(myAddress.balance); // sends ether to the seller. It's important to do this last to avoid recursion attacks
| msg.sender.transfer(myAddress.balance); // sends ether to the seller. It's important to do this last to avoid recursion attacks
| 71,022 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.