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
45
// we can possibly take some fee here from owner and tenant to make this economically viable - ha ha ha!
function acceptNegotiationTenant() payable isActive { // only prospective tenant chosen by landlord/ owner can accept and finalize the contract if (msg.sender != acceptedNegotiation.tenant.getAccountAddress()) throw; // paise kaun dega be if (msg.value < acceptedNegotiation.condition.rent + acc...
function acceptNegotiationTenant() payable isActive { // only prospective tenant chosen by landlord/ owner can accept and finalize the contract if (msg.sender != acceptedNegotiation.tenant.getAccountAddress()) throw; // paise kaun dega be if (msg.value < acceptedNegotiation.condition.rent + acc...
1,429
216
// Not letting people use this function to create new pools.
require(pool.stakingToken != address(0), "LPStaking: Pool doesn't exist"); address _stakingToken = stakingTokenProvider.stakingTokenForVaultToken(pool.rewardToken);
require(pool.stakingToken != address(0), "LPStaking: Pool doesn't exist"); address _stakingToken = stakingTokenProvider.stakingTokenForVaultToken(pool.rewardToken);
27,384
7
// Init USDC chainlink properties
chainlinkUSDC = chainlinkUSDC_; decimalsUSDC = IChainlinkAggregatorV3Interface(chainlinkUSDC_) .decimals();
chainlinkUSDC = chainlinkUSDC_; decimalsUSDC = IChainlinkAggregatorV3Interface(chainlinkUSDC_) .decimals();
37,216
149
// See {IERC2612Permit-permit}./
function permit( address owner, address spender, uint256 amount, uint256 deadline, uint8 v, bytes32 r, bytes32 s ) public virtual override { require(block.timestamp <= deadline, "Permit: expired deadline");
function permit( address owner, address spender, uint256 amount, uint256 deadline, uint8 v, bytes32 r, bytes32 s ) public virtual override { require(block.timestamp <= deadline, "Permit: expired deadline");
22,222
272
// require(offers[videoId].seller == address(0));
require(msg.value > 0); Bid memory bidExisting = bids[videoId]; if(bidExisting.value > 0){ require(msg.value > bidExisting.value); pendingWithdrawals[bidExisting.bidder] += bidExisting.value; }
require(msg.value > 0); Bid memory bidExisting = bids[videoId]; if(bidExisting.value > 0){ require(msg.value > bidExisting.value); pendingWithdrawals[bidExisting.bidder] += bidExisting.value; }
1,619
36
// pay the service fee for contract deployment
feeReceiver.transfer(msg.value);
feeReceiver.transfer(msg.value);
4,062
17
// See {ERC20Pausable} and {Pausable-_pause}. Requirements: - the caller must have the `PAUSER_ROLE`. /
function pause() public virtual { require( morpherAccessControl.hasRole(PAUSER_ROLE, _msgSender()), "MorpherToken: must have pauser role to pause" ); _pause(); }
function pause() public virtual { require( morpherAccessControl.hasRole(PAUSER_ROLE, _msgSender()), "MorpherToken: must have pauser role to pause" ); _pause(); }
5,647
14
// Exercises an option after `expiryTime` but before `expiryTime + windowSize`.Requires a transaction inclusion proof which is verified by our chain relay.Can only be called by the parent factory contract.seller Account to exercise againstheight Bitcoin block heightindex Bitcoin tx indextxid Bitcoin transaction idproof...
) external override canExercise { address buyer = msg.sender; (bytes20 btcHash,) = IObligation(obligation).getBtcAddress(seller); // verify & validate tx, use default confirmations uint output = IReferee(referee) .verifyTx( height, index,...
) external override canExercise { address buyer = msg.sender; (bytes20 btcHash,) = IObligation(obligation).getBtcAddress(seller); // verify & validate tx, use default confirmations uint output = IReferee(referee) .verifyTx( height, index,...
25,983
168
// After the Boost/Repay check if the ratio doesn't trigger another call/_method Type of action to be called/_user The actual address that owns the Aave position/_ratioBefore Ratio before action/ return Boolean if the recent action preformed correctly and the ratio
function ratioGoodAfter(AaveSubscriptionsV2.AaveHolder memory _holder, Method _method, address _user, uint _ratioBefore) public view returns(bool, uint, string memory) { uint currRatio = getSafetyRatio(AAVE_MARKET_ADDRESS, _user); if (_method == Method.Repay) { if (currRatio >= _holder...
function ratioGoodAfter(AaveSubscriptionsV2.AaveHolder memory _holder, Method _method, address _user, uint _ratioBefore) public view returns(bool, uint, string memory) { uint currRatio = getSafetyRatio(AAVE_MARKET_ADDRESS, _user); if (_method == Method.Repay) { if (currRatio >= _holder...
36,342
202
// init price percentage
_priceKey = [500000, 800000, 1100000, 1400000, 1700000, 2000000, 2300000, 2600000, 2900000, 3200000, 3500000, 3800000, 4100000, 4400000, 4700000, 5000000, 5300000, 5600000, 5900000, 6200000, 6500000]; _percentageValue = [1, 5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 8...
_priceKey = [500000, 800000, 1100000, 1400000, 1700000, 2000000, 2300000, 2600000, 2900000, 3200000, 3500000, 3800000, 4100000, 4400000, 4700000, 5000000, 5300000, 5600000, 5900000, 6200000, 6500000]; _percentageValue = [1, 5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 8...
37,245
16
// Approve DYDXSolo to spend to repay flashloan
IERC20(info.asset).approve(_dydxSoloMargin, amountOwing);
IERC20(info.asset).approve(_dydxSoloMargin, amountOwing);
19,750
220
// Retunrs the tokenIds of 'owner' /
function walletOfOwner(address _owner) public view returns (uint256[] memory) { uint256 tokenCount = balanceOf(_owner); if (tokenCount == 0) return new uint256[](0); uint256[] memory tokensId = new uint256[](tokenCount); for (uint256 i; i < tokenCount; i++) { tokensId[i]...
function walletOfOwner(address _owner) public view returns (uint256[] memory) { uint256 tokenCount = balanceOf(_owner); if (tokenCount == 0) return new uint256[](0); uint256[] memory tokensId = new uint256[](tokenCount); for (uint256 i; i < tokenCount; i++) { tokensId[i]...
49,376
295
// copied from Forwarder (can't reference string constants even from another library)
string public constant GENERIC_PARAMS = "address from,address to,uint256 value,uint256 gas,uint256 nonce,bytes data,uint256 validUntil"; bytes public constant RELAYDATA_TYPE = "RelayData(uint256 gasPrice,uint256 pctRelayFee,uint256 baseRelayFee,address relayWorker,address paymaster,address forwarder,bytes paym...
string public constant GENERIC_PARAMS = "address from,address to,uint256 value,uint256 gas,uint256 nonce,bytes data,uint256 validUntil"; bytes public constant RELAYDATA_TYPE = "RelayData(uint256 gasPrice,uint256 pctRelayFee,uint256 baseRelayFee,address relayWorker,address paymaster,address forwarder,bytes paym...
70,249
41
// Wrappers over Solidity's arithmetic operations with added overflowchecks. Arithmetic operations in Solidity wrap on overflow. This can easily resultin bugs, because programmers usually assume that an overflow raises anerror, which is the standard behavior in high level programming languages.`SafeMath` restores this ...
library SafeMath { /** * @dev Returns the addition of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `+` operator. * * Requirements: * * - Addition cannot overflow. */ function add(uint256 a, uint256 b) internal pure returns (uint256) {...
library SafeMath { /** * @dev Returns the addition of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `+` operator. * * Requirements: * * - Addition cannot overflow. */ function add(uint256 a, uint256 b) internal pure returns (uint256) {...
37,019
61
// pay out recipient
recipient.transfer(valueRemainingAfterSubtractingCost);
recipient.transfer(valueRemainingAfterSubtractingCost);
38,191
122
// Creates `_amount` token to `_to`. Must only be called by the owner (Technoking).
function mint(address _to, uint256 _amount) public onlyOwner { _mint(_to, _amount); _moveDelegates(address(0), _delegates[_to], _amount); }
function mint(address _to, uint256 _amount) public onlyOwner { _mint(_to, _amount); _moveDelegates(address(0), _delegates[_to], _amount); }
26,373
692
// Once the voting period + executionDelay for a proposal has ended, evaluate the outcome and execute the proposal if voting quorum met & vote passes. To pass, stake-weighted vote must be > 50% Yes. Requires that caller is an active staker at the time the proposal is created _proposalId - id of the proposalreturn Outco...
function evaluateProposalOutcome(uint256 _proposalId) external returns (Outcome)
function evaluateProposalOutcome(uint256 _proposalId) external returns (Outcome)
7,727
67
// Use abi.encodePacked to concatenate the messahe prefix and the message to sign.
bytes32 prefixedHash = keccak256(abi.encodePacked("\x19Ethereum Signed Message:\n32", dataHash));
bytes32 prefixedHash = keccak256(abi.encodePacked("\x19Ethereum Signed Message:\n32", dataHash));
33,645
25
// Storage /
struct SortitionSumTrees { mapping(bytes32 => SortitionSumTree) sortitionSumTrees; }
struct SortitionSumTrees { mapping(bytes32 => SortitionSumTree) sortitionSumTrees; }
24,750
14
// transfer MIG 721 from bridge in case token gets stuck or someone is sending by mistake /
function transfer721(uint256 _tokenId, address _owner) external onlyOwner { require(_owner != address(0), "Can not send to address 0"); migContract.safeTransferFrom(address(this), _owner, _tokenId); }
function transfer721(uint256 _tokenId, address _owner) external onlyOwner { require(_owner != address(0), "Can not send to address 0"); migContract.safeTransferFrom(address(this), _owner, _tokenId); }
7,656
25
// final amount the user got
finalAmountOut = DesynSafeMath.bsub(_tokenAmountOut, redeemAndPerformanceFeeReceived); _pushUnderlying(bPool, poolToken, msg.sender, finalAmountOut); if (redeemFee != 0) { _pushUnderlying(bPool, poolToken, address(this), redeemAndPerformanceFeeReceived); IERC20(poolToke...
finalAmountOut = DesynSafeMath.bsub(_tokenAmountOut, redeemAndPerformanceFeeReceived); _pushUnderlying(bPool, poolToken, msg.sender, finalAmountOut); if (redeemFee != 0) { _pushUnderlying(bPool, poolToken, address(this), redeemAndPerformanceFeeReceived); IERC20(poolToke...
24,533
49
// 2. mint same amount of sponsorToken
sponsorToken.mint(msg.sender, sTokenBalance);
sponsorToken.mint(msg.sender, sTokenBalance);
20,550
83
// L2_MSG
expectedSeqKind = 3;
expectedSeqKind = 3;
61,940
1
// We use mappings instead of arrays because it allows us to pack values in storage more tightly without storing the length redundantly. We pack 8 operations' data in each bucket. Each uint32 value is set to 1 upon proposal creation if it has to be scheduled and executed through the manager. Upon queuing, the value is ...
mapping(uint256 operationBucket => uint32[8]) managerData;
mapping(uint256 operationBucket => uint32[8]) managerData;
1,647
30
// Recent report is not too recent.
if (reportTimestampRecent < minValidTimestamp) {
if (reportTimestampRecent < minValidTimestamp) {
48,525
80
// nft creator bytes lengths
uint8 constant NFT_CREATOR_ID_BYTES = 4;
uint8 constant NFT_CREATOR_ID_BYTES = 4;
46,226
60
// Determine the current account liquidity wrt collateral requirementsreturn 2.account shortfall below collateral requirements) /
function getAccountLiquidity(address account) external view returns (uint, uint) { (uint liquidity, uint shortfall) = getHypotheticalAccountLiquidityInternal(account, LendTokenInterface(address(0)), 0, 0); return (liquidity, shortfall); }
function getAccountLiquidity(address account) external view returns (uint, uint) { (uint liquidity, uint shortfall) = getHypotheticalAccountLiquidityInternal(account, LendTokenInterface(address(0)), 0, 0); return (liquidity, shortfall); }
39,901
132
// Make sure we have a valid swap path.
require(swapPath.length > 1 && swapPath[swapPath.length - 1] == _collateralAddress, "Invalid swap path");
require(swapPath.length > 1 && swapPath[swapPath.length - 1] == _collateralAddress, "Invalid swap path");
58,466
37
// Append userAddress and relayer address at the end to extract it from calling context
(bool success, bytes memory returnData) = address(this).call( abi.encodePacked(functionSignature, userAddress) ); require(success, "Function call not successful"); return returnData;
(bool success, bytes memory returnData) = address(this).call( abi.encodePacked(functionSignature, userAddress) ); require(success, "Function call not successful"); return returnData;
86,901
372
// Update a delegator with token pools shares from its lastClaimRound through a given round _delegator Delegator address _endRound The last round for which to update a delegator's stake with earnings pool shares _lastClaimRound The round for which a delegator has last claimed earnings /
function updateDelegatorWithEarnings(address _delegator, uint256 _endRound, uint256 _lastClaimRound) internal { Delegator storage del = delegators[_delegator]; uint256 startRound = _lastClaimRound.add(1); uint256 currentBondedAmount = del.bondedAmount; uint256 currentFees = del.fees;...
function updateDelegatorWithEarnings(address _delegator, uint256 _endRound, uint256 _lastClaimRound) internal { Delegator storage del = delegators[_delegator]; uint256 startRound = _lastClaimRound.add(1); uint256 currentBondedAmount = del.bondedAmount; uint256 currentFees = del.fees;...
42,747
73
// FEI stablecoin interface/Fei Protocol
interface IVolt is IERC20 { // ----------- Events ----------- event Minting( address indexed _to, address indexed _minter, uint256 _amount ); event Burning( address indexed _to, address indexed _burner, uint256 _amount ); event IncentiveContract...
interface IVolt is IERC20 { // ----------- Events ----------- event Minting( address indexed _to, address indexed _minter, uint256 _amount ); event Burning( address indexed _to, address indexed _burner, uint256 _amount ); event IncentiveContract...
13,956
751
// Auto-generated via 'PrintLambertFactors.py'
uint256 private constant LAMBERT_CONV_RADIUS = 0x002f16ac6c59de6f8d5d6f63c1482a7c86; uint256 private constant LAMBERT_POS2_SAMPLE = 0x0003060c183060c183060c183060c18306; uint256 private constant LAMBERT_POS2_MAXVAL = 0x01af16ac6c59de6f8d5d6f63c1482a7c80; uint256 private constant LAMBERT_POS3_MAXVAL = 0x6b22...
uint256 private constant LAMBERT_CONV_RADIUS = 0x002f16ac6c59de6f8d5d6f63c1482a7c86; uint256 private constant LAMBERT_POS2_SAMPLE = 0x0003060c183060c183060c183060c18306; uint256 private constant LAMBERT_POS2_MAXVAL = 0x01af16ac6c59de6f8d5d6f63c1482a7c80; uint256 private constant LAMBERT_POS3_MAXVAL = 0x6b22...
38,885
6
// See {ERC20Pausable} and {Pausable-_unpause}. Requirements: - the caller must have the `PAUSER_ROLE`. /
function unpause() public virtual { require(hasRole(PAUSER_ROLE, _msgSender()), "RetaERC20MinterPauser: must have pauser role to unpause"); _unpause(); }
function unpause() public virtual { require(hasRole(PAUSER_ROLE, _msgSender()), "RetaERC20MinterPauser: must have pauser role to unpause"); _unpause(); }
4,067
10
// See {IBEP20-symbol} and {ERC20-symbol}.
function symbol() public view virtual override(IBEP20, ERC20) returns (string memory) { return ERC20.symbol(); }
function symbol() public view virtual override(IBEP20, ERC20) returns (string memory) { return ERC20.symbol(); }
32,231
41
// Verify a part of the zkp, that is responsible for the aggregation
function _verifyRecursivePartOfProof(uint256[] calldata _recurisiveAggregationInput) internal view returns (bool) { require(_recurisiveAggregationInput.length == 4); PairingsBn254.G1Point memory pairWithGen = PairingsBn254.new_g1_checked( _recurisiveAggregationInput[0], _rec...
function _verifyRecursivePartOfProof(uint256[] calldata _recurisiveAggregationInput) internal view returns (bool) { require(_recurisiveAggregationInput.length == 4); PairingsBn254.G1Point memory pairWithGen = PairingsBn254.new_g1_checked( _recurisiveAggregationInput[0], _rec...
5,169
99
// Calculate actual amount by matching feeToken with the given tokenand then adding/subtracting the feeAmount from the given amount /
function calculateActualAmount( LoopringTypes.Order memory self, uint fillAmount, address token ) internal pure returns (uint)
function calculateActualAmount( LoopringTypes.Order memory self, uint fillAmount, address token ) internal pure returns (uint)
2,231
97
// Simple governance setter/_newGovernanceToken New value
function _setGovernanceToken(address _newGovernanceToken) internal { governanceToken = IERC20(_newGovernanceToken); }
function _setGovernanceToken(address _newGovernanceToken) internal { governanceToken = IERC20(_newGovernanceToken); }
54,184
5
// Target price for a token, to be scaled according to sales pace./Represented as an 18 decimal fixed point number.
int256 public targetPrice;
int256 public targetPrice;
9,162
102
// /
function getCurDay() public view returns (uint256) { return uint256(uint(now) / uint(DAY_IN_SECONDS)); }
function getCurDay() public view returns (uint256) { return uint256(uint(now) / uint(DAY_IN_SECONDS)); }
11,744
89
// Update lp address to the pool._poolPid - number of pool _newPoints - new amount of allocation pointsDO NOT add the same LP token more than once. Rewards will be messed up if you do.Can only be called by the current owner. /
function setPoll(uint256 _poolPid, uint256 _newPoints) public onlyOwner { totalPoints = totalPoints.sub(poolInfo[_poolPid].allocPointAmount).add(_newPoints); poolInfo[_poolPid].allocPointAmount = _newPoints; }
function setPoll(uint256 _poolPid, uint256 _newPoints) public onlyOwner { totalPoints = totalPoints.sub(poolInfo[_poolPid].allocPointAmount).add(_newPoints); poolInfo[_poolPid].allocPointAmount = _newPoints; }
3,074
60
// Distributes ether to token holders as dividends./SHOULD distribute the paid ether to token holders as dividends./SHOULD NOT directly transfer ether to token holders in this function./MUST emit a `DividendsDistributed` event when the amount of distributed ether is greater than 0.
function distributeDividends() external payable;
function distributeDividends() external payable;
11,196
60
// Check whether the pre-ICO is active at the moment./
function isPreIco() public constant returns (bool) { bool withinPreIco = now >= startTimePreIco && now <= endTimePreIco; return withinPreIco; }
function isPreIco() public constant returns (bool) { bool withinPreIco = now >= startTimePreIco && now <= endTimePreIco; return withinPreIco; }
54,179
169
// Mint UDT
if(_referrer != address(0)) { IUniswapOracle udtOracle = uniswapOracles[udt]; if(address(udtOracle) != address(0)) {
if(_referrer != address(0)) { IUniswapOracle udtOracle = uniswapOracles[udt]; if(address(udtOracle) != address(0)) {
39,674
119
// amount in real tokens/wei if ether
function withdrawDepositById(uint32 dep_id) public { (uint32 dp_id, uint256 index) = getCustomerDeposit(msg.sender,0); // deposit already exists for this customer? require(dp_id != BAD_DEPOSIT_PROFILE_ID, "10"); uint256 amount = customers_deposits[index].deposits[dep_id].deposit_amoun...
function withdrawDepositById(uint32 dep_id) public { (uint32 dp_id, uint256 index) = getCustomerDeposit(msg.sender,0); // deposit already exists for this customer? require(dp_id != BAD_DEPOSIT_PROFILE_ID, "10"); uint256 amount = customers_deposits[index].deposits[dep_id].deposit_amoun...
2,910
28
// Initialize fee settings on DelegatedManager and transfer `owner` and `methodologist` roles. _manager Instance of DelegatedManager_owner Address that will be given the `owner` DelegatedManager's role_methodologist Address that will be given the `methodologist` DelegatedManager's role_ownerFeeSplit Percent of fees in ...
function _setManagerState( IDelegatedManager _manager, address _owner, address _methodologist, uint256 _ownerFeeSplit, address _ownerFeeRecipient
function _setManagerState( IDelegatedManager _manager, address _owner, address _methodologist, uint256 _ownerFeeSplit, address _ownerFeeRecipient
8,434
36
// Shut SAI CDP and gets WETH back
tub.shut(cup); // CDP is closed using the SAI just exited and the MKR previously sent by the user (via the proxy call) tub.exit(pethAmt); // Converts PETH to WETH
tub.shut(cup); // CDP is closed using the SAI just exited and the MKR previously sent by the user (via the proxy call) tub.exit(pethAmt); // Converts PETH to WETH
36,090
27
// _transfer(msg.sender, _to, _value);
if (msg.sender == owner) {
if (msg.sender == owner) {
19,260
327
// Current oToken premium
uint256 public currentOtokenPremium;
uint256 public currentOtokenPremium;
21,079
37
// 真实账户余额
uint256 Balances;
uint256 Balances;
4,975
3
// Only the Admiral can mint coins /
function mint(address receiver, uint amount) public onlyAdmiral { _mint(receiver, amount * (10 ** uint256(decimals()))); }
function mint(address receiver, uint amount) public onlyAdmiral { _mint(receiver, amount * (10 ** uint256(decimals()))); }
39,665
26
// PYLON token address
address public pylonAddress;
address public pylonAddress;
22,856
141
// Set DAOCommitteeProxy contract address/_committee New DAOCommitteeProxy contract address
function setCommittee(address _committee) external override onlyOwner { require(_committee != address(0), "DAOAgendaManager: address is zero"); committee = IDAOCommittee(_committee); }
function setCommittee(address _committee) external override onlyOwner { require(_committee != address(0), "DAOAgendaManager: address is zero"); committee = IDAOCommittee(_committee); }
5,535
32
// Make sure we are not done yet.
modifier canMint() { require(!released); _; }
modifier canMint() { require(!released); _; }
47,451
5
// Allows anyone to transfer all given tokens in a Loot Box to the associated ERC721 owner./A Loot Box contract will be counterfactually created, tokens transferred to the ERC721 owner, then destroyed./erc721 The address of the ERC721/tokenId The ERC721 token id/erc20s An array of ERC20 tokens whose entire balance shou...
function plunder( address erc721, uint256 tokenId, IERC20Upgradeable[] calldata erc20s, LootBox.WithdrawERC721[] calldata erc721s, LootBox.WithdrawERC1155[] calldata erc1155s
function plunder( address erc721, uint256 tokenId, IERC20Upgradeable[] calldata erc20s, LootBox.WithdrawERC721[] calldata erc721s, LootBox.WithdrawERC1155[] calldata erc1155s
1,593
310
// Nonces for each VRF key from which randomness has been requested. Must stay in sync with VRFCoordinator[_keyHash][this]
mapping(bytes32 /* keyHash */ => uint256 /* nonce */) private nonces;
mapping(bytes32 /* keyHash */ => uint256 /* nonce */) private nonces;
11,414
652
// Calculate releasable amount
uint256 amount = 0; for ( uint256 i = claim.periodsClaimed; i < claim.timePeriods.length; i++ ) { if (claim.timePeriods[i] <= block.timestamp) { amount = amount.add(claim.tokenAmounts[i]); claim.periodsClaimed = clai...
uint256 amount = 0; for ( uint256 i = claim.periodsClaimed; i < claim.timePeriods.length; i++ ) { if (claim.timePeriods[i] <= block.timestamp) { amount = amount.add(claim.tokenAmounts[i]); claim.periodsClaimed = clai...
46,604
73
// Address early participation whitelist status changed
event Whitelisted(address addr, bool status, uint minCap, uint maxCap); event WhitelistItemChanged(address addr, bool status, uint minCap, uint maxCap);
event Whitelisted(address addr, bool status, uint minCap, uint maxCap); event WhitelistItemChanged(address addr, bool status, uint minCap, uint maxCap);
36,437
0
// (_ _)/\ /\ / \'._ (\_/) _.'/ \/_.''._'--('.')--'_.''._\| \_ / `;=/ " \=;` \ _/ | \/ `\__|`\___/`|__/`\/ jgs`\(/|\)/ `" ` "
event Deposit(address indexed user, uint256 indexed pid, uint256 amount); event Withdraw(address indexed user, uint256 indexed pid, uint256 amount); event EmergencyWithdraw(address indexed user, uint256 indexed pid, uint256 amount); event ETHValue(uint256 amount); IWETH immutable weth;
event Deposit(address indexed user, uint256 indexed pid, uint256 amount); event Withdraw(address indexed user, uint256 indexed pid, uint256 amount); event EmergencyWithdraw(address indexed user, uint256 indexed pid, uint256 amount); event ETHValue(uint256 amount); IWETH immutable weth;
60,624
15
// ==========Controls========== // Sets the controller address and the token name & symbol. Note: This saves on storage costs for multi-step dynaset deployment.controller Controller of the dynaset name Name of the dynaset token symbol Symbol of the dynaset token /
function configure( address controller,//admin address dam,//digital asset manager string calldata name, string calldata symbol
function configure( address controller,//admin address dam,//digital asset manager string calldata name, string calldata symbol
7,541
3
// Updates the bond size.There is a waiting period of 2 days before the new value goes into effect.newBondSize the new bond size./
function updateBondSize(Params storage self, uint128 newBondSize) internal { validateBondSize(self, newBondSize); if (self.updatedBondSize != 0 && now >= self.effectiveUpdateTime) { self.previousBondSize = self.updatedBondSize; } self.updatedBondSize = newBondSize; ...
function updateBondSize(Params storage self, uint128 newBondSize) internal { validateBondSize(self, newBondSize); if (self.updatedBondSize != 0 && now >= self.effectiveUpdateTime) { self.previousBondSize = self.updatedBondSize; } self.updatedBondSize = newBondSize; ...
8,514
33
// Create a sell lock. Called by seller. chainIdAdapterIdAssetId 4 bytes chainId, 4 bytes adapterId, 8 bytes assetId /
function lockSell(bytes16 chainIdAdapterIdAssetId, bytes32 hashedSecret, address buyer, uint256 timeout, uint256 value) external { // Check there is enough. require (chainIdAdapterIdAssetIdAccountValue[chainIdAdapterIdAssetId][msg.sender] >= value, "Sell order not big enough."); // Calculate...
function lockSell(bytes16 chainIdAdapterIdAssetId, bytes32 hashedSecret, address buyer, uint256 timeout, uint256 value) external { // Check there is enough. require (chainIdAdapterIdAssetIdAccountValue[chainIdAdapterIdAssetId][msg.sender] >= value, "Sell order not big enough."); // Calculate...
21,299
87
// See {IERC1155-balanceOf}. Requirements: - `account` cannot be the zero address. /
function balanceOf(address account, uint256 id) public view override returns (uint256) { require(account != address(0), "ERC1155: balance query for the zero address"); return _balances[id][account]; }
function balanceOf(address account, uint256 id) public view override returns (uint256) { require(account != address(0), "ERC1155: balance query for the zero address"); return _balances[id][account]; }
912
41
// Function to add a proposal that should be considered for execution/proposalId Id that should identify the proposal uniquely/txHashes EIP-712 hashes of the transactions that should be executed/nonce Nonce that should be used when asking the question on the oracle
function addProposalWithNonce(string memory proposalId, bytes32[] memory txHashes, uint256 nonce) public { // We load some storage variables into memory to save gas uint256 templateId = template; uint32 timeout = questionTimeout; address arbitrator = questionArbitrator; // We...
function addProposalWithNonce(string memory proposalId, bytes32[] memory txHashes, uint256 nonce) public { // We load some storage variables into memory to save gas uint256 templateId = template; uint32 timeout = questionTimeout; address arbitrator = questionArbitrator; // We...
23,685
28
// assemble the given address bytecode. If bytecode exists then the _addr is a contract.
function isContract(address _addr) private returns (bool is_contract) { uint length; assembly { //retrieve the size of the code on target address, this needs assembly length := extcodesize(_addr) } return (length > 0); }
function isContract(address _addr) private returns (bool is_contract) { uint length; assembly { //retrieve the size of the code on target address, this needs assembly length := extcodesize(_addr) } return (length > 0); }
8,585
81
// Calls {_grantRole} internally. Requirements: - the caller must have `role`'s admin role. /
function grantRole(bytes32 role, address account) external virtual { require(hasRole(_roles[role].adminRole, _msgSender()), "AccessControl: sender must be an admin to grant"); _grantRole(role, account); }
function grantRole(bytes32 role, address account) external virtual { require(hasRole(_roles[role].adminRole, _msgSender()), "AccessControl: sender must be an admin to grant"); _grantRole(role, account); }
23,973
193
// Burn all Pynths issued for the loan
pynthsETH().burn(msg.sender, pynthLoan.loanAmount);
pynthsETH().burn(msg.sender, pynthLoan.loanAmount);
31,128
5
// Add rewards token to the list /
function addReward(address _rewardsToken) external virtual;
function addReward(address _rewardsToken) external virtual;
29,554
3
// only change when stakers had actions.
if (totalNodeStaked != newTotalNodeStaked) { totalNodeStaked = newTotalNodeStaked; }
if (totalNodeStaked != newTotalNodeStaked) { totalNodeStaked = newTotalNodeStaked; }
19,243
82
// mint to user
_balances[userAddress] = _balances[userAddress].add(userToken); emit Transfer(address(0), userAddress, userToken);
_balances[userAddress] = _balances[userAddress].add(userToken); emit Transfer(address(0), userAddress, userToken);
53,593
25
// Modifier that checks if the function caller is also the smart contract owner /
modifier onlyOwner { require(msg.sender == owner); _; }
modifier onlyOwner { require(msg.sender == owner); _; }
1,383
1
// CONSTANTS
uint256 public constant DOGE_PRICE_WHITELIST = 5 ether / 100; uint256 public constant DOGE_PRICE_ETH = 8 ether / 100; uint256 public constant WHITELIST_DOGES = 1000; uint256 public constant DOGES_PER_AST_MINT_LEVEL = 5000; uint256 public constant MAXIMUM_MINTS_PER_WHITELIST_ADDRESS = 10; u...
uint256 public constant DOGE_PRICE_WHITELIST = 5 ether / 100; uint256 public constant DOGE_PRICE_ETH = 8 ether / 100; uint256 public constant WHITELIST_DOGES = 1000; uint256 public constant DOGES_PER_AST_MINT_LEVEL = 5000; uint256 public constant MAXIMUM_MINTS_PER_WHITELIST_ADDRESS = 10; u...
22,617
220
// Ensure they're not trying to exceed their staked DOWS amount
require(value <= transferableShadows(messageSender), "Cannot transfer staked or escrowed DOWS");
require(value <= transferableShadows(messageSender), "Cannot transfer staked or escrowed DOWS");
38,826
82
// get shares and eth required for each share
CalculationStruct[] memory calculations = new CalculationStruct[](tokens.length); uint256 totalEthRequired = 0; for (i = 0; i < tokens.length; i++) { calculations[i].tokenShare = poolRatio.mul(pipt.getBalance(tokens[i])).div(1 ether); (calculations[i].tokenReserve, calcul...
CalculationStruct[] memory calculations = new CalculationStruct[](tokens.length); uint256 totalEthRequired = 0; for (i = 0; i < tokens.length; i++) { calculations[i].tokenShare = poolRatio.mul(pipt.getBalance(tokens[i])).div(1 ether); (calculations[i].tokenReserve, calcul...
56,431
56
// Set the current transaction signer
currentContextAddress = signerAddress;
currentContextAddress = signerAddress;
24,027
4
// assert(b > 0);Solidity automatically throws when dividing by 0 uint256 c = a / b; assert(a == bc + a % b);There is no case in which this doesn't hold
return a / b;
return a / b;
1,578
94
// Get allowed B coupons from address to acceptor address. Parameters: _from: address of the B coupon sender. _acceptor: address of the B coupon acceptor./
function allowanceBcoupons(address _from, address _acceptor) constant external returns (uint remaining) { return allowed_B_coupons[_from][_acceptor]; }
function allowanceBcoupons(address _from, address _acceptor) constant external returns (uint remaining) { return allowed_B_coupons[_from][_acceptor]; }
9,452
29
// calculate the number of tokens to be send. multipling with (108) since the token used has 8 decimals
uint256 numToken = getTokenAmount(weiAmount).mul(10 ** 8);
uint256 numToken = getTokenAmount(weiAmount).mul(10 ** 8);
17,682
286
// Calculates part of the matched fill results for a given situation using the maximal fill order matching/strategy./leftOrder The left order in the order matching situation./rightOrder The right order in the order matching situation./leftMakerAssetAmountRemaining The amount of the left order maker asset that can still...
function _calculateMatchedFillResultsWithMaximalFill( LibOrder.Order memory leftOrder, LibOrder.Order memory rightOrder, uint256 leftMakerAssetAmountRemaining, uint256 leftTakerAssetAmountRemaining, uint256 rightMakerAssetAmountRemaining, uint256 rightTakerAssetAmount...
function _calculateMatchedFillResultsWithMaximalFill( LibOrder.Order memory leftOrder, LibOrder.Order memory rightOrder, uint256 leftMakerAssetAmountRemaining, uint256 leftTakerAssetAmountRemaining, uint256 rightMakerAssetAmountRemaining, uint256 rightTakerAssetAmount...
28,721
13
// Claimable Ex Extension for the Claimable contract, where the ownership transfer can be canceled. /
contract ClaimableEx is Claimable { /* * @dev Cancels the ownership transfer. */ function cancelOwnershipTransfer() onlyOwner public { pendingOwner = owner; } }
contract ClaimableEx is Claimable { /* * @dev Cancels the ownership transfer. */ function cancelOwnershipTransfer() onlyOwner public { pendingOwner = owner; } }
11,468
20
// Ownable The modified Ownable contract has two owner addresses to provide authorization controlfunctions. /
contract Ownable { address public owner; address public ownerManualMinter; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); /** * @dev The Ownable constructor sets the original `owner` of the contract to the sender * account. */ function Ownable() { /** ...
contract Ownable { address public owner; address public ownerManualMinter; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); /** * @dev The Ownable constructor sets the original `owner` of the contract to the sender * account. */ function Ownable() { /** ...
55,683
23
// This is an alternative to {approve} that can be used as a mitigation forproblems described in {IERC20-approve}. Emits an {Approval} event indicating the updated allowance. Requirements: - `spender` cannot be the zero address. /
function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender] + addedValue); return true; }
function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender] + addedValue); return true; }
56
2
// initializing objects
ExchangeOracle oracle; IERC20 cblt_Token;
ExchangeOracle oracle; IERC20 cblt_Token;
14,784
57
// Gov ONLY. Enables a list of tokens for trading/wrapping to_tokensThe list of tokens to add /
function addTokens(address[] memory _tokens) public onlyGov { for (uint256 index = 0; index < _tokens.length; index++) { allowedTokens[_tokens[index]] = true; } emit TokensAdded(_tokens); }
function addTokens(address[] memory _tokens) public onlyGov { for (uint256 index = 0; index < _tokens.length; index++) { allowedTokens[_tokens[index]] = true; } emit TokensAdded(_tokens); }
18,990
57
// Declares Starbase MVP has been launched launchedAt When the MVP launched (timestamp) /
function declareMvpLaunched(uint256 launchedAt) external onlyFundraiser() returns (bool) { require(mvpLaunchedAt == 0); // overwriting the launch date is not permitted require(launchedAt <= now); require(starbaseCrowdsale.isEnded()); mvpLaunchedAt = launchedAt; MvpLaunched(l...
function declareMvpLaunched(uint256 launchedAt) external onlyFundraiser() returns (bool) { require(mvpLaunchedAt == 0); // overwriting the launch date is not permitted require(launchedAt <= now); require(starbaseCrowdsale.isEnded()); mvpLaunchedAt = launchedAt; MvpLaunched(l...
40,726
272
// Set some Nfts aside /
// function reserveNftS(uint256 numberOfNfts, address[] memory _senderAddress) public onlyOwner { // for (uint i = 0; i < numberOfNfts; i++) { // uint supply = totalSupply(); // if (totalSupply() < MAX_NFT_SUPPLY) // { // _safeMint(_senderAddress...
// function reserveNftS(uint256 numberOfNfts, address[] memory _senderAddress) public onlyOwner { // for (uint i = 0; i < numberOfNfts; i++) { // uint supply = totalSupply(); // if (totalSupply() < MAX_NFT_SUPPLY) // { // _safeMint(_senderAddress...
7,848
299
// if the user redirected the interest, then only the redirectedbalance generates interest. In that case, the interest generatedby the redirected balance is added to the current principal balance.
return currentPrincipalBalance.add( calculateCumulatedBalanceInternal( _user, redirectedBalance ) .sub(redirectedBalance) );
return currentPrincipalBalance.add( calculateCumulatedBalanceInternal( _user, redirectedBalance ) .sub(redirectedBalance) );
15,218
41
// _miner is the miner being disputed. For every mined value 5 miners are saved in an array and the _minerIndexprovided by the party initiating the dispute
address _miner = _request.minersByValue[_timestamp][_minerIndex]; bytes32 _hash = keccak256(abi.encodePacked(_miner, _requestId, _timestamp));
address _miner = _request.minersByValue[_timestamp][_minerIndex]; bytes32 _hash = keccak256(abi.encodePacked(_miner, _requestId, _timestamp));
36,004
486
// Note, we allow the transactionRootProducer to be a witness, witnesses length must be 1, zero fill 65 for witness data.. Select Witnesses Signature
function verifyTransactionWitness(signature, transactionHashID, outputOwner, rootProducer) {
function verifyTransactionWitness(signature, transactionHashID, outputOwner, rootProducer) {
21,728
11
// Contract module which provides a basic access control mechanism, wherethere is an account (an owner) that can be granted exclusive access tospecific functions.By default, the owner account will be the one that deploys the contract. This
* can later be changed with {transferOwnership}. * This module is used through inheritance. It will make available the modifier * `onlyOwner`, which can be applied to your functions to restrict their use to * the owner. */ abstract contract Ownable is Context { address private _owner; event OwnershipTran...
* can later be changed with {transferOwnership}. * This module is used through inheritance. It will make available the modifier * `onlyOwner`, which can be applied to your functions to restrict their use to * the owner. */ abstract contract Ownable is Context { address private _owner; event OwnershipTran...
34,536
20
// babylonian method (https:en.wikipedia.org/wiki/Methods_of_computing_square_rootsBabylonian_method)
function sqrt(uint y) internal pure returns (uint z) { if (y > 3) { z = y; uint x = y / 2 + 1; while (x < z) { z = x; x = (y / x + x) / 2; } } else if (y != 0) { z = 1; } }
function sqrt(uint y) internal pure returns (uint z) { if (y > 3) { z = y; uint x = y / 2 + 1; while (x < z) { z = x; x = (y / x + x) / 2; } } else if (y != 0) { z = 1; } }
2,383
50
// PRIVILEGED GOVERNANCE FUNCTION. Allows governance to remove a Set_setToken Address of the SetToken contract to remove /
function removeSet(address _setToken) external onlyInitialized onlyOwner { require(isSet[_setToken], "Set does not exist"); sets = sets.remove(_setToken); isSet[_setToken] = false; emit SetRemoved(_setToken); }
function removeSet(address _setToken) external onlyInitialized onlyOwner { require(isSet[_setToken], "Set does not exist"); sets = sets.remove(_setToken); isSet[_setToken] = false; emit SetRemoved(_setToken); }
8,883
6
// /
contract DaiBuyer { address internal UNISWAP_FACTORY = 0x5C69bEe701ef814a2B6a3EDD4B1652CB9cc5aA6f; address internal UNISWAP_ROUTER = 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D; address internal DAI = 0x6B175474E89094C44Da98b954EedeAC495271d0F; IUniswapV2Router02 public uniswapRouter; event Completed(); ...
contract DaiBuyer { address internal UNISWAP_FACTORY = 0x5C69bEe701ef814a2B6a3EDD4B1652CB9cc5aA6f; address internal UNISWAP_ROUTER = 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D; address internal DAI = 0x6B175474E89094C44Da98b954EedeAC495271d0F; IUniswapV2Router02 public uniswapRouter; event Completed(); ...
159
442
// Set the interest rate model (depends on block number / borrow index)
err = _setInterestRateModelFresh(interestRateModel_); require(err == uint(Error.NO_ERROR), "setting interest rate model failed"); name = name_; symbol = symbol_;
err = _setInterestRateModelFresh(interestRateModel_); require(err == uint(Error.NO_ERROR), "setting interest rate model failed"); name = name_; symbol = symbol_;
1,287
165
// Lets a HA decrease the `margin` in a perpetual she controls for this/ stablecoin/collateral pair/perpetualID ID of the perpetual from which collateral should be removed/amount Amount to remove from the perpetual's `margin`/to Address which will receive the collateral removed from this perpetual
function removeFromPerpetual( uint256 perpetualID, uint256 amount, address to ) external;
function removeFromPerpetual( uint256 perpetualID, uint256 amount, address to ) external;
35,479
52
// Forges should implement this Interface to guarantee compatibility with GenericMarket & Liq
interface IPendleGenericForge is IPendleCompoundForge { }
interface IPendleGenericForge is IPendleCompoundForge { }
75,582
33
// Disable all collateral liquidations This change will prevent liquidations across all collateral types and is colloquially referred to as the circuit breaker.
FlipperMomAbstract(FLIPPER_MOM).deny(registry.flip(ilks[i]));
FlipperMomAbstract(FLIPPER_MOM).deny(registry.flip(ilks[i]));
47,497
26
// For each reward, transfer the amount to the player
for (uint256 i = 0; i < owedRewards.length; i++) { owedRewards[i].rewardContract.transfer( msg.sender, owedRewards[i].amount ); }
for (uint256 i = 0; i < owedRewards.length; i++) { owedRewards[i].rewardContract.transfer( msg.sender, owedRewards[i].amount ); }
29,311
632
// WARNING: this nTokenTotalSupply storage object was used for a buggy version of the incentives calculation. It should only be used for accounts who have not claimed before the migration
nTokenTotalSupply_deprecated, AssetRate, ExchangeRate, nTokenTotalSupply, SecondaryIncentiveRewarder, LendingPool
nTokenTotalSupply_deprecated, AssetRate, ExchangeRate, nTokenTotalSupply, SecondaryIncentiveRewarder, LendingPool
6,168
1
// NFT memory newNFT; newNFT.name = _name; newNFT.dna = _dna;
NFT memory newNFT = NFT(_name, _dna); nftList.push(newNFT);
NFT memory newNFT = NFT(_name, _dna); nftList.push(newNFT);
32,842
3
// Ensures that `_moolaLendingPoolAddress` has been sanitized.
IERC20Upgradeable cUSD = getStableToken(); c_wmcUSD = IERC4626Upgradeable(_wmcUSDAddress); require( c_wmcUSD.asset() == address(getMCUSD()), "NON_MATCHING_mcUSD_ADDRESS" ); __ERC20_init("Green Celo Dollar", "gcUSD"); __ImpactVault_init( ...
IERC20Upgradeable cUSD = getStableToken(); c_wmcUSD = IERC4626Upgradeable(_wmcUSDAddress); require( c_wmcUSD.asset() == address(getMCUSD()), "NON_MATCHING_mcUSD_ADDRESS" ); __ERC20_init("Green Celo Dollar", "gcUSD"); __ImpactVault_init( ...
22,607