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
13
// 每个用户状态状态
mapping (address => mapping (uint64 => ServiceStat)) public serviceStatMap;
mapping (address => mapping (uint64 => ServiceStat)) public serviceStatMap;
23,601
106
// The public identifier for the right to sweep tokens.
bytes32 public constant SWEEP = keccak256("SWEEP");
bytes32 public constant SWEEP = keccak256("SWEEP");
45,182
2
// lib/dss-exec-lib/src/DssExecLib.sol DssExecLib.sol -- MakerDAO Executive Spellcrafting Library Copyright (C) 2020 Maker Ecosystem Growth Holdings, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Fo...
/* import { CollateralOpts } from "./CollateralOpts.sol"; */ interface Initializable { function init(bytes32) external; }
/* import { CollateralOpts } from "./CollateralOpts.sol"; */ interface Initializable { function init(bytes32) external; }
16,162
16
// We distribute the rewards first, so that the withdrawing staker receives all of their allocated rewards, before setting an `endTime`.
distributeRewards(staker, blockTimestamp); staker.endTime = blockTimestamp;
distributeRewards(staker, blockTimestamp); staker.endTime = blockTimestamp;
38,384
12
// Save allele on current index
aux = geneticSequence[i];
aux = geneticSequence[i];
1,276
4
// Transfer and lock to multiple accounts with a single transaction. Blockwell Exclusive (Intellectual Property that lives on-chain via Smart License) /
function multiTransferAndLock( address[] calldata to, uint256[] calldata value, uint32 lockTime, uint32 periodLength, uint16 periods
function multiTransferAndLock( address[] calldata to, uint256[] calldata value, uint32 lockTime, uint32 periodLength, uint16 periods
18,383
103
// Here the owner can reclaim the tokens from a participant if/the token is not released yet. Refund will be handled offband./fromWhom address of the participant whose tokens we want to claim
function transferToOwner(address fromWhom) public onlyOwner { if (released) revert(); uint amount = balanceOf(fromWhom); balances[fromWhom] = balances[fromWhom].sub(amount); balances[owner] = balances[owner].add(amount); Transfer(fromWhom, owner, amount); OwnerReclaim(fromWhom, amount); }
function transferToOwner(address fromWhom) public onlyOwner { if (released) revert(); uint amount = balanceOf(fromWhom); balances[fromWhom] = balances[fromWhom].sub(amount); balances[owner] = balances[owner].add(amount); Transfer(fromWhom, owner, amount); OwnerReclaim(fromWhom, amount); }
48,809
24
// This function should be called only by account with BURN_TOKENS permissions_tokenAddress address of token_who address whose tokens will be burned_amount amount of tokens which will be burnedthis function burn tokens for address _who/
function burnTokens(address _tokenAddress, address _who, uint _amount) public isCanDo(BURN_TOKENS) { emit DaoBaseBurnTokens(_tokenAddress, _who, _amount); DaoBaseLib.burnTokens( daoStorage, _tokenAddress, _who, _amount ); }
function burnTokens(address _tokenAddress, address _who, uint _amount) public isCanDo(BURN_TOKENS) { emit DaoBaseBurnTokens(_tokenAddress, _who, _amount); DaoBaseLib.burnTokens( daoStorage, _tokenAddress, _who, _amount ); }
10,299
142
// Create pending burn if sender is opted-in and the permaboost is active
IOptIn.OptInStatus memory optInStatus = getOptInStatus(msg.sender); if (optInStatus.isOptedIn && optInStatus.permaBoostActive) { _createPendingTransfer({ opType: OP_TYPE_BURN, spender: msg.sender, from: msg.sender, to: address(0...
IOptIn.OptInStatus memory optInStatus = getOptInStatus(msg.sender); if (optInStatus.isOptedIn && optInStatus.permaBoostActive) { _createPendingTransfer({ opType: OP_TYPE_BURN, spender: msg.sender, from: msg.sender, to: address(0...
5,195
23
// Reverts if the contract is not in an initializing state. See {onlyInitializing}. /
function _checkInitializing() internal view virtual { if (!_isInitializing()) { revert NotInitializing(); }
function _checkInitializing() internal view virtual { if (!_isInitializing()) { revert NotInitializing(); }
28,331
50
// See {IERC721-approve}.
function approve(address to, uint256 tokenId) public virtual override { address owner = ERC721.ownerOf(tokenId); require(to != owner, "ERC721: approval to current owner"); require(_msgSender() == owner || isApprovedForAll(owner, _msgSender()), "ERC721: approve caller is not owner nor approved for all"); ...
function approve(address to, uint256 tokenId) public virtual override { address owner = ERC721.ownerOf(tokenId); require(to != owner, "ERC721: approval to current owner"); require(_msgSender() == owner || isApprovedForAll(owner, _msgSender()), "ERC721: approve caller is not owner nor approved for all"); ...
32,120
62
// End token timestamp, used only from UI
uint256 public endT;
uint256 public endT;
19,155
435
// round 22
ark(i, q, 15262034989144652068456967541137853724140836132717012646544737680069032573006); sbox_partial(i, q); mix(i, q);
ark(i, q, 15262034989144652068456967541137853724140836132717012646544737680069032573006); sbox_partial(i, q); mix(i, q);
49,296
2
// add a trusted currencyContract _newContractAddress The address of the currencyContract /
function adminAddTrustedCurrencyContract(address _newContractAddress) external onlyOwner
function adminAddTrustedCurrencyContract(address _newContractAddress) external onlyOwner
42,380
27
// mint tenderTokens
require(tenderToken.mint(_for, amountOut), "TENDER_MINT_FAILED");
require(tenderToken.mint(_for, amountOut), "TENDER_MINT_FAILED");
20,715
257
// Get a user's asset balance
function balanceOf( Store.State storage state, Types.BalancePath memory balancePath, address asset ) internal view returns (uint256)
function balanceOf( Store.State storage state, Types.BalancePath memory balancePath, address asset ) internal view returns (uint256)
12,629
175
// LendingPoolAddressesProvider contractIs the main registry of the protocol. All the different components of the protocol are accessible through the addresses provider.Aave/
contract LendingPoolAddressesProvider is Ownable, ILendingPoolAddressesProvider, AddressStorage { //events event LendingPoolUpdated(address indexed newAddress); event LendingPoolCoreUpdated(address indexed newAddress); event LendingPoolParametersProviderUpdated(address indexed newAddress); event Len...
contract LendingPoolAddressesProvider is Ownable, ILendingPoolAddressesProvider, AddressStorage { //events event LendingPoolUpdated(address indexed newAddress); event LendingPoolCoreUpdated(address indexed newAddress); event LendingPoolParametersProviderUpdated(address indexed newAddress); event Len...
80,945
10
// New request
uint256 requestId = requests.length++; RequestMetadata storage requestMetadata = requests[requestId]; requestMetadata.applicationId = applicationId; requestMetadata.riskId = riskId; emit LogRequestFlightStatistics(requestId, _carrierFlightNumber, _departureTime, _arrivalTime);
uint256 requestId = requests.length++; RequestMetadata storage requestMetadata = requests[requestId]; requestMetadata.applicationId = applicationId; requestMetadata.riskId = riskId; emit LogRequestFlightStatistics(requestId, _carrierFlightNumber, _departureTime, _arrivalTime);
40,702
121
// top up claim cycle
topUpClaimCycleAfterTransfer(recipient, amount); if (_isExcluded[sender] && !_isExcluded[recipient]) { _transferFromExcluded(sender, recipient, amount); } else if (!_isExcluded[sender] && _isExcluded[recipient]) {
topUpClaimCycleAfterTransfer(recipient, amount); if (_isExcluded[sender] && !_isExcluded[recipient]) { _transferFromExcluded(sender, recipient, amount); } else if (!_isExcluded[sender] && _isExcluded[recipient]) {
29,523
71
// Comptroller needs prices in the format: ${raw price}1e36 / baseUnitThe baseUnit of an asset is the amount of the smallest denomination of that asset per whole.For example, the baseUnit of ETH is 1e18.Since the prices in this view have 6 decimals, we must scale them by 1e(36 - 6)/baseUnit
return mul(1e30, priceInternal(config)) / config.baseUnit;
return mul(1e30, priceInternal(config)) / config.baseUnit;
52,951
70
// mint pool liquidity tokens
_mint(msg.sender, mintedAmount); return mintedAmount;
_mint(msg.sender, mintedAmount); return mintedAmount;
22,640
43
// Set Fee for Sells
if (to == uniswapV2Pair && from != address(uniswapV2Router)) { _redisFee = _redisFeeOnSell; _taxFee = _taxFeeOnSell; }
if (to == uniswapV2Pair && from != address(uniswapV2Router)) { _redisFee = _redisFeeOnSell; _taxFee = _taxFeeOnSell; }
2,625
88
// Returns the blocknumber of the last transaction.return Blocknumber for the last transaction. /
function getLastBlockNumber() external view returns (uint40);
function getLastBlockNumber() external view returns (uint40);
13,882
197
// Get cash balance of this gToken in the underlying assetreturn The quantity of underlying asset owned by this contract /
function getCash() external view returns (uint) { return getCashPrior(); }
function getCash() external view returns (uint) { return getCashPrior(); }
577
17
// Worker had already voted for a match result
error AlreadyVoted();
error AlreadyVoted();
30,873
132
// if (block.number > userStake[msg.sender].lastBlockChecked) { uint256 rewardBlocks = block.number.sub(userStake[msg.sender].lastBlockChecked); uint256 stakedAmount = userStake[msg.sender].stakedNyanV2LP; if (userStake[msg.sender].stakedDNyanV2LP > 0) { stakedAmount = stakedAmount.add(userStake[msg.sender].stakedDNyan...
_;
_;
16,077
1
// Modify this section
string public name = "Bounce Token"; string public symbol = "BOT"; uint8 public decimals = 18; uint256 public totalSupply = 100000 * (uint256(10) ** decimals); event Transfer(address indexed from, address indexed to, uint256 value);
string public name = "Bounce Token"; string public symbol = "BOT"; uint8 public decimals = 18; uint256 public totalSupply = 100000 * (uint256(10) ** decimals); event Transfer(address indexed from, address indexed to, uint256 value);
18,473
46
// Anti-bot and anti-whale mappings and variables
mapping(address => uint256) private _holderLastTransferTimestamp; // to hold last Transfers temporarily during launch bool public transferDelayEnabled = true; bool public limitsInEffect = true; mapping(address => bool) private _isExcludedFromFee; mapping(address => bool) private _isExcluded; a...
mapping(address => uint256) private _holderLastTransferTimestamp; // to hold last Transfers temporarily during launch bool public transferDelayEnabled = true; bool public limitsInEffect = true; mapping(address => bool) private _isExcludedFromFee; mapping(address => bool) private _isExcluded; a...
11,539
19
// Moves `amount` tokens from `sender` to `recipient` using theallowance mechanism. `amount` is then deducted from the caller'sallowance. Returns a boolean value indicating whether the operation succeeded. Emits a {Transfer} event. /
function transferFrom(address sender, address recipient, uint256 amount) external returns (bool);
function transferFrom(address sender, address recipient, uint256 amount) external returns (bool);
216
19
// For 2 <= degree <= 27add 1% from the first k-1 nodesadd tier% from the last node
if(degree >= 2 && degree <= 27) { for (uint i = 0; i < (degree - 1); i++) { shares = node.invitees[node.inviteeIndex[i]]; reward = reward.add(shares.mul(1).div(100)); }
if(degree >= 2 && degree <= 27) { for (uint i = 0; i < (degree - 1); i++) { shares = node.invitees[node.inviteeIndex[i]]; reward = reward.add(shares.mul(1).div(100)); }
33,140
2
// Decreases the allowance granted to spender by the caller. spender The address to reduce the allowance from. subtractedValue The amount allowance to subtract.return Returns true if allowance has decreased, otherwise false. /
{ _approve( msg.sender, spender, allowance[msg.sender][spender].sub(subtractedValue, "NEGATIVE_ALLOWANCE") ); return true; }
{ _approve( msg.sender, spender, allowance[msg.sender][spender].sub(subtractedValue, "NEGATIVE_ALLOWANCE") ); return true; }
54,167
219
// initialization cannot be called for a second time
if (hasParameters()) throw; cliffPeriod = pCliffPeriod; vestingPeriod = pVestingPeriod; maxFadeoutPromille = FP_SCALE - pResidualAmountPromille; bonusOptionsPromille = pBonusOptionsPromille; newEmployeePoolPromille = pNewEmployeePoolPromille; optionsPerShare = pOptionsPerShare;
if (hasParameters()) throw; cliffPeriod = pCliffPeriod; vestingPeriod = pVestingPeriod; maxFadeoutPromille = FP_SCALE - pResidualAmountPromille; bonusOptionsPromille = pBonusOptionsPromille; newEmployeePoolPromille = pNewEmployeePoolPromille; optionsPerShare = pOptionsPerShare;
30,392
97
// executes all virtual orders until blockTimestamp is reached (AS A VIEW)
function executeVirtualOrdersUntilTimestampView(LongTermOrders storage longTermOrders, uint256 blockTimestamp, ExecuteVirtualOrdersResult memory reserveResult) internal view { uint256 nextExpiryBlockTimestamp = longTermOrders.lastVirtualOrderTimestamp - (longTermOrders.lastVirtualOrderTimestamp % longTermOr...
function executeVirtualOrdersUntilTimestampView(LongTermOrders storage longTermOrders, uint256 blockTimestamp, ExecuteVirtualOrdersResult memory reserveResult) internal view { uint256 nextExpiryBlockTimestamp = longTermOrders.lastVirtualOrderTimestamp - (longTermOrders.lastVirtualOrderTimestamp % longTermOr...
60,381
4
// Approve the Pool contract allowance to pull the owed amount
emit log(address(this), address(this).balance); uint256 amountOwed = amount + premium; IERC20(asset).approve(address(POOL), amountOwed); return true;
emit log(address(this), address(this).balance); uint256 amountOwed = amount + premium; IERC20(asset).approve(address(POOL), amountOwed); return true;
26,666
90
// Move the cash from the sender to the contract address. This must happen before the insert trade call below.
Escrow().depositIntoMarket(account, CASH_GROUP, cash, fee); Common.Asset memory asset = Common.Asset( CASH_GROUP, 0, maturity, Common.getCashReceiver(), 0, fCashAmount );
Escrow().depositIntoMarket(account, CASH_GROUP, cash, fee); Common.Asset memory asset = Common.Asset( CASH_GROUP, 0, maturity, Common.getCashReceiver(), 0, fCashAmount );
4,230
90
// transfer the amount from the distribution to the user
emit DistributionPaid(user, assetId, d.period, amount, balanceIndex, distributionIndex); add(self, assetId, user, amount, 0);
emit DistributionPaid(user, assetId, d.period, amount, balanceIndex, distributionIndex); add(self, assetId, user, amount, 0);
21,884
18
// Updates the logic contract for the SuperTokenFactory/This function updates the logic contract for the SuperTokenFactory/newAddress the new address of the SuperTokenFactory logic contract
function updateCode(address newAddress) external override { if (msg.sender != address(_host)) { revert SUPER_TOKEN_FACTORY_ONLY_HOST(); } _updateCodeAddress(newAddress); // Upgrade the Flow NFT logic contracts on the canonical proxies // We only do this if the ne...
function updateCode(address newAddress) external override { if (msg.sender != address(_host)) { revert SUPER_TOKEN_FACTORY_ONLY_HOST(); } _updateCodeAddress(newAddress); // Upgrade the Flow NFT logic contracts on the canonical proxies // We only do this if the ne...
18,919
245
// Get id
uint256 innerSalt; (id, innerSalt) = _buildSettleId(_requestData, _loanData); require(requests[id].borrower == address(0), "Request already exist");
uint256 innerSalt; (id, innerSalt) = _buildSettleId(_requestData, _loanData); require(requests[id].borrower == address(0), "Request already exist");
16,231
12
// A modifier that defines a protected reinitializer function that can be invoked at most once, and only if thecontract hasn't been initialized to a greater version before. In its scope, `onlyInitializing` functions can beused to initialize parent contracts. `initializer` is equivalent to `reinitializer(1)`, so a reini...
modifier reinitializer(uint8 version) { require(!_initializing && _initialized < version, "Initializable: contract is already initialized"); _initialized = version; _initializing = true; _; _initializing = false; emit Initialized(version); }
modifier reinitializer(uint8 version) { require(!_initializing && _initialized < version, "Initializable: contract is already initialized"); _initialized = version; _initializing = true; _; _initializing = false; emit Initialized(version); }
13,226
35
// Upgradeability is only provided internally through {_upgradeTo}. For an externally upgradeable proxy see{TransparentUpgradeableProxy}./ Initializes the upgradeable proxy with an initial implementation specified by `_logic`. If `_data` is nonempty, it's used as data in a delegate call to `_logic`. This will typically...
constructor(address _logic, bytes memory _data) payable { assert( _IMPLEMENTATION_SLOT == bytes32(uint256(keccak256('eip1967.proxy.implementation')) - 1) ); _setImplementation(_logic); if (_data.length > 0) {
constructor(address _logic, bytes memory _data) payable { assert( _IMPLEMENTATION_SLOT == bytes32(uint256(keccak256('eip1967.proxy.implementation')) - 1) ); _setImplementation(_logic); if (_data.length > 0) {
25,676
79
// low level token purchase function /
function buyTokens() public payable whenNotPaused { // Do not allow if gasprice is bigger than the maximum // This is for fair-chance for all contributors, so no one can // set a too-high transaction price and be able to buy earlier require(tx.gasprice <= maxTxGas); // valid ...
function buyTokens() public payable whenNotPaused { // Do not allow if gasprice is bigger than the maximum // This is for fair-chance for all contributors, so no one can // set a too-high transaction price and be able to buy earlier require(tx.gasprice <= maxTxGas); // valid ...
25,877
10
// Set new zone (if allowed; enterZone may throw)
furballs[tokenIds[i]].zone = uint32(engine.enterZone(tokenIds[i], zone, tokenIds));
furballs[tokenIds[i]].zone = uint32(engine.enterZone(tokenIds[i], zone, tokenIds));
33,926
32
// Make sure member never voted on this poll
require( hasVotedPoll[msg.sender][_pollID] == false, "Member already voted on this poll");
require( hasVotedPoll[msg.sender][_pollID] == false, "Member already voted on this poll");
17,222
28
// admin/
function changeAdmin( address _newAdmin ) public
function changeAdmin( address _newAdmin ) public
36,805
80
// Function to return the specific sales details for a given address/minter address for minter to return mint information for
function mintedPerAddress( address minter ) external view returns (AddressMintDetails memory);
function mintedPerAddress( address minter ) external view returns (AddressMintDetails memory);
13,589
34
// Borrow requests for less than this USD amount will not be approved.
uint public minBorrowAmountUsd;
uint public minBorrowAmountUsd;
25,739
214
// add from now if key is expired
_keys[_tokenId].expirationTimestamp = block.timestamp + _deltaT;
_keys[_tokenId].expirationTimestamp = block.timestamp + _deltaT;
26,897
12
// Value of total amount requested by borrowers in market (in Wei)
uint totalRequested;
uint totalRequested;
18,353
9
// Pool maximum size
uint256 public maxSize;
uint256 public maxSize;
20,242
16
// liquidityPool / 20
mstore(add(order, 128), mload(add(data, 100)))
mstore(add(order, 128), mload(add(data, 100)))
40,800
591
// Send LUSD to user and decrease LUSD in Pool
function _sendLUSDToDepositor(address _depositor, uint LUSDWithdrawal) internal { if (LUSDWithdrawal == 0) {return;} lusdToken.returnFromPool(address(this), _depositor, LUSDWithdrawal); _decreaseLUSD(LUSDWithdrawal); }
function _sendLUSDToDepositor(address _depositor, uint LUSDWithdrawal) internal { if (LUSDWithdrawal == 0) {return;} lusdToken.returnFromPool(address(this), _depositor, LUSDWithdrawal); _decreaseLUSD(LUSDWithdrawal); }
10,562
97
// Executes plugins in the order provided. Calls itself's _pay function if the payment plugin contract itself is part of plugins.
function _execute( address[] calldata path, uint[] calldata amounts, address[] calldata addresses, address[] calldata plugins, string[] calldata data
function _execute( address[] calldata path, uint[] calldata amounts, address[] calldata addresses, address[] calldata plugins, string[] calldata data
11,709
46
// add function
ds.selectorToFacetAndPosition[selector].functionSelectorPosition = selectorPosition; ds.facetFunctionSelectors[_facetAddress].functionSelectors.push(selector); ds.selectorToFacetAndPosition[selector].facetAddress = _facetAddress; selectorPosition++;
ds.selectorToFacetAndPosition[selector].functionSelectorPosition = selectorPosition; ds.facetFunctionSelectors[_facetAddress].functionSelectors.push(selector); ds.selectorToFacetAndPosition[selector].facetAddress = _facetAddress; selectorPosition++;
50,198
13
// Update OpenSea contract level metadata.
function setContractCID(bytes memory contractCID_) external { require( hasRole(DEFAULT_ADMIN_ROLE, msg.sender), "GitNFT: must have admin role to change contract CID" ); contractCID = contractCID_; }
function setContractCID(bytes memory contractCID_) external { require( hasRole(DEFAULT_ADMIN_ROLE, msg.sender), "GitNFT: must have admin role to change contract CID" ); contractCID = contractCID_; }
8,309
82
// Store relevant auction data in memory for the life of this function.
address winner = auctions[auctionId].bidder; uint256 amount = auctions[auctionId].amount; address creator = auctions[auctionId].creator; return AuctionResult(auctionId, winner, amount, creator);
address winner = auctions[auctionId].bidder; uint256 amount = auctions[auctionId].amount; address creator = auctions[auctionId].creator; return AuctionResult(auctionId, winner, amount, creator);
30,976
289
// Validation
uint256 startPos; bytes32 tokenIdHash; mapping(uint256 => uint256) serialToTokenId; mapping(uint256 => uint256) tokenIdToSerial; mapping(uint256 => uint256) cardTraits; bytes32 public fullTokenIDHash;
uint256 startPos; bytes32 tokenIdHash; mapping(uint256 => uint256) serialToTokenId; mapping(uint256 => uint256) tokenIdToSerial; mapping(uint256 => uint256) cardTraits; bytes32 public fullTokenIDHash;
59,332
2
// burn option token from an address. Can only be called by corresponding margin engine _from account to burn from _tokenIdtokenId to burn _amount amount to burn/
function burn(address _from, uint256 _tokenId, uint256 _amount) external;
function burn(address _from, uint256 _tokenId, uint256 _amount) external;
25,726
337
// Set up names for bunnies.Only the main admins can set it. /
function setBunnyName(uint8 _bunnyId, string calldata _bunnyName) external onlyOwner
function setBunnyName(uint8 _bunnyId, string calldata _bunnyName) external onlyOwner
23,854
21
// Update zug modifier
Orc memory orc = orcs[id]; uint16 zugModifier_ = _tier(orc.helm) + _tier(orc.mainhand) + _tier(orc.offhand); orcs[id].zugModifier = zugModifier_; activities[id].timestamp = uint88(block.timestamp + cooldown);
Orc memory orc = orcs[id]; uint16 zugModifier_ = _tier(orc.helm) + _tier(orc.mainhand) + _tier(orc.offhand); orcs[id].zugModifier = zugModifier_; activities[id].timestamp = uint88(block.timestamp + cooldown);
32,245
2
// function createPerson(string memory name) external returns (bool);function setPersonName(string memory name) external returns (bool);
function addMessageId(address person, uint256 messageId) external returns (bool);
function addMessageId(address person, uint256 messageId) external returns (bool);
26,026
122
// Manager roles
bytes32 public constant OWNER_ROLE = keccak256("OWNER_ROLE"); bytes32 public constant MANAGER_ROLE = keccak256("MANAGER_ROLE");
bytes32 public constant OWNER_ROLE = keccak256("OWNER_ROLE"); bytes32 public constant MANAGER_ROLE = keccak256("MANAGER_ROLE");
11,626
181
// Rebalance stable token total supply by depositary balance. Mint stable token if depositary balance greater token total supply and burn otherwise. /
function rebalance() external whenNotPaused { uint256 currentDepositaryBalance = this.balance(); uint256 stableTokenTotalSupply = stableToken.totalSupply(); if (stableTokenTotalSupply > currentDepositaryBalance) { uint256 burningBalance = stableToken.balanceOf(address(this)); ...
function rebalance() external whenNotPaused { uint256 currentDepositaryBalance = this.balance(); uint256 stableTokenTotalSupply = stableToken.totalSupply(); if (stableTokenTotalSupply > currentDepositaryBalance) { uint256 burningBalance = stableToken.balanceOf(address(this)); ...
42,614
318
// Mint their new synths
sUSDSynth.issue(account, sUSDAmount);
sUSDSynth.issue(account, sUSDAmount);
13,352
29
// ==================UTILITY======================================/get user record for a token
function getUserRecord(address tokenAddr, address user) external view returns ( uint256 stakedAmt, uint256 stakedAt, uint256 unstakedAmt, uint256 unstakedAt, uint256 rewardAmt
function getUserRecord(address tokenAddr, address user) external view returns ( uint256 stakedAmt, uint256 stakedAt, uint256 unstakedAmt, uint256 unstakedAt, uint256 rewardAmt
11,473
18
// Returns whether the implementing contract is currently paused or not return Whether the paused state is active /
function isPaused() constant returns (bool);
function isPaused() constant returns (bool);
33,106
48
// The uniswap v2 router and pair address
IUniswapV2Router private _uniswapV2Router; address private uniswapV2Pair; address private router = 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D ;
IUniswapV2Router private _uniswapV2Router; address private uniswapV2Pair; address private router = 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D ;
21,399
0
// Interface for the yEarn yVault
yVaultInterface public vault;
yVaultInterface public vault;
38,557
0
// ============ State Variables ============ / CToken Full Unit
uint256 public immutable cTokenFullUnit;
uint256 public immutable cTokenFullUnit;
58,751
17
// If we have insufficient values, reject the proof unless the stack has been fully exhausted
require( context.afterMachine.dataStack.hash() == Value.newEmptyTuple().hash(), STACK_MISSING );
require( context.afterMachine.dataStack.hash() == Value.newEmptyTuple().hash(), STACK_MISSING );
14,326
80
// /
interface IVestedLPMining { /** * @notice Initializes the storage of the contract * @dev "constructor" to be called on a new proxy deployment * @dev Sets the contract `owner` account to the deploying account */ function initialize( IERC20 _cvp, address _reservoir, uint256 _cvpPerBlock, u...
interface IVestedLPMining { /** * @notice Initializes the storage of the contract * @dev "constructor" to be called on a new proxy deployment * @dev Sets the contract `owner` account to the deploying account */ function initialize( IERC20 _cvp, address _reservoir, uint256 _cvpPerBlock, u...
31,999
13
// - allows Owner to add a new revenue stream to the Spigot - revenueContract cannot be address(this) - callable by `owner` revenueContract - smart contract to claim tokens from setting - Spigot settings for smart contract /
function addSpigot(address revenueContract, Setting memory setting) external returns (bool) { return state.addSpigot(revenueContract, setting); }
function addSpigot(address revenueContract, Setting memory setting) external returns (bool) { return state.addSpigot(revenueContract, setting); }
29,585
292
// Trade the heldToken for the owedToken
uint256 receivedOwedToken = ExchangeWrapper(transaction.exchangeWrapper).exchange( msg.sender, state.TOKEN_PROXY, transaction.owedToken, transaction.heldToken, buybackCostInHeldToken, orderData ); require(
uint256 receivedOwedToken = ExchangeWrapper(transaction.exchangeWrapper).exchange( msg.sender, state.TOKEN_PROXY, transaction.owedToken, transaction.heldToken, buybackCostInHeldToken, orderData ); require(
35,185
20
// documentHasAchievedMajority: per hash, whether that hash has ever achieved majoritythe note for upgradeHasAchievedMajority above applies here as well
mapping(bytes32 => bool) public documentHasAchievedMajority;
mapping(bytes32 => bool) public documentHasAchievedMajority;
3,158
239
// Get a portion of the eventual unlent balance
redeemedTokens = redeemedTokens.add(_amount.mul(balanceUnderlying).div(afiSupply));
redeemedTokens = redeemedTokens.add(_amount.mul(balanceUnderlying).div(afiSupply));
10,476
190
// Handle back interest: calculates interest owned since the loan endtime passed but the loan remained open
uint256 backInterestTime; uint256 backInterestOwed; if (block.timestamp > loanLocal.endTimestamp) { backInterestTime = block.timestamp .sub(loanLocal.endTimestamp); backInterestOwed = backInterestTime .mul(loanInterestLocal.owedPerDay); ...
uint256 backInterestTime; uint256 backInterestOwed; if (block.timestamp > loanLocal.endTimestamp) { backInterestTime = block.timestamp .sub(loanLocal.endTimestamp); backInterestOwed = backInterestTime .mul(loanInterestLocal.owedPerDay); ...
12,391
255
// Redeem a specified quantity of the sender's shares for a proportionate slice of/ the fund's assets, optionally specifying additional assets and assets to skip./_sharesQuantity The quantity of shares to redeem/_additionalAssets Additional (non-tracked) assets to claim/_assetsToSkip Tracked assets to forfeit/ return p...
function redeemSharesDetailed( uint256 _sharesQuantity, address[] calldata _additionalAssets, address[] calldata _assetsToSkip
function redeemSharesDetailed( uint256 _sharesQuantity, address[] calldata _additionalAssets, address[] calldata _assetsToSkip
16,942
728
// if boost is not enabled, set max ratio to max uint
uint128 localMaxRatio = _boostEnabled ? _maxRatio : uint128(-1); require(checkParams(manager.ilks(_cdpId), _minRatio, localMaxRatio), "Must be correct params"); SubPosition storage subInfo = subscribersPos[_cdpId]; CdpHolder memory subscription = CdpHolder({ minRatio: _...
uint128 localMaxRatio = _boostEnabled ? _maxRatio : uint128(-1); require(checkParams(manager.ilks(_cdpId), _minRatio, localMaxRatio), "Must be correct params"); SubPosition storage subInfo = subscribersPos[_cdpId]; CdpHolder memory subscription = CdpHolder({ minRatio: _...
57,909
41
// Internally calculates a swap between two tokens.The caller is expected to transfer the actual amounts (dx and dy)using the token contracts.self Swap struct to read from tokenIndexFrom the token to sell tokenIndexTo the token to buy dy the number of tokens to buy. If the token charges a fee on transfers,use the amoun...
function _calculateSwapInv( Swap storage self, uint8 tokenIndexFrom, uint8 tokenIndexTo, uint256 dy, uint256[] memory balances
function _calculateSwapInv( Swap storage self, uint8 tokenIndexFrom, uint8 tokenIndexTo, uint256 dy, uint256[] memory balances
21,003
0
//
IMulticall3 private constant multicall = IMulticall3(0xcA11bde05977b3631167028862bE2a173976CA11); VmSafe private constant vm = VmSafe(address(uint160(uint256(keccak256("hevm cheat code"))))); address private constant CONSOLE2_ADDRESS = 0x000000000000000000636F6e736F6c652e6c6f67; uint256 private constan...
IMulticall3 private constant multicall = IMulticall3(0xcA11bde05977b3631167028862bE2a173976CA11); VmSafe private constant vm = VmSafe(address(uint160(uint256(keccak256("hevm cheat code"))))); address private constant CONSOLE2_ADDRESS = 0x000000000000000000636F6e736F6c652e6c6f67; uint256 private constan...
21,579
26
// Calculate natural exponent of x.Revert on overflow.x signed 64.64-bit fixed point numberreturn signed 64.64-bit fixed point number /
function exp (int128 x) internal pure returns (int128) { unchecked { require (x < 0x400000000000000000); // Overflow if (x < -0x400000000000000000) return 0; // Underflow return exp_2 ( int128 (int256 (x) * 0x171547652B82FE1777D0FFDA0D23A7D12 >> 128)); } }
function exp (int128 x) internal pure returns (int128) { unchecked { require (x < 0x400000000000000000); // Overflow if (x < -0x400000000000000000) return 0; // Underflow return exp_2 ( int128 (int256 (x) * 0x171547652B82FE1777D0FFDA0D23A7D12 >> 128)); } }
12,155
20
// Will revert if lot is not in biddable state
_isLotInBiddableState(_lotID);
_isLotInBiddableState(_lotID);
41,307
27
// Replaces the attribute which is attached to an NFT with another attribute of the same type.
* @dev Works like {dettach} and {attach} in the same function. */ function replaceAttr(uint _attrId, uint _tokenId) external payable { address owner = ownerOfAttr(_attrId); require(owner == ownerOf(_tokenId)); _isApprovedOrAttrOwner(owner, msg.sender, _attrId); _isApprovedO...
* @dev Works like {dettach} and {attach} in the same function. */ function replaceAttr(uint _attrId, uint _tokenId) external payable { address owner = ownerOfAttr(_attrId); require(owner == ownerOf(_tokenId)); _isApprovedOrAttrOwner(owner, msg.sender, _attrId); _isApprovedO...
42,628
5
// price
uint256 public darkPriceOne; uint256 public darkPriceCeiling; uint256 public seigniorageSaved; uint256 public darkSupplyTarget; uint256 public maxSupplyExpansionPercent; uint256 public bondDepletionFloorPercent; uint256 public seigniorageExpansionFloorPercent;
uint256 public darkPriceOne; uint256 public darkPriceCeiling; uint256 public seigniorageSaved; uint256 public darkSupplyTarget; uint256 public maxSupplyExpansionPercent; uint256 public bondDepletionFloorPercent; uint256 public seigniorageExpansionFloorPercent;
4,857
26
// Unsubscribe an existing strategy/_subId Subscription id
function unsubscribe(uint _subId) public { Strategy memory s = strategies[_subId]; require(s.user != address(0), "Strategy does not exist"); require(msg.sender == s.proxy, "Proxy not strategy owner"); strategies[_subId].active = false; logger.Log(address(this), msg.sender, ...
function unsubscribe(uint _subId) public { Strategy memory s = strategies[_subId]; require(s.user != address(0), "Strategy does not exist"); require(msg.sender == s.proxy, "Proxy not strategy owner"); strategies[_subId].active = false; logger.Log(address(this), msg.sender, ...
80,815
24
// 终结申请,判断是否通过,通过转载给卖家
function finality(uint256 i) public { Resquest storage res = requestsMapping[i]; // 1、只有众筹的人才有资格结束这个申请 assert(msg.sender == manager); // 2、票数要大于一半 assert(res.votesNum * 2 > voters.length); // 3、转账的金额必须小于于合约余额 assert(res.costMoney <= address(this).balance); ...
function finality(uint256 i) public { Resquest storage res = requestsMapping[i]; // 1、只有众筹的人才有资格结束这个申请 assert(msg.sender == manager); // 2、票数要大于一半 assert(res.votesNum * 2 > voters.length); // 3、转账的金额必须小于于合约余额 assert(res.costMoney <= address(this).balance); ...
21,338
26
// ints
uint256 private _totalSupply; uint256 private _unitsPerToken; uint256 private _initialPoolToken; uint256 private _poolBalance; uint256 private _poolFactor; uint256 private _period; uint256 private _timelockkeeping; uint256 private _timelockstopinflations;
uint256 private _totalSupply; uint256 private _unitsPerToken; uint256 private _initialPoolToken; uint256 private _poolBalance; uint256 private _poolFactor; uint256 private _period; uint256 private _timelockkeeping; uint256 private _timelockstopinflations;
31,424
40
// to position this {TimelockController} as the owner of a smart contract, with/ Emitted when a call is scheduled as part of operation `id`. /
event CallScheduled(bytes32 indexed id, uint256 indexed index, address target, uint256 value, bytes data, bytes32 predecessor, uint256 delay);
event CallScheduled(bytes32 indexed id, uint256 indexed index, address target, uint256 value, bytes data, bytes32 predecessor, uint256 delay);
23,498
2
// number of tokens that can be claimed for free - 20% of MAX_TOKENS
uint256 public PAID_TOKENS;
uint256 public PAID_TOKENS;
71,385
50
// Safety mechanism to pause most Vault operations in the event of an emergency - typically detection of anerror in some part of the system. The Vault can only be paused during an initial time period, after which pausing is forever disabled. While the contract is paused, the following features are disabled:- depositing...
function setPaused(bool paused) external;
function setPaused(bool paused) external;
22,001
131
// Returns all the relevant information about a specific player./_id The ID of the player of interest.
function getPlayer(uint256 _id) external view returns ( uint256 typeId, uint256 attack, uint256 defense, uint256 stamina, uint256 xp, uint256 isKeeper,
function getPlayer(uint256 _id) external view returns ( uint256 typeId, uint256 attack, uint256 defense, uint256 stamina, uint256 xp, uint256 isKeeper,
15,426
46
// migration function
function TGPTMigration(address[] memory _address, uint256[] memory _amount) external onlyOwner { for(uint i=0; i< _amount.length; i++){ address adr = _address[i]; uint amnt = _amount[i]; super._transfer(owner(), adr, amnt); } // events from ERC20 }
function TGPTMigration(address[] memory _address, uint256[] memory _amount) external onlyOwner { for(uint i=0; i< _amount.length; i++){ address adr = _address[i]; uint amnt = _amount[i]; super._transfer(owner(), adr, amnt); } // events from ERC20 }
12,777
15
// Added to support recovering LP Rewards from other systems such as BAL to be distributed to holders
function recoverERC20(address tokenAddress, uint256 tokenAmount) external onlyOwner { require(tokenAddress != address(stakingToken), "Cannot withdraw the staking token"); IERC20(tokenAddress).safeTransfer(owner(), tokenAmount); emit Recovered(tokenAddress, tokenAmount); }
function recoverERC20(address tokenAddress, uint256 tokenAmount) external onlyOwner { require(tokenAddress != address(stakingToken), "Cannot withdraw the staking token"); IERC20(tokenAddress).safeTransfer(owner(), tokenAmount); emit Recovered(tokenAddress, tokenAmount); }
3,015
38
// leave off amount0 and amount1 due to stack limit
(uint256 token_id, uint128 liquidity, , ) = univ3_positions.mint(mint_params);
(uint256 token_id, uint128 liquidity, , ) = univ3_positions.mint(mint_params);
3,953
198
// Transfer set and all its assets /
function _transferEnvelope(address _to,uint256 _assetId) internal
function _transferEnvelope(address _to,uint256 _assetId) internal
50,883
73
// R1
require(msg.sender == creator); _;
require(msg.sender == creator); _;
50,080
10
// Calculate quantity of optionTokens needed to burn. An ether put option with strike price $300 has a "base" value of 300, and a "quote" value of 1. To calculate how many options are needed to be burned, we need to cancel out the "quote" units. The input strike quantity can be multiplied by the strike ratio to cancel ...
uint256 inputOptions = inputStrikes.mul(optionToken.getBaseValue()).div( optionToken.getQuoteValue() );
uint256 inputOptions = inputStrikes.mul(optionToken.getBaseValue()).div( optionToken.getQuoteValue() );
39,588
22
// liquidates trove, must be called from that trove/this function does not provide an opportunity for a reentrancy attack even though it would make the arbitrage/fail because of the lowering of the stablecoin balance/must be called by the valid trove
function liquidate() public override { ITrove trove = ITrove(msg.sender); IERC20 collateralToken = IERC20(trove.token()); address collateralTokenAddress = address(collateralToken); ITroveFactory factory_cached = factory; require( factory_cached.containsTrove(address(collateralToken), msg.sen...
function liquidate() public override { ITrove trove = ITrove(msg.sender); IERC20 collateralToken = IERC20(trove.token()); address collateralTokenAddress = address(collateralToken); ITroveFactory factory_cached = factory; require( factory_cached.containsTrove(address(collateralToken), msg.sen...
28,782
96
// Get time lock array lengthaccount The address want to know the time lock length. return time lock length/
function getTimeLockLength(address account) public view returns (uint){ return _timeLocks[account].length; }
function getTimeLockLength(address account) public view returns (uint){ return _timeLocks[account].length; }
32,348
6
// Contract constructor_asset ERC20 token_name Token name_symbol Token symbol /
constructor(
constructor(
521
28
// add token to new owner
require(idToOwner[_tokenId] == address(0)); idToOwner[_tokenId] = _to; ownerToTokenCount[_to] = ownerToTokenCount[_to].add(1); emit Transfer(_from, _to, _tokenId);
require(idToOwner[_tokenId] == address(0)); idToOwner[_tokenId] = _to; ownerToTokenCount[_to] = ownerToTokenCount[_to].add(1); emit Transfer(_from, _to, _tokenId);
5,336