comment stringlengths 11 2.99k | function_code stringlengths 165 3.15k | version stringclasses 80
values |
|---|---|---|
/**
* @dev returns the amount of keys you would get given an amount of eth.
* -functionhash- 0xce89c80c
* @param _rID round ID you want price for
* @param _eth amount of eth sent in
* @return keys received
*/ | function calcKeysReceived(uint256 _rID, uint256 _eth)
public
view
returns(uint256)
{
// grab time
uint256 _now = now;
// are we in a round?
if (_now > round_[_rID].strt + rndGap_ && (_now <= round_[_rID].end || (_now > round_[_rID].end && round_[_rID].plyr == 0)... | 0.4.24 |
/**
* @dev returns current eth price for X keys.
* -functionhash- 0xcf808000
* @param _keys number of keys desired (in 18 decimal format)
* @return amount of eth needed to send
*/ | function iWantXKeys(uint256 _keys)
public
view
returns(uint256)
{
// setup local rID
uint256 _rID = rID_;
// grab time
uint256 _now = now;
// are we in a round?
if (_now > round_[_rID].strt + rndGap_ && (_now <= round_[_rID].end || (_now > ro... | 0.4.24 |
/**
* @dev receives name/player info from names contract
*/ | function receivePlayerInfo(uint256 _pID, address _addr, bytes32 _name, uint256 _laff)
external
{
require (msg.sender == address(PlayerBook), "your not playerNames contract... hmmm..");
if (pIDxAddr_[_addr] != _pID)
pIDxAddr_[_addr] = _pID;
if (pIDxName_[_name] != _pID)
... | 0.4.24 |
/**
* @dev gets existing or registers new pID. use this when a player may be new
* @return pID
*/ | function determinePID(F3Ddatasets.EventReturns memory _eventData_)
private
returns (F3Ddatasets.EventReturns)
{
uint256 _pID = pIDxAddr_[msg.sender];
// if player is new to this version of fomo3d
if (_pID == 0)
{
// grab their player ID, name and last aff ... | 0.4.24 |
/**
* @dev decides if round end needs to be run & new round started. and if
* player unmasked earnings from previously played rounds need to be moved.
*/ | function managePlayer(uint256 _pID, F3Ddatasets.EventReturns memory _eventData_)
private
returns (F3Ddatasets.EventReturns)
{
// if player has played a previous round, move their unmasked earnings
// from that round to gen vault.
if (plyr_[_pID].lrnd != 0)
updateGe... | 0.4.24 |
/**
* @dev moves any unmasked earnings to gen vault. updates earnings mask
*/ | function updateGenVault(uint256 _pID, uint256 _rIDlast)
private
{
uint256 _earnings = calcUnMaskedEarnings(_pID, _rIDlast);
if (_earnings > 0)
{
// put in gen vault
plyr_[_pID].gen = _earnings.add(plyr_[_pID].gen);
// zero out their earnings by... | 0.4.24 |
/**
* @dev updates round timer based on number of whole keys bought.
*/ | function updateTimer(uint256 _keys, uint256 _rID)
private
{
// grab time
uint256 _now = now;
// calculate time based on number of keys bought
uint256 _newTime;
if (_now > round_[_rID].end && round_[_rID].plyr == 0)
_newTime = (((_keys) / (10000000000... | 0.4.24 |
/**
* @dev distributes eth based on fees to com, aff, and p3d
*/ | function distributeExternal(uint256 _rID, uint256 _pID, uint256 _eth, uint256 _affID, uint256 _team, F3Ddatasets.EventReturns memory _eventData_)
private
returns(F3Ddatasets.EventReturns)
{
// pay 2% out to community rewards
uint256 _com = _eth / 50;
// distribute share to af... | 0.4.24 |
/**
* @dev distributes eth based on fees to gen and pot
*/ | function distributeInternal(uint256 _rID, uint256 _pID, uint256 _eth, uint256 _team, uint256 _keys, F3Ddatasets.EventReturns memory _eventData_)
private
returns(F3Ddatasets.EventReturns)
{
// calculate gen share
uint256 _gen = (_eth.mul(fees_[_team].gen)) / 100;
// toss 1% in... | 0.4.24 |
/**
* @dev adds up unmasked earnings, & vault earnings, sets them all to 0
* @return earnings in wei format
*/ | function withdrawEarnings(uint256 _pID)
private
returns(uint256)
{
// update gen vault
updateGenVault(_pID, plyr_[_pID].lrnd);
// from vaults
uint256 _earnings = (plyr_[_pID].win).add(plyr_[_pID].gen).add(plyr_[_pID].aff);
if (_earnings > 0)
{
... | 0.4.24 |
/**
* @dev prepares compression data and fires event for buy or reload tx's
*/ | function endTx(uint256 _pID, uint256 _team, uint256 _eth, uint256 _keys, F3Ddatasets.EventReturns memory _eventData_)
private
{
_eventData_.compressedData = _eventData_.compressedData + (now * 1000000000000000000) + (_team * 100000000000000000000000000000);
_eventData_.compressedIDs = _event... | 0.4.24 |
/**
* @dev Escrow finalization task, called when finalize() is called.
*/ | function _finalization() internal {
if (goalReached()) {
//escrow used to get transferred here, but that allows people to withdraw tokens before LP is created
} else {
_escrow.enableRefunds();
}
super._finalization();
} | 0.5.0 |
/**
* @dev Transfer token for a specified address
* @param _token erc20 The address of the ERC20 contract
* @param _to address The address which you want to transfer to
* @param _value uint256 the _value of tokens to be transferred
*/ | function safeTransfer(IERC20 _token, address _to, uint256 _value) internal returns (bool) {
uint256 prevBalance = _token.balanceOf(address(this));
require(prevBalance >= _value, "Insufficient funds");
_token.transfer(_to, _value);
require(prevBalance - _value == _token.balanceO... | 0.4.24 |
/**
* @dev Allow contract owner to withdraw ERC-20 balance from contract
* while still splitting royalty payments to all other team members.
* in the event ERC-20 tokens are paid to the contract.
* @param _tokenContract contract of ERC-20 token to withdraw
* @param _amount balance to withdraw according to bal... | function withdrawAllERC20(address _tokenContract, uint256 _amount) public onlyOwner {
require(_amount > 0);
IERC20 tokenContract = IERC20(_tokenContract);
require(tokenContract.balanceOf(address(this)) >= _amount, 'Contract does not own enough tokens');
for(uint i=0; i < payableAddressCount; i++ )... | 0.8.9 |
/**
* @dev Withdraw tokens only after crowdsale ends.
* @param beneficiary Whose tokens will be withdrawn.
*/ | function withdrawTokens(address beneficiary) public {
require(goalReached(), "RefundableCrowdsale: goal not reached");
//require(hasClosed(), "PostDeliveryCrowdsale: not closed");
require(finalized(), "Withdraw Tokens: crowdsale not finalized");
uint256 amount = _balances[beneficiary];
... | 0.5.0 |
/**
* @dev Extend crowdsale.
* @param newClosingTime Crowdsale closing time
*/ | function _extendTime(uint256 newClosingTime) internal {
require(!hasClosed(), "TimedCrowdsale: already closed");
// solhint-disable-next-line max-line-length
require(newClosingTime > _closingTime, "TimedCrowdsale: new closing time is before current closing time");
emit TimedCrowdsaleExt... | 0.5.0 |
/**
* @notice Performs the minting of gcToken shares upon the deposit of the
* cToken underlying asset. The funds will be pulled in by this
* contract, therefore they must be previously approved. This
* function builds upon the GTokenBase deposit function. See
* GToke... | function depositUnderlying(uint256 _underlyingCost) public override nonReentrant
{
address _from = msg.sender;
require(_underlyingCost > 0, "underlying cost must be greater than 0");
uint256 _cost = GCFormulae._calcCostFromUnderlyingCost(_underlyingCost, exchangeRate());
(uint256 _netShares, uint256 _feeS... | 0.6.12 |
/**
* @notice Performs the burning of gcToken shares upon the withdrawal of
* the underlying asset. This function builds upon the
* GTokenBase withdrawal function. See GTokenBase.sol for
* further documentation.
* @param _grossShares The gross amount of this gcToken shares be... | function withdrawUnderlying(uint256 _grossShares) public override nonReentrant
{
address _from = msg.sender;
require(_grossShares > 0, "shares must be greater than 0");
(uint256 _cost, uint256 _feeShares) = GFormulae._calcWithdrawalCostFromShares(_grossShares, totalReserve(), totalSupply(), withdrawalFee());... | 0.6.12 |
// @notice Multiplies two numbers, throws on overflow. | function mul(uint256 a, uint256 b) internal pure returns (uint256) {
if (a == 0) {
return 0;
}
uint256 c = a * b;
assert(c / a == b);
return c;
} | 0.4.25 |
// @notice Integer division of two numbers, truncating the quotient. | function div(uint256 a, uint256 b) internal pure returns (uint256) {
// assert(b > 0); // Solidity automatically throws when dividing by 0
// uint256 c = a / b;
// assert(a == b * c + a % b); // There is no case in which this doesn't hold
return a / b;
} | 0.4.25 |
/**
* @notice Deposits funds in the current mint batch
* @param _amount Amount of 3cr3CRV to use for minting
* @param _depositFor User that gets the shares attributed to (for use in zapper contract)
*/ | function depositForMint(uint256 _amount, address _depositFor)
external
nonReentrant
whenNotPaused
onlyApprovedContractOrEOA
{
require(
_hasRole(keccak256("ButterZapper"), msg.sender) || msg.sender == _depositFor,
"you cant transfer other funds"
);
require(threeCrv.balanceOf(msg... | 0.8.1 |
/**
* @notice This function allows a user to withdraw their funds from a batch before that batch has been processed
* @param _batchId From which batch should funds be withdrawn from
* @param _amountToWithdraw Amount of Butter or 3CRV to be withdrawn from the queue (depending on mintBatch / redeemBatch)
* @param _wi... | function withdrawFromBatch(
bytes32 _batchId,
uint256 _amountToWithdraw,
address _withdrawFor
) external {
address recipient = _getRecipient(_withdrawFor);
Batch storage batch = batches[_batchId];
uint256 accountBalance = accountBalances[_batchId][_withdrawFor];
require(batch.claimable ==... | 0.8.1 |
/**
* @notice Claims funds after the batch has been processed (get Butter from a mint batch and 3CRV from a redeem batch)
* @param _batchId Id of batch to claim from
* @param _claimFor User that gets the shares attributed to (for use in zapper contract)
*/ | function claim(bytes32 _batchId, address _claimFor) external returns (uint256) {
(address recipient, BatchType batchType, uint256 accountBalance, uint256 tokenAmountToClaim) = _prepareClaim(
_batchId,
_claimFor
);
//Transfer token
if (batchType == BatchType.Mint) {
setToken.safeTransfe... | 0.8.1 |
/**
* @notice Claims BTR after batch has been processed and stakes it in Staking.sol
* @param _batchId Id of batch to claim from
* @param _claimFor User that gets the shares attributed to (for use in zapper contract)
*/ | function claimAndStake(bytes32 _batchId, address _claimFor) external {
(address recipient, BatchType batchType, uint256 accountBalance, uint256 tokenAmountToClaim) = _prepareClaim(
_batchId,
_claimFor
);
emit Claimed(recipient, batchType, accountBalance, tokenAmountToClaim);
//Transfer toke... | 0.8.1 |
/**
* @notice sets approval for contracts that require access to assets held by this contract
*/ | function setApprovals() external {
(address[] memory tokenAddresses, ) = setBasicIssuanceModule.getRequiredComponentUnitsForIssue(setToken, 1e18);
for (uint256 i; i < tokenAddresses.length; i++) {
IERC20 curveLpToken = curvePoolTokenPairs[tokenAddresses[i]].crvLPToken;
CurveMetapool curveMetapool =... | 0.8.1 |
/**
* @notice returns the min amount of butter that should be minted given an amount of 3crv
* @dev this controls slippage in the minting process
*/ | function getMinAmountToMint(
uint256 _valueOfBatch,
uint256 _valueOfComponentsPerUnit,
uint256 _slippage
) public pure returns (uint256) {
uint256 _mintAmount = (_valueOfBatch * 1e18) / _valueOfComponentsPerUnit;
uint256 _delta = (_mintAmount * _slippage) / 10_000;
return _mintAmount - _delta;... | 0.8.1 |
// ACTIONS WITH OWN TOKEN | function sendToNest(
address _sender,
uint256 _eggId
) external onlyController returns (bool, uint256, uint256, address) {
require(!getter.isEggOnSale(_eggId), "egg is on sale");
require(core.isEggOwner(_sender, _eggId), "not an egg owner");
uint256 _hatchingPrice = t... | 0.4.25 |
/**
* @notice returns the value of butter in virtualPrice
*/ | function valueOfComponents(address[] memory _tokenAddresses, uint256[] memory _quantities)
public
view
returns (uint256)
{
uint256 value;
for (uint256 i = 0; i < _tokenAddresses.length; i++) {
value +=
(((YearnVault(_tokenAddresses[i]).pricePerShare() *
curvePoolTokenPairs[... | 0.8.1 |
/**
* @notice makes sure only zapper or user can withdraw from accout_ and returns the recipient of the withdrawn token
* @param _account is the address which gets withdrawn from
* @dev returns recipient of the withdrawn funds
* @dev By default a user should set _account to their address
* @dev If zapper is used t... | function _getRecipient(address _account) internal view returns (address) {
//Make sure that only zapper can withdraw from someone else
require(_hasRole(keccak256("ButterZapper"), msg.sender) || msg.sender == _account, "you cant transfer other funds");
//Set recipient per default to _account
address rec... | 0.8.1 |
/**
* @notice Generates the next batch id for new deposits
* @param _currentBatchId takes the current mint or redeem batch id
* @param _batchType BatchType of the newly created id
*/ | function _generateNextBatch(bytes32 _currentBatchId, BatchType _batchType) internal returns (bytes32) {
bytes32 id = _generateNextBatchId(_currentBatchId);
batchIds.push(id);
Batch storage batch = batches[id];
batch.batchType = _batchType;
batch.batchId = id;
if (BatchType.Mint == _batchType) {... | 0.8.1 |
/**
* @notice Deposit either Butter or 3CRV in their respective batches
* @param _amount The amount of 3CRV or Butter a user is depositing
* @param _currentBatchId The current reedem or mint batch id to place the funds in the next batch to be processed
* @param _depositFor User that gets the shares attributed to (f... | function _deposit(
uint256 _amount,
bytes32 _currentBatchId,
address _depositFor
) internal {
Batch storage batch = batches[_currentBatchId];
//Add the new funds to the batch
batch.suppliedTokenBalance = batch.suppliedTokenBalance + _amount;
batch.unclaimedShares = batch.unclaimedShares +... | 0.8.1 |
/**
* @notice This function checks all requirements for claiming, updates batches and balances and returns the values needed for the final transfer of tokens
* @param _batchId Id of batch to claim from
* @param _claimFor User that gets the shares attributed to (for use in zapper contract)
*/ | function _prepareClaim(bytes32 _batchId, address _claimFor)
internal
returns (
address,
BatchType,
uint256,
uint256
)
{
Batch storage batch = batches[_batchId];
require(batch.claimable, "not yet claimable");
address recipient = _getRecipient(_claimFor);
uint256 acc... | 0.8.1 |
/**
* @notice Deposit 3CRV in a curve metapool for its LP-Token
* @param _amount The amount of 3CRV that gets deposited
* @param _curveMetapool The metapool where we want to provide liquidity
*/ | function _sendToCurve(uint256 _amount, CurveMetapool _curveMetapool) internal {
//Takes 3CRV and sends lpToken to this contract
//Metapools take an array of amounts with the exoctic stablecoin at the first spot and 3CRV at the second.
//The second variable determines the min amount of LP-Token we want to re... | 0.8.1 |
/**
* @notice Withdraws 3CRV for deposited crvLPToken
* @param _amount The amount of crvLPToken that get deposited
* @param _curveMetapool The metapool where we want to provide liquidity
*/ | function _withdrawFromCurve(uint256 _amount, CurveMetapool _curveMetapool) internal {
//Takes lp Token and sends 3CRV to this contract
//The second variable is the index for the token we want to receive (0 = exotic stablecoin, 1 = 3CRV)
//The third variable determines min amount of token we want to receive ... | 0.8.1 |
/**
* @notice Changes the the ProcessingThreshold
* @param _cooldown Cooldown in seconds
* @param _mintThreshold Amount of MIM necessary to mint immediately
* @param _redeemThreshold Amount of Butter necessary to mint immediately
* @dev The cooldown is the same for redeem and mint batches
*/ | function setProcessingThreshold(
uint256 _cooldown,
uint256 _mintThreshold,
uint256 _redeemThreshold
) public onlyRole(DAO_ROLE) {
ProcessingThreshold memory newProcessingThreshold = ProcessingThreshold({
batchCooldown: _cooldown,
mintThreshold: _mintThreshold,
redeemThreshold: _rede... | 0.8.1 |
/**
* @notice sets slippage for mint and redeem
* @param _mintSlippage amount in bps (e.g. 50 = 0.5%)
* @param _redeemSlippage amount in bps (e.g. 50 = 0.5%)
*/ | function setSlippage(uint256 _mintSlippage, uint256 _redeemSlippage) external onlyRole(DAO_ROLE) {
require(_mintSlippage <= 200 && _redeemSlippage <= 200, "slippage too high");
Slippage memory newSlippage = Slippage({ mintBps: _mintSlippage, redeemBps: _redeemSlippage });
emit SlippageUpdated(slippage, newS... | 0.8.1 |
// Assign tokens to investor with locking period | function assignToken(address _investor,uint256 _tokens) external {
// Tokens assigned by only Angel Sales,PE Sales,Founding Investor and Initiator Team wallets
require(msg.sender == walletAddresses[0] || msg.sender == walletAddresses[1] || msg.sender == walletAddresses[2] || msg.sender == walletAddres... | 0.4.24 |
// For wallet Angel Sales and PE Sales | function getWithdrawableAmountANPES(address _investor) public view returns(uint256) {
require(startWithdraw != 0);
// interval in months
uint interval = safeDiv(safeSub(now,startWithdraw),30 days);
// total allocatedTokens
uint _allocatedTokens = safeAdd(walletAngelPESales[_... | 0.4.24 |
// For wallet Founding Investor and Initiator Team | function getWithdrawableAmountFIIT(address _investor) public view returns(uint256) {
require(startWithdraw != 0);
// interval in months
uint interval = safeDiv(safeSub(now,startWithdraw),30 days);
// total allocatedTokens
uint _allocatedTokens = safeAdd(walletFoundingInitiat... | 0.4.24 |
// Sale of the tokens. Investors can call this method to invest into ITT Tokens | function() payable external {
// Allow only to invest in ICO stage
require(startStop);
//Sorry !! We only allow to invest with minimum 0.5 Ether as value
require(msg.value >= (0.5 ether));
// multiply by exchange rate to get token amount
uint256 calculatedTokens... | 0.4.24 |
// Function will transfer the tokens to investor's address
// Common function code for assigning tokens | function assignTokens(address investor, uint256 tokens) internal {
// Debit tokens from ether exchange wallet
balances[ethExchangeWallet] = safeSub(balances[ethExchangeWallet], tokens);
// Assign tokens to the sender
balances[investor] = safeAdd(balances[investor], tokens);
... | 0.4.24 |
// Transfer `value` ITTokens from sender's account
// `msg.sender` to provided account address `to`.
// @param _to The address of the recipient
// @param _value The number of ITTokens to transfer
// @return Whether the transfer was successful or not | function transfer(address _to, uint _value) public returns (bool ok) {
//validate receiver address and value.Not allow 0 value
require(_to != 0 && _value > 0);
uint256 senderBalance = balances[msg.sender];
//Check sender have enough balance
require(senderBalance >= _value);
... | 0.4.24 |
/**
* @dev Creates a new token type and assigns _initialSupply to an address
* NOTE: remove onlyOwner if you want third parties to create new tokens on your contract (which may change your IDs)
* @param _initialOwner address of the first owner of the token
* @param _initialSupply amount to supply the first owne... | function create(
address _initialOwner,
uint256 _initialSupply,
string calldata _uri,
bytes calldata _data
) external onlyOwner returns (uint256) {
uint256 _id = _getNextTokenID();
_incrementTokenTypeId();
creators[_id] = msg.sender;
if (bytes(_uri).length > 0) {
em... | 0.5.12 |
/**
* @dev Mint tokens for each id in _ids
* @param _to The address to mint tokens to
* @param _ids Array of ids to mint
* @param _quantities Array of amounts of tokens to mint per id
* @param _data Data to pass if receiver is contract
*/ | function batchMint(
address _to,
uint256[] memory _ids,
uint256[] memory _quantities,
bytes memory _data
) public {
for (uint256 i = 0; i < _ids.length; i++) {
uint256 _id = _ids[i];
require(creators[_id] == msg.sender, "ERC1155Tradable#batchMint: ONLY_CREATOR_ALLOWED");
... | 0.5.12 |
/**
* Override isApprovedForAll to whitelist user's OpenSea proxy accounts to enable gas-free listings.
*/ | function isApprovedForAll(
address _owner,
address _operator
) public view returns (bool isOperator) {
// Whitelist OpenSea proxy contract for easy trading.
ProxyRegistry proxyRegistry = ProxyRegistry(proxyRegistryAddress);
if (address(proxyRegistry.proxies(_owner)) == _operator) {
re... | 0.5.12 |
// if accidentally other token was donated to Project Dev | function sendTokenAw(address StandardTokenAddress, address receiver, uint amount){
if (msg.sender != honestisFort) {
throw;
}
sendTokenAway t = transfers[numTransfers];
t.coinContract = StandardToken(StandardTokenAddress);
t.amount = amount;
t.recipient = receiver;
t.coinContract.transfer(receiv... | 0.4.21 |
// removed isValidData(_data) modifier since this function is also called from SentEnoughEther modifier
// _data is checked in parent functions! not checked here! | function getPrice(
MintData memory _data
)
public
view
returns (uint256)
{
uint256 price = 0;
uint8 _tokenStyle = _data.tokenStyle;
// there is a discount to the first DISCOUNT_MINT_MAX STYLE_JAWS mints during WhitelistSale
// this check intentionally allows a single overbuy at th... | 0.8.11 |
//
// Does state updates at mint time and on every transfer
// | function updateVoyagerState(address to, uint256 cvMintIndex) private {
uint256 n_tokens = 0;
if (!_test_chain_mode) {
// Query any n's we hold
n_tokens = n.balanceOf(to);
}
uint256 new_voyage_count = voyage_count[cvMintIndex] + 1;
string memory tr... | 0.8.7 |
/**
* @notice Approve `spender` to transfer up to `amount` from `src`
* @dev This will overwrite the approval amount for `spender`
* and is subject to issues noted [here](https://eips.ethereum.org/EIPS/eip-20#approve)
* @param spender The address of the account which may transfer tokens
* @param rawAmount Th... | function approve(address spender, uint rawAmount) external returns (bool) {
uint96 amount;
if (rawAmount == uint(-1)) {
amount = uint96(-1);
} else {
amount = safe96(rawAmount, "Comfi::approve: amount exceeds 96 bits");
}
allowances[msg.sender][sp... | 0.5.17 |
/**
* @notice Triggers an approval from owner to spends
* @param owner The address to approve from
* @param spender The address to be approved
* @param rawAmount The number of tokens that are approved (2^256-1 means infinite)
* @param deadline The time at which to expire the signature
* @param v The recover... | function permit(address owner, address spender, uint rawAmount, uint deadline, uint8 v, bytes32 r, bytes32 s) external {
uint96 amount;
if (rawAmount == uint(-1)) {
amount = uint96(-1);
} else {
amount = safe96(rawAmount, "Comfi::permit: amount exceeds 96 bits");
... | 0.5.17 |
/**
* @notice Transfer `amount` tokens from `src` to `dst`
* @param src The address of the source account
* @param dst The address of the destination account
* @param rawAmount The number of tokens to transfer
* @return Whether or not the transfer succeeded
*/ | function transferFrom(address src, address dst, uint rawAmount) external returns (bool) {
address spender = msg.sender;
uint96 spenderAllowance = allowances[src][spender];
uint96 amount = safe96(rawAmount, "Comfi::approve: amount exceeds 96 bits");
if (spender != src && spenderAllo... | 0.5.17 |
// RZ Mint Slots | function availableRZMintSlots() public view returns (uint256) {
uint256 availableMintSlots = 0;
if (ribonzContract.balanceOf(msg.sender) == 0) {
// If not holding RIBONZ genesis can't get an RZ mint slot
return 0;
}
uint256[] memory stTokensOfOwner = spa... | 0.8.7 |
//
// Mint a voygagerz with special promo for RIBONZ Genesis + Spacetime holders
// | function mintVoyagerzWithRZ(uint256 num_to_mint) public payable virtual nonReentrant {
// Precondition checks here
uint256 availableSlots = availableRZMintSlots();
require(availableSlots >= num_to_mint, "Need to hold RIBONZ: Genesis and more RIBONZ: Spacetime than mint count");
... | 0.8.7 |
/**
* @dev Returns true if `account` is a contract.
*
* [IMPORTANT]
* ====
* It is unsafe to assume that an address for which this function returns
* false is an externally-owned account (EOA) and not a contract.
*
* Among others, `isContract` will return false for the following
* types of addresses:
... | function isContract(address account) internal view returns (bool) {
// This method relies on extcodesize/address.code.length, which returns 0
// for contracts in construction, since the code is only stored at the end
// of the constructor execution.
return account.code.length > 0;
... | 0.8.0 |
/**
* @dev 1. Mints an mAsset and then deposits to SAVE
* @param _bAsset bAsset address
* @param _amt Amount of bAsset to mint with
* @param _stake Add the imUSD to the Savings Vault?
*/ | function saveViaMint(address _bAsset, uint256 _amt, bool _stake) external {
// 1. Get the input bAsset
IERC20(_bAsset).transferFrom(msg.sender, address(this), _amt);
// 2. Mint
IMasset mAsset_ = IMasset(mAsset);
uint256 massetsMinted = mAsset_.mint(_bAsset, _amt);
/... | 0.5.16 |
/**
* @dev 2. Buys mUSD on Curve, mints imUSD and optionally deposits to the vault
* @param _input bAsset to sell
* @param _curvePosition Index of the bAsset in the Curve pool
* @param _minOutCrv Min amount of mUSD to receive
* @param _amountIn Input asset amount
* @param _stake Add... | function saveViaCurve(
address _input,
int128 _curvePosition,
uint256 _amountIn,
uint256 _minOutCrv,
bool _stake
) external {
// 1. Get the input asset
IERC20(_input).transferFrom(msg.sender, address(this), _amountIn);
// 2. Purchase mUSD
... | 0.5.16 |
/**
* @dev 3. Buys a bAsset on Uniswap with ETH then mUSD on Curve
* @param _amountOutMin bAsset to sell
* @param _path Sell path on Uniswap (e.g. [WETH, DAI])
* @param _curvePosition Index of the bAsset in the Curve pool
* @param _minOutCrv Min amount of mUSD to receive
* @param _stake ... | function saveViaUniswapETH(
uint256 _amountOutMin,
address[] calldata _path,
int128 _curvePosition,
uint256 _minOutCrv,
bool _stake
) external payable {
// 1. Get the bAsset
uint[] memory amounts = uniswap.swapExactETHForTokens.value(msg.value)(
... | 0.5.16 |
/**
* @notice Transfers amount amount of an _id from the _from address to the _to address specified
* @param _from Source address
* @param _to Target address
* @param _id ID of the token type
* @param _amount Transfered amount
* @param _data Additional data with no specified format, sent in... | function safeTransferFrom(address _from, address _to, uint256 _id, uint256 _amount, bytes memory _data)
public
{
require((msg.sender == _from) || operators[_from][msg.sender], "ERC1155#safeTransferFrom: INVALID_OPERATOR");
require(_to != address(0),"ERC1155#safeTransferFrom: INVALID_RECIPIENT");
... | 0.5.12 |
/**
* @notice Send multiple types of Tokens from the _from address to the _to address (with safety call)
* @param _from Source addresses
* @param _to Target addresses
* @param _ids IDs of each token type
* @param _amounts Transfer amounts per token type
* @param _data Additional data wit... | function safeBatchTransferFrom(address _from, address _to, uint256[] memory _ids, uint256[] memory _amounts, bytes memory _data)
public
{
// Requirements
require((msg.sender == _from) || operators[_from][msg.sender], "ERC1155#safeBatchTransferFrom: INVALID_OPERATOR");
require(_to != address(0), "... | 0.5.12 |
/**
* @notice Transfers amount amount of an _id from the _from address to the _to address specified
* @param _from Source address
* @param _to Target address
* @param _id ID of the token type
* @param _amount Transfered amount
*/ | function _safeTransferFrom(address _from, address _to, uint256 _id, uint256 _amount)
internal
{
// Update balances
balances[_from][_id] = balances[_from][_id].sub(_amount); // Subtract amount
balances[_to][_id] = balances[_to][_id].add(_amount); // Add amount
// Emit event
emit Tr... | 0.5.12 |
/**
* @notice Verifies if receiver is contract and if so, calls (_to).onERC1155Received(...)
*/ | function _callonERC1155Received(address _from, address _to, uint256 _id, uint256 _amount, bytes memory _data)
internal
{
// Check if recipient is contract
if (_to.isContract()) {
bytes4 retval = IERC1155TokenReceiver(_to).onERC1155Received(msg.sender, _from, _id, _amount, _data);
require... | 0.5.12 |
/**
* @dev Minting for whitelisted addresses
*
* Requirements:
*
* Contract must be unpaused
* The presale must be going on
* The caller must request less than the max by address authorized
* The amount of token must be superior to 0
* The supply must not be empty
* The price must be correct
*
... | function whitlistedMinting (uint amountToMint, bytes32[] calldata merkleProof ) external payable isWhitelisted(merkleProof) {
require (!_paused, "Contract paused");
require (_presale, "Presale over!");
require (amountToMint + balanceOf(msg.sender) <= _maxNftByWallet, "Requet too much for a wa... | 0.8.1 |
/**
* @dev Minting for the public sale
*
* Requirements:
*
* The presale must be over
* The caller must request less than the max by address authorized
* The amount of token must be superior to 0
* The supply must not be empty
* The price must be correct
*
* @param amountToMint the number of tok... | function publicMint(uint amountToMint) external payable{
require (!_paused, "Contract paused");
require (!_presale, "Presale on");
require (amountToMint + balanceOf(msg.sender) <= _maxNftByWallet, "Requet too much for a wallet");
require (amountToMint > 0, "Error in the amount requ... | 0.8.1 |
/**
* @notice Get the balance of multiple account/token pairs
* @param _owners The addresses of the token holders
* @param _ids ID of the Tokens
* @return The _owner's balance of the Token types requested (i.e. balance for each (owner, id) pair)
*/ | function balanceOfBatch(address[] memory _owners, uint256[] memory _ids)
public view returns (uint256[] memory)
{
require(_owners.length == _ids.length, "ERC1155#balanceOfBatch: INVALID_ARRAY_LENGTH");
// Variables
uint256[] memory batchBalances = new uint256[](_owners.length);
// Iterat... | 0.5.12 |
/**
* @dev Give away attribution
*
* Requirements:
*
* The recipient must be different than 0
* The amount of token requested must be within the reverse
* The amount requested must be supperior to 0
*
*/ | function giveAway (address to, uint amountToMint) external onlyOwner{
require (to != address(0), "address 0 requested");
require (amountToMint <= _reserved, "You requested more than the reserved token");
require (amountToMint > 0, "Amount Issue");
uint currentSupply = to... | 0.8.1 |
/**
* @dev Return an array of token Id owned by `owner`
*/ | function getWallet(address _owner) public view returns(uint [] memory){
uint numberOwned = balanceOf(_owner);
uint [] memory idItems = new uint[](numberOwned);
for (uint i = 0; i < numberOwned; i++){
idItems[i] = tokenOfOwnerByIndex(_owner,i);
}
return... | 0.8.1 |
// https://ethereum.stackexchange.com/questions/19341/address-send-vs-address-transfer-best-practice-usage | function approve(
address payable _destination,
uint256 _amount
) public isMember sufficient(_amount) returns (bool) {
Approval storage approval = approvals[_destination][_amount]; // Create new project
if (!approval.coinciedeParties[msg.sender]) {
approval.coinciedePar... | 0.5.9 |
// @notice owner can start the sale by transferring in required amount of MYB
// @dev the start time is used to determine which day the sale is on (day 0 = first day) | function startSale(uint _timestamp)
external
onlyOwner
returns (bool){
require(start == 0, 'Already started');
require(_timestamp >= now && _timestamp.sub(now) < 2592000, 'Start time not in range');
uint saleAmount = tokensPerDay.mul(365);
require(mybToken.transferFrom(msg.sender, address(... | 0.4.25 |
// @notice Send an index of days and your payment will be divided equally among them
// @dev WEI sent must divide equally into number of days. | function batchFund(uint16[] _day)
payable
external
returns (bool) {
require(_day.length <= 50); // Limit to 50 days to avoid exceeding blocklimit
require(msg.value >= _day.length); // need at least 1 wei per day
uint256 amountPerDay = msg.value.div(_day.length);
assert (amountPerDay... | 0.4.25 |
// @notice Updates claimableTokens, sends all wei to the token holder | function withdraw(uint16 _day)
external
returns (bool) {
require(dayFinished(_day), "day has not finished funding");
Day storage thisDay = day[_day];
uint256 amount = getTokensOwed(msg.sender, _day);
delete thisDay.weiContributed[msg.sender];
mybToken.transfer(msg.sender, amount... | 0.4.25 |
// @notice Updates claimableTokens, sends all tokens to contributor from previous days
// @param (uint16[]) _day, list of token sale days msg.sender contributed wei towards | function batchWithdraw(uint16[] _day)
external
returns (bool) {
uint256 amount;
require(_day.length <= 50); // Limit to 50 days to avoid exceeding blocklimit
for (uint8 i = 0; i < _day.length; i++){
require(dayFinished(_day[i]));
uint256 amountToAdd = getTokensOwed(msg.sender, _da... | 0.4.25 |
// @notice updates ledger with the contribution from _investor
// @param (address) _investor: The sender of WEI to the contract
// @param (uint) _amount: The amount of WEI to add to _day
// @param (uint16) _day: The day to fund | function addContribution(address _investor, uint _amount, uint16 _day)
internal
returns (bool) {
require(_amount > 0, "must send ether with the call");
require(duringSale(_day), "day is not during the sale");
require(!dayFinished(_day), "day has already finished");
Day storage today = day[_day... | 0.4.25 |
// @notice gets the total amount of mybit owed to the contributor
// @dev this function doesn't check for duplicate days. Output may not reflect actual amount owed if this happens. | function getTotalTokensOwed(address _contributor, uint16[] _days)
public
view
returns (uint256 amount) {
require(_days.length < 100); // Limit to 100 days to avoid exceeding block gas limit
for (uint16 i = 0; i < _days.length; i++){
amount = amount.add(getTokensOwed(_contributor, _day... | 0.4.25 |
// @notice returns true if _day is finished | function dayFinished(uint16 _day)
public
view
returns (bool) {
if (now <= start) { return false; } // hasn't yet reached first day, so cannot be finished
return dayFor(now) > _day;
} | 0.4.25 |
/**
* @dev Implementation of IERC777Recipient.
*/ | function tokensReceived(
address /*operator*/,
address from,
address to,
uint256 amount,
bytes calldata userData,
bytes calldata /*operatorData*/
) external override {
address _tokenAddress = msg.sender;
require(supportedTokens.contains(_token... | 0.6.2 |
// Called to reward current KOTH winner and start new game | function rewardKoth() public {
if (msg.sender == feeAddress && lastBlock > 0 && block.number > lastBlock) {
uint fee = pot / 20; // 5%
KothWin(gameId, betId, koth, highestBet, pot, fee, firstBlock, lastBlock);
uint netPot = pot - fee;
address winner = koth;... | 0.4.16 |
//a new 'block' to be mined | function _startNewMiningEpoch() internal
{
//if max supply for the era will be exceeded next reward round then enter the new era before that happens
//4 is the final reward era, almost all tokens minted
//once the final era is reached, more tokens will not be given out because the assert fu... | 0.4.18 |
//10,000,000,000 coins total
//reward begins at 100,000 and is cut in half every reward era (as tokens are mined) | function getMiningReward() public constant returns (uint)
{
//once we get half way thru the coins, only get 50,000 per block
//every reward era, the reward amount halves.
return (100000 * 10**uint(decimals) ).div(5).mul(eraVsMaxSupplyFactor[rewardEra]) ;
} | 0.4.18 |
/// @notice Create an option order for a given NFT
/// @param optionPrice the price of the option
/// @param strikePrice the strike price of the option
/// @param settlementTimestamp the option maturity timestamp
/// @param nftId the token ID of the NFT relevant of this order
/// @param nftContract the address of the N... | function makeOrder(
uint256 optionPrice,
uint256 strikePrice,
uint256 settlementTimestamp,
uint256 nftId,
address nftContract,
NFTeacket.OptionType optionType
) external payable onlyWhenNFTeacketSet {
require(
settlementTimestamp > block.t... | 0.8.4 |
/// @notice Cancel a non filled order
/// @param makerTicketId the ticket ID associated with the order | function cancelOrder(uint256 makerTicketId) external onlyWhenNFTeacketSet {
NFTeacket _nfteacket = NFTeacket(nfteacket);
// Check the seender is the maker
_requireTicketOwner(msg.sender, makerTicketId);
NFTeacket.OptionDataMaker memory optionData = _nfteacket
.ticket... | 0.8.4 |
/// @dev When a trader wants to sell a call, he has to lock his NFT
/// until maturity
/// @param nftId the token ID of the NFT to lock
/// @param nftContractAddress address of the NFT contract | function _lockNft(uint256 nftId, address nftContractAddress) private {
IERC721 nftContract = IERC721(nftContractAddress);
address owner = nftContract.ownerOf(nftId);
require(owner == msg.sender, "NFTea : Not nft owner");
require(
address(this) == owner ||
... | 0.8.4 |
/**
* @dev See {ERC20-_beforeTokenTransfer}.
*
* Requirements:
*
* - minted tokens must not cause the total supply to go over the cap.
*/ | function _beforeTokenTransfer(address from, address to, uint256 amount) internal virtual override {
super._beforeTokenTransfer(from, to, amount);
if (from == address(0)) { // When minting tokens
require(totalSupply().add(amount) <= cap(), "ERC20Capped: cap exceeded");
}
} | 0.6.12 |
/* mapping (uint => address) public wikiToOwner;
mapping (address => uint) ownerWikiCount; */ | function createWikiPage(string _title, string _articleHash, string _imageHash, uint _price) public onlyOwner returns (uint) {
uint id = wikiPages.push(WikiPage(_title, _articleHash, _imageHash, _price)) - 1;
/* tokenOwner[id] = msg.sender;
ownedTokensCount[msg.sender]++; */
_ownMint(id);
} | 0.4.23 |
/**
* @return The result of safely multiplying x and y, interpreting the operands
* as fixed-point decimals of the specified precision unit.
*
* @dev The operands should be in the form of a the specified unit factor which will be
* divided out after the product of x and y is evaluated, so that product must be
* l... | function _multiplyDecimalRound(uint x, uint y, uint precisionUnit)
private
pure
returns (uint)
{
/* Divide by UNIT to remove the extra factor introduced by the product. */
uint quotientTimesTen = x.mul(y) / (precisionUnit / 10);
if (quotientTimesTen % 10 >= 5) {
... | 0.4.25 |
/**
* @return The result of safely dividing x and y. The return value is as a rounded
* decimal in the precision unit specified in the parameter.
*
* @dev y is divided after the product of x and the specified precision unit
* is evaluated, so the product of x and the specified precision unit must
* be less than 2... | function _divideDecimalRound(uint x, uint y, uint precisionUnit)
private
pure
returns (uint)
{
uint resultTimesTen = x.mul(precisionUnit * 10).div(y);
if (resultTimesTen % 10 >= 5) {
resultTimesTen += 10;
}
return resultTimesTen / 10;
} | 0.4.25 |
/**
* @dev Convert a high precision decimal to a standard decimal representation.
*/ | function preciseDecimalToDecimal(uint i)
internal
pure
returns (uint)
{
uint quotientTimesTen = i / (UNIT_TO_HIGH_PRECISION_CONVERSION_FACTOR / 10);
if (quotientTimesTen % 10 >= 5) {
quotientTimesTen += 10;
}
return quotientTimesTen / 10;
} | 0.4.25 |
/**
* @dev Perform an ERC20 token transferFrom. Designed to be called by transferFrom functions
* possessing the optionalProxy or optionalProxy modifiers.
*/ | function _transferFrom_byProxy(address sender, address from, address to, uint value)
internal
returns (bool)
{
/* Insufficient allowance will be handled by the safe subtraction. */
tokenState.setAllowance(from, sender, tokenState.allowance(from, sender).sub(value));
return _i... | 0.4.25 |
/**
* @dev Uses "exponentiation by squaring" algorithm where cost is 0(logN)
* vs 0(N) for naive repeated multiplication.
* Calculates x^n with x as fixed-point and n as regular unsigned int.
* Calculates to 18 digits of precision with SafeDecimalMath.unit()
*/ | function powDecimal(uint x, uint n)
internal
pure
returns (uint)
{
// https://mpark.github.io/programming/2014/08/18/exponentiation-by-squaring/
uint result = SafeDecimalMath.unit();
while (n > 0) {
if (n % 2 != 0) {
result = result.multip... | 0.4.25 |
/**
* @notice ERC20 transferFrom function
*/ | function transferFrom(address from, address to, uint value)
public
optionalProxy
returns (bool)
{
// Skip allowance update in case of infinite allowance
if (tokenState.allowance(from, messageSender) != uint(-1)) {
// Reduce the allowance by the amount we'r... | 0.4.25 |
/**
* @return A unit amount of decaying inflationary supply from the INITIAL_WEEKLY_SUPPLY
* @dev New token supply reduces by the decay rate each week calculated as supply = INITIAL_WEEKLY_SUPPLY * ()
*/ | function tokenDecaySupplyForWeek(uint counter)
public
pure
returns (uint)
{
// Apply exponential decay function to number of weeks since
// start of inflation smoothing to calculate diminishing supply for the week.
uint effectiveDecay = (SafeDecimalMath.unit().sub... | 0.4.25 |
/**
* @return A unit amount of terminal inflation supply
* @dev Weekly compound rate based on number of weeks
*/ | function terminalInflationSupply(uint totalSupply, uint numOfWeeks)
public
pure
returns (uint)
{
// rate = (1 + weekly rate) ^ num of weeks
uint effectiveCompoundRate = SafeDecimalMath.unit().add(TERMINAL_SUPPLY_RATE_ANNUAL.div(52)).powDecimal(numOfWeeks);
// retu... | 0.4.25 |
/**
* @dev Take timeDiff in seconds (Dividend) and MINT_PERIOD_DURATION as (Divisor)
* @return Calculate the numberOfWeeks since last mint rounded down to 1 week
*/ | function weeksSinceLastIssuance()
public
view
returns (uint)
{
// Get weeks since lastMintEvent
// If lastMintEvent not set or 0, then start from inflation start date.
uint timeDiff = lastMintEvent > 0 ? now.sub(lastMintEvent) : now.sub(INFLATION_START_DATE);
... | 0.4.25 |
/**
* @notice Record the mint event from Synthetix by incrementing the inflation
* week counter for the number of weeks minted (probabaly always 1)
* and store the time of the event.
* @param supplyMinted the amount of SNX the total supply was inflated by.
* */ | function recordMintEvent(uint supplyMinted)
external
onlySynthetix
returns (bool)
{
uint numberOfWeeksIssued = weeksSinceLastIssuance();
// add number of weeks minted to weekCounter
weekCounter = weekCounter.add(numberOfWeeksIssued);
// Update mint event to ... | 0.4.25 |
/**
* @notice Retrieve the last update time for a list of currencies
*/ | function lastRateUpdateTimesForCurrencies(bytes32[] currencyKeys)
public
view
returns (uint[])
{
uint[] memory lastUpdateTimes = new uint[](currencyKeys.length);
for (uint i = 0; i < currencyKeys.length; i++) {
lastUpdateTimes[i] = lastRateUpdateTimes(currencyKey... | 0.4.25 |
/**
* @notice Remove an inverse price for the currency key
* @param currencyKey The currency to remove inverse pricing for
*/ | function removeInversePricing(bytes32 currencyKey) external onlyOwner
{
require(inversePricing[currencyKey].entryPoint > 0, "No inverted price exists");
inversePricing[currencyKey].entryPoint = 0;
inversePricing[currencyKey].upperLimit = 0;
inversePricing[currencyKey].lowerLimit = 0... | 0.4.25 |
/**
* @notice Add a pricing aggregator for the given key. Note: existing aggregators may be overridden.
* @param currencyKey The currency key to add an aggregator for
*/ | function addAggregator(bytes32 currencyKey, address aggregatorAddress) external onlyOwner {
AggregatorInterface aggregator = AggregatorInterface(aggregatorAddress);
require(aggregator.latestTimestamp() >= 0, "Given Aggregator is invalid");
if (aggregators[currencyKey] == address(0)) {
... | 0.4.25 |
/**
* @notice Remove a single value from an array by iterating through until it is found.
* @param entry The entry to find
* @param array The array to mutate
* @return bool Whether or not the entry was found and removed
*/ | function removeFromArray(bytes32 entry, bytes32[] storage array) internal returns (bool) {
for (uint i = 0; i < array.length; i++) {
if (array[i] == entry) {
delete array[i];
// Copy the last key into the place of the one we just deleted
// If there's... | 0.4.25 |
/**
* @notice Remove a pricing aggregator for the given key
* @param currencyKey THe currency key to remove an aggregator for
*/ | function removeAggregator(bytes32 currencyKey) external onlyOwner {
address aggregator = aggregators[currencyKey];
require(aggregator != address(0), "No aggregator exists for key");
delete aggregators[currencyKey];
bool wasRemoved = removeFromArray(currencyKey, aggregatorKeys);
... | 0.4.25 |
/**
* @notice A function that lets you easily convert an amount in a source currency to an amount in the destination currency
* @param sourceCurrencyKey The currency the amount is specified in
* @param sourceAmount The source amount, specified in UNIT base
* @param destinationCurrencyKey The destination currency
*... | function effectiveValue(bytes32 sourceCurrencyKey, uint sourceAmount, bytes32 destinationCurrencyKey)
public
view
rateNotStale(sourceCurrencyKey)
rateNotStale(destinationCurrencyKey)
returns (uint)
{
// If there's no change in the currency, then just return the amount... | 0.4.25 |
/**
* @notice Retrieve the rates for a list of currencies
*/ | function ratesForCurrencies(bytes32[] currencyKeys)
public
view
returns (uint[])
{
uint[] memory _localRates = new uint[](currencyKeys.length);
for (uint i = 0; i < currencyKeys.length; i++) {
_localRates[i] = rates(currencyKeys[i]);
}
return _lo... | 0.4.25 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.