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 |
|---|---|---|---|---|
2 | // Validators hub contract object. | voteNvalidate public validatorsHub;
| voteNvalidate public validatorsHub;
| 44,324 |
91 | // Token Id to image hash | mapping(uint256 => string) private _tokenImageHashes;
| mapping(uint256 => string) private _tokenImageHashes;
| 10,419 |
2 | // Constructor that gives msg.sender all of existing tokens./ | constructor(
string memory name,
string memory symbol,
uint256 initialSupply
| constructor(
string memory name,
string memory symbol,
uint256 initialSupply
| 13,283 |
85 | // Refuse any incoming ETH value with calls | fallback() external payable {
revert("Do not send ETH with your call");
}
| fallback() external payable {
revert("Do not send ETH with your call");
}
| 769 |
5 | // Inspired by Curve's Gauge | uint256 veBoostedLpBalance = (lpBalance * TOKENLESS_PRODUCTION) / 100;
if (vePendleSupply > 0) {
veBoostedLpBalance +=
(((_totalStaked() * vePendleBalance) / vePendleSupply) *
(100 - TOKENLESS_PRODUCTION)) /
100;
}
| uint256 veBoostedLpBalance = (lpBalance * TOKENLESS_PRODUCTION) / 100;
if (vePendleSupply > 0) {
veBoostedLpBalance +=
(((_totalStaked() * vePendleBalance) / vePendleSupply) *
(100 - TOKENLESS_PRODUCTION)) /
100;
}
| 7,189 |
10 | // Emitted when asset has been withdrawn | event Exit(address dst, uint256 value);
constructor(
address _ledger,
address _asset,
uint256 _wrapped
) {
auth[msg.sender] = 1;
live = 1;
ledger = LedgerLike(_ledger);
| event Exit(address dst, uint256 value);
constructor(
address _ledger,
address _asset,
uint256 _wrapped
) {
auth[msg.sender] = 1;
live = 1;
ledger = LedgerLike(_ledger);
| 459 |
30 | // } if (bytes(endorsementParams.distributorSensitiveData).length != 0) { | allPolicies[endorsementParams.onChainPolicyId].distributorSensitiveData = endorsementParams
.distributorSensitiveData;
| allPolicies[endorsementParams.onChainPolicyId].distributorSensitiveData = endorsementParams
.distributorSensitiveData;
| 14,060 |
29 | // Ensure `_who` is a participant. | modifier only_participants(address _who) { if (participants[_who] != 0) _; else throw; }
| modifier only_participants(address _who) { if (participants[_who] != 0) _; else throw; }
| 38,200 |
81 | // Address of the sdToken minter contract. | address public immutable minter;
| address public immutable minter;
| 29,541 |
72 | // 1. Check that reserves and balances are consistent (within 1%) | (uint256 r0, uint256 r1,) = lp.getReserves();
uint256 t0bal = token0.balanceOf(address(lp));
uint256 t1bal = token1.balanceOf(address(lp));
require(t0bal.mul(100) <= r0.mul(101), "bad t0 balance");
require(t1bal.mul(100) <= r1.mul(101), "bad t1 balance");
| (uint256 r0, uint256 r1,) = lp.getReserves();
uint256 t0bal = token0.balanceOf(address(lp));
uint256 t1bal = token1.balanceOf(address(lp));
require(t0bal.mul(100) <= r0.mul(101), "bad t0 balance");
require(t1bal.mul(100) <= r1.mul(101), "bad t1 balance");
| 15,005 |
366 | // ComptrollerCore Storage for the comptroller is at this address, while execution is delegated to the `comptrollerImplementation`.CTokens should reference this contract as their comptroller. / | contract Unitroller is UnitrollerAdminStorage, ComptrollerErrorReporter {
/**
* @notice Emitted when pendingComptrollerImplementation is changed
*/
event NewPendingImplementation(address oldPendingImplementation, address newPendingImplementation);
/**
* @notice Emitted when pendingComptrollerImplementation is accepted, which means comptroller implementation is updated
*/
event NewImplementation(address oldImplementation, address newImplementation);
/**
* @notice Emitted when pendingAdmin is changed
*/
event NewPendingAdmin(address oldPendingAdmin, address newPendingAdmin);
/**
* @notice Emitted when pendingAdmin is accepted, which means admin is updated
*/
event NewAdmin(address oldAdmin, address newAdmin);
constructor() public {
// Set admin to caller
admin = msg.sender;
}
/*** Admin Functions ***/
function _setPendingImplementation(address newPendingImplementation) public returns (uint) {
if (msg.sender != admin) {
return fail(Error.UNAUTHORIZED, FailureInfo.SET_PENDING_IMPLEMENTATION_OWNER_CHECK);
}
address oldPendingImplementation = pendingComptrollerImplementation;
pendingComptrollerImplementation = newPendingImplementation;
emit NewPendingImplementation(oldPendingImplementation, pendingComptrollerImplementation);
return uint(Error.NO_ERROR);
}
/**
* @notice Accepts new implementation of comptroller. msg.sender must be pendingImplementation
* @dev Admin function for new implementation to accept it's role as implementation
* @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)
*/
function _acceptImplementation() public returns (uint) {
// Check caller is pendingImplementation and pendingImplementation ≠ address(0)
if (msg.sender != pendingComptrollerImplementation || pendingComptrollerImplementation == address(0)) {
return fail(Error.UNAUTHORIZED, FailureInfo.ACCEPT_PENDING_IMPLEMENTATION_ADDRESS_CHECK);
}
// Save current values for inclusion in log
address oldImplementation = comptrollerImplementation;
address oldPendingImplementation = pendingComptrollerImplementation;
comptrollerImplementation = pendingComptrollerImplementation;
pendingComptrollerImplementation = address(0);
emit NewImplementation(oldImplementation, comptrollerImplementation);
emit NewPendingImplementation(oldPendingImplementation, pendingComptrollerImplementation);
return uint(Error.NO_ERROR);
}
/**
* @notice Begins transfer of admin rights. The newPendingAdmin must call `_acceptAdmin` to finalize the transfer.
* @dev Admin function to begin change of admin. The newPendingAdmin must call `_acceptAdmin` to finalize the transfer.
* @param newPendingAdmin New pending admin.
* @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)
*/
function _setPendingAdmin(address newPendingAdmin) public returns (uint) {
// Check caller = admin
if (msg.sender != admin) {
return fail(Error.UNAUTHORIZED, FailureInfo.SET_PENDING_ADMIN_OWNER_CHECK);
}
// Save current value, if any, for inclusion in log
address oldPendingAdmin = pendingAdmin;
// Store pendingAdmin with value newPendingAdmin
pendingAdmin = newPendingAdmin;
// Emit NewPendingAdmin(oldPendingAdmin, newPendingAdmin)
emit NewPendingAdmin(oldPendingAdmin, newPendingAdmin);
return uint(Error.NO_ERROR);
}
/**
* @notice Accepts transfer of admin rights. msg.sender must be pendingAdmin
* @dev Admin function for pending admin to accept role and update admin
* @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)
*/
function _acceptAdmin() public returns (uint) {
// Check caller is pendingAdmin and pendingAdmin ≠ address(0)
if (msg.sender != pendingAdmin || msg.sender == address(0)) {
return fail(Error.UNAUTHORIZED, FailureInfo.ACCEPT_ADMIN_PENDING_ADMIN_CHECK);
}
// Save current values for inclusion in log
address oldAdmin = admin;
address oldPendingAdmin = pendingAdmin;
// Store admin with value pendingAdmin
admin = pendingAdmin;
// Clear the pending value
pendingAdmin = address(0);
emit NewAdmin(oldAdmin, admin);
emit NewPendingAdmin(oldPendingAdmin, pendingAdmin);
return uint(Error.NO_ERROR);
}
/**
* @dev Delegates execution to an implementation contract.
* It returns to the external caller whatever the implementation returns
* or forwards reverts.
*/
function () payable external {
// delegate all other functions to current implementation
(bool success, ) = comptrollerImplementation.delegatecall(msg.data);
assembly {
let free_mem_ptr := mload(0x40)
returndatacopy(free_mem_ptr, 0, returndatasize)
switch success
case 0 { revert(free_mem_ptr, returndatasize) }
default { return(free_mem_ptr, returndatasize) }
}
}
}
| contract Unitroller is UnitrollerAdminStorage, ComptrollerErrorReporter {
/**
* @notice Emitted when pendingComptrollerImplementation is changed
*/
event NewPendingImplementation(address oldPendingImplementation, address newPendingImplementation);
/**
* @notice Emitted when pendingComptrollerImplementation is accepted, which means comptroller implementation is updated
*/
event NewImplementation(address oldImplementation, address newImplementation);
/**
* @notice Emitted when pendingAdmin is changed
*/
event NewPendingAdmin(address oldPendingAdmin, address newPendingAdmin);
/**
* @notice Emitted when pendingAdmin is accepted, which means admin is updated
*/
event NewAdmin(address oldAdmin, address newAdmin);
constructor() public {
// Set admin to caller
admin = msg.sender;
}
/*** Admin Functions ***/
function _setPendingImplementation(address newPendingImplementation) public returns (uint) {
if (msg.sender != admin) {
return fail(Error.UNAUTHORIZED, FailureInfo.SET_PENDING_IMPLEMENTATION_OWNER_CHECK);
}
address oldPendingImplementation = pendingComptrollerImplementation;
pendingComptrollerImplementation = newPendingImplementation;
emit NewPendingImplementation(oldPendingImplementation, pendingComptrollerImplementation);
return uint(Error.NO_ERROR);
}
/**
* @notice Accepts new implementation of comptroller. msg.sender must be pendingImplementation
* @dev Admin function for new implementation to accept it's role as implementation
* @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)
*/
function _acceptImplementation() public returns (uint) {
// Check caller is pendingImplementation and pendingImplementation ≠ address(0)
if (msg.sender != pendingComptrollerImplementation || pendingComptrollerImplementation == address(0)) {
return fail(Error.UNAUTHORIZED, FailureInfo.ACCEPT_PENDING_IMPLEMENTATION_ADDRESS_CHECK);
}
// Save current values for inclusion in log
address oldImplementation = comptrollerImplementation;
address oldPendingImplementation = pendingComptrollerImplementation;
comptrollerImplementation = pendingComptrollerImplementation;
pendingComptrollerImplementation = address(0);
emit NewImplementation(oldImplementation, comptrollerImplementation);
emit NewPendingImplementation(oldPendingImplementation, pendingComptrollerImplementation);
return uint(Error.NO_ERROR);
}
/**
* @notice Begins transfer of admin rights. The newPendingAdmin must call `_acceptAdmin` to finalize the transfer.
* @dev Admin function to begin change of admin. The newPendingAdmin must call `_acceptAdmin` to finalize the transfer.
* @param newPendingAdmin New pending admin.
* @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)
*/
function _setPendingAdmin(address newPendingAdmin) public returns (uint) {
// Check caller = admin
if (msg.sender != admin) {
return fail(Error.UNAUTHORIZED, FailureInfo.SET_PENDING_ADMIN_OWNER_CHECK);
}
// Save current value, if any, for inclusion in log
address oldPendingAdmin = pendingAdmin;
// Store pendingAdmin with value newPendingAdmin
pendingAdmin = newPendingAdmin;
// Emit NewPendingAdmin(oldPendingAdmin, newPendingAdmin)
emit NewPendingAdmin(oldPendingAdmin, newPendingAdmin);
return uint(Error.NO_ERROR);
}
/**
* @notice Accepts transfer of admin rights. msg.sender must be pendingAdmin
* @dev Admin function for pending admin to accept role and update admin
* @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)
*/
function _acceptAdmin() public returns (uint) {
// Check caller is pendingAdmin and pendingAdmin ≠ address(0)
if (msg.sender != pendingAdmin || msg.sender == address(0)) {
return fail(Error.UNAUTHORIZED, FailureInfo.ACCEPT_ADMIN_PENDING_ADMIN_CHECK);
}
// Save current values for inclusion in log
address oldAdmin = admin;
address oldPendingAdmin = pendingAdmin;
// Store admin with value pendingAdmin
admin = pendingAdmin;
// Clear the pending value
pendingAdmin = address(0);
emit NewAdmin(oldAdmin, admin);
emit NewPendingAdmin(oldPendingAdmin, pendingAdmin);
return uint(Error.NO_ERROR);
}
/**
* @dev Delegates execution to an implementation contract.
* It returns to the external caller whatever the implementation returns
* or forwards reverts.
*/
function () payable external {
// delegate all other functions to current implementation
(bool success, ) = comptrollerImplementation.delegatecall(msg.data);
assembly {
let free_mem_ptr := mload(0x40)
returndatacopy(free_mem_ptr, 0, returndatasize)
switch success
case 0 { revert(free_mem_ptr, returndatasize) }
default { return(free_mem_ptr, returndatasize) }
}
}
}
| 25,995 |
2 | // The EIP-712 typehash for the permit struct used by the contract | bytes32 public constant CLAIM_TYPEHASH = keccak256("Claim(address account,uint256 amount,uint256 nonce,uint256 deadline)");
| bytes32 public constant CLAIM_TYPEHASH = keccak256("Claim(address account,uint256 amount,uint256 nonce,uint256 deadline)");
| 19,073 |
15 | // Calculates ceil(a×b÷denominator) with full precision. Throws if result overflows a uint256 or denominator == 0/a The multiplicand/b The multiplier/denominator The divisor/ return result The 256-bit result | function mulDivRoundingUp(
uint256 a,
uint256 b,
uint256 denominator
| function mulDivRoundingUp(
uint256 a,
uint256 b,
uint256 denominator
| 26,633 |
32 | // Returns applications lengthtoken Token address/ | function getTokenAppsLength(address token) public view returns (uint) {
return tokenApps[token].length;
}
| function getTokenAppsLength(address token) public view returns (uint) {
return tokenApps[token].length;
}
| 11,319 |
52 | // Overrides ERC20._burn in order for burn and burnFrom to emitan additional Burn event. / | function _burn(address who, uint256 value) internal {
super._burn(who, value);
}
| function _burn(address who, uint256 value) internal {
super._burn(who, value);
}
| 2,892 |
6 | // Address which will exercise Man over the network i.e. add tokens, change validator set, conduct upgrades | address public networkGovernor;
| address public networkGovernor;
| 10,916 |
13 | // | interface IBEP20 {
/**
* @dev Returns the amount of tokens in existence.
*/
function totalSupply() external view returns (uint256);
/**
* @dev Returns the token decimals.
*/
function decimals() external view returns (uint8);
/**
* @dev Returns the token symbol.
*/
function symbol() external view returns (string memory);
/**
* @dev Returns the token name.
*/
function name() external view returns (string memory);
/**
* @dev Returns the bep token owner.
*/
function getOwner() external view returns (address);
/**
* @dev Returns the amount of tokens owned by `account`.
*/
function balanceOf(address account) external view returns (uint256);
/**
* @dev Moves `amount` tokens from the caller's account to `recipient`.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transfer(address recipient, uint256 amount) external returns (bool);
/**
* @dev Returns the remaining number of tokens that `spender` will be
* allowed to spend on behalf of `owner` through {transferFrom}. This is
* zero by default.
*
* This value changes when {approve} or {transferFrom} are called.
*/
function allowance(address _owner, address spender) external view returns (uint256);
/**
* @dev Sets `amount` as the allowance of `spender` over the caller's tokens.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* IMPORTANT: Beware that changing an allowance with this method brings the risk
* that someone may use both the old and the new allowance by unfortunate
* transaction ordering. One possible solution to mitigate this race
* condition is to first reduce the spender's allowance to 0 and set the
* desired value afterwards:
* https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
*
* Emits an {Approval} event.
*/
function approve(address spender, uint256 amount) external returns (bool);
/**
* @dev Moves `amount` tokens from `sender` to `recipient` using the
* allowance mechanism. `amount` is then deducted from the caller's
* allowance.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transferFrom(
address sender,
address recipient,
uint256 amount
) external returns (bool);
/**
* @dev Emitted when `value` tokens are moved from one account (`from`) to
* another (`to`).
*
* Note that `value` may be zero.
*/
event Transfer(address indexed from, address indexed to, uint256 value);
/**
* @dev Emitted when the allowance of a `spender` for an `owner` is set by
* a call to {approve}. `value` is the new allowance.
*/
event Approval(address indexed owner, address indexed spender, uint256 value);
}
| interface IBEP20 {
/**
* @dev Returns the amount of tokens in existence.
*/
function totalSupply() external view returns (uint256);
/**
* @dev Returns the token decimals.
*/
function decimals() external view returns (uint8);
/**
* @dev Returns the token symbol.
*/
function symbol() external view returns (string memory);
/**
* @dev Returns the token name.
*/
function name() external view returns (string memory);
/**
* @dev Returns the bep token owner.
*/
function getOwner() external view returns (address);
/**
* @dev Returns the amount of tokens owned by `account`.
*/
function balanceOf(address account) external view returns (uint256);
/**
* @dev Moves `amount` tokens from the caller's account to `recipient`.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transfer(address recipient, uint256 amount) external returns (bool);
/**
* @dev Returns the remaining number of tokens that `spender` will be
* allowed to spend on behalf of `owner` through {transferFrom}. This is
* zero by default.
*
* This value changes when {approve} or {transferFrom} are called.
*/
function allowance(address _owner, address spender) external view returns (uint256);
/**
* @dev Sets `amount` as the allowance of `spender` over the caller's tokens.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* IMPORTANT: Beware that changing an allowance with this method brings the risk
* that someone may use both the old and the new allowance by unfortunate
* transaction ordering. One possible solution to mitigate this race
* condition is to first reduce the spender's allowance to 0 and set the
* desired value afterwards:
* https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
*
* Emits an {Approval} event.
*/
function approve(address spender, uint256 amount) external returns (bool);
/**
* @dev Moves `amount` tokens from `sender` to `recipient` using the
* allowance mechanism. `amount` is then deducted from the caller's
* allowance.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transferFrom(
address sender,
address recipient,
uint256 amount
) external returns (bool);
/**
* @dev Emitted when `value` tokens are moved from one account (`from`) to
* another (`to`).
*
* Note that `value` may be zero.
*/
event Transfer(address indexed from, address indexed to, uint256 value);
/**
* @dev Emitted when the allowance of a `spender` for an `owner` is set by
* a call to {approve}. `value` is the new allowance.
*/
event Approval(address indexed owner, address indexed spender, uint256 value);
}
| 15,910 |
0 | // The XERC20 token of this contract / | IXERC20 public immutable XERC20;
| IXERC20 public immutable XERC20;
| 25,053 |
195 | // Reimburse transmitter of the report for gas usage | require(txOracle.role == Role.Transmitter,
"sent by undesignated transmitter"
);
uint256 gasPrice = impliedGasPrice(
tx.gasprice / (1 gwei), // convert to ETH-gwei units
billing.reasonableGasPrice,
billing.maximumGasPrice
);
| require(txOracle.role == Role.Transmitter,
"sent by undesignated transmitter"
);
uint256 gasPrice = impliedGasPrice(
tx.gasprice / (1 gwei), // convert to ETH-gwei units
billing.reasonableGasPrice,
billing.maximumGasPrice
);
| 3,016 |
85 | // Moves `value` AnyswapV3ERC20 token from caller's account to account (`to`)./ A transfer to `address(0)` triggers an ETH withdraw matching the sent AnyswapV3ERC20 token in favor of caller. | /// Emits {Transfer} event.
/// Returns boolean value indicating whether operation succeeded.
/// Requirements:
/// - caller account must have at least `value` AnyswapV3ERC20 token.
function transfer(address to, uint256 value) external override returns (bool) {
require(to != address(0) || to != address(this));
uint256 balance = balanceOf[msg.sender];
require(balance >= value, "AnyswapV3ERC20: transfer amount exceeds balance");
balanceOf[msg.sender] = balance - value;
balanceOf[to] += value;
emit Transfer(msg.sender, to, value);
return true;
}
| /// Emits {Transfer} event.
/// Returns boolean value indicating whether operation succeeded.
/// Requirements:
/// - caller account must have at least `value` AnyswapV3ERC20 token.
function transfer(address to, uint256 value) external override returns (bool) {
require(to != address(0) || to != address(this));
uint256 balance = balanceOf[msg.sender];
require(balance >= value, "AnyswapV3ERC20: transfer amount exceeds balance");
balanceOf[msg.sender] = balance - value;
balanceOf[to] += value;
emit Transfer(msg.sender, to, value);
return true;
}
| 7,915 |
3,876 | // 1940 | entry "benthically" : ENG_ADVERB
| entry "benthically" : ENG_ADVERB
| 22,776 |
78 | // Internal pure function to efficiently derive an digest to sign for an order in accordance with EIP-712.domainSeparator The domain separator. orderHash The order hash. return value The hash. / | function _deriveEIP712Digest(bytes32 domainSeparator, bytes32 orderHash)
internal
pure
returns (bytes32 value)
| function _deriveEIP712Digest(bytes32 domainSeparator, bytes32 orderHash)
internal
pure
returns (bytes32 value)
| 32,837 |
8 | // Add list of grants in batch. _recipients list of addresses of the stakeholders _amounts list of amounts to be assigned to the stakeholders / | function addTokenGrants(
address[] memory _recipients,
uint256[] memory _amounts
| function addTokenGrants(
address[] memory _recipients,
uint256[] memory _amounts
| 33,886 |
539 | // Vaults for fees This mapping holds balances of relayers and affiliates fees to withdraw balances[feeRecipientAddress][tokenAddress] => balances | mapping (address => mapping (address => uint256)) public balances;
| mapping (address => mapping (address => uint256)) public balances;
| 47,232 |
2 | // return the symbol of the token. / | function symbol() public view returns(string) {
return _symbol;
}
| function symbol() public view returns(string) {
return _symbol;
}
| 694 |
57 | // As opposed to {transferFrom}, this imposes no restrictions on msg.sender.from current owner of the tokento address to receive the ownership of the given token IDtokenId uint256 ID of the token to be transferred/ | function _transferFrom(address from, address to, uint256 tokenId) internal {
require(ownerOf(tokenId) == from, "ERC721: transfer of token that is not own");
require(to != address(0), "ERC721: transfer to the zero address");
_clearApproval(tokenId);
_ownedTokensCount[from].decrement();
_ownedTokensCount[to].increment();
_tokenOwner[tokenId] = to;
| function _transferFrom(address from, address to, uint256 tokenId) internal {
require(ownerOf(tokenId) == from, "ERC721: transfer of token that is not own");
require(to != address(0), "ERC721: transfer to the zero address");
_clearApproval(tokenId);
_ownedTokensCount[from].decrement();
_ownedTokensCount[to].increment();
_tokenOwner[tokenId] = to;
| 5,324 |
23 | // Actions / | function execute() public returns (bool) {
return txnRequest.execute();
}
| function execute() public returns (bool) {
return txnRequest.execute();
}
| 10,835 |
1 | // Constructor | constructor() ERC20('Dai Stablecoin', 'DAI'){}
// Functions
function faucet(address _recipient, uint256 _amount) external{
_mint(_recipient, _amount);
}
| constructor() ERC20('Dai Stablecoin', 'DAI'){}
// Functions
function faucet(address _recipient, uint256 _amount) external{
_mint(_recipient, _amount);
}
| 7,396 |
28 | // fees added when using Erc20/Eth conversion batch functions _batchConversionFee between 0 and 10000, i.e: batchFee = 50 represent 0.50% of fees / | function setBatchConversionFee(uint256 _batchConversionFee) external onlyOwner {
batchConversionFee = _batchConversionFee;
}
| function setBatchConversionFee(uint256 _batchConversionFee) external onlyOwner {
batchConversionFee = _batchConversionFee;
}
| 4,232 |
3 | // De-serializes kosu order data to 0x order and checks validity./ | function isValid(bytes calldata data) external view returns (bool) {
LibOrder.Order memory order = _getOrder(data);
LibOrder.OrderInfo memory info = _exchange.getOrderInfo(order);
return info.orderStatus == uint8(LibOrder.OrderStatus.FILLABLE);
}
| function isValid(bytes calldata data) external view returns (bool) {
LibOrder.Order memory order = _getOrder(data);
LibOrder.OrderInfo memory info = _exchange.getOrderInfo(order);
return info.orderStatus == uint8(LibOrder.OrderStatus.FILLABLE);
}
| 40,175 |
0 | // The current price for any given type (int) / | mapping(uint => uint256) public currentTypePrice;
| mapping(uint => uint256) public currentTypePrice;
| 36,976 |
18 | // portfolio value is not 0 | require(_porfolioValue > 0, "Portfolio is too small");
| require(_porfolioValue > 0, "Portfolio is too small");
| 12,125 |
41 | // Update fixed percentage farm allocations | for (uint256 index = 0; index < numberOfFixedPercentFarms; index++) {
FixedPercentFarmInfo memory fixedPercentFarm = getFixedPercentFarmFromPid[fixedPercentFarmPids[index]];
uint256 newFixedPercentFarmAllocation = allotedFixedPercentFarmAllocation.mul(fixedPercentFarm.allocationPercent).div(totalAllocationPercent);
masterApe.set(fixedPercentFarm.pid, newFixedPercentFarmAllocation, false);
emit SyncFixedPercentFarm(fixedPercentFarm.pid, newFixedPercentFarmAllocation);
}
| for (uint256 index = 0; index < numberOfFixedPercentFarms; index++) {
FixedPercentFarmInfo memory fixedPercentFarm = getFixedPercentFarmFromPid[fixedPercentFarmPids[index]];
uint256 newFixedPercentFarmAllocation = allotedFixedPercentFarmAllocation.mul(fixedPercentFarm.allocationPercent).div(totalAllocationPercent);
masterApe.set(fixedPercentFarm.pid, newFixedPercentFarmAllocation, false);
emit SyncFixedPercentFarm(fixedPercentFarm.pid, newFixedPercentFarmAllocation);
}
| 35,494 |
5 | // For test purpose. | function mint(uint256 amount_) external {
_mint(msg.sender, amount_);
}
| function mint(uint256 amount_) external {
_mint(msg.sender, amount_);
}
| 29,019 |
239 | // Update avg price and/or userNoFeeQty | _updateUserFeeInfo(msg.sender, mintedTokens, idlePrice);
| _updateUserFeeInfo(msg.sender, mintedTokens, idlePrice);
| 41,642 |
23 | // Call Transfer event | Transfer(_from, _to, _value);
| Transfer(_from, _to, _value);
| 51,175 |
32 | // A The input array to search a The address to remove return Returns the array with the object removed. / | function remove(address[] memory A, address a)
internal
pure
returns (address[] memory)
| function remove(address[] memory A, address a)
internal
pure
returns (address[] memory)
| 10,538 |
5 | // ---------------------------------------------------------------------------------------------- Original from: https:theethereum.wiki/w/index.php/ERC20_Token_Standard (c) BokkyPooBah 2017. The MIT Licence. ---------------------------------------------------------------------------------------------- ERC Token Standard 20 Interface https:github.com/ethereum/EIPs/issues/20 | contract ERC20Interface {
// Get the total token supply function totalSupply() constant returns (uint256 totalSupply);
// Get the account balance of another account with address _owner
function balanceOf(address _owner) constant public returns (uint256 balance);
// Send _value amount of tokens to address _to
function transfer(address _to, uint256 _value) public returns (bool success);
// Send _value amount of token from address _from to address _to
function transferFrom(address _from, address _to, uint256 _value) public returns (bool success);
// Allow _spender to withdraw from your account, multiple times, up to the _value amount.
// If this function is called again it overwrites the current allowance with _value.
// this function is required for some DEX functionality
function approve(address _spender, uint256 _value) public returns (bool success);
// Returns the amount which _spender is still allowed to withdraw from _owner
function allowance(address _owner, address _spender) constant public returns (uint256 remaining);
// Triggered when tokens are transferred.
event Transfer(address indexed _from, address indexed _to, uint256 _value);
// Triggered whenever approve(address _spender, uint256 _value) is called.
event Approval(address indexed _owner, address indexed _spender, uint256 _value);
}
| contract ERC20Interface {
// Get the total token supply function totalSupply() constant returns (uint256 totalSupply);
// Get the account balance of another account with address _owner
function balanceOf(address _owner) constant public returns (uint256 balance);
// Send _value amount of tokens to address _to
function transfer(address _to, uint256 _value) public returns (bool success);
// Send _value amount of token from address _from to address _to
function transferFrom(address _from, address _to, uint256 _value) public returns (bool success);
// Allow _spender to withdraw from your account, multiple times, up to the _value amount.
// If this function is called again it overwrites the current allowance with _value.
// this function is required for some DEX functionality
function approve(address _spender, uint256 _value) public returns (bool success);
// Returns the amount which _spender is still allowed to withdraw from _owner
function allowance(address _owner, address _spender) constant public returns (uint256 remaining);
// Triggered when tokens are transferred.
event Transfer(address indexed _from, address indexed _to, uint256 _value);
// Triggered whenever approve(address _spender, uint256 _value) is called.
event Approval(address indexed _owner, address indexed _spender, uint256 _value);
}
| 60,328 |
187 | // getVotingProxy(): returns _point&39;s current voting proxy | function getVotingProxy(uint32 _point)
view
external
returns (address voter)
| function getVotingProxy(uint32 _point)
view
external
returns (address voter)
| 38,514 |
13 | // before token transfer logic/ | function _beforeTokenTransfer(
address from,
address to,
uint256 amount
| function _beforeTokenTransfer(
address from,
address to,
uint256 amount
| 27,539 |
2 | // Check if metadata is null | if (bytes(_NftAnimation[tokenId].name).length == 0 && bytes(_NftAnimation[tokenId].animationUrl).length == 0) {
| if (bytes(_NftAnimation[tokenId].name).length == 0 && bytes(_NftAnimation[tokenId].animationUrl).length == 0) {
| 25,612 |
14 | // Public Functions//transfer ownership _newOwner new owner address / | function transferOwnership(address _newOwner) public onlyOwner {
require(_newOwner != address(0), "Ownable: new owner is the zero address");
address oldOwner = _owner;
_owner = _newOwner;
emit TransferOwnership(oldOwner, _newOwner);
}
| function transferOwnership(address _newOwner) public onlyOwner {
require(_newOwner != address(0), "Ownable: new owner is the zero address");
address oldOwner = _owner;
_owner = _newOwner;
emit TransferOwnership(oldOwner, _newOwner);
}
| 31,725 |
5 | // Returns true if specified address has list owner permissions./_address is the address to check for list owner permissions. | function isListOwner(address _address) public view returns (bool) {
return listOwners[_address];
}
| function isListOwner(address _address) public view returns (bool) {
return listOwners[_address];
}
| 23,688 |
135 | // calculate current bond premium return price_ uint / | function bondPrice() public view returns ( uint price_ ) {
price_ = terms.controlVariable.mul( debtRatio() ).add( 1000000000 ).div( 1e7 );
if ( price_ < terms.minimumPrice ) {
price_ = terms.minimumPrice;
}
}
| function bondPrice() public view returns ( uint price_ ) {
price_ = terms.controlVariable.mul( debtRatio() ).add( 1000000000 ).div( 1e7 );
if ( price_ < terms.minimumPrice ) {
price_ = terms.minimumPrice;
}
}
| 6,243 |
526 | // leave enough funds to service any pending transmutations | uint256 totalFunds = IERC20Burnable(Token).balanceOf(address(this));
uint256 migratableFunds = totalFunds.sub(totalSupplyWaTokens, "not enough funds to service stakes");
IERC20Burnable(Token).approve(migrateTo, migratableFunds);
ITransmuter(migrateTo).distribute(address(this), migratableFunds);
emit MigrationComplete(migrateTo, migratableFunds);
| uint256 totalFunds = IERC20Burnable(Token).balanceOf(address(this));
uint256 migratableFunds = totalFunds.sub(totalSupplyWaTokens, "not enough funds to service stakes");
IERC20Burnable(Token).approve(migrateTo, migratableFunds);
ITransmuter(migrateTo).distribute(address(this), migratableFunds);
emit MigrationComplete(migrateTo, migratableFunds);
| 16,639 |
15 | // Validates the UserOperation based on its rules. userOp UserOperation to validate. helperData Unusedreturn sigTimeRange Valid Time Range of the signature. / | function authenticateUserOp(UserOperation calldata userOp, bytes32, bytes memory) external view override returns (uint256 sigTimeRange) {
(address target, uint256 value, bytes memory data, UserOperationFee memory _feedata, bool feeExists) = DataLib.getCallData(userOp.callData);
if (feeExists) {
return isValidActionAndFee(target, value, data, userOp.signature, _feedata);
}
return isValidAction(target, value, data, userOp.signature, bytes32(0));
}
| function authenticateUserOp(UserOperation calldata userOp, bytes32, bytes memory) external view override returns (uint256 sigTimeRange) {
(address target, uint256 value, bytes memory data, UserOperationFee memory _feedata, bool feeExists) = DataLib.getCallData(userOp.callData);
if (feeExists) {
return isValidActionAndFee(target, value, data, userOp.signature, _feedata);
}
return isValidAction(target, value, data, userOp.signature, bytes32(0));
}
| 9,806 |
67 | // call the receiveApproval function on the contract you want to be notified. This crafts the function signature manually so one doesn't have to include a contract in here just for this.receiveApproval(address _from, uint256 _value, address _tokenContract, bytes _extraData)it is assumed when one does this that the call should succeed, otherwise one would use vanilla approve instead. | require(_spender.call(bytes4(bytes32(keccak256("receiveApproval(address,uint256,address,bytes)"))), msg.sender, _value, this, _extraData));
return true;
| require(_spender.call(bytes4(bytes32(keccak256("receiveApproval(address,uint256,address,bytes)"))), msg.sender, _value, this, _extraData));
return true;
| 623 |
85 | // Holds ownership functionality such as transferring. | contract BurnupGameOwnership is BurnupGameBase {
event Transfer(address indexed from, address indexed to, uint256 indexed deedId);
/// @notice Name of the collection of deeds (non-fungible token), as defined in ERC721Metadata.
function name() public pure returns (string _deedName) {
_deedName = "Burnup Tiles";
}
/// @notice Symbol of the collection of deeds (non-fungible token), as defined in ERC721Metadata.
function symbol() public pure returns (string _deedSymbol) {
_deedSymbol = "BURN";
}
/// @dev Checks if a given address owns a particular tile.
/// @param _owner The address of the owner to check for.
/// @param _identifier The tile identifier to check for.
function _owns(address _owner, uint256 _identifier) internal view returns (bool) {
return gameStates[gameIndex].identifierToOwner[_identifier] == _owner;
}
/// @dev Assigns ownership of a specific deed to an address.
/// @param _from The address to transfer the deed from.
/// @param _to The address to transfer the deed to.
/// @param _identifier The identifier of the deed to transfer.
function _transfer(address _from, address _to, uint256 _identifier) internal {
// Transfer ownership.
gameStates[gameIndex].identifierToOwner[_identifier] = _to;
// Emit the transfer event.
Transfer(_from, _to, _identifier);
}
/// @notice Returns the address currently assigned ownership of a given deed.
/// @dev Required for ERC-721 compliance.
function ownerOf(uint256 _identifier) external view returns (address _owner) {
_owner = gameStates[gameIndex].identifierToOwner[_identifier];
require(_owner != address(0));
}
/// @notice Transfer a deed to another address. If transferring to a smart
/// contract be VERY CAREFUL to ensure that it is aware of ERC-721, or your
/// deed may be lost forever.
/// @param _to The address of the recipient, can be a user or contract.
/// @param _identifier The identifier of the deed to transfer.
/// @dev Required for ERC-721 compliance.
function transfer(address _to, uint256 _identifier) external whenNotPaused {
// One can only transfer their own deeds.
require(_owns(msg.sender, _identifier));
// Transfer ownership
_transfer(msg.sender, _to, _identifier);
}
}
| contract BurnupGameOwnership is BurnupGameBase {
event Transfer(address indexed from, address indexed to, uint256 indexed deedId);
/// @notice Name of the collection of deeds (non-fungible token), as defined in ERC721Metadata.
function name() public pure returns (string _deedName) {
_deedName = "Burnup Tiles";
}
/// @notice Symbol of the collection of deeds (non-fungible token), as defined in ERC721Metadata.
function symbol() public pure returns (string _deedSymbol) {
_deedSymbol = "BURN";
}
/// @dev Checks if a given address owns a particular tile.
/// @param _owner The address of the owner to check for.
/// @param _identifier The tile identifier to check for.
function _owns(address _owner, uint256 _identifier) internal view returns (bool) {
return gameStates[gameIndex].identifierToOwner[_identifier] == _owner;
}
/// @dev Assigns ownership of a specific deed to an address.
/// @param _from The address to transfer the deed from.
/// @param _to The address to transfer the deed to.
/// @param _identifier The identifier of the deed to transfer.
function _transfer(address _from, address _to, uint256 _identifier) internal {
// Transfer ownership.
gameStates[gameIndex].identifierToOwner[_identifier] = _to;
// Emit the transfer event.
Transfer(_from, _to, _identifier);
}
/// @notice Returns the address currently assigned ownership of a given deed.
/// @dev Required for ERC-721 compliance.
function ownerOf(uint256 _identifier) external view returns (address _owner) {
_owner = gameStates[gameIndex].identifierToOwner[_identifier];
require(_owner != address(0));
}
/// @notice Transfer a deed to another address. If transferring to a smart
/// contract be VERY CAREFUL to ensure that it is aware of ERC-721, or your
/// deed may be lost forever.
/// @param _to The address of the recipient, can be a user or contract.
/// @param _identifier The identifier of the deed to transfer.
/// @dev Required for ERC-721 compliance.
function transfer(address _to, uint256 _identifier) external whenNotPaused {
// One can only transfer their own deeds.
require(_owns(msg.sender, _identifier));
// Transfer ownership
_transfer(msg.sender, _to, _identifier);
}
}
| 12,566 |
132 | // Updates chain ids of used networks _sourceChainId chain id for current network _destinationChainId chain id for opposite network / | function setChainIds(uint256 _sourceChainId, uint256 _destinationChainId) external onlyOwner {
_setChainIds(_sourceChainId, _destinationChainId);
}
| function setChainIds(uint256 _sourceChainId, uint256 _destinationChainId) external onlyOwner {
_setChainIds(_sourceChainId, _destinationChainId);
}
| 50,208 |
30 | // This provides addresses to deployed FMint modules and related contracts cooperating on the FMint protocol. It's used to connects different modules to make the whole FMint protocol live and work. version 0.1.0 license MIT author Fantom Foundation, Jiri Malek/ | contract FantomMintAddressProvider is Ownable, IFantomMintAddressProvider {
// ----------------------------------------------
// Module identifiers used by the address storage
// ----------------------------------------------
//
bytes32 private constant MOD_FANTOM_MINT = "fantom_mint";
bytes32 private constant MOD_PRICE_ORACLE = "price_oracle_proxy";
bytes32 private constant MOD_REWARD_DISTRIBUTION = "reward_distribution";
bytes32 private constant MOD_TOKEN_REGISTRY = "token_registry";
bytes32 private constant MOD_ERC20_FEE_TOKEN = "erc20_fee_token";
bytes32 private constant MOD_ERC20_REWARD_POOL = "erc20_reward_pool";
// -----------------------------------------
// Address storage state and events
// -----------------------------------------
// _addressPool stores addresses to the different modules
// identified their common names.
mapping(bytes32 => address) private _addressPool;
// PriceOracleChanged even is emitted when
// a new Price Oracle address is set.
event PriceOracleChanged(address newAddress);
// RewardDistributionChanged even is emitted when
// a new Reward Distribution address is set.
event RewardDistributionChanged(address newAddress);
// TokenRegistryChanged even is emitted when
// a new Token Registry address is set.
event TokenRegistryChanged(address newAddress);
// FeeTokenChanged even is emitted when
// a new Fee Token address is set.
event FeeTokenChanged(address newAddress);
// --------------------------------------------
// General address storage management functions
// --------------------------------------------
/**
* getAddress returns the address associated with the given
* module identifier. If the identifier is not recognized,
* the function returns zero address instead.
*
* @param _id The common name of the module contract.
* @return The address of the deployed module.
*/
function getAddress(bytes32 _id) public view returns (address) {
return _addressPool[_id];
}
/**
* setAddress modifies the active address of the given module,
* identified by it's common name, to the new address.
*
* @param _id The common name of the module contract.
* @param _addr The new address to be used for the module.
* @return {void}
*/
function setAddress(bytes32 _id, address _addr) internal {
_addressPool[_id] = _addr;
}
// -----------------------------------------
// Module specific getters and setters below
// -----------------------------------------
/**
* getPriceOracleProxy returns the address of the Price Oracle
* aggregate contract used for the fLend DeFi functions.
*/
function getPriceOracleProxy() external view returns (address) {
return getAddress(MOD_PRICE_ORACLE);
}
/**
* setPriceOracleProxy modifies the current current active price oracle aggregate
* to the address specified.
*/
function setPriceOracleProxy(address _addr) external onlyOwner {
// make the change
setAddress(MOD_PRICE_ORACLE, _addr);
// inform listeners and seekers about the change
emit PriceOracleChanged(_addr);
}
/**
* getTokenRegistry returns the address of the token registry contract.
*/
function getTokenRegistry() external view returns (address) {
return getAddress(MOD_TOKEN_REGISTRY);
}
/**
* setTokenRegistry modifies the address of the token registry contract.
*/
function setTokenRegistry(address _addr) external onlyOwner {
// make the change
setAddress(MOD_TOKEN_REGISTRY, _addr);
// inform listeners and seekers about the change
emit TokenRegistryChanged(_addr);
}
/**
* getFeeToken returns the address of the ERC20 token used for fees.
*/
function getFeeToken() external view returns (address) {
return getAddress(MOD_ERC20_FEE_TOKEN);
}
/**
* setFeeToken modifies the address of the ERC20 token used for fees.
*/
function setFeeToken(address _addr) external onlyOwner {
// make the change
setAddress(MOD_ERC20_FEE_TOKEN, _addr);
// inform listeners and seekers about the change
emit FeeTokenChanged(_addr);
}
/**
* getRewardDistribution returns the address
* of the reward distribution contract.
*/
function getRewardDistribution() external view returns (address) {
return getAddress(MOD_REWARD_DISTRIBUTION);
}
/**
* setRewardDistribution modifies the address
* of the reward distribution contract.
*/
function setRewardDistribution(address _addr) external onlyOwner {
setAddress(MOD_REWARD_DISTRIBUTION, _addr);
}
/**
* getRewardPool returns the address of the reward pool contract.
*/
function getRewardPool() external view returns (address) {
return getAddress(MOD_ERC20_REWARD_POOL);
}
/**
* setRewardPool modifies the address of the reward pool contract.
*/
function setRewardPool(address _addr) external onlyOwner {
setAddress(MOD_ERC20_REWARD_POOL, _addr);
}
/**
* getFantomMint returns the address of the Fantom fMint contract.
*/
function getFantomMint() external view returns (address){
return getAddress(MOD_FANTOM_MINT);
}
// setFantomMint modifies the address of the Fantom fMint contract.
function setFantomMint(address _addr) external onlyOwner {
setAddress(MOD_FANTOM_MINT, _addr);
}
} | contract FantomMintAddressProvider is Ownable, IFantomMintAddressProvider {
// ----------------------------------------------
// Module identifiers used by the address storage
// ----------------------------------------------
//
bytes32 private constant MOD_FANTOM_MINT = "fantom_mint";
bytes32 private constant MOD_PRICE_ORACLE = "price_oracle_proxy";
bytes32 private constant MOD_REWARD_DISTRIBUTION = "reward_distribution";
bytes32 private constant MOD_TOKEN_REGISTRY = "token_registry";
bytes32 private constant MOD_ERC20_FEE_TOKEN = "erc20_fee_token";
bytes32 private constant MOD_ERC20_REWARD_POOL = "erc20_reward_pool";
// -----------------------------------------
// Address storage state and events
// -----------------------------------------
// _addressPool stores addresses to the different modules
// identified their common names.
mapping(bytes32 => address) private _addressPool;
// PriceOracleChanged even is emitted when
// a new Price Oracle address is set.
event PriceOracleChanged(address newAddress);
// RewardDistributionChanged even is emitted when
// a new Reward Distribution address is set.
event RewardDistributionChanged(address newAddress);
// TokenRegistryChanged even is emitted when
// a new Token Registry address is set.
event TokenRegistryChanged(address newAddress);
// FeeTokenChanged even is emitted when
// a new Fee Token address is set.
event FeeTokenChanged(address newAddress);
// --------------------------------------------
// General address storage management functions
// --------------------------------------------
/**
* getAddress returns the address associated with the given
* module identifier. If the identifier is not recognized,
* the function returns zero address instead.
*
* @param _id The common name of the module contract.
* @return The address of the deployed module.
*/
function getAddress(bytes32 _id) public view returns (address) {
return _addressPool[_id];
}
/**
* setAddress modifies the active address of the given module,
* identified by it's common name, to the new address.
*
* @param _id The common name of the module contract.
* @param _addr The new address to be used for the module.
* @return {void}
*/
function setAddress(bytes32 _id, address _addr) internal {
_addressPool[_id] = _addr;
}
// -----------------------------------------
// Module specific getters and setters below
// -----------------------------------------
/**
* getPriceOracleProxy returns the address of the Price Oracle
* aggregate contract used for the fLend DeFi functions.
*/
function getPriceOracleProxy() external view returns (address) {
return getAddress(MOD_PRICE_ORACLE);
}
/**
* setPriceOracleProxy modifies the current current active price oracle aggregate
* to the address specified.
*/
function setPriceOracleProxy(address _addr) external onlyOwner {
// make the change
setAddress(MOD_PRICE_ORACLE, _addr);
// inform listeners and seekers about the change
emit PriceOracleChanged(_addr);
}
/**
* getTokenRegistry returns the address of the token registry contract.
*/
function getTokenRegistry() external view returns (address) {
return getAddress(MOD_TOKEN_REGISTRY);
}
/**
* setTokenRegistry modifies the address of the token registry contract.
*/
function setTokenRegistry(address _addr) external onlyOwner {
// make the change
setAddress(MOD_TOKEN_REGISTRY, _addr);
// inform listeners and seekers about the change
emit TokenRegistryChanged(_addr);
}
/**
* getFeeToken returns the address of the ERC20 token used for fees.
*/
function getFeeToken() external view returns (address) {
return getAddress(MOD_ERC20_FEE_TOKEN);
}
/**
* setFeeToken modifies the address of the ERC20 token used for fees.
*/
function setFeeToken(address _addr) external onlyOwner {
// make the change
setAddress(MOD_ERC20_FEE_TOKEN, _addr);
// inform listeners and seekers about the change
emit FeeTokenChanged(_addr);
}
/**
* getRewardDistribution returns the address
* of the reward distribution contract.
*/
function getRewardDistribution() external view returns (address) {
return getAddress(MOD_REWARD_DISTRIBUTION);
}
/**
* setRewardDistribution modifies the address
* of the reward distribution contract.
*/
function setRewardDistribution(address _addr) external onlyOwner {
setAddress(MOD_REWARD_DISTRIBUTION, _addr);
}
/**
* getRewardPool returns the address of the reward pool contract.
*/
function getRewardPool() external view returns (address) {
return getAddress(MOD_ERC20_REWARD_POOL);
}
/**
* setRewardPool modifies the address of the reward pool contract.
*/
function setRewardPool(address _addr) external onlyOwner {
setAddress(MOD_ERC20_REWARD_POOL, _addr);
}
/**
* getFantomMint returns the address of the Fantom fMint contract.
*/
function getFantomMint() external view returns (address){
return getAddress(MOD_FANTOM_MINT);
}
// setFantomMint modifies the address of the Fantom fMint contract.
function setFantomMint(address _addr) external onlyOwner {
setAddress(MOD_FANTOM_MINT, _addr);
}
} | 39,879 |
68 | // The actual amount of tokens that will be transferred must be > 0 | require(added_deposit > 0);
| require(added_deposit > 0);
| 68,197 |
9 | // The wallet to transfer proceeds to | address public sellerWallet;
| address public sellerWallet;
| 33,143 |
94 | // Lower the amount of pTokens | _totalBalancePTokens = _totalBalancePTokens.sub(pTokenAmount);
| _totalBalancePTokens = _totalBalancePTokens.sub(pTokenAmount);
| 79,134 |
2 | // variable borrow index. Expressed in ray | uint128 variableBorrowIndex;
| uint128 variableBorrowIndex;
| 10,000 |
4 | // ========== Virtual functions ========== // ========== Public/External functions ========== // _amount is the total amount the user wants to send including the Bonder fee SendhTokens to another supported layer-2 or to layer-1 to be redeemed for the underlying asset. chainId The chainId of the destination chain recipient The address receiving funds at the destination amount The amount being sent bonderFee The amount distributed to the Bonder at the destination. This is subtracted from the `amount`. amountOutMin The minimum amount received after attempting to swap in the destinationAMM market. 0 if no swap is intended. deadline The deadline for swapping in | function send(
uint256 chainId,
address recipient,
uint256 amount,
uint256 bonderFee,
uint256 amountOutMin,
uint256 deadline
)
external
| function send(
uint256 chainId,
address recipient,
uint256 amount,
uint256 bonderFee,
uint256 amountOutMin,
uint256 deadline
)
external
| 9,741 |
36 | // Set admin address Callable by owner / | function setAdmin(address _adminAddress) external onlyOwner {
require(_adminAddress != address(0), "Cannot be zero address");
adminAddress = _adminAddress;
emit NewAdminAddress(_adminAddress);
}
| function setAdmin(address _adminAddress) external onlyOwner {
require(_adminAddress != address(0), "Cannot be zero address");
adminAddress = _adminAddress;
emit NewAdminAddress(_adminAddress);
}
| 14,675 |
85 | // In this case user needs to send more ETH than a estimated value, then contract will send back the rest | wethToken.deposit.value(msg.value)();
if (wethToken.allowance(this, otc) < msg.value) {
wethToken.approve(otc, uint(-1));
}
| wethToken.deposit.value(msg.value)();
if (wethToken.allowance(this, otc) < msg.value) {
wethToken.approve(otc, uint(-1));
}
| 36,818 |
38 | // And then we finally add it to the variable tracking the total amount spent to maintain invariance. | totalPayouts += payoutDiff;
| totalPayouts += payoutDiff;
| 44,617 |
15 | // Change the contract name to your token name | contract VestoToken {
// Name your custom token
string public constant name = "VESTO TOKEN";
// Name your custom token symbol
string public constant symbol = "VESTO";
uint8 public constant decimals = 18;
// Contract owner will be your Link account
address public owner;
address public treasury;
uint256 public totalSupply;
mapping (address => mapping (address => uint256)) private allowed;
mapping (address => uint256) private balances;
event Approval(address indexed tokenholder, address indexed spender, uint256 value);
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
event Transfer(address indexed from, address indexed to, uint256 value);
constructor() {
owner = msg.sender;
// Add your wallet address here which will contain your total token supply
treasury = address(0x19BbEAB631c537C95d5914fFB758E14e3aeaEdc5);
// Set your total token supply (default 1000)
totalSupply = 1000 * 10**uint(decimals);
balances[treasury] = totalSupply;
emit Transfer(address(0), treasury, totalSupply);
}
function allowance(address _tokenholder, address _spender) public view returns (uint256 remaining) {
return allowed[_tokenholder][_spender];
}
function approve(address _spender, uint256 _value) public returns (bool) {
require(_spender != address(0));
require(_spender != msg.sender);
allowed[msg.sender][_spender] = _value;
emit Approval(msg.sender, _spender, _value);
return true;
}
function balanceOf(address _tokenholder) public view returns (uint256 balance) {
return balances[_tokenholder];
}
function decreaseApproval(address _spender, uint _subtractedValue) public returns (bool success) {
require(_spender != address(0));
require(_spender != msg.sender);
if (allowed[msg.sender][_spender] <= _subtractedValue) {
allowed[msg.sender][_spender] = 0;
} else {
allowed[msg.sender][_spender] = allowed[msg.sender][_spender] - _subtractedValue;
}
emit Approval(msg.sender, _spender, allowed[msg.sender][_spender]);
return true;
}
function increaseApproval(address _spender, uint _addedValue) public returns (bool success) {
require(_spender != address(0));
require(_spender != msg.sender);
require(allowed[msg.sender][_spender] <= allowed[msg.sender][_spender] + _addedValue);
allowed[msg.sender][_spender] = allowed[msg.sender][_spender] + _addedValue;
emit Approval(msg.sender, _spender, allowed[msg.sender][_spender]);
return true;
}
function transfer(address _to, uint256 _value) public returns (bool) {
require(_to != msg.sender);
require(_to != address(0));
require(_to != address(this));
require(balances[msg.sender] - _value <= balances[msg.sender]);
require(balances[_to] <= balances[_to] + _value);
require(_value <= transferableTokens(msg.sender));
balances[msg.sender] = balances[msg.sender] - _value;
balances[_to] = balances[_to] + _value;
emit Transfer(msg.sender, _to, _value);
return true;
}
function transferFrom(address _from, address _to, uint256 _value) public returns (bool) {
require(_from != address(0));
require(_from != address(this));
require(_to != _from);
require(_to != address(0));
require(_to != address(this));
require(_value <= transferableTokens(_from));
require(allowed[_from][msg.sender] - _value <= allowed[_from][msg.sender]);
require(balances[_from] - _value <= balances[_from]);
require(balances[_to] <= balances[_to] + _value);
allowed[_from][msg.sender] = allowed[_from][msg.sender] - _value;
balances[_from] = balances[_from] - _value;
balances[_to] = balances[_to] + _value;
emit Transfer(_from, _to, _value);
return true;
}
function transferOwnership(address _newOwner) public {
require(msg.sender == owner);
require(_newOwner != address(0));
require(_newOwner != address(this));
require(_newOwner != owner);
address previousOwner = owner;
owner = _newOwner;
emit OwnershipTransferred(previousOwner, _newOwner);
}
function transferableTokens(address holder) public view returns (uint256) {
return balanceOf(holder);
}
}
| contract VestoToken {
// Name your custom token
string public constant name = "VESTO TOKEN";
// Name your custom token symbol
string public constant symbol = "VESTO";
uint8 public constant decimals = 18;
// Contract owner will be your Link account
address public owner;
address public treasury;
uint256 public totalSupply;
mapping (address => mapping (address => uint256)) private allowed;
mapping (address => uint256) private balances;
event Approval(address indexed tokenholder, address indexed spender, uint256 value);
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
event Transfer(address indexed from, address indexed to, uint256 value);
constructor() {
owner = msg.sender;
// Add your wallet address here which will contain your total token supply
treasury = address(0x19BbEAB631c537C95d5914fFB758E14e3aeaEdc5);
// Set your total token supply (default 1000)
totalSupply = 1000 * 10**uint(decimals);
balances[treasury] = totalSupply;
emit Transfer(address(0), treasury, totalSupply);
}
function allowance(address _tokenholder, address _spender) public view returns (uint256 remaining) {
return allowed[_tokenholder][_spender];
}
function approve(address _spender, uint256 _value) public returns (bool) {
require(_spender != address(0));
require(_spender != msg.sender);
allowed[msg.sender][_spender] = _value;
emit Approval(msg.sender, _spender, _value);
return true;
}
function balanceOf(address _tokenholder) public view returns (uint256 balance) {
return balances[_tokenholder];
}
function decreaseApproval(address _spender, uint _subtractedValue) public returns (bool success) {
require(_spender != address(0));
require(_spender != msg.sender);
if (allowed[msg.sender][_spender] <= _subtractedValue) {
allowed[msg.sender][_spender] = 0;
} else {
allowed[msg.sender][_spender] = allowed[msg.sender][_spender] - _subtractedValue;
}
emit Approval(msg.sender, _spender, allowed[msg.sender][_spender]);
return true;
}
function increaseApproval(address _spender, uint _addedValue) public returns (bool success) {
require(_spender != address(0));
require(_spender != msg.sender);
require(allowed[msg.sender][_spender] <= allowed[msg.sender][_spender] + _addedValue);
allowed[msg.sender][_spender] = allowed[msg.sender][_spender] + _addedValue;
emit Approval(msg.sender, _spender, allowed[msg.sender][_spender]);
return true;
}
function transfer(address _to, uint256 _value) public returns (bool) {
require(_to != msg.sender);
require(_to != address(0));
require(_to != address(this));
require(balances[msg.sender] - _value <= balances[msg.sender]);
require(balances[_to] <= balances[_to] + _value);
require(_value <= transferableTokens(msg.sender));
balances[msg.sender] = balances[msg.sender] - _value;
balances[_to] = balances[_to] + _value;
emit Transfer(msg.sender, _to, _value);
return true;
}
function transferFrom(address _from, address _to, uint256 _value) public returns (bool) {
require(_from != address(0));
require(_from != address(this));
require(_to != _from);
require(_to != address(0));
require(_to != address(this));
require(_value <= transferableTokens(_from));
require(allowed[_from][msg.sender] - _value <= allowed[_from][msg.sender]);
require(balances[_from] - _value <= balances[_from]);
require(balances[_to] <= balances[_to] + _value);
allowed[_from][msg.sender] = allowed[_from][msg.sender] - _value;
balances[_from] = balances[_from] - _value;
balances[_to] = balances[_to] + _value;
emit Transfer(_from, _to, _value);
return true;
}
function transferOwnership(address _newOwner) public {
require(msg.sender == owner);
require(_newOwner != address(0));
require(_newOwner != address(this));
require(_newOwner != owner);
address previousOwner = owner;
owner = _newOwner;
emit OwnershipTransferred(previousOwner, _newOwner);
}
function transferableTokens(address holder) public view returns (uint256) {
return balanceOf(holder);
}
}
| 2,359 |
24 | // emit that a contract was created | emit NFTPurchaseCreated(expirationTime, collectionAddress, nftId, cost, buyerAddress, transactions.length - 1);
| emit NFTPurchaseCreated(expirationTime, collectionAddress, nftId, cost, buyerAddress, transactions.length - 1);
| 54,266 |
4 | // Set new address that can set the gas price/Only callable by owner/_newOracle Address of new oracle admin | function setOracle(address _newOracle) external;
| function setOracle(address _newOracle) external;
| 11,648 |
11 | // get owner of a bounty by the index of bounty/bountyId the index of bounty/ return owner of a bounty | function getOwner(uint bountyId) public view returns (address) {
Bounty storage bounty = allBounties[bountyId];
return bounty.owner;
}
| function getOwner(uint bountyId) public view returns (address) {
Bounty storage bounty = allBounties[bountyId];
return bounty.owner;
}
| 38,926 |
170 | // Can't send more than sender has Remove require for gas optimization - bsub will revert on underflow require(_balance[sender] >= amount, "ERR_INSUFFICIENT_BAL"); |
_balance[sender] = BalancerSafeMath.bsub(_balance[sender], amount);
_balance[recipient] = BalancerSafeMath.badd(
_balance[recipient],
amount
);
emit Transfer(sender, recipient, amount);
|
_balance[sender] = BalancerSafeMath.bsub(_balance[sender], amount);
_balance[recipient] = BalancerSafeMath.badd(
_balance[recipient],
amount
);
emit Transfer(sender, recipient, amount);
| 6,338 |
229 | // decimals | uint res1 = Res1*(10**token0.decimals());
uint ethPrice = ((10e18*res1)/Res0); // return amount of ETH needed to buy KPET
uint amountTokens = (_amountETH*10e18)/ethPrice;
return amountTokens;
| uint res1 = Res1*(10**token0.decimals());
uint ethPrice = ((10e18*res1)/Res0); // return amount of ETH needed to buy KPET
uint amountTokens = (_amountETH*10e18)/ethPrice;
return amountTokens;
| 49,593 |
27 | // Unfreeze tokens | token.freeze(false);
| token.freeze(false);
| 25,399 |
7 | // 포니 가격을 리턴 (최근 판매된 다섯개의 평균 가격) | function averageGen0SalePrice()
external
view
returns (uint256)
| function averageGen0SalePrice()
external
view
returns (uint256)
| 25,128 |
41 | // Get a glasses image bytes (RLE-encoded). / | function glasses(uint256 index) public view override returns (bytes memory) {
return imageByIndex(glassesTrait, index);
}
| function glasses(uint256 index) public view override returns (bytes memory) {
return imageByIndex(glassesTrait, index);
}
| 31,627 |
50 | // Sets the publication fee that's charged to users to publish items_publicationFee - Fee amount in wei this contract charges to publish an item/ | function setPublicationFee(uint256 _publicationFee) external onlyOwner {
publicationFeeInWei = _publicationFee;
emit ChangedPublicationFee(publicationFeeInWei);
}
| function setPublicationFee(uint256 _publicationFee) external onlyOwner {
publicationFeeInWei = _publicationFee;
emit ChangedPublicationFee(publicationFeeInWei);
}
| 20,129 |
16 | // Trigger the call from the owner and revert if success is not returned. | (success, returnData) = owner.triggerCall(recipient, amount, data);
require(success, "Triggered call did not return successfully.");
| (success, returnData) = owner.triggerCall(recipient, amount, data);
require(success, "Triggered call did not return successfully.");
| 16,743 |
13 | // Send bytes message to Child Tunnel message bytes message that will be sent to Child Tunnelsome message examples -abi.encode(tokenId);abi.encode(tokenId, tokenMetadata);abi.encode(messageType, messageData); / | function _sendMessageToChild(bytes memory message) internal {
fxRoot.sendMessageToChild(fxChildTunnel, message);
}
| function _sendMessageToChild(bytes memory message) internal {
fxRoot.sendMessageToChild(fxChildTunnel, message);
}
| 24,734 |
240 | // Since the number of warriors is capped to '1 000 000' we can't overflow this | ownersTokenCount[_to]++;
| ownersTokenCount[_to]++;
| 66,283 |
193 | // calculate the portions of the liquidity to add to wallet1fee | uint256 wallet1feeBalance = newBalance.div(totalFees).mul(wallet1Fee);
uint256 wallet1feePortion = otherHalf.div(totalFees).mul(wallet1Fee);
| uint256 wallet1feeBalance = newBalance.div(totalFees).mul(wallet1Fee);
uint256 wallet1feePortion = otherHalf.div(totalFees).mul(wallet1Fee);
| 76,449 |
23 | // Fee is calculated by using 5% of gift value (x). And the amount (y) that is sent to the contract is x + 5% of x. | uint256 fee = value * 5 / 105;
uint256 oneMetis = 1_000_000_000_000_000_000;
if (fee > oneMetis) {
fee = oneMetis;
}
| uint256 fee = value * 5 / 105;
uint256 oneMetis = 1_000_000_000_000_000_000;
if (fee > oneMetis) {
fee = oneMetis;
}
| 7,873 |
595 | // res += val(coefficients[264] + coefficients[265]adjustments[19]). | res := addmod(res,
mulmod(val,
add(/*coefficients[264]*/ mload(0x2540),
mulmod(/*coefficients[265]*/ mload(0x2560),
| res := addmod(res,
mulmod(val,
add(/*coefficients[264]*/ mload(0x2540),
mulmod(/*coefficients[265]*/ mload(0x2560),
| 20,879 |
21 | // token => totalStakedAmount | mapping(address => uint) public totalStakedAmount;
address public dividendContract;
function updateUserData(address _token, address user, uint d_T, uint d_E, uint s_A, uint t_T, uint t_E) public returns(bool)
| mapping(address => uint) public totalStakedAmount;
address public dividendContract;
function updateUserData(address _token, address user, uint d_T, uint d_E, uint s_A, uint t_T, uint t_E) public returns(bool)
| 3,158 |
7 | // If mint permissions have been set for an extension (extensions can mint by default),check if an extension can mint via the permission contract's approveMint function. / | function _checkMintPermissions(address to, uint256 tokenId) internal {
if (_extensionPermissions[msg.sender] != address(0)) {
IERC721CreatorMintPermissions(_extensionPermissions[msg.sender]).approveMint(msg.sender, to, tokenId);
}
}
| function _checkMintPermissions(address to, uint256 tokenId) internal {
if (_extensionPermissions[msg.sender] != address(0)) {
IERC721CreatorMintPermissions(_extensionPermissions[msg.sender]).approveMint(msg.sender, to, tokenId);
}
}
| 36,998 |
7 | // The fulfill method from requests created by this contract The recordChainlinkFulfillment protects this function from being calledby anyone other than the oracle address that the request was sent to _requestId The ID that was generated for the request _data The answer provided by the oracle / | function fulfill(bytes32 _requestId, uint256 _data)
public
recordChainlinkFulfillment(_requestId)
| function fulfill(bytes32 _requestId, uint256 _data)
public
recordChainlinkFulfillment(_requestId)
| 43,378 |
20 | // Withdraw (alice & bob) | alice.withdraw(30 ether);
bob.withdraw(30 ether);
assertEq(token.balanceOf(address(alice)), 45 ether);
assertEq(token.balanceOf(address(bob)), 45 ether);
assertEq(token.balanceOf(address(vault)), 0 ether);
assertEq(vault.balanceOf(address(alice)), 0 ether);
assertEq(vault.balanceOf(address(bob)), 0 ether);
| alice.withdraw(30 ether);
bob.withdraw(30 ether);
assertEq(token.balanceOf(address(alice)), 45 ether);
assertEq(token.balanceOf(address(bob)), 45 ether);
assertEq(token.balanceOf(address(vault)), 0 ether);
assertEq(vault.balanceOf(address(alice)), 0 ether);
assertEq(vault.balanceOf(address(bob)), 0 ether);
| 3,250 |
44 | // Cannot withdraw more than pool's balance | require(
pool.totalLp >= amount,
"emergency withdraw: pool total not enough"
);
user.amount = 0;
user.rewardDebt = 0;
user.rewardLockedUp = 0;
user.nextHarvestUntil = 0;
pool.totalLp -= amount;
| require(
pool.totalLp >= amount,
"emergency withdraw: pool total not enough"
);
user.amount = 0;
user.rewardDebt = 0;
user.rewardLockedUp = 0;
user.nextHarvestUntil = 0;
pool.totalLp -= amount;
| 17,587 |
98 | // `hat` address is unique root user (has every role) and the unique owner of role 0 (typically 'sys' or 'internal') | contract DSChief is DSRoles, DSChiefApprovals {
function DSChief(DSToken GOV, DSToken IOU, uint MAX_YAYS)
DSChiefApprovals (GOV, IOU, MAX_YAYS)
public
{
authority = this;
owner = 0;
}
function setOwner(address owner_) public {
owner_;
revert();
}
function setAuthority(DSAuthority authority_) public {
authority_;
revert();
}
function isUserRoot(address who)
public
constant
returns (bool)
{
return (who == hat);
}
function setRootUser(address who, bool enabled) public {
who; enabled;
revert();
}
}
| contract DSChief is DSRoles, DSChiefApprovals {
function DSChief(DSToken GOV, DSToken IOU, uint MAX_YAYS)
DSChiefApprovals (GOV, IOU, MAX_YAYS)
public
{
authority = this;
owner = 0;
}
function setOwner(address owner_) public {
owner_;
revert();
}
function setAuthority(DSAuthority authority_) public {
authority_;
revert();
}
function isUserRoot(address who)
public
constant
returns (bool)
{
return (who == hat);
}
function setRootUser(address who, bool enabled) public {
who; enabled;
revert();
}
}
| 7,590 |
312 | // Decreases the mocked timestamp value, used only for testing purposes/ | function mockDecreaseTime(uint256 _seconds) external {
if (mockedTimestamp != 0) mockedTimestamp = mockedTimestamp.sub(_seconds);
else mockedTimestamp = block.timestamp.sub(_seconds);
}
| function mockDecreaseTime(uint256 _seconds) external {
if (mockedTimestamp != 0) mockedTimestamp = mockedTimestamp.sub(_seconds);
else mockedTimestamp = block.timestamp.sub(_seconds);
}
| 46,440 |
25 | // Validate ilk | bytes32 _ilk = _join.ilk();
require(_ilk != 0, "IlkRegistry/ilk-adapter-invalid");
require(ilkData[_ilk].join == address(0), "IlkRegistry/ilk-already-exists");
(address _pip,) = spot.ilks(_ilk);
require(_pip != address(0), "IlkRegistry/pip-invalid");
(address _xlip,,,) = dog.ilks(_ilk);
uint96 _class = 1;
| bytes32 _ilk = _join.ilk();
require(_ilk != 0, "IlkRegistry/ilk-adapter-invalid");
require(ilkData[_ilk].join == address(0), "IlkRegistry/ilk-already-exists");
(address _pip,) = spot.ilks(_ilk);
require(_pip != address(0), "IlkRegistry/pip-invalid");
(address _xlip,,,) = dog.ilks(_ilk);
uint96 _class = 1;
| 23,968 |
30 | // Increase the amount of tokens that an owner allowed to a spender. approve should be called when allowed[_spender] == 0. To increment allowed value is better to use this function to avoid 2 calls (and wait until the 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,
uint256 _addedValue
)
public
returns (bool)
| function increaseApproval(
address _spender,
uint256 _addedValue
)
public
returns (bool)
| 8,052 |
85 | // PartyDAO receives TOKEN_FEE_BASIS_POINTS of the total supply | _partyDAOAmount = (_totalSupply * TOKEN_FEE_BASIS_POINTS) / 10000;
| _partyDAOAmount = (_totalSupply * TOKEN_FEE_BASIS_POINTS) / 10000;
| 38,302 |
23 | // the execution order for the next three lines is crutial | _updateGlobalStatus();
_updateVLiquidity(vLiquidity, true);
if (address(iziToken) == address(0)) {
| _updateGlobalStatus();
_updateVLiquidity(vLiquidity, true);
if (address(iziToken) == address(0)) {
| 45,754 |
109 | // Maintaining Profits | _profitStakers[_lowRiskUsers[i]][true] += _poolBalances[_lowRiskUsers[i]][true].mul(120).div(1000);
| _profitStakers[_lowRiskUsers[i]][true] += _poolBalances[_lowRiskUsers[i]][true].mul(120).div(1000);
| 30,202 |
220 | // Converts digg into wbtc equivalent | amount = amount.mul(1e18).div(10**tokenList[0].decimals); // Normalize the digg amount
uint256 _wbtc = amount.mul(getDiggUSDPrice()).div(1e18); // Get the USD value of digg
_wbtc = _wbtc.mul(1e18).div(getWBTCUSDPrice());
_wbtc = _wbtc.mul(10**tokenList[1].decimals).div(1e18); // Convert to wbtc units
return _wbtc;
| amount = amount.mul(1e18).div(10**tokenList[0].decimals); // Normalize the digg amount
uint256 _wbtc = amount.mul(getDiggUSDPrice()).div(1e18); // Get the USD value of digg
_wbtc = _wbtc.mul(1e18).div(getWBTCUSDPrice());
_wbtc = _wbtc.mul(10**tokenList[1].decimals).div(1e18); // Convert to wbtc units
return _wbtc;
| 70,809 |
13 | // Sanity check if last claim was on or after emission end | if (lastClaimed >= emissionEnd) return 0;
uint256 accumulationPeriod = block.timestamp < emissionEnd ? block.timestamp : emissionEnd; // Getting the min value of both
uint256 totalAccumulated = accumulationPeriod.sub(lastClaimed).mul(emissionPerDay).div(SECONDS_IN_A_DAY);
| if (lastClaimed >= emissionEnd) return 0;
uint256 accumulationPeriod = block.timestamp < emissionEnd ? block.timestamp : emissionEnd; // Getting the min value of both
uint256 totalAccumulated = accumulationPeriod.sub(lastClaimed).mul(emissionPerDay).div(SECONDS_IN_A_DAY);
| 29,807 |
124 | // Make an investment. The crowdsale must be running for one to invest.We must have not pressed the emergency brake.receiver The Ethereum address who receives the tokens customerId (optional) UUID v4 to track the successful payments on the server side/ | function investInternal(address receiver, uint128 customerId) stopInEmergency notFinished private {
// Determine if it's a good time to accept investment from this participant
if (getState() == State.PreFunding) {
// Are we whitelisted for early deposit
require(earlyParticipantWhitelist[msg.sender]);
}
uint weiAmount;
uint tokenAmount;
(weiAmount, tokenAmount) = calculateTokenAmount(msg.value, receiver);
// Sanity check against bad implementation.
assert(weiAmount <= msg.value);
// Dust transaction if no tokens can be given
require(tokenAmount != 0);
if (investedAmountOf[receiver] == 0) {
// A new investor
investorCount++;
}
updateInvestorFunds(tokenAmount, weiAmount, receiver, customerId);
// Pocket the money
multisigWallet.transfer(weiAmount);
// Return excess of money
returnExcedent(msg.value.sub(weiAmount), msg.sender);
}
| function investInternal(address receiver, uint128 customerId) stopInEmergency notFinished private {
// Determine if it's a good time to accept investment from this participant
if (getState() == State.PreFunding) {
// Are we whitelisted for early deposit
require(earlyParticipantWhitelist[msg.sender]);
}
uint weiAmount;
uint tokenAmount;
(weiAmount, tokenAmount) = calculateTokenAmount(msg.value, receiver);
// Sanity check against bad implementation.
assert(weiAmount <= msg.value);
// Dust transaction if no tokens can be given
require(tokenAmount != 0);
if (investedAmountOf[receiver] == 0) {
// A new investor
investorCount++;
}
updateInvestorFunds(tokenAmount, weiAmount, receiver, customerId);
// Pocket the money
multisigWallet.transfer(weiAmount);
// Return excess of money
returnExcedent(msg.value.sub(weiAmount), msg.sender);
}
| 35,329 |
3 | // original allocation from the list and deducting minted tokens). |
error ReviewAdminCannotBeAddressZero(); // We cannot use the zero address (address(0)) as a platformAdmin.
error RoyaltyFeeWillExceedSalePrice(); // The ERC2981 royalty specified will exceed the sale price.
error ShareTotalCannotBeZero(); // The total of all the shares cannot be nothing.
error SliceOutOfBounds(); // The bytes slice operation was out of bounds.
error SliceOverflow(); // The bytes slice operation overlowed.
|
error ReviewAdminCannotBeAddressZero(); // We cannot use the zero address (address(0)) as a platformAdmin.
error RoyaltyFeeWillExceedSalePrice(); // The ERC2981 royalty specified will exceed the sale price.
error ShareTotalCannotBeZero(); // The total of all the shares cannot be nothing.
error SliceOutOfBounds(); // The bytes slice operation was out of bounds.
error SliceOverflow(); // The bytes slice operation overlowed.
| 37,017 |
13 | // AGENT / | function _installAgentApp(Kernel _dao) internal returns (Agent) {
bytes memory initializeData = abi.encodeWithSelector(Agent(0).initialize.selector);
Agent agent = Agent(_installDefaultApp(_dao, AGENT_APP_ID, initializeData));
// We assume that installing the Agent app as a default app means the DAO should have its
// Vault replaced by the Agent. Thus, we also set the DAO's recovery app to the Agent.
_dao.setRecoveryVaultAppId(AGENT_APP_ID);
return agent;
}
| function _installAgentApp(Kernel _dao) internal returns (Agent) {
bytes memory initializeData = abi.encodeWithSelector(Agent(0).initialize.selector);
Agent agent = Agent(_installDefaultApp(_dao, AGENT_APP_ID, initializeData));
// We assume that installing the Agent app as a default app means the DAO should have its
// Vault replaced by the Agent. Thus, we also set the DAO's recovery app to the Agent.
_dao.setRecoveryVaultAppId(AGENT_APP_ID);
return agent;
}
| 7,367 |
33 | // Sells underlying for hTokens.// Requirements:/ - The caller must have allowed DSProxy to spend `underlyingIn` tokens.//hifiPool The address of the HifiPool contract./underlyingIn The exact amount of underlying that the user wants to sell./minHTokenOut The minimum amount of hTokens that the user is willing to accept. | function sellUnderlying(
IHifiPool hifiPool,
uint256 underlyingIn,
uint256 minHTokenOut
) external;
| function sellUnderlying(
IHifiPool hifiPool,
uint256 underlyingIn,
uint256 minHTokenOut
) external;
| 41,057 |
36 | // adding transfer event and _from address as null address | emit Transfer(0x0, msg.sender, _value);
return true;
| emit Transfer(0x0, msg.sender, _value);
return true;
| 3,657 |
390 | // This function allows governor to transfer governance to a new governor and emits event/_governor address Address of new governor | function setGovernor(address _governor) public onlyGovernor {
require(_governor != address(0), "Can't set zero address");
governor = _governor;
emit GovernorSet(governor);
}
| function setGovernor(address _governor) public onlyGovernor {
require(_governor != address(0), "Can't set zero address");
governor = _governor;
emit GovernorSet(governor);
}
| 59,364 |
129 | // Set the contract beneficiary address | function setContractBeneficiary(address payable beneficiary)
public
onlyOwner
| function setContractBeneficiary(address payable beneficiary)
public
onlyOwner
| 1,551 |
104 | // Approve the passed address to spend the specified amount of tokens on behalf of msg.senderand then call `onApprovalReceived` on spender.Beware that changing an allowance with this method brings the risk that someone may use both the oldand the new allowance by unfortunate transaction ordering. One possible solution to mitigate thisrace condition is to first reduce the spender's allowance to 0 and set the desired value afterwards: spender address The address which will spend the funds value uint256 The amount of tokens to be spent data bytes Additional data with no specified format, sent in call to `spender` / | function approveAndCall(address spender, uint256 value, bytes calldata data) external returns (bool);
| function approveAndCall(address spender, uint256 value, bytes calldata data) external returns (bool);
| 14,283 |
17 | // Emitted when the allowance of a `spender` for an `owner` is set by | * a call to {approve}. `value` is the new allowance.
function transferFrom(
address sender,
address recipient,
uint256 amount
) external returns (bool);
*/
event Approval(address indexed owner, address indexed spender, uint256 value);
}
| * a call to {approve}. `value` is the new allowance.
function transferFrom(
address sender,
address recipient,
uint256 amount
) external returns (bool);
*/
event Approval(address indexed owner, address indexed spender, uint256 value);
}
| 337 |
193 | // sharing percents, 10000 == 100% | uint256 public constant REFERRER_SHARE_PCT = 1000; //10%
uint256 public constant NODE_SHARE_LV1_PCT = 400;
uint256 public constant NODE_SHARE_LV2_PCT = 300;
uint256 public constant NODE_SHARE_LV3_PCT = 300;
uint256 public constant NODE_SHARE_LV4_PCT = 200;
uint256 public constant NODE_SHARE_TOTAL_PCT =
NODE_SHARE_LV1_PCT + NODE_SHARE_LV2_PCT + NODE_SHARE_LV3_PCT + NODE_SHARE_LV4_PCT;
uint256 public constant REFERRAL_TOTAL_PCT = REFERRER_SHARE_PCT + NODE_SHARE_TOTAL_PCT;
mapping(address => uint256) public referrerSushiRewards;
| uint256 public constant REFERRER_SHARE_PCT = 1000; //10%
uint256 public constant NODE_SHARE_LV1_PCT = 400;
uint256 public constant NODE_SHARE_LV2_PCT = 300;
uint256 public constant NODE_SHARE_LV3_PCT = 300;
uint256 public constant NODE_SHARE_LV4_PCT = 200;
uint256 public constant NODE_SHARE_TOTAL_PCT =
NODE_SHARE_LV1_PCT + NODE_SHARE_LV2_PCT + NODE_SHARE_LV3_PCT + NODE_SHARE_LV4_PCT;
uint256 public constant REFERRAL_TOTAL_PCT = REFERRER_SHARE_PCT + NODE_SHARE_TOTAL_PCT;
mapping(address => uint256) public referrerSushiRewards;
| 11,416 |
29 | // only allow one reward for each challenge | bytes32 solution = solutionForChallenge[challengeNumber];
solutionForChallenge[challengeNumber] = digest;
if(solution != 0x0) revert(); //prevent the same answer from awarding twice
uint reward_amount = getMiningReward();
balances[msg.sender] = balances[msg.sender].add(reward_amount);
tokensMinted = tokensMinted.add(reward_amount);
| bytes32 solution = solutionForChallenge[challengeNumber];
solutionForChallenge[challengeNumber] = digest;
if(solution != 0x0) revert(); //prevent the same answer from awarding twice
uint reward_amount = getMiningReward();
balances[msg.sender] = balances[msg.sender].add(reward_amount);
tokensMinted = tokensMinted.add(reward_amount);
| 48,171 |
7 | // prevent front-running changing the price | require(totalCost <= maxCost, "Total cost exceeds max cost.");
require(msg.value >= totalCost, "Insufficient funds sent.");
| require(totalCost <= maxCost, "Total cost exceeds max cost.");
require(msg.value >= totalCost, "Insufficient funds sent.");
| 24,090 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.