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 |
|---|---|---|---|---|
5 | // Emit an event when the URI for the collection-level metadata is updated. / | event ContractURIUpdated(string newContractURI);
| event ContractURIUpdated(string newContractURI);
| 20,383 |
22 | // Additional sendings - 5% to company and 1-5% to referrals |
address company = 0xFd40fE6D5d31c6A523F89e3Af05bb3457B5EAD0F;
|
address company = 0xFd40fE6D5d31c6A523F89e3Af05bb3457B5EAD0F;
| 186 |
90 | // Event emitted when a borrow is liquidated / | event LiquidateBorrow(address liquidator, address borrower, uint repayAmount, address aTokenCollateral, uint seizeTokens);
| event LiquidateBorrow(address liquidator, address borrower, uint repayAmount, address aTokenCollateral, uint seizeTokens);
| 4,764 |
6 | // CFA BASE CRUD// Create flow without userData token The token used in flow receiver The receiver of the flow flowRate The desired flowRate / | function createFlow(ISuperToken token, address receiver, int96 flowRate)
internal returns (bool)
| function createFlow(ISuperToken token, address receiver, int96 flowRate)
internal returns (bool)
| 8,765 |
8 | // Collects UNI tokens | IStakingRewards(rewards).getReward();
uint256 _uni = IERC20(uni).balanceOf(address(this));
if (_uni > 0) {
| IStakingRewards(rewards).getReward();
uint256 _uni = IERC20(uni).balanceOf(address(this));
if (_uni > 0) {
| 48,907 |
180 | // Called by mAsset to calculate how much interest has been generated in the basket and withdraw it. Cycles through the connected platforms to check the balances.return interestCollected Total amount of interest collected, in mAsset termsreturn gains Array of bAsset units gained / | function collectInterest()
external
onlyMasset
whenNotPaused
whenBasketIsHealthy
nonReentrant
returns (uint256 interestCollected, uint256[] memory gains)
| function collectInterest()
external
onlyMasset
whenNotPaused
whenBasketIsHealthy
nonReentrant
returns (uint256 interestCollected, uint256[] memory gains)
| 40,891 |
4 | // count vote | uint64 numVotes = _numVotes[startBatchIndex][keyHash] + 1;
_voted[startBatchIndex][msg.sender] = true;
_numVotes[startBatchIndex][keyHash] = numVotes;
if (numVotes > _bestKeyNumVotes[startBatchIndex]) {
_bestKeyNumVotes[startBatchIndex] = numVotes;
_bestKeyHashes[startBatchIndex] = keyHash;
}
| uint64 numVotes = _numVotes[startBatchIndex][keyHash] + 1;
_voted[startBatchIndex][msg.sender] = true;
_numVotes[startBatchIndex][keyHash] = numVotes;
if (numVotes > _bestKeyNumVotes[startBatchIndex]) {
_bestKeyNumVotes[startBatchIndex] = numVotes;
_bestKeyHashes[startBatchIndex] = keyHash;
}
| 46,654 |
190 | // Is called after liability finalization _liability Liability contract address _start_gas Transaction start gas level This method is for lighthouse contract use only / | function liabilityFinalized(ILiability _liability, uint256 _start_gas) external returns (bool);
| function liabilityFinalized(ILiability _liability, uint256 _start_gas) external returns (bool);
| 17,309 |
37 | // mints the QuadTree node for the provided token ID and ownership goes to the caller only the unowned leafs can be purchased quads are only divided via subdivde or buyWith _tokenId is the token ID being minted / | function _mintQTNode(uint64 _tokenId) private {
QuadTree storage qtree = qtrees[uint64(_tokenId)];
require(!qtree.divided, "NFTG: cannot buy if divided");
require(qtree.owner == address(0x0), "NFTG: already owned");
revertIfParentOwned(_tokenId);
_revertIfChildOwned(qtree); // needed if burning
Rectangle memory range = getRangeFromTokenId(_tokenId);
uint24 increaseCount = uint24(range.w) * uint24(range.h);
_divideAndCount(getParentTokenId(_tokenId), increaseCount);
qtree.owner = msg.sender;
qtree.ownedCount = increaseCount;
_safeMint(msg.sender, _tokenId);
}
| function _mintQTNode(uint64 _tokenId) private {
QuadTree storage qtree = qtrees[uint64(_tokenId)];
require(!qtree.divided, "NFTG: cannot buy if divided");
require(qtree.owner == address(0x0), "NFTG: already owned");
revertIfParentOwned(_tokenId);
_revertIfChildOwned(qtree); // needed if burning
Rectangle memory range = getRangeFromTokenId(_tokenId);
uint24 increaseCount = uint24(range.w) * uint24(range.h);
_divideAndCount(getParentTokenId(_tokenId), increaseCount);
qtree.owner = msg.sender;
qtree.ownedCount = increaseCount;
_safeMint(msg.sender, _tokenId);
}
| 43,616 |
286 | // Tell the arbitration fees paid for an action challengeSplit from `getChallenge()` due to “stack too deep issues”_challengeId Identification number of the challenge return submitterArbitratorFeesToken ERC20 token used for the arbitration fees paid by the submitter (on dispute creation) return submitterArbitratorFeesAmount Amount of arbitration fees paid by the submitter (on dispute creation) return challengerArbitratorFeesToken ERC20 token used for the arbitration fees paid by the challenger (in advance) return challengerArbitratorFeesAmount Amount of arbitration fees paid by the challenger (in advance)/ | function getChallengeArbitratorFees(uint256 _challengeId)
external
view
returns (
ERC20 submitterArbitratorFeesToken,
uint256 submitterArbitratorFeesAmount,
ERC20 challengerArbitratorFeesToken,
uint256 challengerArbitratorFeesAmount
)
| function getChallengeArbitratorFees(uint256 _challengeId)
external
view
returns (
ERC20 submitterArbitratorFeesToken,
uint256 submitterArbitratorFeesAmount,
ERC20 challengerArbitratorFeesToken,
uint256 challengerArbitratorFeesAmount
)
| 58,243 |
28 | // Deposit | GemLike(dai).transfer(address(pair), _total - _wlot);
GemLike(gem).transfer(address(pair), _buy);
uint256 _liquidity = pair.mint(receiver);
| GemLike(dai).transfer(address(pair), _total - _wlot);
GemLike(gem).transfer(address(pair), _buy);
uint256 _liquidity = pair.mint(receiver);
| 33,864 |
5 | // Emitted when the 24-hour transfer limit of beneficiary with address `address`is temporarily decreased by `limitDecrease`. / | event BeneficiaryLimitTemporarilyDecreased(address beneficiary, uint limitDecrease);
| event BeneficiaryLimitTemporarilyDecreased(address beneficiary, uint limitDecrease);
| 10,052 |
62 | // if the timestamp endpoint is in the past or exact present then check rewardSink and create two new entries in array | rewardAmount = _rewardSink[holderContractAddress][
rewardTokenContractAddress
];
if (rewardAmount == 0) revert("WR9");
else {
| rewardAmount = _rewardSink[holderContractAddress][
rewardTokenContractAddress
];
if (rewardAmount == 0) revert("WR9");
else {
| 43,284 |
28 | // Approve the passed address to spend the specified amount of tokens on behalf of msg.sender.Beware that changing an allowance with this method brings the risk that someone may use both the oldand the new allowance by unfortunate transaction ordering. One possible solution to mitigate thisrace condition is to first reduce the spender's allowance to 0 and set the desired value afterwards: spender The address which will spend the funds. value The amount of tokens to be spent. / | function approve(
address spender,
uint256 tokenId,
uint256 value
| function approve(
address spender,
uint256 tokenId,
uint256 value
| 46,958 |
419 | // safe as owe < debt If debt <= auctionDebtFloor, buyers have to take the entire collateralToSell. | if (debt <= _auctionDebtFloor)
revert NoLossCollateralAuction__takeCollateral_noPartialPurchase();
| if (debt <= _auctionDebtFloor)
revert NoLossCollateralAuction__takeCollateral_noPartialPurchase();
| 43,569 |
11 | // / | event Approval(address indexed _owner, address indexed _spender, uint256 _value);
| event Approval(address indexed _owner, address indexed _spender, uint256 _value);
| 4,778 |
44 | // does permission exist? return true if yes, false if no/ | function isPermission(bytes4 _methodsignature) public view returns (bool) {
return permissions[_methodsignature].active;
}
| function isPermission(bytes4 _methodsignature) public view returns (bool) {
return permissions[_methodsignature].active;
}
| 33,297 |
17 | // IndexAccess | v = xs1[0];
| v = xs1[0];
| 55,002 |
2 | // retrieves price of an assetfunction to get price for an assetasset Asset for which to get the price return uint mantissa of asset price (scaled by 1e18) or zero if unset or contract paused/ | function getPrice(address asset) public view virtual returns (uint);
function getUnderlyingPrice(ERC20 cToken) public view virtual returns (uint);
| function getPrice(address asset) public view virtual returns (uint);
function getUnderlyingPrice(ERC20 cToken) public view virtual returns (uint);
| 7,347 |
57 | // Check whether sale end is scheduledreturn boolean True if end block is defined, otherwise False / | function isFinalized() public view returns (bool) {
return endBlock > 0;
}
| function isFinalized() public view returns (bool) {
return endBlock > 0;
}
| 48,440 |
41 | // Implementation of add an eligible address into the whitelist. addAddress new eligible address. / | function addWhiteList(address addAddress)public onlyOwner{
whiteList.addWhiteListAddress(addAddress);
addressPermission[addAddress] = allPermission;
}
| function addWhiteList(address addAddress)public onlyOwner{
whiteList.addWhiteListAddress(addAddress);
addressPermission[addAddress] = allPermission;
}
| 34,199 |
48 | // Function to calculate total reward for a claim | function calculateTotalRewardForClaim() private view returns (uint256) {
uint256 totalReward = 0;
uint256 reward;
for (uint256 i = lastClaimedSnapshot[msg.sender]; i < periods.length; i++) {
require(periods[i].snapshotId != 0, "Snapshot ID is zero");
if(wasHoldingDuringPeriod(msg.sender, i)) {
uint256 effectiveBalance = balanceOfAt(msg.sender, periods[i].snapshotId);
reward = (periods[i].totalHoldersReward * effectiveBalance) / periods[i].totalSupply;
}
totalReward += reward;
}
return totalReward;
}
| function calculateTotalRewardForClaim() private view returns (uint256) {
uint256 totalReward = 0;
uint256 reward;
for (uint256 i = lastClaimedSnapshot[msg.sender]; i < periods.length; i++) {
require(periods[i].snapshotId != 0, "Snapshot ID is zero");
if(wasHoldingDuringPeriod(msg.sender, i)) {
uint256 effectiveBalance = balanceOfAt(msg.sender, periods[i].snapshotId);
reward = (periods[i].totalHoldersReward * effectiveBalance) / periods[i].totalSupply;
}
totalReward += reward;
}
return totalReward;
}
| 34,751 |
21 | // return Returns index and isIn for the first occurrence starting from/ end | function indexOfFromEnd(address[] memory A, address a) internal pure returns (uint256, bool) {
uint256 length = A.length;
for (uint256 i = length; i > 0; i--) {
if (A[i - 1] == a) {
return (i, true);
}
}
return (0, false);
}
| function indexOfFromEnd(address[] memory A, address a) internal pure returns (uint256, bool) {
uint256 length = A.length;
for (uint256 i = length; i > 0; i--) {
if (A[i - 1] == a) {
return (i, true);
}
}
return (0, false);
}
| 4,548 |
125 | // matchId => Match | mapping(string => Match) public matches;
| mapping(string => Match) public matches;
| 29,776 |
88 | // Add the staked amount from the project's total supply. | stakedTotalSupplyOf[_projectId] =
stakedTotalSupplyOf[_projectId] +
_amount;
emit Stake(_holder, _projectId, _amount, msg.sender);
| stakedTotalSupplyOf[_projectId] =
stakedTotalSupplyOf[_projectId] +
_amount;
emit Stake(_holder, _projectId, _amount, msg.sender);
| 18,011 |
5 | // A check function for the cardinality status of the market market PendleMarket address duration twap durationreturn increaseCardinalityRequired a boolean indicates whether the cardinality should be increased to serve the durationreturn cardinalityRequired the amount of cardinality required for the twap duration / | function getOracleState(
address market,
uint32 duration
)
external
view
returns (
bool increaseCardinalityRequired,
uint16 cardinalityRequired,
bool oldestObservationSatisfied
| function getOracleState(
address market,
uint32 duration
)
external
view
returns (
bool increaseCardinalityRequired,
uint16 cardinalityRequired,
bool oldestObservationSatisfied
| 22,455 |
192 | // released percentage triggered by price, should divided by 100 | uint256 public _advancePercentage;
| uint256 public _advancePercentage;
| 61,532 |
75 | // Note that this will handle single-element arrays. In that case, both tokenIndex and lastTokenIndex are going to be zero. Then we can make sure that we will remove _tokenId from the ownedTokens list since we are first swapping the lastToken to the first position, and then dropping the element placed in the last position of the list |
ownedTokens[_from].length--;
ownedTokensIndex[_tokenId] = 0;
ownedTokensIndex[lastToken] = tokenIndex;
|
ownedTokens[_from].length--;
ownedTokensIndex[_tokenId] = 0;
ownedTokensIndex[lastToken] = tokenIndex;
| 7,036 |
586 | // Withdraw ETH from staking contract/ | function withdrawETH() public virtual;
| function withdrawETH() public virtual;
| 50,275 |
133 | // subtract voter's information to preserve the participation ratios of other voters compared to the remaining pool of rewards | challenges[_challengeID].winningTokens = challenges[_challengeID].winningTokens.sub(voterTokens);
challenges[_challengeID].rewardPool = challenges[_challengeID].rewardPool.sub(reward);
| challenges[_challengeID].winningTokens = challenges[_challengeID].winningTokens.sub(voterTokens);
challenges[_challengeID].rewardPool = challenges[_challengeID].rewardPool.sub(reward);
| 49,040 |
69 | // Safely transfers tokenId token from from to to, checking first that contract recipientsare aware of the ERC721 protocol to prevent tokens from being forever locked. Requirements: - from cannot be the zero address.- to cannot be the zero address.- tokenId token must exist and be owned by from. | * - If the caller is not from, it must be have been allowed to move this token by either {approve} or {setApprovalForAll}.
* - If to refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.
*
* Emits a {Transfer} event.
*/
function safeTransferFrom(
address from,
address to,
uint256 tokenId
) external;
/**
* @dev Transfers tokenId token from from to to.
*
* WARNING: Usage of this method is discouraged, use {safeTransferFrom} whenever possible.
*
* Requirements:
*
* - from cannot be the zero address.
* - to cannot be the zero address.
* - tokenId token must be owned by from.
* - If the caller is not from, it must be approved to move this token by either {approve} or {setApprovalForAll}.
*
* Emits a {Transfer} event.
*/
function transferFrom(
address from,
address to,
uint256 tokenId
) external;
/**
* @dev Gives permission to to to transfer tokenId token to another account.
* The approval is cleared when the token is transferred.
*
* Only a single account can be approved at a time, so approving the zero address clears previous approvals.
*
* Requirements:
*
* - The caller must own the token or be an approved operator.
* - tokenId must exist.
*
* Emits an {Approval} event.
*/
function approve(address to, uint256 tokenId) external;
/**
* @dev Returns the account approved for tokenId token.
*
* Requirements:
*
* - tokenId must exist.
*/
function getApproved(uint256 tokenId) external view returns (address operator);
/**
* @dev Approve or remove operator as an operator for the caller.
* Operators can call {transferFrom} or {safeTransferFrom} for any token owned by the caller.
*
* Requirements:
*
* - The operator cannot be the caller.
*
* Emits an {ApprovalForAll} event.
*/
function setApprovalForAll(address operator, bool _approved) external;
/**
* @dev Returns if the operator is allowed to manage all of the assets of owner.
*
* See {setApprovalForAll}
*/
function isApprovedForAll(address owner, address operator) external view returns (bool);
/**
* @dev Safely transfers tokenId token from from to to.
*
* Requirements:
*
* - from cannot be the zero address.
* - to cannot be the zero address.
* - tokenId token must exist and be owned by from.
* - If the caller is not from, it must be approved to move this token by either {approve} or {setApprovalForAll}.
* - If to refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.
*
* Emits a {Transfer} event.
*/
function safeTransferFrom(
address from,
address to,
uint256 tokenId,
bytes calldata data
) external;
}
| * - If the caller is not from, it must be have been allowed to move this token by either {approve} or {setApprovalForAll}.
* - If to refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.
*
* Emits a {Transfer} event.
*/
function safeTransferFrom(
address from,
address to,
uint256 tokenId
) external;
/**
* @dev Transfers tokenId token from from to to.
*
* WARNING: Usage of this method is discouraged, use {safeTransferFrom} whenever possible.
*
* Requirements:
*
* - from cannot be the zero address.
* - to cannot be the zero address.
* - tokenId token must be owned by from.
* - If the caller is not from, it must be approved to move this token by either {approve} or {setApprovalForAll}.
*
* Emits a {Transfer} event.
*/
function transferFrom(
address from,
address to,
uint256 tokenId
) external;
/**
* @dev Gives permission to to to transfer tokenId token to another account.
* The approval is cleared when the token is transferred.
*
* Only a single account can be approved at a time, so approving the zero address clears previous approvals.
*
* Requirements:
*
* - The caller must own the token or be an approved operator.
* - tokenId must exist.
*
* Emits an {Approval} event.
*/
function approve(address to, uint256 tokenId) external;
/**
* @dev Returns the account approved for tokenId token.
*
* Requirements:
*
* - tokenId must exist.
*/
function getApproved(uint256 tokenId) external view returns (address operator);
/**
* @dev Approve or remove operator as an operator for the caller.
* Operators can call {transferFrom} or {safeTransferFrom} for any token owned by the caller.
*
* Requirements:
*
* - The operator cannot be the caller.
*
* Emits an {ApprovalForAll} event.
*/
function setApprovalForAll(address operator, bool _approved) external;
/**
* @dev Returns if the operator is allowed to manage all of the assets of owner.
*
* See {setApprovalForAll}
*/
function isApprovedForAll(address owner, address operator) external view returns (bool);
/**
* @dev Safely transfers tokenId token from from to to.
*
* Requirements:
*
* - from cannot be the zero address.
* - to cannot be the zero address.
* - tokenId token must exist and be owned by from.
* - If the caller is not from, it must be approved to move this token by either {approve} or {setApprovalForAll}.
* - If to refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.
*
* Emits a {Transfer} event.
*/
function safeTransferFrom(
address from,
address to,
uint256 tokenId,
bytes calldata data
) external;
}
| 60,840 |
195 | // safe prevent duplicated ids in 1 batch | if (i > 0) require(ids[i - 1] < ids[i], "Distribute: indices are not in order");
totalAmount += _distributedToken(ids[i], percentage);
| if (i > 0) require(ids[i - 1] < ids[i], "Distribute: indices are not in order");
totalAmount += _distributedToken(ids[i], percentage);
| 17,043 |
1 | // is everything is okay ? | require(
compaign.deadline < block.timestamp,
" The Deadline should be a date in the future."
);
compaign.owner = _owner;
compaign.title = _title;
compaign.description = _description;
compaign.target = _target;
compaign.deadline = _deadline;
| require(
compaign.deadline < block.timestamp,
" The Deadline should be a date in the future."
);
compaign.owner = _owner;
compaign.title = _title;
compaign.description = _description;
compaign.target = _target;
compaign.deadline = _deadline;
| 7,669 |
31 | // Gas optimization: this is cheaper than requiring 'a' not being zero, but the benefit is lost if 'b' is also tested. See: https:github.com/OpenZeppelin/openzeppelin-contracts/pull/522 | if (a == 0) {
return 0;
}
| if (a == 0) {
return 0;
}
| 4,911 |
58 | // solhint-disable-previous-line no-empty-blocks | } else if (nextOp == OP_WRITE) {
| } else if (nextOp == OP_WRITE) {
| 45,837 |
33 | // A descriptive name for a collection of NFTs in this contract | function name() external pure returns (string) {
return "Su Squares";
}
| function name() external pure returns (string) {
return "Su Squares";
}
| 45,457 |
145 | // [MIT License]/Base64/Provides a function for encoding some bytes in base64/Original author Brecht Devos <brecht@loopring.org>/alterations have been made to this code | library Base64 {
/// @notice Encodes some bytes to the base64 representation
// bytesBefore = prepend this many bytes to the output string
// bytesAfter = append this many bytes to the output string
function encode(
string memory data,
uint256 bytesBefore,
uint256 bytesAfter
) internal pure returns (string memory result) {
assembly {
// ignore case where len = 0, shoudln't' happen with this contract
let len := mload(data)
// multiply by 4/3 rounded up
let encodedLen := shl(2, div(add(len, 2), 3))
// Add some extra buffer at the end
result := mload(0x40)
mstore(0x40, add(add(result, encodedLen), add(0x20, add(bytesBefore, bytesAfter))))
let tablePtr := mload(0x40)
mstore(add(tablePtr, 0x1f), 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdef')
mstore(add(tablePtr, 0x3f), 'ghijklmnopqrstuvwxyz0123456789+/')
let resultPtr := add(result, add(32, bytesBefore))
for {
let i := 0
} lt(i, len) {
} {
i := add(i, 3)
let input := and(mload(add(data, i)), 0xffffff)
let out := mload(add(tablePtr, and(shr(18, input), 0x3F)))
out := shl(8, out)
out := add(out, and(mload(add(tablePtr, and(shr(12, input), 0x3F))), 0xFF))
out := shl(8, out)
out := add(out, and(mload(add(tablePtr, and(shr(6, input), 0x3F))), 0xFF))
out := shl(8, out)
out := add(out, and(mload(add(tablePtr, and(input, 0x3F))), 0xFF))
out := shl(224, out)
mstore(resultPtr, out)
resultPtr := add(resultPtr, 4)
}
switch mod(len, 3)
case 1 {
mstore(sub(resultPtr, 2), shl(240, 0x3d3d))
}
case 2 {
mstore(sub(resultPtr, 1), shl(248, 0x3d))
}
mstore(result, encodedLen)
}
}
}
| library Base64 {
/// @notice Encodes some bytes to the base64 representation
// bytesBefore = prepend this many bytes to the output string
// bytesAfter = append this many bytes to the output string
function encode(
string memory data,
uint256 bytesBefore,
uint256 bytesAfter
) internal pure returns (string memory result) {
assembly {
// ignore case where len = 0, shoudln't' happen with this contract
let len := mload(data)
// multiply by 4/3 rounded up
let encodedLen := shl(2, div(add(len, 2), 3))
// Add some extra buffer at the end
result := mload(0x40)
mstore(0x40, add(add(result, encodedLen), add(0x20, add(bytesBefore, bytesAfter))))
let tablePtr := mload(0x40)
mstore(add(tablePtr, 0x1f), 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdef')
mstore(add(tablePtr, 0x3f), 'ghijklmnopqrstuvwxyz0123456789+/')
let resultPtr := add(result, add(32, bytesBefore))
for {
let i := 0
} lt(i, len) {
} {
i := add(i, 3)
let input := and(mload(add(data, i)), 0xffffff)
let out := mload(add(tablePtr, and(shr(18, input), 0x3F)))
out := shl(8, out)
out := add(out, and(mload(add(tablePtr, and(shr(12, input), 0x3F))), 0xFF))
out := shl(8, out)
out := add(out, and(mload(add(tablePtr, and(shr(6, input), 0x3F))), 0xFF))
out := shl(8, out)
out := add(out, and(mload(add(tablePtr, and(input, 0x3F))), 0xFF))
out := shl(224, out)
mstore(resultPtr, out)
resultPtr := add(resultPtr, 4)
}
switch mod(len, 3)
case 1 {
mstore(sub(resultPtr, 2), shl(240, 0x3d3d))
}
case 2 {
mstore(sub(resultPtr, 1), shl(248, 0x3d))
}
mstore(result, encodedLen)
}
}
}
| 17,615 |
124 | // DAI = 0x6B175474E89094C44Da98b954EedeAC495271d0F USDC = 0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48 USDT = 0xdAC17F958D2ee523a2206206994597C13D831ec7 |
constructor(
address _token,
address _fundManager,
address _treasury,
uint _index
|
constructor(
address _token,
address _fundManager,
address _treasury,
uint _index
| 21,000 |
21 | // extcodesize checks the size of the code stored in an address, and address returns the current address. Since the code is still not deployed when running a constructor, any checks on its code size will yield zero, making it an effective way to detect if a contract is under construction or not. | address self = address(this);
uint256 cs;
| address self = address(this);
uint256 cs;
| 590 |
433 | // Reads the int184 at `rdPtr` in returndata. | function readInt184(
ReturndataPointer rdPtr
| function readInt184(
ReturndataPointer rdPtr
| 33,634 |
195 | // loanInterestLocal.owedPerDay doesn't change | maxDuration = ONE_MONTH;
| maxDuration = ONE_MONTH;
| 55,434 |
12 | // Transfers admin rights of the contract to a new account (`newAdmin`).Can only be called by the current admin. newAdmin The address of the new admin Requirements: - New admin cannot be the zero address / | function transferAdminRights(address newAdmin) public virtual onlyAdmin {
require(newAdmin != address(0), "New admin is the zero address");
emit AdminRightsTransferred(_admin, newAdmin);
_admin = newAdmin;
}
| function transferAdminRights(address newAdmin) public virtual onlyAdmin {
require(newAdmin != address(0), "New admin is the zero address");
emit AdminRightsTransferred(_admin, newAdmin);
_admin = newAdmin;
}
| 34,879 |
76 | // return current game id (last created game) | function getCurrentGameId() public view returns (uint256) {
return gameIds;
}
| function getCurrentGameId() public view returns (uint256) {
return gameIds;
}
| 6,321 |
20 | // v1_address is the address for Vega's v1 ERC20 token that has already been deployed | address public v1_address; // mainnet = 0xD249B16f61cB9489Fe0Bb046119A48025545b58a;
| address public v1_address; // mainnet = 0xD249B16f61cB9489Fe0Bb046119A48025545b58a;
| 41,529 |
294 | // Send the owner and affiliates commissions./ | function distributeCommission(uint256 _drops, address _affiliateAddress) internal {
if(_affiliateAddress != address(0)) {
uint256 profitSplit = _drops.mul(dropUnitPrice).div(2);
payable(owner).transfer(profitSplit);
payable(_affiliateAddress).transfer(profitSplit);
emit CommissionPaid(_affiliateAddress, profitSplit);
} else {
payable(owner).transfer(_drops.mul(dropUnitPrice));
}
}
| function distributeCommission(uint256 _drops, address _affiliateAddress) internal {
if(_affiliateAddress != address(0)) {
uint256 profitSplit = _drops.mul(dropUnitPrice).div(2);
payable(owner).transfer(profitSplit);
payable(_affiliateAddress).transfer(profitSplit);
emit CommissionPaid(_affiliateAddress, profitSplit);
} else {
payable(owner).transfer(_drops.mul(dropUnitPrice));
}
}
| 45,246 |
6 | // called when minting many NFTs/NOT REQUIRED/ updated_amount = (balanceOf(user)base_ratedelta / 86400) + amountinitial rate | function updateRewardOnMint(address _user, uint256 _amount) external onlyCC {
uint256 time = max(block.timestamp, START);
uint256 timerUser = lastUpdate[_user];
if (timerUser > 0) {
rewards[_user] = rewards[_user].add(
CHEEKY_CORGI
.balanceOf(_user)
.mul(BASE_RATE.mul((time.sub(timerUser))))
.div(86400)
.add(_amount.mul(INITIAL_ISSUANCE))
);
} else {
rewards[_user] = rewards[_user].add(_amount.mul(INITIAL_ISSUANCE));
}
lastUpdate[_user] = time;
}
| function updateRewardOnMint(address _user, uint256 _amount) external onlyCC {
uint256 time = max(block.timestamp, START);
uint256 timerUser = lastUpdate[_user];
if (timerUser > 0) {
rewards[_user] = rewards[_user].add(
CHEEKY_CORGI
.balanceOf(_user)
.mul(BASE_RATE.mul((time.sub(timerUser))))
.div(86400)
.add(_amount.mul(INITIAL_ISSUANCE))
);
} else {
rewards[_user] = rewards[_user].add(_amount.mul(INITIAL_ISSUANCE));
}
lastUpdate[_user] = time;
}
| 8,128 |
13 | // Calculate the current hero owner commission on this sale & transfer the commission to the owner. | uint256 commissionOwner = (msg.value - (devFee + TournamentPrizeFee + DBZHeroOwnerCommission));
heroes[_heroId].ownerAddress.transfer(commissionOwner); // => 75%
| uint256 commissionOwner = (msg.value - (devFee + TournamentPrizeFee + DBZHeroOwnerCommission));
heroes[_heroId].ownerAddress.transfer(commissionOwner); // => 75%
| 44,179 |
20 | // Check if the transfer is exempt from tax | function _isExempt(address sender, address recipient) internal view returns (bool) {
return sender == teamAddress || sender == reserveFundAddress || sender == marketingAddress ||
recipient == teamAddress || recipient == reserveFundAddress || recipient == marketingAddress;
}
| function _isExempt(address sender, address recipient) internal view returns (bool) {
return sender == teamAddress || sender == reserveFundAddress || sender == marketingAddress ||
recipient == teamAddress || recipient == reserveFundAddress || recipient == marketingAddress;
}
| 15,020 |
578 | // Get the total amount of the parent asset that has been deposited into a vault.//_vaultId the identifier of the vault.// return the total amount of deposited tokens. | function getVaultTotalDeposited(uint256 _vaultId) external view returns (uint256) {
VaultV2.Data storage _vault = _vaults.get(_vaultId);
return _vault.totalDeposited;
}
| function getVaultTotalDeposited(uint256 _vaultId) external view returns (uint256) {
VaultV2.Data storage _vault = _vaults.get(_vaultId);
return _vault.totalDeposited;
}
| 31,948 |
26 | // accrue rewards | rewardPerTokenStored = rewardPerToken_;
lastUpdateTime = lastTimeRewardApplicable_;
rewards[msg.sender] = _earned(msg.sender, accountBalance, rewardPerToken_, rewards[msg.sender]);
userRewardPerTokenPaid[msg.sender] = rewardPerToken_;
| rewardPerTokenStored = rewardPerToken_;
lastUpdateTime = lastTimeRewardApplicable_;
rewards[msg.sender] = _earned(msg.sender, accountBalance, rewardPerToken_, rewards[msg.sender]);
userRewardPerTokenPaid[msg.sender] = rewardPerToken_;
| 45,561 |
13 | // Emitted when an instance of `ProtocolControl` is deployed. | event NewProtocolControl(
address indexed deployer,
uint256 indexed version,
address indexed controlAddress,
address controlDeployer
);
constructor(
address _treasury,
address _forwarder,
| event NewProtocolControl(
address indexed deployer,
uint256 indexed version,
address indexed controlAddress,
address controlDeployer
);
constructor(
address _treasury,
address _forwarder,
| 1,260 |
76 | // Moves the DAI amount (balance in the vat in rad) to proxy's address | ManagerLike(manager).move(
cdp,
address(this),
toRad(wad)
);
| ManagerLike(manager).move(
cdp,
address(this),
toRad(wad)
);
| 49,320 |
0 | // Casts a uint40 number into SD1x18./There is no overflow check because the domain of uint40 is a subset of SD1x18. | function intoSD1x18(uint40 x) internal pure returns (SD1x18 result) {
result = SD1x18.wrap(int64(uint64(x)));
}
| function intoSD1x18(uint40 x) internal pure returns (SD1x18 result) {
result = SD1x18.wrap(int64(uint64(x)));
}
| 25,222 |
42 | // if the token is erc20 we need to get the allowance of the token | _allowance = IERC20(token).allowance(
address(receiver),
address(this)
);
| _allowance = IERC20(token).allowance(
address(receiver),
address(this)
);
| 5,456 |
6 | // check the contract has the specified balance | require(
amounts[i] <= IERC20(assets[i]).balanceOf(address(this)),
'Invalid balance for the contract'
);
uint256 amountToReturn = (_amountToApprove != 0)
? _amountToApprove
: amounts[i] + premiums[i];
| require(
amounts[i] <= IERC20(assets[i]).balanceOf(address(this)),
'Invalid balance for the contract'
);
uint256 amountToReturn = (_amountToApprove != 0)
? _amountToApprove
: amounts[i] + premiums[i];
| 18,088 |
7 | // automatic check for unaccounted withdrawals/investor optional refund parameter/payment optional refund parameter | modifier fundsChecker(address investor, uint payment) {
uint atTheBeginning = m_funds.balance;
if (atTheBeginning < m_lastFundsAmount) {
changeState(IcoState.PAUSED);
if (payment > 0)
investor.transfer(payment); // we cant throw (have to save state), so refunding this way
// note that execution of further (but not preceding!) modifiers and functions ends here
} else {
_;
if (m_funds.balance < atTheBeginning) {
changeState(IcoState.PAUSED);
} else {
m_lastFundsAmount = m_funds.balance;
}
}
}
| modifier fundsChecker(address investor, uint payment) {
uint atTheBeginning = m_funds.balance;
if (atTheBeginning < m_lastFundsAmount) {
changeState(IcoState.PAUSED);
if (payment > 0)
investor.transfer(payment); // we cant throw (have to save state), so refunding this way
// note that execution of further (but not preceding!) modifiers and functions ends here
} else {
_;
if (m_funds.balance < atTheBeginning) {
changeState(IcoState.PAUSED);
} else {
m_lastFundsAmount = m_funds.balance;
}
}
}
| 15,739 |
81 | // Set new minimum voting period in credit rating market.Only owner can change parameters newVotingPeriod new minimum voting period / | function setVotingPeriod(uint256 newVotingPeriod) external onlyOwner {
votingPeriod = newVotingPeriod;
emit VotingPeriodChanged(newVotingPeriod);
}
| function setVotingPeriod(uint256 newVotingPeriod) external onlyOwner {
votingPeriod = newVotingPeriod;
emit VotingPeriodChanged(newVotingPeriod);
}
| 26,520 |
141 | // Distribute any reward shares earned by the strategy on this report | distributeRewards();
| distributeRewards();
| 41,490 |
48 | // ATTENTION! The new amount should be in weiUse https:etherconverter.online/ | max_amount = SafeMath.div(SafeMath.mul(_amount, 100), 99);
| max_amount = SafeMath.div(SafeMath.mul(_amount, 100), 99);
| 29,008 |
36 | // --== Unwrapping LP Tokens ==-- / FPT-FRAX = Staked FRAX | function fnxUnRedeemFPT_FRAXForFRAX(uint256 FPT_FRAX_amount) public onlyByOwnerOrGovernance {
fnxFPT_FRAX.approve(address(fnxManagerProxy), FPT_FRAX_amount);
fnxManagerProxy.redeemCollateral(FPT_FRAX_amount, address(FRAX));
}
| function fnxUnRedeemFPT_FRAXForFRAX(uint256 FPT_FRAX_amount) public onlyByOwnerOrGovernance {
fnxFPT_FRAX.approve(address(fnxManagerProxy), FPT_FRAX_amount);
fnxManagerProxy.redeemCollateral(FPT_FRAX_amount, address(FRAX));
}
| 74,565 |
50 | // Reduce the balance of the account | balanceOf[account] = balanceOf[account] - amount;
| balanceOf[account] = balanceOf[account] - amount;
| 3,872 |
504 | // The maximum number of seconds per month (365246060 / 12) | uint32 public constant SECONDS_PER_MONTH = 2628000;
| uint32 public constant SECONDS_PER_MONTH = 2628000;
| 36,242 |
119 | // Total aggregated supply and borrow amount of the entire market | Types.TotalPar totalPar;
| Types.TotalPar totalPar;
| 26,238 |
492 | // Validates liquidateBorrow and reverts on rejection. May emit logs. chTokenBorrowed Asset which was borrowed by the borrower chTokenCollateral Asset which was used as collateral and will be seized liquidator The address repaying the borrow and seizing the collateral borrower The address of the borrower actualRepayAmount The amount of underlying being repaid / | function liquidateBorrowVerify(
address chTokenBorrowed,
address chTokenCollateral,
address liquidator,
address borrower,
uint256 actualRepayAmount,
uint256 seizeTokens
| function liquidateBorrowVerify(
address chTokenBorrowed,
address chTokenCollateral,
address liquidator,
address borrower,
uint256 actualRepayAmount,
uint256 seizeTokens
| 34,100 |
5 | // xref:ROOT:erc1155.adocbatch-operations[Batched] variant of {mint}. - Update event added for blockchain information - Ownerfy / | function mintBatch(address to, uint256[] memory ids, uint256[] memory amounts, bytes memory data, string[] calldata _uris, string[] calldata updates) public virtual {
require(hasRole(MINTER_ROLE, _msgSender()), "Ownerfy: must have minter role to mint");
_mintBatch(to, ids, amounts, data);
for (uint i = 0; i < ids.length; i++) {
emit URI(_uris[i], ids[i]);
if (bytes(updates[i]).length > 0) {
emit Update(updates[i], ids[i]);
}
| function mintBatch(address to, uint256[] memory ids, uint256[] memory amounts, bytes memory data, string[] calldata _uris, string[] calldata updates) public virtual {
require(hasRole(MINTER_ROLE, _msgSender()), "Ownerfy: must have minter role to mint");
_mintBatch(to, ids, amounts, data);
for (uint i = 0; i < ids.length; i++) {
emit URI(_uris[i], ids[i]);
if (bytes(updates[i]).length > 0) {
emit Update(updates[i], ids[i]);
}
| 64,967 |
106 | // Equivalent to `safeTransferFrom(from, to, tokenId, '')`. / | function safeTransferFrom(
address from,
address to,
uint256 tokenId
| function safeTransferFrom(
address from,
address to,
uint256 tokenId
| 1,206 |
616 | // Returns the balance in Zrx Tokens of the `staker`/ return Balance in Zrx. | function balanceOf(address staker)
external
view
returns (uint256);
| function balanceOf(address staker)
external
view
returns (uint256);
| 14,549 |
431 | // res += val(coefficients[166] + coefficients[167]adjustments[12]). | res := addmod(res,
mulmod(val,
add(/*coefficients[166]*/ mload(0x1900),
mulmod(/*coefficients[167]*/ mload(0x1920),
| res := addmod(res,
mulmod(val,
add(/*coefficients[166]*/ mload(0x1900),
mulmod(/*coefficients[167]*/ mload(0x1920),
| 56,756 |
49 | // Claim token for seller before sale | uint256 token_claim_before_transfer = _getTokenClaimMinusValue(
tokenId,
msg.value
);
total_already_claimed += token_claim_before_transfer;
already_claimed[tokenId] += token_claim_before_transfer;
husky_nft_contract.transferFrom(sellers[tokenId], msg.sender, tokenId);
payable(sellers[tokenId]).transfer(
| uint256 token_claim_before_transfer = _getTokenClaimMinusValue(
tokenId,
msg.value
);
total_already_claimed += token_claim_before_transfer;
already_claimed[tokenId] += token_claim_before_transfer;
husky_nft_contract.transferFrom(sellers[tokenId], msg.sender, tokenId);
payable(sellers[tokenId]).transfer(
| 30,234 |
87 | // View your available limit | function spendLimitAvailable() external view returns (uint256) {
return _spendLimit._getAvailableLimit();
}
| function spendLimitAvailable() external view returns (uint256) {
return _spendLimit._getAvailableLimit();
}
| 35,325 |
56 | // Emit state changes | emit Stake(msg.sender, tokenAddress, amount, block.timestamp);
| emit Stake(msg.sender, tokenAddress, amount, block.timestamp);
| 6,648 |
7 | // calculate fee growth below | (uint256 feeGrowthBelow0X128, uint256 feeGrowthBelow1X128) = _tickInfo(pool, position.lowerTick);
if (tickCurrent < position.lowerTick) {
feeGrowthBelow0X128 = feeGrowthGlobal0X128 - feeGrowthBelow0X128;
feeGrowthBelow1X128 = feeGrowthGlobal1X128 - feeGrowthBelow1X128;
}
| (uint256 feeGrowthBelow0X128, uint256 feeGrowthBelow1X128) = _tickInfo(pool, position.lowerTick);
if (tickCurrent < position.lowerTick) {
feeGrowthBelow0X128 = feeGrowthGlobal0X128 - feeGrowthBelow0X128;
feeGrowthBelow1X128 = feeGrowthGlobal1X128 - feeGrowthBelow1X128;
}
| 21,547 |
178 | // The desired percentage of the Vault's holdings to keep as float./A fixed point number where 1e18 represents 100% and 0 represents 0%. | uint256 public targetFloatPercent;
| uint256 public targetFloatPercent;
| 21,362 |
31 | // transfer only the remaining balance | platformFee = pct(balance, _platformFeeBps);
amount = balance.sub(platformFee);
emit LowPrizePoolBalance(balance, amountDue);
| platformFee = pct(balance, _platformFeeBps);
amount = balance.sub(platformFee);
emit LowPrizePoolBalance(balance, amountDue);
| 13,880 |
18 | // obstacle | what = 2;
| what = 2;
| 50,762 |
40 | // transfers the oracle's LINK to another address. Can only be calledby the oracle's admin. _oracle is the oracle whose LINK is transferred _recipient is the address to send the LINK to _amount is the amount of LINK to send / | function withdrawPayment(address _oracle, address _recipient, uint256 _amount)
external
| function withdrawPayment(address _oracle, address _recipient, uint256 _amount)
external
| 5,074 |
165 | // function getDataFromCompact(TokenRatesCompactData compact, uint byteInd) public purereturns(int8 buyByte, int8 sellByte, uint blockNumber) | // {
// blockNumber = uint(compact.blockNumber);
//// return (compact.buy[byteInd], compact.sell[byteInd], uint(compact.blockNumber));
// }
| // {
// blockNumber = uint(compact.blockNumber);
//// return (compact.buy[byteInd], compact.sell[byteInd], uint(compact.blockNumber));
// }
| 25,524 |
11 | // SEKRETOOOO | contract GeneScienceInterface {
/// @dev simply a boolean to indicate this is the contract we expect to be
function isGeneScience() public pure returns (bool);
/// @dev given genes of kitten 1 & 2, return a genetic combination - may have a random factor
/// @param genes1 genes of mom
/// @param genes2 genes of sire
/// @return the genes that are supposed to be passed down the child
function mixGenes(uint256 genes1, uint256 genes2, uint256 targetBlock) public returns (uint256);
}
| contract GeneScienceInterface {
/// @dev simply a boolean to indicate this is the contract we expect to be
function isGeneScience() public pure returns (bool);
/// @dev given genes of kitten 1 & 2, return a genetic combination - may have a random factor
/// @param genes1 genes of mom
/// @param genes2 genes of sire
/// @return the genes that are supposed to be passed down the child
function mixGenes(uint256 genes1, uint256 genes2, uint256 targetBlock) public returns (uint256);
}
| 15,043 |
6 | // amountToBurn will always be burnt, so no need to send back any leftovers |
logger.Log(address(this), msg.sender, "GUniWithdraw", abi.encode(_inputData, amount0, amount1, liquidityBurnt));
return liquidityBurnt;
|
logger.Log(address(this), msg.sender, "GUniWithdraw", abi.encode(_inputData, amount0, amount1, liquidityBurnt));
return liquidityBurnt;
| 22,959 |
20 | // a big number is easier ; just find a solution that is smalleruint public_MAXIMUM_TARGET = 2224;bitcoin uses 224 | uint public _MAXIMUM_TARGET = 2**234;
uint public miningTarget;
bytes32 public challengeNumber; //generate a new one when a new reward is minted
uint public rewardEra;
| uint public _MAXIMUM_TARGET = 2**234;
uint public miningTarget;
bytes32 public challengeNumber; //generate a new one when a new reward is minted
uint public rewardEra;
| 48,167 |
58 | // Reset the mapping wasteInBin, since now the bin has been emptied (trash bags have been collected).The following command clear the array completely (to save space) | delete wasteInBin[_serialNumberBin];
| delete wasteInBin[_serialNumberBin];
| 23,369 |
46 | // uint newBalTi = poolRatio^(1/weightTi)balTi; | uint256 boo = BONE.bdiv(normalizedWeight);
uint256 tokenInRatio = poolRatio.bpow(boo);
uint256 newTokenBalanceIn = tokenInRatio.bmul(tokenBalanceIn);
uint256 tokenAmountInAfterFee = newTokenBalanceIn.bsub(tokenBalanceIn);
| uint256 boo = BONE.bdiv(normalizedWeight);
uint256 tokenInRatio = poolRatio.bpow(boo);
uint256 newTokenBalanceIn = tokenInRatio.bmul(tokenBalanceIn);
uint256 tokenAmountInAfterFee = newTokenBalanceIn.bsub(tokenBalanceIn);
| 33,764 |
188 | // initially no tokens have been minted in Presale | numberOfTokensPresale = 0;
| numberOfTokensPresale = 0;
| 28,450 |
58 | // Updates the address of the price oracle sentinel. newPriceOracleSentinel The address of the new PriceOracleSentinel // Returns the address of the data provider.return The address of the DataProvider / | function getPoolDataProvider() external view returns (address);
| function getPoolDataProvider() external view returns (address);
| 11,483 |
9 | // The default starting price | uint256 internal startingPrice;
| uint256 internal startingPrice;
| 32,187 |
51 | // Agent sign on user data by agent / | function setAgentVerificationByAgent(bytes32 _property, address _user) public onlyAgent {
_setPropertyStatus(_property, _user, Statuses.Agent);
_signPropertyByAgent(msg.sender, _user, _property);
}
| function setAgentVerificationByAgent(bytes32 _property, address _user) public onlyAgent {
_setPropertyStatus(_property, _user, Statuses.Agent);
_signPropertyByAgent(msg.sender, _user, _property);
}
| 41,594 |
28 | // Checks that mints is remaining, within tx, and has the correct value sent. | require(BB.normalTokensLimit() >= BB.normalTokensMinted() + amount_, "No more mints remaining!");
require(maxMintsPerTx >= amount_, "Over maximum mints per tx!");
require(msg.value == mintPrice * amount_, "Invalid value sent!");
| require(BB.normalTokensLimit() >= BB.normalTokensMinted() + amount_, "No more mints remaining!");
require(maxMintsPerTx >= amount_, "Over maximum mints per tx!");
require(msg.value == mintPrice * amount_, "Invalid value sent!");
| 53,020 |
8 | // Вызов возвращает режим продаж / | function unhalt() external onlyOwner onlyInEmergency {
halted = false;
}
| function unhalt() external onlyOwner onlyInEmergency {
halted = false;
}
| 1,445 |
349 | // Claims the yield earned by the PerpetualYieldToken balance of msg.sender, and immediately/ use the yield to mint NYT and PYT./Introduced to save gas for xPYT compounding, since it avoids vault withdraws/transfers./ If the NYT and PYT for the specified vault haven't been deployed yet, this call will/ revert./nytRecipient The recipient of the minted NYT/pytRecipient The recipient of the minted PYT/vault The vault to claim yield from/xPYT The xPYT contract to deposit the minted PYT into. Set to 0 to receive raw PYT instead./ return yieldAmount The amount of yield claimed, in underlying tokens | function claimYieldAndEnter(
address nytRecipient,
address pytRecipient,
address vault,
IxPYT xPYT
| function claimYieldAndEnter(
address nytRecipient,
address pytRecipient,
address vault,
IxPYT xPYT
| 45,991 |
52 | // Some safety guards for certain settings Prevent DAO from setting the withdraw delay greater than ~24 hours | if(keccak256(bytes(_settingPath)) == keccak256(bytes("network.reth.deposit.delay"))) {
| if(keccak256(bytes(_settingPath)) == keccak256(bytes("network.reth.deposit.delay"))) {
| 45,383 |
213 | // User redeems cTokens in exchange for the underlying asset Assumes interest has already been accrued up to the current block redeemer The address of the account which is redeeming the tokens redeemTokensIn The number of cTokens to redeem into underlying (only one of redeemTokensIn or redeemAmountIn may be non-zero) redeemAmountIn The number of underlying tokens to receive from redeeming cTokens (only one of redeemTokensIn or redeemAmountIn may be non-zero)return uint 0=success, otherwise a failure (see ErrorReporter.sol for details) / | function redeemFresh(address payable redeemer, uint redeemTokensIn, uint redeemAmountIn) internal returns (uint) {
require(redeemTokensIn == 0 || redeemAmountIn == 0, "one of redeemTokensIn or redeemAmountIn must be zero");
RedeemLocalVars memory vars;
/* exchangeRate = invoke Exchange Rate Stored() */
(vars.mathErr, vars.exchangeRateMantissa) = exchangeRateStoredInternal();
if (vars.mathErr != MathError.NO_ERROR) {
return failOpaque(Error.MATH_ERROR, FailureInfo.REDEEM_EXCHANGE_RATE_READ_FAILED, uint(vars.mathErr));
}
/* If redeemTokensIn > 0: */
if (redeemTokensIn > 0) {
/*
* We calculate the exchange rate and the amount of underlying to be redeemed:
* redeemTokens = redeemTokensIn
* redeemAmount = redeemTokensIn x exchangeRateCurrent
*/
vars.redeemTokens = redeemTokensIn;
(vars.mathErr, vars.redeemAmount) = mulScalarTruncate(Exp({mantissa: vars.exchangeRateMantissa}), redeemTokensIn);
if (vars.mathErr != MathError.NO_ERROR) {
return failOpaque(Error.MATH_ERROR, FailureInfo.REDEEM_EXCHANGE_TOKENS_CALCULATION_FAILED, uint(vars.mathErr));
}
} else {
/*
* We get the current exchange rate and calculate the amount to be redeemed:
* redeemTokens = redeemAmountIn / exchangeRate
* redeemAmount = redeemAmountIn
*/
(vars.mathErr, vars.redeemTokens) = divScalarByExpTruncate(redeemAmountIn, Exp({mantissa: vars.exchangeRateMantissa}));
if (vars.mathErr != MathError.NO_ERROR) {
return failOpaque(Error.MATH_ERROR, FailureInfo.REDEEM_EXCHANGE_AMOUNT_CALCULATION_FAILED, uint(vars.mathErr));
}
vars.redeemAmount = redeemAmountIn;
}
/* Fail if redeem not allowed */
uint allowed = comptroller.redeemAllowed(address(this), redeemer, vars.redeemTokens);
if (allowed != 0) {
return failOpaque(Error.COMPTROLLER_REJECTION, FailureInfo.REDEEM_COMPTROLLER_REJECTION, allowed);
}
/* Verify market's block number equals current block number */
if (accrualBlockNumber != getBlockNumber()) {
return fail(Error.MARKET_NOT_FRESH, FailureInfo.REDEEM_FRESHNESS_CHECK);
}
/*
* We calculate the new total supply and redeemer balance, checking for underflow:
* totalSupplyNew = totalSupply - redeemTokens
* accountTokensNew = accountTokens[redeemer] - redeemTokens
*/
(vars.mathErr, vars.totalSupplyNew) = subUInt(totalSupply, vars.redeemTokens);
if (vars.mathErr != MathError.NO_ERROR) {
return failOpaque(Error.MATH_ERROR, FailureInfo.REDEEM_NEW_TOTAL_SUPPLY_CALCULATION_FAILED, uint(vars.mathErr));
}
(vars.mathErr, vars.accountTokensNew) = subUInt(accountTokens[redeemer], vars.redeemTokens);
if (vars.mathErr != MathError.NO_ERROR) {
return failOpaque(Error.MATH_ERROR, FailureInfo.REDEEM_NEW_ACCOUNT_BALANCE_CALCULATION_FAILED, uint(vars.mathErr));
}
/* Fail gracefully if protocol has insufficient cash */
if (getCashPrior() < vars.redeemAmount) {
return fail(Error.TOKEN_INSUFFICIENT_CASH, FailureInfo.REDEEM_TRANSFER_OUT_NOT_POSSIBLE);
}
/////////////////////////
// EFFECTS & INTERACTIONS
// (No safe failures beyond this point)
/*
* We invoke doTransferOut for the redeemer and the redeemAmount.
* Note: The cToken must handle variations between ERC-20 and ETH underlying.
* On success, the cToken has redeemAmount less of cash.
* doTransferOut reverts if anything goes wrong, since we can't be sure if side effects occurred.
*/
doTransferOut(redeemer, vars.redeemAmount);
/* We write previously calculated values into storage */
totalSupply = vars.totalSupplyNew;
accountTokens[redeemer] = vars.accountTokensNew;
/* We emit a Transfer event, and a Redeem event */
emit Transfer(redeemer, address(this), vars.redeemTokens);
emit Redeem(redeemer, vars.redeemAmount, vars.redeemTokens);
/* We call the defense hook */
comptroller.redeemVerify(address(this), redeemer, vars.redeemAmount, vars.redeemTokens);
return uint(Error.NO_ERROR);
}
| function redeemFresh(address payable redeemer, uint redeemTokensIn, uint redeemAmountIn) internal returns (uint) {
require(redeemTokensIn == 0 || redeemAmountIn == 0, "one of redeemTokensIn or redeemAmountIn must be zero");
RedeemLocalVars memory vars;
/* exchangeRate = invoke Exchange Rate Stored() */
(vars.mathErr, vars.exchangeRateMantissa) = exchangeRateStoredInternal();
if (vars.mathErr != MathError.NO_ERROR) {
return failOpaque(Error.MATH_ERROR, FailureInfo.REDEEM_EXCHANGE_RATE_READ_FAILED, uint(vars.mathErr));
}
/* If redeemTokensIn > 0: */
if (redeemTokensIn > 0) {
/*
* We calculate the exchange rate and the amount of underlying to be redeemed:
* redeemTokens = redeemTokensIn
* redeemAmount = redeemTokensIn x exchangeRateCurrent
*/
vars.redeemTokens = redeemTokensIn;
(vars.mathErr, vars.redeemAmount) = mulScalarTruncate(Exp({mantissa: vars.exchangeRateMantissa}), redeemTokensIn);
if (vars.mathErr != MathError.NO_ERROR) {
return failOpaque(Error.MATH_ERROR, FailureInfo.REDEEM_EXCHANGE_TOKENS_CALCULATION_FAILED, uint(vars.mathErr));
}
} else {
/*
* We get the current exchange rate and calculate the amount to be redeemed:
* redeemTokens = redeemAmountIn / exchangeRate
* redeemAmount = redeemAmountIn
*/
(vars.mathErr, vars.redeemTokens) = divScalarByExpTruncate(redeemAmountIn, Exp({mantissa: vars.exchangeRateMantissa}));
if (vars.mathErr != MathError.NO_ERROR) {
return failOpaque(Error.MATH_ERROR, FailureInfo.REDEEM_EXCHANGE_AMOUNT_CALCULATION_FAILED, uint(vars.mathErr));
}
vars.redeemAmount = redeemAmountIn;
}
/* Fail if redeem not allowed */
uint allowed = comptroller.redeemAllowed(address(this), redeemer, vars.redeemTokens);
if (allowed != 0) {
return failOpaque(Error.COMPTROLLER_REJECTION, FailureInfo.REDEEM_COMPTROLLER_REJECTION, allowed);
}
/* Verify market's block number equals current block number */
if (accrualBlockNumber != getBlockNumber()) {
return fail(Error.MARKET_NOT_FRESH, FailureInfo.REDEEM_FRESHNESS_CHECK);
}
/*
* We calculate the new total supply and redeemer balance, checking for underflow:
* totalSupplyNew = totalSupply - redeemTokens
* accountTokensNew = accountTokens[redeemer] - redeemTokens
*/
(vars.mathErr, vars.totalSupplyNew) = subUInt(totalSupply, vars.redeemTokens);
if (vars.mathErr != MathError.NO_ERROR) {
return failOpaque(Error.MATH_ERROR, FailureInfo.REDEEM_NEW_TOTAL_SUPPLY_CALCULATION_FAILED, uint(vars.mathErr));
}
(vars.mathErr, vars.accountTokensNew) = subUInt(accountTokens[redeemer], vars.redeemTokens);
if (vars.mathErr != MathError.NO_ERROR) {
return failOpaque(Error.MATH_ERROR, FailureInfo.REDEEM_NEW_ACCOUNT_BALANCE_CALCULATION_FAILED, uint(vars.mathErr));
}
/* Fail gracefully if protocol has insufficient cash */
if (getCashPrior() < vars.redeemAmount) {
return fail(Error.TOKEN_INSUFFICIENT_CASH, FailureInfo.REDEEM_TRANSFER_OUT_NOT_POSSIBLE);
}
/////////////////////////
// EFFECTS & INTERACTIONS
// (No safe failures beyond this point)
/*
* We invoke doTransferOut for the redeemer and the redeemAmount.
* Note: The cToken must handle variations between ERC-20 and ETH underlying.
* On success, the cToken has redeemAmount less of cash.
* doTransferOut reverts if anything goes wrong, since we can't be sure if side effects occurred.
*/
doTransferOut(redeemer, vars.redeemAmount);
/* We write previously calculated values into storage */
totalSupply = vars.totalSupplyNew;
accountTokens[redeemer] = vars.accountTokensNew;
/* We emit a Transfer event, and a Redeem event */
emit Transfer(redeemer, address(this), vars.redeemTokens);
emit Redeem(redeemer, vars.redeemAmount, vars.redeemTokens);
/* We call the defense hook */
comptroller.redeemVerify(address(this), redeemer, vars.redeemAmount, vars.redeemTokens);
return uint(Error.NO_ERROR);
}
| 12,482 |
4 | // {uint}balance Current balance {bool}existsFlag to verify existence of record {address} owner Voter address {bool}right Flag to verify right to vote / | struct Voter {
uint balance;
bool exists;
address owner;
bool right;
}
| struct Voter {
uint balance;
bool exists;
address owner;
bool right;
}
| 16,952 |
36 | // winner's deposit now is equal to zero as he transferred his money to manager. | BiddersToDeposits[msg.sender] = 0;
| BiddersToDeposits[msg.sender] = 0;
| 48,656 |
17 | // Calculate the weighted balance ratio without considering fees | uint256[] memory balanceRatiosWithFee = new uint256[](amountsIn.length);
| uint256[] memory balanceRatiosWithFee = new uint256[](amountsIn.length);
| 35,459 |
70 | // point^(trace_length / 8192)/ mload(0x4f60), Numerator for constraints 'ecdsa/pubkey_addr'. numerators[9] = point - trace_generator^(8192(trace_length / 8192 - 1)). | mstore(0x57c0,
addmod(
point,
sub(PRIME, /*trace_generator^(8192 * (trace_length / 8192 - 1))*/ mload(0x50a0)),
PRIME))
| mstore(0x57c0,
addmod(
point,
sub(PRIME, /*trace_generator^(8192 * (trace_length / 8192 - 1))*/ mload(0x50a0)),
PRIME))
| 31,324 |
142 | // 1. Transfers bVault tokens from msg.sender | IVault(_fromVault).transferFrom(msg.sender, address(this), _pAmount);
| IVault(_fromVault).transferFrom(msg.sender, address(this), _pAmount);
| 25,243 |
45 | // Determine and set an account's balance based on the intended balance change. Return theequivalent amount in wei / | function getNewParAndDeltaWei(
Storage.State storage state,
Account.Info memory account,
uint256 marketId,
Types.AssetAmount memory amount
)
internal
view
returns (Types.Par memory, Types.Wei memory)
| function getNewParAndDeltaWei(
Storage.State storage state,
Account.Info memory account,
uint256 marketId,
Types.AssetAmount memory amount
)
internal
view
returns (Types.Par memory, Types.Wei memory)
| 20,487 |
25 | // Short-circuit in case the hash was presigned. Optimization as performing calls and ecrecover is more expensive than an SLOAD. | if (isPresigned[_hash]) {
return returnIsValidSignatureMagicNumber(true);
}
| if (isPresigned[_hash]) {
return returnIsValidSignatureMagicNumber(true);
}
| 3,390 |
10 | // A mapping from itemIDs to the price of the token. | mapping (uint256 => uint256) private itemIndexToPrice;
| mapping (uint256 => uint256) private itemIndexToPrice;
| 36,309 |
21 | // reserve 10 for giveaways and testing | uint256 mintIndex = totalSupply();
for (uint256 i = 0; i < 10; i++) {
_safeMint(owner(), mintIndex + i);
emit PrimateCreated(owner(), mintIndex + i, "random", 0);
}
| uint256 mintIndex = totalSupply();
for (uint256 i = 0; i < 10; i++) {
_safeMint(owner(), mintIndex + i);
emit PrimateCreated(owner(), mintIndex + i, "random", 0);
}
| 77,955 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.