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
|
|---|---|---|---|---|
217
|
// onlyOwnerOrOperator can set jackpotToken jackpotToken address ether to token rate win reward rate, defult 10(divisor 1000) lose reward rate, defult 1000(divisor 1000) /
|
function ownerSetJackpotToken(address newTokenAddr, uint newTokenEthRate, uint newWinRewardRate, uint newLoseRewardRate) public onlyOwnerOrOperator{
|
function ownerSetJackpotToken(address newTokenAddr, uint newTokenEthRate, uint newWinRewardRate, uint newLoseRewardRate) public onlyOwnerOrOperator{
| 74,226
|
372
|
// Pay appeal deposit
|
NextRoundDetails memory nextRound = _getNextRoundDetails(round, _roundId, config);
_depositAmount(msg.sender, nextRound.feeToken, nextRound.appealDeposit);
|
NextRoundDetails memory nextRound = _getNextRoundDetails(round, _roundId, config);
_depositAmount(msg.sender, nextRound.feeToken, nextRound.appealDeposit);
| 12,970
|
89
|
// slength can contain both the length and contents of the array if length < 32 bytes so let&39;s prepare for that v. http:solidity.readthedocs.io/en/latest/miscellaneous.htmllayout-of-state-variables-in-storage
|
switch add(lt(slength, 32), lt(newlength, 32))
case 2 {
|
switch add(lt(slength, 32), lt(newlength, 32))
case 2 {
| 21,836
|
19
|
// Do nothing if we haven&39;t properly set up the delegator to delegate calls
|
if (controllerLookupName == 0) {
return;
}
|
if (controllerLookupName == 0) {
return;
}
| 47,036
|
93
|
// Mint event./to To address./amount Minted value.
|
event Mint(address indexed to, uint256 amount);
|
event Mint(address indexed to, uint256 amount);
| 33,849
|
85
|
// function to cancel and purchase an existing askcombined function for someone placed a bid to low - but then changes it to complete a limit order existing
|
function cancelAndBuyCall(uint _d, uint _c) payable public {
Call storage d = calls[_d];
Call storage call = calls[_c];
//first cancel the open bid without refund
cancelNewBid(_d); //pyment sends back to make it easier to handle price changes
//are they buying a new or opened call?
if (call.open) {
buyOpenCall(_c); //purchases existing open call
} else {
buyNewCall(_c); //purchases new call
}
}
|
function cancelAndBuyCall(uint _d, uint _c) payable public {
Call storage d = calls[_d];
Call storage call = calls[_c];
//first cancel the open bid without refund
cancelNewBid(_d); //pyment sends back to make it easier to handle price changes
//are they buying a new or opened call?
if (call.open) {
buyOpenCall(_c); //purchases existing open call
} else {
buyNewCall(_c); //purchases new call
}
}
| 13,039
|
323
|
// Increment tier counter
|
tierCounts[tier.id] = tierCounts[tier.id].add(1);
|
tierCounts[tier.id] = tierCounts[tier.id].add(1);
| 53,912
|
216
|
// sets the referenced oracle/_oracle the new oracle to reference
|
function setOracle(address _oracle) external override onlyGovernor {
_setOracle(_oracle);
}
|
function setOracle(address _oracle) external override onlyGovernor {
_setOracle(_oracle);
}
| 29,042
|
13
|
// Modifiers can take inputs. This modifier checks that the address passed in is not the zero address.
|
modifier validAddress(address _addr) {
require(_addr != address(0), "Not valid address");
_;
}
|
modifier validAddress(address _addr) {
require(_addr != address(0), "Not valid address");
_;
}
| 30,103
|
5
|
// Library to parse the PClaims structure from a blob of capnproto data
|
library PClaimsParserLibrary {
/** @dev size in bytes of a PCLAIMS cap'npro structure without the cap'n
proto header bytes*/
uint256 internal constant PCLAIMS_SIZE = 456;
/** @dev Number of bytes of a capnproto header, the data starts after the
header */
uint256 internal constant CAPNPROTO_HEADER_SIZE = 8;
struct PClaims {
BClaimsParserLibrary.BClaims bClaims;
RCertParserLibrary.RCert rCert;
}
/**
@notice This function is for deserializing data directly from capnproto
PClaims. Use `extractInnerPClaims()` if you are extracting PClaims
from other capnproto structure (e.g Proposal).
*/
/// @param src Binary data containing a RCert serialized struct with Capn Proto headers
/// @return pClaims the PClaims struct
/// @dev Execution cost: 7725 gas
function extractPClaims(bytes memory src)
internal
pure
returns (PClaims memory pClaims)
{
uint256 _;
(pClaims, _) = extractInnerPClaims(src, CAPNPROTO_HEADER_SIZE);
}
/**
@notice This function is for deserializing the PClaims struct from an defined
location inside a binary blob. E.G Extract PClaims from inside of
other structure (E.g Proposal capnproto) or skipping the capnproto
headers. Since PClaims is composed of a BClaims struct which has not
a fixed sized depending on the txCount value, this function returns
the pClaims struct deserialized and its binary size. The
binary size must be used to adjust any other data that
is being deserialized after PClaims in case PClaims is being
deserialized from inside another struct.
*/
/// @param src Binary data containing a PClaims serialized struct without Capn Proto headers
/// @param dataOffset offset to start reading the PClaims data from inside src
/// @return pClaims the PClaims struct
/// @return pClaimsBinarySize the size of this PClaims
/// @dev Execution cost: 7026 gas
function extractInnerPClaims(bytes memory src, uint256 dataOffset)
internal
pure
returns (PClaims memory pClaims, uint256 pClaimsBinarySize)
{
require(
dataOffset + PCLAIMS_SIZE > dataOffset,
"PClaimsParserLibrary: Overflow on the dataOffset parameter"
);
uint16 pointerOffsetAdjustment = BClaimsParserLibrary.getPointerOffsetAdjustment(src, dataOffset + 4);
pClaimsBinarySize = PCLAIMS_SIZE - pointerOffsetAdjustment;
require(
src.length >= dataOffset + pClaimsBinarySize,
"PClaimsParserLibrary: Not enough bytes to extract PClaims"
);
pClaims.bClaims = BClaimsParserLibrary.extractInnerBClaims(src, dataOffset + 16, pointerOffsetAdjustment);
pClaims.rCert = RCertParserLibrary.extractInnerRCert(
src,
dataOffset + 16 + BClaimsParserLibrary.BCLAIMS_SIZE - pointerOffsetAdjustment
);
}
}
|
library PClaimsParserLibrary {
/** @dev size in bytes of a PCLAIMS cap'npro structure without the cap'n
proto header bytes*/
uint256 internal constant PCLAIMS_SIZE = 456;
/** @dev Number of bytes of a capnproto header, the data starts after the
header */
uint256 internal constant CAPNPROTO_HEADER_SIZE = 8;
struct PClaims {
BClaimsParserLibrary.BClaims bClaims;
RCertParserLibrary.RCert rCert;
}
/**
@notice This function is for deserializing data directly from capnproto
PClaims. Use `extractInnerPClaims()` if you are extracting PClaims
from other capnproto structure (e.g Proposal).
*/
/// @param src Binary data containing a RCert serialized struct with Capn Proto headers
/// @return pClaims the PClaims struct
/// @dev Execution cost: 7725 gas
function extractPClaims(bytes memory src)
internal
pure
returns (PClaims memory pClaims)
{
uint256 _;
(pClaims, _) = extractInnerPClaims(src, CAPNPROTO_HEADER_SIZE);
}
/**
@notice This function is for deserializing the PClaims struct from an defined
location inside a binary blob. E.G Extract PClaims from inside of
other structure (E.g Proposal capnproto) or skipping the capnproto
headers. Since PClaims is composed of a BClaims struct which has not
a fixed sized depending on the txCount value, this function returns
the pClaims struct deserialized and its binary size. The
binary size must be used to adjust any other data that
is being deserialized after PClaims in case PClaims is being
deserialized from inside another struct.
*/
/// @param src Binary data containing a PClaims serialized struct without Capn Proto headers
/// @param dataOffset offset to start reading the PClaims data from inside src
/// @return pClaims the PClaims struct
/// @return pClaimsBinarySize the size of this PClaims
/// @dev Execution cost: 7026 gas
function extractInnerPClaims(bytes memory src, uint256 dataOffset)
internal
pure
returns (PClaims memory pClaims, uint256 pClaimsBinarySize)
{
require(
dataOffset + PCLAIMS_SIZE > dataOffset,
"PClaimsParserLibrary: Overflow on the dataOffset parameter"
);
uint16 pointerOffsetAdjustment = BClaimsParserLibrary.getPointerOffsetAdjustment(src, dataOffset + 4);
pClaimsBinarySize = PCLAIMS_SIZE - pointerOffsetAdjustment;
require(
src.length >= dataOffset + pClaimsBinarySize,
"PClaimsParserLibrary: Not enough bytes to extract PClaims"
);
pClaims.bClaims = BClaimsParserLibrary.extractInnerBClaims(src, dataOffset + 16, pointerOffsetAdjustment);
pClaims.rCert = RCertParserLibrary.extractInnerRCert(
src,
dataOffset + 16 + BClaimsParserLibrary.BCLAIMS_SIZE - pointerOffsetAdjustment
);
}
}
| 49,090
|
21
|
// ---------------------------------- Define BlackList
|
contract BlackList is Ownable {
function getBlackListStatus(address _userAddress) external view returns (bool) {
return CRS_BLACK_LIST[_userAddress];
}
mapping (address => bool) internal CRS_BLACK_LIST;
function addBlackList (address _exceptedUser) public onlyOwner {
CRS_BLACK_LIST[_exceptedUser] = true;
emit AddedBlackList(_exceptedUser);
}
function removeBlackList (address _whiteUser) public onlyOwner {
CRS_BLACK_LIST[_whiteUser] = false;
emit RemovedBlackList(_whiteUser);
}
event AddedBlackList(address indexed _user);
event RemovedBlackList(address indexed _user);
}
|
contract BlackList is Ownable {
function getBlackListStatus(address _userAddress) external view returns (bool) {
return CRS_BLACK_LIST[_userAddress];
}
mapping (address => bool) internal CRS_BLACK_LIST;
function addBlackList (address _exceptedUser) public onlyOwner {
CRS_BLACK_LIST[_exceptedUser] = true;
emit AddedBlackList(_exceptedUser);
}
function removeBlackList (address _whiteUser) public onlyOwner {
CRS_BLACK_LIST[_whiteUser] = false;
emit RemovedBlackList(_whiteUser);
}
event AddedBlackList(address indexed _user);
event RemovedBlackList(address indexed _user);
}
| 16,377
|
50
|
// Mints tokens to a given address using a signed message during/ the curation panels early access before the actual auction starts./The minter might be different than the receiver./to Token receiver/num Number of tokens to be minted./numMax Max number of tokens that can be minted to the receiver./nonce additional signature salt./signature to prove that the receiver is allowed to get mints.
|
function mintCurationPanel(
address to,
uint16 num,
uint16 numMax,
uint128 nonce,
bytes calldata signature
|
function mintCurationPanel(
address to,
uint16 num,
uint16 numMax,
uint128 nonce,
bytes calldata signature
| 39,179
|
45
|
// Remove time lock, only locker can remove account The address want to remove time lock index Time lock index /
|
function _removeTimeLock(address account, uint8 index) internal {
require(_timeLocks[account].length > index && index >= 0, "TimeLock: invalid index");
uint256 len = _timeLocks[account].length;
if (len - 1 != index) {
// if it is not last item, swap it
_timeLocks[account][index] = _timeLocks[account][len - 1];
}
_timeLocks[account].pop();
emit TimeUnlocked(account);
}
|
function _removeTimeLock(address account, uint8 index) internal {
require(_timeLocks[account].length > index && index >= 0, "TimeLock: invalid index");
uint256 len = _timeLocks[account].length;
if (len - 1 != index) {
// if it is not last item, swap it
_timeLocks[account][index] = _timeLocks[account][len - 1];
}
_timeLocks[account].pop();
emit TimeUnlocked(account);
}
| 15,586
|
68
|
// assert ETH in pool is below pool value
|
if (poolEthBalance > poolValue) {
revert("ETH_ABOVE_AUM_ERROR");
}
|
if (poolEthBalance > poolValue) {
revert("ETH_ABOVE_AUM_ERROR");
}
| 35,930
|
154
|
// Emits a {TransferSingle} event. Requirements: - `from` cannot be the zero address.- `from` must have at least `amount` tokens of token type `id`. /
|
function _burn(
address from,
uint256 id,
uint256 amount
) internal virtual {
require(from != address(0), "ERC1155: burn from the zero address");
address operator = _msgSender();
uint256[] memory ids = _asSingletonArray(id);
uint256[] memory amounts = _asSingletonArray(amount);
|
function _burn(
address from,
uint256 id,
uint256 amount
) internal virtual {
require(from != address(0), "ERC1155: burn from the zero address");
address operator = _msgSender();
uint256[] memory ids = _asSingletonArray(id);
uint256[] memory amounts = _asSingletonArray(amount);
| 7,999
|
13
|
// Proxies don't initialize variables
|
stakedStatePeriod = 1 weeks;
activeStatePeriod = 2 weeks;
turnoverTime = 1 weeks;
validateStatePeriod = 1 weeks;
voteCommitPeriod = 1 weeks;
voteRevealPeriod = 1 weeks;
passThreshold = 100;
emit LogProjectDetails(
weiCost,
reputationCost,
|
stakedStatePeriod = 1 weeks;
activeStatePeriod = 2 weeks;
turnoverTime = 1 weeks;
validateStatePeriod = 1 weeks;
voteCommitPeriod = 1 weeks;
voteRevealPeriod = 1 weeks;
passThreshold = 100;
emit LogProjectDetails(
weiCost,
reputationCost,
| 45,282
|
494
|
// reset id prediction
|
_poolPredictionAmount[id * 3 + 1] = 0; //Reset home prediction Weight
_poolPredictionAmount[id * 3 + 2] = 0; //Reset Draw prediction Weight
_poolPredictionAmount[id * 3 + 3] = 0; //Reset Away prediction Weight
_poolPredictionBonus[id * 3 + 1] = 0; //Reset bonus
_poolPredictionBonus[id * 3 + 2] = 0; //Reset bonus
_poolPredictionBonus[id * 3 + 3] = 0; //Reset bonus
_predictionStartTime[id] = 0;
_predictionEndTime[id] = 0;
|
_poolPredictionAmount[id * 3 + 1] = 0; //Reset home prediction Weight
_poolPredictionAmount[id * 3 + 2] = 0; //Reset Draw prediction Weight
_poolPredictionAmount[id * 3 + 3] = 0; //Reset Away prediction Weight
_poolPredictionBonus[id * 3 + 1] = 0; //Reset bonus
_poolPredictionBonus[id * 3 + 2] = 0; //Reset bonus
_poolPredictionBonus[id * 3 + 3] = 0; //Reset bonus
_predictionStartTime[id] = 0;
_predictionEndTime[id] = 0;
| 26,915
|
133
|
// Indicates that the contract has been initialized. /
|
uint256 internal lastInitializedRevision = 0;
|
uint256 internal lastInitializedRevision = 0;
| 25,704
|
0
|
// Note that owners_ must be strictly increasing, in order to prevent duplicates
|
constructor(uint threshold_, address[] memory owners_, uint256[] memory requiredSignersIdxs_, uint256 requiredSignersThreshold_) public {
require(owners_.length <= 10 && threshold_ <= owners_.length && threshold_ > 0);
address lastAdd = address(0);
for (uint i = 0; i < owners_.length; i++) {
require(owners_[i] > lastAdd, "sender not in increasing order");
isOwner[owners_[i]] = true;
lastAdd = owners_[i];
}
ownersArr = owners_;
threshold = threshold_;
requiredSignersIdxs = requiredSignersIdxs_;
requiredSignersThreshold = requiredSignersThreshold_;
}
|
constructor(uint threshold_, address[] memory owners_, uint256[] memory requiredSignersIdxs_, uint256 requiredSignersThreshold_) public {
require(owners_.length <= 10 && threshold_ <= owners_.length && threshold_ > 0);
address lastAdd = address(0);
for (uint i = 0; i < owners_.length; i++) {
require(owners_[i] > lastAdd, "sender not in increasing order");
isOwner[owners_[i]] = true;
lastAdd = owners_[i];
}
ownersArr = owners_;
threshold = threshold_;
requiredSignersIdxs = requiredSignersIdxs_;
requiredSignersThreshold = requiredSignersThreshold_;
}
| 51,726
|
159
|
// The `SupplyLocalVars` struct is used internally in the `supply` function. To avoid solidity limits on the number of local variables we:1. Use a struct to hold local computation localResults2. Re-use a single variable for Error returns. (This is required with 1 because variable binding to tuple localResults requires either both to be declared inline or both to be previously declared.3. Re-use a boolean error-like return variable. /
|
struct SupplyLocalVars {
uint256 startingBalance;
uint256 newSupplyIndex;
uint256 userSupplyCurrent;
uint256 userSupplyUpdated;
uint256 newTotalSupply;
uint256 currentCash;
uint256 updatedCash;
uint256 newSupplyRateMantissa;
uint256 newBorrowIndex;
uint256 newBorrowRateMantissa;
}
|
struct SupplyLocalVars {
uint256 startingBalance;
uint256 newSupplyIndex;
uint256 userSupplyCurrent;
uint256 userSupplyUpdated;
uint256 newTotalSupply;
uint256 currentCash;
uint256 updatedCash;
uint256 newSupplyRateMantissa;
uint256 newBorrowIndex;
uint256 newBorrowRateMantissa;
}
| 20,949
|
436
|
// Adds a bytes value to the request with a given key name self The initialized request key The name of the key value The bytes value to add /
|
function addBytes(
Request memory self,
string memory key,
bytes memory value
|
function addBytes(
Request memory self,
string memory key,
bytes memory value
| 12,797
|
41
|
// Return the address of wNative relayer.
|
function getWNativeRelayer() external view returns (address);
|
function getWNativeRelayer() external view returns (address);
| 11,167
|
24
|
// Emit event
|
emit OptionTokenCreated(
optionToken,
payoutToken_,
quoteToken_,
eligible_,
expiry_,
receiver_,
call_,
strikePrice_
);
|
emit OptionTokenCreated(
optionToken,
payoutToken_,
quoteToken_,
eligible_,
expiry_,
receiver_,
call_,
strikePrice_
);
| 30,134
|
217
|
// Safeguards.
|
if (v1VaultId == 3) {
revert("Migration not allowed");
}
|
if (v1VaultId == 3) {
revert("Migration not allowed");
}
| 43,303
|
25
|
// /
|
receive() external payable {}
//Fallback Functions
/**
@notice Fallback function that allows the contract to receive Ether.
@dev This function is called when the contract receives Ether without a specific function call.
It allows the contract to accept payments.
*/
fallback() external payable {}
// External Functions
/**
* @notice Retrieves the total earnings of a video.
* @dev Retrieve the total earnings of the specified video.
* @param videoId_ The ID of the video.
* @return The total earnings of the video.
*/
function getVideoTotalEarning(
string memory videoId_
) external view override returns (uint256) {
return videos[videoId_].totalEarning;
}
|
receive() external payable {}
//Fallback Functions
/**
@notice Fallback function that allows the contract to receive Ether.
@dev This function is called when the contract receives Ether without a specific function call.
It allows the contract to accept payments.
*/
fallback() external payable {}
// External Functions
/**
* @notice Retrieves the total earnings of a video.
* @dev Retrieve the total earnings of the specified video.
* @param videoId_ The ID of the video.
* @return The total earnings of the video.
*/
function getVideoTotalEarning(
string memory videoId_
) external view override returns (uint256) {
return videos[videoId_].totalEarning;
}
| 2,789
|
1
|
// modifier to check if caller is a winner
|
modifier isWinner() {
require(IsWinner(), "Caller is not a winner");
_;
}
|
modifier isWinner() {
require(IsWinner(), "Caller is not a winner");
_;
}
| 1,337
|
124
|
// Calculate amount borrowed minus feereturn Amount minus fees /
|
function receivedAmount() public override view returns (uint256) {
return amount.sub(amount.mul(borrowerFee).div(10000));
}
|
function receivedAmount() public override view returns (uint256) {
return amount.sub(amount.mul(borrowerFee).div(10000));
}
| 40,648
|
0
|
// Interface of the BEP20 standard as defined in the EIP. /
|
interface IERC20 {
/**
* @dev Returns the amount of tokens in existence.
*/
function totalSupply() external view returns (uint256);
/**
* @dev Returns the amount of tokens owned by `account`.
*/
function balanceOf(address account) external view returns (uint256);
/**
* @dev Moves `amount` tokens from the caller's account to `recipient`.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transfer(address recipient, uint256 amount) external returns (bool);
/**
* @dev Returns the remaining number of tokens that `spender` will be
* allowed to spend on behalf of `owner` through {transferFrom}. This is
* zero by default.
*
* This value changes when {approve} or {transferFrom} are called.
*/
function allowance(address owner, address spender) external view returns (uint256);
/**
* @dev Sets `amount` as the allowance of `spender` over the caller's tokens.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* IMPORTANT: Beware that changing an allowance with this method brings the risk
* that someone may use both the old and the new allowance by unfortunate
* transaction ordering. One possible solution to mitigate this race
* condition is to first reduce the spender's allowance to 0 and set the
* desired value afterwards:
*
* Emits an {Approval} event.
*/
function approve(address spender, uint256 amount) external returns (bool);
/**
* @dev Moves `amount` tokens from `sender` to `recipient` using the
* allowance mechanism. `amount` is then deducted from the caller's
* allowance.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transferFrom(address sender, address recipient, uint256 amount) external returns (bool);
/**
* @dev Emitted when `value` tokens are moved from one account (`from`) to
* another (`to`).
*
* Note that `value` may be zero.
*/
event Transfer(address indexed from, address indexed to, uint256 value);
/**
* @dev Emitted when the allowance of a `spender` for an `owner` is set by
* a call to {approve}. `value` is the new allowance.
*/
event Approval(address indexed owner, address indexed spender, uint256 value);
}
|
interface IERC20 {
/**
* @dev Returns the amount of tokens in existence.
*/
function totalSupply() external view returns (uint256);
/**
* @dev Returns the amount of tokens owned by `account`.
*/
function balanceOf(address account) external view returns (uint256);
/**
* @dev Moves `amount` tokens from the caller's account to `recipient`.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transfer(address recipient, uint256 amount) external returns (bool);
/**
* @dev Returns the remaining number of tokens that `spender` will be
* allowed to spend on behalf of `owner` through {transferFrom}. This is
* zero by default.
*
* This value changes when {approve} or {transferFrom} are called.
*/
function allowance(address owner, address spender) external view returns (uint256);
/**
* @dev Sets `amount` as the allowance of `spender` over the caller's tokens.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* IMPORTANT: Beware that changing an allowance with this method brings the risk
* that someone may use both the old and the new allowance by unfortunate
* transaction ordering. One possible solution to mitigate this race
* condition is to first reduce the spender's allowance to 0 and set the
* desired value afterwards:
*
* Emits an {Approval} event.
*/
function approve(address spender, uint256 amount) external returns (bool);
/**
* @dev Moves `amount` tokens from `sender` to `recipient` using the
* allowance mechanism. `amount` is then deducted from the caller's
* allowance.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transferFrom(address sender, address recipient, uint256 amount) external returns (bool);
/**
* @dev Emitted when `value` tokens are moved from one account (`from`) to
* another (`to`).
*
* Note that `value` may be zero.
*/
event Transfer(address indexed from, address indexed to, uint256 value);
/**
* @dev Emitted when the allowance of a `spender` for an `owner` is set by
* a call to {approve}. `value` is the new allowance.
*/
event Approval(address indexed owner, address indexed spender, uint256 value);
}
| 5,431
|
1,213
|
// NOTE: if the liquidator has assets that need to be settled this will fail, automatic settlement is not done here due to the bytecode limit
|
liquidatorContext = TransferAssets.placeAssetsInAccount(
liquidator,
liquidatorContext,
assets
);
TransferAssets.invertNotionalAmountsInPlace(assets);
if (c.accountContext.isBitmapEnabled()) {
BitmapAssetsHandler.addMultipleifCashAssets(liquidateAccount, c.accountContext, assets);
} else {
|
liquidatorContext = TransferAssets.placeAssetsInAccount(
liquidator,
liquidatorContext,
assets
);
TransferAssets.invertNotionalAmountsInPlace(assets);
if (c.accountContext.isBitmapEnabled()) {
BitmapAssetsHandler.addMultipleifCashAssets(liquidateAccount, c.accountContext, assets);
} else {
| 11,419
|
97
|
// Non ERC20-conforming tokens are problematic; don't allow them in pools Will revert if invalid - overloaded to save space in the main contract tokens - The prospective tokens to verify /
|
function verifyTokenCompliance(address[] calldata tokens) external {
for (uint i = 0; i < tokens.length; i++) {
verifyTokenComplianceInternal(tokens[i]);
}
}
|
function verifyTokenCompliance(address[] calldata tokens) external {
for (uint i = 0; i < tokens.length; i++) {
verifyTokenComplianceInternal(tokens[i]);
}
}
| 9,202
|
0
|
// can later be changed with {transferModeratorship}./ Initializes the contract setting the deployer as the initial moderator. /
|
constructor() {
address msgSender = _msgSender();
_moderator = msgSender;
emit ModeratorTransferred(address(0), msgSender);
}
|
constructor() {
address msgSender = _msgSender();
_moderator = msgSender;
emit ModeratorTransferred(address(0), msgSender);
}
| 25,156
|
4
|
// Swaps `amountIn` of one token for as much as possible of another token/params The parameters necessary for the swap, encoded as `ExactInputSingleParams` in calldata/ return amountOut The amount of the received token
|
function exactInputSingle(ExactInputSingleParams calldata params) external payable returns (uint256 amountOut);
|
function exactInputSingle(ExactInputSingleParams calldata params) external payable returns (uint256 amountOut);
| 3,940
|
327
|
// Repay Fei debt in the Turbo Fuse Pool, unless we would repay nothing.
|
if (feiAmount != 0) require(feiTurboCToken.repayBorrow(feiAmount) == 0, "REPAY_FAILED");
|
if (feiAmount != 0) require(feiTurboCToken.repayBorrow(feiAmount) == 0, "REPAY_FAILED");
| 80,766
|
4
|
// Ownable The Ownable contract has an owner address, and provides basic authorization controlfunctions, this simplifies the implementation of "user permissions"./
|
contract Ownable {
address public owner;
event OwnershipRenounced(address indexed previousOwner);
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
constructor() public {
owner = 0x31F3b1089A2485D820D48Fe0D05798ee69806d83;
}
modifier onlyOwner() {
require(msg.sender == owner);
_;
}
function transferOwnership(address newOwner) public onlyOwner {
require(newOwner != address(0));
emit OwnershipTransferred(owner, newOwner);
owner = newOwner;
}
function renounceOwnership() public onlyOwner {
emit OwnershipRenounced(owner);
owner = address(0);
}
}
|
contract Ownable {
address public owner;
event OwnershipRenounced(address indexed previousOwner);
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
constructor() public {
owner = 0x31F3b1089A2485D820D48Fe0D05798ee69806d83;
}
modifier onlyOwner() {
require(msg.sender == owner);
_;
}
function transferOwnership(address newOwner) public onlyOwner {
require(newOwner != address(0));
emit OwnershipTransferred(owner, newOwner);
owner = newOwner;
}
function renounceOwnership() public onlyOwner {
emit OwnershipRenounced(owner);
owner = address(0);
}
}
| 82,824
|
20
|
// Override isApprovedForAll to whitelist user's OpenSea proxy accounts to enable gas-free listings. /
|
function isApprovedForAll(
address _owner,
address _operator
|
function isApprovedForAll(
address _owner,
address _operator
| 38,439
|
261
|
// Utility Function /
|
function startPresale(uint256 _startTimestamp) public onlyOwner {
setOnlyWhitelisted(true);
setAvailable(0, true);
setAvailable(1, true);
setAvailable(2, false);
setAvailable(3, false);
setAvailable(4, false);
startSaleTimer(_startTimestamp, _startTimestamp + 48 hours);
maxPresaleTime = block.timestamp + 30 days;
}
|
function startPresale(uint256 _startTimestamp) public onlyOwner {
setOnlyWhitelisted(true);
setAvailable(0, true);
setAvailable(1, true);
setAvailable(2, false);
setAvailable(3, false);
setAvailable(4, false);
startSaleTimer(_startTimestamp, _startTimestamp + 48 hours);
maxPresaleTime = block.timestamp + 30 days;
}
| 14,506
|
234
|
// Scale as rawCollateral (1 - effectiveOutstandingFee) to apply the pro-rata amount to the regular fee.
|
return rawCollateral.mul(FixedPoint.fromUnscaledUint(1).sub(effectiveOutstandingFee));
|
return rawCollateral.mul(FixedPoint.fromUnscaledUint(1).sub(effectiveOutstandingFee));
| 7,783
|
219
|
// Get the correct price for the mint for qty and person minting_count amount of tokens to calc for mint_to the address which will be minting these tokens, passed explicitly/
|
function getPrice(uint256 _count, address _to) public view returns (uint256) {
if(_count == 0) revert ValueCannotBeZero();
// short circuit function if we dont need to even calc incentive pricing
// short circuit if the current wallet mint qty is also already over cap
if(
usingEarlyMintIncentive == false ||
_numberMinted(_to) > earlyMintOwnershipCap
) {
return (PRICE * _count) + PROVIDER_FEE;
}
uint256 endingTokenQty = _numberMinted(_to) + _count;
// If qty to mint results in a final qty less than or equal to the cap then
// the entire qty is within incentive mint.
if(endingTokenQty <= earlyMintOwnershipCap) {
return (EARLY_MINT_PRICE * _count) + PROVIDER_FEE;
}
// If the current token qty is less than the incentive cap
// and the ending token qty is greater than the incentive cap
// we will be straddling the cap so there will be some amount
// that are incentive and some that are regular fee.
uint256 incentiveTokenCount = earlyMintOwnershipCap - _numberMinted(_to);
uint256 outsideIncentiveCount = endingTokenQty - earlyMintOwnershipCap;
return (EARLY_MINT_PRICE * incentiveTokenCount) + (PRICE * outsideIncentiveCount) + PROVIDER_FEE;
}
|
function getPrice(uint256 _count, address _to) public view returns (uint256) {
if(_count == 0) revert ValueCannotBeZero();
// short circuit function if we dont need to even calc incentive pricing
// short circuit if the current wallet mint qty is also already over cap
if(
usingEarlyMintIncentive == false ||
_numberMinted(_to) > earlyMintOwnershipCap
) {
return (PRICE * _count) + PROVIDER_FEE;
}
uint256 endingTokenQty = _numberMinted(_to) + _count;
// If qty to mint results in a final qty less than or equal to the cap then
// the entire qty is within incentive mint.
if(endingTokenQty <= earlyMintOwnershipCap) {
return (EARLY_MINT_PRICE * _count) + PROVIDER_FEE;
}
// If the current token qty is less than the incentive cap
// and the ending token qty is greater than the incentive cap
// we will be straddling the cap so there will be some amount
// that are incentive and some that are regular fee.
uint256 incentiveTokenCount = earlyMintOwnershipCap - _numberMinted(_to);
uint256 outsideIncentiveCount = endingTokenQty - earlyMintOwnershipCap;
return (EARLY_MINT_PRICE * incentiveTokenCount) + (PRICE * outsideIncentiveCount) + PROVIDER_FEE;
}
| 26,789
|
259
|
// burn NFT
|
marbleNFTContract.burn(_tokenId);
|
marbleNFTContract.burn(_tokenId);
| 23,215
|
59
|
// Burns a specific amount of tokens from the target address and decrements allowance from address The address which you want to send tokens from value uint256 The amount of token to be burned /
|
function burnFrom(address from, uint256 value) public {
_burnFrom(from, value);
}
|
function burnFrom(address from, uint256 value) public {
_burnFrom(from, value);
}
| 45,781
|
2
|
// The lower bound for the minimum amount of time the contract must wait before queuing a proposal
|
uint256 public constant MINIMUM_DELAY = 2 days;
|
uint256 public constant MINIMUM_DELAY = 2 days;
| 4,278
|
153
|
// mapping of addresses to mapping of allowances for an address
|
mapping (address => mapping (address => uint)) allowances;
|
mapping (address => mapping (address => uint)) allowances;
| 26,211
|
307
|
// Enable script executor with ID `_executorId`_executorId Identifier of the executor in the registry/
|
function enableScriptExecutor(uint256 _executorId)
external
authP(REGISTRY_MANAGER_ROLE, arr(_executorId))
executorExists(_executorId)
|
function enableScriptExecutor(uint256 _executorId)
external
authP(REGISTRY_MANAGER_ROLE, arr(_executorId))
executorExists(_executorId)
| 6,306
|
2
|
// Emitted when borrowing is enabled or disabled on a reserve. asset The address of the underlying asset of the reserve enabled True if borrowing is enabled, false otherwise /
|
event ReserveBorrowing(address indexed asset, bool enabled);
|
event ReserveBorrowing(address indexed asset, bool enabled);
| 31,113
|
7
|
// is set to true if we transfer tokens
|
bool private m_transfer_tokens = false;
string constant menu_faucet = "🚰 Faucet (Hangzhou only)";
uint8 constant DEFAULT_DIGITS = 6;
|
bool private m_transfer_tokens = false;
string constant menu_faucet = "🚰 Faucet (Hangzhou only)";
uint8 constant DEFAULT_DIGITS = 6;
| 4,890
|
3
|
// Checks if an object belongs to `_group` group in given context Assigning a role to the object makes it a member of a corresponding role group _objectId ID of an object that is being checked for role group membership _contextId Context in which membership should be checked _group name of the role groupreturn true if object with given ID is a member, false otherwise /
|
function isInGroup(
bytes32 _objectId,
|
function isInGroup(
bytes32 _objectId,
| 20,274
|
0
|
// optimize, see https:github.com/ethereum/EIPs/issues/1726issuecomment-472352728
|
uint256 constant internal pointsMultiplier = 2**128;
uint256 internal pointsPerShare;
mapping(address => int256) internal pointsCorrection;
mapping(address => uint256) internal withdrawnFunds;
|
uint256 constant internal pointsMultiplier = 2**128;
uint256 internal pointsPerShare;
mapping(address => int256) internal pointsCorrection;
mapping(address => uint256) internal withdrawnFunds;
| 36,140
|
5
|
// claimGov first to reset the reward
|
claimGov();
uint256 claimableETH = _balances[msg.sender].mulDivDown(ethSupply, _totalSupply);
uint256 claimablePOWAA = _balances[msg.sender].mulDivDown(powaaSupply, _totalSupply);
if (claimableETH == 0 && claimablePOWAA == 0) {
return;
}
|
claimGov();
uint256 claimableETH = _balances[msg.sender].mulDivDown(ethSupply, _totalSupply);
uint256 claimablePOWAA = _balances[msg.sender].mulDivDown(powaaSupply, _totalSupply);
if (claimableETH == 0 && claimablePOWAA == 0) {
return;
}
| 10,706
|
9
|
// Ongoing auctions for validatorId
|
mapping (uint256 => Auction) public validatorAuction;
|
mapping (uint256 => Auction) public validatorAuction;
| 8,123
|
61
|
// Closes the pool specified. _poolId The Id of the pool. /
|
function closePool(uint256 _poolId) public whenNotPaused ownsPool(_poolId) {
if (!ClosedPools[_poolId]) {
ClosedPools[_poolId] = true;
emit poolClosed(_poolId);
}
}
|
function closePool(uint256 _poolId) public whenNotPaused ownsPool(_poolId) {
if (!ClosedPools[_poolId]) {
ClosedPools[_poolId] = true;
emit poolClosed(_poolId);
}
}
| 23,078
|
43
|
// The timestamp when voting starts for a proposal/proposalId The proposal id
|
function proposalSnapshot(bytes32 proposalId) external view returns (uint256);
|
function proposalSnapshot(bytes32 proposalId) external view returns (uint256);
| 32,307
|
249
|
// Similar to EIP20 transfer, except it handles a False result from `transfer` and returns an explanatory error code rather than reverting. If caller has not called checked protocol's balance, this may revert due to insufficient cash held in this contract. If caller has checked protocol's balance prior to this call, and verified it is >= amount, this should not revert in normal conditions.Note: This wrapper safely handles non-standard ERC-20 tokens that do not return a value. /
|
function doTransferOut(address payable to, uint amount) internal returns (Error) {
EIP20NonStandardInterface token = EIP20NonStandardInterface(underlying);
bool result;
token.transfer(to, amount);
// solium-disable-next-line security/no-inline-assembly
assembly {
switch returndatasize()
case 0 { // This is a non-standard ERC-20
result := not(0) // set result to true
}
case 32 { // This is a complaint ERC-20
returndatacopy(0, 0, 32)
result := mload(0) // Set `result = returndata` of external call
}
default { // This is an excessively non-compliant ERC-20, revert.
revert(0, 0)
}
}
if (!result) {
return Error.TOKEN_TRANSFER_OUT_FAILED;
}
return Error.NO_ERROR;
}
|
function doTransferOut(address payable to, uint amount) internal returns (Error) {
EIP20NonStandardInterface token = EIP20NonStandardInterface(underlying);
bool result;
token.transfer(to, amount);
// solium-disable-next-line security/no-inline-assembly
assembly {
switch returndatasize()
case 0 { // This is a non-standard ERC-20
result := not(0) // set result to true
}
case 32 { // This is a complaint ERC-20
returndatacopy(0, 0, 32)
result := mload(0) // Set `result = returndata` of external call
}
default { // This is an excessively non-compliant ERC-20, revert.
revert(0, 0)
}
}
if (!result) {
return Error.TOKEN_TRANSFER_OUT_FAILED;
}
return Error.NO_ERROR;
}
| 75,350
|
20
|
// Balances for each account
|
mapping(address => uint256) balances;
|
mapping(address => uint256) balances;
| 24,222
|
17
|
// Performs a single exact output swap
|
function exactOutputInternal(
uint256 amountOut,
address recipient,
uint160 sqrtPriceLimitX96,
SwapCallbackData memory data
|
function exactOutputInternal(
uint256 amountOut,
address recipient,
uint160 sqrtPriceLimitX96,
SwapCallbackData memory data
| 21,764
|
83
|
// The value is stored at length-1, but we add 1 to all indexes and use 0 as a sentinel value
|
set._indexes[value] = set._values.length;
return true;
|
set._indexes[value] = set._values.length;
return true;
| 11,104
|
91
|
// assert that there is enough available liquidity to safely withdraw this amount
|
require(totalAvailableLiquidity >= redeemableUnderlyingTokens, '10');
|
require(totalAvailableLiquidity >= redeemableUnderlyingTokens, '10');
| 57,765
|
70
|
// Internal function to burn a specific tokenReverts if the token does not exist _tokenId uint256 ID of the token being burned by the msg.sender /
|
function _burn(address _owner, uint256 _tokenId) internal {
clearApproval(_owner, _tokenId);
removeTokenFrom(_owner, _tokenId);
emit Transfer(_owner, address(0), _tokenId);
}
|
function _burn(address _owner, uint256 _tokenId) internal {
clearApproval(_owner, _tokenId);
removeTokenFrom(_owner, _tokenId);
emit Transfer(_owner, address(0), _tokenId);
}
| 28,142
|
11
|
// Equivalent to `require(y == 0 || x <= type(uint256).max / y)`.
|
if mul(y, gt(x, div(not(0), y))) {
|
if mul(y, gt(x, div(not(0), y))) {
| 24,299
|
0
|
// Creator's address.
|
address public immutable creator;
|
address public immutable creator;
| 29,019
|
1
|
// emit a Transfer event with Create semantic to help with discovery.
|
emit TransferSingle(msg.sender, address(0x0), address(0x0), _type, 0);
|
emit TransferSingle(msg.sender, address(0x0), address(0x0), _type, 0);
| 7,349
|
24
|
// getFixedRatesContracts Returns the list of fixed rate contracts /
|
function getFixedRatesContracts() public view returns(address[] memory) {
return(fixedrates);
}
|
function getFixedRatesContracts() public view returns(address[] memory) {
return(fixedrates);
}
| 24,759
|
175
|
// turn transfer on to allow for whitelist form/mutlisend presale
|
if(!openForPresale){
require(canTransferBeforeTradingIsEnabled[from], "aETHER: This account cannot send tokens until trading is enabled");
}
|
if(!openForPresale){
require(canTransferBeforeTradingIsEnabled[from], "aETHER: This account cannot send tokens until trading is enabled");
}
| 24,035
|
38
|
// Fail if number signers unequal to bar. Note that requiring equality constrains the verification's runtime from Ω(bar) to Θ(bar).
|
uint numberSigners = schnorrData.getSignerIndexLength();
if (numberSigners != bar) {
return (false, _errorBarNotReached(uint8(numberSigners), bar));
}
|
uint numberSigners = schnorrData.getSignerIndexLength();
if (numberSigners != bar) {
return (false, _errorBarNotReached(uint8(numberSigners), bar));
}
| 28,274
|
53
|
// Hook that is called before any token transfer.
|
function _beforeTokenTransfer(
address from_,
address to_,
uint256 tokenId_
|
function _beforeTokenTransfer(
address from_,
address to_,
uint256 tokenId_
| 6,552
|
207
|
// set a new royalty receiver and rate, Can only be set by the `royaltyAdmin`./newReceiver the address that should receive the royalty proceeds./royaltyPer10Thousands the share of the salePrice (in 1/10000) given to the receiver.
|
function setRoyaltyParameters(address newReceiver, uint96 royaltyPer10Thousands) external {
require(msg.sender == royaltyAdmin, "NOT_AUTHORIZED");
// require(royaltyPer10Thousands <= 50, "ROYALTY_TOO_HIGH"); ?
_royalty.receiver = newReceiver;
_royalty.per10Thousands = royaltyPer10Thousands;
emit RoyaltySet(newReceiver, royaltyPer10Thousands);
}
|
function setRoyaltyParameters(address newReceiver, uint96 royaltyPer10Thousands) external {
require(msg.sender == royaltyAdmin, "NOT_AUTHORIZED");
// require(royaltyPer10Thousands <= 50, "ROYALTY_TOO_HIGH"); ?
_royalty.receiver = newReceiver;
_royalty.per10Thousands = royaltyPer10Thousands;
emit RoyaltySet(newReceiver, royaltyPer10Thousands);
}
| 67,523
|
146
|
// Returns the element stored at position `index` in the set. O(1). Note that there are no guarantees on the ordering of values inside the array, and it may change when more values are added or removed. Requirements:
|
* - `index` must be strictly less than {length}.
*/
function at(UintToAddressMap storage map, uint256 index) internal view returns (uint256, address) {
(bytes32 key, bytes32 value) = _at(map._inner, index);
return (uint256(key), address(uint256(value)));
}
|
* - `index` must be strictly less than {length}.
*/
function at(UintToAddressMap storage map, uint256 index) internal view returns (uint256, address) {
(bytes32 key, bytes32 value) = _at(map._inner, index);
return (uint256(key), address(uint256(value)));
}
| 601
|
100
|
// Store Token of Investor
|
ico_buyers_token[_address] = ico_buyers_token[_address].add(_tokens);
|
ico_buyers_token[_address] = ico_buyers_token[_address].add(_tokens);
| 22,377
|
21
|
// Make a call on a contract without throwing if the function does not exist.
|
function noThrowCall(address _contract, bytes4 _interfaceId)
internal view returns (uint256 success, uint256 result)
|
function noThrowCall(address _contract, bytes4 _interfaceId)
internal view returns (uint256 success, uint256 result)
| 26,557
|
59
|
// Variables used to randomly select accounts to distrubute tax to
|
accountList[0] = _msgSender();
numberOfAccounts = 1;
|
accountList[0] = _msgSender();
numberOfAccounts = 1;
| 72,576
|
161
|
// Internal function to reflect the fees to the contract rFee The fee to be deducted from the reflection total tFee The fee to be added to the total fees available for use /
|
function _reflectFee(uint256 rFee, uint256 tFee) private {
_maxMintableSupply -= rFee;
totalFeesCharged += tFee;
}
|
function _reflectFee(uint256 rFee, uint256 tFee) private {
_maxMintableSupply -= rFee;
totalFeesCharged += tFee;
}
| 5,286
|
216
|
// Player join the game at first time_initFishAmount _inviter
|
function joinGame (uint _initFishAmount, address payable _inviter) public payable isHuman() isValidFishAmount(_initFishAmount) {
address payable _newUser = msg.sender;
uint _value = msg.value;
require(_inviter != address(0x0) && playerBook[_inviter].status > PlayerStatus.NOT_JOINED, "No such inviter!");
require(playerBook[_newUser].status == PlayerStatus.NOT_JOINED, "Player has joined!");
playerBook[_newUser].isFirstGeneration = false;
emit LogJoinGame (_newUser, _initFishAmount, _value, _inviter, now);
uint _balance = _value.div(2);
// uint _fodderFee = _value.div(2);
// flow of paticipation
// 3. add buyer in consultant's first, add consultant to buyer's consultant list (Commission)
commission.joinGame(_newUser, _inviter);
// 1. init player data
initFishData(_newUser, _initFishAmount);
// 2. reset consultant fishbowl data (Fishbowler, playerBook[_inviter].fishbowlSize, _newUser, playerBook[_newUser].fishbowl) -> return
playerBook[_inviter].fishbowlSize = commission.inviteNewUser(_inviter, playerBook[_inviter].fishbowlSize, _newUser, playerBook[_newUser].fishbowlLevel);
playerBook[_inviter].amountToSale = playerBook[_inviter].fishbowlSize.mul(playerBook[_inviter].admissionPrice);
// 3. renew weekly data
// if (playerBook[_inviter].playerWeekRound != weekData.round)
if (playerBook[_inviter].playerWeekRound != weekRound) {
playerBook[_inviter].playerWeekRound = weekRound;
playerBook[_inviter].playerWeekCount = 0;
}
// playerBook[_inviter].playerWeekCount = playerBook[_inviter].playerWeekCount.add(1);
playerBook[_inviter].playerWeekCount = playerBook[_inviter].playerWeekCount.add(_initFishAmount);
// 4. set week bonus data and sort list
bool tempJudge = false;
int index = -1;
for(uint i = 0; i < 3; i++){
if(playerBook[_inviter].playerWeekCount > playerBook[ weekData[i] ].playerWeekCount){
index = int(i); //紀錄當前使用者大過的排名
if(tempJudge){ //當前使用者有在榜上,直接更動排名
address payable temp = weekData[i];
weekData[i] = _inviter;
weekData[i-1] = temp;
}
}
if (_inviter == weekData[i]) { //檢查當前使用者有無上榜
tempJudge = true;
}
}
if(tempJudge == false){ //當前使用者沒在榜上
for(uint i = 0; int(i) <= index; i++){
address payable temp = weekData[i];
weekData[i] = _inviter;
if(i != 0){
weekData[i-1] = temp;
}
}
}
/*
bytes32 _startID = WEEK_HEAD;
for (uint i = 0; i < 3; i++) {
bytes32 _nextID = weekPlayerNodeList[_startID]._next;
if (playerBook[_inviter].playerWeekCount <= weekPlayerNodeList[_startID].count && playerBook[_inviter].playerWeekCount > weekPlayerNodeList[_nextID].count) {
if (weekPlayerNodeList[_nextID].player == _inviter) {
weekPlayerNodeList[_nextID].count = playerBook[_inviter].playerWeekCount;
break;
}
bytes32 _insertID = keccak256(abi.encodePacked(_inviter, playerBook[_inviter].playerWeekCount));
weekPlayerNodeList[_insertID] = WeekNode(_inviter, playerBook[_inviter].playerWeekCount, _nextID);
weekPlayerNodeList[_startID]._next = _insertID;
break;
} else if (playerBook[_inviter].playerWeekCount > weekPlayerNodeList[_startID].count) {
if (weekPlayerNodeList[_startID].player == _inviter) {
weekPlayerNodeList[_startID].count = playerBook[_inviter].playerWeekCount;
break;
}
bytes32 _insertID = keccak256(abi.encodePacked(_inviter, playerBook[_inviter].playerWeekCount));
weekPlayerNodeList[_insertID] = WeekNode(_inviter, playerBook[_inviter].playerWeekCount, _startID);
WEEK_HEAD = _insertID;
break;
} else {
_startID = _nextID;
continue;
}
}*/
// 5. add buy order.
transactionSystem.addNewBuyOrder(_newUser, _initFishAmount, _balance, false);
initPriceData(_newUser, playerLastTotalCost[_newUser]);
// 5. distribute fodder fee(Commission) -> (playerbook profit setter)
// distributeCommission(_newUser, _fodderFee);
}
|
function joinGame (uint _initFishAmount, address payable _inviter) public payable isHuman() isValidFishAmount(_initFishAmount) {
address payable _newUser = msg.sender;
uint _value = msg.value;
require(_inviter != address(0x0) && playerBook[_inviter].status > PlayerStatus.NOT_JOINED, "No such inviter!");
require(playerBook[_newUser].status == PlayerStatus.NOT_JOINED, "Player has joined!");
playerBook[_newUser].isFirstGeneration = false;
emit LogJoinGame (_newUser, _initFishAmount, _value, _inviter, now);
uint _balance = _value.div(2);
// uint _fodderFee = _value.div(2);
// flow of paticipation
// 3. add buyer in consultant's first, add consultant to buyer's consultant list (Commission)
commission.joinGame(_newUser, _inviter);
// 1. init player data
initFishData(_newUser, _initFishAmount);
// 2. reset consultant fishbowl data (Fishbowler, playerBook[_inviter].fishbowlSize, _newUser, playerBook[_newUser].fishbowl) -> return
playerBook[_inviter].fishbowlSize = commission.inviteNewUser(_inviter, playerBook[_inviter].fishbowlSize, _newUser, playerBook[_newUser].fishbowlLevel);
playerBook[_inviter].amountToSale = playerBook[_inviter].fishbowlSize.mul(playerBook[_inviter].admissionPrice);
// 3. renew weekly data
// if (playerBook[_inviter].playerWeekRound != weekData.round)
if (playerBook[_inviter].playerWeekRound != weekRound) {
playerBook[_inviter].playerWeekRound = weekRound;
playerBook[_inviter].playerWeekCount = 0;
}
// playerBook[_inviter].playerWeekCount = playerBook[_inviter].playerWeekCount.add(1);
playerBook[_inviter].playerWeekCount = playerBook[_inviter].playerWeekCount.add(_initFishAmount);
// 4. set week bonus data and sort list
bool tempJudge = false;
int index = -1;
for(uint i = 0; i < 3; i++){
if(playerBook[_inviter].playerWeekCount > playerBook[ weekData[i] ].playerWeekCount){
index = int(i); //紀錄當前使用者大過的排名
if(tempJudge){ //當前使用者有在榜上,直接更動排名
address payable temp = weekData[i];
weekData[i] = _inviter;
weekData[i-1] = temp;
}
}
if (_inviter == weekData[i]) { //檢查當前使用者有無上榜
tempJudge = true;
}
}
if(tempJudge == false){ //當前使用者沒在榜上
for(uint i = 0; int(i) <= index; i++){
address payable temp = weekData[i];
weekData[i] = _inviter;
if(i != 0){
weekData[i-1] = temp;
}
}
}
/*
bytes32 _startID = WEEK_HEAD;
for (uint i = 0; i < 3; i++) {
bytes32 _nextID = weekPlayerNodeList[_startID]._next;
if (playerBook[_inviter].playerWeekCount <= weekPlayerNodeList[_startID].count && playerBook[_inviter].playerWeekCount > weekPlayerNodeList[_nextID].count) {
if (weekPlayerNodeList[_nextID].player == _inviter) {
weekPlayerNodeList[_nextID].count = playerBook[_inviter].playerWeekCount;
break;
}
bytes32 _insertID = keccak256(abi.encodePacked(_inviter, playerBook[_inviter].playerWeekCount));
weekPlayerNodeList[_insertID] = WeekNode(_inviter, playerBook[_inviter].playerWeekCount, _nextID);
weekPlayerNodeList[_startID]._next = _insertID;
break;
} else if (playerBook[_inviter].playerWeekCount > weekPlayerNodeList[_startID].count) {
if (weekPlayerNodeList[_startID].player == _inviter) {
weekPlayerNodeList[_startID].count = playerBook[_inviter].playerWeekCount;
break;
}
bytes32 _insertID = keccak256(abi.encodePacked(_inviter, playerBook[_inviter].playerWeekCount));
weekPlayerNodeList[_insertID] = WeekNode(_inviter, playerBook[_inviter].playerWeekCount, _startID);
WEEK_HEAD = _insertID;
break;
} else {
_startID = _nextID;
continue;
}
}*/
// 5. add buy order.
transactionSystem.addNewBuyOrder(_newUser, _initFishAmount, _balance, false);
initPriceData(_newUser, playerLastTotalCost[_newUser]);
// 5. distribute fodder fee(Commission) -> (playerbook profit setter)
// distributeCommission(_newUser, _fodderFee);
}
| 54,311
|
94
|
// Do something
|
} else revert("Invalid post process");
|
} else revert("Invalid post process");
| 49,284
|
6
|
// Add info to the arrays of donators and donations
|
campaign.donators.push(msg.sender);
campaign.donations.push(amount);
|
campaign.donators.push(msg.sender);
campaign.donations.push(amount);
| 24,816
|
12
|
// Returns the assetVotingWeightProvider address/ return The address of the assetVotingWeightProvider
|
function getAssetVotingWeightProvider() external view returns(IAssetVotingWeightProvider) {
return assetVotingWeightProvider;
}
|
function getAssetVotingWeightProvider() external view returns(IAssetVotingWeightProvider) {
return assetVotingWeightProvider;
}
| 17,388
|
10
|
// @inheritdoc IBasicMintModule
|
function configuration(address _contract) external view returns (BasicMintConfiguration memory) {
return _configurations[_contract];
}
|
function configuration(address _contract) external view returns (BasicMintConfiguration memory) {
return _configurations[_contract];
}
| 9,781
|
67
|
// 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 virtual returns (bool) {
_approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, "ERC20: decreased allowance below zero"));
return true;
}
|
* 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 virtual returns (bool) {
_approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, "ERC20: decreased allowance below zero"));
return true;
}
| 12,174
|
78
|
// Checks if the keep is currently active./Throws an error if called when the keep has been already closed.
|
modifier onlyWhenActive() {
require(isActive(), "Keep is not active");
_;
}
|
modifier onlyWhenActive() {
require(isActive(), "Keep is not active");
_;
}
| 15,687
|
36
|
// /
|
using SafeMath for *;
using NameFilter for string;
|
using SafeMath for *;
using NameFilter for string;
| 31,845
|
830
|
// Calculates: f(fCash) / f'(fCash)/ f(fCash) = cashAmountexchangeRatefee + fCash/ (cashAmountfee)(totalfCash + totalCash)/ f'(fCash) = 1 - ------------------------------------------------------/ rateScalar(totalfCash - fCash)(totalCash + fCash)
|
function _calculateDelta(
int256 cashAmount,
int256 totalfCash,
int256 totalCashUnderlying,
int256 rateScalar,
int256 fCashGuess,
int256 exchangeRate,
int256 feeRate
|
function _calculateDelta(
int256 cashAmount,
int256 totalfCash,
int256 totalCashUnderlying,
int256 rateScalar,
int256 fCashGuess,
int256 exchangeRate,
int256 feeRate
| 16,238
|
0
|
// JSONS
|
string private _prerevealMetaURI = "https://gateway.pinata.cloud/ipfs/QmSX9UEjufVvifmszeUJENiCtMLFq8wA7jGhTJFdxeCACU/";
string private _revealedMetaURI = "https://gateway.pinata.cloud/ipfs/QmRA71NveXF5EFUSds873WqxkVuT8HvvATgz65ev3ea9d5/";
string private _nightmareMetaURI = "https://gateway.pinata.cloud/ipfs/QmbpWLqDtN3sdFtev4TkWca3tasGmAHgJkpXA21GBkLDke/";
|
string private _prerevealMetaURI = "https://gateway.pinata.cloud/ipfs/QmSX9UEjufVvifmszeUJENiCtMLFq8wA7jGhTJFdxeCACU/";
string private _revealedMetaURI = "https://gateway.pinata.cloud/ipfs/QmRA71NveXF5EFUSds873WqxkVuT8HvvATgz65ev3ea9d5/";
string private _nightmareMetaURI = "https://gateway.pinata.cloud/ipfs/QmbpWLqDtN3sdFtev4TkWca3tasGmAHgJkpXA21GBkLDke/";
| 19,819
|
51
|
// Set a metadata string, expected to be JSON, containing things like arbitrator TOS address
|
function setMetaData(string calldata _metadata)
external
onlyOwner
|
function setMetaData(string calldata _metadata)
external
onlyOwner
| 21,755
|
2
|
// If you sell one (1) token, how much of another do you get? _sold_token_contract Contract of the token we simulate sell. _received_token_contract Contract of the token we simulate receive.return The amount of token we expect in return for a single sold token. /
|
function getSellOneTokenForAnotherRate(
address _sold_token_contract,
address _received_token_contract
|
function getSellOneTokenForAnotherRate(
address _sold_token_contract,
address _received_token_contract
| 12,952
|
308
|
// Constructs a new controller./Creates a new LootBox instance and an associated minimal proxy.
|
constructor () public {
lootBoxInstance = new LootBox();
lootBoxInstance.initialize();
lootBoxBytecode = MinimalProxyLibrary.minimalProxy(address(lootBoxInstance));
}
|
constructor () public {
lootBoxInstance = new LootBox();
lootBoxInstance.initialize();
lootBoxBytecode = MinimalProxyLibrary.minimalProxy(address(lootBoxInstance));
}
| 82,652
|
41
|
// 7 - time of last state change
|
uint stateTime;
|
uint stateTime;
| 62,109
|
7
|
// Trigger an event
|
emit IdeaUploaded(ideaCount, _ideaHash, _title, msg.sender);
|
emit IdeaUploaded(ideaCount, _ideaHash, _title, msg.sender);
| 50,373
|
4
|
// QSD C.g
|
uint256 private constant GOVERNANCE_PERIOD = 9; // 9 epochs
uint256 private constant GOVERNANCE_EXPIRATION = 2; // 2 + 1 epochs
uint256 private constant GOVERNANCE_QUORUM = 33e16; // 33%
uint256 private constant GOVERNANCE_PROPOSAL_THRESHOLD = 9e15; // 0.5%
uint256 private constant GOVERNANCE_SUPER_MAJORITY = 66e16; // 66%
uint256 private constant GOVERNANCE_EMERGENCY_DELAY = 6; // 6 epochs
|
uint256 private constant GOVERNANCE_PERIOD = 9; // 9 epochs
uint256 private constant GOVERNANCE_EXPIRATION = 2; // 2 + 1 epochs
uint256 private constant GOVERNANCE_QUORUM = 33e16; // 33%
uint256 private constant GOVERNANCE_PROPOSAL_THRESHOLD = 9e15; // 0.5%
uint256 private constant GOVERNANCE_SUPER_MAJORITY = 66e16; // 66%
uint256 private constant GOVERNANCE_EMERGENCY_DELAY = 6; // 6 epochs
| 33,969
|
70
|
// Determine size of whitelist first
|
uint activeCount = 0;
for (uint i = 0; i < whitelistIndices.length; i++) {
if (whitelist[whitelistIndices[i]] == Status.In) {
activeCount++;
}
|
uint activeCount = 0;
for (uint i = 0; i < whitelistIndices.length; i++) {
if (whitelist[whitelistIndices[i]] == Status.In) {
activeCount++;
}
| 46,162
|
284
|
// next sale to receive remaining tokens after this one finishes
|
address public m_nextSale;
|
address public m_nextSale;
| 43,245
|
30
|
// transfering Amount to Bidder
|
require(
IERC20(Bids[_NFTid][_bidId].ERC20Address).transferFrom(
msg.sender,
Bids[_NFTid][_bidId].bidderAddress,
Bids[_NFTid][_bidId].Amount + percentageAmount
),
"unable to transfer to bidder Address"
);
NFTdetails[_NFTid].repaid = true;
|
require(
IERC20(Bids[_NFTid][_bidId].ERC20Address).transferFrom(
msg.sender,
Bids[_NFTid][_bidId].bidderAddress,
Bids[_NFTid][_bidId].Amount + percentageAmount
),
"unable to transfer to bidder Address"
);
NFTdetails[_NFTid].repaid = true;
| 32,351
|
84
|
// Get the Pollen token (proxy) contract address return The Pollen contract address/
|
function getPollenAddress() external pure returns(address);
|
function getPollenAddress() external pure returns(address);
| 47,810
|
1
|
// Gets the amount of Swipe locked in the contract
|
uint256 totalSwipe = swipe.balanceOf(address(this));
|
uint256 totalSwipe = swipe.balanceOf(address(this));
| 56,329
|
37
|
// validate input
|
require(getConnectorPurchaseEnabled(converter, fromToken));
|
require(getConnectorPurchaseEnabled(converter, fromToken));
| 50,159
|
20
|
// solium-disable-next-line
|
_timestamps[from] = uint40(block.timestamp);
|
_timestamps[from] = uint40(block.timestamp);
| 17,224
|
3
|
// Handle non-overflow cases, 256 by 256 division
|
if (prod1 == 0) {
require(denominator > 0);
assembly {
result := div(prod0, denominator)
}
|
if (prod1 == 0) {
require(denominator > 0);
assembly {
result := div(prod0, denominator)
}
| 17,422
|
19
|
// burn tokens while tipping
|
function _tipUser(address _user,uint _amount) internal validUser(msg.sender) validUser(_user) returns(bool){
require(msg.sender != _user, "can't tip yourself!");
uint toSend=_amount-((burnFee * _amount) / 100);
uint toTreasury=_amount-toSend;
userIndex[userProf[msg.sender]].totalTips+=_amount;
require(inkToken.transferFrom(msg.sender, treasury, toTreasury));
require(inkToken.transferFrom(msg.sender, _user, toSend));
emit Tipped(msg.sender, _user, _amount);
return true;
}
|
function _tipUser(address _user,uint _amount) internal validUser(msg.sender) validUser(_user) returns(bool){
require(msg.sender != _user, "can't tip yourself!");
uint toSend=_amount-((burnFee * _amount) / 100);
uint toTreasury=_amount-toSend;
userIndex[userProf[msg.sender]].totalTips+=_amount;
require(inkToken.transferFrom(msg.sender, treasury, toTreasury));
require(inkToken.transferFrom(msg.sender, _user, toSend));
emit Tipped(msg.sender, _user, _amount);
return true;
}
| 16,666
|
51
|
// Events /
|
event TokenRegistered(address addr, string symbol);
event TokenUnregistered(address addr, string symbol);
|
event TokenRegistered(address addr, string symbol);
event TokenUnregistered(address addr, string symbol);
| 332
|
176
|
// Exclude marketing from fee and rewards
|
_isExcludedFromFee[marketingAddress] = true;
_exclude(address(marketingAddress));
_unlimitedSender[marketingAddress] = true;
_unlimitedRecipient[marketingAddress] = true;
|
_isExcludedFromFee[marketingAddress] = true;
_exclude(address(marketingAddress));
_unlimitedSender[marketingAddress] = true;
_unlimitedRecipient[marketingAddress] = true;
| 37,840
|
38
|
// Reduce RETH-A Liquidation Ratio by 20% from 170% to 150%
|
DssExecLib.setIlkLiquidationRatio("RETH-A", 150_00);
|
DssExecLib.setIlkLiquidationRatio("RETH-A", 150_00);
| 24,599
|
96
|
// Buys the tokens for the specified tier and for the next one /amount The amount of ether paid to buy the tokens /tokensThisTier The limit of tokens of that tier /tierSelected The tier selected /_rate The rate used for that `tierSelected` /uint The total amount of tokens bought combining the tier prices
|
function calculateExcessTokens(
uint256 amount,
uint256 tokensThisTier,
uint256 tierSelected,
uint256 _rate
|
function calculateExcessTokens(
uint256 amount,
uint256 tokensThisTier,
uint256 tierSelected,
uint256 _rate
| 42,595
|
189
|
// set up player account
|
pIDxAddr_[msg.sender] = pID_;
plyr_[pID_].addr = msg.sender;
|
pIDxAddr_[msg.sender] = pID_;
plyr_[pID_].addr = msg.sender;
| 35,693
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.