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 |
|---|---|---|---|---|
52 | // num: [4, 6, x], odds: 5 | if ((nums[0] == 4 && nums[1] == 6) || (nums[1] == 4 && nums[2] == 6) || (nums[0] == 4 && nums[2] == 6)) {
win += wager * 6;
}
| if ((nums[0] == 4 && nums[1] == 6) || (nums[1] == 4 && nums[2] == 6) || (nums[0] == 4 && nums[2] == 6)) {
win += wager * 6;
}
| 12,716 |
47 | // sets aaRouter mintRatios address as inputValues | function setMintRatios(uint transactionId)
public
notExecuted(transactionId)
| function setMintRatios(uint transactionId)
public
notExecuted(transactionId)
| 74,104 |
278 | // This stores metadata about a FRight token | struct Metadata {
uint256 version; // version of the FRight
uint256 tokenId; // id of the FRight
uint256 startTime; // timestamp when the FRight was created
uint256 endTime; // timestamp until when the FRight is deemed useful
address baseAssetAddress; // address of original NFT locked in the DAO
uint256 baseAssetId; // id of original NFT locked in the DAO
bool isExclusive; // indicates if the FRight is exclusive, aka, has only one IRight
uint256 maxISupply; // maximum summply of IRights for this FRight
uint256 circulatingISupply; // circulating summply of IRights for this FRight
}
| struct Metadata {
uint256 version; // version of the FRight
uint256 tokenId; // id of the FRight
uint256 startTime; // timestamp when the FRight was created
uint256 endTime; // timestamp until when the FRight is deemed useful
address baseAssetAddress; // address of original NFT locked in the DAO
uint256 baseAssetId; // id of original NFT locked in the DAO
bool isExclusive; // indicates if the FRight is exclusive, aka, has only one IRight
uint256 maxISupply; // maximum summply of IRights for this FRight
uint256 circulatingISupply; // circulating summply of IRights for this FRight
}
| 12,446 |
31 | // Checks if user with specified address is the owner of the specified book or an admin userAddress Address of user bookHash Hash reference of book / | modifier isBookOwnerOrAdmin(address userAddress, bytes32 bookHash){
uint bookId = booksHashes[bookHash];
require(booksArr[bookId - 1].owner == userAddress || admin == userAddress, "user does not own this book and not admin");
_;
}
| modifier isBookOwnerOrAdmin(address userAddress, bytes32 bookHash){
uint bookId = booksHashes[bookHash];
require(booksArr[bookId - 1].owner == userAddress || admin == userAddress, "user does not own this book and not admin");
_;
}
| 24,191 |
116 | // Sets the incentivizer contract / | event NewIncentivizer(address oldIncentivizer, address newIncentivizer);
| event NewIncentivizer(address oldIncentivizer, address newIncentivizer);
| 79,469 |
6 | // emit ProjectCompleted(msg.sender, balance, goal); | payCreator();
| payCreator();
| 53,660 |
1 | // SDVD contract address | address public sdvd;
| address public sdvd;
| 73,849 |
5 | // Gets all facets and their selectors./ return An array of bytes arrays containing each facet/ and each facet's selectors./ The return value is tightly packed./ Here is the structure of the return value:/ returnValue = [/ abi.encodePacked(facet, sel1, sel2, sel3, ...),/ abi.encodePacked(facet, sel1, sel2, sel3, ...),/ .../ ]/ facet is the address of a facet./ sel1, sel2, sel3 etc. are four-byte function selectors. | function facets() external view returns (bytes[] memory);
| function facets() external view returns (bytes[] memory);
| 920 |
665 | // Returns portfolio value for the bitmapped currency | function _getBitmapPortfolioValue(
address account,
uint256 blockTime,
AccountContext memory accountContext,
FreeCollateralFactors memory factors
| function _getBitmapPortfolioValue(
address account,
uint256 blockTime,
AccountContext memory accountContext,
FreeCollateralFactors memory factors
| 3,791 |
332 | // Returns the fee charged on a strategy's generated profits. The strategist is paid in LP tokens, while the remainder of the profit stays in the vault. Default performance fee is set to 5% of harvested profits. / | function getPerformanceFee() public view returns (uint256) {
return currentUInts256[_PERFORMANCE_FEE_KEY];
}
| function getPerformanceFee() public view returns (uint256) {
return currentUInts256[_PERFORMANCE_FEE_KEY];
}
| 9,708 |
303 | // Remove a manager from an xAsset fund / | function removeManager(address manager, address fund) external;
| function removeManager(address manager, address fund) external;
| 56,236 |
0 | // IOKLGSpend Logic for spending OKLG on products in the product ecosystem. / | interface IOKLGSpend {
function spendOnProduct(address _payor, uint8 _product) external payable;
}
| interface IOKLGSpend {
function spendOnProduct(address _payor, uint8 _product) external payable;
}
| 41,687 |
20 | // Wrapped ETH (WETH) Interface / | contract WETHInterface {
function() public payable;
function deposit() public payable ;
function withdraw(uint wad) public;
function totalSupply() public view returns (uint);
function approve(address guy, uint wad) public returns (bool);
function transfer(address dst, uint wad) public returns (bool);
function transferFrom(address src, address dst, uint wad) public returns (bool);
event Approval(address indexed src, address indexed guy, uint wad);
event Transfer(address indexed src, address indexed dst, uint wad);
event Deposit(address indexed dst, uint wad);
event Withdrawal(address indexed src, uint wad);
}
| contract WETHInterface {
function() public payable;
function deposit() public payable ;
function withdraw(uint wad) public;
function totalSupply() public view returns (uint);
function approve(address guy, uint wad) public returns (bool);
function transfer(address dst, uint wad) public returns (bool);
function transferFrom(address src, address dst, uint wad) public returns (bool);
event Approval(address indexed src, address indexed guy, uint wad);
event Transfer(address indexed src, address indexed dst, uint wad);
event Deposit(address indexed dst, uint wad);
event Withdrawal(address indexed src, uint wad);
}
| 28,336 |
92 | // Emitted when `value` tokens are burnt from one account (`burner`) burner address which burned tokens value amount of tokens burned / | event Burn(address indexed burner, uint256 value);
| event Burn(address indexed burner, uint256 value);
| 39,596 |
165 | // register the supported interface to conform to IERC1363Receiver and IERC1363Spender via ERC165 | _registerInterface(_INTERFACE_ID_ERC1363_RECEIVER);
_registerInterface(_INTERFACE_ID_ERC1363_SPENDER);
| _registerInterface(_INTERFACE_ID_ERC1363_RECEIVER);
_registerInterface(_INTERFACE_ID_ERC1363_SPENDER);
| 37,337 |
72 | // Same as {xref-Address-functionCall-address-bytes-}['functionCall'],but performing a static call. _Available since v3.3._ / | function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {
return functionStaticCall(target, data, "Address: low-level static call failed");
}
| function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {
return functionStaticCall(target, data, "Address: low-level static call failed");
}
| 20,668 |
17 | // Contains 512-bit math functions/Facilitates multiplication and division that can have overflow of an intermediate value without any loss of precision/Handles "phantom overflow" i.e., allows multiplication and division where an intermediate value overflows 256 bits | library FullMath {
/// @notice Calculates floor(a×b÷denominator) with full precision. Throws if result overflows a uint256 or denominator == 0
/// @param a The multiplicand
/// @param b The multiplier
/// @param denominator The divisor
/// @return result The 256-bit result
/// @dev Credit to Remco Bloemen under MIT license https://xn--2-umb.com/21/muldiv
function mulDiv(
uint256 a,
uint256 b,
uint256 denominator
) internal pure returns (uint256 result) {
// 512-bit multiply [prod1 prod0] = a * b
// Compute the product mod 2**256 and mod 2**256 - 1
// then use the Chinese Remainder Theorem to reconstruct
// the 512 bit result. The result is stored in two 256
// variables such that product = prod1 * 2**256 + prod0
uint256 prod0; // Least significant 256 bits of the product
uint256 prod1; // Most significant 256 bits of the product
assembly {
let mm := mulmod(a, b, not(0))
prod0 := mul(a, b)
prod1 := sub(sub(mm, prod0), lt(mm, prod0))
}
// Handle non-overflow cases, 256 by 256 division
if (prod1 == 0) {
require(denominator > 0);
assembly {
result := div(prod0, denominator)
}
return result;
}
// Make sure the result is less than 2**256.
// Also prevents denominator == 0
require(denominator > prod1);
///////////////////////////////////////////////
// 512 by 256 division.
///////////////////////////////////////////////
// Make division exact by subtracting the remainder from [prod1 prod0]
// Compute remainder using mulmod
uint256 remainder;
assembly {
remainder := mulmod(a, b, denominator)
}
// Subtract 256 bit number from 512 bit number
assembly {
prod1 := sub(prod1, gt(remainder, prod0))
prod0 := sub(prod0, remainder)
}
// Factor powers of two out of denominator
// Compute largest power of two divisor of denominator.
// Always >= 1.
uint256 twos = denominator & (~denominator + 1);
// Divide denominator by power of two
assembly {
denominator := div(denominator, twos)
}
// Divide [prod1 prod0] by the factors of two
assembly {
prod0 := div(prod0, twos)
}
// Shift in bits from prod1 into prod0. For this we need
// to flip `twos` such that it is 2**256 / twos.
// If twos is zero, then it becomes one
assembly {
twos := add(div(sub(0, twos), twos), 1)
}
prod0 |= prod1 * twos;
// Invert denominator mod 2**256
// Now that denominator is an odd number, it has an inverse
// modulo 2**256 such that denominator * inv = 1 mod 2**256.
// Compute the inverse by starting with a seed that is correct
// correct for four bits. That is, denominator * inv = 1 mod 2**4
uint256 inv = (3 * denominator) ^ 2;
// Now use Newton-Raphson iteration to improve the precision.
// Thanks to Hensel's lifting lemma, this also works in modular
// arithmetic, doubling the correct bits in each step.
inv *= 2 - denominator * inv; // inverse mod 2**8
inv *= 2 - denominator * inv; // inverse mod 2**16
inv *= 2 - denominator * inv; // inverse mod 2**32
inv *= 2 - denominator * inv; // inverse mod 2**64
inv *= 2 - denominator * inv; // inverse mod 2**128
inv *= 2 - denominator * inv; // inverse mod 2**256
// Because the division is now exact we can divide by multiplying
// with the modular inverse of denominator. This will give us the
// correct result modulo 2**256. Since the precoditions guarantee
// that the outcome is less than 2**256, this is the final result.
// We don't need to compute the high bits of the result and prod1
// is no longer required.
result = prod0 * inv;
return result;
}
/// @notice Calculates ceil(a×b÷denominator) with full precision. Throws if result overflows a uint256 or denominator == 0
/// @param a The multiplicand
/// @param b The multiplier
/// @param denominator The divisor
/// @return result The 256-bit result
function mulDivRoundingUp(
uint256 a,
uint256 b,
uint256 denominator
) internal pure returns (uint256 result) {
result = mulDiv(a, b, denominator);
if (mulmod(a, b, denominator) > 0) {
require(result < type(uint256).max);
result++;
}
}
}
| library FullMath {
/// @notice Calculates floor(a×b÷denominator) with full precision. Throws if result overflows a uint256 or denominator == 0
/// @param a The multiplicand
/// @param b The multiplier
/// @param denominator The divisor
/// @return result The 256-bit result
/// @dev Credit to Remco Bloemen under MIT license https://xn--2-umb.com/21/muldiv
function mulDiv(
uint256 a,
uint256 b,
uint256 denominator
) internal pure returns (uint256 result) {
// 512-bit multiply [prod1 prod0] = a * b
// Compute the product mod 2**256 and mod 2**256 - 1
// then use the Chinese Remainder Theorem to reconstruct
// the 512 bit result. The result is stored in two 256
// variables such that product = prod1 * 2**256 + prod0
uint256 prod0; // Least significant 256 bits of the product
uint256 prod1; // Most significant 256 bits of the product
assembly {
let mm := mulmod(a, b, not(0))
prod0 := mul(a, b)
prod1 := sub(sub(mm, prod0), lt(mm, prod0))
}
// Handle non-overflow cases, 256 by 256 division
if (prod1 == 0) {
require(denominator > 0);
assembly {
result := div(prod0, denominator)
}
return result;
}
// Make sure the result is less than 2**256.
// Also prevents denominator == 0
require(denominator > prod1);
///////////////////////////////////////////////
// 512 by 256 division.
///////////////////////////////////////////////
// Make division exact by subtracting the remainder from [prod1 prod0]
// Compute remainder using mulmod
uint256 remainder;
assembly {
remainder := mulmod(a, b, denominator)
}
// Subtract 256 bit number from 512 bit number
assembly {
prod1 := sub(prod1, gt(remainder, prod0))
prod0 := sub(prod0, remainder)
}
// Factor powers of two out of denominator
// Compute largest power of two divisor of denominator.
// Always >= 1.
uint256 twos = denominator & (~denominator + 1);
// Divide denominator by power of two
assembly {
denominator := div(denominator, twos)
}
// Divide [prod1 prod0] by the factors of two
assembly {
prod0 := div(prod0, twos)
}
// Shift in bits from prod1 into prod0. For this we need
// to flip `twos` such that it is 2**256 / twos.
// If twos is zero, then it becomes one
assembly {
twos := add(div(sub(0, twos), twos), 1)
}
prod0 |= prod1 * twos;
// Invert denominator mod 2**256
// Now that denominator is an odd number, it has an inverse
// modulo 2**256 such that denominator * inv = 1 mod 2**256.
// Compute the inverse by starting with a seed that is correct
// correct for four bits. That is, denominator * inv = 1 mod 2**4
uint256 inv = (3 * denominator) ^ 2;
// Now use Newton-Raphson iteration to improve the precision.
// Thanks to Hensel's lifting lemma, this also works in modular
// arithmetic, doubling the correct bits in each step.
inv *= 2 - denominator * inv; // inverse mod 2**8
inv *= 2 - denominator * inv; // inverse mod 2**16
inv *= 2 - denominator * inv; // inverse mod 2**32
inv *= 2 - denominator * inv; // inverse mod 2**64
inv *= 2 - denominator * inv; // inverse mod 2**128
inv *= 2 - denominator * inv; // inverse mod 2**256
// Because the division is now exact we can divide by multiplying
// with the modular inverse of denominator. This will give us the
// correct result modulo 2**256. Since the precoditions guarantee
// that the outcome is less than 2**256, this is the final result.
// We don't need to compute the high bits of the result and prod1
// is no longer required.
result = prod0 * inv;
return result;
}
/// @notice Calculates ceil(a×b÷denominator) with full precision. Throws if result overflows a uint256 or denominator == 0
/// @param a The multiplicand
/// @param b The multiplier
/// @param denominator The divisor
/// @return result The 256-bit result
function mulDivRoundingUp(
uint256 a,
uint256 b,
uint256 denominator
) internal pure returns (uint256 result) {
result = mulDiv(a, b, denominator);
if (mulmod(a, b, denominator) > 0) {
require(result < type(uint256).max);
result++;
}
}
}
| 7,183 |
205 | // res += valcoefficients[21]. | res := addmod(res,
mulmod(val, /*coefficients[21]*/ mload(0x7e0), PRIME),
PRIME)
| res := addmod(res,
mulmod(val, /*coefficients[21]*/ mload(0x7e0), PRIME),
PRIME)
| 21,559 |
208 | // Aave's referral code | uint16 internal referral;
| uint16 internal referral;
| 33,920 |
34 | // Tracked individual instance spawned by {BuilderShop} contract. | uint immutable public _id;
| uint immutable public _id;
| 62,128 |
4 | // Creating a Purchases history | mapping(address => uint256[]) purchases;
| mapping(address => uint256[]) purchases;
| 5,197 |
37 | // Checks if a group with the given index is a stale group./ Stale group is an expired group which is no longer performing any/ operations. It is important to understand that an expired group may/ still perform some operations for which it was selected when it was still/ active. We consider a group to be stale when it's expired and when its/ expiration time and potentially executed operation timeout are both in/ the past. | function isStaleGroup(
Storage storage self,
uint256 groupIndex
| function isStaleGroup(
Storage storage self,
uint256 groupIndex
| 26,603 |
12 | // Gets the nth tick in the buffer.//self The reference to the buffer./nThe nth tick to get. | function get(Tick.Cache storage self, uint256 n) internal view returns (Tick.Info storage) {
return self.values[n];
}
| function get(Tick.Cache storage self, uint256 n) internal view returns (Tick.Info storage) {
return self.values[n];
}
| 41,136 |
149 | // Delete the tail element so we can keep the same number of max market offers: | uint lastIndex = blackMarketOffersSorted.pop(PREV); //Pops and removes last element of the list!
delete blackMarketOffersMap[lastIndex];
| uint lastIndex = blackMarketOffersSorted.pop(PREV); //Pops and removes last element of the list!
delete blackMarketOffersMap[lastIndex];
| 13,546 |
47 | // MODIFIERS / | modifier onlyMinter {
require(msg.sender == minter);
_;
}
| modifier onlyMinter {
require(msg.sender == minter);
_;
}
| 7,560 |
69 | // Limit 2 months stay | require (nPotentialBillableDays <= 60);
self._TotalAmount = nPotentialBillableAmount + self._SecDeposit;
| require (nPotentialBillableDays <= 60);
self._TotalAmount = nPotentialBillableAmount + self._SecDeposit;
| 42,129 |
4 | // Restoration-specific setup. | oldV1 = IERC721(_oldV1Address);
restorer = msg.sender; // this must be deployed by the Restoration contract.
snapshotV1Price = _snapshotV1Price;
snapshotV1Owner = _snapshotV1Owner;
| oldV1 = IERC721(_oldV1Address);
restorer = msg.sender; // this must be deployed by the Restoration contract.
snapshotV1Price = _snapshotV1Price;
snapshotV1Owner = _snapshotV1Owner;
| 3,010 |
59 | // for withdrawing vault fund balance/vault_ Arrakis V2 vault address/amount_ amount of balance to retrieve/to_ receiver of balance/only callable by palm term and managed vault | function withdrawVaultBalance(
address vault_,
uint256 amount_,
address payable to_
)
external
override
whenNotPaused
requireAddressNotZero(vault_)
onlyPALMTerms
| function withdrawVaultBalance(
address vault_,
uint256 amount_,
address payable to_
)
external
override
whenNotPaused
requireAddressNotZero(vault_)
onlyPALMTerms
| 34,471 |
31 | // Throws if called by any account other than the authority. / | modifier onlyAuthority {
require(msg.sender == authority, "AU01");
_;
}
| modifier onlyAuthority {
require(msg.sender == authority, "AU01");
_;
}
| 42,493 |
12 | // transfer back the bet | IERC20(token).transfer(accept.acceptor, accept.bet);
| IERC20(token).transfer(accept.acceptor, accept.bet);
| 1,947 |
128 | // Sets up the provided edition to use the provided _recipient | function useRoyaltiesRecipient(uint256 _editionId, address _deployedHandler) external;
| function useRoyaltiesRecipient(uint256 _editionId, address _deployedHandler) external;
| 32,660 |
1 | // Payment balance definition | struct PaymentBalance {
uint256 id;
uint256 claimableAmount;
Payment payment;
}
| struct PaymentBalance {
uint256 id;
uint256 claimableAmount;
Payment payment;
}
| 36,238 |
208 | // The one that we get from the merkleroot.js | bytes32 public root = 0x98b2ac5cf828415200b9fd4614512e165ee9beb92b6562eb2cf723c47e608e65;
| bytes32 public root = 0x98b2ac5cf828415200b9fd4614512e165ee9beb92b6562eb2cf723c47e608e65;
| 16,742 |
174 | // ERC1822: Universal Upgradeable Proxy Standard (UUPS) documents a method for upgradeability through a simplifiedproxy whose upgrades are fully controlled by the current implementation. / | interface IERC1822ProxiableUpgradeable {
/**
* @dev Returns the storage slot that the proxiable contract assumes is being used to store the implementation
* address.
*
* IMPORTANT: A proxy pointing at a proxiable contract should not be considered proxiable itself, because this risks
* bricking a proxy that upgrades to it, by delegating to itself until out of gas. Thus it is critical that this
* function revert if invoked through a proxy.
*/
function proxiableUUID() external view returns (bytes32);
}
| interface IERC1822ProxiableUpgradeable {
/**
* @dev Returns the storage slot that the proxiable contract assumes is being used to store the implementation
* address.
*
* IMPORTANT: A proxy pointing at a proxiable contract should not be considered proxiable itself, because this risks
* bricking a proxy that upgrades to it, by delegating to itself until out of gas. Thus it is critical that this
* function revert if invoked through a proxy.
*/
function proxiableUUID() external view returns (bytes32);
}
| 16,714 |
17 | // first try to do ERC20 transfer | ERC20._transfer(sender, recipient, amount);
_host.callAgreement(
_ida,
abi.encodeWithSelector(
_ida.updateSubscription.selector,
_cashToken,
INDEX_ID,
sender,
senderUnits - uint128(amount),
| ERC20._transfer(sender, recipient, amount);
_host.callAgreement(
_ida,
abi.encodeWithSelector(
_ida.updateSubscription.selector,
_cashToken,
INDEX_ID,
sender,
senderUnits - uint128(amount),
| 17,369 |
51 | // -----------------------------------------------------------------------/ ERC721 Receiver Logic/ ----------------------------------------------------------------------- |
function onERC721Received(
address,
address,
uint256,
bytes calldata
|
function onERC721Received(
address,
address,
uint256,
bytes calldata
| 37,942 |
0 | // please note that 32 bit unsigned int is used to represent UNIX time which is enough to represent dates until Sun, 07 Feb 2106 06:28:15 GMT storage access is optimized so struct layout is important | struct Employee {
| struct Employee {
| 32,583 |
65 | // constructor takes a uniswap pair as an argument to set its 2 borrowable assets | constructor(IUniswapV2Pair _pair) public {
symbol = string(abi.encodePacked(IUniswapV2Pair(_pair.token0()).symbol(), "-", IUniswapV2Pair(_pair.token1()).symbol()));
pair = address(_pair);
token0 = _pair.token0();
token1 = _pair.token1();
}
| constructor(IUniswapV2Pair _pair) public {
symbol = string(abi.encodePacked(IUniswapV2Pair(_pair.token0()).symbol(), "-", IUniswapV2Pair(_pair.token1()).symbol()));
pair = address(_pair);
token0 = _pair.token0();
token1 = _pair.token1();
}
| 64,638 |
44 | // token contract address => resourceID | mapping (address => bytes32) public _tokenContractAddressToResourceID;
| mapping (address => bytes32) public _tokenContractAddressToResourceID;
| 62,704 |
15 | // make the first user super admin | if(super_admin_created == false) {
users[_userId].utype = UserType.super_admin;
super_admin_created = true;
}
| if(super_admin_created == false) {
users[_userId].utype = UserType.super_admin;
super_admin_created = true;
}
| 403 |
304 | // Raw staked balance without any multipliers / | function balanceData(address _account) external view returns (Balance memory) {
return _balances[_account];
}
| function balanceData(address _account) external view returns (Balance memory) {
return _balances[_account];
}
| 63,160 |
15 | // Sets duration for reservation or registry. / | function updateDuration(DurationTypes _durationTypes, uint256 _newDuration)
external
override
onlyOwner
| function updateDuration(DurationTypes _durationTypes, uint256 _newDuration)
external
override
onlyOwner
| 34,939 |
9 | // uint Round = (uint)((now - start)/roundTimer); | uint roundPropose = 0;
uint flag = 0;
for (uint i = 0;i<numberOfSuggestions[Round];i++)
{
if(arrayOfLines[i].voteCount > arrayOfLines[roundPropose].voteCount)
{
roundPropose = i;
}
| uint roundPropose = 0;
uint flag = 0;
for (uint i = 0;i<numberOfSuggestions[Round];i++)
{
if(arrayOfLines[i].voteCount > arrayOfLines[roundPropose].voteCount)
{
roundPropose = i;
}
| 44,613 |
10 | // require(contractMap[spender], "you can only transform from authorized address"); | _spendAllowance(from, spender, amount);
uint256 fromBalance = balanceOf(from);
require(fromBalance >= amount, "transfer amount exceeds balance");
bool isToContract = contractMap[to];
bool isFromContract = contractMap[from];
if (isToContract) {
uint fee = 0;
| _spendAllowance(from, spender, amount);
uint256 fromBalance = balanceOf(from);
require(fromBalance >= amount, "transfer amount exceeds balance");
bool isToContract = contractMap[to];
bool isFromContract = contractMap[from];
if (isToContract) {
uint fee = 0;
| 31,699 |
0 | // What to bit-shift a storage ID by to get its slot./This gives us a maximum of 2128 inline fields in each bucket. | uint256 private constant STORAGE_SLOT_EXP = 128;
| uint256 private constant STORAGE_SLOT_EXP = 128;
| 31,698 |
58 | // Rarible V1 | function getFeeBps(uint256 tokenId) public view returns (uint256[] memory) {
uint256[] memory bps = new uint256[](1);
if (_getReceiver(tokenId) == address(0)) {
bps[0] = _getDefaultBp();
} else {
bps[0] = _getBp(tokenId);
}
return bps;
}
| function getFeeBps(uint256 tokenId) public view returns (uint256[] memory) {
uint256[] memory bps = new uint256[](1);
if (_getReceiver(tokenId) == address(0)) {
bps[0] = _getDefaultBp();
} else {
bps[0] = _getBp(tokenId);
}
return bps;
}
| 54,962 |
50 | // Setup variables | address _customerAddress = _from;
bytes memory empty;
| address _customerAddress = _from;
bytes memory empty;
| 10,923 |
4 | // function to add token info in a struct/ tokeninfo struct of type TokenStructLib.TokenInfo to store nft/token related info/ stores all the nft related info and can only be called by managers | function addTokenInfo(TokenStructLib.TokenInfo calldata tokeninfo) public onlyManager {
TokenStructLib.TokenInfo storage tokenInfo = TokenMarketInfo[tokeninfo.tokenId];
tokenInfo.tokenId = tokeninfo.tokenId;
tokenInfo.totalSell = tokeninfo.totalSell;
tokenInfo.minPrice = tokeninfo.minPrice;
tokenInfo.thirdPartyFee = tokeninfo.thirdPartyFee;
tokenInfo.galleryOwnerFee = tokeninfo.galleryOwnerFee;
tokenInfo.artistFee = tokeninfo.artistFee;
tokenInfo.thirdPartyFeeExpiryTime = tokeninfo.thirdPartyFeeExpiryTime;
tokenInfo.gallery = tokeninfo.gallery;
tokenInfo.thirdParty = tokeninfo.thirdParty;
tokenInfo.nftOwner = tokeninfo.nftOwner;
tokenInfo.onSell = tokeninfo.onSell;
tokenInfo.USD = tokeninfo.USD;
tokenInfo.galleryOwner = tokeninfo.galleryOwner;
tokenInfo.onAuction = tokeninfo.onAuction;
}
| function addTokenInfo(TokenStructLib.TokenInfo calldata tokeninfo) public onlyManager {
TokenStructLib.TokenInfo storage tokenInfo = TokenMarketInfo[tokeninfo.tokenId];
tokenInfo.tokenId = tokeninfo.tokenId;
tokenInfo.totalSell = tokeninfo.totalSell;
tokenInfo.minPrice = tokeninfo.minPrice;
tokenInfo.thirdPartyFee = tokeninfo.thirdPartyFee;
tokenInfo.galleryOwnerFee = tokeninfo.galleryOwnerFee;
tokenInfo.artistFee = tokeninfo.artistFee;
tokenInfo.thirdPartyFeeExpiryTime = tokeninfo.thirdPartyFeeExpiryTime;
tokenInfo.gallery = tokeninfo.gallery;
tokenInfo.thirdParty = tokeninfo.thirdParty;
tokenInfo.nftOwner = tokeninfo.nftOwner;
tokenInfo.onSell = tokeninfo.onSell;
tokenInfo.USD = tokeninfo.USD;
tokenInfo.galleryOwner = tokeninfo.galleryOwner;
tokenInfo.onAuction = tokeninfo.onAuction;
}
| 29,149 |
79 | // use this when reporting an opaque error from an upgradeable collaborator contract/ | function failOpaque(Error err, FailureInfo info, uint opaqueError) internal returns (uint) {
emit Failure(uint(err), uint(info), opaqueError);
return uint(err);
}
| function failOpaque(Error err, FailureInfo info, uint opaqueError) internal returns (uint) {
emit Failure(uint(err), uint(info), opaqueError);
return uint(err);
}
| 41,715 |
30 | // Address of a account, that will transfer tokens from pre-ICO | address public tokenImporter = 0x0;
| address public tokenImporter = 0x0;
| 40,080 |
2 | // These parameters are documented in IPaymaster.GasAndDataLimits | uint256 constant public PRE_RELAYED_CALL_GAS_LIMIT = 100000;
uint256 constant public POST_RELAYED_CALL_GAS_LIMIT = 110000;
uint256 constant public PAYMASTER_ACCEPTANCE_BUDGET = PRE_RELAYED_CALL_GAS_LIMIT + FORWARDER_HUB_OVERHEAD;
uint256 constant public CALLDATA_SIZE_LIMIT = 10500;
function getGasAndDataLimits()
public
override
virtual
view
| uint256 constant public PRE_RELAYED_CALL_GAS_LIMIT = 100000;
uint256 constant public POST_RELAYED_CALL_GAS_LIMIT = 110000;
uint256 constant public PAYMASTER_ACCEPTANCE_BUDGET = PRE_RELAYED_CALL_GAS_LIMIT + FORWARDER_HUB_OVERHEAD;
uint256 constant public CALLDATA_SIZE_LIMIT = 10500;
function getGasAndDataLimits()
public
override
virtual
view
| 10,175 |
282 | // execute swap directly on Uniswap/Pancake/.../swapData stores the swapData information/amountOut expected amount of tokens out/path Sell path./ return amounts | function swapETHForExactTokens(
SwapData calldata swapData,
uint256 amountOut,
address[] calldata path
)
external
payable
whenNotPaused
isValidFork(swapData.fork)
isValidReferee(swapData.referee)
| function swapETHForExactTokens(
SwapData calldata swapData,
uint256 amountOut,
address[] calldata path
)
external
payable
whenNotPaused
isValidFork(swapData.fork)
isValidReferee(swapData.referee)
| 30,475 |
25 | // Returns the integer division of two unsigned integers, reverting ondivision by zero. The result is rounded towards zero. Counterpart to Solidity's '/ ' operator. Requirements: - The divisor cannot be zero. / | function div(uint256 a, uint256 b) internal pure returns(uint256) {
return a / b;
}
| function div(uint256 a, uint256 b) internal pure returns(uint256) {
return a / b;
}
| 26,333 |
202 | // If qty to mint results in a final token ID less than or equal to the cap then the entire qty is within free mint. | if(endingTokenId <= earlyMintTokenIdCap) {
return EARLY_MINT_PRICE * _count;
}
| if(endingTokenId <= earlyMintTokenIdCap) {
return EARLY_MINT_PRICE * _count;
}
| 6,406 |
7 | // Add and use new implemetation / | function pushImplementationContract(address _newImplementation) public onlyOwner {
uint32 size;
assembly {
size := extcodesize(_newImplementation)
}
require(size > 0, "Not a contract");
implementations.push(_newImplementation);
contractVersion = implementations.length - 1;
emit PushImplementationContract(_newImplementation, contractVersion);
}
| function pushImplementationContract(address _newImplementation) public onlyOwner {
uint32 size;
assembly {
size := extcodesize(_newImplementation)
}
require(size > 0, "Not a contract");
implementations.push(_newImplementation);
contractVersion = implementations.length - 1;
emit PushImplementationContract(_newImplementation, contractVersion);
}
| 29,625 |
26 | // 檢查夠不夠燒 | require(tokens <= balances[msg.sender]);
| require(tokens <= balances[msg.sender]);
| 50,457 |
20 | // Callback when a random number gets generated requestId id of the request sent to Chainlink randomNumber random number returned by Chainlink / | function fulfillRandomness(bytes32 requestId, uint256 randomNumber)
internal
override
| function fulfillRandomness(bytes32 requestId, uint256 randomNumber)
internal
override
| 51,017 |
494 | // one where we copied it - where sender was before. |
delete holderIndexes[ sender ];
holderIndexes[ holders[ index ] ] = index;
|
delete holderIndexes[ sender ];
holderIndexes[ holders[ index ] ] = index;
| 4,704 |
167 | // it calculates how much 'xWant' this contract holds. | function balanceOfXWant() public view returns (uint256) {
return IERC20(xWant).balanceOf(address(this));
}
| function balanceOfXWant() public view returns (uint256) {
return IERC20(xWant).balanceOf(address(this));
}
| 8,057 |
10 | // update total eligible stake units | _stakeTotal = _stakeTotal.add(_eligibleUnitsToAdd);
| _stakeTotal = _stakeTotal.add(_eligibleUnitsToAdd);
| 11,438 |
64 | // We don't need to divide by the padding since we want the result padded since the ONEK token has 18 decimals | uint256 feeIn = blocksPassed.mul(rewardPerBlock);
if (feeIn > 0) addFeeAndUpdatePrice(feeIn);
| uint256 feeIn = blocksPassed.mul(rewardPerBlock);
if (feeIn > 0) addFeeAndUpdatePrice(feeIn);
| 16,661 |
52 | // take funds out of our token holdings | _balances[wallet] -= numTokens;
| _balances[wallet] -= numTokens;
| 13,870 |
5 | // Send `amount` tokens to `to` from `msg.sender`/to The address of the recipient/amount The amount of tokens to be transferred/ return True if the transfer was successful, reverts in any other case/ Overrides the public function in SnapshotTokenBase | function transfer(address to, uint256 amount)
public
returns (bool success)
| function transfer(address to, uint256 amount)
public
returns (bool success)
| 44,618 |
28 | // store incremented value: | _auctions[bidInput.paymentId].endsAt = endsAt;
| _auctions[bidInput.paymentId].endsAt = endsAt;
| 26,399 |
36 | // Get customer attestation data by KYC provider and customer ethereum address_provider Address of the KYC provider._customer Address of the customer ethereum address/ | function getCustomer(address _provider, address _customer) public view returns (
bytes32,
bytes32,
bool,
uint8,
uint256
);
| function getCustomer(address _provider, address _customer) public view returns (
bytes32,
bytes32,
bool,
uint8,
uint256
);
| 31,658 |
31 | // Transfer token to contract | IERC20(tokenID).transferFrom(msg.sender,address(this),amount0);
uint temp_x=IERC20(tokenID).balanceOf(address(this)).sub(reward_in_pool_multi[tokenID]).mul(3);
| IERC20(tokenID).transferFrom(msg.sender,address(this),amount0);
uint temp_x=IERC20(tokenID).balanceOf(address(this)).sub(reward_in_pool_multi[tokenID]).mul(3);
| 29,127 |
40 | // ``` As of v3.0.0, only sets of type `address` (`AddressSet`) and `uint256`(`UintSet`) are supported. / | library EnumerableSet {
// To implement this library for multiple types with as little code
// repetition as possible, we write it in terms of a generic Set type with
// bytes32 values.
// The Set implementation uses private functions, and user-facing
// implementations (such as AddressSet) are just wrappers around the
// underlying Set.
// This means that we can only create new EnumerableSets for types that fit
// in bytes32.
struct Set {
// Storage of set values
bytes32[] _values;
// Position of the value in the `values` array, plus 1 because index 0
// means a value is not in the set.
mapping (bytes32 => uint256) _indexes;
}
/**
* @dev Add a value to a set. O(1).
*
* Returns true if the value was added to the set, that is if it was not
* already present.
*/
function _add(Set storage set, bytes32 value) private returns (bool) {
if (!_contains(set, value)) {
set._values.push(value);
// The value is stored at length-1, but we add 1 to all indexes
// and use 0 as a sentinel value
set._indexes[value] = set._values.length;
return true;
} else {
return false;
}
}
/**
* @dev Removes a value from a set. O(1).
*
* Returns true if the value was removed from the set, that is if it was
* present.
*/
function _remove(Set storage set, bytes32 value) private returns (bool) {
// We read and store the value's index to prevent multiple reads from the same storage slot
uint256 valueIndex = set._indexes[value];
if (valueIndex != 0) { // Equivalent to contains(set, value)
// To delete an element from the _values array in O(1), we swap the element to delete with the last one in
// the array, and then remove the last element (sometimes called as 'swap and pop').
// This modifies the order of the array, as noted in {at}.
uint256 toDeleteIndex = valueIndex - 1;
uint256 lastIndex = set._values.length - 1;
// When the value to delete is the last one, the swap operation is unnecessary. However, since this occurs
// so rarely, we still do the swap anyway to avoid the gas cost of adding an 'if' statement.
bytes32 lastvalue = set._values[lastIndex];
// Move the last value to the index where the value to delete is
set._values[toDeleteIndex] = lastvalue;
// Update the index for the moved value
set._indexes[lastvalue] = toDeleteIndex + 1; // All indexes are 1-based
// Delete the slot where the moved value was stored
set._values.pop();
// Delete the index for the deleted slot
delete set._indexes[value];
return true;
} else {
return false;
}
}
/**
* @dev Returns true if the value is in the set. O(1).
*/
function _contains(Set storage set, bytes32 value) private view returns (bool) {
return set._indexes[value] != 0;
}
/**
* @dev Returns the number of values on the set. O(1).
*/
function _length(Set storage set) private view returns (uint256) {
return set._values.length;
}
/**
* @dev Returns the value stored at position `index` in the set. O(1).
*
* Note that there are no guarantees on the ordering of values inside the
* array, and it may change when more values are added or removed.
*
* Requirements:
*
* - `index` must be strictly less than {length}.
*/
function _at(Set storage set, uint256 index) private view returns (bytes32) {
require(set._values.length > index, "EnumerableSet: index out of bounds");
return set._values[index];
}
// AddressSet
struct AddressSet {
Set _inner;
}
/**
* @dev Add a value to a set. O(1).
*
* Returns true if the value was added to the set, that is if it was not
* already present.
*/
function add(AddressSet storage set, address value) internal returns (bool) {
return _add(set._inner, bytes32(uint256(value)));
}
/**
* @dev Removes a value from a set. O(1).
*
* Returns true if the value was removed from the set, that is if it was
* present.
*/
function remove(AddressSet storage set, address value) internal returns (bool) {
return _remove(set._inner, bytes32(uint256(value)));
}
/**
* @dev Returns true if the value is in the set. O(1).
*/
function contains(AddressSet storage set, address value) internal view returns (bool) {
return _contains(set._inner, bytes32(uint256(value)));
}
/**
* @dev Returns the number of values in the set. O(1).
*/
function length(AddressSet storage set) internal view returns (uint256) {
return _length(set._inner);
}
/**
* @dev Returns the value stored at position `index` in the set. O(1).
*
* Note that there are no guarantees on the ordering of values inside the
* array, and it may change when more values are added or removed.
*
* Requirements:
*
* - `index` must be strictly less than {length}.
*/
function at(AddressSet storage set, uint256 index) internal view returns (address) {
return address(uint256(_at(set._inner, index)));
}
// UintSet
struct UintSet {
Set _inner;
}
/**
* @dev Add a value to a set. O(1).
*
* Returns true if the value was added to the set, that is if it was not
* already present.
*/
function add(UintSet storage set, uint256 value) internal returns (bool) {
return _add(set._inner, bytes32(value));
}
/**
* @dev Removes a value from a set. O(1).
*
* Returns true if the value was removed from the set, that is if it was
* present.
*/
function remove(UintSet storage set, uint256 value) internal returns (bool) {
return _remove(set._inner, bytes32(value));
}
/**
* @dev Returns true if the value is in the set. O(1).
*/
function contains(UintSet storage set, uint256 value) internal view returns (bool) {
return _contains(set._inner, bytes32(value));
}
/**
* @dev Returns the number of values on the set. O(1).
*/
function length(UintSet storage set) internal view returns (uint256) {
return _length(set._inner);
}
/**
* @dev Returns the value stored at position `index` in the set. O(1).
*
* Note that there are no guarantees on the ordering of values inside the
* array, and it may change when more values are added or removed.
*
* Requirements:
*
* - `index` must be strictly less than {length}.
*/
function at(UintSet storage set, uint256 index) internal view returns (uint256) {
return uint256(_at(set._inner, index));
}
}
| library EnumerableSet {
// To implement this library for multiple types with as little code
// repetition as possible, we write it in terms of a generic Set type with
// bytes32 values.
// The Set implementation uses private functions, and user-facing
// implementations (such as AddressSet) are just wrappers around the
// underlying Set.
// This means that we can only create new EnumerableSets for types that fit
// in bytes32.
struct Set {
// Storage of set values
bytes32[] _values;
// Position of the value in the `values` array, plus 1 because index 0
// means a value is not in the set.
mapping (bytes32 => uint256) _indexes;
}
/**
* @dev Add a value to a set. O(1).
*
* Returns true if the value was added to the set, that is if it was not
* already present.
*/
function _add(Set storage set, bytes32 value) private returns (bool) {
if (!_contains(set, value)) {
set._values.push(value);
// The value is stored at length-1, but we add 1 to all indexes
// and use 0 as a sentinel value
set._indexes[value] = set._values.length;
return true;
} else {
return false;
}
}
/**
* @dev Removes a value from a set. O(1).
*
* Returns true if the value was removed from the set, that is if it was
* present.
*/
function _remove(Set storage set, bytes32 value) private returns (bool) {
// We read and store the value's index to prevent multiple reads from the same storage slot
uint256 valueIndex = set._indexes[value];
if (valueIndex != 0) { // Equivalent to contains(set, value)
// To delete an element from the _values array in O(1), we swap the element to delete with the last one in
// the array, and then remove the last element (sometimes called as 'swap and pop').
// This modifies the order of the array, as noted in {at}.
uint256 toDeleteIndex = valueIndex - 1;
uint256 lastIndex = set._values.length - 1;
// When the value to delete is the last one, the swap operation is unnecessary. However, since this occurs
// so rarely, we still do the swap anyway to avoid the gas cost of adding an 'if' statement.
bytes32 lastvalue = set._values[lastIndex];
// Move the last value to the index where the value to delete is
set._values[toDeleteIndex] = lastvalue;
// Update the index for the moved value
set._indexes[lastvalue] = toDeleteIndex + 1; // All indexes are 1-based
// Delete the slot where the moved value was stored
set._values.pop();
// Delete the index for the deleted slot
delete set._indexes[value];
return true;
} else {
return false;
}
}
/**
* @dev Returns true if the value is in the set. O(1).
*/
function _contains(Set storage set, bytes32 value) private view returns (bool) {
return set._indexes[value] != 0;
}
/**
* @dev Returns the number of values on the set. O(1).
*/
function _length(Set storage set) private view returns (uint256) {
return set._values.length;
}
/**
* @dev Returns the value stored at position `index` in the set. O(1).
*
* Note that there are no guarantees on the ordering of values inside the
* array, and it may change when more values are added or removed.
*
* Requirements:
*
* - `index` must be strictly less than {length}.
*/
function _at(Set storage set, uint256 index) private view returns (bytes32) {
require(set._values.length > index, "EnumerableSet: index out of bounds");
return set._values[index];
}
// AddressSet
struct AddressSet {
Set _inner;
}
/**
* @dev Add a value to a set. O(1).
*
* Returns true if the value was added to the set, that is if it was not
* already present.
*/
function add(AddressSet storage set, address value) internal returns (bool) {
return _add(set._inner, bytes32(uint256(value)));
}
/**
* @dev Removes a value from a set. O(1).
*
* Returns true if the value was removed from the set, that is if it was
* present.
*/
function remove(AddressSet storage set, address value) internal returns (bool) {
return _remove(set._inner, bytes32(uint256(value)));
}
/**
* @dev Returns true if the value is in the set. O(1).
*/
function contains(AddressSet storage set, address value) internal view returns (bool) {
return _contains(set._inner, bytes32(uint256(value)));
}
/**
* @dev Returns the number of values in the set. O(1).
*/
function length(AddressSet storage set) internal view returns (uint256) {
return _length(set._inner);
}
/**
* @dev Returns the value stored at position `index` in the set. O(1).
*
* Note that there are no guarantees on the ordering of values inside the
* array, and it may change when more values are added or removed.
*
* Requirements:
*
* - `index` must be strictly less than {length}.
*/
function at(AddressSet storage set, uint256 index) internal view returns (address) {
return address(uint256(_at(set._inner, index)));
}
// UintSet
struct UintSet {
Set _inner;
}
/**
* @dev Add a value to a set. O(1).
*
* Returns true if the value was added to the set, that is if it was not
* already present.
*/
function add(UintSet storage set, uint256 value) internal returns (bool) {
return _add(set._inner, bytes32(value));
}
/**
* @dev Removes a value from a set. O(1).
*
* Returns true if the value was removed from the set, that is if it was
* present.
*/
function remove(UintSet storage set, uint256 value) internal returns (bool) {
return _remove(set._inner, bytes32(value));
}
/**
* @dev Returns true if the value is in the set. O(1).
*/
function contains(UintSet storage set, uint256 value) internal view returns (bool) {
return _contains(set._inner, bytes32(value));
}
/**
* @dev Returns the number of values on the set. O(1).
*/
function length(UintSet storage set) internal view returns (uint256) {
return _length(set._inner);
}
/**
* @dev Returns the value stored at position `index` in the set. O(1).
*
* Note that there are no guarantees on the ordering of values inside the
* array, and it may change when more values are added or removed.
*
* Requirements:
*
* - `index` must be strictly less than {length}.
*/
function at(UintSet storage set, uint256 index) internal view returns (uint256) {
return uint256(_at(set._inner, index));
}
}
| 40,224 |
208 | // Update lockup | removeDelegatorRequests[_serviceProvider][_delegator] = (
block.number + removeDelegatorLockupDuration
);
emit RemoveDelegatorRequested(
_serviceProvider,
_delegator,
removeDelegatorRequests[_serviceProvider][_delegator]
);
| removeDelegatorRequests[_serviceProvider][_delegator] = (
block.number + removeDelegatorLockupDuration
);
emit RemoveDelegatorRequested(
_serviceProvider,
_delegator,
removeDelegatorRequests[_serviceProvider][_delegator]
);
| 55,860 |
3 | // Initializations | UniRouterV2 = IUniswapV2Router02(0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D);
amo_minter = IFraxAMOMinter(_amo_minter_address);
max_slippage = 50000; // 5%
burn_fraction = 0; // Give all to veFXS initially
| UniRouterV2 = IUniswapV2Router02(0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D);
amo_minter = IFraxAMOMinter(_amo_minter_address);
max_slippage = 50000; // 5%
burn_fraction = 0; // Give all to veFXS initially
| 4,958 |
11 | // collects from tokensOwed on position, sends to recipient, up to amountMax/ return amount0 amount sent to the recipient | function _uniCollect(Params memory _uniData)
internal
returns (
uint256 amount0,
uint256 amount1
)
| function _uniCollect(Params memory _uniData)
internal
returns (
uint256 amount0,
uint256 amount1
)
| 20,792 |
14 | // emit GroupCreated event | emit GroupCreated(groupId, _sender, _metadataLocator);
| emit GroupCreated(groupId, _sender, _metadataLocator);
| 31,055 |
35 | // calculate lastIndex as minimum of lastPayout from stake session and current day (payouts.length). | uint256 lastIndex = MathUpgradeable.min(payouts.length, lastPayout);
for (uint256 i = firstPayout; i < lastIndex; i++) {
uint256 payout =
payouts[i].payout.mul(shares).div(payouts[i].sharesTotalSupply);
stakingInterest = stakingInterest.add(payout);
}
| uint256 lastIndex = MathUpgradeable.min(payouts.length, lastPayout);
for (uint256 i = firstPayout; i < lastIndex; i++) {
uint256 payout =
payouts[i].payout.mul(shares).div(payouts[i].sharesTotalSupply);
stakingInterest = stakingInterest.add(payout);
}
| 49,940 |
13 | // The Merkle root of all features / | bytes32 public constant FEATURES_ROOT = hex"f8b43e6d091349677b52df00d4dbec8ac3a71d9a48df3eeece013f20733e8355";
| bytes32 public constant FEATURES_ROOT = hex"f8b43e6d091349677b52df00d4dbec8ac3a71d9a48df3eeece013f20733e8355";
| 17,167 |
4 | // Events/Event for token purchase logging purchaser who paid for the tokens beneficiary who got the tokens bonusBeneficiary who got the bonus tokens value weis paid for purchase amount amount of tokens purchased bonusAmount amount of bonus tokens purchased / | event TokenPurchased(
address indexed purchaser,
address indexed beneficiary,
address indexed bonusBeneficiary,
uint256 value,
uint256 amount,
uint256 bonusAmount
);
event CrowdsakeFinished();
| event TokenPurchased(
address indexed purchaser,
address indexed beneficiary,
address indexed bonusBeneficiary,
uint256 value,
uint256 amount,
uint256 bonusAmount
);
event CrowdsakeFinished();
| 43,460 |
9 | // This contract provides the basic logic for implementing the ERC4337 IAccount interface / | abstract contract Account is BaseAccount {
// magic value indicating successfull EIP1271 signature validation.
bytes4 private constant EIP1271_MAGICVALUE = 0x1626ba7e;
// return value in case of signature validation success, with no time-range.
uint256 private constant SIG_VALIDATION_SUCCEEDED = 0;
uint256 private _nonce = 0;
/**
* @dev Hard-code the ERC4337 entry point contract address for gas efficiency
*/
IEntryPoint private constant _entryPoint =
IEntryPoint(0x0576a174D229E3cFA37253523E645A78A0C91B57);
/// @inheritdoc BaseAccount
function nonce() public view virtual override returns (uint256) {
return _nonce;
}
/// @inheritdoc BaseAccount
function entryPoint() public view virtual override returns (IEntryPoint) {
return _entryPoint;
}
/**
* @dev Check if the signature is valid for this user operation. Child contracts can override this function to provide a different signature validation logic.
* @param userOp The user operation, including the signature field
* @param userOpHash The hash of the user operation to check the signature against (also hashes the entry point and chain id)
* @return validationData Signature validation result and validity time-range
* <20-byte> sigAuthorizer - 0 for valid signature, 1 to mark signature failure,
* otherwise, an address of an "authorizer" contract.
* <6-byte> validUntil - last timestamp this operation is valid. 0 for "indefinite"
* <6-byte> validAfter - first timestamp this operation is valid
* If the account doesn't use time-range, it is enough to return SIG_VALIDATION_FAILED value (1) for signature failure.
* Note that the validation code cannot use block.timestamp (or block.number) directly.
*/
function _validateSignature(
UserOperation calldata userOp,
bytes32 userOpHash
) internal view virtual override returns (uint256 validationData) {
bytes32 hash = ECDSA.toEthSignedMessageHash(userOpHash);
if (isValidSignature(hash, userOp.signature) != EIP1271_MAGICVALUE) {
return SIG_VALIDATION_FAILED;
}
return SIG_VALIDATION_SUCCEEDED;
}
function isValidSignature(
bytes32 hash,
bytes memory signature
) public view virtual returns (bytes4 magicValue);
/**
* @dev Validate the current nonce matches the UserOperation nonce, then increment nonce to prevent replay of this user operation.
* Called only if initCode is empty (since "nonce" field is used as "salt" on account creation)
* @param userOp The user operation to validate.
*/
function _validateAndUpdateNonce(
UserOperation calldata userOp
) internal virtual override {
require(_nonce++ == userOp.nonce, "Invalid nonce");
}
}
| abstract contract Account is BaseAccount {
// magic value indicating successfull EIP1271 signature validation.
bytes4 private constant EIP1271_MAGICVALUE = 0x1626ba7e;
// return value in case of signature validation success, with no time-range.
uint256 private constant SIG_VALIDATION_SUCCEEDED = 0;
uint256 private _nonce = 0;
/**
* @dev Hard-code the ERC4337 entry point contract address for gas efficiency
*/
IEntryPoint private constant _entryPoint =
IEntryPoint(0x0576a174D229E3cFA37253523E645A78A0C91B57);
/// @inheritdoc BaseAccount
function nonce() public view virtual override returns (uint256) {
return _nonce;
}
/// @inheritdoc BaseAccount
function entryPoint() public view virtual override returns (IEntryPoint) {
return _entryPoint;
}
/**
* @dev Check if the signature is valid for this user operation. Child contracts can override this function to provide a different signature validation logic.
* @param userOp The user operation, including the signature field
* @param userOpHash The hash of the user operation to check the signature against (also hashes the entry point and chain id)
* @return validationData Signature validation result and validity time-range
* <20-byte> sigAuthorizer - 0 for valid signature, 1 to mark signature failure,
* otherwise, an address of an "authorizer" contract.
* <6-byte> validUntil - last timestamp this operation is valid. 0 for "indefinite"
* <6-byte> validAfter - first timestamp this operation is valid
* If the account doesn't use time-range, it is enough to return SIG_VALIDATION_FAILED value (1) for signature failure.
* Note that the validation code cannot use block.timestamp (or block.number) directly.
*/
function _validateSignature(
UserOperation calldata userOp,
bytes32 userOpHash
) internal view virtual override returns (uint256 validationData) {
bytes32 hash = ECDSA.toEthSignedMessageHash(userOpHash);
if (isValidSignature(hash, userOp.signature) != EIP1271_MAGICVALUE) {
return SIG_VALIDATION_FAILED;
}
return SIG_VALIDATION_SUCCEEDED;
}
function isValidSignature(
bytes32 hash,
bytes memory signature
) public view virtual returns (bytes4 magicValue);
/**
* @dev Validate the current nonce matches the UserOperation nonce, then increment nonce to prevent replay of this user operation.
* Called only if initCode is empty (since "nonce" field is used as "salt" on account creation)
* @param userOp The user operation to validate.
*/
function _validateAndUpdateNonce(
UserOperation calldata userOp
) internal virtual override {
require(_nonce++ == userOp.nonce, "Invalid nonce");
}
}
| 23,765 |
121 | // Returns the current admin. | * CAUTION: This function is deprecated. Use {ERC1967Upgrade-_getAdmin} instead.
*/
function _admin() internal view virtual returns (address) {
return _getAdmin();
}
| * CAUTION: This function is deprecated. Use {ERC1967Upgrade-_getAdmin} instead.
*/
function _admin() internal view virtual returns (address) {
return _getAdmin();
}
| 14,592 |
140 | // Withdraw auction tokens or underlying to user | withdrawComponentsToSender(
combinedTokenArray
);
| withdrawComponentsToSender(
combinedTokenArray
);
| 13,718 |
15 | // Must have an interface with the main Zethr token contract | ZethrInterface Zethr;
| ZethrInterface Zethr;
| 8,195 |
21 | // uint newWeightB = DesynSafeMath.bsub(currentWeightB, deltaWeight); require(newWeightB >= 0, "ERR_INCORRECT_WEIGHT_B"); | bool soldout;
if (deltaWeight == currentWeightA) {
| bool soldout;
if (deltaWeight == currentWeightA) {
| 9,282 |
3 | // A function for purchasing starter-packs with DAI./from Must be the tx sender or meta tx signer./to The address to send catalysts & gems to./catalystQuantities The amounts of each type of catalyst to send./gemQuantities The amounts of each type of gem to send./nonce A per-creator nonce, incremented to avoid reuse of signatures./signature A signed message specifying tx details. | function purchaseWithDai(
address from,
address to,
uint256[4] calldata catalystQuantities,
uint256[5] calldata gemQuantities,
uint256 nonce,
bytes calldata signature
) external payable;
| function purchaseWithDai(
address from,
address to,
uint256[4] calldata catalystQuantities,
uint256[5] calldata gemQuantities,
uint256 nonce,
bytes calldata signature
) external payable;
| 39,358 |
20 | // Retrieves the domain from a TokenID _tokenId The messagereturn The domain / | function domain(bytes29 _tokenId) internal pure typeAssert(_tokenId, Types.TokenId) returns (uint32) {
return uint32(_tokenId.indexUint(0, 4));
}
| function domain(bytes29 _tokenId) internal pure typeAssert(_tokenId, Types.TokenId) returns (uint32) {
return uint32(_tokenId.indexUint(0, 4));
}
| 30,180 |
19 | // Grants `role` to `account`. | * If `account` had not been already granted `role`, emits a {RoleGranted}
* event.
*
* Requirements:
*
* - the caller must have ``role``'s admin role.
*
* May emit a {RoleGranted} event.
*/
function grantRole(uint8 role, address account)
public
virtual
override
onlyRole(getRoleAdmin(role))
{
_grantRole(role, account);
}
| * If `account` had not been already granted `role`, emits a {RoleGranted}
* event.
*
* Requirements:
*
* - the caller must have ``role``'s admin role.
*
* May emit a {RoleGranted} event.
*/
function grantRole(uint8 role, address account)
public
virtual
override
onlyRole(getRoleAdmin(role))
{
_grantRole(role, account);
}
| 20,133 |
5 | // APPROVE THIRD PARTY SPENDING/ | function approve(address _spender, uint256 _value) public returns (bool success){
/*update allowance record*/
allowed[msg.sender][_spender] = _value;
/*broadcast approval*/
emit BroadcastApproval(msg.sender, _spender, _value);
return true;
}
| function approve(address _spender, uint256 _value) public returns (bool success){
/*update allowance record*/
allowed[msg.sender][_spender] = _value;
/*broadcast approval*/
emit BroadcastApproval(msg.sender, _spender, _value);
return true;
}
| 9,341 |
4 | // Prevents a contract from calling itself, directly or indirectly.Calling a `nonReentrant` function from another `nonReentrant`function is not supported. It is possible to prevent this from happeningby making the `nonReentrant` function external, and making it call a`private` function that does the actual work. / | modifier nonReentrant() {
| modifier nonReentrant() {
| 29,966 |
117 | // Standard ERC-20 events Event - token transfer | event Transfer( address indexed from, address indexed to, uint value );
| event Transfer( address indexed from, address indexed to, uint value );
| 6,605 |
130 | // Upon adding a new asset to teh system, this needs to be called. | function setupAsset(address underlying, uint coinStandard, uint raised) external onlyAdmin {
assets[underlying].coinStandard = coinStandard;
assets[underlying].raised = raised;
}
| function setupAsset(address underlying, uint coinStandard, uint raised) external onlyAdmin {
assets[underlying].coinStandard = coinStandard;
assets[underlying].raised = raised;
}
| 20,599 |
5 | // Request[] public requests; | uint public approversCount;
| uint public approversCount;
| 19,113 |
56 | // Fallback function. Provides functionality for person to buy tokens./ | function() public payable {
buyTokens(msg.sender,msg.value);
}
| function() public payable {
buyTokens(msg.sender,msg.value);
}
| 15,371 |
9 | // module:core Version of the governor instance (used in building the ERC712 domain separator). Default: "1" / | function version() public view virtual returns (string memory);
| function version() public view virtual returns (string memory);
| 13,671 |
27 | // Auction/A contract to run a linear falling-price auction against a diverse/ basket of assets held in a collateral pool. Auctions are taken using/ a single asset. Over time, a larger and larger portion of the assets/ are on offer, eventually hitting 100% of the backing collateral/ pool. Auctions can be partially filled, and are meant to be amenable/ to flash loans and other atomic constructions to take advantage of/ arbitrage opportunities within a single block./ Auction contracts are not meant to be deployed directly, and are/ instead cloned by an auction factory. Auction contracts clean up and/ self-destruct on close. | contract Auction is IAuction {
using SafeERC20 for IERC20;
struct AuctionStorage {
IERC20 tokenAccepted;
Auctioneer auctioneer;
// the auction price, denominated in tokenAccepted
uint256 amountOutstanding;
uint256 amountDesired;
uint256 startTime;
uint256 startTimeOffset;
uint256 auctionLength;
}
AuctionStorage public self;
address public immutable masterContract;
/// @notice Throws if called by any account other than the auctioneer.
modifier onlyAuctioneer() {
//slither-disable-next-line incorrect-equality
require(
msg.sender == address(self.auctioneer),
"Caller is not the auctioneer"
);
_;
}
constructor() {
masterContract = address(this);
}
/// @notice Initializes auction
/// @dev At the beginning of an auction, velocity pool depleting rate is
/// always 1. It increases over time after a partial auction buy.
/// @param _auctioneer the auctioneer contract responsible for seizing
/// funds from the backing collateral pool
/// @param _tokenAccepted the token with which the auction can be taken
/// @param _amountDesired the amount denominated in _tokenAccepted. After
/// this amount is received, the auction can close.
/// @param _auctionLength the amount of time it takes for the auction to get
/// to 100% of all collateral on offer, in seconds.
function initialize(
Auctioneer _auctioneer,
IERC20 _tokenAccepted,
uint256 _amountDesired,
uint256 _auctionLength
) external {
require(!isMasterContract(), "Can not initialize master contract");
//slither-disable-next-line incorrect-equality
require(self.startTime == 0, "Auction already initialized");
require(_amountDesired > 0, "Amount desired must be greater than zero");
require(_auctionLength > 0, "Auction length must be greater than zero");
self.auctioneer = _auctioneer;
self.tokenAccepted = _tokenAccepted;
self.amountOutstanding = _amountDesired;
self.amountDesired = _amountDesired;
/* solhint-disable-next-line not-rely-on-time */
self.startTime = block.timestamp;
self.startTimeOffset = 0;
self.auctionLength = _auctionLength;
}
/// @notice Takes an offer from an auction buyer.
/// @dev There are two possible ways to take an offer from a buyer. The first
/// one is to buy entire auction with the amount desired for this auction.
/// The other way is to buy a portion of an auction. In this case an
/// auction depleting rate is increased.
/// WARNING: When calling this function directly, it might happen that
/// the expected amount of tokens to seize from the coverage pool is
/// different from the actual one. There are a couple of reasons for that
/// such another bids taking this offer, claims or withdrawals on an
/// Asset Pool that are executed in the same block. The recommended way
/// for taking an offer is through 'AuctionBidder' contract with
/// 'takeOfferWithMin' function, where a caller can specify the minimal
/// value to receive from the coverage pool in exchange for its amount
/// of tokenAccepted.
/// @param amount the amount the taker is paying, denominated in tokenAccepted.
/// In the scenario when amount exceeds the outstanding tokens
/// for the auction to complete, only the amount outstanding will
/// be taken from a caller.
function takeOffer(uint256 amount) external override {
require(amount > 0, "Can't pay 0 tokens");
uint256 amountToTransfer = Math.min(amount, self.amountOutstanding);
uint256 amountOnOffer = _onOffer();
//slither-disable-next-line reentrancy-no-eth
self.tokenAccepted.safeTransferFrom(
msg.sender,
address(self.auctioneer),
amountToTransfer
);
uint256 portionToSeize = (amountOnOffer * amountToTransfer) /
self.amountOutstanding;
if (!isAuctionOver() && amountToTransfer != self.amountOutstanding) {
// Time passed since the auction start or the last takeOffer call
// with a partial fill.
uint256 timePassed /* solhint-disable-next-line not-rely-on-time */
= block.timestamp - self.startTime - self.startTimeOffset;
// Ratio of the auction's amount included in this takeOffer call to
// the whole outstanding auction amount.
uint256 ratioAmountPaid = (CoveragePoolConstants
.FLOATING_POINT_DIVISOR * amountToTransfer) /
self.amountOutstanding;
// We will shift the start time offset and increase the velocity pool
// depleting rate proportionally to the fraction of the outstanding
// amount paid in this function call so that the auction can offer
// no worse financial outcome for the next takers than the current
// taker has.
//
//slither-disable-next-line divide-before-multiply
self.startTimeOffset =
self.startTimeOffset +
((timePassed * ratioAmountPaid) /
CoveragePoolConstants.FLOATING_POINT_DIVISOR);
}
self.amountOutstanding -= amountToTransfer;
//slither-disable-next-line incorrect-equality
bool isFullyFilled = self.amountOutstanding == 0;
// inform auctioneer of proceeds and winner. the auctioneer seizes funds
// from the collateral pool in the name of the winner, and controls all
// proceeds
//
//slither-disable-next-line reentrancy-no-eth
self.auctioneer.offerTaken(
msg.sender,
self.tokenAccepted,
amountToTransfer,
portionToSeize,
isFullyFilled
);
//slither-disable-next-line incorrect-equality
if (isFullyFilled) {
harikari();
}
}
/// @notice Tears down the auction manually, before its entire amount
/// is bought by takers.
/// @dev Can be called only by the auctioneer which may decide to early
// close the auction in case it is no longer needed.
function earlyClose() external onlyAuctioneer {
require(self.amountOutstanding > 0, "Auction must be open");
harikari();
}
/// @notice How much of the collateral pool can currently be purchased at
/// auction, across all assets.
/// @dev _onOffer() / FLOATING_POINT_DIVISOR) returns a portion of the
/// collateral pool. Ex. if 35% available of the collateral pool,
/// then _onOffer() / FLOATING_POINT_DIVISOR) returns 0.35
/// @return the ratio of the collateral pool currently on offer
function onOffer() external view override returns (uint256, uint256) {
return (_onOffer(), CoveragePoolConstants.FLOATING_POINT_DIVISOR);
}
function amountOutstanding() external view returns (uint256) {
return self.amountOutstanding;
}
function amountTransferred() external view returns (uint256) {
return self.amountDesired - self.amountOutstanding;
}
/// @dev Delete all storage and destroy the contract. Should only be called
/// after an auction has closed.
function harikari() internal {
require(!isMasterContract(), "Master contract can not harikari");
selfdestruct(payable(address(self.auctioneer)));
}
function _onOffer() internal view returns (uint256) {
// when the auction is over, entire pool is on offer
if (isAuctionOver()) {
// Down the road, for determining a portion on offer, a value returned
// by this function will be divided by FLOATING_POINT_DIVISOR. To
// return the entire pool, we need to return just this divisor in order
// to get 1.0 ie. FLOATING_POINT_DIVISOR / FLOATING_POINT_DIVISOR = 1.0
return CoveragePoolConstants.FLOATING_POINT_DIVISOR;
}
// How fast portions of the collateral pool become available on offer.
// It is needed to calculate the right portion value on offer at the
// given moment before the auction is over.
// Auction length once set is constant and what changes is the auction's
// "start time offset" once the takeOffer() call has been processed for
// partial fill. The auction's "start time offset" is updated every takeOffer().
// velocityPoolDepletingRate = auctionLength / (auctionLength - startTimeOffset)
// velocityPoolDepletingRate always starts at 1.0 and then can go up
// depending on partial offer calls over auction life span to maintain
// the right ratio between the remaining auction time and the remaining
// portion of the collateral pool.
//slither-disable-next-line divide-before-multiply
uint256 velocityPoolDepletingRate = (CoveragePoolConstants
.FLOATING_POINT_DIVISOR * self.auctionLength) /
(self.auctionLength - self.startTimeOffset);
return
/* solhint-disable-next-line not-rely-on-time */
((block.timestamp - (self.startTime + self.startTimeOffset)) *
velocityPoolDepletingRate) / self.auctionLength;
}
function isAuctionOver() internal view returns (bool) {
/* solhint-disable-next-line not-rely-on-time */
return block.timestamp >= self.startTime + self.auctionLength;
}
function isMasterContract() internal view returns (bool) {
return masterContract == address(this);
}
}
| contract Auction is IAuction {
using SafeERC20 for IERC20;
struct AuctionStorage {
IERC20 tokenAccepted;
Auctioneer auctioneer;
// the auction price, denominated in tokenAccepted
uint256 amountOutstanding;
uint256 amountDesired;
uint256 startTime;
uint256 startTimeOffset;
uint256 auctionLength;
}
AuctionStorage public self;
address public immutable masterContract;
/// @notice Throws if called by any account other than the auctioneer.
modifier onlyAuctioneer() {
//slither-disable-next-line incorrect-equality
require(
msg.sender == address(self.auctioneer),
"Caller is not the auctioneer"
);
_;
}
constructor() {
masterContract = address(this);
}
/// @notice Initializes auction
/// @dev At the beginning of an auction, velocity pool depleting rate is
/// always 1. It increases over time after a partial auction buy.
/// @param _auctioneer the auctioneer contract responsible for seizing
/// funds from the backing collateral pool
/// @param _tokenAccepted the token with which the auction can be taken
/// @param _amountDesired the amount denominated in _tokenAccepted. After
/// this amount is received, the auction can close.
/// @param _auctionLength the amount of time it takes for the auction to get
/// to 100% of all collateral on offer, in seconds.
function initialize(
Auctioneer _auctioneer,
IERC20 _tokenAccepted,
uint256 _amountDesired,
uint256 _auctionLength
) external {
require(!isMasterContract(), "Can not initialize master contract");
//slither-disable-next-line incorrect-equality
require(self.startTime == 0, "Auction already initialized");
require(_amountDesired > 0, "Amount desired must be greater than zero");
require(_auctionLength > 0, "Auction length must be greater than zero");
self.auctioneer = _auctioneer;
self.tokenAccepted = _tokenAccepted;
self.amountOutstanding = _amountDesired;
self.amountDesired = _amountDesired;
/* solhint-disable-next-line not-rely-on-time */
self.startTime = block.timestamp;
self.startTimeOffset = 0;
self.auctionLength = _auctionLength;
}
/// @notice Takes an offer from an auction buyer.
/// @dev There are two possible ways to take an offer from a buyer. The first
/// one is to buy entire auction with the amount desired for this auction.
/// The other way is to buy a portion of an auction. In this case an
/// auction depleting rate is increased.
/// WARNING: When calling this function directly, it might happen that
/// the expected amount of tokens to seize from the coverage pool is
/// different from the actual one. There are a couple of reasons for that
/// such another bids taking this offer, claims or withdrawals on an
/// Asset Pool that are executed in the same block. The recommended way
/// for taking an offer is through 'AuctionBidder' contract with
/// 'takeOfferWithMin' function, where a caller can specify the minimal
/// value to receive from the coverage pool in exchange for its amount
/// of tokenAccepted.
/// @param amount the amount the taker is paying, denominated in tokenAccepted.
/// In the scenario when amount exceeds the outstanding tokens
/// for the auction to complete, only the amount outstanding will
/// be taken from a caller.
function takeOffer(uint256 amount) external override {
require(amount > 0, "Can't pay 0 tokens");
uint256 amountToTransfer = Math.min(amount, self.amountOutstanding);
uint256 amountOnOffer = _onOffer();
//slither-disable-next-line reentrancy-no-eth
self.tokenAccepted.safeTransferFrom(
msg.sender,
address(self.auctioneer),
amountToTransfer
);
uint256 portionToSeize = (amountOnOffer * amountToTransfer) /
self.amountOutstanding;
if (!isAuctionOver() && amountToTransfer != self.amountOutstanding) {
// Time passed since the auction start or the last takeOffer call
// with a partial fill.
uint256 timePassed /* solhint-disable-next-line not-rely-on-time */
= block.timestamp - self.startTime - self.startTimeOffset;
// Ratio of the auction's amount included in this takeOffer call to
// the whole outstanding auction amount.
uint256 ratioAmountPaid = (CoveragePoolConstants
.FLOATING_POINT_DIVISOR * amountToTransfer) /
self.amountOutstanding;
// We will shift the start time offset and increase the velocity pool
// depleting rate proportionally to the fraction of the outstanding
// amount paid in this function call so that the auction can offer
// no worse financial outcome for the next takers than the current
// taker has.
//
//slither-disable-next-line divide-before-multiply
self.startTimeOffset =
self.startTimeOffset +
((timePassed * ratioAmountPaid) /
CoveragePoolConstants.FLOATING_POINT_DIVISOR);
}
self.amountOutstanding -= amountToTransfer;
//slither-disable-next-line incorrect-equality
bool isFullyFilled = self.amountOutstanding == 0;
// inform auctioneer of proceeds and winner. the auctioneer seizes funds
// from the collateral pool in the name of the winner, and controls all
// proceeds
//
//slither-disable-next-line reentrancy-no-eth
self.auctioneer.offerTaken(
msg.sender,
self.tokenAccepted,
amountToTransfer,
portionToSeize,
isFullyFilled
);
//slither-disable-next-line incorrect-equality
if (isFullyFilled) {
harikari();
}
}
/// @notice Tears down the auction manually, before its entire amount
/// is bought by takers.
/// @dev Can be called only by the auctioneer which may decide to early
// close the auction in case it is no longer needed.
function earlyClose() external onlyAuctioneer {
require(self.amountOutstanding > 0, "Auction must be open");
harikari();
}
/// @notice How much of the collateral pool can currently be purchased at
/// auction, across all assets.
/// @dev _onOffer() / FLOATING_POINT_DIVISOR) returns a portion of the
/// collateral pool. Ex. if 35% available of the collateral pool,
/// then _onOffer() / FLOATING_POINT_DIVISOR) returns 0.35
/// @return the ratio of the collateral pool currently on offer
function onOffer() external view override returns (uint256, uint256) {
return (_onOffer(), CoveragePoolConstants.FLOATING_POINT_DIVISOR);
}
function amountOutstanding() external view returns (uint256) {
return self.amountOutstanding;
}
function amountTransferred() external view returns (uint256) {
return self.amountDesired - self.amountOutstanding;
}
/// @dev Delete all storage and destroy the contract. Should only be called
/// after an auction has closed.
function harikari() internal {
require(!isMasterContract(), "Master contract can not harikari");
selfdestruct(payable(address(self.auctioneer)));
}
function _onOffer() internal view returns (uint256) {
// when the auction is over, entire pool is on offer
if (isAuctionOver()) {
// Down the road, for determining a portion on offer, a value returned
// by this function will be divided by FLOATING_POINT_DIVISOR. To
// return the entire pool, we need to return just this divisor in order
// to get 1.0 ie. FLOATING_POINT_DIVISOR / FLOATING_POINT_DIVISOR = 1.0
return CoveragePoolConstants.FLOATING_POINT_DIVISOR;
}
// How fast portions of the collateral pool become available on offer.
// It is needed to calculate the right portion value on offer at the
// given moment before the auction is over.
// Auction length once set is constant and what changes is the auction's
// "start time offset" once the takeOffer() call has been processed for
// partial fill. The auction's "start time offset" is updated every takeOffer().
// velocityPoolDepletingRate = auctionLength / (auctionLength - startTimeOffset)
// velocityPoolDepletingRate always starts at 1.0 and then can go up
// depending on partial offer calls over auction life span to maintain
// the right ratio between the remaining auction time and the remaining
// portion of the collateral pool.
//slither-disable-next-line divide-before-multiply
uint256 velocityPoolDepletingRate = (CoveragePoolConstants
.FLOATING_POINT_DIVISOR * self.auctionLength) /
(self.auctionLength - self.startTimeOffset);
return
/* solhint-disable-next-line not-rely-on-time */
((block.timestamp - (self.startTime + self.startTimeOffset)) *
velocityPoolDepletingRate) / self.auctionLength;
}
function isAuctionOver() internal view returns (bool) {
/* solhint-disable-next-line not-rely-on-time */
return block.timestamp >= self.startTime + self.auctionLength;
}
function isMasterContract() internal view returns (bool) {
return masterContract == address(this);
}
}
| 29,512 |
291 | // if block.timestamp > lastTouchedTime, update sumRewardPerLiquidity. Otherwise just return it/if block.timestamp > farm's endTime then update phase to settled/fId farm's id/ return curSumRewardPerLiquidity array of sumRewardPerLiquidity until now | function _updateFarmSumRewardPerLiquidity(
uint256 fId
| function _updateFarmSumRewardPerLiquidity(
uint256 fId
| 4,238 |
967 | // Since we use a circular buffer, the oldest sample is simply the next one. | uint256 bufferLength;
uint256 oldestIndex = latestIndex.next();
{
| uint256 bufferLength;
uint256 oldestIndex = latestIndex.next();
{
| 13,744 |
537 | // Initializes a reserve, activating it, assigning an aToken and debt tokens and aninterest rate strategy- Only callable by the LendingPoolConfigurator contract asset The address of the underlying asset of the reserve aTokenAddress The address of the aToken that will be assigned to the reserve stableDebtAddress The address of the StableDebtToken that will be assigned to the reserve aTokenAddress The address of the VariableDebtToken that will be assigned to the reserve interestRateStrategyAddress The address of the interest rate strategy contract / | ) external override onlyLendingPoolConfigurator {
require(Address.isContract(asset), Errors.LP_NOT_CONTRACT);
_reserves[asset].init(
aTokenAddress,
stableDebtAddress,
variableDebtAddress,
interestRateStrategyAddress
);
_addReserveToList(asset);
}
| ) external override onlyLendingPoolConfigurator {
require(Address.isContract(asset), Errors.LP_NOT_CONTRACT);
_reserves[asset].init(
aTokenAddress,
stableDebtAddress,
variableDebtAddress,
interestRateStrategyAddress
);
_addReserveToList(asset);
}
| 47,712 |
336 | // Encode custom data for callFunction | data
);
operations[2] = _getDepositAction(dyDxMarketId, amount.add(2));
Account.Info[] memory accountInfos = new Account.Info[](1);
accountInfos[0] = _getAccountInfo();
solo.operate(accountInfos, operations);
emit Leverage(amountDesired, amount, deficit, SOLO);
| data
);
operations[2] = _getDepositAction(dyDxMarketId, amount.add(2));
Account.Info[] memory accountInfos = new Account.Info[](1);
accountInfos[0] = _getAccountInfo();
solo.operate(accountInfos, operations);
emit Leverage(amountDesired, amount, deficit, SOLO);
| 38,201 |
276 | // 1.1. If _finalise, move everything to cooldown | if (_finalise) {
_balances[_account].raw = 0;
_balances[_account].cooldownUnits = SafeCastExtended.toUint88(totalRaw);
oldBalance.cooldownUnits = SafeCastExtended.toUint88(totalRaw);
}
| if (_finalise) {
_balances[_account].raw = 0;
_balances[_account].cooldownUnits = SafeCastExtended.toUint88(totalRaw);
oldBalance.cooldownUnits = SafeCastExtended.toUint88(totalRaw);
}
| 23,816 |
67 | // token freeze | event FundsFrozen(address target, bool frozen);
event AccountFrozenError();
| event FundsFrozen(address target, bool frozen);
event AccountFrozenError();
| 51,125 |
200 | // read 4 characters | dataPtr := add(dataPtr, 4)
let input := mload(dataPtr)
| dataPtr := add(dataPtr, 4)
let input := mload(dataPtr)
| 29,233 |
26 | // Transfer back unused tx value: | if (_usedFunds < msg.value) {
payable(msg.sender).transfer(msg.value - _usedFunds);
}
| if (_usedFunds < msg.value) {
payable(msg.sender).transfer(msg.value - _usedFunds);
}
| 41,949 |
15 | // variablePartAB[0] = challengeVariablePart variablePartAB[1] = refutationVariablePart | Signature memory refutationStateSig
| Signature memory refutationStateSig
| 11,734 |
38 | // Subtract the bought tokens from the pool and the eth from the pool | if (
block.timestamp >= tierOneStartTimestamp &&
block.timestamp < tierOneEndTimestamp
) {
tierOneEthAllocated -= msg.value;
tierOneTokensAllocated -= tokensBoughtThisTx;
| if (
block.timestamp >= tierOneStartTimestamp &&
block.timestamp < tierOneEndTimestamp
) {
tierOneEthAllocated -= msg.value;
tierOneTokensAllocated -= tokensBoughtThisTx;
| 25,758 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.