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
11
// Start the arbitrage /
function makeArbitrage(uint256 amount) public onlyOwner { bytes memory data = ""; ERC20 dai = ERC20(DAI_ADDRESS); lendingPool.flashLoan(address(this), DAI_ADDRESS, amount, data); // Any left amount of DAI is considered profit uint256 profit = dai.balanceOf(address(this)); // Sending back the profits require( dai.transfer(msg.sender, profit), "Could not transfer back the profit" ); }
function makeArbitrage(uint256 amount) public onlyOwner { bytes memory data = ""; ERC20 dai = ERC20(DAI_ADDRESS); lendingPool.flashLoan(address(this), DAI_ADDRESS, amount, data); // Any left amount of DAI is considered profit uint256 profit = dai.balanceOf(address(this)); // Sending back the profits require( dai.transfer(msg.sender, profit), "Could not transfer back the profit" ); }
1,178
25
// frax amount converter to kashipar fraction/kashipair_address Address of kashipair/frax_amount Amount of Frax/ return fraction in kashipair
function fraxToKashipairFraction(address kashipair_address, uint frax_amount) public view returns (uint256) { require(kashipairs_check[kashipair_address], "KashiAMO: Add Kashipair address to AMO"); IKashiPairMediumRiskV1 newKashipair = IKashiPairMediumRiskV1(kashipair_address); uint256 share = SUSHIBentoBox.toShare(fraxAddress, frax_amount, false); (uint256 kashipair_totalAsset_elastic, uint256 kashipair_totalAsset_base) = newKashipair.totalAsset(); if (kashipair_totalAsset_elastic == 0) { return share; } else { return (share * kashipair_totalAsset_base) / kashipair_totalAsset_elastic; } }
function fraxToKashipairFraction(address kashipair_address, uint frax_amount) public view returns (uint256) { require(kashipairs_check[kashipair_address], "KashiAMO: Add Kashipair address to AMO"); IKashiPairMediumRiskV1 newKashipair = IKashiPairMediumRiskV1(kashipair_address); uint256 share = SUSHIBentoBox.toShare(fraxAddress, frax_amount, false); (uint256 kashipair_totalAsset_elastic, uint256 kashipair_totalAsset_base) = newKashipair.totalAsset(); if (kashipair_totalAsset_elastic == 0) { return share; } else { return (share * kashipair_totalAsset_base) / kashipair_totalAsset_elastic; } }
19,612
15
// Update the total balanceShares for this cycle
uint256 cycleTotalShares = yDaiSharesPerCycle.sub(yDaiSharesForContractBeforeWithdrawal.sub(yDaiSharesForContractAfterWithdrawal));
uint256 cycleTotalShares = yDaiSharesPerCycle.sub(yDaiSharesForContractBeforeWithdrawal.sub(yDaiSharesForContractAfterWithdrawal));
20,957
237
// ERC20 transfer function. /
function transfer(address to, uint value) public optionalProxy returns (bool) { systemStatus().requireSystemActive(); // Ensure they're not trying to exceed their staked SNX amount require(value <= transferableSynthetix(messageSender), "Cannot transfer staked or escrowed SNX"); // Perform the transfer: if there is a problem an exception will be thrown in this call. _transfer_byProxy(messageSender, to, value); return true; }
function transfer(address to, uint value) public optionalProxy returns (bool) { systemStatus().requireSystemActive(); // Ensure they're not trying to exceed their staked SNX amount require(value <= transferableSynthetix(messageSender), "Cannot transfer staked or escrowed SNX"); // Perform the transfer: if there is a problem an exception will be thrown in this call. _transfer_byProxy(messageSender, to, value); return true; }
5,770
207
// whitelist the given underwriter, add to the underwriterwhitelist. _underwriter the address of the underwriter /
function updateUnderwriterWhitelist(address _underwriter, bool _val) external onlyOwner { underwriterWhitelist[_underwriter] = _val; emit UnderwriterWhitelistUpdated(_underwriter, _val); }
function updateUnderwriterWhitelist(address _underwriter, bool _val) external onlyOwner { underwriterWhitelist[_underwriter] = _val; emit UnderwriterWhitelistUpdated(_underwriter, _val); }
31,074
19
// 提币
function withdraw(uint256 value) public { require(value > 0 && directPushMultiple(msg.sender) >= 3,"3 times withdrawal"); // 验证是否有足够提取额度 uint256 count = availableQuantity(msg.sender); require(count >= value,"Not enough quota"); // 提币 IERC20(ERC20).transfer(msg.sender,value); user[msg.sender].amountWithdrawn = user[msg.sender].amountWithdrawn.add(value); }
function withdraw(uint256 value) public { require(value > 0 && directPushMultiple(msg.sender) >= 3,"3 times withdrawal"); // 验证是否有足够提取额度 uint256 count = availableQuantity(msg.sender); require(count >= value,"Not enough quota"); // 提币 IERC20(ERC20).transfer(msg.sender,value); user[msg.sender].amountWithdrawn = user[msg.sender].amountWithdrawn.add(value); }
12,621
91
// Gets the token ID at a given index of the tokens list of the requested owner owner address owning the tokens list to be accessed index uint256 representing the index to be accessed of the requested tokens listreturn uint256 token ID at the given index of the tokens list owned by the requested address /
function tokenOfOwnerByIndex( address owner, uint256 index ) public view returns (uint256)
function tokenOfOwnerByIndex( address owner, uint256 index ) public view returns (uint256)
71,548
504
// Interacting with creditors // Creditor withdraws funds./ If _baseAssetRequested is less than the asset that the vehicle can provide, / it will withraw as much as possible./_baseAssetRequested the amount of base asset requested by the creditor / return The actual amount that the IV has sent back.
function withdrawAsCreditor( uint256 _baseAssetRequested
function withdrawAsCreditor( uint256 _baseAssetRequested
59,673
14
// Returns a JSON representation of the contract version containing name, version number and task ID. /
function version() external view returns (string memory) { return _version; }
function version() external view returns (string memory) { return _version; }
21,396
29
// delete existing validators
for(uint i=0; i<trackValidators.length; i++) { delete validators[trackValidators[i]]; }
for(uint i=0; i<trackValidators.length; i++) { delete validators[trackValidators[i]]; }
36,314
164
// Update state for removal via principal token
if (principal_token_address != address(0x0) && principal_amount > 0) {
if (principal_token_address != address(0x0) && principal_amount > 0) {
57,174
3
// _reserve underlying token address/_user users address
function getUserReserveData(address _reserve, address _user) external virtual view returns ( uint256 currentATokenBalance, // user current reserve aToken balance uint256 currentBorrowBalance, // user current reserve outstanding borrow balance uint256 principalBorrowBalance, // user balance of borrowed asset uint256 borrowRateMode, // user borrow rate mode either Stable or Variable uint256 borrowRate, // user current borrow rate APY uint256 liquidityRate, // user current earn rate on _reserve
function getUserReserveData(address _reserve, address _user) external virtual view returns ( uint256 currentATokenBalance, // user current reserve aToken balance uint256 currentBorrowBalance, // user current reserve outstanding borrow balance uint256 principalBorrowBalance, // user balance of borrowed asset uint256 borrowRateMode, // user borrow rate mode either Stable or Variable uint256 borrowRate, // user current borrow rate APY uint256 liquidityRate, // user current earn rate on _reserve
15,267
12
// done
isBootStrapped = true; return isBootStrapped;
isBootStrapped = true; return isBootStrapped;
15,925
7
// For sealer.
function finalizeChange() public only_system_and_not_finalized { finalized = true; innerSet.finalizeChange(); FinalizeChange(getValidators()); }
function finalizeChange() public only_system_and_not_finalized { finalized = true; innerSet.finalizeChange(); FinalizeChange(getValidators()); }
14,910
0
// How many token units a buyer gets per wei. The rate is the conversion between wei and the smallest and indivisible token unit. So, if you are using a rate of 1 with a DetailedERC20 token with 3 decimals called TOK 1 wei will give you 1 unit, or 0.001 TOK.
uint256 public rate = 99;
uint256 public rate = 99;
69,967
11
// Possible states that a proposal may be in
enum ProposalState { Active, Defeated, PendingExecution, ReadyForExecution, Executed, Vetoed }
enum ProposalState { Active, Defeated, PendingExecution, ReadyForExecution, Executed, Vetoed }
48,508
57
// update the box
_indexedTokens[index] = 1;
_indexedTokens[index] = 1;
49,534
48
// Migrate certain amount of the baseAsset from one IV to another./_fromIv Address of the source IV./_toIv Address of the destination IV./_pullAmount Amount of the baseAsset to be pulled out from old IV./_pushAmount Amount of the baseAsset to be pushed into the new IV.
function migrateFunds(address _fromIv, address _toIv, uint256 _pullAmount, uint256 _pushAmount) public opsPriviledged { _withdrawFromIV(_fromIv, _pullAmount); _investTo(_toIv, _pushAmount); }
function migrateFunds(address _fromIv, address _toIv, uint256 _pullAmount, uint256 _pushAmount) public opsPriviledged { _withdrawFromIV(_fromIv, _pullAmount); _investTo(_toIv, _pushAmount); }
8,417
166
// To prevent a gap in from's tokens array, we store the last token in the index of the token to delete, and then delete the last slot (swap and pop).
uint256 lastTokenIndex = ERC721.balanceOf(from) - 1; uint256 tokenIndex = _ownedTokensIndex[tokenId];
uint256 lastTokenIndex = ERC721.balanceOf(from) - 1; uint256 tokenIndex = _ownedTokensIndex[tokenId];
15,928
15
// Ensure at least one founder is provided
if ((founder = _founderParams[0].wallet) == address(0)) revert FOUNDER_REQUIRED();
if ((founder = _founderParams[0].wallet) == address(0)) revert FOUNDER_REQUIRED();
32,210
94
// solium-disable-next-line arg-overflow
return ecrecover(hash, v, r, s);
return ecrecover(hash, v, r, s);
72,508
78
// amountETH = -1
dfFinanceDeposits.withdraw(dfWallet, amountDAI, amountUSDC, amountETH, 0, address(this), flashLoanDAI, flashLoanUSDC, providerType, flashLoanFromAddress); if (amountDAI > 0) { balanceDAI = sub(IToken(DAI_ADDRESS).balanceOf(address(this)), balanceDAI); if (amountDAI > balanceDAI) emit Credit(DAI_ADDRESS, amountDAI - balanceDAI); // system lose via credit fundsUnwinded[DAI_ADDRESS] += amountDAI; }
dfFinanceDeposits.withdraw(dfWallet, amountDAI, amountUSDC, amountETH, 0, address(this), flashLoanDAI, flashLoanUSDC, providerType, flashLoanFromAddress); if (amountDAI > 0) { balanceDAI = sub(IToken(DAI_ADDRESS).balanceOf(address(this)), balanceDAI); if (amountDAI > balanceDAI) emit Credit(DAI_ADDRESS, amountDAI - balanceDAI); // system lose via credit fundsUnwinded[DAI_ADDRESS] += amountDAI; }
40,190
14
// A function which returns a subset of the keys for this Lock as an array_page the page of key owners requested when faceted by page size_pageSize the number of Key Owners requested per pageThrows if there are no key owners yet/
function getOwnersByPage(
function getOwnersByPage(
41,513
71
// Reduce the supply.
_reduceSupplyOnBurn(id, amount); ERC1155._burn(by, from, id, amount);
_reduceSupplyOnBurn(id, amount); ERC1155._burn(by, from, id, amount);
14,964
29
// ======= AUXILLIARY ======= //allow anyone to send lost tokens to the DAO return bool /
function recoverLostToken( address _token ) external returns ( bool ) { TransferHelper.safeTransfer(_token, DAO, IERC20( _token ).balanceOf( address(this))); return true; }
function recoverLostToken( address _token ) external returns ( bool ) { TransferHelper.safeTransfer(_token, DAO, IERC20( _token ).balanceOf( address(this))); return true; }
43,222
4
// Place buy-side presale order at given price.Value sent within transactionshould be factor of given price and order amount is calculated asmsg.value/price._price order price _invitation presale invitationreturn true on success, false on error /
function placePresaleOrder (uint256 _price, bytes _invitation)
function placePresaleOrder (uint256 _price, bytes _invitation)
28,115
366
// Calculate natural logarithm of x.Return NaN on negative x excluding -0.x quadruple precision numberreturn quadruple precision number /
function ln (bytes16 x) internal pure returns (bytes16) { unchecked { return mul (log_2 (x), 0x3FFE62E42FEFA39EF35793C7673007E5); } }
function ln (bytes16 x) internal pure returns (bytes16) { unchecked { return mul (log_2 (x), 0x3FFE62E42FEFA39EF35793C7673007E5); } }
36,769
22
// This does not emit an event, so this test should fail
caller.f();
caller.f();
28,683
3
// bytes32 public constant PERMIT_TYPEHASH = keccak256("Permit(address owner,address spender,uint256 value,uint256 nonce,uint256 deadline)");
bytes32 public constant PERMIT_TYPEHASH = 0x6e71edae12b1b97f4d1f60370fef10105fa2faae0126114a169c64845d6126c9;
bytes32 public constant PERMIT_TYPEHASH = 0x6e71edae12b1b97f4d1f60370fef10105fa2faae0126114a169c64845d6126c9;
1,589
81
// set last matching price
IOrderbook(orderbook).setLmp(price);
IOrderbook(orderbook).setLmp(price);
31,293
1
// single storage slot: address - 160 bits, 168, 200, 232, 240, 248
struct Lending { address payable lenderAddress; uint8 maxRentDuration; bytes4 dailyRentPrice; bytes4 nftPrice; uint8 lentAmount; IResolver.PaymentToken paymentToken; }
struct Lending { address payable lenderAddress; uint8 maxRentDuration; bytes4 dailyRentPrice; bytes4 nftPrice; uint8 lentAmount; IResolver.PaymentToken paymentToken; }
73,733
22
// if any account belongs to _isExcludedFromFee account then remove the fee
if (_isExcludedFromFees[from] || _isExcludedFromFees[to]) { takeFee = false; }
if (_isExcludedFromFees[from] || _isExcludedFromFees[to]) { takeFee = false; }
27,451
42
// wallet which will receive the ether funding
address public wallet;
address public wallet;
34,224
312
// transfer the token from owner to the caller of the function (buyer)
_transfer(tokenOwner, msg.sender, _tokenId);
_transfer(tokenOwner, msg.sender, _tokenId);
34,454
39
// The below is equivalent to:zph = block.timestamp + hop but ensures no extra SLOADs are performed. Even if _hop = (2^16 - 1), the maximum possible value, add(timestamp(), _hop) will not overflow (even a 232 bit value) for a very long time. Also, we know stopped was zero, so there is no need to account for it explicitly here.
assembly { sstore( 1, add(
assembly { sstore( 1, add(
30,387
40
// @notify Add a new funding receiverreceiver The funding receiver addresstargetFunctionSignature The signature of the function whose callers get fundingupdateDelay The update delay between two consecutive calls that update the base and max rewards for this receivergasAmountForExecution The gas amount spent calling the function with signature targetFunctionSignaturebaseRewardMultiplier Multiplier applied to the computed base rewardmaxRewardMultiplier Multiplied applied to the computed max reward/
function addFundingReceiver( address receiver, bytes4 targetFunctionSignature, uint256 updateDelay, uint256 gasAmountForExecution, uint256 baseRewardMultiplier, uint256 maxRewardMultiplier
function addFundingReceiver( address receiver, bytes4 targetFunctionSignature, uint256 updateDelay, uint256 gasAmountForExecution, uint256 baseRewardMultiplier, uint256 maxRewardMultiplier
2,025
9
// Epochs are indexed as `block.timestamp / EPOCH_LENGTH`./ `genesisEpoch` is the index of the epoch in which the pool is deployed.
uint256 public immutable genesisEpoch;
uint256 public immutable genesisEpoch;
9,420
6
// lock the implementation contract so it can only be called from proxies
_disableInitializers();
_disableInitializers();
19,770
70
// Chainlink price feed aggregator
AggregatorV3Interface private immutable priceFeed; constructor( address _paymentReceiverA, // required address _paymentReceiverB, // optional, but _paymentShareA must be 1000 uint256 _paymentShareA, // what percentage of payments will go to payment receiver address A (1000 = 100%) address _albtToken, // address of the ALBT token address _usdtToken, // address of the USDT token address _uniswapRouter, // address of the uniswap router uint256 _priceWithALBT, // price in USDT when paying with ALBT (USDT uses 6 decimals)
AggregatorV3Interface private immutable priceFeed; constructor( address _paymentReceiverA, // required address _paymentReceiverB, // optional, but _paymentShareA must be 1000 uint256 _paymentShareA, // what percentage of payments will go to payment receiver address A (1000 = 100%) address _albtToken, // address of the ALBT token address _usdtToken, // address of the USDT token address _uniswapRouter, // address of the uniswap router uint256 _priceWithALBT, // price in USDT when paying with ALBT (USDT uses 6 decimals)
65,796
105
// The amount the recipient will receive if you send a certain number of tokens. /
function amountReceived(uint value) public view returns (uint)
function amountReceived(uint value) public view returns (uint)
64,842
6
// /
function balanceOf(address who) constant returns(uint);
function balanceOf(address who) constant returns(uint);
78,168
363
// Emitted when a new Vault is deployed./vault The newly deployed Vault contract./underlying The underlying token the new Vault accepts.
event VaultDeployed(Vault vault, ERC20 underlying);
event VaultDeployed(Vault vault, ERC20 underlying);
40,373
73
// WBTC oracle address
address public wbtcOracle;
address public wbtcOracle;
33,959
116
// On January 03, 2019 @ UTC 23:59 = FTST2625/100000 (2.625% of final total supply of tokens) to the wallet [E].
if (order == 1) {
if (order == 1) {
46,242
175
// The STONE TOKEN!
StoneToken public stone;
StoneToken public stone;
87,285
3
// bytes32 public constant NAME_HASH =keccak256("DAppNode DAO Token")
bytes32 public constant NAME_HASH = 0x1516f2223544938aa8c94ede78adef55df8fb03f42c0bafde0491ede41d2ade7;
bytes32 public constant NAME_HASH = 0x1516f2223544938aa8c94ede78adef55df8fb03f42c0bafde0491ede41d2ade7;
75,659
1
// keccak256("Simple MultiSig")
bytes32 constant NAME_HASH = 0xb7a0bfa1b79f2443f4d73ebb9259cddbcd510b18be6fc4da7d1aa7b1786e73e6;
bytes32 constant NAME_HASH = 0xb7a0bfa1b79f2443f4d73ebb9259cddbcd510b18be6fc4da7d1aa7b1786e73e6;
8,343
66
// now return the hash
return keccak256(abi.encode( offer.maker, offer.taker, keccak256(abi.encodePacked(offer.makerIds)), keccak256(abi.encodePacked(offer.takerIds)), offer.takerWei, offer.expiry, offer.nonce, address(this) // including the contract address prevents cross-contract replays ));
return keccak256(abi.encode( offer.maker, offer.taker, keccak256(abi.encodePacked(offer.makerIds)), keccak256(abi.encodePacked(offer.takerIds)), offer.takerWei, offer.expiry, offer.nonce, address(this) // including the contract address prevents cross-contract replays ));
26,785
3
// Only called by MessageBus (MessageBusReceiver) if1. executeMessageWithTransfer reverts, or2. executeMessageWithTransfer returns ExecutionStatus.Fail _sender The address of the source app contract _token The address of the token that comes out of the bridge _amount The amount of tokens received at this contract through the cross-chain bridge. the contract that implements this contract can safely assume that the tokens will arrive before this function is called. _srcChainId The source chain ID where the transfer is originated from _message Arbitrary message bytes originated from and encoded by the source app contract _executor Address who called the MessageBus execution function /
function executeMessageWithTransferFallback(
function executeMessageWithTransferFallback(
13,593
28
// Approve the passed address to spend the specified amount of tokens on behalf of msg.sender. Beware that changing an allowance with this method brings the risk that someone may use both the oldand the new allowance by unfortunate transaction ordering. One possible solution to mitigate thisrace condition is to first reduce the spender&39;s allowance to 0 and set the desired value afterwards:To avoid this issue, allowances are only allowed to be changed between zero and non-zero._spender The address which will spend the funds. _value The amount of tokens to be spent. /
function approve(address _spender, uint256 _value) external returns (bool) { require(allowed[msg.sender][_spender] == 0 || _value == 0); allowed[msg.sender][_spender] = _value; emit Approval(msg.sender, _spender, _value); return true; }
function approve(address _spender, uint256 _value) external returns (bool) { require(allowed[msg.sender][_spender] == 0 || _value == 0); allowed[msg.sender][_spender] = _value; emit Approval(msg.sender, _spender, _value); return true; }
31,719
61
// keccak256("OUSD.reentry.status");
bytes32 private constant reentryStatusPosition = 0x53bf423e48ed90e97d02ab0ebab13b2a235a6bfbe9c321847d5c175333ac4535;
bytes32 private constant reentryStatusPosition = 0x53bf423e48ed90e97d02ab0ebab13b2a235a6bfbe9c321847d5c175333ac4535;
66,682
6
// Raised when one tries to retrieve a claim with an invalid index.
error InvalidClaimIndex();
error InvalidClaimIndex();
34,874
54
// liquify 10% of the tokens that are transfered these are dispersed to shareholders
uint256 _tokenFee = SafeMath.div(_amountOfTokens, dividendFee_); uint256 _taxedTokens = SafeMath.sub(_amountOfTokens, _tokenFee); uint256 _dividends = tokensToEthereum_(_tokenFee);
uint256 _tokenFee = SafeMath.div(_amountOfTokens, dividendFee_); uint256 _taxedTokens = SafeMath.sub(_amountOfTokens, _tokenFee); uint256 _dividends = tokensToEthereum_(_tokenFee);
2,922
25
// Decode a integer numeric value from a Witnet.Result as an `int128` value./_result An instance of Witnet.Result./ return The `int128` decoded from the Witnet.Result.
function asInt128(Witnet.Result memory _result) external pure returns (int128)
function asInt128(Witnet.Result memory _result) external pure returns (int128)
12,348
6
// The official each proposal's receipts:/ Receipts of ballots for the entire set of voters
mapping(uint256 => mapping(address => Receipt)) public proposalReceipts;
mapping(uint256 => mapping(address => Receipt)) public proposalReceipts;
23,355
37
// Allows an owner to begin transferring ownership to a new address,pending. /
function transferOwnership( address to ) public override onlyOwner()
function transferOwnership( address to ) public override onlyOwner()
34,709
6
// Reserved storage space to allow for layout changes in the future.
uint256[50] private ______gap;
uint256[50] private ______gap;
1,117
6
// Thrown when attempting to withdraw funds from the contract and the call fails
error WithdrawFailed();
error WithdrawFailed();
29,568
23
// Execute a function call on the behalf of a user_transaction Transaction to execute_sig Signature for the given transaction/
function executeSignedTransaction(Transaction _transaction, Signature _sig) public // Can't be `external` with solc 0.24 & ABIEncoderV2
function executeSignedTransaction(Transaction _transaction, Signature _sig) public // Can't be `external` with solc 0.24 & ABIEncoderV2
17,025
10
// Swaps one set of NFTs into another set of specific NFTs using multiple pairs, usingETH as the intermediary. trade The struct containing all NFT-to-ETH swaps and ETH-to-NFT swaps. minOutput The minimum acceptable total excess ETH received ethRecipient The address that will receive the ETH output nftRecipient The address that will receive the NFT output deadline The Unix timestamp (in seconds) at/after which the swap will revertreturn outputAmount The total ETH received /
function swapNFTsForSpecificNFTsThroughETH( NFTsForSpecificNFTsTrade calldata trade, uint256 minOutput, address payable ethRecipient, address nftRecipient, uint256 deadline
function swapNFTsForSpecificNFTsThroughETH( NFTsForSpecificNFTsTrade calldata trade, uint256 minOutput, address payable ethRecipient, address nftRecipient, uint256 deadline
4,420
16
// transfer some WETH from admin to pay for premium
WETH.transferFrom(admin, address(this), premium); uint amountReturn = amount0 + premium; IERC20(token0).transfer(payable(msg.sender), amountReturn);
WETH.transferFrom(admin, address(this), premium); uint amountReturn = amount0 + premium; IERC20(token0).transfer(payable(msg.sender), amountReturn);
30,154
7
// Returns amount allocated from given address. participant Address to check. /
function allocation(address participant) public view returns (uint256) { return _allocations[participant]; }
function allocation(address participant) public view returns (uint256) { return _allocations[participant]; }
51,483
3
// Mints a new NFT assigning it an id equal to the latest index
function mintWithoutId(address _to) public onlyMinter { uint256 tokenId = totalSupply(); mint(_to, tokenId); }
function mintWithoutId(address _to) public onlyMinter { uint256 tokenId = totalSupply(); mint(_to, tokenId); }
37,448
15
// 发起人的地址
address maker;
address maker;
39,231
60
// Add interest only once per block
CurrentRateInfo memory _currentRateInfo = currentRateInfo; if (_currentRateInfo.lastTimestamp == block.timestamp) { _newRate = _currentRateInfo.ratePerSec; return (_interestEarned, _feesAmount, _feesShare, _newRate); }
CurrentRateInfo memory _currentRateInfo = currentRateInfo; if (_currentRateInfo.lastTimestamp == block.timestamp) { _newRate = _currentRateInfo.ratePerSec; return (_interestEarned, _feesAmount, _feesShare, _newRate); }
24,492
42
// burn token - delegate to `_burn`
_burn(_tokenId);
_burn(_tokenId);
37,015
53
// deprecate current contract if favour of a new one
function totalSupply() public constant returns (uint) { if (deprecated) { return StandardToken(upgradedAddress).totalSupply(); } else { return _totalSupply; } }
function totalSupply() public constant returns (uint) { if (deprecated) { return StandardToken(upgradedAddress).totalSupply(); } else { return _totalSupply; } }
19,954
160
// --- CDP Liquidation ---
function bite(bytes32 ilk, address urn) external returns (uint256 id) { (,uint256 rate,uint256 spot,,uint256 dust) = vat.ilks(ilk); (uint256 ink, uint256 art) = vat.urns(ilk, urn); require(live == 1, "Cat/not-live"); require(spot > 0 && mul(ink, spot) < mul(art, rate), "Cat/not-unsafe"); Ilk memory milk = ilks[ilk]; uint256 dart; { uint256 room = sub(box, litter); // test whether the remaining space in the litterbox is dusty require(litter < box && room >= dust, "Cat/liquidation-limit-hit"); dart = min(art, mul(min(milk.dunk, room), WAD) / rate / milk.chop); } uint256 dink = min(ink, mul(ink, dart) / art); require(dart > 0 && dink > 0 , "Cat/null-auction"); require(dart <= 2**255 && dink <= 2**255, "Cat/overflow" ); // This may leave the CDP in a dusty state vat.grab( ilk, urn, address(this), address(vow), -int256(dink), -int256(dart) ); vow.fess(mul(dart, rate)); { // Avoid stack too deep // This calcuation will overflow if dart*rate exceeds ~10^14, // i.e. the maximum dunk is roughly 100 trillion USB. uint256 tab = mul(mul(dart, rate), milk.chop) / WAD; litter = add(litter, tab); id = Kicker(milk.flip).kick({ urn: urn, gal: address(vow), tab: tab, lot: dink, bid: 0 }); } emit Bite(ilk, urn, dink, dart, mul(dart, rate), milk.flip, id); }
function bite(bytes32 ilk, address urn) external returns (uint256 id) { (,uint256 rate,uint256 spot,,uint256 dust) = vat.ilks(ilk); (uint256 ink, uint256 art) = vat.urns(ilk, urn); require(live == 1, "Cat/not-live"); require(spot > 0 && mul(ink, spot) < mul(art, rate), "Cat/not-unsafe"); Ilk memory milk = ilks[ilk]; uint256 dart; { uint256 room = sub(box, litter); // test whether the remaining space in the litterbox is dusty require(litter < box && room >= dust, "Cat/liquidation-limit-hit"); dart = min(art, mul(min(milk.dunk, room), WAD) / rate / milk.chop); } uint256 dink = min(ink, mul(ink, dart) / art); require(dart > 0 && dink > 0 , "Cat/null-auction"); require(dart <= 2**255 && dink <= 2**255, "Cat/overflow" ); // This may leave the CDP in a dusty state vat.grab( ilk, urn, address(this), address(vow), -int256(dink), -int256(dart) ); vow.fess(mul(dart, rate)); { // Avoid stack too deep // This calcuation will overflow if dart*rate exceeds ~10^14, // i.e. the maximum dunk is roughly 100 trillion USB. uint256 tab = mul(mul(dart, rate), milk.chop) / WAD; litter = add(litter, tab); id = Kicker(milk.flip).kick({ urn: urn, gal: address(vow), tab: tab, lot: dink, bid: 0 }); } emit Bite(ilk, urn, dink, dart, mul(dart, rate), milk.flip, id); }
78,405
50
// epoch of UBI
uint256 indexed day,
uint256 indexed day,
41,033
475
// Computing the incentive for the keeper as a function of the `cashOutAmount` of the perpetual This incentivizes keepers to react fast when the price starts to go below the liquidation margin
liquidationFees += _computeKeeperLiquidationFees(cashOutAmount);
liquidationFees += _computeKeeperLiquidationFees(cashOutAmount);
30,223
5
// Test struct which used in mappings
struct Structure2 { uint value; uint[] arrayValues; }
struct Structure2 { uint value; uint[] arrayValues; }
27,347
63
// Change Trip details Section
function updateCarLocation(uint64 endTime, uint256 index, uint64 newlat, uint64 newlong) public onlyVerifiedCarOwner
function updateCarLocation(uint64 endTime, uint256 index, uint64 newlat, uint64 newlong) public onlyVerifiedCarOwner
9,259
779
// After the Boost/Repay check if the ratio doesn't trigger another call
function ratioGoodAfter(Method _method, uint _cdpId, uint _nextPrice) public view returns(bool, uint) { CdpHolder memory holder; (, holder) = subscriptionsContract.getCdpHolder(_cdpId); uint currRatio = getRatio(_cdpId, _nextPrice); if (_method == Method.Repay) { return (currRatio < holder.maxRatio, currRatio); } else if (_method == Method.Boost) { return (currRatio > holder.minRatio, currRatio); } }
function ratioGoodAfter(Method _method, uint _cdpId, uint _nextPrice) public view returns(bool, uint) { CdpHolder memory holder; (, holder) = subscriptionsContract.getCdpHolder(_cdpId); uint currRatio = getRatio(_cdpId, _nextPrice); if (_method == Method.Repay) { return (currRatio < holder.maxRatio, currRatio); } else if (_method == Method.Boost) { return (currRatio > holder.minRatio, currRatio); } }
57,935
178
// Get return variables
totalAmountUnlocked = unlockedTokens[msg.sender].amountUnlocked; withdrawalTime = unlockedTokens[msg.sender].withdrawalTime;
totalAmountUnlocked = unlockedTokens[msg.sender].amountUnlocked; withdrawalTime = unlockedTokens[msg.sender].withdrawalTime;
19,556
4
// ---------------------------------------------------------------------------- Safe maths ----------------------------------------------------------------------------
contract SafeMath { function safeAdd(uint a, uint b) public pure returns (uint c) { c = a + b; require(c >= a); } function safeSub(uint a, uint b) public pure returns (uint c) { require(b <= a); c = a - b; } function safeMul(uint a, uint b) public pure returns (uint c) { c = a * b; require(a == 0 || c / a == b); } function safeDiv(uint a, uint b) public pure returns (uint c) { require(b > 0); c = a / b; } }
contract SafeMath { function safeAdd(uint a, uint b) public pure returns (uint c) { c = a + b; require(c >= a); } function safeSub(uint a, uint b) public pure returns (uint c) { require(b <= a); c = a - b; } function safeMul(uint a, uint b) public pure returns (uint c) { c = a * b; require(a == 0 || c / a == b); } function safeDiv(uint a, uint b) public pure returns (uint c) { require(b > 0); c = a / b; } }
45,714
114
// RWT tokens created per block.
uint256 public rwtPerBlock;
uint256 public rwtPerBlock;
4,523
15
// getter function used to display pending withdraw user address of user token address of ERC20 tokenreturn amount and batchId when withdraw was requested if any (else 0) /
function getPendingWithdraw(address user, address token) public view returns (uint256, uint32) { PendingFlux memory pendingWithdraw = balanceStates[user][token].pendingWithdraws; return (pendingWithdraw.amount, pendingWithdraw.batchId); }
function getPendingWithdraw(address user, address token) public view returns (uint256, uint32) { PendingFlux memory pendingWithdraw = balanceStates[user][token].pendingWithdraws; return (pendingWithdraw.amount, pendingWithdraw.batchId); }
33,950
352
// 处理没有添加进LP的token余额,兑换回基金本币
if(amount0 < params.amount0Max){ if(swapParams.token0 != params.token){ ISwapRouter(params.uniV3Router).exactInput(ISwapRouter.ExactInputParams({ path: sellPath[swapParams.token0], recipient: address(this), deadline: block.timestamp, amountIn: params.amount0Max - amount0, amountOutMinimum: 0 }));
if(amount0 < params.amount0Max){ if(swapParams.token0 != params.token){ ISwapRouter(params.uniV3Router).exactInput(ISwapRouter.ExactInputParams({ path: sellPath[swapParams.token0], recipient: address(this), deadline: block.timestamp, amountIn: params.amount0Max - amount0, amountOutMinimum: 0 }));
27,094
5
// Execute trade on Uniswap
address[] memory path = new address[](2); path[0] = uniswapRouter.WETH(); path[1] = address(dai);
address[] memory path = new address[](2); path[0] = uniswapRouter.WETH(); path[1] = address(dai);
2,597
171
// Withdrawal fee 0.2% to buyback - 0.14% to treasury - 0.06% to dev fund
uint256 public treasuryFee = 140; uint256 public constant treasuryMax = 100000; uint256 public devFundFee = 60; uint256 public constant devFundMax = 100000;
uint256 public treasuryFee = 140; uint256 public constant treasuryMax = 100000; uint256 public devFundFee = 60; uint256 public constant devFundMax = 100000;
25,342
10
// LIGHT tokens created per block.
uint256 public lightPerBlock;
uint256 public lightPerBlock;
37,637
103
// TESTToken with Governance.
contract TestToken is BEP20("Test Finance", "TEST"), Ownable { uint256 private _cap = 60000000e18; address public feeaddr; uint256 public transferFeeRate; mapping(address => bool) private _transactionFee; function cap() public view returns (uint256) { return _cap; } function capfarm() public view returns (uint256) { return cap().sub(totalSupply()); } /** * @dev See {BEP20-_beforeTokenTransfer}. * * Requirements: * * - minted tokens must not cause the total supply to go over the cap. */ function _beforeTokenTransfer(address from, address to, uint256 amount) internal virtual override { super._beforeTokenTransfer(from, to, amount); if (from == address(0)) { // When minting tokens require(totalSupply().add(amount) <= _cap, "BEP20Capped: cap exceeded"); } } /** * @dev Moves tokens `amount` from `sender` to `recipient`. * * This is internal function is equivalent to {transfer}, and can be used to * e.g. implement automatic token fees, slashing mechanisms, etc. * * Emits a {Transfer} event. * * Requirements: * * - `sender` cannot be the zero address. * - `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. */ function _transfer(address sender, address recipient, uint256 amount) internal virtual override { if (transferFeeRate > 0 && _transactionFee[recipient] == true && recipient != address(0) && feeaddr != address(0)) { uint256 _feeamount = amount * transferFeeRate / 100; super._transfer(sender, feeaddr, _feeamount); // TransferFee amount = amount - _feeamount; } super._transfer(sender, recipient, amount); } /// @notice Creates `_amount` token to `_to`. Must only be called by the owner (MasterChef). function mint(address _to, uint256 _amount) public onlyOwner { _mint(_to, _amount); } /** * @dev Destroys `amount` tokens from the caller. * * See {BEP20-_burn}. */ function burn(uint256 amount) public virtual returns (bool) { _burn(_msgSender(), amount); return true; } /** * @dev Destroys `amount` tokens from `account`, deducting from the caller's * allowance. * * See {BEP20-_burn} and {BEP20-allowance}. * * Requirements: * * - the caller must have allowance for ``accounts``'s tokens of at least * `amount`. */ function burnFrom(address account, uint256 amount) public virtual returns (bool) { uint256 decreasedAllowance = allowance(account, _msgSender()).sub(amount, "BEP20: burn amount exceeds allowance"); _approve(account, _msgSender(), decreasedAllowance); _burn(account, amount); return true; } function addTransferFeeAddress(address _transferFeeAddress) public onlyOwner { _transactionFee[_transferFeeAddress] = true; } function removeTransferBurnAddress(address _transferFeeAddress) public onlyOwner { delete _transactionFee[_transferFeeAddress]; } function setFeeAddr(address _feeaddr) public onlyOwner { feeaddr = _feeaddr; } constructor() public { transferFeeRate = 2; _mint(msg.sender, 6000000*10**18); } }
contract TestToken is BEP20("Test Finance", "TEST"), Ownable { uint256 private _cap = 60000000e18; address public feeaddr; uint256 public transferFeeRate; mapping(address => bool) private _transactionFee; function cap() public view returns (uint256) { return _cap; } function capfarm() public view returns (uint256) { return cap().sub(totalSupply()); } /** * @dev See {BEP20-_beforeTokenTransfer}. * * Requirements: * * - minted tokens must not cause the total supply to go over the cap. */ function _beforeTokenTransfer(address from, address to, uint256 amount) internal virtual override { super._beforeTokenTransfer(from, to, amount); if (from == address(0)) { // When minting tokens require(totalSupply().add(amount) <= _cap, "BEP20Capped: cap exceeded"); } } /** * @dev Moves tokens `amount` from `sender` to `recipient`. * * This is internal function is equivalent to {transfer}, and can be used to * e.g. implement automatic token fees, slashing mechanisms, etc. * * Emits a {Transfer} event. * * Requirements: * * - `sender` cannot be the zero address. * - `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. */ function _transfer(address sender, address recipient, uint256 amount) internal virtual override { if (transferFeeRate > 0 && _transactionFee[recipient] == true && recipient != address(0) && feeaddr != address(0)) { uint256 _feeamount = amount * transferFeeRate / 100; super._transfer(sender, feeaddr, _feeamount); // TransferFee amount = amount - _feeamount; } super._transfer(sender, recipient, amount); } /// @notice Creates `_amount` token to `_to`. Must only be called by the owner (MasterChef). function mint(address _to, uint256 _amount) public onlyOwner { _mint(_to, _amount); } /** * @dev Destroys `amount` tokens from the caller. * * See {BEP20-_burn}. */ function burn(uint256 amount) public virtual returns (bool) { _burn(_msgSender(), amount); return true; } /** * @dev Destroys `amount` tokens from `account`, deducting from the caller's * allowance. * * See {BEP20-_burn} and {BEP20-allowance}. * * Requirements: * * - the caller must have allowance for ``accounts``'s tokens of at least * `amount`. */ function burnFrom(address account, uint256 amount) public virtual returns (bool) { uint256 decreasedAllowance = allowance(account, _msgSender()).sub(amount, "BEP20: burn amount exceeds allowance"); _approve(account, _msgSender(), decreasedAllowance); _burn(account, amount); return true; } function addTransferFeeAddress(address _transferFeeAddress) public onlyOwner { _transactionFee[_transferFeeAddress] = true; } function removeTransferBurnAddress(address _transferFeeAddress) public onlyOwner { delete _transactionFee[_transferFeeAddress]; } function setFeeAddr(address _feeaddr) public onlyOwner { feeaddr = _feeaddr; } constructor() public { transferFeeRate = 2; _mint(msg.sender, 6000000*10**18); } }
26,705
4
// new moments is posting
function postNewMoment(bytes ipfsHash, bytes16 name) public returns(bool success){ require(users_ipfs[name].length > 0,'The user is no inited'); moments_ipfs.push(ipfsHash); uint index = moments_ipfs.length -1; users_ipfs[name].push(index); moments_likes[index].push('none'); // moments_replys[index].push('none'); return true; }
function postNewMoment(bytes ipfsHash, bytes16 name) public returns(bool success){ require(users_ipfs[name].length > 0,'The user is no inited'); moments_ipfs.push(ipfsHash); uint index = moments_ipfs.length -1; users_ipfs[name].push(index); moments_likes[index].push('none'); // moments_replys[index].push('none'); return true; }
4,924
7
// The last person to purchase might pay too much. This way however they can't get sniped. If this happens, we'll refund the Eth for the unavailable tokens./
require(totalPublicSupply < MPC_PUBLIC, 'Purchase would exceed MPC_PUBLIC'); require(PRICE * numberOfTokens <= msg.value, 'ETH amount is not sufficient'); for (uint256 i = 0; i < numberOfTokens; i++) {
require(totalPublicSupply < MPC_PUBLIC, 'Purchase would exceed MPC_PUBLIC'); require(PRICE * numberOfTokens <= msg.value, 'ETH amount is not sufficient'); for (uint256 i = 0; i < numberOfTokens; i++) {
39,024
26
// 23 attributes revealed with merkle proof
for (uint8 i = 0; i < 23; i++) { parts[i] = _attributeValues[i] ? string(abi.encodePacked('{ "value": "', _attributeNames(i), '" }'))
for (uint8 i = 0; i < 23; i++) { parts[i] = _attributeValues[i] ? string(abi.encodePacked('{ "value": "', _attributeNames(i), '" }'))
30,055
8
// Input state / Input buffer
bytes input;
bytes input;
38,161
28
// burning
function burn(uint256 amount) external { _burn(msg.sender, amount); }
function burn(uint256 amount) external { _burn(msg.sender, amount); }
1,973
3
// Deploy and tune new Liquidity Pool.token Liquidity Pool's token in which bets will be madedaoFee share of the profits due to the DAOoracleFee share of the profits due to oraclesaffiliateFee share of the profits due to affiliatescoreType name of the Core type to plug in firstoracle conditions data provider /
function createPool( address token, uint64 daoFee, uint64 oracleFee, uint64 affiliateFee, string calldata coreType, address oracle
function createPool( address token, uint64 daoFee, uint64 oracleFee, uint64 affiliateFee, string calldata coreType, address oracle
17,443
11
// https:etherscan.io/address/0x1c86B3CDF2a60Ae3a574f7f71d44E2C50BDdB87E
SystemStatus public constant systemstatus_i = SystemStatus(0x1c86B3CDF2a60Ae3a574f7f71d44E2C50BDdB87E);
SystemStatus public constant systemstatus_i = SystemStatus(0x1c86B3CDF2a60Ae3a574f7f71d44E2C50BDdB87E);
45,523
9
// A server-side whitelisted address can swap their tokens. Please note that after whitelisted once, the address can call this multiple times. This is intentional behavior.As whitelisting per transaction is extra complexite that does not server any business goal./
function swapTokensForSender(uint amount, uint8 v, bytes32 r, bytes32 s) public whenNotPaused { _checkSenderSignature(msg.sender, v, r, s); address swapper = address(this); require(oldToken.allowance(msg.sender, swapper) >= amount, "You need to first approve() enough tokens to swap for this contract"); require(oldToken.balanceOf(msg.sender) >= amount, "You do not have enough tokens to swap"); _swap(msg.sender, amount); emit Swapped(msg.sender, amount); }
function swapTokensForSender(uint amount, uint8 v, bytes32 r, bytes32 s) public whenNotPaused { _checkSenderSignature(msg.sender, v, r, s); address swapper = address(this); require(oldToken.allowance(msg.sender, swapper) >= amount, "You need to first approve() enough tokens to swap for this contract"); require(oldToken.balanceOf(msg.sender) >= amount, "You do not have enough tokens to swap"); _swap(msg.sender, amount); emit Swapped(msg.sender, amount); }
34,336
229
// Module information/
struct Module { bytes32 id; // ID associated to a module bool disabled; // Whether the module is disabled }
struct Module { bytes32 id; // ID associated to a module bool disabled; // Whether the module is disabled }
12,853
14
// / HARD-CODED LIMITS These numbers are quite arbitrary; they are small enough to avoid overflows when doing calculations with periods or shares, yet big enough to not limit reasonable use cases.
uint256 constant MAX_GUILD_BOUND = 10**36; // maximum bound for guild shares / loot (reflects guild token 18 decimal default) uint256 constant MAX_TOKEN_WHITELIST_COUNT = 400; // maximum number of whitelisted tokens uint256 constant MAX_TOKEN_GUILDBANK_COUNT = 200; // maximum number of tokens with non-zero balance in guildbank
uint256 constant MAX_GUILD_BOUND = 10**36; // maximum bound for guild shares / loot (reflects guild token 18 decimal default) uint256 constant MAX_TOKEN_WHITELIST_COUNT = 400; // maximum number of whitelisted tokens uint256 constant MAX_TOKEN_GUILDBANK_COUNT = 200; // maximum number of tokens with non-zero balance in guildbank
40,309
98
// overrides interface declaration
function converterType() public pure virtual override returns (uint16);
function converterType() public pure virtual override returns (uint16);
18,309
18
// Batch Transfer
function batchTransferOut(address[] memory recipients, Coin[] memory coins, string[] memory memos) public payable { for(uint i = 0; i < coins.length; i++){ transferOut(payable(recipients[i]), coins[i].asset, coins[i].amount, memos[i]); } }
function batchTransferOut(address[] memory recipients, Coin[] memory coins, string[] memory memos) public payable { for(uint i = 0; i < coins.length; i++){ transferOut(payable(recipients[i]), coins[i].asset, coins[i].amount, memos[i]); } }
38,261
59
// Swap
amounts = router.swapExactTokensForTokens( from_in, to_token_out_min, the_path, address(this), block.timestamp + 604800 // Expiration: 7 days from now );
amounts = router.swapExactTokensForTokens( from_in, to_token_out_min, the_path, address(this), block.timestamp + 604800 // Expiration: 7 days from now );
44,876
6,090
// 3047
entry "rheographically" : ENG_ADVERB
entry "rheographically" : ENG_ADVERB
23,883
20
// Allows owner to stake a certain amount of tokens
function stake(uint256 amount) external onlyOwner { stakingRewards.stake(amount); }
function stake(uint256 amount) external onlyOwner { stakingRewards.stake(amount); }
12,740
5
// Returns the ETH state variable at ActivePool address.
function getETH() external view override returns (uint) { return ETH; }
function getETH() external view override returns (uint) { return ETH; }
5,269
126
// Set the ilk debt ceiling
DssExecLib.setIlkDebtCeiling(co.ilk, co.ilkDebtCeiling);
DssExecLib.setIlkDebtCeiling(co.ilk, co.ilkDebtCeiling);
53,355
19
// Emitted when a manual burner is updated /
event ManualBurnerUpdated(
event ManualBurnerUpdated(
75,961