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
|
---|---|---|---|---|
44 | // trust Id of the key | keyTrustAssociations[keyId],
| keyTrustAssociations[keyId],
| 15,639 |
6 | // An extension to `ITaskAcceptorV1` that helps task runners know where to find details about how to complete the task. | interface ITaskAcceptanceCriteriaV1 is ITaskAcceptorV1 {
/// @return a string that could be a URI or some abi-encoded data
function taskAcceptanceCriteria(uint256 _taskId) external view returns (string calldata);
}
| interface ITaskAcceptanceCriteriaV1 is ITaskAcceptorV1 {
/// @return a string that could be a URI or some abi-encoded data
function taskAcceptanceCriteria(uint256 _taskId) external view returns (string calldata);
}
| 26,472 |
71 | // bytes4(keccak256('balanceOf(address,uint256)')) == 0x00fdd58ebytes4(keccak256('balanceOfBatch(address[],uint256[])')) == 0x4e1273f4bytes4(keccak256('setApprovalForAll(address,bool)')) == 0xa22cb465bytes4(keccak256('isApprovedForAll(address,address)')) == 0xe985e9c5bytes4(keccak256('safeTransferFrom(address,address,uint256,uint256,bytes)')) == 0xf242432abytes4(keccak256('safeBatchTransferFrom(address,address,uint256[],uint256[],bytes)')) == 0x2eb2c2d6 => 0x00fdd58e ^ 0x4e1273f4 ^ 0xa22cb465 ^ 0xe985e9c5 ^ 0xf242432a ^ 0x2eb2c2d6 == 0xd9b67a26 / | bytes4 private constant _INTERFACE_ID_ERC1155 = 0xd9b67a26;
| bytes4 private constant _INTERFACE_ID_ERC1155 = 0xd9b67a26;
| 11,075 |
622 | // Emitted when the input is greater than 133.084258667509499441. | error PRBMathSD59x18__ExpInputTooBig(int256 x);
| error PRBMathSD59x18__ExpInputTooBig(int256 x);
| 62,349 |
194 | // Allows owner of the contract updating the token metadata in case there is a need. _tokenId uint256 ID of the token. _uri string metadata URI. / | function updateTokenMetadata(uint256 _tokenId, string calldata _uri) external onlyOwner {
_setTokenURI(_tokenId, _uri);
emit TokenURIUpdated(_tokenId, _uri);
}
| function updateTokenMetadata(uint256 _tokenId, string calldata _uri) external onlyOwner {
_setTokenURI(_tokenId, _uri);
emit TokenURIUpdated(_tokenId, _uri);
}
| 2,511 |
1 | // /// | enum Vote {
Null, // default value, counted as abstention
Yes,
No
}
| enum Vote {
Null, // default value, counted as abstention
Yes,
No
}
| 24,287 |
159 | // gas overhead to calculate gasUseWithoutPost |
function postOverhead() external view returns (uint256);
|
function postOverhead() external view returns (uint256);
| 3,486 |
24 | // PoW failed | return 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF;
| return 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF;
| 21,599 |
20 | // The bid is good! Remove the auction before sending the fees to the sender so we can't have a reentrancy attack. | _removeAuction(_tokenId);
| _removeAuction(_tokenId);
| 19 |
290 | // Accepts new implementation of controller. msg.sender must be pendingImplementationAdmin function for new implementation to accept it's role as implementation return uint 0=success, otherwise a failure (see ErrorReporter.sol for details)/ | function _acceptImplementation() public returns (uint) {
// Check caller is pendingImplementation and pendingImplementation ≠ address(0)
if (msg.sender != pendingControllerImplementation || pendingControllerImplementation == address(0)) {
return fail(Error.UNAUTHORIZED, FailureInfo.ACCEPT_PENDING_IMPLEMENTATION_ADDRESS_CHECK);
}
// Save current values for inclusion in log
address oldImplementation = controllerImplementation;
address oldPendingImplementation = pendingControllerImplementation;
controllerImplementation = pendingControllerImplementation;
pendingControllerImplementation = address(0);
emit NewImplementation(oldImplementation, controllerImplementation);
emit NewPendingImplementation(oldPendingImplementation, pendingControllerImplementation);
return uint(Error.NO_ERROR);
}
| function _acceptImplementation() public returns (uint) {
// Check caller is pendingImplementation and pendingImplementation ≠ address(0)
if (msg.sender != pendingControllerImplementation || pendingControllerImplementation == address(0)) {
return fail(Error.UNAUTHORIZED, FailureInfo.ACCEPT_PENDING_IMPLEMENTATION_ADDRESS_CHECK);
}
// Save current values for inclusion in log
address oldImplementation = controllerImplementation;
address oldPendingImplementation = pendingControllerImplementation;
controllerImplementation = pendingControllerImplementation;
pendingControllerImplementation = address(0);
emit NewImplementation(oldImplementation, controllerImplementation);
emit NewPendingImplementation(oldPendingImplementation, pendingControllerImplementation);
return uint(Error.NO_ERROR);
}
| 12,124 |
65 | // Transfer Ether funds to owner and terminate contract It would be unfair to allow ourselves to destroy a contract with more than 25 ether and claim the jackpot, lower than that we would consider it still a beta (any Ether would be transfered to the newer contract) |
ticket.destroy();
selfdestruct(owner);
|
ticket.destroy();
selfdestruct(owner);
| 7,314 |
38 | // function to calculate the quantity of bnb needed using its TOKEN price to buy `buyAmount` of TOKEN | function calculateBNBAmount(uint256 tokenAmount) public view returns (uint256) {
require(tokenPrice > 0, "TOKEN price per BNB should be greater than 0");
uint256 bnbAmount = tokenAmount.mul(DEFAULT_DECIMALS).div(tokenPrice);
return bnbAmount;
}
| function calculateBNBAmount(uint256 tokenAmount) public view returns (uint256) {
require(tokenPrice > 0, "TOKEN price per BNB should be greater than 0");
uint256 bnbAmount = tokenAmount.mul(DEFAULT_DECIMALS).div(tokenPrice);
return bnbAmount;
}
| 41,037 |
8 | // Throws if called by any account other than a guardian account (temporary account allowed access to settings before DAO is fully enabled)/ | modifier onlyGuardian() {
require(msg.sender == rocketStorage.getGuardian(), "Account is not a temporary guardian");
_;
}
| modifier onlyGuardian() {
require(msg.sender == rocketStorage.getGuardian(), "Account is not a temporary guardian");
_;
}
| 10,739 |
5 | // create an account, and return its address.returns the address even if the account is already deployed.Note that during UserOperation execution, this method is called only if the account is not deployed.This method returns an existing account address so that entryPoint.getSenderAddress() would work even after account creation / | function createAccount(address owner,uint256 salt) public returns (SimpleAccount ret) {
address addr = getAddress(owner, salt);
uint codeSize = addr.code.length;
if (codeSize > 0) {
return SimpleAccount(payable(addr));
}
ret = SimpleAccount(payable(new ERC1967Proxy{salt : bytes32(salt)}(
address(accountImplementation),
abi.encodeCall(SimpleAccount.initialize, (owner))
)));
}
| function createAccount(address owner,uint256 salt) public returns (SimpleAccount ret) {
address addr = getAddress(owner, salt);
uint codeSize = addr.code.length;
if (codeSize > 0) {
return SimpleAccount(payable(addr));
}
ret = SimpleAccount(payable(new ERC1967Proxy{salt : bytes32(salt)}(
address(accountImplementation),
abi.encodeCall(SimpleAccount.initialize, (owner))
)));
}
| 24,031 |
10 | // A simple implementation of the ERC20 interface for training purposes. See https:eips.ethereum.org/EIPS/eip-20 for details. | contract SCM is IERC20 {
string private constant _name = "Scam";
string private constant _symbol = "SCM";
uint8 private constant _decimals = 18;
uint256 private _totalSupply;
mapping (address => uint256) private _balances;
mapping (address => mapping (address => uint256)) private _allowed;
// Create the contract and set balance of the creator to `totalSupply`.
constructor(uint256 totalSupply) public {
_totalSupply = totalSupply;
_balances[msg.sender] = totalSupply;
emit Transfer(address(0), msg.sender, totalSupply);
}
// Get name of this coin, used in UI to improve human readability.
function name() public view returns (string memory) {
return _name;
}
// Get symbol for this coin, used in UI to improve human readability.
function symbol() public view returns (string memory) {
return _symbol;
}
// Get number of decimal places used to represent token values in UI.
function decimals() public view returns (uint8) {
return _decimals;
}
// Get total token supply.
function totalSupply() public view returns (uint256) {
return _totalSupply;
}
// Get balance of the given user.
function balanceOf(address owner) public view returns (uint256 balance) {
return _balances[owner];
}
// Transfer tokens from caller's wallet to the given wallet.
function transfer(address to, uint256 value) public returns (bool success) {
return transferFrom(msg.sender, to, value);
}
// Transfer tokens from the given wallet to another wallet.
function transferFrom(address from, address to, uint256 value) public returns (bool success) {
require(from != address(0), "sending from zero address");
require(to != address(0), "sending to zero address");
require(_balances[from] >= value, "not enough funds");
if (from != msg.sender) {
require(_allowed[from][msg.sender] >= value, "allowance exhausted");
_allowed[from][msg.sender] -= value;
}
_balances[from] -= value;
_balances[to] += value;
emit Transfer(from, to, value);
return true;
}
// Give `spender` permission to withdraw up to `value` tokens from the caller's wallet.
function approve(address spender, uint256 value) public returns (bool success) {
require(spender != address(0), "setting allowance for zero address");
if (msg.sender != spender) {
_allowed[msg.sender][spender] = value;
}
emit Approval(msg.sender, spender, value);
return true;
}
// Get number of tokens `spender` is still allowed to withdraw from `owner`.
function allowance(address owner, address spender) public view returns (uint256 remaining) {
return _allowed[owner][spender];
}
}
| contract SCM is IERC20 {
string private constant _name = "Scam";
string private constant _symbol = "SCM";
uint8 private constant _decimals = 18;
uint256 private _totalSupply;
mapping (address => uint256) private _balances;
mapping (address => mapping (address => uint256)) private _allowed;
// Create the contract and set balance of the creator to `totalSupply`.
constructor(uint256 totalSupply) public {
_totalSupply = totalSupply;
_balances[msg.sender] = totalSupply;
emit Transfer(address(0), msg.sender, totalSupply);
}
// Get name of this coin, used in UI to improve human readability.
function name() public view returns (string memory) {
return _name;
}
// Get symbol for this coin, used in UI to improve human readability.
function symbol() public view returns (string memory) {
return _symbol;
}
// Get number of decimal places used to represent token values in UI.
function decimals() public view returns (uint8) {
return _decimals;
}
// Get total token supply.
function totalSupply() public view returns (uint256) {
return _totalSupply;
}
// Get balance of the given user.
function balanceOf(address owner) public view returns (uint256 balance) {
return _balances[owner];
}
// Transfer tokens from caller's wallet to the given wallet.
function transfer(address to, uint256 value) public returns (bool success) {
return transferFrom(msg.sender, to, value);
}
// Transfer tokens from the given wallet to another wallet.
function transferFrom(address from, address to, uint256 value) public returns (bool success) {
require(from != address(0), "sending from zero address");
require(to != address(0), "sending to zero address");
require(_balances[from] >= value, "not enough funds");
if (from != msg.sender) {
require(_allowed[from][msg.sender] >= value, "allowance exhausted");
_allowed[from][msg.sender] -= value;
}
_balances[from] -= value;
_balances[to] += value;
emit Transfer(from, to, value);
return true;
}
// Give `spender` permission to withdraw up to `value` tokens from the caller's wallet.
function approve(address spender, uint256 value) public returns (bool success) {
require(spender != address(0), "setting allowance for zero address");
if (msg.sender != spender) {
_allowed[msg.sender][spender] = value;
}
emit Approval(msg.sender, spender, value);
return true;
}
// Get number of tokens `spender` is still allowed to withdraw from `owner`.
function allowance(address owner, address spender) public view returns (uint256 remaining) {
return _allowed[owner][spender];
}
}
| 21 |
1 | // return the current keeper index / | function getKeeperIndex() external view returns (uint256) {
return s_keeperIndex;
}
| function getKeeperIndex() external view returns (uint256) {
return s_keeperIndex;
}
| 42,845 |
57 | // public inputs | PairingsBn254.Fr memory tmp = PairingsBn254.new_fr(0);
PairingsBn254.Fr memory inputs_term = PairingsBn254.new_fr(0);
for (uint256 i = 0; i < proof.input_values.length; i++) {
tmp.assign(state.cached_lagrange_evals[i]);
tmp.mul_assign(PairingsBn254.new_fr(proof.input_values[i]));
inputs_term.add_assign(tmp);
}
| PairingsBn254.Fr memory tmp = PairingsBn254.new_fr(0);
PairingsBn254.Fr memory inputs_term = PairingsBn254.new_fr(0);
for (uint256 i = 0; i < proof.input_values.length; i++) {
tmp.assign(state.cached_lagrange_evals[i]);
tmp.mul_assign(PairingsBn254.new_fr(proof.input_values[i]));
inputs_term.add_assign(tmp);
}
| 33,625 |
118 | // Hash (keccak256) of the payload used by transferPreSigned _token address The address of the token. _to address The address which you want to transfer to. _value uint256 The amount of tokens to be transferred. _fee uint256 The amount of tokens paid to msg.sender, by the owner. _nonce uint256 Presigned transaction number. / | function hashForSign(
bytes4 _selector,
address _token,
address _to,
uint256 _value,
uint256 _fee,
uint256 _nonce
)
public
pure
| function hashForSign(
bytes4 _selector,
address _token,
address _to,
uint256 _value,
uint256 _fee,
uint256 _nonce
)
public
pure
| 15,658 |
176 | // Emits a {DisabledReward} event. Requirements: - reward feature mush be enabled./ | function disableReward() public onlyOwner {
require(_rewardEnabled, "Reward feature is already disabled.");
setTaxReward(new uint32[](3), 0);
_rewardEnabled = false;
emit DisabledReward();
}
| function disableReward() public onlyOwner {
require(_rewardEnabled, "Reward feature is already disabled.");
setTaxReward(new uint32[](3), 0);
_rewardEnabled = false;
emit DisabledReward();
}
| 13,027 |
28 | // special case for equal weights | if (_fromConnectorWeight == _toConnectorWeight)
return safeMul(_toConnectorBalance, _amount) / safeAdd(_fromConnectorBalance, _amount);
uint256 result;
uint8 precision;
uint256 baseN = safeAdd(_fromConnectorBalance, _amount);
(result, precision) = power(baseN, _fromConnectorBalance, _fromConnectorWeight, _toConnectorWeight);
uint256 temp1 = safeMul(_toConnectorBalance, result);
uint256 temp2 = _toConnectorBalance << precision;
return (temp1 - temp2) / result;
| if (_fromConnectorWeight == _toConnectorWeight)
return safeMul(_toConnectorBalance, _amount) / safeAdd(_fromConnectorBalance, _amount);
uint256 result;
uint8 precision;
uint256 baseN = safeAdd(_fromConnectorBalance, _amount);
(result, precision) = power(baseN, _fromConnectorBalance, _fromConnectorWeight, _toConnectorWeight);
uint256 temp1 = safeMul(_toConnectorBalance, result);
uint256 temp2 = _toConnectorBalance << precision;
return (temp1 - temp2) / result;
| 88,154 |
58 | // Source the token from the baseStrategy and send to the strategy. | _withdrawFromBaseStrategy(strategy, token, tokenConfig, recipient, borrowAmount);
| _withdrawFromBaseStrategy(strategy, token, tokenConfig, recipient, borrowAmount);
| 35,592 |
73 | // the symbol that don't use in reels | byte private constant UNUSED_SYMBOL = "\xff"; // 255
uint internal constant REELS_LEN = 9;
uint private constant BIG_COMBINATION_MIN_LEN = 8;
bytes32 private constant PAYMENT_LOG_MSG = "slot";
bytes32 private constant REFUND_LOG_MSG = "slot.refund";
uint private constant HANDLE_BET_COST = 0.001 ether;
uint private constant HOUSE_EDGE_PERCENT = 1;
uint private constant JACKPOT_PERCENT = 1;
uint private constant MIN_WIN_PERCENT = 30;
uint private constant MIN_BET_AMOUNT = 10 + (HANDLE_BET_COST * 100 / MIN_WIN_PERCENT * 100) / (100 - HOUSE_EDGE_PERCENT - JACKPOT_PERCENT);
| byte private constant UNUSED_SYMBOL = "\xff"; // 255
uint internal constant REELS_LEN = 9;
uint private constant BIG_COMBINATION_MIN_LEN = 8;
bytes32 private constant PAYMENT_LOG_MSG = "slot";
bytes32 private constant REFUND_LOG_MSG = "slot.refund";
uint private constant HANDLE_BET_COST = 0.001 ether;
uint private constant HOUSE_EDGE_PERCENT = 1;
uint private constant JACKPOT_PERCENT = 1;
uint private constant MIN_WIN_PERCENT = 30;
uint private constant MIN_BET_AMOUNT = 10 + (HANDLE_BET_COST * 100 / MIN_WIN_PERCENT * 100) / (100 - HOUSE_EDGE_PERCENT - JACKPOT_PERCENT);
| 41,111 |
187 | // exclude from max tx | _isExcludedFromMaxTx[owner()] = true;
_isExcludedFromMaxTx[address(this)] = true;
_isExcludedFromMaxTx[marketingWallet] = true;
_isExcludedFromMaxTx[CharityWallet] = true;
| _isExcludedFromMaxTx[owner()] = true;
_isExcludedFromMaxTx[address(this)] = true;
_isExcludedFromMaxTx[marketingWallet] = true;
_isExcludedFromMaxTx[CharityWallet] = true;
| 19,310 |
0 | // Event for dispatching when holder claimed benefits./owner address that claimed benefits. | event ClaimBenefits(address indexed owner);
| event ClaimBenefits(address indexed owner);
| 70,923 |
21 | // This creates an array with all balances // This generates a public event on the blockchain that will notify clients / ZVC to TZVC | event Mapping(address _from, uint256 _value, bytes _extraData);
event Burn(address _from, uint256 _value, string _zvAddr);
| event Mapping(address _from, uint256 _value, bytes _extraData);
event Burn(address _from, uint256 _value, string _zvAddr);
| 12,681 |
206 | // Set the new contract address | auction = candidateContract;
| auction = candidateContract;
| 46,258 |
0 | // Mint Manager Interface. / | interface IMintManager {
/**
* @dev Return the current minting-point index.
*/
function getIndex() external view returns (uint256);
}
| interface IMintManager {
/**
* @dev Return the current minting-point index.
*/
function getIndex() external view returns (uint256);
}
| 21,420 |
139 | // Move the pointer 32 bytes leftwards to make room for the length. | ptr := sub(ptr, 32)
| ptr := sub(ptr, 32)
| 9,122 |
21 | // Returns Governor address from the Nexusreturn Address of Governor Contract / | function _governor() internal view returns (address) {
return nexus.governor();
}
| function _governor() internal view returns (address) {
return nexus.governor();
}
| 26,529 |
8 | // Compound's WhitePaperInterestRateModel ContractCompoundThe parameterized model described in section 2.4 of the original Compound Protocol whitepaper/ | contract WhitePaperInterestRateModel is InterestRateModel {
using SafeMath for uint;
event NewInterestParams(uint baseRatePerTimestamp, uint multiplierPerTimestamp);
/**
* @notice The approximate number of blocks per year that is assumed by the interest rate model
*/
uint public constant timestampsPerYear = 31536000;
/**
* @notice The multiplier of utilization rate that gives the slope of the interest rate
*/
uint public multiplierPerTimestamp;
/**
* @notice The base interest rate which is the y-intercept when utilization rate is 0
*/
uint public baseRatePerTimestamp;
/**
* @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)
*/
constructor(uint baseRatePerYear, uint multiplierPerYear) public {
baseRatePerTimestamp = baseRatePerYear.div(timestampsPerYear);
multiplierPerTimestamp = multiplierPerYear.div(timestampsPerYear);
emit NewInterestParams(baseRatePerTimestamp, multiplierPerTimestamp);
}
/**
* @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 getBorrowRate(uint cash, uint borrows, uint reserves) public view returns (uint) {
uint ur = utilizationRate(cash, borrows, reserves);
return ur.mul(multiplierPerTimestamp).div(1e18).add(baseRatePerTimestamp);
}
/**
* @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 view returns (uint) {
uint oneMinusReserveFactor = uint(1e18).sub(reserveFactorMantissa);
uint borrowRate = getBorrowRate(cash, borrows, reserves);
uint rateToPool = borrowRate.mul(oneMinusReserveFactor).div(1e18);
return utilizationRate(cash, borrows, reserves).mul(rateToPool).div(1e18);
}
}
| contract WhitePaperInterestRateModel is InterestRateModel {
using SafeMath for uint;
event NewInterestParams(uint baseRatePerTimestamp, uint multiplierPerTimestamp);
/**
* @notice The approximate number of blocks per year that is assumed by the interest rate model
*/
uint public constant timestampsPerYear = 31536000;
/**
* @notice The multiplier of utilization rate that gives the slope of the interest rate
*/
uint public multiplierPerTimestamp;
/**
* @notice The base interest rate which is the y-intercept when utilization rate is 0
*/
uint public baseRatePerTimestamp;
/**
* @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)
*/
constructor(uint baseRatePerYear, uint multiplierPerYear) public {
baseRatePerTimestamp = baseRatePerYear.div(timestampsPerYear);
multiplierPerTimestamp = multiplierPerYear.div(timestampsPerYear);
emit NewInterestParams(baseRatePerTimestamp, multiplierPerTimestamp);
}
/**
* @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 getBorrowRate(uint cash, uint borrows, uint reserves) public view returns (uint) {
uint ur = utilizationRate(cash, borrows, reserves);
return ur.mul(multiplierPerTimestamp).div(1e18).add(baseRatePerTimestamp);
}
/**
* @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 view returns (uint) {
uint oneMinusReserveFactor = uint(1e18).sub(reserveFactorMantissa);
uint borrowRate = getBorrowRate(cash, borrows, reserves);
uint rateToPool = borrowRate.mul(oneMinusReserveFactor).div(1e18);
return utilizationRate(cash, borrows, reserves).mul(rateToPool).div(1e18);
}
}
| 14,223 |
11 | // it should be easier a hearbeat call only move a step forward but considering gas price, one heartbeat may cause multiple moves to a temp steady status. | function heartbeat() public override {
bool again = false;
do {
again = false;
if (status == ProjectStatus.Auditing) {
again = _heartbeat_auditing();
} else if (status == ProjectStatus.Audited) {
if (block.number >= raise_start) {
status = ProjectStatus.Raising;
again = true;
emit ProjectRaising(id);
}
} else if (status == ProjectStatus.Raising) {
again = _heartbeat_raising();
} else if (
status == ProjectStatus.Refunding &&
USDT_address.balanceOf(address(this)) == 0
) {
status = ProjectStatus.Failed;
emit ProjectFailed(id);
again = true;
} else if (status == ProjectStatus.Succeeded) {
again = _heartbeat_succeeded();
} else if (status == ProjectStatus.InsurancePaid) {
status = ProjectStatus.Rolling;
emit ProjectRolling(id);
again = true;
} else if (status == ProjectStatus.Liquidating) {
if (USDT_address.balanceOf(address(this)) == 0) {
status = ProjectStatus.Failed;
emit ProjectFailed(id);
again = true;
}
} else if (status == ProjectStatus.Repaying) {
again = _heartbeat_repaying();
}
} while (again);
}
| function heartbeat() public override {
bool again = false;
do {
again = false;
if (status == ProjectStatus.Auditing) {
again = _heartbeat_auditing();
} else if (status == ProjectStatus.Audited) {
if (block.number >= raise_start) {
status = ProjectStatus.Raising;
again = true;
emit ProjectRaising(id);
}
} else if (status == ProjectStatus.Raising) {
again = _heartbeat_raising();
} else if (
status == ProjectStatus.Refunding &&
USDT_address.balanceOf(address(this)) == 0
) {
status = ProjectStatus.Failed;
emit ProjectFailed(id);
again = true;
} else if (status == ProjectStatus.Succeeded) {
again = _heartbeat_succeeded();
} else if (status == ProjectStatus.InsurancePaid) {
status = ProjectStatus.Rolling;
emit ProjectRolling(id);
again = true;
} else if (status == ProjectStatus.Liquidating) {
if (USDT_address.balanceOf(address(this)) == 0) {
status = ProjectStatus.Failed;
emit ProjectFailed(id);
again = true;
}
} else if (status == ProjectStatus.Repaying) {
again = _heartbeat_repaying();
}
} while (again);
}
| 40,787 |
206 | // swap and burn collected funds | _doomCat.swapAndBurn(collectedRescueFunds);
| _doomCat.swapAndBurn(collectedRescueFunds);
| 10,994 |
152 | // Calculate x - y.Special values behave in the following way: NaN - x = NaN for any x.Infinity - x = Infinity for any finite x.-Infinity - x = -Infinity for any finite x.Infinity - -Infinity = Infinity.-Infinity - Infinity = -Infinity.Infinity - Infinity = -Infinity - -Infinity = NaN.x quadruple precision number y quadruple precision numberreturn quadruple precision number / | function sub (bytes16 x, bytes16 y) internal pure returns (bytes16) {
return add (x, y ^ 0x80000000000000000000000000000000);
}
| function sub (bytes16 x, bytes16 y) internal pure returns (bytes16) {
return add (x, y ^ 0x80000000000000000000000000000000);
}
| 83,969 |
20 | // Require proposer is active Staker or guardian address | require(
Staking(stakingAddress).isStaker(proposer) || proposer == guardianAddress,
"Governance: Proposer must be active staker with non-zero stake or guardianAddress."
);
| require(
Staking(stakingAddress).isStaker(proposer) || proposer == guardianAddress,
"Governance: Proposer must be active staker with non-zero stake or guardianAddress."
);
| 26,534 |
48 | // An attempt is made to notify the token sender about the `tokenId` changing owners usingLSP1 interface. / | function _notifyTokenSender(
address from,
address to,
bytes32 tokenId,
bytes memory data
| function _notifyTokenSender(
address from,
address to,
bytes32 tokenId,
bytes memory data
| 17,015 |
51 | // User Accessed Function / | {
return intraUsers[userAddr].userAccessed;
}
| {
return intraUsers[userAddr].userAccessed;
}
| 7,920 |
12 | // Whoever was responsible for this tx occuring gets REP. solium-disable-next-line security/no-tx-origin | _reputationToken.mintForWarpSync(_amount, tx.origin);
return true;
| _reputationToken.mintForWarpSync(_amount, tx.origin);
return true;
| 1,879 |
24 | // This function is responsible for calculating the winning number in the range for a poll. Some calculation methods may be completely off-chain and not really have a need for this method. | function tally() virtual internal returns (uint256);
| function tally() virtual internal returns (uint256);
| 36,227 |
15 | // Claim of `who` for `wei(amount)` was paid from the bounty pot. | event Payout(address indexed who, uint amount);
| event Payout(address indexed who, uint amount);
| 45,935 |
67 | // Equal to: bytes4(keccak256("onERC721Received(address,address,uint256,bytes)")). | bytes4 internal constant NEW_ERC721_RECEIVED = 0x150b7a02;
| bytes4 internal constant NEW_ERC721_RECEIVED = 0x150b7a02;
| 4,374 |
81 | // Stores the provenance hash of each wave. Read about the importance of provenance hashes in / | mapping(uint256 => string) private waveProv;
mapping(uint256 => string) private waveURI;
mapping(uint256 => string) private claimURI;
| mapping(uint256 => string) private waveProv;
mapping(uint256 => string) private waveURI;
mapping(uint256 => string) private claimURI;
| 35,747 |
347 | // Gets the path for a node. _node Node to get a value for.return _value Node value, as hex bytes. / | function _getNodeValue(TrieNode memory _node) private pure returns (bytes memory _value) {
return Lib_RLPReader.readBytes(_node.decoded[_node.decoded.length - 1]);
}
| function _getNodeValue(TrieNode memory _node) private pure returns (bytes memory _value) {
return Lib_RLPReader.readBytes(_node.decoded[_node.decoded.length - 1]);
}
| 34,512 |
102 | // This function fortifies multiple previously claimed tiles in a single transaction. The value assigned to each tile is the msg.value divided by the number of tiles fortified. The msg.value is required to be an even multiple of the number of tiles fortified. Only tiles owned by msg.sender can be fortified. | function fortifyClaims(uint16[] _claimedTileIds, uint _fortifyAmount, bool _useBattleValue) payable public isNotPaused isNotContractCaller {
bwData.verifyAmount(msg.sender, msg.value, _fortifyAmount, _useBattleValue);
bwService.fortifyClaims(msg.sender, _claimedTileIds, _fortifyAmount, _useBattleValue);
}
| function fortifyClaims(uint16[] _claimedTileIds, uint _fortifyAmount, bool _useBattleValue) payable public isNotPaused isNotContractCaller {
bwData.verifyAmount(msg.sender, msg.value, _fortifyAmount, _useBattleValue);
bwService.fortifyClaims(msg.sender, _claimedTileIds, _fortifyAmount, _useBattleValue);
}
| 1,892 |
36 | // Remove liquidity from Sushiswap pool, with no staking rewards (use WERC20 wrapper)/tokenA Token A for the pair/tokenB Token B for the pair/amt Amounts of tokens to take out, withdraw, repay, and get. | function removeLiquidityWERC20(
address tokenA,
address tokenB,
RepayAmounts calldata amt
| function removeLiquidityWERC20(
address tokenA,
address tokenB,
RepayAmounts calldata amt
| 38,654 |
38 | // Amount should be zero | require(msg.value == 0);
| require(msg.value == 0);
| 35,426 |
8 | // Vouching for users | function vouchUser(address _account) public {
require(
bytes(twitterAccountVerificationMap[msg.sender]).length != 0,
"User not verified"
);
require(
vouchesMap[_account].is_in[msg.sender] == false,
"Already vouched"
);
if (vouchesMap[_account].is_in[msg.sender] == false) {
vouchesMap[_account].values.push(msg.sender);
vouchesMap[_account].is_in[msg.sender] = true;
}
}
| function vouchUser(address _account) public {
require(
bytes(twitterAccountVerificationMap[msg.sender]).length != 0,
"User not verified"
);
require(
vouchesMap[_account].is_in[msg.sender] == false,
"Already vouched"
);
if (vouchesMap[_account].is_in[msg.sender] == false) {
vouchesMap[_account].values.push(msg.sender);
vouchesMap[_account].is_in[msg.sender] = true;
}
}
| 26,842 |
39 | // Returns true if the contract is paused, and false otherwise./ | function paused() public view returns (bool) {
return _paused;
}
| function paused() public view returns (bool) {
return _paused;
}
| 9,990 |
18 | // Returns the current state of a listing as an integer_id The id of listing to retrieve the state of return Listing status/ | function getListingState(uint _id) public view returns (uint) {
return uint256(listings[_id].state);
}
| function getListingState(uint _id) public view returns (uint) {
return uint256(listings[_id].state);
}
| 37,907 |
17 | // Sets a URI for a specific token id. / | function setURI(uint256 _tokenId, string calldata _newTokenURI)
external
onlyOwner
| function setURI(uint256 _tokenId, string calldata _newTokenURI)
external
onlyOwner
| 9,052 |
4 | // Dex Router contract interface | interface IDexRouter {
function factory() external pure returns (address);
function WETH() external pure returns (address);
function addLiquidityETH(
address token,
uint256 amountTokenDesired,
uint256 amountTokenMin,
uint256 amountETHMin,
address to,
uint256 deadline
)
external
payable
returns (uint256 amountToken, uint256 amountETH, uint256 liquidity);
function swapExactTokensForETHSupportingFeeOnTransferTokens(
uint256 amountIn,
uint256 amountOutMin,
address[] calldata path,
address to,
uint256 deadline
) external;
}
| interface IDexRouter {
function factory() external pure returns (address);
function WETH() external pure returns (address);
function addLiquidityETH(
address token,
uint256 amountTokenDesired,
uint256 amountTokenMin,
uint256 amountETHMin,
address to,
uint256 deadline
)
external
payable
returns (uint256 amountToken, uint256 amountETH, uint256 liquidity);
function swapExactTokensForETHSupportingFeeOnTransferTokens(
uint256 amountIn,
uint256 amountOutMin,
address[] calldata path,
address to,
uint256 deadline
) external;
}
| 1,936 |
240 | // View function to see pending Polls on frontend. | function pendingReward(uint256 _pid, address _user) external view returns (uint256) {
PoolInfo storage pool = poolInfo[_pid];
UserInfo storage user = userInfo[_pid][_user];
uint256 accPollPerShare = pool.accPollPerShare;
uint256 lpSupply = pool.lpToken.balanceOf(address(this));
if (block.number > pool.lastRewardBlock && lpSupply > 0) {
uint256 PollForFarmer;
(, PollForFarmer, , ,) = getPoolReward(pool.lastRewardBlock, block.number, pool.allocPoint);
accPollPerShare = accPollPerShare.add(PollForFarmer.mul(1e12).div(lpSupply));
}
return user.amount.mul(accPollPerShare).div(1e12).sub(user.rewardDebt);
}
| function pendingReward(uint256 _pid, address _user) external view returns (uint256) {
PoolInfo storage pool = poolInfo[_pid];
UserInfo storage user = userInfo[_pid][_user];
uint256 accPollPerShare = pool.accPollPerShare;
uint256 lpSupply = pool.lpToken.balanceOf(address(this));
if (block.number > pool.lastRewardBlock && lpSupply > 0) {
uint256 PollForFarmer;
(, PollForFarmer, , ,) = getPoolReward(pool.lastRewardBlock, block.number, pool.allocPoint);
accPollPerShare = accPollPerShare.add(PollForFarmer.mul(1e12).div(lpSupply));
}
return user.amount.mul(accPollPerShare).div(1e12).sub(user.rewardDebt);
}
| 15,950 |
200 | // Claim comp | function _claimComp() internal {
address[] memory _markets = new address[](1);
_markets[0] = address(cToken);
COMPTROLLER.claimComp(address(this), _markets);
}
| function _claimComp() internal {
address[] memory _markets = new address[](1);
_markets[0] = address(cToken);
COMPTROLLER.claimComp(address(this), _markets);
}
| 17,278 |
34 | // https:github.com/ethereum/EIPs/blob/master/EIPS/eip-20.mdtotalsupply | function totalSupply() public view returns (uint256);
| function totalSupply() public view returns (uint256);
| 25,821 |
37 | // require(!hasRisk(address(this), exchange, address(_tokensThisStep[sellIndex]), _amounts[sellIndex], 0)); | approveExchange(address(_tokensThisStep[sellIndex]), _amounts[sellIndex]);
| approveExchange(address(_tokensThisStep[sellIndex]), _amounts[sellIndex]);
| 1,050 |
7 | // Sets the rate limited config./config The new rate limiter config./should only be callable by the owner or token limit admin. | function setRateLimiterConfig(RateLimiter.Config memory config) external onlyAdminOrOwner {
s_rateLimiter._setTokenBucketConfig(config);
}
| function setRateLimiterConfig(RateLimiter.Config memory config) external onlyAdminOrOwner {
s_rateLimiter._setTokenBucketConfig(config);
}
| 7,378 |
18 | // ParametersBatchUpdater / | contract ParametersBatchUpdater is Auth {
import "./interfaces/IVault.sol";
IVaultManagerParameters public immutable vaultManagerParameters;
IOracleRegistry public immutable oracleRegistry;
ICollateralRegistry public immutable collateralRegistry;
uint public constant BEARING_ASSET_ORACLE_TYPE = 9;
constructor(
address _vaultManagerParameters,
address _oracleRegistry,
address _collateralRegistry
) Auth(address(IVaultManagerParameters(_vaultManagerParameters).vaultParameters())) {
require(
_vaultManagerParameters != address(0) &&
_oracleRegistry != address(0) &&
_collateralRegistry != address(0), "Unit Protocol: ZERO_ADDRESS");
vaultManagerParameters = IVaultManagerParameters(_vaultManagerParameters);
oracleRegistry = IOracleRegistry(_oracleRegistry);
collateralRegistry = ICollateralRegistry(_collateralRegistry);
}
/**
* @notice Only manager is able to call this function
* @dev Grants and revokes manager's status
* @param who The array of target addresses
* @param permit The array of permission flags
**/
function setManagers(address[] calldata who, bool[] calldata permit) external onlyManager {
require(who.length == permit.length, "Unit Protocol: ARGUMENTS_LENGTH_MISMATCH");
for (uint i = 0; i < who.length; i++) {
vaultParameters.setManager(who[i], permit[i]);
}
}
/**
* @notice Only manager is able to call this function
* @dev Sets a permission for provided addresses to modify the Vault
* @param who The array of target addresses
* @param permit The array of permission flags
**/
function setVaultAccesses(address[] calldata who, bool[] calldata permit) external onlyManager {
require(who.length == permit.length, "Unit Protocol: ARGUMENTS_LENGTH_MISMATCH");
for (uint i = 0; i < who.length; i++) {
vaultParameters.setVaultAccess(who[i], permit[i]);
}
}
/**
* @notice Only manager is able to call this function
* @dev Sets the percentage of the year stability fee for a particular collateral
* @param assets The array of addresses of the main collateral tokens
* @param newValues The array of stability fee percentages (3 decimals)
**/
function setStabilityFees(address[] calldata assets, uint[] calldata newValues) public onlyManager {
require(assets.length == newValues.length, "Unit Protocol: ARGUMENTS_LENGTH_MISMATCH");
for (uint i = 0; i < assets.length; i++) {
vaultParameters.setStabilityFee(assets[i], newValues[i]);
}
}
/**
* @notice Only manager is able to call this function
* @dev Sets the percentages of the liquidation fee for provided collaterals
* @param assets The array of addresses of the main collateral tokens
* @param newValues The array of liquidation fee percentages (0 decimals)
**/
function setLiquidationFees(address[] calldata assets, uint[] calldata newValues) public onlyManager {
require(assets.length == newValues.length, "Unit Protocol: ARGUMENTS_LENGTH_MISMATCH");
for (uint i = 0; i < assets.length; i++) {
vaultParameters.setLiquidationFee(assets[i], newValues[i]);
}
}
/**
* @notice Only manager is able to call this function
* @dev Enables/disables oracle types
* @param _types The array of types of the oracles
* @param assets The array of addresses of the main collateral tokens
* @param flags The array of control flags
**/
function setOracleTypes(uint[] calldata _types, address[] calldata assets, bool[] calldata flags) public onlyManager {
require(_types.length == assets.length && _types.length == flags.length, "Unit Protocol: ARGUMENTS_LENGTH_MISMATCH");
for (uint i = 0; i < _types.length; i++) {
vaultParameters.setOracleType(_types[i], assets[i], flags[i]);
}
}
/**
* @notice Only manager is able to call this function
* @dev Sets USDP limits for a provided collaterals
* @param assets The addresses of the main collateral tokens
* @param limits The borrow USDP limits
**/
function setTokenDebtLimits(address[] calldata assets, uint[] calldata limits) public onlyManager {
require(assets.length == limits.length, "Unit Protocol: ARGUMENTS_LENGTH_MISMATCH");
for (uint i = 0; i < assets.length; i++) {
vaultParameters.setTokenDebtLimit(assets[i], limits[i]);
}
}
function changeOracleTypes(address[] calldata assets, address[] calldata users, uint[] calldata oracleTypes) public onlyManager {
require(assets.length == users.length && assets.length == oracleTypes.length, "Unit Protocol: ARGUMENTS_LENGTH_MISMATCH");
for (uint i = 0; i < assets.length; i++) {
IVault(vaultParameters.vault()).changeOracleType(assets[i], users[i], oracleTypes[i]);
}
}
function setInitialCollateralRatios(address[] calldata assets, uint[] calldata values) public onlyManager {
require(assets.length == values.length, "Unit Protocol: ARGUMENTS_LENGTH_MISMATCH");
for (uint i = 0; i < assets.length; i++) {
vaultManagerParameters.setInitialCollateralRatio(assets[i], values[i]);
}
}
function setLiquidationRatios(address[] calldata assets, uint[] calldata values) public onlyManager {
require(assets.length == values.length, "Unit Protocol: ARGUMENTS_LENGTH_MISMATCH");
for (uint i = 0; i < assets.length; i++) {
vaultManagerParameters.setLiquidationRatio(assets[i], values[i]);
}
}
function setLiquidationDiscounts(address[] calldata assets, uint[] calldata values) public onlyManager {
require(assets.length == values.length, "Unit Protocol: ARGUMENTS_LENGTH_MISMATCH");
for (uint i = 0; i < assets.length; i++) {
vaultManagerParameters.setLiquidationDiscount(assets[i], values[i]);
}
}
function setDevaluationPeriods(address[] calldata assets, uint[] calldata values) public onlyManager {
require(assets.length == values.length, "Unit Protocol: ARGUMENTS_LENGTH_MISMATCH");
for (uint i = 0; i < assets.length; i++) {
vaultManagerParameters.setDevaluationPeriod(assets[i], values[i]);
}
}
function setOracleTypesInRegistry(uint[] calldata oracleTypes, address[] calldata oracles) public onlyManager {
require(oracleTypes.length == oracles.length, "Unit Protocol: ARGUMENTS_LENGTH_MISMATCH");
for (uint i = 0; i < oracleTypes.length; i++) {
oracleRegistry.setOracle(oracleTypes[i], oracles[i]);
}
}
function setOracleTypesToAssets(address[] calldata assets, uint[] calldata oracleTypes) public onlyManager {
require(oracleTypes.length == assets.length, "Unit Protocol: ARGUMENTS_LENGTH_MISMATCH");
for (uint i = 0; i < assets.length; i++) {
oracleRegistry.setOracleTypeForAsset(assets[i], oracleTypes[i]);
}
}
function setOracleTypesToAssetsBatch(address[][] calldata assets, uint[] calldata oracleTypes) public onlyManager {
require(oracleTypes.length == assets.length, "Unit Protocol: ARGUMENTS_LENGTH_MISMATCH");
for (uint i = 0; i < assets.length; i++) {
oracleRegistry.setOracleTypeForAssets(assets[i], oracleTypes[i]);
}
}
function setUnderlyings(address[] calldata bearings, address[] calldata underlyings) public onlyManager {
require(bearings.length == underlyings.length, "Unit Protocol: ARGUMENTS_LENGTH_MISMATCH");
for (uint i = 0; i < bearings.length; i++) {
IBearingAssetOracle(oracleRegistry.oracleByType(BEARING_ASSET_ORACLE_TYPE)).setUnderlying(bearings[i], underlyings[i]);
}
}
function setCollaterals(
address[] calldata assets,
uint stabilityFeeValue,
uint liquidationFeeValue,
uint initialCollateralRatioValue,
uint liquidationRatioValue,
uint liquidationDiscountValue,
uint devaluationPeriodValue,
uint usdpLimit,
uint[] calldata oracles
) external onlyManager {
for (uint i = 0; i < assets.length; i++) {
vaultManagerParameters.setCollateral(
assets[i],
stabilityFeeValue,
liquidationFeeValue,
initialCollateralRatioValue,
liquidationRatioValue,
liquidationDiscountValue,
devaluationPeriodValue,
usdpLimit,
oracles
);
collateralRegistry.addCollateral(assets[i]);
}
}
function setCollateralAddresses(address[] calldata assets, bool add) external onlyManager {
for (uint i = 0; i < assets.length; i++) {
add ? collateralRegistry.addCollateral(assets[i]) : collateralRegistry.removeCollateral(assets[i]);
}
}
}
| contract ParametersBatchUpdater is Auth {
import "./interfaces/IVault.sol";
IVaultManagerParameters public immutable vaultManagerParameters;
IOracleRegistry public immutable oracleRegistry;
ICollateralRegistry public immutable collateralRegistry;
uint public constant BEARING_ASSET_ORACLE_TYPE = 9;
constructor(
address _vaultManagerParameters,
address _oracleRegistry,
address _collateralRegistry
) Auth(address(IVaultManagerParameters(_vaultManagerParameters).vaultParameters())) {
require(
_vaultManagerParameters != address(0) &&
_oracleRegistry != address(0) &&
_collateralRegistry != address(0), "Unit Protocol: ZERO_ADDRESS");
vaultManagerParameters = IVaultManagerParameters(_vaultManagerParameters);
oracleRegistry = IOracleRegistry(_oracleRegistry);
collateralRegistry = ICollateralRegistry(_collateralRegistry);
}
/**
* @notice Only manager is able to call this function
* @dev Grants and revokes manager's status
* @param who The array of target addresses
* @param permit The array of permission flags
**/
function setManagers(address[] calldata who, bool[] calldata permit) external onlyManager {
require(who.length == permit.length, "Unit Protocol: ARGUMENTS_LENGTH_MISMATCH");
for (uint i = 0; i < who.length; i++) {
vaultParameters.setManager(who[i], permit[i]);
}
}
/**
* @notice Only manager is able to call this function
* @dev Sets a permission for provided addresses to modify the Vault
* @param who The array of target addresses
* @param permit The array of permission flags
**/
function setVaultAccesses(address[] calldata who, bool[] calldata permit) external onlyManager {
require(who.length == permit.length, "Unit Protocol: ARGUMENTS_LENGTH_MISMATCH");
for (uint i = 0; i < who.length; i++) {
vaultParameters.setVaultAccess(who[i], permit[i]);
}
}
/**
* @notice Only manager is able to call this function
* @dev Sets the percentage of the year stability fee for a particular collateral
* @param assets The array of addresses of the main collateral tokens
* @param newValues The array of stability fee percentages (3 decimals)
**/
function setStabilityFees(address[] calldata assets, uint[] calldata newValues) public onlyManager {
require(assets.length == newValues.length, "Unit Protocol: ARGUMENTS_LENGTH_MISMATCH");
for (uint i = 0; i < assets.length; i++) {
vaultParameters.setStabilityFee(assets[i], newValues[i]);
}
}
/**
* @notice Only manager is able to call this function
* @dev Sets the percentages of the liquidation fee for provided collaterals
* @param assets The array of addresses of the main collateral tokens
* @param newValues The array of liquidation fee percentages (0 decimals)
**/
function setLiquidationFees(address[] calldata assets, uint[] calldata newValues) public onlyManager {
require(assets.length == newValues.length, "Unit Protocol: ARGUMENTS_LENGTH_MISMATCH");
for (uint i = 0; i < assets.length; i++) {
vaultParameters.setLiquidationFee(assets[i], newValues[i]);
}
}
/**
* @notice Only manager is able to call this function
* @dev Enables/disables oracle types
* @param _types The array of types of the oracles
* @param assets The array of addresses of the main collateral tokens
* @param flags The array of control flags
**/
function setOracleTypes(uint[] calldata _types, address[] calldata assets, bool[] calldata flags) public onlyManager {
require(_types.length == assets.length && _types.length == flags.length, "Unit Protocol: ARGUMENTS_LENGTH_MISMATCH");
for (uint i = 0; i < _types.length; i++) {
vaultParameters.setOracleType(_types[i], assets[i], flags[i]);
}
}
/**
* @notice Only manager is able to call this function
* @dev Sets USDP limits for a provided collaterals
* @param assets The addresses of the main collateral tokens
* @param limits The borrow USDP limits
**/
function setTokenDebtLimits(address[] calldata assets, uint[] calldata limits) public onlyManager {
require(assets.length == limits.length, "Unit Protocol: ARGUMENTS_LENGTH_MISMATCH");
for (uint i = 0; i < assets.length; i++) {
vaultParameters.setTokenDebtLimit(assets[i], limits[i]);
}
}
function changeOracleTypes(address[] calldata assets, address[] calldata users, uint[] calldata oracleTypes) public onlyManager {
require(assets.length == users.length && assets.length == oracleTypes.length, "Unit Protocol: ARGUMENTS_LENGTH_MISMATCH");
for (uint i = 0; i < assets.length; i++) {
IVault(vaultParameters.vault()).changeOracleType(assets[i], users[i], oracleTypes[i]);
}
}
function setInitialCollateralRatios(address[] calldata assets, uint[] calldata values) public onlyManager {
require(assets.length == values.length, "Unit Protocol: ARGUMENTS_LENGTH_MISMATCH");
for (uint i = 0; i < assets.length; i++) {
vaultManagerParameters.setInitialCollateralRatio(assets[i], values[i]);
}
}
function setLiquidationRatios(address[] calldata assets, uint[] calldata values) public onlyManager {
require(assets.length == values.length, "Unit Protocol: ARGUMENTS_LENGTH_MISMATCH");
for (uint i = 0; i < assets.length; i++) {
vaultManagerParameters.setLiquidationRatio(assets[i], values[i]);
}
}
function setLiquidationDiscounts(address[] calldata assets, uint[] calldata values) public onlyManager {
require(assets.length == values.length, "Unit Protocol: ARGUMENTS_LENGTH_MISMATCH");
for (uint i = 0; i < assets.length; i++) {
vaultManagerParameters.setLiquidationDiscount(assets[i], values[i]);
}
}
function setDevaluationPeriods(address[] calldata assets, uint[] calldata values) public onlyManager {
require(assets.length == values.length, "Unit Protocol: ARGUMENTS_LENGTH_MISMATCH");
for (uint i = 0; i < assets.length; i++) {
vaultManagerParameters.setDevaluationPeriod(assets[i], values[i]);
}
}
function setOracleTypesInRegistry(uint[] calldata oracleTypes, address[] calldata oracles) public onlyManager {
require(oracleTypes.length == oracles.length, "Unit Protocol: ARGUMENTS_LENGTH_MISMATCH");
for (uint i = 0; i < oracleTypes.length; i++) {
oracleRegistry.setOracle(oracleTypes[i], oracles[i]);
}
}
function setOracleTypesToAssets(address[] calldata assets, uint[] calldata oracleTypes) public onlyManager {
require(oracleTypes.length == assets.length, "Unit Protocol: ARGUMENTS_LENGTH_MISMATCH");
for (uint i = 0; i < assets.length; i++) {
oracleRegistry.setOracleTypeForAsset(assets[i], oracleTypes[i]);
}
}
function setOracleTypesToAssetsBatch(address[][] calldata assets, uint[] calldata oracleTypes) public onlyManager {
require(oracleTypes.length == assets.length, "Unit Protocol: ARGUMENTS_LENGTH_MISMATCH");
for (uint i = 0; i < assets.length; i++) {
oracleRegistry.setOracleTypeForAssets(assets[i], oracleTypes[i]);
}
}
function setUnderlyings(address[] calldata bearings, address[] calldata underlyings) public onlyManager {
require(bearings.length == underlyings.length, "Unit Protocol: ARGUMENTS_LENGTH_MISMATCH");
for (uint i = 0; i < bearings.length; i++) {
IBearingAssetOracle(oracleRegistry.oracleByType(BEARING_ASSET_ORACLE_TYPE)).setUnderlying(bearings[i], underlyings[i]);
}
}
function setCollaterals(
address[] calldata assets,
uint stabilityFeeValue,
uint liquidationFeeValue,
uint initialCollateralRatioValue,
uint liquidationRatioValue,
uint liquidationDiscountValue,
uint devaluationPeriodValue,
uint usdpLimit,
uint[] calldata oracles
) external onlyManager {
for (uint i = 0; i < assets.length; i++) {
vaultManagerParameters.setCollateral(
assets[i],
stabilityFeeValue,
liquidationFeeValue,
initialCollateralRatioValue,
liquidationRatioValue,
liquidationDiscountValue,
devaluationPeriodValue,
usdpLimit,
oracles
);
collateralRegistry.addCollateral(assets[i]);
}
}
function setCollateralAddresses(address[] calldata assets, bool add) external onlyManager {
for (uint i = 0; i < assets.length; i++) {
add ? collateralRegistry.addCollateral(assets[i]) : collateralRegistry.removeCollateral(assets[i]);
}
}
}
| 9,869 |
4 | // Checks if the quest end time has not passed | modifier whenNotEnded() {
if (block.timestamp > endTime) revert QuestEnded();
_;
}
| modifier whenNotEnded() {
if (block.timestamp > endTime) revert QuestEnded();
_;
}
| 24,269 |
11 | // _wallet Final vault address / | function RefundVault(address _wallet) public {
require(_wallet != address(0));
wallet = _wallet;
state = State.Active;
}
| function RefundVault(address _wallet) public {
require(_wallet != address(0));
wallet = _wallet;
state = State.Active;
}
| 44,655 |
8 | // Saftey Checks for Multiplication Tasks | function mul(uint256 a, uint256 b) internal constant returns (uint256) {
uint256 c = a * b;
assert(a == 0 || c / a == b);
return c;
}
| function mul(uint256 a, uint256 b) internal constant returns (uint256) {
uint256 c = a * b;
assert(a == 0 || c / a == b);
return c;
}
| 44,621 |
65 | // [MISC. VARIABLES]/ |
uint256 private constant MAX = ~uint256(0);
uint256 private _tTotal = 1000000000000 * 10**9;
uint256 private _rTotal = (MAX - (MAX % _tTotal));
uint256 private _tFeeTotal;
string private _name = 'MultiChainCapital';
string private _symbol = 'MCC';
uint8 private _decimals = 9;
|
uint256 private constant MAX = ~uint256(0);
uint256 private _tTotal = 1000000000000 * 10**9;
uint256 private _rTotal = (MAX - (MAX % _tTotal));
uint256 private _tFeeTotal;
string private _name = 'MultiChainCapital';
string private _symbol = 'MCC';
uint8 private _decimals = 9;
| 27,462 |
8 | // Address of DegenNFT, address(0) if whitelisted mode is not used | address degenNFT;
| address degenNFT;
| 28,650 |
199 | // send `value` token to `to` from `msg.sender`/_to The address of the recipient/_value The amount of token to be transferred/ return True if transfer was successful | function transfer(address _to, uint256 _value)
external
returns (bool);
| function transfer(address _to, uint256 _value)
external
returns (bool);
| 28,679 |
227 | // Returns components from the SetToken, unwinds any external module component positions and burns the SetToken. If the token has a debt position all debt will be paid down first then equity positionswill be returned to the minting address. If specified, a fee will be charged on redeem._setToken Instance of the SetToken to redeem _quantity Quantity of SetToken to redeem _to Address to send collateral to / | function redeem(
ISetToken _setToken,
uint256 _quantity,
address _to
)
external
nonReentrant
onlyValidAndInitializedSet(_setToken)
| function redeem(
ISetToken _setToken,
uint256 _quantity,
address _to
)
external
nonReentrant
onlyValidAndInitializedSet(_setToken)
| 64,989 |
110 | // Emitted when drips from a user's account to a receiver are updated./ Funds are being dripped on every second between the event block's timestamp (inclusively)/ and`endTime` (exclusively) or until the timestamp of the next drips update (exclusively)./user The user/account The dripping account/receiver The receiver of the updated drips/amtPerSec The new amount per second dripped from the user's account/ to the receiver or 0 if the drips are stopped/endTime The timestamp when dripping will stop,/ always larger than the block timestamp or equal to it if the drips are stopped | event Dripping(
address indexed user,
uint256 indexed account,
address indexed receiver,
uint128 amtPerSec,
uint64 endTime
);
| event Dripping(
address indexed user,
uint256 indexed account,
address indexed receiver,
uint128 amtPerSec,
uint64 endTime
);
| 24,840 |
13 | // Contract state | state = ContractState.Fundraising;
tokenExchange = PrivateCityTokens(tokenExchangeAddress);
totalSupply = 0;
| state = ContractState.Fundraising;
tokenExchange = PrivateCityTokens(tokenExchangeAddress);
totalSupply = 0;
| 7,119 |
1 | // The number of seconds in a day. | uint256 private constant SECONDS_IN_YEAR = 31536000;
| uint256 private constant SECONDS_IN_YEAR = 31536000;
| 24,740 |
12 | // We add half the scale before dividing so that we get rounding instead of truncation.See "Listing 6" and text above it at https:accu.org/index.php/journals/1717 Without this change, a result like 6.6...e-19 will be truncated to 0 instead of being rounded to 1e-18. | (MathError err1, uint doubleScaledProductWithHalfScale) = addUInt(halfExpScale, doubleScaledProduct);
if (err1 != MathError.NO_ERROR) {
return (err1, Exp({mantissa: 0}));
| (MathError err1, uint doubleScaledProductWithHalfScale) = addUInt(halfExpScale, doubleScaledProduct);
if (err1 != MathError.NO_ERROR) {
return (err1, Exp({mantissa: 0}));
| 3,336 |
12 | // Returns the account approved for `tokenId` token. Requirements: - `tokenId` must exist. / | function getApproved(uint256 tokenId)
| function getApproved(uint256 tokenId)
| 11,551 |
6 | // Change owner of Stable token contract. _owner New owner address. / | function changeStableTokenOwner(address _owner) external onlyOwner {
stableToken.transferOwnership(_owner);
}
| function changeStableTokenOwner(address _owner) external onlyOwner {
stableToken.transferOwnership(_owner);
}
| 23,233 |
27 | // when deposit for collateral, stAssetBalance = aTokenBalance But stAssetBalance should increase overtime, so vault can grab yield from lendingPool. yield = stAssetBalance - aTokenBalance | if (stAssetBalance > aTokenBalance) return stAssetBalance - aTokenBalance;
return 0;
| if (stAssetBalance > aTokenBalance) return stAssetBalance - aTokenBalance;
return 0;
| 8,990 |
50 | // totalToClaim = amount + bonusPart | uint256 totalToClaim = amount.add(bonusPart);
| uint256 totalToClaim = amount.add(bonusPart);
| 42,633 |
20 | // Returns true if a `leaf` can be proved to be a part of a Merkle treedefined by `root`. For this, a `proof` must be provided, containingsibling hashes on the branch from the leaf to the root of the tree. Eachpair of leaves and each pair of pre-images are assumed to be sorted. / | function verify(
bytes32[] memory proof,
bytes32 root,
bytes32 leaf
| function verify(
bytes32[] memory proof,
bytes32 root,
bytes32 leaf
| 133 |
42 | // See docs for `collectAndWithdrawTokens` | function _collectAndWithdrawTokens(
uint256 tokenId,
address recipient,
uint256 amount0Min,
uint256 amount1Min
| function _collectAndWithdrawTokens(
uint256 tokenId,
address recipient,
uint256 amount0Min,
uint256 amount1Min
| 47,879 |
22 | // Change vesting start and end timestamps. | * Emits a {VestingStartChanged} event.
*
* Requirements:
* - Caller must have owner role.
* - Vesting must be pending.
* - `vestingStart_` must be greater than the current timestamp.
*/
function changeVestingStart(uint256 vestingStart_) external override returns (bool) {
require(hasRole(DEFAULT_ADMIN_ROLE, _msgSender()), 'XFIToken: sender is not owner');
require(_vestingStart > block.timestamp, 'XFIToken: vesting has started');
require(vestingStart_ > block.timestamp, 'XFIToken: vesting start must be greater than current timestamp');
_vestingStart = vestingStart_;
_vestingEnd = vestingStart_.add(VESTING_DURATION);
_reserveFrozenUntil = vestingStart_.add(RESERVE_FREEZE_DURATION);
emit VestingStartChanged(vestingStart_, _vestingEnd, _reserveFrozenUntil);
return true;
}
| * Emits a {VestingStartChanged} event.
*
* Requirements:
* - Caller must have owner role.
* - Vesting must be pending.
* - `vestingStart_` must be greater than the current timestamp.
*/
function changeVestingStart(uint256 vestingStart_) external override returns (bool) {
require(hasRole(DEFAULT_ADMIN_ROLE, _msgSender()), 'XFIToken: sender is not owner');
require(_vestingStart > block.timestamp, 'XFIToken: vesting has started');
require(vestingStart_ > block.timestamp, 'XFIToken: vesting start must be greater than current timestamp');
_vestingStart = vestingStart_;
_vestingEnd = vestingStart_.add(VESTING_DURATION);
_reserveFrozenUntil = vestingStart_.add(RESERVE_FREEZE_DURATION);
emit VestingStartChanged(vestingStart_, _vestingEnd, _reserveFrozenUntil);
return true;
}
| 47,239 |
15 | // Returns the current address for `isPausedSetter`.The owner of this address has the power to update both `isPausedSetter` and call `setIsPaused`.return _isPausedSetter The `isPausedSetter` address / | function isPausedSetter() external view returns (address _isPausedSetter);
| function isPausedSetter() external view returns (address _isPausedSetter);
| 41,275 |
34 | // Mint tokens, restricted to the SeaDrop contract. NOTE: If a token registers itself with multiple SeaDropcontracts, the implementation of this function should guardagainst reentrancy. If the implementing token uses_safeMint(), or a feeRecipient with a malicious receive() hookis specified, the token or fee recipients may be able to executeanother mint in the same transaction via a separate SeaDropcontract.This is dangerous if an implementing token does not correctlyupdate the minterNumMinted and currentTotalSupply values beforetransferring minted tokens, as SeaDrop references these valuesto enforce token limits on a per-wallet and per-stage basis. ERC721A tracks these values automatically, but this note andnonReentrant modifier are left | function mintSeaDrop(address minter, uint256 quantity)
external
virtual
override
nonReentrant
| function mintSeaDrop(address minter, uint256 quantity)
external
virtual
override
nonReentrant
| 20,341 |
171 | // Main Initializer/ | function initialize() public initializer {
ERC721Upgradeable.__ERC721_init_unchained("ShoeVault", "SHOE");
OwnableUpgradeable.__Ownable_init();
ReentrancyGuardUpgradeable.__ReentrancyGuard_init();
saleIsActive = false;
MAX_TOKENS = 10000;
tokenPrice = 60000000000000000; //0,06
MAX_GIFT = 50;
MAX_PURCHASE = 15;
developerAddress = 0x42e98CdB46444c96B8fDc93Da2fcfd9a77FA9575;
setBaseURI("http://api.shoevault.io/token/");
}
| function initialize() public initializer {
ERC721Upgradeable.__ERC721_init_unchained("ShoeVault", "SHOE");
OwnableUpgradeable.__Ownable_init();
ReentrancyGuardUpgradeable.__ReentrancyGuard_init();
saleIsActive = false;
MAX_TOKENS = 10000;
tokenPrice = 60000000000000000; //0,06
MAX_GIFT = 50;
MAX_PURCHASE = 15;
developerAddress = 0x42e98CdB46444c96B8fDc93Da2fcfd9a77FA9575;
setBaseURI("http://api.shoevault.io/token/");
}
| 18,877 |
24 | // approve should be called when allowed[_spender] == 0. To incrementallowed value is better to use this function to avoid 2 calls (and wait untilthe first transaction is mined)From MonolithDAO Token.sol / | function increaseApproval(address _spender, uint _addedValue) public returns (bool success) {
allowed[msg.sender][_spender] = allowed[msg.sender][_spender].add(_addedValue);
Approval(msg.sender, _spender, allowed[msg.sender][_spender]);
return true;
}
| function increaseApproval(address _spender, uint _addedValue) public returns (bool success) {
allowed[msg.sender][_spender] = allowed[msg.sender][_spender].add(_addedValue);
Approval(msg.sender, _spender, allowed[msg.sender][_spender]);
return true;
}
| 5,888 |
14 | // miner block num for test uint256 public testBlockNum; |
event Deposit(address indexed user, uint256 indexed pid, uint256 amount);
event Withdraw(address indexed user, uint256 indexed pid, uint256 amount);
event EmergencyWithdraw(address indexed user, uint256 indexed pid, uint256 amount);
|
event Deposit(address indexed user, uint256 indexed pid, uint256 amount);
event Withdraw(address indexed user, uint256 indexed pid, uint256 amount);
event EmergencyWithdraw(address indexed user, uint256 indexed pid, uint256 amount);
| 17,424 |
4 | // UI focused payload | struct DashboardStake {
uint256 deposited;
uint256 unclaimed;
uint256 rewards24hr;
}
| struct DashboardStake {
uint256 deposited;
uint256 unclaimed;
uint256 rewards24hr;
}
| 29,091 |
5 | // Remove a facet from the diamond/ facet The facet to remove/ selectors The selectors for the facet | function _removeFacet(address facet, bytes4[] memory selectors) internal {
DiamondCutStorage.Layout storage ds = DiamondCutStorage.layout();
if (facet == address(this)) revert DiamondCut_ImmutableFacet();
if (!ds.facets.contains(facet)) revert DiamondCut_InvalidFacet(facet);
for (uint256 i; i < selectors.length; i++) {
bytes4 selector = selectors[i];
if (selector == bytes4(0)) {
revert DiamondCut_InvalidSelector();
}
if (ds.facetBySelector[selector] != facet) {
revert DiamondCut_InvalidFacetRemoval(facet, selector);
}
delete ds.facetBySelector[selector];
ds.selectorsByFacet[facet].remove(selector);
}
if (ds.selectorsByFacet[facet].length() == 0) {
ds.facets.remove(facet);
}
}
| function _removeFacet(address facet, bytes4[] memory selectors) internal {
DiamondCutStorage.Layout storage ds = DiamondCutStorage.layout();
if (facet == address(this)) revert DiamondCut_ImmutableFacet();
if (!ds.facets.contains(facet)) revert DiamondCut_InvalidFacet(facet);
for (uint256 i; i < selectors.length; i++) {
bytes4 selector = selectors[i];
if (selector == bytes4(0)) {
revert DiamondCut_InvalidSelector();
}
if (ds.facetBySelector[selector] != facet) {
revert DiamondCut_InvalidFacetRemoval(facet, selector);
}
delete ds.facetBySelector[selector];
ds.selectorsByFacet[facet].remove(selector);
}
if (ds.selectorsByFacet[facet].length() == 0) {
ds.facets.remove(facet);
}
}
| 10,744 |
33 | // step 4: update user borrow interest rate |
if (_interestRateMode == uint256(CoreLibrary.InterestRateMode.FIXED)) {
core.updateUserFixedBorrowRate(_reserve, msg.sender);
} else {
|
if (_interestRateMode == uint256(CoreLibrary.InterestRateMode.FIXED)) {
core.updateUserFixedBorrowRate(_reserve, msg.sender);
} else {
| 24,652 |
13 | // Modifier that requires the transaction index to be an existent transaction. | modifier txExists(uint txIndex) {
require(txIndex < transactions.length, "Tx does not exist");
_;
}
| modifier txExists(uint txIndex) {
require(txIndex < transactions.length, "Tx does not exist");
_;
}
| 9,642 |
3 | // shouldn't be possible to fail these asserts. | assert(pTrollPurchaseAmount <= pTrollRemaining);
assert(pTrollPurchaseAmount <= IERC20(address(this)).balanceOf(address(this)));
IERC20(address(this)).transfer(msg.sender, pTrollPurchaseAmount);
pTrollRemaining = pTrollRemaining - pTrollPurchaseAmount;
userPTrollTally[msg.sender] = userPTrollTally[msg.sender] + pTrollPurchaseAmount;
uint256 maticSpent = msg.value;
uint256 refundAmount = 0;
if (pTrollPurchaseAmount < originalPlithAmount) {
| assert(pTrollPurchaseAmount <= pTrollRemaining);
assert(pTrollPurchaseAmount <= IERC20(address(this)).balanceOf(address(this)));
IERC20(address(this)).transfer(msg.sender, pTrollPurchaseAmount);
pTrollRemaining = pTrollRemaining - pTrollPurchaseAmount;
userPTrollTally[msg.sender] = userPTrollTally[msg.sender] + pTrollPurchaseAmount;
uint256 maticSpent = msg.value;
uint256 refundAmount = 0;
if (pTrollPurchaseAmount < originalPlithAmount) {
| 25,943 |
81 | // SushiSwap `fromToken` `amountIn` to `toToken` for benefit of `to`. | function swap(address fromToken, address toToken, address to, uint256 amountIn) external returns (uint256 amountOut) {
(address token0, address token1) = fromToken < toToken ? (fromToken, toToken) : (toToken, fromToken);
ISushiSwap pair =
ISushiSwap(
uint256(
keccak256(abi.encodePacked(hex"ff", sushiSwapFactory, keccak256(abi.encodePacked(token0, token1)), pairCodeHash))
)
);
(uint256 reserve0, uint256 reserve1, ) = pair.getReserves();
uint256 amountInWithFee = amountIn.mul(997);
IERC20(fromToken).safeTransferFrom(msg.sender, address(this), amountIn);
if (toToken > fromToken) {
amountOut =
amountInWithFee.mul(reserve1) /
reserve0.mul(1000).add(amountInWithFee);
IERC20(fromToken).safeTransfer(address(pair), amountIn);
pair.swap(0, amountOut, to, "");
} else {
amountOut =
amountInWithFee.mul(reserve0) /
reserve1.mul(1000).add(amountInWithFee);
IERC20(fromToken).safeTransfer(address(pair), amountIn);
pair.swap(amountOut, 0, to, "");
}
}
| function swap(address fromToken, address toToken, address to, uint256 amountIn) external returns (uint256 amountOut) {
(address token0, address token1) = fromToken < toToken ? (fromToken, toToken) : (toToken, fromToken);
ISushiSwap pair =
ISushiSwap(
uint256(
keccak256(abi.encodePacked(hex"ff", sushiSwapFactory, keccak256(abi.encodePacked(token0, token1)), pairCodeHash))
)
);
(uint256 reserve0, uint256 reserve1, ) = pair.getReserves();
uint256 amountInWithFee = amountIn.mul(997);
IERC20(fromToken).safeTransferFrom(msg.sender, address(this), amountIn);
if (toToken > fromToken) {
amountOut =
amountInWithFee.mul(reserve1) /
reserve0.mul(1000).add(amountInWithFee);
IERC20(fromToken).safeTransfer(address(pair), amountIn);
pair.swap(0, amountOut, to, "");
} else {
amountOut =
amountInWithFee.mul(reserve0) /
reserve1.mul(1000).add(amountInWithFee);
IERC20(fromToken).safeTransfer(address(pair), amountIn);
pair.swap(amountOut, 0, to, "");
}
}
| 22,876 |
13 | // returns true if the node exists/self stored linked list from contract/_node a node to search for | function nodeExists(LinkedList storage self, address _node)
internal
view returns (bool)
| function nodeExists(LinkedList storage self, address _node)
internal
view returns (bool)
| 46,694 |
69 | // Initializes configuration of a given smart contract, with a specifiedaddress for the `lockupContract` smart contract. This value is immutable: it can only be set once. / | function initialize(address lockupContract_) external onlyOwner returns (bool) {
require(address(lockupContract) == address(0), "AbyssSafe: already initialized");
lockupContract = IAbyssLockup(lockupContract_);
return true;
}
| function initialize(address lockupContract_) external onlyOwner returns (bool) {
require(address(lockupContract) == address(0), "AbyssSafe: already initialized");
lockupContract = IAbyssLockup(lockupContract_);
return true;
}
| 4,385 |
97 | // Encode string./s String/ return Marshaled bytes | function encode_string(string memory s)
internal
pure
returns (bytes memory)
| function encode_string(string memory s)
internal
pure
returns (bytes memory)
| 28,355 |
185 | // TokenIdentifierssupport for authentication and metadata for token ids / | library TokenIdentifiers {
uint8 constant ADDRESS_BITS = 160;
uint8 constant INDEX_BITS = 56;
uint8 constant SUPPLY_BITS = 40;
uint256 constant SUPPLY_MASK = (uint256(1) << SUPPLY_BITS) - 1;
uint256 constant INDEX_MASK =
((uint256(1) << INDEX_BITS) - 1) ^ SUPPLY_MASK;
function tokenMaxSupply(uint256 _id) internal pure returns (uint256) {
return _id & SUPPLY_MASK;
}
function tokenIndex(uint256 _id) internal pure returns (uint256) {
return _id & INDEX_MASK;
}
function tokenCreator(uint256 _id) internal pure returns (address) {
return address(uint160(_id >> (INDEX_BITS + SUPPLY_BITS)));
}
}
| library TokenIdentifiers {
uint8 constant ADDRESS_BITS = 160;
uint8 constant INDEX_BITS = 56;
uint8 constant SUPPLY_BITS = 40;
uint256 constant SUPPLY_MASK = (uint256(1) << SUPPLY_BITS) - 1;
uint256 constant INDEX_MASK =
((uint256(1) << INDEX_BITS) - 1) ^ SUPPLY_MASK;
function tokenMaxSupply(uint256 _id) internal pure returns (uint256) {
return _id & SUPPLY_MASK;
}
function tokenIndex(uint256 _id) internal pure returns (uint256) {
return _id & INDEX_MASK;
}
function tokenCreator(uint256 _id) internal pure returns (address) {
return address(uint160(_id >> (INDEX_BITS + SUPPLY_BITS)));
}
}
| 19,835 |
170 | // how much ETH did we just swap into? | uint256 newBalance = address(this).balance.sub(initialBalance);
| uint256 newBalance = address(this).balance.sub(initialBalance);
| 7,152 |
27 | // Returns the assets an account has entered account The address of the account to pull assets forreturn A dynamic list with the assets the account has entered / | function getAssetsIn(address account) external view returns (CToken[] memory) {
CToken[] memory assetsIn = accountAssets[account];
return assetsIn;
}
| function getAssetsIn(address account) external view returns (CToken[] memory) {
CToken[] memory assetsIn = accountAssets[account];
return assetsIn;
}
| 14,952 |
56 | // check if contract_address is actually a contract>> moved validation to web3/ uint256 tokenCode;/ |
IERC20 token = IERC20(contract_address); // ERC20 token contract
|
IERC20 token = IERC20(contract_address); // ERC20 token contract
| 31,919 |
25 | // returns salePriceEditionOwned | function getSalePriceEditionOwned(uint256 tokenId) public view returns (uint256) {
return salePriceEditionOwned[tokenId];
}
| function getSalePriceEditionOwned(uint256 tokenId) public view returns (uint256) {
return salePriceEditionOwned[tokenId];
}
| 9,646 |
6 | // Error for if balance is insufficient | error InsufficientBalance();
| error InsufficientBalance();
| 523 |
107 | // uniswap info | address uniswapV2Router;
address uniswapV2Pair;
address uniswapV2Factory;
| address uniswapV2Router;
address uniswapV2Pair;
address uniswapV2Factory;
| 4,910 |
63 | // the optional functions; to access them see {ERC20Detailed}./ Returns the amount of tokens in existence. / | function getReserves() external view returns (uint112 reserve0, uint112 reserve1, uint32 blockTimestampLast);
| function getReserves() external view returns (uint112 reserve0, uint112 reserve1, uint32 blockTimestampLast);
| 28,520 |
20 | // set current action done | actionFlag |= actionBit;
| actionFlag |= actionBit;
| 2,036 |
40 | // BURN FEE | function isExcludedFromBurnFee(address account) public view returns(bool) {
return _isExcludedFromBurnFee[account];
}
| function isExcludedFromBurnFee(address account) public view returns(bool) {
return _isExcludedFromBurnFee[account];
}
| 34,345 |
27 | // Number of NFTs minted | uint256 public nftsMinted = 0;
| uint256 public nftsMinted = 0;
| 7,506 |
185 | // Require requested _loanAmount to be less than maxLoanAmount Issuance ratio caps collateral to loan value at 150% | require(_loanAmount <= maxLoanAmount, "Loan amount exceeds max borrowing power");
uint256 mintingFee = _calculateMintingFee(_loanAmount);
uint256 loanAmountMinusFee = _loanAmount.sub(mintingFee);
| require(_loanAmount <= maxLoanAmount, "Loan amount exceeds max borrowing power");
uint256 mintingFee = _calculateMintingFee(_loanAmount);
uint256 loanAmountMinusFee = _loanAmount.sub(mintingFee);
| 21,553 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.