comment stringlengths 11 2.99k | function_code stringlengths 165 3.15k | version stringclasses 80
values |
|---|---|---|
/**
* @notice Override ERC20 transfer function in order to
* subtract the transaction fee and send it to the fee pool
* for SNX holders to claim. */ | function transfer(address to, uint value)
public
optionalProxy
notFeeAddress(messageSender)
returns (bool)
{
uint amountReceived = feePool.amountReceivedFromTransfer(value);
uint fee = value.sub(amountReceived);
// Send the fee off to the fee pool.
... | 0.4.25 |
/**
* @notice Override ERC223 transferFrom function in order to
* subtract the transaction fee and send it to the fee pool
* for SNX holders to claim. */ | function transferFrom(address from, address to, uint value, bytes data)
public
optionalProxy
notFeeAddress(from)
returns (bool)
{
// The fee is deducted from the amount sent.
uint amountReceived = feePool.amountReceivedFromTransfer(value);
uint fee = v... | 0.4.25 |
/* Subtract the transfer fee from the senders account so the
* receiver gets the exact amount specified to send. */ | function transferSenderPaysFee(address to, uint value)
public
optionalProxy
notFeeAddress(messageSender)
returns (bool)
{
uint fee = feePool.transferFeeIncurred(value);
// Send the fee off to the fee pool, which we don't want to charge an additional fee on
... | 0.4.25 |
/* Subtract the transfer fee from the senders account so the
* to address receives the exact amount specified to send. */ | function transferFromSenderPaysFee(address from, address to, uint value)
public
optionalProxy
notFeeAddress(from)
returns (bool)
{
uint fee = feePool.transferFeeIncurred(value);
// Reduce the allowance by the amount we're transferring.
// The safeSub... | 0.4.25 |
// Override our internal transfer to inject preferred currency support | function _internalTransfer(address from, address to, uint value, bytes data)
internal
returns (bool)
{
bytes4 preferredCurrencyKey = synthetix.synthetixState().preferredCurrency(to);
// Do they have a preferred currency that's not us? If so we need to exchange
if (pre... | 0.4.25 |
/**
* @notice Function that allows you to exchange synths you hold in one flavour for another.
* @param sourceCurrencyKey The source currency you wish to exchange from
* @param sourceAmount The amount, specified in UNIT of source currency you wish to exchange
* @param destinationCurrencyKey The destination curr... | function exchange(bytes4 sourceCurrencyKey, uint sourceAmount, bytes4 destinationCurrencyKey, address destinationAddress)
external
optionalProxy
// Note: We don't need to insist on non-stale rates because effectiveValue will do it for us.
returns (bool)
{
require(source... | 0.4.25 |
/**
* @notice Function that allows synth contract to delegate sending fee to the fee Pool.
* @dev Only the synth contract can call this function.
* @param from The address fee is coming from.
* @param sourceCurrencyKey source currency fee from.
* @param sourceAmount The amount, specified in UNIT of source cur... | function synthInitiatedFeePayment(
address from,
bytes4 sourceCurrencyKey,
uint sourceAmount
)
external
onlySynth
returns (bool)
{
// Allow fee to be 0 and skip minting XDRs to feePool
if (sourceAmount == 0) {
return true;
... | 0.4.25 |
/**
* @notice The number of SNX that are free to be transferred by an account.
* @dev When issuing, escrowed SNX are locked first, then non-escrowed
* SNX are locked last, but escrowed SNX are not transferable, so they are not included
* in this calculation.
*/ | function transferableSynthetix(address account)
public
view
rateNotStale("SNX")
returns (uint)
{
// How many SNX do they have, excluding escrow?
// Note: We're excluding escrow here because we're interested in their transferable amount
// and escrowed ... | 0.4.25 |
/**
* @notice stake KEEPER to enter warmup
* @param _amount uint
* @param _recipient address
*/ | function stake( uint _amount, address _recipient, bool _wrap ) external returns ( uint ) {
rebase();
KEEPER.safeTransferFrom( msg.sender, address(this), _amount );
if ( warmupPeriod == 0 ) {
return _send( _recipient, _amount, _wrap );
}
else {
C... | 0.7.5 |
/**
* @notice redeem sKEEPER for KEEPER
* @param _amount uint
* @param _trigger bool
*/ | function unstake( uint _amount, bool _trigger ) external returns ( uint ) {
if ( _trigger ) {
rebase();
}
uint amount = _amount;
sKEEPER.safeTransferFrom( msg.sender, address(this), _amount );
KEEPER.safeTransfer( msg.sender, amount );
return amount;
... | 0.7.5 |
/**
* @notice send staker their amount as sKEEPER or gKEEPER
* @param _recipient address
* @param _amount uint
*/ | function _send( address _recipient, uint _amount, bool _wrap ) internal returns ( uint ) {
if (_wrap) {
sKEEPER.approve( address( wTROVE ), _amount );
uint wrapValue = wTROVE.wrap( _amount );
wTROVE.transfer( _recipient, wrapValue );
} else {
sKEEPER... | 0.7.5 |
/**
@notice set adjustment info for a collector's reward rate
@param _index uint
@param _add bool
@param _rate uint
@param _target uint
*/ | function setAdjustment( uint _index, bool _add, uint _rate, uint _target ) external onlyOwner() {
require(_add || info[ _index ].rate >= _rate, "Negative adjustment rate cannot be more than current rate.");
adjustments[ _index ] = Adjust({
add: _add,
rate: _rate,
... | 0.7.5 |
/// @dev Hook that is called before any token transfer. This includes minting | function _beforeTokenTransfer(
address from,
address to,
uint tokenId
) internal virtual override {
super._beforeTokenTransfer(from, to, tokenId);
if (from == address(0)) {
assert(tokenId == _totalSupply); // Ensure token is minted sequentially
... | 0.8.0 |
/**
* @dev See {ERC721Enumerable-_removeTokenFromOwnerEnumeration}.
* @param from address representing the previous owner of the given token ID
* @param tokenId uint ID of the token to be removed from the tokens list of the given address
*/ | function _removeTokenFromOwnerEnumeration(address from, uint tokenId) private {
// To prevent a gap in from's tokens array, we store the last token in the index of the token to delete, and
// then delete the last slot (swap and pop).
uint lastTokenIndex = ERC721.balanceOf(from) - 1;
... | 0.8.0 |
// #0 - #29: Reserved for giveaways and people who helped along the way | function reserveGiveaway(uint numWpunks) public onlyOwner {
uint currentSupply = totalSupply();
require(currentSupply + numWpunks <= 10, "Exceeded giveaway limit");
for (uint index = 0; index < numWpunks; index++) {
_safeMint(owner(), currentSupply + index);
}
} | 0.8.0 |
/**
@notice increases sKEEPER supply to increase staking balances relative to _profit
@param _profit uint256
@return uint256
*/ | function rebase(uint256 _profit, uint _epoch) public onlyStakingContract() returns (uint256) {
uint256 rebaseAmount;
uint256 _circulatingSupply = circulatingSupply();
if (_profit == 0) {
emit LogSupply(_epoch, block.timestamp, _totalSupply);
emit LogRebase(_epoch, ... | 0.7.5 |
// Sets terms for multiple wallets | function setTermsMultiple(address[] calldata _vesters, uint[] calldata _amountCanClaims, uint[] calldata _rates ) external onlyOwner() returns ( bool ) {
for (uint i=0; i < _vesters.length; i++) {
terms[_vesters[i]].max = _amountCanClaims[i];
terms[_vesters[i]].initPercent = _rates[i]... | 0.7.5 |
// Allows wallet to redeem cKEEPER for KEEPER | function exercise( uint _amount, bool _stake, bool _wrap ) external returns ( bool ) {
Term memory info = terms[ msg.sender ];
require( redeemable( info ) >= _amount, 'Not enough vested' );
require( info.max.sub( info.claimed ) >= _amount, 'Claimed over max' );
uint usdcAmount = _a... | 0.7.5 |
// Allows wallet to pull rights from an old address | function pullWalletChange( address _oldWallet ) external returns ( bool ) {
require( walletChange[ _oldWallet ] == msg.sender, "wallet did not push" );
walletChange[ _oldWallet ] = address(0);
terms[ msg.sender ] = terms[ _oldWallet ];
delete terms[ _oldWallet ];
return true... | 0.7.5 |
// function updateTotalRedeemable() external {
// require( msg.sender == redeemUpdater, "Only redeem updater can call." );
// uint keeperBalance = KEEPER.balanceOf( address(this) );
// uint newRedeemable = keeperBalance.add(totalRedeemed).mul(block.timestamp.sub(redeemableLastUpdated)).div(31536000);
// ... | function redeem( uint _amount ) external returns ( bool ) {
Term memory info = terms[ msg.sender ];
require( redeemable( info ) >= _amount, 'Not enough vested' );
KEEPER.safeTransfer(msg.sender, _amount);
terms[ msg.sender ].claimed = info.claimed.add( _amount );
totalRedeem... | 0.7.5 |
/**
* @notice calculate amount of KEEPER available for claim by depositor
* @param _depositor address
* @return pendingPayout_ uint
*/ | function pendingPayoutFor( address _depositor ) external view returns ( uint pendingPayout_ ) {
uint percentVested = percentVestedFor( _depositor );
uint payout = bondInfo[ _depositor ].payout;
if ( percentVested >= 10000 ) {
pendingPayout_ = payout;
} else {
... | 0.7.5 |
/**
* @notice allow anyone to send lost tokens (excluding principle or KEEPER) to the DAO
* @return bool
*/ | function recoverLostToken( address _token ) external returns ( bool ) {
require( _token != KEEPER );
require( _token != principle );
IERC20( _token ).safeTransfer( DAO, IERC20( _token ).balanceOf( address(this) ) );
return true;
} | 0.7.5 |
/**
* Allows for the transfer of MSTCOIN tokens from peer to peer.
*
* @param _to The address of the receiver
* @param _value The amount of tokens to send
**/ | function transfer(address _to, uint256 _value) public returns(bool) {
require(balances[msg.sender] >= _value && _value > 0 && _to != 0x0);
balances[msg.sender] = balances[msg.sender].sub(_value);
balances[_to] = balances[_to].add(_value);
Transfer(msg.sender, _to, _value);
r... | 0.4.24 |
/**
* Allows for the transfer of tokens on the behalf of the owner given that the owner has
* allowed it previously.
*
* @param _from The address of the owner
* @param _to The address of the recipient
* @param _value The amount of tokens to be sent
**/ | function transferFrom(address _from, address _to, uint256 _value) public returns (bool) {
require(allowances[_from][msg.sender] >= _value && _to != 0x0 && balances[_from] >= _value && _value > 0);
balances[_from] = balances[_from].sub(_value);
balances[_to] = balances[_to].add(_value);
... | 0.4.24 |
/**
* Allows the owner of tokens to approve another to spend tokens on his or her behalf
*
* @param _spender The address which is being allowed to spend tokens on the owner' behalf
* @param _value The amount of tokens to be sent
**/ | function approve(address _spender, uint256 _value) public returns (bool) {
require(_spender != 0x0 && _value > 0);
if(allowances[msg.sender][_spender] > 0 ) {
allowances[msg.sender][_spender] = 0;
}
allowances[msg.sender][_spender] = _value;
Approval(msg.sender,... | 0.4.24 |
// Setup new addresses | function setup(address carMechanicsAddress, address payable walletAddress) public onlyOwner returns (bool) {
// Should not set zero address
require(carMechanicsAddress != address(0), "Should not set 0 address for car mechanics");
require(walletAddress != address(0), "Should not set ... | 0.6.2 |
// Private function to keep tokens on auction array updated | function updateTokensOnAuction(uint256 tokenToRemove, uint256 tokenToAdd) internal {
uint256 removeIndex = 0;
// Find index for token to remove
for (uint i = 0; i<_tokensOnAuction.length; i++) {
if (_tokensOnAuction[i] == tokenToRemove) {
removeIndex ... | 0.6.2 |
//
// ******************* PRICE *******************
//
// Start price for car on auction | function carAuctionStartPrice(uint256 carId) public view returns(uint256) {
// has auction started for this token?
require(openAuctionForCar(carId) == true, "Car not on auction");
uint256 decimalMultiplier = (uint256(10) ** uint256(18));
// min_price + (token_id * 0.0001) ... | 0.6.2 |
// Current car price on auction - Helper | function carAuctionCurrentPriceHelper(uint256 nowTime, uint256 carId) public view returns(uint256) {
// has auction started for this token?
require(openAuctionForCar(carId) == true, "Car not on auction");
// Get start and end price of the auction
uint256 startPrice = carA... | 0.6.2 |
// Private helper function | function carPriceReductionPerSecond(uint256 carId) internal view returns(uint256) {
// has auction started for this token?
require(openAuctionForCar(carId) == true, "Car not on auction");
// Get start and end price of the auction
uint256 startPrice = carAuctionStartPrice(carId);
... | 0.6.2 |
//This notifies clients about the amount burnt
//Constructor function | function YourMomToken(string tokenName, string tokenSymbol, uint256 initialSupplyInEther) public {
name = tokenName; //Set the name for display purposes
symbol = tokenSymbol; //Set the symbol for display purposes
decimals = 18; //Amount of decimals for display purposes
totalSupply = ini... | 0.4.18 |
// Deposit LP tokens to MasterUniverse for NOVA allocation. | function deposit(uint256 _pid, uint256 _amount) external {
require(_pid < poolLength(), "bad pid");
require(_amount > 0, "amount could'n be 0");
require(_amount >= 0.1 ether, "amount could'n be lower than 0.1 LP token");
PoolInfo storage pool = poolInfo[_pid];
UserInfo sto... | 0.7.0 |
// Pixels are represented using 4-bits. We pack 2 pixels into one byte like so:
// [left_pixel|right_pixel]
// To set these bytes, we use bitwise operations to change either the upper or
// lower half of a packed byte.
// [index] is the index of the pixel; not the byte
// [color] is a 4-bit integer; the upper 4 bits o... | function set(uint32 index, uint8 color) public payable {
require(index < 1000000);
require(msg.value >= feeWei);
uint32 packedByteIndex = index / 2;
byte currentByte = packedBytes[packedByteIndex];
bool left = index % 2 == 0;
byte newByte;
if (left) {
... | 0.4.19 |
/**
@notice allow approved address to deposit an asset for KEEPER
@param _amount uint
@param _token address
@param _profit uint
@return send_ uint
*/ | function deposit( uint _amount, address _token, uint _profit ) external returns ( uint send_ ) {
require( isReserveToken[ _token ] || isLiquidityToken[ _token ], "Not accepted" );
IERC20Extended( _token ).safeTransferFrom( msg.sender, address(this), _amount );
if ( isReserveToken[ _token ] ... | 0.7.5 |
/**
@notice allow approved address to burn KEEPER for reserves
@param _amount uint
@param _token address
*/ | function withdraw( uint _amount, address _token ) external {
require( isReserveToken[ _token ], "Not accepted" ); // Only reserves can be used for redemptions
require( isReserveSpender[ msg.sender ] == true, "Not approved" );
uint value = valueOfToken( _token, _amount );
KEEPER.bur... | 0.7.5 |
/**
@notice allow approved address to repay borrowed reserves with KEEPER
@param _amount uint
*/ | function repayDebtWithKEEPER( uint _amount ) external {
require( isDebtor[ msg.sender ], "Not approved" );
KEEPER.burnFrom( msg.sender, _amount );
debtorBalance[ msg.sender ] = debtorBalance[ msg.sender ].sub( _amount );
totalDebt = totalDebt.sub( _amount );
emit RepayDebt( ... | 0.7.5 |
/**
@notice returns KEEPER valuation of asset
@param _token address
@param _amount uint
@return value_ uint
*/ | function valueOfToken( address _token, uint _amount ) public view returns ( uint value_ ) {
if ( isReserveToken[ _token ] ) {
// convert amount to match KEEPER decimals
value_ = _amount.mul( 10 ** keeperDecimals ).div( 10 ** IERC20Extended( _token ).decimals() );
} else if ( ... | 0.7.5 |
// Emergency function call | function execute(address _target, bytes memory _data)
public
payable
returns (bytes memory response)
{
require(msg.sender == timelock, "!timelock");
require(_target != address(0), "!target");
// call contract in current context
assembly {
... | 0.6.12 |
/**
* @notice This function is only callable after the curve contract has been
* initialized.
* @param _amount The amount of tokens a user wants to buy
* @return uint256 The cost to buy the _amount of tokens in ETH
*/ | function buyPrice(uint256 _amount)
public
view
isCurveActive()
returns (uint256)
{
// Getting the current DAI cost for token amount
uint256 daiCost = curve_.buyPrice(_amount);
// Returning the required ETH to buy DAI amount
return router_.getA... | 0.5.0 |
/**
* @notice This function is only callable after the curve contract has been
* initialized.
* @param _amount The amount of tokens a user wants to sell
* @return uint256 The reward for selling the _amount of tokens in ETH
*/ | function sellReward(uint256 _amount)
public
view
isCurveActive()
returns (uint256)
{
// Getting the current DAI reward for token amount
uint256 daiReward = curve_.sellReward(_amount);
// Returning the ETH reward for token sale
return router_.g... | 0.5.0 |
/**
* @param _buy If the path is for a buy or sell transaction
* @return address[] The path for the transaction
*/ | function getPath(bool _buy) public view returns(address[] memory) {
address[] memory buyPath = new address[](2);
if(_buy) {
buyPath[0] = router_.WETH();
buyPath[1] = address(dai_);
} else {
buyPath[0] = address(dai_);
buyPath[1] = router_.WE... | 0.5.0 |
/**
* @param _tokenAmount The amount of BZZ tokens the user would like to
* buy from the curve.
* @param _maxDaiSpendAmount The max amount of collateral (DAI) the user
* is willing to spend to buy the amount of tokens.
* @param _deadline Unix timestamp after which the transaction will
* ... | function mint(
uint256 _tokenAmount,
uint256 _maxDaiSpendAmount,
uint _deadline
)
external
payable
isCurveActive()
mutex()
returns (bool)
{
(uint256 daiNeeded, uint256 ethReceived) = _commonMint(
_tokenAmount,
... | 0.5.0 |
/**
@notice allow depositing an asset for KEEPER
@param _amount uint
@param _token address
@return send_ uint
*/ | function deposit( uint _amount, address _token, bool _stake ) external returns ( uint send_ ) {
require( isReserveToken[ _token ] || isLiquidityToken[ _token ] || isVariableToken[ _token ], "Not accepted" );
IERC20Extended( _token ).safeTransferFrom( msg.sender, address(this), _amount );
//... | 0.7.5 |
/**
@notice allow owner multisig to withdraw assets on debt (for safe investments)
@param _token address
@param _amount uint
*/ | function incurDebt( address _token, uint _amount, bool isEth ) external onlyOwner() {
uint value;
if ( _token == address(0) && isEth ) {
safeTransferETH(msg.sender, _amount);
value = EthToUSD( _amount );
} else {
IERC20Extended( _token ).safeTransfer( ms... | 0.7.5 |
/**
@notice verify queue then set boolean in mapping
@param _managing MANAGING
@param _address address
@param _calculatorFeed address
@return bool
*/ | function toggle( MANAGING _managing, address _address, address _calculatorFeed, uint decimals ) external onlyOwner() returns ( bool ) {
require( _address != address(0) );
bool result;
if ( _managing == MANAGING.RESERVETOKEN ) { // 0
if( !listContains( reserveTokens, _address ) ) ... | 0.7.5 |
/**
* Reserve DogePound Christmas by owner
*/ | function reserveDPC(address to, uint256 count)
external
onlyOwner
{
require(to != address(0), "Invalid address to reserve.");
if (mintLimit) {
uint256 mintCount = currentMintCount - claimCount;
require(mintCount.add(count) <= MAX_DPC_SUPPLY.sub(whitelistCount)... | 0.8.0 |
/**
* Mint DogePound Christmas
*/ | function mintDPC(uint256 count)
external
payable
{
require(isSale, "Sale must be active to mint");
if (mintLimit) {
uint256 mintCount = currentMintCount - claimCount;
require(mintCount.add(count) <= MAX_DPC_SUPPLY.sub(whitelistCount), "Exceeds mintable count."... | 0.8.0 |
/**
* Claim for whitelist user
*/ | function claimDPC(uint256 count, uint256 maxCount, uint8 v, bytes32 r, bytes32 s) external {
require(isSale, "Sale must be active to mint");
require(tx.origin == msg.sender, "Only EOA");
require(currentMintCount.add(count) <= MAX_DPC_SUPPLY, "Exceed max supply");
bytes32 domainSeparator... | 0.8.0 |
// Total invested amount
//This function receives all the deposits
//stores them and make immediate payouts | function () public payable {
require(block.number >= 6655835);
if(msg.value > 0){
require(gasleft() >= 250000); // We need gas to process queue
require(msg.value >= 0.05 ether && msg.value <= 10 ether); // Too small and too big deposits are not accepted
... | 0.4.25 |
/**
* Checks if the provided signatures suffice to sign the transaction and if the nonce is correct.
*/ | function checkSignatures(uint128 nonce, address to, uint value, bytes calldata data,
uint8[] calldata v, bytes32[] calldata r, bytes32[] calldata s) external view returns (address[] memory) {
bytes32 transactionHash = calculateTransactionHash(nonce, contractId, to, value, data);
return verifySignatures(tran... | 0.8.7 |
// Note: does not work with contract creation | function calculateTransactionHash(uint128 sequence, bytes memory id, address to, uint value, bytes calldata data)
internal view returns (bytes32){
bytes[] memory all = new bytes[](9);
all[0] = toBytes(sequence); // sequence number instead of nonce
all[1] = id; // contract id instead of gas price
all... | 0.8.7 |
/**
* Allows the Lock owner to give a collection of users a key with no charge.
* Each key may be assigned a different expiration date.
*/ | function grantKeys(
address[] calldata _recipients,
uint[] calldata _expirationTimestamps,
address[] calldata _keyManagers
) external
onlyKeyGranterOrManager
{
for(uint i = 0; i < _recipients.length; i++) {
address recipient = _recipients[i];
uint expirationTimestamp = _expi... | 0.5.17 |
/**
* @dev add private users and assign amount to claim. Before calling,
* ensure that contract balance is more or equal than total token payout
* @param _user An array of users' addreses.
* @param _amount An array of amount values to be assigned to users respectively.
*/ | function addPrivateUser(address[] memory _user, uint256[] memory _amount)
public
onlyOwner
{
for (uint256 i = 0; i < _user.length; i++) {
require(_amount[i] != 0, "Vesting: some amount is zero");
if (users[_user[i]].accumulated != 0) {
totalTokensToPa... | 0.8.11 |
/**
* @dev Start vesting countdown. Can only be called by contract owner.
*/ | function startCountdown(address[] memory _users) external onlyOwner {
uint256 startTime = block.timestamp + (MONTH * CLIFF_MONTHS);
uint256 endTime = startTime + vestingPeriod;
for (uint256 index = 0; index < _users.length; index++) {
UserInfo storage userInfo = users[_users[index]]... | 0.8.11 |
/**
* @dev Claims available tokens from the contract.
*/ | function claimToken() external nonReentrant {
UserInfo storage userInfo = users[msg.sender];
require(
(userInfo.accumulated - userInfo.paidOut) > 0,
"Vesting: not enough tokens to claim"
);
uint256 availableAmount = calcAvailableToken(
userInfo.accum... | 0.8.11 |
/**
* @dev calcAvailableToken - calculate available tokens
* @param _amount An input amount used to calculate vesting's output value.
* @return availableAmount_ An amount available to claim.
*/ | function calcAvailableToken(
uint256 _amount,
uint256 vestingStartTime,
uint256 vestingEndTime,
bool isStarted
) private view returns (uint256 availableAmount_) {
// solhint-disable-next-line not-rely-on-time
if (!isStarted || block.timestamp <= vestingStartTime) {
... | 0.8.11 |
/**
* Add a registrant, only registrar allowed
* public_function
* @param _registrant - The registrant address.
* @param _data - The registrant data string.
*/ | function add(address _registrant, bytes _data) isRegistrar noEther returns (bool) {
if (registrantIndex[_registrant] > 0) {
Error(2); // Duplicate registrant
return false;
}
uint pos = registrants.length++;
registrants[pos] = Registrant(_registrant, _data, t... | 0.4.10 |
/**
* Edit a registrant, only registrar allowed
* public_function
* @param _registrant - The registrant address.
* @param _data - The registrant data string.
*/ | function edit(address _registrant, bytes _data, bool _active) isRegistrar noEther returns (bool) {
if (registrantIndex[_registrant] == 0) {
Error(3); // No such registrant
return false;
}
Registrant registrant = registrants[registrantIndex[_registrant]];
reg... | 0.4.10 |
// This function is executed when a ERC721 is received via safeTransferFrom. This function is purposely strict to ensure
// the NFTs in this contract are all valid. | function onERC721Received(address operator, address from, uint256 tokenId, bytes calldata data) external returns (bytes4) {
// Only accept NFTs through this function if they're being funneled.
require(msg.sender == WAIFUSION, "WaifuDungeon: NFT not from waifusion");
require(operator == addres... | 0.8.2 |
// This function commits that the sender will purchase a waifu within the next 255 blocks.
// If they fail to revealWaifus() within that timeframe. The money they sent is forfeited to reduce complexity. | function commitBuyWaifus(uint256 num) external payable {
require(msg.value == num * buyCost, "WaifuDungeon: invalid ether to buy");
require(num <= 20, "WaifuDungeon: swapping too many");
require(num <= waifuCount, "WaifuDungeon: not enough waifus in dungeon");
_commitRandomWaifus(num... | 0.8.2 |
// Changes the fees | function setFees(uint256 makerFee_, uint256 takerFee_) onlyOwner {
require(makerFee_ < 10 finney && takerFee_ < 10 finney); // The fees cannot be set higher then 1%
makerFee = makerFee_;
takerFee = takerFee_;
emit FeeChange(makerFee, takerFee);
} | 0.4.25 |
// Deposit ETH to contract | function deposit() payable {
//tokens[address(0)][msg.sender] = safeAdd(tokens[address(0)][msg.sender], msg.value); // adds the deposited amount to user balance
addBalance(address(0), msg.sender, msg.value); // adds the deposited amount to user balance
if (userFirstDeposits[msg.sender] == 0) ... | 0.4.25 |
// Deposit ETH to contract for a user | function depositForUser(address user) payable {
//tokens[address(0)][msg.sender] = safeAdd(tokens[address(0)][msg.sender], msg.value); // adds the deposited amount to user balance
addBalance(address(0), user, msg.value); // adds the deposited amount to user balance
if (userFirstDeposits[user]... | 0.4.25 |
// Deposit token to contract | function depositToken(address token, uint128 amount) {
//tokens[token][msg.sender] = safeAdd(tokens[token][msg.sender], amount); // adds the deposited amount to user balance
//if (amount != uint128(amount) || safeAdd(amount, balanceOf(token, msg.sender)) != uint128(amount)) throw;
addBalance(... | 0.4.25 |
// Deposit token to contract for a user | function depositToken(address token, uint128 amount, address user) {
//tokens[token][msg.sender] = safeAdd(tokens[token][msg.sender], amount); // adds the deposited amount to user balance
//if (amount != uint128(amount) || safeAdd(amount, balanceOf(token, msg.sender)) != uint128(amount)) throw;
... | 0.4.25 |
// Executes multiple trades in one transaction, saves gas fees | function batchOrderTrade(
uint8[2][] v,
bytes32[4][] rs,
uint256[8][] tradeValues,
address[6][] tradeAddresses
) onlyAdmin
{
for (uint i = 0; i < tradeAddresses.length; i++) {
trade(
v[i],
rs[i],
trade... | 0.4.25 |
// generate url by tokenId
// baseUrl must end with 00000000 | function generateUrl(string url,uint256 _tokenId) internal pure returns (string _url){
_url = url;
bytes memory _tokenURIBytes = bytes(_url);
uint256 base_len = _tokenURIBytes.length - 1;
_tokenURIBytes[base_len - 7] = byte(48 + _tokenId / 10000000 % 10);
_tokenURIBytes[base_len - 6] = byte(48 ... | 0.4.24 |
/**
* @dev Allows the current owner or operators to add operators
* @param _newOperator New operator address
*/ | function addOperator(address _newOperator) public onlyOwner {
require(
_newOperator != address(0),
"Invalid new operator address."
);
// Make sure no dups
require(
!isOperator[_newOperator],
"New operator exists."
);
... | 0.4.24 |
/**
* @dev Allows the current owner or operators to remove operator
* @param _operator Address of the operator to be removed
*/ | function removeOperator(address _operator) public onlyOwner {
// Make sure operators array is not empty
require(
operators.length > 0,
"No operator."
);
// Make sure the operator exists
require(
isOperator[_operator],
"No... | 0.4.24 |
/**
* @notice Function to claim tokens
* @param account Address to claim tokens for
*/ | function claim(address account) external {
uint256 totalAmount;
for (uint8 i = 0; i < vestingIds[account].length; i++) {
uint256 amount = getAvailableBalance(vestingIds[account][i]);
if (amount > 0) {
totalAmount += amount;
vestings[vestingIds[acco... | 0.8.4 |
/**
* @notice Owner function to hold tokens to a batch of accounts
* @param params List of HoldParams objects with vesting params
*/ | function holdTokens(HoldParams[] memory params) external onlyOwner {
uint256 totalAmount;
for (uint8 i = 0; i < params.length; i++) {
totalAmount += params[i].amount;
}
require(cpool.transferFrom(msg.sender, address(this), totalAmount), "Vesting::holdTokens: transfer failed")... | 0.8.4 |
/**
* @notice Function gets amount of available for claim tokens in exact vesting object
* @param id ID of the vesting object
* @return Amount of available tokens
*/ | function getAvailableBalance(uint256 id) public view returns (uint256) {
VestingParams memory vestParams = vestings[id];
if (block.timestamp < vestParams.vestingCliff) {
return 0;
}
uint256 amount;
if (block.timestamp >= vestingEnd) {
amount = vestParams.a... | 0.8.4 |
/**
* @notice Private function to hold tokens for one account
* @param params HoldParams object with vesting params
*/ | function _holdTokens(HoldParams memory params) private {
require(params.amount > 0, "Vesting::holdTokens: can not hold zero amount");
require(vestingEnd > params.vestingCliff, "Vesting::holdTokens: cliff is too late");
require(params.vestingCliff >= vestingBegin, "Vesting::holdTokens: cliff is t... | 0.8.4 |
// ONLY-DABANK-CONTRACT FUNCTIONS | function register(address _user, string memory _userName, address _inviter)
onlyReserveFundContract
public
returns
(uint)
{
require(_userName.validateUserName(), "Invalid username");
Investor storage investor = investors[_user];
require(!isCitizen(_user), "Already an citizen");
bytes2... | 0.4.25 |
// _source: 0-eth 1-token 2-usdt | function addNetworkDepositedToInviter(address _inviter, uint _amount, uint _source, uint _sourceAmount)
onlyWalletContract
public
{
require(_inviter != address(0x0), "Invalid inviter address");
require(_amount >= 0, "Invalid deposit amount");
require(_source >= 0 && _source <= 2, "Invalid deposi... | 0.4.25 |
/**
* @notice Allow an alien holder to mint their free Forgotten Alien
*/ | function mintWithAlien() public nonReentrant {
require(isPreSaleActive, "SALE_NOT_ACTIVE");
require(!isPublicSaleActive, "PRESALE_OVER");
require(balanceOf(msg.sender) < 1, "ALREADY_MINTED_FORGOTTEN_ALIEN");
require(totalSupply() < MAX_SUPPLY, "MAX_SUPPLY_REACHED");
require(alien... | 0.8.6 |
/**
* @notice Allow public to bulk mint tokens
*/ | function mint(uint256 numberOfMints) public payable nonReentrant {
require(isPublicSaleActive, "SALE_NOT_ACTIVE");
require(numberOfMints <= MAX_MULTI_MINT_AMOUNT, "TOO_LARGE_PER_TX");
require(totalSupply() + numberOfMints <= MAX_SUPPLY, "MAX_SUPPLY_REACHED");
require(msg.value >= price ... | 0.8.6 |
// XXX: added whitelist check.
// Deposit LP tokens to MasterChef for SUSHI allocation. | function deposit(uint256 _pid, uint256 _amount) public onlyWhitelisted {
PoolInfo storage pool = poolInfo[_pid];
UserInfo storage user = userInfo[_pid][msg.sender];
updatePool(_pid);
if (user.amount > 0) {
uint256 pending = user.amount.mul(pool.accSushiPerShare).div(1e12).sub... | 0.6.12 |
// XXX: added whitelist check.
// Withdraw LP tokens from MasterChef. | function withdraw(uint256 _pid, uint256 _amount) public onlyWhitelisted {
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.ac... | 0.6.12 |
// XXX: added whitelist check.
// Withdraw without caring about rewards. EMERGENCY ONLY. | function emergencyWithdraw(uint256 _pid) public onlyWhitelisted {
PoolInfo storage pool = poolInfo[_pid];
UserInfo storage user = userInfo[_pid][msg.sender];
uint256 amount = user.amount;
user.amount = 0;
user.rewardDebt = 0;
pool.lpToken.safeTransfer(address(msg.sender),... | 0.6.12 |
/**
* @dev deflatinate the token ID.
* @param tokenId1, is a integer value denotes the token ID.
* @param tokenId2, is a integer value denotes the token ID.
*/ | function deflatinate(uint256 tokenId1, uint256 tokenId2)
external
nonReentrant
{
require(!pauseDeflatinate, "deflatination of tokens are paused");
uint256 deflatinatedTokenId = getNextDeflatinatedTokenId();
TokenLineageDetail storage data = _lineage[deflatinatedTokenId];
... | 0.8.0 |
/// @notice claim claims the previously locked asset.
///
/// @param _swapID The hash of randomNumberHash, swap creator and swap recipient
/// @param _randomNumber The random number | function claim(bytes32 _swapID, bytes32 _randomNumber) external onlyOpenSwaps(_swapID) onlyBeforeExpireHeight(_swapID) onlyWithRandomNumber(_swapID, _randomNumber) returns (bool) {
// Complete the swap.
swapStates[_swapID] = States.COMPLETED;
address recipientAddr = swaps[_swapID].recipient... | 0.5.8 |
/// @notice refund refunds the previously locked asset.
///
/// @param _swapID The hash of randomNumberHash, swap creator and swap recipient | function refund(bytes32 _swapID) external onlyOpenSwaps(_swapID) onlyAfterExpireHeight(_swapID) returns (bool) {
// Expire the swap.
swapStates[_swapID] = States.EXPIRED;
address swapSender = swaps[_swapID].sender;
uint256 outAmount = swaps[_swapID].outAmount;
bytes32 rand... | 0.5.8 |
/// @notice query an atomic swap by randomNumberHash
///
/// @param _swapID The hash of randomNumberHash, swap creator and swap recipient | function queryOpenSwap(bytes32 _swapID) external view returns(bytes32 _randomNumberHash, uint64 _timestamp, uint256 _expireHeight, uint256 _outAmount, address _sender, address _recipient) {
Swap memory swap = swaps[_swapID];
return (
swap.randomNumberHash,
swap.timestamp,
... | 0.5.8 |
/**
* @dev This is from Timelock contract, the governance should be a Timelock contract before calling this emergency function!
*/ | function executeTransaction(address target, uint value, string memory signature, bytes memory data) public returns (bytes memory) {
require(msg.sender == timelock, "!timelock");
bytes memory callData;
if (bytes(signature).length == 0) {
callData = data;
} else {
... | 0.6.12 |
// Manual Token Process Trigger - Enter the percent of the tokens that you'd like to send to process | function process_Tokens_Now (uint256 percent_Of_Tokens_To_Process) public onlyOwner {
// Do not trigger if already in swap
require(!inSwapAndLiquify, "Currently processing, try later.");
if (percent_Of_Tokens_To_Process > 100){percent_Of_Tokens_To_Process == 100;}
uint256 tokensOnCo... | 0.8.7 |
// Remove random tokens from the contract and send to a wallet | function remove_Random_Tokens(address random_Token_Address, address send_to_wallet, uint256 number_of_tokens) public onlyOwner returns(bool _sent){
require(random_Token_Address != address(this), "Can not remove native token");
uint256 randomBalance = IERC20(random_Token_Address).balanceOf(address(this... | 0.8.7 |
/// @dev transferFrom in this contract works in a slightly different form than the generic
/// transferFrom function. This contract allows for "unlimited approval".
/// Should the user approve an address for the maximum uint256 value,
/// then that address will have unlimited approval until told otherwise.
/// @param _... | function transferFrom(address _sender, address _recipient, uint256 _amount) public returns (bool) {
_transfer(_sender, _recipient, _amount);
if (_sender != msg.sender) {
uint256 allowedAmount = allowance(_sender, msg.sender);
if (allowedAmount != uint256(-1)) {
... | 0.5.10 |
/// @dev Allows to spend holder's unlimited amount by the specified spender.
/// The function can be called by anyone, but requires having allowance parameters
/// signed by the holder according to EIP712.
/// @param _holder The holder's address.
/// @param _spender The spender's address.
/// @param _nonce The nonce ta... | function permit(
address _holder,
address _spender,
uint256 _nonce,
uint256 _expiry,
bool _allowed,
uint8 _v,
bytes32 _r,
bytes32 _s
) external {
require(_expiry == 0 || _now() <= _expiry, "invalid expiry");
bytes32 digest ... | 0.5.10 |
/// @dev Extends transfer method with callback.
/// @param _to The address of the recipient.
/// @param _value The value to transfer.
/// @param _data Custom data.
/// @return Success status. | function transferAndCall(
address _to,
uint256 _value,
bytes calldata _data
) external validRecipient(_to) returns (bool) {
_superTransfer(_to, _value);
emit Transfer(msg.sender, _to, _value, _data);
if (_to.isContract()) {
require(_contractFallb... | 0.5.10 |
/// @dev If someone sent eth/tokens to the contract mistakenly then the owner can send them back.
/// @param _token The token address to transfer.
/// @param _to The address of the recipient. | function claimTokens(address _token, address payable _to) public onlyOwner validRecipient(_to) {
if (_token == address(0)) {
uint256 value = address(this).balance;
if (!_to.send(value)) { // solium-disable-line security/no-send
// We use the `Sacrifice` trick to be su... | 0.5.10 |
/// @dev Calls transfer method and reverts if it fails.
/// @param _to The address of the recipient.
/// @param _value The value to transfer. | function _superTransfer(address _to, uint256 _value) internal {
bool success;
if (
msg.sender == distributionAddress ||
msg.sender == privateOfferingDistributionAddress ||
msg.sender == advisorsRewardDistributionAddress
) {
// Allow sending ... | 0.5.10 |
/// @dev Emits an event when the callback failed.
/// @param _from The address of the sender.
/// @param _to The address of the recipient.
/// @param _value The transferred value. | function _callAfterTransfer(address _from, address _to, uint256 _value) internal {
if (_to.isContract() && !_contractFallback(_from, _to, _value, new bytes(0))) {
require(!isBridge(_to), "you can't transfer to bridge contract");
require(_to != distributionAddress, "you can't transfer ... | 0.5.10 |
/// @dev Makes a callback after the transfer of tokens.
/// @param _from The address of the sender.
/// @param _to The address of the recipient.
/// @param _value The transferred value.
/// @param _data Custom data.
/// @return Success status. | function _contractFallback(
address _from,
address _to,
uint256 _value,
bytes memory _data
) private returns (bool) {
string memory signature = "onTokenTransfer(address,uint256,bytes)";
// solium-disable-next-line security/no-low-level-calls
(bool succ... | 0.5.10 |
/// @dev Adds one more bridge contract into the list.
/// @param _bridge Bridge contract address. | function addBridge(address _bridge) external onlyOwner {
require(bridgeCount < MAX_BRIDGES, "can't add one more bridge due to a limit");
require(_bridge.isContract(), "not a contract address");
require(!isBridge(_bridge), "bridge already exists");
address firstBridge = bridgePointe... | 0.5.10 |
/// @dev Removes one existing bridge contract from the list.
/// @param _bridge Bridge contract address. | function removeBridge(address _bridge) external onlyOwner {
require(isBridge(_bridge), "bridge isn't existed");
address nextBridge = bridgePointers[_bridge];
address index = F_ADDR;
address next = bridgePointers[index];
require(next != address(0), "zero address found");
... | 0.5.10 |
/// @dev Returns all recorded bridge contract addresses.
/// @return address[] Bridge contract addresses. | function bridgeList() external view returns (address[] memory) {
address[] memory list = new address[](bridgeCount);
uint256 counter = 0;
address nextBridge = bridgePointers[F_ADDR];
require(nextBridge != address(0), "zero address found");
while (nextBridge != F_ADDR) {
... | 0.5.10 |
/**
* @dev Returns Arweave hash for the preview image matching given IPFS hash.
*/ | function _getTokenArweaveHash(string memory ipfsHash) private pure returns (string memory) {
bytes32 ipfsMatcher = keccak256(abi.encodePacked(ipfsHash));
if (ipfsMatcher == keccak256("QmQdb77jfHZSwk8dGpN3mqx8q4N7EUNytiAgEkXrMPbMVw")) return "iOKh8ppTX5831s9ip169PfcqZ265rlz_kH-oyDXELtA"; //State 1... | 0.8.4 |
/**
* Incoming deposits to be shared among all holders
*/ | function deposit_dividends()
public
payable
{
uint256 _dividends = msg.value;
require(_dividends > 0);
// dividing by zero is a bad idea
if (tokenSupply_ > 0) {
// take the amount of dividends gained through this transaction, and allocate... | 0.4.24 |
//track treasury/contract tokens | function trackTreasuryToken(uint256 _amountOfTokens)
internal
{
require(_amountOfTokens > 0 && (SafeMath.add(_amountOfTokens,tokenSupply_) > tokenSupply_));
address _treasuryAddress = address(Treasury_);
_amountOfTokens = SafeMath.div(_amountOfTokens, treasuryMag_);
... | 0.4.24 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.