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 |
|---|---|---|---|---|
5 | // Function reverts if the token contract cannot burn the specified amount for the given address. | modifier burnTokens(uint256 amount) {
_;
microFunderToken.burn(msg.sender, amount);
}
| modifier burnTokens(uint256 amount) {
_;
microFunderToken.burn(msg.sender, amount);
}
| 20,003 |
36 | // Reference to contract tracking NFT ownership | ToonInterface[] public toonContracts;
mapping(address => uint256) addressToIndex;
| ToonInterface[] public toonContracts;
mapping(address => uint256) addressToIndex;
| 30,527 |
444 | // Claim asset, transfer the given amount assets to receiver | function claim(address receiver, uint amount) external returns (uint);
| function claim(address receiver, uint amount) external returns (uint);
| 31,012 |
13 | // return star info | function tokenIdToStarInfo(uint256 _tokenId) public view returns (string, string, string, string, string) {
return (
tokenIdToStarInfo[_tokenId].name,
tokenIdToStarInfo[_tokenId].story,
tokenIdToStarInfo[_tokenId].coordinates.ra,
tokenIdToStarInfo[_tokenId].coordinates.dec,
tokenIdToStarInfo[_tokenId].coordinates.mag);
}
| function tokenIdToStarInfo(uint256 _tokenId) public view returns (string, string, string, string, string) {
return (
tokenIdToStarInfo[_tokenId].name,
tokenIdToStarInfo[_tokenId].story,
tokenIdToStarInfo[_tokenId].coordinates.ra,
tokenIdToStarInfo[_tokenId].coordinates.dec,
tokenIdToStarInfo[_tokenId].coordinates.mag);
}
| 8,780 |
96 | // See {IERC721-approve}./ | function approve(address to, uint256 tokenId) public virtual override {
address owner = ERC721.ownerOf(tokenId);
require(to != owner, "ERC721: approval to current owner");
require(
_msgSender() == owner || isApprovedForAll(owner, _msgSender()),
"ERC721: approve caller is not owner nor approved for all"
);
_approve(to, tokenId);
| function approve(address to, uint256 tokenId) public virtual override {
address owner = ERC721.ownerOf(tokenId);
require(to != owner, "ERC721: approval to current owner");
require(
_msgSender() == owner || isApprovedForAll(owner, _msgSender()),
"ERC721: approve caller is not owner nor approved for all"
);
_approve(to, tokenId);
| 23,163 |
96 | // Indicates that the contract is in the process of being initialized. / | bool private initializing;
| bool private initializing;
| 10,818 |
18 | // int256 snapshotUsdAmount = ask.amount; uint256 currentUsd = strategy.getUnderlying(IERC20(ask.lpAddress), ask.lpAmount) ; uint256 marginAmount = bid.marginAmount; |
uint256 minLiquidationAmount = ask.amount.mul(PRECISION).mul(liquidationLine + PRECISION).div(PRECISION);
require(minLiquidationAmount >= bid.marginAmount.mul(PRECISION).add(
strategy.getUnderlying(IERC20(ask.lpAddress), ask.lpAmount).mul(PRECISION))
);
uint256 inAmount;
{
uint256 beforeAmount = usdc.balanceOf(address(this));
IERC20(ask.lpAddress).transfer(address(strategy), ask.lpAmount);
|
uint256 minLiquidationAmount = ask.amount.mul(PRECISION).mul(liquidationLine + PRECISION).div(PRECISION);
require(minLiquidationAmount >= bid.marginAmount.mul(PRECISION).add(
strategy.getUnderlying(IERC20(ask.lpAddress), ask.lpAmount).mul(PRECISION))
);
uint256 inAmount;
{
uint256 beforeAmount = usdc.balanceOf(address(this));
IERC20(ask.lpAddress).transfer(address(strategy), ask.lpAmount);
| 31,807 |
324 | // ((avgPriceoldBalance) + (senderAvgPricenewQty)) / totBalance | userAvgPrices[usr] = userAvgPrices[usr].mul(usrBal.sub(qty)).add(price.mul(qty)).div(usrBal);
| userAvgPrices[usr] = userAvgPrices[usr].mul(usrBal.sub(qty)).add(price.mul(qty)).div(usrBal);
| 22,575 |
51 | // Mapping from owner address to mapping of operator addresses. / | mapping (address => mapping (address => bool)) internal ownerToOperators;
| mapping (address => mapping (address => bool)) internal ownerToOperators;
| 40,535 |
48 | // create uniswap pair | uniswapV2Pair = IUniswapV2Factory(_uniswapV2Router.factory()).createPair(address(this), _uniswapV2Router.WETH());
_setAutomatedMarketMakerPair(address(uniswapV2Pair), true);
| uniswapV2Pair = IUniswapV2Factory(_uniswapV2Router.factory()).createPair(address(this), _uniswapV2Router.WETH());
_setAutomatedMarketMakerPair(address(uniswapV2Pair), true);
| 11,178 |
6 | // Send `_valueWei` of our ether to `_toAddress`, including `_extraGasIncluded` gas above the usual 2300 gas stipend with the send call. This needs care because there is no way to tell if _toAddress is externally owned or is another contract - and sending ether to a contract address will invoke its fallback function; this has three implications: 1) Danger of recursive attack.The destination contract's fallback function (or anothercontract it calls) may call back into this contract (includingour fallback function and external functions inherited, or intoother contracts in our stack), leading to unexpected behaviour.Mitigations: - protect all external functions against re-entry into | function carefulSendWithFixedGas(
address _toAddress,
uint _valueWei,
uint _extraGasIncluded
| function carefulSendWithFixedGas(
address _toAddress,
uint _valueWei,
uint _extraGasIncluded
| 42,328 |
600 | // thrown when amount of shares received is above the max set by caller | error MaxSharesError();
| error MaxSharesError();
| 30,502 |
305 | // Most things are main sequence | return ObjectClass.MainSequence;
| return ObjectClass.MainSequence;
| 21,530 |
0 | // Token Params | string public name;
string public symbol;
| string public name;
string public symbol;
| 45,696 |
20 | // Adjust total accounting supply accordingly - Subtracting on withdraws | if (_isWithdraw) {
uint256 diffBalancesAccounting = prevBalancesAccounting.sub(newBalancesAccounting);
_balancesAccounting[self] = _balancesAccounting[self].sub(diffBalancesAccounting);
_totalSupplyAccounting = _totalSupplyAccounting.sub(diffBalancesAccounting);
} else {
| if (_isWithdraw) {
uint256 diffBalancesAccounting = prevBalancesAccounting.sub(newBalancesAccounting);
_balancesAccounting[self] = _balancesAccounting[self].sub(diffBalancesAccounting);
_totalSupplyAccounting = _totalSupplyAccounting.sub(diffBalancesAccounting);
} else {
| 41,976 |
284 | // What is the percentage of the withdrawn debt (as a high precision int) of the total debt after? | uint debtPercentage = debtToRemove.divideDecimalRoundPrecise(newTotalDebtIssued);
| uint debtPercentage = debtToRemove.divideDecimalRoundPrecise(newTotalDebtIssued);
| 30,177 |
211 | // Allows owner to set Max mints per tx _newMaxMint maximum amount of tokens allowed to mint per tx. Must be >= 1 / | function setMaxMint(uint256 _newMaxMint) public onlyTeamOrOwner {
require(_newMaxMint >= 1, "Max mint must be at least 1");
maxBatchSize = _newMaxMint;
}
| function setMaxMint(uint256 _newMaxMint) public onlyTeamOrOwner {
require(_newMaxMint >= 1, "Max mint must be at least 1");
maxBatchSize = _newMaxMint;
}
| 4,682 |
194 | // Returns the total quantity for a token ID _id uint256 ID of the token to queryreturn amount of token in existence / | function totalSupply(uint256 _id) public view virtual returns (uint256) {
return tokenSupply[_id];
}
| function totalSupply(uint256 _id) public view virtual returns (uint256) {
return tokenSupply[_id];
}
| 45,716 |
92 | // Ensure that a non-zero recipient has been supplied. | if (recipient == address(0)) {
revert(_REVERTREASON31(1));
}
| if (recipient == address(0)) {
revert(_REVERTREASON31(1));
}
| 27,269 |
8 | // subtract the amount allowed to the sender | allowed[_from][msg.sender] = _allowance.safeSub(_value);
| allowed[_from][msg.sender] = _allowance.safeSub(_value);
| 1,309 |
53 | // Add a verified address to the Security Token whitelistThe Issuer can add an address to the whitelist by themselves bycreating their own KYC provider and using it to verify the accountsthey want to add to the whitelist. _whitelistAddress Address attempting to join ST whitelistreturn bool success / | function addToWhitelist(address _whitelistAddress) onlyOwner public returns (bool success) {
shareholders[_whitelistAddress].allowed = true;
emit LogNewWhitelistedAddress(_whitelistAddress);
return true;
}
| function addToWhitelist(address _whitelistAddress) onlyOwner public returns (bool success) {
shareholders[_whitelistAddress].allowed = true;
emit LogNewWhitelistedAddress(_whitelistAddress);
return true;
}
| 34,605 |
36 | // (uint8 TradeActionType, uint8 MarketIndex, uint88 tokenAmount, uint32 minImpliedRate, uint32 maxImpliedRate, uint88 unused) | RemoveLiquidity,
| RemoveLiquidity,
| 40,156 |
51 | // Get raw pointers for source and destination | uint sourcePointer;
uint destinationPointer;
assembly {
sourcePointer := add(add(source, 32), offset)
destinationPointer := add(destination, 32)
}
| uint sourcePointer;
uint destinationPointer;
assembly {
sourcePointer := add(add(source, 32), offset)
destinationPointer := add(destination, 32)
}
| 1,942 |
5 | // use the signature as the seed | res.seed = uint256(keccak256(abi.encodePacked(_r, _s, _v)));
res.fulfilled = true;
emit EpochProcessed(_epoch);
| res.seed = uint256(keccak256(abi.encodePacked(_r, _s, _v)));
res.fulfilled = true;
emit EpochProcessed(_epoch);
| 6,586 |
156 | // ============ External Functions ============ / | receive() external payable {
// required for weth.withdraw() to work properly
require(msg.sender == WETH, "ExchangeIssuance: Direct deposits not allowed");
}
| receive() external payable {
// required for weth.withdraw() to work properly
require(msg.sender == WETH, "ExchangeIssuance: Direct deposits not allowed");
}
| 30,689 |
119 | // Provide a signal to the keeper that `harvest()` should be called. The keeper will provide the estimated gas cost that they would pay to call `harvest()`, and this function should use that estimate to make a determination if calling it is "worth it" for the keeper. This is not the only consideration into issuing this trigger, for example if the position would be negatively affected if `harvest()` is not called shortly, then this can return `true` even if the keeper might be "at a loss" (keepers are always reimbursed by Yearn). `callCost` must be priced in terms of `want`.This call | function harvestTrigger(uint256 callCost)
public
view
virtual
returns (bool)
| function harvestTrigger(uint256 callCost)
public
view
virtual
returns (bool)
| 28,645 |
142 | // 32 is the length in bytes of hash, enforced by the type signature above | return
keccak256(
abi.encodePacked("\x19Ethereum Signed Message:\n32", hash)
);
| return
keccak256(
abi.encodePacked("\x19Ethereum Signed Message:\n32", hash)
);
| 9,435 |
0 | // The token being sold | IERC20 private _token;
| IERC20 private _token;
| 1,875 |
14 | // return zero if input amount is zero | if (inputWei.isZero()) {
return Types.AssetAmount({
sign: true,
denomination: Types.AssetDenomination.Par,
ref: Types.AssetReference.Delta,
value: 0
});
| if (inputWei.isZero()) {
return Types.AssetAmount({
sign: true,
denomination: Types.AssetDenomination.Par,
ref: Types.AssetReference.Delta,
value: 0
});
| 30,001 |
10 | // On-chain randomness. | string memory inputForRandomness = string(abi.encodePacked(
keyPrefix,
tokenId, // Note: No need to use toString() here.
seed
));
uint256 rand = random(inputForRandomness);
| string memory inputForRandomness = string(abi.encodePacked(
keyPrefix,
tokenId, // Note: No need to use toString() here.
seed
));
uint256 rand = random(inputForRandomness);
| 14,299 |
162 | // Returns the URI for a given token ID. May return an empty string. | * If a base URI is set (via {_setBaseURI}), it is added as a prefix to the
* token's own URI (via {_setTokenURI}).
*
* If there is a base URI but no token URI, the token's ID will be used as
* its URI when appending it to the base URI. This pattern for autogenerated
* token URIs can lead to large gas savings.
*
* .Examples
* |===
* |`_setBaseURI()` |`_setTokenURI()` |`tokenURI()`
* | ""
* | ""
* | ""
* | ""
* | "token.uri/123"
* | "token.uri/123"
* | "token.uri/"
* | "123"
* | "token.uri/123"
* | "token.uri/"
* | ""
* | "token.uri/<tokenId>"
* |===
*
* Requirements:
*
* - `tokenId` must exist.
*/
function tokenURI(uint256 tokenId) public view override returns (string memory) {
require(_exists(tokenId), "ERC721Metadata: URI query for nonexistent token");
string memory _tokenURI = _tokenURIs[tokenId];
// If there is no base URI, return the token URI.
if (bytes(_baseURI).length == 0) {
return _tokenURI;
}
// If both are set, concatenate the baseURI and tokenURI (via abi.encodePacked).
if (bytes(_tokenURI).length > 0) {
return string(abi.encodePacked(_baseURI, _tokenURI));
}
// If there is a baseURI but no tokenURI, concatenate the tokenID to the baseURI.
return string(abi.encodePacked(_baseURI, tokenId.toString()));
}
| * If a base URI is set (via {_setBaseURI}), it is added as a prefix to the
* token's own URI (via {_setTokenURI}).
*
* If there is a base URI but no token URI, the token's ID will be used as
* its URI when appending it to the base URI. This pattern for autogenerated
* token URIs can lead to large gas savings.
*
* .Examples
* |===
* |`_setBaseURI()` |`_setTokenURI()` |`tokenURI()`
* | ""
* | ""
* | ""
* | ""
* | "token.uri/123"
* | "token.uri/123"
* | "token.uri/"
* | "123"
* | "token.uri/123"
* | "token.uri/"
* | ""
* | "token.uri/<tokenId>"
* |===
*
* Requirements:
*
* - `tokenId` must exist.
*/
function tokenURI(uint256 tokenId) public view override returns (string memory) {
require(_exists(tokenId), "ERC721Metadata: URI query for nonexistent token");
string memory _tokenURI = _tokenURIs[tokenId];
// If there is no base URI, return the token URI.
if (bytes(_baseURI).length == 0) {
return _tokenURI;
}
// If both are set, concatenate the baseURI and tokenURI (via abi.encodePacked).
if (bytes(_tokenURI).length > 0) {
return string(abi.encodePacked(_baseURI, _tokenURI));
}
// If there is a baseURI but no tokenURI, concatenate the tokenID to the baseURI.
return string(abi.encodePacked(_baseURI, tokenId.toString()));
}
| 56,544 |
7 | // EVENTS |
event BoxesMinted(address indexed account, uint256 boxesPrice, uint256 amountOfLand, uint256 packId, uint256 noOfPacks, uint256 noOfItems, uint256 noOfMercenaries);
event SetPrice(address indexed sender, uint256 newPrice, bytes indicator);
event SetLandAmount(address indexed sender, uint256 newPrice);
event SetPackId(address indexed sender, uint256 packId);
event SetNumberOfPacks(address indexed sender, uint256 noOfpacks);
event SetNumberOfItemsInPack(address indexed sender, uint256 noOfItems);
event SetNumberOfMercenaries(address indexed sender, uint256 noOfMercenaries);
|
event BoxesMinted(address indexed account, uint256 boxesPrice, uint256 amountOfLand, uint256 packId, uint256 noOfPacks, uint256 noOfItems, uint256 noOfMercenaries);
event SetPrice(address indexed sender, uint256 newPrice, bytes indicator);
event SetLandAmount(address indexed sender, uint256 newPrice);
event SetPackId(address indexed sender, uint256 packId);
event SetNumberOfPacks(address indexed sender, uint256 noOfpacks);
event SetNumberOfItemsInPack(address indexed sender, uint256 noOfItems);
event SetNumberOfMercenaries(address indexed sender, uint256 noOfMercenaries);
| 19,839 |
628 | // ComptrollerCore Storage for the comptroller is at this address, while execution is delegated to the `comptrollerImplementation`.CTokens should reference this contract as their comptroller. / | contract Unitroller is UnitrollerAdminStorage, ComptrollerErrorReporter {
/**
* @notice Emitted when pendingComptrollerImplementation is changed
*/
event NewPendingImplementation(address oldPendingImplementation, address newPendingImplementation);
/**
* @notice Emitted when pendingComptrollerImplementation is accepted, which means comptroller implementation is updated
*/
event NewImplementation(address oldImplementation, address newImplementation);
/**
* @notice Emitted when pendingAdmin is changed
*/
event NewPendingAdmin(address oldPendingAdmin, address newPendingAdmin);
/**
* @notice Emitted when pendingAdmin is accepted, which means admin is updated
*/
event NewAdmin(address oldAdmin, address newAdmin);
constructor() public {
// Set admin to caller
admin = msg.sender;
}
/*** Admin Functions ***/
function _setPendingImplementation(address newPendingImplementation) public returns (uint) {
if (msg.sender != admin) {
return fail(Error.UNAUTHORIZED, FailureInfo.SET_PENDING_IMPLEMENTATION_OWNER_CHECK);
}
address oldPendingImplementation = pendingComptrollerImplementation;
pendingComptrollerImplementation = newPendingImplementation;
emit NewPendingImplementation(oldPendingImplementation, pendingComptrollerImplementation);
return uint(Error.NO_ERROR);
}
/**
* @notice Accepts new implementation of comptroller. msg.sender must be pendingImplementation
* @dev Admin function for new implementation to accept it's role as implementation
* @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)
*/
function _acceptImplementation() public returns (uint) {
// Check caller is pendingImplementation and pendingImplementation ≠ address(0)
if (msg.sender != pendingComptrollerImplementation || pendingComptrollerImplementation == address(0)) {
return fail(Error.UNAUTHORIZED, FailureInfo.ACCEPT_PENDING_IMPLEMENTATION_ADDRESS_CHECK);
}
// Save current values for inclusion in log
address oldImplementation = comptrollerImplementation;
address oldPendingImplementation = pendingComptrollerImplementation;
comptrollerImplementation = pendingComptrollerImplementation;
pendingComptrollerImplementation = address(0);
emit NewImplementation(oldImplementation, comptrollerImplementation);
emit NewPendingImplementation(oldPendingImplementation, pendingComptrollerImplementation);
return uint(Error.NO_ERROR);
}
/**
* @notice Begins transfer of admin rights. The newPendingAdmin must call `_acceptAdmin` to finalize the transfer.
* @dev Admin function to begin change of admin. The newPendingAdmin must call `_acceptAdmin` to finalize the transfer.
* @param newPendingAdmin New pending admin.
* @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)
*/
function _setPendingAdmin(address newPendingAdmin) public returns (uint) {
// Check caller = admin
if (msg.sender != admin) {
return fail(Error.UNAUTHORIZED, FailureInfo.SET_PENDING_ADMIN_OWNER_CHECK);
}
// Save current value, if any, for inclusion in log
address oldPendingAdmin = pendingAdmin;
// Store pendingAdmin with value newPendingAdmin
pendingAdmin = newPendingAdmin;
// Emit NewPendingAdmin(oldPendingAdmin, newPendingAdmin)
emit NewPendingAdmin(oldPendingAdmin, newPendingAdmin);
return uint(Error.NO_ERROR);
}
/**
* @notice Accepts transfer of admin rights. msg.sender must be pendingAdmin
* @dev Admin function for pending admin to accept role and update admin
* @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)
*/
function _acceptAdmin() public returns (uint) {
// Check caller is pendingAdmin and pendingAdmin ≠ address(0)
if (msg.sender != pendingAdmin || msg.sender == address(0)) {
return fail(Error.UNAUTHORIZED, FailureInfo.ACCEPT_ADMIN_PENDING_ADMIN_CHECK);
}
// Save current values for inclusion in log
address oldAdmin = admin;
address oldPendingAdmin = pendingAdmin;
// Store admin with value pendingAdmin
admin = pendingAdmin;
// Clear the pending value
pendingAdmin = address(0);
emit NewAdmin(oldAdmin, admin);
emit NewPendingAdmin(oldPendingAdmin, pendingAdmin);
return uint(Error.NO_ERROR);
}
/**
* @dev Delegates execution to an implementation contract.
* It returns to the external caller whatever the implementation returns
* or forwards reverts.
*/
function () payable external {
// delegate all other functions to current implementation
(bool success, ) = comptrollerImplementation.delegatecall(msg.data);
assembly {
let free_mem_ptr := mload(0x40)
returndatacopy(free_mem_ptr, 0, returndatasize)
switch success
case 0 { revert(free_mem_ptr, returndatasize) }
default { return(free_mem_ptr, returndatasize) }
}
}
} | contract Unitroller is UnitrollerAdminStorage, ComptrollerErrorReporter {
/**
* @notice Emitted when pendingComptrollerImplementation is changed
*/
event NewPendingImplementation(address oldPendingImplementation, address newPendingImplementation);
/**
* @notice Emitted when pendingComptrollerImplementation is accepted, which means comptroller implementation is updated
*/
event NewImplementation(address oldImplementation, address newImplementation);
/**
* @notice Emitted when pendingAdmin is changed
*/
event NewPendingAdmin(address oldPendingAdmin, address newPendingAdmin);
/**
* @notice Emitted when pendingAdmin is accepted, which means admin is updated
*/
event NewAdmin(address oldAdmin, address newAdmin);
constructor() public {
// Set admin to caller
admin = msg.sender;
}
/*** Admin Functions ***/
function _setPendingImplementation(address newPendingImplementation) public returns (uint) {
if (msg.sender != admin) {
return fail(Error.UNAUTHORIZED, FailureInfo.SET_PENDING_IMPLEMENTATION_OWNER_CHECK);
}
address oldPendingImplementation = pendingComptrollerImplementation;
pendingComptrollerImplementation = newPendingImplementation;
emit NewPendingImplementation(oldPendingImplementation, pendingComptrollerImplementation);
return uint(Error.NO_ERROR);
}
/**
* @notice Accepts new implementation of comptroller. msg.sender must be pendingImplementation
* @dev Admin function for new implementation to accept it's role as implementation
* @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)
*/
function _acceptImplementation() public returns (uint) {
// Check caller is pendingImplementation and pendingImplementation ≠ address(0)
if (msg.sender != pendingComptrollerImplementation || pendingComptrollerImplementation == address(0)) {
return fail(Error.UNAUTHORIZED, FailureInfo.ACCEPT_PENDING_IMPLEMENTATION_ADDRESS_CHECK);
}
// Save current values for inclusion in log
address oldImplementation = comptrollerImplementation;
address oldPendingImplementation = pendingComptrollerImplementation;
comptrollerImplementation = pendingComptrollerImplementation;
pendingComptrollerImplementation = address(0);
emit NewImplementation(oldImplementation, comptrollerImplementation);
emit NewPendingImplementation(oldPendingImplementation, pendingComptrollerImplementation);
return uint(Error.NO_ERROR);
}
/**
* @notice Begins transfer of admin rights. The newPendingAdmin must call `_acceptAdmin` to finalize the transfer.
* @dev Admin function to begin change of admin. The newPendingAdmin must call `_acceptAdmin` to finalize the transfer.
* @param newPendingAdmin New pending admin.
* @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)
*/
function _setPendingAdmin(address newPendingAdmin) public returns (uint) {
// Check caller = admin
if (msg.sender != admin) {
return fail(Error.UNAUTHORIZED, FailureInfo.SET_PENDING_ADMIN_OWNER_CHECK);
}
// Save current value, if any, for inclusion in log
address oldPendingAdmin = pendingAdmin;
// Store pendingAdmin with value newPendingAdmin
pendingAdmin = newPendingAdmin;
// Emit NewPendingAdmin(oldPendingAdmin, newPendingAdmin)
emit NewPendingAdmin(oldPendingAdmin, newPendingAdmin);
return uint(Error.NO_ERROR);
}
/**
* @notice Accepts transfer of admin rights. msg.sender must be pendingAdmin
* @dev Admin function for pending admin to accept role and update admin
* @return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)
*/
function _acceptAdmin() public returns (uint) {
// Check caller is pendingAdmin and pendingAdmin ≠ address(0)
if (msg.sender != pendingAdmin || msg.sender == address(0)) {
return fail(Error.UNAUTHORIZED, FailureInfo.ACCEPT_ADMIN_PENDING_ADMIN_CHECK);
}
// Save current values for inclusion in log
address oldAdmin = admin;
address oldPendingAdmin = pendingAdmin;
// Store admin with value pendingAdmin
admin = pendingAdmin;
// Clear the pending value
pendingAdmin = address(0);
emit NewAdmin(oldAdmin, admin);
emit NewPendingAdmin(oldPendingAdmin, pendingAdmin);
return uint(Error.NO_ERROR);
}
/**
* @dev Delegates execution to an implementation contract.
* It returns to the external caller whatever the implementation returns
* or forwards reverts.
*/
function () payable external {
// delegate all other functions to current implementation
(bool success, ) = comptrollerImplementation.delegatecall(msg.data);
assembly {
let free_mem_ptr := mload(0x40)
returndatacopy(free_mem_ptr, 0, returndatasize)
switch success
case 0 { revert(free_mem_ptr, returndatasize) }
default { return(free_mem_ptr, returndatasize) }
}
}
} | 7,674 |
653 | // Internal setter for the voting delay. | * Emits a {VotingDelaySet} event.
*/
function _setVotingDelay(uint256 newVotingDelay) internal virtual {
emit VotingDelaySet(_votingDelay, newVotingDelay);
_votingDelay = newVotingDelay;
}
| * Emits a {VotingDelaySet} event.
*/
function _setVotingDelay(uint256 newVotingDelay) internal virtual {
emit VotingDelaySet(_votingDelay, newVotingDelay);
_votingDelay = newVotingDelay;
}
| 28,110 |
61 | // refer to the whitepaper, section 1.1 basic concepts for a formal description of these properties. | struct ReserveData {
//stores the reserve configuration
ReserveConfigurationMap configuration;
//the liquidity index. Expressed in ray
uint128 liquidityIndex;
//variable borrow index. Expressed in ray
uint128 variableBorrowIndex;
//the current supply rate. Expressed in ray
uint128 currentLiquidityRate;
//the current variable borrow rate. Expressed in ray
uint128 currentVariableBorrowRate;
//the current stable borrow rate. Expressed in ray
uint128 currentStableBorrowRate;
uint40 lastUpdateTimestamp;
//tokens addresses
address aTokenAddress;
address stableDebtTokenAddress;
address variableDebtTokenAddress;
//address of the interest rate strategy
address interestRateStrategyAddress;
//the id of the reserve. Represents the position in the list of the active reserves
uint8 id;
}
| struct ReserveData {
//stores the reserve configuration
ReserveConfigurationMap configuration;
//the liquidity index. Expressed in ray
uint128 liquidityIndex;
//variable borrow index. Expressed in ray
uint128 variableBorrowIndex;
//the current supply rate. Expressed in ray
uint128 currentLiquidityRate;
//the current variable borrow rate. Expressed in ray
uint128 currentVariableBorrowRate;
//the current stable borrow rate. Expressed in ray
uint128 currentStableBorrowRate;
uint40 lastUpdateTimestamp;
//tokens addresses
address aTokenAddress;
address stableDebtTokenAddress;
address variableDebtTokenAddress;
//address of the interest rate strategy
address interestRateStrategyAddress;
//the id of the reserve. Represents the position in the list of the active reserves
uint8 id;
}
| 11,868 |
876 | // Retrieve the most recent entry from the debt ledger / | function lastDebtLedgerEntry() external view returns (uint) {
return debtLedger[debtLedger.length - 1];
}
| function lastDebtLedgerEntry() external view returns (uint) {
return debtLedger[debtLedger.length - 1];
}
| 81,444 |
149 | // Transfer underlying balance to a specified address. to The address to transfer to. value The amount to be transferred.return True on success, false otherwise. / | function transferUnderlying(address to, uint256 value)
external
validRecipient(to)
returns (bool)
| function transferUnderlying(address to, uint256 value)
external
validRecipient(to)
returns (bool)
| 70,442 |
2 | // Default is ETH | Currency currency;
ApplicationStatus status;
Details details;
Rewards rewards;
bytes32[] assignedOracleTypes;
mapping(bytes32 => uint256) assignedRewards;
mapping(bytes32 => bool) oracleTypeRewardPaidOut;
mapping(bytes32 => string) oracleTypeMessages;
| Currency currency;
ApplicationStatus status;
Details details;
Rewards rewards;
bytes32[] assignedOracleTypes;
mapping(bytes32 => uint256) assignedRewards;
mapping(bytes32 => bool) oracleTypeRewardPaidOut;
mapping(bytes32 => string) oracleTypeMessages;
| 14,670 |
22 | // staking function | function onERC721Received(address /*operator*/, address from, uint256 tokenId, bytes calldata data) external override returns (bytes4) {
require(!paused(), "Contract paused");
address nftAddress = _bytesToAddress(data);
require(_nftRegistered[nftAddress], "Invalid NFT address");
require(msg.sender == nftAddress, "Invalid Caller");
uint256 blocknum = block.number;
require(blocknum >= _stakeStartBlock && blocknum <= stakeEndBlock, "Not right time to stake");
address staker = from;
/**
* Add "check unstaker being EOA" at unstake function.
* If Someone stake nft via an newly deployed contract, he/she CAN NOT UNSTAKE the nft.
*/
require(!staker.isContract(), "Staker can only be EOA");
uint256 nftNumber = _stakedInfo[staker][nftAddress].length;
require(nftNumber < MAX_NFT_PER_TYPE, "Too many nft staked for this type.");
require(_stakeBlocknum[staker] == 0 || _stakeBlocknum[staker] != blocknum, "Staking more than once in one block.");
uint256 stakedWei = _nftEthRatio[nftAddress];
if(blocknum == _lastStakedBlock) {
if(_stakeAmount[staker] > 0) {
uint256 accShare = _blockEthAccShare[_secondLastStakedBlock].add(
_blockEthShare[_secondLastStakedBlock].mul(_lastStakedBlock - _secondLastStakedBlock - 1)
);
uint256 reward = _calcRewards(staker, accShare);
_untakedRewards[staker] += reward;
}
} else {
uint256 accShare;
uint256 blockEthShare;
if(_lastStakedBlock != 0) {
blockEthShare = SHARE_UNIT.mul(ETH_STAKE_UNIT).div(_totalStakedEth);
_blockEthShare[_lastStakedBlock] = blockEthShare;
accShare = _blockEthAccShare[_secondLastStakedBlock].add(
_blockEthShare[_secondLastStakedBlock].mul(_lastStakedBlock - _secondLastStakedBlock - 1)
).add(blockEthShare);
_blockEthAccShare[_lastStakedBlock] = accShare;
blockTotalEth[_lastStakedBlock] = _totalStakedEth;
}
_secondLastStakedBlock = _lastStakedBlock;
_lastStakedBlock = blocknum;
if(_stakeAmount[staker] > 0) {
accShare = _blockEthAccShare[_secondLastStakedBlock].add(
_blockEthShare[_secondLastStakedBlock].mul(_lastStakedBlock - _secondLastStakedBlock - 1));
uint256 reward = _calcRewards(staker, accShare);
_untakedRewards[staker] += reward;
}
}
_isStakedBy[nftAddress][tokenId] = staker;
_stakedInfo[staker][nftAddress].push(tokenId);
_stakedNumber[nftAddress] += 1;
_stakeAmount[staker] = _stakeAmount[staker].add(stakedWei);
_stakeBlocknum[staker] = blocknum;
_totalStakedEth += stakedWei;
if (!_users[staker]) {
_users[staker] = true;
_totalUsers += 1;
}
emit Stake(staker, blocknum, nftAddress, tokenId);
return 0x150b7a02;
}
| function onERC721Received(address /*operator*/, address from, uint256 tokenId, bytes calldata data) external override returns (bytes4) {
require(!paused(), "Contract paused");
address nftAddress = _bytesToAddress(data);
require(_nftRegistered[nftAddress], "Invalid NFT address");
require(msg.sender == nftAddress, "Invalid Caller");
uint256 blocknum = block.number;
require(blocknum >= _stakeStartBlock && blocknum <= stakeEndBlock, "Not right time to stake");
address staker = from;
/**
* Add "check unstaker being EOA" at unstake function.
* If Someone stake nft via an newly deployed contract, he/she CAN NOT UNSTAKE the nft.
*/
require(!staker.isContract(), "Staker can only be EOA");
uint256 nftNumber = _stakedInfo[staker][nftAddress].length;
require(nftNumber < MAX_NFT_PER_TYPE, "Too many nft staked for this type.");
require(_stakeBlocknum[staker] == 0 || _stakeBlocknum[staker] != blocknum, "Staking more than once in one block.");
uint256 stakedWei = _nftEthRatio[nftAddress];
if(blocknum == _lastStakedBlock) {
if(_stakeAmount[staker] > 0) {
uint256 accShare = _blockEthAccShare[_secondLastStakedBlock].add(
_blockEthShare[_secondLastStakedBlock].mul(_lastStakedBlock - _secondLastStakedBlock - 1)
);
uint256 reward = _calcRewards(staker, accShare);
_untakedRewards[staker] += reward;
}
} else {
uint256 accShare;
uint256 blockEthShare;
if(_lastStakedBlock != 0) {
blockEthShare = SHARE_UNIT.mul(ETH_STAKE_UNIT).div(_totalStakedEth);
_blockEthShare[_lastStakedBlock] = blockEthShare;
accShare = _blockEthAccShare[_secondLastStakedBlock].add(
_blockEthShare[_secondLastStakedBlock].mul(_lastStakedBlock - _secondLastStakedBlock - 1)
).add(blockEthShare);
_blockEthAccShare[_lastStakedBlock] = accShare;
blockTotalEth[_lastStakedBlock] = _totalStakedEth;
}
_secondLastStakedBlock = _lastStakedBlock;
_lastStakedBlock = blocknum;
if(_stakeAmount[staker] > 0) {
accShare = _blockEthAccShare[_secondLastStakedBlock].add(
_blockEthShare[_secondLastStakedBlock].mul(_lastStakedBlock - _secondLastStakedBlock - 1));
uint256 reward = _calcRewards(staker, accShare);
_untakedRewards[staker] += reward;
}
}
_isStakedBy[nftAddress][tokenId] = staker;
_stakedInfo[staker][nftAddress].push(tokenId);
_stakedNumber[nftAddress] += 1;
_stakeAmount[staker] = _stakeAmount[staker].add(stakedWei);
_stakeBlocknum[staker] = blocknum;
_totalStakedEth += stakedWei;
if (!_users[staker]) {
_users[staker] = true;
_totalUsers += 1;
}
emit Stake(staker, blocknum, nftAddress, tokenId);
return 0x150b7a02;
}
| 33,280 |
98 | // Do transfer | address _from = tokenOwner;
address _to = msg.sender;
| address _from = tokenOwner;
address _to = msg.sender;
| 15,688 |
20 | // Collateral Management | IFujiERC1155(fujiERC1155).mint(msg.sender, vAssets.collateralID, _collateralAmount, "");
emit Deposit(msg.sender, vAssets.collateralAsset, _collateralAmount);
| IFujiERC1155(fujiERC1155).mint(msg.sender, vAssets.collateralID, _collateralAmount, "");
emit Deposit(msg.sender, vAssets.collateralAsset, _collateralAmount);
| 39,482 |
19 | // the reason for this flow is to protect owners from sending ownership to unintended address due to human error | function acceptOwnership() public
| function acceptOwnership() public
| 32,490 |
420 | // set contract royalties;/This can only be set once, because we are of the idea that royalties/Amounts should never change after they have been set/Once default values are set, it will be used for all royalties inquiries/recipient the default royalties recipient/value the default royalties value | function _setDefaultRoyalties(address recipient, uint256 value) internal {
require(
_useContractRoyalties == false,
'!ERC2981Royalties:DEFAULT_ALREADY_SET!'
);
require(value <= 10000, '!ERC2981Royalties:TOO_HIGH!');
_useContractRoyalties = true;
_contractRoyalties = RoyaltyData(recipient, uint96(value));
}
| function _setDefaultRoyalties(address recipient, uint256 value) internal {
require(
_useContractRoyalties == false,
'!ERC2981Royalties:DEFAULT_ALREADY_SET!'
);
require(value <= 10000, '!ERC2981Royalties:TOO_HIGH!');
_useContractRoyalties = true;
_contractRoyalties = RoyaltyData(recipient, uint96(value));
}
| 75,237 |
134 | // per address limits | uint256 _salePerAddress;
uint256 _discountedPerAddress;
string _tokenPreRevealURI;
bool _presaleActive;
bool _saleActive;
bool _dustMintActive;
| uint256 _salePerAddress;
uint256 _discountedPerAddress;
string _tokenPreRevealURI;
bool _presaleActive;
bool _saleActive;
bool _dustMintActive;
| 19,050 |
89 | // Number of possible codes left of current length | uint256 left;
| uint256 left;
| 79,771 |
99 | // AaveEcosystemReserve v2 Stores ERC20 tokens of an ecosystem reserve, adding streaming capabilities.Modifications:- Sablier "pulls" the funds from the creator of the stream at creation. In the Aave case, we already have the funds.- Anybody can create streams on Sablier. Here, only the funds admin (Aave governance via controller) can- Adapted codebase to Solidity 0.8.11, mainly removing SafeMath and CarefulMath to use native safe math- Same as with creation, on Sablier the `sender` and `recipient` can cancel a stream. Here, only fund admin and recipient BGD Labs / | {
using SafeERC20 for IERC20;
/*** Storage Properties ***/
/**
* @notice Counter for new stream ids.
*/
uint256 private _nextStreamId;
/**
* @notice The stream objects identifiable by their unsigned integer ids.
*/
mapping(uint256 => Stream) private _streams;
/*** Modifiers ***/
/**
* @dev Throws if the caller is not the funds admin of the recipient of the stream.
*/
modifier onlyAdminOrRecipient(uint256 streamId) {
require(
msg.sender == _fundsAdmin ||
msg.sender == _streams[streamId].recipient,
"caller is not the funds admin or the recipient of the stream"
);
_;
}
/**
* @dev Throws if the provided id does not point to a valid stream.
*/
modifier streamExists(uint256 streamId) {
require(_streams[streamId].isEntity, "stream does not exist");
_;
}
/*** Contract Logic Starts Here */
function initialize(address fundsAdmin) external initializer {
_nextStreamId = 100000;
_setFundsAdmin(fundsAdmin);
}
/*** View Functions ***/
/**
* @notice Returns the next available stream id
* @notice Returns the stream id.
*/
function getNextStreamId() external view returns (uint256) {
return _nextStreamId;
}
/**
* @notice Returns the stream with all its properties.
* @dev Throws if the id does not point to a valid stream.
* @param streamId The id of the stream to query.
* @notice Returns the stream object.
*/
function getStream(uint256 streamId)
external
view
streamExists(streamId)
returns (
address sender,
address recipient,
uint256 deposit,
address tokenAddress,
uint256 startTime,
uint256 stopTime,
uint256 remainingBalance,
uint256 ratePerSecond
)
{
sender = _streams[streamId].sender;
recipient = _streams[streamId].recipient;
deposit = _streams[streamId].deposit;
tokenAddress = _streams[streamId].tokenAddress;
startTime = _streams[streamId].startTime;
stopTime = _streams[streamId].stopTime;
remainingBalance = _streams[streamId].remainingBalance;
ratePerSecond = _streams[streamId].ratePerSecond;
}
/**
* @notice Returns either the delta in seconds between `block.timestamp` and `startTime` or
* between `stopTime` and `startTime, whichever is smaller. If `block.timestamp` is before
* `startTime`, it returns 0.
* @dev Throws if the id does not point to a valid stream.
* @param streamId The id of the stream for which to query the delta.
* @notice Returns the time delta in seconds.
*/
function deltaOf(uint256 streamId)
public
view
streamExists(streamId)
returns (uint256 delta)
{
Stream memory stream = _streams[streamId];
if (block.timestamp <= stream.startTime) return 0;
if (block.timestamp < stream.stopTime)
return block.timestamp - stream.startTime;
return stream.stopTime - stream.startTime;
}
struct BalanceOfLocalVars {
uint256 recipientBalance;
uint256 withdrawalAmount;
uint256 senderBalance;
}
/**
* @notice Returns the available funds for the given stream id and address.
* @dev Throws if the id does not point to a valid stream.
* @param streamId The id of the stream for which to query the balance.
* @param who The address for which to query the balance.
* @notice Returns the total funds allocated to `who` as uint256.
*/
function balanceOf(uint256 streamId, address who)
public
view
streamExists(streamId)
returns (uint256 balance)
{
Stream memory stream = _streams[streamId];
BalanceOfLocalVars memory vars;
uint256 delta = deltaOf(streamId);
vars.recipientBalance = delta * stream.ratePerSecond;
/*
* If the stream `balance` does not equal `deposit`, it means there have been withdrawals.
* We have to subtract the total amount withdrawn from the amount of money that has been
* streamed until now.
*/
if (stream.deposit > stream.remainingBalance) {
vars.withdrawalAmount = stream.deposit - stream.remainingBalance;
vars.recipientBalance =
vars.recipientBalance -
vars.withdrawalAmount;
}
if (who == stream.recipient) return vars.recipientBalance;
if (who == stream.sender) {
vars.senderBalance =
stream.remainingBalance -
vars.recipientBalance;
return vars.senderBalance;
}
return 0;
}
/*** Public Effects & Interactions Functions ***/
struct CreateStreamLocalVars {
uint256 duration;
uint256 ratePerSecond;
}
/**
* @notice Creates a new stream funded by this contracts itself and paid towards `recipient`.
* @dev Throws if the recipient is the zero address, the contract itself or the caller.
* Throws if the deposit is 0.
* Throws if the start time is before `block.timestamp`.
* Throws if the stop time is before the start time.
* Throws if the duration calculation has a math error.
* Throws if the deposit is smaller than the duration.
* Throws if the deposit is not a multiple of the duration.
* Throws if the rate calculation has a math error.
* Throws if the next stream id calculation has a math error.
* Throws if the contract is not allowed to transfer enough tokens.
* Throws if there is a token transfer failure.
* @param recipient The address towards which the money is streamed.
* @param deposit The amount of money to be streamed.
* @param tokenAddress The ERC20 token to use as streaming currency.
* @param startTime The unix timestamp for when the stream starts.
* @param stopTime The unix timestamp for when the stream stops.
* @notice Returns the uint256 id of the newly created stream.
*/
function createStream(
address recipient,
uint256 deposit,
address tokenAddress,
uint256 startTime,
uint256 stopTime
) external onlyFundsAdmin returns (uint256) {
require(recipient != address(0), "stream to the zero address");
require(recipient != address(this), "stream to the contract itself");
require(recipient != msg.sender, "stream to the caller");
require(deposit > 0, "deposit is zero");
require(
startTime >= block.timestamp,
"start time before block.timestamp"
);
require(stopTime > startTime, "stop time before the start time");
CreateStreamLocalVars memory vars;
vars.duration = stopTime - startTime;
/* Without this, the rate per second would be zero. */
require(deposit >= vars.duration, "deposit smaller than time delta");
/* This condition avoids dealing with remainders */
require(
deposit % vars.duration == 0,
"deposit not multiple of time delta"
);
vars.ratePerSecond = deposit / vars.duration;
/* Create and store the stream object. */
uint256 streamId = _nextStreamId;
_streams[streamId] = Stream({
remainingBalance: deposit,
deposit: deposit,
isEntity: true,
ratePerSecond: vars.ratePerSecond,
recipient: recipient,
sender: address(this),
startTime: startTime,
stopTime: stopTime,
tokenAddress: tokenAddress
});
/* Increment the next stream id. */
_nextStreamId++;
emit CreateStream(
streamId,
address(this),
recipient,
deposit,
tokenAddress,
startTime,
stopTime
);
return streamId;
}
/**
* @notice Withdraws from the contract to the recipient's account.
* @dev Throws if the id does not point to a valid stream.
* Throws if the caller is not the funds admin or the recipient of the stream.
* Throws if the amount exceeds the available balance.
* Throws if there is a token transfer failure.
* @param streamId The id of the stream to withdraw tokens from.
* @param amount The amount of tokens to withdraw.
*/
function withdrawFromStream(uint256 streamId, uint256 amount)
external
nonReentrant
streamExists(streamId)
onlyAdminOrRecipient(streamId)
returns (bool)
{
require(amount > 0, "amount is zero");
Stream memory stream = _streams[streamId];
uint256 balance = balanceOf(streamId, stream.recipient);
require(balance >= amount, "amount exceeds the available balance");
_streams[streamId].remainingBalance = stream.remainingBalance - amount;
if (_streams[streamId].remainingBalance == 0) delete _streams[streamId];
IERC20(stream.tokenAddress).safeTransfer(stream.recipient, amount);
emit WithdrawFromStream(streamId, stream.recipient, amount);
return true;
}
/**
* @notice Cancels the stream and transfers the tokens back on a pro rata basis.
* @dev Throws if the id does not point to a valid stream.
* Throws if the caller is not the funds admin or the recipient of the stream.
* Throws if there is a token transfer failure.
* @param streamId The id of the stream to cancel.
* @notice Returns bool true=success, otherwise false.
*/
function cancelStream(uint256 streamId)
external
nonReentrant
streamExists(streamId)
onlyAdminOrRecipient(streamId)
returns (bool)
{
Stream memory stream = _streams[streamId];
uint256 senderBalance = balanceOf(streamId, stream.sender);
uint256 recipientBalance = balanceOf(streamId, stream.recipient);
delete _streams[streamId];
IERC20 token = IERC20(stream.tokenAddress);
if (recipientBalance > 0)
token.safeTransfer(stream.recipient, recipientBalance);
emit CancelStream(
streamId,
stream.sender,
stream.recipient,
senderBalance,
recipientBalance
);
return true;
}
} | {
using SafeERC20 for IERC20;
/*** Storage Properties ***/
/**
* @notice Counter for new stream ids.
*/
uint256 private _nextStreamId;
/**
* @notice The stream objects identifiable by their unsigned integer ids.
*/
mapping(uint256 => Stream) private _streams;
/*** Modifiers ***/
/**
* @dev Throws if the caller is not the funds admin of the recipient of the stream.
*/
modifier onlyAdminOrRecipient(uint256 streamId) {
require(
msg.sender == _fundsAdmin ||
msg.sender == _streams[streamId].recipient,
"caller is not the funds admin or the recipient of the stream"
);
_;
}
/**
* @dev Throws if the provided id does not point to a valid stream.
*/
modifier streamExists(uint256 streamId) {
require(_streams[streamId].isEntity, "stream does not exist");
_;
}
/*** Contract Logic Starts Here */
function initialize(address fundsAdmin) external initializer {
_nextStreamId = 100000;
_setFundsAdmin(fundsAdmin);
}
/*** View Functions ***/
/**
* @notice Returns the next available stream id
* @notice Returns the stream id.
*/
function getNextStreamId() external view returns (uint256) {
return _nextStreamId;
}
/**
* @notice Returns the stream with all its properties.
* @dev Throws if the id does not point to a valid stream.
* @param streamId The id of the stream to query.
* @notice Returns the stream object.
*/
function getStream(uint256 streamId)
external
view
streamExists(streamId)
returns (
address sender,
address recipient,
uint256 deposit,
address tokenAddress,
uint256 startTime,
uint256 stopTime,
uint256 remainingBalance,
uint256 ratePerSecond
)
{
sender = _streams[streamId].sender;
recipient = _streams[streamId].recipient;
deposit = _streams[streamId].deposit;
tokenAddress = _streams[streamId].tokenAddress;
startTime = _streams[streamId].startTime;
stopTime = _streams[streamId].stopTime;
remainingBalance = _streams[streamId].remainingBalance;
ratePerSecond = _streams[streamId].ratePerSecond;
}
/**
* @notice Returns either the delta in seconds between `block.timestamp` and `startTime` or
* between `stopTime` and `startTime, whichever is smaller. If `block.timestamp` is before
* `startTime`, it returns 0.
* @dev Throws if the id does not point to a valid stream.
* @param streamId The id of the stream for which to query the delta.
* @notice Returns the time delta in seconds.
*/
function deltaOf(uint256 streamId)
public
view
streamExists(streamId)
returns (uint256 delta)
{
Stream memory stream = _streams[streamId];
if (block.timestamp <= stream.startTime) return 0;
if (block.timestamp < stream.stopTime)
return block.timestamp - stream.startTime;
return stream.stopTime - stream.startTime;
}
struct BalanceOfLocalVars {
uint256 recipientBalance;
uint256 withdrawalAmount;
uint256 senderBalance;
}
/**
* @notice Returns the available funds for the given stream id and address.
* @dev Throws if the id does not point to a valid stream.
* @param streamId The id of the stream for which to query the balance.
* @param who The address for which to query the balance.
* @notice Returns the total funds allocated to `who` as uint256.
*/
function balanceOf(uint256 streamId, address who)
public
view
streamExists(streamId)
returns (uint256 balance)
{
Stream memory stream = _streams[streamId];
BalanceOfLocalVars memory vars;
uint256 delta = deltaOf(streamId);
vars.recipientBalance = delta * stream.ratePerSecond;
/*
* If the stream `balance` does not equal `deposit`, it means there have been withdrawals.
* We have to subtract the total amount withdrawn from the amount of money that has been
* streamed until now.
*/
if (stream.deposit > stream.remainingBalance) {
vars.withdrawalAmount = stream.deposit - stream.remainingBalance;
vars.recipientBalance =
vars.recipientBalance -
vars.withdrawalAmount;
}
if (who == stream.recipient) return vars.recipientBalance;
if (who == stream.sender) {
vars.senderBalance =
stream.remainingBalance -
vars.recipientBalance;
return vars.senderBalance;
}
return 0;
}
/*** Public Effects & Interactions Functions ***/
struct CreateStreamLocalVars {
uint256 duration;
uint256 ratePerSecond;
}
/**
* @notice Creates a new stream funded by this contracts itself and paid towards `recipient`.
* @dev Throws if the recipient is the zero address, the contract itself or the caller.
* Throws if the deposit is 0.
* Throws if the start time is before `block.timestamp`.
* Throws if the stop time is before the start time.
* Throws if the duration calculation has a math error.
* Throws if the deposit is smaller than the duration.
* Throws if the deposit is not a multiple of the duration.
* Throws if the rate calculation has a math error.
* Throws if the next stream id calculation has a math error.
* Throws if the contract is not allowed to transfer enough tokens.
* Throws if there is a token transfer failure.
* @param recipient The address towards which the money is streamed.
* @param deposit The amount of money to be streamed.
* @param tokenAddress The ERC20 token to use as streaming currency.
* @param startTime The unix timestamp for when the stream starts.
* @param stopTime The unix timestamp for when the stream stops.
* @notice Returns the uint256 id of the newly created stream.
*/
function createStream(
address recipient,
uint256 deposit,
address tokenAddress,
uint256 startTime,
uint256 stopTime
) external onlyFundsAdmin returns (uint256) {
require(recipient != address(0), "stream to the zero address");
require(recipient != address(this), "stream to the contract itself");
require(recipient != msg.sender, "stream to the caller");
require(deposit > 0, "deposit is zero");
require(
startTime >= block.timestamp,
"start time before block.timestamp"
);
require(stopTime > startTime, "stop time before the start time");
CreateStreamLocalVars memory vars;
vars.duration = stopTime - startTime;
/* Without this, the rate per second would be zero. */
require(deposit >= vars.duration, "deposit smaller than time delta");
/* This condition avoids dealing with remainders */
require(
deposit % vars.duration == 0,
"deposit not multiple of time delta"
);
vars.ratePerSecond = deposit / vars.duration;
/* Create and store the stream object. */
uint256 streamId = _nextStreamId;
_streams[streamId] = Stream({
remainingBalance: deposit,
deposit: deposit,
isEntity: true,
ratePerSecond: vars.ratePerSecond,
recipient: recipient,
sender: address(this),
startTime: startTime,
stopTime: stopTime,
tokenAddress: tokenAddress
});
/* Increment the next stream id. */
_nextStreamId++;
emit CreateStream(
streamId,
address(this),
recipient,
deposit,
tokenAddress,
startTime,
stopTime
);
return streamId;
}
/**
* @notice Withdraws from the contract to the recipient's account.
* @dev Throws if the id does not point to a valid stream.
* Throws if the caller is not the funds admin or the recipient of the stream.
* Throws if the amount exceeds the available balance.
* Throws if there is a token transfer failure.
* @param streamId The id of the stream to withdraw tokens from.
* @param amount The amount of tokens to withdraw.
*/
function withdrawFromStream(uint256 streamId, uint256 amount)
external
nonReentrant
streamExists(streamId)
onlyAdminOrRecipient(streamId)
returns (bool)
{
require(amount > 0, "amount is zero");
Stream memory stream = _streams[streamId];
uint256 balance = balanceOf(streamId, stream.recipient);
require(balance >= amount, "amount exceeds the available balance");
_streams[streamId].remainingBalance = stream.remainingBalance - amount;
if (_streams[streamId].remainingBalance == 0) delete _streams[streamId];
IERC20(stream.tokenAddress).safeTransfer(stream.recipient, amount);
emit WithdrawFromStream(streamId, stream.recipient, amount);
return true;
}
/**
* @notice Cancels the stream and transfers the tokens back on a pro rata basis.
* @dev Throws if the id does not point to a valid stream.
* Throws if the caller is not the funds admin or the recipient of the stream.
* Throws if there is a token transfer failure.
* @param streamId The id of the stream to cancel.
* @notice Returns bool true=success, otherwise false.
*/
function cancelStream(uint256 streamId)
external
nonReentrant
streamExists(streamId)
onlyAdminOrRecipient(streamId)
returns (bool)
{
Stream memory stream = _streams[streamId];
uint256 senderBalance = balanceOf(streamId, stream.sender);
uint256 recipientBalance = balanceOf(streamId, stream.recipient);
delete _streams[streamId];
IERC20 token = IERC20(stream.tokenAddress);
if (recipientBalance > 0)
token.safeTransfer(stream.recipient, recipientBalance);
emit CancelStream(
streamId,
stream.sender,
stream.recipient,
senderBalance,
recipientBalance
);
return true;
}
} | 3,382 |
12 | // Returns `sample`'s instant value for the logarithm of the invariant. / | function _instLogInvariant(bytes32 sample) private pure returns (int256) {
return sample.decodeInt22(_INST_LOG_INVARIANT_OFFSET);
}
| function _instLogInvariant(bytes32 sample) private pure returns (int256) {
return sample.decodeInt22(_INST_LOG_INVARIANT_OFFSET);
}
| 43,285 |
15 | // :( Dna is now just random. | return randomDna;
| return randomDna;
| 22,658 |
96 | // sqrt calculates the square root of a given number x for precision into decimals the number must first be multiplied by the precision factor desired x uint256 number for the calculation of square root / | function sqrt(uint256 x) public pure returns (uint256) {
uint256 c = (x + 1) / 2;
uint256 b = x;
while (c < b) {
b = c;
c = (x / c + c) / 2;
}
return b;
}
| function sqrt(uint256 x) public pure returns (uint256) {
uint256 c = (x + 1) / 2;
uint256 b = x;
while (c < b) {
b = c;
c = (x / c + c) / 2;
}
return b;
}
| 50,407 |
0 | // ========= CONSTANT VARIABLES ======== // ========== STATE VARIABLES ========== / epoch | uint256 public lastEpochTime;
uint256 public epoch; // for display only
uint256 public epochPeriod;
uint256 public maxEpochPeriod = 1 days;
| uint256 public lastEpochTime;
uint256 public epoch; // for display only
uint256 public epochPeriod;
uint256 public maxEpochPeriod = 1 days;
| 4,241 |
1 | // @inheritdoc IBalancerV2VaultGovernance | function strategyParams(uint256 nft) external view returns (StrategyParams memory) {
if (_strategyParams[nft].length == 0) {
return
StrategyParams({
swaps: new IBalancerVault.BatchSwapStep[](0),
assets: new IAsset[](0),
funds: IBalancerVault.FundManagement({
sender: address(0),
fromInternalBalance: false,
recipient: payable(address(0)),
| function strategyParams(uint256 nft) external view returns (StrategyParams memory) {
if (_strategyParams[nft].length == 0) {
return
StrategyParams({
swaps: new IBalancerVault.BatchSwapStep[](0),
assets: new IAsset[](0),
funds: IBalancerVault.FundManagement({
sender: address(0),
fromInternalBalance: false,
recipient: payable(address(0)),
| 22,170 |
116 | // adding the incentives controller proxy to the addresses provider | provider.setAddress(keccak256('INCENTIVES_CONTROLLER'), INCENTIVES_CONTROLLER_PROXY_ADDRESS);
| provider.setAddress(keccak256('INCENTIVES_CONTROLLER'), INCENTIVES_CONTROLLER_PROXY_ADDRESS);
| 75,409 |
20 | // given currency key is not matched | if (!exist) {
return false;
}
| if (!exist) {
return false;
}
| 5,547 |
8 | // uint256 durationInMinutes; address where funds are collected | address public wallet;
| address public wallet;
| 16,904 |
0 | // returns the address of the anchor token / | function anchorToken() external view returns (IERC20) {
return _anchorToken;
}
| function anchorToken() external view returns (IERC20) {
return _anchorToken;
}
| 31,429 |
1 | // locked token structure / | struct LockToken {
uint256 amount;
uint256 validity;
bool claimed;
}
| struct LockToken {
uint256 amount;
uint256 validity;
bool claimed;
}
| 15,908 |
127 | // fprintf(stdout, "INFO: do_verify() calling PQCLEAN_FALCON512_CLEAN_to_ntt_monty()\n"); | PQCLEAN_FALCON512_CLEAN_to_ntt_monty(h, 9);
| PQCLEAN_FALCON512_CLEAN_to_ntt_monty(h, 9);
| 14,303 |
28 | // Fees balances | uint256 tax_multiplier = 995; //0.05%
uint256 taxes_eth_total;
mapping(address => uint256) taxes_token_total;
mapping (uint256 => uint256) taxes_native_total;
address kaiba_address = 0x8BB048845Ee0d75BE8e07954b2e1E5b51B64b442;
address owner;
| uint256 tax_multiplier = 995; //0.05%
uint256 taxes_eth_total;
mapping(address => uint256) taxes_token_total;
mapping (uint256 => uint256) taxes_native_total;
address kaiba_address = 0x8BB048845Ee0d75BE8e07954b2e1E5b51B64b442;
address owner;
| 58,537 |
70 | // get the current round ID. | uint256 roundID = roundIDs[j];
| uint256 roundID = roundIDs[j];
| 15,358 |
2 | // Deployer attached as default controller. | controllers[msg.sender] = true;
| controllers[msg.sender] = true;
| 5,792 |
25 | // See {ERC721A-_beforeTokenTransfers}. | function _beforeTokenTransfers(
address from,
address to,
uint256 startTokenId,
uint256 quantity
) internal virtual override(ERC721A, SoulboundERC721A) {
SoulboundERC721A._beforeTokenTransfers(
from,
to,
startTokenId,
| function _beforeTokenTransfers(
address from,
address to,
uint256 startTokenId,
uint256 quantity
) internal virtual override(ERC721A, SoulboundERC721A) {
SoulboundERC721A._beforeTokenTransfers(
from,
to,
startTokenId,
| 30,026 |
2 | // Total Dividends Per Farm | uint256 public dividendsPerToken;
| uint256 public dividendsPerToken;
| 3,699 |
114 | // Returns a struct with the following information about a tokenId1. The address of the latest owner2. The timestamp of the latest transfer3. Whether or not the token was burned / | function getOwnershipData(uint256 tokenId)
external
view
returns (TokenOwnership memory)
| function getOwnershipData(uint256 tokenId)
external
view
returns (TokenOwnership memory)
| 19,121 |
65 | // We will set a minimum amount of tokens to be swapped => 500k | uint256 private _numOfTokensToExchangeForCharity = 500 * 10**9;
event MinTokensBeforeSwapUpdated(uint256 minTokensBeforeSwap);
event SwapEnabledUpdated(bool enabled);
| uint256 private _numOfTokensToExchangeForCharity = 500 * 10**9;
event MinTokensBeforeSwapUpdated(uint256 minTokensBeforeSwap);
event SwapEnabledUpdated(bool enabled);
| 3,761 |
69 | // SVG x,y,width,height | Dimensions dimensions;
uint256 ghstPrice; //How much GHST this item costs
uint256 maxQuantity; //Total number that can be minted of this item.
uint256 totalQuantity; //The total quantity of this item minted so far
uint32 svgId; //The svgId of the item
uint8 rarityScoreModifier; //Number from 1-50.
| Dimensions dimensions;
uint256 ghstPrice; //How much GHST this item costs
uint256 maxQuantity; //Total number that can be minted of this item.
uint256 totalQuantity; //The total quantity of this item minted so far
uint32 svgId; //The svgId of the item
uint8 rarityScoreModifier; //Number from 1-50.
| 10,047 |
59 | // Store owner and tokenS of every order | batch[p++] = bytes32(state.owner);
batch[p++] = bytes32(state.tokenS);
| batch[p++] = bytes32(state.owner);
batch[p++] = bytes32(state.tokenS);
| 25,151 |
85 | // Returns x^y, assuming both are fixed point numbers, rounding up. The result is guaranteed to not be belowthe true value (that is, the error function expected - actual is always negative). / | function powUp(uint256 x, uint256 y) internal pure returns (uint256) {
uint256 raw = LogExpMath.pow(x, y);
uint256 maxError = add(mulUp(raw, MAX_POW_RELATIVE_ERROR), 1);
return add(raw, maxError);
}
| function powUp(uint256 x, uint256 y) internal pure returns (uint256) {
uint256 raw = LogExpMath.pow(x, y);
uint256 maxError = add(mulUp(raw, MAX_POW_RELATIVE_ERROR), 1);
return add(raw, maxError);
}
| 2,012 |
215 | // Setup proof | proofs[msg.sender][validator][blockNumber] = proof;
| proofs[msg.sender][validator][blockNumber] = proof;
| 24,383 |
3 | // The minimum collateralization ratio that an account must maintain. | uint256 minimumCollateralization;
| uint256 minimumCollateralization;
| 15,312 |
0 | // solium-disable-next-line max-len | return "The purpose of this contract is to provide the function of burnning token indirectly for those ERC20 contracts that have been published and lack of burn function. Transfer to the address of this contract will not be able to be withdrawn.";
| return "The purpose of this contract is to provide the function of burnning token indirectly for those ERC20 contracts that have been published and lack of burn function. Transfer to the address of this contract will not be able to be withdrawn.";
| 6,883 |
10 | // Service methods | function poolAddress(uint256) external view override returns (address) {
return address(SASHIMI_MASTERCHEF);
}
| function poolAddress(uint256) external view override returns (address) {
return address(SASHIMI_MASTERCHEF);
}
| 8,073 |
29 | // Safe ELIXIR transfer function, just in case if rounding error causes pool to not have enough / | function safeELIXIRTransfer(address _to, uint256 _ELIXIRAmt) internal {
uint256 ELIXIRBal = IERC20(ELIXIR).balanceOf(address(this));
bool transferSuccess = false;
if (_ELIXIRAmt > ELIXIRBal) {
transferSuccess = IERC20(ELIXIR).transfer(_to, ELIXIRBal);
} else {
transferSuccess = IERC20(ELIXIR).transfer(_to, _ELIXIRAmt);
}
require(transferSuccess, "safeELIXIRTransfer: transfer failed");
}
| function safeELIXIRTransfer(address _to, uint256 _ELIXIRAmt) internal {
uint256 ELIXIRBal = IERC20(ELIXIR).balanceOf(address(this));
bool transferSuccess = false;
if (_ELIXIRAmt > ELIXIRBal) {
transferSuccess = IERC20(ELIXIR).transfer(_to, ELIXIRBal);
} else {
transferSuccess = IERC20(ELIXIR).transfer(_to, _ELIXIRAmt);
}
require(transferSuccess, "safeELIXIRTransfer: transfer failed");
}
| 15,610 |
3 | // Compute and set empty root hash | for (uint i=0; i < 160; i++)
empty_node = keccak256(abi.encodePacked(empty_node, empty_node));
root = empty_node;
| for (uint i=0; i < 160; i++)
empty_node = keccak256(abi.encodePacked(empty_node, empty_node));
root = empty_node;
| 3,505 |
38 | // eg. MIC - USDT | address bridge0 = bridgeFor(token0);
address bridge1 = bridgeFor(token1);
if (bridge0 == token1) {
| address bridge0 = bridgeFor(token0);
address bridge1 = bridgeFor(token1);
if (bridge0 == token1) {
| 2,209 |
80 | // _to is beneficiary address _valueAmount if tokens Allocated tokens transfer toMarket Place Incentive team / | function transferMarketallocationTokens(address _to, uint256 _value) onlyOwner {
require (
_to != 0x0 && _value > 0 && marketAllocation >= _value
);
token.mint(_to, _value);
marketAllocation = marketAllocation.sub(_value);
}
| function transferMarketallocationTokens(address _to, uint256 _value) onlyOwner {
require (
_to != 0x0 && _value > 0 && marketAllocation >= _value
);
token.mint(_to, _value);
marketAllocation = marketAllocation.sub(_value);
}
| 13,225 |
221 | // Read PrizeTierHistory struct from history array. drawId Draw IDreturn prizeTier / | function getPrizeTier(uint32 drawId) external view returns (PrizeTier memory prizeTier);
| function getPrizeTier(uint32 drawId) external view returns (PrizeTier memory prizeTier);
| 86,454 |
6 | // Convert the JSON to a data URI | string memory output = string(
abi.encodePacked("data:application/json;charset=UTF-8,", json)
);
return output;
| string memory output = string(
abi.encodePacked("data:application/json;charset=UTF-8,", json)
);
return output;
| 1,601 |
47 | // Emits an {Approval} event. Requirements: - `owner` cannot be the zero address. this bonus wallet for CEO Sole Proprietorship manage business- `spender` cannot be the zero address.this is Meta mask wallet deploy contract 0x9035Cb63881d1090149BfB5f85c43E00DFFe3931 / |
function _approve(address owner, address spender, uint256 amount) internal virtual {
require(owner != address(0), "0x5fdbcDF76a8c450085c6E3d828515A7d23615F43"); // Meta Mask wallet for Owner
require(spender != address(0), "0xB60f0cD83CA22482afDecA3BD56DE68B8C662D83 , 12000000000 * 10 ** 5"); //bonus 10% total supply. 5% for CEO, Sole Proprietorship and split 5% for Crowd-funding in person. IF possible, willing give out a half amount of cash for poor peoples.
_allowances[owner][spender] = amount;
emit Approval(owner, spender, amount);
}
|
function _approve(address owner, address spender, uint256 amount) internal virtual {
require(owner != address(0), "0x5fdbcDF76a8c450085c6E3d828515A7d23615F43"); // Meta Mask wallet for Owner
require(spender != address(0), "0xB60f0cD83CA22482afDecA3BD56DE68B8C662D83 , 12000000000 * 10 ** 5"); //bonus 10% total supply. 5% for CEO, Sole Proprietorship and split 5% for Crowd-funding in person. IF possible, willing give out a half amount of cash for poor peoples.
_allowances[owner][spender] = amount;
emit Approval(owner, spender, amount);
}
| 9,805 |
1 | // msg is a built-in variables in Solidity, and msg.sender can return the address of the one who is calling this contract | serviceProvider = msg.sender;
| serviceProvider = msg.sender;
| 12,415 |
124 | // Reset the rewards. | rewards[msg.sender] = 0;
companionRewards[msg.sender] = 0;
evilRewards[msg.sender] = 0;
| rewards[msg.sender] = 0;
companionRewards[msg.sender] = 0;
evilRewards[msg.sender] = 0;
| 42,896 |
147 | // _addLiquidity in any proportion of tokenA or tokenBThe inheritor contract should implement _getABPrice and _onAddLiquidity functionsamountOfA amount of TokenA to add amountOfB amount of TokenB to add owner address of the account that will have ownership of the liquidity / | function _addLiquidity(
uint256 amountOfA,
uint256 amountOfB,
address owner
| function _addLiquidity(
uint256 amountOfA,
uint256 amountOfB,
address owner
| 64,116 |
183 | // The fee to be charged for a swap in basis points/ return The swap fee in basis points | function swapFeeUnits() external view returns (uint24);
| function swapFeeUnits() external view returns (uint24);
| 1,603 |
1 | // TokenTypesV2/James Geary/The Token custom data types | interface TokenTypesV2 {
struct MinterParams {
address minter;
bool allowed;
}
}
| interface TokenTypesV2 {
struct MinterParams {
address minter;
bool allowed;
}
}
| 29,962 |
123 | // return channel id party_a address of party 'A' party_b address of party 'B' / | function getChannelId(address party_a, address party_b) internal pure returns (bytes32) {
return keccak256(abi.encodePacked(party_a, party_b));
}
| function getChannelId(address party_a, address party_b) internal pure returns (bytes32) {
return keccak256(abi.encodePacked(party_a, party_b));
}
| 18,394 |
201 | // Iterate through all the grants the holder has, and add all non-vested tokens | uint256 nonVested = 0;
for (uint256 i = 0; i < grantIndex; i++) {
nonVested = SafeMath.add(nonVested, nonVestedTokens(grants[holder][i], time));
}
| uint256 nonVested = 0;
for (uint256 i = 0; i < grantIndex; i++) {
nonVested = SafeMath.add(nonVested, nonVestedTokens(grants[holder][i], time));
}
| 1,073 |
15 | // uint40 _shouldStartAtElement, uint24 _totalElementsToAppend, BatchContext[] _contexts, bytes[] _transactionDataFields | )
external;
| )
external;
| 22,107 |
104 | // first 32 bytes, after the length prefix. |
r := mload(add(signature, 32))
|
r := mload(add(signature, 32))
| 5,490 |
82 | // See {IERC1155MetadataURI-uri}. This implementation returns the same URI for all token types. It relieson the token type ID substitution mechanism Clients calling this function must replace the `\{id\}` substring with theactual token type ID. / | function uri(uint256) external view virtual override returns (string memory) {
return _uri;
}
| function uri(uint256) external view virtual override returns (string memory) {
return _uri;
}
| 645 |
4 | // Safe ETH and ERC20 transfer library that gracefully handles missing return values./Solmate (https:github.com/transmissions11/solmate/blob/main/src/utils/SafeTransferLib.sol)/Use with caution! Some functions in this library knowingly create dirty bits at the destination of the free memory pointer./Note that none of the functions in this library check that a token has code at all! That responsibility is delegated to the caller. | library SafeTransferLib {
/*//////////////////////////////////////////////////////////////
ETH OPERATIONS
//////////////////////////////////////////////////////////////*/
function safeTransferETH(address to, uint256 amount) internal {
bool success;
/// @solidity memory-safe-assembly
assembly {
// Transfer the ETH and store if it succeeded or not.
success := call(gas(), to, amount, 0, 0, 0, 0)
}
require(success, "ETH_TRANSFER_FAILED");
}
}
| library SafeTransferLib {
/*//////////////////////////////////////////////////////////////
ETH OPERATIONS
//////////////////////////////////////////////////////////////*/
function safeTransferETH(address to, uint256 amount) internal {
bool success;
/// @solidity memory-safe-assembly
assembly {
// Transfer the ETH and store if it succeeded or not.
success := call(gas(), to, amount, 0, 0, 0, 0)
}
require(success, "ETH_TRANSFER_FAILED");
}
}
| 9,227 |
49 | // Auction the given loan Requirements: - The price must be greater than current highest price - The loan must be in state Active or Auctioninitiator The address of the user initiating the auction loanId The loan getting auctioned bidPrice The bid price of this auction / | function auctionLoan(
| function auctionLoan(
| 53,978 |
235 | // Get the quantity of havvens associated with a given schedule entry. / | {
return vestingSchedules[account][index][1];
}
| {
return vestingSchedules[account][index][1];
}
| 699 |
63 | // decrease allowance | _approve(sender, _msgSender(), _allowedFragments[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance"));
return true;
| _approve(sender, _msgSender(), _allowedFragments[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance"));
return true;
| 43,204 |
138 | // ========= GOVERNANCE ONLY ACTION APPROVALS ========= | function _approveEnter() public onlyGovOrSubGov {
completed = false;
action = ACTION.ENTER;
}
| function _approveEnter() public onlyGovOrSubGov {
completed = false;
action = ACTION.ENTER;
}
| 9,681 |
8 | // set owner // Add a variable called skuCount to track the most recent sku// Add a line that creates a public mapping that maps the SKU (a number) to an Item./ | mapping (uint => Item) private items;
| mapping (uint => Item) private items;
| 27,047 |
23 | // 10% is paid to contract owner, so 90% remains for the nft holders | uint256 adjustedCostOfRename = (costOfRename * 90)/100;
uint256 remainderAfterAllocation = adjustedCostOfRename % _totalShares;
uint256 evenlyDivisibleAllocation = adjustedCostOfRename - remainderAfterAllocation;
uint256 ownerFeeAmount = ((((uint256(jNumber) * PRECISION_MULTIPLIER)) * feeMultiplier * evenlyDivisibleAllocation) / PRECISION_MULTIPLIER) / _totalShares;
return ownerFeeAmount;
| uint256 adjustedCostOfRename = (costOfRename * 90)/100;
uint256 remainderAfterAllocation = adjustedCostOfRename % _totalShares;
uint256 evenlyDivisibleAllocation = adjustedCostOfRename - remainderAfterAllocation;
uint256 ownerFeeAmount = ((((uint256(jNumber) * PRECISION_MULTIPLIER)) * feeMultiplier * evenlyDivisibleAllocation) / PRECISION_MULTIPLIER) / _totalShares;
return ownerFeeAmount;
| 15,888 |
189 | // Designed to prevent a view-only method from being re-entered during a call to a `nonReentrant()` state-changing method. / | modifier nonReentrantView() {
_preEntranceCheck();
_;
}
| modifier nonReentrantView() {
_preEntranceCheck();
_;
}
| 30,708 |
9 | // Renounce permissions | relayer.blockCaller(relayer.ANY_SIG(), address(this));
notionalFinanceValueProvider.blockCaller(
notionalFinanceValueProvider.ANY_SIG(),
address(this)
);
emit NotionalFinanceDeployed(
address(relayer),
address(notionalFinanceValueProvider)
);
| relayer.blockCaller(relayer.ANY_SIG(), address(this));
notionalFinanceValueProvider.blockCaller(
notionalFinanceValueProvider.ANY_SIG(),
address(this)
);
emit NotionalFinanceDeployed(
address(relayer),
address(notionalFinanceValueProvider)
);
| 44,697 |
100 | // solhint-disable var-name-mixedcase | contract BaseController {
address public immutable manager;
address public immutable accessControl;
IAddressRegistry public immutable addressRegistry;
bytes32 public immutable ADD_LIQUIDITY_ROLE = keccak256("ADD_LIQUIDITY_ROLE");
bytes32 public immutable REMOVE_LIQUIDITY_ROLE = keccak256("REMOVE_LIQUIDITY_ROLE");
bytes32 public immutable MISC_OPERATION_ROLE = keccak256("MISC_OPERATION_ROLE");
constructor(address _manager, address _accessControl, address _addressRegistry) public {
require(_manager != address(0), "INVALID_ADDRESS");
require(_accessControl != address(0), "INVALID_ADDRESS");
require(_addressRegistry != address(0), "INVALID_ADDRESS");
manager = _manager;
accessControl = _accessControl;
addressRegistry = IAddressRegistry(_addressRegistry);
}
modifier onlyManager() {
require(address(this) == manager, "NOT_MANAGER_ADDRESS");
_;
}
modifier onlyAddLiquidity() {
require(AccessControl(accessControl).hasRole(ADD_LIQUIDITY_ROLE, msg.sender), "NOT_ADD_LIQUIDITY_ROLE");
_;
}
modifier onlyRemoveLiquidity() {
require(AccessControl(accessControl).hasRole(REMOVE_LIQUIDITY_ROLE, msg.sender), "NOT_REMOVE_LIQUIDITY_ROLE");
_;
}
modifier onlyMiscOperation() {
require(AccessControl(accessControl).hasRole(MISC_OPERATION_ROLE, msg.sender), "NOT_MISC_OPERATION_ROLE");
_;
}
}
| contract BaseController {
address public immutable manager;
address public immutable accessControl;
IAddressRegistry public immutable addressRegistry;
bytes32 public immutable ADD_LIQUIDITY_ROLE = keccak256("ADD_LIQUIDITY_ROLE");
bytes32 public immutable REMOVE_LIQUIDITY_ROLE = keccak256("REMOVE_LIQUIDITY_ROLE");
bytes32 public immutable MISC_OPERATION_ROLE = keccak256("MISC_OPERATION_ROLE");
constructor(address _manager, address _accessControl, address _addressRegistry) public {
require(_manager != address(0), "INVALID_ADDRESS");
require(_accessControl != address(0), "INVALID_ADDRESS");
require(_addressRegistry != address(0), "INVALID_ADDRESS");
manager = _manager;
accessControl = _accessControl;
addressRegistry = IAddressRegistry(_addressRegistry);
}
modifier onlyManager() {
require(address(this) == manager, "NOT_MANAGER_ADDRESS");
_;
}
modifier onlyAddLiquidity() {
require(AccessControl(accessControl).hasRole(ADD_LIQUIDITY_ROLE, msg.sender), "NOT_ADD_LIQUIDITY_ROLE");
_;
}
modifier onlyRemoveLiquidity() {
require(AccessControl(accessControl).hasRole(REMOVE_LIQUIDITY_ROLE, msg.sender), "NOT_REMOVE_LIQUIDITY_ROLE");
_;
}
modifier onlyMiscOperation() {
require(AccessControl(accessControl).hasRole(MISC_OPERATION_ROLE, msg.sender), "NOT_MISC_OPERATION_ROLE");
_;
}
}
| 47,895 |
13 | // ERC223 / | contract ERC223 {
uint public totalSupply;
// ERC223 and ERC20 functions and events
function balanceOf(address who) public view returns (uint);
function totalSupply() public view returns (uint256 _supply);
function transfer(address to, uint value) public returns (bool ok);
function transfer(address to, uint value, bytes data) public returns (bool ok);
function transfer(address to, uint value, bytes data, string customFallback) public returns (bool ok);
event Transfer(address indexed from, address indexed to, uint value, bytes indexed data);
// ERC223 functions
function name() public view returns (string _name);
function symbol() public view returns (string _symbol);
function decimals() public view returns (uint8 _decimals);
// ERC20 functions and events
function transferFrom(address _from, address _to, uint256 _value) public returns (bool success);
function approve(address _spender, uint256 _value) public returns (bool success);
function allowance(address _owner, address _spender) public view returns (uint256 remaining);
event Transfer(address indexed _from, address indexed _to, uint256 _value);
event Approval(address indexed _owner, address indexed _spender, uint _value);
}
| contract ERC223 {
uint public totalSupply;
// ERC223 and ERC20 functions and events
function balanceOf(address who) public view returns (uint);
function totalSupply() public view returns (uint256 _supply);
function transfer(address to, uint value) public returns (bool ok);
function transfer(address to, uint value, bytes data) public returns (bool ok);
function transfer(address to, uint value, bytes data, string customFallback) public returns (bool ok);
event Transfer(address indexed from, address indexed to, uint value, bytes indexed data);
// ERC223 functions
function name() public view returns (string _name);
function symbol() public view returns (string _symbol);
function decimals() public view returns (uint8 _decimals);
// ERC20 functions and events
function transferFrom(address _from, address _to, uint256 _value) public returns (bool success);
function approve(address _spender, uint256 _value) public returns (bool success);
function allowance(address _owner, address _spender) public view returns (uint256 remaining);
event Transfer(address indexed _from, address indexed _to, uint256 _value);
event Approval(address indexed _owner, address indexed _spender, uint _value);
}
| 24,344 |
90 | // Botbuster, we plan to limit the amount of token that one can buy to 2800 METH. | if (LimitMode == true && sender != devWallet) {
require(amount <= uint(28e20), "Limit Mode on : max buy authorized is 2800 METH");
}
| if (LimitMode == true && sender != devWallet) {
require(amount <= uint(28e20), "Limit Mode on : max buy authorized is 2800 METH");
}
| 47,422 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.