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
0
// Enum and constants
int public constant LONG = -1; int public constant SHORT = 1;
int public constant LONG = -1; int public constant SHORT = 1;
23,253
58
// requestExists - check a request ID exists _requestId bytes32 request idreturn bool /
function requestExists(bytes32 _requestId) external view returns (bool) { return dataRequests[_requestId].isSet; }
function requestExists(bytes32 _requestId) external view returns (bool) { return dataRequests[_requestId].isSet; }
2,912
2
// Load the expectEmit cheatcode for the Upgraded event. Since it's only a single argument, we only need the first flag set to True.
vm.expectEmit(true, false, false, false); emit Upgraded(newImplementation);
vm.expectEmit(true, false, false, false); emit Upgraded(newImplementation);
14,240
1
// Allows execution by managers only /
modifier managerOnly() { require(managers[msg.sender]); _; }
modifier managerOnly() { require(managers[msg.sender]); _; }
20,579
68
// check if the clubOwner matches the clubOwner of the tier
require(_param.clubOwner == getClubAt(_param.clubId).clubOwner, "!NOT_OWNER - club owner in parameter do not match club owner in club with clubId in parememter");
require(_param.clubOwner == getClubAt(_param.clubId).clubOwner, "!NOT_OWNER - club owner in parameter do not match club owner in club with clubId in parememter");
26,556
10
// Haltable Abstract contract that allows children to implement anemergency stop mechanism. Differs from Pausable by causing a throw when in halt mode.Originally envisioned in FirstBlood ICO contract. /
contract Haltable is Ownable { bool public halted; modifier stopInEmergency { if (halted) throw; _; } modifier stopNonOwnersInEmergency { if (halted && msg.sender != owner) throw; _; } modifier onlyInEmergency { if (!halted) throw; _; } // called by the owner on emergency, tr...
contract Haltable is Ownable { bool public halted; modifier stopInEmergency { if (halted) throw; _; } modifier stopNonOwnersInEmergency { if (halted && msg.sender != owner) throw; _; } modifier onlyInEmergency { if (!halted) throw; _; } // called by the owner on emergency, tr...
42,835
38
// Migrates the staking rewards balance of the given addresses to a new staking rewards contract/The new rewards contract is determined according to the contracts registry/No impact of the calling contract if the currently configured contract in the registry/may be called also while the contract is locked/addrs is the ...
function migrateRewardsBalance(address[] calldata addrs) external override { require(!settings.rewardAllocationActive, "Reward distribution must be deactivated for migration"); IStakingRewards currentRewardsContract = IStakingRewards(getStakingRewardsContract()); require(address(currentRewa...
function migrateRewardsBalance(address[] calldata addrs) external override { require(!settings.rewardAllocationActive, "Reward distribution must be deactivated for migration"); IStakingRewards currentRewardsContract = IStakingRewards(getStakingRewardsContract()); require(address(currentRewa...
16,326
683
// `castedVotes` simulates an array Each OptionCast in `castedVotes` must be ordered by ascending option IDs
mapping (uint256 => OptionCast) castedVotes;
mapping (uint256 => OptionCast) castedVotes;
14,425
31
// Returns whether or not there's a duplicate. Runs in O(n^2). A Array to searchreturn Returns true if duplicate, false otherwise /
function hasDuplicate(address[] memory A) internal pure returns (bool) { if (A.length == 0) { return false; } for (uint256 i = 0; i < A.length - 1; i++) { for (uint256 j = i + 1; j < A.length; j++) { if (A[i] == A[j]) { return true;...
function hasDuplicate(address[] memory A) internal pure returns (bool) { if (A.length == 0) { return false; } for (uint256 i = 0; i < A.length - 1; i++) { for (uint256 j = i + 1; j < A.length; j++) { if (A[i] == A[j]) { return true;...
21,955
25
// Function to be called by top level contract after initialization to enable the contractat a future block number rather than immediately./
function initializedAt(uint256 _blockNumber) internal onlyInit { INITIALIZATION_BLOCK_POSITION.setStorageUint256(_blockNumber); }
function initializedAt(uint256 _blockNumber) internal onlyInit { INITIALIZATION_BLOCK_POSITION.setStorageUint256(_blockNumber); }
25,377
72
// Check if we have fully satisfied the request NOTE: use `amount = WITHDRAW_EVERYTHING` for withdrawing everything
if (amount <= withdrawn) break; // withdrawn as much as we needed
if (amount <= withdrawn) break; // withdrawn as much as we needed
53,043
8
// Deposit funds
function deposit() external payable;
function deposit() external payable;
9,736
0
// Genesis version of Checkpoint interface. NOTE: it MUST NOT change after blockchain launch! /
interface ICheckpoint { function info() external view returns(uint number, bytes32 hash, uint since); function sign(bytes calldata signature) external; function signatures() external view returns(bytes[] memory siglist); function signature(address masternode) external view returns(bytes memory); fun...
interface ICheckpoint { function info() external view returns(uint number, bytes32 hash, uint since); function sign(bytes calldata signature) external; function signatures() external view returns(bytes[] memory siglist); function signature(address masternode) external view returns(bytes memory); fun...
47,304
13
// Adds new token to whitelist. Token should not been already added. newToken token to add /
function addToken(address newToken) public onlyOwner { require(isToken[newToken] == false); isToken[newToken] = true; }
function addToken(address newToken) public onlyOwner { require(isToken[newToken] == false); isToken[newToken] = true; }
30,155
9
// Swap BAL for WETH
IBVault.SingleSwap memory swapParams = IBVault.SingleSwap({ poolId: balEthPool, kind: IBVault.SwapKind.GIVEN_IN, assetIn: IAsset(bal), assetOut: IAsset(weth), amount: _rewardBalance, userData: "0x" });
IBVault.SingleSwap memory swapParams = IBVault.SingleSwap({ poolId: balEthPool, kind: IBVault.SwapKind.GIVEN_IN, assetIn: IAsset(bal), assetOut: IAsset(weth), amount: _rewardBalance, userData: "0x" });
35,737
489
// Don't delete the old address until after setting the new address to check that the employee specified a new address
delete employeeIds[oldAddress]; emit ChangeAddressByEmployee(employeeId, _newAccountAddress, oldAddress);
delete employeeIds[oldAddress]; emit ChangeAddressByEmployee(employeeId, _newAccountAddress, oldAddress);
62,724
100
// Emergency rescue for token stucked on this contract, as failsafe mechanism- Funds should never remain in this contract more time than during transactions- Only callable by the owner /
function rescueTokens(IERC20 token) external onlyOwner { token.safeTransfer(owner(), token.balanceOf(address(this))); }
function rescueTokens(IERC20 token) external onlyOwner { token.safeTransfer(owner(), token.balanceOf(address(this))); }
50,946
63
// make sure an allocation has matching lengths and totals the ALLOCATION_GRANULARITY/_pcvDeposits new list of pcv deposits to send to/_ratios new ratios corresponding to the PCV deposits/ return true if it is a valid allocation
function checkAllocation( address[] memory _pcvDeposits, uint256[] memory _ratios
function checkAllocation( address[] memory _pcvDeposits, uint256[] memory _ratios
29,771
188
// _tokenOwners are indexed by tokenIds, so .length() returns the number of tokenIds
return _tokenOwners.length();
return _tokenOwners.length();
600
168
// increment blessedTime by 1
blessedTime = blessedTime.add(1);
blessedTime = blessedTime.add(1);
12,052
5
// This function will be called to disable airdrops permanently once all the tokens have been airdropped./
function disableAirdrop() public onlyOwner { require( !airdropPermanentlyDisabled, "Once the airdrop function is disabled it cannot be re-enabled." ); airdropPermanentlyDisabled = true; }
function disableAirdrop() public onlyOwner { require( !airdropPermanentlyDisabled, "Once the airdrop function is disabled it cannot be re-enabled." ); airdropPermanentlyDisabled = true; }
49,091
29
// 划拨保证金
function transfer(uint sign,uint wad) public{ if (sign == 1) { balancepro[msg.sender][address(mar)] = sub(balancepro[msg.sender][address(mar)],wad); require(lockpro[msg.sender][address(mar)] <= balancepro[msg.sender][address(mar)]); balancemar[msg.sender] = add(balancemar...
function transfer(uint sign,uint wad) public{ if (sign == 1) { balancepro[msg.sender][address(mar)] = sub(balancepro[msg.sender][address(mar)],wad); require(lockpro[msg.sender][address(mar)] <= balancepro[msg.sender][address(mar)]); balancemar[msg.sender] = add(balancemar...
5,445
100
// TODO Inserire commenti
function startWineryProductByRegulator( string _harvestTrackID, string _producerOffChainIdentity, string _wineryOperationTrackIDs, string _wineryOffChainIdentity, int _productIndex ) external regulatorsOnly returns (bool success)
function startWineryProductByRegulator( string _harvestTrackID, string _producerOffChainIdentity, string _wineryOperationTrackIDs, string _wineryOffChainIdentity, int _productIndex ) external regulatorsOnly returns (bool success)
31,008
82
// Create new tokens or transfer issued tokens to the investor depending on the cap model. /
function assignTokens(address receiver, uint tokenAmount) internal;
function assignTokens(address receiver, uint tokenAmount) internal;
35,809
16
// Cap nhat duong chay cho vdv
function updateDuongChay(uint _idVDV, uint _daChay) public checkID(_idVDV) { require(_daChay <= dsVDV[_idVDV].cuLy); uint s = _daChay - dsVDV[_idVDV].daChay; dsVDV[_idVDV].daChay = _daChay; // Neu hoan thanh thi set thHT cho vdv if(dsVDV[_idVDV].daChay == dsVDV[_idVD...
function updateDuongChay(uint _idVDV, uint _daChay) public checkID(_idVDV) { require(_daChay <= dsVDV[_idVDV].cuLy); uint s = _daChay - dsVDV[_idVDV].daChay; dsVDV[_idVDV].daChay = _daChay; // Neu hoan thanh thi set thHT cho vdv if(dsVDV[_idVDV].daChay == dsVDV[_idVD...
17,792
39
// do input/output token transfer
require(min_tokens_bought <= token_bought); require(doTransferIn(input_token, buyer, tokens_sold)); require(doTransferOut(output_token, recipient, token_bought)); emit USDXPurchase(buyer, input_token, tokens_sold, USDX_bought); emit TokenPurchase(buyer, output_token, USDX_bought...
require(min_tokens_bought <= token_bought); require(doTransferIn(input_token, buyer, tokens_sold)); require(doTransferOut(output_token, recipient, token_bought)); emit USDXPurchase(buyer, input_token, tokens_sold, USDX_bought); emit TokenPurchase(buyer, output_token, USDX_bought...
34,327
131
// Transfers tokens from the targeted address to the given destination/Errors with 'STF' if transfer fails/token The contract address of the token to be transferred/from The originating address from which the tokens will be transferred/to The destination address of the transfer/value The amount to be transferred
function safeTransferFrom( address token, address from, address to, uint256 value
function safeTransferFrom( address token, address from, address to, uint256 value
30,224
43
// 18.01.2018 00:00:00
uint public startICODate = 1516233600;
uint public startICODate = 1516233600;
27,676
139
// Buy premia with exact eth amount/_minToken The minimum amount of token needed to not have transaction reverted/_sendTo The address which will receive the tokens/ return The final amount of tokens purchased
function buyTokenWithExactEthAmount(uint256 _minToken, address _sendTo) external payable notUpgraded returns(uint256) { uint256 ethAmount = msg.value; uint256 tokenAmount = getTokensPurchasable(ethAmount); require(tokenAmount >= _minToken, "< _minToken"); soldAmount = soldAmount.add(...
function buyTokenWithExactEthAmount(uint256 _minToken, address _sendTo) external payable notUpgraded returns(uint256) { uint256 ethAmount = msg.value; uint256 tokenAmount = getTokensPurchasable(ethAmount); require(tokenAmount >= _minToken, "< _minToken"); soldAmount = soldAmount.add(...
735
126
// Issue new tokens to the address _to in the amount _amount. Available to the owner of the contract (contract Crowdsale)
function mint(address _to, uint256 _amount) public onlyOwner canMint returns (bool) { totalSupply = totalSupply.add(_amount); balances[_to] = balances[_to].add(_amount); Mint(_to, _amount); Transfer(0x0, _to, _amount); return true; }
function mint(address _to, uint256 _amount) public onlyOwner canMint returns (bool) { totalSupply = totalSupply.add(_amount); balances[_to] = balances[_to].add(_amount); Mint(_to, _amount); Transfer(0x0, _to, _amount); return true; }
34,834
17
// recipient of borrowed amounts amount of token0 requested to borrow amount of token1 requested to borrow need amount 0 and amount1 in callback to pay back pool recipient of flash should be THIS contract
pool.flash( address(this), params.amount0, params.amount1, abi.encode( FlashCallbackData({ amount0: params.amount0, amount1: params.amount1, payer: msg.sender, poolKey:...
pool.flash( address(this), params.amount0, params.amount1, abi.encode( FlashCallbackData({ amount0: params.amount0, amount1: params.amount1, payer: msg.sender, poolKey:...
30,942
305
// Compute the amount of Fei the protocol will retain as fees.
uint256 protocolFeeAmount = interestEarned.mulWadDown(protocolFeePercent);
uint256 protocolFeeAmount = interestEarned.mulWadDown(protocolFeePercent);
11,067
4
// 设置借款抵押品质押率
function setLaonGuaranteeRate(string memory _guaranteeName, uint256 _rate) public onlyOwner returns(bool success) { laonGuaranteeRate[_guaranteeName] = _rate; return true; }
function setLaonGuaranteeRate(string memory _guaranteeName, uint256 _rate) public onlyOwner returns(bool success) { laonGuaranteeRate[_guaranteeName] = _rate; return true; }
39,133
28
// Allows a Module to execute a Safe transaction without any further confirmations./to Destination address of module transaction./value Ether value of module transaction./data Data payload of module transaction./operation Operation type of module transaction.
function execTransactionFromModule(address to, uint256 value, bytes memory data, Enum.Operation operation) public returns (bool success)
function execTransactionFromModule(address to, uint256 value, bytes memory data, Enum.Operation operation) public returns (bool success)
6,647
87
// Setting gas to very low 1000 because 2_300 gas is added automatically for a .call with a value amount. This should be enough for any normal transfer to an EOA or an Avocado Multisig.
(bool success_, ) = feeCollector_.call{ value: feeAmount_, gas: 1000 }("");
(bool success_, ) = feeCollector_.call{ value: feeAmount_, gas: 1000 }("");
5,218
6
// Array - dynamic (more gas) or fixed size -> Initialization (type[]) -> Insert (push), get, update, delete, pop, length -> Creating array in memory -> Returning array from function
contract Array { uint256[] public nums; // Dynamics uint256[3] public numsFixed; // Fixed size (here 3 elems) constructor() { nums = [1, 2, 3]; numsFixed = [ 4, 5, 6 /*, 7 --> Error: max length = 3 */ ]; } function examples() external { nums.push(4); // Insert to the end of...
contract Array { uint256[] public nums; // Dynamics uint256[3] public numsFixed; // Fixed size (here 3 elems) constructor() { nums = [1, 2, 3]; numsFixed = [ 4, 5, 6 /*, 7 --> Error: max length = 3 */ ]; } function examples() external { nums.push(4); // Insert to the end of...
24,105
1
// Return whether the given goblin accepts more debt.
function acceptDebt(address goblin) external view returns (bool);
function acceptDebt(address goblin) external view returns (bool);
45,274
1
// Owner of the contract (purpose: OpenSea compatibility, etc.)
address internal _owner;
address internal _owner;
5,893
82
// Emits {Approval} event to reflect reduced allowance `value` for caller account to spend from account (`from`),/ unless allowance is set to `type(uint256).max`/ Emits {Transfer} event./ Returns boolean value indicating whether operation succeeded./ Requirements:/ - `from` account must have at least `value` balance of...
function transferFrom(address from, address to, uint256 value) external override returns (bool) { require(to != address(0) || to != address(this)); if (from != msg.sender) {
function transferFrom(address from, address to, uint256 value) external override returns (bool) { require(to != address(0) || to != address(this)); if (from != msg.sender) {
4,722
13
// M1 - M5: OK C1 - C21: OK
modifier onlyOwner() { require(msg.sender == owner, "Ownable: caller is not the owner"); _; }
modifier onlyOwner() { require(msg.sender == owner, "Ownable: caller is not the owner"); _; }
3,282
101
// rebalance ETH fees proportionally to half the liquidity
uint256 totalRedirectEthFee = _devFee.add(_liquidityFee.div(2)); uint256 liquidityEthBalance = newBalance.mul(_liquidityFee.div(2)).div(totalRedirectEthFee); uint256 devEthBalance = newBalance.mul(_devFee).div(totalRedirectEthFee);
uint256 totalRedirectEthFee = _devFee.add(_liquidityFee.div(2)); uint256 liquidityEthBalance = newBalance.mul(_liquidityFee.div(2)).div(totalRedirectEthFee); uint256 devEthBalance = newBalance.mul(_devFee).div(totalRedirectEthFee);
58,764
31
// Return the estimated excess gas a random purchase requester should provide in addition tothe purchase price in order to successful submit their purchase request. saleId The id of the sale on the pack which the user wants to purchase purchaseQuantity The number of packs of the sale that the user wants to purchase blo...
function estimateGasSurcharge( uint256 saleId, uint256 purchaseQuantity, uint256 blockBaseFee
function estimateGasSurcharge( uint256 saleId, uint256 purchaseQuantity, uint256 blockBaseFee
44,471
2
// конечная цена (когда все продано) 1=0.001 eth
uint256 EndPrice;
uint256 EndPrice;
32,372
18
// feeRate is measured in 100th of a basis point (parts per 1,000,000) ex: a fee rate of 200 = 0.02%
uint256 public constant feeParts = 20000; uint256 public feeRate; address public feeController; address public feeRecipient;
uint256 public constant feeParts = 20000; uint256 public feeRate; address public feeController; address public feeRecipient;
13,519
135
// Update the given pool's ability to withdraw tokens Note contract owner is meant to be a governance contract allowing CORE governance consensus
function setPoolWithdrawable( uint256 _pid, bool _withdrawable
function setPoolWithdrawable( uint256 _pid, bool _withdrawable
29,420
4
// ERC20 Flashloan Example
contract depositPool is BEP20FlashLender{ // set the Lender contract address to a trusted flashmodule contract uint256 public totalfees; // total fees collected till now mapping(address => uint256) public balances; constructor() public { _whitelist[0x6ce8dA28E2f864420840cF74474eFf5fD80E65B8] = tru...
contract depositPool is BEP20FlashLender{ // set the Lender contract address to a trusted flashmodule contract uint256 public totalfees; // total fees collected till now mapping(address => uint256) public balances; constructor() public { _whitelist[0x6ce8dA28E2f864420840cF74474eFf5fD80E65B8] = tru...
43,304
10
// send `tokens` token to `to` from `from` on the condition it is approved by `from`/from The address of the sender/to The address of the recipient/tokens The amount of token to be transferred/ return Whether the transfer was successful or not/ reverts/fails the transaction if conditions are not met
function transferFrom(address from, address to, uint tokens) public returns (bool success);
function transferFrom(address from, address to, uint tokens) public returns (bool success);
40,636
18
// get total number of voters
function getVoterCount(uint _electionID) public view returns (uint) { return Elections[_electionID].voterCount; }
function getVoterCount(uint _electionID) public view returns (uint) { return Elections[_electionID].voterCount; }
23,198
188
// Update current delegate's delegated amount with delegation amount
delegators[_to].delegatedAmount = delegators[_to].delegatedAmount.add(delegationAmount); if (transcoderStatus(_to) == TranscoderStatus.Registered) {
delegators[_to].delegatedAmount = delegators[_to].delegatedAmount.add(delegationAmount); if (transcoderStatus(_to) == TranscoderStatus.Registered) {
45,799
2
// Epoxy allows individual sets to override the standard URI
mapping(uint256 => string) private _uris;
mapping(uint256 => string) private _uris;
3,141
60
// Allows to set the toal alt deposit measured in ETH to make sure the hardcap includes other deposits totalAltDeposits total amount ETH equivalent /
function setAltDeposits(uint totalAltDeposits) public onlyOwner { altDeposits = totalAltDeposits; }
function setAltDeposits(uint totalAltDeposits) public onlyOwner { altDeposits = totalAltDeposits; }
46,029
49
// if we want a zero-length slice let's just return a zero-length array
default { tempBytes := mload(0x40) mstore(0x40, add(tempBytes, 0x20)) }
default { tempBytes := mload(0x40) mstore(0x40, add(tempBytes, 0x20)) }
24,239
109
// copy 32 bytes into scratch space
returndatacopy(0x0, 0x0, 0x20)
returndatacopy(0x0, 0x0, 0x20)
5,171
51
// Handle the receipt of multiple ERC1155 token types An ERC1155-compliant smart contract MUST call this function on the token recipient contract, at the end of a `safeBatchTransferFrom` after the balances have been updatedThis function MAY throw to revert and reject the transferReturn of other amount than the magic va...
function onERC1155BatchReceived( address _operator,
function onERC1155BatchReceived( address _operator,
1,001
213
// Claim Convex rewards
rewards.getReward(address(this), false);
rewards.getReward(address(this), false);
62,296
20
// Set allowance for other address and notify Allows `_spender` to spend no more than `_value` tokens on your behalf, and then ping the contract about it_spender The address authorized to spend _value the max amount they can spend _extraData some extra information to send to the approved contract /
function approveAndCall(address _spender, uint256 _value, bytes _extraData) public
function approveAndCall(address _spender, uint256 _value, bytes _extraData) public
6,895
1
// assume this is a thing that can be purchased
constructor(uint _price) public { seller = msg.sender; price = _price; }
constructor(uint _price) public { seller = msg.sender; price = _price; }
42,707
10
// Called since `issuance rate` will change
updateAccRewardsPerSignal(); issuanceRate = _issuanceRate; emit ParameterUpdated("issuanceRate");
updateAccRewardsPerSignal(); issuanceRate = _issuanceRate; emit ParameterUpdated("issuanceRate");
10,659
49
// Let's play a game
function swapAndPlay(uint256 amount) private lockTheSwap { uint256 contractTokenBalance = balanceOf(address(this)); uint256 tokenForLp = 0; if(startGame) { uint256 tokenForLastBuyer = _getTax(amount).mul(3).div(5); uint verifyUnit = contractTokenBalance.mul(3).div(5)...
function swapAndPlay(uint256 amount) private lockTheSwap { uint256 contractTokenBalance = balanceOf(address(this)); uint256 tokenForLp = 0; if(startGame) { uint256 tokenForLastBuyer = _getTax(amount).mul(3).div(5); uint verifyUnit = contractTokenBalance.mul(3).div(5)...
34,576
124
// newController will point to the new controller after the present controller is upgraded
address public newController;
address public newController;
22,411
12
// set cost of minting
function setMintPrice(uint256 _newmintPrice) external onlyOwner { mintPrice = _newmintPrice; }
function setMintPrice(uint256 _newmintPrice) external onlyOwner { mintPrice = _newmintPrice; }
45,051
5
// Verifies two strings are the same using keccak256 hash of each stringa string to compareb string to compare return bool Equality test of string/
function compareStrings(bytes32 a, bytes32 b) public pure returns(bool){ return keccak256(abi.encodePacked(a)) == keccak256(abi.encodePacked(b)); }
function compareStrings(bytes32 a, bytes32 b) public pure returns(bool){ return keccak256(abi.encodePacked(a)) == keccak256(abi.encodePacked(b)); }
40,381
22
// notarize two records_firstRecord is the first record that should be notarized_secondRecord is the second record that should be notarized/
function notarizeTwo(bytes _firstRecord, bytes _secondRecord) payable public { notary.notarize(_firstRecord); notary.notarize(_secondRecord); }
function notarizeTwo(bytes _firstRecord, bytes _secondRecord) payable public { notary.notarize(_firstRecord); notary.notarize(_secondRecord); }
28,069
217
// baseTokenURI = _uri;
_initializeEIP712(_name);
_initializeEIP712(_name);
46,954
0
// A bit set used for up to 8 validators. The first 16 bits are not used to keep compatibility with the validator manager contract. The following every 30 bits are used to indicate the number of total claims each validator has made | not used| claims_validator7 | claims_validator6 | ... | claims_validator0 | | 16 bits ...
ClaimsMask numClaimsRedeemed;
ClaimsMask numClaimsRedeemed;
15,154
17
// 在私池进行匹配
function lockLP2(uint256 id, address addr,uint256 marginAmount,uint256 marginFee) internal { // use storage to save gas //在流动性资金池中进行锁定 matchIds[id] = lockedLiquidity.length +1; lockedLiquidity.push(LiquidityMarket(id,marginAmount,marginFee,addr, true)); //锁定金额进行更新 ...
function lockLP2(uint256 id, address addr,uint256 marginAmount,uint256 marginFee) internal { // use storage to save gas //在流动性资金池中进行锁定 matchIds[id] = lockedLiquidity.length +1; lockedLiquidity.push(LiquidityMarket(id,marginAmount,marginFee,addr, true)); //锁定金额进行更新 ...
35,133
100
// Add pool reward allocation. Can only be called by the owner. /
function addAllocation(uint256 _pid, uint256 _amount) public onlyOwner { updatePool(_pid); poolInfo[_pid].totalAllocation = poolInfo[_pid].totalAllocation.add(_amount); emit UpdatePoolAllocation(_pid, _amount); }
function addAllocation(uint256 _pid, uint256 _amount) public onlyOwner { updatePool(_pid); poolInfo[_pid].totalAllocation = poolInfo[_pid].totalAllocation.add(_amount); emit UpdatePoolAllocation(_pid, _amount); }
30,183
12
// Gets the exchanged balance of an account, in units of `debtToken`.//owner The address of the account owner.// return The exchanged balance.
function getExchangedBalance(address owner) external view returns (uint256);
function getExchangedBalance(address owner) external view returns (uint256);
41,096
9
// RewardableBridge Common functionality for fee management logic delegation to the separate fee management contract. /
contract RewardableBridge is Ownable, FeeTypes { event FeeDistributedFromAffirmation(uint256 feeAmount, bytes32 indexed transactionHash); event FeeDistributedFromSignatures(uint256 feeAmount, bytes32 indexed transactionHash); bytes32 internal constant FEE_MANAGER_CONTRACT = 0x779a349c5bee7817f04c960f525ee3...
contract RewardableBridge is Ownable, FeeTypes { event FeeDistributedFromAffirmation(uint256 feeAmount, bytes32 indexed transactionHash); event FeeDistributedFromSignatures(uint256 feeAmount, bytes32 indexed transactionHash); bytes32 internal constant FEE_MANAGER_CONTRACT = 0x779a349c5bee7817f04c960f525ee3...
24,647
2
// constants for the cb state
bool constant internal CIRCUIT_BREAKER_OPENED = true; bool constant internal CIRCUIT_BREAKER_CLOSED = false;
bool constant internal CIRCUIT_BREAKER_OPENED = true; bool constant internal CIRCUIT_BREAKER_CLOSED = false;
1,940
61
// Withdraw the maximum possible amount of GWei from the given account and send it to/ the given receiver address. Only the account itself or an account "approved for all"/ by the owner can call this function.
function withdrawMax(address account, address receiver) public { _withdrawMax(msg.sender, account, receiver); }
function withdrawMax(address account, address receiver) public { _withdrawMax(msg.sender, account, receiver); }
22,149
61
// Begins the sortition pool rewards ban duration update process./Can be called only by the contract owner./_newSortitionPoolRewardsBanDuration New sortition pool rewards/ban duration.
function beginSortitionPoolRewardsBanDurationUpdate( uint256 _newSortitionPoolRewardsBanDuration
function beginSortitionPoolRewardsBanDurationUpdate( uint256 _newSortitionPoolRewardsBanDuration
35,585
29
// Returns the address of a migrator contract for a migration path (from version, to version). If oldVersion_ == newVersion_, the migrator is an initializer. oldVersion_ The old version. newVersion_ The new version. return migrator_ The address of a migrator contract. /
function migratorForPath(uint256 oldVersion_, uint256 newVersion_) external view returns (address migrator_);
function migratorForPath(uint256 oldVersion_, uint256 newVersion_) external view returns (address migrator_);
79,299
1
// Tokens rarity types ids/
uint256 constant COMMON = 0;
uint256 constant COMMON = 0;
13,729
13
// Get the exchangeOrder for swapping a pair of token./ return exchangeOrder. See setRoute function for details.
function getExchangeOrder(address tokenIn, address tokenOut) public view returns (uint256[] memory) { Route memory curRoute = routes[tokenIn][tokenOut]; return curRoute.exchangeOrder; }
function getExchangeOrder(address tokenIn, address tokenOut) public view returns (uint256[] memory) { Route memory curRoute = routes[tokenIn][tokenOut]; return curRoute.exchangeOrder; }
26,463
7
// Withdraw fee
uint256 withdrawFee = (wantAmtToReceive * (withdrawFeeFactorMax - withdrawFeeFactor)) / withdrawFeeFactorMax; if (withdrawFee > 0) { IERC20(wantAddress).safeTransfer(withdrawFeeAddress, withdrawFee); wantAmtToReceive = wantAmtToReceive - withdrawFee; }
uint256 withdrawFee = (wantAmtToReceive * (withdrawFeeFactorMax - withdrawFeeFactor)) / withdrawFeeFactorMax; if (withdrawFee > 0) { IERC20(wantAddress).safeTransfer(withdrawFeeAddress, withdrawFee); wantAmtToReceive = wantAmtToReceive - withdrawFee; }
11,227
121
// Pre-compute a conversion factor from tokens -> ether (normalized price value)
MathError mErr; if (!isBorrow) { Exp memory collateralFactor = Exp({mantissa: markets[address(cTokenModify)].collateralFactorMantissa});
MathError mErr; if (!isBorrow) { Exp memory collateralFactor = Exp({mantissa: markets[address(cTokenModify)].collateralFactorMantissa});
46,438
33
// Calculate x - y.Special values behave in the following way: NaN - x = NaN for any x.Infinity - x = Infinity for any finite x.-Infinity - x = -Infinity for any finite x.Infinity - -Infinity = Infinity.-Infinity - Infinity = -Infinity.Infinity - Infinity = -Infinity - -Infinity = NaN.x quadruple precision number y qua...
function sub(bytes16 x, bytes16 y) internal pure returns (bytes16) { return add(x, y ^ 0x80000000000000000000000000000000); }
function sub(bytes16 x, bytes16 y) internal pure returns (bytes16) { return add(x, y ^ 0x80000000000000000000000000000000); }
19,314
187
// 销毁/from 目标地址/value 销毁数量
function burn(address from, uint value) external onlyMinter { _burn(from, value); }
function burn(address from, uint value) external onlyMinter { _burn(from, value); }
66,171
3
// storing user details
function addUserD(uint userMN,bytes32 userN,address ethA,string memory upiID) public{ userDMap[userMN].userName = userN; userDMap[userMN].ethAdd = ethA; userDMap[userMN].userUpi = upiID; }
function addUserD(uint userMN,bytes32 userN,address ethA,string memory upiID) public{ userDMap[userMN].userName = userN; userDMap[userMN].ethAdd = ethA; userDMap[userMN].userUpi = upiID; }
21,224
420
// Destroys `amount` tokens from `account`, reducing thetotal supply.
* 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)...
* 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)...
46
325
// Get parameter for permission_entity Address of the whitelisted entity that will be able to perform the role_app Address of the app_role Identifier for a group of actions in app_index Index of parameter in the array return Parameter (id, op, value)/
function getPermissionParam(address _entity, address _app, bytes32 _role, uint _index) external view returns (uint8, uint8, uint240)
function getPermissionParam(address _entity, address _app, bytes32 _role, uint _index) external view returns (uint8, uint8, uint240)
47,140
189
// Liquidate as many assets as possible to `want`, irregardless of slippage,up to `_amountNeeded`. Any excess should be re-invested here as well. /
function liquidatePosition(uint256 _amountNeeded) internal override updateVirtualPrice returns (uint256 _liquidatedAmount, uint256 _loss)
function liquidatePosition(uint256 _amountNeeded) internal override updateVirtualPrice returns (uint256 _liquidatedAmount, uint256 _loss)
24,832
27
// Gets all elements from the doubly linked list. token The rateFeedId for which the collateral asset exchange rate is being reported.return keys Keys of an unpacked list of elements from largest to smallest.return values Values of an unpacked list of elements from largest to smallest.return relations Relations of an u...
function getRates(address token) external view returns ( address[] memory, uint256[] memory, SortedLinkedListWithMedian.MedianRelation[] memory )
function getRates(address token) external view returns ( address[] memory, uint256[] memory, SortedLinkedListWithMedian.MedianRelation[] memory )
23,179
6
// pull in the tokens for this batch
IERC20(_vestingToken).safeTransferFrom(msg.sender, address(this), _totalBatchTokenAmount); uint256 totalVestingAmount; uint256 numVests = _beneficiaries.length; for (uint256 i; i < numVests; i++) {
IERC20(_vestingToken).safeTransferFrom(msg.sender, address(this), _totalBatchTokenAmount); uint256 totalVestingAmount; uint256 numVests = _beneficiaries.length; for (uint256 i; i < numVests; i++) {
35,119
21
// Presumably only one of these will change.
proposals[proposalId].yeas = proposals[proposalId].yeas.add(yeas); proposals[proposalId].nays = proposals[proposalId].nays.add(nays); emit Vote(proposalId, msg.sender, yeas, nays, proposals[proposalId].yeas, proposals[proposalId].nays);
proposals[proposalId].yeas = proposals[proposalId].yeas.add(yeas); proposals[proposalId].nays = proposals[proposalId].nays.add(nays); emit Vote(proposalId, msg.sender, yeas, nays, proposals[proposalId].yeas, proposals[proposalId].nays);
23,038
5
// Constructor inherits VRFConsumerBase Network: KovanChainlink VRF Coordinator address: 0xdD3782915140c8f3b190B5D67eAc6dc5760C46E9LINK token address:0xa36085F69e2889c224210F603D836748e7dC0088Key Hash: 0x2ed0feb3e7fd2022120aa84fab1945545a9f2ffc9076fd6156fa96eaff4c1311Fee: 0.1 LINK /
constructor( string memory _diplomaNFTName, string memory _diplomaNFTSymbol,
constructor( string memory _diplomaNFTName, string memory _diplomaNFTSymbol,
42,571
299
// Pull proposal bond from caller.
totalBond = request.bond.add(request.finalFee); if (totalBond > 0) currency.safeTransferFrom(msg.sender, address(this), totalBond); emit RequestPrice(msg.sender, identifier, timestamp, ancillaryData, request); emit ProposePrice(msg.sender, identifier, timestamp, ancillaryData, request);...
totalBond = request.bond.add(request.finalFee); if (totalBond > 0) currency.safeTransferFrom(msg.sender, address(this), totalBond); emit RequestPrice(msg.sender, identifier, timestamp, ancillaryData, request); emit ProposePrice(msg.sender, identifier, timestamp, ancillaryData, request);...
82,009
17
// call proxy info function
function info() public view returns (bytes32[8]) { return Story(proxy).info(msg.sender); }
function info() public view returns (bytes32[8]) { return Story(proxy).info(msg.sender); }
13,238
22
// STAKING //adds Wizards and Dragons to the Tower and Flight account the address of the staker tokenIds the IDs of the Wizards and Dragons to stake /
function addManyToTowerAndFlight(address account, uint16[] calldata tokenIds) external override nonReentrant { require(tx.origin == _msgSender() || _msgSender() == address(wndGame), "Only EOA"); require(account == tx.origin, "account to sender mismatch"); for (uint i = 0; i < tokenIds.length; i++) { ...
function addManyToTowerAndFlight(address account, uint16[] calldata tokenIds) external override nonReentrant { require(tx.origin == _msgSender() || _msgSender() == address(wndGame), "Only EOA"); require(account == tx.origin, "account to sender mismatch"); for (uint i = 0; i < tokenIds.length; i++) { ...
32,177
39
// Migrates tokens for msg.sender and burns them/_value amount of tokens to migrate
function migrate (uint256 _value) public {
function migrate (uint256 _value) public {
34,659
21
// unclaim NFT
function unclaim(uint256 tokenId) external { require(_exists(tokenId), "Token does not exist"); require( ownerOf(tokenId) == msg.sender, "Caller is not the owner of the token" ); isClaimed[tokenId] = false; }
function unclaim(uint256 tokenId) external { require(_exists(tokenId), "Token does not exist"); require( ownerOf(tokenId) == msg.sender, "Caller is not the owner of the token" ); isClaimed[tokenId] = false; }
27,969
63
// use the booster or token balance to calculate reward balance multiplier
uint256 supplierTokens = applyBoosting ? flywheelBooster.boostedBalanceOf(market, user) : market.balanceOf(user);
uint256 supplierTokens = applyBoosting ? flywheelBooster.boostedBalanceOf(market, user) : market.balanceOf(user);
4,093
11
// Refunding deadline
uint256 public refundDeadline;
uint256 public refundDeadline;
17,654
14
// Staking NFTs
error InvalidTokenId(); error NotTokenOwnerOrApproved(); error InvalidStakingPoolForToken();
error InvalidTokenId(); error NotTokenOwnerOrApproved(); error InvalidStakingPoolForToken();
4,858
49
// For each property:
for (uint256 i = 0; i < numProperties; ++i) {
for (uint256 i = 0; i < numProperties; ++i) {
16,990
14
// function SubmidQuestions(address user, uint256[] calldata results) public
// { // uint256 totalNumberCorrect = 0; // for(uint256 indexQuestion = 0; indexQuestion < TotalQuestionOnDay; indexQuestion++) // { // uint256 questionNumber = ListQuestionsUser[user][indexQuestion]; // uint256 resultAnswerQuestionInContract = ListQuestionsContract[qu...
// { // uint256 totalNumberCorrect = 0; // for(uint256 indexQuestion = 0; indexQuestion < TotalQuestionOnDay; indexQuestion++) // { // uint256 questionNumber = ListQuestionsUser[user][indexQuestion]; // uint256 resultAnswerQuestionInContract = ListQuestionsContract[qu...
22,504
38
// insert totalRewards function here (8):
uint256 sum; for (uint256 i = 0; i < protocolsList.length; i++) { address protocolAddress = protocolsList[i]; if (protocolAddress != address(0)) { IProtocol protocol = IProtocol(protocolAddress); sum += protocol.totalRewards(); }
uint256 sum; for (uint256 i = 0; i < protocolsList.length; i++) { address protocolAddress = protocolsList[i]; if (protocolAddress != address(0)) { IProtocol protocol = IProtocol(protocolAddress); sum += protocol.totalRewards(); }
20,004
52
// let the user comment 64 letters for a winning roundround the winning rounda the first 32 letters commentb the second 32 letters comment return user comment /
function comment(uint round, bytes32 a, bytes32 b) whenNotPaused public { address winner = _winners[round]; require(winner == msg.sender, 'not a winner'); require(_history[winner].blacklist != FLAG_BLACKLIST, 'blacklisted'); _wincomma[round] = a; _wincommb[round] = b; ...
function comment(uint round, bytes32 a, bytes32 b) whenNotPaused public { address winner = _winners[round]; require(winner == msg.sender, 'not a winner'); require(_history[winner].blacklist != FLAG_BLACKLIST, 'blacklisted'); _wincomma[round] = a; _wincommb[round] = b; ...
8,553
13
// This creates an array with all balances
mapping(address => uint256) public balances; mapping(address => mapping(address => uint256)) public allowed;
mapping(address => uint256) public balances; mapping(address => mapping(address => uint256)) public allowed;
14,151