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 |
|---|---|---|---|---|
236 | // Tokens can be managed by their owner or approved accounts via {approve} or {setApprovalForAll}. Tokens start existing when they are minted (`_mint`),and stop existing when they are burned (`_burn`). / | function _exists(uint256 tokenId) internal view virtual returns (bool) {
return _tokenOwners.contains(tokenId);
}
| function _exists(uint256 tokenId) internal view virtual returns (bool) {
return _tokenOwners.contains(tokenId);
}
| 417 |
7 | // brews tokens created per block. | uint256 public rewardPerBlock;
| uint256 public rewardPerBlock;
| 7,814 |
1 | // The `sellTokenAddress` field from the API response. | IERC20 sellToken,
| IERC20 sellToken,
| 45,097 |
21 | // Because of the previous require, we know that if msg.sender != withdrawer then currentAllowance >= shares | _setAllowance(withdrawer, msg.sender, currentAllowance - shares);
| _setAllowance(withdrawer, msg.sender, currentAllowance - shares);
| 52,289 |
249 | // CurveGaugeV2RewardsHandlerBase Contract/Enzyme Council <[email protected]>/Base contract for handling claiming and reinvesting rewards for a Curve pool/ that uses the LiquidityGaugeV2 contract | abstract contract CurveGaugeV2RewardsHandlerBase is CurveGaugeV2ActionsMixin {
using AddressArrayLib for address[];
address private immutable CURVE_GAUGE_V2_REWARDS_HANDLER_CRV_TOKEN;
address private immutable CURVE_GAUGE_V2_REWARDS_HANDLER_MINTER;
constructor(address _minter, address _crvToken) public {
CURVE_GAUGE_V2_REWARDS_HANDLER_CRV_TOKEN = _crvToken;
CURVE_GAUGE_V2_REWARDS_HANDLER_MINTER = _minter;
}
/// @dev Helper to claim all rewards (CRV and pool-specific).
/// Requires contract to be approved to use mint_for().
function __curveGaugeV2ClaimAllRewards(address _gauge, address _target) internal {
// Claim owed $CRV
ICurveMinter(CURVE_GAUGE_V2_REWARDS_HANDLER_MINTER).mint_for(_gauge, _target);
// Claim owed pool-specific rewards
__curveGaugeV2ClaimRewards(_gauge, _target);
}
/// @dev Helper to claim all rewards, then pull either the newly claimed balances only,
/// or full vault balances into the current contract
function __curveGaugeV2ClaimRewardsAndPullBalances(
address _gauge,
address _target,
bool _useFullBalances
)
internal
returns (address[] memory rewardsTokens_, uint256[] memory rewardsTokenAmountsPulled_)
{
if (_useFullBalances) {
return __curveGaugeV2ClaimRewardsAndPullFullBalances(_gauge, _target);
}
return __curveGaugeV2ClaimRewardsAndPullClaimedBalances(_gauge, _target);
}
/// @dev Helper to claim all rewards, then pull only the newly claimed balances
/// of all rewards tokens into the current contract
function __curveGaugeV2ClaimRewardsAndPullClaimedBalances(address _gauge, address _target)
internal
returns (address[] memory rewardsTokens_, uint256[] memory rewardsTokenAmountsPulled_)
{
rewardsTokens_ = __curveGaugeV2GetRewardsTokensWithCrv(_gauge);
uint256[] memory rewardsTokenPreClaimBalances = new uint256[](rewardsTokens_.length);
for (uint256 i; i < rewardsTokens_.length; i++) {
rewardsTokenPreClaimBalances[i] = ERC20(rewardsTokens_[i]).balanceOf(_target);
}
__curveGaugeV2ClaimAllRewards(_gauge, _target);
rewardsTokenAmountsPulled_ = __pullPartialAssetBalances(
_target,
rewardsTokens_,
rewardsTokenPreClaimBalances
);
return (rewardsTokens_, rewardsTokenAmountsPulled_);
}
/// @dev Helper to claim all rewards, then pull the full balances of all rewards tokens
/// in the target into the current contract
function __curveGaugeV2ClaimRewardsAndPullFullBalances(address _gauge, address _target)
internal
returns (address[] memory rewardsTokens_, uint256[] memory rewardsTokenAmountsPulled_)
{
__curveGaugeV2ClaimAllRewards(_gauge, _target);
rewardsTokens_ = __curveGaugeV2GetRewardsTokensWithCrv(_gauge);
rewardsTokenAmountsPulled_ = __pullFullAssetBalances(_target, rewardsTokens_);
return (rewardsTokens_, rewardsTokenAmountsPulled_);
}
/// @dev Helper to get all rewards tokens for staking LP tokens
function __curveGaugeV2GetRewardsTokensWithCrv(address _gauge)
internal
view
returns (address[] memory rewardsTokens_)
{
return
__curveGaugeV2GetRewardsTokens(_gauge).addUniqueItem(
CURVE_GAUGE_V2_REWARDS_HANDLER_CRV_TOKEN
);
}
///////////////////
// STATE GETTERS //
///////////////////
/// @notice Gets the `CURVE_GAUGE_V2_REWARDS_HANDLER_CRV_TOKEN` variable
/// @return crvToken_ The `CURVE_GAUGE_V2_REWARDS_HANDLER_CRV_TOKEN` variable value
function getCurveGaugeV2RewardsHandlerCrvToken() public view returns (address crvToken_) {
return CURVE_GAUGE_V2_REWARDS_HANDLER_CRV_TOKEN;
}
/// @notice Gets the `CURVE_GAUGE_V2_REWARDS_HANDLER_MINTER` variable
/// @return minter_ The `CURVE_GAUGE_V2_REWARDS_HANDLER_MINTER` variable value
function getCurveGaugeV2RewardsHandlerMinter() public view returns (address minter_) {
return CURVE_GAUGE_V2_REWARDS_HANDLER_MINTER;
}
}
| abstract contract CurveGaugeV2RewardsHandlerBase is CurveGaugeV2ActionsMixin {
using AddressArrayLib for address[];
address private immutable CURVE_GAUGE_V2_REWARDS_HANDLER_CRV_TOKEN;
address private immutable CURVE_GAUGE_V2_REWARDS_HANDLER_MINTER;
constructor(address _minter, address _crvToken) public {
CURVE_GAUGE_V2_REWARDS_HANDLER_CRV_TOKEN = _crvToken;
CURVE_GAUGE_V2_REWARDS_HANDLER_MINTER = _minter;
}
/// @dev Helper to claim all rewards (CRV and pool-specific).
/// Requires contract to be approved to use mint_for().
function __curveGaugeV2ClaimAllRewards(address _gauge, address _target) internal {
// Claim owed $CRV
ICurveMinter(CURVE_GAUGE_V2_REWARDS_HANDLER_MINTER).mint_for(_gauge, _target);
// Claim owed pool-specific rewards
__curveGaugeV2ClaimRewards(_gauge, _target);
}
/// @dev Helper to claim all rewards, then pull either the newly claimed balances only,
/// or full vault balances into the current contract
function __curveGaugeV2ClaimRewardsAndPullBalances(
address _gauge,
address _target,
bool _useFullBalances
)
internal
returns (address[] memory rewardsTokens_, uint256[] memory rewardsTokenAmountsPulled_)
{
if (_useFullBalances) {
return __curveGaugeV2ClaimRewardsAndPullFullBalances(_gauge, _target);
}
return __curveGaugeV2ClaimRewardsAndPullClaimedBalances(_gauge, _target);
}
/// @dev Helper to claim all rewards, then pull only the newly claimed balances
/// of all rewards tokens into the current contract
function __curveGaugeV2ClaimRewardsAndPullClaimedBalances(address _gauge, address _target)
internal
returns (address[] memory rewardsTokens_, uint256[] memory rewardsTokenAmountsPulled_)
{
rewardsTokens_ = __curveGaugeV2GetRewardsTokensWithCrv(_gauge);
uint256[] memory rewardsTokenPreClaimBalances = new uint256[](rewardsTokens_.length);
for (uint256 i; i < rewardsTokens_.length; i++) {
rewardsTokenPreClaimBalances[i] = ERC20(rewardsTokens_[i]).balanceOf(_target);
}
__curveGaugeV2ClaimAllRewards(_gauge, _target);
rewardsTokenAmountsPulled_ = __pullPartialAssetBalances(
_target,
rewardsTokens_,
rewardsTokenPreClaimBalances
);
return (rewardsTokens_, rewardsTokenAmountsPulled_);
}
/// @dev Helper to claim all rewards, then pull the full balances of all rewards tokens
/// in the target into the current contract
function __curveGaugeV2ClaimRewardsAndPullFullBalances(address _gauge, address _target)
internal
returns (address[] memory rewardsTokens_, uint256[] memory rewardsTokenAmountsPulled_)
{
__curveGaugeV2ClaimAllRewards(_gauge, _target);
rewardsTokens_ = __curveGaugeV2GetRewardsTokensWithCrv(_gauge);
rewardsTokenAmountsPulled_ = __pullFullAssetBalances(_target, rewardsTokens_);
return (rewardsTokens_, rewardsTokenAmountsPulled_);
}
/// @dev Helper to get all rewards tokens for staking LP tokens
function __curveGaugeV2GetRewardsTokensWithCrv(address _gauge)
internal
view
returns (address[] memory rewardsTokens_)
{
return
__curveGaugeV2GetRewardsTokens(_gauge).addUniqueItem(
CURVE_GAUGE_V2_REWARDS_HANDLER_CRV_TOKEN
);
}
///////////////////
// STATE GETTERS //
///////////////////
/// @notice Gets the `CURVE_GAUGE_V2_REWARDS_HANDLER_CRV_TOKEN` variable
/// @return crvToken_ The `CURVE_GAUGE_V2_REWARDS_HANDLER_CRV_TOKEN` variable value
function getCurveGaugeV2RewardsHandlerCrvToken() public view returns (address crvToken_) {
return CURVE_GAUGE_V2_REWARDS_HANDLER_CRV_TOKEN;
}
/// @notice Gets the `CURVE_GAUGE_V2_REWARDS_HANDLER_MINTER` variable
/// @return minter_ The `CURVE_GAUGE_V2_REWARDS_HANDLER_MINTER` variable value
function getCurveGaugeV2RewardsHandlerMinter() public view returns (address minter_) {
return CURVE_GAUGE_V2_REWARDS_HANDLER_MINTER;
}
}
| 83,848 |
12 | // Value (subprotocol NFT ID) for primary type | uint256 primary;
| uint256 primary;
| 12,985 |
62 | // TokenMintERC20MintableTokenMintable ERC20 token with burning and optional functions implemented.Any address with minter role can mint new tokens.For full specification of ERC-20 standard see: / | contract TokenMintERC20MintableToken is ERC20Mintable {
string private _name;
string private _symbol;
uint8 private _decimals;
/**
* @dev Constructor.
* @param name name of the token
* @param symbol symbol of the token, 3-4 chars is recommended
* @param decimals number of decimal places of one token unit, 18 is widely used
* @param initialSupply initial supply of tokens in lowest units (depending on decimals)
* @param tokenOwnerAddress address that gets 100% of token supply
*/
constructor(string memory name, string memory symbol, uint8 decimals, uint256 initialSupply, address payable feeReceiver, address tokenOwnerAddress) public payable {
_name = name;
_symbol = symbol;
_decimals = decimals;
// set tokenOwnerAddress as owner of initial supply, more tokens can be minted later
_mint(tokenOwnerAddress, initialSupply);
// pay the service fee for contract deployment
feeReceiver.transfer(msg.value);
}
/**
* @dev transfers minter role from msg.sender to newMinter
*/
function transferMinterRole(address newMinter) public {
addMinter(newMinter);
renounceMinter();
}
/**
* @dev Burns a specific amount of tokens.
* @param value The amount of lowest token units to be burned.
*/
function burn(uint256 value) public {
_burn(msg.sender, value);
}
// optional functions from ERC20 stardard
/**
* @return the name of the token.
*/
function name() public view returns (string memory) {
return _name;
}
/**
* @return the symbol of the token.
*/
function symbol() public view returns (string memory) {
return _symbol;
}
/**
* @return the number of decimals of the token.
*/
function decimals() public view returns (uint8) {
return _decimals;
}
} | contract TokenMintERC20MintableToken is ERC20Mintable {
string private _name;
string private _symbol;
uint8 private _decimals;
/**
* @dev Constructor.
* @param name name of the token
* @param symbol symbol of the token, 3-4 chars is recommended
* @param decimals number of decimal places of one token unit, 18 is widely used
* @param initialSupply initial supply of tokens in lowest units (depending on decimals)
* @param tokenOwnerAddress address that gets 100% of token supply
*/
constructor(string memory name, string memory symbol, uint8 decimals, uint256 initialSupply, address payable feeReceiver, address tokenOwnerAddress) public payable {
_name = name;
_symbol = symbol;
_decimals = decimals;
// set tokenOwnerAddress as owner of initial supply, more tokens can be minted later
_mint(tokenOwnerAddress, initialSupply);
// pay the service fee for contract deployment
feeReceiver.transfer(msg.value);
}
/**
* @dev transfers minter role from msg.sender to newMinter
*/
function transferMinterRole(address newMinter) public {
addMinter(newMinter);
renounceMinter();
}
/**
* @dev Burns a specific amount of tokens.
* @param value The amount of lowest token units to be burned.
*/
function burn(uint256 value) public {
_burn(msg.sender, value);
}
// optional functions from ERC20 stardard
/**
* @return the name of the token.
*/
function name() public view returns (string memory) {
return _name;
}
/**
* @return the symbol of the token.
*/
function symbol() public view returns (string memory) {
return _symbol;
}
/**
* @return the number of decimals of the token.
*/
function decimals() public view returns (uint8) {
return _decimals;
}
} | 11,966 |
336 | // Emitted when an attester is disabled attester newly disabled attester / | event AttesterDisabled(address indexed attester);
| event AttesterDisabled(address indexed attester);
| 2,081 |
63 | // 거리 계산 (재전투 시 중복 계산을 방지하기 위해 여기서 계산합니다.) | uint distance = (params1[i] < params3[i] ? params3[i] - params1[i] : params1[i] - params3[i]) + (params2[i] < params4[i] ? params4[i] - params2[i] : params2[i] - params4[i]);
record.enemy = armyManager.getPositionOwner(params3[i], params4[i]);
moveAndAttack(params1[i], params2[i], params3[i], params4[i], record, distance, 0);
| uint distance = (params1[i] < params3[i] ? params3[i] - params1[i] : params1[i] - params3[i]) + (params2[i] < params4[i] ? params4[i] - params2[i] : params2[i] - params4[i]);
record.enemy = armyManager.getPositionOwner(params3[i], params4[i]);
moveAndAttack(params1[i], params2[i], params3[i], params4[i], record, distance, 0);
| 3,591 |
6 | // Initializer that marks the contract as initialized.It is important to run this if you had deployed a previous version of a Migratable contract. / | function initialize() isInitializer("Migratable", "1.2.1") public {
}
| function initialize() isInitializer("Migratable", "1.2.1") public {
}
| 19,364 |
133 | // See {AbstractBridgeAgent} documentation for some core concepts description./ Initializes the agent / | constructor(address _bridgeSigner, address payable _treasurer)
AbstractBridgeAgent(_bridgeSigner, _treasurer)
| constructor(address _bridgeSigner, address payable _treasurer)
AbstractBridgeAgent(_bridgeSigner, _treasurer)
| 52,354 |
1 | // prevent anyone else. | return 99;
| return 99;
| 12,524 |
171 | // Total number of tokens used as collateral in circulation. / | uint256 public totalCollateralTokens;
| uint256 public totalCollateralTokens;
| 22,916 |
89 | // Pauses transactions./Callable only by the founder./Callable only when the contract is not paused./ return success | function pause() public onlyFounder whenNotPaused returns (bool success) {
// Set pause
paused = true;
// See {event Pause}
emit Pause();
// Returns true on success.
return true;
}
| function pause() public onlyFounder whenNotPaused returns (bool success) {
// Set pause
paused = true;
// See {event Pause}
emit Pause();
// Returns true on success.
return true;
}
| 4,792 |
12 | // send won Dogs to tresury | function transferDog(uint256 dogId) external {
dogs.transferFrom(address(this), treasury, dogId);
}
| function transferDog(uint256 dogId) external {
dogs.transferFrom(address(this), treasury, dogId);
}
| 48,370 |
37 | // buy | require(amount <= _maxTxAmount);
require(tradingOpen);
| require(amount <= _maxTxAmount);
require(tradingOpen);
| 12,600 |
48 | // For Backwards compatibilityreturn The decimals of the token. Forced to 18 in ERC777. / | function decimals() public erc20 view returns (uint8) {return uint8(18);}
/**
* @notice ERC20 backwards compatible transfer.
* @param _to The address of the recipient
* @param _amount The number of tokens to be transferred
* @return `true`, if the transfer can't be done, it should fail.
*/
function transfer(address _to, uint256 _amount) public erc20 returns (bool success) {
doSend(msg.sender, _to, _amount, "", msg.sender, "", false);
return true;
}
| function decimals() public erc20 view returns (uint8) {return uint8(18);}
/**
* @notice ERC20 backwards compatible transfer.
* @param _to The address of the recipient
* @param _amount The number of tokens to be transferred
* @return `true`, if the transfer can't be done, it should fail.
*/
function transfer(address _to, uint256 _amount) public erc20 returns (bool success) {
doSend(msg.sender, _to, _amount, "", msg.sender, "", false);
return true;
}
| 14,921 |
108 | // if(!_isExcludedFromFees[from] && !_isExcludedFromFees[to] && to==uniswapV2Pair){ require(amount <= maxSellTransactionAmount, "amount exceeds the maxSellTransactionAmount."); } |
if(!inSwapAndLiquify && to==uniswapV2Pair &&
swapAndLiquifyEnabled &&
!_isExcludedFromFees[from])
{
swapAndLiquify();
}
|
if(!inSwapAndLiquify && to==uniswapV2Pair &&
swapAndLiquifyEnabled &&
!_isExcludedFromFees[from])
{
swapAndLiquify();
}
| 15,240 |
0 | // Lyrics updated for this edition | event SongUpdated(
address target,
address sender,
SongMetadata songMetadata,
ProjectMetadata projectMetadata,
string[] tags,
Credit[] credits
);
| event SongUpdated(
address target,
address sender,
SongMetadata songMetadata,
ProjectMetadata projectMetadata,
string[] tags,
Credit[] credits
);
| 21,320 |
89 | // Transfer underlying to the desired receiver | Safe.transfer(IERC20(underlying), r, returned);
return returned;
| Safe.transfer(IERC20(underlying), r, returned);
return returned;
| 30,265 |
1 | // The address of the term auction bidlocker that loan is being rolled into | address rolloverAuction;
| address rolloverAuction;
| 27,969 |
261 | // check that otoken to redeem is whitelisted | require(whitelist.isWhitelistedOtoken(_args.otoken), "C27");
(address collateral, address underlying, address strike, uint256 expiry) = _getOtokenDetails(address(otoken));
| require(whitelist.isWhitelistedOtoken(_args.otoken), "C27");
(address collateral, address underlying, address strike, uint256 expiry) = _getOtokenDetails(address(otoken));
| 34,546 |
0 | // ABIEncoderV2 uses an array of Calls for executing generic batch calls. | struct Call {
address to;
bytes data;
}
| struct Call {
address to;
bytes data;
}
| 52,570 |
69 | // Sets block.prevrandao Not available on EVM versions before Paris. Use `difficulty` instead. If used on unsupported EVM versions it will revert. | function prevrandao(bytes32 newPrevrandao) external;
| function prevrandao(bytes32 newPrevrandao) external;
| 30,886 |
57 | // Core settlement logic for buying an ERC721 asset. Used by `buyERC721` and `batchBuyERC721s`. | function _buyERC721(LibNFTOrder.NFTSellOrder memory sellOrder, LibSignature.Signature memory signature) internal {
(, bytes32 orderHash) = _buyNFT(sellOrder, signature, 1);
emit ERC721SellOrderFilled(
sellOrder.maker,
msg.sender,
sellOrder.erc20Token,
sellOrder.erc20TokenAmount,
sellOrder.nft,
sellOrder.nftId,
orderHash
);
}
| function _buyERC721(LibNFTOrder.NFTSellOrder memory sellOrder, LibSignature.Signature memory signature) internal {
(, bytes32 orderHash) = _buyNFT(sellOrder, signature, 1);
emit ERC721SellOrderFilled(
sellOrder.maker,
msg.sender,
sellOrder.erc20Token,
sellOrder.erc20TokenAmount,
sellOrder.nft,
sellOrder.nftId,
orderHash
);
}
| 43,149 |
18 | // update the isConfirmed to true for msg.sender | transaction.isConfirmed[msg.sender] = true;
| transaction.isConfirmed[msg.sender] = true;
| 41,812 |
9 | // requires each account to be verified with eth verify | require(ethVerify.verifiedUsers(msg.sender));
| require(ethVerify.verifiedUsers(msg.sender));
| 27,149 |
16 | // An elliptic curve arithmetics contract // Deployment: | ABI: [{"constant":true,"inputs":[{"name":"_ax","type":"uint256"},{"name":"_ay","type":"uint256"},{"name":"_az","type":"uint256"},{"name":"_bx","type":"uint256"},{"name":"_by","type":"uint256"},{"name":"_bz","type":"uint256"}],"name":"jadd","outputs":[{"name":"","type":"uint256"},{"name":"","type":"uint256"},{"name":"","type":"uint256"}],"payable":false,"type":"function"},{"constant":true,"inputs":[{"name":"_pub1","type":"uint256"},{"name":"_pub2","type":"uint256"}],"name":"hash_pubkey_to_pubkey","outputs":[{"name":"","type":"uint256"},{"name":"","type":"uint256"}],"payable":false,"type":"function"},{"constant":true,"inputs":[{"name":"_x","type":"uint256"},{"name":"_y_bit","type":"uint256"}],"name":"jrecover_y","outputs":[{"name":"","type":"uint256"}],"payable":false,"type":"function"},{"constant":true,"inputs":[{"name":"_q0","type":"uint256"},{"name":"_q1","type":"uint256"},{"name":"_q2","type":"uint256"}],"name":"jdecompose","outputs":[{"name":"","type":"uint256"},{"name":"","type":"uint256"}],"payable":false,"type":"function"},{"constant":true,"inputs":[{"name":"_ax","type":"uint256"},{"name":"_ay","type":"uint256"},{"name":"_az","type":"uint256"}],"name":"jdouble","outputs":[{"name":"","type":"uint256"},{"name":"","type":"uint256"},{"name":"","type":"uint256"}],"payable":false,"type":"function"},{"constant":true,"inputs":[{"name":"_data","type":"uint256"},{"name":"_bit","type":"uint256"}],"name":"isbit","outputs":[{"name":"","type":"uint256"}],"payable":false,"type":"function"},{"constant":true,"inputs":[{"name":"_b","type":"uint256"},{"name":"_e","type":"uint256"},{"name":"_m","type":"uint256"}],"name":"jexp","outputs":[{"name":"","type":"uint256"}],"payable":false,"type":"function"},{"constant":true,"inputs":[{"name":"_bx","type":"uint256"},{"name":"_by","type":"uint256"},{"name":"_bz","type":"uint256"},{"name":"_n","type":"uint256"}],"name":"jmul","outputs":[{"name":"","type":"uint256"},{"name":"","type":"uint256"},{"name":"","type":"uint256"}],"payable":false,"type":"function"},{"inputs":[],"type":"constructor"},{"payable":false,"type":"fallback"}]
Optimized: yes
Solidity version: v0.4.4
*/
pragma solidity ^0.4.0;
contract ArithLib {
uint constant internal P = 115792089237316195423570985008687907853269984665640564039457584007908834671663;
uint constant internal N = 115792089237316195423570985008687907852837564279074904382605163141518161494337;
uint constant internal M = 57896044618658097711785492504343953926634992332820282019728792003956564819968;
uint constant internal Gx = 55066263022277343669578718895168534326250603453777594175500187360389116729240;
uint constant internal Gy = 32670510020758816978083085130507043184471273380659243275938904335757337482424;
function ArithLib() { }
function jdouble(uint _ax, uint _ay, uint _az) constant returns (uint, uint, uint) {
if(_ay == 0) return (0, 0, 0);
uint nx = (
//m * m
(3 * _ax * _ax) * (3 * _ax * _ax) -
//2 * s
2 * (4 * _ax * (_ay * _ay))) % P;
uint ny = (
//m
(3 * _ax * _ax) *
//s - nx
((4 * _ax * (_ay * _ay)) - nx) -
//8 * ysq * ysq
8 * (_ay * _ay) * (_ay * _ay)) % P;
uint nz = (2 * _ay * _az) % P;
return (nx, ny, nz);
}
function jadd(uint _ax, uint _ay, uint _az, uint _bx, uint _by, uint _bz) constant returns (uint, uint, uint) {
if(_ay == 0) return(_bx, _by, _bz);
if(_by == 0) return(_ax, _ay, _az);
uint u1 = (_ax * _bz * _bz) % P;
uint u2 = (_bx * _az * _az) % P;
_bx = (_ay * _bz * _bz * _bz) % P;
_by = (_by * _az * _az * _az) % P;
//u1 == u2
if(u1 == u2) {
//s1 != s2
if(_bx != _by) return(0, 0, 1);
return jdouble(_ax, _ay, _az);
}
uint nx = ((_by - _bx) * (_by - _bx) - (u2 - u1) * (u2 - u1) * (u2 - u1) - 2 * u1 * (u2 - u1) * (u2 - u1)) % P;
return (
nx,
((_by - _bx) * (u1 * (u2 - u1) * (u2 - u1) - nx) - _bx * (u2 - u1) * (u2 - u1) * (u2 - u1)) % P,
((u2 - u1) * _az * _bz) % P);
}
function jmul(uint _bx, uint _by, uint _bz, uint _n) constant returns (uint, uint, uint) {
_n = _n % N;
if(((_by == 0)) || (_n == 0)) return(0, 0, 1);
uint ax = 0;
uint ay = 0;
uint az = 1;
uint b = M;
while(b > 0) {
(ax, ay, az) = jdouble(ax, ay, az);
if((_n & b) != 0) {
if(ay == 0) {
(ax, ay, az) = (_bx, _by, _bz);
} else {
(ax, ay, az) = jadd(ax, ay, az, _bx, _by, _bz);
}
}
b = b / 2;
}
return (ax, ay, az);
}
function jexp(uint _b, uint _e, uint _m) constant returns (uint) {
uint o = 1;
uint bit = M;
while (bit > 0) {
uint bitval = 0;
if(_e & bit > 0) bitval = 1;
o = mulmod(mulmod(o, o, _m), _b ** bitval, _m);
bitval = 0;
if(_e & (bit / 2) > 0) bitval = 1;
o = mulmod(mulmod(o, o, _m), _b ** bitval, _m);
bitval = 0;
if(_e & (bit / 4) > 0) bitval = 1;
o = mulmod(mulmod(o, o, _m), _b ** bitval, _m);
bitval = 0;
if(_e & (bit / 8) > 0) bitval = 1;
o = mulmod(mulmod(o, o, _m), _b ** bitval, _m);
bit = (bit / 16);
}
return o;
}
function jrecover_y(uint _x, uint _y_bit) constant returns (uint) {
uint xcubed = mulmod(mulmod(_x, _x, P), _x, P);
uint beta = jexp(addmod(xcubed, 7, P), ((P + 1) / 4), P);
uint y_is_positive = _y_bit ^ (beta % 2) ^ 1;
return(beta * y_is_positive + (P - beta) * (1 - y_is_positive));
}
function jdecompose(uint _q0, uint _q1, uint _q2) constant returns (uint, uint) {
uint ox = mulmod(_q0, jexp(_q2, P - 3, P), P);
uint oy = mulmod(_q1, jexp(_q2, P - 4, P), P);
return(ox, oy);
}
function isbit(uint _data, uint _bit) constant returns (uint) {
return (_data / 2**(_bit % 8)) % 2;
}
function hash_pubkey_to_pubkey(uint _pub1, uint _pub2) constant returns (uint, uint) {
uint x = uint(sha3(_pub1, _pub2));
while(true) {
uint xcubed = mulmod(mulmod(x, x, P), x, P);
uint beta = jexp(addmod(xcubed, 7, P), ((P + 1) / 4), P);
uint y = beta * (beta % 2) + (P - beta) * (1 - (beta % 2));
if(addmod(xcubed, 7, P) == mulmod(y, y, P)) return(x, y);
x = ((x + 1) % P);
}
}
function () {
throw;
}
}
| ABI: [{"constant":true,"inputs":[{"name":"_ax","type":"uint256"},{"name":"_ay","type":"uint256"},{"name":"_az","type":"uint256"},{"name":"_bx","type":"uint256"},{"name":"_by","type":"uint256"},{"name":"_bz","type":"uint256"}],"name":"jadd","outputs":[{"name":"","type":"uint256"},{"name":"","type":"uint256"},{"name":"","type":"uint256"}],"payable":false,"type":"function"},{"constant":true,"inputs":[{"name":"_pub1","type":"uint256"},{"name":"_pub2","type":"uint256"}],"name":"hash_pubkey_to_pubkey","outputs":[{"name":"","type":"uint256"},{"name":"","type":"uint256"}],"payable":false,"type":"function"},{"constant":true,"inputs":[{"name":"_x","type":"uint256"},{"name":"_y_bit","type":"uint256"}],"name":"jrecover_y","outputs":[{"name":"","type":"uint256"}],"payable":false,"type":"function"},{"constant":true,"inputs":[{"name":"_q0","type":"uint256"},{"name":"_q1","type":"uint256"},{"name":"_q2","type":"uint256"}],"name":"jdecompose","outputs":[{"name":"","type":"uint256"},{"name":"","type":"uint256"}],"payable":false,"type":"function"},{"constant":true,"inputs":[{"name":"_ax","type":"uint256"},{"name":"_ay","type":"uint256"},{"name":"_az","type":"uint256"}],"name":"jdouble","outputs":[{"name":"","type":"uint256"},{"name":"","type":"uint256"},{"name":"","type":"uint256"}],"payable":false,"type":"function"},{"constant":true,"inputs":[{"name":"_data","type":"uint256"},{"name":"_bit","type":"uint256"}],"name":"isbit","outputs":[{"name":"","type":"uint256"}],"payable":false,"type":"function"},{"constant":true,"inputs":[{"name":"_b","type":"uint256"},{"name":"_e","type":"uint256"},{"name":"_m","type":"uint256"}],"name":"jexp","outputs":[{"name":"","type":"uint256"}],"payable":false,"type":"function"},{"constant":true,"inputs":[{"name":"_bx","type":"uint256"},{"name":"_by","type":"uint256"},{"name":"_bz","type":"uint256"},{"name":"_n","type":"uint256"}],"name":"jmul","outputs":[{"name":"","type":"uint256"},{"name":"","type":"uint256"},{"name":"","type":"uint256"}],"payable":false,"type":"function"},{"inputs":[],"type":"constructor"},{"payable":false,"type":"fallback"}]
Optimized: yes
Solidity version: v0.4.4
*/
pragma solidity ^0.4.0;
contract ArithLib {
uint constant internal P = 115792089237316195423570985008687907853269984665640564039457584007908834671663;
uint constant internal N = 115792089237316195423570985008687907852837564279074904382605163141518161494337;
uint constant internal M = 57896044618658097711785492504343953926634992332820282019728792003956564819968;
uint constant internal Gx = 55066263022277343669578718895168534326250603453777594175500187360389116729240;
uint constant internal Gy = 32670510020758816978083085130507043184471273380659243275938904335757337482424;
function ArithLib() { }
function jdouble(uint _ax, uint _ay, uint _az) constant returns (uint, uint, uint) {
if(_ay == 0) return (0, 0, 0);
uint nx = (
//m * m
(3 * _ax * _ax) * (3 * _ax * _ax) -
//2 * s
2 * (4 * _ax * (_ay * _ay))) % P;
uint ny = (
//m
(3 * _ax * _ax) *
//s - nx
((4 * _ax * (_ay * _ay)) - nx) -
//8 * ysq * ysq
8 * (_ay * _ay) * (_ay * _ay)) % P;
uint nz = (2 * _ay * _az) % P;
return (nx, ny, nz);
}
function jadd(uint _ax, uint _ay, uint _az, uint _bx, uint _by, uint _bz) constant returns (uint, uint, uint) {
if(_ay == 0) return(_bx, _by, _bz);
if(_by == 0) return(_ax, _ay, _az);
uint u1 = (_ax * _bz * _bz) % P;
uint u2 = (_bx * _az * _az) % P;
_bx = (_ay * _bz * _bz * _bz) % P;
_by = (_by * _az * _az * _az) % P;
//u1 == u2
if(u1 == u2) {
//s1 != s2
if(_bx != _by) return(0, 0, 1);
return jdouble(_ax, _ay, _az);
}
uint nx = ((_by - _bx) * (_by - _bx) - (u2 - u1) * (u2 - u1) * (u2 - u1) - 2 * u1 * (u2 - u1) * (u2 - u1)) % P;
return (
nx,
((_by - _bx) * (u1 * (u2 - u1) * (u2 - u1) - nx) - _bx * (u2 - u1) * (u2 - u1) * (u2 - u1)) % P,
((u2 - u1) * _az * _bz) % P);
}
function jmul(uint _bx, uint _by, uint _bz, uint _n) constant returns (uint, uint, uint) {
_n = _n % N;
if(((_by == 0)) || (_n == 0)) return(0, 0, 1);
uint ax = 0;
uint ay = 0;
uint az = 1;
uint b = M;
while(b > 0) {
(ax, ay, az) = jdouble(ax, ay, az);
if((_n & b) != 0) {
if(ay == 0) {
(ax, ay, az) = (_bx, _by, _bz);
} else {
(ax, ay, az) = jadd(ax, ay, az, _bx, _by, _bz);
}
}
b = b / 2;
}
return (ax, ay, az);
}
function jexp(uint _b, uint _e, uint _m) constant returns (uint) {
uint o = 1;
uint bit = M;
while (bit > 0) {
uint bitval = 0;
if(_e & bit > 0) bitval = 1;
o = mulmod(mulmod(o, o, _m), _b ** bitval, _m);
bitval = 0;
if(_e & (bit / 2) > 0) bitval = 1;
o = mulmod(mulmod(o, o, _m), _b ** bitval, _m);
bitval = 0;
if(_e & (bit / 4) > 0) bitval = 1;
o = mulmod(mulmod(o, o, _m), _b ** bitval, _m);
bitval = 0;
if(_e & (bit / 8) > 0) bitval = 1;
o = mulmod(mulmod(o, o, _m), _b ** bitval, _m);
bit = (bit / 16);
}
return o;
}
function jrecover_y(uint _x, uint _y_bit) constant returns (uint) {
uint xcubed = mulmod(mulmod(_x, _x, P), _x, P);
uint beta = jexp(addmod(xcubed, 7, P), ((P + 1) / 4), P);
uint y_is_positive = _y_bit ^ (beta % 2) ^ 1;
return(beta * y_is_positive + (P - beta) * (1 - y_is_positive));
}
function jdecompose(uint _q0, uint _q1, uint _q2) constant returns (uint, uint) {
uint ox = mulmod(_q0, jexp(_q2, P - 3, P), P);
uint oy = mulmod(_q1, jexp(_q2, P - 4, P), P);
return(ox, oy);
}
function isbit(uint _data, uint _bit) constant returns (uint) {
return (_data / 2**(_bit % 8)) % 2;
}
function hash_pubkey_to_pubkey(uint _pub1, uint _pub2) constant returns (uint, uint) {
uint x = uint(sha3(_pub1, _pub2));
while(true) {
uint xcubed = mulmod(mulmod(x, x, P), x, P);
uint beta = jexp(addmod(xcubed, 7, P), ((P + 1) / 4), P);
uint y = beta * (beta % 2) + (P - beta) * (1 - (beta % 2));
if(addmod(xcubed, 7, P) == mulmod(y, y, P)) return(x, y);
x = ((x + 1) % P);
}
}
function () {
throw;
}
}
| 41,775 |
62 | // -- Events -- |
event newPendingOwnership(address indexed from, address indexed to);
event newOwnership(address indexed from, address indexed to);
|
event newPendingOwnership(address indexed from, address indexed to);
event newOwnership(address indexed from, address indexed to);
| 12,135 |
24 | // check that at least two weeks have passed since the last reserve auction completed, and that the auction was not kicked within the past 72 hours | if (block.timestamp < lastBurnTimestamp + 2 weeks || block.timestamp - reserveAuction_.kicked <= 72 hours) {
revert ReserveAuctionTooSoon();
}
| if (block.timestamp < lastBurnTimestamp + 2 weeks || block.timestamp - reserveAuction_.kicked <= 72 hours) {
revert ReserveAuctionTooSoon();
}
| 40,123 |
12 | // Mapping to keep track of max drawings that can be purchased per address in a round | mapping(uint256 => mapping(uint256 => uint256)) public capsPerDrawing;
| mapping(uint256 => mapping(uint256 => uint256)) public capsPerDrawing;
| 65,610 |
24 | // Retrieves the storage root of an account. _address Address of the account to access.return Corresponding storage root. / | function getAccountStorageRoot(
address _address
)
override
public
view
returns (
bytes32
)
| function getAccountStorageRoot(
address _address
)
override
public
view
returns (
bytes32
)
| 25,504 |
126 | // Deposit incoming token and mint pool token i.e. shares. / | function _deposit(uint256 amount) internal whenNotPaused {
uint256 shares = _calculateShares(convertTo18(amount));
_beforeMinting(amount);
_mint(_msgSender(), shares);
}
| function _deposit(uint256 amount) internal whenNotPaused {
uint256 shares = _calculateShares(convertTo18(amount));
_beforeMinting(amount);
_mint(_msgSender(), shares);
}
| 8,115 |
6 | // Check if this token is a curve pool token | bool isCrvToken;
| bool isCrvToken;
| 19,319 |
2 | // New Fallback Function and Receive functionfor 0.6.0 only/ | contract A {
event SomeEvent(address _addr, uint _amount);
/**
* Will be called when (fallback) is used in Remix
*/
receive() external payable {
emit SomeEvent(msg.sender, msg.value);
}
/**
* Will be called when msg.data is not empty or when receive() doesn't exist
*
* If not payable => assert-style error on msg.value not empty
* */
fallback () external {
}
} | contract A {
event SomeEvent(address _addr, uint _amount);
/**
* Will be called when (fallback) is used in Remix
*/
receive() external payable {
emit SomeEvent(msg.sender, msg.value);
}
/**
* Will be called when msg.data is not empty or when receive() doesn't exist
*
* If not payable => assert-style error on msg.value not empty
* */
fallback () external {
}
} | 2,617 |
159 | // Prices | uint256 public WLPrice = 0.00 ether;
uint256 public PublicPrice = 0.00 ether;
| uint256 public WLPrice = 0.00 ether;
uint256 public PublicPrice = 0.00 ether;
| 30,500 |
8 | // The maximum end time of streaming. | uint32 maxEnd;
| uint32 maxEnd;
| 21,581 |
130 | // get the amount of Ether/BNB fees stored in this contract owned by galaxy-treasury | uint256 amount = galaxyTreasuryNetwork;
require(amount > 0, "Treasury of network should be greater than 0");
| uint256 amount = galaxyTreasuryNetwork;
require(amount > 0, "Treasury of network should be greater than 0");
| 52,696 |
1 | // function greet() constant returns (string greeting) {bug: greeting comes up empty | function greet() constant returns (string theGreeting) {
return greeting;
}
| function greet() constant returns (string theGreeting) {
return greeting;
}
| 15,795 |
78 | // please note, that in order to incentivize staking, we won't be updating the time of the last claim, thus preserving the rewards bonus multiplier |
emit RewardsStaked(provider, newPoolToken, amount, newId);
return newId;
|
emit RewardsStaked(provider, newPoolToken, amount, newId);
return newId;
| 23,599 |
94 | // Read the bytes4 from array memory | assembly {
result := mload(add(b, add(index,32)))
| assembly {
result := mload(add(b, add(index,32)))
| 18,797 |
17 | // nextAmountToSwap = 0. nextToNext > 0 | SwapData storage data = swapData[tokenA_][tokenB_][mask];
accumRatio[tokenA_][tokenB_][mask][swapDataMem.performedSwaps + 1] = accumRatio[tokenA_][tokenB_][mask][swapDataMem.performedSwaps];
data.nextAmountToSwap = swapDataMem.nextAmountToSwap + swapDataMem.nextToNextAmountToSwap;
data.nextToNextAmountToSwap = 0;
data.performedSwaps += 1;
| SwapData storage data = swapData[tokenA_][tokenB_][mask];
accumRatio[tokenA_][tokenB_][mask][swapDataMem.performedSwaps + 1] = accumRatio[tokenA_][tokenB_][mask][swapDataMem.performedSwaps];
data.nextAmountToSwap = swapDataMem.nextAmountToSwap + swapDataMem.nextToNextAmountToSwap;
data.nextToNextAmountToSwap = 0;
data.performedSwaps += 1;
| 11,718 |
7 | // NFT Address => Bool | mapping(address => bool) public exists;
bytes4 private constant INTERFACE_ID_ERC721 = 0x80ac58cd;
| mapping(address => bool) public exists;
bytes4 private constant INTERFACE_ID_ERC721 = 0x80ac58cd;
| 28,629 |
18 | // tokenFallback is called from an ERC223 compatible contract/_from the address from which the token was sent/_value the amount of tokens sent/_data the data sent with the transaction | function tokenFallback(address _from, uint _value, bytes _data) public pure {
_from;
_value;
_data;
// TKN memory tkn;
// tkn.sender = _from;
// tkn.value = _value;
// tkn.data = _data;
// uint32 u = uint32(_data[3]) + (uint32(_data[2]) << 8) + (uint32(_data[1]) << 16) + (uint32(_data[0]) << 24);
// tkn.sig = bytes4(u);
/* tkn variable is analogue of msg variable of Ether transaction
* tkn.sender is person who initiated this token transaction (analogue of msg.sender)
* tkn.value the number of tokens that were sent (analogue of msg.value)
* tkn.data is data of token transaction (analogue of msg.data)
* tkn.sig is 4 bytes signature of function
* if data of token transaction is a function execution
*/
}
| function tokenFallback(address _from, uint _value, bytes _data) public pure {
_from;
_value;
_data;
// TKN memory tkn;
// tkn.sender = _from;
// tkn.value = _value;
// tkn.data = _data;
// uint32 u = uint32(_data[3]) + (uint32(_data[2]) << 8) + (uint32(_data[1]) << 16) + (uint32(_data[0]) << 24);
// tkn.sig = bytes4(u);
/* tkn variable is analogue of msg variable of Ether transaction
* tkn.sender is person who initiated this token transaction (analogue of msg.sender)
* tkn.value the number of tokens that were sent (analogue of msg.value)
* tkn.data is data of token transaction (analogue of msg.data)
* tkn.sig is 4 bytes signature of function
* if data of token transaction is a function execution
*/
}
| 6,034 |
0 | // @custom:member amount The total amount the fee was taken from, as a fixed point number with the same number of decimals as the terminal in which this struct was created./ @custom:member fee The percent of the fee, out of MAX_FEE./ @custom:member feeDiscount The discount of the fee./ @custom:member beneficiary The address that will receive the tokens that are minted as a result of the fee payment. | struct JBFee {
uint256 amount;
uint32 fee;
uint32 feeDiscount;
address beneficiary;
}
| struct JBFee {
uint256 amount;
uint32 fee;
uint32 feeDiscount;
address beneficiary;
}
| 14,432 |
108 | // EIP-2 still allows signature malleability for ecrecover(). Remove this possibility and make the signature unique. Appendix F in the Ethereum Yellow paper (https:ethereum.github.io/yellowpaper/paper.pdf), defines the valid range for s in (281): 0 < s < secp256k1n 1 2 + 1, and for v in (282): v 1 {27, 28}. Most signatures from current libraries generate a unique signature with an s-value in the lower half order. If your library generates malleable signatures, such as s-values in the upper range, calculate a new s-value with 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEBAAEDCE6AF48A03BBFD25E8CD0364141 - s1 and flip v from 27 to 28 or vice versa. If your library | if (uint256(s) > 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF5D576E7357A4501DDFE92F46681B20A0) {
return address(0);
}
| if (uint256(s) > 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF5D576E7357A4501DDFE92F46681B20A0) {
return address(0);
}
| 23,703 |
3 | // do not accept value sent directly to contract / | receive() external payable {
revert("No value accepted");
}
| receive() external payable {
revert("No value accepted");
}
| 34,561 |
27 | // LGT ARBITRAGE | function lgtArb(uint _amount) public payable shadowPossession chiDiscount {
require(_amount > 0, "Amount may not be 0");
lgt.mintToSellTo(_amount, msg.value, block.timestamp, msg.sender);
}
| function lgtArb(uint _amount) public payable shadowPossession chiDiscount {
require(_amount > 0, "Amount may not be 0");
lgt.mintToSellTo(_amount, msg.value, block.timestamp, msg.sender);
}
| 9,536 |
36 | // Internal: Set the max time allowed for indexers stake on allocations. _maxAllocationEpochs Allocation duration limit in epochs / | function _setMaxAllocationEpochs(uint32 _maxAllocationEpochs) private {
maxAllocationEpochs = _maxAllocationEpochs;
emit ParameterUpdated("maxAllocationEpochs");
}
| function _setMaxAllocationEpochs(uint32 _maxAllocationEpochs) private {
maxAllocationEpochs = _maxAllocationEpochs;
emit ParameterUpdated("maxAllocationEpochs");
}
| 12,481 |
13 | // ----- VARIABLES |
address public owner; // Owner of this contract
address public admin; // The one who is allowed to do changes
mapping(address => uint256) balances; // Maintain balance in a mapping
mapping(address => mapping (address => uint256)) allowances; // Allowances index-1 = Owner account index-2 = spender account
|
address public owner; // Owner of this contract
address public admin; // The one who is allowed to do changes
mapping(address => uint256) balances; // Maintain balance in a mapping
mapping(address => mapping (address => uint256)) allowances; // Allowances index-1 = Owner account index-2 = spender account
| 36,603 |
12 | // burns specified amount token(s) of specific id from specified account account address of token holder idid of token, aka. tier amountunits of token to be burnt from beneficiary / | function burn(
address account,
uint256 id,
uint256 amount
| function burn(
address account,
uint256 id,
uint256 amount
| 8,386 |
3 | // The number of leaves in the tree | uint256 numLeaves;
| uint256 numLeaves;
| 23,465 |
21 | // Creates a new game token/_name game token name; set by player | function createRandomGameToken(string memory _name) public {
require(!getPlayer(msg.sender).inBattle, "Player is in a battle"); // Require that player is not already in a battle
require(isPlayer(msg.sender), "Please Register Player First"); // Require that the player is registered
_createGameToken(_name); // Creates game token
}
| function createRandomGameToken(string memory _name) public {
require(!getPlayer(msg.sender).inBattle, "Player is in a battle"); // Require that player is not already in a battle
require(isPlayer(msg.sender), "Please Register Player First"); // Require that the player is registered
_createGameToken(_name); // Creates game token
}
| 21,193 |
111 | // no ref purchase |
jackpot_ = SafeMath.add(jackpot_, _referralBonus);
referralBalance_[Master] = SafeMath.add(referralBalance_[Master], _referralBonus);
|
jackpot_ = SafeMath.add(jackpot_, _referralBonus);
referralBalance_[Master] = SafeMath.add(referralBalance_[Master], _referralBonus);
| 65,268 |
14 | // Checks where the caller is a Club's onwer | modifier onlyClubOwnerRole() {
require(hasRole(CLUB_OWNER_ROLE, _msgSender()), "!CLUB_OWNER");
_; // move on
}
| modifier onlyClubOwnerRole() {
require(hasRole(CLUB_OWNER_ROLE, _msgSender()), "!CLUB_OWNER");
_; // move on
}
| 5,342 |
89 | // On the first call to nonReentrant, _notEntered will be true | require(_status != _ENTERED, "ReentrancyGuard: reentrant call");
| require(_status != _ENTERED, "ReentrancyGuard: reentrant call");
| 595 |
78 | // ERC20 compliant transfer function _to Address to send funds to _amount Amount of token to sendreturn true for successful/ | function transfer(TokenStorage storage self, address _to, uint _amount) public returns (bool) {
require(isWhitelisted(self,_to));
uint balance_owner = self.user_total_balances[msg.sender];
if (
_to == msg.sender ||
_to == address(0) ||
_amount == 0 ||
balance_owner < _amount
) return false;
transferHelper(self,msg.sender, _to, _amount);
self.user_total_balances[msg.sender] = self.user_total_balances[msg.sender].sub(_amount);
self.user_total_balances[_to] = self.user_total_balances[_to].add(_amount);
emit Transfer(msg.sender, _to, _amount);
return true;
}
| function transfer(TokenStorage storage self, address _to, uint _amount) public returns (bool) {
require(isWhitelisted(self,_to));
uint balance_owner = self.user_total_balances[msg.sender];
if (
_to == msg.sender ||
_to == address(0) ||
_amount == 0 ||
balance_owner < _amount
) return false;
transferHelper(self,msg.sender, _to, _amount);
self.user_total_balances[msg.sender] = self.user_total_balances[msg.sender].sub(_amount);
self.user_total_balances[_to] = self.user_total_balances[_to].add(_amount);
emit Transfer(msg.sender, _to, _amount);
return true;
}
| 18,041 |
26 | // Check the merkle proof against the root hash array | for(uint256 i = 0; i < rootHash.length; i++)
{
if (node == rootHash[i])
{
return true;
}
| for(uint256 i = 0; i < rootHash.length; i++)
{
if (node == rootHash[i])
{
return true;
}
| 51,930 |
14 | // SubDao用のNFTのアドレス、オーナーのTokenIdを設定する/ | function updateNftAddressAndOwnerTokenId(address _nftAddress, uint256 _ownerTokenId) public onlyOwner {
erc721Address = _nftAddress;
memberInfoes[msg.sender].tokenId = _ownerTokenId;
emit UpdatedOwnerInfo(_nftAddress,_ownerTokenId);
}
| function updateNftAddressAndOwnerTokenId(address _nftAddress, uint256 _ownerTokenId) public onlyOwner {
erc721Address = _nftAddress;
memberInfoes[msg.sender].tokenId = _ownerTokenId;
emit UpdatedOwnerInfo(_nftAddress,_ownerTokenId);
}
| 2,960 |
14 | // Allows the current owner to transfer mint control of the contract to a newOwner. newOwner The address to transfer ownership to. / | function transferMintOwnership(address newOwner) public onlyOwner {
require(newOwner != address(0));
emit MintOwnershipTransferred(mintOwner, newOwner);
mintOwner = newOwner;
}
| function transferMintOwnership(address newOwner) public onlyOwner {
require(newOwner != address(0));
emit MintOwnershipTransferred(mintOwner, newOwner);
mintOwner = newOwner;
}
| 81,949 |
53 | // inflate for precision | uint userPercent = stonks / (totalSpentBig / player[addr].playerRound[r].preMarketSpent);
return (userPercent * 100) / INVEST_RATIO;
| uint userPercent = stonks / (totalSpentBig / player[addr].playerRound[r].preMarketSpent);
return (userPercent * 100) / INVEST_RATIO;
| 12,319 |
1 | // get rewards of given account available for withdrawal account owner of rewardsreturn uint quantity of rewards available / | function rewardsOf (address account) public view returns (uint) {
return (
balanceOf(account) * _cumulativeRewardPerToken
+ _rewardsReserved[account]
- _rewardsExcluded[account]
) / REWARD_SCALAR;
}
| function rewardsOf (address account) public view returns (uint) {
return (
balanceOf(account) * _cumulativeRewardPerToken
+ _rewardsReserved[account]
- _rewardsExcluded[account]
) / REWARD_SCALAR;
}
| 32,965 |
19 | // Proposes new Algebra fee value for protocol/the new value will also be used for previously accumulated tokens that have not yet been withdrawn/newAlgebraFee new Algebra fee value | function proposeAlgebraFeeChange(uint16 newAlgebraFee) external;
| function proposeAlgebraFeeChange(uint16 newAlgebraFee) external;
| 25,282 |
72 | // remove limits after token is stable - 30-60 minutes | function removeLimits() external onlyOwner returns (bool){
limitsInEffect = false;
gasLimitActive = false;
return true;
}
| function removeLimits() external onlyOwner returns (bool){
limitsInEffect = false;
gasLimitActive = false;
return true;
}
| 36,482 |
78 | // Solidity already throws when dividing by 0. | return a / b;
| return a / b;
| 1,147 |
138 | // Deterimine if reward address timestamp record has matured | if(g_timestamps[msg.sender][_rewardAddress]._reward > block.timestamp) {
| if(g_timestamps[msg.sender][_rewardAddress]._reward > block.timestamp) {
| 32,125 |
27 | // Gas fees that have accumulated in this contract to reimburse the arbitrator for paying fees for releasing escrow. These are stored locally to avoid having to pay additional gas costs for transfer during each release. | uint256 public accumulatedGasFees;
| uint256 public accumulatedGasFees;
| 11,174 |
4 | // store init code for transient contracts that deploy metamorphic contracts. | bytes private _transientContractInitializationCode;
| bytes private _transientContractInitializationCode;
| 37,622 |
162 | // Mint | uint256 public maxBatch;
uint256 public publicMintable;
| uint256 public maxBatch;
uint256 public publicMintable;
| 778 |
82 | // assert(a == bc + a % b);There is no case in which this doesn&39;t hold | return c;
| return c;
| 34,144 |
26 | // Reserved storage space to allow for layout changes in the future. | uint256[50] private ______gap;
| uint256[50] private ______gap;
| 44,706 |
335 | // user went from zero or positive to borrowing | state.accounts[account.owner][account.number].numberOfMarketsWithBorrow += 1;
| state.accounts[account.owner][account.number].numberOfMarketsWithBorrow += 1;
| 7,582 |
14 | // ERC-721 Non-Fungible Token Standard, optional metadata extension / | contract ERC721Metadata is ERC721Basic {
function name() external view returns (string _name);
function symbol() external view returns (string _symbol);
function tokenURI(uint256 _tokenId) public view returns (string);
}
| contract ERC721Metadata is ERC721Basic {
function name() external view returns (string _name);
function symbol() external view returns (string _symbol);
function tokenURI(uint256 _tokenId) public view returns (string);
}
| 1,496 |
169 | // 終了:_presale_endが0の場合は無期限 | if( _presale_end != 0 && _presale_end <= block.timestamp ){
return( false );
}
| if( _presale_end != 0 && _presale_end <= block.timestamp ){
return( false );
}
| 28,808 |
158 | // ERC1363 Implementation of an ERC1363 interface / | contract ERC1363 is ERC20, IERC1363, ERC165 {
using Address for address;
/*
* Note: the ERC-165 identifier for this interface is 0x4bbee2df.
* 0x4bbee2df ===
* bytes4(keccak256('transferAndCall(address,uint256)')) ^
* bytes4(keccak256('transferAndCall(address,uint256,bytes)')) ^
* bytes4(keccak256('transferFromAndCall(address,address,uint256)')) ^
* bytes4(keccak256('transferFromAndCall(address,address,uint256,bytes)'))
*/
bytes4 internal constant _INTERFACE_ID_ERC1363_TRANSFER = 0x4bbee2df;
/*
* Note: the ERC-165 identifier for this interface is 0xfb9ec8ce.
* 0xfb9ec8ce ===
* bytes4(keccak256('approveAndCall(address,uint256)')) ^
* bytes4(keccak256('approveAndCall(address,uint256,bytes)'))
*/
bytes4 internal constant _INTERFACE_ID_ERC1363_APPROVE = 0xfb9ec8ce;
// Equals to `bytes4(keccak256("onTransferReceived(address,address,uint256,bytes)"))`
// which can be also obtained as `IERC1363Receiver(0).onTransferReceived.selector`
bytes4 private constant _ERC1363_RECEIVED = 0x88a7ca5c;
// Equals to `bytes4(keccak256("onApprovalReceived(address,uint256,bytes)"))`
// which can be also obtained as `IERC1363Spender(0).onApprovalReceived.selector`
bytes4 private constant _ERC1363_APPROVED = 0x7b04a2d0;
/**
* @param name Name of the token
* @param symbol A symbol to be used as ticker
*/
constructor (string memory name, string memory symbol) ERC20(name, symbol) {
// register the supported interfaces to conform to ERC1363 via ERC165
_registerInterface(_INTERFACE_ID_ERC1363_TRANSFER);
_registerInterface(_INTERFACE_ID_ERC1363_APPROVE);
}
/**
* @dev Transfer tokens to a specified address and then execute a callback on recipient.
* @param to The address to transfer to.
* @param value The amount to be transferred.
* @return A boolean that indicates if the operation was successful.
*/
function transferAndCall(address to, uint256 value) public override returns (bool) {
return transferAndCall(to, value, "");
}
/**
* @dev Transfer tokens to a specified address and then execute a callback on recipient.
* @param to The address to transfer to
* @param value The amount to be transferred
* @param data Additional data with no specified format
* @return A boolean that indicates if the operation was successful.
*/
function transferAndCall(address to, uint256 value, bytes memory data) public override returns (bool) {
transfer(to, value);
require(_checkAndCallTransfer(_msgSender(), to, value, data), "ERC1363: _checkAndCallTransfer reverts");
return true;
}
/**
* @dev Transfer tokens from one address to another and then execute a callback on recipient.
* @param from The address which you want to send tokens from
* @param to The address which you want to transfer to
* @param value The amount of tokens to be transferred
* @return A boolean that indicates if the operation was successful.
*/
function transferFromAndCall(address from, address to, uint256 value) public override returns (bool) {
return transferFromAndCall(from, to, value, "");
}
/**
* @dev Transfer tokens from one address to another and then execute a callback on recipient.
* @param from The address which you want to send tokens from
* @param to The address which you want to transfer to
* @param value The amount of tokens to be transferred
* @param data Additional data with no specified format
* @return A boolean that indicates if the operation was successful.
*/
function transferFromAndCall(address from, address to, uint256 value, bytes memory data) public override returns (bool) {
transferFrom(from, to, value);
require(_checkAndCallTransfer(from, to, value, data), "ERC1363: _checkAndCallTransfer reverts");
return true;
}
/**
* @dev Approve spender to transfer tokens and then execute a callback on recipient.
* @param spender The address allowed to transfer to
* @param value The amount allowed to be transferred
* @return A boolean that indicates if the operation was successful.
*/
function approveAndCall(address spender, uint256 value) public override returns (bool) {
return approveAndCall(spender, value, "");
}
/**
* @dev Approve spender to transfer tokens and then execute a callback on recipient.
* @param spender The address allowed to transfer to.
* @param value The amount allowed to be transferred.
* @param data Additional data with no specified format.
* @return A boolean that indicates if the operation was successful.
*/
function approveAndCall(address spender, uint256 value, bytes memory data) public override returns (bool) {
approve(spender, value);
require(_checkAndCallApprove(spender, value, data), "ERC1363: _checkAndCallApprove reverts");
return true;
}
/**
* @dev Internal function to invoke `onTransferReceived` on a target address
* The call is not executed if the target address is not a contract
* @param from address Representing the previous owner of the given token value
* @param to address Target address that will receive the tokens
* @param value uint256 The amount mount of tokens to be transferred
* @param data bytes Optional data to send along with the call
* @return whether the call correctly returned the expected magic value
*/
function _checkAndCallTransfer(address from, address to, uint256 value, bytes memory data) internal returns (bool) {
if (!to.isContract()) {
return false;
}
bytes4 retval = IERC1363Receiver(to).onTransferReceived(
_msgSender(), from, value, data
);
return (retval == _ERC1363_RECEIVED);
}
/**
* @dev Internal function to invoke `onApprovalReceived` on a target address
* The call is not executed if the target address is not a contract
* @param spender address The address which will spend the funds
* @param value uint256 The amount of tokens to be spent
* @param data bytes Optional data to send along with the call
* @return whether the call correctly returned the expected magic value
*/
function _checkAndCallApprove(address spender, uint256 value, bytes memory data) internal returns (bool) {
if (!spender.isContract()) {
return false;
}
bytes4 retval = IERC1363Spender(spender).onApprovalReceived(
_msgSender(), value, data
);
return (retval == _ERC1363_APPROVED);
}
}
| contract ERC1363 is ERC20, IERC1363, ERC165 {
using Address for address;
/*
* Note: the ERC-165 identifier for this interface is 0x4bbee2df.
* 0x4bbee2df ===
* bytes4(keccak256('transferAndCall(address,uint256)')) ^
* bytes4(keccak256('transferAndCall(address,uint256,bytes)')) ^
* bytes4(keccak256('transferFromAndCall(address,address,uint256)')) ^
* bytes4(keccak256('transferFromAndCall(address,address,uint256,bytes)'))
*/
bytes4 internal constant _INTERFACE_ID_ERC1363_TRANSFER = 0x4bbee2df;
/*
* Note: the ERC-165 identifier for this interface is 0xfb9ec8ce.
* 0xfb9ec8ce ===
* bytes4(keccak256('approveAndCall(address,uint256)')) ^
* bytes4(keccak256('approveAndCall(address,uint256,bytes)'))
*/
bytes4 internal constant _INTERFACE_ID_ERC1363_APPROVE = 0xfb9ec8ce;
// Equals to `bytes4(keccak256("onTransferReceived(address,address,uint256,bytes)"))`
// which can be also obtained as `IERC1363Receiver(0).onTransferReceived.selector`
bytes4 private constant _ERC1363_RECEIVED = 0x88a7ca5c;
// Equals to `bytes4(keccak256("onApprovalReceived(address,uint256,bytes)"))`
// which can be also obtained as `IERC1363Spender(0).onApprovalReceived.selector`
bytes4 private constant _ERC1363_APPROVED = 0x7b04a2d0;
/**
* @param name Name of the token
* @param symbol A symbol to be used as ticker
*/
constructor (string memory name, string memory symbol) ERC20(name, symbol) {
// register the supported interfaces to conform to ERC1363 via ERC165
_registerInterface(_INTERFACE_ID_ERC1363_TRANSFER);
_registerInterface(_INTERFACE_ID_ERC1363_APPROVE);
}
/**
* @dev Transfer tokens to a specified address and then execute a callback on recipient.
* @param to The address to transfer to.
* @param value The amount to be transferred.
* @return A boolean that indicates if the operation was successful.
*/
function transferAndCall(address to, uint256 value) public override returns (bool) {
return transferAndCall(to, value, "");
}
/**
* @dev Transfer tokens to a specified address and then execute a callback on recipient.
* @param to The address to transfer to
* @param value The amount to be transferred
* @param data Additional data with no specified format
* @return A boolean that indicates if the operation was successful.
*/
function transferAndCall(address to, uint256 value, bytes memory data) public override returns (bool) {
transfer(to, value);
require(_checkAndCallTransfer(_msgSender(), to, value, data), "ERC1363: _checkAndCallTransfer reverts");
return true;
}
/**
* @dev Transfer tokens from one address to another and then execute a callback on recipient.
* @param from The address which you want to send tokens from
* @param to The address which you want to transfer to
* @param value The amount of tokens to be transferred
* @return A boolean that indicates if the operation was successful.
*/
function transferFromAndCall(address from, address to, uint256 value) public override returns (bool) {
return transferFromAndCall(from, to, value, "");
}
/**
* @dev Transfer tokens from one address to another and then execute a callback on recipient.
* @param from The address which you want to send tokens from
* @param to The address which you want to transfer to
* @param value The amount of tokens to be transferred
* @param data Additional data with no specified format
* @return A boolean that indicates if the operation was successful.
*/
function transferFromAndCall(address from, address to, uint256 value, bytes memory data) public override returns (bool) {
transferFrom(from, to, value);
require(_checkAndCallTransfer(from, to, value, data), "ERC1363: _checkAndCallTransfer reverts");
return true;
}
/**
* @dev Approve spender to transfer tokens and then execute a callback on recipient.
* @param spender The address allowed to transfer to
* @param value The amount allowed to be transferred
* @return A boolean that indicates if the operation was successful.
*/
function approveAndCall(address spender, uint256 value) public override returns (bool) {
return approveAndCall(spender, value, "");
}
/**
* @dev Approve spender to transfer tokens and then execute a callback on recipient.
* @param spender The address allowed to transfer to.
* @param value The amount allowed to be transferred.
* @param data Additional data with no specified format.
* @return A boolean that indicates if the operation was successful.
*/
function approveAndCall(address spender, uint256 value, bytes memory data) public override returns (bool) {
approve(spender, value);
require(_checkAndCallApprove(spender, value, data), "ERC1363: _checkAndCallApprove reverts");
return true;
}
/**
* @dev Internal function to invoke `onTransferReceived` on a target address
* The call is not executed if the target address is not a contract
* @param from address Representing the previous owner of the given token value
* @param to address Target address that will receive the tokens
* @param value uint256 The amount mount of tokens to be transferred
* @param data bytes Optional data to send along with the call
* @return whether the call correctly returned the expected magic value
*/
function _checkAndCallTransfer(address from, address to, uint256 value, bytes memory data) internal returns (bool) {
if (!to.isContract()) {
return false;
}
bytes4 retval = IERC1363Receiver(to).onTransferReceived(
_msgSender(), from, value, data
);
return (retval == _ERC1363_RECEIVED);
}
/**
* @dev Internal function to invoke `onApprovalReceived` on a target address
* The call is not executed if the target address is not a contract
* @param spender address The address which will spend the funds
* @param value uint256 The amount of tokens to be spent
* @param data bytes Optional data to send along with the call
* @return whether the call correctly returned the expected magic value
*/
function _checkAndCallApprove(address spender, uint256 value, bytes memory data) internal returns (bool) {
if (!spender.isContract()) {
return false;
}
bytes4 retval = IERC1363Spender(spender).onApprovalReceived(
_msgSender(), value, data
);
return (retval == _ERC1363_APPROVED);
}
}
| 3,909 |
39 | // check amountOutMin in the last | require(amounts[amounts.length - 1] >= amountOutMin, "CRouter: insufficient output amount ");
| require(amounts[amounts.length - 1] >= amountOutMin, "CRouter: insufficient output amount ");
| 14,822 |
166 | // Pausable decreaseAllowance function spender The address which will spend the funds. subtractedValue The amount of tokens to decrease the allowance by.return If the action was successful in bool. / | function decreaseAllowance(address spender, uint subtractedValue) public whenNotPaused returns (bool success) {
return super.decreaseAllowance(spender, subtractedValue);
}
| function decreaseAllowance(address spender, uint subtractedValue) public whenNotPaused returns (bool success) {
return super.decreaseAllowance(spender, subtractedValue);
}
| 38,112 |
4 | // min fee amount is not required in a shutdown because raw fees are transferred directly to treasury | minFeeAmount = 0;
| minFeeAmount = 0;
| 17,988 |
144 | // load storage array into memory for efficiency | uint24[5] memory costs = execCost_;
string memory ds;
for (; oracleStep < costs.length; oracleStep++) {
ds = oracleStep == 3 ? "nested" : "computation";
totalCost += getOracleGasCost(ds, costs[oracleStep]);
}
| uint24[5] memory costs = execCost_;
string memory ds;
for (; oracleStep < costs.length; oracleStep++) {
ds = oracleStep == 3 ? "nested" : "computation";
totalCost += getOracleGasCost(ds, costs[oracleStep]);
}
| 48,067 |
24 | // Withdrawal of funds failed. / | error WithdrawFailed();
| error WithdrawFailed();
| 805 |
83 | // exclude from fees, wallet limit and transaction limit | excludeFromAllLimits(owner(), true);
excludeFromAllLimits(address(this), true);
excludeFromWalletLimit(uniswapV2Pair, true);
dev = _dev;
| excludeFromAllLimits(owner(), true);
excludeFromAllLimits(address(this), true);
excludeFromWalletLimit(uniswapV2Pair, true);
dev = _dev;
| 5,000 |
35 | // set tokenOwnerAddress as owner of all tokens | _mint(tokenOwnerAddress, totalSupply);
| _mint(tokenOwnerAddress, totalSupply);
| 2,071 |
45 | // Reclaim ownership of Ownable contracts contractAddr The address of the Ownable to be reclaimed. / | function reclaimContract(address contractAddr) external onlyOwner {
Ownable contractInst = Ownable(contractAddr);
contractInst.transferOwnership(owner);
}
| function reclaimContract(address contractAddr) external onlyOwner {
Ownable contractInst = Ownable(contractAddr);
contractInst.transferOwnership(owner);
}
| 52,343 |
1,010 | // This is a non-standard ERC-20 | success := 1 // set success to true
| success := 1 // set success to true
| 11,319 |
61 | // example: Contract(_to)....If there is an operator, where _from is not equal to msg.sender, we use msg.sender. | bytes4 returnData = IERC721Receiver(_to).onERC721Received(msg.sender, _from, _tokenId, _data);
return returnData == MAGIC_ERC721_RECEIVED;
| bytes4 returnData = IERC721Receiver(_to).onERC721Received(msg.sender, _from, _tokenId, _data);
return returnData == MAGIC_ERC721_RECEIVED;
| 17,271 |
54 | // A competitive Sport such as shuai jiao or baseball in which competitors attempt to gain the highest scoreto win matches / | struct Sport {
bytes32 id;
string name;
string notes;
}
| struct Sport {
bytes32 id;
string name;
string notes;
}
| 38,764 |
89 | // Returns the number of decimals used to get its user representation.For example, if `decimals` equals `2`, a balance of `505` tokens shouldbe displayed to a user as `5,05` (`505 / 102`). NOTE: This information is only used for _display_ purposes: it inno way affects any of the arithmetic of the contract, including | * {IERC20-balanceOf} and {IERC20-transfer}.
*/
function decimals() public view virtual returns (uint32) {
return _decimals;
}
| * {IERC20-balanceOf} and {IERC20-transfer}.
*/
function decimals() public view virtual returns (uint32) {
return _decimals;
}
| 36,340 |
1 | // Emitted when the pause is lifted. / | event UnPaused();
event EnableVaultToBorrow(
uint256 indexed vaultId,
address indexed vaultAddress
);
event DisableVaultToBorrow(
| event UnPaused();
event EnableVaultToBorrow(
uint256 indexed vaultId,
address indexed vaultAddress
);
event DisableVaultToBorrow(
| 17,188 |
104 | // If the most recent entry in the membership history is for the current epoch number, we need to look at the previous entry. | if (history.entries[head].epochNumber == epochNumber) {
if (head > history.tail) {
head = head.sub(1);
}
| if (history.entries[head].epochNumber == epochNumber) {
if (head > history.tail) {
head = head.sub(1);
}
| 19,563 |
2 | // origination fee is set as default as 25 basis points of the loan amount (0.0025%) | originationFeePercentage = 0.0025 * 1e18;
| originationFeePercentage = 0.0025 * 1e18;
| 5,843 |
90 | // Core of JITU (Just-In-Time-Underwriter) KeeperDAO This contract allows whitelisted keepers to add buffer to compound positions that are slightly above water, so that in the case they go underwater the keepers canpreempt a liquidation. / | contract JITUCore is Ownable {
/** State */
IERC721 public immutable nft;
LiquidityPoolLike public liquidityPool;
mapping (address=>bool) keeperWhitelist;
mapping (address=>bool) underwriterWhitelist;
/** Events */
event KeeperWhitelistUpdated(address indexed _keeper, bool _updatedValue);
event UnderwriterWhitelistUpdated(address indexed _underwriter, bool _updatedValue);
event LiquidityPoolUpdated(address indexed _oldValue, address indexed _newValue);
/**
* @notice initialize the contract state
*/
constructor (LiquidityPoolLike _liquidityPool, IERC721 _nft) {
liquidityPool = _liquidityPool;
nft = _nft;
}
/** Modifiers */
/**
* @notice reverts if the caller is not a whitelisted keeper
*/
modifier onlyWhitelistedKeeper() {
require(
keeperWhitelist[msg.sender],
"JITU: caller is not a whitelisted keeper"
);
_;
}
/**
* @notice reverts if the caller is not a whitelisted underwriter
*/
modifier onlyWhitelistedUnderwriter() {
require(
underwriterWhitelist[msg.sender],
"JITU: caller is not a whitelisted underwriter"
);
_;
}
/**
* @notice reverts if the caller is not the vault owner
*/
modifier onlyVaultOwner(address _vault) {
require(
nft.ownerOf(uint256(uint160(_vault))) == msg.sender,
"JITU: not the owner"
);
_;
}
/**
* @notice reverts if the wallet is invalid
*/
modifier valid(address _vault) {
require(
nft.ownerOf(uint256(uint160(_vault))) != address(0),
"JITU: invalid vault address"
);
_;
}
/** External Functions */
/**
* @notice this contract can accept ethereum transfers
*/
receive() external payable {}
/**
* @notice whitelist the given keeper, add to the keeper
* whitelist.
* @param _keeper the address of the keeper
*/
function updateKeeperWhitelist(address _keeper, bool _val) external onlyOwner {
keeperWhitelist[_keeper] = _val;
emit KeeperWhitelistUpdated(_keeper, _val);
}
/**
* @notice update the liquidity provider.
* @param _liquidityPool the address of the liquidityPool
*/
function updateLiquidityPool(LiquidityPoolLike _liquidityPool) external onlyOwner {
require(_liquidityPool != LiquidityPoolLike(address(0)), "JITU: liquidity pool cannot be 0x0");
emit LiquidityPoolUpdated(address(liquidityPool), address(_liquidityPool));
liquidityPool = _liquidityPool;
}
/**
* @notice whitelist the given underwriter, add to the underwriter
* whitelist.
* @param _underwriter the address of the underwriter
*/
function updateUnderwriterWhitelist(address _underwriter, bool _val) external onlyOwner {
underwriterWhitelist[_underwriter] = _val;
emit UnderwriterWhitelistUpdated(_underwriter, _val);
}
}
| contract JITUCore is Ownable {
/** State */
IERC721 public immutable nft;
LiquidityPoolLike public liquidityPool;
mapping (address=>bool) keeperWhitelist;
mapping (address=>bool) underwriterWhitelist;
/** Events */
event KeeperWhitelistUpdated(address indexed _keeper, bool _updatedValue);
event UnderwriterWhitelistUpdated(address indexed _underwriter, bool _updatedValue);
event LiquidityPoolUpdated(address indexed _oldValue, address indexed _newValue);
/**
* @notice initialize the contract state
*/
constructor (LiquidityPoolLike _liquidityPool, IERC721 _nft) {
liquidityPool = _liquidityPool;
nft = _nft;
}
/** Modifiers */
/**
* @notice reverts if the caller is not a whitelisted keeper
*/
modifier onlyWhitelistedKeeper() {
require(
keeperWhitelist[msg.sender],
"JITU: caller is not a whitelisted keeper"
);
_;
}
/**
* @notice reverts if the caller is not a whitelisted underwriter
*/
modifier onlyWhitelistedUnderwriter() {
require(
underwriterWhitelist[msg.sender],
"JITU: caller is not a whitelisted underwriter"
);
_;
}
/**
* @notice reverts if the caller is not the vault owner
*/
modifier onlyVaultOwner(address _vault) {
require(
nft.ownerOf(uint256(uint160(_vault))) == msg.sender,
"JITU: not the owner"
);
_;
}
/**
* @notice reverts if the wallet is invalid
*/
modifier valid(address _vault) {
require(
nft.ownerOf(uint256(uint160(_vault))) != address(0),
"JITU: invalid vault address"
);
_;
}
/** External Functions */
/**
* @notice this contract can accept ethereum transfers
*/
receive() external payable {}
/**
* @notice whitelist the given keeper, add to the keeper
* whitelist.
* @param _keeper the address of the keeper
*/
function updateKeeperWhitelist(address _keeper, bool _val) external onlyOwner {
keeperWhitelist[_keeper] = _val;
emit KeeperWhitelistUpdated(_keeper, _val);
}
/**
* @notice update the liquidity provider.
* @param _liquidityPool the address of the liquidityPool
*/
function updateLiquidityPool(LiquidityPoolLike _liquidityPool) external onlyOwner {
require(_liquidityPool != LiquidityPoolLike(address(0)), "JITU: liquidity pool cannot be 0x0");
emit LiquidityPoolUpdated(address(liquidityPool), address(_liquidityPool));
liquidityPool = _liquidityPool;
}
/**
* @notice whitelist the given underwriter, add to the underwriter
* whitelist.
* @param _underwriter the address of the underwriter
*/
function updateUnderwriterWhitelist(address _underwriter, bool _val) external onlyOwner {
underwriterWhitelist[_underwriter] = _val;
emit UnderwriterWhitelistUpdated(_underwriter, _val);
}
}
| 39,784 |
1 | // Multiplies two unsigned integers, reverts on overflow. / | function mul(uint256 a, uint256 b) internal pure returns (uint256) {
// Gas optimization: this is cheaper than requiring 'a' not being zero, but the
// benefit is lost if 'b' is also tested.
// See: https://github.com/OpenZeppelin/openzeppelin-solidity/pull/522
if (a == 0) {
return 0;
}
uint256 c = a * b;
require(c / a == b);
return c;
}
| function mul(uint256 a, uint256 b) internal pure returns (uint256) {
// Gas optimization: this is cheaper than requiring 'a' not being zero, but the
// benefit is lost if 'b' is also tested.
// See: https://github.com/OpenZeppelin/openzeppelin-solidity/pull/522
if (a == 0) {
return 0;
}
uint256 c = a * b;
require(c / a == b);
return c;
}
| 901 |
63 | // Batch Swap | struct Swap {
address pool;
uint256 tokenInParam; // tokenInAmount / maxAmountIn
uint256 tokenOutParam; // minAmountOut / tokenAmountOut
uint256 maxPrice;
}
| struct Swap {
address pool;
uint256 tokenInParam; // tokenInAmount / maxAmountIn
uint256 tokenOutParam; // minAmountOut / tokenAmountOut
uint256 maxPrice;
}
| 29,347 |
26 | // Check if the address owns the NFT with the given token ID | return IERC721(nftContractAddress).ownerOf(_tokenId) == msg.sender;
| return IERC721(nftContractAddress).ownerOf(_tokenId) == msg.sender;
| 32,851 |
245 | // Check that tokenId was not transferred by `_beforeTokenTransfer` hook | require(
ERC721.ownerOf(tokenId) == from,
"ERC721: transfer from incorrect owner"
);
| require(
ERC721.ownerOf(tokenId) == from,
"ERC721: transfer from incorrect owner"
);
| 3,122 |
4 | // Get the vault fee ratereturn int256 The vault fee rate / | function getVaultFeeRate() public view override returns (int256) {
return _vaultFeeRate;
}
| function getVaultFeeRate() public view override returns (int256) {
return _vaultFeeRate;
}
| 20,521 |
13 | // The sender liquidates the borrowers collateral. The collateral seized is transferred to the liquidator. borrower The borrower of this cToken to be liquidated cTokenCollateral The market in which to seize collateral from the borrower repayAmount The amount of the underlying borrowed asset to repayreturn uint 0=success, otherwise a failure (see ErrorReporter.sol for details) / | function liquidateBorrow(address borrower, uint repayAmount, CTokenInterface cTokenCollateral) external returns (uint) {
bytes memory data = delegateToImplementation(abi.encodeWithSignature("liquidateBorrow(address,uint256,address)", borrower, repayAmount, cTokenCollateral));
return abi.decode(data, (uint));
}
| function liquidateBorrow(address borrower, uint repayAmount, CTokenInterface cTokenCollateral) external returns (uint) {
bytes memory data = delegateToImplementation(abi.encodeWithSignature("liquidateBorrow(address,uint256,address)", borrower, repayAmount, cTokenCollateral));
return abi.decode(data, (uint));
}
| 61,169 |
1 | // Stack the return of `ownerOf`. | else if (opcode_ == OPCODE_OWNER_OF) {
state_.stack[baseIndex_] = uint256(
uint160(
IERC721(address(uint160(state_.stack[baseIndex_])))
.ownerOf(state_.stack[state_.stackIndex])
)
);
}
| else if (opcode_ == OPCODE_OWNER_OF) {
state_.stack[baseIndex_] = uint256(
uint160(
IERC721(address(uint160(state_.stack[baseIndex_])))
.ownerOf(state_.stack[state_.stackIndex])
)
);
}
| 21,054 |
25 | // ------------------------------------------------------------------------ Transferred approved amount from other's account ------------------------------------------------------------------------ | function transferFrom(address _from, address _to, uint _value) unfreezed(_to) unfreezed(_from) unfreezed(msg.sender) noEmergencyFreeze() public returns (bool success) {
require(_value <= allowed[_from][msg.sender]);
require (_value <= balances[_from]);
balances[_from] = balances[_from].sub(_value);
allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_value);
balances[_to] = balances[_to].add(_value);
emit Transfer(_from, _to, _value);
return true;
}
| function transferFrom(address _from, address _to, uint _value) unfreezed(_to) unfreezed(_from) unfreezed(msg.sender) noEmergencyFreeze() public returns (bool success) {
require(_value <= allowed[_from][msg.sender]);
require (_value <= balances[_from]);
balances[_from] = balances[_from].sub(_value);
allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_value);
balances[_to] = balances[_to].add(_value);
emit Transfer(_from, _to, _value);
return true;
}
| 32,542 |
59 | // Verifies whether the contract is not paused. | modifier whenNotPaused() {
require(!paused, "Sorry but the contract isn't paused.");
_;
}
| modifier whenNotPaused() {
require(!paused, "Sorry but the contract isn't paused.");
_;
}
| 49,592 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.