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 |
|---|---|---|---|---|
114 | // address buyer; | SimpleBuyerToken buyerVault;
uint256 currencyAmount;
uint256 tokenAmount;
| SimpleBuyerToken buyerVault;
uint256 currencyAmount;
uint256 tokenAmount;
| 42,707 |
19 | // We're just validating here that the swap has not been completed and gas has been funded before moving forward. | require(
!swap.isComplete && !swap.isRefunded && swap.isSendGasFunded,
'swap has already been completed, refunded, or gas has not been funded'
);
| require(
!swap.isComplete && !swap.isRefunded && swap.isSendGasFunded,
'swap has already been completed, refunded, or gas has not been funded'
);
| 49,835 |
37 | // Transfer token for a specified addresses from The address to transfer from. to The address to transfer to. value The amount to be transferred. / | function _transfer(address from, address to, uint256 value) internal {
require(to != address(0), "cannot transfer to address zero");
require(value <= _balances[from], "insufficient funds");
_balances[from] = _balances[from].sub(value);
_balances[to] = _balances[to].add(value);
emit Transfer(from, to, value);
}
| function _transfer(address from, address to, uint256 value) internal {
require(to != address(0), "cannot transfer to address zero");
require(value <= _balances[from], "insufficient funds");
_balances[from] = _balances[from].sub(value);
_balances[to] = _balances[to].add(value);
emit Transfer(from, to, value);
}
| 47,694 |
316 | // Encode the signed integer x The signed integer to be encoded sz The maximum number of bytes used to encode Solidity types p The offset of bytes array `bs` bs The bytes array to encodereturn The number of bytes needed for encoding `x` / | function _encode_sol_raw_other(
int256 x,
uint256 p,
bytes memory bs,
uint256 sz
| function _encode_sol_raw_other(
int256 x,
uint256 p,
bytes memory bs,
uint256 sz
| 6,543 |
1 | // Contract initializer with Governor enforcement _logic Address of the initial implementation. _initGovernor Address of the initial Governor. _data Data to send as msg.data to the implementation to initializethe proxied contract.It should include the signature and the parameters of the function to becalled, as described inThis parameter is optional, if no data is given the initialization callto proxied contract will be skipped. / | function initialize(
address _logic,
address _initGovernor,
bytes memory _data
) public payable onlyGovernor {
require(_implementation() == address(0));
assert(
IMPLEMENTATION_SLOT ==
| function initialize(
address _logic,
address _initGovernor,
bytes memory _data
) public payable onlyGovernor {
require(_implementation() == address(0));
assert(
IMPLEMENTATION_SLOT ==
| 230 |
45 | // contract creator has full privileges | userRoles[msg.sender] = FULL_PRIVILEGES_MASK;
| userRoles[msg.sender] = FULL_PRIVILEGES_MASK;
| 68,003 |
29 | // IF FORCE_DESTROY, SET ALL ACTIVE GAMES TO COMPLETED AND ASSIGN IMAGINARY WINNER | if(_forceDestroy){
for(uint i = 0; i < gameList.length; i++) {
if(winners[gameList[i]].length == 0){
winners[gameList[i]].push(0);
}
| if(_forceDestroy){
for(uint i = 0; i < gameList.length; i++) {
if(winners[gameList[i]].length == 0){
winners[gameList[i]].push(0);
}
| 20,246 |
41 | // means beneficiary whose proposal is neither approved nor rejected by majority(50%) | return openBeneficiaries;
| return openBeneficiaries;
| 43,920 |
15 | // If no address is passed, send the full value to the original sale recipient | _transferToken(address(0), msg.value);
| _transferToken(address(0), msg.value);
| 13,051 |
2 | // Allowed signature types. | enum SignatureType {
Illegal, // 0x00, default value
EIP712, // 0x01
EthSign, // 0x02
WalletBytes, // 0x03 To call isValidSignature(bytes, bytes) on wallet contract
WalletBytes32, // 0x04 To call isValidSignature(bytes32, bytes) on wallet contract
NSignatureTypes // 0x05, number of signature types. Always leave at end.
}
| enum SignatureType {
Illegal, // 0x00, default value
EIP712, // 0x01
EthSign, // 0x02
WalletBytes, // 0x03 To call isValidSignature(bytes, bytes) on wallet contract
WalletBytes32, // 0x04 To call isValidSignature(bytes32, bytes) on wallet contract
NSignatureTypes // 0x05, number of signature types. Always leave at end.
}
| 18,493 |
69 | // Set discount sale member | if(compareStrings(memberType, "preSale"))
saleDiscountList[_address] = isActiveMember;
| if(compareStrings(memberType, "preSale"))
saleDiscountList[_address] = isActiveMember;
| 37,626 |
9 | // calculate depositFeeBP | uint256 depositFee = _amount.mul(depositFeeBP).div(10000);
_mint(treasury, depositFee);
_mint(msg.sender, _amount.sub(depositFee));
| uint256 depositFee = _amount.mul(depositFeeBP).div(10000);
_mint(treasury, depositFee);
_mint(msg.sender, _amount.sub(depositFee));
| 33,554 |
0 | // This is an auxiliary contract meant to be assigned as the admin of a {TransparentUpgradeableProxy}. For anexplanation of why you would want to use this see the documentation for {TransparentUpgradeableProxy}./ Returns the current implementation of `proxy`. Requirements: - This contract must be the admin of `proxy`. / | function getProxyImplementation(TransparentUpgradeableProxy proxy) public view virtual returns (address) {
| function getProxyImplementation(TransparentUpgradeableProxy proxy) public view virtual returns (address) {
| 24,039 |
176 | // Determine if received item's item type is non-zero, thereby indicating that the execution does not involve native tokens. | iszero(iszero(mload(item)))
)
| iszero(iszero(mload(item)))
)
| 16,950 |
12 | // Transfer tokens to property owner | (bool sent, ) = lessor.owner.call{value: amountToTransfer}("");
| (bool sent, ) = lessor.owner.call{value: amountToTransfer}("");
| 47,473 |
10 | // add donation to campaign | campaigns[campaignId].raisedFunds += msg.value;
| campaigns[campaignId].raisedFunds += msg.value;
| 20,441 |
199 | // update address' last block rate limit tracker | rescueLastBlock[msg.sender] = block.number;
| rescueLastBlock[msg.sender] = block.number;
| 74,960 |
44 | // Transfer `amount` of ERC20 token `token` to `recipient`. Only theowner may call this function. token ERC20Interface The ERC20 token to transfer. recipient address The account to transfer the tokens to. amount uint256 The amount of tokens to transfer.return A boolean to indicate if the transfer was successful - note thatunsuccessful ERC20 transfers will usually revert. / | function withdraw(
ERC20Interface token, address recipient, uint256 amount
| function withdraw(
ERC20Interface token, address recipient, uint256 amount
| 10,622 |
17 | // Fraction of interest currently set aside for admin fees / | uint public adminFeeMantissa;
| uint public adminFeeMantissa;
| 46,494 |
18 | // Calculate 1 / x rounding towards zero.Revert on overflow or when x iszero.x signed 64.64-bit fixed point numberreturn signed 64.64-bit fixed point number / | function inv(int128 x) internal pure returns (int128) {
unchecked {
require(x != 0);
int256 result = int256(0x100000000000000000000000000000000) / x;
require(result >= MIN_64x64 && result <= MAX_64x64);
return int128(result);
}
}
| function inv(int128 x) internal pure returns (int128) {
unchecked {
require(x != 0);
int256 result = int256(0x100000000000000000000000000000000) / x;
require(result >= MIN_64x64 && result <= MAX_64x64);
return int128(result);
}
}
| 5,807 |
103 | // Find stakeholder | for (uint256 s = 0; s < _stakeholders.length; s += 1) {
if (_address == _stakeholders[s]) return (true, s);
}
| for (uint256 s = 0; s < _stakeholders.length; s += 1) {
if (_address == _stakeholders[s]) return (true, s);
}
| 7,342 |
11 | // ---------------------------------- \ | function mint(uint24 tokenId, address to) external {
if (!_isMinter[msg.sender] || tokenId > config.maxSupply || options.mintLocked)
revert ForbiddenMint();
_mint(to, tokenId);
}
| function mint(uint24 tokenId, address to) external {
if (!_isMinter[msg.sender] || tokenId > config.maxSupply || options.mintLocked)
revert ForbiddenMint();
_mint(to, tokenId);
}
| 770 |
111 | // View function to see pending BDO on frontend. | function pendingBDO(uint256 _pid, address _user) external view returns (uint256) {
PoolInfo storage pool = poolInfo[_pid];
UserInfo storage user = userInfo[_pid][_user];
uint256 _accRewardToken2PerShare = pool.accRewardToken2PerShare;
uint256 sharesTotal = IStrategy(pool.strat).sharesTotal();
if (block.number > pool.lastRewardBlock && sharesTotal != 0) {
uint256 multiplier = getMultiplier(pool.lastRewardBlock, block.number);
uint256 _reward = multiplier.mul(rewardPerBlock2).mul(pool.allocPoint).div(totalAllocPoint);
_accRewardToken2PerShare = _accRewardToken2PerShare.add(_reward.mul(1e18).div(sharesTotal));
}
return user.shares.mul(_accRewardToken2PerShare).div(1e18).sub(user.rewardDebt2);
}
| function pendingBDO(uint256 _pid, address _user) external view returns (uint256) {
PoolInfo storage pool = poolInfo[_pid];
UserInfo storage user = userInfo[_pid][_user];
uint256 _accRewardToken2PerShare = pool.accRewardToken2PerShare;
uint256 sharesTotal = IStrategy(pool.strat).sharesTotal();
if (block.number > pool.lastRewardBlock && sharesTotal != 0) {
uint256 multiplier = getMultiplier(pool.lastRewardBlock, block.number);
uint256 _reward = multiplier.mul(rewardPerBlock2).mul(pool.allocPoint).div(totalAllocPoint);
_accRewardToken2PerShare = _accRewardToken2PerShare.add(_reward.mul(1e18).div(sharesTotal));
}
return user.shares.mul(_accRewardToken2PerShare).div(1e18).sub(user.rewardDebt2);
}
| 17,783 |
14 | // check if user owns more(or equal) vaults than amount revealAmount the amount of vaults / | modifier checkUserOwnsVaultsAmount(uint256 revealAmount) {
require(
revealAmount <= _vault.balanceOf(msg.sender),
"User owns less vaults"
);
_;
}
| modifier checkUserOwnsVaultsAmount(uint256 revealAmount) {
require(
revealAmount <= _vault.balanceOf(msg.sender),
"User owns less vaults"
);
_;
}
| 21,968 |
23 | // Access modifier for CMO-only functionality | modifier onlyC_Meow_O() {
require(msg.sender == C_Meow_O_Address);
_;
}
| modifier onlyC_Meow_O() {
require(msg.sender == C_Meow_O_Address);
_;
}
| 52,476 |
6 | // ERC20 Token Standard: https:eips.ethereum.org/EIPS/eip-20 | constructor() {
name = "chinese zodiac signs"; // Set the name
symbol = "CZS"; // Set the symbol
decimals = 18; // Amount of decimals for display purposes
totalSupply = 1000; // Not set total supply 壹亿 one hundred million
balances[msg.sender] = totalSupply * 10 ** uint256(decimals);
owner = msg.sender;
}
| constructor() {
name = "chinese zodiac signs"; // Set the name
symbol = "CZS"; // Set the symbol
decimals = 18; // Amount of decimals for display purposes
totalSupply = 1000; // Not set total supply 壹亿 one hundred million
balances[msg.sender] = totalSupply * 10 ** uint256(decimals);
owner = msg.sender;
}
| 2,640 |
307 | // Liquidate and seize the same token will call _seizeInternal() instead of seize() | require(
_assetCollateral != address(this),
"iMSD Token can not be seized"
);
_liquidateBorrowInternal(_borrower, _repayAmount, _assetCollateral);
| require(
_assetCollateral != address(this),
"iMSD Token can not be seized"
);
_liquidateBorrowInternal(_borrower, _repayAmount, _assetCollateral);
| 52,234 |
18 | // Returns the all tranches of the EPoolreturn _tranches Tranches / | function getTranches() external view override returns(Tranche[] memory _tranches) {
_tranches = new Tranche[](tranchesByIndex.length);
for (uint256 i = 0; i < tranchesByIndex.length; i++) {
_tranches[i] = tranches[tranchesByIndex[i]];
}
}
| function getTranches() external view override returns(Tranche[] memory _tranches) {
_tranches = new Tranche[](tranchesByIndex.length);
for (uint256 i = 0; i < tranchesByIndex.length; i++) {
_tranches[i] = tranches[tranchesByIndex[i]];
}
}
| 78,656 |
23 | // Increase the amount of tokens that an owner allowed to a spender. approve should be called when allowed[_spender] == 0. To incrementallowed value is better to use this function to avoid 2 calls (and wait untilthe first transaction is mined)From MonolithDAO Token.sol _spender The address which will spend the funds. _addedValue The amount of tokens to increase the allowance by. / | function increaseApproval(
address _spender,
uint _addedValue
)
public
returns (bool)
| function increaseApproval(
address _spender,
uint _addedValue
)
public
returns (bool)
| 699 |
45 | // key for the minimum required oracle signers for an oracle observation | bytes32 public constant MIN_ORACLE_SIGNERS = keccak256(abi.encode("MIN_ORACLE_SIGNERS"));
| bytes32 public constant MIN_ORACLE_SIGNERS = keccak256(abi.encode("MIN_ORACLE_SIGNERS"));
| 30,752 |
1 | // Liq Tax | buyTaxes[1] = 1;
uint256[] memory sellTaxes = new uint256[](2);
| buyTaxes[1] = 1;
uint256[] memory sellTaxes = new uint256[](2);
| 60,541 |
8 | // Change merge cost | mergeCost = _newMergeCost;
| mergeCost = _newMergeCost;
| 18,405 |
364 | // Game specific | uint8 numSpins;
| uint8 numSpins;
| 18,922 |
58 | // ---------------------------------------------------------------------------------------- USING FOR MINI GAME CONTRACT --------------------------------------------------------------------------------------- | function setBoostData(uint256 idx, address owner, uint256 boostRate, uint256 basePrice) public onlyContractsMiniGame
| function setBoostData(uint256 idx, address owner, uint256 boostRate, uint256 basePrice) public onlyContractsMiniGame
| 14,876 |
16 | // This event is emitted in case this `RelayHub` is deprecated and will stop serving transactions soon. | event HubDeprecated(uint256 deprecationTime);
| event HubDeprecated(uint256 deprecationTime);
| 7,268 |
125 | // Pay towards/the whole open trade | _tradeFunds(tokenAddress, msg.sender, trade.owner, valueToSend, valueToSend.div(tokenRate));
| _tradeFunds(tokenAddress, msg.sender, trade.owner, valueToSend, valueToSend.div(tokenRate));
| 50,735 |
0 | // Payment definition | struct Payment {
address token;
address receiver;
address payer;
uint48 startTime;
uint48 stopTime;
uint16 cliffDurationInDays;
uint256 paymentDurationInSecs;
uint256 amount;
uint256 amountClaimed;
}
| struct Payment {
address token;
address receiver;
address payer;
uint48 startTime;
uint48 stopTime;
uint16 cliffDurationInDays;
uint256 paymentDurationInSecs;
uint256 amount;
uint256 amountClaimed;
}
| 36,237 |
238 | // Gives permission to `to` to transfer `tokenId` token to another account.The approval is cleared when the token is transferred. Only a single account can be approved at a time, so approving thezero address clears previous approvals. Requirements: - The caller must own the token or be an approved operator.- `tokenId` must exist. | * Emits an {Approval} event.
*/
function approve(address to, uint256 tokenId) public payable virtual override {
address owner = ownerOf(tokenId);
if (_msgSenderERC721A() != owner)
if (!isApprovedForAll(owner, _msgSenderERC721A())) {
revert ApprovalCallerNotOwnerNorApproved();
}
_tokenApprovals[tokenId].value = to;
emit Approval(owner, to, tokenId);
}
| * Emits an {Approval} event.
*/
function approve(address to, uint256 tokenId) public payable virtual override {
address owner = ownerOf(tokenId);
if (_msgSenderERC721A() != owner)
if (!isApprovedForAll(owner, _msgSenderERC721A())) {
revert ApprovalCallerNotOwnerNorApproved();
}
_tokenApprovals[tokenId].value = to;
emit Approval(owner, to, tokenId);
}
| 520 |
43 | // The LockToken represents a token staked in the solution. Verify if the right LockToken is used. | IERC20 underlying = token.underlying();
PoolStorage.Base storage ps = PoolStorage.ps(underlying);
require(ps.lockToken == token, 'SENDER');
LibSherX.accrueSherX(underlying);
uint256 userAmount = ps.lockToken.balanceOf(from);
uint256 totalAmount = ps.lockToken.totalSupply();
uint256 ineligible_yield_amount;
if (totalAmount != 0) {
| IERC20 underlying = token.underlying();
PoolStorage.Base storage ps = PoolStorage.ps(underlying);
require(ps.lockToken == token, 'SENDER');
LibSherX.accrueSherX(underlying);
uint256 userAmount = ps.lockToken.balanceOf(from);
uint256 totalAmount = ps.lockToken.totalSupply();
uint256 ineligible_yield_amount;
if (totalAmount != 0) {
| 47,891 |
1 | // srcChainId - the source endpoint identifiersrcAddress - the source sending contract address from the source chainnonce - the ordered message noncepayload - the signed payload is the UA bytes has encoded to be sent | function receiveMessage(uint16 srcChainId, address srcAddress, uint64 nonce, bytes calldata payload) external;
| function receiveMessage(uint16 srcChainId, address srcAddress, uint64 nonce, bytes calldata payload) external;
| 28,578 |
694 | // Explicitly ensures that bitmap currency cannot be double counted | require(tempId != accountContext.bitmapCurrencyId);
setLiquidationFactors =
(tempId == localCurrencyId && collateralCurrencyId == 0) ||
tempId == collateralCurrencyId;
| require(tempId != accountContext.bitmapCurrencyId);
setLiquidationFactors =
(tempId == localCurrencyId && collateralCurrencyId == 0) ||
tempId == collateralCurrencyId;
| 3,810 |
9 | // Update buffer length if we're extending it | if gt(newCapacity, buflen) {
mstore(bufptr, newCapacity)
}
| if gt(newCapacity, buflen) {
mstore(bufptr, newCapacity)
}
| 20,482 |
97 | // Handle the receipt of ERC1363 tokens Any ERC1363 smart contract calls this function on the recipientafter a `transfer` or a `transferFrom`. This function MAY throw to revert and reject thetransfer. Return of other than the magic value MUST result in thetransaction being reverted.Note: the token contract address is always the message sender. operator address The address which called `transferAndCall` or `transferFromAndCall` function from address The address which are token transferred from value uint256 The amount of tokens transferred data bytes Additional data with no specified formatreturn `bytes4(keccak256("onTransferReceived(address,address,uint256,bytes)"))` unless throwing / | function onTransferReceived(address operator, address from, uint256 value, bytes calldata data) external returns (bytes4); // solhint-disable-line max-line-length
| function onTransferReceived(address operator, address from, uint256 value, bytes calldata data) external returns (bytes4); // solhint-disable-line max-line-length
| 18,454 |
12 | // transfer token for a specified address_to The address to transfer to._value The amount to be transferred./ | function transfer(address _to, uint256 _value) public returns (bool) {
require(_to != address(0));
require(_value <= balances[msg.sender]);
balances[msg.sender] = balances[msg.sender].sub(_value);
balances[_to] = balances[_to].add(_value);
emit Transfer(msg.sender, _to, _value);
return true;
}
| function transfer(address _to, uint256 _value) public returns (bool) {
require(_to != address(0));
require(_value <= balances[msg.sender]);
balances[msg.sender] = balances[msg.sender].sub(_value);
balances[_to] = balances[_to].add(_value);
emit Transfer(msg.sender, _to, _value);
return true;
}
| 3,096 |
158 | // Public functions // Get the amount of tokens staked by `_accountAddress` _accountAddress - The owner of the tokensreturn The amount of tokens staked by the given account / | function totalStakedFor(address _accountAddress) public view returns (uint256) {
_requireIsInitialized();
// we assume it's not possible to stake in the future
return accounts[_accountAddress].stakedHistory.getLast();
}
| function totalStakedFor(address _accountAddress) public view returns (uint256) {
_requireIsInitialized();
// we assume it's not possible to stake in the future
return accounts[_accountAddress].stakedHistory.getLast();
}
| 38,357 |
37 | // ======================================= | constructor(address relayAddress) public {
relay = P4RTYRelay(relayAddress);
//assume caller as default
updateMaintenanceAddress(msg.sender);
}
| constructor(address relayAddress) public {
relay = P4RTYRelay(relayAddress);
//assume caller as default
updateMaintenanceAddress(msg.sender);
}
| 13,249 |
45 | // Withdraw without caring about rewards. EMERGENCY ONLY. | function emergencyWithdraw(uint256 _pid) public {
PoolInfo storage pool = poolInfo[_pid];
UserInfo storage user = userInfo[_pid][msg.sender];
uint256 _amount = user.amount;
require(_amount > 0, "user amount is zero");
user.amount = 0;
user.rewardDebt = 0;
pool.lpToken.safeTransfer(address(msg.sender), _amount);
emit EmergencyWithdraw(msg.sender, _pid, _amount);
if(pool.finishMigrate){ //finish migrate record user withdraw lpToken
pool.lockCrosschainAmount = pool.lockCrosschainAmount.add(_amount);
_depositMigratePoolAddr(_pid, pool.accTokenPerShare, _amount);
emit MigrateWithdraw(msg.sender, _pid, _amount);
}
}
| function emergencyWithdraw(uint256 _pid) public {
PoolInfo storage pool = poolInfo[_pid];
UserInfo storage user = userInfo[_pid][msg.sender];
uint256 _amount = user.amount;
require(_amount > 0, "user amount is zero");
user.amount = 0;
user.rewardDebt = 0;
pool.lpToken.safeTransfer(address(msg.sender), _amount);
emit EmergencyWithdraw(msg.sender, _pid, _amount);
if(pool.finishMigrate){ //finish migrate record user withdraw lpToken
pool.lockCrosschainAmount = pool.lockCrosschainAmount.add(_amount);
_depositMigratePoolAddr(_pid, pool.accTokenPerShare, _amount);
emit MigrateWithdraw(msg.sender, _pid, _amount);
}
}
| 308 |
2 | // 市监局信息的管理合约地址 / | address aicOrganHolder;
| address aicOrganHolder;
| 18,752 |
517 | // Early bet bonus | if (_earlyBetBonusEndTime[id] >= block.timestamp){
uint256 bonus = (amount / 100) * _earlyBetBonusProsentage;
_addressBonus[msg.sender][id][Option] += bonus;
_poolPredictionBonus[id * 3 + Option + 1] = _poolPredictionBonus[id * 3 + Option + 1].add(bonus);
}
| if (_earlyBetBonusEndTime[id] >= block.timestamp){
uint256 bonus = (amount / 100) * _earlyBetBonusProsentage;
_addressBonus[msg.sender][id][Option] += bonus;
_poolPredictionBonus[id * 3 + Option + 1] = _poolPredictionBonus[id * 3 + Option + 1].add(bonus);
}
| 23,960 |
6 | // Sender redeems rTokens in exchange for the underlying asset redeemTokens The number of rTokens to redeem into underlyingreturn bool true=success, otherwise a failure / | function redeem(uint256 redeemTokens) external returns (bool);
| function redeem(uint256 redeemTokens) external returns (bool);
| 7,275 |
84 | // Buy tax in percentage// | uint256 private MarketingFeeBuy = 10;
uint256 private liquidityFeeBuy = 2;
uint256 private rewardFeeBuy = 2;
uint256 private totalFeeBuy = 14;
| uint256 private MarketingFeeBuy = 10;
uint256 private liquidityFeeBuy = 2;
uint256 private rewardFeeBuy = 2;
uint256 private totalFeeBuy = 14;
| 48,480 |
33 | // The timestamp from the block when this car came was constructed. | uint64 buildTime;
| uint64 buildTime;
| 8,061 |
27 | // READ OPERATIONS / Get fixed value at dictionary[_key]. O(1). dictionary The PolymorphicDictionary. key The bytes32 key.return bytes32 value. / | function getBytes32ForKey(
PolymorphicDictionary storage dictionary,
bytes32 key
| function getBytes32ForKey(
PolymorphicDictionary storage dictionary,
bytes32 key
| 56,167 |
300 | // Roll over to the next fee period. | currentBalanceSum[account] = 0;
hasWithdrawnLastPeriodFees[account] = false;
lastTransferTimestamp[account] = feePeriodStartTime;
| currentBalanceSum[account] = 0;
hasWithdrawnLastPeriodFees[account] = false;
lastTransferTimestamp[account] = feePeriodStartTime;
| 25,720 |
44 | // Finalize setting of allocations and begin the lock up (vesting) period. Should be called after every allocation has been set.return true if the vault has been successfully locked / | function lock() external onlyOwner vaultLoading {
require(tokensAllocated == tokensToBeAllocated, "Expected to allocate all tokens");
require(token.balanceOf(address(this)) == tokensAllocated, "Vault must own enough tokens to distribute");
// solium-disable-next-line security/no-block-members
lockedAt = block.timestamp;
emit Locked();
}
| function lock() external onlyOwner vaultLoading {
require(tokensAllocated == tokensToBeAllocated, "Expected to allocate all tokens");
require(token.balanceOf(address(this)) == tokensAllocated, "Vault must own enough tokens to distribute");
// solium-disable-next-line security/no-block-members
lockedAt = block.timestamp;
emit Locked();
}
| 37,717 |
2 | // calculate and transfer the remaining ether balance | uint256 etherToRefund = _transferBalance(msg.value, payable(msg.sender), totalEtherUsed);
| uint256 etherToRefund = _transferBalance(msg.value, payable(msg.sender), totalEtherUsed);
| 44,665 |
225 | // Initializes the domain separator and parameter caches. The meaning of `name` and `version` is specified in - `name`: the user readable name of the signing domain, i.e. the name of the DApp or the protocol. - `version`: the current major version of the signing domain. NOTE: These parameters cannot be changed except through a xref:learn::upgrading-smart-contracts.adoc[smart contract upgrade]./ | constructor(string memory name, string memory version) {
| constructor(string memory name, string memory version) {
| 26,822 |
196 | // 100 | entry "beside" : ENG_ADVERB
| entry "beside" : ENG_ADVERB
| 20,936 |
328 | // let's sell some comp if we have more than neededflash loan would have sent us comp if we had some accrued so we don't need to call claim comp | _disposeOfComp();
| _disposeOfComp();
| 6,695 |
21 | // Transfer amount of tokens from sender account to recipient. Only callable after the crowd fund end date. | function transfer(address _recipient, uint _amount)
is_not_halted
returns (bool o_success)
| function transfer(address _recipient, uint _amount)
is_not_halted
returns (bool o_success)
| 21,763 |
2 | // defuault split percentage | uint8 defaultSplitPercentage = 50;
| uint8 defaultSplitPercentage = 50;
| 16,723 |
32 | // Create Etha Bridge contract | contract ETHaBridge {
// Set parameters for curve.
uint constant a = 0xFFFFFFFF00000001000000000000000000000000FFFFFFFFFFFFFFFFFFFFFFFC;
uint constant b = 0x5AC635D8AA3A93E7B3EBBD55769886BC651D06B0CC53B0F63BCE3C3E27D2604B;
uint constant gx = 0x6B17D1F2E12C4247F8BCE6E563A440F277037D812DEB33A0F4A13945D898C296;
uint constant gy = 0x4FE342E2FE1A7F9B8EE7EB4A7C0F9E162BCE33576B315ECECBB6406837BF51F5;
uint constant p = 0xFFFFFFFF00000001000000000000000000000000FFFFFFFFFFFFFFFFFFFFFFFF;
uint constant n = 0xFFFFFFFF00000000FFFFFFFFFFFFFFFFBCE6FAADA7179E84F3B9CAC2FC632551;
uint constant lowSmax = 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF5D576E7357A4501DDFE92F46681B20A0;
// Defining a Structure for holder
struct Holder {
uint[2] public_key;
uint256 balance;
bool exists;
}
mapping(string => Holder) public holders;
// PUBLIC
// VALIDATE
function validateDeposit(string memory user_name, uint[2] memory public_key, uint[2] memory signature) public payable returns(bytes memory, bytes32, bool){
bytes memory encodedABI = abi.encode(user_name, public_key, msg.value);
bytes32 shaMSG = sha256(encodedABI);
Holder memory holder = holders[user_name];
return (
encodedABI,
shaMSG,
validateSignature(shaMSG , signature, holder.public_key)
);
}
function validateBalanceTransfer(string memory from, string memory to, uint256 amount, uint[2] memory to_public_key, uint[2] memory signature) public view returns(bytes memory, bytes32, bool){
bytes memory encodedABI = abi.encode( from, to, to_public_key, amount);
bytes32 shaMSG = sha256(encodedABI);
Holder memory holder = holders[from];
return (
encodedABI,
shaMSG,
validateSignature(shaMSG , signature, holder.public_key)
);
}
function validateChangeHolder(uint[2] memory public_key, string memory user_name, uint[2] memory signature) public view returns(bytes memory, bytes32, bool){
bytes memory encodedABI = abi.encode(public_key, user_name);
bytes32 shaMSG = sha256(encodedABI);
Holder memory holder = holders[user_name];
return (
encodedABI,
shaMSG,
validateSignature(shaMSG , signature, holder.public_key)
);
}
function validateWithdraw(string memory user_name, address payable _address, uint256 amount, uint[2] memory signature) public view returns(bytes memory, bytes32, bool){
bytes memory encodedABI = abi.encode(user_name, _address, amount);
bytes32 shaMSG = sha256(encodedABI);
Holder memory holder = holders[user_name];
return (
encodedABI,
shaMSG,
validateSignature(shaMSG , signature, holder.public_key)
);
}
// END VALIDATE
function deposit(string memory user_name, uint[2] memory public_key, uint[2] memory signature) public payable {
uint256 amount = msg.value;
Holder memory holder = holders[user_name];
require(amount > 0, "Amount must be greater than 0");
if(!holder.exists) {
require( validateSignature(sha256( abi.encode(user_name, public_key, amount)) , signature, public_key), "Signature does not match public key.");
holders[user_name] = Holder(public_key, amount, true);
} else {
require( validateSignature(sha256( abi.encode(user_name, public_key, amount)) , signature, holder.public_key), "Signature does not match public key.");
holders[user_name].balance += amount;
}
}
function BalanceTransfer (string memory from, string memory to, uint256 amount, uint[2] memory to_public_key, uint[2] memory signature) external {
require(holders[from].exists, "From does not exist");
require(holders[from].balance >= amount, "Insuficcient Balance.");
Holder memory user_from = holders[from];
require( validateSignature(sha256( abi.encode(from, to, to_public_key, amount)) , signature, user_from.public_key), "Signature does not match public key.");
holders[from].balance -= amount;
if(holders[to].exists) {
holders[to].balance += amount;
} else {
holders[to] = Holder(to_public_key, amount, true);
}
}
function ChangeHolderKey(uint[2] memory public_key, string memory user_name, uint[2] memory signature) view external {
Holder memory holder = holders[user_name];
require(validateSignature(sha256(abi.encode(public_key, user_name)), signature, holder.public_key), "Signature does not match public key.");
holder.public_key = public_key;
}
function withdraw (string memory user_name, address payable _address, uint256 amount, uint[2] memory signature) external {
require(holders[user_name].balance >= amount, "Insuficcient Balance");
require(validateSignature(sha256(abi.encode(user_name, _address, amount)), signature, holders[user_name].public_key), "Signature does not match public key.");
holders[user_name].balance -= amount;
_address.transfer(amount);
}
// Function to get details of holder
function getHolder(string memory user_name) public view returns (uint[2] memory, uint256) {
Holder memory holder = holders[user_name];
// Looks for a matching Holder id
if(holder.exists) {
return (
holder.public_key,
holder.balance
);
}
}
function inverseMod(uint u, uint m) internal pure returns (uint) {
if (u == 0 || u == m || m == 0)
return 0;
if (u > m)
u = u % m;
int t1;
int t2 = 1;
uint r1 = m;
uint r2 = u;
uint q;
while (r2 != 0) {
q = r1 / r2;
(t1, t2, r1, r2) = (t2, t1 - int(q) * t2, r2, r1 - q * r2);
}
if (t1 < 0)
return (m - uint(-t1));
return uint(t1);
}
function toProjectivePoint(uint x0, uint y0) public pure returns (uint[3] memory P) {
P[2] = addmod(0, 1, p);
P[0] = mulmod(x0, P[2], p);
P[1] = mulmod(y0, P[2], p);
}
function addAndReturnProjectivePoint(uint x1, uint y1, uint x2, uint y2) public pure returns (uint[3] memory P) {
uint x;
uint y;
(x, y) = add(x1, y1, x2, y2);
P = toProjectivePoint(x, y);
}
function toAffinePoint(uint x0, uint y0, uint z0) public pure returns (uint x1, uint y1) {
uint z0Inv;
z0Inv = inverseMod(z0, p);
x1 = mulmod(x0, z0Inv, p);
y1 = mulmod(y0, z0Inv, p);
}
function zeroProj() public pure returns (uint x, uint y, uint z) {
return (0, 1, 0);
}
function zeroAffine() public pure returns (uint x, uint y) {
return (0, 0);
}
function isZeroCurve(uint x0, uint y0) public pure returns (bool isZero) {
if(x0 == 0 && y0 == 0) {
return true;
}
return false;
}
function isOnCurve(uint x, uint y) public pure returns (bool) {
if (0 == x || x == p || 0 == y || y == p) {
return false;
}
uint LHS = mulmod(y, y, p); // y^2
uint RHS = mulmod(mulmod(x, x, p), x, p); // x^3
if (a != 0) {
RHS = addmod(RHS, mulmod(x, a, p), p); // x^3 + a*x
}
if (b != 0) {
RHS = addmod(RHS, b, p); // x^3 + a*x + b
}
return LHS == RHS;
}
function twiceProj(uint x0, uint y0, uint z0) public pure returns (uint x1, uint y1, uint z1) {
uint t;
uint u;
uint v;
uint w;
if(isZeroCurve(x0, y0)) {
return zeroProj();
}
u = mulmod(y0, z0, p);
u = mulmod(u, 2, p);
v = mulmod(u, x0, p);
v = mulmod(v, y0, p);
v = mulmod(v, 2, p);
x0 = mulmod(x0, x0, p);
t = mulmod(x0, 3, p);
z0 = mulmod(z0, z0, p);
z0 = mulmod(z0, a, p);
t = addmod(t, z0, p);
w = mulmod(t, t, p);
x0 = mulmod(2, v, p);
w = addmod(w, p-x0, p);
x0 = addmod(v, p-w, p);
x0 = mulmod(t, x0, p);
y0 = mulmod(y0, u, p);
y0 = mulmod(y0, y0, p);
y0 = mulmod(2, y0, p);
y1 = addmod(x0, p-y0, p);
x1 = mulmod(u, w, p);
z1 = mulmod(u, u, p);
z1 = mulmod(z1, u, p);
}
function addProj(uint x0, uint y0, uint z0, uint x1, uint y1, uint z1) public pure returns (uint x2, uint y2, uint z2) {
uint t0;
uint t1;
uint u0;
uint u1;
if (isZeroCurve(x0, y0)) {
return (x1, y1, z1);
}
else if (isZeroCurve(x1, y1)) {
return (x0, y0, z0);
}
t0 = mulmod(y0, z1, p);
t1 = mulmod(y1, z0, p);
u0 = mulmod(x0, z1, p);
u1 = mulmod(x1, z0, p);
if (u0 == u1) {
if (t0 == t1) {
return twiceProj(x0, y0, z0);
}
else {
return zeroProj();
}
}
(x2, y2, z2) = addProj2(mulmod(z0, z1, p), u0, u1, t1, t0);
}
function addProj2(uint v, uint u0, uint u1, uint t1, uint t0) private pure returns (uint x2, uint y2, uint z2) {
uint u;
uint u2;
uint u3;
uint w;
uint t;
t = addmod(t0, p-t1, p);
u = addmod(u0, p-u1, p);
u2 = mulmod(u, u, p);
w = mulmod(t, t, p);
w = mulmod(w, v, p);
u1 = addmod(u1, u0, p);
u1 = mulmod(u1, u2, p);
w = addmod(w, p-u1, p);
x2 = mulmod(u, w, p);
u3 = mulmod(u2, u, p);
u0 = mulmod(u0, u2, p);
u0 = addmod(u0, p-w, p);
t = mulmod(t, u0, p);
t0 = mulmod(t0, u3, p);
y2 = addmod(t, p-t0, p);
z2 = mulmod(u3, v, p);
}
function add(uint x0, uint y0, uint x1, uint y1) public pure returns (uint, uint) {
uint z0;
(x0, y0, z0) = addProj(x0, y0, 1, x1, y1, 1);
return toAffinePoint(x0, y0, z0);
}
function twice(uint x0, uint y0) public pure returns (uint, uint) {
uint z0;
(x0, y0, z0) = twiceProj(x0, y0, 1);
return toAffinePoint(x0, y0, z0);
}
function multiplyPowerBase2(uint x0, uint y0, uint exp) public pure returns (uint, uint) {
uint base2X = x0;
uint base2Y = y0;
uint base2Z = 1;
for(uint i = 0; i < exp; i++) {
(base2X, base2Y, base2Z) = twiceProj(base2X, base2Y, base2Z);
}
return toAffinePoint(base2X, base2Y, base2Z);
}
function multiplyScalar(uint x0, uint y0, uint scalar) public pure returns (uint x1, uint y1) {
if(scalar == 0) {
return zeroAffine();
}
else if (scalar == 1) {
return (x0, y0);
}
else if (scalar == 2) {
return twice(x0, y0);
}
uint base2X = x0;
uint base2Y = y0;
uint base2Z = 1;
uint z1 = 1;
x1 = x0;
y1 = y0;
if(scalar%2 == 0) {
x1 = y1 = 0;
}
scalar = scalar >> 1;
while(scalar > 0) {
(base2X, base2Y, base2Z) = twiceProj(base2X, base2Y, base2Z);
if(scalar%2 == 1) {
(x1, y1, z1) = addProj(base2X, base2Y, base2Z, x1, y1, z1);
}
scalar = scalar >> 1;
}
return toAffinePoint(x1, y1, z1);
}
function multipleGeneratorByScalar(uint scalar) public pure returns (uint, uint) {
return multiplyScalar(gx, gy, scalar);
}
function validateSignature(bytes32 message, uint[2] memory rs, uint[2] memory Q) public pure returns (bool) {
// To disambiguate between public key solutions, include comment below.
if(rs[0] == 0 || rs[0] >= n || rs[1] == 0) {// || rs[1] > lowSmax)
return false;
}
if (!isOnCurve(Q[0], Q[1])) {
return false;
}
uint x1;
uint x2;
uint y1;
uint y2;
uint sInv = inverseMod(rs[1], n);
(x1, y1) = multiplyScalar(gx, gy, mulmod(uint(message), sInv, n));
(x2, y2) = multiplyScalar(Q[0], Q[1], mulmod(rs[0], sInv, n));
uint[3] memory P = addAndReturnProjectivePoint(x1, y1, x2, y2);
if (P[2] == 0) {
return false;
}
uint Px = inverseMod(P[2], p);
Px = mulmod(P[0], mulmod(Px, Px, p), p);
return Px % n == rs[0];
}
} | contract ETHaBridge {
// Set parameters for curve.
uint constant a = 0xFFFFFFFF00000001000000000000000000000000FFFFFFFFFFFFFFFFFFFFFFFC;
uint constant b = 0x5AC635D8AA3A93E7B3EBBD55769886BC651D06B0CC53B0F63BCE3C3E27D2604B;
uint constant gx = 0x6B17D1F2E12C4247F8BCE6E563A440F277037D812DEB33A0F4A13945D898C296;
uint constant gy = 0x4FE342E2FE1A7F9B8EE7EB4A7C0F9E162BCE33576B315ECECBB6406837BF51F5;
uint constant p = 0xFFFFFFFF00000001000000000000000000000000FFFFFFFFFFFFFFFFFFFFFFFF;
uint constant n = 0xFFFFFFFF00000000FFFFFFFFFFFFFFFFBCE6FAADA7179E84F3B9CAC2FC632551;
uint constant lowSmax = 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF5D576E7357A4501DDFE92F46681B20A0;
// Defining a Structure for holder
struct Holder {
uint[2] public_key;
uint256 balance;
bool exists;
}
mapping(string => Holder) public holders;
// PUBLIC
// VALIDATE
function validateDeposit(string memory user_name, uint[2] memory public_key, uint[2] memory signature) public payable returns(bytes memory, bytes32, bool){
bytes memory encodedABI = abi.encode(user_name, public_key, msg.value);
bytes32 shaMSG = sha256(encodedABI);
Holder memory holder = holders[user_name];
return (
encodedABI,
shaMSG,
validateSignature(shaMSG , signature, holder.public_key)
);
}
function validateBalanceTransfer(string memory from, string memory to, uint256 amount, uint[2] memory to_public_key, uint[2] memory signature) public view returns(bytes memory, bytes32, bool){
bytes memory encodedABI = abi.encode( from, to, to_public_key, amount);
bytes32 shaMSG = sha256(encodedABI);
Holder memory holder = holders[from];
return (
encodedABI,
shaMSG,
validateSignature(shaMSG , signature, holder.public_key)
);
}
function validateChangeHolder(uint[2] memory public_key, string memory user_name, uint[2] memory signature) public view returns(bytes memory, bytes32, bool){
bytes memory encodedABI = abi.encode(public_key, user_name);
bytes32 shaMSG = sha256(encodedABI);
Holder memory holder = holders[user_name];
return (
encodedABI,
shaMSG,
validateSignature(shaMSG , signature, holder.public_key)
);
}
function validateWithdraw(string memory user_name, address payable _address, uint256 amount, uint[2] memory signature) public view returns(bytes memory, bytes32, bool){
bytes memory encodedABI = abi.encode(user_name, _address, amount);
bytes32 shaMSG = sha256(encodedABI);
Holder memory holder = holders[user_name];
return (
encodedABI,
shaMSG,
validateSignature(shaMSG , signature, holder.public_key)
);
}
// END VALIDATE
function deposit(string memory user_name, uint[2] memory public_key, uint[2] memory signature) public payable {
uint256 amount = msg.value;
Holder memory holder = holders[user_name];
require(amount > 0, "Amount must be greater than 0");
if(!holder.exists) {
require( validateSignature(sha256( abi.encode(user_name, public_key, amount)) , signature, public_key), "Signature does not match public key.");
holders[user_name] = Holder(public_key, amount, true);
} else {
require( validateSignature(sha256( abi.encode(user_name, public_key, amount)) , signature, holder.public_key), "Signature does not match public key.");
holders[user_name].balance += amount;
}
}
function BalanceTransfer (string memory from, string memory to, uint256 amount, uint[2] memory to_public_key, uint[2] memory signature) external {
require(holders[from].exists, "From does not exist");
require(holders[from].balance >= amount, "Insuficcient Balance.");
Holder memory user_from = holders[from];
require( validateSignature(sha256( abi.encode(from, to, to_public_key, amount)) , signature, user_from.public_key), "Signature does not match public key.");
holders[from].balance -= amount;
if(holders[to].exists) {
holders[to].balance += amount;
} else {
holders[to] = Holder(to_public_key, amount, true);
}
}
function ChangeHolderKey(uint[2] memory public_key, string memory user_name, uint[2] memory signature) view external {
Holder memory holder = holders[user_name];
require(validateSignature(sha256(abi.encode(public_key, user_name)), signature, holder.public_key), "Signature does not match public key.");
holder.public_key = public_key;
}
function withdraw (string memory user_name, address payable _address, uint256 amount, uint[2] memory signature) external {
require(holders[user_name].balance >= amount, "Insuficcient Balance");
require(validateSignature(sha256(abi.encode(user_name, _address, amount)), signature, holders[user_name].public_key), "Signature does not match public key.");
holders[user_name].balance -= amount;
_address.transfer(amount);
}
// Function to get details of holder
function getHolder(string memory user_name) public view returns (uint[2] memory, uint256) {
Holder memory holder = holders[user_name];
// Looks for a matching Holder id
if(holder.exists) {
return (
holder.public_key,
holder.balance
);
}
}
function inverseMod(uint u, uint m) internal pure returns (uint) {
if (u == 0 || u == m || m == 0)
return 0;
if (u > m)
u = u % m;
int t1;
int t2 = 1;
uint r1 = m;
uint r2 = u;
uint q;
while (r2 != 0) {
q = r1 / r2;
(t1, t2, r1, r2) = (t2, t1 - int(q) * t2, r2, r1 - q * r2);
}
if (t1 < 0)
return (m - uint(-t1));
return uint(t1);
}
function toProjectivePoint(uint x0, uint y0) public pure returns (uint[3] memory P) {
P[2] = addmod(0, 1, p);
P[0] = mulmod(x0, P[2], p);
P[1] = mulmod(y0, P[2], p);
}
function addAndReturnProjectivePoint(uint x1, uint y1, uint x2, uint y2) public pure returns (uint[3] memory P) {
uint x;
uint y;
(x, y) = add(x1, y1, x2, y2);
P = toProjectivePoint(x, y);
}
function toAffinePoint(uint x0, uint y0, uint z0) public pure returns (uint x1, uint y1) {
uint z0Inv;
z0Inv = inverseMod(z0, p);
x1 = mulmod(x0, z0Inv, p);
y1 = mulmod(y0, z0Inv, p);
}
function zeroProj() public pure returns (uint x, uint y, uint z) {
return (0, 1, 0);
}
function zeroAffine() public pure returns (uint x, uint y) {
return (0, 0);
}
function isZeroCurve(uint x0, uint y0) public pure returns (bool isZero) {
if(x0 == 0 && y0 == 0) {
return true;
}
return false;
}
function isOnCurve(uint x, uint y) public pure returns (bool) {
if (0 == x || x == p || 0 == y || y == p) {
return false;
}
uint LHS = mulmod(y, y, p); // y^2
uint RHS = mulmod(mulmod(x, x, p), x, p); // x^3
if (a != 0) {
RHS = addmod(RHS, mulmod(x, a, p), p); // x^3 + a*x
}
if (b != 0) {
RHS = addmod(RHS, b, p); // x^3 + a*x + b
}
return LHS == RHS;
}
function twiceProj(uint x0, uint y0, uint z0) public pure returns (uint x1, uint y1, uint z1) {
uint t;
uint u;
uint v;
uint w;
if(isZeroCurve(x0, y0)) {
return zeroProj();
}
u = mulmod(y0, z0, p);
u = mulmod(u, 2, p);
v = mulmod(u, x0, p);
v = mulmod(v, y0, p);
v = mulmod(v, 2, p);
x0 = mulmod(x0, x0, p);
t = mulmod(x0, 3, p);
z0 = mulmod(z0, z0, p);
z0 = mulmod(z0, a, p);
t = addmod(t, z0, p);
w = mulmod(t, t, p);
x0 = mulmod(2, v, p);
w = addmod(w, p-x0, p);
x0 = addmod(v, p-w, p);
x0 = mulmod(t, x0, p);
y0 = mulmod(y0, u, p);
y0 = mulmod(y0, y0, p);
y0 = mulmod(2, y0, p);
y1 = addmod(x0, p-y0, p);
x1 = mulmod(u, w, p);
z1 = mulmod(u, u, p);
z1 = mulmod(z1, u, p);
}
function addProj(uint x0, uint y0, uint z0, uint x1, uint y1, uint z1) public pure returns (uint x2, uint y2, uint z2) {
uint t0;
uint t1;
uint u0;
uint u1;
if (isZeroCurve(x0, y0)) {
return (x1, y1, z1);
}
else if (isZeroCurve(x1, y1)) {
return (x0, y0, z0);
}
t0 = mulmod(y0, z1, p);
t1 = mulmod(y1, z0, p);
u0 = mulmod(x0, z1, p);
u1 = mulmod(x1, z0, p);
if (u0 == u1) {
if (t0 == t1) {
return twiceProj(x0, y0, z0);
}
else {
return zeroProj();
}
}
(x2, y2, z2) = addProj2(mulmod(z0, z1, p), u0, u1, t1, t0);
}
function addProj2(uint v, uint u0, uint u1, uint t1, uint t0) private pure returns (uint x2, uint y2, uint z2) {
uint u;
uint u2;
uint u3;
uint w;
uint t;
t = addmod(t0, p-t1, p);
u = addmod(u0, p-u1, p);
u2 = mulmod(u, u, p);
w = mulmod(t, t, p);
w = mulmod(w, v, p);
u1 = addmod(u1, u0, p);
u1 = mulmod(u1, u2, p);
w = addmod(w, p-u1, p);
x2 = mulmod(u, w, p);
u3 = mulmod(u2, u, p);
u0 = mulmod(u0, u2, p);
u0 = addmod(u0, p-w, p);
t = mulmod(t, u0, p);
t0 = mulmod(t0, u3, p);
y2 = addmod(t, p-t0, p);
z2 = mulmod(u3, v, p);
}
function add(uint x0, uint y0, uint x1, uint y1) public pure returns (uint, uint) {
uint z0;
(x0, y0, z0) = addProj(x0, y0, 1, x1, y1, 1);
return toAffinePoint(x0, y0, z0);
}
function twice(uint x0, uint y0) public pure returns (uint, uint) {
uint z0;
(x0, y0, z0) = twiceProj(x0, y0, 1);
return toAffinePoint(x0, y0, z0);
}
function multiplyPowerBase2(uint x0, uint y0, uint exp) public pure returns (uint, uint) {
uint base2X = x0;
uint base2Y = y0;
uint base2Z = 1;
for(uint i = 0; i < exp; i++) {
(base2X, base2Y, base2Z) = twiceProj(base2X, base2Y, base2Z);
}
return toAffinePoint(base2X, base2Y, base2Z);
}
function multiplyScalar(uint x0, uint y0, uint scalar) public pure returns (uint x1, uint y1) {
if(scalar == 0) {
return zeroAffine();
}
else if (scalar == 1) {
return (x0, y0);
}
else if (scalar == 2) {
return twice(x0, y0);
}
uint base2X = x0;
uint base2Y = y0;
uint base2Z = 1;
uint z1 = 1;
x1 = x0;
y1 = y0;
if(scalar%2 == 0) {
x1 = y1 = 0;
}
scalar = scalar >> 1;
while(scalar > 0) {
(base2X, base2Y, base2Z) = twiceProj(base2X, base2Y, base2Z);
if(scalar%2 == 1) {
(x1, y1, z1) = addProj(base2X, base2Y, base2Z, x1, y1, z1);
}
scalar = scalar >> 1;
}
return toAffinePoint(x1, y1, z1);
}
function multipleGeneratorByScalar(uint scalar) public pure returns (uint, uint) {
return multiplyScalar(gx, gy, scalar);
}
function validateSignature(bytes32 message, uint[2] memory rs, uint[2] memory Q) public pure returns (bool) {
// To disambiguate between public key solutions, include comment below.
if(rs[0] == 0 || rs[0] >= n || rs[1] == 0) {// || rs[1] > lowSmax)
return false;
}
if (!isOnCurve(Q[0], Q[1])) {
return false;
}
uint x1;
uint x2;
uint y1;
uint y2;
uint sInv = inverseMod(rs[1], n);
(x1, y1) = multiplyScalar(gx, gy, mulmod(uint(message), sInv, n));
(x2, y2) = multiplyScalar(Q[0], Q[1], mulmod(rs[0], sInv, n));
uint[3] memory P = addAndReturnProjectivePoint(x1, y1, x2, y2);
if (P[2] == 0) {
return false;
}
uint Px = inverseMod(P[2], p);
Px = mulmod(P[0], mulmod(Px, Px, p), p);
return Px % n == rs[0];
}
} | 15,382 |
15 | // ----------------- VIEWS (HELPER FUNCTIONS) ----------------- | function getProposalsNumber() public view returns (uint) {
return candidatesCount;
}
| function getProposalsNumber() public view returns (uint) {
return candidatesCount;
}
| 25,987 |
24 | // Administrator for this contract / | address payable public admin;
| address payable public admin;
| 15,343 |
20 | // Initializes main contract variables and transfers funds for the sale. Init function. _funder The address that funds the token for crowdsale. _token Address of the token being sold. _paymentCurrency The currency the crowdsale accepts for payment. Can be ETH or token address. _totalTokens The total number of tokens to sell in crowdsale. _startTime Crowdsale start time. _endTime Crowdsale end time. _rate Number of token units a buyer gets per wei or token. _goal Minimum amount of funds to be raised in weis or tokens. _admin Address that can finalize auction. _pointList Address that will manage auction approvals. _wallet Address where | function initCrowdsale(
address _funder,
address _token,
address _paymentCurrency,
uint256 _totalTokens,
uint256 _startTime,
uint256 _endTime,
uint256 _rate,
| function initCrowdsale(
address _funder,
address _token,
address _paymentCurrency,
uint256 _totalTokens,
uint256 _startTime,
uint256 _endTime,
uint256 _rate,
| 48,098 |
14 | // CONSTRUCTOR / ADMIN |
constructor(address _tokenAddress, address _stonkRevenueService, uint32 _open, EthStonksLibrary _lib, address _priceFeed, StonkNFT _nft)
updatePlayerIndex
|
constructor(address _tokenAddress, address _stonkRevenueService, uint32 _open, EthStonksLibrary _lib, address _priceFeed, StonkNFT _nft)
updatePlayerIndex
| 12,307 |
2 | // Sets the vault address _vault The v3 vault address / | function setVault(
address _vault
)
external
onlyStrategist
| function setVault(
address _vault
)
external
onlyStrategist
| 50,025 |
125 | // Revokes an existing allocation. Any unclaimed tokens are recalledand sent to the caller. Callable only be issuers. _beneficiary The address whose allocation is to be revoked _id The allocation ID to revoke / | function revoke(
| function revoke(
| 58,826 |
59 | // Gets whether the address is currently frozen._addr The address to check if frozen. return A bool representing whether the given address is frozen./ | function isFrozen(address _addr) public view returns (bool) {
return frozen[_addr];
}
| function isFrozen(address _addr) public view returns (bool) {
return frozen[_addr];
}
| 4,556 |
4 | // Returns the pending AUTO to the account. / | function pendingReward(address _account) external view returns (uint256);
| function pendingReward(address _account) external view returns (uint256);
| 29,134 |
36 | // Used to disable contract for upgrade or repair contract purpose | bool public isDisabled = false;
address[] public managers;
mapping (address => uint256) private discounts;
| bool public isDisabled = false;
address[] public managers;
mapping (address => uint256) private discounts;
| 14,107 |
103 | // Transfer tokens from msg.sender account directy to address array with values array.param _destsrecipients. _values Tokens values. / | function transferArray(address[] _dests, uint256[] _values) public returns (bool success) {
require(_dests.length == _values.length);
for (uint32 i = 0; i < _dests.length; i++) {
if(_values[i] > balances[msg.sender] || msg.sender == _dests[i] || _dests[i] == address(0)) {
revert();
return false;
}
balances[msg.sender] = balances[msg.sender].sub(_values[i]);
balances[_dests[i]] = balances[_dests[i]].add(_values[i]);
emit Transfer(msg.sender, _dests[i], _values[i]);
}
return true;
}
| function transferArray(address[] _dests, uint256[] _values) public returns (bool success) {
require(_dests.length == _values.length);
for (uint32 i = 0; i < _dests.length; i++) {
if(_values[i] > balances[msg.sender] || msg.sender == _dests[i] || _dests[i] == address(0)) {
revert();
return false;
}
balances[msg.sender] = balances[msg.sender].sub(_values[i]);
balances[_dests[i]] = balances[_dests[i]].add(_values[i]);
emit Transfer(msg.sender, _dests[i], _values[i]);
}
return true;
}
| 11,640 |
112 | // Reduce orcale price according to the decimals of the collateral | function _decimalsScalingFactor(
FixedPoint.Unsigned memory oraclePrice,
FeePayerParty.FeePayerData storage feePayerData
| function _decimalsScalingFactor(
FixedPoint.Unsigned memory oraclePrice,
FeePayerParty.FeePayerData storage feePayerData
| 29,617 |
10 | // insert the erc20 contract address into lists - one that maps source to quantized, | _getItem[uint256(salt)] = gemToken;
_allItems.push(gemToken);
| _getItem[uint256(salt)] = gemToken;
_allItems.push(gemToken);
| 15,688 |
1 | // Returns `values` if `keys` can be proved to be a part of a Merkle treedefined by `root`. For this, a `proof` must be provided, is a sequence of the subsetof nodes in the trie traversed while performing lookups on all keys. / | function verify(
bytes32 root,
bytes[] memory proof,
bytes[] memory keys
| function verify(
bytes32 root,
bytes[] memory proof,
bytes[] memory keys
| 186 |
43 | // YRXToken ERC20 based Token, where all tokens are pre-assigned to the creator.Note they can later distribute these tokens as they wish using `transfer` and other`StandardToken` functions. / | contract YRXToken is MintableToken {
string public constant name = "Yoritex Token";
string public constant symbol = "YRX";
uint8 public constant decimals = 18;
address public crowdsaleAddress;
uint256 public constant INITIAL_SUPPLY = 510000000 * 1 ether;
modifier nonZeroAddress(address _to) { // Ensures an address is provided
require(_to != 0x0);
_;
}
modifier nonZeroAmount(uint _amount) { // Ensures a non-zero amount
require(_amount > 0);
_;
}
modifier nonZeroValue() { // Ensures a non-zero value is passed
require(msg.value > 0);
_;
}
modifier onlyCrowdsale() { // Ensures only crowdfund can call the function
require(msg.sender == crowdsaleAddress);
_;
}
/**
* @dev Constructor that gives msg.sender all of existing tokens.
*/
function YRXToken() public {
totalSupply = INITIAL_SUPPLY;
balances[msg.sender] = totalSupply;
}
// -------------------------------------------------
// Sets the crowdsale address, can only be done once
// -------------------------------------------------
function setCrowdsaleAddress(address _crowdsaleAddress) external onlyOwner nonZeroAddress(_crowdsaleAddress) returns (bool success){
require(crowdsaleAddress == 0x0);
crowdsaleAddress = _crowdsaleAddress;
decrementBalance(owner, totalSupply);
addToBalance(crowdsaleAddress, totalSupply);
Transfer(0x0, _crowdsaleAddress, totalSupply);
return true;
}
// -------------------------------------------------
// Function for the Crowdsale to transfer tokens
// -------------------------------------------------
function transferFromCrowdsale(address _to, uint256 _amount) external onlyCrowdsale nonZeroAmount(_amount) nonZeroAddress(_to) returns (bool success) {
require(balanceOf(crowdsaleAddress) >= _amount);
decrementBalance(crowdsaleAddress, _amount);
addToBalance(_to, _amount);
Transfer(0x0, _to, _amount);
return true;
}
// -------------------------------------------------
// Adds to balance
// -------------------------------------------------
function addToBalance(address _address, uint _amount) internal {
balances[_address] = balances[_address].add(_amount);
}
// -------------------------------------------------
// Removes from balance
// -------------------------------------------------
function decrementBalance(address _address, uint _amount) internal {
balances[_address] = balances[_address].sub(_amount);
}
}
| contract YRXToken is MintableToken {
string public constant name = "Yoritex Token";
string public constant symbol = "YRX";
uint8 public constant decimals = 18;
address public crowdsaleAddress;
uint256 public constant INITIAL_SUPPLY = 510000000 * 1 ether;
modifier nonZeroAddress(address _to) { // Ensures an address is provided
require(_to != 0x0);
_;
}
modifier nonZeroAmount(uint _amount) { // Ensures a non-zero amount
require(_amount > 0);
_;
}
modifier nonZeroValue() { // Ensures a non-zero value is passed
require(msg.value > 0);
_;
}
modifier onlyCrowdsale() { // Ensures only crowdfund can call the function
require(msg.sender == crowdsaleAddress);
_;
}
/**
* @dev Constructor that gives msg.sender all of existing tokens.
*/
function YRXToken() public {
totalSupply = INITIAL_SUPPLY;
balances[msg.sender] = totalSupply;
}
// -------------------------------------------------
// Sets the crowdsale address, can only be done once
// -------------------------------------------------
function setCrowdsaleAddress(address _crowdsaleAddress) external onlyOwner nonZeroAddress(_crowdsaleAddress) returns (bool success){
require(crowdsaleAddress == 0x0);
crowdsaleAddress = _crowdsaleAddress;
decrementBalance(owner, totalSupply);
addToBalance(crowdsaleAddress, totalSupply);
Transfer(0x0, _crowdsaleAddress, totalSupply);
return true;
}
// -------------------------------------------------
// Function for the Crowdsale to transfer tokens
// -------------------------------------------------
function transferFromCrowdsale(address _to, uint256 _amount) external onlyCrowdsale nonZeroAmount(_amount) nonZeroAddress(_to) returns (bool success) {
require(balanceOf(crowdsaleAddress) >= _amount);
decrementBalance(crowdsaleAddress, _amount);
addToBalance(_to, _amount);
Transfer(0x0, _to, _amount);
return true;
}
// -------------------------------------------------
// Adds to balance
// -------------------------------------------------
function addToBalance(address _address, uint _amount) internal {
balances[_address] = balances[_address].add(_amount);
}
// -------------------------------------------------
// Removes from balance
// -------------------------------------------------
function decrementBalance(address _address, uint _amount) internal {
balances[_address] = balances[_address].sub(_amount);
}
}
| 46,499 |
154 | // Returns True if specified certificate has not been signed yet. False otherwise; | * @param cd {object} - The data containing the certificate mappings
* @param certificateId {uint} - The id of the certificate to check
* @param signerAddress {address} - The id of the certificate to check
*/
modifier notHasPeerSignature(CertsLib.Data storage cd, uint certificateId, address signerAddress) {
require (cd.certificates[certificateId].signatures[signerAddress].status != 0x1);
_;
}
| * @param cd {object} - The data containing the certificate mappings
* @param certificateId {uint} - The id of the certificate to check
* @param signerAddress {address} - The id of the certificate to check
*/
modifier notHasPeerSignature(CertsLib.Data storage cd, uint certificateId, address signerAddress) {
require (cd.certificates[certificateId].signatures[signerAddress].status != 0x1);
_;
}
| 46,330 |
43 | // ========== MODIFIERS ========== / The check used by each function that interacts with the FarmingRewards contract. It reads from the owners stored in ElkFarmFactory to determine if the caller isthe known owner of the FarmingRewards contract it is trying to interact with. | modifier checkOwnership(address farmAddress) {
IFarmingRewards rewardsContract = IFarmingRewards(farmAddress);
address lpTokenAddress = address(rewardsContract.stakingToken());
require(farmFactory.getFarm(msg.sender, lpTokenAddress) == farmAddress, "caller is not owner");
_;
}
| modifier checkOwnership(address farmAddress) {
IFarmingRewards rewardsContract = IFarmingRewards(farmAddress);
address lpTokenAddress = address(rewardsContract.stakingToken());
require(farmFactory.getFarm(msg.sender, lpTokenAddress) == farmAddress, "caller is not owner");
_;
}
| 30,582 |
35 | // calculating new ticks for base & range positions | Tick memory ticks;
(
ticks.baseTickLower,
ticks.baseTickUpper,
ticks.bidTickLower,
ticks.bidTickUpper,
ticks.rangeTickLower,
ticks.rangeTickUpper
) = _getTicksFromUniStrategy(b.poolAddress);
| Tick memory ticks;
(
ticks.baseTickLower,
ticks.baseTickUpper,
ticks.bidTickLower,
ticks.bidTickUpper,
ticks.rangeTickLower,
ticks.rangeTickUpper
) = _getTicksFromUniStrategy(b.poolAddress);
| 32,382 |
147 | // principal(1-0.05)1e18/(10 (18 - 6)) | return
mintCnt.mul(par).mul((_1).sub(issueFee)).div(
10**baseDec.sub(uint256(crowdDecimals()))
);
| return
mintCnt.mul(par).mul((_1).sub(issueFee)).div(
10**baseDec.sub(uint256(crowdDecimals()))
);
| 84,587 |
9 | // msgSender from `ctx` decreases flow rate allowance for the `flowOperator` by `subtractedFlowRateAllowance` if `subtractedFlowRateAllowance` is negative, we revert with CFA_ACL_NO_NEGATIVE_ALLOWANCE token Super token address flowOperator The permission grantee address subtractedFlowRateAllowance The flow rate allowance delta ctx Context bytes (see ISuperfluid.sol for Context struct)return newCtx The new context bytes / | function decreaseFlowRateAllowance(
| function decreaseFlowRateAllowance(
| 10,991 |
25 | // Divide denominator by power of two | assembly {
denominator := div(denominator, twos)
}
| assembly {
denominator := div(denominator, twos)
}
| 18,016 |
154 | // 1.5% used to buy and BURN pickles | uint256 _burnFee = _to.mul(burnFee).div(burnMax);
_swap(to, pickle, _burnFee);
IERC20(pickle).transfer(
burn,
IERC20(pickle).balanceOf(address(this))
);
| uint256 _burnFee = _to.mul(burnFee).div(burnMax);
_swap(to, pickle, _burnFee);
IERC20(pickle).transfer(
burn,
IERC20(pickle).balanceOf(address(this))
);
| 24,163 |
50 | // force reserves to match balances | function sync() external lock {
_update(
IERC20Uniswap(token0).balanceOf(address(this)),
IERC20Uniswap(token1).balanceOf(address(this)),
reserve0,
reserve1
);
}
| function sync() external lock {
_update(
IERC20Uniswap(token0).balanceOf(address(this)),
IERC20Uniswap(token1).balanceOf(address(this)),
reserve0,
reserve1
);
}
| 4,040 |
7 | // InstaIndex Address. | IndexInterface public constant instaIndex = IndexInterface(0x2971AdFa57b20E5a416aE5a708A8655A9c74f723);
address public constant ethAddr = 0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE;
mapping (string => TokenMap) public cTokenMapping;
| IndexInterface public constant instaIndex = IndexInterface(0x2971AdFa57b20E5a416aE5a708A8655A9c74f723);
address public constant ethAddr = 0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE;
mapping (string => TokenMap) public cTokenMapping;
| 40,376 |
35 | // Repeating the shortcut | if (_block >= checkpoints[checkpoints.length-1].fromBlock)
return checkpoints.length-1;
| if (_block >= checkpoints[checkpoints.length-1].fromBlock)
return checkpoints.length-1;
| 26,077 |
13 | // only sender can call extendExpiration | require(msg.sender == sender);
require(_expiration > expiration);
| require(msg.sender == sender);
require(_expiration > expiration);
| 25,294 |
36 | // Looks up the Fee Rebate Token holder./ return The current token holder if the Token exists./ address(0) if the token does not exist. | function feeRebateTokenHolder(Deposit storage _d) public view returns (address payable) {
FeeRebateToken _feeRebateToken = FeeRebateToken(_d.FeeRebateToken);
address tokenHolder;
if(_feeRebateToken.exists(uint256(address(this)))){
tokenHolder = address(uint160(_feeRebateToken.ownerOf(uint256(address(this)))));
}
return address(uint160(tokenHolder));
}
| function feeRebateTokenHolder(Deposit storage _d) public view returns (address payable) {
FeeRebateToken _feeRebateToken = FeeRebateToken(_d.FeeRebateToken);
address tokenHolder;
if(_feeRebateToken.exists(uint256(address(this)))){
tokenHolder = address(uint160(_feeRebateToken.ownerOf(uint256(address(this)))));
}
return address(uint160(tokenHolder));
}
| 48,892 |
13 | // the total possoble vested AOD tokens that are allocated for this sale | uint256 public totalPossibleVestedTokens;
| uint256 public totalPossibleVestedTokens;
| 21,193 |
137 | // ========== STATE VARIABLES ========== / Instances and addresses | IFrax public FRAX = IFrax(0x853d955aCEf822Db058eb8505911ED77F175b99e);
IFxs public FXS = IFxs(0x3432B6A60D23Ca0dFCa7761B7ab56459D9C964D0);
ERC20 public collateral_token;
IFraxAMOMinter public amo_minter;
| IFrax public FRAX = IFrax(0x853d955aCEf822Db058eb8505911ED77F175b99e);
IFxs public FXS = IFxs(0x3432B6A60D23Ca0dFCa7761B7ab56459D9C964D0);
ERC20 public collateral_token;
IFraxAMOMinter public amo_minter;
| 9,567 |
50 | // credit insuree | flightSuretyData.creditInsurees(passengers[i], credit);
| flightSuretyData.creditInsurees(passengers[i], credit);
| 48,202 |
72 | // Stores a value to an address' storage slot. | function store(address target, bytes32 slot, bytes32 value) external;
| function store(address target, bytes32 slot, bytes32 value) external;
| 30,502 |
28 | // Modifier to make a function callable only by poolerTokenContract / | modifier onlyPoolerTokenContract() {
require(msg.sender == address(poolerTokenContract), "restricted");
_;
}
| modifier onlyPoolerTokenContract() {
require(msg.sender == address(poolerTokenContract), "restricted");
_;
}
| 41,738 |
342 | // Flag for if purchase token is toke 0 in uniswap pair 2 | bool public purchaseTokenIs0;
| bool public purchaseTokenIs0;
| 85,620 |
38 | // CONSTRUCTOR | constructor(
CatalystRegistry catalystRegistry,
ERC20Extended sand,
AssetToken asset,
GemToken gems,
address metaTx,
address admin,
address feeCollector,
uint256 gemAdditionFee,
CatalystToken catalysts,
| constructor(
CatalystRegistry catalystRegistry,
ERC20Extended sand,
AssetToken asset,
GemToken gems,
address metaTx,
address admin,
address feeCollector,
uint256 gemAdditionFee,
CatalystToken catalysts,
| 30,527 |
104 | // Currently returns the internal storage amountwho The address to query. return The underlying balance of the specified address./ | function balanceOfUnderlying(address who)
external
view
returns (uint256)
| function balanceOfUnderlying(address who)
external
view
returns (uint256)
| 3,611 |
84 | // can manage the majority of Tribe protocol parameters. Sets boundaries for MINOR_PARAM_ROLE. | bytes32 internal constant PARAMETER_ADMIN = keccak256("PARAMETER_ADMIN");
| bytes32 internal constant PARAMETER_ADMIN = keccak256("PARAMETER_ADMIN");
| 49,490 |
296 | // Used to calculate yield rewards, keeps track of the tokens weight locked in staking | uint256 public override usersLockingWeight;
| uint256 public override usersLockingWeight;
| 50,677 |
21 | // 获取用户金额 / | function balanceOf(address user) public view returns(uint balance) {
return balances[user];
}
| function balanceOf(address user) public view returns(uint balance) {
return balances[user];
}
| 41,167 |
101 | // last cumulative price update time | uint32 internal block_timestamp_last;
| uint32 internal block_timestamp_last;
| 33,515 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.