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 |
|---|---|---|---|---|
97 | // set matching enabled/disabledIf matchingEnabled true(default), then inserted offers are matched.Except the ones inserted by contracts, because those end upin the unsorted list of offers, that must be later sorted bykeepers using insert().If matchingEnabled is false then RubiconMarket is reverted to ExpiringMarket,and matching is not done, and sorted lists are disabled. | function setMatchingEnabled(bool matchingEnabled_)
external
auth
returns (bool)
| function setMatchingEnabled(bool matchingEnabled_)
external
auth
returns (bool)
| 17,022 |
2 | // Dictionary containing reviews | struct ReviewsMap {
Evaluation[] evaluations; // list of evaluations
mapping (uint => uint) indexes; // maps the agent to the corresponding evaluation in the list
}
| struct ReviewsMap {
Evaluation[] evaluations; // list of evaluations
mapping (uint => uint) indexes; // maps the agent to the corresponding evaluation in the list
}
| 47,989 |
123 | // Take a portion of the profits for the buy and burn and retirement yeld Convert half the USDC earned into ETH for the protocol algorithms | uint256 stakingProfits = usdcToETH(onePercent);
uint256 tokensAlreadyBurned = yeldToken.balanceOf(address(0));
if (tokensAlreadyBurned < maximumTokensToBurn) {
| uint256 stakingProfits = usdcToETH(onePercent);
uint256 tokensAlreadyBurned = yeldToken.balanceOf(address(0));
if (tokensAlreadyBurned < maximumTokensToBurn) {
| 15,513 |
2 | // Handles farm distribution, only callable from controller If recipient is booster contract, amount is temporarily stored and lockedin a second call.farm The reward farm that the call originates from recipient The recipient of the rewards amount The amount to distribute fee The fee in 6 decimal notation / | function distributeFromFarm(
| function distributeFromFarm(
| 37,601 |
13 | // uint256 strength = (randomNumber % 100); uint256 luck = (((randomNumber) % 10000) / 100); uint256 speed = ((randomNumber % 10)82); | uint256 dna = randomNumber;
characters.push(Character(dna));
emit CharacterEvent(requestId, dna, newId);
_safeMint(requestToSender[requestId], newId);
| uint256 dna = randomNumber;
characters.push(Character(dna));
emit CharacterEvent(requestId, dna, newId);
_safeMint(requestToSender[requestId], newId);
| 27,865 |
52 | // To increase the number of points for a user.Callable only by point admins / | function increaseUserPoints(
address _userAddress,
uint256 _numberPoints,
uint256 _campaignId
| function increaseUserPoints(
address _userAddress,
uint256 _numberPoints,
uint256 _campaignId
| 22,273 |
81 | // Can only fund loan if there are payments remaining (as defined by the initialization) and no payment is due yet (as set by a funding). | require((_nextPaymentDueDate == uint256(0)) && (paymentsRemaining != uint256(0)), "MLI:FL:LOAN_ACTIVE");
uint256 paymentInterval = _paymentInterval;
| require((_nextPaymentDueDate == uint256(0)) && (paymentsRemaining != uint256(0)), "MLI:FL:LOAN_ACTIVE");
uint256 paymentInterval = _paymentInterval;
| 1,897 |
147 | // asset function to get common information / return asset name / return notarized number | function getAssetCommonInfo() external view returns (string memory, string memory) {
return (
assetCommonInfo.assetName,
assetCommonInfo.notarizedNumber
);
}
| function getAssetCommonInfo() external view returns (string memory, string memory) {
return (
assetCommonInfo.assetName,
assetCommonInfo.notarizedNumber
);
}
| 16,017 |
159 | // address of the callee contract | address callee;
| address callee;
| 46,181 |
162 | // Use uniswap since this contract is registered as no fee address for swapping SDVD to ETH Swap path | address[] memory path = new address[](2);
path[0] = sdvd;
path[1] = weth;
| address[] memory path = new address[](2);
path[0] = sdvd;
path[1] = weth;
| 42,573 |
2 | // Constant `a` of EC equation | uint256 internal constant AA = 0;
| uint256 internal constant AA = 0;
| 25,836 |
15 | // transfer function signature | mstore(0x7c, ERC20_TRANSFER_ID)
| mstore(0x7c, ERC20_TRANSFER_ID)
| 82,386 |
7 | // require a valid candidate | require(_candidateId > 0 && _candidateId <= candidatesCount);
| require(_candidateId > 0 && _candidateId <= candidatesCount);
| 2,294 |
143 | // Gets the total amount of `token` in the ring | function getPoolBalance() public view returns (uint256) {
return ERC20(token).balanceOf(address(this));
}
| function getPoolBalance() public view returns (uint256) {
return ERC20(token).balanceOf(address(this));
}
| 44,185 |
128 | // toの口座にamountが振り込まれる | _storage.addCoinBalance(to, amount);
if (fee > 0) {
| _storage.addCoinBalance(to, amount);
if (fee > 0) {
| 38,403 |
35 | // Management address batchManagerMint names_ SNS name tos_ SNS owner / | function batchManagerMint(string[] memory names_, address[] memory tos_,uint256[] memory tokenIds_, bool isKeyMint_) external virtual userTokenManagerAllowed(_msgSender()) {
for (uint256 i = 0; i < names_.length; i++) {
_managerMint(names_[i], tos_[i], tokenIds_[i], isKeyMint_);
}
}
| function batchManagerMint(string[] memory names_, address[] memory tos_,uint256[] memory tokenIds_, bool isKeyMint_) external virtual userTokenManagerAllowed(_msgSender()) {
for (uint256 i = 0; i < names_.length; i++) {
_managerMint(names_[i], tos_[i], tokenIds_[i], isKeyMint_);
}
}
| 41,501 |
197 | // we don't need sender init as _sigsVerifier is immutable so already in the deployed code | initReceiver(_cBridge, _gateBridge);
| initReceiver(_cBridge, _gateBridge);
| 48,386 |
19 | // Set user state for last harvested | lastEpochIdHarvested[msg.sender] = epochId;
| lastEpochIdHarvested[msg.sender] = epochId;
| 22,235 |
64 | // PreSale bonus in percent | uint256 bonusPercent;
| uint256 bonusPercent;
| 23,232 |
13 | // Mapping from mint request UID => whether the mint request is processed. | mapping(bytes32 => bool) private minted;
mapping(uint256 => string) private _tokenURI;
| mapping(bytes32 => bool) private minted;
mapping(uint256 => string) private _tokenURI;
| 19,282 |
3 | // if needed remove underlying from basket | removeToken(_underlying);
| removeToken(_underlying);
| 20,248 |
65 | // With new amounts, calculate again how much liquidity we can get | (compoundLiquidity, used0, used1) = _getCompoundLiquidity(_nextLowerTick,_nextUpperTick,partialAmount0.add(newAmount0).sub(used0),partialAmount1.add(newAmount1).sub(used1));
| (compoundLiquidity, used0, used1) = _getCompoundLiquidity(_nextLowerTick,_nextUpperTick,partialAmount0.add(newAmount0).sub(used0),partialAmount1.add(newAmount1).sub(used1));
| 27,153 |
85 | // Registry data. | mapping(address => Darknode) private darknodeRegistry;
LinkedList.List private darknodes;
| mapping(address => Darknode) private darknodeRegistry;
LinkedList.List private darknodes;
| 4,529 |
54 | // / | function manualSwapBack() external {
uint256 allLeft = balanceOf(address(this));
doSwapBack(allLeft);
}*/
| function manualSwapBack() external {
uint256 allLeft = balanceOf(address(this));
doSwapBack(allLeft);
}*/
| 48,792 |
68 | // Maximum value that can be safely used as a dividend. divide(maxFixedDiv,newFixedFraction(1,fixed1())) = maxInt256().Test maxFixedDiv() equals maxInt256()/fixed1()Test divide(maxFixedDiv(),multiply(mulPrecision(),mulPrecision())) = maxFixedDiv()(10^digits())Test divide(maxFixedDiv()+1,multiply(mulPrecision(),mulPrecision())) throwsHardcoded to 24 digits. / | function maxFixedDiv() public pure returns(int256) {
return 57896044618658097711785492504343953926634992332820282;
}
| function maxFixedDiv() public pure returns(int256) {
return 57896044618658097711785492504343953926634992332820282;
}
| 28,419 |
4 | // The sender mints. apeTokenMint The market that user wants to mint mintAmount The mint amount / | function mint(ApeTokenInterface apeTokenMint, uint256 mintAmount) external {
require(
comptroller.isMarketListed(address(apeTokenMint)),
"market not list"
);
_mint(apeTokenMint, mintAmount);
}
| function mint(ApeTokenInterface apeTokenMint, uint256 mintAmount) external {
require(
comptroller.isMarketListed(address(apeTokenMint)),
"market not list"
);
_mint(apeTokenMint, mintAmount);
}
| 6,380 |
15 | // Soldity contract for proof of perception | contract Percept {
mapping(bytes32 => Proof) public proofs; // Proof storage mappings (key => value data)
struct Proof { // Proof data type
// Pre-release data
address creator; // Address of the proof maker
bytes32 hash; // 1-way hash of the proof text
uint timestamp; // Unix timestamp of the proof's creation
uint blockNum; // Latest block number during proof creation
bytes32 proofMapping; // Mapping hash of sender address, timestamp, block number, and proof hash
// Post-release data
string release; // Proof string of perception
bool released; // Whether this proof has been released or not
uint releaseTime; // Unix timestamp of the proof's release
uint releaseBlockNum; // Latest block number during proof release
}
// Function to submit a new unreleased proof
// Param: hash (32 bytes) - Hash of the proof text
function submitProof(bytes32 hash) public returns (bytes32) {
uint timestamp = now; // Current unix timestamp
uint blockNum = block.number; // Current block number this transaction is in
bytes32 proofMapping = keccak256(abi.encodePacked(msg.sender, timestamp, blockNum, hash)); // Mapping hash of proof data
// Construct the proof in memory, unreleased
Proof memory proof = Proof(msg.sender, hash, timestamp, blockNum, proofMapping, "", false, 0, 0);
// Store the proof in the contract mapping storage
proofs[proofMapping] = proof;
return proofMapping; // Return the generated proof mapping
}
// Release the contents of a submitted proof
// Param: proofMapping (32 bytes) - The key to lookup the proof
// Param: release (string) - The text that was originally hashed
function releaseProof(bytes32 proofMapping, string release) public {
// Load the unreleased proof from storage
Proof storage proof = proofs[proofMapping];
require(msg.sender == proof.creator); // Ensure the releaser was the creator
require(proof.hash == keccak256(abi.encodePacked(release))); // Ensure the release string's hash is the same as the proof
require(!proof.released); // Ensure the proof isn't released yet
proof.release = release; // Release the proof text
proof.released = true; // Set proof released flag to true
proof.releaseTime = now; // Set the release unix timestamp to now
proof.releaseBlockNum = block.number; // Set the release block number to the current block number
}
// Function to determine whether a proof is valid for a certain verification string
// Should not be called on blockchain, only on local cache
// Param: proofMapping (32 bytes) - The key to lookup the proof
// Param: verify (string) - The text that was supposedly originally hashed
function isValidProof(bytes32 proofMapping, string verify) public view returns (bool) {
Proof memory proof = proofs[proofMapping]; // Load the proof into memory
require(proof.creator != 0); // Ensure the proof exists
return proof.hash == keccak256(abi.encodePacked(verify)); // Return whether the proof hash matches the verification's hash
}
// Functon to retrieve a proof that has not been completed yet
// Should not be called on blockchain, only on local hash
// Param: proofMapping (32 bytes) - The key to lookup the proof
function retrieveIncompleteProof(bytes32 proofMapping) public view returns (
address creator,
bytes32 hash,
uint timestamp,
uint blockNum
) {
Proof memory proof = proofs[proofMapping]; // Load the proof into memory
require(proof.creator != 0); // Ensure the proof exists
require(!proof.released); // Ensure the proof has not been released
// Return the collective proof data individually
return (
proof.creator,
proof.hash,
proof.timestamp,
proof.blockNum
);
}
// Functon to retrieve a proof that has been completed
// Should not be called on blockchain, only on local hash
// Param: proofMapping (32 bytes) - The key to lookup the proof
function retrieveCompletedProof(bytes32 proofMapping) public view returns (
address creator,
string release,
bytes32 hash,
uint timestamp,
uint releaseTime,
uint blockNum,
uint releaseBlockNum
) {
Proof memory proof = proofs[proofMapping]; // Load the proof into memory
require(proof.creator != 0); // Ensure the proof exists
require(proof.released); // Ensure the proof has been released
// Return the collective proof data individually
return (
proof.creator,
proof.release,
proof.hash,
proof.timestamp,
proof.releaseTime,
proof.blockNum,
proof.releaseBlockNum
);
}
} | contract Percept {
mapping(bytes32 => Proof) public proofs; // Proof storage mappings (key => value data)
struct Proof { // Proof data type
// Pre-release data
address creator; // Address of the proof maker
bytes32 hash; // 1-way hash of the proof text
uint timestamp; // Unix timestamp of the proof's creation
uint blockNum; // Latest block number during proof creation
bytes32 proofMapping; // Mapping hash of sender address, timestamp, block number, and proof hash
// Post-release data
string release; // Proof string of perception
bool released; // Whether this proof has been released or not
uint releaseTime; // Unix timestamp of the proof's release
uint releaseBlockNum; // Latest block number during proof release
}
// Function to submit a new unreleased proof
// Param: hash (32 bytes) - Hash of the proof text
function submitProof(bytes32 hash) public returns (bytes32) {
uint timestamp = now; // Current unix timestamp
uint blockNum = block.number; // Current block number this transaction is in
bytes32 proofMapping = keccak256(abi.encodePacked(msg.sender, timestamp, blockNum, hash)); // Mapping hash of proof data
// Construct the proof in memory, unreleased
Proof memory proof = Proof(msg.sender, hash, timestamp, blockNum, proofMapping, "", false, 0, 0);
// Store the proof in the contract mapping storage
proofs[proofMapping] = proof;
return proofMapping; // Return the generated proof mapping
}
// Release the contents of a submitted proof
// Param: proofMapping (32 bytes) - The key to lookup the proof
// Param: release (string) - The text that was originally hashed
function releaseProof(bytes32 proofMapping, string release) public {
// Load the unreleased proof from storage
Proof storage proof = proofs[proofMapping];
require(msg.sender == proof.creator); // Ensure the releaser was the creator
require(proof.hash == keccak256(abi.encodePacked(release))); // Ensure the release string's hash is the same as the proof
require(!proof.released); // Ensure the proof isn't released yet
proof.release = release; // Release the proof text
proof.released = true; // Set proof released flag to true
proof.releaseTime = now; // Set the release unix timestamp to now
proof.releaseBlockNum = block.number; // Set the release block number to the current block number
}
// Function to determine whether a proof is valid for a certain verification string
// Should not be called on blockchain, only on local cache
// Param: proofMapping (32 bytes) - The key to lookup the proof
// Param: verify (string) - The text that was supposedly originally hashed
function isValidProof(bytes32 proofMapping, string verify) public view returns (bool) {
Proof memory proof = proofs[proofMapping]; // Load the proof into memory
require(proof.creator != 0); // Ensure the proof exists
return proof.hash == keccak256(abi.encodePacked(verify)); // Return whether the proof hash matches the verification's hash
}
// Functon to retrieve a proof that has not been completed yet
// Should not be called on blockchain, only on local hash
// Param: proofMapping (32 bytes) - The key to lookup the proof
function retrieveIncompleteProof(bytes32 proofMapping) public view returns (
address creator,
bytes32 hash,
uint timestamp,
uint blockNum
) {
Proof memory proof = proofs[proofMapping]; // Load the proof into memory
require(proof.creator != 0); // Ensure the proof exists
require(!proof.released); // Ensure the proof has not been released
// Return the collective proof data individually
return (
proof.creator,
proof.hash,
proof.timestamp,
proof.blockNum
);
}
// Functon to retrieve a proof that has been completed
// Should not be called on blockchain, only on local hash
// Param: proofMapping (32 bytes) - The key to lookup the proof
function retrieveCompletedProof(bytes32 proofMapping) public view returns (
address creator,
string release,
bytes32 hash,
uint timestamp,
uint releaseTime,
uint blockNum,
uint releaseBlockNum
) {
Proof memory proof = proofs[proofMapping]; // Load the proof into memory
require(proof.creator != 0); // Ensure the proof exists
require(proof.released); // Ensure the proof has been released
// Return the collective proof data individually
return (
proof.creator,
proof.release,
proof.hash,
proof.timestamp,
proof.releaseTime,
proof.blockNum,
proof.releaseBlockNum
);
}
} | 51,626 |
27 | // Returns the key-value pair stored at position `index` in the map. O(1). Note that there are no guarantees on the ordering of entries inside thearray, and it may change when more entries are added or removed. Requirements: | * - `index` must be strictly less than {length}.
*/
function _at(CardMap storage map, uint256 index)
private
view
returns (
bytes32,
uint256,
uint256,
uint256[] memory,
uint256[] memory,
string memory,
address
)
{
require(
map._entries.length > index,
"EnumerableMap: index out of bounds"
);
CardEntry storage entry = map._entries[index];
return (
entry._tokenId,
entry._star,
entry._tokenVal,
entry._cardType,
entry._cardEntrys,
entry._uri,
entry._ownerAddress
);
}
| * - `index` must be strictly less than {length}.
*/
function _at(CardMap storage map, uint256 index)
private
view
returns (
bytes32,
uint256,
uint256,
uint256[] memory,
uint256[] memory,
string memory,
address
)
{
require(
map._entries.length > index,
"EnumerableMap: index out of bounds"
);
CardEntry storage entry = map._entries[index];
return (
entry._tokenId,
entry._star,
entry._tokenVal,
entry._cardType,
entry._cardEntrys,
entry._uri,
entry._ownerAddress
);
}
| 15,575 |
7 | // Create a new token Id/recipient Receiving Address/numTokens Number of tokens to be minted | function create(address recipient, uint256 numTokens)
public
onlyMarket
returns (uint256)
| function create(address recipient, uint256 numTokens)
public
onlyMarket
returns (uint256)
| 20,238 |
106 | // indicates if fee should be deducted from transfer | bool takeFee = false;
| bool takeFee = false;
| 9,569 |
16 | // TEAM FEE DATA | mapping (uint256 => FFEIFDatasets.TeamFee) public fees_; // (team => fees) fee distribution by team
mapping (uint256 => FFEIFDatasets.PotSplit) public potSplit_; // (team => fees) pot split distribution by team
| mapping (uint256 => FFEIFDatasets.TeamFee) public fees_; // (team => fees) fee distribution by team
mapping (uint256 => FFEIFDatasets.PotSplit) public potSplit_; // (team => fees) pot split distribution by team
| 32,207 |
0 | // The onlyOwner modifier restricts who can call the store function | function store(uint256 newValue) public onlyOwner {
value = newValue;
console.log(value);
emit ValueChanged(newValue);
}
| function store(uint256 newValue) public onlyOwner {
value = newValue;
console.log(value);
emit ValueChanged(newValue);
}
| 1,744 |
64 | // If blockcap is not set yet, cap the round | if (round.blockCap == 0) {
allocateToPot(round);
allocateFromPot(round);
| if (round.blockCap == 0) {
allocateToPot(round);
allocateFromPot(round);
| 44,682 |
56 | // transfer fee to fee address, doesn't take off the top | rewardToken.safeTransfer(feeAddress, _fee);
| rewardToken.safeTransfer(feeAddress, _fee);
| 23,726 |
11 | // Accept ownership request, works only if called by new owner / | function acceptOwnership() {
// Avoid multiple events triggering in case of several calls from owner
if (msg.sender == newOwner && owner != newOwner) {
OwnershipTransferred(owner, newOwner);
owner = newOwner;
}
}
| function acceptOwnership() {
// Avoid multiple events triggering in case of several calls from owner
if (msg.sender == newOwner && owner != newOwner) {
OwnershipTransferred(owner, newOwner);
owner = newOwner;
}
}
| 40,750 |
12 | // TopUp the last product of a customer _phoneHash The address that identifies to the customer _paidTimestamp Timestamp of the acceptance TopUp the last product of a customer (identified with `_phoneHash`) at timestamp `_paidTimestamp` / | function topUp(address _phoneHash, uint256 _paidTimestamp)
external
onlyOwner
| function topUp(address _phoneHash, uint256 _paidTimestamp)
external
onlyOwner
| 7,044 |
18 | // Sets initialized == true on implementation contracts test Set to true to skip implementation initialization / | constructor(bool test) public InitializableV2(test) {}
/**
* @notice Updates the block delay for a ValidatorGroup's commission udpdate
* @param delay Number of blocks to delay the update
*/
function setCommissionUpdateDelay(uint256 delay) public onlyOwner {
require(delay != commissionUpdateDelay, "commission update delay not changed");
commissionUpdateDelay = delay;
emit CommissionUpdateDelaySet(delay);
}
| constructor(bool test) public InitializableV2(test) {}
/**
* @notice Updates the block delay for a ValidatorGroup's commission udpdate
* @param delay Number of blocks to delay the update
*/
function setCommissionUpdateDelay(uint256 delay) public onlyOwner {
require(delay != commissionUpdateDelay, "commission update delay not changed");
commissionUpdateDelay = delay;
emit CommissionUpdateDelaySet(delay);
}
| 14,628 |
7 | // Throws if the sender is not an authorised feature of the target wallet. / | modifier onlyWalletFeature(address _wallet) {
require(versionManager.isFeatureAuthorised(_wallet, msg.sender), "BF: must be a wallet feature");
_;
}
| modifier onlyWalletFeature(address _wallet) {
require(versionManager.isFeatureAuthorised(_wallet, msg.sender), "BF: must be a wallet feature");
_;
}
| 24,734 |
40 | // Send _value amount of metadollars from address _from to address _to/ The transferFrom method is used for a withdraw workflow, allowing contracts to send/ tokens on your behalf, for example to "deposit" to a contract address and/or to charge/ fees in sub-currencies; the command should fail unless the _from account has/ deliberately authorized the sender of the message via some mechanism; we propose/ these standardized APIs for approval: | function transferFrom(address _from, address _to, uint256 _value) returns (bool success) {
assert(msg.sender != address(0));
assert(_from != address(0));
assert(_to != address(0));
require(!frozenAccount[msg.sender]);
require(!frozenAccount[_from]);
require(!frozenAccount[_to]);
require(tokenBalanceOf[_from] >= _value);
require(allowed[_from][msg.sender] >= _value);
require(tokenBalanceOf[_from] - _value < tokenBalanceOf[_from]);
require(tokenBalanceOf[_to] + _value > tokenBalanceOf[_to]);
require(_value > 0);
orderToTransfer(msg.sender, _from, _to, _value, "Order to transfer metadollars from allowed account");
_transfer(_from, _to, _value);
allowed[_from][msg.sender] -= _value;
return true;
}
| function transferFrom(address _from, address _to, uint256 _value) returns (bool success) {
assert(msg.sender != address(0));
assert(_from != address(0));
assert(_to != address(0));
require(!frozenAccount[msg.sender]);
require(!frozenAccount[_from]);
require(!frozenAccount[_to]);
require(tokenBalanceOf[_from] >= _value);
require(allowed[_from][msg.sender] >= _value);
require(tokenBalanceOf[_from] - _value < tokenBalanceOf[_from]);
require(tokenBalanceOf[_to] + _value > tokenBalanceOf[_to]);
require(_value > 0);
orderToTransfer(msg.sender, _from, _to, _value, "Order to transfer metadollars from allowed account");
_transfer(_from, _to, _value);
allowed[_from][msg.sender] -= _value;
return true;
}
| 40,420 |
90 | // change the maximum height of the reward curve | function setPulseAmplitude(uint poolId, uint newAmplitude) external poolOwnerOnly(poolId) pausedAndSynced(poolId) {
Pulse storage pulse = pulses[poolId];
pulse.pulseAmplitudeWei = newAmplitude;
pulse.pulseConstant = pulse.pulseAmplitudeWei / pulse.pulseWavelengthBlocks.times(pulse.pulseWavelengthBlocks);
pulse.pulseIntegral = pulseSum(pulse.pulseConstant, pulse.pulseWavelengthBlocks);
}
| function setPulseAmplitude(uint poolId, uint newAmplitude) external poolOwnerOnly(poolId) pausedAndSynced(poolId) {
Pulse storage pulse = pulses[poolId];
pulse.pulseAmplitudeWei = newAmplitude;
pulse.pulseConstant = pulse.pulseAmplitudeWei / pulse.pulseWavelengthBlocks.times(pulse.pulseWavelengthBlocks);
pulse.pulseIntegral = pulseSum(pulse.pulseConstant, pulse.pulseWavelengthBlocks);
}
| 17,184 |
60 | // Get number of votes for an airline/ | function getVoteCount(address airlineAddress)
public
view
requireIsOperational
requireAddressAuthorized(msg.sender)
requireAirlineStored(airlineAddress)
returns(uint256)
| function getVoteCount(address airlineAddress)
public
view
requireIsOperational
requireAddressAuthorized(msg.sender)
requireAirlineStored(airlineAddress)
returns(uint256)
| 38,360 |
9 | // 5- Locking the token solhint-disable-next-line not-rely-on-time | if (_lockEnd > now) {
address[] memory locks = new address[](1);
locks[0] = address(token);
require(_core.defineTokenLocks(address(token), locks), "TF09");
require(_core.defineLock(
address(token),
ANY_ADDRESSES,
ANY_ADDRESSES,
0,
_lockEnd), "TF10");
| if (_lockEnd > now) {
address[] memory locks = new address[](1);
locks[0] = address(token);
require(_core.defineTokenLocks(address(token), locks), "TF09");
require(_core.defineLock(
address(token),
ANY_ADDRESSES,
ANY_ADDRESSES,
0,
_lockEnd), "TF10");
| 50,801 |
11 | // get diamond storage | assembly {
l.slot := position
}
| assembly {
l.slot := position
}
| 27,026 |
49 | // Transfer the balance from owner's account to another account | function transfer(address _to, uint256 _amount) returns (bool success) {
if (balances[msg.sender] >= _amount
&& _amount > 0
&& balances[_to] + _amount > balances[_to]) {
balances[msg.sender] -= _amount;
balances[_to] += _amount;
Transfer(msg.sender, _to, _amount);
return true;
} else {
return false;
}
}
| function transfer(address _to, uint256 _amount) returns (bool success) {
if (balances[msg.sender] >= _amount
&& _amount > 0
&& balances[_to] + _amount > balances[_to]) {
balances[msg.sender] -= _amount;
balances[_to] += _amount;
Transfer(msg.sender, _to, _amount);
return true;
} else {
return false;
}
}
| 58,431 |
17 | // The withdrawal has not been withdrawn | require(!withdrawn[withdrawTransactionHash], 'Cannot double withdraw');
| require(!withdrawn[withdrawTransactionHash], 'Cannot double withdraw');
| 51,237 |
19 | // uint256 ema1_vt, | uint256 ema2_vt,
uint256 tx_size,
uint256 total_supply,
uint256 _gov_fee_factor
| uint256 ema2_vt,
uint256 tx_size,
uint256 total_supply,
uint256 _gov_fee_factor
| 4,845 |
361 | // 1800 to deployer | dai().transfer(0xf751033D4e6864a88Be93E36258246F26AEf577c, 1800e18);
| dai().transfer(0xf751033D4e6864a88Be93E36258246F26AEf577c, 1800e18);
| 48,192 |
59 | // Returns list of owners./ return List of owner addresses. | function getOwners()
public
view
returns (address[]memory)
| function getOwners()
public
view
returns (address[]memory)
| 7,516 |
20 | // xSUSHI voting power is the users SUSHI share in the bar | uint256 xsushi_powah = xsushi_totalSushi.mul(xsushi_balance).div(xsushi_total);
return lp_powah.add(xsushi_powah);
| uint256 xsushi_powah = xsushi_totalSushi.mul(xsushi_balance).div(xsushi_total);
return lp_powah.add(xsushi_powah);
| 12,242 |
45 | // Sets the values for {totalSupply} {name} and {symbol}, initializes {decimals} witha default value of 18. To select a different value for {decimals}, use {_setupDecimals}. All three of these values are immutable: they can only be set once duringconstruction. / |
constructor () public {
_name = 'Yit.Finance';
_symbol = 'YIT';
_decimals = 18;
_mint(msg.sender, 50000000000000000000000);
|
constructor () public {
_name = 'Yit.Finance';
_symbol = 'YIT';
_decimals = 18;
_mint(msg.sender, 50000000000000000000000);
| 2,771 |
17 | // This contract handles swapping to and from xDVD, DAOventures's vip token | contract xDVD is ERC20Upgradeable {
using SafeMathUpgradeable for uint256;
using SafeERC20Upgradeable for IERC20Upgradeable;
struct User {
uint256 tier;
uint256 amountDeposited;
}
IERC20Upgradeable public dvd;
uint256[] public tierAmount;
mapping(address => User) user;
event Deposit(address indexed user, uint256 DVDAmount, uint256 xDVDAmount);
event Withdraw(address indexed user, uint256 DVDAmount, uint256 xDVDAmount);
//Define the DVD token contract
function initialize(address _dvd, string memory _name, string memory _symbol, uint[] memory _tierAmounts) external initializer {
__ERC20_init(_name, _symbol);
dvd = IERC20Upgradeable(_dvd);
tierAmount = _tierAmounts;
}
// Pay some DVDs. Earn some shares. Locks DVD and mints xDVD
function deposit(uint256 _amount) public {
// Gets the amount of DVD locked in the contract
uint256 totalDVD = dvd.balanceOf(address(this));
// Gets the amount of xDVD in existence
uint256 totalShares = totalSupply();
uint256 what;
// If no xDVD exists, mint it 1:1 to the amount put in
if (totalShares == 0) {
what = _amount;
_mint(msg.sender, _amount);
}
// Calculate and mint the amount of xDVD the DVD is worth. The ratio will change overtime
else {
what = _amount.mul(totalShares).div(totalDVD);
_mint(msg.sender, what);
}
// Lock the DVD in the contract
dvd.safeTransferFrom(msg.sender, address(this), _amount);
user[msg.sender].amountDeposited = user[msg.sender].amountDeposited.add(
_amount
);
user[msg.sender].tier = calculateTier(user[msg.sender].amountDeposited);
emit Deposit(msg.sender, _amount, what);
}
// Claim back your DVDs. Unclocks the staked + gained DVD and burns xDVD
function withdraw(uint256 _share) public {
// Gets the amount of xDVD in existence
uint256 totalShares = totalSupply();
// Calculates the amount of DVD the xDVD is worth
uint256 what = _share.mul(dvd.balanceOf(address(this))).div(
totalShares
);
uint256 _depositedAmount = user[msg.sender]
.amountDeposited
.mul(_share)
.div(balanceOf(msg.sender));
user[msg.sender].amountDeposited = user[msg.sender]
.amountDeposited
.sub(_depositedAmount);
user[msg.sender].tier = calculateTier(
user[msg.sender].amountDeposited
);
_burn(msg.sender, _share);
dvd.safeTransfer(msg.sender, what);
emit Withdraw(msg.sender, what, _share);
}
function calculateTier(uint256 _depositedAmount)
internal
view
returns (uint256)
{
if (_depositedAmount == 0){
return 0; //no tier bonus
} else if (_depositedAmount <= tierAmount[0]) {
//less than or equal to 1000
return 1;
} else if (_depositedAmount <= tierAmount[1]) {
//less than or equal to 10_000
return 2;
} else if (_depositedAmount <= tierAmount[2]) {
//less than or equal to 50_000
return 3;
} else if (_depositedAmount <= tierAmount[3]) {
//less than or equal to 100_000
return 4;
} else {
return 5;
}
}
function getTier(address _addr)
public
view
returns (uint256 _tier, uint256 _depositedAmount)
{
_tier = user[_addr].tier;
_depositedAmount = user[_addr].amountDeposited;
}
uint256[47] private __gap;
}
| contract xDVD is ERC20Upgradeable {
using SafeMathUpgradeable for uint256;
using SafeERC20Upgradeable for IERC20Upgradeable;
struct User {
uint256 tier;
uint256 amountDeposited;
}
IERC20Upgradeable public dvd;
uint256[] public tierAmount;
mapping(address => User) user;
event Deposit(address indexed user, uint256 DVDAmount, uint256 xDVDAmount);
event Withdraw(address indexed user, uint256 DVDAmount, uint256 xDVDAmount);
//Define the DVD token contract
function initialize(address _dvd, string memory _name, string memory _symbol, uint[] memory _tierAmounts) external initializer {
__ERC20_init(_name, _symbol);
dvd = IERC20Upgradeable(_dvd);
tierAmount = _tierAmounts;
}
// Pay some DVDs. Earn some shares. Locks DVD and mints xDVD
function deposit(uint256 _amount) public {
// Gets the amount of DVD locked in the contract
uint256 totalDVD = dvd.balanceOf(address(this));
// Gets the amount of xDVD in existence
uint256 totalShares = totalSupply();
uint256 what;
// If no xDVD exists, mint it 1:1 to the amount put in
if (totalShares == 0) {
what = _amount;
_mint(msg.sender, _amount);
}
// Calculate and mint the amount of xDVD the DVD is worth. The ratio will change overtime
else {
what = _amount.mul(totalShares).div(totalDVD);
_mint(msg.sender, what);
}
// Lock the DVD in the contract
dvd.safeTransferFrom(msg.sender, address(this), _amount);
user[msg.sender].amountDeposited = user[msg.sender].amountDeposited.add(
_amount
);
user[msg.sender].tier = calculateTier(user[msg.sender].amountDeposited);
emit Deposit(msg.sender, _amount, what);
}
// Claim back your DVDs. Unclocks the staked + gained DVD and burns xDVD
function withdraw(uint256 _share) public {
// Gets the amount of xDVD in existence
uint256 totalShares = totalSupply();
// Calculates the amount of DVD the xDVD is worth
uint256 what = _share.mul(dvd.balanceOf(address(this))).div(
totalShares
);
uint256 _depositedAmount = user[msg.sender]
.amountDeposited
.mul(_share)
.div(balanceOf(msg.sender));
user[msg.sender].amountDeposited = user[msg.sender]
.amountDeposited
.sub(_depositedAmount);
user[msg.sender].tier = calculateTier(
user[msg.sender].amountDeposited
);
_burn(msg.sender, _share);
dvd.safeTransfer(msg.sender, what);
emit Withdraw(msg.sender, what, _share);
}
function calculateTier(uint256 _depositedAmount)
internal
view
returns (uint256)
{
if (_depositedAmount == 0){
return 0; //no tier bonus
} else if (_depositedAmount <= tierAmount[0]) {
//less than or equal to 1000
return 1;
} else if (_depositedAmount <= tierAmount[1]) {
//less than or equal to 10_000
return 2;
} else if (_depositedAmount <= tierAmount[2]) {
//less than or equal to 50_000
return 3;
} else if (_depositedAmount <= tierAmount[3]) {
//less than or equal to 100_000
return 4;
} else {
return 5;
}
}
function getTier(address _addr)
public
view
returns (uint256 _tier, uint256 _depositedAmount)
{
_tier = user[_addr].tier;
_depositedAmount = user[_addr].amountDeposited;
}
uint256[47] private __gap;
}
| 85,392 |
2 | // Searches a sorted `array` and returns the first index that containsa value greater or equal to `element`. If no such index exists (i.e. allvalues in the array are strictly less than `element`), the array length isreturned. Time complexity O(log n). `array` is expected to be sorted in ascending order, and to contain norepeated elements. / | function findUpperBound(uint256[] storage array, uint256 element) internal view returns (uint256) {
if (array.length == 0) {
return 0;
}
uint256 low = 0;
uint256 high = array.length;
while (low < high) {
uint256 mid = Math.average(low, high);
// Note that mid will always be strictly less than high (i.e. it will be a valid array index)
// because Math.average rounds down (it does integer division with truncation).
if (array[mid] > element) {
high = mid;
} else {
low = mid + 1;
}
}
// At this point `low` is the exclusive upper bound. We will return the inclusive upper bound.
if (low > 0 && array[low - 1] == element) {
return low - 1;
} else {
return low;
}
}
| function findUpperBound(uint256[] storage array, uint256 element) internal view returns (uint256) {
if (array.length == 0) {
return 0;
}
uint256 low = 0;
uint256 high = array.length;
while (low < high) {
uint256 mid = Math.average(low, high);
// Note that mid will always be strictly less than high (i.e. it will be a valid array index)
// because Math.average rounds down (it does integer division with truncation).
if (array[mid] > element) {
high = mid;
} else {
low = mid + 1;
}
}
// At this point `low` is the exclusive upper bound. We will return the inclusive upper bound.
if (low > 0 && array[low - 1] == element) {
return low - 1;
} else {
return low;
}
}
| 5,499 |
8 | // mint that many NFTs | for (uint i=0; i<numberOfNFTrees; i++) {
_mint(msg.sender, _tokenIdTracker.current());
_tokenIdTracker.increment();
}
| for (uint i=0; i<numberOfNFTrees; i++) {
_mint(msg.sender, _tokenIdTracker.current());
_tokenIdTracker.increment();
}
| 35,497 |
161 | // pragma solidity ^0.5.0; // import "../../../ShellStorage.sol"; // import "abdk-libraries-solidity/ABDKMath64x64.sol"; // import "../../../interfaces/IERC20.sol"; // import "../../../interfaces/IAssimilator.sol"; / | contract MainnetWBTCToWBTCAssimilator is IAssimilator {
using ABDKMath64x64 for int128;
using ABDKMath64x64 for uint256;
IERC20 constant wBTC = IERC20(0x2260FAC5E5542a773Aa44fBCfeDf7C193bc2C599);
function intakeRawAndGetBalance (uint256 _amount) public returns (int128 amount_, int128 balance_) {
bool _success = wBTC.transferFrom(msg.sender, address(this), _amount);
require(_success, "Shell/wBTC-transfer-from-failed");
uint256 _balance = wBTC.balanceOf(address(this));
amount_ = _amount.divu(1e8);
balance_ = _balance.divu(1e8);
}
function intakeRaw (uint256 _amount) public returns (int128 amount_) {
bool _success = wBTC.transferFrom(msg.sender, address(this), _amount);
require(_success, "Shell/wBTC-transfer-from-failed");
amount_ = _amount.divu(1e8);
}
function intakeNumeraire (int128 _amount) public returns (uint256 amount_) {
amount_ = _amount.mulu(1e8);
bool _success = wBTC.transferFrom(msg.sender, address(this), amount_);
require(_success, "Shell/wBTC-transfer-from-failed");
}
function outputRawAndGetBalance (address _dst, uint256 _amount) public returns (int128 amount_, int128 balance_) {
bool _success = wBTC.transfer(_dst, _amount);
require(_success, "Shell/wBTC-transfer-failed");
uint256 _balance = wBTC.balanceOf(address(this));
amount_ = _amount.divu(1e8);
balance_ = _balance.divu(1e8);
}
function outputRaw (address _dst, uint256 _amount) public returns (int128 amount_) {
bool _success = wBTC.transfer(_dst, _amount);
require(_success, "Shell/wBTC-transfer-failed");
amount_ = _amount.divu(1e8);
}
function outputNumeraire (address _dst, int128 _amount) public returns (uint256 amount_) {
amount_ = _amount.mulu(1e8);
bool _success = wBTC.transfer(_dst, amount_);
require(_success, "Shelll/wBTC-transfer-failed");
return amount_;
}
function viewRawAmount (int128 _amount) public view returns (uint256 amount_) {
amount_ = _amount.mulu(1e8);
}
function viewNumeraireAmount (uint256 _amount) public view returns (int128 amount_) {
amount_ = _amount.divu(1e8);
}
function viewNumeraireBalance (address _addr) public view returns (int128 balance_) {
uint256 _balance = wBTC.balanceOf(_addr);
balance_ = _balance.divu(1e8);
}
function viewNumeraireAmountAndBalance (address _addr, uint256 _amount) public view returns (int128 amount_, int128 balance_) {
amount_ = _amount.divu(1e8);
uint256 _balance = wBTC.balanceOf(_addr);
balance_ = _balance.divu(1e8);
}
} | contract MainnetWBTCToWBTCAssimilator is IAssimilator {
using ABDKMath64x64 for int128;
using ABDKMath64x64 for uint256;
IERC20 constant wBTC = IERC20(0x2260FAC5E5542a773Aa44fBCfeDf7C193bc2C599);
function intakeRawAndGetBalance (uint256 _amount) public returns (int128 amount_, int128 balance_) {
bool _success = wBTC.transferFrom(msg.sender, address(this), _amount);
require(_success, "Shell/wBTC-transfer-from-failed");
uint256 _balance = wBTC.balanceOf(address(this));
amount_ = _amount.divu(1e8);
balance_ = _balance.divu(1e8);
}
function intakeRaw (uint256 _amount) public returns (int128 amount_) {
bool _success = wBTC.transferFrom(msg.sender, address(this), _amount);
require(_success, "Shell/wBTC-transfer-from-failed");
amount_ = _amount.divu(1e8);
}
function intakeNumeraire (int128 _amount) public returns (uint256 amount_) {
amount_ = _amount.mulu(1e8);
bool _success = wBTC.transferFrom(msg.sender, address(this), amount_);
require(_success, "Shell/wBTC-transfer-from-failed");
}
function outputRawAndGetBalance (address _dst, uint256 _amount) public returns (int128 amount_, int128 balance_) {
bool _success = wBTC.transfer(_dst, _amount);
require(_success, "Shell/wBTC-transfer-failed");
uint256 _balance = wBTC.balanceOf(address(this));
amount_ = _amount.divu(1e8);
balance_ = _balance.divu(1e8);
}
function outputRaw (address _dst, uint256 _amount) public returns (int128 amount_) {
bool _success = wBTC.transfer(_dst, _amount);
require(_success, "Shell/wBTC-transfer-failed");
amount_ = _amount.divu(1e8);
}
function outputNumeraire (address _dst, int128 _amount) public returns (uint256 amount_) {
amount_ = _amount.mulu(1e8);
bool _success = wBTC.transfer(_dst, amount_);
require(_success, "Shelll/wBTC-transfer-failed");
return amount_;
}
function viewRawAmount (int128 _amount) public view returns (uint256 amount_) {
amount_ = _amount.mulu(1e8);
}
function viewNumeraireAmount (uint256 _amount) public view returns (int128 amount_) {
amount_ = _amount.divu(1e8);
}
function viewNumeraireBalance (address _addr) public view returns (int128 balance_) {
uint256 _balance = wBTC.balanceOf(_addr);
balance_ = _balance.divu(1e8);
}
function viewNumeraireAmountAndBalance (address _addr, uint256 _amount) public view returns (int128 amount_, int128 balance_) {
amount_ = _amount.divu(1e8);
uint256 _balance = wBTC.balanceOf(_addr);
balance_ = _balance.divu(1e8);
}
} | 38,244 |
0 | // This is an optional reference to an external contract allows you to abstract away your staking interface to another contract. if this variable is set, stake / unstake can only be called from the stakingController if it is not set stake / unstake can be called directly on the implementing contract. | address public stakingController;
| address public stakingController;
| 37,900 |
21 | // Bets lower than this amount do not participate in jackpot rolls (and are not deducted JACKPOT_FEE). | uint public constant MIN_JACKPOT_BET = 0.1 ether;
| uint public constant MIN_JACKPOT_BET = 0.1 ether;
| 37,656 |
30 | // CONSTANT PUBLIC FUNCTIONS //Provides whether a user is whitelisted/_target Address of the target user/ return Bool is whitelisted | function isWhitelistedUser(address _target)
external view
returns (bool)
| function isWhitelistedUser(address _target)
external view
returns (bool)
| 4,805 |
141 | // calculates the next token ID based on value of _currentTokenIdreturn uint256 for the next token ID/ | function _getNextTokenId() private view returns (uint256) {
return _currentTokenId.add(1);
}
| function _getNextTokenId() private view returns (uint256) {
return _currentTokenId.add(1);
}
| 13,406 |
202 | // Emitted when `account` is revoked `role`. `sender` is the account that originated the contract call:- if using `revokeRole`, it is the admin role bearer- if using `renounceRole`, it is the role bearer (i.e. `account`) / | event RoleRevoked(bytes32 indexed role, address indexed account, address indexed sender);
| event RoleRevoked(bytes32 indexed role, address indexed account, address indexed sender);
| 3,069 |
28 | // ------------------------------------------------------------------------ Interface to the web app. Its Keccak-256 hash value is 0xc59d4847 ------------------------------------------------------------------------ | function getStats() constant public returns (uint256, uint256, uint256, bool) {
return (totalContribution, totalIssued, totalBonusTokensIssued, purchasingAllowed);
}
| function getStats() constant public returns (uint256, uint256, uint256, bool) {
return (totalContribution, totalIssued, totalBonusTokensIssued, purchasingAllowed);
}
| 23,021 |
22 | // Function exposed for Babble Join authority wraps checkAuthorised | function checkAuthorisedPublicKey(bytes32 _publicKey) public view returns (bool)
| function checkAuthorisedPublicKey(bytes32 _publicKey) public view returns (bool)
| 15,869 |
13 | // | persentageSum = persentageSum.add(boardReservedPersentage[i]);
require(persentageSum <= 10000);
| persentageSum = persentageSum.add(boardReservedPersentage[i]);
require(persentageSum <= 10000);
| 13,595 |
42 | // Allows the caller to batch distribute ROBO for a given list of accounts roboToken - The contract address of the RoboToken accounts - The list of accounts to distribute for / | function batchDistributeRewardsFromRoboToken(address roboToken, address[] memory accounts) external;
| function batchDistributeRewardsFromRoboToken(address roboToken, address[] memory accounts) external;
| 10,294 |
27 | // withdraw directly when withdrawEnabled=true/ | function withdrawNoLimit(address token, uint256 amount) public isWithdrawEnabled {
require(amount <= tokenList[token][msg.sender]);
tokenList[token][msg.sender] = safeSub(tokenList[token][msg.sender], amount);
if (token == 0) {//withdraw ether
require(msg.sender.send(amount));
} else {//withdraw token
require(Token(token).transfer(msg.sender, amount));
}
Withdraw(token, msg.sender, amount, tokenList[token][msg.sender]);
}
| function withdrawNoLimit(address token, uint256 amount) public isWithdrawEnabled {
require(amount <= tokenList[token][msg.sender]);
tokenList[token][msg.sender] = safeSub(tokenList[token][msg.sender], amount);
if (token == 0) {//withdraw ether
require(msg.sender.send(amount));
} else {//withdraw token
require(Token(token).transfer(msg.sender, amount));
}
Withdraw(token, msg.sender, amount, tokenList[token][msg.sender]);
}
| 53,808 |
283 | // solhint-disable no-simple-event-func-name | event Transfer(
address indexed from,
address indexed to,
uint256 value
);
event Approval(
address indexed owner,
address indexed spender,
uint256 value
| event Transfer(
address indexed from,
address indexed to,
uint256 value
);
event Approval(
address indexed owner,
address indexed spender,
uint256 value
| 15,003 |
51 | // ---------------------------------------------------------------------------- BokkyPooBah&39;s Token Teleportation Service Library v1.00 Enjoy. (c) BokkyPooBah / Bok Consulting Pty Ltd 2018. The MIT Licence. ---------------------------------------------------------------------------- | library BTTSLib {
struct Data {
bool initialised;
// Ownership
address owner;
address newOwner;
// Minting and management
address minter;
bool mintable;
bool transferable;
mapping(address => bool) accountLocked;
// Token
string symbol;
string name;
uint8 decimals;
uint totalSupply;
mapping(address => uint) balances;
mapping(address => mapping(address => uint)) allowed;
mapping(address => uint) nextNonce;
}
// ------------------------------------------------------------------------
// Constants
// ------------------------------------------------------------------------
uint public constant bttsVersion = 110;
bytes public constant signingPrefix = "\x19Ethereum Signed Message:\n32";
bytes4 public constant signedTransferSig = "\x75\x32\xea\xac";
bytes4 public constant signedApproveSig = "\xe9\xaf\xa7\xa1";
bytes4 public constant signedTransferFromSig = "\x34\x4b\xcc\x7d";
bytes4 public constant signedApproveAndCallSig = "\xf1\x6f\x9b\x53";
// ------------------------------------------------------------------------
// Event
// ------------------------------------------------------------------------
event OwnershipTransferred(address indexed from, address indexed to);
event MinterUpdated(address from, address to);
event Mint(address indexed tokenOwner, uint tokens, bool lockAccount);
event MintingDisabled();
event TransfersEnabled();
event AccountUnlocked(address indexed tokenOwner);
event Transfer(address indexed from, address indexed to, uint tokens);
event Approval(address indexed tokenOwner, address indexed spender, uint tokens);
// ------------------------------------------------------------------------
// Initialisation
// ------------------------------------------------------------------------
function init(Data storage self, address owner, string symbol, string name, uint8 decimals, uint initialSupply, bool mintable, bool transferable) public {
require(!self.initialised);
self.initialised = true;
self.owner = owner;
self.symbol = symbol;
self.name = name;
self.decimals = decimals;
if (initialSupply > 0) {
self.balances[owner] = initialSupply;
self.totalSupply = initialSupply;
Mint(self.owner, initialSupply, false);
Transfer(address(0), self.owner, initialSupply);
}
self.mintable = mintable;
self.transferable = transferable;
}
// ------------------------------------------------------------------------
// Safe maths, inspired by OpenZeppelin
// ------------------------------------------------------------------------
function safeAdd(uint a, uint b) internal pure returns (uint c) {
c = a + b;
require(c >= a);
}
function safeSub(uint a, uint b) internal pure returns (uint c) {
require(b <= a);
c = a - b;
}
function safeMul(uint a, uint b) internal pure returns (uint c) {
c = a * b;
require(a == 0 || c / a == b);
}
function safeDiv(uint a, uint b) internal pure returns (uint c) {
require(b > 0);
c = a / b;
}
// ------------------------------------------------------------------------
// Ownership
// ------------------------------------------------------------------------
function transferOwnership(Data storage self, address newOwner) public {
require(msg.sender == self.owner);
self.newOwner = newOwner;
}
function acceptOwnership(Data storage self) public {
require(msg.sender == self.newOwner);
OwnershipTransferred(self.owner, self.newOwner);
self.owner = self.newOwner;
self.newOwner = address(0);
}
function transferOwnershipImmediately(Data storage self, address newOwner) public {
require(msg.sender == self.owner);
OwnershipTransferred(self.owner, newOwner);
self.owner = newOwner;
self.newOwner = address(0);
}
// ------------------------------------------------------------------------
// Minting and management
// ------------------------------------------------------------------------
function setMinter(Data storage self, address minter) public {
require(msg.sender == self.owner);
require(self.mintable);
MinterUpdated(self.minter, minter);
self.minter = minter;
}
function mint(Data storage self, address tokenOwner, uint tokens, bool lockAccount) public returns (bool success) {
require(self.mintable);
require(msg.sender == self.minter || msg.sender == self.owner);
if (lockAccount) {
self.accountLocked[tokenOwner] = true;
}
self.balances[tokenOwner] = safeAdd(self.balances[tokenOwner], tokens);
self.totalSupply = safeAdd(self.totalSupply, tokens);
Mint(tokenOwner, tokens, lockAccount);
Transfer(address(0), tokenOwner, tokens);
return true;
}
function unlockAccount(Data storage self, address tokenOwner) public {
require(msg.sender == self.owner);
require(self.accountLocked[tokenOwner]);
self.accountLocked[tokenOwner] = false;
AccountUnlocked(tokenOwner);
}
function disableMinting(Data storage self) public {
require(self.mintable);
require(msg.sender == self.minter || msg.sender == self.owner);
self.mintable = false;
if (self.minter != address(0)) {
MinterUpdated(self.minter, address(0));
self.minter = address(0);
}
MintingDisabled();
}
function enableTransfers(Data storage self) public {
require(msg.sender == self.owner);
require(!self.transferable);
self.transferable = true;
TransfersEnabled();
}
// ------------------------------------------------------------------------
// Other functions
// ------------------------------------------------------------------------
function transferAnyERC20Token(Data storage self, address tokenAddress, uint tokens) public returns (bool success) {
require(msg.sender == self.owner);
return ERC20Interface(tokenAddress).transfer(self.owner, tokens);
}
// ------------------------------------------------------------------------
// ecrecover from a signature rather than the signature in parts [v, r, s]
// The signature format is a compact form {bytes32 r}{bytes32 s}{uint8 v}.
// Compact means, uint8 is not padded to 32 bytes.
//
// An invalid signature results in the address(0) being returned, make
// sure that the returned result is checked to be non-zero for validity
//
// Parts from https://gist.github.com/axic/5b33912c6f61ae6fd96d6c4a47afde6d
// ------------------------------------------------------------------------
function ecrecoverFromSig(bytes32 hash, bytes sig) public pure returns (address recoveredAddress) {
bytes32 r;
bytes32 s;
uint8 v;
if (sig.length != 65) return address(0);
assembly {
r := mload(add(sig, 32))
s := mload(add(sig, 64))
// Here we are loading the last 32 bytes. We exploit the fact that 'mload' will pad with zeroes if we overread.
// There is no 'mload8' to do this, but that would be nicer.
v := byte(0, mload(add(sig, 96)))
}
// Albeit non-transactional signatures are not specified by the YP, one would expect it to match the YP range of [27, 28]
// geth uses [0, 1] and some clients have followed. This might change, see https://github.com/ethereum/go-ethereum/issues/2053
if (v < 27) {
v += 27;
}
if (v != 27 && v != 28) return address(0);
return ecrecover(hash, v, r, s);
}
// ------------------------------------------------------------------------
// Get CheckResult message
// ------------------------------------------------------------------------
function getCheckResultMessage(Data storage /*self*/, BTTSTokenInterface.CheckResult result) public pure returns (string) {
if (result == BTTSTokenInterface.CheckResult.Success) {
return "Success";
} else if (result == BTTSTokenInterface.CheckResult.NotTransferable) {
return "Tokens not transferable yet";
} else if (result == BTTSTokenInterface.CheckResult.AccountLocked) {
return "Account locked";
} else if (result == BTTSTokenInterface.CheckResult.SignerMismatch) {
return "Mismatch in signing account";
} else if (result == BTTSTokenInterface.CheckResult.InvalidNonce) {
return "Invalid nonce";
} else if (result == BTTSTokenInterface.CheckResult.InsufficientApprovedTokens) {
return "Insufficient approved tokens";
} else if (result == BTTSTokenInterface.CheckResult.InsufficientApprovedTokensForFees) {
return "Insufficient approved tokens for fees";
} else if (result == BTTSTokenInterface.CheckResult.InsufficientTokens) {
return "Insufficient tokens";
} else if (result == BTTSTokenInterface.CheckResult.InsufficientTokensForFees) {
return "Insufficient tokens for fees";
} else if (result == BTTSTokenInterface.CheckResult.OverflowError) {
return "Overflow error";
} else {
return "Unknown error";
}
}
// ------------------------------------------------------------------------
// Token functions
// ------------------------------------------------------------------------
function transfer(Data storage self, address to, uint tokens) public returns (bool success) {
// Owner and minter can move tokens before the tokens are transferable
require(self.transferable || (self.mintable && (msg.sender == self.owner || msg.sender == self.minter)));
require(!self.accountLocked[msg.sender]);
self.balances[msg.sender] = safeSub(self.balances[msg.sender], tokens);
self.balances[to] = safeAdd(self.balances[to], tokens);
Transfer(msg.sender, to, tokens);
return true;
}
function approve(Data storage self, address spender, uint tokens) public returns (bool success) {
require(!self.accountLocked[msg.sender]);
self.allowed[msg.sender][spender] = tokens;
Approval(msg.sender, spender, tokens);
return true;
}
function transferFrom(Data storage self, address from, address to, uint tokens) public returns (bool success) {
require(self.transferable);
require(!self.accountLocked[from]);
self.balances[from] = safeSub(self.balances[from], tokens);
self.allowed[from][msg.sender] = safeSub(self.allowed[from][msg.sender], tokens);
self.balances[to] = safeAdd(self.balances[to], tokens);
Transfer(from, to, tokens);
return true;
}
function approveAndCall(Data storage self, address spender, uint tokens, bytes data) public returns (bool success) {
require(!self.accountLocked[msg.sender]);
self.allowed[msg.sender][spender] = tokens;
Approval(msg.sender, spender, tokens);
ApproveAndCallFallBack(spender).receiveApproval(msg.sender, tokens, address(this), data);
return true;
}
// ------------------------------------------------------------------------
// Signed function
// ------------------------------------------------------------------------
function signedTransferHash(Data storage /*self*/, address tokenOwner, address to, uint tokens, uint fee, uint nonce) public view returns (bytes32 hash) {
hash = keccak256(signedTransferSig, address(this), tokenOwner, to, tokens, fee, nonce);
}
function signedTransferCheck(Data storage self, address tokenOwner, address to, uint tokens, uint fee, uint nonce, bytes sig, address feeAccount) public view returns (BTTSTokenInterface.CheckResult result) {
if (!self.transferable) return BTTSTokenInterface.CheckResult.NotTransferable;
bytes32 hash = signedTransferHash(self, tokenOwner, to, tokens, fee, nonce);
if (tokenOwner == address(0) || tokenOwner != ecrecoverFromSig(keccak256(signingPrefix, hash), sig)) return BTTSTokenInterface.CheckResult.SignerMismatch;
if (self.accountLocked[tokenOwner]) return BTTSTokenInterface.CheckResult.AccountLocked;
if (self.nextNonce[tokenOwner] != nonce) return BTTSTokenInterface.CheckResult.InvalidNonce;
uint total = safeAdd(tokens, fee);
if (self.balances[tokenOwner] < tokens) return BTTSTokenInterface.CheckResult.InsufficientTokens;
if (self.balances[tokenOwner] < total) return BTTSTokenInterface.CheckResult.InsufficientTokensForFees;
if (self.balances[to] + tokens < self.balances[to]) return BTTSTokenInterface.CheckResult.OverflowError;
if (self.balances[feeAccount] + fee < self.balances[feeAccount]) return BTTSTokenInterface.CheckResult.OverflowError;
return BTTSTokenInterface.CheckResult.Success;
}
function signedTransfer(Data storage self, address tokenOwner, address to, uint tokens, uint fee, uint nonce, bytes sig, address feeAccount) public returns (bool success) {
require(self.transferable);
bytes32 hash = signedTransferHash(self, tokenOwner, to, tokens, fee, nonce);
require(tokenOwner != address(0) && tokenOwner == ecrecoverFromSig(keccak256(signingPrefix, hash), sig));
require(!self.accountLocked[tokenOwner]);
require(self.nextNonce[tokenOwner] == nonce);
self.nextNonce[tokenOwner] = nonce + 1;
self.balances[tokenOwner] = safeSub(self.balances[tokenOwner], tokens);
self.balances[to] = safeAdd(self.balances[to], tokens);
Transfer(tokenOwner, to, tokens);
self.balances[tokenOwner] = safeSub(self.balances[tokenOwner], fee);
self.balances[feeAccount] = safeAdd(self.balances[feeAccount], fee);
Transfer(tokenOwner, feeAccount, fee);
return true;
}
function signedApproveHash(Data storage /*self*/, address tokenOwner, address spender, uint tokens, uint fee, uint nonce) public view returns (bytes32 hash) {
hash = keccak256(signedApproveSig, address(this), tokenOwner, spender, tokens, fee, nonce);
}
function signedApproveCheck(Data storage self, address tokenOwner, address spender, uint tokens, uint fee, uint nonce, bytes sig, address feeAccount) public view returns (BTTSTokenInterface.CheckResult result) {
if (!self.transferable) return BTTSTokenInterface.CheckResult.NotTransferable;
bytes32 hash = signedApproveHash(self, tokenOwner, spender, tokens, fee, nonce);
if (tokenOwner == address(0) || tokenOwner != ecrecoverFromSig(keccak256(signingPrefix, hash), sig)) return BTTSTokenInterface.CheckResult.SignerMismatch;
if (self.accountLocked[tokenOwner]) return BTTSTokenInterface.CheckResult.AccountLocked;
if (self.nextNonce[tokenOwner] != nonce) return BTTSTokenInterface.CheckResult.InvalidNonce;
if (self.balances[tokenOwner] < fee) return BTTSTokenInterface.CheckResult.InsufficientTokensForFees;
if (self.balances[feeAccount] + fee < self.balances[feeAccount]) return BTTSTokenInterface.CheckResult.OverflowError;
return BTTSTokenInterface.CheckResult.Success;
}
function signedApprove(Data storage self, address tokenOwner, address spender, uint tokens, uint fee, uint nonce, bytes sig, address feeAccount) public returns (bool success) {
require(self.transferable);
bytes32 hash = signedApproveHash(self, tokenOwner, spender, tokens, fee, nonce);
require(tokenOwner != address(0) && tokenOwner == ecrecoverFromSig(keccak256(signingPrefix, hash), sig));
require(!self.accountLocked[tokenOwner]);
require(self.nextNonce[tokenOwner] == nonce);
self.nextNonce[tokenOwner] = nonce + 1;
self.allowed[tokenOwner][spender] = tokens;
Approval(tokenOwner, spender, tokens);
self.balances[tokenOwner] = safeSub(self.balances[tokenOwner], fee);
self.balances[feeAccount] = safeAdd(self.balances[feeAccount], fee);
Transfer(tokenOwner, feeAccount, fee);
return true;
}
function signedTransferFromHash(Data storage /*self*/, address spender, address from, address to, uint tokens, uint fee, uint nonce) public view returns (bytes32 hash) {
hash = keccak256(signedTransferFromSig, address(this), spender, from, to, tokens, fee, nonce);
}
function signedTransferFromCheck(Data storage self, address spender, address from, address to, uint tokens, uint fee, uint nonce, bytes sig, address feeAccount) public view returns (BTTSTokenInterface.CheckResult result) {
if (!self.transferable) return BTTSTokenInterface.CheckResult.NotTransferable;
bytes32 hash = signedTransferFromHash(self, spender, from, to, tokens, fee, nonce);
if (spender == address(0) || spender != ecrecoverFromSig(keccak256(signingPrefix, hash), sig)) return BTTSTokenInterface.CheckResult.SignerMismatch;
if (self.accountLocked[from]) return BTTSTokenInterface.CheckResult.AccountLocked;
if (self.nextNonce[spender] != nonce) return BTTSTokenInterface.CheckResult.InvalidNonce;
uint total = safeAdd(tokens, fee);
if (self.allowed[from][spender] < tokens) return BTTSTokenInterface.CheckResult.InsufficientApprovedTokens;
if (self.allowed[from][spender] < total) return BTTSTokenInterface.CheckResult.InsufficientApprovedTokensForFees;
if (self.balances[from] < tokens) return BTTSTokenInterface.CheckResult.InsufficientTokens;
if (self.balances[from] < total) return BTTSTokenInterface.CheckResult.InsufficientTokensForFees;
if (self.balances[to] + tokens < self.balances[to]) return BTTSTokenInterface.CheckResult.OverflowError;
if (self.balances[feeAccount] + fee < self.balances[feeAccount]) return BTTSTokenInterface.CheckResult.OverflowError;
return BTTSTokenInterface.CheckResult.Success;
}
function signedTransferFrom(Data storage self, address spender, address from, address to, uint tokens, uint fee, uint nonce, bytes sig, address feeAccount) public returns (bool success) {
require(self.transferable);
bytes32 hash = signedTransferFromHash(self, spender, from, to, tokens, fee, nonce);
require(spender != address(0) && spender == ecrecoverFromSig(keccak256(signingPrefix, hash), sig));
require(!self.accountLocked[from]);
require(self.nextNonce[spender] == nonce);
self.nextNonce[spender] = nonce + 1;
self.balances[from] = safeSub(self.balances[from], tokens);
self.allowed[from][spender] = safeSub(self.allowed[from][spender], tokens);
self.balances[to] = safeAdd(self.balances[to], tokens);
Transfer(from, to, tokens);
self.balances[from] = safeSub(self.balances[from], fee);
self.allowed[from][spender] = safeSub(self.allowed[from][spender], fee);
self.balances[feeAccount] = safeAdd(self.balances[feeAccount], fee);
Transfer(from, feeAccount, fee);
return true;
}
function signedApproveAndCallHash(Data storage /*self*/, address tokenOwner, address spender, uint tokens, bytes data, uint fee, uint nonce) public view returns (bytes32 hash) {
hash = keccak256(signedApproveAndCallSig, address(this), tokenOwner, spender, tokens, data, fee, nonce);
}
function signedApproveAndCallCheck(Data storage self, address tokenOwner, address spender, uint tokens, bytes data, uint fee, uint nonce, bytes sig, address feeAccount) public view returns (BTTSTokenInterface.CheckResult result) {
if (!self.transferable) return BTTSTokenInterface.CheckResult.NotTransferable;
bytes32 hash = signedApproveAndCallHash(self, tokenOwner, spender, tokens, data, fee, nonce);
if (tokenOwner == address(0) || tokenOwner != ecrecoverFromSig(keccak256(signingPrefix, hash), sig)) return BTTSTokenInterface.CheckResult.SignerMismatch;
if (self.accountLocked[tokenOwner]) return BTTSTokenInterface.CheckResult.AccountLocked;
if (self.nextNonce[tokenOwner] != nonce) return BTTSTokenInterface.CheckResult.InvalidNonce;
if (self.balances[tokenOwner] < fee) return BTTSTokenInterface.CheckResult.InsufficientTokensForFees;
if (self.balances[feeAccount] + fee < self.balances[feeAccount]) return BTTSTokenInterface.CheckResult.OverflowError;
return BTTSTokenInterface.CheckResult.Success;
}
function signedApproveAndCall(Data storage self, address tokenOwner, address spender, uint tokens, bytes data, uint fee, uint nonce, bytes sig, address feeAccount) public returns (bool success) {
require(self.transferable);
bytes32 hash = signedApproveAndCallHash(self, tokenOwner, spender, tokens, data, fee, nonce);
require(tokenOwner != address(0) && tokenOwner == ecrecoverFromSig(keccak256(signingPrefix, hash), sig));
require(!self.accountLocked[tokenOwner]);
require(self.nextNonce[tokenOwner] == nonce);
self.nextNonce[tokenOwner] = nonce + 1;
self.allowed[tokenOwner][spender] = tokens;
Approval(tokenOwner, spender, tokens);
self.balances[tokenOwner] = safeSub(self.balances[tokenOwner], fee);
self.balances[feeAccount] = safeAdd(self.balances[feeAccount], fee);
Transfer(tokenOwner, feeAccount, fee);
ApproveAndCallFallBack(spender).receiveApproval(tokenOwner, tokens, address(this), data);
return true;
}
}
| library BTTSLib {
struct Data {
bool initialised;
// Ownership
address owner;
address newOwner;
// Minting and management
address minter;
bool mintable;
bool transferable;
mapping(address => bool) accountLocked;
// Token
string symbol;
string name;
uint8 decimals;
uint totalSupply;
mapping(address => uint) balances;
mapping(address => mapping(address => uint)) allowed;
mapping(address => uint) nextNonce;
}
// ------------------------------------------------------------------------
// Constants
// ------------------------------------------------------------------------
uint public constant bttsVersion = 110;
bytes public constant signingPrefix = "\x19Ethereum Signed Message:\n32";
bytes4 public constant signedTransferSig = "\x75\x32\xea\xac";
bytes4 public constant signedApproveSig = "\xe9\xaf\xa7\xa1";
bytes4 public constant signedTransferFromSig = "\x34\x4b\xcc\x7d";
bytes4 public constant signedApproveAndCallSig = "\xf1\x6f\x9b\x53";
// ------------------------------------------------------------------------
// Event
// ------------------------------------------------------------------------
event OwnershipTransferred(address indexed from, address indexed to);
event MinterUpdated(address from, address to);
event Mint(address indexed tokenOwner, uint tokens, bool lockAccount);
event MintingDisabled();
event TransfersEnabled();
event AccountUnlocked(address indexed tokenOwner);
event Transfer(address indexed from, address indexed to, uint tokens);
event Approval(address indexed tokenOwner, address indexed spender, uint tokens);
// ------------------------------------------------------------------------
// Initialisation
// ------------------------------------------------------------------------
function init(Data storage self, address owner, string symbol, string name, uint8 decimals, uint initialSupply, bool mintable, bool transferable) public {
require(!self.initialised);
self.initialised = true;
self.owner = owner;
self.symbol = symbol;
self.name = name;
self.decimals = decimals;
if (initialSupply > 0) {
self.balances[owner] = initialSupply;
self.totalSupply = initialSupply;
Mint(self.owner, initialSupply, false);
Transfer(address(0), self.owner, initialSupply);
}
self.mintable = mintable;
self.transferable = transferable;
}
// ------------------------------------------------------------------------
// Safe maths, inspired by OpenZeppelin
// ------------------------------------------------------------------------
function safeAdd(uint a, uint b) internal pure returns (uint c) {
c = a + b;
require(c >= a);
}
function safeSub(uint a, uint b) internal pure returns (uint c) {
require(b <= a);
c = a - b;
}
function safeMul(uint a, uint b) internal pure returns (uint c) {
c = a * b;
require(a == 0 || c / a == b);
}
function safeDiv(uint a, uint b) internal pure returns (uint c) {
require(b > 0);
c = a / b;
}
// ------------------------------------------------------------------------
// Ownership
// ------------------------------------------------------------------------
function transferOwnership(Data storage self, address newOwner) public {
require(msg.sender == self.owner);
self.newOwner = newOwner;
}
function acceptOwnership(Data storage self) public {
require(msg.sender == self.newOwner);
OwnershipTransferred(self.owner, self.newOwner);
self.owner = self.newOwner;
self.newOwner = address(0);
}
function transferOwnershipImmediately(Data storage self, address newOwner) public {
require(msg.sender == self.owner);
OwnershipTransferred(self.owner, newOwner);
self.owner = newOwner;
self.newOwner = address(0);
}
// ------------------------------------------------------------------------
// Minting and management
// ------------------------------------------------------------------------
function setMinter(Data storage self, address minter) public {
require(msg.sender == self.owner);
require(self.mintable);
MinterUpdated(self.minter, minter);
self.minter = minter;
}
function mint(Data storage self, address tokenOwner, uint tokens, bool lockAccount) public returns (bool success) {
require(self.mintable);
require(msg.sender == self.minter || msg.sender == self.owner);
if (lockAccount) {
self.accountLocked[tokenOwner] = true;
}
self.balances[tokenOwner] = safeAdd(self.balances[tokenOwner], tokens);
self.totalSupply = safeAdd(self.totalSupply, tokens);
Mint(tokenOwner, tokens, lockAccount);
Transfer(address(0), tokenOwner, tokens);
return true;
}
function unlockAccount(Data storage self, address tokenOwner) public {
require(msg.sender == self.owner);
require(self.accountLocked[tokenOwner]);
self.accountLocked[tokenOwner] = false;
AccountUnlocked(tokenOwner);
}
function disableMinting(Data storage self) public {
require(self.mintable);
require(msg.sender == self.minter || msg.sender == self.owner);
self.mintable = false;
if (self.minter != address(0)) {
MinterUpdated(self.minter, address(0));
self.minter = address(0);
}
MintingDisabled();
}
function enableTransfers(Data storage self) public {
require(msg.sender == self.owner);
require(!self.transferable);
self.transferable = true;
TransfersEnabled();
}
// ------------------------------------------------------------------------
// Other functions
// ------------------------------------------------------------------------
function transferAnyERC20Token(Data storage self, address tokenAddress, uint tokens) public returns (bool success) {
require(msg.sender == self.owner);
return ERC20Interface(tokenAddress).transfer(self.owner, tokens);
}
// ------------------------------------------------------------------------
// ecrecover from a signature rather than the signature in parts [v, r, s]
// The signature format is a compact form {bytes32 r}{bytes32 s}{uint8 v}.
// Compact means, uint8 is not padded to 32 bytes.
//
// An invalid signature results in the address(0) being returned, make
// sure that the returned result is checked to be non-zero for validity
//
// Parts from https://gist.github.com/axic/5b33912c6f61ae6fd96d6c4a47afde6d
// ------------------------------------------------------------------------
function ecrecoverFromSig(bytes32 hash, bytes sig) public pure returns (address recoveredAddress) {
bytes32 r;
bytes32 s;
uint8 v;
if (sig.length != 65) return address(0);
assembly {
r := mload(add(sig, 32))
s := mload(add(sig, 64))
// Here we are loading the last 32 bytes. We exploit the fact that 'mload' will pad with zeroes if we overread.
// There is no 'mload8' to do this, but that would be nicer.
v := byte(0, mload(add(sig, 96)))
}
// Albeit non-transactional signatures are not specified by the YP, one would expect it to match the YP range of [27, 28]
// geth uses [0, 1] and some clients have followed. This might change, see https://github.com/ethereum/go-ethereum/issues/2053
if (v < 27) {
v += 27;
}
if (v != 27 && v != 28) return address(0);
return ecrecover(hash, v, r, s);
}
// ------------------------------------------------------------------------
// Get CheckResult message
// ------------------------------------------------------------------------
function getCheckResultMessage(Data storage /*self*/, BTTSTokenInterface.CheckResult result) public pure returns (string) {
if (result == BTTSTokenInterface.CheckResult.Success) {
return "Success";
} else if (result == BTTSTokenInterface.CheckResult.NotTransferable) {
return "Tokens not transferable yet";
} else if (result == BTTSTokenInterface.CheckResult.AccountLocked) {
return "Account locked";
} else if (result == BTTSTokenInterface.CheckResult.SignerMismatch) {
return "Mismatch in signing account";
} else if (result == BTTSTokenInterface.CheckResult.InvalidNonce) {
return "Invalid nonce";
} else if (result == BTTSTokenInterface.CheckResult.InsufficientApprovedTokens) {
return "Insufficient approved tokens";
} else if (result == BTTSTokenInterface.CheckResult.InsufficientApprovedTokensForFees) {
return "Insufficient approved tokens for fees";
} else if (result == BTTSTokenInterface.CheckResult.InsufficientTokens) {
return "Insufficient tokens";
} else if (result == BTTSTokenInterface.CheckResult.InsufficientTokensForFees) {
return "Insufficient tokens for fees";
} else if (result == BTTSTokenInterface.CheckResult.OverflowError) {
return "Overflow error";
} else {
return "Unknown error";
}
}
// ------------------------------------------------------------------------
// Token functions
// ------------------------------------------------------------------------
function transfer(Data storage self, address to, uint tokens) public returns (bool success) {
// Owner and minter can move tokens before the tokens are transferable
require(self.transferable || (self.mintable && (msg.sender == self.owner || msg.sender == self.minter)));
require(!self.accountLocked[msg.sender]);
self.balances[msg.sender] = safeSub(self.balances[msg.sender], tokens);
self.balances[to] = safeAdd(self.balances[to], tokens);
Transfer(msg.sender, to, tokens);
return true;
}
function approve(Data storage self, address spender, uint tokens) public returns (bool success) {
require(!self.accountLocked[msg.sender]);
self.allowed[msg.sender][spender] = tokens;
Approval(msg.sender, spender, tokens);
return true;
}
function transferFrom(Data storage self, address from, address to, uint tokens) public returns (bool success) {
require(self.transferable);
require(!self.accountLocked[from]);
self.balances[from] = safeSub(self.balances[from], tokens);
self.allowed[from][msg.sender] = safeSub(self.allowed[from][msg.sender], tokens);
self.balances[to] = safeAdd(self.balances[to], tokens);
Transfer(from, to, tokens);
return true;
}
function approveAndCall(Data storage self, address spender, uint tokens, bytes data) public returns (bool success) {
require(!self.accountLocked[msg.sender]);
self.allowed[msg.sender][spender] = tokens;
Approval(msg.sender, spender, tokens);
ApproveAndCallFallBack(spender).receiveApproval(msg.sender, tokens, address(this), data);
return true;
}
// ------------------------------------------------------------------------
// Signed function
// ------------------------------------------------------------------------
function signedTransferHash(Data storage /*self*/, address tokenOwner, address to, uint tokens, uint fee, uint nonce) public view returns (bytes32 hash) {
hash = keccak256(signedTransferSig, address(this), tokenOwner, to, tokens, fee, nonce);
}
function signedTransferCheck(Data storage self, address tokenOwner, address to, uint tokens, uint fee, uint nonce, bytes sig, address feeAccount) public view returns (BTTSTokenInterface.CheckResult result) {
if (!self.transferable) return BTTSTokenInterface.CheckResult.NotTransferable;
bytes32 hash = signedTransferHash(self, tokenOwner, to, tokens, fee, nonce);
if (tokenOwner == address(0) || tokenOwner != ecrecoverFromSig(keccak256(signingPrefix, hash), sig)) return BTTSTokenInterface.CheckResult.SignerMismatch;
if (self.accountLocked[tokenOwner]) return BTTSTokenInterface.CheckResult.AccountLocked;
if (self.nextNonce[tokenOwner] != nonce) return BTTSTokenInterface.CheckResult.InvalidNonce;
uint total = safeAdd(tokens, fee);
if (self.balances[tokenOwner] < tokens) return BTTSTokenInterface.CheckResult.InsufficientTokens;
if (self.balances[tokenOwner] < total) return BTTSTokenInterface.CheckResult.InsufficientTokensForFees;
if (self.balances[to] + tokens < self.balances[to]) return BTTSTokenInterface.CheckResult.OverflowError;
if (self.balances[feeAccount] + fee < self.balances[feeAccount]) return BTTSTokenInterface.CheckResult.OverflowError;
return BTTSTokenInterface.CheckResult.Success;
}
function signedTransfer(Data storage self, address tokenOwner, address to, uint tokens, uint fee, uint nonce, bytes sig, address feeAccount) public returns (bool success) {
require(self.transferable);
bytes32 hash = signedTransferHash(self, tokenOwner, to, tokens, fee, nonce);
require(tokenOwner != address(0) && tokenOwner == ecrecoverFromSig(keccak256(signingPrefix, hash), sig));
require(!self.accountLocked[tokenOwner]);
require(self.nextNonce[tokenOwner] == nonce);
self.nextNonce[tokenOwner] = nonce + 1;
self.balances[tokenOwner] = safeSub(self.balances[tokenOwner], tokens);
self.balances[to] = safeAdd(self.balances[to], tokens);
Transfer(tokenOwner, to, tokens);
self.balances[tokenOwner] = safeSub(self.balances[tokenOwner], fee);
self.balances[feeAccount] = safeAdd(self.balances[feeAccount], fee);
Transfer(tokenOwner, feeAccount, fee);
return true;
}
function signedApproveHash(Data storage /*self*/, address tokenOwner, address spender, uint tokens, uint fee, uint nonce) public view returns (bytes32 hash) {
hash = keccak256(signedApproveSig, address(this), tokenOwner, spender, tokens, fee, nonce);
}
function signedApproveCheck(Data storage self, address tokenOwner, address spender, uint tokens, uint fee, uint nonce, bytes sig, address feeAccount) public view returns (BTTSTokenInterface.CheckResult result) {
if (!self.transferable) return BTTSTokenInterface.CheckResult.NotTransferable;
bytes32 hash = signedApproveHash(self, tokenOwner, spender, tokens, fee, nonce);
if (tokenOwner == address(0) || tokenOwner != ecrecoverFromSig(keccak256(signingPrefix, hash), sig)) return BTTSTokenInterface.CheckResult.SignerMismatch;
if (self.accountLocked[tokenOwner]) return BTTSTokenInterface.CheckResult.AccountLocked;
if (self.nextNonce[tokenOwner] != nonce) return BTTSTokenInterface.CheckResult.InvalidNonce;
if (self.balances[tokenOwner] < fee) return BTTSTokenInterface.CheckResult.InsufficientTokensForFees;
if (self.balances[feeAccount] + fee < self.balances[feeAccount]) return BTTSTokenInterface.CheckResult.OverflowError;
return BTTSTokenInterface.CheckResult.Success;
}
function signedApprove(Data storage self, address tokenOwner, address spender, uint tokens, uint fee, uint nonce, bytes sig, address feeAccount) public returns (bool success) {
require(self.transferable);
bytes32 hash = signedApproveHash(self, tokenOwner, spender, tokens, fee, nonce);
require(tokenOwner != address(0) && tokenOwner == ecrecoverFromSig(keccak256(signingPrefix, hash), sig));
require(!self.accountLocked[tokenOwner]);
require(self.nextNonce[tokenOwner] == nonce);
self.nextNonce[tokenOwner] = nonce + 1;
self.allowed[tokenOwner][spender] = tokens;
Approval(tokenOwner, spender, tokens);
self.balances[tokenOwner] = safeSub(self.balances[tokenOwner], fee);
self.balances[feeAccount] = safeAdd(self.balances[feeAccount], fee);
Transfer(tokenOwner, feeAccount, fee);
return true;
}
function signedTransferFromHash(Data storage /*self*/, address spender, address from, address to, uint tokens, uint fee, uint nonce) public view returns (bytes32 hash) {
hash = keccak256(signedTransferFromSig, address(this), spender, from, to, tokens, fee, nonce);
}
function signedTransferFromCheck(Data storage self, address spender, address from, address to, uint tokens, uint fee, uint nonce, bytes sig, address feeAccount) public view returns (BTTSTokenInterface.CheckResult result) {
if (!self.transferable) return BTTSTokenInterface.CheckResult.NotTransferable;
bytes32 hash = signedTransferFromHash(self, spender, from, to, tokens, fee, nonce);
if (spender == address(0) || spender != ecrecoverFromSig(keccak256(signingPrefix, hash), sig)) return BTTSTokenInterface.CheckResult.SignerMismatch;
if (self.accountLocked[from]) return BTTSTokenInterface.CheckResult.AccountLocked;
if (self.nextNonce[spender] != nonce) return BTTSTokenInterface.CheckResult.InvalidNonce;
uint total = safeAdd(tokens, fee);
if (self.allowed[from][spender] < tokens) return BTTSTokenInterface.CheckResult.InsufficientApprovedTokens;
if (self.allowed[from][spender] < total) return BTTSTokenInterface.CheckResult.InsufficientApprovedTokensForFees;
if (self.balances[from] < tokens) return BTTSTokenInterface.CheckResult.InsufficientTokens;
if (self.balances[from] < total) return BTTSTokenInterface.CheckResult.InsufficientTokensForFees;
if (self.balances[to] + tokens < self.balances[to]) return BTTSTokenInterface.CheckResult.OverflowError;
if (self.balances[feeAccount] + fee < self.balances[feeAccount]) return BTTSTokenInterface.CheckResult.OverflowError;
return BTTSTokenInterface.CheckResult.Success;
}
function signedTransferFrom(Data storage self, address spender, address from, address to, uint tokens, uint fee, uint nonce, bytes sig, address feeAccount) public returns (bool success) {
require(self.transferable);
bytes32 hash = signedTransferFromHash(self, spender, from, to, tokens, fee, nonce);
require(spender != address(0) && spender == ecrecoverFromSig(keccak256(signingPrefix, hash), sig));
require(!self.accountLocked[from]);
require(self.nextNonce[spender] == nonce);
self.nextNonce[spender] = nonce + 1;
self.balances[from] = safeSub(self.balances[from], tokens);
self.allowed[from][spender] = safeSub(self.allowed[from][spender], tokens);
self.balances[to] = safeAdd(self.balances[to], tokens);
Transfer(from, to, tokens);
self.balances[from] = safeSub(self.balances[from], fee);
self.allowed[from][spender] = safeSub(self.allowed[from][spender], fee);
self.balances[feeAccount] = safeAdd(self.balances[feeAccount], fee);
Transfer(from, feeAccount, fee);
return true;
}
function signedApproveAndCallHash(Data storage /*self*/, address tokenOwner, address spender, uint tokens, bytes data, uint fee, uint nonce) public view returns (bytes32 hash) {
hash = keccak256(signedApproveAndCallSig, address(this), tokenOwner, spender, tokens, data, fee, nonce);
}
function signedApproveAndCallCheck(Data storage self, address tokenOwner, address spender, uint tokens, bytes data, uint fee, uint nonce, bytes sig, address feeAccount) public view returns (BTTSTokenInterface.CheckResult result) {
if (!self.transferable) return BTTSTokenInterface.CheckResult.NotTransferable;
bytes32 hash = signedApproveAndCallHash(self, tokenOwner, spender, tokens, data, fee, nonce);
if (tokenOwner == address(0) || tokenOwner != ecrecoverFromSig(keccak256(signingPrefix, hash), sig)) return BTTSTokenInterface.CheckResult.SignerMismatch;
if (self.accountLocked[tokenOwner]) return BTTSTokenInterface.CheckResult.AccountLocked;
if (self.nextNonce[tokenOwner] != nonce) return BTTSTokenInterface.CheckResult.InvalidNonce;
if (self.balances[tokenOwner] < fee) return BTTSTokenInterface.CheckResult.InsufficientTokensForFees;
if (self.balances[feeAccount] + fee < self.balances[feeAccount]) return BTTSTokenInterface.CheckResult.OverflowError;
return BTTSTokenInterface.CheckResult.Success;
}
function signedApproveAndCall(Data storage self, address tokenOwner, address spender, uint tokens, bytes data, uint fee, uint nonce, bytes sig, address feeAccount) public returns (bool success) {
require(self.transferable);
bytes32 hash = signedApproveAndCallHash(self, tokenOwner, spender, tokens, data, fee, nonce);
require(tokenOwner != address(0) && tokenOwner == ecrecoverFromSig(keccak256(signingPrefix, hash), sig));
require(!self.accountLocked[tokenOwner]);
require(self.nextNonce[tokenOwner] == nonce);
self.nextNonce[tokenOwner] = nonce + 1;
self.allowed[tokenOwner][spender] = tokens;
Approval(tokenOwner, spender, tokens);
self.balances[tokenOwner] = safeSub(self.balances[tokenOwner], fee);
self.balances[feeAccount] = safeAdd(self.balances[feeAccount], fee);
Transfer(tokenOwner, feeAccount, fee);
ApproveAndCallFallBack(spender).receiveApproval(tokenOwner, tokens, address(this), data);
return true;
}
}
| 22,840 |
124 | // automation variables | uint public minRedemptionRatioPerc; // the min % excess collateral that must remain after any ETH redeem action
uint public automationFeePerc; // the fee that goes to the collateral pool, on entry or exit, to compensate for potentially triggering a boost or redeem
| uint public minRedemptionRatioPerc; // the min % excess collateral that must remain after any ETH redeem action
uint public automationFeePerc; // the fee that goes to the collateral pool, on entry or exit, to compensate for potentially triggering a boost or redeem
| 29,307 |
27 | // The level of this sheet. 0 expresses initial price sheet, a value greater than 0 expresses bite price sheet | uint8 level;
| uint8 level;
| 37,182 |
8 | // Modifier to make a function callable only when caller is the Owner or `contractName1` or `contractName2` contract.Requirements:- The caller must be the owner, `contractName1`, or `contractName2`. / | modifier allowTwo(string memory contractName1, string memory contractName2) {
require(
contractManager.getContract(contractName1) == msg.sender ||
contractManager.getContract(contractName2) == msg.sender ||
_isOwner(),
"Message sender is invalid");
_;
}
| modifier allowTwo(string memory contractName1, string memory contractName2) {
require(
contractManager.getContract(contractName1) == msg.sender ||
contractManager.getContract(contractName2) == msg.sender ||
_isOwner(),
"Message sender is invalid");
_;
}
| 11,493 |
639 | // Calculate 2 raised into given power.x power to raise 2 into, multiplied by 2^121return 2 raised into given power / | function pow_2(uint128 x)
| function pow_2(uint128 x)
| 47,333 |
439 | // Price has never been requested. Price requests always go in the next round, so add 1 to the computed current round. | uint256 nextRoundId = currentRoundId.add(1);
priceRequests[priceRequestId] = PriceRequest({
identifier: identifier,
time: time,
lastVotingRound: nextRoundId,
index: pendingPriceRequests.length,
ancillaryData: ancillaryData
});
| uint256 nextRoundId = currentRoundId.add(1);
priceRequests[priceRequestId] = PriceRequest({
identifier: identifier,
time: time,
lastVotingRound: nextRoundId,
index: pendingPriceRequests.length,
ancillaryData: ancillaryData
});
| 9,971 |
0 | // Partial ERC20 interface needed by internal functions / | interface IERC20Internal {
event Transfer(address indexed from, address indexed to, uint256 value);
event Approval(
address indexed owner,
address indexed spender,
uint256 value
);
}
| interface IERC20Internal {
event Transfer(address indexed from, address indexed to, uint256 value);
event Approval(
address indexed owner,
address indexed spender,
uint256 value
);
}
| 18,315 |
10 | // Tracks registered resolver status. | struct Resolver {
bool active;
uint8 fee;
}
| struct Resolver {
bool active;
uint8 fee;
}
| 29,755 |
8 | // CRITICAL TO SETUP / | modifier requireContractsSet() {
require(address(gamblrDeposits) != address(0), "Contracts not set");
_;
}
| modifier requireContractsSet() {
require(address(gamblrDeposits) != address(0), "Contracts not set");
_;
}
| 2,066 |
4 | // Mask out irrelevant contracts and check again for new contracts | uint256 mask = uint256(-1);
if(shortest < 32) {
mask = ~(2 ** (8 * (32 - shortest + idx)) - 1);
}
| uint256 mask = uint256(-1);
if(shortest < 32) {
mask = ~(2 ** (8 * (32 - shortest + idx)) - 1);
}
| 23,383 |
204 | // SAFETY: Simple int-to-bool cast. | _b := _u
| _b := _u
| 9,840 |
6 | // If the last available tokenID is still unused... | if (tokenMatrix[maxIndex - 1] == 0) {
| if (tokenMatrix[maxIndex - 1] == 0) {
| 17,289 |
429 | // Access an element of the array without performing bounds check. The position is assumed to be within bounds. / | function _unsafeAccess(Checkpoint[] storage ckpts, uint256 pos) private pure returns (Checkpoint storage result) {
assembly {
mstore(0, ckpts.slot)
result.slot := add(keccak256(0, 0x20), pos)
}
}
| function _unsafeAccess(Checkpoint[] storage ckpts, uint256 pos) private pure returns (Checkpoint storage result) {
assembly {
mstore(0, ckpts.slot)
result.slot := add(keccak256(0, 0x20), pos)
}
}
| 7,589 |
27 | // require(minorTokenAmt > 0, "OneSwapBuyback: NO_MINOR_TOKENS"); | if (minorTokenAmt == 0) { return; }
| if (minorTokenAmt == 0) { return; }
| 35,863 |
7 | // Rubic token fee | uint256 public RubicPlatformFee;
| uint256 public RubicPlatformFee;
| 17,850 |
334 | // MANAGER ONLY: Remove collateral asset. Collateral asset exited in Compound marketsIf there is a borrow balance, collateral asset cannot be removed_setToken Instance of the SetToken _collateralAssets Addresses of collateral underlying assets to remove / | function removeCollateralAssets(ISetToken _setToken, IERC20[] memory _collateralAssets) external onlyManagerAndValidSet(_setToken) {
// Sync Compound and SetToken positions prior to any removal action
sync(_setToken, true);
for(uint256 i = 0; i < _collateralAssets.length; i++) {
ICErc20 cToken = underlyingToCToken[_collateralAssets[i]];
require(collateralCTokenEnabled[_setToken][cToken], "Collateral not enabled");
// Note: Will only exit market if cToken is not enabled as a borrow asset as well
// If there is an existing borrow balance, will revert and market cannot be exited on Compound
if (!borrowCTokenEnabled[_setToken][cToken]) {
_setToken.invokeExitMarket(cToken, comptroller);
}
delete collateralCTokenEnabled[_setToken][cToken];
enabledAssets[_setToken].collateralCTokens.removeStorage(address(cToken));
}
emit CollateralAssetsUpdated(_setToken, false, _collateralAssets);
}
| function removeCollateralAssets(ISetToken _setToken, IERC20[] memory _collateralAssets) external onlyManagerAndValidSet(_setToken) {
// Sync Compound and SetToken positions prior to any removal action
sync(_setToken, true);
for(uint256 i = 0; i < _collateralAssets.length; i++) {
ICErc20 cToken = underlyingToCToken[_collateralAssets[i]];
require(collateralCTokenEnabled[_setToken][cToken], "Collateral not enabled");
// Note: Will only exit market if cToken is not enabled as a borrow asset as well
// If there is an existing borrow balance, will revert and market cannot be exited on Compound
if (!borrowCTokenEnabled[_setToken][cToken]) {
_setToken.invokeExitMarket(cToken, comptroller);
}
delete collateralCTokenEnabled[_setToken][cToken];
enabledAssets[_setToken].collateralCTokens.removeStorage(address(cToken));
}
emit CollateralAssetsUpdated(_setToken, false, _collateralAssets);
}
| 2,856 |
24 | // returns what gensis pool a supported token is mapped to/tokens array of addresses of supported tokens/ return genesisAddresses array of genesis pools corresponding to supported tokens | function getGenesisPools(address[] calldata tokens)
external
view
returns (address[] memory genesisAddresses);
| function getGenesisPools(address[] calldata tokens)
external
view
returns (address[] memory genesisAddresses);
| 25,130 |
31 | // Returns asset decimals. return asset decimals. / | function decimals() constant returns(uint8) {
return etoken2.baseUnit(etoken2Symbol);
}
| function decimals() constant returns(uint8) {
return etoken2.baseUnit(etoken2Symbol);
}
| 8,493 |
21 | // Lets an account remove a published contract (and all its versions). The account must be approved by the publisher, or be the publisher. publisherThe address of the publisher.contractId The identifier for a published contract (that can have multiple verisons). / | function removeFromPublicList(address publisher, string memory contractId) external;
| function removeFromPublicList(address publisher, string memory contractId) external;
| 10,154 |
5 | // Switch 생성 | Switch s = switches[numPaid++];
s.addr = msg.sender;
s.endTime = now + 300;
s.status = true;
| Switch s = switches[numPaid++];
s.addr = msg.sender;
s.endTime = now + 300;
s.status = true;
| 23,653 |
8 | // Allows an owner to update reward rate per sec./_rewardPerSec Reward rate generated each second. | function setRewardPerSec(uint256 _rewardPerSec) public onlyOwner {
rewardPerSec = _rewardPerSec;
}
| function setRewardPerSec(uint256 _rewardPerSec) public onlyOwner {
rewardPerSec = _rewardPerSec;
}
| 29,045 |
46 | // Set basic parameters | poolID = _poolID;
rewardPool = _rewardPool;
curveLpDecimals = IERC20Detailed(_crvLp).decimals();
ONE_CURVE_LP_TOKEN = 10**(curveLpDecimals);
curveDeposit = _curveArgs.deposit;
depositor = _curveArgs.depositor;
depositPosition = _curveArgs.depositPosition;
releaseBlocksPeriod = _releasePeriod;
setBlocksPerYear(2465437); // given that blocks are mined at a 13.15s/block rate
| poolID = _poolID;
rewardPool = _rewardPool;
curveLpDecimals = IERC20Detailed(_crvLp).decimals();
ONE_CURVE_LP_TOKEN = 10**(curveLpDecimals);
curveDeposit = _curveArgs.deposit;
depositor = _curveArgs.depositor;
depositPosition = _curveArgs.depositPosition;
releaseBlocksPeriod = _releasePeriod;
setBlocksPerYear(2465437); // given that blocks are mined at a 13.15s/block rate
| 45,599 |
26 | // Sets the commission rate charged on competitions and max players permitted in a single competition on creation of the contract./ | constructor(
uint256 _commissionRate,
uint256 _maxPlayers
| constructor(
uint256 _commissionRate,
uint256 _maxPlayers
| 16,877 |
0 | // set 1st and 2nd entries | fibseries.push(1);
fibseries.push(1);
| fibseries.push(1);
fibseries.push(1);
| 24,698 |
4 | // Get Total Cost | uint256 cost = CostUtils.getMintCost(jNumber, decimals);
| uint256 cost = CostUtils.getMintCost(jNumber, decimals);
| 15,880 |
0 | // Global Varaibles/string that holds the contract name | string public name = "BlockBox";
| string public name = "BlockBox";
| 37,079 |
13 | // ------------------------------------------------------------------------ Constants ------------------------------------------------------------------------ | uint public constant bttsVersion = 110;
bytes public constant signingPrefix = "\x19Ethereum Signed Message:\n32";
bytes4 public constant signedTransferSig = "\x75\x32\xea\xac";
bytes4 public constant signedApproveSig = "\xe9\xaf\xa7\xa1";
bytes4 public constant signedTransferFromSig = "\x34\x4b\xcc\x7d";
bytes4 public constant signedApproveAndCallSig = "\xf1\x6f\x9b\x53";
| uint public constant bttsVersion = 110;
bytes public constant signingPrefix = "\x19Ethereum Signed Message:\n32";
bytes4 public constant signedTransferSig = "\x75\x32\xea\xac";
bytes4 public constant signedApproveSig = "\xe9\xaf\xa7\xa1";
bytes4 public constant signedTransferFromSig = "\x34\x4b\xcc\x7d";
bytes4 public constant signedApproveAndCallSig = "\xf1\x6f\x9b\x53";
| 81,530 |
15 | // Returns the price to register or renew a name. name The name being registered or renewed. expires When the name presently expires (0 if this is a new registration). duration How long the name is being registered or extended for, in seconds.return base premium tuple of base price + premium price / | function price(
string calldata name,
uint256 expires,
uint256 duration
) external view returns (Price calldata);
| function price(
string calldata name,
uint256 expires,
uint256 duration
) external view returns (Price calldata);
| 26,688 |
0 | // solhint-disable-next-line max-line-length https:github.com/OpenZeppelin/openzeppelin-contracts-upgradeable/blob/f9b6fc3fdab7aca33a9cfa8837c5cd7f67e176be/contracts/utils/AddressUpgradeable.solL177 | if (success) {
if (returndata.length == 0) {
| if (success) {
if (returndata.length == 0) {
| 4,146 |
34 | // The Comptroller token contract | Comptroller private comptroller = Comptroller(0x3d9819210A31b4961b30EF54bE2aeD79B9c9Cd3B);
address public owner;
| Comptroller private comptroller = Comptroller(0x3d9819210A31b4961b30EF54bE2aeD79B9c9Cd3B);
address public owner;
| 33,731 |
7 | // This event MUST happen before source's events | emit AssetSourceUpdated(assets[i], sources[i]);
_updateAssetSource(IPriceFeed(sources[i]));
| emit AssetSourceUpdated(assets[i], sources[i]);
_updateAssetSource(IPriceFeed(sources[i]));
| 81,206 |
25 | // Get all the passengers which need to be credited for the flight | PassengerInsurance[] memory passengerInsurancesForFlight
= passengerInsurances[flightKey];
for (uint256 i = 0; i < passengerInsurancesForFlight.length; i++) {
address passengerAddress = passengerInsurancesForFlight[i]
.passengerAddress;
uint256 insuranceValue = passengerInsurancesForFlight[i].value + passengerInsurancesForFlight[i].value.div(2);
| PassengerInsurance[] memory passengerInsurancesForFlight
= passengerInsurances[flightKey];
for (uint256 i = 0; i < passengerInsurancesForFlight.length; i++) {
address passengerAddress = passengerInsurancesForFlight[i]
.passengerAddress;
uint256 insuranceValue = passengerInsurancesForFlight[i].value + passengerInsurancesForFlight[i].value.div(2);
| 13,799 |
15 | // return the token being sold. / | function getToken()
public view
returns (IERC20)
| function getToken()
public view
returns (IERC20)
| 17,857 |
383 | // Save borrow market updates | borrowMarket.blockNumber = block.number;
borrowMarket.totalBorrows = localResults
.newTotalBorrows_ProtocolUnderwaterAsset;
| borrowMarket.blockNumber = block.number;
borrowMarket.totalBorrows = localResults
.newTotalBorrows_ProtocolUnderwaterAsset;
| 26,177 |
43 | // Admin list does not contain the creators address! | require(containsSender);
_;
| require(containsSender);
_;
| 30,455 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.