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
|
|---|---|---|---|---|
18
|
// contract owner initiates vote counting and set WorkflowStatus to Votes Tallied/no need for a for loop as winningProposalId was updated live during votin sessio
|
function countVotes()
public
onlyOwner
checkStatus(state, WorkflowStatus.VotingSessionEnded)
|
function countVotes()
public
onlyOwner
checkStatus(state, WorkflowStatus.VotingSessionEnded)
| 4,833
|
62
|
// MODIFIED: Only the steward is allowed to transfer
|
return (spender == steward);
|
return (spender == steward);
| 26,056
|
24
|
// mapping(uint256 => awardpartner) public awardpartners;
|
uint256 public totalDeposit;
uint256 public totalAward;
uint256 public minAward = 100 ether;
uint256 public maxAward = 1000 ether;
uint256 public seeResultFee = 1 ether;
uint256[] public seeResultFeePercent = [7000, 3000];
uint256 public totalAwardSystem;
uint256 public totalAwardRanking;
uint256 public totalAwardPartner;
uint[] public percenRanking = [200, 100, 50, 20, 20, 20, 20, 20, 20, 20];
|
uint256 public totalDeposit;
uint256 public totalAward;
uint256 public minAward = 100 ether;
uint256 public maxAward = 1000 ether;
uint256 public seeResultFee = 1 ether;
uint256[] public seeResultFeePercent = [7000, 3000];
uint256 public totalAwardSystem;
uint256 public totalAwardRanking;
uint256 public totalAwardPartner;
uint[] public percenRanking = [200, 100, 50, 20, 20, 20, 20, 20, 20, 20];
| 11,080
|
72
|
// Allows the user to get the first value for the requestId before the specified timestamp_requestId is the requestId to look up the value for_timestamp before which to search for first verified value return _ifRetrieve bool true if it is able to retreive a value, the value, and the value's timestamp return _value the value retrieved return _timestampRetrieved the value's timestamp/
|
function getDataBefore(uint256 _requestId, uint256 _timestamp)
public
returns (bool _ifRetrieve, uint256 _value, uint256 _timestampRetrieved)
|
function getDataBefore(uint256 _requestId, uint256 _timestamp)
public
returns (bool _ifRetrieve, uint256 _value, uint256 _timestampRetrieved)
| 22,892
|
23
|
// Create a uniswap pair for this new token uniswapV2Pair = IUniswapV2Pair(IUniswapV2Factory(_uniswapV2Router.factory()).getPair(_priceToken,_uniswapV2Router.WETH()));
|
uniswapV2Router = _uniswapV2Router;
Growth_Value.push(AttackDogLib.GrowthValue(5,3,3));
Growth_Value.push(AttackDogLib.GrowthValue(5,3,3));
Growth_Value.push(AttackDogLib.GrowthValue(3,6,2));
Growth_Value.push(AttackDogLib.GrowthValue(3,5,4));
Growth_Value.push(AttackDogLib.GrowthValue(3,4,4));
Growth_Value.push(AttackDogLib.GrowthValue(3,4,4));
Growth_Value.push(AttackDogLib.GrowthValue(3,4,4));
|
uniswapV2Router = _uniswapV2Router;
Growth_Value.push(AttackDogLib.GrowthValue(5,3,3));
Growth_Value.push(AttackDogLib.GrowthValue(5,3,3));
Growth_Value.push(AttackDogLib.GrowthValue(3,6,2));
Growth_Value.push(AttackDogLib.GrowthValue(3,5,4));
Growth_Value.push(AttackDogLib.GrowthValue(3,4,4));
Growth_Value.push(AttackDogLib.GrowthValue(3,4,4));
Growth_Value.push(AttackDogLib.GrowthValue(3,4,4));
| 13,663
|
12
|
// etherfund.me fee wallet
|
address public feeReceiverWallet;
|
address public feeReceiverWallet;
| 50,298
|
211
|
// ------------------------------------------------------------------------------------------------/ Interface for ECR_MGRINHERITANCE: /
|
interface ECR_MGR_Interface {
/*
* @dev Set an asset to escrow status (6/50/56). Sets timelock for unix timestamp of escrow end.
*/
function setEscrow(
bytes32 _idxHash,
uint8 _newAssetStatus,
bytes32 _escrowOwnerAddressHash,
uint256 _timelock
) external;
/*
* @dev remove an asset from escrow status
*/
function endEscrow(bytes32 _idxHash) external;
/*
* @dev Set data in EDL mapping
* Must be setter contract
* Must be in escrow
*/
function setEscrowDataLight(
bytes32 _idxHash,
escrowDataExtLight calldata _escrowDataLight
) external;
/*
* @dev Set data in EDL mapping
* Must be setter contract
* Must be in escrow
*/
function setEscrowDataHeavy(
bytes32 _idxHash,
escrowDataExtHeavy calldata escrowDataHeavy
) external;
/*
* @dev Permissive removal of asset from escrow status after time-out
*/
function permissiveEndEscrow(bytes32 _idxHash) external;
/*
* @dev return escrow OwnerHash
*/
function retrieveEscrowOwner(bytes32 _idxHash)
external
returns (bytes32 hashOfEscrowOwnerAdress);
/*
* @dev return escrow data @ IDX
*/
function retrieveEscrowData(bytes32 _idxHash)
external
returns (escrowData memory);
/*
* @dev return EscrowDataLight @ IDX
*/
function retrieveEscrowDataLight(bytes32 _idxHash)
external
view
returns (escrowDataExtLight memory);
/*
* @dev return EscrowDataHeavy @ IDX
*/
function retrieveEscrowDataHeavy(bytes32 _idxHash)
external
view
returns (escrowDataExtHeavy memory);
}
|
interface ECR_MGR_Interface {
/*
* @dev Set an asset to escrow status (6/50/56). Sets timelock for unix timestamp of escrow end.
*/
function setEscrow(
bytes32 _idxHash,
uint8 _newAssetStatus,
bytes32 _escrowOwnerAddressHash,
uint256 _timelock
) external;
/*
* @dev remove an asset from escrow status
*/
function endEscrow(bytes32 _idxHash) external;
/*
* @dev Set data in EDL mapping
* Must be setter contract
* Must be in escrow
*/
function setEscrowDataLight(
bytes32 _idxHash,
escrowDataExtLight calldata _escrowDataLight
) external;
/*
* @dev Set data in EDL mapping
* Must be setter contract
* Must be in escrow
*/
function setEscrowDataHeavy(
bytes32 _idxHash,
escrowDataExtHeavy calldata escrowDataHeavy
) external;
/*
* @dev Permissive removal of asset from escrow status after time-out
*/
function permissiveEndEscrow(bytes32 _idxHash) external;
/*
* @dev return escrow OwnerHash
*/
function retrieveEscrowOwner(bytes32 _idxHash)
external
returns (bytes32 hashOfEscrowOwnerAdress);
/*
* @dev return escrow data @ IDX
*/
function retrieveEscrowData(bytes32 _idxHash)
external
returns (escrowData memory);
/*
* @dev return EscrowDataLight @ IDX
*/
function retrieveEscrowDataLight(bytes32 _idxHash)
external
view
returns (escrowDataExtLight memory);
/*
* @dev return EscrowDataHeavy @ IDX
*/
function retrieveEscrowDataHeavy(bytes32 _idxHash)
external
view
returns (escrowDataExtHeavy memory);
}
| 62,767
|
18
|
// track the deposit on the ledger this could revert for a few reasons: - the key is not root - the vault is not a trusted collateral provider the ledger
|
(,,uint256 finalLedgerBalance) = ledger.deposit(keyId, tokenArn, amount);
|
(,,uint256 finalLedgerBalance) = ledger.deposit(keyId, tokenArn, amount);
| 15,406
|
46
|
// Attempt to send them to funds
|
uint256 funds = abandonedIcoBalances[msg.sender];
abandonedIcoBalances[msg.sender] = 0;
if (!msg.sender.send(funds))
throw;
|
uint256 funds = abandonedIcoBalances[msg.sender];
abandonedIcoBalances[msg.sender] = 0;
if (!msg.sender.send(funds))
throw;
| 11,551
|
15
|
// Set the token URI descriptor. Only callable by the owner when not locked. /
|
function setDescriptor(IGorfDescriptor _descriptor) external onlyOwner whenDescriptorNotLocked {
descriptor = _descriptor;
}
|
function setDescriptor(IGorfDescriptor _descriptor) external onlyOwner whenDescriptorNotLocked {
descriptor = _descriptor;
}
| 61,297
|
46
|
// Send seller the proceeds.
|
if (!msg.sender.send(safeSub(transactionWeiAmountNoFee, currentTakeFee))) {
revert();
}
|
if (!msg.sender.send(safeSub(transactionWeiAmountNoFee, currentTakeFee))) {
revert();
}
| 45,278
|
31
|
// Cumulative amount of Wei credited to an account, since the contract's deployment
|
mapping(address => uint256) public scaledDividendCreditedTo;
|
mapping(address => uint256) public scaledDividendCreditedTo;
| 78,019
|
255
|
// ----VIEWS
|
function networkOpened(uint chainId) external view returns (bool);
function accountOutboundings(
address account,
uint periodId,
uint index
) external view returns (uint);
function accountInboundings(address account, uint index) external view returns (uint);
|
function networkOpened(uint chainId) external view returns (bool);
function accountOutboundings(
address account,
uint periodId,
uint index
) external view returns (uint);
function accountInboundings(address account, uint index) external view returns (uint);
| 15,992
|
112
|
// Pay referral fee to the referrer, if any.
|
function payReferralFee(address _user, uint _pending) internal {
if (referralFeeBP > 0) {
address referrer = userReferrer[_user];
if (referrer != address(0) && referrer != 0x000000000000000000000000000000000000dEaD) {
uint referralFee = _pending.mul(referralFeeBP).div(10000);
safeHairTransfer(referrer, referralFee);
emit ReferralFeePaid(msg.sender, referrer, referralFee);
}
}
}
|
function payReferralFee(address _user, uint _pending) internal {
if (referralFeeBP > 0) {
address referrer = userReferrer[_user];
if (referrer != address(0) && referrer != 0x000000000000000000000000000000000000dEaD) {
uint referralFee = _pending.mul(referralFeeBP).div(10000);
safeHairTransfer(referrer, referralFee);
emit ReferralFeePaid(msg.sender, referrer, referralFee);
}
}
}
| 27,390
|
65
|
// Permissionless pool actions/Contains pool methods that can be called by anyone
|
interface IUniswapV3PoolActions {
/// @notice Sets the initial price for the pool
/// @dev Price is represented as a sqrt(amountToken1/amountToken0) Q64.96 value
/// @param sqrtPriceX96 the initial sqrt price of the pool as a Q64.96
function initialize(uint160 sqrtPriceX96) external;
/// @notice Adds liquidity for the given recipient/tickLower/tickUpper position
/// @dev The caller of this method receives a callback in the form of IUniswapV3MintCallback#uniswapV3MintCallback
/// in which they must pay any token0 or token1 owed for the liquidity. The amount of token0/token1 due depends
/// on tickLower, tickUpper, the amount of liquidity, and the current price.
/// @param recipient The address for which the liquidity will be created
/// @param tickLower The lower tick of the position in which to add liquidity
/// @param tickUpper The upper tick of the position in which to add liquidity
/// @param amount The amount of liquidity to mint
/// @param data Any data that should be passed through to the callback
/// @return amount0 The amount of token0 that was paid to mint the given amount of liquidity. Matches the value in the callback
/// @return amount1 The amount of token1 that was paid to mint the given amount of liquidity. Matches the value in the callback
function mint(
address recipient,
int24 tickLower,
int24 tickUpper,
uint128 amount,
bytes calldata data
) external returns (uint256 amount0, uint256 amount1);
/// @notice Collects tokens owed to a position
/// @dev Does not recompute fees earned, which must be done either via mint or burn of any amount of liquidity.
/// Collect must be called by the position owner. To withdraw only token0 or only token1, amount0Requested or
/// amount1Requested may be set to zero. To withdraw all tokens owed, caller may pass any value greater than the
/// actual tokens owed, e.g. type(uint128).max. Tokens owed may be from accumulated swap fees or burned liquidity.
/// @param recipient The address which should receive the fees collected
/// @param tickLower The lower tick of the position for which to collect fees
/// @param tickUpper The upper tick of the position for which to collect fees
/// @param amount0Requested How much token0 should be withdrawn from the fees owed
/// @param amount1Requested How much token1 should be withdrawn from the fees owed
/// @return amount0 The amount of fees collected in token0
/// @return amount1 The amount of fees collected in token1
function collect(
address recipient,
int24 tickLower,
int24 tickUpper,
uint128 amount0Requested,
uint128 amount1Requested
) external returns (uint128 amount0, uint128 amount1);
/// @notice Burn liquidity from the sender and account tokens owed for the liquidity to the position
/// @dev Can be used to trigger a recalculation of fees owed to a position by calling with an amount of 0
/// @dev Fees must be collected separately via a call to #collect
/// @param tickLower The lower tick of the position for which to burn liquidity
/// @param tickUpper The upper tick of the position for which to burn liquidity
/// @param amount How much liquidity to burn
/// @return amount0 The amount of token0 sent to the recipient
/// @return amount1 The amount of token1 sent to the recipient
function burn(
int24 tickLower,
int24 tickUpper,
uint128 amount
) external returns (uint256 amount0, uint256 amount1);
/// @notice Swap token0 for token1, or token1 for token0
/// @dev The caller of this method receives a callback in the form of IUniswapV3SwapCallback#uniswapV3SwapCallback
/// @param recipient The address to receive the output of the swap
/// @param zeroForOne The direction of the swap, true for token0 to token1, false for token1 to token0
/// @param amountSpecified The amount of the swap, which implicitly configures the swap as exact input (positive), or exact output (negative)
/// @param sqrtPriceLimitX96 The Q64.96 sqrt price limit. If zero for one, the price cannot be less than this
/// value after the swap. If one for zero, the price cannot be greater than this value after the swap
/// @param data Any data to be passed through to the callback
/// @return amount0 The delta of the balance of token0 of the pool, exact when negative, minimum when positive
/// @return amount1 The delta of the balance of token1 of the pool, exact when negative, minimum when positive
function swap(
address recipient,
bool zeroForOne,
int256 amountSpecified,
uint160 sqrtPriceLimitX96,
bytes calldata data
) external returns (int256 amount0, int256 amount1);
/// @notice Receive token0 and/or token1 and pay it back, plus a fee, in the callback
/// @dev The caller of this method receives a callback in the form of IUniswapV3FlashCallback#uniswapV3FlashCallback
/// @dev Can be used to donate underlying tokens pro-rata to currently in-range liquidity providers by calling
/// with 0 amount{0,1} and sending the donation amount(s) from the callback
/// @param recipient The address which will receive the token0 and token1 amounts
/// @param amount0 The amount of token0 to send
/// @param amount1 The amount of token1 to send
/// @param data Any data to be passed through to the callback
function flash(
address recipient,
uint256 amount0,
uint256 amount1,
bytes calldata data
) external;
/// @notice Increase the maximum number of price and liquidity observations that this pool will store
/// @dev This method is no-op if the pool already has an observationCardinalityNext greater than or equal to
/// the input observationCardinalityNext.
/// @param observationCardinalityNext The desired minimum number of observations for the pool to store
function increaseObservationCardinalityNext(uint16 observationCardinalityNext) external;
}
|
interface IUniswapV3PoolActions {
/// @notice Sets the initial price for the pool
/// @dev Price is represented as a sqrt(amountToken1/amountToken0) Q64.96 value
/// @param sqrtPriceX96 the initial sqrt price of the pool as a Q64.96
function initialize(uint160 sqrtPriceX96) external;
/// @notice Adds liquidity for the given recipient/tickLower/tickUpper position
/// @dev The caller of this method receives a callback in the form of IUniswapV3MintCallback#uniswapV3MintCallback
/// in which they must pay any token0 or token1 owed for the liquidity. The amount of token0/token1 due depends
/// on tickLower, tickUpper, the amount of liquidity, and the current price.
/// @param recipient The address for which the liquidity will be created
/// @param tickLower The lower tick of the position in which to add liquidity
/// @param tickUpper The upper tick of the position in which to add liquidity
/// @param amount The amount of liquidity to mint
/// @param data Any data that should be passed through to the callback
/// @return amount0 The amount of token0 that was paid to mint the given amount of liquidity. Matches the value in the callback
/// @return amount1 The amount of token1 that was paid to mint the given amount of liquidity. Matches the value in the callback
function mint(
address recipient,
int24 tickLower,
int24 tickUpper,
uint128 amount,
bytes calldata data
) external returns (uint256 amount0, uint256 amount1);
/// @notice Collects tokens owed to a position
/// @dev Does not recompute fees earned, which must be done either via mint or burn of any amount of liquidity.
/// Collect must be called by the position owner. To withdraw only token0 or only token1, amount0Requested or
/// amount1Requested may be set to zero. To withdraw all tokens owed, caller may pass any value greater than the
/// actual tokens owed, e.g. type(uint128).max. Tokens owed may be from accumulated swap fees or burned liquidity.
/// @param recipient The address which should receive the fees collected
/// @param tickLower The lower tick of the position for which to collect fees
/// @param tickUpper The upper tick of the position for which to collect fees
/// @param amount0Requested How much token0 should be withdrawn from the fees owed
/// @param amount1Requested How much token1 should be withdrawn from the fees owed
/// @return amount0 The amount of fees collected in token0
/// @return amount1 The amount of fees collected in token1
function collect(
address recipient,
int24 tickLower,
int24 tickUpper,
uint128 amount0Requested,
uint128 amount1Requested
) external returns (uint128 amount0, uint128 amount1);
/// @notice Burn liquidity from the sender and account tokens owed for the liquidity to the position
/// @dev Can be used to trigger a recalculation of fees owed to a position by calling with an amount of 0
/// @dev Fees must be collected separately via a call to #collect
/// @param tickLower The lower tick of the position for which to burn liquidity
/// @param tickUpper The upper tick of the position for which to burn liquidity
/// @param amount How much liquidity to burn
/// @return amount0 The amount of token0 sent to the recipient
/// @return amount1 The amount of token1 sent to the recipient
function burn(
int24 tickLower,
int24 tickUpper,
uint128 amount
) external returns (uint256 amount0, uint256 amount1);
/// @notice Swap token0 for token1, or token1 for token0
/// @dev The caller of this method receives a callback in the form of IUniswapV3SwapCallback#uniswapV3SwapCallback
/// @param recipient The address to receive the output of the swap
/// @param zeroForOne The direction of the swap, true for token0 to token1, false for token1 to token0
/// @param amountSpecified The amount of the swap, which implicitly configures the swap as exact input (positive), or exact output (negative)
/// @param sqrtPriceLimitX96 The Q64.96 sqrt price limit. If zero for one, the price cannot be less than this
/// value after the swap. If one for zero, the price cannot be greater than this value after the swap
/// @param data Any data to be passed through to the callback
/// @return amount0 The delta of the balance of token0 of the pool, exact when negative, minimum when positive
/// @return amount1 The delta of the balance of token1 of the pool, exact when negative, minimum when positive
function swap(
address recipient,
bool zeroForOne,
int256 amountSpecified,
uint160 sqrtPriceLimitX96,
bytes calldata data
) external returns (int256 amount0, int256 amount1);
/// @notice Receive token0 and/or token1 and pay it back, plus a fee, in the callback
/// @dev The caller of this method receives a callback in the form of IUniswapV3FlashCallback#uniswapV3FlashCallback
/// @dev Can be used to donate underlying tokens pro-rata to currently in-range liquidity providers by calling
/// with 0 amount{0,1} and sending the donation amount(s) from the callback
/// @param recipient The address which will receive the token0 and token1 amounts
/// @param amount0 The amount of token0 to send
/// @param amount1 The amount of token1 to send
/// @param data Any data to be passed through to the callback
function flash(
address recipient,
uint256 amount0,
uint256 amount1,
bytes calldata data
) external;
/// @notice Increase the maximum number of price and liquidity observations that this pool will store
/// @dev This method is no-op if the pool already has an observationCardinalityNext greater than or equal to
/// the input observationCardinalityNext.
/// @param observationCardinalityNext The desired minimum number of observations for the pool to store
function increaseObservationCardinalityNext(uint16 observationCardinalityNext) external;
}
| 3,612
|
24
|
// Current fallback withdrawal root /
|
bytes32 public fallbackRoot;
|
bytes32 public fallbackRoot;
| 41,815
|
346
|
// we want to revert if we can't liquidateall
|
if(!forceMigrate) {
require(position < minWant);
}
|
if(!forceMigrate) {
require(position < minWant);
}
| 5,136
|
15
|
// Allows the Lock owner to extend an existing keys with no charge. _tokenId The id of the token to extend _duration The duration in secondes to add ot the key set `_duration` to 0 to use the default duration of the lock /
|
function grantKeyExtension(uint _tokenId, uint _duration) external;
|
function grantKeyExtension(uint _tokenId, uint _duration) external;
| 11,189
|
104
|
// Pay the caller for relaying the rate
|
rewardCaller(feeReceiver, callerReward);
|
rewardCaller(feeReceiver, callerReward);
| 31,576
|
219
|
// Transfer a child token from an ERC721 contract to a composable. Used for old tokens that does nothave a safeTransferFrom method like cryptokitties This contract has to be approved first in _childContract _from The address that owns the child token. _tokenId The token that becomes the parent owner _childContract The ERC721 contract of the child token _childTokenId The tokenId of the child token /
|
function _getChild(
address _from,
uint256 _tokenId,
address _childContract,
uint256 _childTokenId
|
function _getChild(
address _from,
uint256 _tokenId,
address _childContract,
uint256 _childTokenId
| 60,586
|
109
|
// Current number of votes for abstaining for this proposal
|
uint abstainVotes;
|
uint abstainVotes;
| 7,399
|
32
|
// Adds new token to list of valid tokenstoken address of token contract to add to listtokenNum uint128 index of a token to add/
|
function addToken(address token, uint128 tokenNum) external onlyOwner {
numsTokens.set(tokenNum, token);
}
|
function addToken(address token, uint128 tokenNum) external onlyOwner {
numsTokens.set(tokenNum, token);
}
| 46,059
|
19
|
// Init first node. ownerAddress Address of person who is top referrer. /
|
function init(address ownerAddress) onlyOwner public{
require(lastUserId == 0, "Contract has already been initialized");
users[ownerAddress] = User(
++lastUserId,
address(0),
new address[](0)
);
addressById[lastUserId] = ownerAddress;
NewUser(ownerAddress, address(0), lastUserId);
}
|
function init(address ownerAddress) onlyOwner public{
require(lastUserId == 0, "Contract has already been initialized");
users[ownerAddress] = User(
++lastUserId,
address(0),
new address[](0)
);
addressById[lastUserId] = ownerAddress;
NewUser(ownerAddress, address(0), lastUserId);
}
| 17,702
|
147
|
// No conversion is needed as the pool token has 18 decimals
|
IERC20(poolToken).safeTransferFrom(msg.sender, feeRecipient, feeAmount);
|
IERC20(poolToken).safeTransferFrom(msg.sender, feeRecipient, feeAmount);
| 53,116
|
221
|
// timestamp setter/_preSaleStartTs timestamp that designates the start of presale phase/_preSaleEndTs timestamp that designates the end of presale phase/_publicSaleStartTs timestamp that designates the start of public sale phase/_publicSaleEndTs timestamp that designates the end of public sale phase
|
function setDates(
uint256 _preSaleStartTs,
uint256 _preSaleEndTs,
uint256 _publicSaleStartTs,
uint256 _publicSaleEndTs
|
function setDates(
uint256 _preSaleStartTs,
uint256 _preSaleEndTs,
uint256 _publicSaleStartTs,
uint256 _publicSaleEndTs
| 18,961
|
80
|
// Contract implements Chainlink's Upkeep system interface, automating the upkeep of a registry of Pod contracts
|
contract PodsUpkeep is KeeperCompatibleInterface, Ownable {
using SafeMathUpgradeable for uint256;
/// @notice Address of the registry of pods contract which require upkeep
AddressRegistry public podsRegistry;
/// @dev Fixed length of the last upkeep block number (multiple this by 8 to get the maximum number of pods for storage)
uint8 constant PODS_PACKED_ARRAY_SIZE = 10;
uint256[PODS_PACKED_ARRAY_SIZE] internal lastUpkeepBlockNumber;
/// @notice Global upkeep interval expressed in blocks at which pods.batch() will be called
uint256 public upkeepBlockInterval;
/// @notice Emitted when the upkeep block interval is updated
event UpkeepBlockIntervalUpdated(uint upkeepBlockInterval);
/// @notice Emitted when the upkeep max batch is updated
event UpkeepBatchLimitUpdated(uint upkeepBatchLimit);
/// @notice Emitted when the address registry is updated
event PodsRegistryUpdated(AddressRegistry addressRegistry);
/// @notice Emitted when the drop() call reverts
/// @param error is the revert message
event ErrorCallingDrop(string error);
/// @notice Maximum number of pods that performUpkeep can be called on
uint256 public upkeepBatchLimit;
/// @notice Contract Constructor. No initializer.
constructor(AddressRegistry _podsRegistry, address _owner, uint256 _upkeepBlockInterval, uint256 _upkeepBatchLimit) Ownable() {
podsRegistry = _podsRegistry;
emit PodsRegistryUpdated(_podsRegistry);
transferOwnership(_owner);
upkeepBlockInterval = _upkeepBlockInterval;
emit UpkeepBlockIntervalUpdated(_upkeepBlockInterval);
upkeepBatchLimit = _upkeepBatchLimit;
emit UpkeepBatchLimitUpdated(_upkeepBatchLimit);
}
/// @notice Updates a 256 bit word with a 32 bit representation of a block number at a particular index
/// @param _existingUpkeepBlockNumbers The 256 word
/// @param _podIndex The index within that word (0 to 7)
/// @param _value The block number value to be inserted
function _updateLastBlockNumberForPodIndex(uint256 _existingUpkeepBlockNumbers, uint8 _podIndex, uint32 _value) internal pure returns (uint256) {
uint256 mask = (type(uint32).max | uint256(0)) << (_podIndex * 32); // get a mask of all 1's at the pod index
uint256 updateBits = (uint256(0) | _value) << (_podIndex * 32); // position value at index with 0's in every other position
/*
(updateBits | ~mask)
negation of the mask is 0's at the location of the block number, 1's everywhere else
OR'ing it with updateBits will give 1's everywhere else, block number intact
(_existingUpkeepBlockNumbers | mask)
OR'ing the exstingUpkeepBlockNumbers with mask will give maintain other blocknumber, put all 1's at podIndex
finally AND'ing the two halves will filter through 1's if they are supposed to be there
*/
return (updateBits | ~mask) & (_existingUpkeepBlockNumbers | mask);
}
/// @notice Takes a 256 bit word and 0 to 7 index within and returns the uint32 value at that index
/// @param _existingUpkeepBlockNumbers The 256 word
/// @param _podIndex The index within that word
function _readLastBlockNumberForPodIndex(uint256 _existingUpkeepBlockNumbers, uint8 _podIndex) internal pure returns (uint32) {
uint256 mask = (type(uint32).max | uint256(0)) << (_podIndex * 32);
return uint32((_existingUpkeepBlockNumbers & mask) >> (_podIndex * 32));
}
/// @notice Get the last Upkeep block number for a pod
/// @param podIndex The position of the pod in the Registry
function readLastBlockNumberForPodIndex(uint256 podIndex) public view returns (uint32) {
uint256 wordIndex = podIndex / 8;
return _readLastBlockNumberForPodIndex(lastUpkeepBlockNumber[wordIndex], uint8(podIndex % 8));
}
/// @notice Checks if Pods require upkeep. Call in a static manner every block by the Chainlink Upkeep network.
/// @param checkData Not used in this implementation.
/// @return upkeepNeeded as true if performUpkeep() needs to be called, false otherwise. performData returned empty.
function checkUpkeep(bytes calldata checkData) override external view returns (bool upkeepNeeded, bytes memory performData) {
address[] memory pods = podsRegistry.getAddresses();
uint256 _upkeepBlockInterval = upkeepBlockInterval;
uint256 podsLength = pods.length;
for(uint256 podWord = 0; podWord <= podsLength / 8; podWord++){
uint256 _lastUpkeep = lastUpkeepBlockNumber[podWord]; // this performs the SLOAD
for(uint256 i = 0; i + (podWord * 8) < podsLength; i++){
uint32 podLastUpkeepBlockNumber = _readLastBlockNumberForPodIndex(_lastUpkeep, uint8(i));
if(block.number > podLastUpkeepBlockNumber + _upkeepBlockInterval){
return (true, "");
}
}
}
return (false, "");
}
/// @notice Performs upkeep on the pods contract and updates lastUpkeepBlockNumbers
/// @param performData Not used in this implementation.
function performUpkeep(bytes calldata performData) override external {
address[] memory pods = podsRegistry.getAddresses();
uint256 podsLength = pods.length;
uint256 _batchLimit = upkeepBatchLimit;
uint256 batchesPerformed = 0;
for(uint8 podWord = 0; podWord <= podsLength / 8; podWord++){ // give word index
uint256 _updateBlockNumber = lastUpkeepBlockNumber[podWord]; // this performs the SLOAD
for(uint8 i = 0; i + (podWord * 8) < podsLength; i++){ // pod index within word
if(batchesPerformed >= _batchLimit) {
break;
}
// get the 32 bit block number from the 256 bit word
uint32 podLastUpkeepBlockNumber = _readLastBlockNumberForPodIndex(_updateBlockNumber, i);
if(block.number > podLastUpkeepBlockNumber + upkeepBlockInterval) {
try IPod(pods[i + (podWord * 8)]).drop() {
batchesPerformed++;
// updated pod's most recent upkeep block number and store update to that 256 bit word
_updateBlockNumber = _updateLastBlockNumberForPodIndex(_updateBlockNumber, i, uint32(block.number));
}
catch(bytes memory error){
emit ErrorCallingDrop(string(error));
}
}
}
lastUpkeepBlockNumber[podWord] = _updateBlockNumber; // update the entire 256 bit word at once
}
}
/// @notice Updates the upkeepBlockInterval. Can only be called by the contract owner
/// @param _upkeepBlockInterval The new upkeepBlockInterval (in blocks)
function updateBlockUpkeepInterval(uint256 _upkeepBlockInterval) external onlyOwner {
upkeepBlockInterval = _upkeepBlockInterval;
emit UpkeepBlockIntervalUpdated(_upkeepBlockInterval);
}
/// @notice Updates the upkeep max batch. Can only be called by the contract owner
/// @param _upkeepBatchLimit The new _upkeepBatchLimit
function updateUpkeepBatchLimit(uint256 _upkeepBatchLimit) external onlyOwner {
upkeepBatchLimit = _upkeepBatchLimit;
emit UpkeepBatchLimitUpdated(_upkeepBatchLimit);
}
/// @notice Updates the address registry. Can only be called by the contract owner
/// @param _addressRegistry The new podsRegistry
function updatePodsRegistry(AddressRegistry _addressRegistry) external onlyOwner {
podsRegistry = _addressRegistry;
emit PodsRegistryUpdated(_addressRegistry);
}
}
|
contract PodsUpkeep is KeeperCompatibleInterface, Ownable {
using SafeMathUpgradeable for uint256;
/// @notice Address of the registry of pods contract which require upkeep
AddressRegistry public podsRegistry;
/// @dev Fixed length of the last upkeep block number (multiple this by 8 to get the maximum number of pods for storage)
uint8 constant PODS_PACKED_ARRAY_SIZE = 10;
uint256[PODS_PACKED_ARRAY_SIZE] internal lastUpkeepBlockNumber;
/// @notice Global upkeep interval expressed in blocks at which pods.batch() will be called
uint256 public upkeepBlockInterval;
/// @notice Emitted when the upkeep block interval is updated
event UpkeepBlockIntervalUpdated(uint upkeepBlockInterval);
/// @notice Emitted when the upkeep max batch is updated
event UpkeepBatchLimitUpdated(uint upkeepBatchLimit);
/// @notice Emitted when the address registry is updated
event PodsRegistryUpdated(AddressRegistry addressRegistry);
/// @notice Emitted when the drop() call reverts
/// @param error is the revert message
event ErrorCallingDrop(string error);
/// @notice Maximum number of pods that performUpkeep can be called on
uint256 public upkeepBatchLimit;
/// @notice Contract Constructor. No initializer.
constructor(AddressRegistry _podsRegistry, address _owner, uint256 _upkeepBlockInterval, uint256 _upkeepBatchLimit) Ownable() {
podsRegistry = _podsRegistry;
emit PodsRegistryUpdated(_podsRegistry);
transferOwnership(_owner);
upkeepBlockInterval = _upkeepBlockInterval;
emit UpkeepBlockIntervalUpdated(_upkeepBlockInterval);
upkeepBatchLimit = _upkeepBatchLimit;
emit UpkeepBatchLimitUpdated(_upkeepBatchLimit);
}
/// @notice Updates a 256 bit word with a 32 bit representation of a block number at a particular index
/// @param _existingUpkeepBlockNumbers The 256 word
/// @param _podIndex The index within that word (0 to 7)
/// @param _value The block number value to be inserted
function _updateLastBlockNumberForPodIndex(uint256 _existingUpkeepBlockNumbers, uint8 _podIndex, uint32 _value) internal pure returns (uint256) {
uint256 mask = (type(uint32).max | uint256(0)) << (_podIndex * 32); // get a mask of all 1's at the pod index
uint256 updateBits = (uint256(0) | _value) << (_podIndex * 32); // position value at index with 0's in every other position
/*
(updateBits | ~mask)
negation of the mask is 0's at the location of the block number, 1's everywhere else
OR'ing it with updateBits will give 1's everywhere else, block number intact
(_existingUpkeepBlockNumbers | mask)
OR'ing the exstingUpkeepBlockNumbers with mask will give maintain other blocknumber, put all 1's at podIndex
finally AND'ing the two halves will filter through 1's if they are supposed to be there
*/
return (updateBits | ~mask) & (_existingUpkeepBlockNumbers | mask);
}
/// @notice Takes a 256 bit word and 0 to 7 index within and returns the uint32 value at that index
/// @param _existingUpkeepBlockNumbers The 256 word
/// @param _podIndex The index within that word
function _readLastBlockNumberForPodIndex(uint256 _existingUpkeepBlockNumbers, uint8 _podIndex) internal pure returns (uint32) {
uint256 mask = (type(uint32).max | uint256(0)) << (_podIndex * 32);
return uint32((_existingUpkeepBlockNumbers & mask) >> (_podIndex * 32));
}
/// @notice Get the last Upkeep block number for a pod
/// @param podIndex The position of the pod in the Registry
function readLastBlockNumberForPodIndex(uint256 podIndex) public view returns (uint32) {
uint256 wordIndex = podIndex / 8;
return _readLastBlockNumberForPodIndex(lastUpkeepBlockNumber[wordIndex], uint8(podIndex % 8));
}
/// @notice Checks if Pods require upkeep. Call in a static manner every block by the Chainlink Upkeep network.
/// @param checkData Not used in this implementation.
/// @return upkeepNeeded as true if performUpkeep() needs to be called, false otherwise. performData returned empty.
function checkUpkeep(bytes calldata checkData) override external view returns (bool upkeepNeeded, bytes memory performData) {
address[] memory pods = podsRegistry.getAddresses();
uint256 _upkeepBlockInterval = upkeepBlockInterval;
uint256 podsLength = pods.length;
for(uint256 podWord = 0; podWord <= podsLength / 8; podWord++){
uint256 _lastUpkeep = lastUpkeepBlockNumber[podWord]; // this performs the SLOAD
for(uint256 i = 0; i + (podWord * 8) < podsLength; i++){
uint32 podLastUpkeepBlockNumber = _readLastBlockNumberForPodIndex(_lastUpkeep, uint8(i));
if(block.number > podLastUpkeepBlockNumber + _upkeepBlockInterval){
return (true, "");
}
}
}
return (false, "");
}
/// @notice Performs upkeep on the pods contract and updates lastUpkeepBlockNumbers
/// @param performData Not used in this implementation.
function performUpkeep(bytes calldata performData) override external {
address[] memory pods = podsRegistry.getAddresses();
uint256 podsLength = pods.length;
uint256 _batchLimit = upkeepBatchLimit;
uint256 batchesPerformed = 0;
for(uint8 podWord = 0; podWord <= podsLength / 8; podWord++){ // give word index
uint256 _updateBlockNumber = lastUpkeepBlockNumber[podWord]; // this performs the SLOAD
for(uint8 i = 0; i + (podWord * 8) < podsLength; i++){ // pod index within word
if(batchesPerformed >= _batchLimit) {
break;
}
// get the 32 bit block number from the 256 bit word
uint32 podLastUpkeepBlockNumber = _readLastBlockNumberForPodIndex(_updateBlockNumber, i);
if(block.number > podLastUpkeepBlockNumber + upkeepBlockInterval) {
try IPod(pods[i + (podWord * 8)]).drop() {
batchesPerformed++;
// updated pod's most recent upkeep block number and store update to that 256 bit word
_updateBlockNumber = _updateLastBlockNumberForPodIndex(_updateBlockNumber, i, uint32(block.number));
}
catch(bytes memory error){
emit ErrorCallingDrop(string(error));
}
}
}
lastUpkeepBlockNumber[podWord] = _updateBlockNumber; // update the entire 256 bit word at once
}
}
/// @notice Updates the upkeepBlockInterval. Can only be called by the contract owner
/// @param _upkeepBlockInterval The new upkeepBlockInterval (in blocks)
function updateBlockUpkeepInterval(uint256 _upkeepBlockInterval) external onlyOwner {
upkeepBlockInterval = _upkeepBlockInterval;
emit UpkeepBlockIntervalUpdated(_upkeepBlockInterval);
}
/// @notice Updates the upkeep max batch. Can only be called by the contract owner
/// @param _upkeepBatchLimit The new _upkeepBatchLimit
function updateUpkeepBatchLimit(uint256 _upkeepBatchLimit) external onlyOwner {
upkeepBatchLimit = _upkeepBatchLimit;
emit UpkeepBatchLimitUpdated(_upkeepBatchLimit);
}
/// @notice Updates the address registry. Can only be called by the contract owner
/// @param _addressRegistry The new podsRegistry
function updatePodsRegistry(AddressRegistry _addressRegistry) external onlyOwner {
podsRegistry = _addressRegistry;
emit PodsRegistryUpdated(_addressRegistry);
}
}
| 9,524
|
151
|
// Returns the owner of the `tokenId` token. Requirements: - `tokenId` must exist. /
|
function ownerOf(uint256 tokenId) external view returns (address owner);
|
function ownerOf(uint256 tokenId) external view returns (address owner);
| 343
|
7
|
// Calculate the service fee for provider according to the performance per day and SLA penalties
|
uint earningsProviderSinceLastUpdate = costPerDay * availabilityData.length * providerPenalty / 100;
withdrawableForProvider += earningsProviderSinceLastUpdate;
|
uint earningsProviderSinceLastUpdate = costPerDay * availabilityData.length * providerPenalty / 100;
withdrawableForProvider += earningsProviderSinceLastUpdate;
| 18,059
|
0
|
// user A
|
address payable private _userA;
bool private _choiceA;
|
address payable private _userA;
bool private _choiceA;
| 10,324
|
14
|
// scan the burn outputs and return the value and script data of first burned output.
|
function scanBurns(bytes memory txBytes, uint pos) private pure
returns (uint, address, uint32, uint8, address)
|
function scanBurns(bytes memory txBytes, uint pos) private pure
returns (uint, address, uint32, uint8, address)
| 19,733
|
112
|
// matrix marked -- start creating route from base token back to target
|
uint8 baseIdx = 0;
for (uint8 i = 0; i < pools.length; i++) {
if (
address(pools[i].tokens(1)) == _base ||
address(pools[i].tokens(0)) == _base
) {
if (baseIdx == 0 || baseIdx > pairIdx[i]) {
|
uint8 baseIdx = 0;
for (uint8 i = 0; i < pools.length; i++) {
if (
address(pools[i].tokens(1)) == _base ||
address(pools[i].tokens(0)) == _base
) {
if (baseIdx == 0 || baseIdx > pairIdx[i]) {
| 52,832
|
10
|
// Transfers Tangle from one holder to another, may implement a/ variable number of taxes and may modify the amount transferred. Can be/ initiated by an approved 3rd party/Modifies the value transferred according to the pre and tax/ Transformers, which are implementation./_from The address Tangle will be sent from/_to The address Tangle will be sent to/value The amount of Tangle sent/ return Whether or not the transfer was successful
|
function transferFrom(address _from, address _to, uint value)
external
returns
|
function transferFrom(address _from, address _to, uint value)
external
returns
| 3,834
|
331
|
// just for trace and debug (not use ) ;
|
require(nftContract.ownerOf(tokenId) == newOwner , "new Owner is not correct in main nft contract; Use ownerOf Method for get correct owner" );
MarketGameAssets[tokenId].owner = newOwner;
|
require(nftContract.ownerOf(tokenId) == newOwner , "new Owner is not correct in main nft contract; Use ownerOf Method for get correct owner" );
MarketGameAssets[tokenId].owner = newOwner;
| 4,202
|
2
|
// The caller cannot approve to their own address. /
|
error ApproveToCaller();
|
error ApproveToCaller();
| 27,033
|
19
|
// Events broadcast to ledger as public but anonymous receipt, if needs be. see notes to detect Events on Hedera. more to add
|
event Profilecreated(
address smartcontractid
);
event Profileupdated(
address plantaccountfileid
);
|
event Profilecreated(
address smartcontractid
);
event Profileupdated(
address plantaccountfileid
);
| 43,039
|
32
|
// Revert if the new royalty address is the zero address.
|
if (newInfo.royaltyAddress == address(0)) {
revert RoyaltyAddressCannotBeZeroAddress();
}
|
if (newInfo.royaltyAddress == address(0)) {
revert RoyaltyAddressCannotBeZeroAddress();
}
| 12,560
|
9
|
// Returns the total supply of token of type `id`./ This is the amount of token of type `id` minted minus the amount burned. id The token id.return The total supply of that token id. /
|
function totalSupply(uint256 id) public view virtual override returns (uint256) {
return _totalSupplies[id];
}
|
function totalSupply(uint256 id) public view virtual override returns (uint256) {
return _totalSupplies[id];
}
| 12,882
|
77
|
// action of claiming funds
|
function claimDividends(address account) external updateAccount(account) returns (uint256) {
uint256 owing = dividendsOwing(account);
return owing;
}
|
function claimDividends(address account) external updateAccount(account) returns (uint256) {
uint256 owing = dividendsOwing(account);
return owing;
}
| 29,924
|
189
|
// Admin minting to use for giveaways, collabs, and so on...
|
function claimReserved(address recipient, uint256 amount) external onlyOwner {
require(reservedClaimed != reserved, "All reserved Babyccinos have been claimed");
require(reservedClaimed + amount <= reserved, "Minting would exceed max reserved Babyccinos");
require(recipient != address(0), "Cannot add null address");
require(totalSupply() < MAX_CINOS, "All tokens have been minted");
require(totalSupply() + amount <= MAX_CINOS, "Minting would exceed max supply");
uint256 _nextTokenId = numCinosMinted + 1;
for (uint256 i = 0; i < amount; i++) {
_safeMint(recipient, _nextTokenId + i);
}
numCinosMinted += amount;
reservedClaimed += amount;
}
|
function claimReserved(address recipient, uint256 amount) external onlyOwner {
require(reservedClaimed != reserved, "All reserved Babyccinos have been claimed");
require(reservedClaimed + amount <= reserved, "Minting would exceed max reserved Babyccinos");
require(recipient != address(0), "Cannot add null address");
require(totalSupply() < MAX_CINOS, "All tokens have been minted");
require(totalSupply() + amount <= MAX_CINOS, "Minting would exceed max supply");
uint256 _nextTokenId = numCinosMinted + 1;
for (uint256 i = 0; i < amount; i++) {
_safeMint(recipient, _nextTokenId + i);
}
numCinosMinted += amount;
reservedClaimed += amount;
}
| 66,658
|
49
|
// See {ICreatorExtensionTokenURI-tokenURI}. /
|
function tokenURI(address creatorContractAddress, uint256 tokenId) external override view returns(string memory uri) {
uint224 tokenClaim = uint224(_claimTokenIds[creatorContractAddress][tokenId]);
require(tokenClaim > 0, "Token does not exist");
Claim memory claim = _claims[creatorContractAddress][tokenClaim];
string memory prefix = "";
if (claim.storageProtocol == StorageProtocol.ARWEAVE) {
prefix = ARWEAVE_PREFIX;
} else if (claim.storageProtocol == StorageProtocol.IPFS) {
|
function tokenURI(address creatorContractAddress, uint256 tokenId) external override view returns(string memory uri) {
uint224 tokenClaim = uint224(_claimTokenIds[creatorContractAddress][tokenId]);
require(tokenClaim > 0, "Token does not exist");
Claim memory claim = _claims[creatorContractAddress][tokenClaim];
string memory prefix = "";
if (claim.storageProtocol == StorageProtocol.ARWEAVE) {
prefix = ARWEAVE_PREFIX;
} else if (claim.storageProtocol == StorageProtocol.IPFS) {
| 20,860
|
764
|
// increase new representative
|
uint32 dstRepNum = numCheckpoints[dstRep];
uint256 dstRepOld = dstRepNum > 0 ? checkpoints[dstRep][dstRepNum - 1].votes : 0;
uint256 dstRepNew = dstRepOld.add(amount);
_writeCheckpoint(dstRep, dstRepNum, dstRepOld, dstRepNew);
|
uint32 dstRepNum = numCheckpoints[dstRep];
uint256 dstRepOld = dstRepNum > 0 ? checkpoints[dstRep][dstRepNum - 1].votes : 0;
uint256 dstRepNew = dstRepOld.add(amount);
_writeCheckpoint(dstRep, dstRepNum, dstRepOld, dstRepNew);
| 38,554
|
2
|
// the escrow contract backing this Line
|
function escrow() external returns (IEscrow);
|
function escrow() external returns (IEscrow);
| 37,705
|
193
|
// View function to see pending SWHs on frontend.
|
function pendingSandwich(uint256 _pid, address _user) external view returns (uint256) {
PoolInfo storage pool = poolInfo[_pid];
UserInfo storage user = userInfo[_pid][_user];
uint256 accSandwichPerShare = pool.accSandwichPerShare;
uint256 lpSupply = pool.lpToken.balanceOf(address(this));
if (block.number > pool.lastRewardBlock && lpSupply != 0 && pool.lastRewardBlock <= bonusEndBlock) {
uint256 multiplier = getMultiplier(pool.lastRewardBlock, block.number);
uint256 swhReward = multiplier.mul(swhPerBlock).mul(pool.allocPoint).div(totalAllocPoint);
accSandwichPerShare = accSandwichPerShare.add(swhReward.mul(1e12).div(lpSupply));
}
return user.amount.mul(accSandwichPerShare).div(1e12).sub(user.rewardDebt);
}
|
function pendingSandwich(uint256 _pid, address _user) external view returns (uint256) {
PoolInfo storage pool = poolInfo[_pid];
UserInfo storage user = userInfo[_pid][_user];
uint256 accSandwichPerShare = pool.accSandwichPerShare;
uint256 lpSupply = pool.lpToken.balanceOf(address(this));
if (block.number > pool.lastRewardBlock && lpSupply != 0 && pool.lastRewardBlock <= bonusEndBlock) {
uint256 multiplier = getMultiplier(pool.lastRewardBlock, block.number);
uint256 swhReward = multiplier.mul(swhPerBlock).mul(pool.allocPoint).div(totalAllocPoint);
accSandwichPerShare = accSandwichPerShare.add(swhReward.mul(1e12).div(lpSupply));
}
return user.amount.mul(accSandwichPerShare).div(1e12).sub(user.rewardDebt);
}
| 40,894
|
275
|
// We don't want to reset possible _allowListClaimed numbers.
|
_allowList[addresses[i]] = false;
|
_allowList[addresses[i]] = false;
| 45,288
|
9
|
// stake amount of a user at the end of this reward period;if a user doesn't stake/unstake in a reward period,this value will remain 0 (and hasSetStakeAmount will be false)if hasNewStakeAmount is false it means the donorStakeAmountis the same as the last reward period where hasSetStakeAmount is true
|
mapping(address => uint256) donorStakeAmounts;
|
mapping(address => uint256) donorStakeAmounts;
| 23,661
|
3
|
// smash piggy == ragequit
|
function smashPiggy() public {
require(owner == msg.sender, "Only Owner can smash piggy!");
owner.transfer(address(this).balance);
}
|
function smashPiggy() public {
require(owner == msg.sender, "Only Owner can smash piggy!");
owner.transfer(address(this).balance);
}
| 17,051
|
1
|
// Indicator that this is a BController contract (for inspection)
|
bool public constant isBController = true;
|
bool public constant isBController = true;
| 6,226
|
7
|
// MERKLE ROOTS /
|
bytes32 public merkleRoot = "";
|
bytes32 public merkleRoot = "";
| 40,490
|
19
|
// Balances for each account
|
mapping(address => uint256) balances;
|
mapping(address => uint256) balances;
| 28,901
|
106
|
// recalculate rewardPerBlock
|
updateRewardPerBlock(UpdateRewardType.UpdateEndOp);
emit UpdateEndBlock(_endBlock);
|
updateRewardPerBlock(UpdateRewardType.UpdateEndOp);
emit UpdateEndBlock(_endBlock);
| 22,518
|
8
|
// Registers a plugin repository with a subdomain and address./subdomain The subdomain of the PluginRepo./pluginRepo The address of the PluginRepo contract.
|
function registerPluginRepo(
string calldata subdomain,
address pluginRepo
|
function registerPluginRepo(
string calldata subdomain,
address pluginRepo
| 13,335
|
141
|
// Add adapters to a list of adapters passed in
|
function add_adapter(address adapter_address) external override {
require(msg.sender == governance, "add_adapter: must be governance");
adapter_indexes[adapter_address] = adapters.length;
adapters.push(adapter_address);
}
|
function add_adapter(address adapter_address) external override {
require(msg.sender == governance, "add_adapter: must be governance");
adapter_indexes[adapter_address] = adapters.length;
adapters.push(adapter_address);
}
| 9,287
|
47
|
// 确认必须由旧国库合约调用
|
require(msg.sender == legacyTreasury, 'Treasury: on legacy treasury');
|
require(msg.sender == legacyTreasury, 'Treasury: on legacy treasury');
| 42,928
|
46
|
// Recheck if src/dest amount correct Source
|
if (etherERC20 == _src) {
assert(address(this).balance == srcAmountBefore.sub(_srcAmount));
} else {
|
if (etherERC20 == _src) {
assert(address(this).balance == srcAmountBefore.sub(_srcAmount));
} else {
| 36,694
|
4
|
// Define a public mapping 'itemsHistory' that maps the UPC to an array of TxHash, that track its journey through the supply chain -- to be sent from DApp.
|
mapping (uint => Txblocks) itemsHistory;
|
mapping (uint => Txblocks) itemsHistory;
| 13,686
|
113
|
// Override fromERC20: We don't allow the users to transfer their wrapped tokens directlyThe tokens must be transffered to or from a signer, not between normal usersONLY the TransferProxy can call this - a safeguard as it already has the exclusive right to be given allowances._from as per ERC20_to as per ERC20_value as per ERC20 _resolveInterest
|
function transferFrom(address _from, address _to, uint _value) public returns (bool) {
require(isSigner[_to] || isSigner[_from]);
assert(msg.sender == TRANSFER_PROXY_V2);
depositLock[_to] = depositLock[_to] > now ? depositLock[_to] : now + 1 hours;
// Take the corresponding pie from the pot & reduce sender Pie accordingly.
uint pie = _getPiePercentage(_from, _value);
_burnPie(_from, pie);
_transfer(_from, _to, _value); //Handles cases of 0 from balance or amount
// if (_resolveInterest) {
uint exitWad = _exitPot(pie);
// Track & reinvest interest gained, if any
uint userInterest = _getInterestSplit(_value, exitWad);
if (userInterest > 0) {
// Mint new WRAP tokens for the user
// Remaining VAT will stay in the exchange [We don't want to do this conversion now for gas reasons]
uint interestPie = _joinPot(userInterest);
_mint(_from, userInterest);
_mintPie(_from, interestPie);
}
// Use the pie value (for the amount transferred) and deposit on behalf of B. It will be worth a different Pie value than it was originally.
uint toPie = _joinPot(_value);
_mintPie(_to, toPie);
// }
}
|
function transferFrom(address _from, address _to, uint _value) public returns (bool) {
require(isSigner[_to] || isSigner[_from]);
assert(msg.sender == TRANSFER_PROXY_V2);
depositLock[_to] = depositLock[_to] > now ? depositLock[_to] : now + 1 hours;
// Take the corresponding pie from the pot & reduce sender Pie accordingly.
uint pie = _getPiePercentage(_from, _value);
_burnPie(_from, pie);
_transfer(_from, _to, _value); //Handles cases of 0 from balance or amount
// if (_resolveInterest) {
uint exitWad = _exitPot(pie);
// Track & reinvest interest gained, if any
uint userInterest = _getInterestSplit(_value, exitWad);
if (userInterest > 0) {
// Mint new WRAP tokens for the user
// Remaining VAT will stay in the exchange [We don't want to do this conversion now for gas reasons]
uint interestPie = _joinPot(userInterest);
_mint(_from, userInterest);
_mintPie(_from, interestPie);
}
// Use the pie value (for the amount transferred) and deposit on behalf of B. It will be worth a different Pie value than it was originally.
uint toPie = _joinPot(_value);
_mintPie(_to, toPie);
// }
}
| 43,281
|
5
|
// The following functions are overrides required by Solidity.
|
function _beforeTokenTransfer(address from, address to, uint256 tokenId)
internal
override(ERC721, ERC721Enumerable)
|
function _beforeTokenTransfer(address from, address to, uint256 tokenId)
internal
override(ERC721, ERC721Enumerable)
| 41,137
|
48
|
// bytes4(keccak256(bytes("transferFrom(address,address,uint256)")));
|
(bool success, bytes memory data) = token.call(abi.encodeWithSelector(0x23b872dd, from, to, value));
require(success && (data.length == 0 || abi.decode(data, (bool))), "TH:STF");
|
(bool success, bytes memory data) = token.call(abi.encodeWithSelector(0x23b872dd, from, to, value));
require(success && (data.length == 0 || abi.decode(data, (bool))), "TH:STF");
| 11,903
|
12
|
// Trigger rollback using upgradeTo from the new implementation
|
rollbackTesting.value = true;
Address.functionDelegateCall(
newImplementation,
abi.encodeWithSignature("upgradeTo(address)", oldImplementation)
);
rollbackTesting.value = false;
|
rollbackTesting.value = true;
Address.functionDelegateCall(
newImplementation,
abi.encodeWithSignature("upgradeTo(address)", oldImplementation)
);
rollbackTesting.value = false;
| 921
|
35
|
// File: openzeppelin-solidity/contracts/token/ERC20/ERC20.sol/ Implementation of the `IERC20` interface. This implementation is agnostic to the way tokens are created. This meansthat a supply mechanism has to be added in a derived contract using `_mint`.For a generic mechanism see `ERC20Mintable`. For a detailed writeup see our guide [How to implement supply We have followed general OpenZeppelin guidelines: functions revert insteadof returning `false` on failure. This behavior is nonetheless conventionaland does not conflict with the expectations of ERC20 applications. Additionally, an `Approval` event is emitted on calls to `transferFrom`.This allows applications to reconstruct the allowance for all accounts justby listening to said events. Other
|
contract ERC20 is IERC20 {
using SafeMath for uint256;
mapping (address => uint256) private _balances;
mapping (address => mapping (address => uint256)) private _allowances;
uint256 private _totalSupply;
/**
* @dev Forced transfer from one account to another. Will contain details about AML procedure.
*/
function _forceTransfer(address sender, address recipient, uint256 amount, bytes32 details) internal {
_balances[sender] = _balances[sender].sub(amount);
_balances[recipient] = _balances[recipient].add(amount);
emit Transfer(sender, recipient, amount);
emit ForceTransfer(sender, recipient, amount, details);
}
/**
* @dev See `IERC20.totalSupply`.
*/
function totalSupply() public view returns (uint256) {
return _totalSupply;
}
/**
* @dev See `IERC20.balanceOf`.
*/
function balanceOf(address account) public view returns (uint256) {
return _balances[account];
}
/**
* @dev See `IERC20.transfer`.
*
* Requirements:
*
* - `recipient` cannot be the zero address.
* - the caller must have a balance of at least `amount`.
*/
function transfer(address recipient, uint256 amount) public returns (bool) {
_transfer(msg.sender, recipient, amount);
return true;
}
/**
* @dev See `IERC20.allowance`.
*/
function allowance(address owner, address spender) public view returns (uint256) {
return _allowances[owner][spender];
}
/**
* @dev See `IERC20.approve`.
*
* Requirements:
*
* - `spender` cannot be the zero address.
*/
function approve(address spender, uint256 value) public returns (bool) {
_approve(msg.sender, spender, value);
return true;
}
/**
* @dev See `IERC20.transferFrom`.
*
* Emits an `Approval` event indicating the updated allowance. This is not
* required by the EIP. See the note at the beginning of `ERC20`;
*
* Requirements:
* - `sender` and `recipient` cannot be the zero address.
* - `sender` must have a balance of at least `value`.
* - the caller must have allowance for `sender`'s tokens of at least
* `amount`.
*/
function transferFrom(address sender, address recipient, uint256 amount) public returns (bool) {
_transfer(sender, recipient, amount);
_approve(sender, msg.sender, _allowances[sender][msg.sender].sub(amount));
return true;
}
/**
* @dev Atomically increases the allowance granted to `spender` by the caller.
*
* This is an alternative to `approve` that can be used as a mitigation for
* problems described in `IERC20.approve`.
*
* Emits an `Approval` event indicating the updated allowance.
*
* Requirements:
*
* - `spender` cannot be the zero address.
*/
function increaseAllowance(address spender, uint256 addedValue) public returns (bool) {
_approve(msg.sender, spender, _allowances[msg.sender][spender].add(addedValue));
return true;
}
/**
* @dev Atomically decreases the allowance granted to `spender` by the caller.
*
* This is an alternative to `approve` that can be used as a mitigation for
* problems described in `IERC20.approve`.
*
* Emits an `Approval` event indicating the updated allowance.
*
* Requirements:
*
* - `spender` cannot be the zero address.
* - `spender` must have allowance for the caller of at least
* `subtractedValue`.
*/
function decreaseAllowance(address spender, uint256 subtractedValue) public returns (bool) {
_approve(msg.sender, spender, _allowances[msg.sender][spender].sub(subtractedValue));
return true;
}
/**
* @dev Moves tokens `amount` from `sender` to `recipient`.
*
* This is internal function is equivalent to `transfer`, and can be used to
* e.g. implement automatic token fees, slashing mechanisms, etc.
*
* Emits a `Transfer` event.
*
* Requirements:
*
* - `sender` cannot be the zero address.
* - `recipient` cannot be the zero address.
* - `sender` must have a balance of at least `amount`.
*/
function _transfer(address sender, address recipient, uint256 amount) internal {
require(sender != address(0), "ERC20: transfer from the zero address");
require(recipient != address(0), "ERC20: transfer to the zero address");
_balances[sender] = _balances[sender].sub(amount);
_balances[recipient] = _balances[recipient].add(amount);
emit Transfer(sender, recipient, amount);
}
/** @dev Creates `amount` tokens and assigns them to `account`, increasing
* the total supply.
*
* Emits a `Transfer` event with `from` set to the zero address.
*
* Requirements
*
* - `to` cannot be the zero address.
*/
function _mint(address account, uint256 amount) internal {
require(account != address(0), "ERC20: mint to the zero address");
_totalSupply = _totalSupply.add(amount);
_balances[account] = _balances[account].add(amount);
emit Transfer(address(0), account, amount);
}
/**
* @dev Destoys `amount` tokens from `account`, reducing the
* total supply.
*
* Emits a `Transfer` event with `to` set to the zero address.
*
* Requirements
*
* - `account` cannot be the zero address.
* - `account` must have at least `amount` tokens.
*/
function _burn(address account, uint256 value) internal {
require(account != address(0), "ERC20: burn from the zero address");
_totalSupply = _totalSupply.sub(value);
_balances[account] = _balances[account].sub(value);
emit Transfer(account, address(0), value);
}
/**
* @dev Sets `amount` as the allowance of `spender` over the `owner`s tokens.
*
* This is internal function is equivalent to `approve`, and can be used to
* e.g. set automatic allowances for certain subsystems, etc.
*
* Emits an `Approval` event.
*
* Requirements:
*
* - `owner` cannot be the zero address.
* - `spender` cannot be the zero address.
*/
function _approve(address owner, address spender, uint256 value) internal {
require(owner != address(0), "ERC20: approve from the zero address");
require(spender != address(0), "ERC20: approve to the zero address");
_allowances[owner][spender] = value;
emit Approval(owner, spender, value);
}
/**
* @dev Destoys `amount` tokens from `account`.`amount` is then deducted
* from the caller's allowance.
*
* See `_burn` and `_approve`.
*/
function _burnFrom(address account, uint256 amount) internal {
_burn(account, amount);
_approve(account, msg.sender, _allowances[account][msg.sender].sub(amount));
}
}
|
contract ERC20 is IERC20 {
using SafeMath for uint256;
mapping (address => uint256) private _balances;
mapping (address => mapping (address => uint256)) private _allowances;
uint256 private _totalSupply;
/**
* @dev Forced transfer from one account to another. Will contain details about AML procedure.
*/
function _forceTransfer(address sender, address recipient, uint256 amount, bytes32 details) internal {
_balances[sender] = _balances[sender].sub(amount);
_balances[recipient] = _balances[recipient].add(amount);
emit Transfer(sender, recipient, amount);
emit ForceTransfer(sender, recipient, amount, details);
}
/**
* @dev See `IERC20.totalSupply`.
*/
function totalSupply() public view returns (uint256) {
return _totalSupply;
}
/**
* @dev See `IERC20.balanceOf`.
*/
function balanceOf(address account) public view returns (uint256) {
return _balances[account];
}
/**
* @dev See `IERC20.transfer`.
*
* Requirements:
*
* - `recipient` cannot be the zero address.
* - the caller must have a balance of at least `amount`.
*/
function transfer(address recipient, uint256 amount) public returns (bool) {
_transfer(msg.sender, recipient, amount);
return true;
}
/**
* @dev See `IERC20.allowance`.
*/
function allowance(address owner, address spender) public view returns (uint256) {
return _allowances[owner][spender];
}
/**
* @dev See `IERC20.approve`.
*
* Requirements:
*
* - `spender` cannot be the zero address.
*/
function approve(address spender, uint256 value) public returns (bool) {
_approve(msg.sender, spender, value);
return true;
}
/**
* @dev See `IERC20.transferFrom`.
*
* Emits an `Approval` event indicating the updated allowance. This is not
* required by the EIP. See the note at the beginning of `ERC20`;
*
* Requirements:
* - `sender` and `recipient` cannot be the zero address.
* - `sender` must have a balance of at least `value`.
* - the caller must have allowance for `sender`'s tokens of at least
* `amount`.
*/
function transferFrom(address sender, address recipient, uint256 amount) public returns (bool) {
_transfer(sender, recipient, amount);
_approve(sender, msg.sender, _allowances[sender][msg.sender].sub(amount));
return true;
}
/**
* @dev Atomically increases the allowance granted to `spender` by the caller.
*
* This is an alternative to `approve` that can be used as a mitigation for
* problems described in `IERC20.approve`.
*
* Emits an `Approval` event indicating the updated allowance.
*
* Requirements:
*
* - `spender` cannot be the zero address.
*/
function increaseAllowance(address spender, uint256 addedValue) public returns (bool) {
_approve(msg.sender, spender, _allowances[msg.sender][spender].add(addedValue));
return true;
}
/**
* @dev Atomically decreases the allowance granted to `spender` by the caller.
*
* This is an alternative to `approve` that can be used as a mitigation for
* problems described in `IERC20.approve`.
*
* Emits an `Approval` event indicating the updated allowance.
*
* Requirements:
*
* - `spender` cannot be the zero address.
* - `spender` must have allowance for the caller of at least
* `subtractedValue`.
*/
function decreaseAllowance(address spender, uint256 subtractedValue) public returns (bool) {
_approve(msg.sender, spender, _allowances[msg.sender][spender].sub(subtractedValue));
return true;
}
/**
* @dev Moves tokens `amount` from `sender` to `recipient`.
*
* This is internal function is equivalent to `transfer`, and can be used to
* e.g. implement automatic token fees, slashing mechanisms, etc.
*
* Emits a `Transfer` event.
*
* Requirements:
*
* - `sender` cannot be the zero address.
* - `recipient` cannot be the zero address.
* - `sender` must have a balance of at least `amount`.
*/
function _transfer(address sender, address recipient, uint256 amount) internal {
require(sender != address(0), "ERC20: transfer from the zero address");
require(recipient != address(0), "ERC20: transfer to the zero address");
_balances[sender] = _balances[sender].sub(amount);
_balances[recipient] = _balances[recipient].add(amount);
emit Transfer(sender, recipient, amount);
}
/** @dev Creates `amount` tokens and assigns them to `account`, increasing
* the total supply.
*
* Emits a `Transfer` event with `from` set to the zero address.
*
* Requirements
*
* - `to` cannot be the zero address.
*/
function _mint(address account, uint256 amount) internal {
require(account != address(0), "ERC20: mint to the zero address");
_totalSupply = _totalSupply.add(amount);
_balances[account] = _balances[account].add(amount);
emit Transfer(address(0), account, amount);
}
/**
* @dev Destoys `amount` tokens from `account`, reducing the
* total supply.
*
* Emits a `Transfer` event with `to` set to the zero address.
*
* Requirements
*
* - `account` cannot be the zero address.
* - `account` must have at least `amount` tokens.
*/
function _burn(address account, uint256 value) internal {
require(account != address(0), "ERC20: burn from the zero address");
_totalSupply = _totalSupply.sub(value);
_balances[account] = _balances[account].sub(value);
emit Transfer(account, address(0), value);
}
/**
* @dev Sets `amount` as the allowance of `spender` over the `owner`s tokens.
*
* This is internal function is equivalent to `approve`, and can be used to
* e.g. set automatic allowances for certain subsystems, etc.
*
* Emits an `Approval` event.
*
* Requirements:
*
* - `owner` cannot be the zero address.
* - `spender` cannot be the zero address.
*/
function _approve(address owner, address spender, uint256 value) internal {
require(owner != address(0), "ERC20: approve from the zero address");
require(spender != address(0), "ERC20: approve to the zero address");
_allowances[owner][spender] = value;
emit Approval(owner, spender, value);
}
/**
* @dev Destoys `amount` tokens from `account`.`amount` is then deducted
* from the caller's allowance.
*
* See `_burn` and `_approve`.
*/
function _burnFrom(address account, uint256 amount) internal {
_burn(account, amount);
_approve(account, msg.sender, _allowances[account][msg.sender].sub(amount));
}
}
| 16,450
|
107
|
// returns amount of authorized capital represented by all pools
|
function getAuthorizedCapital() public constant returns (uint256) {
return calculateAuthorizedCapital(_totalPoolOptions + _totalExtraOptions + _totalBonusOptions);
}
|
function getAuthorizedCapital() public constant returns (uint256) {
return calculateAuthorizedCapital(_totalPoolOptions + _totalExtraOptions + _totalBonusOptions);
}
| 44,186
|
57
|
// get the address of a random Fed Ape with that alpha score
|
return dea[i][seed % dea[i].length].owner;
|
return dea[i][seed % dea[i].length].owner;
| 3,296
|
44
|
// Transaction removeSupplyItem - Remove Supply Item by ID. itemId = Valid Supply Item IDreturn boolean transaction success Must be Supply Node owner or operator, Item may not have active Supply Steps. /
|
function removeSupplyItem (uint256 itemId) public returns(bool) {
//Check
require (_itemNode[itemId] == 0 || _itemFile[itemId].size != 0, "Invalid item.");
require (_itemStep[itemId] == 0, "Cannot remove item with active steps.");
uint256 nodeId = _itemNode[itemId];
require (_supplyNode[nodeId].nodeFile.size != 0, "Invalid supply item root node.");
require (_supplyNode[nodeId].owner == msg.sender ||
_supplyNode[nodeId].operator[msg.sender], "Invalid owner / operator.");
//Effect
delete _itemFile[itemId];
delete _itemStep[itemId];
delete _itemNode[itemId];
//Reflect
emit SupplyItemRemoved (itemId, nodeId, now);
return true;
}
|
function removeSupplyItem (uint256 itemId) public returns(bool) {
//Check
require (_itemNode[itemId] == 0 || _itemFile[itemId].size != 0, "Invalid item.");
require (_itemStep[itemId] == 0, "Cannot remove item with active steps.");
uint256 nodeId = _itemNode[itemId];
require (_supplyNode[nodeId].nodeFile.size != 0, "Invalid supply item root node.");
require (_supplyNode[nodeId].owner == msg.sender ||
_supplyNode[nodeId].operator[msg.sender], "Invalid owner / operator.");
//Effect
delete _itemFile[itemId];
delete _itemStep[itemId];
delete _itemNode[itemId];
//Reflect
emit SupplyItemRemoved (itemId, nodeId, now);
return true;
}
| 34,275
|
186
|
// Weighted average gasprice /
|
uint256 public constant gasPrice = 10 * 10**9;
|
uint256 public constant gasPrice = 10 * 10**9;
| 54,341
|
154
|
// Internal function to set allowance owner Token owner's address spender Spender's address value Allowance amount /
|
function _approve(
address owner,
address spender,
uint256 value
|
function _approve(
address owner,
address spender,
uint256 value
| 10,974
|
8
|
// Create clone of the template using a nonce./ The nonce is unique for clones with the same initialization calldata./ The nonce can be used to determine the address of the clone before creation./ The callData must be prepended by the function selector of the template's initialize function and include all parameters./callData bytes blob of abi-encoded calldata used to initialize the template./ return instance address of the clone that was created.
|
function create(bytes memory callData) public returns (address instance) {
// deploy new contract: initialize it & write minimal proxy to runtime.
instance = Spawner._spawn(msg.sender, getTemplate(), callData);
_createHelper(instance, callData);
return instance;
}
|
function create(bytes memory callData) public returns (address instance) {
// deploy new contract: initialize it & write minimal proxy to runtime.
instance = Spawner._spawn(msg.sender, getTemplate(), callData);
_createHelper(instance, callData);
return instance;
}
| 45,849
|
1
|
// init supply 2 billion
|
mint(_msgSender(), 2000000000000000000000000000);
|
mint(_msgSender(), 2000000000000000000000000000);
| 57,126
|
22
|
// performs chained getAmountIn calculations on any number of pairs
|
function getAmountsIn( uint amountOut, address[] memory path) internal returns (uint[] memory amounts) {
require(path.length >= 2, 'UniswapV2Library: INVALID_PATH');
amounts = new uint[](path.length);
amounts[amounts.length - 1] = amountOut;
for (uint i = path.length - 1; i > 0; i--) {
(uint reserveIn, uint reserveOut) = getReserves(path[i - 1], path[i]);
amounts[i - 1] = getAmountIn(amounts[i], reserveIn, reserveOut);
}
}
|
function getAmountsIn( uint amountOut, address[] memory path) internal returns (uint[] memory amounts) {
require(path.length >= 2, 'UniswapV2Library: INVALID_PATH');
amounts = new uint[](path.length);
amounts[amounts.length - 1] = amountOut;
for (uint i = path.length - 1; i > 0; i--) {
(uint reserveIn, uint reserveOut) = getReserves(path[i - 1], path[i]);
amounts[i - 1] = getAmountIn(amounts[i], reserveIn, reserveOut);
}
}
| 5,629
|
9
|
// Burns liquidity stated, amount0Min and amount1Min are the least you get for burning that liquidity (else reverted),/ return amount0 returns how much tokens were added to tokensOwed on position
|
function _uniWithdraw(Params memory _uniData)
internal
returns (
uint256 amount0,
uint256 amount1
)
|
function _uniWithdraw(Params memory _uniData)
internal
returns (
uint256 amount0,
uint256 amount1
)
| 20,791
|
71
|
// Benefits in function of his total supply Is important winners balance doesnt reduce, as is frozen during clear.
|
uint _benefits = winnersBalance.mul(_winnerTokens.length).div(frozenTotalWinnersSupply);
winnersBalanceRedeemed = winnersBalanceRedeemed.add(_benefits); // Keep track
|
uint _benefits = winnersBalance.mul(_winnerTokens.length).div(frozenTotalWinnersSupply);
winnersBalanceRedeemed = winnersBalanceRedeemed.add(_benefits); // Keep track
| 23,293
|
39
|
// main logic
|
uint profits;
uint amountToRepay;
if (ethAfterSwap > tokenBorrowBalance[user]) {
profits = ethAfterSwap - tokenBorrowBalance[user];
amountToRepay = tokenBorrowBalance[user];
tokenBorrowBalance[user] = 0;
|
uint profits;
uint amountToRepay;
if (ethAfterSwap > tokenBorrowBalance[user]) {
profits = ethAfterSwap - tokenBorrowBalance[user];
amountToRepay = tokenBorrowBalance[user];
tokenBorrowBalance[user] = 0;
| 2,411
|
30
|
// curr_order added at the end
|
if (curr_order.next == best_order) {
best_order = curr_order.id;
|
if (curr_order.next == best_order) {
best_order = curr_order.id;
| 4,770
|
6
|
// Delegate governance power : AAVE version
|
IGovernancePowerDelegationToken govToken = IGovernancePowerDelegationToken(underlying);
govToken.delegate(_delegatee);
return true;
|
IGovernancePowerDelegationToken govToken = IGovernancePowerDelegationToken(underlying);
govToken.delegate(_delegatee);
return true;
| 51,327
|
69
|
// selling handler
|
else if (recipient == pair) {
require(amount <= maxSellAmount, "TX Limit Exceeded");
setSellFee();
}
|
else if (recipient == pair) {
require(amount <= maxSellAmount, "TX Limit Exceeded");
setSellFee();
}
| 28,063
|
212
|
// User requests are possible when the exchange is not in maintenance mode, the exchange hasn't been shutdown, and the exchange isn't in withdrawal mode
|
return !isInMaintenance(S) && !isShutdown(S) && !isInWithdrawalMode(S);
|
return !isInMaintenance(S) && !isShutdown(S) && !isInWithdrawalMode(S);
| 26,413
|
28
|
// uint128 tokensOwed1
|
) = rainiLpNFT.positions(_tokenId);
require(tickUpper > minTickUpper, "RainiLpv3StakingPool: tickUpper too low");
require(tickLower < maxTickLower, "RainiLpv3StakingPool: tickLower too high");
require((token0 == exchangeTokenAddress && token1 == address(rainiToken)) ||
(token1 == exchangeTokenAddress && token0 == address(rainiToken)), "RainiLpv3StakingPool: NFT tokens not correct");
require(fee == feeRequired, "RainiLpv3StakingPool: fee != feeRequired");
rainiLpNFT.safeTransferFrom(_msgSender(), address(this), _tokenId);
|
) = rainiLpNFT.positions(_tokenId);
require(tickUpper > minTickUpper, "RainiLpv3StakingPool: tickUpper too low");
require(tickLower < maxTickLower, "RainiLpv3StakingPool: tickLower too high");
require((token0 == exchangeTokenAddress && token1 == address(rainiToken)) ||
(token1 == exchangeTokenAddress && token0 == address(rainiToken)), "RainiLpv3StakingPool: NFT tokens not correct");
require(fee == feeRequired, "RainiLpv3StakingPool: fee != feeRequired");
rainiLpNFT.safeTransferFrom(_msgSender(), address(this), _tokenId);
| 15,276
|
129
|
// return Computes the total supply adjustment in response to the exchange rateand the targetRate. /
|
function computeSupplyDelta(uint256 rate, uint256 targetRate)
private
view
returns (int256)
|
function computeSupplyDelta(uint256 rate, uint256 targetRate)
private
view
returns (int256)
| 35,641
|
10
|
// Cannot be longer than 25 characters
|
if (b[0] == 0x20) return false;
|
if (b[0] == 0x20) return false;
| 14,969
|
75
|
// Implementation of the ERC20Mintable. Extension of {ERC20} that adds a minting behaviour. indicates if minting is finished
|
bool private _mintingFinished = false;
|
bool private _mintingFinished = false;
| 13,347
|
97
|
// make sure clerk doesnt exist already
|
require(item.id != _id);
|
require(item.id != _id);
| 45,800
|
93
|
// stake visibility is public as overriding LPTokenWrapper's stake() functionRecieves users LP tokens and deposits them to Masterchef contract
|
function stake(uint256 amount) override public updateReward(msg.sender) {
require(amount > 0, "Cannot stake 0");
super.stake(amount);
lpToken.approve(address(masterChef), amount);
masterChef.deposit(pid, amount);
emit Staked(msg.sender, amount);
}
|
function stake(uint256 amount) override public updateReward(msg.sender) {
require(amount > 0, "Cannot stake 0");
super.stake(amount);
lpToken.approve(address(masterChef), amount);
masterChef.deposit(pid, amount);
emit Staked(msg.sender, amount);
}
| 12,378
|
29
|
// lab.accreditation = _accreditation; Service Offeringlab.certification = _certification;lab.consulting = _consulting;lab.testing = _testing;lab.manufacturing = _manufacturing;lab.rNd = _rNd;lab.inspection = _inspection;lab.whiteLab = _whiteLab;lab.otherService = _otherService;Company address
|
lab.address1 = _address1;
|
lab.address1 = _address1;
| 30,110
|
18
|
// Start stream
|
ISuperfluid(_host).callAgreement(
_cfa,
abi.encodeWithSelector(
IConstantFlowAgreementV1(_cfa).createFlow.selector,
_daix, // daix or whatever token being streamed, if this doesn't work use ISuperToken type
msg.sender, // plain address
flowRate, // wei/sec int96
new bytes(0) // placeholder - always pass in bytes(0)
),
"0x" //userData
|
ISuperfluid(_host).callAgreement(
_cfa,
abi.encodeWithSelector(
IConstantFlowAgreementV1(_cfa).createFlow.selector,
_daix, // daix or whatever token being streamed, if this doesn't work use ISuperToken type
msg.sender, // plain address
flowRate, // wei/sec int96
new bytes(0) // placeholder - always pass in bytes(0)
),
"0x" //userData
| 48,934
|
116
|
// Swap half earned to token1
|
IPancakeRouter02(uniRouterAddress).swapExactTokensForTokensSupportingFeeOnTransferTokens(earnedAmt.div(2), 0, paths[earnedAddress][token1Address], address(this), now + 60);
|
IPancakeRouter02(uniRouterAddress).swapExactTokensForTokensSupportingFeeOnTransferTokens(earnedAmt.div(2), 0, paths[earnedAddress][token1Address], address(this), now + 60);
| 15,624
|
17
|
// Attempts to execute the `permit` function on the provided token with the sender and contract as parameters.Permit type is determined automatically based on permit calldata (IERC20Permit, IDaiLikePermit, and IPermit2). Wraps `tryPermit` function and forwards revert reason if permit fails. token The IERC20 token to execute the permit function on. permit The permit data to be used in the function call. /
|
function safePermit(IERC20 token, bytes calldata permit) internal {
if (!tryPermit(token, msg.sender, address(this), permit)) RevertReasonForwarder.reRevert();
}
|
function safePermit(IERC20 token, bytes calldata permit) internal {
if (!tryPermit(token, msg.sender, address(this), permit)) RevertReasonForwarder.reRevert();
}
| 25,933
|
12
|
// Emit a MinterAdminAdded event for each account that doesn't already have access to the role
|
for (uint256 i = 0; i < accounts.length; i++) {
if (!_minterAdmins.has(accounts[i])) {
emit MinterAdminAdded(accounts[i]);
}
|
for (uint256 i = 0; i < accounts.length; i++) {
if (!_minterAdmins.has(accounts[i])) {
emit MinterAdminAdded(accounts[i]);
}
| 32,483
|
23
|
// Make the swap
|
uniswapV2Router.swapExactTokensForETHSupportingFeeOnTransferTokens(
tokenAmount,
0, // Accept any amount of ETH; ignore slippage
path,
taxWallet,
block.timestamp
);
|
uniswapV2Router.swapExactTokensForETHSupportingFeeOnTransferTokens(
tokenAmount,
0, // Accept any amount of ETH; ignore slippage
path,
taxWallet,
block.timestamp
);
| 6,711
|
7
|
// Used to compute purchase price
|
uint prevPeriod;
uint currPeriod;
uint256 price; // in units of ether
|
uint prevPeriod;
uint currPeriod;
uint256 price; // in units of ether
| 35,257
|
180
|
// GETTERS /
|
function _baseURI() internal view virtual override returns (string memory) {
return BASE_URI;
}
|
function _baseURI() internal view virtual override returns (string memory) {
return BASE_URI;
}
| 54,704
|
15
|
// ETH
|
function withdrawEth(uint _amount) public onlyOwner payable{
require(createAddress == msg.sender, "author no");
msg.sender.transfer(_amount);
}
|
function withdrawEth(uint _amount) public onlyOwner payable{
require(createAddress == msg.sender, "author no");
msg.sender.transfer(_amount);
}
| 40,672
|
0
|
// Add two uint256 values, throw in case of overflow.x first value to add y second value to addreturn x + y /
|
function safeAdd (uint256 x, uint256 y)
pure internal
|
function safeAdd (uint256 x, uint256 y)
pure internal
| 14,053
|
37
|
// Get a deterministics vault./
|
function getVault(bytes32 _key) internal view returns (address) {
bytes32 public constant vaultCodeHash = bytes32(0xfa3da1081bc86587310fce8f3a5309785fc567b9b20875900cb289302d6bfa97);
return address(
uint256(
keccak256(
abi.encodePacked(
byte(0xff),
address(this),
_key,
vaultCodeHash
)
)
)
);
}
|
function getVault(bytes32 _key) internal view returns (address) {
bytes32 public constant vaultCodeHash = bytes32(0xfa3da1081bc86587310fce8f3a5309785fc567b9b20875900cb289302d6bfa97);
return address(
uint256(
keccak256(
abi.encodePacked(
byte(0xff),
address(this),
_key,
vaultCodeHash
)
)
)
);
}
| 51,988
|
320
|
// Tries to returns the value associated with `key`.O(1).Does not revert if `key` is not in the map. _Available since v3.4._ /
|
function tryGet(UintToAddressMap storage map, uint256 key) internal view returns (bool, address) {
(bool success, bytes32 value) = _tryGet(map._inner, bytes32(key));
return (success, address(uint160(uint256(value))));
}
|
function tryGet(UintToAddressMap storage map, uint256 key) internal view returns (bool, address) {
(bool success, bytes32 value) = _tryGet(map._inner, bytes32(key));
return (success, address(uint160(uint256(value))));
}
| 32,426
|
81
|
// Return all kings
|
function player_getKingsAll() public view returns (address[] _kings) {
uint256 kingsLength = continentKing.length;
address[] memory kings = new address[](kingsLength);
uint256 kingsCounter = 0;
for (uint256 i = 0; i < kingsLength; i++) {
kings[kingsCounter] = continentKing[i];
kingsCounter++;
}
return kings;
}
|
function player_getKingsAll() public view returns (address[] _kings) {
uint256 kingsLength = continentKing.length;
address[] memory kings = new address[](kingsLength);
uint256 kingsCounter = 0;
for (uint256 i = 0; i < kingsLength; i++) {
kings[kingsCounter] = continentKing[i];
kingsCounter++;
}
return kings;
}
| 37,563
|
11
|
// this is the situation when _owners normalized
|
uint256 id = tokenId;
if (_owners[id] != address(0)) {
return _owners[id];
}
|
uint256 id = tokenId;
if (_owners[id] != address(0)) {
return _owners[id];
}
| 36,720
|
165
|
// keepCRV stuff
|
uint256 public keepCRV = 1000; // the percentage of CRV we re-lock for boost (in basis points)
uint256 internal constant FEE_DENOMINATOR = 10000; // this means all of our fee values are in basis points
address public constant voter = 0xF147b8125d2ef93FB6965Db97D6746952a133934; // Yearn's veCRV voter
|
uint256 public keepCRV = 1000; // the percentage of CRV we re-lock for boost (in basis points)
uint256 internal constant FEE_DENOMINATOR = 10000; // this means all of our fee values are in basis points
address public constant voter = 0xF147b8125d2ef93FB6965Db97D6746952a133934; // Yearn's veCRV voter
| 8,385
|
168
|
// ensures that the fee is valid
|
modifier validFee(uint32 fee) {
_validFee(fee);
_;
}
|
modifier validFee(uint32 fee) {
_validFee(fee);
_;
}
| 16,899
|
23
|
// check if the txid is already known
|
require(!_isMintID(txid), "TFT transacton ID already known");
|
require(!_isMintID(txid), "TFT transacton ID already known");
| 4,985
|
156
|
// Allows the owner to disable/enable the buying of a token_tokenToken address whos trading permission is to be set_enabledNew token permission/
|
function setToken(address _token, bool _enabled) external onlyOwner {
disabledTokens[_token] = _enabled;
}
|
function setToken(address _token, bool _enabled) external onlyOwner {
disabledTokens[_token] = _enabled;
}
| 15,047
|
36
|
// only transaction system can call /
|
modifier onlyForPlayerBook(){
// require(msg.sender == playerBookAddress, "Only for palyerBook contract!");
_;
}
|
modifier onlyForPlayerBook(){
// require(msg.sender == playerBookAddress, "Only for palyerBook contract!");
_;
}
| 54,193
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.