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 |
|---|---|---|---|---|
65 | // KYC Check | validateWhitelisted(_beneficiary);
| validateWhitelisted(_beneficiary);
| 59,291 |
5 | // Whenever the drop has been succesfully set | bool public dropSet;
| bool public dropSet;
| 15,305 |
4 | // read the mints made by a specified wallet address._wallet the wallet address/ | function mintsForWallet(address _wallet) public view returns (uint64) {
return _getAux(_wallet);
}
| function mintsForWallet(address _wallet) public view returns (uint64) {
return _getAux(_wallet);
}
| 37,240 |
167 | // Provides a safe ERC20.transfer version for different ERC-20 implementations./ Reverts on a failed transfer./token The address of the ERC-20 token./to Transfer tokens to./amount The token amount. | function safeTransfer(
IERC20 token,
address to,
uint256 amount
| function safeTransfer(
IERC20 token,
address to,
uint256 amount
| 5,344 |
22 | // fadeout options at the end of fadout | return minFadeValue;
| return minFadeValue;
| 16,525 |
39 | // Creates a vesting contract that vests its balance of any ERC20 token to the_beneficiary, gradually in a linear fashion until _start + _duration. By then allof the balance will have vested. _beneficiary address of the beneficiary to whom vested tokens are transferred _cliff duration in seconds of the cliff in which tokens will begin to vest _duration duration in seconds of the period in which the tokens will vest _revocable whether the vesting is revocable or not / | function TokenVesting(address _beneficiary, uint256 _start, uint256 _cliff, uint256 _duration, bool _revocable) public {
require(_beneficiary != address(0));
require(_cliff <= _duration);
beneficiary = _beneficiary;
revocable = _revocable;
duration = _duration;
cliff = _start.add(_cliff);
start = _start;
}
| function TokenVesting(address _beneficiary, uint256 _start, uint256 _cliff, uint256 _duration, bool _revocable) public {
require(_beneficiary != address(0));
require(_cliff <= _duration);
beneficiary = _beneficiary;
revocable = _revocable;
duration = _duration;
cliff = _start.add(_cliff);
start = _start;
}
| 2,598 |
130 | // Sets the price of a product_productId - the product id_price - the product price/ | function setPrice(uint256 _productId, uint256 _price)
external
onlyMinter
| function setPrice(uint256 _productId, uint256 _price)
external
onlyMinter
| 22,975 |
68 | // Create a new stake It is recomended to call stakeOnExistingNode after creating a new stakeso that a griefer doesn't remove your stake by immediately calling returnOldDeposit / | function newStake() external payable onlyValidator whenNotPaused {
_newStake(msg.value);
}
| function newStake() external payable onlyValidator whenNotPaused {
_newStake(msg.value);
}
| 22,006 |
5 | // Buys the given summoner. Must pay the exact correct prirce. | function buy(address nft, uint256 tokenId) external payable nonReentrant {
uint256 price = prices[nft][tokenId];
require(price > 0, "not listed");
require(msg.value == price, "bad msg.value");
uint256 fee = (price * feeBps) / 10000;
uint256 get = price - fee;
address lister = listers[tokenId][nft];
prices[nft][tokenId] = 0;
listers[tokenId][nft] = address(0);
IERC721(nft).safeTransferFrom(address(this), msg.sender, tokenId);
payable(lister).transfer(get);
nftSet.remove(nft);
tokenIdSet[nft].remove(tokenId);
myTokenIdSet[msg.sender][nft].remove(tokenId);
myNFTSet[msg.sender].remove(nft);
emit Buy(nft, tokenId, lister, msg.sender, price, fee);
}
| function buy(address nft, uint256 tokenId) external payable nonReentrant {
uint256 price = prices[nft][tokenId];
require(price > 0, "not listed");
require(msg.value == price, "bad msg.value");
uint256 fee = (price * feeBps) / 10000;
uint256 get = price - fee;
address lister = listers[tokenId][nft];
prices[nft][tokenId] = 0;
listers[tokenId][nft] = address(0);
IERC721(nft).safeTransferFrom(address(this), msg.sender, tokenId);
payable(lister).transfer(get);
nftSet.remove(nft);
tokenIdSet[nft].remove(tokenId);
myTokenIdSet[msg.sender][nft].remove(tokenId);
myNFTSet[msg.sender].remove(nft);
emit Buy(nft, tokenId, lister, msg.sender, price, fee);
}
| 40,458 |
34 | // If this vault is underwater-with-respect-to-rewards (different than noncompliant), liquidation is pro-rata underater iff: weiAsset[target_address] < vSYMDebtE18[target_address]/1E18weiPervSYM(liqPenaltyE10+1E10)/1E10 | uint LHS2 = weiAsset[target_address].mul( 10 ** 18 ).mul( 10 ** 10);
uint RHS2 = vSYMDebtE18[target_address].mul( weiPervSYM ).mul( liqPenaltyE10.add( 10 ** 10 ));
uint weiClaim;
if( LHS2 < RHS2 ) { // pro-rata claim
| uint LHS2 = weiAsset[target_address].mul( 10 ** 18 ).mul( 10 ** 10);
uint RHS2 = vSYMDebtE18[target_address].mul( weiPervSYM ).mul( liqPenaltyE10.add( 10 ** 10 ));
uint weiClaim;
if( LHS2 < RHS2 ) { // pro-rata claim
| 8,276 |
361 | // Exactly how much of userIn to swap to get perfectly balanced ratio for LP tokens This code matches Alpha Homora and Zapper reserveIn Amount of reserves for asset 0 userIn Availabe amount of asset 0 to swapreturn Amount of userIn to swap for asset 1 / | function calculateSwapInAmount(uint256 reserveIn, uint256 userIn)
internal
pure
returns (uint256)
| function calculateSwapInAmount(uint256 reserveIn, uint256 userIn)
internal
pure
returns (uint256)
| 81,205 |
26 | // @inheritdoc IIndexPrice/we overwrite the index price in BaseToken depending on the status/1. Open: the price is from the price feed/2. Paused or Closed: the price is twap when the token was paused | function getIndexPrice(uint256 interval) public view override returns (uint256) {
if (_status == IBaseToken.Status.Open) {
return _formatDecimals(IPriceFeed(_priceFeed).getPrice(interval));
}
return _pausedIndexPrice;
}
| function getIndexPrice(uint256 interval) public view override returns (uint256) {
if (_status == IBaseToken.Status.Open) {
return _formatDecimals(IPriceFeed(_priceFeed).getPrice(interval));
}
return _pausedIndexPrice;
}
| 2,212 |
188 | // track the tokens that ascended & add to the global goal | sacrificed.increment();
ritualizedInhabitants[vessel] = true;
emit performRitualEvent(msg.sender, vessel, sacrifice);
| sacrificed.increment();
ritualizedInhabitants[vessel] = true;
emit performRitualEvent(msg.sender, vessel, sacrifice);
| 43,791 |
27 | // this function is defined in a child contract //whether a note is already spent / | function isSpent(bytes32 _nullifierHash) public view returns (bool) {
return nullifierHashes[_nullifierHash];
}
| function isSpent(bytes32 _nullifierHash) public view returns (bool) {
return nullifierHashes[_nullifierHash];
}
| 34,924 |
50 | // Calculates partial value given a numerator and denominator rounded down./numerator Numerator./denominator Denominator./target Value to calculate partial of./ return Partial value of target rounded down. | function getPartialAmountFloor(
uint256 numerator,
uint256 denominator,
uint256 target
)
internal
pure
returns (uint256 partialAmount)
| function getPartialAmountFloor(
uint256 numerator,
uint256 denominator,
uint256 target
)
internal
pure
returns (uint256 partialAmount)
| 8,678 |
81 | // Internal function to notify SDT to the gauge | function _distributeSDT() internal {
if (sdtDistributor != address(0)) {
ISDTDistributor(sdtDistributor).distribute(gauge);
}
}
| function _distributeSDT() internal {
if (sdtDistributor != address(0)) {
ISDTDistributor(sdtDistributor).distribute(gauge);
}
}
| 30,979 |
259 | // Construct an array of market(s) to enable as collateral. | CERC20[] memory marketsToEnter = new CERC20[](1);
marketsToEnter[0] = assetTurboCToken;
| CERC20[] memory marketsToEnter = new CERC20[](1);
marketsToEnter[0] = assetTurboCToken;
| 11,028 |
159 | // case 3. normal case | uint256 baseInputRatio = DecimalMath.divFloor(baseInput, baseReserve);
uint256 quoteInputRatio = DecimalMath.divFloor(quoteInput, quoteReserve);
uint256 mintRatio = quoteInputRatio < baseInputRatio ? quoteInputRatio : baseInputRatio;
shares = DecimalMath.mulFloor(totalSupply, mintRatio);
| uint256 baseInputRatio = DecimalMath.divFloor(baseInput, baseReserve);
uint256 quoteInputRatio = DecimalMath.divFloor(quoteInput, quoteReserve);
uint256 mintRatio = quoteInputRatio < baseInputRatio ? quoteInputRatio : baseInputRatio;
shares = DecimalMath.mulFloor(totalSupply, mintRatio);
| 7,972 |
10 | // ENCHANT BALANCE |
uint enchant_total = enchant.totalSupply();
uint enchant_balance = enchant.balanceOf(member);
uint enchant_totalSeance = seance.balanceOf(address(enchant));
|
uint enchant_total = enchant.totalSupply();
uint enchant_balance = enchant.balanceOf(member);
uint enchant_totalSeance = seance.balanceOf(address(enchant));
| 42,852 |
60 | // Track the address for the new contract | address payable deployedAddress;
| address payable deployedAddress;
| 5,087 |
6 | // Returns balance of particular account | function balanceOf(address _owner) constant returns (uint256 balance) {
return balances[_owner];
}
| function balanceOf(address _owner) constant returns (uint256 balance) {
return balances[_owner];
}
| 55,554 |
10 | // main minting function | function mint_Cubes(uint amount) public {
require(mintingSaleIsActive, "Minting is not active yet"); //is minting active
_mint_With_Tickets(msg.sender, amount);
}
| function mint_Cubes(uint amount) public {
require(mintingSaleIsActive, "Minting is not active yet"); //is minting active
_mint_With_Tickets(msg.sender, amount);
}
| 8,934 |
553 | // res += val(coefficients[246] + coefficients[247]adjustments[15]). | res := addmod(res,
mulmod(val,
add(/*coefficients[246]*/ mload(0x2300),
mulmod(/*coefficients[247]*/ mload(0x2320),
| res := addmod(res,
mulmod(val,
add(/*coefficients[246]*/ mload(0x2300),
mulmod(/*coefficients[247]*/ mload(0x2320),
| 14,874 |
8 | // Event | event Transfer(address indexed _from, address indexed _to, uint256 _value);
event UpdateStatus(string newStatus);
event Burn(address target, uint256 _value);
event MintedToken(address target, uint256 _value);
event FrozenFunds(address target, bool _value);
event Approval(address indexed owner, address indexed spender, uint256 value);
| event Transfer(address indexed _from, address indexed _to, uint256 _value);
event UpdateStatus(string newStatus);
event Burn(address target, uint256 _value);
event MintedToken(address target, uint256 _value);
event FrozenFunds(address target, bool _value);
event Approval(address indexed owner, address indexed spender, uint256 value);
| 10,618 |
170 | // Maximum amount of DOOM to migrate | uint256 public maxDoomToMigrate;
| uint256 public maxDoomToMigrate;
| 60,962 |
19 | // Gives worker permission to act on a DApp/_workerAddress address of the worker node to given permission/_dappAddress address of the dapp that permission will be given to | function authorize(address _workerAddress, address _dappAddress) external;
| function authorize(address _workerAddress, address _dappAddress) external;
| 51,092 |
14 | // Event emitted when launcher is created using template id. | event LauncherCreated(address indexed owner, address indexed addr, address launcherTemplate);
| event LauncherCreated(address indexed owner, address indexed addr, address launcherTemplate);
| 10,560 |
58 | // withdraw dividends for user | IERC20(quaiToken).transfer(msg.sender, dividends);
| IERC20(quaiToken).transfer(msg.sender, dividends);
| 6,905 |
85 | // ethInvestedDuringICO tracks how much Ether goes straight to tokens, Cannot purchase more than the hard cap during ICO. | require(ethInvestedDuringICO <= icoHardCap);
| require(ethInvestedDuringICO <= icoHardCap);
| 80,485 |
7 | // Triggered when the claimDelay value has been updatedoldClaimDelayOld claimDelay value newClaimDelayNew claimDelay value / | event ClaimDelayUpdated(uint256 oldClaimDelay, uint256 newClaimDelay);
| event ClaimDelayUpdated(uint256 oldClaimDelay, uint256 newClaimDelay);
| 20,313 |
14 | // Ensure that sufficient gas is available to copy returndata while expanding memory where necessary. Start by computing the word size of returndata and allocated memory. Round up to the nearest full word. | let returnDataWords := div(
add(returndatasize(), AlmostOneWord),
OneWord
)
| let returnDataWords := div(
add(returndatasize(), AlmostOneWord),
OneWord
)
| 14,444 |
2 | // events | event MinterChanged(address indexed previousMinter, address indexed newMinter);
| event MinterChanged(address indexed previousMinter, address indexed newMinter);
| 16,524 |
62 | // swapping the matoken for mtoken | inversePairTokens[0] = address(matoken);
| inversePairTokens[0] = address(matoken);
| 29,627 |
16 | // 30天只能转出一次; 24个小时乘以30天; | uint256 public monthTime;
| uint256 public monthTime;
| 9,668 |
10 | // Deposits entire Weth/Bal balance of caller. Stakes same amount in Rewards contract/_stakeAddress The Reward contract address/_lock boolean whether depositor wants to lock funds immediately | function depositAll(bool _lock, address _stakeAddress) external {
uint256 wethBalBalance = IERC20(wethBal).balanceOf(msg.sender); //This is balancer balance of msg.sender
deposit(wethBalBalance, _lock, _stakeAddress);
}
| function depositAll(bool _lock, address _stakeAddress) external {
uint256 wethBalBalance = IERC20(wethBal).balanceOf(msg.sender); //This is balancer balance of msg.sender
deposit(wethBalBalance, _lock, _stakeAddress);
}
| 30,325 |
15 | // Reverts if sender does not have admin role associated. / | modifier onlyAdmin() {
require(isAdmin(msg.sender), "Operatorable: caller does not have the admin role");
_;
}
| modifier onlyAdmin() {
require(isAdmin(msg.sender), "Operatorable: caller does not have the admin role");
_;
}
| 37,196 |
46 | // PoolHedger Lyra Uses the delta hedging funds from the LiquidityPool to hedge option deltas,so LPs are minimally exposed to movements in the underlying asset price. / | contract PoolHedger is Ownable {
using SafeMath for uint;
using SignedSafeMath for int;
using SafeDecimalMath for uint;
LyraGlobals internal globals;
OptionMarket internal optionMarket;
OptionGreekCache internal optionGreekCache;
LiquidityPool internal liquidityPool;
IERC20 internal quoteAsset;
IERC20 internal baseAsset;
bool initialized = false;
bool public shortingInitialized = false;
// the ID of our short that is opened when we init the contract.
uint public shortId;
// the ratio we wish to maintain on our short position.
uint public shortBuffer;
// The last time a short or long position was updated
uint public lastInteraction;
// How long before balance can be updated
uint public interactionDelay;
// Counter for reentrancy guard
uint internal counter = 1;
constructor() Ownable() {
shortBuffer = (2 * SafeDecimalMath.UNIT);
interactionDelay = 3 hours;
emit ShortBufferSet(shortBuffer);
emit InteractionDelaySet(interactionDelay);
}
function setShortBuffer(uint newShortBuffer) external onlyOwner {
require(newShortBuffer <= (10 * SafeDecimalMath.UNIT), "buffer too high"); // 1000%
require(newShortBuffer >= ((15 * SafeDecimalMath.UNIT) / 10), "buffer too low"); // 150%
shortBuffer = newShortBuffer;
emit ShortBufferSet(shortBuffer);
}
function setInteractionDelay(uint newInteractionDelay) external onlyOwner {
interactionDelay = newInteractionDelay;
emit InteractionDelaySet(interactionDelay);
}
/**
* @dev Initialize the contract.
*
* @param _globals LyraGlobals address
* @param _optionMarket OptionMarket address
* @param _liquidityPool LiquidityPool address
* @param _quoteAsset Quote asset address
* @param _baseAsset Base asset address
*/
function init(
LyraGlobals _globals,
OptionMarket _optionMarket,
OptionGreekCache _optionGreekCache,
LiquidityPool _liquidityPool,
IERC20 _quoteAsset,
IERC20 _baseAsset
) external {
require(!initialized, "contract already initialized");
globals = _globals;
optionMarket = _optionMarket;
optionGreekCache = _optionGreekCache;
liquidityPool = _liquidityPool;
quoteAsset = _quoteAsset;
baseAsset = _baseAsset;
initialized = true;
}
/**
* @dev Initialises the short.
*/
function initShort() external onlyOwner {
require(initialized, "contract must be initialized");
require(!shortingInitialized, "shorting already initialized");
LyraGlobals.ExchangeGlobals memory exchangeGlobals =
globals.getExchangeGlobals(address(optionMarket), LyraGlobals.ExchangeType.ALL);
openShort(exchangeGlobals);
shortingInitialized = true;
}
/**
* @dev Reopens the short if the old one was closed or liquidated.
*/
function reopenShort() external onlyOwner {
require(initialized && shortingInitialized, "not initialized");
LyraGlobals.ExchangeGlobals memory exchangeGlobals =
globals.getExchangeGlobals(address(optionMarket), LyraGlobals.ExchangeType.ALL);
(, , , , , , , uint interestIndex, ) = exchangeGlobals.short.loans(shortId);
// Cannot open a new short if the old one is still open
require(interestIndex == 0, "short still open");
openShort(exchangeGlobals);
}
/**
* @dev Opens the short position with 0 amount and 0 collateral.
*
* @param exchangeGlobals The ExchangeGlobals.
*/
function openShort(LyraGlobals.ExchangeGlobals memory exchangeGlobals) internal reentrancyGuard {
uint minCollateral = exchangeGlobals.short.minCollateral();
quoteAsset.approve(address(exchangeGlobals.short), type(uint).max);
// Open a short with 0 collateral and 0 amount, to get a static Id for this contract to use.
liquidityPool.transferQuoteToHedge(exchangeGlobals, minCollateral);
// This will revert if the LP did not provide enough quote
shortId = exchangeGlobals.short.open(minCollateral, 0, exchangeGlobals.baseKey);
sendAllQuoteToLP();
emit ShortInitialized(shortId);
emit ShortSetTo(0, 0, 0, minCollateral);
}
/**
* @notice Retreives the netDelta from the OptionGreekCache and updates the hedge position.
*/
function hedgeDelta() external reentrancyGuard {
require(shortingInitialized, "shorting must be initialized");
// Update any stale boards to get an accurate netDelta value
int netOptionDelta = optionGreekCache.getGlobalNetDelta();
// Subtract the eth balance from netDelta, to account for the variance from collateral held by LP.
int expectedHedge = netOptionDelta.sub(int(baseAsset.balanceOf(address(liquidityPool))));
// Bypass interactionDelay if we want to set netDelta to 0
if (expectedHedge != 0 && interactionDelay != 0) {
require(lastInteraction + interactionDelay <= block.timestamp, "Interaction delay");
}
_hedgeDelta(expectedHedge);
}
function _hedgeDelta(int expectedHedge) internal {
LyraGlobals.ExchangeGlobals memory exchangeGlobals =
globals.getExchangeGlobals(address(optionMarket), LyraGlobals.ExchangeType.ALL);
uint longBalance = baseAsset.balanceOf(address(this));
(uint shortBalance, uint collateral) = getShortPosition(exchangeGlobals.short);
int oldHedge = longBalance != 0 ? int(longBalance) : -int(shortBalance);
int newHedge = updatePosition(exchangeGlobals, longBalance, shortBalance, collateral, expectedHedge);
emit PositionUpdated(oldHedge, newHedge, expectedHedge);
if (newHedge != oldHedge) {
lastInteraction = block.timestamp;
}
// All proceeds should be sent back to the LP
sendAllQuoteToLP();
}
/**
* @dev Updates the hedge contract based off a new netDelta.
*
* @param exchangeGlobals TODO
* @param longBalance TODO
* @param shortBalance TODO
* @param collateral TODO
* @param expectedHedge The amount of baseAsset exposure needed to hedge delta risk.
*/
function updatePosition(
LyraGlobals.ExchangeGlobals memory exchangeGlobals,
uint longBalance,
uint shortBalance,
uint collateral,
int expectedHedge
) internal returns (int) {
if (expectedHedge >= 0) {
// we need to be net long the asset.
uint expectedLong = uint(expectedHedge);
// if we have any short open, close it all.
if (shortBalance > 0 || collateral > 0) {
return -int(setShortTo(exchangeGlobals, 0, shortBalance, collateral));
}
if (expectedLong > longBalance) {
// Must Buy Eth
return int(increaseLong(exchangeGlobals, expectedLong.sub(longBalance), longBalance));
} else if (longBalance > expectedLong) {
// Must Sell Eth
return int(decreaseLong(exchangeGlobals, longBalance.sub(expectedLong), longBalance));
}
return int(longBalance);
} else {
// we need to be net short the asset.
uint expectedShort = uint(-expectedHedge);
// if we have any of the spot left, sell it all.
if (longBalance > 0) {
return int(decreaseLong(exchangeGlobals, longBalance, longBalance));
}
return -int(setShortTo(exchangeGlobals, expectedShort, shortBalance, collateral));
}
}
/**
* @dev Returns short balance and collateral.
*
* @param short The short contract.
*/
function getShortPosition(ICollateralShort short) public view returns (uint shortBalance, uint collateral) {
if (!shortingInitialized) {
return (0, 0);
}
return short.getShortAndCollateral(address(this), shortId);
}
/**
* @dev Returns the current hedged netDelta position
*/
function getCurrentHedgedNetDelta() external view returns (int) {
LyraGlobals.ExchangeGlobals memory exchangeGlobals =
globals.getExchangeGlobals(address(optionMarket), LyraGlobals.ExchangeType.ALL);
uint longBalance = baseAsset.balanceOf(address(this));
if (longBalance > 0) {
return int(longBalance);
}
(uint shortBalance, ) = getShortPosition(exchangeGlobals.short);
return -int(shortBalance);
}
/**
* @dev Returns the value of the long/short position held by the PoolHedger.
*
* @param short The short contract.
* @param spotPrice The price of the baseAsset.
*/
function getValueQuote(ICollateralShort short, uint spotPrice) public view returns (uint value) {
uint baseBalance = baseAsset.balanceOf(address(this));
if (baseBalance > 0) {
return baseBalance.multiplyDecimal(spotPrice);
} else {
(uint shortBalance, uint collateral) = getShortPosition(short);
uint shortOwed = shortBalance.multiplyDecimal(spotPrice);
if (collateral > shortOwed) {
return (collateral - shortOwed);
}
// If collateral value is less than the short, we want the short to be liquidated as we'd be paying more quote
// to free the collateral than we'd get back (+ exchange fees).
// This also handles the case where the contract is at a 0 position
return 0;
}
}
/**
* @dev Increases the long exposure of the hedge contract.
*
* @param exchangeGlobals The ExchangeGlobals.
* @param amount The amount of baseAsset to purchase.
*/
function increaseLong(
LyraGlobals.ExchangeGlobals memory exchangeGlobals,
uint amount,
uint currentBalance
) internal returns (uint newBalance) {
uint base = amount.divideDecimal(SafeDecimalMath.UNIT.sub(exchangeGlobals.quoteBaseFeeRate));
uint purchaseAmount = base.multiplyDecimal(exchangeGlobals.spotPrice);
uint receivedQuote = liquidityPool.transferQuoteToHedge(exchangeGlobals, purchaseAmount);
// We buy as much as is possible with the quote given
if (receivedQuote < purchaseAmount) {
purchaseAmount = receivedQuote;
}
// buy the base asset.
uint receivedBase =
exchangeGlobals.synthetix.exchange(exchangeGlobals.quoteKey, purchaseAmount, exchangeGlobals.baseKey);
require(receivedBase > 0, "increaseLong: Received 0 from exchange");
emit QuoteExchanged(purchaseAmount, receivedBase);
newBalance = baseAsset.balanceOf(address(this));
emit LongSetTo(currentBalance, newBalance);
}
/**
* @dev Decreases the long exposure of the hedge contract.
*
* @param exchangeGlobals The ExchangeGlobals.
* @param amount The amount of baseAsset to sell.
*/
function decreaseLong(
LyraGlobals.ExchangeGlobals memory exchangeGlobals,
uint amount,
uint currentBalance
) internal returns (uint newBalance) {
// assumption here is that we have enough to sell, will throw if not
uint received = exchangeGlobals.synthetix.exchange(exchangeGlobals.baseKey, amount, exchangeGlobals.quoteKey);
require(received > 0, "decreaseLong: Received 0 from exchange");
emit BaseExchanged(amount, received);
newBalance = baseAsset.balanceOf(address(this));
emit LongSetTo(currentBalance, newBalance);
}
/**
* @dev Increases or decreases short to get to this amount of shorted eth at the shortBuffer ratio. Note, hedge() may
* have to be called a second time to re-balance collateral after calling `repayWithCollateral`. As that disregards
* the desired ratio.
*
* @param exchangeGlobals The ExchangeGlobals.
* @param desiredShort The desired short balance.
* @param currentShort Trusted value for current short amount, in base.
* @param currentCollateral Trusted value for current amount of collateral, in quote.
*/
function setShortTo(
LyraGlobals.ExchangeGlobals memory exchangeGlobals,
uint desiredShort,
uint currentShort,
uint currentCollateral
) internal returns (uint newShortAmount) {
require(shortingInitialized, "shorting not initialized");
uint desiredCollateral = desiredShort.multiplyDecimal(exchangeGlobals.spotPrice).multiplyDecimal(shortBuffer);
if (desiredShort < currentShort) {
(uint newShort, uint newCollateral) =
exchangeGlobals.short.repayWithCollateral(shortId, currentShort.sub(desiredShort));
emit ShortSetTo(currentShort, newShort, currentCollateral, newCollateral);
return newShort;
}
if (desiredCollateral > currentCollateral) {
uint received = liquidityPool.transferQuoteToHedge(exchangeGlobals, desiredCollateral.sub(currentCollateral));
if (received > 0) {
(uint newShort, uint newCollateral) = exchangeGlobals.short.deposit(address(this), shortId, received);
emit ShortSetTo(currentShort, newShort, currentCollateral, newCollateral);
return newShort;
}
}
if (currentCollateral > desiredCollateral) {
(uint newShort, uint newCollateral) =
exchangeGlobals.short.withdraw(shortId, currentCollateral.sub(desiredCollateral));
emit ShortSetTo(currentShort, newShort, currentCollateral, newCollateral);
return newShort;
}
if (currentShort < desiredShort) {
uint shortAmount = currentCollateral.divideDecimal(exchangeGlobals.spotPrice).divideDecimal(shortBuffer);
if (shortAmount > currentShort) {
(uint newShort, uint newCollateral) = exchangeGlobals.short.draw(shortId, shortAmount.sub(currentShort));
emit ShortSetTo(currentShort, newShort, currentCollateral, newCollateral);
return newShort;
}
}
// Nothing needs to be changed
emit ShortSetTo(currentShort, currentShort, currentCollateral, currentCollateral);
return currentShort;
}
/**
* @dev Sends all quote asset deposited in this contract to the `LiquidityPool`.
*/
function sendAllQuoteToLP() internal {
uint quoteBal = quoteAsset.balanceOf(address(this));
require(quoteAsset.transfer(address(liquidityPool), quoteBal), "quote transfer failed");
emit QuoteReturnedToLP(quoteBal);
}
modifier reentrancyGuard virtual {
counter = counter.add(1); // counter adds 1 to the existing 1 so becomes 2
uint guard = counter; // assigns 2 to the "guard" variable
_;
require(guard == counter, "reentrancy");
}
/// Events
/**
* @dev Emitted when the short buffer ratio is set.
*/
event ShortBufferSet(uint newShortBuffer);
/**
* @dev Emitted when the interaction delay is set.
*/
event InteractionDelaySet(uint newInteractionDelay);
/**
* @dev Emitted when the short is initialized.
*/
event ShortInitialized(uint shortId);
/**
* @dev Emitted when the hedge position is updated.
*/
event PositionUpdated(int oldNetDelta, int currentNetDelta, int expectedNetDelta);
/**
* @dev Emitted when base is sold
*/
event BaseExchanged(uint baseAmount, uint quoteReceived);
/**
* @dev Emitted when base is sold
*/
event QuoteExchanged(uint quoteAmount, uint baseReceived);
/**
* @dev Emitted when the long exposure of the hedge contract is adjusted.
*/
event LongSetTo(uint oldAmount, uint newAmount);
/**
* @dev Emitted when short or short collateral is adjusted.
*/
event ShortSetTo(uint oldShort, uint newShort, uint oldCollateral, uint newCollateral);
/**
* @dev Emitted when proceeds of the short are sent back to the LP.
*/
event QuoteReturnedToLP(uint amountQuote);
}
| contract PoolHedger is Ownable {
using SafeMath for uint;
using SignedSafeMath for int;
using SafeDecimalMath for uint;
LyraGlobals internal globals;
OptionMarket internal optionMarket;
OptionGreekCache internal optionGreekCache;
LiquidityPool internal liquidityPool;
IERC20 internal quoteAsset;
IERC20 internal baseAsset;
bool initialized = false;
bool public shortingInitialized = false;
// the ID of our short that is opened when we init the contract.
uint public shortId;
// the ratio we wish to maintain on our short position.
uint public shortBuffer;
// The last time a short or long position was updated
uint public lastInteraction;
// How long before balance can be updated
uint public interactionDelay;
// Counter for reentrancy guard
uint internal counter = 1;
constructor() Ownable() {
shortBuffer = (2 * SafeDecimalMath.UNIT);
interactionDelay = 3 hours;
emit ShortBufferSet(shortBuffer);
emit InteractionDelaySet(interactionDelay);
}
function setShortBuffer(uint newShortBuffer) external onlyOwner {
require(newShortBuffer <= (10 * SafeDecimalMath.UNIT), "buffer too high"); // 1000%
require(newShortBuffer >= ((15 * SafeDecimalMath.UNIT) / 10), "buffer too low"); // 150%
shortBuffer = newShortBuffer;
emit ShortBufferSet(shortBuffer);
}
function setInteractionDelay(uint newInteractionDelay) external onlyOwner {
interactionDelay = newInteractionDelay;
emit InteractionDelaySet(interactionDelay);
}
/**
* @dev Initialize the contract.
*
* @param _globals LyraGlobals address
* @param _optionMarket OptionMarket address
* @param _liquidityPool LiquidityPool address
* @param _quoteAsset Quote asset address
* @param _baseAsset Base asset address
*/
function init(
LyraGlobals _globals,
OptionMarket _optionMarket,
OptionGreekCache _optionGreekCache,
LiquidityPool _liquidityPool,
IERC20 _quoteAsset,
IERC20 _baseAsset
) external {
require(!initialized, "contract already initialized");
globals = _globals;
optionMarket = _optionMarket;
optionGreekCache = _optionGreekCache;
liquidityPool = _liquidityPool;
quoteAsset = _quoteAsset;
baseAsset = _baseAsset;
initialized = true;
}
/**
* @dev Initialises the short.
*/
function initShort() external onlyOwner {
require(initialized, "contract must be initialized");
require(!shortingInitialized, "shorting already initialized");
LyraGlobals.ExchangeGlobals memory exchangeGlobals =
globals.getExchangeGlobals(address(optionMarket), LyraGlobals.ExchangeType.ALL);
openShort(exchangeGlobals);
shortingInitialized = true;
}
/**
* @dev Reopens the short if the old one was closed or liquidated.
*/
function reopenShort() external onlyOwner {
require(initialized && shortingInitialized, "not initialized");
LyraGlobals.ExchangeGlobals memory exchangeGlobals =
globals.getExchangeGlobals(address(optionMarket), LyraGlobals.ExchangeType.ALL);
(, , , , , , , uint interestIndex, ) = exchangeGlobals.short.loans(shortId);
// Cannot open a new short if the old one is still open
require(interestIndex == 0, "short still open");
openShort(exchangeGlobals);
}
/**
* @dev Opens the short position with 0 amount and 0 collateral.
*
* @param exchangeGlobals The ExchangeGlobals.
*/
function openShort(LyraGlobals.ExchangeGlobals memory exchangeGlobals) internal reentrancyGuard {
uint minCollateral = exchangeGlobals.short.minCollateral();
quoteAsset.approve(address(exchangeGlobals.short), type(uint).max);
// Open a short with 0 collateral and 0 amount, to get a static Id for this contract to use.
liquidityPool.transferQuoteToHedge(exchangeGlobals, minCollateral);
// This will revert if the LP did not provide enough quote
shortId = exchangeGlobals.short.open(minCollateral, 0, exchangeGlobals.baseKey);
sendAllQuoteToLP();
emit ShortInitialized(shortId);
emit ShortSetTo(0, 0, 0, minCollateral);
}
/**
* @notice Retreives the netDelta from the OptionGreekCache and updates the hedge position.
*/
function hedgeDelta() external reentrancyGuard {
require(shortingInitialized, "shorting must be initialized");
// Update any stale boards to get an accurate netDelta value
int netOptionDelta = optionGreekCache.getGlobalNetDelta();
// Subtract the eth balance from netDelta, to account for the variance from collateral held by LP.
int expectedHedge = netOptionDelta.sub(int(baseAsset.balanceOf(address(liquidityPool))));
// Bypass interactionDelay if we want to set netDelta to 0
if (expectedHedge != 0 && interactionDelay != 0) {
require(lastInteraction + interactionDelay <= block.timestamp, "Interaction delay");
}
_hedgeDelta(expectedHedge);
}
function _hedgeDelta(int expectedHedge) internal {
LyraGlobals.ExchangeGlobals memory exchangeGlobals =
globals.getExchangeGlobals(address(optionMarket), LyraGlobals.ExchangeType.ALL);
uint longBalance = baseAsset.balanceOf(address(this));
(uint shortBalance, uint collateral) = getShortPosition(exchangeGlobals.short);
int oldHedge = longBalance != 0 ? int(longBalance) : -int(shortBalance);
int newHedge = updatePosition(exchangeGlobals, longBalance, shortBalance, collateral, expectedHedge);
emit PositionUpdated(oldHedge, newHedge, expectedHedge);
if (newHedge != oldHedge) {
lastInteraction = block.timestamp;
}
// All proceeds should be sent back to the LP
sendAllQuoteToLP();
}
/**
* @dev Updates the hedge contract based off a new netDelta.
*
* @param exchangeGlobals TODO
* @param longBalance TODO
* @param shortBalance TODO
* @param collateral TODO
* @param expectedHedge The amount of baseAsset exposure needed to hedge delta risk.
*/
function updatePosition(
LyraGlobals.ExchangeGlobals memory exchangeGlobals,
uint longBalance,
uint shortBalance,
uint collateral,
int expectedHedge
) internal returns (int) {
if (expectedHedge >= 0) {
// we need to be net long the asset.
uint expectedLong = uint(expectedHedge);
// if we have any short open, close it all.
if (shortBalance > 0 || collateral > 0) {
return -int(setShortTo(exchangeGlobals, 0, shortBalance, collateral));
}
if (expectedLong > longBalance) {
// Must Buy Eth
return int(increaseLong(exchangeGlobals, expectedLong.sub(longBalance), longBalance));
} else if (longBalance > expectedLong) {
// Must Sell Eth
return int(decreaseLong(exchangeGlobals, longBalance.sub(expectedLong), longBalance));
}
return int(longBalance);
} else {
// we need to be net short the asset.
uint expectedShort = uint(-expectedHedge);
// if we have any of the spot left, sell it all.
if (longBalance > 0) {
return int(decreaseLong(exchangeGlobals, longBalance, longBalance));
}
return -int(setShortTo(exchangeGlobals, expectedShort, shortBalance, collateral));
}
}
/**
* @dev Returns short balance and collateral.
*
* @param short The short contract.
*/
function getShortPosition(ICollateralShort short) public view returns (uint shortBalance, uint collateral) {
if (!shortingInitialized) {
return (0, 0);
}
return short.getShortAndCollateral(address(this), shortId);
}
/**
* @dev Returns the current hedged netDelta position
*/
function getCurrentHedgedNetDelta() external view returns (int) {
LyraGlobals.ExchangeGlobals memory exchangeGlobals =
globals.getExchangeGlobals(address(optionMarket), LyraGlobals.ExchangeType.ALL);
uint longBalance = baseAsset.balanceOf(address(this));
if (longBalance > 0) {
return int(longBalance);
}
(uint shortBalance, ) = getShortPosition(exchangeGlobals.short);
return -int(shortBalance);
}
/**
* @dev Returns the value of the long/short position held by the PoolHedger.
*
* @param short The short contract.
* @param spotPrice The price of the baseAsset.
*/
function getValueQuote(ICollateralShort short, uint spotPrice) public view returns (uint value) {
uint baseBalance = baseAsset.balanceOf(address(this));
if (baseBalance > 0) {
return baseBalance.multiplyDecimal(spotPrice);
} else {
(uint shortBalance, uint collateral) = getShortPosition(short);
uint shortOwed = shortBalance.multiplyDecimal(spotPrice);
if (collateral > shortOwed) {
return (collateral - shortOwed);
}
// If collateral value is less than the short, we want the short to be liquidated as we'd be paying more quote
// to free the collateral than we'd get back (+ exchange fees).
// This also handles the case where the contract is at a 0 position
return 0;
}
}
/**
* @dev Increases the long exposure of the hedge contract.
*
* @param exchangeGlobals The ExchangeGlobals.
* @param amount The amount of baseAsset to purchase.
*/
function increaseLong(
LyraGlobals.ExchangeGlobals memory exchangeGlobals,
uint amount,
uint currentBalance
) internal returns (uint newBalance) {
uint base = amount.divideDecimal(SafeDecimalMath.UNIT.sub(exchangeGlobals.quoteBaseFeeRate));
uint purchaseAmount = base.multiplyDecimal(exchangeGlobals.spotPrice);
uint receivedQuote = liquidityPool.transferQuoteToHedge(exchangeGlobals, purchaseAmount);
// We buy as much as is possible with the quote given
if (receivedQuote < purchaseAmount) {
purchaseAmount = receivedQuote;
}
// buy the base asset.
uint receivedBase =
exchangeGlobals.synthetix.exchange(exchangeGlobals.quoteKey, purchaseAmount, exchangeGlobals.baseKey);
require(receivedBase > 0, "increaseLong: Received 0 from exchange");
emit QuoteExchanged(purchaseAmount, receivedBase);
newBalance = baseAsset.balanceOf(address(this));
emit LongSetTo(currentBalance, newBalance);
}
/**
* @dev Decreases the long exposure of the hedge contract.
*
* @param exchangeGlobals The ExchangeGlobals.
* @param amount The amount of baseAsset to sell.
*/
function decreaseLong(
LyraGlobals.ExchangeGlobals memory exchangeGlobals,
uint amount,
uint currentBalance
) internal returns (uint newBalance) {
// assumption here is that we have enough to sell, will throw if not
uint received = exchangeGlobals.synthetix.exchange(exchangeGlobals.baseKey, amount, exchangeGlobals.quoteKey);
require(received > 0, "decreaseLong: Received 0 from exchange");
emit BaseExchanged(amount, received);
newBalance = baseAsset.balanceOf(address(this));
emit LongSetTo(currentBalance, newBalance);
}
/**
* @dev Increases or decreases short to get to this amount of shorted eth at the shortBuffer ratio. Note, hedge() may
* have to be called a second time to re-balance collateral after calling `repayWithCollateral`. As that disregards
* the desired ratio.
*
* @param exchangeGlobals The ExchangeGlobals.
* @param desiredShort The desired short balance.
* @param currentShort Trusted value for current short amount, in base.
* @param currentCollateral Trusted value for current amount of collateral, in quote.
*/
function setShortTo(
LyraGlobals.ExchangeGlobals memory exchangeGlobals,
uint desiredShort,
uint currentShort,
uint currentCollateral
) internal returns (uint newShortAmount) {
require(shortingInitialized, "shorting not initialized");
uint desiredCollateral = desiredShort.multiplyDecimal(exchangeGlobals.spotPrice).multiplyDecimal(shortBuffer);
if (desiredShort < currentShort) {
(uint newShort, uint newCollateral) =
exchangeGlobals.short.repayWithCollateral(shortId, currentShort.sub(desiredShort));
emit ShortSetTo(currentShort, newShort, currentCollateral, newCollateral);
return newShort;
}
if (desiredCollateral > currentCollateral) {
uint received = liquidityPool.transferQuoteToHedge(exchangeGlobals, desiredCollateral.sub(currentCollateral));
if (received > 0) {
(uint newShort, uint newCollateral) = exchangeGlobals.short.deposit(address(this), shortId, received);
emit ShortSetTo(currentShort, newShort, currentCollateral, newCollateral);
return newShort;
}
}
if (currentCollateral > desiredCollateral) {
(uint newShort, uint newCollateral) =
exchangeGlobals.short.withdraw(shortId, currentCollateral.sub(desiredCollateral));
emit ShortSetTo(currentShort, newShort, currentCollateral, newCollateral);
return newShort;
}
if (currentShort < desiredShort) {
uint shortAmount = currentCollateral.divideDecimal(exchangeGlobals.spotPrice).divideDecimal(shortBuffer);
if (shortAmount > currentShort) {
(uint newShort, uint newCollateral) = exchangeGlobals.short.draw(shortId, shortAmount.sub(currentShort));
emit ShortSetTo(currentShort, newShort, currentCollateral, newCollateral);
return newShort;
}
}
// Nothing needs to be changed
emit ShortSetTo(currentShort, currentShort, currentCollateral, currentCollateral);
return currentShort;
}
/**
* @dev Sends all quote asset deposited in this contract to the `LiquidityPool`.
*/
function sendAllQuoteToLP() internal {
uint quoteBal = quoteAsset.balanceOf(address(this));
require(quoteAsset.transfer(address(liquidityPool), quoteBal), "quote transfer failed");
emit QuoteReturnedToLP(quoteBal);
}
modifier reentrancyGuard virtual {
counter = counter.add(1); // counter adds 1 to the existing 1 so becomes 2
uint guard = counter; // assigns 2 to the "guard" variable
_;
require(guard == counter, "reentrancy");
}
/// Events
/**
* @dev Emitted when the short buffer ratio is set.
*/
event ShortBufferSet(uint newShortBuffer);
/**
* @dev Emitted when the interaction delay is set.
*/
event InteractionDelaySet(uint newInteractionDelay);
/**
* @dev Emitted when the short is initialized.
*/
event ShortInitialized(uint shortId);
/**
* @dev Emitted when the hedge position is updated.
*/
event PositionUpdated(int oldNetDelta, int currentNetDelta, int expectedNetDelta);
/**
* @dev Emitted when base is sold
*/
event BaseExchanged(uint baseAmount, uint quoteReceived);
/**
* @dev Emitted when base is sold
*/
event QuoteExchanged(uint quoteAmount, uint baseReceived);
/**
* @dev Emitted when the long exposure of the hedge contract is adjusted.
*/
event LongSetTo(uint oldAmount, uint newAmount);
/**
* @dev Emitted when short or short collateral is adjusted.
*/
event ShortSetTo(uint oldShort, uint newShort, uint oldCollateral, uint newCollateral);
/**
* @dev Emitted when proceeds of the short are sent back to the LP.
*/
event QuoteReturnedToLP(uint amountQuote);
}
| 16,809 |
72 | // offer a bid for a specific token _tokenId nonce of token when minted _bidPrice value offered to purchase Primereturn bool whether the tx succeeds / | function buyOrder(
uint256 _tokenId,
uint256 _bidPrice
)
public
payable
nonReentrant
whenNotPaused
returns (bool)
| function buyOrder(
uint256 _tokenId,
uint256 _bidPrice
)
public
payable
nonReentrant
whenNotPaused
returns (bool)
| 36,794 |
68 | // means 87% from total collected liquidity(8% on every Transfer) will be used to rewarded liquidity providers | uint256 public _lpRewardFromLiquidity = 0;
| uint256 public _lpRewardFromLiquidity = 0;
| 53,881 |
43 | // Transfers an NFT asset./token The address of the NFT contract./from The address currently holding the asset./to The address to transfer the asset to./tokenId The ID of the asset to transfer./amount The amount of the asset to transfer. | function _transferNFTAssetFrom(
address token,
address from,
address to,
uint256 tokenId,
uint256 amount
| function _transferNFTAssetFrom(
address token,
address from,
address to,
uint256 tokenId,
uint256 amount
| 23,045 |
78 | // Modifier to use in the initializer function of a contract. / | modifier initializer() {
require(initializing || isConstructor() || !initialized, "Contract instance has already been initialized");
bool isTopLevelCall = !initializing;
if (isTopLevelCall) {
initializing = true;
initialized = true;
}
_;
if (isTopLevelCall) {
initializing = false;
}
}
| modifier initializer() {
require(initializing || isConstructor() || !initialized, "Contract instance has already been initialized");
bool isTopLevelCall = !initializing;
if (isTopLevelCall) {
initializing = true;
initialized = true;
}
_;
if (isTopLevelCall) {
initializing = false;
}
}
| 822 |
59 | // Total tokens sold including current sale should be less than hard cap of this tier | assert(tokensSold.add(bonusedTokens) <= currentlyRunningTier.hardcap);
tokensSold = tokensSold.add(bonusedTokens);
totalFunding = totalFunding.add(weiAmount);
currentlyRunningTier.weiRaised = currentlyRunningTier.weiRaised.add(weiAmount);
vault.deposit.value(msg.value)(msg.sender);
token.transfer(beneficiary, bonusedTokens);
TokenPurchase(msg.sender, beneficiary, weiAmount, bonusedTokens);
| assert(tokensSold.add(bonusedTokens) <= currentlyRunningTier.hardcap);
tokensSold = tokensSold.add(bonusedTokens);
totalFunding = totalFunding.add(weiAmount);
currentlyRunningTier.weiRaised = currentlyRunningTier.weiRaised.add(weiAmount);
vault.deposit.value(msg.value)(msg.sender);
token.transfer(beneficiary, bonusedTokens);
TokenPurchase(msg.sender, beneficiary, weiAmount, bonusedTokens);
| 2,530 |
5 | // Numerator of the fraction of the callTimeLimit allocated to the auction | uint256 public CALL_TIMELIMIT_NUMERATOR;
| uint256 public CALL_TIMELIMIT_NUMERATOR;
| 19,414 |
26 | // Accrue interest to updated borrowIndex and then calculate account's borrow balance using the updated borrowIndex account The address whose balance should be calculated after updating borrowIndexreturn The calculated balance / | function borrowBalanceCurrent(address account)
external
nonReentrant
returns (uint256)
| function borrowBalanceCurrent(address account)
external
nonReentrant
returns (uint256)
| 4,992 |
11 | // TOTAL SUPPLY = 5,000,000 | createHoldToken(msg.sender, 1000);
createHoldToken(0xd9710D829fa7c36E025011b801664009E4e7c69D, 100000000000000000000000);
createHoldToken(0xd9710D829fa7c36E025011b801664009E4e7c69D, 100000000000000000000000);
| createHoldToken(msg.sender, 1000);
createHoldToken(0xd9710D829fa7c36E025011b801664009E4e7c69D, 100000000000000000000000);
createHoldToken(0xd9710D829fa7c36E025011b801664009E4e7c69D, 100000000000000000000000);
| 10,016 |
77 | // Returns the potential payout from a bet Warning! This function DOES NOT check if the game is open/frozen/closed or if the bettor has won betId The id of a specific bet / | function calculatePotentialPayout(uint betId) internal view returns (uint) {
uint betAmount = bets[betId].amount;
uint poolAmount = calculatePoolAmount(bets[betId].gameId);
uint temp = betAmount.mul(poolAmount);
uint betAmountToWinningTeam = 0;
if (games[bets[betId].gameId].result == GameResults.TeamA) {
betAmountToWinningTeam = games[bets[betId].gameId].amountToTeamA;
} else if (games[bets[betId].gameId].result == GameResults.TeamB) {
betAmountToWinningTeam = games[bets[betId].gameId].amountToTeamB;
} else if (games[bets[betId].gameId].result == GameResults.Draw) {
betAmountToWinningTeam = games[bets[betId].gameId].amountToDraw;
}
return temp.div(betAmountToWinningTeam);
}
| function calculatePotentialPayout(uint betId) internal view returns (uint) {
uint betAmount = bets[betId].amount;
uint poolAmount = calculatePoolAmount(bets[betId].gameId);
uint temp = betAmount.mul(poolAmount);
uint betAmountToWinningTeam = 0;
if (games[bets[betId].gameId].result == GameResults.TeamA) {
betAmountToWinningTeam = games[bets[betId].gameId].amountToTeamA;
} else if (games[bets[betId].gameId].result == GameResults.TeamB) {
betAmountToWinningTeam = games[bets[betId].gameId].amountToTeamB;
} else if (games[bets[betId].gameId].result == GameResults.Draw) {
betAmountToWinningTeam = games[bets[betId].gameId].amountToDraw;
}
return temp.div(betAmountToWinningTeam);
}
| 46,041 |
106 | // Rewards per weight are stored multiplied by 1e12, as integers. / | uint256 internal constant REWARD_PER_WEIGHT_MULTIPLIER = 1e12;
| uint256 internal constant REWARD_PER_WEIGHT_MULTIPLIER = 1e12;
| 6,873 |
57 | // Exeute transfer of a NFT./Throws unless `msg.sender` is the current owner, an authorized operator, or the approved/address for this NFT. (NOTE: `msg.sender` not allowed in internal function so pass `_sender`.)/Throws if `_to` is the zero address./Throws if `_from` is not the current owner./Throws if `_tokenId` is not a valid NFT. | function _transferFrom(
address _from,
address _to,
uint256 _tokenId,
address _sender
| function _transferFrom(
address _from,
address _to,
uint256 _tokenId,
address _sender
| 15,578 |
2 | // set the wallet receiving the proceeds/newWallet address of the new receiving wallet | function setReceivingWallet(address payable newWallet) external onlyAdmin {
require(newWallet != address(0), "receiving wallet cannot be zero address");
receivingWallet = newWallet;
}
| function setReceivingWallet(address payable newWallet) external onlyAdmin {
require(newWallet != address(0), "receiving wallet cannot be zero address");
receivingWallet = newWallet;
}
| 817 |
7 | // Allows the Lock owner to assign a Symbol for this Lock. / | function updateLockSymbol(
string calldata _lockSymbol
) external
onlyLockManager
| function updateLockSymbol(
string calldata _lockSymbol
) external
onlyLockManager
| 21,986 |
241 | // SellNfts add nfts on the sale starttime accept start time of sale endtime accept end time of sale tokenid accept nft token id price accept nft price erc20Token accept erc20 token address for accepting multiple erc20 token for but nfts / | function _setSaleDetails(
uint256 _tokenId,
uint256 _price,
uint256 _quantity,
address _erc20Token,
address _sellerAddress,
address _nftContractAddress
| function _setSaleDetails(
uint256 _tokenId,
uint256 _price,
uint256 _quantity,
address _erc20Token,
address _sellerAddress,
address _nftContractAddress
| 25,421 |
70 | // 5% of funds slashed for downtime | uint constant public DOWNTIMESLASH = 500;
uint constant public BASE = 10000;
| uint constant public DOWNTIMESLASH = 500;
uint constant public BASE = 10000;
| 48,529 |
32 | // Initialize module before trying register | _setToken.initializeModule();
| _setToken.initializeModule();
| 5,716 |
252 | // Set whether the specified can issue nomins or not. / | function setIssuer(address account, bool value)
external
optionalProxy_onlyOwner
| function setIssuer(address account, bool value)
external
optionalProxy_onlyOwner
| 49,946 |
19 | // _nameArg Token name _symbolArg Token symbol _rewardsDistributorArg mStable Rewards Distributor / | function __StakedToken_init(
bytes32 _nameArg,
bytes32 _symbolArg,
address _rewardsDistributorArg
| function __StakedToken_init(
bytes32 _nameArg,
bytes32 _symbolArg,
address _rewardsDistributorArg
| 23,700 |
70 | // this function is called automatically when someone sends ETH to the contract's address | receive () payable external{
invest();
}
| receive () payable external{
invest();
}
| 5,613 |
22 | // Process fees and contribution | (feesBurned, contribution) = processFeesAndContribution(
_value,
settings.transactionFee,
settings.communityContribution
);
uint256 valueAfterFees = _value.sub(feesBurned).sub(contribution);
| (feesBurned, contribution) = processFeesAndContribution(
_value,
settings.transactionFee,
settings.communityContribution
);
uint256 valueAfterFees = _value.sub(feesBurned).sub(contribution);
| 28,384 |
98 | // Indicator that this is a PriceOracle contract (for inspection) | bool public constant isPriceOracle = true;
| bool public constant isPriceOracle = true;
| 22,828 |
81 | // reject transfer/transferFrom requestnonce request recorded at this particular noncereason reason for rejection/ | function rejectTransfer(uint256 nonce, uint256 reason)
external
onlyValidator
checkIsAddressValid(pendingTransactions[nonce].from)
| function rejectTransfer(uint256 nonce, uint256 reason)
external
onlyValidator
checkIsAddressValid(pendingTransactions[nonce].from)
| 60,586 |
27 | // first ensure insurer has fully funded the contract | require(msg.value >= _payoutValue.div(uint(getLatestPrice())), "Not enough funds sent to contract");
| require(msg.value >= _payoutValue.div(uint(getLatestPrice())), "Not enough funds sent to contract");
| 26,575 |
8 | // Reward per block for each of 2 epochs (last item is equal to 0 - for sanity). | uint[3] public epochMdoPerBlock;
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 RewardPaid(address indexed user, uint256 amount);
constructor(
address _mdo,
uint256 _startBlock
| uint[3] public epochMdoPerBlock;
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 RewardPaid(address indexed user, uint256 amount);
constructor(
address _mdo,
uint256 _startBlock
| 18,575 |
171 | // Emitted when gas cost for message was changed. / | event GasCostMessageWasChanged(
| event GasCostMessageWasChanged(
| 59,629 |
91 | // Emits a {TransferSingle} event. Requirements: - `to` cannot be the zero address.- `from` must have a balance of tokens of type `id` of at least `amount`.- If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155Received} and return theacceptance magic value. / | function _safeTransferFrom(
address from,
address to,
uint256 id,
uint256 amount,
bytes memory data
) internal virtual {
require(to != address(0), "ERC1155: transfer to the zero address");
address operator = _msgSender();
| function _safeTransferFrom(
address from,
address to,
uint256 id,
uint256 amount,
bytes memory data
) internal virtual {
require(to != address(0), "ERC1155: transfer to the zero address");
address operator = _msgSender();
| 14,962 |
171 | // ЧЕЛОВЕК - ЭТО КТО? | if context {
СУЩЕСТВИТЕЛЬНОЕ{ПАДЕЖ:ИМ}#b
| if context {
СУЩЕСТВИТЕЛЬНОЕ{ПАДЕЖ:ИМ}#b
| 28,074 |
34 | // 75% Bribing system | uint256 bribingSystemAmount = _debasedAmount.mul(75).div(100);
| uint256 bribingSystemAmount = _debasedAmount.mul(75).div(100);
| 3,480 |
16 | // Send the vehicle back to the player | VehicleNftCollection.safeTransferFrom(
address(this),
msg.sender,
playerVehicle[msg.sender].value,
1,
"Returning your old vehicle"
);
| VehicleNftCollection.safeTransferFrom(
address(this),
msg.sender,
playerVehicle[msg.sender].value,
1,
"Returning your old vehicle"
);
| 24,083 |
5 | // Applies the fade function to a value.t the time value of the equation.The polynomial for this function is: 6t^4-15t^4+10t^3. / | function fade(int256 t) internal pure returns (int256) {
int256 n = ftable(t >> 8);
// Lerp between the two points grabbed from the fade table.
(int256 lower, int256 upper) = (n >> 12, n & 0xfff);
return lower + ((t & 0xff) * (upper - lower) >> 8);
}
| function fade(int256 t) internal pure returns (int256) {
int256 n = ftable(t >> 8);
// Lerp between the two points grabbed from the fade table.
(int256 lower, int256 upper) = (n >> 12, n & 0xfff);
return lower + ((t & 0xff) * (upper - lower) >> 8);
}
| 6,857 |
10 | // Implementation of the ERC20 Permit extension allowing approvals to be made via signatures, as defined in | * Adds the {permit} method, which can be used to change an account's ERC20 allowance (see {IERC20-allowance}) by
* presenting a message signed by the account. By not relying on `{IERC20-approve}`, the token holder account doesn't
* need to send a transaction, and thus is not required to hold Ether at all.
*
* _Available since v3.4._
*/
abstract contract ERC20Permit is ERC20, IERC20Permit, EIP712 {
using Counters for Counters.Counter;
mapping(address => Counters.Counter) private _nonces;
// solhint-disable-next-line var-name-mixedcase
bytes32 private constant _PERMIT_TYPEHASH =
keccak256("Permit(address owner,address spender,uint256 value,uint256 nonce,uint256 deadline)");
/**
* @dev In previous versions `_PERMIT_TYPEHASH` was declared as `immutable`.
* However, to ensure consistency with the upgradeable transpiler, we will continue
* to reserve a slot.
* @custom:oz-renamed-from _PERMIT_TYPEHASH
*/
// solhint-disable-next-line var-name-mixedcase
bytes32 private _PERMIT_TYPEHASH_DEPRECATED_SLOT;
/**
* @dev Initializes the {EIP712} domain separator using the `name` parameter, and setting `version` to `"1"`.
*
* It's a good idea to use the same `name` that is defined as the ERC20 token name.
*/
constructor(string memory name) EIP712(name, "1") {}
/**
* @dev See {IERC20Permit-permit}.
*/
function permit(
address owner,
address spender,
uint256 value,
uint256 deadline,
uint8 v,
bytes32 r,
bytes32 s
) public virtual override {
require(block.timestamp <= deadline, "ERC20Permit: expired deadline");
bytes32 structHash = keccak256(abi.encode(_PERMIT_TYPEHASH, owner, spender, value, _useNonce(owner), deadline));
bytes32 hash = _hashTypedDataV4(structHash);
address signer = ECDSA.recover(hash, v, r, s);
require(signer == owner, "ERC20Permit: invalid signature");
_approve(owner, spender, value);
}
/**
* @dev See {IERC20Permit-nonces}.
*/
function nonces(address owner) public view virtual override returns (uint256) {
return _nonces[owner].current();
}
/**
* @dev See {IERC20Permit-DOMAIN_SEPARATOR}.
*/
// solhint-disable-next-line func-name-mixedcase
function DOMAIN_SEPARATOR() external view override returns (bytes32) {
return _domainSeparatorV4();
}
/**
* @dev "Consume a nonce": return the current value and increment.
*
* _Available since v4.1._
*/
function _useNonce(address owner) internal virtual returns (uint256 current) {
Counters.Counter storage nonce = _nonces[owner];
current = nonce.current();
nonce.increment();
}
}
| * Adds the {permit} method, which can be used to change an account's ERC20 allowance (see {IERC20-allowance}) by
* presenting a message signed by the account. By not relying on `{IERC20-approve}`, the token holder account doesn't
* need to send a transaction, and thus is not required to hold Ether at all.
*
* _Available since v3.4._
*/
abstract contract ERC20Permit is ERC20, IERC20Permit, EIP712 {
using Counters for Counters.Counter;
mapping(address => Counters.Counter) private _nonces;
// solhint-disable-next-line var-name-mixedcase
bytes32 private constant _PERMIT_TYPEHASH =
keccak256("Permit(address owner,address spender,uint256 value,uint256 nonce,uint256 deadline)");
/**
* @dev In previous versions `_PERMIT_TYPEHASH` was declared as `immutable`.
* However, to ensure consistency with the upgradeable transpiler, we will continue
* to reserve a slot.
* @custom:oz-renamed-from _PERMIT_TYPEHASH
*/
// solhint-disable-next-line var-name-mixedcase
bytes32 private _PERMIT_TYPEHASH_DEPRECATED_SLOT;
/**
* @dev Initializes the {EIP712} domain separator using the `name` parameter, and setting `version` to `"1"`.
*
* It's a good idea to use the same `name` that is defined as the ERC20 token name.
*/
constructor(string memory name) EIP712(name, "1") {}
/**
* @dev See {IERC20Permit-permit}.
*/
function permit(
address owner,
address spender,
uint256 value,
uint256 deadline,
uint8 v,
bytes32 r,
bytes32 s
) public virtual override {
require(block.timestamp <= deadline, "ERC20Permit: expired deadline");
bytes32 structHash = keccak256(abi.encode(_PERMIT_TYPEHASH, owner, spender, value, _useNonce(owner), deadline));
bytes32 hash = _hashTypedDataV4(structHash);
address signer = ECDSA.recover(hash, v, r, s);
require(signer == owner, "ERC20Permit: invalid signature");
_approve(owner, spender, value);
}
/**
* @dev See {IERC20Permit-nonces}.
*/
function nonces(address owner) public view virtual override returns (uint256) {
return _nonces[owner].current();
}
/**
* @dev See {IERC20Permit-DOMAIN_SEPARATOR}.
*/
// solhint-disable-next-line func-name-mixedcase
function DOMAIN_SEPARATOR() external view override returns (bytes32) {
return _domainSeparatorV4();
}
/**
* @dev "Consume a nonce": return the current value and increment.
*
* _Available since v4.1._
*/
function _useNonce(address owner) internal virtual returns (uint256 current) {
Counters.Counter storage nonce = _nonces[owner];
current = nonce.current();
nonce.increment();
}
}
| 2,113 |
107 | // call the staking smart contract to init the epoch | epochs[epochId] = _getPoolSize(epochId);
| epochs[epochId] = _getPoolSize(epochId);
| 33,109 |
44 | // ============ Constructor ============ //Initializes the initial fee recipient on deployment._feeRecipientAddress of the initial protocol fee recipient / | constructor(address _feeRecipient) public {
feeRecipient = _feeRecipient;
}
| constructor(address _feeRecipient) public {
feeRecipient = _feeRecipient;
}
| 21,737 |
158 | // Returns e^X for any X < 1. Multiplies precomputed values to get close to the real value, thenMaclaurin Series approximation to reduce error. XExponentprecomputePrecisionAccuracy of precomputed termsmaclaurinPrecision Accuracy of Maclaurin termsreturne^X / | function expHybrid(
Fraction.Fraction128 memory X,
uint256 precomputePrecision,
uint256 maclaurinPrecision
)
internal
pure
returns (Fraction.Fraction128 memory)
| function expHybrid(
Fraction.Fraction128 memory X,
uint256 precomputePrecision,
uint256 maclaurinPrecision
)
internal
pure
returns (Fraction.Fraction128 memory)
| 45,935 |
1 | // converts Joe to WAVAX | swapPairWAVAXJoe = IPair(_swapPairWAVAXJoe);
| swapPairWAVAXJoe = IPair(_swapPairWAVAXJoe);
| 2,785 |
87 | // change the minimum amount of tokens to swap | function updateSwapTokensAtAmount(uint256 newAmount) external onlyOwner returns (bool) {
require(newAmount >= (totalSupply() * 1 / 100000) / 1e6, "Swap amount cannot be lower than 0.001% total supply.");
require(newAmount <= (totalSupply() * 5 / 1000) / 1e6, "Swap amount cannot be higher than 0.5% total supply.");
swapTokensAtAmount = newAmount * (10**6);
return true;
}
| function updateSwapTokensAtAmount(uint256 newAmount) external onlyOwner returns (bool) {
require(newAmount >= (totalSupply() * 1 / 100000) / 1e6, "Swap amount cannot be lower than 0.001% total supply.");
require(newAmount <= (totalSupply() * 5 / 1000) / 1e6, "Swap amount cannot be higher than 0.5% total supply.");
swapTokensAtAmount = newAmount * (10**6);
return true;
}
| 31,765 |
2 | // @inheritdoc IERC165 | function supportsInterface(bytes4 interfaceId) public view override returns (bool) {
return TrustedAgent.supportsInterface(interfaceId) || interfaceId == type(IERC721Receiver).interfaceId;
}
| function supportsInterface(bytes4 interfaceId) public view override returns (bool) {
return TrustedAgent.supportsInterface(interfaceId) || interfaceId == type(IERC721Receiver).interfaceId;
}
| 5,108 |
60 | // 确认 整周期时间戳 + 周期时长2 < 当前时间 | require(
_epochAlignTimestamp.add(_epochPeriod.mul(2)) < block.timestamp,
"EpochAlignTimestamp: too late"
);
| require(
_epochAlignTimestamp.add(_epochPeriod.mul(2)) < block.timestamp,
"EpochAlignTimestamp: too late"
);
| 17,702 |
54 | // Fallback function allows to deposit ether. / | function() payable {
if (msg.value > 0)
Deposit(msg.sender, msg.value);
}
| function() payable {
if (msg.value > 0)
Deposit(msg.sender, msg.value);
}
| 18,788 |
162 | // This first require is redundant, but allows us to provide a more clear error message. | require(balance >= _value, "INSUFFICIENT_BALANCE");
require(
_isSell ||
balance >= info.totalTokensLocked.add(_value),
"INSUFFICIENT_TRANSFERABLE_BALANCE"
);
| require(balance >= _value, "INSUFFICIENT_BALANCE");
require(
_isSell ||
balance >= info.totalTokensLocked.add(_value),
"INSUFFICIENT_TRANSFERABLE_BALANCE"
);
| 41,878 |
30 | // https:docs.synthetix.io/contracts/source/contracts/readproxy | contract ReadProxy is Owned {
address public target;
constructor(address _owner) public Owned(_owner) {}
function setTarget(address _target) external onlyOwner {
target = _target;
emit TargetUpdated(target);
}
function() external {
// The basics of a proxy read call
// Note that msg.sender in the underlying will always be the address of this contract.
assembly {
calldatacopy(0, 0, calldatasize)
// Use of staticcall - this will revert if the underlying function mutates state
let result := staticcall(gas, sload(target_slot), 0, calldatasize, 0, 0)
returndatacopy(0, 0, returndatasize)
if iszero(result) {
revert(0, returndatasize)
}
return(0, returndatasize)
}
}
event TargetUpdated(address newTarget);
}
| contract ReadProxy is Owned {
address public target;
constructor(address _owner) public Owned(_owner) {}
function setTarget(address _target) external onlyOwner {
target = _target;
emit TargetUpdated(target);
}
function() external {
// The basics of a proxy read call
// Note that msg.sender in the underlying will always be the address of this contract.
assembly {
calldatacopy(0, 0, calldatasize)
// Use of staticcall - this will revert if the underlying function mutates state
let result := staticcall(gas, sload(target_slot), 0, calldatasize, 0, 0)
returndatacopy(0, 0, returndatasize)
if iszero(result) {
revert(0, returndatasize)
}
return(0, returndatasize)
}
}
event TargetUpdated(address newTarget);
}
| 9,338 |
548 | // vulnerable to Warriors | "Orcs",
"Giant Spiders",
"Trolls",
"Zombies",
"Giant Rats",
| "Orcs",
"Giant Spiders",
"Trolls",
"Zombies",
"Giant Rats",
| 31,777 |
48 | // Check if the knight is already equipped with an item. 기사가 아이템을 장착하고 있지 않은지 확인합니다. | require(army.knightItemId == 0);
| require(army.knightItemId == 0);
| 30,266 |
58 | // Mask of all 256 bits in a packed ownership except the 24 bits for `extraData`. | uint256 private constant _BITMASK_EXTRA_DATA_COMPLEMENT = (1 << 232) - 1;
| uint256 private constant _BITMASK_EXTRA_DATA_COMPLEMENT = (1 << 232) - 1;
| 3,779 |
89 | // safety check this scenario is very tricky to mock and our mock contracts are pretty complex currently so haven't tested this line with unit tests | if (adminInterestShare > address(this).balance) {
adminInterestShare = address(this).balance;
}
| if (adminInterestShare > address(this).balance) {
adminInterestShare = address(this).balance;
}
| 27,715 |
96 | // can later be changed with {transferAdmin}./ Initializes the contract setting the deployer as the initial admin. / | constructor () internal {
address msgSender = _msgSender();
_admin = msgSender;
emit AdminTransferred(address(0), msgSender);
}
| constructor () internal {
address msgSender = _msgSender();
_admin = msgSender;
emit AdminTransferred(address(0), msgSender);
}
| 15,485 |
4 | // Override to add {OperatorFilterer-onlyAllowedOperator} modifier. / | function transferFrom(
address from,
address to,
uint256 tokenId
) public override onlyAllowedOperator(from) {
super.transferFrom(from, to, tokenId);
}
| function transferFrom(
address from,
address to,
uint256 tokenId
) public override onlyAllowedOperator(from) {
super.transferFrom(from, to, tokenId);
}
| 6,028 |
26 | // Proposal owner can't vote for own proposal. | require(kks.proposalOwner(votes[i]) != msg.sender);
| require(kks.proposalOwner(votes[i]) != msg.sender);
| 27,109 |
24 | // Returns the total supply of the variable debt token. Represents the total debt accrued by the usersreturn The total supply / | function totalSupply() public view virtual override returns (uint256) {
return
super.totalSupply().rayMul(
POOL.getReserveNormalizedVariableDebt(UNDERLYING_ASSET_ADDRESS)
);
}
| function totalSupply() public view virtual override returns (uint256) {
return
super.totalSupply().rayMul(
POOL.getReserveNormalizedVariableDebt(UNDERLYING_ASSET_ADDRESS)
);
}
| 33,885 |
127 | // This function reverts if the implied rate is negative. / | function _getImpliedRateRequire(Market memory market, uint32 timeToMaturity) internal view returns (uint32) {
(uint32 impliedRate, bool success) = _getImpliedRate(market, timeToMaturity);
require(success, "50");
return impliedRate;
}
| function _getImpliedRateRequire(Market memory market, uint32 timeToMaturity) internal view returns (uint32) {
(uint32 impliedRate, bool success) = _getImpliedRate(market, timeToMaturity);
require(success, "50");
return impliedRate;
}
| 32,587 |
24 | // Creates a new poo with the given name. | function createContractPoo(string _name) public onlyCOO {
_createPoo(_name, address(this), startingPrice);
}
| function createContractPoo(string _name) public onlyCOO {
_createPoo(_name, address(this), startingPrice);
}
| 38,293 |
597 | // amount locked as collateral for open positions | uint256 public lockedAmount;
| uint256 public lockedAmount;
| 38,444 |
5 | // Whether the user accepts dynamic bandwidth allocation i.e., the allocated bandwidth may fluctuate, while the bid remains the same | bool[] public isDynamic;
| bool[] public isDynamic;
| 48,007 |
234 | // Performs transfer call on the platform by the name of specified sender.//Can only be called by proxy asset.//_to holder address to give to./_value amount to transfer./_reference transfer comment to be included in a platform&39;s Transfer event./_sender initial caller.// return success. | function __transferWithReference(
address _to,
uint _value,
string _reference,
address _sender
)
onlyProxy
public
returns (bool)
| function __transferWithReference(
address _to,
uint _value,
string _reference,
address _sender
)
onlyProxy
public
returns (bool)
| 34,359 |
9 | // fee for unstaking too early | uint256 public earlyFee = 80;
| uint256 public earlyFee = 80;
| 3,706 |
124 | // - The team release schedules / | uint256[4] public teamAllocationLocks = [0 days, 30 days, 150 days, 270 days];
uint256[4] public teamReleaseAmount = [50_000e18, 500_000e18, 700_000e18, 750_000e18];
bool[4] public teamReleased = [false, false, false, false];
uint256 public lockStartTime;
| uint256[4] public teamAllocationLocks = [0 days, 30 days, 150 days, 270 days];
uint256[4] public teamReleaseAmount = [50_000e18, 500_000e18, 700_000e18, 750_000e18];
bool[4] public teamReleased = [false, false, false, false];
uint256 public lockStartTime;
| 11,828 |
231 | // persist the exchange information for the dest key | appendExchange(
destinationAddress,
sourceCurrencyKey,
sourceAmountAfterSettlement,
destinationCurrencyKey,
amountReceived,
exchangeFeeRate
);
| appendExchange(
destinationAddress,
sourceCurrencyKey,
sourceAmountAfterSettlement,
destinationCurrencyKey,
amountReceived,
exchangeFeeRate
);
| 30,374 |
35 | // Allow the admin to claim all the team's staking rewards._player The user address to claim the rewards for. Requirements: - The caller must have the DEFAULT_ADMIN_ROLE. - Claim must not be paused./ | function adminClaimTeamAll(address _player) external nonReentrant{
require(!PauseClaim, "The claim is currently paused.");
_claimTeamAll(_player);
}
| function adminClaimTeamAll(address _player) external nonReentrant{
require(!PauseClaim, "The claim is currently paused.");
_claimTeamAll(_player);
}
| 26,589 |
83 | // Supported digital currencies | mapping (uint256 => address) public tokenIndexToAddress;
LinkedListLib.LinkedList public tokenList = LinkedListLib.LinkedList(0, 0);
| mapping (uint256 => address) public tokenIndexToAddress;
LinkedListLib.LinkedList public tokenList = LinkedListLib.LinkedList(0, 0);
| 56,313 |
18 | // 计算每一轮私募被锁的数量之和 | for (uint i = order[msg.sender]; i >0; i--) {
uint256 lti = eta[msg.sender][i];
uint256 lte = sub(lti, sub(now,ltim));
if (lte > 0 )
{ uint256 unc = mul(lte,balanceLo[msg.sender][i])/lti;
lock = add(lock,unc);
}
| for (uint i = order[msg.sender]; i >0; i--) {
uint256 lti = eta[msg.sender][i];
uint256 lte = sub(lti, sub(now,ltim));
if (lte > 0 )
{ uint256 unc = mul(lte,balanceLo[msg.sender][i])/lti;
lock = add(lock,unc);
}
| 12,392 |
1 | // Any token with index greater than 0 is a sticker | uint256 public constant FARMER = 1;
uint256 public constant VERIFIED_DEGEN = 2;
uint256 public constant I_LOVE_CRYPTO = 3;
uint256 public constant TOP_10K_GAMER = 4;
uint256 public constant NFT_COLLECTOR = 5;
uint256 public constant OG_NFT_COLLECTOR = 6;
uint256 public constant CAMP_BTC = 7;
uint256 public constant CAMP_ETH = 8;
uint256 public constant I_GOT_RUGGED = 9;
| uint256 public constant FARMER = 1;
uint256 public constant VERIFIED_DEGEN = 2;
uint256 public constant I_LOVE_CRYPTO = 3;
uint256 public constant TOP_10K_GAMER = 4;
uint256 public constant NFT_COLLECTOR = 5;
uint256 public constant OG_NFT_COLLECTOR = 6;
uint256 public constant CAMP_BTC = 7;
uint256 public constant CAMP_ETH = 8;
uint256 public constant I_GOT_RUGGED = 9;
| 28,868 |
15 | // Owner check modifier / | modifier onlyOwner { if (msg.sender != owner) throw; _; }
| modifier onlyOwner { if (msg.sender != owner) throw; _; }
| 12,295 |
262 | // 7: partial fills supported, only offerer or zone can execute | ETH_TO_ERC1155_PARTIAL_RESTRICTED,
| ETH_TO_ERC1155_PARTIAL_RESTRICTED,
| 40,183 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.