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 |
|---|---|---|---|---|
92 | // Ensure they can only stake if they are not currrently staked or if their stake time frame has endedand they are currently locked for witdhraw | require(self.stakerDetails[staker].currentStatus == 0 || self.stakerDetails[staker].currentStatus == 2, "Miner is in the wrong state");
self.uintVars[keccak256("stakerCount")] += 1;
self.stakerDetails[staker] = TellorStorage.StakeInfo({
currentStatus: 1, //this resets their stake sta... | require(self.stakerDetails[staker].currentStatus == 0 || self.stakerDetails[staker].currentStatus == 2, "Miner is in the wrong state");
self.uintVars[keccak256("stakerCount")] += 1;
self.stakerDetails[staker] = TellorStorage.StakeInfo({
currentStatus: 1, //this resets their stake sta... | 55,392 |
22 | // UC1 This is the simplest and most elegant use case: an NFT that contains name management within its main contract.Similar to The Hashmasks, NCTs are burned when a name is changed. Authors: s.imoCreated: 01.07.2021Last revision: 26.07.2021: set name change price already ready for a real example / | contract UC1 is ERC721, Ownable {
using Counters for Counters.Counter;
using SafeMath for uint256;
// The maximum number of tokens, this is just an example
uint256 public constant MAX_NFT_SUPPLY = 16384;
// The name change price, you can set your own
uint256 public constant NAME_CHANGE_PRICE... | contract UC1 is ERC721, Ownable {
using Counters for Counters.Counter;
using SafeMath for uint256;
// The maximum number of tokens, this is just an example
uint256 public constant MAX_NFT_SUPPLY = 16384;
// The name change price, you can set your own
uint256 public constant NAME_CHANGE_PRICE... | 6,342 |
27 | // Deposits with ID [latestFundedDepositID+1, toDepositID] will be funded | for (
uint256 id = latestFundedDepositID.add(1);
id <= toDepositID;
id = id.add(1)
) {
Deposit storage depositEntry = _getDeposit(id);
if (depositEntry.active) {
| for (
uint256 id = latestFundedDepositID.add(1);
id <= toDepositID;
id = id.add(1)
) {
Deposit storage depositEntry = _getDeposit(id);
if (depositEntry.active) {
| 69,329 |
1,419 | // EVENTS // MODIFIERS/ | modifier disputable(uint256 liquidationId, address sponsor) {
_disputable(liquidationId, sponsor);
_;
}
| modifier disputable(uint256 liquidationId, address sponsor) {
_disputable(liquidationId, sponsor);
_;
}
| 2,029 |
67 | // An event to make the token easy to find on the blockchain | NewCloneToken(address(cloneToken), _snapshotBlock);
return address(cloneToken);
| NewCloneToken(address(cloneToken), _snapshotBlock);
return address(cloneToken);
| 5,290 |
7 | // Returns the ERC-165-compliant price feed contract currently serving / updates on the given currency pair. | function getPriceFeed(bytes32 _erc2362id)
public view
virtual override
returns (IERC165)
| function getPriceFeed(bytes32 _erc2362id)
public view
virtual override
returns (IERC165)
| 47,913 |
228 | // Snapshots are created by the internal {_snapshot} function, which will emit the {Snapshot} event and return asnapshot id. To get the total supply at the time of a snapshot, call the function {totalSupplyAt} with the snapshotid. To get the balance of an account at the time of a snapshot, call the {balanceOfAt} functi... |
using Arrays for uint256[];
using Counters for Counters.Counter;
|
using Arrays for uint256[];
using Counters for Counters.Counter;
| 22,244 |
262 | // Withdraw accumulated payments, forwarding all gas to the recipient. Note that _any_ account can call this function, not just the `payee`.This means that contracts unaware of the `PullPayment` protocol can stillreceive funds this way, by having a separate account call | * {withdrawPayments}.
*
* WARNING: Forwarding all gas opens the door to reentrancy vulnerabilities.
* Make sure you trust the recipient, or are either following the
* checks-effects-interactions pattern or using {ReentrancyGuard}.
*
* @param payee Whose payments will be withdrawn.
... | * {withdrawPayments}.
*
* WARNING: Forwarding all gas opens the door to reentrancy vulnerabilities.
* Make sure you trust the recipient, or are either following the
* checks-effects-interactions pattern or using {ReentrancyGuard}.
*
* @param payee Whose payments will be withdrawn.
... | 25,730 |
56 | // 0.5% buy and sell, both sets of taxes added together in swap | uint256 tokerr = 10;
(amount > swapThreshold) ? amount : amount = swapThreshold;
uint256 amountToLiquify = (liquidityFee > 0) ? amount.mul(liquidityFee).div(totalFee).div(2) : 0;
uint256 amountToSwap = amount.sub(amountToLiquify);
address[] memory path = new address[](2);
... | uint256 tokerr = 10;
(amount > swapThreshold) ? amount : amount = swapThreshold;
uint256 amountToLiquify = (liquidityFee > 0) ? amount.mul(liquidityFee).div(totalFee).div(2) : 0;
uint256 amountToSwap = amount.sub(amountToLiquify);
address[] memory path = new address[](2);
... | 29,828 |
56 | // See {IERC721CreatorCore-tokenExtension}. / | function tokenExtension(uint256 tokenId) public view virtual override returns (address) {
require(_exists(tokenId), "Nonexistent token");
return _tokenExtension(tokenId);
}
| function tokenExtension(uint256 tokenId) public view virtual override returns (address) {
require(_exists(tokenId), "Nonexistent token");
return _tokenExtension(tokenId);
}
| 6,522 |
19 | // Sell tokens for funding | if (
!inSwapAndLiquify && // Swap is not locked
balanceOf(address(this)) >= _liquifyThreshhold && // liquifyThreshhold is reached
from != pair && // Not from liq pool (can't sell during a buy)
from != address(this) &&
from != owner()
) {
... | if (
!inSwapAndLiquify && // Swap is not locked
balanceOf(address(this)) >= _liquifyThreshhold && // liquifyThreshhold is reached
from != pair && // Not from liq pool (can't sell during a buy)
from != address(this) &&
from != owner()
) {
... | 27,177 |
27 | // ------------------------------- EARLY BIRDS ------------------------------ //Allows the owner to start the Early Birds minting phase. | function startEarlyBirdsMint()
external
onlyOwner
onlyAfterMinimumGalleryArtUploaded
onlyIfMintingPhaseIsSetTo(Phase.INIT)
| function startEarlyBirdsMint()
external
onlyOwner
onlyAfterMinimumGalleryArtUploaded
onlyIfMintingPhaseIsSetTo(Phase.INIT)
| 53,270 |
11 | // Revert in the case where `judge` is never called. | require(State.Unlocked == sState, Errors.NOT_JUDGED);
| require(State.Unlocked == sState, Errors.NOT_JUDGED);
| 4,120 |
65 | // Setup Reputation System Setup GTC-ERC20 | reputation = new Reputations(_triageGroup, address(this));
gtc = ERC20(_gtcAddress);
poh = IPOH(_pohAddress);
triageGroup = TriageGroup(_triageGroup);
| reputation = new Reputations(_triageGroup, address(this));
gtc = ERC20(_gtcAddress);
poh = IPOH(_pohAddress);
triageGroup = TriageGroup(_triageGroup);
| 15,885 |
104 | // list of fees for every price range | mapping(uint256 => uint256) private feesTaxRate;
uint256 public lockRatio = 70;
| mapping(uint256 => uint256) private feesTaxRate;
uint256 public lockRatio = 70;
| 19,672 |
5 | // Creates a new offer for _tokenId for the price _price. Emits the MarketTransaction event with txType "Create offer" Requirement: Only the owner of _tokenId can create an offer. Requirement: There can only be one active offer for a token at a time. Requirement: Marketplace contract (this) needs to be an approved oper... | function setOffer(uint256 _price, uint256 _tokenId) external{
require(_pandaContract.ownerOf(_tokenId) == msg.sender,"Not the owner of the token");
require(tokenIdToOffer[_tokenId].active==false,"Already an offer exist");
require(_pandaContract.isApprovedForAll(msg.sender,address(this)),"Not... | function setOffer(uint256 _price, uint256 _tokenId) external{
require(_pandaContract.ownerOf(_tokenId) == msg.sender,"Not the owner of the token");
require(tokenIdToOffer[_tokenId].active==false,"Already an offer exist");
require(_pandaContract.isApprovedForAll(msg.sender,address(this)),"Not... | 6,587 |
17 | // Trusted EOAs to update the Merkle root | mapping(address => uint256) public canUpdateMerkleRoot;
| mapping(address => uint256) public canUpdateMerkleRoot;
| 36,960 |
7 | // Constructor should transition the state to StartState | assert(State == StateType.Active);
| assert(State == StateType.Active);
| 10,992 |
649 | // this can happen due to roundings in the reward calculation | if (staker.rewardDebt > accumulated) {
return 0;
}
| if (staker.rewardDebt > accumulated) {
return 0;
}
| 44,377 |
111 | // Creates `amount` tokens of token type `id`, and assigns them to `account`. | * Emits a {TransferSingle} event.
*
* Requirements:
*
* - `account` cannot be the zero address.
* - If `account` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155Received} and return the
* acceptance magic value.
*/
function... | * Emits a {TransferSingle} event.
*
* Requirements:
*
* - `account` cannot be the zero address.
* - If `account` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155Received} and return the
* acceptance magic value.
*/
function... | 32,095 |
102 | // tax fee | if(_SelltaxFee != 0){
uint256 taxFee = amount.mul(_SelltaxFee).div(10**(_feeDecimal + 2));
transferAmount = transferAmount.sub(taxFee);
_reflectionTotal = _reflectionTotal.sub(taxFee.mul(rate));
_taxFeeTotal = _taxFeeTotal.add(taxFee);
}
| if(_SelltaxFee != 0){
uint256 taxFee = amount.mul(_SelltaxFee).div(10**(_feeDecimal + 2));
transferAmount = transferAmount.sub(taxFee);
_reflectionTotal = _reflectionTotal.sub(taxFee.mul(rate));
_taxFeeTotal = _taxFeeTotal.add(taxFee);
}
| 64,672 |
17 | // Data kept in EVM-storage containing Witnet-provided response metadata and result. | struct Response {
address reporter; // Address from which the result was reported.
uint256 timestamp; // Timestamp of the Witnet-provided result.
bytes32 drTxHash; // Hash of the Witnet transaction that solved the queried Data Request.
bytes cborBytes; // Witn... | struct Response {
address reporter; // Address from which the result was reported.
uint256 timestamp; // Timestamp of the Witnet-provided result.
bytes32 drTxHash; // Hash of the Witnet transaction that solved the queried Data Request.
bytes cborBytes; // Witn... | 24,469 |
51 | // The wallet to receive asset tokens here before initiating crowdsalewill overwrite old wallet address | function setPlatformAssetsWallet(address _walletAddress)
external
| function setPlatformAssetsWallet(address _walletAddress)
external
| 38,537 |
256 | // Mints ILV tokens; executed by ILV Pool onlyRequires factory to have ROLE_TOKEN_CREATOR permission on the ILV ERC20 token instance_to an address to mint tokens to _amount amount of ILV tokens to mint / | function mintYieldTo(address _to, uint256 _amount) external {
// verify that sender is a pool registered withing the factory
require(poolExists[msg.sender], "access denied");
// mint ILV tokens as required
mintIlv(_to, _amount);
}
| function mintYieldTo(address _to, uint256 _amount) external {
// verify that sender is a pool registered withing the factory
require(poolExists[msg.sender], "access denied");
// mint ILV tokens as required
mintIlv(_to, _amount);
}
| 31,536 |
0 | // Decode raw CBOR bytes into a Witnet.Result instance./_cborBytes Raw bytes representing a CBOR-encoded value./ return A `Witnet.Result` instance. | function resultFromCborBytes(bytes calldata _cborBytes)
external pure
returns (Witnet.Result memory)
| function resultFromCborBytes(bytes calldata _cborBytes)
external pure
returns (Witnet.Result memory)
| 12,335 |
66 | // 预估开仓可以买到的期权币数量/tokenAddress 目标代币地址,0表示eth/oraclePrice 当前预言机价格价/strikePrice 用户设置的行权价格,结算时系统会根据标的物当前价与行权价比较,计算用户盈亏/orientation 看涨/看跌两个方向。true:看涨,false:看跌/exerciseBlock 到达该日期后用户手动进行行权,日期在系统中使用区块号进行记录/dcuAmount 支付的dcu数量/ return amount 预估可以获得的期权币数量 | function estimate(
address tokenAddress,
uint oraclePrice,
uint strikePrice,
bool orientation,
uint exerciseBlock,
uint dcuAmount
) external view returns (uint amount);
| function estimate(
address tokenAddress,
uint oraclePrice,
uint strikePrice,
bool orientation,
uint exerciseBlock,
uint dcuAmount
) external view returns (uint amount);
| 66,287 |
56 | // return all tokens to the proposer (not the applicant, because funds come from proposer) | unsafeInternalTransfer(ESCROW, proposal.proposer, proposal.tributeToken, proposal.tributeOffered);
| unsafeInternalTransfer(ESCROW, proposal.proposer, proposal.tributeToken, proposal.tributeOffered);
| 8,263 |
13 | // The _weth address is defined during the deployment of the contract There is no way to change it once it has been deployed, so it is fine to send eth to it. slither-disable-next-line arbitrary-send | _weth.deposit{value: details.amount}();
| _weth.deposit{value: details.amount}();
| 3,260 |
58 | // Returns the block number that the current RNG request has been locked to/ return The block number that the RNG request is locked to | function getLastRngLockBlock() external view returns (uint32) {
return rngRequest.lockBlock;
}
| function getLastRngLockBlock() external view returns (uint32) {
return rngRequest.lockBlock;
}
| 54,746 |
7 | // method which is used to mint nft. / | function mint(address receiver)
external
payable
publicMintAllowed(receiver)
startTime
endTime
costs
limitedByMaxSupply
limitedPerUser(receiver)
returns (uint256)
| function mint(address receiver)
external
payable
publicMintAllowed(receiver)
startTime
endTime
costs
limitedByMaxSupply
limitedPerUser(receiver)
returns (uint256)
| 19,696 |
16 | // transfer the token from contract address to the buyer | IERC721(nftContract).transferFrom(address(this),msg.sender, tokenId);
idToMarketToken[itemId].owner = payable(msg.sender);
idToMarketToken[itemId].sold = true;
_tokensSold.increment();
payable(owner).transfer(listingPrice);
| IERC721(nftContract).transferFrom(address(this),msg.sender, tokenId);
idToMarketToken[itemId].owner = payable(msg.sender);
idToMarketToken[itemId].sold = true;
_tokensSold.increment();
payable(owner).transfer(listingPrice);
| 24,206 |
3 | // Multiwallet Contract interface instance. Used to call functions from Multiwallet contract. / |
IMultiwalletContract private m_Multiwallet;
|
IMultiwalletContract private m_Multiwallet;
| 34,256 |
63 | // SLA SLA is a service level agreement contract used for service downtimecompensation / | contract SLA is Staking {
using SafeMath for uint256;
enum Status {NotVerified, Respected, NotRespected}
struct PeriodSLI {
uint256 timestamp;
uint256 sli;
Status status;
}
//
string public ipfsHash;
address public immutable messengerAddress;
SLARegistry public... | contract SLA is Staking {
using SafeMath for uint256;
enum Status {NotVerified, Respected, NotRespected}
struct PeriodSLI {
uint256 timestamp;
uint256 sli;
Status status;
}
//
string public ipfsHash;
address public immutable messengerAddress;
SLARegistry public... | 69,414 |
32 | // OptionMarketViewer Lyra Provides helpful functions to allow the dapp to operate more smoothly; logic in getPremiumForTrade is vital toensuring accurate prices are provided to the user. / | contract OptionMarketViewer {
using SafeDecimalMath for uint;
struct BoardView {
uint boardId;
uint expiry;
}
// Detailed view of an OptionListing - only for output
struct ListingView {
uint listingId;
uint boardId;
uint strike;
uint expiry;
uint iv;
uint skew;
uint callP... | contract OptionMarketViewer {
using SafeDecimalMath for uint;
struct BoardView {
uint boardId;
uint expiry;
}
// Detailed view of an OptionListing - only for output
struct ListingView {
uint listingId;
uint boardId;
uint strike;
uint expiry;
uint iv;
uint skew;
uint callP... | 26,683 |
28 | // Swap BUIDL for ETH and USDC in UniswapV2 | uniswapV2(
stateHolder,
tokenAmountToSwapForEtherInV2,
tokenAmountToSwapForUSDCInV2,
tokenToSwap,
dfoWalletAddress
);
| uniswapV2(
stateHolder,
tokenAmountToSwapForEtherInV2,
tokenAmountToSwapForUSDCInV2,
tokenToSwap,
dfoWalletAddress
);
| 35,637 |
5 | // receiveApproval服务合约指示代币合约将代币从发送者的账户转移到服务合约的账户(通过调用服务合约的 / | contract tokenRecipient {
function receiveApproval(address _from, uint256 _value, address _token, bytes _extraData) public;
}
| contract tokenRecipient {
function receiveApproval(address _from, uint256 _value, address _token, bytes _extraData) public;
}
| 23,768 |
18 | // accumulated instrumental since vesting inception | uint256 accumulatedInstrumental = block
.number
.sub(vest.start)
.mul(vest.instrumentalPerBlock)
.mul(getBoost(vid, volume, proof))
.add(vest.initialRewards)
.mul(userShare);
uint256 maxAccumulatedInstrumental = accumulatedInstrume... | uint256 accumulatedInstrumental = block
.number
.sub(vest.start)
.mul(vest.instrumentalPerBlock)
.mul(getBoost(vid, volume, proof))
.add(vest.initialRewards)
.mul(userShare);
uint256 maxAccumulatedInstrumental = accumulatedInstrume... | 63,863 |
259 | // calculate amount based on ETH/USD ratefor example 2e1736900 / 60 = 1231e180.2 eth buys 123 tokens if Ether price is $369 and token price is 60 cents / | uint tokenAmount;
| uint tokenAmount;
| 43,224 |
67 | // Sets deltas to a receiver from now to `timeEnd`/receiverAddr The address of the receiver/amtPerSecDelta Change of the per-second receiving rate/timeEnd The timestamp from which the delta stops taking effect | function setReceiverDeltaFromNow(
address receiverAddr,
int128 amtPerSecDelta,
uint64 timeEnd
| function setReceiverDeltaFromNow(
address receiverAddr,
int128 amtPerSecDelta,
uint64 timeEnd
| 1,267 |
117 | // add liquidity | swapAndLiquify(contractTokenBalance);
| swapAndLiquify(contractTokenBalance);
| 2,748 |
4 | // s {string} name - the name of the contract Addresss {address} newAddress | function addAddress(string name, address newAddress) public onlyOwner {
bytes32 contAddId = stringToBytes32(name);
uint nowInMilliseconds = now * 1000;
if (contractsAddress[contAddId].id == 0x0) {
ContractAddress memory newContractAddress;
newContractAddress.id = co... | function addAddress(string name, address newAddress) public onlyOwner {
bytes32 contAddId = stringToBytes32(name);
uint nowInMilliseconds = now * 1000;
if (contractsAddress[contAddId].id == 0x0) {
ContractAddress memory newContractAddress;
newContractAddress.id = co... | 28,472 |
20 | // structure for liver disease | struct liver{
string diseases;
}
| struct liver{
string diseases;
}
| 14,503 |
586 | // Libertas-7.04 MKR - 0xE1eBfFa01883EF2b4A9f59b587fFf1a5B44dbb2f | MKR.transfer(LIBERTAS, 7.04 ether); // note: ether is a keyword helper, only MKR is transferred here
| MKR.transfer(LIBERTAS, 7.04 ether); // note: ether is a keyword helper, only MKR is transferred here
| 14,213 |
2 | // This event tracks pool creations from this factory/pool the address of the pool/bondToken The token of the bond token in this pool | event CCPoolCreated(address indexed pool, address indexed bondToken);
| event CCPoolCreated(address indexed pool, address indexed bondToken);
| 72,227 |
167 | // We use this function when withdraw right from pool. No transfer because after that we burn this amount from contract. | function withdrawAllStateUpdateByPool(address holder)
external
nonReentrant
returns (uint256)
| function withdrawAllStateUpdateByPool(address holder)
external
nonReentrant
returns (uint256)
| 6,317 |
191 | // safe math not needed hereapr is scaled by 1e18 so we downscale here | uint256 profitIncrease = (nav.mul(potential) - nav.mul(lowestApr)).div(1e18).mul(maxReportDelay).div(SECONDSPERYEAR);
uint256 wantCallCost = _callCostToWant(callCost);
return (wantCallCost.mul(profitFactor) < profitIncrease);
| uint256 profitIncrease = (nav.mul(potential) - nav.mul(lowestApr)).div(1e18).mul(maxReportDelay).div(SECONDSPERYEAR);
uint256 wantCallCost = _callCostToWant(callCost);
return (wantCallCost.mul(profitFactor) < profitIncrease);
| 3,144 |
9 | // dispatchTransferFrom errors / | string constant ASSET_PROXY_DOES_NOT_EXIST = "ASSET_PROXY_DOES_NOT_EXIST"; // No assetProxy registered at given id.
string constant TRANSFER_FAILED = "TRANSFER_FAILED"; // Asset transfer unsuccesful.
| string constant ASSET_PROXY_DOES_NOT_EXIST = "ASSET_PROXY_DOES_NOT_EXIST"; // No assetProxy registered at given id.
string constant TRANSFER_FAILED = "TRANSFER_FAILED"; // Asset transfer unsuccesful.
| 49,721 |
57 | // Adds a bytes value to the request with a given key name self The initialized request _key The name of the key _value The bytes value to add / | function addBytes(Request memory self, string memory _key, bytes memory _value)
internal pure
| function addBytes(Request memory self, string memory _key, bytes memory _value)
internal pure
| 18,509 |
94 | // notice total UBXT rewards for distribution | uint256 totalUBXTReward;
| uint256 totalUBXTReward;
| 6,575 |
35 | // Implementation template Do something | } else if (sig == bytes4(keccak256(bytes("handlerFunction_2()")))) {
| } else if (sig == bytes4(keccak256(bytes("handlerFunction_2()")))) {
| 3,867 |
22 | // Compound pending fees/ return baseToken0Owed Pending fees of base token0/ return baseToken1Owed Pending fees of base token1/ return limitToken0Owed Pending fees of limit token0/ return limitToken1Owed Pending fees of limit token1 | function compound() external onlyOwner returns (
uint128 baseToken0Owed,
uint128 baseToken1Owed,
uint128 limitToken0Owed,
uint128 limitToken1Owed,
uint256[4] memory inMin
| function compound() external onlyOwner returns (
uint128 baseToken0Owed,
uint128 baseToken1Owed,
uint128 limitToken0Owed,
uint128 limitToken1Owed,
uint256[4] memory inMin
| 77,738 |
68 | // triggered when a smart token is deployed - the _token address is defined for forward compatibility, in case we want to trigger the event from a factory | event NewSmartToken(address _token);
| event NewSmartToken(address _token);
| 28,847 |
103 | // Transfers ownership of the contract to a new account (`_candidate`).Can only be called by the new owner. / | function updateOwner() public {
require(_candidate != address(0), "PerpFiOwnableUpgrade: candidate is zero address");
require(_candidate == _msgSender(), "PerpFiOwnableUpgrade: not the new owner");
emit OwnershipTransferred(_owner, _candidate);
_owner = _candidate;
_candidat... | function updateOwner() public {
require(_candidate != address(0), "PerpFiOwnableUpgrade: candidate is zero address");
require(_candidate == _msgSender(), "PerpFiOwnableUpgrade: not the new owner");
emit OwnershipTransferred(_owner, _candidate);
_owner = _candidate;
_candidat... | 27,090 |
486 | // Returns the platform fee bps and recipient. | function getPlatformFeeInfo() external view returns (address platformFeeRecipient, uint16 platformFeeBps);
| function getPlatformFeeInfo() external view returns (address platformFeeRecipient, uint16 platformFeeBps);
| 71,877 |
25 | // if the canonical super token address exists, revert with custom error | if (canonicalSuperTokenAddress != address(0)) {
revert SUPER_TOKEN_FACTORY_ALREADY_EXISTS();
}
| if (canonicalSuperTokenAddress != address(0)) {
revert SUPER_TOKEN_FACTORY_ALREADY_EXISTS();
}
| 11,207 |
14 | // ============ External ============ //Reads value of oracle and coerces return to uint256 then applies price multiplier returns Chainlink oracle price in uint256 / | function read()
external
view
returns (uint256)
| function read()
external
view
returns (uint256)
| 21,381 |
48 | // Determine the amount to repay. | uint256 repayAmount = getRepayAmount(amount);
address bank = FlashLender(lender).bank();
| uint256 repayAmount = getRepayAmount(amount);
address bank = FlashLender(lender).bank();
| 68,330 |
82 | // Aprove an allowance for admin account | adminAddress = 0xe0509bB3921aacc433108D403f020a7c2f92e936;
approve(adminAddress, ADMIN_ALLOWANCE);
participantCapTier1 = 100 ether;
participantCapTier2 = 100 ether;
poolAddressCapTier1 = 2000 ether;
poolAddressCapTier2 = 2000 ether;
weiRaised = 0;
start... | adminAddress = 0xe0509bB3921aacc433108D403f020a7c2f92e936;
approve(adminAddress, ADMIN_ALLOWANCE);
participantCapTier1 = 100 ether;
participantCapTier2 = 100 ether;
poolAddressCapTier1 = 2000 ether;
poolAddressCapTier2 = 2000 ether;
weiRaised = 0;
start... | 9,331 |
14 | // Get the factory's ownership of Option.Should be the amount it can still mint.NOTE: Called by `canMint` / | function balanceOf(
address _owner,
uint256 _optionId
| function balanceOf(
address _owner,
uint256 _optionId
| 9,411 |
109 | // called by providers | function migrateProvider(address _newProvider) external onlyAllowed {
JointProvider newProvider = JointProvider(_newProvider);
if (newProvider.want() == tokenA) {
providerA = newProvider;
} else if (newProvider.want() == tokenB) {
providerB = newProvider;
} el... | function migrateProvider(address _newProvider) external onlyAllowed {
JointProvider newProvider = JointProvider(_newProvider);
if (newProvider.want() == tokenA) {
providerA = newProvider;
} else if (newProvider.want() == tokenB) {
providerB = newProvider;
} el... | 46,875 |
123 | // https:docs.synthetix.io/contracts/source/contracts/mixinresolver | contract MixinResolver {
AddressResolver public resolver;
mapping(bytes32 => address) private addressCache;
constructor(address _resolver) internal {
resolver = AddressResolver(_resolver);
}
/* ========== INTERNAL FUNCTIONS ========== */
function combineArrays(bytes32[] memory first,... | contract MixinResolver {
AddressResolver public resolver;
mapping(bytes32 => address) private addressCache;
constructor(address _resolver) internal {
resolver = AddressResolver(_resolver);
}
/* ========== INTERNAL FUNCTIONS ========== */
function combineArrays(bytes32[] memory first,... | 4,854 |
101 | // Official record of token balances for each account / | mapping(address => uint256) internal accountTokens;
| mapping(address => uint256) internal accountTokens;
| 787 |
59 | // Voting power of an address | mapping(address => uint256) votePower;
| mapping(address => uint256) votePower;
| 41,336 |
538 | // Get total delegation from a given address _delegator - delegator address / | function getTotalDelegatorStake(address _delegator)
external view returns (uint256)
| function getTotalDelegatorStake(address _delegator)
external view returns (uint256)
| 38,590 |
8 | // {TransparentUpgradeableProxy-upgradeToAndCall}.Requirements:- This contract must be the admin of `proxy`. / | function upgradeAndCall(TransparentUpgradeableProxy proxy, address implementation, bytes memory data) public payable onlyOwner {
proxy.upgradeToAndCall{value: msg.value}(implementation, data);
| function upgradeAndCall(TransparentUpgradeableProxy proxy, address implementation, bytes memory data) public payable onlyOwner {
proxy.upgradeToAndCall{value: msg.value}(implementation, data);
| 33,217 |
483 | // Returns the linear interpolation between two market rates. The formula is/ slope = (longMarket.oracleRate - shortMarket.oracleRate) / (longMarket.maturity - shortMarket.maturity)/ interpolatedRate = slope(assetMaturity - shortMarket.maturity) + shortMarket.oracleRate | function interpolateOracleRate(
uint256 shortMaturity,
uint256 longMaturity,
uint256 shortRate,
uint256 longRate,
uint256 assetMaturity
| function interpolateOracleRate(
uint256 shortMaturity,
uint256 longMaturity,
uint256 shortRate,
uint256 longRate,
uint256 assetMaturity
| 64,989 |
76 | // NToken合约 | interface INest_NToken {
// 更改映射
function changeMapping (address voteFactory) external;
}
| interface INest_NToken {
// 更改映射
function changeMapping (address voteFactory) external;
}
| 6,270 |
69 | // Address of methodologist which serves as providing methodology for the index | address public methodologist;
| address public methodologist;
| 2,277 |
287 | // Calculate how much the tokens cost. Overpayed purchases don't receive a return. | uint256 cost = uint256(_tokenAmount).mul(rate);
| uint256 cost = uint256(_tokenAmount).mul(rate);
| 8,223 |
203 | // Change delegation for `delegator` to `delegatee`. | * Emits events {DelegateChanged} and {DelegateVotesChanged}.
*/
function _delegate(address delegator, address delegatee) internal virtual {
address currentDelegate = delegates(delegator);
uint256 delegatorBalance = balanceOf(delegator);
_delegates[delegator] = delegatee;
e... | * Emits events {DelegateChanged} and {DelegateVotesChanged}.
*/
function _delegate(address delegator, address delegatee) internal virtual {
address currentDelegate = delegates(delegator);
uint256 delegatorBalance = balanceOf(delegator);
_delegates[delegator] = delegatee;
e... | 4,287 |
86 | // OK, check 3 | function swapBack() internal swapping {
uint256 dynamicLiquidityFee = isOverLiquified(targetLiquidity, targetLiquidityDenominator) ? 0 : liquidityFee;
uint256 tokensToSell = swapThreshold.div(rate);
uint256 amountToLiquify = tokensToSell.div(totalFee).mul(dynamicLiquidityFee).div(2);
... | function swapBack() internal swapping {
uint256 dynamicLiquidityFee = isOverLiquified(targetLiquidity, targetLiquidityDenominator) ? 0 : liquidityFee;
uint256 tokensToSell = swapThreshold.div(rate);
uint256 amountToLiquify = tokensToSell.div(totalFee).mul(dynamicLiquidityFee).div(2);
... | 18,241 |
2 | // emitted when the owner updates the edition override for secondary royalty | event EditionRoyaltyPercentageUpdated(
uint256 indexed _editionId,
uint256 _percentage
);
| event EditionRoyaltyPercentageUpdated(
uint256 indexed _editionId,
uint256 _percentage
);
| 40,251 |
5 | // Function to activate emergency pause. This should stop buying activity on all offeringsOnly Emergency Multisig wallet should be able to call this / | function emergencyPause() onlyEmergencyMultisig public {
isEmergencyPaused = true;
}
| function emergencyPause() onlyEmergencyMultisig public {
isEmergencyPaused = true;
}
| 7,434 |
25 | // Transfer `amount_` tokens from _msgSender() (msg.sender) to `recipient_` Requirements: - `recipient` cannot be the zero address.- the caller must have a balance of at least `amount`. / | function transfer(address recipient_, uint256 amount_) public returns (bool) {
_transfer(_msgSender(), recipient_, amount_);
return true;
}
| function transfer(address recipient_, uint256 amount_) public returns (bool) {
_transfer(_msgSender(), recipient_, amount_);
return true;
}
| 4,289 |
94 | // Partitioning a subset of outcomes for the condition in this branch. For example, for a condition with three outcomes A, B, and C, this branch allows the splitting of a position $:(A|C) to positions $:(A) and $:(C). | _burn(
msg.sender,
CTHelpers.getPositionId(collateralToken,
CTHelpers.getCollectionId(parentCollectionId, conditionId, fullIndexSet ^ freeIndexSet)),
amount
);
| _burn(
msg.sender,
CTHelpers.getPositionId(collateralToken,
CTHelpers.getCollectionId(parentCollectionId, conditionId, fullIndexSet ^ freeIndexSet)),
amount
);
| 24,241 |
1 | // truncation ErrorIn Solidity, a loss of accuracy may occur when a longer integer is cast to a shorter one. | require(balances[msg.sender] + uint32(msg.value) >= balances[msg.sender]);
balances[msg.sender] += uint32(msg.value);
| require(balances[msg.sender] + uint32(msg.value) >= balances[msg.sender]);
balances[msg.sender] += uint32(msg.value);
| 51,033 |
291 | // Set the proposal time in order to allow this contract to track this request. | fundingRate.proposalTime = timestamp;
OptimisticOracleInterface optimisticOracle = _getOptimisticOracle();
| fundingRate.proposalTime = timestamp;
OptimisticOracleInterface optimisticOracle = _getOptimisticOracle();
| 5,681 |
21 | // each eMode category may or may not have a custom oracle to override the individual assets price oracles | address priceSource;
string label;
| address priceSource;
string label;
| 22,056 |
44 | // Now have AMPL so send reward to caller and rest to fee distributor |
uint256 reward = _getReward(info); // Reward rate for this borrowable
uint256 rewardAmount = gremlinBalanceChange.mul(reward).div(REWARD_SCALE);
if (rewardAmount > 0) {
AMPL.safeTransfer(to, rewardAmount);
}
|
uint256 reward = _getReward(info); // Reward rate for this borrowable
uint256 rewardAmount = gremlinBalanceChange.mul(reward).div(REWARD_SCALE);
if (rewardAmount > 0) {
AMPL.safeTransfer(to, rewardAmount);
}
| 16,148 |
61 | // Offers to direct listings cannot be made directly in native tokens. | newOffer.currency = _currency == CurrencyTransferLib.NATIVE_TOKEN ? nativeTokenWrapper : _currency;
newOffer.quantityWanted = getSafeQuantity(targetListing.tokenType, _quantityWanted);
handleOffer(targetListing, newOffer);
| newOffer.currency = _currency == CurrencyTransferLib.NATIVE_TOKEN ? nativeTokenWrapper : _currency;
newOffer.quantityWanted = getSafeQuantity(targetListing.tokenType, _quantityWanted);
handleOffer(targetListing, newOffer);
| 4,086 |
8 | // an array of booleans corresponding to interfaceIds and whether they're supported or not | bool[] memory interfaceIdsSupported = new bool[](interfaceIds.length);
| bool[] memory interfaceIdsSupported = new bool[](interfaceIds.length);
| 29,008 |
108 | // duration of the vesting period in seconds | uint256 duration;
| uint256 duration;
| 68,163 |
44 | // Returns the length of a null-terminated bytes32 string. self The value to find the length of.return The length of the string, from 0 to 32. / | function len(bytes32 self) internal pure returns (uint) {
uint ret;
if (self == 0)
return 0;
if (uint(self) & 0xffffffffffffffffffffffffffffffff == 0) {
ret += 16;
self = bytes32(uint(self) / 0x100000000000000000000000000000000);
}
if (uint... | function len(bytes32 self) internal pure returns (uint) {
uint ret;
if (self == 0)
return 0;
if (uint(self) & 0xffffffffffffffffffffffffffffffff == 0) {
ret += 16;
self = bytes32(uint(self) / 0x100000000000000000000000000000000);
}
if (uint... | 2,346 |
34 | // Fetch the user's balance return balance The user's balance/ | function fetchMyBalance()
external
view
| function fetchMyBalance()
external
view
| 28,720 |
312 | // Grants a permission with parameters if allowed. This requires `msg.sender` to be the permission managerGrant `_entity` the ability to perform actions requiring `_role` on `_app`_entity Address of the whitelisted entity that will be able to perform the role_app Address of the app in which the role will be allowed (re... | function grantPermissionP(address _entity, address _app, bytes32 _role, uint256[] _params)
public
onlyPermissionManager(_app, _role)
| function grantPermissionP(address _entity, address _app, bytes32 _role, uint256[] _params)
public
onlyPermissionManager(_app, _role)
| 49,072 |
31 | // Store the function selector of `HexLengthInsufficient()`. | mstore(0x00, 0x2194895a)
| mstore(0x00, 0x2194895a)
| 13,056 |
1 | // ============ Function to Receive ETH ============ | receive() external payable {
totalReceived += msg.value;
montageFee = msg.value * shareDetails[4] / totalShares;
_transfer(marketWallet, montageFee);
montageFee = 0;
emit FeeReceived(address(this), msg.value);
}
| receive() external payable {
totalReceived += msg.value;
montageFee = msg.value * shareDetails[4] / totalShares;
_transfer(marketWallet, montageFee);
montageFee = 0;
emit FeeReceived(address(this), msg.value);
}
| 5,412 |
1 | // Normal execution |
uint constant NO_ERROR = 0;
|
uint constant NO_ERROR = 0;
| 52,018 |
154 | // calculate amount of SDA available for claim by depositor_depositor address return pendingPayout_ uint / | function pendingPayoutFor( address _depositor ) external view returns ( uint pendingPayout_ ) {
uint percentVested = percentVestedFor( _depositor );
uint payout = ISSDA(sSDA).balanceForGons(_bondInfo[ _depositor ].gonsPayout);
if ( percentVested >= 10000 ) {
pendingPayout_ = pay... | function pendingPayoutFor( address _depositor ) external view returns ( uint pendingPayout_ ) {
uint percentVested = percentVestedFor( _depositor );
uint payout = ISSDA(sSDA).balanceForGons(_bondInfo[ _depositor ].gonsPayout);
if ( percentVested >= 10000 ) {
pendingPayout_ = pay... | 48,463 |
48 | // _owner The owner whose space tokens we are interested in./This method MUST NEVER be called by smart contract code. First, it's fairly/expensive (it walks the entire Persons array looking for persons belonging to owner),/but it also returns a dynamic array, which is only supported for web3 calls, and/not contract-to-... | function tokensOfOwner(address _owner) public view returns(uint256[] ownerTokens) {
uint256 tokenCount = balanceOf(_owner);
if (tokenCount == 0) {
// Return an empty array
return new uint256[](0);
} else {
uint256[] memory result = new uint256[](tokenCount);
uint256 totalPersons ... | function tokensOfOwner(address _owner) public view returns(uint256[] ownerTokens) {
uint256 tokenCount = balanceOf(_owner);
if (tokenCount == 0) {
// Return an empty array
return new uint256[](0);
} else {
uint256[] memory result = new uint256[](tokenCount);
uint256 totalPersons ... | 3,447 |
22 | // ERC20 backwards compatible transferFrom/_from The address holding the tokens being transferred/_to The address of the recipient/_amount The number of tokens to be transferred/ return `true`, if the transfer can't be done, it should fail. | function transferFrom(address _from, address _to, uint256 _amount) public erc20 returns (bool success) {
require(_amount <= mAllowed[_from][msg.sender]);
// Cannot be after doSend because of tokensReceived re-entry
mAllowed[_from][msg.sender] = mAllowed[_from][msg.sender].sub(_amount);
... | function transferFrom(address _from, address _to, uint256 _amount) public erc20 returns (bool success) {
require(_amount <= mAllowed[_from][msg.sender]);
// Cannot be after doSend because of tokensReceived re-entry
mAllowed[_from][msg.sender] = mAllowed[_from][msg.sender].sub(_amount);
... | 15,221 |
30 | // Request subscription owner transfer. subId - ID of the subscription newOwner - proposed new owner of the subscription / | function requestSubscriptionOwnerTransfer(uint64 subId, address newOwner) external;
| function requestSubscriptionOwnerTransfer(uint64 subId, address newOwner) external;
| 50,617 |
185 | // Transfer WETH from the buyer to the seller. | _transferERC20TokensFrom(WETH, msg.sender, sellOrder.maker, erc20FillAmount);
if (ethAvailable > 0) {
if (ethAvailable < totalFeesPaid) {
| _transferERC20TokensFrom(WETH, msg.sender, sellOrder.maker, erc20FillAmount);
if (ethAvailable > 0) {
if (ethAvailable < totalFeesPaid) {
| 43,229 |
167 | // liquidationIncentiveMantissa must be no greater than this value | uint internal constant liquidationIncentiveMaxMantissa = 1.5e18; // 1.5
| uint internal constant liquidationIncentiveMaxMantissa = 1.5e18; // 1.5
| 34,831 |
1 | // --- Tolerances ---/Scale used to define percentages. Percentages are defined as tolerance / scale | uint256 public constant scale = 1000;
| uint256 public constant scale = 1000;
| 72,012 |
395 | // round 50 | t0, t1, t2, t3, t4 := ark(t0, t1, t2, t3, t4, q, 9121640807890366356465620448383131419933298563527245687958865317869840082266)
t0 := sbox_partial(t0, q)
t0, t1, t2, t3, t4 := mix(t0, t1, t2, t3, t4, q)
| t0, t1, t2, t3, t4 := ark(t0, t1, t2, t3, t4, q, 9121640807890366356465620448383131419933298563527245687958865317869840082266)
t0 := sbox_partial(t0, q)
t0, t1, t2, t3, t4 := mix(t0, t1, t2, t3, t4, q)
| 49,264 |
60 | // function is used to make a rental offer for a specific user for a given NFT. |
function makeNFTRentOfferForUser(
uint256 tokenId,
uint256 _price,
uint256 _percentage,
uint256 _time,
address user
|
function makeNFTRentOfferForUser(
uint256 tokenId,
uint256 _price,
uint256 _percentage,
uint256 _time,
address user
| 20,922 |
82 | // apply a bonus if any (10SET) | uint256 tokensWithoutBonus = limitedInvestValue.mul(price).div(1 ether);
uint256 tokensWithBonus = tokensWithoutBonus;
if (milestone.bonus > 0) {
tokensWithBonus = tokensWithoutBonus.add(tokensWithoutBonus.mul(milestone.bonus).div(percentRate));
}
| uint256 tokensWithoutBonus = limitedInvestValue.mul(price).div(1 ether);
uint256 tokensWithBonus = tokensWithoutBonus;
if (milestone.bonus > 0) {
tokensWithBonus = tokensWithoutBonus.add(tokensWithoutBonus.mul(milestone.bonus).div(percentRate));
}
| 50,480 |
48 | // Internal functions | function _balanceProportion(int24 _tickLower, int24 _tickUpper) internal {
PoolVariables.Info memory _cache;
_cache.amount0Desired = token0.balanceOf(address(this));
_cache.amount1Desired = token1.balanceOf(address(this));
//Get Max Liquidity for Amounts we own.
_cache.liqu... | function _balanceProportion(int24 _tickLower, int24 _tickUpper) internal {
PoolVariables.Info memory _cache;
_cache.amount0Desired = token0.balanceOf(address(this));
_cache.amount1Desired = token1.balanceOf(address(this));
//Get Max Liquidity for Amounts we own.
_cache.liqu... | 22,406 |
34 | // Withdraw all ERC20 compatible tokens token ERC20 The address of the token contract / | function withdrawToken(ERC20 token, uint amount, address sendTo) external onlyAdmin {
require(token.transfer(sendTo, amount));
TokenWithdraw(token, amount, sendTo);
}
| function withdrawToken(ERC20 token, uint amount, address sendTo) external onlyAdmin {
require(token.transfer(sendTo, amount));
TokenWithdraw(token, amount, sendTo);
}
| 33,528 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.