comment stringlengths 11 2.99k | function_code stringlengths 165 3.15k | version stringclasses 80
values |
|---|---|---|
/// @dev Collects tokens and ether owned by this module to a controlled address.
/// @param tokens The list of tokens and ether to collect. | function collectTokens(address[] calldata tokens)
external
nonReentrant
{
address to = controller.collectTo();
for (uint i = 0; i < tokens.length; i++) {
address token = tokens[i];
if (token == address(0)) {
uint amount = address(this... | 0.6.6 |
/// @dev Returns a read-only array with the addresses stored in the call data
/// at the specified function parameter index.
/// Example: function bar(address[] signers, uint value);
/// To extact `signers` use parameterIdx := 0
/// Example: function foo(address wallet, address[] signers, a... | function extractAddressesFromCallData(
bytes memory data,
uint parameterIdx
)
internal
pure
returns (address[] memory addresses)
{
// Find the offset of the function parameter in the call data
uint dataOffset = data.toUint(4 + 32 * parameterI... | 0.6.6 |
/// @dev Save the meta-transaction to history.
/// This method must throw if the transaction is not unique or the nonce is invalid.
/// @param wallet The target wallet.
/// @param nonce The nonce
/// @param metaTxHash The signed hash of the transaction | function saveExecutedMetaTx(
address wallet,
uint nonce,
bytes32 metaTxHash
)
private
{
if (nonce == 0) {
require(!wallets[wallet].metaTxHash[metaTxHash], "INVALID_HASH");
wallets[wallet].metaTxHash[metaTxHash] = true;
} el... | 0.6.6 |
// @dev Adds to the list of open auctions and fires the
// AuctionCreated event.
// @param _cutieId The token ID is to be put on auction.
// @param _auction To add an auction.
// @param _fee Amount of money to feature auction | function _addAuction(uint40 _cutieId, Auction _auction) internal
{
// Require that all auctions have a duration of
// at least one minute. (Keeps our math from getting hairy!)
require(_auction.duration >= 1 minutes);
cutieIdToAuction[_cutieId] = _auction;
em... | 0.4.21 |
// @dev Calculates the price and transfers winnings.
// Does not transfer token ownership. | function _bid(uint40 _cutieId, uint128 _bidAmount)
internal
returns (uint128)
{
// Get a reference to the auction struct
Auction storage auction = cutieIdToAuction[_cutieId];
require(_isOnAuction(auction));
// Check that bid > current price
uint128... | 0.4.21 |
// @dev calculate current price of auction.
// When testing, make this function public and turn on
// `Current price calculation` test suite. | function _computeCurrentPrice(
uint128 _startPrice,
uint128 _endPrice,
uint40 _duration,
uint40 _secondsPassed
)
internal
pure
returns (uint128)
{
if (_secondsPassed >= _duration) {
return _endPrice;
} else {
... | 0.4.21 |
// @dev return current price of token. | function _currentPrice(Auction storage _auction)
internal
view
returns (uint128)
{
uint40 secondsPassed = 0;
uint40 timeNow = uint40(now);
if (timeNow > _auction.startedAt) {
secondsPassed = timeNow - _auction.startedAt;
}
ret... | 0.4.21 |
// @dev create and begin new auction. | function createAuction(uint40 _cutieId, uint128 _startPrice, uint128 _endPrice, uint40 _duration, address _seller)
public whenNotPaused payable
{
require(_isOwner(msg.sender, _cutieId));
_escrow(msg.sender, _cutieId);
Auction memory auction = Auction(
_startPrice,
... | 0.4.21 |
// @dev Returns auction info for a token on auction.
// @param _cutieId - ID of token on auction. | function getAuctionInfo(uint40 _cutieId)
public
view
returns
(
address seller,
uint128 startPrice,
uint128 endPrice,
uint40 duration,
uint40 startedAt,
uint128 featuringFee
) {
Auction storage auction = cutieIdToAuction[... | 0.4.21 |
// @dev create and start a new auction
// @param _cutieId - ID of cutie to auction, sender must be owner.
// @param _startPrice - Price of item (in wei) at the beginning of auction.
// @param _endPrice - Price of item (in wei) at the end of auction.
// @param _duration - Length of auction (in seconds).
// @param _selle... | function createAuction(
uint40 _cutieId,
uint128 _startPrice,
uint128 _endPrice,
uint40 _duration,
address _seller
)
public
payable
{
require(msg.sender == address(coreContract));
_escrow(_seller, _cutieId);
Auction memo... | 0.4.21 |
/**
* @notice Add a token ID to the list of a given address
* @dev Throws if the receiver address has hit ownership limit or the PixelCon already has an owner
* @param _to Address representing the new owner of the given token ID
* @param _tokenId ID of the token to be added to the tokens list of the giv... | function addTokenTo(address _to, uint256 _tokenId) internal
{
uint64[] storage ownedList = ownedTokens[_to];
TokenLookup storage lookupData = tokenLookup[_tokenId];
require(ownedList.length < uint256(2 ** 32) - 1, "Max number of PixelCons per owner has been reached");
require(lookupData.owner == address(0... | 0.4.24 |
/**
* @notice see IMedia
*/ | function mintWithSig(
address creator,
MediaData memory data,
IMarket.BidShares memory bidShares,
EIP712Signature memory sig
) public override nonReentrant {
require(
sig.deadline == 0 || sig.deadline >= block.timestamp,
"Media: mintWithSig exp... | 0.6.12 |
/**
* @notice See IMedia
* @dev This method is loosely based on the permit for ERC-20 tokens in EIP-2612, but modified
* for ERC-721.
*/ | function permit(
address spender,
uint256 tokenId,
EIP712Signature memory sig
) public override nonReentrant onlyExistingToken(tokenId) {
require(
sig.deadline == 0 || sig.deadline >= block.timestamp,
"Media: Permit expired"
);
require... | 0.6.12 |
/**
* @notice Creates a new token for `creator`. Its token ID will be automatically
* assigned (and available on the emitted {IERC721-Transfer} event), and the token
* URI autogenerated based on the base URI passed at construction.
*
* See {ERC721-_safeMint}.
*
* On mint, also set the sha256 hashes of the... | function _mintForCreator(
address creator,
MediaData memory data,
IMarket.BidShares memory bidShares
) internal onlyValidURI(data.tokenURI) onlyValidURI(data.metadataURI) {
require(data.contentHash != 0, "Media: content hash must be non-zero");
require(
_co... | 0.6.12 |
/**
* @dev Calculates EIP712 DOMAIN_SEPARATOR based on the current contract and chain ID.
*/ | function _calculateDomainSeparator() internal view returns (bytes32) {
uint256 chainID;
/* solium-disable-next-line */
assembly {
chainID := chainid()
}
return
keccak256(
abi.encode(
keccak256(
... | 0.6.12 |
/**
* @dev Withdraw ERC-20 token of this contract
*/ | function withdrawToken(address tokenAddress) external onlyOwner contractActive{
require(tokenAddress != address(0), "Contract address is zero address");
require(tokenAddress != address(this), "Can not transfer self token");
IERC20Token tokenContract = IERC20Token(tokenAddress);
... | 0.7.4 |
// Withdraw LP tokens or claim rewrads if amount is 0 | function withdraw(uint256 _pid, uint256 _amount) public {
PoolInfo storage pool = poolInfo[_pid];
UserInfo storage user = userInfo[_pid][msg.sender];
require(user.amount >= _amount, "withdraw: not good");
updatePool(_pid);
uint256 pending = user.amount.mul(pool.accSheeshaPer... | 0.7.6 |
/**
* @dev Internal function to remove a token ID from the list of a given address
* Note that this function is left internal to make ERC721Enumerable possible, but is not
* intended to be called by custom derived contracts: in particular, it emits no Transfer event,
* and doesn't clear approvals.
* @param fr... | function _removeTokenFrom(address from, uint256 tokenId) internal {
require(ownerOf(tokenId) == from);
_ownedTokensCount[from] = _ownedTokensCount[from].sub(1);
_tokenOwner[tokenId] = address(0);
// To prevent a gap in the array, we store the last token in the index of the token to delete, and
... | 0.4.24 |
///
/// Giveaway
/// | function giveaway(address _to, uint256 _amount) external onlyOwner {
require(tokenCount + _amount <= supply, "Not enough supply");
require(_amount < giveawaySupply, "Giving away too many NFTs");
require(_amount > 0, "Amount must be greater than zero");
_mintPrivate(_to, _amount);
} | 0.8.4 |
/**
* @dev burn : To decrease total supply of tokens
*/ | function burn(uint256 _amount) public onlyOwner returns (bool) {
require(_amount >= 0, "Invalid amount");
require(_amount <= balances[msg.sender], "Insufficient Balance");
_totalSupply = safeSub(_totalSupply, _amount);
balances[owner] = safeSub(balances[owner], _amount);
emi... | 0.6.0 |
// deploy a staking reward contract for the staking token, and store the reward amount
// the reward will be distributed to the staking reward contract no sooner than the genesis | function deploy(address stakingToken, address collectionAddress, uint rewardAmount) public onlyOwner {
StakingRewardsInfo storage info = stakingRewardsInfoByStakingToken[stakingToken];
require(info.stakingRewards == address(0), 'StakingRewardsFactory::deploy: already deployed');
info.stakin... | 0.5.17 |
// notify reward amount for an individual staking token.
// this is a fallback in case the notifyRewardAmounts costs too much gas to call for all contracts | function notifyRewardAmount(address stakingToken) public {
require(block.timestamp >= stakingRewardsGenesis, 'StakingRewardsFactory::notifyRewardAmount: not ready');
StakingRewardsInfo storage info = stakingRewardsInfoByStakingToken[stakingToken];
require(info.stakingRewards != address(0), ... | 0.5.17 |
// calculate price based on pair reserves | function getUSDValue() public view returns(uint256)
{
IUniswapV2Pair pair = IUniswapV2Pair(usdPair);
if(pair.token0() != WETH){
(uint Res0, uint Res1,) = pair.getReserves();
// decimals
uint res1 = Res1 * 1 ether;
return( res1 / Res0 ); // return amount of token0 neede... | 0.6.12 |
/**
* @dev Creates an upgradeable proxy
* @param version representing the first version to be set for the proxy
* @return address of the new proxy created
*/ | function createProxy(
uint256 version,
address _primaryOwner,
address _systemAddress,
address _authorityAddress,
address _registryaddress
) public onlyOneOfOnwer() returns (address) {
require(proxyAddress == address(0), "ERR_PROXY_ALREADY_CREATED");
... | 0.5.9 |
// ============ DVM Functions (create & add liquidity) ============ | function createDODOVendingMachine(
address baseToken,
address quoteToken,
uint256 baseInAmount,
uint256 quoteInAmount,
uint256 lpFeeRate,
uint256 i,
uint256 k,
bool isOpenTWAP,
uint256 deadLine
)
external
override
... | 0.6.9 |
/*
1 - if the funding of the project Failed, allows investors to claim their locked ether back.
2 - if the Investor votes NO to a Development Milestone Completion Proposal, where the majority
also votes NO allows investors to claim their locked ether back.
3 - project owner misses to set the time for a Developm... | function canCashBack() public view requireInitialised returns (bool) {
// case 1
if(checkFundingStateFailed()) {
return true;
}
// case 2
if(checkMilestoneStateInvestorVotedNoVotingEndedNo()) {
return true;
}
// case 3
i... | 0.4.17 |
/**
* Sunrise
**/ | function sunrise() external {
require(!paused(), "Season: Paused.");
require(seasonTime() > season(), "Season: Still current Season.");
(
Decimal.D256 memory beanPrice,
Decimal.D256 memory usdcPrice
) = IOracle(address(this)).capture();
uint256 price = be... | 0.7.6 |
/**
* @notice Initialize tap
* @param _controller The address of the controller contract
* @param _reserve The address of the reserve [pool] contract
* @param _beneficiary The address of the beneficiary [to whom funds are to be withdrawn]
* @param _batchBlocks... | function initialize(
IAragonFundraisingController _controller,
Vault _reserve,
address _beneficiary,
uint256 _batchBlocks,
uint256 _maximumTapRateIncreasePct,
uint256 ... | 0.4.24 |
/**
* @dev Transfers tokens from sender to the contract.
* User calls this function when he wants to transfer tokens to another blockchain.
* @notice User must have approved tokenInAmount of tokenIn
*/ | function swapTokensToOtherBlockchain(swapToParams memory params)
external
payable
whenNotPaused
TransferTo(params, msg.value)
{
IERC20 tokenIn = IERC20(params.firstPath[0]);
if (params.firstPath.length > 1) {
require(
tokenIn.transferFrom(
... | 0.8.4 |
/**
* @dev Transfers tokens to end user in current blockchain
*/ | function swapTokensToUserWithFee(swapFromParams memory params)
external
onlyRelayer
whenNotPaused
TransferFrom(params)
{
uint256 amountWithoutFee = FullMath.mulDiv(
params.amountWithFee,
1e6 - feeAmountOfBlockchain[numOfThisBlockchain],
1e6... | 0.8.4 |
/**
* @dev Swaps RBC from pool to initially spent by user tokens and transfers him
* @notice There is used the same structure as in other similar functions but amountOutMin should be
* equal to the amount of tokens initially spent by user (we are refunding them), AmountWithFee should
* be equal to the amount of RBC... | function refundTokensToUser(swapFromParams memory params)
external
onlyRelayer
whenNotPaused
TransferFrom(params)
{
IERC20 RBCToken = IERC20(params.path[0]);
if (params.path.length == 1) {
require(
RBCToken.transferFrom(
... | 0.8.4 |
/**
* @dev Registers another blockchain for availability to swap
* @param numOfOtherBlockchain number of blockchain
*/ | function addOtherBlockchain(uint128 numOfOtherBlockchain)
external
onlyOwner
{
require(
numOfOtherBlockchain != numOfThisBlockchain,
"swapContract: Cannot add this blockchain to array of other blockchains"
);
require(
!existingOtherBlockcha... | 0.8.4 |
/**
* @dev Change existing blockchain id
* @param oldNumOfOtherBlockchain number of existing blockchain
* @param newNumOfOtherBlockchain number of new blockchain
*/ | function changeOtherBlockchain(
uint128 oldNumOfOtherBlockchain,
uint128 newNumOfOtherBlockchain
) external onlyOwner {
require(
oldNumOfOtherBlockchain != newNumOfOtherBlockchain,
"swapContract: Cannot change blockchains with same number"
);
require(
... | 0.8.4 |
/**
* @dev Transfers permissions of contract ownership.
* Will setup new owner and one manager on contract.
* Main purpose of this function is to transfer ownership from deployer account ot real owner
* @param newOwner Address of new owner
* @param newManager Address of new manager
*/ | function transferOwnerAndSetManager(address newOwner, address newManager)
external
onlyOwner
{
require(
newOwner != _msgSender(),
"swapContract: New owner must be different than current"
);
require(
newOwner != address(0x0),
"sw... | 0.8.4 |
/**
* @dev Function changes values associated with certain originalTxHash
* @param originalTxHash Transaction hash to change
* @param statusCode Associated status: 0-Not processed, 1-Processed, 2-Reverted
* @param hashedParams Hashed params with which the initial transaction was executed
*/ | function changeTxStatus(
bytes32 originalTxHash,
uint256 statusCode,
bytes32 hashedParams
) external onlyRelayer {
require(
statusCode != 0,
"swapContract: you cannot set the statusCode to 0"
);
require(
processedTransactions[origin... | 0.8.4 |
//Deletes from mapping (bytes32 => array[]) at index _index | function deleteArrayAddress(bytes32 _key, uint256 _index) internal {
address[] storage array = addressArrayStorage[_key];
require(_index < array.length, "Index should less than length of the array");
array[_index] = array[array.length - 1];
array.length = array.length - 1;
} | 0.4.24 |
//Deletes from mapping (bytes32 => bytes32[]) at index _index | function deleteArrayBytes32(bytes32 _key, uint256 _index) internal {
bytes32[] storage array = bytes32ArrayStorage[_key];
require(_index < array.length, "Index should less than length of the array");
array[_index] = array[array.length - 1];
array.length = array.length - 1;
} | 0.4.24 |
/**
* @dev Upgrades the implementation address
* @param _newVersion representing the version name of the new implementation to be set
* @param _newImplementation representing the address of the new implementation to be set
*/ | function _upgradeTo(string _newVersion, address _newImplementation) internal {
require(
__implementation != _newImplementation && _newImplementation != address(0),
"Old address is not allowed and implementation address should not be 0x"
);
require(AddressUtils.isCont... | 0.4.24 |
/**
* @dev Converts a `uint256` to a `string`.
* via OraclizeAPI - MIT licence
* https://github.com/oraclize/ethereum-api/blob/b42146b063c7d6ee1358846c198246239e9360e8/oraclizeAPI_0.4.25.sol
*/ | function fromUint(uint256 value) internal pure returns (string memory) {
if (value == 0) {
return "0";
}
uint256 temp = value;
uint256 digits;
while (temp != 0) {
digits++;
temp /= 10;
}
bytes memory buffer = new bytes(digits);
... | 0.8.4 |
/**
* Index Of
*
* Locates and returns the position of a character within a string starting
* from a defined offset
*
* @param _base When being used for a data type this is the extended object
* otherwise this is the string acting as the haystack to be
* searched
* @param _value The n... | function indexOf(
bytes memory _base,
string memory _value,
uint256 _offset
) internal pure returns (int256) {
bytes memory _valueBytes = bytes(_value);
assert(_valueBytes.length == 1);
for (uint256 i = _offset; i < _base.length; i++) {
if (_base[i] == _... | 0.8.4 |
// Season of Plenty | function rewardEther(uint256 amount) internal {
uint256 base;
if (s.sop.base == 0) {
base = amount.mul(BIG_BASE);
s.sop.base = BURN_BASE;
}
else base = amount.mul(s.sop.base).div(s.sop.weth);
// Award ether to claimed stalk holders
uint256 basePer... | 0.7.6 |
/** @param _owner The owner whose ships tokens we are interested in.
* @dev This method MUST NEVER be called by smart contract code. First, it's fairly
* expensive (it walks the entire Collectibles owners array looking for NFT belonging to owner)
*/ | function tokensOfOwner(address _owner) external view returns(uint256[] ownerTokens) {
uint256 tokenCount = balanceOf(_owner);
if (tokenCount == 0) {
// Return an empty array
return new uint256[](0);
} else {
uint256[] memory result = new uint256[](toke... | 0.4.24 |
/**
* Shed
**/ | function sqrt(uint y) internal pure returns (uint z) {
if (y > 3) {
z = y;
uint x = y / 2 + 1;
while (x < z) {
z = x;
x = (y / x + x) / 2;
}
} else if (y != 0) {
z = 1;
}
} | 0.7.6 |
/**
* @notice Initialize presale
* @param _controller The address of the controller contract
* @param _tokenManager The address of the [bonded] token manager contract
* @param _reserve The address of the reserve [pool] contract
* @param _beneficiary The ... | function initialize(
IAragonFundraisingController _controller,
TokenManager _tokenManager,
address _reserve,
address _beneficiary,
address _contributionToken,
uint256 ... | 0.4.24 |
/**
* @notice Contribute to the presale up to `@tokenAmount(self.contributionToken(): address, _value)`
* @param _contributor The address of the contributor
* @param _value The amount of contribution token to be spent
*/ | function contribute(address _contributor, uint256 _value) external payable nonReentrant auth(CONTRIBUTE_ROLE) {
require(state() == State.Funding, ERROR_INVALID_STATE);
require(_value != 0, ERROR_INVALID_CONTRIBUTE_VALUE);
if (contributionToken == ETH) {
require(msg... | 0.4.24 |
/**
* @notice Returns the current state of that presale
*/ | function state() public view isInitialized returns (State) {
if (openDate == 0 || openDate > getTimestamp64()) {
return State.Pending;
}
if (totalRaised >= goal) {
if (isClosed) {
return State.Closed;
} else {
return S... | 0.4.24 |
/**
* Liquidity
**/ | function addLiquidity(AddLiquidity calldata al) internal returns (uint256, uint256) {
(uint256 beansDeposited, uint256 ethDeposited, uint256 liquidity) = _addLiquidity(
msg.value,
al.beanAmount,
al.minEthAmount,
al.minBeanAmount
);
(bool success,) ... | 0.7.6 |
/// @dev internal function to update MLB player id | function _updateMLBPlayerId(uint256 _tokenId, uint256 _newMLBPlayerId) internal {
// Get Token Obj
NFT storage lsnftObj = allNFTs[_tokenId];
lsnftObj.mlbPlayerId = _newMLBPlayerId;
// Update Token Data with new updated attributes
allNFTs[_tokenId] = lsnftObj;
... | 0.4.24 |
// Split the minting blob into token_id and blueprint portions
// {token_id}:{blueprint} | function split(bytes calldata blob)
internal
pure
returns (uint256, bytes memory)
{
int256 index = Bytes.indexOf(blob, ":", 0);
require(index >= 0, "Separator must exist");
// Trim the { and } from the parameters
uint256 tokenID = Bytes.toUint(blob[1:uint256(i... | 0.8.4 |
/// @dev internal function to update asset earnedBy value for an asset/token | function _updateEarnedBy(uint256 _tokenId, uint256 _earnedBy) internal {
// Get Token Obj
NFT storage lsnftObj = allNFTs[_tokenId];
lsnftObj.earnedBy = _earnedBy;
// Update Token Data with new updated attributes
allNFTs[_tokenId] = lsnftObj;
emit Ass... | 0.4.24 |
/**
* Soil
**/ | function increaseSoil(uint256 amount) internal returns (int256) {
uint256 maxTotalSoil = C.getMaxSoilRatioCap().mul(bean().totalSupply()).div(1e18);
uint256 minTotalSoil = C.getMinSoilRatioCap().mul(bean().totalSupply()).div(1e18);
if (s.f.soil > maxTotalSoil) {
amount = s.f.soil.sub... | 0.7.6 |
/**
* @dev Generates promo collectibles. Only callable by Game Master, with isAttached as 0.
* @notice The generation of an asset if limited via the generationSeasonController
* @param _teamId teamId of the asset/token/collectible
* @param _posId position of the asset/token/collectible
* ... | function createPromoCollectible(
uint8 _teamId,
uint8 _posId,
uint256 _attributes,
address _owner,
uint256 _gameId,
uint256 _playerOverrideId,
uint256 _mlbPlayerId)
external
canCreate
whenNotPaused
returns (uint256)
... | 0.4.24 |
/**
* Public
**/ | function claim(Claim calldata c) public payable {
if (c.beanWithdrawals.length > 0) _claimBeans(c.beanWithdrawals);
if (c.lpWithdrawals.length > 0) {
if (c.convertLP) _removeAndClaimLP(c.lpWithdrawals, c.minBeanAmount, c.minEthAmount);
else _claimLP(c.lpWithdrawals);
}
... | 0.7.6 |
// Claim Beans | function _claimBeans(uint32[] calldata withdrawals) private {
uint256 beansClaimed = 0;
for (uint256 i = 0; i < withdrawals.length; i++) {
require(withdrawals[i] <= s.season.current, "Claim: Withdrawal not recievable.");
beansClaimed = beansClaimed.add(claimBeanWithdrawal(msg.sen... | 0.7.6 |
/**
* @dev Generaes a new single seed Collectible, with isAttached as 0.
* @notice Helps in creating seed collectible.The generation of an asset if limited via the generationSeasonController
* @param _teamId teamId of the asset/token/collectible
* @param _posId position of the asset/token/c... | function createSeedCollectible(
uint8 _teamId,
uint8 _posId,
uint256 _attributes,
address _owner,
uint256 _gameId,
uint256 _playerOverrideId,
uint256 _mlbPlayerId)
external
canCreate
whenNotPaused
returns (uint256) {
... | 0.4.24 |
//constructor function
//initializing lock-up periods and corresponding amounts of tokens | function CareerChainPrivateSale
(
uint256 _openingTime,
uint256 _closingTime,
uint256 _rate,
address _wallet,
uint256[6] _lockupEndTime,
uint256 _firstVestedLockUpAmount,
uint256 _stagedVestedLockUpAmounts,
CareerChainToken _token
)
... | 0.4.24 |
// Calculates the amount that has already vested. | function vestedAmount() private view returns (uint256) {
uint256 lockupStage = 0;
uint256 releasable = 0;
//determine current lock-up phase
uint256 i = 0;
// solium-disable-next-line security/no-block-members
while (i < lockupEndTime.length && lockupEndTime[i] <= ... | 0.4.24 |
//Withdraw tokens only after lock-up ends, applying the staged lock-up scheme. | function withdrawTokens() public {
uint256 tobeReleased = 0;
uint256 unreleased = releasableAmount();
//max amount to be withdrawn is the releasable amount, excess stays in lock-up, unless all lock-ups have ended
// solium-disable-next-line security/no-block-members
if(bal... | 0.4.24 |
/***** external functions *****/ | function prepareInstance(
string _boardTokenName,
string _boardTokenSymbol,
address[] _boardMembers,
uint64[3] _boardVotingSettings,
uint64 _financePeriod
)
external
{
require(_boardMembers.length > 0, ERROR_BAD_SETTINGS);
... | 0.4.24 |
/***** internal apps installation functions *****/ | function _installBoardApps(Kernel _dao, MiniMeToken _token, uint64[3] _votingSettings, uint64 _financePeriod)
internal
returns (TokenManager)
{
TokenManager tm = _installTokenManagerApp(_dao, _token, BOARD_TRANSFERABLE, BOARD_MAX_PER_ACCOUNT);
Voting voting = _installVotingApp(_... | 0.4.24 |
/***** internal apps initialization functions *****/ | function _initializePresale(
uint256 _goal,
uint64 _period,
uint256 _exchangeRate,
uint64 _vestingCliffPeriod,
uint64 _vestingCompletePeriod,
uint256 _supplyOfferedPct,
uint256 _fundingForBeneficiaryPct,
uint64 _openDate
)
interna... | 0.4.24 |
/***** internal setup functions *****/ | function _setupCollaterals(
Kernel _dao,
uint256[2] _virtualSupplies,
uint256[2] _virtualBalances,
uint256[2] _slippages,
uint256 _rateDAI,
uint256 _floorDAI
)
internal
{
ACL acl = ACL(_dao.acl());
(, Voting shareVoting... | 0.4.24 |
/**
* @dev Generate new Reward Collectible and transfer it to the owner, with isAttached as 0.
* @notice Helps in redeeming the Rewards using our Oracle. Creates & transfers the asset to the redeemer (_owner)
* The generation of an asset if limited via the generationSeasonController
* @param _teamId t... | function createRewardCollectible (
uint8 _teamId,
uint8 _posId,
uint256 _attributes,
address _owner,
uint256 _gameId,
uint256 _playerOverrideId,
uint256 _mlbPlayerId)
external
canCreate
whenNotPaused
returns (uint256) {
... | 0.4.24 |
// function create(address _beneficiary, uint256 _start, uint256 _cliff, uint256 _duration, bool _revocable, uint256 noOfTokens) onlyOwner public returns(StandardTokenVesting) { | function create(address _beneficiary, uint256 _cliff, uint256 _duration, bool _revocable, uint256 noOfTokens) public onlyOwner returns(StandardTokenVesting) {
StandardTokenVesting vesting = new StandardTokenVesting(_beneficiary, now , _cliff , _duration, _revocable);
vesting.transferOwnership(msg.send... | 0.4.24 |
// Funds withdrawal to cover costs of fairwin operation. | function withdrawFunds(address beneficiary, uint withdrawAmount) external onlyOwner {
require (withdrawAmount <= address(this).balance, "Increase amount larger than balance.");
require (jackpotSize + lockedInBets + withdrawAmount <= address(this).balance, "Not enough funds.");
sendFunds(benef... | 0.4.24 |
// This is the method used to settle 99% of bets. To process a bet with a specific
// "commit", settleBet should supply a "reveal" number that would Keccak256-hash to
// "commit". "blockHash" is the block hash of placeBet block as seen by croupier; it
// is additionally asserted to prevent changing the bet outcomes on ... | function settleBet(uint reveal, bytes32 blockHash) external onlyCroupier {
uint commit = uint(keccak256(abi.encodePacked(reveal)));
Bet storage bet = bets[commit];
uint placeBlockNumber = bet.placeBlockNumber;
// Check that bet has not expired yet (see comment to BET_EXPIRATION_B... | 0.4.24 |
// This method is used to settle a bet that was mined into an uncle block. At this
// point the player was shown some bet outcome, but the blockhash at placeBet height
// is different because of Ethereum chain reorg. We supply a full merkle proof of the
// placeBet transaction receipt to provide untamperable evidence t... | function settleBetUncleMerkleProof(uint reveal, uint40 canonicalBlockNumber) external onlyCroupier {
// "commit" for bet settlement can only be obtained by hashing a "reveal".
uint commit = uint(keccak256(abi.encodePacked(reveal)));
Bet storage bet = bets[commit];
// Check that c... | 0.4.24 |
// Refund transaction - return the bet amount of a roll that was not processed in a
// due timeframe. Processing such blocks is not possible due to EVM limitations (see
// BET_EXPIRATION_BLOCKS comment above for details). In case you ever find yourself
// in a situation like this, just contact the fairwin support, howe... | function refundBet(uint commit) external {
// Check that bet is in 'active' state.
Bet storage bet = bets[commit];
uint amount = bet.amount;
require (amount != 0, "Bet should be in an 'active' state");
// Check that bet has already expired.
require (block.number... | 0.4.24 |
// Get the expected win amount after house edge is subtracted. | function getDiceWinAmount(uint amount, uint modulo, uint rollUnder) private pure returns (uint winAmount, uint jackpotFee) {
require (0 < rollUnder && rollUnder <= modulo, "Win probability out of range.");
jackpotFee = amount >= MIN_JACKPOT_BET ? JACKPOT_FEE : 0;
uint houseEdge = amount *... | 0.4.24 |
// Memory copy. | function memcpy(uint dest, uint src, uint len) pure private {
// Full 32 byte words
for(; len >= 32; len -= 32) {
assembly { mstore(dest, mload(src)) }
dest += 32; src += 32;
}
// Remaining bytes
uint mask = 256 ** (32 - len) - 1;
assembl... | 0.4.24 |
/**
* @dev Generate new ETH Card Collectible, with isAttached as 2.
* @notice Helps to generate Collectibles/Tokens/Asset and transfer to ETH Cards,
* which can be redeemed using our web-app.The generation of an asset if limited via the generationSeasonController
* @param _teamId teamId of the asset/t... | function createETHCardCollectible (
uint8 _teamId,
uint8 _posId,
uint256 _attributes,
address _owner,
uint256 _gameId,
uint256 _playerOverrideId,
uint256 _mlbPlayerId)
external
canCreate
whenNotPaused
returns (uint256) {
... | 0.4.24 |
/**
* @dev Returns all the relevant information about a specific Collectible.
* @notice Get details about your collectible
* @param _tokenId The token identifier
* @return isAttached Is Object attached
* @return teamId team identifier of the asset/token/collectible
* @re... | function getCollectibleDetails(uint256 _tokenId)
external
view
returns (
uint256 isAttached,
uint32 sequenceId,
uint8 teamId,
uint8 positionId,
uint64 creationTime,
uint256 attributes,
uint256 playerOverrideId,
uint256 ml... | 0.4.24 |
// External function | function spin(bytes32 hash, uint8 _v, bytes32 _r, bytes32 _s)
external
payable
mustSignWithECDSA(hash, _v, _r, _s)
{
// Conditions
require(msg.value >= minimumWager, "wager must be greater than or equal minimumWager.");
require(msg.value <= maximumWager, "wager... | 0.4.24 |
/**
* @dev Only allows trasnctions to go throught if the msg.sender is in the apporved list
* @notice Updates the gameCardID properrty of the asset
* @param _gameCardNumber The game card number
* @param _playerId The player identifier
*/ | function updateCurrentGameCardId(uint256 _gameCardNumber, uint256 _playerId) public whenNotPaused {
require (contractsApprovedList[msg.sender]);
NFT memory obj = _getAttributesOfToken(_playerId);
obj.currentGameCardId = _gameCardNumber;
if ( _gameCardNumber == ... | 0.4.24 |
// redeem(): burn one star token, receive ownership of the most recently deposited star in exchange
// | function redeem() external returns (uint16) {
// must have sufficient balance
require(startoken.balanceOf(_msgSender()) >= ONE_STAR, "Treasury: Not enough balance");
// there must be at least one star in the asset list
require(assets.length > 0, "Treasury: no star available to redeem");... | 0.8.9 |
// Decrease the amount of tokens that an owner allowed to a spender.
// approve should be called when allowed[spender] == 0.
// To decrement allowed value is better to use this function to avoid 2 calls (and wait until the first transaction is mined) | function decreaseApproval(address spender, uint256 subtractedValue ) public returns (bool){
uint256 oldValue = allowed[msg.sender][spender];
if (subtractedValue >= oldValue) {
allowed[msg.sender][spender] = 0;
} else {
allowed[msg.sender][spender] = oldValue.sub(subtractedValue);
}
emit ... | 0.4.24 |
//freeze HXY tokens to contract | function Freeze(address token)
public
{
if(isFreezeFinished(msg.sender, token)){
Unfreeze(token);//unfreezes all currently frozen tokens
}
uint amt;
//update balances
if(token == hxyAddress){
amt = mintedHxy[msg.sender];
r... | 0.6.4 |
//unfreeze HXY tokens from contract | function Unfreeze(address token)
public
{
uint amt;
if(token == hxyAddress){
require(tokenHxyFrozenBalances[msg.sender] > 0,"Error: unsufficient frozen balance");//ensure user has enough frozen funds
require(isFreezeFinished(msg.sender, token), "tokens cannot be... | 0.6.4 |
//HXY frozen for 365 days , HXB locked till maxSupply , HXP frozen till platform launch | function isFreezeFinished(address _user, address token)
public
view
returns(bool)
{
if(token == hxyAddress){
if(frozen[_user].freezeHxyStartTimestamp == 0){
return false;
}
else{
return (frozen[_user].freeze... | 0.6.4 |
/**
* @dev A batch function to facilitate batching of asset creation. canCreate modifier
* helps in controlling who can call the function
* @notice Batch Function to Create Assets
* @param _teamId The team identifier
* @param _attributes The attributes
* @param _playerOverri... | function batchCreateAsset(
uint8[] _teamId,
uint256[] _attributes,
uint256[] _playerOverrideId,
uint256[] _mlbPlayerId,
address[] _to)
external
canCreate
whenNotPaused {
require (isBatchSupported);
require (_teamId.lengt... | 0.4.24 |
/*
* @notify Modify an uint256 parameter
* @param parameter The name of the parameter to change
* @param val The new value for the parameter
*/ | function modifyParameters(bytes32 parameter, uint256 val) external isAuthority {
if (parameter == "nb") {
require(both(val > 0, val <= EIGHTEEN_DECIMAL_NUMBER), "PRawPerSecondCalculator/invalid-nb");
noiseBarrier = val;
}
else if (parameter == "ps") {
require(val > ... | 0.6.7 |
/**
* @dev Overriden TransferFrom, with the modifier canTransfer which uses our attachment system
* @notice Helps in trasnferring assets
* @param _from the address sending from
* @param _to the address sending to
* @param _tokenId The token identifier
*/ | function transferFrom(
address _from,
address _to,
uint256 _tokenId
)
public
canTransfer(_tokenId)
{
// Asset should not be in play
require (checkIsAttached(_tokenId) == 0);
require (_from != address(0));
require (_to... | 0.4.24 |
/*
* @notice Return a redemption rate bounded by feedbackOutputLowerBound and feedbackOutputUpperBound as well as the
timeline over which that rate will take effect
* @param pOutput The raw redemption rate computed from the proportional and integral terms
*/ | function getBoundedRedemptionRate(int pOutput) public isReader view returns (uint256, uint256) {
int boundedPOutput = pOutput;
uint newRedemptionRate;
if (pOutput < feedbackOutputLowerBound) {
boundedPOutput = feedbackOutputLowerBound;
} else if (pOutput > int(feedbackOutputU... | 0.6.7 |
/*
* @notice Compute and return the upcoming redemption rate
* @param marketPrice The system coin market price
* @param redemptionPrice The system coin redemption price
*/ | function getNextRedemptionRate(uint marketPrice, uint redemptionPrice, uint)
public isReader view returns (uint256, int256, uint256) {
// The proportional term is just redemption - market. Market is read as having 18 decimals so we multiply by 10**9
// in order to have 27 decimals like the redempt... | 0.6.7 |
/**
* @dev Facilitates batch trasnfer of collectible with multiple TO Address, depending if batch is supported on contract.
* @notice Batch Trasnfer with multpple TO addresses
* @param _tokenIds The token identifiers
* @param _fromB the address sending from
* @param _toB the add... | function multiBatchTransferFrom(
uint256[] _tokenIds,
address[] _fromB,
address[] _toB)
public
{
require (isBatchSupported);
require (_tokenIds.length > 0 && _fromB.length > 0 && _toB.length > 0);
uint256 _id;
address _to;
addr... | 0.4.24 |
/**
* Updates House Oracle function
*
*/ | function changeHouseOracle(address oracleAddress, uint oraclePercentage) onlyOwner public {
require(add(houseData.housePercentage,oraclePercentage)<1000,"House + Oracle percentage should be lower than 100%");
if (oracleAddress != houseData.oracleAddress) {
houseData.oldOracleAddress = hou... | 0.5.8 |
/*
* Places a Pool Bet
*/ | function placePoolBet(uint eventId, uint outputId, uint forecast, uint closingDateTime, uint256 minimumWager, uint256 maximumWager, string memory createdBy) payable public {
require(msg.value > 0,"Wager should be greater than zero");
require(!houseData.newBetsPaused,"Bets are paused right now");
... | 0.5.8 |
/*
* Places a HeadToHEad Bet
*/ | function placeH2HBet(uint eventId, uint outputId, uint forecast, uint closingDateTime, uint256 payoutRate, string memory createdBy) payable public {
require(msg.value > 0,"Wager should be greater than zero");
require(!houseData.newBetsPaused,"Bets are paused right now");
betNextId += 1;
... | 0.5.8 |
/*
* Increase wager
*/ | function increaseWager(uint betId, uint forecast, string memory createdBy) payable public {
require(msg.value > 0,"Increase wager amount should be greater than zero");
require(bets[betId].betType == BetType.poolbet,"Only poolbet supports the increaseWager");
require(playerBetForecastWager[msg... | 0.5.8 |
/*
* Remove a Bet
*/ | function removeBet(uint betId, string memory createdBy) public {
require(bets[betId].createdBy == msg.sender,"Caller and player created don't match");
require(playerBetTotalBets[msg.sender][betId] > 0, "Player should has placed at least one bet");
require(betTotalBets[betId] == playerBetTotal... | 0.5.8 |
/*
* Refute a Bet
*/ | function refuteBet(uint betId, string memory createdBy) public {
require(playerBetTotalAmount[msg.sender][betId]>0,"Caller hasn't placed any bet");
require(!playerBetRefuted[msg.sender][betId],"Already refuted");
require(bets[betId].betType == BetType.headtohead || bets[betId].betType == BetT... | 0.5.8 |
/**
* Cancels a Bet
*/ | function cancelBet(uint betId) onlyOwner public {
require(houseData.managed, "Cancel available on managed Houses");
updateBetDataFromOracle(betId, getBetEventId(betId), getBetEventOutputId(betId));
require(getBetFreezeTime(betId) > now,"Freeze time passed");
bets[betId].isCanc... | 0.5.8 |
/// @notice Backward compatible function
/// @notice Use token address ETH_TOKEN_ADDRESS for ether
/// @dev Trade from src to dest token and sends dest token to destAddress
/// @param trader Address of the taker side of this trade
/// @param src Source token
/// @param srcAmount Amount of src tokens in twei
/// @param ... | function tradeWithHint(
address payable trader,
ERC20 src,
uint256 srcAmount,
ERC20 dest,
address payable destAddress,
uint256 maxDestAmount,
uint256 minConversionRate,
address payable walletId,
bytes calldata hint
) external payable ... | 0.6.6 |
/// @notice Use token address ETH_TOKEN_ADDRESS for ether
/// @dev Trade from src to dest token and sends dest token to destAddress
/// @param trader Address of the taker side of this trade
/// @param src Source token
/// @param srcAmount Amount of src tokens in twei
/// @param dest Destination token
/// @param destAdd... | function tradeWithHintAndFee(
address payable trader,
IERC20 src,
uint256 srcAmount,
IERC20 dest,
address payable destAddress,
uint256 maxDestAmount,
uint256 minConversionRate,
address payable platformWallet,
uint256 platformFeeBps,
... | 0.6.6 |
/// @notice Can be called only by operator
/// @dev Allow or prevent to trade token -> eth for list of reserves
/// Useful for migration to new network contract
/// Call storage to get list of reserves supporting token -> eth
/// @param token Token address
/// @param startIndex start index in reserves list
//... | function listReservesForToken(
IERC20 token,
uint256 startIndex,
uint256 endIndex,
bool add
) external {
onlyOperator();
if (startIndex > endIndex) {
// no need to do anything
return;
}
address[] memory reserves =... | 0.6.6 |
/// @dev gets the expected rates when trading src -> dest token, with / without fees
/// @param src Source token
/// @param dest Destination token
/// @param srcQty Amount of src tokens in twei
/// @param platformFeeBps Part of the trade that is allocated as fee to platform wallet. Ex: 1000 = 10%
/// @param hint Advanc... | function getExpectedRateWithHintAndFee(
IERC20 src,
IERC20 dest,
uint256 srcQty,
uint256 platformFeeBps,
bytes calldata hint
)
external
view
override
returns (
uint256 rateWithNetworkFee,
uint256 rateWithAllF... | 0.6.6 |
/// @notice Backward compatible API
/// @dev Gets the expected and slippage rate for exchanging src -> dest token
/// @dev worstRate is hardcoded to be 3% lower of expectedRate
/// @param src Source token
/// @param dest Destination token
/// @param srcQty Amount of src tokens in twei
/// @return expectedRate for a tra... | function getExpectedRate(
ERC20 src,
ERC20 dest,
uint256 srcQty
) external view returns (uint256 expectedRate, uint256 worstRate) {
if (src == dest) return (0, 0);
uint256 qty = srcQty & ~PERM_HINT_GET_RATE;
TradeData memory tradeData = initTradeInput({
... | 0.6.6 |
/// @notice Calculates platform fee and reserve rebate percentages for the trade.
/// Transfers eth and rebate wallet data to kyberFeeHandler | function handleFees(TradeData memory tradeData) internal {
uint256 sentFee = tradeData.networkFeeWei + tradeData.platformFeeWei;
//no need to handle fees if total fee is zero
if (sentFee == 0)
return;
// update reserve eligibility and rebate percentages
(
... | 0.6.6 |
/// @notice Use token address ETH_TOKEN_ADDRESS for ether
/// @dev Do one trade with each reserve in reservesData, verifying network balance
/// as expected to ensure reserves take correct src amount
/// @param src Source token
/// @param dest Destination token
/// @param destAddress Address to send tokens to
/// @... | function doReserveTrades(
IERC20 src,
IERC20 dest,
address payable destAddress,
ReservesData memory reservesData,
uint256 expectedDestAmount,
uint256 srcDecimals,
uint256 destDecimals
) internal virtual {
if (src == dest) {
// e... | 0.6.6 |
/// @notice If user maxDestAmount < actual dest amount, actualSrcAmount will be < srcAmount
/// Calculate the change, and send it back to the user | function handleChange(
IERC20 src,
uint256 srcAmount,
uint256 requiredSrcAmount,
address payable trader
) internal {
if (requiredSrcAmount < srcAmount) {
// if there is "change" send back to trader
if (src == ETH_TOKEN_ADDRESS) {
... | 0.6.6 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.