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 |
|---|---|---|---|---|
43 | // Emit event to the logs so can be effectively used later | emit CowsArrived(master, cows);
| emit CowsArrived(master, cows);
| 57,695 |
21 | // calculates number of FFEIF received given X eth _curEth current amount of eth in contract _newEth eth being spentreturn amount of ticket purchased / | function keysRec(uint256 _curEth, uint256 _newEth)
internal
view
returns (uint256)
| function keysRec(uint256 _curEth, uint256 _newEth)
internal
view
returns (uint256)
| 32,209 |
11 | // Compute the cost of arbitration. It is recommended not to increase it often, as it can be highly time and gas consuming for the arbitrated contracts to cope with fee augmentation._extraData Can be used to give additional info on the dispute to be created. return fee Amount to be paid. / | function arbitrationCost(bytes _extraData) public view returns(uint fee);
| function arbitrationCost(bytes _extraData) public view returns(uint fee);
| 42,838 |
46 | // gets the current number of tokens staked for a day lockedTS the timestamp to get the staked tokens for / | function getCurrentStakedUntil(uint256 lockedTS) external view returns (uint96) {
uint32 nCheckpoints = numTotalStakingCheckpoints[lockedTS];
return nCheckpoints > 0 ? totalStakingCheckpoints[lockedTS][nCheckpoints - 1].stake : 0;
}
| function getCurrentStakedUntil(uint256 lockedTS) external view returns (uint96) {
uint32 nCheckpoints = numTotalStakingCheckpoints[lockedTS];
return nCheckpoints > 0 ? totalStakingCheckpoints[lockedTS][nCheckpoints - 1].stake : 0;
}
| 17,037 |
241 | // Transfer asset from this contract to sender./assetData Byte array encoded for the respective asset proxy./amount Amount of asset to transfer to sender. | function transferOut(
bytes memory assetData,
uint256 amount
)
internal
{
assetData.transferFrom(
address(this),
msg.sender,
amount
| function transferOut(
bytes memory assetData,
uint256 amount
)
internal
{
assetData.transferFrom(
address(this),
msg.sender,
amount
| 49,088 |
48 | // Updates LXL management settings. _manager Account that governs LXL contract settings. _swiftResolverToken Token to mark participants in swift resolution. _userRewardToken Token for LXL user rewards. _wETH Standard contract reference to wrap ether._MAX_DURATION Time limit in seconds on token lockup - default 63113904 (2-year). _resolutionRate Rate to determine resolution fee for locker (e.g., 20 = 5% of remainder). _swiftResolverTokenBalance Token balance required to perform swift resolution._userReward Reward amount granted to LXL users in `userRewardToken`. _lockerTerms General terms wrapping LXL. / | function updateLockerSettings(
address _manager,
address _swiftResolverToken,
address _userRewardToken,
address _wETH,
uint256 _MAX_DURATION,
uint256 _resolutionRate,
uint256 _swiftResolverTokenBalance,
uint256 _userReward,
string calldata _lockerTerms
| function updateLockerSettings(
address _manager,
address _swiftResolverToken,
address _userRewardToken,
address _wETH,
uint256 _MAX_DURATION,
uint256 _resolutionRate,
uint256 _swiftResolverTokenBalance,
uint256 _userReward,
string calldata _lockerTerms
| 64,612 |
0 | // ========== DEPENDENCIES ========== // ====== VARIABLES ====== // ====== STRUCTS ====== / | struct Info {
uint256 rate; // in ten-thousandths ( 5000 = 0.5% )
address recipient;
}
| struct Info {
uint256 rate; // in ten-thousandths ( 5000 = 0.5% )
address recipient;
}
| 47,038 |
9 | // track intt nodes | mapping(bytes32 => bool) public parentNodeActive;
| mapping(bytes32 => bool) public parentNodeActive;
| 12,092 |
64 | // update balances | walletTokenBalance[_tokenAddress][_withdrawalAddress] = walletTokenBalance[_tokenAddress][_withdrawalAddress].add(_amount);
tokenBalance[_tokenAddress] = tokenBalance[_tokenAddress].add(_amount);
_id = depositId++;
lockedToken[_id].tokenAddress = _tokenAddress;
lockedToken[_id].withdrawalAddress = _withdrawalAddress;
lockedToken[_id].tokenAmount = _amount;
lockedToken[_id].unlockTime = _unlockTime;
lockedToken[_id].withdrawn = false;
| walletTokenBalance[_tokenAddress][_withdrawalAddress] = walletTokenBalance[_tokenAddress][_withdrawalAddress].add(_amount);
tokenBalance[_tokenAddress] = tokenBalance[_tokenAddress].add(_amount);
_id = depositId++;
lockedToken[_id].tokenAddress = _tokenAddress;
lockedToken[_id].withdrawalAddress = _withdrawalAddress;
lockedToken[_id].tokenAmount = _amount;
lockedToken[_id].unlockTime = _unlockTime;
lockedToken[_id].withdrawn = false;
| 51,577 |
2 | // Can only draw after this time. | uint256 public drawTime;
| uint256 public drawTime;
| 7,903 |
56 | // Upgrades a proxy to the newest implementation of a contract and forwards a function call to it.This is useful to initialize the proxied contract. proxy Proxy to be upgraded. implementation Address of the Implementation. data Data to send as msg.data in the low level call.It should include the signature and the parameters of the function to be called, as described in / | function upgradeAndCall(AdminUpgradeabilityProxy proxy, address implementation, bytes memory data) payable public onlyOwner {
proxy.upgradeToAndCall.value(msg.value)(implementation, data);
}
| function upgradeAndCall(AdminUpgradeabilityProxy proxy, address implementation, bytes memory data) payable public onlyOwner {
proxy.upgradeToAndCall.value(msg.value)(implementation, data);
}
| 6,455 |
233 | // Gets the current votes balance for `account` account The address to get votes balancereturn The number of current votes for `account` / | function getCurrentVotes(address account)
external
view
returns (uint256)
| function getCurrentVotes(address account)
external
view
returns (uint256)
| 23,125 |
5 | // Has the user designate a delegate to vote on behalf of them/Delegate can be set to 0 or userAddress for the user to vote on/ their own behalf/delegate Delegate address | function updateDelegate(address delegate)
external
override
| function updateDelegate(address delegate)
external
override
| 8,859 |
163 | // Reverts if the first 32 bytes of the bytes array is not equal to requestId requestId bytes32 data bytes / | modifier validateMultiWordResponseId(
bytes32 requestId,
bytes memory data
| modifier validateMultiWordResponseId(
bytes32 requestId,
bytes memory data
| 52,899 |
284 | // Override parent bind function and disable. / | function bind(
address token,
uint256 balance,
uint256 denorm
| function bind(
address token,
uint256 balance,
uint256 denorm
| 10,722 |
20 | // 通过存入nest来初始化资金池,没存入x个nest,资金池增加x个dcu和x个nest,同时用户得到x个dcu/amount 存入数量 | function deposit(uint amount) external;
| function deposit(uint amount) external;
| 26,773 |
4 | // do bitwise comparison, if i-th bit is turned on, multiply ratio by hardcoded values of sqrt(1.0001^-(2^i))2^128 where 0 <= i <= 19 | uint256 ratio = (absTick & 0x1 != 0)
? 0xfffcb933bd6fad37aa2d162d1a594001
: 0x100000000000000000000000000000000;
if (absTick & 0x2 != 0) ratio = (ratio * 0xfff97272373d413259a46990580e213a) >> 128;
if (absTick & 0x4 != 0) ratio = (ratio * 0xfff2e50f5f656932ef12357cf3c7fdcc) >> 128;
if (absTick & 0x8 != 0) ratio = (ratio * 0xffe5caca7e10e4e61c3624eaa0941cd0) >> 128;
if (absTick & 0x10 != 0) ratio = (ratio * 0xffcb9843d60f6159c9db58835c926644) >> 128;
if (absTick & 0x20 != 0) ratio = (ratio * 0xff973b41fa98c081472e6896dfb254c0) >> 128;
if (absTick & 0x40 != 0) ratio = (ratio * 0xff2ea16466c96a3843ec78b326b52861) >> 128;
if (absTick & 0x80 != 0) ratio = (ratio * 0xfe5dee046a99a2a811c461f1969c3053) >> 128;
| uint256 ratio = (absTick & 0x1 != 0)
? 0xfffcb933bd6fad37aa2d162d1a594001
: 0x100000000000000000000000000000000;
if (absTick & 0x2 != 0) ratio = (ratio * 0xfff97272373d413259a46990580e213a) >> 128;
if (absTick & 0x4 != 0) ratio = (ratio * 0xfff2e50f5f656932ef12357cf3c7fdcc) >> 128;
if (absTick & 0x8 != 0) ratio = (ratio * 0xffe5caca7e10e4e61c3624eaa0941cd0) >> 128;
if (absTick & 0x10 != 0) ratio = (ratio * 0xffcb9843d60f6159c9db58835c926644) >> 128;
if (absTick & 0x20 != 0) ratio = (ratio * 0xff973b41fa98c081472e6896dfb254c0) >> 128;
if (absTick & 0x40 != 0) ratio = (ratio * 0xff2ea16466c96a3843ec78b326b52861) >> 128;
if (absTick & 0x80 != 0) ratio = (ratio * 0xfe5dee046a99a2a811c461f1969c3053) >> 128;
| 26,937 |
179 | // Static call into ERC20.allowance(). Reverts if the call fails for some reason (should never fail)./ | function staticAllowance(ERC20 _token, address _owner, address _spender) internal view returns (uint256) {
bytes memory allowanceCallData = abi.encodeWithSelector(
_token.allowance.selector,
_owner,
_spender
);
(bool success, uint256 allowance) = staticInvoke(_token, allowanceCallData);
require(success, ERROR_TOKEN_ALLOWANCE_REVERTED);
return allowance;
}
| function staticAllowance(ERC20 _token, address _owner, address _spender) internal view returns (uint256) {
bytes memory allowanceCallData = abi.encodeWithSelector(
_token.allowance.selector,
_owner,
_spender
);
(bool success, uint256 allowance) = staticInvoke(_token, allowanceCallData);
require(success, ERROR_TOKEN_ALLOWANCE_REVERTED);
return allowance;
}
| 17,595 |
14 | // {_pid} Id of the pool {_amount} Amount to be staked return {bool} Status of stake/ | function stake(uint256 _pid, uint256 _amount) external override returns (bool) {
Pool memory pool = poolInfo[_pid];
IERC20Upgradeable token = IERC20Upgradeable(pool.token);
require(
token.allowance(msg.sender, address(this)) >= _amount,
"Decubate : Set allowance first!"
);
bool success = token.transferFrom(msg.sender, address(this), _amount);
| function stake(uint256 _pid, uint256 _amount) external override returns (bool) {
Pool memory pool = poolInfo[_pid];
IERC20Upgradeable token = IERC20Upgradeable(pool.token);
require(
token.allowance(msg.sender, address(this)) >= _amount,
"Decubate : Set allowance first!"
);
bool success = token.transferFrom(msg.sender, address(this), _amount);
| 23,015 |
40 | // Handler safely corrects allowance if allowance is insufficient. _token Evaluates allowance of this token. _spender Address gaining allowance. _amount Required allowance amount. / | function _handleAllowance(
IERC20 _token,
address _spender,
uint256 _amount
| function _handleAllowance(
IERC20 _token,
address _spender,
uint256 _amount
| 9,892 |
51 | // Convert rate to 1ETH to token or token to 1 ETH | rate = ((rate * 10**18) / _amount);
| rate = ((rate * 10**18) / _amount);
| 35,173 |
12 | // Try to make flash-loan exploit harder to do by only allowing externally owned addresses. | require(msg.sender == tx.origin, "Jeweler: must use EOA");
_;
| require(msg.sender == tx.origin, "Jeweler: must use EOA");
_;
| 12,993 |
2 | // manage voters and vote state | mapping(address => bool) public voters;
| mapping(address => bool) public voters;
| 31,752 |
0 | // EVENTS //The Birth event is fired whenever a new team comes into existence. | event Birth(uint256 teamId, string name, address owner);
| event Birth(uint256 teamId, string name, address owner);
| 47,372 |
1 | // Lock the Ichi in the contract | IERC20(Ichi).transferFrom(msg.sender, address(this), _amount);
| IERC20(Ichi).transferFrom(msg.sender, address(this), _amount);
| 31,238 |
287 | // Clear the reference to sire from the matron (REQUIRED! Having siringWithId set is what marks a matron as being pregnant.) | delete matron.siringWithId;
| delete matron.siringWithId;
| 41,055 |
273 | // Calculates the amount of reserve in exchange for DVD./tokenAmount Token value in wei to use in the conversion./ return Reserve amount in wei. | function dvdToReserve(uint256 tokenAmount) public view returns (uint256) {
return _calculateDVDToReserve(tokenAmount, dvdTotalSupply(), totalReserve);
}
| function dvdToReserve(uint256 tokenAmount) public view returns (uint256) {
return _calculateDVDToReserve(tokenAmount, dvdTotalSupply(), totalReserve);
}
| 80,750 |
30 | // A method to add a list of trusted nodes_nodeAddrs a list of trusted nodes/ | function addNodeAddr(address[] calldata _nodeAddrs) override external onlyExecutor{
for (uint256 i = 0; i< _nodeAddrs.length; i++){
address _nodeAddr = _nodeAddrs[i];
require(!nodeAddrSta[_nodeAddr], "This node is already a pledged node");
nodeAddrSta[_nodeAddr] = true;
uint256 _nodeAddrIndex = nodeAddrIndex[_nodeAddr];
if (_nodeAddrIndex == 0){
_nodeAddrIndex = ++nodeNum;
nodeAddrIndex[_nodeAddr] = _nodeAddrIndex;
nodeIndexAddr[_nodeAddrIndex] = _nodeAddr;
addNodeStake(_nodeAddrIndex);
}
emit AddNodeAddr(_nodeAddrs[i]);
}
}
| function addNodeAddr(address[] calldata _nodeAddrs) override external onlyExecutor{
for (uint256 i = 0; i< _nodeAddrs.length; i++){
address _nodeAddr = _nodeAddrs[i];
require(!nodeAddrSta[_nodeAddr], "This node is already a pledged node");
nodeAddrSta[_nodeAddr] = true;
uint256 _nodeAddrIndex = nodeAddrIndex[_nodeAddr];
if (_nodeAddrIndex == 0){
_nodeAddrIndex = ++nodeNum;
nodeAddrIndex[_nodeAddr] = _nodeAddrIndex;
nodeIndexAddr[_nodeAddrIndex] = _nodeAddr;
addNodeStake(_nodeAddrIndex);
}
emit AddNodeAddr(_nodeAddrs[i]);
}
}
| 47,537 |
17 | // gas and return values during simulation preOpGas the gas used for validation (including preValidationGas) prefund the required prefund for this operation sigFailed validateUserOp's (or paymaster's) signature check failed validAfter - first timestamp this UserOp is valid (merging account and paymaster time-range) validUntil - last timestamp this UserOp is valid (merging account and paymaster time-range) paymasterContext returned by validatePaymasterUserOp (to be passed into postOp) / | struct ReturnInfo {
uint256 preOpGas;
uint256 prefund;
bool sigFailed;
uint48 validAfter;
uint48 validUntil;
bytes paymasterContext;
}
| struct ReturnInfo {
uint256 preOpGas;
uint256 prefund;
bool sigFailed;
uint48 validAfter;
uint48 validUntil;
bytes paymasterContext;
}
| 2,674 |
383 | // Gets type of oraclize query for a given Oraclize Query ID. myid Oraclize Query ID identifying the query for which the result is being received.return _typeof It could be of type "quote","quotation","cover","claim" etc. / | function getApiIdTypeOf(bytes32 myid) external view returns(bytes4) {
return allAPIid[myid].typeOf;
}
| function getApiIdTypeOf(bytes32 myid) external view returns(bytes4) {
return allAPIid[myid].typeOf;
}
| 22,343 |
17 | // if initial, needs to be run again in 28 days to complete the shut down | bookEndTime = now + 28 days;
margin[0] += feeOverpay;
| bookEndTime = now + 28 days;
margin[0] += feeOverpay;
| 7,365 |
4 | // A specific function to add funds to the Twallet after the Twallet contract is created. Anyone can addFunds to the twallet. The receive() and fallback() functions below also allow the twallet to be funded if the addFunds is not called. | //function addFunds() payable public returns (bool success) {
// emit Funded(msg.sender, msg.value);
//}
| //function addFunds() payable public returns (bool success) {
// emit Funded(msg.sender, msg.value);
//}
| 48,879 |
175 | // Check that we are past the cliff period for this ticket type | require(getBlockTimestamp() > ticketType.trancheLength.mul(ticketType.cliffTranches).add(TGE), "GenTickets: Ticket is still within cliff period");
| require(getBlockTimestamp() > ticketType.trancheLength.mul(ticketType.cliffTranches).add(TGE), "GenTickets: Ticket is still within cliff period");
| 47,292 |
50 | // Overrides _mint to include attribute generation/_to The token recipient/_tokenId The ERC-721 token id | function _mint(address _to, uint256 _tokenId) internal override {
// Mint the token
super._mint(_to, _tokenId);
// Increment the total supply
unchecked {
++settings.totalSupply;
}
// Generate the token attributes
if (!settings.metadataRenderer.onMinted(_tokenId)) revert NO_METADATA_GENERATED();
}
| function _mint(address _to, uint256 _tokenId) internal override {
// Mint the token
super._mint(_to, _tokenId);
// Increment the total supply
unchecked {
++settings.totalSupply;
}
// Generate the token attributes
if (!settings.metadataRenderer.onMinted(_tokenId)) revert NO_METADATA_GENERATED();
}
| 29,924 |
4 | // Sends an amount of existing coins from any caller to an address | function send(address receiver, uint amount) public {
require(amount <= balances[msg.sender], "Insufficient balance.");
balances[msg.sender] -= amount;
balances[receiver] += amount;
emit Sent(msg.sender, receiver, amount);
}
| function send(address receiver, uint amount) public {
require(amount <= balances[msg.sender], "Insufficient balance.");
balances[msg.sender] -= amount;
balances[receiver] += amount;
emit Sent(msg.sender, receiver, amount);
}
| 82,611 |
4 | // Transfer currency from msg.sender to the recipient/if currency is ETH, the value must have been sent in the execute call and is transferred directly/if currency is token, the value is transferred from msg.sender via permit2/currency The currency to transfer/recipient The recipient of the currency/amount The amount of currency to transfer/permit2 The deployed permit2 address | function transferFromDirectFiller(address currency, address recipient, uint256 amount, IPermit2 permit2) internal {
if (isNative(currency)) {
(bool success,) = recipient.call{value: amount}("");
if (!success) revert NativeTransferFailed();
} else {
permit2.transferFrom(msg.sender, recipient, SafeCast.toUint160(amount), currency);
}
}
| function transferFromDirectFiller(address currency, address recipient, uint256 amount, IPermit2 permit2) internal {
if (isNative(currency)) {
(bool success,) = recipient.call{value: amount}("");
if (!success) revert NativeTransferFailed();
} else {
permit2.transferFrom(msg.sender, recipient, SafeCast.toUint160(amount), currency);
}
}
| 16,520 |
269 | // claim release reward token | function claimReward(uint8 _pid) public {
LaunchPadInfo storage pool = launchPadInfo[_pid];
UserInfo storage user = userInfo[_pid][ msg.sender ];
if( user.lockedAmount > user.pickedAmount ){
uint256 _pickedAmount = 0;
if( block.timestamp > pool.releaseStart ){
_pickedAmount = user.lockedAmount.mul(block.timestamp.sub(pool.releaseStart)).div(pool.lockPeriod);
if( _pickedAmount > user.lockedAmount ){
_pickedAmount = user.lockedAmount;
}
_pickedAmount = _pickedAmount.sub( user.pickedAmount );
user.pickedAmount = user.pickedAmount.add(_pickedAmount);
TransferHelper.safeTransfer( address(pool.launchToken), msg.sender , _pickedAmount );
}
}
}
| function claimReward(uint8 _pid) public {
LaunchPadInfo storage pool = launchPadInfo[_pid];
UserInfo storage user = userInfo[_pid][ msg.sender ];
if( user.lockedAmount > user.pickedAmount ){
uint256 _pickedAmount = 0;
if( block.timestamp > pool.releaseStart ){
_pickedAmount = user.lockedAmount.mul(block.timestamp.sub(pool.releaseStart)).div(pool.lockPeriod);
if( _pickedAmount > user.lockedAmount ){
_pickedAmount = user.lockedAmount;
}
_pickedAmount = _pickedAmount.sub( user.pickedAmount );
user.pickedAmount = user.pickedAmount.add(_pickedAmount);
TransferHelper.safeTransfer( address(pool.launchToken), msg.sender , _pickedAmount );
}
}
}
| 58,855 |
227 | // Called by existed member if wish to Withdraw membership. / | function withdrawMembership() public {
require(!ms.isPause() && ms.isMember(msg.sender));
require(dAppToken.totalLockedBalance(msg.sender, now) == 0); //solhint-disable-line
require(!tf.isLockedForMemberVote(msg.sender)); // No locked tokens for Member/Governance voting
// require(cr.getAllPendingRewardOfUser(msg.sender) == 0); // No pending reward to be claimed(claim assesment).
require(dAppToken.tokensUnlockable(msg.sender, "CLA") == 0, "Member should have no CLA unlockable tokens");
// gv.removeDelegation(msg.sender);
dAppToken.burnFrom(msg.sender, tk.balanceOf(msg.sender));
_updateRole(msg.sender, uint(Role.Member), false);
dAppToken.removeFromWhitelist(msg.sender); // need clarification on whitelist
}
| function withdrawMembership() public {
require(!ms.isPause() && ms.isMember(msg.sender));
require(dAppToken.totalLockedBalance(msg.sender, now) == 0); //solhint-disable-line
require(!tf.isLockedForMemberVote(msg.sender)); // No locked tokens for Member/Governance voting
// require(cr.getAllPendingRewardOfUser(msg.sender) == 0); // No pending reward to be claimed(claim assesment).
require(dAppToken.tokensUnlockable(msg.sender, "CLA") == 0, "Member should have no CLA unlockable tokens");
// gv.removeDelegation(msg.sender);
dAppToken.burnFrom(msg.sender, tk.balanceOf(msg.sender));
_updateRole(msg.sender, uint(Role.Member), false);
dAppToken.removeFromWhitelist(msg.sender); // need clarification on whitelist
}
| 12,843 |
149 | // Method to get a direct quote between the given tokens - might not be always availableas there might not be any direct liquidity between them / | function quoteDirect(
IERC20 fromToken,
IERC20 toToken,
uint256 amount
)
public
view
returns (uint256 returnAmount, uint256[ex_count] memory swapAmounts)
| function quoteDirect(
IERC20 fromToken,
IERC20 toToken,
uint256 amount
)
public
view
returns (uint256 returnAmount, uint256[ex_count] memory swapAmounts)
| 36,806 |
16 | // Allows to perform method only after many beneficiaries call it with the same arguments/ | modifier onlyManyBeneficiaries {
if (checkHowManyBeneficiaries(howManyBeneficiariesDecide)) {
bool update = (insideCallSender == address(0));
if (update) {
insideCallSender = msg.sender;
insideCallCount = howManyBeneficiariesDecide;
}
_;
if (update) {
insideCallSender = address(0);
insideCallCount = 0;
}
}
}
| modifier onlyManyBeneficiaries {
if (checkHowManyBeneficiaries(howManyBeneficiariesDecide)) {
bool update = (insideCallSender == address(0));
if (update) {
insideCallSender = msg.sender;
insideCallCount = howManyBeneficiariesDecide;
}
_;
if (update) {
insideCallSender = address(0);
insideCallCount = 0;
}
}
}
| 37,336 |
1 | // The amount of DAI per ABQ for the bid | uint128 pricePerToken;
| uint128 pricePerToken;
| 54,686 |
71 | // Determine the current sale round/ return integer representing the index of the current sale round | function currentRoundIndex() internal view returns (uint8 roundNum) {
roundNum = currentRoundIndexByDate();
/// round determined by conjunction of both time and total sold tokens
while(roundNum < 4 && totalSupply > roundCaps[roundNum]) {
roundNum++;
}
}
| function currentRoundIndex() internal view returns (uint8 roundNum) {
roundNum = currentRoundIndexByDate();
/// round determined by conjunction of both time and total sold tokens
while(roundNum < 4 && totalSupply > roundCaps[roundNum]) {
roundNum++;
}
}
| 26,314 |
7 | // initial mint | _safeMint(msg.sender, 20);
| _safeMint(msg.sender, 20);
| 10,707 |
154 | // Perform raw minting | function _mintWithoutValidation(address to, uint amount) internal {
for (uint i = 0; i < amount; i++) {
_mint(to, totalSupply);
emit Mint(to, totalSupply);
totalSupply += 1;
}
}
| function _mintWithoutValidation(address to, uint amount) internal {
for (uint i = 0; i < amount; i++) {
_mint(to, totalSupply);
emit Mint(to, totalSupply);
totalSupply += 1;
}
}
| 50,690 |
45 | // swap tokens and send some to marketing, whilst keeping the eth for buyback burn | uint256 contractTokenBalance = balanceOf(address(this));
if (contractTokenBalance >= minimumTokensBeforeSwap) {
if (rBuybackBurn != 0) {
uint256 toBeBurned = tokenFromReflection(rBuybackBurn);
rBuybackBurn = 0;
uint256 toBeSentToMarketing = contractTokenBalance.sub(toBeBurned);
swapTokensForETHTo(toBeSentToMarketing, marketingAddr);
swapTokensForETHTo(toBeBurned, payable(this));
} else {
| uint256 contractTokenBalance = balanceOf(address(this));
if (contractTokenBalance >= minimumTokensBeforeSwap) {
if (rBuybackBurn != 0) {
uint256 toBeBurned = tokenFromReflection(rBuybackBurn);
rBuybackBurn = 0;
uint256 toBeSentToMarketing = contractTokenBalance.sub(toBeBurned);
swapTokensForETHTo(toBeSentToMarketing, marketingAddr);
swapTokensForETHTo(toBeBurned, payable(this));
} else {
| 39,570 |
6 | // collection address => creator address | mapping(address => address) public collectionCreators;
| mapping(address => address) public collectionCreators;
| 40,279 |
3 | // Burn some MIX in association with a 32 byte hash. hash The hash associated with the burn. / | function burn(bytes32 hash) external payable hasValue {
hashBurnt[hash] += msg.value;
emit Burn(hash, msg.value);
}
| function burn(bytes32 hash) external payable hasValue {
hashBurnt[hash] += msg.value;
emit Burn(hash, msg.value);
}
| 49,550 |
293 | // Transfers ownership of a HEX stake instance (HSI) contract to a new address. This is a pivileged operation only Hedron.sol can call. End users can use the NFT tokenize / detokenize to handle HSI transfers. currentHolder Address to transfer the HSI contract from. hsiIndex Index of the HSI contract's address in the currentHolder's HSI list. hsiAddress Address of the HSI contract to be transfered. newHolder Address to transfer to HSI contract to. / | function hsiTransfer (
address currentHolder,
uint256 hsiIndex,
address hsiAddress,
address newHolder
)
external
| function hsiTransfer (
address currentHolder,
uint256 hsiIndex,
address hsiAddress,
address newHolder
)
external
| 27,354 |
90 | // Swap native ETH for CRV on Curve/amount - amount to swap/ return amount of CRV obtained after the swap | function _swapEthToCrv(uint256 amount) internal returns (uint256) {
return
crvEthSwap.exchange_underlying{value: amount}(
CRVETH_ETH_INDEX,
CRVETH_CRV_INDEX,
amount,
0
);
}
| function _swapEthToCrv(uint256 amount) internal returns (uint256) {
return
crvEthSwap.exchange_underlying{value: amount}(
CRVETH_ETH_INDEX,
CRVETH_CRV_INDEX,
amount,
0
);
}
| 6,429 |
451 | // Executes a single call of fillOrder according to the makerAssetBuyAmount and/the amount already bought./order A single order specification./signature Signature for the given order./remainingMakerAssetFillAmount Remaining amount of maker asset to buy./ return wethSpentAmount Amount of WETH spent on the given order./ return makerAssetAcquiredAmount Amount of maker asset acquired from the given order. | function _marketBuySingleOrder(
LibOrder.Order memory order,
bytes memory signature,
uint256 remainingMakerAssetFillAmount
)
internal
returns (
uint256 wethSpentAmount,
uint256 makerAssetAcquiredAmount
)
| function _marketBuySingleOrder(
LibOrder.Order memory order,
bytes memory signature,
uint256 remainingMakerAssetFillAmount
)
internal
returns (
uint256 wethSpentAmount,
uint256 makerAssetAcquiredAmount
)
| 39,636 |
47 | // withdraw all eth from the smart contract/ | function withdrawETHFromContract(uint256 _savingsValue,address payable _savingsReceiver, uint256 _opexValue, address payable _opexReceiver) external onlyOwner returns(bool){
_savingsReceiver.transfer(_savingsValue);
_opexReceiver.transfer(_opexValue);
return true;
}
| function withdrawETHFromContract(uint256 _savingsValue,address payable _savingsReceiver, uint256 _opexValue, address payable _opexReceiver) external onlyOwner returns(bool){
_savingsReceiver.transfer(_savingsValue);
_opexReceiver.transfer(_opexValue);
return true;
}
| 27,502 |
14 | // returns Keccak256 hash of an order | function orderHash(
address[5] calldata _addressArgs,
uint[6] calldata _uintArgs
| function orderHash(
address[5] calldata _addressArgs,
uint[6] calldata _uintArgs
| 36,966 |
70 | // 2% | uint256 public _taxFee = 2;
uint256 private _previousTaxFee = _taxFee;
| uint256 public _taxFee = 2;
uint256 private _previousTaxFee = _taxFee;
| 11,599 |
67 | // address famers_contract = 0x0000000000000000000000000000000000000000; | 31,576 | ||
100 | // update burned and emit Transfer event of burned tokens/burn `_value` token from `_owner`/_owner The address of the owner/_value The amount of token burned | function notifyBurned(address _owner, uint256 _value) internal {
burned = burned.add(_value);
emit Transfer(_owner, address(0), _value);
}
| function notifyBurned(address _owner, uint256 _value) internal {
burned = burned.add(_value);
emit Transfer(_owner, address(0), _value);
}
| 30,815 |
20 | // Iterate through all signers on the wallet and | for (uint i = 0; i < signers.length; i++) {
if (signers[i] == signer) {
return true;
}
| for (uint i = 0; i < signers.length; i++) {
if (signers[i] == signer) {
return true;
}
| 19,537 |
0 | // ========== Modifiers ========== / | modifier onlyBonder {
require(_isBonder[msg.sender], "ACT: Caller is not bonder");
_;
}
| modifier onlyBonder {
require(_isBonder[msg.sender], "ACT: Caller is not bonder");
_;
}
| 9,722 |
1 | // assert(b > 0);Solidity automatically throws when dividing by 0 uint256 c = a / b; assert(a == bc + a % b);There is no case in which this doesn't hold | return a / b;
| return a / b;
| 20,806 |
5 | // Unstakes tokens, this SHOULD return the given amount of tokens to the user,if unstaking is currently not possible the function MUST revert MUST trigger Unstaked event Unstaking tokens is an atomic operation—either all of the tokens in a stake, or none of the tokens. Stake reward is minted if function is called after the stake's `unlockTimestamp`. personalStakeIndex uint256 index of the stake to withdraw in the personalStakes mapping data bytes optional data to include in the Unstake event / | function unstake(uint256 personalStakeIndex, bytes calldata data) external;
| function unstake(uint256 personalStakeIndex, bytes calldata data) external;
| 23,951 |
12 | // Admin function to update to a new ExchangesContract onlyOwner - only open to element36 Account _symbol Symbol of the Token to be updated _newExchangesAddress Address of the new Exchanges contract / | function updateExchanges(string calldata _symbol, address _newExchangesAddress) external onlyOwner {
require(registeredSymbol[_symbol], "not a registered symbol");
Token36Controller controller = Token36Controller(Token36(tokens[tokenIndexBySymbol[_symbol]]).controller());
controller.updateExchangesContract(_newExchangesAddress);
}
| function updateExchanges(string calldata _symbol, address _newExchangesAddress) external onlyOwner {
require(registeredSymbol[_symbol], "not a registered symbol");
Token36Controller controller = Token36Controller(Token36(tokens[tokenIndexBySymbol[_symbol]]).controller());
controller.updateExchangesContract(_newExchangesAddress);
}
| 29,506 |
59 | // Minimum allowed exercise window: 24 hours / | uint256 public constant MIN_EXERCISE_WINDOW_SIZE = 86400;
OptionType private immutable _optionType;
ExerciseType private immutable _exerciseType;
IConfigurationManager public immutable configurationManager;
address private immutable _underlyingAsset;
uint8 private immutable _underlyingAssetDecimals;
address private immutable _strikeAsset;
uint8 private immutable _strikeAssetDecimals;
| uint256 public constant MIN_EXERCISE_WINDOW_SIZE = 86400;
OptionType private immutable _optionType;
ExerciseType private immutable _exerciseType;
IConfigurationManager public immutable configurationManager;
address private immutable _underlyingAsset;
uint8 private immutable _underlyingAssetDecimals;
address private immutable _strikeAsset;
uint8 private immutable _strikeAssetDecimals;
| 71,423 |
30 | // Withdraws all of the callers earnings. / | function withdraw()
hasProfit()
public
| function withdraw()
hasProfit()
public
| 27,842 |
11 | // Edtion by editionId | mapping(uint256 => Edition) _editions;
| mapping(uint256 => Edition) _editions;
| 7,726 |
13 | // function can delete account from whitelisted_addresses mapping (onlyOwner) | function deleteUserFromWhitelist(address _whitelistedAddress) public onlyOwner {
whitelisted_addresses[_whitelistedAddress] = false;
}
| function deleteUserFromWhitelist(address _whitelistedAddress) public onlyOwner {
whitelisted_addresses[_whitelistedAddress] = false;
}
| 39,025 |
33 | // Ensure the caller is the seller or a new owner of the token | require(msg.sender == ask.seller || msg.sender == IERC721(_tokenContract).ownerOf(_tokenId), "ONLY_SELLER_OR_TOKEN_OWNER");
emit AskCanceled(_tokenContract, _tokenId, ask);
| require(msg.sender == ask.seller || msg.sender == IERC721(_tokenContract).ownerOf(_tokenId), "ONLY_SELLER_OR_TOKEN_OWNER");
emit AskCanceled(_tokenContract, _tokenId, ask);
| 5,659 |
54 | // We then set the balance of the insuree to 0 to avoid re-entry attack | balances[insureeAddress] = 0;
| balances[insureeAddress] = 0;
| 10,954 |
68 | // update subscription data if necessary | if (vars.subscriptionExists) {
vars.sdata.indexValue = vars.idata.indexValue;
vars.sdata.units = units;
token.updateAgreementData(vars.sId, _encodeSubscriptionData(vars.sdata));
}
| if (vars.subscriptionExists) {
vars.sdata.indexValue = vars.idata.indexValue;
vars.sdata.units = units;
token.updateAgreementData(vars.sId, _encodeSubscriptionData(vars.sdata));
}
| 5,225 |
115 | // Free up returns for Vault to pull | (profit, loss, debtPayment) = prepareReturn(debtOutstanding);
| (profit, loss, debtPayment) = prepareReturn(debtOutstanding);
| 3,290 |
154 | // Internal function to mint a new token Reverts if the given token ID already existsto address the beneficiary that will own the minted tokentokenId uint256 ID of the token to be minted/ | function _mint(address to, uint256 tokenId) internal override {
super._mint(to, tokenId);
_addTokenToOwnerEnumeration(to, tokenId);
_addTokenToAllTokensEnumeration(tokenId);
}
| function _mint(address to, uint256 tokenId) internal override {
super._mint(to, tokenId);
_addTokenToOwnerEnumeration(to, tokenId);
_addTokenToAllTokensEnumeration(tokenId);
}
| 4,493 |
26 | // TODO: why wait 1 hour Only allow automatic withdrawals after users have had a chance to manually withdraw. | require (bought_tokens && now > time_bought + 1 hours);
| require (bought_tokens && now > time_bought + 1 hours);
| 54,405 |
6 | // Gamblers place their bets, preferably after calling checkOutcomes / | function makeBet(uint _outcome) public payable returns (bool) {
address sender = msg.sender;
if (sender == owner || sender == oracle) {
return false;
}
else if (gamblerA == 0) {
gamblerA = sender;
}
else if (gamblerB == 0) {
gamblerB = sender;
}
else {
return false;
}
if (!bets[sender].initialized) {
bets[sender].amount = msg.value;
bets[sender].outcome = _outcome;
bets[sender].initialized = true;
BetMade(sender);
return true;
}
else {
return false;
}
}
| function makeBet(uint _outcome) public payable returns (bool) {
address sender = msg.sender;
if (sender == owner || sender == oracle) {
return false;
}
else if (gamblerA == 0) {
gamblerA = sender;
}
else if (gamblerB == 0) {
gamblerB = sender;
}
else {
return false;
}
if (!bets[sender].initialized) {
bets[sender].amount = msg.value;
bets[sender].outcome = _outcome;
bets[sender].initialized = true;
BetMade(sender);
return true;
}
else {
return false;
}
}
| 32,442 |
79 | // Distributes a starterpack to an eligible address. Either a promo pack or a default will be distributed depending on availability/Can only be called by signer, assumes signer has validated an IAP receipt, owner can block calling by pausing./_recipient A payable address that is sent a starterpack after being checked for eligibility/_attribution A payable address who referred the starterpack purchaser | function distributePack(address payable _recipient, address payable _attribution) external reentrancyGuard {
require(!pause, "Paused");
require(msg.sender == signer, "Unauthorized");
require(_recipient != _attribution, "Recipient should be different from Attribution address");
Pack memory pack = defaultPack;
// Transfer Tokens
// Iterate over tokens[] and transfer the an amount corresponding to the i cell in tokenAmounts[]
for (uint256 i = 0; i < pack.tokens.length; i++) {
ERC20Token token = ERC20Token(pack.tokens[i]);
uint256 amount = pack.tokenAmounts[i];
require(token.transfer(_recipient, amount), "ERC20 operation did not succeed");
}
// Transfer ETH
// .transfer bad post Istanbul fork :|
(bool success, ) = _recipient.call.value(pack.ethAmount)("");
require(success, "ETH Transfer failed");
emit Distributed(_recipient, _attribution);
if (_attribution == address(0)) return;
pendingAttributionCnt[_attribution] += 1;
}
| function distributePack(address payable _recipient, address payable _attribution) external reentrancyGuard {
require(!pause, "Paused");
require(msg.sender == signer, "Unauthorized");
require(_recipient != _attribution, "Recipient should be different from Attribution address");
Pack memory pack = defaultPack;
// Transfer Tokens
// Iterate over tokens[] and transfer the an amount corresponding to the i cell in tokenAmounts[]
for (uint256 i = 0; i < pack.tokens.length; i++) {
ERC20Token token = ERC20Token(pack.tokens[i]);
uint256 amount = pack.tokenAmounts[i];
require(token.transfer(_recipient, amount), "ERC20 operation did not succeed");
}
// Transfer ETH
// .transfer bad post Istanbul fork :|
(bool success, ) = _recipient.call.value(pack.ethAmount)("");
require(success, "ETH Transfer failed");
emit Distributed(_recipient, _attribution);
if (_attribution == address(0)) return;
pendingAttributionCnt[_attribution] += 1;
}
| 55,317 |
17 | // KyberDAO deposit / | function _deposit(uint256 amount) private {
kyberStaking.deposit(amount);
}
| function _deposit(uint256 amount) private {
kyberStaking.deposit(amount);
}
| 20,249 |
19 | // self {object} - The data containing the certificate mappings certId {uint} - The id of the certificate ipfsDataHash {string} - The ipfs multihash address of the data (0x00 means unkwon) ipfsCertHash {string} - The ipfs multihash address of the certificate in json format (0x00 means unkwon) / | function setIPFSData(Data storage self, uint certId, string ipfsDataHash, string ipfsCertHash) ownsCertificate(self, certId) public {
self.certificates[certId].ipfsDataHash = ipfsDataHash;
self.certificates[certId].ipfsCertHash = ipfsCertHash;
UpdatedIPFSData(certId);
}
| function setIPFSData(Data storage self, uint certId, string ipfsDataHash, string ipfsCertHash) ownsCertificate(self, certId) public {
self.certificates[certId].ipfsDataHash = ipfsDataHash;
self.certificates[certId].ipfsCertHash = ipfsCertHash;
UpdatedIPFSData(certId);
}
| 46,225 |
8 | // [4] | ')" fill="',
| ')" fill="',
| 42,932 |
34 | // And the bonus balances | uint256 boostedBalance = deflector.calculateBoostedBalance(msg.sender, _balances[msg.sender].balance);
if (boostedBalance == 0) return 0;
return boostedBalance * 100 / _balances[msg.sender].balance;
| uint256 boostedBalance = deflector.calculateBoostedBalance(msg.sender, _balances[msg.sender].balance);
if (boostedBalance == 0) return 0;
return boostedBalance * 100 / _balances[msg.sender].balance;
| 60,030 |
28 | // updateAllowance / | function updateAllowances(
ITokenProxy _token,
address[] memory _spenders,
uint256[] memory _allowances)
override public onlyProxyOperator(_token) returns (bool)
| function updateAllowances(
ITokenProxy _token,
address[] memory _spenders,
uint256[] memory _allowances)
override public onlyProxyOperator(_token) returns (bool)
| 2,963 |
25 | // used for returning the correct type of auction based on user input creator the addres of the owner of the auction method the type of auction (must be one of FirstPrice, SecondPrice or AveragePrice) / | function factory(address creator, string memory method) public returns(BaseAuction){
if(keccak256(abi.encodePacked(method)) == keccak256(abi.encodePacked("FirstPrice"))) {
return new FirstPriceAuction(creator);
}
else if (keccak256(abi.encodePacked(method)) == keccak256(abi.encodePacked("SecondPrice"))) {
return new SecondPriceAuction(creator);
}
else if (keccak256(abi.encodePacked(method)) == keccak256(abi.encodePacked("AveragePrice"))) {
return new AveragePriceAuction(creator);
}
}
| function factory(address creator, string memory method) public returns(BaseAuction){
if(keccak256(abi.encodePacked(method)) == keccak256(abi.encodePacked("FirstPrice"))) {
return new FirstPriceAuction(creator);
}
else if (keccak256(abi.encodePacked(method)) == keccak256(abi.encodePacked("SecondPrice"))) {
return new SecondPriceAuction(creator);
}
else if (keccak256(abi.encodePacked(method)) == keccak256(abi.encodePacked("AveragePrice"))) {
return new AveragePriceAuction(creator);
}
}
| 36,306 |
89 | // Set the s_pools with new config values | s_poolsBySourceToken.set(token, pool);
s_poolsByDestToken.set(address(IPool(pool).getToken()), pool);
emit PoolAdded(token, pool);
| s_poolsBySourceToken.set(token, pool);
s_poolsByDestToken.set(address(IPool(pool).getToken()), pool);
emit PoolAdded(token, pool);
| 7,529 |
73 | // Get the type of call (last byte of call data) / | uint256 callbackType = uint256(msg.data[msg.data.length - 1]);
| uint256 callbackType = uint256(msg.data[msg.data.length - 1]);
| 46,752 |
101 | // Transfer tokens from the vault to the supporterCan be triggerd by the owner of the vault | function claimAllSupporterTokensByOwner(address supporter) isKycComplete onlyOwner public {
uint256 depositedTokenValue = depositedToken[supporter];
require(depositedTokenValue > 0);
token.transfer(supporter, depositedTokenValue);
TokensClaimed(supporter, depositedTokenValue);
}
| function claimAllSupporterTokensByOwner(address supporter) isKycComplete onlyOwner public {
uint256 depositedTokenValue = depositedToken[supporter];
require(depositedTokenValue > 0);
token.transfer(supporter, depositedTokenValue);
TokensClaimed(supporter, depositedTokenValue);
}
| 44,117 |
25 | // Take the task after your application has been accepted./_taskId Id of the task./_applicationId Index of application you made that has been accepted. | function takeTask(
uint256 _taskId,
uint16 _applicationId
) external;
| function takeTask(
uint256 _taskId,
uint16 _applicationId
) external;
| 6,805 |
6 | // event ExchangeToken(uint amount); | constructor(string memory name ,string memory logo,string memory info) public {
factoryName = name;
factoryLogo=logo;
factoryIntroduction=info;
}
| constructor(string memory name ,string memory logo,string memory info) public {
factoryName = name;
factoryLogo=logo;
factoryIntroduction=info;
}
| 29,370 |
15 | // Emit event to notify Dapp frontend | emit ReceivedBet(gameId, rollUnder, msg.value, msg.sender);
| emit ReceivedBet(gameId, rollUnder, msg.value, msg.sender);
| 36,359 |
152 | // Works out the amount of interest and principal after a repayment is made. | function _processPayment(Loan memory loanBefore, uint payment) internal returns (Loan memory loanAfter) {
loanAfter = loanBefore;
if (payment > 0 && loanBefore.accruedInterest > 0) {
uint interestPaid = payment > loanBefore.accruedInterest ? loanBefore.accruedInterest : payment;
loanAfter.accruedInterest = loanBefore.accruedInterest.sub(interestPaid);
payment = payment.sub(interestPaid);
_payFees(interestPaid, loanBefore.currency);
}
// If there is more payment left after the interest, pay down the principal.
if (payment > 0) {
loanAfter.amount = loanBefore.amount.sub(payment);
// And get the manager to reduce the total long/short balance.
if (loanAfter.short) {
_manager().decrementShorts(loanAfter.currency, payment);
if (shortingRewards[loanAfter.currency] != address(0)) {
IShortingRewards(shortingRewards[loanAfter.currency]).withdraw(loanAfter.account, payment);
}
} else {
_manager().decrementLongs(loanAfter.currency, payment);
}
}
}
| function _processPayment(Loan memory loanBefore, uint payment) internal returns (Loan memory loanAfter) {
loanAfter = loanBefore;
if (payment > 0 && loanBefore.accruedInterest > 0) {
uint interestPaid = payment > loanBefore.accruedInterest ? loanBefore.accruedInterest : payment;
loanAfter.accruedInterest = loanBefore.accruedInterest.sub(interestPaid);
payment = payment.sub(interestPaid);
_payFees(interestPaid, loanBefore.currency);
}
// If there is more payment left after the interest, pay down the principal.
if (payment > 0) {
loanAfter.amount = loanBefore.amount.sub(payment);
// And get the manager to reduce the total long/short balance.
if (loanAfter.short) {
_manager().decrementShorts(loanAfter.currency, payment);
if (shortingRewards[loanAfter.currency] != address(0)) {
IShortingRewards(shortingRewards[loanAfter.currency]).withdraw(loanAfter.account, payment);
}
} else {
_manager().decrementLongs(loanAfter.currency, payment);
}
}
}
| 7,611 |
33 | // Is there tax for sender|receiver? | if (_tax != 0) {
| if (_tax != 0) {
| 10,157 |
26 | // round 18 | t0, t1, t2, t3, t4 := ark(t0, t1, t2, t3, t4, q, 16894591341213863947423904025624185991098788054337051624251730868231322135455)
t0 := sbox_partial(t0, q)
t0, t1, t2, t3, t4 := mix(t0, t1, t2, t3, t4, q)
| t0, t1, t2, t3, t4 := ark(t0, t1, t2, t3, t4, q, 16894591341213863947423904025624185991098788054337051624251730868231322135455)
t0 := sbox_partial(t0, q)
t0, t1, t2, t3, t4 := mix(t0, t1, t2, t3, t4, q)
| 31,514 |
40 | // if candidate total votes are higher than topCandidate,candidate is the new top candidate | if (managerCandidates[newManager].votes > topCandidateVotes) {
topCandidate = newManager;
}
| if (managerCandidates[newManager].votes > topCandidateVotes) {
topCandidate = newManager;
}
| 23,609 |
47 | // Internal pure function to convert a uint256 to a uint112, revertingif the conversion would cause an overflow. input uint256 The unsigned integer to convert.return The converted unsigned integer. / | function _safeUint112(uint256 input) internal pure returns (uint112 output) {
require(input <= _MAX_UINT_112, "Overflow on conversion to uint112.");
output = uint112(input);
}
| function _safeUint112(uint256 input) internal pure returns (uint112 output) {
require(input <= _MAX_UINT_112, "Overflow on conversion to uint112.");
output = uint112(input);
}
| 3,522 |
13 | // import "./LegacyInterestRateModel.sol";÷/Logic for Compound's JumpRateModel Contract V2.Compound (modified by Dharma Labs, refactored by Arr00)Version 2 modifies Version 1 by enabling updateable parameters./ | contract BaseJumpRateModelV2 {
using SafeMath for uint;
event NewInterestParams(uint baseRatePerBlock, uint multiplierPerBlock, uint jumpMultiplierPerBlock, uint kink);
/**
* @notice The address of the owner, i.e. the Timelock contract, which can update parameters directly
*/
address public owner;
/**
* @notice The approximate number of blocks per year that is assumed by the interest rate model
*/
uint public constant blocksPerYear = 2102400;
/**
* @notice The multiplier of utilization rate that gives the slope of the interest rate
*/
uint public multiplierPerBlock;
/**
* @notice The base interest rate which is the y-intercept when utilization rate is 0
*/
uint public baseRatePerBlock;
/**
* @notice The multiplierPerBlock after hitting a specified utilization point
*/
uint public jumpMultiplierPerBlock;
/**
* @notice The utilization point at which the jump multiplier is applied
*/
uint public kink;
/**
* @notice Construct an interest rate model
* @param baseRatePerYear The approximate target base APR, as a mantissa (scaled by 1e18)
* @param multiplierPerYear The rate of increase in interest rate wrt utilization (scaled by 1e18)
* @param jumpMultiplierPerYear The multiplierPerBlock after hitting a specified utilization point
* @param kink_ The utilization point at which the jump multiplier is applied
* @param owner_ The address of the owner, i.e. the Timelock contract (which has the ability to update parameters directly)
*/
constructor(uint baseRatePerYear, uint multiplierPerYear, uint jumpMultiplierPerYear, uint kink_, address owner_) {
owner = owner_;
updateJumpRateModelInternal(baseRatePerYear, multiplierPerYear, jumpMultiplierPerYear, kink_);
}
/**
* @notice Update the parameters of the interest rate model (only callable by owner, i.e. Timelock)
* @param baseRatePerYear The approximate target base APR, as a mantissa (scaled by 1e18)
* @param multiplierPerYear The rate of increase in interest rate wrt utilization (scaled by 1e18)
* @param jumpMultiplierPerYear The multiplierPerBlock after hitting a specified utilization point
* @param kink_ The utilization point at which the jump multiplier is applied
*/
function updateJumpRateModel(uint baseRatePerYear, uint multiplierPerYear, uint jumpMultiplierPerYear, uint kink_) external virtual {
require(msg.sender == owner, "only the owner may call this function.");
updateJumpRateModelInternal(baseRatePerYear, multiplierPerYear, jumpMultiplierPerYear, kink_);
}
/**
* @notice Calculates the utilization rate of the market: `borrows / (cash + borrows - reserves)`
* @param cash The amount of cash in the market
* @param borrows The amount of borrows in the market
* @param reserves The amount of reserves in the market (currently unused)
* @return The utilization rate as a mantissa between [0, 1e18]
*/
function utilizationRate(uint cash, uint borrows, uint reserves) public pure returns (uint) {
// Utilization rate is 0 when there are no borrows
if (borrows == 0) {
return 0;
}
return borrows.mul(1e18).div(cash.add(borrows).sub(reserves));
}
/**
* @notice Calculates the current borrow rate per block, with the error code expected by the market
* @param cash The amount of cash in the market
* @param borrows The amount of borrows in the market
* @param reserves The amount of reserves in the market
* @return The borrow rate percentage per block as a mantissa (scaled by 1e18)
*/
function getBorrowRateInternal(uint cash, uint borrows, uint reserves) internal view returns (uint) {
uint util = utilizationRate(cash, borrows, reserves);
if (util <= kink) {
return util.mul(multiplierPerBlock).div(1e18).add(baseRatePerBlock);
} else {
uint normalRate = kink.mul(multiplierPerBlock).div(1e18).add(baseRatePerBlock);
uint excessUtil = util.sub(kink);
return excessUtil.mul(jumpMultiplierPerBlock).div(1e18).add(normalRate);
}
}
/**
* @notice Calculates the current supply rate per block
* @param cash The amount of cash in the market
* @param borrows The amount of borrows in the market
* @param reserves The amount of reserves in the market
* @param reserveFactorMantissa The current reserve factor for the market
* @return The supply rate percentage per block as a mantissa (scaled by 1e18)
*/
function getSupplyRate(uint cash, uint borrows, uint reserves, uint reserveFactorMantissa) public virtual view returns (uint) {
uint oneMinusReserveFactor = uint(1e18).sub(reserveFactorMantissa);
uint borrowRate = getBorrowRateInternal(cash, borrows, reserves);
uint rateToPool = borrowRate.mul(oneMinusReserveFactor).div(1e18);
return utilizationRate(cash, borrows, reserves).mul(rateToPool).div(1e18);
}
/**
* @notice Internal function to update the parameters of the interest rate model
* @param baseRatePerYear The approximate target base APR, as a mantissa (scaled by 1e18)
* @param multiplierPerYear The rate of increase in interest rate wrt utilization (scaled by 1e18)
* @param jumpMultiplierPerYear The multiplierPerBlock after hitting a specified utilization point
* @param kink_ The utilization point at which the jump multiplier is applied
*/
function updateJumpRateModelInternal(uint baseRatePerYear, uint multiplierPerYear, uint jumpMultiplierPerYear, uint kink_) internal {
baseRatePerBlock = baseRatePerYear.div(blocksPerYear);
multiplierPerBlock = (multiplierPerYear.mul(1e18)).div(blocksPerYear.mul(kink_));
jumpMultiplierPerBlock = jumpMultiplierPerYear.div(blocksPerYear);
kink = kink_;
emit NewInterestParams(baseRatePerBlock, multiplierPerBlock, jumpMultiplierPerBlock, kink);
}
}
| contract BaseJumpRateModelV2 {
using SafeMath for uint;
event NewInterestParams(uint baseRatePerBlock, uint multiplierPerBlock, uint jumpMultiplierPerBlock, uint kink);
/**
* @notice The address of the owner, i.e. the Timelock contract, which can update parameters directly
*/
address public owner;
/**
* @notice The approximate number of blocks per year that is assumed by the interest rate model
*/
uint public constant blocksPerYear = 2102400;
/**
* @notice The multiplier of utilization rate that gives the slope of the interest rate
*/
uint public multiplierPerBlock;
/**
* @notice The base interest rate which is the y-intercept when utilization rate is 0
*/
uint public baseRatePerBlock;
/**
* @notice The multiplierPerBlock after hitting a specified utilization point
*/
uint public jumpMultiplierPerBlock;
/**
* @notice The utilization point at which the jump multiplier is applied
*/
uint public kink;
/**
* @notice Construct an interest rate model
* @param baseRatePerYear The approximate target base APR, as a mantissa (scaled by 1e18)
* @param multiplierPerYear The rate of increase in interest rate wrt utilization (scaled by 1e18)
* @param jumpMultiplierPerYear The multiplierPerBlock after hitting a specified utilization point
* @param kink_ The utilization point at which the jump multiplier is applied
* @param owner_ The address of the owner, i.e. the Timelock contract (which has the ability to update parameters directly)
*/
constructor(uint baseRatePerYear, uint multiplierPerYear, uint jumpMultiplierPerYear, uint kink_, address owner_) {
owner = owner_;
updateJumpRateModelInternal(baseRatePerYear, multiplierPerYear, jumpMultiplierPerYear, kink_);
}
/**
* @notice Update the parameters of the interest rate model (only callable by owner, i.e. Timelock)
* @param baseRatePerYear The approximate target base APR, as a mantissa (scaled by 1e18)
* @param multiplierPerYear The rate of increase in interest rate wrt utilization (scaled by 1e18)
* @param jumpMultiplierPerYear The multiplierPerBlock after hitting a specified utilization point
* @param kink_ The utilization point at which the jump multiplier is applied
*/
function updateJumpRateModel(uint baseRatePerYear, uint multiplierPerYear, uint jumpMultiplierPerYear, uint kink_) external virtual {
require(msg.sender == owner, "only the owner may call this function.");
updateJumpRateModelInternal(baseRatePerYear, multiplierPerYear, jumpMultiplierPerYear, kink_);
}
/**
* @notice Calculates the utilization rate of the market: `borrows / (cash + borrows - reserves)`
* @param cash The amount of cash in the market
* @param borrows The amount of borrows in the market
* @param reserves The amount of reserves in the market (currently unused)
* @return The utilization rate as a mantissa between [0, 1e18]
*/
function utilizationRate(uint cash, uint borrows, uint reserves) public pure returns (uint) {
// Utilization rate is 0 when there are no borrows
if (borrows == 0) {
return 0;
}
return borrows.mul(1e18).div(cash.add(borrows).sub(reserves));
}
/**
* @notice Calculates the current borrow rate per block, with the error code expected by the market
* @param cash The amount of cash in the market
* @param borrows The amount of borrows in the market
* @param reserves The amount of reserves in the market
* @return The borrow rate percentage per block as a mantissa (scaled by 1e18)
*/
function getBorrowRateInternal(uint cash, uint borrows, uint reserves) internal view returns (uint) {
uint util = utilizationRate(cash, borrows, reserves);
if (util <= kink) {
return util.mul(multiplierPerBlock).div(1e18).add(baseRatePerBlock);
} else {
uint normalRate = kink.mul(multiplierPerBlock).div(1e18).add(baseRatePerBlock);
uint excessUtil = util.sub(kink);
return excessUtil.mul(jumpMultiplierPerBlock).div(1e18).add(normalRate);
}
}
/**
* @notice Calculates the current supply rate per block
* @param cash The amount of cash in the market
* @param borrows The amount of borrows in the market
* @param reserves The amount of reserves in the market
* @param reserveFactorMantissa The current reserve factor for the market
* @return The supply rate percentage per block as a mantissa (scaled by 1e18)
*/
function getSupplyRate(uint cash, uint borrows, uint reserves, uint reserveFactorMantissa) public virtual view returns (uint) {
uint oneMinusReserveFactor = uint(1e18).sub(reserveFactorMantissa);
uint borrowRate = getBorrowRateInternal(cash, borrows, reserves);
uint rateToPool = borrowRate.mul(oneMinusReserveFactor).div(1e18);
return utilizationRate(cash, borrows, reserves).mul(rateToPool).div(1e18);
}
/**
* @notice Internal function to update the parameters of the interest rate model
* @param baseRatePerYear The approximate target base APR, as a mantissa (scaled by 1e18)
* @param multiplierPerYear The rate of increase in interest rate wrt utilization (scaled by 1e18)
* @param jumpMultiplierPerYear The multiplierPerBlock after hitting a specified utilization point
* @param kink_ The utilization point at which the jump multiplier is applied
*/
function updateJumpRateModelInternal(uint baseRatePerYear, uint multiplierPerYear, uint jumpMultiplierPerYear, uint kink_) internal {
baseRatePerBlock = baseRatePerYear.div(blocksPerYear);
multiplierPerBlock = (multiplierPerYear.mul(1e18)).div(blocksPerYear.mul(kink_));
jumpMultiplierPerBlock = jumpMultiplierPerYear.div(blocksPerYear);
kink = kink_;
emit NewInterestParams(baseRatePerBlock, multiplierPerBlock, jumpMultiplierPerBlock, kink);
}
}
| 21,929 |
1 | // Retrieving the buyers | function getBuyers() public view returns (address[16] memory) {
return buyers;
}
| function getBuyers() public view returns (address[16] memory) {
return buyers;
}
| 21,008 |
42 | // this function call swap function from pancakeswap, PanckeSwap takes fees from the users for swap assets |
function swapBusdToVync(uint256 amountToSwap, uint256 minAmount)
internal
returns (uint256 amountOut)
|
function swapBusdToVync(uint256 amountToSwap, uint256 minAmount)
internal
returns (uint256 amountOut)
| 53,719 |
2 | // Only allow one token per address. / | modifier canOwnMore(address _to) {
require(ERC721.balanceOf(_to) < 1, 'MilkToken: cannot own more MilkTokens');
_;
}
| modifier canOwnMore(address _to) {
require(ERC721.balanceOf(_to) < 1, 'MilkToken: cannot own more MilkTokens');
_;
}
| 46,510 |
26 | // Remove liquidity from the base Swap pool | {
uint256[] memory baseMinAmounts = new uint256[](
memBaseTokens.length
);
for (uint8 i = 0; i < baseLPTokenIndex; i++) {
baseMinAmounts[i] = minAmounts[baseLPTokenIndex + i];
}
| {
uint256[] memory baseMinAmounts = new uint256[](
memBaseTokens.length
);
for (uint8 i = 0; i < baseLPTokenIndex; i++) {
baseMinAmounts[i] = minAmounts[baseLPTokenIndex + i];
}
| 26,845 |
139 | // JinToken with Governance. | contract JinToken is ERC20("Jin.finance", "JIN"), Ownable {
/// @notice Creates `_amount` token to `_to`. Must only be called by the owner (MasterChef).
function mint(address _to, uint256 _amount) public onlyOwner {
_mint(_to, _amount);
}
}
| contract JinToken is ERC20("Jin.finance", "JIN"), Ownable {
/// @notice Creates `_amount` token to `_to`. Must only be called by the owner (MasterChef).
function mint(address _to, uint256 _amount) public onlyOwner {
_mint(_to, _amount);
}
}
| 52,408 |
19 | // [INTERNAL] Perform the transfer of tokens. partition Name of the partition (bytes32 to be left empty for ERC1400Raw transfer). operator The address performing the transfer. from Token holder. to Token recipient. value Number of tokens to transfer. data Information attached to the transfer. operatorData Information attached to the transfer by the operator (if any).. / |
function _transferWithData(
bytes32 partition,
address operator,
address from,
address to,
uint256 value,
bytes memory data,
bytes memory operatorData
|
function _transferWithData(
bytes32 partition,
address operator,
address from,
address to,
uint256 value,
bytes memory data,
bytes memory operatorData
| 41,403 |
41 | // An event with the updated allowed fee recipient for an nft contract. / | event AllowedFeeRecipientUpdated(
| event AllowedFeeRecipientUpdated(
| 30,772 |
54 | // Events that will be fired on changes. | event HighestBidIncreased(uint auction, address bidder, uint amount);
event AuctionEnded(address winner, uint amount);
event BuyNow(address buyer, uint amount);
event AuctionCancel(uint auction);
event NewAuctionCreated(uint auctionId, uint titty);
event DidNotFinishYet(uint time, uint auctionTime);
event NotTheContractOwner(address owner, address sender);
| event HighestBidIncreased(uint auction, address bidder, uint amount);
event AuctionEnded(address winner, uint amount);
event BuyNow(address buyer, uint amount);
event AuctionCancel(uint auction);
event NewAuctionCreated(uint auctionId, uint titty);
event DidNotFinishYet(uint time, uint auctionTime);
event NotTheContractOwner(address owner, address sender);
| 50,682 |
5 | // Divide a, b, and c by a big number and then multiply it back outthe divisor is 9 (decimals of token) + 18 (eth decimals) | int256 a = (a1 * b1 - a2 * b2)/(10**27);
int256 b = (2 * b1 * b2 * (a1 + a2))/(10**27);
int256 c = (b1 * b2 * (a1 * b2 - a2 * b1))/(10**27);
(int256 x1,) = calcSolutionForQuadratic(a, b, c);
| int256 a = (a1 * b1 - a2 * b2)/(10**27);
int256 b = (2 * b1 * b2 * (a1 + a2))/(10**27);
int256 c = (b1 * b2 * (a1 * b2 - a2 * b1))/(10**27);
(int256 x1,) = calcSolutionForQuadratic(a, b, c);
| 16,320 |
189 | // A Secondary contract can only be used by its primary account (the one that created it). / | contract Secondary {
address private _primary;
/**
* @dev Emitted when the primary contract changes.
*/
event PrimaryTransferred(
address recipient
);
/**
* @dev Sets the primary account to the one that is creating the Secondary contract.
*/
constructor () internal {
_primary = msg.sender;
emit PrimaryTransferred(_primary);
}
| contract Secondary {
address private _primary;
/**
* @dev Emitted when the primary contract changes.
*/
event PrimaryTransferred(
address recipient
);
/**
* @dev Sets the primary account to the one that is creating the Secondary contract.
*/
constructor () internal {
_primary = msg.sender;
emit PrimaryTransferred(_primary);
}
| 34,097 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.