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
143
// Auction start price is fair value minus half price range to center the auction at fair value
uint256 auctionStartPrice = fairValue.sub(halfPriceRange);
uint256 auctionStartPrice = fairValue.sub(halfPriceRange);
32,753
73
// Calculate share (member / totaltokens)
return (factoredWeight + factoredContributed) * totalTokensReceived / (factoredTotalWeight + factoredTotalContributed);
return (factoredWeight + factoredContributed) * totalTokensReceived / (factoredTotalWeight + factoredTotalContributed);
54,458
8
// Transfers the ownership of an NFT from one address to another address/Throws unless `msg.sender` is the current owner, an authorized/operator, or the approved address for this NFT. Throws if `_from` is/not the current owner. Throws if `_to` is the zero address. Throws if/`_tokenId` is not a valid NFT. When transfer ...
function safeTransferFrom(address _from, address _to, uint256 _tokenId, bytes memory _data) public { _transfer(_from, _to, _tokenId); require(_checkOnERC721Received(_from, _to, _tokenId, _data), "Transfer to non ERC721 receiver"); }
function safeTransferFrom(address _from, address _to, uint256 _tokenId, bytes memory _data) public { _transfer(_from, _to, _tokenId); require(_checkOnERC721Received(_from, _to, _tokenId, _data), "Transfer to non ERC721 receiver"); }
50,479
1
// Prevents a contract from calling itself, directly or indirectly. If you mark a function `nonReentrant`, you should alsomark it `external`. Calling one nonReentrant function fromanother is not supported. Instead, you can implement a`private` function doing the actual work, and a `external`wrapper marked as `nonReentr...
modifier nonReentrant() { require(!reentrancyLock); reentrancyLock = true; _; reentrancyLock = false; }
modifier nonReentrant() { require(!reentrancyLock); reentrancyLock = true; _; reentrancyLock = false; }
6,755
398
// reference to the Staking for choosing random Dog thieves
IStaking public staking;
IStaking public staking;
12,735
2
// 0: bg 1: back 2: body 3: hat 4: face 5: front 6: 1_1
uint24[7] public _layerByteBoundaries = [3320, 3655, 85316, 138435, 168455, 169590, 201423]; uint8[] public _faceMaskingList = [39];
uint24[7] public _layerByteBoundaries = [3320, 3655, 85316, 138435, 168455, 169590, 201423]; uint8[] public _faceMaskingList = [39];
31,583
71
// Mints new tokens, increasing totalSupply, and a users balance.Limited to onlyMinter modifier/
function mint(address to, uint256 amount) external onlyMinter returns (bool)
function mint(address to, uint256 amount) external onlyMinter returns (bool)
12,610
148
// Emit this event when the owner changes the standard sale's packPrice.
event StandardPackPriceChanged(uint256 packPrice);
event StandardPackPriceChanged(uint256 packPrice);
70,683
521
// returns provider's pending rewards requirements: - the specified program ids array needs to consist from unique and existing program ids with the same rewardtoken /
function pendingRewards(address provider, uint256[] calldata ids) external view returns (uint256);
function pendingRewards(address provider, uint256[] calldata ids) external view returns (uint256);
28,093
13
// Returns whether a Draw can be completed.return True if a Draw can be completed, false otherwise. /
function canCompleteDraw() external view returns (bool);
function canCompleteDraw() external view returns (bool);
24,663
5
// ToDo: create a sellTokens() function:
/*function sellTokens(uint amountToSell) public payable returns(uint ethAmount) { //yourToken.transferFrom(msg.sender, address(this), theAmount) require(msg.value > 0, "Tokens needed to get the eth!"); uint ethAmount = msg.value/tokensPerEth; uint256 sellerBalance = yourToken.balanceOf(msg.sender); ...
/*function sellTokens(uint amountToSell) public payable returns(uint ethAmount) { //yourToken.transferFrom(msg.sender, address(this), theAmount) require(msg.value > 0, "Tokens needed to get the eth!"); uint ethAmount = msg.value/tokensPerEth; uint256 sellerBalance = yourToken.balanceOf(msg.sender); ...
25,968
54
// token holders
address[] public holders;
address[] public holders;
51,831
18
// called by the governor to pause, triggers stopped state /
function pause() public onlyGovernor whenNotPaused { _pause(); }
function pause() public onlyGovernor whenNotPaused { _pause(); }
18,190
16
// Withdraw ERC20 Balance and transfer out to payoutAddressErc20/ tokenAddress ERC20 Token Address
function drainErc20Balance(address tokenAddress) external adminRequired nonReentrant{ uint256 amount; if (IERC20(tokenAddress).balanceOf(address(this)) > 0) { amount = IERC20(tokenAddress).balanceOf(address(this)); uint256 platfromCommission = ((amount * platformFeeBps) / 100...
function drainErc20Balance(address tokenAddress) external adminRequired nonReentrant{ uint256 amount; if (IERC20(tokenAddress).balanceOf(address(this)) > 0) { amount = IERC20(tokenAddress).balanceOf(address(this)); uint256 platfromCommission = ((amount * platformFeeBps) / 100...
22,321
51
// Sets `amount` as the allowance of `spender` over the caller's tokens. Returns a boolean value indicating whether the operation succeeded. IMPORTANT: Beware that changing an allowance with this method brings the risk that someone may use both the old and the new allowance by unfortunate transaction ordering. One poss...
function approve(address spender, uint256 amount) external returns (bool);
function approve(address spender, uint256 amount) external returns (bool);
4,311
82
// booster variables variables to keep track of totalSupply and balances (after accounting for multiplier)
uint256 public boostedTotalSupply; uint256 public lastBoostPurchase; // timestamp of lastBoostPurchase mapping(address => uint256) public boostedBalances; mapping(address => uint256) public numBoostersBought; // each booster = 5% increase in stake amt mapping(address => uint256) public nextBoostPurc...
uint256 public boostedTotalSupply; uint256 public lastBoostPurchase; // timestamp of lastBoostPurchase mapping(address => uint256) public boostedBalances; mapping(address => uint256) public numBoostersBought; // each booster = 5% increase in stake amt mapping(address => uint256) public nextBoostPurc...
55,125
414
// We write previously calculated values into storage //We invoke doTransferOut for the redeemer and the redeemAmount. Note: The cToken must handle variations between ERC-20 and ETH underlying. On success, the cToken has redeemAmount less of cash. doTransferOut reverts if anything goes wrong, since we can't be sure if ...
doTransferOut(redeemer, vars.redeemAmount, isNative);
doTransferOut(redeemer, vars.redeemAmount, isNative);
18,386
51
// HoldefiSettings contract/Holdefi Team/This contract is for Holdefi settings implementation
contract HoldefiSettings is HoldefiOwnable { using SafeMath for uint256; /// @notice Markets Features struct MarketSettings { bool isExist; // Market is exist or not bool isActive; // Market is open for deposit or not uint256 borrowRate; uint256 borrowRateUpdateTime; uint256 suppliersShareRate; uin...
contract HoldefiSettings is HoldefiOwnable { using SafeMath for uint256; /// @notice Markets Features struct MarketSettings { bool isExist; // Market is exist or not bool isActive; // Market is open for deposit or not uint256 borrowRate; uint256 borrowRateUpdateTime; uint256 suppliersShareRate; uin...
21,572
348
// Function a smart contract must implement to be able to consent to a loan. The loan offeringwill be generated off-chain. The "loan owner" address will own the loan-side of the resultingposition. If true is returned, and no errors are thrown by the Margin contract, the loan will haveoccurred. This means that verifyLoa...
function verifyLoanOffering( address[9] addresses, uint256[7] values256, uint32[4] values32, bytes32 positionId, bytes signature ) external
function verifyLoanOffering( address[9] addresses, uint256[7] values256, uint32[4] values32, bytes32 positionId, bytes signature ) external
17,855
1
// A coefficient used to normalize the token to a value comparable to the debt token. For example, if the underlying token is 8 decimals and the debt token is 18 decimals then the conversion factor will be 10^10. One unit of the underlying token will be comparably equal to one unit of the debt token.
uint256 conversionFactor;
uint256 conversionFactor;
10,811
221
// Modifier to make a function callable only when the contract is not paused.
modifier whenNotPaused() { require(!paused(), "Contract paused"); _; }
modifier whenNotPaused() { require(!paused(), "Contract paused"); _; }
24,914
3
// tracks owner of a fuelId
mapping(uint256 => address) public loaderOf;
mapping(uint256 => address) public loaderOf;
12,796
63
// Waste can be dumped only at allowed disposal stations
(bool result, uint station_id) = _checkFinalDestiantion(_latitude, _longitude); require(result == true);
(bool result, uint station_id) = _checkFinalDestiantion(_latitude, _longitude); require(result == true);
23,373
231
// Calculate for how long the token has been staked
uint256 stakedDays = (block.timestamp - conquestStart) / 24 / 60 / 60; uint256[3] memory periods = _stakingPeriods; uint256[3] memory rewards = _stakingRewards; if (stakedDays >= periods[2]) { return rewards[2]; } else if (stakedDays >= periods[1]) {
uint256 stakedDays = (block.timestamp - conquestStart) / 24 / 60 / 60; uint256[3] memory periods = _stakingPeriods; uint256[3] memory rewards = _stakingRewards; if (stakedDays >= periods[2]) { return rewards[2]; } else if (stakedDays >= periods[1]) {
40,426
84
// Tokens burned event /
event Burn(address from, uint256 amount);
event Burn(address from, uint256 amount);
28,783
49
// check settlement window
if (exerciseWindow == 0) revert PM_InvalidExerciseWindow(); (, uint8 underlyingId, uint8 strikeId, uint8 collateralId) = productId.parseProductId(); if (tokenType == TokenType.CALL && underlyingId != collateralId && !_isCollateralizable(underlyingId, collateralId)) { revert PM_Inva...
if (exerciseWindow == 0) revert PM_InvalidExerciseWindow(); (, uint8 underlyingId, uint8 strikeId, uint8 collateralId) = productId.parseProductId(); if (tokenType == TokenType.CALL && underlyingId != collateralId && !_isCollateralizable(underlyingId, collateralId)) { revert PM_Inva...
31,406
68
// Check rollback was effective
require(oldImplementation == _getImplementation(), "ERC1967Upgrade: upgrade breaks further upgrades");
require(oldImplementation == _getImplementation(), "ERC1967Upgrade: upgrade breaks further upgrades");
28,991
79
// attempt rageQuit notification
try IRageQuit(delegate).rageQuit{gas: RAGEQUIT_GAS}() {
try IRageQuit(delegate).rageQuit{gas: RAGEQUIT_GAS}() {
31,436
11
// Burns `_amount` reputation from `_owner`/_user The address that will lose the reputation/_amount The quantity of reputation to burn/ return True if the reputation are burned correctly
function burn(address _user, uint256 _amount) public returns (bool) { //user can burn his own rep other wise we check _canMint if (_user != _msgSender()) _canMint(); _burn(_user, _amount); return true; }
function burn(address _user, uint256 _amount) public returns (bool) { //user can burn his own rep other wise we check _canMint if (_user != _msgSender()) _canMint(); _burn(_user, _amount); return true; }
5,071
22
// emergency function in case a compromised locker is removed
function unlockIfRemovedLocker(uint256 tokenId) external override onlyOwner { if (!locked(tokenId)) { revert NotLockedAsset(); } if (_lockers[_lockedBy[tokenId]]) { revert NotADeactivatedLocker(); } delete _lockedBy[tokenId]; emit ForcefullyUnlocked(tokenId); }
function unlockIfRemovedLocker(uint256 tokenId) external override onlyOwner { if (!locked(tokenId)) { revert NotLockedAsset(); } if (_lockers[_lockedBy[tokenId]]) { revert NotADeactivatedLocker(); } delete _lockedBy[tokenId]; emit ForcefullyUnlocked(tokenId); }
37,845
10
// count all digits preceding least significant figure
numSigfigs++;
numSigfigs++;
16,476
6
// Changes the admin of the proxy. NOTE: Only the admin can call this function. /
function setAdmin(address _newAdmin) external ifAdmin { require(_newAdmin != address(0), "Cannot change the admin of a proxy to the zero address"); _setAdmin(_newAdmin); }
function setAdmin(address _newAdmin) external ifAdmin { require(_newAdmin != address(0), "Cannot change the admin of a proxy to the zero address"); _setAdmin(_newAdmin); }
17,295
15
// return entire purchased price if key is non-expiring
if (expirationDuration == type(uint).max) { return keyPrice; }
if (expirationDuration == type(uint).max) { return keyPrice; }
2,213
3
// Latest recorded promotion id. Starts at 0 and is incremented by 1 for each new promotion. So the first promotion will have id 1, the second 2, etc. /
uint256 internal _latestPromotionId;
uint256 internal _latestPromotionId;
24,910
112
// Reduce the balance of the account
balanceOf[account] = balanceOf[account] - amount;
balanceOf[account] = balanceOf[account] - amount;
24,318
18
// bytes32 constant MAIL_V2_TYPE_HASH = keccak256('MailV2(PersonV2 from,PersonV2[] to,string contents)PersonV2(string name,address[] wallet)'); bytes32 constant PERSON_V2_TYPE_HASH = keccak256('PersonV2(string name,address[] wallet)');
bytes32 constant Message_TYPE_HASH = keccak256('Message(string[] data)');
bytes32 constant Message_TYPE_HASH = keccak256('Message(string[] data)');
13,665
76
// formula: staker_burn = staker_stake / total_contract_stakecontract_burn reordered for precision loss prevention
_stakerBurnAmount = _currentStake.mul(_totalBurnAmount).div(_stakedOnContract); _newStake = _currentStake.sub(_stakerBurnAmount);
_stakerBurnAmount = _currentStake.mul(_totalBurnAmount).div(_stakedOnContract); _newStake = _currentStake.sub(_stakerBurnAmount);
21,529
129
// Calculate total amount of tokens being unlocked by now
uint totalUnlockedByNow = ((totalTimePassedFromUnlockingDay) / (30 days) + 1) * monthlyTransferAllowance;
uint totalUnlockedByNow = ((totalTimePassedFromUnlockingDay) / (30 days) + 1) * monthlyTransferAllowance;
49,436
79
// Return to user moneyEscrowed that wasn&39;t filled yet
if (_moneyEscrowed > 0) { ICash _denominationToken = _market.getDenominationToken(); require(_denominationToken.transferFrom(_market, _sender, _moneyEscrowed)); }
if (_moneyEscrowed > 0) { ICash _denominationToken = _market.getDenominationToken(); require(_denominationToken.transferFrom(_market, _sender, _moneyEscrowed)); }
52,637
466
// BalanceTrackable An ownable that has a balance tracker property /
contract BalanceTrackable is Ownable { // // Variables // ----------------------------------------------------------------------------------------------------------------- BalanceTracker public balanceTracker; bool public balanceTrackerFrozen; // // Events // ---------------------------...
contract BalanceTrackable is Ownable { // // Variables // ----------------------------------------------------------------------------------------------------------------- BalanceTracker public balanceTracker; bool public balanceTrackerFrozen; // // Events // ---------------------------...
21,993
23
// abi hash encode to bytes
require( ITssGroupManager(resolve("Proxy__TSS_GroupManager")).verifySign( keccak256(abi.encode(_batch, _shouldStartAtElement)), _signature), "verify signature failed" );
require( ITssGroupManager(resolve("Proxy__TSS_GroupManager")).verifySign( keccak256(abi.encode(_batch, _shouldStartAtElement)), _signature), "verify signature failed" );
15,519
77
// we can only defund BIT or MNT into the predefined treasury address
ERC20(_tokenAddress).safeTransfer(treasury, _amount); emit ContractDefunded(treasury, _tokenAddress, _amount);
ERC20(_tokenAddress).safeTransfer(treasury, _amount); emit ContractDefunded(treasury, _tokenAddress, _amount);
12,367
31
// Ensures the caller is the StakingAuRa contract address.
modifier onlyStakingContract() { require(msg.sender == address(stakingContract)); _; }
modifier onlyStakingContract() { require(msg.sender == address(stakingContract)); _; }
27,652
15
// the only type of liquidation where we do not need to involve swappa is: - collateral == loan asset - receiveAToken == false example is if someone deposited cUSD and borrowed cUSD
require(collateral == loanAsset, "no swap path defined, collateral must be equal to loan asset");
require(collateral == loanAsset, "no swap path defined, collateral must be equal to loan asset");
29,620
58
// Override exchange rate for daily bonuses
if (now < START_TIME + 3600 * 24 * 1) { exchangeRate = 10800; } else if (now < START_TIME + 3600 * 24 * 2) {
if (now < START_TIME + 3600 * 24 * 1) { exchangeRate = 10800; } else if (now < START_TIME + 3600 * 24 * 2) {
23,580
128
// Create a reusable template, which should be a JSON document./ Placeholders should use gettext() syntax, eg %s./Template data is only stored in the event logs, but its block number is kept in contract storage./content The template content/ return The ID of the newly-created template, which is created sequentially.
function createTemplate(string calldata content) external returns (uint256);
function createTemplate(string calldata content) external returns (uint256);
49,598
5
// Emitted when the fee BPS is changed for a given NFT.tokenId The token ID mapped to the NFT. newFeeBps The new fee BPS mapped to the NFT. /
event FeeBpsChanged(uint256 indexed tokenId, uint16 newFeeBps);
event FeeBpsChanged(uint256 indexed tokenId, uint16 newFeeBps);
39,290
249
// Limit token transfer until the TGE is over./
modifier tokenReleased(address _sender) { require(released); _; }
modifier tokenReleased(address _sender) { require(released); _; }
1,098
0
// Sets the initial storage of the contract. _owners List of Safe owners. _threshold Number of required confirmations for a Safe transaction. /
function setupOwners(address[] memory _owners, uint256 _threshold) internal {
function setupOwners(address[] memory _owners, uint256 _threshold) internal {
24,304
307
// User supplies assets into the market and receives sTokens in exchange Assumes interest has already been accrued up to the current block minter The address of the account which is supplying the assets mintAmount The amount of the underlying asset to supplyreturn (uint, uint) An error code (0=success, otherwise a fail...
function mintFresh(address minter, uint mintAmount) internal returns (uint, uint) { /* Fail if mint not allowed */ uint allowed = comptroller.mintAllowed(address(this), minter, mintAmount); if (allowed != 0) { return (failOpaque(Error.COMPTROLLER_REJECTION, FailureInfo.MINT_COMPT...
function mintFresh(address minter, uint mintAmount) internal returns (uint, uint) { /* Fail if mint not allowed */ uint allowed = comptroller.mintAllowed(address(this), minter, mintAmount); if (allowed != 0) { return (failOpaque(Error.COMPTROLLER_REJECTION, FailureInfo.MINT_COMPT...
56,819
211
// Burn the sold tokens (both front-end and back-end variants).
tokenSupply = tokenSupply.sub(_frontEndTokensToBurn); divTokenSupply = divTokenSupply.sub(_divTokensToBurn);
tokenSupply = tokenSupply.sub(_frontEndTokensToBurn); divTokenSupply = divTokenSupply.sub(_divTokensToBurn);
18,797
39
// Change the current bonus
function setCurrentBonus(uint256 _bonus) private { bonus = _bonus; return; }
function setCurrentBonus(uint256 _bonus) private { bonus = _bonus; return; }
4,570
77
// Divide delta by 1010 to bring it to 4 decimals for strike selection
if (sp >= st) { (d1, d2) = derivatives(t, v, sp, st); delta = Math.ncdf((Math.FIXED_1 * d1) / 1e18).div(10**10); } else {
if (sp >= st) { (d1, d2) = derivatives(t, v, sp, st); delta = Math.ncdf((Math.FIXED_1 * d1) / 1e18).div(10**10); } else {
35,500
288
// handle
punkBids[tokenId] = Bid(false, tokenId, address(0), 0); _safeTransfer(_msgSender(), bid.bidder, tokenId, "");
punkBids[tokenId] = Bid(false, tokenId, address(0), 0); _safeTransfer(_msgSender(), bid.bidder, tokenId, "");
27,085
2
// to set the merkle proof
function updateMerkleRoot(bytes32 newmerkleRoot) external onlyOwner { merkleRoot = newmerkleRoot; emit MerkleRootUpdated(merkleRoot); }
function updateMerkleRoot(bytes32 newmerkleRoot) external onlyOwner { merkleRoot = newmerkleRoot; emit MerkleRootUpdated(merkleRoot); }
29,892
16
// The COMP borrow index for each market for each borrower as of the last time they accrued COMP
mapping(address => mapping(address => uint)) public compBorrowerIndex;
mapping(address => mapping(address => uint)) public compBorrowerIndex;
25,712
57
// if the proposal spends 100% of guild bank balance for a token, decrement total guild bank tokens
if (userTokenBalances[GUILD][proposal.paymentToken] == 0 && proposal.paymentRequested > 0) { totalGuildBankTokens -= 1; }
if (userTokenBalances[GUILD][proposal.paymentToken] == 0 && proposal.paymentRequested > 0) { totalGuildBankTokens -= 1; }
18,116
50
// See {recover}. /
function toEthSignedMessageHash(bytes32 hash) internal pure returns (bytes32) {
function toEthSignedMessageHash(bytes32 hash) internal pure returns (bytes32) {
65,357
284
// manage metadata changes and upgrades to v2 and minting new v2
contract ChildTAMAGManager is Ownable{ address public signerAddress; ITAMAG2 public newTamag; event TamagUpdated(uint256 tamagId, string tokenURI, uint256 traits, uint256 nounce); event TamagEquipAdd(uint256 tamagId, string tokenURI, uint256 equipId, uint256 slot, uint256 nounce); event TamagEq...
contract ChildTAMAGManager is Ownable{ address public signerAddress; ITAMAG2 public newTamag; event TamagUpdated(uint256 tamagId, string tokenURI, uint256 traits, uint256 nounce); event TamagEquipAdd(uint256 tamagId, string tokenURI, uint256 equipId, uint256 slot, uint256 nounce); event TamagEq...
24,134
137
// File: @airswap/delegate/contracts/DelegateFactory.sol//
contract DelegateFactory is IDelegateFactory, ILocatorWhitelist { // Mapping specifying whether an address was deployed by this factory mapping(address => bool) internal _deployedAddresses; // The swap and indexer contracts to use in the deployment of Delegates ISwap public swapContract; IIndexer public index...
contract DelegateFactory is IDelegateFactory, ILocatorWhitelist { // Mapping specifying whether an address was deployed by this factory mapping(address => bool) internal _deployedAddresses; // The swap and indexer contracts to use in the deployment of Delegates ISwap public swapContract; IIndexer public index...
10,239
11
// 2 observations are needed to reliably calculate the block starting tick
require(observationCardinality > 1, 'NEO');
require(observationCardinality > 1, 'NEO');
32,194
51
// SafeERC20 Wrappers around ERC20 operations that throw on failure (when the tokencontract returns false). Tokens that return no value (and instead revert orthrow on failure) are also supported, non-reverting calls are assumed to besuccessful.To use this library you can add a `using SafeERC20 for ERC20;` statement to ...
library SafeERC20 { using SafeMath for uint256; function safeTransfer( IERC20 token, address to, uint256 value ) internal { _callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value)); } function safeTransferFrom( IERC20 token, ...
library SafeERC20 { using SafeMath for uint256; function safeTransfer( IERC20 token, address to, uint256 value ) internal { _callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value)); } function safeTransferFrom( IERC20 token, ...
23,251
114
// Resets the lottery, clears the existing state variable values and the lotterycan be initialized again. Emits {LotteryReset} event indicating that the lottery config and contract state is reset. Requirements: - Only the address set at `adminAddress` can call this function.- The Lottery has closed. /
function resetLottery() private {
function resetLottery() private {
30,201
266
// And may not be set to be shorter than a day.
uint constant MIN_FEE_PERIOD_DURATION_SECONDS = 1 days;
uint constant MIN_FEE_PERIOD_DURATION_SECONDS = 1 days;
81,461
89
// return return true(false) if order specified by `orderHash` is(not) cancelled/
function getCancel( bytes32 orderHash ) public view returns (bool)
function getCancel( bytes32 orderHash ) public view returns (bool)
13,272
45
// See {_burn} and {_approve}. /
function _burnFrom(address account, uint256 amount) internal { _burn(account, amount); _approve( account, _msgSender(), _allowances[account][_msgSender()].sub(amount, "BEP20: burn amount exceeds allowance") ); }
function _burnFrom(address account, uint256 amount) internal { _burn(account, amount); _approve( account, _msgSender(), _allowances[account][_msgSender()].sub(amount, "BEP20: burn amount exceeds allowance") ); }
926
151
// take the amount of dividends gained through this transaction, and allocates them evenly to each shareholder
profitPerShare_ += (_dividends * magnitude / tokenSupply_);
profitPerShare_ += (_dividends * magnitude / tokenSupply_);
24,595
0
// The name of this contract
string public constant NAME = 'Amphora Protocol Governor';
string public constant NAME = 'Amphora Protocol Governor';
29,064
3
// used to decouple insurance price and multiplier from data contract
uint256 amount; uint256 multiplier; bool credited;
uint256 amount; uint256 multiplier; bool credited;
44,398
18
// cancelProposal cancels the proposal if no one managed to vote yet must be sent from the proposal contract
function cancelProposal(uint256 proposalID) nonReentrant external { ProposalState storage prop = proposals[proposalID]; require(prop.params.proposalContract != address(0), "proposal with a given ID doesnt exist"); require(isInitialStatus(prop.status), "proposal isn't active"); requir...
function cancelProposal(uint256 proposalID) nonReentrant external { ProposalState storage prop = proposals[proposalID]; require(prop.params.proposalContract != address(0), "proposal with a given ID doesnt exist"); require(isInitialStatus(prop.status), "proposal isn't active"); requir...
7,087
275
// If the borrower is a credit account, check the credit limit instead of account liquidity.
if (creditLimit > 0) { (uint256 oErr, , uint256 borrowBalance, ) = CToken(cToken).getAccountSnapshot(borrower); require(oErr == 0, "snapshot error"); require(creditLimit >= add_(borrowBalance, borrowAmount), "insufficient credit limit"); } else {
if (creditLimit > 0) { (uint256 oErr, , uint256 borrowBalance, ) = CToken(cToken).getAccountSnapshot(borrower); require(oErr == 0, "snapshot error"); require(creditLimit >= add_(borrowBalance, borrowAmount), "insufficient credit limit"); } else {
50,954
1,142
// Emits an {CurrencyApproval} event. Requirements: - `currency` cannot be the zero address. 0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE will denote to native coin (eth,matic, and etc.) - `spender` cannot be the zero address./
function _approve( address currency, address spender, uint256 amount ) internal { require( currency != address(0), "CurrencyPermit: approve currency of zero address" ); require(
function _approve( address currency, address spender, uint256 amount ) internal { require( currency != address(0), "CurrencyPermit: approve currency of zero address" ); require(
30,787
8
// Get consensus values from request
( uint16 interestRate, uint16 collateralRatio, uint256 maxLoanAmount ) = LibConsensus.processLoanTerms(request); Loan storage loan = LibCreateLoan.initNewLoan( request.request.assetAddress, maxLoanAmount, request.request.dur...
( uint16 interestRate, uint16 collateralRatio, uint256 maxLoanAmount ) = LibConsensus.processLoanTerms(request); Loan storage loan = LibCreateLoan.initNewLoan( request.request.assetAddress, maxLoanAmount, request.request.dur...
49,951
2
// confirms that the caller is the guardian account/
modifier onlyGuardian { require(msg.sender == guardian, "invalid caller"); _; }
modifier onlyGuardian { require(msg.sender == guardian, "invalid caller"); _; }
10,984
27
// update length
mstore(stringPtr, add(currentStringLength, len)) mstore(0x40, mload(add(result, 0xa0))) mstore(0x60, mload(add(result, 0xc0))) mstore(0x80, mload(add(result, 0xe0))) mstore(0xa0, mload(add(result, 0x100))) mstore(0xc0, mload(add(result, 0x120))) mstore(0xe0, mload(add(result, ...
mstore(stringPtr, add(currentStringLength, len)) mstore(0x40, mload(add(result, 0xa0))) mstore(0x60, mload(add(result, 0xc0))) mstore(0x80, mload(add(result, 0xe0))) mstore(0xa0, mload(add(result, 0x100))) mstore(0xc0, mload(add(result, 0x120))) mstore(0xe0, mload(add(result, ...
43,452
6
// Events that the contract emits /
event StratHarvest(address indexed harvester); event StratRebalance(uint256 _borrowRate, uint256 _borrowDepth); constructor( address _want, address _borrow, address _native, uint256 _borrowRate,
event StratHarvest(address indexed harvester); event StratRebalance(uint256 _borrowRate, uint256 _borrowDepth); constructor( address _want, address _borrow, address _native, uint256 _borrowRate,
29,715
20
// function for applying accounts closing request
function ApplyToCloseAccount (address ClosingAccountAddress) public
function ApplyToCloseAccount (address ClosingAccountAddress) public
7,213
1
// Updates the base URL of tokenReverts if the sender is not owner _newURI New base URL /
function updateBaseTokenURI(string memory _newURI) public onlyOwner noEmergencyFreeze
function updateBaseTokenURI(string memory _newURI) public onlyOwner noEmergencyFreeze
65,719
27
// Add to the staked balance and total supply.
stakedBalanceOf[_holder][_projectId] = stakedBalanceOf[_holder][_projectId] + _amount; stakedTotalSupplyOf[_projectId] = stakedTotalSupplyOf[_projectId] + _amount;
stakedBalanceOf[_holder][_projectId] = stakedBalanceOf[_holder][_projectId] + _amount; stakedTotalSupplyOf[_projectId] = stakedTotalSupplyOf[_projectId] + _amount;
29,460
13
// 发放商品
IStoreOP(goods[goodsId].contractAddress).mint(msg.sender, quantity, goods[goodsId].data); goods[goodsId].quantitySold += uint32(quantity);
IStoreOP(goods[goodsId].contractAddress).mint(msg.sender, quantity, goods[goodsId].data); goods[goodsId].quantitySold += uint32(quantity);
29,708
469
// default to 10%
refundPenaltyBasisPoints = 1000;
refundPenaltyBasisPoints = 1000;
37,906
62
// Next emission point.
eid++;
eid++;
2,756
39
// overwrite _maxRepayLimit memory variable in order to prevent stack too deep error when emitting repay event
_maxRepayLimit = repaymentAmountAfterFees;
_maxRepayLimit = repaymentAmountAfterFees;
25,431
55
// Emits a {Transfer} event with `to` set to the zero address. Requirements: - `account` cannot be the zero address.- `account` must have at least `amount` tokens. /
function _burn(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: burn from the zero address"); _beforeTokenTransfer(account, address(0), amount); _balances[account] = _balances[account].sub( amount, "ERC20: burn amount exceed...
function _burn(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: burn from the zero address"); _beforeTokenTransfer(account, address(0), amount); _balances[account] = _balances[account].sub( amount, "ERC20: burn amount exceed...
545
95
// We need to swap the current tokens to ETH and send to the MarketingPool wallet
swapTokensForEth(contractTokenBalance); uint256 contractETHBalance = address(this).balance; if(contractETHBalance > 0) { sendETHToMarketingPool(address(this).balance); }
swapTokensForEth(contractTokenBalance); uint256 contractETHBalance = address(this).balance; if(contractETHBalance > 0) { sendETHToMarketingPool(address(this).balance); }
4,409
275
// Borrow the max borrowable amount.
borrowAmount = getBorrowableAmount(); if (borrowAmount != 0) { _borrow(borrowAmount); }
borrowAmount = getBorrowableAmount(); if (borrowAmount != 0) { _borrow(borrowAmount); }
4,682
60
// function to allow admin to transfer ETH from this contract
function TransferETH(address payable recipient, uint256 amount) public onlyOwner { recipient.transfer(amount); }
function TransferETH(address payable recipient, uint256 amount) public onlyOwner { recipient.transfer(amount); }
10,620
12
// Change Crowdsale Stage. Available Options: PreICO, ICO
function setCrowdsaleStage(uint value) public onlyOwner { CrowdsaleStage _stage; if (uint(CrowdsaleStage.PreICO) == value) { _stage = CrowdsaleStage.PreICO; } else if (uint(CrowdsaleStage.ICO) == value) { _stage = CrowdsaleStage.ICO; } stage = _stag...
function setCrowdsaleStage(uint value) public onlyOwner { CrowdsaleStage _stage; if (uint(CrowdsaleStage.PreICO) == value) { _stage = CrowdsaleStage.PreICO; } else if (uint(CrowdsaleStage.ICO) == value) { _stage = CrowdsaleStage.ICO; } stage = _stag...
49,806
20
// Stores token balances of this contract at a given moment.It's used to ensure there're no changes in balances at theend of a transaction. /
store.tokensToCheck = new Snapshot[](10);
store.tokensToCheck = new Snapshot[](10);
40,928
6
// Completes POWO transfers by updating the balances on the current block number_from address to transfer from_to addres to transfer to_amount to transfer/
function doTransfer(TellorStorage.TellorStorageStruct storage self, address _from, address _to, uint256 _amount) public { require(_amount > 0, "Tried to send non-positive amount"); require(_to != address(0), "Receiver is 0 address"); //allowedToTrade checks the stakeAmount is removed from ba...
function doTransfer(TellorStorage.TellorStorageStruct storage self, address _from, address _to, uint256 _amount) public { require(_amount > 0, "Tried to send non-positive amount"); require(_to != address(0), "Receiver is 0 address"); //allowedToTrade checks the stakeAmount is removed from ba...
15,278
5
// break if is an index of an IndexAccess
a[b.c];
a[b.c];
53,837
204
// pool can only be joined when it's unpaused /
modifier joiningNotPaused() { require(!pauseStatus, "TrueFiPool: Joining the pool is paused"); _; }
modifier joiningNotPaused() { require(!pauseStatus, "TrueFiPool: Joining the pool is paused"); _; }
41,089
111
// Set liquidation incentive to new incentive
liquidationIncentiveMantissa = newLiquidationIncentiveMantissa;
liquidationIncentiveMantissa = newLiquidationIncentiveMantissa;
25,306
126
// 流动性奖励地址
address public liquidityRewardPoolAddr; uint256 public constant REWARD_POOL_MULTIPLE = 13; uint256 public constant PUBLISHER_MULTIPLE = 3; uint256 public constant DEVELOPER_MULTIPLE = 2;
address public liquidityRewardPoolAddr; uint256 public constant REWARD_POOL_MULTIPLE = 13; uint256 public constant PUBLISHER_MULTIPLE = 3; uint256 public constant DEVELOPER_MULTIPLE = 2;
15,465
20
// todo: 0 out released amount if missing balance from trader
uint256 releasedAmount = uint256(userState.releasedDepositAssetAmount); if (releasedAmount <= _amount) { uint256 redeemAmount = _amount.sub(releasedAmount); userState.pendingAsset = uint256(userState.pendingAsset).sub( redeemAmount ...
uint256 releasedAmount = uint256(userState.releasedDepositAssetAmount); if (releasedAmount <= _amount) { uint256 redeemAmount = _amount.sub(releasedAmount); userState.pendingAsset = uint256(userState.pendingAsset).sub( redeemAmount ...
14,838
168
// Can be overridden to add finalization logic. The overriding function/should call super.finalization() to ensure the chain of finalization is/executed entirely.
function finalization() internal { }
function finalization() internal { }
53,998
71
// Initialize can only be called once. It saves the block number in which it was initialized.Initializes a kernel instance along with its ACL and sets `_permissionsCreator` as the entity that can create other permissions_baseAcl Address of base ACL app_permissionsCreator Entity that will be given permission over create...
function initialize(address _baseAcl, address _permissionsCreator) onlyInit public { initialized(); IACL acl = IACL(newAppProxy(this, ACL_APP_ID)); _setApp(APP_BASES_NAMESPACE, ACL_APP_ID, _baseAcl); _setApp(APP_ADDR_NAMESPACE, ACL_APP_ID, acl); acl.initialize(_permissions...
function initialize(address _baseAcl, address _permissionsCreator) onlyInit public { initialized(); IACL acl = IACL(newAppProxy(this, ACL_APP_ID)); _setApp(APP_BASES_NAMESPACE, ACL_APP_ID, _baseAcl); _setApp(APP_ADDR_NAMESPACE, ACL_APP_ID, acl); acl.initialize(_permissions...
51,176
48
// validate pair
lpToken = IDXswapFactory(factory).getPair(tokenA, tokenB); if (lpToken == address(0)) revert InvalidPair(); _approveTokenIfNeeded(lpToken, amount, router);
lpToken = IDXswapFactory(factory).getPair(tokenA, tokenB); if (lpToken == address(0)) revert InvalidPair(); _approveTokenIfNeeded(lpToken, amount, router);
22,076
0
// Partial interface for Oracle contract/Based on PriceOracle from Compound Finance/ (https:github.com/compound-finance/compound-protocol/blob/v2.8.1/contracts/PriceOracle.sol)
interface IOracle { /// @notice Get the underlying price of a market(cToken) asset /// @param market The market to get the underlying price of /// @return The underlying asset price mantissa (scaled by 1e18). /// Zero means the price is unavailable. function getUnde...
interface IOracle { /// @notice Get the underlying price of a market(cToken) asset /// @param market The market to get the underlying price of /// @return The underlying asset price mantissa (scaled by 1e18). /// Zero means the price is unavailable. function getUnde...
16,661
155
// set a new reference to the NFT ownership contract/_CStorageAddress - address of a deployed contract implementing EthernautsStorage.
function setEthernautsStorageContract(address _CStorageAddress) public onlyCLevel whenPaused { EthernautsStorage candidateContract = EthernautsStorage(_CStorageAddress); require(candidateContract.isEthernautsStorage()); ethernautsStorage = candidateContract; }
function setEthernautsStorageContract(address _CStorageAddress) public onlyCLevel whenPaused { EthernautsStorage candidateContract = EthernautsStorage(_CStorageAddress); require(candidateContract.isEthernautsStorage()); ethernautsStorage = candidateContract; }
63,178