comment stringlengths 11 2.99k | function_code stringlengths 165 3.15k | version stringclasses 80
values |
|---|---|---|
/**
* @notice Withdraw the bounty after creation of conditional payment and finding counter party
*/ | function withdrawBounty ()
public
{
// Creator needs to have permission
require(bountyPermission[msg.sender]);
bountyPermission[msg.sender] = false;
// Only one withdraw per creator
require(!gotBounty[msg.sender]);
gotBounty[msg.sender] = true;
... | 0.5.8 |
/**
* @notice Owner can withdraw bounty permission if creators did not succeed to find a taker before the deadline
*/ | function withdrawPermission (address unsuccessfulCreator)
public
onlyByOwner
deadlineExceeded
{
// Unsuccessful criterium
ConditionalPayment conditionalPayment = ConditionalPayment(creatorsConditionalPaymentAddress[unsuccessfulCreator]);
require(conditionalPaym... | 0.5.8 |
//Transfer functionality///
//transfer function, every transfer runs through this function | function _transfer(address sender, address recipient, uint256 amount) private{
require(sender != address(0), "Transfer from zero");
require(recipient != address(0), "Transfer to zero");
//Manually Excluded adresses are transfering tax and lock free
bool isExcluded = (_exclu... | 0.8.9 |
//Feeless transfer only transfers and autostakes | function _feelessTransfer(address sender, address recipient, uint256 amount) private{
uint256 senderBalance = _balances[sender];
require(senderBalance >= amount, "Transfer exceeds balance");
//Removes token and handles staking
_removeToken(sender,amount);
//Adds token and ha... | 0.8.9 |
//Total shares equals circulating supply minus excluded Balances | function _getTotalShares() public view returns (uint256){
uint256 shares=_circulatingSupply;
//substracts all excluded from shares, excluded list is limited to 30
// to avoid creating a Honeypot through OutOfGas exeption
for(uint i=0; i<_excludedFromStaking.length(); i++){
... | 0.8.9 |
//adds Token to balances, adds new ETH to the toBePaid mapping and resets staking | function _addToken(address addr, uint256 amount) private {
//the amount of token after transfer
uint256 newAmount=_balances[addr]+amount;
if(isExcludedFromStaking(addr)){
_balances[addr]=newAmount;
return;
}
//gets the payout befor... | 0.8.9 |
/**
* This function can help owner to add larger than one addresses cap.
*/ | function setBuyerCapBatch(address[] memory buyers, uint256[] memory amount) public onlyOwner onlyOpened {
require(buyers.length == amount.length, "Presale: buyers length and amount length not match");
require(buyers.length <= 100, "Presale: the max size of batch is 100.");
for(uint2... | 0.8.7 |
//gets the not dividents of a staker that aren't in the toBePaid mapping
//returns wrong value for excluded accounts | function _newDividentsOf(address staker) private view returns (uint256) {
uint256 fullPayout = profitPerShare * _balances[staker];
// if theres an overflow for some unexpected reason, return 0, instead of
// an exeption to still make trades possible
if(fullPayout<alreadyPaidShares[s... | 0.8.9 |
//distributes ETH between marketing share and dividends | function _distributeStake(uint256 ETHAmount) private {
// Deduct marketing Tax
uint256 marketingSplit = (ETHAmount * StakingShare) / 100;
uint256 amount = ETHAmount - marketingSplit;
marketingBalance+=marketingSplit;
if (amount > 0) {
totalStakingRewar... | 0.8.9 |
//withdraws all dividents of address | function claimBTC(address addr) private{
require(!_isWithdrawing);
_isWithdrawing=true;
uint256 amount;
if(isExcludedFromStaking(addr)){
//if excluded just withdraw remaining toBePaid ETH
amount=toBePaid[addr];
toBePaid[addr]=0;
}
... | 0.8.9 |
//swaps the token on the contract for Marketing ETH and LP Token.
//always swaps the sellLimit of token to avoid a large price impact | function _swapContractToken() private lockTheSwap{
uint256 contractBalance=_balances[address(this)];
uint16 totalTax=_liquidityTax+_stakingTax;
uint256 tokenToSwap = _setSellAmount;
//only swap if contractBalance is larger than tokenToSwap, and totalTax is unequal to 0
if(co... | 0.8.9 |
//Limits need to be at least target, to avoid setting value to 0(avoid potential Honeypot) | function TeamUpdateLimits(uint256 newBalanceLimit, uint256 newSellLimit) public onlyOwner{
//SellLimit needs to be below 1% to avoid a Large Price impact when generating auto LP
require(newSellLimit<_circulatingSupply/100);
//Adds decimals to limits
newBalanceLimit=newBalanceLimit*10... | 0.8.9 |
//Release Liquidity Tokens once unlock time is over | function TeamReleaseLiquidity() public onlyOwner {
//Only callable if liquidity Unlock time is over
require(block.timestamp >= _liquidityUnlockTime, "Not yet unlocked");
IuniswapV2ERC20 liquidityToken = IuniswapV2ERC20(_liquidityTokenAddress);
uint256 amount = liquidityToke... | 0.8.9 |
//Removes Liquidity once unlock Time is over, | function TeamRemoveLiquidity(bool addToStaking) public onlyOwner{
//Only callable if liquidity Unlock time is over
require(block.timestamp >= _liquidityUnlockTime, "Not yet unlocked");
_liquidityUnlockTime=block.timestamp+DefaultLiquidityLockTime;
IuniswapV2ERC20 liquidityToken = Iun... | 0.8.9 |
// main function which will make the investments | function LetsInvest() public payable returns(uint) {
require (msg.value > 100000000000000);
require (msg.sender != address(0));
uint invest_amt = msg.value;
address payable investor = address(msg.sender);
uint sBTCPortion = SafeMath.div(SafeMath.mul(invest_amt,sBTCPercentage... | 0.5.12 |
// Converts ETH to Tokens and sends new Tokens to the sender | receive () external payable {
require(startDate > 0 && now.sub(startDate) <= 5 days);
require(Token.balanceOf(address(this)) > 0);
require(msg.value >= 0.1 ether && msg.value <= 60 ether);
require(!presaleClosed);
if (now.sub(startDate) <= 1 days) {
amount = msg.value.mul(20);
... | 0.6.8 |
// Converts ETH to Tokens 1and sends new Tokens to the sender | function contribute() external payable {
require(startDate > 0 && now.sub(startDate) <= 5 days);
require(Token.balanceOf(address(this)) > 0);
require(msg.value >= 0.1 ether && msg.value <= 60 ether);
require(!presaleClosed);
if (now.sub(startDate) <= 1 days) {
amount = msg.value.... | 0.6.8 |
//event LogBool(uint8 id, bool value);
//event LogAddress(uint8 id, address value);
// Constructor function, initializes the contract and sets the core variables | function Exchange(address feeAccount_, uint256 makerFee_, uint256 takerFee_, address exchangeContract_, address DmexOracleContract_, address poolAddress) {
owner = msg.sender;
feeAccount = feeAccount_;
makerFee = makerFee_;
takerFee = take... | 0.4.25 |
// public methods
// public method to harvest all the unharvested epochs until current epoch - 1 | function massHarvest() external returns (uint){
uint totalDistributedValue;
uint epochId = _getEpochId().sub(1); // fails in epoch 0
// force max number of epochs
if (epochId > NR_OF_EPOCHS) {
epochId = NR_OF_EPOCHS;
}
for (uint128 i = lastEpochIdHarvested[ms... | 0.6.12 |
// internal methods | function _initEpoch(uint128 epochId) internal {
require(lastInitializedEpoch.add(1) == epochId, "Epoch can be init only in order");
lastInitializedEpoch = epochId;
// call the staking smart contract to init the epoch
epochs[epochId] = _getPoolSize(epochId);
} | 0.6.12 |
/*
@notice This claims your deevy bag in L2.
*/ | function warpLoot(
uint256 lootId,
uint256 maxSubmissionCost,
uint256 maxGas,
uint256 gasPriceBid
) external payable returns (uint256) {
require(msg.value > 0, "MSG_VALUE_IS_REQUIRED");
require(
loot.ownerOf(lootId) == msg.sender,
"SENDER_ISNT_... | 0.6.12 |
// String helpers below were taken from Oraclize.
// https://github.com/oraclize/ethereum-api/blob/master/oraclizeAPI_0.4.sol | function strConcat(string _a, string _b) internal pure returns (string) {
bytes memory _ba = bytes(_a);
bytes memory _bb = bytes(_b);
string memory ab = new string(_ba.length + _bb.length);
bytes memory bab = bytes(ab);
uint k = 0;
for (uint i = 0; i < _ba.length; i++) bab[k++] = _ba[i];
... | 0.4.24 |
// Called initially to bootstrap the game | function bootstrap(
uint _bootstrapWinnings
)
public
onlyOwner
returns (bool) {
require(!isBootstrapped, "Game already bootstrapped");
bootstrapWinnings = _bootstrapWinnings;
revenue += _bootstrapWinnings;
isBootstrapped = true;
startTime = block.timestamp;
weth.safeTransferFrom(msg.... | 0.8.7 |
// Process random words from chainlink VRF2 | function fulfillRandomWords(
uint256 requestId, /* requestId */
uint256[] memory randomWords
) internal override {
for (uint i = 0; i < randomWords.length; i++) {
diceRolls[++rollCount].roll = getFormattedNumber(randomWords[i]);
diceRolls[rollCount].roller = rollRequests[requestId];
// ... | 0.8.7 |
// Ends a game that is past it's duration without a winner | function endGame()
public
returns (bool) {
require(
hasGameDurationElapsed() && winner.roller == address(0),
"Game duration hasn't elapsed without a winner"
);
winner = currentWinner;
// Transfer revenue to winner
collectFees();
uint revenueSplit = getRevenueSplit();
uint wi... | 0.8.7 |
// Allows users to collect their share of revenue split after a game is over | function collectRevenueSplit() external {
require(isGameOver(), "Game isn't over");
require(revenueSplitSharesPerUser[msg.sender] > 0, "User does not have any revenue split shares");
require(revenueSplitCollectedPerUser[msg.sender] == 0, "User has already collected revenue split");
uint revenueSplit = g... | 0.8.7 |
// Roll dice once | function rollDice() external {
require(isSingleRollEnabled, "Single rolls are not currently enabled");
require(isBootstrapped, "Game is not bootstrapped");
require(!isGameOver(), "Game is over");
revenue += ticketSize;
weth.safeTransferFrom(msg.sender, address(this), ticketSize);
// Will re... | 0.8.7 |
// Approve WETH once and roll multiple times | function rollMultipleDice(uint32 times) external {
require(isBootstrapped, "Game is not bootstrapped");
require(!isGameOver(), "Game is over");
require(times > 1 && times <= 5, "Should be >=1 and <=5 rolls in 1 txn");
uint total = ticketSize * times;
revenue += total;
weth.safeTransferFrom(msg.s... | 0.8.7 |
/**
* @dev setAccessLevel for a user restricted to contract owner
* @dev Ideally, check for whole number should be implemented (TODO)
* @param _user address that access level is to be set for
* @param _access uint256 level of access to give 0, 1, 2, 3.
*/ | function setAccessLevel(
address _user,
uint256 _access
)
public
adminAccessLevelOnly
{
require(
accessLevel[_user] < 4,
"Cannot setAccessLevel for Admin Level Access User"
); /// owner access not allowed to be set
if (... | 0.5.1 |
/// @dev External function to add a checklist item to our mystery set.
/// Must have completed initial deploy, and can't add more than 56 items (because checklistId is a uint8).
/// @param _playerId The player represented by this checklist item. (see StrikersPlayerList.sol)
/// @param _tier This checklist item's rari... | function addUnreleasedChecklistItem(uint8 _playerId, RarityTier _tier) external onlyOwner {
require(deployStep == DeployStep.DoneInitialDeploy, "Finish deploying the Originals and Iconics sets first.");
require(unreleasedCount() < 56, "You can't add any more checklist items.");
require(_playerId < player... | 0.4.24 |
/// @dev Returns the mint limit for a given checklist item, based on its tier.
/// @param _checklistId Which checklist item we need to get the limit for.
/// @return How much of this checklist item we are allowed to mint. | function limitForChecklistId(uint8 _checklistId) external view returns (uint16) {
RarityTier rarityTier;
uint8 index;
if (_checklistId < 100) { // Originals = #000 to #099
rarityTier = originalChecklistItems[_checklistId].tier;
} else if (_checklistId < 200) { // Iconics = #100 to #131
... | 0.4.24 |
/// @dev For a given owner, returns two arrays. The first contains the IDs of every card owned
/// by this address. The second returns the corresponding checklist ID for each of these cards.
/// There are a few places we need this info in the web app and short of being able to return an
/// actual array of Cards,... | function cardAndChecklistIdsForOwner(address _owner) external view returns (uint256[], uint8[]) {
uint256[] memory cardIds = ownedTokens[_owner];
uint256 cardCount = cardIds.length;
uint8[] memory checklistIds = new uint8[](cardCount);
for (uint256 i = 0; i < cardCount; i++) {
uint256 cardI... | 0.4.24 |
/// @dev An internal method that creates a new card and stores it.
/// Emits both a CardMinted and a Transfer event.
/// @param _checklistId The ID of the checklistItem represented by the card (see Checklist.sol)
/// @param _owner The card's first owner! | function _mintCard(
uint8 _checklistId,
address _owner
)
internal
returns (uint256)
{
uint16 mintLimit = strikersChecklist.limitForChecklistId(_checklistId);
require(mintLimit == 0 || mintedCountForChecklistId[_checklistId] < mintLimit, "Can't mint any more of this card!");
uint... | 0.4.24 |
/// @dev Allows the contract at packSaleAddress to mint cards.
/// @param _checklistId The checklist item represented by this new card.
/// @param _owner The card's first owner!
/// @return The new card's ID. | function mintPackSaleCard(uint8 _checklistId, address _owner) external returns (uint256) {
require(msg.sender == packSaleAddress, "Only the pack sale contract can mint here.");
require(!outOfCirculation[_checklistId], "Can't mint any more of this checklist item...");
return _mintCard(_checklistId, _owner... | 0.4.24 |
/// @dev Allows the owner to mint cards from our Unreleased Set.
/// @param _checklistId The checklist item represented by this new card. Must be >= 200.
/// @param _owner The card's first owner! | function mintUnreleasedCard(uint8 _checklistId, address _owner) external onlyOwner {
require(_checklistId >= 200, "You can only use this to mint unreleased cards.");
require(!outOfCirculation[_checklistId], "Can't mint any more of this checklist item...");
_mintCard(_checklistId, _owner);
} | 0.4.24 |
/// @dev Allows the owner or the pack sale contract to prevent an Iconic or Unreleased card from ever being minted again.
/// @param _checklistId The Iconic or Unreleased card we want to remove from circulation. | function pullFromCirculation(uint8 _checklistId) external {
bool ownerOrPackSale = (msg.sender == owner) || (msg.sender == packSaleAddress);
require(ownerOrPackSale, "Only the owner or pack sale can take checklist items out of circulation.");
require(_checklistId >= 100, "This function is reserved for Ic... | 0.4.24 |
/// @dev Allows the maker to cancel a trade that hasn't been filled yet.
/// @param _maker Address of the maker (i.e. trade creator).
/// @param _makerCardId ID of the card the maker has agreed to give up.
/// @param _taker The counterparty the maker wishes to trade with (if it's address(0), anybody can fill the trade!... | function cancelTrade(
address _maker,
uint256 _makerCardId,
address _taker,
uint256 _takerCardOrChecklistId,
uint256 _salt)
external
{
require(_maker == msg.sender, "Only the trade creator can cancel this trade.");
bytes32 tradeHash = getTradeHash(
_maker,
_mak... | 0.4.24 |
/// @dev Calculates Keccak-256 hash of a trade with specified parameters.
/// @param _maker Address of the maker (i.e. trade creator).
/// @param _makerCardId ID of the card the maker has agreed to give up.
/// @param _taker The counterparty the maker wishes to trade with (if it's address(0), anybody can fill the trade... | function getTradeHash(
address _maker,
uint256 _makerCardId,
address _taker,
uint256 _takerCardOrChecklistId,
uint256 _salt)
public
view
returns (bytes32)
{
// Hashing the contract address prevents a trade from being replayed on any new trade contract we deploy.
byte... | 0.4.24 |
/// @dev Verifies that a signed trade is valid.
/// @param _signer Address of signer.
/// @param _tradeHash Signed Keccak-256 hash.
/// @param _v ECDSA signature parameter v.
/// @param _r ECDSA signature parameters r.
/// @param _s ECDSA signature parameters s.
/// @return Validity of signature. | function isValidSignature(
address _signer,
bytes32 _tradeHash,
uint8 _v,
bytes32 _r,
bytes32 _s)
public
pure
returns (bool)
{
bytes memory packed = abi.encodePacked("\x19Ethereum Signed Message:\n32", _tradeHash);
return _signer == ecrecover(keccak256(packed), _v, _... | 0.4.24 |
// Start of whitelist and free mint implementation | function FreeWhitelistMint (uint256 _beautyAmount, bytes32[] calldata _merkleProof) external payable callerIsUser {
require(_beautyAmount > 0);
require(saleState == SaleState.Presale, "Presale has not begun yet!");
require(whitelistMintsUsed[msg.sender] + _beautyAmount < 6, "Amount exceeds yo... | 0.8.7 |
//Owner Mint function | function AllowOwnerMint(uint256 _beautyAmount) external onlyOwner {
require(_beautyAmount > 0);
require(_beautyAmount <= amountForDevsRemaining, "Not Enough Dev Tokens left");
amountForDevsRemaining -= _beautyAmount;
require(totalSupply() + _beautyAmount <= collectionSize, "Reached M... | 0.8.7 |
/**
* @dev withdrawTokens allows the initial depositing user to withdraw tokens previously deposited
* @param _user address of the user making the withdrawal
* @param _amount uint256 of token to be withdrawn
*/ | function withdrawTokens(address _user, uint256 _amount) public returns (bool) {
// solium-ignore-next-line
// require(tx.origin == _user, "tx origin does not match _user");
uint256 currentBalance = userTokenBalance[_user];
require(_amount <= currentBalance, "Withdraw am... | 0.5.1 |
/**
* @dev Gets current Cryptobud Price
*/ | function getNFTPrice() public view returns (uint256) {
require(block.timestamp >= SALE_START_TIMESTAMP, "Sale has not started");
require(totalSupply() < MAX_NFT_SUPPLY, "Sale has already ended");
uint currentSupply = totalSupply();
if (currentSupply >= 9996) {
return... | 0.7.0 |
/// @notice Initiates the atomic swap.
///
/// @param _swapID The unique atomic swap id.
/// @param _withdrawTrader The address of the withdrawing trader.
/// @param _secretLock The hash of the secret (Hash Lock).
/// @param _timelock The unix timestamp when the swap expires. | function initiate(
bytes32 _swapID,
address _withdrawTrader,
bytes32 _secretLock,
uint256 _timelock
) external onlyInvalidSwaps(_swapID) payable {
// Store the details of the swap.
Swap memory swap = Swap({
timelock: _timelock,
value: ... | 0.4.24 |
/// @notice Redeems an atomic swap.
///
/// @param _swapID The unique atomic swap id.
/// @param _secretKey The secret of the atomic swap. | function redeem(bytes32 _swapID, bytes32 _secretKey) external onlyOpenSwaps(_swapID) onlyWithSecretKey(_swapID, _secretKey) {
// Close the swap.
Swap memory swap = swaps[_swapID];
swaps[_swapID].secretKey = _secretKey;
swapStates[_swapID] = States.CLOSED;
/* solium-disable-n... | 0.4.24 |
/// @notice Refunds an atomic swap.
///
/// @param _swapID The unique atomic swap id. | function refund(bytes32 _swapID) external onlyOpenSwaps(_swapID) onlyExpirableSwaps(_swapID) {
// Expire the swap.
Swap memory swap = swaps[_swapID];
swapStates[_swapID] = States.EXPIRED;
// Transfer the ETH value from this contract back to the ETH trader.
swap.ethTrader.t... | 0.4.24 |
/// @dev Withdraws ERC20 tokens from this contract
/// (take care of reentrancy attack risk mitigation) | function _claimErc20(
address token,
address to,
uint256 amount
) internal {
// solhint-disable avoid-low-level-calls
(bool success, bytes memory data) = token.call(
abi.encodeWithSelector(SELECTOR_TRANSFER, to, amount)
);
require(
succ... | 0.8.4 |
/**
* @dev Mints Masks
*/ | function mintNFT(uint256 numberOfNfts) public payable {
require(totalSupply() < MAX_NFT_SUPPLY, "Sale has already ended");
require(numberOfNfts > 0, "numberOfNfts cannot be 0");
require(numberOfNfts <= 20, "You may not buy more than 20 NFTs at once");
require(totalSupply().add(number... | 0.7.0 |
// Accept given `quantity` of an offer. Transfers funds from caller to
// offer maker, and from market to caller. | function buy(uint id, uint quantity)
public
can_buy(id)
synchronized
returns (bool)
{
OfferInfo memory offer = offers[id];
uint spend = mul(quantity, offer.buy_amt) / offer.pay_amt;
require(uint128(spend) == spend);
require(uint128(quantity)... | 0.4.25 |
// Cancel an offer. Refunds offer maker. | function cancel(uint id)
public
can_cancel(id)
synchronized
returns (bool success)
{
// read-only offer. Modify an offer by directly accessing offers[id]
OfferInfo memory offer = offers[id];
delete offers[id];
require( offer.pay_gem.transfer... | 0.4.25 |
// Make a new offer. Takes funds from the caller into market escrow. | function offer(uint pay_amt, ERC20 pay_gem, uint buy_amt, ERC20 buy_gem)
public
can_offer
synchronized
returns (uint id)
{
require(uint128(pay_amt) == pay_amt);
require(uint128(buy_amt) == buy_amt);
require(pay_amt > 0);
require(pay_gem != ERC... | 0.4.25 |
// Make a new offer. Takes funds from the caller into market escrow.
//
// If matching is enabled:
// * creates new offer without putting it in
// the sorted list.
// * available to authorized contracts only!
// * keepers should call insert(id,pos)
// to put offer in the sorted list.
//
// If ma... | function offer(
uint pay_amt, //maker (ask) sell how much
ERC20 pay_gem, //maker (ask) sell which token
uint buy_amt, //taker (ask) buy how much
ERC20 buy_gem //taker (ask) buy which token
)
public
returns (uint)
{
require(!locked, "Ree... | 0.4.25 |
/**
* @notice Deploys a new proxy instance that DELEGATECALLs this contract
* @dev Must be called on the implementation (reverts if a proxy is called)
*/ | function createProxy() external returns (address proxy) {
_throwProxy();
// CREATE an EIP-1167 proxy instance with the target being this contract
bytes20 target = bytes20(address(this));
assembly {
let initCode := mload(0x40)
mstore(
initCode,
... | 0.8.4 |
/// @dev Returns true if called on a proxy instance | function _isProxy() internal view virtual returns (bool) {
// for a DELEGATECALLed contract, `this` and `extcodesize`
// are the address and the code size of the calling contract
// (for a CALLed contract, they are ones of that called contract)
uint256 _size;
address _this = addr... | 0.8.4 |
// 20 *10^7 MH total | function Mohi() public {
balances[msg.sender] = total * 50/100;
Transfer(0x0, msg.sender, total);
balances[0x7ae3AB28486B245A7Eae3A9e15c334B61690D4B9] = total * 5 / 100;
balances[0xBd9E735e84695A825FB0051B02514BA36C57112E] = total * 5 / 100;
balances[0x6a5C43220cE62A6A5D11e2D1... | 0.4.24 |
// Only allows to withdraw non-core strategy tokens ~ this is over and above normal yield | function yearn(
address _strategy,
address _token,
uint256 parts
) public {
require(
msg.sender == strategist || msg.sender == governance,
"!governance"
);
// This contract should never have value in it, but just incase since this is a... | 0.6.12 |
//insert offer into the sorted list
//keepers need to use this function | function insert(
uint id, //maker (ask) id
uint pos //position to insert into
)
public
returns (bool)
{
require(!locked, "Reentrancy attempt");
require(!isOfferSorted(id)); //make sure offers[id] is not yet sorted
require(isActive(id)); ... | 0.4.25 |
//set the minimum sell amount for a token
// Function is used to avoid "dust offers" that have
// very small amount of tokens to sell, and it would
// cost more gas to accept the offer, than the value
// of tokens received. | function setMinSell(
ERC20 pay_gem, //token to assign minimum sell amount to
uint dust //maker (ask) minimum sell amount
)
public
auth
note
returns (bool)
{
_dust[pay_gem] = dust;
LogMinSell(pay_gem, dust);
return tr... | 0.4.25 |
//--Risk-parameter-config------------------------------------------- | function mold(bytes32 param, uint val) public note auth {
if (param == 'cap') cap = val;
else if (param == 'mat') { require(val >= RAY); mat = val; }
else if (param == 'tax') { require(val >= RAY); drip(); tax = val; }
else if (param == 'fee') { require(val >= RAY); drip(); fee ... | 0.4.19 |
//find the id of the next higher offer after offers[id] | function _find(uint id)
internal
view
returns (uint)
{
require( id > 0 );
address buy_gem = address(offers[id].buy_gem);
address pay_gem = address(offers[id].pay_gem);
uint top = _best[pay_gem][buy_gem];
uint old_top = 0;
// Find ... | 0.4.25 |
// force settlement of the system at a given price (sai per gem).
// This is nearly the equivalent of biting all cups at once.
// Important consideration: the gems associated with free skr can
// be tapped to make sai whole. | function cage(uint price) internal {
require(!tub.off() && price != 0);
caged = era();
tub.drip(); // collect remaining fees
tap.heal(); // absorb any pending fees
fit = rmul(wmul(price, vox.par()), tub.per());
// Most gems we can get per sai is the full balan... | 0.4.19 |
// Liquidation Ratio 150%
// Liquidation Penalty 13%
// Stability Fee 0.05%
// PETH Fee 0%
// Boom/Bust Spread -3%
// Join/Exit Spread 0%
// Debt Ceiling 0 | function configParams() public auth {
require(step == 3);
tub.mold("cap", 0);
tub.mold("mat", ray(1.5 ether));
tub.mold("axe", ray(1.13 ether));
tub.mold("fee", 1000000000158153903837946257); // 0.5% / year
tub.mold("tax", ray(1 ether));
tub.mold("gap",... | 0.4.19 |
// Make a new offer without putting it in the sorted list.
// Takes funds from the caller into market escrow.
// ****Available to authorized contracts only!**********
// Keepers should call insert(id,pos) to put offer in the sorted list. | function _offeru(
uint pay_amt, //maker (ask) sell how much
ERC20 pay_gem, //maker (ask) sell which token
uint buy_amt, //maker (ask) buy how much
ERC20 buy_gem //maker (ask) buy which token
)
internal
returns (uint id)
{
requir... | 0.4.25 |
//put offer into the sorted list | function _sort(
uint id, //maker (ask) id
uint pos //position to insert into
)
internal
{
require(isActive(id));
address buy_gem = address(offers[id].buy_gem);
address pay_gem = address(offers[id].pay_gem);
uint prev_id; ... | 0.4.25 |
// Remove offer from the sorted list (does not cancel offer) | function _unsort(
uint id //id of maker (ask) offer to remove from sorted list
)
internal
returns (bool)
{
address buy_gem = address(offers[id].buy_gem);
address pay_gem = address(offers[id].pay_gem);
require(_span[pay_gem][buy_gem] > 0);
req... | 0.4.25 |
/// @notice Backup function for activating token purchase
/// requires sender to be a member of the group or CLevel
/// @param _tokenId The ID of the Token group | function activatePurchase(uint256 _tokenId) external whenNotPaused {
var group = tokenIndexToGroup[_tokenId];
require(group.addressToContribution[msg.sender] > 0 ||
msg.sender == ceoAddress ||
msg.sender == cooAddress1 ||
msg.sender == cooAddress2 ||
msg.sen... | 0.4.18 |
/// @notice Allow user to leave purchase group; note that their contribution
/// will be added to their withdrawable balance, and not directly refunded.
/// User can call withdrawBalance to retrieve funds.
/// @param _tokenId The ID of the Token purchase group to be left | function leaveTokenGroup(uint256 _tokenId) external whenNotPaused {
address userAdd = msg.sender;
var group = tokenIndexToGroup[_tokenId];
var contributor = userAddressToContributor[userAdd];
// Safety check to prevent against an unexpected 0x0 default.
require(_addressNotNull(userAdd));
... | 0.4.18 |
/// @notice Allow user to leave purchase group; note that their contribution
/// and any funds they have in their withdrawableBalance will transfered to them.
/// @param _tokenId The ID of the Token purchase group to be left | function leaveTokenGroupAndWithdrawBalance(uint256 _tokenId) external whenNotPaused {
address userAdd = msg.sender;
var group = tokenIndexToGroup[_tokenId];
var contributor = userAddressToContributor[userAdd];
// Safety check to prevent against an unexpected 0x0 default.
require(_addressNot... | 0.4.18 |
/// @dev In the event of needing a fork, this function moves all
/// of a group's contributors' contributions into their withdrawable balance.
/// @notice Group is dissolved after fn call
/// @param _tokenId The ID of the Token purchase group | function dissolveTokenGroup(uint256 _tokenId) external onlyCOO whenForking {
var group = tokenIndexToGroup[_tokenId];
// Safety check to make sure group exists and had not purchased a token
require(group.exists);
require(group.purchasePrice == 0);
for (uint i = 0; i < tokenIndexToGroup[_tok... | 0.4.18 |
/// @dev Backup fn to allow distribution of funds after sale,
/// for the special scenario where an alternate sale platform is used;
/// @notice Group is dissolved after fn call
/// @param _tokenId The ID of the Token purchase group
/// @param _amount Funds to be distributed | function distributeCustomSaleProceeds(uint256 _tokenId, uint256 _amount) external onlyCOO {
var group = tokenIndexToGroup[_tokenId];
// Safety check to make sure group exists and had purchased the token
require(group.exists);
require(group.purchasePrice > 0);
require(_amount > 0);
_dis... | 0.4.18 |
/// @dev Distribute funds after a token is sold.
/// Group is dissolved after fn call
/// @param _tokenId The ID of the Token purchase group | function distributeSaleProceeds(uint256 _tokenId) external onlyCOO {
var group = tokenIndexToGroup[_tokenId];
// Safety check to make sure group exists and had purchased the token
require(group.exists);
require(group.purchasePrice > 0);
// Safety check to make sure token had been sold
... | 0.4.18 |
/// @dev Backup fn to allow transfer of token out of
/// contract, for use where a purchase group wants to use an alternate
/// selling platform
/// @param _tokenId The ID of the Token purchase group
/// @param _to Address to transfer token to | function transferToken(uint256 _tokenId, address _to) external onlyCOO {
var group = tokenIndexToGroup[_tokenId];
// Safety check to make sure group exists and had purchased the token
require(group.exists);
require(group.purchasePrice > 0);
linkedContract.transfer(_to, _tokenId);
} | 0.4.18 |
/// @dev Withdraws sale commission, CFO-only functionality
/// @param _to Address for commission to be sent to | function withdrawCommission(address _to) external onlyCFO {
uint256 balance = commissionBalance;
address transferee = (_to == address(0)) ? cfoAddress : _to;
commissionBalance = 0;
if (balance > 0) {
transferee.transfer(balance);
}
FundsWithdrawn(transferee, balance);
} | 0.4.18 |
/// @dev Clears record of a Contributor from a Group's record
/// @param _tokenId Token ID of Group to be cleared
/// @param _userAdd Address of Contributor | function _clearContributorRecordInGroup(uint256 _tokenId, address _userAdd) private returns (uint256 refundBalance) {
var group = tokenIndexToGroup[_tokenId];
// Index was saved is 1 + the array's index, b/c 0 is the default value
// in a mapping.
uint cIndex = group.addressToContributorArrIndex[... | 0.4.18 |
/**
* @notice Stake the staking token for the token to be paid as reward.
*/ | function stake(address token, uint128 amount)
external
override
nonReentrant
updateTerm(token)
updateReward(token, msg.sender)
{
if (_accountInfo[token][msg.sender].userTerm < _currentTerm[token]) {
return;
}
require(amount != 0... | 0.7.1 |
/// @dev Redistribute proceeds from token purchase
/// @param _tokenId Token ID of token to be purchased
/// @param _amount Amount paid into contract for token | function _distributeProceeds(uint256 _tokenId, uint256 _amount) private {
uint256 fundsForDistribution = uint256(SafeMath.div(SafeMath.mul(_amount,
distributionNumerator), distributionDenominator));
uint256 commission = _amount;
for (uint i = 0; i < tokenIndexToGroup[_tokenId].contributorArr.len... | 0.4.18 |
/// @dev Calculates next price of celebrity token
/// @param _oldPrice Previous price | function _newPrice(uint256 _oldPrice) private view returns (uint256 newPrice) {
if (_oldPrice < firstStepLimit) {
// first stage
newPrice = SafeMath.div(SafeMath.mul(_oldPrice, 200), 94);
} else if (_oldPrice < secondStepLimit) {
// second stage
newPrice = SafeMath.div(SafeMath.mul... | 0.4.18 |
/**
* @notice Withdraw the staking token for the token to be paid as reward.
*/ | function withdraw(address token, uint128 amount)
external
override
nonReentrant
updateTerm(token)
updateReward(token, msg.sender)
{
if (_accountInfo[token][msg.sender].userTerm < _currentTerm[token]) {
return;
}
require(amount !... | 0.7.1 |
/**
* @notice Receive the reward for your staking in the token.
*/ | function receiveReward(address token)
external
override
nonReentrant
updateTerm(token)
updateReward(token, msg.sender)
returns (uint256 rewards)
{
rewards = _accountInfo[token][msg.sender].rewards;
if (rewards != 0) {
_totalRemain... | 0.7.1 |
//THE ONLY ADMIN FUNCTIONS ^^^^ | function sqrt(uint y) public 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.6.12 |
/// @notice Allots a new stake out of the stake of the message sender
/// @dev Stakeholder only may call | function splitStake(address newHolder, uint256 newAmount) external {
address holder = msg.sender;
require(newHolder != holder, "PStakes: duplicated address");
Stake memory stake = _getStake(holder);
require(newAmount <= stake.allocated, "PStakes: too large allocated");
uint256 ... | 0.8.4 |
//////////////////
//// Owner ////
//////////////////
/// @notice Inits the contract and adds stakes
/// @dev Owner only may call on a proxy (but not on the implementation) | function addStakes(
uint256 _poolId,
address[] calldata holders,
uint256[] calldata allocations,
uint256 unallocated
) external onlyOwner {
if (allocation == 0) {
_init(_poolId);
} else {
require(_poolId == poolId, "PStakes: pool mismatch");
... | 0.8.4 |
/// @notice Withdraws accidentally sent token from this contract
/// @dev Owner may call only | function claimErc20(
address claimedToken,
address to,
uint256 amount
) external onlyOwner nonReentrant {
IERC20 vestedToken = IERC20(address(_getToken()));
if (claimedToken == address(vestedToken)) {
uint256 balance = vestedToken.balanceOf(address(this));
... | 0.8.4 |
/// @notice Removes the contract from blockchain when tokens are released
/// @dev Owner only may call on a proxy (but not on the implementation) | function removeContract() external onlyOwner {
// avoid accidental removing of the implementation
_throwImplementation();
require(allocation == released, "PStakes: unpaid stakes");
IERC20 vestedToken = IERC20(address(_getToken()));
uint256 balance = vestedToken.balanceOf(addres... | 0.8.4 |
/// @notice Initialize the contract
/// @dev May be called on a proxy only (but not on the implementation) | function _init(uint256 _poolId) internal {
_throwImplementation();
require(_poolId < 2**16, "PStakes:unsafePoolId");
IVestingPools pools = _getVestingPools();
address wallet = pools.getWallet(_poolId);
require(wallet == address(this), "PStakes:invalidPool");
PoolParams m... | 0.8.4 |
/// @dev Returns amount that may be released for the given stake and factor | function _releasableAmount(Stake memory stake, uint256 _factor)
internal
pure
returns (uint256)
{
uint256 share = (_factor * uint256(stake.allocated)) / SCALE;
if (share > stake.allocated) {
// imprecise division safeguard
share = uint256(stake.allocat... | 0.8.4 |
/// @dev Sends the releasable amount of the specified placeholder | function _withdraw(address holder) internal {
Stake memory stake = _getStake(holder);
uint256 releasable = _releasableAmount(stake, uint256(factor));
require(releasable > 0, "PStakes: nothing to withdraw");
stakes[holder].released = _safe96(uint256(stake.released) + releasable);
... | 0.8.4 |
/// @dev Gets collateral balance deposited into Vesper Grow Pool | function _getCollateralBalance() internal view returns (uint256) {
uint256 _totalSupply = vToken.totalSupply();
// avoids division by zero error when pool is empty
return (_totalSupply != 0) ? (vToken.totalValue() * vToken.balanceOf(address(this))) / _totalSupply : 0;
} | 0.8.3 |
// When we add a shortable pynth, we need to know the iPynth as well
// This is so we can get the proper skew for the short rate. | function addShortablePynths(bytes32[2][] calldata requiredPynthAndInverseNamesInResolver, bytes32[] calldata pynthKeys)
external
onlyOwner
{
require(requiredPynthAndInverseNamesInResolver.length == pynthKeys.length, "Input array length mismatch");
for (uint i = 0; i < requiredPynthA... | 0.5.16 |
//A mapping to store the player pairs in private rooms based on keccak256 ids generated locally
//constructor | function Lottery() public{
owner = msg.sender;
player_count = 0;
ante = 0.054 ether;
required_number_players = 2;
winner_percentage = 98;
oraclize_setProof(proofType_Ledger);
oracle_price = 0.003 ether;
oraclize_gas = 285000;
private_room... | 0.4.21 |
// function when someone gambles a.k.a sends ether to the contract | function buy() whenNotPaused payable public{
// No arguments are necessary, all
// information is already part of
// the transaction. The keyword payable
// is required for the function to
// be able to receive Ether.
// If the bet is not equal to the ante + t... | 0.4.21 |
/* Address => (productName => amount) */ | function TestConf () { name = "TestConf"; totalSupply = 1000000; initialIssuance = totalSupply; owner = 0x443B9375536521127DBfABff21f770e4e684475d; currentEthPrice = 20000; /* TODO: Oracle */ currentTokenPrice = 100; /* In cents */ symbol = "TEST1"; balances[owner] = 100; } | 0.4.14 |
/**
* @dev Mint new quantity amount of nfts
*/ | function mint(uint quantity) public payable isOpen notPaused {
require(quantity > 0, "You can't mint 0");
require(quantity <= maxPurchaseSize, "Exceeds max per transaction");
require(totalSupply() + quantity <= MAX_SUPPLY, "Not enough token left");
uint256 price = mintPrice.mul(quantity);
req... | 0.8.4 |
/**
* @dev Returns all the token IDs owned by address who
*/ | function tokensOfAddress(address who) external view returns(uint256[] memory) {
uint tokenCount = balanceOf(who);
uint256[] memory tokensId = new uint256[](tokenCount);
for(uint i = 0; i < tokenCount; i++){
tokensId[i] = tokenOfOwnerByIndex(who, i);
}
return tokensId;
} | 0.8.4 |
/**
* @dev Mint new quantity amount of nfts for specific address
* Bypass pause modifier
*/ | function ownerMint(uint quantity) public ownersOnly {
require(quantity > 0, "You can't mint 0");
require(totalSupply() + quantity <= MAX_SUPPLY, "Not enough token left");
for(uint i = 0; i < quantity; i++){
_safeMint(msg.sender, totalSupply().add(1));
}
} | 0.8.4 |
// Address of peg contract (to reject direct transfers) | function MinimalToken(
uint256 _initialAmount,
string _tokenName,
uint8 _decimalUnits,
string _tokenSymbol,
address _peg
) public {
balances[msg.sender] = _initialAmount;
totalSupply = _initialAmount;
name = _tokenName;
decimals =... | 0.4.19 |
//----------------------------------------------
// [public] tokenURI
//---------------------------------------------- | function tokenURI( uint256 tokenId ) public view override returns (string memory) {
require( _exists( tokenId ), "nonexistent token" );
// 修復データがあれば
string memory url = repairedUrl( tokenId );
if( bytes(url).length > 0 ){
return( url );
}
uint256 at... | 0.8.7 |
// _rollupParams = [ confirmPeriodBlocks, extraChallengeTimeBlocks, arbGasSpeedLimitPerBlock, baseStake ]
// connectedContracts = [delayedBridge, sequencerInbox, outbox, rollupEventBridge, challengeFactory, nodeFactory] | function initialize(
bytes32 _machineHash,
uint256[4] calldata _rollupParams,
address _stakeToken,
address _owner,
bytes calldata _extraConfig,
address[6] calldata connectedContracts,
address[2] calldata _facets,
uint256[2] calldata sequencerInboxParams
... | 0.6.11 |
/** ========== Internal Helpers ========== */ | function _mint(address dst, uint256 rawAmount) internal virtual {
require(dst != address(0), "mint to the zero address");
uint96 amount = safe96(rawAmount);
_totalSupply = add96(_totalSupply, amount, "mint amount overflows");
balances[dst] += amount; // add96 not needed because totalSupply does not over... | 0.7.6 |
/*
* Function to mint new NFTs when breeding
*/ | function breed(
uint256 idSecond
)
public
payable
{
require(NFTPrice == msg.value, "Ether value sent is not correct");
require(isActive, "Contract is not active");
require(BAYC.balanceOf(msg.sender)>=1,"You are not BAYC");
require(!hasBreed[idSe... | 0.8.4 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.