Unnamed: 0
int64 0
7.36k
| comments
stringlengths 3
35.2k
| code_string
stringlengths 1
527k
| code
stringlengths 1
527k
| __index_level_0__
int64 0
88.6k
|
|---|---|---|---|---|
147
|
// https:etherscan.io/address/0x853d955aCEf822Db058eb8505911ED77F175b99e
|
address internal constant FRAX_UNDERLYING = 0x853d955aCEf822Db058eb8505911ED77F175b99e;
uint256 internal constant FRAX_DECIMALS = 18;
|
address internal constant FRAX_UNDERLYING = 0x853d955aCEf822Db058eb8505911ED77F175b99e;
uint256 internal constant FRAX_DECIMALS = 18;
| 15,838
|
3
|
// address[] memory _patientAddrList = [0x0000000000000000000000000000000000000000];
|
Hospital memory h;
h.hospitalAddr = msg.sender;
h.hospitalName = _hospitalName;
h.isValue = true;
hospitals[_hospitalName] = h;
|
Hospital memory h;
h.hospitalAddr = msg.sender;
h.hospitalName = _hospitalName;
h.isValue = true;
hospitals[_hospitalName] = h;
| 44,527
|
62
|
// Apply minimum fee
|
uint256 minFee = isSwap ? feeStructure.minSwapFee : feeStructure.minBaseFee;
if (fee < minFee) fee = minFee;
|
uint256 minFee = isSwap ? feeStructure.minSwapFee : feeStructure.minBaseFee;
if (fee < minFee) fee = minFee;
| 41,669
|
110
|
// 2. Effects
|
highestBidOf[_auctionId] = 0;
highestBidderOf[_auctionId] = 0x0000000000000000000000000000000000000000;
auctionEnded[_auctionId] = true;
emit AuctionEnded(highestAuctionBidder, amount, _auctionId, idOfAuctionedAss);
|
highestBidOf[_auctionId] = 0;
highestBidderOf[_auctionId] = 0x0000000000000000000000000000000000000000;
auctionEnded[_auctionId] = true;
emit AuctionEnded(highestAuctionBidder, amount, _auctionId, idOfAuctionedAss);
| 78,208
|
13
|
// small win percentage (prize pool)
|
uint256 public constant SMALL_WIN_PCT = 50; // 0.5%
|
uint256 public constant SMALL_WIN_PCT = 50; // 0.5%
| 10,288
|
7
|
// Product Simpler version of Product interface /
|
contract Product is ExtendsOwnable {
string public name;
uint256 public maxcap;
uint256 public exceed;
uint256 public minimum;
uint256 public rate;
uint256 public lockup;
constructor (
string _name,
uint256 _maxcap,
uint256 _exceed,
uint256 _minimum,
uint256 _rate,
uint256 _lockup
) public {
name = _name;
maxcap = _maxcap;
exceed = _exceed;
minimum = _minimum;
rate = _rate;
lockup = _lockup;
}
function setName(string _name) external onlyOwner {
name = _name;
}
function setMaxcap(uint256 _maxcap) external onlyOwner {
maxcap = _maxcap;
}
function setExceed(uint256 _exceed) external onlyOwner {
exceed = _exceed;
}
function setMinimum(uint256 _minimum) external onlyOwner {
minimum = _minimum;
}
function setRate(uint256 _rate) external onlyOwner {
rate = _rate;
}
function setLockup(uint256 _lockup) external onlyOwner {
lockup = _lockup;
}
}
|
contract Product is ExtendsOwnable {
string public name;
uint256 public maxcap;
uint256 public exceed;
uint256 public minimum;
uint256 public rate;
uint256 public lockup;
constructor (
string _name,
uint256 _maxcap,
uint256 _exceed,
uint256 _minimum,
uint256 _rate,
uint256 _lockup
) public {
name = _name;
maxcap = _maxcap;
exceed = _exceed;
minimum = _minimum;
rate = _rate;
lockup = _lockup;
}
function setName(string _name) external onlyOwner {
name = _name;
}
function setMaxcap(uint256 _maxcap) external onlyOwner {
maxcap = _maxcap;
}
function setExceed(uint256 _exceed) external onlyOwner {
exceed = _exceed;
}
function setMinimum(uint256 _minimum) external onlyOwner {
minimum = _minimum;
}
function setRate(uint256 _rate) external onlyOwner {
rate = _rate;
}
function setLockup(uint256 _lockup) external onlyOwner {
lockup = _lockup;
}
}
| 43,499
|
5
|
// Returns the amount of tokens in existence. /
|
function totalSupply() external view returns (uint256);
|
function totalSupply() external view returns (uint256);
| 36,960
|
20
|
// require(flightsuretydata.getFlightStatusCode(flightCodeDate) == STATUS_CODE_UNKNOWN, 'Flight status already changed');
|
bool result = flightsuretydata.changeFlightStatusCode(flightCodeDate, statusCode);
if (result) {
if (statusCode >= STATUS_CODE_LATE_AIRLINE) {
setInsurancePayout(flightCodeDate);
}
|
bool result = flightsuretydata.changeFlightStatusCode(flightCodeDate, statusCode);
if (result) {
if (statusCode >= STATUS_CODE_LATE_AIRLINE) {
setInsurancePayout(flightCodeDate);
}
| 30,732
|
152
|
// Calculate SFI earnings per tranche
|
tranche_SFI_earned[epoch][uint256(Tranche.S)] = TRANCHE_SFI_MULTIPLIER.S.mul(amount_sfi).div(100000);
tranche_SFI_earned[epoch][uint256(Tranche.AA)] = TRANCHE_SFI_MULTIPLIER.AA.mul(amount_sfi).div(100000);
tranche_SFI_earned[epoch][uint256(Tranche.A)] = TRANCHE_SFI_MULTIPLIER.A.mul(amount_sfi).div(100000);
emit WindDownEpochSFI(wind_down.previous_epoch, tranche_SFI_earned[epoch][uint256(Tranche.S)], tranche_SFI_earned[epoch][uint256(Tranche.AA)], tranche_SFI_earned[epoch][uint256(Tranche.A)]);
|
tranche_SFI_earned[epoch][uint256(Tranche.S)] = TRANCHE_SFI_MULTIPLIER.S.mul(amount_sfi).div(100000);
tranche_SFI_earned[epoch][uint256(Tranche.AA)] = TRANCHE_SFI_MULTIPLIER.AA.mul(amount_sfi).div(100000);
tranche_SFI_earned[epoch][uint256(Tranche.A)] = TRANCHE_SFI_MULTIPLIER.A.mul(amount_sfi).div(100000);
emit WindDownEpochSFI(wind_down.previous_epoch, tranche_SFI_earned[epoch][uint256(Tranche.S)], tranche_SFI_earned[epoch][uint256(Tranche.AA)], tranche_SFI_earned[epoch][uint256(Tranche.A)]);
| 42,756
|
19
|
// Set the product contract address. This is accessible only for the owner and can only be setted once.
|
function setProductContractAddress(address _productContractAddress) public onlyOwner {
// Check weather the product contract address is setted or not.
require( productContractAddress == address(0), "Product contract is setted." );
// Set the address.
productContractAddress = _productContractAddress;
}
|
function setProductContractAddress(address _productContractAddress) public onlyOwner {
// Check weather the product contract address is setted or not.
require( productContractAddress == address(0), "Product contract is setted." );
// Set the address.
productContractAddress = _productContractAddress;
}
| 49,406
|
191
|
// Change the bas URI if required
|
function setBaseURI(string memory _URI) external onlyOwner {
baseURI = _URI;
}
|
function setBaseURI(string memory _URI) external onlyOwner {
baseURI = _URI;
}
| 43,169
|
32
|
// 0x31: Retrieval of at least one of the sources timed out.
|
RetrievalTimeout,
|
RetrievalTimeout,
| 24,482
|
16
|
// remove the replica from mappings
|
_clearReplica(_replica);
|
_clearReplica(_replica);
| 38,301
|
168
|
// metadata
|
string name;
string description;
|
string name;
string description;
| 66,349
|
147
|
// Getters
|
constructor(
address _rewards,
address _want,
address _strategist
)
public
StrategyBase(_want, _strategist)
|
constructor(
address _rewards,
address _want,
address _strategist
)
public
StrategyBase(_want, _strategist)
| 8,907
|
68
|
// how to split up the final pot based on which team was picked (F3D, P3D)
|
potSplit_[0] = F3Ddatasets.PotSplit(0,0); //100% to winner
|
potSplit_[0] = F3Ddatasets.PotSplit(0,0); //100% to winner
| 50,274
|
288
|
// POSITION FUNCTIONS // Requests to transfer ownership of the caller's current position to a new sponsor address.Once the request liveness is passed, the sponsor can execute the transfer and specify the new sponsor. The liveness length is the same as the withdrawal liveness. /
|
function requestTransferPosition() public onlyPreExpiration() nonReentrant() {
PositionData storage positionData = _getPositionData(msg.sender);
require(positionData.transferPositionRequestPassTimestamp == 0, "Pending transfer");
// Make sure the proposed expiration of this request is not post-expiry.
uint256 requestPassTime = getCurrentTime().add(withdrawalLiveness);
require(requestPassTime < expirationTimestamp, "Request expires post-expiry");
// Update the position object for the user.
positionData.transferPositionRequestPassTimestamp = requestPassTime;
emit RequestTransferPosition(msg.sender);
}
|
function requestTransferPosition() public onlyPreExpiration() nonReentrant() {
PositionData storage positionData = _getPositionData(msg.sender);
require(positionData.transferPositionRequestPassTimestamp == 0, "Pending transfer");
// Make sure the proposed expiration of this request is not post-expiry.
uint256 requestPassTime = getCurrentTime().add(withdrawalLiveness);
require(requestPassTime < expirationTimestamp, "Request expires post-expiry");
// Update the position object for the user.
positionData.transferPositionRequestPassTimestamp = requestPassTime;
emit RequestTransferPosition(msg.sender);
}
| 30,773
|
144
|
// burn old tokens
|
OLD_MONETARY_SUPERVISOR.burnFromReserve(reserveTokenAmount);
|
OLD_MONETARY_SUPERVISOR.burnFromReserve(reserveTokenAmount);
| 70,708
|
316
|
// Calculate pay out & pay out
|
if (zethr.balanceOf(address(this)) >= 1e10) {
payOutAmount = zethr.balanceOf(address(this)) / payOutDivisor;
}
|
if (zethr.balanceOf(address(this)) >= 1e10) {
payOutAmount = zethr.balanceOf(address(this)) / payOutDivisor;
}
| 32,499
|
95
|
// Add full rewards UP TO end of LOCK epoch
|
uint endEpochAccumulated = epochs[user.endLockEpoch]
.finalEpochAccumulation;
userStakingPower += user.bonusAmount;
accumulatedRewards = userStakingPower * endEpochAccumulated;
claimableRewards = accumulatedRewards - user.offsetPoints;
endEpochAccumulated = user.depositAmount * endEpochAccumulated;
userStakingPower = user.depositAmount;
|
uint endEpochAccumulated = epochs[user.endLockEpoch]
.finalEpochAccumulation;
userStakingPower += user.bonusAmount;
accumulatedRewards = userStakingPower * endEpochAccumulated;
claimableRewards = accumulatedRewards - user.offsetPoints;
endEpochAccumulated = user.depositAmount * endEpochAccumulated;
userStakingPower = user.depositAmount;
| 32,092
|
108
|
// cards_ is encoded: 64 bit cardId 96 bit price 32 bit loyalty price 64 bit maxSupply
|
uint cardId = uint256(uint64(encodedCardData_));
require(cardId <= maxGameId, "cardId < 2**32");
require(cardId <= cardTokenCounts.length, "sequential cards");
if(cardId == cardTokenCounts.length) {
cardTokenCounts.push(0);
}
|
uint cardId = uint256(uint64(encodedCardData_));
require(cardId <= maxGameId, "cardId < 2**32");
require(cardId <= cardTokenCounts.length, "sequential cards");
if(cardId == cardTokenCounts.length) {
cardTokenCounts.push(0);
}
| 25,709
|
32
|
// Withdraw dividends
|
withdraw();
|
withdraw();
| 34,038
|
254
|
// Distribute the remaining bond into the darknode payment reward pool
|
require(address(darknodePayment) != address(0x0), "DarknodeRegistry: invalid payment address");
require(ren.transfer(address(darknodePayment.store()), reward), "DarknodeRegistry: reward transfer failed");
require(ren.transfer(_challenger, reward), "DarknodeRegistry: reward transfer failed");
|
require(address(darknodePayment) != address(0x0), "DarknodeRegistry: invalid payment address");
require(ren.transfer(address(darknodePayment.store()), reward), "DarknodeRegistry: reward transfer failed");
require(ren.transfer(_challenger, reward), "DarknodeRegistry: reward transfer failed");
| 44,528
|
16
|
// Passes arbitrary bytes of data to an external contract that implements the Callee interface.Does not change any asset amounts. This function may be useful for setting certain variableson layer-two contracts for certain accounts without having to make a separate Ethereumtransaction for doing so. Also, the second-layer contracts can ensure that the call is comingfrom an operator of the particular account. /
|
struct CallArgs {
Account.Info account;
address callee;
bytes data;
}
|
struct CallArgs {
Account.Info account;
address callee;
bytes data;
}
| 13,599
|
91
|
// Get Locked and unlocked capital
|
uint256[] memory userDeposits = ownedDeposits[msg.sender];
require(userDeposits.length != 0, "Dont have any deposits");
_claimRecord.claimedAmount = _claimRecord.claimedAmount.add(
claimableAmount
);
_claimRecord.claimedAt = block.timestamp;
require(claimableAmount <= getBalance(), "no enough busd in pool");
IERC20Upgradeable(BUSDContract).safeTransfer(
|
uint256[] memory userDeposits = ownedDeposits[msg.sender];
require(userDeposits.length != 0, "Dont have any deposits");
_claimRecord.claimedAmount = _claimRecord.claimedAmount.add(
claimableAmount
);
_claimRecord.claimedAt = block.timestamp;
require(claimableAmount <= getBalance(), "no enough busd in pool");
IERC20Upgradeable(BUSDContract).safeTransfer(
| 28,759
|
52
|
// SimpleTokenVery simple ERC20 Token example, where all tokens are pre-assigned to the creator. Note they can later distribute these tokens as they wish using `transfer` and other `StandardToken` functions./
|
// contract StfuTokenCrowdsale is Crowdsale {
// string public constant name = "StfuToken"; // solium-disable-line uppercase
// string public constant symbol = "STFU"; // solium-disable-line uppercase
// uint8 public constant decimals = 18; // solium-disable-line uppercase
// uint256 public constant INITIAL_SUPPLY = 20000 * (10 ** uint256(decimals));
// /**
// * @dev Constructor that gives msg.sender all of existing tokens.
// */
// function StfuToken() public {
// totalSupply_ = INITIAL_SUPPLY;
// balances[msg.sender] = INITIAL_SUPPLY;
// Transfer(0x0, msg.sender, INITIAL_SUPPLY);
// }
// }
|
// contract StfuTokenCrowdsale is Crowdsale {
// string public constant name = "StfuToken"; // solium-disable-line uppercase
// string public constant symbol = "STFU"; // solium-disable-line uppercase
// uint8 public constant decimals = 18; // solium-disable-line uppercase
// uint256 public constant INITIAL_SUPPLY = 20000 * (10 ** uint256(decimals));
// /**
// * @dev Constructor that gives msg.sender all of existing tokens.
// */
// function StfuToken() public {
// totalSupply_ = INITIAL_SUPPLY;
// balances[msg.sender] = INITIAL_SUPPLY;
// Transfer(0x0, msg.sender, INITIAL_SUPPLY);
// }
// }
| 37,780
|
67
|
// AllowanceCrowdsale Extension of Crowdsale where tokens are held by a wallet, which approves an allowance to the crowdsale. /
|
contract AllowanceCrowdsale is Crowdsale {
using SafeMath for uint256;
using SafeERC20 for ERC20;
address public tokenWallet;
/**
* @dev Constructor, takes token wallet address.
* @param _tokenWallet Address holding the tokens, which has approved allowance to the crowdsale
*/
constructor(address _tokenWallet) public {
require(_tokenWallet != address(0));
tokenWallet = _tokenWallet;
}
/**
* @dev Checks the amount of tokens left in the allowance.
* @return Amount of tokens left in the allowance
*/
function remainingTokens() public view returns (uint256) {
return token.allowance(tokenWallet, this);
}
/**
* @dev Overrides parent behavior by transferring tokens from wallet.
* @param _beneficiary Token purchaser
* @param _tokenAmount Amount of tokens purchased
*/
function _deliverTokens(
address _beneficiary,
uint256 _tokenAmount
)
internal
{
token.safeTransferFrom(tokenWallet, _beneficiary, _tokenAmount);
}
}
|
contract AllowanceCrowdsale is Crowdsale {
using SafeMath for uint256;
using SafeERC20 for ERC20;
address public tokenWallet;
/**
* @dev Constructor, takes token wallet address.
* @param _tokenWallet Address holding the tokens, which has approved allowance to the crowdsale
*/
constructor(address _tokenWallet) public {
require(_tokenWallet != address(0));
tokenWallet = _tokenWallet;
}
/**
* @dev Checks the amount of tokens left in the allowance.
* @return Amount of tokens left in the allowance
*/
function remainingTokens() public view returns (uint256) {
return token.allowance(tokenWallet, this);
}
/**
* @dev Overrides parent behavior by transferring tokens from wallet.
* @param _beneficiary Token purchaser
* @param _tokenAmount Amount of tokens purchased
*/
function _deliverTokens(
address _beneficiary,
uint256 _tokenAmount
)
internal
{
token.safeTransferFrom(tokenWallet, _beneficiary, _tokenAmount);
}
}
| 28,880
|
2
|
// Mapping of the geoJson for each token
|
mapping(uint256 => string) private geoJson;
|
mapping(uint256 => string) private geoJson;
| 37,962
|
27
|
// /read-only interface//total number of posts
|
function numberOfPosts(
)external view virtual override returns(
uint256
|
function numberOfPosts(
)external view virtual override returns(
uint256
| 12,594
|
219
|
// Reads the int128 at `cdPtr` in calldata.
|
function readInt128(
CalldataPointer cdPtr
|
function readInt128(
CalldataPointer cdPtr
| 12,723
|
6
|
// transfers the SEANCE to the contract.
|
seance.transferFrom(msg.sender, address(this), amount);
emit Enchant(msg.sender, amount);
|
seance.transferFrom(msg.sender, address(this), amount);
emit Enchant(msg.sender, amount);
| 51,820
|
109
|
// Returns an abbreviated name for NFTokens.return _symbol Representing symbol. /
|
function symbol() external view override returns (string memory _symbol) {
_symbol = nftSymbol;
}
|
function symbol() external view override returns (string memory _symbol) {
_symbol = nftSymbol;
}
| 15,362
|
127
|
// Mines new gemstones. Puts kind you want to mine + your salt and tests your luck!
|
function mine(uint kind, uint salt) external nonReentrant {
uint val = luck(kind, salt);
nonce[msg.sender]++;
require(kind < gemCount, 'gem kind not exist');
uint diff = gems[kind].difficulty;
require(val <= type(uint).max / diff, 'salt not good enough');
gems[kind].difficulty = (diff * gems[kind].multiplier) / 10000 + 1;
_mint(msg.sender, kind, gems[kind].gemsPerMine, '');
}
|
function mine(uint kind, uint salt) external nonReentrant {
uint val = luck(kind, salt);
nonce[msg.sender]++;
require(kind < gemCount, 'gem kind not exist');
uint diff = gems[kind].difficulty;
require(val <= type(uint).max / diff, 'salt not good enough');
gems[kind].difficulty = (diff * gems[kind].multiplier) / 10000 + 1;
_mint(msg.sender, kind, gems[kind].gemsPerMine, '');
}
| 41,240
|
8
|
// Evento que notifica a aplicação cliente Etherum da aprovação de saldo de um proprietário para um "gastador"
|
event Approval(address indexed holder, address indexed spender, uint256 value);
|
event Approval(address indexed holder, address indexed spender, uint256 value);
| 40,682
|
112
|
// Exercises an active option optionID ID of your option /
|
function exercise(uint optionID) external {
Option storage option = options[optionID];
require(option.expiration >= block.timestamp, "Option has expired");
require(option.holder == msg.sender, "Wrong msg.sender");
require(option.state == State.Active, "Wrong state");
option.state = State.Exercised;
uint profit = _payProfit(optionID);
cumulativeStrike = cumulativeStrike.sub(option.strike);
cumulativeAmount = cumulativeAmount.sub(option.amount);
if (option.optionType == OptionType.Call) {
cumulativeCalls = cumulativeCalls.sub(option.lockedAmount);
} else if (option.optionType == OptionType.Put) {
cumulativePuts = cumulativePuts.sub(option.lockedAmount);
}
emit Exercise(optionID, profit);
}
|
function exercise(uint optionID) external {
Option storage option = options[optionID];
require(option.expiration >= block.timestamp, "Option has expired");
require(option.holder == msg.sender, "Wrong msg.sender");
require(option.state == State.Active, "Wrong state");
option.state = State.Exercised;
uint profit = _payProfit(optionID);
cumulativeStrike = cumulativeStrike.sub(option.strike);
cumulativeAmount = cumulativeAmount.sub(option.amount);
if (option.optionType == OptionType.Call) {
cumulativeCalls = cumulativeCalls.sub(option.lockedAmount);
} else if (option.optionType == OptionType.Put) {
cumulativePuts = cumulativePuts.sub(option.lockedAmount);
}
emit Exercise(optionID, profit);
}
| 34,982
|
18
|
// returns ETH & Token to the liquidity provider
|
(bool sent, ) = (msg.sender).call{value: ethAmount}("");
|
(bool sent, ) = (msg.sender).call{value: ethAmount}("");
| 7,432
|
20
|
// Set the address of ValidationManager with which validation will be done/Allowed only for Deployer (see contract Deployerable)
|
function setValidationManager(
address _validationAddress
|
function setValidationManager(
address _validationAddress
| 24,122
|
229
|
// 8. Tell the manager.
|
if (loan.short) {
_manager().decrementShorts(loan.currency, loan.amount);
if (shortingRewards[loan.currency] != address(0)) {
IShortingRewards(shortingRewards[loan.currency]).withdraw(borrower, loan.amount);
}
|
if (loan.short) {
_manager().decrementShorts(loan.currency, loan.amount);
if (shortingRewards[loan.currency] != address(0)) {
IShortingRewards(shortingRewards[loan.currency]).withdraw(borrower, loan.amount);
}
| 18,201
|
43
|
// this is a recent ethereum block hash, used to prevent pre-mining future blocks
|
function getChallengeNumber() public constant returns (bytes32) {
return challengeNumber;
}
|
function getChallengeNumber() public constant returns (bytes32) {
return challengeNumber;
}
| 4,752
|
13
|
// Contract not in expected state
|
revert();
_;
|
revert();
_;
| 56,416
|
5
|
// EVENTS
|
event MarketPurchase(
address indexed _from,
address indexed _to,
uint32 _point,
uint96 _price,
address token
);
event ListingRemoved(
|
event MarketPurchase(
address indexed _from,
address indexed _to,
uint32 _point,
uint96 _price,
address token
);
event ListingRemoved(
| 3,130
|
204
|
// Execute min withdrawal fee update (with time delay enforced). Needs to be called after the update was prepraed. Fails if called before time delay is met.return New withdrawal fee. /
|
function executeNewMinWithdrawalFee() external returns (uint256) {
uint256 newFee = _executeUInt256(_MIN_WITHDRAWAL_FEE_KEY);
_checkFeeInvariants(newFee, getMaxWithdrawalFee());
return newFee;
}
|
function executeNewMinWithdrawalFee() external returns (uint256) {
uint256 newFee = _executeUInt256(_MIN_WITHDRAWAL_FEE_KEY);
_checkFeeInvariants(newFee, getMaxWithdrawalFee());
return newFee;
}
| 80,206
|
9
|
// Decode a `Witnet.CBOR` structure into a native `string` value./_cborValue An instance of `Witnet.CBOR`./ return The value represented by the input, as a `string` value.
|
function decodeString(Witnet.CBOR memory _cborValue) public pure returns(string memory) {
_cborValue.len = readLength(_cborValue.buffer, _cborValue.additionalInformation);
if (_cborValue.len == _UINT64_MAX) {
bytes memory textData;
bool done;
while (!done) {
uint64 itemLength = readIndefiniteStringLength(_cborValue.buffer, _cborValue.majorType);
if (itemLength < _UINT64_MAX) {
textData = abi.encodePacked(textData, readText(_cborValue.buffer, itemLength / 4));
} else {
done = true;
}
}
return string(textData);
} else {
return string(readText(_cborValue.buffer, _cborValue.len));
}
}
|
function decodeString(Witnet.CBOR memory _cborValue) public pure returns(string memory) {
_cborValue.len = readLength(_cborValue.buffer, _cborValue.additionalInformation);
if (_cborValue.len == _UINT64_MAX) {
bytes memory textData;
bool done;
while (!done) {
uint64 itemLength = readIndefiniteStringLength(_cborValue.buffer, _cborValue.majorType);
if (itemLength < _UINT64_MAX) {
textData = abi.encodePacked(textData, readText(_cborValue.buffer, itemLength / 4));
} else {
done = true;
}
}
return string(textData);
} else {
return string(readText(_cborValue.buffer, _cborValue.len));
}
}
| 12,261
|
456
|
// Set the owner of a Relay Manager. Called only by the RelayManager itself./ Note that owners cannot transfer ownership - if the entry already exists, reverts./owner - owner of the relay (as configured off-chain)
|
function setRelayManagerOwner(address payable owner) external;
|
function setRelayManagerOwner(address payable owner) external;
| 78,275
|
29
|
// Transfers of 0 values MUST be treated as normal transfers and fire the Transfer event (ERC-20)
|
require(_value >= 0);
|
require(_value >= 0);
| 1,182
|
177
|
// Freeze the amount of tokens for that resource
|
KingOfEthResourcesInterface(interfaceContract).exchangeFreezeTokens(
_resource
, msg.sender
, _amountTrading
);
|
KingOfEthResourcesInterface(interfaceContract).exchangeFreezeTokens(
_resource
, msg.sender
, _amountTrading
);
| 47,955
|
327
|
// OpenSea contract helper that defines a few things/Simon Fremaux (@dievardump)/This is a contract used to add OpenSea's/gas-less trading and contractURI support
|
contract BaseOpenSea {
string private _contractURI;
ProxyRegistry private _proxyRegistry;
/// @notice Returns the contract URI function. Used on OpenSea to get details
// about a contract (owner, royalties etc...)
function contractURI() public view returns (string memory) {
return _contractURI;
}
/// @notice Returns the current OS proxyRegistry address registered
function proxyRegistry() public view returns (address) {
return address(_proxyRegistry);
}
/// @notice Helper for OpenSea gas-less trading
/// @dev Allows to check if `operator` is owner's OpenSea proxy
/// @param owner the owner we check for
/// @param operator the operator (proxy) we check for
function isOwnersOpenSeaProxy(address owner, address operator)
public
view
returns (bool)
{
ProxyRegistry proxyRegistry_ = _proxyRegistry;
return
// we have a proxy registry address
address(proxyRegistry_) != address(0) &&
// current operator is owner's proxy address
address(proxyRegistry_.proxies(owner)) == operator;
}
/// @dev Internal function to set the _contractURI
/// @param contractURI_ the new contract uri
function _setContractURI(string memory contractURI_) internal {
_contractURI = contractURI_;
}
/// @dev Internal function to set the _proxyRegistry
/// @param proxyRegistryAddress the new proxy registry address
function _setOpenSeaRegistry(address proxyRegistryAddress) internal {
_proxyRegistry = ProxyRegistry(proxyRegistryAddress);
}
}
|
contract BaseOpenSea {
string private _contractURI;
ProxyRegistry private _proxyRegistry;
/// @notice Returns the contract URI function. Used on OpenSea to get details
// about a contract (owner, royalties etc...)
function contractURI() public view returns (string memory) {
return _contractURI;
}
/// @notice Returns the current OS proxyRegistry address registered
function proxyRegistry() public view returns (address) {
return address(_proxyRegistry);
}
/// @notice Helper for OpenSea gas-less trading
/// @dev Allows to check if `operator` is owner's OpenSea proxy
/// @param owner the owner we check for
/// @param operator the operator (proxy) we check for
function isOwnersOpenSeaProxy(address owner, address operator)
public
view
returns (bool)
{
ProxyRegistry proxyRegistry_ = _proxyRegistry;
return
// we have a proxy registry address
address(proxyRegistry_) != address(0) &&
// current operator is owner's proxy address
address(proxyRegistry_.proxies(owner)) == operator;
}
/// @dev Internal function to set the _contractURI
/// @param contractURI_ the new contract uri
function _setContractURI(string memory contractURI_) internal {
_contractURI = contractURI_;
}
/// @dev Internal function to set the _proxyRegistry
/// @param proxyRegistryAddress the new proxy registry address
function _setOpenSeaRegistry(address proxyRegistryAddress) internal {
_proxyRegistry = ProxyRegistry(proxyRegistryAddress);
}
}
| 38,578
|
14
|
// Helper interfaces
|
import { IWETH } from "../interfaces/IWETH.sol";
import "../openzeppelin-presets/token/ERC20/SafeERC20.sol";
library CurrencyTransferLib {
using SafeERC20 for IERC20;
/// @dev The address interpreted as native token of the chain.
address public constant NATIVE_TOKEN = 0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE;
/// @dev Transfers a given amount of currency.
function transferCurrency(
address _currency,
address _from,
address _to,
uint256 _amount
) internal {
if (_amount == 0) {
return;
}
if (_currency == NATIVE_TOKEN) {
safeTransferNativeToken(_to, _amount);
} else {
safeTransferERC20(_currency, _from, _to, _amount);
}
}
/// @dev Transfers a given amount of currency. (With native token wrapping)
function transferCurrencyWithWrapper(
address _currency,
address _from,
address _to,
uint256 _amount,
address _nativeTokenWrapper
) internal {
if (_amount == 0) {
return;
}
if (_currency == NATIVE_TOKEN) {
if (_from == address(this)) {
// withdraw from weth then transfer withdrawn native token to recipient
IWETH(_nativeTokenWrapper).withdraw(_amount);
safeTransferNativeTokenWithWrapper(_to, _amount, _nativeTokenWrapper);
} else if (_to == address(this)) {
// store native currency in weth
require(_amount == msg.value, "msg.value != amount");
IWETH(_nativeTokenWrapper).deposit{ value: _amount }();
} else {
safeTransferNativeTokenWithWrapper(_to, _amount, _nativeTokenWrapper);
}
} else {
safeTransferERC20(_currency, _from, _to, _amount);
}
}
/// @dev Transfer `amount` of ERC20 token from `from` to `to`.
function safeTransferERC20(
address _currency,
address _from,
address _to,
uint256 _amount
) internal {
if (_from == _to) {
return;
}
if (_from == address(this)) {
IERC20(_currency).safeTransfer(_to, _amount);
} else {
IERC20(_currency).safeTransferFrom(_from, _to, _amount);
}
}
/// @dev Transfers `amount` of native token to `to`.
function safeTransferNativeToken(address to, uint256 value) internal {
// solhint-disable avoid-low-level-calls
// slither-disable-next-line low-level-calls
(bool success, ) = to.call{ value: value }("");
require(success, "native token transfer failed");
}
/// @dev Transfers `amount` of native token to `to`. (With native token wrapping)
function safeTransferNativeTokenWithWrapper(
address to,
uint256 value,
address _nativeTokenWrapper
) internal {
// solhint-disable avoid-low-level-calls
// slither-disable-next-line low-level-calls
(bool success, ) = to.call{ value: value }("");
if (!success) {
IWETH(_nativeTokenWrapper).deposit{ value: value }();
IERC20(_nativeTokenWrapper).safeTransfer(to, value);
}
}
}
|
import { IWETH } from "../interfaces/IWETH.sol";
import "../openzeppelin-presets/token/ERC20/SafeERC20.sol";
library CurrencyTransferLib {
using SafeERC20 for IERC20;
/// @dev The address interpreted as native token of the chain.
address public constant NATIVE_TOKEN = 0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE;
/// @dev Transfers a given amount of currency.
function transferCurrency(
address _currency,
address _from,
address _to,
uint256 _amount
) internal {
if (_amount == 0) {
return;
}
if (_currency == NATIVE_TOKEN) {
safeTransferNativeToken(_to, _amount);
} else {
safeTransferERC20(_currency, _from, _to, _amount);
}
}
/// @dev Transfers a given amount of currency. (With native token wrapping)
function transferCurrencyWithWrapper(
address _currency,
address _from,
address _to,
uint256 _amount,
address _nativeTokenWrapper
) internal {
if (_amount == 0) {
return;
}
if (_currency == NATIVE_TOKEN) {
if (_from == address(this)) {
// withdraw from weth then transfer withdrawn native token to recipient
IWETH(_nativeTokenWrapper).withdraw(_amount);
safeTransferNativeTokenWithWrapper(_to, _amount, _nativeTokenWrapper);
} else if (_to == address(this)) {
// store native currency in weth
require(_amount == msg.value, "msg.value != amount");
IWETH(_nativeTokenWrapper).deposit{ value: _amount }();
} else {
safeTransferNativeTokenWithWrapper(_to, _amount, _nativeTokenWrapper);
}
} else {
safeTransferERC20(_currency, _from, _to, _amount);
}
}
/// @dev Transfer `amount` of ERC20 token from `from` to `to`.
function safeTransferERC20(
address _currency,
address _from,
address _to,
uint256 _amount
) internal {
if (_from == _to) {
return;
}
if (_from == address(this)) {
IERC20(_currency).safeTransfer(_to, _amount);
} else {
IERC20(_currency).safeTransferFrom(_from, _to, _amount);
}
}
/// @dev Transfers `amount` of native token to `to`.
function safeTransferNativeToken(address to, uint256 value) internal {
// solhint-disable avoid-low-level-calls
// slither-disable-next-line low-level-calls
(bool success, ) = to.call{ value: value }("");
require(success, "native token transfer failed");
}
/// @dev Transfers `amount` of native token to `to`. (With native token wrapping)
function safeTransferNativeTokenWithWrapper(
address to,
uint256 value,
address _nativeTokenWrapper
) internal {
// solhint-disable avoid-low-level-calls
// slither-disable-next-line low-level-calls
(bool success, ) = to.call{ value: value }("");
if (!success) {
IWETH(_nativeTokenWrapper).deposit{ value: value }();
IERC20(_nativeTokenWrapper).safeTransfer(to, value);
}
}
}
| 2,841
|
51
|
// set Broker for Investor/_target address of Investor/_broker address of Broker
|
function setReferral(address _target, address _broker, uint256 _amount) onlyOwner public {
require (_target != 0x0);
require (_broker != 0x0);
referrals[_target] = _broker;
emit SetReferral(_target, _broker);
if(_amount>0x0){
uint256 brokerBonus = safeDiv(safeMul(_amount,referralBonus),hundredPercent);
bonus[_broker] = safeAdd(bonus[_broker],brokerBonus);
emit ReferralBonus(_target,_broker,brokerBonus);
}
}
|
function setReferral(address _target, address _broker, uint256 _amount) onlyOwner public {
require (_target != 0x0);
require (_broker != 0x0);
referrals[_target] = _broker;
emit SetReferral(_target, _broker);
if(_amount>0x0){
uint256 brokerBonus = safeDiv(safeMul(_amount,referralBonus),hundredPercent);
bonus[_broker] = safeAdd(bonus[_broker],brokerBonus);
emit ReferralBonus(_target,_broker,brokerBonus);
}
}
| 27,791
|
169
|
// get reward
|
uint256 yaoReward = getPoolReward(pool.lastRewardBlock, pool.allocPoint);
|
uint256 yaoReward = getPoolReward(pool.lastRewardBlock, pool.allocPoint);
| 16,375
|
1
|
// validation for date of campaign
|
require(campaign.deadline < block.timestamp, "Wrong date for deadline");
campaign.owner = _owner;
campaign.titile = _title;
campaign.description = _description;
campaign.target = _target;
campaign.deadline = _deadline;
campaign.amountCollected = 0;
campaign.imageURL = _imageURL;
|
require(campaign.deadline < block.timestamp, "Wrong date for deadline");
campaign.owner = _owner;
campaign.titile = _title;
campaign.description = _description;
campaign.target = _target;
campaign.deadline = _deadline;
campaign.amountCollected = 0;
campaign.imageURL = _imageURL;
| 17,652
|
6
|
// event Mint(address indexed sender, uint amount0, uint amount1); event Burn(address indexed sender, uint amount0, uint amount1, address indexed to);
|
event Add(uint _amount01In, uint reserve0, uint reserve1);
event Swap(
address indexed sender,
address token01Out,
uint amount2In,
uint amount2Out,
address indexed to
);
event Sync(uint reserve0, uint reserve1, uint reserve2);
event remove(uint amount0, uint amount1, uint amount2);
|
event Add(uint _amount01In, uint reserve0, uint reserve1);
event Swap(
address indexed sender,
address token01Out,
uint amount2In,
uint amount2Out,
address indexed to
);
event Sync(uint reserve0, uint reserve1, uint reserve2);
event remove(uint amount0, uint amount1, uint amount2);
| 36,667
|
166
|
// Emitted when an attempt to relay a call failed. This can happen due to incorrect {relayCall} arguments, or the recipient not accepting the relayed call. Theactual relayed call was not executed, and the recipient not charged. The `reason` parameter contains an error code: values 1-10 correspond to `PreconditionCheck` entries, and valuesover 10 are custom recipient error codes returned from {acceptRelayedCall}. /
|
event CanRelayFailed(address indexed relay, address indexed from, address indexed to, bytes4 selector, uint256 reason);
|
event CanRelayFailed(address indexed relay, address indexed from, address indexed to, bytes4 selector, uint256 reason);
| 5,459
|
215
|
// Utilized during module initializations to check that the module is in pending stateand that the CKToken is valid /
|
modifier onlyValidAndPendingCK(ICKToken _ckToken) {
_validateOnlyValidAndPendingCK(_ckToken);
_;
}
|
modifier onlyValidAndPendingCK(ICKToken _ckToken) {
_validateOnlyValidAndPendingCK(_ckToken);
_;
}
| 23,399
|
38
|
// events
|
event TokenPurchase(address indexed beneficiary, uint256 value, uint256 amount);
event CrowdFundClosed(uint256 _blockTimeStamp);
event ChangeFoundersWalletAddress(uint256 _blockTimeStamp, address indexed _foundersWalletAddress);
|
event TokenPurchase(address indexed beneficiary, uint256 value, uint256 amount);
event CrowdFundClosed(uint256 _blockTimeStamp);
event ChangeFoundersWalletAddress(uint256 _blockTimeStamp, address indexed _foundersWalletAddress);
| 1,161
|
22
|
// Base contract for PixelCoins. Holds all common structs, events and base variables./Oliver Schneider <info@pixelcoins.io> (https:pixelcoins.io)/See the PixelCore contract documentation to understand how the various contract facets are arranged.
|
contract PixelBase is PixelAuthority {
/*** EVENTS ***/
/// @dev Transfer event as defined in current draft of ERC721. Emitted every time a Pixel
/// ownership is assigned.
event Transfer(address from, address to, uint256 tokenId);
/*** CONSTANTS ***/
uint32 public WIDTH = 1000;
uint32 public HEIGHT = 1000;
/*** STORAGE ***/
/// @dev A mapping from pixel ids to the address that owns them. A pixel address of 0 means,
/// that the pixel can still be bought.
mapping (uint256 => address) public pixelIndexToOwner;
/// Address that is approved to change ownship
mapping (uint256 => address) public pixelIndexToApproved;
/// Stores the color of an pixel, indexed by pixelid
mapping (uint256 => uint32) public colors;
// @dev A mapping from owner address to count of tokens that address owns.
// Used internally inside balanceOf() to resolve ownership count.
mapping (address => uint256) ownershipTokenCount;
// Internal utility functions: These functions all assume that their input arguments
// are valid. We leave it to public methods to sanitize their inputs and follow
// the required logic.
/// @dev Assigns ownership of a specific Pixel to an address.
function _transfer(address _from, address _to, uint256 _tokenId) internal {
// Can no overflowe since the number of Pixels is capped.
// transfer ownership
ownershipTokenCount[_to]++;
pixelIndexToOwner[_tokenId] = _to;
if (_from != address(0)) {
ownershipTokenCount[_from]--;
delete pixelIndexToApproved[_tokenId];
}
// Emit the transfer event.
Transfer(_from, _to, _tokenId);
}
/// @dev Checks if a given address is the current owner of a particular Pixel.
/// @param _claimant the address we are validating against.
/// @param _tokenId Pixel id
function _owns(address _claimant, uint256 _tokenId) internal view returns (bool) {
return pixelIndexToOwner[_tokenId] == _claimant;
}
/// @dev Checks if a given address currently has transferApproval for a particular Pixel.
/// @param _claimant the address we are confirming pixel is approved for.
/// @param _tokenId pixel id, only valid when > 0
function _approvedFor(address _claimant, uint256 _tokenId) internal view returns (bool) {
return pixelIndexToApproved[_tokenId] == _claimant;
}
}
|
contract PixelBase is PixelAuthority {
/*** EVENTS ***/
/// @dev Transfer event as defined in current draft of ERC721. Emitted every time a Pixel
/// ownership is assigned.
event Transfer(address from, address to, uint256 tokenId);
/*** CONSTANTS ***/
uint32 public WIDTH = 1000;
uint32 public HEIGHT = 1000;
/*** STORAGE ***/
/// @dev A mapping from pixel ids to the address that owns them. A pixel address of 0 means,
/// that the pixel can still be bought.
mapping (uint256 => address) public pixelIndexToOwner;
/// Address that is approved to change ownship
mapping (uint256 => address) public pixelIndexToApproved;
/// Stores the color of an pixel, indexed by pixelid
mapping (uint256 => uint32) public colors;
// @dev A mapping from owner address to count of tokens that address owns.
// Used internally inside balanceOf() to resolve ownership count.
mapping (address => uint256) ownershipTokenCount;
// Internal utility functions: These functions all assume that their input arguments
// are valid. We leave it to public methods to sanitize their inputs and follow
// the required logic.
/// @dev Assigns ownership of a specific Pixel to an address.
function _transfer(address _from, address _to, uint256 _tokenId) internal {
// Can no overflowe since the number of Pixels is capped.
// transfer ownership
ownershipTokenCount[_to]++;
pixelIndexToOwner[_tokenId] = _to;
if (_from != address(0)) {
ownershipTokenCount[_from]--;
delete pixelIndexToApproved[_tokenId];
}
// Emit the transfer event.
Transfer(_from, _to, _tokenId);
}
/// @dev Checks if a given address is the current owner of a particular Pixel.
/// @param _claimant the address we are validating against.
/// @param _tokenId Pixel id
function _owns(address _claimant, uint256 _tokenId) internal view returns (bool) {
return pixelIndexToOwner[_tokenId] == _claimant;
}
/// @dev Checks if a given address currently has transferApproval for a particular Pixel.
/// @param _claimant the address we are confirming pixel is approved for.
/// @param _tokenId pixel id, only valid when > 0
function _approvedFor(address _claimant, uint256 _tokenId) internal view returns (bool) {
return pixelIndexToApproved[_tokenId] == _claimant;
}
}
| 46,809
|
19
|
// Storage slot with the address of the current implementation.This is the keccak-256 hash of "eip1967.proxy.implementation" subtracted by 1, and isvalidated in the constructor. /
|
bytes32 internal constant IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;
|
bytes32 internal constant IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;
| 5,289
|
18
|
// Allows a Module to execute a Safe transaction without any further confirmations./to Destination address of module transaction./value Ether value of module transaction./data Data payload of module transaction./operation Operation type of module transaction.
|
function execTransactionFromModule(address to, uint256 value, bytes calldata data, Enum.Operation operation)
external
returns (bool success);
|
function execTransactionFromModule(address to, uint256 value, bytes calldata data, Enum.Operation operation)
external
returns (bool success);
| 30,737
|
29
|
// Maintain a maximum allowable transfer size (in Ether) for the deposit manager.
|
uint256 private _etherLimit; // unused
bool private _originatesFromReserveTrader; // unused, don't change storage layout
uint256 private constant _VERSION = 1016;
|
uint256 private _etherLimit; // unused
bool private _originatesFromReserveTrader; // unused, don't change storage layout
uint256 private constant _VERSION = 1016;
| 29,353
|
703
|
// res += valcoefficients[175].
|
res := addmod(res,
mulmod(val, /*coefficients[175]*/ mload(0x19e0), PRIME),
PRIME)
|
res := addmod(res,
mulmod(val, /*coefficients[175]*/ mload(0x19e0), PRIME),
PRIME)
| 19,767
|
11
|
// 所有僵尸集合
|
Zombie[] public zombies;
|
Zombie[] public zombies;
| 3,538
|
30
|
// A mapping from tokens IDs to the address that owns them. All tokens have some valid owner address
|
mapping (uint256 => address) public tokenIndexToOwner;
|
mapping (uint256 => address) public tokenIndexToOwner;
| 30,766
|
143
|
// total amount of tokens to be released at the end of the vesting
|
uint256 amountTotal;
|
uint256 amountTotal;
| 25,484
|
6
|
// Results a metadata URI tokenId token URI per token ID /
|
function uri(uint256 tokenId)
public
view
override(ERC1155URIStorage)
returns (string memory)
|
function uri(uint256 tokenId)
public
view
override(ERC1155URIStorage)
returns (string memory)
| 37,542
|
21
|
//
|
* @dev See {IERC20-totalSupply}.
*/
function totalSupply() public view virtual override returns (uint256) {
return _totalSupply;
}
|
* @dev See {IERC20-totalSupply}.
*/
function totalSupply() public view virtual override returns (uint256) {
return _totalSupply;
}
| 74,382
|
1
|
// pool data view functions
|
function getA() external view returns (uint256);
function getAPrecise() external view returns (uint256);
function getAllowlist() external view returns (IAllowlist);
function getToken(uint8 index) external view returns (IERC20);
function getTokenIndex(address tokenAddress) external view returns (uint8);
|
function getA() external view returns (uint256);
function getAPrecise() external view returns (uint256);
function getAllowlist() external view returns (IAllowlist);
function getToken(uint8 index) external view returns (IERC20);
function getTokenIndex(address tokenAddress) external view returns (uint8);
| 6,568
|
39
|
// Transfer INCH to Purchaser
|
inchWormContract.transfer(msg.sender, _inchToBuy);
emit BuyInchWithWei(_inchToBuy, msg.value);
|
inchWormContract.transfer(msg.sender, _inchToBuy);
emit BuyInchWithWei(_inchToBuy, msg.value);
| 33,325
|
2
|
// Adds liquidity to the pool. /
|
function addLiquidity(uint256 _amountCk, uint256 _amountUsdc, address to)
external
nonReentrant
returns (
uint256 calculatedAmountCk,
uint256 calculatedAmountUsdc,
uint256 liquidity
)
|
function addLiquidity(uint256 _amountCk, uint256 _amountUsdc, address to)
external
nonReentrant
returns (
uint256 calculatedAmountCk,
uint256 calculatedAmountUsdc,
uint256 liquidity
)
| 14,231
|
54
|
// One more bit, double codes left
|
left <<= 1;
if (left < h.counts[len]) {
|
left <<= 1;
if (left < h.counts[len]) {
| 1,940
|
24
|
// This function is only callable after the curve contract has beeninitialized._amount The amount of tokens a user wants to sellreturn uint256 The reward for selling the _amount of tokens in ETH /
|
function sellReward(uint256 _amount)
public
view
isCurveActive()
returns (uint256)
|
function sellReward(uint256 _amount)
public
view
isCurveActive()
returns (uint256)
| 29,224
|
7
|
// get required margin, denominated in collateral
|
FPI.FixedPointInt memory collateralRequired = _getMarginRequired(_vault, hasShort, hasLong);
FPI.FixedPointInt memory excessCollateral = collateralAmount.sub(collateralRequired);
bool isExcess = excessCollateral.isGreaterThanOrEqual(ZERO);
address otoken = hasLong ? _vault.longOtokens[0] : _vault.shortOtokens[0];
uint256 collateralDecimals = uint256(ERC20Interface(OtokenInterface(otoken).collateralAsset()).decimals());
|
FPI.FixedPointInt memory collateralRequired = _getMarginRequired(_vault, hasShort, hasLong);
FPI.FixedPointInt memory excessCollateral = collateralAmount.sub(collateralRequired);
bool isExcess = excessCollateral.isGreaterThanOrEqual(ZERO);
address otoken = hasLong ? _vault.longOtokens[0] : _vault.shortOtokens[0];
uint256 collateralDecimals = uint256(ERC20Interface(OtokenInterface(otoken).collateralAsset()).decimals());
| 8,489
|
70
|
// Emitted when quorum votes basis points is set
|
event QuorumVotesBPSSet(uint256 oldQuorumVotesBPS, uint256 newQuorumVotesBPS);
|
event QuorumVotesBPSSet(uint256 oldQuorumVotesBPS, uint256 newQuorumVotesBPS);
| 65,117
|
19
|
// Convenience method for a pairing check for three pairs.
|
function pairingProd3(
G1Point memory a1, G2Point memory a2,
G1Point memory b1, G2Point memory b2,
G1Point memory c1, G2Point memory c2
|
function pairingProd3(
G1Point memory a1, G2Point memory a2,
G1Point memory b1, G2Point memory b2,
G1Point memory c1, G2Point memory c2
| 6,747
|
17
|
// BridgeOperationsStorage Functionality for storing processed bridged operations. /
|
abstract contract BridgeOperationsStorage is EternalStorage {
/**
* @dev Stores the bridged token of a message sent to the AMB bridge.
* @param _messageId of the message sent to the bridge.
* @param _token bridged token address.
*/
function setMessageToken(bytes32 _messageId, address _token) internal {
addressStorage[keccak256(abi.encodePacked("messageToken", _messageId))] = _token;
}
/**
* @dev Tells the bridged token address of a message sent to the AMB bridge.
* @return address of a token contract.
*/
function messageToken(bytes32 _messageId) internal view returns (address) {
return addressStorage[keccak256(abi.encodePacked("messageToken", _messageId))];
}
/**
* @dev Stores the value of a message sent to the AMB bridge.
* @param _messageId of the message sent to the bridge.
* @param _value amount of tokens bridged.
*/
function setMessageValue(bytes32 _messageId, uint256 _value) internal {
uintStorage[keccak256(abi.encodePacked("messageValue", _messageId))] = _value;
}
/**
* @dev Tells the amount of tokens of a message sent to the AMB bridge.
* @return value representing amount of tokens.
*/
function messageValue(bytes32 _messageId) internal view returns (uint256) {
return uintStorage[keccak256(abi.encodePacked("messageValue", _messageId))];
}
/**
* @dev Stores the receiver of a message sent to the AMB bridge.
* @param _messageId of the message sent to the bridge.
* @param _recipient receiver of the tokens bridged.
*/
function setMessageRecipient(bytes32 _messageId, address _recipient) internal {
addressStorage[keccak256(abi.encodePacked("messageRecipient", _messageId))] = _recipient;
}
/**
* @dev Tells the receiver of a message sent to the AMB bridge.
* @return address of the receiver.
*/
function messageRecipient(bytes32 _messageId) internal view returns (address) {
return addressStorage[keccak256(abi.encodePacked("messageRecipient", _messageId))];
}
}
|
abstract contract BridgeOperationsStorage is EternalStorage {
/**
* @dev Stores the bridged token of a message sent to the AMB bridge.
* @param _messageId of the message sent to the bridge.
* @param _token bridged token address.
*/
function setMessageToken(bytes32 _messageId, address _token) internal {
addressStorage[keccak256(abi.encodePacked("messageToken", _messageId))] = _token;
}
/**
* @dev Tells the bridged token address of a message sent to the AMB bridge.
* @return address of a token contract.
*/
function messageToken(bytes32 _messageId) internal view returns (address) {
return addressStorage[keccak256(abi.encodePacked("messageToken", _messageId))];
}
/**
* @dev Stores the value of a message sent to the AMB bridge.
* @param _messageId of the message sent to the bridge.
* @param _value amount of tokens bridged.
*/
function setMessageValue(bytes32 _messageId, uint256 _value) internal {
uintStorage[keccak256(abi.encodePacked("messageValue", _messageId))] = _value;
}
/**
* @dev Tells the amount of tokens of a message sent to the AMB bridge.
* @return value representing amount of tokens.
*/
function messageValue(bytes32 _messageId) internal view returns (uint256) {
return uintStorage[keccak256(abi.encodePacked("messageValue", _messageId))];
}
/**
* @dev Stores the receiver of a message sent to the AMB bridge.
* @param _messageId of the message sent to the bridge.
* @param _recipient receiver of the tokens bridged.
*/
function setMessageRecipient(bytes32 _messageId, address _recipient) internal {
addressStorage[keccak256(abi.encodePacked("messageRecipient", _messageId))] = _recipient;
}
/**
* @dev Tells the receiver of a message sent to the AMB bridge.
* @return address of the receiver.
*/
function messageRecipient(bytes32 _messageId) internal view returns (address) {
return addressStorage[keccak256(abi.encodePacked("messageRecipient", _messageId))];
}
}
| 39,036
|
19
|
// to return the tx origin just for the testing purposes
|
address public txorigin;
|
address public txorigin;
| 13,140
|
80
|
// sUSD
|
_token = IERC20(address(0x57Ab1ec28D129707052df4dF418D58a2D46d5f51));
tokenList.push(
TokenInfo({
token: _token,
decimals: _token.decimals(),
price: 1e18,
curveID: 3
})
|
_token = IERC20(address(0x57Ab1ec28D129707052df4dF418D58a2D46d5f51));
tokenList.push(
TokenInfo({
token: _token,
decimals: _token.decimals(),
price: 1e18,
curveID: 3
})
| 12,454
|
79
|
// The accrued but not yet transferred rewards for each user
|
mapping(address => uint256) public rewardsAccrued;
|
mapping(address => uint256) public rewardsAccrued;
| 17,270
|
35
|
// Returns the vesting schedule information for a given identifier.return the vesting schedule structure information /
|
function getVestingSchedule(
bytes32 vestingScheduleId
|
function getVestingSchedule(
bytes32 vestingScheduleId
| 9,022
|
10
|
// Set mint price for a CryptoSea Friend. /
|
function setMintPrice(uint256 _mintPrice) external onlyOwner {
mintPrice = _mintPrice;
}
|
function setMintPrice(uint256 _mintPrice) external onlyOwner {
mintPrice = _mintPrice;
}
| 62,631
|
934
|
// Upper limit on how much of this token the contract can hold at any time
|
uint72 maxCollateralBalance;
|
uint72 maxCollateralBalance;
| 3,975
|
57
|
// such situation can happen when calculated limits relative to the token decimals are too low e.g. minPerTx(address(0)) == 1014, _decimals == 3. _minPerTx happens to be 0, which is not allowed. in this case, limits are raised to the default values
|
if (_minPerTx == 0) {
_minPerTx = 1;
if (_maxPerTx <= _minPerTx) {
_maxPerTx = 100;
_executionMaxPerTx = 100;
if (_dailyLimit <= _maxPerTx || _executionDailyLimit <= _executionMaxPerTx) {
_dailyLimit = 10000;
_executionDailyLimit = 10000;
}
|
if (_minPerTx == 0) {
_minPerTx = 1;
if (_maxPerTx <= _minPerTx) {
_maxPerTx = 100;
_executionMaxPerTx = 100;
if (_dailyLimit <= _maxPerTx || _executionDailyLimit <= _executionMaxPerTx) {
_dailyLimit = 10000;
_executionDailyLimit = 10000;
}
| 2,269
|
28
|
// Transfer tokens to tenderizer
|
steak.safeTransferFrom(_for, address(this), _amount);
_deposit(_for, _amount);
|
steak.safeTransferFrom(_for, address(this), _amount);
_deposit(_for, _amount);
| 20,716
|
2
|
// Provide registry information
|
string public constant override Name = "Withdraw";
string public constant override StateEncoding =
"tuple(bytes initiatorSignature, address initiator, address responder, bytes32 data, uint256 nonce, uint256 fee, address callTo, bytes callData)";
string public constant override ResolverEncoding =
"tuple(bytes responderSignature)";
|
string public constant override Name = "Withdraw";
string public constant override StateEncoding =
"tuple(bytes initiatorSignature, address initiator, address responder, bytes32 data, uint256 nonce, uint256 fee, address callTo, bytes callData)";
string public constant override ResolverEncoding =
"tuple(bytes responderSignature)";
| 39,287
|
2
|
// Multiplies two numbers, returns an error on overflow. /
|
function mulUInt(uint256 a, uint256 b) internal pure returns (MathError, uint256) {
if (a == 0) {
return (MathError.NO_ERROR, 0);
}
uint256 c = a * b;
if (c / a != b) {
return (MathError.INTEGER_OVERFLOW, 0);
} else {
return (MathError.NO_ERROR, c);
}
}
|
function mulUInt(uint256 a, uint256 b) internal pure returns (MathError, uint256) {
if (a == 0) {
return (MathError.NO_ERROR, 0);
}
uint256 c = a * b;
if (c / a != b) {
return (MathError.INTEGER_OVERFLOW, 0);
} else {
return (MathError.NO_ERROR, c);
}
}
| 27,387
|
3
|
// Exchange ID for converting between MATIC and WMATIC
|
uint256 constant WETH_ID = type(uint256).max;
|
uint256 constant WETH_ID = type(uint256).max;
| 26,454
|
32
|
// checking of allowance and token value is done by SafeMath
|
balanceOf[_from] = balanceOf[_from].sub(_value); // Subtract from the targeted balance
allowance[_from][msg.sender] = allowance[_from][msg.sender].sub(_value); // Subtract from the sender's allowance
totalSupply = totalSupply.sub(_value); // Update totalSupply
emit Burn(_from, _value);
return true;
|
balanceOf[_from] = balanceOf[_from].sub(_value); // Subtract from the targeted balance
allowance[_from][msg.sender] = allowance[_from][msg.sender].sub(_value); // Subtract from the sender's allowance
totalSupply = totalSupply.sub(_value); // Update totalSupply
emit Burn(_from, _value);
return true;
| 15,655
|
19
|
// Emit the Transfer/Mint event. the 0x0 source address implies a mint It will also provide the circulating supply info.
|
emit TransferSingle(
msg.sender,
address(0x0),
dst,
id,
quantity
);
|
emit TransferSingle(
msg.sender,
address(0x0),
dst,
id,
quantity
);
| 16,366
|
72
|
// vault finalization task, called when owner calls finalize()
|
function finalization() internal {
if (goalReached()) {
vault.close();
} else {
vault.enableRefunds();
}
super.finalization();
}
|
function finalization() internal {
if (goalReached()) {
vault.close();
} else {
vault.enableRefunds();
}
super.finalization();
}
| 33,373
|
1
|
// information about each photography request photography request by busincess acount holders
|
struct PhotographyRequest {
address requestMaker;
string logo;// ipfs hash to the logo
string description;
uint price;
uint id;
}
|
struct PhotographyRequest {
address requestMaker;
string logo;// ipfs hash to the logo
string description;
uint price;
uint id;
}
| 33,600
|
15
|
// Returns supply claimed by claimer for a given conditionId.
|
function getSupplyClaimedByWallet(
uint256 _conditionId,
address _claimer
|
function getSupplyClaimedByWallet(
uint256 _conditionId,
address _claimer
| 11,744
|
3
|
// Game
|
uint countPresses;
uint256 countInvestorDividends;
uint amountPlayed;
uint32 timerEnd; // The timestamp for the end after this time stamp, the winner can withdraw its reward
uint32 timerInterval = 21600; // We set the interval of 3h
address winningAddress;
|
uint countPresses;
uint256 countInvestorDividends;
uint amountPlayed;
uint32 timerEnd; // The timestamp for the end after this time stamp, the winner can withdraw its reward
uint32 timerInterval = 21600; // We set the interval of 3h
address winningAddress;
| 24,885
|
145
|
// -------------------------------------------------------------------------------------- Added due to Matic <-> Ethereum PoS transfer requiring 1PLCO2 on Matic network to be burned or minted. Eth supply can be increased if it is ever necessary.--------------------------------------------------------------------------------------
|
function setMaxVolume(uint maxVolume) external onlyOwner {
_maxSupply = maxVolume;
}
|
function setMaxVolume(uint maxVolume) external onlyOwner {
_maxSupply = maxVolume;
}
| 58,081
|
599
|
// Verifies that a hash has been signed by the given signer./hash Any 32-byte hash./signature Proof that the hash has been signed by signer./ return isValid `true` if the signature is valid for the given hash and signer.
|
function isValidHashSignature(
bytes32 hash,
address signerAddress,
bytes memory signature
)
public
view
returns (bool isValid);
|
function isValidHashSignature(
bytes32 hash,
address signerAddress,
bytes memory signature
)
public
view
returns (bool isValid);
| 12,464
|
5
|
// Checks if a user has been supplying only one reserve as collateral this uses a simple trick - if a number is a power of two (only one bit set) then n & (n - 1) == 0 self The configuration objectreturn True if the user has been supplying as collateral one reserve, false otherwise /
|
) internal pure returns (bool) {
uint256 collateralData = self.data & COLLATERAL_MASK;
return
collateralData != 0 && (collateralData & (collateralData - 1) == 0);
}
|
) internal pure returns (bool) {
uint256 collateralData = self.data & COLLATERAL_MASK;
return
collateralData != 0 && (collateralData & (collateralData - 1) == 0);
}
| 32,881
|
88
|
// File: contracts/external/Require.sol/// Require dYdX Stringifies parameters to pretty-print revert messages. Costs more gas than regular require() /
|
library Require {
// ============ Constants ============
uint256 constant ASCII_ZERO = 48; // '0'
uint256 constant ASCII_RELATIVE_ZERO = 87; // 'a' - 10
uint256 constant ASCII_LOWER_EX = 120; // 'x'
bytes2 constant COLON = 0x3a20; // ': '
bytes2 constant COMMA = 0x2c20; // ', '
bytes2 constant LPAREN = 0x203c; // ' <'
byte constant RPAREN = 0x3e; // '>'
uint256 constant FOUR_BIT_MASK = 0xf;
// ============ Library Functions ============
function that(
bool must,
bytes32 file,
bytes32 reason
)
internal
pure
{
if (!must) {
revert(
string(
abi.encodePacked(
stringifyTruncated(file),
COLON,
stringifyTruncated(reason)
)
)
);
}
}
function that(
bool must,
bytes32 file,
bytes32 reason,
uint256 payloadA
)
internal
pure
{
if (!must) {
revert(
string(
abi.encodePacked(
stringifyTruncated(file),
COLON,
stringifyTruncated(reason),
LPAREN,
stringify(payloadA),
RPAREN
)
)
);
}
}
function that(
bool must,
bytes32 file,
bytes32 reason,
uint256 payloadA,
uint256 payloadB
)
internal
pure
{
if (!must) {
revert(
string(
abi.encodePacked(
stringifyTruncated(file),
COLON,
stringifyTruncated(reason),
LPAREN,
stringify(payloadA),
COMMA,
stringify(payloadB),
RPAREN
)
)
);
}
}
function that(
bool must,
bytes32 file,
bytes32 reason,
address payloadA
)
internal
pure
{
if (!must) {
revert(
string(
abi.encodePacked(
stringifyTruncated(file),
COLON,
stringifyTruncated(reason),
LPAREN,
stringify(payloadA),
RPAREN
)
)
);
}
}
function that(
bool must,
bytes32 file,
bytes32 reason,
address payloadA,
uint256 payloadB
)
internal
pure
{
if (!must) {
revert(
string(
abi.encodePacked(
stringifyTruncated(file),
COLON,
stringifyTruncated(reason),
LPAREN,
stringify(payloadA),
COMMA,
stringify(payloadB),
RPAREN
)
)
);
}
}
function that(
bool must,
bytes32 file,
bytes32 reason,
address payloadA,
uint256 payloadB,
uint256 payloadC
)
internal
pure
{
if (!must) {
revert(
string(
abi.encodePacked(
stringifyTruncated(file),
COLON,
stringifyTruncated(reason),
LPAREN,
stringify(payloadA),
COMMA,
stringify(payloadB),
COMMA,
stringify(payloadC),
RPAREN
)
)
);
}
}
function that(
bool must,
bytes32 file,
bytes32 reason,
bytes32 payloadA
)
internal
pure
{
if (!must) {
revert(
string(
abi.encodePacked(
stringifyTruncated(file),
COLON,
stringifyTruncated(reason),
LPAREN,
stringify(payloadA),
RPAREN
)
)
);
}
}
function that(
bool must,
bytes32 file,
bytes32 reason,
bytes32 payloadA,
uint256 payloadB,
uint256 payloadC
)
internal
pure
{
if (!must) {
revert(
string(
abi.encodePacked(
stringifyTruncated(file),
COLON,
stringifyTruncated(reason),
LPAREN,
stringify(payloadA),
COMMA,
stringify(payloadB),
COMMA,
stringify(payloadC),
RPAREN
)
)
);
}
}
// ============ Private Functions ============
function stringifyTruncated(
bytes32 input
)
private
pure
returns (bytes memory)
{
// put the input bytes into the result
bytes memory result = abi.encodePacked(input);
// determine the length of the input by finding the location of the last non-zero byte
for (uint256 i = 32; i > 0; ) {
// reverse-for-loops with unsigned integer
/* solium-disable-next-line security/no-modify-for-iter-var */
i--;
// find the last non-zero byte in order to determine the length
if (result[i] != 0) {
uint256 length = i + 1;
/* solium-disable-next-line security/no-inline-assembly */
assembly {
mstore(result, length) // r.length = length;
}
return result;
}
}
// all bytes are zero
return new bytes(0);
}
function stringify(
uint256 input
)
private
pure
returns (bytes memory)
{
if (input == 0) {
return "0";
}
// get the final string length
uint256 j = input;
uint256 length;
while (j != 0) {
length++;
j /= 10;
}
// allocate the string
bytes memory bstr = new bytes(length);
// populate the string starting with the least-significant character
j = input;
for (uint256 i = length; i > 0; ) {
// reverse-for-loops with unsigned integer
/* solium-disable-next-line security/no-modify-for-iter-var */
i--;
// take last decimal digit
bstr[i] = byte(uint8(ASCII_ZERO + (j % 10)));
// remove the last decimal digit
j /= 10;
}
return bstr;
}
function stringify(
address input
)
private
pure
returns (bytes memory)
{
uint256 z = uint256(input);
// addresses are "0x" followed by 20 bytes of data which take up 2 characters each
bytes memory result = new bytes(42);
// populate the result with "0x"
result[0] = byte(uint8(ASCII_ZERO));
result[1] = byte(uint8(ASCII_LOWER_EX));
// for each byte (starting from the lowest byte), populate the result with two characters
for (uint256 i = 0; i < 20; i++) {
// each byte takes two characters
uint256 shift = i * 2;
// populate the least-significant character
result[41 - shift] = char(z & FOUR_BIT_MASK);
z = z >> 4;
// populate the most-significant character
result[40 - shift] = char(z & FOUR_BIT_MASK);
z = z >> 4;
}
return result;
}
function stringify(
bytes32 input
)
private
pure
returns (bytes memory)
{
uint256 z = uint256(input);
// bytes32 are "0x" followed by 32 bytes of data which take up 2 characters each
bytes memory result = new bytes(66);
// populate the result with "0x"
result[0] = byte(uint8(ASCII_ZERO));
result[1] = byte(uint8(ASCII_LOWER_EX));
// for each byte (starting from the lowest byte), populate the result with two characters
for (uint256 i = 0; i < 32; i++) {
// each byte takes two characters
uint256 shift = i * 2;
// populate the least-significant character
result[65 - shift] = char(z & FOUR_BIT_MASK);
z = z >> 4;
// populate the most-significant character
result[64 - shift] = char(z & FOUR_BIT_MASK);
z = z >> 4;
}
return result;
}
function char(
uint256 input
)
private
pure
returns (byte)
{
// return ASCII digit (0-9)
if (input < 10) {
return byte(uint8(input + ASCII_ZERO));
}
// return ASCII letter (a-f)
return byte(uint8(input + ASCII_RELATIVE_ZERO));
}
}
|
library Require {
// ============ Constants ============
uint256 constant ASCII_ZERO = 48; // '0'
uint256 constant ASCII_RELATIVE_ZERO = 87; // 'a' - 10
uint256 constant ASCII_LOWER_EX = 120; // 'x'
bytes2 constant COLON = 0x3a20; // ': '
bytes2 constant COMMA = 0x2c20; // ', '
bytes2 constant LPAREN = 0x203c; // ' <'
byte constant RPAREN = 0x3e; // '>'
uint256 constant FOUR_BIT_MASK = 0xf;
// ============ Library Functions ============
function that(
bool must,
bytes32 file,
bytes32 reason
)
internal
pure
{
if (!must) {
revert(
string(
abi.encodePacked(
stringifyTruncated(file),
COLON,
stringifyTruncated(reason)
)
)
);
}
}
function that(
bool must,
bytes32 file,
bytes32 reason,
uint256 payloadA
)
internal
pure
{
if (!must) {
revert(
string(
abi.encodePacked(
stringifyTruncated(file),
COLON,
stringifyTruncated(reason),
LPAREN,
stringify(payloadA),
RPAREN
)
)
);
}
}
function that(
bool must,
bytes32 file,
bytes32 reason,
uint256 payloadA,
uint256 payloadB
)
internal
pure
{
if (!must) {
revert(
string(
abi.encodePacked(
stringifyTruncated(file),
COLON,
stringifyTruncated(reason),
LPAREN,
stringify(payloadA),
COMMA,
stringify(payloadB),
RPAREN
)
)
);
}
}
function that(
bool must,
bytes32 file,
bytes32 reason,
address payloadA
)
internal
pure
{
if (!must) {
revert(
string(
abi.encodePacked(
stringifyTruncated(file),
COLON,
stringifyTruncated(reason),
LPAREN,
stringify(payloadA),
RPAREN
)
)
);
}
}
function that(
bool must,
bytes32 file,
bytes32 reason,
address payloadA,
uint256 payloadB
)
internal
pure
{
if (!must) {
revert(
string(
abi.encodePacked(
stringifyTruncated(file),
COLON,
stringifyTruncated(reason),
LPAREN,
stringify(payloadA),
COMMA,
stringify(payloadB),
RPAREN
)
)
);
}
}
function that(
bool must,
bytes32 file,
bytes32 reason,
address payloadA,
uint256 payloadB,
uint256 payloadC
)
internal
pure
{
if (!must) {
revert(
string(
abi.encodePacked(
stringifyTruncated(file),
COLON,
stringifyTruncated(reason),
LPAREN,
stringify(payloadA),
COMMA,
stringify(payloadB),
COMMA,
stringify(payloadC),
RPAREN
)
)
);
}
}
function that(
bool must,
bytes32 file,
bytes32 reason,
bytes32 payloadA
)
internal
pure
{
if (!must) {
revert(
string(
abi.encodePacked(
stringifyTruncated(file),
COLON,
stringifyTruncated(reason),
LPAREN,
stringify(payloadA),
RPAREN
)
)
);
}
}
function that(
bool must,
bytes32 file,
bytes32 reason,
bytes32 payloadA,
uint256 payloadB,
uint256 payloadC
)
internal
pure
{
if (!must) {
revert(
string(
abi.encodePacked(
stringifyTruncated(file),
COLON,
stringifyTruncated(reason),
LPAREN,
stringify(payloadA),
COMMA,
stringify(payloadB),
COMMA,
stringify(payloadC),
RPAREN
)
)
);
}
}
// ============ Private Functions ============
function stringifyTruncated(
bytes32 input
)
private
pure
returns (bytes memory)
{
// put the input bytes into the result
bytes memory result = abi.encodePacked(input);
// determine the length of the input by finding the location of the last non-zero byte
for (uint256 i = 32; i > 0; ) {
// reverse-for-loops with unsigned integer
/* solium-disable-next-line security/no-modify-for-iter-var */
i--;
// find the last non-zero byte in order to determine the length
if (result[i] != 0) {
uint256 length = i + 1;
/* solium-disable-next-line security/no-inline-assembly */
assembly {
mstore(result, length) // r.length = length;
}
return result;
}
}
// all bytes are zero
return new bytes(0);
}
function stringify(
uint256 input
)
private
pure
returns (bytes memory)
{
if (input == 0) {
return "0";
}
// get the final string length
uint256 j = input;
uint256 length;
while (j != 0) {
length++;
j /= 10;
}
// allocate the string
bytes memory bstr = new bytes(length);
// populate the string starting with the least-significant character
j = input;
for (uint256 i = length; i > 0; ) {
// reverse-for-loops with unsigned integer
/* solium-disable-next-line security/no-modify-for-iter-var */
i--;
// take last decimal digit
bstr[i] = byte(uint8(ASCII_ZERO + (j % 10)));
// remove the last decimal digit
j /= 10;
}
return bstr;
}
function stringify(
address input
)
private
pure
returns (bytes memory)
{
uint256 z = uint256(input);
// addresses are "0x" followed by 20 bytes of data which take up 2 characters each
bytes memory result = new bytes(42);
// populate the result with "0x"
result[0] = byte(uint8(ASCII_ZERO));
result[1] = byte(uint8(ASCII_LOWER_EX));
// for each byte (starting from the lowest byte), populate the result with two characters
for (uint256 i = 0; i < 20; i++) {
// each byte takes two characters
uint256 shift = i * 2;
// populate the least-significant character
result[41 - shift] = char(z & FOUR_BIT_MASK);
z = z >> 4;
// populate the most-significant character
result[40 - shift] = char(z & FOUR_BIT_MASK);
z = z >> 4;
}
return result;
}
function stringify(
bytes32 input
)
private
pure
returns (bytes memory)
{
uint256 z = uint256(input);
// bytes32 are "0x" followed by 32 bytes of data which take up 2 characters each
bytes memory result = new bytes(66);
// populate the result with "0x"
result[0] = byte(uint8(ASCII_ZERO));
result[1] = byte(uint8(ASCII_LOWER_EX));
// for each byte (starting from the lowest byte), populate the result with two characters
for (uint256 i = 0; i < 32; i++) {
// each byte takes two characters
uint256 shift = i * 2;
// populate the least-significant character
result[65 - shift] = char(z & FOUR_BIT_MASK);
z = z >> 4;
// populate the most-significant character
result[64 - shift] = char(z & FOUR_BIT_MASK);
z = z >> 4;
}
return result;
}
function char(
uint256 input
)
private
pure
returns (byte)
{
// return ASCII digit (0-9)
if (input < 10) {
return byte(uint8(input + ASCII_ZERO));
}
// return ASCII letter (a-f)
return byte(uint8(input + ASCII_RELATIVE_ZERO));
}
}
| 1,684
|
0
|
// Interface of the ERC20 standard as defined in the EIP. /
|
interface IERC20withDec is IERC20 {
/**
* @dev Returns the number of decimals used for the token
*/
function decimals() external view returns (uint8);
}
|
interface IERC20withDec is IERC20 {
/**
* @dev Returns the number of decimals used for the token
*/
function decimals() external view returns (uint8);
}
| 431
|
155
|
// Core ERC1155 creator implementation /
|
abstract contract ERC1155CreatorCore is CreatorCore, IERC1155CreatorCore {
using EnumerableSet for EnumerableSet.AddressSet;
/**
* @dev See {IERC165-supportsInterface}.
*/
function supportsInterface(bytes4 interfaceId) public view virtual override(CreatorCore, IERC165) returns (bool) {
return interfaceId == type(IERC1155CreatorCore).interfaceId || super.supportsInterface(interfaceId);
}
/**
* @dev See {ICreatorCore-setApproveTransferExtension}.
*/
function setApproveTransferExtension(bool enabled) external override extensionRequired {
require(!enabled || ERC165Checker.supportsInterface(msg.sender, type(IERC1155CreatorExtensionApproveTransfer).interfaceId), "Extension must implement IERC1155CreatorExtensionApproveTransfer");
if (_extensionApproveTransfers[msg.sender] != enabled) {
_extensionApproveTransfers[msg.sender] = enabled;
emit ExtensionApproveTransferUpdated(msg.sender, enabled);
}
}
/**
* @dev Set mint permissions for an extension
*/
function _setMintPermissions(address extension, address permissions) internal {
require(_extensions.contains(extension), "Invalid extension");
require(permissions == address(0x0) || ERC165Checker.supportsInterface(permissions, type(IERC1155CreatorMintPermissions).interfaceId), "Invalid address");
if (_extensionPermissions[extension] != permissions) {
_extensionPermissions[extension] = permissions;
emit MintPermissionsUpdated(extension, permissions, msg.sender);
}
}
/**
* Check if an extension can mint
*/
function _checkMintPermissions(address[] memory to, uint256[] memory tokenIds, uint256[] memory amounts) internal {
if (_extensionPermissions[msg.sender] != address(0x0)) {
IERC1155CreatorMintPermissions(_extensionPermissions[msg.sender]).approveMint(msg.sender, to, tokenIds, amounts);
}
}
/**
* Post burn actions
*/
function _postBurn(address owner, uint256[] memory tokenIds, uint256[] memory amounts) internal virtual {
require(tokenIds.length > 0, "Invalid input");
address extension = _tokensExtension[tokenIds[0]];
for (uint i = 0; i < tokenIds.length; i++) {
require(_tokensExtension[tokenIds[i]] == extension, "Mismatched token originators");
}
// Callback to originating extension if needed
if (extension != address(this)) {
if (ERC165Checker.supportsInterface(extension, type(IERC1155CreatorExtensionBurnable).interfaceId)) {
IERC1155CreatorExtensionBurnable(extension).onBurn(owner, tokenIds, amounts);
}
}
}
/**
* Approve a transfer
*/
function _approveTransfer(address from, address to, uint256[] memory tokenIds, uint256[] memory amounts) internal {
require(tokenIds.length > 0, "Invalid input");
address extension = _tokensExtension[tokenIds[0]];
for (uint i = 0; i < tokenIds.length; i++) {
require(_tokensExtension[tokenIds[i]] == extension, "Mismatched token originators");
}
if (_extensionApproveTransfers[extension]) {
require(IERC1155CreatorExtensionApproveTransfer(extension).approveTransfer(from, to, tokenIds, amounts), "Extension approval failure");
}
}
}
|
abstract contract ERC1155CreatorCore is CreatorCore, IERC1155CreatorCore {
using EnumerableSet for EnumerableSet.AddressSet;
/**
* @dev See {IERC165-supportsInterface}.
*/
function supportsInterface(bytes4 interfaceId) public view virtual override(CreatorCore, IERC165) returns (bool) {
return interfaceId == type(IERC1155CreatorCore).interfaceId || super.supportsInterface(interfaceId);
}
/**
* @dev See {ICreatorCore-setApproveTransferExtension}.
*/
function setApproveTransferExtension(bool enabled) external override extensionRequired {
require(!enabled || ERC165Checker.supportsInterface(msg.sender, type(IERC1155CreatorExtensionApproveTransfer).interfaceId), "Extension must implement IERC1155CreatorExtensionApproveTransfer");
if (_extensionApproveTransfers[msg.sender] != enabled) {
_extensionApproveTransfers[msg.sender] = enabled;
emit ExtensionApproveTransferUpdated(msg.sender, enabled);
}
}
/**
* @dev Set mint permissions for an extension
*/
function _setMintPermissions(address extension, address permissions) internal {
require(_extensions.contains(extension), "Invalid extension");
require(permissions == address(0x0) || ERC165Checker.supportsInterface(permissions, type(IERC1155CreatorMintPermissions).interfaceId), "Invalid address");
if (_extensionPermissions[extension] != permissions) {
_extensionPermissions[extension] = permissions;
emit MintPermissionsUpdated(extension, permissions, msg.sender);
}
}
/**
* Check if an extension can mint
*/
function _checkMintPermissions(address[] memory to, uint256[] memory tokenIds, uint256[] memory amounts) internal {
if (_extensionPermissions[msg.sender] != address(0x0)) {
IERC1155CreatorMintPermissions(_extensionPermissions[msg.sender]).approveMint(msg.sender, to, tokenIds, amounts);
}
}
/**
* Post burn actions
*/
function _postBurn(address owner, uint256[] memory tokenIds, uint256[] memory amounts) internal virtual {
require(tokenIds.length > 0, "Invalid input");
address extension = _tokensExtension[tokenIds[0]];
for (uint i = 0; i < tokenIds.length; i++) {
require(_tokensExtension[tokenIds[i]] == extension, "Mismatched token originators");
}
// Callback to originating extension if needed
if (extension != address(this)) {
if (ERC165Checker.supportsInterface(extension, type(IERC1155CreatorExtensionBurnable).interfaceId)) {
IERC1155CreatorExtensionBurnable(extension).onBurn(owner, tokenIds, amounts);
}
}
}
/**
* Approve a transfer
*/
function _approveTransfer(address from, address to, uint256[] memory tokenIds, uint256[] memory amounts) internal {
require(tokenIds.length > 0, "Invalid input");
address extension = _tokensExtension[tokenIds[0]];
for (uint i = 0; i < tokenIds.length; i++) {
require(_tokensExtension[tokenIds[i]] == extension, "Mismatched token originators");
}
if (_extensionApproveTransfers[extension]) {
require(IERC1155CreatorExtensionApproveTransfer(extension).approveTransfer(from, to, tokenIds, amounts), "Extension approval failure");
}
}
}
| 73,058
|
70
|
// Returns the current implementation.
|
* NOTE: Only the admin can call this function. See {ProxyAdmin-getProxyImplementation}.
*
* TIP: To get this value clients can read directly from the storage slot shown below (specified by EIP1967) using the
* https://eth.wiki/json-rpc/API#eth_getstorageat[`eth_getStorageAt`] RPC call.
* `0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc`
*/
function implementation() external ifAdmin returns (address implementation_) {
implementation_ = _implementation();
}
|
* NOTE: Only the admin can call this function. See {ProxyAdmin-getProxyImplementation}.
*
* TIP: To get this value clients can read directly from the storage slot shown below (specified by EIP1967) using the
* https://eth.wiki/json-rpc/API#eth_getstorageat[`eth_getStorageAt`] RPC call.
* `0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc`
*/
function implementation() external ifAdmin returns (address implementation_) {
implementation_ = _implementation();
}
| 6,634
|
28
|
// Modifier to make a function callable only when the contract is not paused. /
|
modifier whenNotPaused() {
require(!paused);
_;
}
|
modifier whenNotPaused() {
require(!paused);
_;
}
| 10,208
|
33
|
// Require that the caller is the Oraclize contract.
|
require(msg.sender == oraclize_cbAddress(), "sender is not oraclize");
|
require(msg.sender == oraclize_cbAddress(), "sender is not oraclize");
| 20,850
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.