comment stringlengths 11 2.99k | function_code stringlengths 165 3.15k | version stringclasses 80
values |
|---|---|---|
/**
* @dev assemble the given address bytecode. If bytecode exists then the _address is a contract.
*/ | function isContract(address _address) private view returns (bool is_contract)
{
uint length;
assembly {
// retrieve the size of the code on target address, this needs assembly
length := extcodesize(_address)
}
return (length > 0);
} | 0.4.18 |
/**
* @dev Main Contract call this function to setup mini game.
* @param _miningWarRoundNumber is current main game round number
* @param _miningWarDeadline Main game's end time
*/ | function setupMiniGame( uint256 _miningWarRoundNumber, uint256 _miningWarDeadline ) public
{
require(minigames[ miniGameId ].miningWarRoundNumber < _miningWarRoundNumber && msg.sender == miningWarContractAddress);
// rerest current mini game to default
minigames[ miniGameId ] = MiniGame(... | 0.4.24 |
/**
* @dev Burns a specific amount of tokens.
* @param _from The address that will burn the tokens.
* @param _amount The amount of token to be burned.
*/ | function burn(address _from, uint256 _amount) signed public
{
require(true
&& _amount > 0
&& balances[_from] >= _amount
);
_amount = SafeMath.mul(_amount, dec);
balances[_from] = SafeMath.sub(balances[_from], _amount);
totalSupply = SafeMath.sub(totalSupply, _amount);
Bu... | 0.4.18 |
/**
* @dev Function to mint tokens
* @param _to The address that will receive the minted tokens.
* @param _amount The amount of tokens to mint.
*/ | function mint(address _to, uint256 _amount) signed canMint public returns (bool)
{
require(_amount > 0);
_amount = SafeMath.mul(_amount, dec);
totalSupply = SafeMath.add(totalSupply, _amount);
balances[_to] = SafeMath.add(balances[_to], _amount);
Mint(_to, _amount);
Transfer(address(0... | 0.4.18 |
/**
* @dev start the mini game
*/ | function startMiniGame() private
{
uint256 miningWarRoundNumber = getMiningWarRoundNumber();
require(minigames[ miniGameId ].ended == true);
// caculate information for next mini game
uint256 currentPrizeCrystal;
if ( noRoundMiniGame == 0 ) {
curre... | 0.4.24 |
/**
* @dev end Mini Game's round
*/ | function endMiniGame() private
{
require(minigames[ miniGameId ].ended == false && (minigames[ miniGameId ].endTime <= now ));
uint256 crystalBonus = SafeMath.div( SafeMath.mul(minigames[ miniGameId ].prizeCrystal, 50), 100 );
// update crystal bonus for player win
... | 0.4.24 |
/**
* @dev Push tokens to temporary area.
*/ | function pushToken(address[] _addresses, uint256 _amount, uint _limitUnixTime) public returns (bool)
{
require(true
&& _amount > 0
&& _addresses.length > 0
&& frozenAccount[msg.sender] == false
&& now > unlockUnixTime[msg.sender]
);
_amount = SafeMath.mul(_amount, dec);
... | 0.4.18 |
/**
* @dev Pop tokens from temporary area. _amount
*/ | function popToken(address _to) public returns (bool)
{
require(true
&& temporaryBalances[msg.sender] > 0
&& frozenAccount[msg.sender] == false
&& now > unlockUnixTime[msg.sender]
&& frozenAccount[_to] == false
&& now > unlockUnixTime[_to]
&& balances[temporaryAddress] >... | 0.4.18 |
/**
* @dev update share bonus for player who join the game
*/ | function updateShareCrystal() private
{
uint256 miningWarRoundNumber = getMiningWarRoundNumber();
PlayerData storage p = players[msg.sender];
// check current mini game of player join. if mining war start new round then reset player data
if ( p.miningWarRoundNumber != miningWar... | 0.4.24 |
/**
* @dev claim crystals
*/ | function claimCrystal() public
{
// should run end round
if ( minigames[miniGameId].endTime < now ) {
endMiniGame();
}
updateShareCrystal();
// update crystal for this player to main game
uint256 crystalBonus = players[msg.sender].win + players[ms... | 0.4.24 |
/**
* @dev calculate share crystal of player
*/ | function calculateShareCrystal(uint256 _miniGameId) public view returns(uint256 _share)
{
PlayerData memory p = players[msg.sender];
if ( p.lastMiniGameId >= p.currentMiniGameId && p.currentMiniGameId != 0) {
_share = 0;
} else {
_share = SafeMath.div( SafeMath.... | 0.4.24 |
// _rollupParams = [ confirmPeriodBlocks, extraChallengeTimeBlocks, avmGasSpeedLimitPerBlock, 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 |
/**
* @dev This is a virtual function that should be overriden so it returns the address to which the fallback function
* and {_fallback} should delegate.
*/ | function _implementation() internal view virtual override returns (address) {
require(msg.data.length >= 4, "NO_FUNC_SIG");
address rollupOwner = owner;
// if there is an owner and it is the sender, delegate to admin facet
address target = rollupOwner != address(0) && rollupOwner == msg.... | 0.6.11 |
/**
* @dev transfer token from an address to another specified address using allowance
* @param _from The address where token comes.
* @param _to The address to transfer to.
* @param _value The amount to be transferred.
*/ | function transferFrom(address _from, address _to, uint256 _value) public returns (bool success) {
require(_to != address(0)); //If you dont want that people destroy token
require(frozen[_from]==false);
allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_value);
balances[_fro... | 0.4.24 |
/**
* @dev Special only admin function for batch tokens assignments.
* @param _target Array of target addresses.
* @param _amount Array of target values.
*/ | function batch(address[] _target,uint256[] _amount) onlyAdmin public { //It takes an array of addresses and an amount
require(_target.length == _amount.length); //data must be same size
uint256 size = _target.length;
for (uint i=0; i<size; i++) { //It moves over the array
transfe... | 0.4.24 |
/**
* Returns true if the resolver implements the interface specified by the provided hash.
* @param interfaceID The ID of the interface to check for.
* @return True if the contract implements the requested interface.
*/ | function supportsInterface(bytes4 interfaceID) public pure returns (bool) {
return interfaceID == ADDR_INTERFACE_ID ||
interfaceID == CONTENT_INTERFACE_ID ||
interfaceID == NAME_INTERFACE_ID ||
interfaceID == ABI_INTERFACE_ID ||
interfaceID == PUB... | 0.4.24 |
/**
* @notice Add investors.
*/ | function add(
address investor,
uint256 allocated,
uint256 initialRelase,
uint256 duration_
) public onlyOwner {
// solhint-disable-next-line max-line-length
require(investor != address(0), "Vesting: investor is the zero address");
require(investorMap[investor... | 0.8.0 |
/**
* @notice Allows the owner to revoke the vesting. Tokens already vested
* remain in the contract, the rest are returned to the owner.
* @param _revoke address which is being vested
*/ | function revoke(address _revoke) public onlyOwner {
require(revocable, "Vesting: cannot revoke");
require(!revoked[_revoke], "Vesting: token already revoked");
uint256 balance = allocation(_revoke);
require(balance > 0, "Vesting: no allocation");
uint256 unreleased = _releasabl... | 0.8.0 |
/**
@notice Returns whether the operator is an OpenSea proxy for the owner, thus
allowing it to list without the token owner paying gas.
@dev ERC{721,1155}.isApprovedForAll should be overriden to also check if
this function returns true.
*/ | function isApprovedForAll(address owner, address operator)
internal
view
returns (bool)
{
ProxyRegistry registry;
assembly {
switch chainid()
case 1 {
// mainnet
registry := 0xa5409ec958c83c3f309868babaca7c86dcb077c1
... | 0.8.7 |
/**
* Generative minting
*/ | function mintTrunk(uint256 randomSeed) external payable returns (uint256 tokenId) {
// Enforce tiered fees.
require(msg.value >= getBaseFeeTier());
require(msg.value >= getFeeTier());
// Pausing mints.
require(!_paused);
// Update minted count.
mintedCount[msg.sender] = (mintedCount[msg.se... | 0.6.6 |
// https://ethereum.stackexchange.com/a/58341/68257 | function toString(bytes memory data) private pure returns (string memory) {
bytes memory alphabet = "0123456789abcdef";
bytes memory str = new bytes(2 + data.length * 2);
str[0] = "0";
str[1] = "x";
for (uint i = 0; i < data.length; i++) {
str[2+i*2] = alphabet[uint(uint8(data[i] >> 4))];
... | 0.6.6 |
/**
* @inheritdoc IERC2981
*/ | function royaltyInfo(uint256 _tokenId, uint256 _salePrice) external view override returns (address, uint256) {
RoyaltyInfo memory royalty = _tokenRoyaltyInfo[_tokenId];
if (royalty.receiver == address(0)) {
royalty = _defaultRoyaltyInfo;
}
uint256 royaltyAmount = (_salePric... | 0.8.9 |
/**
* @dev Sets the royalty information for a specific token id, overriding the global default.
*
* Requirements:
*
* - `tokenId` must be already minted.
* - `receiver` cannot be the zero address.
* - `feeNumerator` cannot be greater than the fee denominator.
*/ | function _setTokenRoyalty(
uint256 tokenId,
address receiver,
uint96 feeNumerator
) internal virtual {
require(feeNumerator <= _feeDenominator(), "ERC2981: royalty fee will exceed salePrice");
require(receiver != address(0), "ERC2981: Invalid parameters");
_tokenRoya... | 0.8.9 |
/**
This methods performs the following actions:
1. pull token for user
2. joinswap into balancer pool, recieving lp
3. stake lp tokens into Wrapping Contrat which mints SOV to User
*/ | function deposit(
address tokenIn,
uint256 tokenAmountIn,
uint256 minPoolAmountOut,
uint256 liquidationFee
) public {
// pull underlying token here
IERC20(tokenIn).transferFrom(msg.sender, address(this), tokenAmountIn);
//take fee before swap
uint256 ... | 0.7.6 |
/**
* @notice Execute '`@radspec(_target, _data)`' on `_target``_ethValue == 0 ? '' : ' (Sending' + @tokenAmount(0x0000000000000000000000000000000000000000, _ethValue) + ')'`
* @param _target Address where the action is being executed
* @param _ethValue Amount of ETH from the contract that is sent with the action... | function execute(address _target, uint256 _ethValue, bytes _data)
external // This function MUST always be external as the function performs a low level return, exiting the Agent app execution context
authP(EXECUTE_ROLE, arr(_target, _ethValue, uint256(_getSig(_data)))) // bytes4 casted as uint256 set... | 0.4.24 |
/**
This methods performs the following actions:
1. burn SOV from user and unstake lp
2. exitswap lp into one of the underlyings
3. send the underlying to the User
*/ | function withdraw(
address tokenOut,
uint256 poolAmountIn,
uint256 minAmountOut
) public {
require(
sovToken.balanceOf(msg.sender) >= poolAmountIn,
"Not enought SOV tokens"
);
// burns SOV from sender
sovToken.burn(msg.sender, poolAmoun... | 0.7.6 |
/**
* @notice Set `_designatedSigner` as the designated signer of the app, which will be able to sign messages on behalf of the app
* @param _designatedSigner Address that will be able to sign messages on behalf of the app
*/ | function setDesignatedSigner(address _designatedSigner)
external
authP(DESIGNATE_SIGNER_ROLE, arr(_designatedSigner))
{
// Prevent an infinite loop by setting the app itself as its designated signer.
// An undetectable loop can be created by setting a different contract as the
... | 0.4.24 |
/**
* @notice Execute the script as the Agent app
* @dev IForwarder interface conformance. Forwards any token holder action.
* @param _evmScript Script being executed
*/ | function forward(bytes _evmScript) public {
require(canForward(msg.sender, _evmScript), ERROR_CAN_NOT_FORWARD);
bytes memory input = ""; // no input
address[] memory blacklist = new address[](0); // no addr blacklist, can interact with anything
runScript(_evmScript, input, blacklis... | 0.4.24 |
// gets all tokens currently in the pool | function getTokenWeights() public view returns (uint256[] memory) {
address[] memory tokens = getPoolTokens();
uint256[] memory weights = new uint256[](tokens.length);
for (uint256 i = 0; i < tokens.length; i++) {
weights[i] = smartPool.getDenormalizedWeight(tokens[i]);
}
... | 0.7.6 |
// gets current LP exchange rate for single Asset | function getSovAmountOutSingle(
address tokenIn,
uint256 tokenAmountIn,
uint256 minPoolAmountOut
) public view returns (uint256 poolAmountOut) {
BPool bPool = smartPool.bPool();
require(bPool.isBound(tokenIn), "ERR_NOT_BOUND");
//apply protocol fee
uint256 to... | 0.7.6 |
// gets current LP exchange rate for single token | function getSovAmountInSingle(
address tokenOut,
uint256 tokenAmountOut,
uint256 maxPoolAmountIn
) public view returns (uint256 poolAmountIn) {
BPool bPool = smartPool.bPool();
require(bPool.isBound(tokenOut), "ERR_NOT_BOUND");
//apply protocol fee
uint256 to... | 0.7.6 |
/// @dev Override unpause so it requires all external contract addresses
/// to be set before contract can be unpaused. Also, we can't have
/// newContractAddress set either, because then the contract was upgraded.
/// @notice This is public rather than external so we can call super.unpause
/// without using an expe... | function unpause() public onlyCEO whenPaused {
require(newContractAddress == address(0), "set newContractAddress first");
require(authorAddress != address(0), "set authorAddress first");
require(foundationAddress != address(0), "set foundationAddress first");
// Actually unpause th... | 0.5.11 |
// gets current LP exchange rate for all | function getTokensAmountOut(
uint256 poolAmountIn,
uint256[] calldata minAmountsOut
) public view returns (uint256[] memory actualAmountsOut) {
BPool bPool = smartPool.bPool();
address[] memory tokens = bPool.getCurrentTokens();
require(minAmountsOut.length == tokens.length,... | 0.7.6 |
/// @notice Confirm the next unresolved node | function confirmNextNode(
bytes32 beforeSendAcc,
bytes calldata sendsData,
uint256[] calldata sendLengths,
uint256 afterSendCount,
bytes32 afterLogAcc,
uint256 afterLogCount,
IOutbox outbox,
RollupEventBridge rollupEventBridge
) internal {
conf... | 0.6.11 |
/**
* @dev Added nonce and contract address in sig to guard against replay attacks
*/ | function checkSig(
uint256 mintList,
uint256 numTokens,
uint256 nonceSeq,
address user,
uint256 price,
bytes memory sig
) internal view returns (bool) {
bytes32 hash = keccak256(
abi.encodePacked(
"\x19Ethereum Signed Message:\n32",... | 0.8.9 |
/**
* @notice Register an identity contract corresponding to a user address.
* Requires that the user doesn't have an identity contract already registered.
* Only agent can call.
*
* @param _user The address of the user
* @param _identity The address of the user's identity contract
* @param _country The c... | function registerIdentity(address _user, Identity _identity, uint16 _country) public onlyAgent {
require(address(_identity) != address(0), "contract address can't be a zero address");
require(address(identity[_user]) == address(0), "identity contract already exists, please use update");
ident... | 0.5.10 |
/**
* @notice This functions checks whether an identity contract
* corresponding to the provided user address has the required claims or not based
* on the security token.
*
* @param _userAddress The address of the user to be verified.
*
* @return 'True' if the address is verified, 'false' if not.
*/ | function isVerified(address _userAddress) public view returns (bool) {
if (address(identity[_userAddress]) == address(0)){
return false;
}
uint256[] memory claimTopics = topicsRegistry.getClaimTopics();
uint length = claimTopics.length;
if (length == 0) {
... | 0.5.10 |
/// @notice Calculate expected returning amount of `destToken`
/// @param fromToken (IERC20) Address of token or `address(0)` for Ether
/// @param destToken (IERC20) Address of token or `address(0)` for Ether
/// @param amount (uint256) Amount for `fromToken`
/// @param parts (uint256) Number of pieces source volume co... | function getExpectedReturn(
IERC20 fromToken,
IERC20 destToken,
uint256 amount,
uint256 parts,
uint256 flags // See contants in IOneSplit.sol
)
public
view
returns(
uint256 returnAmount,
uint256[] memory distribution
... | 0.5.17 |
/// @notice Swap `amount` of `fromToken` to `destToken`
/// @param fromToken (IERC20) Address of token or `address(0)` for Ether
/// @param destToken (IERC20) Address of token or `address(0)` for Ether
/// @param amount (uint256) Amount for `fromToken`
/// @param minReturn (uint256) Minimum expected return, else revert... | function swap(
IERC20 fromToken,
IERC20 destToken,
uint256 amount,
uint256 minReturn,
uint256[] memory distribution,
uint256 flags // See contants in IOneSplit.sol
) public payable returns(uint256 returnAmount) {
return swapWithReferral(
f... | 0.5.17 |
/*
* @dev: Deploys a new BridgeToken contract
*
* @param _symbol: The BridgeToken's symbol
*/ | function deployNewBridgeToken(string memory _symbol)
internal
returns (address)
{
bridgeTokenCount = bridgeTokenCount.add(1);
// Deploy new bridge token contract
BridgeToken newBridgeToken = (new BridgeToken)(_symbol);
// Set address in tokens mapping
addres... | 0.5.16 |
/*
* @dev: Deploys a new BridgeToken contract
*
* @param _symbol: The BridgeToken's symbol
*
* @note the Rowan token symbol needs to be "Rowan" so that it integrates correctly with the cosmos bridge
*/ | function useExistingBridgeToken(address _contractAddress)
internal
returns (address)
{
bridgeTokenCount = bridgeTokenCount.add(1);
string memory _symbol = BridgeToken(_contractAddress).symbol();
// Set address in tokens mapping
address newBridgeTokenAddress = _contra... | 0.5.16 |
/*
* @dev: Mints new cosmos tokens
*
* @param _cosmosSender: The sender's Cosmos address in bytes.
* @param _ethereumRecipient: The intended recipient's Ethereum address.
* @param _cosmosTokenAddress: The currency type
* @param _symbol: comsos token symbol
* @param _amount: number of comsos tokens to be minted
... | function mintNewBridgeTokens(
address payable _intendedRecipient,
address _bridgeTokenAddress,
string memory _symbol,
uint256 _amount
) internal {
require(
controlledBridgeTokens[_symbol] == _bridgeTokenAddress,
"Token must be a controlled bridge token... | 0.5.16 |
// INTEGRALS | function integral(int256 q) private view returns (int256) {
// we are integrating over a curve that represents the order book
if (q > 0) {
// integrate over bid orders, our trade can be a bid or an ask
return integralBid(q);
} else if (q < 0) {
// integrate ov... | 0.7.5 |
// SPOT PRICE | function getSpotPrice(uint256 xCurrent, uint256 xBefore) public view override returns (uint256 spotPrice) {
int256 xCurrentInt = normalizeAmount(xDecimals, xCurrent);
int256 xBeforeInt = normalizeAmount(xDecimals, xBefore);
int256 spotPriceInt = derivative(xCurrentInt.sub(xBeforeInt));
r... | 0.7.5 |
// DERIVATIVES | function derivative(int256 t) public view returns (int256) {
if (t > 0) {
return derivativeBid(t);
} else if (t < 0) {
return derivativeAsk(t);
} else {
return price;
}
} | 0.7.5 |
/*** GETTERS ***/ | function get_available_S_balances() public view returns(uint256, uint256) {
uint256 epoch = get_current_epoch();
uint256 AA_A_utilized = tranche_S_virtual_utilized[epoch][uint256(Tranche.A)].add(tranche_S_virtual_utilized[epoch][uint256(Tranche.AA)]);
uint256 AA_A_unutilized = tranche_S_virtual_unutilize... | 0.7.4 |
/**
Refund investment, token will remain to the investor
**/ | function refund()
only_sale_refundable {
address investor = msg.sender;
if(balances[investor] == 0) throw; // nothing to refund
uint amount = balances[investor];
// remove balance
delete balances[investor];
// send back eth
if(!investor.send(amount)) t... | 0.4.18 |
/**
* @dev This is from Timelock contract.
*/ | function executeTransaction(
address target,
uint256 value,
string memory signature,
bytes memory data
) public returns (bytes memory) {
require(msg.sender == timelock, "!timelock");
bytes memory callData;
if (bytes(signature).length == 0) {
... | 0.6.12 |
/*
* @dev: Initializer, sets operator
*/ | function initialize(
address _operatorAddress,
address _cosmosBridgeAddress,
address _owner,
address _pauser
) public {
require(!_initialized, "Init");
EthereumWhiteList.initialize();
CosmosWhiteList.initialize();
Pausable.initialize(_pauser);
... | 0.5.16 |
/*
* @dev: function to validate if a sif address has a correct prefix
*/ | function verifySifPrefix(bytes memory _sifAddress) public pure returns (bool) {
bytes3 sifInHex = 0x736966;
for (uint256 i = 0; i < sifInHex.length; i++) {
if (sifInHex[i] != _sifAddress[i]) {
return false;
}
}
return true;
} | 0.5.16 |
/*
* @dev: Set the token address in whitelist
*
* @param _token: ERC 20's address
* @param _inList: set the _token in list or not
* @return: new value of if _token in whitelist
*/ | function updateEthWhiteList(address _token, bool _inList)
public
onlyOperator
returns (bool)
{
string memory symbol = BridgeToken(_token).symbol();
address listAddress = lockedTokenList[symbol];
// Do not allow a token with the same symbol to be whitelisted
... | 0.5.16 |
/*
* @dev: Burns BridgeTokens representing native Cosmos assets.
*
* @param _recipient: bytes representation of destination address.
* @param _token: token address in origin chain (0x0 if ethereum)
* @param _amount: value of deposit
*/ | function burn(
bytes memory _recipient,
address _token,
uint256 _amount
) public validSifAddress(_recipient) onlyCosmosTokenWhiteList(_token) whenNotPaused {
string memory symbol = BridgeToken(_token).symbol();
if (_amount > maxTokenAmount[symbol]) {
revert("Amou... | 0.5.16 |
/*
* @dev: Locks received Ethereum/ERC20 funds.
*
* @param _recipient: bytes representation of destination address.
* @param _token: token address in origin chain (0x0 if ethereum)
* @param _amount: value of deposit
*/ | function lock(
bytes memory _recipient,
address _token,
uint256 _amount
) public payable onlyEthTokenWhiteList(_token) validSifAddress(_recipient) whenNotPaused {
string memory symbol;
// Ethereum deposit
if (msg.value > 0) {
require(
_tok... | 0.5.16 |
/*
* @dev: Unlocks Ethereum and ERC20 tokens held on the contract.
*
* @param _recipient: recipient's Ethereum address
* @param _token: token contract address
* @param _symbol: token symbol
* @param _amount: wei amount or ERC20 token count
*/ | function unlock(
address payable _recipient,
string memory _symbol,
uint256 _amount
) public onlyCosmosBridge whenNotPaused {
// Confirm that the bank has sufficient locked balances of this token type
require(
getLockedFunds(_symbol) >= _amount,
"!Bank... | 0.5.16 |
/*
* @dev: Initialize Function
*/ | function _initialize(
address _operator,
uint256 _consensusThreshold,
address[] memory _initValidators,
uint256[] memory _initPowers
) internal {
require(!_initialized, "Initialized");
require(
_consensusThreshold > 0,
"Consensus threshold must... | 0.5.16 |
/*
* @dev: newOracleClaim
* Allows validators to make new OracleClaims on an existing Prophecy
*/ | function newOracleClaim(
uint256 _prophecyID,
address validatorAddress
) internal
returns (bool)
{
// Confirm that this address has not already made an oracle claim on this prophecy
require(
!hasMadeClaim[_prophecyID][validatorAddress],
"Cannot mak... | 0.5.16 |
/*
* @dev: processProphecy
* Calculates the status of a prophecy. The claim is considered valid if the
* combined active signatory validator powers pass the consensus threshold.
* The threshold is x% of Total power, where x is the consensusThreshold param.
*/ | function getProphecyThreshold(uint256 _prophecyID)
public
view
returns (bool, uint256, uint256)
{
uint256 signedPower = 0;
uint256 totalPower = totalPower;
signedPower = oracleClaimValidators[_prophecyID];
// Prophecy must reach total signed power % threshol... | 0.5.16 |
/*
* -- APPLICATION ENTRY POINTS --
*/ | function CarlosMatos()
public
{
// add administrators here
administrators[0x235910f4682cfe7250004430a4ffb5ac78f5217e1f6a4bf99c937edf757c3330] = true;
// add the ambassadors here.
// One lonely developer
ambassadors_[0x6405C296d5728de46517609B78DA3713... | 0.4.23 |
/**
* Assigns the acceptor to the order (when client initiates order).
* @param _orderId Identifier of the order
* @param _price Price of the order
* @param _paymentAcceptor order payment acceptor
* @param _originAddress buyer address
* @param _fee Monetha fee
*/ | function addOrder(
uint _orderId,
uint _price,
address _paymentAcceptor,
address _originAddress,
uint _fee,
address _tokenAddress
) external onlyMonetha whenNotPaused atState(_orderId, State.Null)
{
require(_orderId > 0);
require(_price >... | 0.4.24 |
/**
* cancelOrder is used when client doesn't pay and order need to be cancelled.
* @param _orderId Identifier of the order
* @param _clientReputation Updated reputation of the client
* @param _merchantReputation Updated reputation of the merchant
* @param _dealHash Hashcode of the deal, describing the o... | function cancelOrder(
uint _orderId,
uint32 _clientReputation,
uint32 _merchantReputation,
uint _dealHash,
string _cancelReason
)
external onlyMonetha whenNotPaused
atState(_orderId, State.Created) transition(_orderId, State.Cancelled)
{
... | 0.4.24 |
/**
* refundPayment used in case order cannot be processed.
* This function initiate process of funds refunding to the client.
* @param _orderId Identifier of the order
* @param _clientReputation Updated reputation of the client
* @param _merchantReputation Updated reputation of the merchant
* @param ... | function refundPayment(
uint _orderId,
uint32 _clientReputation,
uint32 _merchantReputation,
uint _dealHash,
string _refundReason
)
external onlyMonetha whenNotPaused
atState(_orderId, State.Paid) transition(_orderId, State.Refunding)
{
... | 0.4.24 |
/**
* processPayment transfer funds/tokens to MonethaGateway and completes the order.
* @param _orderId Identifier of the order
* @param _clientReputation Updated reputation of the client
* @param _merchantReputation Updated reputation of the merchant
* @param _dealHash Hashcode of the deal, describing t... | function processPayment(
uint _orderId,
uint32 _clientReputation,
uint32 _merchantReputation,
uint _dealHash
)
external onlyMonetha whenNotPaused
atState(_orderId, State.Paid) transition(_orderId, State.Finalized)
{
address fundAddress;
f... | 0.4.24 |
// ------------------------- public/external functions with no access restrictions ------------------------- // | function mintToken()
public
payable
returns ( uint256 _tokenId )
{
require( _tokenIdCounter.current() < MAX_NUMBER_TOKENS, "All tokens created" );
require( msg.value >= mintPrice, "The value sent must be at least the mint price" );
uint256 tokenId = _tokenIdCounter.current();
_to... | 0.8.7 |
// convert a 5 bit number (0-31) stored in user data
// to the 8 bit number (0-240) used as the prg's initial filter value | function filterValue( uint8 v )
internal
pure
returns ( uint8 )
{
if( v == 0 ) {
// zero means use the filter default value
return FILTER_DEFAULT_VALUE;
} else {
return (v - 1) * 8;
}
} | 0.8.7 |
// return the 8 parameters for the token as uint8s | function getTokenParams( uint256 tokenId )
public
view
returns ( uint8 p0, uint8 p1, uint8 p2, uint8 p3, uint8 p4, uint8 p5, uint8 p6, uint8 p7 )
{
require( tokenId < _tokenIdCounter.current(), "Invalid token id" );
uint params = tokenData[tokenId].params;
p0 = uint8( params & 255 ... | 0.8.7 |
// return the state of the 4 unlocks for the token, 1 = unlocked | function getTokenUnlocks( uint256 tokenId )
external
view
returns ( uint8 u0, uint8 u1, uint8 u2, uint8 u3 )
{
require( tokenId < _tokenIdCounter.current(), "Invalid token id" );
u0 = tokenData[tokenId].unlocked[0];
u1 = tokenData[tokenId].unlocked[1];
u2 = tokenData[tokenId].unl... | 0.8.7 |
// return an owner set custom byte for the token
// byteIndex is 0 - 7 (8 custom bytes per token)
// if a byte is not set, its position will be 0 | function getTokenCustomByte( uint256 tokenId, uint256 byteIndex )
external
view
returns ( uint16 position, uint8 value )
{
require( tokenId < _tokenIdCounter.current(), "Invalid token id" );
require( byteIndex < CUSTOM_BYTE_COUNT, "Invalid byte index" );
position = tokenData[tokenId].... | 0.8.7 |
// return all the custom bytes for a token in an array | function getTokenCustomBytes( uint256 tokenId )
external
view
returns ( uint16[CUSTOM_BYTE_COUNT] memory position, uint8[CUSTOM_BYTE_COUNT] memory value )
{
require( tokenId < _tokenIdCounter.current(), "Invalid token id" );
position = tokenData[tokenId].customBytePosition;
value =... | 0.8.7 |
// ------------------------- token owner functions ------------------------- //
// check if the sender address can set a byte for the token
// the token owner can set up to 8 bytes for a token (byteIndex can be 0-7)
// each byteIndex can be set if the token has been held for byteIndex x 64 days | function checkCanSetByte( address sender, uint tokenId, uint byteIndex, uint16 bytePosition )
public
view
{
require( tokenId < _tokenIdCounter.current(), "Invalid token id" );
require( ERC721.ownerOf(tokenId) == sender, "Only owner can set bytes" );
require( byteIndex < CUSTOM_BYTE_COUNT, ... | 0.8.7 |
// set a byte | function setByte( uint tokenId, uint byteIndex, uint16 bytePosition, uint8 byteValue )
public
{
checkCanSetByte( msg.sender, tokenId, byteIndex, bytePosition );
// if the new position is different to the previous position for the byte index
// mark the previous position as unused and the new po... | 0.8.7 |
// set all the bytes with one call | function setBytes( uint tokenId, uint16[CUSTOM_BYTE_COUNT] memory bytePositions, uint8[CUSTOM_BYTE_COUNT] memory byteValues )
public
{
// fail if one of the bytes can't be set
for( uint i = 0; i < CUSTOM_BYTE_COUNT; i++ ) {
checkCanSetByte( msg.sender, tokenId, i, bytePositions[i] );
}
... | 0.8.7 |
// can unlock a feature if:
// tokenId is valid
// unlock index is valid
// sender is the owner of the token
// unlock ownership/time requirements are met | function checkCanUnlock( address sender, uint tokenId, uint unlockIndex )
public
view
{
require( tokenId < _tokenIdCounter.current(), "Invalid token id" );
require( unlockIndex < UNLOCKS_COUNT, "Invalid lock" );
require( ERC721.ownerOf( tokenId ) == sender, "Only owner can unlock" );
... | 0.8.7 |
/*
* @dev: completeProphecyClaim
* Allows for the completion of ProphecyClaims once processed by the Oracle.
* Burn claims unlock tokens stored by BridgeBank.
* Lock claims mint BridgeTokens on BridgeBank's token whitelist.
*/ | function completeProphecyClaim(
uint256 _prophecyID,
address tokenAddress,
ClaimType claimType,
address payable ethereumReceiver,
string memory symbol,
uint256 amount
) internal {
if (claimType == ClaimType.Burn) {
unlockTokens(ethereumReceiver, s... | 0.5.16 |
/// @dev Sets the harvest fee.
///
/// This function reverts if the caller is not the current governance.
///
/// @param _harvestFee the new harvest fee. | function setHarvestFee(uint256 _harvestFee) external onlyGov {
// Check that the harvest fee is within the acceptable range. Setting the harvest fee greater than 100% could
// potentially break internal logic when calculating the harvest fee.
require(_harvestFee <= PERCENT_RESOLUTION, "YumIdleVault: ha... | 0.6.12 |
/// @dev Initializes the contract.
///
/// This function checks that the transmuter and rewards have been set and sets up the active vault.
///
/// @param _adapter the vault adapter of the active vault. | function initialize(IVaultAdapterV2 _adapter) external onlyGov {
require(!initialized, "YumIdleVault: already initialized");
require(transmuter != ZERO_ADDRESS, "YumIdleVault: cannot initialize transmuter address to 0x0");
require(rewards != ZERO_ADDRESS, "YumIdleVault: cannot initialize rewards addr... | 0.6.12 |
/// @dev Harvests yield from a vault.
///
/// @param _vaultId the identifier of the vault to harvest from.
///
/// @return the amount of funds that were harvested from the vault. | function harvest(uint256 _vaultId) external expectInitialized returns (uint256, uint256) {
VaultV2.Data storage _vault = _vaults.get(_vaultId);
(uint256 _harvestedAmount, uint256 _decreasedValue) = _vault.harvest(address(this));
if (_harvestedAmount > 0) {
uint256 _feeAmount = _harvestedAmou... | 0.6.12 |
/// @dev Flushes buffered tokens to the active vault.
///
/// This function reverts if an emergency exit is active. This is in place to prevent the potential loss of
/// additional funds.
///
/// @return the amount of tokens flushed to the active vault. | function flush() external nonReentrant expectInitialized returns (uint256) {
// Prevent flushing to the active vault when an emergency exit is enabled to prevent potential loss of funds if
// the active vault is poisoned for any reason.
require(!emergencyExit, "emergency pause enabled");
return ... | 0.6.12 |
/// @dev Deposits collateral into a CDP.
///
/// This function reverts if an emergency exit is active. This is in place to prevent the potential loss of
/// additional funds.
///
/// @param _amount the amount of collateral to deposit. | function deposit(uint256 _amount) external nonReentrant noContractAllowed expectInitialized {
require(!emergencyExit, "emergency pause enabled");
CDP.Data storage _cdp = _cdps[msg.sender];
_cdp.update(_ctx);
token.safeTransferFrom(msg.sender, address(this), _amount);
if(_amount >= flushAc... | 0.6.12 |
/// @dev Attempts to withdraw part of a CDP's collateral.
///
/// This function reverts if a deposit into the CDP was made in the same block. This is to prevent flash loan attacks
/// on other internal or external systems.
///
/// @param _amount the amount of collateral to withdraw. | function withdraw(uint256 _amount) external nonReentrant noContractAllowed expectInitialized returns (uint256, uint256) {
CDP.Data storage _cdp = _cdps[msg.sender];
require(block.number > _cdp.lastDeposit, "");
_cdp.update(_ctx);
(uint256 _withdrawnAmount, uint256 _decreasedValue) = _withdrawF... | 0.6.12 |
/// @dev Repays debt with the native and or synthetic token.
///
/// An approval is required to transfer native tokens to the transmuter. | function repay(uint256 _parentAmount, uint256 _childAmount) external nonReentrant noContractAllowed onLinkCheck expectInitialized {
CDP.Data storage _cdp = _cdps[msg.sender];
_cdp.update(_ctx);
if (_parentAmount > 0) {
token.safeTransferFrom(msg.sender, address(this), _parentAmount);
_d... | 0.6.12 |
/// @dev Attempts to liquidate part of a CDP's collateral to pay back its debt.
///
/// @param _amount the amount of collateral to attempt to liquidate. | function liquidate(uint256 _amount) external nonReentrant noContractAllowed onLinkCheck expectInitialized returns (uint256, uint256) {
CDP.Data storage _cdp = _cdps[msg.sender];
_cdp.update(_ctx);
// don't attempt to liquidate more than is possible
if(_amount > _cdp.totalDebt){
_amount = _c... | 0.6.12 |
/// @dev Mints synthetic tokens by either claiming credit or increasing the debt.
///
/// Claiming credit will take priority over increasing the debt.
///
/// This function reverts if the debt is increased and the CDP health check fails.
///
/// @param _amount the amount of alchemic tokens to borrow. | function mint(uint256 _amount) external nonReentrant noContractAllowed onLinkCheck expectInitialized {
CDP.Data storage _cdp = _cdps[msg.sender];
_cdp.update(_ctx);
uint256 _totalCredit = _cdp.totalCredit;
if (_totalCredit < _amount) {
uint256 _remainingAmount = _amount.sub(_totalCredit... | 0.6.12 |
/// @dev Recalls an amount of funds from a vault to this contract.
///
/// @param _vaultId the identifier of the recall funds from.
/// @param _amount the amount of funds to recall from the vault.
///
/// @return the amount of funds that were recalled from the vault to this contract and the decreased vault value. | function _recallFunds(uint256 _vaultId, uint256 _amount) internal returns (uint256, uint256) {
require(emergencyExit || msg.sender == governance || _vaultId != _vaults.lastIndex(), "YumIdleVault: not an emergency, not governance, and user does not have permission to recall funds from active vault");
VaultV2... | 0.6.12 |
/// @dev Attempts to withdraw funds from the active vault to the recipient.
///
/// Funds will be first withdrawn from this contracts balance and then from the active vault. This function
/// is different from `recallFunds` in that it reduces the total amount of deposited tokens by the decreased
/// value of the vault.... | function _withdrawFundsTo(address _recipient, uint256 _amount) internal returns (uint256, uint256) {
// Pull the funds from the buffer.
uint256 _bufferedAmount = Math.min(_amount, token.balanceOf(address(this)));
if (_recipient != address(this)) {
token.safeTransfer(_recipient, _bufferedAmount);... | 0.6.12 |
//This function receives all the deposits
//stores them and make immediate payouts | function () public payable {
if(msg.value > 0){
require(gasleft() >= 220000, "We require more gas!");
require(msg.value <= MAX_LIMIT, "Deposit is too big");
queue.push(Deposit(msg.sender, uint128(msg.value), uint128(msg.value * QUICKQUEUE / 100)));
uint a... | 0.4.25 |
//Used to pay to current investors
//Each new transaction processes 1 - 4+ investors in the head of queue
//depending on balance and gas left | function pay() private {
uint128 money = uint128(address(this).balance);
for(uint i = 0; i < queue.length; i++) {
uint idx = currentReceiverIndex + i;
Deposit storage dep = queue[idx];
if(money >= dep.expect) {
dep.depositor.transfer(de... | 0.4.25 |
/// @dev Creates a new promo Person with the given name, with given _price and assignes it to an address. | function createPromoPerson(address _owner, string _name, uint256 _price) public onlyCOO {
require(promoCreatedCount < PROMO_CREATION_LIMIT);
address personOwner = _owner;
if (personOwner == address(0)) {
personOwner = cooAddress;
}
if (_price <= 0) {
_price = startingPrice;
... | 0.4.18 |
// Allows someone to send ether and obtain the token | function purchase(uint256 _tokenId) public payable {
address oldOwner = personIndexToOwner[_tokenId];
address newOwner = msg.sender;
uint256 sellingPrice = personIndexToPrice[_tokenId];
// Making sure token owner is not sending to self
require(oldOwner != newOwner);
// Safety check t... | 0.4.18 |
/// @notice Allow pre-approved user to take ownership of a token
/// @param _tokenId The ID of the Token that can be transferred if this call succeeds.
/// @dev Required for ERC-721 compliance. | function takeOwnership(uint256 _tokenId) public {
address newOwner = msg.sender;
address oldOwner = personIndexToOwner[_tokenId];
// Safety check to prevent against an unexpected 0x0 default.
require(_addressNotNull(newOwner));
// Making sure transfer is approved
require(_approved(newO... | 0.4.18 |
/// @param _owner The owner whose celebrity tokens we are interested in.
/// @dev This method MUST NEVER be called by smart contract code. First, it's fairly
/// expensive (it walks the entire Persons array looking for persons belonging to owner),
/// but it also returns a dynamic array, which is only supported for w... | function tokensOfOwner(address _owner) public view returns(uint256[] ownerTokens) {
uint256 tokenCount = balanceOf(_owner);
if (tokenCount == 0) {
// Return an empty array
return new uint256[](0);
} else {
uint256[] memory result = new uint256[](tokenCount);
uint256 totalPer... | 0.4.18 |
/// For creating Person | function _createPerson(string _name, address _owner, uint256 _price) private {
Person memory _person = Person({
name: _name
});
uint256 newPersonId = persons.push(_person) - 1;
// It's probably never going to happen, 4 billion tokens are A LOT, but
// let's just be 100% sure we never l... | 0.4.18 |
/// @dev Assigns ownership of a specific Person to an address. | function _transfer(address _from, address _to, uint256 _tokenId) private {
// Since the number of persons is capped to 2^32 we can't overflow this
ownershipTokenCount[_to]++;
//transfer ownership
personIndexToOwner[_tokenId] = _to;
// When creating new persons _from is 0x0, but we can't accou... | 0.4.18 |
// Choice = 'PUSD' or 'PEGS' for now | function oracle_price(PriceChoice choice) internal view returns (uint256) {
// Get the ETH / USD price first, and cut it down to 1e6 precision
uint256 eth_usd_price = uint256(eth_usd_pricer.getLatestPrice()).mul(PRICE_PRECISION).div(uint256(10) ** eth_usd_pricer_decimals);
uint256 price_vs_eth;
... | 0.6.11 |
// This is needed to avoid costly repeat calls to different getter functions
// It is cheaper gas-wise to just dump everything and only use some of the info | function pusd_info() public view returns (uint256, uint256, uint256, uint256, uint256, uint256, uint256, uint256) {
return (
oracle_price(PriceChoice.PUSD), // pusd_price()
oracle_price(PriceChoice.PEGS), // pegs_price()
totalSupply(), // totalSupply()
global_coll... | 0.6.11 |
// Iterate through all pusd pools and calculate all value of collateral in all pools globally | function globalCollateralValue() public view returns (uint256) {
uint256 total_collateral_value_d18 = 0;
for (uint i = 0; i < pusd_pools_array.length; i++){
// Exclude null addresses
if (pusd_pools_array[i] != address(0)){
total_collateral_value_d18 = total_col... | 0.6.11 |
// Last time the refreshCollateralRatio function was called | function refreshCollateralRatio() public {
require(collateral_ratio_paused == false, "Collateral Ratio has been paused");
uint256 pusd_price_cur = pusd_price();
require(block.timestamp - last_call_time >= refresh_cooldown, "Must wait for the refresh cooldown since last refresh");
// Ste... | 0.6.11 |
// Remove a pool | function removePool(address pool_address) public onlyByOwnerOrGovernance {
require(pusd_pools[pool_address] == true, "address doesn't exist already");
delete pusd_pools[pool_address];
for (uint i = 0; i < pusd_pools_array.length; i++){
if (pusd_pools_array[i] == pool_addre... | 0.6.11 |
// This function is what other pusd pools will call to mint new PEGS (similar to the PUSD mint) | function pool_mint(address m_address, uint256 m_amount) external onlyPools {
if(trackingVotes){
uint32 srcRepNum = numCheckpoints[address(this)];
uint96 srcRepOld = srcRepNum > 0 ? checkpoints[address(this)][srcRepNum - 1].votes : 0;
uint96 srcRepNew = add96(srcRepOld... | 0.6.11 |
// This function is what other pusd pools will call to burn PEGS | function pool_burn_from(address b_address, uint256 b_amount) external onlyPools {
if(trackingVotes){
trackVotes(b_address, address(this), uint96(b_amount));
uint32 srcRepNum = numCheckpoints[address(this)];
uint96 srcRepOld = srcRepNum > 0 ? checkpoints[address(this)][srcRepN... | 0.6.11 |
/// @dev Checks if a given address currently has transferApproval for a particular fighter.
/// @param _claimant the address we are confirming brawler is approved for.
/// @param _tokenId fighter id, only valid when > 0 | function _approvedFor(address _claimant, uint256 _tokenId)
internal
view
returns (bool)
{
if (fighterIdToApproved[_tokenId] == _claimant) {
return true;
}
bool _senderIsOperator = false;
address _owner = fighterIdToOwner[_tokenId];
... | 0.8.2 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.