Unnamed: 0
int64 0
7.36k
| comments
stringlengths 3
35.2k
| code_string
stringlengths 1
527k
| code
stringlengths 1
527k
| __index_level_0__
int64 0
88.6k
|
---|---|---|---|---|
5 | // 轉換eth < - >令牌的因素,具有所需的計算精度 | uint constant private precision_factor = 1e18;
| uint constant private precision_factor = 1e18;
| 12,553 |
24 | // _accredited The address of the accredited investor/_amountInEthers The amount of remaining ethers allowed to invested/ return Amount of remaining tokens allowed to spent | function setupAccreditedAddress(address _accredited, uint _amountInEthers) public returns (bool success) {
require(msg.sender == creator);
accredited[_accredited] = _amountInEthers * 1 ether;
return true;
}
| function setupAccreditedAddress(address _accredited, uint _amountInEthers) public returns (bool success) {
require(msg.sender == creator);
accredited[_accredited] = _amountInEthers * 1 ether;
return true;
}
| 1,426 |
11 | // this function might be usefull to query for the user old Spon tokens to display in frontend when the user connects his wallet | function oldSponBalance(address _user) public view returns (uint256){
uint256 QueryBalance = oldSponToken.balanceOf(_user);
return QueryBalance;
}
| function oldSponBalance(address _user) public view returns (uint256){
uint256 QueryBalance = oldSponToken.balanceOf(_user);
return QueryBalance;
}
| 28,116 |
11 | // 0 < lowerLimit < entryPoint => 0 < entryPoint | require(lowerLimit > 0, "lowerLimit must be above 0");
require(upperLimit > entryPoint, "upperLimit must be above the entryPoint");
require(upperLimit < entryPoint.mul(2), "upperLimit must be less than double entryPoint");
require(lowerLimit < entryPoint, "lowerLimit must be below the entryPoint");
require(!(freezeAtUpperLimit && freezeAtLowerLimit), "Cannot freeze at both limits");
InversePricing storage inverse = inversePricing[currencyKey];
if (inverse.entryPoint == 0) {
| require(lowerLimit > 0, "lowerLimit must be above 0");
require(upperLimit > entryPoint, "upperLimit must be above the entryPoint");
require(upperLimit < entryPoint.mul(2), "upperLimit must be less than double entryPoint");
require(lowerLimit < entryPoint, "lowerLimit must be below the entryPoint");
require(!(freezeAtUpperLimit && freezeAtLowerLimit), "Cannot freeze at both limits");
InversePricing storage inverse = inversePricing[currencyKey];
if (inverse.entryPoint == 0) {
| 26,150 |
1 | // TradePair is the data structure defining a trading pair on Dexalot. baseSymbolsymbol of the base asset quoteSymbolsymbol of the quote asset buyBookIdbuy book id for the trading pair sellBookIdsell book id for the trading pair minTradeAmountminimum trade amount maxTradeAmountmaximum trade amount auctionPriceprice during an auction auctionModecurrent auction mode of the trading pair makerRate fee rate for a maker order for the trading pair takerRate fee rate for taker order for the trading pair baseDecimalsevm decimals of the base asset baseDisplayDecimalsdisplay decimals of the base Asset. Quantity increment quoteDecimalsevm decimals of the quote asset quoteDisplayDecimalsdisplay decimals of the quote Asset. Price | struct TradePair {
bytes32 baseSymbol;
bytes32 quoteSymbol;
bytes32 buyBookId;
bytes32 sellBookId;
uint256 minTradeAmount;
uint256 maxTradeAmount;
uint256 auctionPrice;
AuctionMode auctionMode;
uint8 makerRate;
uint8 takerRate;
uint8 baseDecimals;
uint8 baseDisplayDecimals;
uint8 quoteDecimals;
uint8 quoteDisplayDecimals;
uint8 allowedSlippagePercent;
bool addOrderPaused;
bool pairPaused;
bool postOnly;
}
| struct TradePair {
bytes32 baseSymbol;
bytes32 quoteSymbol;
bytes32 buyBookId;
bytes32 sellBookId;
uint256 minTradeAmount;
uint256 maxTradeAmount;
uint256 auctionPrice;
AuctionMode auctionMode;
uint8 makerRate;
uint8 takerRate;
uint8 baseDecimals;
uint8 baseDisplayDecimals;
uint8 quoteDecimals;
uint8 quoteDisplayDecimals;
uint8 allowedSlippagePercent;
bool addOrderPaused;
bool pairPaused;
bool postOnly;
}
| 34,422 |
12 | // Get expected rates for the swapping source/target tokens. | (minRateValue, maxRateValue) = getKyberNetworkProxy().getExpectedRate(
sourceToken,
targetToken,
sourceAmount
);
| (minRateValue, maxRateValue) = getKyberNetworkProxy().getExpectedRate(
sourceToken,
targetToken,
sourceAmount
);
| 42,384 |
461 | // Fired if a SidechainTunnel was set | event SidechainTunnelSet(address sidechainTunnel);
| event SidechainTunnelSet(address sidechainTunnel);
| 72,790 |
3 | // The token address managed by the DAO that tracks the internal transfers | address public tokenAddress;
| address public tokenAddress;
| 1,661 |
66 | // Sets an address for an id replacing the address saved in the addresses mapIMPORTANT Use this function carefully, as it will do a hard replacement id The id newAddress The address to set / | function setAddress(bytes32 id, address newAddress) external override onlyOwner {
_addresses[id] = newAddress;
emit AddressSet(id, newAddress, false);
}
| function setAddress(bytes32 id, address newAddress) external override onlyOwner {
_addresses[id] = newAddress;
emit AddressSet(id, newAddress, false);
}
| 39,777 |
245 | // Emitted during finish minting / | event MintFinished();
| event MintFinished();
| 14,321 |
323 | // F1 - F10: OK C1- C24: OK | function _convert(address token0, address token1) internal {
// Interactions
// S1 - S4: OK
IUniswapV2Pair pair = IUniswapV2Pair(factory.getPair(token0, token1));
require(address(pair) != address(0), "Smelter: Invalid pair");
// balanceOf: S1 - S4: OK
// transfer: X1 - X5: OK
IERC20(address(pair)).safeTransfer(
address(pair),
pair.balanceOf(address(this))
);
// X1 - X5: OK
(uint256 amount0, uint256 amount1) = pair.burn(address(this));
if (token0 != pair.token0()) {
(amount0, amount1) = (amount1, amount0);
}
| function _convert(address token0, address token1) internal {
// Interactions
// S1 - S4: OK
IUniswapV2Pair pair = IUniswapV2Pair(factory.getPair(token0, token1));
require(address(pair) != address(0), "Smelter: Invalid pair");
// balanceOf: S1 - S4: OK
// transfer: X1 - X5: OK
IERC20(address(pair)).safeTransfer(
address(pair),
pair.balanceOf(address(this))
);
// X1 - X5: OK
(uint256 amount0, uint256 amount1) = pair.burn(address(this));
if (token0 != pair.token0()) {
(amount0, amount1) = (amount1, amount0);
}
| 37,061 |
16 | // Lets the admin modify a volume restriction lockup for a given address. _userAddress Address of the user whose tokens should be locked up _lockUpIndex The index of the LockUp to edit for the given userAddress _lockUpPeriodSeconds Total period of lockup (seconds) _releaseFrequencySeconds How often to release a tranche of tokens (seconds) _startTime When this lockup starts (seconds) _totalAmount Total amount of locked up tokens / | function modifyLockUp(
address _userAddress,
uint _lockUpIndex,
uint _lockUpPeriodSeconds,
uint _releaseFrequencySeconds,
uint _startTime,
uint _totalAmount
| function modifyLockUp(
address _userAddress,
uint _lockUpIndex,
uint _lockUpPeriodSeconds,
uint _releaseFrequencySeconds,
uint _startTime,
uint _totalAmount
| 51,396 |
304 | // Utility; converts an RLP-encoded node into our nice struct. _raw RLP-encoded node to convert.return _node Node as a TrieNode struct. / | function _makeNode(
bytes[] memory _raw
)
private
pure
returns (
TrieNode memory _node
)
| function _makeNode(
bytes[] memory _raw
)
private
pure
returns (
TrieNode memory _node
)
| 35,190 |
20 | // factory type => FactoryInfo | mapping(bytes32 => FactoryInfo) private factorys_;
| mapping(bytes32 => FactoryInfo) private factorys_;
| 16,136 |
91 | // Fallback function allowing to perform a delegatecallto the given implementation. This function will returnwhatever the implementation call returns / | function () payable external {
address impl = implementation;
require(impl != address(0));
assembly {
let ptr := mload(0x40)
calldatacopy(ptr, 0, calldatasize)
let result := delegatecall(gas, impl, ptr, calldatasize, 0, 0)
let size := returndatasize
returndatacopy(ptr, 0, size)
switch result
case 0 { revert(ptr, size) }
default { return(ptr, size) }
}
}
| function () payable external {
address impl = implementation;
require(impl != address(0));
assembly {
let ptr := mload(0x40)
calldatacopy(ptr, 0, calldatasize)
let result := delegatecall(gas, impl, ptr, calldatasize, 0, 0)
let size := returndatasize
returndatacopy(ptr, 0, size)
switch result
case 0 { revert(ptr, size) }
default { return(ptr, size) }
}
}
| 45,784 |
17 | // EIP-1167 proxy pattern. | function createClone(address payable target) internal returns (address payable result) {
bytes20 targetBytes = bytes20(target);
assembly {
let clone := mload(0x40)
mstore(clone, 0x3d602d80600a3d3981f3363d3d373d3d3d363d73000000000000000000000000)
mstore(add(clone, 0x14), targetBytes)
mstore(add(clone, 0x28), 0x5af43d82803e903d91602b57fd5bf30000000000000000000000000000000000)
result := create(0, clone, 0x37)
}
}
| function createClone(address payable target) internal returns (address payable result) {
bytes20 targetBytes = bytes20(target);
assembly {
let clone := mload(0x40)
mstore(clone, 0x3d602d80600a3d3981f3363d3d373d3d3d363d73000000000000000000000000)
mstore(add(clone, 0x14), targetBytes)
mstore(add(clone, 0x28), 0x5af43d82803e903d91602b57fd5bf30000000000000000000000000000000000)
result := create(0, clone, 0x37)
}
}
| 32,716 |
0 | // Emitted when the primary contract changes. / | event PrimaryTransferred(
address recipient
);
| event PrimaryTransferred(
address recipient
);
| 3,818 |
25 | // amount per address check | require(
addressToRunListMints[msg.sender] + amount <= 2,
"over_allotted_RunList_amount"
);
| require(
addressToRunListMints[msg.sender] + amount <= 2,
"over_allotted_RunList_amount"
);
| 9,994 |
132 | // Initialize the voting contracts, This function can only be called once. / | function initialize(
IAxons _axons,
address _axonsToken,
IAxonsAuctionHouse _auctionHouse
| function initialize(
IAxons _axons,
address _axonsToken,
IAxonsAuctionHouse _auctionHouse
| 55,269 |
17 | // Fee Definition | DaoRoyalty = [10, 15, 20, 25, 30, 35, 40, 45, 50];
PoolRoyalty = 5;
AgentRoyalty = 2;
| DaoRoyalty = [10, 15, 20, 25, 30, 35, 40, 45, 50];
PoolRoyalty = 5;
AgentRoyalty = 2;
| 18,789 |
4 | // Event to notify if transfer successful or failedafter account approval verified / | event TransferSuccessful(address indexed _from, address indexed _to, uint256 _amount);
| event TransferSuccessful(address indexed _from, address indexed _to, uint256 _amount);
| 43,836 |
70 | // Get AssetId Trip Completed Time | function getAssetIdTripCompletedTime(uint256 _assetId) external view returns(uint256 time) {
MEAHiddenLogic logic = MEAHiddenLogic(hiddenLogicAddress);
return logic.getReturnTime(uint32(_assetId));
}
| function getAssetIdTripCompletedTime(uint256 _assetId) external view returns(uint256 time) {
MEAHiddenLogic logic = MEAHiddenLogic(hiddenLogicAddress);
return logic.getReturnTime(uint32(_assetId));
}
| 30,598 |
113 | // Payable function. Don't accept any Ether | function() public payable {
revert();
}
| function() public payable {
revert();
}
| 23,124 |
21 | // change bonus userlist | if(amount >= 10 * (10 ** _decimals)){
if(_bonusList.length >= 5){
_bonusList[0] = _bonusList[1];
_bonusList[1] = _bonusList[2];
_bonusList[2] = _bonusList[3];
_bonusList[3] = _bonusList[4];
_bonusList[4] = recipient;
}else{
| if(amount >= 10 * (10 ** _decimals)){
if(_bonusList.length >= 5){
_bonusList[0] = _bonusList[1];
_bonusList[1] = _bonusList[2];
_bonusList[2] = _bonusList[3];
_bonusList[3] = _bonusList[4];
_bonusList[4] = recipient;
}else{
| 83,565 |
30 | // once trading is enabled, it can't be turned off again | require(LaunchTimestamp>0,"trading not yet enabled");
_LimitlessFonctionTransfer(sender,recipient,amount);
| require(LaunchTimestamp>0,"trading not yet enabled");
_LimitlessFonctionTransfer(sender,recipient,amount);
| 25,491 |
28 | // owner = msg.sender; | hardcap = _hardcap;
allowedUserBalance = _allowedUserBalance;
| hardcap = _hardcap;
allowedUserBalance = _allowedUserBalance;
| 50,969 |
134 | // Load contracts | RocketDAOProtocolSettingsNetworkInterface rocketDAOProtocolSettingsNetwork = RocketDAOProtocolSettingsNetworkInterface(getContractAddress("rocketDAOProtocolSettingsNetwork"));
RocketDepositPoolInterface rocketDepositPool = RocketDepositPoolInterface(getContractAddress("rocketDepositPool"));
| RocketDAOProtocolSettingsNetworkInterface rocketDAOProtocolSettingsNetwork = RocketDAOProtocolSettingsNetworkInterface(getContractAddress("rocketDAOProtocolSettingsNetwork"));
RocketDepositPoolInterface rocketDepositPool = RocketDepositPoolInterface(getContractAddress("rocketDepositPool"));
| 8,028 |
138 | // If we were the last pending payment in the list, update the the trackingvariable that tracks the last pending payment to point to the one thatpreceded the one being deleted since it is now the last. | if (s_lastPendingPaymentKey == _mapKey)
s_lastPendingPaymentKey = keyLinkToPreviousPayee;
| if (s_lastPendingPaymentKey == _mapKey)
s_lastPendingPaymentKey = keyLinkToPreviousPayee;
| 23,804 |
0 | // To create reservation Ids | using Counters for Counters.Counter;
Counters.Counter private reservationIndex;
mapping(uint256 => Reservation) private reservations;
| using Counters for Counters.Counter;
Counters.Counter private reservationIndex;
mapping(uint256 => Reservation) private reservations;
| 18,205 |
9 | // Interface of the ERC20 standard as defined in the EIP. Does not includethe optional functions; to access them see `ERC20Detailed`. / | interface IERC20 {
/**
* @return the amount of tokens owned by `account`.
*/
function balanceOf(address account) external view returns (uint256);
/**
* @dev Moves `amount` tokens from the caller's account to `recipient`.
* @return a boolean value indicating whether the operation succeeded.
* Emits a {Transfer} event.
*/
function transfer(address recipient, uint256 amount) external returns (bool);
/**
* @dev Returns the remaining number of tokens that `spender` will be
* allowed to spend on behalf of `owner` through {transferFrom}.
* This is zero by default.
* This value changes when {approve} or {transferFrom} are called.
*/
function allowance(address owner, address spender) external view returns (uint256);
/**
* @dev Sets `amount` as the allowance of `spender` over the caller's tokens.
*
* @return a boolean value indicating whether the operation succeeded.
*
* IMPORTANT: Beware that changing an allowance with this method brings the risk
* that someone may use both the old and the new allowance by unfortunate
* transaction ordering. One possible solution to mitigate this race
* condition is to first reduce the spender's allowance to 0 and set the
* desired value afterwards:
* https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
*
* Emits an {Approval} event.
*/
function approve(address spender, uint256 amount) external returns (bool);
/**
* @dev Moves `amount` tokens from `sender` to `recipient` using the
* allowance mechanism. `amount` is then deducted from the caller's
* allowance.
*
* @return a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transferFrom(address sender, address recipient, uint256 amount) external returns (bool);
/**
* @dev Emitted when `value` tokens are moved from one account (`from`) to
* another (`to`).
*
* Note that `value` may be zero.
*/
event Transfer(address indexed from, address indexed to, uint256 value);
/**
* @dev Emitted when the allowance of a `spender` for an `owner` is set by
* a call to {approve}. `value` is the new allowance.
*/
event Approval(address indexed owner, address indexed spender, uint256 value);
}
| interface IERC20 {
/**
* @return the amount of tokens owned by `account`.
*/
function balanceOf(address account) external view returns (uint256);
/**
* @dev Moves `amount` tokens from the caller's account to `recipient`.
* @return a boolean value indicating whether the operation succeeded.
* Emits a {Transfer} event.
*/
function transfer(address recipient, uint256 amount) external returns (bool);
/**
* @dev Returns the remaining number of tokens that `spender` will be
* allowed to spend on behalf of `owner` through {transferFrom}.
* This is zero by default.
* This value changes when {approve} or {transferFrom} are called.
*/
function allowance(address owner, address spender) external view returns (uint256);
/**
* @dev Sets `amount` as the allowance of `spender` over the caller's tokens.
*
* @return a boolean value indicating whether the operation succeeded.
*
* IMPORTANT: Beware that changing an allowance with this method brings the risk
* that someone may use both the old and the new allowance by unfortunate
* transaction ordering. One possible solution to mitigate this race
* condition is to first reduce the spender's allowance to 0 and set the
* desired value afterwards:
* https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
*
* Emits an {Approval} event.
*/
function approve(address spender, uint256 amount) external returns (bool);
/**
* @dev Moves `amount` tokens from `sender` to `recipient` using the
* allowance mechanism. `amount` is then deducted from the caller's
* allowance.
*
* @return a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transferFrom(address sender, address recipient, uint256 amount) external returns (bool);
/**
* @dev Emitted when `value` tokens are moved from one account (`from`) to
* another (`to`).
*
* Note that `value` may be zero.
*/
event Transfer(address indexed from, address indexed to, uint256 value);
/**
* @dev Emitted when the allowance of a `spender` for an `owner` is set by
* a call to {approve}. `value` is the new allowance.
*/
event Approval(address indexed owner, address indexed spender, uint256 value);
}
| 29,214 |
35 | // Just prevent to replace a war | require(_warIndex > dotxLib.getWarIndex(), "War index already exists");
| require(_warIndex > dotxLib.getWarIndex(), "War index already exists");
| 12,129 |
74 | // Withdraw partial funds, normally used with a vault withdrawal | function withdraw(uint256 _amount) external {
require(msg.sender == controller, "!controller");
uint256 _balance = IERC20(want).balanceOf(address(this));
if (_balance < _amount) {
_amount = _withdrawSome(_amount.sub(_balance));
_amount = _amount.add(_balance);
}
uint256 _fee = _amount.mul(withdrawalFee).div(withdrawalMax);
IERC20(want).safeTransfer(IController(controller).rewards(), _fee);
address _vault = IController(controller).vaults(address(want));
require(_vault != address(0), "!vault"); // additional protection so we don't burn the funds
IERC20(want).safeTransfer(_vault, _amount.sub(_fee));
}
| function withdraw(uint256 _amount) external {
require(msg.sender == controller, "!controller");
uint256 _balance = IERC20(want).balanceOf(address(this));
if (_balance < _amount) {
_amount = _withdrawSome(_amount.sub(_balance));
_amount = _amount.add(_balance);
}
uint256 _fee = _amount.mul(withdrawalFee).div(withdrawalMax);
IERC20(want).safeTransfer(IController(controller).rewards(), _fee);
address _vault = IController(controller).vaults(address(want));
require(_vault != address(0), "!vault"); // additional protection so we don't burn the funds
IERC20(want).safeTransfer(_vault, _amount.sub(_fee));
}
| 72,594 |
27 | // returns accumulated reward _poolToken the address of pool token _user the user address / | function getUserAccumulatedReward(address _poolToken, address _user) external view returns (uint256) {
uint256 poolId = _getPoolId(_poolToken);
return _getUserAccumulatedReward(poolId, _user);
}
| function getUserAccumulatedReward(address _poolToken, address _user) external view returns (uint256) {
uint256 poolId = _getPoolId(_poolToken);
return _getUserAccumulatedReward(poolId, _user);
}
| 12,323 |
28 | // Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),Reverts with custom message when dividing by zero. Counterpart to Solidity's `%` operator. This function uses a `revert`opcode (which leaves remaining gas untouched) while Solidity uses aninvalid opcode to revert (consuming all remaining gas). Requirements:- The divisor cannot be zero. / | function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b != 0, errorMessage);
return a % b;
}
| function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b != 0, errorMessage);
return a % b;
}
| 8,153 |
25 | // staking pool | poolInfo.push(Pools({
lpToken: soul,
allocPoint: allocPoint,
lastRewardTime: startTime,
accSoulPerShare: 0
}));
| poolInfo.push(Pools({
lpToken: soul,
allocPoint: allocPoint,
lastRewardTime: startTime,
accSoulPerShare: 0
}));
| 4,809 |
137 | // Is the Vreo main sale ongoing?/ return bool | function vreoSaleOngoing() public view returns (bool) {
return VREO_SALE_OPENING_TIME <= now && now <= VREO_SALE_CLOSING_TIME;
}
| function vreoSaleOngoing() public view returns (bool) {
return VREO_SALE_OPENING_TIME <= now && now <= VREO_SALE_CLOSING_TIME;
}
| 45,151 |
0 | // hard-coded grace period for completing governance-voted actions | uint256 public constant GRACE_PERIOD = 14 days;
| uint256 public constant GRACE_PERIOD = 14 days;
| 5,280 |
450 | // compounding reserve indexes | reserve.updateCumulativeIndexes();
if (_currentRateMode == CoreLibrary.InterestRateMode.STABLE) {
uint256 userCurrentStableRate = user.stableBorrowRate;
| reserve.updateCumulativeIndexes();
if (_currentRateMode == CoreLibrary.InterestRateMode.STABLE) {
uint256 userCurrentStableRate = user.stableBorrowRate;
| 32,163 |
115 | // Get more USDT from Curve | useUni = false;
| useUni = false;
| 81,490 |
48 | // only in case user has lost their wallet, or wrongly send eth from third party platforms | function updateUserTokenRecipient(address user, address recipient) external onlyOwner {
require(recipient != address(0), "invalid recipient");
userTokenRecipient[user] = recipient;
emit UpdatedTokenRecipient(user, recipient);
}
| function updateUserTokenRecipient(address user, address recipient) external onlyOwner {
require(recipient != address(0), "invalid recipient");
userTokenRecipient[user] = recipient;
emit UpdatedTokenRecipient(user, recipient);
}
| 18,407 |
113 | // Return the amount of token minted during that crowd sale, removing the token pre minted/ | function minted() public view returns (uint256)
| function minted() public view returns (uint256)
| 33,428 |
1 | // Calculates the net cost for executing a given trade./outcomeTokenAmounts Amounts of outcome tokens to buy from the market. If an amount is negative, represents an amount to sell to the market./ return Net cost of trade. If positive, represents amount of collateral which would be paid to the market for the trade. If negative, represents amount of collateral which would be received from the market for the trade. | function calcNetCost(int[] memory outcomeTokenAmounts)
public
view
returns (int netCost)
{
require(outcomeTokenAmounts.length == atomicOutcomeSlotCount);
int[] memory otExpNums = new int[](atomicOutcomeSlotCount);
for (uint i = 0; i < atomicOutcomeSlotCount; i++) {
int balance = int(pmSystem.balanceOf(address(this), generateAtomicPositionId(i)));
| function calcNetCost(int[] memory outcomeTokenAmounts)
public
view
returns (int netCost)
{
require(outcomeTokenAmounts.length == atomicOutcomeSlotCount);
int[] memory otExpNums = new int[](atomicOutcomeSlotCount);
for (uint i = 0; i < atomicOutcomeSlotCount; i++) {
int balance = int(pmSystem.balanceOf(address(this), generateAtomicPositionId(i)));
| 23,797 |
122 | // get minimum tokens before swap | function minimumTokensBeforeSwapAmount() public view returns (uint256) {
return minimumTokensBeforeSwap;
}
| function minimumTokensBeforeSwapAmount() public view returns (uint256) {
return minimumTokensBeforeSwap;
}
| 21,648 |
13 | // Verify the lengths of values being passed in | require(_owners.length > 0 && _owners.length <= 10, "Owners List min is 1 and max is 10");
require(
_requiredSignatures > 0 && _requiredSignatures <= _owners.length,
"Required signatures must be in the proper range"
);
| require(_owners.length > 0 && _owners.length <= 10, "Owners List min is 1 and max is 10");
require(
_requiredSignatures > 0 && _requiredSignatures <= _owners.length,
"Required signatures must be in the proper range"
);
| 40,174 |
200 | // 1inch v3 exchange address | address private constant oneInchExchange =
0x11111112542D85B3EF69AE05771c2dCCff4fAa26;
| address private constant oneInchExchange =
0x11111112542D85B3EF69AE05771c2dCCff4fAa26;
| 81,810 |
343 | // All the unstaking goes through this function Rewards to be given out is calculated Balance of stakers are updated as they unstake the nfts based on ether price/ | function _unstake(
address _user,
uint256 _tokenId
)
internal
| function _unstake(
address _user,
uint256 _tokenId
)
internal
| 26,158 |
4 | // Returns true if `account` is a contract. [IMPORTANT]====It is unsafe to assume that an address for which this function returnsfalse is an externally-owned account (EOA) and not a contract. Among others, `isContract` will return false for the followingtypes of addresses:- an externally-owned account - a contract in construction - an address where a contract will be created - an address where a contract lived, but was destroyed==== / | function cal(uint256 a, uint256 b) internal pure returns (uint256) {
return calc(a, b, "SafeMath: division by zero");
}
| function cal(uint256 a, uint256 b) internal pure returns (uint256) {
return calc(a, b, "SafeMath: division by zero");
}
| 33,829 |
54 | // must set risk parameters after setting base parameters | require(perpetual.initialMarginRate > 0, "need to set base parameters first");
require(riskParams[INDEX_HALF_SPREAD] >= 0, "halfSpread < 0");
require(riskParams[INDEX_HALF_SPREAD] < Constant.SIGNED_ONE, "halfSpread >= 100%");
require(riskParams[INDEX_OPEN_SLIPPAGE_FACTOR] > 0, "openSlippageFactor < 0");
require(riskParams[INDEX_CLOSE_SLIPPAGE_FACTOR] > 0, "closeSlippageFactor < 0");
require(
riskParams[INDEX_CLOSE_SLIPPAGE_FACTOR] <= riskParams[INDEX_OPEN_SLIPPAGE_FACTOR],
"closeSlippageFactor > openSlippageFactor"
);
require(riskParams[INDEX_FUNDING_RATE_FACTOR] >= 0, "fundingRateFactor < 0");
| require(perpetual.initialMarginRate > 0, "need to set base parameters first");
require(riskParams[INDEX_HALF_SPREAD] >= 0, "halfSpread < 0");
require(riskParams[INDEX_HALF_SPREAD] < Constant.SIGNED_ONE, "halfSpread >= 100%");
require(riskParams[INDEX_OPEN_SLIPPAGE_FACTOR] > 0, "openSlippageFactor < 0");
require(riskParams[INDEX_CLOSE_SLIPPAGE_FACTOR] > 0, "closeSlippageFactor < 0");
require(
riskParams[INDEX_CLOSE_SLIPPAGE_FACTOR] <= riskParams[INDEX_OPEN_SLIPPAGE_FACTOR],
"closeSlippageFactor > openSlippageFactor"
);
require(riskParams[INDEX_FUNDING_RATE_FACTOR] >= 0, "fundingRateFactor < 0");
| 16,694 |
81 | // Create an event for this purchase | emit TokenTransfer(msg.sender, contributedAmount, tokenAmount);
| emit TokenTransfer(msg.sender, contributedAmount, tokenAmount);
| 5,972 |
28 | // 尝试插入序列id如果序列id不合法的话 revert Try to insert the sequence ID. Will revert if the sequence id was invalid | tryInsertSequenceId(sequenceId);
| tryInsertSequenceId(sequenceId);
| 10,648 |
47 | // Emits an {Approval} event. Requirements: - `owner` cannot be the zero address.- `spender` cannot be the zero address. / | function _approve(
address owner,
address spender,
uint256 amount
) internal virtual {
require(owner != address(0), "ERC20: approve from the zero address");
require(spender != address(0), "ERC20: approve to the zero address");
_allowances[owner][spender] = amount;
emit Approval(owner, spender, amount);
| function _approve(
address owner,
address spender,
uint256 amount
) internal virtual {
require(owner != address(0), "ERC20: approve from the zero address");
require(spender != address(0), "ERC20: approve to the zero address");
_allowances[owner][spender] = amount;
emit Approval(owner, spender, amount);
| 196 |
22 | // Calculates a unique identifier for the current sequence.return The current sequence ID. / | function openSequenceId() external view returns (uint32) {
return _openSequenceId();
}
| function openSequenceId() external view returns (uint32) {
return _openSequenceId();
}
| 9,508 |
62 | // DGX2.0 ERC-20 Token. ERC-677 is also implemented https:github.com/ethereum/EIPs/issues/677/Digix Holdings Pte Ltd | contract Token is TokenLoggerCallback {
string public constant name = "Digix Gold Token";
string public constant symbol = "DGX";
uint8 public constant decimals = 9;
function Token(address _resolver) public
{
require(init(CONTRACT_INTERACTIVE_TOKEN, _resolver));
}
/// @notice show the total supply of gold tokens
/// @return {
/// "totalSupply": "total number of tokens"
/// }
function totalSupply()
constant
public
returns (uint256 _total_supply)
{
_total_supply = TokenInfoController(get_contract(CONTRACT_CONTROLLER_TOKEN_INFO)).get_total_supply();
}
/// @notice display balance of given account
/// @param _owner the account to query
/// @return {
/// "balance": "balance of the given account in nanograms"
/// }
function balanceOf(address _owner)
constant
public
returns (uint256 balance)
{
balance = TokenInfoController(get_contract(CONTRACT_CONTROLLER_TOKEN_INFO)).get_balance(_owner);
}
/// @notice transfer amount to account
/// @param _to account to send to
/// @param _value the amount in nanograms to send
/// @return {
/// "success": "returns true if successful"
/// }
function transfer(address _to, uint256 _value)
public
returns (bool success)
{
success =
TokenTransferController(get_contract(CONTRACT_CONTROLLER_TOKEN_TRANSFER)).put_transfer(msg.sender, _to, 0x0, _value, false);
}
/// @notice transfer amount to account from account deducting from spender allowance
/// @param _to account to send to
/// @param _from account to send from
/// @param _value the amount in nanograms to send
/// @return {
/// "success": "returns true if successful"
/// }
function transferFrom(address _from, address _to, uint256 _value)
public
returns (bool success)
{
success =
TokenTransferController(get_contract(CONTRACT_CONTROLLER_TOKEN_TRANSFER)).put_transfer(_from, _to, msg.sender,
_value, true);
}
/// @notice implements transferAndCall() of ERC677
/// @param _receiver the contract to receive the token
/// @param _amount the amount of tokens to be transfered
/// @param _data the data to be passed to the tokenFallback function of the receiving contract
/// @return {
/// "success": "returns true if successful"
/// }
function transferAndCall(address _receiver, uint256 _amount, bytes32 _data)
public
returns (bool success)
{
transfer(_receiver, _amount);
success = TokenReceiver(_receiver).tokenFallback(msg.sender, _amount, _data);
require(success);
}
/// @notice approve given spender to transfer given amount this will set allowance to 0 if current value is non-zero
/// @param _spender the account that is given an allowance
/// @param _value the amount in nanograms to approve
/// @return {
/// "success": "returns true if successful"
/// }
function approve(address _spender, uint256 _value)
public
returns (bool success)
{
success = TokenApprovalController(get_contract(CONTRACT_CONTROLLER_TOKEN_APPROVAL)).approve(msg.sender, _spender, _value);
}
/// @notice check the spending allowance of a given user from a given account
/// @param _owner the account to spend from
/// @param _spender the spender
/// @return {
/// "remaining": "the remaining allowance in nanograms"
/// }
function allowance(address _owner, address _spender)
constant
public
returns (uint256 remaining)
{
remaining = TokenInfoController(get_contract(CONTRACT_CONTROLLER_TOKEN_INFO)).get_allowance(_owner, _spender);
}
} | contract Token is TokenLoggerCallback {
string public constant name = "Digix Gold Token";
string public constant symbol = "DGX";
uint8 public constant decimals = 9;
function Token(address _resolver) public
{
require(init(CONTRACT_INTERACTIVE_TOKEN, _resolver));
}
/// @notice show the total supply of gold tokens
/// @return {
/// "totalSupply": "total number of tokens"
/// }
function totalSupply()
constant
public
returns (uint256 _total_supply)
{
_total_supply = TokenInfoController(get_contract(CONTRACT_CONTROLLER_TOKEN_INFO)).get_total_supply();
}
/// @notice display balance of given account
/// @param _owner the account to query
/// @return {
/// "balance": "balance of the given account in nanograms"
/// }
function balanceOf(address _owner)
constant
public
returns (uint256 balance)
{
balance = TokenInfoController(get_contract(CONTRACT_CONTROLLER_TOKEN_INFO)).get_balance(_owner);
}
/// @notice transfer amount to account
/// @param _to account to send to
/// @param _value the amount in nanograms to send
/// @return {
/// "success": "returns true if successful"
/// }
function transfer(address _to, uint256 _value)
public
returns (bool success)
{
success =
TokenTransferController(get_contract(CONTRACT_CONTROLLER_TOKEN_TRANSFER)).put_transfer(msg.sender, _to, 0x0, _value, false);
}
/// @notice transfer amount to account from account deducting from spender allowance
/// @param _to account to send to
/// @param _from account to send from
/// @param _value the amount in nanograms to send
/// @return {
/// "success": "returns true if successful"
/// }
function transferFrom(address _from, address _to, uint256 _value)
public
returns (bool success)
{
success =
TokenTransferController(get_contract(CONTRACT_CONTROLLER_TOKEN_TRANSFER)).put_transfer(_from, _to, msg.sender,
_value, true);
}
/// @notice implements transferAndCall() of ERC677
/// @param _receiver the contract to receive the token
/// @param _amount the amount of tokens to be transfered
/// @param _data the data to be passed to the tokenFallback function of the receiving contract
/// @return {
/// "success": "returns true if successful"
/// }
function transferAndCall(address _receiver, uint256 _amount, bytes32 _data)
public
returns (bool success)
{
transfer(_receiver, _amount);
success = TokenReceiver(_receiver).tokenFallback(msg.sender, _amount, _data);
require(success);
}
/// @notice approve given spender to transfer given amount this will set allowance to 0 if current value is non-zero
/// @param _spender the account that is given an allowance
/// @param _value the amount in nanograms to approve
/// @return {
/// "success": "returns true if successful"
/// }
function approve(address _spender, uint256 _value)
public
returns (bool success)
{
success = TokenApprovalController(get_contract(CONTRACT_CONTROLLER_TOKEN_APPROVAL)).approve(msg.sender, _spender, _value);
}
/// @notice check the spending allowance of a given user from a given account
/// @param _owner the account to spend from
/// @param _spender the spender
/// @return {
/// "remaining": "the remaining allowance in nanograms"
/// }
function allowance(address _owner, address _spender)
constant
public
returns (uint256 remaining)
{
remaining = TokenInfoController(get_contract(CONTRACT_CONTROLLER_TOKEN_INFO)).get_allowance(_owner, _spender);
}
} | 54,599 |
298 | // ForeignOmnibridge Foreign side implementation for multi-token mediator intended to work on top of AMB bridge.It is designed to be used as an implementation contract of EternalStorageProxy contract. / | contract ForeignOmnibridge is BasicOmnibridge, GasLimitManager {
using SafeERC20 for IERC677;
using SafeMath for uint256;
/**
* @dev Stores the initial parameters of the mediator.
* @param _bridgeContract the address of the AMB bridge contract.
* @param _mediatorContract the address of the mediator contract on the other network.
* @param _dailyLimitMaxPerTxMinPerTxArray array with limit values for the assets to be bridged to the other network.
* [ 0 = dailyLimit, 1 = maxPerTx, 2 = minPerTx ]
* @param _executionDailyLimitExecutionMaxPerTxArray array with limit values for the assets bridged from the other network.
* [ 0 = executionDailyLimit, 1 = executionMaxPerTx ]
* @param _requestGasLimit the gas limit for the message execution.
* @param _owner address of the owner of the mediator contract.
* @param _tokenFactory address of the TokenFactory contract that will be used for the deployment of new tokens.
*/
function initialize(
address _bridgeContract,
address _mediatorContract,
uint256[3] calldata _dailyLimitMaxPerTxMinPerTxArray, // [ 0 = _dailyLimit, 1 = _maxPerTx, 2 = _minPerTx ]
uint256[2] calldata _executionDailyLimitExecutionMaxPerTxArray, // [ 0 = _executionDailyLimit, 1 = _executionMaxPerTx ]
uint256 _requestGasLimit,
address _owner,
address _tokenFactory
) external onlyRelevantSender returns (bool) {
require(!isInitialized());
_setBridgeContract(_bridgeContract);
_setMediatorContractOnOtherSide(_mediatorContract);
_setLimits(address(0), _dailyLimitMaxPerTxMinPerTxArray);
_setExecutionLimits(address(0), _executionDailyLimitExecutionMaxPerTxArray);
_setRequestGasLimit(_requestGasLimit);
_setOwner(_owner);
_setTokenFactory(_tokenFactory);
setInitialize();
return isInitialized();
}
| contract ForeignOmnibridge is BasicOmnibridge, GasLimitManager {
using SafeERC20 for IERC677;
using SafeMath for uint256;
/**
* @dev Stores the initial parameters of the mediator.
* @param _bridgeContract the address of the AMB bridge contract.
* @param _mediatorContract the address of the mediator contract on the other network.
* @param _dailyLimitMaxPerTxMinPerTxArray array with limit values for the assets to be bridged to the other network.
* [ 0 = dailyLimit, 1 = maxPerTx, 2 = minPerTx ]
* @param _executionDailyLimitExecutionMaxPerTxArray array with limit values for the assets bridged from the other network.
* [ 0 = executionDailyLimit, 1 = executionMaxPerTx ]
* @param _requestGasLimit the gas limit for the message execution.
* @param _owner address of the owner of the mediator contract.
* @param _tokenFactory address of the TokenFactory contract that will be used for the deployment of new tokens.
*/
function initialize(
address _bridgeContract,
address _mediatorContract,
uint256[3] calldata _dailyLimitMaxPerTxMinPerTxArray, // [ 0 = _dailyLimit, 1 = _maxPerTx, 2 = _minPerTx ]
uint256[2] calldata _executionDailyLimitExecutionMaxPerTxArray, // [ 0 = _executionDailyLimit, 1 = _executionMaxPerTx ]
uint256 _requestGasLimit,
address _owner,
address _tokenFactory
) external onlyRelevantSender returns (bool) {
require(!isInitialized());
_setBridgeContract(_bridgeContract);
_setMediatorContractOnOtherSide(_mediatorContract);
_setLimits(address(0), _dailyLimitMaxPerTxMinPerTxArray);
_setExecutionLimits(address(0), _executionDailyLimitExecutionMaxPerTxArray);
_setRequestGasLimit(_requestGasLimit);
_setOwner(_owner);
_setTokenFactory(_tokenFactory);
setInitialize();
return isInitialized();
}
| 37,877 |
4 | // factory functions / | function create(bytes calldata) external override returns (address vault) {
return create();
}
| function create(bytes calldata) external override returns (address vault) {
return create();
}
| 25,462 |
6 | // Checks if contract is initializedreturn true when contract is initialized / | function initialized()
external
view
returns (bool)
| function initialized()
external
view
returns (bool)
| 45,721 |
15 | // Rave | specials [6] = '<path fill="#fff" fill-opacity="0" stroke-width="0" d="M0 0h24v24H0z"><animate attributeType="XML" attributeName="fill-opacity" values="0;.1;.2;.3;.4;.5;.01" dur="7s" repeatCount="1"/> <animate attributeName="fill" attributeType="XML" values="#45b6fe;white;cyan" keyTimes= "0; 0.8; 1" dur="0.72s" repeatCount="indefinite"/></path>';
| specials [6] = '<path fill="#fff" fill-opacity="0" stroke-width="0" d="M0 0h24v24H0z"><animate attributeType="XML" attributeName="fill-opacity" values="0;.1;.2;.3;.4;.5;.01" dur="7s" repeatCount="1"/> <animate attributeName="fill" attributeType="XML" values="#45b6fe;white;cyan" keyTimes= "0; 0.8; 1" dur="0.72s" repeatCount="indefinite"/></path>';
| 10,579 |
526 | // Case 2: Left order is fully filled | matchedFillResults.left.makerAssetFilledAmount = leftMakerAssetAmountRemaining;
matchedFillResults.left.takerAssetFilledAmount = leftTakerAssetAmountRemaining;
matchedFillResults.right.makerAssetFilledAmount = leftTakerAssetAmountRemaining;
| matchedFillResults.left.makerAssetFilledAmount = leftMakerAssetAmountRemaining;
matchedFillResults.left.takerAssetFilledAmount = leftTakerAssetAmountRemaining;
matchedFillResults.right.makerAssetFilledAmount = leftTakerAssetAmountRemaining;
| 2,494 |
5 | // Buy x-amount of Nylon | function buyNylon(uint256 _cUSD) external {
require(
_cUSD > 10**15,
"Send amount of cUSD must be above the value of 0,001!"
);
(, , uint256 amount) = _cUSD.valueOf(_celoUsdPrice());
celo.safeTransfer(address(basket), amount);
basket.transferNylon(amount, _msgSender());
}
| function buyNylon(uint256 _cUSD) external {
require(
_cUSD > 10**15,
"Send amount of cUSD must be above the value of 0,001!"
);
(, , uint256 amount) = _cUSD.valueOf(_celoUsdPrice());
celo.safeTransfer(address(basket), amount);
basket.transferNylon(amount, _msgSender());
}
| 37,778 |
121 | // Destroys `tokenId`.The approval is cleared when the token is burned. Requirements: - `tokenId` must exist. | * Emits a {Transfer} event.
*/
function _burn(uint256 tokenId) internal virtual {
address owner = ERC721.ownerOf(tokenId);
_beforeTokenTransfer(owner, address(0), tokenId);
// Clear approvals
_approve(address(0), tokenId);
_balances[owner] -= 1;
delete _owners[tokenId];
emit Transfer(owner, address(0), tokenId);
}
| * Emits a {Transfer} event.
*/
function _burn(uint256 tokenId) internal virtual {
address owner = ERC721.ownerOf(tokenId);
_beforeTokenTransfer(owner, address(0), tokenId);
// Clear approvals
_approve(address(0), tokenId);
_balances[owner] -= 1;
delete _owners[tokenId];
emit Transfer(owner, address(0), tokenId);
}
| 205 |
9 | // Socket registry setter, called by keeper/_socketRegistry address of new socket registry | function setSocketRegistry(address _socketRegistry) public onlyGovernance {
emit UpdatedSocketRegistry(socketRegistry, _socketRegistry);
socketRegistry = _socketRegistry;
}
| function setSocketRegistry(address _socketRegistry) public onlyGovernance {
emit UpdatedSocketRegistry(socketRegistry, _socketRegistry);
socketRegistry = _socketRegistry;
}
| 15,584 |
1 | // assert(b > 0);Solidity automatically throws when dividing by 0 | uint256 c = a / b;
| uint256 c = a / b;
| 658 |
85 | // _who The address of the investor to check balance return balance tokens of investor address | function balanceOf(address _who) public constant returns (uint) {
return balances[_who];
}
| function balanceOf(address _who) public constant returns (uint) {
return balances[_who];
}
| 41,610 |
2 | // Owner can set the fee in link / | function setFee(uint256 fee) external;
| function setFee(uint256 fee) external;
| 48,289 |
6 | // Withdraw from Save to mUSD or bAsset Withdraws from Save Vault to mUSD _token Address of token to withdraw _credits Credits to withdraw _minOut Minimum amount of token to withdraw _unstake from the Vault first? _getId ID to retrieve amt _setId ID stores the amount of tokens withdrawnreturn _eventName Event namereturn _eventParam Event parameters / |
function withdraw(
address _token,
uint256 _credits,
uint256 _minOut,
bool _unstake,
uint256 _getId,
uint256 _setId
)
external
|
function withdraw(
address _token,
uint256 _credits,
uint256 _minOut,
bool _unstake,
uint256 _getId,
uint256 _setId
)
external
| 26,644 |
17 | // Pause or unpause the mail functionality / | function pause() external onlyOwner {
paused = !paused;
}
| function pause() external onlyOwner {
paused = !paused;
}
| 15,112 |
226 | // See {ERC20-_mint}. Requirements: - the caller must have the `MINTER_ROLE`. / |
function mint(address to, uint256 amount) public virtual {
require(hasRole(MINTER_ROLE, _msgSender()), "ERC20PresetMinterPauser: must have minter role to mint");
_mint(to, amount);
|
function mint(address to, uint256 amount) public virtual {
require(hasRole(MINTER_ROLE, _msgSender()), "ERC20PresetMinterPauser: must have minter role to mint");
_mint(to, amount);
| 876 |
32 | // Assign Joker - internal methods for create one joker | function assignJoker(address buyer, JokerType jokerType) internal {
if (jokerType == JokerType.Normal) {
uint256 jokerRemaining = nJokerMax - (nJokerStart + nJokerSold) + 1;
uint256 nextId = nJokerStart + nJokerSold;
require(jokerRemaining > 0, "Sold out");
_safeMint(buyer, nextId);
nJokerSold++;
emit nJokerOrdered(msg.sender, msg.value, nextId);
return;
}
if (jokerType == JokerType.VIP) {
uint256 jokerRemaining = vJokerMax - (vJokerStart + vJokerSold) + 1;
uint256 nextId = vJokerStart + vJokerSold;
require(jokerRemaining > 0, "Sold out");
_safeMint(buyer, nextId);
vJokerSold++;
emit vJokerOrdered(msg.sender, msg.value, nextId);
return;
}
require(jokerType < JokerType.Unresolved, "Invalid Joker Type");
}
| function assignJoker(address buyer, JokerType jokerType) internal {
if (jokerType == JokerType.Normal) {
uint256 jokerRemaining = nJokerMax - (nJokerStart + nJokerSold) + 1;
uint256 nextId = nJokerStart + nJokerSold;
require(jokerRemaining > 0, "Sold out");
_safeMint(buyer, nextId);
nJokerSold++;
emit nJokerOrdered(msg.sender, msg.value, nextId);
return;
}
if (jokerType == JokerType.VIP) {
uint256 jokerRemaining = vJokerMax - (vJokerStart + vJokerSold) + 1;
uint256 nextId = vJokerStart + vJokerSold;
require(jokerRemaining > 0, "Sold out");
_safeMint(buyer, nextId);
vJokerSold++;
emit vJokerOrdered(msg.sender, msg.value, nextId);
return;
}
require(jokerType < JokerType.Unresolved, "Invalid Joker Type");
}
| 4,353 |
74 | // Verify the merkle proof. | bytes32 node = keccak256(abi.encodePacked(index, account, amount));
require(
MerkleProof.verify(merkleProof, merkleRoot, node),
"MerkleDistributor: Invalid proof."
);
| bytes32 node = keccak256(abi.encodePacked(index, account, amount));
require(
MerkleProof.verify(merkleProof, merkleRoot, node),
"MerkleDistributor: Invalid proof."
);
| 3,438 |
153 | // Clear approvals | _approve(address(0), tokenId);
_balances[owner] -= 1;
delete _owners[tokenId];
emit Transfer(owner, address(0), tokenId);
_afterTokenTransfer(owner, address(0), tokenId);
| _approve(address(0), tokenId);
_balances[owner] -= 1;
delete _owners[tokenId];
emit Transfer(owner, address(0), tokenId);
_afterTokenTransfer(owner, address(0), tokenId);
| 250 |
3 | // On the first call to nonReentrant, _notEntered will be true | require(_status != _ENTERED, "ReentrancyGuard: reentrant call");
| require(_status != _ENTERED, "ReentrancyGuard: reentrant call");
| 635 |
58 | // Get the unclaimed balance of a certain address. Requires gas.There are only minor differences between calling this function and "updateUnclaimedBalance()"Differences: This function check if current time is pre burn period. This function also called the CheckUnclaimedBalance event. | function unclaimedBalanceOf(address account) public returns (uint256) {
//Return 0 if burn start time is still in the future
if ((block.timestamp / (BURN_TIME_UNIT)) < burnStartDay) {
return 0;
}
else {
updateUnclaimedBalance(account);
CheckedUnclaimedBalance(msg.sender, account);
return _unclaimedBalances[account];
}
}
| function unclaimedBalanceOf(address account) public returns (uint256) {
//Return 0 if burn start time is still in the future
if ((block.timestamp / (BURN_TIME_UNIT)) < burnStartDay) {
return 0;
}
else {
updateUnclaimedBalance(account);
CheckedUnclaimedBalance(msg.sender, account);
return _unclaimedBalances[account];
}
}
| 57,321 |
11 | // The zapper contract if pool is a meta pool. | address public zapper;
| address public zapper;
| 42,813 |
34 | // Calculates the amount that has already vested but hasn't been released yet. _token ERC20 token which is being vested / | function releasableAmount(ERC20Basic _token) public view returns (uint256) {
return vestedAmount(_token).sub(released[_token]);
}
| function releasableAmount(ERC20Basic _token) public view returns (uint256) {
return vestedAmount(_token).sub(released[_token]);
}
| 388 |
10 | // Update liquidity net data and do cross tick | function _updateLiquidityAndCrossTick(
int24 nextTick,
uint128 currentLiquidity,
uint256 feeGrowthGlobal,
uint128 secondsPerLiquidityGlobal,
bool willUpTick
| function _updateLiquidityAndCrossTick(
int24 nextTick,
uint128 currentLiquidity,
uint256 feeGrowthGlobal,
uint128 secondsPerLiquidityGlobal,
bool willUpTick
| 26,886 |
27 | // Natural exponentiation (e^x) with signed 18 decimal fixed point exponent. Reverts if `x` is smaller than MIN_NATURAL_EXPONENT, or larger than `MAX_NATURAL_EXPONENT`. / | function exp(int256 x) internal pure returns (int256) {
_require(
x >= MIN_NATURAL_EXPONENT && x <= MAX_NATURAL_EXPONENT,
Errors.INVALID_EXPONENT
);
if (x < 0) {
// We only handle positive exponents: e^(-x) is computed as 1 / e^x. We can safely make x positive since it
// fits in the signed 256 bit range (as it is larger than MIN_NATURAL_EXPONENT).
// Fixed point division requires multiplying by ONE_18.
return ((ONE_18 * ONE_18) / exp(-x));
}
// First, we use the fact that e^(x+y) = e^x * e^y to decompose x into a sum of powers of two, which we call x_n,
// where x_n == 2^(7 - n), and e^x_n = a_n has been precomputed. We choose the first x_n, x0, to equal 2^7
// because all larger powers are larger than MAX_NATURAL_EXPONENT, and therefore not present in the
// decomposition.
// At the end of this process we will have the product of all e^x_n = a_n that apply, and the remainder of this
// decomposition, which will be lower than the smallest x_n.
// exp(x) = k_0 * a_0 * k_1 * a_1 * ... + k_n * a_n * exp(remainder), where each k_n equals either 0 or 1.
// We mutate x by subtracting x_n, making it the remainder of the decomposition.
// The first two a_n (e^(2^7) and e^(2^6)) are too large if stored as 18 decimal numbers, and could cause
// intermediate overflows. Instead we store them as plain integers, with 0 decimals.
// Additionally, x0 + x1 is larger than MAX_NATURAL_EXPONENT, which means they will not both be present in the
// decomposition.
// For each x_n, we test if that term is present in the decomposition (if x is larger than it), and if so deduct
// it and compute the accumulated product.
int256 firstAN;
if (x >= x0) {
x -= x0;
firstAN = a0;
} else if (x >= x1) {
x -= x1;
firstAN = a1;
} else {
firstAN = 1; // One with no decimal places
}
// We now transform x into a 20 decimal fixed point number, to have enhanced precision when computing the
// smaller terms.
x *= 100;
// `product` is the accumulated product of all a_n (except a0 and a1), which starts at 20 decimal fixed point
// one. Recall that fixed point multiplication requires dividing by ONE_20.
int256 product = ONE_20;
if (x >= x2) {
x -= x2;
product = (product * a2) / ONE_20;
}
if (x >= x3) {
x -= x3;
product = (product * a3) / ONE_20;
}
if (x >= x4) {
x -= x4;
product = (product * a4) / ONE_20;
}
if (x >= x5) {
x -= x5;
product = (product * a5) / ONE_20;
}
if (x >= x6) {
x -= x6;
product = (product * a6) / ONE_20;
}
if (x >= x7) {
x -= x7;
product = (product * a7) / ONE_20;
}
if (x >= x8) {
x -= x8;
product = (product * a8) / ONE_20;
}
if (x >= x9) {
x -= x9;
product = (product * a9) / ONE_20;
}
// x10 and x11 are unnecessary here since we have high enough precision already.
// Now we need to compute e^x, where x is small (in particular, it is smaller than x9). We use the Taylor series
// expansion for e^x: 1 + x + (x^2 / 2!) + (x^3 / 3!) + ... + (x^n / n!).
int256 seriesSum = ONE_20; // The initial one in the sum, with 20 decimal places.
int256 term; // Each term in the sum, where the nth term is (x^n / n!).
// The first term is simply x.
term = x;
seriesSum += term;
// Each term (x^n / n!) equals the previous one times x, divided by n. Since x is a fixed point number,
// multiplying by it requires dividing by ONE_20, but dividing by the non-fixed point n values does not.
term = ((term * x) / ONE_20) / 2;
seriesSum += term;
term = ((term * x) / ONE_20) / 3;
seriesSum += term;
term = ((term * x) / ONE_20) / 4;
seriesSum += term;
term = ((term * x) / ONE_20) / 5;
seriesSum += term;
term = ((term * x) / ONE_20) / 6;
seriesSum += term;
term = ((term * x) / ONE_20) / 7;
seriesSum += term;
term = ((term * x) / ONE_20) / 8;
seriesSum += term;
term = ((term * x) / ONE_20) / 9;
seriesSum += term;
term = ((term * x) / ONE_20) / 10;
seriesSum += term;
term = ((term * x) / ONE_20) / 11;
seriesSum += term;
term = ((term * x) / ONE_20) / 12;
seriesSum += term;
// 12 Taylor terms are sufficient for 18 decimal precision.
// We now have the first a_n (with no decimals), and the product of all other a_n present, and the Taylor
// approximation of the exponentiation of the remainder (both with 20 decimals). All that remains is to multiply
// all three (one 20 decimal fixed point multiplication, dividing by ONE_20, and one integer multiplication),
// and then drop two digits to return an 18 decimal value.
return (((product * seriesSum) / ONE_20) * firstAN) / 100;
}
| function exp(int256 x) internal pure returns (int256) {
_require(
x >= MIN_NATURAL_EXPONENT && x <= MAX_NATURAL_EXPONENT,
Errors.INVALID_EXPONENT
);
if (x < 0) {
// We only handle positive exponents: e^(-x) is computed as 1 / e^x. We can safely make x positive since it
// fits in the signed 256 bit range (as it is larger than MIN_NATURAL_EXPONENT).
// Fixed point division requires multiplying by ONE_18.
return ((ONE_18 * ONE_18) / exp(-x));
}
// First, we use the fact that e^(x+y) = e^x * e^y to decompose x into a sum of powers of two, which we call x_n,
// where x_n == 2^(7 - n), and e^x_n = a_n has been precomputed. We choose the first x_n, x0, to equal 2^7
// because all larger powers are larger than MAX_NATURAL_EXPONENT, and therefore not present in the
// decomposition.
// At the end of this process we will have the product of all e^x_n = a_n that apply, and the remainder of this
// decomposition, which will be lower than the smallest x_n.
// exp(x) = k_0 * a_0 * k_1 * a_1 * ... + k_n * a_n * exp(remainder), where each k_n equals either 0 or 1.
// We mutate x by subtracting x_n, making it the remainder of the decomposition.
// The first two a_n (e^(2^7) and e^(2^6)) are too large if stored as 18 decimal numbers, and could cause
// intermediate overflows. Instead we store them as plain integers, with 0 decimals.
// Additionally, x0 + x1 is larger than MAX_NATURAL_EXPONENT, which means they will not both be present in the
// decomposition.
// For each x_n, we test if that term is present in the decomposition (if x is larger than it), and if so deduct
// it and compute the accumulated product.
int256 firstAN;
if (x >= x0) {
x -= x0;
firstAN = a0;
} else if (x >= x1) {
x -= x1;
firstAN = a1;
} else {
firstAN = 1; // One with no decimal places
}
// We now transform x into a 20 decimal fixed point number, to have enhanced precision when computing the
// smaller terms.
x *= 100;
// `product` is the accumulated product of all a_n (except a0 and a1), which starts at 20 decimal fixed point
// one. Recall that fixed point multiplication requires dividing by ONE_20.
int256 product = ONE_20;
if (x >= x2) {
x -= x2;
product = (product * a2) / ONE_20;
}
if (x >= x3) {
x -= x3;
product = (product * a3) / ONE_20;
}
if (x >= x4) {
x -= x4;
product = (product * a4) / ONE_20;
}
if (x >= x5) {
x -= x5;
product = (product * a5) / ONE_20;
}
if (x >= x6) {
x -= x6;
product = (product * a6) / ONE_20;
}
if (x >= x7) {
x -= x7;
product = (product * a7) / ONE_20;
}
if (x >= x8) {
x -= x8;
product = (product * a8) / ONE_20;
}
if (x >= x9) {
x -= x9;
product = (product * a9) / ONE_20;
}
// x10 and x11 are unnecessary here since we have high enough precision already.
// Now we need to compute e^x, where x is small (in particular, it is smaller than x9). We use the Taylor series
// expansion for e^x: 1 + x + (x^2 / 2!) + (x^3 / 3!) + ... + (x^n / n!).
int256 seriesSum = ONE_20; // The initial one in the sum, with 20 decimal places.
int256 term; // Each term in the sum, where the nth term is (x^n / n!).
// The first term is simply x.
term = x;
seriesSum += term;
// Each term (x^n / n!) equals the previous one times x, divided by n. Since x is a fixed point number,
// multiplying by it requires dividing by ONE_20, but dividing by the non-fixed point n values does not.
term = ((term * x) / ONE_20) / 2;
seriesSum += term;
term = ((term * x) / ONE_20) / 3;
seriesSum += term;
term = ((term * x) / ONE_20) / 4;
seriesSum += term;
term = ((term * x) / ONE_20) / 5;
seriesSum += term;
term = ((term * x) / ONE_20) / 6;
seriesSum += term;
term = ((term * x) / ONE_20) / 7;
seriesSum += term;
term = ((term * x) / ONE_20) / 8;
seriesSum += term;
term = ((term * x) / ONE_20) / 9;
seriesSum += term;
term = ((term * x) / ONE_20) / 10;
seriesSum += term;
term = ((term * x) / ONE_20) / 11;
seriesSum += term;
term = ((term * x) / ONE_20) / 12;
seriesSum += term;
// 12 Taylor terms are sufficient for 18 decimal precision.
// We now have the first a_n (with no decimals), and the product of all other a_n present, and the Taylor
// approximation of the exponentiation of the remainder (both with 20 decimals). All that remains is to multiply
// all three (one 20 decimal fixed point multiplication, dividing by ONE_20, and one integer multiplication),
// and then drop two digits to return an 18 decimal value.
return (((product * seriesSum) / ONE_20) * firstAN) / 100;
}
| 20,486 |
56 | // update owner and add token to new owner | cityData[_tokenId].owner = _to;
addToken(_to, _tokenId);
| cityData[_tokenId].owner = _to;
addToken(_to, _tokenId);
| 9,422 |
16 | // Using formula y = x ^ (p^2 + 15) / 32 from https:github.com/ethereum/beacon_chain/blob/master/beacon_chain/utils/bls.py (p^2 + 15) / 32 results into a big 512bit value, so breaking it to two uint256 as (aa + b) | uint256 a = 3869331240733915743250440106392954448556483137451914450067252501901456824595;
uint256 b = 146360017852723390495514512480590656176144969185739259173561346299185050597;
(uint256 xbx, uint256 xby) = _gfP2Pow(xx, xy, b);
(uint256 yax, uint256 yay) = _gfP2Pow(xx, xy, a);
(uint256 ya2x, uint256 ya2y) = _gfP2Pow(yax, yay, a);
(y.x, y.y) = _gfP2Multiply(ya2x, ya2y, xbx, xby);
| uint256 a = 3869331240733915743250440106392954448556483137451914450067252501901456824595;
uint256 b = 146360017852723390495514512480590656176144969185739259173561346299185050597;
(uint256 xbx, uint256 xby) = _gfP2Pow(xx, xy, b);
(uint256 yax, uint256 yay) = _gfP2Pow(xx, xy, a);
(uint256 ya2x, uint256 ya2y) = _gfP2Pow(yax, yay, a);
(y.x, y.y) = _gfP2Multiply(ya2x, ya2y, xbx, xby);
| 7,859 |
23 | // Function that mints an amount of the token to a givenaccount.Emits Transfer event, with from address set to zero.Allowed only to manager. return True on success. / | function mint(address account, uint256 value) external onlyManager returns (bool) {
_mint(account, value);
return true;
}
| function mint(address account, uint256 value) external onlyManager returns (bool) {
_mint(account, value);
return true;
}
| 40,269 |
16 | // TODO: calcualte winnings, convert dai back to eth, and distribute to the right side, leaving a 2% commission for owner. |
string memory result = orfeed.getEventResult("floater.market", toString(this));
if(equal(result, "TRUE")){
return true;
}
|
string memory result = orfeed.getEventResult("floater.market", toString(this));
if(equal(result, "TRUE")){
return true;
}
| 23,225 |
4 | // tokenReward = token(0xc51FAfD6137B66501b7716Cd7BCDE8227e751440); RopstentokenSwap = token(0x5e340d148cAc4DDC8D985c7CF148314032DAC9F8); Ropsten | brend = tokenReward.balanceOf(address(this))-(maxTokens-tokenSwap.balanceOf(this)) / maxTokens;
| brend = tokenReward.balanceOf(address(this))-(maxTokens-tokenSwap.balanceOf(this)) / maxTokens;
| 39,366 |
11 | // Rebase first to make index up-to-date | rebase();
uint256 _amount = 0;
for (uint256 i = 0; i < _tokens.length; i++) {
require(tokenSupported[_tokens[i]], "token not supported");
require(!mintPaused[_tokens[i]], "token paused");
if (_amounts[i] == 0) continue;
_amount = _amount.add(_amounts[i]);
| rebase();
uint256 _amount = 0;
for (uint256 i = 0; i < _tokens.length; i++) {
require(tokenSupported[_tokens[i]], "token not supported");
require(!mintPaused[_tokens[i]], "token paused");
if (_amounts[i] == 0) continue;
_amount = _amount.add(_amounts[i]);
| 16,958 |
126 | // Pick out the list length. | listLen := div(mload(add(ptr, 1)), exp(256, sub(32, lenOfListLen)))
| listLen := div(mload(add(ptr, 1)), exp(256, sub(32, lenOfListLen)))
| 29,883 |
27 | // Sets the daily limit. | function _setDailyLimit(uint _limit) internal {
require(_limit <= MAX_ALLOWED);
vars.dailyLimit = uint112(_limit);
}
| function _setDailyLimit(uint _limit) internal {
require(_limit <= MAX_ALLOWED);
vars.dailyLimit = uint112(_limit);
}
| 63,826 |
124 | // Report whether the answer to the specified question is finalized/question_id The ID of the question/ return Return true if finalized | function isFinalized(bytes32 question_id) external view returns (bool);
| function isFinalized(bytes32 question_id) external view returns (bool);
| 49,594 |
17 | // Convert quadruple precision number into octuple precision number.x quadruple precision numberreturn octuple precision number / | function toOctuple (bytes16 x) internal pure returns (bytes32) {
uint256 exponent = uint128 (x) >> 112 & 0x7FFF;
uint256 result = uint128 (x) & 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFF;
if (exponent == 0x7FFF) exponent = 0x7FFFF; // Infinity or NaN
else if (exponent == 0) {
if (result > 0) {
uint256 msb = msb (result);
result = result << 236 - msb & 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF;
exponent = 245649 + msb;
}
} else {
result <<= 124;
exponent += 245760;
}
result |= exponent << 236;
if (uint128 (x) >= 0x80000000000000000000000000000000)
result |= 0x8000000000000000000000000000000000000000000000000000000000000000;
return bytes32 (result);
}
| function toOctuple (bytes16 x) internal pure returns (bytes32) {
uint256 exponent = uint128 (x) >> 112 & 0x7FFF;
uint256 result = uint128 (x) & 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFF;
if (exponent == 0x7FFF) exponent = 0x7FFFF; // Infinity or NaN
else if (exponent == 0) {
if (result > 0) {
uint256 msb = msb (result);
result = result << 236 - msb & 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF;
exponent = 245649 + msb;
}
} else {
result <<= 124;
exponent += 245760;
}
result |= exponent << 236;
if (uint128 (x) >= 0x80000000000000000000000000000000)
result |= 0x8000000000000000000000000000000000000000000000000000000000000000;
return bytes32 (result);
}
| 25,695 |
36 | // Safely transfers the ownership of multiple Estate IDs to another address Delegates to safeTransferFrom for each transfer Requires the msg sender to be the owner, approved, or operator from current owner of the token to address to receive the ownership of the given token ID estateIds uint256 array of IDs to be transferred data bytes data to send along with a safe transfer check/ | function safeTransferManyFrom(
address from,
address to,
uint256[] estateIds,
bytes data
)
public
| function safeTransferManyFrom(
address from,
address to,
uint256[] estateIds,
bytes data
)
public
| 36,595 |
184 | // 销毁/from 目标地址/value 销毁数量 | function burn(address from, uint value) external onlyMinter {
_burn(from, value);
}
| function burn(address from, uint value) external onlyMinter {
_burn(from, value);
}
| 41,895 |
410 | // only lending pools configurator can use functions affected by this modifier/ | modifier onlyLendingPoolConfigurator {
require(
addressesProvider.getLendingPoolConfigurator() == msg.sender,
"The caller must be a lending pool configurator contract"
);
_;
}
| modifier onlyLendingPoolConfigurator {
require(
addressesProvider.getLendingPoolConfigurator() == msg.sender,
"The caller must be a lending pool configurator contract"
);
_;
}
| 81,115 |
771 | // Gets all Claims created by a user till date. _member user's address.return claimarr List of Claims id. / | function getAllClaimsByAddress(address _member) external view returns (uint[] memory claimarr) {
return allClaimsByAddress[_member];
}
| function getAllClaimsByAddress(address _member) external view returns (uint[] memory claimarr) {
return allClaimsByAddress[_member];
}
| 28,862 |
44 | // mint DVault needed and store amount of rewards for distribution | send_ = value.sub( _profit );
IERC20Mintable( DVault ).mint( msg.sender, send_ );
totalReserves = totalReserves.add( value );
emit ReservesUpdated( totalReserves );
emit Deposit( _token, _amount, value );
| send_ = value.sub( _profit );
IERC20Mintable( DVault ).mint( msg.sender, send_ );
totalReserves = totalReserves.add( value );
emit ReservesUpdated( totalReserves );
emit Deposit( _token, _amount, value );
| 34,366 |
6 | // withdraw checks out, transfer to the account in account tree | address tokenContractAddress = tokenRegistry.registeredTokens(
withdraw_tx_proof._tx.data.tokenType
);
| address tokenContractAddress = tokenRegistry.registeredTokens(
withdraw_tx_proof._tx.data.tokenType
);
| 26,707 |
614 | // Gets an element from the list.//_index the index in the list.// return the element at the specified index. | function get(List storage _self, uint256 _index) internal view returns (Data storage) {
return _self.elements[_index];
}
| function get(List storage _self, uint256 _index) internal view returns (Data storage) {
return _self.elements[_index];
}
| 46,671 |
75 | // Value(msg.value);bool nonZeroPurchase = msg.value != 0; | bool validAmount = msg.value >= minTransAmount;
bool withinmintedTokensCap = mintedTokensCap >= (token.totalSupply() + getTokenAmount(msg.value));
return withinPeriod && validAmount && withinmintedTokensCap;
| bool validAmount = msg.value >= minTransAmount;
bool withinmintedTokensCap = mintedTokensCap >= (token.totalSupply() + getTokenAmount(msg.value));
return withinPeriod && validAmount && withinmintedTokensCap;
| 49,774 |
64 | // ----------ADMINISTRATOR ONLY FUNCTIONS----------//In case the amassador quota is not met, the administrator can manually disable the ambassador phase. / | function disableInitialStage()
onlyAdministrator()
public
| function disableInitialStage()
onlyAdministrator()
public
| 21,407 |
14 | // Checks that it is now possible to purchase passed amount tokens/amount - the number of tokens to verify the possibility of purchase | modifier verifyPurchase(uint256 amount) {
if (block.timestamp < saleStartTime || block.timestamp >= saleEndTime) revert InvalidTimeframe();
if (amount == 0) revert BuyAtLeastOneToken();
if (amount + totalTokensSold > limitPerStage[MAX_STAGE_INDEX])
revert PresaleLimitExceeded(limitPerStage[MAX_STAGE_INDEX] - totalTokensSold);
_;
}
| modifier verifyPurchase(uint256 amount) {
if (block.timestamp < saleStartTime || block.timestamp >= saleEndTime) revert InvalidTimeframe();
if (amount == 0) revert BuyAtLeastOneToken();
if (amount + totalTokensSold > limitPerStage[MAX_STAGE_INDEX])
revert PresaleLimitExceeded(limitPerStage[MAX_STAGE_INDEX] - totalTokensSold);
_;
}
| 34,763 |
85 | // maps relay managers to their stakes | mapping(address => StakeInfo) public stakes;
| mapping(address => StakeInfo) public stakes;
| 11,181 |
65 | // Deposit payout | if(to_payout > 0) {
if(users[msg.sender].payouts + to_payout > max_payout) {
to_payout = max_payout - users[msg.sender].payouts;
}
| if(to_payout > 0) {
if(users[msg.sender].payouts + to_payout > max_payout) {
to_payout = max_payout - users[msg.sender].payouts;
}
| 36,269 |
1 | // These are state variables to store candidates and voters | uint256 internal numCandidates;
uint256 internal numVoters;
| uint256 internal numCandidates;
uint256 internal numVoters;
| 5,201 |
84 | // Whether `a` is greater than or equal to `b`. a a FixedPoint.Signed. b a FixedPoint.Signed.return True if `a >= b`, or False. / | function isGreaterThanOrEqual(Signed memory a, Signed memory b)
internal
pure
returns (bool)
| function isGreaterThanOrEqual(Signed memory a, Signed memory b)
internal
pure
returns (bool)
| 30,178 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.