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
|
// totalPrincipalAmount = totalPrincipalAmount + actualMintAmount
|
productInfo.totalPrincipalAmount = add_(productInfo.totalPrincipalAmount, vars.actualMintAmount);
_createProductWith(productInfoId, vars.account, vars.actualMintAmount);
VDON(VDONAddress).mint(vars.account, mul_(productInfo.VDONExchangeRate, vars.actualMintAmount));
emit Mint(vars.account, vars.actualMintAmount);
return vars.actualMintAmount;
|
productInfo.totalPrincipalAmount = add_(productInfo.totalPrincipalAmount, vars.actualMintAmount);
_createProductWith(productInfoId, vars.account, vars.actualMintAmount);
VDON(VDONAddress).mint(vars.account, mul_(productInfo.VDONExchangeRate, vars.actualMintAmount));
emit Mint(vars.account, vars.actualMintAmount);
return vars.actualMintAmount;
| 52,645
|
3
|
// ==============================================================/ Withdraw NFT from the contract lien Reconstructed lien info lienId The ID for the lien being cleared /
|
function withdrawNft(Lien calldata lien, uint256 lienId) external;
|
function withdrawNft(Lien calldata lien, uint256 lienId) external;
| 13,724
|
145
|
// fallback function that allows contract to accept ETH
|
function () public payable {}
}
|
function () public payable {}
}
| 22,207
|
46
|
// treasury
|
bool _successTransferTreasury = platformToken.transfer(treasury, _fees - _partReward * 2);
require(_successTransferTreasury, "Treasury protocol fees transfer failure");
balance = _balance;
isWinnersSet = true;
|
bool _successTransferTreasury = platformToken.transfer(treasury, _fees - _partReward * 2);
require(_successTransferTreasury, "Treasury protocol fees transfer failure");
balance = _balance;
isWinnersSet = true;
| 6,404
|
59
|
// Get the value of the next burn from the bonding curve /
|
function getBurnValue(uint256 printNumber)
public
pure
returns (uint256 value)
|
function getBurnValue(uint256 printNumber)
public
pure
returns (uint256 value)
| 20,940
|
6
|
// returns (bool){
|
require (keccak256(abi.encodePacked(tokens[_hashPassport].image)) == keccak256(abi.encodePacked(_image)),
"myvaxxID: The patient does not have a passport");
return true;
|
require (keccak256(abi.encodePacked(tokens[_hashPassport].image)) == keccak256(abi.encodePacked(_image)),
"myvaxxID: The patient does not have a passport");
return true;
| 46,753
|
80
|
// can later be changed with {transferOwnership}./ Initializes the contract setting the deployer as the initial owner. /
|
constructor () internal {
address msgSender = _msgSender();
_owner = msgSender;
emit OwnershipTransferred(address(0), msgSender);
}
|
constructor () internal {
address msgSender = _msgSender();
_owner = msgSender;
emit OwnershipTransferred(address(0), msgSender);
}
| 13,263
|
33
|
// Returns the downcasted uint16 from uint256, reverting onoverflow (when the input is greater than largest uint16). Counterpart to Solidity's `uint16` operator. Requirements: - input must fit into 16 bits /
|
function toUint16(uint256 value) internal pure returns (uint16) {
if (value > type(uint16).max) {
revert SafeCastOverflowedUintDowncast(16, value);
}
return uint16(value);
}
|
function toUint16(uint256 value) internal pure returns (uint16) {
if (value > type(uint16).max) {
revert SafeCastOverflowedUintDowncast(16, value);
}
return uint16(value);
}
| 1,342
|
91
|
// ZKSeaNFT contract. Contains the nft info in layer1 and layer2
|
IZKSeaNFT internal zkSeaNFT;
UniswapV2Factory internal pairmanager;
|
IZKSeaNFT internal zkSeaNFT;
UniswapV2Factory internal pairmanager;
| 22,411
|
175
|
// reduce
|
cvx = (crv * reduction) / totalCliffs;
|
cvx = (crv * reduction) / totalCliffs;
| 12,930
|
181
|
// The LP token used
|
IBEP20 public lpToken;
|
IBEP20 public lpToken;
| 5,189
|
5
|
// get Total Supply
|
function totalSupply() view public returns (uint){
return currentIndex;
}
|
function totalSupply() view public returns (uint){
return currentIndex;
}
| 54,823
|
40
|
// ------------------------------------------------------------------------ Constructor to allow total tokens minted (upon creation) to be set Name and Symbol can be changed via SetInfo (decided to remove from constructor) ------------------------------------------------------------------------
|
constructor(uint256 _totalTokensToMint) payable public {
name = "Morality";
symbol = "MO";
totalSupply = _totalTokensToMint;
decimals = 18;
balances[msg.sender] = totalSupply;
creator = msg.sender;
emit LogFundsReceived(msg.sender, msg.value);
}
|
constructor(uint256 _totalTokensToMint) payable public {
name = "Morality";
symbol = "MO";
totalSupply = _totalTokensToMint;
decimals = 18;
balances[msg.sender] = totalSupply;
creator = msg.sender;
emit LogFundsReceived(msg.sender, msg.value);
}
| 10,433
|
7
|
// forward is called by the registry and forwards the call to the target gasAmount is the amount of gas to use in the call data is the 4 bytes function selector + arbitrary function datareturn success indicating whether the target call succeeded or failed /
|
function forward(uint256 gasAmount, bytes memory data) external returns (bool success, uint256 gasUsed) {
if (msg.sender != address(s_registry)) revert();
address target = i_target;
gasUsed = gasleft();
assembly {
let g := gas()
// Compute g -= PERFORM_GAS_CUSHION and check for underflow
if lt(g, PERFORM_GAS_CUSHION) {
revert(0, 0)
}
g := sub(g, PERFORM_GAS_CUSHION)
// if g - g//64 <= gasAmount, revert
// (we subtract g//64 because of EIP-150)
if iszero(gt(sub(g, div(g, 64)), gasAmount)) {
revert(0, 0)
}
// solidity calls check that a contract actually exists at the destination, so we do the same
if iszero(extcodesize(target)) {
revert(0, 0)
}
// call with exact gas
success := call(gasAmount, target, 0, add(data, 0x20), mload(data), 0, 0)
}
gasUsed = gasUsed - gasleft();
return (success, gasUsed);
}
|
function forward(uint256 gasAmount, bytes memory data) external returns (bool success, uint256 gasUsed) {
if (msg.sender != address(s_registry)) revert();
address target = i_target;
gasUsed = gasleft();
assembly {
let g := gas()
// Compute g -= PERFORM_GAS_CUSHION and check for underflow
if lt(g, PERFORM_GAS_CUSHION) {
revert(0, 0)
}
g := sub(g, PERFORM_GAS_CUSHION)
// if g - g//64 <= gasAmount, revert
// (we subtract g//64 because of EIP-150)
if iszero(gt(sub(g, div(g, 64)), gasAmount)) {
revert(0, 0)
}
// solidity calls check that a contract actually exists at the destination, so we do the same
if iszero(extcodesize(target)) {
revert(0, 0)
}
// call with exact gas
success := call(gasAmount, target, 0, add(data, 0x20), mload(data), 0, 0)
}
gasUsed = gasUsed - gasleft();
return (success, gasUsed);
}
| 18,912
|
177
|
// convert remainder to weth
|
remainder = swapTokens(position.token, WETH_ADDRESS, canReturn.sub(position.owed));
|
remainder = swapTokens(position.token, WETH_ADDRESS, canReturn.sub(position.owed));
| 22,689
|
122
|
// Get from the DAO settings
|
RocketDAOProtocolSettingsRewardsInterface daoSettingsRewards = RocketDAOProtocolSettingsRewardsInterface(getContractAddress("rocketDAOProtocolSettingsRewards"));
return daoSettingsRewards.getRewardsClaimIntervalTime();
|
RocketDAOProtocolSettingsRewardsInterface daoSettingsRewards = RocketDAOProtocolSettingsRewardsInterface(getContractAddress("rocketDAOProtocolSettingsRewards"));
return daoSettingsRewards.getRewardsClaimIntervalTime();
| 62,877
|
99
|
// _weiAmount Value in wei to be converted into tokensreturn Number of tokens that can be purchased with the specified _weiAmount /
|
function _getTokenAmount(uint256 _weiAmount) internal view returns (uint256) {
return _weiAmount.div(rate).mul(10 ** 9);
}
|
function _getTokenAmount(uint256 _weiAmount) internal view returns (uint256) {
return _weiAmount.div(rate).mul(10 ** 9);
}
| 16,660
|
350
|
// The loan data is stored, but not initiated yet.
|
Created,
|
Created,
| 24,432
|
16
|
// pool index => swapped amount of token0
|
mapping(uint => uint) public swappedAmount0P;
|
mapping(uint => uint) public swappedAmount0P;
| 24,348
|
414
|
// Emitted when the pause is lifted for `name`
|
event Unpaused(bytes32 name);
|
event Unpaused(bytes32 name);
| 44,359
|
30
|
// Add oracles to whitelist.//_whitelist user list.
|
function addOracles(address[] _whitelist) external onlyContractOwner returns (uint) {
for (uint _idx = 0; _idx < _whitelist.length; ++_idx) {
address _oracle = _whitelist[_idx];
if (!oracles[_oracle]) {
oracles[_oracle] = true;
_emitOracleAdded(_oracle);
}
}
return OK;
}
|
function addOracles(address[] _whitelist) external onlyContractOwner returns (uint) {
for (uint _idx = 0; _idx < _whitelist.length; ++_idx) {
address _oracle = _whitelist[_idx];
if (!oracles[_oracle]) {
oracles[_oracle] = true;
_emitOracleAdded(_oracle);
}
}
return OK;
}
| 15,622
|
8
|
// IERC20/This interface composes ERC-20 token calls with common extensions.
|
interface IERC20 {
function totalSupply() external view returns (uint256);
function balanceOf(address account) external view returns (uint256);
function allowance(address owner, address spender) external view returns (uint256);
function approve(address spender, uint256 amount) external returns (bool);
event Transfer(address indexed from, address indexed to, uint256 value);
event Approval(address indexed owner, address indexed spender, uint256 value);
/// @dev EIP-2612 {permit}.
function permit(
address owner,
address spender,
uint256 value,
uint256 deadline,
uint8 v,
bytes32 r,
bytes32 s
) external;
}
|
interface IERC20 {
function totalSupply() external view returns (uint256);
function balanceOf(address account) external view returns (uint256);
function allowance(address owner, address spender) external view returns (uint256);
function approve(address spender, uint256 amount) external returns (bool);
event Transfer(address indexed from, address indexed to, uint256 value);
event Approval(address indexed owner, address indexed spender, uint256 value);
/// @dev EIP-2612 {permit}.
function permit(
address owner,
address spender,
uint256 value,
uint256 deadline,
uint8 v,
bytes32 r,
bytes32 s
) external;
}
| 31,021
|
543
|
// Verify that the provided Merkle tree data is valid by using the Merkle proof.
|
ExchangeBalances.verifyAccountBalance(
uint(S.merkleRoot),
merkleProof
);
|
ExchangeBalances.verifyAccountBalance(
uint(S.merkleRoot),
merkleProof
);
| 31,689
|
4,858
|
// 2430
|
entry "diploidized" : ENG_ADJECTIVE
|
entry "diploidized" : ENG_ADJECTIVE
| 19,042
|
2
|
// singleton always needs to be first declared variable, to ensure that it is at the same location in the contracts to which calls are delegated. To reduce deployment costs this variable is internal and needs to be retrieved via `getStorageAt`
|
address internal singleton;
|
address internal singleton;
| 8,522
|
63
|
// spawningForIndexes: per address, per point, (index + 1) inthe spawningFor array
|
mapping(address => mapping(uint32 => uint256)) public spawningForIndexes;
|
mapping(address => mapping(uint32 => uint256)) public spawningForIndexes;
| 36,908
|
257
|
// Calculates TWAP from uniswapWhen liquidity is low, this can be manipulated by an end of block -> next block attack. We delay the activation of rebases 12 hours after liquidity incentives to reduce this attack vector. Additional there is very little supply to be able to manipulate this during that time period of highest vuln. /
|
function getTWAP() internal returns (uint256) {
(
uint256 priceCumulative,
uint32 blockTimestamp
) = UniswapV2OracleLibrary.currentCumulativePrices(
uniswap_pair,
isToken0
);
uint32 timeElapsed = blockTimestamp - blockTimestampLast; // overflow is desired
// no period check as is done in isRebaseWindow
// overflow is desired
uint256 priceAverage = uint256(
uint224((priceCumulative - priceCumulativeLast) / timeElapsed)
);
priceCumulativeLast = priceCumulative;
blockTimestampLast = blockTimestamp;
// BASE is on order of 1e18, which takes 2^60 bits
// multiplication will revert if priceAverage > 2^196
// (which it can because it overflows intentially)
if (priceAverage > uint192(-1)) {
// eat loss of precision
// effectively: (x / 2**112) * 1e18
return (priceAverage >> 112) * BASE;
}
// cant overflow
// effectively: (x * 1e18 / 2**112)
return (priceAverage * BASE) >> 112;
}
|
function getTWAP() internal returns (uint256) {
(
uint256 priceCumulative,
uint32 blockTimestamp
) = UniswapV2OracleLibrary.currentCumulativePrices(
uniswap_pair,
isToken0
);
uint32 timeElapsed = blockTimestamp - blockTimestampLast; // overflow is desired
// no period check as is done in isRebaseWindow
// overflow is desired
uint256 priceAverage = uint256(
uint224((priceCumulative - priceCumulativeLast) / timeElapsed)
);
priceCumulativeLast = priceCumulative;
blockTimestampLast = blockTimestamp;
// BASE is on order of 1e18, which takes 2^60 bits
// multiplication will revert if priceAverage > 2^196
// (which it can because it overflows intentially)
if (priceAverage > uint192(-1)) {
// eat loss of precision
// effectively: (x / 2**112) * 1e18
return (priceAverage >> 112) * BASE;
}
// cant overflow
// effectively: (x * 1e18 / 2**112)
return (priceAverage * BASE) >> 112;
}
| 14,341
|
161
|
// Returns a token ID owned by `owner` at a given `index` of its token list.
|
* Use along with {balanceOf} to enumerate all of ``owner``'s tokens.
*/
function tokenOfOwnerByIndex(address owner, uint256 index)
external
view
returns (uint256 tokenId);
/**
* @dev Returns a token ID at a given `index` of all the tokens stored by the contract.
* Use along with {totalSupply} to enumerate all tokens.
*/
function tokenByIndex(uint256 index) external view returns (uint256);
}
|
* Use along with {balanceOf} to enumerate all of ``owner``'s tokens.
*/
function tokenOfOwnerByIndex(address owner, uint256 index)
external
view
returns (uint256 tokenId);
/**
* @dev Returns a token ID at a given `index` of all the tokens stored by the contract.
* Use along with {totalSupply} to enumerate all tokens.
*/
function tokenByIndex(uint256 index) external view returns (uint256);
}
| 7,726
|
161
|
// Gets the reward amount in saved without withdrawal and returns the sum of all values. /
|
uint256 value =
|
uint256 value =
| 19,324
|
2
|
// Thrown when the requested amount for a transfer is larger than the permissioned amount/maxAmount The maximum amount a spender can request to transfer
|
error InvalidAmount(uint256 maxAmount);
|
error InvalidAmount(uint256 maxAmount);
| 19,777
|
91
|
// Add tokens&bonus amount to counters
|
function addToStat(uint tokens, uint bonus) internal {
uint total = tokens + bonus;
totalSupply = totalSupply.add(total);
//tokensBought = tokensBought.add(tokens.div(multiplier));
//tokensBonus = tokensBonus.add(bonus.div(multiplier));
tokensSoldTotal = tokensSoldTotal.add(tokens);
}
|
function addToStat(uint tokens, uint bonus) internal {
uint total = tokens + bonus;
totalSupply = totalSupply.add(total);
//tokensBought = tokensBought.add(tokens.div(multiplier));
//tokensBonus = tokensBonus.add(bonus.div(multiplier));
tokensSoldTotal = tokensSoldTotal.add(tokens);
}
| 28,397
|
11
|
// Logs bets + output to web3 for precise &39;payout on win&39; field in UI
|
event LogBet(address sender, uint value, uint rollUnder);
|
event LogBet(address sender, uint value, uint rollUnder);
| 35,387
|
4
|
// MTX is invalid after this time.
|
uint256 expirationTimeSeconds;
|
uint256 expirationTimeSeconds;
| 27,994
|
1
|
// price of 1 token in GWEI
|
}
|
}
| 32,789
|
14
|
// Move the rose to the Active Pool, and mint the OSDAmount to the borrower
|
_activePoolAddColl(contractsCache.activePool, vars.netColl);
_withdrawOSD(contractsCache.activePool, contractsCache.osdToken, msg.sender, _OSDAmount, vars.netDebt);
|
_activePoolAddColl(contractsCache.activePool, vars.netColl);
_withdrawOSD(contractsCache.activePool, contractsCache.osdToken, msg.sender, _OSDAmount, vars.netDebt);
| 31,257
|
11
|
// 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);
|
event Transfer(address indexed from, address indexed to, uint256 value);
| 2,405
|
1,416
|
// Liquidations are unique by ID per sponsor
|
mapping(address => LiquidationData[]) public liquidations;
|
mapping(address => LiquidationData[]) public liquidations;
| 12,582
|
45
|
// return true if crowdsale event has ended
|
function hasEnded() public constant returns (bool) {
return now > ICOEndTime;
}
|
function hasEnded() public constant returns (bool) {
return now > ICOEndTime;
}
| 47,362
|
13
|
// a modifier which allows only `panicOwner` to call a function.
|
modifier onlyPanicOwner() {
require(panicOwner == _msgSender(),
"TokenVault: caller is not the panic owner");
_;
}
|
modifier onlyPanicOwner() {
require(panicOwner == _msgSender(),
"TokenVault: caller is not the panic owner");
_;
}
| 40,416
|
4
|
// 32 bytes returned: check if non-zero
|
case 0x20 {
|
case 0x20 {
| 52,117
|
23
|
// Pausable Base contract which allows children to implement an emergency stop mechanism. /
|
contract Pausable is Ownable {
event Pause();
event Unpause();
bool public paused = false;
/**
* @dev Modifier to make a function callable only when the contract is not paused.
*/
modifier whenNotPaused() {
require(!paused);
_;
}
/**
* @dev Modifier to make a function callable only when the contract is paused.
*/
modifier whenPaused() {
require(paused);
_;
}
/**
* @dev called by the owner to pause, triggers stopped state
*/
function pause() onlyOwner whenNotPaused public {
paused = true;
emit Pause();
}
/**
* @dev called by the owner to unpause, returns to normal state
*/
function unpause() onlyOwner whenPaused public {
paused = false;
emit Unpause();
}
}
|
contract Pausable is Ownable {
event Pause();
event Unpause();
bool public paused = false;
/**
* @dev Modifier to make a function callable only when the contract is not paused.
*/
modifier whenNotPaused() {
require(!paused);
_;
}
/**
* @dev Modifier to make a function callable only when the contract is paused.
*/
modifier whenPaused() {
require(paused);
_;
}
/**
* @dev called by the owner to pause, triggers stopped state
*/
function pause() onlyOwner whenNotPaused public {
paused = true;
emit Pause();
}
/**
* @dev called by the owner to unpause, returns to normal state
*/
function unpause() onlyOwner whenPaused public {
paused = false;
emit Unpause();
}
}
| 2,763
|
36
|
// only owner address can set minBet /
|
{
minBet = newMinimumBet;
}
|
{
minBet = newMinimumBet;
}
| 12,289
|
130
|
// Mints `quantity` tokens and transfers them to `to`. Requirements: - `to` cannot be the zero address.- `quantity` cannot be larger than the max batch size.
|
* Emits a {Transfer} event.
*/
function _safeMint(
address to,
uint256 quantity,
bytes memory _data
) internal {
uint256 startTokenId = currentIndex;
require(to != address(0), 'ERC721A: mint to the zero address');
// We know if the first token in the batch doesn't exist, the other ones don't as well, because of serial ordering.
require(!_exists(startTokenId), 'ERC721A: token already minted');
require(quantity > 0, 'ERC721A: quantity must be greater 0');
_beforeTokenTransfers(address(0), to, startTokenId, quantity);
AddressData memory addressData = _addressData[to];
_addressData[to] = AddressData(
addressData.balance + uint128(quantity),
addressData.numberMinted + uint128(quantity)
);
_ownerships[startTokenId] = TokenOwnership(to, uint64(block.timestamp));
uint256 updatedIndex = startTokenId;
for (uint256 i = 0; i < quantity; i++) {
emit Transfer(address(0), to, updatedIndex);
require(
_checkOnERC721Received(address(0), to, updatedIndex, _data),
'ERC721A: transfer to non ERC721Receiver implementer'
);
updatedIndex++;
}
currentIndex = updatedIndex;
_afterTokenTransfers(address(0), to, startTokenId, quantity);
}
|
* Emits a {Transfer} event.
*/
function _safeMint(
address to,
uint256 quantity,
bytes memory _data
) internal {
uint256 startTokenId = currentIndex;
require(to != address(0), 'ERC721A: mint to the zero address');
// We know if the first token in the batch doesn't exist, the other ones don't as well, because of serial ordering.
require(!_exists(startTokenId), 'ERC721A: token already minted');
require(quantity > 0, 'ERC721A: quantity must be greater 0');
_beforeTokenTransfers(address(0), to, startTokenId, quantity);
AddressData memory addressData = _addressData[to];
_addressData[to] = AddressData(
addressData.balance + uint128(quantity),
addressData.numberMinted + uint128(quantity)
);
_ownerships[startTokenId] = TokenOwnership(to, uint64(block.timestamp));
uint256 updatedIndex = startTokenId;
for (uint256 i = 0; i < quantity; i++) {
emit Transfer(address(0), to, updatedIndex);
require(
_checkOnERC721Received(address(0), to, updatedIndex, _data),
'ERC721A: transfer to non ERC721Receiver implementer'
);
updatedIndex++;
}
currentIndex = updatedIndex;
_afterTokenTransfers(address(0), to, startTokenId, quantity);
}
| 17,233
|
115
|
// The address of initializer to initialize staking address.
|
address private _initializer;
|
address private _initializer;
| 29,550
|
14
|
// administrator list (see above on what they can do)mapping(bytes32 => bool) public administrators;
|
mapping(address => bool) public administrators;
|
mapping(address => bool) public administrators;
| 19,441
|
30
|
// this function MUST be called on any balance changes, otherwise can be used to infinitely claim fees Fees are segregated from core funds, so fees can never put liquidity at risk
|
function _updateFor(address recipient) internal {
uint _supplied = balanceOf[recipient]; // get LP balance of `recipient`
if (_supplied > 0) {
uint _supplyIndex0 = supplyIndex0[recipient]; // get last adjusted index0 for recipient
uint _supplyIndex1 = supplyIndex1[recipient];
uint _index0 = index0; // get global index0 for accumulated fees
uint _index1 = index1;
supplyIndex0[recipient] = _index0; // update user current position to global position
supplyIndex1[recipient] = _index1;
uint _delta0 = _index0 - _supplyIndex0; // see if there is any difference that need to be accrued
uint _delta1 = _index1 - _supplyIndex1;
if (_delta0 > 0) {
uint _share = _supplied * _delta0 / 1e18; // add accrued difference for each supplied token
claimable0[recipient] += _share;
}
if (_delta1 > 0) {
uint _share = _supplied * _delta1 / 1e18;
claimable1[recipient] += _share;
}
} else {
supplyIndex0[recipient] = index0; // new users are set to the default global state
supplyIndex1[recipient] = index1;
}
}
|
function _updateFor(address recipient) internal {
uint _supplied = balanceOf[recipient]; // get LP balance of `recipient`
if (_supplied > 0) {
uint _supplyIndex0 = supplyIndex0[recipient]; // get last adjusted index0 for recipient
uint _supplyIndex1 = supplyIndex1[recipient];
uint _index0 = index0; // get global index0 for accumulated fees
uint _index1 = index1;
supplyIndex0[recipient] = _index0; // update user current position to global position
supplyIndex1[recipient] = _index1;
uint _delta0 = _index0 - _supplyIndex0; // see if there is any difference that need to be accrued
uint _delta1 = _index1 - _supplyIndex1;
if (_delta0 > 0) {
uint _share = _supplied * _delta0 / 1e18; // add accrued difference for each supplied token
claimable0[recipient] += _share;
}
if (_delta1 > 0) {
uint _share = _supplied * _delta1 / 1e18;
claimable1[recipient] += _share;
}
} else {
supplyIndex0[recipient] = index0; // new users are set to the default global state
supplyIndex1[recipient] = index1;
}
}
| 34,190
|
3
|
// contracts
|
IERC20 public reignToken;
ISovWrapper public wrapper;
uint128 public lastInitializedEpoch;
uint256 public epochDuration; // init from staking contract
uint256 public epochStart; // init from staking contract
mapping(uint128 => uint256) private _sizeAtEpoch;
mapping(address => uint128) private _lastEpochIdHarvested;
|
IERC20 public reignToken;
ISovWrapper public wrapper;
uint128 public lastInitializedEpoch;
uint256 public epochDuration; // init from staking contract
uint256 public epochStart; // init from staking contract
mapping(uint128 => uint256) private _sizeAtEpoch;
mapping(address => uint128) private _lastEpochIdHarvested;
| 29
|
15
|
// Sanity check: has that much to spend
|
if (routerBalance < _maxIn) revert PortalFacet__repayAavePortal_insufficientFunds();
|
if (routerBalance < _maxIn) revert PortalFacet__repayAavePortal_insufficientFunds();
| 23,039
|
17
|
// Check in Foundation if msg.sender is the owner of this contract.Same remark. /
|
function isIdentityOwner() internal view returns (bool) {
return msg.sender == identityOwner();
}
|
function isIdentityOwner() internal view returns (bool) {
return msg.sender == identityOwner();
}
| 37,216
|
53
|
// Unlocks the contract for owner when _lockTime is exceeds
|
function unlock() public virtual {
require(_previousOwner == msg.sender, "You don't have permission to unlock");
require(now > _lockTime , "Contract is locked until 7 days");
emit OwnershipTransferred(_owner, _previousOwner);
_owner = _previousOwner;
}
|
function unlock() public virtual {
require(_previousOwner == msg.sender, "You don't have permission to unlock");
require(now > _lockTime , "Contract is locked until 7 days");
emit OwnershipTransferred(_owner, _previousOwner);
_owner = _previousOwner;
}
| 8,098
|
69
|
// Emitted when an admin supports a market
|
event MarketAdded(
address iToken,
uint256 collateralFactor,
uint256 borrowFactor,
uint256 supplyCapacity,
uint256 borrowCapacity,
uint256 distributionFactor
);
function _addMarket(
|
event MarketAdded(
address iToken,
uint256 collateralFactor,
uint256 borrowFactor,
uint256 supplyCapacity,
uint256 borrowCapacity,
uint256 distributionFactor
);
function _addMarket(
| 13,209
|
191
|
// 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");
| 2,458
|
15
|
// starting
|
uint256 public startTime = 0; // January 1, 1970 12:00:00
|
uint256 public startTime = 0; // January 1, 1970 12:00:00
| 71,146
|
1
|
// Public Functions//Relays a cross domain message to a contract.@inheritdoc iOVM_L2CrossDomainMessenger /
|
function relayMessage(
|
function relayMessage(
| 25,126
|
63
|
// We will transfer and then empty the rewards for the sender.
|
_rewards[msg.sender] = 0;
roomToken.transferFrom(roomTokenRewardsReservoirAddress, msg.sender, reward);
emit ClaimReward(msg.sender, reward);
|
_rewards[msg.sender] = 0;
roomToken.transferFrom(roomTokenRewardsReservoirAddress, msg.sender, reward);
emit ClaimReward(msg.sender, reward);
| 73,453
|
49
|
// Total number of owners
|
uint256 private _totalOwner;
|
uint256 private _totalOwner;
| 29,463
|
17
|
// WARNING: This contract assumes synth and reserve are equally valuable and share the same decimals (e.g. Dola and Dai) DO NOT USE WITH USDC OR USDT DO NOT USE WITH NON-STANDARD ERC20 TOKENS
|
contract Stabilizer {
using SafeMath for uint;
uint public constant MAX_FEE = 1000; // 10%
uint public constant FEE_DENOMINATOR = 10000;
uint public buyFee;
uint public sellFee;
uint public supplyCap;
uint public supply;
ERC20 public synth;
ERC20 public reserve;
address public operator;
IStrat public strat;
address public governance;
constructor(ERC20 synth_, ERC20 reserve_, uint buyFee_, uint sellFee_, uint supplyCap_) public {
require(buyFee_ <= MAX_FEE, "buyFee_ too high");
require(sellFee_ <= MAX_FEE, "sellFee_ too high");
synth = synth_;
reserve = reserve_;
governance = tx.origin;
buyFee = buyFee_;
sellFee = sellFee_;
operator = tx.origin;
supplyCap = supplyCap_;
}
modifier onlyOperator {
require(msg.sender == operator || msg.sender == governance, "ONLY OPERATOR OR GOV");
_;
}
modifier onlyGovernance {
require(msg.sender == governance, "ONLY GOV");
_;
}
function setOperator(address operator_) public {
require(msg.sender == governance || msg.sender == operator, "ONLY GOV OR OPERATOR");
require(operator_ != address(0), "NO ADDRESS ZERO");
operator = operator_;
}
function setBuyFee(uint amount) public onlyGovernance {
require(amount <= MAX_FEE, "amount too high");
buyFee = amount;
}
function setSellFee(uint amount) public onlyGovernance {
require(amount <= MAX_FEE, "amount too high");
sellFee = amount;
}
function setCap(uint amount) public onlyOperator {
supplyCap = amount;
}
function setGovernance(address gov_) public onlyGovernance {
require(gov_ != address(0), "NO ADDRESS ZERO");
governance = gov_;
}
function setStrat(IStrat newStrat) public onlyGovernance {
require(newStrat.underlying() == address(reserve), "Invalid strat");
if(address(strat) != address(0)) {
uint prevTotalValue = strat.calcTotalValue();
strat.divest(prevTotalValue);
}
reserve.transfer(address(newStrat), reserve.balanceOf(address(this)));
newStrat.invest();
strat = newStrat;
}
function removeStrat() public onlyGovernance {
uint prevTotalValue = strat.calcTotalValue();
strat.divest(prevTotalValue);
strat = IStrat(address(0));
}
function takeProfit() public {
uint totalReserves = getTotalReserves();
if(totalReserves > supply) {
uint profit = totalReserves - supply; // underflow prevented by if condition
if(address(strat) != address(0)) {
uint bal = reserve.balanceOf(address(this));
if(bal < profit) {
strat.divest(profit - bal); // underflow prevented by if condition
}
}
reserve.transfer(governance, profit);
}
}
function buy(uint amount) public {
uint fee = amount.mul(buyFee).div(FEE_DENOMINATOR);
uint depositAmount = amount.sub(fee);
require(supply.add(depositAmount) <= supplyCap, "supply exceeded cap");
reserve.transferFrom(msg.sender, governance, fee);
if(address(strat) != address(0)) {
reserve.transferFrom(msg.sender, address(strat), depositAmount);
strat.invest();
} else {
reserve.transferFrom(msg.sender, address(this), depositAmount);
}
emit Buy(msg.sender, depositAmount, amount);
synth.mint(msg.sender, depositAmount);
supply = supply.add(depositAmount);
}
function sell(uint amount) public {
synth.transferFrom(msg.sender, address(this), amount);
synth.burn(amount);
uint reserveBal = reserve.balanceOf(address(this));
if(address(strat) != address(0) && reserveBal < amount) {
strat.divest(amount - reserveBal); // underflow prevented by if condition
}
uint afterFee;
if(sellFee > 0) {
uint fee = amount.mul(sellFee).div(FEE_DENOMINATOR);
afterFee = amount.sub(fee);
reserve.transfer(governance, fee);
} else {
afterFee = amount;
}
reserve.transfer(msg.sender, afterFee);
supply = supply.sub(amount);
emit Sell(msg.sender, amount, afterFee);
}
function rescue(ERC20 token) public onlyGovernance {
require(token != reserve, "RESERVE CANNOT BE RESCUED");
token.transfer(governance, token.balanceOf(address(this)));
}
function getTotalReserves() internal returns (uint256 bal) { // new view function because strat.calcTotalValue() is not view function
bal = reserve.balanceOf(address(this));
if(address(strat) != address(0)) {
bal = bal.add(strat.calcTotalValue());
}
}
event Buy(address indexed user, uint purchased, uint spent);
event Sell(address indexed user, uint sold, uint received);
}
|
contract Stabilizer {
using SafeMath for uint;
uint public constant MAX_FEE = 1000; // 10%
uint public constant FEE_DENOMINATOR = 10000;
uint public buyFee;
uint public sellFee;
uint public supplyCap;
uint public supply;
ERC20 public synth;
ERC20 public reserve;
address public operator;
IStrat public strat;
address public governance;
constructor(ERC20 synth_, ERC20 reserve_, uint buyFee_, uint sellFee_, uint supplyCap_) public {
require(buyFee_ <= MAX_FEE, "buyFee_ too high");
require(sellFee_ <= MAX_FEE, "sellFee_ too high");
synth = synth_;
reserve = reserve_;
governance = tx.origin;
buyFee = buyFee_;
sellFee = sellFee_;
operator = tx.origin;
supplyCap = supplyCap_;
}
modifier onlyOperator {
require(msg.sender == operator || msg.sender == governance, "ONLY OPERATOR OR GOV");
_;
}
modifier onlyGovernance {
require(msg.sender == governance, "ONLY GOV");
_;
}
function setOperator(address operator_) public {
require(msg.sender == governance || msg.sender == operator, "ONLY GOV OR OPERATOR");
require(operator_ != address(0), "NO ADDRESS ZERO");
operator = operator_;
}
function setBuyFee(uint amount) public onlyGovernance {
require(amount <= MAX_FEE, "amount too high");
buyFee = amount;
}
function setSellFee(uint amount) public onlyGovernance {
require(amount <= MAX_FEE, "amount too high");
sellFee = amount;
}
function setCap(uint amount) public onlyOperator {
supplyCap = amount;
}
function setGovernance(address gov_) public onlyGovernance {
require(gov_ != address(0), "NO ADDRESS ZERO");
governance = gov_;
}
function setStrat(IStrat newStrat) public onlyGovernance {
require(newStrat.underlying() == address(reserve), "Invalid strat");
if(address(strat) != address(0)) {
uint prevTotalValue = strat.calcTotalValue();
strat.divest(prevTotalValue);
}
reserve.transfer(address(newStrat), reserve.balanceOf(address(this)));
newStrat.invest();
strat = newStrat;
}
function removeStrat() public onlyGovernance {
uint prevTotalValue = strat.calcTotalValue();
strat.divest(prevTotalValue);
strat = IStrat(address(0));
}
function takeProfit() public {
uint totalReserves = getTotalReserves();
if(totalReserves > supply) {
uint profit = totalReserves - supply; // underflow prevented by if condition
if(address(strat) != address(0)) {
uint bal = reserve.balanceOf(address(this));
if(bal < profit) {
strat.divest(profit - bal); // underflow prevented by if condition
}
}
reserve.transfer(governance, profit);
}
}
function buy(uint amount) public {
uint fee = amount.mul(buyFee).div(FEE_DENOMINATOR);
uint depositAmount = amount.sub(fee);
require(supply.add(depositAmount) <= supplyCap, "supply exceeded cap");
reserve.transferFrom(msg.sender, governance, fee);
if(address(strat) != address(0)) {
reserve.transferFrom(msg.sender, address(strat), depositAmount);
strat.invest();
} else {
reserve.transferFrom(msg.sender, address(this), depositAmount);
}
emit Buy(msg.sender, depositAmount, amount);
synth.mint(msg.sender, depositAmount);
supply = supply.add(depositAmount);
}
function sell(uint amount) public {
synth.transferFrom(msg.sender, address(this), amount);
synth.burn(amount);
uint reserveBal = reserve.balanceOf(address(this));
if(address(strat) != address(0) && reserveBal < amount) {
strat.divest(amount - reserveBal); // underflow prevented by if condition
}
uint afterFee;
if(sellFee > 0) {
uint fee = amount.mul(sellFee).div(FEE_DENOMINATOR);
afterFee = amount.sub(fee);
reserve.transfer(governance, fee);
} else {
afterFee = amount;
}
reserve.transfer(msg.sender, afterFee);
supply = supply.sub(amount);
emit Sell(msg.sender, amount, afterFee);
}
function rescue(ERC20 token) public onlyGovernance {
require(token != reserve, "RESERVE CANNOT BE RESCUED");
token.transfer(governance, token.balanceOf(address(this)));
}
function getTotalReserves() internal returns (uint256 bal) { // new view function because strat.calcTotalValue() is not view function
bal = reserve.balanceOf(address(this));
if(address(strat) != address(0)) {
bal = bal.add(strat.calcTotalValue());
}
}
event Buy(address indexed user, uint purchased, uint spent);
event Sell(address indexed user, uint sold, uint received);
}
| 11,109
|
1
|
// migration functions migrate the data from the previous contract in stages all addresses are included for transparency and easy verification however addresses with no robots (i.e. failed transaction and never bought properly) have been commented out.
|
// to view the full list of state assignments, go to etherscan.io/address/{address} and you can view the verified
mapping (address => uint[]) public userToRobots;
function _migrate(uint _index) external onlyOwner {
bytes4 selector = bytes4(sha3("setData()"));
address a = migrators[_index];
require(a.delegatecall(selector));
}
|
// to view the full list of state assignments, go to etherscan.io/address/{address} and you can view the verified
mapping (address => uint[]) public userToRobots;
function _migrate(uint _index) external onlyOwner {
bytes4 selector = bytes4(sha3("setData()"));
address a = migrators[_index];
require(a.delegatecall(selector));
}
| 40,517
|
3
|
// set nominee owner, granting permission to call acceptOwnership /
|
function _transferOwnership(address account) internal virtual override {
SafeOwnableStorage.layout().setNomineeOwner(account);
}
|
function _transferOwnership(address account) internal virtual override {
SafeOwnableStorage.layout().setNomineeOwner(account);
}
| 20,925
|
6
|
// CNSRegistryForwarder CNSRegistryForwarder simplifies operation with legacy meta-transactions.It works on top of existing SignatureController contract. /
|
contract CNSRegistryForwarder is BaseRoutingForwarder {
IForwarder private _target;
constructor(IForwarder target) {
_target = target;
_addRoute('transferFrom(address,address,uint256)', 'transferFromFor(address,address,uint256,bytes)');
_addRoute('safeTransferFrom(address,address,uint256)', 'safeTransferFromFor(address,address,uint256,bytes)');
_addRoute(
'safeTransferFrom(address,address,uint256,bytes)',
'safeTransferFromFor(address,address,uint256,bytes,bytes)'
);
_addRoute('burn(uint256)', 'burnFor(uint256,bytes)');
_addRoute('mintChild(address,uint256,string)', 'mintChildFor(address,uint256,string,bytes)');
_addRoute('safeMintChild(address,uint256,string)', 'safeMintChildFor(address,uint256,string,bytes)');
_addRoute(
'safeMintChild(address,uint256,string,bytes)',
'safeMintChildFor(address,uint256,string,bytes,bytes)'
);
_addRoute(
'transferFromChild(address,address,uint256,string)',
'transferFromChildFor(address,address,uint256,string,bytes)'
);
_addRoute(
'safeTransferFromChild(address,address,uint256,string)',
'safeTransferFromChildFor(address,address,uint256,string,bytes)'
);
_addRoute(
'safeTransferFromChild(address,address,uint256,string,bytes)',
'safeTransferFromChildFor(address,address,uint256,string,bytes,bytes)'
);
_addRoute('burnChild(uint256,string)', 'burnChildFor(uint256,string,bytes)');
_addRoute('resolveTo(address,uint256)', 'resolveToFor(address,uint256,bytes)');
}
function nonceOf(uint256 tokenId) public view override returns (uint256) {
return _target.nonceOf(tokenId);
}
function verify(ForwardRequest calldata req, bytes calldata signature) external view override returns (bool) {
return _verify(req, address(_target), signature);
}
function execute(ForwardRequest calldata req, bytes calldata signature) external override returns (bytes memory) {
uint256 gas = gasleft();
return _execute(req.from, address(_target), req.tokenId, gas, req.data, signature);
}
/**
* 0xef2c3088 = bytes4(keccak256('transferFromFor(address,address,uint256,bytes)'))
* 0x6debcb8d = bytes4(keccak256('safeTransferFromFor(address,address,uint256,bytes)'))
* 0x280d9b05 = bytes4(keccak256('safeTransferFromFor(address,address,uint256,bytes,bytes)'))
* 0x61603dd9 = bytes4(keccak256('burnFor(uint256,bytes)'))
* 0xb34f33c5 = bytes4(keccak256('mintChildFor(address,uint256,string,bytes)'))
* 0x30135293 = bytes4(keccak256('safeMintChildFor(address,uint256,string,bytes)'))
* 0x07eca395 = bytes4(keccak256('safeMintChildFor(address,uint256,string,bytes,bytes)'))
* 0x68b6154f = bytes4(keccak256('transferFromChildFor(address,address,uint256,string,bytes)'))
* 0xd0778d6c = bytes4(keccak256('safeTransferFromChildFor(address,address,uint256,string,bytes)'))
* 0xf5090c1e = bytes4(keccak256('safeTransferFromChildFor(address,address,uint256,string,bytes,bytes)'))
* 0x6fab95b3 = bytes4(keccak256('burnChildFor(uint256,string,bytes)'))
* 0x511f1112 = bytes4(keccak256('resolveToFor(address,uint256,bytes)'))
*/
function _buildRouteData(
bytes4 selector,
bytes memory data,
bytes memory signature
) internal pure override returns (bytes memory) {
if(selector == 0xef2c3088) {
(address p1, address p2, uint256 p3) = abi.decode(data, (address, address, uint256));
return abi.encodeWithSelector(selector, p1, p2, p3, signature);
} else if(selector == 0x6debcb8d) {
(address p1, address p2, uint256 p3) = abi.decode(data, (address, address, uint256));
return abi.encodeWithSelector(selector, p1, p2, p3, signature);
} else if(selector == 0x280d9b05) {
(address p1, address p2, uint256 p3, bytes memory p4) = abi.decode(data, (address, address, uint256, bytes));
return abi.encodeWithSelector(selector, p1, p2, p3, p4, signature);
} else if(selector == 0x61603dd9) {
(uint256 p1) = abi.decode(data, (uint256));
return abi.encodeWithSelector(selector, p1, signature);
} else if(selector == 0xb34f33c5) {
(address p1, uint256 p2, string memory p3) = abi.decode(data, (address, uint256, string));
return abi.encodeWithSelector(selector, p1, p2, p3, signature);
} else if(selector == 0x30135293) {
(address p1, uint256 p2, string memory p3) = abi.decode(data, (address, uint256, string));
return abi.encodeWithSelector(selector, p1, p2, p3, signature);
} else if(selector == 0x07eca395) {
(address p1, uint256 p2, string memory p3, bytes memory p4) = abi.decode(data, (address, uint256, string, bytes));
return abi.encodeWithSelector(selector, p1, p2, p3, p4, signature);
} else if(selector == 0x68b6154f) {
(address p1, address p2, uint256 p3, string memory p4) = abi.decode(data, (address, address, uint256, string));
return abi.encodeWithSelector(selector, p1, p2, p3, p4, signature);
} else if(selector == 0xd0778d6c) {
(address p1, address p2, uint256 p3, string memory p4) = abi.decode(data, (address, address, uint256, string));
return abi.encodeWithSelector(selector, p1, p2, p3, p4, signature);
} else if(selector == 0xf5090c1e) {
(address p1, address p2, uint256 p3, string memory p4, bytes memory p5) = abi.decode(data, (address, address, uint256, string, bytes));
return abi.encodeWithSelector(selector, p1, p2, p3, p4, p5, signature);
} else if(selector == 0x6fab95b3) {
(uint256 p1, string memory p2) = abi.decode(data, (uint256, string));
return abi.encodeWithSelector(selector, p1, p2, signature);
} else if(selector == 0x511f1112) {
(address p1, uint256 p2) = abi.decode(data, (address, uint256));
return abi.encodeWithSelector(selector, p1, p2, signature);
}
return '';
}
}
|
contract CNSRegistryForwarder is BaseRoutingForwarder {
IForwarder private _target;
constructor(IForwarder target) {
_target = target;
_addRoute('transferFrom(address,address,uint256)', 'transferFromFor(address,address,uint256,bytes)');
_addRoute('safeTransferFrom(address,address,uint256)', 'safeTransferFromFor(address,address,uint256,bytes)');
_addRoute(
'safeTransferFrom(address,address,uint256,bytes)',
'safeTransferFromFor(address,address,uint256,bytes,bytes)'
);
_addRoute('burn(uint256)', 'burnFor(uint256,bytes)');
_addRoute('mintChild(address,uint256,string)', 'mintChildFor(address,uint256,string,bytes)');
_addRoute('safeMintChild(address,uint256,string)', 'safeMintChildFor(address,uint256,string,bytes)');
_addRoute(
'safeMintChild(address,uint256,string,bytes)',
'safeMintChildFor(address,uint256,string,bytes,bytes)'
);
_addRoute(
'transferFromChild(address,address,uint256,string)',
'transferFromChildFor(address,address,uint256,string,bytes)'
);
_addRoute(
'safeTransferFromChild(address,address,uint256,string)',
'safeTransferFromChildFor(address,address,uint256,string,bytes)'
);
_addRoute(
'safeTransferFromChild(address,address,uint256,string,bytes)',
'safeTransferFromChildFor(address,address,uint256,string,bytes,bytes)'
);
_addRoute('burnChild(uint256,string)', 'burnChildFor(uint256,string,bytes)');
_addRoute('resolveTo(address,uint256)', 'resolveToFor(address,uint256,bytes)');
}
function nonceOf(uint256 tokenId) public view override returns (uint256) {
return _target.nonceOf(tokenId);
}
function verify(ForwardRequest calldata req, bytes calldata signature) external view override returns (bool) {
return _verify(req, address(_target), signature);
}
function execute(ForwardRequest calldata req, bytes calldata signature) external override returns (bytes memory) {
uint256 gas = gasleft();
return _execute(req.from, address(_target), req.tokenId, gas, req.data, signature);
}
/**
* 0xef2c3088 = bytes4(keccak256('transferFromFor(address,address,uint256,bytes)'))
* 0x6debcb8d = bytes4(keccak256('safeTransferFromFor(address,address,uint256,bytes)'))
* 0x280d9b05 = bytes4(keccak256('safeTransferFromFor(address,address,uint256,bytes,bytes)'))
* 0x61603dd9 = bytes4(keccak256('burnFor(uint256,bytes)'))
* 0xb34f33c5 = bytes4(keccak256('mintChildFor(address,uint256,string,bytes)'))
* 0x30135293 = bytes4(keccak256('safeMintChildFor(address,uint256,string,bytes)'))
* 0x07eca395 = bytes4(keccak256('safeMintChildFor(address,uint256,string,bytes,bytes)'))
* 0x68b6154f = bytes4(keccak256('transferFromChildFor(address,address,uint256,string,bytes)'))
* 0xd0778d6c = bytes4(keccak256('safeTransferFromChildFor(address,address,uint256,string,bytes)'))
* 0xf5090c1e = bytes4(keccak256('safeTransferFromChildFor(address,address,uint256,string,bytes,bytes)'))
* 0x6fab95b3 = bytes4(keccak256('burnChildFor(uint256,string,bytes)'))
* 0x511f1112 = bytes4(keccak256('resolveToFor(address,uint256,bytes)'))
*/
function _buildRouteData(
bytes4 selector,
bytes memory data,
bytes memory signature
) internal pure override returns (bytes memory) {
if(selector == 0xef2c3088) {
(address p1, address p2, uint256 p3) = abi.decode(data, (address, address, uint256));
return abi.encodeWithSelector(selector, p1, p2, p3, signature);
} else if(selector == 0x6debcb8d) {
(address p1, address p2, uint256 p3) = abi.decode(data, (address, address, uint256));
return abi.encodeWithSelector(selector, p1, p2, p3, signature);
} else if(selector == 0x280d9b05) {
(address p1, address p2, uint256 p3, bytes memory p4) = abi.decode(data, (address, address, uint256, bytes));
return abi.encodeWithSelector(selector, p1, p2, p3, p4, signature);
} else if(selector == 0x61603dd9) {
(uint256 p1) = abi.decode(data, (uint256));
return abi.encodeWithSelector(selector, p1, signature);
} else if(selector == 0xb34f33c5) {
(address p1, uint256 p2, string memory p3) = abi.decode(data, (address, uint256, string));
return abi.encodeWithSelector(selector, p1, p2, p3, signature);
} else if(selector == 0x30135293) {
(address p1, uint256 p2, string memory p3) = abi.decode(data, (address, uint256, string));
return abi.encodeWithSelector(selector, p1, p2, p3, signature);
} else if(selector == 0x07eca395) {
(address p1, uint256 p2, string memory p3, bytes memory p4) = abi.decode(data, (address, uint256, string, bytes));
return abi.encodeWithSelector(selector, p1, p2, p3, p4, signature);
} else if(selector == 0x68b6154f) {
(address p1, address p2, uint256 p3, string memory p4) = abi.decode(data, (address, address, uint256, string));
return abi.encodeWithSelector(selector, p1, p2, p3, p4, signature);
} else if(selector == 0xd0778d6c) {
(address p1, address p2, uint256 p3, string memory p4) = abi.decode(data, (address, address, uint256, string));
return abi.encodeWithSelector(selector, p1, p2, p3, p4, signature);
} else if(selector == 0xf5090c1e) {
(address p1, address p2, uint256 p3, string memory p4, bytes memory p5) = abi.decode(data, (address, address, uint256, string, bytes));
return abi.encodeWithSelector(selector, p1, p2, p3, p4, p5, signature);
} else if(selector == 0x6fab95b3) {
(uint256 p1, string memory p2) = abi.decode(data, (uint256, string));
return abi.encodeWithSelector(selector, p1, p2, signature);
} else if(selector == 0x511f1112) {
(address p1, uint256 p2) = abi.decode(data, (address, uint256));
return abi.encodeWithSelector(selector, p1, p2, signature);
}
return '';
}
}
| 83,548
|
1
|
// coin per token
|
uint256 private cpt;
uint256 private fund;
uint256 private lastBalance;
|
uint256 private cpt;
uint256 private fund;
uint256 private lastBalance;
| 48,687
|
20
|
// To withdraw the ether sent by marketplace
|
function withdraw() public {
require(msg.sender == owner, "Only the owner can withdraw");
payable(owner).transfer(address(this).balance);
}
|
function withdraw() public {
require(msg.sender == owner, "Only the owner can withdraw");
payable(owner).transfer(address(this).balance);
}
| 22,955
|
155
|
// If no reward is currently being distributed, the new rate is just `reward / duration`
|
rewardRate = reward / rewardsDuration;
|
rewardRate = reward / rewardsDuration;
| 50,918
|
58
|
// This is where your custom logic goesWhen this code executes, this contract will hold _amount of _tokenBorrowIt is important that, by the end of the execution of this function, this contract holds at least _amountToRepay of the _tokenPay tokenPaying back the flash-loan happens automatically for you -- DO NOT pay back the loan in this function_tokenBorrow The address of the token you flash-borrowed, address(0) indicates ETH_amount The amount of the _tokenBorrow token you borrowed_tokenPay The address of the token in which you'll repay the flash-borrow, address(0) indicates ETH_amountToRepay The amount of the _tokenPay token that will be auto-removed from this
|
function execute(address _tokenBorrow, uint _amount, address _tokenPay, uint _amountToRepay, bytes memory _userData) internal override {
// do whatever you want here
// we're just going to update some local variables because we're boring
// but you could do some arbitrage or liquidaztions or CDP collateral swaps, etc
lastTokenBorrow = _tokenBorrow; // just for testing
lastAmount = _amount; // just for testing
lastTokenPay = _tokenPay; // just for testing
lastamountToRepay = _amountToRepay; // just for testing
lastUserData = _userData; // just for testing
}
|
function execute(address _tokenBorrow, uint _amount, address _tokenPay, uint _amountToRepay, bytes memory _userData) internal override {
// do whatever you want here
// we're just going to update some local variables because we're boring
// but you could do some arbitrage or liquidaztions or CDP collateral swaps, etc
lastTokenBorrow = _tokenBorrow; // just for testing
lastAmount = _amount; // just for testing
lastTokenPay = _tokenPay; // just for testing
lastamountToRepay = _amountToRepay; // just for testing
lastUserData = _userData; // just for testing
}
| 14,677
|
66
|
// Private Functions//Calculates the integer ceiling of the log base 2 of an input. _in Unsigned input to calculate the log.return ceil(log_base_2(_in)) /
|
function _ceilLog2(uint256 _in) private pure returns (uint256) {
require(_in > 0, 'Lib_MerkleTree: Cannot compute ceil(log_2) of 0.');
if (_in == 1) {
return 0;
}
// Find the highest set bit (will be floor(log_2)).
// Borrowed with <3 from https://github.com/ethereum/solidity-examples
uint256 val = _in;
uint256 highest = 0;
for (uint256 i = 128; i >= 1; i >>= 1) {
if (val & (((uint256(1) << i) - 1) << i) != 0) {
highest += i;
val >>= i;
}
}
// Increment by one if this is not a perfect logarithm.
if ((uint256(1) << highest) != _in) {
highest += 1;
}
return highest;
}
|
function _ceilLog2(uint256 _in) private pure returns (uint256) {
require(_in > 0, 'Lib_MerkleTree: Cannot compute ceil(log_2) of 0.');
if (_in == 1) {
return 0;
}
// Find the highest set bit (will be floor(log_2)).
// Borrowed with <3 from https://github.com/ethereum/solidity-examples
uint256 val = _in;
uint256 highest = 0;
for (uint256 i = 128; i >= 1; i >>= 1) {
if (val & (((uint256(1) << i) - 1) << i) != 0) {
highest += i;
val >>= i;
}
}
// Increment by one if this is not a perfect logarithm.
if ((uint256(1) << highest) != _in) {
highest += 1;
}
return highest;
}
| 13,868
|
103
|
// Approves a wallet address to spend on behalf of the sender./ This function is overridden to leverage transfer state feature./ _spender The address which is approved to spend on behalf of the sender./ _value The amount of tokens approve to spend.
|
function approve(address _spender, uint256 _value)
public
revertIfLocked(msg.sender)
canTransfer(msg.sender)
|
function approve(address _spender, uint256 _value)
public
revertIfLocked(msg.sender)
canTransfer(msg.sender)
| 49,619
|
161
|
// the powers of the given validators in the same order as above
|
uint256[] powers;
|
uint256[] powers;
| 40,392
|
2
|
// balances[0x1111...] = 100;
|
mapping(address => mapping(address => uint)) allowed;
|
mapping(address => mapping(address => uint)) allowed;
| 20,843
|
172
|
// Sets {name} as "EURO Stable Token", {symbol} as "EURST" and {decimals} with 18. Setup roles {DEFAULT_ADMIN_ROLE}, {MINTER_ROLE}, {WIPER_ROLE} and {REGISTRY_MANAGER_ROLE}. Mints `initialSupply` tokens and assigns them to the caller. /
|
constructor(
uint256 _initialSupply,
IUserRegistry _userRegistry,
address _minter,
address _wiper,
address _registryManager
) public ERC20("EURO Stable Token", "EURST") {
_setupRole(DEFAULT_ADMIN_ROLE, msg.sender);
_setupRole(MINTER_ROLE, _minter);
_setupRole(WIPER_ROLE, _wiper);
|
constructor(
uint256 _initialSupply,
IUserRegistry _userRegistry,
address _minter,
address _wiper,
address _registryManager
) public ERC20("EURO Stable Token", "EURST") {
_setupRole(DEFAULT_ADMIN_ROLE, msg.sender);
_setupRole(MINTER_ROLE, _minter);
_setupRole(WIPER_ROLE, _wiper);
| 49,942
|
126
|
// will pause the system
|
function pause() public onlyPauser {
if (msg.sender == coreDev) {
shouldPauseDev = true;
} else {
shouldPauseTrustee = true;
}
if (shouldPauseDev && shouldPauseTrustee) {
systemPause = true;
// pause the system
boringDAO().pause();
// pause satellitepool
for(uint i=0; i < satellitePools.length; i++) {
if(isSatellitePool[satellitePools[i]] == true) {
IPause(satellitePools[i]).pause();
}
}
}
}
|
function pause() public onlyPauser {
if (msg.sender == coreDev) {
shouldPauseDev = true;
} else {
shouldPauseTrustee = true;
}
if (shouldPauseDev && shouldPauseTrustee) {
systemPause = true;
// pause the system
boringDAO().pause();
// pause satellitepool
for(uint i=0; i < satellitePools.length; i++) {
if(isSatellitePool[satellitePools[i]] == true) {
IPause(satellitePools[i]).pause();
}
}
}
}
| 80,397
|
35
|
// Implements IControllerGovernanceEngine
|
function state()
public
constant
returns (
Gov.State s
)
|
function state()
public
constant
returns (
Gov.State s
)
| 32,417
|
26
|
// Company should get paid here
|
remainder -= (news[_id].totalFundAmount * percentageCompany / 100) / news[_id].totalAuditors;
|
remainder -= (news[_id].totalFundAmount * percentageCompany / 100) / news[_id].totalAuditors;
| 26,297
|
0
|
// Finney to Wei
|
uint256 mintPriceInWei = uint256(edition.contractMintPriceInFinney) *
10e14;
|
uint256 mintPriceInWei = uint256(edition.contractMintPriceInFinney) *
10e14;
| 7,661
|
33
|
// Burns all tokens of the eligible burner /
|
function burnAllTokens() public isBurner(msg.sender) {
require(balances[msg.sender]>0);
uint256 value = balances[msg.sender];
totalSupply = totalSupply.sub(value);
balances[msg.sender] = 0;
emit Burn(msg.sender, value);
}
|
function burnAllTokens() public isBurner(msg.sender) {
require(balances[msg.sender]>0);
uint256 value = balances[msg.sender];
totalSupply = totalSupply.sub(value);
balances[msg.sender] = 0;
emit Burn(msg.sender, value);
}
| 20,145
|
47
|
// See {ERC20-totalSupply}. /
|
function totalSupply() external view virtual override returns (uint256) {
return _totalSupply;
}
|
function totalSupply() external view virtual override returns (uint256) {
return _totalSupply;
}
| 8,361
|
113
|
// ======== CONSTRUCTOR ======== / address _rewardPool,
|
address _curve3Pool,
address _rewardCollector,
address _ftmAddress,
uint256 _ftmAddressChangeTimelock,
uint256 _timelockInBlocks,
address _router
|
address _curve3Pool,
address _rewardCollector,
address _ftmAddress,
uint256 _ftmAddressChangeTimelock,
uint256 _timelockInBlocks,
address _router
| 8,967
|
353
|
// gasAccountTargetEthBalance_ The target ETH balance of the gas account
|
function updateGasAccountTargetEthBalance(uint256 gasAccountTargetEthBalance_)
external;
|
function updateGasAccountTargetEthBalance(uint256 gasAccountTargetEthBalance_)
external;
| 63,518
|
26
|
// Multiplies an `Unsigned` and an unscaled uint256, reverting on overflow. This will "floor" the product. a a FixedPoint. b a uint256.return the product of `a` and `b`. /
|
function mul(Unsigned memory a, uint256 b) internal pure returns (Unsigned memory) {
return Unsigned(a.rawValue.mul(b));
}
|
function mul(Unsigned memory a, uint256 b) internal pure returns (Unsigned memory) {
return Unsigned(a.rawValue.mul(b));
}
| 8,908
|
174
|
// Revert if the creator payouts are not set.
|
if (creatorPayoutsLength == 0) {
revert CreatorPayoutsNotSet();
}
|
if (creatorPayoutsLength == 0) {
revert CreatorPayoutsNotSet();
}
| 15,096
|
19
|
// extract and store the current bitcoin address
|
payerRefundAddress[_requestId][j] = Bytes.extractString(_payerRefundAddress, sizeCurrentBitcoinAddress, ++cursor);
|
payerRefundAddress[_requestId][j] = Bytes.extractString(_payerRefundAddress, sizeCurrentBitcoinAddress, ++cursor);
| 23,047
|
1
|
// SIZE / TBDreturn TBD /
|
function size(
Column[] memory _column
|
function size(
Column[] memory _column
| 27,025
|
4
|
// 2/3 of validators must sign to interact
|
address[] public _validators;
|
address[] public _validators;
| 31,594
|
53
|
// Getter of the delay between queuing and executionreturn The delay in seconds /
|
function getDelay() external view override returns (uint256) {
return _delay;
}
|
function getDelay() external view override returns (uint256) {
return _delay;
}
| 75,959
|
10
|
// Returns the zamzam token /
|
function token() external view returns (IERC20Upgradeable) {
return zamzamToken;
}
|
function token() external view returns (IERC20Upgradeable) {
return zamzamToken;
}
| 32,977
|
113
|
// import { IERC20 } from "@openzeppelin/contracts/token/ERC20/IERC20.sol";
|
function borrowBalanceCurrent(address _account) external returns (uint256);
function borrowBalanceStored(address _account) external view returns (uint256);
function balanceOfUnderlying(address _account) external returns (uint256);
|
function borrowBalanceCurrent(address _account) external returns (uint256);
function borrowBalanceStored(address _account) external view returns (uint256);
function balanceOfUnderlying(address _account) external returns (uint256);
| 15,849
|
13
|
// Returns the sender whitelist set by the `setSendersWhitelist` function.
|
function getSendersWhitelist() external view returns(address[] memory whitelist) {
whitelist = _sendersWhitelist;
}
|
function getSendersWhitelist() external view returns(address[] memory whitelist) {
whitelist = _sendersWhitelist;
}
| 33,432
|
5
|
// Event raised only the first time this NFT receives a vote
|
event FirstVote(address indexed tokenAddress, uint256 indexed tokenId);
|
event FirstVote(address indexed tokenAddress, uint256 indexed tokenId);
| 28,133
|
8
|
// TODO: Source
|
uint256 public constant UNUSED_FUNDS_MIN_DEPOSIT_SIZE = 1;
uint256 public constant MIN_LOAN_DURATION = 30 days;
uint256 public constant MIN_LOAN_PAYMENT_INTERVAL = 2 days;
uint256 public constant MAX_LOAN_DURATION = 1825 days;
uint256 public constant MAX_LOAN_PAYMENT_INTERVAL = 180 days;
uint32 public constant LENDER_NEEDS_KYC = 1 << 1;
uint32 public constant BORROWER_NEEDS_KYC = 1 << 2;
|
uint256 public constant UNUSED_FUNDS_MIN_DEPOSIT_SIZE = 1;
uint256 public constant MIN_LOAN_DURATION = 30 days;
uint256 public constant MIN_LOAN_PAYMENT_INTERVAL = 2 days;
uint256 public constant MAX_LOAN_DURATION = 1825 days;
uint256 public constant MAX_LOAN_PAYMENT_INTERVAL = 180 days;
uint32 public constant LENDER_NEEDS_KYC = 1 << 1;
uint32 public constant BORROWER_NEEDS_KYC = 1 << 2;
| 51,383
|
48
|
// Allows a farmer to mark an item 'Packed'also marks farmer address and block number into itemHistory. Only a farmer can call it. _upc: uint
|
* Emits an {Packed} event.
*/
function packItem(uint _upc) public
processed(_upc)
verifyCaller(msg.sender)
onlyFarmer()
{
// Update the appropriate fields
items[_upc].itemState = State.Packed;
// Emit the appropriate event
emit Packed(_upc);
//itemsHistory?
itemsHistory[_upc][2] = History(msg.sender, block.number);
}
|
* Emits an {Packed} event.
*/
function packItem(uint _upc) public
processed(_upc)
verifyCaller(msg.sender)
onlyFarmer()
{
// Update the appropriate fields
items[_upc].itemState = State.Packed;
// Emit the appropriate event
emit Packed(_upc);
//itemsHistory?
itemsHistory[_upc][2] = History(msg.sender, block.number);
}
| 21,569
|
21
|
// ------------------------------------------------------------------------ Transfer tokens from the from account to the to accountThe calling account must already have sufficient tokens approve(...)-d for spending from the from account and - From account must have sufficient balance to transfer - Spender must have sufficient allowance to transfer - 0 value transfers are allowed ------------------------------------------------------------------------
|
function transferFrom(address from, address to, uint tokens) public returns (bool success) {
balances[from] = safeSub(balances[from], tokens);
allowed[from][msg.sender] = safeSub(allowed[from][msg.sender], tokens);
balances[to] = safeAdd(balances[to], tokens);
Transfer(from, to, tokens);
return true;
}
|
function transferFrom(address from, address to, uint tokens) public returns (bool success) {
balances[from] = safeSub(balances[from], tokens);
allowed[from][msg.sender] = safeSub(allowed[from][msg.sender], tokens);
balances[to] = safeAdd(balances[to], tokens);
Transfer(from, to, tokens);
return true;
}
| 3,802
|
19
|
// change Muon's app id/appIdd distinguishes us from other Muon apps/appId_ Muon's app id
|
function setAppId(uint8 appId_) external onlyOwner {
emit SetAppId(appId, appId_);
appId = appId_;
}
|
function setAppId(uint8 appId_) external onlyOwner {
emit SetAppId(appId, appId_);
appId = appId_;
}
| 46,563
|
25
|
// ๋ง์ฝ ์๋์ ๋ณธ๋ถ๊ฐ ์์ ์๋ ๊ฒฝ์ฐ, ์ฒ์ ์ง๋ ๊ณณ ์ฃผ๋ณ์ ์ ๊ตฐ์ ๊ฑด๋ฌผ์ด ์กด์ฌํ๋ฉด ์๋ฉ๋๋ค.
|
if (ownerToHQIds[owner].length == 0) {
for (uint i = (col <= 3 ? 0 : col - 3); i <= (col >= 96 ? 99 : col + 3); i += 1) {
for (uint j = (row <= 3 ? 0 : row - 3); j <= (row >= 96 ? 99 : row + 3); j += 1) {
require(positionToBuildingId[i][j] == 0 || buildings[positionToBuildingId[i][j]].owner == owner);
}
|
if (ownerToHQIds[owner].length == 0) {
for (uint i = (col <= 3 ? 0 : col - 3); i <= (col >= 96 ? 99 : col + 3); i += 1) {
for (uint j = (row <= 3 ? 0 : row - 3); j <= (row >= 96 ? 99 : row + 3); j += 1) {
require(positionToBuildingId[i][j] == 0 || buildings[positionToBuildingId[i][j]].owner == owner);
}
| 24,739
|
0
|
// Mint 55 tokens for the team.
|
for( uint i = 0; i < 55; i++ ) {
_safeMint( _team[1], i );
}
|
for( uint i = 0; i < 55; i++ ) {
_safeMint( _team[1], i );
}
| 4,391
|
12
|
// Whether `a` is less than `b`. a a FixedPoint. b a uint256.return True if `a < b`, or False. /
|
function isLessThan(Unsigned memory a, uint256 b) internal pure returns (bool) {
return a.rawValue < fromUnscaledUint(b).rawValue;
}
|
function isLessThan(Unsigned memory a, uint256 b) internal pure returns (bool) {
return a.rawValue < fromUnscaledUint(b).rawValue;
}
| 8,894
|
2
|
// Write /
|
{
require(hasRole(FACTORY_ADMIN, msg.sender), "WINTokenSale: Restricted to FACTORY_ADMIN role");
require(whitelistContract.getWhitelistStatus(tx.origin), "WINTokenSale: user is not in whitelist");
require(ERC1155(winTokenContract).balanceOf(address(this), collectionId) >= _amount,"WINTokenSale: not enough tokens remaining to sale");
uint256 totalPrice = price * _amount;
TransferHelper.safeTransferFrom(erc20Token, address(tx.origin), address(this), totalPrice);
ERC1155(winTokenContract).safeTransferFrom(address(this), tx.origin, collectionId, _amount, "");
if (ERC20(erc20Token).balanceOf(address(this)) >= softCap){
softCapReached = true;
}
}
|
{
require(hasRole(FACTORY_ADMIN, msg.sender), "WINTokenSale: Restricted to FACTORY_ADMIN role");
require(whitelistContract.getWhitelistStatus(tx.origin), "WINTokenSale: user is not in whitelist");
require(ERC1155(winTokenContract).balanceOf(address(this), collectionId) >= _amount,"WINTokenSale: not enough tokens remaining to sale");
uint256 totalPrice = price * _amount;
TransferHelper.safeTransferFrom(erc20Token, address(tx.origin), address(this), totalPrice);
ERC1155(winTokenContract).safeTransferFrom(address(this), tx.origin, collectionId, _amount, "");
if (ERC20(erc20Token).balanceOf(address(this)) >= softCap){
softCapReached = true;
}
}
| 23,315
|
9
|
// Clones the allowlist using EIP-1167 template during new protocol registration /
|
function cloneAllowlist() internal returns (address allowlistAddress) {
bytes20 templateAddress = bytes20(allowlistTemplateAddress);
assembly {
let clone := mload(0x40)
mstore(
clone,
0x3d602d80600a3d3981f3363d3d373d3d3d363d73000000000000000000000000
)
mstore(add(clone, 0x14), templateAddress)
mstore(
add(clone, 0x28),
0x5af43d82803e903d91602b57fd5bf30000000000000000000000000000000000
)
allowlistAddress := create(0, clone, 0x37)
}
}
|
function cloneAllowlist() internal returns (address allowlistAddress) {
bytes20 templateAddress = bytes20(allowlistTemplateAddress);
assembly {
let clone := mload(0x40)
mstore(
clone,
0x3d602d80600a3d3981f3363d3d373d3d3d363d73000000000000000000000000
)
mstore(add(clone, 0x14), templateAddress)
mstore(
add(clone, 0x28),
0x5af43d82803e903d91602b57fd5bf30000000000000000000000000000000000
)
allowlistAddress := create(0, clone, 0x37)
}
}
| 2,342
|
55
|
// Should be emitted when the arbitration is requested. _questionID The ID of the question with the request for arbitration. _requester The address of the arbitration requester. _maxPrevious The maximum value of the current bond for the question. The arbitration request will get rejected if the current bond is greater than _maxPrevious. If set to 0, _maxPrevious is ignored. /
|
event ArbitrationRequested(bytes32 indexed _questionID, address indexed _requester, uint256 _maxPrevious);
|
event ArbitrationRequested(bytes32 indexed _questionID, address indexed _requester, uint256 _maxPrevious);
| 45,516
|
30
|
// event when someone bought tokens by ETH
|
event investmentReceived(
address sender,
uint weis,
uint total
);
uint256 public maxSupply = 298500000000000000000000000;
uint256 public allowedToBeSold = 104475000000000000000000000;
address public founder = address( 0x3abb86C7C1a533Eb0464E9BD870FD1b501C7A8A8 );
uint256 public rate = 2800;
|
event investmentReceived(
address sender,
uint weis,
uint total
);
uint256 public maxSupply = 298500000000000000000000000;
uint256 public allowedToBeSold = 104475000000000000000000000;
address public founder = address( 0x3abb86C7C1a533Eb0464E9BD870FD1b501C7A8A8 );
uint256 public rate = 2800;
| 79,660
|
18
|
// Total HND equivalents
|
rewards[2] = rewards[0] + rewards[1];
|
rewards[2] = rewards[0] + rewards[1];
| 44,711
|
13
|
// require(price == 0,"Price is zero!"); require(mToU == 0,"mToU is zero"); require(UToI == 0,"UToI is zero");
|
finalMatic = ((price*100000000/UToI)/mToU);
emit maticevent(finalMatic);
map[symbol] = finalMatic;
return finalMatic;
|
finalMatic = ((price*100000000/UToI)/mToU);
emit maticevent(finalMatic);
map[symbol] = finalMatic;
return finalMatic;
| 33,383
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.