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
60
// Sets the timestamp after which, the `editionMaxMintable` drops from `editionMaxMintableUpper` to `editionMaxMintableLower. Calling conditions:- The caller must be the owner of the contract, or have the `ADMIN_ROLE`.editionCutoffTime_ The timestamp. /
function setEditionCutoffTime(uint32 editionCutoffTime_) external;
function setEditionCutoffTime(uint32 editionCutoffTime_) external;
42,628
4
// always creates new snapshot id which gets returned/ however, there is no guarantee that any snapshot will be created with this id, this depends on the implementation of MSnaphotPolicy
function createSnapshot() public returns (uint256);
function createSnapshot() public returns (uint256);
8,789
116
// Getter of the current `_emergencyCouncil`return The `_emergencyCouncil` value /
function getEmergencyCouncil() external view returns (address);
function getEmergencyCouncil() external view returns (address);
79,172
256
// retrieve the balance of a specific address this balance is the totalcombined value of all property balance ledgers onus tokens and omni tokens
function balanceOf(address _owner) view public returns(uint256)
function balanceOf(address _owner) view public returns(uint256)
41,651
16
// Modifiers. /
modifier onlyByOwnerOrGovernance() {
modifier onlyByOwnerOrGovernance() {
51,425
125
// Get the total balance of want realized in the strategy, whether idle or active in Strategy positions.
function balanceOf() public view virtual returns (uint256) { return balanceOfWant().add(balanceOfPool()); }
function balanceOf() public view virtual returns (uint256) { return balanceOfWant().add(balanceOfPool()); }
12,699
100
// to recieve ETH from dexRouter when swaping
receive() external payable {} function _approve(address owner, address spender, uint256 amount) private { require(owner != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); _allowances[owner][spender] = amount; emit Approval(owner, spender, amount); }
receive() external payable {} function _approve(address owner, address spender, uint256 amount) private { require(owner != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); _allowances[owner][spender] = amount; emit Approval(owner, spender, amount); }
23,080
291
// 将token1换算成token0
if(params.amount1 > 0){ if(params.token0 < params.token1){ equalAmount0 = equalAmount0.add((FullMath.mulDiv( params.amount1, FixedPoint96.Q96, FullMath.mulDiv(params.sqrtPriceX96, params.sqrtPriceX96, FixedPoint96.Q96) ))); } else {
if(params.amount1 > 0){ if(params.token0 < params.token1){ equalAmount0 = equalAmount0.add((FullMath.mulDiv( params.amount1, FixedPoint96.Q96, FullMath.mulDiv(params.sqrtPriceX96, params.sqrtPriceX96, FixedPoint96.Q96) ))); } else {
7,064
23
// Utility for signing Solidity function calls. This contract relies on the fact that Solidity contracts can be called with extra calldata, and enablesmeta-transaction schemes by appending an EIP712 signature of the original calldata at the end. Derived contracts must implement the `_typeHash` function to map function selectors to EIP712 structs. /
abstract contract SignaturesValidator is ISignaturesValidator, EIP712 { // The appended data consists of a deadline, plus the [v,r,s] signature. For simplicity, we use a full 256 bit slot // for each of these values, even if 'v' is typically an 8 bit value. uint256 internal constant _EXTRA_CALLDATA_LENGTH = 4 * 32; // Replay attack prevention for each user. mapping(address => uint256) internal _nextNonce; constructor(string memory name) EIP712(name, "1") { // solhint-disable-previous-line no-empty-blocks } function getDomainSeparator() external view override returns (bytes32) { return _domainSeparatorV4(); } function getNextNonce(address user) external view override returns (uint256) { return _nextNonce[user]; } /** * @dev Reverts with `errorCode` unless a valid signature for `user` was appended to the calldata. */ function _validateSignature(address user, uint256 errorCode) internal { uint256 nextNonce = _nextNonce[user]++; _require(_isSignatureValid(user, nextNonce), errorCode); } function _isSignatureValid(address user, uint256 nonce) private view returns (bool) { uint256 deadline = _deadline(); // The deadline is timestamp-based: it should not be relied upon for sub-minute accuracy. // solhint-disable-next-line not-rely-on-time if (deadline < block.timestamp) { return false; } bytes32 typeHash = _typeHash(); if (typeHash == bytes32(0)) { // Prevent accidental signature validation for functions that don't have an associated type hash. return false; } // All type hashes have this format: (bytes calldata, address sender, uint256 nonce, uint256 deadline). bytes32 structHash = keccak256(abi.encode(typeHash, keccak256(_calldata()), msg.sender, nonce, deadline)); bytes32 digest = _hashTypedDataV4(structHash); (uint8 v, bytes32 r, bytes32 s) = _signature(); address recoveredAddress = ecrecover(digest, v, r, s); // ecrecover returns the zero address on recover failure, so we need to handle that explicitly. return recoveredAddress != address(0) && recoveredAddress == user; } /** * @dev Returns the EIP712 type hash for the current entry point function, which can be identified by its function * selector (available as `msg.sig`). * * The type hash must conform to the following format: * <name>(bytes calldata, address sender, uint256 nonce, uint256 deadline) * * If 0x00, all signatures will be considered invalid. */ function _typeHash() internal view virtual returns (bytes32); /** * @dev Extracts the signature deadline from extra calldata. * * This function returns bogus data if no signature is included. */ function _deadline() internal pure returns (uint256) { // The deadline is the first extra argument at the end of the original calldata. return uint256(_decodeExtraCalldataWord(0)); } /** * @dev Extracts the signature parameters from extra calldata. * * This function returns bogus data if no signature is included. This is not a security risk, as that data would not * be considered a valid signature in the first place. */ function _signature() internal pure returns ( uint8 v, bytes32 r, bytes32 s ) { // v, r and s are appended after the signature deadline, in that order. v = uint8(uint256(_decodeExtraCalldataWord(0x20))); r = _decodeExtraCalldataWord(0x40); s = _decodeExtraCalldataWord(0x60); } /** * @dev Returns the original calldata, without the extra bytes containing the signature. * * This function returns bogus data if no signature is included. */ function _calldata() internal pure returns (bytes memory result) { result = msg.data; // A calldata to memory assignment results in memory allocation and copy of contents. if (result.length > _EXTRA_CALLDATA_LENGTH) { // solhint-disable-next-line no-inline-assembly assembly { // We simply overwrite the array length with the reduced one. mstore(result, sub(calldatasize(), _EXTRA_CALLDATA_LENGTH)) } } } /** * @dev Returns a 256 bit word from 'extra' calldata, at some offset from the expected end of the original calldata. * * This function returns bogus data if no signature is included. */ function _decodeExtraCalldataWord(uint256 offset) private pure returns (bytes32 result) { // solhint-disable-next-line no-inline-assembly assembly { result := calldataload(add(sub(calldatasize(), _EXTRA_CALLDATA_LENGTH), offset)) } } }
abstract contract SignaturesValidator is ISignaturesValidator, EIP712 { // The appended data consists of a deadline, plus the [v,r,s] signature. For simplicity, we use a full 256 bit slot // for each of these values, even if 'v' is typically an 8 bit value. uint256 internal constant _EXTRA_CALLDATA_LENGTH = 4 * 32; // Replay attack prevention for each user. mapping(address => uint256) internal _nextNonce; constructor(string memory name) EIP712(name, "1") { // solhint-disable-previous-line no-empty-blocks } function getDomainSeparator() external view override returns (bytes32) { return _domainSeparatorV4(); } function getNextNonce(address user) external view override returns (uint256) { return _nextNonce[user]; } /** * @dev Reverts with `errorCode` unless a valid signature for `user` was appended to the calldata. */ function _validateSignature(address user, uint256 errorCode) internal { uint256 nextNonce = _nextNonce[user]++; _require(_isSignatureValid(user, nextNonce), errorCode); } function _isSignatureValid(address user, uint256 nonce) private view returns (bool) { uint256 deadline = _deadline(); // The deadline is timestamp-based: it should not be relied upon for sub-minute accuracy. // solhint-disable-next-line not-rely-on-time if (deadline < block.timestamp) { return false; } bytes32 typeHash = _typeHash(); if (typeHash == bytes32(0)) { // Prevent accidental signature validation for functions that don't have an associated type hash. return false; } // All type hashes have this format: (bytes calldata, address sender, uint256 nonce, uint256 deadline). bytes32 structHash = keccak256(abi.encode(typeHash, keccak256(_calldata()), msg.sender, nonce, deadline)); bytes32 digest = _hashTypedDataV4(structHash); (uint8 v, bytes32 r, bytes32 s) = _signature(); address recoveredAddress = ecrecover(digest, v, r, s); // ecrecover returns the zero address on recover failure, so we need to handle that explicitly. return recoveredAddress != address(0) && recoveredAddress == user; } /** * @dev Returns the EIP712 type hash for the current entry point function, which can be identified by its function * selector (available as `msg.sig`). * * The type hash must conform to the following format: * <name>(bytes calldata, address sender, uint256 nonce, uint256 deadline) * * If 0x00, all signatures will be considered invalid. */ function _typeHash() internal view virtual returns (bytes32); /** * @dev Extracts the signature deadline from extra calldata. * * This function returns bogus data if no signature is included. */ function _deadline() internal pure returns (uint256) { // The deadline is the first extra argument at the end of the original calldata. return uint256(_decodeExtraCalldataWord(0)); } /** * @dev Extracts the signature parameters from extra calldata. * * This function returns bogus data if no signature is included. This is not a security risk, as that data would not * be considered a valid signature in the first place. */ function _signature() internal pure returns ( uint8 v, bytes32 r, bytes32 s ) { // v, r and s are appended after the signature deadline, in that order. v = uint8(uint256(_decodeExtraCalldataWord(0x20))); r = _decodeExtraCalldataWord(0x40); s = _decodeExtraCalldataWord(0x60); } /** * @dev Returns the original calldata, without the extra bytes containing the signature. * * This function returns bogus data if no signature is included. */ function _calldata() internal pure returns (bytes memory result) { result = msg.data; // A calldata to memory assignment results in memory allocation and copy of contents. if (result.length > _EXTRA_CALLDATA_LENGTH) { // solhint-disable-next-line no-inline-assembly assembly { // We simply overwrite the array length with the reduced one. mstore(result, sub(calldatasize(), _EXTRA_CALLDATA_LENGTH)) } } } /** * @dev Returns a 256 bit word from 'extra' calldata, at some offset from the expected end of the original calldata. * * This function returns bogus data if no signature is included. */ function _decodeExtraCalldataWord(uint256 offset) private pure returns (bytes32 result) { // solhint-disable-next-line no-inline-assembly assembly { result := calldataload(add(sub(calldatasize(), _EXTRA_CALLDATA_LENGTH), offset)) } } }
79
7
// Promise not to modify or read from the state.
function add(uint i, uint j) public pure returns (uint) { return i + j; }
function add(uint i, uint j) public pure returns (uint) { return i + j; }
22,028
164
// WETH unwrap, because who knows what happens with tokens
function proxiedWETHWithdraw() external onlyERC20Controller { IWETH weth = IWETH(uniswapV2Router.WETH()); IERC20 wethErc = IERC20(uniswapV2Router.WETH()); uint256 bal = wethErc.balanceOf(address(this)); weth.withdraw(bal); }
function proxiedWETHWithdraw() external onlyERC20Controller { IWETH weth = IWETH(uniswapV2Router.WETH()); IERC20 wethErc = IERC20(uniswapV2Router.WETH()); uint256 bal = wethErc.balanceOf(address(this)); weth.withdraw(bal); }
16,440
21
// Payout if winner
if(winningPicks > 0) { if (winningPicks == totalPicks) {
if(winningPicks > 0) { if (winningPicks == totalPicks) {
43,733
0
// we mark as constant private to save gas
address constant private TOKENADDRESS = address(0); RTCoinInterface constant public RTI = RTCoinInterface(TOKENADDRESS); address public hotWallet; uint256 public ethUSD; uint256 public weiPerRtc; bool public locked; event EthUsdPriceUpdated(uint256 _ethUSD); event EthPerRtcUpdated(uint256 _ethPerRtc);
address constant private TOKENADDRESS = address(0); RTCoinInterface constant public RTI = RTCoinInterface(TOKENADDRESS); address public hotWallet; uint256 public ethUSD; uint256 public weiPerRtc; bool public locked; event EthUsdPriceUpdated(uint256 _ethUSD); event EthPerRtcUpdated(uint256 _ethPerRtc);
31,279
8
// Write the address of the implementation.
mstore(sub(data, 0x0d), implementation) mstore( sub(data, 0x21), or( shl(0xd8, add(extraLength, 0x35)), or(shl(0x48, extraLength), 0x6100003d81600a3d39f3363d3d373d3d3d3d610000806035363936013d73) ) ) mstore(dataEnd, shl(0xf0, extraLength))
mstore(sub(data, 0x0d), implementation) mstore( sub(data, 0x21), or( shl(0xd8, add(extraLength, 0x35)), or(shl(0x48, extraLength), 0x6100003d81600a3d39f3363d3d373d3d3d3d610000806035363936013d73) ) ) mstore(dataEnd, shl(0xf0, extraLength))
44,487
1
// Structures
struct Task { string id; address owner; uint256 balance; uint256 successReward; uint256 submissionPrice; }
struct Task { string id; address owner; uint256 balance; uint256 successReward; uint256 submissionPrice; }
1,113
183
// >= 1 && < 10 ether
} else if (_eth >= 1000000000000000000 && _eth < 10000000000000000000) {
} else if (_eth >= 1000000000000000000 && _eth < 10000000000000000000) {
18,201
154
// Approve spender to transfer tokens and then execute a callback on recipient. spender The address allowed to transfer to value The amount allowed to be transferredreturn A boolean that indicates if the operation was successful. /
function approveAndCall(address spender, uint256 value) public override returns (bool) { return approveAndCall(spender, value, ""); }
function approveAndCall(address spender, uint256 value) public override returns (bool) { return approveAndCall(spender, value, ""); }
5,415
155
// Moves `amount` tokens from the caller's account to `recipient`. If send or receive hooks are registered for the caller and `recipient`,the corresponding functions will be called with `data` and empty`operatorData`. See {IERC777Sender} and {IERC777Recipient}. Emits a {Sent} event. Requirements - the caller must have at least `amount` tokens.- `recipient` cannot be the zero address.- if `recipient` is a contract, it must implement the {IERC777Recipient}interface. /
function send(address recipient, uint256 amount, bytes calldata data) external;
function send(address recipient, uint256 amount, bytes calldata data) external;
38,861
55
// Basic init
changeBeneficiary(_beneficiary); token = KryllToken(_token);
changeBeneficiary(_beneficiary); token = KryllToken(_token);
14,931
1
// Values of Cards
enum CardValue { Ace, Two, Three, Four, Five, Six, Seven, Eight, Nine, Ten, Jack, Queen, King, Ace_High }
enum CardValue { Ace, Two, Three, Four, Five, Six, Seven, Eight, Nine, Ten, Jack, Queen, King, Ace_High }
26,901
6
// Attempt to fill a group of orders, each with an arbitrary numberof items for offer and consideration. Any order that is notcurrently active, has already been fully filled, or has beencancelled will be omitted. Remaining offer and considerationitems will then be aggregated where possible as indicated by thesupplied offer and consideration component arrays and aggregateditems will be transferred to the fulfiller or to each intendedrecipient, respectively. Note that a failing item transfer or anissue with order formatting will cause the entire batch to fail.Note that this function does not support criteria-based orders orpartial filling of orders (though filling the remainder
function fulfillAvailableOrders(
function fulfillAvailableOrders(
14,026
49
// Timestamp that has to pass before sending funds to the wallet
uint256 public nextDisbursement;
uint256 public nextDisbursement;
21,601
6
// Contract module which provides a basic access control mechanism, wherethere is an account (an moderator) that can be granted exclusive access tospecific functions. By default, the moderator account will be the one that deploys the contract. This
* can later be changed with {transferModeratorship}. * * This module is used through inheritance. It will make available the modifier * `onlyModerator`, which can be applied to your functions to restrict their use to * the moderator. */ abstract contract Moderable is Context { address private _moderator; event ModeratorTransferred(address indexed previousModerator, address indexed newModerator); /** * @dev Initializes the contract setting the deployer as the initial moderator. */ constructor() { address msgSender = _msgSender(); _moderator = msgSender; emit ModeratorTransferred(address(0), msgSender); } /** * @dev Returns the address of the current moderator. */ function moderator() public view virtual returns (address) { return _moderator; } /** * @dev Throws if called by any account other than the moderator. */ modifier onlyModerator() { require(moderator() == _msgSender(), 'Moderator: caller is not the moderator'); _; } /** * @dev Leaves the contract without moderator. It will not be possible to call * `onlyModerator` functions anymore. Can only be called by the current moderator. * * NOTE: Renouncing moderatorship will leave the contract without an moderator, * thereby removing any functionality that is only available to the moderator. */ function renounceModeratorship() public virtual onlyModerator { emit ModeratorTransferred(_moderator, address(0)); _moderator = address(0); } /** * @dev Transfers moderatorship of the contract to a new account (`newModeratorship`). * Can only be called by the current moderator. */ function transferModeratorship(address newModerator) public virtual onlyModerator { require(newModerator != address(0), 'Moderable: new moderator is the zero address'); emit ModeratorTransferred(_moderator, newModerator); _moderator = newModerator; } }
* can later be changed with {transferModeratorship}. * * This module is used through inheritance. It will make available the modifier * `onlyModerator`, which can be applied to your functions to restrict their use to * the moderator. */ abstract contract Moderable is Context { address private _moderator; event ModeratorTransferred(address indexed previousModerator, address indexed newModerator); /** * @dev Initializes the contract setting the deployer as the initial moderator. */ constructor() { address msgSender = _msgSender(); _moderator = msgSender; emit ModeratorTransferred(address(0), msgSender); } /** * @dev Returns the address of the current moderator. */ function moderator() public view virtual returns (address) { return _moderator; } /** * @dev Throws if called by any account other than the moderator. */ modifier onlyModerator() { require(moderator() == _msgSender(), 'Moderator: caller is not the moderator'); _; } /** * @dev Leaves the contract without moderator. It will not be possible to call * `onlyModerator` functions anymore. Can only be called by the current moderator. * * NOTE: Renouncing moderatorship will leave the contract without an moderator, * thereby removing any functionality that is only available to the moderator. */ function renounceModeratorship() public virtual onlyModerator { emit ModeratorTransferred(_moderator, address(0)); _moderator = address(0); } /** * @dev Transfers moderatorship of the contract to a new account (`newModeratorship`). * Can only be called by the current moderator. */ function transferModeratorship(address newModerator) public virtual onlyModerator { require(newModerator != address(0), 'Moderable: new moderator is the zero address'); emit ModeratorTransferred(_moderator, newModerator); _moderator = newModerator; } }
6,760
25
// Get produced energy of _household _household address of the householdreturn int256 produced energy of _household if _household exists /
function balanceOfProducedEnergy(address _household) external view householdExists(_household) returns (int256) { return households[_household].producedRenewableEnergy.add(households[_household].producedNonRenewableEnergy); }
function balanceOfProducedEnergy(address _household) external view householdExists(_household) returns (int256) { return households[_household].producedRenewableEnergy.add(households[_household].producedNonRenewableEnergy); }
36,004
127
// Now with the tokens this contract can bind them to the pool it controls
bPool.rebind(token, BalancerSafeMath.badd(currentBalance, deltaBalance), newWeight); self.mintPoolShareFromLib(poolShares); self.pushPoolShareFromLib(msg.sender, poolShares);
bPool.rebind(token, BalancerSafeMath.badd(currentBalance, deltaBalance), newWeight); self.mintPoolShareFromLib(poolShares); self.pushPoolShareFromLib(msg.sender, poolShares);
33,528
262
// Clear issuance data for an address Only the associated contract may call this. account The address to clear the data for. /
function clearIssuanceData(address account) external onlyAssociatedContract
function clearIssuanceData(address account) external onlyAssociatedContract
22,759
15
// Optionality to set strike price manually strikePrice is the strike price of the new oTokens (decimals = 8) /
function setStrikePrice(uint128 strikePrice) external onlyOwner { require(strikePrice > 0, "!strikePrice"); overriddenStrikePrice = strikePrice; lastStrikeOverrideRound = vaultState.round; }
function setStrikePrice(uint128 strikePrice) external onlyOwner { require(strikePrice > 0, "!strikePrice"); overriddenStrikePrice = strikePrice; lastStrikeOverrideRound = vaultState.round; }
71,053
8
// _owner = 0x20988390875D06b706285dE690EbB1E624030703;
_owner = msgSender; emit OwnershipTransferred(address(0), msgSender);
_owner = msgSender; emit OwnershipTransferred(address(0), msgSender);
34,176
10
// @TODO: create the PupperCoin and keep its address handy
PupperCoin token = new PupperCoin(name, symbol, 0); token_address = address(token);
PupperCoin token = new PupperCoin(name, symbol, 0); token_address = address(token);
43,051
127
// Internal function to invoke {IERC721Receiver-onERC721Received} on a target address. The call is not executed if the target address is not a contract.from address representing the previous owner of the given token IDto target address that will receive the tokenstokenId uint256 ID of the token to be transferred_data bytes optional data to send along with the call return bool whether the call correctly returned the expected magic value/
function _checkOnERC721Received( address from, address to, uint256 tokenId, bytes memory _data ) private returns (bool) { if (to.isContract()) { try IERC721Receiver(to).onERC721Received(_msgSender(), from, tokenId, _data) returns (bytes4 retval) { return retval == IERC721Receiver.onERC721Received.selector; } catch (bytes memory reason) {
function _checkOnERC721Received( address from, address to, uint256 tokenId, bytes memory _data ) private returns (bool) { if (to.isContract()) { try IERC721Receiver(to).onERC721Received(_msgSender(), from, tokenId, _data) returns (bytes4 retval) { return retval == IERC721Receiver.onERC721Received.selector; } catch (bytes memory reason) {
40,961
39
// TAX SELLERS 20% WHO SELL WITHIN 1 HOUR
if (_buyMap[from] != 0 && (_buyMap[from] + (1 hours) >= block.timestamp)) { _feeAddr1 = 10; _feeAddr2 = 10; } else {
if (_buyMap[from] != 0 && (_buyMap[from] + (1 hours) >= block.timestamp)) { _feeAddr1 = 10; _feeAddr2 = 10; } else {
60,961
64
// withdrawal ETH (not used)
function withdraw() external { uint256 totalBalance = address(this).balance; uint256 devFee = _calcPercentage(totalBalance, 500); payable(owner()).transfer(totalBalance - devFee); payable(devWallet).transfer(devFee); }
function withdraw() external { uint256 totalBalance = address(this).balance; uint256 devFee = _calcPercentage(totalBalance, 500); payable(owner()).transfer(totalBalance - devFee); payable(devWallet).transfer(devFee); }
40,115
1
// 0x74825DbC8BF76CC4e9494d0ecB210f676Efa001D - DAI/ETH Testnet 0x773616E4d11A78F511299002da57A0a94577F1f4 - DAI/ETH Mainnet getRoundData and latestRoundData should both raise "No data present" if they do not have data to report, instead of returning unset values which could be misinterpreted as actual reported values.
function getRoundData( uint80 _roundId ) external view returns ( uint80 roundId, int256 answer, uint256 startedAt, uint256 updatedAt,
function getRoundData( uint80 _roundId ) external view returns ( uint80 roundId, int256 answer, uint256 startedAt, uint256 updatedAt,
27,182
70
// Used in cases where we want the user to be able to withdraw all the money they have committed to the game (Expired and Cancelled states).
function _processFullWithdrawalForAllOfUsersPositions( uint256 gameId_, uint256 gameOptions_
function _processFullWithdrawalForAllOfUsersPositions( uint256 gameId_, uint256 gameOptions_
23,296
129
// 1. skip 0 amount 2. handle ETH transfer
function universalTransfer( IERC20 token, address payable to, uint256 amount
function universalTransfer( IERC20 token, address payable to, uint256 amount
19,698
57
// Fetches a DashboardStake for the ApeCoin poolreturn dashboardStake A dashboardStake struct _address An Ethereum address /
function getApeCoinStake(address _address) public view returns (DashboardStake memory) { uint256 tokenId = 0; uint256 deposited = addressPosition[_address].stakedAmount; uint256 unclaimed = deposited > 0 ? this.pendingRewards(0, _address, tokenId) : 0; uint256 rewards24Hrs = deposited > 0 ? _estimate24HourRewards(0, _address, 0) : 0; return DashboardStake(APECOIN_POOL_ID, tokenId, deposited, unclaimed, rewards24Hrs, NULL_PAIR); }
function getApeCoinStake(address _address) public view returns (DashboardStake memory) { uint256 tokenId = 0; uint256 deposited = addressPosition[_address].stakedAmount; uint256 unclaimed = deposited > 0 ? this.pendingRewards(0, _address, tokenId) : 0; uint256 rewards24Hrs = deposited > 0 ? _estimate24HourRewards(0, _address, 0) : 0; return DashboardStake(APECOIN_POOL_ID, tokenId, deposited, unclaimed, rewards24Hrs, NULL_PAIR); }
22,502
255
// MakerDAO CDP actions
uint256 constant RAY = 10 ** 27;
uint256 constant RAY = 10 ** 27;
45,748
46
// In order to keep backwards compatibility we have kept the userseed field around. We remove the use of it because given that the blockhashenters later, it overrides whatever randomness the used seed provides.Given that it adds no security, and can easily lead to misunderstandings,we have removed it from usage and can now provide a simpler API. /
uint256 constant private USER_SEED_PLACEHOLDER = 0;
uint256 constant private USER_SEED_PLACEHOLDER = 0;
48,162
106
// swap tokens for native currency
swapTokensForNative(half); // <- this breaks the native currency -> swap when swap and liquify is triggered
swapTokensForNative(half); // <- this breaks the native currency -> swap when swap and liquify is triggered
920
15
// Unallocated Collateral Dollar Value (E18)
allocations[1] = freeColDolVal();
allocations[1] = freeColDolVal();
15,740
3
// ------------------------------------------------------------------------ Owner can initiate transfer of contract to a new owner ------------------------------------------------------------------------
function transferOwnership(address _newOwner) onlyOwner { newOwner = _newOwner; }
function transferOwnership(address _newOwner) onlyOwner { newOwner = _newOwner; }
27,096
71
// isOwnerProviderOrDelegate check whether msg.sender is owner, provider ordelegate for a DID given _did refers to decentralized identifier (a bytes32 length ID).return boolean true if yes /
function isOwnerProviderOrDelegate( bytes32 _did ) public view returns (bool)
function isOwnerProviderOrDelegate( bytes32 _did ) public view returns (bool)
11,361
16
// Query the default royalty receiver and percentage./ return Tuple containing the default royalty recipient and percentage out of 10_000
function getDefaultRoyaltyRecipientAndPercentage() external view returns (address, uint256) { return (_defaultRecipient, _defaultPercentage); }
function getDefaultRoyaltyRecipientAndPercentage() external view returns (address, uint256) { return (_defaultRecipient, _defaultPercentage); }
36,730
289
// amount needs to be subtracted from totalBalance because it has already been added to it from either IWETH.deposit and IERC20.safeTransferFrom
uint256 total = totalWithDepositedAmount.sub(amount); uint256 shareSupply = totalSupply();
uint256 total = totalWithDepositedAmount.sub(amount); uint256 shareSupply = totalSupply();
63,611
15
// Events (for use in frontend)
event Deposit(address founder, uint256 amount); event Withdraw(address funder, uint256 amount);
event Deposit(address founder, uint256 amount); event Withdraw(address funder, uint256 amount);
32,314
206
// Set the creator registry address upon construction. Immutable.
function setCreatorRegistryStore(address _crsAddress) internal { ApprovedCreatorRegistryInterface candidateCreatorRegistryStore = ApprovedCreatorRegistryInterface(_crsAddress);
function setCreatorRegistryStore(address _crsAddress) internal { ApprovedCreatorRegistryInterface candidateCreatorRegistryStore = ApprovedCreatorRegistryInterface(_crsAddress);
81,541
168
// Append data we use later for hashingcfolioItem The token ID of the c-folio item current The current data being hashes return The current data, with internal data appended /
function appendHash(address cfolioItem, bytes calldata current) external view
function appendHash(address cfolioItem, bytes calldata current) external view
66,416
64
// Decodes message for allowing interchain connection.Returns structure `InterchainConnectionMessage`. /
function decodeInterchainConnectionMessage(bytes calldata data) internal pure returns (InterchainConnectionMessage memory)
function decodeInterchainConnectionMessage(bytes calldata data) internal pure returns (InterchainConnectionMessage memory)
36,755
121
// Token information tokenId % 1,000,000 = index of token (i.e. how many were minted before this token) (tokenId / 1,000,000) % 100 = week in which sacrificed occured (from game start) (tokenId / 100,000,000) = number of cultists remaining after sacrifice
let countdown := mod(div(tokenId, 1000000), 100)
let countdown := mod(div(tokenId, 1000000), 100)
80,883
629
//
// contract newBaseProxy { // bytes32 private constant implementPositon = keccak256("org.Finnexus.implementation.storage"); // bytes32 private constant proxyOwnerPosition = keccak256("org.Finnexus.Owner.storage"); // constructor(address implementation_) public { // // Creator of the contract is admin during initialization // _setProxyOwner(msg.sender); // _setImplementation(implementation_); // (bool success,) = implementation_.delegatecall(abi.encodeWithSignature("initialize()")); // require(success); // } // /** // * @dev Allows the current owner to transfer ownership // * @param _newOwner The address to transfer ownership to // */ // function transferProxyOwnership(address _newOwner) public onlyProxyOwner // { // require(_newOwner != address(0)); // _setProxyOwner(_newOwner); // } // function _setProxyOwner(address _newOwner) internal // { // bytes32 position = proxyOwnerPosition; // assembly { // sstore(position, _newOwner) // } // } // function proxyOwner() public view returns (address owner) { // bytes32 position = proxyOwnerPosition; // assembly { // owner := sload(position) // } // } // /** // * @dev Tells the address of the current implementation // * @return address of the current implementation // */ // function getImplementation() public view returns (address impl) { // bytes32 position = implementPositon; // assembly { // impl := sload(position) // } // } // function _setImplementation(address _newImplementation) internal // { // bytes32 position = implementPositon; // assembly { // sstore(position, _newImplementation) // } // } // function setImplementation(address _newImplementation)public onlyProxyOwner{ // address currentImplementation = getImplementation(); // require(currentImplementation != _newImplementation); // _setImplementation(_newImplementation); // (bool success,) = _newImplementation.delegatecall(abi.encodeWithSignature("update()")); // require(success); // } // /** // * @notice Delegates execution to the implementation contract // * @dev It returns to the external caller whatever the implementation returns or forwards reverts // * @param data The raw data to delegatecall // * @return The returned bytes from the delegatecall // */ // function delegateToImplementation(bytes memory data) public returns (bytes memory) { // (bool success, bytes memory returnData) = getImplementation().delegatecall(data); // assembly { // if eq(success, 0) { // revert(add(returnData, 0x20), returndatasize) // } // } // return returnData; // } // /** // * @notice Delegates execution to an implementation contract // * @dev It returns to the external caller whatever the implementation returns or forwards reverts // * There are an additional 2 prefix uints from the wrapper returndata, which we ignore since we make an extra hop. // * @param data The raw data to delegatecall // * @return The returned bytes from the delegatecall // */ // function delegateToViewImplementation(bytes memory data) public view returns (bytes memory) { // (bool success, bytes memory returnData) = address(this).staticcall(abi.encodeWithSignature("delegateToImplementation(bytes)", data)); // assembly { // if eq(success, 0) { // revert(add(returnData, 0x20), returndatasize) // } // } // return abi.decode(returnData, (bytes)); // } // function delegateToViewAndReturn() internal view returns (bytes memory) { // (bool success, ) = address(this).staticcall(abi.encodeWithSignature("delegateToImplementation(bytes)", 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(add(free_mem_ptr, 0x40), sub(returndatasize, 0x40)) } // } // } // function delegateAndReturn() internal returns (bytes memory) { // (bool success, ) = getImplementation().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) } // } // } // /** // * @dev Throws if called by any account other than the owner. // */ // modifier onlyProxyOwner() { // require (msg.sender == proxyOwner()); // _; // } // }
// contract newBaseProxy { // bytes32 private constant implementPositon = keccak256("org.Finnexus.implementation.storage"); // bytes32 private constant proxyOwnerPosition = keccak256("org.Finnexus.Owner.storage"); // constructor(address implementation_) public { // // Creator of the contract is admin during initialization // _setProxyOwner(msg.sender); // _setImplementation(implementation_); // (bool success,) = implementation_.delegatecall(abi.encodeWithSignature("initialize()")); // require(success); // } // /** // * @dev Allows the current owner to transfer ownership // * @param _newOwner The address to transfer ownership to // */ // function transferProxyOwnership(address _newOwner) public onlyProxyOwner // { // require(_newOwner != address(0)); // _setProxyOwner(_newOwner); // } // function _setProxyOwner(address _newOwner) internal // { // bytes32 position = proxyOwnerPosition; // assembly { // sstore(position, _newOwner) // } // } // function proxyOwner() public view returns (address owner) { // bytes32 position = proxyOwnerPosition; // assembly { // owner := sload(position) // } // } // /** // * @dev Tells the address of the current implementation // * @return address of the current implementation // */ // function getImplementation() public view returns (address impl) { // bytes32 position = implementPositon; // assembly { // impl := sload(position) // } // } // function _setImplementation(address _newImplementation) internal // { // bytes32 position = implementPositon; // assembly { // sstore(position, _newImplementation) // } // } // function setImplementation(address _newImplementation)public onlyProxyOwner{ // address currentImplementation = getImplementation(); // require(currentImplementation != _newImplementation); // _setImplementation(_newImplementation); // (bool success,) = _newImplementation.delegatecall(abi.encodeWithSignature("update()")); // require(success); // } // /** // * @notice Delegates execution to the implementation contract // * @dev It returns to the external caller whatever the implementation returns or forwards reverts // * @param data The raw data to delegatecall // * @return The returned bytes from the delegatecall // */ // function delegateToImplementation(bytes memory data) public returns (bytes memory) { // (bool success, bytes memory returnData) = getImplementation().delegatecall(data); // assembly { // if eq(success, 0) { // revert(add(returnData, 0x20), returndatasize) // } // } // return returnData; // } // /** // * @notice Delegates execution to an implementation contract // * @dev It returns to the external caller whatever the implementation returns or forwards reverts // * There are an additional 2 prefix uints from the wrapper returndata, which we ignore since we make an extra hop. // * @param data The raw data to delegatecall // * @return The returned bytes from the delegatecall // */ // function delegateToViewImplementation(bytes memory data) public view returns (bytes memory) { // (bool success, bytes memory returnData) = address(this).staticcall(abi.encodeWithSignature("delegateToImplementation(bytes)", data)); // assembly { // if eq(success, 0) { // revert(add(returnData, 0x20), returndatasize) // } // } // return abi.decode(returnData, (bytes)); // } // function delegateToViewAndReturn() internal view returns (bytes memory) { // (bool success, ) = address(this).staticcall(abi.encodeWithSignature("delegateToImplementation(bytes)", 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(add(free_mem_ptr, 0x40), sub(returndatasize, 0x40)) } // } // } // function delegateAndReturn() internal returns (bytes memory) { // (bool success, ) = getImplementation().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) } // } // } // /** // * @dev Throws if called by any account other than the owner. // */ // modifier onlyProxyOwner() { // require (msg.sender == proxyOwner()); // _; // } // }
74,669
41
// , arthxAmountPrecision
); collateralNeeded = ( collateralNeeded.mul( uint256(1e6).sub(_arthController.getRedemptionFee()) ) ) .div(1e6); uint256 arthxInputNeededD18 =
); collateralNeeded = ( collateralNeeded.mul( uint256(1e6).sub(_arthController.getRedemptionFee()) ) ) .div(1e6); uint256 arthxInputNeededD18 =
51,432
127
// Safe kimchi transfer function, just in case if rounding error causes pool to not have enough KIMCHIs.
function safeKimchiTransfer(address _to, uint256 _amount) internal { uint256 kimchiBal = kimchi.balanceOf(address(this)); if (_amount > kimchiBal) { kimchi.transfer(_to, kimchiBal); } else { kimchi.transfer(_to, _amount); } }
function safeKimchiTransfer(address _to, uint256 _amount) internal { uint256 kimchiBal = kimchi.balanceOf(address(this)); if (_amount > kimchiBal) { kimchi.transfer(_to, kimchiBal); } else { kimchi.transfer(_to, _amount); } }
7,951
8
// calculate the amount of token how much input token should be reimbursed
uint256 amountRequired = IUniswapV2Router(sourceRouter).getAmountsIn(amountToken, path1)[0];
uint256 amountRequired = IUniswapV2Router(sourceRouter).getAmountsIn(amountToken, path1)[0];
22,737
17
// extendDeadline(): allows the issuer to add more time to the/ bounty, allowing it to continue accepting fulfillments/_bountyId the index of the bounty/_newDeadline the new deadline in timestamp format
function extendDeadline(uint _bountyId, uint _newDeadline) public;
function extendDeadline(uint _bountyId, uint _newDeadline) public;
47,394
30
// called to exit a vault if the Squeeth Power Perp contracts are shutdown _crabAmount amount of strategy token to burn /
function withdrawShutdown(uint256 _crabAmount) external nonReentrant { require(powerTokenController.isShutDown(), "Squeeth contracts not shut down"); require(hasRedeemedInShutdown, "Crab must redeemShortShutdown"); uint256 strategyShare = _calcCrabRatio(_crabAmount, totalSupply()); uint256 ethToWithdraw = _calcEthToWithdraw(strategyShare, address(this).balance); _burn(msg.sender, _crabAmount); payable(msg.sender).sendValue(ethToWithdraw); emit WithdrawShutdown(msg.sender, _crabAmount, ethToWithdraw); }
function withdrawShutdown(uint256 _crabAmount) external nonReentrant { require(powerTokenController.isShutDown(), "Squeeth contracts not shut down"); require(hasRedeemedInShutdown, "Crab must redeemShortShutdown"); uint256 strategyShare = _calcCrabRatio(_crabAmount, totalSupply()); uint256 ethToWithdraw = _calcEthToWithdraw(strategyShare, address(this).balance); _burn(msg.sender, _crabAmount); payable(msg.sender).sendValue(ethToWithdraw); emit WithdrawShutdown(msg.sender, _crabAmount, ethToWithdraw); }
3,755
146
// The pricing plan determining the fee to be paid in NOKU tokens by customers for using Noku services
NokuPricingPlan public pricingPlan;
NokuPricingPlan public pricingPlan;
29,692
425
// Multiplier used to calculate the maximum repayAmount when liquidating a borrow /
uint public closeFactorMantissa;
uint public closeFactorMantissa;
7,599
179
// Get a snapshot of the account's balances, and the cached exchange rate This is used by comptroller to more efficiently perform liquidity checks. account Address of the account to snapshotreturn (possible error, token balance, borrow balance, exchange rate mantissa) /
function getAccountSnapshot(address account) external view returns (uint, uint, uint, uint) { uint cTokenBalance = accountTokens[account]; uint borrowBalance; uint exchangeRateMantissa; MathError mErr; (mErr, borrowBalance) = borrowBalanceStoredInternal(account); if (mErr != MathError.NO_ERROR) { return (uint(Error.MATH_ERROR), 0, 0, 0); } (mErr, exchangeRateMantissa) = exchangeRateStoredInternal(); if (mErr != MathError.NO_ERROR) { return (uint(Error.MATH_ERROR), 0, 0, 0); } return (uint(Error.NO_ERROR), cTokenBalance, borrowBalance, exchangeRateMantissa); }
function getAccountSnapshot(address account) external view returns (uint, uint, uint, uint) { uint cTokenBalance = accountTokens[account]; uint borrowBalance; uint exchangeRateMantissa; MathError mErr; (mErr, borrowBalance) = borrowBalanceStoredInternal(account); if (mErr != MathError.NO_ERROR) { return (uint(Error.MATH_ERROR), 0, 0, 0); } (mErr, exchangeRateMantissa) = exchangeRateStoredInternal(); if (mErr != MathError.NO_ERROR) { return (uint(Error.MATH_ERROR), 0, 0, 0); } return (uint(Error.NO_ERROR), cTokenBalance, borrowBalance, exchangeRateMantissa); }
41,723
71
// require(updateLCtimeout > now)
require(Channels[_lcID].isOpen, "LC is closed."); require(virtualChannels[_vcID].isInSettlementState, "VC is not in settlement state."); require(virtualChannels[_vcID].updateVCtimeout < now, "Update vc timeout has not elapsed."); require(!virtualChannels[_vcID].isClose, "VC is already closed");
require(Channels[_lcID].isOpen, "LC is closed."); require(virtualChannels[_vcID].isInSettlementState, "VC is not in settlement state."); require(virtualChannels[_vcID].updateVCtimeout < now, "Update vc timeout has not elapsed."); require(!virtualChannels[_vcID].isClose, "VC is already closed");
30,348
48
// The owner is rating the guest
require(booking.guestRating == 0, 'Guest already rated, cannot re-rate');
require(booking.guestRating == 0, 'Guest already rated, cannot re-rate');
28,302
18
// swap T-NFTs for ETH/_tokenIds the token Ids of T-NFTs
function swapTNftForEth(uint256[] calldata _tokenIds) external onlyOwner { require(totalValueInLp >= 30 ether * _tokenIds.length, "not enough ETH in LP"); uint128 amount = uint128(30 ether * _tokenIds.length); totalValueOutOfLp += amount; totalValueInLp -= amount; address owner = owner(); for (uint256 i = 0; i < _tokenIds.length; i++) { tNft.transferFrom(owner, address(this), _tokenIds[i]); } (bool sent, ) = address(owner).call{value: amount}(""); require(sent, "Failed to send Ether"); }
function swapTNftForEth(uint256[] calldata _tokenIds) external onlyOwner { require(totalValueInLp >= 30 ether * _tokenIds.length, "not enough ETH in LP"); uint128 amount = uint128(30 ether * _tokenIds.length); totalValueOutOfLp += amount; totalValueInLp -= amount; address owner = owner(); for (uint256 i = 0; i < _tokenIds.length; i++) { tNft.transferFrom(owner, address(this), _tokenIds[i]); } (bool sent, ) = address(owner).call{value: amount}(""); require(sent, "Failed to send Ether"); }
15,005
6
// Set a maximum value that a variable can hold. This is done to ensure that the token supply remains within a certain limit.
uint256 private constant MAX_TOKEN_SUPPLY = ~uint256(0);
uint256 private constant MAX_TOKEN_SUPPLY = ~uint256(0);
5,177
113
// Distribute rewards based on vesper pool balance and supply
contract PoolRewards is Initializable, IPoolRewards, ReentrancyGuard, PoolRewardsStorage { string public constant VERSION = "3.0.13"; using SafeERC20 for IERC20; /** * @dev Called by proxy to initialize this contract * @param _pool Vesper pool address * @param _rewardTokens Array of reward token addresses */ function initialize(address _pool, address[] memory _rewardTokens) public initializer { require(_pool != address(0), "pool-address-is-zero"); require(_rewardTokens.length != 0, "invalid-reward-tokens"); pool = _pool; rewardTokens = _rewardTokens; for (uint256 i = 0; i < _rewardTokens.length; i++) { isRewardToken[_rewardTokens[i]] = true; } } modifier onlyAuthorized() { require(msg.sender == IVesperPool(pool).governor(), "not-authorized"); _; } /** * @notice Notify that reward is added. Only authorized caller can call * @dev Also updates reward rate and reward earning period. * @param _rewardTokens Tokens being rewarded * @param _rewardAmounts Rewards amount for token on same index in rewardTokens array * @param _rewardDurations Duration for which reward will be distributed */ function notifyRewardAmount( address[] memory _rewardTokens, uint256[] memory _rewardAmounts, uint256[] memory _rewardDurations ) external virtual override onlyAuthorized { _notifyRewardAmount(_rewardTokens, _rewardAmounts, _rewardDurations, IERC20(pool).totalSupply()); } function notifyRewardAmount( address _rewardToken, uint256 _rewardAmount, uint256 _rewardDuration ) external virtual override onlyAuthorized { _notifyRewardAmount(_rewardToken, _rewardAmount, _rewardDuration, IERC20(pool).totalSupply()); } /// @notice Add new reward token in existing rewardsToken array function addRewardToken(address _newRewardToken) external onlyAuthorized { require(_newRewardToken != address(0), "reward-token-address-zero"); require(!isRewardToken[_newRewardToken], "reward-token-already-exist"); emit RewardTokenAdded(_newRewardToken, rewardTokens); rewardTokens.push(_newRewardToken); isRewardToken[_newRewardToken] = true; } /** * @notice Claim earned rewards. * @dev This function will claim rewards for all tokens being rewarded */ function claimReward(address _account) external override nonReentrant { uint256 _totalSupply = IERC20(pool).totalSupply(); uint256 _balance = IERC20(pool).balanceOf(_account); uint256 _len = rewardTokens.length; for (uint256 i = 0; i < _len; i++) { address _rewardToken = rewardTokens[i]; _updateReward(_rewardToken, _account, _totalSupply, _balance); // Claim rewards uint256 reward = rewards[_rewardToken][_account]; if (reward != 0 && reward <= IERC20(_rewardToken).balanceOf(address(this))) { rewards[_rewardToken][_account] = 0; IERC20(_rewardToken).safeTransfer(_account, reward); emit RewardPaid(_account, _rewardToken, reward); } } } /** * @notice Updated reward for given account. Only Pool can call */ function updateReward(address _account) external override { require(msg.sender == pool, "only-pool-can-update-reward"); uint256 _totalSupply = IERC20(pool).totalSupply(); uint256 _balance = IERC20(pool).balanceOf(_account); uint256 _len = rewardTokens.length; for (uint256 i = 0; i < _len; i++) { _updateReward(rewardTokens[i], _account, _totalSupply, _balance); } } /** * @notice Returns claimable reward amount. * @return _rewardTokens Array of tokens being rewarded * @return _claimableAmounts Array of claimable for token on same index in rewardTokens */ function claimable(address _account) external view override returns (address[] memory _rewardTokens, uint256[] memory _claimableAmounts) { uint256 _totalSupply = IERC20(pool).totalSupply(); uint256 _balance = IERC20(pool).balanceOf(_account); uint256 _len = rewardTokens.length; _claimableAmounts = new uint256[](_len); for (uint256 i = 0; i < _len; i++) { _claimableAmounts[i] = _claimable(rewardTokens[i], _account, _totalSupply, _balance); } _rewardTokens = rewardTokens; } /// @notice Provides easy access to all rewardTokens function getRewardTokens() external view returns (address[] memory) { return rewardTokens; } /// @notice Returns timestamp of last reward update function lastTimeRewardApplicable(address _rewardToken) public view override returns (uint256) { return block.timestamp < periodFinish[_rewardToken] ? block.timestamp : periodFinish[_rewardToken]; } function rewardForDuration() external view override returns (address[] memory _rewardTokens, uint256[] memory _rewardForDuration) { uint256 _len = rewardTokens.length; _rewardForDuration = new uint256[](_len); for (uint256 i = 0; i < _len; i++) { _rewardForDuration[i] = rewardRates[rewardTokens[i]] * rewardDuration[rewardTokens[i]]; } _rewardTokens = rewardTokens; } /** * @notice Rewards rate per pool token * @return _rewardTokens Array of tokens being rewarded * @return _rewardPerTokenRate Array of Rewards rate for token on same index in rewardTokens */ function rewardPerToken() external view override returns (address[] memory _rewardTokens, uint256[] memory _rewardPerTokenRate) { uint256 _totalSupply = IERC20(pool).totalSupply(); uint256 _len = rewardTokens.length; _rewardPerTokenRate = new uint256[](_len); for (uint256 i = 0; i < _len; i++) { _rewardPerTokenRate[i] = _rewardPerToken(rewardTokens[i], _totalSupply); } _rewardTokens = rewardTokens; } function _claimable( address _rewardToken, address _account, uint256 _totalSupply, uint256 _balance ) internal view returns (uint256) { uint256 _rewardPerTokenAvailable = _rewardPerToken(_rewardToken, _totalSupply) - userRewardPerTokenPaid[_rewardToken][_account]; uint256 _rewardsEarnedSinceLastUpdate = (_balance * _rewardPerTokenAvailable) / 1e18; return rewards[_rewardToken][_account] + _rewardsEarnedSinceLastUpdate; } // There are scenarios when extending contract will override external methods and // end up calling internal function. Hence providing internal functions function _notifyRewardAmount( address[] memory _rewardTokens, uint256[] memory _rewardAmounts, uint256[] memory _rewardDurations, uint256 _totalSupply ) internal { uint256 _len = _rewardTokens.length; uint256 _amountsLen = _rewardAmounts.length; uint256 _durationsLen = _rewardDurations.length; require(_len != 0, "invalid-reward-tokens"); require(_amountsLen != 0, "invalid-reward-amounts"); require(_durationsLen != 0, "invalid-reward-durations"); require(_len == _amountsLen && _len == _durationsLen, "array-length-mismatch"); for (uint256 i = 0; i < _len; i++) { _notifyRewardAmount(_rewardTokens[i], _rewardAmounts[i], _rewardDurations[i], _totalSupply); } } function _notifyRewardAmount( address _rewardToken, uint256 _rewardAmount, uint256 _rewardDuration, uint256 _totalSupply ) internal { require(_rewardToken != address(0), "incorrect-reward-token"); require(_rewardAmount != 0, "incorrect-reward-amount"); require(_rewardDuration != 0, "incorrect-reward-duration"); require(isRewardToken[_rewardToken], "invalid-reward-token"); // Update rewards earned so far rewardPerTokenStored[_rewardToken] = _rewardPerToken(_rewardToken, _totalSupply); if (block.timestamp >= periodFinish[_rewardToken]) { rewardRates[_rewardToken] = _rewardAmount / _rewardDuration; } else { uint256 remainingPeriod = periodFinish[_rewardToken] - block.timestamp; uint256 leftover = remainingPeriod * rewardRates[_rewardToken]; rewardRates[_rewardToken] = (_rewardAmount + leftover) / _rewardDuration; } // Safety check uint256 balance = IERC20(_rewardToken).balanceOf(address(this)); require(rewardRates[_rewardToken] <= (balance / _rewardDuration), "rewards-too-high"); // Start new drip time rewardDuration[_rewardToken] = _rewardDuration; lastUpdateTime[_rewardToken] = block.timestamp; periodFinish[_rewardToken] = block.timestamp + _rewardDuration; emit RewardAdded(_rewardToken, _rewardAmount, _rewardDuration); } function _rewardPerToken(address _rewardToken, uint256 _totalSupply) internal view returns (uint256) { if (_totalSupply == 0) { return rewardPerTokenStored[_rewardToken]; } uint256 _timeSinceLastUpdate = lastTimeRewardApplicable(_rewardToken) - lastUpdateTime[_rewardToken]; uint256 _rewardsSinceLastUpdate = _timeSinceLastUpdate * rewardRates[_rewardToken]; uint256 _rewardsPerTokenSinceLastUpdate = (_rewardsSinceLastUpdate * 1e18) / _totalSupply; return rewardPerTokenStored[_rewardToken] + _rewardsPerTokenSinceLastUpdate; } function _updateReward( address _rewardToken, address _account, uint256 _totalSupply, uint256 _balance ) internal { uint256 _rewardPerTokenStored = _rewardPerToken(_rewardToken, _totalSupply); rewardPerTokenStored[_rewardToken] = _rewardPerTokenStored; lastUpdateTime[_rewardToken] = lastTimeRewardApplicable(_rewardToken); if (_account != address(0)) { rewards[_rewardToken][_account] = _claimable(_rewardToken, _account, _totalSupply, _balance); userRewardPerTokenPaid[_rewardToken][_account] = _rewardPerTokenStored; } } }
contract PoolRewards is Initializable, IPoolRewards, ReentrancyGuard, PoolRewardsStorage { string public constant VERSION = "3.0.13"; using SafeERC20 for IERC20; /** * @dev Called by proxy to initialize this contract * @param _pool Vesper pool address * @param _rewardTokens Array of reward token addresses */ function initialize(address _pool, address[] memory _rewardTokens) public initializer { require(_pool != address(0), "pool-address-is-zero"); require(_rewardTokens.length != 0, "invalid-reward-tokens"); pool = _pool; rewardTokens = _rewardTokens; for (uint256 i = 0; i < _rewardTokens.length; i++) { isRewardToken[_rewardTokens[i]] = true; } } modifier onlyAuthorized() { require(msg.sender == IVesperPool(pool).governor(), "not-authorized"); _; } /** * @notice Notify that reward is added. Only authorized caller can call * @dev Also updates reward rate and reward earning period. * @param _rewardTokens Tokens being rewarded * @param _rewardAmounts Rewards amount for token on same index in rewardTokens array * @param _rewardDurations Duration for which reward will be distributed */ function notifyRewardAmount( address[] memory _rewardTokens, uint256[] memory _rewardAmounts, uint256[] memory _rewardDurations ) external virtual override onlyAuthorized { _notifyRewardAmount(_rewardTokens, _rewardAmounts, _rewardDurations, IERC20(pool).totalSupply()); } function notifyRewardAmount( address _rewardToken, uint256 _rewardAmount, uint256 _rewardDuration ) external virtual override onlyAuthorized { _notifyRewardAmount(_rewardToken, _rewardAmount, _rewardDuration, IERC20(pool).totalSupply()); } /// @notice Add new reward token in existing rewardsToken array function addRewardToken(address _newRewardToken) external onlyAuthorized { require(_newRewardToken != address(0), "reward-token-address-zero"); require(!isRewardToken[_newRewardToken], "reward-token-already-exist"); emit RewardTokenAdded(_newRewardToken, rewardTokens); rewardTokens.push(_newRewardToken); isRewardToken[_newRewardToken] = true; } /** * @notice Claim earned rewards. * @dev This function will claim rewards for all tokens being rewarded */ function claimReward(address _account) external override nonReentrant { uint256 _totalSupply = IERC20(pool).totalSupply(); uint256 _balance = IERC20(pool).balanceOf(_account); uint256 _len = rewardTokens.length; for (uint256 i = 0; i < _len; i++) { address _rewardToken = rewardTokens[i]; _updateReward(_rewardToken, _account, _totalSupply, _balance); // Claim rewards uint256 reward = rewards[_rewardToken][_account]; if (reward != 0 && reward <= IERC20(_rewardToken).balanceOf(address(this))) { rewards[_rewardToken][_account] = 0; IERC20(_rewardToken).safeTransfer(_account, reward); emit RewardPaid(_account, _rewardToken, reward); } } } /** * @notice Updated reward for given account. Only Pool can call */ function updateReward(address _account) external override { require(msg.sender == pool, "only-pool-can-update-reward"); uint256 _totalSupply = IERC20(pool).totalSupply(); uint256 _balance = IERC20(pool).balanceOf(_account); uint256 _len = rewardTokens.length; for (uint256 i = 0; i < _len; i++) { _updateReward(rewardTokens[i], _account, _totalSupply, _balance); } } /** * @notice Returns claimable reward amount. * @return _rewardTokens Array of tokens being rewarded * @return _claimableAmounts Array of claimable for token on same index in rewardTokens */ function claimable(address _account) external view override returns (address[] memory _rewardTokens, uint256[] memory _claimableAmounts) { uint256 _totalSupply = IERC20(pool).totalSupply(); uint256 _balance = IERC20(pool).balanceOf(_account); uint256 _len = rewardTokens.length; _claimableAmounts = new uint256[](_len); for (uint256 i = 0; i < _len; i++) { _claimableAmounts[i] = _claimable(rewardTokens[i], _account, _totalSupply, _balance); } _rewardTokens = rewardTokens; } /// @notice Provides easy access to all rewardTokens function getRewardTokens() external view returns (address[] memory) { return rewardTokens; } /// @notice Returns timestamp of last reward update function lastTimeRewardApplicable(address _rewardToken) public view override returns (uint256) { return block.timestamp < periodFinish[_rewardToken] ? block.timestamp : periodFinish[_rewardToken]; } function rewardForDuration() external view override returns (address[] memory _rewardTokens, uint256[] memory _rewardForDuration) { uint256 _len = rewardTokens.length; _rewardForDuration = new uint256[](_len); for (uint256 i = 0; i < _len; i++) { _rewardForDuration[i] = rewardRates[rewardTokens[i]] * rewardDuration[rewardTokens[i]]; } _rewardTokens = rewardTokens; } /** * @notice Rewards rate per pool token * @return _rewardTokens Array of tokens being rewarded * @return _rewardPerTokenRate Array of Rewards rate for token on same index in rewardTokens */ function rewardPerToken() external view override returns (address[] memory _rewardTokens, uint256[] memory _rewardPerTokenRate) { uint256 _totalSupply = IERC20(pool).totalSupply(); uint256 _len = rewardTokens.length; _rewardPerTokenRate = new uint256[](_len); for (uint256 i = 0; i < _len; i++) { _rewardPerTokenRate[i] = _rewardPerToken(rewardTokens[i], _totalSupply); } _rewardTokens = rewardTokens; } function _claimable( address _rewardToken, address _account, uint256 _totalSupply, uint256 _balance ) internal view returns (uint256) { uint256 _rewardPerTokenAvailable = _rewardPerToken(_rewardToken, _totalSupply) - userRewardPerTokenPaid[_rewardToken][_account]; uint256 _rewardsEarnedSinceLastUpdate = (_balance * _rewardPerTokenAvailable) / 1e18; return rewards[_rewardToken][_account] + _rewardsEarnedSinceLastUpdate; } // There are scenarios when extending contract will override external methods and // end up calling internal function. Hence providing internal functions function _notifyRewardAmount( address[] memory _rewardTokens, uint256[] memory _rewardAmounts, uint256[] memory _rewardDurations, uint256 _totalSupply ) internal { uint256 _len = _rewardTokens.length; uint256 _amountsLen = _rewardAmounts.length; uint256 _durationsLen = _rewardDurations.length; require(_len != 0, "invalid-reward-tokens"); require(_amountsLen != 0, "invalid-reward-amounts"); require(_durationsLen != 0, "invalid-reward-durations"); require(_len == _amountsLen && _len == _durationsLen, "array-length-mismatch"); for (uint256 i = 0; i < _len; i++) { _notifyRewardAmount(_rewardTokens[i], _rewardAmounts[i], _rewardDurations[i], _totalSupply); } } function _notifyRewardAmount( address _rewardToken, uint256 _rewardAmount, uint256 _rewardDuration, uint256 _totalSupply ) internal { require(_rewardToken != address(0), "incorrect-reward-token"); require(_rewardAmount != 0, "incorrect-reward-amount"); require(_rewardDuration != 0, "incorrect-reward-duration"); require(isRewardToken[_rewardToken], "invalid-reward-token"); // Update rewards earned so far rewardPerTokenStored[_rewardToken] = _rewardPerToken(_rewardToken, _totalSupply); if (block.timestamp >= periodFinish[_rewardToken]) { rewardRates[_rewardToken] = _rewardAmount / _rewardDuration; } else { uint256 remainingPeriod = periodFinish[_rewardToken] - block.timestamp; uint256 leftover = remainingPeriod * rewardRates[_rewardToken]; rewardRates[_rewardToken] = (_rewardAmount + leftover) / _rewardDuration; } // Safety check uint256 balance = IERC20(_rewardToken).balanceOf(address(this)); require(rewardRates[_rewardToken] <= (balance / _rewardDuration), "rewards-too-high"); // Start new drip time rewardDuration[_rewardToken] = _rewardDuration; lastUpdateTime[_rewardToken] = block.timestamp; periodFinish[_rewardToken] = block.timestamp + _rewardDuration; emit RewardAdded(_rewardToken, _rewardAmount, _rewardDuration); } function _rewardPerToken(address _rewardToken, uint256 _totalSupply) internal view returns (uint256) { if (_totalSupply == 0) { return rewardPerTokenStored[_rewardToken]; } uint256 _timeSinceLastUpdate = lastTimeRewardApplicable(_rewardToken) - lastUpdateTime[_rewardToken]; uint256 _rewardsSinceLastUpdate = _timeSinceLastUpdate * rewardRates[_rewardToken]; uint256 _rewardsPerTokenSinceLastUpdate = (_rewardsSinceLastUpdate * 1e18) / _totalSupply; return rewardPerTokenStored[_rewardToken] + _rewardsPerTokenSinceLastUpdate; } function _updateReward( address _rewardToken, address _account, uint256 _totalSupply, uint256 _balance ) internal { uint256 _rewardPerTokenStored = _rewardPerToken(_rewardToken, _totalSupply); rewardPerTokenStored[_rewardToken] = _rewardPerTokenStored; lastUpdateTime[_rewardToken] = lastTimeRewardApplicable(_rewardToken); if (_account != address(0)) { rewards[_rewardToken][_account] = _claimable(_rewardToken, _account, _totalSupply, _balance); userRewardPerTokenPaid[_rewardToken][_account] = _rewardPerTokenStored; } } }
83,776
44
// Burn token and get receipt in return./ This is the entrypoint for users to start ETH -> Substrate transfer./amount Amount of token to burn (a.k.a. transfer to substrate)./substrateRecipient AccountId on substrate side that will receive/ funds/Reverts with `BridgeInactive` if bridge is inactive/Reverts with underlying token's error if bridge is not approved to/manage funds or if caller has insufficient balance/Emits `OutgoingReceipt(sender, amount, substrateRecipient)` on success/Interacts with `token` contract
function burn(uint256 amount, bytes32 substrateRecipient) public { // CHECKS if (!bridgeActive) revert BridgeInactive(); // EFFECTS emit OutgoingReceipt(msg.sender, substrateRecipient, amount); // INTERACTIONS token.burn(msg.sender, amount); }
function burn(uint256 amount, bytes32 substrateRecipient) public { // CHECKS if (!bridgeActive) revert BridgeInactive(); // EFFECTS emit OutgoingReceipt(msg.sender, substrateRecipient, amount); // INTERACTIONS token.burn(msg.sender, amount); }
18,790
82
// Parent crowdsale contract extended with support for pausable crowdsale, meaning crowdsale can be paused by owner at any timeWhile the contract is in paused state, the contributions will be rejected /
contract PausableCrowdsale is Crowdsale, Pausable { function PausableCrowdsale(bool _paused) public { if (_paused) { pause(); } } // overriding Crowdsale#validPurchase to add extra paused logic // @return true if investors can buy at the moment function validPurchase() internal constant returns(bool) { return super.validPurchase() && !paused; } }
contract PausableCrowdsale is Crowdsale, Pausable { function PausableCrowdsale(bool _paused) public { if (_paused) { pause(); } } // overriding Crowdsale#validPurchase to add extra paused logic // @return true if investors can buy at the moment function validPurchase() internal constant returns(bool) { return super.validPurchase() && !paused; } }
7,320
33
// 10% of the total Ether sent is used to pay existing holders.
var fee = mul(div(msg.value, 20), 4);
var fee = mul(div(msg.value, 20), 4);
24,831
5
// Modifer to see if a certain transcation is valid when only owner modifier allowes it
modifier onlyOwner(){ require(contractOwner == msg.sender, "Sender not Authorized"); _; }
modifier onlyOwner(){ require(contractOwner == msg.sender, "Sender not Authorized"); _; }
45,236
146
// Returns an URI for a contract /
function toString(address _addr) public pure returns (string memory) { bytes32 value = bytes32(uint256(_addr)); bytes memory alphabet = "0123456789abcdef"; bytes memory str = new bytes(42); str[0] = "0"; str[1] = "x"; for (uint i = 0; i < 20; i++) { str[2+i*2] = alphabet[uint(uint8(value[i + 12] >> 4))]; str[3+i*2] = alphabet[uint(uint8(value[i + 12] & 0x0f))]; } return string(str); }
function toString(address _addr) public pure returns (string memory) { bytes32 value = bytes32(uint256(_addr)); bytes memory alphabet = "0123456789abcdef"; bytes memory str = new bytes(42); str[0] = "0"; str[1] = "x"; for (uint i = 0; i < 20; i++) { str[2+i*2] = alphabet[uint(uint8(value[i + 12] >> 4))]; str[3+i*2] = alphabet[uint(uint8(value[i + 12] & 0x0f))]; } return string(str); }
19,991
5
// msg est ce que l'on va envoyer depuis le front
uint256 amount= msg.value; Campaign storage campaign = campaigns[_id]; campaign.donators.push(msg.sender); campaign.donations.push(amount);
uint256 amount= msg.value; Campaign storage campaign = campaigns[_id]; campaign.donators.push(msg.sender); campaign.donations.push(amount);
31,681
215
// Support market here in the Comptroller
uint256 err = _supportMarket(cToken);
uint256 err = _supportMarket(cToken);
23,490
3
// the current crate id
uint16 public crateId; mapping(uint16 crateId => uint16 tokenId) internal crateWinningToken;
uint16 public crateId; mapping(uint16 crateId => uint16 tokenId) internal crateWinningToken;
3,001
34
// swap
{ (address input, address output) = (ETH_ADDRESS, toTokenContract); (address token0, ) = sortTokens(input, output); IUniswapV2Pair pair = IUniswapV2Pair(pairFor(input, output)); uint amountInput; uint amountOutput; {
{ (address input, address output) = (ETH_ADDRESS, toTokenContract); (address token0, ) = sortTokens(input, output); IUniswapV2Pair pair = IUniswapV2Pair(pairFor(input, output)); uint amountInput; uint amountOutput; {
13,079
121
// Standard ERC20 token with Short Hand Attack and approve() race condition mitigation. Based on code by FirstBlood: /
contract StandardToken is ERC20, SafeMath { /* Token supply got increased and a new owner received these tokens */ event Minted(address receiver, uint amount); /* Actual balances of token holders */ mapping(address => uint) balances; /* approve() allowances */ mapping (address => mapping (address => uint)) allowed; /* Interface declaration */ function isToken() public constant returns (bool weAre) { return true; } function transfer(address _to, uint _value) returns (bool success) { balances[msg.sender] = safeSub(balances[msg.sender], _value); balances[_to] = safeAdd(balances[_to], _value); Transfer(msg.sender, _to, _value); return true; } function transferFrom(address _from, address _to, uint _value) returns (bool success) { uint _allowance = allowed[_from][msg.sender]; balances[_to] = safeAdd(balances[_to], _value); balances[_from] = safeSub(balances[_from], _value); allowed[_from][msg.sender] = safeSub(_allowance, _value); Transfer(_from, _to, _value); return true; } function balanceOf(address _owner) constant returns (uint balance) { return balances[_owner]; } function approve(address _spender, uint _value) returns (bool success) { // To change the approve amount you first have to reduce the addresses` // allowance to zero by calling `approve(_spender, 0)` if it is not // already 0 to mitigate the race condition described here: // https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 if ((_value != 0) && (allowed[msg.sender][_spender] != 0)) throw; allowed[msg.sender][_spender] = _value; Approval(msg.sender, _spender, _value); return true; } function allowance(address _owner, address _spender) constant returns (uint remaining) { return allowed[_owner][_spender]; } }
contract StandardToken is ERC20, SafeMath { /* Token supply got increased and a new owner received these tokens */ event Minted(address receiver, uint amount); /* Actual balances of token holders */ mapping(address => uint) balances; /* approve() allowances */ mapping (address => mapping (address => uint)) allowed; /* Interface declaration */ function isToken() public constant returns (bool weAre) { return true; } function transfer(address _to, uint _value) returns (bool success) { balances[msg.sender] = safeSub(balances[msg.sender], _value); balances[_to] = safeAdd(balances[_to], _value); Transfer(msg.sender, _to, _value); return true; } function transferFrom(address _from, address _to, uint _value) returns (bool success) { uint _allowance = allowed[_from][msg.sender]; balances[_to] = safeAdd(balances[_to], _value); balances[_from] = safeSub(balances[_from], _value); allowed[_from][msg.sender] = safeSub(_allowance, _value); Transfer(_from, _to, _value); return true; } function balanceOf(address _owner) constant returns (uint balance) { return balances[_owner]; } function approve(address _spender, uint _value) returns (bool success) { // To change the approve amount you first have to reduce the addresses` // allowance to zero by calling `approve(_spender, 0)` if it is not // already 0 to mitigate the race condition described here: // https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 if ((_value != 0) && (allowed[msg.sender][_spender] != 0)) throw; allowed[msg.sender][_spender] = _value; Approval(msg.sender, _spender, _value); return true; } function allowance(address _owner, address _spender) constant returns (uint remaining) { return allowed[_owner][_spender]; } }
13,886
32
// adding right origin fees
for (uint256 i; i < originRight.length; i++) { result = result + originRight[i].value; }
for (uint256 i; i < originRight.length; i++) { result = result + originRight[i].value; }
16,418
77
// increment the totalRecyclableWaste field of the citizen by the weight of trash bag citizens[_generator].totalRecyclableWaste += wasteWeight; ideally we would use the SafeMath method .add() for this addition
citizens[_generator].totalRecyclableWaste.add(_wasteWeight);
citizens[_generator].totalRecyclableWaste.add(_wasteWeight);
43,681
204
// Syscoin block is not in superblock
emit RelayTransaction(bytes32(0), ERR_SUPERBLOCK); return ERR_SUPERBLOCK;
emit RelayTransaction(bytes32(0), ERR_SUPERBLOCK); return ERR_SUPERBLOCK;
3,061
206
// set our keepCRV
keepCRV = 1000;
keepCRV = 1000;
34,894
222
// Interface to the contract responsible for controlling mint/burn
TokenControllerInterface public override controller;
TokenControllerInterface public override controller;
54,774
29
// Restricts the function to be only callable by the owner or admin of `edition`. edition The edition address. /
modifier onlyEditionOwnerOrAdmin(address edition) virtual { if ( msg.sender != OwnableRoles(edition).owner() && !OwnableRoles(edition).hasAnyRole(msg.sender, ISoundEditionV1(edition).ADMIN_ROLE()) ) revert Unauthorized(); _; }
modifier onlyEditionOwnerOrAdmin(address edition) virtual { if ( msg.sender != OwnableRoles(edition).owner() && !OwnableRoles(edition).hasAnyRole(msg.sender, ISoundEditionV1(edition).ADMIN_ROLE()) ) revert Unauthorized(); _; }
42,496
83
// Division of two int256 variables and fails on overflow. /
function div(int256 a, int256 b) internal pure returns (int256) { // Prevent overflow when dividing MIN_INT256 by -1 require(b != -1 || a != MIN_INT256); // Solidity already throws when dividing by 0. return a / b; }
function div(int256 a, int256 b) internal pure returns (int256) { // Prevent overflow when dividing MIN_INT256 by -1 require(b != -1 || a != MIN_INT256); // Solidity already throws when dividing by 0. return a / b; }
43,919
94
// change account's milestone policy. _from address for milestone policy applyed from. _prevPolicy index of original milestone policy. _newPolicy index of milestone policy to be changed. /
function modifyMilestoneFrom(address _from, uint8 _prevPolicy, uint8 _newPolicy) public onlyOwner returns (bool)
function modifyMilestoneFrom(address _from, uint8 _prevPolicy, uint8 _newPolicy) public onlyOwner returns (bool)
70,704
164
// Extend sale openingTime New opening time. closingTime New closing time. /
function extendTime(uint256 openingTime, uint256 closingTime) public onlyOwner
function extendTime(uint256 openingTime, uint256 closingTime) public onlyOwner
15,567
9
// withdrawas funds in contract to Farmtroller to be invested
function withdraw() external onlyOwner { uint balance = address(this).balance; payable(address(Farmtroller)).transfer(balance); }
function withdraw() external onlyOwner { uint balance = address(this).balance; payable(address(Farmtroller)).transfer(balance); }
31,744
8
// sale enabled.
bool private isSaleEnabled = false;
bool private isSaleEnabled = false;
58,903
61
// Returns the maximum amount of tokens available for loan. token The address of the token that is requested.return The amont of token that can be loaned. /
function maxFlashLoan(address token) public view override returns (uint256) { return token == address(this) ? type(uint256).max - TauForNativeBySomeordinarypoggers.totalSupply() : 0; }
function maxFlashLoan(address token) public view override returns (uint256) { return token == address(this) ? type(uint256).max - TauForNativeBySomeordinarypoggers.totalSupply() : 0; }
14,513
157
// The function used to determine how much asset is locked in the current action.this will impact the closepositionamount calculated from the vault. /
function currentLockedAsset() external view returns (uint256);
function currentLockedAsset() external view returns (uint256);
71,098
63
// Updates the AddressRegistry contract address. Admin role only. addressRegistryAddressRegistry contract address. /
function setAddressRegistry(IAddressRegistry addressRegistry) public onlyRole(DEFAULT_ADMIN_ROLE) { _addressRegistry = addressRegistry; }
function setAddressRegistry(IAddressRegistry addressRegistry) public onlyRole(DEFAULT_ADMIN_ROLE) { _addressRegistry = addressRegistry; }
24,607
1
// Initializes the RiskModule name_ Name of the Risk Module scrPercentage_ Solvency Capital Requirement percentage, to calculate ensuroFee_ % of premium that will go for Ensuro treasury (in ray) scrInterestRate_ cost of capital (in ray) maxScrPerPolicy_ Max SCR to be allocated to this module (in wad) scrLimit_ Max SCR to be allocated to this module (in wad) wallet_ Address of the RiskModule provider /
function initialize(
function initialize(
13,376
180
// Mint of specific poster type to address./
function mintType(address to, uint16 characterSheetTypeId, uint16 amount) public { if(!minters[msg.sender]) revert OnlyMintersCanMintCharacterSheets(); if(amount == 0) revert NoCharacterSheetMintAmountProvided(); uint256 tokenId = _nextTokenId; if(characterSheetTypeId >= characterSheetTypes.length) revert InvalidPurchaseCharacterSheetTypeId(); if(amount > characterSheetsLeft(characterSheetTypeId)) revert AllCharacterSheetsOfTypeMinted(); characterSheetTypes[characterSheetTypeId].minted += amount; for (uint16 i; i < amount; i++) { _tokenIdCharacterSheetTypes[tokenId++] = characterSheetTypeId; } _safeMint(to, amount, ''); }
function mintType(address to, uint16 characterSheetTypeId, uint16 amount) public { if(!minters[msg.sender]) revert OnlyMintersCanMintCharacterSheets(); if(amount == 0) revert NoCharacterSheetMintAmountProvided(); uint256 tokenId = _nextTokenId; if(characterSheetTypeId >= characterSheetTypes.length) revert InvalidPurchaseCharacterSheetTypeId(); if(amount > characterSheetsLeft(characterSheetTypeId)) revert AllCharacterSheetsOfTypeMinted(); characterSheetTypes[characterSheetTypeId].minted += amount; for (uint16 i; i < amount; i++) { _tokenIdCharacterSheetTypes[tokenId++] = characterSheetTypeId; } _safeMint(to, amount, ''); }
33,151
6
// store the params
g_storage = params;
g_storage = params;
21,521
184
// check if an ERC-20 contract is a valid payable contract for executing a mint._erc20TokenContract address of ERC-20 contract in question/
function isApprovedForERC20Payments(address _erc20TokenContract) public view returns(bool) { return allowedTokenContracts[_erc20TokenContract].isActive == true; }
function isApprovedForERC20Payments(address _erc20TokenContract) public view returns(bool) { return allowedTokenContracts[_erc20TokenContract].isActive == true; }
6,391
94
// if account has allow transfer permission then that account should be able to transfer tokens to other accounts with allow_deposit permission
bool allow_transfer;
bool allow_transfer;
16,435
7
// stake OHM for sOHM
IStaking internal immutable staking = IStaking(0xB63cac384247597756545b500253ff8E607a8020);
IStaking internal immutable staking = IStaking(0xB63cac384247597756545b500253ff8E607a8020);
17,160
1
// Emitted when blacklist admin remove account into blacklist
event BlacklistedRemoved(address indexed account);
event BlacklistedRemoved(address indexed account);
4,962
47
// Payout optional protocol fee
remainingProfit = _handleProtocolFeePayout(remainingProfit, offer.currency);
remainingProfit = _handleProtocolFeePayout(remainingProfit, offer.currency);
11,879
39
// Delete worked in test maybe not longer neededbasically deleting a trip
function reserveTripExternal(uint64 endTime, uint256 index) public
function reserveTripExternal(uint64 endTime, uint256 index) public
23,758
2
// Access
function createRole(bytes32 _role) external; function addRoleToAccount(address _address, bytes32 _role) external; function cleanRolesForAccount(address _address) external;
function createRole(bytes32 _role) external; function addRoleToAccount(address _address, bytes32 _role) external; function cleanRolesForAccount(address _address) external;
15,066
2
// Get Betting Game Address by `bettingGameId` /
function getBettingGameById(uint256 _bettingGameId) public view returns (address)
function getBettingGameById(uint256 _bettingGameId) public view returns (address)
30,180
113
// KNEEL PEON! KNEEL BEFORE YOUR MASTER! /
function worship() public payable onlyAwake { assembly { if gt(sload(timestampUntilNextEpoch.slot), add(timestamp(), 1)) { mstore(0x00, ERROR_SIG) mstore(0x04, 0x20) mstore(0x24, 8) mstore(0x44, 'Too Soon') revert(0x00, 0x64) } } uint256 score = currentEpochTotalSacrificed + placationCount; if (lastEpochTotalSacrificed >= score) { assembly { // emit Obliterate(_totalSupply) mstore(0x00, sload(_totalSupply.slot)) log1(0x00, 0x20, OBLITERATE_SIG) selfdestruct(0x00) // womp womp } } assembly { sstore(lastEpochTotalSacrificed.slot, sload(currentEpochTotalSacrificed.slot)) sstore(currentEpochTotalSacrificed.slot, 0) sstore(timestampUntilNextEpoch.slot, add(timestamp(), SECONDS_PER_WEEK)) sstore(doomCounter.slot, add(sload(doomCounter.slot), 1)) sstore(placationCount.slot, 0) } if (doomCounter == (WEEKS_UNTIL_OBLIVION + 1)) { obliterate(); } // emit Countdown(doomCounter) assembly { mstore(0x00, sload(doomCounter.slot)) log1(0x00, 0x20, COUNTDOWN_SIG) } }
function worship() public payable onlyAwake { assembly { if gt(sload(timestampUntilNextEpoch.slot), add(timestamp(), 1)) { mstore(0x00, ERROR_SIG) mstore(0x04, 0x20) mstore(0x24, 8) mstore(0x44, 'Too Soon') revert(0x00, 0x64) } } uint256 score = currentEpochTotalSacrificed + placationCount; if (lastEpochTotalSacrificed >= score) { assembly { // emit Obliterate(_totalSupply) mstore(0x00, sload(_totalSupply.slot)) log1(0x00, 0x20, OBLITERATE_SIG) selfdestruct(0x00) // womp womp } } assembly { sstore(lastEpochTotalSacrificed.slot, sload(currentEpochTotalSacrificed.slot)) sstore(currentEpochTotalSacrificed.slot, 0) sstore(timestampUntilNextEpoch.slot, add(timestamp(), SECONDS_PER_WEEK)) sstore(doomCounter.slot, add(sload(doomCounter.slot), 1)) sstore(placationCount.slot, 0) } if (doomCounter == (WEEKS_UNTIL_OBLIVION + 1)) { obliterate(); } // emit Countdown(doomCounter) assembly { mstore(0x00, sload(doomCounter.slot)) log1(0x00, 0x20, COUNTDOWN_SIG) } }
17,594
33
// Swap tokens for BNB.
swapTokensForBNB(halfForBNB);
swapTokensForBNB(halfForBNB);
1,688