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 |
|---|---|---|---|---|
20 | // ========== MUTATIVE FUNCTIONS ========== // initialize contract _stake address of stake token _reward address of reward token _start epoch seconds of mining starts _end epoch seconds of mining complete _totalReward totalReward / | function initialize(
address _stake,
address _reward,
uint256 _start,
uint256 _end,
uint256 _totalReward
) external override {
require(!initialized, "initialized = true");
| function initialize(
address _stake,
address _reward,
uint256 _start,
uint256 _end,
uint256 _totalReward
) external override {
require(!initialized, "initialized = true");
| 13,075 |
34 | // atEditionId is one-indexed hence the need to remove one here | return editionSize + 1 - atEditionId.current();
| return editionSize + 1 - atEditionId.current();
| 15,110 |
54 | // Default fallback function | function() payable
| function() payable
| 36,640 |
1 | // EIP-2 still allows signature malleability for ecrecover(). Remove this possibility and make the signature unique. Appendix F in the Ethereum Yellow paper (https:ethereum.github.io/yellowpaper/paper.pdf), defines | // the valid range for s in (301): 0 < s < secp256k1n ÷ 2 + 1, and for v in (302): v ∈ {27, 28}. Most
// signatures from current libraries generate a unique signature with an s-value in the lower half order.
//
// If your library generates malleable signatures, such as s-values in the upper range, calculate a new s-value
// with 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEBAAEDCE6AF48A03BBFD25E8CD0364141 - s1 and flip v from 27 to 28 or
// vice versa. If your library also generates signatures with 0/1 for v instead 27/28, add 27 to v to accept
// these malleable signatures as well.
uint256 private constant _S_BOUNDARY = 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF5D576E7357A4501DDFE92F46681B20A0 + 1;
uint256 private constant _COMPACT_S_MASK = 0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff;
uint256 private constant _COMPACT_V_SHIFT = 255;
function recover(
bytes32 hash,
uint8 v,
bytes32 r,
bytes32 s
) internal view returns (address signer) {
assembly ("memory-safe") { // solhint-disable-line no-inline-assembly
if lt(s, _S_BOUNDARY) {
let ptr := mload(0x40)
mstore(ptr, hash)
mstore(add(ptr, 0x20), v)
mstore(add(ptr, 0x40), r)
mstore(add(ptr, 0x60), s)
mstore(0, 0)
pop(staticcall(gas(), 0x1, ptr, 0x80, 0, 0x20))
signer := mload(0)
}
}
}
| // the valid range for s in (301): 0 < s < secp256k1n ÷ 2 + 1, and for v in (302): v ∈ {27, 28}. Most
// signatures from current libraries generate a unique signature with an s-value in the lower half order.
//
// If your library generates malleable signatures, such as s-values in the upper range, calculate a new s-value
// with 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEBAAEDCE6AF48A03BBFD25E8CD0364141 - s1 and flip v from 27 to 28 or
// vice versa. If your library also generates signatures with 0/1 for v instead 27/28, add 27 to v to accept
// these malleable signatures as well.
uint256 private constant _S_BOUNDARY = 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF5D576E7357A4501DDFE92F46681B20A0 + 1;
uint256 private constant _COMPACT_S_MASK = 0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff;
uint256 private constant _COMPACT_V_SHIFT = 255;
function recover(
bytes32 hash,
uint8 v,
bytes32 r,
bytes32 s
) internal view returns (address signer) {
assembly ("memory-safe") { // solhint-disable-line no-inline-assembly
if lt(s, _S_BOUNDARY) {
let ptr := mload(0x40)
mstore(ptr, hash)
mstore(add(ptr, 0x20), v)
mstore(add(ptr, 0x40), r)
mstore(add(ptr, 0x60), s)
mstore(0, 0)
pop(staticcall(gas(), 0x1, ptr, 0x80, 0, 0x20))
signer := mload(0)
}
}
}
| 25,919 |
282 | // concatenate storage byte array with the new l1Tx | _concatStorage(mapL1TxQueue[nextL1FillingQueue], l1Tx);
emit L1UserTxEvent(nextL1FillingQueue, uint8(currentPosition), l1Tx);
if (currentPosition + 1 >= _MAX_L1_USER_TX) {
nextL1FillingQueue++;
}
| _concatStorage(mapL1TxQueue[nextL1FillingQueue], l1Tx);
emit L1UserTxEvent(nextL1FillingQueue, uint8(currentPosition), l1Tx);
if (currentPosition + 1 >= _MAX_L1_USER_TX) {
nextL1FillingQueue++;
}
| 79,290 |
17 | // Override this to implement your module! | function _checkIfEligible(uint256 _tokenId) internal view virtual returns (bool);
| function _checkIfEligible(uint256 _tokenId) internal view virtual returns (bool);
| 58,582 |
5 | // Zethr main contract interface | contract ZethrInterface{
function withdraw() public;
}
| contract ZethrInterface{
function withdraw() public;
}
| 13,764 |
238 | // user has to have at least equal amount of tokens which he's willing to buy | require(getCurrentUserMaxPurchase() >= tokenAmount);
| require(getCurrentUserMaxPurchase() >= tokenAmount);
| 18,506 |
24 | // ========== ADDRESS RESOLVER CONFIGURATION ========== / ========== CONSTRUCTOR ========== | constructor(address _owner, address _resolver) public Owned(_owner) Pausable() MixinResolver(_resolver) {
liquidationDeadline = now + 92 days; // Time before loans can be liquidated
}
| constructor(address _owner, address _resolver) public Owned(_owner) Pausable() MixinResolver(_resolver) {
liquidationDeadline = now + 92 days; // Time before loans can be liquidated
}
| 36,245 |
281 | // Tests equality of two byte arrays./lhs First byte array to compare./rhs Second byte array to compare./ return True if arrays are the same. False otherwise. | function equals(
bytes memory lhs,
bytes memory rhs
)
internal
pure
returns (bool equal)
| function equals(
bytes memory lhs,
bytes memory rhs
)
internal
pure
returns (bool equal)
| 42,197 |
9 | // solhint-disable avoid-low-level-calls slither-disable-next-line low-level-calls | (bool success, ) = to.call{ value: value }("");
| (bool success, ) = to.call{ value: value }("");
| 25,150 |
78 | // Finalise the crowdsale funds | assert(!salesAgents[msg.sender].finalised);
| assert(!salesAgents[msg.sender].finalised);
| 33,478 |
29 | // Converting fromToken to WETH | path[0] = address(_fromToken);
path[1] = address(WETH);
uint256[] memory amounts = router.swapExactTokensForTokens({
amountIn: _amountGet,
amountOutMin: 0,
path: path,
to: address(this),
deadline: uint(-1)
});
| path[0] = address(_fromToken);
path[1] = address(WETH);
uint256[] memory amounts = router.swapExactTokensForTokens({
amountIn: _amountGet,
amountOutMin: 0,
path: path,
to: address(this),
deadline: uint(-1)
});
| 54,386 |
7 | // called when user wants to withdraw tokens back to root chain Should burn user's tokens. This transaction will be verified when exiting on root chain amount amount of tokens to withdraw / | function withdraw(uint256 amount) external virtual {
_burn(_msgSender(), amount);
}
| function withdraw(uint256 amount) external virtual {
_burn(_msgSender(), amount);
}
| 139 |
22 | // total reward token | _balances[msg.sender][stakingToken_].totalInReward = _balances[
msg.sender
][stakingToken_].totalInReward.add(_amountReward);
emit Stake(msg.sender, amount_);
| _balances[msg.sender][stakingToken_].totalInReward = _balances[
msg.sender
][stakingToken_].totalInReward.add(_amountReward);
emit Stake(msg.sender, amount_);
| 12,862 |
241 | // calculate the service fee | serviceFee = askingPrice[_tokenId] * serviceFeeNum / 10000;
ILoyaltyToken LoyaltyTokenContract = ILoyaltyToken(loyaltyTokenAddress);
if(loyaltyTokenAddress==address(0) || LoyaltyTokenContract.userTotalStake(msg.sender)<loyaltyTokenLimit){
require(msg.value == askingPrice[_tokenId], "Value missmatch");
} else {
| serviceFee = askingPrice[_tokenId] * serviceFeeNum / 10000;
ILoyaltyToken LoyaltyTokenContract = ILoyaltyToken(loyaltyTokenAddress);
if(loyaltyTokenAddress==address(0) || LoyaltyTokenContract.userTotalStake(msg.sender)<loyaltyTokenLimit){
require(msg.value == askingPrice[_tokenId], "Value missmatch");
} else {
| 4,735 |
33 | // The stack TOKEN! | StackToken public stack;
| StackToken public stack;
| 14,255 |
7 | // Deposits `amount` into the sender's escrow balance and updates the global depositbalance. Sender should ensure that this contract has a transfer allowance of at least `amount` of REVV from their account before calling this function. Reverts if the contract is paused. Reverts if the sale has started. Reverts if the sale has ended. Reverts if the deposit amount is zero. Reverts if the updated global deposit balance overflows. Reverts if the deposit transfer from the sender fails. Emits the Deposited event. An amount of REVV is transferred from the sender to this contract. amount The amount to deposit. / | function deposit(
uint256 amount
| function deposit(
uint256 amount
| 13,426 |
104 | // Returns the token id of the next minted token | function nextTokenId() external view returns(uint256){
return _nextTokenId;
}
| function nextTokenId() external view returns(uint256){
return _nextTokenId;
}
| 26,179 |
148 | // Unstake an amount from each protocol on Nxm (takes 30 days to unstake). _lastId The ID of the last unstake request on Nexus Mutual (needed for unstaking).return unstakeAmount The amount of each token that we're unstaking./ | {
IPooledStaking pool = IPooledStaking( _getPool() );
for(uint256 i = 0; i < bucketSize; i++) {
uint256 index = (startProtocol + i) % protocols.length;
if(index < checkpointProtocol) index = index + checkpointProtocol;
uint256 unstakePercent = unstakePercents[index];
address unstakeProtocol = protocols[index];
uint256 stake = pool.stakerContractStake(address(this), unstakeProtocol);
unstakeAmount = stake.mul(unstakePercent).div(DENOMINATOR);
uint256 trueUnstakeAmount = _protocolUnstakeable(unstakeProtocol, unstakeAmount);
// Can't unstake less than 20 NXM.
if (trueUnstakeAmount < 20 ether) continue;
amounts.push(trueUnstakeAmount);
activeProtocols.push(unstakeProtocol);
}
pool.requestUnstake(activeProtocols, amounts, _lastId);
delete amounts;
delete activeProtocols;
}
| {
IPooledStaking pool = IPooledStaking( _getPool() );
for(uint256 i = 0; i < bucketSize; i++) {
uint256 index = (startProtocol + i) % protocols.length;
if(index < checkpointProtocol) index = index + checkpointProtocol;
uint256 unstakePercent = unstakePercents[index];
address unstakeProtocol = protocols[index];
uint256 stake = pool.stakerContractStake(address(this), unstakeProtocol);
unstakeAmount = stake.mul(unstakePercent).div(DENOMINATOR);
uint256 trueUnstakeAmount = _protocolUnstakeable(unstakeProtocol, unstakeAmount);
// Can't unstake less than 20 NXM.
if (trueUnstakeAmount < 20 ether) continue;
amounts.push(trueUnstakeAmount);
activeProtocols.push(unstakeProtocol);
}
pool.requestUnstake(activeProtocols, amounts, _lastId);
delete amounts;
delete activeProtocols;
}
| 62,703 |
13 | // Signing address for the s_oracles[a].index'th oracle. I.e., report signatures from this oracle should ecrecover back to address a. | Signer,
| Signer,
| 22,807 |
1 | // IAssetProvider is the interface each asset provider implements.We assume there are three types of asset providers.1. Static asset provider, which has a collection of assets (either in the storage or the code) and returns them.2. Generative provider, which dynamically (but deterministically from the seed) generates assets.3. Data visualizer, which generates assets based on various data on the blockchain. Note: Asset providers MUST implements IERC165 (supportsInterface method) as well./ | interface IAssetProvider {
struct ProviderInfo {
string key; // short and unique identifier of this provider (e.g., "asset")
string name; // human readable display name (e.g., "Asset Store")
IAssetProvider provider;
}
function getProviderInfo() external view returns(ProviderInfo memory);
/**
* This function returns SVGPart and the tag. The SVGPart consists of one or more SVG elements.
* The tag specifies the identifier of the SVG element to be displayed (using <use> tag).
* The tag is the combination of the provider key and assetId (e.e., "asset123")
*/
function generateSVGPart(uint256 _assetId) external view returns(string memory svgPart, string memory tag);
/**
* This is an optional function, which returns various traits of the image for ERC721 token.
* Format: {"trait_type":"TRAIL_TYPE","value":"VALUE"},{...}
*/
function generateTraits(uint256 _assetId) external pure returns (string memory);
/**
* This function returns the number of assets available from this provider.
* If the total supply is 100, assetIds of available assets are 0,1,...99.
* The generative providers may returns 0, which indicates the provider dynamically but
* deterministically generates assets using the given assetId as the random seed.
*/
function totalSupply() external view returns(uint256);
/**
* Returns the onwer. The registration update is possible only if both contracts have the same owner.
*/
function getOwner() external view returns (address);
/**
* This function processes the royalty payment from the decentralized autonomous marketplace.
*/
function processPayout(uint256 _assetId) external payable;
event Payout(string providerKey, uint256 assetId, address payable to, uint256 amount);
} | interface IAssetProvider {
struct ProviderInfo {
string key; // short and unique identifier of this provider (e.g., "asset")
string name; // human readable display name (e.g., "Asset Store")
IAssetProvider provider;
}
function getProviderInfo() external view returns(ProviderInfo memory);
/**
* This function returns SVGPart and the tag. The SVGPart consists of one or more SVG elements.
* The tag specifies the identifier of the SVG element to be displayed (using <use> tag).
* The tag is the combination of the provider key and assetId (e.e., "asset123")
*/
function generateSVGPart(uint256 _assetId) external view returns(string memory svgPart, string memory tag);
/**
* This is an optional function, which returns various traits of the image for ERC721 token.
* Format: {"trait_type":"TRAIL_TYPE","value":"VALUE"},{...}
*/
function generateTraits(uint256 _assetId) external pure returns (string memory);
/**
* This function returns the number of assets available from this provider.
* If the total supply is 100, assetIds of available assets are 0,1,...99.
* The generative providers may returns 0, which indicates the provider dynamically but
* deterministically generates assets using the given assetId as the random seed.
*/
function totalSupply() external view returns(uint256);
/**
* Returns the onwer. The registration update is possible only if both contracts have the same owner.
*/
function getOwner() external view returns (address);
/**
* This function processes the royalty payment from the decentralized autonomous marketplace.
*/
function processPayout(uint256 _assetId) external payable;
event Payout(string providerKey, uint256 assetId, address payable to, uint256 amount);
} | 8,708 |
5 | // Returns the balance of the user | function getMyHoldings() external view returns(uint256 amountToken1, uint256 amountToken2/*, uint256 myShare*/) {
amountToken1 = token1Balance[msg.sender];
amountToken2 = token2Balance[msg.sender];
//myShare = shares[msg.sender];
}
| function getMyHoldings() external view returns(uint256 amountToken1, uint256 amountToken2/*, uint256 myShare*/) {
amountToken1 = token1Balance[msg.sender];
amountToken2 = token2Balance[msg.sender];
//myShare = shares[msg.sender];
}
| 5,317 |
28 | // Revokes `role` from the calling account. | * Roles are often managed via {grantRole} and {revokeRole}: this function's
* purpose is to provide a mechanism for accounts to lose their privileges
* if they are compromised (such as when a trusted device is misplaced).
*
* If the calling account had been granted `role`, emits a {RoleRevoked}
* event.
*
* Requirements:
*
* - the caller must be `account`.
*/
function renounceRole(bytes32 role, address account) public override {
require(account == msg.sender || hasRole(getRoleAdmin(role), msg.sender), "you cant renounce this role");
_revokeRole(role, account);
}
| * Roles are often managed via {grantRole} and {revokeRole}: this function's
* purpose is to provide a mechanism for accounts to lose their privileges
* if they are compromised (such as when a trusted device is misplaced).
*
* If the calling account had been granted `role`, emits a {RoleRevoked}
* event.
*
* Requirements:
*
* - the caller must be `account`.
*/
function renounceRole(bytes32 role, address account) public override {
require(account == msg.sender || hasRole(getRoleAdmin(role), msg.sender), "you cant renounce this role");
_revokeRole(role, account);
}
| 26,355 |
26 | // pauses or unpauses all the actions of the protocol, including aToken transfers val true if protocol needs to be paused, false otherwise / | function setPoolPause(bool val) external onlyEmergencyAdmin {
pool.setPause(val);
}
| function setPoolPause(bool val) external onlyEmergencyAdmin {
pool.setPause(val);
}
| 19,756 |
1 | // set entry, overwrite value if name already exists/name entry name, unique in index/value entry value as bytes32 | function setEntry(string name, bytes32 value, DigitalTwinLibrary.EntryType entryType) public auth {
DigitalTwinLibrary.setEntry(iclData, name, value, entryType);
}
| function setEntry(string name, bytes32 value, DigitalTwinLibrary.EntryType entryType) public auth {
DigitalTwinLibrary.setEntry(iclData, name, value, entryType);
}
| 5,636 |
56 | // Additional features and functions assigned to the/ Base721 contract for hooks and overrides | interface IBaseERC721Interface {
/*
Exposing common NFT internal functionality for base contract overrides
To save gas and make API cleaner this is only for new functionality not exposed in
the core ERC721 contract
*/
/// Mint an NFT. Allowed to mint by owner, approval or by the parent contract
/// @param tokenId id to burn
function __burn(uint256 tokenId) external;
/// Mint an NFT. Allowed only by the parent contract
/// @param to address to mint to
/// @param tokenId token id to mint
function __mint(address to, uint256 tokenId) external;
/// Set the base URI of the contract. Allowed only by parent contract
/// @param base base uri
/// @param extension extension
function __setBaseURI(string memory base, string memory extension) external;
/* Exposes common internal read features for public use */
/// Token exists
/// @param tokenId token id to see if it exists
function __exists(uint256 tokenId) external view returns (bool);
/// Simple approval for operation check on token for address
/// @param spender address spending/changing token
/// @param tokenId tokenID to change / operate on
function __isApprovedOrOwner(address spender, uint256 tokenId)
external
view
returns (bool);
function __isApprovedForAll(address owner, address operator)
external
view
returns (bool);
function __tokenURI(uint256 tokenId) external view returns (string memory);
function __owner() external view returns (address);
}
| interface IBaseERC721Interface {
/*
Exposing common NFT internal functionality for base contract overrides
To save gas and make API cleaner this is only for new functionality not exposed in
the core ERC721 contract
*/
/// Mint an NFT. Allowed to mint by owner, approval or by the parent contract
/// @param tokenId id to burn
function __burn(uint256 tokenId) external;
/// Mint an NFT. Allowed only by the parent contract
/// @param to address to mint to
/// @param tokenId token id to mint
function __mint(address to, uint256 tokenId) external;
/// Set the base URI of the contract. Allowed only by parent contract
/// @param base base uri
/// @param extension extension
function __setBaseURI(string memory base, string memory extension) external;
/* Exposes common internal read features for public use */
/// Token exists
/// @param tokenId token id to see if it exists
function __exists(uint256 tokenId) external view returns (bool);
/// Simple approval for operation check on token for address
/// @param spender address spending/changing token
/// @param tokenId tokenID to change / operate on
function __isApprovedOrOwner(address spender, uint256 tokenId)
external
view
returns (bool);
function __isApprovedForAll(address owner, address operator)
external
view
returns (bool);
function __tokenURI(uint256 tokenId) external view returns (string memory);
function __owner() external view returns (address);
}
| 7,344 |
75 | // Check that proposal creator is allowed to create a proposal. | uint256 balance = _governingToken.stakedOf(msg.sender);
uint256 weight = voteWeight();
require(balance >= weight);
| uint256 balance = _governingToken.stakedOf(msg.sender);
uint256 weight = voteWeight();
require(balance >= weight);
| 10,798 |
4 | // get the current balance of the swaped tokens | tokensSwaped = getBalance(destAddr) - tokensBefore;
require(tokensSwaped > 0, ERR_TOKENS_SWAPED_ZERO);
| tokensSwaped = getBalance(destAddr) - tokensBefore;
require(tokensSwaped > 0, ERR_TOKENS_SWAPED_ZERO);
| 24,341 |
41 | // this is to retry a failed message on LayerZero_srcChainId - the source chain identifier_srcAddress - the source chain contract address_nonce - the ordered message nonce_payload - the payload to be retried | function retryMessage(
uint16 _srcChainId
, bytes memory _srcAddress
, uint64 _nonce
, bytes calldata _payload
) external
| function retryMessage(
uint16 _srcChainId
, bytes memory _srcAddress
, uint64 _nonce
, bytes calldata _payload
) external
| 18,404 |
18 | // Destroy tokens Remove `_value` tokens from the system irreversibly _value The amount of money will be burnedreturn True if `_value` is burned successfully / | function burn(uint256 _value) public returns(bool) {
balances[msg.sender] = balances[msg.sender].sub(_value);
totalSupply = totalSupply.sub(_value);
emit Burn(msg.sender, _value);
return true;
}
| function burn(uint256 _value) public returns(bool) {
balances[msg.sender] = balances[msg.sender].sub(_value);
totalSupply = totalSupply.sub(_value);
emit Burn(msg.sender, _value);
return true;
}
| 26,725 |
45 | // Returns all rpc urls and their aliases as structs. | function rpcUrlStructs() external view returns (Rpc[] memory);
| function rpcUrlStructs() external view returns (Rpc[] memory);
| 26,085 |
38 | // Add a new role/only owner can call this function, the role has to be a new role./On success, `RoleAdded` event will be fired/role the role to be added | function addRole(bytes32 role) public onlyOwner {
require(!roleSet.contains(role), "role exists");
roleSet.add(role);
emit RoleAdded(role, _msgSender());
}
| function addRole(bytes32 role) public onlyOwner {
require(!roleSet.contains(role), "role exists");
roleSet.add(role);
emit RoleAdded(role, _msgSender());
}
| 2,952 |
166 | // event of exchange WRC-20 token with original chain token request/event invoked by storeman group/smgIDID of storemanGroup/tokenPairIDtoken pair ID of cross chain token/tokenAccount Rapidity shadow token account/valueRapidity value/userAccountaccount of shadow chain, used to receive token | event UserBurnLogger(bytes32 indexed smgID, uint indexed tokenPairID, address indexed tokenAccount, uint value, uint serviceFee, uint fee, bytes userAccount);
| event UserBurnLogger(bytes32 indexed smgID, uint indexed tokenPairID, address indexed tokenAccount, uint value, uint serviceFee, uint fee, bytes userAccount);
| 36,178 |
115 | // swap | bool canSwap = contractTokenBalance >= swapTokensAtAmount;
if (!swapping && canSwap && swapEnabled && recipient == pair) {
swapping = true;
swapBack();
swapping = false;
}
| bool canSwap = contractTokenBalance >= swapTokensAtAmount;
if (!swapping && canSwap && swapEnabled && recipient == pair) {
swapping = true;
swapBack();
swapping = false;
}
| 21,335 |
4 | // Keeping track | uint256 public totalMinted = 0;
uint256 public totalUnplugged = 0;
| uint256 public totalMinted = 0;
uint256 public totalUnplugged = 0;
| 19,659 |
18 | // Sets the configuration of the LayerZero messaging library of the specified version/version New messaging library version | function setSendVersion(uint16 version) external onlyOwner {
lzEndpoint.setSendVersion(version);
}
| function setSendVersion(uint16 version) external onlyOwner {
lzEndpoint.setSendVersion(version);
}
| 35,845 |
13 | // |/|/ Creates a NiftySwap Exchange for given token contract _tokenThe address of the ERC-1155 token contract _currency The address of the currency token contract _lpFeeFee that will go to LPs Number between 0 and 1000, where 10 is 1.0% and 100 is 10%. _instance Instancethat allows to deploy new instances of an exchange. This is mainly meant to be used for tokens that change their ERC-2981 support. / | function createExchange(address _token, address _currency, uint256 _lpFee, uint256 _instance) external;
| function createExchange(address _token, address _currency, uint256 _lpFee, uint256 _instance) external;
| 34,891 |
109 | // Returns the instructions associated with the module / | function getInstructions() external view returns (string);
| function getInstructions() external view returns (string);
| 6,696 |
2,236 | // 1119 | entry "bowered" : ENG_ADJECTIVE
| entry "bowered" : ENG_ADJECTIVE
| 17,731 |
18 | // calculate earned reflection minus claimed reflections / | function _allEarnedReflection(address tokenOwner) internal view returns (uint) {
uint[] memory _tokens = _tokensByOwner(tokenOwner);
if (_tokens.length == 0) {
return 0;
}
uint _allEarned;
uint _tEarned;
for (uint i = 0; i < _tokens.length; i++) {
_tEarned = _totalDividend - _claimedDividends[_tokens[i]];
if (_tEarned > 0) {
_allEarned += _tEarned;
}
}
return _allEarned;
}
| function _allEarnedReflection(address tokenOwner) internal view returns (uint) {
uint[] memory _tokens = _tokensByOwner(tokenOwner);
if (_tokens.length == 0) {
return 0;
}
uint _allEarned;
uint _tEarned;
for (uint i = 0; i < _tokens.length; i++) {
_tEarned = _totalDividend - _claimedDividends[_tokens[i]];
if (_tEarned > 0) {
_allEarned += _tEarned;
}
}
return _allEarned;
}
| 4,997 |
4 | // Intermediate Logic, confirm amount of tokens received, approve next exchange to sell | uint256 tokensReceived = IERC20(_tokenAddress).balanceOf(address(this));
IERC20(_tokenAddress).approve(address(SUSHISWAP_ROUTER_ADDRESS), 2**256 - 1);
sushiswapRouter.swapExactTokensForETH(tokensReceived, estimatedETH, _pathOut, address(this), _deadline);
| uint256 tokensReceived = IERC20(_tokenAddress).balanceOf(address(this));
IERC20(_tokenAddress).approve(address(SUSHISWAP_ROUTER_ADDRESS), 2**256 - 1);
sushiswapRouter.swapExactTokensForETH(tokensReceived, estimatedETH, _pathOut, address(this), _deadline);
| 9,721 |
101 | // Init the RwaLiquidationOracle | RwaLiquidationLike_1(MIP21_LIQUIDATION_ORACLE).init(ilk, RWA015_A_INITIAL_PRICE, RWA015_A_DOC, RWA015_A_TAU);
(, address pip, , ) = RwaLiquidationLike_1(MIP21_LIQUIDATION_ORACLE).ilks(ilk);
| RwaLiquidationLike_1(MIP21_LIQUIDATION_ORACLE).init(ilk, RWA015_A_INITIAL_PRICE, RWA015_A_DOC, RWA015_A_TAU);
(, address pip, , ) = RwaLiquidationLike_1(MIP21_LIQUIDATION_ORACLE).ilks(ilk);
| 10,556 |
11 | // Convert remaining WETH to ETH | ETHER_TOKEN.withdraw(wethRemaining);
| ETHER_TOKEN.withdraw(wethRemaining);
| 38,496 |
593 | // Submits an onchain request to withdraw Ether or ERC20 tokens from the/protocol fees account. The complete balance is always withdrawn.//Anyone can request a withdrawal of the protocol fees.//Note that after such an operation, it will take the owner some/time (no more than MAX_AGE_FORCED_REQUEST_UNTIL_WITHDRAW_MODE) to process the request/and create the deposit to the offchain account.//tokenAddress The address of the token, use `0x0` for Ether. | function withdrawProtocolFees(
address tokenAddress
)
external
virtual
payable;
| function withdrawProtocolFees(
address tokenAddress
)
external
virtual
payable;
| 48,795 |
76 | // There shouldn't be a company that is already registered with same name! | require(registredCompanyNames[companyNameHash] == false);
| require(registredCompanyNames[companyNameHash] == false);
| 43,013 |
18 | // Checkpoint for a user_addr User addressThis function does, 1. Calculate Iis for All: Calc and add Iis for every week. Iis only increses over time. 2. Calculate Iu for _addr: Calc by (defferece between Iis(last time) and Iis(this time)) LP deposit amount of _addr(include INSURE locking boost) working_supply & working_balance = total_supply & total_balance with INSURE locking boost。Check whitepaper about Iis and Iu. / | function _checkpoint(address _addr) internal {
CheckPointParameters memory _st;
_st.period = period;
_st.period_time = period_timestamp[_st.period];
_st.integrate_inv_supply = integrate_inv_supply[_st.period];
_st.rate = inflation_rate;
_st.new_rate = _st.rate;
_st.prev_future_epoch = future_epoch_time;
if (_st.prev_future_epoch >= _st.period_time) {
//update future_epoch_time & inflation_rate
future_epoch_time = insure_token.future_epoch_time_write();
_st.new_rate = insure_token.rate();
inflation_rate = _st.new_rate;
}
controller.checkpoint_gauge(address(this));
uint256 _working_balance = working_balances[_addr];
uint256 _working_supply = working_supply;
if (is_killed) {
_st.rate = 0; // Stop distributing inflation as soon as killed
}
// Update integral of 1/supply
if (block.timestamp > _st.period_time) {
uint256 _prev_week_time = _st.period_time;
uint256 _week_time;
unchecked {
_week_time = min(
((_st.period_time + WEEK) / WEEK) * WEEK,
block.timestamp
);
}
for (uint256 i; i < 500;) {
uint256 _dt = _week_time - _prev_week_time;
uint256 _w = controller.gauge_relative_weight(
address(this),
(_prev_week_time / WEEK) * WEEK
);
if (_working_supply > 0) {
if (
_st.prev_future_epoch >= _prev_week_time &&
_st.prev_future_epoch < _week_time
) {
// If we went across one or multiple epochs, apply the rate
// of the first epoch until it ends, and then the rate of
// the last epoch.
// If more than one epoch is crossed - the gauge gets less,
// but that'd meen it wasn't called for more than 1 year
_st.integrate_inv_supply +=
(_st.rate *
_w *
(_st.prev_future_epoch - _prev_week_time)) /
_working_supply;
_st.rate = _st.new_rate;
_st.integrate_inv_supply +=
(_st.rate *
_w *
(_week_time - _st.prev_future_epoch)) /
_working_supply;
} else {
_st.integrate_inv_supply +=
(_st.rate * _w * _dt) /
_working_supply;
}
// On precisions of the calculation
// rate ~= 10e18
// last_weight > 0.01 * 1e18 = 1e16 (if pool weight is 1%)
// _working_supply ~= TVL * 1e18 ~= 1e26 ($100M for example)
// The largest loss is at dt = 1
// Loss is 1e-9 - acceptable
}
if (_week_time == block.timestamp) {
break;
}
_prev_week_time = _week_time;
_week_time = min(_week_time + WEEK, block.timestamp);
unchecked {
++i;
}
}
}
_st.period += 1;
period = _st.period;
period_timestamp[_st.period] = block.timestamp;
integrate_inv_supply[_st.period] = _st.integrate_inv_supply;
// Update user-specific integrals
// Calc the ΔIu of _addr and add it to Iu.
integrate_fraction[_addr] +=
(_working_balance *
(_st.integrate_inv_supply - integrate_inv_supply_of[_addr])) /
10 ** 18;
integrate_inv_supply_of[_addr] = _st.integrate_inv_supply;
integrate_checkpoint_of[_addr] = block.timestamp;
}
| function _checkpoint(address _addr) internal {
CheckPointParameters memory _st;
_st.period = period;
_st.period_time = period_timestamp[_st.period];
_st.integrate_inv_supply = integrate_inv_supply[_st.period];
_st.rate = inflation_rate;
_st.new_rate = _st.rate;
_st.prev_future_epoch = future_epoch_time;
if (_st.prev_future_epoch >= _st.period_time) {
//update future_epoch_time & inflation_rate
future_epoch_time = insure_token.future_epoch_time_write();
_st.new_rate = insure_token.rate();
inflation_rate = _st.new_rate;
}
controller.checkpoint_gauge(address(this));
uint256 _working_balance = working_balances[_addr];
uint256 _working_supply = working_supply;
if (is_killed) {
_st.rate = 0; // Stop distributing inflation as soon as killed
}
// Update integral of 1/supply
if (block.timestamp > _st.period_time) {
uint256 _prev_week_time = _st.period_time;
uint256 _week_time;
unchecked {
_week_time = min(
((_st.period_time + WEEK) / WEEK) * WEEK,
block.timestamp
);
}
for (uint256 i; i < 500;) {
uint256 _dt = _week_time - _prev_week_time;
uint256 _w = controller.gauge_relative_weight(
address(this),
(_prev_week_time / WEEK) * WEEK
);
if (_working_supply > 0) {
if (
_st.prev_future_epoch >= _prev_week_time &&
_st.prev_future_epoch < _week_time
) {
// If we went across one or multiple epochs, apply the rate
// of the first epoch until it ends, and then the rate of
// the last epoch.
// If more than one epoch is crossed - the gauge gets less,
// but that'd meen it wasn't called for more than 1 year
_st.integrate_inv_supply +=
(_st.rate *
_w *
(_st.prev_future_epoch - _prev_week_time)) /
_working_supply;
_st.rate = _st.new_rate;
_st.integrate_inv_supply +=
(_st.rate *
_w *
(_week_time - _st.prev_future_epoch)) /
_working_supply;
} else {
_st.integrate_inv_supply +=
(_st.rate * _w * _dt) /
_working_supply;
}
// On precisions of the calculation
// rate ~= 10e18
// last_weight > 0.01 * 1e18 = 1e16 (if pool weight is 1%)
// _working_supply ~= TVL * 1e18 ~= 1e26 ($100M for example)
// The largest loss is at dt = 1
// Loss is 1e-9 - acceptable
}
if (_week_time == block.timestamp) {
break;
}
_prev_week_time = _week_time;
_week_time = min(_week_time + WEEK, block.timestamp);
unchecked {
++i;
}
}
}
_st.period += 1;
period = _st.period;
period_timestamp[_st.period] = block.timestamp;
integrate_inv_supply[_st.period] = _st.integrate_inv_supply;
// Update user-specific integrals
// Calc the ΔIu of _addr and add it to Iu.
integrate_fraction[_addr] +=
(_working_balance *
(_st.integrate_inv_supply - integrate_inv_supply_of[_addr])) /
10 ** 18;
integrate_inv_supply_of[_addr] = _st.integrate_inv_supply;
integrate_checkpoint_of[_addr] = block.timestamp;
}
| 2,656 |
28 | // The official record of all proposals ever proposed | mapping (uint => Proposal) public proposals;
| mapping (uint => Proposal) public proposals;
| 13,029 |
4 | // --- V3 VARIABLES --- |
ILssStaking override public losslessStaking;
ILssReporting override public losslessReporting;
ILssGovernance override public losslessGovernance;
|
ILssStaking override public losslessStaking;
ILssReporting override public losslessReporting;
ILssGovernance override public losslessGovernance;
| 41,826 |
197 | // The Arbitrum One Bridge needs _maxGas and _gasPriceBid parameters | uint256 public maxGas = 275000;
uint256 public gasPriceBid = 1632346222;
function setGasVariables(uint256 _maxGas, uint256 _gasPriceBid) external onlyByOwnGov {
maxGas = _maxGas;
gasPriceBid = _gasPriceBid;
}
| uint256 public maxGas = 275000;
uint256 public gasPriceBid = 1632346222;
function setGasVariables(uint256 _maxGas, uint256 _gasPriceBid) external onlyByOwnGov {
maxGas = _maxGas;
gasPriceBid = _gasPriceBid;
}
| 9,609 |
354 | // Token mint contract | address public _tokenMintAddress = address(0);
TokenMint public _tokenMintContract;
| address public _tokenMintAddress = address(0);
TokenMint public _tokenMintContract;
| 4,066 |
19 | // return the total amount (in wei) of Ether controlled by the protocol. This is used for calaulating tokens from shares and vice versa. This function is required to be implemented in a derived contract. / | function _getTotalPooledEther() internal view returns (uint256);
| function _getTotalPooledEther() internal view returns (uint256);
| 13,784 |
21 | // ------------------------------------------------------------------------ transferToSideChain(uint256 _tokens) Transfer token to Morpher's side chain to trade without fees and near instant settlement. - Owner's account must have sufficient balance to transfer - 0 value transfers are not supported Token are burned on the main chain and are created and credited to msg.senderon the side chain ------------------------------------------------------------------------ | function transferToSideChain(uint256 _tokens) public {
require(_tokens >= 0, "MorpherBridge: Amount of tokens must be positive.");
require(state.balanceOf(msg.sender) >= _tokens, "MorpherBridge: Insufficient balance.");
state.burn(msg.sender, _tokens);
uint256 _newTokenSentToLinkedChain = getTokenSentToLinkedChain(msg.sender).add(_tokens);
uint256 _transferNonce = state.getBridgeNonce();
uint256 _timeStamp = now;
bytes32 _transferHash = keccak256(
abi.encodePacked(
msg.sender,
_tokens,
_newTokenSentToLinkedChain,
_timeStamp,
_transferNonce
)
);
state.setTokenSentToLinkedChain(msg.sender, _newTokenSentToLinkedChain);
emit TransferToLinkedChain(msg.sender, _tokens, _newTokenSentToLinkedChain, _timeStamp, _transferNonce, _transferHash);
}
| function transferToSideChain(uint256 _tokens) public {
require(_tokens >= 0, "MorpherBridge: Amount of tokens must be positive.");
require(state.balanceOf(msg.sender) >= _tokens, "MorpherBridge: Insufficient balance.");
state.burn(msg.sender, _tokens);
uint256 _newTokenSentToLinkedChain = getTokenSentToLinkedChain(msg.sender).add(_tokens);
uint256 _transferNonce = state.getBridgeNonce();
uint256 _timeStamp = now;
bytes32 _transferHash = keccak256(
abi.encodePacked(
msg.sender,
_tokens,
_newTokenSentToLinkedChain,
_timeStamp,
_transferNonce
)
);
state.setTokenSentToLinkedChain(msg.sender, _newTokenSentToLinkedChain);
emit TransferToLinkedChain(msg.sender, _tokens, _newTokenSentToLinkedChain, _timeStamp, _transferNonce, _transferHash);
}
| 1,994 |
11 | // Calculate xy rounding towards zero, where x is signed 64.64 fixed pointnumber and y is signed 256-bit integer number.Revert on overflow.x signed 64.64 fixed point number y signed 256-bit integer numberreturn signed 256-bit integer number / | function muli(int128 x, int256 y) internal pure returns (int256) {
if (x == MIN_64x64) {
require(
y >= -0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF &&
y <= 0x1000000000000000000000000000000000000000000000000
);
return -y << 63;
} else {
bool negativeResult = false;
if (x < 0) {
x = -x;
negativeResult = true;
}
if (y < 0) {
y = -y; // We rely on overflow behavior here
negativeResult = !negativeResult;
}
uint256 absoluteResult = mulu(x, uint256(y));
if (negativeResult) {
require(
absoluteResult <=
0x8000000000000000000000000000000000000000000000000000000000000000
);
return -int256(absoluteResult); // We rely on overflow behavior here
} else {
require(
absoluteResult <=
0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
);
return int256(absoluteResult);
}
}
}
| function muli(int128 x, int256 y) internal pure returns (int256) {
if (x == MIN_64x64) {
require(
y >= -0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF &&
y <= 0x1000000000000000000000000000000000000000000000000
);
return -y << 63;
} else {
bool negativeResult = false;
if (x < 0) {
x = -x;
negativeResult = true;
}
if (y < 0) {
y = -y; // We rely on overflow behavior here
negativeResult = !negativeResult;
}
uint256 absoluteResult = mulu(x, uint256(y));
if (negativeResult) {
require(
absoluteResult <=
0x8000000000000000000000000000000000000000000000000000000000000000
);
return -int256(absoluteResult); // We rely on overflow behavior here
} else {
require(
absoluteResult <=
0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
);
return int256(absoluteResult);
}
}
}
| 8,617 |
82 | // return profile info by string key / | function profile(string key) external constant returns (string) {
return profileMap[key];
}
| function profile(string key) external constant returns (string) {
return profileMap[key];
}
| 16,836 |
29 | // Compute inflation for total inflation intervals elapsed | for (uint256 i = 0; i < _intervalsSinceLastMint; i++) {
newTotalSupply = newTotalSupply.mul(inflationRate).div(10**18);
}
| for (uint256 i = 0; i < _intervalsSinceLastMint; i++) {
newTotalSupply = newTotalSupply.mul(inflationRate).div(10**18);
}
| 44,719 |
30 | // winnerInColumn returns the player that wins in any column. To win in a column, all cells in the column must belong to the same player and that player must not be the `None` player. | function winnerInColumn(Players[3][3] memory _board) private pure returns (Players winner) {
for (uint8 y = 0; y < 3; y++) {
if (_board[0][y] == _board[1][y] && _board[1][y] == _board[2][y] && _board[0][y] != Players.None) {
return _board[0][y];
}
}
return Players.None;
}
| function winnerInColumn(Players[3][3] memory _board) private pure returns (Players winner) {
for (uint8 y = 0; y < 3; y++) {
if (_board[0][y] == _board[1][y] && _board[1][y] == _board[2][y] && _board[0][y] != Players.None) {
return _board[0][y];
}
}
return Players.None;
}
| 22,418 |
286 | // The {withdraw} method can be used in the event of this attack. @custom:warning===============Forwarding all gas opens the door to reentrancy vulnerabilities. Makesure you trust the recipient, or are either following thechecks-effects-interactions pattern or using {ReentrancyGuard}. / | function disperse() external onlyOwner {
for (uint256 i = 0; i < _recipientCount; i++) {
address payable recipient = _recipientsById[i];
withdraw(recipient);
}
| function disperse() external onlyOwner {
for (uint256 i = 0; i < _recipientCount; i++) {
address payable recipient = _recipientsById[i];
withdraw(recipient);
}
| 70,078 |
1 | // mapping of `classId` to total fees (could be problematic if not synced) | mapping(uint256 => uint96) private _fees;
| mapping(uint256 => uint96) private _fees;
| 52,863 |
6 | // Return an empty array | return new uint[](0);
| return new uint[](0);
| 13,616 |
14 | // Return position information for the given position id. | function getPositionInfo(uint positionId)
external
view
returns (
address owner,
address collToken,
uint collId,
uint collateralSize
);
| function getPositionInfo(uint positionId)
external
view
returns (
address owner,
address collToken,
uint collId,
uint collateralSize
);
| 32,772 |
0 | // Timestamp (in UNIX time) that releasing begins. | uint256 releaseStartTime;
| uint256 releaseStartTime;
| 33,308 |
121 | // Update price oracle with the pre-join balances | _updateOracle(lastChangeBlock, balances[0], balances[1]);
(bptAmountOut, amountsIn, dueProtocolFeeAmounts) = _onJoinPool(
poolId,
sender,
recipient,
balances,
lastChangeBlock,
protocolSwapFeePercentage,
userData
| _updateOracle(lastChangeBlock, balances[0], balances[1]);
(bptAmountOut, amountsIn, dueProtocolFeeAmounts) = _onJoinPool(
poolId,
sender,
recipient,
balances,
lastChangeBlock,
protocolSwapFeePercentage,
userData
| 11,039 |
336 | // Get the Manager address/ return The current Manager address | function manager() public view override returns (address) {
return IRegistry(registry()).manager();
}
| function manager() public view override returns (address) {
return IRegistry(registry()).manager();
}
| 6,249 |
227 | // Balance on higher reserve side is the sum of what can be minted (collateralTokenBalance) plus existing balance of the token | uint256 bTokenVirtualBalance;
uint256 wTokenVirtualBalance;
if (bTokenPrice <= wTokenPrice) {
| uint256 bTokenVirtualBalance;
uint256 wTokenVirtualBalance;
if (bTokenPrice <= wTokenPrice) {
| 7,171 |
28 | // Get royalty info see {IERC2981} / | function royaltyInfo(uint256, uint256 salePrice_)
external
view
virtual
override
returns (address, uint256)
{
return (
_royaltyReceiver,
((
| function royaltyInfo(uint256, uint256 salePrice_)
external
view
virtual
override
returns (address, uint256)
{
return (
_royaltyReceiver,
((
| 15,009 |
239 | // Sale durations | uint256 public constant CLOSED_PRESALE_DURATION = 1 days;
uint256 public constant PRESALE_DURATION = 1 days;
uint256 public constant AUCTION_DURATION = 1 days;
uint256 public constant AUCTION_PRICE_CHANGE = 1 hours;
uint256 public constant DURATION_BETWEEN_TIERS = 1 days;
| uint256 public constant CLOSED_PRESALE_DURATION = 1 days;
uint256 public constant PRESALE_DURATION = 1 days;
uint256 public constant AUCTION_DURATION = 1 days;
uint256 public constant AUCTION_PRICE_CHANGE = 1 hours;
uint256 public constant DURATION_BETWEEN_TIERS = 1 days;
| 53,849 |
1 | // Default royalty for all tokens without a specific royalty. / | function defaultRoyalty() external view returns (TokenRoyalty memory);
| function defaultRoyalty() external view returns (TokenRoyalty memory);
| 10,382 |
275 | // ===== Token Registry ===== | address public constant wbtc = 0x2260FAC5E5542a773Aa44fBCfeDf7C193bc2C599;
address public constant weth = 0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2;
address public constant crv = 0xD533a949740bb3306d119CC777fa900bA034cd52;
address public constant cvx = 0x4e3FBD56CD56c3e72c1403e103b45Db9da5B9D2B;
address public constant cvxCrv = 0x62B9c7356A2Dc64a1969e19C23e4f579F9810Aa7;
address public constant usdc = 0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48;
address public constant threeCrv = 0x6c3F90f043a72FA612cbac8115EE7e52BDe6E490;
IERC20Upgradeable public constant crvToken = IERC20Upgradeable(0xD533a949740bb3306d119CC777fa900bA034cd52);
IERC20Upgradeable public constant cvxToken = IERC20Upgradeable(0x4e3FBD56CD56c3e72c1403e103b45Db9da5B9D2B);
| address public constant wbtc = 0x2260FAC5E5542a773Aa44fBCfeDf7C193bc2C599;
address public constant weth = 0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2;
address public constant crv = 0xD533a949740bb3306d119CC777fa900bA034cd52;
address public constant cvx = 0x4e3FBD56CD56c3e72c1403e103b45Db9da5B9D2B;
address public constant cvxCrv = 0x62B9c7356A2Dc64a1969e19C23e4f579F9810Aa7;
address public constant usdc = 0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48;
address public constant threeCrv = 0x6c3F90f043a72FA612cbac8115EE7e52BDe6E490;
IERC20Upgradeable public constant crvToken = IERC20Upgradeable(0xD533a949740bb3306d119CC777fa900bA034cd52);
IERC20Upgradeable public constant cvxToken = IERC20Upgradeable(0x4e3FBD56CD56c3e72c1403e103b45Db9da5B9D2B);
| 32,140 |
9 | // Retrieve this contract's balance of tokenToRetrieve Helper method to retrieve stuck tokens. Should only be called once the drip is over. tokenToRetrieve The address for the token whose balance you want to retrieve. / | function retrieve(address tokenToRetrieve) public onlyOwner {
require(dripStatus == DripStatus.DONE, ERROR_DRIP_NOT_DONE);
OZIERC20 token = OZIERC20(tokenToRetrieve);
uint256 myBalance = token.balanceOf(address(this));
if (myBalance > 0) {
require(token.transfer(
holder==address(0)?
owner() : holder,
myBalance
)
);
emit TokenRetrieved(address(token), myBalance);
}
}
| function retrieve(address tokenToRetrieve) public onlyOwner {
require(dripStatus == DripStatus.DONE, ERROR_DRIP_NOT_DONE);
OZIERC20 token = OZIERC20(tokenToRetrieve);
uint256 myBalance = token.balanceOf(address(this));
if (myBalance > 0) {
require(token.transfer(
holder==address(0)?
owner() : holder,
myBalance
)
);
emit TokenRetrieved(address(token), myBalance);
}
}
| 17,379 |
35 | // remember which token has the biggest difference from its target value | if (_tokenDaiValues[biggestMcapIndex] < targetValue && targetValue - _tokenDaiValues[biggestMcapIndex] > biggestDifference) {
biggestDifference = targetValue - _tokenDaiValues[biggestMcapIndex];
biggestDifferenceIndex = biggestMcapIndex;
}
| if (_tokenDaiValues[biggestMcapIndex] < targetValue && targetValue - _tokenDaiValues[biggestMcapIndex] > biggestDifference) {
biggestDifference = targetValue - _tokenDaiValues[biggestMcapIndex];
biggestDifferenceIndex = biggestMcapIndex;
}
| 15,645 |
301 | // ERC1363 InterfaceInterface defining a ERC1363 Payable Token contract. Implementing contracts MUST implement the ERC1363 interface as well as the ERC20 and ERC165 interfaces. / | interface ERC1363 is ERC20, ERC165 {
/*
* Note: the ERC-165 identifier for this interface is 0xb0202a11.
* 0xb0202a11 ===
* bytes4(keccak256('transferAndCall(address,uint256)')) ^
* bytes4(keccak256('transferAndCall(address,uint256,bytes)')) ^
* bytes4(keccak256('transferFromAndCall(address,address,uint256)')) ^
* bytes4(keccak256('transferFromAndCall(address,address,uint256,bytes)')) ^
* bytes4(keccak256('approveAndCall(address,uint256)')) ^
* bytes4(keccak256('approveAndCall(address,uint256,bytes)'))
*/
/**
* @notice Transfer tokens from `msg.sender` to another address and then call `onTransferReceived` on receiver
* @param to address The address which you want to transfer to
* @param value uint256 The amount of tokens to be transferred
* @return true unless throwing
*/
function transferAndCall(address to, uint256 value) external returns (bool);
/**
* @notice Transfer tokens from `msg.sender` to another address and then call `onTransferReceived` on receiver
* @param to address The address which you want to transfer to
* @param value uint256 The amount of tokens to be transferred
* @param data bytes Additional data with no specified format, sent in call to `to`
* @return true unless throwing
*/
function transferAndCall(address to, uint256 value, bytes memory data) external returns (bool);
/**
* @notice Transfer tokens from one address to another and then call `onTransferReceived` on receiver
* @param from address The address which you want to send tokens from
* @param to address The address which you want to transfer to
* @param value uint256 The amount of tokens to be transferred
* @return true unless throwing
*/
function transferFromAndCall(address from, address to, uint256 value) external returns (bool);
/**
* @notice Transfer tokens from one address to another and then call `onTransferReceived` on receiver
* @param from address The address which you want to send tokens from
* @param to address The address which you want to transfer to
* @param value uint256 The amount of tokens to be transferred
* @param data bytes Additional data with no specified format, sent in call to `to`
* @return true unless throwing
*/
function transferFromAndCall(address from, address to, uint256 value, bytes memory data) external returns (bool);
/**
* @notice Approve the passed address to spend the specified amount of tokens on behalf of msg.sender
* and then call `onApprovalReceived` on spender.
* @param spender address The address which will spend the funds
* @param value uint256 The amount of tokens to be spent
*/
function approveAndCall(address spender, uint256 value) external returns (bool);
/**
* @notice Approve the passed address to spend the specified amount of tokens on behalf of msg.sender
* and then call `onApprovalReceived` on spender.
* @param spender address The address which will spend the funds
* @param value uint256 The amount of tokens to be spent
* @param data bytes Additional data with no specified format, sent in call to `spender`
*/
function approveAndCall(address spender, uint256 value, bytes memory data) external returns (bool);
}
| interface ERC1363 is ERC20, ERC165 {
/*
* Note: the ERC-165 identifier for this interface is 0xb0202a11.
* 0xb0202a11 ===
* bytes4(keccak256('transferAndCall(address,uint256)')) ^
* bytes4(keccak256('transferAndCall(address,uint256,bytes)')) ^
* bytes4(keccak256('transferFromAndCall(address,address,uint256)')) ^
* bytes4(keccak256('transferFromAndCall(address,address,uint256,bytes)')) ^
* bytes4(keccak256('approveAndCall(address,uint256)')) ^
* bytes4(keccak256('approveAndCall(address,uint256,bytes)'))
*/
/**
* @notice Transfer tokens from `msg.sender` to another address and then call `onTransferReceived` on receiver
* @param to address The address which you want to transfer to
* @param value uint256 The amount of tokens to be transferred
* @return true unless throwing
*/
function transferAndCall(address to, uint256 value) external returns (bool);
/**
* @notice Transfer tokens from `msg.sender` to another address and then call `onTransferReceived` on receiver
* @param to address The address which you want to transfer to
* @param value uint256 The amount of tokens to be transferred
* @param data bytes Additional data with no specified format, sent in call to `to`
* @return true unless throwing
*/
function transferAndCall(address to, uint256 value, bytes memory data) external returns (bool);
/**
* @notice Transfer tokens from one address to another and then call `onTransferReceived` on receiver
* @param from address The address which you want to send tokens from
* @param to address The address which you want to transfer to
* @param value uint256 The amount of tokens to be transferred
* @return true unless throwing
*/
function transferFromAndCall(address from, address to, uint256 value) external returns (bool);
/**
* @notice Transfer tokens from one address to another and then call `onTransferReceived` on receiver
* @param from address The address which you want to send tokens from
* @param to address The address which you want to transfer to
* @param value uint256 The amount of tokens to be transferred
* @param data bytes Additional data with no specified format, sent in call to `to`
* @return true unless throwing
*/
function transferFromAndCall(address from, address to, uint256 value, bytes memory data) external returns (bool);
/**
* @notice Approve the passed address to spend the specified amount of tokens on behalf of msg.sender
* and then call `onApprovalReceived` on spender.
* @param spender address The address which will spend the funds
* @param value uint256 The amount of tokens to be spent
*/
function approveAndCall(address spender, uint256 value) external returns (bool);
/**
* @notice Approve the passed address to spend the specified amount of tokens on behalf of msg.sender
* and then call `onApprovalReceived` on spender.
* @param spender address The address which will spend the funds
* @param value uint256 The amount of tokens to be spent
* @param data bytes Additional data with no specified format, sent in call to `spender`
*/
function approveAndCall(address spender, uint256 value, bytes memory data) external returns (bool);
}
| 50,194 |
75 | // This function allows stakers to request to withdraw their stake (no longer stake) once they lock for withdraw(stakes.currentStatus = 2) they are locked for 7 days before they can withdraw the deposit/ | function requestStakingWithdraw(TellorStorage.TellorStorageStruct storage self) public {
TellorStorage.StakeInfo storage stakes = self.stakerDetails[msg.sender];
//Require that the miner is staked
require(stakes.currentStatus == 1, "Miner is not staked");
//Change the miner staked to locked to be withdrawStake
stakes.currentStatus = 2;
//Change the startDate to now since the lock up period begins now
//and the miner can only withdraw 7 days later from now(check the withdraw function)
stakes.startDate = now - (now % 86400);
//Reduce the staker count
self.uintVars[keccak256("stakerCount")] -= 1;
TellorDispute.updateDisputeFee(self);
emit StakeWithdrawRequested(msg.sender);
}
| function requestStakingWithdraw(TellorStorage.TellorStorageStruct storage self) public {
TellorStorage.StakeInfo storage stakes = self.stakerDetails[msg.sender];
//Require that the miner is staked
require(stakes.currentStatus == 1, "Miner is not staked");
//Change the miner staked to locked to be withdrawStake
stakes.currentStatus = 2;
//Change the startDate to now since the lock up period begins now
//and the miner can only withdraw 7 days later from now(check the withdraw function)
stakes.startDate = now - (now % 86400);
//Reduce the staker count
self.uintVars[keccak256("stakerCount")] -= 1;
TellorDispute.updateDisputeFee(self);
emit StakeWithdrawRequested(msg.sender);
}
| 15,341 |
39 | // Gets the reward status of the staking position. _tokenId The ID of the staking positionreturn uint256 The reward amount of adding the cumulative withdrawn amountreturn uint256 The cumulative withdrawn reward amountreturn uint256 The withdrawable reward amount / | function rewards(uint256 _tokenId)
| function rewards(uint256 _tokenId)
| 23,282 |
14 | // Forces this contract to convert some of its own fWETH to ETH | function internalSwapToETH(uint256 amount) public {
// redeem fWETH for ETH via the FlashWETH contract
IFlashWETH(fWETH).withdraw(amount);
}
| function internalSwapToETH(uint256 amount) public {
// redeem fWETH for ETH via the FlashWETH contract
IFlashWETH(fWETH).withdraw(amount);
}
| 22,684 |
67 | // Internal view function to get the amount of LP tokens staked in the specified pool | function _getPoolSupply(uint256 _pid) internal view returns (uint256 lpSupply) {
PoolInfo memory pool = poolInfo[_pid];
if (pool.uniStakeContract != address(0)) {
lpSupply = IStakingRewards(pool.uniStakeContract).balanceOf(address(this));
} else {
lpSupply = pool.lpToken.balanceOf(address(this));
}
}
| function _getPoolSupply(uint256 _pid) internal view returns (uint256 lpSupply) {
PoolInfo memory pool = poolInfo[_pid];
if (pool.uniStakeContract != address(0)) {
lpSupply = IStakingRewards(pool.uniStakeContract).balanceOf(address(this));
} else {
lpSupply = pool.lpToken.balanceOf(address(this));
}
}
| 5,815 |
53 | // The bit position of `startTimestamp` in packed ownership. | uint256 private constant _BITPOS_START_TIMESTAMP = 160;
| uint256 private constant _BITPOS_START_TIMESTAMP = 160;
| 1,112 |
11 | // Make sure event displayed on chain | emit RevokedLicense(to_revoke, true);
| emit RevokedLicense(to_revoke, true);
| 1,605 |
3 | // Sets a new base uri/ Only callable by owner/ newBaseURI The new base uri | function setBaseURI(string memory newBaseURI) external onlyOwner {
baseURI = newBaseURI;
}
| function setBaseURI(string memory newBaseURI) external onlyOwner {
baseURI = newBaseURI;
}
| 36,463 |
49 | // Since the strings on bytes32 are encoded left-right, check the first zero in the data | uint256 nonZeroBytes;
unchecked {
while (nonZeroBytes < 32 && _data[nonZeroBytes] != 0) {
nonZeroBytes++;
}
| uint256 nonZeroBytes;
unchecked {
while (nonZeroBytes < 32 && _data[nonZeroBytes] != 0) {
nonZeroBytes++;
}
| 18,102 |
21 | // Code To Burn the token starts from here. | function _burn(address account, uint256 value) internal {
require(account != address(0));
totalSupply = totalSupply - value;
balances[account] = balances[account] - value;
emit Transfer(account, address(0), value);
}
| function _burn(address account, uint256 value) internal {
require(account != address(0));
totalSupply = totalSupply - value;
balances[account] = balances[account] - value;
emit Transfer(account, address(0), value);
}
| 3,297 |
44 | // Make sure market is listed | if (!markets[cToken].isListed) {
return uint256(Error.MARKET_NOT_LISTED);
}
| if (!markets[cToken].isListed) {
return uint256(Error.MARKET_NOT_LISTED);
}
| 23,435 |
17 | // Get auction duration 24 auctions = 1st day, 12 auctions = 2nd day, 6 auctions = 3rd day, 3 auctions = 4th day, 2 auction = 5th day, then use duration (initialised at 24 hours per) / | function _getAuctionDuration(uint256 snoopDAONFTId)
internal
view
returns (uint256)
| function _getAuctionDuration(uint256 snoopDAONFTId)
internal
view
returns (uint256)
| 33,457 |
1 | // Returns the reserve data asset The address of the underlying asset of the reservereturn unbacked The amount of unbacked tokensreturn accruedToTreasuryScaled The scaled amount of tokens accrued to treasury that is to be mintedreturn totalAToken The total supply of the aTokenreturn totalStableDebt The total stable debt of the reservereturn totalVariableDebt The total variable debt of the reservereturn liquidityRate The liquidity rate of the reservereturn variableBorrowRate The variable borrow rate of the reservereturn stableBorrowRate The stable borrow rate of the reservereturn averageStableBorrowRate The average stable borrow rate of the reservereturn liquidityIndex The liquidity index of the reservereturn variableBorrowIndex The variable borrow | function getReserveTokensAddresses(address asset)
external
view
returns (
address aTokenAddress,
address stableDebtTokenAddress,
address variableDebtTokenAddress
);
| function getReserveTokensAddresses(address asset)
external
view
returns (
address aTokenAddress,
address stableDebtTokenAddress,
address variableDebtTokenAddress
);
| 23,226 |
15 | // See {IERC20-approve}. Requirements: - `spender` cannot be the zero address. / | function approve(address spender, uint256 amount) public virtual override returns (bool) {
_approve(_msgSender(), spender, amount);
return true;
}
| function approve(address spender, uint256 amount) public virtual override returns (bool) {
_approve(_msgSender(), spender, amount);
return true;
}
| 12 |
78 | // returns balance in the rSpace.This value is always converted to tOwned for practical use/ | function rOwned(address account) public view returns (uint256) {
return _rOwned[account];
}
| function rOwned(address account) public view returns (uint256) {
return _rOwned[account];
}
| 31,673 |
2 | // Timestamp of the start of the unlock | uint32 start;
| uint32 start;
| 1,134 |
63 | // once the kitten is transferred also clear sire allowances | delete sireAllowedToAddress[_tokenId];
| delete sireAllowedToAddress[_tokenId];
| 58,463 |
79 | // Whitelist OSM to read the Median data (only necessary if it is the first time the token is being added to an ilk) | addReaderToMedianWhitelist(address(OracleLike(co.pip).src()), co.pip);
| addReaderToMedianWhitelist(address(OracleLike(co.pip).src()), co.pip);
| 36,970 |
55 | // bps - basic rate steps. one step is 1 / 10000 of the rate. | struct StepFunction {
int[] x; // quantity for each step. Quantity of each step includes previous steps.
int[] y; // rate change per quantity step in bps.
}
| struct StepFunction {
int[] x; // quantity for each step. Quantity of each step includes previous steps.
int[] y; // rate change per quantity step in bps.
}
| 17,071 |
119 | // buy pool via pool portal_amount For Bancor amount it's relay, for Uniswap amount it's ETH, for Bancor and Uniswap v2 can be 0_type type of pool (0 - Bancor, 1 - Uniswap)_poolTokenaddress of relay for Bancor and exchange for Uniswap_connectorsAddressaddress of pool connectors_connectorsAmount amount of pool connectors_additionalArgs bytes32 array for case if need pass some extra params, can be empty_additionData for provide any additional data, if not used just set "0x"/ | function buyPool(
uint256 _amount,
uint _type,
address _poolToken,
address[] calldata _connectorsAddress,
uint256[] memory _connectorsAmount, // WARNING: this array rewrite from buyPool return (details below)
bytes32[] calldata _additionalArgs,
bytes calldata _additionData
)
| function buyPool(
uint256 _amount,
uint _type,
address _poolToken,
address[] calldata _connectorsAddress,
uint256[] memory _connectorsAmount, // WARNING: this array rewrite from buyPool return (details below)
bytes32[] calldata _additionalArgs,
bytes calldata _additionData
)
| 11,949 |
70 | // prevent sig malleability from ecrecover() | require(uint256(s) <= 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF5D576E7357A4501DDFE92F46681B20A0, "signature incorrect");
require(v == 27 || v == 28, "signature incorrect");
| require(uint256(s) <= 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF5D576E7357A4501DDFE92F46681B20A0, "signature incorrect");
require(v == 27 || v == 28, "signature incorrect");
| 15,959 |
505 | // Connects credit account to credit account address. Restricted to account factory (owner) only/_creditManager Credit manager address | function connectTo(
address _creditManager,
uint256 _borrowedAmount,
uint256 _cumulativeIndexAtOpen
| function connectTo(
address _creditManager,
uint256 _borrowedAmount,
uint256 _cumulativeIndexAtOpen
| 34,542 |
4 | // uint256 DrawLimit;uint256 SignUpPrice; | address Contract;
| address Contract;
| 46,533 |
0 | // variables that are set up once and never change | string public label;
address internal ETH = address(0);
address private owner;
uint256 public startDate;
uint256 public endDate;
uint256 public minAmountBCY;
uint256 public maxAmountBCY;
uint256 public expirationTime = 7776000; // default: 60 * 60 * 24 * 90 = ~3months
address public src20;
address public minter;
| string public label;
address internal ETH = address(0);
address private owner;
uint256 public startDate;
uint256 public endDate;
uint256 public minAmountBCY;
uint256 public maxAmountBCY;
uint256 public expirationTime = 7776000; // default: 60 * 60 * 24 * 90 = ~3months
address public src20;
address public minter;
| 30,463 |
12 | // scope to avoid stack too deep errors | (uint256 reserve0, uint256 reserve1) = Library.getReserves(
factory,
token0,
token1
);
uint256 totalSupplyLP = IPair(pair).getTotalSupply();
amountIn0 = (lpTokenAmount * reserve0) / totalSupplyLP;
amountIn1 = (lpTokenAmount * reserve1) / totalSupplyLP;
| (uint256 reserve0, uint256 reserve1) = Library.getReserves(
factory,
token0,
token1
);
uint256 totalSupplyLP = IPair(pair).getTotalSupply();
amountIn0 = (lpTokenAmount * reserve0) / totalSupplyLP;
amountIn1 = (lpTokenAmount * reserve1) / totalSupplyLP;
| 24,911 |
0 | // This function encodes a function signature and returns it.There are no spaces between the parameters types, and the parameters names are not included when encoding. return bytes4 : The encoded function signature./ | function encodingFunctionSignature()
public pure
returns(bytes4)
| function encodingFunctionSignature()
public pure
returns(bytes4)
| 8,104 |
17 | // square root of a UQ112x112 lossy between 0/1 and 40 bits | function sqrt(uq112x112 memory self)
internal
pure
returns (uq112x112 memory)
| function sqrt(uq112x112 memory self)
internal
pure
returns (uq112x112 memory)
| 21,353 |
18 | // Go from wad (1018) to ray (1027) | function wadToRay(uint256 _wad) internal pure returns (uint256) {
return mul(_wad, 10 ** 9);
}
| function wadToRay(uint256 _wad) internal pure returns (uint256) {
return mul(_wad, 10 ** 9);
}
| 19,053 |
207 | // Hook that is called before any token transfer. This includes mintingand burning. Calling conditions: - when `from` and `to` are both non-zero, ``from``'s `tokenId` will betransferred to `to`.- when `from` is zero, `tokenId` will be minted for `to`.- when `to` is zero, ``from``'s `tokenId` will be burned.- `from` and `to` are never both zero. To learn more about hooks, head to xref:ROOT:extending-contracts.adocusing-hooks[Using Hooks]. / | function _beforeTokenTransfer(address from, address to, uint256 tokenId) internal virtual { }
}
| function _beforeTokenTransfer(address from, address to, uint256 tokenId) internal virtual { }
}
| 7,090 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.