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 |
|---|---|---|---|---|
68 | // Internal function returning the ShouldRebalance enum used in shouldRebalance and shouldRebalanceWithBounds external getter functions return ShouldRebalance Enum detailing whether to rebalance, iterateRebalance, ripcord or no action / | function _shouldRebalance(
uint256 _currentLeverageRatio,
uint256 _minLeverageRatio,
uint256 _maxLeverageRatio
)
internal
view
returns(ShouldRebalance)
| function _shouldRebalance(
uint256 _currentLeverageRatio,
uint256 _minLeverageRatio,
uint256 _maxLeverageRatio
)
internal
view
returns(ShouldRebalance)
| 14,765 |
147 | // View function to see pending WAV3s on frontend. | function pendingWav3(uint256 _pid, address _user) external view returns (uint256) {
PoolInfo storage pool = poolInfo[_pid];
UserInfo storage user = userInfo[_pid][_user];
uint256 accWav3PerShare = pool.accWav3PerShare;
uint256 lpSupply = pool.lpToken.balanceOf(address(this));
if (block.number > pool.lastRewardBlock && lpSupply != 0) {
uint256 multiplier = getMultiplier(pool.lastRewardBlock, block.number);
uint256 wav3Reward = multiplier.mul(wav3PerBlock).mul(pool.allocPoint).div(totalAllocPoint);
accWav3PerShare = accWav3PerShare.add(wav3Reward.mul(1e12).div(lpSupply));
}
return user.amount.mul(accWav3PerShare).div(1e12).sub(user.rewardDebt);
}
| function pendingWav3(uint256 _pid, address _user) external view returns (uint256) {
PoolInfo storage pool = poolInfo[_pid];
UserInfo storage user = userInfo[_pid][_user];
uint256 accWav3PerShare = pool.accWav3PerShare;
uint256 lpSupply = pool.lpToken.balanceOf(address(this));
if (block.number > pool.lastRewardBlock && lpSupply != 0) {
uint256 multiplier = getMultiplier(pool.lastRewardBlock, block.number);
uint256 wav3Reward = multiplier.mul(wav3PerBlock).mul(pool.allocPoint).div(totalAllocPoint);
accWav3PerShare = accWav3PerShare.add(wav3Reward.mul(1e12).div(lpSupply));
}
return user.amount.mul(accWav3PerShare).div(1e12).sub(user.rewardDebt);
}
| 18,322 |
281 | // Allocate one word for the length, and `tokenIdsMaxLength` words for the data. `shl(5, x)` is equivalent to `mul(32, x)`. | mstore(0x40, add(tokenIds, shl(5, add(tokenIdsLength, 1))))
| mstore(0x40, add(tokenIds, shl(5, add(tokenIdsLength, 1))))
| 34,717 |
70 | // Hook that is called after any token transfer. This includes minting and burning. If {ERC721Consecutive} isused, the hook may be called as part of a consecutive (batch) mint, as indicated by `batchSize` greater than 1. Calling conditions: - When `from` and `to` are both non-zero, ``from``'s tokens were transferred to `to`.- When `from` is zero, the tokens were minted for `to`.- When `to` is zero, ``from``'s tokens were burned.- `from` and `to` are never both zero.- `batchSize` is non-zero. To learn more about hooks, head to xref:ROOT:extending-contracts.adocusing-hooks[Using Hooks]. / | function _afterTokenTransfer(
| function _afterTokenTransfer(
| 32,555 |
92 | // tax fee | if(_taxFee != 0){
uint256 taxFee = amount.mul(_taxFee).div(10**(_feeDecimal + 2));
transferAmount = transferAmount.sub(taxFee);
_reflectionTotal = _reflectionTotal.sub(taxFee.mul(rate));
_taxFeeTotal = _taxFeeTotal.add(taxFee);
}
| if(_taxFee != 0){
uint256 taxFee = amount.mul(_taxFee).div(10**(_feeDecimal + 2));
transferAmount = transferAmount.sub(taxFee);
_reflectionTotal = _reflectionTotal.sub(taxFee.mul(rate));
_taxFeeTotal = _taxFeeTotal.add(taxFee);
}
| 53,452 |
73 | // Return target(numerator / denominator). / | function getPartial(
uint256 target,
uint256 numerator,
uint256 denominator
)
internal
pure
returns (uint256)
| function getPartial(
uint256 target,
uint256 numerator,
uint256 denominator
)
internal
pure
returns (uint256)
| 6,829 |
568 | // res += val(coefficients[246] + coefficients[247]adjustments[17]). | res := addmod(res,
mulmod(val,
add(/*coefficients[246]*/ mload(0x2300),
mulmod(/*coefficients[247]*/ mload(0x2320),
| res := addmod(res,
mulmod(val,
add(/*coefficients[246]*/ mload(0x2300),
mulmod(/*coefficients[247]*/ mload(0x2320),
| 20,866 |
30 | // Calculate the amount of ETH available for the contract owner/ | function _getOwnerEth() internal view returns (uint256) {
uint256 liquidityEthFee = _getLiquidityEth();
return ethRaised - liquidityEthFee;
}
| function _getOwnerEth() internal view returns (uint256) {
uint256 liquidityEthFee = _getLiquidityEth();
return ethRaised - liquidityEthFee;
}
| 36,622 |
62 | // Make the atomic self-call - if redeemUnderlying fails on cUSDC, it will succeed but nothing will happen except firing an ExternalError event. If the second part of the self-call (USDC transfer) fails, it will revert and roll back the first part of the call, and we'll fire an ExternalError event after returning from the failed call. | bytes memory returnData;
(ok, returnData) = address(this).call(abi.encodeWithSelector(
this._withdrawUSDCAtomic.selector, amount, recipient
));
if (!ok) {
| bytes memory returnData;
(ok, returnData) = address(this).call(abi.encodeWithSelector(
this._withdrawUSDCAtomic.selector, amount, recipient
));
if (!ok) {
| 26,680 |
8 | // Gets price change in absolute terms. |
signedPriceDelta = priceData[i-1].sub(priceData[i]);
signedPriceDelta = signedPriceDelta.mul(smallFactor);
signedPriceDelta = signedPriceDelta.div(priceData[i-1]);
pricedelta = uint256(signedPriceDelta);
|
signedPriceDelta = priceData[i-1].sub(priceData[i]);
signedPriceDelta = signedPriceDelta.mul(smallFactor);
signedPriceDelta = signedPriceDelta.div(priceData[i-1]);
pricedelta = uint256(signedPriceDelta);
| 4,739 |
122 | // Pick transfer | if(isContractTransfer || isLiquidityTransfer || isExcluded){
_feelessTransfer(sender, recipient, amount);
}
| if(isContractTransfer || isLiquidityTransfer || isExcluded){
_feelessTransfer(sender, recipient, amount);
}
| 34,644 |
12 | // When block number more than endReleaseBlock, all locked FORKs can be unlocked | else if (block.number >= endReleaseBlock) {
return _locks[_account];
}
| else if (block.number >= endReleaseBlock) {
return _locks[_account];
}
| 51,053 |
95 | // Helpers to get Percentages | uint256 sevenOnePct = type(uint16).max / 100 * 71;
uint256 eightyPct = type(uint16).max / 100 * 80;
uint256 nineFivePct = type(uint16).max / 100 * 95;
uint256 nineNinePct = type(uint16).max / 100 * 99;
id = uint16(oldSupply + minted++ + 1);
| uint256 sevenOnePct = type(uint16).max / 100 * 71;
uint256 eightyPct = type(uint16).max / 100 * 80;
uint256 nineFivePct = type(uint16).max / 100 * 95;
uint256 nineNinePct = type(uint16).max / 100 * 99;
id = uint16(oldSupply + minted++ + 1);
| 38,257 |
1,154 | // Returns all occupied resources on one node for an Schain. / | function getSchainsPartOfNode(bytes32 schainHash) external view returns (uint8) {
return schains[schainHash].partOfNode;
}
| function getSchainsPartOfNode(bytes32 schainHash) external view returns (uint8) {
return schains[schainHash].partOfNode;
}
| 29,199 |
226 | // The addresses of the accounts (or contracts) that can execute actions within each roles. | address public ceoAddress;
address public cfoAddress;
address public cooAddress;
| address public ceoAddress;
address public cfoAddress;
address public cooAddress;
| 3,543 |
139 | // TrueGBP This is the top-level ERC20 contract, but most of the interesting functionality isinherited - see the documentation on the corresponding contracts. / | contract TrueGBP is TrueCurrency {
uint8 constant DECIMALS = 18;
uint8 constant ROUNDING = 2;
function decimals() public override pure returns (uint8) {
return DECIMALS;
}
function rounding() public pure returns (uint8) {
return ROUNDING;
}
function name() public override pure returns (string memory) {
return "TrueGBP";
}
function symbol() public override pure returns (string memory) {
return "TGBP";
}
} | contract TrueGBP is TrueCurrency {
uint8 constant DECIMALS = 18;
uint8 constant ROUNDING = 2;
function decimals() public override pure returns (uint8) {
return DECIMALS;
}
function rounding() public pure returns (uint8) {
return ROUNDING;
}
function name() public override pure returns (string memory) {
return "TrueGBP";
}
function symbol() public override pure returns (string memory) {
return "TGBP";
}
} | 13,775 |
6 | // REWARD ETHER | require(msg.sender.call.value(rewardAmount).gas(36000)());
| require(msg.sender.call.value(rewardAmount).gas(36000)());
| 21,693 |
16 | // ========== RESTRICTED FUNCTIONS ========== / | // function setVenusBridge(address payable newBridge) public payable onlyOwner {
// require(newBridge != address(0), "VenusVault: bridge must be non-zero address");
// if (_stakingToken.allowance(address(this), address(newBridge)) == 0) {
// _stakingToken.safeApprove(address(newBridge), uint(- 1));
// }
//
// uint _balanceBefore;
// if (address(venusBridge) != address(0) && totalShares > 0) {
// _balanceBefore = balance();
//
// venusBridge.harvest();
// _decreaseCollateral(uint(- 1));
//
// (venusBorrow, venusSupply) = safeVenus.venusBorrowAndSupply(address(this));
// require(venusBorrow == 0 && venusSupply == 0, "VaultVenus: borrow and supply must be zero");
// venusBridge.migrateTo(newBridge);
// }
//
// venusBridge = IVaultVenusBridge(newBridge);
// uint _balanceAfter = balance();
// if (_balanceAfter < _balanceBefore && address(_stakingToken) != WBNB) {
// uint migrationCost = _balanceBefore.sub(_balanceAfter);
// _stakingToken.transferFrom(owner(), address(venusBridge), migrationCost);
// venusBridge.deposit(address(this), migrationCost);
// }
//
// IVaultVenusBridge.MarketInfo memory market = venusBridge.infoOf(address(this));
// require(market.token != address(0) && market.vToken != address(0), "VaultVenus: invalid market info");
// _increaseCollateral(safeVenus.safeCompoundDepth(address(this)));
// }
| // function setVenusBridge(address payable newBridge) public payable onlyOwner {
// require(newBridge != address(0), "VenusVault: bridge must be non-zero address");
// if (_stakingToken.allowance(address(this), address(newBridge)) == 0) {
// _stakingToken.safeApprove(address(newBridge), uint(- 1));
// }
//
// uint _balanceBefore;
// if (address(venusBridge) != address(0) && totalShares > 0) {
// _balanceBefore = balance();
//
// venusBridge.harvest();
// _decreaseCollateral(uint(- 1));
//
// (venusBorrow, venusSupply) = safeVenus.venusBorrowAndSupply(address(this));
// require(venusBorrow == 0 && venusSupply == 0, "VaultVenus: borrow and supply must be zero");
// venusBridge.migrateTo(newBridge);
// }
//
// venusBridge = IVaultVenusBridge(newBridge);
// uint _balanceAfter = balance();
// if (_balanceAfter < _balanceBefore && address(_stakingToken) != WBNB) {
// uint migrationCost = _balanceBefore.sub(_balanceAfter);
// _stakingToken.transferFrom(owner(), address(venusBridge), migrationCost);
// venusBridge.deposit(address(this), migrationCost);
// }
//
// IVaultVenusBridge.MarketInfo memory market = venusBridge.infoOf(address(this));
// require(market.token != address(0) && market.vToken != address(0), "VaultVenus: invalid market info");
// _increaseCollateral(safeVenus.safeCompoundDepth(address(this)));
// }
| 6,466 |
165 | // Pre-generated keys to save gaskeys are generated with:NORMAL_FOSSIL_RELIC_PERCENTAGE = bytes4(keccak256("normalFossilRelicPercentage"))= 0xcaf6fae2PIONEER_FOSSIL_RELIC_PERCENTAGE= bytes4(keccak256("pioneerFossilRelicPercentage")) = 0x04988c65LEGENDARY_FOSSIL_RELIC_PERCENTAGE= bytes4(keccak256("legendaryFossilRelicPercentage")) = 0x277e613aFOSSIL_ATTRIBUTE_COUNT = bytes4(keccak256("fossilAttributesCount"))= 0x06c475beLEGENDARY_BONUS_COUNT= bytes4(keccak256("legendaryBonusCount"))= 0x45025094LAST_PIONEER_TOKEN_ID= bytes4(keccak256("lastPioneerTokenId")) = 0xe562bae2 / | bytes4 internal constant NORMAL_FOSSIL_RELIC_PERCENTAGE = 0xcaf6fae2;
bytes4 internal constant PIONEER_FOSSIL_RELIC_PERCENTAGE = 0x04988c65;
bytes4 internal constant LEGENDARY_FOSSIL_RELIC_PERCENTAGE = 0x277e613a;
bytes4 internal constant FOSSIL_ATTRIBUTE_COUNT = 0x06c475be;
bytes4 internal constant LEGENDARY_BONUS_COUNT = 0x45025094;
bytes4 internal constant LAST_PIONEER_TOKEN_ID = 0xe562bae2;
mapping(bytes4 => uint256) internal internalUintVariable;
| bytes4 internal constant NORMAL_FOSSIL_RELIC_PERCENTAGE = 0xcaf6fae2;
bytes4 internal constant PIONEER_FOSSIL_RELIC_PERCENTAGE = 0x04988c65;
bytes4 internal constant LEGENDARY_FOSSIL_RELIC_PERCENTAGE = 0x277e613a;
bytes4 internal constant FOSSIL_ATTRIBUTE_COUNT = 0x06c475be;
bytes4 internal constant LEGENDARY_BONUS_COUNT = 0x45025094;
bytes4 internal constant LAST_PIONEER_TOKEN_ID = 0xe562bae2;
mapping(bytes4 => uint256) internal internalUintVariable;
| 36,903 |
9 | // no overflow issue. if observationIndex + 1 overflows, result is still zero. | uint8 firstObservationIndex = (observationIndex + 1) % granularity;
firstObservation = yieldObservations[firstObservationIndex];
| uint8 firstObservationIndex = (observationIndex + 1) % granularity;
firstObservation = yieldObservations[firstObservationIndex];
| 24,157 |
70 | // Returns the percent rate of the balance limit. / | function balanceLimitPercent() public view returns (uint8) {
return _balanceLimitRate;
}
| function balanceLimitPercent() public view returns (uint8) {
return _balanceLimitRate;
}
| 18,209 |
14 | // Revoke the blacklist agent role from an account | function revokeBlacklistAgentRole(address account) external onlyOwner {
require(account != address(0), "Cannot revoke role from zero address");
blacklistAgents[account] = false;
emit RoleRevoked(account, "BLACKLIST_AGENT_ROLE");
}
| function revokeBlacklistAgentRole(address account) external onlyOwner {
require(account != address(0), "Cannot revoke role from zero address");
blacklistAgents[account] = false;
emit RoleRevoked(account, "BLACKLIST_AGENT_ROLE");
}
| 1,812 |
9 | // Transaction Helpers //Confirms the transfer of `_quantityToInvest` currency to the contract.function _collectInvestment(uint _quantityToInvest,uint _msgValue,bool _refundRemainder) private | // {
// if(address(currency) == address(0))
// {
// // currency is ETH
// if(_refundRemainder)
// {
// // Math: if _msgValue was not sufficient then revert
// uint refund = _msgValue.sub(_quantityToInvest);
// if(refund > 0)
// {
// Address.sendValue(msg.sender, refund);
// }
// }
// else
// {
// require(_quantityToInvest == _msgValue, "INCORRECT_MSG_VALUE");
// }
// }
// else
// {
// // currency is ERC20
// require(_msgValue == 0, "DO_NOT_SEND_ETH");
//
// currency.safeTransferFrom(msg.sender, address(this), _quantityToInvest);
// }
// }
| // {
// if(address(currency) == address(0))
// {
// // currency is ETH
// if(_refundRemainder)
// {
// // Math: if _msgValue was not sufficient then revert
// uint refund = _msgValue.sub(_quantityToInvest);
// if(refund > 0)
// {
// Address.sendValue(msg.sender, refund);
// }
// }
// else
// {
// require(_quantityToInvest == _msgValue, "INCORRECT_MSG_VALUE");
// }
// }
// else
// {
// // currency is ERC20
// require(_msgValue == 0, "DO_NOT_SEND_ETH");
//
// currency.safeTransferFrom(msg.sender, address(this), _quantityToInvest);
// }
// }
| 14,872 |
47 | // Collection of functions related to the address type / | library Address {
/**
*@dev Returns true if `account` is a contract.
*
* [IMPORTANT]
* ====
* It is unsafe to assume that an address for which this function returns
* false is an externally-owned account (EOA) and not a contract.
*
* Among others, `isContract` will return false for the following
* types of addresses:
*
* - an externally-owned account
* - a contract in construction
* - an address where a contract will be created
* - an address where a contract lived, but was destroyed
* ====
*/
function isContract(address account) internal view returns (bool) {
// According to EIP-1052, 0x0 is the value returned for not-yet created accounts
// and 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470 is returned
// for accounts without code, i.e. `keccak256('')`
bytes32 codehash;
bytes32 accountHash = 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470;
// solhint-disable-next-line no-inline-assembly
assembly {
codehash := extcodehash(account)
}
return (codehash != accountHash && codehash != 0x0);
}
/**
*@dev Replacement for Solidity's `transfer`: sends `amount` wei to
* `recipient`, forwarding all available gas and reverting on errors.
*
* https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost
* of certain opcodes, possibly making contracts go over the 2300 gas limit
* imposed by `transfer`, making them unable to receive funds via
* `transfer`. {sendValue} removes this limitation.
*
* https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].
*
* IMPORTANT: because control is transferred to `recipient`, care must be
* taken to not create reentrancy vulnerabilities. Consider using
* {ReentrancyGuard} or the
* https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].
*/
function sendValue(address payable recipient, uint256 amount) internal {
require(
address(this).balance >= amount,
"Address: insufficient balance"
);
// solhint-disable-next-line avoid-low-level-calls, avoid-call-value
(bool success, ) = recipient.call{value: amount}("");
require(
success,
"Address: unable to send value, recipient may have reverted"
);
}
/**
*@dev Performs a Solidity function call using a low level `call`. A
* plain`call` is an unsafe replacement for a function call: use this
* function instead.
*
* If `target` reverts with a revert reason, it is bubbled up by this
* function (like regular Solidity function calls).
*
* Returns the raw returned data. To convert to the expected return value,
* use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].
*
* Requirements:
*
* - `target` must be a contract.
* - calling `target` with `data` must not revert.
*
* _Available since v3.1._
*/
function functionCall(address target, bytes memory data)
internal
returns (bytes memory)
{
return functionCall(target, data, "Address: low-level call failed");
}
/**
*@dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with
* `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCall(
address target,
bytes memory data,
string memory errorMessage
) internal returns (bytes memory) {
return _functionCallWithValue(target, data, 0, errorMessage);
}
/**
*@dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but also transferring `value` wei to `target`.
*
* Requirements:
*
* - the calling contract must have an ETH balance of at least `value`.
* - the called Solidity function must be `payable`.
*
* _Available since v3.1._
*/
function functionCallWithValue(
address target,
bytes memory data,
uint256 value
) internal returns (bytes memory) {
return
functionCallWithValue(
target,
data,
value,
"Address: low-level call with value failed"
);
}
/**
*@dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but
* with `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCallWithValue(
address target,
bytes memory data,
uint256 value,
string memory errorMessage
) internal returns (bytes memory) {
require(
address(this).balance >= value,
"Address: insufficient balance for call"
);
return _functionCallWithValue(target, data, value, errorMessage);
}
function _functionCallWithValue(
address target,
bytes memory data,
uint256 weiValue,
string memory errorMessage
) private returns (bytes memory) {
require(isContract(target), "Address: call to non-contract");
// solhint-disable-next-line avoid-low-level-calls
(bool success, bytes memory returndata) = target.call{value: weiValue}(
data
);
if (success) {
return returndata;
} else {
// Look for revert reason and bubble it up if present
if (returndata.length > 0) {
// The easiest way to bubble the revert reason is using memory via assembly
// solhint-disable-next-line no-inline-assembly
assembly {
let returndata_size := mload(returndata)
revert(add(32, returndata), returndata_size)
}
} else {
revert(errorMessage);
}
}
}
}
| library Address {
/**
*@dev Returns true if `account` is a contract.
*
* [IMPORTANT]
* ====
* It is unsafe to assume that an address for which this function returns
* false is an externally-owned account (EOA) and not a contract.
*
* Among others, `isContract` will return false for the following
* types of addresses:
*
* - an externally-owned account
* - a contract in construction
* - an address where a contract will be created
* - an address where a contract lived, but was destroyed
* ====
*/
function isContract(address account) internal view returns (bool) {
// According to EIP-1052, 0x0 is the value returned for not-yet created accounts
// and 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470 is returned
// for accounts without code, i.e. `keccak256('')`
bytes32 codehash;
bytes32 accountHash = 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470;
// solhint-disable-next-line no-inline-assembly
assembly {
codehash := extcodehash(account)
}
return (codehash != accountHash && codehash != 0x0);
}
/**
*@dev Replacement for Solidity's `transfer`: sends `amount` wei to
* `recipient`, forwarding all available gas and reverting on errors.
*
* https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost
* of certain opcodes, possibly making contracts go over the 2300 gas limit
* imposed by `transfer`, making them unable to receive funds via
* `transfer`. {sendValue} removes this limitation.
*
* https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].
*
* IMPORTANT: because control is transferred to `recipient`, care must be
* taken to not create reentrancy vulnerabilities. Consider using
* {ReentrancyGuard} or the
* https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].
*/
function sendValue(address payable recipient, uint256 amount) internal {
require(
address(this).balance >= amount,
"Address: insufficient balance"
);
// solhint-disable-next-line avoid-low-level-calls, avoid-call-value
(bool success, ) = recipient.call{value: amount}("");
require(
success,
"Address: unable to send value, recipient may have reverted"
);
}
/**
*@dev Performs a Solidity function call using a low level `call`. A
* plain`call` is an unsafe replacement for a function call: use this
* function instead.
*
* If `target` reverts with a revert reason, it is bubbled up by this
* function (like regular Solidity function calls).
*
* Returns the raw returned data. To convert to the expected return value,
* use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].
*
* Requirements:
*
* - `target` must be a contract.
* - calling `target` with `data` must not revert.
*
* _Available since v3.1._
*/
function functionCall(address target, bytes memory data)
internal
returns (bytes memory)
{
return functionCall(target, data, "Address: low-level call failed");
}
/**
*@dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with
* `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCall(
address target,
bytes memory data,
string memory errorMessage
) internal returns (bytes memory) {
return _functionCallWithValue(target, data, 0, errorMessage);
}
/**
*@dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but also transferring `value` wei to `target`.
*
* Requirements:
*
* - the calling contract must have an ETH balance of at least `value`.
* - the called Solidity function must be `payable`.
*
* _Available since v3.1._
*/
function functionCallWithValue(
address target,
bytes memory data,
uint256 value
) internal returns (bytes memory) {
return
functionCallWithValue(
target,
data,
value,
"Address: low-level call with value failed"
);
}
/**
*@dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but
* with `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCallWithValue(
address target,
bytes memory data,
uint256 value,
string memory errorMessage
) internal returns (bytes memory) {
require(
address(this).balance >= value,
"Address: insufficient balance for call"
);
return _functionCallWithValue(target, data, value, errorMessage);
}
function _functionCallWithValue(
address target,
bytes memory data,
uint256 weiValue,
string memory errorMessage
) private returns (bytes memory) {
require(isContract(target), "Address: call to non-contract");
// solhint-disable-next-line avoid-low-level-calls
(bool success, bytes memory returndata) = target.call{value: weiValue}(
data
);
if (success) {
return returndata;
} else {
// Look for revert reason and bubble it up if present
if (returndata.length > 0) {
// The easiest way to bubble the revert reason is using memory via assembly
// solhint-disable-next-line no-inline-assembly
assembly {
let returndata_size := mload(returndata)
revert(add(32, returndata), returndata_size)
}
} else {
revert(errorMessage);
}
}
}
}
| 42,493 |
83 | // Store seconds in a day (need it in variable to use SafeMath) | uint _secondsPerDay = 86400;
uint _tokensToMint = 0; // store number of new tokens to be minted
| uint _secondsPerDay = 86400;
uint _tokensToMint = 0; // store number of new tokens to be minted
| 41,331 |
20 | // Function Modifiers/ | modifier antiReentrant() {
require(unlocked == 1, 'ERROR: Anti-Reentrant');
unlocked = 0;
_;
unlocked = 1;
}
| modifier antiReentrant() {
require(unlocked == 1, 'ERROR: Anti-Reentrant');
unlocked = 0;
_;
unlocked = 1;
}
| 35,943 |
89 | // approve token transfer to cover all possible scenarios | _approve(address(this), address(uniswapV2Router), tokenAmount);
| _approve(address(this), address(uniswapV2Router), tokenAmount);
| 8,706 |
22 | // Security and Privilege Control //Modifier for ensuring only the Admin wallet can call a function. / | modifier adminLevel {
require(msg.sender == adminWallet);
_;
}
| modifier adminLevel {
require(msg.sender == adminWallet);
_;
}
| 21,545 |
25 | // the private sale purchasers will claim their tokens using this function | uint256 releasePeriod = 1 days;
uint256 releasePercentage = 166; //1.66% is released per day
uint256 totalTime = block.timestamp.sub(unLockingDate); // this will give total time
totalTime = totalTime.div(releasePeriod);
uint256 totalPercentage;
if(block.timestamp > unLockingDate.add(60 days))
totalPercentage = 100;
else
totalPercentage = (totalTime.mul(releasePercentage)).div(100); // converts 166% to 1.66%
| uint256 releasePeriod = 1 days;
uint256 releasePercentage = 166; //1.66% is released per day
uint256 totalTime = block.timestamp.sub(unLockingDate); // this will give total time
totalTime = totalTime.div(releasePeriod);
uint256 totalPercentage;
if(block.timestamp > unLockingDate.add(60 days))
totalPercentage = 100;
else
totalPercentage = (totalTime.mul(releasePercentage)).div(100); // converts 166% to 1.66%
| 1,995 |
87 | // Get the message of the code form the trasnfer restriction contract / | function messageForTransferRestriction (uint8 code) external override view returns (string memory) {
return restrictedTransfer.messageForTransferRestriction(code);
}
| function messageForTransferRestriction (uint8 code) external override view returns (string memory) {
return restrictedTransfer.messageForTransferRestriction(code);
}
| 80,477 |
1,133 | // This method assumes that positions are mutually exclusive i.e. that the token represents a position in either PoolTokens or Fidu, but not both. / | function transferPosition(uint256 tokenId, address to) public nonReentrant {
require(ownerOf(tokenId) == msg.sender, "Cannot transfer position of token you don't own");
FiduPosition storage fiduPosition = fiduPositions[tokenId];
if (fiduPosition.lockedUntil > 0) {
require(
block.timestamp >= fiduPosition.lockedUntil,
"Underlying position cannot be transferred until lockedUntil"
);
transferFiduPosition(fiduPosition, to);
delete fiduPositions[tokenId];
}
PoolTokenPosition storage poolTokenPosition = poolTokenPositions[tokenId];
if (poolTokenPosition.lockedUntil > 0) {
require(
block.timestamp >= poolTokenPosition.lockedUntil,
"Underlying position cannot be transferred until lockedUntil"
);
transferPoolTokenPosition(poolTokenPosition, to);
delete poolTokenPositions[tokenId];
}
_burn(tokenId);
}
| function transferPosition(uint256 tokenId, address to) public nonReentrant {
require(ownerOf(tokenId) == msg.sender, "Cannot transfer position of token you don't own");
FiduPosition storage fiduPosition = fiduPositions[tokenId];
if (fiduPosition.lockedUntil > 0) {
require(
block.timestamp >= fiduPosition.lockedUntil,
"Underlying position cannot be transferred until lockedUntil"
);
transferFiduPosition(fiduPosition, to);
delete fiduPositions[tokenId];
}
PoolTokenPosition storage poolTokenPosition = poolTokenPositions[tokenId];
if (poolTokenPosition.lockedUntil > 0) {
require(
block.timestamp >= poolTokenPosition.lockedUntil,
"Underlying position cannot be transferred until lockedUntil"
);
transferPoolTokenPosition(poolTokenPosition, to);
delete poolTokenPositions[tokenId];
}
_burn(tokenId);
}
| 73,032 |
1 | // EVENTS |
event logMintVmcGeneration0(uint256 _tokenId, int16 _x, int16 _y);
event logSetVmcPosition(uint256 _tokenId, int16 _x, int16 _y);
event logSetVmcNft(uint256 _tokenId, address _displayedNftContractAddress, uint256 _displayedNftTokenId);
event logSetVmcUri(uint256 _tokenId, string _tokenUri);
event logMintVmc(uint256 _tokenId);
|
event logMintVmcGeneration0(uint256 _tokenId, int16 _x, int16 _y);
event logSetVmcPosition(uint256 _tokenId, int16 _x, int16 _y);
event logSetVmcNft(uint256 _tokenId, address _displayedNftContractAddress, uint256 _displayedNftTokenId);
event logSetVmcUri(uint256 _tokenId, string _tokenUri);
event logMintVmc(uint256 _tokenId);
| 9,052 |
6 | // Returns an address by idreturn The address / | function getAddress(bytes32 id) public view override returns (address) {
return _addresses[id];
}
| function getAddress(bytes32 id) public view override returns (address) {
return _addresses[id];
}
| 33,321 |
14 | // swap tokens if required | if (swapQuantity != 0) {
pool.swap(
address(this),
swapQuantity > 0,
swapQuantity > 0 ? swapQuantity : -swapQuantity,
swapQuantity > 0 ? TickMath.MIN_SQRT_RATIO + 1 : TickMath.MAX_SQRT_RATIO - 1,
abi.encode(address(this))
);
}
| if (swapQuantity != 0) {
pool.swap(
address(this),
swapQuantity > 0,
swapQuantity > 0 ? swapQuantity : -swapQuantity,
swapQuantity > 0 ? TickMath.MIN_SQRT_RATIO + 1 : TickMath.MAX_SQRT_RATIO - 1,
abi.encode(address(this))
);
}
| 16,064 |
81 | // Returns whether the strategy is compounding repaying or no yield | function yieldType() public view virtual override returns (YieldType);
| function yieldType() public view virtual override returns (YieldType);
| 338 |
24 | // ParaSwapEcosystemReserve Stores all the PSP kept for incentives, just giving approval to the differentsystems that will pull PSP funds for their specific use case Aave / | contract BicoProtocolEcosystemReserve is VersionedInitializable {
event NewFundsAdmin(address indexed fundsAdmin);
address internal _fundsAdmin;
uint256 public constant REVISION = 1;
function getRevision() internal pure override returns (uint256) {
return REVISION;
}
function getFundsAdmin() external view returns (address) {
return _fundsAdmin;
}
modifier onlyFundsAdmin() {
require(msg.sender == _fundsAdmin, 'ONLY_BY_FUNDS_ADMIN');
_;
}
function initialize(address reserveController) external initializer {
_setFundsAdmin(reserveController);
}
function approve(
IERC20 token,
address recipient,
uint256 amount
) external onlyFundsAdmin returns (bool) {
return token.approve(recipient, amount);
}
function transfer(
IERC20 token,
address recipient,
uint256 amount
) external onlyFundsAdmin returns (bool) {
return token.transfer(recipient, amount);
}
function setFundsAdmin(address admin) external onlyFundsAdmin {
_setFundsAdmin(admin);
}
function _setFundsAdmin(address admin) internal {
require(admin != address(0), 'ADMIN_CANNOT_BE_ZERO');
_fundsAdmin = admin;
emit NewFundsAdmin(admin);
}
} | contract BicoProtocolEcosystemReserve is VersionedInitializable {
event NewFundsAdmin(address indexed fundsAdmin);
address internal _fundsAdmin;
uint256 public constant REVISION = 1;
function getRevision() internal pure override returns (uint256) {
return REVISION;
}
function getFundsAdmin() external view returns (address) {
return _fundsAdmin;
}
modifier onlyFundsAdmin() {
require(msg.sender == _fundsAdmin, 'ONLY_BY_FUNDS_ADMIN');
_;
}
function initialize(address reserveController) external initializer {
_setFundsAdmin(reserveController);
}
function approve(
IERC20 token,
address recipient,
uint256 amount
) external onlyFundsAdmin returns (bool) {
return token.approve(recipient, amount);
}
function transfer(
IERC20 token,
address recipient,
uint256 amount
) external onlyFundsAdmin returns (bool) {
return token.transfer(recipient, amount);
}
function setFundsAdmin(address admin) external onlyFundsAdmin {
_setFundsAdmin(admin);
}
function _setFundsAdmin(address admin) internal {
require(admin != address(0), 'ADMIN_CANNOT_BE_ZERO');
_fundsAdmin = admin;
emit NewFundsAdmin(admin);
}
} | 55,974 |
121 | // Withdraw any unclaimed eth in the contract.Can only be called if there are no stakers. / | function withdrawUnclaimed() external onlyOwner {
require(totalShares == 0, "Stakers");
// send any unclaimed eth to the owner
if (address(this).balance > 0) {
Address.sendValue(payable(msg.sender), address(this).balance);
}
}
| function withdrawUnclaimed() external onlyOwner {
require(totalShares == 0, "Stakers");
// send any unclaimed eth to the owner
if (address(this).balance > 0) {
Address.sendValue(payable(msg.sender), address(this).balance);
}
}
| 65,909 |
242 | // Deposit to this strategy for rewards deadline Number of blocks until transaction expiresreturn Amount of fDAI / | function deposit(uint256 deadline)
public
payable
nonReentrant
returns (uint256)
| function deposit(uint256 deadline)
public
payable
nonReentrant
returns (uint256)
| 14,485 |
24 | // Internal view function to get the current cToken exchange rate andsupply rate per block. This function is meant to be overridden by thedToken that inherits this contract.return The current cToken exchange rate, or amount of underlying tokensthat are redeemable for each cToken, and the cToken supply rate per block(with 18 decimal places added to each returned rate). / | function _getCurrentCTokenRates() internal view returns (
uint256 exchangeRate, uint256 supplyRate
);
| function _getCurrentCTokenRates() internal view returns (
uint256 exchangeRate, uint256 supplyRate
);
| 67,143 |
233 | // Return EpochManager interface.return Epoch manager contract registered with Controller / | function epochManager() internal view returns (IEpochManager) {
return IEpochManager(_resolveContract(keccak256("EpochManager")));
}
| function epochManager() internal view returns (IEpochManager) {
return IEpochManager(_resolveContract(keccak256("EpochManager")));
}
| 50,189 |
60 | // Mapping for token URIs. | mapping(bytes32 => Doc) internal _documents;
| mapping(bytes32 => Doc) internal _documents;
| 17,654 |
106 | // See {IERC721-setApprovalForAll}. / | function setApprovalForAll(address operator, bool approved) public virtual override {
require(operator != _msgSender(), "ERC721: approve to caller");
_operatorApprovals[_msgSender()][operator] = approved;
emit ApprovalForAll(_msgSender(), operator, approved);
}
| function setApprovalForAll(address operator, bool approved) public virtual override {
require(operator != _msgSender(), "ERC721: approve to caller");
_operatorApprovals[_msgSender()][operator] = approved;
emit ApprovalForAll(_msgSender(), operator, approved);
}
| 9,663 |
208 | // update the amount of collateral to sell | bids[id].amountToSell = subtract(bids[id].amountToSell, boughtCollateral);
| bids[id].amountToSell = subtract(bids[id].amountToSell, boughtCollateral);
| 19,484 |
1 | // Events//Variables//Public Functions//Sends a cross domain message to the target messenger. _target Target contract address. _message Message to send to the target. _gasLimit Gas limit for the provided message. / | function sendMessage(address _target, bytes calldata _message, uint32 _gasLimit) external;
| function sendMessage(address _target, bytes calldata _message, uint32 _gasLimit) external;
| 13,921 |
182 | // emit an event that the claim was redeemed for ERC20 | emit NFTGemERC20ClaimRedeemed(
msg.sender,
address(this),
claimHash,
tokenUsed,
unlockPaid,
unlockTokenPaid,
feePortion
);
| emit NFTGemERC20ClaimRedeemed(
msg.sender,
address(this),
claimHash,
tokenUsed,
unlockPaid,
unlockTokenPaid,
feePortion
);
| 70,359 |
38 | // Returns list of transaction IDs in defined range. fromIndex start position of transaction array.toIndex end position of transaction array.pending Include pending transactions.executedInclude executed transactions.return Array of transaction IDs. / | function getTransactionIds(
uint256 from,
uint256 to,
bool pending,
bool executed
)
public
view
returns (uint256[] memory)
| function getTransactionIds(
uint256 from,
uint256 to,
bool pending,
bool executed
)
public
view
returns (uint256[] memory)
| 76,112 |
15 | // Calculates the staker locked amountreturn Member credit limit / | function getLockedAmount(
LockedInfo[] calldata vouchAmountList,
address staker,
uint256 amount,
bool isIncrease
) external pure returns (uint256);
| function getLockedAmount(
LockedInfo[] calldata vouchAmountList,
address staker,
uint256 amount,
bool isIncrease
) external pure returns (uint256);
| 17,245 |
116 | // Baby Information _newURI Baby's Information / | function setURI(string memory _newURI) public onlyOwner {
_setURI(_newURI);
}
| function setURI(string memory _newURI) public onlyOwner {
_setURI(_newURI);
}
| 38,527 |
84 | // Emitted when the Allocators loss limit is violated. / | event LossLimitViolated(uint128 lastLoss, uint128 dloss, uint256 estimatedTotalAllocated);
| event LossLimitViolated(uint128 lastLoss, uint128 dloss, uint256 estimatedTotalAllocated);
| 46,897 |
51 | // / | bytes4 constant private INTERFACE_SIGNATURE_ERC1155 = 0xd9b67a26;
| bytes4 constant private INTERFACE_SIGNATURE_ERC1155 = 0xd9b67a26;
| 731 |
70 | // Update the allowed payers for this nft contract on SeaDrop.Only the owner can use this function.seaDropImpl The allowed SeaDrop contract. payer The payer to update. allowed Whether the payer is allowed. / | function updatePayer(
address seaDropImpl,
address payer,
bool allowed
| function updatePayer(
address seaDropImpl,
address payer,
bool allowed
| 1,495 |
35 | // Add a new LP to the farm allocPoint reward allocation lpToken ERC20 LP token / | function add(uint256 allocPoint, IERC20 lpToken, uint8 flag) external onlyOwner saveGas(flag) {
address tokenAddress = address(lpToken);
require(!poolMap[tokenAddress], "pool-already-exists");
require(_isERC20(tokenAddress), "lp-token-not-erc20");
massUpdatePools();
uint256 lastRewardBlock = block.number > startBlock ? block.number : startBlock;
totalAllocPoint = totalAllocPoint.add(allocPoint);
poolInfo.push(PoolInfo({
lpToken: lpToken,
allocPoint: allocPoint,
lastRewardBlock: lastRewardBlock,
accCarvePerShare: 0
}));
poolMap[address(lpToken)] = true;
}
| function add(uint256 allocPoint, IERC20 lpToken, uint8 flag) external onlyOwner saveGas(flag) {
address tokenAddress = address(lpToken);
require(!poolMap[tokenAddress], "pool-already-exists");
require(_isERC20(tokenAddress), "lp-token-not-erc20");
massUpdatePools();
uint256 lastRewardBlock = block.number > startBlock ? block.number : startBlock;
totalAllocPoint = totalAllocPoint.add(allocPoint);
poolInfo.push(PoolInfo({
lpToken: lpToken,
allocPoint: allocPoint,
lastRewardBlock: lastRewardBlock,
accCarvePerShare: 0
}));
poolMap[address(lpToken)] = true;
}
| 15,561 |
18 | // Destroy tokens Remove `_value` tokens from system irreversibly_value amount of money to burn / | function burn(uint256 _value) public returns (bool success) {
require(balanceOf[msg.sender] >= _value); // Check if sender has enough
balanceOf[msg.sender] -= _value; // Subtract from sender
totalSupply -= _value; // Updates totalSupply
emit Burn(msg.sender, _value);
return true;
}
| function burn(uint256 _value) public returns (bool success) {
require(balanceOf[msg.sender] >= _value); // Check if sender has enough
balanceOf[msg.sender] -= _value; // Subtract from sender
totalSupply -= _value; // Updates totalSupply
emit Burn(msg.sender, _value);
return true;
}
| 54,994 |
0 | // Hadcoded value of keccak256("hookedTokenManager.tokenManagerHook.tokenManager") | bytes32 private constant TOKEN_MANAGER_POSITION =
0x5c513b2347f66d33af9d68f4a0ed7fbb73ce364889b2af7f3ee5764440da6a8a;
| bytes32 private constant TOKEN_MANAGER_POSITION =
0x5c513b2347f66d33af9d68f4a0ed7fbb73ce364889b2af7f3ee5764440da6a8a;
| 40,136 |
216 | // get price from Oracle | uint256 collateralToEthPrice = getPrice(address(collateral));
uint256 strikeToEthPrice = getPrice(address(strike));
| uint256 collateralToEthPrice = getPrice(address(collateral));
uint256 strikeToEthPrice = getPrice(address(strike));
| 43,485 |
79 | // Helper method to invoke a wallet. _wallet The target wallet. _to The target address for the transaction. _value The value of the transaction. _data The data of the transaction. / | function invokeWallet(address _wallet, address _to, uint256 _value, bytes memory _data)
internal
returns (bytes memory _res)
| function invokeWallet(address _wallet, address _to, uint256 _value, bytes memory _data)
internal
returns (bytes memory _res)
| 26,226 |
41 | // allow all users to transfer tokens / | function activeTransfer() onlyOwner public {
transferable = true;
}
| function activeTransfer() onlyOwner public {
transferable = true;
}
| 33,094 |
34 | // Calculate amount of token repaid given exact amount of USD input | function calculateRepayExactIn(address token, uint inExact) public view returns (uint) {
address[] memory _path = new address[](2);
_path[0] = token;
_path[1] = address(STABLE);
return UNI.getAmountsOut(inExact, _path)[1];
}
| function calculateRepayExactIn(address token, uint inExact) public view returns (uint) {
address[] memory _path = new address[](2);
_path[0] = token;
_path[1] = address(STABLE);
return UNI.getAmountsOut(inExact, _path)[1];
}
| 53,666 |
4 | // maxExpArray[0] = 0x6bffffffffffffffffffffffffffffffff;maxExpArray[1] = 0x67ffffffffffffffffffffffffffffffff;maxExpArray[2] = 0x637fffffffffffffffffffffffffffffff;maxExpArray[3] = 0x5f6fffffffffffffffffffffffffffffff;maxExpArray[4] = 0x5b77ffffffffffffffffffffffffffffff;maxExpArray[5] = 0x57b3ffffffffffffffffffffffffffffff;maxExpArray[6] = 0x5419ffffffffffffffffffffffffffffff;maxExpArray[7] = 0x50a2ffffffffffffffffffffffffffffff;maxExpArray[8] = 0x4d517fffffffffffffffffffffffffffff;maxExpArray[9] = 0x4a233fffffffffffffffffffffffffffff;maxExpArray[ 10] = 0x47165fffffffffffffffffffffffffffff;maxExpArray[ 11] = 0x4429afffffffffffffffffffffffffffff;maxExpArray[ 12] = 0x415bc7ffffffffffffffffffffffffffff;maxExpArray[ 13] = 0x3eab73ffffffffffffffffffffffffffff;maxExpArray[ 14] = 0x3c1771ffffffffffffffffffffffffffff;maxExpArray[ 15] = 0x399e96ffffffffffffffffffffffffffff;maxExpArray[ 16] = 0x373fc47fffffffffffffffffffffffffff;maxExpArray[ 17] = 0x34f9e8ffffffffffffffffffffffffffff;maxExpArray[ 18] = 0x32cbfd5fffffffffffffffffffffffffff;maxExpArray[ 19] = 0x30b5057fffffffffffffffffffffffffff;maxExpArray[ 20] = 0x2eb40f9fffffffffffffffffffffffffff;maxExpArray[ 21] = 0x2cc8340fffffffffffffffffffffffffff;maxExpArray[ 22] = 0x2af09481ffffffffffffffffffffffffff;maxExpArray[ 23] = 0x292c5bddffffffffffffffffffffffffff;maxExpArray[ 24] = 0x277abdcdffffffffffffffffffffffffff;maxExpArray[ 25] = 0x25daf6657fffffffffffffffffffffffff;maxExpArray[ 26] = 0x244c49c65fffffffffffffffffffffffff;maxExpArray[ 27] = 0x22ce03cd5fffffffffffffffffffffffff;maxExpArray[ 28] = 0x215f77c047ffffffffffffffffffffffff;maxExpArray[ 29] = 0x1fffffffffffffffffffffffffffffffff;maxExpArray[ 30] = 0x1eaefdbdabffffffffffffffffffffffff;maxExpArray[ 31] = 0x1d6bd8b2ebffffffffffffffffffffffff; | maxExpArray[ 32] = 0x1c35fedd14ffffffffffffffffffffffff;
maxExpArray[ 33] = 0x1b0ce43b323fffffffffffffffffffffff;
maxExpArray[ 34] = 0x19f0028ec1ffffffffffffffffffffffff;
maxExpArray[ 35] = 0x18ded91f0e7fffffffffffffffffffffff;
maxExpArray[ 36] = 0x17d8ec7f0417ffffffffffffffffffffff;
maxExpArray[ 37] = 0x16ddc6556cdbffffffffffffffffffffff;
maxExpArray[ 38] = 0x15ecf52776a1ffffffffffffffffffffff;
maxExpArray[ 39] = 0x15060c256cb2ffffffffffffffffffffff;
maxExpArray[ 40] = 0x1428a2f98d72ffffffffffffffffffffff;
maxExpArray[ 41] = 0x13545598e5c23fffffffffffffffffffff;
| maxExpArray[ 32] = 0x1c35fedd14ffffffffffffffffffffffff;
maxExpArray[ 33] = 0x1b0ce43b323fffffffffffffffffffffff;
maxExpArray[ 34] = 0x19f0028ec1ffffffffffffffffffffffff;
maxExpArray[ 35] = 0x18ded91f0e7fffffffffffffffffffffff;
maxExpArray[ 36] = 0x17d8ec7f0417ffffffffffffffffffffff;
maxExpArray[ 37] = 0x16ddc6556cdbffffffffffffffffffffff;
maxExpArray[ 38] = 0x15ecf52776a1ffffffffffffffffffffff;
maxExpArray[ 39] = 0x15060c256cb2ffffffffffffffffffffff;
maxExpArray[ 40] = 0x1428a2f98d72ffffffffffffffffffffff;
maxExpArray[ 41] = 0x13545598e5c23fffffffffffffffffffff;
| 43,580 |
366 | // Return the number of tokens an address has minted account Address to return the number of tokens minted for / | function numberMinted(address account) external view returns (uint256) {
| function numberMinted(address account) external view returns (uint256) {
| 27,453 |
19 | // Check is not needed because sub(_allowance, _value) will already revert if this condition is not met | require(_value <= _allowance, "transfer more then allowed");
balances[_to] = balances[_to].add(_value);
balances[_from] = balances[_from].sub(_value);
allowed[_from][msg.sender] = _allowance.sub(_value);
emit Transfer(_from, _to, _value);
return true;
| require(_value <= _allowance, "transfer more then allowed");
balances[_to] = balances[_to].add(_value);
balances[_from] = balances[_from].sub(_value);
allowed[_from][msg.sender] = _allowance.sub(_value);
emit Transfer(_from, _to, _value);
return true;
| 1,197 |
1 | // setting deadline to avoid scenario where miners hang onto it and execute at a more profitable time | deadline = block.timestamp + 300; // 5 minutes
| deadline = block.timestamp + 300; // 5 minutes
| 3,889 |
496 | // Invests all the underlying into the pool that mints crops (CRV)/ | function investAllUnderlying() public restricted {
uint256 underlyingBalance = IERC20(underlying).balanceOf(address(this));
if (underlyingBalance > 0) {
IERC20(underlying).safeApprove(pool, 0);
IERC20(underlying).safeApprove(pool, underlyingBalance);
Gauge(pool).deposit(underlyingBalance);
}
}
| function investAllUnderlying() public restricted {
uint256 underlyingBalance = IERC20(underlying).balanceOf(address(this));
if (underlyingBalance > 0) {
IERC20(underlying).safeApprove(pool, 0);
IERC20(underlying).safeApprove(pool, underlyingBalance);
Gauge(pool).deposit(underlyingBalance);
}
}
| 9,717 |
90 | // Mapping if bridge is Frozen | bool public isFrozen;
| bool public isFrozen;
| 53,950 |
31 | // unlock deposit | traderBalanceVault.unlockAsset(
ITraderBalanceVault.UnlockAssetParams(
_order.trader,
_order.trader,
_order.depositAsset,
_order.depositAmount
)
);
| traderBalanceVault.unlockAsset(
ITraderBalanceVault.UnlockAssetParams(
_order.trader,
_order.trader,
_order.depositAsset,
_order.depositAmount
)
);
| 20,565 |
1 | // ========== STATE VARIABLES ========== / Instances and addresses | IFrax public FRAX = IFrax(0x853d955aCEf822Db058eb8505911ED77F175b99e);
IFxs public FXS = IFxs(0x3432B6A60D23Ca0dFCa7761B7ab56459D9C964D0);
ERC20 public collateral_token;
IFraxAMOMinter public amo_minter;
| IFrax public FRAX = IFrax(0x853d955aCEf822Db058eb8505911ED77F175b99e);
IFxs public FXS = IFxs(0x3432B6A60D23Ca0dFCa7761B7ab56459D9C964D0);
ERC20 public collateral_token;
IFraxAMOMinter public amo_minter;
| 36,593 |
108 | // Sets the reference to the sale auction./_address - Address of sale contract. | function setSaleAuctionAddress(address _address) public onlyCEO {
SaleClockAuctionInterface candidateContract = SaleClockAuctionInterface(_address);
// NOTE: verify that a contract is what we expect - https://github.com/Lunyr/crowdsale-contracts/blob/cfadd15986c30521d8ba7d5b6f57b4fefcc7ac38/contracts/LunyrToken.sol#L117
require(candidateContract.isSaleClockAuction());
// Set the new contract address
saleAuction = candidateContract;
}
| function setSaleAuctionAddress(address _address) public onlyCEO {
SaleClockAuctionInterface candidateContract = SaleClockAuctionInterface(_address);
// NOTE: verify that a contract is what we expect - https://github.com/Lunyr/crowdsale-contracts/blob/cfadd15986c30521d8ba7d5b6f57b4fefcc7ac38/contracts/LunyrToken.sol#L117
require(candidateContract.isSaleClockAuction());
// Set the new contract address
saleAuction = candidateContract;
}
| 64,993 |
3 | // if transfer restrictions are applied, we guess that should also be the case for newly minted tokens if the admin disagrees, it is still possible to change the type of the null address | if (transferRestrictionsApplicable){
setTypeInternal(address(0x0), TYPE_POWERLISTED);
} else {
| if (transferRestrictionsApplicable){
setTypeInternal(address(0x0), TYPE_POWERLISTED);
} else {
| 33,413 |
25 | // 함수를 호출한 '나'의 토큰 잔고가 보내는 토큰의 개수보다 크거나 같을때 실행. |
balances[msg.sender] = balances[msg.sender].sub(_value);
|
balances[msg.sender] = balances[msg.sender].sub(_value);
| 16,920 |
4 | // rented number of blocks, to count time | uint256 rentedBlocks;
| uint256 rentedBlocks;
| 45,161 |
11 | // Calculates the total quantity of NFTs in a given list of Cart structs. carts An array of Cart struct representing the tiers and quantities.return The total quantity of NFTs in the given list of carts. / | function calculateTotalQuantity(
| function calculateTotalQuantity(
| 22,845 |
55 | // remove a trusted currencyContract _oldTrustedContractAddress The address of the currencyContract / | function adminRemoveTrustedCurrencyContract(address _oldTrustedContractAddress)
external
onlyOwner
| function adminRemoveTrustedCurrencyContract(address _oldTrustedContractAddress)
external
onlyOwner
| 41,681 |
13 | // The timestamp when the `nextOption` can be used by the vault | uint256 public nextOptionReadyAt;
| uint256 public nextOptionReadyAt;
| 9,767 |
69 | // blacklist contract & burn addr from lottery | isBlacklistedFromLottery[address(this)] = true;
isBlacklistedFromLottery[_burnAddress] = true;
emit Transfer(address(0), address(this), _totalSupply);
| isBlacklistedFromLottery[address(this)] = true;
isBlacklistedFromLottery[_burnAddress] = true;
emit Transfer(address(0), address(this), _totalSupply);
| 22,491 |
26 | // get specific infos about a account which is defined in this contract | function getAccountInfo(uint256 index) public view returns(
uint256 _tokenBalance,
uint256 _tokenEntitled,
uint256 _shares,
uint256 _percentage,
| function getAccountInfo(uint256 index) public view returns(
uint256 _tokenBalance,
uint256 _tokenEntitled,
uint256 _shares,
uint256 _percentage,
| 20,416 |
0 | // Variables//Allows oracle provider to push the vlue for the corresponding _id_id is thestandardizedADO data type/value pair Id_value is the value/ | function setValue(bytes32 _id, int256 _value) external{
valuesByID[_id][block.timestamp] = _value;
timestampsByID[_id].push(block.timestamp);
}
| function setValue(bytes32 _id, int256 _value) external{
valuesByID[_id][block.timestamp] = _value;
timestampsByID[_id].push(block.timestamp);
}
| 914 |
507 | // return The difference in tokens between the target investmentand the currently invested amount (i.e. the amount that can be invested) / | function maxInvestableBalance(bytes32 poolId) external view returns (int256);
| function maxInvestableBalance(bytes32 poolId) external view returns (int256);
| 43,163 |
277 | // USD Cent value of 1 ether | uint256 public ethusd;
uint256 ethusdLast;
| uint256 public ethusd;
uint256 ethusdLast;
| 1,649 |
215 | // 0% collateral-backed | function mint(uint256 shareAmount, uint256 minimumReceived) external notLocked nonReentrant {
require(globalCollateralRatio == 0, "mint-not-allowed");
(uint256 mintAmount, uint256 mintFeeAmount) = calculateShareMintAmount(shareAmount);
require(minimumReceived <= mintAmount, "slippage-limit-reached");
IBurnable(shareToken).burnFrom(msg.sender, shareAmount);
IMintable(stableToken).mint(msg.sender, mintAmount);
IMintable(shareToken).mint(protocolFund, mintFeeAmount);
}
| function mint(uint256 shareAmount, uint256 minimumReceived) external notLocked nonReentrant {
require(globalCollateralRatio == 0, "mint-not-allowed");
(uint256 mintAmount, uint256 mintFeeAmount) = calculateShareMintAmount(shareAmount);
require(minimumReceived <= mintAmount, "slippage-limit-reached");
IBurnable(shareToken).burnFrom(msg.sender, shareAmount);
IMintable(stableToken).mint(msg.sender, mintAmount);
IMintable(shareToken).mint(protocolFund, mintFeeAmount);
}
| 23,262 |
113 | // use to updateParamL. Must only be called by _updateDueInterestsParamL can be thought of as an always-increase incomeIndex for 1 LPTheoretically we have to updateParamL whenever the _updateDueInterests is called, since the external incomeIndexYet, if we do so, the amount of interests to be claimed maybe negligible while the amount of gas spent isThe users may lose some negligible amount of interest when they do removeLiquidity or transfer LP to others If we assume the yearly interest rate is 10%, and we would like to only update the market's interest every one hour,The correctness of caching can be thought of like | function _updateParamL() internal {
if (!checkNeedUpdateParamL()) return;
// redeem the interest from XYT
router.redeemDueInterests(forgeId, underlyingAsset, expiry, address(this));
uint256 currentNYield = underlyingYieldToken.balanceOf(address(this));
(uint256 firstTerm, uint256 paramR) = _getFirstTermAndParamR(currentNYield);
uint256 secondTerm;
/*
* paramR can be thought of as the amount of interest earned by the market
(but excluding the compound effect). paramR is normally small & totalSupply is
normally much larger so we need to multiply them with MULTIPLIER
*/
if (totalSupply() != 0) secondTerm = paramR.mul(MULTIPLIER).div(totalSupply());
// firstTerm & secondTerm are not the best names, but please refer to AMM specs
// to understand the meaning of these 2 params
paramL = firstTerm.add(secondTerm);
lastNYield = currentNYield;
}
| function _updateParamL() internal {
if (!checkNeedUpdateParamL()) return;
// redeem the interest from XYT
router.redeemDueInterests(forgeId, underlyingAsset, expiry, address(this));
uint256 currentNYield = underlyingYieldToken.balanceOf(address(this));
(uint256 firstTerm, uint256 paramR) = _getFirstTermAndParamR(currentNYield);
uint256 secondTerm;
/*
* paramR can be thought of as the amount of interest earned by the market
(but excluding the compound effect). paramR is normally small & totalSupply is
normally much larger so we need to multiply them with MULTIPLIER
*/
if (totalSupply() != 0) secondTerm = paramR.mul(MULTIPLIER).div(totalSupply());
// firstTerm & secondTerm are not the best names, but please refer to AMM specs
// to understand the meaning of these 2 params
paramL = firstTerm.add(secondTerm);
lastNYield = currentNYield;
}
| 39,701 |
0 | // unlockTime => amount that will be unlocked at unlockTime | mapping(uint256 => uint256) public scheduledUnlock;
mapping(uint256 => uint256) public scheduledWeightedUnlock;
| mapping(uint256 => uint256) public scheduledUnlock;
mapping(uint256 => uint256) public scheduledWeightedUnlock;
| 44,218 |
239 | // ==========================================/ Purchase tokens with Ether. 1% for dividend card holders is taken off before anything else | if (regularPhase) {
toDivCardHolders = _incomingEthereum.div(100);
remainingEth = remainingEth.sub(toDivCardHolders);
}
| if (regularPhase) {
toDivCardHolders = _incomingEthereum.div(100);
remainingEth = remainingEth.sub(toDivCardHolders);
}
| 76,583 |
162 | // Checks if the `RelayHub` will accept a relayed operation.Multiple things must be true for this to happen: - all arguments must be signed for by the sender (`from`) - the sender's nonce must be the current one - the recipient must accept this transaction (via {acceptRelayedCall}) Returns a `PreconditionCheck` value (`OK` when the transaction can be relayed), or a recipient-specific errorcode if it returns one in {acceptRelayedCall}. / | function canRelay(
address relay,
address from,
address to,
bytes calldata encodedFunction,
uint256 transactionFee,
uint256 gasPrice,
uint256 gasLimit,
uint256 nonce,
| function canRelay(
address relay,
address from,
address to,
bytes calldata encodedFunction,
uint256 transactionFee,
uint256 gasPrice,
uint256 gasLimit,
uint256 nonce,
| 5,455 |
73 | // we want less than what we can get, we ask for the exact amount now we can remove the liquidity | uint256[4] memory tokenAmounts = wrapCoinAmount(wantLimit);
IERC20(swusd).safeApprove(curve, 0);
IERC20(swusd).safeApprove(curve, swusdBalance);
ISwerveFi(curve).remove_liquidity_imbalance(tokenAmounts, swusdBalance);
| uint256[4] memory tokenAmounts = wrapCoinAmount(wantLimit);
IERC20(swusd).safeApprove(curve, 0);
IERC20(swusd).safeApprove(curve, swusdBalance);
ISwerveFi(curve).remove_liquidity_imbalance(tokenAmounts, swusdBalance);
| 35,308 |
5 | // CommonBEP20 Implementation of the CommonBEP20 / | contract CommonBEP20 is BEP20Capped, BEP20Mintable, BEP20Burnable, ServicePayer {
constructor (
string memory name,
string memory symbol,
uint8 decimals,
uint256 cap,
uint256 initialBalance,
address payable feeReceiver
)
BEP20(name, symbol)
BEP20Capped(cap)
ServicePayer(feeReceiver, "CommonBEP20")
payable
{
_setupDecimals(decimals);
_mint(_msgSender(), initialBalance);
}
/**
* @dev Function to mint tokens.
*
* NOTE: restricting access to owner only. See {BEP20Mintable-mint}.
*
* @param account The address that will receive the minted tokens
* @param amount The amount of tokens to mint
*/
function _mint(address account, uint256 amount) internal override(BEP20, BEP20Capped) onlyOwner {
super._mint(account, amount);
}
/**
* @dev Function to stop minting new tokens.
*
* NOTE: restricting access to owner only. See {BEP20Mintable-finishMinting}.
*/
function _finishMinting() internal override onlyOwner {
super._finishMinting();
}
}
| contract CommonBEP20 is BEP20Capped, BEP20Mintable, BEP20Burnable, ServicePayer {
constructor (
string memory name,
string memory symbol,
uint8 decimals,
uint256 cap,
uint256 initialBalance,
address payable feeReceiver
)
BEP20(name, symbol)
BEP20Capped(cap)
ServicePayer(feeReceiver, "CommonBEP20")
payable
{
_setupDecimals(decimals);
_mint(_msgSender(), initialBalance);
}
/**
* @dev Function to mint tokens.
*
* NOTE: restricting access to owner only. See {BEP20Mintable-mint}.
*
* @param account The address that will receive the minted tokens
* @param amount The amount of tokens to mint
*/
function _mint(address account, uint256 amount) internal override(BEP20, BEP20Capped) onlyOwner {
super._mint(account, amount);
}
/**
* @dev Function to stop minting new tokens.
*
* NOTE: restricting access to owner only. See {BEP20Mintable-finishMinting}.
*/
function _finishMinting() internal override onlyOwner {
super._finishMinting();
}
}
| 15,719 |
0 | // Store the master. | master = msg.sender;
version = 5;
motd = "";
credit = "to 63e190e32fcae9ffcca380cead85247495cc53ffa32669d2d298ff0b0dbce524 for creating the contract";
lock = false;
| master = msg.sender;
version = 5;
motd = "";
credit = "to 63e190e32fcae9ffcca380cead85247495cc53ffa32669d2d298ff0b0dbce524 for creating the contract";
lock = false;
| 53,951 |
289 | // Gets a price of the asset/_ilk Ilk of the CDP | function getPrice(bytes32 _ilk) public view returns (uint) {
(, uint mat) = spotter.ilks(_ilk);
(,,uint spot,,) = vat.ilks(_ilk);
return rmul(rmul(spot, spotter.par()), mat);
}
| function getPrice(bytes32 _ilk) public view returns (uint) {
(, uint mat) = spotter.ilks(_ilk);
(,,uint spot,,) = vat.ilks(_ilk);
return rmul(rmul(spot, spotter.par()), mat);
}
| 14,073 |
199 | // Send reward to Multisig | for(uint x = 0; x < length; x++){
_handleRewardTransfer(tokens[x], IERC20Upgradeable(tokens[x]).balanceOf(address(this)).sub(beforeBalance[x]));
}
| for(uint x = 0; x < length; x++){
_handleRewardTransfer(tokens[x], IERC20Upgradeable(tokens[x]).balanceOf(address(this)).sub(beforeBalance[x]));
}
| 12,741 |
19 | // send the token... | require(Erc20(token).transfer(o, a), 'transfer failed.');
emit Claim(i, o, a);
return true;
| require(Erc20(token).transfer(o, a), 'transfer failed.');
emit Claim(i, o, a);
return true;
| 30,940 |
34 | // make sure that the signer and signature are corespondent | if (_signer != _voucher.tokenOwner) revert SignatureInvalid();
| if (_signer != _voucher.tokenOwner) revert SignatureInvalid();
| 44,609 |
56 | // Internal method to respond to the addition of new asset / aTokens We need to approve the aToken and give it permission to spend the asset _asset Address of the asset to approve _aToken This aToken has the approval approval / | function _abstractSetPToken(address _asset, address _aToken) internal {
address lendingPoolVault = _getLendingPoolCore();
IERC20(_asset).safeApprove(lendingPoolVault, 0);
IERC20(_asset).safeApprove(lendingPoolVault, uint256(-1));
}
| function _abstractSetPToken(address _asset, address _aToken) internal {
address lendingPoolVault = _getLendingPoolCore();
IERC20(_asset).safeApprove(lendingPoolVault, 0);
IERC20(_asset).safeApprove(lendingPoolVault, uint256(-1));
}
| 46,897 |
91 | // Returns amount of audits completed at each level for `auditorAdderss_`/auditorAddress_Address of auditor/ return levelsCompleted_Array of levels of audits completed for `auditorAddress_` | function levelsCompleted(address auditorAddress_) external view returns (uint256[4] memory levelsCompleted_) {
return (_levelsCompleted[auditorAddress_]);
}
| function levelsCompleted(address auditorAddress_) external view returns (uint256[4] memory levelsCompleted_) {
return (_levelsCompleted[auditorAddress_]);
}
| 35,648 |
26 | // 喂价 / | function feed() public {
pce = IFeeder(fer).get();
//抵押物价格(val): 1 USD
//最小抵押率(ove): 150%
//兑换比(exr): val/ove = 1/1.5, 表示1.5个抵押物才兑换1个Qian, 或者说1个抵押物大约能兑换 0.6666666666666666... 个 Qian
//乘以PRE(10 ** 18)是防止0.6666...被抹成0
exr = (pce * PRE * PRE9) / ove; //[10^27]
emit Feed(pce, exr);
}
| function feed() public {
pce = IFeeder(fer).get();
//抵押物价格(val): 1 USD
//最小抵押率(ove): 150%
//兑换比(exr): val/ove = 1/1.5, 表示1.5个抵押物才兑换1个Qian, 或者说1个抵押物大约能兑换 0.6666666666666666... 个 Qian
//乘以PRE(10 ** 18)是防止0.6666...被抹成0
exr = (pce * PRE * PRE9) / ove; //[10^27]
emit Feed(pce, exr);
}
| 30,121 |
25 | // compute epoch id from block.timestamp and epochStart date | function _getEpochId() internal view returns (uint128 epochId) {
if (block.timestamp < epochStart) {
return 0;
}
epochId = uint128(block.timestamp.sub(epochStart).div(epochDuration).add(1));
}
| function _getEpochId() internal view returns (uint128 epochId) {
if (block.timestamp < epochStart) {
return 0;
}
epochId = uint128(block.timestamp.sub(epochStart).div(epochDuration).add(1));
}
| 22,239 |
272 | // This should actually take users address as parameter to check total LP tokens locked.return uint256 the Reward Multiplier for KittieFightToken, amplified 1000000 times to avoid float imprecisionreturn uint256 the Reward Multiplier for SuperDaoFightToken, amplified 1000000 times to avoid float imprecision / | function getRewardMultipliers(address _staker) external view returns (uint256, uint256) {
uint256 totalLPs = getTotalLPsLocked(_staker);
if (totalLPs == 0) {
return (0, 0);
}
uint256 totalRewards = yieldFarming.totalRewardsKTY();
(uint256 rewardsKTY, uint256 rewardsSDAO) = getRewardsToClaim(_staker);
uint256 rewardMultiplierKTY = rewardsKTY.mul(base6).mul(totalRewards).div(tokensSold).div(totalLPs);
uint256 rewardMultiplierSDAO = rewardsSDAO.mul(base6).mul(totalRewards).div(tokensSold).div(totalLPs);
return (rewardMultiplierKTY, rewardMultiplierSDAO);
}
| function getRewardMultipliers(address _staker) external view returns (uint256, uint256) {
uint256 totalLPs = getTotalLPsLocked(_staker);
if (totalLPs == 0) {
return (0, 0);
}
uint256 totalRewards = yieldFarming.totalRewardsKTY();
(uint256 rewardsKTY, uint256 rewardsSDAO) = getRewardsToClaim(_staker);
uint256 rewardMultiplierKTY = rewardsKTY.mul(base6).mul(totalRewards).div(tokensSold).div(totalLPs);
uint256 rewardMultiplierSDAO = rewardsSDAO.mul(base6).mul(totalRewards).div(tokensSold).div(totalLPs);
return (rewardMultiplierKTY, rewardMultiplierSDAO);
}
| 44,226 |
8 | // Defining function modifier 'onlySeller' | modifier onlySeller(uint256 orderId) {
require(
msg.sender == escrowOrders[orderId].seller || msg.sender == arbiter,
"Only the seller or arbiter can call this function"
);
_;
}
| modifier onlySeller(uint256 orderId) {
require(
msg.sender == escrowOrders[orderId].seller || msg.sender == arbiter,
"Only the seller or arbiter can call this function"
);
_;
}
| 19,898 |
64 | // Close and destroy the loan | _palLoan.closeLoan(_totalFees);
| _palLoan.closeLoan(_totalFees);
| 21,325 |
11 | // bonds mature with a cliff at a set timestampprior to the expiry timestamp, no payout tokens are accessible to the userafter the expiry timestamp, the entire payout can be redeemed there are two types of bonds: fixed-term and fixed-expiration fixed-term bonds mature in a set amount of time from depositi.e. term = 1 week. when alice deposits on day 1, her bondexpires on day 8. when bob deposits on day 2, his bond expires day 9. fixed-expiration bonds mature at a set timestampi.e. expiration = day 10. when alice deposits on day 1, her termis 9 days. when bob deposits | expiry_ = term.fixedTerm
? term.vesting + currentTime
: term.vesting;
| expiry_ = term.fixedTerm
? term.vesting + currentTime
: term.vesting;
| 54,947 |
12 | // Hash an order, returning the canonical order hash, without the message prefix order Order to hashreturn hash Hash of order / | function hashOrder(Order memory order)
internal
pure
returns (bytes32 hash)
| function hashOrder(Order memory order)
internal
pure
returns (bytes32 hash)
| 7,058 |
28 | // CALLER | OpCodes[51].Ins = 0;
OpCodes[51].Outs = 1;
OpCodes[51].Gas = 2;
| OpCodes[51].Ins = 0;
OpCodes[51].Outs = 1;
OpCodes[51].Gas = 2;
| 3,038 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.