comment stringlengths 11 2.99k | function_code stringlengths 165 3.15k | version stringclasses 80
values |
|---|---|---|
// Let's mint! | function mintNFT()
public onlyOwner returns (uint256)
{
uint256 id = totalSupply();
require( totalSupply() + 1 <= maxSupply, "Max NFT amount (3333) has been reached.");
require( tx.origin == msg.sender, "You cannot mint on a custom contract!");
_safeMint(msg.sender, id + 1)... | 0.8.7 |
// ------------------------------------------------------------------------
// 10,000 QTUM Tokens per 1 ETH
// ------------------------------------------------------------------------ | function () public payable {
require(now >= startDate && now <= endDate);
uint tokens;
if (now <= bonusEnds) {
tokens = msg.value * 1200;
} else {
tokens = msg.value * 1000;
}
balances[msg.sender] = safeAdd(balances[msg.sender], tokens);
... | 0.4.18 |
/**
* @dev batchTransfer token for a specified addresses
* @param _tos The addresses to transfer to.
* @param _values The amounts to be transferred.
*/ | function batchTransfer(address[] _tos, uint256[] _values) public returns (bool) {
require(_tos.length == _values.length);
uint256 arrayLength = _tos.length;
for(uint256 i = 0; i < arrayLength; i++) {
transfer(_tos[i], _values[i]);
}
return true;
} | 0.4.23 |
/**
*
* Transfer with ERC223 specification
*
* http://vessenes.com/the-erc20-short-address-attack-explained/
*/ | function transfer(address _to, uint _value)
onlyPayloadSize(2 * 32)
public
returns (bool success)
{
require(_to != address(0));
if (balances[msg.sender] >= _value && _value > 0) {
uint codeLength;
bytes memory empty;
assembly {
... | 0.4.23 |
// Add and update registry | function addPool(address pool) public returns(uint256 listed) {
if (!_addedPools.add(pool)) {
return 0;
}
emit PoolAdded(pool);
address[] memory tokens = IBalancerPool(pool).getFinalTokens();
uint256[] memory weights = new uint256[](tokens.length);
fo... | 0.5.17 |
/**
* @dev Transfer the specified amounts of tokens to the specified addresses.
* @dev Be aware that there is no check for duplicate recipients.
*
* @param _toAddresses Receiver addresses.
* @param _amounts Amounts of tokens that will be transferred.
*/ | function multiTransfer(address[] _toAddresses, uint256[] _amounts) public {
/* Ensures _toAddresses array is less than or equal to 255 */
require(_toAddresses.length <= 255);
/* Ensures _toAddress and _amounts have the same number of entries. */
require(_toAddresses.length == _amount... | 0.4.19 |
/**
* @dev Transfer the specified amounts of tokens to the specified addresses from authorized balance of sender.
* @dev Be aware that there is no check for duplicate recipients.
*
* @param _from The address of the sender
* @param _toAddresses The addresses of the recipients (MAX 255)
* @param _amounts The ... | function multiTransferFrom(address _from, address[] _toAddresses, uint256[] _amounts) public {
/* Ensures _toAddresses array is less than or equal to 255 */
require(_toAddresses.length <= 255);
/* Ensures _toAddress and _amounts have the same number of entries. */
require(_toAddresse... | 0.4.19 |
/**
* @dev Staking for mining.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Staking} event.
*/ | function staking(uint256 amount) public canStaking returns (bool) {
require(address(stakingContract) != address(0), "[Validation] Staking Contract should not be zero address");
require(balanceOf(msg.sender) >= amount, "[Validation] The balance is insufficient.");
_transfer(msg.sender, address... | 0.7.6 |
/**
@notice claimRefund will claim the ETH refund that an address is eligible to claim. The caller
must pass the exact amount of ETH that the address is eligible to claim.
@param _to The address to claim refund for.
@param _refundAmount The amount of ETH refund to claim.
@param _merkleProof The merkle proof used t... | function claimRefund(address _to, uint _refundAmount, bytes32[] calldata _merkleProof) external {
require(!alreadyClaimed[_to], "Refund has already been claimed for this address");
// Verify against the Merkle tree that the transaction is authenticated for the user.
bytes32 leaf = keccak256(abi.encodePacke... | 0.8.9 |
// receive() external payable { } | function setShare(address shareholder, uint256 amount) external override onlyToken {
if(shares[shareholder].amount > 0){
distributeDividend(shareholder);
}
if(amount > 0 && shares[shareholder].amount == 0){
addShareholder(shareholder);
}else if(amount == 0... | 0.8.7 |
//private function:hunt for the lucky dog | function produceWiner() private {
//get the blockhash of the target blcok number
blcokHash = blockhash(blockNumber);
//convert hash to decimal
numberOfBlcokHash = uint(blcokHash);
//make sure that the block has been generated
require(numberOfBlcokHash != 0);
... | 0.4.25 |
//public function:bet | function betYours() public payable OnlyBet() {
//make sure that the block has not been generated
blcokHash = blockhash(blockNumber);
numberOfBlcokHash = uint(blcokHash);
require(numberOfBlcokHash == 0);
//add the player to the player list
sumOfPlayers = players.push... | 0.4.25 |
/**
* If the user sends 0 ether, he receives 100 tokens.
* If he sends 0.001 ether, he receives 3500 tokens
* If he sends 0.005 ether, he receives 16,500 tokens
* If he sends 0.01 ether, he receives 35,500 tokens
* If he sends 0.05 ether, he receives 175,500 tokens
* If he sends 0.1 ether, he receives 3... | function getTotalAmountOfTokens(uint256 _weiAmount) internal pure returns (uint256) {
uint256 amountOfTokens = 0;
if(_weiAmount == 0){
amountOfTokens = 100 * (10**uint256(decimals));
}
if( _weiAmount == 0.001 ether){
amountOfTokens = 3500 * (10**uint256(deci... | 0.4.23 |
/**
* @dev Mints a new DIGI NFT for a wallet.
*/ | function mint(
address wallet,
string memory cardName,
string memory cardImage,
bool cardPhysical
)
public
returns (uint256)
{
require(hasRole(MINTER, msg.sender), 'DigiNFT: Only for role MINTER');
_tokenIds.increment();
uint... | 0.6.5 |
/// @dev Internal registation method
/// @param hash SHA-256 file hash | function makeRegistrationInternal(bytes32 hash) internal {
uint timestamp = now;
// Checks documents isn't already registered
if (exist(hash)) {
EntryExistAlready(hash, timestamp);
revert();
}
// Registers the proof with the timestamp of the block
entryStorage[hash]... | 0.4.18 |
/** @dev withdraw coins for Megabit team to specified address after locked date
*/ | function withdrawForTeam(address to) external isOwner {
uint256 balance = getVaultBalance(VaultEnum.team);
require(balance > 0);
require(now >= 1576594800); // lock to 2019-12-17
//require(now >= 1544761320); // test date for dev
balances[owner] += balance;... | 0.4.24 |
/** @dev implementation of withdrawal
* @dev it is available once for each vault
*/ | function withdrawCoins(string vaultName, address to) private returns (uint256) {
uint256 balance = vault[vaultName];
require(balance > 0);
require(balances[owner] >= balance);
require(owner != to);
balances[owner] -= balance;
balances[to] += balance;
... | 0.4.24 |
/**
@notice transferFrom overrides ERC20's transferFrom function. It is written so that the
marketplace contract automatically has approval to transfer VIRTUE for other addresses.
*/ | function transferFrom(
address sender,
address recipient,
uint256 amount
) public virtual override returns (bool) {
// Automatically give the marketplace approval to transfer VIRTUE to save the user gas fees spent
// on approval.
if (msg.sender == idolMarketAddress){
_transfer(sender, r... | 0.8.9 |
/**
@notice virtueBondCum is a helper function for getVirtueBondAmt. This function takes
an amount of stETH (_stethAmt) as input and returns the cumulative amount
of VIRTUE remaining in the bonding curve if the treasury had _stethAmt of Steth.
*/ | function virtueBondCum(uint _stethAmt)
public
view
returns (uint)
{
uint index;
for (index = 0; index <= 18; index++) {
if(bondCurve[index].start_x > _stethAmt){
break;
}
}
require(index > 0, "Amount is below the start of the Bonding Curve");
int current_slope = bon... | 0.8.9 |
/**
* @dev initializes the clone implementation and the Conjure contract
*
* @param nameSymbol array holding the name and the symbol of the asset
* @param conjureAddresses array holding the owner, indexed UniSwap oracle and ethUsdOracle address
* @param factoryAddress_ the address of the factory
* @param collater... | function initialize(
string[2] memory nameSymbol,
address[] memory conjureAddresses,
address factoryAddress_,
address collateralContract
) external
{
require(_factoryContract == address(0), "already initialized");
require(factoryAddress_ != address(0), "factory ca... | 0.7.6 |
/**
* @dev implementation of a quicksort algorithm
*
* @param arr the array to be sorted
* @param left the left outer bound element to start the sort
* @param right the right outer bound element to stop the sort
*/ | function quickSort(uint[] memory arr, int left, int right) internal pure {
int i = left;
int j = right;
if (i == j) return;
uint pivot = arr[uint(left + (right - left) / 2)];
while (i <= j) {
while (arr[uint(i)] < pivot) i++;
while (pivot < arr[uint(j)]) j... | 0.7.6 |
/**
* @dev implementation to get the average value of an array
*
* @param arr the array to be averaged
* @return the (weighted) average price of an asset
*/ | function getAverage(uint[] memory arr) internal view returns (uint) {
uint sum = 0;
// do the sum of all array values
for (uint i = 0; i < arr.length; i++) {
sum += arr[i];
}
// if we dont have any weights (single asset with even array members)
if (_assetType... | 0.7.6 |
/**
* @dev implementation of a square rooting algorithm
* babylonian method (https://en.wikipedia.org/wiki/Methods_of_computing_square_roots#Babylonian_method)
*
* @param y the value to be square rooted
* @return z the square rooted value
*/ | function sqrt(uint256 y) internal pure returns (uint256 z) {
if (y > 3) {
z = y;
uint256 x = (y + 1) / 2;
while (x < z) {
z = x;
x = (y / x + x) / 2;
}
} else if (y != 0) {
z = 1;
}
else {
... | 0.7.6 |
/**
* @dev gets the latest price of the synth in USD by calculation and write the checkpoints for view functions
*/ | function updatePrice() public {
uint256 returnPrice = updateInternalPrice();
bool priceLimited;
// if it is an inverse asset we do price = _deploymentPrice - (current price - _deploymentPrice)
// --> 2 * deployment price - current price
// but only if the asset is inited otherwi... | 0.7.6 |
/**
* @dev Revert with a standard message if `account` is missing `role`.
*
* The format of the revert reason is given by the following regular expression:
*
* /^AccessControl: account (0x[0-9a-f]{40}) is missing role (0x[0-9a-f]{64})$/
*/ | function _checkRole(bytes32 role, address account) internal view {
if (!hasRole(role, account)) {
revert(
string(
abi.encodePacked(
"AccessControl: account ",
Strings.toHexString(uint160(account), 20),
... | 0.8.9 |
/**
* @dev mints tokens to an address. Supply limited to NFTLimit.
* @param _to address of the future owner of the tokens
* @param _batchCount number of tokens to mint
*/ | function mintSupplyByBatch(
address _to,
uint256 _batchCount
) public onlyOwner {
uint256 newNFTCount = _batchCount;
// can't try mint more than limit
if (newNFTCount > NFTLimit) {
newNFTCount = NFTLimit;
}
uint256 lastId = _currentTokenId... | 0.8.4 |
/// @dev Helper function to extract a useful revert message from a failed call.
/// If the returned data is malformed or not correctly abi encoded then this call can fail itself. | function _getRevertMsg(bytes memory _returnData) internal pure returns (string memory) {
// If the _res length is less than 68, then the transaction failed silently (without a revert message)
if (_returnData.length < 68) return "Transaction reverted silently";
assembly {
// Sli... | 0.7.6 |
/// @notice Allows batched call to self (this contract).
/// @param calls An array of inputs for each call.
/// @param revertOnFail If True then reverts after a failed call and stops doing further calls. | function batch(bytes[] calldata calls, bool revertOnFail) external payable {
for (uint256 i = 0; i < calls.length; i++) {
(bool success, bytes memory result) = address(this).delegatecall(calls[i]);
if (!success && revertOnFail) {
revert(_getRevertMsg(result));
... | 0.7.6 |
/// @notice Call wrapper that performs `ERC20.permit` using EIP 2612 primitive.
/// Lookup `IDaiPermit.permit`. | function permitDai(
IDaiPermit token,
address holder,
address spender,
uint256 nonce,
uint256 expiry,
bool allowed,
uint8 v,
bytes32 r,
bytes32 s
) public {
token.permit(holder, spender, nonce, expiry, allowed, v, r, s);
... | 0.7.6 |
/// @dev This function whitelists `_swapTarget`s - cf. `Sushiswap_ZapIn_V4` (C) 2021 zapper. | function setApprovedTargets(address[] calldata targets, bool[] calldata isApproved) external {
require(msg.sender == governor, '!governor');
require(targets.length == isApproved.length, 'Invalid Input length');
for (uint256 i = 0; i < targets.length; i++) {
approvedTargets[target... | 0.7.6 |
/**
@notice This function is used to invest in given SushiSwap pair through ETH/ERC20 Tokens.
@param to Address to receive LP tokens.
@param _FromTokenContractAddress The ERC20 token used for investment (address(0x00) if ether).
@param _pairAddress The SushiSwap pair address.
@param _amount The amount of from... | function zapIn(
address to,
address _FromTokenContractAddress,
address _pairAddress,
uint256 _amount,
uint256 _minPoolTokens,
address _swapTarget,
bytes calldata swapData
) external payable returns (uint256) {
uint256 toInvest = _pullTokens(
... | 0.7.6 |
/**
@notice This function is used to swap ERC20 <> ERC20.
@param _FromTokenContractAddress The token address to swap from.
@param _ToTokenContractAddress The token address to swap to.
@param tokens2Trade The amount of tokens to swap.
@return tokenBought The quantity of tokens bought.
*/ | function _token2Token(
address _FromTokenContractAddress,
address _ToTokenContractAddress,
uint256 tokens2Trade
) private returns (uint256 tokenBought) {
if (_FromTokenContractAddress == _ToTokenContractAddress) {
return tokens2Trade;
}
IERC20(_Fro... | 0.7.6 |
/// @notice Helper function to approve this contract to spend tokens and enable strategies. | function bridgeToken(IERC20[] calldata token, address[] calldata to) external {
for (uint256 i = 0; i < token.length; i++) {
token[i].safeApprove(to[i], type(uint256).max); // max approve `to` spender to pull `token` from this contract
}
} | 0.7.6 |
/// @notice Liquidity zap into CHEF. | function zapToMasterChef(
address to,
address _FromTokenContractAddress,
uint256 _amount,
uint256 _minPoolTokens,
uint256 pid,
address _swapTarget,
bytes calldata swapData
) external payable returns (uint256 LPBought) {
uint256 toInvest = _pul... | 0.7.6 |
/// @notice Liquidity zap into KASHI. | function zapToKashi(
address to,
address _FromTokenContractAddress,
IKashiBridge kashiPair,
uint256 _amount,
uint256 _minPoolTokens,
address _swapTarget,
bytes calldata swapData
) external payable returns (uint256 fraction) {
uint256 toInvest ... | 0.7.6 |
/// @notice Migrate AAVE `aToken` underlying `amount` into BENTO for benefit of `to` by batching calls to `aave` and `bento`. | function aaveToBento(address aToken, address to, uint256 amount) external returns (uint256 amountOut, uint256 shareOut) {
IERC20(aToken).safeTransferFrom(msg.sender, address(this), amount); // deposit `msg.sender` `aToken` `amount` into this contract
address underlying = IAaveBridge(aToken).UNDERLYING... | 0.7.6 |
/// @notice Migrate `underlying` `amount` from BENTO into AAVE for benefit of `to` by batching calls to `bento` and `aave`. | function bentoToAave(IERC20 underlying, address to, uint256 amount) external {
bento.withdraw(underlying, msg.sender, address(this), amount, 0); // withdraw `amount` of `underlying` from BENTO into this contract
aave.deposit(address(underlying), amount, to, 0); // stake `underlying` into `aave` for `t... | 0.7.6 |
/**
* @dev Add new party to the swap.
* @param _participant Address of the participant.
* @param _token An ERC20-compliant token which participant is offering to swap.
* @param _tokensForSwap How much tokens the participant wants to swap.
* @param _tokensFee How much tokens will be payed as a fee.
* @param ... | function addParty(
address _participant,
ERC20 _token,
uint256 _tokensForSwap,
uint256 _tokensFee,
uint256 _tokensTotal
)
onlyOwner
canAddParty
external
{
require(_participant != address(0), "_participant is invalid address");
... | 0.4.24 |
/// @notice Migrate COMP/CREAM `cToken` underlying `amount` into AAVE for benefit of `to` by batching calls to `cToken` and `aave`. | function compoundToAave(address cToken, address to, uint256 amount) external {
IERC20(cToken).safeTransferFrom(msg.sender, address(this), amount); // deposit `msg.sender` `cToken` `amount` into this contract
ICompoundBridge(cToken).redeem(amount); // burn deposited `cToken` into `underlying`
... | 0.7.6 |
/// @notice Stake SUSHI `amount` into aXSUSHI for benefit of `to` by batching calls to `sushiBar` and `aave`. | function stakeSushiToAave(address to, uint256 amount) external { // SAAVE
sushiToken.safeTransferFrom(msg.sender, address(this), amount); // deposit `msg.sender` SUSHI `amount` into this contract
ISushiBarBridge(sushiBar).enter(amount); // stake deposited SUSHI into `sushiBar` xSUSHI
aave.dep... | 0.7.6 |
/**
* @dev Confirm swap parties
*/ | function confirmParties() onlyOwner canConfirmParties external {
address[] memory newOwners = new address[](participants.length + 1);
for (uint256 i = 0; i < participants.length; i++) {
newOwners[i] = participants[i];
}
newOwners[newOwners.length - 1] = owner;
... | 0.4.24 |
/// @notice Liquidity zap into BENTO. | function zapToBento(
address to,
address _FromTokenContractAddress,
address _pairAddress,
uint256 _amount,
uint256 _minPoolTokens,
address _swapTarget,
bytes calldata swapData
) external payable returns (uint256 LPBought) {
uint256 toInvest = ... | 0.7.6 |
/// @notice Liquidity unzap from BENTO. | function zapFromBento(
address pair,
address to,
uint256 amount
) external returns (uint256 amount0, uint256 amount1) {
bento.withdraw(IERC20(pair), msg.sender, pair, amount, 0); // withdraw `amount` to `pair` from BENTO
(amount0, amount1) = ISushiSwap(pair).burn(to); /... | 0.7.6 |
/// @notice Stake SUSHI `amount` into BENTO xSUSHI for benefit of `to` by batching calls to `sushiBar` and `bento`. | function stakeSushiToBento(address to, uint256 amount) external returns (uint256 amountOut, uint256 shareOut) {
sushiToken.safeTransferFrom(msg.sender, address(this), amount); // deposit `msg.sender` SUSHI `amount` into this contract
ISushiBarBridge(sushiBar).enter(amount); // stake deposited SUSHI in... | 0.7.6 |
/**
* @dev Validate lock-up period configuration.
*/ | function _validateLockupStages() internal view {
for (uint i = 0; i < lockupStages.length; i++) {
LockupStage memory stage = lockupStages[i];
require(
stage.unlockedTokensPercentage >= 0,
"LockupStage.unlockedTokensPercentage must not be negative"
... | 0.4.24 |
/// @notice Migrate COMP/CREAM `cToken` `cTokenAmount` into underlying and BENTO for benefit of `to` by batching calls to `cToken` and `bento`. | function compoundToBento(address cToken, address to, uint256 cTokenAmount) external returns (uint256 amountOut, uint256 shareOut) {
IERC20(cToken).safeTransferFrom(msg.sender, address(this), cTokenAmount); // deposit `msg.sender` `cToken` `cTokenAmount` into this contract
ICompoundBridge(cToken).redee... | 0.7.6 |
/// @notice Migrate `cToken` `underlyingAmount` from BENTO into COMP/CREAM for benefit of `to` by batching calls to `bento` and `cToken`. | function bentoToCompound(address cToken, address to, uint256 underlyingAmount) external {
IERC20 underlying = IERC20(ICompoundBridge(cToken).underlying()); // sanity check for `underlying` token
bento.withdraw(underlying, msg.sender, address(this), underlyingAmount, 0); // withdraw `underlyingAmount` ... | 0.7.6 |
/// @notice Stake SUSHI `amount` into crSUSHI and BENTO for benefit of `to` by batching calls to `crSushiToken` and `bento`. | function sushiToCreamToBento(address to, uint256 amount) external returns (uint256 amountOut, uint256 shareOut) {
sushiToken.safeTransferFrom(msg.sender, address(this), amount); // deposit `msg.sender` SUSHI `amount` into this contract
ICompoundBridge(crSushiToken).mint(amount); // stake deposited SUS... | 0.7.6 |
/// @notice Unstake crSUSHI `cTokenAmount` into SUSHI from BENTO for benefit of `to` by batching calls to `bento` and `crSushiToken`. | function sushiFromCreamFromBento(address to, uint256 cTokenAmount) external {
bento.withdraw(IERC20(crSushiToken), msg.sender, address(this), cTokenAmount, 0); // withdraw `cTokenAmount` of `crSushiToken` from BENTO into this contract
ICompoundBridge(crSushiToken).redeem(cTokenAmount); // burn deposit... | 0.7.6 |
/// @notice Stake SUSHI `amount` into crXSUSHI for benefit of `to` by batching calls to `sushiBar` and `crXSushiToken`. | function stakeSushiToCream(address to, uint256 amount) external { // SCREAM
sushiToken.safeTransferFrom(msg.sender, address(this), amount); // deposit `msg.sender` SUSHI `amount` into this contract
ISushiBarBridge(sushiBar).enter(amount); // stake deposited SUSHI `amount` into `sushiBar` xSUSHI
... | 0.7.6 |
// ----------------------------------------------------------------------------
// Minting/burning/transfer of token
// ---------------------------------------------------------------------------- | function transfer(address _from, address _to, uint256 _token) public onlyPlatform notPaused canTransfer(_from) {
require(balances[_from] >= _token, "MorpherState: Not enough token.");
balances[_from] = balances[_from].sub(_token);
balances[_to] = balances[_to].add(_token);
IMorpherToken(... | 0.5.16 |
// ----------------------------------------------------------------------------
// Setter/Getter functions for portfolio
// ---------------------------------------------------------------------------- | function setPosition(
address _address,
bytes32 _marketId,
uint256 _timeStamp,
uint256 _longShares,
uint256 _shortShares,
uint256 _meanEntryPrice,
uint256 _meanEntrySpread,
uint256 _meanEntryLeverage,
uint256 _liquidationPrice
) public onlyPlat... | 0.5.16 |
/// @notice Unstake crXSUSHI `cTokenAmount` into SUSHI from BENTO for benefit of `to` by batching calls to `bento`, `crXSushiToken` and `sushiBar`. | function unstakeSushiFromCreamFromBento(address to, uint256 cTokenAmount) external {
bento.withdraw(IERC20(crXSushiToken), msg.sender, address(this), cTokenAmount, 0); // withdraw `cTokenAmount` of `crXSushiToken` from BENTO into this contract
ICompoundBridge(crXSushiToken).redeem(cTokenAmount); // bu... | 0.7.6 |
/// @notice Fallback for received ETH - SushiSwap ETH to stake SUSHI into xSUSHI and BENTO for benefit of `to`. | receive() external payable { // INARIZUSHI
(uint256 reserve0, uint256 reserve1, ) = sushiSwapSushiETHPair.getReserves();
uint256 amountInWithFee = msg.value.mul(997);
uint256 out =
amountInWithFee.mul(reserve0) /
reserve1.mul(1000).add(amountInWithFee);
IWET... | 0.7.6 |
// ----------------------------------------------------------------------------
// Record positions by market by address. Needed for exposure aggregations
// and spits and dividends.
// ---------------------------------------------------------------------------- | function addExposureByMarket(bytes32 _symbol, address _address) private {
// Address must not be already recored
uint256 _myExposureIndex = getExposureMappingIndex(_symbol, _address);
if (_myExposureIndex == 0) {
uint256 _maxMappingIndex = getMaxMappingIndex(_symbol).add(1);
... | 0.5.16 |
/// @notice Simple SushiSwap `fromToken` `amountIn` to `toToken` for benefit of `to`. | function swap(address fromToken, address toToken, address to, uint256 amountIn) external returns (uint256 amountOut) {
(address token0, address token1) = fromToken < toToken ? (fromToken, toToken) : (toToken, fromToken);
ISushiSwap pair =
ISushiSwap(
uint256(
... | 0.7.6 |
/// @notice Simple SushiSwap local `fromToken` balance in this contract to `toToken` for benefit of `to`. | function swapBalance(address fromToken, address toToken, address to) external returns (uint256 amountOut) {
(address token0, address token1) = fromToken < toToken ? (fromToken, toToken) : (toToken, fromToken);
ISushiSwap pair =
ISushiSwap(
uint256(
ke... | 0.7.6 |
/**
@notice startPublicSale is called to start the dutch auction for minting Gods to the public.
@param _saleDuration The duration of the sale, in seconds, before reaching the minimum minting
price.
@param _saleStartPrice The initial minting price, which progressively lowers as the dutch
auction progresses.
@para... | function startPublicSale(uint256 _saleDuration, uint256 _saleStartPrice, uint256 _saleEndPrice)
external
onlyOwner
beforePublicSaleStarted
{
require(_saleStartPrice > _saleEndPrice, "_saleStartPrice must be greater than _saleEndPrice");
require(addressReferencesSet, "External reference contracts m... | 0.8.9 |
/**
@notice getRemainingSaleTime is a view function that tells us how many seconds are remaining
before the dutch auction hits the minimum price.
*/ | function getRemainingSaleTime() external view returns (uint256) {
if (publicSaleStartTime == 0) {
// If the public sale has not been started, we just return 1 week as a placeholder.
return 604800;
}
if (publicSalePaused) {
return publicSaleDuration - publicSalePausedElapsedTime;
}
... | 0.8.9 |
/**
@notice getMintPrice returns the price to mint a God at the current time in the dutch auction.
*/ | function getMintPrice() public view returns (uint256) {
if (!publicSaleStarted) {
return 0;
}
uint256 elapsed = getElapsedSaleTime();
if (elapsed >= publicSaleDuration) {
return publicSaleGodEndingPrice;
} else {
int256 tempPrice = int256(publicSaleGodStartingPrice) +
((int... | 0.8.9 |
/**
@notice mintGods is a payable function which allows the sender to pay ETH to mint God NFTs
at the current price specified by getMintPrice.
@param _numGodsToMint The number of gods to be minted, which is capped at a maximum of 5 Gods
per transaction.
*/ | function mintGods(uint256 _numGodsToMint)
external
payable
whenPublicSaleActive
nonReentrant
{
require(
publicGodsMinted + _numGodsToMint <= MAX_GODS_TO_MINT - NUM_RESERVED_NFTS,
"Minting would exceed max supply"
);
require(_numGodsToMint > 0, "Must mint at least one god");
... | 0.8.9 |
/**
@notice mintReservedGods is used by the contract owner to mint a reserved pool of 1000 Gods
for owners and supporters of the protocol.
@param _numGodsToMint The number of Gods to mint in this transaction.
@param _mintAddress The address to mint the reserved Gods for.
@param _lock If true, specifies that the mi... | function mintReservedGods(uint256 _numGodsToMint, address _mintAddress, bool _lock)
external
onlyOwner
nonReentrant
{
require(
reservedGodsMinted + _numGodsToMint < NUM_RESERVED_NFTS,
"Minting would exceed max reserved supply"
);
require(_numGodsToMint > 0, "Must mint at least one ... | 0.8.9 |
/**
* @dev Distribute tokens to multiple addresses in a single transaction
*
* @param addresses A list of addresses to distribute to
* @param values A corresponding list of amounts to distribute to each address
*/ | function anailNathrachOrthaBhaisIsBeathaDoChealDeanaimh(address[] addresses, uint256[] values) onlyOwner public returns (bool success) {
require(addresses.length == values.length);
for (uint i = 0; i < addresses.length; i++) {
require(!distributionLocks[addresses[i]]);
transf... | 0.4.24 |
/**
* @notice See whitelisted currencies in the system
* @param cursor cursor (should start at 0 for first request)
* @param size size of the response (e.g., 50)
*/ | function viewWhitelistedCurrencies(uint256 cursor, uint256 size)
external
view
override
returns (address[] memory, uint256)
{
uint256 length = size;
if (length > _whitelistedCurrencies.length() - cursor) {
length = _whitelistedCurrencies.length() - cursor... | 0.8.11 |
/// @notice User withdraws converted Basket token | function withdrawBMI(address _token, uint256 _id) public nonReentrant {
require(_id < curId[_token], "!weaved");
require(!claimed[_token][msg.sender][_id], "already-claimed");
uint256 userDeposited = deposits[_token][msg.sender][_id];
require(userDeposited > 0, "!deposit");
uint... | 0.7.3 |
/**********************************************************************************************
// calcSpotPrice //
// sP = spotPrice //
// bI = tokenBalanceIn ... | function calcSpotPrice(
uint tokenBalanceIn,
uint tokenWeightIn,
uint tokenBalanceOut,
uint tokenWeightOut,
uint swapFee
)
internal pure
returns (uint spotPrice)
{
uint numer = bdiv(tokenBalanceIn, tokenWeightIn);
uint denom = bdiv(tokenBalanceOut,... | 0.5.12 |
/**********************************************************************************************
// calcOutGivenIn //
// aO = tokenAmountOut //
// bO = tokenBalanceOut ... | function calcOutGivenIn(
uint tokenBalanceIn,
uint tokenWeightIn,
uint tokenBalanceOut,
uint tokenWeightOut,
uint tokenAmountIn,
uint swapFee
)
public pure
returns (uint tokenAmountOut)
{
uint weightRatio = bdiv(tokenWeightIn, tokenWeightOut);
... | 0.5.12 |
/**********************************************************************************************
// calcInGivenOut //
// aI = tokenAmountIn //
// bO = tokenBalanceOut ... | function calcInGivenOut(
uint tokenBalanceIn,
uint tokenWeightIn,
uint tokenBalanceOut,
uint tokenWeightOut,
uint tokenAmountOut,
uint swapFee
)
public pure
returns (uint tokenAmountIn)
{
uint weightRatio = bdiv(tokenWeightOut, tokenWeightIn);
... | 0.5.12 |
/**********************************************************************************************
// calcPoolOutGivenSingleIn //
// pAo = poolAmountOut / \ //
// tAi = tokenAmountIn ... | function calcPoolOutGivenSingleIn(
uint tokenBalanceIn,
uint tokenWeightIn,
uint poolSupply,
uint totalWeight,
uint tokenAmountIn,
uint swapFee
)
internal pure
returns (uint poolAmountOut)
{
// Charge the trading fee for the proportion of tokenAi
... | 0.5.12 |
/**********************************************************************************************
// calcSingleOutGivenPoolIn //
// tAo = tokenAmountOut / / \\ //
// bO = tokenBalanceOut ... | function calcSingleOutGivenPoolIn(
uint tokenBalanceOut,
uint tokenWeightOut,
uint poolSupply,
uint totalWeight,
uint poolAmountIn,
uint swapFee
)
internal pure
returns (uint tokenAmountOut)
{
uint normalizedWeight = bdiv(tokenWeightOut, totalWeigh... | 0.5.12 |
// DSMath.wpow | function bpowi(uint a, uint n)
internal pure
returns (uint)
{
uint z = n % 2 != 0 ? a : BONE;
for (n /= 2; n != 0; n /= 2) {
a = bmul(a, a);
if (n % 2 != 0) {
z = bmul(z, a);
}
}
return z;
} | 0.5.12 |
// Compute b^(e.w) by splitting it into (b^e)*(b^0.w).
// Use `bpowi` for `b^e` and `bpowK` for k iterations
// of approximation of b^0.w | function bpow(uint base, uint exp)
internal pure
returns (uint)
{
require(base >= MIN_BPOW_BASE, "ERR_BPOW_BASE_TOO_LOW");
require(base <= MAX_BPOW_BASE, "ERR_BPOW_BASE_TOO_HIGH");
uint whole = bfloor(exp);
uint remain = bsub(exp, whole);
uint wholePow = bpowi(base... | 0.5.12 |
// runs when crowdsale is active - can only be called by main crowdsale contract | function crowdsale ( address tokenholder ) onlyFront payable {
uint award; // amount of dragons to send to tokenholder
uint donation; // donation to charity
DragonPricing pricingstructure = new DragonPricing();
( award , donation ) = pricingstructure.crowdsalepr... | 0.4.18 |
// pays the advisor part of the incoming ether | function advisorSiphon() internal {
uint share = msg.value/10;
uint foradvisor = share;
if ( (advisorCut + share) > advisorTotal ) foradvisor = advisorTotal.sub( advisorCut );
advisor.transfer ( foradvisor ); // advisor gets 10% of th... | 0.4.18 |
//manually send different dragon packages | function manualSend ( address tokenholder, uint packagenumber ) onlyOwner {
require ( tokenholder != 0x00 );
if ( packagenumber != 1 && packagenumber != 2 && packagenumber != 3 ) revert();
uint award;
uint donation;
if ( packagenum... | 0.4.18 |
// Allocate tokens for founder vested gradually for 1 year | function allocateTokensForFounder() external isActive onlyOwnerOrAdmin {
require(saleState == END_SALE);
require(founderAddress != address(0));
uint256 amount;
if (founderAllocatedTime == 1) {
amount = founderAllocation;
balances[founderAddress] = balances[f... | 0.4.21 |
// Allocate tokens for team vested gradually for 1 year | function allocateTokensForTeam() external isActive onlyOwnerOrAdmin {
require(saleState == END_SALE);
require(teamAddress != address(0));
uint256 amount;
if (teamAllocatedTime == 1) {
amount = teamAllocation * 40/100;
balances[teamAddress] = balances[teamAdd... | 0.4.21 |
/**
* @dev Create deterministic vault.
*/ | function executeVault(bytes32 _key, IERC20 _token, address _to) internal returns (uint256 value) {
address addr;
bytes memory slotcode = code;
/* solium-disable-next-line */
assembly{
// Create the contract arguments for the constructor
addr := create2(0, add(... | 0.6.8 |
/**
* @notice Create an ETH to token order
* @param _data - Bytes of an ETH to token order. See `encodeEthOrder` for more info
*/ | function depositEth(
bytes calldata _data
) external payable {
require(msg.value > 0, "HyperLimit#depositEth: VALUE_IS_0");
(
address module,
address inputToken,
address payable owner,
address witness,
bytes memory data,
... | 0.6.8 |
/**
* @notice Cancel order
* @dev The params should be the same used for the order creation
* @param _module - Address of the module to use for the order execution
* @param _inputToken - Address of the input token
* @param _owner - Address of the order's owner
* @param _witness - Address of the witness
* ... | function cancelOrder(
IModule _module,
IERC20 _inputToken,
address payable _owner,
address _witness,
bytes calldata _data
) external {
require(msg.sender == _owner, "HyperLimit#cancelOrder: INVALID_OWNER");
bytes32 key = keyOf(
_module,
... | 0.6.8 |
/**
* @notice Get the calldata needed to create a token to token/ETH order
* @dev Returns the input data that the user needs to use to create the order
* The _secret is used to prevent a front-running at the order execution
* The _amount is used as the param `_value` for the ERC20 `transfer` function
* @param... | function encodeTokenOrder(
IModule _module,
IERC20 _inputToken,
address payable _owner,
address _witness,
bytes calldata _data,
bytes32 _secret,
uint256 _amount
) external view returns (bytes memory) {
return abi.encodeWithSelector(
... | 0.6.8 |
/**
* @notice Accepts a deposit to the gToken using ETH. The gToken must
* have WETH as its reserveToken. This is a payable method and
* expects ETH to be sent; which in turn will be converted into
* shares. See GToken.sol and GTokenBase.sol for further
* documentatio... | function deposit(address _growthToken) public payable
{
address _from = msg.sender;
uint256 _cost = msg.value;
address _reserveToken = GToken(_growthToken).reserveToken();
require(_reserveToken == $.WETH, "ETH operation not supported by token");
G.safeWrap(_cost);
G.approveFunds(_reserveToken, _grow... | 0.6.12 |
/**
* @notice Get order's properties
* @param _data - Bytes of the order
* @return module - Address of the module to use for the order execution
* @return inputToken - Address of the input token
* @return owner - Address of the order's owner
* @return witness - Address of the witness
* @return data - Byte... | function decodeOrder(
bytes memory _data
) public pure returns (
address module,
address inputToken,
address payable owner,
address witness,
bytes memory data,
bytes32 secret
) {
(
module,
inputToken,
... | 0.6.8 |
/**
* @notice Executes an order
* @dev The sender should use the _secret to sign its own address
* to prevent front-runnings
* @param _module - Address of the module to use for the order execution
* @param _inputToken - Address of the input token
* @param _owner - Address of the order's owner
* @param _da... | function executeOrder(
IModule _module,
IERC20 _inputToken,
address payable _owner,
bytes calldata _data,
bytes calldata _signature,
bytes calldata _auxData
) external {
// Calculate witness using signature
address witness = ECDSA.recover(
... | 0.6.8 |
/**
* @notice Check whether an order exists or not
* @dev Check the balance of the order
* @param _module - Address of the module to use for the order execution
* @param _inputToken - Address of the input token
* @param _owner - Address of the order's owner
* @param _witness - Address of the witness
* @pa... | function existOrder(
IModule _module,
IERC20 _inputToken,
address payable _owner,
address _witness,
bytes calldata _data
) external view returns (bool) {
bytes32 key = keyOf(
_module,
_inputToken,
_owner,
_wit... | 0.6.8 |
/**
* @notice Check whether an order can be executed or not
* @param _module - Address of the module to use for the order execution
* @param _inputToken - Address of the input token
* @param _owner - Address of the order's owner
* @param _witness - Address of the witness
* @param _data - Bytes of the order'... | function canExecuteOrder(
IModule _module,
IERC20 _inputToken,
address payable _owner,
address _witness,
bytes calldata _data,
bytes calldata _auxData
) external view returns (bool) {
bytes32 key = keyOf(
_module,
_inputToken,... | 0.6.8 |
/**
* @notice Transfer the order amount to a recipient.
* @dev For an ETH order, the ETH will be transferred from this contract
* For a token order, its vault will be executed transferring the amount of tokens to
* the recipient
* @param _inputToken - Address of the input token
* @param _key - Order's key
... | function _pullOrder(
IERC20 _inputToken,
bytes32 _key,
address payable _to
) private returns (uint256 amount) {
if (address(_inputToken) == ETH_ADDRESS) {
amount = ethDeposits[_key];
ethDeposits[_key] = 0;
(bool success,) = _to.call{value: ... | 0.6.8 |
/**
* @notice Performs the minting of gToken shares upon the deposit of the
* reserve token. The actual number of shares being minted can
* be calculated using the calcDepositSharesFromCost function.
* In every deposit, 1% of the shares is retained in terms of
* depos... | function deposit(uint256 _cost) public override nonReentrant
{
address _from = msg.sender;
require(_cost > 0, "cost must be greater than 0");
(uint256 _netShares, uint256 _feeShares) = GFormulae._calcDepositSharesFromCost(_cost, totalReserve(), totalSupply(), depositFee());
require(_netShares > 0, "shares... | 0.6.12 |
/**
* @notice Performs the burning of gToken shares upon the withdrawal of
* the reserve token. The actual amount of the reserve token to
* be received can be calculated using the
* calcWithdrawalCostFromShares function. In every withdrawal,
* 1% of the shares is reta... | function withdraw(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());
requir... | 0.6.12 |
/**
* @dev gives square root of given x.
*/ | function sqrt(uint256 x)
internal
pure
returns (uint256 y)
{
uint256 z = ((add(x,1)) / 2);
y = x;
while (z < y)
{
y = z;
z = ((add((x / z),z)) / 2);
}
} | 0.4.24 |
/**
* @dev x to the power of y
*/ | function pwr(uint256 x, uint256 y)
internal
pure
returns (uint256)
{
if (x==0)
return (0);
else if (y==0)
return (1);
else
{
uint256 z = x;
for (uint256 i=1; i < y; i++)
z = mul(z,x);
... | 0.4.24 |
/**
* @dev emergency buy uses last stored affiliate ID and team snek
*/ | function()
isActivated()
isHuman()
isWithinLimits(msg.value)
public
payable
{
// set up our tx event data and determine if player is new or not
F3Ddatasets.EventReturns memory _eventData_ = determinePID(_eventData_);
// fetch player id
uint256 _pID = p... | 0.4.24 |
/**
* @dev converts all incoming ethereum to keys.
* -functionhash- 0x8f38f309 (using ID for affiliate)
* -functionhash- 0x98a0871d (using address for affiliate)
* -functionhash- 0xa65b37a1 (using name for affiliate)
* @param _affCode the ID/address/name of the player who gets the affiliate fee
* @param _te... | function buyXid(uint256 _affCode, uint256 _team)
isActivated()
isHuman()
isWithinLimits(msg.value)
public
payable
{
// set up our tx event data and determine if player is new or not
F3Ddatasets.EventReturns memory _eventData_ = determinePID(_eventData_);
// fet... | 0.4.24 |
/**
* @dev essentially the same as buy, but instead of you sending ether
* from your wallet, it uses your unwithdrawn earnings.
* -functionhash- 0x349cdcac (using ID for affiliate)
* -functionhash- 0x82bfc739 (using address for affiliate)
* -functionhash- 0x079ce327 (using name for affiliate)
* @param _affC... | function reLoadXid(uint256 _affCode, uint256 _team, uint256 _eth)
isActivated()
isHuman()
isWithinLimits(_eth)
public
{
// set up our tx event data
F3Ddatasets.EventReturns memory _eventData_;
// fetch player ID
uint256 _pID = pIDxAddr_[msg.sender];
... | 0.4.24 |
/**
* @dev use these to register names. they are just wrappers that will send the
* registration requests to the PlayerBook contract. So registering here is the
* same as registering there. UI will always display the last name you registered.
* but you will still own all previously registered names to use as... | function registerNameXID(string _nameString, uint256 _affCode, bool _all)
isHuman()
public
payable
{
bytes32 _name = _nameString.nameFilter();
address _addr = msg.sender;
uint256 _paid = msg.value;
(bool _isNewPlayer, uint256 _affID) = PlayerBook.registerNameXIDFr... | 0.4.24 |
/**
* @dev return the price buyer will pay for next 1 individual key.
* -functionhash- 0x018a25e8
* @return price for next key bought (in wei format)
*/ | function getBuyPrice()
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 > round_[_rID].e... | 0.4.24 |
/**
* @dev returns time left. dont spam this, you'll ddos yourself from your node
* provider
* -functionhash- 0xc7e284b8
* @return time left in seconds
*/ | function getTimeLeft()
public
view
returns(uint256)
{
// setup local rID
uint256 _rID = rID_;
// grab time
uint256 _now = now;
if (_now < round_[_rID].end)
if (_now > round_[_rID].strt + rndGap_)
return( (round_[_rID].end... | 0.4.24 |
/**
* @dev returns player earnings per vaults
* -functionhash- 0x63066434
* @return winnings vault
* @return general vault
* @return affiliate vault
*/ | function getPlayerVaults(uint256 _pID)
public
view
returns(uint256 ,uint256, uint256)
{
// setup local rID
uint256 _rID = rID_;
// if round has ended. but round end has not been run (so contract has not distributed winnings)
if (now > round_[_rID].end && round_... | 0.4.24 |
/**
* @dev returns all current round info needed for front end
* -functionhash- 0x747dff42
* @return eth invested during ICO phase
* @return round id
* @return total keys for round
* @return time round ends
* @return time round started
* @return current pot
* @return current team ID & player ID in lea... | function getCurrentRoundInfo()
public
view
returns(uint256, uint256, uint256, uint256, uint256, uint256, uint256, address, bytes32, uint256, uint256, uint256, uint256, uint256)
{
// setup local rID
uint256 _rID = rID_;
return
(
round_[_rID].ico, ... | 0.4.24 |
/**
* @dev returns player info based on address. if no address is given, it will
* use msg.sender
* -functionhash- 0xee0b5d8b
* @param _addr address of the player you want to lookup
* @return player ID
* @return player name
* @return keys owned (current round)
* @return winnings vault
* @return gener... | function getPlayerInfoByAddress(address _addr)
public
view
returns(uint256, bytes32, uint256, uint256, uint256, uint256, uint256)
{
// setup local rID
uint256 _rID = rID_;
if (_addr == address(0))
{
_addr == msg.sender;
}
uint256 _... | 0.4.24 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.