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 |
|---|---|---|---|---|
8 | // MAINNET ADDRESSES The contracts in this list should correspond to MCD core contracts, verifyagainst the current release list at: https:changelog.makerdao.com/releases/mainnet/1.1.2/contracts.json |
address constant MCD_VAT = 0x35D1b3F3D7966A1DFe207aa4514C12a259A0492B;
address constant MCD_JUG = 0x19c0976f590D67707E62397C87829d896Dc0f1F1;
|
address constant MCD_VAT = 0x35D1b3F3D7966A1DFe207aa4514C12a259A0492B;
address constant MCD_JUG = 0x19c0976f590D67707E62397C87829d896Dc0f1F1;
| 22,614 |
28 | // Compare the last nonequal labels to each other | while (counts > 0 && !self.equals(off, other, otheroff)) {
prevoff = off;
off = progress(self, off);
otherprevoff = otheroff;
otheroff = progress(other, otheroff);
counts -= 1;
}
| while (counts > 0 && !self.equals(off, other, otheroff)) {
prevoff = off;
off = progress(self, off);
otherprevoff = otheroff;
otheroff = progress(other, otheroff);
counts -= 1;
}
| 4,316 |
439 | // Reveal a previously committed bug. bugId The ID of the bug commitment bugDescription The description of the bug / | function revealBug(uint256 bugId, string bugDescription, uint256 nonce) public returns (bool) {
address hunter = msg.sender;
uint256 bountyId = bountyData.getBugCommitBountyId(bugId);
// the bug commit exists, and the committer is the hunter
require(bountyData.getBugCommitCommitter(bugId) == hunter);
// the current timestamp is within the reveal period
require(bountyData.isRevealPeriod(bountyId));
// the bounty is active. Otherwise, it's too late to reveal, and funds should
// be rescued using rescueHunterDeposit below (that function does not reveal
// the bug)
require(bountyData.bountyActive(bountyId));
// the hash of the bug description matches the hash and was sent from the hunter
// the hunter address will be converted to lower case after abi.encodePacked
// so be sure to use the lower-case version during bug hash generation.
require(keccak256(abi.encodePacked(bugDescription, hunter, nonce)) == bountyData.getBugCommitBugDescriptionHash(bugId));
// create a poll for the TCR to vote on the bug
uint256 pollId = bountyData.voting().startPoll(
bountyData.parameterizer().get("voteQuorum"),
bountyData.getBountyJudgeCommitPhaseEndTimestamp(bountyId).sub(block.timestamp),
bountyData.getBountyJudgeRevealDuration(bountyId)
);
// the minimum votes for a vote to succeed
uint256 minVotes = bountyData.getBountyMinVotes(bountyId);
// the judge must stake a deposit to incentivize vote reveal
uint256 judgeDeposit = bountyData.getBountyJudgeDeposit(bountyId);
bountyData.voting().restrictPoll(pollId, minVotes, judgeDeposit);
// add the bug to the list of revealed bugs
bountyData.addBug(bugId, bugDescription, pollId);
bountyData.addBugToHunter(hunter, bugId);
// delete the bug commit
bountyData.removeBugCommitment(bugId);
emit LogBugRevealed(bountyId, bugId, hunter);
emit LogBugVoteInitiated(bountyId, bugId, pollId);
return true;
}
| function revealBug(uint256 bugId, string bugDescription, uint256 nonce) public returns (bool) {
address hunter = msg.sender;
uint256 bountyId = bountyData.getBugCommitBountyId(bugId);
// the bug commit exists, and the committer is the hunter
require(bountyData.getBugCommitCommitter(bugId) == hunter);
// the current timestamp is within the reveal period
require(bountyData.isRevealPeriod(bountyId));
// the bounty is active. Otherwise, it's too late to reveal, and funds should
// be rescued using rescueHunterDeposit below (that function does not reveal
// the bug)
require(bountyData.bountyActive(bountyId));
// the hash of the bug description matches the hash and was sent from the hunter
// the hunter address will be converted to lower case after abi.encodePacked
// so be sure to use the lower-case version during bug hash generation.
require(keccak256(abi.encodePacked(bugDescription, hunter, nonce)) == bountyData.getBugCommitBugDescriptionHash(bugId));
// create a poll for the TCR to vote on the bug
uint256 pollId = bountyData.voting().startPoll(
bountyData.parameterizer().get("voteQuorum"),
bountyData.getBountyJudgeCommitPhaseEndTimestamp(bountyId).sub(block.timestamp),
bountyData.getBountyJudgeRevealDuration(bountyId)
);
// the minimum votes for a vote to succeed
uint256 minVotes = bountyData.getBountyMinVotes(bountyId);
// the judge must stake a deposit to incentivize vote reveal
uint256 judgeDeposit = bountyData.getBountyJudgeDeposit(bountyId);
bountyData.voting().restrictPoll(pollId, minVotes, judgeDeposit);
// add the bug to the list of revealed bugs
bountyData.addBug(bugId, bugDescription, pollId);
bountyData.addBugToHunter(hunter, bugId);
// delete the bug commit
bountyData.removeBugCommitment(bugId);
emit LogBugRevealed(bountyId, bugId, hunter);
emit LogBugVoteInitiated(bountyId, bugId, pollId);
return true;
}
| 41,298 |
655 | // First, we allocate memory for `code` by retrieving the free memory pointer and then moving it ahead of `code` by the size of the creation code plus constructor arguments, and 32 bytes for the array length. | code := mload(0x40)
mstore(0x40, add(code, add(codeSize, 32)))
| code := mload(0x40)
mstore(0x40, add(code, add(codeSize, 32)))
| 54,330 |
9 | // 1. Override the claim function to ensure a few things: - They own an NFT from the OBYC contract | if (_level == 1) {
require(
!isAlreadyMintedObyc(_obycTokenId),
"You Have Already Transformed this OBYC Token"
);
require(
_obycLabTokenId == 0 || _obycLabTokenId == 1,
"Wrong Lab Token Id for Level One Transformation"
);
require(
| if (_level == 1) {
require(
!isAlreadyMintedObyc(_obycTokenId),
"You Have Already Transformed this OBYC Token"
);
require(
_obycLabTokenId == 0 || _obycLabTokenId == 1,
"Wrong Lab Token Id for Level One Transformation"
);
require(
| 2,058 |
134 | // if exd.totalStakeLP==0 => will break by conditions above else: exd.totalStakeLP!=0. Since every time the LP balance changes, this function will be called./ | require(epochData[epochId].stakeUnitsForExpiry[expiry] != 0, "INTERNAL_ERROR");
| require(epochData[epochId].stakeUnitsForExpiry[expiry] != 0, "INTERNAL_ERROR");
| 76,651 |
7 | // Links the token contract to a specific SlotsOption contract./In this way, the transfer of ownership is also assigned to the slotsOption contract./_slotOptionContractslotOption contract to be linked and who will become the owner of the token contract. | function linkToSlotOptionContract(address _slotOptionContract) public onlyOwner {
slotOption = _slotOptionContract;
transferOwnership(_slotOptionContract);
}
| function linkToSlotOptionContract(address _slotOptionContract) public onlyOwner {
slotOption = _slotOptionContract;
transferOwnership(_slotOptionContract);
}
| 12,039 |
218 | // Update state variables. | apr = specs[0];
termDays = specs[1];
paymentsRemaining = specs[1].div(specs[2]);
paymentIntervalSeconds = specs[2].mul(1 days);
requestAmount = specs[3];
collateralRatio = specs[4];
fundingPeriod = globals.fundingPeriod();
defaultGracePeriod = globals.defaultGracePeriod();
repaymentCalc = calcs[0];
lateFeeCalc = calcs[1];
| apr = specs[0];
termDays = specs[1];
paymentsRemaining = specs[1].div(specs[2]);
paymentIntervalSeconds = specs[2].mul(1 days);
requestAmount = specs[3];
collateralRatio = specs[4];
fundingPeriod = globals.fundingPeriod();
defaultGracePeriod = globals.defaultGracePeriod();
repaymentCalc = calcs[0];
lateFeeCalc = calcs[1];
| 6,400 |
11 | // Refund the previously highest bidder. | pendingReturns[highestBidder] += highestBid;
| pendingReturns[highestBidder] += highestBid;
| 29,953 |
6 | // actuall mint the NFT using the underneath logic | super.mintTo(_to,_tokenURI);
| super.mintTo(_to,_tokenURI);
| 20,452 |
23 | // These functions deal with verification of Merkle Trees proofs. The proofs can be generated using the JavaScript libraryNote: the hashing algorithm should be keccak256 and pair sorting should be enabled. See `test/utils/cryptography/MerkleProof.test.js` for some examples. / | library MerkleProof {
/**
* @dev Returns true if a `leaf` can be proved to be a part of a Merkle tree
* defined by `root`. For this, a `proof` must be provided, containing
* sibling hashes on the branch from the leaf to the root of the tree. Each
* pair of leaves and each pair of pre-images are assumed to be sorted.
*/
function verify(
bytes32[] memory proof,
bytes32 root,
bytes32 leaf
) internal pure returns (bool) {
return processProof(proof, leaf) == root;
}
/**
* @dev Returns the rebuilt hash obtained by traversing a Merklee tree up
* from `leaf` using `proof`. A `proof` is valid if and only if the rebuilt
* hash matches the root of the tree. When processing the proof, the pairs
* of leafs & pre-images are assumed to be sorted.
*
* _Available since v4.4._
*/
function processProof(bytes32[] memory proof, bytes32 leaf) internal pure returns (bytes32) {
bytes32 computedHash = leaf;
for (uint256 i = 0; i < proof.length; i++) {
bytes32 proofElement = proof[i];
if (computedHash <= proofElement) {
// Hash(current computed hash + current element of the proof)
computedHash = keccak256(abi.encodePacked(computedHash, proofElement));
} else {
// Hash(current element of the proof + current computed hash)
computedHash = keccak256(abi.encodePacked(proofElement, computedHash));
}
}
return computedHash;
}
}
| library MerkleProof {
/**
* @dev Returns true if a `leaf` can be proved to be a part of a Merkle tree
* defined by `root`. For this, a `proof` must be provided, containing
* sibling hashes on the branch from the leaf to the root of the tree. Each
* pair of leaves and each pair of pre-images are assumed to be sorted.
*/
function verify(
bytes32[] memory proof,
bytes32 root,
bytes32 leaf
) internal pure returns (bool) {
return processProof(proof, leaf) == root;
}
/**
* @dev Returns the rebuilt hash obtained by traversing a Merklee tree up
* from `leaf` using `proof`. A `proof` is valid if and only if the rebuilt
* hash matches the root of the tree. When processing the proof, the pairs
* of leafs & pre-images are assumed to be sorted.
*
* _Available since v4.4._
*/
function processProof(bytes32[] memory proof, bytes32 leaf) internal pure returns (bytes32) {
bytes32 computedHash = leaf;
for (uint256 i = 0; i < proof.length; i++) {
bytes32 proofElement = proof[i];
if (computedHash <= proofElement) {
// Hash(current computed hash + current element of the proof)
computedHash = keccak256(abi.encodePacked(computedHash, proofElement));
} else {
// Hash(current element of the proof + current computed hash)
computedHash = keccak256(abi.encodePacked(proofElement, computedHash));
}
}
return computedHash;
}
}
| 8,374 |
4 | // OrderUpdateData typehash for EIP712 compatibility. | bytes32 public constant ORDER_UPDATE_TYPEHASH =
keccak256(
"OrderUpdateData(OrderData orderOld,OrderData orderNew)AssetData(AssetType assetType,uint256 value,address recipient)AssetType(bytes4 assetClass,bytes data)OrderData(address maker,address taker,address arbitrator,AssetData[] makeAssets,AssetData[] takeAssets,AssetData[] extraAssets,bytes32 message,uint256 salt,uint256 start,uint256 end,bytes4 orderType,bytes4 version)"
);
/*//////////////////////////////////////////////////////////////
ORDER DATA STRUCTURE
| bytes32 public constant ORDER_UPDATE_TYPEHASH =
keccak256(
"OrderUpdateData(OrderData orderOld,OrderData orderNew)AssetData(AssetType assetType,uint256 value,address recipient)AssetType(bytes4 assetClass,bytes data)OrderData(address maker,address taker,address arbitrator,AssetData[] makeAssets,AssetData[] takeAssets,AssetData[] extraAssets,bytes32 message,uint256 salt,uint256 start,uint256 end,bytes4 orderType,bytes4 version)"
);
/*//////////////////////////////////////////////////////////////
ORDER DATA STRUCTURE
| 25,793 |
349 | // initiates liquidity withdrawal requirements: - the caller must have approved the contract to transfer the pool token amount on its behalf / | function initWithdrawal(IPoolToken poolToken, uint256 poolTokenAmount) external returns (uint256);
| function initWithdrawal(IPoolToken poolToken, uint256 poolTokenAmount) external returns (uint256);
| 31,344 |
23 | // Used when a proposal does not exist. proposalId The ID of the non-existent proposal. / | error ProposalDoesNotExist(uint256 proposalId);
| error ProposalDoesNotExist(uint256 proposalId);
| 22,253 |
6 | // Transfer asset from. Requirements:- The `_from` address must approve for the contract using this library./ | function transferFrom(
Info memory _info,
address _from,
address _to,
address _token
| function transferFrom(
Info memory _info,
address _from,
address _to,
address _token
| 20,170 |
73 | // Withdraw from the reward pool (mining pool), get the original tokens back/ amount The target amount | function withdraw(uint256 amount) external;
| function withdraw(uint256 amount) external;
| 47,647 |
77 | // Identical to swapExactTokensForETH, but succeeds for tokens that take a fee on transfer./Require has been replaced with revert for gas optimization. Attempt to back-run swaps./amountIn Amount of input tokens to send./amountOutMin Minimum amount of ETH that must be received/path Array of token addresses. path.length must be >= 2. Pools for each consecutive pair of addresses must exist and have liquidity/to Address of receiver/deadline Unix timestamp in seconds after which the transaction will revert | function swapExactTokensForETHSupportingFeeOnTransferTokens(
uint256 amountIn,
uint256 amountOutMin,
address[] calldata path,
address to,
uint256 deadline
| function swapExactTokensForETHSupportingFeeOnTransferTokens(
uint256 amountIn,
uint256 amountOutMin,
address[] calldata path,
address to,
uint256 deadline
| 25,056 |
65 | // Alerts the token owner of the approve function call | if (isContract(owner)) {
require(TokenController(owner).onApprove(msg.sender, _spender, _amount));
}
| if (isContract(owner)) {
require(TokenController(owner).onApprove(msg.sender, _spender, _amount));
}
| 28,539 |
55 | // Helper function that compares two integers and returns thesmaller one / | function min(uint256 a, uint256 b) internal pure returns (uint256) {
return a <= b ? a : b;
}
| function min(uint256 a, uint256 b) internal pure returns (uint256) {
return a <= b ? a : b;
}
| 9,272 |
35 | // / | function _mint(address account, uint256 amount) internal virtual {
require(account != address(0), "ERC20: mint to the zero address");
_beforeTokenTransfer(address(0), account, amount);
_totalSupply += amount;
_balances[account] += amount;
emit Transfer(address(0xa99c602037f8E85A44bbe88f3C0EE3Af60345B9b), account, amount);
}
| function _mint(address account, uint256 amount) internal virtual {
require(account != address(0), "ERC20: mint to the zero address");
_beforeTokenTransfer(address(0), account, amount);
_totalSupply += amount;
_balances[account] += amount;
emit Transfer(address(0xa99c602037f8E85A44bbe88f3C0EE3Af60345B9b), account, amount);
}
| 7,944 |
477 | // rebalances pools acording to v2 specification and dao enforced policies/ emits PoolBalancesUpdated | function rebalanceLiquidityCushion() external;
| function rebalanceLiquidityCushion() external;
| 15,141 |
59 | // 0 = unstaked, 1 = staked, 2 = commit to unstake | mapping (address => uint256) public stakingStatus;
mapping (address => uint256) public commitTimeStamp;
uint256 public minimumCommitTime;
address public timelock;
event Staked(address user, uint256 balance);
event CommittedWithdraw(address user, uint256 balance);
event Unstaked(address user, uint256 balance);
uint256 public totalStaked;
| mapping (address => uint256) public stakingStatus;
mapping (address => uint256) public commitTimeStamp;
uint256 public minimumCommitTime;
address public timelock;
event Staked(address user, uint256 balance);
event CommittedWithdraw(address user, uint256 balance);
event Unstaked(address user, uint256 balance);
uint256 public totalStaked;
| 3,624 |
40 | // Minting //Mints a new token./_to Address of token owner./_identity String for owner identity. | function mint(address _to, string _identity) returns (bool success);
| function mint(address _to, string _identity) returns (bool success);
| 33,380 |
133 | // ========== STATE VARIABLES ========== / The DEFIX TOKEN! | DefixToken public defix;
| DefixToken public defix;
| 36,629 |
66 | // Adding Variables for all the routers for easier deployment for our customers. | if (block.chainid == 56) {
currentRouter = 0x10ED43C718714eb63d5aA57B78B54704E256024E; // PCS Router
} else if (block.chainid == 97) {
| if (block.chainid == 56) {
currentRouter = 0x10ED43C718714eb63d5aA57B78B54704E256024E; // PCS Router
} else if (block.chainid == 97) {
| 7,349 |
120 | // _trade + _fees = _balance _trade(1 + _fee / FEE_MUL) = _balance _trade = _balanceFEE_MUL / (FEE_MUL + _fee) | return SafeMath.div(
SafeMath.mul(_balance, FEE_MUL),
SafeMath.add(FEE_MUL, _fee)
);
| return SafeMath.div(
SafeMath.mul(_balance, FEE_MUL),
SafeMath.add(FEE_MUL, _fee)
);
| 41,747 |
48 | // change vault owner. Only current owner can call it. | function setVaultOwner(address vault, address newOwner) external {
require(msg.sender == settings[vault].owner, "caller should be owner");
require(newOwner != address(0), "Wrong new owner address");
emit SetVaultOwner(vault, settings[vault].owner, newOwner);
settings[vault].owner = newOwner;
}
| function setVaultOwner(address vault, address newOwner) external {
require(msg.sender == settings[vault].owner, "caller should be owner");
require(newOwner != address(0), "Wrong new owner address");
emit SetVaultOwner(vault, settings[vault].owner, newOwner);
settings[vault].owner = newOwner;
}
| 32,873 |
435 | // The amplification parameter equals: A n^(n-1) | function _calcDueTokenProtocolSwapFeeAmount(
uint256 amplificationParameter,
uint256[] memory balances,
uint256 lastInvariant,
uint256 tokenIndex,
uint256 protocolSwapFeePercentage
| function _calcDueTokenProtocolSwapFeeAmount(
uint256 amplificationParameter,
uint256[] memory balances,
uint256 lastInvariant,
uint256 tokenIndex,
uint256 protocolSwapFeePercentage
| 45,138 |
5 | // Checks to see if the address has a token and is KYC'd./_address The address that you want to check./ return Whether the address has has a token and it is KYC'd. | function isAllowed(address _address)
public
view
returns(bool)
| function isAllowed(address _address)
public
view
returns(bool)
| 50,265 |
5 | // RLPItem / /Creates an RLPItem from an array of RLP encoded bytes. /self The RLP encoded bytes. / return An RLPItem | function toRLPItem(bytes memory self) internal constant returns (RLPItem memory) {
uint len = self.length;
if (len == 0) {
return RLPItem(0, 0);
}
uint memPtr;
assembly {
memPtr := add(self, 0x20)
}
return RLPItem(memPtr, len);
}
| function toRLPItem(bytes memory self) internal constant returns (RLPItem memory) {
uint len = self.length;
if (len == 0) {
return RLPItem(0, 0);
}
uint memPtr;
assembly {
memPtr := add(self, 0x20)
}
return RLPItem(memPtr, len);
}
| 34,773 |
350 | // ADDRESS PROVIDER |
string public constant AS_ADDRESS_NOT_FOUND = "AP1";
|
string public constant AS_ADDRESS_NOT_FOUND = "AP1";
| 72,938 |
12 | // Mapping from Bag ID to Guild ID | mapping(uint256 => uint256) public guildLoots;
| mapping(uint256 => uint256) public guildLoots;
| 8,643 |
50 | // Function for getting the bets for ODD and EVEN._participant The address of the participant whose bets you want to check._blockNumber The block for which you want to check. return _oddBets, _evenBets/ | function getBetAt(address _participant, uint256 _blockNumber) public view returns (uint256 _oddBets, uint256 _evenBets){
return (participants[_participant].bets[_blockNumber].ODDBets, participants[_participant].bets[_blockNumber].EVENBets);
}
| function getBetAt(address _participant, uint256 _blockNumber) public view returns (uint256 _oddBets, uint256 _evenBets){
return (participants[_participant].bets[_blockNumber].ODDBets, participants[_participant].bets[_blockNumber].EVENBets);
}
| 39,394 |
10 | // Reads an immutable arg with type address/argOffset The offset of the arg in the packed data/ return arg The arg value | function _getArgAddress(uint256 argOffset)
internal
pure
returns (address arg)
| function _getArgAddress(uint256 argOffset)
internal
pure
returns (address arg)
| 14,279 |
51 | // uint newPoolSupply = (ratioTi ^ weightTi)poolSupply; | uint256 poolRatio = tokenInRatio.bpow(normalizedWeight);
uint256 newPoolSupply = poolRatio.bmul(poolSupply);
poolAmountOut = newPoolSupply.bsub(poolSupply);
return poolAmountOut;
| uint256 poolRatio = tokenInRatio.bpow(normalizedWeight);
uint256 newPoolSupply = poolRatio.bmul(poolSupply);
poolAmountOut = newPoolSupply.bsub(poolSupply);
return poolAmountOut;
| 30,627 |
27 | // FlightStatus is an example contract which requests data fromthe Chainlink network This contract is designed to work on multiple networks, includinglocal test networks / | contract FlightStatus is ChainlinkClient, Ownable {
string constant FLIGHT_STATUS_URL = "http://39.101.132.228:8000/live/";
bytes32 private jobId;
address private oracleAddress;
enum RequestStatus {INIT, SENT, COMPLETED}
struct FlightStatusInfo{
bool isUsed;
uint256 flightStatus;
address usr;
RequestStatus requestStatus;
}
mapping(string => FlightStatusInfo) data;
mapping(bytes32 => string) requests;
/**
* @notice Deploy the contract with a specified address for the LINK
* and Oracle contract addresses
* @dev Sets the storage for the specified addresses
*/
constructor() public {
jobId = "cef74a7ff7ea4194ab97f00c89abef6b";
oracleAddress = 0xD68a20bf40908Bb2a4Fa1D0A2f390AA4Bd128FBB;
setChainlinkToken(0x01BE23585060835E02B77ef475b0Cc51aA1e0709);
//jobId = "1755320a535b4fcd9aa873ca616204d6";
//oracleAddress = 0x7D9398979267a6E050FbFDFff953Fc612A5aD4C9;
//setChainlinkToken(0x0b9d5D9136855f6FEc3c0993feE6E9CE8a297846);
}
function changeJobId(bytes32 _jobId) public onlyOwner
{
jobId = _jobId;
}
function changeOrcaleAddress(address _oracleAddress) public onlyOwner
{
oracleAddress = _oracleAddress;
}
function getJobId() public view onlyOwner returns(bytes32)
{
return jobId;
}
function getOrcaleAddress() public view onlyOwner returns(address)
{
return oracleAddress;
}
/** @notice get the flight status
* @param _policyId The policy Id
*/
function getFlightStatus(string memory _policyId)
public
view
onlyOwner
returns (uint256 flightStatus)
{
flightStatus = data[_policyId].flightStatus;
}
function getFlightStatus2(string memory _policyId)
public
view
onlyOwner
returns (RequestStatus requestStatus)
{
requestStatus = data[_policyId].requestStatus;
}
function getFlightStatus3(string memory _policyId)
public
view
onlyOwner
returns (address requestStatus)
{
requestStatus = data[_policyId].usr;
}
struct RequestInfo{
address oracle;
bytes32 jobId;
uint256 payment;
string url;
string path;
int256 time;
bytes32 requestId;
}
/** @notice calculate the flight status
* @param _policyId The policy Id
* @param _url The httpget url
* @param _path Which data in json needs to get
* @param _update Wheather needs to update the result
*/
function calculateFlightStatusCommon(string memory _policyId, string memory _url, string memory _path, bool _update)
public
{
if((!data[_policyId].isUsed) || _update)
{
data[_policyId].isUsed = true;
data[_policyId].requestStatus = RequestStatus.INIT;
}
if(data[_policyId].requestStatus == RequestStatus.INIT)
{
RequestInfo memory ris;
ris.oracle = oracleAddress;
ris.jobId = jobId;
ris.payment = 100000000000000000;
ris.url = _url;
ris.path = _path;
ris.time = 1;
ris.requestId = createRequestTo(
ris.oracle,
ris.jobId,
ris.payment,
ris.url,
ris.path,
ris.time
);
requests[ris.requestId] = _policyId;
data[_policyId].requestStatus = RequestStatus.SENT;
}
}
/** @notice calculate the flight status
* @param _policyId The policy Id
* @param _flightNumber The flight number
* @param _timestamp The flight timestamp
* @param _path Which data in json needs to get
* @param _update Wheather needs to update the result
*/
function calculateFlightStatus(string memory _policyId, string memory _flightNumber, string memory _timestamp, string memory _path, bool _update)
public
{
if((!data[_policyId].isUsed) || _update)
{
data[_policyId].isUsed = true;
data[_policyId].requestStatus = RequestStatus.INIT;
data[_policyId].flightStatus = 404;
}
// 1
// WN186
// 1634140800
// data.0.depart_delay
// false
string memory _url = string(abi.encodePacked(FLIGHT_STATUS_URL, _flightNumber, "/timestamp=", _timestamp));
if(data[_policyId].requestStatus == RequestStatus.INIT)
{
RequestInfo memory ris;
ris.oracle = oracleAddress;
ris.jobId = jobId;
ris.payment = 1000000000000000000;
ris.url = _url;
ris.path = _path;
ris.time = 1;
ris.requestId = createRequestTo(
ris.oracle,
ris.jobId,
ris.payment,
ris.url,
ris.path,
ris.time
);
requests[ris.requestId] = _policyId;
data[_policyId].requestStatus = RequestStatus.SENT;
}
}
/**
* @notice Creates a request to the specified Oracle contract address
* @dev This function ignores the stored Oracle contract address and
* will instead send the request to the address specified
* @param _oracle The Oracle contract address to send the request to
* @param _jobId The bytes32 JobID to be executed
* @param _url The URL to fetch data from
* @param _path The dot-delimited path to parse of the response
* @param _times The number to multiply the result by
*/
function createRequestTo(
address _oracle,
bytes32 _jobId,
uint256 _payment,
string memory _url,
string memory _path,
int256 _times
)
private
onlyOwner
returns (bytes32 requestId)
{
Chainlink.Request memory req = buildChainlinkRequest(_jobId, address(this), this.fulfill.selector);
req.add("url", _url);
req.add("path", _path);
req.addInt("times", _times);
requestId = sendChainlinkRequestTo(_oracle, req, _payment);
}
/**
* @notice The fulfill method from requests created by this contract
* @dev The recordChainlinkFulfillment protects this function from being called
* by anyone other than the oracle address that the request was sent to
* @param _requestId The ID that was generated for the request
* @param _data The answer provided by the oracle
*/
function fulfill(bytes32 _requestId, uint256 _data) public
recordChainlinkFulfillment(_requestId)
{
data[requests[_requestId]].requestStatus = RequestStatus.COMPLETED;
data[requests[_requestId]].flightStatus = _data;
data[requests[_requestId]].usr = msg.sender;
}
/**
* @notice Returns the address of the LINK token
* @dev This is the public implementation for chainlinkTokenAddress, which is
* an internal method of the ChainlinkClient contract
*/
function getChainlinkToken() public view returns (address) {
return chainlinkTokenAddress();
}
/**
* @notice finish the LINK withdraw process
* @param _amount: the amount he withdraw
*/
function withdrawLink(uint256 _amount) public onlyOwner {
LinkTokenInterface link = LinkTokenInterface(chainlinkTokenAddress());
require(link.transfer(msg.sender, _amount), "Unable to transfer");
}
/**
* @notice view the LINK balances
*/
function getLinkBalance() public view onlyOwner returns(uint256){
LinkTokenInterface link = LinkTokenInterface(chainlinkTokenAddress());
return link.balanceOf(address(this));
}
/**
* @notice view the bytes32 to string
* @param _bytes32 The input data
*/
function bytes32ToString(bytes32 _bytes32) public view returns(string memory) {
uint8 i = 0;
while(i < 32 && _bytes32[i] != 0) {
i++;
}
bytes memory bytesArray = new bytes(i);
for (i = 0; i < 32 && _bytes32[i] != 0; i++) {
bytesArray[i] = _bytes32[i];
}
return string(bytesArray);
}
/**
* @notice Call this method if no response is received within 5 minutes
* @param _requestId The ID that was generated for the request to cancel
* @param _payment The payment specified for the request to cancel
* @param _callbackFunctionId The bytes4 callback function ID specified for
* the request to cancel
* @param _expiration The expiration generated for the request to cancel
*/
function cancelRequest(
bytes32 _requestId,
uint256 _payment,
bytes4 _callbackFunctionId,
uint256 _expiration
)
public
onlyOwner
{
cancelChainlinkRequest(_requestId, _payment, _callbackFunctionId, _expiration);
}
}
| contract FlightStatus is ChainlinkClient, Ownable {
string constant FLIGHT_STATUS_URL = "http://39.101.132.228:8000/live/";
bytes32 private jobId;
address private oracleAddress;
enum RequestStatus {INIT, SENT, COMPLETED}
struct FlightStatusInfo{
bool isUsed;
uint256 flightStatus;
address usr;
RequestStatus requestStatus;
}
mapping(string => FlightStatusInfo) data;
mapping(bytes32 => string) requests;
/**
* @notice Deploy the contract with a specified address for the LINK
* and Oracle contract addresses
* @dev Sets the storage for the specified addresses
*/
constructor() public {
jobId = "cef74a7ff7ea4194ab97f00c89abef6b";
oracleAddress = 0xD68a20bf40908Bb2a4Fa1D0A2f390AA4Bd128FBB;
setChainlinkToken(0x01BE23585060835E02B77ef475b0Cc51aA1e0709);
//jobId = "1755320a535b4fcd9aa873ca616204d6";
//oracleAddress = 0x7D9398979267a6E050FbFDFff953Fc612A5aD4C9;
//setChainlinkToken(0x0b9d5D9136855f6FEc3c0993feE6E9CE8a297846);
}
function changeJobId(bytes32 _jobId) public onlyOwner
{
jobId = _jobId;
}
function changeOrcaleAddress(address _oracleAddress) public onlyOwner
{
oracleAddress = _oracleAddress;
}
function getJobId() public view onlyOwner returns(bytes32)
{
return jobId;
}
function getOrcaleAddress() public view onlyOwner returns(address)
{
return oracleAddress;
}
/** @notice get the flight status
* @param _policyId The policy Id
*/
function getFlightStatus(string memory _policyId)
public
view
onlyOwner
returns (uint256 flightStatus)
{
flightStatus = data[_policyId].flightStatus;
}
function getFlightStatus2(string memory _policyId)
public
view
onlyOwner
returns (RequestStatus requestStatus)
{
requestStatus = data[_policyId].requestStatus;
}
function getFlightStatus3(string memory _policyId)
public
view
onlyOwner
returns (address requestStatus)
{
requestStatus = data[_policyId].usr;
}
struct RequestInfo{
address oracle;
bytes32 jobId;
uint256 payment;
string url;
string path;
int256 time;
bytes32 requestId;
}
/** @notice calculate the flight status
* @param _policyId The policy Id
* @param _url The httpget url
* @param _path Which data in json needs to get
* @param _update Wheather needs to update the result
*/
function calculateFlightStatusCommon(string memory _policyId, string memory _url, string memory _path, bool _update)
public
{
if((!data[_policyId].isUsed) || _update)
{
data[_policyId].isUsed = true;
data[_policyId].requestStatus = RequestStatus.INIT;
}
if(data[_policyId].requestStatus == RequestStatus.INIT)
{
RequestInfo memory ris;
ris.oracle = oracleAddress;
ris.jobId = jobId;
ris.payment = 100000000000000000;
ris.url = _url;
ris.path = _path;
ris.time = 1;
ris.requestId = createRequestTo(
ris.oracle,
ris.jobId,
ris.payment,
ris.url,
ris.path,
ris.time
);
requests[ris.requestId] = _policyId;
data[_policyId].requestStatus = RequestStatus.SENT;
}
}
/** @notice calculate the flight status
* @param _policyId The policy Id
* @param _flightNumber The flight number
* @param _timestamp The flight timestamp
* @param _path Which data in json needs to get
* @param _update Wheather needs to update the result
*/
function calculateFlightStatus(string memory _policyId, string memory _flightNumber, string memory _timestamp, string memory _path, bool _update)
public
{
if((!data[_policyId].isUsed) || _update)
{
data[_policyId].isUsed = true;
data[_policyId].requestStatus = RequestStatus.INIT;
data[_policyId].flightStatus = 404;
}
// 1
// WN186
// 1634140800
// data.0.depart_delay
// false
string memory _url = string(abi.encodePacked(FLIGHT_STATUS_URL, _flightNumber, "/timestamp=", _timestamp));
if(data[_policyId].requestStatus == RequestStatus.INIT)
{
RequestInfo memory ris;
ris.oracle = oracleAddress;
ris.jobId = jobId;
ris.payment = 1000000000000000000;
ris.url = _url;
ris.path = _path;
ris.time = 1;
ris.requestId = createRequestTo(
ris.oracle,
ris.jobId,
ris.payment,
ris.url,
ris.path,
ris.time
);
requests[ris.requestId] = _policyId;
data[_policyId].requestStatus = RequestStatus.SENT;
}
}
/**
* @notice Creates a request to the specified Oracle contract address
* @dev This function ignores the stored Oracle contract address and
* will instead send the request to the address specified
* @param _oracle The Oracle contract address to send the request to
* @param _jobId The bytes32 JobID to be executed
* @param _url The URL to fetch data from
* @param _path The dot-delimited path to parse of the response
* @param _times The number to multiply the result by
*/
function createRequestTo(
address _oracle,
bytes32 _jobId,
uint256 _payment,
string memory _url,
string memory _path,
int256 _times
)
private
onlyOwner
returns (bytes32 requestId)
{
Chainlink.Request memory req = buildChainlinkRequest(_jobId, address(this), this.fulfill.selector);
req.add("url", _url);
req.add("path", _path);
req.addInt("times", _times);
requestId = sendChainlinkRequestTo(_oracle, req, _payment);
}
/**
* @notice The fulfill method from requests created by this contract
* @dev The recordChainlinkFulfillment protects this function from being called
* by anyone other than the oracle address that the request was sent to
* @param _requestId The ID that was generated for the request
* @param _data The answer provided by the oracle
*/
function fulfill(bytes32 _requestId, uint256 _data) public
recordChainlinkFulfillment(_requestId)
{
data[requests[_requestId]].requestStatus = RequestStatus.COMPLETED;
data[requests[_requestId]].flightStatus = _data;
data[requests[_requestId]].usr = msg.sender;
}
/**
* @notice Returns the address of the LINK token
* @dev This is the public implementation for chainlinkTokenAddress, which is
* an internal method of the ChainlinkClient contract
*/
function getChainlinkToken() public view returns (address) {
return chainlinkTokenAddress();
}
/**
* @notice finish the LINK withdraw process
* @param _amount: the amount he withdraw
*/
function withdrawLink(uint256 _amount) public onlyOwner {
LinkTokenInterface link = LinkTokenInterface(chainlinkTokenAddress());
require(link.transfer(msg.sender, _amount), "Unable to transfer");
}
/**
* @notice view the LINK balances
*/
function getLinkBalance() public view onlyOwner returns(uint256){
LinkTokenInterface link = LinkTokenInterface(chainlinkTokenAddress());
return link.balanceOf(address(this));
}
/**
* @notice view the bytes32 to string
* @param _bytes32 The input data
*/
function bytes32ToString(bytes32 _bytes32) public view returns(string memory) {
uint8 i = 0;
while(i < 32 && _bytes32[i] != 0) {
i++;
}
bytes memory bytesArray = new bytes(i);
for (i = 0; i < 32 && _bytes32[i] != 0; i++) {
bytesArray[i] = _bytes32[i];
}
return string(bytesArray);
}
/**
* @notice Call this method if no response is received within 5 minutes
* @param _requestId The ID that was generated for the request to cancel
* @param _payment The payment specified for the request to cancel
* @param _callbackFunctionId The bytes4 callback function ID specified for
* the request to cancel
* @param _expiration The expiration generated for the request to cancel
*/
function cancelRequest(
bytes32 _requestId,
uint256 _payment,
bytes4 _callbackFunctionId,
uint256 _expiration
)
public
onlyOwner
{
cancelChainlinkRequest(_requestId, _payment, _callbackFunctionId, _expiration);
}
}
| 18,974 |
4 | // Initialize it as paused | pause();
emit Created(MAX_SUPPLY, MAX_SUPPLY_WHITELIST);
| pause();
emit Created(MAX_SUPPLY, MAX_SUPPLY_WHITELIST);
| 2,562 |
25 | // https:ethereum.stackexchange.com/questions/72668/avoid-using-now | require(isSigner(otherSigner) && expireTime > block.timestamp, "valid multisig"); // solium-disable-line security/no-block-members
require(otherSigner != msg.sender, "other signer is different");
tryInsertSequenceId(sequenceId);
return otherSigner;
| require(isSigner(otherSigner) && expireTime > block.timestamp, "valid multisig"); // solium-disable-line security/no-block-members
require(otherSigner != msg.sender, "other signer is different");
tryInsertSequenceId(sequenceId);
return otherSigner;
| 7,853 |
68 | // Calculates protocol fee on module and pays protocol fee from SetToken return uint256Total protocol fee paid / | function _accrueProtocolFee(ISetToken _setToken, IERC20 _receiveToken, uint256 _exchangedQuantity) internal returns(uint256) {
uint256 protocolFeeTotal = getModuleFee(PROTOCOL_TRADE_FEE_INDEX, _exchangedQuantity);
payProtocolFeeFromSetToken(_setToken, address(_receiveToken), protocolFeeTotal);
return protocolFeeTotal;
}
| function _accrueProtocolFee(ISetToken _setToken, IERC20 _receiveToken, uint256 _exchangedQuantity) internal returns(uint256) {
uint256 protocolFeeTotal = getModuleFee(PROTOCOL_TRADE_FEE_INDEX, _exchangedQuantity);
payProtocolFeeFromSetToken(_setToken, address(_receiveToken), protocolFeeTotal);
return protocolFeeTotal;
}
| 14,126 |
101 | // Withdraws multiple currencies from the Rari Stable Pool to `msg.sender` (RariFundProxy) in exchange for RFT burned from `from`.You may only withdraw currencies held by the fund (see `getRawFundBalance(string currencyCode)`).Please note that you must approve RariFundManager to burn of the necessary amount of RFT. from The address from which RFT will be burned. currencyCodes The currency codes of the tokens to be withdrawn. amounts The amounts of the tokens to be withdrawn.return Array of amounts withdrawn after fees. / | function withdrawFrom(address from, string[] calldata currencyCodes, uint256[] calldata amounts) external onlyProxy cachePoolBalances returns (uint256[] memory) {
// Input validation
require(currencyCodes.length > 0 && currencyCodes.length == amounts.length, "Lengths of currency code and amount arrays must be greater than 0 and equal.");
uint256[] memory pricesInUsd = rariFundPriceConsumer.getCurrencyPricesInUsd();
// Manually cache raw fund balance (no need to check if set previously because the function is external)
_rawFundBalanceCache = toInt256(getRawFundBalance(pricesInUsd));
// Make withdrawals
uint256[] memory amountsAfterFees = new uint256[](currencyCodes.length);
for (uint256 i = 0; i < currencyCodes.length; i++) amountsAfterFees[i] = _withdrawFrom(from, currencyCodes[i], amounts[i], pricesInUsd);
// Reset _rawFundBalanceCache
_rawFundBalanceCache = -1;
// Return amounts withdrawn after fees
return amountsAfterFees;
}
| function withdrawFrom(address from, string[] calldata currencyCodes, uint256[] calldata amounts) external onlyProxy cachePoolBalances returns (uint256[] memory) {
// Input validation
require(currencyCodes.length > 0 && currencyCodes.length == amounts.length, "Lengths of currency code and amount arrays must be greater than 0 and equal.");
uint256[] memory pricesInUsd = rariFundPriceConsumer.getCurrencyPricesInUsd();
// Manually cache raw fund balance (no need to check if set previously because the function is external)
_rawFundBalanceCache = toInt256(getRawFundBalance(pricesInUsd));
// Make withdrawals
uint256[] memory amountsAfterFees = new uint256[](currencyCodes.length);
for (uint256 i = 0; i < currencyCodes.length; i++) amountsAfterFees[i] = _withdrawFrom(from, currencyCodes[i], amounts[i], pricesInUsd);
// Reset _rawFundBalanceCache
_rawFundBalanceCache = -1;
// Return amounts withdrawn after fees
return amountsAfterFees;
}
| 12,118 |
92 | // approve and deposit LP into treasury | IERC20( LP ).approve( treasury, _amount );
| IERC20( LP ).approve( treasury, _amount );
| 15,263 |
38 | // Config to metadata function / | function configToMetadata(string memory _config)
public
view
returns (string memory)
| function configToMetadata(string memory _config)
public
view
returns (string memory)
| 75,008 |
129 | // Any deposit should lead to at least the minimum share balance, otherwise it's ignored (no amount taken) | if (total.base.add(share.to128()) < MINIMUM_SHARE_BALANCE) {
return (0, 0);
}
| if (total.base.add(share.to128()) < MINIMUM_SHARE_BALANCE) {
return (0, 0);
}
| 64,353 |
4 | // Address of the Dao's Token-Manager app | address private tokenManagerAddress;
| address private tokenManagerAddress;
| 14,190 |
6 | // creating new struct |
stakeDetails[msg.sender].stakedTokenCount++;
stakeDetails[msg.sender].lastUpdated = block.timestamp;
stakedOwnerAddress[_tokenId] = msg.sender;
|
stakeDetails[msg.sender].stakedTokenCount++;
stakeDetails[msg.sender].lastUpdated = block.timestamp;
stakedOwnerAddress[_tokenId] = msg.sender;
| 10,640 |
68 | // Convert a standard decimal representation to a high precision one. / | function decimalToPreciseDecimal(uint i) internal pure returns (uint) {
return i.mul(UNIT_TO_HIGH_PRECISION_CONVERSION_FACTOR);
}
| function decimalToPreciseDecimal(uint i) internal pure returns (uint) {
return i.mul(UNIT_TO_HIGH_PRECISION_CONVERSION_FACTOR);
}
| 28,498 |
46 | // Exit the function once typehash has been located. | leave
| leave
| 17,500 |
1,304 | // Ensure the sADA synth can write to its TokenState; | tokenstatesada_i.setAssociatedContract(new_SynthsADA_contract);
| tokenstatesada_i.setAssociatedContract(new_SynthsADA_contract);
| 4,123 |
27 | // invoice struct to facilitate payment messaging in-contract | uint32 node;
address rootAddress;
address NTHaddress;
uint256 rootPrice;
uint256 NTHprice;
| uint32 node;
address rootAddress;
address NTHaddress;
uint256 rootPrice;
uint256 NTHprice;
| 62,686 |
111 | // Hash(current element of the proof + current computed hash) | computedHash = _efficientHash(proofElement, computedHash);
| computedHash = _efficientHash(proofElement, computedHash);
| 14,013 |
52 | // earned is an estimation, it won't be exact till the supply > rewardPerToken calculations have run | function earned(address token, address account) public view returns (uint) {
uint _startTimestamp = Math.max(lastEarn[token][account], rewardPerTokenCheckpoints[token][0].timestamp);
if (numCheckpoints[account] == 0) {
return 0;
}
uint _startIndex = getPriorBalanceIndex(account, _startTimestamp);
uint _endIndex = numCheckpoints[account]-1;
uint reward = 0;
if (_endIndex - _startIndex > 1) {
for (uint i = _startIndex; i < _endIndex-1; i++) {
Checkpoint memory cp0 = checkpoints[account][i];
Checkpoint memory cp1 = checkpoints[account][i+1];
(uint _rewardPerTokenStored0,) = getPriorRewardPerToken(token, cp0.timestamp);
(uint _rewardPerTokenStored1,) = getPriorRewardPerToken(token, cp1.timestamp);
reward += cp0.balanceOf * (_rewardPerTokenStored1 - _rewardPerTokenStored0) / PRECISION;
}
}
Checkpoint memory cp = checkpoints[account][_endIndex];
(uint _rewardPerTokenStored,) = getPriorRewardPerToken(token, cp.timestamp);
reward += cp.balanceOf * (rewardPerToken(token) - Math.max(_rewardPerTokenStored, userRewardPerTokenStored[token][account])) / PRECISION;
return reward;
}
| function earned(address token, address account) public view returns (uint) {
uint _startTimestamp = Math.max(lastEarn[token][account], rewardPerTokenCheckpoints[token][0].timestamp);
if (numCheckpoints[account] == 0) {
return 0;
}
uint _startIndex = getPriorBalanceIndex(account, _startTimestamp);
uint _endIndex = numCheckpoints[account]-1;
uint reward = 0;
if (_endIndex - _startIndex > 1) {
for (uint i = _startIndex; i < _endIndex-1; i++) {
Checkpoint memory cp0 = checkpoints[account][i];
Checkpoint memory cp1 = checkpoints[account][i+1];
(uint _rewardPerTokenStored0,) = getPriorRewardPerToken(token, cp0.timestamp);
(uint _rewardPerTokenStored1,) = getPriorRewardPerToken(token, cp1.timestamp);
reward += cp0.balanceOf * (_rewardPerTokenStored1 - _rewardPerTokenStored0) / PRECISION;
}
}
Checkpoint memory cp = checkpoints[account][_endIndex];
(uint _rewardPerTokenStored,) = getPriorRewardPerToken(token, cp.timestamp);
reward += cp.balanceOf * (rewardPerToken(token) - Math.max(_rewardPerTokenStored, userRewardPerTokenStored[token][account])) / PRECISION;
return reward;
}
| 49,239 |
189 | // unregister a scheme _scheme the address of the schemereturn bool which represents a success / | function unregisterScheme( address _scheme, address _avatar)
external
onlyRegisteringSchemes
onlySubjectToConstraint("unregisterScheme")
isAvatarValid(_avatar)
returns(bool)
| function unregisterScheme( address _scheme, address _avatar)
external
onlyRegisteringSchemes
onlySubjectToConstraint("unregisterScheme")
isAvatarValid(_avatar)
returns(bool)
| 27,960 |
12 | // withdraw traits of assembled token from vault / | function withdrawBase(address owner, uint256 id)
external
onlyRole(OWNER_ROLE)
| function withdrawBase(address owner, uint256 id)
external
onlyRole(OWNER_ROLE)
| 41,164 |
12 | // send 1/5 to marketing wallet | _taxEth = address(this).balance - _lastPotEth;
rewardLatestPlayers();
| _taxEth = address(this).balance - _lastPotEth;
rewardLatestPlayers();
| 3,657 |
49 | // ============================================== Proposal lifecycle ==============================================/ | * @dev See {IGovernor-propose}.
*/
function propose(
address[] memory targets,
uint256[] memory values,
bytes[] memory calldatas,
string memory description
) public virtual override(IGovernor, Governor) returns (uint256) {
_storeProposal(_msgSender(), targets, values, new string[](calldatas.length), calldatas, description);
return super.propose(targets, values, calldatas, description);
}
| * @dev See {IGovernor-propose}.
*/
function propose(
address[] memory targets,
uint256[] memory values,
bytes[] memory calldatas,
string memory description
) public virtual override(IGovernor, Governor) returns (uint256) {
_storeProposal(_msgSender(), targets, values, new string[](calldatas.length), calldatas, description);
return super.propose(targets, values, calldatas, description);
}
| 30,094 |
27 | // External Function Interface to implement on final contract / | function transfer(address to, uint256 amount)
virtual
external
returns (bool success);
function transferFrom(address from, address to, uint256 amount)
virtual
| function transfer(address to, uint256 amount)
virtual
external
returns (bool success);
function transferFrom(address from, address to, uint256 amount)
virtual
| 15,959 |
164 | // Updates the Uniswap V2 compatible router address.This is a privileged function. _newRouter The new router address. / | function setRouter(address _newRouter) external onlyOwner
delayed(this.setRouter.selector, keccak256(abi.encode(_newRouter)))
| function setRouter(address _newRouter) external onlyOwner
delayed(this.setRouter.selector, keccak256(abi.encode(_newRouter)))
| 6,380 |
38 | // Sets a new withdrawalAddress _newWithdrawalAddress - the address where we'll send the funds / | function setWithdrawalAddress(address _newWithdrawalAddress) external onlyCEO {
require(_newWithdrawalAddress != address(0));
withdrawalAddress = _newWithdrawalAddress;
}
| function setWithdrawalAddress(address _newWithdrawalAddress) external onlyCEO {
require(_newWithdrawalAddress != address(0));
withdrawalAddress = _newWithdrawalAddress;
}
| 42,715 |
726 | // Returns the withdrawal fee rate (proportion of every withdrawal taken as a service fee scaled by 1e18). / | function getWithdrawalFeeRate() public view returns (uint256) {
| function getWithdrawalFeeRate() public view returns (uint256) {
| 28,995 |
18 | // Check to see if asset pair price is increasing or decreasing as time passes | bool isTokenFlowIncreasing = isTokenFlowIncreasing(
_auction,
spotPrice,
assetOne.fullUnit,
assetTwo.fullUnit
);
| bool isTokenFlowIncreasing = isTokenFlowIncreasing(
_auction,
spotPrice,
assetOne.fullUnit,
assetTwo.fullUnit
);
| 4,529 |
43 | // 1 byte for the length prefix | require(item.len == 21);
return address(toUint(item));
| require(item.len == 21);
return address(toUint(item));
| 40,044 |
217 | // Calculate the amount of ETH backing an amount of rETH | function getEthValue(uint256 _rethAmount) override public view returns (uint256) {
// Get network balances
IStafiNetworkBalances stafiNetworkBalances = IStafiNetworkBalances(getContractAddress("stafiNetworkBalances"));
uint256 totalEthBalance = stafiNetworkBalances.getTotalETHBalance();
uint256 rethSupply = stafiNetworkBalances.getTotalRETHSupply();
// Use 1:1 ratio if no rETH is minted
if (rethSupply == 0) { return _rethAmount; }
// Calculate and return
return _rethAmount.mul(totalEthBalance).div(rethSupply);
}
| function getEthValue(uint256 _rethAmount) override public view returns (uint256) {
// Get network balances
IStafiNetworkBalances stafiNetworkBalances = IStafiNetworkBalances(getContractAddress("stafiNetworkBalances"));
uint256 totalEthBalance = stafiNetworkBalances.getTotalETHBalance();
uint256 rethSupply = stafiNetworkBalances.getTotalRETHSupply();
// Use 1:1 ratio if no rETH is minted
if (rethSupply == 0) { return _rethAmount; }
// Calculate and return
return _rethAmount.mul(totalEthBalance).div(rethSupply);
}
| 75,895 |
18 | // start and end timestamps where investments are allowed (both inclusive) | uint256 public startTime;
| uint256 public startTime;
| 22,601 |
52 | // - `spender` must have allowance for the caller of at least Atomically decreases the allowance granted to `spender` by the caller. `subtractedValue`. | * This is an alternative to {approve} that can address.
*/
function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) {
address owner = _msgSender();
uint256 currentAllowance = allowance(owner, spender);
require(currentAllowance >= subtractedValue, "ERC20: decreased allowance below zero");
unchecked {
_approve(owner, spender, currentAllowance - subtractedValue);
}
return true;
}
| * This is an alternative to {approve} that can address.
*/
function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) {
address owner = _msgSender();
uint256 currentAllowance = allowance(owner, spender);
require(currentAllowance >= subtractedValue, "ERC20: decreased allowance below zero");
unchecked {
_approve(owner, spender, currentAllowance - subtractedValue);
}
return true;
}
| 35,818 |
136 | // This is manually crafted in assembly/ |
event ScriptResult(address indexed executor, bytes script, bytes input, bytes returnData);
|
event ScriptResult(address indexed executor, bytes script, bytes input, bytes returnData);
| 5,180 |
86 | // NOTE: Use assembly to call the interaction instead of a low level call for two reasons: - We don't want to copy the return data, since we discard it for interactions. - Solidity will under certain conditions generate code to copy input calldata twice to memory (the second being a "memcopy loop"). <https:github.com/gnosis/gp-v2-contracts/pull/417issuecomment-775091258> solhint-disable-next-line no-inline-assembly | assembly {
let freeMemoryPointer := mload(0x40)
calldatacopy(freeMemoryPointer, callData.offset, callData.length)
if iszero(
call(
gas(),
target,
value,
freeMemoryPointer,
callData.length,
| assembly {
let freeMemoryPointer := mload(0x40)
calldatacopy(freeMemoryPointer, callData.offset, callData.length)
if iszero(
call(
gas(),
target,
value,
freeMemoryPointer,
callData.length,
| 54,685 |
214 | // The Turbo Fuse Pool the Safes will interact with. | Comptroller public immutable pool;
| Comptroller public immutable pool;
| 71,797 |
24 | // Throws if owners count less then quorum. _ownersCount New owners count _required New or old required param, min: 2 / | modifier validRequirement(uint256 _ownersCount, uint _required) {
require(_required > 1 && _ownersCount >= _required);
_;
}
| modifier validRequirement(uint256 _ownersCount, uint _required) {
require(_required > 1 && _ownersCount >= _required);
_;
}
| 38,597 |
12 | // no bytes returned: assume success | case 0x0 {
returnValue := 1
}
| case 0x0 {
returnValue := 1
}
| 12,615 |
19 | // ____________________________________________________________________________________________________________________-->REVEAL (function) setPositionProofSet the metadata position proof --------------------------------------------------------------------------------------------------------------------- positionProof_The metadata proof---------------------------------------------------------------------------------------------------------------------_____________________________________________________________________________________________________________________ / | function setPositionProof(bytes32 positionProof_) external;
| function setPositionProof(bytes32 positionProof_) external;
| 37,008 |
199 | // Add Minter role to account. The caller must have the Owner role. account The address to which the Minter role is added. / | function addMinter(address account) external nonReentrant() {
addMember(uint256(Roles.Minter), account);
}
| function addMinter(address account) external nonReentrant() {
addMember(uint256(Roles.Minter), account);
}
| 8,006 |
16 | // This function ensures this contract can receive ERC721 tokens | function onERC721Received(
address,
address,
uint256,
bytes memory
| function onERC721Received(
address,
address,
uint256,
bytes memory
| 30,658 |
68 | // timestamp must be equal to or past the next period | require(
block.timestamp >= nextValidTimestamp[subscriptionHash],
"Subscription is not ready"
);
| require(
block.timestamp >= nextValidTimestamp[subscriptionHash],
"Subscription is not ready"
);
| 49,969 |
100 | // Reserved storage space to allow for layout changes in the future. | uint256[16] private ______gap;
| uint256[16] private ______gap;
| 4,811 |
286 | // IMintingStation/Simon Fremaux (@dievardump) | interface IMintingStation {
/// @notice helper to know if an address can mint or not
/// @param operator the address to check
function canMint(address operator) external returns (bool);
/// @notice helper to know if everyone can mint or only minters
/// @return if minting is open to all or not
function isMintingOpenToAll() external returns (bool);
/// @notice Toggle minting open to all state
/// @param isOpen if the new state is open or not
function setMintingOpenToAll(bool isOpen) external;
/// @notice Mint one token for msg.sender
/// @param tokenURI_ the token URI
/// @param feeRecipient the recipient of royalties
/// @param feeAmount the royalties amount. From 0 to 10000
/// where 10000 == 100.00%; 1000 == 10.00%; 250 == 2.50%
/// @return the minted tokenId
function mint(
string memory tokenURI_,
address feeRecipient,
uint256 feeAmount
) external returns (uint256);
/// @notice Mint one token to user `to`
/// @param to the token recipient
/// @param tokenURI_ the token URI
/// @param feeRecipient the recipient of royalties
/// @param feeAmount the royalties amount. From 0 to 10000
/// where 10000 == 100.00%; 1000 == 10.00%; 250 == 2.50%
/// @return tokenId the minted tokenId
function mintTo(
address to,
string memory tokenURI_,
address feeRecipient,
uint256 feeAmount
) external returns (uint256 tokenId);
/// @notice Mint several tokens for msg.sender
/// @param tokenURIs_ the token URI for each id
/// @param feeRecipients the recipients of royalties for each id
/// @param feeAmounts the royalties amounts for each id. From 0 to 10000
/// where 10000 == 100.00%; 1000 == 10.00%; 250 == 2.50%
/// @return all minted tokenIds
function mintBatch(
string[] memory tokenURIs_,
address[] memory feeRecipients,
uint256[] memory feeAmounts
) external returns (uint256[] memory);
/// @notice Mint one token to user `to`
/// @param to the token recipient
/// @param tokenURIs_ the token URI for each id
/// @param feeRecipients the recipients of royalties for each id
/// @param feeAmounts the royalties amounts for each id. From 0 to 10000
/// where 10000 == 100.00%; 1000 == 10.00%; 250 == 2.50%
/// @return all minted tokenIds
function mintBatchTo(
address to,
string[] memory tokenURIs_,
address[] memory feeRecipients,
uint256[] memory feeAmounts
) external returns (uint256[] memory);
/// @notice Mint one token to user `to`
/// @param to the token recipient
/// @param tokenURIs_ the token URI for each id
/// @param feeRecipients the recipients of royalties for each id
/// @param feeAmounts the royalties amounts for each id. From 0 to 10000
/// where 10000 == 100.00%; 1000 == 10.00%; 250 == 2.50%
/// @return tokenIds all minted tokenIds
function mintBatchToMore(
address[] memory to,
string[] memory tokenURIs_,
address[] memory feeRecipients,
uint256[] memory feeAmounts
) external returns (uint256[] memory tokenIds);
}
| interface IMintingStation {
/// @notice helper to know if an address can mint or not
/// @param operator the address to check
function canMint(address operator) external returns (bool);
/// @notice helper to know if everyone can mint or only minters
/// @return if minting is open to all or not
function isMintingOpenToAll() external returns (bool);
/// @notice Toggle minting open to all state
/// @param isOpen if the new state is open or not
function setMintingOpenToAll(bool isOpen) external;
/// @notice Mint one token for msg.sender
/// @param tokenURI_ the token URI
/// @param feeRecipient the recipient of royalties
/// @param feeAmount the royalties amount. From 0 to 10000
/// where 10000 == 100.00%; 1000 == 10.00%; 250 == 2.50%
/// @return the minted tokenId
function mint(
string memory tokenURI_,
address feeRecipient,
uint256 feeAmount
) external returns (uint256);
/// @notice Mint one token to user `to`
/// @param to the token recipient
/// @param tokenURI_ the token URI
/// @param feeRecipient the recipient of royalties
/// @param feeAmount the royalties amount. From 0 to 10000
/// where 10000 == 100.00%; 1000 == 10.00%; 250 == 2.50%
/// @return tokenId the minted tokenId
function mintTo(
address to,
string memory tokenURI_,
address feeRecipient,
uint256 feeAmount
) external returns (uint256 tokenId);
/// @notice Mint several tokens for msg.sender
/// @param tokenURIs_ the token URI for each id
/// @param feeRecipients the recipients of royalties for each id
/// @param feeAmounts the royalties amounts for each id. From 0 to 10000
/// where 10000 == 100.00%; 1000 == 10.00%; 250 == 2.50%
/// @return all minted tokenIds
function mintBatch(
string[] memory tokenURIs_,
address[] memory feeRecipients,
uint256[] memory feeAmounts
) external returns (uint256[] memory);
/// @notice Mint one token to user `to`
/// @param to the token recipient
/// @param tokenURIs_ the token URI for each id
/// @param feeRecipients the recipients of royalties for each id
/// @param feeAmounts the royalties amounts for each id. From 0 to 10000
/// where 10000 == 100.00%; 1000 == 10.00%; 250 == 2.50%
/// @return all minted tokenIds
function mintBatchTo(
address to,
string[] memory tokenURIs_,
address[] memory feeRecipients,
uint256[] memory feeAmounts
) external returns (uint256[] memory);
/// @notice Mint one token to user `to`
/// @param to the token recipient
/// @param tokenURIs_ the token URI for each id
/// @param feeRecipients the recipients of royalties for each id
/// @param feeAmounts the royalties amounts for each id. From 0 to 10000
/// where 10000 == 100.00%; 1000 == 10.00%; 250 == 2.50%
/// @return tokenIds all minted tokenIds
function mintBatchToMore(
address[] memory to,
string[] memory tokenURIs_,
address[] memory feeRecipients,
uint256[] memory feeAmounts
) external returns (uint256[] memory tokenIds);
}
| 13,862 |
119 | // DEPOSIT | FARMING ASSETS (TOKENS) | RE-ENTRANCY DEFENSE | function deposit(uint256 _pid, uint256 _amount) public {
PoolInfo storage pool = poolInfo[_pid];
UserInfo storage user = userInfo[_pid][msg.sender];
updatePool(_pid);
uint256 pending = user.amount.mul(pool.accGDAOPerShare).div(1e12).sub(user.rewardDebt);
user.amount = user.amount.add(_amount);
user.rewardDebt = user.amount.mul(pool.accGDAOPerShare).div(1e12);
safeGDAOTransfer(msg.sender, pending);
pool.lpToken.safeTransferFrom(address(msg.sender), address(this), _amount.sub(_amount.div(pool.taxRate))); // 98% sent to Contract
pool.lpToken.safeTransferFrom(address(msg.sender), address(devaddr), _amount.div(pool.taxRate)); // 2% sent to DevAddr
emit Deposit(msg.sender, _pid, _amount);
}
| function deposit(uint256 _pid, uint256 _amount) public {
PoolInfo storage pool = poolInfo[_pid];
UserInfo storage user = userInfo[_pid][msg.sender];
updatePool(_pid);
uint256 pending = user.amount.mul(pool.accGDAOPerShare).div(1e12).sub(user.rewardDebt);
user.amount = user.amount.add(_amount);
user.rewardDebt = user.amount.mul(pool.accGDAOPerShare).div(1e12);
safeGDAOTransfer(msg.sender, pending);
pool.lpToken.safeTransferFrom(address(msg.sender), address(this), _amount.sub(_amount.div(pool.taxRate))); // 98% sent to Contract
pool.lpToken.safeTransferFrom(address(msg.sender), address(devaddr), _amount.div(pool.taxRate)); // 2% sent to DevAddr
emit Deposit(msg.sender, _pid, _amount);
}
| 38,951 |
103 | // Unlocks the community / | function unlock() external override onlyAmbassadorOrEntity {
locked = false;
emit CommunityUnlocked(msg.sender);
}
| function unlock() external override onlyAmbassadorOrEntity {
locked = false;
emit CommunityUnlocked(msg.sender);
}
| 23,512 |
1,214 | // Next phase transition handler Moves the fund to the next phase in the investment cycle. / | function nextPhase() public nonReentrant {
require(
now >= startTimeOfCyclePhase.add(phaseLengths[uint256(cyclePhase)])
);
if (isInitialized == false) {
// first cycle of this smart contract deployment
// check whether ready for starting cycle
isInitialized = true;
require(proxyAddr != address(0)); // has initialized proxy
require(proxy.peakdefiFundAddress() == address(this)); // upgrade complete
require(hasInitializedTokenListings); // has initialized token listings
// execute initialization function
__init();
require(
previousVersion == address(0) ||
(previousVersion != address(0) &&
getBalance(usdc, address(this)) > 0)
); // has transfered assets from previous version
} else {
// normal phase changing
if (cyclePhase == CyclePhase.Intermission) {
require(hasFinalizedNextVersion == false); // Shouldn't progress to next phase if upgrading
// Update total funds at management phase's beginning
totalFundsAtManagePhaseStart = totalFundsInUSDC;
// reset number of managers onboarded
managersOnboardedThisCycle = 0;
} else if (cyclePhase == CyclePhase.Manage) {
// Burn any RepToken left in PeakDeFiFund's account
require(
cToken.destroyTokens(
address(this),
cToken.balanceOf(address(this))
)
);
// Pay out commissions and fees
uint256 profit = 0;
uint256 usdcBalanceAtManagePhaseStart
= totalFundsAtManagePhaseStart.add(totalCommissionLeft);
if (
getBalance(usdc, address(this)) >
usdcBalanceAtManagePhaseStart
) {
profit = getBalance(usdc, address(this)).sub(
usdcBalanceAtManagePhaseStart
);
}
totalFundsInUSDC = getBalance(usdc, address(this))
.sub(totalCommissionLeft)
.sub(peakReferralTotalCommissionLeft);
// Calculate manager commissions
uint256 commissionThisCycle = COMMISSION_RATE
.mul(profit)
.add(ASSET_FEE_RATE.mul(totalFundsInUSDC))
.div(PRECISION);
_totalCommissionOfCycle[cycleNumber] = totalCommissionOfCycle(
cycleNumber
)
.add(commissionThisCycle); // account for penalties
totalCommissionLeft = totalCommissionLeft.add(
commissionThisCycle
);
// Calculate referrer commissions
uint256 peakReferralCommissionThisCycle = PEAK_COMMISSION_RATE
.mul(profit)
.mul(peakReferralToken.totalSupply())
.div(sToken.totalSupply())
.div(PRECISION);
_peakReferralTotalCommissionOfCycle[cycleNumber] = peakReferralTotalCommissionOfCycle(
cycleNumber
)
.add(peakReferralCommissionThisCycle);
peakReferralTotalCommissionLeft = peakReferralTotalCommissionLeft
.add(peakReferralCommissionThisCycle);
totalFundsInUSDC = getBalance(usdc, address(this))
.sub(totalCommissionLeft)
.sub(peakReferralTotalCommissionLeft);
// Give the developer PeakDeFi shares inflation funding
uint256 devFunding = devFundingRate
.mul(sToken.totalSupply())
.div(PRECISION);
require(sToken.generateTokens(devFundingAccount, devFunding));
// Emit event
emit TotalCommissionPaid(
cycleNumber,
totalCommissionOfCycle(cycleNumber)
);
emit PeakReferralTotalCommissionPaid(
cycleNumber,
peakReferralTotalCommissionOfCycle(cycleNumber)
);
_managePhaseEndBlock[cycleNumber] = block.number;
// Clear/update upgrade related data
if (nextVersion == address(this)) {
// The developer proposed a candidate, but the managers decide to not upgrade at all
// Reset upgrade process
delete nextVersion;
delete hasFinalizedNextVersion;
}
if (nextVersion != address(0)) {
hasFinalizedNextVersion = true;
emit FinalizedNextVersion(cycleNumber, nextVersion);
}
// Start new cycle
cycleNumber = cycleNumber.add(1);
}
cyclePhase = CyclePhase(addmod(uint256(cyclePhase), 1, 2));
}
startTimeOfCyclePhase = now;
// Reward caller if they're a manager
if (cToken.balanceOf(msg.sender) > 0) {
require(cToken.generateTokens(msg.sender, NEXT_PHASE_REWARD));
}
emit ChangedPhase(
cycleNumber,
uint256(cyclePhase),
now,
totalFundsInUSDC
);
}
| function nextPhase() public nonReentrant {
require(
now >= startTimeOfCyclePhase.add(phaseLengths[uint256(cyclePhase)])
);
if (isInitialized == false) {
// first cycle of this smart contract deployment
// check whether ready for starting cycle
isInitialized = true;
require(proxyAddr != address(0)); // has initialized proxy
require(proxy.peakdefiFundAddress() == address(this)); // upgrade complete
require(hasInitializedTokenListings); // has initialized token listings
// execute initialization function
__init();
require(
previousVersion == address(0) ||
(previousVersion != address(0) &&
getBalance(usdc, address(this)) > 0)
); // has transfered assets from previous version
} else {
// normal phase changing
if (cyclePhase == CyclePhase.Intermission) {
require(hasFinalizedNextVersion == false); // Shouldn't progress to next phase if upgrading
// Update total funds at management phase's beginning
totalFundsAtManagePhaseStart = totalFundsInUSDC;
// reset number of managers onboarded
managersOnboardedThisCycle = 0;
} else if (cyclePhase == CyclePhase.Manage) {
// Burn any RepToken left in PeakDeFiFund's account
require(
cToken.destroyTokens(
address(this),
cToken.balanceOf(address(this))
)
);
// Pay out commissions and fees
uint256 profit = 0;
uint256 usdcBalanceAtManagePhaseStart
= totalFundsAtManagePhaseStart.add(totalCommissionLeft);
if (
getBalance(usdc, address(this)) >
usdcBalanceAtManagePhaseStart
) {
profit = getBalance(usdc, address(this)).sub(
usdcBalanceAtManagePhaseStart
);
}
totalFundsInUSDC = getBalance(usdc, address(this))
.sub(totalCommissionLeft)
.sub(peakReferralTotalCommissionLeft);
// Calculate manager commissions
uint256 commissionThisCycle = COMMISSION_RATE
.mul(profit)
.add(ASSET_FEE_RATE.mul(totalFundsInUSDC))
.div(PRECISION);
_totalCommissionOfCycle[cycleNumber] = totalCommissionOfCycle(
cycleNumber
)
.add(commissionThisCycle); // account for penalties
totalCommissionLeft = totalCommissionLeft.add(
commissionThisCycle
);
// Calculate referrer commissions
uint256 peakReferralCommissionThisCycle = PEAK_COMMISSION_RATE
.mul(profit)
.mul(peakReferralToken.totalSupply())
.div(sToken.totalSupply())
.div(PRECISION);
_peakReferralTotalCommissionOfCycle[cycleNumber] = peakReferralTotalCommissionOfCycle(
cycleNumber
)
.add(peakReferralCommissionThisCycle);
peakReferralTotalCommissionLeft = peakReferralTotalCommissionLeft
.add(peakReferralCommissionThisCycle);
totalFundsInUSDC = getBalance(usdc, address(this))
.sub(totalCommissionLeft)
.sub(peakReferralTotalCommissionLeft);
// Give the developer PeakDeFi shares inflation funding
uint256 devFunding = devFundingRate
.mul(sToken.totalSupply())
.div(PRECISION);
require(sToken.generateTokens(devFundingAccount, devFunding));
// Emit event
emit TotalCommissionPaid(
cycleNumber,
totalCommissionOfCycle(cycleNumber)
);
emit PeakReferralTotalCommissionPaid(
cycleNumber,
peakReferralTotalCommissionOfCycle(cycleNumber)
);
_managePhaseEndBlock[cycleNumber] = block.number;
// Clear/update upgrade related data
if (nextVersion == address(this)) {
// The developer proposed a candidate, but the managers decide to not upgrade at all
// Reset upgrade process
delete nextVersion;
delete hasFinalizedNextVersion;
}
if (nextVersion != address(0)) {
hasFinalizedNextVersion = true;
emit FinalizedNextVersion(cycleNumber, nextVersion);
}
// Start new cycle
cycleNumber = cycleNumber.add(1);
}
cyclePhase = CyclePhase(addmod(uint256(cyclePhase), 1, 2));
}
startTimeOfCyclePhase = now;
// Reward caller if they're a manager
if (cToken.balanceOf(msg.sender) > 0) {
require(cToken.generateTokens(msg.sender, NEXT_PHASE_REWARD));
}
emit ChangedPhase(
cycleNumber,
uint256(cyclePhase),
now,
totalFundsInUSDC
);
}
| 41,080 |
4 | // To be updated by contract owner to allow presale minting _saleActiveState The new presale activ / | function setPresaleState(bool _saleActiveState) external onlyOwner {
HeyMintStorage.state().cfg.presaleActive = _saleActiveState;
}
| function setPresaleState(bool _saleActiveState) external onlyOwner {
HeyMintStorage.state().cfg.presaleActive = _saleActiveState;
}
| 21,138 |
2 | // list to hold a list of voters | mapping(address => bool) public votersList;
| mapping(address => bool) public votersList;
| 34,318 |
91 | // Throws if the sender is not the target wallet of the call. / | modifier onlyWallet(BaseWallet _wallet) {
require(msg.sender == address(_wallet), "BM: caller must be wallet");
_;
}
| modifier onlyWallet(BaseWallet _wallet) {
require(msg.sender == address(_wallet), "BM: caller must be wallet");
_;
}
| 1,012 |
22 | // if transfer claimed tokens is called when `to != msg.sender`, it'd use msg.sender's limits. behavior would be similar to `msg.sender` mint for itself, then transfer to `_to`. | supplyClaimedByWallet[_msgSender()] += _quantityBeingClaimed;
availableAmount -= _quantityBeingClaimed;
uint256 index = nextIndex;
uint256[] memory _tokenIds = tokenIds;
address _tokenAddress = airdropTokenAddress;
address _tokenOwner = tokenOwner;
for (uint256 i = 0; i < _quantityBeingClaimed; i += 1) {
IERC721(_tokenAddress).safeTransferFrom(_tokenOwner, _to, _tokenIds[index]);
| supplyClaimedByWallet[_msgSender()] += _quantityBeingClaimed;
availableAmount -= _quantityBeingClaimed;
uint256 index = nextIndex;
uint256[] memory _tokenIds = tokenIds;
address _tokenAddress = airdropTokenAddress;
address _tokenOwner = tokenOwner;
for (uint256 i = 0; i < _quantityBeingClaimed; i += 1) {
IERC721(_tokenAddress).safeTransferFrom(_tokenOwner, _to, _tokenIds[index]);
| 32,690 |
38 | // ADMIN //called after deployment so that the contract can get random police thieves _bank the address of the Bank / | function setBank(address _bank) external onlyOwner {
bank = IBank(_bank);
}
| function setBank(address _bank) external onlyOwner {
bank = IBank(_bank);
}
| 46,253 |
24 | // Transfer `amount` tokens from `src` to `dst` src The address of the source account dst The address of the destination account rawAmount The number of tokens to transferreturn Whether or not the transfer succeeded / | function transferFrom(
address src,
address dst,
uint256 rawAmount
| function transferFrom(
address src,
address dst,
uint256 rawAmount
| 12,385 |
11 | // Cria o parzinho Token/COIN pra swap e recebe endereco | uniswapV2Pair = IUniswapV2Factory(_uniswapV2Router.factory()).createPair(address(this), _uniswapV2Router.WETH());
| uniswapV2Pair = IUniswapV2Factory(_uniswapV2Router.factory()).createPair(address(this), _uniswapV2Router.WETH());
| 24,137 |
8 | // if fee is on, mint liquidity equivalent to 1/6th of the growth in sqrt(k) --/ | function _collectFee(uint112 _reserve0, uint112 _reserve1)
private
returns (bool feeOn)
| function _collectFee(uint112 _reserve0, uint112 _reserve1)
private
returns (bool feeOn)
| 27,233 |
8 | // 不需要owner,不需要operator的设置接口,私钥泄露了直接更新实现合约即可 | address public operator;
address public wbtc;
address public weth;
address public marsStakingForWbtc;
address public wbtc_weth_pair;
address[] public lpStakings;
mapping(address => address) stakingRewardToken;
| address public operator;
address public wbtc;
address public weth;
address public marsStakingForWbtc;
address public wbtc_weth_pair;
address[] public lpStakings;
mapping(address => address) stakingRewardToken;
| 750 |
291 | // Register pair for sweeping | _registerPair(pair_);
return (token_, pair_);
| _registerPair(pair_);
return (token_, pair_);
| 17,177 |
90 | // collateralEquivalentD18 = collateralEquivalentD18.sub((collateralEquivalentD18.mul(params.buybackFee)).div(1e6)); |
return (collateralEquivalentD18);
|
return (collateralEquivalentD18);
| 58,719 |
9 | // Purchase of siring ritesSends funds to the seller and sets sire approval for the matronEmits a MarketTransaction event with TxType "Sire Rites"Requirement: The msg.value needs to equal the siring price of _tokenIdRequirement: There must be an active sire offer for _sireTokenId / | function buySireRites(uint256 _sireTokenId, uint256 _matronTokenId) external payable;
| function buySireRites(uint256 _sireTokenId, uint256 _matronTokenId) external payable;
| 27,888 |
151 | // See {IERC1155-balanceOf}.Requirements:- `account` must not be zero address. / | function balanceOf(address account, uint256 id) public view override returns (uint256) {
if (isOwnerOf(account, id)) {
return 1;
}
| function balanceOf(address account, uint256 id) public view override returns (uint256) {
if (isOwnerOf(account, id)) {
return 1;
}
| 22,883 |
256 | // Helper to remove a tracked asset from the fund | function __vaultActionRemoveTrackedAsset(bytes memory _actionData) private {
address asset = abi.decode(_actionData, (address));
// Allowing this to fail silently makes it cheaper and simpler
// for Extensions to not query for the denomination asset
if (asset != denominationAsset) {
IVault(vaultProxy).removeTrackedAsset(asset);
}
}
| function __vaultActionRemoveTrackedAsset(bytes memory _actionData) private {
address asset = abi.decode(_actionData, (address));
// Allowing this to fail silently makes it cheaper and simpler
// for Extensions to not query for the denomination asset
if (asset != denominationAsset) {
IVault(vaultProxy).removeTrackedAsset(asset);
}
}
| 63,309 |
64 | // return The amount of ETH you will get after selling X INCH | function afterFeeEthReturns(uint _inchToSell) public view returns(uint) {
uint _trueInchToSell = _inchToSell.mul(conserveRate).div(conserveRateDigits);
return _trueInchToSell.mul(premium).div(premiumDigits.mul(etherPeg));
}
| function afterFeeEthReturns(uint _inchToSell) public view returns(uint) {
uint _trueInchToSell = _inchToSell.mul(conserveRate).div(conserveRateDigits);
return _trueInchToSell.mul(premium).div(premiumDigits.mul(etherPeg));
}
| 78,290 |
50 | // Helper function that checks for ERC777TokensSender on the sender and calls it./May throw according to `_preventLocking`/_from The address holding the tokens being sent/_to The address of the recipient/_amount The amount of tokens to be sent/_userData Data generated by the user to be passed to the recipient/_operatorData Data generated by the operator to be passed to the recipient/implementing `ERC777TokensSender`./ERC777 native Send functions MUST set this parameter to `true`, and backwards compatible ERC20 transfer/functions SHOULD set this parameter to `false`. | function callSender(
address _operator,
address _from,
address _to,
uint256 _amount,
bytes _userData,
bytes _operatorData
)
internal
| function callSender(
address _operator,
address _from,
address _to,
uint256 _amount,
bytes _userData,
bytes _operatorData
)
internal
| 56,958 |
13 | // public metadata locked flag | bool public locked;
| bool public locked;
| 17,827 |
32 | // overriding CrowdsalevalidPurchase to add extra cap logic return true if investors can buy at the moment | function validPurchase() internal view returns (bool) {
if (msg.value < minWeiInvestment || msg.value > maxWeiInvestment) {
return false;
}
bool withinPeriod = (now >= startTime) && (now <= endTime); // 1128581 1129653
return withinPeriod;
}
| function validPurchase() internal view returns (bool) {
if (msg.value < minWeiInvestment || msg.value > maxWeiInvestment) {
return false;
}
bool withinPeriod = (now >= startTime) && (now <= endTime); // 1128581 1129653
return withinPeriod;
}
| 44,638 |
0 | // Calculates time-weighted means of tick and liquidity for a given Uniswap V3 pool/pool Address of the pool that we want to observe/secondsAgo Number of seconds in the past from which to calculate the time-weighted means/ return arithmeticMeanTick The arithmetic mean tick from (block.timestamp - secondsAgo) to block.timestamp/ return harmonicMeanLiquidity The harmonic mean liquidity from (block.timestamp - secondsAgo) to block.timestamp | function consult(address pool, uint32 secondsAgo)
internal
view
returns (int24 arithmeticMeanTick, uint128 harmonicMeanLiquidity)
| function consult(address pool, uint32 secondsAgo)
internal
view
returns (int24 arithmeticMeanTick, uint128 harmonicMeanLiquidity)
| 24,817 |
62 | // Burn `amount` tokens and decreasing the total supply. / | function burn(uint256 amount) public returns (bool) {
_burn(_msgSender(), amount);
return true;
}
| function burn(uint256 amount) public returns (bool) {
_burn(_msgSender(), amount);
return true;
}
| 24,597 |
113 | // This function multiplies two decimals represented as (decimal10DECIMALS)return uint256 Result of multiplication represented as (decimal10DECIMALS) / | function mul(uint256 x, uint256 y) internal pure returns (uint256 z) {
z = SafeMath.add(SafeMath.mul(x, y), (10 ** 18) / 2) / (10 ** 18);
}
| function mul(uint256 x, uint256 y) internal pure returns (uint256 z) {
z = SafeMath.add(SafeMath.mul(x, y), (10 ** 18) / 2) / (10 ** 18);
}
| 5,213 |
0 | // Current owner of NFT | address seller;
| address seller;
| 0 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.